{"commit":"21071cdf683a6b58722553aa9d403aaea3f73365","subject":"Rewrite port for Varnish PURGE requests","message":"Rewrite port for Varnish PURGE requests\n\nBug: T54302\nChange-Id: Ieb6a9ab49962fb76ddfd393949e53b7d1d24b9f3\n","repos":"stuartbman\/mediawiki-vagrant,stuartbman\/mediawiki-vagrant,stuartbman\/mediawiki-vagrant,HarriAlasi\/wiki3dviewer,wikimedia\/mediawiki-vagrant,HarriAlasi\/wiki3dviewer,wikimedia\/mediawiki-vagrant,stuartbman\/mediawiki-vagrant,stuartbman\/mediawiki-vagrant,HarriAlasi\/wiki3dviewer,wikimedia\/mediawiki-vagrant,HarriAlasi\/wiki3dviewer,wikimedia\/mediawiki-vagrant,wikimedia\/mediawiki-vagrant,HarriAlasi\/wiki3dviewer,stuartbman\/mediawiki-vagrant,stuartbman\/mediawiki-vagrant,HarriAlasi\/wiki3dviewer,HarriAlasi\/wiki3dviewer,wikimedia\/mediawiki-vagrant","old_file":"puppet\/modules\/varnish\/files\/default-subs.vcl","new_file":"puppet\/modules\/varnish\/files\/default-subs.vcl","new_contents":"# vcl_recv is called whenever a request is received\nsub vcl_recv {\n # Serve objects up to 2 minutes past their expiry if the backend\n # is slow to respond.\n set req.grace = 120s;\n set req.http.X-Forwarded-For = client.ip;\n\n # Since we expose varnish on the default port (6081) we need to rewrite\n # requests that are generated using the default wiki port (8080)\n # This needs to be done early because it's needed for PURGE calls\n if (req.url ~ \":8080\") {\n set req.url = regsub(req.url, \"(.*):8080\/(.*)\", \"\\1:6081\/\\2\");\n }\n\n # This uses the ACL action called \"purge\". Basically if a request to\n # PURGE the cache comes from anywhere other than localhost, ignore it.\n if (req.request == \"PURGE\") {\n if (!client.ip ~ purge) {\n error 405 \"Not allowed.\";\n }\n return(lookup);\n }\n\n # Pass any requests that Varnish does not understand straight to the backend.\n if (req.request != \"GET\" && req.request != \"HEAD\" &&\n req.request != \"PUT\" && req.request != \"POST\" &&\n req.request != \"TRACE\" && req.request != \"OPTIONS\" &&\n req.request != \"DELETE\") {\n return(pipe); \/* Non-RFC2616 or CONNECT which is weird. *\/\n }\n\n # Pass anything other than GET and HEAD directly.\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n return(pass);\n }\n\n # Pretend that image requests don't have cookie\/auth, so that they get cached\n if (req.url ~ \"^\/images\/\") {\n unset req.http.Authorization;\n unset req.http.Cookie;\n }\n\n # Pass requests from logged-in users directly.\n if (req.http.Authorization || req.http.Cookie ~ \"wikiUserID=\") {\n return(pass);\n }\n\n # Pass any requests with the \"If-None-Match\" header directly.\n if (req.http.If-None-Match) {\n return(pass);\n }\n\n # Force lookup if the request is a no-cache request from the client.\n if (req.http.Cache-Control ~ \"no-cache\") {\n ban_url(req.url);\n }\n\n # Pass requests to potential non-plain reads on articles (eg. action=edit)\n if (req.url ~ \"^\/w\/index\\.php\" || req.url ~ \"^\/\\?title=\") {\n return(pass);\n }\n\n # normalize Accept-Encoding to reduce vary\n if (req.http.Accept-Encoding) {\n if (req.http.User-Agent ~ \"MSIE 6\") {\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n\n return(lookup);\n}\n\nsub vcl_pipe {\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n # set req.http.connection = \"close\";\n\n # This is otherwise not necessary if you do not do any request rewriting.\n\n set req.http.connection = \"close\";\n}\n\n# Called if the cache has a copy of the page.\nsub vcl_hit {\n if (req.request == \"PURGE\") {\n ban_url(req.url);\n error 200 \"Purged\";\n }\n\n if (!obj.ttl > 0s) {\n return(pass);\n }\n}\n\n# Called if the cache does not have a copy of the page.\nsub vcl_miss {\n if (req.request == \"PURGE\") {\n error 200 \"Not in cache\";\n }\n}\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"hit (\" + obj.hits + \")\";\n } else {\n set resp.http.X-Cache = \"miss (0)\";\n }\n}\n\n# Called after a document has been successfully retrieved from the backend.\nsub vcl_fetch {\n\n # set minimum timeouts to auto-discard stored objects\n# set beresp.prefetch = -30s;\n set beresp.grace = 120s;\n\n if (beresp.ttl < 48h) {\n set beresp.ttl = 48h;\n }\n\n if (!beresp.ttl > 0s) {\n return(hit_for_pass);\n }\n\n if (beresp.http.Set-Cookie) {\n return(hit_for_pass);\n }\n\n# if (beresp.http.Cache-Control ~ \"(private|no-cache|no-store)\")\n# {return(hit_for_pass);}\n\n if (req.http.Authorization && !beresp.http.Cache-Control ~ \"public\") {\n return(hit_for_pass);\n }\n}\n","old_contents":"# vcl_recv is called whenever a request is received\nsub vcl_recv {\n # Serve objects up to 2 minutes past their expiry if the backend\n # is slow to respond.\n set req.grace = 120s;\n set req.http.X-Forwarded-For = client.ip;\n\n # This uses the ACL action called \"purge\". Basically if a request to\n # PURGE the cache comes from anywhere other than localhost, ignore it.\n if (req.request == \"PURGE\") {\n if (!client.ip ~ purge) {\n error 405 \"Not allowed.\";\n }\n return(lookup);\n }\n\n # Pass any requests that Varnish does not understand straight to the backend.\n if (req.request != \"GET\" && req.request != \"HEAD\" &&\n req.request != \"PUT\" && req.request != \"POST\" &&\n req.request != \"TRACE\" && req.request != \"OPTIONS\" &&\n req.request != \"DELETE\") {\n return(pipe); \/* Non-RFC2616 or CONNECT which is weird. *\/\n }\n\n # Pass anything other than GET and HEAD directly.\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n return(pass);\n }\n\n # Pretend that image requests don't have cookie\/auth, so that they get cached\n if (req.url ~ \"^\/images\/\") {\n unset req.http.Authorization;\n unset req.http.Cookie;\n }\n\n # Pass requests from logged-in users directly.\n if (req.http.Authorization || req.http.Cookie ~ \"wikiUserID=\") {\n return(pass);\n }\n\n # Pass any requests with the \"If-None-Match\" header directly.\n if (req.http.If-None-Match) {\n return(pass);\n }\n\n # Force lookup if the request is a no-cache request from the client.\n if (req.http.Cache-Control ~ \"no-cache\") {\n ban_url(req.url);\n }\n\n # Pass requests to potential non-plain reads on articles (eg. action=edit)\n if (req.url ~ \"^\/w\/index\\.php\" || req.url ~ \"^\/\\?title=\") {\n return(pass);\n }\n\n # normalize Accept-Encoding to reduce vary\n if (req.http.Accept-Encoding) {\n if (req.http.User-Agent ~ \"MSIE 6\") {\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n\n return(lookup);\n}\n\nsub vcl_pipe {\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n # set req.http.connection = \"close\";\n\n # This is otherwise not necessary if you do not do any request rewriting.\n\n set req.http.connection = \"close\";\n}\n\n# Called if the cache has a copy of the page.\nsub vcl_hit {\n if (req.request == \"PURGE\") {\n ban_url(req.url);\n error 200 \"Purged\";\n }\n\n if (!obj.ttl > 0s) {\n return(pass);\n }\n}\n\n# Called if the cache does not have a copy of the page.\nsub vcl_miss {\n if (req.request == \"PURGE\") {\n error 200 \"Not in cache\";\n }\n}\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"hit (\" + obj.hits + \")\";\n } else {\n set resp.http.X-Cache = \"miss (0)\";\n }\n}\n\n# Called after a document has been successfully retrieved from the backend.\nsub vcl_fetch {\n\n # set minimum timeouts to auto-discard stored objects\n# set beresp.prefetch = -30s;\n set beresp.grace = 120s;\n\n if (beresp.ttl < 48h) {\n set beresp.ttl = 48h;\n }\n\n if (!beresp.ttl > 0s) {\n return(hit_for_pass);\n }\n\n if (beresp.http.Set-Cookie) {\n return(hit_for_pass);\n }\n\n# if (beresp.http.Cache-Control ~ \"(private|no-cache|no-store)\")\n# {return(hit_for_pass);}\n\n if (req.http.Authorization && !beresp.http.Cache-Control ~ \"public\") {\n return(hit_for_pass);\n }\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"5df22780ec5aee9214b0683b13a5585bb7e7e0e1","subject":"amend backend host inside default.vcl","message":"amend backend host inside default.vcl\n","repos":"varnish\/varnish-microservice-monitor,varnish\/zipnish,varnish\/zipnish,varnish\/zipnish,varnish\/zipnish,varnish\/varnish-microservice-monitor,varnish\/varnish-microservice-monitor,varnish\/varnish-microservice-monitor,varnish\/varnish-microservice-monitor,varnish\/zipnish","old_file":"default.vcl","new_file":"default.vcl","new_contents":"backend default {\n .host = \"i192.168.33.14\";\n .port = \"9000\";\n}\n\nsub vcl_recv {\n\treturn (pass);\n}\n\nsub vcl_backend_response {\n}\n\nsub vcl_deliver {\n}\n","old_contents":"backend default {\n .host = \"127.0.0.1\";\n .port = \"9000\";\n}\n\nsub vcl_recv {\n\treturn (pass);\n}\n\nsub vcl_backend_response {\n}\n\nsub vcl_deliver {\n}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"4d6508800ee01c96c92fef1fa7d0fc0fde924f57","subject":"improve comment regarding HIT\/MISS detection","message":"improve comment regarding HIT\/MISS detection\n","repos":"NITEMAN\/Varnish_VCL_samps-hacks,NITEMAN\/varnish-bites","old_file":"varnish4\/drupal-base.vcl","new_file":"varnish4\/drupal-base.vcl","new_contents":"\/* Varnish 4 example config for Drupal 7 \/ Pressflow 6 & 7 *\/\n# Original source: https:\/\/github.com\/NITEMAN\/varnish-bites\/varnish4\/drupal-base.vcl\n# Copyright (c) 2015 Pedro Gonz\u00e1lez Serrano and individual contributors.\n# MIT License\n\n# Intended to be used both in simple production environments and with\n# learning\/teaching purposes.\n# Some references may not be yet updated to VCL 4.0, we use SeeV3 then.\n\n# WARNING:\n# Note that the built-in logic will be appended to our code if no return is performed before.\n# Built-in logic is included commented out right after our's for reference purposes in that cases.\n# See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleDefault\n\n#######################################################################\n# Initialization: Version & imports;\n\n\/* Version statement *\/\n# Since Varnish 4.0 it's mandatory to declare VCL version on first line.\nvcl 4.0;\n\n\/* Module (VMOD) imports *\/\n# Standard module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_std.generated.html\nimport std;\n\n# Directors module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# Unused in simple configs.\n#import directors;\n\n\n#######################################################################\n# Probe, backend, ACL and subroutine definitions\n\n\/* Backend probes \/ healthchecks *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#probes\nprobe basic {\n \/* Only test that backend's IP serves content for '\/' *\/\n # This might be a too heavy probe\n # .url = \"\/\";\n \/* Only test that backend's IP has apache working *\/\n # Nginx would fail this probe with a default config\n .request =\n \"OPTIONS * HTTP\/1.1\"\n \"Host: *\"\n \"Connection: close\";\n .interval = 10s;\n .timeout = 2s;\n .window = 8;\n .threshold = 6;\n}\n\n\/* Backend definitions.*\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#backend-definition\nbackend default {\n \/* Default backend on the same machine. WARNING: timeouts could be not big enought for certain POST request *\/\n .host = \"127.0.0.1\";\n .port = \"8008\";\n .connect_timeout = 60s;\n .first_byte_timeout = 60s;\n .between_bytes_timeout = 60s;\n .probe = basic;\n}\n\n\/* Access Control Lists *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#access-control-list-acl\nacl purge_ban {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use '\"localhost\";' instead\n}\nacl allowed_monitors {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n}\n#acl own_proxys {\n# \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n#}\n\n\/* Custom subroutines *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#subroutines\n#TODO# Test in Varnihs 4\n# Empty in simple configs.\n# We can name subs with no restrictions but as a task can need several chunks of code in diferent states,\n# it's a good idea to identify what main sub will call each with a suffix.\n# \/* Example 301 client redirection removing \"www\" prefix from request *\/\n# sub perm_redirections_recv {\n# if ( req.http.host ~ \"^www.*$\" ) {\n# return(synth(751, \"http:\/\/\" + regsub(req.http.host, \"^www\\.\", \"\") + req.url));\n# }\n# }\n# sub perm_redirections_synth {\n# if (resp.status == 751) {\n# \/* Get new URL from the response *\/\n# set resp.http.Location = resp.response;\n# \/* Set HTTP 301 for permanent redirect *\/\n# set resp.status = 301;\n# return (deliver);\n# }\n# }\n\n\n#######################################################################\n# Client side\n\n# vcl_recv: Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-recv\nsub vcl_recv {\n \/* 0th: general bypass, general return & authorization checks *\/\n # Empty in simple configs.\n # Useful for debugging we can pipe or pass the request to default backend here to bypass completely Varnish.\n # return (pipe);\n # return (pass);\n # We can also return here a 200 Ok for network performance benchmarking.\n # return(synth(200, \"Ok\"));\n # Finally we can perform basic HTTP authentification here, by example.\n # SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* 1st: Check for Varnish special requests *\/ \n # Custom response implementation example in order to check that Varnish is working properly.\n # This is usefull for automatic monitoring with monit or when Varnish is behind another proxies like HAProxy.\n if ( ( req.http.host == \"monitor.server.health\"\n || req.http.host == \"health.varnish\" )\n && client.ip ~ allowed_monitors\n && ( req.method == \"OPTIONS\" || req.method == \"GET\" )\n ) {\n return(synth(200, \"Ban added\"));\n }\n # Purge logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#http-purging\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if (req.method == \"PURGE\") {\n if (!client.ip ~ purge_ban) {\n return(synth(405, \"Not allowed.\"));\n }\n return (purge);\n }\n # Ban logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#bans\n if (req.method == \"BAN\") {\n if (!client.ip ~ purge_ban) {\n return(synth(405, \"Not allowed.\"));\n }\n ban(\"req.http.host == \" + req.http.host +\n \"&& req.url == \" + req.url); \n return(synth(200, \"Ban added\"));\n }\n\n \/* 2nd: Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_recv;\n # Here we can also enforce SSL when Varnish run behind some SSL termination point.\n\n \/* 3rd: Time for backend choice *\/\n # Empty in simple configs.\n\n \/* 4th: Prepare headers for the backend *\/\n # Empty in simple configs.\n # Example remove own_proxys from X-Forwarded-For\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/whats-new\/upgrading.html#x-forwarded-for-is-now-set-before-vcl-recv\n # if ( req.restarts == 0\n # && client.ip ~ own_proxys\n # && req.http.x-forwarded-for\n # ) {\n # set req.http.X-Forwarded-For = regsub(req.http.X-Forwarded-For, \",( )?\" + client.ip, \"\");\n # }\n\n \/* 5th: Bypass breakpoint 1 *\/\n # Useful for debugging we can now pipe or pass the request to backend with headers setted.\n # return (pipe);\n # return (pass);\n\n \/* 6th: Decide if we should deal with a request (mostly copied from built-in logic) *\/\n if (req.method == \"PRI\") {\n \/* We do not support SPDY or HTTP\/2.0 *\/\n return (synth(405));\n }\n if ( req.method != \"GET\"\n && req.method != \"HEAD\"\n && req.method != \"PUT\"\n && req.method != \"POST\"\n && req.method != \"TRACE\"\n && req.method != \"OPTIONS\"\n && req.method != \"DELETE\"\n ) {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n\n \/* 7th: Access control for some URLs by ACL *\/\n # Empty in simple configs.\n # By example denial some URLs depending on client-ip, we'll need to define corresponding ACL 'internal'.\n # if ( req.url ~ \"^\/(cron|install)\\.php\"\n # && ! client.ip ~ internal\n # ) {\n # # Have Varnish throw the error directly.\n # return(synth(403, \"Forbidden.\"));\n # # Use a custom error page that you've defined in Drupal at the path \"404\".\n # # set req.url = \"\/403\";\n # }\n\n \/* 8th: Custom exceptions *\/\n # Host exception example:\n # if (req.http.host == \"ejemplo.exception.com\") {\n # return (pass);\n # }\n # Drupal exceptions, edit if we want to cache some AJAX\/AHAH request.\n # Add here filters for never cache URLs such as Payment Gateway's callbacks\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/ooyala\/ping$\" ||\n req.url ~ \"^\/admin\/build\/features\" ||\n req.url ~ \"^\/info\/.*$\" ||\n req.url ~ \"^\/flag\/.*$\" ||\n req.url ~ \"^.*\/ajax\/.*$\" ||\n req.url ~ \"^.*\/ahah\/.*$\") {\n \/* Do not cache these paths *\/\n return (pass);\n }\n # Pipe these paths directly to backend for streaming.\n if (req.url ~ \"^\/admin\/content\/backup_migrate\/export\") {\n return (pipe);\n }\n if (req.url ~ \"^\/system\/files\") {\n return (pipe);\n }\n\n \/* 9th: Serve from anonymous cahe if all backends are down *\/\n if (! std.healthy(req.backend_hint) ) {\n #TODO# Consider moving this to vcl_backend_fetch\n unset req.http.Cookie;\n #TODO# Add sick marker\n } \n\n \/* 10th: Deal with compression and the Accept-Encoding header *\/\n # Althought Varnish 3 handles gziped content itself by default, just to be sure we want to \n # remove Accept-Encoding for some compressed formats.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html#what-does-http-gzip-support-do\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/varnishd.html?highlight=http_gzip_support\n # See (for older configs) https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleNormalizeAcceptEncoding\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|mp4|flv|zip|rar)$\") {\n \/* Already compressed formats, no sense trying to compress again *\/\n unset req.http.Accept-Encoding;\n }\n }\n\n \/* 11th: Another header manipulation *\/\n # Empty in simple configs.\n # We could add here a custom header grouping User-agent families.\n\n \/* 12th: Cookie removal *\/\n # Always cache the following static file types for all users. \n # Use with care if we control certain downloads depending on cookies. \n # Be carefull also if appending .htm[l] via Drupal's clean URLs.\n if ( req.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|woff2|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n && req.url !~ \"\/system\/storage\/serve\"\n ) {\n unset req.http.Cookie;\n }\n # Remove all cookies that backend doesn't need to know about.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRemovingSomeCookies\n if (req.http.Cookie) {\n \/* Warning: Not a pretty solution *\/\n \/* Prefix header containing cookies with ';' *\/\n set req.http.Cookie = \";\" + req.http.Cookie;\n \/* Remove any spaces after ';' in header containing cookies *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n \/* Prefix cookies we want to preserve with one space *\/\n \/* 'S{1,2}ESS[a-z0-9]+' is the regular expression matching a Drupal session cookie ({1,2} added for HTTPS support) *\/\n \/* 'NO_CACHE' is usually set after a POST request to make sure issuing user see the results of his post *\/\n \/* 'OATMEAL' & 'CHOCOLATECHIP' are special cookies used by Drupal's Bakery module to provide Single Sign On *\/\n \/* Keep in mind we should add here any cookie that should reach the backend such as splahs avoiding cookies *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \";(S{1,2}ESS[a-z0-9]+|NO_CACHE|OATMEAL|CHOCOLATECHIP)=\", \"; \\1=\");\n \/* Remove from the header any single Cookie not prefixed with a space until next ';' separator *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n \/* Remove any '; ' at the start or the end of the header *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n\n if (req.http.Cookie == \"\") {\n \/* If there are no remaining cookies, remove the cookie header. *\/\n unset req.http.Cookie;\n }\n }\n\n \/* 13th: Session cookie & special cookies bypass caching stage *\/\n # As we might want to cache some requests, hashed with its cookies, \n # we don't simply pass when some cookies remain present at this point.\n # Instead we look for request that must be passed due to the cookie header.\n if ( req.http.Cookie ~ \"SESS\"\n || req.http.Cookie ~ \"SSESS\"\n || req.http.Cookie ~ \"NO_CACHE\"\n || req.http.Cookie ~ \"OATMEAL\"\n || req.http.Cookie ~ \"CHOCOLATECHIP\"\n ) {\n return (pass);\n }\n\n \/* 14th: Bypass breakpoint 2 *\/\n # Useful for debugging we can now pipe or pass the request to backend to bypass cache.\n # return (pipe);\n # return (pass);\n\n \/* 15th: Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning inconditionally.\n return (hash);\n}\n\n# vcl_pipe: Called upon entering pipe mode.\n# In this mode, the request is passed on to the backend, \n# and any further data from either client or backend is passed on unaltered until either end closes the connection.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pipe\n# sub vcl_pipe {\n# # By default Connection: close is set on all piped requests, to stop\n# # connection reuse from sending future requests directly to the\n# # (potentially) wrong backend. If you do want this to happen, you can undo\n# # it here.\n# # unset bereq.http.connection;\n# return (pipe);\n# }\n\n# vcl_pass: Called upon entering pass mode. \n# In this mode, the request is passed on to the backend, and the backend's response is passed on to the client, \n# but is not entered into the cache.\n# Subsequent requests submitted over the same client connection are handled normally.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pass\n# sub vcl_pass {\n# return (fetch);\n# }\n\n# vcl_hash: You may call hash_data() on the data you would like to add to the hash.\n# Hash is used by Varnish to uniquely identify objects.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hash\nsub vcl_hash {\n \/* Hash cookie data *\/\n # As requests with same URL and host can produce diferent results when issued with different cookies,\n # we need to store items hashed with the associated cookies. Note that cookies are already sanitized when we reach this point.\n if (req.http.Cookie) {\n \/* Include cookie in cache hash *\/\n hash_data(req.http.Cookie);\n }\n\n \/* Custom header hashing *\/\n # Empty in simple configs.\n # Example for caching differents object versions by device previously detected (when static content could also vary):\n # if (req.http.X-UA-Device) {\n # hash_data(req.http.X-UA-Device);\n # }\n # Example for caching diferent object versions by X-Forwarded-Proto, trying to be smart about what kind of request\n # could generate diffetent responses.\n if ( req.http.X-Forwarded-Proto\n && req.url !~ \"(?i)\\.(png|gif|jpeg|jpg|ico|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|woff2|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\") {\n hash_data(req.http.X-Forwarded-Proto);\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (lookup);\n# }\n\n# vcl_purge: Called after the purge has been executed and all its variants have been evited.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-purge\n# sub vcl_purge {\n# return (synth(200, \"Purged\"));\n# }\n\n# vcl_hit: Called after a cache lookup if the requested document was found in the cache.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hit\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n \/\/ A pure unadultered hit, deliver it\n return (deliver);\n }\n \/* Allow varnish to serve up stale content if it is responding slowly *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n if (obj.ttl + 60s > 0s) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n return (deliver);\n }\n \/* Allow varish to serve up stale content if all backends are down *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n if ( ! std.healthy(req.backend_hint)\n && obj.ttl + obj.grace > 0s\n ) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n return (deliver);\n }\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning inconditionally.\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\n# vcl_miss: Called after a cache lookup if the requested document was not found in the cache.\n# Its purpose is to decide whether or not to attempt to retrieve the document from the backend, and which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-miss\n# sub vcl_miss {\n# return (fetch);\n# }\n\n# vcl_deliver: Called before an object is delivered to the client\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-deliver\nsub vcl_deliver {\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # Add whether the object is a cache hit or miss and the number of hits for the object.\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Addingaheaderindicatinghitmiss\n # In Varnish 4 the obj.hits counter behaviour has changed (see bug 1492), so\n # we use a different method: if X-Varnish contains only 1 id, we have a miss,\n # if it contains more (and therefore a space), we have a hit.\n if (resp.http.x-varnish ~ \" \") {\n set resp.http.X-Cache = \"HIT\";\n # Since in Varnish 4 the behaviour of obj.hits changed, this might not be accurate\n # See https:\/\/www.varnish-cache.org\/trac\/ticket\/1492\n set resp.http.X-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Cache = \"MISS\";\n \/* Show the results of cookie sanitization *\/\n set resp.http.X-Cookie = req.http.Cookie;\n }\n\n #TODO# Add sick marker\n\n # Restart count\n if ( req.restarts > 0) {\n set resp.http.X-Restarts = req.restarts;\n }\n\n # Add the Varnish server hostname\n set resp.http.X-Varnish-Server = server.hostname;\n # If we have setted a custom header with device family detected we can show it:\n # if (req.http.X-UA-Device) {\n # set resp.http.X-UA-Device = req.http.X-UA-Device;\n # }\n # If we have recived a custom header with the protocol in the request we can show it:\n # if (req.http.X-Forwarded-Proto) {\n # set resp.http.X-Forwarded-Proto = req.http.X-Forwarded-Proto;\n # }\n\n \/* Vary header manipulation *\/\n # Empty in simple configs.\n # By example, if we are storing & serving diferent objects depending on User-Agent header we must set the correct Vary header:\n # if (resp.http.Vary) {\n # set resp.http.Vary = resp.http.Vary + \",User-Agent\";\n # } else {\n # set resp.http.Vary = \"User-Agent\";\n # }\n\n \/* Fake headers *\/\n # Empty in simple configs\n # We can fake server headers here, by example:\n # set resp.http.Server = \"Deep thought\";\n # set resp.http.X-Powered-By = \"BOFH\";\n # Or have some fun with headers:\n # See http:\/\/www.nextthing.org\/archives\/2005\/08\/07\/fun-with-http-headers\n # See http:\/\/royal.pingdom.com\/2012\/08\/15\/fun-and-unusual-http-response-headers\/\n # set resp.http.X-Thank-You = \"for bothering to look at my HTTP headers\";\n # set resp.http.X-Answer = \"42\";\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_deliver {\n# return (deliver);\n# }\n\n# vcl_synth: Called to deliver a synthetic object. A synthetic object is generated in VCL,\n# not fetched from the backend. It is typically contructed using the synthetic() function.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-synth\n\/*\n * We can come here \"invisibly\" with the following errors: 413, 417 & 503\n *\/\nsub vcl_synth {\n \/* Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_synth;\n\n \/* Try to restart request in case of failure *\/\n # Note that max_restarts defaults to 4\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if (resp.status == 503 && req.restarts < 4) {\n return(restart);\n }\n\n \/* Set common headers for synthetic responses *\/\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n\n \/* HTTP Authentification client request *\/\n # Empty in simple configs. SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* Error page & refresh \/ redirections *\/\n # We have plenty of choices when we have to serve an error to the client, \n # from the default error page to javascript black magic or plain redirections.\n # Adding some external statistic javascript to track failures served to clients is strongly suggested.\n # We can't use external resources on synthetic content, everything must be inlined.\n # If we need to include images we can embed them in base64 encoding.\n # Here is the default error page for Varnish 4 (not so pretty)\n # We're using error 200 for monitoring puposes which should not be retried client side *\/\n if ( resp.status != 200) {\n set resp.http.Retry-After = \"5\";\n }\n\n ## Example custom 403 error page.\n #if (resp.status == 403) {\n # synthetic(std.fileread(\"\/403.html\"));\n # return(deliver);\n #}\n \n # Consider add some analytics stuff to trace accesses\n synthetic( {\"\n\n \n \"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning inconditionally.\n return (deliver);\n}\n\n#######################################################################\n# Backend Fetch\n\n# vcl_backend_fetch: Called before sending the backend request. In this subroutine you typically alter the request before it gets to the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-fetch\n# sub vcl_backend_fetch {\n# return (fetch);\n# }\n\n# vcl_backend_response: Called after the response headers has been successfully retrieved from the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-response\nsub vcl_backend_response {\n \/* Caching exceptions *\/\n # Varnish will cache objects with response codes: 200, 203, 300, 301, 302, 307, 404 & 410.\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/VCL_Basics.html#the-initial-value-of-beresp-ttl\n # Drupal's Imagecache module can return a 307 redirection to the requested url itself and, depending on Drupal's cache settings,\n # this could lead to a redirection loop being cached for a long time but also we want Varnish to shield a little the backend.\n # See http:\/\/drupal.org\/node\/1248010\n # See http:\/\/drupal.org\/node\/310656\n if (beresp.status == 307 &&\n #TODO# verify that this work better than 'bereq.url ~ \"imagecache\"' *\/\n beresp.http.Location == bereq.url &&\n beresp.ttl > 5s) {\n set beresp.ttl = 5s;\n set beresp.http.cache-control = \"max-age=5\";\n }\n\n \/* Request retrial *\/\n if ( beresp.status == 500\n || beresp.status == 503\n ) {\n #TODO# consider not restarting POST requests as seenV3 on https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleSaintMode\n return (retry);\n }\n\n \/* Enable grace mode. Related with vcl_hit *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n set beresp.grace = 1h;\n\n \/* Strip cookies from the following static file types for all users. Related with our 12th stage on vcl_recv *\/\n if (bereq.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|woff2|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\") {\n unset beresp.http.set-cookie;\n }\n\n \/* Gzip response *\/\n # Empty in simple configs\n # Use Varnish to Gzip respone, if suitable, before storing it on cache\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html\n if ( ! beresp.http.Content-Encoding\n && ( beresp.http.content-type ~ \"text\"\n || beresp.http.content-type ~ \"application\/x-javascript\"\n || beresp.http.content-type ~ \"application\/javascript\"\n || beresp.http.content-type ~ \"application\/rss+xml\"\n || beresp.http.content-type ~ \"application\/xml\"\n || beresp.http.content-type ~ \"Application\/JSON\")\n ) {\n set beresp.do_gzip = true;\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # We can add the name of the backend that has processed the request:\n # set beresp.http.X-Backend = beresp.backend.name;\n # We can use a header to tell if the object was gziped by Varnish\n # if (beresp.do_gzip) {\n # set beresp.http.X-Varnish-Gzipped = \"yes\";\n # } else {\n # set beresp.http.X-Varnish-Gizipped = \"no\";\n # }\n # We can also add headers informing whether the object is cacheable or not and why.\n # https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Varnish3.0\n if (beresp.ttl <= 0s) {\n \/* Varnish determined the object was not cacheable *\/\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n } elsif (bereq.http.Cookie ~ \"(SESS|SSESS|NO_CACHE|OATMEAL|CHOCOLATECHIP)\") {\n \/* We don't wish to cache content for logged in users or with certain cookies. Related with our 9th stage on vcl_recv *\/\n set beresp.http.X-Cacheable = \"NO:Cookies\";\n # return(hit_for_pass);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n \/* We are respecting the Cache-Control=private header from the backend *\/\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n # return(hit_for_pass);\n } else {\n \/* Varnish determined the object was cacheable *\/\n set beresp.http.X-Cacheable = \"YES\";\n }\n\n \/* Further header manipulation *\/\n # Empty in simple configs.\n # We can also unset some headers to prevent information disclosure and save some cache space\n # unset beresp.http.Server;\n # unset beresp.http.X-Powered-By;\n # Retry count\n if ( bereq.retries > 0) {\n set beresp.http.X-Retries = bereq.retries;\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_backend_response {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Surrogate-control ~ \"no-store\" ||\n# (!beresp.http.Surrogate-Control &&\n# beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n# beresp.http.Vary == \"*\") {\n# \/*\n# * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# *\/\n# set beresp.ttl = 120s;\n# set beresp.uncacheable = true;\n# }\n# return (deliver);\n# }\n\n# vcl_backend_error: This subroutine is called if we fail the backend fetch.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-error\nsub vcl_backend_error {\n\n \/* Try to restart request in case of failure *\/\n #TODO# Confirm max_retries default value\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if (bereq.retries < 4) {\n return (retry);\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # Retry count\n if ( bereq.retries > 0) {\n set beresp.http.X-Retries = bereq.retries;\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + beresp.status + \" \" + beresp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + beresp.status + \" \" + beresp.reason + {\"<\/h1>\n <p>\"} + beresp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + bereq.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this point.\n return (deliver);\n}\n\n#######################################################################\n# Housekeeping\n\n# vcl_init: Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-init\n# Here is where you should declare your directors now.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-backends.html#directors\n# Empty in simple configs\n# sub vcl_init {\n# return (ok);\n# }\n\n# vcl_fini: Called when VCL is discarded only after all requests have exited the VCL. Typically used to clean up VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-fini\n# sub vcl_fini {\n# return (ok);\n# }\n\n","old_contents":"\/* Varnish 4 example config for Drupal 7 \/ Pressflow 6 & 7 *\/\n# Original source: https:\/\/github.com\/NITEMAN\/varnish-bites\/varnish4\/drupal-base.vcl\n# Copyright (c) 2015 Pedro Gonz\u00e1lez Serrano and individual contributors.\n# MIT License\n\n# Intended to be used both in simple production environments and with\n# learning\/teaching purposes.\n# Some references may not be yet updated to VCL 4.0, we use SeeV3 then.\n\n# WARNING:\n# Note that the built-in logic will be appended to our code if no return is performed before.\n# Built-in logic is included commented out right after our's for reference purposes in that cases.\n# See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleDefault\n\n#######################################################################\n# Initialization: Version & imports;\n\n\/* Version statement *\/\n# Since Varnish 4.0 it's mandatory to declare VCL version on first line.\nvcl 4.0;\n\n\/* Module (VMOD) imports *\/\n# Standard module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_std.generated.html\nimport std;\n\n# Directors module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# Unused in simple configs.\n#import directors;\n\n\n#######################################################################\n# Probe, backend, ACL and subroutine definitions\n\n\/* Backend probes \/ healthchecks *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#probes\nprobe basic {\n \/* Only test that backend's IP serves content for '\/' *\/\n # This might be a too heavy probe\n # .url = \"\/\";\n \/* Only test that backend's IP has apache working *\/\n # Nginx would fail this probe with a default config\n .request =\n \"OPTIONS * HTTP\/1.1\"\n \"Host: *\"\n \"Connection: close\";\n .interval = 10s;\n .timeout = 2s;\n .window = 8;\n .threshold = 6;\n}\n\n\/* Backend definitions.*\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#backend-definition\nbackend default {\n \/* Default backend on the same machine. WARNING: timeouts could be not big enought for certain POST request *\/\n .host = \"127.0.0.1\";\n .port = \"8008\";\n .connect_timeout = 60s;\n .first_byte_timeout = 60s;\n .between_bytes_timeout = 60s;\n .probe = basic;\n}\n\n\/* Access Control Lists *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#access-control-list-acl\nacl purge_ban {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use '\"localhost\";' instead\n}\nacl allowed_monitors {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n}\n#acl own_proxys {\n# \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n#}\n\n\/* Custom subroutines *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#subroutines\n#TODO# Test in Varnihs 4\n# Empty in simple configs.\n# We can name subs with no restrictions but as a task can need several chunks of code in diferent states,\n# it's a good idea to identify what main sub will call each with a suffix.\n# \/* Example 301 client redirection removing \"www\" prefix from request *\/\n# sub perm_redirections_recv {\n# if ( req.http.host ~ \"^www.*$\" ) {\n# return(synth(751, \"http:\/\/\" + regsub(req.http.host, \"^www\\.\", \"\") + req.url));\n# }\n# }\n# sub perm_redirections_synth {\n# if (resp.status == 751) {\n# \/* Get new URL from the response *\/\n# set resp.http.Location = resp.response;\n# \/* Set HTTP 301 for permanent redirect *\/\n# set resp.status = 301;\n# return (deliver);\n# }\n# }\n\n\n#######################################################################\n# Client side\n\n# vcl_recv: Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-recv\nsub vcl_recv {\n \/* 0th: general bypass, general return & authorization checks *\/\n # Empty in simple configs.\n # Useful for debugging we can pipe or pass the request to default backend here to bypass completely Varnish.\n # return (pipe);\n # return (pass);\n # We can also return here a 200 Ok for network performance benchmarking.\n # return(synth(200, \"Ok\"));\n # Finally we can perform basic HTTP authentification here, by example.\n # SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* 1st: Check for Varnish special requests *\/ \n # Custom response implementation example in order to check that Varnish is working properly.\n # This is usefull for automatic monitoring with monit or when Varnish is behind another proxies like HAProxy.\n if ( ( req.http.host == \"monitor.server.health\"\n || req.http.host == \"health.varnish\" )\n && client.ip ~ allowed_monitors\n && ( req.method == \"OPTIONS\" || req.method == \"GET\" )\n ) {\n return(synth(200, \"Ban added\"));\n }\n # Purge logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#http-purging\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if (req.method == \"PURGE\") {\n if (!client.ip ~ purge_ban) {\n return(synth(405, \"Not allowed.\"));\n }\n return (purge);\n }\n # Ban logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#bans\n if (req.method == \"BAN\") {\n if (!client.ip ~ purge_ban) {\n return(synth(405, \"Not allowed.\"));\n }\n ban(\"req.http.host == \" + req.http.host +\n \"&& req.url == \" + req.url); \n return(synth(200, \"Ban added\"));\n }\n\n \/* 2nd: Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_recv;\n # Here we can also enforce SSL when Varnish run behind some SSL termination point.\n\n \/* 3rd: Time for backend choice *\/\n # Empty in simple configs.\n\n \/* 4th: Prepare headers for the backend *\/\n # Empty in simple configs.\n # Example remove own_proxys from X-Forwarded-For\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/whats-new\/upgrading.html#x-forwarded-for-is-now-set-before-vcl-recv\n # if ( req.restarts == 0\n # && client.ip ~ own_proxys\n # && req.http.x-forwarded-for\n # ) {\n # set req.http.X-Forwarded-For = regsub(req.http.X-Forwarded-For, \",( )?\" + client.ip, \"\");\n # }\n\n \/* 5th: Bypass breakpoint 1 *\/\n # Useful for debugging we can now pipe or pass the request to backend with headers setted.\n # return (pipe);\n # return (pass);\n\n \/* 6th: Decide if we should deal with a request (mostly copied from built-in logic) *\/\n if (req.method == \"PRI\") {\n \/* We do not support SPDY or HTTP\/2.0 *\/\n return (synth(405));\n }\n if ( req.method != \"GET\"\n && req.method != \"HEAD\"\n && req.method != \"PUT\"\n && req.method != \"POST\"\n && req.method != \"TRACE\"\n && req.method != \"OPTIONS\"\n && req.method != \"DELETE\"\n ) {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n\n \/* 7th: Access control for some URLs by ACL *\/\n # Empty in simple configs.\n # By example denial some URLs depending on client-ip, we'll need to define corresponding ACL 'internal'.\n # if ( req.url ~ \"^\/(cron|install)\\.php\"\n # && ! client.ip ~ internal\n # ) {\n # # Have Varnish throw the error directly.\n # return(synth(403, \"Forbidden.\"));\n # # Use a custom error page that you've defined in Drupal at the path \"404\".\n # # set req.url = \"\/403\";\n # }\n\n \/* 8th: Custom exceptions *\/\n # Host exception example:\n # if (req.http.host == \"ejemplo.exception.com\") {\n # return (pass);\n # }\n # Drupal exceptions, edit if we want to cache some AJAX\/AHAH request.\n # Add here filters for never cache URLs such as Payment Gateway's callbacks\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/ooyala\/ping$\" ||\n req.url ~ \"^\/admin\/build\/features\" ||\n req.url ~ \"^\/info\/.*$\" ||\n req.url ~ \"^\/flag\/.*$\" ||\n req.url ~ \"^.*\/ajax\/.*$\" ||\n req.url ~ \"^.*\/ahah\/.*$\") {\n \/* Do not cache these paths *\/\n return (pass);\n }\n # Pipe these paths directly to backend for streaming.\n if (req.url ~ \"^\/admin\/content\/backup_migrate\/export\") {\n return (pipe);\n }\n if (req.url ~ \"^\/system\/files\") {\n return (pipe);\n }\n\n \/* 9th: Serve from anonymous cahe if all backends are down *\/\n if (! std.healthy(req.backend_hint) ) {\n #TODO# Consider moving this to vcl_backend_fetch\n unset req.http.Cookie;\n #TODO# Add sick marker\n } \n\n \/* 10th: Deal with compression and the Accept-Encoding header *\/\n # Althought Varnish 3 handles gziped content itself by default, just to be sure we want to \n # remove Accept-Encoding for some compressed formats.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html#what-does-http-gzip-support-do\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/varnishd.html?highlight=http_gzip_support\n # See (for older configs) https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleNormalizeAcceptEncoding\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|mp4|flv|zip|rar)$\") {\n \/* Already compressed formats, no sense trying to compress again *\/\n unset req.http.Accept-Encoding;\n }\n }\n\n \/* 11th: Another header manipulation *\/\n # Empty in simple configs.\n # We could add here a custom header grouping User-agent families.\n\n \/* 12th: Cookie removal *\/\n # Always cache the following static file types for all users. \n # Use with care if we control certain downloads depending on cookies. \n # Be carefull also if appending .htm[l] via Drupal's clean URLs.\n if ( req.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|woff2|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n && req.url !~ \"\/system\/storage\/serve\"\n ) {\n unset req.http.Cookie;\n }\n # Remove all cookies that backend doesn't need to know about.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRemovingSomeCookies\n if (req.http.Cookie) {\n \/* Warning: Not a pretty solution *\/\n \/* Prefix header containing cookies with ';' *\/\n set req.http.Cookie = \";\" + req.http.Cookie;\n \/* Remove any spaces after ';' in header containing cookies *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n \/* Prefix cookies we want to preserve with one space *\/\n \/* 'S{1,2}ESS[a-z0-9]+' is the regular expression matching a Drupal session cookie ({1,2} added for HTTPS support) *\/\n \/* 'NO_CACHE' is usually set after a POST request to make sure issuing user see the results of his post *\/\n \/* 'OATMEAL' & 'CHOCOLATECHIP' are special cookies used by Drupal's Bakery module to provide Single Sign On *\/\n \/* Keep in mind we should add here any cookie that should reach the backend such as splahs avoiding cookies *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \";(S{1,2}ESS[a-z0-9]+|NO_CACHE|OATMEAL|CHOCOLATECHIP)=\", \"; \\1=\");\n \/* Remove from the header any single Cookie not prefixed with a space until next ';' separator *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n \/* Remove any '; ' at the start or the end of the header *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n\n if (req.http.Cookie == \"\") {\n \/* If there are no remaining cookies, remove the cookie header. *\/\n unset req.http.Cookie;\n }\n }\n\n \/* 13th: Session cookie & special cookies bypass caching stage *\/\n # As we might want to cache some requests, hashed with its cookies, \n # we don't simply pass when some cookies remain present at this point.\n # Instead we look for request that must be passed due to the cookie header.\n if ( req.http.Cookie ~ \"SESS\"\n || req.http.Cookie ~ \"SSESS\"\n || req.http.Cookie ~ \"NO_CACHE\"\n || req.http.Cookie ~ \"OATMEAL\"\n || req.http.Cookie ~ \"CHOCOLATECHIP\"\n ) {\n return (pass);\n }\n\n \/* 14th: Bypass breakpoint 2 *\/\n # Useful for debugging we can now pipe or pass the request to backend to bypass cache.\n # return (pipe);\n # return (pass);\n\n \/* 15th: Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning inconditionally.\n return (hash);\n}\n\n# vcl_pipe: Called upon entering pipe mode.\n# In this mode, the request is passed on to the backend, \n# and any further data from either client or backend is passed on unaltered until either end closes the connection.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pipe\n# sub vcl_pipe {\n# # By default Connection: close is set on all piped requests, to stop\n# # connection reuse from sending future requests directly to the\n# # (potentially) wrong backend. If you do want this to happen, you can undo\n# # it here.\n# # unset bereq.http.connection;\n# return (pipe);\n# }\n\n# vcl_pass: Called upon entering pass mode. \n# In this mode, the request is passed on to the backend, and the backend's response is passed on to the client, \n# but is not entered into the cache.\n# Subsequent requests submitted over the same client connection are handled normally.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pass\n# sub vcl_pass {\n# return (fetch);\n# }\n\n# vcl_hash: You may call hash_data() on the data you would like to add to the hash.\n# Hash is used by Varnish to uniquely identify objects.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hash\nsub vcl_hash {\n \/* Hash cookie data *\/\n # As requests with same URL and host can produce diferent results when issued with different cookies,\n # we need to store items hashed with the associated cookies. Note that cookies are already sanitized when we reach this point.\n if (req.http.Cookie) {\n \/* Include cookie in cache hash *\/\n hash_data(req.http.Cookie);\n }\n\n \/* Custom header hashing *\/\n # Empty in simple configs.\n # Example for caching differents object versions by device previously detected (when static content could also vary):\n # if (req.http.X-UA-Device) {\n # hash_data(req.http.X-UA-Device);\n # }\n # Example for caching diferent object versions by X-Forwarded-Proto, trying to be smart about what kind of request\n # could generate diffetent responses.\n if ( req.http.X-Forwarded-Proto\n && req.url !~ \"(?i)\\.(png|gif|jpeg|jpg|ico|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|woff2|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\") {\n hash_data(req.http.X-Forwarded-Proto);\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (lookup);\n# }\n\n# vcl_purge: Called after the purge has been executed and all its variants have been evited.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-purge\n# sub vcl_purge {\n# return (synth(200, \"Purged\"));\n# }\n\n# vcl_hit: Called after a cache lookup if the requested document was found in the cache.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hit\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n \/\/ A pure unadultered hit, deliver it\n return (deliver);\n }\n \/* Allow varnish to serve up stale content if it is responding slowly *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n if (obj.ttl + 60s > 0s) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n return (deliver);\n }\n \/* Allow varish to serve up stale content if all backends are down *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n if ( ! std.healthy(req.backend_hint)\n && obj.ttl + obj.grace > 0s\n ) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n return (deliver);\n }\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning inconditionally.\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\n# vcl_miss: Called after a cache lookup if the requested document was not found in the cache.\n# Its purpose is to decide whether or not to attempt to retrieve the document from the backend, and which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-miss\n# sub vcl_miss {\n# return (fetch);\n# }\n\n# vcl_deliver: Called before an object is delivered to the client\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-deliver\nsub vcl_deliver {\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # In Varnish 4 the obj.hits counter behaviour has changed, so we use a\n # different method: if X-Varnish contains only 1 id, we have a miss, if it\n # contains more (and therefore a space), we have a hit.\n if (resp.http.x-varnish ~ \" \") {\n set resp.http.X-Cache = \"HIT\";\n set resp.http.X-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Cache = \"MISS\";\n \/* Show the results of cookie sanitization *\/\n set resp.http.X-Cookie = req.http.Cookie;\n }\n \n\n #TODO# Add sick marker\n # Restart count\n if ( req.restarts > 0) {\n set resp.http.X-Restarts = req.restarts;\n }\n\n # Add the Varnish server hostname\n set resp.http.X-Varnish-Server = server.hostname;\n # If we have setted a custom header with device family detected we can show it:\n # if (req.http.X-UA-Device) {\n # set resp.http.X-UA-Device = req.http.X-UA-Device;\n # }\n # If we have recived a custom header with the protocol in the request we can show it:\n # if (req.http.X-Forwarded-Proto) {\n # set resp.http.X-Forwarded-Proto = req.http.X-Forwarded-Proto;\n # }\n\n \/* Vary header manipulation *\/\n # Empty in simple configs.\n # By example, if we are storing & serving diferent objects depending on User-Agent header we must set the correct Vary header:\n # if (resp.http.Vary) {\n # set resp.http.Vary = resp.http.Vary + \",User-Agent\";\n # } else {\n # set resp.http.Vary = \"User-Agent\";\n # }\n\n \/* Fake headers *\/\n # Empty in simple configs\n # We can fake server headers here, by example:\n # set resp.http.Server = \"Deep thought\";\n # set resp.http.X-Powered-By = \"BOFH\";\n # Or have some fun with headers:\n # See http:\/\/www.nextthing.org\/archives\/2005\/08\/07\/fun-with-http-headers\n # See http:\/\/royal.pingdom.com\/2012\/08\/15\/fun-and-unusual-http-response-headers\/\n # set resp.http.X-Thank-You = \"for bothering to look at my HTTP headers\";\n # set resp.http.X-Answer = \"42\";\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_deliver {\n# return (deliver);\n# }\n\n# vcl_synth: Called to deliver a synthetic object. A synthetic object is generated in VCL,\n# not fetched from the backend. It is typically contructed using the synthetic() function.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-synth\n\/*\n * We can come here \"invisibly\" with the following errors: 413, 417 & 503\n *\/\nsub vcl_synth {\n \/* Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_synth;\n\n \/* Try to restart request in case of failure *\/\n # Note that max_restarts defaults to 4\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if (resp.status == 503 && req.restarts < 4) {\n return(restart);\n }\n\n \/* Set common headers for synthetic responses *\/\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n\n \/* HTTP Authentification client request *\/\n # Empty in simple configs. SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* Error page & refresh \/ redirections *\/\n # We have plenty of choices when we have to serve an error to the client, \n # from the default error page to javascript black magic or plain redirections.\n # Adding some external statistic javascript to track failures served to clients is strongly suggested.\n # We can't use external resources on synthetic content, everything must be inlined.\n # If we need to include images we can embed them in base64 encoding.\n # Here is the default error page for Varnish 4 (not so pretty)\n # We're using error 200 for monitoring puposes which should not be retried client side *\/\n if ( resp.status != 200) {\n set resp.http.Retry-After = \"5\";\n }\n\n ## Example custom 403 error page.\n #if (resp.status == 403) {\n # synthetic(std.fileread(\"\/403.html\"));\n # return(deliver);\n #}\n \n # Consider add some analytics stuff to trace accesses\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning inconditionally.\n return (deliver);\n}\n\n#######################################################################\n# Backend Fetch\n\n# vcl_backend_fetch: Called before sending the backend request. In this subroutine you typically alter the request before it gets to the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-fetch\n# sub vcl_backend_fetch {\n# return (fetch);\n# }\n\n# vcl_backend_response: Called after the response headers has been successfully retrieved from the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-response\nsub vcl_backend_response {\n \/* Caching exceptions *\/\n # Varnish will cache objects with response codes: 200, 203, 300, 301, 302, 307, 404 & 410.\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/VCL_Basics.html#the-initial-value-of-beresp-ttl\n # Drupal's Imagecache module can return a 307 redirection to the requested url itself and, depending on Drupal's cache settings,\n # this could lead to a redirection loop being cached for a long time but also we want Varnish to shield a little the backend.\n # See http:\/\/drupal.org\/node\/1248010\n # See http:\/\/drupal.org\/node\/310656\n if (beresp.status == 307 &&\n #TODO# verify that this work better than 'bereq.url ~ \"imagecache\"' *\/\n beresp.http.Location == bereq.url &&\n beresp.ttl > 5s) {\n set beresp.ttl = 5s;\n set beresp.http.cache-control = \"max-age=5\";\n }\n\n \/* Request retrial *\/\n if ( beresp.status == 500\n || beresp.status == 503\n ) {\n #TODO# consider not restarting POST requests as seenV3 on https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleSaintMode\n return (retry);\n }\n\n \/* Enable grace mode. Related with vcl_hit *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n set beresp.grace = 1h;\n\n \/* Strip cookies from the following static file types for all users. Related with our 12th stage on vcl_recv *\/\n if (bereq.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|woff2|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\") {\n unset beresp.http.set-cookie;\n }\n\n \/* Gzip response *\/\n # Empty in simple configs\n # Use Varnish to Gzip respone, if suitable, before storing it on cache\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html\n if ( ! beresp.http.Content-Encoding\n && ( beresp.http.content-type ~ \"text\"\n || beresp.http.content-type ~ \"application\/x-javascript\"\n || beresp.http.content-type ~ \"application\/javascript\"\n || beresp.http.content-type ~ \"application\/rss+xml\"\n || beresp.http.content-type ~ \"application\/xml\"\n || beresp.http.content-type ~ \"Application\/JSON\")\n ) {\n set beresp.do_gzip = true;\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # We can add the name of the backend that has processed the request:\n # set beresp.http.X-Backend = beresp.backend.name;\n # We can use a header to tell if the object was gziped by Varnish\n # if (beresp.do_gzip) {\n # set beresp.http.X-Varnish-Gzipped = \"yes\";\n # } else {\n # set beresp.http.X-Varnish-Gizipped = \"no\";\n # }\n # We can also add headers informing whether the object is cacheable or not and why.\n # https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Varnish3.0\n if (beresp.ttl <= 0s) {\n \/* Varnish determined the object was not cacheable *\/\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n } elsif (bereq.http.Cookie ~ \"(SESS|SSESS|NO_CACHE|OATMEAL|CHOCOLATECHIP)\") {\n \/* We don't wish to cache content for logged in users or with certain cookies. Related with our 9th stage on vcl_recv *\/\n set beresp.http.X-Cacheable = \"NO:Cookies\";\n # return(hit_for_pass);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n \/* We are respecting the Cache-Control=private header from the backend *\/\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n # return(hit_for_pass);\n } else {\n \/* Varnish determined the object was cacheable *\/\n set beresp.http.X-Cacheable = \"YES\";\n }\n\n \/* Further header manipulation *\/\n # Empty in simple configs.\n # We can also unset some headers to prevent information disclosure and save some cache space\n # unset beresp.http.Server;\n # unset beresp.http.X-Powered-By;\n # Retry count\n if ( bereq.retries > 0) {\n set beresp.http.X-Retries = bereq.retries;\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_backend_response {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Surrogate-control ~ \"no-store\" ||\n# (!beresp.http.Surrogate-Control &&\n# beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n# beresp.http.Vary == \"*\") {\n# \/*\n# * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# *\/\n# set beresp.ttl = 120s;\n# set beresp.uncacheable = true;\n# }\n# return (deliver);\n# }\n\n# vcl_backend_error: This subroutine is called if we fail the backend fetch.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-error\nsub vcl_backend_error {\n\n \/* Try to restart request in case of failure *\/\n #TODO# Confirm max_retries default value\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if (bereq.retries < 4) {\n return (retry);\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # Retry count\n if ( bereq.retries > 0) {\n set beresp.http.X-Retries = bereq.retries;\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + beresp.status + \" \" + beresp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + beresp.status + \" \" + beresp.reason + {\"<\/h1>\n <p>\"} + beresp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + bereq.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this point.\n return (deliver);\n}\n\n#######################################################################\n# Housekeeping\n\n# vcl_init: Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-init\n# Here is where you should declare your directors now.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-backends.html#directors\n# Empty in simple configs\n# sub vcl_init {\n# return (ok);\n# }\n\n# vcl_fini: Called when VCL is discarded only after all requests have exited the VCL. Typically used to clean up VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-fini\n# sub vcl_fini {\n# return (ok);\n# }\n\n","returncode":0,"stderr":"","license":"unknown","lang":"VCL"} {"commit":"b26fc96ad8727c86a1356bdf6c37e792e0c685dd","subject":"update varnish vcl to 4.0","message":"update varnish vcl to 4.0\n","repos":"KhanovaSkola\/khanovaskola-v3,KhanovaSkola\/khanovaskola-v3,KhanovaSkola\/khanovaskola-v3,KhanovaSkola\/khanovaskola-v3,KhanovaSkola\/khanovaskola-v3,KhanovaSkola\/khanovaskola-v3","old_file":"production\/varnish.vcl","new_file":"production\/varnish.vcl","new_contents":"vcl 4.0;\n\n# Disable esi xml check on varnish Startup\n# Example:\n# DAEMON_OPTS=\"-a :6081 \\\n# -T localhost:6082 \\\n# -p feature=+esi_disable_xml_check\n#\n\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8085\";\n}\n\nsub vcl_recv {\n\tif (req.method != \"GET\") {\n\t\treturn (pass);\n\t}\n\treturn (hash);\n}\n\nsub vcl_hash {\n\thash_data(req.url);\n\tif (req.url ~ \"\/esi\/headeruser($|\\?)\")\n\t{\n\t\thash_data(regsub(req.http.cookie, \".*PHPSESSID=([^;]+);.*\", \"\\1\"));\n\t}\n\treturn (lookup);\n}\n\nsub vcl_backend_response {\n\tset beresp.do_esi = true;\n\tset beresp.ttl = 15m;\n}\n","old_contents":"#\n# Requires Varnish 4\n#\n# Disable esi xml check on varnish Startup\n# Example:\n# DAEMON_OPTS=\"-a :6081 \\\n# -T localhost:6082 \\\n# -p feature=+esi_disable_xml_check\n#\n\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8085\";\n}\n\nsub vcl_hash {\n\thash_data(req.url);\n\tif (req.url ~ \"\/esi\/headeruser($|\\?)\")\n\t{\n\t\tset req.http.X-SID = regsub(req.http.cookie, \".*PHPSESSID=([^;]+);.*\", \"\\1\");\n\t\thash_data(req.http.X-SID);\n\t\tremove req.http.X-SID;\n\t}\n\treturn (hash);\n}\n\nsub vcl_recv {\n\tif (req.request != \"GET\") {\n\t\treturn (pass);\n\t}\n\treturn (lookup);\n}\n\nsub vcl_fetch {\n\tset beresp.do_esi = true;\n set beresp.ttl = 15m;\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"22dc13452088e1c913ce11661eb24316ad2cce9b","subject":"Don't unset x-pass for bypass requests nor process any ESIs","message":"Don't unset x-pass for bypass requests nor process any ESIs\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets\/recv.vcl","new_file":"etc\/vcl_snippets\/recv.vcl","new_contents":" # When using Magento tester to test whether your site is configured properly\n # this uses a bypass secret. By default we will use service ID as the bypass secret\n # however user can override this by defining a bypass_secret key in the\n # magentomodule_config edge dictionary\n if ( req.http.bypass-secret ) {\n declare local var.bypass-secret STRING;\n set var.bypass-secret = table.lookup(magentomodule_config, \"bypass_secret\", \"NONE\");\n if ( var.bypass-secret == req.http.bypass-secret ) {\n set req.http.x-pass = \"1\";\n set var.fastly_req_do_shield = false;\n set req.hash_always_miss = true;\n set req.esi = false;\n } else if ( var.bypass-secret == \"NONE\" && req.http.bypass-secret == req.service_id ) {\n set req.http.x-pass = \"1\";\n set var.fastly_req_do_shield = false;\n set req.hash_always_miss = true;\n set req.esi = false;\n } else {\n error 403 \"Bypass Secret incorrect\";\n }\n\n if (req.url == \"\/fastly-io-tester\") {\n # IO won't work for PASS requests\n unset req.http.x-pass;\n # IO requires shielding\n set var.fastly_req_do_shield = true;\n set req.hash_always_miss = true;\n set req.http.X-Fastly-Imageopto-Api = \"fastly\";\n }\n }\n\n # VCL required to support maintenance mode. Don't maintenance mode admin pages and supporting assets\n if (table.lookup(magentomodule_config, \"allow_super_users_during_maint\", \"0\") == \"1\" &&\n !req.http.Fastly-Client-Ip ~ maint_allowlist &&\n !req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" &&\n !req.url ~ \"^\/pub\/(static|error)\/\") {\n\n # If we end up here after a restart and there is a ResponseObject it means we got here after error\n # page VCL restart. We shouldn't touch it. Otherwise return a plain 503 error page\n if ( req.restarts > 0 && req.http.ResponseObject ) {\n set req.http.ResponseObject = \"970\";\n } else {\n error 503 \"Maintenance mode\";\n }\n }\n\n unset req.http.x-long-cache;\n\n # We want to force long cache times on any of the versioned assets\n if (req.url.path ~ \"^\/static\/version\\d*\/\") {\n set req.http.x-long-cache = \"1\";\n }\n\n # User's Cookie may contain some Magento Vary items we should vary on\n if (req.http.cookie:X-Magento-Vary) {\n set req.http.X-Magento-Vary = req.http.cookie:X-Magento-Vary;\n } else {\n unset req.http.X-Magento-Vary;\n }\n\n ############################################################################################################\n # Following code block controls purge by URL. By default we want to protect all URL purges. In general this\n # is addressed by adding Fastly-Purge-Requires-Auth request header in vcl_recv however this runs the risk of\n # exposing API tokens if user attempts to purge non-https URLs. For this reason inside the Magento module\n # we use X-Purge-Token. Unfortunately this breaks purge from the Fastly UI. Therefore in the next code block\n # we check for presence of X-Purge-Token. If it's not present we force the Fastly-Purge-Requires-Auth\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n if (req.http.X-Purge-Token && req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n } else {\n error 403;\n }\n } else {\n set req.http.Fastly-Purge-Requires-Auth = \"1\";\n }\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (fastly.ff.visits_this_service > 0) {\n # disable ESI processing on Origin Shield\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Make sure we lookup end user geo not shielding. More at https:\/\/docs.fastly.com\/vcl\/geolocation\/#using-geographic-variables-with-shielding\n set client.geo.ip_override = req.http.Fastly-Client-IP;\n\n if ((req.request == \"GET\" || req.request == \"HEAD\") && req.url.path ~ \"\/graphql\" && req.url.qs ~ \"query=\") {\n set req.http.graphql = \"1\";\n } else {\n unset req.http.graphql;\n }\n\n # geoip lookup\n if (req.url.path ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie:X-Magento-Vary || req.http.cookie:form_key) {\n error 980 \"GeoIP already processed\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url.qs !~ \"country_code=\" ) {\n set req.url = querystring.set(req.url, \"country_code\", if ( req.http.geo_override, req.http.geo_override, client.geo.country_code));\n }\n }\n } else if ( req.url.path !~ \"\/graphql\" ) {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking by default\n # and allow custom parameters to be set. List of parameters is configurable in admin\n set req.http.Magento-Original-URL = req.url;\n # Change the list of ignored parameters by configuring them in the Advanced section\n set req.url = querystring.regfilter(req.url, \"^(####QUERY_PARAMETERS####)$\");\n }\n\n # Don't allow clients to force a pass\n if (req.restarts == 0) {\n if ( !req.http.bypass-secret ) {\n unset req.http.x-pass;\n }\n unset req.http.Rate-Limit;\n unset req.http.magento-admin-path;\n }\n\n # Pass on checkout URLs. Because it's a snippet we want to execute this after backend selection so we handle it\n # in the request condition\n if (!req.http.x-long-cache && req.url ~ \"\/(checkout|customer\/section\/load)\") {\n set req.http.x-pass = \"1\";\n # Pass all admin actions\n # ####ADMIN_PATH#### is replaced with value of frontName from app\/etc\/env.php\n } else if ( req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" ) {\n set req.http.x-pass = \"1\";\n set req.http.magento-admin-path = \"1\";\n } else {\n # Sort the query arguments to increase cache hit ratio with query arguments that\n # may be out od order. In case you want to restore the unsorted URL add a snippet\n # after this one that sets req.url to req.http.Magento-Original-URL\n if ( !req.http.x-pass ) {\n set req.url = boltsort.sort(req.url);\n }\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.http.x-long-cache || req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n # GraphQL special headers handling because this area doesn't rely on X-Magento-Vary cookie\n if (req.http.graphql && !req.http.X-Magento-Cache-Id && req.http.Authorization ~ \"^Bearer\" ) {\n unset req.http.graphql;\n set req.http.x-pass = \"1\";\n }\n","old_contents":" # When using Magento tester to test whether your site is configured properly\n # this uses a bypass secret. By default we will use service ID as the bypass secret\n # however user can override this by defining a bypass_secret key in the\n # magentomodule_config edge dictionary\n if ( req.http.bypass-secret ) {\n declare local var.bypass-secret STRING;\n set var.bypass-secret = table.lookup(magentomodule_config, \"bypass_secret\", \"NONE\");\n if ( var.bypass-secret == req.http.bypass-secret ) {\n set req.http.x-pass = \"1\";\n set var.fastly_req_do_shield = false;\n set req.hash_always_miss = true;\n } else if ( var.bypass-secret == \"NONE\" && req.http.bypass-secret == req.service_id ) {\n set req.http.x-pass = \"1\";\n set var.fastly_req_do_shield = false;\n set req.hash_always_miss = true;\n } else {\n error 403 \"Bypass Secret incorrect\";\n }\n\n if (req.url == \"\/fastly-io-tester\") {\n # IO won't work for PASS requests\n unset req.http.x-pass;\n # IO requires shielding\n set var.fastly_req_do_shield = true;\n set req.hash_always_miss = true;\n set req.http.X-Fastly-Imageopto-Api = \"fastly\";\n }\n }\n\n # VCL required to support maintenance mode. Don't maintenance mode admin pages and supporting assets\n if (table.lookup(magentomodule_config, \"allow_super_users_during_maint\", \"0\") == \"1\" &&\n !req.http.Fastly-Client-Ip ~ maint_allowlist &&\n !req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" &&\n !req.url ~ \"^\/pub\/(static|error)\/\") {\n\n # If we end up here after a restart and there is a ResponseObject it means we got here after error\n # page VCL restart. We shouldn't touch it. Otherwise return a plain 503 error page\n if ( req.restarts > 0 && req.http.ResponseObject ) {\n set req.http.ResponseObject = \"970\";\n } else {\n error 503 \"Maintenance mode\";\n }\n }\n\n unset req.http.x-long-cache;\n\n # We want to force long cache times on any of the versioned assets\n if (req.url.path ~ \"^\/static\/version\\d*\/\") {\n set req.http.x-long-cache = \"1\";\n }\n\n # User's Cookie may contain some Magento Vary items we should vary on\n if (req.http.cookie:X-Magento-Vary) {\n set req.http.X-Magento-Vary = req.http.cookie:X-Magento-Vary;\n } else {\n unset req.http.X-Magento-Vary;\n }\n\n ############################################################################################################\n # Following code block controls purge by URL. By default we want to protect all URL purges. In general this\n # is addressed by adding Fastly-Purge-Requires-Auth request header in vcl_recv however this runs the risk of\n # exposing API tokens if user attempts to purge non-https URLs. For this reason inside the Magento module\n # we use X-Purge-Token. Unfortunately this breaks purge from the Fastly UI. Therefore in the next code block\n # we check for presence of X-Purge-Token. If it's not present we force the Fastly-Purge-Requires-Auth\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n if (req.http.X-Purge-Token && req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n } else {\n error 403;\n }\n } else {\n set req.http.Fastly-Purge-Requires-Auth = \"1\";\n }\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (fastly.ff.visits_this_service > 0) {\n # disable ESI processing on Origin Shield\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Make sure we lookup end user geo not shielding. More at https:\/\/docs.fastly.com\/vcl\/geolocation\/#using-geographic-variables-with-shielding\n set client.geo.ip_override = req.http.Fastly-Client-IP;\n\n if ((req.request == \"GET\" || req.request == \"HEAD\") && req.url.path ~ \"\/graphql\" && req.url.qs ~ \"query=\") {\n set req.http.graphql = \"1\";\n } else {\n unset req.http.graphql;\n }\n\n # geoip lookup\n if (req.url.path ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie:X-Magento-Vary || req.http.cookie:form_key) {\n error 980 \"GeoIP already processed\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url.qs !~ \"country_code=\" ) {\n set req.url = querystring.set(req.url, \"country_code\", if ( req.http.geo_override, req.http.geo_override, client.geo.country_code));\n }\n }\n } else if ( req.url.path !~ \"\/graphql\" ) {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking by default\n # and allow custom parameters to be set. List of parameters is configurable in admin\n set req.http.Magento-Original-URL = req.url;\n # Change the list of ignored parameters by configuring them in the Advanced section\n set req.url = querystring.regfilter(req.url, \"^(####QUERY_PARAMETERS####)$\");\n }\n\n # Don't allow clients to force a pass\n if (req.restarts == 0) {\n unset req.http.x-pass;\n unset req.http.Rate-Limit;\n unset req.http.magento-admin-path;\n }\n\n # Pass on checkout URLs. Because it's a snippet we want to execute this after backend selection so we handle it\n # in the request condition\n if (!req.http.x-long-cache && req.url ~ \"\/(checkout|customer\/section\/load)\") {\n set req.http.x-pass = \"1\";\n # Pass all admin actions\n # ####ADMIN_PATH#### is replaced with value of frontName from app\/etc\/env.php\n } else if ( req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" ) {\n set req.http.x-pass = \"1\";\n set req.http.magento-admin-path = \"1\";\n } else {\n # Sort the query arguments to increase cache hit ratio with query arguments that\n # may be out od order. In case you want to restore the unsorted URL add a snippet\n # after this one that sets req.url to req.http.Magento-Original-URL\n if ( !req.http.x-pass ) {\n set req.url = boltsort.sort(req.url);\n }\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.http.x-long-cache || req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n # GraphQL special headers handling because this area doesn't rely on X-Magento-Vary cookie\n if (req.http.graphql && !req.http.X-Magento-Cache-Id && req.http.Authorization ~ \"^Bearer\" ) {\n unset req.http.graphql;\n set req.http.x-pass = \"1\";\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"737b17286ec3db3b9a5688b975fdf57351ec3a4e","subject":"Improved error response","message":"Improved error response\n","repos":"holderdeord\/hdo-puppet,holderdeord\/hdo-puppet,holderdeord\/hdo-puppet,holderdeord\/hdo-puppet,holderdeord\/hdo-puppet","old_file":"modules\/varnish\/templates\/fastly.vcl_error.vcl","new_file":"modules\/varnish\/templates\/fastly.vcl_error.vcl","new_contents":"sub vcl_error {\n if (obj.status == 801) {\n set obj.status = 301;\n set obj.response = \"Moved Permanently\";\n set obj.http.Location = \"https:\/\/\" req.http.host req.url;\n synthetic {\"\"};\n return (deliver);\n }\n\n if (req.http.Fastly-Restart-On-Error) {\n if (obj.status == 503 && req.restarts == 0) {\n restart;\n }\n }\n\n#--FASTLY ERROR START\n {\n if (obj.status == 550) {\n return(deliver);\n }\n }\n#--FASTLY ERROR END\n\n #\n # error response if all else fails\n #\n\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n\n synthetic {\"\n <!DOCTYPE html>\n <html lang=\"no\">\n <head>\n <meta charset=\"UTF-8\">\n <title>Holder de ord<\/title>\n <meta property='og:description' content='Holder de ord er en politisk uavhengig organisasjon som kartlegger norske politiske partiers l\u00f8fter og sammenligner disse med hva de gj\u00f8r p\u00e5 storting og i regjering.' \/>\n <style type='text\/css' media='screen'>\n body{background: #f6f6f6; margin: 0; padding: 200px 20px 20px; font: 14px\/22px \"Helvetica Neue\", sans-serif; text-align: center; -webkit-font-smoothing: antialiased;}\n a {text-decoration: none; color: inherit;}\n h1 img {width: 290px; height: auto; border: none;}\n h1, h2 {font: inherit; margin: 0; opacity: 0.3}\n a:hover h1, a:hover h2 {opacity: 0.45;}\n <\/style>\n <\/head>\n <body>\n <a href='http:\/\/www.holderdeord.no'>\n <h1>\n <img alt='Holder de ord - Bringer politikken til folket' src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAhsAAAAuAgMAAAD8YTMZAAAADFBMVEUAAAAAAAAAAAAAAAA16TeWAAAABHRSTlMA\/qVIp765TgAABIJJREFUeF7N2D1u7DYQB3B9YIstZFd7BDXpt3CKREfYQn9KsAVEtd8rdARdQkcwkBgBsjeILrFHcJPKbR6C56xGYw6p4VqB7SIsd6nRjx8ih4z+p+UnmKMP+PnlXEIAXW18A\/A3zPMMuD7XfFYANATYlcRIABgKt0U\/O3LY3yLMpY9iALh133sCgC\/OI0DrMLYAKifgF4n3u3JwnUY7cBdwoF468PWSY2CYVR4l3lE5UnDjlQNdwIFx6cAYdmQEqxxHLQ6jHFv7TuWoQ45OORrtcGS9OIw40LkODnb\/QFblwBhwNMphwg4Ajw8kE5M46oUjpXnwBOM5qpeX7wOjbx+nMp4dRXT9hNJxnKv9xeFzQ9Xkw4unmZMOKOeAUXQ12Hi\/Ed5zxNTqhKyOg4TkxcEGLqaKleOYGnUFtPyIVzZUM4OxAfdoX+PdEN51bFATGK3voOcq5YhOZuGInlArB0ekj6Z\/dcTSrnRA6ztydPNsbZQjgdGOHEvHFlXIMWCcG9NJB7ODfm58x2munqL0HRxKOTYYF44UCDhSHsAMB6scauvIUPoOVMw32pGjWHMQB712JGjYU4ccKYzroL7id2rHFq1yWKs49ii0I0PHDazEUZKD8Z4jRsvTG71yxDisOJjbKYd4d8Y6To4jR+86MhTsR6EcCRo9LtoRo1UOGb899LhQnEIcDjtGpxwR6rX5wVztyI3tmFE5eNzEIewErXYMpXJQ83xHqh2OK0Ovv1vqRNexf2WnIcepUo6d8R3cTuXYlcJnR4KDOJKgg5zasVOOFFXAUVqHMkaJncU3dl1nFOY9yX980A5qPH6ZksR\/2HGDWjtOk8O8TEUczdJxPaBnBw8SuEyO0joa5aDJZqvGuH8cgDbgqOzOHkk4O+Cd\/XcUR3TJcVp3UOm1Y\/e2o2UHqugTHdH7Hc1nOrr3O4xy8DzV82PdcQg43js\/yvnx1e8l97+XuylZrC\/M0+rN7wV\/vnwDOs\/x3vVjCnOFKuB4e\/0oeJXP0Xrf7YfW08FcWMfW19MMjbeOfWh\/yaEdqP\/j\/lK7jvZD++2e4Kv7nHT0Zm2\/Xc8\/0vX8g7t4Lf\/Q+dgWxYV8bAznY+uODO1aPqYde\/SfnZ9uwvlpK\/lpIC\/cYfTz9VKqB\/P1dUe+nq9rx2CW5xepHjy\/rDsGCF2KnF9CjgSV78gxUvVL57l1RxY+z50w2mReO7aoFw7Dfdspxx5lyFEsHPmb59vYdVTWcVqeb3ckTcPn\/cOKgy8uWuUgMEduA45MnfeHem66sX3Ig5U+gF6JOuzguOkT+P5j4UiAI2+8vqOmFNG\/\/+Dt9BvfB813Ln2Uu5dYfMHCjsx14Jw82Pug+6narwIZYP44xx5k1HYVx9P3QQng3o9RKUL3Y61yBO\/HSnU\/hsp3hO\/HYkjTleMYdHRLRx92XNnQ1mGsw4y+g1+NrwHHXRRwxMpB1ZRDmLLP0RyS9\/n7PvO0w4xhRysOqSYO3SG9dYAdHFsc\/Lg5Rp7jh2nKPUchR4KD57g9qitXW37kqSAL0jg77onxL1YFWov3xdyXAAAAAElFTkSuQmCC\">\n <\/h1>\n <h2>tekniske problemer - straks tilbake<\/h2>\n <\/a>\n <\/body>\n <\/html>\n \"};\n\n return(deliver);\n}\n","old_contents":"sub vcl_error {\n if (obj.status == 801) {\n set obj.status = 301;\n set obj.response = \"Moved Permanently\";\n set obj.http.Location = \"https:\/\/\" req.http.host req.url;\n synthetic {\"\"};\n return (deliver);\n }\n\n if (req.http.Fastly-Restart-On-Error) {\n if (obj.status == 503 && req.restarts == 0) {\n restart;\n }\n }\n\n#--FASTLY ERROR START\n {\n if (obj.status == 550) {\n return(deliver);\n }\n }\n#--FASTLY ERROR END\n\n #\n # error response if all else fails\n #\n\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n\n if (req.url ~ \"widget\") {\n # no HTML response for widgets\n synthetic {\"\"};\n } else {\n\n synthetic {\"\n <!DOCTYPE html>\n <html>\n <head>\n <meta http-equiv='Content-Type' content='text\/html; charset=UTF-8' \/>\n <title>Holder de ord<\/title>\n <meta name='title' content='Holder de ord' \/>\n <meta property='og:description' content='Holder de ord er en politisk uavhengig organisasjon som kartlegger norske politiske partiers l\u00f8fter og sammenligner disse med hva de gj\u00f8r p\u00e5 storting og i regjering.' \/>\n <style type='text\/css' media='screen'>\n body{-webkit-font-smoothing:antialiased !important;}html body{margin:0;}#container{position:relative;}#logo{margin-left:auto;margin-right:auto;position:relative;width:300px;padding-bottom:20px;}.information{font-family:Verdana;font-size:16px;font-weight:100;color:#111;text-align:center;position:absolute;top:40%;left:50%;height:30%;width:50%;margin:-15% 0 0 -25%;}\n <\/style>\n <\/head>\n <body>\n <div class='container'>\n <div class='information'>\n <div id='logo'><a href='http:\/\/www.holderdeord.no'><img alt='Holder de ord - Bringer politikken til folket' src='data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAASwAAAC9CAYAAAAJMEAnAAAEJGlDQ1BJQ0MgUHJvZmlsZQAAOBGFVd9v21QUPolvUqQWPyBYR4eKxa9VU1u5GxqtxgZJk6XtShal6dgqJOQ6N4mpGwfb6baqT3uBNwb8AUDZAw9IPCENBmJ72fbAtElThyqqSUh76MQPISbtBVXhu3ZiJ1PEXPX6yznfOec7517bRD1fabWaGVWIlquunc8klZOnFpSeTYrSs9RLA9Sr6U4tkcvNEi7BFffO6+EdigjL7ZHu\/k72I796i9zRiSJPwG4VHX0Z+AxRzNRrtksUvwf7+Gm3BtzzHPDTNgQCqwKXfZwSeNHHJz1OIT8JjtAq6xWtCLwGPLzYZi+3YV8DGMiT4VVuG7oiZpGzrZJhcs\/hL49xtzH\/Dy6bdfTsXYNY+5yluWO4D4neK\/ZUvok\/17X0HPBLsF+vuUlhfwX4j\/rSfAJ4H1H0qZJ9dN7nR19frRTeBt4Fe9FwpwtN+2p1MXscGLHR9SXrmMgjONd1ZxKzpBeA71b4tNhj6JGoyFNp4GHgwUp9qplfmnFW5oTdy7NamcwCI49kv6fN5IAHgD+0rbyoBc3SOjczohbyS1drbq6pQdqumllRC\/0ymTtej8gpbbuVwpQfyw66dqEZyxZKxtHpJn+tZnpnEdrYBbueF9qQn93S7HQGGHnYP7w6L+YGHNtd1FJitqPAR+hERCNOFi1i1alKO6RQnjKUxL1GNjwlMsiEhcPLYTEiT9ISbN15OY\/jx4SMshe9LaJRpTvHr3C\/ybFYP1PZAfwfYrPsMBtnE6SwN9ib7AhLwTrBDgUKcm06FSrTfSj187xPdVQWOk5Q8vxAfSiIUc7Z7xr6zY\/+hpqwSyv0I0\/QMTRb7RMgBxNodTfSPqdraz\/sDjzKBrv4zu2+a2t0\/HHzjd2Lbcc2sG7GtsL42K+xLfxtUgI7YHqKlqHK8HbCCXgjHT1cAdMlDetv4FnQ2lLasaOl6vmB0CMmwT\/IPszSueHQqv6i\/qluqF+oF9TfO2qEGTumJH0qfSv9KH0nfS\/9TIp0Wboi\/SRdlb6RLgU5u++9nyXYe69fYRPdil1o1WufNSdTTsp75BfllPy8\/LI8G7AUuV8ek6fkvfDsCfbNDP0dvRh0CrNqTbV7LfEEGDQPJQadBtfGVMWEq3QWWdufk6ZSNsjG2PQjp3ZcnOWWing6noonSInvi0\/Ex+IzAreevPhe+CawpgP1\/pMTMDo64G0sTCXIM+KdOnFWRfQKdJvQzV1+Bt8OokmrdtY2yhVX2a+qrykJfMq4Ml3VR4cVzTQVz+UoNne4vcKLoyS+gyKO6EHe+75Fdt0Mbe5bRIf\/wjvrVmhbqBN97RD1vxrahvBOfOYzoosH9bq94uejSOQGkVM6sN\/7HelL4t10t9F4gPdVzydEOx83Gv+uNxo7XyL\/FtFl8z9ZAHF4bBsrEwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAXFpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IlhNUCBDb3JlIDQuNC4wIj4KICAgPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4KICAgICAgPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIKICAgICAgICAgICAgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIj4KICAgICAgICAgPHhtcDpDcmVhdG9yVG9vbD5BZG9iZSBQaG90b3Nob3AgQ1M1IE1hY2ludG9zaDwveG1wOkNyZWF0b3JUb29sPgogICAgICA8L3JkZjpEZXNjcmlwdGlvbj4KICAgPC9yZGY6UkRGPgo8L3g6eG1wbWV0YT4KJMk4MgAAQABJREFUeAHsvQmAXEd17l\/3dvcsWmzLsrzgRaPFtjbbITZgCMRjICSQAC+ABAmQsATvxiwJj38WyyYkL3\/AYGxLtpU4bEkIEiRAgLBG4zzALHLAWJstjUbyJtuyvEmzdt973+87dW9PjzQz6pnukWbkLmn67lWnTp3z1alTW5AkibvgggsKTz\/99KzWOA7CMEzi9BhFUVgcaCqd98j9T61NksgdhvD8efOOKzrXksvl4srkREvLwMCzGx5+uKfy\/kScB9d35N2SPUmyfHk5z8HNNx\/jguAsF+aXuSRZ4hJ3pgv4S9xcjjM4Oo6OZ928t5PrbVxv47jFhclGl8\/fn1xyyTMZvcG6dTk3Z06QtLeXsnv1PAaEpUuXTi90d+efpUyzuI+hbHU9a9asng0bNsDqIxvOWbjw9GLRnREELoHkGHEUF8cdciGSEgS9+WLY4\/LR\/ub+\/n3DyQxpheeff37u7rvvjtCBIbI27sSH+fC8k0+eHra2FirLYJjXJuxWVt6tra29GzduHKg2IWHCvn37ji0MDOT70MUMG6r9vvI94UlpoLmUzEgGZsyY0Tec3F0cXJx3rsOtT5JR9SEQYC1esOCcIHarkOpjkJZ+boUIUIQIzUADd4Y5d8XGzs4HVMgTUbhZvCL6sbYHPgYdr4GOpzmGWcaDJJgehMH1m3ZsW6t72TfZ83ocDUQ2bw6SlSuNacH114eAyvkuCn4LNXoFf893hcIs19TkkyvyGtrm4gp5DyG5UOAP\/isMICMDxaf59peA2X+5IPmuO\/HEDRkYkgbguGQIOPoPx\/eb8eXMM888plBMbiC9c5Mk2E95hqQPAAfT4Gsff3+9def29byfo0zLwDy+VMf2FWkaKJFusqRt4V\/Am5XQJmUaoGBz0DbugEBHxIcMBz0k8hTy+xiR7eTe\/S52m6I4v+W+B+97uDIBKWc9gUv5U96UBvn7aBIkr4Lv3Vwm0GR5r0x\/gs6pApIS+N9K\/H1BEv\/d5l07vrcC\/o5mfIgXApSlc89cGofJDUHizuB7dDEpQPn4igYiAhdQvkkPEVBpB7vhUCd82RwXC5sqyyMti1LGvwN5Y1oFCh0HNrwsDzJZFYfOid9YOa4Ylc4oxtG09MOJYrbFu+\/8fYHbGzy\/KZ8\/m3qSJNPkOOSC0JVKJTEvC3WlJVizpoAFZBaHAdXxc17pZp\/4dorod930abPEcgMnAVSxCJjzj1KAGIHqIC1i3EB\/7Pr70+dBDoA7DhBrh6ntrqfnA+7xJ74V3HLrP7m9j3+vDI4V6WcZHM9xeUpLvjdfSPIDr2jKF+ZFUWzkizQsaCvjOIk\/q\/jbXbv0q6xg40mzlm9IeUYY5grQpr\/pJtq1RegLQyUiNUnjUt5RwIEwLG1d0rbghzz73kDO\/Xj79u2PZzV+pqy1JJ9+q2RNufl5MWXwAqyMOkQ7tijK5R2T9zj+F3294\/zzJa8jVlB9fX3GsjhwxyCvFxXyhZZSHJn+jQ+tSI0PfRUlCnyw8oiTUpgvbV7ctvC7vPFvW3Zuu0tlYQI5QkVqgJUkuSJZeiaJo2OJboCaiDYE6Jy4Fojem8POzhI6DMdnBFYwuJ9M5JA4SMNOCJM8J70V6Y+bfxVxSKADd31HLlmZgtXq1S8AqN7LO292M2cUXD8VQ2+PpE08UGFjqTjRNRgqz60STZ+LQqDAFQdi+9N3Aq\/mpj90+\/avcLPnrAtuvvWm5OrLfyKwNGtr5cqIz2rOWy7Yj6nRtLcURfMQjn54iOWSFKmQVOMOIBR9gxk4omcDUuY0wwP4IySTNecfqPJslPyo6nAuj9I0hUHuXOq+c6M4vqIpSn6KsqxLXOnftu7c2SVluTgI8h3YzPCsLghD8k9TBjIAVBmKFsnQYBiv1TIYw\/Bn5Dkrb45Y1L68Z86cWRVvKZNSGAZ7AatTKZMe2hLNnqfDJzeWu9Aj\/Mohg3kqq3M5P7cUx++hIvknNOTT8Gob8dGyP9j6TwHLAFAFqpLKQ1iouknXZDRXB\/mpPj+gJ2YA6SJgZEoljdaLFGhTe6t+wSwpopOVg4U1zQ2UAKrgTwGq2a4Pfd6\/v2gCRlOYt2jnlQMaJoEO+ZOVf2CQssR8o+9MQOGhQIz7AwORgVc+X3CtrX\/g9u\/7neCW1Te4vpk3Qke3aCJCNUtrVhhKMOf5lhQ4+jKlXLGuVO7D0H1gPib+mqZbKGmDnypqCbEVvk\/ZdMt+xkYJ4nJQ7igwajyaRj6+wOVzYe5FJPuiKMn9yZJ5C27rD91nO5PE\/IxyT6xP1o\/qT6mKJpROpJA3KlxjegVlFadVRTaGl4gaN4ppDlku0O4fU2KFfIJDEVCBkcBLpos+BygFeYl4dsiyETilVEuHQ4GK6BJHVCsEcSwfIoZ\/eCx\/V0Zx9Kql8878s01d277G\/YNAywBrODb4hCAWxMpSHO69qXovWIHTe9114lkSrFp1Frz8OADyOmXYgErMTZza7QQrF5USAgy3wzDv8oWQNjNSIVyq4JC+F5apSVvidczeNAIAK6HABML8RaUIsIpdczPNzfCjuDguDG655c8Aqq1KUf60zM+l69pDBY1EX3t8kzMGcV8FgFoI8FVwsjSkePLLivd2m2KKsbJk+uRxfSzieGNzFP8eFtfKLTu3\/1hgdfHFgNb6OoCWkiR4pg+yHrqk9LLcB2\/am\/X5If4S+ZWOF2M6NMYR6wF0pZcwEqlXJXzIQP48y3nTAEgtFX8TA8kqJ1VXlFiCQqAYudyZlMvapW0LLt+0s\/MfU9Aq+85lAQwbiNOKdtiHU\/xmsGJFLlm7XMie0CR7Gdj0VTdj5utcH63Q\/n5ZVbKmsmYf5S6HIWxuaSm46TPy5lQfKA643r5H8EltdN37f+p6un\/kj1z39T2Mn6sfUHNu+vS8fWdOb+KxBq4xUMpDk5P0+mjpzpjxe9DxNUCrXU8FVtYJYK8+F38oGylGiPdyDH9YTaEQKBeGBUw3moBBwRSD6gMu0izzVTDy7SskbtL8UVNZyvJKlOfrS9rO\/BNxXGAl0NJ5fYNUy8wK0dkkWiforxVeOOJuATbkCnD0\/B0AQqPmbBgM4Jb\/r0NVf8In1RZpuTRRHgWLwgwApQ9JPCa2HGDVr3IDXVfRRPzdlDo+IQLCBBRGmsQkPajJlaxdq1rNBTevfhWM+rybNuMkt+9ZCbRM1tSqsgx48JrW0oSlBJj1PcHdDfz9DHm7l0ZrF9Kue\/vpFSwBUoBZfrrri+ZQQm2uVFyGA\/6FxHkBltSJLsw14Q\/jdRSnbL0BWgKxfc\/GgOFZAN+6YNVt70yuvOwbGWjV19JS8pM4SAtgrgSU0234Vb+HkY+BkOSNT6ORbhV\/MI33jiGO2bx6EqV8CgozE8zLUz9RjPx44KKc0QFzpzg5\/GVxyW8zm3f+fvG8Bc\/b0tX5kQy06mlppQpKayh5iDbRIxBE9pRfy\/xoORzDM3IdJLiD41Zy2QtrHtHHM++uzoeVJmQgkSUKfTHAozEy+yD1RprX9yPnMxi1YPqUvTfkGLjmxEWMPghOgNen8t1CmL6IioXeajzT1gJR2ZKUQClJAKu4SOXRAvGfOPv0s39J2TzMI1l00XMKsMxntXKlSUVwy20vB6z+yU2bPsd1dxdhlniRFRC8xGfd3FyQP8319HVicP4bf19306ZtSN7xjtEc1nuJ5wH+7ubvK4zfanZB069jSb2W6zcQ59kUmiwrmetqIvo\/uZi6uweI\/wRA6wuA6ZuTq6\/4rluxIg6uuy6sh0+L9KdA8IhCLYt6RD\/dvLPzyrESra77bW1tM\/vC8ERa5\/PpFz2vFAcvIZ4XoyhzUJgC5rWag9IRayaiULK4UJZEHRJNXF+\/dN6C3KauzpUGWsjH+kOMEaqOTp+odJP0PxM3Fz5O73drfgCnZn5AVn8mg9VFN8pbpEF0HvufLg08q1dr8cvBEyoODW2Ke+iWu2PTjh27Rkl+2EdL2tpOwVV5fpREbwCkl1NBzIhwqoJU+k8SRnSojhgsw0WMrrqGiD5EPuTPMiUdNuKj7SZSEDDeSbV2HNx8+3mAz2dorgFWPSlYlQVFtUUIkOVdb+8+pOoOCmdNcsUVWzKeWFxr1gyC\/e7dg1XjKVToWbjkklJy9dW0M91d+gtuuv0zANW7UYxLAKZZNCf1ptKj9rD0m7gHaE0\/DtC6A9\/a6ymo\/wFoJd6ifTAdfXmUBzJb9pNIWKV91WQ5HWf0NO\/q737+vq0hC91PPP0C+p\/fzPUf0DyZg0XFqZqJ5gLQuUITyQygOU2w\/Fqc8U9u7ur89HrAChJqHrOmDEhA9Mc4pL1bt25FxrBYDkMYCw+HI4daHBkEVwTuERaTc7vmzZvX0razreTah\/vCuTkdHck6skowZm\/euXM3b35Df4vmn\/lVTN5PAkwLKAuBlpgi1FIlUiIpOiqSNy2ZP3\/VZg+OOI+fK2HdutCaWKtWzQbFb6X5dQY+J5gi0K4AK9W4LS1YVd3\/g1j9ZXLV5f+ZsQjgQIhpvl13nWpCCfqoQQISrF2bc5s3M2xi5UDy3kvVXfthrLtvA0wfca0tL2PYBIPfYiscL8VOzcYiPq3TsLhWB7fd9jq+fZy08y4d0DpqokfRQ7Evyw6j0uWkVbO9fC97lh4zLNBl0N7eHmT+mnRQqMrrx\/rDsf4lmhsfJL438FfAqqKJroGRRO1jaUJRBmj+NNFk+ZtF8xbet7Vr+7cZ41bXQFLmV4KGcOHChYXTtp8W2VjEOqWiIQzigY4dHR1qDY\/H8T4cNYlmFOiBwOpQVhv5s8Drml0QaqyXRt1v3bHt68vmLniSpvE6eghPBrO8pZWWA\/TK4JoHSr6cbz8j\/j8nAGtIj1sSXIdl9WIACXmhphhUAHovGDnbhKO8t\/crdOC8D+voIZ6rx67JLV9eFOjoGuCww6F+YLjEXwVLbxCKtm5dAdAcSK66rAPr6fdx8n8CB\/476K\/Ku1I0CFoql\/3d+LSmvwg6r+P7K0i7NCQf3DzqA6iR5RHQkcLpunwve1ZxHPGZmombly7NSVHUC8iwhZ89OvcBjbe7Frf+sbRKaKLjS8lAC0tLzUN8KdNpmn5k0RmLfrU1SR6p4+BSTGbv+yFbamoVtyXb6gUoFSyZ4NP2Q8eflpteNF3QScbHjbs6f7h47sK\/RT9uggfWG8i5xoGim95Zz8DEC\/nkM7KcpbBHdTCgWL7cBCG4adXrYcJVNMuUZ93L8u\/BSlNq+gf+0cWltwqsNPo9BYkBNGFEZaiGgfpeYCU\/miy15Mor9+JYfyfjsm42P1kuJ6eyLAgFrGKuNBYsCC7Hn\/UG3TQLUdOFGmHMHJCwC6ykFMuWLWuSVbBlZ+cnaZK8jebIQ9TwVN5YcFkpIzgoWh5LjDERuReEuZJ8KS4diV1uqo6ZkMoP1L4aDJXng3eP0jM\/SPdiM5jyuZjiSbapJ9GCLCuBllmEpgqL5tH01LOjX\/jVFET2ghtvPA6\/9l8y1gqcN3NWzm6eGHDlGH2uIQ1fck8sulR+JznLNfpcIGFMrNMPllIsS82c8Ur+qsvfy0DS25kcTWmYT9GnZ2O1sLrUPA2DP8ciU6+XwtFfZj6fE\/IrJRBwqYZXAlt2dX4D+fgjWiOP4ADGwjKfltBKzRFkRM1QSZB7N82Xl+obNWt0bITaODDHdVj1cO+OHY9RLj8z69ZHKeZTFBo7Ztr7vOl0oOjRUc14WTNlwMk3v50eugvMavE1m4crcaEFEOvtvQv+XJmsbFfTqyl1luvphAQDRTU1FWJ6Qvr7v+ma00pEICrqNNCxp5dJES3nA7lv06vWNGQcmc4bYfwcyKbhAEqBTQJPgvfR5uznUkAm36bpCvpSwMdSYsDUbNr171KK2bfjT73xpTiAM74cAKedwia4bgaGPTAvPGdBMpN5gsx3PsoBy23aJLV3wQ03nIAAvscLIY5HpFL3YRBDF5pCBm7uZRLCB9RMs0nQNN3s+QT\/WBOxDI7Rn+Js7wKcRJv3ZQhYtWqGD+8JPv0PJ9np8nq7f9MUnmOH9fT8yZmvbG\/atW0dRtUNXmDoncoc1LqB4hBUGK9d3Hbmi\/X+vvPP9zKki0aonQOJY9iFEOtgtsL5MIhCs4iPWgvLrKt0gKhrnvZahjGfwzIvMNasUHElsik2CCLhpuTyy3\/CzcAxFEE3DltYscImPSdXXcWUnOBjDDTF5U770HfrigwWS+FeU\/NSly\/ZyN+GL6t+pSNrST4txdiUd5\/GmrqLbnbVaVnTHJHBl0WbET8XXfkJMxLKvqyjVn+Ux8MagnRoianjQSkn+LesEj96Gb5piUG1gAvpe5NNp6GP2qwrD1JIKHI6ULzHtTTdYixK\/V0HsWsCb1jVzXpYlsRJJ\/wjoyXXW0+lrF+PreSDQY7ycSXJm2QBpuQcvWU3gfweLupNmzZpSZPcPSw1Q9P7Vo3PgulMH4HvFniKL8tX\/smr6DF8nm6zQKJZZ\/6dxu9YOVDZTkDUT1bdLCEvxyOjloCB2xtEiY1VOyqFXtLllm72GZ8z51xA4CU2EVl2vfKvZlbIJKsSFlcQ\/GPy7nc\/acCW9iaWGXaYTsxi6ujIq4mIwvwDfqsYgKVsNHFaI4ChmKmL\/L6E6T\/npGSpK9wK9DCRedQmo0ojc6SHcd83yeidWFOq23zTnBu8ksP60r3zgmDgfDFjzqY55ee6boTxccAs3MAt09coqAZFmveKCsNOOTySK07XgNOj1Ol+3XWDy7NE7qW2BpUf56Y8+6AVQUul7S5p+rLdwN8lZmWPD\/txzx6fdlLSKOANZlEJkHRXEKuVH5qaj2V4ym+INvU2MoC1AVhiRh0C47w0kj3Y+OCDTwJOX8cBr1hlZRkoweiQsVrMpQuZTB2+UA81NIJPjspKX\/mrKnRU9dZBL4nXe1y7yW9pX98LqBEuzNyGqhXEdw6aASLY+tU9j97TrUhGNGnL6MZLuYgxQgRG4+bpDg6rXQRM31QTiFe9XlHTY4\/le3JM46onbIQMOtMyMPJfwQHiltPd97Kx6mRy5bseMRrXrj2yteXgnMFnGQn\/PYZeMGmagax0IUI4zUMUh64qClBO35uNZqYa2bHxUzMHZGWlvixGuMc\/Aq8eA5xOQii06omZWzBbzUKVwa9prfZ7Hn20G8tMsjQ+2amAuuXON5AQ0bqWqfJVM3PqHIGASFiyftt69crmFs+d\/+dYtC1+eg6VM4E6WksEhdxTs\/x7uqfBvyMCFi9bRsE6FLz0pD7Ytm0b3t8JCebo\/vGDD\/ayBjaD++qTRnDjZ1maOFiaNosZuGwWpRRfY66EyT9QStYcTCdF1yflscciwYIOL\/xBdKcbSN6HZTgdJ7wahOIIUItesLdEcMOaE5IPXqJVIhqhjhxoaWnxMl8qbUvyzVtQppPUFky5Ly3yohS4s4rTp8uPtS1bUrhWMva4PXWS+lopqep7FvfLG9w+tPAhLbqYVPqjshg0bEH3zZJq93eZIiRRFwhFWroHsLqR9YNek1q0km+MCjFdXYPUE0nws0Lf\/m\/ra81JHBGwpM2+pFxznOQuXDR\/\/la6Fmdk3nqffH1+IVYeg75SPp7GSmsnGLnjjJr8BjSV\/NeF7lOx5E8zRUffTeIkFgKsUvFhXES\/9C8KDeyF7PLIHDPne7HILjvNDzBdfbHXkpQcNWsTd5prdqdw5wnmKPqp+LUw7MjkdFKmquk\/IkzNQiY9b+G0HdbaiqFpOaA\/Jkcn02BBtty2DOT0XZUhFUTMstgxlcGHbD4e6el5XYN0oh7xyoiR+oAotI1ja6KNx4iBnHDJGfMvJrIPcPoaZZk\/s6gs43RwgIYFmuDIe3CrLFm+scp8RMCCMM1MJyIAJEjWBHFITwrr10yAYhOvxIDVu4wjs4S2Sn9cpca3hLTQ88+jo+c4pl\/AZSVhyci855Wgi5+H9PKkCQCQaEne977dbFKxAxoXwwjxgYLg168uwAC6WLX7vQCzFRDnjVAfDlhHhpQbMdpucoiicIEypfPbrIS0QYOVgdPE6rEkrXhUlipQaunfp0VxImKp9aBkTvBEsllbMEBJbACslPir0P9DgYTyUUvM0IwCQV8CeCTB8+bNm7erOYqOLzU1jTgUSNuDBVFhepwvzeZU62EtXTx3wW8AVi\/FgpopUIIurbxqC2b6c8d+OCzKG8df2rxr2xdSmnmkyZ4jBhFmi+nksKpgql6snZnDJ5fFq\/XGVZpWcNnN4T8Z6S5LsZQVOYlZSE9z9ExCVEFwYs1Cfb1rokezj0TiiPeHNksf9P5eM5HVzy45pN7BFC+W5igOFeBkaM6OmJ8p9kD8TFcYLaHdDzL0KkKprGaH+6HXVgSIIkHNsjIog1x12fVibWUXBO20e9oNBOz2+ES+Ml3FICnXWDIFlP5RDj9sd+26URNgEbdAT9EeBzNua01y+1m2IcfiYrp3UOB92n4ComgakD+T62MBzmb+DLBZv130qJWg5WQkz7KytFwsLtz4f6Io90FFKt8Vz6xiGAWw9Kopi0Yvka6inPgAYdoEQ3wfdyAOT2sQHGsTi71lAkeIMt3wgPPHx53ABH5Ixs0M5LA3tQxJzfLjS0CdUkEwcwJJeE5HvWfPHtP0OMztwX37LJI4S7pUZopkC5Sh7tAOU1mQvA6+k90d\/ahylpKO\/tYYn1psFqm13hAV21NgjLGM9LrHAyLNA+RnVa2mps2+kSDSVBEAUrJatTpGOt6QyleSjX6yU889IM47tF+hwIxvylbsIQBLhEOkrbfMaX15OyxXlFjdQhwVbHhAOUJlAHmUkASBFnebXEE4raEK3tLSGk3QCYllvhvdXMfTy4SnA2TL142TunAAtsu\/dGAnk0DGrF0Ua7AMfCmNMV3qHwOW2qyeYRJFxwM2UE1s9D76VJNVdXD8BlpOK7YSd1kyD36v4k6FsUOWZTLIauWPM4vBozbOd9pA8c\/yQfK6ex\/c8Vg6QX1Ic7MKwCJqz1lFXR2BFbSO9ZQsmAkx1u+GfZ9m+7D3ddM3D0d8fMQfWD0\/EhUV+0RmA2RHerVxf1wcoJ5Hi4YtBDNdRno4lsSQdSnUsImMJZ7KdxUnIT34i\/r\/AlW2A5Gp18g6liXs34AmmSMpaUO\/0k0wlpuJOz0Kwt\/m+vOaNgX4ij\/lt0cHLIvGox\/jJMC\/NLGMkAk4Yi6m+FiHxALXa36fMtmeL+I2fKs06ScgJ+OI0rPaF452QVZdVDaGFR\/XVqjx\/nHE3vhkDBygZ1xO4APBRGWDH8dKgmU0agmKxGtjLbEM9y0xM7hVsi5xiWXN1D+kRgwARGfBIaIX16TVJrwGPl4DjY362CJgqAQL9IXhKbz2OTYBadMmIHwlH6F8Z2Ypjg5YSsO4ipMxTh5mN4sOou7HS0ZBGhWHoLS6x4bXWuDfL+1xMQSeTtKWdnUxVLxFcwoaUz9QvNcU3vymaXRZtLGz+WAVX06KU6j0jE3Y8cXYTDnJK2vlyo+GNkzG5uyk4F7tRJSHKYTxDHrGp3lzKuU\/0SObFIIVkc1tS1P0ZTam5K1JSOHWt8kGKIjCImJuaxWh7kOaVGMiccSXiZ1UNABrxFfSB2KMfwtzBymW+gl7pN+c4sfyriu9TmRMf4ojOgxyKPD1i+cvfHTLju1r7Blf65NRAEvxEQm1PF73u2HrOzY\/0LlR9yYqQFO4pG3+V+mYOT2mm0AZGFda6in0fqBH4Uw3lsp0b6mIdYbUqjnna7dnFumznSDGlU69P0rptiWZg+AMK2k\/Mt+kW5t7s5Sy9ja0DgMyk+Wz3pQ8Z+Obn47FCqLcSdhSM5Af2A0IwGrpmnguVeNkj5gkmeVgulId0\/iYjwjyht3Bh5\/lrxkTQr3xGBkGkdVFNcxbxIqoa\/yRlhjGq10I7tOxw3UMsdV1bzyBnAsRRb2c59\/k5BskVWLAgyzSoXzwcwSKeNVb+OoEPpkLaefAgXPpXGxVXjXdyX8mFhuiMQVK6+mzN2ESXb94wYK7eO9e9RTy\/QjbfIka1puGrDxgJQfe\/9kywWBFikLdePG8haOhqF4bNcAxEyp7KQge4upxegrnSbfFaw4YiqrY3AKWJ17Ae\/fqXZUB6Q9luEVyGH+yqTa7n5yLssyXskA01ZFNocKlYmW2l\/mEfjoRAGdzCg8jiUdzUqkMeMUOkjYbvqAJz\/Izeckw8wVF7UWmrAza29vDsexZqGikXvrjZ+Pmru0\/1ulEhvrJthQIZgAs8OCO3iC+qqurqzz4tZo8LFiw4NjmOFzMcIs3AVTvxJo6nrhgC8Ju9YLpYR6wYjR57mRGPvwZ8f6RlrgmH6PvmgNd6ll\/LBcF94iYedrSp40tfTp0Vb+g4f0aMXv66ae3zsw15bxs1CH+JUt2u41bOg2wBFXAO4zxzSrtTxe7F5OKAZYHhzqkWUsUmzebHDPN9gVEc5o1\/8rxQbemEgauy+Ujm7mubcvKjxsnNXOg3bWrRiixQUXetbmlKIhEht5aPwiTa6wB1fTBbuz\/B5VgNgxiPIlTotZs07dKs15W0IG01Ksihl5N\/taqFfujnLu9q7Orb6xg2NnZ+Qz0\/UR\/bD7xRfYkvAnQekklaAmYeM7kX3YyYv2xZQsWvGBjZ+fPl8P44ZuEUGZGL9ohMI2avHm5c+fOARDVnF8HMqWWawmCvmdCZPGxrgdIvT4haWe5401bfkFmXkmMADrWihyp8gNprfS+6NXcXyMr5UgPwDTVGNzG65XQF7LTtMiWUxOeUBJWju4X7JHYcLrXR0SGxLJnqR+D9UjbTmbjh7+e2ttmYqkEFAzDnLuvaUaTAVbZ5+Uf1\/QrYBEA1BTJAR\/XC6wULQIoG0jYsB9EMcsKndXW84DLIUNAhcDXwLLsIHRxy67td5932plvLuaTr+JsPx+rq9w85HkoUGCowyxajVo08eeaSygkGzaIOD2g0CoZWHk+7HfjvGnxZvvIjTOOwc9Sx7u\/Ef7IFF\/NqbSxzP1S2iy8KLjllgvsPayVegvLIEFVnPmJzy5YvXohdF5sX1hHhDVHKAVERauRxsmPyrGlU3nK142TmjjAQn7WHMwlwW8gLGem00aYKaFopfoJSydbEhvYyMIqjbFOzRlCYEXVjxrblaVSx58h6dV4ISNG2UcY2ZbQt86ev3074z9wHB36L9J8yfXItN7VGCtEOrznoW0PEeO1gBWzCmwcEslIVW1UvSxaYdBvaAaCvhsRsCrzxse+mCpvTuJziKWP4XoDQfbI\/DmkbvcrdqaQJZ9EkUqhqXkWEP52ZUWL6IkzRyIYUG5KVx2N3Zuhtc0v2JfVttClLchK0QNsSCxzWnslanPWCpE\/EpQfPWlKgVCI6IJTT50Gd9+QTm0pZmYt99TlHjCdpBczwyqNTInqxAUvr3WKbIKjgQW4tgl72tvHRbfGWMn\/pzjwhf0Xh5+oTvZBZpKu1PKyZBY80fnQXD2rCrDSWKbkgbXSHyHP37cpOj6\/vlko60UhCd4S3LLGr+KZWjmHPaO3355P1i6P6LU8g7T\/iK4d+dlEH2ahSoyC1EpAQfL95Ko\/6Trs9B3lCUo35t8938C\/p6n1dWT31bROZFN5\/ZAe4RqRs5n\/G1wxv0EsqVuLQJE9B4OWmlG2zXHP2onW3paUpyhVNi+Yg8jkTtuA5egFrMpmYeK+wjZeJZcvNwvFp9CaWC0t7HfGjjUELJZScJi30JLvTPsfKn03UPoAu+acZU1YVTAKMpA1G7S3h7NwrW7xIGAnalMwXTdCbRyQH2ZtsjY6Z\/58lCJ5H7NvpTS2zrvFDHJxbPKH4BtbHtqyV\/drag5axI2fjAPI9DNp1ZzdsqMhGrxn8qZNhTpqActQmk0lLNfNuTvB7fWu0CQAEBDoV13VJSdDJnBvDW5Z\/WZ7ly20zAFvFxP7Y8DjLjIag1W3\/R41zHusWRqzbbpZV6nLoLlZhHyH5m2HTmjuqic1LUu70\/gZJwfUFMzWdCrFwYfCIPci22dXYxTFYUkLTmV6x3B7JtsjF31dSWl1UgCsUWmIGXUI2K448Y3h4vjQoOFVaY\/qUQtYluNsgTtZMEl4u22X5Z0TmaDlWSudvQlbZHr9TXDT7WeaL4uP1UwYyrX6XhlYrVmTt41b5Wh3ycfY0HUaY8OEoLT\/CKrSqe6xruRsX22br4qulSvNOVxfip57sQms5EtRzhlVfQlK8wGPQRod7svfQClx1HQUR5D8031dXVt1joNelUoj1IkDjI8ecQA3ZVBgfSx2Oz7KfVjmlF671oPy3se+RhX5n7bLs8+3t7WQTJpgCVvYL2D802ptaW\/fLU+\/q1OBVEZjFlxHR05NweDWW2cxQeF20l\/Mhq7ev+ahUtVN7FoZfpEkX3TvvfIbFsd11zWsq0pmjuMczA8rwWpp24K3MuT6Uzarw+8H6SsM1Sp4l9UiZyDjL\/O54B+VXOqgzyq9cVDQ+CTlgGTcApVFr11UmgnSUG7yTKPfj37AMk7g6zE\/kcY4BfHfue7uHs1XMOvFs0tNwwSwcIDGK+k5XMP7LeYE156GdQ7EbcpgY8RWrZrNPIovkO7L8bEBTJaYH1VNj5Vrac67\/fsfA7f+D7VMop5Blp957lhXSGo92S+gskGhcDqzrJgKdiXI8w\/0ALLInHXEDDYF5ceiW5YmopxYH7t3+\/YHFQe+q4Z1Vc+CIS6kewQLyxBL\/hsDLF+T1DnxyRQd2S1P1WEr+v\/GV\/V33PqIRqTBJdWSoapR7mmRwhw2zekACN10g+tt1yM\/BjZEJMe+4gs+fevZjFyXZXWRgSWef0vfJ1aiKZhnuUhV8dcmV17lR+PTxFXwr4z\/N0UBO8xxc2qOb\/yUTPyXAph2Vtuc4zrEOoG9WUbL5s07OXbhSuTgMj\/VJAUrkSRp0FQQF9AU0fTN4JYtXdu\/qEftyMv6rIdZN2oJoc10qSWGo+Zb5sv15kYYFipBRUifG4CVlSiZTrtLw80pEEgq\/eOErYQKbFTeg5kThH+dfOhD+1KrzIQ7i2MsRxSFnjyalUttuk0MUJUtIxzsv8\/swE8AVvOxrGTfyfjVEAYFvZe3pmt3923JVZf72epYZhnY2Vvj\/TFlxKPHQD1FsaedhTXRwPFGN6HfVQCDNjqFpSoPye9IIWD6ht+lhSODMcGdQZDSR+edfN704rTuN7KDwIewqpZqcChDGARO5WYg31i5qylYiuPvFJLiSn1rzciEqTp1ClgVlZba5CyDOuX1UNFQqKYIle+hFlJb+4eGMD5ulH0JKz+c8ueMYkca4uBTn2p1Ta2X2xb1fX0SSjW\/8BshrNq2vlj6anLlpd8ysFm7Ng9ojQOwLiLaO7VyKCDFYNSKwHivReDR+ymB97jmZlbr6tVzlYhvevqlqEM3gx7c7v3fwuj73\/pczci6gJUigxHkL2TdR6uxNBdOAyDndMxJ6rnVVAVYKNWxBAESfLcND041WgEQraKwASThmf7GHM5ZuPD0qBS\/yrUE72CCyUvlrwKnFCFaYSsBqCTMsiLyIE9nBwuGbCgkuSt+tWv7U5U+rzEnfuAHyoGp4uBcQoZWaOR3CWtQ+Z+QQJnYiPQJiXx8kdpUJIpVyNQn5vvWzgGRiSN4mXX3qG8SylISeJg11dT0WgaQvsJGuSv3nhEJ4OFcT\/cuhgau1G0xkMOAzscX2sufBWxB73615TwmGqygMP7ItU472Xor+\/rVBBRQeQGVNSHgnA5Y7e++kyfvplfw2fqBlbLkd0LCstDmBBog+XmmmNSQT0U5ehD4p\/wc\/cXsqbXOqUUku869jIXc3sajz2u2fvbKoY5K85wzzjhuIJc7PRcH5xDTRXzzcubtLlDtMGhVsfAAJrWVgLHHxl4V1JEMWP2CFtsf\/2rXfTvk99qQ+N7EQ6V9qOepyAHINg3lNefOnbv6V7t2PZUNrTjU97U+H3N51Jpgld9jNfRRGCX4w27bQ4N4hgI\/NwBLKxqgMDjeP9viZofeuupVb1zqt2JhHtsGPgnuSN576bahrKr+SoIAMBbc8ce3AIqzqAvmYiE9H8F8OeDT7qZNP8bS6emR9UDENuufI5qpnqkcw9tbAM793d\/FCntncsVVj5ad7CtXVk\/IyG9a7QUvmCDPXntB8Eb23rsVt8FqTI193FcWDpSVkWMb5Uk+yueisNizZdeux4z3ipgwyidDHiGgtsIkY59YZiS5aem8BYtZNcRGl4vO7OU0WjGyhbvNZJBdWdxJi9sWnM44loVhHMynnGez0JRV3gJBwMqsWqXhZcAqKFufnHtYOTQDo3g9W85dsvHBbdu1DlOHb6ZnydZ2NC57QGamz0tKSeH2s89Y8HFmXj1WigqUCxvnTkCI46aQ+X\/PwD8b9DoBSYw3SpUnAhl1M7GgSJnIf5yFirJ+DlhYQ6yr2T2vZz2pdhvdbuxAxK0S56IU4ZdILsS3dAfLT7WqEs44VtVRrZebV8taVTsbsHKnUiecih+q2ZaEGSB6AZVPEasKtZJYJgwQRYCx8Aq2rmB3z+ddqf8a9iV8WpaVu24lbZbqFZ0YRw+kqeYPUdqyswDCZaDXHyIuT5hk1KwqAj1XjMKYbeHy3\/21trZLIehp\/E\/iDUyoNsgOYpCJ9utk5yMw48MMLPAwTwKVQQlarvSBHnCtO+KaikXsA4BUnsqd3q4EKvFB6ywVbGCoXFdJvAaf1Yd\/9eCupy7G4u0ArOpdBkaGj5SWKW63MHlNFAWPYWCQPuhq7laorUMgMrGCdKJjwkJpNVGuVLTkeUyVSB1IOSgKsUB02IM4v59e\/D4Im+YL74DXk2CG7hzdTcIh1lVwuWvGT9WL78rLNKWG8DJ8mSPWzbTX+AnSGVaJj5LxakL6rl6XeKgSLyF8fQzeDXCie2A0fUqj9M7WfMH7znp7mJYQ\/C0O9o8pNQ9W16EoK6sloBoiy++QfVkwmmJPmyg8BqPimPLDmk68JaNsFYulBX0lDcgVG\/q8UI4xbtEJjSCVMCUV7GHikImqKsbDk3E445vS1YdERS4VeELWFaHACqDy93G8b4+D5G+3dnV+Rq\/Jr7e+wumve\/UNkCVCrAyC6dAx38c\/LlaNSJoYoYzLDVAqlahIy0EJZXwq3zzg5FDPD3h9XJeW4TgsdaOOWnb6+CwWKzd4JLil8rE9GEYELArf3s8+nmpHs66y1QxO6PtflNhFjCLPsmFMsuLKwEvNRBWgf5K9V8tRciJLyvf+CbikVgLJXB6gwvLtZ7mYnp7v885Hkqsv+79KTGBlDva6NAOHlOGQnEmDpbqyYki\/XoKpNAYwaFowErpzwf6xxutprKBUoGWVgAT30IFMKV+ELA6+EpBhbGHNKiZMGEw2fqxcAIw9vP1FFmP41Naurp36VD4rLYWi84kNQmFrHlIGVeVvzOTAjzTimOktAYP9yqEqfpbfnqAT9eoqxANN+8Om0jO+VtEdkScfhfkuNbnzhPNOPnl6BWBxywcVMZLuM2ocTR8cjoOlBwVKX3ToR4Uq4iVwVdOQ9QzefHMzzZPLXAH\/UH+f+S+IS9EqkcEwttgHvxt6JgoFevqVU11HpUMzBF9ZoZCzJqIsr97S3WTp791JJ3yG6UCGpOmSMXVUlMEyhQwtjlaZY6OcG7p30P2h2RrDFTqYRlZVnIikb+tR0nxZpMS1ka64VhGqimrwffE9DRQAbaxAq+HnjTLDP4YyJMkDyMA34codWkhOr\/NcIAYJNiYrjaHmg9HCjx0rSCtHTO6UwTFmsvz5qCfkP+WFCXj1aQgrVDL+C5PjwXJJoxw15eoeUltYCoVZhWfj7tJj6aWIRl5pANhQFq0Xn5zaP23aaRWA5RPwRPF6mbNZhqsjoNa3ZOZY1Uf6pGyc4UfHqplt1lXWMxjksK7oJZJ1pfgEHuVCHEKtSrTqNIZ8OfRCPhIyQTJaNFBHXauJONCvGek\/h54vQ8Xa5PLLntKn1gRknFY2j3FodDVdGf9UpmQ9QwG7VxFrPfJs0Y0nIuy7gsY7CaMo8GYktIK08Zzyvf\/Px9mJd3IDUntI5F508buRi7+WzQtUKukI+Pr6qw4m3+SYnwkrg4OTrOlOBZ2IkECMAFfL5wx2qynMSXmh3urFbQvvI\/LfSiNM2eRdbaR+Wi525xpghXGUZ8+OGSz6TnnG3EOAWE9Z7d5ilBzHeBXDkJooq\/rjYIYJcMR6zqnbQZ9aV3NcYmJdOcC3kYOqyeCOO2gPB3\/pjsMPrgnEGhxoCnGwpTFyTGN8gkvMHOjMqWYRvj4GR1BrJPeT7k\/BjB+4pvBH2XIyB45+H2NKo74eJTPIafEYdYLiN07L1D4ZlW+jRlrFQ2CnWWmy0N3MYjxNgjRqSGtQWCS+qdBqQyzkV3YBbe2gG\/2iQkh2w\/f7if2eXBj\/rD+fu2fbtu0890G+KtZlElDV0bLNYueYJMiz1KxCmLmoeGOiTy0trz+xDb5ME9R92DJ8iGxF0fg4lSUdq82aGEJeDBNKYAKdBIYdrn3476u9u66SBtYaU+lrDBzlAZe4SNjBmiPdt7liqfRmSzQu0EMRu8+VotIMXhngBTll1f09HXx7GJKfSQkYMYPVEjjCexavBgdubFvw7WKx2M2NZzMTnW8Cds9Q1\/XGiu+HpYVvvG2mF3sjnIzBve7JJ+8j55hYQ4SmIqoaT2WNeuNZNHUjjk9yfASrtgtr6n6c+dszkFJKZaDSKqd1DpkA5AZy\/XFh4CvFqLQI4nqwsiSg+pvQIMUfiAdmUVY\/LxQLtH2dm7NpU9aTYWnzTrl3iE66\/2CUxePgPE5wdVBoFdzMGBwLqaQoR3oYIDvxU4ypeyKKw8dmlvY\/uuHhh4fMU5Nctbv2gIGUEwVUZdlELL4zEJXgv8tomPAyOIBrRgvzIafD2B9WPCvTWHGPsppjZZWP3eOlXPB5aNfGpvvgmZYoFiZM48PHg1z8hL7LFuGrjGMs58Spzg9vRrnoTsDwMzBIDvZ+4ZDFpZcEXGz+oRfHEv+UejdYwTLCrOQ5GYi2Zuopp+Tc7t0RTvUhCjwZ6DsSNAwK6sSnfrEG5ba3S8GQfY1faISpyIGjGrCOVIFIEZ2WtXnqqdCddVbi7rwzZlApenIU1w7jZDasCrF2fE06zjiGfNY+uHTxzJkzk9QCEEgdvTXzEAYc3RdlwJLgjJRVyvqw1Uim7CM3XSR3VQuexXXddYfXBGdpZrW+xkLnSHyv9f4heFlr9If6fkxldajIpurzI1wGB7JtTGUC7YcdE0ZLU5kpA9aBOWtcNzjQ4ECDA5ONAyMi6GQjtEFPgwMNDjQ40ACshgw0ONDgwJThQAOwpkxRNQhtcKDBgQZgNWSgwYEGB6YMBxqANWWKqkFogwMNDjQAqyEDDQ40ODBlONAArClTVA1CGxxocKABWA0ZaHCgwYEpw4EGYE2ZomoQ2uBAgwMNwGrIQIMDDQ5MGQ40AGvKFFWD0AYHGhxoAFZDBhocaHBgynCgAVhTpqgahDY40OBAA7AaMtDgQIMDU4YDDcCaMkXVILTBgQYH\/ELyDT40OHAYOWCL2mkdxuuv94srbtoUuKVLBxdmnESLIB5GtjSSqoID5QX8DrXSXxVxHfjKoADyZBKtwHkgnYf7Wko6ppUfDzeB9U6PDAcpOHmLXluawYPR0rE18LV905Ilidu8OZkMS0wb0I68Gu5o2Rnp2RAeHC4dSfMxEk11uT9ReSkDVl2oHCaSlDlhOwU9xy1P1rl1KiQrqInK1DBkNG4dZg5YufvlqUM3AkDZO5\/5TLOL4wL72bP1bFRMrr66vAVXJckGYGyOK\/A62jbxgA8hOyCbtZnuejQlK7RU1wPlRRukdng9N32vl65POGBVCl3lOZnL9jq09eLrlaHKNBrnh58DJrQCKu28XbGNWbBmzTTXFy1ml9xlVFdno56ncTwBmZ7O7msFjhJs7Xa7jw2\/HsO22sVztmfL3ev27r6\/EqRsm7SjELiy0hKAcS4AOyo2z5BMAGJhPcDYAGvZ\/PnnxXFwLQxiW\/dA26aP1xkvobMmD8c+BG4fq8Zrj75H2cxyVxTGO4Kmph1bt27dx71yWAF41SMz5QgrTsSsDAwXz5\/\/qiAJ\/4TrIpvY0SxJxpvPihSqP4UUNYWOY4+Kr2zesf3z+pJ72gPysG3yUT21Y38zs4IyoAKkCm4gfhky8DvE9hvIw5kc57gmtpjTxpwwYtgg7Iq0EW2RzU2TR3lvE+\/dCZB9O7n6sl9k3xhwLV9uW9dm9+p91Ear69evLy2eN68tSHJ\/AT1tUPcM5VYP\/28vOM1mr8FuZLEzDpNNM48\/fvOGDRuKygdpiEG2R6iuawmKK9ODpW0LX81us+8ivgESEP9GKIjqUyQC9hF0z6LnT7AFC5vXul0ll+8674H7d61lP8MspixPXI8LjD3Tk\/AUNqB8g7YJJ1NZ3OM8Ku9pHJxqf1GLk22Ic0nwZNJffGBJ28JfcvfOMB\/8973btz+YZUjAlfK1ngo8SFAcnsOuski46NOfHh2+oBTZl116+DinBljtfoureub38GUoTcmE8LrrclhBtnty8IkvTHet3W+m4N8Kn1\/kmpqnO+1ALVwWEJWEQ5yz46l+0EyxRqfUI1YogQFaoZB3udxpPD\/NlYq\/DePeH6y6bT0q\/Pnk8su\/WQbGdew\/WWHNpWTV5bBnzx6QFTvPFY6LXfTGQr4wq0QeyDN3PdnjSyj93nROUbGdbBI83v3E05uXzF347SSMUItkJ08i0lJrZFwKznfloHIiTnYuTc4r5PJvigVVNeWhHHX5ZDDGpDt0pcc3zp3fuXjegp8HcbI+nDntLpLfz8sGYOPJlwEWhJewqdiVPikQYQQrrZDKVIzrhJJI8cAOQVDgxklI50nUuC8gzfdEJbd98byFP+Dev27p2taRAdd4MlIViYkbiFAU8qi\/GHqG5jOlt6q4xvGSeMs2tzkK1XZEHkcUk+4Ts6quu86VwWr1bW91LclVaPSFrqU1tZQEUAMSUm0jL7kQp9OjFYHnvP3CHQGZtCnCIPW2Rghwha65ZQ47aa9wvX3\/K7jl1m+DIp8EuO4UWE20tVUKSmxJHTwbxfEspKefrYibIVT6WUOo0BEsBq7QjeAk5ORi4OtSKvbPNgfRzVw\/zUOFmqxx4vH0ogdxDIt1afdIuTJkV3o7O698XnmecaDiPTsNQ+00PY8I5sGvVyZBfE3c3bsR8PomKa+9r6trK0kLjBWqzldVZm1KU0ZaJbkjnUOzkMEeG5eoQ+1oO5KbJUXxB24hbyyEeW9byhb11Furtu7cvj7NSP2tLcw6owm60BY0gu3NpR5ZGDzL7tT1SMFIaVVbVqTUUdc0DmdkAgmAyteWN9++BJZ+hEJ9o2sFqIogTW9vDKP1PCTHOc4zv6XPv5VGBSsy4jNAk4SY9CM9MWZNf4mXaYo1FZpcLv8619f78mDVrWvcQN\/fJO9\/\/5O8GghAK\/1dWZT1Pw6lmyvdGHpz9ESlI+JA9o1BBxkVcoW5MJjPg4\/0J7nXLG478wM8vEvxj0W5R0oerpou+uTNyjUul9\/PKNKNyvPyC8OcDL7Hmdd23cryE4ThNBJ5IfdeGMTBpUvmLViLQ+ZW8nW\/XlsRrMAttO6QVuSghWHbfxohVu4q+8G\/qsnOclImn0hC\/UFTHuHLI4E5iBRhJVl2QnkyM50ieiN8\/OaStgWrlrS1ncJzDD6sIG8OZ\/HWdvS1O9kSIxPoInZSlxB4GmuL\/rn0NcCQz5phWDtvQ0a\/46a1vhFLCPuxN6LZVzL20gqG2dakkfTCo9TKguX5fAj48Nfk\/wqc57GkTPaMm3rXNxsF9PIbBVwPDJRII3GFphlYXR9whZb\/DFatejFCZz2IZm1NTGEgJhYkOpwM6ojJETRyd5Q\/XB7++aDe+Ugq9IMcJs50A\/l3uTC8EN5+Df\/ra9O0BVoZHemtsR2kchYBvxylB\/6vdj1QvMqLylvGEPoO9dJldB3rVHpPaz94XhiE76Ox+4PFbQs\/KD\/h2mStVWyHylsl44bJtbIGBeMJoJCAANYQgwDC2uCyamiKkSnEVX8CJWUmjqOEZFrDMHcF+fzukrkLXmnfkVn5toYhrn63xEXIHE82x\/IN+W6ioChCOjfKob18NlVOgo6OfLkJuOrW68nPF1xr82lYVKiaHFRW7nngQ8rnQQr2GjhNaw3NApNYRKU+LLEnAKBHXFF\/xac0tAEgc7wT8AeAAWqSQuQkjQvZCaUMNGz6S66fURDTpr0Qkfo6wPmH4mG5iXhYGJrpiOQnd4i\/0D\/P5YIcNhRgZEE6kumH4Zd0QwoPN6MoLuXDcA716x2L5i78DURVxoB0y\/Sq1iwqsnIYrx6g6xDkaSrrO1qNrhM\/QoD+kifpPUmAW95QwYo8jQ8\/8ejOB\/7tnDPOXKBnooUoRsQlMWaEQFJ86SNJNKxiAFaNGNGQSALXBHGtfDsNBc0Ju3guOxG5sz+Ez7CQFIw4MoJgxyBxkFA+4TIA7KuL5y58\/5Zd2\/9evq2LqV3XY5UNSacuF2k+XdKHSjyBGIjEugjDgeTBzVKxVDyRApTT3cIc1zFEZrL7k\/Wonr\/kkkuKsrDc7JM+7Zqbr8DfhFXVV6R4TTCtelJ5Cq5U2TSl7p6B\/icApg0o30+pv7bw95BLCk\/xVtEgvFhscVF4gosH5uJkP4f7LyKuX3et01ppEoYAm9iCUFvvripD5BEh7+lB2lpOwLf1OUBrdnLV5TdnoJVZgRPBTymkFBWB6UYz\/wVaHkB+pwU4bEZID9EyHToGOcOf607nej4ZOVHIRc0t4cMnrncQwbRCN9DKhXMiF33y3Llzf4d3nkJvVImbgo+Q1hhvS+oFnKYHe6HPGj+HjITKl2LG9+1a+LwFfkC39B1OcFMZFp\/4ITsCNWRE9wRcPFAe82HuteTt7CXz57+H+\/9NPCJlWL\/W8ICl5HB5EjuRJ4\/D\/reHuXgjN47JFcN4gLgOzIhMBo3403EgLBaSUjAzyCfHQ+upcRIsgrZfg+TnE+cc\/igcZQZhoxb2GcmASxmJZW1N5501i9sWzNyys\/OT6wGri+sOWmKnr65I6+fU2++CngE6e5uKZFjP6hpILZcv5aK+HF3ZPmQdDdn1ZD6aZSWwWrEu5y468SbX0ny5G8BXFWMV0UCTjkkYOUqRcoCZd7r39W5AAr\/Ii99xhcL9Arxq8hl8gd7GZ3vOlZOd6u7NNP\/mYoGpm1VlI2FXBSqQTHgH0GtmGEX\/TYCWK4PWBPq0kFu5LKRYz9LF94ktnZ3yx1QdFi1aNDPp7z+VLFwYJPEfwLhXGXDRdCJLWJZeccldjFmCWRW+sBQUriKBv+ZPaQsUDtLFqgmofDEISqRdwFD4OcOPrgaBHiuFwbFJVDiorDJdbwJbB3Ilyj1oLsTBTAplDlbHGRTMEorn+dB9DlZkC9fikel7CsYi3YCLd0qYkSG992dFcbSWltXbePf7ekHhwPwND1hkBFZ5jzTDEUpRfut9u+57jNv6G1e44IILCs8+8cRCXFmvQK7fCkpdCINy6q0gKxGpWbMPGgWSsiWLnDOg0N2ApbVPltZ6QEvPeVzHmkXZsQph\/8bt27ePK3PPgY\/MZ5UOW3C\/ueejrrl1EKzkpxJYyYhG8\/BjMQqAouvr20JZ3kDxrkuuuvrZA9kkB7nd01xCBc0nZB4hGmhKmLz97d3cvUt\/+KhWu77+9xD\/FTQVZ+HD0hdUeAZY+r7g+jHBmpubAK0bAK29gBZWj5UuhPk4dV33IFwpBgwuI60RLIPh0kzHI27l2Va++8KStvl\/BPc+jl7MRi\/KoMVzuU40loKRD8lbl82b9\/dcP6q0eFYfwCIeK4Qk2H\/ezh0b04r00eHorubemWeeeUxuIDkHTf49DJYV1okA\/coXSZENo12Fo6YvXSoxgJk7KQ6iL9D0fRP5+5F0nT9siUFQHhGwMquhvsEAAEAASURBVKKIGj\/CwExdC3TuvvtuX7uZHAxhlvJ7IPOUlt1LB8PRDHBbzjv5vM8UW\/a9hTbDn4LAi3glB1UaTgFY8QuVxFQAyIpYY4B3fCPI27V5V+f3lQaPD0Je7tcQIJGmqPInOuUE7OjoUD4nIohPQwphIhKpZ5wClrLP6ubV7wGQPmzjqeRvCgAKH1SFxq65KWdWV6n\/FjwWf5NceUVZ6A2gNL1GQfMDK8DJR2FCZT19Gimfvadev+TKK3dx\/ZfBLbd\/FV\/Z\/49193IsrRzN0Qy0pAdN+LSKAFqBd24MVt3exbd3CWxJawLcCRnVSGxolatra2trQjzVdvX0l18ZPGHUtwUGSytIP6QmqoQ\/Q6fT42jMF7GmZtLS8KCFOqDgekfHs6MgvJh3sVilKXXTBU8vo2O3nnHGMcT9FKDTTB0uC0vPKnU7y1vlPdFXvt62bZsqqB\/p77zTzlxVzCeXEcWVeO6OS5u+6Lu3ssiCWWBgWYm67mQXxWtoHr6G6HZdrI4WRu7xZ+GQgKW3QHxT3vmA1d1VKpsYqW9FjA4qJI1mJ8T3PHqPas476A38FhFfy+PLZG1hVkEYvYke68WiAvZXkUxMK8XRDWeffrYy8bAAhe\/LmeC8HiFJwdgJrERnPSI9KuI45RRZv3Fw8630WNEcUVOvt3eAc7MqKD+BVeRaWvJYVU9x\/\/1YN59T3k0O1q4Nq50DiMQbkGV8Q4iCrNdP\/qjkqks34Ed7resb+Ft6FK+hGy2nRgVfqWmokIe2yE2fNsd193wyuPXW1wBaT9kQjAkaXEqaSRRqRKxzs2fPjrq6usYkO9KRZcuWFTZu3DiweWcnPeULP05j9yMotPlxyBY+GPnt5NjHuRQnLyWpLyKjNo5J6dYzdOfzRv+xxx5blR5YGUNAqusixZcEfJEe3fPQtoe495dnL1jwNRw+f4e19XISsJbSAaCVRIy9C3O5JdhhH+ObN6\/3rSrjgyL2JrnORgmkbsipGkEUjPJq+ZHeS4MyrWG72TAFjCYz9YLNO3fu3tzVeTkRXgZY7acwAKJAoFWOhwTztHEjHHPnhvnoQ3qgqRIXBwZag+\/V56wi4fpEONVjKTvZV6+egRhe62bMPAlAUK3rwUocE1i1tgJW\/TjR3YrkyhSsZNkwr9CABitpPLwg+sS+TweHGvBccklPctVl78NZ8Vc8BaJogspv5ksPHSClXpqMLc0XcvfPla7i4HamSOMhZcK+QT9igVVaEePndJ\/l1i70xKcpywra9Z7dCIIlAFxaWdQ3T2IhxoPnZJU5TvVcBwM4jtJ1AbhaQ2rWmbvnvs7On++P+mkiJp9WzgACBlHbe7xJBu09pq+p1ejcisXzF16iEwWeGTOqAiz\/SX1+00wpM0EGOlu6tt+OmfhOKH1mELSy9Dyh1CoqmcuWzl3wCj3pcB3mdMzeahzrzwEpibv0Um\/JJsEfMyzh1dYjJ2e3iQ9p4uM0y6q3dw\/TM9+RXH3590WJmmFqRqo5Vy\/KBDpuxfLY5igSKWl9lKER1yLNJJjN\/bHUaCom6ggQfe\/B\/\/Wbdvf6601x7HwS\/mDZG1BouhqE\/1TIq5xxE+E3PbDnXJ6ae7r\/xDQLWUnULUfmPqtDbOi6goGXwEjDkx588MHezV3b3wcG\/5UycyBocQt\/ncPfT95j92fLFiw4gzgkQ4ZVhx2wMj6IiPXJoKW0ddeOLwdxeDXoSyekLC2afGlRQLrMxxL+ribmR1yjtrW+b29vn9QCmOV1yh6vv15TtZLgllvmoTKXmSM9juWf8XxHsFwe73o\/PXRheA1+ph8or2YFTZDPCGFObFiFJlYTkquu+GtA6zZrplp3usGUgCqP853O9tZjaU1dY+9Ck\/nRdDHJA\/ncLpwiI9ICAyr0wI6g13H9TdHxykLmD9N5vcJYLaxq0kWMIlposfzEen\/zzu0fJVcfFw4LzChWX7GRW87laVfzdyF3L0\/jNwPliAFWlslK0Nq8a9sXoPMT9syPQaFnxL9JJkJ17eJ0fG2hGL9Cd6mRJqQN71N8bv9KsbGOBE7oTG4FVtSy1LryTnY\/zkqTk\/XGx5MrLpUTGMuKQaUT5ytSEhYqQQsZ+XPX23MXNEpaEHwptil6yToHXPJqeg1fnX56xGU+pWO4gwGSPQhYZkchlX8758e\/kDRRuc\/I7qHwB7yVPZlcR1V+6tTKQOukeaf\/OdbcN2wwtZGq6khZNme8WfZc\/kE6qDQBnLXGx5EPAq0sE0lL\/u\/IVwcoL8LJgC8iSkQjnulFEMnBW0S1GNCwsias\/GTlOqyr5\/H7JgOmZEjvV+SmTWfwXd8PXV\/uU\/buunVNycp234ScMLIqIr7kErOYmAD9FNLxF\/it+nEA2bCYVLXz9CQmNvDUJW\/Xl2qmTgkrK7HBsRWZHTyVVoSBd\/IP3p06Z3Ru4YNmIDi+aJZ7+jDjxR9D3+U4o7IxxOLXW1l4H+aWwujNyp067SYFYIkYIa8ciRqbAlDdiJ+915qGjHDJapksE+DYq5bNPZPBaYxUS9v9Om+E+nAgrbFT4Mm1Y6xcQO8fkccGYqo4HOusuJ5uObpvSj54yRPms1q+3Ftk9SHjkLEg2qrNTIaTK65Yz+UdttaW\/1LPGB5Dz7NVekF7cONqBi9bmDRyn9KTHSospZAmH5fKRUXwLwQ9FM4z2W1V3Nn5VDiK3o40Z5t2bdsE8TcqX8idVjKxpiHXvhdRTUYX\/t4Fp546jc\/wCE2isGnTJjnj3aaubV+DzG+LVIhMa0xd0b2L8x0T8qQ4jC\/Su+p9JKOTKh+ia0oHv7aV79QI3CuZq8cQzXSOoDKmUXLNLTr7lpvR+h86caec4nXJLg7fj1lMrBphKeaC22m2PmlzFhGclAoWTqJTM58\/Ba\/Wq+ye1omfnMHoUoUBixeLRDUxYKw4rvOUx8njzXFsg7hldUzOrIxOFcVTniNMD8ln6XS7T452Cyo7AZUGjVr2knN78y0v1rNJpejKRLlpGCTrNJBMpiLlVenLEkCp0nw5RxNUmoX1zseUFAJf2nX59fxctWoBsb3E5gqqee7lKaJ5WHDdDKULwi8n73hHn1lXVU63qQt1B0ayebNRRtPwV5D5VescsHfky6KDgGHUgBj0Bi\/jRRtmMdmahchycP7555s8Lz59wVLIfFGKueSBwaE4pTN558amX+3alU3vmrKyCtha2NjV9Sjl8iVdcFTT0PJE\/m1AKXORpzM+ol3P663oirOmMPPuu43YIIk6GNzLnA2JWLkW4YLcCICZl8iytadZYh0ddqjxJ8iAr921a+wIgF\/3P6O\/Rjon\/vMlS8zSZZUQFMcttEnHGsqgwBxTb10lv3JJ6U67d6TliDW5KCvP29h91fUwBkvOTi8okh8\/RitJlrpVq86cSJpnzpw5JgAR3Rres3TpUptlYbSFyfvpIZudApZpMfKuVU40RYLr4Pt6j08nnf4a\/dX\/CITTPMTfwkDp4dp\/rWwKvGgGCgOwLV+gd71PovoEJvzNjnQGugaVsjrhL9CQ8xA8pumIZuXG5iiIjrlBFCzkuEvfkJlap+skGuGuiBnjpbEjYxI8fXc0BFkeNLNSwIqW4bDO2dpTmFMya5EdrACxJrgrnS7jmEbj3z9CDDDZuO46yTK9gnkmWkebXaF5iYvZiScL8lEHwSmIj3yf99e5CctsfoZ7Evbdf38TA0Ddvn24Yg8RNHMEMRPvUn8hrGxb+GfQ+S4Bk1lVxndxnDlyKoI42VzM0xRPw1SWU9HO2CwDrIF8fkuhFN+LGr\/I5Ew\/ptRUNvK1sx\/A2XPnzp10gKVMQGc6bN\/do4LjWiWmZmFeDRNJoQaY8qpqyx+k3yjjgwKaFmh1B8PBEvEYYCm+6r4b31tWDhOcxvgos6\/ER9Xm1A\/hQt87iFJpXJMsFeZNeAd88j96e4KnvBhBY\/lJ3nfJ7uCW1Rug2zplTCJkHQqwcrkWpvGcZfHNmmVlPZa4R3yXIR5xGGm6mdvw8MOsdTP2sOz0hQtZh+IaRP0qIR1yrzLwA3Tp5EBm8hJKgOuO7ds7H5cM2eXYk5qUX2juIcul\/xJlfxEEmo4rg8icKSPnJ4ZJbv6kAyzRSFteSqO1sTYz7mofZYOdPQgiBizqBk2CeXpfgTEalj9\/VfWvviFiw6czYNgfE2kJOzWPONQNtAIttejCVkzE7afsOv3\/Qr8E0Mzdqik9XC9mzvM1azQB9nSfrMmPTmOc10xu7mehvWSbPdu8WX4XWQlHNgx1pN\/L\/H\/oofbG7qYkNQGPtY+aWLo5OkOEZlN1KOTayxlAxMKarnhPP\/301oUPLSy6dl0NDWZ17d5dwJpo7o2apjfl2UEodGcyi+NlDJV+PQvHna6JwYCVnxiMdCIrlhGmpoG50Q\/2RwO3prEOTtUZmsyUusKPVeY\/un6vtFFgbDpucJXqdeBmUJBtkxKwMj8AOdkF5XuRO1aLKOdLBWLdJWTq1Kx09rS3jwOw7BMWREGYg2AZ0v1Zjt5ZMyS5LJXxHVncy++WU4q+\/eRJW35GLKXUwVq\/Wn58pB381e7dno+l0jFw+YRsALJkR9rjLS73hCsEjxz88RG8w3Zf5dSDsJOlZlSmqp8FV0Y8ckThJnPK711\/faAVI8rXYzxBgVhlRJIZHAsifmzJvIVPzMw3Nz8294HYdSlNE1rPTztHEZtYSjVJZhTyyWy+PwklPV6rQotM1oOyPECuOd91kyzgjcNAjKMHqKI\/+ODOB3t1j0dHvpIYI79GeF15FECh08kOwNsQK3sXHhn\/VIQYEqdOSsDKxlYl\/YW9rhDthfg2SYWJQJoTk7IgOEE1muYnZRkc3xGeSPDKhsT4YhnpKwkXxcAE3aTINl\/jVpCR4q\/r\/VNO8fTFMRZDfgbVvWGVMUgFAAZweJrq3o\/Ezt6vKxHjiAy6guuuk\/9NC6w9jjHYxyBSmoDKgDWt1KzV8kUz69WMJUUDRPSthZay1nmrKhiD+UEZDag0uV8f8j0tCzFYQU81QJSdS6JoNx6sSzbu2HYPl9Zk9+8cNb\/KM8AV7mYrtWcxHI71ubf8GT+MK3FwwqQELMxECz1hTze7DNgAOTIADHva7SGlCSxPb2lp0VSRXjzlNYZUgmqMZZjPkTHtlqOF+ScIEYdJtA63WJSP9aVAWv5MNyVTabzdWFo1VhJ1oLAiCquhV6yTMmvIYR+NVzb2DGywWMVrQoUW99RTrI\/jesprbg15YawXBlpqrqkZB7OqC5Ln9E3pYgVQ6S654UdDenBl3Y9Z+JbNXdt+cbFfG+qo6hCycksd76zTsC\/IBc9SRsz\/PJiP1A7TJyVgqcRE7osfemhg49wFWnlZgXIdmguMrhDvkC\/4dnunlh8it224aolj2G9TC0vifLSY8cPm84jfxJFpQYvfoOrp1WE4AFUa74V8kqiadYdKWyCl\/\/ahEXjAF\/ace4qPBuMsvbM+9X1WEb9FOeV+mlievMQC5WR+uKBq09dIwz2dBPc2L12qZlQGqpTdgTlhZJlNQYLYjnEQXI5OUVvA2S6He93\/2A3IEmspqiKeGkHLs7BIH+Ri23qS0yM+GEyK1kmXDa1iqpDTFCKt+JGRDd2yEk1+kl43a5avBLP3a80IMZOA2p426wL5sTWgRjlmeqfhDAN8zBGALUuGqSzDvOMIR\/wiBpF9l2XCLxGZVH4VY5dqJXxyfU\/TWKA\/8mJcMDhj3OSi3EsWq932tyBn1vti5rYv0FQKpUeu59geTasitNvv+H+QF2RB8lD3P4hixyHIDtzApPdhZU73MFQ3\/X7mQUkbCWI+J2a4BMdyoV5E57L37eLI\/UBdhQM9PxtK8L9h7JgNI94jLZ72Z+u9mkQGIix+ymKaJHiIP73DArvypucZW6UllTVkQb638nislHDWQNeySjkA0K1iQ5Y3ZBzmG68N2Y2pfTQJo7RaqFZM34fLDhnuy6yX4Z4fsXvtKi2FXncM9eRxdo642TH9seJKgifvfuQR70vpqHxa5bkJMM4EzB9waiNJfAqbjc0vYtaRH3GrpiojH\/IaHZFRKzFum\/nIWTZBmBnrk7N5mDnRBwb2uXyzemjTjEjp+Wf+YfW05VnFwWkDhckR6PEzh7uoiaP5bPuFeGNISZLUUpOfRADm3KP6sVBDD2EWhSwrsMPsZ9wTd9Ei+G8kqgiI0TrILNPsbSNHg\/3wocWzkWH1cs9DDOezDLh6\/mSnydqSv1PIpwqCnsi4SEuiwOiYjy9qa\/sF73WRJu9MfRdDJfCGSZ6mb3zQiABxzyt\/sHdSAta+8883wGpuip7HCs8nZOSK8DTYc5zuD1N4Q4Ase6HKo30rPWTs385NOzv\/scrvanpNhQTZpj01RTQRH+\/e7fn5zDPPutknPuiTyJpTWOSaA53LH4dmadDufx3pUe4VLBCyep6GwXlaZ9gF\/ZqSI8VmJx8el3BuJeFOfVOfnkLfzqQ4wRW2Lm7OXXnfffc9ofirCfPmzWvBV3A6AxReCNi9ljhexxCGVu1zZ\/Uz\/UyAlmSFTRWUhWB+FOc\/QNxXc68eszuqIXOi3ynrAqM3TgPsW8sKjZbT0SbhE3918cikBKxsHBZFdDaKcYI17vVjMAXdVPvKADnZnnGT6TQ1AICY4Zq1kikjbvu1zM2cOWyxVsegQYPa5EKCxl+5TOqYRL2isnzLWmHE+DazqKw2Nz8QE+sxsaYxXaen59eVoA3AZLWEejezxpuZ4NP\/cBIQdaEfOEosXmb81mP9\/TRzg\/st7qeeEsDVZOVSiDGWD5unxN24Um\/YfN\/2J7QMML3cKmfgRibSwSEr\/66uLq3Zsy39+2em5fw+VtTfaicpAIzoTcgVDcMxXAl5x7+aLF8698zbtCwL39Wch4OpO+x3yjwCp5fSUEblo0H9EHKLjcwzxLvVOekAS6VDgVpbnuMFFJ7fdFVDUpA+laJOkAhWZgu3iL18ooIbzOT4eJ6kWxo5lrkpT9MZX1RT9ysDqjIABZtYFE+j2xm5yM40ftdeKbmslguDG29rS9532U52xDmizRPEOWCzi4hBoKjwwAupz5bZhO2KSo4pRSqUh5nkYjKD761WeSFRX\/uzDu7TbJsjn5\/7xcKF+YRKT3Ks6+FC+kzPtUJD2NfXF\/gdc7b\/O3sOdtHxvQ43xUJAy1taSLhVz1CM90t7972ebwVYao5KX2rOy3B0Ho57y9NE\/CotNi3HdNzKVM8EV1zA40cBsm1S9EkV2lkpQQSdferZjLJmaRNR6+dSaTiwHqnm0r3tSdRvtaVWWZjKhaZMTargAQgpCTehIdttaRYtiawg0OpXJ1twLjtHXmT3JE9HMrC5RLn8g+D3HTvbUyMDsAYaEpq0Yg42GsB6WutGM5CRD0J2QCZoaywdRc8hglnbWrhSYCWFhdwcS60wn44NGpB1rv1SK+QAibfh8JajIPxNe6aX7JFSnHqBPARYo8qD637qqUUg7wsB5jQj5FQM9P488p9s2bpzZ9ekA6x95\/tZ7mFT6bcopF\/zZVIuDMsN+eRGctfWBx6YXNNDymRO+ROvzE892onQ\/MRbJzRIvCxpUlvRTbfOnDcGn\/1sC1ZZKdvJ5ojkPJ1HGNx8+3mk\/3rbyNXcS0az1u+if1Z9HckPRV+6SUbdAEsRMzm0pvgEXJm1Uejd\/x8o6s\/Vm+iDRy\/Y79NIkrNwvp+RPsxeSi+n1EGGhuWJlVdeT2PqeDodfAbIlfIrUBMGYFn+WA8mFWBdTPdutkg9xvbbyUAeq5gmiDZXtQyo1rHt7Tn5blY02bIw2XXjWCMHaF6ly8wwZzv8rm0+kcvLSkkVBvnpx\/2SJK92+\/t+11KrQxNrPFQPcZ4H0Z\/gXzueFUZpQQxqOzv7QHn0MIbW9y2NdMG\/8aQ3kd9gbVi459FHu5H\/X8p4Qm\/LC9qpCWrqHAQodk49jBbI6lQGLccGycrLHyszALVGglt+yFYs0AbTngzCyMpuUgFW1jvYvffpP4T03\/HISvPdykMoG0S2JlDiNlKn\/bcyqM0nM5TWdSPUzgH4Kb3wzaiQIbkJG363aJaLNrnVgWclutymz+Cd5Gp2V55lVhabUNjzw\/STCbaRtHr1Szi+0xXNkrJb\/Eh2WBbH5P\/\/Jlddcq8eEDzw+vPJ+RskTxphw2FRwpSp0NH9P3UDYFSewJ3LRez8HuCzMzhGvgylwC4NGreyu2vjjh1aNGDyWFjqoZN1xSqibUDUhzSwDr2Rgph1xREtYiEv6Of+Oi3wx73GJhRiwsQEA6fkssseRoC+nI6\/EiB5qdJwgR6Wfmpuvojx3e8VCfQUDmi55IkhZ5hY16yxLcWCm29upvFwLdbVdNu23iwOE3RtlhHQcaDR5H4JXr\/B66QHLJgsE3aYTJs+a6trzYeckoHiCdpduxXQsrkLXopOX6MqEv3WNJDUiKKRyPA2eg5lV\/6rMqoe2ElhYWXDCcgHHYC5j9EUXEJLsAxQvlSCyHoM4\/hBIMwyoKVltQnFlCy1SU609Ramm5UiMWtZtG+zmz5NUsVgJgJOBS6YviOlSj7Evn+vs\/vyO7BqaXo+YQdrCmbryIf5P2Otq992vabjUgT+JD4MwLSWbHKn2\/v4NzL6Joyo2iMuIxStiZ7yRWW8xm6twJtMvqlRlXSOcC6w0nLQ2trvvIULT4xC90laTTMBJg9WsijNxPejQijFH7eW+v9N0clBP+GCNQLd5dsZWOnG4rb5nyQ\/y4WqlIuNIPaVjLTCRv8KhW\/d0tl5v95n7NWwZapnjVAHDuzebZUBmzvsILbbXBGji923Oc8qiQJNsKJrbZ0GRHw6uOX2CwR0PA+DFelONnUg48AozL+WbtYKUC5HKK71o9it8spkuuSamkOsKwA2WG1N1iliXSm\/SPwIK5ci8igJGjLlAAuyQ4GVekUZ6zijGLk1jLt6AWt90TuiCjBr\/5rrB1819wN3k1Zx5VuNHjg0YKk1eaDA1ONa1pH8TxqoqSOrfX6aWuUalRQpakVODZbzIQjYQDWHeRj9NB7I\/71upr6rTHHSFxuHenJgiJXVs++zrtj\/7dTKshrF0kpcAVCIAK026pjPBTff9nyBg1u7PA46OurePESwy1NwglW3\/R5AuZpmKcDJEHxbcwyq\/BCMAs1Baf6Xk6su\/2rKl0nfFEzpJFtxr+lCduOAI574DLAyLTngjfFdwt8JCdluWAKrs88++4R4f9\/ncai\/XsYJgTyANN644kbCnG+VdLB2c9d2a8rrHYWsNhqRSPADl5Kiqk+4GCeoiJdJqJ1ftQ31o10P\/CvEez+IJoDKqatiUKqBY25fUGAmN2scJX9138P3PcF1qG3q60NRORafWvmycSIO2JbwAE\/yoQ+xYF\/yEXZX2AM4acyRvNtZGcmS0Qj4JUjLvwY3rb6Y4kvYlrtE061Jomfv1uNnxYoKmU1+3c2YeQLjwnB0UEMrFcmNfppw8XR3b8K\/dr3uyLeWWn+6nPQB02IECytjeUD7fGKCjVetQ9ToaSDDQvou\/zR4Ey+dN+9Fuf7Sv+Nk\/30GogmFtI5YWnbWscbsAYyTONrJyPZrRYaMG32r84rC1+VgICoTMnBP3YwmBjzNjoMvHuJMRMtZlg6MC9fjSM+GLiydt+CdUZj8B7PR3whBEH8AWOnasRgvP+Torzbv2vG9NDk55MdMy2ikwqpKAKxr3KOlOyWe3XmnrwavvPIuJOCvbExTIc\/ifqk\/y+sQoNUjS+sslwvWYv1crrzJEQ8zE43TqodvK1m71oZceL7Fn3P7nt1ED6bkGAHiVy0CZI6mqy42J9dcfp9\/dwr0DIpi0a6jC3oPFELppL9nzZ4JsbC8feI5lk2R81fV\/Yr+i1OjRF\/IKJG+L1iw4FjtCISNBFjlXgooerDyTT0fObu8Y1nlaSLKgf2ncv0QXYjrp6ybI5rsMMzzJnH5XJG5l4S2trYmiCnNqQCuPeKta\/cJ6pfTbIujim2MlKAlumjRopmud+C3sajewb3fxcGuQclCH\/msBi2rFLxwtNNBFa3evLPzE7yfoa31YOm6xqBMkjdSdon67S2famcDsmUm1ZjGQZ+LZx3wkDBhaRyUaA03rGnoLZRScvUVtzPHcL5rav0QBVfgT054WVy+XuntLbmWZqyegdXBqlt\/E6\/DDclVl26QpSYSZOnYFlvatUbrUWnFBK+jenzIYBXVkiWm1NpmDGD8JAJyB3HgQrBamBHhVHRxJNl+abBqzYuSKy\/5KedCMCvfQyZy5F7wOucJ7aNW9n7cA+kh9wywzADrwKdjvzZuGtxTiEnYuq\/V5FJblqEZcTu8q9T5LIE96unj4TD6XtZPzVgJmkqvbU7cuyjml4I\/Wp9e8RN16vbx6RfBnIKowDj58Kad27+SpWNlnl6MCFiG5mJf4J5XyiWv5KwznayZxVP1Ecf6MbmB5BwW9bmIjsrfpva7EKBq0uYPtGGZE6hJnRU+K\/Y2Id2CwIqm4D\/3BfEHlZjMSzUlq074UC\/CQRCL0R80jRN3zpK2thfyyU\/Vzj7Up\/V6rlKrLJB6xVvveOSXkpVkwLN3z1+42SfNYgrMexhAWkACrbxIU6KXp4lWZLWEAlN63sKmpu0A3Jdg8b8kV1\/2M\/NvHUAcH6EnZV094OnQS3t3xYo4uP12T8v0ln9x+3vewpiw33I93d7KksxrZPu0aae43u7LiOGnRj\/pkEp1CQ1N9rBfIZl9MAUlduj60CAmo\/fWJJTsSIaGvjGOKybmEhXMCX4tnt6\/jBh+UrFl2ZiA\/ty5c2cVw6bzEOxXoOW\/DdNfwJJe1G1mVSlPLL\/N72DGBsgv4EiNEid\/s3nndjNOyFZ5rFaWo+EBi4j4lnV4Es1GxwRKrl06d373QFPuO819fYa+3AZvqAAKhUKx1AS29CVR1AwMlaazbvEs\/J+nQNE8GLCI1cmWQszZRHoC5qBMC1lNarvymCZfmXgeyCwMIB4K2WH8H6YX+67Z8vDDfWrH1hWsMg7g4NN0ACabstNu+OlFcxd+MGoK7iWfw\/Om\/N34TsS3YjQtHGgeKO3YsWMfvBiTMIwv1fp8Zf4sgdbKlUXGPl3tKHLX1HKZCyM5vUEIBjSq4CSQJZzgUSmkuXYy969xfQNvoUfvh2DJf\/H+zwG1zuT9739SL8ODQdHVjUMF\/7pZbMk73tGHo\/9\/u+6e83GyM8q95P1ZqvQi6EqC1wWrbn9xcuWld7nrO3JuZXv9KrxD0Tm+5+IgXueoh2kG8FTjrWCP55Dnrl5wQf0sLIs7oSnG+PkwnMPxhqXz5394IJe7J9\/bW8DQGLZ8pPuulJtRdPEslw+fh+NpIQQucWF+GQvMnY1OHec3f8UwieKSjCAC1jhvWZbMgmQweNBk\/qzYXQtY\/bXYlvqtDiqrUZQSOFGbGVQk4eehzHcUisn9cb5J40M0cUoue15xoFSJePIxI1ZDXGgtcZCbwdNjIK5FSyU6efwRMiMqYjCoIjaUNc6LPqLxzaO8II8mLO9ct3XXjo9KoScMrKwYDC2lM5Abvoil\/L4WluJO8imelqHUiKzDT5wwIC5fPK45Dn61eO7c9xPlbrMcaevXIfoJj6LshL\/66n6ad1e62XP2YDH\/FQvmNeHDUk8dTS\/qf3WcqFj7+rz11dJyEnLwRhbVeyON\/8ddoWUnAPYQHN6DbOzjfQ3uRCyqDJI8Fo2hzmMZZ6uxn+XL4znXEwXtn+ig63jGZ72H67sSwIoEpH3+DXttkv5Euf1Q2g83Zw5LLRuw1Jdyr+\/SURziL8FU+fd8Eu8ICs2aG2cafGB6vNrC9OxpPJwJThwL8LSgRKnWpPrOqirQr3JVKyrlvNgfqCy0hRkLE0ZPIwN\/unnnjjuUxmgtqVEAS596ZcaSYkkXlnLNBcuGZZ7IGRIMSyEOom24vQcpQIE84aeyIOIJWIGytLA8WC5WC1rGW7j+C7oz\/12vjUa8j6cevyQsWqywwtno2+xh81lrUuITaTBEQ73wM\/JJs9WSe\/bskX9lygTr\/VPPoYYvOHdtsPq2+wCFv6PH7jQb\/U4zn\/saliLgkl8iBrhkmWsgZ+iamk5EK06EGS9UgxyHDH\/jzL54qjhKeBY0TgyhtZhsYCtWVpzIv\/Z6ei5fkrz3ih+7jo6co\/fS3plkPxJA9MPoj3PsJJ0E3WSHBSx94IHJKWopdDkmu89R34yXg4PREK8pwVj0wKiVvosC6bsaDEzh8hqFvYJFlT6DQt7wfkQWIwQHzD\/9Q4Zo\/H8bd+34oQg5VOVdhaIYd9S+LUFMkT8dB\/8QTvmhhv6xVhXIClpjKolGq23p7TPHqHiCiOkZC5gEtG5Z25o7+0HaG10YvxqzcBCsDpfloWwSANiSzNcheazMby3nxMsCbb20hlV2TxXDAWsOslVZ7cIm4g9jMNC6vsMqn+SKy\/4ZMWQi9P4vWV08bZrMfmSLikpgJck0K4hfNRVldWktfq21pUnURfBNK5mO508gJRsgLT9TjowPGpeVWVm54E9029N9fRVyn0Vy2I8eAgaa9yMUz9iFkWAiklqHquKDEy449dSahzYMxi\/mGBsH9WA4fa+U\/7LeD+q7xeKta+m7LYkjfReIEb0Mk1wejQcvHkPH\/jKMBl6\/cVenByu5fQ6h7yZwxo\/MkDayjTn2Y8\/8C+mcvgNu+9EPg69VnKXMALEgmJ\/sEbJVXqwf5e2O4uArINiarTs7f6R3eB6w1Ea4Pl3IL\/uuzkfoMZL0o9z7owdXbtmzOidJEZo\/wAQuNwrr6pzuxERnTays9\/C9l22kifg2d\/ycr+GEvxp\/0otdgc3YtXZWCb9SGbis0hIjYLD9R5hVqdXAb\/+pxE2dJ2kgfgx3qv4BrCy1718fMEE6uQIr65RTNGraKovs7SqP5dgtnUGdqfLz6l\/LHZfbF+9nQ9hMiaBXAMCl+EUFkJzSn6NTgc4w\/tK3qo8\/ywhHxLBCEiv1wF7K3jwwbpI84FFGqgcoRYrB5tUZfccXzgu0oJ5AGP6VMVZ\/v7Wr81eKVXjAgc+o4A4RDLCUNBHLsNbHGEYHUGKRDHdPD0a6bx\/JbCFKGG1WrOSUhHzv4DZY\/w1aDeu2dG27y97mRyYhh3hC5ggaLFEihLHnM6OwlqPxCnOAuWB4B2uJabJ8a71vfu6gdl2WwH0x+NQd32Fc6WtZl+oPuW5ndLwAIyxbUl7pvOAgD3UK8pSo2ZmGVC4xRbCyIkbDH8\/xnTz8sfnhoBl6qy4D5EV2gmbiSn6UjgDEdAZpYrHAUfUgI6rqo3qql7Qt2MYHr1Q65E1iizaxVDJDjfg7mbUMlvK8s921Q17anKsiBXTQ8k18GjbBmKLhFP5Q+Rn2+bD6TqvCRUl0bxAHX43D+Cv37dhxT0ZmOgJeK\/wOG2H2Xnb0FhZeehClWWMkyEMB\/0L2fFzHShkUHeZsj+MnEZ3tsGoDYHsnzu2fbOzsfCBLAMblxPiJ6QnMUnEt8h\/RvlVbnbZ1bfksxzqGE8SdFrCWRk+OzcdNRoCWyB1DFJPu1VTxNenZ\/FrJ+9+t3r\/PMQxiHVXqC2j+vQrAugigXuoKheOwvKhtlWVktDo5HV+epQKqvSNwVKuQDvS\/O1h9+1eSKy79Nk\/E+6oBK4xwW9AbprIj2lbkVbTT4aRxhKXjc3Q5jY\/Ig74S1WlI\/kfp5HKBRnpDMSQniTm2cQ610Dn1Rl78unSG9w4pQ3qHeBRTK51bsMYUnpPa9KAyZcXu9T3Zi6zfD5D\/lEK4E4n\/ycadXY9mObsYX3aHciOn\/BiCARZV02P\/r70zgfOrqPL93f69JGlCgBi2JL2FrGwmijsdF5znzCgDbqM+ZeYpI0\/BEdFRZxSfuL4ZwYURxhHUUXAeDDroDAOipnFkCwlbdnpPAgFCAll6+S\/33vf91b3179vd\/+50QsDmw7+gc++tOnXq1DmnTp06Vff+aeRWRlEtFrzA5P9segA\/XP301h5o3wmLHsU57PVcv8cpDW5dv22b2cq2NMI0v62tTYw8oDto6xzqlYMYfYRJHoCJ\/E6gdilwrZ\/v5MalYinm2Ef8cMnNm58oO9w\/ePF8d8m2V\/a2WHLJi+FPr5fcoT\/369+b6cyMmgmML8aILUCr56Nrsxn9Myln8kBbNFQPOOyAmWwy+CRifKN8QT+7Vc9UL6\/kVkMrrQEiqHGTjS\/qZ9T5EHJ7sVRshcbd+Ca8BB6XwjhqgOTtKheShrUNE+Ibt6HhAhN410hmFP43Y\/J2xs9RINW5LKOvMEqeHkF3N9JB7M2bN6ttcW7CtoVTzeCx9ZTCkj4QOCT7At5D5npKl04OPANxT4Bpu8Y7nlRXfRxvfaCn5xm1aZMMleO0OasOcbzLUMjS+suPP57zHocpHXdcUcfxJ8Jmln7tHN1ndpgI7nCW6csQM0qlenFQ56FYmh6yoA6VLrU7vVTyCvX1JX4Sqh\/+T3qWP9Q2\/xD18LY858wzPYfXesZbeuk9Q45J1zp79ybeybRpfKNg4PDKxOLUNQw93JXIOf\/8vQwwM3gnyxuNkdbW1unoj7c31R3J8gh0aH8QRPyAiWSZWZJOFvPEcPqqQa6\/P1CbgpTO2nb1fGRj4\/4DBaoFl03PdhzYsaOrTsXnZ+aL+ohBto3sPbxzcUr82e3t8bMN9Ug5jJuYbeC5uJfA5UnxTRh9FkZxsud1oIpptHlQSvpc8GE0zqlK12g6D\/VZ\/XNuuMFzZs92nZ0746nyc2AH05\/JymiycAfT9mRgD6bdg4GdTNvjwdBOdryPEycbr\/b4+dbDcokfcT5lfMBDKmnHNCUzmQzUH9xYwEQPo2nc6kPqz+GoBEPEZ802NzJhTgW+HI5uTRaH8bz0LuAf4rvqZ57pON\/9Lj95esNBe0Ia6OUx0k5v2zI95hlNP2yD0mIe0abNzFwP1WN5zsZBwgeN8+dMr43ByvCgelvlQJUDVQ5MWQ78Yb2NKcuWKmFVDlQ5MBU5UDVYU1EqVZqqHKhyoCIHqgarIluqmVUOVDkwFTlQNVhTUSpVmqocqHKgIgeqBqsiW6qZVQ5UOTAVOVA1WFNRKlWaqhyocqAiB6oGqyJbqplVDlQ5MBU5UDVYU1EqVZqqHKhyoCIHqgarIluqmVUOVDkwFTlQNVhTUSpVmqocqHKgIgeqBqsiW6qZVQ5UOTAVOVA1WFNRKlWaqhyocqAiB8znZSqWVDOrHKhyoMqBKcaBqoc1xQRSJafKgSoHKnNAn2Kqfl6mMm+quVUOVDkwBTngLm5sOXsK0lUlqcqBKgde7BzQ7yDxwXn+4+eJIn5o2e\/Sr3Hc9GLnS7X\/VQ5UOTD1OECAnRWgfiTD8fjxVZfv2V8bcFONY009WVUpqnKgygE4wPeWfe0M8oMX+u5yQ8Avsa6tcqbKgSoHqhyYihzQDw7zW7gedmoa9+uDsNb\/o6lIaJWmKgeqHKhywNkPD2YkP2\/m+8FQdZewqhNVDlQ58ILhgPsO1ogvGGqrhFY5UOXAi5IDOwnAt+NoVT2sF6X4q52ucuCFyYHqDuELU25VqqsceFFyoGqwXpRir3a6yoEXJgeqBuuFKbcq1VUOvCg5UDVYL0qxVztd5cALkwMjDJY7Mnn28XB0DVzeypUrA10PB74qjgNzIJWfkWMWOiOLQ9ohFt6V7spgpetKnjqIXE48qr2DkvGh1Ck3+AK4oX\/wy4VfK4PR5KqMNEZGo+HGe1ZdjasVK1bkuD8keWZxixjSGHqS7LH52brPx71hoAhsc9qkZKE+4ZA2bK4iVIzeuXSnt2TDhvCGOA4PljDhAG1EPf1V0\/PEgVSWVp6m1Wcri7S+cJYqdSOVc6WicfMOpc64yKZgQSqH8fglXo6Q0WS6IDlwJMkDt8bjYRtXKa1j6BkvfzK0Hk4YzY4yJmMIHK8RGa92pz1r2MYDHZEvBi9dujS3YcOGEs0dNgaPaKT6MGkOLFu2rGYiWUheQjaebmhGb1jbEK+KV5mBKPjRsJXysgRWKq+Ul60zVe9Ft2gbzQNL72T4ZWEPdB3NoxUnnDBtV01N1NPTM6S6o8sPhG+iOoeCazLtHQhG7QpmND\/NOayFCxce4xfDt1B6HJarlnd3cnzWoQa7X+C6j+87bPNib\/PGvs6HQWA8rMl0JAuzpKn13eC7iL9\/n7N17uVSdMp9i+9AHaiWT44D8FSzbiSDFO4f\/CjaexLf6Pjhxp6OeyyGpfOb3xe53gVoxC2b+rq+IqXIysrisPD2upJlzao4Li2dv2Bp7MVfotpAFAef29K3pVswSxobj3Oc4CPoUF0QON9a19m5DVwVZWzbWDZ\/wZLQi\/8K1dxVCrxvdnR07LVltt2pfh2PXpu\/uKXlZDd0voAsisWie0nH9o7t6pMm\/8fnbbuAoXkKQvvR+r6u3yufemOMv\/KVsmVLm5rOiGP\/g7gcJzmxezQ8fMAP3M9OxPcEy8h\/LZ26Lmls\/gBfczmT77n8eENf128s5OKmlj9Hj96MjbhhY2\/XLcq39SzM4bpOhNcsCYOh4h\/Fnvcjj9CD3oqGMOzKsNOFYjphFO3l21m3LWluvnJjd\/fvyBuh5OMQa5aZSVl85rS6+lcO5Ifc7a3bryZv7\/LlyzPl42CoZh8UB1gmmJlpcHCwvtZxLqwJco2FUqEHJGWDxbukZ02rq30Vsph+4oknXk7ZIH\/oCXJPUkUPeOfSpZKXE\/pOS43nnx1FseNH4TVkGYPlxX5L5Dl\/66NHpTD+Jfnb2traDD2qZ5MaamM5wzMYwpfm\/NxFxVJpyC8Wf0zeXtsHCz+Vr+oLLBvDrxF9LMULgyB3DgbF8WpK4rcxWLvn7K6F5RfU1OQWFwrFreQbg8V1onFhypa1trZGjvejmiBYWAxxcl2niNHyWL4cSf1thHjG8J38igkZGVmgC7WM+r+oq6l97WA+\/yjAxmCpL4sam\/+c\/D8dKgxJV4zBog1TryLSZ5FZiZ8WnTFYsece7WOoMEqFqBT+C4VbeTPaw9Py6cCRiGQRNuv1tbncOwrF0qsxWudhtG4HzjDPIste1cnsM8zcV4pCmcE90\/btM15aQ0MDj5WTra\/xUxni8OXatoTxYNuzdQ+13nPaJt5xKJ7HXjHLLQSzh7ff0XH3mbq6OjPYZCSIT5r7Zc3NL48i9zympAc29XX+s+qqn0wwRhZu7OTRFYfvExEacPNZ3DQ2QMk0j68Xjcgf9TBbo5cUua4QacDthR6Td+Mo2AM9HqoMhPfZ1pXclzQteIUTR++nS2s39fVcqzz46dEP0x8i2IOwyjx4TlDI9odxtj9CFlyzMjL1snAprTZm5cRh\/EYM\/UIM\/WOR514QuNGDxVIQRF4kQ+MobJOtP5l+zkHo\/Y47IJ1Bjlm5eshmyOQ7o+SdbWSCe9u+QMSf0aAqt\/mLG1tfxdT5XizQQ5u6O78nWFueGKzIHYhlXuJ4N2G8L2GM+rIIAfYWNba+Ll8qfrsmlzsZo\/WZBQsWyMvKq0z4NJO2t7fHWF3XaTNEaclXVlrXDW8qFuNBwoP3PfzEEwPCD3yo+gwEv3ntWgPbjde1lntwG4bLbRasjZXoPpuor7b9ffv2uRMZwNnQNnrDgKq+9fJoz7Sv9vYt3+dCg2JtIxhraRV96qfgoGUMXJY+ey86acv0pXlts9pSHw3+DF7FBss8s3V1zcCUeUOeoR96KtYbJn4kSkzV9cVSYTfLwrUswYxiPtDaKtoMz8PIe2d9bc0FQ4X87U1NTT9WbIQJvUY8ES1x6K+LvOInXMfLO2GwWXlKJQyOl4xRxw0T45OUJAoHz3zxjGu8kyGlRB8McTCSlUiFOqlsxXN4Y+hL6xm9yeZPxA\/KjJ6gdI6MpfRMOmdxqm6qw+LlMOsMlWP\/kZ7QDxWUMFbvq62pvWCoWLi1sbHxOvKG7j7xxBpn+3YTUwrD4EE\/KF2McS\/m3GKvKinl\/KfiglNn7k3\/zd34\/xADloyMwYtid64eIHTz5u6OX2Rrqa\/qg67SuVH9HMO3bF17LxT2nqvu0+csb9oNyDvhnfip8acxneWfHU8AmnEimrSrqYqrViXxT90rvs0lMeau84HaXO35+WL+d9S\/VmNf5VQtmooevrz8IXro+UXiVyQhtg1zlVK1L21s+Saz6jVYv9P8fHwyeWsQmjeeMbH1U1z3Aq8\/k5SnmxR3dkSVlVLlFjfgMoxCWWakzct2XHUmk8RkUKmt8doTiZrRkgHFQ3qfpXVEU6oATJk+W5jJz86itngED0RXJcMKWtE5ou00z9BPG6Y\/We8ED9nwWNJUY8CIh2rvbi76MymlrzyjAjzISAbOeaqnNwnkWsMmZdu8dfNjVNTSxqSmpqY6GbUADYIY0xhtJG1jINQuz6LdGLy0mrnQCkS5dIxqfPooLdNgq1hHtAKjsknxQ\/hUB3jJJdu+4ZvKlVJ85h5w27Z5Hv1Piq+MC4LyQk8jZX5t27ZNSycTp9oSb5HXc4XFo0Fs9Vpmmv8mldavX1\/2zqgyoHowzbSTRaC+ZvowQucokhyMHq1MY5JO+4jahho8vtFU2Wd7NZVoZ8w4En9SjOJjmU\/KE21cTB5gVh+jEX2L42IC5u62fLLlxmDR7fIgKwahydNsCEJ1zGV2DaSwKNXmxH13p7m+gnzG9YwXNy1oQ9leGrnRLVEQPFZTCN+KO7cCrPdt6O26TkQumteywvPclSBcu7m387fKU\/2TG09aXHKitzhetK7k+3fUlEqnsdJvg+XHoGYhPe8tlYJfAi6hl5VPnSXPMP7k5uY5cOBUL3JPRII1LIF4lKEnIocxplZNHMUbN\/Z1\/TrFYRS+iYFWH3tvoJw2nVmwoYCP0O2FcTuVO4GNrQHhOVbw1Ands6D8nhmlwQcGcnUr0beV0LnNm15\/DSD7ocsKUE2V6ZWS7mjqa+HjGAu9ODqBfh2Lss6Ap3glzuNh7Ny9ua\/zThmrbN+y+Ba2tLzMj5xXM8aPT5DHO+jjPZt6O+6mbVPP5I\/5J+E1MIZfSxoXvBRD8XrXix7S0p78eNH81lfz7dnlaBRfIHKXh2EIK92FBGE\/aNjI8tEPC7c\/3Nf39KJ5i473\/dKfgmyozglvxlg9oyblYTGARrS+vbXVjzs6kIfj4KWvpN8vdTxnX43n\/PtDnZ1PeghbAy+b5ElYBV3atOBt0LQA\/Xq8UOPfCKkyrMbYLJvf8hoU5OXQexxDBHLix0LPuWtLV9d9wIkfyD7xZLUhEDvBuejgk3uLQ7880q9vRF\/fBGdONG278Q4v8m5b39exkbqsVIf1K0ub7imPl85rfi3TPHx090D+KWbp7biLFs9v\/RDDhmxvfzFwb+mIO\/aKXy78omo+rg1u2hxv3ic8xRDqjXugp8oJOqyxdbRUD0PvDGI1\/UC\/EueBi9tsZISQYP+u\/WHhFhlL9UEYzQaJG50Jf+bileGlxDu92L2PgPoqYLQK8vAsBZqm1BaY2jbPXEcKlqzexsYgZqJaOH9hMx8wfn3sRsewxpc+2Y+ChmZDrxC+AX1bjGo0oFP9GMNNgRvLBjxhW5D+STfg3QAqsSThZ9yCk\/SXCCPHsnp3MLDvltRg2Wq4qXzrXU86d9U2u83ZuXOnN3v27GQ2ct0GOi6BFfQnOBkztxhdyMe1zimF4bl+Ma71gmB54AcOLt3tgFwnOI6cvZvl5CfyxcJNK133d6tSyytjFfjeP5RCZ3sQxR0EEs\/MBQkNmnoUK\/H98IMYvA9v3tq1xuBKjYKEuWh+y0dYmlxAh5Z4fExVXDUdcAJTVxO9vgJdiqPfAk6zsSxZpN2petf7v1iUPxat9Eqo1TcGXtSD4n1V8Zust8My5218Uvoy+rkJY7ULWb+GuJ76udUZHPw51ffbJaZBxj8ogwZNacf8ba9lQHwHpVrKx\/TZ3IBWmjTffwUgKpUGEc5V7oz6S6HBGD6yuY3DJgxrneN9noDih4MgmEV+OUHLviVNLd+PanOqt0\/b5xSO8B7KwOkNSvGOXJD7dKFUuo0syQg2OGcjw0uSQQAPsFhswrzU9YJ\/ps9OoVjcmw+CNwJ6n+cVT4fLV9ODfUUn9xB5DwpHNsFrw9DaWsVxHYcNm3OQyz\/T7lGFUvG6Ad\/7VwOPgBLOi4bkluMWxitY2tR6EWXfMvKL4q9aL2\/hCexq50pfRD0+gK5My7Ybh+GepU0tV9UXhi6DHwPp8gOD6Z8Oz78jHjUENfeETvQK+tWQ1JUsIulIN3R+clNv18\/Il5dSNhaCyz5HnvfOnO9\/FHzM4YZfhJK8FejgCt\/Lwa9Cfy7vvIJq650gXIFhvlr0xIWCPNstwjfJJHU28owi709yOf9zpk3pqZGRu9hDRr7nO4Rsdk7zpqnNbvX7id6tH4HoT\/m+fzy66vipjhP3Chc1tvz45NbWz4NrG\/pVQx0zqUySJgPGRDVEaGh24EVXMYbOKobxk7R3h8WxuLn5LD\/2\/g9j8xXQSLYkzcxCjCyM4rWL57d8gV3q\/xC878bn+EHAsplPITPm6Zv4eTL8vCaX9G1vmJuRxFRkTMUVxIa9CHcLgZ3hdG8TXyt9hx\/kGFzFXkL0JnYxc2DA76+p58QzjXruqzAwg\/zdGIaFLfA0swSMdSpaUs\/tTHebErxRrTEqnnciHdFs9\/swLP2e2eAp1KWVqeo9GIXlCOMyturfAYP3462AyAyCT4Lz63TMQXZ3hWF8J9k6hnEkxu6VlL0ST5CyaCMaeQV1jeDN9rvnX8vgOQPh5UsMIDr\/CCrawPA5i521lxVLxX9CeftR3uvVVppqwC1jsxgdZUqPb8UAP8z9w7n+\/l2CUTzJAuuq2Jqu8PY4z\/OXqj79\/AnxzYdZAOUZokwgzqtxBd\/NxsfFYf+gJoLPiFboN7ZXxirw\/M8IT7EU\/hajdwe+DCxyXkOdN9PXj8dDJWnERWvWrBmxBFCd0Ql6azQZMBpVxySm5+vR416U6igy3sYAWI4cu90w+q9CGNbR1janEDwmYGjTZrIGalCMwoo+QoSmClZ6xCbN62jtyppcDcaqcHsUBn\/T0btlr8rRSjYdkxSGOXML\/hjev4fcy5EFfS5e6w\/Uf0VQ8MRfPL\/56xjuv0wV+2ZYep+KoOyV0P0W+Pnp\/hoTG\/pMOVzguhzTQXau14BxehOye6gUltrRvW3UPRb5nFubq2lGnl9eMrdlHSR0pMa\/zE\/RJRqU4Ne16A1jwDsKRp6DHE6DH13o2m384ck4O4Ia50nBsv8QoDS6zfmhGbm6n2wa9nUi5wZo3oGeqs230ubLGfjbMdI3o\/91cGBrriFn2sRYfYi+ftPTZF0K72cs\/Qe7G4Po28vg4TkY+vPQ\/WnLXrLsf\/U82aPvejpPsByZAfJxCCvnU98YcsbjjFwp\/g7Bf4xVKQ9Pzt+At6\/68gYR7rW5XHACZzl2QOe\/wZPtyOBY6Pwzxt7yQli6llXDHxuP2PGuQ7d7aGQWY\/Dt9O0UfimnLwrdX9K3eups87zSLqOwBEqTqQ1FZqP6dBRsI2o0QxrgeKWaKPZOoBtvR0vVSXK9b3MWY4cIG5o1q+T2m61OWcZfu5H78Y1bO9erbFQaggBpVZ6dqbLg6TsBeKxuHG7FEv\/V+p7OW7P18HQeYEb+J+r9UdifX07ZHVrXLm5qanRi\/yK8MwxS6WvTjpn1+exgbZJXEvt\/78fuR6kzVAic\/+ZqEpuf5+X84IxisfQU0+j7NvV2ytMwadncuZcXY\/fKXC7355RfvPjExbdt2r7JGCO4ZGl9hMjLhZu6O35l6+maCnJYwTKF6qf6D\/NY\/gWX2rNLKciVeEkPMrF8DQN9Md7kTfImGR+RBM+i8ULDo6j0tVLO+0JHR2de9cDpMUv9LQb0iyjDhSzNb9rU03GHyo7AIuZZ1eh+TMJQJrQ4gynNMYr2AHD6wxtqrcP7wGCF9yNn8c8ktWdumMwV40ImgyjWCAOdgqILycA0y0\/Tq1mPAAAcOElEQVTX\/R6TznH5YvG3LJPe19mz5UkZAysvQySaZusubWz9H3TuuzV+wPHA0o\/mNM37K2t4lsxvOYuyv0SJBf6xjT2d37b11Bf48Vk8si\/Bnf9t+ahyFDwvgtFRBmf08c19PT+Av2XawXsbXtEN9HsR8\/+bqNKhgL7Fnb2mPCvzC9nNwos5LYpLazb2dH0kC6t7ms3HWDN0bSD0WEscRILGsgzTcWXGFueiINV\/eRiXNtBmWUZCnSzR3E94eMalUunHtW540QPpsl3lWrYyjr\/HeHtnOH3oFrJ+pPx0l7DcnvLGpNjJWZrC\/qFv4GW+C1xEA5x3b+jpuNnCYzMu5sjFCYzdhznD+Z6NfR0bbNmyua3fLcSln1K+AvleQv67NvZ23M9Vf5zna5mD6E+JitG6Db2d6P5wMkqiicfwxXWPwgO4kTl\/IxP4atb497EguxcF+Q9m+PNg+tOUvwfk31dMRmiM8YljRfCxbu6DWWNFXlkJkRa+DqLjpNtw88mdma4dZ0fd0Uf+RjmKG9m6vheyAxI\/gnSkdAtsXRZ6p9HkCfCqnw2pH1rllzIJRu4qW7zfZ2AWyHlpXclZoXydCoaOt+oevDcywI2x0kFL1V2\/bRs7pdHVMsz09TQ3KMjFTpLxLAz6XmusbHsCsIJMoUdcKEM\/1H\/W44Hxhpy0TcOPsBBcE8bRQxjSGrj2OltZywAG4AwGaFch8C63yyKVgzPyBuquoI8Pij9k\/Imth3dkCLXP2SsF4i+kuPqZN6OgTRh4C8P8aWhCeCNwsNxNZJfs0dj6I2CEQxlMFE+wXDgCHv5TbVCzkJ3ltUHknt9J3Cr1XGxzBl513Hp358mNjYsh6Pso80yU+WYM3EUyVtCb6KoT\/7GWiHiJd7rT664WEi1\/hFN9wWG7Bl71Bp53BCvvN5YbEX7j5cT7mHh+DagxHOmS0ZmzdV47IHdJF2m\/RfUEY9vVs01qx+q\/8tD7hC\/JQsWAqR5\/Jh9wnA8S46SGoWLxHOxV+mLr4GGzxyFej\/WI8ETOgEct8O9JpPsta6wsPUyG14LnRoVCoOmNFu\/+hgbbD9tM9kpDRkqKn2FUWv8Om3A+SzdR8CEmjn9XF1V28rwF8C9uM5Oi6\/7jhtRYoQ+1Kl+\/rbMTZlybTJrxmThI85VfTgzu9H4Mr8oGRQAwlhnF7eVvM7Q9wnULTOngbxdlPLrTYVSzCLPR+xRxctHpeJIMjv7asgKUXElQYK66H06oNa5dfvduLUecu9kSbksOpTnETQao8WTCrLgcv8HNnmH44zr7PQ61qt6pxx47XdufMkp6ptfPUHcvdIupZkAO1NbOpq1WLSeIQ5S9OS1d6KOhrej793LXzfICFHGjcGUTxjdoaWmZqTy1J35ky8e9T3vuFlmekPL5vKmn+lse3fIUfdwkBnFdXMbhOgu15IVD92CsdipfCqaBRjVv\/ZPr9zNgzNKbXi5RXrnu+DeJLEBqQY4++ujyzK\/JRfkYNN8q2Wgjk9RL+GVx6Er7Pr7EIJPdQtaLV9XV5FawDHyE9fN567Z2dKlcy+bR3guk7HPz4atC1\/8Bsc7jMXCrCr5zPn3eKxqkm9QVvxal7d1hwxYyaHbCWt\/T8zhE3CueQU1TCiv+wR7zROdyOlzpCK9itLpvd9rRfedx6Rn\/HaG8NBkZ2Qd7Bb7MLwZ9wi8MU1Nq+BsbG42MLXx6LfN7VP6kHvUurwWEH6ZN+uRLNilvbPFJMrzQtW5WlN+oTOlMGwyR3lAXPPFdRt1dZ0FxT5GTHoQbisVxdQdY3HU0jY0wPPCPIonLNJTRgAs39XT+UPWJZ5s+I\/tGil6iGBuxqfIYy062fOv4t4pTCc4tOfNU3yZaMbMGjXl2YrATi\/GS6CwBVpZlrruLA3\/vXd\/d\/dCiRYsagt1BPNgw6KMtRxICezsgX5G7jdutwf85NTA0NEQ2zWaSDVSDd1wGZMDTW9cp5AMjkDlz5pTatxsFcgjaRlFpkD4AZjbUEnAyHlcQhVlzDkwjCOzseOjxx431574gKObHk6HgGIwTXfPMso6Iez3xbnYSwRA7r13UvIBrNB0lZSMxZu52B4LYOYb2YL665Y0I6govya3fV29oJUCsIP6I\/icgFf5VH4C0y6iZM2fS5PCyhEIZWJoeNszkmcFFVRObEFa9AyhMtl36Ycro0ZHLjz9esmHpKgiJ5uATlZL+YCRO7+wywVgZmbKHVUY5Er3vR3jqnM3S75y4zqUYjVNYBnYwdt7HUn99qg8iO1qJdyc0cC4dCO4xPFzBQFuMgfsdq9m\/6OzsflITH8I1NDQ2NireWU991VzI615nc0N8wRgjEaNzgeCNjxcMA3as7BB0yS3JODmnd3YavLoXTSxFdEsC30EkWjL4VLGxt9Hg1ATQ29t7EFgODpR+Jm0ybJGNOeNkMUC80Rm49PTd27eb8IE2MugjGpHqBLFg8YiuTnf9fCXjatGZKzjxC5jkHeds7k+UBAgZfJoY75UCkNHEezbxvtQ5MDzEAXs7cupGRvUGEf8ggkH+FvOnGFGA\/9lgy9IrLOWOStYx0vkulRmlUc\/NfETQHQOwWwWbNydbr7on7eHvG7iBdSjhl9hFO4\/jCNev631kU39\/v1dPKNNAZf4pMyaTN\/GtWJAkGUF7P+JqhUSmN1h\/TzR96BcY2reVXOfyJc2tx\/gl985C7A3VuFFd5IZskXqXssRi+7h4p9dfa9b+2gXl3TXiGewtOs4lNHSJDLqSjLYxF3AqmaFFU1xJmFg2vQTgOG2qMNmUdlF6Y6uIT1Kk9NlebbGEZohDgkZgaYGtb+GNUoIpIKaYdGYYw7O5c3e2tdm2DogH68uOu5OHNwS241PEz1IU37yeYwaqzAyc0yyrPr9DPSP58IIbTTzagdZykCfeV+tJDi\/jUrrt6S4Zy3\/MEYdOYBe4zwXNuQI3IhhBpVmBqWCswRI0jFLhTme8viXlgplkGm69bZI1DhdYMrTVvunTaLTwyhpTsb1cLFFJc+E+sYPJ9dfw3fEWaTeekAMrL\/NWjPFUU7kO657r5pFRLVR9I2l3NHmMP2YyLQtDN0q8xTJ1FW9MH43Bsq3Qd14QcI21k7ssD8Aaj2TJ5NxKbOdL9PtEXLqTQbtJSuT4lcZ0xUafXWYiHINDSyECjw8wSN5WwysKdPxHJS8cwpfcz6q6nm3U6exassNU2ohB+pTgVbHolbSBxc6WAv3R9XDhYVhprb+4ChNcJgZORpmXv91fmwbH+QdferQkxoEUZv5GQaMEo3IMiCAPlLL1hkVY9sMOVH2S5e2ThAMMBytEL+rhK7O5sxqXlbM18QVsb\/9uU3f3L61SaxCtTEcPQSJFxOTe7mLwENvwzkDMnyAwfA\/HStbSfNTGmUDQ8+KJVjPEhpArVqud+fU28hUXsZzVFRLY28QbAHQNzyZNdlBa+Bf41eiP2Jrth3SNvOEySnkYCZStMOpeVWHsGmLZcxHCAuLbn8cD\/mgHZ+PSkEF5UqWpnHSd\/7+DSHaASnKy9GiM4eYyxtjIKhV9s9kzqrmKj8ZgZUvCIDIurdw7GjXWeWXqvmMxWYPxOg6NYygqzl5ZXM\/l\/ZKWFg4TOh+Axv3FSGdy4ia4r3eQpsGVRxk0vbzp1s4Rjp+t7+rcCrOTg6ZRDV+goIt0ggN0P9nQ0\/lfzyWdI3BbcWUyoWvYw2KX1hTxCkIGZEj39Gu6zWvjsd30oKwAZpJB+oP5mflM3QoNWiSTusIkGhs\/CT8wadLBUWyJjjkwa8dfoexdHGV4P8vCq9gtfDTdCVKXZWANcYwBxaZwqqJ9VP8Uq\/yvcrzgVdS5muMnb0W+O4i\/GD1tbGwssV1v4Km+alNP19ds2+Nd1Zb0WE2MB3MY8su47TGWw4DzWaBI3veDqFrFftIdVvFdwtKf\/Fp2sYwQrAc2cXuEjfCcdUToVk4J9DEdcD4v+PD6xuZeKn5dMcQ03ol9MEs98X2IKPA\/4GFvnRi5YzZOUjqzoIZm8JT5mxqs4SVKECrQ7DiKVwi6zSwJ2gyS2Asb6CfGitMRrvuMyZzkP7Q4rNmTrDMRGFb+eLyoJmjZ4zv+7et7HnlwPHjTj\/TNctaDe5ycuxPjeySuqAK4\/0W58VASxTZCVUzDMIkyVi3ZOFPSCuv3Q+6Plk7CsmvXLr0LqNuiaCQ2eLxRovRUvwqYEh+Tq4cxWig6ReN2To8vnzlT7RtlQ3oLBQvRj9ojD+b5MPxjg9LogcdgHIVxLAvEK3hbL6X248JfF4rO8ppcsJSzVN9dOHfhuZQ\/qgDw7A0bRg0Ud0bR9x7kJd4Pc7ygnXM6K0LO+DAI3ivPTA1LoYmHPG6IiJ2TLDFWRuKhzaOdspLbvOfjalcke\/bs8Vj2jurj80GBGWiPJuY5nv9UX9\/RtPoEy\/FAh3jtRgUrkcYk7OE+7pdKZtOKJRqnAlO2GQ0dQa\/lZ61OCRAeaoTDf0trX0MmfewS\/quNYXHmaiervQHwTyOs3gwW4zAIG2LRhGPkNEJG7Sotp7IcyRElIV62rnwMRP8ytenKVM\/RhyHFqxxZTBCGUhIFvkwjkft+bSmTtrJnYHYfjJtuDLVhlO2UYEYkKKAMfozIzTxMPANqxKp6GT9MXofRusVzPCLX4S0ETG+HiZdxfcuiefOOz2BObtuSi85U0a\/VibCcs5vY1eEZG5J4k1xNytQfJjl1sdUXG8PKwE14a5YkqohHwQra8FhHL+zuFh7Iyyk9Q0sZjFZ5KQPSu3DDyYpXLp3f0qZGNIDL9fhSANJ7PUQT1yl\/nkRgaqvML5OR\/ScpqVhOJpSSWFFbBZceNKxdOwJeriF6MTKPZpXBUZOX6DUeYD7GifqdHC48ww\/Cb4jfwtnLax2mDf4RvP74vMzRm7q61tGRj3NA0mGT9tygGH\/JwiXX+G41gMq\/UW8rKA8yzFLECC79J1PH9MUsGwzwBDxJx0Gm7mRvTRvwomT5JRndWDZYlkf2mkErGanzh5oyMi7v5LrRA0wQzIreqWHk\/6lQix5LG6+YnUST58Aq9XiNOcoDjP2KiiFlWOvNo\/5JB6FZWXFC\/XN8feUX6XGaf9QXFsBnahVznCzghIFsBfJ\/j6k78Rgrt6Eb6phPW6C\/xgYpzwbfjdJgbYExoDnPy53Gu09OkOOtQg4BERlr4CM7vCPV\/G4scNJJx\/3Jxq5Ojj04zvTp0yM+FJcyPcGi\/DEJxqZyGS0eUxeJj85PUCgmw2EKPWRhxGTeM\/seTDoLo3kctB7H7tsbJQRSP4f57meBcmvkR\/9GnmiV0TUeCmvBf+GMynt5ReZ1fFzlGj4P8p1c4GzHarHg5QOGvFtRdMDHM+9CraaudS0O3E+1XiFRUQFpKUg9AbLlHFDtdwLOQpdKhTCoO4UgzmV4FUcVwuJDvhOtsihKgfvzXCm6gLIz2Dy4mhPgX6AXd6qcNxxexqHRz9P\/GZxm3uh78c9tvX6+NFKjTWMSg9tcbdkwH61IbElypdwKdJ4OIeqQqzkqsnx5ebmZIhyBN8UCu3EhvcSI6CNwi5pa\/gZ+X8u5nXdNi+Ie4D4jYy14G1uCROLztTTtOBu7O\/+F+GQz1F2Kt3YJsuzmcORVKuOk+C9Cp\/QxliPzi3Hpe0xQX0GeG4oFSnyvxvUZLqF3DHHhI1jFPAApiUemygkbKtFsSgVgBWwzJnkdoh0ZzlYdaN7U09N76rGnagmvPpbjOnQ2RT+MVbJICEp0fLjkgHdjaLXeXcH3V3Mo7f8Fgf9ujiowiTfXRk7NLbWlsBjm4mW0dAn6dBLx3cfg\/022pd25XDRDTIKg0RMRMCmZyWqAvsaLGhv\/muOKJ3DIejkHRK\/i+ezNvb09XV1de9DTnwByOrr3IeT3NMp\/fbGYeypXU+J1WEfva9VhdI7ldcrBR7Z2S5+zfDIeH5w5nteH5rKkfLSRYyLSGeMuUbkWxcc2uUdz\/2+8K7aOwcDZHn81J9fvc\/3gBjp4DgNar8BcMeiGxCeSZA6Ouu4M43mxRWrz06tRQN1TdZrWwHBihmVsClOnurR7RDSN0MeoVDqKoH7sHJHC2OA4Z65OnQ5nzyM\/IPB\/DTb3FRztvxD6fkYbHM\/wXosCf5nV9O\/wXj4otDDQzAAEgH\/F06f1yCsKzADx3cVStCYM49VhEK\/hPbPVOd\/7De7Dv3oDpfmWJJhVb\/rpOg3hMcmScKfG3CQSxl7bigUCxjOg46eRX\/tIGPt3RkHN\/XRwFfx9DQq0iyjhJ3WWCIVxVxI7ZGbci928GC+lGy9lAUb5OhzjtRwZXcNJ5xvJO5n+70D4F63r7n7CnlsxJzngqXhOu3VZEvHXptl+2Hydi6LJVB\/iB3UgkLZewUHM25k9uwZq6m7d\/+TTpwoeeusp0+2RHHQve0qeHymMMB26ICdxxXl2N\/d0\/QAivqyRwPuKn17auOCzyhcCbGoZF1mQmqTNvd1f1CtM5sCw6313yfwF\/1Ml5iyX432MPu\/mtZ1Xs7v4n+JHLohW+25pDZPU6sB3f8\/sfAsvO5+RokMlIkRqeHGkH6W7Um22NLlC33SMKlQOxwtHQgw\/IcPy4VF6sha9c6CVF\/79X+PpdxTr+m9fPLdlsWqAry7lVwNjyDBO+WF0jDqMjKT\/cVZGFXUqq2vUqxet6L2JXwqfjrvAQ1\/eFCugS\/GyVgdB7lhCJ1d6TvH+Yo6AOSEQdO0NlA0gx0\/pDQd7xkkn3REcYxkecPxHOMtJ+YY37jT1XfkyTtxchG4+WZerYVc4uH5ZS8s8lc0KC1fBk2u0E8jk8ilOvq\/mhfk1LBbYjHHuw66s8d3gV5idK3R+Szih3fAmihiDGCDaW4FBbOd94Q7eWvnNknmty1Lmefcy2FcRD+qA+TpoyRFYV64f25LxbpZcq3nv59s4kCt5VeNiWTrrfmppAtfv4ttJvajyQyI2k4yBMM+8b8fXCrcimtU6E2Jh6HqHzuqAYxXvJZpzVLM3zFY9w5QZM2YMcfP7wXyhGy9ks62XnzbwBjp4Nkzp54To1zf0PHIvr9hcCX3nhgVeK4l5lScs\/SednoNb8496n011JVBdmbG\/Do\/+BMX\/GY\/bKEFAfIWC3QueH8fdvQ\/pfZ8TEI8JXgmiNvMlxh5Y+3teCDceQnvZ7Tcg4\/+Dk0vSNpe8CglaZzdeQptHkdfDDPUD7s\/a2Gc+jCg8HM6NzVKcft0Ve9Fb8LC+xWn4zfiBencTIUcdig0RPn3z8Ods2w0N9Iu4j3sHLy1vxE02y3dTIMRxtG4on++FBuOppfniuRkoQ\/rqRhx9BqPVg1LzXiZxiNidgfIJhhVb9BgKdS8adhtT9lNpfWq7Oxh4txOYvQtIxpfjNHJ2Std9Yf7L1LmCpV4fMCtQ7BOVzzTZjXe4FgNze5gLzU6uYlzwhNcMo0\/Cl5+y9O9lAL5m7ty5ZhAlr4B4b0In8bCjDvGDtnEO1Ld4t94YoI0f8qbDJuUpwckd8l6R\/235YmBo5mwPW43tpk8JlHv\/YCEvXbg\/eTb\/wqbKydblNP7PEevn6HcXBDDpx03QpIPNpi6e7zbK7oaKX5Uirxz7rZtXl8iIg7VMsGXdprWKbbZndI2h\/fBgocD5JudO8SqlUPVMjIil9SO85vln6MFlYRw+nJRjbJy4D535CbtnZ+lLKsq3GwXNjz2m15fuZJz2IeQtSR2IAT\/yWa3xC3\/LY1xn5KSb6MfH+BbYfUDOKsXeaap3F1+MGHSjj5ai6Dxo+DVlTyMjnAyNM16TcuJe9OG\/0ePriH0VVIeYn9G\/oGHaLzBaf8eqqRv9mwVsI3zVRC+DmvCmidgCHJ5JFp5jyGoocc9zXmGAdd9uu\/4VYgSRLK30QJLx2r9\/f91xxx03qFhHkjvyX838fAFCs0hhFC6f0+L1nPouamYYWSt50u5D7Z7a3OydG4bamZigmZdjWy\/hPcK\/h9Y1vF\/3GtUVHTa2o5o6jV4bunfiGi9lSfJZdpW+qnzRYtfEesbCv8Qv+kbha3JhkS9v71+3deszakfl9Fd8Mp+a2QitZI3og2DGS5YmXORzGPA3IXoGi\/vmfeHQpmlBMN+Na\/OcZNxr31cUHtve6Hs9q0+5MMTI1XLIZehpxYmUr5Stp+cmZDq9f3qwYeeGAci3Sk3\/3WDHwoX1LCXLcQ3BK2VxwPfZtUPxTPLiApsVjzz2iOJ\/ZiY8Zc6cet4ji9c8+uhAUjP591UYlX5OTOsjjYJNcRp9EW7qTds\/fXowa9asATPZpXlajuizKBYX2baOv3Q2+jEz76HYMmhCmygtD6c3NR3Jt1Rm5aIcvl5YCvO5\/objGvZYPVCbghe+U+acUr87t3tEO7Y9Xa0ea5K09bPlle4tfpVl+VWKgmc2P7p5d9q26ffoPqZ1iIXX6sdZ9EmY4WVRpcYyebRrxg1ZY3RRNAlUbeuqQ+BuPn80X47yh2qdvYwVM5moDNARY1mTBQamdvRYrpSfrStdQ79rCyTJMVvGPS+sz39JMcrxJVoF9nkXtS7aBx3J0k+EpAlYIy89ip+YdJb2XlxE\/8TPssGyFSa6Chnl6uC4jM02OBEulR0MrMUlq66T9KzLP8Ly4krNank\/Xq51s4WxV+Ff3Nh8f+AFp3H04TN2G5xs65ZLpmXlt\/UO59UaLJYJf0a7P2NJ8FQu9s94OP3hhmxbli5IKhsXlZMvvktWI\/Jt3fHq2XJdhWOyfZ0IdqKybHuj26TeiIExunx03bR8TB2br+t4\/FDZ85km4slEZaNpPBjY0XVHPwsXeRPpzITlo\/GN90wzFWUkeMoq7rCPh8vmi\/bxdNUMXAGsZNblohjEmD8ZCeULIYjGGCvKvJV4LbqO11AWxhIm2Ey+wW\/LsldgfIv\/xnKBfzcu417W2y01kftFBTvliclA6KqP+vHh\/M9D0mn6ljyxrDWqCi4JSk2bwW\/7Rna538pbmfJDdWwCxvZzXFot7Ogrrrjalc\/rluLQ7LQ0MSsJp9rTH8VlurL1lakyYA2crtn78eoJJuXbCAUg3\/bDGu5sc4YIwfCnduxV9waPrivhT8o70y8hUH6GdyPaFL8p9kWPrad+kQeuJG8EETxk6wBW5rnyVSw8KS7RVv6z+ITb4tS98rkIrpxvy3Ule0K+ZGGz92k\/yu2rjbF9HMuvtE0\/pWvcsZNty95naC3zxZbpKppIhucZHhlZ6jmFGTMBZvCO0I3x8tM24FvyQ7GCs3RQpuNP6Pc7R\/CGPPOsOln4TD1jF1K6R+ifCZiqZwBXXMpZJBNdRTTlYzqfrTMezHj5o+qWjSQdNMqmQ4jsPlxKnOpyAucXEZx7L1vgWwZ2Pb0\/R5CZtXQzS8YTTdfi+HJiPKyjTdJAMrRyVb\/LuNPycS9pvQn7OV5l6pqTFFQuv66vHdYU53jVyvnAHRStqkiVin1L25ywHylMuf3sDWUV9SXNr9jmePSMh8u2R3lFfAdqy9a31wO1k9InnkzIF4tv9HU8OlO8FfmVllXs32j8o59pb1K0TkTXaJwpPRXxTtTeJMoqNTVhXopzDEx5h2dMyRTNoCNmVtaVwPk3+ezuw3xq9v1YsTexy8lJdxl4nX+LnsYDu5mHn27q6zaOmYwd1Q5JIZ8tOzhW\/DTBN5atcR8vBpm1e\/a7YM8Wf7V+lQMvBg78fxAN2T5iTbNnAAAAAElFTkSuQmCC' \/><\/a><\/div>\n <h2>Hm, teknisk feil.<\/h2>\n <p>Straks tilbake!<\/p>\n <\/div>\n <\/div>\n <\/body>\n <\/html>\n \"};\n\n }\n\n return(deliver);\n}\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"382a15fa5e7a0f73e4234dac347cc8d0fe39c41a","subject":"Setup our VCL to log our downloads to linehaul","message":"Setup our VCL to log our downloads to linehaul\n","repos":"alex\/warehouse,alex\/warehouse,pypa\/warehouse,dstufft\/warehouse,alex\/warehouse,pypa\/warehouse,pypa\/warehouse,alex\/warehouse,dstufft\/warehouse,alex\/warehouse,pypa\/warehouse,dstufft\/warehouse,dstufft\/warehouse","old_file":"vcl\/main.vcl","new_file":"vcl\/main.vcl","new_contents":"\nsub vcl_recv {\n\n # I'm not 100% sure on what this is exactly for, it was taken from the\n # Fastly documentation, however, what I *believe* it does is just ensure\n # that we don't serve a stale copy of the page from the shield node when\n # an edge node is requesting content.\n if (req.http.Fastly-FF) {\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Some (Older) clients will send a hash fragment as part of the URL even\n # though that is a local only modification. This breaks this badly for the\n # files in S3, and in general it's just not needed.\n set req.url = regsub(req.url, \"#.*$\", \"\");\n\n # Most of the URLs in Warehouse do not support or require any sort of query\n # parameter. If we strip these at the edge then we'll increase our cache\n # efficiency when they won't otherwise change the output of the pages.\n #\n # This will match any URL except those that start with:\n #\n # * \/search\/\n # * \/account\/login\/\n # * \/account\/logout\/\n # * \/account\/register\/\n # * \/pypi\n if (req.url !~ \"^\/(search\/|account\/(login|logout|register)\/|pypi)\") {\n set req.url = req.url.path;\n }\n\n # Sort all of our query parameters, this will ensure that the same query\n # parameters in a different order will end up being represented as the same\n # thing, reducing cache misses due to ordering differences.\n set req.url = boltsort.sort(req.url);\n\n\n#FASTLY recv\n\n\n # We want to Force SSL for the WebUI by redirecting to the HTTPS version of\n # the page, however for API calls we want to return an error code directing\n # people to instead use HTTPS.\n if (!req.http.Fastly-SSL) {\n\n # The \/simple\/ and \/packages\/ API.\n if (req.url ~ \"^\/(simple|packages)\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy JSON API.\n if (req.url ~ \"^\/pypi\/.+\/json$\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy ?:action= API.\n if (req.url ~ \"^\/pypi.*(\\?|&)=:action\") {\n error 803 \"SSL is required\";\n }\n\n # If we're on the \/pypi page and we've received something other than a\n # GET or HEAD request, then we have no way to determine if a particular\n # request is an API call or not because it'll be in the request body\n # and that isn't available to us here. So in those cases, we won't\n # do a redirect.\n if (req.url ~ \"^\/pypi\") {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n error 801 \"Force SSL\";\n }\n }\n else {\n # This isn't a \/pypi URL so we'll just unconditionally redirect to\n # HTTPS.\n error 801 \"Force SSL\";\n }\n }\n\n # Redirect www.pypi.io and warehouse.python.org to pypi.io, this is\n # purposely done *after* the HTTPS checks.\n if (std.tolower(req.http.host) ~ \"^(www.pypi.io|warehouse.python.org)$\") {\n set req.http.Location = \"https:\/\/pypi.io\" req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n # Redirect warehouse-staging.python.org to test.pypi.io.\n if (std.tolower(req.http.host) == \"warehouse-staging.python.org\") {\n set req.http.Location = \"https:\/\/test.pypi.io\" req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n\n # Requests to \/packages\/ get dispatched to Amazon instead of to our typical\n # Origin. This requires a a bit of setup to make it work.\n if (req.http.host ~ \"^(test-)?files.pythonhosted.org$\"\n && req.url ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\") {\n # Setup our environment to better match what S3 expects\/needs\n set req.http.Host = req.http.AWS-Bucket-Name \".s3.amazonaws.com\";\n set req.http.Date = now;\n set req.url = regsuball(req.url, \"\\+\", urlencode(\"+\"));\n\n # Compute the Authorization header that S3 requires to be able to\n # access the files stored there.\n set req.http.Authorization = \"AWS \" req.http.AWS-Access-Key-ID \":\" digest.hmac_sha1_base64(req.http.AWS-Secret-Access-Key, \"GET\" LF LF LF req.http.Date LF \"\/\" req.http.AWS-Bucket-Name req.url.path);\n\n # We don't want to send our Warehouse-Token to S3, so we'll go ahead\n # and remove it.\n unset req.http.Warehouse-Token;\n }\n\n # We no longer need any of these variables, which would exist only to\n # shuffle configuration from the Fastly UI into our VCL.\n unset req.http.AWS-Access-Key-ID;\n unset req.http.AWS-Secret-Access-Key;\n unset req.http.AWS-Bucket-Name;\n\n # We have a number of items that we'll pass back to the origin, but only\n # if we have a Warehouse-Token that will allow them to be accepted.\n if (req.http.Warehouse-Token) {\n # Set a header to tell the backend if we're using https or http.\n if (req.http.Fastly-SSL) {\n set req.http.Warehouse-Proto = \"https\";\n } else {\n set req.http.Warehouse-Proto = \"http\";\n }\n\n # Pass the client IP address back to the backend.\n if (req.http.Fastly-Client-IP) {\n set req.http.Warehouse-IP = req.http.Fastly-Client-IP;\n }\n\n # Pass the real host value back to the backend.\n if (req.http.Host) {\n set req.http.Warehouse-Host = req.http.host;\n }\n }\n\n # On a POST, we want to skip the shielding and hit backends directly.\n if (req.request == \"POST\") {\n set req.backend = F_Heroku;\n }\n\n # Do not bother to attempt to run the caching mechanisms for methods that\n # are not generally safe to cache.\n if (req.request != \"HEAD\" &&\n req.request != \"GET\" &&\n req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n # We don't ever want to cache our health URL. Outside systems should be\n # able to use it to reach past Fastly and get an end to end health check.\n if (req.url == \"\/_health\/\") {\n return(pass);\n }\n\n # Finally, return the default lookup action.\n return(lookup);\n}\n\n\nsub vcl_fetch {\n\n # These are newer kinds of redirects which should be able to be cached by\n # default, even though Fastly doesn't currently have them in their default\n # list of cacheable status codes.\n if (http_status_matches(beresp.status, \"303,307,308\")) {\n set beresp.cacheable = true;\n }\n\n # For any 5xx status code we want to see if a stale object exists for it,\n # if so we'll go ahead and serve it.\n if (beresp.status >= 500 && beresp.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n # When delivering a 304 response, we don't always have access to all the\n # headers in the resp because a 304 response is supposed to remove most of\n # the headers. So we'll instead stash these headers on the request so that\n # we can log this data from there instead of from the response.\n if (beresp.http.x-amz-meta-project\n || beresp.http.x-amz-meta-version\n || beresp.http.x-amz-meta-package-type) {\n set req.http.Fastly-amz-meta-project = beresp.http.x-amz-meta-project;\n set req.http.Fastly-amz-meta-version = beresp.http.x-amz-meta-version;\n set req.http.Fastly-amz-meta-package-type = beresp.http.x-amz-meta-package-type;\n }\n\n\n#FASTLY fetch\n\n\n # Trigger a \"SSL is required\" error if the backend has indicated to do so.\n if (beresp.http.X-Fastly-Error == \"803\") {\n error 803 \"SSL is required\";\n }\n\n # If we've gotten a 502 or a 503 from the backend, we'll go ahead and retry\n # the request.\n if ((beresp.status == 502 || beresp.status == 503) &&\n req.restarts < 1 &&\n (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n # If we've restarted, then we'll record the number of restarts.\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n # If there is a Set-Cookie header, we'll ensure that we do not cache the\n # response.\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n # If the response has the private Cache-Control directive then we won't\n # cache it.\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # If we've gotten an error after the restarts we'll deliver the response\n # with a very short cache time.\n if (http_status_matches(beresp.status, \"500,502,503\")) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n # Apply a default TTL if there isn't a max-age or s-maxage.\n if (beresp.http.Expires ||\n beresp.http.Surrogate-Control ~ \"max-age\" ||\n beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # Keep the ttl here\n }\n else {\n # Apply the default ttl\n set beresp.ttl = 60s;\n }\n\n # Actually deliver the fetched response.\n return(deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n # If the object we have isn't cacheable, then just serve it directly\n # without going through any of the caching mechanisms.\n if (!obj.cacheable) {\n return(pass);\n }\n\n return(deliver);\n}\n\n\nsub vcl_deliver {\n # If this is an error and we have a stale response available, restart so\n # that we can pick it up and serve it.\n if (resp.status >= 500 && resp.status < 600) {\n if (stale.exists) {\n restart;\n }\n }\n\n#FASTLY deliver\n\n # Unset headers that we don't need\/want to send on to the client because\n # they are not generally useful.\n unset resp.http.Server;\n unset resp.http.Via;\n\n # Unset a few headers set by Amazon that we don't really have a need\/desire\n # to send to clients.\n unset resp.http.X-AMZ-Replication-Status;\n unset resp.http.X-AMZ-Meta-Python-Version;\n unset resp.http.X-AMZ-Meta-Version;\n unset resp.http.X-AMZ-Meta-Package-Type;\n unset resp.http.X-AMZ-Meta-Project;\n\n # Set our standard security headers, we do this in VCL rather than in\n # Warehouse itself so that we always get these headers, regardless of the\n # origin server being used.\n set resp.http.Strict-Transport-Security = \"max-age=31536000; includeSubDomains; preload\";\n set resp.http.X-Frame-Options = \"deny\";\n set resp.http.X-XSS-Protection = \"1; mode=block\";\n set resp.http.X-Content-Type-Options = \"nosniff\";\n set resp.http.X-Permitted-Cross-Domain-Policies = \"none\";\n\n # Unstash our information about what project\/version\/package-type a\n # particular file download was for.\n if (req.http.Fastly-amz-meta-project\n || req.http.Fastly-amz-meta-version\n || req.http.Fastly-amz-meta-package-type) {\n set resp.http.x-amz-meta-project = req.http.Fastly-amz-meta-project;\n set resp.http.x-amz-meta-version = req.http.Fastly-amz-meta-version;\n set resp.http.x-amz-meta-package-type = req.http.Fastly-amz-meta-package-type;\n }\n\n # If we're not executing a shielding request, and the URL is one of our file\n # URLs, and it's a GET request, and the response is either a 200 or a 304\n # then we want to log an event stating that a download has taken place.\n if (!req.http.Fastly-FF\n && std.tolower(req.http.host) == \"files.pythonhosted.org\"\n && req.url.path ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\"\n && req.request == \"GET\"\n && http_status_matches(resp.status, \"200,304\")) {\n log {\"syslog \"} req.service_id {\" linehaul :: \"} \"2@\" now \"|\" geoip.country_code \"|\" req.url.path \"|\" tls.client.protocol \"|\" tls.client.cipher \"|\" resp.http.x-amz-meta-project \"|\" resp.http.x-amz-meta-version \"|\" resp.http.x-amz-meta-package-type \"|\" req.http.user-agent;\n log {\"syslog \"} req.service_id {\" downloads :: \"} \"2@\" now \"|\" geoip.country_code \"|\" req.url.path \"|\" tls.client.protocol \"|\" tls.client.cipher \"|\" resp.http.x-amz-meta-project \"|\" resp.http.x-amz-meta-version \"|\" resp.http.x-amz-meta-package-type \"|\" req.http.user-agent;\n }\n\n return(deliver);\n}\n\n\nsub vcl_error {\n#FASTLY error\n\n # If we have a 5xx error and there is a stale object available, then we\n # will deliver that stale object.\n if (obj.status >= 500 && obj.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n if (obj.status == 803) {\n set obj.status = 403;\n set obj.response = \"SSL is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic {\"SSL is required.\"};\n return (deliver);\n } else if (obj.status == 750) {\n set obj.status = 301;\n set obj.http.Location = req.http.Location;\n set obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n synthetic {\"<html><head><title>301 Moved Permanently<\/title><\/head><body><center><h1>301 Moved Permanently<\/h1><\/center><\/body><\/html>\"};\n return(deliver);\n }\n\n}\n","old_contents":"\nsub vcl_recv {\n\n # I'm not 100% sure on what this is exactly for, it was taken from the\n # Fastly documentation, however, what I *believe* it does is just ensure\n # that we don't serve a stale copy of the page from the shield node when\n # an edge node is requesting content.\n if (req.http.Fastly-FF) {\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Some (Older) clients will send a hash fragment as part of the URL even\n # though that is a local only modification. This breaks this badly for the\n # files in S3, and in general it's just not needed.\n set req.url = regsub(req.url, \"#.*$\", \"\");\n\n # Most of the URLs in Warehouse do not support or require any sort of query\n # parameter. If we strip these at the edge then we'll increase our cache\n # efficiency when they won't otherwise change the output of the pages.\n #\n # This will match any URL except those that start with:\n #\n # * \/search\/\n # * \/account\/login\/\n # * \/account\/logout\/\n # * \/account\/register\/\n # * \/pypi\n if (req.url !~ \"^\/(search\/|account\/(login|logout|register)\/|pypi)\") {\n set req.url = req.url.path;\n }\n\n # Sort all of our query parameters, this will ensure that the same query\n # parameters in a different order will end up being represented as the same\n # thing, reducing cache misses due to ordering differences.\n set req.url = boltsort.sort(req.url);\n\n\n#FASTLY recv\n\n\n # We want to Force SSL for the WebUI by redirecting to the HTTPS version of\n # the page, however for API calls we want to return an error code directing\n # people to instead use HTTPS.\n if (!req.http.Fastly-SSL) {\n\n # The \/simple\/ and \/packages\/ API.\n if (req.url ~ \"^\/(simple|packages)\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy JSON API.\n if (req.url ~ \"^\/pypi\/.+\/json$\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy ?:action= API.\n if (req.url ~ \"^\/pypi.*(\\?|&)=:action\") {\n error 803 \"SSL is required\";\n }\n\n # If we're on the \/pypi page and we've received something other than a\n # GET or HEAD request, then we have no way to determine if a particular\n # request is an API call or not because it'll be in the request body\n # and that isn't available to us here. So in those cases, we won't\n # do a redirect.\n if (req.url ~ \"^\/pypi\") {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n error 801 \"Force SSL\";\n }\n }\n else {\n # This isn't a \/pypi URL so we'll just unconditionally redirect to\n # HTTPS.\n error 801 \"Force SSL\";\n }\n }\n\n # Redirect www.pypi.io and warehouse.python.org to pypi.io, this is\n # purposely done *after* the HTTPS checks.\n if (std.tolower(req.http.host) ~ \"^(www.pypi.io|warehouse.python.org)$\") {\n set req.http.Location = \"https:\/\/pypi.io\" req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n # Redirect warehouse-staging.python.org to test.pypi.io.\n if (std.tolower(req.http.host) == \"warehouse-staging.python.org\") {\n set req.http.Location = \"https:\/\/test.pypi.io\" req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n\n # Requests to \/packages\/ get dispatched to Amazon instead of to our typical\n # Origin. This requires a a bit of setup to make it work.\n if (req.http.host ~ \"^(test-)?files.pythonhosted.org$\"\n && req.url ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\") {\n # Setup our environment to better match what S3 expects\/needs\n set req.http.Host = req.http.AWS-Bucket-Name \".s3.amazonaws.com\";\n set req.http.Date = now;\n set req.url = regsuball(req.url, \"\\+\", urlencode(\"+\"));\n\n # Compute the Authorization header that S3 requires to be able to\n # access the files stored there.\n set req.http.Authorization = \"AWS \" req.http.AWS-Access-Key-ID \":\" digest.hmac_sha1_base64(req.http.AWS-Secret-Access-Key, \"GET\" LF LF LF req.http.Date LF \"\/\" req.http.AWS-Bucket-Name req.url.path);\n\n # We don't want to send our Warehouse-Token to S3, so we'll go ahead\n # and remove it.\n unset req.http.Warehouse-Token;\n }\n\n # We no longer need any of these variables, which would exist only to\n # shuffle configuration from the Fastly UI into our VCL.\n unset req.http.AWS-Access-Key-ID;\n unset req.http.AWS-Secret-Access-Key;\n unset req.http.AWS-Bucket-Name;\n\n # We have a number of items that we'll pass back to the origin, but only\n # if we have a Warehouse-Token that will allow them to be accepted.\n if (req.http.Warehouse-Token) {\n # Set a header to tell the backend if we're using https or http.\n if (req.http.Fastly-SSL) {\n set req.http.Warehouse-Proto = \"https\";\n } else {\n set req.http.Warehouse-Proto = \"http\";\n }\n\n # Pass the client IP address back to the backend.\n if (req.http.Fastly-Client-IP) {\n set req.http.Warehouse-IP = req.http.Fastly-Client-IP;\n }\n\n # Pass the real host value back to the backend.\n if (req.http.Host) {\n set req.http.Warehouse-Host = req.http.host;\n }\n }\n\n # On a POST, we want to skip the shielding and hit backends directly.\n if (req.request == \"POST\") {\n set req.backend = F_Heroku;\n }\n\n # Do not bother to attempt to run the caching mechanisms for methods that\n # are not generally safe to cache.\n if (req.request != \"HEAD\" &&\n req.request != \"GET\" &&\n req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n # We don't ever want to cache our health URL. Outside systems should be\n # able to use it to reach past Fastly and get an end to end health check.\n if (req.url == \"\/_health\/\") {\n return(pass);\n }\n\n # Finally, return the default lookup action.\n return(lookup);\n}\n\n\nsub vcl_fetch {\n\n # These are newer kinds of redirects which should be able to be cached by\n # default, even though Fastly doesn't currently have them in their default\n # list of cacheable status codes.\n if (http_status_matches(beresp.status, \"303,307,308\")) {\n set beresp.cacheable = true;\n }\n\n # For any 5xx status code we want to see if a stale object exists for it,\n # if so we'll go ahead and serve it.\n if (beresp.status >= 500 && beresp.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n\n#FASTLY fetch\n\n\n # Trigger a \"SSL is required\" error if the backend has indicated to do so.\n if (beresp.http.X-Fastly-Error == \"803\") {\n error 803 \"SSL is required\";\n }\n\n # If we've gotten a 502 or a 503 from the backend, we'll go ahead and retry\n # the request.\n if ((beresp.status == 502 || beresp.status == 503) &&\n req.restarts < 1 &&\n (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n # If we've restarted, then we'll record the number of restarts.\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n # If there is a Set-Cookie header, we'll ensure that we do not cache the\n # response.\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n # If the response has the private Cache-Control directive then we won't\n # cache it.\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # If we've gotten an error after the restarts we'll deliver the response\n # with a very short cache time.\n if (http_status_matches(beresp.status, \"500,502,503\")) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n # Apply a default TTL if there isn't a max-age or s-maxage.\n if (beresp.http.Expires ||\n beresp.http.Surrogate-Control ~ \"max-age\" ||\n beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # Keep the ttl here\n }\n else {\n # Apply the default ttl\n set beresp.ttl = 60s;\n }\n\n # Actually deliver the fetched response.\n return(deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n # If the object we have isn't cacheable, then just serve it directly\n # without going through any of the caching mechanisms.\n if (!obj.cacheable) {\n return(pass);\n }\n\n return(deliver);\n}\n\n\nsub vcl_deliver {\n # If this is an error and we have a stale response available, restart so\n # that we can pick it up and serve it.\n if (resp.status >= 500 && resp.status < 600) {\n if (stale.exists) {\n restart;\n }\n }\n\n#FASTLY deliver\n\n # Unset headers that we don't need\/want to send on to the client because\n # they are not generally useful.\n unset resp.http.Server;\n unset resp.http.Via;\n\n # Unset a few headers set by Amazon that we don't really have a need\/desire\n # to send to clients.\n unset resp.http.X-AMZ-Replication-Status;\n unset resp.http.X-AMZ-Meta-Python-Version;\n unset resp.http.X-AMZ-Meta-Version;\n unset resp.http.X-AMZ-Meta-Package-Type;\n unset resp.http.X-AMZ-Meta-Project;\n\n # Set our standard security headers, we do this in VCL rather than in\n # Warehouse itself so that we always get these headers, regardless of the\n # origin server being used.\n set resp.http.Strict-Transport-Security = \"max-age=31536000; includeSubDomains; preload\";\n set resp.http.X-Frame-Options = \"deny\";\n set resp.http.X-XSS-Protection = \"1; mode=block\";\n set resp.http.X-Content-Type-Options = \"nosniff\";\n set resp.http.X-Permitted-Cross-Domain-Policies = \"none\";\n\n return(deliver);\n}\n\n\nsub vcl_error {\n#FASTLY error\n\n # If we have a 5xx error and there is a stale object available, then we\n # will deliver that stale object.\n if (obj.status >= 500 && obj.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n if (obj.status == 803) {\n set obj.status = 403;\n set obj.response = \"SSL is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic {\"SSL is required.\"};\n return (deliver);\n } else if (obj.status == 750) {\n set obj.status = 301;\n set obj.http.Location = req.http.Location;\n set obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n synthetic {\"<html><head><title>301 Moved Permanently<\/title><\/head><body><center><h1>301 Moved Permanently<\/h1><\/center><\/body><\/html>\"};\n return(deliver);\n }\n\n}\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"3c33b93461793ad69c5a3aa644b44f3c64e07855","subject":"Forgot to change error -> synth here.","message":"Forgot to change error -> synth here.\n","repos":"franciscovg\/Varnish-Cache,varnish\/Varnish-Cache,gquintard\/Varnish-Cache,feld\/Varnish-Cache,mrhmouse\/Varnish-Cache,chrismoulton\/Varnish-Cache,zhoualbeart\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,franciscovg\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,mrhmouse\/Varnish-Cache,alarky\/varnish-cache-doc-ja,chrismoulton\/Varnish-Cache,gquintard\/Varnish-Cache,mrhmouse\/Varnish-Cache,alarky\/varnish-cache-doc-ja,zhoualbeart\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,alarky\/varnish-cache-doc-ja,gauthier-delacroix\/Varnish-Cache,chrismoulton\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,gquintard\/Varnish-Cache,zhoualbeart\/Varnish-Cache,chrismoulton\/Varnish-Cache,feld\/Varnish-Cache,alarky\/varnish-cache-doc-ja,varnish\/Varnish-Cache,mrhmouse\/Varnish-Cache,varnish\/Varnish-Cache,varnish\/Varnish-Cache,franciscovg\/Varnish-Cache,franciscovg\/Varnish-Cache,chrismoulton\/Varnish-Cache,alarky\/varnish-cache-doc-ja,franciscovg\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,mrhmouse\/Varnish-Cache,zhoualbeart\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,feld\/Varnish-Cache,gquintard\/Varnish-Cache,varnish\/Varnish-Cache,zhoualbeart\/Varnish-Cache,feld\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,feld\/Varnish-Cache","old_file":"bin\/varnishd\/builtin.vcl","new_file":"bin\/varnishd\/builtin.vcl","new_contents":"\/*-\n * Copyright (c) 2006 Verdens Gang AS\n * Copyright (c) 2006-2014 Varnish Software AS\n * All rights reserved.\n *\n * Author: Poul-Henning Kamp <phk@phk.freebsd.dk>\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in the\n * documentation and\/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n\n *\n * The built-in (previously called default) VCL code.\n *\n * NB! You do NOT need to copy & paste all of these functions into your\n * own vcl code, if you do not provide a definition of one of these\n * functions, the compiler will automatically fall back to the default\n * code from this file.\n *\n * This code will be prefixed with a backend declaration built from the\n * -b argument.\n *\/\n\nvcl 4.0;\n\n#######################################################################\n# Client side\n\nsub vcl_recv {\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization || req.http.Cookie) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n return (hash);\n}\n\nsub vcl_pipe {\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n # set bereq.http.connection = \"close\";\n # here. It is not set by default as it might break some broken web\n # applications, like IIS with NTLM authentication.\n return (pipe);\n}\n\nsub vcl_pass {\n return (fetch);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n return (lookup);\n}\n\nsub vcl_purge {\n return (synth(200, \"Purged\"));\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n \/\/ A pure unadultered hit, deliver it\n return (deliver);\n }\n if (obj.ttl + obj.grace > 0s) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n return (deliver);\n }\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\nsub vcl_miss {\n return (fetch);\n}\n\nsub vcl_deliver {\n \/*\n * These two write to the stored object causing extra page faults\n * Enable them only if you need them.\n *\n * set obj.hits = obj.hits + 1;\n * set obj.last_use = now;\n *\/\n return (deliver);\n}\n\n\/*\n * We can come here \"invisibly\" with the following errors: 413, 417 & 503\n *\/\nsub vcl_synth {\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n set resp.http.Retry-After = \"5\";\n synthetic( {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n return (deliver);\n}\n\n#######################################################################\n# Backend Fetch\n\nsub vcl_backend_fetch {\n return (fetch);\n}\n\nsub vcl_backend_response {\n if (beresp.ttl <= 0s ||\n beresp.http.Set-Cookie ||\n beresp.http.Surrogate-control ~ \"no-store\" ||\n (!beresp.http.Surrogate-Control &&\n beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n beresp.http.Vary == \"*\") {\n \/*\n * Mark as \"Hit-For-Pass\" for the next 2 minutes\n *\/\n set beresp.ttl = 120s;\n set beresp.uncacheable = true;\n }\n return (deliver);\n}\n\nsub vcl_backend_error {\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} + beresp.status + \" \" + beresp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + beresp.status + \" \" + beresp.reason + {\"<\/h1>\n <p>\"} + beresp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + bereq.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n return (deliver);\n}\n\n#######################################################################\n# Housekeeping\n\nsub vcl_init {\n return (ok);\n}\n\nsub vcl_fini {\n return (ok);\n}\n","old_contents":"\/*-\n * Copyright (c) 2006 Verdens Gang AS\n * Copyright (c) 2006-2014 Varnish Software AS\n * All rights reserved.\n *\n * Author: Poul-Henning Kamp <phk@phk.freebsd.dk>\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in the\n * documentation and\/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n\n *\n * The built-in (previously called default) VCL code.\n *\n * NB! You do NOT need to copy & paste all of these functions into your\n * own vcl code, if you do not provide a definition of one of these\n * functions, the compiler will automatically fall back to the default\n * code from this file.\n *\n * This code will be prefixed with a backend declaration built from the\n * -b argument.\n *\/\n\nvcl 4.0;\n\n#######################################################################\n# Client side\n\nsub vcl_recv {\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization || req.http.Cookie) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n return (hash);\n}\n\nsub vcl_pipe {\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n # set bereq.http.connection = \"close\";\n # here. It is not set by default as it might break some broken web\n # applications, like IIS with NTLM authentication.\n return (pipe);\n}\n\nsub vcl_pass {\n return (fetch);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n return (lookup);\n}\n\nsub vcl_purge {\n return (error(200, \"Purged\"));\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n \/\/ A pure unadultered hit, deliver it\n return (deliver);\n }\n if (obj.ttl + obj.grace > 0s) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n return (deliver);\n }\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\nsub vcl_miss {\n return (fetch);\n}\n\nsub vcl_deliver {\n \/*\n * These two write to the stored object causing extra page faults\n * Enable them only if you need them.\n *\n * set obj.hits = obj.hits + 1;\n * set obj.last_use = now;\n *\/\n return (deliver);\n}\n\n\/*\n * We can come here \"invisibly\" with the following errors: 413, 417 & 503\n *\/\nsub vcl_synth {\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n set resp.http.Retry-After = \"5\";\n synthetic( {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n return (deliver);\n}\n\n#######################################################################\n# Backend Fetch\n\nsub vcl_backend_fetch {\n return (fetch);\n}\n\nsub vcl_backend_response {\n if (beresp.ttl <= 0s ||\n beresp.http.Set-Cookie ||\n beresp.http.Surrogate-control ~ \"no-store\" ||\n (!beresp.http.Surrogate-Control &&\n beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n beresp.http.Vary == \"*\") {\n \/*\n * Mark as \"Hit-For-Pass\" for the next 2 minutes\n *\/\n set beresp.ttl = 120s;\n set beresp.uncacheable = true;\n }\n return (deliver);\n}\n\nsub vcl_backend_error {\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} + beresp.status + \" \" + beresp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + beresp.status + \" \" + beresp.reason + {\"<\/h1>\n <p>\"} + beresp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + bereq.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n return (deliver);\n}\n\n#######################################################################\n# Housekeeping\n\nsub vcl_init {\n return (ok);\n}\n\nsub vcl_fini {\n return (ok);\n}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"553cd8b3fc14bfa1c744273f5a6f182fc16d04da","subject":"VCL doesn't allow string concatenation in an error throw","message":"VCL doesn't allow string concatenation in an error throw\n","repos":"wlonk\/warehouse,karan\/warehouse,alex\/warehouse,dstufft\/warehouse,pypa\/warehouse,karan\/warehouse,pypa\/warehouse,dstufft\/warehouse,pypa\/warehouse,pypa\/warehouse,alex\/warehouse,dstufft\/warehouse,karan\/warehouse,karan\/warehouse,wlonk\/warehouse,alex\/warehouse,dstufft\/warehouse,karan\/warehouse,alex\/warehouse,wlonk\/warehouse,alex\/warehouse","old_file":"vcl\/main.vcl","new_file":"vcl\/main.vcl","new_contents":"\nsub vcl_recv {\n#FASTLY recv\n\n # We want to Force SSL for the WebUI by redirecting to the HTTPS version of\n # the page, however for API calls we want to return an error code directing\n # people to instead use HTTPS.\n if (!req.http.Fastly-SSL) {\n\n # The \/simple\/ and \/packages\/ API.\n if (req.url ~ \"^\/(simple|packages)\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy JSON API.\n if (req.url ~ \"^\/pypi\/.+\/json$\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy ?:action= API.\n if (req.url ~ \"^\/pypi.*(\\?|&)=:action\") {\n error 803 \"SSL is required\";\n }\n\n # If we're on the \/pypi page and we've received something other than a\n # GET or HEAD request, then we have no way to determine if a particular\n # request is an API call or not because it'll be in the request body\n # and that isn't available to us here. So in those cases, we won't\n # do a redirect.\n if (req.url ~ \"^\/pypi\") {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n error 801 \"Force SSL\";\n }\n }\n else {\n # This isn't a \/pypi URL so we'll just unconditionally redirect to\n # HTTPS.\n error 801 \"Force SSL\";\n }\n }\n\n # Canonicalize our domains by redirecting any domain that doesn't match our\n # primary domain to our primary domain. We do this *after* the HTTPS check\n # on purpose.\n if (std.tolower(req.http.host) != std.tolower(req.http.Primary-Domain)) {\n set req.http.Location = \"https:\/\/\" req.http.Primary-Domain req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n\n # Set a header to tell the backend if we're using https or http.\n if (req.http.Fastly-SSL) {\n set req.http.Warehouse-Proto = \"https\";\n } else {\n set req.http.Warehouse-Proto = \"http\";\n }\n\n # Pass the client IP address back to the backend.\n if (req.http.Fastly-Client-IP) {\n set req.http.Warehouse-IP = req.http.Fastly-Client-IP;\n }\n\n # Pass the real host value back to the backend.\n if (req.http.Host) {\n set req.http.Warehouse-Host = req.http.Host;\n }\n\n # Do not bother to attempt to run the caching mechanisms for methods that\n # are not generally safe to cache.\n if (req.request != \"HEAD\" &&\n req.request != \"GET\" &&\n req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n # Finally, return the default lookup action.\n return(lookup);\n}\n\n\nsub vcl_fetch {\n#FASTLY fetch\n\n # Trigger a \"SSL is required\" error if the backend has indicated to do so.\n if (beresp.http.X-Fastly-Error == \"803\") {\n error 803 \"SSL is required\";\n }\n\n # If we've gotten a 502 or a 503 from the backend, we'll go ahead and retry\n # the request.\n if ((beresp.status == 502 || beresp.status == 503) &&\n req.restarts < 1 &&\n (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n # If we've restarted, then we'll record the number of restarts.\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n # If there is a Set-Cookie header, we'll ensure that we do not cache the\n # response.\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n # If the response has the private Cache-Control directive then we won't\n # cache it.\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # If we've gotten an error after the restarts we'll deliver the response\n # with a very short cache time.\n if (beresp.status == 500 || beresp.status == 503) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n # Apply a default TTL if there isn't a max-age or s-maxage.\n if (beresp.http.Expires ||\n beresp.http.Surrogate-Control ~ \"max-age\" ||\n beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # Keep the ttl here\n }\n else {\n # Apply the default ttl\n set beresp.ttl = 60s;\n }\n\n # Actually deliver the fetched response.\n return(deliver);\n}\n\n\nsub vcl_deliver {\n#FASTLY deliver\n\n # Unset headers that we don't need\/want to send on to the client because\n # they are not generally useful.\n unset resp.http.Server;\n unset resp.http.Via;\n\n # Set our standard security headers, we do this in VCL rather than in\n # Warehouse itself so that we always get these headers, regardless of the\n # origin server being used.\n set resp.http.Strict-Transport-Security = \"max-age=31536000; includeSubDomains; preload\";\n set resp.http.X-Frame-Options = \"deny\";\n set resp.http.X-XSS-Protection = \"1; mode=block\";\n set resp.http.X-Content-Type-Options = \"nosniff\";\n set resp.http.X-Permitted-Cross-Domain-Policies = \"none\";\n\n return(deliver);\n}\n\n\nsub vcl_error {\n#FASTLY error\n\n if (obj.status == 803) {\n set obj.status = 403;\n set obj.response = \"SSL is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic {\"SSL is required.\"};\n return (deliver);\n } else if (obj.status == 750) {\n set obj.status = 301;\n set obj.http.Location = req.http.Location;\n set obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n synthetic {\"<html><head><title>301 Moved Permanently<\/title><\/head><body><center><h1>301 Moved Permanently<\/h1><\/center><\/body><\/html>\"};\n return(deliver);\n }\n\n}\n","old_contents":"\nsub vcl_recv {\n#FASTLY recv\n\n # We want to Force SSL for the WebUI by redirecting to the HTTPS version of\n # the page, however for API calls we want to return an error code directing\n # people to instead use HTTPS.\n if (!req.http.Fastly-SSL) {\n\n # The \/simple\/ and \/packages\/ API.\n if (req.url ~ \"^\/(simple|packages)\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy JSON API.\n if (req.url ~ \"^\/pypi\/.+\/json$\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy ?:action= API.\n if (req.url ~ \"^\/pypi.*(\\?|&)=:action\") {\n error 803 \"SSL is required\";\n }\n\n # If we're on the \/pypi page and we've received something other than a\n # GET or HEAD request, then we have no way to determine if a particular\n # request is an API call or not because it'll be in the request body\n # and that isn't available to us here. So in those cases, we won't\n # do a redirect.\n if (req.url ~ \"^\/pypi\") {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n error 801 \"Force SSL\";\n }\n }\n else {\n # This isn't a \/pypi URL so we'll just unconditionally redirect to\n # HTTPS.\n error 801 \"Force SSL\";\n }\n }\n\n # Canonicalize our domains by redirecting any domain that doesn't match our\n # primary domain to our primary domain. We do this *after* the HTTPS check\n # on purpose.\n if (std.tolower(req.http.host) != std.tolower(req.http.Primary-Domain)) {\n error 750 \"https:\/\/\" req.http.Primary-Domain req.url;\n }\n\n # Set a header to tell the backend if we're using https or http.\n if (req.http.Fastly-SSL) {\n set req.http.Warehouse-Proto = \"https\";\n } else {\n set req.http.Warehouse-Proto = \"http\";\n }\n\n # Pass the client IP address back to the backend.\n if (req.http.Fastly-Client-IP) {\n set req.http.Warehouse-IP = req.http.Fastly-Client-IP;\n }\n\n # Pass the real host value back to the backend.\n if (req.http.Host) {\n set req.http.Warehouse-Host = req.http.Host;\n }\n\n # Do not bother to attempt to run the caching mechanisms for methods that\n # are not generally safe to cache.\n if (req.request != \"HEAD\" &&\n req.request != \"GET\" &&\n req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n # Finally, return the default lookup action.\n return(lookup);\n}\n\n\nsub vcl_fetch {\n#FASTLY fetch\n\n # Trigger a \"SSL is required\" error if the backend has indicated to do so.\n if (beresp.http.X-Fastly-Error == \"803\") {\n error 803 \"SSL is required\";\n }\n\n # If we've gotten a 502 or a 503 from the backend, we'll go ahead and retry\n # the request.\n if ((beresp.status == 502 || beresp.status == 503) &&\n req.restarts < 1 &&\n (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n # If we've restarted, then we'll record the number of restarts.\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n # If there is a Set-Cookie header, we'll ensure that we do not cache the\n # response.\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n # If the response has the private Cache-Control directive then we won't\n # cache it.\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # If we've gotten an error after the restarts we'll deliver the response\n # with a very short cache time.\n if (beresp.status == 500 || beresp.status == 503) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n # Apply a default TTL if there isn't a max-age or s-maxage.\n if (beresp.http.Expires ||\n beresp.http.Surrogate-Control ~ \"max-age\" ||\n beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # Keep the ttl here\n }\n else {\n # Apply the default ttl\n set beresp.ttl = 60s;\n }\n\n # Actually deliver the fetched response.\n return(deliver);\n}\n\n\nsub vcl_deliver {\n#FASTLY deliver\n\n # Unset headers that we don't need\/want to send on to the client because\n # they are not generally useful.\n unset resp.http.Server;\n unset resp.http.Via;\n\n # Set our standard security headers, we do this in VCL rather than in\n # Warehouse itself so that we always get these headers, regardless of the\n # origin server being used.\n set resp.http.Strict-Transport-Security = \"max-age=31536000; includeSubDomains; preload\";\n set resp.http.X-Frame-Options = \"deny\";\n set resp.http.X-XSS-Protection = \"1; mode=block\";\n set resp.http.X-Content-Type-Options = \"nosniff\";\n set resp.http.X-Permitted-Cross-Domain-Policies = \"none\";\n\n return(deliver);\n}\n\n\nsub vcl_error {\n#FASTLY error\n\n if (obj.status == 803) {\n set obj.status = 403;\n set obj.response = \"SSL is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic {\"SSL is required.\"};\n return (deliver);\n } else if (obj.status == 750) {\n set obj.status = 301;\n set obj.http.Location = obj.response;\n set obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n synthetic {\"<html><head><title>301 Moved Permanently<\/title><\/head><body><center><h1>301 Moved Permanently<\/h1><\/center><\/body><\/html>\"};\n return(deliver);\n }\n\n}\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"3810097dcd4ece7abcc8a663ed7a8aba757e5441","subject":"Longer caching of most successful GET requests","message":"Longer caching of most successful GET requests\n","repos":"alexanderlaw\/sqlfiddle2,alexanderlaw\/sqlfiddle2,alexanderlaw\/sqlfiddle2,jakefeasel\/sqlfiddle2,jakefeasel\/sqlfiddle2,alexanderlaw\/sqlfiddle2,alexanderlaw\/sqlfiddle2,jakefeasel\/sqlfiddle2,jakefeasel\/sqlfiddle2","old_file":"src\/main\/resources\/varnish\/default.vcl","new_file":"src\/main\/resources\/varnish\/default.vcl","new_contents":"backend default {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\n\n sub vcl_recv {\n\n if (! (req.url ~ \"^\/openidm\/\") ) {\n set req.url = regsub(req.url, \"^\/\", \"\/sqlfiddle\/\");\n }\n\n if ( req.url == \"\/sqlfiddle\/\") {\n set req.url = \"\/sqlfiddle\/index.html\"; \n }\n\n if (req.request == \"GET\" && req.url != \"\/openidm\/info\/login\") {\n unset req.http.cookie;\n }\n\n }\n\nsub vcl_fetch {\n if (req.request == \"GET\" && req.url != \"\/openidm\/info\/login\") {\n set beresp.ttl = 3600s;\n }\n if (beresp.status != 200) {\n set beresp.ttl = 0s;\n }\n}\n","old_contents":"backend default {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\n\n sub vcl_recv {\n\n if (! (req.url ~ \"^\/openidm\/\") ) {\n set req.url = regsub(req.url, \"^\/\", \"\/sqlfiddle\/\");\n }\n\n if ( req.url == \"\/sqlfiddle\/\") {\n set req.url = \"\/sqlfiddle\/index.html\"; \n }\n\n if (req.request == \"GET\" && req.url != \"\/openidm\/info\/login\") {\n unset req.http.cookie;\n }\n\n }","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"05eee383a6a3a04fb66165d794a0da9b6cffcbad","subject":"set the backend_hint to the www_dir backend; the dynamic one.","message":"set the backend_hint to the www_dir backend; the dynamic one.\n","repos":"amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon","old_file":"images\/varnish\/default.vcl","new_file":"images\/varnish\/default.vcl","new_contents":"#\n# This is an example VCL file for Varnish.\n#\n# It does not do anything by default, delegating control to the\n# builtin VCL. The builtin VCL is called when there is no explicit\n# return statement.\n#\n# See the VCL chapters in the Users Guide at https:\/\/www.varnish-cache.org\/docs\/\n# and https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExamples for more examples.\n\nvcl 4.0;\n\nimport std;\nimport dynamic;\n\n# set backend default\nbackend default {\n .host = \"${VARNISH_BACKEND_HOST:-nginx}\";\n .port = \"${VARNISH_BACKEND_PORT:-8080}\";\n .first_byte_timeout = 35m;\n .between_bytes_timeout = 10m;\n}\n\nsub vcl_init {\n new www_dir = dynamic.director(\n port = \"${VARNISH_BACKEND_PORT:-8080}\",\n first_byte_timeout = 90s,\n between_bytes_timeout = 90s,\n ttl = 60s);\n }\n\nsub vcl_recv {\n # Happens before we check if we have this in cache already.\n #\n # Typically you clean up the request here, removing cookies you don't need,\n # rewriting the request, etc.\n\n # set the backend, which should be used:\n set req.backend_hint = www_dir.backend(\"${VARNISH_BACKEND_HOST:-nginx}\");\n\n # Needed for Readyness and Liveness checks - do not remove\n if (req.url ~ \"^\/varnish_status$\") {\n return (synth(200,\"OK\"));\n }\n\n}\n\nsub vcl_backend_response {\n # Happens after we have read the response headers from the backend.\n #\n # Here you clean the response headers, removing silly Set-Cookie headers\n # and other mistakes your backend does.\n}\n\nsub vcl_deliver {\n # Happens when we have all the pieces we need, and are about to send the\n # response to the client.\n #\n # You can do accounting or modifying the final object here.\n}\n","old_contents":"#\n# This is an example VCL file for Varnish.\n#\n# It does not do anything by default, delegating control to the\n# builtin VCL. The builtin VCL is called when there is no explicit\n# return statement.\n#\n# See the VCL chapters in the Users Guide at https:\/\/www.varnish-cache.org\/docs\/\n# and https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExamples for more examples.\n\nvcl 4.0;\n\nimport std;\nimport dynamic;\n\n# set backend default\nbackend default {\n .host = \"${VARNISH_BACKEND_HOST:-nginx}\";\n .port = \"${VARNISH_BACKEND_PORT:-8080}\";\n .first_byte_timeout = 35m;\n .between_bytes_timeout = 10m;\n}\n\nsub vcl_init {\n new www_dir = dynamic.director(\n port = \"${VARNISH_BACKEND_PORT:-8080}\",\n first_byte_timeout = 90s,\n between_bytes_timeout = 90s,\n ttl = 60s);\n }\n\nsub vcl_recv {\n # Happens before we check if we have this in cache already.\n #\n # Typically you clean up the request here, removing cookies you don't need,\n # rewriting the request, etc.\n\n # set the backend, which should be used:\n set req.backend_hint = default;\n\n # Needed for Readyness and Liveness checks - do not remove\n if (req.url ~ \"^\/varnish_status$\") {\n return (synth(200,\"OK\"));\n }\n\n}\n\nsub vcl_backend_response {\n # Happens after we have read the response headers from the backend.\n #\n # Here you clean the response headers, removing silly Set-Cookie headers\n # and other mistakes your backend does.\n}\n\nsub vcl_deliver {\n # Happens when we have all the pieces we need, and are about to send the\n # response to the client.\n #\n # You can do accounting or modifying the final object here.\n}\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"106b27719d4c72d103a21e0f2ab75587e6d25e66","subject":"improve grace comments and debug headers","message":"improve grace comments and debug headers\n","repos":"NITEMAN\/Varnish_VCL_samps-hacks,NITEMAN\/varnish-bites","old_file":"varnish4\/drupal-base.vcl","new_file":"varnish4\/drupal-base.vcl","new_contents":"\/* Varnish 4 example config for Drupal 7 \/ Pressflow 6 & 7 *\/\n# Original source: https:\/\/github.com\/NITEMAN\/varnish-bites\/varnish4\/drupal-base.vcl\n# Copyright (c) 2015 Pedro Gonz\u00e1lez Serrano and individual contributors.\n# MIT License\n\n# Intended to be used both in simple production environments and with\n# learning\/teaching purposes.\n# Some references may not be yet updated to VCL 4.0, we use SeeV3 then.\n\n# WARNING:\n# Note that the built-in logic will be appended to our code if no return is performed before.\n# Built-in logic is included commented out right after our's for reference purposes in that cases.\n# See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleDefault\n\n#######################################################################\n# Initialization: Version & imports;\n\n\/* Version statement *\/\n# Since Varnish 4.0 it's mandatory to declare VCL version on first line.\nvcl 4.0;\n\n\/* Module (VMOD) imports *\/\n# Standard module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_std.generated.html\nimport std;\n\n# Directors module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# Unused in simple configs.\n#import directors;\n\n\n#######################################################################\n# Probe, backend, ACL and subroutine definitions\n\n\/* Backend probes \/ healthchecks *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#probes\nprobe basic {\n \/* Only test that backend's IP serves content for '\/' *\/\n # This might be a too heavy probe\n # .url = \"\/\";\n \/* Only test that backend's IP has apache working *\/\n # Nginx would fail this probe with a default config\n .request =\n \"OPTIONS * HTTP\/1.1\"\n \"Host: *\"\n \"Connection: close\";\n .interval = 10s;\n .timeout = 2s;\n .window = 8;\n .threshold = 6;\n}\n\n\/* Backend definitions.*\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#backend-definition\nbackend default {\n \/* Default backend on the same machine. WARNING: timeouts could be not big enought for certain POST request *\/\n .host = \"127.0.0.1\";\n .port = \"8008\";\n .max_connections = 100;\n .connect_timeout = 60s;\n .first_byte_timeout = 60s;\n .between_bytes_timeout = 60s;\n .probe = basic;\n}\n\n\/* Access Control Lists *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#access-control-list-acl\nacl purge_ban {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use '\"localhost\";' instead\n}\nacl allowed_monitors {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n}\n#acl own_proxys {\n# \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n#}\n\n\/* Custom subroutines *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#subroutines\n#TODO# Test in Varnihs 4\n# Empty in simple configs.\n# We can name subs with no restrictions but as a task can need several chunks of code in diferent states,\n# it's a good idea to identify what main sub will call each with a suffix.\n# \/* Example 301 client redirection removing \"www\" prefix from request *\/\n# sub perm_redirections_recv {\n# if ( req.http.host ~ \"^www.*$\" ) {\n# return(synth(751, \"http:\/\/\" + regsub(req.http.host, \"^www\\.\", \"\") + req.url));\n# }\n# }\n# sub perm_redirections_synth {\n# if (resp.status == 751) {\n# \/* Get new URL from the response *\/\n# set resp.http.Location = resp.response;\n# \/* Set HTTP 301 for permanent redirect *\/\n# set resp.status = 301;\n# return (deliver);\n# }\n# }\n\n\n#######################################################################\n# Client side\n\n# vcl_recv: Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-recv\nsub vcl_recv {\n \/* 0th: general bypass, general return & authorization checks *\/\n # Empty in simple configs.\n # Useful for debugging we can pipe or pass the request to default backend here to bypass completely Varnish.\n # return (pipe);\n # return (pass);\n # We can also return here a 200 Ok for network performance benchmarking.\n # return(synth(200, \"Ok\"));\n # Finally we can perform basic HTTP authentification here, by example.\n # SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* 1st: Check for Varnish special requests *\/ \n # Custom response implementation example in order to check that Varnish is working properly.\n # This is usefull for automatic monitoring with monit or when Varnish is behind another proxies like HAProxy.\n if ( ( req.http.host == \"monitor.server.health\"\n || req.http.host == \"health.varnish\" )\n && client.ip ~ allowed_monitors\n && ( req.method == \"OPTIONS\" || req.method == \"GET\" )\n ) {\n return(synth(200, \"Ban added\"));\n }\n # Purge logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#http-purging\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if (req.method == \"PURGE\") {\n if (!client.ip ~ purge_ban) {\n return(synth(405, \"Not allowed.\"));\n }\n return (purge);\n }\n # Ban logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#bans\n if (req.method == \"BAN\") {\n if (!client.ip ~ purge_ban) {\n return(synth(405, \"Not allowed.\"));\n }\n ban(\"req.http.host == \" + req.http.host +\n \"&& req.url == \" + req.url); \n return(synth(200, \"Ban added\"));\n }\n\n \/* 2nd: Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_recv;\n # Here we can also enforce SSL when Varnish run behind some SSL termination point.\n\n \/* 3rd: Time for backend choice *\/\n # Empty in simple configs.\n\n \/* 4th: Prepare headers for the backend *\/\n # Empty in simple configs.\n # Example remove own_proxys from X-Forwarded-For\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/whats-new\/upgrading.html#x-forwarded-for-is-now-set-before-vcl-recv\n # if ( req.restarts == 0\n # && client.ip ~ own_proxys\n # && req.http.x-forwarded-for\n # ) {\n # set req.http.X-Forwarded-For = regsub(req.http.X-Forwarded-For, \",( )?\" + client.ip, \"\");\n # }\n\n \/* 5th: Bypass breakpoint 1 *\/\n # Useful for debugging we can now pipe or pass the request to backend with headers setted.\n # return (pipe);\n # return (pass);\n\n \/* 6th: Decide if we should deal with a request (mostly copied from built-in logic) *\/\n if (req.method == \"PRI\") {\n \/* We do not support SPDY or HTTP\/2.0 *\/\n return (synth(405));\n }\n if ( req.method != \"GET\"\n && req.method != \"HEAD\"\n && req.method != \"PUT\"\n && req.method != \"POST\"\n && req.method != \"TRACE\"\n && req.method != \"OPTIONS\"\n && req.method != \"DELETE\"\n ) {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n\n \/* 7th: Access control for some URLs by ACL *\/\n # Empty in simple configs.\n # By example denial some URLs depending on client-ip, we'll need to define corresponding ACL 'internal'.\n # if ( req.url ~ \"^\/(cron|install)\\.php\"\n # && ! client.ip ~ internal\n # ) {\n # # Have Varnish throw the error directly.\n # return(synth(403, \"Forbidden.\"));\n # # Use a custom error page that you've defined in Drupal at the path \"404\".\n # # set req.url = \"\/403\";\n # }\n\n \/* 8th: Custom exceptions *\/\n # Host exception example:\n # if (req.http.host == \"ejemplo.exception.com\") {\n # return (pass);\n # }\n # Drupal exceptions, edit if we want to cache some AJAX\/AHAH request.\n # Add here filters for never cache URLs such as Payment Gateway's callbacks\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/ooyala\/ping$\" ||\n req.url ~ \"^\/admin\/build\/features\" ||\n req.url ~ \"^\/info\/.*$\" ||\n req.url ~ \"^\/flag\/.*$\" ||\n req.url ~ \"^.*\/ajax\/.*$\" ||\n req.url ~ \"^.*\/ahah\/.*$\") {\n \/* Do not cache these paths *\/\n return (pass);\n }\n # Pipe these paths directly to backend for streaming.\n if (req.url ~ \"^\/admin\/content\/backup_migrate\/export\") {\n return (pipe);\n }\n if (req.url ~ \"^\/system\/files\") {\n return (pipe);\n }\n\n \/* 9th: Graced objets & Serve from anonymous cahe if all backends are down *\/\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n # set req.http.grace = \"none\";\n if (! std.healthy(req.backend_hint) ) {\n # We must do this here since cookie hashing\n unset req.http.Cookie;\n #TODO# Add sick marker\n } \n\n \/* 10th: Deal with compression and the Accept-Encoding header *\/\n # Althought Varnish 3 handles gziped content itself by default, just to be sure we want to \n # remove Accept-Encoding for some compressed formats.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html#what-does-http-gzip-support-do\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/varnishd.html?highlight=http_gzip_support\n # See (for older configs) https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleNormalizeAcceptEncoding\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|mp4|flv|zip|rar)$\") {\n \/* Already compressed formats, no sense trying to compress again *\/\n unset req.http.Accept-Encoding;\n }\n }\n\n \/* 11th: Another header manipulation *\/\n # Empty in simple configs.\n # We could add here a custom header grouping User-agent families.\n\n \/* 12th: Cookie removal *\/\n # Always cache the following static file types for all users. \n # Use with care if we control certain downloads depending on cookies. \n # Be carefull also if appending .htm[l] via Drupal's clean URLs.\n if ( req.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|woff2|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n && req.url !~ \"\/system\/storage\/serve\"\n ) {\n unset req.http.Cookie;\n }\n # Remove all cookies that backend doesn't need to know about.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRemovingSomeCookies\n if (req.http.Cookie) {\n \/* Warning: Not a pretty solution *\/\n \/* Prefix header containing cookies with ';' *\/\n set req.http.Cookie = \";\" + req.http.Cookie;\n \/* Remove any spaces after ';' in header containing cookies *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n \/* Prefix cookies we want to preserve with one space *\/\n \/* 'S{1,2}ESS[a-z0-9]+' is the regular expression matching a Drupal session cookie ({1,2} added for HTTPS support) *\/\n \/* 'NO_CACHE' is usually set after a POST request to make sure issuing user see the results of his post *\/\n \/* 'OATMEAL' & 'CHOCOLATECHIP' are special cookies used by Drupal's Bakery module to provide Single Sign On *\/\n \/* Keep in mind we should add here any cookie that should reach the backend such as splahs avoiding cookies *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \";(S{1,2}ESS[a-z0-9]+|NO_CACHE|OATMEAL|CHOCOLATECHIP)=\", \"; \\1=\");\n \/* Remove from the header any single Cookie not prefixed with a space until next ';' separator *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n \/* Remove any '; ' at the start or the end of the header *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n\n if (req.http.Cookie == \"\") {\n \/* If there are no remaining cookies, remove the cookie header. *\/\n unset req.http.Cookie;\n }\n }\n\n \/* 13th: Session cookie & special cookies bypass caching stage *\/\n # As we might want to cache some requests, hashed with its cookies, \n # we don't simply pass when some cookies remain present at this point.\n # Instead we look for request that must be passed due to the cookie header.\n if ( req.http.Cookie ~ \"SESS\"\n || req.http.Cookie ~ \"SSESS\"\n || req.http.Cookie ~ \"NO_CACHE\"\n || req.http.Cookie ~ \"OATMEAL\"\n || req.http.Cookie ~ \"CHOCOLATECHIP\"\n ) {\n return (pass);\n }\n\n \/* 14th: Bypass breakpoint 2 *\/\n # Useful for debugging we can now pipe or pass the request to backend to bypass cache.\n # return (pipe);\n # return (pass);\n\n \/* 15th: Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning inconditionally.\n return (hash);\n}\n\n# vcl_pipe: Called upon entering pipe mode.\n# In this mode, the request is passed on to the backend, \n# and any further data from either client or backend is passed on unaltered until either end closes the connection.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pipe\n# sub vcl_pipe {\n# # By default Connection: close is set on all piped requests, to stop\n# # connection reuse from sending future requests directly to the\n# # (potentially) wrong backend. If you do want this to happen, you can undo\n# # it here.\n# # unset bereq.http.connection;\n# return (pipe);\n# }\n\n# vcl_pass: Called upon entering pass mode. \n# In this mode, the request is passed on to the backend, and the backend's response is passed on to the client, \n# but is not entered into the cache.\n# Subsequent requests submitted over the same client connection are handled normally.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pass\n# sub vcl_pass {\n# return (fetch);\n# }\n\n# vcl_hash: You may call hash_data() on the data you would like to add to the hash.\n# Hash is used by Varnish to uniquely identify objects.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hash\nsub vcl_hash {\n \/* Hash cookie data *\/\n # As requests with same URL and host can produce diferent results when issued with different cookies,\n # we need to store items hashed with the associated cookies. Note that cookies are already sanitized when we reach this point.\n if (req.http.Cookie) {\n \/* Include cookie in cache hash *\/\n hash_data(req.http.Cookie);\n }\n\n \/* Custom header hashing *\/\n # Empty in simple configs.\n # Example for caching differents object versions by device previously detected (when static content could also vary):\n # if (req.http.X-UA-Device) {\n # hash_data(req.http.X-UA-Device);\n # }\n # Example for caching diferent object versions by X-Forwarded-Proto, trying to be smart about what kind of request\n # could generate diffetent responses.\n if ( req.http.X-Forwarded-Proto\n && req.url !~ \"(?i)\\.(png|gif|jpeg|jpg|ico|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|woff2|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\") {\n hash_data(req.http.X-Forwarded-Proto);\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (lookup);\n# }\n\n# vcl_purge: Called after the purge has been executed and all its variants have been evited.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-purge\n# sub vcl_purge {\n# return (synth(200, \"Purged\"));\n# }\n\n# vcl_hit: Called after a cache lookup if the requested document was found in the cache.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hit\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n \/\/ A pure unadultered hit, deliver it\n return (deliver);\n }\n \/* Allow varnish to serve up stale content if it is responding slowly *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n if (obj.ttl + 60s > 0s) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n set req.http.grace = \"normal\";\n return (deliver);\n }\n \/* Allow varish to serve up stale content if all backends are down *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n if ( ! std.healthy(req.backend_hint)\n && obj.ttl + obj.grace > 0s\n ) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n set req.http.grace = \"extended\";\n return (deliver);\n }\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning inconditionally.\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\n# vcl_miss: Called after a cache lookup if the requested document was not found in the cache.\n# Its purpose is to decide whether or not to attempt to retrieve the document from the backend, and which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-miss\n# sub vcl_miss {\n# return (fetch);\n# }\n\n# vcl_deliver: Called before an object is delivered to the client\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-deliver\nsub vcl_deliver {\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # Add whether the object is a cache hit or miss and the number of hits for the object.\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Addingaheaderindicatinghitmiss\n # In Varnish 4 the obj.hits counter behaviour has changed (see bug 1492), so\n # we use a different method: if X-Varnish contains only 1 id, we have a miss,\n # if it contains more (and therefore a space), we have a hit.\n if (resp.http.x-varnish ~ \" \") {\n set resp.http.X-Cache = \"HIT\";\n # Since in Varnish 4 the behaviour of obj.hits changed, this might not be accurate\n # See https:\/\/www.varnish-cache.org\/trac\/ticket\/1492\n set resp.http.X-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Cache = \"MISS\";\n \/* Show the results of cookie sanitization *\/\n set resp.http.X-Cookie = req.http.Cookie;\n }\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n set resp.http.grace = req.http.grace;\n\n #TODO# Add sick marker\n\n # Restart count\n if ( req.restarts > 0) {\n set resp.http.X-Restarts = req.restarts;\n }\n\n # Add the Varnish server hostname\n set resp.http.X-Varnish-Server = server.hostname;\n # If we have setted a custom header with device family detected we can show it:\n # if (req.http.X-UA-Device) {\n # set resp.http.X-UA-Device = req.http.X-UA-Device;\n # }\n # If we have recived a custom header with the protocol in the request we can show it:\n # if (req.http.X-Forwarded-Proto) {\n # set resp.http.X-Forwarded-Proto = req.http.X-Forwarded-Proto;\n # }\n\n \/* Vary header manipulation *\/\n # Empty in simple configs.\n # By example, if we are storing & serving diferent objects depending on User-Agent header we must set the correct Vary header:\n # if (resp.http.Vary) {\n # set resp.http.Vary = resp.http.Vary + \",User-Agent\";\n # } else {\n # set resp.http.Vary = \"User-Agent\";\n # }\n\n \/* Fake headers *\/\n # Empty in simple configs\n # We can fake server headers here, by example:\n # set resp.http.Server = \"Deep thought\";\n # set resp.http.X-Powered-By = \"BOFH\";\n # Or have some fun with headers:\n # See http:\/\/www.nextthing.org\/archives\/2005\/08\/07\/fun-with-http-headers\n # See http:\/\/royal.pingdom.com\/2012\/08\/15\/fun-and-unusual-http-response-headers\/\n # set resp.http.X-Thank-You = \"for bothering to look at my HTTP headers\";\n # set resp.http.X-Answer = \"42\";\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_deliver {\n# return (deliver);\n# }\n\n# vcl_synth: Called to deliver a synthetic object. A synthetic object is generated in VCL,\n# not fetched from the backend. It is typically contructed using the synthetic() function.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-synth\n\/*\n * We can come here \"invisibly\" with the following errors: 413, 417 & 503\n *\/\nsub vcl_synth {\n \/* Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_synth;\n\n \/* Try to restart request in case of failure *\/\n # Note that max_restarts defaults to 4\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if (resp.status == 503 && req.restarts < 4) {\n return(restart);\n }\n\n \/* Set common headers for synthetic responses *\/\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n\n \/* HTTP Authentification client request *\/\n # Empty in simple configs. SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* Load synthetic responses from disk *\/\n # Note that files loaded this way are never re-readed (even after a reload).\n # You should consider PROS\/CONS of doing an include instead.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_std.generated.html#func-fileread\n # Example custom 403 error page.\n # if (resp.status == 403) {\n # synthetic(std.fileread(\"\/403.html\"));\n # return(deliver);\n # }\n\n \/* Error page & refresh \/ redirections *\/\n # We have plenty of choices when we have to serve an error to the client, \n # from the default error page to javascript black magic or plain redirections.\n # Adding some external statistic javascript to track failures served to clients is strongly suggested.\n # We can't use external resources on synthetic content, everything must be inlined.\n # If we need to include images we can embed them in base64 encoding.\n # Here is the default error page for Varnish 4 (not so pretty)\n # We're using error 200 for monitoring puposes which should not be retried client side *\/\n if ( resp.status != 200) {\n set resp.http.Retry-After = \"5\";\n }\n\n # Consider add some analytics stuff to trace accesses\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning inconditionally.\n return (deliver);\n}\n\n#######################################################################\n# Backend Fetch\n\n# vcl_backend_fetch: Called before sending the backend request. In this subroutine you typically alter the request before it gets to the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-fetch\n# sub vcl_backend_fetch {\n# return (fetch);\n# }\n\n# vcl_backend_response: Called after the response headers has been successfully retrieved from the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-response\nsub vcl_backend_response {\n \/* Caching exceptions *\/\n # Varnish will cache objects with response codes: 200, 203, 300, 301, 302, 307, 404 & 410.\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/VCL_Basics.html#the-initial-value-of-beresp-ttl\n # Drupal's Imagecache module can return a 307 redirection to the requested url itself and, depending on Drupal's cache settings,\n # this could lead to a redirection loop being cached for a long time but also we want Varnish to shield a little the backend.\n # See http:\/\/drupal.org\/node\/1248010\n # See http:\/\/drupal.org\/node\/310656\n if (beresp.status == 307 &&\n #TODO# verify that this work better than 'bereq.url ~ \"imagecache\"' *\/\n beresp.http.Location == bereq.url &&\n beresp.ttl > 5s) {\n set beresp.ttl = 5s;\n set beresp.http.cache-control = \"max-age=5\";\n }\n\n \/* Request retrial *\/\n if ( beresp.status == 500\n || beresp.status == 503\n ) {\n #TODO# consider not restarting POST requests as seenV3 on https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleSaintMode\n return (retry);\n }\n\n \/* Enable grace mode. Related with vcl_hit *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n set beresp.grace = 1h;\n\n \/* Strip cookies from the following static file types for all users. Related with our 12th stage on vcl_recv *\/\n if (bereq.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|woff2|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\") {\n unset beresp.http.set-cookie;\n }\n\n \/* Gzip response *\/\n # Empty in simple configs\n # Use Varnish to Gzip respone, if suitable, before storing it on cache\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html\n if ( ! beresp.http.Content-Encoding\n && ( beresp.http.content-type ~ \"text\"\n || beresp.http.content-type ~ \"application\/x-javascript\"\n || beresp.http.content-type ~ \"application\/javascript\"\n || beresp.http.content-type ~ \"application\/rss+xml\"\n || beresp.http.content-type ~ \"application\/xml\"\n || beresp.http.content-type ~ \"Application\/JSON\")\n ) {\n set beresp.do_gzip = true;\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # We can add the name of the backend that has processed the request:\n # set beresp.http.X-Backend = beresp.backend.name;\n # We can use a header to tell if the object was gziped by Varnish\n # if (beresp.do_gzip) {\n # set beresp.http.X-Varnish-Gzipped = \"yes\";\n # } else {\n # set beresp.http.X-Varnish-Gizipped = \"no\";\n # }\n # We can also add headers informing whether the object is cacheable or not and why.\n # https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Varnish3.0\n if (beresp.ttl <= 0s) {\n \/* Varnish determined the object was not cacheable *\/\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n } elsif (bereq.http.Cookie ~ \"(SESS|SSESS|NO_CACHE|OATMEAL|CHOCOLATECHIP)\") {\n \/* We don't wish to cache content for logged in users or with certain cookies. Related with our 9th stage on vcl_recv *\/\n set beresp.http.X-Cacheable = \"NO:Cookies\";\n # return(hit_for_pass);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n \/* We are respecting the Cache-Control=private header from the backend *\/\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n # return(hit_for_pass);\n } else {\n \/* Varnish determined the object was cacheable *\/\n set beresp.http.X-Cacheable = \"YES\";\n }\n\n \/* Further header manipulation *\/\n # Empty in simple configs.\n # We can also unset some headers to prevent information disclosure and save some cache space\n # unset beresp.http.Server;\n # unset beresp.http.X-Powered-By;\n # Retry count\n if ( bereq.retries > 0) {\n set beresp.http.X-Retries = bereq.retries;\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_backend_response {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Surrogate-control ~ \"no-store\" ||\n# (!beresp.http.Surrogate-Control &&\n# beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n# beresp.http.Vary == \"*\") {\n# \/*\n# * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# *\/\n# set beresp.ttl = 120s;\n# set beresp.uncacheable = true;\n# }\n# return (deliver);\n# }\n\n# vcl_backend_error: This subroutine is called if we fail the backend fetch.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-error\nsub vcl_backend_error {\n\n \/* Try to restart request in case of failure *\/\n #TODO# Confirm max_retries default value\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if (bereq.retries < 4) {\n return (retry);\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # Retry count\n if ( bereq.retries > 0) {\n set beresp.http.X-Retries = bereq.retries;\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + beresp.status + \" \" + beresp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + beresp.status + \" \" + beresp.reason + {\"<\/h1>\n <p>\"} + beresp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + bereq.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this point.\n return (deliver);\n}\n\n#######################################################################\n# Housekeeping\n\n# vcl_init: Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-init\n# Here is where you should declare your directors now.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-backends.html#directors\n# Empty in simple configs\n# sub vcl_init {\n# return (ok);\n# }\n\n# vcl_fini: Called when VCL is discarded only after all requests have exited the VCL. Typically used to clean up VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-fini\n# sub vcl_fini {\n# return (ok);\n# }\n\n","old_contents":"\/* Varnish 4 example config for Drupal 7 \/ Pressflow 6 & 7 *\/\n# Original source: https:\/\/github.com\/NITEMAN\/varnish-bites\/varnish4\/drupal-base.vcl\n# Copyright (c) 2015 Pedro Gonz\u00e1lez Serrano and individual contributors.\n# MIT License\n\n# Intended to be used both in simple production environments and with\n# learning\/teaching purposes.\n# Some references may not be yet updated to VCL 4.0, we use SeeV3 then.\n\n# WARNING:\n# Note that the built-in logic will be appended to our code if no return is performed before.\n# Built-in logic is included commented out right after our's for reference purposes in that cases.\n# See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleDefault\n\n#######################################################################\n# Initialization: Version & imports;\n\n\/* Version statement *\/\n# Since Varnish 4.0 it's mandatory to declare VCL version on first line.\nvcl 4.0;\n\n\/* Module (VMOD) imports *\/\n# Standard module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_std.generated.html\nimport std;\n\n# Directors module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# Unused in simple configs.\n#import directors;\n\n\n#######################################################################\n# Probe, backend, ACL and subroutine definitions\n\n\/* Backend probes \/ healthchecks *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#probes\nprobe basic {\n \/* Only test that backend's IP serves content for '\/' *\/\n # This might be a too heavy probe\n # .url = \"\/\";\n \/* Only test that backend's IP has apache working *\/\n # Nginx would fail this probe with a default config\n .request =\n \"OPTIONS * HTTP\/1.1\"\n \"Host: *\"\n \"Connection: close\";\n .interval = 10s;\n .timeout = 2s;\n .window = 8;\n .threshold = 6;\n}\n\n\/* Backend definitions.*\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#backend-definition\nbackend default {\n \/* Default backend on the same machine. WARNING: timeouts could be not big enought for certain POST request *\/\n .host = \"127.0.0.1\";\n .port = \"8008\";\n .max_connections = 100;\n .connect_timeout = 60s;\n .first_byte_timeout = 60s;\n .between_bytes_timeout = 60s;\n .probe = basic;\n}\n\n\/* Access Control Lists *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#access-control-list-acl\nacl purge_ban {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use '\"localhost\";' instead\n}\nacl allowed_monitors {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n}\n#acl own_proxys {\n# \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n#}\n\n\/* Custom subroutines *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#subroutines\n#TODO# Test in Varnihs 4\n# Empty in simple configs.\n# We can name subs with no restrictions but as a task can need several chunks of code in diferent states,\n# it's a good idea to identify what main sub will call each with a suffix.\n# \/* Example 301 client redirection removing \"www\" prefix from request *\/\n# sub perm_redirections_recv {\n# if ( req.http.host ~ \"^www.*$\" ) {\n# return(synth(751, \"http:\/\/\" + regsub(req.http.host, \"^www\\.\", \"\") + req.url));\n# }\n# }\n# sub perm_redirections_synth {\n# if (resp.status == 751) {\n# \/* Get new URL from the response *\/\n# set resp.http.Location = resp.response;\n# \/* Set HTTP 301 for permanent redirect *\/\n# set resp.status = 301;\n# return (deliver);\n# }\n# }\n\n\n#######################################################################\n# Client side\n\n# vcl_recv: Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-recv\nsub vcl_recv {\n \/* 0th: general bypass, general return & authorization checks *\/\n # Empty in simple configs.\n # Useful for debugging we can pipe or pass the request to default backend here to bypass completely Varnish.\n # return (pipe);\n # return (pass);\n # We can also return here a 200 Ok for network performance benchmarking.\n # return(synth(200, \"Ok\"));\n # Finally we can perform basic HTTP authentification here, by example.\n # SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* 1st: Check for Varnish special requests *\/ \n # Custom response implementation example in order to check that Varnish is working properly.\n # This is usefull for automatic monitoring with monit or when Varnish is behind another proxies like HAProxy.\n if ( ( req.http.host == \"monitor.server.health\"\n || req.http.host == \"health.varnish\" )\n && client.ip ~ allowed_monitors\n && ( req.method == \"OPTIONS\" || req.method == \"GET\" )\n ) {\n return(synth(200, \"Ban added\"));\n }\n # Purge logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#http-purging\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if (req.method == \"PURGE\") {\n if (!client.ip ~ purge_ban) {\n return(synth(405, \"Not allowed.\"));\n }\n return (purge);\n }\n # Ban logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#bans\n if (req.method == \"BAN\") {\n if (!client.ip ~ purge_ban) {\n return(synth(405, \"Not allowed.\"));\n }\n ban(\"req.http.host == \" + req.http.host +\n \"&& req.url == \" + req.url); \n return(synth(200, \"Ban added\"));\n }\n\n \/* 2nd: Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_recv;\n # Here we can also enforce SSL when Varnish run behind some SSL termination point.\n\n \/* 3rd: Time for backend choice *\/\n # Empty in simple configs.\n\n \/* 4th: Prepare headers for the backend *\/\n # Empty in simple configs.\n # Example remove own_proxys from X-Forwarded-For\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/whats-new\/upgrading.html#x-forwarded-for-is-now-set-before-vcl-recv\n # if ( req.restarts == 0\n # && client.ip ~ own_proxys\n # && req.http.x-forwarded-for\n # ) {\n # set req.http.X-Forwarded-For = regsub(req.http.X-Forwarded-For, \",( )?\" + client.ip, \"\");\n # }\n\n \/* 5th: Bypass breakpoint 1 *\/\n # Useful for debugging we can now pipe or pass the request to backend with headers setted.\n # return (pipe);\n # return (pass);\n\n \/* 6th: Decide if we should deal with a request (mostly copied from built-in logic) *\/\n if (req.method == \"PRI\") {\n \/* We do not support SPDY or HTTP\/2.0 *\/\n return (synth(405));\n }\n if ( req.method != \"GET\"\n && req.method != \"HEAD\"\n && req.method != \"PUT\"\n && req.method != \"POST\"\n && req.method != \"TRACE\"\n && req.method != \"OPTIONS\"\n && req.method != \"DELETE\"\n ) {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n\n \/* 7th: Access control for some URLs by ACL *\/\n # Empty in simple configs.\n # By example denial some URLs depending on client-ip, we'll need to define corresponding ACL 'internal'.\n # if ( req.url ~ \"^\/(cron|install)\\.php\"\n # && ! client.ip ~ internal\n # ) {\n # # Have Varnish throw the error directly.\n # return(synth(403, \"Forbidden.\"));\n # # Use a custom error page that you've defined in Drupal at the path \"404\".\n # # set req.url = \"\/403\";\n # }\n\n \/* 8th: Custom exceptions *\/\n # Host exception example:\n # if (req.http.host == \"ejemplo.exception.com\") {\n # return (pass);\n # }\n # Drupal exceptions, edit if we want to cache some AJAX\/AHAH request.\n # Add here filters for never cache URLs such as Payment Gateway's callbacks\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/ooyala\/ping$\" ||\n req.url ~ \"^\/admin\/build\/features\" ||\n req.url ~ \"^\/info\/.*$\" ||\n req.url ~ \"^\/flag\/.*$\" ||\n req.url ~ \"^.*\/ajax\/.*$\" ||\n req.url ~ \"^.*\/ahah\/.*$\") {\n \/* Do not cache these paths *\/\n return (pass);\n }\n # Pipe these paths directly to backend for streaming.\n if (req.url ~ \"^\/admin\/content\/backup_migrate\/export\") {\n return (pipe);\n }\n if (req.url ~ \"^\/system\/files\") {\n return (pipe);\n }\n\n \/* 9th: Serve from anonymous cahe if all backends are down *\/\n if (! std.healthy(req.backend_hint) ) {\n #TODO# Consider moving this to vcl_backend_fetch\n unset req.http.Cookie;\n #TODO# Add sick marker\n } \n\n \/* 10th: Deal with compression and the Accept-Encoding header *\/\n # Althought Varnish 3 handles gziped content itself by default, just to be sure we want to \n # remove Accept-Encoding for some compressed formats.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html#what-does-http-gzip-support-do\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/varnishd.html?highlight=http_gzip_support\n # See (for older configs) https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleNormalizeAcceptEncoding\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|mp4|flv|zip|rar)$\") {\n \/* Already compressed formats, no sense trying to compress again *\/\n unset req.http.Accept-Encoding;\n }\n }\n\n \/* 11th: Another header manipulation *\/\n # Empty in simple configs.\n # We could add here a custom header grouping User-agent families.\n\n \/* 12th: Cookie removal *\/\n # Always cache the following static file types for all users. \n # Use with care if we control certain downloads depending on cookies. \n # Be carefull also if appending .htm[l] via Drupal's clean URLs.\n if ( req.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|woff2|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n && req.url !~ \"\/system\/storage\/serve\"\n ) {\n unset req.http.Cookie;\n }\n # Remove all cookies that backend doesn't need to know about.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRemovingSomeCookies\n if (req.http.Cookie) {\n \/* Warning: Not a pretty solution *\/\n \/* Prefix header containing cookies with ';' *\/\n set req.http.Cookie = \";\" + req.http.Cookie;\n \/* Remove any spaces after ';' in header containing cookies *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n \/* Prefix cookies we want to preserve with one space *\/\n \/* 'S{1,2}ESS[a-z0-9]+' is the regular expression matching a Drupal session cookie ({1,2} added for HTTPS support) *\/\n \/* 'NO_CACHE' is usually set after a POST request to make sure issuing user see the results of his post *\/\n \/* 'OATMEAL' & 'CHOCOLATECHIP' are special cookies used by Drupal's Bakery module to provide Single Sign On *\/\n \/* Keep in mind we should add here any cookie that should reach the backend such as splahs avoiding cookies *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \";(S{1,2}ESS[a-z0-9]+|NO_CACHE|OATMEAL|CHOCOLATECHIP)=\", \"; \\1=\");\n \/* Remove from the header any single Cookie not prefixed with a space until next ';' separator *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n \/* Remove any '; ' at the start or the end of the header *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n\n if (req.http.Cookie == \"\") {\n \/* If there are no remaining cookies, remove the cookie header. *\/\n unset req.http.Cookie;\n }\n }\n\n \/* 13th: Session cookie & special cookies bypass caching stage *\/\n # As we might want to cache some requests, hashed with its cookies, \n # we don't simply pass when some cookies remain present at this point.\n # Instead we look for request that must be passed due to the cookie header.\n if ( req.http.Cookie ~ \"SESS\"\n || req.http.Cookie ~ \"SSESS\"\n || req.http.Cookie ~ \"NO_CACHE\"\n || req.http.Cookie ~ \"OATMEAL\"\n || req.http.Cookie ~ \"CHOCOLATECHIP\"\n ) {\n return (pass);\n }\n\n \/* 14th: Bypass breakpoint 2 *\/\n # Useful for debugging we can now pipe or pass the request to backend to bypass cache.\n # return (pipe);\n # return (pass);\n\n \/* 15th: Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning inconditionally.\n return (hash);\n}\n\n# vcl_pipe: Called upon entering pipe mode.\n# In this mode, the request is passed on to the backend, \n# and any further data from either client or backend is passed on unaltered until either end closes the connection.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pipe\n# sub vcl_pipe {\n# # By default Connection: close is set on all piped requests, to stop\n# # connection reuse from sending future requests directly to the\n# # (potentially) wrong backend. If you do want this to happen, you can undo\n# # it here.\n# # unset bereq.http.connection;\n# return (pipe);\n# }\n\n# vcl_pass: Called upon entering pass mode. \n# In this mode, the request is passed on to the backend, and the backend's response is passed on to the client, \n# but is not entered into the cache.\n# Subsequent requests submitted over the same client connection are handled normally.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pass\n# sub vcl_pass {\n# return (fetch);\n# }\n\n# vcl_hash: You may call hash_data() on the data you would like to add to the hash.\n# Hash is used by Varnish to uniquely identify objects.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hash\nsub vcl_hash {\n \/* Hash cookie data *\/\n # As requests with same URL and host can produce diferent results when issued with different cookies,\n # we need to store items hashed with the associated cookies. Note that cookies are already sanitized when we reach this point.\n if (req.http.Cookie) {\n \/* Include cookie in cache hash *\/\n hash_data(req.http.Cookie);\n }\n\n \/* Custom header hashing *\/\n # Empty in simple configs.\n # Example for caching differents object versions by device previously detected (when static content could also vary):\n # if (req.http.X-UA-Device) {\n # hash_data(req.http.X-UA-Device);\n # }\n # Example for caching diferent object versions by X-Forwarded-Proto, trying to be smart about what kind of request\n # could generate diffetent responses.\n if ( req.http.X-Forwarded-Proto\n && req.url !~ \"(?i)\\.(png|gif|jpeg|jpg|ico|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|woff2|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\") {\n hash_data(req.http.X-Forwarded-Proto);\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (lookup);\n# }\n\n# vcl_purge: Called after the purge has been executed and all its variants have been evited.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-purge\n# sub vcl_purge {\n# return (synth(200, \"Purged\"));\n# }\n\n# vcl_hit: Called after a cache lookup if the requested document was found in the cache.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hit\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n \/\/ A pure unadultered hit, deliver it\n return (deliver);\n }\n \/* Allow varnish to serve up stale content if it is responding slowly *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n if (obj.ttl + 60s > 0s) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n return (deliver);\n }\n \/* Allow varish to serve up stale content if all backends are down *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n if ( ! std.healthy(req.backend_hint)\n && obj.ttl + obj.grace > 0s\n ) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n return (deliver);\n }\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning inconditionally.\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\n# vcl_miss: Called after a cache lookup if the requested document was not found in the cache.\n# Its purpose is to decide whether or not to attempt to retrieve the document from the backend, and which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-miss\n# sub vcl_miss {\n# return (fetch);\n# }\n\n# vcl_deliver: Called before an object is delivered to the client\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-deliver\nsub vcl_deliver {\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # Add whether the object is a cache hit or miss and the number of hits for the object.\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Addingaheaderindicatinghitmiss\n # In Varnish 4 the obj.hits counter behaviour has changed (see bug 1492), so\n # we use a different method: if X-Varnish contains only 1 id, we have a miss,\n # if it contains more (and therefore a space), we have a hit.\n if (resp.http.x-varnish ~ \" \") {\n set resp.http.X-Cache = \"HIT\";\n # Since in Varnish 4 the behaviour of obj.hits changed, this might not be accurate\n # See https:\/\/www.varnish-cache.org\/trac\/ticket\/1492\n set resp.http.X-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Cache = \"MISS\";\n \/* Show the results of cookie sanitization *\/\n set resp.http.X-Cookie = req.http.Cookie;\n }\n\n #TODO# Add sick marker\n\n # Restart count\n if ( req.restarts > 0) {\n set resp.http.X-Restarts = req.restarts;\n }\n\n # Add the Varnish server hostname\n set resp.http.X-Varnish-Server = server.hostname;\n # If we have setted a custom header with device family detected we can show it:\n # if (req.http.X-UA-Device) {\n # set resp.http.X-UA-Device = req.http.X-UA-Device;\n # }\n # If we have recived a custom header with the protocol in the request we can show it:\n # if (req.http.X-Forwarded-Proto) {\n # set resp.http.X-Forwarded-Proto = req.http.X-Forwarded-Proto;\n # }\n\n \/* Vary header manipulation *\/\n # Empty in simple configs.\n # By example, if we are storing & serving diferent objects depending on User-Agent header we must set the correct Vary header:\n # if (resp.http.Vary) {\n # set resp.http.Vary = resp.http.Vary + \",User-Agent\";\n # } else {\n # set resp.http.Vary = \"User-Agent\";\n # }\n\n \/* Fake headers *\/\n # Empty in simple configs\n # We can fake server headers here, by example:\n # set resp.http.Server = \"Deep thought\";\n # set resp.http.X-Powered-By = \"BOFH\";\n # Or have some fun with headers:\n # See http:\/\/www.nextthing.org\/archives\/2005\/08\/07\/fun-with-http-headers\n # See http:\/\/royal.pingdom.com\/2012\/08\/15\/fun-and-unusual-http-response-headers\/\n # set resp.http.X-Thank-You = \"for bothering to look at my HTTP headers\";\n # set resp.http.X-Answer = \"42\";\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_deliver {\n# return (deliver);\n# }\n\n# vcl_synth: Called to deliver a synthetic object. A synthetic object is generated in VCL,\n# not fetched from the backend. It is typically contructed using the synthetic() function.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-synth\n\/*\n * We can come here \"invisibly\" with the following errors: 413, 417 & 503\n *\/\nsub vcl_synth {\n \/* Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_synth;\n\n \/* Try to restart request in case of failure *\/\n # Note that max_restarts defaults to 4\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if (resp.status == 503 && req.restarts < 4) {\n return(restart);\n }\n\n \/* Set common headers for synthetic responses *\/\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n\n \/* HTTP Authentification client request *\/\n # Empty in simple configs. SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* Load synthetic responses from disk *\/\n # Note that files loaded this way are never re-readed (even after a reload).\n # You should consider PROS\/CONS of doing an include instead.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_std.generated.html#func-fileread\n # Example custom 403 error page.\n # if (resp.status == 403) {\n # synthetic(std.fileread(\"\/403.html\"));\n # return(deliver);\n # }\n\n \/* Error page & refresh \/ redirections *\/\n # We have plenty of choices when we have to serve an error to the client, \n # from the default error page to javascript black magic or plain redirections.\n # Adding some external statistic javascript to track failures served to clients is strongly suggested.\n # We can't use external resources on synthetic content, everything must be inlined.\n # If we need to include images we can embed them in base64 encoding.\n # Here is the default error page for Varnish 4 (not so pretty)\n # We're using error 200 for monitoring puposes which should not be retried client side *\/\n if ( resp.status != 200) {\n set resp.http.Retry-After = \"5\";\n }\n\n # Consider add some analytics stuff to trace accesses\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning inconditionally.\n return (deliver);\n}\n\n#######################################################################\n# Backend Fetch\n\n# vcl_backend_fetch: Called before sending the backend request. In this subroutine you typically alter the request before it gets to the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-fetch\n# sub vcl_backend_fetch {\n# return (fetch);\n# }\n\n# vcl_backend_response: Called after the response headers has been successfully retrieved from the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-response\nsub vcl_backend_response {\n \/* Caching exceptions *\/\n # Varnish will cache objects with response codes: 200, 203, 300, 301, 302, 307, 404 & 410.\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/VCL_Basics.html#the-initial-value-of-beresp-ttl\n # Drupal's Imagecache module can return a 307 redirection to the requested url itself and, depending on Drupal's cache settings,\n # this could lead to a redirection loop being cached for a long time but also we want Varnish to shield a little the backend.\n # See http:\/\/drupal.org\/node\/1248010\n # See http:\/\/drupal.org\/node\/310656\n if (beresp.status == 307 &&\n #TODO# verify that this work better than 'bereq.url ~ \"imagecache\"' *\/\n beresp.http.Location == bereq.url &&\n beresp.ttl > 5s) {\n set beresp.ttl = 5s;\n set beresp.http.cache-control = \"max-age=5\";\n }\n\n \/* Request retrial *\/\n if ( beresp.status == 500\n || beresp.status == 503\n ) {\n #TODO# consider not restarting POST requests as seenV3 on https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleSaintMode\n return (retry);\n }\n\n \/* Enable grace mode. Related with vcl_hit *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n set beresp.grace = 1h;\n\n \/* Strip cookies from the following static file types for all users. Related with our 12th stage on vcl_recv *\/\n if (bereq.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|woff2|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\") {\n unset beresp.http.set-cookie;\n }\n\n \/* Gzip response *\/\n # Empty in simple configs\n # Use Varnish to Gzip respone, if suitable, before storing it on cache\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html\n if ( ! beresp.http.Content-Encoding\n && ( beresp.http.content-type ~ \"text\"\n || beresp.http.content-type ~ \"application\/x-javascript\"\n || beresp.http.content-type ~ \"application\/javascript\"\n || beresp.http.content-type ~ \"application\/rss+xml\"\n || beresp.http.content-type ~ \"application\/xml\"\n || beresp.http.content-type ~ \"Application\/JSON\")\n ) {\n set beresp.do_gzip = true;\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # We can add the name of the backend that has processed the request:\n # set beresp.http.X-Backend = beresp.backend.name;\n # We can use a header to tell if the object was gziped by Varnish\n # if (beresp.do_gzip) {\n # set beresp.http.X-Varnish-Gzipped = \"yes\";\n # } else {\n # set beresp.http.X-Varnish-Gizipped = \"no\";\n # }\n # We can also add headers informing whether the object is cacheable or not and why.\n # https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Varnish3.0\n if (beresp.ttl <= 0s) {\n \/* Varnish determined the object was not cacheable *\/\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n } elsif (bereq.http.Cookie ~ \"(SESS|SSESS|NO_CACHE|OATMEAL|CHOCOLATECHIP)\") {\n \/* We don't wish to cache content for logged in users or with certain cookies. Related with our 9th stage on vcl_recv *\/\n set beresp.http.X-Cacheable = \"NO:Cookies\";\n # return(hit_for_pass);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n \/* We are respecting the Cache-Control=private header from the backend *\/\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n # return(hit_for_pass);\n } else {\n \/* Varnish determined the object was cacheable *\/\n set beresp.http.X-Cacheable = \"YES\";\n }\n\n \/* Further header manipulation *\/\n # Empty in simple configs.\n # We can also unset some headers to prevent information disclosure and save some cache space\n # unset beresp.http.Server;\n # unset beresp.http.X-Powered-By;\n # Retry count\n if ( bereq.retries > 0) {\n set beresp.http.X-Retries = bereq.retries;\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_backend_response {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Surrogate-control ~ \"no-store\" ||\n# (!beresp.http.Surrogate-Control &&\n# beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n# beresp.http.Vary == \"*\") {\n# \/*\n# * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# *\/\n# set beresp.ttl = 120s;\n# set beresp.uncacheable = true;\n# }\n# return (deliver);\n# }\n\n# vcl_backend_error: This subroutine is called if we fail the backend fetch.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-error\nsub vcl_backend_error {\n\n \/* Try to restart request in case of failure *\/\n #TODO# Confirm max_retries default value\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if (bereq.retries < 4) {\n return (retry);\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # Retry count\n if ( bereq.retries > 0) {\n set beresp.http.X-Retries = bereq.retries;\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + beresp.status + \" \" + beresp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + beresp.status + \" \" + beresp.reason + {\"<\/h1>\n <p>\"} + beresp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + bereq.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this point.\n return (deliver);\n}\n\n#######################################################################\n# Housekeeping\n\n# vcl_init: Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-init\n# Here is where you should declare your directors now.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-backends.html#directors\n# Empty in simple configs\n# sub vcl_init {\n# return (ok);\n# }\n\n# vcl_fini: Called when VCL is discarded only after all requests have exited the VCL. Typically used to clean up VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-fini\n# sub vcl_fini {\n# return (ok);\n# }\n\n","returncode":0,"stderr":"","license":"unknown","lang":"VCL"} {"commit":"4ae71e537b8b4af9711ebc67e7fd3bebe499cb95","subject":"Added diagnostic headers to passthrough reasons.","message":"Added diagnostic headers to passthrough reasons.\n","repos":"telusdigital\/ansible-varnish,colstrom\/ansible-varnish,gotofbi\/ansible-varnish,killerwails\/ansible-varnish,gotofbi\/ansible-varnish,killerwails\/ansible-varnish,noqcks\/ansible-varnish,kkwoker\/ansible-varnish","old_file":"templates\/etc\/varnish\/default.vcl","new_file":"templates\/etc\/varnish\/default.vcl","new_contents":"vcl 4.0;\n\nimport directors;\nimport std;\n\n###\n# Varnish Documentation\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-built-in-subs.html\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/reference\/vcl.html\n##\n\n{% for backend in varnish_backend_hosts %}\nbackend application_{{ loop.index }} {\n .host = \"{{ backend }}\";\n .port = \"{{ varnish_backend_port }}\";\n{% if varnish_health_checks_enabled %}\n .probe = {\n .url = \"{{ varnish_health_check_url }}\";\n .interval = {{ varnish_health_check_interval }};\n .timeout = {{ varnish_health_check_timeout }};\n .window = {{ varnish_health_check_window }};\n .threshold = {{ varnish_health_check_threshold }};\n }\n{% endif %}\n}\n{% endfor %}\n\n###\n# vcl_init\n# Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n###\n# The vcl_init subroutine may terminate with calling return() with one of the following keywords:\n#\n# ok\n# Normal return, VCL continues loading.\n##\n\nsub vcl_init {\n new application = directors.round_robin();\n{% for backend in varnish_backend_hosts %}\n application.add_backend(application_{{ loop.index }});\n{% endfor %}\n}\n\n###\n# vcl_recv\n# Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use. \n# It is also used to modify the request\n###\n# The vcl_recv subroutine may terminate with calling return() on one of the following keywords:\n#\n# synth(status code, reason)\n# Return a synthetic object with the specified status code to the client and abandon the request.\n# pass\n# Switch to pass mode. Control will eventually pass to vcl_pass.\n# pipe\n# Switch to pipe mode. Control will eventually pass to vcl_pipe.\n# hash\n# Continue processing the object as a potential candidate for caching. Passes the control over to vcl_hash.\n# purge\n# Purge the object and it's variants. Control passes through vcl_hash to vcl_purge.\n#\n\nsub vcl_recv {\n set req.backend_hint = application.backend();\n\n ###\n # Avoid processing uncacheable requests\n ###\n\n if (req.http.Authorization) {\n return (pass);\n }\n\n ###\n # Inject X-Forwarded-For headers, but only once.\n ###\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n{% if varnish_header_sanitization_enabled %}\n ###\n # Header Sanitization\n ###\n\n{% if varnish_discards_port_from_host_header %}\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n{% endif %}\n\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_enabled %}\n ###\n # Cookie Sanitization\n ###\n\n ### Google Analytics\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n\n ### Quantcast\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n \n ### AddThis\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n\n ### General Cleanup\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n{% endif %}\n\n{% if varnish_uri_sanitization_enabled %}\n ###\n # URI Sanitization\n ###\n \n if (req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=\") {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n{% endif %}\n\n{% if varnish_workaround_telusdotcom_browser_profile %}\n ###\n # Workaround for BrowserProfile and Language\/Region Detection on TELUS.com\n ###\n\n if (req.http.Cookie ~ \"BrowserProfile\") {\n set req.http.X-Language = regsuball(req.http.Cookie, \"language..:\\\\.(.*)\\\\.,\", \"\\1\");\n set req.http.X-Province = regsuball(req.http.Cookie, \"region..:\\\\.(.*)\\\\.,\", \"\\1\");\n } else {\n if (req.http.Cookie ~ \"lang=\") {\n set req.http.X-Language = regsuball(req.http.Cookie, \"lang=(.*);\", \"\\1\");\n } else {\n set req.http.X-Language = \"en\";\n }\n\n if (req.http.Cookie ~ \"prov=\") {\n set req.http.X-Province = regsuball(req.http.Cookie, \"prov=(.*);\", \"\\1\");\n } else {\n set req.http.X-Province = \"BC\";\n }\n }\n\n if (req.url ~ \"\/(en|fr)\/\") {\n if (req.url ~ \"\/en\/\" && req.http.X-Language != \"en\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Language)\";\n return(pass);\n }\n if (req.url ~ \"\/fr\/\" && req.http.X-Language != \"fr\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Language)\";\n return(pass);\n }\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Language)\";\n return(pass);\n }\n\n if (req.url ~ \"\/(ab|bc|mb|nb|nl|ns|nt|nu|on|pe|qc|sk|yt)\/\") {\n {% for province in ['ab', 'bc', 'mb', 'nb', 'nl', 'ns', 'nt', 'nu', 'on', 'pe', 'qc', 'sk', 'yt'] %}\n if (req.url ~ \"{{ province }}\" && req.http.X-Province != \"{{ province }}\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Province)\";\n return(pass);\n }\n {% endfor %}\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Province)\";\n return(pass);\n }\n{% endif %}\n\n{% if varnish_blacklist_enabled %}\n if ((req.url ~ \"{{ varnish_blacklist_regexp }}\")) {\n set req.http.X-Passthrough-Reason = \"Path in Blacklist\";\n return(pass);\n } else {\n{% if varnish_discards_client_cookies %}\n unset req.http.Cookie;\n{% endif %}\n }\n{% endif %}\n\n}\n\n###\n# vcl_hit\n# Called when a cache lookup is successful.\n###\n# The vcl_hit subroutine may terminate with calling return() with one of the following keywords:\n#\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n# deliver\n# Deliver the object. Control passes to vcl_deliver.\n# synth(status code, reason)\n# Return the specified status code to the client and abandon the request.\n###\n\nsub vcl_hit {\n if (obj.ttl > 0s) {\n return (deliver);\n }\n{% if varnish_health_checks_enabled %}\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (fetch);\n }\n{% else %}\n if (obj.ttl + obj.grace > 0s) {\n return (deliver);\n }\n\n return (fetch);\n{% endif %}\n}\n\n###\n# vcl_backend_response\n# Called after the response headers has been successfully retrieved from the backend.\n###\n# The vcl_backend_response subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Possibly insert the object into the cache, then deliver it to the Control will eventually pass to vcl_deliver.\n# abandon\n# Abandon the backend request and generates an error.\n# retry\n# Retry the backend transaction. Increases the retries counter. If the number of retries is higher than max_retries Varnish emits a guru meditation error.\n###\n\nsub vcl_backend_response {\n{% if varnish_blacklist_enabled %}\n if (bereq.url ~ \"{{ varnish_blacklist_regexp }}\") {\n set beresp.http.X-Cacheable = \"NO:Path in Blacklist\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n if (bereq.http.X-Passthrough-Reason) {\n set beresp.http.X-Passthrough-Reason = bereq.http.X-Passthrough-Reason;\n return(deliver);\n } else {\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n }\n }\n{% else %}\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n{% endif %}\n\n{% if varnish_cache_diagnostics_enabled %}\n if (bereq.http.Cookie) {\n set beresp.http.X-Cacheable = \"NO:Cookie in Request\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO:Set-Cookie in Response\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.X-No-Cache) {\n set beresp.http.X-Cacheable = \"NO:X-No-Cache\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.ttl <= 0s) {\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n{% endif %}\n\n set beresp.grace = {{ varnish_grace_period }};\n}\n\n###\n# vcl_deliver\n# Called before a cached object is delivered to the client.\n###\n# The vcl_deliver subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Deliver the object to the client.\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n###\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n","old_contents":"vcl 4.0;\n\nimport directors;\nimport std;\n\n###\n# Varnish Documentation\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-built-in-subs.html\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/reference\/vcl.html\n##\n\n{% for backend in varnish_backend_hosts %}\nbackend application_{{ loop.index }} {\n .host = \"{{ backend }}\";\n .port = \"{{ varnish_backend_port }}\";\n{% if varnish_health_checks_enabled %}\n .probe = {\n .url = \"{{ varnish_health_check_url }}\";\n .interval = {{ varnish_health_check_interval }};\n .timeout = {{ varnish_health_check_timeout }};\n .window = {{ varnish_health_check_window }};\n .threshold = {{ varnish_health_check_threshold }};\n }\n{% endif %}\n}\n{% endfor %}\n\n###\n# vcl_init\n# Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n###\n# The vcl_init subroutine may terminate with calling return() with one of the following keywords:\n#\n# ok\n# Normal return, VCL continues loading.\n##\n\nsub vcl_init {\n new application = directors.round_robin();\n{% for backend in varnish_backend_hosts %}\n application.add_backend(application_{{ loop.index }});\n{% endfor %}\n}\n\n###\n# vcl_recv\n# Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use. \n# It is also used to modify the request\n###\n# The vcl_recv subroutine may terminate with calling return() on one of the following keywords:\n#\n# synth(status code, reason)\n# Return a synthetic object with the specified status code to the client and abandon the request.\n# pass\n# Switch to pass mode. Control will eventually pass to vcl_pass.\n# pipe\n# Switch to pipe mode. Control will eventually pass to vcl_pipe.\n# hash\n# Continue processing the object as a potential candidate for caching. Passes the control over to vcl_hash.\n# purge\n# Purge the object and it's variants. Control passes through vcl_hash to vcl_purge.\n#\n\nsub vcl_recv {\n set req.backend_hint = application.backend();\n\n ###\n # Avoid processing uncacheable requests\n ###\n\n if (req.http.Authorization) {\n return (pass);\n }\n\n ###\n # Inject X-Forwarded-For headers, but only once.\n ###\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n{% if varnish_header_sanitization_enabled %}\n ###\n # Header Sanitization\n ###\n\n{% if varnish_discards_port_from_host_header %}\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n{% endif %}\n\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_enabled %}\n ###\n # Cookie Sanitization\n ###\n\n ### Google Analytics\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n\n ### Quantcast\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n \n ### AddThis\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n\n ### General Cleanup\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n{% endif %}\n\n{% if varnish_uri_sanitization_enabled %}\n ###\n # URI Sanitization\n ###\n \n if (req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=\") {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n{% endif %}\n\n{% if varnish_workaround_telusdotcom_browser_profile %}\n ###\n # Workaround for BrowserProfile and Language\/Region Detection on TELUS.com\n ###\n\n if (req.http.Cookie ~ \"BrowserProfile\") {\n set req.http.X-Language = regsuball(req.http.Cookie, \"language..:\\\\.(.*)\\\\.,\", \"\\1\");\n set req.http.X-Province = regsuball(req.http.Cookie, \"region..:\\\\.(.*)\\\\.,\", \"\\1\");\n } else {\n if (req.http.Cookie ~ \"lang=\") {\n set req.http.X-Language = regsuball(req.http.Cookie, \"lang=(.*);\", \"\\1\");\n } else {\n set req.http.X-Language = \"en\";\n }\n\n if (req.http.Cookie ~ \"prov=\") {\n set req.http.X-Province = regsuball(req.http.Cookie, \"prov=(.*);\", \"\\1\");\n } else {\n set req.http.X-Province = \"BC\";\n }\n }\n\n if (req.url ~ \"\/(en|fr)\/\") {\n if (req.url ~ \"\/en\/\" && req.http.X-Language != \"en\") {\n return(pass);\n }\n if (req.url ~ \"\/fr\/\" && req.http.X-Language != \"fr\") {\n return(pass);\n }\n } else {\n return(pass);\n }\n\n if (req.url ~ \"\/(ab|bc|mb|nb|nl|ns|nt|nu|on|pe|qc|sk|yt)\/\") {\n {% for province in ['ab', 'bc', 'mb', 'nb', 'nl', 'ns', 'nt', 'nu', 'on', 'pe', 'qc', 'sk', 'yt'] %}\n if (req.url ~ \"{{ province }}\" && req.http.X-Province != \"{{ province }}\") {\n return(pass);\n }\n {% endfor %}\n } else {\n return(pass);\n }\n{% endif %}\n\n{% if varnish_blacklist_enabled %}\n if ((req.url ~ \"{{ varnish_blacklist_regexp }}\")) {\n return(pass);\n } else {\n{% if varnish_discards_client_cookies %}\n unset req.http.Cookie;\n{% endif %}\n }\n{% endif %}\n\n}\n\n###\n# vcl_hit\n# Called when a cache lookup is successful.\n###\n# The vcl_hit subroutine may terminate with calling return() with one of the following keywords:\n#\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n# deliver\n# Deliver the object. Control passes to vcl_deliver.\n# synth(status code, reason)\n# Return the specified status code to the client and abandon the request.\n###\n\nsub vcl_hit {\n if (obj.ttl > 0s) {\n return (deliver);\n }\n{% if varnish_health_checks_enabled %}\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (fetch);\n }\n{% else %}\n if (obj.ttl + obj.grace > 0s) {\n return (deliver);\n }\n\n return (fetch);\n{% endif %}\n}\n\n###\n# vcl_backend_response\n# Called after the response headers has been successfully retrieved from the backend.\n###\n# The vcl_backend_response subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Possibly insert the object into the cache, then deliver it to the Control will eventually pass to vcl_deliver.\n# abandon\n# Abandon the backend request and generates an error.\n# retry\n# Retry the backend transaction. Increases the retries counter. If the number of retries is higher than max_retries Varnish emits a guru meditation error.\n###\n\nsub vcl_backend_response {\n{% if varnish_blacklist_enabled %}\n if (bereq.url ~ \"{{ varnish_blacklist_regexp }}\") {\n set beresp.http.X-Cacheable = \"NO:Path in Blacklist\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n }\n{% else %}\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n{% endif %}\n\n{% if varnish_cache_diagnostics_enabled %}\n if (bereq.http.Cookie) {\n set beresp.http.X-Cacheable = \"NO:Cookie in Request\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO:Set-Cookie in Response\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.X-No-Cache) {\n set beresp.http.X-Cacheable = \"NO:X-No-Cache\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.ttl <= 0s) {\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n{% endif %}\n\n set beresp.grace = {{ varnish_grace_period }};\n}\n\n###\n# vcl_deliver\n# Called before a cached object is delivered to the client.\n###\n# The vcl_deliver subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Deliver the object to the client.\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n###\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"8ddec944974932a00a74d61fa7121a3e24613dac","subject":"coding consistency","message":"coding consistency\n","repos":"NITEMAN\/Varnish_VCL_samps-hacks,NITEMAN\/varnish-bites","old_file":"varnish4\/drupal-base.vcl","new_file":"varnish4\/drupal-base.vcl","new_contents":"\/*\n * Varnish 4 example config for Drupal 7 \/ Pressflow 6 & 7\n *\/\n\n# Original source: https:\/\/github.com\/NITEMAN\/varnish-bites\/varnish4\/drupal-base.vcl\n# Copyright (c) 2015 Pedro Gonz\u00e1lez Serrano and individual contributors.\n# MIT License\n\n# Intended to be used both in simple production environments and with\n# learning\/teaching purposes.\n# Some references may not be yet updated to VCL 4.0, we use SeeV3 then.\n\n# WARNING:\n# Note that the built-in logic will be appended to our code if no return is\n# performed before.\n# Built-in logic is included commented out right after our's for reference\n# purposes in that cases.\n# See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleDefault\n\n#######################################################################\n# Initialization: Version & imports;\n\n\/* Version statement *\/\n# Since Varnish 4.0 it's mandatory to declare VCL version on first line.\nvcl 4.0;\n\n\/* Module (VMOD) imports *\/\n# Standard module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_std.generated.html\nimport std;\n\n# Directors module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# Unused in simple configs.\n#import directors;\n\n\n#######################################################################\n# Probe, backend, ACL and subroutine definitions\n\n\/* Backend probes \/ healthchecks *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#probes\nprobe basic {\n \/* Only test that backend's IP serves content for '\/' *\/\n # This might be a too heavy probe\n # .url = \"\/\";\n\n \/* Only test that backend's IP has apache working *\/\n # Nginx would fail this probe with a default config\n .request =\n \"OPTIONS * HTTP\/1.1\"\n \"Host: *\"\n \"Connection: close\";\n\n \/* Common options *\/\n .interval = 10s;\n .timeout = 2s;\n .window = 8;\n .threshold = 6;\n}\n\n\/* Backend definitions.*\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#backend-definition\nbackend default {\n \/* Default backend on the same machine. *\/\n # WARNING: timeouts could be not big enought for certain POST requests.\n .host = \"127.0.0.1\";\n .port = \"8008\";\n .max_connections = 100;\n .connect_timeout = 60s;\n .first_byte_timeout = 60s;\n .between_bytes_timeout = 60s;\n .probe = basic;\n}\n\n\/* Access Control Lists *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#access-control-list-acl\nacl purge_ban {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use '\"localhost\";' instead\n}\nacl allowed_monitors {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n}\n# acl own_proxys {\n# \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n# }\n\n\/* Custom subroutines *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#subroutines\n#TODO# Test in Varnihs 4\n# Empty in simple configs.\n# The only restriction naming subs is that the 'vlc_' prefix is reserverd for\n# Varnish use. As a task can need several chunks of code in diferent states,\n# it's a good idea to identify what main sub will call each with a suffix.\n# \/* Example 301 client redirection removing \"www\" prefix from request *\/\n# sub perm_redirections_recv {\n# if ( req.http.host ~ \"^www.*$\" ) {\n# return (\n# synth(751, \"http:\/\/\" + regsub(req.http.host, \"^www\\.\", \"\") + req.url)\n# );\n# }\n# }\n# sub perm_redirections_synth {\n# if ( resp.status == 751 ) {\n# \/* Get new URL from the response *\/\n# set resp.http.Location = resp.response;\n# \/* Set HTTP 301 for permanent redirect *\/\n# set resp.status = 301;\n# return (deliver);\n# }\n# }\n\n\n#######################################################################\n# Client side\n\n# vcl_recv: Called at the beginning of a request, after the complete request\n# has been received and parsed. Its purpose is to decide whether or not to\n# serve the request, how to do it, and, if applicable, which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-recv\nsub vcl_recv {\n \/* 0th: general bypass, general return & authorization checks *\/\n # Empty in simple configs.\n # Useful for debugging we can pipe or pass the request to default backend\n # here to bypass completely Varnish.\n # return (pipe);\n # return (pass);\n # We can also return here a 200 Ok for network performance benchmarking.\n # return (synth(200, \"Ok\"));\n # Finally we can perform basic HTTP authentification here, by example.\n # SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* 1st: Check for Varnish special requests *\/ \n # Custom response implementation example in order to check that Varnish is\n # working properly.\n # This is usefull for automatic monitoring with monit or when Varnish is\n # behind another proxies like HAProxy.\n if ( ( req.http.host == \"monitor.server.health\"\n || req.http.host == \"health.varnish\" )\n && client.ip ~ allowed_monitors\n && ( req.method == \"OPTIONS\" || req.method == \"GET\" )\n ) {\n return (synth(200, \"Ban added\"));\n }\n # Purge logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#http-purging\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if ( req.method == \"PURGE\" ) {\n if ( client.ip !~ purge_ban ) {\n return (synth(405, \"Not allowed.\"));\n }\n return (purge);\n }\n # Ban logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#bans\n if ( req.method == \"BAN\" ) {\n if ( client.ip !~ purge_ban ) {\n return (synth(405, \"Not allowed.\"));\n }\n ban( \"req.http.host == \" + req.http.host +\n \"&& req.url == \" + req.url);\n return (synth(200, \"Ban added\"));\n }\n\n \/* 2nd: Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_recv;\n # Here we can also enforce SSL when Varnish run behind some SSL termination\n # point.\n\n \/* 3rd: Time for backend choice *\/\n # Empty in simple configs.\n\n \/* 4th: Prepare request for the backend *\/\n # Empty in simple configs.\n # Example remove own_proxys from X-Forwarded-For\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/whats-new\/upgrading.html#x-forwarded-for-is-now-set-before-vcl-recv\n # if ( req.restarts == 0\n # && client.ip ~ own_proxys\n # && req.http.x-forwarded-for\n # ) {\n # set req.http.X-Forwarded-For\n # = regsub(req.http.X-Forwarded-For, \",( )?\" + client.ip, \"\");\n # }\n # Example normalize the host header, remove the port (in case you're testing\n # this on various TCP ports)\n # set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n \/* 5th: Bypass breakpoint 1 *\/\n # Useful for debugging we can now pipe or pass the request to backend with\n # headers setted.\n # return (pipe);\n # return (pass);\n\n \/* 6th: Decide if we should deal with a request (mostly from built-in logic) *\/\n if ( req.method == \"PRI\" ) {\n \/* We do not support SPDY or HTTP\/2.0 *\/\n return (synth(405));\n }\n if ( req.method != \"GET\"\n && req.method != \"HEAD\"\n && req.method != \"PUT\"\n && req.method != \"POST\"\n && req.method != \"TRACE\"\n && req.method != \"OPTIONS\"\n && req.method != \"DELETE\"\n ) {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if ( req.method != \"GET\"\n && req.method != \"HEAD\"\n ) {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if ( req.http.Authorization ) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n # Websocket support\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html\n if ( req.http.Upgrade ~ \"(?i)websocket\" ) {\n return (pipe);\n }\n\n \/* 7th: Access control for some URLs by ACL *\/\n # Empty in simple configs.\n # By example denial some URLs depending on client-ip, we'll need to define\n # corresponding ACL 'internal'.\n # if ( req.url ~ \"^\/(cron|install)\\.php\"\n # && client.ip !~ internal\n # ) {\n # # Have Varnish throw the error directly.\n # return (synth(403, \"Forbidden.\"));\n # # Use a custom error page that you've defined in Drupal at the path \"404\".\n # # set req.url = \"\/403\";\n # }\n\n \/* 8th: Custom exceptions *\/\n # Host exception example:\n # if ( req.http.host == \"ejemplo.exception.com\" ) {\n # return (pass);\n # }\n # Drupal exceptions, edit if we want to cache some AJAX\/AHAH request.\n # Add here filters for never cache URLs such as Payment Gateway's callbacks.\n if ( req.url ~ \"^\/status\\.php$\"\n || req.url ~ \"^\/update\\.php$\"\n || req.url ~ \"^\/ooyala\/ping$\"\n || req.url ~ \"^\/admin\/build\/features\"\n || req.url ~ \"^\/info\/.*$\"\n || req.url ~ \"^\/flag\/.*$\"\n || req.url ~ \"^.*\/ajax\/.*$\"\n || req.url ~ \"^.*\/ahah\/.*$\"\n ) {\n \/* Do not cache these paths *\/\n return (pass);\n }\n # Pipe these paths directly to backend for streaming.\n if ( req.url ~ \"^\/admin\/content\/backup_migrate\/export\" ) {\n return (pipe);\n }\n if ( req.url ~ \"^\/system\/files\" ) {\n return (pipe);\n }\n\n \/* 9th: Graced objets & Serve from anonymous cahe if all backends are down *\/\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n # set req.http.grace = \"none\";\n if ( ! std.healthy(req.backend_hint) ) {\n # We must do this here since cookie hashing\n unset req.http.Cookie;\n #TODO# Add sick marker\n } \n\n \/* 10th: Deal with compression and the Accept-Encoding header *\/\n # Althought Varnish 3 handles gziped content itself by default, just to be\n # sure we want to remove Accept-Encoding for some compressed formats.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html#what-does-http-gzip-support-do\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/varnishd.html?highlight=http_gzip_support\n # See (for older configs) https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleNormalizeAcceptEncoding\n if ( req.http.Accept-Encoding ) {\n if ( req.url ~ \"(?i)\\.(7z|avi|bz2|flv|gif|gz|jpe?g|mpe?g|mk[av]|mov|mp[34]|og[gm]|pdf|png|rar|swf|tar|tbz|tgz|woff2?|zip|xz)(\\?.*)?$\"\n ) {\n \/* Already compressed formats, no sense trying to compress again *\/\n unset req.http.Accept-Encoding;\n }\n }\n\n \/* 11th: Another request manipulation *\/\n # Empty in simple configs.\n # We could add here a custom header grouping User-agent families.\n\n \/* 12th: Cookie removal *\/\n # Always cache the following static file types for all users. \n # Use with care if we control certain downloads depending on cookies. \n # Be carefull also if appending .htm[l] via Drupal's clean URLs.\n if ( req.url ~ \"(?i)\\.(bz2|css|eot|gif|gz|html?|ico|jpe?g|js|mp3|ogg|otf|pdf|png|rar|svg|swf|tbz|tgz|ttf|woff2?|zip)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n && req.url !~ \"\/system\/storage\/serve\"\n ) {\n unset req.http.Cookie;\n }\n # Remove all cookies that backend doesn't need to know about.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRemovingSomeCookies\n if ( req.http.Cookie ) {\n \/* Warning: Not a pretty solution *\/\n # Prefix header containing cookies with ';'\n set req.http.Cookie = \";\" + req.http.Cookie;\n # Remove any spaces after ';' in header containing cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n # Prefix cookies we want to preserve with one space:\n # 'S{1,2}ESS[a-z0-9]+' is the regular expression matching a Drupal session\n # cookie ({1,2} added for HTTPS support).\n # 'NO_CACHE' is usually set after a POST request to make sure issuing user\n # see the results of his post.\n # 'OATMEAL' & 'CHOCOLATECHIP' are special cookies used by Drupal's Bakery\n # module to provide Single Sign On.\n # Keep in mind we should add here any cookie that should reach the backend\n # such as splash avoiding cookies.\n set req.http.Cookie\n = regsuball(\n req.http.Cookie,\n \";(S{1,2}ESS[a-z0-9]+|NO_CACHE|OATMEAL|CHOCOLATECHIP)=\",\n \"; \\1=\"\n );\n # Remove from the header any single Cookie not prefixed with a space until\n # next ';' separator.\n set req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n # Remove any '; ' at the start or the end of the header.\n set req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n #If there are no remaining cookies, remove the cookie header.\n if ( req.http.Cookie == \"\" ) {\n unset req.http.Cookie;\n }\n }\n\n \/* 13th: Session cookie & special cookies bypass caching stage *\/\n # As we might want to cache some requests, hashed with its cookies, we don't\n # simply pass when some cookies remain present at this point.\n # Instead we look for request that must be passed due to the cookie header.\n if ( req.http.Cookie ~ \"SESS\"\n || req.http.Cookie ~ \"SSESS\"\n || req.http.Cookie ~ \"NO_CACHE\"\n || req.http.Cookie ~ \"OATMEAL\"\n || req.http.Cookie ~ \"CHOCOLATECHIP\"\n ) {\n return (pass);\n }\n\n \/* 14th: Announce ESI Support *\/\n # Empty in simple configs.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/esi.html\n # Note that ESI included requests inherits its parent's modified request, so\n # depending on the case you will end playing with req.esi_level to know\n # current depth.\n # Send Surrogate-Capability headers\n # See http:\/\/www.w3.org\/TR\/edge-arch\n # Note that myproxyname is an identifier that should avoid collitions\n # set req.http.Surrogate-Capability = \"myproxyname=ESI\/1.0\";\n\n \/* 15th: Bypass breakpoint 2 *\/\n # Useful for debugging we can now pipe or pass the request to backend to\n # bypass cache.\n # return (pipe);\n # return (pass);\n\n \/* 16th: Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n return (hash);\n}\n\n# vcl_pipe: Called upon entering pipe mode.\n# In this mode, the request is passed on to the backend, and any further data\n# from either client or backend is passed on unaltered until either end closes\n# the connection.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pipe\nsub vcl_pipe {\n # Websocket support\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html\n if ( req.http.upgrade ) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n}\n# sub vcl_pipe {\n# # By default Connection: close is set on all piped requests, to stop\n# # connection reuse from sending future requests directly to the\n# # (potentially) wrong backend. If you do want this to happen, you can undo\n# # it here.\n# # unset bereq.http.connection;\n# return (pipe);\n# }\n\n# vcl_pass: Called upon entering pass mode. \n# In this mode, the request is passed on to the backend, and the backend's\n# response is passed on to the client, but is not entered into the cache.\n# Subsequent requests submitted over the same client connection are handled normally.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pass\n# sub vcl_pass {\n# return (fetch);\n# }\n\n# vcl_hash: You may call hash_data() on the data you would like to add to the\n# hash.\n# Hash is used by Varnish to uniquely identify objects.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hash\nsub vcl_hash {\n \/* Hash cookie data *\/\n # As requests with same URL and host can produce diferent results when issued\n # with different cookies, we need to store items hashed with the associated\n # cookies. Note that cookies are already sanitized when we reach this point.\n if ( req.http.Cookie ) {\n \/* Include cookie in cache hash *\/\n hash_data(req.http.Cookie);\n }\n\n \/* Custom header hashing *\/\n # Empty in simple configs.\n # Example for caching differents object versions by device previously\n # detected (when static content could also vary):\n # if ( req.http.X-UA-Device ) {\n # hash_data(req.http.X-UA-Device);\n # }\n # Example for caching diferent object versions by X-Forwarded-Proto, trying\n # to be smart about what kind of request could generate diffetent responses.\n if ( req.http.X-Forwarded-Proto\n && req.url !~ \"(?i)\\.(bz2|css|eot|gif|gz|html?|ico|jpe?g|js|mp3|ogg|otf|pdf|png|rar|svg|swf|tbz|tgz|ttf|woff2?|zip)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n ) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (lookup);\n# }\n\n# vcl_purge: Called after the purge has been executed and all its variants have\n# been evited.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-purge\n# sub vcl_purge {\n# return (synth(200, \"Purged\"));\n# }\n\n# vcl_hit: Called after a cache lookup if the requested document was found in\n# the cache.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hit\nsub vcl_hit {\n if ( obj.ttl >= 0s ) {\n \/\/ A pure unadultered hit, deliver it\n return (deliver);\n }\n \/* Allow varnish to serve up stale content if it is responding slowly *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n if ( obj.ttl + 60s > 0s ) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n set req.http.grace = \"normal\";\n return (deliver);\n }\n \/* Allow varish to serve up stale content if all backends are down *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n if ( ! std.healthy(req.backend_hint)\n && obj.ttl + obj.grace > 0s\n ) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n set req.http.grace = \"extended\";\n return (deliver);\n }\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\n# vcl_miss: Called after a cache lookup if the requested document was not found\n# in the cache.\n# Its purpose is to decide whether or not to attempt to retrieve the document\n# from the backend, and which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-miss\n# sub vcl_miss {\n# return (fetch);\n# }\n\n# vcl_deliver: Called before an object is delivered to the client\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-deliver\nsub vcl_deliver {\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # Add whether the object is a cache hit or miss and the number of hits for\n # the object.\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Addingaheaderindicatinghitmiss\n # In Varnish 4 the obj.hits counter behaviour has changed (see bug 1492), so\n # we use a different method: if X-Varnish contains only 1 id, we have a miss,\n # if it contains more (and therefore a space), we have a hit.\n if ( resp.http.x-varnish ~ \" \" ) {\n set resp.http.X-Cache = \"HIT\";\n # Since in Varnish 4 the behaviour of obj.hits changed, this might not be\n # accurate.\n # See https:\/\/www.varnish-cache.org\/trac\/ticket\/1492\n set resp.http.X-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Cache = \"MISS\";\n \/* Show the results of cookie sanitization *\/\n set resp.http.X-Cookie = req.http.Cookie;\n }\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n set resp.http.grace = req.http.grace;\n\n #TODO# Add sick marker\n\n # Restart count\n if ( req.restarts > 0 ) {\n set resp.http.X-Restarts = req.restarts;\n }\n\n # Add the Varnish server hostname\n set resp.http.X-Varnish-Server = server.hostname;\n # If we have setted a custom header with device's family detected we can show\n # it:\n # if ( req.http.X-UA-Device ) {\n # set resp.http.X-UA-Device = req.http.X-UA-Device;\n # }\n # If we have recived a custom header indicating the protocol in the request we\n # can show it:\n # if ( req.http.X-Forwarded-Proto ) {\n # set resp.http.X-Forwarded-Proto = req.http.X-Forwarded-Proto;\n # }\n\n \/* Vary header manipulation *\/\n # Empty in simple configs.\n # By example, if we are storing & serving diferent objects depending on\n # User-Agent header we must set the correct Vary header:\n # if ( resp.http.Vary ) {\n # set resp.http.Vary = resp.http.Vary + \",User-Agent\";\n # } else {\n # set resp.http.Vary = \"User-Agent\";\n # }\n\n \/* Fake headers *\/\n # Empty in simple configs\n # We can fake server headers here, by example:\n # set resp.http.Server = \"Deep thought\";\n # set resp.http.X-Powered-By = \"BOFH\";\n # Or have some fun with headers:\n # See http:\/\/www.nextthing.org\/archives\/2005\/08\/07\/fun-with-http-headers\n # See http:\/\/royal.pingdom.com\/2012\/08\/15\/fun-and-unusual-http-response-headers\/\n # set resp.http.X-Thank-You = \"for bothering to look at my HTTP headers\";\n # set resp.http.X-Answer = \"42\";\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_deliver {\n# return (deliver);\n# }\n\n# vcl_synth: Called to deliver a synthetic object. A synthetic object is\n# generated in VCL, not fetched from the backend. It is typically contructed\n# using the synthetic() function.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-synth\n\/*\n * We can come here \"invisibly\" with the following errors: 413, 417 & 503\n *\/\nsub vcl_synth {\n \/* Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_synth;\n\n \/* Try to restart request in case of failure *\/\n # Note that max_restarts defaults to 4\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if ( resp.status == 503\n && req.restarts < 4\n ) {\n return (restart);\n }\n\n \/* Set common headers for synthetic responses *\/\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n\n \/* HTTP Authentification client request *\/\n # Empty in simple configs.\n # SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* Load synthetic responses from disk *\/\n # Note that files loaded this way are never re-readed (even after a reload).\n # You should consider PROS\/CONS of doing an include instead.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_std.generated.html#func-fileread\n # Example custom 403 error page.\n # if ( resp.status == 403 ) {\n # synthetic(std.fileread(\"\/403.html\"));\n # return (deliver);\n # }\n\n \/* Error page & refresh \/ redirections *\/\n # We have plenty of choices when we have to serve an error to the client, \n # from the default error page to javascript black magic or plain redirections.\n # Adding some external statistic javascript to track failures served to\n # clients is strongly suggested.\n # We can't use external resources on synthetic content, everything must be\n # inlined.\n # If we need to include images we can embed them in base64 encoding.\n # We're using error 200 for monitoring puposes which should not be retried\n # client side.\n if ( resp.status != 200 ) {\n set resp.http.Retry-After = \"5\";\n }\n\n # Here is the default error page for Varnish 4 (not so pretty)\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n return (deliver);\n}\n\n#######################################################################\n# Backend Fetch\n\n# vcl_backend_fetch: Called before sending the backend request. In this\n# subroutine you typically alter the request before it gets to the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-fetch\n# sub vcl_backend_fetch {\n# return (fetch);\n# }\n\n# vcl_backend_response: Called after the response headers has been successfully\n# retrieved from the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-response\nsub vcl_backend_response {\n \/* Caching exceptions *\/\n # Varnish will cache objects with response codes:\n # 200, 203, 300, 301, 302, 307, 404 & 410.\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/VCL_Basics.html#the-initial-value-of-beresp-ttl\n # Drupal's Imagecache module can return a 307 redirection to the requested\n # url itself and, depending on Drupal's cache settings, this could lead to a\n # redirection loop being cached for a long time but also we want Varnish to\n # shield a little the backend.\n # See http:\/\/drupal.org\/node\/1248010\n # See http:\/\/drupal.org\/node\/310656\n if ( beresp.status == 307\n #TODO# verify that this work better than 'bereq.url ~ \"imagecache\"'\n && beresp.http.Location == bereq.url\n && beresp.ttl > 5s\n ) {\n set beresp.ttl = 5s;\n set beresp.http.cache-control = \"max-age=5\";\n }\n\n \/* Request retrial *\/\n if ( beresp.status == 500\n || beresp.status == 503\n ) {\n #TODO# consider not restarting POST requests as seenV3 on https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleSaintMode\n return (retry);\n }\n\n \/* Enable grace mode. Related with vcl_hit *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n set beresp.grace = 1h;\n\n \/* Strip cookies from the following static file types for all users. *\/\n # Related with our 12th stage on vcl_recv\n if ( bereq.url ~ \"(?i)\\.(bz2|css|eot|gif|gz|html?|ico|jpe?g|js|mp3|ogg|otf|pdf|png|rar|svg|swf|tbz|tgz|ttf|woff2?|zip)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n ) {\n unset beresp.http.set-cookie;\n }\n\n \/* Process ESI responses *\/\n # Empty in simple configs.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/esi.html\n # Send Surrogate-Capability headers\n # See http:\/\/www.w3.org\/TR\/edge-arch\n # Note that myproxyname is an identifier that should avoid collitions\n # Check for ESI acknowledgement and remove Surrogate-Control header\n #TODO# Add support for Surrogate-Control Targetting\n # if ( beresp.http.Surrogate-Control ~ \"ESI\/1.0\" ) {\n # unset beresp.http.Surrogate-Control;\n # set beresp.do_esi = true;\n # }\n\n \/* Gzip response *\/\n # Empty in simple configs.\n # Use Varnish to Gzip respone, if suitable, before storing it on cache.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html\n if ( ! beresp.http.Content-Encoding\n && ( beresp.http.content-type ~ \"text\"\n || beresp.http.content-type ~ \"application\/x-javascript\"\n || beresp.http.content-type ~ \"application\/javascript\"\n || beresp.http.content-type ~ \"application\/rss+xml\"\n || beresp.http.content-type ~ \"application\/xml\"\n || beresp.http.content-type ~ \"Application\/JSON\")\n ) {\n set beresp.do_gzip = true;\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # We can add the name of the backend that has processed the request:\n # set beresp.http.X-Backend = beresp.backend.name;\n # We can use a header to tell if the object was gziped by Varnish:\n # if ( beresp.do_gzip ) {\n # set beresp.http.X-Varnish-Gzipped = \"yes\";\n # } else {\n # set beresp.http.X-Varnish-Gizipped = \"no\";\n # }\n # We can also add headers informing whether the object is cacheable or not and why:\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Varnish3.0\n if ( beresp.ttl <= 0s ) {\n \/* Varnish determined the object was not cacheable *\/\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n } elsif ( bereq.http.Cookie ~ \"(SESS|SSESS|NO_CACHE|OATMEAL|CHOCOLATECHIP)\" ) {\n \/* We don't wish to cache content for logged in users or with certain cookies. *\/\n # Related with our 9th stage on vcl_recv\n set beresp.http.X-Cacheable = \"NO:Cookies\";\n # set beresp.uncacheable = true;\n } elsif ( beresp.http.Cache-Control ~ \"private\" ) {\n \/* We are respecting the Cache-Control=private header from the backend *\/\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n # set beresp.uncacheable = true;\n } else {\n \/* Varnish determined the object was cacheable *\/\n set beresp.http.X-Cacheable = \"YES\";\n }\n\n \/* Further header manipulation *\/\n # Empty in simple configs.\n # We can also unset some headers to prevent information disclosure and save\n # some cache space.\n # unset beresp.http.Server;\n # unset beresp.http.X-Powered-By;\n # Retry count.\n if ( bereq.retries > 0 ) {\n set beresp.http.X-Retries = bereq.retries;\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_backend_response {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Surrogate-control ~ \"no-store\" ||\n# (!beresp.http.Surrogate-Control &&\n# beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n# beresp.http.Vary == \"*\") {\n# \/*\n# * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# *\/\n# set beresp.ttl = 120s;\n# set beresp.uncacheable = true;\n# }\n# return (deliver);\n# }\n\n# vcl_backend_error: This subroutine is called if we fail the backend fetch.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-error\nsub vcl_backend_error {\n\n \/* Try to restart request in case of failure *\/\n #TODO# Confirm max_retries default value\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if ( bereq.retries < 4 ) {\n return (retry);\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # Retry count\n if ( bereq.retries > 0 ) {\n set beresp.http.X-Retries = bereq.retries;\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + beresp.status + \" \" + beresp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + beresp.status + \" \" + beresp.reason + {\"<\/h1>\n <p>\"} + beresp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + bereq.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this\n # point.\n return (deliver);\n}\n\n#######################################################################\n# Housekeeping\n\n# vcl_init: Called when VCL is loaded, before any requests pass through it.\n# Typically used to initialize VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-init\n# Here is where you should declare your directors now.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-backends.html#directors\n# Empty in simple configs\n# sub vcl_init {\n# return (ok);\n# }\n\n# vcl_fini: Called when VCL is discarded only after all requests have exited\n# the VCL. Typically used to clean up VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-fini\n# sub vcl_fini {\n# return (ok);\n# }\n\n","old_contents":"\/*\n * Varnish 4 example config for Drupal 7 \/ Pressflow 6 & 7\n *\/\n\n# Original source: https:\/\/github.com\/NITEMAN\/varnish-bites\/varnish4\/drupal-base.vcl\n# Copyright (c) 2015 Pedro Gonz\u00e1lez Serrano and individual contributors.\n# MIT License\n\n# Intended to be used both in simple production environments and with\n# learning\/teaching purposes.\n# Some references may not be yet updated to VCL 4.0, we use SeeV3 then.\n\n# WARNING:\n# Note that the built-in logic will be appended to our code if no return is\n# performed before.\n# Built-in logic is included commented out right after our's for reference\n# purposes in that cases.\n# See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleDefault\n\n#######################################################################\n# Initialization: Version & imports;\n\n\/* Version statement *\/\n# Since Varnish 4.0 it's mandatory to declare VCL version on first line.\nvcl 4.0;\n\n\/* Module (VMOD) imports *\/\n# Standard module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_std.generated.html\nimport std;\n\n# Directors module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# Unused in simple configs.\n#import directors;\n\n\n#######################################################################\n# Probe, backend, ACL and subroutine definitions\n\n\/* Backend probes \/ healthchecks *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#probes\nprobe basic {\n \/* Only test that backend's IP serves content for '\/' *\/\n # This might be a too heavy probe\n # .url = \"\/\";\n\n \/* Only test that backend's IP has apache working *\/\n # Nginx would fail this probe with a default config\n .request =\n \"OPTIONS * HTTP\/1.1\"\n \"Host: *\"\n \"Connection: close\";\n\n \/* Common options *\/\n .interval = 10s;\n .timeout = 2s;\n .window = 8;\n .threshold = 6;\n}\n\n\/* Backend definitions.*\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#backend-definition\nbackend default {\n \/* Default backend on the same machine. *\/\n # WARNING: timeouts could be not big enought for certain POST requests.\n .host = \"127.0.0.1\";\n .port = \"8008\";\n .max_connections = 100;\n .connect_timeout = 60s;\n .first_byte_timeout = 60s;\n .between_bytes_timeout = 60s;\n .probe = basic;\n}\n\n\/* Access Control Lists *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#access-control-list-acl\nacl purge_ban {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use '\"localhost\";' instead\n}\nacl allowed_monitors {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n}\n# acl own_proxys {\n# \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n# }\n\n\/* Custom subroutines *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#subroutines\n#TODO# Test in Varnihs 4\n# Empty in simple configs.\n# The only restriction naming subs is that the 'vlc_' prefix is reserverd for\n# Varnish use. As a task can need several chunks of code in diferent states,\n# it's a good idea to identify what main sub will call each with a suffix.\n# \/* Example 301 client redirection removing \"www\" prefix from request *\/\n# sub perm_redirections_recv {\n# if ( req.http.host ~ \"^www.*$\" ) {\n# return(\n# synth(751, \"http:\/\/\" + regsub(req.http.host, \"^www\\.\", \"\") + req.url)\n# );\n# }\n# }\n# sub perm_redirections_synth {\n# if (resp.status == 751) {\n# \/* Get new URL from the response *\/\n# set resp.http.Location = resp.response;\n# \/* Set HTTP 301 for permanent redirect *\/\n# set resp.status = 301;\n# return (deliver);\n# }\n# }\n\n\n#######################################################################\n# Client side\n\n# vcl_recv: Called at the beginning of a request, after the complete request\n# has been received and parsed. Its purpose is to decide whether or not to\n# serve the request, how to do it, and, if applicable, which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-recv\nsub vcl_recv {\n \/* 0th: general bypass, general return & authorization checks *\/\n # Empty in simple configs.\n # Useful for debugging we can pipe or pass the request to default backend\n # here to bypass completely Varnish.\n # return (pipe);\n # return (pass);\n # We can also return here a 200 Ok for network performance benchmarking.\n # return(synth(200, \"Ok\"));\n # Finally we can perform basic HTTP authentification here, by example.\n # SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* 1st: Check for Varnish special requests *\/ \n # Custom response implementation example in order to check that Varnish is\n # working properly.\n # This is usefull for automatic monitoring with monit or when Varnish is\n # behind another proxies like HAProxy.\n if ( ( req.http.host == \"monitor.server.health\"\n || req.http.host == \"health.varnish\" )\n && client.ip ~ allowed_monitors\n && ( req.method == \"OPTIONS\" || req.method == \"GET\" )\n ) {\n return(synth(200, \"Ban added\"));\n }\n # Purge logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#http-purging\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if ( req.method == \"PURGE\" ) {\n if ( ! client.ip ~ purge_ban ) {\n return(synth(405, \"Not allowed.\"));\n }\n return (purge);\n }\n # Ban logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#bans\n if ( req.method == \"BAN\" ) {\n if ( ! client.ip ~ purge_ban ) {\n return(synth(405, \"Not allowed.\"));\n }\n ban( \"req.http.host == \" + req.http.host +\n \"&& req.url == \" + req.url);\n return(synth(200, \"Ban added\"));\n }\n\n \/* 2nd: Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_recv;\n # Here we can also enforce SSL when Varnish run behind some SSL termination\n # point.\n\n \/* 3rd: Time for backend choice *\/\n # Empty in simple configs.\n\n \/* 4th: Prepare request for the backend *\/\n # Empty in simple configs.\n # Example remove own_proxys from X-Forwarded-For\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/whats-new\/upgrading.html#x-forwarded-for-is-now-set-before-vcl-recv\n # if ( req.restarts == 0\n # && client.ip ~ own_proxys\n # && req.http.x-forwarded-for\n # ) {\n # set req.http.X-Forwarded-For\n # = regsub(req.http.X-Forwarded-For, \",( )?\" + client.ip, \"\");\n # }\n # Example normalize the host header, remove the port (in case you're testing\n # this on various TCP ports)\n # set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n \/* 5th: Bypass breakpoint 1 *\/\n # Useful for debugging we can now pipe or pass the request to backend with\n # headers setted.\n # return (pipe);\n # return (pass);\n\n \/* 6th: Decide if we should deal with a request (mostly from built-in logic) *\/\n if (req.method == \"PRI\") {\n \/* We do not support SPDY or HTTP\/2.0 *\/\n return (synth(405));\n }\n if ( req.method != \"GET\"\n && req.method != \"HEAD\"\n && req.method != \"PUT\"\n && req.method != \"POST\"\n && req.method != \"TRACE\"\n && req.method != \"OPTIONS\"\n && req.method != \"DELETE\"\n ) {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n # Websocket support\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n \/* 7th: Access control for some URLs by ACL *\/\n # Empty in simple configs.\n # By example denial some URLs depending on client-ip, we'll need to define\n # corresponding ACL 'internal'.\n # if ( req.url ~ \"^\/(cron|install)\\.php\"\n # && ! client.ip ~ internal\n # ) {\n # # Have Varnish throw the error directly.\n # return(synth(403, \"Forbidden.\"));\n # # Use a custom error page that you've defined in Drupal at the path \"404\".\n # # set req.url = \"\/403\";\n # }\n\n \/* 8th: Custom exceptions *\/\n # Host exception example:\n # if (req.http.host == \"ejemplo.exception.com\") {\n # return (pass);\n # }\n # Drupal exceptions, edit if we want to cache some AJAX\/AHAH request.\n # Add here filters for never cache URLs such as Payment Gateway's callbacks.\n if ( req.url ~ \"^\/status\\.php$\"\n || req.url ~ \"^\/update\\.php$\"\n || req.url ~ \"^\/ooyala\/ping$\"\n || req.url ~ \"^\/admin\/build\/features\"\n || req.url ~ \"^\/info\/.*$\"\n || req.url ~ \"^\/flag\/.*$\"\n || req.url ~ \"^.*\/ajax\/.*$\"\n || req.url ~ \"^.*\/ahah\/.*$\"\n ) {\n \/* Do not cache these paths *\/\n return (pass);\n }\n # Pipe these paths directly to backend for streaming.\n if (req.url ~ \"^\/admin\/content\/backup_migrate\/export\") {\n return (pipe);\n }\n if (req.url ~ \"^\/system\/files\") {\n return (pipe);\n }\n\n \/* 9th: Graced objets & Serve from anonymous cahe if all backends are down *\/\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n # set req.http.grace = \"none\";\n if ( ! std.healthy(req.backend_hint) ) {\n # We must do this here since cookie hashing\n unset req.http.Cookie;\n #TODO# Add sick marker\n } \n\n \/* 10th: Deal with compression and the Accept-Encoding header *\/\n # Althought Varnish 3 handles gziped content itself by default, just to be\n # sure we want to remove Accept-Encoding for some compressed formats.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html#what-does-http-gzip-support-do\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/varnishd.html?highlight=http_gzip_support\n # See (for older configs) https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleNormalizeAcceptEncoding\n if (req.http.Accept-Encoding) {\n if ( req.url ~ \"(?i)\\.(7z|avi|bz2|flv|gif|gz|jpe?g|mpe?g|mk[av]|mov|mp[34]|og[gm]|pdf|png|rar|swf|tar|tbz|tgz|woff2?|zip|xz)(\\?.*)?$\"\n ) {\n \/* Already compressed formats, no sense trying to compress again *\/\n unset req.http.Accept-Encoding;\n }\n }\n\n \/* 11th: Another request manipulation *\/\n # Empty in simple configs.\n # We could add here a custom header grouping User-agent families.\n\n \/* 12th: Cookie removal *\/\n # Always cache the following static file types for all users. \n # Use with care if we control certain downloads depending on cookies. \n # Be carefull also if appending .htm[l] via Drupal's clean URLs.\n if ( req.url ~ \"(?i)\\.(bz2|css|eot|gif|gz|html?|ico|jpe?g|js|mp3|ogg|otf|pdf|png|rar|svg|swf|tbz|tgz|ttf|woff2?|zip)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n && ! req.url ~ \"\/system\/storage\/serve\"\n ) {\n unset req.http.Cookie;\n }\n # Remove all cookies that backend doesn't need to know about.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRemovingSomeCookies\n if (req.http.Cookie) {\n \/* Warning: Not a pretty solution *\/\n # Prefix header containing cookies with ';'\n set req.http.Cookie = \";\" + req.http.Cookie;\n # Remove any spaces after ';' in header containing cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n # Prefix cookies we want to preserve with one space:\n # 'S{1,2}ESS[a-z0-9]+' is the regular expression matching a Drupal session\n # cookie ({1,2} added for HTTPS support).\n # 'NO_CACHE' is usually set after a POST request to make sure issuing user\n # see the results of his post.\n # 'OATMEAL' & 'CHOCOLATECHIP' are special cookies used by Drupal's Bakery\n # module to provide Single Sign On.\n # Keep in mind we should add here any cookie that should reach the backend\n # such as splash avoiding cookies.\n set req.http.Cookie\n = regsuball(\n req.http.Cookie,\n \";(S{1,2}ESS[a-z0-9]+|NO_CACHE|OATMEAL|CHOCOLATECHIP)=\",\n \"; \\1=\"\n );\n # Remove from the header any single Cookie not prefixed with a space until\n # next ';' separator.\n set req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n # Remove any '; ' at the start or the end of the header.\n set req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n #If there are no remaining cookies, remove the cookie header.\n if (req.http.Cookie == \"\") {\n unset req.http.Cookie;\n }\n }\n\n \/* 13th: Session cookie & special cookies bypass caching stage *\/\n # As we might want to cache some requests, hashed with its cookies, we don't\n # simply pass when some cookies remain present at this point.\n # Instead we look for request that must be passed due to the cookie header.\n if ( req.http.Cookie ~ \"SESS\"\n || req.http.Cookie ~ \"SSESS\"\n || req.http.Cookie ~ \"NO_CACHE\"\n || req.http.Cookie ~ \"OATMEAL\"\n || req.http.Cookie ~ \"CHOCOLATECHIP\"\n ) {\n return (pass);\n }\n\n \/* 14th: Announce ESI Support *\/\n # Empty in simple configs.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/esi.html\n # Note that ESI included requests inherits its parent's modified request, so\n # depending on the case you will end playing with req.esi_level to know\n # current depth.\n # Send Surrogate-Capability headers\n # See http:\/\/www.w3.org\/TR\/edge-arch\n # Note that myproxyname is an identifier that should avoid collitions\n # set req.http.Surrogate-Capability = \"myproxyname=ESI\/1.0\";\n\n \/* 15th: Bypass breakpoint 2 *\/\n # Useful for debugging we can now pipe or pass the request to backend to\n # bypass cache.\n # return (pipe);\n # return (pass);\n\n \/* 16th: Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n return (hash);\n}\n\n# vcl_pipe: Called upon entering pipe mode.\n# In this mode, the request is passed on to the backend, and any further data\n# from either client or backend is passed on unaltered until either end closes\n# the connection.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pipe\nsub vcl_pipe {\n # Websocket support\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n}\n# sub vcl_pipe {\n# # By default Connection: close is set on all piped requests, to stop\n# # connection reuse from sending future requests directly to the\n# # (potentially) wrong backend. If you do want this to happen, you can undo\n# # it here.\n# # unset bereq.http.connection;\n# return (pipe);\n# }\n\n# vcl_pass: Called upon entering pass mode. \n# In this mode, the request is passed on to the backend, and the backend's\n# response is passed on to the client, but is not entered into the cache.\n# Subsequent requests submitted over the same client connection are handled normally.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pass\n# sub vcl_pass {\n# return (fetch);\n# }\n\n# vcl_hash: You may call hash_data() on the data you would like to add to the\n# hash.\n# Hash is used by Varnish to uniquely identify objects.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hash\nsub vcl_hash {\n \/* Hash cookie data *\/\n # As requests with same URL and host can produce diferent results when issued\n # with different cookies, we need to store items hashed with the associated\n # cookies. Note that cookies are already sanitized when we reach this point.\n if (req.http.Cookie) {\n \/* Include cookie in cache hash *\/\n hash_data(req.http.Cookie);\n }\n\n \/* Custom header hashing *\/\n # Empty in simple configs.\n # Example for caching differents object versions by device previously\n # detected (when static content could also vary):\n # if (req.http.X-UA-Device) {\n # hash_data(req.http.X-UA-Device);\n # }\n # Example for caching diferent object versions by X-Forwarded-Proto, trying\n # to be smart about what kind of request could generate diffetent responses.\n if ( req.http.X-Forwarded-Proto\n && req.url !~ \"(?i)\\.(bz2|css|eot|gif|gz|html?|ico|jpe?g|js|mp3|ogg|otf|pdf|png|rar|svg|swf|tbz|tgz|ttf|woff2?|zip)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n ) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (lookup);\n# }\n\n# vcl_purge: Called after the purge has been executed and all its variants have\n# been evited.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-purge\n# sub vcl_purge {\n# return (synth(200, \"Purged\"));\n# }\n\n# vcl_hit: Called after a cache lookup if the requested document was found in\n# the cache.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hit\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n \/\/ A pure unadultered hit, deliver it\n return (deliver);\n }\n \/* Allow varnish to serve up stale content if it is responding slowly *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n if (obj.ttl + 60s > 0s) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n set req.http.grace = \"normal\";\n return (deliver);\n }\n \/* Allow varish to serve up stale content if all backends are down *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n if ( ! std.healthy(req.backend_hint)\n && obj.ttl + obj.grace > 0s\n ) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n set req.http.grace = \"extended\";\n return (deliver);\n }\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\n# vcl_miss: Called after a cache lookup if the requested document was not found\n# in the cache.\n# Its purpose is to decide whether or not to attempt to retrieve the document\n# from the backend, and which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-miss\n# sub vcl_miss {\n# return (fetch);\n# }\n\n# vcl_deliver: Called before an object is delivered to the client\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-deliver\nsub vcl_deliver {\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # Add whether the object is a cache hit or miss and the number of hits for\n # the object.\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Addingaheaderindicatinghitmiss\n # In Varnish 4 the obj.hits counter behaviour has changed (see bug 1492), so\n # we use a different method: if X-Varnish contains only 1 id, we have a miss,\n # if it contains more (and therefore a space), we have a hit.\n if (resp.http.x-varnish ~ \" \") {\n set resp.http.X-Cache = \"HIT\";\n # Since in Varnish 4 the behaviour of obj.hits changed, this might not be\n # accurate.\n # See https:\/\/www.varnish-cache.org\/trac\/ticket\/1492\n set resp.http.X-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Cache = \"MISS\";\n \/* Show the results of cookie sanitization *\/\n set resp.http.X-Cookie = req.http.Cookie;\n }\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n set resp.http.grace = req.http.grace;\n\n #TODO# Add sick marker\n\n # Restart count\n if ( req.restarts > 0) {\n set resp.http.X-Restarts = req.restarts;\n }\n\n # Add the Varnish server hostname\n set resp.http.X-Varnish-Server = server.hostname;\n # If we have setted a custom header with device's family detected we can show\n # it:\n # if (req.http.X-UA-Device) {\n # set resp.http.X-UA-Device = req.http.X-UA-Device;\n # }\n # If we have recived a custom header indicating the protocol in the request we\n # can show it:\n # if (req.http.X-Forwarded-Proto) {\n # set resp.http.X-Forwarded-Proto = req.http.X-Forwarded-Proto;\n # }\n\n \/* Vary header manipulation *\/\n # Empty in simple configs.\n # By example, if we are storing & serving diferent objects depending on\n # User-Agent header we must set the correct Vary header:\n # if (resp.http.Vary) {\n # set resp.http.Vary = resp.http.Vary + \",User-Agent\";\n # } else {\n # set resp.http.Vary = \"User-Agent\";\n # }\n\n \/* Fake headers *\/\n # Empty in simple configs\n # We can fake server headers here, by example:\n # set resp.http.Server = \"Deep thought\";\n # set resp.http.X-Powered-By = \"BOFH\";\n # Or have some fun with headers:\n # See http:\/\/www.nextthing.org\/archives\/2005\/08\/07\/fun-with-http-headers\n # See http:\/\/royal.pingdom.com\/2012\/08\/15\/fun-and-unusual-http-response-headers\/\n # set resp.http.X-Thank-You = \"for bothering to look at my HTTP headers\";\n # set resp.http.X-Answer = \"42\";\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_deliver {\n# return (deliver);\n# }\n\n# vcl_synth: Called to deliver a synthetic object. A synthetic object is\n# generated in VCL, not fetched from the backend. It is typically contructed\n# using the synthetic() function.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-synth\n\/*\n * We can come here \"invisibly\" with the following errors: 413, 417 & 503\n *\/\nsub vcl_synth {\n \/* Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_synth;\n\n \/* Try to restart request in case of failure *\/\n # Note that max_restarts defaults to 4\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if (resp.status == 503 && req.restarts < 4) {\n return(restart);\n }\n\n \/* Set common headers for synthetic responses *\/\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n\n \/* HTTP Authentification client request *\/\n # Empty in simple configs.\n # SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* Load synthetic responses from disk *\/\n # Note that files loaded this way are never re-readed (even after a reload).\n # You should consider PROS\/CONS of doing an include instead.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_std.generated.html#func-fileread\n # Example custom 403 error page.\n # if (resp.status == 403) {\n # synthetic(std.fileread(\"\/403.html\"));\n # return(deliver);\n # }\n\n \/* Error page & refresh \/ redirections *\/\n # We have plenty of choices when we have to serve an error to the client, \n # from the default error page to javascript black magic or plain redirections.\n # Adding some external statistic javascript to track failures served to\n # clients is strongly suggested.\n # We can't use external resources on synthetic content, everything must be\n # inlined.\n # If we need to include images we can embed them in base64 encoding.\n # We're using error 200 for monitoring puposes which should not be retried\n # client side.\n if ( resp.status != 200) {\n set resp.http.Retry-After = \"5\";\n }\n\n # Here is the default error page for Varnish 4 (not so pretty)\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n return (deliver);\n}\n\n#######################################################################\n# Backend Fetch\n\n# vcl_backend_fetch: Called before sending the backend request. In this\n# subroutine you typically alter the request before it gets to the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-fetch\n# sub vcl_backend_fetch {\n# return (fetch);\n# }\n\n# vcl_backend_response: Called after the response headers has been successfully\n# retrieved from the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-response\nsub vcl_backend_response {\n \/* Caching exceptions *\/\n # Varnish will cache objects with response codes:\n # 200, 203, 300, 301, 302, 307, 404 & 410.\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/VCL_Basics.html#the-initial-value-of-beresp-ttl\n # Drupal's Imagecache module can return a 307 redirection to the requested\n # url itself and, depending on Drupal's cache settings, this could lead to a\n # redirection loop being cached for a long time but also we want Varnish to\n # shield a little the backend.\n # See http:\/\/drupal.org\/node\/1248010\n # See http:\/\/drupal.org\/node\/310656\n if ( beresp.status == 307\n #TODO# verify that this work better than 'bereq.url ~ \"imagecache\"'\n && beresp.http.Location == bereq.url\n && beresp.ttl > 5s\n ) {\n set beresp.ttl = 5s;\n set beresp.http.cache-control = \"max-age=5\";\n }\n\n \/* Request retrial *\/\n if ( beresp.status == 500\n || beresp.status == 503\n ) {\n #TODO# consider not restarting POST requests as seenV3 on https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleSaintMode\n return (retry);\n }\n\n \/* Enable grace mode. Related with vcl_hit *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n set beresp.grace = 1h;\n\n \/* Strip cookies from the following static file types for all users. *\/\n # Related with our 12th stage on vcl_recv\n if ( bereq.url ~ \"(?i)\\.(bz2|css|eot|gif|gz|html?|ico|jpe?g|js|mp3|ogg|otf|pdf|png|rar|svg|swf|tbz|tgz|ttf|woff2?|zip)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n ) {\n unset beresp.http.set-cookie;\n }\n\n \/* Process ESI responses *\/\n # Empty in simple configs.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/esi.html\n # Send Surrogate-Capability headers\n # See http:\/\/www.w3.org\/TR\/edge-arch\n # Note that myproxyname is an identifier that should avoid collitions\n # Check for ESI acknowledgement and remove Surrogate-Control header\n #TODO# Add support for Surrogate-Control Targetting\n # if ( beresp.http.Surrogate-Control ~ \"ESI\/1.0\" ) {\n # unset beresp.http.Surrogate-Control;\n # set beresp.do_esi = true;\n # }\n\n \/* Gzip response *\/\n # Empty in simple configs.\n # Use Varnish to Gzip respone, if suitable, before storing it on cache.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html\n if ( ! beresp.http.Content-Encoding\n && ( beresp.http.content-type ~ \"text\"\n || beresp.http.content-type ~ \"application\/x-javascript\"\n || beresp.http.content-type ~ \"application\/javascript\"\n || beresp.http.content-type ~ \"application\/rss+xml\"\n || beresp.http.content-type ~ \"application\/xml\"\n || beresp.http.content-type ~ \"Application\/JSON\")\n ) {\n set beresp.do_gzip = true;\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # We can add the name of the backend that has processed the request:\n # set beresp.http.X-Backend = beresp.backend.name;\n # We can use a header to tell if the object was gziped by Varnish:\n # if (beresp.do_gzip) {\n # set beresp.http.X-Varnish-Gzipped = \"yes\";\n # } else {\n # set beresp.http.X-Varnish-Gizipped = \"no\";\n # }\n # We can also add headers informing whether the object is cacheable or not and why:\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Varnish3.0\n if (beresp.ttl <= 0s) {\n \/* Varnish determined the object was not cacheable *\/\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n } elsif (bereq.http.Cookie ~ \"(SESS|SSESS|NO_CACHE|OATMEAL|CHOCOLATECHIP)\") {\n \/* We don't wish to cache content for logged in users or with certain cookies. *\/\n # Related with our 9th stage on vcl_recv\n set beresp.http.X-Cacheable = \"NO:Cookies\";\n # set beresp.uncacheable = true;\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n \/* We are respecting the Cache-Control=private header from the backend *\/\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n # set beresp.uncacheable = true;\n } else {\n \/* Varnish determined the object was cacheable *\/\n set beresp.http.X-Cacheable = \"YES\";\n }\n\n \/* Further header manipulation *\/\n # Empty in simple configs.\n # We can also unset some headers to prevent information disclosure and save\n # some cache space.\n # unset beresp.http.Server;\n # unset beresp.http.X-Powered-By;\n # Retry count.\n if ( bereq.retries > 0) {\n set beresp.http.X-Retries = bereq.retries;\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_backend_response {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Surrogate-control ~ \"no-store\" ||\n# (!beresp.http.Surrogate-Control &&\n# beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n# beresp.http.Vary == \"*\") {\n# \/*\n# * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# *\/\n# set beresp.ttl = 120s;\n# set beresp.uncacheable = true;\n# }\n# return (deliver);\n# }\n\n# vcl_backend_error: This subroutine is called if we fail the backend fetch.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-error\nsub vcl_backend_error {\n\n \/* Try to restart request in case of failure *\/\n #TODO# Confirm max_retries default value\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if (bereq.retries < 4) {\n return (retry);\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # Retry count\n if ( bereq.retries > 0) {\n set beresp.http.X-Retries = bereq.retries;\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + beresp.status + \" \" + beresp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + beresp.status + \" \" + beresp.reason + {\"<\/h1>\n <p>\"} + beresp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + bereq.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this\n # point.\n return (deliver);\n}\n\n#######################################################################\n# Housekeeping\n\n# vcl_init: Called when VCL is loaded, before any requests pass through it.\n# Typically used to initialize VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-init\n# Here is where you should declare your directors now.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-backends.html#directors\n# Empty in simple configs\n# sub vcl_init {\n# return (ok);\n# }\n\n# vcl_fini: Called when VCL is discarded only after all requests have exited\n# the VCL. Typically used to clean up VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-fini\n# sub vcl_fini {\n# return (ok);\n# }\n\n","returncode":0,"stderr":"","license":"unknown","lang":"VCL"} {"commit":"2df2ebb3854d5b9409a78c0601ab669ab08b5f01","subject":"add websocket support","message":"add websocket support\n","repos":"NITEMAN\/Varnish_VCL_samps-hacks,NITEMAN\/varnish-bites","old_file":"varnish4\/drupal-base.vcl","new_file":"varnish4\/drupal-base.vcl","new_contents":"\/*\n * Varnish 4 example config for Drupal 7 \/ Pressflow 6 & 7\n *\/\n\n# Original source: https:\/\/github.com\/NITEMAN\/varnish-bites\/varnish4\/drupal-base.vcl\n# Copyright (c) 2015 Pedro Gonz\u00e1lez Serrano and individual contributors.\n# MIT License\n\n# Intended to be used both in simple production environments and with\n# learning\/teaching purposes.\n# Some references may not be yet updated to VCL 4.0, we use SeeV3 then.\n\n# WARNING:\n# Note that the built-in logic will be appended to our code if no return is\n# performed before.\n# Built-in logic is included commented out right after our's for reference\n# purposes in that cases.\n# See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleDefault\n\n#######################################################################\n# Initialization: Version & imports;\n\n\/* Version statement *\/\n# Since Varnish 4.0 it's mandatory to declare VCL version on first line.\nvcl 4.0;\n\n\/* Module (VMOD) imports *\/\n# Standard module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_std.generated.html\nimport std;\n\n# Directors module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# Unused in simple configs.\n#import directors;\n\n\n#######################################################################\n# Probe, backend, ACL and subroutine definitions\n\n\/* Backend probes \/ healthchecks *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#probes\nprobe basic {\n \/* Only test that backend's IP serves content for '\/' *\/\n # This might be a too heavy probe\n # .url = \"\/\";\n\n \/* Only test that backend's IP has apache working *\/\n # Nginx would fail this probe with a default config\n .request =\n \"OPTIONS * HTTP\/1.1\"\n \"Host: *\"\n \"Connection: close\";\n\n \/* Common options *\/\n .interval = 10s;\n .timeout = 2s;\n .window = 8;\n .threshold = 6;\n}\n\n\/* Backend definitions.*\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#backend-definition\nbackend default {\n \/* Default backend on the same machine. *\/\n # WARNING: timeouts could be not big enought for certain POST requests.\n .host = \"127.0.0.1\";\n .port = \"8008\";\n .max_connections = 100;\n .connect_timeout = 60s;\n .first_byte_timeout = 60s;\n .between_bytes_timeout = 60s;\n .probe = basic;\n}\n\n\/* Access Control Lists *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#access-control-list-acl\nacl purge_ban {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use '\"localhost\";' instead\n}\nacl allowed_monitors {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n}\n# acl own_proxys {\n# \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n# }\n\n\/* Custom subroutines *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#subroutines\n#TODO# Test in Varnihs 4\n# Empty in simple configs.\n# The only restriction naming subs is that the 'vlc_' prefix is reserverd for\n# Varnish use. As a task can need several chunks of code in diferent states,\n# it's a good idea to identify what main sub will call each with a suffix.\n# \/* Example 301 client redirection removing \"www\" prefix from request *\/\n# sub perm_redirections_recv {\n# if ( req.http.host ~ \"^www.*$\" ) {\n# return(\n# synth(751, \"http:\/\/\" + regsub(req.http.host, \"^www\\.\", \"\") + req.url)\n# );\n# }\n# }\n# sub perm_redirections_synth {\n# if (resp.status == 751) {\n# \/* Get new URL from the response *\/\n# set resp.http.Location = resp.response;\n# \/* Set HTTP 301 for permanent redirect *\/\n# set resp.status = 301;\n# return (deliver);\n# }\n# }\n\n\n#######################################################################\n# Client side\n\n# vcl_recv: Called at the beginning of a request, after the complete request\n# has been received and parsed. Its purpose is to decide whether or not to\n# serve the request, how to do it, and, if applicable, which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-recv\nsub vcl_recv {\n \/* 0th: general bypass, general return & authorization checks *\/\n # Empty in simple configs.\n # Useful for debugging we can pipe or pass the request to default backend\n # here to bypass completely Varnish.\n # return (pipe);\n # return (pass);\n # We can also return here a 200 Ok for network performance benchmarking.\n # return(synth(200, \"Ok\"));\n # Finally we can perform basic HTTP authentification here, by example.\n # SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* 1st: Check for Varnish special requests *\/ \n # Custom response implementation example in order to check that Varnish is\n # working properly.\n # This is usefull for automatic monitoring with monit or when Varnish is\n # behind another proxies like HAProxy.\n if ( ( req.http.host == \"monitor.server.health\"\n || req.http.host == \"health.varnish\" )\n && client.ip ~ allowed_monitors\n && ( req.method == \"OPTIONS\" || req.method == \"GET\" )\n ) {\n return(synth(200, \"Ban added\"));\n }\n # Purge logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#http-purging\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if ( req.method == \"PURGE\" ) {\n if ( ! client.ip ~ purge_ban ) {\n return(synth(405, \"Not allowed.\"));\n }\n return (purge);\n }\n # Ban logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#bans\n if ( req.method == \"BAN\" ) {\n if ( ! client.ip ~ purge_ban ) {\n return(synth(405, \"Not allowed.\"));\n }\n ban( \"req.http.host == \" + req.http.host +\n \"&& req.url == \" + req.url);\n return(synth(200, \"Ban added\"));\n }\n\n \/* 2nd: Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_recv;\n # Here we can also enforce SSL when Varnish run behind some SSL termination\n # point.\n\n \/* 3rd: Time for backend choice *\/\n # Empty in simple configs.\n\n \/* 4th: Prepare request for the backend *\/\n # Empty in simple configs.\n # Example remove own_proxys from X-Forwarded-For\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/whats-new\/upgrading.html#x-forwarded-for-is-now-set-before-vcl-recv\n # if ( req.restarts == 0\n # && client.ip ~ own_proxys\n # && req.http.x-forwarded-for\n # ) {\n # set req.http.X-Forwarded-For\n # = regsub(req.http.X-Forwarded-For, \",( )?\" + client.ip, \"\");\n # }\n # Example normalize the host header, remove the port (in case you're testing\n # this on various TCP ports)\n # set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n \/* 5th: Bypass breakpoint 1 *\/\n # Useful for debugging we can now pipe or pass the request to backend with\n # headers setted.\n # return (pipe);\n # return (pass);\n\n \/* 6th: Decide if we should deal with a request (mostly from built-in logic) *\/\n if (req.method == \"PRI\") {\n \/* We do not support SPDY or HTTP\/2.0 *\/\n return (synth(405));\n }\n if ( req.method != \"GET\"\n && req.method != \"HEAD\"\n && req.method != \"PUT\"\n && req.method != \"POST\"\n && req.method != \"TRACE\"\n && req.method != \"OPTIONS\"\n && req.method != \"DELETE\"\n ) {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n # Websocket support\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n \/* 7th: Access control for some URLs by ACL *\/\n # Empty in simple configs.\n # By example denial some URLs depending on client-ip, we'll need to define\n # corresponding ACL 'internal'.\n # if ( req.url ~ \"^\/(cron|install)\\.php\"\n # && ! client.ip ~ internal\n # ) {\n # # Have Varnish throw the error directly.\n # return(synth(403, \"Forbidden.\"));\n # # Use a custom error page that you've defined in Drupal at the path \"404\".\n # # set req.url = \"\/403\";\n # }\n\n \/* 8th: Custom exceptions *\/\n # Host exception example:\n # if (req.http.host == \"ejemplo.exception.com\") {\n # return (pass);\n # }\n # Drupal exceptions, edit if we want to cache some AJAX\/AHAH request.\n # Add here filters for never cache URLs such as Payment Gateway's callbacks.\n if ( req.url ~ \"^\/status\\.php$\"\n || req.url ~ \"^\/update\\.php$\"\n || req.url ~ \"^\/ooyala\/ping$\"\n || req.url ~ \"^\/admin\/build\/features\"\n || req.url ~ \"^\/info\/.*$\"\n || req.url ~ \"^\/flag\/.*$\"\n || req.url ~ \"^.*\/ajax\/.*$\"\n || req.url ~ \"^.*\/ahah\/.*$\"\n ) {\n \/* Do not cache these paths *\/\n return (pass);\n }\n # Pipe these paths directly to backend for streaming.\n if (req.url ~ \"^\/admin\/content\/backup_migrate\/export\") {\n return (pipe);\n }\n if (req.url ~ \"^\/system\/files\") {\n return (pipe);\n }\n\n \/* 9th: Graced objets & Serve from anonymous cahe if all backends are down *\/\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n # set req.http.grace = \"none\";\n if ( ! std.healthy(req.backend_hint) ) {\n # We must do this here since cookie hashing\n unset req.http.Cookie;\n #TODO# Add sick marker\n } \n\n \/* 10th: Deal with compression and the Accept-Encoding header *\/\n # Althought Varnish 3 handles gziped content itself by default, just to be\n # sure we want to remove Accept-Encoding for some compressed formats.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html#what-does-http-gzip-support-do\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/varnishd.html?highlight=http_gzip_support\n # See (for older configs) https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleNormalizeAcceptEncoding\n if (req.http.Accept-Encoding) {\n if ( req.url\n ~ \"\\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|mp4|flv|zip|rar)$\"\n ) {\n \/* Already compressed formats, no sense trying to compress again *\/\n unset req.http.Accept-Encoding;\n }\n }\n\n \/* 11th: Another request manipulation *\/\n # Empty in simple configs.\n # We could add here a custom header grouping User-agent families.\n\n \/* 12th: Cookie removal *\/\n # Always cache the following static file types for all users. \n # Use with care if we control certain downloads depending on cookies. \n # Be carefull also if appending .htm[l] via Drupal's clean URLs.\n if ( req.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|woff2|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n && ! req.url ~ \"\/system\/storage\/serve\"\n ) {\n unset req.http.Cookie;\n }\n # Remove all cookies that backend doesn't need to know about.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRemovingSomeCookies\n if (req.http.Cookie) {\n \/* Warning: Not a pretty solution *\/\n # Prefix header containing cookies with ';'\n set req.http.Cookie = \";\" + req.http.Cookie;\n # Remove any spaces after ';' in header containing cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n # Prefix cookies we want to preserve with one space:\n # 'S{1,2}ESS[a-z0-9]+' is the regular expression matching a Drupal session\n # cookie ({1,2} added for HTTPS support).\n # 'NO_CACHE' is usually set after a POST request to make sure issuing user\n # see the results of his post.\n # 'OATMEAL' & 'CHOCOLATECHIP' are special cookies used by Drupal's Bakery\n # module to provide Single Sign On.\n # Keep in mind we should add here any cookie that should reach the backend\n # such as splash avoiding cookies.\n set req.http.Cookie\n = regsuball(\n req.http.Cookie,\n \";(S{1,2}ESS[a-z0-9]+|NO_CACHE|OATMEAL|CHOCOLATECHIP)=\",\n \"; \\1=\"\n );\n # Remove from the header any single Cookie not prefixed with a space until\n # next ';' separator.\n set req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n # Remove any '; ' at the start or the end of the header.\n set req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n #If there are no remaining cookies, remove the cookie header.\n if (req.http.Cookie == \"\") {\n unset req.http.Cookie;\n }\n }\n\n \/* 13th: Session cookie & special cookies bypass caching stage *\/\n # As we might want to cache some requests, hashed with its cookies, we don't\n # simply pass when some cookies remain present at this point.\n # Instead we look for request that must be passed due to the cookie header.\n if ( req.http.Cookie ~ \"SESS\"\n || req.http.Cookie ~ \"SSESS\"\n || req.http.Cookie ~ \"NO_CACHE\"\n || req.http.Cookie ~ \"OATMEAL\"\n || req.http.Cookie ~ \"CHOCOLATECHIP\"\n ) {\n return (pass);\n }\n\n \/* 14th: Bypass breakpoint 2 *\/\n # Useful for debugging we can now pipe or pass the request to backend to\n # bypass cache.\n # return (pipe);\n # return (pass);\n\n \/* 15th: Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n return (hash);\n}\n\n# vcl_pipe: Called upon entering pipe mode.\n# In this mode, the request is passed on to the backend, and any further data\n# from either client or backend is passed on unaltered until either end closes\n# the connection.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pipe\nsub vcl_pipe {\n # Websocket support\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n}\n# sub vcl_pipe {\n# # By default Connection: close is set on all piped requests, to stop\n# # connection reuse from sending future requests directly to the\n# # (potentially) wrong backend. If you do want this to happen, you can undo\n# # it here.\n# # unset bereq.http.connection;\n# return (pipe);\n# }\n\n# vcl_pass: Called upon entering pass mode. \n# In this mode, the request is passed on to the backend, and the backend's\n# response is passed on to the client, but is not entered into the cache.\n# Subsequent requests submitted over the same client connection are handled normally.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pass\n# sub vcl_pass {\n# return (fetch);\n# }\n\n# vcl_hash: You may call hash_data() on the data you would like to add to the\n# hash.\n# Hash is used by Varnish to uniquely identify objects.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hash\nsub vcl_hash {\n \/* Hash cookie data *\/\n # As requests with same URL and host can produce diferent results when issued\n # with different cookies, we need to store items hashed with the associated\n # cookies. Note that cookies are already sanitized when we reach this point.\n if (req.http.Cookie) {\n \/* Include cookie in cache hash *\/\n hash_data(req.http.Cookie);\n }\n\n \/* Custom header hashing *\/\n # Empty in simple configs.\n # Example for caching differents object versions by device previously\n # detected (when static content could also vary):\n # if (req.http.X-UA-Device) {\n # hash_data(req.http.X-UA-Device);\n # }\n # Example for caching diferent object versions by X-Forwarded-Proto, trying\n # to be smart about what kind of request could generate diffetent responses.\n if ( req.http.X-Forwarded-Proto\n && req.url !~ \"(?i)\\.(png|gif|jpeg|jpg|ico|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|woff2|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\") {\n hash_data(req.http.X-Forwarded-Proto);\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (lookup);\n# }\n\n# vcl_purge: Called after the purge has been executed and all its variants have\n# been evited.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-purge\n# sub vcl_purge {\n# return (synth(200, \"Purged\"));\n# }\n\n# vcl_hit: Called after a cache lookup if the requested document was found in\n# the cache.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hit\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n \/\/ A pure unadultered hit, deliver it\n return (deliver);\n }\n \/* Allow varnish to serve up stale content if it is responding slowly *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n if (obj.ttl + 60s > 0s) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n set req.http.grace = \"normal\";\n return (deliver);\n }\n \/* Allow varish to serve up stale content if all backends are down *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n if ( ! std.healthy(req.backend_hint)\n && obj.ttl + obj.grace > 0s\n ) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n set req.http.grace = \"extended\";\n return (deliver);\n }\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\n# vcl_miss: Called after a cache lookup if the requested document was not found\n# in the cache.\n# Its purpose is to decide whether or not to attempt to retrieve the document\n# from the backend, and which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-miss\n# sub vcl_miss {\n# return (fetch);\n# }\n\n# vcl_deliver: Called before an object is delivered to the client\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-deliver\nsub vcl_deliver {\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # Add whether the object is a cache hit or miss and the number of hits for\n # the object.\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Addingaheaderindicatinghitmiss\n # In Varnish 4 the obj.hits counter behaviour has changed (see bug 1492), so\n # we use a different method: if X-Varnish contains only 1 id, we have a miss,\n # if it contains more (and therefore a space), we have a hit.\n if (resp.http.x-varnish ~ \" \") {\n set resp.http.X-Cache = \"HIT\";\n # Since in Varnish 4 the behaviour of obj.hits changed, this might not be\n # accurate.\n # See https:\/\/www.varnish-cache.org\/trac\/ticket\/1492\n set resp.http.X-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Cache = \"MISS\";\n \/* Show the results of cookie sanitization *\/\n set resp.http.X-Cookie = req.http.Cookie;\n }\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n set resp.http.grace = req.http.grace;\n\n #TODO# Add sick marker\n\n # Restart count\n if ( req.restarts > 0) {\n set resp.http.X-Restarts = req.restarts;\n }\n\n # Add the Varnish server hostname\n set resp.http.X-Varnish-Server = server.hostname;\n # If we have setted a custom header with device's family detected we can show\n # it:\n # if (req.http.X-UA-Device) {\n # set resp.http.X-UA-Device = req.http.X-UA-Device;\n # }\n # If we have recived a custom header indicating the protocol in the request we\n # can show it:\n # if (req.http.X-Forwarded-Proto) {\n # set resp.http.X-Forwarded-Proto = req.http.X-Forwarded-Proto;\n # }\n\n \/* Vary header manipulation *\/\n # Empty in simple configs.\n # By example, if we are storing & serving diferent objects depending on\n # User-Agent header we must set the correct Vary header:\n # if (resp.http.Vary) {\n # set resp.http.Vary = resp.http.Vary + \",User-Agent\";\n # } else {\n # set resp.http.Vary = \"User-Agent\";\n # }\n\n \/* Fake headers *\/\n # Empty in simple configs\n # We can fake server headers here, by example:\n # set resp.http.Server = \"Deep thought\";\n # set resp.http.X-Powered-By = \"BOFH\";\n # Or have some fun with headers:\n # See http:\/\/www.nextthing.org\/archives\/2005\/08\/07\/fun-with-http-headers\n # See http:\/\/royal.pingdom.com\/2012\/08\/15\/fun-and-unusual-http-response-headers\/\n # set resp.http.X-Thank-You = \"for bothering to look at my HTTP headers\";\n # set resp.http.X-Answer = \"42\";\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_deliver {\n# return (deliver);\n# }\n\n# vcl_synth: Called to deliver a synthetic object. A synthetic object is\n# generated in VCL, not fetched from the backend. It is typically contructed\n# using the synthetic() function.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-synth\n\/*\n * We can come here \"invisibly\" with the following errors: 413, 417 & 503\n *\/\nsub vcl_synth {\n \/* Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_synth;\n\n \/* Try to restart request in case of failure *\/\n # Note that max_restarts defaults to 4\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if (resp.status == 503 && req.restarts < 4) {\n return(restart);\n }\n\n \/* Set common headers for synthetic responses *\/\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n\n \/* HTTP Authentification client request *\/\n # Empty in simple configs.\n # SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* Load synthetic responses from disk *\/\n # Note that files loaded this way are never re-readed (even after a reload).\n # You should consider PROS\/CONS of doing an include instead.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_std.generated.html#func-fileread\n # Example custom 403 error page.\n # if (resp.status == 403) {\n # synthetic(std.fileread(\"\/403.html\"));\n # return(deliver);\n # }\n\n \/* Error page & refresh \/ redirections *\/\n # We have plenty of choices when we have to serve an error to the client, \n # from the default error page to javascript black magic or plain redirections.\n # Adding some external statistic javascript to track failures served to\n # clients is strongly suggested.\n # We can't use external resources on synthetic content, everything must be\n # inlined.\n # If we need to include images we can embed them in base64 encoding.\n # We're using error 200 for monitoring puposes which should not be retried\n # client side.\n if ( resp.status != 200) {\n set resp.http.Retry-After = \"5\";\n }\n\n # Here is the default error page for Varnish 4 (not so pretty)\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n return (deliver);\n}\n\n#######################################################################\n# Backend Fetch\n\n# vcl_backend_fetch: Called before sending the backend request. In this\n# subroutine you typically alter the request before it gets to the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-fetch\n# sub vcl_backend_fetch {\n# return (fetch);\n# }\n\n# vcl_backend_response: Called after the response headers has been successfully\n# retrieved from the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-response\nsub vcl_backend_response {\n \/* Caching exceptions *\/\n # Varnish will cache objects with response codes:\n # 200, 203, 300, 301, 302, 307, 404 & 410.\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/VCL_Basics.html#the-initial-value-of-beresp-ttl\n # Drupal's Imagecache module can return a 307 redirection to the requested\n # url itself and, depending on Drupal's cache settings, this could lead to a\n # redirection loop being cached for a long time but also we want Varnish to\n # shield a little the backend.\n # See http:\/\/drupal.org\/node\/1248010\n # See http:\/\/drupal.org\/node\/310656\n if (beresp.status == 307 &&\n #TODO# verify that this work better than 'bereq.url ~ \"imagecache\"'\n beresp.http.Location == bereq.url &&\n beresp.ttl > 5s) {\n set beresp.ttl = 5s;\n set beresp.http.cache-control = \"max-age=5\";\n }\n\n \/* Request retrial *\/\n if ( beresp.status == 500\n || beresp.status == 503\n ) {\n #TODO# consider not restarting POST requests as seenV3 on https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleSaintMode\n return (retry);\n }\n\n \/* Enable grace mode. Related with vcl_hit *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n set beresp.grace = 1h;\n\n \/* Strip cookies from the following static file types for all users. *\/\n # Related with our 12th stage on vcl_recv\n if (bereq.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|woff2|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\") {\n unset beresp.http.set-cookie;\n }\n\n \/* Gzip response *\/\n # Empty in simple configs.\n # Use Varnish to Gzip respone, if suitable, before storing it on cache.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html\n if ( ! beresp.http.Content-Encoding\n && ( beresp.http.content-type ~ \"text\"\n || beresp.http.content-type ~ \"application\/x-javascript\"\n || beresp.http.content-type ~ \"application\/javascript\"\n || beresp.http.content-type ~ \"application\/rss+xml\"\n || beresp.http.content-type ~ \"application\/xml\"\n || beresp.http.content-type ~ \"Application\/JSON\")\n ) {\n set beresp.do_gzip = true;\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # We can add the name of the backend that has processed the request:\n # set beresp.http.X-Backend = beresp.backend.name;\n # We can use a header to tell if the object was gziped by Varnish:\n # if (beresp.do_gzip) {\n # set beresp.http.X-Varnish-Gzipped = \"yes\";\n # } else {\n # set beresp.http.X-Varnish-Gizipped = \"no\";\n # }\n # We can also add headers informing whether the object is cacheable or not and why:\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Varnish3.0\n if (beresp.ttl <= 0s) {\n \/* Varnish determined the object was not cacheable *\/\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n } elsif (bereq.http.Cookie ~ \"(SESS|SSESS|NO_CACHE|OATMEAL|CHOCOLATECHIP)\") {\n \/* We don't wish to cache content for logged in users or with certain cookies. *\/\n # Related with our 9th stage on vcl_recv\n set beresp.http.X-Cacheable = \"NO:Cookies\";\n # set beresp.uncacheable = true;\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n \/* We are respecting the Cache-Control=private header from the backend *\/\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n # set beresp.uncacheable = true;\n } else {\n \/* Varnish determined the object was cacheable *\/\n set beresp.http.X-Cacheable = \"YES\";\n }\n\n \/* Further header manipulation *\/\n # Empty in simple configs.\n # We can also unset some headers to prevent information disclosure and save\n # some cache space.\n # unset beresp.http.Server;\n # unset beresp.http.X-Powered-By;\n # Retry count.\n if ( bereq.retries > 0) {\n set beresp.http.X-Retries = bereq.retries;\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_backend_response {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Surrogate-control ~ \"no-store\" ||\n# (!beresp.http.Surrogate-Control &&\n# beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n# beresp.http.Vary == \"*\") {\n# \/*\n# * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# *\/\n# set beresp.ttl = 120s;\n# set beresp.uncacheable = true;\n# }\n# return (deliver);\n# }\n\n# vcl_backend_error: This subroutine is called if we fail the backend fetch.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-error\nsub vcl_backend_error {\n\n \/* Try to restart request in case of failure *\/\n #TODO# Confirm max_retries default value\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if (bereq.retries < 4) {\n return (retry);\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # Retry count\n if ( bereq.retries > 0) {\n set beresp.http.X-Retries = bereq.retries;\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + beresp.status + \" \" + beresp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + beresp.status + \" \" + beresp.reason + {\"<\/h1>\n <p>\"} + beresp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + bereq.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this\n # point.\n return (deliver);\n}\n\n#######################################################################\n# Housekeeping\n\n# vcl_init: Called when VCL is loaded, before any requests pass through it.\n# Typically used to initialize VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-init\n# Here is where you should declare your directors now.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-backends.html#directors\n# Empty in simple configs\n# sub vcl_init {\n# return (ok);\n# }\n\n# vcl_fini: Called when VCL is discarded only after all requests have exited\n# the VCL. Typically used to clean up VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-fini\n# sub vcl_fini {\n# return (ok);\n# }\n\n","old_contents":"\/*\n * Varnish 4 example config for Drupal 7 \/ Pressflow 6 & 7\n *\/\n\n# Original source: https:\/\/github.com\/NITEMAN\/varnish-bites\/varnish4\/drupal-base.vcl\n# Copyright (c) 2015 Pedro Gonz\u00e1lez Serrano and individual contributors.\n# MIT License\n\n# Intended to be used both in simple production environments and with\n# learning\/teaching purposes.\n# Some references may not be yet updated to VCL 4.0, we use SeeV3 then.\n\n# WARNING:\n# Note that the built-in logic will be appended to our code if no return is\n# performed before.\n# Built-in logic is included commented out right after our's for reference\n# purposes in that cases.\n# See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleDefault\n\n#######################################################################\n# Initialization: Version & imports;\n\n\/* Version statement *\/\n# Since Varnish 4.0 it's mandatory to declare VCL version on first line.\nvcl 4.0;\n\n\/* Module (VMOD) imports *\/\n# Standard module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_std.generated.html\nimport std;\n\n# Directors module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# Unused in simple configs.\n#import directors;\n\n\n#######################################################################\n# Probe, backend, ACL and subroutine definitions\n\n\/* Backend probes \/ healthchecks *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#probes\nprobe basic {\n \/* Only test that backend's IP serves content for '\/' *\/\n # This might be a too heavy probe\n # .url = \"\/\";\n\n \/* Only test that backend's IP has apache working *\/\n # Nginx would fail this probe with a default config\n .request =\n \"OPTIONS * HTTP\/1.1\"\n \"Host: *\"\n \"Connection: close\";\n\n \/* Common options *\/\n .interval = 10s;\n .timeout = 2s;\n .window = 8;\n .threshold = 6;\n}\n\n\/* Backend definitions.*\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#backend-definition\nbackend default {\n \/* Default backend on the same machine. *\/\n # WARNING: timeouts could be not big enought for certain POST requests.\n .host = \"127.0.0.1\";\n .port = \"8008\";\n .max_connections = 100;\n .connect_timeout = 60s;\n .first_byte_timeout = 60s;\n .between_bytes_timeout = 60s;\n .probe = basic;\n}\n\n\/* Access Control Lists *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#access-control-list-acl\nacl purge_ban {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use '\"localhost\";' instead\n}\nacl allowed_monitors {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n}\n# acl own_proxys {\n# \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n# }\n\n\/* Custom subroutines *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#subroutines\n#TODO# Test in Varnihs 4\n# Empty in simple configs.\n# The only restriction naming subs is that the 'vlc_' prefix is reserverd for\n# Varnish use. As a task can need several chunks of code in diferent states,\n# it's a good idea to identify what main sub will call each with a suffix.\n# \/* Example 301 client redirection removing \"www\" prefix from request *\/\n# sub perm_redirections_recv {\n# if ( req.http.host ~ \"^www.*$\" ) {\n# return(\n# synth(751, \"http:\/\/\" + regsub(req.http.host, \"^www\\.\", \"\") + req.url)\n# );\n# }\n# }\n# sub perm_redirections_synth {\n# if (resp.status == 751) {\n# \/* Get new URL from the response *\/\n# set resp.http.Location = resp.response;\n# \/* Set HTTP 301 for permanent redirect *\/\n# set resp.status = 301;\n# return (deliver);\n# }\n# }\n\n\n#######################################################################\n# Client side\n\n# vcl_recv: Called at the beginning of a request, after the complete request\n# has been received and parsed. Its purpose is to decide whether or not to\n# serve the request, how to do it, and, if applicable, which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-recv\nsub vcl_recv {\n \/* 0th: general bypass, general return & authorization checks *\/\n # Empty in simple configs.\n # Useful for debugging we can pipe or pass the request to default backend\n # here to bypass completely Varnish.\n # return (pipe);\n # return (pass);\n # We can also return here a 200 Ok for network performance benchmarking.\n # return(synth(200, \"Ok\"));\n # Finally we can perform basic HTTP authentification here, by example.\n # SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* 1st: Check for Varnish special requests *\/ \n # Custom response implementation example in order to check that Varnish is\n # working properly.\n # This is usefull for automatic monitoring with monit or when Varnish is\n # behind another proxies like HAProxy.\n if ( ( req.http.host == \"monitor.server.health\"\n || req.http.host == \"health.varnish\" )\n && client.ip ~ allowed_monitors\n && ( req.method == \"OPTIONS\" || req.method == \"GET\" )\n ) {\n return(synth(200, \"Ban added\"));\n }\n # Purge logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#http-purging\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if ( req.method == \"PURGE\" ) {\n if ( ! client.ip ~ purge_ban ) {\n return(synth(405, \"Not allowed.\"));\n }\n return (purge);\n }\n # Ban logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#bans\n if ( req.method == \"BAN\" ) {\n if ( ! client.ip ~ purge_ban ) {\n return(synth(405, \"Not allowed.\"));\n }\n ban( \"req.http.host == \" + req.http.host +\n \"&& req.url == \" + req.url);\n return(synth(200, \"Ban added\"));\n }\n\n \/* 2nd: Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_recv;\n # Here we can also enforce SSL when Varnish run behind some SSL termination\n # point.\n\n \/* 3rd: Time for backend choice *\/\n # Empty in simple configs.\n\n \/* 4th: Prepare request for the backend *\/\n # Empty in simple configs.\n # Example remove own_proxys from X-Forwarded-For\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/whats-new\/upgrading.html#x-forwarded-for-is-now-set-before-vcl-recv\n # if ( req.restarts == 0\n # && client.ip ~ own_proxys\n # && req.http.x-forwarded-for\n # ) {\n # set req.http.X-Forwarded-For\n # = regsub(req.http.X-Forwarded-For, \",( )?\" + client.ip, \"\");\n # }\n # Example normalize the host header, remove the port (in case you're testing\n # this on various TCP ports)\n # set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n \/* 5th: Bypass breakpoint 1 *\/\n # Useful for debugging we can now pipe or pass the request to backend with\n # headers setted.\n # return (pipe);\n # return (pass);\n\n \/* 6th: Decide if we should deal with a request (mostly from built-in logic) *\/\n if (req.method == \"PRI\") {\n \/* We do not support SPDY or HTTP\/2.0 *\/\n return (synth(405));\n }\n if ( req.method != \"GET\"\n && req.method != \"HEAD\"\n && req.method != \"PUT\"\n && req.method != \"POST\"\n && req.method != \"TRACE\"\n && req.method != \"OPTIONS\"\n && req.method != \"DELETE\"\n ) {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n\n \/* 7th: Access control for some URLs by ACL *\/\n # Empty in simple configs.\n # By example denial some URLs depending on client-ip, we'll need to define\n # corresponding ACL 'internal'.\n # if ( req.url ~ \"^\/(cron|install)\\.php\"\n # && ! client.ip ~ internal\n # ) {\n # # Have Varnish throw the error directly.\n # return(synth(403, \"Forbidden.\"));\n # # Use a custom error page that you've defined in Drupal at the path \"404\".\n # # set req.url = \"\/403\";\n # }\n\n \/* 8th: Custom exceptions *\/\n # Host exception example:\n # if (req.http.host == \"ejemplo.exception.com\") {\n # return (pass);\n # }\n # Drupal exceptions, edit if we want to cache some AJAX\/AHAH request.\n # Add here filters for never cache URLs such as Payment Gateway's callbacks.\n if ( req.url ~ \"^\/status\\.php$\"\n || req.url ~ \"^\/update\\.php$\"\n || req.url ~ \"^\/ooyala\/ping$\"\n || req.url ~ \"^\/admin\/build\/features\"\n || req.url ~ \"^\/info\/.*$\"\n || req.url ~ \"^\/flag\/.*$\"\n || req.url ~ \"^.*\/ajax\/.*$\"\n || req.url ~ \"^.*\/ahah\/.*$\"\n ) {\n \/* Do not cache these paths *\/\n return (pass);\n }\n # Pipe these paths directly to backend for streaming.\n if (req.url ~ \"^\/admin\/content\/backup_migrate\/export\") {\n return (pipe);\n }\n if (req.url ~ \"^\/system\/files\") {\n return (pipe);\n }\n\n \/* 9th: Graced objets & Serve from anonymous cahe if all backends are down *\/\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n # set req.http.grace = \"none\";\n if ( ! std.healthy(req.backend_hint) ) {\n # We must do this here since cookie hashing\n unset req.http.Cookie;\n #TODO# Add sick marker\n } \n\n \/* 10th: Deal with compression and the Accept-Encoding header *\/\n # Althought Varnish 3 handles gziped content itself by default, just to be\n # sure we want to remove Accept-Encoding for some compressed formats.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html#what-does-http-gzip-support-do\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/varnishd.html?highlight=http_gzip_support\n # See (for older configs) https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleNormalizeAcceptEncoding\n if (req.http.Accept-Encoding) {\n if ( req.url\n ~ \"\\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|mp4|flv|zip|rar)$\"\n ) {\n \/* Already compressed formats, no sense trying to compress again *\/\n unset req.http.Accept-Encoding;\n }\n }\n\n \/* 11th: Another request manipulation *\/\n # Empty in simple configs.\n # We could add here a custom header grouping User-agent families.\n\n \/* 12th: Cookie removal *\/\n # Always cache the following static file types for all users. \n # Use with care if we control certain downloads depending on cookies. \n # Be carefull also if appending .htm[l] via Drupal's clean URLs.\n if ( req.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|woff2|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n && ! req.url ~ \"\/system\/storage\/serve\"\n ) {\n unset req.http.Cookie;\n }\n # Remove all cookies that backend doesn't need to know about.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRemovingSomeCookies\n if (req.http.Cookie) {\n \/* Warning: Not a pretty solution *\/\n # Prefix header containing cookies with ';'\n set req.http.Cookie = \";\" + req.http.Cookie;\n # Remove any spaces after ';' in header containing cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n # Prefix cookies we want to preserve with one space:\n # 'S{1,2}ESS[a-z0-9]+' is the regular expression matching a Drupal session\n # cookie ({1,2} added for HTTPS support).\n # 'NO_CACHE' is usually set after a POST request to make sure issuing user\n # see the results of his post.\n # 'OATMEAL' & 'CHOCOLATECHIP' are special cookies used by Drupal's Bakery\n # module to provide Single Sign On.\n # Keep in mind we should add here any cookie that should reach the backend\n # such as splash avoiding cookies.\n set req.http.Cookie\n = regsuball(\n req.http.Cookie,\n \";(S{1,2}ESS[a-z0-9]+|NO_CACHE|OATMEAL|CHOCOLATECHIP)=\",\n \"; \\1=\"\n );\n # Remove from the header any single Cookie not prefixed with a space until\n # next ';' separator.\n set req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n # Remove any '; ' at the start or the end of the header.\n set req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n #If there are no remaining cookies, remove the cookie header.\n if (req.http.Cookie == \"\") {\n unset req.http.Cookie;\n }\n }\n\n \/* 13th: Session cookie & special cookies bypass caching stage *\/\n # As we might want to cache some requests, hashed with its cookies, we don't\n # simply pass when some cookies remain present at this point.\n # Instead we look for request that must be passed due to the cookie header.\n if ( req.http.Cookie ~ \"SESS\"\n || req.http.Cookie ~ \"SSESS\"\n || req.http.Cookie ~ \"NO_CACHE\"\n || req.http.Cookie ~ \"OATMEAL\"\n || req.http.Cookie ~ \"CHOCOLATECHIP\"\n ) {\n return (pass);\n }\n\n \/* 14th: Bypass breakpoint 2 *\/\n # Useful for debugging we can now pipe or pass the request to backend to\n # bypass cache.\n # return (pipe);\n # return (pass);\n\n \/* 15th: Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n return (hash);\n}\n\n# vcl_pipe: Called upon entering pipe mode.\n# In this mode, the request is passed on to the backend, and any further data\n# from either client or backend is passed on unaltered until either end closes\n# the connection.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pipe\n# sub vcl_pipe {\n# # By default Connection: close is set on all piped requests, to stop\n# # connection reuse from sending future requests directly to the\n# # (potentially) wrong backend. If you do want this to happen, you can undo\n# # it here.\n# # unset bereq.http.connection;\n# return (pipe);\n# }\n\n# vcl_pass: Called upon entering pass mode. \n# In this mode, the request is passed on to the backend, and the backend's\n# response is passed on to the client, but is not entered into the cache.\n# Subsequent requests submitted over the same client connection are handled normally.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pass\n# sub vcl_pass {\n# return (fetch);\n# }\n\n# vcl_hash: You may call hash_data() on the data you would like to add to the\n# hash.\n# Hash is used by Varnish to uniquely identify objects.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hash\nsub vcl_hash {\n \/* Hash cookie data *\/\n # As requests with same URL and host can produce diferent results when issued\n # with different cookies, we need to store items hashed with the associated\n # cookies. Note that cookies are already sanitized when we reach this point.\n if (req.http.Cookie) {\n \/* Include cookie in cache hash *\/\n hash_data(req.http.Cookie);\n }\n\n \/* Custom header hashing *\/\n # Empty in simple configs.\n # Example for caching differents object versions by device previously\n # detected (when static content could also vary):\n # if (req.http.X-UA-Device) {\n # hash_data(req.http.X-UA-Device);\n # }\n # Example for caching diferent object versions by X-Forwarded-Proto, trying\n # to be smart about what kind of request could generate diffetent responses.\n if ( req.http.X-Forwarded-Proto\n && req.url !~ \"(?i)\\.(png|gif|jpeg|jpg|ico|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|woff2|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\") {\n hash_data(req.http.X-Forwarded-Proto);\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (lookup);\n# }\n\n# vcl_purge: Called after the purge has been executed and all its variants have\n# been evited.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-purge\n# sub vcl_purge {\n# return (synth(200, \"Purged\"));\n# }\n\n# vcl_hit: Called after a cache lookup if the requested document was found in\n# the cache.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hit\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n \/\/ A pure unadultered hit, deliver it\n return (deliver);\n }\n \/* Allow varnish to serve up stale content if it is responding slowly *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n if (obj.ttl + 60s > 0s) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n set req.http.grace = \"normal\";\n return (deliver);\n }\n \/* Allow varish to serve up stale content if all backends are down *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n if ( ! std.healthy(req.backend_hint)\n && obj.ttl + obj.grace > 0s\n ) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n set req.http.grace = \"extended\";\n return (deliver);\n }\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\n# vcl_miss: Called after a cache lookup if the requested document was not found\n# in the cache.\n# Its purpose is to decide whether or not to attempt to retrieve the document\n# from the backend, and which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-miss\n# sub vcl_miss {\n# return (fetch);\n# }\n\n# vcl_deliver: Called before an object is delivered to the client\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-deliver\nsub vcl_deliver {\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # Add whether the object is a cache hit or miss and the number of hits for\n # the object.\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Addingaheaderindicatinghitmiss\n # In Varnish 4 the obj.hits counter behaviour has changed (see bug 1492), so\n # we use a different method: if X-Varnish contains only 1 id, we have a miss,\n # if it contains more (and therefore a space), we have a hit.\n if (resp.http.x-varnish ~ \" \") {\n set resp.http.X-Cache = \"HIT\";\n # Since in Varnish 4 the behaviour of obj.hits changed, this might not be\n # accurate.\n # See https:\/\/www.varnish-cache.org\/trac\/ticket\/1492\n set resp.http.X-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Cache = \"MISS\";\n \/* Show the results of cookie sanitization *\/\n set resp.http.X-Cookie = req.http.Cookie;\n }\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n set resp.http.grace = req.http.grace;\n\n #TODO# Add sick marker\n\n # Restart count\n if ( req.restarts > 0) {\n set resp.http.X-Restarts = req.restarts;\n }\n\n # Add the Varnish server hostname\n set resp.http.X-Varnish-Server = server.hostname;\n # If we have setted a custom header with device's family detected we can show\n # it:\n # if (req.http.X-UA-Device) {\n # set resp.http.X-UA-Device = req.http.X-UA-Device;\n # }\n # If we have recived a custom header indicating the protocol in the request we\n # can show it:\n # if (req.http.X-Forwarded-Proto) {\n # set resp.http.X-Forwarded-Proto = req.http.X-Forwarded-Proto;\n # }\n\n \/* Vary header manipulation *\/\n # Empty in simple configs.\n # By example, if we are storing & serving diferent objects depending on\n # User-Agent header we must set the correct Vary header:\n # if (resp.http.Vary) {\n # set resp.http.Vary = resp.http.Vary + \",User-Agent\";\n # } else {\n # set resp.http.Vary = \"User-Agent\";\n # }\n\n \/* Fake headers *\/\n # Empty in simple configs\n # We can fake server headers here, by example:\n # set resp.http.Server = \"Deep thought\";\n # set resp.http.X-Powered-By = \"BOFH\";\n # Or have some fun with headers:\n # See http:\/\/www.nextthing.org\/archives\/2005\/08\/07\/fun-with-http-headers\n # See http:\/\/royal.pingdom.com\/2012\/08\/15\/fun-and-unusual-http-response-headers\/\n # set resp.http.X-Thank-You = \"for bothering to look at my HTTP headers\";\n # set resp.http.X-Answer = \"42\";\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_deliver {\n# return (deliver);\n# }\n\n# vcl_synth: Called to deliver a synthetic object. A synthetic object is\n# generated in VCL, not fetched from the backend. It is typically contructed\n# using the synthetic() function.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-synth\n\/*\n * We can come here \"invisibly\" with the following errors: 413, 417 & 503\n *\/\nsub vcl_synth {\n \/* Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_synth;\n\n \/* Try to restart request in case of failure *\/\n # Note that max_restarts defaults to 4\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if (resp.status == 503 && req.restarts < 4) {\n return(restart);\n }\n\n \/* Set common headers for synthetic responses *\/\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n\n \/* HTTP Authentification client request *\/\n # Empty in simple configs.\n # SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* Load synthetic responses from disk *\/\n # Note that files loaded this way are never re-readed (even after a reload).\n # You should consider PROS\/CONS of doing an include instead.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_std.generated.html#func-fileread\n # Example custom 403 error page.\n # if (resp.status == 403) {\n # synthetic(std.fileread(\"\/403.html\"));\n # return(deliver);\n # }\n\n \/* Error page & refresh \/ redirections *\/\n # We have plenty of choices when we have to serve an error to the client, \n # from the default error page to javascript black magic or plain redirections.\n # Adding some external statistic javascript to track failures served to\n # clients is strongly suggested.\n # We can't use external resources on synthetic content, everything must be\n # inlined.\n # If we need to include images we can embed them in base64 encoding.\n # We're using error 200 for monitoring puposes which should not be retried\n # client side.\n if ( resp.status != 200) {\n set resp.http.Retry-After = \"5\";\n }\n\n # Here is the default error page for Varnish 4 (not so pretty)\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n return (deliver);\n}\n\n#######################################################################\n# Backend Fetch\n\n# vcl_backend_fetch: Called before sending the backend request. In this\n# subroutine you typically alter the request before it gets to the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-fetch\n# sub vcl_backend_fetch {\n# return (fetch);\n# }\n\n# vcl_backend_response: Called after the response headers has been successfully\n# retrieved from the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-response\nsub vcl_backend_response {\n \/* Caching exceptions *\/\n # Varnish will cache objects with response codes:\n # 200, 203, 300, 301, 302, 307, 404 & 410.\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/VCL_Basics.html#the-initial-value-of-beresp-ttl\n # Drupal's Imagecache module can return a 307 redirection to the requested\n # url itself and, depending on Drupal's cache settings, this could lead to a\n # redirection loop being cached for a long time but also we want Varnish to\n # shield a little the backend.\n # See http:\/\/drupal.org\/node\/1248010\n # See http:\/\/drupal.org\/node\/310656\n if (beresp.status == 307 &&\n #TODO# verify that this work better than 'bereq.url ~ \"imagecache\"'\n beresp.http.Location == bereq.url &&\n beresp.ttl > 5s) {\n set beresp.ttl = 5s;\n set beresp.http.cache-control = \"max-age=5\";\n }\n\n \/* Request retrial *\/\n if ( beresp.status == 500\n || beresp.status == 503\n ) {\n #TODO# consider not restarting POST requests as seenV3 on https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleSaintMode\n return (retry);\n }\n\n \/* Enable grace mode. Related with vcl_hit *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n set beresp.grace = 1h;\n\n \/* Strip cookies from the following static file types for all users. *\/\n # Related with our 12th stage on vcl_recv\n if (bereq.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|woff2|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\") {\n unset beresp.http.set-cookie;\n }\n\n \/* Gzip response *\/\n # Empty in simple configs.\n # Use Varnish to Gzip respone, if suitable, before storing it on cache.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html\n if ( ! beresp.http.Content-Encoding\n && ( beresp.http.content-type ~ \"text\"\n || beresp.http.content-type ~ \"application\/x-javascript\"\n || beresp.http.content-type ~ \"application\/javascript\"\n || beresp.http.content-type ~ \"application\/rss+xml\"\n || beresp.http.content-type ~ \"application\/xml\"\n || beresp.http.content-type ~ \"Application\/JSON\")\n ) {\n set beresp.do_gzip = true;\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # We can add the name of the backend that has processed the request:\n # set beresp.http.X-Backend = beresp.backend.name;\n # We can use a header to tell if the object was gziped by Varnish:\n # if (beresp.do_gzip) {\n # set beresp.http.X-Varnish-Gzipped = \"yes\";\n # } else {\n # set beresp.http.X-Varnish-Gizipped = \"no\";\n # }\n # We can also add headers informing whether the object is cacheable or not and why:\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Varnish3.0\n if (beresp.ttl <= 0s) {\n \/* Varnish determined the object was not cacheable *\/\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n } elsif (bereq.http.Cookie ~ \"(SESS|SSESS|NO_CACHE|OATMEAL|CHOCOLATECHIP)\") {\n \/* We don't wish to cache content for logged in users or with certain cookies. *\/\n # Related with our 9th stage on vcl_recv\n set beresp.http.X-Cacheable = \"NO:Cookies\";\n # set beresp.uncacheable = true;\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n \/* We are respecting the Cache-Control=private header from the backend *\/\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n # set beresp.uncacheable = true;\n } else {\n \/* Varnish determined the object was cacheable *\/\n set beresp.http.X-Cacheable = \"YES\";\n }\n\n \/* Further header manipulation *\/\n # Empty in simple configs.\n # We can also unset some headers to prevent information disclosure and save\n # some cache space.\n # unset beresp.http.Server;\n # unset beresp.http.X-Powered-By;\n # Retry count.\n if ( bereq.retries > 0) {\n set beresp.http.X-Retries = bereq.retries;\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_backend_response {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Surrogate-control ~ \"no-store\" ||\n# (!beresp.http.Surrogate-Control &&\n# beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n# beresp.http.Vary == \"*\") {\n# \/*\n# * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# *\/\n# set beresp.ttl = 120s;\n# set beresp.uncacheable = true;\n# }\n# return (deliver);\n# }\n\n# vcl_backend_error: This subroutine is called if we fail the backend fetch.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-error\nsub vcl_backend_error {\n\n \/* Try to restart request in case of failure *\/\n #TODO# Confirm max_retries default value\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if (bereq.retries < 4) {\n return (retry);\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # Retry count\n if ( bereq.retries > 0) {\n set beresp.http.X-Retries = bereq.retries;\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + beresp.status + \" \" + beresp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + beresp.status + \" \" + beresp.reason + {\"<\/h1>\n <p>\"} + beresp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + bereq.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this\n # point.\n return (deliver);\n}\n\n#######################################################################\n# Housekeeping\n\n# vcl_init: Called when VCL is loaded, before any requests pass through it.\n# Typically used to initialize VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-init\n# Here is where you should declare your directors now.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-backends.html#directors\n# Empty in simple configs\n# sub vcl_init {\n# return (ok);\n# }\n\n# vcl_fini: Called when VCL is discarded only after all requests have exited\n# the VCL. Typically used to clean up VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-fini\n# sub vcl_fini {\n# return (ok);\n# }\n\n","returncode":0,"stderr":"","license":"unknown","lang":"VCL"} {"commit":"ca088363905a5cb61960328a8273ab8f0dc05f81","subject":"x-varnish header to check a miss","message":"x-varnish header to check a miss\n","repos":"NITEMAN\/Varnish_VCL_samps-hacks,NITEMAN\/varnish-bites","old_file":"varnish4\/drupal-base.vcl","new_file":"varnish4\/drupal-base.vcl","new_contents":"\/* Varnish 4 example config for Drupal 7 \/ Pressflow 6 & 7 *\/\n# Original source: https:\/\/github.com\/NITEMAN\/varnish-bites\/varnish4\/drupal-base.vcl\n# Copyright (c) 2015 Pedro Gonz\u00e1lez Serrano and individual contributors.\n# MIT License\n\n# Intended to be used both in simple production environments and with\n# learning\/teaching purposes.\n# Some references may not be yet updated to VCL 4.0, we use SeeV3 then.\n\n# WARNING:\n# Note that the built-in logic will be appended to our code if no return is performed before.\n# Built-in logic is included commented out right after our's for reference purposes in that cases.\n# See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleDefault\n\n#######################################################################\n# Initialization: Version & imports;\n\n\/* Version statement *\/\n# Since Varnish 4.0 it's mandatory to declare VCL version on first line.\nvcl 4.0;\n\n\/* Module (VMOD) imports *\/\n# Standard module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_std.generated.html\nimport std;\n\n# Directors module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# Unused in simple configs.\n#import directors;\n\n\n#######################################################################\n# Probe, backend, ACL and subroutine definitions\n\n\/* Backend probes \/ healthchecks *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#probes\nprobe basic {\n \/* Only test that backend's IP serves content for '\/' *\/\n # This might be a too heavy probe\n # .url = \"\/\";\n \/* Only test that backend's IP has apache working *\/\n # Nginx would fail this probe with a default config\n .request =\n \"OPTIONS * HTTP\/1.1\"\n \"Host: *\"\n \"Connection: close\";\n .interval = 10s;\n .timeout = 2s;\n .window = 8;\n .threshold = 6;\n}\n\n\/* Backend definitions.*\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#backend-definition\nbackend default {\n \/* Default backend on the same machine. WARNING: timeouts could be not big enought for certain POST request *\/\n .host = \"127.0.0.1\";\n .port = \"8008\";\n .connect_timeout = 60s;\n .first_byte_timeout = 60s;\n .between_bytes_timeout = 60s;\n .probe = basic;\n}\n\n\/* Access Control Lists *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#access-control-list-acl\nacl purge_ban {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use '\"localhost\";' instead\n}\nacl allowed_monitors {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n}\n#acl own_proxys {\n# \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n#}\n\n\/* Custom subroutines *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#subroutines\n#TODO# Test in Varnihs 4\n# Empty in simple configs.\n# We can name subs with no restrictions but as a task can need several chunks of code in diferent states,\n# it's a good idea to identify what main sub will call each with a suffix.\n# \/* Example 301 client redirection removing \"www\" prefix from request *\/\n# sub perm_redirections_recv {\n# if ( req.http.host ~ \"^www.*$\" ) {\n# return(synth(751, \"http:\/\/\" + regsub(req.http.host, \"^www\\.\", \"\") + req.url));\n# }\n# }\n# sub perm_redirections_synth {\n# if (resp.status == 751) {\n# \/* Get new URL from the response *\/\n# set resp.http.Location = resp.response;\n# \/* Set HTTP 301 for permanent redirect *\/\n# set resp.status = 301;\n# return (deliver);\n# }\n# }\n\n\n#######################################################################\n# Client side\n\n# vcl_recv: Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-recv\nsub vcl_recv {\n \/* 0th: general bypass, general return & authorization checks *\/\n # Empty in simple configs.\n # Useful for debugging we can pipe or pass the request to default backend here to bypass completely Varnish.\n # return (pipe);\n # return (pass);\n # We can also return here a 200 Ok for network performance benchmarking.\n # return(synth(200, \"Ok\"));\n # Finally we can perform basic HTTP authentification here, by example.\n # SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* 1st: Check for Varnish special requests *\/ \n # Custom response implementation example in order to check that Varnish is working properly.\n # This is usefull for automatic monitoring with monit or when Varnish is behind another proxies like HAProxy.\n if ( ( req.http.host == \"monitor.server.health\"\n || req.http.host == \"health.varnish\" )\n && client.ip ~ allowed_monitors\n && ( req.method == \"OPTIONS\" || req.method == \"GET\" )\n ) {\n return(synth(200, \"Ban added\"));\n }\n # Purge logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#http-purging\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if (req.method == \"PURGE\") {\n if (!client.ip ~ purge_ban) {\n return(synth(405, \"Not allowed.\"));\n }\n return (purge);\n }\n # Ban logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#bans\n if (req.method == \"BAN\") {\n if (!client.ip ~ purge_ban) {\n return(synth(405, \"Not allowed.\"));\n }\n ban(\"req.http.host == \" + req.http.host +\n \"&& req.url == \" + req.url); \n return(synth(200, \"Ban added\"));\n }\n\n \/* 2nd: Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_recv;\n # Here we can also enforce SSL when Varnish run behind some SSL termination point.\n\n \/* 3rd: Time for backend choice *\/\n # Empty in simple configs.\n\n \/* 4th: Prepare headers for the backend *\/\n # Empty in simple configs.\n # Example remove own_proxys from X-Forwarded-For\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/whats-new\/upgrading.html#x-forwarded-for-is-now-set-before-vcl-recv\n # if ( req.restarts == 0\n # && client.ip ~ own_proxys\n # && req.http.x-forwarded-for\n # ) {\n # set req.http.X-Forwarded-For = regsub(req.http.X-Forwarded-For, \",( )?\" + client.ip, \"\");\n # }\n\n \/* 5th: Bypass breakpoint 1 *\/\n # Useful for debugging we can now pipe or pass the request to backend with headers setted.\n # return (pipe);\n # return (pass);\n\n \/* 6th: Decide if we should deal with a request (mostly copied from built-in logic) *\/\n if (req.method == \"PRI\") {\n \/* We do not support SPDY or HTTP\/2.0 *\/\n return (synth(405));\n }\n if ( req.method != \"GET\"\n && req.method != \"HEAD\"\n && req.method != \"PUT\"\n && req.method != \"POST\"\n && req.method != \"TRACE\"\n && req.method != \"OPTIONS\"\n && req.method != \"DELETE\"\n ) {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n\n \/* 7th: Access control for some URLs by ACL *\/\n # Empty in simple configs.\n # By example denial some URLs depending on client-ip, we'll need to define corresponding ACL 'internal'.\n # if ( req.url ~ \"^\/(cron|install)\\.php\"\n # && ! client.ip ~ internal\n # ) {\n # # Have Varnish throw the error directly.\n # return(synth(403, \"Forbidden.\"));\n # # Use a custom error page that you've defined in Drupal at the path \"404\".\n # # set req.url = \"\/403\";\n # }\n\n \/* 8th: Custom exceptions *\/\n # Host exception example:\n # if (req.http.host == \"ejemplo.exception.com\") {\n # return (pass);\n # }\n # Drupal exceptions, edit if we want to cache some AJAX\/AHAH request.\n # Add here filters for never cache URLs such as Payment Gateway's callbacks\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/ooyala\/ping$\" ||\n req.url ~ \"^\/admin\/build\/features\" ||\n req.url ~ \"^\/info\/.*$\" ||\n req.url ~ \"^\/flag\/.*$\" ||\n req.url ~ \"^.*\/ajax\/.*$\" ||\n req.url ~ \"^.*\/ahah\/.*$\") {\n \/* Do not cache these paths *\/\n return (pass);\n }\n # Pipe these paths directly to backend for streaming.\n if (req.url ~ \"^\/admin\/content\/backup_migrate\/export\") {\n return (pipe);\n }\n if (req.url ~ \"^\/system\/files\") {\n return (pipe);\n }\n\n \/* 9th: Serve from anonymous cahe if all backends are down *\/\n if (! std.healthy(req.backend_hint) ) {\n #TODO# Consider moving this to vcl_backend_fetch\n unset req.http.Cookie;\n #TODO# Add sick marker\n } \n\n \/* 10th: Deal with compression and the Accept-Encoding header *\/\n # Althought Varnish 3 handles gziped content itself by default, just to be sure we want to \n # remove Accept-Encoding for some compressed formats.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html#what-does-http-gzip-support-do\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/varnishd.html?highlight=http_gzip_support\n # See (for older configs) https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleNormalizeAcceptEncoding\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|mp4|flv|zip|rar)$\") {\n \/* Already compressed formats, no sense trying to compress again *\/\n unset req.http.Accept-Encoding;\n }\n }\n\n \/* 11th: Another header manipulation *\/\n # Empty in simple configs.\n # We could add here a custom header grouping User-agent families.\n\n \/* 12th: Cookie removal *\/\n # Always cache the following static file types for all users. \n # Use with care if we control certain downloads depending on cookies. \n # Be carefull also if appending .htm[l] via Drupal's clean URLs.\n if ( req.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|woff2|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n && req.url !~ \"\/system\/storage\/serve\"\n ) {\n unset req.http.Cookie;\n }\n # Remove all cookies that backend doesn't need to know about.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRemovingSomeCookies\n if (req.http.Cookie) {\n \/* Warning: Not a pretty solution *\/\n \/* Prefix header containing cookies with ';' *\/\n set req.http.Cookie = \";\" + req.http.Cookie;\n \/* Remove any spaces after ';' in header containing cookies *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n \/* Prefix cookies we want to preserve with one space *\/\n \/* 'S{1,2}ESS[a-z0-9]+' is the regular expression matching a Drupal session cookie ({1,2} added for HTTPS support) *\/\n \/* 'NO_CACHE' is usually set after a POST request to make sure issuing user see the results of his post *\/\n \/* 'OATMEAL' & 'CHOCOLATECHIP' are special cookies used by Drupal's Bakery module to provide Single Sign On *\/\n \/* Keep in mind we should add here any cookie that should reach the backend such as splahs avoiding cookies *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \";(S{1,2}ESS[a-z0-9]+|NO_CACHE|OATMEAL|CHOCOLATECHIP)=\", \"; \\1=\");\n \/* Remove from the header any single Cookie not prefixed with a space until next ';' separator *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n \/* Remove any '; ' at the start or the end of the header *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n\n if (req.http.Cookie == \"\") {\n \/* If there are no remaining cookies, remove the cookie header. *\/\n unset req.http.Cookie;\n }\n }\n\n \/* 13th: Session cookie & special cookies bypass caching stage *\/\n # As we might want to cache some requests, hashed with its cookies, \n # we don't simply pass when some cookies remain present at this point.\n # Instead we look for request that must be passed due to the cookie header.\n if ( req.http.Cookie ~ \"SESS\"\n || req.http.Cookie ~ \"SSESS\"\n || req.http.Cookie ~ \"NO_CACHE\"\n || req.http.Cookie ~ \"OATMEAL\"\n || req.http.Cookie ~ \"CHOCOLATECHIP\"\n ) {\n return (pass);\n }\n\n \/* 14th: Bypass breakpoint 2 *\/\n # Useful for debugging we can now pipe or pass the request to backend to bypass cache.\n # return (pipe);\n # return (pass);\n\n \/* 15th: Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning inconditionally.\n return (hash);\n}\n\n# vcl_pipe: Called upon entering pipe mode.\n# In this mode, the request is passed on to the backend, \n# and any further data from either client or backend is passed on unaltered until either end closes the connection.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pipe\n# sub vcl_pipe {\n# # By default Connection: close is set on all piped requests, to stop\n# # connection reuse from sending future requests directly to the\n# # (potentially) wrong backend. If you do want this to happen, you can undo\n# # it here.\n# # unset bereq.http.connection;\n# return (pipe);\n# }\n\n# vcl_pass: Called upon entering pass mode. \n# In this mode, the request is passed on to the backend, and the backend's response is passed on to the client, \n# but is not entered into the cache.\n# Subsequent requests submitted over the same client connection are handled normally.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pass\n# sub vcl_pass {\n# return (fetch);\n# }\n\n# vcl_hash: You may call hash_data() on the data you would like to add to the hash.\n# Hash is used by Varnish to uniquely identify objects.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hash\nsub vcl_hash {\n \/* Hash cookie data *\/\n # As requests with same URL and host can produce diferent results when issued with different cookies,\n # we need to store items hashed with the associated cookies. Note that cookies are already sanitized when we reach this point.\n if (req.http.Cookie) {\n \/* Include cookie in cache hash *\/\n hash_data(req.http.Cookie);\n }\n\n \/* Custom header hashing *\/\n # Empty in simple configs.\n # Example for caching differents object versions by device previously detected (when static content could also vary):\n # if (req.http.X-UA-Device) {\n # hash_data(req.http.X-UA-Device);\n # }\n # Example for caching diferent object versions by X-Forwarded-Proto, trying to be smart about what kind of request\n # could generate diffetent responses.\n if ( req.http.X-Forwarded-Proto\n && req.url !~ \"(?i)\\.(png|gif|jpeg|jpg|ico|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|woff2|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\") {\n hash_data(req.http.X-Forwarded-Proto);\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (lookup);\n# }\n\n# vcl_purge: Called after the purge has been executed and all its variants have been evited.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-purge\n# sub vcl_purge {\n# return (synth(200, \"Purged\"));\n# }\n\n# vcl_hit: Called after a cache lookup if the requested document was found in the cache.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hit\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n \/\/ A pure unadultered hit, deliver it\n return (deliver);\n }\n \/* Allow varnish to serve up stale content if it is responding slowly *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n if (obj.ttl + 60s > 0s) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n return (deliver);\n }\n \/* Allow varish to serve up stale content if all backends are down *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n if ( ! std.healthy(req.backend_hint)\n && obj.ttl + obj.grace > 0s\n ) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n return (deliver);\n }\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning inconditionally.\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\n# vcl_miss: Called after a cache lookup if the requested document was not found in the cache.\n# Its purpose is to decide whether or not to attempt to retrieve the document from the backend, and which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-miss\n# sub vcl_miss {\n# return (fetch);\n# }\n\n# vcl_deliver: Called before an object is delivered to the client\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-deliver\nsub vcl_deliver {\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # In Varnish 4 the obj.hits counter behaviour has changed, so we use a\n # different method: if X-Varnish contains only 1 id, we have a miss, if it\n # contains more (and therefore a space), we have a hit.\n if (resp.http.x-varnish ~ \" \") {\n set resp.http.X-Cache = \"HIT\";\n set resp.http.X-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Cache = \"MISS\";\n \/* Show the results of cookie sanitization *\/\n set resp.http.X-Cookie = req.http.Cookie;\n }\n \n\n #TODO# Add sick marker\n # Restart count\n if ( req.restarts > 0) {\n set resp.http.X-Restarts = req.restarts;\n }\n\n # Add the Varnish server hostname\n set resp.http.X-Varnish-Server = server.hostname;\n # If we have setted a custom header with device family detected we can show it:\n # if (req.http.X-UA-Device) {\n # set resp.http.X-UA-Device = req.http.X-UA-Device;\n # }\n # If we have recived a custom header with the protocol in the request we can show it:\n # if (req.http.X-Forwarded-Proto) {\n # set resp.http.X-Forwarded-Proto = req.http.X-Forwarded-Proto;\n # }\n\n \/* Vary header manipulation *\/\n # Empty in simple configs.\n # By example, if we are storing & serving diferent objects depending on User-Agent header we must set the correct Vary header:\n # if (resp.http.Vary) {\n # set resp.http.Vary = resp.http.Vary + \",User-Agent\";\n # } else {\n # set resp.http.Vary = \"User-Agent\";\n # }\n\n \/* Fake headers *\/\n # Empty in simple configs\n # We can fake server headers here, by example:\n # set resp.http.Server = \"Deep thought\";\n # set resp.http.X-Powered-By = \"BOFH\";\n # Or have some fun with headers:\n # See http:\/\/www.nextthing.org\/archives\/2005\/08\/07\/fun-with-http-headers\n # See http:\/\/royal.pingdom.com\/2012\/08\/15\/fun-and-unusual-http-response-headers\/\n # set resp.http.X-Thank-You = \"for bothering to look at my HTTP headers\";\n # set resp.http.X-Answer = \"42\";\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_deliver {\n# return (deliver);\n# }\n\n# vcl_synth: Called to deliver a synthetic object. A synthetic object is generated in VCL,\n# not fetched from the backend. It is typically contructed using the synthetic() function.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-synth\n\/*\n * We can come here \"invisibly\" with the following errors: 413, 417 & 503\n *\/\nsub vcl_synth {\n \/* Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_synth;\n\n \/* Try to restart request in case of failure *\/\n # Note that max_restarts defaults to 4\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if (resp.status == 503 && req.restarts < 4) {\n return(restart);\n }\n\n \/* Set common headers for synthetic responses *\/\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n\n \/* HTTP Authentification client request *\/\n # Empty in simple configs. SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* Error page & refresh \/ redirections *\/\n # We have plenty of choices when we have to serve an error to the client, \n # from the default error page to javascript black magic or plain redirections.\n # Adding some external statistic javascript to track failures served to clients is strongly suggested.\n # We can't use external resources on synthetic content, everything must be inlined.\n # If we need to include images we can embed them in base64 encoding.\n # Here is the default error page for Varnish 4 (not so pretty)\n # We're using error 200 for monitoring puposes which should not be retried client side *\/\n if ( resp.status != 200) {\n set resp.http.Retry-After = \"5\";\n }\n\n ## Example custom 403 error page.\n #if (resp.status == 403) {\n # synthetic(std.fileread(\"\/403.html\"));\n # return(deliver);\n #}\n \n # Consider add some analytics stuff to trace accesses\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning inconditionally.\n return (deliver);\n}\n\n#######################################################################\n# Backend Fetch\n\n# vcl_backend_fetch: Called before sending the backend request. In this subroutine you typically alter the request before it gets to the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-fetch\n# sub vcl_backend_fetch {\n# return (fetch);\n# }\n\n# vcl_backend_response: Called after the response headers has been successfully retrieved from the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-response\nsub vcl_backend_response {\n \/* Caching exceptions *\/\n # Varnish will cache objects with response codes: 200, 203, 300, 301, 302, 307, 404 & 410.\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/VCL_Basics.html#the-initial-value-of-beresp-ttl\n # Drupal's Imagecache module can return a 307 redirection to the requested url itself and, depending on Drupal's cache settings,\n # this could lead to a redirection loop being cached for a long time but also we want Varnish to shield a little the backend.\n # See http:\/\/drupal.org\/node\/1248010\n # See http:\/\/drupal.org\/node\/310656\n if (beresp.status == 307 &&\n #TODO# verify that this work better than 'bereq.url ~ \"imagecache\"' *\/\n beresp.http.Location == bereq.url &&\n beresp.ttl > 5s) {\n set beresp.ttl = 5s;\n set beresp.http.cache-control = \"max-age=5\";\n }\n\n \/* Request retrial *\/\n if ( beresp.status == 500\n || beresp.status == 503\n ) {\n #TODO# consider not restarting POST requests as seenV3 on https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleSaintMode\n return (retry);\n }\n\n \/* Enable grace mode. Related with vcl_hit *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n set beresp.grace = 1h;\n\n \/* Strip cookies from the following static file types for all users. Related with our 12th stage on vcl_recv *\/\n if (bereq.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|woff2|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\") {\n unset beresp.http.set-cookie;\n }\n\n \/* Gzip response *\/\n # Empty in simple configs\n # Use Varnish to Gzip respone, if suitable, before storing it on cache\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html\n if ( ! beresp.http.Content-Encoding\n && ( beresp.http.content-type ~ \"text\"\n || beresp.http.content-type ~ \"application\/x-javascript\"\n || beresp.http.content-type ~ \"application\/javascript\"\n || beresp.http.content-type ~ \"application\/rss+xml\"\n || beresp.http.content-type ~ \"application\/xml\"\n || beresp.http.content-type ~ \"Application\/JSON\")\n ) {\n set beresp.do_gzip = true;\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # We can add the name of the backend that has processed the request:\n # set beresp.http.X-Backend = beresp.backend.name;\n # We can use a header to tell if the object was gziped by Varnish\n # if (beresp.do_gzip) {\n # set beresp.http.X-Varnish-Gzipped = \"yes\";\n # } else {\n # set beresp.http.X-Varnish-Gizipped = \"no\";\n # }\n # We can also add headers informing whether the object is cacheable or not and why.\n # https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Varnish3.0\n if (beresp.ttl <= 0s) {\n \/* Varnish determined the object was not cacheable *\/\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n } elsif (bereq.http.Cookie ~ \"(SESS|SSESS|NO_CACHE|OATMEAL|CHOCOLATECHIP)\") {\n \/* We don't wish to cache content for logged in users or with certain cookies. Related with our 9th stage on vcl_recv *\/\n set beresp.http.X-Cacheable = \"NO:Cookies\";\n # return(hit_for_pass);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n \/* We are respecting the Cache-Control=private header from the backend *\/\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n # return(hit_for_pass);\n } else {\n \/* Varnish determined the object was cacheable *\/\n set beresp.http.X-Cacheable = \"YES\";\n }\n\n \/* Further header manipulation *\/\n # Empty in simple configs.\n # We can also unset some headers to prevent information disclosure and save some cache space\n # unset beresp.http.Server;\n # unset beresp.http.X-Powered-By;\n # Retry count\n if ( bereq.retries > 0) {\n set beresp.http.X-Retries = bereq.retries;\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_backend_response {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Surrogate-control ~ \"no-store\" ||\n# (!beresp.http.Surrogate-Control &&\n# beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n# beresp.http.Vary == \"*\") {\n# \/*\n# * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# *\/\n# set beresp.ttl = 120s;\n# set beresp.uncacheable = true;\n# }\n# return (deliver);\n# }\n\n# vcl_backend_error: This subroutine is called if we fail the backend fetch.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-error\nsub vcl_backend_error {\n\n \/* Try to restart request in case of failure *\/\n #TODO# Confirm max_retries default value\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if (bereq.retries < 4) {\n return (retry);\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # Retry count\n if ( bereq.retries > 0) {\n set beresp.http.X-Retries = bereq.retries;\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + beresp.status + \" \" + beresp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + beresp.status + \" \" + beresp.reason + {\"<\/h1>\n <p>\"} + beresp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + bereq.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this point.\n return (deliver);\n}\n\n#######################################################################\n# Housekeeping\n\n# vcl_init: Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-init\n# Here is where you should declare your directors now.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-backends.html#directors\n# Empty in simple configs\n# sub vcl_init {\n# return (ok);\n# }\n\n# vcl_fini: Called when VCL is discarded only after all requests have exited the VCL. Typically used to clean up VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-fini\n# sub vcl_fini {\n# return (ok);\n# }\n\n","old_contents":"\/* Varnish 4 example config for Drupal 7 \/ Pressflow 6 & 7 *\/\n# Original source: https:\/\/github.com\/NITEMAN\/varnish-bites\/varnish4\/drupal-base.vcl\n# Copyright (c) 2015 Pedro Gonz\u00e1lez Serrano and individual contributors.\n# MIT License\n\n# Intended to be used both in simple production environments and with\n# learning\/teaching purposes.\n# Some references may not be yet updated to VCL 4.0, we use SeeV3 then.\n\n# WARNING:\n# Note that the built-in logic will be appended to our code if no return is performed before.\n# Built-in logic is included commented out right after our's for reference purposes in that cases.\n# See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleDefault\n\n#######################################################################\n# Initialization: Version & imports;\n\n\/* Version statement *\/\n# Since Varnish 4.0 it's mandatory to declare VCL version on first line.\nvcl 4.0;\n\n\/* Module (VMOD) imports *\/\n# Standard module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_std.generated.html\nimport std;\n\n# Directors module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# Unused in simple configs.\n#import directors;\n\n\n#######################################################################\n# Probe, backend, ACL and subroutine definitions\n\n\/* Backend probes \/ healthchecks *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#probes\nprobe basic {\n \/* Only test that backend's IP serves content for '\/' *\/\n # This might be a too heavy probe\n # .url = \"\/\";\n \/* Only test that backend's IP has apache working *\/\n # Nginx would fail this probe with a default config\n .request =\n \"OPTIONS * HTTP\/1.1\"\n \"Host: *\"\n \"Connection: close\";\n .interval = 10s;\n .timeout = 2s;\n .window = 8;\n .threshold = 6;\n}\n\n\/* Backend definitions.*\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#backend-definition\nbackend default {\n \/* Default backend on the same machine. WARNING: timeouts could be not big enought for certain POST request *\/\n .host = \"127.0.0.1\";\n .port = \"8008\";\n .connect_timeout = 60s;\n .first_byte_timeout = 60s;\n .between_bytes_timeout = 60s;\n .probe = basic;\n}\n\n\/* Access Control Lists *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#access-control-list-acl\nacl purge_ban {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use '\"localhost\";' instead\n}\nacl allowed_monitors {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n}\n#acl own_proxys {\n# \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n#}\n\n\/* Custom subroutines *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#subroutines\n#TODO# Test in Varnihs 4\n# Empty in simple configs.\n# We can name subs with no restrictions but as a task can need several chunks of code in diferent states,\n# it's a good idea to identify what main sub will call each with a suffix.\n# \/* Example 301 client redirection removing \"www\" prefix from request *\/\n# sub perm_redirections_recv {\n# if ( req.http.host ~ \"^www.*$\" ) {\n# return(synth(751, \"http:\/\/\" + regsub(req.http.host, \"^www\\.\", \"\") + req.url));\n# }\n# }\n# sub perm_redirections_synth {\n# if (resp.status == 751) {\n# \/* Get new URL from the response *\/\n# set resp.http.Location = resp.response;\n# \/* Set HTTP 301 for permanent redirect *\/\n# set resp.status = 301;\n# return (deliver);\n# }\n# }\n\n\n#######################################################################\n# Client side\n\n# vcl_recv: Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-recv\nsub vcl_recv {\n \/* 0th: general bypass, general return & authorization checks *\/\n # Empty in simple configs.\n # Useful for debugging we can pipe or pass the request to default backend here to bypass completely Varnish.\n # return (pipe);\n # return (pass);\n # We can also return here a 200 Ok for network performance benchmarking.\n # return(synth(200, \"Ok\"));\n # Finally we can perform basic HTTP authentification here, by example.\n # SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* 1st: Check for Varnish special requests *\/ \n # Custom response implementation example in order to check that Varnish is working properly.\n # This is usefull for automatic monitoring with monit or when Varnish is behind another proxies like HAProxy.\n if ( ( req.http.host == \"monitor.server.health\"\n || req.http.host == \"health.varnish\" )\n && client.ip ~ allowed_monitors\n && ( req.method == \"OPTIONS\" || req.method == \"GET\" )\n ) {\n return(synth(200, \"Ban added\"));\n }\n # Purge logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#http-purging\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if (req.method == \"PURGE\") {\n if (!client.ip ~ purge_ban) {\n return(synth(405, \"Not allowed.\"));\n }\n return (purge);\n }\n # Ban logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#bans\n if (req.method == \"BAN\") {\n if (!client.ip ~ purge_ban) {\n return(synth(405, \"Not allowed.\"));\n }\n ban(\"req.http.host == \" + req.http.host +\n \"&& req.url == \" + req.url); \n return(synth(200, \"Ban added\"));\n }\n\n \/* 2nd: Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_recv;\n # Here we can also enforce SSL when Varnish run behind some SSL termination point.\n\n \/* 3rd: Time for backend choice *\/\n # Empty in simple configs.\n\n \/* 4th: Prepare headers for the backend *\/\n # Empty in simple configs.\n # Example remove own_proxys from X-Forwarded-For\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/whats-new\/upgrading.html#x-forwarded-for-is-now-set-before-vcl-recv\n # if ( req.restarts == 0\n # && client.ip ~ own_proxys\n # && req.http.x-forwarded-for\n # ) {\n # set req.http.X-Forwarded-For = regsub(req.http.X-Forwarded-For, \",( )?\" + client.ip, \"\");\n # }\n\n \/* 5th: Bypass breakpoint 1 *\/\n # Useful for debugging we can now pipe or pass the request to backend with headers setted.\n # return (pipe);\n # return (pass);\n\n \/* 6th: Decide if we should deal with a request (mostly copied from built-in logic) *\/\n if (req.method == \"PRI\") {\n \/* We do not support SPDY or HTTP\/2.0 *\/\n return (synth(405));\n }\n if ( req.method != \"GET\"\n && req.method != \"HEAD\"\n && req.method != \"PUT\"\n && req.method != \"POST\"\n && req.method != \"TRACE\"\n && req.method != \"OPTIONS\"\n && req.method != \"DELETE\"\n ) {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n\n \/* 7th: Access control for some URLs by ACL *\/\n # Empty in simple configs.\n # By example denial some URLs depending on client-ip, we'll need to define corresponding ACL 'internal'.\n # if ( req.url ~ \"^\/(cron|install)\\.php\"\n # && ! client.ip ~ internal\n # ) {\n # # Have Varnish throw the error directly.\n # return(synth(403, \"Forbidden.\"));\n # # Use a custom error page that you've defined in Drupal at the path \"404\".\n # # set req.url = \"\/403\";\n # }\n\n \/* 8th: Custom exceptions *\/\n # Host exception example:\n # if (req.http.host == \"ejemplo.exception.com\") {\n # return (pass);\n # }\n # Drupal exceptions, edit if we want to cache some AJAX\/AHAH request.\n # Add here filters for never cache URLs such as Payment Gateway's callbacks\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/ooyala\/ping$\" ||\n req.url ~ \"^\/admin\/build\/features\" ||\n req.url ~ \"^\/info\/.*$\" ||\n req.url ~ \"^\/flag\/.*$\" ||\n req.url ~ \"^.*\/ajax\/.*$\" ||\n req.url ~ \"^.*\/ahah\/.*$\") {\n \/* Do not cache these paths *\/\n return (pass);\n }\n # Pipe these paths directly to backend for streaming.\n if (req.url ~ \"^\/admin\/content\/backup_migrate\/export\") {\n return (pipe);\n }\n if (req.url ~ \"^\/system\/files\") {\n return (pipe);\n }\n\n \/* 9th: Serve from anonymous cahe if all backends are down *\/\n if (! std.healthy(req.backend_hint) ) {\n #TODO# Consider moving this to vcl_backend_fetch\n unset req.http.Cookie;\n #TODO# Add sick marker\n } \n\n \/* 10th: Deal with compression and the Accept-Encoding header *\/\n # Althought Varnish 3 handles gziped content itself by default, just to be sure we want to \n # remove Accept-Encoding for some compressed formats.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html#what-does-http-gzip-support-do\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/varnishd.html?highlight=http_gzip_support\n # See (for older configs) https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleNormalizeAcceptEncoding\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|mp4|flv|zip|rar)$\") {\n \/* Already compressed formats, no sense trying to compress again *\/\n unset req.http.Accept-Encoding;\n }\n }\n\n \/* 11th: Another header manipulation *\/\n # Empty in simple configs.\n # We could add here a custom header grouping User-agent families.\n\n \/* 12th: Cookie removal *\/\n # Always cache the following static file types for all users. \n # Use with care if we control certain downloads depending on cookies. \n # Be carefull also if appending .htm[l] via Drupal's clean URLs.\n if ( req.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|woff2|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n && req.url !~ \"\/system\/storage\/serve\"\n ) {\n unset req.http.Cookie;\n }\n # Remove all cookies that backend doesn't need to know about.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRemovingSomeCookies\n if (req.http.Cookie) {\n \/* Warning: Not a pretty solution *\/\n \/* Prefix header containing cookies with ';' *\/\n set req.http.Cookie = \";\" + req.http.Cookie;\n \/* Remove any spaces after ';' in header containing cookies *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n \/* Prefix cookies we want to preserve with one space *\/\n \/* 'S{1,2}ESS[a-z0-9]+' is the regular expression matching a Drupal session cookie ({1,2} added for HTTPS support) *\/\n \/* 'NO_CACHE' is usually set after a POST request to make sure issuing user see the results of his post *\/\n \/* 'OATMEAL' & 'CHOCOLATECHIP' are special cookies used by Drupal's Bakery module to provide Single Sign On *\/\n \/* Keep in mind we should add here any cookie that should reach the backend such as splahs avoiding cookies *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \";(S{1,2}ESS[a-z0-9]+|NO_CACHE|OATMEAL|CHOCOLATECHIP)=\", \"; \\1=\");\n \/* Remove from the header any single Cookie not prefixed with a space until next ';' separator *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n \/* Remove any '; ' at the start or the end of the header *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n\n if (req.http.Cookie == \"\") {\n \/* If there are no remaining cookies, remove the cookie header. *\/\n unset req.http.Cookie;\n }\n }\n\n \/* 13th: Session cookie & special cookies bypass caching stage *\/\n # As we might want to cache some requests, hashed with its cookies, \n # we don't simply pass when some cookies remain present at this point.\n # Instead we look for request that must be passed due to the cookie header.\n if ( req.http.Cookie ~ \"SESS\"\n || req.http.Cookie ~ \"SSESS\"\n || req.http.Cookie ~ \"NO_CACHE\"\n || req.http.Cookie ~ \"OATMEAL\"\n || req.http.Cookie ~ \"CHOCOLATECHIP\"\n ) {\n return (pass);\n }\n\n \/* 14th: Bypass breakpoint 2 *\/\n # Useful for debugging we can now pipe or pass the request to backend to bypass cache.\n # return (pipe);\n # return (pass);\n\n \/* 15th: Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning inconditionally.\n return (hash);\n}\n\n# vcl_pipe: Called upon entering pipe mode.\n# In this mode, the request is passed on to the backend, \n# and any further data from either client or backend is passed on unaltered until either end closes the connection.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pipe\n# sub vcl_pipe {\n# # By default Connection: close is set on all piped requests, to stop\n# # connection reuse from sending future requests directly to the\n# # (potentially) wrong backend. If you do want this to happen, you can undo\n# # it here.\n# # unset bereq.http.connection;\n# return (pipe);\n# }\n\n# vcl_pass: Called upon entering pass mode. \n# In this mode, the request is passed on to the backend, and the backend's response is passed on to the client, \n# but is not entered into the cache.\n# Subsequent requests submitted over the same client connection are handled normally.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pass\n# sub vcl_pass {\n# return (fetch);\n# }\n\n# vcl_hash: You may call hash_data() on the data you would like to add to the hash.\n# Hash is used by Varnish to uniquely identify objects.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hash\nsub vcl_hash {\n \/* Hash cookie data *\/\n # As requests with same URL and host can produce diferent results when issued with different cookies,\n # we need to store items hashed with the associated cookies. Note that cookies are already sanitized when we reach this point.\n if (req.http.Cookie) {\n \/* Include cookie in cache hash *\/\n hash_data(req.http.Cookie);\n }\n\n \/* Custom header hashing *\/\n # Empty in simple configs.\n # Example for caching differents object versions by device previously detected (when static content could also vary):\n # if (req.http.X-UA-Device) {\n # hash_data(req.http.X-UA-Device);\n # }\n # Example for caching diferent object versions by X-Forwarded-Proto, trying to be smart about what kind of request\n # could generate diffetent responses.\n if ( req.http.X-Forwarded-Proto\n && req.url !~ \"(?i)\\.(png|gif|jpeg|jpg|ico|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|woff2|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\") {\n hash_data(req.http.X-Forwarded-Proto);\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (lookup);\n# }\n\n# vcl_purge: Called after the purge has been executed and all its variants have been evited.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-purge\n# sub vcl_purge {\n# return (synth(200, \"Purged\"));\n# }\n\n# vcl_hit: Called after a cache lookup if the requested document was found in the cache.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hit\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n \/\/ A pure unadultered hit, deliver it\n return (deliver);\n }\n \/* Allow varnish to serve up stale content if it is responding slowly *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n if (obj.ttl + 60s > 0s) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n return (deliver);\n }\n \/* Allow varish to serve up stale content if all backends are down *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n if ( ! std.healthy(req.backend_hint)\n && obj.ttl + obj.grace > 0s\n ) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n return (deliver);\n }\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning inconditionally.\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\n# vcl_miss: Called after a cache lookup if the requested document was not found in the cache.\n# Its purpose is to decide whether or not to attempt to retrieve the document from the backend, and which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-miss\n# sub vcl_miss {\n# return (fetch);\n# }\n\n# vcl_deliver: Called before an object is delivered to the client\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-deliver\nsub vcl_deliver {\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # Add whether the object is a cache hit or miss and the number of hits for the object.\n # https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Addingaheaderindicatinghitmiss\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n set resp.http.X-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Cache = \"MISS\";\n \/* Show the results of cookie sanitization *\/\n set resp.http.X-Cookie = req.http.Cookie;\n }\n #TODO# Add sick marker\n # Restart count\n if ( req.restarts > 0) {\n set resp.http.X-Restarts = req.restarts;\n }\n\n # Add the Varnish server hostname\n set resp.http.X-Varnish-Server = server.hostname;\n # If we have setted a custom header with device family detected we can show it:\n # if (req.http.X-UA-Device) {\n # set resp.http.X-UA-Device = req.http.X-UA-Device;\n # }\n # If we have recived a custom header with the protocol in the request we can show it:\n # if (req.http.X-Forwarded-Proto) {\n # set resp.http.X-Forwarded-Proto = req.http.X-Forwarded-Proto;\n # }\n\n \/* Vary header manipulation *\/\n # Empty in simple configs.\n # By example, if we are storing & serving diferent objects depending on User-Agent header we must set the correct Vary header:\n # if (resp.http.Vary) {\n # set resp.http.Vary = resp.http.Vary + \",User-Agent\";\n # } else {\n # set resp.http.Vary = \"User-Agent\";\n # }\n\n \/* Fake headers *\/\n # Empty in simple configs\n # We can fake server headers here, by example:\n # set resp.http.Server = \"Deep thought\";\n # set resp.http.X-Powered-By = \"BOFH\";\n # Or have some fun with headers:\n # See http:\/\/www.nextthing.org\/archives\/2005\/08\/07\/fun-with-http-headers\n # See http:\/\/royal.pingdom.com\/2012\/08\/15\/fun-and-unusual-http-response-headers\/\n # set resp.http.X-Thank-You = \"for bothering to look at my HTTP headers\";\n # set resp.http.X-Answer = \"42\";\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_deliver {\n# return (deliver);\n# }\n\n# vcl_synth: Called to deliver a synthetic object. A synthetic object is generated in VCL,\n# not fetched from the backend. It is typically contructed using the synthetic() function.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-synth\n\/*\n * We can come here \"invisibly\" with the following errors: 413, 417 & 503\n *\/\nsub vcl_synth {\n \/* Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_synth;\n\n \/* Try to restart request in case of failure *\/\n # Note that max_restarts defaults to 4\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if (resp.status == 503 && req.restarts < 4) {\n return(restart);\n }\n\n \/* Set common headers for synthetic responses *\/\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n\n \/* HTTP Authentification client request *\/\n # Empty in simple configs. SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* Error page & refresh \/ redirections *\/\n # We have plenty of choices when we have to serve an error to the client, \n # from the default error page to javascript black magic or plain redirections.\n # Adding some external statistic javascript to track failures served to clients is strongly suggested.\n # We can't use external resources on synthetic content, everything must be inlined.\n # If we need to include images we can embed them in base64 encoding.\n # Here is the default error page for Varnish 4 (not so pretty)\n # We're using error 200 for monitoring puposes which should not be retried client side *\/\n if ( resp.status != 200) {\n set resp.http.Retry-After = \"5\";\n }\n # Consider add some analytics stuff to trace accesses\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning inconditionally.\n return (deliver);\n}\n\n#######################################################################\n# Backend Fetch\n\n# vcl_backend_fetch: Called before sending the backend request. In this subroutine you typically alter the request before it gets to the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-fetch\n# sub vcl_backend_fetch {\n# return (fetch);\n# }\n\n# vcl_backend_response: Called after the response headers has been successfully retrieved from the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-response\nsub vcl_backend_response {\n \/* Caching exceptions *\/\n # Varnish will cache objects with response codes: 200, 203, 300, 301, 302, 307, 404 & 410.\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/VCL_Basics.html#the-initial-value-of-beresp-ttl\n # Drupal's Imagecache module can return a 307 redirection to the requested url itself and, depending on Drupal's cache settings,\n # this could lead to a redirection loop being cached for a long time but also we want Varnish to shield a little the backend.\n # See http:\/\/drupal.org\/node\/1248010\n # See http:\/\/drupal.org\/node\/310656\n if (beresp.status == 307 &&\n #TODO# verify that this work better than 'bereq.url ~ \"imagecache\"' *\/\n beresp.http.Location == bereq.url &&\n beresp.ttl > 5s) {\n set beresp.ttl = 5s;\n set beresp.http.cache-control = \"max-age=5\";\n }\n\n \/* Request retrial *\/\n if ( beresp.status == 500\n || beresp.status == 503\n ) {\n #TODO# consider not restarting POST requests as seenV3 on https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleSaintMode\n return (retry);\n }\n\n \/* Enable grace mode. Related with vcl_hit *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n set beresp.grace = 1h;\n\n \/* Strip cookies from the following static file types for all users. Related with our 12th stage on vcl_recv *\/\n if (bereq.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|woff2|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\") {\n unset beresp.http.set-cookie;\n }\n\n \/* Gzip response *\/\n # Empty in simple configs\n # Use Varnish to Gzip respone, if suitable, before storing it on cache\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html\n if ( ! beresp.http.Content-Encoding\n && ( beresp.http.content-type ~ \"text\"\n || beresp.http.content-type ~ \"application\/x-javascript\"\n || beresp.http.content-type ~ \"application\/javascript\"\n || beresp.http.content-type ~ \"application\/rss+xml\"\n || beresp.http.content-type ~ \"application\/xml\"\n || beresp.http.content-type ~ \"Application\/JSON\")\n ) {\n set beresp.do_gzip = true;\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # We can add the name of the backend that has processed the request:\n # set beresp.http.X-Backend = beresp.backend.name;\n # We can use a header to tell if the object was gziped by Varnish\n # if (beresp.do_gzip) {\n # set beresp.http.X-Varnish-Gzipped = \"yes\";\n # } else {\n # set beresp.http.X-Varnish-Gizipped = \"no\";\n # }\n # We can also add headers informing whether the object is cacheable or not and why.\n # https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Varnish3.0\n if (beresp.ttl <= 0s) {\n \/* Varnish determined the object was not cacheable *\/\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n } elsif (bereq.http.Cookie ~ \"(SESS|SSESS|NO_CACHE|OATMEAL|CHOCOLATECHIP)\") {\n \/* We don't wish to cache content for logged in users or with certain cookies. Related with our 9th stage on vcl_recv *\/\n set beresp.http.X-Cacheable = \"NO:Cookies\";\n # return(hit_for_pass);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n \/* We are respecting the Cache-Control=private header from the backend *\/\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n # return(hit_for_pass);\n } else {\n \/* Varnish determined the object was cacheable *\/\n set beresp.http.X-Cacheable = \"YES\";\n }\n\n \/* Further header manipulation *\/\n # Empty in simple configs.\n # We can also unset some headers to prevent information disclosure and save some cache space\n # unset beresp.http.Server;\n # unset beresp.http.X-Powered-By;\n # Retry count\n if ( bereq.retries > 0) {\n set beresp.http.X-Retries = bereq.retries;\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_backend_response {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Surrogate-control ~ \"no-store\" ||\n# (!beresp.http.Surrogate-Control &&\n# beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n# beresp.http.Vary == \"*\") {\n# \/*\n# * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# *\/\n# set beresp.ttl = 120s;\n# set beresp.uncacheable = true;\n# }\n# return (deliver);\n# }\n\n# vcl_backend_error: This subroutine is called if we fail the backend fetch.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-error\nsub vcl_backend_error {\n\n \/* Try to restart request in case of failure *\/\n #TODO# Confirm max_retries default value\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if (bereq.retries < 4) {\n return (retry);\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # Retry count\n if ( bereq.retries > 0) {\n set beresp.http.X-Retries = bereq.retries;\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + beresp.status + \" \" + beresp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + beresp.status + \" \" + beresp.reason + {\"<\/h1>\n <p>\"} + beresp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + bereq.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this point.\n return (deliver);\n}\n\n#######################################################################\n# Housekeeping\n\n# vcl_init: Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-init\n# Here is where you should declare your directors now.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-backends.html#directors\n# Empty in simple configs\n# sub vcl_init {\n# return (ok);\n# }\n\n# vcl_fini: Called when VCL is discarded only after all requests have exited the VCL. Typically used to clean up VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-fini\n# sub vcl_fini {\n# return (ok);\n# }\n\n","returncode":0,"stderr":"","license":"unknown","lang":"VCL"} {"commit":"8297db6db8e0bf262de5efed43db4d4cf177a6d4","subject":"force gzip compression with varnish","message":"force gzip compression with varnish\n","repos":"fhartwig\/adhocracy3.mercator,liqd\/adhocracy3.mercator,fhartwig\/adhocracy3.mercator,fhartwig\/adhocracy3.mercator,liqd\/adhocracy3.mercator,fhartwig\/adhocracy3.mercator,xs2maverick\/adhocracy3.mercator,liqd\/adhocracy3.mercator,xs2maverick\/adhocracy3.mercator,xs2maverick\/adhocracy3.mercator,xs2maverick\/adhocracy3.mercator,xs2maverick\/adhocracy3.mercator,liqd\/adhocracy3.mercator,liqd\/adhocracy3.mercator,liqd\/adhocracy3.mercator,fhartwig\/adhocracy3.mercator,xs2maverick\/adhocracy3.mercator,fhartwig\/adhocracy3.mercator,fhartwig\/adhocracy3.mercator,liqd\/adhocracy3.mercator","old_file":"src\/adhocracy_core\/varnish.vcl","new_file":"src\/adhocracy_core\/varnish.vcl","new_contents":"vcl 4.0;\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"6541\";\n}\n\nacl purge {\n \"localhost\";\n}\n\nsub vcl_recv {\n\n # purge purge requests if from localhost\n # Allow to purge regular expressio\u01f9s with header\n # X-Purge-Regex and host name with X-Purge-Host.\n if (req.method == \"PURGE\") {\n if (!client.ip ~ purge) {\n return(synth(405, \"Not allowed.\"));\n }\n ban(\"req.http.host == \" + req.http.X-Purge-Host +\n \" && req.url ~ \" + req.url + req.http.X-Purge-Regex);\n return(synth(200, \"Purged\"));\n }\n\n \/* pipe (ignore) non GET and HEAD and OPTIONS requests*\/\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"OPTIONS\") {\n return(pipe);\n }\n return(hash);\n}\n\nsub vcl_backend_response {\n if (beresp.http.content-type ~ \"application\/json\") {\n set beresp.do_gzip = true;\n }\n}\n","old_contents":"vcl 4.0;\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"6541\";\n}\n\nacl purge {\n \"localhost\";\n}\n\nsub vcl_recv {\n\n # purge purge requests if from localhost\n # Allow to purge regular expressio\u01f9s with header\n # X-Purge-Regex and host name with X-Purge-Host.\n if (req.method == \"PURGE\") {\n if (!client.ip ~ purge) {\n return(synth(405, \"Not allowed.\"));\n }\n ban(\"req.http.host == \" + req.http.X-Purge-Host +\n \" && req.url ~ \" + req.url + req.http.X-Purge-Regex);\n return(synth(200, \"Purged\"));\n }\n\n \/* pipe (ignore) non GET and HEAD and OPTIONS requests*\/\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"OPTIONS\") {\n return(pipe);\n }\n return(hash);\n}\n\n\n","returncode":0,"stderr":"","license":"agpl-3.0","lang":"VCL"} {"commit":"f18f001b3488f572d9f6ebd29c6c3188f5d27af3","subject":"Remove unused error code response","message":"Remove unused error code response\n","repos":"JakeChampion\/polyfill-service,JakeChampion\/polyfill-service","old_file":"fastly\/vcl\/redirects.vcl","new_file":"fastly\/vcl\/redirects.vcl","new_contents":"sub vcl_recv {\n\tif (req.http.Host ~ \"polyfills.io\") {\n\t\t# Fastly recommend using the 900-999 range of status codes for custom errors within an application's VCL.\n\t\t# Do the canonicalise checks before the HTTPS check to avoid a double redirect\n\t\terror 901 \"Canonicalise\";\n\t}\n\tif (req.http.Host ~ \"www.polyfills.io\") {\n\t\t# Fastly recommend using the 900-999 range of status codes for custom errors within an application's VCL.\n\t\t# Do the canonicalise checks before the HTTPS check to avoid a double redirect\n\t\terror 901 \"Canonicalise\";\n\t}\n\tif (req.http.Host ~ \"www.polyfill.io\") {\n\t\t# Do the canonicalise checks before the HTTPS check to avoid a double redirect\n\t\terror 901 \"Canonicalise\";\n\t}\n\tif (!req.http.Fastly-SSL) {\n\t\t# 801 is a special error code that Fastly uses to Force HTTPS on the request\n\t\terror 801 \"Redirect to HTTPS\";\n\t}\n\tif (req.http.Orig-URL ~ \"^\/v1\") {\n\t\terror 902 \"Redirect to V2\";\n\t}\n\t\n\tif (req.url.path ~ \"^\/v2\/?\") {\n\t\tif (!(req.url.path ~ \"^\/v2\/polyfill(\\.\\w+)(\\.\\w+)?\" && req.url.ext == \"js\")) {\n\t\t\terror 908;\n\t\t}\n\t}\n\tif (req.url.path == \"\/\") {\n\t\terror 908;\n\t}\n}\n\nsub vcl_error {\n\t# Redirect to canonical prod\/qa origins\n\tif (obj.status == 901) {\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\tset obj.http.Location = \"https:\/\/polyfill.io\" req.url;\n\t\tsynthetic {\"\"};\n\t\treturn (deliver);\n\t}\n\t# Redirect to v2\n\tif (obj.status == 902) {\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\t# Remove libVersion and gated query parameters if they exist.\n\t\tset req.url = querystring.regfilter(req.url, \"^\\b(libVersion|gated)\\b.*\");\n\t\tset obj.http.Location = if(req.url.path == \"\/v1\", \"\/v3\/\", regsub(req.url, \"^\/v1\", \"\/v2\"));\n\t\tset obj.http.Deprecation-Notice = \"API version 1 has been decommissioned - see the body of this response for more information.\";\n\t\tsynthetic {\"API version 1 has been decommissioned. Your request is being redirected to v2. The `libVersion` and `gated` query string parameters are no longer supported and if present have been removed from your request.\\n\\nA deprecation period for v1 existed between August and December 2015, during which time v1 requests were honoured but a deprecation warning was added to output.\"};\n\t\treturn (deliver);\n\t}\n\n\t# Redirect to v3\n\tif (obj.status == 908) {\n\t\tset obj.status = 301;\n\t\tset obj.http.Location = \"\/v3\/\";\n\t\treturn (deliver);\n\t}\n\n}\n","old_contents":"sub vcl_recv {\n\tif (req.http.Host ~ \"polyfills.io\") {\n\t\t# Fastly recommend using the 900-999 range of status codes for custom errors within an application's VCL.\n\t\t# Do the canonicalise checks before the HTTPS check to avoid a double redirect\n\t\terror 901 \"Canonicalise\";\n\t}\n\tif (req.http.Host ~ \"www.polyfills.io\") {\n\t\t# Fastly recommend using the 900-999 range of status codes for custom errors within an application's VCL.\n\t\t# Do the canonicalise checks before the HTTPS check to avoid a double redirect\n\t\terror 901 \"Canonicalise\";\n\t}\n\tif (req.http.Host ~ \"www.polyfill.io\") {\n\t\t# Do the canonicalise checks before the HTTPS check to avoid a double redirect\n\t\terror 901 \"Canonicalise\";\n\t}\n\tif (!req.http.Fastly-SSL) {\n\t\t# 801 is a special error code that Fastly uses to Force HTTPS on the request\n\t\terror 801 \"Redirect to HTTPS\";\n\t}\n\tif (req.http.Orig-URL ~ \"^\/v1\") {\n\t\terror 902 \"Redirect to V2\";\n\t}\n\t\n\tif (req.url.path ~ \"^\/v2\/?\") {\n\t\tif (!(req.url.path ~ \"^\/v2\/polyfill(\\.\\w+)(\\.\\w+)?\" && req.url.ext == \"js\")) {\n\t\t\terror 908;\n\t\t}\n\t}\n\tif (req.url.path == \"\/\") {\n\t\terror 908;\n\t}\n}\n\nsub vcl_error {\n # Redirect to canonical prod\/qa origins\n\tif (obj.status == 901) {\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\tset obj.http.Location = \"https:\/\/polyfill.io\" req.url;\n\t\tsynthetic {\"\"};\n\t\treturn (deliver);\n\t}\n\t# Redirect to v2\n\tif (obj.status == 902) {\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\t# Remove libVersion and gated query parameters if they exist.\n\t\tset req.url = querystring.regfilter(req.url, \"^\\b(libVersion|gated)\\b.*\");\n\t\tset obj.http.Location = if(req.url.path == \"\/v1\", \"\/v3\/\", regsub(req.url, \"^\/v1\", \"\/v2\"));\n\t\tset obj.http.Deprecation-Notice = \"API version 1 has been decommissioned - see the body of this response for more information.\";\n\t\tsynthetic {\"API version 1 has been decommissioned. Your request is being redirected to v2. The `libVersion` and `gated` query string parameters are no longer supported and if present have been removed from your request.\\n\\nA deprecation period for v1 existed between August and December 2015, during which time v1 requests were honoured but a deprecation warning was added to output.\"};\n\t\treturn (deliver);\n\t}\n\n\t# Redirect to v3\n\tif (obj.status == 908) {\n\t\tset obj.status = 301;\n\t\tset obj.http.Location = \"\/v3\/\";\n\t\treturn (deliver);\n\t}\n\t\n\t# Redirect to home\n\tif (obj.status == 908) {\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\tset obj.http.Location = \"https:\/\/polyfill.io\";\n\t\tsynthetic {\"\"};\n\t\treturn (deliver);\n\t}\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"b685a6067689f6de5ae2d40e1d4cf382685fb312","subject":"We can't pass from the snippet. Module will add it's own request setting that passes","message":"We can't pass from the snippet. Module will add it's own request setting that passes\n","repos":"fastly\/fastly-magento,fastly\/fastly-magento,fastly\/fastly-magento,fastly\/fastly-magento","old_file":"app\/code\/community\/Fastly\/CDN\/etc\/vcl_snippets\/recv.vcl","new_file":"app\/code\/community\/Fastly\/CDN\/etc\/vcl_snippets\/recv.vcl","new_contents":" # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n # Sort the query arguments\n set req.url = boltsort.sort(req.url);\n\n # bypass language switcher\n if (req.url ~ \"(?i)___from_store=.*&___store=.*\") {\n set req.http.X-Pass = \"1\";\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (req.http.cookie:FASTLY_CDN_ENV) {\n set req.http.Fastly-Cdn-Env = req.http.cookie:FASTLY_CDN_ENV;\n } else {\n unset req.http.Fastly-Cdn-Env;\n }\n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n\n if (!req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n error 403;\n }\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n\n } else {\n error 403;\n }\n\n }\n\n # disable ESI processing on Origin Shield\n if (req.http.Fastly-FF) {\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(media|js|skin)\/.*\\.(png|jpg|jpeg|gif|css|js|swf|ico)$\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n # formkey lookup\n if (req.url ~ \"\/fastlycdn\/getformkey\/\") {\n # check if we have a formkey cookie\n if (req.http.Cookie:FASTLY_CDN_FORMKEY) {\n set req.http.Formkey = req.http.Cookie:FASTLY_CDN_FORMKEY;\n } else {\n # create formkey\n set req.http.seed = req.http.Cookie client.ip remote.port client.geo.longitude client.geo.latitude client.geo.postal_code;\n set req.http.Formkey = regsub(digest.hash_md5(req.http.seed), \"^0x\", \"\");\n }\n error 760 req.http.Formkey;\n }\n\n # client.geo lookup\n if (req.url ~ \"fastlycdn\/esi\/getcountry\/\") {\n # check if GeoIP has been already processed by client\n if (req.http.Cookie:FASTLY_CDN_GEOIP_PROCESSED) {\n error 200 \"\";\n } else {\n # modify req.url and restart request processing\n error 750 client.geo.country_code;\n }\n }\n\n # client.geo get country code\n if (req.url ~ \"fastlycdn\/esi\/getcountrycode\/\") {\n # create and set req.http.X-Country-Code\n error 755 client.geo.country_code;\n }\n\n # check for ESI calls\n if (req.url ~ \"esi_data=\") {\n # check for valid cookie data\n if (req.http.Cookie ~ \"FASTLY_CDN-([A-Za-z0-9-_]+)=([^;]*)\") {\n set req.url = querystring.filter(req.url, \"esi_data\") + \"&esi_data=\" + re.group.2;\n }\n }\n\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking\n set req.http.Magento-Original-URL = req.url;\n set req.url = querystring.regfilter(req.url, \"^(utm_.*|gclid|gdftrk|_ga|mc_.*)\");\n","old_contents":" # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n # Sort the query arguments\n set req.url = boltsort.sort(req.url);\n\n # bypass language switcher\n if (req.url ~ \"(?i)___from_store=.*&___store=.*\") {\n set req.http.X-Pass = \"1\";\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (req.http.cookie:FASTLY_CDN_ENV) {\n set req.http.Fastly-Cdn-Env = req.http.cookie:FASTLY_CDN_ENV;\n } else {\n unset req.http.Fastly-Cdn-Env;\n }\n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n\n if (!req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n error 403;\n }\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n\n } else {\n error 403;\n }\n\n }\n\n # disable ESI processing on Origin Shield\n if (req.http.Fastly-FF) {\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(media|js|skin)\/.*\\.(png|jpg|jpeg|gif|css|js|swf|ico)$\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n # formkey lookup\n if (req.url ~ \"\/fastlycdn\/getformkey\/\") {\n # check if we have a formkey cookie\n if (req.http.Cookie:FASTLY_CDN_FORMKEY) {\n set req.http.Formkey = req.http.Cookie:FASTLY_CDN_FORMKEY;\n } else {\n # create formkey\n set req.http.seed = req.http.Cookie client.ip remote.port client.geo.longitude client.geo.latitude client.geo.postal_code;\n set req.http.Formkey = regsub(digest.hash_md5(req.http.seed), \"^0x\", \"\");\n }\n error 760 req.http.Formkey;\n }\n\n # client.geo lookup\n if (req.url ~ \"fastlycdn\/esi\/getcountry\/\") {\n # check if GeoIP has been already processed by client\n if (req.http.Cookie:FASTLY_CDN_GEOIP_PROCESSED) {\n error 200 \"\";\n } else {\n # modify req.url and restart request processing\n error 750 client.geo.country_code;\n }\n }\n\n # client.geo get country code\n if (req.url ~ \"fastlycdn\/esi\/getcountrycode\/\") {\n # create and set req.http.X-Country-Code\n error 755 client.geo.country_code;\n }\n\n # check for ESI calls\n if (req.url ~ \"esi_data=\") {\n # check for valid cookie data\n if (req.http.Cookie ~ \"FASTLY_CDN-([A-Za-z0-9-_]+)=([^;]*)\") {\n set req.url = querystring.filter(req.url, \"esi_data\") + \"&esi_data=\" + re.group.2;\n }\n }\n\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking\n set req.http.Magento-Original-URL = req.url;\n set req.url = querystring.regfilter(req.url, \"^(utm_.*|gclid|gdftrk|_ga|mc_.*)\");\n\n # If object has been marked as pass pass it\n if ( req.http.X-Pass ) {\n return(pass);\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"ef7a82f86e04dceb10d29797f282f8d5d26bf178","subject":"Update sample varnish to make use of cache headers coming from webapp","message":"Update sample varnish to make use of cache headers coming from webapp\n","repos":"AstunTechnology\/NRW_FishMapMon,AstunTechnology\/NRW_FishMapMon,AstunTechnology\/NRW_FishMapMon,AstunTechnology\/NRW_FishMapMon","old_file":"config\/varnish\/default.vcl","new_file":"config\/varnish\/default.vcl","new_contents":"# This is a basic VCL configuration file for varnish. See the vcl(7)\n# man page for details on VCL syntax and semantics.\n# \n# Default backend definition. Set this to point to your content\n# server.\n# \nbackend cy {\n .host = \"cy.blah\";\n .port = \"8001\";\n}\n\nbackend en {\n .host = \"en.blah\";\n .port = \"8002\";\n}\n\n\n# \n# Below is a commented-out copy of the default VCL logic. If you\n# redefine any of these subroutines, the built-in logic will be\n# appended to your code.\nsub vcl_recv {\n\tif (req.http.host ~ \"(?i)^(www.)?cy.blah\") {\n\t\tset req.http.host = \"cy.blah\";\n\t\tset req.backend = cy;\n\t}\n\telsif (req.http.host ~ \"(?i)^(www.)?en.blah\") {\n\t\tset req.http.host = \"en.blah\";\n\t\tset req.backend = en;\n\t}\n\n\n\tif ( req.url ~ \"^\/static\/\" ) {\n\t\tunset req.http.Cookie;\n\t}\n\tif ( req.url ~ \"^\/wms\" ) {\n\t\t# allow caching but rely on headers from backend\n\t\treturn (lookup);\n\t}\n# if (req.restarts == 0) {\n# \tif (req.http.x-forwarded-for) {\n# \t set req.http.X-Forwarded-For =\n# \t\treq.http.X-Forwarded-For + \", \" + client.ip;\n# \t} else {\n# \t set req.http.X-Forwarded-For = client.ip;\n# \t}\n# }\n# if (req.request != \"GET\" &&\n# req.request != \"HEAD\" &&\n# req.request != \"PUT\" &&\n# req.request != \"POST\" &&\n# req.request != \"TRACE\" &&\n# req.request != \"OPTIONS\" &&\n# req.request != \"DELETE\") {\n# \/* Non-RFC2616 or CONNECT which is weird. *\/\n# return (pipe);\n# }\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization || req.http.Cookie) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n return (lookup);\n}\n# \n# sub vcl_pipe {\n# # Note that only the first request to the backend will have\n# # X-Forwarded-For set. If you use X-Forwarded-For and want to\n# # have it set for all requests, make sure to have:\n# # set bereq.http.connection = \"close\";\n# # here. It is not set by default as it might break some broken web\n# # applications, like IIS with NTLM authentication.\n# return (pipe);\n# }\n# \n# sub vcl_pass {\n# return (pass);\n# }\n# \n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (hash);\n# }\n# \n# sub vcl_hit {\n# return (deliver);\n# }\n# \n# sub vcl_miss {\n# return (fetch);\n# }\n# \nsub vcl_fetch {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Vary == \"*\") {\n# \t\t\/*\n# \t\t * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# \t\t *\/\n# \t\tset beresp.ttl = 120 s;\n# \t\treturn (hit_for_pass);\n# }\n\tif ( req.url ~ \"^\/wms\" ) {\n \t\tunset beresp.http.set-cookie;\n\t\tunset beresp.http.expires;\n\t}\t\t\n return (deliver);\n}\n# \n# sub vcl_deliver {\n# return (deliver);\n# }\n# \n# sub vcl_error {\n# set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n# set obj.http.Retry-After = \"5\";\n# synthetic {\"\n# <?xml version=\"1.0\" encoding=\"utf-8\"?>\n# <!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n# \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n# <html>\n# <head>\n# <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n# <\/head>\n# <body>\n# <h1>Error \"} + obj.status + \" \" + obj.response + {\"<\/h1>\n# <p>\"} + obj.response + {\"<\/p>\n# <h3>Guru Meditation:<\/h3>\n# <p>XID: \"} + req.xid + {\"<\/p>\n# <hr>\n# <p>Varnish cache server<\/p>\n# <\/body>\n# <\/html>\n# \"};\n# return (deliver);\n# }\n# \n# sub vcl_init {\n# \treturn (ok);\n# }\n# \n# sub vcl_fini {\n# \treturn (ok);\n# }\n","old_contents":"# This is a basic VCL configuration file for varnish. See the vcl(7)\n# man page for details on VCL syntax and semantics.\n# \n# Default backend definition. Set this to point to your content\n# server.\n# \nbackend cy {\n .host = \"cy.blah\";\n .port = \"8001\";\n}\n\nbackend en {\n .host = \"en.blah\";\n .port = \"8002\";\n}\n\n\n# \n# Below is a commented-out copy of the default VCL logic. If you\n# redefine any of these subroutines, the built-in logic will be\n# appended to your code.\nsub vcl_recv {\n\tif (req.http.host ~ \"(?i)^(www.)?cy.blah\") {\n\t\tset req.http.host = \"cy.blah\";\n\t\tset req.backend = cy;\n\t}\n\telsif (req.http.host ~ \"(?i)^(www.)?en.blah\") {\n\t\tset req.http.host = \"en.blah\";\n\t\tset req.backend = en;\n\t}\n\n\tif ( req.url ~ \"^\/wms\\?map=fishmap\" ) {\n\t\treturn (pass);\n\t}\n\n\tif ( req.url ~ \"^\/static\/\" ) {\n\t\treturn (lookup);\n\t}\n\tif ( req.url ~ \"^\/wms\" ) {\n\t\treturn (lookup);\n\t}\n# if (req.restarts == 0) {\n# \tif (req.http.x-forwarded-for) {\n# \t set req.http.X-Forwarded-For =\n# \t\treq.http.X-Forwarded-For + \", \" + client.ip;\n# \t} else {\n# \t set req.http.X-Forwarded-For = client.ip;\n# \t}\n# }\n# if (req.request != \"GET\" &&\n# req.request != \"HEAD\" &&\n# req.request != \"PUT\" &&\n# req.request != \"POST\" &&\n# req.request != \"TRACE\" &&\n# req.request != \"OPTIONS\" &&\n# req.request != \"DELETE\") {\n# \/* Non-RFC2616 or CONNECT which is weird. *\/\n# return (pipe);\n# }\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization || req.http.Cookie) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n return (lookup);\n}\n# \n# sub vcl_pipe {\n# # Note that only the first request to the backend will have\n# # X-Forwarded-For set. If you use X-Forwarded-For and want to\n# # have it set for all requests, make sure to have:\n# # set bereq.http.connection = \"close\";\n# # here. It is not set by default as it might break some broken web\n# # applications, like IIS with NTLM authentication.\n# return (pipe);\n# }\n# \n# sub vcl_pass {\n# return (pass);\n# }\n# \n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (hash);\n# }\n# \n# sub vcl_hit {\n# return (deliver);\n# }\n# \n# sub vcl_miss {\n# return (fetch);\n# }\n# \nsub vcl_fetch {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Vary == \"*\") {\n# \t\t\/*\n# \t\t * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# \t\t *\/\n# \t\tset beresp.ttl = 120 s;\n# \t\treturn (hit_for_pass);\n# }\n\tif ( req.url ~ \"^\/wms\\?map=fishmap\" ) {\n\t\tunset beresp.http.last-modified;\n\t\treturn (hit_for_pass);\n\t}\n\tif ( req.url ~ \"^\/wms\" ) {\n \t\tunset beresp.http.set-cookie;\n\t\tunset beresp.http.expires;\n \t\tset beresp.ttl = 1w;\n\t set beresp.http.Cache-Control = \"max-age=1900\";\n\t}\t\t\n return (deliver);\n}\n# \n# sub vcl_deliver {\n# return (deliver);\n# }\n# \n# sub vcl_error {\n# set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n# set obj.http.Retry-After = \"5\";\n# synthetic {\"\n# <?xml version=\"1.0\" encoding=\"utf-8\"?>\n# <!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n# \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n# <html>\n# <head>\n# <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n# <\/head>\n# <body>\n# <h1>Error \"} + obj.status + \" \" + obj.response + {\"<\/h1>\n# <p>\"} + obj.response + {\"<\/p>\n# <h3>Guru Meditation:<\/h3>\n# <p>XID: \"} + req.xid + {\"<\/p>\n# <hr>\n# <p>Varnish cache server<\/p>\n# <\/body>\n# <\/html>\n# \"};\n# return (deliver);\n# }\n# \n# sub vcl_init {\n# \treturn (ok);\n# }\n# \n# sub vcl_fini {\n# \treturn (ok);\n# }\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"c3099a6f368496b3b2d4cce06084703d27aede4c","subject":"Add first attempt","message":"Add first attempt\n","repos":"rhargreaves\/fastly-vcl-experiments,rhargreaves\/fastly-vcl-experiments","old_file":"99_bottles.vcl","new_file":"99_bottles.vcl","new_contents":"backend F_fake_backend {\n\t.host = \"fake-backend.example.com\";\n\t.port = \"80\";\n\t.dynamic = true;\n\t.connect_timeout = 5s;\n\t.first_byte_timeout = 15s;\n\t.probe = {\n\t\t.dummy = true;\n\t}\n}\n\nsub vcl_recv {\n#FASTLY recv\n\tset req.backend = F_fake_backend;\n\n\tset req.http.X-Bottle = if(req.url ~ \"(?i)bottle=([^&]*)\", urldecode(re.group.1), \"99\");\n\tset req.http.X-Wall = if(req.http.X-Wall, \" \", \"\") req.http.X-Bottle;\n\n\tif(req.http.X-Bottle == \"0\") {\n\t\terror 996;\n\t}\n\treturn(lookup);\n}\n\nsub vcl_fetch {\n#FASTLY fetch\n\n\tif(req.restarts > 0) {\n\t\tset beresp.http.Fastly-Restarts = req.restarts;\n\t}\n\treturn(deliver);\n}\n\nsub vcl_deliver {\n#FASTLY deliver\n\tset resp.http.X-Wall = req.http.X-Wall;\n\n\tif(req.restarts == 2) {\n# For now, limit to 3 bottles as we can only restart 3 times\n\t\tset req.http.X-Next-Bottle = \"0\";\n\t}\n\n\tset req.url = \"\/?bottle=\" req.http.X-Next-Bottle;\n\tif(req.restarts < 2) {\n\t\trestart;\n\t}\n\treturn(deliver);\n}\n\nsub set_next_bottle {\n\tset req.grace = 1d;\n\tset req.http.X-Original-Grace = req.grace;\n\tset req.grace = std.atoi(req.http.X-Bottle);\n\tset req.grace -= 1s;\n\tset req.http.X-Next-Bottle = regsub(req.grace, \"\\..*\", \"\");\n\tset req.grace = std.atoi(req.http.X-Original-Grace);\n}\n\nsub vcl_error {\n#FASTLY error\n\tif(obj.status == 996) {\n\t\tset obj.status = 200;\n\t\tset obj.response = \"Cheers!\";\n\t\tsynthetic req.http.X-Wall;\n\t\treturn (deliver);\n\t}\n}\n","old_contents":"sub vcl_recv {\n#FASTLY recv\n return(lookup);\n}\n\nsub vcl_fetch {\n#FASTLY fetch\n\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n return(deliver);\n}\n\nsub vcl_hit {\n#FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\nsub vcl_miss {\n#FASTLY miss\n return(fetch);\n}\n\nsub vcl_deliver {\n#FASTLY deliver\n return(deliver);\n}\n\nsub vcl_error {\n#FASTLY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"f7efe7643cfc787afca73e835ccaa5da66291291","subject":"We need to move the check for Cache-Control private prior to the \"non-cacheable\" assets because for backend protection purposes we set a very low TTL to deliver these errors if things go bad with the backend. Unfortunately this may inadvertently cache things we were not supposed to cache.","message":"We need to move the check for Cache-Control private prior to the \"non-cacheable\"\nassets because for backend protection purposes we set a very low TTL to deliver\nthese errors if things go bad with the backend. Unfortunately this may inadvertently\ncache things we were not supposed to cache.\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets\/fetch.vcl","new_file":"etc\/vcl_snippets\/fetch.vcl","new_contents":" \/* handle 5XX (or any other unwanted status code) *\/\n if (beresp.status >= 500 && beresp.status < 600) {\n\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n \/* deliver stale if the object is available *\/\n if (stale.exists) {\n return(deliver_stale);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n \/* else go to vcl_error to deliver a synthetic *\/\n error 503;\n }\n\n # Remove Set-Cookies from responses for static content\n # to match the cookie removal in recv.\n if (req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's since those can be temporary during the site build\/index\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n }\n\n }\n\n if (req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Content-Type ~ \"text\/(html|xml)\") {\n # enable ESI feature for Magento response by default\n esi;\n if (!beresp.http.Vary ~ \"X-Magento-Vary,Https\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \",X-Magento-Vary,Https\";\n } else {\n set beresp.http.Vary = \"X-Magento-Vary,Https\";\n }\n }\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content\n if (http_status_matches(beresp.status, \"200,404\") && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url.ext ~ \"(?i)(css|js|html|eot|ico|otf|ttf|json)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # cache only successfully responses and 404s\n if ( !http_status_matches(beresp.status, \"200,301,404\")) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\") && !req.http.x-pass ) {\n unset beresp.http.set-cookie;\n if (req.url !~ \"^\/(pub\/)?(media|static)\/.*\") {\n set beresp.grace = 86400m;\n }\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type\n if (beresp.http.Content-Type ~ \"image\") {\n set beresp.http.Surrogate-Key = \"image\";\n } elsif (beresp.http.Content-Type ~ \"script\") {\n set beresp.http.Surrogate-Key = \"script\";\n } elsif (beresp.http.Content-Type ~ \"css\") {\n set beresp.http.Surrogate-Key = \"css\";\n }\n return (deliver);\n }\n","old_contents":" \/* handle 5XX (or any other unwanted status code) *\/\n if (beresp.status >= 500 && beresp.status < 600) {\n\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n \/* deliver stale if the object is available *\/\n if (stale.exists) {\n return(deliver_stale);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n \/* else go to vcl_error to deliver a synthetic *\/\n error 503;\n }\n\n # Remove Set-Cookies from responses for static content\n # to match the cookie removal in recv.\n if (req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's since those can be temporary during the site build\/index\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n }\n\n }\n\n if (req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Content-Type ~ \"text\/(html|xml)\") {\n # enable ESI feature for Magento response by default\n esi;\n if (!beresp.http.Vary ~ \"X-Magento-Vary,Https\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \",X-Magento-Vary,Https\";\n } else {\n set beresp.http.Vary = \"X-Magento-Vary,Https\";\n }\n }\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content\n if (http_status_matches(beresp.status, \"200,404\") && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url.ext ~ \"(?i)(css|js|html|eot|ico|otf|ttf|json)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # cache only successfully responses and 404s\n if ( !http_status_matches(beresp.status, \"200,301,404\")) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\") && !req.http.x-pass ) {\n unset beresp.http.set-cookie;\n if (req.url !~ \"^\/(pub\/)?(media|static)\/.*\") {\n set beresp.grace = 86400m;\n }\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type\n if (beresp.http.Content-Type ~ \"image\") {\n set beresp.http.Surrogate-Key = \"image\";\n } elsif (beresp.http.Content-Type ~ \"script\") {\n set beresp.http.Surrogate-Key = \"script\";\n } elsif (beresp.http.Content-Type ~ \"css\") {\n set beresp.http.Surrogate-Key = \"css\";\n }\n return (deliver);\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"647e0b5c93522dc91f0b89e589ed958dc7e9d657","subject":"Always sort query arguments","message":"Always sort query arguments\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/fastly.vcl","new_file":"etc\/fastly.vcl","new_contents":"###############################################################################\n#\n# Fastly CDN for Magento 2\n#\n# NOTICE OF LICENSE\n#\n# This source file is subject to the Fastly CDN for Magento 2 End User License\n# Agreement that is bundled with this package in the file LICENSE_FASTLY_CDN.txt.\n#\n# @copyright Copyright (c) 2016 Fastly, Inc. (http:\/\/www.fastly.com)\n# @license BSD, see LICENSE_FASTLY_CDN.txt\n#\n###############################################################################\n\n# This is a basic VCL configuration file for Fastly CDN for Magento 2 module.\n\nsub vcl_recv {\n#FASTLY recv\n\n # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n # Sort the query arguments\n set req.url = boltsort.sort(req.url);\n\n if (req.url ~ \"^\/static\/version(\\d*\/)?(.*)$\") {\n set req.url = \"\/static\/\" + re.group.2 + \"?\" + re.group.1;\n } \n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n set req.http.X-Sig = regsub(req.http.X-Purge-Token, \"^[^_]+_(.*)\", \"\\1\");\n set req.http.X-Exp = regsub(req.http.X-Purge-Token, \"^([^_]+)_.*\", \"\\1\");\n\n # validate signature\n if (req.http.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path req.http.X-Exp), \"^0x\", \"\")) {\n\n # use vcl time math to check expiration timestamp\n set req.http.X-Original-Grace = req.grace;\n set req.grace = std.atoi(strftime({\"%s\"}, now));\n set req.grace -= std.atoi(req.http.X-Exp);\n\n if (std.atoi(req.grace) > 0) {\n error 410;\n }\n\n # clean up grace since we used it for time math\n set req.grace = std.atoi(req.http.X-Original-Grace);\n unset req.http.X-Original-Grace;\n\n } else {\n error 403;\n }\n\n # cleanup variables\n unset req.http.X-Purge-Token;\n unset req.http.X-Sig;\n unset req.http.X-Exp;\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n # disable ESI processing on Origin Shield\n if (req.http.Fastly-FF) {\n set req.esi = false;\n }\n\n # We only deal with GET and HEAD by default\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n return (pass);\n }\n \n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie ~ \"(X-Magento-Vary|form_key)=\") {\n error 200 \"\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url !~ \"country_code=\" ) {\n set req.url = req.url \"?country_code=\" if ( req.http.geo_override, req.http.geo_override, geoip.country_code);\n }\n }\n } else {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking\n set req.http.Fastly-Original-URL = req.url;\n set req.url = querystring.regfilter(req.url, \"^(utm_.*|gclid|gdftrk|_ga|mc_.*)\");\n }\n \n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n return (lookup);\n }\n\n # Bypass shopping cart and checkout requests\n if (req.url ~ \"\/checkout\") {\n return (pass);\n }\n\n return(lookup);\n}\n\nsub vcl_fetch {\n\n # Remove Set-Cookies from responses for static content\n # to match the cookie removal in recv.\n if (req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n }\n\n }\n\n#FASTLY fetch\n\n if (beresp.status >= 500) {\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n }\n\n if (req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Content-Type ~ \"text\/html\" || beresp.http.Content-Type ~ \"text\/xml\") {\n # enable ESI feature for Magento response by default\n esi;\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content\n if ((beresp.status == 200 || beresp.status == 404) && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url ~ \"\\.(css|js|html|eot|ico|otf|ttf|json)($|\\?)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # cache only successfully responses and 404s\n if (beresp.status != 200 && beresp.status != 301 && beresp.status != 404) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\")) {\n unset beresp.http.set-cookie;\n if (req.url !~ \"^\/(pub\/)?(media|static)\/.*\") {\n set beresp.grace = 86400m;\n }\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type\n if (beresp.http.Content-Type ~ \"image\") {\n set beresp.http.Surrogate-Key = \"image\";\n } elsif (beresp.http.Content-Type ~ \"script\") {\n set beresp.http.Surrogate-Key = \"script\";\n } elsif (beresp.http.Content-Type ~ \"css\") {\n set beresp.http.Surrogate-Key = \"css\";\n }\n\n set beresp.http.X-Surrogate-Key = beresp.http.Surrogate-Key;\n return (deliver);\n }\n\n return (deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\n\nsub vcl_miss {\n # Deactivate gzip on origin\n unset bereq.http.Accept-Encoding;\n\n#FASTLY miss\n\n return(fetch);\n}\n\nsub vcl_deliver {\n\n # Send no cache headers to end users for non-static content. Also make sure\n # we only set this on the edge nodes and not on shields\n if (req.url !~ \"^\/(pub\/)?(media|static)\/.*\" && !req.http.Fastly-FF ) {\n set resp.http.Pragma = \"no-cache\";\n set resp.http.Cache-Control = \"no-store, no-cache, must-revalidate, max-age=0\";\n }\n\n # Add an easy way to see whether custom Fastly VCL has been uploaded\n if ( req.http.Fastly-Debug ) {\n set resp.http.Fastly-Magento-VCL-Uploaded = \"yes\";\n } else {\n remove resp.http.Fastly-Module-Enabled;\n }\n # debug info\n if (resp.http.X-Magento-Debug) {\n if (obj.hits > 0) {\n set resp.http.X-Magento-Cache-Debug = \"HIT\";\n set resp.http.X-Magento-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Magento-Cache-Debug = \"MISS\";\n }\n } else {\n # remove Varnish\/proxy header\n remove resp.http.Age;\n remove resp.http.X-Magento-Debug;\n remove resp.http.X-Magento-Tags;\n remove resp.http.X-Surrogate-Key;\n remove resp.http.X-Magento-Cache-Control;\n remove resp.http.X-Powered-By;\n remove resp.http.Server;\n remove resp.http.X-Varnish;\n remove resp.http.Via;\n remove resp.http.Link;\n remove resp.http.X-Purge-URL;\n remove resp.http.X-Purge-Host;\n }\n\n#FASTLY deliver\n\n return (deliver);\n}\n\n\nsub vcl_error {\n # workaround for possible security issue\n if (req.url ~ \"^\\s\") {\n set obj.status = 400;\n set obj.response = \"Malformed request\";\n synthetic \"\";\n return (deliver);\n }\n\n # error 200\n if (obj.status == 200) {\n return (deliver);\n }\n\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} obj.status \" \" obj.response {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} obj.status \" \" obj.response {\"<\/h1>\n <p>\"} obj.response {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} req.xid {\"<\/p>\n <hr>\n <p>Fastly CDN server<\/p>\n <\/body>\n<\/html>\n\"};\n\n#FASTLY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n\nsub vcl_hash {\n set req.hash += req.http.Https;\n set req.hash += req.http.host;\n set req.hash += req.url;\n\n if (req.http.cookie:X-Magento-Vary ) {\n set req.hash += req.http.cookie:X-Magento-Vary;\n }\n \n set req.hash += \"#####GENERATION#####\";\n\n ### {{ design_exceptions_code }} ###\n\n return (hash);\n}\n\n","old_contents":"###############################################################################\n#\n# Fastly CDN for Magento 2\n#\n# NOTICE OF LICENSE\n#\n# This source file is subject to the Fastly CDN for Magento 2 End User License\n# Agreement that is bundled with this package in the file LICENSE_FASTLY_CDN.txt.\n#\n# @copyright Copyright (c) 2016 Fastly, Inc. (http:\/\/www.fastly.com)\n# @license BSD, see LICENSE_FASTLY_CDN.txt\n#\n###############################################################################\n\n# This is a basic VCL configuration file for Fastly CDN for Magento 2 module.\n\nsub vcl_recv {\n#FASTLY recv\n\n\n # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n if (req.url ~ \"^\/static\/version(\\d*\/)?(.*)$\") {\n set req.url = \"\/static\/\" + re.group.2 + \"?\" + re.group.1;\n } \n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n set req.http.X-Sig = regsub(req.http.X-Purge-Token, \"^[^_]+_(.*)\", \"\\1\");\n set req.http.X-Exp = regsub(req.http.X-Purge-Token, \"^([^_]+)_.*\", \"\\1\");\n\n # validate signature\n if (req.http.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path req.http.X-Exp), \"^0x\", \"\")) {\n\n # use vcl time math to check expiration timestamp\n set req.http.X-Original-Grace = req.grace;\n set req.grace = std.atoi(strftime({\"%s\"}, now));\n set req.grace -= std.atoi(req.http.X-Exp);\n\n if (std.atoi(req.grace) > 0) {\n error 410;\n }\n\n # clean up grace since we used it for time math\n set req.grace = std.atoi(req.http.X-Original-Grace);\n unset req.http.X-Original-Grace;\n\n } else {\n error 403;\n }\n\n # cleanup variables\n unset req.http.X-Purge-Token;\n unset req.http.X-Sig;\n unset req.http.X-Exp;\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n # disable ESI processing on Origin Shield\n if (req.http.Fastly-FF) {\n set req.esi = false;\n }\n\n # We only deal with GET and HEAD by default\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n return (pass);\n }\n \n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie ~ \"(X-Magento-Vary|form_key)=\") {\n error 200 \"\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url !~ \"country_code=\" ) {\n set req.url = req.url \"?country_code=\" if ( req.http.geo_override, req.http.geo_override, geoip.country_code);\n }\n }\n } else {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking\n set req.http.Fastly-Original-URL = req.url;\n set req.url = querystring.regfilter(req.url, \"^(utm_.*|gclid|gdftrk|_ga|mc_.*)\");\n }\n \n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n return (lookup);\n }\n\n # Bypass shopping cart and checkout requests\n if (req.url ~ \"\/checkout\") {\n return (pass);\n }\n\n return(lookup);\n}\n\nsub vcl_fetch {\n\n # Remove Set-Cookies from responses for static content\n # to match the cookie removal in recv.\n if (req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n }\n\n }\n\n#FASTLY fetch\n\n if (beresp.status >= 500) {\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n }\n\n if (req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Content-Type ~ \"text\/html\" || beresp.http.Content-Type ~ \"text\/xml\") {\n # enable ESI feature for Magento response by default\n esi;\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content\n if ((beresp.status == 200 || beresp.status == 404) && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url ~ \"\\.(css|js|html|eot|ico|otf|ttf|json)($|\\?)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # cache only successfully responses and 404s\n if (beresp.status != 200 && beresp.status != 301 && beresp.status != 404) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\")) {\n unset beresp.http.set-cookie;\n if (req.url !~ \"^\/(pub\/)?(media|static)\/.*\") {\n set beresp.grace = 86400m;\n }\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type\n if (beresp.http.Content-Type ~ \"image\") {\n set beresp.http.Surrogate-Key = \"image\";\n } elsif (beresp.http.Content-Type ~ \"script\") {\n set beresp.http.Surrogate-Key = \"script\";\n } elsif (beresp.http.Content-Type ~ \"css\") {\n set beresp.http.Surrogate-Key = \"css\";\n }\n\n set beresp.http.X-Surrogate-Key = beresp.http.Surrogate-Key;\n return (deliver);\n }\n\n return (deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\n\nsub vcl_miss {\n # Deactivate gzip on origin\n unset bereq.http.Accept-Encoding;\n\n#FASTLY miss\n\n return(fetch);\n}\n\nsub vcl_deliver {\n\n # Send no cache headers to end users for non-static content. Also make sure\n # we only set this on the edge nodes and not on shields\n if (req.url !~ \"^\/(pub\/)?(media|static)\/.*\" && !req.http.Fastly-FF ) {\n set resp.http.Pragma = \"no-cache\";\n set resp.http.Cache-Control = \"no-store, no-cache, must-revalidate, max-age=0\";\n }\n\n # Add an easy way to see whether custom Fastly VCL has been uploaded\n if ( req.http.Fastly-Debug ) {\n set resp.http.Fastly-Magento-VCL-Uploaded = \"yes\";\n } else {\n remove resp.http.Fastly-Module-Enabled;\n }\n # debug info\n if (resp.http.X-Magento-Debug) {\n if (obj.hits > 0) {\n set resp.http.X-Magento-Cache-Debug = \"HIT\";\n set resp.http.X-Magento-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Magento-Cache-Debug = \"MISS\";\n }\n } else {\n # remove Varnish\/proxy header\n remove resp.http.Age;\n remove resp.http.X-Magento-Debug;\n remove resp.http.X-Magento-Tags;\n remove resp.http.X-Surrogate-Key;\n remove resp.http.X-Magento-Cache-Control;\n remove resp.http.X-Powered-By;\n remove resp.http.Server;\n remove resp.http.X-Varnish;\n remove resp.http.Via;\n remove resp.http.Link;\n remove resp.http.X-Purge-URL;\n remove resp.http.X-Purge-Host;\n }\n\n#FASTLY deliver\n\n return (deliver);\n}\n\n\nsub vcl_error {\n # workaround for possible security issue\n if (req.url ~ \"^\\s\") {\n set obj.status = 400;\n set obj.response = \"Malformed request\";\n synthetic \"\";\n return (deliver);\n }\n\n # error 200\n if (obj.status == 200) {\n return (deliver);\n }\n\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} obj.status \" \" obj.response {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} obj.status \" \" obj.response {\"<\/h1>\n <p>\"} obj.response {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} req.xid {\"<\/p>\n <hr>\n <p>Fastly CDN server<\/p>\n <\/body>\n<\/html>\n\"};\n\n#FASTLY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n\nsub vcl_hash {\n set req.hash += req.http.Https;\n set req.hash += req.http.host;\n set req.hash += req.url;\n\n if (req.http.cookie:X-Magento-Vary ) {\n set req.hash += req.http.cookie:X-Magento-Vary;\n }\n \n set req.hash += \"#####GENERATION#####\";\n\n ### {{ design_exceptions_code }} ###\n\n return (hash);\n}\n\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"6cf94126b97c6cd4b9c35e97d5076cd264b4e6ab","subject":"fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well","message":"fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/fastly.vcl","new_file":"etc\/fastly.vcl","new_contents":"###############################################################################\n#\n# Fastly CDN for Magento 2\n#\n# NOTICE OF LICENSE\n#\n# This source file is subject to the Fastly CDN for Magento 2 End User License\n# Agreement that is bundled with this package in the file LICENSE_FASTLY_CDN.txt.\n#\n# @copyright Copyright (c) 2016 Fastly, Inc. (http:\/\/www.fastly.com)\n# @license BSD, see LICENSE_FASTLY_CDN.txt\n#\n###############################################################################\n\n# This is a basic VCL configuration file for Fastly CDN for Magento 2 module.\n\nsub vcl_recv {\n#FASTLY recv\n\n # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking\n set req.http.Fastly-Original-URL = req.url;\n set req.url = querystring.regfilter(req.url, \"^(utm_.*|gclid|gdftrk|_ga|mc_.*)\");\n\n if (req.url ~ \"^\/static\/version(\\d*\/)?(.*)$\") {\n set req.url = \"\/static\/\" + re.group.2 + \"?\" + re.group.1;\n } \n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n set req.http.X-Sig = regsub(req.http.X-Purge-Token, \"^[^_]+_(.*)\", \"\\1\");\n set req.http.X-Exp = regsub(req.http.X-Purge-Token, \"^([^_]+)_.*\", \"\\1\");\n\n # validate signature\n if (req.http.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path req.http.X-Exp), \"^0x\", \"\")) {\n\n # use vcl time math to check expiration timestamp\n set req.http.X-Original-Grace = req.grace;\n set req.grace = std.atoi(strftime({\"%s\"}, now));\n set req.grace -= std.atoi(req.http.X-Exp);\n\n if (std.atoi(req.grace) > 0) {\n error 410;\n }\n\n # clean up grace since we used it for time math\n set req.grace = std.atoi(req.http.X-Original-Grace);\n unset req.http.X-Original-Grace;\n\n } else {\n error 403;\n }\n\n # cleanup variables\n unset req.http.X-Purge-Token;\n unset req.http.X-Sig;\n unset req.http.X-Exp;\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n # disable ESI processing on Origin Shield\n if (req.http.Fastly-FF) {\n set req.esi = false;\n }\n\n # We only deal with GET and HEAD by default\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n return (pass);\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n return (lookup);\n }\n\n # Bypass shopping cart and checkout requests\n if (req.url ~ \"\/checkout\") {\n return (pass);\n }\n\n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie ~ \"(X-Magento-Vary|form_key)=\") {\n error 200 \"\";\n } else {\n # append parameter with country code\n set req.url = req.url \"?country_code=\" geoip.country_code;\n }\n }\n\n return(lookup);\n}\n\nsub vcl_fetch {\n\n # Remove Set-Cookies from responses for static content\n # to match the cookie removal in recv.\n if (req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n }\n\n }\n\n#FASTLY fetch\n\n if (beresp.status >= 500) {\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n }\n\n if (req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Content-Type ~ \"text\/html\" || beresp.http.Content-Type ~ \"text\/xml\") {\n # enable ESI feature for Magento response by default\n esi;\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content\n if ((beresp.status == 200 || beresp.status == 404) && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url ~ \"\\.(css|js|html|eot|ico|otf|ttf|json)($|\\?)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # cache only successfully responses and 404s\n if (beresp.status != 200 && beresp.status != 301 && beresp.status != 404) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\")) {\n unset beresp.http.set-cookie;\n if (req.url !~ \"^\/(pub\/)?(media|static)\/.*\") {\n set beresp.http.Pragma = \"no-cache\";\n set beresp.http.Expires = \"-1\";\n set beresp.http.Cache-Control = \"no-store, no-cache, must-revalidate, max-age=0\";\n set beresp.grace = 1m;\n }\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type\n if (beresp.http.Content-Type ~ \"image\") {\n set beresp.http.Surrogate-Key = \"image\";\n } elsif (beresp.http.Content-Type ~ \"script\") {\n set beresp.http.Surrogate-Key = \"script\";\n } elsif (beresp.http.Content-Type ~ \"css\") {\n set beresp.http.Surrogate-Key = \"css\";\n }\n\n set beresp.http.X-Surrogate-Key = beresp.http.Surrogate-Key;\n return (deliver);\n }\n\n return (deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\n\nsub vcl_miss {\n # Deactivate gzip on origin\n unset bereq.http.Accept-Encoding;\n\n#FASTLY miss\n\n return(fetch);\n}\n\nsub vcl_deliver {\n\n # Add an easy way to see whether custom Fastly VCL has been uploaded\n if ( req.http.Fastly-Debug ) {\n set resp.http.Fastly-Magento-VCL-Uploaded = \"yes\";\n } else {\n remove resp.http.Fastly-Module-Enabled;\n }\n # debug info\n if (resp.http.X-Magento-Debug) {\n if (obj.hits > 0) {\n set resp.http.X-Magento-Cache-Debug = \"HIT\";\n set resp.http.X-Magento-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Magento-Cache-Debug = \"MISS\";\n }\n } else {\n # remove Varnish\/proxy header\n remove resp.http.Age;\n remove resp.http.X-Magento-Debug;\n remove resp.http.X-Magento-Tags;\n remove resp.http.X-Surrogate-Key;\n remove resp.http.X-Magento-Cache-Control;\n remove resp.http.X-Powered-By;\n remove resp.http.Server;\n remove resp.http.X-Varnish;\n remove resp.http.Via;\n remove resp.http.Link;\n remove resp.http.X-Purge-URL;\n remove resp.http.X-Purge-Host;\n }\n\n#FASTLY deliver\n\n return (deliver);\n}\n\n\nsub vcl_error {\n # workaround for possible security issue\n if (req.url ~ \"^\\s\") {\n set obj.status = 400;\n set obj.response = \"Malformed request\";\n synthetic \"\";\n return (deliver);\n }\n\n # error 200\n if (obj.status == 200) {\n return (deliver);\n }\n\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} obj.status \" \" obj.response {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} obj.status \" \" obj.response {\"<\/h1>\n <p>\"} obj.response {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} req.xid {\"<\/p>\n <hr>\n <p>Fastly CDN server<\/p>\n <\/body>\n<\/html>\n\"};\n\n#FASTLY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n\nsub vcl_hash {\n set req.hash += req.http.Https;\n set req.hash += req.http.host;\n set req.hash += req.url;\n\n if (req.http.cookie:X-Magento-Vary ) {\n set req.hash += req.http.cookie:X-Magento-Vary;\n }\n \n set req.hash += \"#####GENERATION#####\";\n\n ### {{ design_exceptions_code }} ###\n\n return (hash);\n}\n\n","old_contents":"###############################################################################\n#\n# Fastly CDN for Magento 2\n#\n# NOTICE OF LICENSE\n#\n# This source file is subject to the Fastly CDN for Magento 2 End User License\n# Agreement that is bundled with this package in the file LICENSE_FASTLY_CDN.txt.\n#\n# @copyright Copyright (c) 2016 Fastly, Inc. (http:\/\/www.fastly.com)\n# @license BSD, see LICENSE_FASTLY_CDN.txt\n#\n###############################################################################\n\n# This is a basic VCL configuration file for Fastly CDN for Magento 2 module.\n\nsub vcl_recv {\n#FASTLY recv\n\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking\n set req.http.Fastly-Original-URL = req.url;\n set req.url = querystring.regfilter(req.url, \"^(utm_.*|gclid|gdftrk|_ga|mc_.*)\");\n\n if (req.url ~ \"^\/static\/version(\\d*\/)?(.*)$\") {\n set req.url = \"\/static\/\" + re.group.2 + \"?\" + re.group.1;\n } \n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n set req.http.X-Sig = regsub(req.http.X-Purge-Token, \"^[^_]+_(.*)\", \"\\1\");\n set req.http.X-Exp = regsub(req.http.X-Purge-Token, \"^([^_]+)_.*\", \"\\1\");\n\n # validate signature\n if (req.http.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path req.http.X-Exp), \"^0x\", \"\")) {\n\n # use vcl time math to check expiration timestamp\n set req.http.X-Original-Grace = req.grace;\n set req.grace = std.atoi(strftime({\"%s\"}, now));\n set req.grace -= std.atoi(req.http.X-Exp);\n\n if (std.atoi(req.grace) > 0) {\n error 410;\n }\n\n # clean up grace since we used it for time math\n set req.grace = std.atoi(req.http.X-Original-Grace);\n unset req.http.X-Original-Grace;\n\n } else {\n error 403;\n }\n\n # cleanup variables\n unset req.http.X-Purge-Token;\n unset req.http.X-Sig;\n unset req.http.X-Exp;\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n # disable ESI processing on Origin Shield\n if (req.http.Fastly-FF) {\n set req.esi = false;\n }\n\n # We only deal with GET and HEAD by default\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n return (pass);\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n return (lookup);\n }\n\n # Bypass shopping cart and checkout requests\n if (req.url ~ \"\/checkout\") {\n return (pass);\n }\n\n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie ~ \"(X-Magento-Vary|form_key)=\") {\n error 200 \"\";\n } else {\n # append parameter with country code\n set req.url = req.url \"?country_code=\" geoip.country_code;\n }\n }\n\n return(lookup);\n}\n\nsub vcl_fetch {\n\n # Remove Set-Cookies from responses for static content\n # to match the cookie removal in recv.\n if (req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n }\n\n }\n\n#FASTLY fetch\n\n if (beresp.status >= 500) {\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n }\n\n if (req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Content-Type ~ \"text\/html\" || beresp.http.Content-Type ~ \"text\/xml\") {\n # enable ESI feature for Magento response by default\n esi;\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content\n if ((beresp.status == 200 || beresp.status == 404) && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url ~ \"\\.(css|js|html|eot|ico|otf|ttf|json)($|\\?)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # cache only successfully responses and 404s\n if (beresp.status != 200 && beresp.status != 301 && beresp.status != 404) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\")) {\n unset beresp.http.set-cookie;\n if (req.url !~ \"^\/(pub\/)?(media|static)\/.*\") {\n set beresp.http.Pragma = \"no-cache\";\n set beresp.http.Expires = \"-1\";\n set beresp.http.Cache-Control = \"no-store, no-cache, must-revalidate, max-age=0\";\n set beresp.grace = 1m;\n }\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type\n if (beresp.http.Content-Type ~ \"image\") {\n set beresp.http.Surrogate-Key = \"image\";\n } elsif (beresp.http.Content-Type ~ \"script\") {\n set beresp.http.Surrogate-Key = \"script\";\n } elsif (beresp.http.Content-Type ~ \"css\") {\n set beresp.http.Surrogate-Key = \"css\";\n }\n\n set beresp.http.X-Surrogate-Key = beresp.http.Surrogate-Key;\n return (deliver);\n }\n\n return (deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\n\nsub vcl_miss {\n # Deactivate gzip on origin\n unset bereq.http.Accept-Encoding;\n\n#FASTLY miss\n\n return(fetch);\n}\n\nsub vcl_deliver {\n\n # Add an easy way to see whether custom Fastly VCL has been uploaded\n if ( req.http.Fastly-Debug ) {\n set resp.http.Fastly-Magento-VCL-Uploaded = \"yes\";\n } else {\n remove resp.http.Fastly-Module-Enabled;\n }\n # debug info\n if (resp.http.X-Magento-Debug) {\n if (obj.hits > 0) {\n set resp.http.X-Magento-Cache-Debug = \"HIT\";\n set resp.http.X-Magento-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Magento-Cache-Debug = \"MISS\";\n }\n } else {\n # remove Varnish\/proxy header\n remove resp.http.Age;\n remove resp.http.X-Magento-Debug;\n remove resp.http.X-Magento-Tags;\n remove resp.http.X-Surrogate-Key;\n remove resp.http.X-Magento-Cache-Control;\n remove resp.http.X-Powered-By;\n remove resp.http.Server;\n remove resp.http.X-Varnish;\n remove resp.http.Via;\n remove resp.http.Link;\n remove resp.http.X-Purge-URL;\n remove resp.http.X-Purge-Host;\n }\n\n#FASTLY deliver\n\n return (deliver);\n}\n\n\nsub vcl_error {\n # workaround for possible security issue\n if (req.url ~ \"^\\s\") {\n set obj.status = 400;\n set obj.response = \"Malformed request\";\n synthetic \"\";\n return (deliver);\n }\n\n # error 200\n if (obj.status == 200) {\n return (deliver);\n }\n\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} obj.status \" \" obj.response {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} obj.status \" \" obj.response {\"<\/h1>\n <p>\"} obj.response {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} req.xid {\"<\/p>\n <hr>\n <p>Fastly CDN server<\/p>\n <\/body>\n<\/html>\n\"};\n\n#FASTLY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n\nsub vcl_hash {\n set req.hash += req.http.Https;\n set req.hash += req.http.host;\n set req.hash += req.url;\n\n if (req.http.cookie:X-Magento-Vary ) {\n set req.hash += req.http.cookie:X-Magento-Vary;\n }\n \n set req.hash += \"#####GENERATION#####\";\n\n ### {{ design_exceptions_code }} ###\n\n return (hash);\n}\n\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"d5f9b64b3ed511a8e8ecebba1ba36f4a2544edaa","subject":"Update Varnish config","message":"Update Varnish config\n","repos":"jclgoodwin\/bustimes.org.uk,jclgoodwin\/bustimes.org.uk,jclgoodwin\/bustimes.org.uk,jclgoodwin\/bustimes.org.uk","old_file":"config\/varnish\/default.vcl","new_file":"config\/varnish\/default.vcl","new_contents":"vcl 4.0;\n\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8081\";\n}\n\nbackend bustimesio {\n .host = \"127.0.0.1\";\n .port = \"8082\";\n}\n\nbackend tileserver {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\n\nsub vcl_recv {\n if (req.http.host == \"bustimes.io\") {\n set req.backend_hint = bustimesio;\n } elif (req.url ~ \"^\/styles\/\") {\n set req.backend_hint = tileserver;\n }\n\n if (req.url ~ \"^\/(admin\/|contact|awin-transaction)\") {\n return (pass);\n }\n\n if (req.url ~ \"^\/services\/\" && req.http.Cookie ~ \"sessionid\") {\n return (pass);\n }\n\n if (req.http.User-Agent ~ \"(?i)(ads|google|bing|msn|yandex|baidu|ro|career|seznam|)bot\" ||\n req.http.User-Agent ~ \"(?i)(baidu|jike|symantec|)spider\" ||\n req.http.User-Agent ~ \"(?i)(scanner|facebookexternalhit|crawler|admantx)\"\n ) {\n set req.http.X-Bot = \"bot\";\n }\n\n unset req.http.Cookie;\n}\n\nsub vcl_backend_response {\n if (bereq.url !~ \"^\/(admin\/|contact)\") {\n unset beresp.http.set-cookie;\n\n if (beresp.status >= 200 && beresp.status < 400) {\n if (bereq.url ~ \"^\/stops\/\") {\n set beresp.ttl = 30s;\n\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary + \", X-Bot\";\n } else {\n set beresp.http.Vary = \"X-Bot\";\n }\n } elif (bereq.url ~ \"^\/styles\/\") {\n set beresp.ttl = 30d;\n } else {\n set beresp.ttl = 1h;\n }\n }\n\n }\n}\n","old_contents":"vcl 4.0;\n\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8081\";\n}\n\nsub vcl_recv {\n if (req.url ~ \"^\/(admin\/|contact|awin-transaction)\") {\n return (pass);\n }\n\n if (req.http.User-Agent ~ \"(?i)(ads|google|bing|msn|yandex|baidu|ro|career|seznam|)bot\" ||\n req.http.User-Agent ~ \"(?i)(baidu|jike|symantec|)spider\" ||\n req.http.User-Agent ~ \"(?i)(scanner|facebookexternalhit|crawler|admantx)\"\n ) {\n set req.http.X-Bot = \"bot\";\n }\n\n unset req.http.Cookie;\n}\n\nsub vcl_backend_response {\n if (bereq.url !~ \"^\/(admin\/|contact)\") {\n unset beresp.http.set-cookie;\n\n if (beresp.status >= 200 && beresp.status < 400) {\n if (bereq.url ~ \"^\/stops\/\") {\n set beresp.ttl = 30s;\n\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary + \", X-Bot\";\n } else {\n set beresp.http.Vary = \"X-Bot\";\n }\n } else {\n set beresp.ttl = 1h;\n }\n }\n\n }\n}\n","returncode":0,"stderr":"","license":"mpl-2.0","lang":"VCL"} {"commit":"b1d667a857cfec43206849b92325c57679db3d91","subject":"- better handling of req.http.graphql","message":"- better handling of req.http.graphql\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets\/recv.vcl","new_file":"etc\/vcl_snippets\/recv.vcl","new_contents":" # VCL required to support maintenance mode. Don't maintenance mode admin pages and supporting assets\n if (table.lookup(magentomodule_config, \"allow_super_users_during_maint\", \"0\") == \"1\" &&\n !req.http.Fastly-Client-Ip ~ maint_allowlist &&\n !req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" &&\n !req.url ~ \"^\/pub\/static\/\") {\n\n # If we end up here after a restart and there is a ResponseObject it means we got here after error\n # page VCL restart. We shouldn't touch it. Otherwise return a plain 503 error page\n if ( req.restarts > 0 && req.http.ResponseObject ) {\n set req.http.ResponseObject = \"970\";\n } else {\n error 503 \"Maintenance mode\";\n }\n }\n\n # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n unset req.http.x-long-cache;\n\n # We want to force long cache times on any of the versioned assets\n if (req.url.path ~ \"^\/static\/version\\d*\/\") {\n set req.http.x-long-cache = \"1\";\n }\n \n # User's Cookie may contain some Magento Vary items we should vary on\n if (req.http.cookie:X-Magento-Vary) {\n set req.http.X-Magento-Vary = req.http.cookie:X-Magento-Vary;\n } else {\n unset req.http.X-Magento-Vary;\n }\n\n ############################################################################################################\n # Following code block controls purge by URL. By default we want to protect all URL purges. In general this\n # is addressed by adding Fastly-Purge-Requires-Auth request header in vcl_recv however this runs the risk of\n # exposing API tokens if user attempts to purge non-https URLs. For this reason inside the Magento module\n # we use X-Purge-Token. Unfortunately this breaks purge from the Fastly UI. Therefore in the next code block\n # we check for presence of X-Purge-Token. If it's not present we force the Fastly-Purge-Requires-Auth\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n if (req.http.X-Purge-Token && req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n } else {\n error 403;\n }\n } else {\n set req.http.Fastly-Purge-Requires-Auth = \"1\";\n }\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (fastly.ff.visits_this_service > 0) {\n # disable ESI processing on Origin Shield\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Make sure we lookup end user geo not shielding. More at https:\/\/docs.fastly.com\/vcl\/geolocation\/#using-geographic-variables-with-shielding\n set client.geo.ip_override = req.http.Fastly-Client-IP;\n\n # geoip lookup\n if (req.url.path ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie:X-Magento-Vary || req.http.cookie:form_key) {\n error 980 \"GeoIP already processed\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url.qs !~ \"country_code=\" ) {\n set req.url = querystring.set(req.url, \"country_code\", if ( req.http.geo_override, req.http.geo_override, client.geo.country_code));\n }\n }\n } else {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking by default\n # and allow custom parameters to be set. List of parameters is configurable in admin\n set req.http.Magento-Original-URL = req.url;\n # Change the list of ignored parameters by configuring them in the Advanced section\n set req.url = querystring.regfilter(req.url, \"^(####QUERY_PARAMETERS####)\");\n }\n\n # Don't allow clients to force a pass\n if (req.restarts == 0) {\n unset req.http.x-pass;\n unset req.http.Rate-Limit;\n }\n \n # Pass on checkout URLs. Because it's a snippet we want to execute this after backend selection so we handle it\n # in the request condition\n if (!req.http.x-long-cache && req.url ~ \"\/(catalogsearch|checkout|customer\/section\/load)\") {\n set req.http.x-pass = \"1\";\n # Pass all admin actions\n # ####ADMIN_PATH#### is replaced with value of frontName from app\/etc\/env.php\n } else if ( req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" ) {\n set req.http.x-pass = \"1\";\n } else {\n # Sort the query arguments to increase cache hit ratio with query arguments that\n # may be out od order. In case you want to restore the unsorted URL add a snippet\n # after this one that sets req.url to req.http.Magento-Original-URL\n if ( !req.http.x-pass ) {\n set req.url = boltsort.sort(req.url);\n }\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.http.x-long-cache || req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n unset req.http.graphql;\n # GraphQL special headers handling because this area doesn't rely on X-Magento-Vary cookie\n if (req.request == \"GET\" && req.url.path ~ \"\/graphql\" && req.url.qs ~ \"query=\") {\n if ( req.http.Authorization ~ \"^Bearer\" ) {\n set req.http.x-pass = \"1\";\n } else {\n set req.http.graphql = \"1\";\n if (req.http.Store) {\n set req.http.X-Magento-Vary = req.http.Store;\n }\n if (req.http.Content-Currency) {\n if (req.http.X-Magento-Vary) {\n set req.http.X-Magento-Vary = req.http.X-Magento-Vary req.http.Content-Currency;\n } else {\n set req.http.X-Magento-Vary = req.http.Content-Currency;\n }\n }\n }\n }\n","old_contents":" # VCL required to support maintenance mode. Don't maintenance mode admin pages and supporting assets\n if (table.lookup(magentomodule_config, \"allow_super_users_during_maint\", \"0\") == \"1\" &&\n !req.http.Fastly-Client-Ip ~ maint_allowlist &&\n !req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" &&\n !req.url ~ \"^\/pub\/static\/\") {\n\n # If we end up here after a restart and there is a ResponseObject it means we got here after error\n # page VCL restart. We shouldn't touch it. Otherwise return a plain 503 error page\n if ( req.restarts > 0 && req.http.ResponseObject ) {\n set req.http.ResponseObject = \"970\";\n } else {\n error 503 \"Maintenance mode\";\n }\n }\n\n # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n unset req.http.x-long-cache;\n\n # We want to force long cache times on any of the versioned assets\n if (req.url.path ~ \"^\/static\/version\\d*\/\") {\n set req.http.x-long-cache = \"1\";\n }\n \n # User's Cookie may contain some Magento Vary items we should vary on\n if (req.http.cookie:X-Magento-Vary) {\n set req.http.X-Magento-Vary = req.http.cookie:X-Magento-Vary;\n } else {\n unset req.http.X-Magento-Vary;\n }\n\n ############################################################################################################\n # Following code block controls purge by URL. By default we want to protect all URL purges. In general this\n # is addressed by adding Fastly-Purge-Requires-Auth request header in vcl_recv however this runs the risk of\n # exposing API tokens if user attempts to purge non-https URLs. For this reason inside the Magento module\n # we use X-Purge-Token. Unfortunately this breaks purge from the Fastly UI. Therefore in the next code block\n # we check for presence of X-Purge-Token. If it's not present we force the Fastly-Purge-Requires-Auth\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n if (req.http.X-Purge-Token && req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n } else {\n error 403;\n }\n } else {\n set req.http.Fastly-Purge-Requires-Auth = \"1\";\n }\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (fastly.ff.visits_this_service > 0) {\n # disable ESI processing on Origin Shield\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Make sure we lookup end user geo not shielding. More at https:\/\/docs.fastly.com\/vcl\/geolocation\/#using-geographic-variables-with-shielding\n set client.geo.ip_override = req.http.Fastly-Client-IP;\n\n # geoip lookup\n if (req.url.path ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie:X-Magento-Vary || req.http.cookie:form_key) {\n error 980 \"GeoIP already processed\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url.qs !~ \"country_code=\" ) {\n set req.url = querystring.set(req.url, \"country_code\", if ( req.http.geo_override, req.http.geo_override, client.geo.country_code));\n }\n }\n } else {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking by default\n # and allow custom parameters to be set. List of parameters is configurable in admin\n set req.http.Magento-Original-URL = req.url;\n # Change the list of ignored parameters by configuring them in the Advanced section\n set req.url = querystring.regfilter(req.url, \"^(####QUERY_PARAMETERS####)\");\n }\n\n # Don't allow clients to force a pass\n if (req.restarts == 0) {\n unset req.http.x-pass;\n unset req.http.Rate-Limit;\n }\n \n # Pass on checkout URLs. Because it's a snippet we want to execute this after backend selection so we handle it\n # in the request condition\n if (!req.http.x-long-cache && req.url ~ \"\/(catalogsearch|checkout|customer\/section\/load)\") {\n set req.http.x-pass = \"1\";\n # Pass all admin actions\n # ####ADMIN_PATH#### is replaced with value of frontName from app\/etc\/env.php\n } else if ( req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" ) {\n set req.http.x-pass = \"1\";\n } else {\n # Sort the query arguments to increase cache hit ratio with query arguments that\n # may be out od order. In case you want to restore the unsorted URL add a snippet\n # after this one that sets req.url to req.http.Magento-Original-URL\n if ( !req.http.x-pass ) {\n set req.url = boltsort.sort(req.url);\n }\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.http.x-long-cache || req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n # GraphQL special headers handling because this area doesn't rely on X-Magento-Vary cookie\n if (req.request == \"GET\" && req.url.path ~ \"\/graphql\" && req.url.qs ~ \"query=\") {\n set req.http.graphql = \"1\";\n if ( req.http.Authorization ~ \"^Bearer\" ) {\n set req.http.x-pass = \"1\";\n } else {\n if (req.http.Store) {\n set req.http.X-Magento-Vary = req.http.Store;\n }\n if (req.http.Content-Currency) {\n if (req.http.X-Magento-Vary) {\n set req.http.X-Magento-Vary = req.http.X-Magento-Vary req.http.Content-Currency;\n } else {\n set req.http.X-Magento-Vary = req.http.Content-Currency;\n }\n }\n }\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"bc1592574bc0181bc2180cbc9ec704ff526b8551","subject":"TTL is 1 hour","message":"TTL is 1 hour\n","repos":"genesis\/wordpress,evolution\/wordpress,jalevin\/wordpress,jalevin\/wordpress,genesis\/wordpress,evolution\/wordpress,genesis\/wordpress,evolution\/wordpress,evolution\/genesis-wordpress,evolution\/genesis-wordpress,genesis\/wordpress,genesis\/wordpress,evolution\/genesis-wordpress,evolution\/genesis-wordpress,evolution\/genesis-wordpress,evolution\/wordpress,jalevin\/wordpress,evolution\/wordpress,jalevin\/wordpress,evolution\/genesis-wordpress,genesis\/wordpress,jalevin\/wordpress","old_file":"provisioning\/roles\/varnish\/files\/etc-varnish\/production.vcl","new_file":"provisioning\/roles\/varnish\/files\/etc-varnish\/production.vcl","new_contents":"# Default backend definition. Set this to point to your content server.\n# all paths relative to varnish option vcl_dir\n\ninclude \"custom.backend.vcl\";\ninclude \"custom.acl.vcl\";\n\n# Handle the HTTP request received by the client\nsub vcl_recv {\n # varnish serves stale (but cacheable) objects while retriving object from backend\n if (req.backend.healthy) {\n set req.grace = 30s;\n } else {\n set req.grace = 1h;\n }\n\n # shortcut for DFind requests\n if (req.url ~ \"^\/w00tw00t\") {\n error 404 \"Not Found\";\n }\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n # Normalize the header, remove the port (in case you're testing this on various TCP ports)\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n # Allow purging\n if (req.request == \"PURGE\") {\n if (!client.ip ~ purge) {\n # Not from an allowed IP? Then die with an error.\n error 405 \"This IP is not allowed to send PURGE requests.\";\n }\n\n # If you got this stage (and didn't error out above), do a cache-lookup\n # That will force entry into vcl_hit() or vcl_miss() below and purge the actual cache\n return (lookup);\n }\n\n # Only deal with \"normal\" types\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"PATCH\" &&\n req.request != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n # We only deal with GET and HEAD by default\n return (pass);\n }\n\n # Some generic URL manipulation, useful for all templates that follow\n # First remove the Google Analytics added parameters, useless for our backend\n if (req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=\") {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # Strip hash, server doesn't need it.\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n # Strip a trailing ? if it exists\n if (req.url ~ \"\\?$\") {\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # This is an example to redirect with a 301\/302 HTTP status code from within Varnish\n # if (req.http.Host ~ \"secure.mysite.tld\") {\n # # We may want to force our users from the secure site to the HTTPs version?\n # error 720 \"https:\/\/secure.mysite.tld\";\n # # If you want to keep the URLs intact, this also works:\n # error 720 \"https:\/\/\" + req.http.Host + req.url;\n # }\n #\n # Or to force a 302 temporary redirect, use error 721\n # if (req.http.Host ~ \"temp.mysite.tld\") {\n # # Temporary redirect\n # error 721 \"http:\/\/mysite.tld\/temp\";\n # }\n #\n\n # Some generic cookie manipulation, useful for all templates that follow\n # Remove the \"has_js\" cookie\n set req.http.Cookie = regsuball(req.http.Cookie, \"has_js=[^;]+(; )?\", \"\");\n\n # Remove any Satallite cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__gaid=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"_sdsat_[^=]+=[^;]+(; )?\", \"\");\n\n # Remove any Google Analytics based cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__utm.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"_ga=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmctr=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmcmd.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmccn.=[^;]+(; )?\", \"\");\n\n # Remove any Cloudflare cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__cfduid=[^;]+(; )?\", \"\");\n\n # Remove the Quant Capital cookies (added by some plugin, all __qca)\n set req.http.Cookie = regsuball(req.http.Cookie, \"__qc.=[^;]+(; )?\", \"\");\n\n # Remove the AddThis cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__atuvc=[^;]+(; )?\", \"\");\n\n # Remove a \";\" prefix in the cookie if present\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n\n # Are there cookies left with only spaces or that are empty?\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n\n # Normalize Accept-Encoding header\n # straight from the manual: https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/vary.html\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n # No point in compressing these\n remove req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n # unkown algorithm\n remove req.http.Accept-Encoding;\n }\n }\n\n # Remove all cookies for static files\n # A valid discussion could be held on this line: do you really need to cache static files that don't cause load? Only if you have memory left.\n # Sure, there's disk I\/O, but chances are your OS will already have these files in their buffers (thus memory).\n # Before you blindly enable this, have a read here: http:\/\/mattiasgeniar.be\/2012\/11\/28\/stop-caching-static-files\/\n if (req.url ~ \"^[^?]*\\.(bmp|bz2|css|doc|eot|flv|gif|gz|ico|jpeg|jpg|js|less|mp[34]|pdf|png|rar|rtf|swf|tar|tgz|txt|wav|woff|xml|zip)(\\?.*)?$\") {\n unset req.http.Cookie;\n return (lookup);\n }\n\n # Send Surrogate-Capability headers to announce ESI support to backend\n set req.http.Surrogate-Capability = \"key=ESI\/1.0\";\n\n # Include custom vcl_recv logic\n include \"conf.d\/receive\/wordpress.vcl\";\n\n if (req.http.Authorization || req.http.Cookie) {\n # Not cacheable by default\n return (pass);\n }\n\n return (lookup);\n}\n\nsub vcl_pipe {\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n # set bereq.http.connection = \"close\";\n # here. It is not set by default as it might break some broken web\n # applications, like IIS with NTLM authentication.\n\n #set bereq.http.Connection = \"Close\";\n return (pipe);\n}\n\nsub vcl_pass {\n return (pass);\n}\n\n# The data on which the hashing will take place\nsub vcl_hash {\n hash_data(req.url);\n\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n\n # hash cookies for object with auth\n if (req.http.Cookie) {\n hash_data(req.http.Cookie);\n }\n if (req.http.Authorization) {\n hash_data(req.http.Authorization);\n }\n\n return (hash);\n}\n\nsub vcl_hit {\n # Allow purges\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"purged\";\n }\n\n return (deliver);\n}\n\nsub vcl_miss {\n # Allow purges\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"purged\";\n }\n\n return (fetch);\n}\n\n# Handle the HTTP request coming from our backend \nsub vcl_fetch {\n set beresp.grace = 1h;\n\n # Include custom vcl_fetch logic\n include \"conf.d\/fetch\/wordpress.vcl\";\n\n # Parse ESI request and remove Surrogate-Control header\n if (beresp.http.Surrogate-Control ~ \"ESI\/1.0\") {\n unset beresp.http.Surrogate-Control;\n set beresp.do_esi = true;\n }\n\n # If the request to the backend returns a code is 5xx, restart the loop\n # If the number of restarts reaches the value of the parameter max_restarts,\n # the request will be error'ed. max_restarts defaults to 4. This prevents\n # an eternal loop in the event that, e.g., the object does not exist at all.\n if (beresp.status >= 500 && beresp.status <= 599){\n return(restart);\n }\n\n # Enable cache for all static files\n # The same argument as the static caches from above: monitor your cache size, if you get data nuked out of it, consider giving up the static file cache.\n # Before you blindly enable this, have a read here: http:\/\/mattiasgeniar.be\/2012\/11\/28\/stop-caching-static-files\/\n if (req.url ~ \"^[^?]*\\.(bmp|bz2|css|doc|eot|flv|gif|gz|ico|jpeg|jpg|js|less|mp[34]|pdf|png|rar|rtf|swf|tar|tgz|txt|wav|woff|xml|zip)(\\?.*)?$\") {\n unset beresp.http.set-cookie;\n }\n\n # Sometimes, a 301 or 302 redirect formed via Apache's mod_rewrite can mess with the HTTP port that is being passed along.\n # This often happens with simple rewrite rules in a scenario where Varnish runs on :80 and Apache on :8080 on the same box.\n # A redirect can then often redirect the end-user to a URL on :8080, where it should be :80.\n # This may need finetuning on your setup.\n #\n # To prevent accidental replace, we only filter the 301\/302 redirects for now.\n if (beresp.status == 301 || beresp.status == 302) {\n set beresp.http.Location = regsub(beresp.http.Location, \":[0-9]+\", \"\");\n }\n\n # Don't cache user & server errors\n if (beresp.status >= 400) {\n return (hit_for_pass);\n }\n\n # Non private responses without cookies and with a ttl of 0 should be artificially extended to 1 hour\n if (beresp.ttl <= 0s && beresp.http.Cache-Control !~ \"private\" && (!beresp.http.Set-Cookie)) {\n set beresp.ttl = 1h;\n set beresp.http.X-Cache-Extended = \"1\";\n }\n\n # Set 2min cache if unset for static files\n if (beresp.ttl <= 0s || beresp.http.Set-Cookie || beresp.http.Vary == \"*\") {\n set beresp.ttl = 120s;\n return (hit_for_pass);\n }\n\n return (deliver);\n}\n\n# The routine when we deliver the HTTP request to the user\n# Last chance to modify headers that are sent to the client\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"cached\";\n } else {\n set resp.http.x-Cache = \"uncached\";\n }\n\n # Remove some headers: PHP version\n unset resp.http.X-Powered-By;\n\n # Remove some headers: Apache version & OS\n unset resp.http.Server;\n unset resp.http.X-Drupal-Cache;\n unset resp.http.X-Varnish;\n unset resp.http.Via;\n unset resp.http.Link;\n\n return (deliver);\n}\n\nsub vcl_error {\n if (obj.status >= 500 && obj.status <= 599 && req.restarts < 4) {\n # 4 retry for 5xx error\n return(restart);\n } elsif (obj.status >= 400 && obj.status <= 499 ) {\n # use 404 error page for 4xx error\n include \"conf.d\/error-404.vcl\";\n } elsif (obj.status <= 200 && obj.status >= 299 ) {\n # for other errors (not 5xx, not 4xx and not 2xx)\n include \"conf.d\/error.vcl\";\n } elseif (obj.status == 720) {\n # We use this special error status 720 to force redirects with 301 (permanent) redirects\n # To use this, call the following from anywhere in vcl_recv: error 720 \"http:\/\/host\/new.html\"\n set obj.status = 301;\n set obj.http.Location = obj.response;\n return (deliver);\n } elseif (obj.status == 721) {\n # And we use error status 721 to force redirects with a 302 (temporary) redirect\n # To use this, call the following from anywhere in vcl_recv: error 720 \"http:\/\/host\/new.html\"\n set obj.status = 302;\n set obj.http.Location = obj.response;\n return (deliver);\n } else {\n include \"conf.d\/error.vcl\";\n }\n\n return (deliver);\n}\n\nsub vcl_init {\n return (ok);\n}\n\nsub vcl_fini {\n return (ok);\n}\n","old_contents":"# Default backend definition. Set this to point to your content server.\n# all paths relative to varnish option vcl_dir\n\ninclude \"custom.backend.vcl\";\ninclude \"custom.acl.vcl\";\n\n# Handle the HTTP request received by the client\nsub vcl_recv {\n # varnish serves stale (but cacheable) objects while retriving object from backend\n if (req.backend.healthy) {\n set req.grace = 30s;\n } else {\n set req.grace = 1h;\n }\n\n # shortcut for DFind requests\n if (req.url ~ \"^\/w00tw00t\") {\n error 404 \"Not Found\";\n }\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n # Normalize the header, remove the port (in case you're testing this on various TCP ports)\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n # Allow purging\n if (req.request == \"PURGE\") {\n if (!client.ip ~ purge) {\n # Not from an allowed IP? Then die with an error.\n error 405 \"This IP is not allowed to send PURGE requests.\";\n }\n\n # If you got this stage (and didn't error out above), do a cache-lookup\n # That will force entry into vcl_hit() or vcl_miss() below and purge the actual cache\n return (lookup);\n }\n\n # Only deal with \"normal\" types\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"PATCH\" &&\n req.request != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n # We only deal with GET and HEAD by default\n return (pass);\n }\n\n # Some generic URL manipulation, useful for all templates that follow\n # First remove the Google Analytics added parameters, useless for our backend\n if (req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=\") {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # Strip hash, server doesn't need it.\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n # Strip a trailing ? if it exists\n if (req.url ~ \"\\?$\") {\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # This is an example to redirect with a 301\/302 HTTP status code from within Varnish\n # if (req.http.Host ~ \"secure.mysite.tld\") {\n # # We may want to force our users from the secure site to the HTTPs version?\n # error 720 \"https:\/\/secure.mysite.tld\";\n # # If you want to keep the URLs intact, this also works:\n # error 720 \"https:\/\/\" + req.http.Host + req.url;\n # }\n #\n # Or to force a 302 temporary redirect, use error 721\n # if (req.http.Host ~ \"temp.mysite.tld\") {\n # # Temporary redirect\n # error 721 \"http:\/\/mysite.tld\/temp\";\n # }\n #\n\n # Some generic cookie manipulation, useful for all templates that follow\n # Remove the \"has_js\" cookie\n set req.http.Cookie = regsuball(req.http.Cookie, \"has_js=[^;]+(; )?\", \"\");\n\n # Remove any Satallite cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__gaid=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"_sdsat_[^=]+=[^;]+(; )?\", \"\");\n\n # Remove any Google Analytics based cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__utm.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"_ga=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmctr=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmcmd.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmccn.=[^;]+(; )?\", \"\");\n\n # Remove any Cloudflare cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__cfduid=[^;]+(; )?\", \"\");\n\n # Remove the Quant Capital cookies (added by some plugin, all __qca)\n set req.http.Cookie = regsuball(req.http.Cookie, \"__qc.=[^;]+(; )?\", \"\");\n\n # Remove the AddThis cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__atuvc=[^;]+(; )?\", \"\");\n\n # Remove a \";\" prefix in the cookie if present\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n\n # Are there cookies left with only spaces or that are empty?\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n\n # Normalize Accept-Encoding header\n # straight from the manual: https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/vary.html\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n # No point in compressing these\n remove req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n # unkown algorithm\n remove req.http.Accept-Encoding;\n }\n }\n\n # Remove all cookies for static files\n # A valid discussion could be held on this line: do you really need to cache static files that don't cause load? Only if you have memory left.\n # Sure, there's disk I\/O, but chances are your OS will already have these files in their buffers (thus memory).\n # Before you blindly enable this, have a read here: http:\/\/mattiasgeniar.be\/2012\/11\/28\/stop-caching-static-files\/\n if (req.url ~ \"^[^?]*\\.(bmp|bz2|css|doc|eot|flv|gif|gz|ico|jpeg|jpg|js|less|mp[34]|pdf|png|rar|rtf|swf|tar|tgz|txt|wav|woff|xml|zip)(\\?.*)?$\") {\n unset req.http.Cookie;\n return (lookup);\n }\n\n # Send Surrogate-Capability headers to announce ESI support to backend\n set req.http.Surrogate-Capability = \"key=ESI\/1.0\";\n\n # Include custom vcl_recv logic\n include \"conf.d\/receive\/wordpress.vcl\";\n\n if (req.http.Authorization || req.http.Cookie) {\n # Not cacheable by default\n return (pass);\n }\n\n return (lookup);\n}\n\nsub vcl_pipe {\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n # set bereq.http.connection = \"close\";\n # here. It is not set by default as it might break some broken web\n # applications, like IIS with NTLM authentication.\n\n #set bereq.http.Connection = \"Close\";\n return (pipe);\n}\n\nsub vcl_pass {\n return (pass);\n}\n\n# The data on which the hashing will take place\nsub vcl_hash {\n hash_data(req.url);\n\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n\n # hash cookies for object with auth\n if (req.http.Cookie) {\n hash_data(req.http.Cookie);\n }\n if (req.http.Authorization) {\n hash_data(req.http.Authorization);\n }\n\n return (hash);\n}\n\nsub vcl_hit {\n # Allow purges\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"purged\";\n }\n\n return (deliver);\n}\n\nsub vcl_miss {\n # Allow purges\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"purged\";\n }\n\n return (fetch);\n}\n\n# Handle the HTTP request coming from our backend \nsub vcl_fetch {\n set beresp.grace = 1h;\n\n # Include custom vcl_fetch logic\n include \"conf.d\/fetch\/wordpress.vcl\";\n\n # Parse ESI request and remove Surrogate-Control header\n if (beresp.http.Surrogate-Control ~ \"ESI\/1.0\") {\n unset beresp.http.Surrogate-Control;\n set beresp.do_esi = true;\n }\n\n # If the request to the backend returns a code is 5xx, restart the loop\n # If the number of restarts reaches the value of the parameter max_restarts,\n # the request will be error'ed. max_restarts defaults to 4. This prevents\n # an eternal loop in the event that, e.g., the object does not exist at all.\n if (beresp.status >= 500 && beresp.status <= 599){\n return(restart);\n }\n\n # Enable cache for all static files\n # The same argument as the static caches from above: monitor your cache size, if you get data nuked out of it, consider giving up the static file cache.\n # Before you blindly enable this, have a read here: http:\/\/mattiasgeniar.be\/2012\/11\/28\/stop-caching-static-files\/\n if (req.url ~ \"^[^?]*\\.(bmp|bz2|css|doc|eot|flv|gif|gz|ico|jpeg|jpg|js|less|mp[34]|pdf|png|rar|rtf|swf|tar|tgz|txt|wav|woff|xml|zip)(\\?.*)?$\") {\n unset beresp.http.set-cookie;\n }\n\n # Sometimes, a 301 or 302 redirect formed via Apache's mod_rewrite can mess with the HTTP port that is being passed along.\n # This often happens with simple rewrite rules in a scenario where Varnish runs on :80 and Apache on :8080 on the same box.\n # A redirect can then often redirect the end-user to a URL on :8080, where it should be :80.\n # This may need finetuning on your setup.\n #\n # To prevent accidental replace, we only filter the 301\/302 redirects for now.\n if (beresp.status == 301 || beresp.status == 302) {\n set beresp.http.Location = regsub(beresp.http.Location, \":[0-9]+\", \"\");\n }\n\n # Don't cache user & server errors\n if (beresp.status >= 400) {\n return (hit_for_pass);\n }\n\n # Non private responses without cookies and with a ttl of 0 should be artificially extended to 5min\n if (beresp.ttl <= 0s && beresp.http.Cache-Control !~ \"private\" && (!beresp.http.Set-Cookie)) {\n set beresp.ttl = 1h;\n set beresp.http.X-Cache-Extended = \"1\";\n }\n\n # Set 2min cache if unset for static files\n if (beresp.ttl <= 0s || beresp.http.Set-Cookie || beresp.http.Vary == \"*\") {\n set beresp.ttl = 120s;\n return (hit_for_pass);\n }\n\n return (deliver);\n}\n\n# The routine when we deliver the HTTP request to the user\n# Last chance to modify headers that are sent to the client\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"cached\";\n } else {\n set resp.http.x-Cache = \"uncached\";\n }\n\n # Remove some headers: PHP version\n unset resp.http.X-Powered-By;\n\n # Remove some headers: Apache version & OS\n unset resp.http.Server;\n unset resp.http.X-Drupal-Cache;\n unset resp.http.X-Varnish;\n unset resp.http.Via;\n unset resp.http.Link;\n\n return (deliver);\n}\n\nsub vcl_error {\n if (obj.status >= 500 && obj.status <= 599 && req.restarts < 4) {\n # 4 retry for 5xx error\n return(restart);\n } elsif (obj.status >= 400 && obj.status <= 499 ) {\n # use 404 error page for 4xx error\n include \"conf.d\/error-404.vcl\";\n } elsif (obj.status <= 200 && obj.status >= 299 ) {\n # for other errors (not 5xx, not 4xx and not 2xx)\n include \"conf.d\/error.vcl\";\n } elseif (obj.status == 720) {\n # We use this special error status 720 to force redirects with 301 (permanent) redirects\n # To use this, call the following from anywhere in vcl_recv: error 720 \"http:\/\/host\/new.html\"\n set obj.status = 301;\n set obj.http.Location = obj.response;\n return (deliver);\n } elseif (obj.status == 721) {\n # And we use error status 721 to force redirects with a 302 (temporary) redirect\n # To use this, call the following from anywhere in vcl_recv: error 720 \"http:\/\/host\/new.html\"\n set obj.status = 302;\n set obj.http.Location = obj.response;\n return (deliver);\n } else {\n include \"conf.d\/error.vcl\";\n }\n\n return (deliver);\n}\n\nsub vcl_init {\n return (ok);\n}\n\nsub vcl_fini {\n return (ok);\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"8c56d063c1dfd5dbdafdeae26416f0bb4bce5288","subject":"Old habits die hard.","message":"Old habits die hard.\n\nreq.request is now called req.method.\n","repos":"feld\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,gquintard\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,chrismoulton\/Varnish-Cache,franciscovg\/Varnish-Cache,varnish\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,varnish\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,chrismoulton\/Varnish-Cache,chrismoulton\/Varnish-Cache,franciscovg\/Varnish-Cache,gquintard\/Varnish-Cache,varnish\/Varnish-Cache,gquintard\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,zhoualbeart\/Varnish-Cache,gquintard\/Varnish-Cache,zhoualbeart\/Varnish-Cache,alarky\/varnish-cache-doc-ja,varnish\/Varnish-Cache,mrhmouse\/Varnish-Cache,franciscovg\/Varnish-Cache,alarky\/varnish-cache-doc-ja,gauthier-delacroix\/Varnish-Cache,feld\/Varnish-Cache,zhoualbeart\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,mrhmouse\/Varnish-Cache,feld\/Varnish-Cache,alarky\/varnish-cache-doc-ja,alarky\/varnish-cache-doc-ja,zhoualbeart\/Varnish-Cache,chrismoulton\/Varnish-Cache,chrismoulton\/Varnish-Cache,franciscovg\/Varnish-Cache,zhoualbeart\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,varnish\/Varnish-Cache,mrhmouse\/Varnish-Cache,feld\/Varnish-Cache,alarky\/varnish-cache-doc-ja,mrhmouse\/Varnish-Cache,feld\/Varnish-Cache,mrhmouse\/Varnish-Cache,franciscovg\/Varnish-Cache","old_file":"bin\/varnishd\/builtin.vcl","new_file":"bin\/varnishd\/builtin.vcl","new_contents":"\/*-\n * Copyright (c) 2006 Verdens Gang AS\n * Copyright (c) 2006-2014 Varnish Software AS\n * All rights reserved.\n *\n * Author: Poul-Henning Kamp <phk@phk.freebsd.dk>\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in the\n * documentation and\/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n\n *\n * The built-in (previously called default) VCL code.\n *\n * NB! You do NOT need to copy & paste all of these functions into your\n * own vcl code, if you do not provide a definition of one of these\n * functions, the compiler will automatically fall back to the default\n * code from this file.\n *\n * This code will be prefixed with a backend declaration built from the\n * -b argument.\n *\/\n\nvcl 4.0;\n\n#######################################################################\n# Client side\n\nsub vcl_recv {\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n \/* We don't support chunked uploads, except when piping. *\/\n if ((req.method == \"POST\" || req.method == \"PUT\") &&\n req.http.transfer-encoding ~ \"chunked\") {\n return(pipe);\n }\n\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization || req.http.Cookie) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n return (hash);\n}\n\nsub vcl_pipe {\n # By default Connection: close is set on all piped requests, to stop\n # connection reuse from sending future requests directly to the\n # (potentially) wrong backend. If you do want this to happen, you can undo\n # it here.\n # unset bereq.http.connection;\n return (pipe);\n}\n\nsub vcl_pass {\n return (fetch);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n return (lookup);\n}\n\nsub vcl_purge {\n return (synth(200, \"Purged\"));\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n \/\/ A pure unadultered hit, deliver it\n return (deliver);\n }\n if (obj.ttl + obj.grace > 0s) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n return (deliver);\n }\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\nsub vcl_miss {\n return (fetch);\n}\n\nsub vcl_deliver {\n return (deliver);\n}\n\n\/*\n * We can come here \"invisibly\" with the following errors: 413, 417 & 503\n *\/\nsub vcl_synth {\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n set resp.http.Retry-After = \"5\";\n synthetic( {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n return (deliver);\n}\n\n#######################################################################\n# Backend Fetch\n\nsub vcl_backend_fetch {\n return (fetch);\n}\n\nsub vcl_backend_response {\n if (beresp.ttl <= 0s ||\n beresp.http.Set-Cookie ||\n beresp.http.Surrogate-control ~ \"no-store\" ||\n (!beresp.http.Surrogate-Control &&\n beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n beresp.http.Vary == \"*\") {\n \/*\n * Mark as \"Hit-For-Pass\" for the next 2 minutes\n *\/\n set beresp.ttl = 120s;\n set beresp.uncacheable = true;\n }\n return (deliver);\n}\n\nsub vcl_backend_error {\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} + beresp.status + \" \" + beresp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + beresp.status + \" \" + beresp.reason + {\"<\/h1>\n <p>\"} + beresp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + bereq.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n return (deliver);\n}\n\n#######################################################################\n# Housekeeping\n\nsub vcl_init {\n return (ok);\n}\n\nsub vcl_fini {\n return (ok);\n}\n","old_contents":"\/*-\n * Copyright (c) 2006 Verdens Gang AS\n * Copyright (c) 2006-2014 Varnish Software AS\n * All rights reserved.\n *\n * Author: Poul-Henning Kamp <phk@phk.freebsd.dk>\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in the\n * documentation and\/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n\n *\n * The built-in (previously called default) VCL code.\n *\n * NB! You do NOT need to copy & paste all of these functions into your\n * own vcl code, if you do not provide a definition of one of these\n * functions, the compiler will automatically fall back to the default\n * code from this file.\n *\n * This code will be prefixed with a backend declaration built from the\n * -b argument.\n *\/\n\nvcl 4.0;\n\n#######################################################################\n# Client side\n\nsub vcl_recv {\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n \/* We don't support chunked uploads, except when piping. *\/\n if ((req.request == \"POST\" || req.request == \"PUT\") &&\n req.http.transfer-encoding ~ \"chunked\") {\n return(pipe);\n }\n\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization || req.http.Cookie) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n return (hash);\n}\n\nsub vcl_pipe {\n # By default Connection: close is set on all piped requests, to stop\n # connection reuse from sending future requests directly to the\n # (potentially) wrong backend. If you do want this to happen, you can undo\n # it here.\n # unset bereq.http.connection;\n return (pipe);\n}\n\nsub vcl_pass {\n return (fetch);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n return (lookup);\n}\n\nsub vcl_purge {\n return (synth(200, \"Purged\"));\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n \/\/ A pure unadultered hit, deliver it\n return (deliver);\n }\n if (obj.ttl + obj.grace > 0s) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n return (deliver);\n }\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\nsub vcl_miss {\n return (fetch);\n}\n\nsub vcl_deliver {\n return (deliver);\n}\n\n\/*\n * We can come here \"invisibly\" with the following errors: 413, 417 & 503\n *\/\nsub vcl_synth {\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n set resp.http.Retry-After = \"5\";\n synthetic( {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n return (deliver);\n}\n\n#######################################################################\n# Backend Fetch\n\nsub vcl_backend_fetch {\n return (fetch);\n}\n\nsub vcl_backend_response {\n if (beresp.ttl <= 0s ||\n beresp.http.Set-Cookie ||\n beresp.http.Surrogate-control ~ \"no-store\" ||\n (!beresp.http.Surrogate-Control &&\n beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n beresp.http.Vary == \"*\") {\n \/*\n * Mark as \"Hit-For-Pass\" for the next 2 minutes\n *\/\n set beresp.ttl = 120s;\n set beresp.uncacheable = true;\n }\n return (deliver);\n}\n\nsub vcl_backend_error {\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} + beresp.status + \" \" + beresp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + beresp.status + \" \" + beresp.reason + {\"<\/h1>\n <p>\"} + beresp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + bereq.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n return (deliver);\n}\n\n#######################################################################\n# Housekeeping\n\nsub vcl_init {\n return (ok);\n}\n\nsub vcl_fini {\n return (ok);\n}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"00080b71ba3e02e8a036444455b60528c105be70","subject":"- adding extra query check on the fetch","message":"- adding extra query check on the fetch\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets\/fetch.vcl","new_file":"etc\/vcl_snippets\/fetch.vcl","new_contents":" \/* handle 5XX (or any other unwanted status code) *\/\n if (beresp.status >= 500 && beresp.status < 600) {\n\n \/* deliver stale if the object is available *\/\n if (stale.exists) {\n return(deliver_stale);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n }\n\n # Remove Set-Cookies from responses for static content to match the cookie removal in recv.\n if (req.http.x-long-cache || req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's since those can be temporary during the site build\/index\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n set beresp.http.Cache-Control = \"max-age=0\";\n } else if (req.http.x-long-cache) {\n # Force caching for signed cached assets.\n set beresp.ttl = 31536000s;\n # Add immutable as it avoids IMS and INM revalidations\n set beresp.http.Cache-Control = \"max-age=31536000, immutable\";\n }\n }\n\n # Fix Vary Header in some cases. In 99.9% of cases Varying on User-Agent is counterproductive\n # https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleFixupVary\n if (beresp.http.Vary ~ \"User-Agent\") {\n set beresp.http.Vary = regsub(beresp.http.Vary, \",? *User-Agent *\", \"\");\n set beresp.http.Vary = regsub(beresp.http.Vary, \"^, *\", \"\");\n if (beresp.http.Vary == \"\") {\n unset beresp.http.Vary;\n }\n }\n\n # All the Magento responses should emit X-Esi headers\n if (beresp.http.x-esi) {\n # enable ESI feature for Magento response by default\n esi;\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content except\n if ( http_status_matches(beresp.status, \"200,404\") && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|text\\\/html|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url.ext ~ \"(?i)(css|js|html|eot|ico|otf|ttf|json)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # Add Varying on X-Magento-Vary\n if (beresp.http.Content-Type ~ \"text\/(html|xml)\" || (req.url ~ \"\/graphql\" && req.request == \"GET\" && req.url.qs ~ \"query=\")) {\n if (!beresp.http.Vary ~ \"X-Magento-Vary,Https\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \",X-Magento-Vary,Https\";\n } else {\n set beresp.http.Vary = \"X-Magento-Vary,Https\";\n }\n }\n }\n\n # Just in case the Request Setting for x-pass is missing\n if (req.http.x-pass) {\n return (pass);\n }\n\n if (beresp.http.Cache-Control ~ \"private|no-cache|no-store\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # Never cache 302s\n if (beresp.status == 302) {\n return (pass);\n }\n\n # Varnish sets default TTL if none of these are present. If not set we want to make sure we don't cache it\n if (!beresp.http.Expires && !beresp.http.Surrogate-Control ~ \"max-age\" && !beresp.http.Cache-Control ~ \"(s-maxage|max-age)\") {\n set beresp.ttl = 0s;\n set beresp.cacheable = false;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\") && !req.http.x-pass ) {\n unset beresp.http.set-cookie;\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type if they are image\/script or CSS\n if (beresp.http.Content-Type ~ \"(image|script|css)\") {\n set beresp.http.Surrogate-Key = re.group.1;\n }\n }\n","old_contents":" \/* handle 5XX (or any other unwanted status code) *\/\n if (beresp.status >= 500 && beresp.status < 600) {\n\n \/* deliver stale if the object is available *\/\n if (stale.exists) {\n return(deliver_stale);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n }\n\n # Remove Set-Cookies from responses for static content to match the cookie removal in recv.\n if (req.http.x-long-cache || req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's since those can be temporary during the site build\/index\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n set beresp.http.Cache-Control = \"max-age=0\";\n } else if (req.http.x-long-cache) {\n # Force caching for signed cached assets.\n set beresp.ttl = 31536000s;\n # Add immutable as it avoids IMS and INM revalidations\n set beresp.http.Cache-Control = \"max-age=31536000, immutable\";\n }\n }\n\n # Fix Vary Header in some cases. In 99.9% of cases Varying on User-Agent is counterproductive\n # https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleFixupVary\n if (beresp.http.Vary ~ \"User-Agent\") {\n set beresp.http.Vary = regsub(beresp.http.Vary, \",? *User-Agent *\", \"\");\n set beresp.http.Vary = regsub(beresp.http.Vary, \"^, *\", \"\");\n if (beresp.http.Vary == \"\") {\n unset beresp.http.Vary;\n }\n }\n\n # All the Magento responses should emit X-Esi headers\n if (beresp.http.x-esi) {\n # enable ESI feature for Magento response by default\n esi;\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content except\n if ( http_status_matches(beresp.status, \"200,404\") && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|text\\\/html|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url.ext ~ \"(?i)(css|js|html|eot|ico|otf|ttf|json)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # Add Varying on X-Magento-Vary\n if (beresp.http.Content-Type ~ \"text\/(html|xml)\" || (req.url ~ \"\/graphql\" && req.request == \"GET\")) {\n if (!beresp.http.Vary ~ \"X-Magento-Vary,Https\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \",X-Magento-Vary,Https\";\n } else {\n set beresp.http.Vary = \"X-Magento-Vary,Https\";\n }\n }\n }\n\n # Just in case the Request Setting for x-pass is missing\n if (req.http.x-pass) {\n return (pass);\n }\n\n if (beresp.http.Cache-Control ~ \"private|no-cache|no-store\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # Never cache 302s\n if (beresp.status == 302) {\n return (pass);\n }\n\n # Varnish sets default TTL if none of these are present. If not set we want to make sure we don't cache it\n if (!beresp.http.Expires && !beresp.http.Surrogate-Control ~ \"max-age\" && !beresp.http.Cache-Control ~ \"(s-maxage|max-age)\") {\n set beresp.ttl = 0s;\n set beresp.cacheable = false;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\") && !req.http.x-pass ) {\n unset beresp.http.set-cookie;\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type if they are image\/script or CSS\n if (beresp.http.Content-Type ~ \"(image|script|css)\") {\n set beresp.http.Surrogate-Key = re.group.1;\n }\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"3fb4749dcee0f16bc59ea9345e6c3693ed8113b8","subject":"Opera Mobi fixes as proposed in issue #8","message":"Opera Mobi fixes as proposed in issue #8\n","repos":"wikp\/varnish-devicedetect,varnish\/varnish-devicedetect,kevinquinnyo\/varnish-devicedetect,kevinquinnyo\/varnish-devicedetect,wikp\/varnish-devicedetect,varnish\/varnish-devicedetect","old_file":"devicedetect.vcl","new_file":"devicedetect.vcl","new_contents":"# Copyright (c) 2012-2013 Varnish Software AS\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions\n# are met:\n# 1. Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n# 2. Redistributions in binary form must reproduce the above copyright\n# notice, this list of conditions and the following disclaimer in the\n# documentation and\/or other materials provided with the distribution.\n#\n# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n# ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n# SUCH DAMAGE.\n#\n# detectdevice.vcl - regex based device detection for Varnish\n# http:\/\/github.com\/varnish\/varnish-devicedetect\/\n#\n# Author: Lasse Karstensen <lasse@varnish-software.com>\n\nsub devicedetect {\n\tunset req.http.X-UA-Device;\n\tset req.http.X-UA-Device = \"pc\";\n\n\t# Handle that a cookie may override the detection alltogether.\n\tif (req.http.Cookie ~ \"(?i)X-UA-Device-force\") {\n\t\t\/* ;?? means zero or one ;, non-greedy to match the first. *\/\n\t\tset req.http.X-UA-Device = regsub(req.http.Cookie, \"(?i).*X-UA-Device-force=([^;]+);??.*\", \"\\1\");\n\t\t\/* Clean up our mess in the cookie header *\/\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|; ) *X-UA-Device-force=[^;]+;? *\", \"\\1\");\n\t\t\/* If the cookie header is now empty, or just whitespace, unset it. *\/\n\t\tif (req.http.Cookie ~ \"^ *$\") { unset req.http.Cookie; }\n\t} else {\n\t\tif (req.http.User-Agent ~ \"(?i)(ads|google|bing|msn|yandex|baidu|ro|career|)bot\" ||\n\t\t req.http.User-Agent ~ \"(?i)(baidu|jike|symantec)spider\" ||\n\t\t req.http.User-Agent ~ \"(?i)scanner\" ||\n\t\t req.http.User-Agent ~ \"(?i)(web)crawler\") {\n\t\t\tset req.http.X-UA-Device = \"bot\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ipad\") { set req.http.X-UA-Device = \"tablet-ipad\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ip(hone|od)\") { set req.http.X-UA-Device = \"mobile-iphone\"; }\n\t\t\/* how do we differ between an android phone and an android tablet?\n\t\t http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent *\/\n\t\telsif (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") { set req.http.X-UA-Device = \"mobile-android\"; }\n\t\t\/\/ android 3\/honeycomb was just about tablet-only, and any phones will probably handle a bigger page layout.\n\t\telsif (req.http.User-Agent ~ \"(?i)android 3\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\t\/* see http:\/\/my.opera.com\/community\/openweb\/idopera\/ *\/\n\t\telsif (req.http.User-Agent ~ \"Opera Mobi\") { set req.http.X-UA-Device = \"mobile-smartphone\"; }\n\t\t\/\/ May very well give false positives towards android tablets. Suggestions welcome.\n\t\telsif (req.http.User-Agent ~ \"(?i)android\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\telsif (req.http.User-Agent ~ \"PlayBook; U; RIM Tablet\") { set req.http.X-UA-Device = \"tablet-rim\"; }\n\t\telsif (req.http.User-Agent ~ \"hp-tablet.*TouchPad\") { set req.http.X-UA-Device = \"tablet-hp\"; }\n\t\telsif (req.http.User-Agent ~ \"Kindle\/3\") { set req.http.X-UA-Device = \"tablet-kindle\"; }\n\t\telsif (req.http.User-Agent ~ \"Mobile.+Firefox\") { set req.http.X-UA-Device = \"mobile-firefoxos\"; }\n\t\telsif (req.http.User-Agent ~ \"^HTC\" ||\n\t\t req.http.User-Agent ~ \"Fennec\" ||\n\t\t req.http.User-Agent ~ \"IEMobile\" ||\n\t\t req.http.User-Agent ~ \"BlackBerry\" ||\n\t\t req.http.User-Agent ~ \"BB10.*Mobile\" ||\n\t\t req.http.User-Agent ~ \"GT-.*Build\/GINGERBREAD\" ||\n\t\t req.http.User-Agent ~ \"SymbianOS.*AppleWebKit\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-smartphone\";\n\t\t}\n\t\telsif (req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)^sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)^nokia\" ||\n\t\t req.http.User-Agent ~ \"(?i)^samsung\" ||\n\t\t req.http.User-Agent ~ \"(?i)^lg\" ||\n\t\t req.http.User-Agent ~ \"(?i)bada\" ||\n\t\t req.http.User-Agent ~ \"(?i)blazer\" ||\n\t\t req.http.User-Agent ~ \"(?i)cellphone\" ||\n\t\t req.http.User-Agent ~ \"(?i)iemobile\" ||\n\t\t req.http.User-Agent ~ \"(?i)midp-2.0\" ||\n\t\t req.http.User-Agent ~ \"(?i)u990\" ||\n\t\t req.http.User-Agent ~ \"(?i)netfront\" ||\n\t\t req.http.User-Agent ~ \"(?i)opera mini\" ||\n\t\t req.http.User-Agent ~ \"(?i)palm\" ||\n\t\t req.http.User-Agent ~ \"(?i)nintendo wii\" ||\n\t\t req.http.User-Agent ~ \"(?i)playstation portable\" ||\n\t\t req.http.User-Agent ~ \"(?i)portalmmm\" ||\n\t\t req.http.User-Agent ~ \"(?i)proxinet\" ||\n\t\t req.http.User-Agent ~ \"(?i)sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)windows\\ ?ce\" ||\n\t\t req.http.User-Agent ~ \"(?i)winwap\" ||\n\t\t req.http.User-Agent ~ \"(?i)eudoraweb\" ||\n\t\t req.http.User-Agent ~ \"(?i)htc\" ||\n\t\t req.http.User-Agent ~ \"(?i)240x320\" ||\n\t\t req.http.User-Agent ~ \"(?i)avantgo\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-generic\";\n\t\t}\n\t}\n}\n","old_contents":"# Copyright (c) 2012-2013 Varnish Software AS\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions\n# are met:\n# 1. Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n# 2. Redistributions in binary form must reproduce the above copyright\n# notice, this list of conditions and the following disclaimer in the\n# documentation and\/or other materials provided with the distribution.\n#\n# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n# ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n# SUCH DAMAGE.\n#\n# detectdevice.vcl - regex based device detection for Varnish\n# http:\/\/github.com\/varnish\/varnish-devicedetect\/\n#\n# Author: Lasse Karstensen <lasse@varnish-software.com>\n\nsub devicedetect {\n\tunset req.http.X-UA-Device;\n\tset req.http.X-UA-Device = \"pc\";\n\n\t# Handle that a cookie may override the detection alltogether.\n\tif (req.http.Cookie ~ \"(?i)X-UA-Device-force\") {\n\t\t\/* ;?? means zero or one ;, non-greedy to match the first. *\/\n\t\tset req.http.X-UA-Device = regsub(req.http.Cookie, \"(?i).*X-UA-Device-force=([^;]+);??.*\", \"\\1\");\n\t\t\/* Clean up our mess in the cookie header *\/\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|; ) *X-UA-Device-force=[^;]+;? *\", \"\\1\");\n\t\t\/* If the cookie header is now empty, or just whitespace, unset it. *\/\n\t\tif (req.http.Cookie ~ \"^ *$\") { unset req.http.Cookie; }\n\t} else {\n\t\tif (req.http.User-Agent ~ \"(?i)(ads|google|bing|msn|yandex|baidu|ro|career|)bot\" ||\n\t\t req.http.User-Agent ~ \"(?i)(baidu|jike|symantec)spider\" ||\n\t\t req.http.User-Agent ~ \"(?i)scanner\" ||\n\t\t req.http.User-Agent ~ \"(?i)(web)crawler\") {\n\t\t\tset req.http.X-UA-Device = \"bot\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ipad\") { set req.http.X-UA-Device = \"tablet-ipad\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ip(hone|od)\") { set req.http.X-UA-Device = \"mobile-iphone\"; }\n\t\t\/* how do we differ between an android phone and an android tablet?\n\t\t http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent *\/\n\t\telsif (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") { set req.http.X-UA-Device = \"mobile-android\"; }\n\t\t\/\/ android 3\/honeycomb was just about tablet-only, and any phones will probably handle a bigger page layout.\n\t\telsif (req.http.User-Agent ~ \"(?i)android 3\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\t\/\/ May very well give false positives towards android tablets. Suggestions welcome.\n\t\telsif (req.http.User-Agent ~ \"(?i)android\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\telsif (req.http.User-Agent ~ \"PlayBook; U; RIM Tablet\") { set req.http.X-UA-Device = \"tablet-rim\"; }\n\t\telsif (req.http.User-Agent ~ \"hp-tablet.*TouchPad\") { set req.http.X-UA-Device = \"tablet-hp\"; }\n\t\telsif (req.http.User-Agent ~ \"Kindle\/3\") { set req.http.X-UA-Device = \"tablet-kindle\"; }\n\t\telsif (req.http.User-Agent ~ \"Mobile.+Firefox\") { set req.http.X-UA-Device = \"mobile-firefoxos\"; }\n\t\telsif (req.http.User-Agent ~ \"^HTC\" ||\n\t\t req.http.User-Agent ~ \"Fennec\" ||\n\t\t req.http.User-Agent ~ \"IEMobile\" ||\n\t\t req.http.User-Agent ~ \"BlackBerry\" ||\n\t\t req.http.User-Agent ~ \"BB10.*Mobile\" ||\n\t\t req.http.User-Agent ~ \"GT-.*Build\/GINGERBREAD\" ||\n\t\t req.http.User-Agent ~ \"SymbianOS.*AppleWebKit\" ||\n\t\t req.http.User-Agent ~ \"Opera Mobi\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-smartphone\";\n\t\t}\n\t\telsif (req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)^sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)^nokia\" ||\n\t\t req.http.User-Agent ~ \"(?i)^samsung\" ||\n\t\t req.http.User-Agent ~ \"(?i)^lg\" ||\n\t\t req.http.User-Agent ~ \"(?i)bada\" ||\n\t\t req.http.User-Agent ~ \"(?i)blazer\" ||\n\t\t req.http.User-Agent ~ \"(?i)cellphone\" ||\n\t\t req.http.User-Agent ~ \"(?i)iemobile\" ||\n\t\t req.http.User-Agent ~ \"(?i)midp-2.0\" ||\n\t\t req.http.User-Agent ~ \"(?i)u990\" ||\n\t\t req.http.User-Agent ~ \"(?i)netfront\" ||\n\t\t req.http.User-Agent ~ \"(?i)opera mini\" ||\n\t\t req.http.User-Agent ~ \"(?i)palm\" ||\n\t\t req.http.User-Agent ~ \"(?i)nintendo wii\" ||\n\t\t req.http.User-Agent ~ \"(?i)playstation portable\" ||\n\t\t req.http.User-Agent ~ \"(?i)portalmmm\" ||\n\t\t req.http.User-Agent ~ \"(?i)proxinet\" ||\n\t\t req.http.User-Agent ~ \"(?i)sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)windows\\ ?ce\" ||\n\t\t req.http.User-Agent ~ \"(?i)winwap\" ||\n\t\t req.http.User-Agent ~ \"(?i)eudoraweb\" ||\n\t\t req.http.User-Agent ~ \"(?i)htc\" ||\n\t\t req.http.User-Agent ~ \"(?i)240x320\" ||\n\t\t req.http.User-Agent ~ \"(?i)avantgo\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-generic\";\n\t\t}\n\t}\n}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"0094646a0336232e3e463737227fd944f674d79d","subject":"Support v2 API endpoints in Fastly config","message":"Support v2 API endpoints in Fastly config\n","repos":"kdzwinel\/polyfill-service,JakeChampion\/polyfill-service,kdzwinel\/polyfill-service,mcshaz\/polyfill-service,mcshaz\/polyfill-service,jonathan-fielding\/polyfill-service,jonathan-fielding\/polyfill-service,jonathan-fielding\/polyfill-service,mcshaz\/polyfill-service,kdzwinel\/polyfill-service,JakeChampion\/polyfill-service","old_file":"fastly-config.vcl","new_file":"fastly-config.vcl","new_contents":"sub vcl_recv {\n#FASTLY recv\n\n\tif (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n\t\treturn(pass);\n\t}\n\n\tif (req.url ~ \"^\/v\\d\/polyfill\\.\" && req.url !~ \"[\\?\\&]ua=\") {\n\t\tset req.http.X-Orig-URL = req.url;\n\t\tset req.url = \"\/v2\/normalizeUa?ua=\" urlencode(req.http.User-Agent);\n\t}\n\n\treturn(lookup);\n}\n\nsub vcl_deliver {\n#FASTLY deliver\n\n\t# If the response is to a normalise request and there's a parked \"original request\", use the normalised UA response to modify the original request and restart it\n\tif (req.url ~ \"^\/v\\d\/normalizeUa\" && resp.status == 200 && req.http.X-Orig-URL) {\n\t\tset req.http.Fastly-force-Shield = \"1\";\n\t\tif (req.http.X-Orig-URL ~ \"\\?\") {\n\t\t\tset req.url = req.http.X-Orig-URL \"&ua=\" resp.http.Normalized-User-Agent;\n\t\t} else {\n\t\t\tset req.url = req.http.X-Orig-URL \"?ua=\" resp.http.Normalized-User-Agent;\n\t\t}\n\t\trestart;\n\n\t# If the original request didn't specify a UA override, and we added one when the request was sent to the backend, the backend won't have included a Vary:user-agent header (correctly) but we need to add one\n\t} else if (req.url ~ \"^\/v\\d\/polyfill\\..*[\\?\\&]ua=\" && req.http.X-Orig-URL && req.http.X-Orig-URL !~ \"[\\?\\&]ua=\") {\n\t\tset resp.http.Vary = \"Accept-Encoding, User-Agent\";\n\t}\n\treturn(deliver);\n}\n","old_contents":"sub vcl_recv {\n#FASTLY recv\n\n\tif (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n\t\treturn(pass);\n\t}\n\n\tif (req.url ~ \"^\/v1\/polyfill\\.\" && req.url !~ \"[\\?\\&]ua=\") {\n\t\tset req.http.X-Orig-URL = req.url;\n\t\tset req.url = \"\/v1\/normalizeUa?ua=\" urlencode(req.http.User-Agent);\n\t}\n\n\treturn(lookup);\n}\n\nsub vcl_deliver {\n#FASTLY deliver\n\n\t# If the response is to a normalise request and there's a parked \"original request\", use the normalised UA response to modify the original request and restart it\n\tif (req.url ~ \"^\/v1\/normalizeUa\" && resp.status == 200 && req.http.X-Orig-URL) {\n\t\tset req.http.Fastly-force-Shield = \"1\";\n\t\tif (req.http.X-Orig-URL ~ \"\\?\") {\n\t\t\tset req.url = req.http.X-Orig-URL \"&ua=\" resp.http.Normalized-User-Agent;\n\t\t} else {\n\t\t\tset req.url = req.http.X-Orig-URL \"?ua=\" resp.http.Normalized-User-Agent;\n\t\t}\n\t\trestart;\n\n\t# If the original request didn't specify a UA override, and we added one when the request was sent to the backend, the backend won't have included a Vary:user-agent header (correctly) but we need to add one\n\t} else if (req.url ~ \"^\/v1\/polyfill\\..*[\\?\\&]ua=\" && req.http.X-Orig-URL && req.http.X-Orig-URL !~ \"[\\?\\&]ua=\") {\n\t\tset resp.http.Vary = \"Accept-Encoding, User-Agent\";\n\t}\n\treturn(deliver);\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"a6b9e5b8a30651e6165c04e6edae16eed1dcbaf2","subject":"Simplified wp cookie regex (based on cookie regex we're using in production.vcl)","message":"Simplified wp cookie regex (based on cookie regex we're using in production.vcl)\n","repos":"evolution\/wordpress,evolution\/genesis-wordpress,evolution\/genesis-wordpress,genesis\/wordpress,genesis\/wordpress,evolution\/wordpress,genesis\/wordpress,evolution\/genesis-wordpress,jalevin\/wordpress,evolution\/wordpress,genesis\/wordpress,evolution\/genesis-wordpress,jalevin\/wordpress,jalevin\/wordpress,genesis\/wordpress,evolution\/wordpress,jalevin\/wordpress,jalevin\/wordpress,evolution\/genesis-wordpress,evolution\/genesis-wordpress,genesis\/wordpress,evolution\/wordpress","old_file":"provisioning\/roles\/varnish\/files\/etc-varnish\/conf.d\/receive\/wordpress.vcl","new_file":"provisioning\/roles\/varnish\/files\/etc-varnish\/conf.d\/receive\/wordpress.vcl","new_contents":"# Pass all login requests straight through\nif (req.url ~ \"wp-login\") {\n return (pass);\n}\n# Pipe all admin requests directly\nif (req.url ~ \"wp-admin\") {\n return (pipe);\n}\n\n# Pass all requests containing a wp- or wordpress_ cookie\n# (meaning NO caching for logged in users)\nif (req.http.Cookie ~ \"(^|;\\s*)(wp-|wordpress_)\") {\n return (pass);\n}\n\n# Drop *all* cookies sent to Wordpress, if we've gotten this far\nunset req.http.Cookie;\n\n# Try a cache-lookup\nreturn (lookup);\n","old_contents":"# Pass all login requests straight through\nif (req.url ~ \"wp-login\") {\n return (pass);\n}\n# Pipe all admin requests directly\nif (req.url ~ \"wp-admin\") {\n return (pipe);\n}\n\n# Pass all requests containing a wp- or wordpress_ cookie\n# (meaning NO caching for logged in users)\nif (req.http.Cookie ~ \"^([^;]+;\\s*)*?(wp-|wordpress_)\") {\n return (pass);\n}\n\n# Drop *all* cookies sent to Wordpress, if we've gotten this far\nunset req.http.Cookie;\n\n# Try a cache-lookup\nreturn (lookup);\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"d47ccc01183a0999a0e1dbd7e1edb917b45d336a","subject":"add max_connections to backend example","message":"add max_connections to backend example\n","repos":"NITEMAN\/varnish-bites,NITEMAN\/Varnish_VCL_samps-hacks","old_file":"varnish4\/drupal-base.vcl","new_file":"varnish4\/drupal-base.vcl","new_contents":"\/* Varnish 4 example config for Drupal 7 \/ Pressflow 6 & 7 *\/\n# Original source: https:\/\/github.com\/NITEMAN\/varnish-bites\/varnish4\/drupal-base.vcl\n# Copyright (c) 2015 Pedro Gonz\u00e1lez Serrano and individual contributors.\n# MIT License\n\n# Intended to be used both in simple production environments and with\n# learning\/teaching purposes.\n# Some references may not be yet updated to VCL 4.0, we use SeeV3 then.\n\n# WARNING:\n# Note that the built-in logic will be appended to our code if no return is performed before.\n# Built-in logic is included commented out right after our's for reference purposes in that cases.\n# See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleDefault\n\n#######################################################################\n# Initialization: Version & imports;\n\n\/* Version statement *\/\n# Since Varnish 4.0 it's mandatory to declare VCL version on first line.\nvcl 4.0;\n\n\/* Module (VMOD) imports *\/\n# Standard module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_std.generated.html\nimport std;\n\n# Directors module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# Unused in simple configs.\n#import directors;\n\n\n#######################################################################\n# Probe, backend, ACL and subroutine definitions\n\n\/* Backend probes \/ healthchecks *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#probes\nprobe basic {\n \/* Only test that backend's IP serves content for '\/' *\/\n # This might be a too heavy probe\n # .url = \"\/\";\n \/* Only test that backend's IP has apache working *\/\n # Nginx would fail this probe with a default config\n .request =\n \"OPTIONS * HTTP\/1.1\"\n \"Host: *\"\n \"Connection: close\";\n .interval = 10s;\n .timeout = 2s;\n .window = 8;\n .threshold = 6;\n}\n\n\/* Backend definitions.*\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#backend-definition\nbackend default {\n \/* Default backend on the same machine. WARNING: timeouts could be not big enought for certain POST request *\/\n .host = \"127.0.0.1\";\n .port = \"8008\";\n .max_connections = 100;\n .connect_timeout = 60s;\n .first_byte_timeout = 60s;\n .between_bytes_timeout = 60s;\n .probe = basic;\n}\n\n\/* Access Control Lists *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#access-control-list-acl\nacl purge_ban {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use '\"localhost\";' instead\n}\nacl allowed_monitors {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n}\n#acl own_proxys {\n# \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n#}\n\n\/* Custom subroutines *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#subroutines\n#TODO# Test in Varnihs 4\n# Empty in simple configs.\n# We can name subs with no restrictions but as a task can need several chunks of code in diferent states,\n# it's a good idea to identify what main sub will call each with a suffix.\n# \/* Example 301 client redirection removing \"www\" prefix from request *\/\n# sub perm_redirections_recv {\n# if ( req.http.host ~ \"^www.*$\" ) {\n# return(synth(751, \"http:\/\/\" + regsub(req.http.host, \"^www\\.\", \"\") + req.url));\n# }\n# }\n# sub perm_redirections_synth {\n# if (resp.status == 751) {\n# \/* Get new URL from the response *\/\n# set resp.http.Location = resp.response;\n# \/* Set HTTP 301 for permanent redirect *\/\n# set resp.status = 301;\n# return (deliver);\n# }\n# }\n\n\n#######################################################################\n# Client side\n\n# vcl_recv: Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-recv\nsub vcl_recv {\n \/* 0th: general bypass, general return & authorization checks *\/\n # Empty in simple configs.\n # Useful for debugging we can pipe or pass the request to default backend here to bypass completely Varnish.\n # return (pipe);\n # return (pass);\n # We can also return here a 200 Ok for network performance benchmarking.\n # return(synth(200, \"Ok\"));\n # Finally we can perform basic HTTP authentification here, by example.\n # SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* 1st: Check for Varnish special requests *\/ \n # Custom response implementation example in order to check that Varnish is working properly.\n # This is usefull for automatic monitoring with monit or when Varnish is behind another proxies like HAProxy.\n if ( ( req.http.host == \"monitor.server.health\"\n || req.http.host == \"health.varnish\" )\n && client.ip ~ allowed_monitors\n && ( req.method == \"OPTIONS\" || req.method == \"GET\" )\n ) {\n return(synth(200, \"Ban added\"));\n }\n # Purge logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#http-purging\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if (req.method == \"PURGE\") {\n if (!client.ip ~ purge_ban) {\n return(synth(405, \"Not allowed.\"));\n }\n return (purge);\n }\n # Ban logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#bans\n if (req.method == \"BAN\") {\n if (!client.ip ~ purge_ban) {\n return(synth(405, \"Not allowed.\"));\n }\n ban(\"req.http.host == \" + req.http.host +\n \"&& req.url == \" + req.url); \n return(synth(200, \"Ban added\"));\n }\n\n \/* 2nd: Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_recv;\n # Here we can also enforce SSL when Varnish run behind some SSL termination point.\n\n \/* 3rd: Time for backend choice *\/\n # Empty in simple configs.\n\n \/* 4th: Prepare headers for the backend *\/\n # Empty in simple configs.\n # Example remove own_proxys from X-Forwarded-For\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/whats-new\/upgrading.html#x-forwarded-for-is-now-set-before-vcl-recv\n # if ( req.restarts == 0\n # && client.ip ~ own_proxys\n # && req.http.x-forwarded-for\n # ) {\n # set req.http.X-Forwarded-For = regsub(req.http.X-Forwarded-For, \",( )?\" + client.ip, \"\");\n # }\n\n \/* 5th: Bypass breakpoint 1 *\/\n # Useful for debugging we can now pipe or pass the request to backend with headers setted.\n # return (pipe);\n # return (pass);\n\n \/* 6th: Decide if we should deal with a request (mostly copied from built-in logic) *\/\n if (req.method == \"PRI\") {\n \/* We do not support SPDY or HTTP\/2.0 *\/\n return (synth(405));\n }\n if ( req.method != \"GET\"\n && req.method != \"HEAD\"\n && req.method != \"PUT\"\n && req.method != \"POST\"\n && req.method != \"TRACE\"\n && req.method != \"OPTIONS\"\n && req.method != \"DELETE\"\n ) {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n\n \/* 7th: Access control for some URLs by ACL *\/\n # Empty in simple configs.\n # By example denial some URLs depending on client-ip, we'll need to define corresponding ACL 'internal'.\n # if ( req.url ~ \"^\/(cron|install)\\.php\"\n # && ! client.ip ~ internal\n # ) {\n # # Have Varnish throw the error directly.\n # return(synth(403, \"Forbidden.\"));\n # # Use a custom error page that you've defined in Drupal at the path \"404\".\n # # set req.url = \"\/403\";\n # }\n\n \/* 8th: Custom exceptions *\/\n # Host exception example:\n # if (req.http.host == \"ejemplo.exception.com\") {\n # return (pass);\n # }\n # Drupal exceptions, edit if we want to cache some AJAX\/AHAH request.\n # Add here filters for never cache URLs such as Payment Gateway's callbacks\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/ooyala\/ping$\" ||\n req.url ~ \"^\/admin\/build\/features\" ||\n req.url ~ \"^\/info\/.*$\" ||\n req.url ~ \"^\/flag\/.*$\" ||\n req.url ~ \"^.*\/ajax\/.*$\" ||\n req.url ~ \"^.*\/ahah\/.*$\") {\n \/* Do not cache these paths *\/\n return (pass);\n }\n # Pipe these paths directly to backend for streaming.\n if (req.url ~ \"^\/admin\/content\/backup_migrate\/export\") {\n return (pipe);\n }\n if (req.url ~ \"^\/system\/files\") {\n return (pipe);\n }\n\n \/* 9th: Serve from anonymous cahe if all backends are down *\/\n if (! std.healthy(req.backend_hint) ) {\n #TODO# Consider moving this to vcl_backend_fetch\n unset req.http.Cookie;\n #TODO# Add sick marker\n } \n\n \/* 10th: Deal with compression and the Accept-Encoding header *\/\n # Althought Varnish 3 handles gziped content itself by default, just to be sure we want to \n # remove Accept-Encoding for some compressed formats.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html#what-does-http-gzip-support-do\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/varnishd.html?highlight=http_gzip_support\n # See (for older configs) https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleNormalizeAcceptEncoding\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|mp4|flv|zip|rar)$\") {\n \/* Already compressed formats, no sense trying to compress again *\/\n unset req.http.Accept-Encoding;\n }\n }\n\n \/* 11th: Another header manipulation *\/\n # Empty in simple configs.\n # We could add here a custom header grouping User-agent families.\n\n \/* 12th: Cookie removal *\/\n # Always cache the following static file types for all users. \n # Use with care if we control certain downloads depending on cookies. \n # Be carefull also if appending .htm[l] via Drupal's clean URLs.\n if ( req.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|woff2|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n && req.url !~ \"\/system\/storage\/serve\"\n ) {\n unset req.http.Cookie;\n }\n # Remove all cookies that backend doesn't need to know about.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRemovingSomeCookies\n if (req.http.Cookie) {\n \/* Warning: Not a pretty solution *\/\n \/* Prefix header containing cookies with ';' *\/\n set req.http.Cookie = \";\" + req.http.Cookie;\n \/* Remove any spaces after ';' in header containing cookies *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n \/* Prefix cookies we want to preserve with one space *\/\n \/* 'S{1,2}ESS[a-z0-9]+' is the regular expression matching a Drupal session cookie ({1,2} added for HTTPS support) *\/\n \/* 'NO_CACHE' is usually set after a POST request to make sure issuing user see the results of his post *\/\n \/* 'OATMEAL' & 'CHOCOLATECHIP' are special cookies used by Drupal's Bakery module to provide Single Sign On *\/\n \/* Keep in mind we should add here any cookie that should reach the backend such as splahs avoiding cookies *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \";(S{1,2}ESS[a-z0-9]+|NO_CACHE|OATMEAL|CHOCOLATECHIP)=\", \"; \\1=\");\n \/* Remove from the header any single Cookie not prefixed with a space until next ';' separator *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n \/* Remove any '; ' at the start or the end of the header *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n\n if (req.http.Cookie == \"\") {\n \/* If there are no remaining cookies, remove the cookie header. *\/\n unset req.http.Cookie;\n }\n }\n\n \/* 13th: Session cookie & special cookies bypass caching stage *\/\n # As we might want to cache some requests, hashed with its cookies, \n # we don't simply pass when some cookies remain present at this point.\n # Instead we look for request that must be passed due to the cookie header.\n if ( req.http.Cookie ~ \"SESS\"\n || req.http.Cookie ~ \"SSESS\"\n || req.http.Cookie ~ \"NO_CACHE\"\n || req.http.Cookie ~ \"OATMEAL\"\n || req.http.Cookie ~ \"CHOCOLATECHIP\"\n ) {\n return (pass);\n }\n\n \/* 14th: Bypass breakpoint 2 *\/\n # Useful for debugging we can now pipe or pass the request to backend to bypass cache.\n # return (pipe);\n # return (pass);\n\n \/* 15th: Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning inconditionally.\n return (hash);\n}\n\n# vcl_pipe: Called upon entering pipe mode.\n# In this mode, the request is passed on to the backend, \n# and any further data from either client or backend is passed on unaltered until either end closes the connection.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pipe\n# sub vcl_pipe {\n# # By default Connection: close is set on all piped requests, to stop\n# # connection reuse from sending future requests directly to the\n# # (potentially) wrong backend. If you do want this to happen, you can undo\n# # it here.\n# # unset bereq.http.connection;\n# return (pipe);\n# }\n\n# vcl_pass: Called upon entering pass mode. \n# In this mode, the request is passed on to the backend, and the backend's response is passed on to the client, \n# but is not entered into the cache.\n# Subsequent requests submitted over the same client connection are handled normally.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pass\n# sub vcl_pass {\n# return (fetch);\n# }\n\n# vcl_hash: You may call hash_data() on the data you would like to add to the hash.\n# Hash is used by Varnish to uniquely identify objects.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hash\nsub vcl_hash {\n \/* Hash cookie data *\/\n # As requests with same URL and host can produce diferent results when issued with different cookies,\n # we need to store items hashed with the associated cookies. Note that cookies are already sanitized when we reach this point.\n if (req.http.Cookie) {\n \/* Include cookie in cache hash *\/\n hash_data(req.http.Cookie);\n }\n\n \/* Custom header hashing *\/\n # Empty in simple configs.\n # Example for caching differents object versions by device previously detected (when static content could also vary):\n # if (req.http.X-UA-Device) {\n # hash_data(req.http.X-UA-Device);\n # }\n # Example for caching diferent object versions by X-Forwarded-Proto, trying to be smart about what kind of request\n # could generate diffetent responses.\n if ( req.http.X-Forwarded-Proto\n && req.url !~ \"(?i)\\.(png|gif|jpeg|jpg|ico|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|woff2|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\") {\n hash_data(req.http.X-Forwarded-Proto);\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (lookup);\n# }\n\n# vcl_purge: Called after the purge has been executed and all its variants have been evited.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-purge\n# sub vcl_purge {\n# return (synth(200, \"Purged\"));\n# }\n\n# vcl_hit: Called after a cache lookup if the requested document was found in the cache.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hit\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n \/\/ A pure unadultered hit, deliver it\n return (deliver);\n }\n \/* Allow varnish to serve up stale content if it is responding slowly *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n if (obj.ttl + 60s > 0s) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n return (deliver);\n }\n \/* Allow varish to serve up stale content if all backends are down *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n if ( ! std.healthy(req.backend_hint)\n && obj.ttl + obj.grace > 0s\n ) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n return (deliver);\n }\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning inconditionally.\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\n# vcl_miss: Called after a cache lookup if the requested document was not found in the cache.\n# Its purpose is to decide whether or not to attempt to retrieve the document from the backend, and which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-miss\n# sub vcl_miss {\n# return (fetch);\n# }\n\n# vcl_deliver: Called before an object is delivered to the client\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-deliver\nsub vcl_deliver {\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # Add whether the object is a cache hit or miss and the number of hits for the object.\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Addingaheaderindicatinghitmiss\n # In Varnish 4 the obj.hits counter behaviour has changed (see bug 1492), so\n # we use a different method: if X-Varnish contains only 1 id, we have a miss,\n # if it contains more (and therefore a space), we have a hit.\n if (resp.http.x-varnish ~ \" \") {\n set resp.http.X-Cache = \"HIT\";\n # Since in Varnish 4 the behaviour of obj.hits changed, this might not be accurate\n # See https:\/\/www.varnish-cache.org\/trac\/ticket\/1492\n set resp.http.X-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Cache = \"MISS\";\n \/* Show the results of cookie sanitization *\/\n set resp.http.X-Cookie = req.http.Cookie;\n }\n\n #TODO# Add sick marker\n\n # Restart count\n if ( req.restarts > 0) {\n set resp.http.X-Restarts = req.restarts;\n }\n\n # Add the Varnish server hostname\n set resp.http.X-Varnish-Server = server.hostname;\n # If we have setted a custom header with device family detected we can show it:\n # if (req.http.X-UA-Device) {\n # set resp.http.X-UA-Device = req.http.X-UA-Device;\n # }\n # If we have recived a custom header with the protocol in the request we can show it:\n # if (req.http.X-Forwarded-Proto) {\n # set resp.http.X-Forwarded-Proto = req.http.X-Forwarded-Proto;\n # }\n\n \/* Vary header manipulation *\/\n # Empty in simple configs.\n # By example, if we are storing & serving diferent objects depending on User-Agent header we must set the correct Vary header:\n # if (resp.http.Vary) {\n # set resp.http.Vary = resp.http.Vary + \",User-Agent\";\n # } else {\n # set resp.http.Vary = \"User-Agent\";\n # }\n\n \/* Fake headers *\/\n # Empty in simple configs\n # We can fake server headers here, by example:\n # set resp.http.Server = \"Deep thought\";\n # set resp.http.X-Powered-By = \"BOFH\";\n # Or have some fun with headers:\n # See http:\/\/www.nextthing.org\/archives\/2005\/08\/07\/fun-with-http-headers\n # See http:\/\/royal.pingdom.com\/2012\/08\/15\/fun-and-unusual-http-response-headers\/\n # set resp.http.X-Thank-You = \"for bothering to look at my HTTP headers\";\n # set resp.http.X-Answer = \"42\";\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_deliver {\n# return (deliver);\n# }\n\n# vcl_synth: Called to deliver a synthetic object. A synthetic object is generated in VCL,\n# not fetched from the backend. It is typically contructed using the synthetic() function.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-synth\n\/*\n * We can come here \"invisibly\" with the following errors: 413, 417 & 503\n *\/\nsub vcl_synth {\n \/* Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_synth;\n\n \/* Try to restart request in case of failure *\/\n # Note that max_restarts defaults to 4\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if (resp.status == 503 && req.restarts < 4) {\n return(restart);\n }\n\n \/* Set common headers for synthetic responses *\/\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n\n \/* HTTP Authentification client request *\/\n # Empty in simple configs. SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* Load synthetic responses from disk *\/\n # Note that files loaded this way are never re-readed (even after a reload).\n # You should consider PROS\/CONS of doing an include instead.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_std.generated.html#func-fileread\n # Example custom 403 error page.\n # if (resp.status == 403) {\n # synthetic(std.fileread(\"\/403.html\"));\n # return(deliver);\n # }\n\n \/* Error page & refresh \/ redirections *\/\n # We have plenty of choices when we have to serve an error to the client, \n # from the default error page to javascript black magic or plain redirections.\n # Adding some external statistic javascript to track failures served to clients is strongly suggested.\n # We can't use external resources on synthetic content, everything must be inlined.\n # If we need to include images we can embed them in base64 encoding.\n # Here is the default error page for Varnish 4 (not so pretty)\n # We're using error 200 for monitoring puposes which should not be retried client side *\/\n if ( resp.status != 200) {\n set resp.http.Retry-After = \"5\";\n }\n\n # Consider add some analytics stuff to trace accesses\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning inconditionally.\n return (deliver);\n}\n\n#######################################################################\n# Backend Fetch\n\n# vcl_backend_fetch: Called before sending the backend request. In this subroutine you typically alter the request before it gets to the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-fetch\n# sub vcl_backend_fetch {\n# return (fetch);\n# }\n\n# vcl_backend_response: Called after the response headers has been successfully retrieved from the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-response\nsub vcl_backend_response {\n \/* Caching exceptions *\/\n # Varnish will cache objects with response codes: 200, 203, 300, 301, 302, 307, 404 & 410.\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/VCL_Basics.html#the-initial-value-of-beresp-ttl\n # Drupal's Imagecache module can return a 307 redirection to the requested url itself and, depending on Drupal's cache settings,\n # this could lead to a redirection loop being cached for a long time but also we want Varnish to shield a little the backend.\n # See http:\/\/drupal.org\/node\/1248010\n # See http:\/\/drupal.org\/node\/310656\n if (beresp.status == 307 &&\n #TODO# verify that this work better than 'bereq.url ~ \"imagecache\"' *\/\n beresp.http.Location == bereq.url &&\n beresp.ttl > 5s) {\n set beresp.ttl = 5s;\n set beresp.http.cache-control = \"max-age=5\";\n }\n\n \/* Request retrial *\/\n if ( beresp.status == 500\n || beresp.status == 503\n ) {\n #TODO# consider not restarting POST requests as seenV3 on https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleSaintMode\n return (retry);\n }\n\n \/* Enable grace mode. Related with vcl_hit *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n set beresp.grace = 1h;\n\n \/* Strip cookies from the following static file types for all users. Related with our 12th stage on vcl_recv *\/\n if (bereq.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|woff2|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\") {\n unset beresp.http.set-cookie;\n }\n\n \/* Gzip response *\/\n # Empty in simple configs\n # Use Varnish to Gzip respone, if suitable, before storing it on cache\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html\n if ( ! beresp.http.Content-Encoding\n && ( beresp.http.content-type ~ \"text\"\n || beresp.http.content-type ~ \"application\/x-javascript\"\n || beresp.http.content-type ~ \"application\/javascript\"\n || beresp.http.content-type ~ \"application\/rss+xml\"\n || beresp.http.content-type ~ \"application\/xml\"\n || beresp.http.content-type ~ \"Application\/JSON\")\n ) {\n set beresp.do_gzip = true;\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # We can add the name of the backend that has processed the request:\n # set beresp.http.X-Backend = beresp.backend.name;\n # We can use a header to tell if the object was gziped by Varnish\n # if (beresp.do_gzip) {\n # set beresp.http.X-Varnish-Gzipped = \"yes\";\n # } else {\n # set beresp.http.X-Varnish-Gizipped = \"no\";\n # }\n # We can also add headers informing whether the object is cacheable or not and why.\n # https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Varnish3.0\n if (beresp.ttl <= 0s) {\n \/* Varnish determined the object was not cacheable *\/\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n } elsif (bereq.http.Cookie ~ \"(SESS|SSESS|NO_CACHE|OATMEAL|CHOCOLATECHIP)\") {\n \/* We don't wish to cache content for logged in users or with certain cookies. Related with our 9th stage on vcl_recv *\/\n set beresp.http.X-Cacheable = \"NO:Cookies\";\n # return(hit_for_pass);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n \/* We are respecting the Cache-Control=private header from the backend *\/\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n # return(hit_for_pass);\n } else {\n \/* Varnish determined the object was cacheable *\/\n set beresp.http.X-Cacheable = \"YES\";\n }\n\n \/* Further header manipulation *\/\n # Empty in simple configs.\n # We can also unset some headers to prevent information disclosure and save some cache space\n # unset beresp.http.Server;\n # unset beresp.http.X-Powered-By;\n # Retry count\n if ( bereq.retries > 0) {\n set beresp.http.X-Retries = bereq.retries;\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_backend_response {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Surrogate-control ~ \"no-store\" ||\n# (!beresp.http.Surrogate-Control &&\n# beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n# beresp.http.Vary == \"*\") {\n# \/*\n# * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# *\/\n# set beresp.ttl = 120s;\n# set beresp.uncacheable = true;\n# }\n# return (deliver);\n# }\n\n# vcl_backend_error: This subroutine is called if we fail the backend fetch.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-error\nsub vcl_backend_error {\n\n \/* Try to restart request in case of failure *\/\n #TODO# Confirm max_retries default value\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if (bereq.retries < 4) {\n return (retry);\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # Retry count\n if ( bereq.retries > 0) {\n set beresp.http.X-Retries = bereq.retries;\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + beresp.status + \" \" + beresp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + beresp.status + \" \" + beresp.reason + {\"<\/h1>\n <p>\"} + beresp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + bereq.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this point.\n return (deliver);\n}\n\n#######################################################################\n# Housekeeping\n\n# vcl_init: Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-init\n# Here is where you should declare your directors now.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-backends.html#directors\n# Empty in simple configs\n# sub vcl_init {\n# return (ok);\n# }\n\n# vcl_fini: Called when VCL is discarded only after all requests have exited the VCL. Typically used to clean up VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-fini\n# sub vcl_fini {\n# return (ok);\n# }\n\n","old_contents":"\/* Varnish 4 example config for Drupal 7 \/ Pressflow 6 & 7 *\/\n# Original source: https:\/\/github.com\/NITEMAN\/varnish-bites\/varnish4\/drupal-base.vcl\n# Copyright (c) 2015 Pedro Gonz\u00e1lez Serrano and individual contributors.\n# MIT License\n\n# Intended to be used both in simple production environments and with\n# learning\/teaching purposes.\n# Some references may not be yet updated to VCL 4.0, we use SeeV3 then.\n\n# WARNING:\n# Note that the built-in logic will be appended to our code if no return is performed before.\n# Built-in logic is included commented out right after our's for reference purposes in that cases.\n# See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleDefault\n\n#######################################################################\n# Initialization: Version & imports;\n\n\/* Version statement *\/\n# Since Varnish 4.0 it's mandatory to declare VCL version on first line.\nvcl 4.0;\n\n\/* Module (VMOD) imports *\/\n# Standard module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_std.generated.html\nimport std;\n\n# Directors module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# Unused in simple configs.\n#import directors;\n\n\n#######################################################################\n# Probe, backend, ACL and subroutine definitions\n\n\/* Backend probes \/ healthchecks *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#probes\nprobe basic {\n \/* Only test that backend's IP serves content for '\/' *\/\n # This might be a too heavy probe\n # .url = \"\/\";\n \/* Only test that backend's IP has apache working *\/\n # Nginx would fail this probe with a default config\n .request =\n \"OPTIONS * HTTP\/1.1\"\n \"Host: *\"\n \"Connection: close\";\n .interval = 10s;\n .timeout = 2s;\n .window = 8;\n .threshold = 6;\n}\n\n\/* Backend definitions.*\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#backend-definition\nbackend default {\n \/* Default backend on the same machine. WARNING: timeouts could be not big enought for certain POST request *\/\n .host = \"127.0.0.1\";\n .port = \"8008\";\n .connect_timeout = 60s;\n .first_byte_timeout = 60s;\n .between_bytes_timeout = 60s;\n .probe = basic;\n}\n\n\/* Access Control Lists *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#access-control-list-acl\nacl purge_ban {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use '\"localhost\";' instead\n}\nacl allowed_monitors {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n}\n#acl own_proxys {\n# \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n#}\n\n\/* Custom subroutines *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#subroutines\n#TODO# Test in Varnihs 4\n# Empty in simple configs.\n# We can name subs with no restrictions but as a task can need several chunks of code in diferent states,\n# it's a good idea to identify what main sub will call each with a suffix.\n# \/* Example 301 client redirection removing \"www\" prefix from request *\/\n# sub perm_redirections_recv {\n# if ( req.http.host ~ \"^www.*$\" ) {\n# return(synth(751, \"http:\/\/\" + regsub(req.http.host, \"^www\\.\", \"\") + req.url));\n# }\n# }\n# sub perm_redirections_synth {\n# if (resp.status == 751) {\n# \/* Get new URL from the response *\/\n# set resp.http.Location = resp.response;\n# \/* Set HTTP 301 for permanent redirect *\/\n# set resp.status = 301;\n# return (deliver);\n# }\n# }\n\n\n#######################################################################\n# Client side\n\n# vcl_recv: Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-recv\nsub vcl_recv {\n \/* 0th: general bypass, general return & authorization checks *\/\n # Empty in simple configs.\n # Useful for debugging we can pipe or pass the request to default backend here to bypass completely Varnish.\n # return (pipe);\n # return (pass);\n # We can also return here a 200 Ok for network performance benchmarking.\n # return(synth(200, \"Ok\"));\n # Finally we can perform basic HTTP authentification here, by example.\n # SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* 1st: Check for Varnish special requests *\/ \n # Custom response implementation example in order to check that Varnish is working properly.\n # This is usefull for automatic monitoring with monit or when Varnish is behind another proxies like HAProxy.\n if ( ( req.http.host == \"monitor.server.health\"\n || req.http.host == \"health.varnish\" )\n && client.ip ~ allowed_monitors\n && ( req.method == \"OPTIONS\" || req.method == \"GET\" )\n ) {\n return(synth(200, \"Ban added\"));\n }\n # Purge logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#http-purging\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if (req.method == \"PURGE\") {\n if (!client.ip ~ purge_ban) {\n return(synth(405, \"Not allowed.\"));\n }\n return (purge);\n }\n # Ban logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#bans\n if (req.method == \"BAN\") {\n if (!client.ip ~ purge_ban) {\n return(synth(405, \"Not allowed.\"));\n }\n ban(\"req.http.host == \" + req.http.host +\n \"&& req.url == \" + req.url); \n return(synth(200, \"Ban added\"));\n }\n\n \/* 2nd: Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_recv;\n # Here we can also enforce SSL when Varnish run behind some SSL termination point.\n\n \/* 3rd: Time for backend choice *\/\n # Empty in simple configs.\n\n \/* 4th: Prepare headers for the backend *\/\n # Empty in simple configs.\n # Example remove own_proxys from X-Forwarded-For\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/whats-new\/upgrading.html#x-forwarded-for-is-now-set-before-vcl-recv\n # if ( req.restarts == 0\n # && client.ip ~ own_proxys\n # && req.http.x-forwarded-for\n # ) {\n # set req.http.X-Forwarded-For = regsub(req.http.X-Forwarded-For, \",( )?\" + client.ip, \"\");\n # }\n\n \/* 5th: Bypass breakpoint 1 *\/\n # Useful for debugging we can now pipe or pass the request to backend with headers setted.\n # return (pipe);\n # return (pass);\n\n \/* 6th: Decide if we should deal with a request (mostly copied from built-in logic) *\/\n if (req.method == \"PRI\") {\n \/* We do not support SPDY or HTTP\/2.0 *\/\n return (synth(405));\n }\n if ( req.method != \"GET\"\n && req.method != \"HEAD\"\n && req.method != \"PUT\"\n && req.method != \"POST\"\n && req.method != \"TRACE\"\n && req.method != \"OPTIONS\"\n && req.method != \"DELETE\"\n ) {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n\n \/* 7th: Access control for some URLs by ACL *\/\n # Empty in simple configs.\n # By example denial some URLs depending on client-ip, we'll need to define corresponding ACL 'internal'.\n # if ( req.url ~ \"^\/(cron|install)\\.php\"\n # && ! client.ip ~ internal\n # ) {\n # # Have Varnish throw the error directly.\n # return(synth(403, \"Forbidden.\"));\n # # Use a custom error page that you've defined in Drupal at the path \"404\".\n # # set req.url = \"\/403\";\n # }\n\n \/* 8th: Custom exceptions *\/\n # Host exception example:\n # if (req.http.host == \"ejemplo.exception.com\") {\n # return (pass);\n # }\n # Drupal exceptions, edit if we want to cache some AJAX\/AHAH request.\n # Add here filters for never cache URLs such as Payment Gateway's callbacks\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/ooyala\/ping$\" ||\n req.url ~ \"^\/admin\/build\/features\" ||\n req.url ~ \"^\/info\/.*$\" ||\n req.url ~ \"^\/flag\/.*$\" ||\n req.url ~ \"^.*\/ajax\/.*$\" ||\n req.url ~ \"^.*\/ahah\/.*$\") {\n \/* Do not cache these paths *\/\n return (pass);\n }\n # Pipe these paths directly to backend for streaming.\n if (req.url ~ \"^\/admin\/content\/backup_migrate\/export\") {\n return (pipe);\n }\n if (req.url ~ \"^\/system\/files\") {\n return (pipe);\n }\n\n \/* 9th: Serve from anonymous cahe if all backends are down *\/\n if (! std.healthy(req.backend_hint) ) {\n #TODO# Consider moving this to vcl_backend_fetch\n unset req.http.Cookie;\n #TODO# Add sick marker\n } \n\n \/* 10th: Deal with compression and the Accept-Encoding header *\/\n # Althought Varnish 3 handles gziped content itself by default, just to be sure we want to \n # remove Accept-Encoding for some compressed formats.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html#what-does-http-gzip-support-do\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/varnishd.html?highlight=http_gzip_support\n # See (for older configs) https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleNormalizeAcceptEncoding\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|mp4|flv|zip|rar)$\") {\n \/* Already compressed formats, no sense trying to compress again *\/\n unset req.http.Accept-Encoding;\n }\n }\n\n \/* 11th: Another header manipulation *\/\n # Empty in simple configs.\n # We could add here a custom header grouping User-agent families.\n\n \/* 12th: Cookie removal *\/\n # Always cache the following static file types for all users. \n # Use with care if we control certain downloads depending on cookies. \n # Be carefull also if appending .htm[l] via Drupal's clean URLs.\n if ( req.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|woff2|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n && req.url !~ \"\/system\/storage\/serve\"\n ) {\n unset req.http.Cookie;\n }\n # Remove all cookies that backend doesn't need to know about.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRemovingSomeCookies\n if (req.http.Cookie) {\n \/* Warning: Not a pretty solution *\/\n \/* Prefix header containing cookies with ';' *\/\n set req.http.Cookie = \";\" + req.http.Cookie;\n \/* Remove any spaces after ';' in header containing cookies *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n \/* Prefix cookies we want to preserve with one space *\/\n \/* 'S{1,2}ESS[a-z0-9]+' is the regular expression matching a Drupal session cookie ({1,2} added for HTTPS support) *\/\n \/* 'NO_CACHE' is usually set after a POST request to make sure issuing user see the results of his post *\/\n \/* 'OATMEAL' & 'CHOCOLATECHIP' are special cookies used by Drupal's Bakery module to provide Single Sign On *\/\n \/* Keep in mind we should add here any cookie that should reach the backend such as splahs avoiding cookies *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \";(S{1,2}ESS[a-z0-9]+|NO_CACHE|OATMEAL|CHOCOLATECHIP)=\", \"; \\1=\");\n \/* Remove from the header any single Cookie not prefixed with a space until next ';' separator *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n \/* Remove any '; ' at the start or the end of the header *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n\n if (req.http.Cookie == \"\") {\n \/* If there are no remaining cookies, remove the cookie header. *\/\n unset req.http.Cookie;\n }\n }\n\n \/* 13th: Session cookie & special cookies bypass caching stage *\/\n # As we might want to cache some requests, hashed with its cookies, \n # we don't simply pass when some cookies remain present at this point.\n # Instead we look for request that must be passed due to the cookie header.\n if ( req.http.Cookie ~ \"SESS\"\n || req.http.Cookie ~ \"SSESS\"\n || req.http.Cookie ~ \"NO_CACHE\"\n || req.http.Cookie ~ \"OATMEAL\"\n || req.http.Cookie ~ \"CHOCOLATECHIP\"\n ) {\n return (pass);\n }\n\n \/* 14th: Bypass breakpoint 2 *\/\n # Useful for debugging we can now pipe or pass the request to backend to bypass cache.\n # return (pipe);\n # return (pass);\n\n \/* 15th: Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning inconditionally.\n return (hash);\n}\n\n# vcl_pipe: Called upon entering pipe mode.\n# In this mode, the request is passed on to the backend, \n# and any further data from either client or backend is passed on unaltered until either end closes the connection.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pipe\n# sub vcl_pipe {\n# # By default Connection: close is set on all piped requests, to stop\n# # connection reuse from sending future requests directly to the\n# # (potentially) wrong backend. If you do want this to happen, you can undo\n# # it here.\n# # unset bereq.http.connection;\n# return (pipe);\n# }\n\n# vcl_pass: Called upon entering pass mode. \n# In this mode, the request is passed on to the backend, and the backend's response is passed on to the client, \n# but is not entered into the cache.\n# Subsequent requests submitted over the same client connection are handled normally.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pass\n# sub vcl_pass {\n# return (fetch);\n# }\n\n# vcl_hash: You may call hash_data() on the data you would like to add to the hash.\n# Hash is used by Varnish to uniquely identify objects.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hash\nsub vcl_hash {\n \/* Hash cookie data *\/\n # As requests with same URL and host can produce diferent results when issued with different cookies,\n # we need to store items hashed with the associated cookies. Note that cookies are already sanitized when we reach this point.\n if (req.http.Cookie) {\n \/* Include cookie in cache hash *\/\n hash_data(req.http.Cookie);\n }\n\n \/* Custom header hashing *\/\n # Empty in simple configs.\n # Example for caching differents object versions by device previously detected (when static content could also vary):\n # if (req.http.X-UA-Device) {\n # hash_data(req.http.X-UA-Device);\n # }\n # Example for caching diferent object versions by X-Forwarded-Proto, trying to be smart about what kind of request\n # could generate diffetent responses.\n if ( req.http.X-Forwarded-Proto\n && req.url !~ \"(?i)\\.(png|gif|jpeg|jpg|ico|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|woff2|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\") {\n hash_data(req.http.X-Forwarded-Proto);\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (lookup);\n# }\n\n# vcl_purge: Called after the purge has been executed and all its variants have been evited.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-purge\n# sub vcl_purge {\n# return (synth(200, \"Purged\"));\n# }\n\n# vcl_hit: Called after a cache lookup if the requested document was found in the cache.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hit\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n \/\/ A pure unadultered hit, deliver it\n return (deliver);\n }\n \/* Allow varnish to serve up stale content if it is responding slowly *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n if (obj.ttl + 60s > 0s) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n return (deliver);\n }\n \/* Allow varish to serve up stale content if all backends are down *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n if ( ! std.healthy(req.backend_hint)\n && obj.ttl + obj.grace > 0s\n ) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n return (deliver);\n }\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning inconditionally.\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\n# vcl_miss: Called after a cache lookup if the requested document was not found in the cache.\n# Its purpose is to decide whether or not to attempt to retrieve the document from the backend, and which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-miss\n# sub vcl_miss {\n# return (fetch);\n# }\n\n# vcl_deliver: Called before an object is delivered to the client\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-deliver\nsub vcl_deliver {\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # Add whether the object is a cache hit or miss and the number of hits for the object.\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Addingaheaderindicatinghitmiss\n # In Varnish 4 the obj.hits counter behaviour has changed (see bug 1492), so\n # we use a different method: if X-Varnish contains only 1 id, we have a miss,\n # if it contains more (and therefore a space), we have a hit.\n if (resp.http.x-varnish ~ \" \") {\n set resp.http.X-Cache = \"HIT\";\n # Since in Varnish 4 the behaviour of obj.hits changed, this might not be accurate\n # See https:\/\/www.varnish-cache.org\/trac\/ticket\/1492\n set resp.http.X-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Cache = \"MISS\";\n \/* Show the results of cookie sanitization *\/\n set resp.http.X-Cookie = req.http.Cookie;\n }\n\n #TODO# Add sick marker\n\n # Restart count\n if ( req.restarts > 0) {\n set resp.http.X-Restarts = req.restarts;\n }\n\n # Add the Varnish server hostname\n set resp.http.X-Varnish-Server = server.hostname;\n # If we have setted a custom header with device family detected we can show it:\n # if (req.http.X-UA-Device) {\n # set resp.http.X-UA-Device = req.http.X-UA-Device;\n # }\n # If we have recived a custom header with the protocol in the request we can show it:\n # if (req.http.X-Forwarded-Proto) {\n # set resp.http.X-Forwarded-Proto = req.http.X-Forwarded-Proto;\n # }\n\n \/* Vary header manipulation *\/\n # Empty in simple configs.\n # By example, if we are storing & serving diferent objects depending on User-Agent header we must set the correct Vary header:\n # if (resp.http.Vary) {\n # set resp.http.Vary = resp.http.Vary + \",User-Agent\";\n # } else {\n # set resp.http.Vary = \"User-Agent\";\n # }\n\n \/* Fake headers *\/\n # Empty in simple configs\n # We can fake server headers here, by example:\n # set resp.http.Server = \"Deep thought\";\n # set resp.http.X-Powered-By = \"BOFH\";\n # Or have some fun with headers:\n # See http:\/\/www.nextthing.org\/archives\/2005\/08\/07\/fun-with-http-headers\n # See http:\/\/royal.pingdom.com\/2012\/08\/15\/fun-and-unusual-http-response-headers\/\n # set resp.http.X-Thank-You = \"for bothering to look at my HTTP headers\";\n # set resp.http.X-Answer = \"42\";\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_deliver {\n# return (deliver);\n# }\n\n# vcl_synth: Called to deliver a synthetic object. A synthetic object is generated in VCL,\n# not fetched from the backend. It is typically contructed using the synthetic() function.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-synth\n\/*\n * We can come here \"invisibly\" with the following errors: 413, 417 & 503\n *\/\nsub vcl_synth {\n \/* Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_synth;\n\n \/* Try to restart request in case of failure *\/\n # Note that max_restarts defaults to 4\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if (resp.status == 503 && req.restarts < 4) {\n return(restart);\n }\n\n \/* Set common headers for synthetic responses *\/\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n\n \/* HTTP Authentification client request *\/\n # Empty in simple configs. SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* Load synthetic responses from disk *\/\n # Note that files loaded this way are never re-readed (even after a reload).\n # You should consider PROS\/CONS of doing an include instead.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_std.generated.html#func-fileread\n # Example custom 403 error page.\n # if (resp.status == 403) {\n # synthetic(std.fileread(\"\/403.html\"));\n # return(deliver);\n # }\n\n \/* Error page & refresh \/ redirections *\/\n # We have plenty of choices when we have to serve an error to the client, \n # from the default error page to javascript black magic or plain redirections.\n # Adding some external statistic javascript to track failures served to clients is strongly suggested.\n # We can't use external resources on synthetic content, everything must be inlined.\n # If we need to include images we can embed them in base64 encoding.\n # Here is the default error page for Varnish 4 (not so pretty)\n # We're using error 200 for monitoring puposes which should not be retried client side *\/\n if ( resp.status != 200) {\n set resp.http.Retry-After = \"5\";\n }\n\n # Consider add some analytics stuff to trace accesses\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning inconditionally.\n return (deliver);\n}\n\n#######################################################################\n# Backend Fetch\n\n# vcl_backend_fetch: Called before sending the backend request. In this subroutine you typically alter the request before it gets to the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-fetch\n# sub vcl_backend_fetch {\n# return (fetch);\n# }\n\n# vcl_backend_response: Called after the response headers has been successfully retrieved from the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-response\nsub vcl_backend_response {\n \/* Caching exceptions *\/\n # Varnish will cache objects with response codes: 200, 203, 300, 301, 302, 307, 404 & 410.\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/VCL_Basics.html#the-initial-value-of-beresp-ttl\n # Drupal's Imagecache module can return a 307 redirection to the requested url itself and, depending on Drupal's cache settings,\n # this could lead to a redirection loop being cached for a long time but also we want Varnish to shield a little the backend.\n # See http:\/\/drupal.org\/node\/1248010\n # See http:\/\/drupal.org\/node\/310656\n if (beresp.status == 307 &&\n #TODO# verify that this work better than 'bereq.url ~ \"imagecache\"' *\/\n beresp.http.Location == bereq.url &&\n beresp.ttl > 5s) {\n set beresp.ttl = 5s;\n set beresp.http.cache-control = \"max-age=5\";\n }\n\n \/* Request retrial *\/\n if ( beresp.status == 500\n || beresp.status == 503\n ) {\n #TODO# consider not restarting POST requests as seenV3 on https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleSaintMode\n return (retry);\n }\n\n \/* Enable grace mode. Related with vcl_hit *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n set beresp.grace = 1h;\n\n \/* Strip cookies from the following static file types for all users. Related with our 12th stage on vcl_recv *\/\n if (bereq.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|woff2|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\") {\n unset beresp.http.set-cookie;\n }\n\n \/* Gzip response *\/\n # Empty in simple configs\n # Use Varnish to Gzip respone, if suitable, before storing it on cache\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html\n if ( ! beresp.http.Content-Encoding\n && ( beresp.http.content-type ~ \"text\"\n || beresp.http.content-type ~ \"application\/x-javascript\"\n || beresp.http.content-type ~ \"application\/javascript\"\n || beresp.http.content-type ~ \"application\/rss+xml\"\n || beresp.http.content-type ~ \"application\/xml\"\n || beresp.http.content-type ~ \"Application\/JSON\")\n ) {\n set beresp.do_gzip = true;\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # We can add the name of the backend that has processed the request:\n # set beresp.http.X-Backend = beresp.backend.name;\n # We can use a header to tell if the object was gziped by Varnish\n # if (beresp.do_gzip) {\n # set beresp.http.X-Varnish-Gzipped = \"yes\";\n # } else {\n # set beresp.http.X-Varnish-Gizipped = \"no\";\n # }\n # We can also add headers informing whether the object is cacheable or not and why.\n # https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Varnish3.0\n if (beresp.ttl <= 0s) {\n \/* Varnish determined the object was not cacheable *\/\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n } elsif (bereq.http.Cookie ~ \"(SESS|SSESS|NO_CACHE|OATMEAL|CHOCOLATECHIP)\") {\n \/* We don't wish to cache content for logged in users or with certain cookies. Related with our 9th stage on vcl_recv *\/\n set beresp.http.X-Cacheable = \"NO:Cookies\";\n # return(hit_for_pass);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n \/* We are respecting the Cache-Control=private header from the backend *\/\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n # return(hit_for_pass);\n } else {\n \/* Varnish determined the object was cacheable *\/\n set beresp.http.X-Cacheable = \"YES\";\n }\n\n \/* Further header manipulation *\/\n # Empty in simple configs.\n # We can also unset some headers to prevent information disclosure and save some cache space\n # unset beresp.http.Server;\n # unset beresp.http.X-Powered-By;\n # Retry count\n if ( bereq.retries > 0) {\n set beresp.http.X-Retries = bereq.retries;\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_backend_response {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Surrogate-control ~ \"no-store\" ||\n# (!beresp.http.Surrogate-Control &&\n# beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n# beresp.http.Vary == \"*\") {\n# \/*\n# * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# *\/\n# set beresp.ttl = 120s;\n# set beresp.uncacheable = true;\n# }\n# return (deliver);\n# }\n\n# vcl_backend_error: This subroutine is called if we fail the backend fetch.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-error\nsub vcl_backend_error {\n\n \/* Try to restart request in case of failure *\/\n #TODO# Confirm max_retries default value\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if (bereq.retries < 4) {\n return (retry);\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # Retry count\n if ( bereq.retries > 0) {\n set beresp.http.X-Retries = bereq.retries;\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + beresp.status + \" \" + beresp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + beresp.status + \" \" + beresp.reason + {\"<\/h1>\n <p>\"} + beresp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + bereq.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this point.\n return (deliver);\n}\n\n#######################################################################\n# Housekeeping\n\n# vcl_init: Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-init\n# Here is where you should declare your directors now.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-backends.html#directors\n# Empty in simple configs\n# sub vcl_init {\n# return (ok);\n# }\n\n# vcl_fini: Called when VCL is discarded only after all requests have exited the VCL. Typically used to clean up VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-fini\n# sub vcl_fini {\n# return (ok);\n# }\n\n","returncode":0,"stderr":"","license":"unknown","lang":"VCL"} {"commit":"17c109a7983b02bca3759374877ea078ea7cd3f4","subject":"Added detection for the new Microsoft Surface Devices - @see https:\/\/msdn.microsoft.com\/library\/hh920767(v=vs.85).aspx","message":"Added detection for the new Microsoft Surface Devices - @see https:\/\/msdn.microsoft.com\/library\/hh920767(v=vs.85).aspx\n","repos":"varnish\/varnish-devicedetect,varnish\/varnish-devicedetect","old_file":"devicedetect.vcl","new_file":"devicedetect.vcl","new_contents":"# Copyright (c) 2012-2014 Varnish Software AS\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions\n# are met:\n# 1. Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n# 2. Redistributions in binary form must reproduce the above copyright\n# notice, this list of conditions and the following disclaimer in the\n# documentation and\/or other materials provided with the distribution.\n#\n# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n# ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n# SUCH DAMAGE.\n#\n# detectdevice.vcl - regex based device detection for Varnish\n# https:\/\/github.com\/varnish\/varnish-devicedetect\/\n#\n# Author: Lasse Karstensen <lkarsten@varnish-software.com>\n\nsub devicedetect {\n\tunset req.http.X-UA-Device;\n\tset req.http.X-UA-Device = \"pc\";\n\n\t# Handle that a cookie may override the detection alltogether.\n\tif (req.http.Cookie ~ \"(?i)X-UA-Device-force\") {\n\t\t\/* ;?? means zero or one ;, non-greedy to match the first. *\/\n\t\tset req.http.X-UA-Device = regsub(req.http.Cookie, \"(?i).*X-UA-Device-force=([^;]+);??.*\", \"\\1\");\n\t\t\/* Clean up our mess in the cookie header *\/\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|; ) *X-UA-Device-force=[^;]+;? *\", \"\\1\");\n\t\t\/* If the cookie header is now empty, or just whitespace, unset it. *\/\n\t\tif (req.http.Cookie ~ \"^ *$\") { unset req.http.Cookie; }\n\t} else {\n if (req.http.User-Agent ~ \"\\(compatible; Googlebot-Mobile\/2.1; \\+http:\/\/www.google.com\/bot.html\\)\" ||\n (req.http.User-Agent ~ \"iPhone\" && req.http.User-Agent ~ \"\\(compatible; Googlebot\/2.1; \\+http:\/\/www.google.com\/bot.html\")) {\n set req.http.X-UA-Device = \"mobile-bot\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)(ads|google|bing|msn|yandex|baidu|ro|career|)bot\" ||\n\t\t req.http.User-Agent ~ \"(?i)(baidu|jike|symantec)spider\" ||\n\t\t req.http.User-Agent ~ \"(?i)scanner\" ||\n\t\t req.http.User-Agent ~ \"(?i)(web)crawler\") {\n\t\t\tset req.http.X-UA-Device = \"bot\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ipad\") { set req.http.X-UA-Device = \"tablet-ipad\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ip(hone|od)\") { set req.http.X-UA-Device = \"mobile-iphone\"; }\n\t\t\/* how do we differ between an android phone and an android tablet?\n\t\t http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent *\/\n\t\telsif (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") { set req.http.X-UA-Device = \"mobile-android\"; }\n\t\t\/\/ android 3\/honeycomb was just about tablet-only, and any phones will probably handle a bigger page layout.\n\t\telsif (req.http.User-Agent ~ \"(?i)android 3\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\t\/* Opera Mobile *\/\n\t\telsif (req.http.User-Agent ~ \"Opera Mobi\") { set req.http.X-UA-Device = \"mobile-smartphone\"; }\n\t\t\/\/ May very well give false positives towards android tablets. Suggestions welcome.\n\t\telsif (req.http.User-Agent ~ \"(?i)android\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\telsif (req.http.User-Agent ~ \"PlayBook; U; RIM Tablet\") { set req.http.X-UA-Device = \"tablet-rim\"; }\n\t\telsif (req.http.User-Agent ~ \"hp-tablet.*TouchPad\") { set req.http.X-UA-Device = \"tablet-hp\"; }\n\t\telsif (req.http.User-Agent ~ \"Kindle\/3\") { set req.http.X-UA-Device = \"tablet-kindle\"; }\n\t\telsif (req.http.User-Agent ~ \"Touch.+Tablet PC\" ||\n\t\t req.http.User-Agent ~ \"Windows NT [0-9.]+; [ARM;|WOW64;|Win64; x64]\" ) {\n\t\t set req.http.X-UA-Device = \"tablet-microsoft\";\n\t\t}\n\t\telsif (req.http.User-Agent ~ \"Mobile.+Firefox\") { set req.http.X-UA-Device = \"mobile-firefoxos\"; }\n\t\telsif (req.http.User-Agent ~ \"^HTC\" ||\n\t\t req.http.User-Agent ~ \"Fennec\" ||\n\t\t req.http.User-Agent ~ \"IEMobile\" ||\n\t\t req.http.User-Agent ~ \"BlackBerry\" ||\n\t\t req.http.User-Agent ~ \"BB10.*Mobile\" ||\n\t\t req.http.User-Agent ~ \"GT-.*Build\/GINGERBREAD\" ||\n\t\t req.http.User-Agent ~ \"SymbianOS.*AppleWebKit\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-smartphone\";\n\t\t}\n\t\telsif (req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)^sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)^nokia\" ||\n\t\t req.http.User-Agent ~ \"(?i)^samsung\" ||\n\t\t req.http.User-Agent ~ \"(?i)^lg\" ||\n\t\t req.http.User-Agent ~ \"(?i)bada\" ||\n\t\t req.http.User-Agent ~ \"(?i)blazer\" ||\n\t\t req.http.User-Agent ~ \"(?i)cellphone\" ||\n\t\t req.http.User-Agent ~ \"(?i)iemobile\" ||\n\t\t req.http.User-Agent ~ \"(?i)midp-2.0\" ||\n\t\t req.http.User-Agent ~ \"(?i)u990\" ||\n\t\t req.http.User-Agent ~ \"(?i)netfront\" ||\n\t\t req.http.User-Agent ~ \"(?i)opera mini\" ||\n\t\t req.http.User-Agent ~ \"(?i)palm\" ||\n\t\t req.http.User-Agent ~ \"(?i)nintendo wii\" ||\n\t\t req.http.User-Agent ~ \"(?i)playstation portable\" ||\n\t\t req.http.User-Agent ~ \"(?i)portalmmm\" ||\n\t\t req.http.User-Agent ~ \"(?i)proxinet\" ||\n\t\t req.http.User-Agent ~ \"(?i)sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)windows\\ ?ce\" ||\n\t\t req.http.User-Agent ~ \"(?i)winwap\" ||\n\t\t req.http.User-Agent ~ \"(?i)eudoraweb\" ||\n\t\t req.http.User-Agent ~ \"(?i)htc\" ||\n\t\t req.http.User-Agent ~ \"(?i)240x320\" ||\n\t\t req.http.User-Agent ~ \"(?i)avantgo\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-generic\";\n\t\t}\n\t}\n}\n","old_contents":"# Copyright (c) 2012-2014 Varnish Software AS\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions\n# are met:\n# 1. Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n# 2. Redistributions in binary form must reproduce the above copyright\n# notice, this list of conditions and the following disclaimer in the\n# documentation and\/or other materials provided with the distribution.\n#\n# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n# ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n# SUCH DAMAGE.\n#\n# detectdevice.vcl - regex based device detection for Varnish\n# https:\/\/github.com\/varnish\/varnish-devicedetect\/\n#\n# Author: Lasse Karstensen <lkarsten@varnish-software.com>\n\nsub devicedetect {\n\tunset req.http.X-UA-Device;\n\tset req.http.X-UA-Device = \"pc\";\n\n\t# Handle that a cookie may override the detection alltogether.\n\tif (req.http.Cookie ~ \"(?i)X-UA-Device-force\") {\n\t\t\/* ;?? means zero or one ;, non-greedy to match the first. *\/\n\t\tset req.http.X-UA-Device = regsub(req.http.Cookie, \"(?i).*X-UA-Device-force=([^;]+);??.*\", \"\\1\");\n\t\t\/* Clean up our mess in the cookie header *\/\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|; ) *X-UA-Device-force=[^;]+;? *\", \"\\1\");\n\t\t\/* If the cookie header is now empty, or just whitespace, unset it. *\/\n\t\tif (req.http.Cookie ~ \"^ *$\") { unset req.http.Cookie; }\n\t} else {\n if (req.http.User-Agent ~ \"\\(compatible; Googlebot-Mobile\/2.1; \\+http:\/\/www.google.com\/bot.html\\)\" ||\n (req.http.User-Agent ~ \"iPhone\" && req.http.User-Agent ~ \"\\(compatible; Googlebot\/2.1; \\+http:\/\/www.google.com\/bot.html\")) {\n set req.http.X-UA-Device = \"mobile-bot\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)(ads|google|bing|msn|yandex|baidu|ro|career|)bot\" ||\n\t\t req.http.User-Agent ~ \"(?i)(baidu|jike|symantec)spider\" ||\n\t\t req.http.User-Agent ~ \"(?i)scanner\" ||\n\t\t req.http.User-Agent ~ \"(?i)(web)crawler\") {\n\t\t\tset req.http.X-UA-Device = \"bot\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ipad\") { set req.http.X-UA-Device = \"tablet-ipad\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ip(hone|od)\") { set req.http.X-UA-Device = \"mobile-iphone\"; }\n\t\t\/* how do we differ between an android phone and an android tablet?\n\t\t http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent *\/\n\t\telsif (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") { set req.http.X-UA-Device = \"mobile-android\"; }\n\t\t\/\/ android 3\/honeycomb was just about tablet-only, and any phones will probably handle a bigger page layout.\n\t\telsif (req.http.User-Agent ~ \"(?i)android 3\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\t\/* Opera Mobile *\/\n\t\telsif (req.http.User-Agent ~ \"Opera Mobi\") { set req.http.X-UA-Device = \"mobile-smartphone\"; }\n\t\t\/\/ May very well give false positives towards android tablets. Suggestions welcome.\n\t\telsif (req.http.User-Agent ~ \"(?i)android\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\telsif (req.http.User-Agent ~ \"PlayBook; U; RIM Tablet\") { set req.http.X-UA-Device = \"tablet-rim\"; }\n\t\telsif (req.http.User-Agent ~ \"hp-tablet.*TouchPad\") { set req.http.X-UA-Device = \"tablet-hp\"; }\n\t\telsif (req.http.User-Agent ~ \"Kindle\/3\") { set req.http.X-UA-Device = \"tablet-kindle\"; }\n\t\telsif (req.http.User-Agent ~ \"Touch.+Tablet PC\") { set req.http.X-UA-Device = \"tablet-microsoft\"; }\n\t\telsif (req.http.User-Agent ~ \"Mobile.+Firefox\") { set req.http.X-UA-Device = \"mobile-firefoxos\"; }\n\t\telsif (req.http.User-Agent ~ \"^HTC\" ||\n\t\t req.http.User-Agent ~ \"Fennec\" ||\n\t\t req.http.User-Agent ~ \"IEMobile\" ||\n\t\t req.http.User-Agent ~ \"BlackBerry\" ||\n\t\t req.http.User-Agent ~ \"BB10.*Mobile\" ||\n\t\t req.http.User-Agent ~ \"GT-.*Build\/GINGERBREAD\" ||\n\t\t req.http.User-Agent ~ \"SymbianOS.*AppleWebKit\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-smartphone\";\n\t\t}\n\t\telsif (req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)^sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)^nokia\" ||\n\t\t req.http.User-Agent ~ \"(?i)^samsung\" ||\n\t\t req.http.User-Agent ~ \"(?i)^lg\" ||\n\t\t req.http.User-Agent ~ \"(?i)bada\" ||\n\t\t req.http.User-Agent ~ \"(?i)blazer\" ||\n\t\t req.http.User-Agent ~ \"(?i)cellphone\" ||\n\t\t req.http.User-Agent ~ \"(?i)iemobile\" ||\n\t\t req.http.User-Agent ~ \"(?i)midp-2.0\" ||\n\t\t req.http.User-Agent ~ \"(?i)u990\" ||\n\t\t req.http.User-Agent ~ \"(?i)netfront\" ||\n\t\t req.http.User-Agent ~ \"(?i)opera mini\" ||\n\t\t req.http.User-Agent ~ \"(?i)palm\" ||\n\t\t req.http.User-Agent ~ \"(?i)nintendo wii\" ||\n\t\t req.http.User-Agent ~ \"(?i)playstation portable\" ||\n\t\t req.http.User-Agent ~ \"(?i)portalmmm\" ||\n\t\t req.http.User-Agent ~ \"(?i)proxinet\" ||\n\t\t req.http.User-Agent ~ \"(?i)sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)windows\\ ?ce\" ||\n\t\t req.http.User-Agent ~ \"(?i)winwap\" ||\n\t\t req.http.User-Agent ~ \"(?i)eudoraweb\" ||\n\t\t req.http.User-Agent ~ \"(?i)htc\" ||\n\t\t req.http.User-Agent ~ \"(?i)240x320\" ||\n\t\t req.http.User-Agent ~ \"(?i)avantgo\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-generic\";\n\t\t}\n\t}\n}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"f990ca888acf08a00a86c49c9b6c057dc179399f","subject":"Don't allow clients to force a pass","message":"Don't allow clients to force a pass\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets\/recv.vcl","new_file":"etc\/vcl_snippets\/recv.vcl","new_contents":" # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n # Rewrite \/static\/versionxxxxx URLs. Avoids us having to rewrite on nginx layer\n if (req.url ~ \"^\/static\/version(\\d*\/)?(.*)$\") {\n set req.url = \"\/static\/\" + re.group.2 + \"?\" + re.group.1;\n }\n \n # User's Cookie may contain some Magento Vary items we should vary on\n if (req.http.cookie:X-Magento-Vary ) {\n set req.http.X-Magento-Vary = req.http.cookie:X-Magento-Vary;\n } else {\n unset req.http.X-Magento-Vary;\n }\n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n if (!req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n error 403;\n }\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n\n } else {\n error 403;\n }\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (req.http.Fastly-FF) {\n # disable ESI processing on Origin Shield\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie:X-Magento-Vary || req.http.cookie:form_key) {\n error 200 \"\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url.qs !~ \"country_code=\" ) {\n set req.url = req.url \"?country_code=\" if ( req.http.geo_override, req.http.geo_override, client.geo.country_code);\n }\n }\n } else {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking\n set req.http.Magento-Original-URL = req.url;\n set req.url = querystring.regfilter(req.url, \"^(utm_.*|gclid|gdftrk|_ga|mc_.*)\");\n }\n\n # Don't allow clients to force a pass\n if (req.restarts == 0) {\n unset req.http.x-pass;\n }\n \n # Pass on checkout URLs. Because it's a snippet we want to execute this after backend selection so we handle it\n # in the request condition\n if (req.url ~ \"\/(catalogsearch|checkout)\") {\n set req.http.x-pass = \"1\";\n # Pass all admin actions\n } else if ( req.url ~ \"^\/(index\\.php\/)?admin(_.*)?\/\" ) {\n set req.http.x-pass = \"1\";\n } else {\n # Sort the query arguments to increase cache hit ratio with query arguments that\n # may be out od order\n set req.url = boltsort.sort(req.url);\n }\n\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n","old_contents":" # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n # Rewrite \/static\/versionxxxxx URLs. Avoids us having to rewrite on nginx layer\n if (req.url ~ \"^\/static\/version(\\d*\/)?(.*)$\") {\n set req.url = \"\/static\/\" + re.group.2 + \"?\" + re.group.1;\n }\n \n # User's Cookie may contain some Magento Vary items we should vary on\n if (req.http.cookie:X-Magento-Vary ) {\n set req.http.X-Magento-Vary = req.http.cookie:X-Magento-Vary;\n } else {\n unset req.http.X-Magento-Vary;\n }\n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n if (!req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n error 403;\n }\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n\n } else {\n error 403;\n }\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (req.http.Fastly-FF) {\n # disable ESI processing on Origin Shield\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie:X-Magento-Vary || req.http.cookie:form_key) {\n error 200 \"\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url.qs !~ \"country_code=\" ) {\n set req.url = req.url \"?country_code=\" if ( req.http.geo_override, req.http.geo_override, client.geo.country_code);\n }\n }\n } else {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking\n set req.http.Magento-Original-URL = req.url;\n set req.url = querystring.regfilter(req.url, \"^(utm_.*|gclid|gdftrk|_ga|mc_.*)\");\n }\n \n # Pass on checkout URLs. Because it's a snippet we want to execute this after backend selection so we handle it\n # in the request condition\n if (req.url ~ \"\/(catalogsearch|checkout)\") {\n set req.http.x-pass = \"1\";\n # Pass all admin actions\n } else if ( req.url ~ \"^\/(index\\.php\/)?admin(_.*)?\/\" ) {\n set req.http.x-pass = \"1\";\n } else {\n # Sort the query arguments to increase cache hit ratio with query arguments that\n # may be out od order\n set req.url = boltsort.sort(req.url);\n }\n\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"facbd86da095bd845eb2cb9a8b117d5c4ddcc0e4","subject":"Add Fastly-Page-Cacheable headers to expose whether a specific page is cacheable regardless of cache control headers","message":"Add Fastly-Page-Cacheable headers to expose whether a specific page is cacheable regardless of cache control headers\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets\/deliver.vcl","new_file":"etc\/vcl_snippets\/deliver.vcl","new_contents":" if (resp.status >= 500 && resp.status < 600) {\n \/* restart if the stale object is available *\/\n if (stale.exists) {\n restart;\n }\n }\n\n # Send no cache headers to end users for non-static content. Also make sure\n # we only set this on the edge nodes and not on shields\n if (req.url !~ \"^\/(pub\/)?(media|static)\/.*\" && !req.http.Fastly-FF ) {\n set resp.http.Pragma = \"no-cache\";\n set resp.http.Cache-Control = \"no-store, no-cache, must-revalidate, max-age=0\";\n }\n\n # Remove X-Magento-Vary and HTTPs Vary served to the user\n if ( !req.http.Fastly-FF ) {\n set resp.http.Vary = regsub(resp.http.Vary, \"X-Magento-Vary,Https\", \"Cookie\");\n }\n\n # Add an easy way to see whether custom Fastly VCL has been uploaded\n if ( req.http.Fastly-Debug ) {\n set resp.http.Fastly-Magento-VCL-Uploaded = \"1.2.24\";\n } else {\n remove resp.http.Fastly-Module-Enabled;\n remove resp.http.fastly-page-cacheable;\n }\n # debug info\n if (resp.http.X-Magento-Debug) {\n if (obj.hits > 0) {\n set resp.http.X-Magento-Cache-Debug = \"HIT\";\n set resp.http.X-Magento-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Magento-Cache-Debug = \"MISS\";\n }\n } else {\n # remove Varnish\/proxy header\n remove resp.http.Age;\n remove resp.http.X-Magento-Debug;\n remove resp.http.X-Magento-Tags;\n remove resp.http.X-Magento-Cache-Control;\n remove resp.http.X-Powered-By;\n remove resp.http.Server;\n remove resp.http.X-Varnish;\n remove resp.http.Via;\n remove resp.http.X-Purge-URL;\n remove resp.http.X-Purge-Host;\n }\n","old_contents":" if (resp.status >= 500 && resp.status < 600) {\n \/* restart if the stale object is available *\/\n if (stale.exists) {\n restart;\n }\n }\n\n # Send no cache headers to end users for non-static content. Also make sure\n # we only set this on the edge nodes and not on shields\n if (req.url !~ \"^\/(pub\/)?(media|static)\/.*\" && !req.http.Fastly-FF ) {\n set resp.http.Pragma = \"no-cache\";\n set resp.http.Cache-Control = \"no-store, no-cache, must-revalidate, max-age=0\";\n }\n\n # Remove X-Magento-Vary and HTTPs Vary served to the user\n if ( !req.http.Fastly-FF ) {\n set resp.http.Vary = regsub(resp.http.Vary, \"X-Magento-Vary,Https\", \"Cookie\");\n }\n\n # Add an easy way to see whether custom Fastly VCL has been uploaded\n if ( req.http.Fastly-Debug ) {\n set resp.http.Fastly-Magento-VCL-Uploaded = \"1.2.24\";\n } else {\n remove resp.http.Fastly-Module-Enabled;\n }\n # debug info\n if (resp.http.X-Magento-Debug) {\n if (obj.hits > 0) {\n set resp.http.X-Magento-Cache-Debug = \"HIT\";\n set resp.http.X-Magento-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Magento-Cache-Debug = \"MISS\";\n }\n } else {\n # remove Varnish\/proxy header\n remove resp.http.Age;\n remove resp.http.X-Magento-Debug;\n remove resp.http.X-Magento-Tags;\n remove resp.http.X-Magento-Cache-Control;\n remove resp.http.X-Powered-By;\n remove resp.http.Server;\n remove resp.http.X-Varnish;\n remove resp.http.Via;\n remove resp.http.X-Purge-URL;\n remove resp.http.X-Purge-Host;\n }","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"d75759a37f59cdeeecb36ef40c782519d2d6554f","subject":"Updated backend.vcl to include better documentation and valid VCL syntax.","message":"Updated backend.vcl to include better documentation and valid VCL syntax.\n","repos":"gurumitts\/Elasticd,gurumitts\/Elasticd,bryantrobbins\/Elasticd,FINRAOS\/Elasticd,bryantrobbins\/Elasticd,SMxJrz\/Elasticd,FINRAOS\/Elasticd,mchao47\/Elasticd,mchao47\/Elasticd,SMxJrz\/Elasticd","old_file":"templates\/backend.vcl","new_file":"templates\/backend.vcl","new_contents":"{#\nDefault VCL for web configs.\n\nExpected Result:\n backend web1 {\n .host = \"10.0.0.1\"\n .port = \"80\"\n }\n backend web2 {\n .host = \"10.0.0.1\"\n .port = \"80\"\n }\n ...\n\nAvailable Variables:\n (array) resources containing one or more (Resource) resource.\n Resource class and it's descendants will always implement __str__ to make it easier to use here.\n#}\n\n\n{% for ipresource in resources %}\n backend web{{ loop.index0 }} {\n .host = \"{{ ipresource }}\";\n .port = \"80\";\n }\n{% endfor %}\n","old_contents":"{% for ip in resources %}\n web loop.index0 {\n host:{{ ip }}\n }\n{% endfor %}\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"f1674fea5b4a2a1d1a31d7b07b03c5252efa0389","subject":"Update advanced_mobile recipe's varnish cache config","message":"Update advanced_mobile recipe's varnish cache config\n","repos":"moovweb\/tritium,moovweb\/tritium,moovweb\/tritium,moovweb\/tritium,moovweb\/tritium","old_file":"ambrosia\/external\/omni-mobile\/recipes\/advanced_mobile\/config\/cache.vcl","new_file":"ambrosia\/external\/omni-mobile\/recipes\/advanced_mobile\/config\/cache.vcl","new_contents":"\n\/*\n * Default Cache.vcl\n *\n * By default, any responses with Cache-Control set correctly are cached.\n *\n * If you don't want to cache anything, you need to update vcl_fetch and\n * comment out some lines so return(pass) is always called.\n *\n * If you do want to cache with more granularity, read up on Varnish \n * configurations and modify this file CAREFULLY.\n *\/\n\nsub vcl_fetch {\n \/*\n * Default Varnish logic EXCEPT:\n * (1) Responses with a set-cookie header can still make their way\n * into the cache. But I remove the set-cookie header in those instances.\n * (2) Instead of using 'beresp.cacheable' to determine cacheability,\n * I am checking for Cache-Control public\n *\/\n\n \/\/ Copy the X-Mob-Type type from the request header into the response header\n set beresp.http.X-Mob-Type = req.http.X-Mob-Type;\n\n \/\/ This caches any response w max-age in the Cache-Control header\n \/\/ for the duration specified in the header. We expect assets to have these headers set.\n \/\/ Comment out the 4 lines below if you don't want to cache anything\n if (beresp.http.Cache-Control ~ \"(public|max\\-age)\") {\n remove beresp.http.Set-Cookie;\n return (deliver);\n }\n\n return (pass);\n}\n\nsub vcl_recv {\n set req.backend = application_director;\n \n \/*\n * Default Varnish Caching logic with four exceptions:\n * (1) requests with cookies are cacheable\n * (2) X-Forwarded-For is only set when the client ip is not 127.0.0.1\n * (3) X-Moov-Secure requests are not cacheable\n * (4) Set the QA backend server to <customer>_appv01 which has a fixed IP\n * (5) Set the X-Mob-Type header based on user agent\n * (6) requests for assets are cacheable \n *\/\n \n \/\/ Cache all assets\n if (req.url ~ \"\\.(png|gif|jpeg|jpg|ico|swf|css|js)(\\?[a-z0-9%&]+)?$\") {\n unset req.http.Cookie;\n } \n if (req.http.Content-Type ~ \"png|gif|jpeg|jpg|ico|swf|css|javascript\") {\n unset req.http.Cookie;\n } \n \n \n \/\/ Set the X-Mob-Type based on the user agent\n set req.http.X-Mob-Type = \"1\";\n\n \/\/ Use the following lines to vary the cache for any user agents that will be\n \/\/ served different content; here's an example for blackberry\n \/*\n if (req.http.User-Agent ~ \"BlackBerry[0-9]{4}\\\/(4\\.6|4\\.7|4\\.8|5\\.)\") {\n set req.http.X-Mob-Type = \"2\";\n }\n *\/\n\n if (req.http.host ~ \"^mstage\") {\n set req.backend = {{#GOPERIOD#ProjectName}}_appv01;\n set req.http.X-QA = \"true\";\n }\n\n if (client.ip != \"127.0.0.1\") {\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For =\n req.http.X-Forwarded-For \", \" client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n \n if (req.request != \"GET\" && req.request != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n \n if (req.http.x-moov-secure) {\n \/* This request originated as an HTTPS request: not cacheable *\/\n return (pass);\n }\n if (req.http.Authorization) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n\n return (lookup);\n}\n\nsub vcl_hash {\n \/*\n * Start default.vcl\n * Copied from default config so we can use the default hash and add the\n * X-Mob-Type to it.\n *\/\n set req.hash += req.url;\n if (req.http.host) {\n set req.hash += req.http.host;\n } else {\n set req.hash += server.ip;\n }\n \/*\n * End default.vcl\n *\/\n\n \/\/ Add the X-Mob-Type to the hash value\n set req.hash += req.http.X-Mob-Type;\n\n \/\/ Return the custom hash value to Varnish\n return (hash);\n}\n\n\/*\n * Error page to be presented should there be a problem in the cache\n *\/\nsub vcl_error {\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n synthetic{\"\n <!DOCTYPE html PUBLIC '-\/\/W3C\/\/DTD XHTML 1.0 Transitional\/\/EN' 'http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-transitional.dtd'>\n <html>\n <head>\n <title>Something went wrong<\/title>\n <\/head>\n <body>\n <style>body {background-color: #eee;} div {padding:10px;} #coming-soon {font-size: 30px;} #explanation {font-size: 15px;}<\/style><div id='coming-soon'>Looks like something went wrong here!<\/div><div id='explanation'>We're currently experiencing a technical issue. Please try to refresh the page or visit us on our <a href='www.{{#GOPERIOD#Domain}}' desktop site<\/a>. We apologize for the inconvenience.<\/div>\n <\/body>\n <\/html>\n \"};\n return (deliver);\n}\n","old_contents":"\n\/*\n * Default Cache.vcl\n *\n * If you don't want to cache anything, you are all set.\n * If you do want to cache some things, you will have to modify this file.\n * As a starting point you can simply remove the first 'return (pass);' line from \n * 'vcl_fetch'. This will enable some reasonable caching rules.\n *\/\nsub vcl_fetch {\n \/*\n * Default Varnish logic EXCEPT:\n * (1) Responses with a set-cookie header can still make their way\n * into the cache. But I remove the set-cookie header in those instances.\n * (2) Instead of using 'beresp.cacheable' to determine cacheability,\n * I am checking for Cache-Control public\n *\/\n\n \/\/ Copy the X-Mob-Type type from the request header into the response header\n set beresp.http.X-Mob-Type = req.http.X-Mob-Type;\n\n if (beresp.http.Cache-Control ~ \"public\") {\n remove beresp.http.Set-Cookie;\n return (deliver);\n }\n\n return (pass);\n}\n\nsub vcl_recv {\n set req.backend = application_director;\n \n \/*\n * Default Varnish Caching logic with four exceptions:\n * (1) requests with cookies are cacheable\n * (2) X-Forwarded-For is only set when the client ip is not 127.0.0.1\n * (3) X-Moov-Secure requests are not cacheable\n * (4) Set the QA backend server to <customer>_appv01 which has a fixed IP\n * (5) Set the X-Mob-Type header based on user agent\n * (6) requests for assets are cacheable \n *\/\n \n \/\/ Cache all assets\n if (req.url ~ \"\\.(png|gif|jpeg|jpg|ico|swf|css|js)(\\?[a-z0-9%&]+)?$\") {\n unset req.http.Cookie;\n } \n if (req.http.Content-Type ~ \"png|gif|jpeg|jpg|ico|swf|css|javascript\") {\n unset req.http.Cookie;\n } \n \n \n \/\/ Set the X-Mob-Type based on the user agent\n set req.http.X-Mob-Type = \"1\";\n\n \/\/ Use the following lines to vary the cache for any user agents that will be\n \/\/ served different content; here's an example for blackberry\n \/*\n if (req.http.User-Agent ~ \"BlackBerry[0-9]{4}\\\/(4\\.6|4\\.7|4\\.8|5\\.)\") {\n set req.http.X-Mob-Type = \"2\";\n }\n *\/\n\n if (req.http.host ~ \"^mstage\") {\n set req.backend = {{#GOPERIOD#ProjectName}}_appv01;\n set req.http.X-QA = \"true\";\n }\n\n if (client.ip != \"127.0.0.1\") {\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For =\n req.http.X-Forwarded-For \", \" client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n \n if (req.request != \"GET\" && req.request != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n \n if (req.http.x-moov-secure) {\n \/* This request originated as an HTTPS request: not cacheable *\/\n return (pass);\n }\n if (req.http.Authorization) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n\n return (lookup);\n}\n\nsub vcl_hash {\n \/*\n * Start default.vcl\n * Copied from default config so we can use the default hash and add the\n * X-Mob-Type to it.\n *\/\n set req.hash += req.url;\n if (req.http.host) {\n set req.hash += req.http.host;\n } else {\n set req.hash += server.ip;\n }\n \/*\n * End default.vcl\n *\/\n\n \/\/ Add the X-Mob-Type to the hash value\n set req.hash += req.http.X-Mob-Type;\n\n \/\/ Return the custom hash value to Varnish\n return (hash);\n}\n\n\/*\n * Error page to be presented should there be a problem in the cache\n *\/\nsub vcl_error {\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n synthetic{\"\n <!DOCTYPE html PUBLIC '-\/\/W3C\/\/DTD XHTML 1.0 Transitional\/\/EN' 'http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-transitional.dtd'>\n <html>\n <head>\n <title>Something went wrong<\/title>\n <\/head>\n <body>\n <style>body {background-color: #eee;} div {padding:10px;} #coming-soon {font-size: 30px;} #explanation {font-size: 15px;}<\/style><div id='coming-soon'>Looks like something went wrong here!<\/div><div id='explanation'>We're currently experiencing a technical issue. Please try to refresh the page or visit us on our <a href='www.{{#GOPERIOD#Domain}}' desktop site<\/a>. We apologize for the inconvenience.<\/div>\n <\/body>\n <\/html>\n \"};\n return (deliver);\n}\n","returncode":0,"stderr":"","license":"mpl-2.0","lang":"VCL"} {"commit":"bf31df46f2e34374ad21bf6e048b56b30c0bf299","subject":"Perform legacy redirect at Fastly.","message":"Perform legacy redirect at Fastly.\n","repos":"mcshaz\/polyfill-service,kdzwinel\/polyfill-service,jonathan-fielding\/polyfill-service,JakeChampion\/polyfill-service,jonathan-fielding\/polyfill-service,jonathan-fielding\/polyfill-service,mcshaz\/polyfill-service,mcshaz\/polyfill-service,kdzwinel\/polyfill-service,JakeChampion\/polyfill-service,kdzwinel\/polyfill-service","old_file":"fastly-config.vcl","new_file":"fastly-config.vcl","new_contents":"sub vcl_recv {\n#FASTLY recv\n\n\tif (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n\t return(pass);\n\t}\n\n\t# Redirect legacy service users to legacy service\n\tset req.http.X-Referer-Host = regsub(req.http.Referer, \"^https?\\:\\\/\\\/([^\\\/]+)(\\\/.*)?$\", \"\\1\");\n\tif (req.url == \"\/normalize.js\" ||\n\t\treq.url == \"\/normalize.css\" ||\n\t\treq.url == \"\/normalise.js\" ||\n\t\treq.url == \"\/normalise.css\" ||\n\t\treq.http.X-Referer-Host == \"www.manrepeller.com\" ||\n\t\treq.http.X-Referer-Host == \"www.mulesoft.com\" ||\n\t\treq.http.X-Referer-Host == \"iluoghidelcuore.it\" ||\n\t\treq.http.X-Referer-Host == \"it.donga.com\" ||\n\t\treq.http.X-Referer-Host == \"www.watchguard.com\" ||\n\t\treq.http.X-Referer-Host == \"www.mulesoft.org\" ||\n\t\treq.http.X-Referer-Host == \"asmwall.com\" ||\n\t\treq.http.X-Referer-Host == \"www.jcsu.edu\" ||\n\t\treq.http.X-Referer-Host == \"adscendmedia.com\" ||\n\t\treq.http.X-Referer-Host == \"game.donga.com\" ||\n\t\treq.http.X-Referer-Host == \"framkino.no\" ||\n\t\treq.http.X-Referer-Host == \"www.accesswireless.com\" ||\n\t\treq.http.X-Referer-Host == \"represent.com\" ||\n\t\treq.http.X-Referer-Host == \"www.designergreek.com\" ||\n\t\treq.http.X-Referer-Host == \"www.plumbingoverstock.com\" ||\n\t\treq.http.X-Referer-Host == \"servicos.searh.rn.gov.br\" ||\n\t\treq.http.X-Referer-Host == \"www.jane-usa.com\" ||\n\t\treq.http.X-Referer-Host == \"www.juntaempresa.com.br\" ||\n\t\treq.http.X-Referer-Host == \"watchguard.com\" ||\n\t\treq.http.X-Referer-Host == \"www.logianalytics.com\" ||\n\t\treq.http.X-Referer-Host == \"www.thebathpoint.com\" ||\n\t\treq.http.X-Referer-Host == \"blogs.mulesoft.org\" ||\n\t\treq.http.X-Referer-Host == \"www.purecanadiangaming.com\" ||\n\t\treq.http.X-Referer-Host == \"play.egzaminatorius.lt\" ||\n\t\treq.http.X-Referer-Host == \"internetacademi.com\" ||\n\t\treq.http.X-Referer-Host == \"www.skyhighnetworks.com\" ||\n\t\treq.http.X-Referer-Host == \"interactive.guim.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"www.soloio.com\" ||\n\t\treq.http.X-Referer-Host == \"desenvolvimentoparaweb.com\" ||\n\t\treq.http.X-Referer-Host == \"daily-fantasy.trunk.development.manhattan.gq1.yahoo.com\" ||\n\t\treq.http.X-Referer-Host == \"blog.damyller.com.br\" ||\n\t\treq.http.X-Referer-Host == \"doggiebag.no\" ||\n\t\treq.http.X-Referer-Host == \"www.beverlydiamonds.com\" ||\n\t\treq.http.X-Referer-Host == \"www.rogerscup.com\" ||\n\t\treq.http.X-Referer-Host == \"blog.hudy.cz\" ||\n\t\treq.http.X-Referer-Host == \"techhamlet.com\" ||\n\t\treq.http.X-Referer-Host == \"www.flirtfachmann.de\" ||\n\t\treq.http.X-Referer-Host == \"alpacacomics.com\" ||\n\t\treq.http.X-Referer-Host == \"areariservata.fondoprevidenzafinanze.it\" ||\n\t\treq.http.X-Referer-Host == \"www.framkino.no\" ||\n\t\treq.http.X-Referer-Host == \"www.nationalsecurities.com\" ||\n\t\treq.http.X-Referer-Host == \"www.tenniscanada.com\" ||\n\t\treq.http.X-Referer-Host == \"libek.org.rs\" ||\n\t\treq.http.X-Referer-Host == \"learn.logianalytics.com\" ||\n\t\treq.http.X-Referer-Host == \"www.impartner.lt\" ||\n\t\treq.http.X-Referer-Host == \"chameleon.biworldwide.com\" ||\n\t\treq.http.X-Referer-Host == \"www.pujckapowebu.cz\" ||\n\t\treq.http.X-Referer-Host == \"www.dlcnetwork.com\" ||\n\t\treq.http.X-Referer-Host == \"www.forbes.com\" ||\n\t\treq.http.X-Referer-Host == \"blog.skyhighnetworks.com\" ||\n\t\treq.http.X-Referer-Host == \"rflx.bjornborg.com\" ||\n\t\treq.http.X-Referer-Host == \"www.coach-outlet-store.com\" ||\n\t\treq.http.X-Referer-Host == \"gist.io\" ||\n\t\treq.http.X-Referer-Host == \"www.suicideispreventable.org\" ||\n\t\treq.http.X-Referer-Host == \"www.rangemastertacticalgear.com\" ||\n\t\treq.http.X-Referer-Host == \"www.hcpozicka.sk\" ||\n\t\treq.http.X-Referer-Host == \"www.airsoftmegastore.com\" ||\n\t\treq.http.X-Referer-Host == \"colortile.github.io\" ||\n\t\treq.http.X-Referer-Host == \"brasstacksmadras.com\" ||\n\t\treq.http.X-Referer-Host == \"hotelcasadomingo.com.mx\" ||\n\t\treq.http.X-Referer-Host == \"client.local\" ||\n\t\treq.http.X-Referer-Host == \"www.worcesterpromotions.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"www.asmwall.com\" ||\n\t\treq.http.X-Referer-Host == \"training.mulesoft.com\" ||\n\t\treq.http.X-Referer-Host == \"localhost\" ||\n\t\treq.http.X-Referer-Host == \"exhilarateme.com\" ||\n\t\treq.http.X-Referer-Host == \"www.kommentatorskampen.viasatsport.se\" ||\n\t\treq.http.X-Referer-Host == \"www.golfgearselect.com\" ||\n\t\treq.http.X-Referer-Host == \"www.hcpujcka.cz\" ||\n\t\treq.http.X-Referer-Host == \"www.industriallawsociety.org.uk\" ||\n\t\treq.http.X-Referer-Host == \"www.locawebcorp.com.br\" ||\n\t\treq.http.X-Referer-Host == \"giffffr.giphy.com\" ||\n\t\treq.http.X-Referer-Host == \"mccall.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"kommentatorskampen.viasatsport.se\" ||\n\t\treq.http.X-Referer-Host == \"bpharm.localhost\" ||\n\t\treq.http.X-Referer-Host == \"miraclebodyandpaint.com\" ||\n\t\treq.http.X-Referer-Host == \"www.tymprozdravi.cz\" ||\n\t\treq.http.X-Referer-Host == \"delicius.it\" ||\n\t\treq.http.X-Referer-Host == \"www.bluehighwaygames.com\" ||\n\t\treq.http.X-Referer-Host == \"tales-of-pikohan.de\" ||\n\t\treq.http.X-Referer-Host == \"demo.restoreadytest.com\" ||\n\t\treq.http.X-Referer-Host == \"mark.stratmann.me\" ||\n\t\treq.http.X-Referer-Host == \"apixtechnology.com\" ||\n\t\treq.http.X-Referer-Host == \"www.telefonickapozicka.sk\" ||\n\t\treq.http.X-Referer-Host == \"www.telefonnipujcka.cz\" ||\n\t\treq.http.X-Referer-Host == \"www.iteo.no\" ||\n\t\treq.http.X-Referer-Host == \"www.diktate.info\" ||\n\t\treq.http.X-Referer-Host == \"bpharm.192.168.56.102.xip.io\" ||\n\t\treq.http.X-Referer-Host == \"www.artisanprecast.com\" ||\n\t\treq.http.X-Referer-Host == \"tcisolutions.com\" ||\n\t\treq.http.X-Referer-Host == \"icelebrate.icehotel.com\" ||\n\t\treq.http.X-Referer-Host == \"www.thirtysevenwest.com\" ||\n\t\treq.http.X-Referer-Host == \"www.asgllc.com\" ||\n\t\treq.http.X-Referer-Host == \"www.mailinbox.net\" ||\n\t\treq.http.X-Referer-Host == \"rustyfelty.com\" ||\n\t\treq.http.X-Referer-Host == \"pulse.p2c.com\" ||\n\t\treq.http.X-Referer-Host == \"www.framkino.com\" ||\n\t\treq.http.X-Referer-Host == \"armourselfstorage.com\" ||\n\t\treq.http.X-Referer-Host == \"www.dezrezblog.com\" ||\n\t\treq.http.X-Referer-Host == \"goodpeople.com\" ||\n\t\treq.http.X-Referer-Host == \"survey-project.localhost\" ||\n\t\treq.http.X-Referer-Host == \"www.eden-houlgate.com\" ||\n\t\treq.http.X-Referer-Host == \"www.patiovirtual.com.br\" ||\n\t\treq.http.X-Referer-Host == \"stats.egzaminatorius.lt\" ||\n\t\treq.http.X-Referer-Host == \"www.movieville.org\" ||\n\t\treq.http.X-Referer-Host == \"secure.watchguard.com\" ||\n\t\treq.http.X-Referer-Host == \"nationalsecurities.com\" ||\n\t\treq.http.X-Referer-Host == \"timepad.localhost\" ||\n\t\treq.http.X-Referer-Host == \"www.snaponindustrial.eu\" ||\n\t\treq.http.X-Referer-Host == \"www.fangear.com\" ||\n\t\treq.http.X-Referer-Host == \"www.scribbleshop.com\" ||\n\t\treq.http.X-Referer-Host == \"forums.mulesoft.org\" ||\n\t\treq.http.X-Referer-Host == \"dataentries.in\" ||\n\t\treq.http.X-Referer-Host == \"maki.alconost.com\" ||\n\t\treq.http.X-Referer-Host == \"dixso.github.io\" ||\n\t\treq.http.X-Referer-Host == \"citaprevia.volkswagen.es\" ||\n\t\treq.http.X-Referer-Host == \"movieville.org\" ||\n\t\treq.http.X-Referer-Host == \"www.seoestudios.com\" ||\n\t\treq.http.X-Referer-Host == \"tickets.campo.nu\" ||\n\t\treq.http.X-Referer-Host == \"perriehale.toucan\" ||\n\t\treq.http.X-Referer-Host == \"online.printstation.cz\" ||\n\t\treq.http.X-Referer-Host == \"www.le-bistrot-basque.com\" ||\n\t\treq.http.X-Referer-Host == \"www.thaiartofmassage.com\" ||\n\t\treq.http.X-Referer-Host == \"www.seevolution.com\" ||\n\t\treq.http.X-Referer-Host == \"janeusa.david\" ||\n\t\treq.http.X-Referer-Host == \"www.goodpeople.com\" ||\n\t\treq.http.X-Referer-Host == \"feeds.feedburner.com\" ||\n\t\treq.http.X-Referer-Host == \"www.millwardesque.com\" ||\n\t\treq.http.X-Referer-Host == \"cci.smartucs.a\" ||\n\t\treq.http.X-Referer-Host == \"forum.tales-of-pikohan.de\" ||\n\t\treq.http.X-Referer-Host == \"small.mu\" ||\n\t\treq.http.X-Referer-Host == \"crisp.toucan\" ||\n\t\treq.http.X-Referer-Host == \"www.fosterdenovo.local\" ||\n\t\treq.http.X-Referer-Host == \"dev1776.nationalsecurities.com\" ||\n\t\treq.http.X-Referer-Host == \"byose.net\" ||\n\t\treq.http.X-Referer-Host == \"www.eurodiary.ie\" ||\n\t\treq.http.X-Referer-Host == \"lemouvementassociatif.org\" ||\n\t\treq.http.X-Referer-Host == \"www.ey.com\" ||\n\t\treq.http.X-Referer-Host == \"cuterunslive.com\" ||\n\t\treq.http.X-Referer-Host == \"taxes-in-serbia.localhost\" ||\n\t\treq.http.X-Referer-Host == \"blog.odynia.org\" ||\n\t\treq.http.X-Referer-Host == \"solarenaymar.com.ar\" ||\n\t\treq.http.X-Referer-Host == \"www.aispaitalia.it\" ||\n\t\treq.http.X-Referer-Host == \"www.startupsaturday.it\" ||\n\t\treq.http.X-Referer-Host == \"support.watchguard.com\" ||\n\t\treq.http.X-Referer-Host == \"dax.absolnet.se\" ||\n\t\treq.http.X-Referer-Host == \"www.creativeinnovation.net.au\" ||\n\t\treq.http.X-Referer-Host == \"dev.raird.no\" ||\n\t\treq.http.X-Referer-Host == \"lesjeteursdencre.fr\" ||\n\t\treq.http.X-Referer-Host == \"itnotes.pl\" ||\n\t\treq.http.X-Referer-Host == \"www.thesocietyinternational.com\" ||\n\t\treq.http.X-Referer-Host == \"terminalfx.com\" ||\n\t\treq.http.X-Referer-Host == \"draft.sx\" ||\n\t\treq.http.X-Referer-Host == \"atelier-florent.fr\" ||\n\t\treq.http.X-Referer-Host == \"www.buona-tavola-ristorante.fr\" ||\n\t\treq.http.X-Referer-Host == \"www.terminalfx.com\" ||\n\t\treq.http.X-Referer-Host == \"www.taxattorney.com\" ||\n\t\treq.http.X-Referer-Host == \"proenter.dev\" ||\n\t\treq.http.X-Referer-Host == \"bodelo-advocaten.be\" ||\n\t\treq.http.X-Referer-Host == \"www.football1asia.com\" ||\n\t\treq.http.X-Referer-Host == \"rets.ly\" ||\n\t\treq.http.X-Referer-Host == \"erriol.com\" ||\n\t\treq.http.X-Referer-Host == \"shssandiego.com\" ||\n\t\treq.http.X-Referer-Host == \"notecrow.appspot.com\" ||\n\t\treq.http.X-Referer-Host == \"framkino.com\" ||\n\t\treq.http.X-Referer-Host == \"sexsite.daan\" ||\n\t\treq.http.X-Referer-Host == \"sro.dk\" ||\n\t\treq.http.X-Referer-Host == \"www.coloft.com\" ||\n\t\treq.http.X-Referer-Host == \"taxiplus.vsystem.hu\" ||\n\t\treq.http.X-Referer-Host == \"stage.mulesoft.com\" ||\n\t\treq.http.X-Referer-Host == \"local.dev.ugameplan.com\" ||\n\t\treq.http.X-Referer-Host == \"posh-nosh.com\" ||\n\t\treq.http.X-Referer-Host == \"phongthuyshop.vn\" ||\n\t\treq.http.X-Referer-Host == \"local.mansionhouse.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"www.compareaccounting.com\" ||\n\t\treq.http.X-Referer-Host == \"news.coinometrics.com\" ||\n\t\treq.http.X-Referer-Host == \"prod-yann.mailinbox.net\" ||\n\t\treq.http.X-Referer-Host == \"rachelree.se\" ||\n\t\treq.http.X-Referer-Host == \"dev1.accesswireless.usdigitalpartners.net\" ||\n\t\treq.http.X-Referer-Host == \"www.ewirisk.com\" ||\n\t\treq.http.X-Referer-Host == \"snapchan.com\" ||\n\t\treq.http.X-Referer-Host == \"www.trikatasieraakademija.lv\" ||\n\t\treq.http.X-Referer-Host == \"www.fosteringadoptionswindon.org.uk\" ||\n\t\treq.http.X-Referer-Host == \"patiovirtual.com.br\" ||\n\t\treq.http.X-Referer-Host == \"www.libmanpro.com\" ||\n\t\treq.http.X-Referer-Host == \"www.diktate.dev\" ||\n\t\treq.http.X-Referer-Host == \"idisco.pianetaitalia.intra\" ||\n\t\treq.http.X-Referer-Host == \"strudelfolhadinho.com.br\" ||\n\t\treq.http.X-Referer-Host == \"www.cunesoft.com\" ||\n\t\treq.http.X-Referer-Host == \"www.shropshirefoundation.org\" ||\n\t\treq.http.X-Referer-Host == \"speakingofbeauty.tv\" ||\n\t\treq.http.X-Referer-Host == \"www.sbs.com.au\" ||\n\t\treq.http.X-Referer-Host == \"bosch.pikmahosting.de\" ||\n\t\treq.http.X-Referer-Host == \"janeusa.lol\" ||\n\t\treq.http.X-Referer-Host == \"eso.toucan\" ||\n\t\treq.http.X-Referer-Host == \"www.lamedicis.com\" ||\n\t\treq.http.X-Referer-Host == \"cereseurope.com\" ||\n\t\treq.http.X-Referer-Host == \"www.pizza-moltobene.fr\" ||\n\t\treq.http.X-Referer-Host == \"www.kaptiva.com.br\" ||\n\t\treq.http.X-Referer-Host == \"flixified.com\" ||\n\t\treq.http.X-Referer-Host == \"www.12roundsboxing.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"www.tensionautomation.com\" ||\n\t\treq.http.X-Referer-Host == \"www.copyprint.nl\" ||\n\t\treq.http.X-Referer-Host == \"unisol\" ||\n\t\treq.http.X-Referer-Host == \"timepad.ews.co.rs\" ||\n\t\treq.http.X-Referer-Host == \"dev.rets.ly\" ||\n\t\treq.http.X-Referer-Host == \"www.vrhabilis.com\" ||\n\t\treq.http.X-Referer-Host == \"trondheggelund.no\" ||\n\t\treq.http.X-Referer-Host == \"www.ferienwohnungen-lebenswert.de\" ||\n\t\treq.http.X-Referer-Host == \"blog.mainline.com\" ||\n\t\treq.http.X-Referer-Host == \"arcstonepartners.com\" ||\n\t\treq.http.X-Referer-Host == \"dev-mj\" ||\n\t\treq.http.X-Referer-Host == \"www.crisp-cpd.com\" ||\n\t\treq.http.X-Referer-Host == \"purecanadiangaming.com\" ||\n\t\treq.http.X-Referer-Host == \"mainline.com\" ||\n\t\treq.http.X-Referer-Host == \"idx.dev.rets.ly\" ||\n\t\treq.http.X-Referer-Host == \"eneco.flicker.visualwind.com\" ||\n\t\treq.http.X-Referer-Host == \"mi.etoilemedia.it\" ||\n\t\treq.http.X-Referer-Host == \"www.atmosphericwatergenerator.net\" ||\n\t\treq.http.X-Referer-Host == \"www.gasnaturalenergyclass.com\" ||\n\t\treq.http.X-Referer-Host == \"salesmarketing.championpetfoods.com\" ||\n\t\treq.http.X-Referer-Host == \"www.watchgaurd.com\" ||\n\t\treq.http.X-Referer-Host == \"vm-sqlext-svil\" ||\n\t\treq.http.X-Referer-Host == \"dev.accesswireless.usdigitalpartners.net\" ||\n\t\treq.http.X-Referer-Host == \"kommentatorskampen.ohmytest.se\" ||\n\t\treq.http.X-Referer-Host == \"m.euvivoesporte.com.br\" ||\n\t\treq.http.X-Referer-Host == \"blog.dasroot.net\" ||\n\t\treq.http.X-Referer-Host == \"bugsdashboard.com\" ||\n\t\treq.http.X-Referer-Host == \"www.eurodiary.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"seecanadabetter-app.appspot.com\" ||\n\t\treq.http.X-Referer-Host == \"www.bobbychanblog.com\" ||\n\t\treq.http.X-Referer-Host == \"www.mybenefitsatwork.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"www.fotolotos.lt\" ||\n\t\treq.http.X-Referer-Host == \"robferguson.org\" ||\n\t\treq.http.X-Referer-Host == \"staging.motherapp.com\" ||\n\t\treq.http.X-Referer-Host == \"www.undergroundminingequipmentcompaniescalgaryquotes.com\" ||\n\t\treq.http.X-Referer-Host == \"idisco.pianetaitalia.com\" ||\n\t\treq.http.X-Referer-Host == \"cliocalman.com\" ||\n\t\treq.http.X-Referer-Host == \"sexymirror-app.com\" ||\n\t\treq.http.X-Referer-Host == \"taxes-in-serbia.192.168.56.102.xip.io\" ||\n\t\treq.http.X-Referer-Host == \"wunderbiz.com\" ||\n\t\treq.http.X-Referer-Host == \"thebathpoint.webdemo.es\" ||\n\t\treq.http.X-Referer-Host == \"www.restaurant-lemenhir.com\" ||\n\t\treq.http.X-Referer-Host == \"www.valdeure.fr\" ||\n\t\treq.http.X-Referer-Host == \"bpharm.ews.co.rs\" ||\n\t\treq.http.X-Referer-Host == \"teachersdunet.com\" ||\n\t\treq.http.X-Referer-Host == \"livesmartswmo.com\" ||\n\t\treq.http.X-Referer-Host == \"javiblog.com\" ||\n\t\treq.http.X-Referer-Host == \"portal.com.local\" ||\n\t\treq.http.X-Referer-Host == \"mi.etoilemedia.com\" ||\n\t\treq.http.X-Referer-Host == \"www.lens.org\" ||\n\t\treq.http.X-Referer-Host == \"blacknet.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"my-faith-be-like.ghost.io\" ||\n\t\treq.http.X-Referer-Host == \"laravel.dev\" ||\n\t\treq.http.X-Referer-Host == \"fi-hpotts.2014-mansionhouse\" ||\n\t\treq.http.X-Referer-Host == \"mi.mailinbox.net\" ||\n\t\treq.http.X-Referer-Host == \"www.schulkeplusrewards.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"sasha-project.s3.amazonaws.com\" ||\n\t\treq.http.X-Referer-Host == \"www.solarenaymar.com.ar\" ||\n\t\treq.http.X-Referer-Host == \"generate.visualwind.com\" ||\n\t\treq.http.X-Referer-Host == \"drupaltest.wgti.net\" ||\n\t\treq.http.X-Referer-Host == \"minasdev.org\" ||\n\t\treq.http.X-Referer-Host == \"ims-logistic.dev\" ||\n\t\treq.http.X-Referer-Host == \"viaresto.com\" ||\n\t\treq.http.X-Referer-Host == \"learn.logixml.com\" ||\n\t\treq.http.X-Referer-Host == \"ox.espadrill-admin\" ||\n\t\treq.http.X-Referer-Host == \"smallmu-sandbox.s3-ap-southeast-1.amazonaws.com\" ||\n\t\treq.http.X-Referer-Host == \"www.firstinternet.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"m.facebook.com\" ||\n\t\treq.http.X-Referer-Host == \"www.ace.media\" ||\n\t\treq.http.X-Referer-Host == \"www.ewiretx.com\" ||\n\t\treq.http.X-Referer-Host == \"crisp.test.tdev.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"www.mifabricavisual.com\" ||\n\t\treq.http.X-Referer-Host == \"www.targetintervention.no\" ||\n\t\treq.http.X-Referer-Host == \"www.couperogers.com\" ||\n\t\treq.http.X-Referer-Host == \"skyhighstaging.local.com\" ||\n\t\treq.http.X-Referer-Host == \"altorendimientoacademico.queretaro.itesm.mx\" ||\n\t\treq.http.X-Referer-Host == \"www.gall-holl.com\" ||\n\t\treq.http.X-Referer-Host == \"sbs-moad.s3-ap-southeast-2.amazonaws.com\" ||\n\t\treq.http.X-Referer-Host == \"firstint.recruitment-lite\" ||\n\t\treq.http.X-Referer-Host == \"www.sro.dk\" ||\n\t\treq.http.X-Referer-Host == \"www.menbur.com\" ||\n\t\treq.http.X-Referer-Host == \"libmanpro.com\" ||\n\t\treq.http.X-Referer-Host == \"blurayaustralia.com\" ||\n\t\treq.http.X-Referer-Host == \"www.adscendmedia.com\" ||\n\t\treq.http.X-Referer-Host == \"blog.vincentbrouillet.com\" ||\n\t\treq.http.X-Referer-Host == \"www.investiumonline.nl\" ||\n\t\treq.http.X-Referer-Host == \"burakkp.com\" ||\n\t\treq.http.X-Referer-Host == \"audreysystem.seeties.me\" ||\n\t\treq.http.X-Referer-Host == \"everestsalesconsultants.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"accesswireless.usdphosting.com\" ||\n\t\treq.http.X-Referer-Host == \"frota.searh.rn.gov.br\" ||\n\t\treq.http.X-Referer-Host == \"qa.ugameplan.com\" ||\n\t\treq.http.X-Referer-Host == \"secure.yec.co\" ||\n\t\treq.http.X-Referer-Host == \"connect.eu.mulesoft.com\" ||\n\t\treq.http.X-Referer-Host == \"www.lastlongerreview.com\" ||\n\t\treq.http.X-Referer-Host == \"kommentatorskampen.lo\" ||\n\t\treq.http.X-Referer-Host == \"kido.bigroominternet.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"ohmydev.se\" ||\n\t\treq.http.X-Referer-Host == \"www.bentogarcia.es\" ||\n\t\treq.http.X-Referer-Host == \"rearview.herokai.com\" ||\n\t\treq.http.X-Referer-Host == \"lecafelatin.resto-ready.com\" ||\n\t\treq.http.X-Referer-Host == \"html24-dev.dk\" ||\n\t\treq.http.X-Referer-Host == \"seecanadabetter.ddev\" ||\n\t\treq.http.X-Referer-Host == \"portal.ad1.wrvc.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"garthwunsch.com\" ||\n\t\treq.http.X-Referer-Host == \"www.elitecustomsigns.com\" ||\n\t\treq.http.X-Referer-Host == \"kaptiva.com.br\" ||\n\t\treq.http.X-Referer-Host == \"nordicinox.com\" ||\n\t\treq.http.X-Referer-Host == \"www.nataktivisterna.lo\" ||\n\t\treq.http.X-Referer-Host == \"www.fidalgobaycoffee.com\" ||\n\t\treq.http.X-Referer-Host == \"mailinbox.net\" ||\n\t\treq.http.X-Referer-Host == \"www.tension.com\" ||\n\t\treq.http.X-Referer-Host == \"www.mccall.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"petbucks.org\" ||\n\t\treq.http.X-Referer-Host == \"mulesoftcompdev.prod.acquia-sites.com\" ||\n\t\treq.http.X-Referer-Host == \"logidev.devcloud.acquia-sites.com\" ||\n\t\treq.http.X-Referer-Host == \"www.cuterunslive.com\" ||\n\t\treq.http.X-Referer-Host == \"ec2-54-86-27-137.compute-1.amazonaws.com\" ||\n\t\treq.http.X-Referer-Host == \"coloft.com\" ||\n\t\treq.http.X-Referer-Host == \"dev-yann.mailinbox.net\" ||\n\t\treq.http.X-Referer-Host == \"titistore.es\" ||\n\t\treq.http.X-Referer-Host == \"biztro.pl\" ||\n\t\treq.http.X-Referer-Host == \"zd.ews.co.rs\" ||\n\t\treq.http.X-Referer-Host == \"www.cafelatincaen.com\" ||\n\t\treq.http.X-Referer-Host == \"togume.com\" ||\n\t\treq.http.X-Referer-Host == \"connect.mulesoft.com\" ||\n\t\treq.http.X-Referer-Host == \"che.local\" ||\n\t\treq.http.X-Referer-Host == \"nataktivisterna.lo\" ||\n\t\treq.http.X-Referer-Host == \"livelean.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"copyprint.nl\" ||\n\t\treq.http.X-Referer-Host == \"jayhathaway.com\" ||\n\t\treq.http.X-Referer-Host == \"rugsejis.epratybos.lt\" ||\n\t\treq.http.X-Referer-Host == \"media-env.elasticbeanstalk.com\" ||\n\t\treq.http.X-Referer-Host == \"id.snowfire.io\" ||\n\t\treq.http.X-Referer-Host == \"employme.at\" ||\n\t\treq.http.X-Referer-Host == \"booleanbrothers.com\" ||\n\t\treq.http.X-Referer-Host == \"www.fusiongroup.ie\" ||\n\t\treq.http.X-Referer-Host == \"skyhighnetworks.gravitatestaging.com\" ||\n\t\treq.http.X-Referer-Host == \"www.teachers.youtalkonline.com\" ||\n\t\treq.http.X-Referer-Host == \"sunshineandfrank.com\" ||\n\t\treq.http.X-Referer-Host == \"proof.acemedia.bigroominternet.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"personaltrainersinlosangeles.com\" ||\n\t\treq.http.X-Referer-Host == \"www.shawn.co\" ||\n\t\treq.http.X-Referer-Host == \"solidproperty.com.my\" ||\n\t\treq.http.X-Referer-Host == \"www.nordicinox.com\" ||\n\t\treq.http.X-Referer-Host == \"tension.com\" ||\n\t\treq.http.X-Referer-Host == \"especiaiss3.gshow.globo.com\" ||\n\t\treq.http.X-Referer-Host == \"seebstore.com\" ||\n\t\treq.http.X-Referer-Host == \"packerz.uk\" ||\n\t\treq.http.X-Referer-Host == \"happyliving.jp\" ||\n\t\treq.http.X-Referer-Host == \"www.vacacionesdebuenrollito.com\" ||\n\t\treq.http.X-Referer-Host == \"plastpack.ind.br\" ||\n\t\treq.http.X-Referer-Host == \"finance.trunk.development.manhattan.gq1.yahoo.com\" ||\n\t\treq.http.X-Referer-Host == \"elearningpprd.biworldwide.com\" ||\n\t\treq.http.X-Referer-Host == \"millwardesque.com\" ||\n\t\treq.http.X-Referer-Host == \"icehotel.lo\" ||\n\t\treq.http.X-Referer-Host == \"ongair.im\" ||\n\t\treq.http.X-Referer-Host == \"mule01a.managed.contegix.com\" ||\n\t\treq.http.X-Referer-Host == \"ipated.org\" ||\n\t\treq.http.X-Referer-Host == \"cientifica-research.com\" ||\n\t\treq.http.X-Referer-Host == \"andreypopp.github.io\" ||\n\t\treq.http.X-Referer-Host == \"schools.medsense.in\" ||\n\t\treq.http.X-Referer-Host == \"d-ycl.cigna.com\" ||\n\t\treq.http.X-Referer-Host == \"romankorver.com\" ||\n\t\treq.http.X-Referer-Host == \"ihaveanidea.me\" ||\n\t\treq.http.X-Referer-Host == \"evoyan.org\" ||\n\t\treq.http.X-Referer-Host == \"cectserver.dyndns.org\" ||\n\t\treq.http.X-Referer-Host == \"test.idx.dev.rets.ly\" ||\n\t\treq.http.X-Referer-Host == \"vastgoedpro.dataquote.nl\" ||\n\t\treq.http.X-Referer-Host == \"sifopweb\" ||\n\t\treq.http.X-Referer-Host == \"instituteofselfmastery.com.au\" ||\n\t\treq.http.X-Referer-Host == \"www.automobrella.com\" ||\n\t\treq.http.X-Referer-Host == \"panel.mibubu.com\" ||\n\t\treq.http.X-Referer-Host == \"whsb.herokuapp.com\" ||\n\t\treq.http.X-Referer-Host == \"heastea.com\" ||\n\t\treq.http.X-Referer-Host == \"meishinkan.pl\" ||\n\t\treq.http.X-Referer-Host == \"manrepeller.staging.wpengine.com\" ||\n\t\treq.http.X-Referer-Host == \"derprecated.com\" ||\n\t\treq.http.X-Referer-Host == \"fobesfamily.com\" ||\n\t\treq.http.X-Referer-Host == \"tensionautomation.com\" ||\n\t\treq.http.X-Referer-Host == \"www.jesuisoriginale.com\" ||\n\t\treq.http.X-Referer-Host == \"www.domgonsa.com.ar\" ||\n\t\treq.http.X-Referer-Host == \"www.digitalpark.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"debray.jerome.free.fr\" ||\n\t\treq.http.X-Referer-Host == \"rainmakerthinking.training\" ||\n\t\treq.http.X-Referer-Host == \"thespineauthority.com.au\" ||\n\t\treq.http.X-Referer-Host == \"pseudocubic.com\" ||\n\t\treq.http.X-Referer-Host == \"mi.sky8.it\" ||\n\t\treq.http.X-Referer-Host == \"iteo.staging.wpengine.com\" ||\n\t\treq.http.X-Referer-Host == \"adscend-q.dev\" ||\n\t\treq.http.X-Referer-Host == \"taxes-in-serbia.ews.co.rs\" ||\n\t\treq.http.X-Referer-Host == \"s.codepen.io\" ||\n\t\treq.http.X-Referer-Host == \"seecanadabetter.ca\" ||\n\t\treq.http.X-Referer-Host == \"www.werkbund.com.br\" ||\n\t\treq.http.X-Referer-Host == \"www.art365.co.za\" ||\n\t\treq.http.X-Referer-Host == \"tensionpackaging.com\" ||\n\t\treq.http.X-Referer-Host == \"ec2-54-164-179-111.compute-1.amazonaws.com\" ||\n\t\treq.http.X-Referer-Host == \"sms.loc\" ||\n\t\treq.http.X-Referer-Host == \"timeclock.neonandmore.com\" ||\n\t\treq.http.X-Referer-Host == \"silverblingblack.com\" ||\n\t\treq.http.X-Referer-Host == \"www.modulolanguage.com\" ||\n\t\treq.http.X-Referer-Host == \"visualise.today\" ||\n\t\treq.http.X-Referer-Host == \"pickinglist.constance.com.br\" ||\n\t\treq.http.X-Referer-Host == \"mobileshoppingapps.net\" ||\n\t\treq.http.X-Referer-Host == \"ashleyandbarry.com\" ||\n\t\treq.http.X-Referer-Host == \"www.planetgreen.cl\" ||\n\t\treq.http.X-Referer-Host == \"portal-intranet.ti.sabesp.com.br\" ||\n\t\treq.http.X-Referer-Host == \"gordonrecords.net\" ||\n\t\treq.http.X-Referer-Host == \"cce.pathlore.net\" ||\n\t\treq.http.X-Referer-Host == \"www.myclaimvalue.com\" ||\n\t\treq.http.X-Referer-Host == \"stage.mulesoft.org\" ||\n\t\treq.http.X-Referer-Host == \"javiblog.javigs.es\"\n\t) {\n\t\tset req.http.X-Redir-URL = \"https:\/\/legacy.polyfill.io\" req.url;\n\t\terror 900 req.http.X-Redir-URL;\n\t}\n\n\tif (req.url ~ \"^\/v1\/polyfill\\.\" && req.url !~ \"[\\?\\&]ua=\") {\n\t\tset req.http.X-Orig-URL = req.url;\n\t\tset req.url = \"\/v1\/normalizeUa?ua=\" regsuball(regsuball(regsuball(req.http.User-Agent, {\"%\"}, {\"%25\"}), {\" \"}, {\"%20\"}), {\"&\"}, {\"%26\"});\n\t}\n\n\treturn(lookup);\n}\n\nsub vcl_deliver {\n#FASTLY deliver\n\tif (req.url ~ \"^\/v1\/normalizeUa\" && resp.status == 200) {\n\t\tset req.http.Fastly-force-Shield = \"1\";\n\t\tif (req.http.X-Orig-URL ~ \"\\?\") {\n\t\t\tset req.url = req.http.X-Orig-URL \"&ua=\" resp.http.Normalized-User-Agent;\n\t\t} else {\n\t\t\tset req.url = req.http.X-Orig-URL \"?ua=\" resp.http.Normalized-User-Agent;\n\t\t}\n\t\trestart;\n\t} else if (req.url ~ \"^\/v1\/polyfill\\..*[\\?\\&]ua=\" && req.http.X-Orig-URL && req.http.X-Orig-URL !~ \"[\\?\\&]ua=\") {\n\t\tset resp.http.Vary = \"Accept-Encoding, User-Agent\";\n\t}\n\treturn(deliver);\n}\n\nsub vcl_error {\n\tif (obj.status == 900) {\n\t\tset obj.http.Location = obj.response;\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\tsynthetic {\"The referer header or request URI supplied in your request is known to be an attempt to use the previous version of polyfill.io, so for backwards compatibility we're redirecting you to legacy.polyfill.io which will handle your request using the old version of the service. The legacy version will be discontinued in the future, so please update to the new version, and then let us know by raising an issue in our repo at https:\/\/github.com\/financial-times\/polyfill-service.\"};\n\t\treturn (deliver);\n\t}\n}\n","old_contents":"sub vcl_recv {\n#FASTLY recv\n\n\tif (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n\t\treturn(pass);\n\t}\n\n\tif (req.url ~ \"^\/v1\/polyfill\\.\" && req.url !~ \"[\\?\\&]ua=\") {\n\t\tset req.http.X-Orig-URL = req.url;\n\t\tset req.url = \"\/v1\/normalizeUa?ua=\" urlencode(req.http.User-Agent);\n\t}\n\n\treturn(lookup);\n}\n\nsub vcl_deliver {\n#FASTLY deliver\n\tif (req.url ~ \"^\/v1\/normalizeUa\" && resp.status == 200) {\n\t\tset req.http.Fastly-force-Shield = \"1\";\n\t\tif (req.http.X-Orig-URL ~ \"\\?\") {\n\t\t\tset req.url = req.http.X-Orig-URL \"&ua=\" resp.http.Normalized-User-Agent;\n\t\t} else {\n\t\t\tset req.url = req.http.X-Orig-URL \"?ua=\" resp.http.Normalized-User-Agent;\n\t\t}\n\t\trestart;\n\t} else if (req.url ~ \"^\/v1\/polyfill\\..*[\\?\\&]ua=\" && req.http.X-Orig-URL && req.http.X-Orig-URL !~ \"[\\?\\&]ua=\") {\n\t\tset resp.http.Vary = \"Accept-Encoding, User-Agent\";\n\t}\n\treturn(deliver);\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"95bcbb0c72f7203c99f4ff54a08969c46d15315e","subject":"Add logging from fastly (#1010)","message":"Add logging from fastly (#1010)\n\n","repos":"mcshaz\/polyfill-service,kdzwinel\/polyfill-service,jonathan-fielding\/polyfill-service,JakeChampion\/polyfill-service,mcshaz\/polyfill-service,jonathan-fielding\/polyfill-service,jonathan-fielding\/polyfill-service,JakeChampion\/polyfill-service,kdzwinel\/polyfill-service,kdzwinel\/polyfill-service,mcshaz\/polyfill-service","old_file":"fastly-config.vcl","new_file":"fastly-config.vcl","new_contents":"import boltsort;\n\nsub vcl_recv {\n#FASTLY recv\n\n\t# Only log 0.1% of requests.\n\tif (randombool(1, 1000)) {\n\t\tset req.http.log = \"1\";\n\t}\n\n\t# Attach a unique id to each request, can be useful when investigating logs\n\tif (!req.http.request-id) {\n\t\tset req.http.request-id =\n\t\t\trandomstr(8, \"0123456789abcdef\") \"-\"\n\t\t\trandomstr(4, \"0123456789abcdef\") \"-4\"\n\t\t\trandomstr(3, \"0123456789abcdef\") \"-\"\n\t\t\trandomstr(1, \"89ab\") randomstr(3, \"0123456789abcdef\") \"-\"\n\t\t\trandomstr(12, \"0123456789abcdef\");\n\t}\n\n\tif ( req.request == \"FASTLYPURGE\" ) {\n\t\tset req.http.Fastly-Purge-Requires-Auth = \"1\";\n\t}\n\n\tif (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n\t\treturn(pass);\n\t}\n\n\tif (!req.http.Fastly-SSL) {\n\t\tif (req.http.Host == \"cdn.polyfill.io\" || req.http.Host == \"polyfill.io\") {\n\t\t\terror 751 \"Redirect to prod HTTPS\";\n\t\t}\n\t\tif (req.http.Host == \"qa.polyfill.io\") {\n\t\t\terror 752 \"Redirect to QA HTTPS\";\n\t\t}\n\t}\n\n\tif (req.http.Host ~ \"polyfills.io\") {\n\t\terror 751 \"Canonicalise\";\n\t}\n\n\tif (req.url ~ \"^\/v2\/(polyfill\\.|recordRumData)\" && req.url !~ \"[\\?\\&]ua=\") {\n\t\tset req.http.X-Orig-URL = req.url;\n\t\tset req.url = \"\/v2\/normalizeUa?ua=\" urlencode(req.http.User-Agent);\n\t}\n\n\tif (req.url ~ \"^\/v2\/recordRumData\" && req.http.Normalized-User-Agent) {\n\t\tset req.http.Log = regsub(req.url, \"^.*?\\?(.*)$\", \"\\1\") \"&ip=\" client.ip \"&refer_domain=\" regsub(req.http.Referer, \"^(https?\\:\\\/\\\/)?(www\\.)?(.+?)(\\:\\d+)?([\\\/\\?].*)?$\", \"\\3\") \"&country=\" geoip.country_code \"&data_center=\" if(req.http.Cookie:FastlyDC, req.http.Cookie:FastlyDC, server.datacenter);\n\t\terror 204 \"No Content\";\n\t}\n\n\tset req.url = boltsort.sort(req.url);\n\n\treturn(lookup);\n}\n\nsub vcl_deliver {\n#FASTLY deliver\n\n\tcall custom_syslog;\n\n\t# If we are debugging, it is useful to know what the request-id will be so\n\t# that we can look at the logs for our requests\n\tif (req.http.FT-Debug) {\n\t\tset resp.http.request-id = req.http.request-id;\n\t}\n\n\t# If the response is to a normalise request and there's a parked \"original request\", use the normalised UA response to modify the original request and restart it\n\tif (req.url ~ \"^\/v\\d\/normalizeUa\" && resp.status == 200 && req.http.X-Orig-URL ~ \"^\/v2\/(polyfill\\.|recordRumData)\") {\n\t\tset req.http.Fastly-force-Shield = \"1\";\n\t\tset req.http.Normalized-User-Agent = resp.http.Normalized-User-Agent;\n\t\tif (req.http.X-Orig-URL ~ \"\\?\") {\n\t\t\tset req.url = req.http.X-Orig-URL \"&ua=\" resp.http.Normalized-User-Agent;\n\t\t} else {\n\t\t\tset req.url = req.http.X-Orig-URL \"?ua=\" resp.http.Normalized-User-Agent;\n\t\t}\n\t\trestart;\n\n\t# If the original request didn't specify a UA override, and we added one when the request was sent to the backend, the backend won't have included a Vary:user-agent header (correctly) but we need to add one\n\t} else if (req.url ~ \"^\/v\\d\/polyfill\\..*[\\?\\&]ua=\" && req.http.X-Orig-URL && req.http.X-Orig-URL !~ \"[\\?\\&]ua=\") {\n\t\tadd resp.http.Vary = \"User-Agent\";\n\t}\n\n\tif (req.url ~ \"[\\&\\?]rum=1\") {\n\t\tadd resp.http.Set-Cookie = \"FastlyDC=\" server.datacenter \"; Path=\/; HttpOnly; max-age=60\";\n\t}\n\n\treturn(deliver);\n}\n\nsub vcl_error {\n#FASTLY error\n\n\t# We log all vcl_error calls as these are probably exceptional circumstances\n\tcall custom_error_syslog;\n\n\t# Redirect to canonical prod\/qa origins\n\tif (obj.status == 751 || obj.status == 752) {\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\tset obj.http.Location = \"https:\/\/\" if(obj.status == 751, \"\", \"qa.\") \"polyfill.io\" req.url;\n\t\tsynthetic {\"\"};\n\t\treturn (deliver);\n\t}\n}\n\nsub custom_syslog {\n\t# The log function will only be called if the request is one of the 25%\n\t# which we labelled as having logging enabled\n\tif (req.http.log) {\n\t\tlog {\"syslog ${SERVICEID} Fastly :: serviceid=${SERVICEID}\"}\n\t\t\t{\" timestamp=\"} time.start.sec\n\t\t\t{\" event=\"} {\"REQUEST\"}\n\t\t\t{\" host=\"} req.http.host\n\t\t\t{\" request-id=\"} req.http.request-id\n\t\t\t{\" bytes=\"} resp.http.content-length\n\t\t\t{\" client_ip=\"} req.http.Fastly-Client-IP\n\t\t\t{\" method=\"} req.request\n\t\t\t{\" useragent=\"} req.http.User-Agent\n\t\t\t{\" url=\"\"} req.url {\"\"\"}\n\t\t\t{\" content_type=\"\"} resp.http.Content-Type {\"\"\"}\n\t\t\t{\" status=\"} resp.status\n\t\t\t{\" content-length=\"} resp.http.content-length\n\t\t\tif(geoip.city,{\" geoip_city=\"\"} geoip.city {\"\"\"},{\"\"})\n\t\t\tif(geoip.region,{\" geoip_region=\"\"} geoip.region {\"\"\"},{\"\"})\n\t\t\tif(geoip.country_code,{\" geoip_country=\"} geoip.country_code,{\"\"})\n\t\t\tif(geoip.continent_code,{\" geoip_continent=\"} geoip.continent_code,{\"\"})\n\t\t\t{\" fastly_region=\"} server.region\n\t\t\t{\" fastly_datacenter=\"} server.datacenter\n\t\t\t{\" fastly_node=\"} server.identity\n\t\t\t{\" fastly_state=\"} fastly_info.state\n\t\t\t{\" duration_ms=\"} time.elapsed.msec;\n\t}\n}\n\nsub custom_error_syslog {\n\t# The reason custom_error_syslog is different from custom_syslog is because when\n\t# vcl_error is entered, there will be no resp object, which is used inside\n\t# custom_syslog to log information about the response we are sending\n\n\tlog {\"syslog ${SERVICEID} Fastly :: serviceid=${SERVICEID}\"}\n\t\t{\" timestamp=\"} time.start.sec\n\t\t{\" event=\"} {\"REQUEST\"}\n\t\t{\" host=\"} req.http.host\n\t\t{\" request-id=\"} req.http.request-id\n\t\t{\" client_ip=\"} req.http.Fastly-Client-IP\n\t\t{\" method=\"} req.request\n\t\t{\" useragent=\"} req.http.User-Agent\n\t\t{\" url=\"\"} req.url {\"\"\"}\n\t\tif(geoip.city,{\" geoip_city=\"\"} geoip.city {\"\"\"},{\"\"})\n\t\tif(geoip.region,{\" geoip_region=\"\"} geoip.region {\"\"\"},{\"\"})\n\t\tif(geoip.country_code,{\" geoip_country=\"} geoip.country_code,{\"\"})\n\t\tif(geoip.continent_code,{\" geoip_continent=\"} geoip.continent_code,{\"\"})\n\t\t{\" fastly_region=\"} server.region\n\t\t{\" fastly_datacenter=\"} server.datacenter\n\t\t{\" fastly_node=\"} server.identity\n\t\t{\" fastly_state=\"} fastly_info.state\n\t\t{\" duration_ms=\"} time.elapsed.msec;\n}\n","old_contents":"import boltsort;\n\nsub vcl_recv {\n#FASTLY recv\n\tif ( req.request == \"FASTLYPURGE\" ) {\n\t\tset req.http.Fastly-Purge-Requires-Auth = \"1\";\n\t}\n\n\tif (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n\t\treturn(pass);\n\t}\n\n\tif (!req.http.Fastly-SSL) {\n\t\tif (req.http.Host == \"cdn.polyfill.io\" || req.http.Host == \"polyfill.io\") {\n\t\t\terror 751 \"Redirect to prod HTTPS\";\n\t\t}\n\t\tif (req.http.Host == \"qa.polyfill.io\") {\n\t\t\terror 752 \"Redirect to QA HTTPS\";\n\t\t}\n\t}\n\n\tif (req.http.Host ~ \"polyfills.io\") {\n\t\terror 751 \"Canonicalise\";\n\t}\n\n\tif (req.url ~ \"^\/v2\/(polyfill\\.|recordRumData)\" && req.url !~ \"[\\?\\&]ua=\") {\n\t\tset req.http.X-Orig-URL = req.url;\n\t\tset req.url = \"\/v2\/normalizeUa?ua=\" urlencode(req.http.User-Agent);\n\t}\n\n\tif (req.url ~ \"^\/v2\/recordRumData\" && req.http.Normalized-User-Agent) {\n\t\tset req.http.Log = regsub(req.url, \"^.*?\\?(.*)$\", \"\\1\") \"&ip=\" client.ip \"&refer_domain=\" regsub(req.http.Referer, \"^(https?\\:\\\/\\\/)?(www\\.)?(.+?)(\\:\\d+)?([\\\/\\?].*)?$\", \"\\3\") \"&country=\" geoip.country_code \"&data_center=\" if(req.http.Cookie:FastlyDC, req.http.Cookie:FastlyDC, server.datacenter);\n\t\terror 204 \"No Content\";\n\t}\n\n\tset req.url = boltsort.sort(req.url);\n\n\treturn(lookup);\n}\n\nsub vcl_deliver {\n#FASTLY deliver\n\n\t# If the response is to a normalise request and there's a parked \"original request\", use the normalised UA response to modify the original request and restart it\n\tif (req.url ~ \"^\/v\\d\/normalizeUa\" && resp.status == 200 && req.http.X-Orig-URL ~ \"^\/v2\/(polyfill\\.|recordRumData)\") {\n\t\tset req.http.Fastly-force-Shield = \"1\";\n\t\tset req.http.Normalized-User-Agent = resp.http.Normalized-User-Agent;\n\t\tif (req.http.X-Orig-URL ~ \"\\?\") {\n\t\t\tset req.url = req.http.X-Orig-URL \"&ua=\" resp.http.Normalized-User-Agent;\n\t\t} else {\n\t\t\tset req.url = req.http.X-Orig-URL \"?ua=\" resp.http.Normalized-User-Agent;\n\t\t}\n\t\trestart;\n\n\t# If the original request didn't specify a UA override, and we added one when the request was sent to the backend, the backend won't have included a Vary:user-agent header (correctly) but we need to add one\n\t} else if (req.url ~ \"^\/v\\d\/polyfill\\..*[\\?\\&]ua=\" && req.http.X-Orig-URL && req.http.X-Orig-URL !~ \"[\\?\\&]ua=\") {\n\t\tadd resp.http.Vary = \"User-Agent\";\n\t}\n\n\tif (req.url ~ \"[\\&\\?]rum=1\") {\n\t\tadd resp.http.Set-Cookie = \"FastlyDC=\" server.datacenter \"; Path=\/; HttpOnly; max-age=60\";\n\t}\n\n\treturn(deliver);\n}\n\nsub vcl_error {\n\n\t# Redirect to canonical prod\/qa origins\n\tif (obj.status == 751 || obj.status == 752) {\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\tset obj.http.Location = \"https:\/\/\" if(obj.status == 751, \"\", \"qa.\") \"polyfill.io\" req.url;\n\t\tsynthetic {\"\"};\n\t\treturn (deliver);\n\t}\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"c574fead2ac81164b12d06f630f9b653c0765989","subject":"Revert \"ensure multiple words can be matched such as `\/v2\/polyfill.production.min.js`\"","message":"Revert \"ensure multiple words can be matched such as `\/v2\/polyfill.production.min.js`\"\n\nThis reverts commit c25c34d5a58b0a002dca18c49afbe46a14ab3f3f.\n","repos":"JakeChampion\/polyfill-service,JakeChampion\/polyfill-service","old_file":"fastly\/vcl\/polyfill-service.vcl","new_file":"fastly\/vcl\/polyfill-service.vcl","new_contents":"sub set_backend {\n\t# Calculate the ideal region to route the request to.\n\tdeclare local var.region STRING;\n\tif (server.region ~ \"(APAC|Asia|North-America|South-America|US-Central|US-East|US-West)\") {\n\t\tset var.region = \"US\";\n\t} else {\n\t\tset var.region = \"EU\";\n\t}\n\n\t# Gather the health of the shields and origins.\n\tdeclare local var.v3_eu_is_healthy BOOL;\n\tset req.backend = F_v3_eu;\n\tset var.v3_eu_is_healthy = req.backend.healthy;\n\n\tdeclare local var.v3_us_is_healthy BOOL;\n\tset req.backend = F_v3_us;\n\tset var.v3_us_is_healthy = req.backend.healthy;\n\n\t# Set some sort of default, that shouldn't get used.\n\tset req.backend = F_v3_eu;\n\n\t# Route EU requests to the nearest healthy shield or origin.\n\tif (var.region == \"EU\") {\n\t\tif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_eu;\n\t\t}\n\t}\n\n\t# Route US requests to the nearest healthy shield or origin.\n\tif (var.region == \"US\") {\n\t\tif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_us;\n\t\t}\n\t}\n\n\t# Persist the decision so we can debug the result.\n\tset req.http.Debug-Backend = req.backend;\n\n\t# The Fastly macro is inserted after the backend is selected because the\n\t# macro has the code to select the correct req.http.Host value based on the backend.\n\t#FASTLY recv\n}\n\nsub vcl_recv {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_recv;\n\t}\n\n\tif (req.method != \"GET\" && req.method != \"HEAD\" && req.method != \"OPTIONS\" && req.method != \"FASTLYPURGE\" && req.method != \"PURGE\") {\n\t\terror 911;\n\t}\n\n\tif (req.method == \"OPTIONS\") {\n\t\terror 912;\n\t}\n\n\t# Because the old service had a router which allowed any words between \/v2\/polyfill. and .js\n\tif (req.url ~ \"^\/v2\/polyfill(\\.\\w+)\\.js\") {\n\t\tset req.url = regsub(req.url, \"^\/v2\/polyfill(\\.\\w+)\\.js\", \"\/v2\/polyfill.min.js\");\n\t}\n\n\t# Override the v3 defaults with the defaults of v2\n\tif (req.url ~ \"^\/v2\/polyfill(\\.min)?\\.js\") {\n\t\tset req.url = regsub(req.url, \"^\/v2\", \"\/v3\");\n\t\tset req.url = querystring.set(req.url, \"version\", \"3.25.1\");\n\t\tdeclare local var.unknown STRING;\n\t\tset var.unknown = subfield(req.url.qs, \"unknown\", \"&\");\n\t\tset req.url = querystring.set(req.url, \"unknown\", if(var.unknown != \"\", var.unknown, \"ignore\"));\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\") {\n\t\tcall normalise_querystring_parameters_for_polyfill_bundle;\n\t}\n\n\t# Sort the querystring parameters alphabetically to improve chances of hitting a cached copy.\n\t# If querystring is empty, remove the ? from the url.\n\tset req.url = querystring.clean(querystring.sort(req.url));\n\tcall set_backend;\n}\n\nsub vcl_hash {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_hash;\n\t}\n\n\t# We are not adding req.http.host to the hash because we want https:\/\/cdn.polyfill.io and https:\/\/polyfill.io to be a single object in the cache.\n\t# set req.hash += req.http.host;\n\tset req.hash += req.url;\n\t# We include return(hash) to stop the function falling through to the default VCL built into varnish, which for vcl_hash will add req.url and req.http.Host to the hash.\n\treturn(hash);\n}\n\nsub vcl_miss {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_miss;\n\t}\n}\n\nsub vcl_pass {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_pass;\n\t}\n}\n\nsub vcl_fetch {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_fetch;\n\t}\n\n\t# These header are only required for HTML documents.\n\tif (beresp.http.Content-Type ~ \"text\/html\") {\n\t\t# Enables the cross-site scripting filter built into most modern web browsers.\n\t\tset beresp.http.X-XSS-Protection = \"1; mode=block\";\t\n\t}\n\t# Prevents MIME-sniffing a response away from the declared content type.\n\tset beresp.http.X-Content-Type-Options = \"nosniff\";\n\n\t# Ensure the site is only served over HTTPS and reduce the chances of someone performing a MITM attack.\n\tset beresp.http.Strict-Transport-Security = \"max-age=31536000; includeSubdomains; preload\";\n\n\t# The Referrer-Policy header governs which referrer information, sent in the Referer header, should be included with requests made.\n\t# Send a full URL when performing a same-origin request, but only send the origin of the document for other cases.\n\tset beresp.http.Referrer-Policy = \"origin-when-cross-origin\";\n\n\t# Enable purging of all objects in the Fastly cache by issuing a purge with the key \"polyfill-service\".\n\tif (beresp.http.Surrogate-Key !~ \"\\bpolyfill-service\\b\") {\n\t\tset beresp.http.Surrogate-Key = if(beresp.http.Surrogate-Key, beresp.http.Surrogate-Key \" polyfill-service\", \"polyfill-service\");\n\t}\n\n\tset beresp.http.Timing-Allow-Origin = \"*\";\n\n\tif (req.http.Normalized-User-Agent) {\n\t\tset beresp.http.Normalized-User-Agent = req.http.Normalized-User-Agent;\n\t\tset beresp.http.Detected-User-Agent = req.http.useragent_parser_family \"\/\" req.http.useragent_parser_major \".\" req.http.useragent_parser_minor \".\" req.http.useragent_parser_patch;\n\t}\n}\n\nsub vcl_deliver {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_deliver;\n\t}\n\n\tset req.http.Fastly-Force-Shield = \"yes\";\n\n\t# Allow cross origin GET, HEAD, and OPTIONS requests to be made.\n\tif (req.http.Origin) {\n\t\tset resp.http.Access-Control-Allow-Origin = \"*\";\n\t\tset resp.http.Access-Control-Allow-Methods = \"GET,HEAD,OPTIONS\";\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\") {\n\t\t# Need to add \"Vary: User-Agent\" in after vcl_fetch to avoid the \n\t\t# \"Vary: User-Agent\" entering the Varnish cache.\n\t\t# We need \"Vary: User-Agent\" in the browser cache because a browser\n\t\t# may update itself to a version which needs different polyfills\n\t\t# So we need to have it ignore the browser cached bundle when the user-agent changes.\n\t\tadd resp.http.Vary = \"User-Agent\";\n\t\tadd resp.http.Vary = \"Accept-Encoding\";\n\t}\n\n\tadd resp.http.Server-Timing = fastly_info.state {\", fastly;desc=\"Edge time\";dur=\"} time.elapsed.msec;\n\n\tif (req.http.Fastly-Debug) {\n\t\tset resp.http.Debug-Backend = req.http.Debug-Backend;\n\t\tset resp.http.Debug-Host = req.http.Host;\n\t\tset resp.http.Debug-Fastly-Restarts = req.restarts;\n\t\tset resp.http.Debug-Orig-URL = req.http.Orig-URL;\n\t\tset resp.http.Debug-VCL-Route = req.http.X-VCL-Route;\n\t\tset resp.http.useragent_parser_family = req.http.useragent_parser_family;\n\t\tset resp.http.useragent_parser_major = req.http.useragent_parser_major;\n\t\tset resp.http.useragent_parser_minor = req.http.useragent_parser_minor;\n\t\tset resp.http.useragent_parser_patch = req.http.useragent_parser_patch;\n\t} else {\n\t\tunset resp.http.Server;\n\t\tunset resp.http.Via;\n\t\tunset resp.http.X-Cache;\n\t\tunset resp.http.X-Cache-Hits;\n\t\tunset resp.http.X-Served-By;\n\t\tunset resp.http.X-Timer;\n\t\tunset resp.http.Fastly-Restarts;\n\t}\n}\n\nsub vcl_error {\n\tif (obj.status == 911) {\n\t\tset obj.status = 405;\n\t\tset obj.response = \"METHOD NOT ALLOWED\";\n\t\tset obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n\t\tset obj.http.Cache-Control = \"private, no-store\";\n\t\tsynthetic req.method \" METHOD NOT ALLOWED\";\n\t\treturn (deliver);\n\t}\n\tif (obj.status == 912) {\n\t\tset obj.status = 200;\n\t\tset obj.response = \"OK\";\n\t\tset obj.http.Allow = \"OPTIONS, GET, HEAD\";\n\t\treturn (deliver);\n\t}\n}\n","old_contents":"sub set_backend {\n\t# Calculate the ideal region to route the request to.\n\tdeclare local var.region STRING;\n\tif (server.region ~ \"(APAC|Asia|North-America|South-America|US-Central|US-East|US-West)\") {\n\t\tset var.region = \"US\";\n\t} else {\n\t\tset var.region = \"EU\";\n\t}\n\n\t# Gather the health of the shields and origins.\n\tdeclare local var.v3_eu_is_healthy BOOL;\n\tset req.backend = F_v3_eu;\n\tset var.v3_eu_is_healthy = req.backend.healthy;\n\n\tdeclare local var.v3_us_is_healthy BOOL;\n\tset req.backend = F_v3_us;\n\tset var.v3_us_is_healthy = req.backend.healthy;\n\n\t# Set some sort of default, that shouldn't get used.\n\tset req.backend = F_v3_eu;\n\n\t# Route EU requests to the nearest healthy shield or origin.\n\tif (var.region == \"EU\") {\n\t\tif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_eu;\n\t\t}\n\t}\n\n\t# Route US requests to the nearest healthy shield or origin.\n\tif (var.region == \"US\") {\n\t\tif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_us;\n\t\t}\n\t}\n\n\t# Persist the decision so we can debug the result.\n\tset req.http.Debug-Backend = req.backend;\n\n\t# The Fastly macro is inserted after the backend is selected because the\n\t# macro has the code to select the correct req.http.Host value based on the backend.\n\t#FASTLY recv\n}\n\nsub vcl_recv {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_recv;\n\t}\n\n\tif (req.method != \"GET\" && req.method != \"HEAD\" && req.method != \"OPTIONS\" && req.method != \"FASTLYPURGE\" && req.method != \"PURGE\") {\n\t\terror 911;\n\t}\n\n\tif (req.method == \"OPTIONS\") {\n\t\terror 912;\n\t}\n\n\t# Because the old service had a router which allowed any words between \/v2\/polyfill. and .js\n\tif (req.url ~ \"^\/v2\/polyfill(\\.\\w+)+\\.js\") {\n\t\tset req.url = regsub(req.url, \"^\/v2\/polyfill(\\.\\w+)\\.js\", \"\/v2\/polyfill.min.js\");\n\t}\n\n\t# Override the v3 defaults with the defaults of v2\n\tif (req.url ~ \"^\/v2\/polyfill(\\.min)?\\.js\") {\n\t\tset req.url = regsub(req.url, \"^\/v2\", \"\/v3\");\n\t\tset req.url = querystring.set(req.url, \"version\", \"3.25.1\");\n\t\tdeclare local var.unknown STRING;\n\t\tset var.unknown = subfield(req.url.qs, \"unknown\", \"&\");\n\t\tset req.url = querystring.set(req.url, \"unknown\", if(var.unknown != \"\", var.unknown, \"ignore\"));\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\") {\n\t\tcall normalise_querystring_parameters_for_polyfill_bundle;\n\t}\n\n\t# Sort the querystring parameters alphabetically to improve chances of hitting a cached copy.\n\t# If querystring is empty, remove the ? from the url.\n\tset req.url = querystring.clean(querystring.sort(req.url));\n\tcall set_backend;\n}\n\nsub vcl_hash {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_hash;\n\t}\n\n\t# We are not adding req.http.host to the hash because we want https:\/\/cdn.polyfill.io and https:\/\/polyfill.io to be a single object in the cache.\n\t# set req.hash += req.http.host;\n\tset req.hash += req.url;\n\t# We include return(hash) to stop the function falling through to the default VCL built into varnish, which for vcl_hash will add req.url and req.http.Host to the hash.\n\treturn(hash);\n}\n\nsub vcl_miss {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_miss;\n\t}\n}\n\nsub vcl_pass {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_pass;\n\t}\n}\n\nsub vcl_fetch {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_fetch;\n\t}\n\n\t# These header are only required for HTML documents.\n\tif (beresp.http.Content-Type ~ \"text\/html\") {\n\t\t# Enables the cross-site scripting filter built into most modern web browsers.\n\t\tset beresp.http.X-XSS-Protection = \"1; mode=block\";\t\n\t}\n\t# Prevents MIME-sniffing a response away from the declared content type.\n\tset beresp.http.X-Content-Type-Options = \"nosniff\";\n\n\t# Ensure the site is only served over HTTPS and reduce the chances of someone performing a MITM attack.\n\tset beresp.http.Strict-Transport-Security = \"max-age=31536000; includeSubdomains; preload\";\n\n\t# The Referrer-Policy header governs which referrer information, sent in the Referer header, should be included with requests made.\n\t# Send a full URL when performing a same-origin request, but only send the origin of the document for other cases.\n\tset beresp.http.Referrer-Policy = \"origin-when-cross-origin\";\n\n\t# Enable purging of all objects in the Fastly cache by issuing a purge with the key \"polyfill-service\".\n\tif (beresp.http.Surrogate-Key !~ \"\\bpolyfill-service\\b\") {\n\t\tset beresp.http.Surrogate-Key = if(beresp.http.Surrogate-Key, beresp.http.Surrogate-Key \" polyfill-service\", \"polyfill-service\");\n\t}\n\n\tset beresp.http.Timing-Allow-Origin = \"*\";\n\n\tif (req.http.Normalized-User-Agent) {\n\t\tset beresp.http.Normalized-User-Agent = req.http.Normalized-User-Agent;\n\t\tset beresp.http.Detected-User-Agent = req.http.useragent_parser_family \"\/\" req.http.useragent_parser_major \".\" req.http.useragent_parser_minor \".\" req.http.useragent_parser_patch;\n\t}\n}\n\nsub vcl_deliver {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_deliver;\n\t}\n\n\tset req.http.Fastly-Force-Shield = \"yes\";\n\n\t# Allow cross origin GET, HEAD, and OPTIONS requests to be made.\n\tif (req.http.Origin) {\n\t\tset resp.http.Access-Control-Allow-Origin = \"*\";\n\t\tset resp.http.Access-Control-Allow-Methods = \"GET,HEAD,OPTIONS\";\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\") {\n\t\t# Need to add \"Vary: User-Agent\" in after vcl_fetch to avoid the \n\t\t# \"Vary: User-Agent\" entering the Varnish cache.\n\t\t# We need \"Vary: User-Agent\" in the browser cache because a browser\n\t\t# may update itself to a version which needs different polyfills\n\t\t# So we need to have it ignore the browser cached bundle when the user-agent changes.\n\t\tadd resp.http.Vary = \"User-Agent\";\n\t\tadd resp.http.Vary = \"Accept-Encoding\";\n\t}\n\n\tadd resp.http.Server-Timing = fastly_info.state {\", fastly;desc=\"Edge time\";dur=\"} time.elapsed.msec;\n\n\tif (req.http.Fastly-Debug) {\n\t\tset resp.http.Debug-Backend = req.http.Debug-Backend;\n\t\tset resp.http.Debug-Host = req.http.Host;\n\t\tset resp.http.Debug-Fastly-Restarts = req.restarts;\n\t\tset resp.http.Debug-Orig-URL = req.http.Orig-URL;\n\t\tset resp.http.Debug-VCL-Route = req.http.X-VCL-Route;\n\t\tset resp.http.useragent_parser_family = req.http.useragent_parser_family;\n\t\tset resp.http.useragent_parser_major = req.http.useragent_parser_major;\n\t\tset resp.http.useragent_parser_minor = req.http.useragent_parser_minor;\n\t\tset resp.http.useragent_parser_patch = req.http.useragent_parser_patch;\n\t} else {\n\t\tunset resp.http.Server;\n\t\tunset resp.http.Via;\n\t\tunset resp.http.X-Cache;\n\t\tunset resp.http.X-Cache-Hits;\n\t\tunset resp.http.X-Served-By;\n\t\tunset resp.http.X-Timer;\n\t\tunset resp.http.Fastly-Restarts;\n\t}\n}\n\nsub vcl_error {\n\tif (obj.status == 911) {\n\t\tset obj.status = 405;\n\t\tset obj.response = \"METHOD NOT ALLOWED\";\n\t\tset obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n\t\tset obj.http.Cache-Control = \"private, no-store\";\n\t\tsynthetic req.method \" METHOD NOT ALLOWED\";\n\t\treturn (deliver);\n\t}\n\tif (obj.status == 912) {\n\t\tset obj.status = 200;\n\t\tset obj.response = \"OK\";\n\t\tset obj.http.Allow = \"OPTIONS, GET, HEAD\";\n\t\treturn (deliver);\n\t}\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"91f55f1102134ff3d8ef1c7c4d367d8512d7e54d","subject":"Comment explaining the suggested method of implement purge in the VCL","message":"Comment explaining the suggested method of implement purge in the VCL\n","repos":"nzherald\/alaveteli,sarhane\/alaveteli-test,petterreinholdtsen\/alaveteli,andreicristianpetcu\/alaveteli_old,codeforcroatia\/alaveteli,andreicristianpetcu\/alaveteli_old,obshtestvo\/alaveteli-bulgaria,codeforcroatia\/alaveteli,10layer\/alaveteli,petterreinholdtsen\/alaveteli,Br3nda\/alaveteli,TEDICpy\/QueremoSaber,10layer\/alaveteli,andreicristianpetcu\/alaveteli,hasadna\/alaveteli,andreicristianpetcu\/alaveteli,sarhane\/alaveteli-test,4bic\/alaveteli,Br3nda\/alaveteli,petterreinholdtsen\/alaveteli,obshtestvo\/alaveteli-bulgaria,10layer\/alaveteli,andreicristianpetcu\/alaveteli,codeforcroatia\/alaveteli,hasadna\/alaveteli,sarhane\/alaveteli-test,TEDICpy\/QueremoSaber,nzherald\/alaveteli,datauy\/alaveteli,TEDICpy\/QueremoSaber,obshtestvo\/alaveteli-bulgaria,4bic\/alaveteli,sarhane\/alaveteli-test,petterreinholdtsen\/alaveteli,obshtestvo\/alaveteli-bulgaria,obshtestvo\/alaveteli-bulgaria,Br3nda\/alaveteli,codeforcroatia\/alaveteli,4bic\/alaveteli,nzherald\/alaveteli,TEDICpy\/QueremoSaber,datauy\/alaveteli,4bic\/alaveteli,petterreinholdtsen\/alaveteli,andreicristianpetcu\/alaveteli,4bic\/alaveteli,Br3nda\/alaveteli,TEDICpy\/QueremoSaber,Br3nda\/alaveteli,nzherald\/alaveteli,hasadna\/alaveteli,datauy\/alaveteli,andreicristianpetcu\/alaveteli_old,hasadna\/alaveteli,andreicristianpetcu\/alaveteli_old,andreicristianpetcu\/alaveteli_old,hasadna\/alaveteli,hasadna\/alaveteli,andreicristianpetcu\/alaveteli,nzherald\/alaveteli","old_file":"config\/varnish-alaveteli.vcl","new_file":"config\/varnish-alaveteli.vcl","new_contents":"# This is a sample VCL configuration file for varnish running in front\n# of Alaveteli. See the vcl(7) man page for details on VCL syntax and\n# semantics.\n\n# \n# Default backend definition. Set this to point to your content\n# server. In this case, apache + Passenger running on port 80\n# \n\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"80\";\n .connect_timeout = 600s;\n .first_byte_timeout = 600s;\n .between_bytes_timeout = 600s;\n}\n\n\/\/ set the servers alaveteli can issue a purge from\nacl purge {\n \"localhost\";\n \"127.0.0.1\";\n}\n\nsub vcl_recv {\n\n # Handle IPv6\n if (req.http.Host ~ \"^ipv6.*\") {\n set req.http.host = regsub(req.http.host, \"^ipv6\\.(.*)\",\"www\\.\\1\");\n }\n\n\n # Sanitise X-Forwarded-For...\n remove req.http.X-Forwarded-For;\n set req.http.X-Forwarded-For = client.ip;\n \n # Remove Google Analytics, has_js, and last-seen cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"(^|;\\s*)(__[a-z]+|has_js|has_seen_country_message|seen_foi2)=[^;]*\", \"\");\n\n # Normalize the Accept-Encoding header\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|flv|pdf|ico)$\") {\n # No point in compressing these\n remove req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n # unknown algorithm\n remove req.http.Accept-Encoding;\n }\n }\n \n # Ignore empty cookies\n if (req.http.Cookie ~ \"^\\s*$\") {\n remove req.http.Cookie;\n }\n \n if (req.request != \"GET\" &&\n req.request != \"HEAD\" && \n req.request != \"POST\" &&\n req.request != \"PUT\" &&\n req.request != \"PURGE\" &&\n req.request != \"DELETE\" ) {\n # We don't allow any other methods.\n error 405 \"Method Not Allowed\";\n }\n\n if (req.request != \"GET\" && req.request != \"HEAD\" && req.request != \"PURGE\") {\n \/* We only deal with GET and HEAD by default, the rest get passed direct to backend *\/\n return (pass);\n }\n \n # Ignore Cookies on images...\n if (req.url ~ \"\\.(png|gif|jpg|jpeg|swf|css|js|rdf|ico|txt)(\\?.*|)$\") {\n remove req.http.Cookie;\n return (lookup);\n }\n\n if (req.http.Authorization || req.http.Cookie) {\n return (pass);\n }\n # Let's have a little grace\n set req.grace = 30s;\n # Handle PURGE requests\n if (req.request == \"PURGE\") {\n if (!client.ip ~ purge) {\n error 405 \"Not allowed.\";\n }\n\n # For an explanation of the followng roundabout way of defining\n # ban lists, see\n # http:\/\/kristianlyng.wordpress.com\/2010\/07\/28\/smart-bans-with-varnish\/\n\n # XXX in Varnish 2.x, the following would be\n # purge(\"obj.http.x-url ~ \" req.url);\n ban(\"obj.http.x-url ~ \" + req.url);\n error 200 \"Banned\";\n }\n return (lookup);\n}\n\nsub vcl_fetch {\n set beresp.http.x-url = req.url;\n if (req.url ~ \"\\.(png|gif|jpg|jpeg|swf|css|js|rdf|ico|txt)(\\?.*|)$\") {\n # Ignore backend headers..\n remove beresp.http.set-Cookie;\n set beresp.ttl = 3600s;\n return (deliver);\n }\n\n if (beresp.status == 404 || beresp.status == 301 || beresp.status == 500) {\n set beresp.ttl = 1m;\n return (deliver);\n }\n}\n\n","old_contents":"# This is a sample VCL configuration file for varnish running in front\n# of Alaveteli. See the vcl(7) man page for details on VCL syntax and\n# semantics.\n\n# \n# Default backend definition. Set this to point to your content\n# server. In this case, apache + Passenger running on port 80\n# \n\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"80\";\n .connect_timeout = 600s;\n .first_byte_timeout = 600s;\n .between_bytes_timeout = 600s;\n}\n\n\/\/ set the servers alaveteli can issue a purge from\nacl purge {\n \"localhost\";\n \"127.0.0.1\";\n}\n\nsub vcl_recv {\n\n # Handle IPv6\n if (req.http.Host ~ \"^ipv6.*\") {\n set req.http.host = regsub(req.http.host, \"^ipv6\\.(.*)\",\"www\\.\\1\");\n }\n\n\n # Sanitise X-Forwarded-For...\n remove req.http.X-Forwarded-For;\n set req.http.X-Forwarded-For = client.ip;\n \n # Remove Google Analytics, has_js, and last-seen cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"(^|;\\s*)(__[a-z]+|has_js|has_seen_country_message|seen_foi2)=[^;]*\", \"\");\n\n # Normalize the Accept-Encoding header\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|flv|pdf|ico)$\") {\n # No point in compressing these\n remove req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n # unknown algorithm\n remove req.http.Accept-Encoding;\n }\n }\n \n # Ignore empty cookies\n if (req.http.Cookie ~ \"^\\s*$\") {\n remove req.http.Cookie;\n }\n \n if (req.request != \"GET\" &&\n req.request != \"HEAD\" && \n req.request != \"POST\" &&\n req.request != \"PUT\" &&\n req.request != \"PURGE\" &&\n req.request != \"DELETE\" ) {\n # We don't allow any other methods.\n error 405 \"Method Not Allowed\";\n }\n\n if (req.request != \"GET\" && req.request != \"HEAD\" && req.request != \"PURGE\") {\n \/* We only deal with GET and HEAD by default, the rest get passed direct to backend *\/\n return (pass);\n }\n \n # Ignore Cookies on images...\n if (req.url ~ \"\\.(png|gif|jpg|jpeg|swf|css|js|rdf|ico|txt)(\\?.*|)$\") {\n remove req.http.Cookie;\n return (lookup);\n }\n\n if (req.http.Authorization || req.http.Cookie) {\n return (pass);\n }\n # Let's have a little grace\n set req.grace = 30s;\n # Handle PURGE requests\n if (req.request == \"PURGE\") {\n if (!client.ip ~ purge) {\n error 405 \"Not allowed.\";\n }\n # XXX in Varnish 2.x, the following would be\n # purge(\"obj.http.x-url ~ \" req.url);\n ban(\"obj.http.x-url ~ \" + req.url);\n error 200 \"Banned\";\n }\n return (lookup);\n}\n\nsub vcl_fetch {\n set beresp.http.x-url = req.url;\n if (req.url ~ \"\\.(png|gif|jpg|jpeg|swf|css|js|rdf|ico|txt)(\\?.*|)$\") {\n # Ignore backend headers..\n remove beresp.http.set-Cookie;\n set beresp.ttl = 3600s;\n return (deliver);\n }\n\n if (beresp.status == 404 || beresp.status == 301 || beresp.status == 500) {\n set beresp.ttl = 1m;\n return (deliver);\n }\n}\n\n","returncode":0,"stderr":"","license":"agpl-3.0","lang":"VCL"} {"commit":"77d9ecae9bdca416912998d5461f6e3c0b6ae32a","subject":"use a single header to enable proxies such as ft.com-cdn to modify the header on their end (#1925)","message":"use a single header to enable proxies such as ft.com-cdn to modify the header on their end (#1925)\n\n","repos":"JakeChampion\/polyfill-service,JakeChampion\/polyfill-service","old_file":"fastly\/vcl\/polyfill-service.vcl","new_file":"fastly\/vcl\/polyfill-service.vcl","new_contents":"sub set_backend {\n\t# The Fastly macro is inserted before the backend is selected because the\n\t# macro has the code which defines the values avaiable for req.http.Host\n\t# but it also contains a default backend which is always set to the EU. I wish we could disable the default backend setting.\n\t#FASTLY recv\n\t\n\t# Calculate the ideal region to route the request to.\n \tdeclare local var.region STRING; \n\tif (server.region ~ \"(APAC|Asia|North-America|South-America|US-Central|US-East|US-West)\") {\n\t\tset var.region = \"US\";\n \t} else {\n\t\tset var.region = \"EU\";\n \t}\n\n\t# Gather the health of the shields and origins.\n\tdeclare local var.v3_eu_is_healthy BOOL;\n\tset req.backend = F_v3_eu;\n\tset var.v3_eu_is_healthy = req.backend.healthy;\n\n\tdeclare local var.v3_us_is_healthy BOOL;\n \tset req.backend = F_v3_us;\n \tset var.v3_us_is_healthy = req.backend.healthy;\n\n \tdeclare local var.shield_eu_is_healthy BOOL;\n \tset req.backend = ssl_shield_london_city_uk;\n \tset var.shield_eu_is_healthy = req.backend.healthy;\n\n \tdeclare local var.shield_us_is_healthy BOOL;\n \tset req.backend = ssl_shield_iad_va_us;\n \tset var.shield_us_is_healthy = req.backend.healthy;\n\n \t# Set some sort of default, that shouldn't get used.\n \tset req.backend = F_v3_eu;\n\n\tdeclare local var.EU_shield_server_name STRING;\n\tset var.EU_shield_server_name = \"LCY\";\n\n\tdeclare local var.US_shield_server_name STRING;\n\tset var.US_shield_server_name = \"IAD\";\n\n\t# Route EU requests to the nearest healthy shield or origin.\n \tif (var.region == \"EU\") {\n\t\tif (server.datacenter != var.EU_shield_server_name && req.http.Request_Came_From_Shield != var.EU_shield_server_name && var.shield_eu_is_healthy) {\n\t\t\tset req.backend = ssl_shield_london_city_uk;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t\tset req.http.Host = req.http.EU_Host;\n\t\t} elseif (var.shield_us_is_healthy) {\n\t\t\tset req.backend = ssl_shield_iad_va_us;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t\tset req.http.Host = req.http.US_Host;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_eu;\n\t\t}\n \t}\n\n\t# Route US requests to the nearest healthy shield or origin.\n \tif (var.region == \"US\") {\n\t\tif (server.datacenter != var.US_shield_server_name && req.http.Request_Came_From_Shield != var.US_shield_server_name && var.shield_us_is_healthy) {\n\t\t\tset req.backend = ssl_shield_iad_va_us;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t\tset req.http.Host = req.http.US_Host;\n\t\t} elseif (var.shield_eu_is_healthy) {\n\t\t\tset req.backend = ssl_shield_london_city_uk;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t\tset req.http.Host = req.http.EU_Host;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_us;\n\t\t}\n\t}\n\n\t# Persist the decision so we can debug the result.\n \tset req.http.Debug-Backend = req.backend;\n}\n\nsub vcl_recv {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_recv;\n\t}\n\n\tif (req.method != \"GET\" && req.method != \"HEAD\" && req.method != \"OPTIONS\" && req.method != \"FASTLYPURGE\" && req.method != \"PURGE\") {\n\t\terror 911;\n\t}\n\n\tif (req.method == \"OPTIONS\") {\n\t\terror 912;\n\t}\n\n\t# Because the old service had a router which allowed any words between \/v2\/polyfill. and .js\n\tif (req.url.path ~ \"^\/v2\/polyfill(\\.\\w+)(\\.\\w+)?\" && req.url.ext == \"js\") {\n\t\tif (re.group.2) {\n\t\t\tset req.url = \"\/v2\/polyfill.min.js?\" req.url.qs;\n\t\t} else {\n\t\t\tset req.url = \"\/v2\/polyfill.js?\" req.url.qs;\n\t\t}\n\t}\n\n\t# Override the v3 defaults with the defaults of v2\n\tif (req.url ~ \"^\/v2\/polyfill(\\.min)?\\.js\") {\n\t\tset req.url = regsub(req.url, \"^\/v2\", \"\/v3\");\n\t\tset req.url = querystring.set(req.url, \"version\", \"3.25.1\");\n\t\tdeclare local var.unknown STRING;\n\t\tset var.unknown = subfield(req.url.qs, \"unknown\", \"&\");\n\t\tset req.url = querystring.set(req.url, \"unknown\", if(var.unknown != \"\", var.unknown, \"ignore\"));\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\") {\n\t\tcall normalise_querystring_parameters_for_polyfill_bundle;\n\t\t# Sort the querystring parameters alphabetically to improve chances of hitting a cached copy.\n\t\t# If querystring is empty, remove the ? from the url.\n\t\tset req.url = querystring.clean(querystring.sort(req.url));\n\t\tcall set_backend;\n\t} else {\n\t\t# The request is to an endpoint which doesn't use query parameters, let's remove them to increase our cache-hit-ratio\n\t\tset req.url = querystring.remove(req.url);\n\t\tcall set_backend;\n\t}\n}\n\nsub vcl_hash {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_hash;\n\t}\n\n\t# We are not adding req.http.host to the hash because we want https:\/\/cdn.polyfill.io and https:\/\/polyfill.io to be a single object in the cache.\n\t# set req.hash += req.http.host;\n\tset req.hash += req.url;\n\t# We include return(hash) to stop the function falling through to the default VCL built into varnish, which for vcl_hash will add req.url and req.http.Host to the hash.\n\treturn(hash);\n}\n\n\nsub shielding_header {\n\tif (req.backend == ssl_shield_iad_va_us) {\n\t\tset req.http.Request_Came_From_Shield = server.datacenter;\n\t} elsif (req.backend == ssl_shield_london_city_uk) {\n\t\tset req.http.Request_Came_From_Shield = server.datacenter;\n\t}\n}\n\nsub vcl_miss {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_miss;\n\t}\n\tcall shielding_header;\n}\n\nsub vcl_pass {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_pass;\n\t}\n\tcall shielding_header;\n}\n\nsub vcl_fetch {\n\tset beresp.http.Request_Came_From_Shield = req.http.Request_Came_From_Shield;\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_fetch;\n\t}\n\n\t# These header are only required for HTML documents.\n\tif (beresp.http.Content-Type ~ \"text\/html\") {\n\t\t# Enables the cross-site scripting filter built into most modern web browsers.\n\t\tset beresp.http.X-XSS-Protection = \"1; mode=block\";\t\n\t}\n\t# Prevents MIME-sniffing a response away from the declared content type.\n\tset beresp.http.X-Content-Type-Options = \"nosniff\";\n\n\t# Ensure the site is only served over HTTPS and reduce the chances of someone performing a MITM attack.\n\tset beresp.http.Strict-Transport-Security = \"max-age=31536000; includeSubdomains; preload\";\n\n\t# The Referrer-Policy header governs which referrer information, sent in the Referer header, should be included with requests made.\n\t# Send a full URL when performing a same-origin request, but only send the origin of the document for other cases.\n\tset beresp.http.Referrer-Policy = \"origin-when-cross-origin\";\n\n\t# Enable purging of all objects in the Fastly cache by issuing a purge with the key \"polyfill-service\".\n\tif (beresp.http.Surrogate-Key !~ \"\\bpolyfill-service\\b\") {\n\t\tset beresp.http.Surrogate-Key = if(beresp.http.Surrogate-Key, beresp.http.Surrogate-Key \" polyfill-service\", \"polyfill-service\");\n\t}\n\n\tset beresp.http.Timing-Allow-Origin = \"*\";\n\n\tif (req.http.Normalized-User-Agent) {\n\t\tset beresp.http.Normalized-User-Agent = req.http.Normalized-User-Agent;\n\t\tset beresp.http.Detected-User-Agent = req.http.useragent_parser_family \"\/\" req.http.useragent_parser_major \".\" req.http.useragent_parser_minor \".\" req.http.useragent_parser_patch;\n\t}\n}\n\nsub vcl_deliver {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_deliver;\n\t}\n\n\tset req.http.Fastly-Force-Shield = \"yes\";\n\n\t# Allow cross origin GET, HEAD, and OPTIONS requests to be made.\n\tif (req.http.Origin) {\n\t\tset resp.http.Access-Control-Allow-Origin = \"*\";\n\t\tset resp.http.Access-Control-Allow-Methods = \"GET,HEAD,OPTIONS\";\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\" && !resp.http.Request_Came_From_Shield && req.backend != ssl_shield_iad_va_us && req.backend != ssl_shield_london_city_uk) {\n\t\t# Need to add \"Vary: User-Agent\" in after vcl_fetch to avoid the \n\t\t# \"Vary: User-Agent\" entering the Varnish cache.\n\t\t# We need \"Vary: User-Agent\" in the browser cache because a browser\n\t\t# may update itself to a version which needs different polyfills\n\t\t# So we need to have it ignore the browser cached bundle when the user-agent changes.\n\t\tset resp.http.Vary = \"User-Agent, Accept-Encoding\";\n\t}\n\n\tadd resp.http.Server-Timing = fastly_info.state {\", fastly;desc=\"Edge time\";dur=\"} time.elapsed.msec;\n\n\tif (req.http.Fastly-Debug) {\n\t\tset resp.http.Debug-Backend = req.http.Debug-Backend;\n\t\tset resp.http.Debug-Host = req.http.Host;\n\t\tset resp.http.Debug-Fastly-Restarts = req.restarts;\n\t\tset resp.http.Debug-Orig-URL = req.http.Orig-URL;\n\t\tset resp.http.Debug-VCL-Route = req.http.X-VCL-Route;\n\t\tset resp.http.useragent_parser_family = req.http.useragent_parser_family;\n\t\tset resp.http.useragent_parser_major = req.http.useragent_parser_major;\n\t\tset resp.http.useragent_parser_minor = req.http.useragent_parser_minor;\n\t\tset resp.http.useragent_parser_patch = req.http.useragent_parser_patch;\n\t} else {\n\t\tunset resp.http.Server;\n\t\tunset resp.http.Via;\n\t\tunset resp.http.X-Cache;\n\t\tunset resp.http.X-Cache-Hits;\n\t\tunset resp.http.X-Served-By;\n\t\tunset resp.http.X-Timer;\n\t\tunset resp.http.Fastly-Restarts;\n\t\tunset resp.http.X-PreFetch-Pass;\n\t\tunset resp.http.X-PreFetch-Miss;\n\t\tunset resp.http.X-PostFetch;\n\t}\n}\n\nsub vcl_error {\n\tif (obj.status == 911) {\n\t\tset obj.status = 405;\n\t\tset obj.response = \"METHOD NOT ALLOWED\";\n\t\tset obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n\t\tset obj.http.Cache-Control = \"private, no-store\";\n\t\tsynthetic req.method \" METHOD NOT ALLOWED\";\n\t\treturn (deliver);\n\t}\n\tif (obj.status == 912) {\n\t\tset obj.status = 200;\n\t\tset obj.response = \"OK\";\n\t\tset obj.http.Allow = \"OPTIONS, GET, HEAD\";\n\t\treturn (deliver);\n\t}\n}\n","old_contents":"sub set_backend {\n\t# The Fastly macro is inserted before the backend is selected because the\n\t# macro has the code which defines the values avaiable for req.http.Host\n\t# but it also contains a default backend which is always set to the EU. I wish we could disable the default backend setting.\n\t#FASTLY recv\n\t\n\t# Calculate the ideal region to route the request to.\n \tdeclare local var.region STRING; \n\tif (server.region ~ \"(APAC|Asia|North-America|South-America|US-Central|US-East|US-West)\") {\n\t\tset var.region = \"US\";\n \t} else {\n\t\tset var.region = \"EU\";\n \t}\n\n\t# Gather the health of the shields and origins.\n\tdeclare local var.v3_eu_is_healthy BOOL;\n\tset req.backend = F_v3_eu;\n\tset var.v3_eu_is_healthy = req.backend.healthy;\n\n\tdeclare local var.v3_us_is_healthy BOOL;\n \tset req.backend = F_v3_us;\n \tset var.v3_us_is_healthy = req.backend.healthy;\n\n \tdeclare local var.shield_eu_is_healthy BOOL;\n \tset req.backend = ssl_shield_london_city_uk;\n \tset var.shield_eu_is_healthy = req.backend.healthy;\n\n \tdeclare local var.shield_us_is_healthy BOOL;\n \tset req.backend = ssl_shield_iad_va_us;\n \tset var.shield_us_is_healthy = req.backend.healthy;\n\n \t# Set some sort of default, that shouldn't get used.\n \tset req.backend = F_v3_eu;\n\n\tdeclare local var.EU_shield_server_name STRING;\n\tset var.EU_shield_server_name = \"LCY\";\n\n\tdeclare local var.US_shield_server_name STRING;\n\tset var.US_shield_server_name = \"IAD\";\n\n\t# Route EU requests to the nearest healthy shield or origin.\n \tif (var.region == \"EU\") {\n\t\tif (server.datacenter != var.EU_shield_server_name && req.http.Request_Came_From_Shield != var.EU_shield_server_name && var.shield_eu_is_healthy) {\n\t\t\tset req.backend = ssl_shield_london_city_uk;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t\tset req.http.Host = req.http.EU_Host;\n\t\t} elseif (var.shield_us_is_healthy) {\n\t\t\tset req.backend = ssl_shield_iad_va_us;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t\tset req.http.Host = req.http.US_Host;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_eu;\n\t\t}\n \t}\n\n\t# Route US requests to the nearest healthy shield or origin.\n \tif (var.region == \"US\") {\n\t\tif (server.datacenter != var.US_shield_server_name && req.http.Request_Came_From_Shield != var.US_shield_server_name && var.shield_us_is_healthy) {\n\t\t\tset req.backend = ssl_shield_iad_va_us;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t\tset req.http.Host = req.http.US_Host;\n\t\t} elseif (var.shield_eu_is_healthy) {\n\t\t\tset req.backend = ssl_shield_london_city_uk;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t\tset req.http.Host = req.http.EU_Host;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_us;\n\t\t}\n\t}\n\n\t# Persist the decision so we can debug the result.\n \tset req.http.Debug-Backend = req.backend;\n}\n\nsub vcl_recv {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_recv;\n\t}\n\n\tif (req.method != \"GET\" && req.method != \"HEAD\" && req.method != \"OPTIONS\" && req.method != \"FASTLYPURGE\" && req.method != \"PURGE\") {\n\t\terror 911;\n\t}\n\n\tif (req.method == \"OPTIONS\") {\n\t\terror 912;\n\t}\n\n\t# Because the old service had a router which allowed any words between \/v2\/polyfill. and .js\n\tif (req.url.path ~ \"^\/v2\/polyfill(\\.\\w+)(\\.\\w+)?\" && req.url.ext == \"js\") {\n\t\tif (re.group.2) {\n\t\t\tset req.url = \"\/v2\/polyfill.min.js?\" req.url.qs;\n\t\t} else {\n\t\t\tset req.url = \"\/v2\/polyfill.js?\" req.url.qs;\n\t\t}\n\t}\n\n\t# Override the v3 defaults with the defaults of v2\n\tif (req.url ~ \"^\/v2\/polyfill(\\.min)?\\.js\") {\n\t\tset req.url = regsub(req.url, \"^\/v2\", \"\/v3\");\n\t\tset req.url = querystring.set(req.url, \"version\", \"3.25.1\");\n\t\tdeclare local var.unknown STRING;\n\t\tset var.unknown = subfield(req.url.qs, \"unknown\", \"&\");\n\t\tset req.url = querystring.set(req.url, \"unknown\", if(var.unknown != \"\", var.unknown, \"ignore\"));\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\") {\n\t\tcall normalise_querystring_parameters_for_polyfill_bundle;\n\t\t# Sort the querystring parameters alphabetically to improve chances of hitting a cached copy.\n\t\t# If querystring is empty, remove the ? from the url.\n\t\tset req.url = querystring.clean(querystring.sort(req.url));\n\t\tcall set_backend;\n\t} else {\n\t\t# The request is to an endpoint which doesn't use query parameters, let's remove them to increase our cache-hit-ratio\n\t\tset req.url = querystring.remove(req.url);\n\t\tcall set_backend;\n\t}\n}\n\nsub vcl_hash {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_hash;\n\t}\n\n\t# We are not adding req.http.host to the hash because we want https:\/\/cdn.polyfill.io and https:\/\/polyfill.io to be a single object in the cache.\n\t# set req.hash += req.http.host;\n\tset req.hash += req.url;\n\t# We include return(hash) to stop the function falling through to the default VCL built into varnish, which for vcl_hash will add req.url and req.http.Host to the hash.\n\treturn(hash);\n}\n\n\nsub shielding_header {\n\tif (req.backend == ssl_shield_iad_va_us) {\n\t\tset req.http.Request_Came_From_Shield = server.datacenter;\n\t} elsif (req.backend == ssl_shield_london_city_uk) {\n\t\tset req.http.Request_Came_From_Shield = server.datacenter;\n\t}\n}\n\nsub vcl_miss {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_miss;\n\t}\n\tcall shielding_header;\n}\n\nsub vcl_pass {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_pass;\n\t}\n\tcall shielding_header;\n}\n\nsub vcl_fetch {\n\tset beresp.http.Request_Came_From_Shield = req.http.Request_Came_From_Shield;\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_fetch;\n\t}\n\n\t# These header are only required for HTML documents.\n\tif (beresp.http.Content-Type ~ \"text\/html\") {\n\t\t# Enables the cross-site scripting filter built into most modern web browsers.\n\t\tset beresp.http.X-XSS-Protection = \"1; mode=block\";\t\n\t}\n\t# Prevents MIME-sniffing a response away from the declared content type.\n\tset beresp.http.X-Content-Type-Options = \"nosniff\";\n\n\t# Ensure the site is only served over HTTPS and reduce the chances of someone performing a MITM attack.\n\tset beresp.http.Strict-Transport-Security = \"max-age=31536000; includeSubdomains; preload\";\n\n\t# The Referrer-Policy header governs which referrer information, sent in the Referer header, should be included with requests made.\n\t# Send a full URL when performing a same-origin request, but only send the origin of the document for other cases.\n\tset beresp.http.Referrer-Policy = \"origin-when-cross-origin\";\n\n\t# Enable purging of all objects in the Fastly cache by issuing a purge with the key \"polyfill-service\".\n\tif (beresp.http.Surrogate-Key !~ \"\\bpolyfill-service\\b\") {\n\t\tset beresp.http.Surrogate-Key = if(beresp.http.Surrogate-Key, beresp.http.Surrogate-Key \" polyfill-service\", \"polyfill-service\");\n\t}\n\n\tset beresp.http.Timing-Allow-Origin = \"*\";\n\n\tif (req.http.Normalized-User-Agent) {\n\t\tset beresp.http.Normalized-User-Agent = req.http.Normalized-User-Agent;\n\t\tset beresp.http.Detected-User-Agent = req.http.useragent_parser_family \"\/\" req.http.useragent_parser_major \".\" req.http.useragent_parser_minor \".\" req.http.useragent_parser_patch;\n\t}\n}\n\nsub vcl_deliver {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_deliver;\n\t}\n\n\tset req.http.Fastly-Force-Shield = \"yes\";\n\n\t# Allow cross origin GET, HEAD, and OPTIONS requests to be made.\n\tif (req.http.Origin) {\n\t\tset resp.http.Access-Control-Allow-Origin = \"*\";\n\t\tset resp.http.Access-Control-Allow-Methods = \"GET,HEAD,OPTIONS\";\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\" && !resp.http.Request_Came_From_Shield && req.backend != ssl_shield_iad_va_us && req.backend != ssl_shield_london_city_uk) {\n\t\t# Need to add \"Vary: User-Agent\" in after vcl_fetch to avoid the \n\t\t# \"Vary: User-Agent\" entering the Varnish cache.\n\t\t# We need \"Vary: User-Agent\" in the browser cache because a browser\n\t\t# may update itself to a version which needs different polyfills\n\t\t# So we need to have it ignore the browser cached bundle when the user-agent changes.\n\t\tadd resp.http.Vary = \"User-Agent\";\n\t\tadd resp.http.Vary = \"Accept-Encoding\";\n\t}\n\n\tadd resp.http.Server-Timing = fastly_info.state {\", fastly;desc=\"Edge time\";dur=\"} time.elapsed.msec;\n\n\tif (req.http.Fastly-Debug) {\n\t\tset resp.http.Debug-Backend = req.http.Debug-Backend;\n\t\tset resp.http.Debug-Host = req.http.Host;\n\t\tset resp.http.Debug-Fastly-Restarts = req.restarts;\n\t\tset resp.http.Debug-Orig-URL = req.http.Orig-URL;\n\t\tset resp.http.Debug-VCL-Route = req.http.X-VCL-Route;\n\t\tset resp.http.useragent_parser_family = req.http.useragent_parser_family;\n\t\tset resp.http.useragent_parser_major = req.http.useragent_parser_major;\n\t\tset resp.http.useragent_parser_minor = req.http.useragent_parser_minor;\n\t\tset resp.http.useragent_parser_patch = req.http.useragent_parser_patch;\n\t} else {\n\t\tunset resp.http.Server;\n\t\tunset resp.http.Via;\n\t\tunset resp.http.X-Cache;\n\t\tunset resp.http.X-Cache-Hits;\n\t\tunset resp.http.X-Served-By;\n\t\tunset resp.http.X-Timer;\n\t\tunset resp.http.Fastly-Restarts;\n\t\tunset resp.http.X-PreFetch-Pass;\n\t\tunset resp.http.X-PreFetch-Miss;\n\t\tunset resp.http.X-PostFetch;\n\t}\n}\n\nsub vcl_error {\n\tif (obj.status == 911) {\n\t\tset obj.status = 405;\n\t\tset obj.response = \"METHOD NOT ALLOWED\";\n\t\tset obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n\t\tset obj.http.Cache-Control = \"private, no-store\";\n\t\tsynthetic req.method \" METHOD NOT ALLOWED\";\n\t\treturn (deliver);\n\t}\n\tif (obj.status == 912) {\n\t\tset obj.status = 200;\n\t\tset obj.response = \"OK\";\n\t\tset obj.http.Allow = \"OPTIONS, GET, HEAD\";\n\t\treturn (deliver);\n\t}\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"c15fe9079118111067cf43d1b0eefac5ddd4d8da","subject":"add referer_domain header for use in finding out what domains are using polyfill-service","message":"add referer_domain header for use in finding out what domains are using polyfill-service\n","repos":"JakeChampion\/polyfill-service,JakeChampion\/polyfill-service","old_file":"fastly\/vcl\/polyfill-service.vcl","new_file":"fastly\/vcl\/polyfill-service.vcl","new_contents":"sub set_backend {\n\t# The Fastly macro is inserted before the backend is selected because the\n\t# macro has the code which defines the values avaiable for req.http.Host\n\t# but it also contains a default backend which is always set to the EU. I wish we could disable the default backend setting.\n\t#FASTLY recv\n\t\n\t# Calculate the ideal region to route the request to.\n \tdeclare local var.region STRING; \n\tif (server.region ~ \"(APAC|Asia|North-America|South-America|US-Central|US-East|US-West)\") {\n\t\tset var.region = \"US\";\n \t} else {\n\t\tset var.region = \"EU\";\n \t}\n\n\t# Gather the health of the shields and origins.\n\tdeclare local var.v3_eu_is_healthy BOOL;\n\tset req.backend = F_v3_eu;\n\tset var.v3_eu_is_healthy = req.backend.healthy;\n\n\tdeclare local var.v3_us_is_healthy BOOL;\n \tset req.backend = F_v3_us;\n \tset var.v3_us_is_healthy = req.backend.healthy;\n\n \tdeclare local var.shield_eu_is_healthy BOOL;\n \tset req.backend = ssl_shield_london_city_uk;\n \tset var.shield_eu_is_healthy = req.backend.healthy;\n\n \tdeclare local var.shield_us_is_healthy BOOL;\n \tset req.backend = ssl_shield_iad_va_us;\n \tset var.shield_us_is_healthy = req.backend.healthy;\n\n \t# Set some sort of default, that shouldn't get used.\n \tset req.backend = F_v3_eu;\n\n\tdeclare local var.EU_shield_server_name STRING;\n\tset var.EU_shield_server_name = \"LCY\";\n\n\tdeclare local var.US_shield_server_name STRING;\n\tset var.US_shield_server_name = \"IAD\";\n\n\t# Route EU requests to the nearest healthy shield or origin.\n \tif (var.region == \"EU\") {\n\t\tif (server.datacenter != var.EU_shield_server_name && req.http.Request_Came_From_Shield != var.EU_shield_server_name && var.shield_eu_is_healthy) {\n\t\t\tset req.backend = ssl_shield_london_city_uk;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t\tset req.http.Host = req.http.EU_Host;\n\t\t} elseif (var.shield_us_is_healthy) {\n\t\t\tset req.backend = ssl_shield_iad_va_us;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t\tset req.http.Host = req.http.US_Host;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_eu;\n\t\t}\n \t}\n\n\t# Route US requests to the nearest healthy shield or origin.\n \tif (var.region == \"US\") {\n\t\tif (server.datacenter != var.US_shield_server_name && req.http.Request_Came_From_Shield != var.US_shield_server_name && var.shield_us_is_healthy) {\n\t\t\tset req.backend = ssl_shield_iad_va_us;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t\tset req.http.Host = req.http.US_Host;\n\t\t} elseif (var.shield_eu_is_healthy) {\n\t\t\tset req.backend = ssl_shield_london_city_uk;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t\tset req.http.Host = req.http.EU_Host;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_us;\n\t\t}\n\t}\n\n\t# Persist the decision so we can debug the result.\n \tset req.http.Debug-Backend = req.backend;\n}\n\nsub vcl_recv {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_recv;\n\t}\n\n\tif (req.method != \"GET\" && req.method != \"HEAD\" && req.method != \"OPTIONS\" && req.method != \"FASTLYPURGE\" && req.method != \"PURGE\") {\n\t\terror 911;\n\t}\n\n\tif (req.method == \"OPTIONS\") {\n\t\terror 912;\n\t}\n\n\t# Because the old service had a router which allowed any words between \/v2\/polyfill. and .js\n\tif (req.url.path ~ \"^\/v2\/polyfill(\\.\\w+)(\\.\\w+)?\" && req.url.ext == \"js\") {\n\t\tif (re.group.2) {\n\t\t\tset req.url = \"\/v2\/polyfill.min.js?\" req.url.qs;\n\t\t} else {\n\t\t\tset req.url = \"\/v2\/polyfill.js?\" req.url.qs;\n\t\t}\n\t}\n\n\t# Override the v3 defaults with the defaults of v2\n\tif (req.url ~ \"^\/v2\/polyfill(\\.min)?\\.js\") {\n\t\tset req.url = regsub(req.url, \"^\/v2\", \"\/v3\");\n\t\tset req.url = querystring.set(req.url, \"version\", \"3.25.1\");\n\t\tdeclare local var.unknown STRING;\n\t\tset var.unknown = subfield(req.url.qs, \"unknown\", \"&\");\n\t\tset req.url = querystring.set(req.url, \"unknown\", if(var.unknown != \"\", var.unknown, \"ignore\"));\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\") {\n\t\tcall normalise_querystring_parameters_for_polyfill_bundle;\n\t\t# Sort the querystring parameters alphabetically to improve chances of hitting a cached copy.\n\t\t# If querystring is empty, remove the ? from the url.\n\t\tset req.url = querystring.clean(querystring.sort(req.url));\n\t\tcall set_backend;\n\t} else {\n\t\t# The request is to an endpoint which doesn't use query parameters, let's remove them to increase our cache-hit-ratio\n\t\tset req.url = querystring.remove(req.url);\n\t\tcall set_backend;\n\t}\n\t\n\tif (req.backend == ssl_shield_iad_va_us || req.backend == ssl_shield_london_city_uk) {\n\t\t# avoid passing stale content from Shield POP to Edge POP\n\t\tset req.max_stale_while_revalidate = 0s;\n\t} else {\n\t\tset req.http.referer_domain = if(req.http.referer ~ \"^https?\\:\\\/\\\/([^\\\/:?#]+)(?:[\\\/:?#]|$)\", re.group.1, \"\");\n\t}\n}\n\nsub vcl_hash {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_hash;\n\t}\n\n\t# We are not adding req.http.host to the hash because we want https:\/\/cdn.polyfill.io and https:\/\/polyfill.io to be a single object in the cache.\n\t# set req.hash += req.http.host;\n\tset req.hash += req.url;\n\t# We include return(hash) to stop the function falling through to the default VCL built into varnish, which for vcl_hash will add req.url and req.http.Host to the hash.\n\treturn(hash);\n}\n\n\nsub shielding_header {\n\tif (req.backend == ssl_shield_iad_va_us) {\n\t\tset req.http.Request_Came_From_Shield = server.datacenter;\n\t} elsif (req.backend == ssl_shield_london_city_uk) {\n\t\tset req.http.Request_Came_From_Shield = server.datacenter;\n\t}\n}\n\nsub vcl_miss {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_miss;\n\t}\n\tcall shielding_header;\n}\n\nsub vcl_pass {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_pass;\n\t}\n\tcall shielding_header;\n}\n\nsub vcl_fetch {\n\tset beresp.http.Request_Came_From_Shield = req.http.Request_Came_From_Shield;\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_fetch;\n\t}\n\n\t# These header are only required for HTML documents.\n\tif (beresp.http.Content-Type ~ \"text\/html\") {\n\t\t# Enables the cross-site scripting filter built into most modern web browsers.\n\t\tset beresp.http.X-XSS-Protection = \"1; mode=block\";\t\n\t}\n\t# Prevents MIME-sniffing a response away from the declared content type.\n\tset beresp.http.X-Content-Type-Options = \"nosniff\";\n\n\t# Ensure the site is only served over HTTPS and reduce the chances of someone performing a MITM attack.\n\tset beresp.http.Strict-Transport-Security = \"max-age=31536000; includeSubdomains; preload\";\n\n\t# The Referrer-Policy header governs which referrer information, sent in the Referer header, should be included with requests made.\n\t# Send a full URL when performing a same-origin request, but only send the origin of the document for other cases.\n\tset beresp.http.Referrer-Policy = \"origin-when-cross-origin\";\n\n\t# Enable purging of all objects in the Fastly cache by issuing a purge with the key \"polyfill-service\".\n\tif (beresp.http.Surrogate-Key !~ \"\\bpolyfill-service\\b\") {\n\t\tset beresp.http.Surrogate-Key = if(beresp.http.Surrogate-Key, beresp.http.Surrogate-Key \" polyfill-service\", \"polyfill-service\");\n\t}\n\n\tset beresp.http.Timing-Allow-Origin = \"*\";\n\n\tif (req.http.Normalized-User-Agent) {\n\t\tset beresp.http.Normalized-User-Agent = req.http.Normalized-User-Agent;\n\t\tset beresp.http.Detected-User-Agent = req.http.useragent_parser_family \"\/\" req.http.useragent_parser_major \".\" req.http.useragent_parser_minor \".\" req.http.useragent_parser_patch;\n\t}\n}\n\nsub vcl_deliver {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_deliver;\n\t}\n\n\tset req.http.Fastly-Force-Shield = \"yes\";\n\n\t# Allow cross origin GET, HEAD, and OPTIONS requests to be made.\n\tif (req.http.Origin) {\n\t\tset resp.http.Access-Control-Allow-Origin = \"*\";\n\t\tset resp.http.Access-Control-Allow-Methods = \"GET,HEAD,OPTIONS\";\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\" && !resp.http.Request_Came_From_Shield && req.backend != ssl_shield_iad_va_us && req.backend != ssl_shield_london_city_uk) {\n\t\t# Need to add \"Vary: User-Agent\" in after vcl_fetch to avoid the \n\t\t# \"Vary: User-Agent\" entering the Varnish cache.\n\t\t# We need \"Vary: User-Agent\" in the browser cache because a browser\n\t\t# may update itself to a version which needs different polyfills\n\t\t# So we need to have it ignore the browser cached bundle when the user-agent changes.\n\t\tset resp.http.Vary = \"User-Agent, Accept-Encoding\";\n\t}\n\n\tadd resp.http.Server-Timing = fastly_info.state {\", fastly;desc=\"Edge time\";dur=\"} time.elapsed.msec;\n\n\tif (req.http.Fastly-Debug) {\n\t\tset resp.http.Debug-Backend = req.http.Debug-Backend;\n\t\tset resp.http.Debug-Host = req.http.Host;\n\t\tset resp.http.Debug-Fastly-Restarts = req.restarts;\n\t\tset resp.http.Debug-Orig-URL = req.http.Orig-URL;\n\t\tset resp.http.Debug-VCL-Route = req.http.X-VCL-Route;\n\t\tset resp.http.useragent_parser_family = req.http.useragent_parser_family;\n\t\tset resp.http.useragent_parser_major = req.http.useragent_parser_major;\n\t\tset resp.http.useragent_parser_minor = req.http.useragent_parser_minor;\n\t\tset resp.http.useragent_parser_patch = req.http.useragent_parser_patch;\n\t} else {\n\t\tunset resp.http.Server;\n\t\tunset resp.http.Via;\n\t\tunset resp.http.X-Cache;\n\t\tunset resp.http.X-Cache-Hits;\n\t\tunset resp.http.X-Served-By;\n\t\tunset resp.http.X-Timer;\n\t\tunset resp.http.Fastly-Restarts;\n\t\tunset resp.http.X-PreFetch-Pass;\n\t\tunset resp.http.X-PreFetch-Miss;\n\t\tunset resp.http.X-PostFetch;\n\t}\n}\n\nsub vcl_error {\n\tif (obj.status == 911) {\n\t\tset obj.status = 405;\n\t\tset obj.response = \"METHOD NOT ALLOWED\";\n\t\tset obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n\t\tset obj.http.Cache-Control = \"private, no-store\";\n\t\tsynthetic req.method \" METHOD NOT ALLOWED\";\n\t\treturn (deliver);\n\t}\n\tif (obj.status == 912) {\n\t\tset obj.status = 200;\n\t\tset obj.response = \"OK\";\n\t\tset obj.http.Allow = \"OPTIONS, GET, HEAD\";\n\t\treturn (deliver);\n\t}\n}\n","old_contents":"sub set_backend {\n\t# The Fastly macro is inserted before the backend is selected because the\n\t# macro has the code which defines the values avaiable for req.http.Host\n\t# but it also contains a default backend which is always set to the EU. I wish we could disable the default backend setting.\n\t#FASTLY recv\n\t\n\t# Calculate the ideal region to route the request to.\n \tdeclare local var.region STRING; \n\tif (server.region ~ \"(APAC|Asia|North-America|South-America|US-Central|US-East|US-West)\") {\n\t\tset var.region = \"US\";\n \t} else {\n\t\tset var.region = \"EU\";\n \t}\n\n\t# Gather the health of the shields and origins.\n\tdeclare local var.v3_eu_is_healthy BOOL;\n\tset req.backend = F_v3_eu;\n\tset var.v3_eu_is_healthy = req.backend.healthy;\n\n\tdeclare local var.v3_us_is_healthy BOOL;\n \tset req.backend = F_v3_us;\n \tset var.v3_us_is_healthy = req.backend.healthy;\n\n \tdeclare local var.shield_eu_is_healthy BOOL;\n \tset req.backend = ssl_shield_london_city_uk;\n \tset var.shield_eu_is_healthy = req.backend.healthy;\n\n \tdeclare local var.shield_us_is_healthy BOOL;\n \tset req.backend = ssl_shield_iad_va_us;\n \tset var.shield_us_is_healthy = req.backend.healthy;\n\n \t# Set some sort of default, that shouldn't get used.\n \tset req.backend = F_v3_eu;\n\n\tdeclare local var.EU_shield_server_name STRING;\n\tset var.EU_shield_server_name = \"LCY\";\n\n\tdeclare local var.US_shield_server_name STRING;\n\tset var.US_shield_server_name = \"IAD\";\n\n\t# Route EU requests to the nearest healthy shield or origin.\n \tif (var.region == \"EU\") {\n\t\tif (server.datacenter != var.EU_shield_server_name && req.http.Request_Came_From_Shield != var.EU_shield_server_name && var.shield_eu_is_healthy) {\n\t\t\tset req.backend = ssl_shield_london_city_uk;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t\tset req.http.Host = req.http.EU_Host;\n\t\t} elseif (var.shield_us_is_healthy) {\n\t\t\tset req.backend = ssl_shield_iad_va_us;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t\tset req.http.Host = req.http.US_Host;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_eu;\n\t\t}\n \t}\n\n\t# Route US requests to the nearest healthy shield or origin.\n \tif (var.region == \"US\") {\n\t\tif (server.datacenter != var.US_shield_server_name && req.http.Request_Came_From_Shield != var.US_shield_server_name && var.shield_us_is_healthy) {\n\t\t\tset req.backend = ssl_shield_iad_va_us;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t\tset req.http.Host = req.http.US_Host;\n\t\t} elseif (var.shield_eu_is_healthy) {\n\t\t\tset req.backend = ssl_shield_london_city_uk;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t\tset req.http.Host = req.http.EU_Host;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_us;\n\t\t}\n\t}\n\n\t# Persist the decision so we can debug the result.\n \tset req.http.Debug-Backend = req.backend;\n}\n\nsub vcl_recv {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_recv;\n\t}\n\n\tif (req.method != \"GET\" && req.method != \"HEAD\" && req.method != \"OPTIONS\" && req.method != \"FASTLYPURGE\" && req.method != \"PURGE\") {\n\t\terror 911;\n\t}\n\n\tif (req.method == \"OPTIONS\") {\n\t\terror 912;\n\t}\n\n\t# Because the old service had a router which allowed any words between \/v2\/polyfill. and .js\n\tif (req.url.path ~ \"^\/v2\/polyfill(\\.\\w+)(\\.\\w+)?\" && req.url.ext == \"js\") {\n\t\tif (re.group.2) {\n\t\t\tset req.url = \"\/v2\/polyfill.min.js?\" req.url.qs;\n\t\t} else {\n\t\t\tset req.url = \"\/v2\/polyfill.js?\" req.url.qs;\n\t\t}\n\t}\n\n\t# Override the v3 defaults with the defaults of v2\n\tif (req.url ~ \"^\/v2\/polyfill(\\.min)?\\.js\") {\n\t\tset req.url = regsub(req.url, \"^\/v2\", \"\/v3\");\n\t\tset req.url = querystring.set(req.url, \"version\", \"3.25.1\");\n\t\tdeclare local var.unknown STRING;\n\t\tset var.unknown = subfield(req.url.qs, \"unknown\", \"&\");\n\t\tset req.url = querystring.set(req.url, \"unknown\", if(var.unknown != \"\", var.unknown, \"ignore\"));\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\") {\n\t\tcall normalise_querystring_parameters_for_polyfill_bundle;\n\t\t# Sort the querystring parameters alphabetically to improve chances of hitting a cached copy.\n\t\t# If querystring is empty, remove the ? from the url.\n\t\tset req.url = querystring.clean(querystring.sort(req.url));\n\t\tcall set_backend;\n\t} else {\n\t\t# The request is to an endpoint which doesn't use query parameters, let's remove them to increase our cache-hit-ratio\n\t\tset req.url = querystring.remove(req.url);\n\t\tcall set_backend;\n\t}\n\t\n\tif (req.backend == ssl_shield_iad_va_us || req.backend == ssl_shield_london_city_uk) {\n\t\t# avoid passing stale content from Shield POP to Edge POP\n\t\tset req.max_stale_while_revalidate = 0s;\n\t}\n}\n\nsub vcl_hash {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_hash;\n\t}\n\n\t# We are not adding req.http.host to the hash because we want https:\/\/cdn.polyfill.io and https:\/\/polyfill.io to be a single object in the cache.\n\t# set req.hash += req.http.host;\n\tset req.hash += req.url;\n\t# We include return(hash) to stop the function falling through to the default VCL built into varnish, which for vcl_hash will add req.url and req.http.Host to the hash.\n\treturn(hash);\n}\n\n\nsub shielding_header {\n\tif (req.backend == ssl_shield_iad_va_us) {\n\t\tset req.http.Request_Came_From_Shield = server.datacenter;\n\t} elsif (req.backend == ssl_shield_london_city_uk) {\n\t\tset req.http.Request_Came_From_Shield = server.datacenter;\n\t}\n}\n\nsub vcl_miss {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_miss;\n\t}\n\tcall shielding_header;\n}\n\nsub vcl_pass {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_pass;\n\t}\n\tcall shielding_header;\n}\n\nsub vcl_fetch {\n\tset beresp.http.Request_Came_From_Shield = req.http.Request_Came_From_Shield;\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_fetch;\n\t}\n\n\t# These header are only required for HTML documents.\n\tif (beresp.http.Content-Type ~ \"text\/html\") {\n\t\t# Enables the cross-site scripting filter built into most modern web browsers.\n\t\tset beresp.http.X-XSS-Protection = \"1; mode=block\";\t\n\t}\n\t# Prevents MIME-sniffing a response away from the declared content type.\n\tset beresp.http.X-Content-Type-Options = \"nosniff\";\n\n\t# Ensure the site is only served over HTTPS and reduce the chances of someone performing a MITM attack.\n\tset beresp.http.Strict-Transport-Security = \"max-age=31536000; includeSubdomains; preload\";\n\n\t# The Referrer-Policy header governs which referrer information, sent in the Referer header, should be included with requests made.\n\t# Send a full URL when performing a same-origin request, but only send the origin of the document for other cases.\n\tset beresp.http.Referrer-Policy = \"origin-when-cross-origin\";\n\n\t# Enable purging of all objects in the Fastly cache by issuing a purge with the key \"polyfill-service\".\n\tif (beresp.http.Surrogate-Key !~ \"\\bpolyfill-service\\b\") {\n\t\tset beresp.http.Surrogate-Key = if(beresp.http.Surrogate-Key, beresp.http.Surrogate-Key \" polyfill-service\", \"polyfill-service\");\n\t}\n\n\tset beresp.http.Timing-Allow-Origin = \"*\";\n\n\tif (req.http.Normalized-User-Agent) {\n\t\tset beresp.http.Normalized-User-Agent = req.http.Normalized-User-Agent;\n\t\tset beresp.http.Detected-User-Agent = req.http.useragent_parser_family \"\/\" req.http.useragent_parser_major \".\" req.http.useragent_parser_minor \".\" req.http.useragent_parser_patch;\n\t}\n}\n\nsub vcl_deliver {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_deliver;\n\t}\n\n\tset req.http.Fastly-Force-Shield = \"yes\";\n\n\t# Allow cross origin GET, HEAD, and OPTIONS requests to be made.\n\tif (req.http.Origin) {\n\t\tset resp.http.Access-Control-Allow-Origin = \"*\";\n\t\tset resp.http.Access-Control-Allow-Methods = \"GET,HEAD,OPTIONS\";\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\" && !resp.http.Request_Came_From_Shield && req.backend != ssl_shield_iad_va_us && req.backend != ssl_shield_london_city_uk) {\n\t\t# Need to add \"Vary: User-Agent\" in after vcl_fetch to avoid the \n\t\t# \"Vary: User-Agent\" entering the Varnish cache.\n\t\t# We need \"Vary: User-Agent\" in the browser cache because a browser\n\t\t# may update itself to a version which needs different polyfills\n\t\t# So we need to have it ignore the browser cached bundle when the user-agent changes.\n\t\tset resp.http.Vary = \"User-Agent, Accept-Encoding\";\n\t}\n\n\tadd resp.http.Server-Timing = fastly_info.state {\", fastly;desc=\"Edge time\";dur=\"} time.elapsed.msec;\n\n\tif (req.http.Fastly-Debug) {\n\t\tset resp.http.Debug-Backend = req.http.Debug-Backend;\n\t\tset resp.http.Debug-Host = req.http.Host;\n\t\tset resp.http.Debug-Fastly-Restarts = req.restarts;\n\t\tset resp.http.Debug-Orig-URL = req.http.Orig-URL;\n\t\tset resp.http.Debug-VCL-Route = req.http.X-VCL-Route;\n\t\tset resp.http.useragent_parser_family = req.http.useragent_parser_family;\n\t\tset resp.http.useragent_parser_major = req.http.useragent_parser_major;\n\t\tset resp.http.useragent_parser_minor = req.http.useragent_parser_minor;\n\t\tset resp.http.useragent_parser_patch = req.http.useragent_parser_patch;\n\t} else {\n\t\tunset resp.http.Server;\n\t\tunset resp.http.Via;\n\t\tunset resp.http.X-Cache;\n\t\tunset resp.http.X-Cache-Hits;\n\t\tunset resp.http.X-Served-By;\n\t\tunset resp.http.X-Timer;\n\t\tunset resp.http.Fastly-Restarts;\n\t\tunset resp.http.X-PreFetch-Pass;\n\t\tunset resp.http.X-PreFetch-Miss;\n\t\tunset resp.http.X-PostFetch;\n\t}\n}\n\nsub vcl_error {\n\tif (obj.status == 911) {\n\t\tset obj.status = 405;\n\t\tset obj.response = \"METHOD NOT ALLOWED\";\n\t\tset obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n\t\tset obj.http.Cache-Control = \"private, no-store\";\n\t\tsynthetic req.method \" METHOD NOT ALLOWED\";\n\t\treturn (deliver);\n\t}\n\tif (obj.status == 912) {\n\t\tset obj.status = 200;\n\t\tset obj.response = \"OK\";\n\t\tset obj.http.Allow = \"OPTIONS, GET, HEAD\";\n\t\treturn (deliver);\n\t}\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"91891548b80d19e87b0e668ec5df7c517f622c20","subject":"remove zip from varnish, static files 1 day browser cache","message":"remove zip from varnish, static files 1 day browser cache\n","repos":"Arasaac\/dockerizePHPApp,Arasaac\/dockerizePHPApp,Arasaac\/dockerizePHPApp,Arasaac\/dockerizePHPApp,Arasaac\/dockerizePHPApp,Arasaac\/dockerizePHPApp","old_file":"varnish\/default.vcl","new_file":"varnish\/default.vcl","new_contents":"vcl 4.0;\n# Based on: https:\/\/github.com\/mattiasgeniar\/varnish-4.0-configuration-templates\/blob\/master\/\nimport std;\nimport directors;\n\nbackend server1 { # Define one backend\n .host = \"{VARNISH_BACKEND_HOST}\";\n .port = \"{VARNISH_BACKEND_PORT}\";\n .max_connections = 300; # That's it\n\n .probe = {\n #.url = \"\/\"; # short easy way (GET \/)\n # We prefer to only do a HEAD \/\n .request =\n \"HEAD \/ HTTP\/1.1\"\n \"Host: arasaac\"\n \"Connection: close\"\n \"User-Agent: Varnish Health Probe\";\n\n .interval = 5s; # check the health of each backend every 5 seconds\n .timeout = 3s; # timing out after 1 second.\n .window = 5; # If 3 out of the last 5 polls succeeded the backend is considered healthy, otherwise it will be marked as sick\n .threshold = 3;\n }\n\n .first_byte_timeout = 3s; # How long to wait before we receive a first byte from our backend?\n .connect_timeout = 5s; # How long to wait for a backend connection?\n .between_bytes_timeout = 2s; # How long to wait between bytes received from our backend?\n}\n\n#acl purge {\n # ACL we'll use later to allow purges\n# \"localhost\";\n# \"127.0.0.1\";\n# \"::1\";\n#}\n\nsub vcl_init {\n # Called when VCL is loaded, before any requests pass through it.\n # Typically used to initialize VMODs.\n\n new vdir = directors.round_robin();\n vdir.add_backend(server1);\n # vdir.add_backend(server...);\n # vdir.add_backend(servern);\n}\n\nsub vcl_recv {\n set req.backend_hint = vdir.backend(); # send all traffic to the vdir director\n\n # Normalize the header, remove the port (in case you're testing this on various TCP ports)\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n # Remove the proxy header (see https:\/\/httpoxy.org\/#mitigate-varnish)\n unset req.http.proxy;\n\n # when purging from php files, we need to send the request to varnish but process it as it were arasaac web server\n if ( req.http.host ~ \"varnish\" ) {\n set req.http.x-host = req.http.host;\n set req.http.host = \"www.arasaac.org\";\n }\n\n\n if (req.http.host ~ \"^arasaac.org\" || req.http.host ~ \"arasaac.net\" || req.http.host ~ \"arasaac.es\" ) {\n return (synth (750, \"\"));\n }\n if (req.url~ \"^\/index.php\") {\n set req.url = regsub(req.url, \"index.php\", \"\");\n } \n\n # Allow purging\n if (req.method == \"PURGE\") {\n# if (!client.ip ~ purge) { # purge is the ACL defined at the begining\n # Not from an allowed IP? Then die with an error.\n# return (synth(405, \"This IP is not allowed to send PURGE requests.\"));\n# }\n # If you got this stage (and didn't error out above), purge the cached result\n return (purge);\n }\n if (req.method == \"BAN\")\n {\n \/\/ TODO: Add client validation as needed\n ban(\"obj.http.x-url ~ \" + req.url);\n return(synth(901, \"BAN Set for \" + req.url));\n }\n \n #administration staff without cache \n if (req.url ~ \"inc\" || req.url ~ \"languages\" || req.url ~ \"gestionar_internacionalizacion.php\") {\n return (pass);\n }\n\n # Only deal with \"normal\" types\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"PATCH\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n # Implementing websocket support (https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html)\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n # Only cache GET or HEAD requests. This makes sure the POST requests are always passed.\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n\n set req.http.Cookie = regsuball(req.http.Cookie, \"has_js=[^;]+(; )?\", \"\");\n\n # Remove any Google Analytics based cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__utm.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"_ga=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"_gat=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmctr=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmcmd.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmccn.=[^;]+(; )?\", \"\");\n\n\n\n # Remove Arasaac Cookies for caching:\n\n if (!(req.url ~ \"product_id\" || req.url ~ \"n_elementos_cesto.php\" || req.url ~ \"herramientas\" || req.url ~ \"zip_cesto.php\" || req.url ~ \"carpeta_trabajo.php\" || req.url ~ \"admin.php\" || req.url ~ \"cesta.php\")) {\n set req.http.Cookie = regsuball(req.http.Cookie, \"PHPSESSID=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"preImg=x; \", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"; \", \";\");\n\n if (!(req.http.Cookie ~ \"selected_language\")) {\n if (req.http.Accept-Language ~ \"^en\") {\n set req.http.Cookie = \"selected_language=en;\";\n } elsif (req.http.Accept-Language ~ \"^es\") {\n set req.http.Cookie = \"selected_language=es;\";\n } elsif (req.http.Accept-Language ~ \"^fr\") {\n set req.http.Cookie = \"selected_language=fr;\";\n } elsif (req.http.Accept-Language ~ \"^ro\") {\n set req.http.Cookie = \"selected_language=ro;\";\n } elsif (req.http.Accept-Language ~ \"^pt\") {\n set req.http.Cookie = \"selected_language=pt;\";\n } elsif (req.http.Accept-Language ~ \"^br\") {\n set req.http.Cookie = \"selected_language=br;\";\n } else {\n # unknown language. Remove the accept-language header and\n # use the backend default.\n set req.http.Cookie = \"selected_language=en;\";\n }\n }\n }\n \n #unset req.http.cookie; \n # Remove DoubleClick offensive cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__gads=[^;]+(; )?\", \"\");\n\n # Remove the Quant Capital cookies (added by some plugin, all __qca)\n set req.http.Cookie = regsuball(req.http.Cookie, \"__qc.=[^;]+(; )?\", \"\");\n\n # Remove the AddThis cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__atuv.=[^;]+(; )?\", \"\");\n\n # Remove a \";\" prefix in the cookie if present\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n\n # Are there cookies left with only spaces or that are empty?\n if (req.http.Cookie ~ \"^\\s*$\") {\n unset req.http.Cookie;\n }\n\n # Remove all cookies for static files\n # A valid discussion could be held on this line: do you really need to cache static files that don't cause load? Only if you have memory left.\n # Sure, there's disk I\/O, but chances are your OS will already have these files in their buffers (thus memory).\n # Before you blindly enable this, have a read here: https:\/\/ma.ttias.be\/stop-caching-static-files\/\n if (req.url ~ \"^[^?]*\\.(avi|bmp|css|csv|doc|docx|flac|flv|gif|ico|jpeg|jpg|js|mov|mp3|mp4|mpeg|mpg|odt|otf|ogg|ogm|opus|pdf|png|ppt|pptx|rtf|svg|svgz|swf|ttf|txt|txz|wav|webm|webp|woff|woff2|xls|xlsx|xml|xz)(\\?.*)?$\") {\n unset req.http.Cookie;\n #return (pass);\n }\n if (req.url ~ \"^[^?]*\\.(7z|bz2|eot|gz|less|rar|tar|tbz|tgz|zip)(\\?.*)?$\") {\n #unset req.http.Cookie;\n return (pass);\n }\n \n #at the end because I need to remove previous cookies \n #if (req.url ~ \"purge.php\") {\n # return (pass);\n #}\n\n return (hash);\n}\n\nsub vcl_pipe {\n # Called upon entering pipe mode.\n # In this mode, the request is passed on to the backend, and any further data from both the client\n # and backend is passed on unaltered until either end closes the connection. Basically, Varnish will\n # degrade into a simple TCP proxy, shuffling bytes back and forth. For a connection in pipe mode,\n # no other VCL subroutine will ever get called after vcl_pipe.\n\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n # set bereq.http.connection = \"close\";\n # here. It is not set by default as it might break some broken web\n # applications, like IIS with NTLM authentication.\n\n # set bereq.http.Connection = \"Close\";\n\n # Implementing websocket support (https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html)\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n\n return (pipe);\n}\n\nsub vcl_pass {\n # Called upon entering pass mode. In this mode, the request is passed on to the backend, and the\n # backend's response is passed on to the client, but is not entered into the cache. Subsequent\n # requests submitted over the same client connection are handled normally.\n\n # return (pass);\n}\n\n# The data on which the hashing will take place\nsub vcl_hash {\n # Called after vcl_recv to create a hash value for the request. This is used as a key\n # to look up the object in Varnish.\n\n hash_data(req.url);\n\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n\n # hash cookies for requests that have them\n# if (req.http.Language) {\n #add cookie in hash\n# hash_data(req.http.Language);\n# }\n if (req.http.Cookie) {\n hash_data(req.http.Cookie);\n }\n #for debugging hash \n #std.log(\"######################################################################################################\");\n #std.log(req.http.Cookie + req.http.host + req.url);\n\n}\n\nsub vcl_hit {\n # Called when a cache lookup is successful.\n\n if (obj.ttl >= 0s) {\n # A pure unadultered hit, deliver it\n return (deliver);\n }\n\n # https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-grace.html\n # When several clients are requesting the same page Varnish will send one request to the backend and place the others on hold while fetching one copy from the backend. In some products this is called request coalescing and Varnish does this automatically.\n # If you are serving thousands of hits per second the queue of waiting requests can get huge. There are two potential problems - one is a thundering herd problem - suddenly releasing a thousand threads to serve content might send the load sky high. Secondly - nobody likes to wait. To deal with this we can instruct Varnish to keep the objects in cache beyond their TTL and to serve the waiting requests somewhat stale content.\n\n# if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n# return (deliver);\n# } else {\n# return (fetch);\n# }\n\n # We have no fresh fish. Lets look at the stale ones.\n if (std.healthy(req.backend_hint)) {\n # Backend is healthy. Limit age to 10s.\n if (obj.ttl + 10s > 0s) {\n #set req.http.grace = \"normal(limited)\";\n return (deliver);\n } else {\n # No candidate for grace. Fetch a fresh object.\n return(fetch);\n }\n } else {\n # backend is sick - use full grace\n if (obj.ttl + obj.grace > 0s) {\n #set req.http.grace = \"full\";\n return (deliver);\n } else {\n # no graced object.\n return (fetch);\n }\n }\n\n # fetch & deliver once we get the result\n return (fetch); # Dead code, keep as a safeguard\n}\n\nsub vcl_miss {\n # Called after a cache lookup if the requested document was not found in the cache. Its purpose\n # is to decide whether or not to attempt to retrieve the document from the backend, and which\n # backend to use.\n\n return (fetch);\n}\n\n# Handle the HTTP request coming from our backend\nsub vcl_backend_response {\n # Called after the response headers has been successfully retrieved from the backend.\n\n # Pause ESI request and remove Surrogate-Control header\n if (beresp.http.Surrogate-Control ~ \"ESI\/1.0\") {\n unset beresp.http.Surrogate-Control;\n set beresp.do_esi = true;\n }\n\n # Enable cache for all static files\n # The same argument as the static caches from above: monitor your cache size, if you get data nuked out of it, consider giving up the static file cache.\n # Before you blindly enable this, have a read here: https:\/\/ma.ttias.be\/stop-caching-static-files\/\n #if (bereq.url ~ \"^[^?]*\\.(7z|avi|bmp|bz2|css|csv|doc|docx|eot|flac|flv|gif|gz|ico|jpeg|jpg|js|less|mka|mkv|mov|mp3|mp4|mpeg|mpg|odt|otf|ogg|ogm|opus|pdf|png|ppt|pptx|rar|rtf|svg|svgz|swf|tar|tbz|tgz|ttf|txt|txz|wav|webm|webp|woff|woff2|xls|xlsx|xml|xz|zip)(\\?.*)?$\") {\n # unset beresp.http.set-cookie;\n #}\n \n if (bereq.url ~ \"^\/$\") {\n # en firefox a veces se cacheaba al cambiar el lenguaje dando datos erroneos\n set beresp.ttl = 86400s;\n set beresp.http.cache-control = \"public, max-age = 0\";\n unset beresp.http.set-cookie;\n return(deliver);\n }\n if (bereq.url ~ \"^[^?]*\\.(7z|bz2|eot|gz|less|rar|tar|tbz|tgz|zip)(\\?.*)?$\") {\n set beresp.http.cache-control = \"public, max-age = 86400\";\n unset beresp.http.Cookie;\n return (deliver);\n }\n\n if (bereq.url ~ \"^[^?]*\\.(7z|avi|bmp|bz2|css|csv|doc|docx|eot|flac|flv|gif|gz|ico|jpeg|jpg|js|less|mka|mkv|mov|mp3|mp4|mpeg|mpg|odt|otf|ogg|ogm|opus|pdf|png|ppt|pptx|rar|rtf|svg|svgz|swf|tar|tbz|tgz|ttf|txt|txz|wav|webm|webp|woff|woff2|xls|xlsx|xml|xz|zip)(\\?.*)?$\") {\n unset beresp.http.Cookie;\n set beresp.http.cache-control = \"public, max-age = 86400\";\n return (deliver);\n }\n \n #if (!(bereq.url ~ \"language_set.php\" || bereq.url ~ \"cesta.php\" || bereq.url ~ \"pictogramas_color.php\" || bereq.url ~ \"pictogramas_byn.php\"|| bereq.url ~ \"imagenes.php\" || bereq.url ~ \"videos_lse.php\" || bereq.url ~ \"signos_lse_color.php\" || bereq.url ~ \"buscar.php\" || bereq.url ~ \"n_elementos_cesto.php\" || bereq.url ~ \"herramientas\" || bereq.url ~ \"zip_cesto.php\" || bereq.url ~ \"carpeta_trabajo.php\" || bereq.url ~ \"admin.php\")) {\n\n if (!(bereq.url ~ \"language_set.php\" || bereq.url ~ \"product_id\" || bereq.url ~ \"n_elementos_cesto.php\" || bereq.url ~ \"herramientas\" || bereq.url ~ \"zip_cesto.php\" || bereq.url ~ \"carpeta_trabajo.php\" || bereq.url ~ \"admin.php\" || bereq.url ~ \"inc\" || bereq.url ~ \"cesta.php\" )) {\n set beresp.ttl = 86400s;\n set beresp.http.cache-control = \"public, max-age = 300\";\n #set beresp.http.log = \"ha entrado aqu\u00ed\";\n #set beresp.http.X-CacheReason = \"varnishcache\";\n unset beresp.http.set-cookie;\n return(deliver);\n }\n \n\n # Large static files are delivered directly to the end-user without\n # waiting for Varnish to fully read the file first.\n # Varnish 4 fully supports Streaming, so use streaming here to avoid locking.\n if (bereq.url ~ \"^[^?]*\\.(7z|avi|bz2|flac|flv|gz|mka|mkv|mov|mp3|mp4|mpeg|mpg|ogg|ogm|opus|rar|tar|tgz|tbz|txz|wav|webm|xz|zip)(\\?.*)?$\") {\n unset beresp.http.set-cookie;\n set beresp.do_stream = true; # Check memory usage it'll grow in fetch_chunksize blocks (128k by default) if the backend doesn't send a Content-Length header, so only enable it for big objects\n }\n\n # Sometimes, a 301 or 302 redirect formed via Apache's mod_rewrite can mess with the HTTP port that is being passed along.\n # This often happens with simple rewrite rules in a scenario where Varnish runs on :80 and Apache on :8080 on the same box.\n # A redirect can then often redirect the end-user to a URL on :8080, where it should be :80.\n # This may need finetuning on your setup.\n #\n # To prevent accidental replace, we only filter the 301\/302 redirects for now.\n if (beresp.status == 301 || beresp.status == 302) {\n set beresp.http.Location = regsub(beresp.http.Location, \":[0-9]+\", \"\");\n }\n\n # Set 2min cache if unset for static files\n if (beresp.ttl <= 0s || beresp.http.Set-Cookie || beresp.http.Vary == \"*\") {\n set beresp.ttl = 120s; # Important, you shouldn't rely on this, SET YOUR HEADERS in the backend\n set beresp.uncacheable = true;\n return (deliver);\n }\n\n # Don't cache 50x responses\n if (beresp.status == 500 || beresp.status == 502 || beresp.status == 503 || beresp.status == 504) {\n return (abandon);\n }\n\n # Allow stale content, in case the backend goes down.\n # make Varnish keep all objects for 6 hours beyond their TTL\n set beresp.grace = 6h;\n\n return (deliver);\n}\n\n# The routine when we deliver the HTTP request to the user\n# Last chance to modify headers that are sent to the client\nsub vcl_deliver {\n # Called before a cached object is delivered to the client.\n\n if (obj.hits > 0) { # Add debug header to see if it's a HIT\/MISS and the number of hits, disable when not needed\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n\n # Please note that obj.hits behaviour changed in 4.0, now it counts per objecthead, not per object\n # and obj.hits may not be reset in some cases where bans are in use. See bug 1492 for details.\n # So take hits with a grain of salt\n set resp.http.X-Cache-Hits = obj.hits;\n\n # Remove some headers: PHP version\n unset resp.http.X-Powered-By;\n\n # Remove some headers: Apache version & OS\n unset resp.http.Server;\n unset resp.http.X-Drupal-Cache;\n unset resp.http.X-Varnish;\n unset resp.http.Via;\n unset resp.http.Link;\n unset resp.http.X-Generator;\n\n return (deliver);\n}\n\nsub vcl_purge {\n # Only handle actual PURGE HTTP methods, everything else is discarded\n if (req.method != \"PURGE\") {\n # restart request\n set req.http.X-Purge = \"Yes\";\n return(restart);\n }\n}\n\nsub vcl_synth {\n if (resp.status == 720) {\n # We use this special error status 720 to force redirects with 301 (permanent) redirects\n # To use this, call the following from anywhere in vcl_recv: return (synth(720, \"http:\/\/host\/new.html\"));\n set resp.http.Location = resp.reason;\n set resp.status = 301;\n return (deliver);\n } elseif (resp.status == 721) {\n # And we use error status 721 to force redirects with a 302 (temporary) redirect\n # To use this, call the following from anywhere in vcl_recv: return (synth(720, \"http:\/\/host\/new.html\"));\n set resp.http.Location = resp.reason;\n set resp.status = 302;\n return (deliver);\n } elseif (resp.status == 750) {\n set resp.status = 301;\n set resp.http.Location = \"http:\/\/www.arasaac.org\" + req.url;\n return(deliver);\n }\n\n return (deliver);\n}\n\n\nsub vcl_fini {\n # Called when VCL is discarded only after all requests have exited the VCL.\n # Typically used to clean up VMODs.\n\n return (ok);\n}\n","old_contents":"vcl 4.0;\n# Based on: https:\/\/github.com\/mattiasgeniar\/varnish-4.0-configuration-templates\/blob\/master\/\nimport std;\nimport directors;\n\nbackend server1 { # Define one backend\n .host = \"{VARNISH_BACKEND_HOST}\";\n .port = \"{VARNISH_BACKEND_PORT}\";\n .max_connections = 300; # That's it\n\n .probe = {\n #.url = \"\/\"; # short easy way (GET \/)\n # We prefer to only do a HEAD \/\n .request =\n \"HEAD \/ HTTP\/1.1\"\n \"Host: arasaac\"\n \"Connection: close\"\n \"User-Agent: Varnish Health Probe\";\n\n .interval = 5s; # check the health of each backend every 5 seconds\n .timeout = 3s; # timing out after 1 second.\n .window = 5; # If 3 out of the last 5 polls succeeded the backend is considered healthy, otherwise it will be marked as sick\n .threshold = 3;\n }\n\n .first_byte_timeout = 3s; # How long to wait before we receive a first byte from our backend?\n .connect_timeout = 5s; # How long to wait for a backend connection?\n .between_bytes_timeout = 2s; # How long to wait between bytes received from our backend?\n}\n\n#acl purge {\n # ACL we'll use later to allow purges\n# \"localhost\";\n# \"127.0.0.1\";\n# \"::1\";\n#}\n\nsub vcl_init {\n # Called when VCL is loaded, before any requests pass through it.\n # Typically used to initialize VMODs.\n\n new vdir = directors.round_robin();\n vdir.add_backend(server1);\n # vdir.add_backend(server...);\n # vdir.add_backend(servern);\n}\n\nsub vcl_recv {\n set req.backend_hint = vdir.backend(); # send all traffic to the vdir director\n\n # Normalize the header, remove the port (in case you're testing this on various TCP ports)\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n # Remove the proxy header (see https:\/\/httpoxy.org\/#mitigate-varnish)\n unset req.http.proxy;\n\n # when purging from php files, we need to send the request to varnish but process it as it were arasaac web server\n if ( req.http.host ~ \"varnish\" ) {\n set req.http.x-host = req.http.host;\n set req.http.host = \"www.arasaac.org\";\n }\n\n\n if (req.http.host ~ \"^arasaac.org\" || req.http.host ~ \"arasaac.net\" || req.http.host ~ \"arasaac.es\" ) {\n return (synth (750, \"\"));\n }\n if (req.url~ \"^\/index.php\") {\n set req.url = regsub(req.url, \"index.php\", \"\");\n } \n\n # Allow purging\n if (req.method == \"PURGE\") {\n# if (!client.ip ~ purge) { # purge is the ACL defined at the begining\n # Not from an allowed IP? Then die with an error.\n# return (synth(405, \"This IP is not allowed to send PURGE requests.\"));\n# }\n # If you got this stage (and didn't error out above), purge the cached result\n return (purge);\n }\n if (req.method == \"BAN\")\n {\n \/\/ TODO: Add client validation as needed\n ban(\"obj.http.x-url ~ \" + req.url);\n return(synth(901, \"BAN Set for \" + req.url));\n }\n \n #administration staff without cache \n if (req.url ~ \"inc\") {\n return (pass);\n }\n\n # Only deal with \"normal\" types\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"PATCH\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n # Implementing websocket support (https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html)\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n # Only cache GET or HEAD requests. This makes sure the POST requests are always passed.\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n\n set req.http.Cookie = regsuball(req.http.Cookie, \"has_js=[^;]+(; )?\", \"\");\n\n # Remove any Google Analytics based cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__utm.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"_ga=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"_gat=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmctr=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmcmd.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmccn.=[^;]+(; )?\", \"\");\n\n\n\n # Remove Arasaac Cookies for caching:\n #if (!(req.url ~ \"cesta.php\" || req.url ~ \"pictogramas_color.php\" || req.url ~ \"pictogramas_byn.php\"|| req.url ~ \"imagenes.php\" || req.url ~ \"videos_lse.php\" || req.url ~ \"signos_lse_color.php\" \n # || req.url ~ \"buscar.php\" || req.url ~ \"n_elementos_cesto.php\" || req.url ~ \"herramientas\" || req.url ~ \"zip_cesto.php\" || req.url ~ \"carpeta_trabajo.php\" || req.url ~ \"admin.php\")) {\n\n if (!(req.url ~ \"product_id\" || req.url ~ \"n_elementos_cesto.php\" || req.url ~ \"herramientas\" || req.url ~ \"zip_cesto.php\" || req.url ~ \"carpeta_trabajo.php\" || req.url ~ \"admin.php\" || req.url ~ \"cesta.php\")) {\n set req.http.Cookie = regsuball(req.http.Cookie, \"PHPSESSID=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"preImg=x; \", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"; \", \";\");\n\n if (!(req.http.Cookie ~ \"selected_language\")) {\n if (req.http.Accept-Language ~ \"^en\") {\n set req.http.Cookie = \"selected_language=en;\";\n } elsif (req.http.Accept-Language ~ \"^es\") {\n set req.http.Cookie = \"selected_language=es;\";\n } elsif (req.http.Accept-Language ~ \"^fr\") {\n set req.http.Cookie = \"selected_language=fr;\";\n } elsif (req.http.Accept-Language ~ \"^ro\") {\n set req.http.Cookie = \"selected_language=ro;\";\n } elsif (req.http.Accept-Language ~ \"^pt\") {\n set req.http.Cookie = \"selected_language=pt;\";\n } elsif (req.http.Accept-Language ~ \"^br\") {\n set req.http.Cookie = \"selected_language=br;\";\n } else {\n # unknown language. Remove the accept-language header and\n # use the backend default.\n set req.http.Cookie = \"selected_language=en;\";\n }\n }\n }\n \n #unset req.http.cookie; \n # Remove DoubleClick offensive cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__gads=[^;]+(; )?\", \"\");\n\n # Remove the Quant Capital cookies (added by some plugin, all __qca)\n set req.http.Cookie = regsuball(req.http.Cookie, \"__qc.=[^;]+(; )?\", \"\");\n\n # Remove the AddThis cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__atuv.=[^;]+(; )?\", \"\");\n\n # Remove a \";\" prefix in the cookie if present\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n\n # Are there cookies left with only spaces or that are empty?\n if (req.http.Cookie ~ \"^\\s*$\") {\n unset req.http.Cookie;\n }\n\n # Remove all cookies for static files\n # A valid discussion could be held on this line: do you really need to cache static files that don't cause load? Only if you have memory left.\n # Sure, there's disk I\/O, but chances are your OS will already have these files in their buffers (thus memory).\n # Before you blindly enable this, have a read here: https:\/\/ma.ttias.be\/stop-caching-static-files\/\n if (req.url ~ \"^[^?]*\\.(7z|avi|bmp|bz2|css|csv|doc|docx|eot|flac|flv|gif|gz|ico|jpeg|jpg|js|less|mka|mkv|mov|mp3|mp4|mpeg|mpg|odt|otf|ogg|ogm|opus|pdf|png|ppt|pptx|rar|rtf|svg|svgz|swf|tar|tbz|tgz|ttf|txt|txz|wav|webm|webp|woff|woff2|xls|xlsx|xml|xz|zip)(\\?.*)?$\") {\n unset req.http.Cookie;\n #return (pass);\n }\n \n #at the end because I need to remove previous cookies \n #if (req.url ~ \"purge.php\") {\n # return (pass);\n #}\n\n return (hash);\n}\n\nsub vcl_pipe {\n # Called upon entering pipe mode.\n # In this mode, the request is passed on to the backend, and any further data from both the client\n # and backend is passed on unaltered until either end closes the connection. Basically, Varnish will\n # degrade into a simple TCP proxy, shuffling bytes back and forth. For a connection in pipe mode,\n # no other VCL subroutine will ever get called after vcl_pipe.\n\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n # set bereq.http.connection = \"close\";\n # here. It is not set by default as it might break some broken web\n # applications, like IIS with NTLM authentication.\n\n # set bereq.http.Connection = \"Close\";\n\n # Implementing websocket support (https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html)\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n\n return (pipe);\n}\n\nsub vcl_pass {\n # Called upon entering pass mode. In this mode, the request is passed on to the backend, and the\n # backend's response is passed on to the client, but is not entered into the cache. Subsequent\n # requests submitted over the same client connection are handled normally.\n\n # return (pass);\n}\n\n# The data on which the hashing will take place\nsub vcl_hash {\n # Called after vcl_recv to create a hash value for the request. This is used as a key\n # to look up the object in Varnish.\n\n hash_data(req.url);\n\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n\n # hash cookies for requests that have them\n# if (req.http.Language) {\n #add cookie in hash\n# hash_data(req.http.Language);\n# }\n if (req.http.Cookie) {\n hash_data(req.http.Cookie);\n }\n #for debugging hash \n #std.log(\"######################################################################################################\");\n #std.log(req.http.Cookie + req.http.host + req.url);\n\n}\n\nsub vcl_hit {\n # Called when a cache lookup is successful.\n\n if (obj.ttl >= 0s) {\n # A pure unadultered hit, deliver it\n return (deliver);\n }\n\n # https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-grace.html\n # When several clients are requesting the same page Varnish will send one request to the backend and place the others on hold while fetching one copy from the backend. In some products this is called request coalescing and Varnish does this automatically.\n # If you are serving thousands of hits per second the queue of waiting requests can get huge. There are two potential problems - one is a thundering herd problem - suddenly releasing a thousand threads to serve content might send the load sky high. Secondly - nobody likes to wait. To deal with this we can instruct Varnish to keep the objects in cache beyond their TTL and to serve the waiting requests somewhat stale content.\n\n# if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n# return (deliver);\n# } else {\n# return (fetch);\n# }\n\n # We have no fresh fish. Lets look at the stale ones.\n if (std.healthy(req.backend_hint)) {\n # Backend is healthy. Limit age to 10s.\n if (obj.ttl + 10s > 0s) {\n #set req.http.grace = \"normal(limited)\";\n return (deliver);\n } else {\n # No candidate for grace. Fetch a fresh object.\n return(fetch);\n }\n } else {\n # backend is sick - use full grace\n if (obj.ttl + obj.grace > 0s) {\n #set req.http.grace = \"full\";\n return (deliver);\n } else {\n # no graced object.\n return (fetch);\n }\n }\n\n # fetch & deliver once we get the result\n return (fetch); # Dead code, keep as a safeguard\n}\n\nsub vcl_miss {\n # Called after a cache lookup if the requested document was not found in the cache. Its purpose\n # is to decide whether or not to attempt to retrieve the document from the backend, and which\n # backend to use.\n\n return (fetch);\n}\n\n# Handle the HTTP request coming from our backend\nsub vcl_backend_response {\n # Called after the response headers has been successfully retrieved from the backend.\n\n # Pause ESI request and remove Surrogate-Control header\n if (beresp.http.Surrogate-Control ~ \"ESI\/1.0\") {\n unset beresp.http.Surrogate-Control;\n set beresp.do_esi = true;\n }\n\n # Enable cache for all static files\n # The same argument as the static caches from above: monitor your cache size, if you get data nuked out of it, consider giving up the static file cache.\n # Before you blindly enable this, have a read here: https:\/\/ma.ttias.be\/stop-caching-static-files\/\n #if (bereq.url ~ \"^[^?]*\\.(7z|avi|bmp|bz2|css|csv|doc|docx|eot|flac|flv|gif|gz|ico|jpeg|jpg|js|less|mka|mkv|mov|mp3|mp4|mpeg|mpg|odt|otf|ogg|ogm|opus|pdf|png|ppt|pptx|rar|rtf|svg|svgz|swf|tar|tbz|tgz|ttf|txt|txz|wav|webm|webp|woff|woff2|xls|xlsx|xml|xz|zip)(\\?.*)?$\") {\n # unset beresp.http.set-cookie;\n #}\n \n if (bereq.url ~ \"^\/$\") {\n # en firefox a veces se cacheaba al cambiar el lenguaje dando datos erroneos\n set beresp.ttl = 86400s;\n set beresp.http.cache-control = \"public, max-age = 0\";\n unset beresp.http.set-cookie;\n return(deliver);\n }\n\n \n #if (!(bereq.url ~ \"language_set.php\" || bereq.url ~ \"cesta.php\" || bereq.url ~ \"pictogramas_color.php\" || bereq.url ~ \"pictogramas_byn.php\"|| bereq.url ~ \"imagenes.php\" || bereq.url ~ \"videos_lse.php\" || bereq.url ~ \"signos_lse_color.php\" || bereq.url ~ \"buscar.php\" || bereq.url ~ \"n_elementos_cesto.php\" || bereq.url ~ \"herramientas\" || bereq.url ~ \"zip_cesto.php\" || bereq.url ~ \"carpeta_trabajo.php\" || bereq.url ~ \"admin.php\")) {\n\n if (!(bereq.url ~ \"language_set.php\" || bereq.url ~ \"product_id\" || bereq.url ~ \"n_elementos_cesto.php\" || bereq.url ~ \"herramientas\" || bereq.url ~ \"zip_cesto.php\" || bereq.url ~ \"carpeta_trabajo.php\" || bereq.url ~ \"admin.php\" || bereq.url ~ \"inc\" || bereq.url ~ \"cesta.php\" )) {\n set beresp.ttl = 86400s;\n set beresp.http.cache-control = \"public, max-age = 300\";\n #set beresp.http.log = \"ha entrado aqu\u00ed\";\n #set beresp.http.X-CacheReason = \"varnishcache\";\n unset beresp.http.set-cookie;\n return(deliver);\n }\n \n if (bereq.url ~ \"^[^?]*\\.(7z|avi|bmp|bz2|css|csv|doc|docx|eot|flac|flv|gif|gz|ico|jpeg|jpg|js|less|mka|mkv|mov|mp3|mp4|mpeg|mpg|odt|otf|ogg|ogm|opus|pdf|png|ppt|pptx|rar|rtf|svg|svgz|swf|tar|tbz|tgz|ttf|txt|txz|wav|webm|webp|woff|woff2|xls|xlsx|xml|xz|zip)(\\?.*)?$\") {\n unset beresp.http.Cookie;\n set beresp.http.cache-control = \"public, max-age = 86400\";\n }\n\n # Large static files are delivered directly to the end-user without\n # waiting for Varnish to fully read the file first.\n # Varnish 4 fully supports Streaming, so use streaming here to avoid locking.\n if (bereq.url ~ \"^[^?]*\\.(7z|avi|bz2|flac|flv|gz|mka|mkv|mov|mp3|mp4|mpeg|mpg|ogg|ogm|opus|rar|tar|tgz|tbz|txz|wav|webm|xz|zip)(\\?.*)?$\") {\n unset beresp.http.set-cookie;\n set beresp.do_stream = true; # Check memory usage it'll grow in fetch_chunksize blocks (128k by default) if the backend doesn't send a Content-Length header, so only enable it for big objects\n }\n\n # Sometimes, a 301 or 302 redirect formed via Apache's mod_rewrite can mess with the HTTP port that is being passed along.\n # This often happens with simple rewrite rules in a scenario where Varnish runs on :80 and Apache on :8080 on the same box.\n # A redirect can then often redirect the end-user to a URL on :8080, where it should be :80.\n # This may need finetuning on your setup.\n #\n # To prevent accidental replace, we only filter the 301\/302 redirects for now.\n if (beresp.status == 301 || beresp.status == 302) {\n set beresp.http.Location = regsub(beresp.http.Location, \":[0-9]+\", \"\");\n }\n\n # Set 2min cache if unset for static files\n if (beresp.ttl <= 0s || beresp.http.Set-Cookie || beresp.http.Vary == \"*\") {\n set beresp.ttl = 120s; # Important, you shouldn't rely on this, SET YOUR HEADERS in the backend\n set beresp.uncacheable = true;\n return (deliver);\n }\n\n # Don't cache 50x responses\n if (beresp.status == 500 || beresp.status == 502 || beresp.status == 503 || beresp.status == 504) {\n return (abandon);\n }\n\n # Allow stale content, in case the backend goes down.\n # make Varnish keep all objects for 6 hours beyond their TTL\n set beresp.grace = 6h;\n\n return (deliver);\n}\n\n# The routine when we deliver the HTTP request to the user\n# Last chance to modify headers that are sent to the client\nsub vcl_deliver {\n # Called before a cached object is delivered to the client.\n\n if (obj.hits > 0) { # Add debug header to see if it's a HIT\/MISS and the number of hits, disable when not needed\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n\n # Please note that obj.hits behaviour changed in 4.0, now it counts per objecthead, not per object\n # and obj.hits may not be reset in some cases where bans are in use. See bug 1492 for details.\n # So take hits with a grain of salt\n set resp.http.X-Cache-Hits = obj.hits;\n\n # Remove some headers: PHP version\n unset resp.http.X-Powered-By;\n\n # Remove some headers: Apache version & OS\n unset resp.http.Server;\n unset resp.http.X-Drupal-Cache;\n unset resp.http.X-Varnish;\n unset resp.http.Via;\n unset resp.http.Link;\n unset resp.http.X-Generator;\n\n return (deliver);\n}\n\nsub vcl_purge {\n # Only handle actual PURGE HTTP methods, everything else is discarded\n if (req.method != \"PURGE\") {\n # restart request\n set req.http.X-Purge = \"Yes\";\n return(restart);\n }\n}\n\nsub vcl_synth {\n if (resp.status == 720) {\n # We use this special error status 720 to force redirects with 301 (permanent) redirects\n # To use this, call the following from anywhere in vcl_recv: return (synth(720, \"http:\/\/host\/new.html\"));\n set resp.http.Location = resp.reason;\n set resp.status = 301;\n return (deliver);\n } elseif (resp.status == 721) {\n # And we use error status 721 to force redirects with a 302 (temporary) redirect\n # To use this, call the following from anywhere in vcl_recv: return (synth(720, \"http:\/\/host\/new.html\"));\n set resp.http.Location = resp.reason;\n set resp.status = 302;\n return (deliver);\n } elseif (resp.status == 750) {\n set resp.status = 301;\n set resp.http.Location = \"http:\/\/www.arasaac.org\" + req.url;\n return(deliver);\n }\n\n return (deliver);\n}\n\n\nsub vcl_fini {\n # Called when VCL is discarded only after all requests have exited the VCL.\n # Typically used to clean up VMODs.\n\n return (ok);\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"0f1792883be7bb8089ba689646d6bd2606aa83e1","subject":"Improve VCL inline docs","message":"Improve VCL inline docs\n","repos":"JakeChampion\/polyfill-service,jonathan-fielding\/polyfill-service,kdzwinel\/polyfill-service,kdzwinel\/polyfill-service,mcshaz\/polyfill-service,mcshaz\/polyfill-service,kdzwinel\/polyfill-service,JakeChampion\/polyfill-service,jonathan-fielding\/polyfill-service,mcshaz\/polyfill-service,jonathan-fielding\/polyfill-service","old_file":"fastly-config.vcl","new_file":"fastly-config.vcl","new_contents":"sub vcl_recv {\n#FASTLY recv\n\n\tif (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n\t\treturn(pass);\n\t}\n\n\tif (req.url ~ \"^\/v1\/polyfill\\.\" && req.url !~ \"[\\?\\&]ua=\") {\n\t\tset req.http.X-Orig-URL = req.url;\n\t\tset req.url = \"\/v1\/normalizeUa?ua=\" urlencode(req.http.User-Agent);\n\t}\n\n\treturn(lookup);\n}\n\nsub vcl_deliver {\n#FASTLY deliver\n\n\t# If the response is to a normalise request and there's a parked \"original request\", use the normalised UA response to modify the original request and restart it\n\tif (req.url ~ \"^\/v1\/normalizeUa\" && resp.status == 200 && req.http.X-Orig-URL) {\n\t\tset req.http.Fastly-force-Shield = \"1\";\n\t\tif (req.http.X-Orig-URL ~ \"\\?\") {\n\t\t\tset req.url = req.http.X-Orig-URL \"&ua=\" resp.http.Normalized-User-Agent;\n\t\t} else {\n\t\t\tset req.url = req.http.X-Orig-URL \"?ua=\" resp.http.Normalized-User-Agent;\n\t\t}\n\t\trestart;\n\n\t# If the original request didn't specify a UA override, and we added one when the request was sent to the backend, the backend won't have included a Vary:user-agent header (correctly) but we need to add one\n\t} else if (req.url ~ \"^\/v1\/polyfill\\..*[\\?\\&]ua=\" && req.http.X-Orig-URL && req.http.X-Orig-URL !~ \"[\\?\\&]ua=\") {\n\t\tset resp.http.Vary = \"Accept-Encoding, User-Agent\";\n\t}\n\treturn(deliver);\n}\n","old_contents":"sub vcl_recv {\n#FASTLY recv\n\n\tif (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n\t\treturn(pass);\n\t}\n\n\tif (req.url ~ \"^\/v1\/polyfill\\.\" && req.url !~ \"[\\?\\&]ua=\") {\n\t\tset req.http.X-Orig-URL = req.url;\n\t\tset req.url = \"\/v1\/normalizeUa?ua=\" urlencode(req.http.User-Agent);\n\t}\n\n\treturn(lookup);\n}\n\nsub vcl_deliver {\n#FASTLY deliver\n\tif (req.url ~ \"^\/v1\/normalizeUa\" && resp.status == 200) {\n\t\tset req.http.Fastly-force-Shield = \"1\";\n\t\tif (req.http.X-Orig-URL ~ \"\\?\") {\n\t\t\tset req.url = req.http.X-Orig-URL \"&ua=\" resp.http.Normalized-User-Agent;\n\t\t} else {\n\t\t\tset req.url = req.http.X-Orig-URL \"?ua=\" resp.http.Normalized-User-Agent;\n\t\t}\n\t\trestart;\n\t} else if (req.url ~ \"^\/v1\/polyfill\\..*[\\?\\&]ua=\" && req.http.X-Orig-URL && req.http.X-Orig-URL !~ \"[\\?\\&]ua=\") {\n\t\tset resp.http.Vary = \"Accept-Encoding, User-Agent\";\n\t}\n\treturn(deliver);\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"302d463c84cc5c6d0818db585bbb886bbd1c72cc","subject":"Force lookup of kss resources and fix cached creation of objects in Plone","message":"Force lookup of kss resources and fix cached creation of objects in Plone\n","repos":"ssm\/pkg-varnish,ssm\/pkg-varnish,ssm\/pkg-varnish,ssm\/pkg-varnish,ssm\/pkg-varnish","old_file":"etc\/zope-plone.vcl","new_file":"etc\/zope-plone.vcl","new_contents":"#\n# This is an example VCL configuration file for varnish, meant for the\n# Plone CMS running within Zope. It defines a \"default\" backend for\n# serving static content from a normal web server, and a \"zope\"\n# backend for requests to the Zope CMS\n#\n# See the vcl(7) man page for details on VCL syntax and semantics.\n#\n# $Id$\n#\n\n# Default backend definition. Set this to point to your content\n# server.\n\n# Default backend is the Zope CMS\nbackend default {\n\t.host = \"127.0.0.1\";\n\t.port = \"9673\";\n}\n\nacl purge {\n\t\"localhost\";\n\t\"192.0.2.0\"\/24;\n}\n\nsub vcl_recv {\n\n\t# Normalize host headers, and do rewriting for the zope sites. Reject\n\t# requests for unknown hosts\n if (req.http.host ~ \"(www.)?example.com\") {\n set req.http.host = \"example.com\";\n set req.url = \"\/VirtualHostBase\/http\/example.com:80\/example.com\/VirtualHostRoot\" + req.url;\n } elsif (req.http.host ~ \"(www.)?example.org\") {\n set req.http.host = \"example.org\";\n set req.url = \"\/VirtualHostBase\/http\/example.org:80\/example.org\/VirtualHostRoot\" + req.url;\n } else {\n error 404 \"Unknown virtual host.\";\n }\n\n # Handle special requests\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n\n # POST - Logins and edits\n if (req.request == \"POST\") {\n return(pass);\n }\n \n # PURGE - The CacheFu product can invalidate updated URLs\n if (req.request == \"PURGE\") {\n if (!client.ip ~ purge) {\n error 405 \"Not allowed.\";\n }\n return(lookup);\n }\n\n # Do not cache the creation of objects in Plone\n if (req.url ~ \"createObject\"){\n return(pass);\n }\n }\n\n # Don't cache authenticated requests\n if (req.http.Cookie && req.http.Cookie ~ \"__ac(|_(name|password|persistent))=\") {\n\n\t\t# Force lookup of specific urls unlikely to need protection\n\t\tif (req.url ~ \"\\.(js|css|kss)\") {\n remove req.http.cookie;\n return(lookup);\n }\n return(pass);\n }\n\n # The default vcl_recv is used from here.\n }\n\n# Do the PURGE thing\nsub vcl_hit {\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged\";\n }\n}\nsub vcl_miss {\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged\";\n }\n}\n\n# Enforce a minimum TTL, since we can PURGE changed objects actively\n# from Zope by using the CacheFu product\n\nsub vcl_fetch {\n if (beresp.ttl < 3600s) {\n set beresp.ttl = 3600s;\n }\n}\n","old_contents":"#\n# This is an example VCL configuration file for varnish, meant for the\n# Plone CMS running within Zope. It defines a \"default\" backend for\n# serving static content from a normal web server, and a \"zope\"\n# backend for requests to the Zope CMS\n#\n# See the vcl(7) man page for details on VCL syntax and semantics.\n#\n# $Id$\n#\n\n# Default backend definition. Set this to point to your content\n# server.\n\n# Default backend is the Zope CMS\nbackend default {\n\t.host = \"127.0.0.1\";\n\t.port = \"9673\";\n}\n\nacl purge {\n\t\"localhost\";\n\t\"192.0.2.0\"\/24;\n}\n\nsub vcl_recv {\n\n\t# Normalize host headers, and do rewriting for the zope sites. Reject\n\t# requests for unknown hosts\n if (req.http.host ~ \"(www.)?example.com\") {\n set req.http.host = \"example.com\";\n set req.url = \"\/VirtualHostBase\/http\/example.com:80\/example.com\/VirtualHostRoot\" + req.url;\n } elsif (req.http.host ~ \"(www.)?example.org\") {\n set req.http.host = \"example.org\";\n set req.url = \"\/VirtualHostBase\/http\/example.org:80\/example.org\/VirtualHostRoot\" + req.url;\n } else {\n error 404 \"Unknown virtual host.\";\n }\n\n # Handle special requests\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n\n # POST - Logins and edits\n if (req.request == \"POST\") {\n return(pass);\n }\n \n # PURGE - The CacheFu product can invalidate updated URLs\n if (req.request == \"PURGE\") {\n if (!client.ip ~ purge) {\n error 405 \"Not allowed.\";\n }\n return(lookup);\n }\n }\n\n # Don't cache authenticated requests\n if (req.http.Cookie && req.http.Cookie ~ \"__ac(|_(name|password|persistent))=\") {\n\n\t\t# Force lookup of specific urls unlikely to need protection\n\t\tif (req.url ~ \"\\.(js|css)\") {\n remove req.http.cookie;\n return(lookup);\n }\n return(pass);\n }\n\n # The default vcl_recv is used from here.\n }\n\n# Do the PURGE thing\nsub vcl_hit {\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged\";\n }\n}\nsub vcl_miss {\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged\";\n }\n}\n\n# Enforce a minimum TTL, since we can PURGE changed objects actively\n# from Zope by using the CacheFu product\n\nsub vcl_fetch {\n if (beresp.ttl < 3600s) {\n set beresp.ttl = 3600s;\n }\n}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"2141125d7d32440552dc425512cb1e585b4c0e85","subject":"Change vcl_pipe comment to talk about bereq, not req","message":"Change vcl_pipe comment to talk about bereq, not req\n\nThanks to DocWilco for spotting this.\n\n\ngit-svn-id: 2c9807fa3ff65b17195bd55dc8a6c4261e10127b@5192 d4fa192b-c00b-0410-8231-f00ffab90ce4\n","repos":"drwilco\/varnish-cache-old,ajasty-cavium\/Varnish-Cache,franciscovg\/Varnish-Cache,mrhmouse\/Varnish-Cache,wikimedia\/operations-debs-varnish,ajasty-cavium\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,zhoualbeart\/Varnish-Cache,alarky\/varnish-cache-doc-ja,drwilco\/varnish-cache-old,feld\/Varnish-Cache,drwilco\/varnish-cache-drwilco,gauthier-delacroix\/Varnish-Cache,drwilco\/varnish-cache-drwilco,drwilco\/varnish-cache-drwilco,mrhmouse\/Varnish-Cache,ssm\/pkg-varnish,ajasty-cavium\/Varnish-Cache,feld\/Varnish-Cache,varnish\/Varnish-Cache,mrhmouse\/Varnish-Cache,alarky\/varnish-cache-doc-ja,zhoualbeart\/Varnish-Cache,alarky\/varnish-cache-doc-ja,gquintard\/Varnish-Cache,ambernetas\/varnish-cache,feld\/Varnish-Cache,wikimedia\/operations-debs-varnish,ssm\/pkg-varnish,zhoualbeart\/Varnish-Cache,drwilco\/varnish-cache-old,ssm\/pkg-varnish,wikimedia\/operations-debs-varnish,ssm\/pkg-varnish,gquintard\/Varnish-Cache,franciscovg\/Varnish-Cache,ssm\/pkg-varnish,ajasty-cavium\/Varnish-Cache,varnish\/Varnish-Cache,1HLtd\/Varnish-Cache,gquintard\/Varnish-Cache,varnish\/Varnish-Cache,chrismoulton\/Varnish-Cache,zhoualbeart\/Varnish-Cache,ambernetas\/varnish-cache,chrismoulton\/Varnish-Cache,feld\/Varnish-Cache,varnish\/Varnish-Cache,chrismoulton\/Varnish-Cache,mrhmouse\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,wikimedia\/operations-debs-varnish,wikimedia\/operations-debs-varnish,alarky\/varnish-cache-doc-ja,franciscovg\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,franciscovg\/Varnish-Cache,1HLtd\/Varnish-Cache,franciscovg\/Varnish-Cache,chrismoulton\/Varnish-Cache,zhoualbeart\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,mrhmouse\/Varnish-Cache,1HLtd\/Varnish-Cache,chrismoulton\/Varnish-Cache,gquintard\/Varnish-Cache,ambernetas\/varnish-cache,1HLtd\/Varnish-Cache,feld\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,varnish\/Varnish-Cache,alarky\/varnish-cache-doc-ja","old_file":"bin\/varnishd\/default.vcl","new_file":"bin\/varnishd\/default.vcl","new_contents":"\/*-\n * Copyright (c) 2006 Verdens Gang AS\n * Copyright (c) 2006-2009 Linpro AS\n * All rights reserved.\n *\n * Author: Poul-Henning Kamp <phk@phk.freebsd.dk>\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in the\n * documentation and\/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR \n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\n * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n * $Id$\n *\n * The default VCL code.\n *\n * NB! You do NOT need to copy & paste all of these functions into your\n * own vcl code, if you do not provide a definition of one of these\n * functions, the compiler will automatically fall back to the default\n * code from this file.\n *\n * This code will be prefixed with a backend declaration built from the\n * -b argument.\n *\/\n\nsub vcl_recv {\n if (req.restarts == 0) {\n\tif (req.http.x-forwarded-for) {\n\t set req.http.X-Forwarded-For =\n\t\treq.http.X-Forwarded-For + \", \" + client.ip;\n\t} else {\n\t set req.http.X-Forwarded-For = client.ip;\n\t}\n }\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization || req.http.Cookie) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n return (lookup);\n}\n\nsub vcl_pipe {\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n # set bereq.http.connection = \"close\";\n # here. It is not set by default as it might break some broken web\n # applications, like IIS with NTLM authentication.\n return (pipe);\n}\n\nsub vcl_pass {\n return (pass);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n return (hash);\n}\n\nsub vcl_hit {\n if (!obj.cacheable) {\n return (pass);\n }\n return (deliver);\n}\n\nsub vcl_miss {\n return (fetch);\n}\n\nsub vcl_fetch {\n if (!beresp.cacheable) {\n return (pass);\n }\n if (beresp.http.Set-Cookie) {\n return (pass);\n }\n return (deliver);\n}\n\nsub vcl_deliver {\n return (deliver);\n}\n\nsub vcl_error {\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + obj.status + \" \" + obj.response + {\"<\/h1>\n <p>\"} + obj.response + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"};\n return (deliver);\n}\n","old_contents":"\/*-\n * Copyright (c) 2006 Verdens Gang AS\n * Copyright (c) 2006-2009 Linpro AS\n * All rights reserved.\n *\n * Author: Poul-Henning Kamp <phk@phk.freebsd.dk>\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in the\n * documentation and\/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR \n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\n * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n * $Id$\n *\n * The default VCL code.\n *\n * NB! You do NOT need to copy & paste all of these functions into your\n * own vcl code, if you do not provide a definition of one of these\n * functions, the compiler will automatically fall back to the default\n * code from this file.\n *\n * This code will be prefixed with a backend declaration built from the\n * -b argument.\n *\/\n\nsub vcl_recv {\n if (req.restarts == 0) {\n\tif (req.http.x-forwarded-for) {\n\t set req.http.X-Forwarded-For =\n\t\treq.http.X-Forwarded-For + \", \" + client.ip;\n\t} else {\n\t set req.http.X-Forwarded-For = client.ip;\n\t}\n }\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization || req.http.Cookie) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n return (lookup);\n}\n\nsub vcl_pipe {\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n # set req.http.connection = \"close\";\n # here. It is not set by default as it might break some broken web\n # applications, like IIS with NTLM authentication.\n return (pipe);\n}\n\nsub vcl_pass {\n return (pass);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n return (hash);\n}\n\nsub vcl_hit {\n if (!obj.cacheable) {\n return (pass);\n }\n return (deliver);\n}\n\nsub vcl_miss {\n return (fetch);\n}\n\nsub vcl_fetch {\n if (!beresp.cacheable) {\n return (pass);\n }\n if (beresp.http.Set-Cookie) {\n return (pass);\n }\n return (deliver);\n}\n\nsub vcl_deliver {\n return (deliver);\n}\n\nsub vcl_error {\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + obj.status + \" \" + obj.response + {\"<\/h1>\n <p>\"} + obj.response + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"};\n return (deliver);\n}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"6584c0bd471fd6ea4285f95dd937cd749c8e8684","subject":"Be more careful about what gets cached and about surrogate keys","message":"Be more careful about what gets cached and about surrogate keys\n","repos":"fastly\/fastly-magento,fastly\/fastly-magento,fastly\/fastly-magento,fastly\/fastly-magento","old_file":"app\/code\/community\/Fastly\/CDN\/etc\/vcl_snippets\/fetch.vcl","new_file":"app\/code\/community\/Fastly\/CDN\/etc\/vcl_snippets\/fetch.vcl","new_contents":" if (beresp.status >= 500 && beresp.status < 600) {\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n \/* deliver stale if the object is available *\/\n if (stale.exists) {\n return(deliver_stale);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n \/* else go to vcl_error to deliver a synthetic *\/\n error beresp.status beresp.response;\n\n }\n\n if (beresp.http.X-Esi || beresp.http.Content-Type ~ \"^text\/(html|xml)\") {\n # enable ESI feature for Magento response by default\n esi;\n if (!beresp.http.Vary ~ \"Fastly-Cdn-Env,Https\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \",Fastly-Cdn-Env,Https\";\n } else {\n set beresp.http.Vary = \"Fastly-Cdn-Env,Https\";\n }\n }\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content\n if (http_status_matches(beresp.status, \"200,404\") && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url.ext ~ \"(?i)(css|js|html|eot|ico|otf|ttf|json)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # Force any responses with private, no-cache or no-store in Cache-Control to pass\n if (beresp.http.Cache-Control ~ \"private|no-cache|no-store\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # Just in case the Request Setting for x-pass is missing\n if (req.http.x-pass) {\n return (pass);\n }\n\n # Varnish sets default TTL if none of these are present\n if (!beresp.http.Expires && !beresp.http.Surrogate-Control ~ \"max-age\" && !beresp.http.Cache-Control ~ \"(s-maxage|max-age)\") {\n set beresp.ttl = 0s;\n }\n\n # If origin provides TTL for an object we cache it\n if ( beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\") && !req.http.x-pass ) {\n if (beresp.http.Content-Type ~ \"^text\/(html|xml)\") {\n # marker for vcl_deliver to reset Age:\n set beresp.http.magentomarker = \"1\";\n\n # Don't cache cookies - this is here because Magento sets cookies even for anonymous users\n # which busts cache\n unset beresp.http.set-cookie;\n\n # init surrogate keys\n if (beresp.http.Surrogate-Key) {\n set beresp.http.Surrogate-Key = beresp.http.Surrogate-Key \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n } else if (beresp.http.Content-Type ~ \"(image|script|css)\") {\n # set surrogate keys by content type if they are image\/script or CSS\n if (beresp.http.Surrogate-Key) {\n set beresp.http.Surrogate-Key = beresp.http.Surrogate-Key \" \" re.group.1;\n } else {\n set beresp.http.Surrogate-Key = re.group.1;\n }\n }\n }\n","old_contents":" if (beresp.status >= 500 && beresp.status < 600) {\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n \/* deliver stale if the object is available *\/\n if (stale.exists) {\n return(deliver_stale);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n \/* else go to vcl_error to deliver a synthetic *\/\n error 503;\n\n }\n\n if (beresp.http.X-Esi || beresp.http.Content-Type ~ \"text\/(html|xml)\") {\n # enable ESI feature for Magento response by default\n esi;\n if (!beresp.http.Vary ~ \"Fastly-Cdn-Env,Https\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \",Fastly-Cdn-Env,Https\";\n } else {\n set beresp.http.Vary = \"Fastly-Cdn-Env,Https\";\n }\n }\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content\n if (http_status_matches(beresp.status, \"200,404\") && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url.ext ~ \"(?i)(css|js|html|eot|ico|otf|ttf|json)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # Force any responses with private, no-cache or no-store in Cache-Control to pass\n if (beresp.http.Cache-Control ~ \"private|no-cache|no-store\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # If origin provides TTL for an object we cache it\n if ( beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\") && !req.http.x-pass ) {\n if (beresp.http.Content-Type ~ \"text\/(html|xml)\") {\n # marker for vcl_deliver to reset Age:\n set beresp.http.magentomarker = \"1\";\n\n # Don't cache cookies - this is here because Magento sets cookies even for anonymous users\n # which busts cache\n unset beresp.http.set-cookie;\n }\n\n # init surrogate keys\n if (beresp.http.Surrogate-Key) {\n set beresp.http.Surrogate-Key = beresp.http.Surrogate-Key \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type if they are image\/script or CSS\n if (beresp.http.Content-Type ~ \"(image|script|css)\") {\n set beresp.http.Surrogate-Key = re.group.1;\n }\n\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"891bd6bd69d5ed99d175443fe52bee18a10b00b2","subject":"Ignore all cookies except the Noosfero one","message":"Ignore all cookies except the Noosfero one\n\nIf people use things like Google Analytics and other Javascript crap\nthat sets cookies and we don't ignore then on the Varnish side, then no\ncache is done at all.\n","repos":"evandrojr\/noosferogov,danielafeitosa\/noosfero,coletivoEITA\/noosfero-ecosol,arthurmde\/noosfero,evandrojr\/noosfero,macartur\/noosfero,larissa\/noosfero,blogoosfero\/noosfero,arthurmde\/noosfero,hackathon-oscs\/cartografias,AlessandroCaetano\/noosfero,CIRANDAS\/noosfero-ecosol,alexandreab\/noosfero,samasti\/noosfero,danielafeitosa\/noosfero,AlessandroCaetano\/noosfero,tallysmartins\/noosfero,alexandreab\/noosfero,tallysmartins\/noosfero,rafamanzo\/mezuro-travis,hebertdougl\/noosfero,abner\/noosfero,uniteddiversity\/noosfero,uniteddiversity\/noosfero,arthurmde\/noosfero,uniteddiversity\/noosfero,arthurmde\/noosfero,hackathon-oscs\/rede-osc,cesarfex\/noosfero,samasti\/noosfero,rafamanzo\/mezuro-travis,macartur\/noosfero,ludaac\/noosfero-mx,AlessandroCaetano\/noosfero,coletivoEITA\/noosfero,samasti\/noosfero,evandrojr\/noosfero,uniteddiversity\/noosfero,alexandreab\/noosfero,LuisBelo\/tccnoosfero,hackathon-oscs\/cartografias,coletivoEITA\/noosfero-ecosol,AlessandroCaetano\/noosfero,larissa\/noosfero,uniteddiversity\/noosfero,marcosronaldo\/noosfero,danielafeitosa\/noosfero,hackathon-oscs\/rede-osc,marcosronaldo\/noosfero,tallysmartins\/noosfero,vfcosta\/noosfero,coletivoEITA\/noosfero-ecosol,marcosronaldo\/noosfero,CIRANDAS\/noosfero-ecosol,marcosronaldo\/noosfero,rafamanzo\/mezuro-travis,abner\/noosfero,hackathon-oscs\/rede-osc,marcosronaldo\/noosfero,danielafeitosa\/noosfero,arthurmde\/noosfero,alexandreab\/noosfero,AlessandroCaetano\/noosfero,danielafeitosa\/noosfero,coletivoEITA\/noosfero,coletivoEITA\/noosfero,LuisBelo\/tccnoosfero,rafamanzo\/mezuro-travis,hebertdougl\/noosfero,larissa\/noosfero,coletivoEITA\/noosfero,cesarfex\/noosfero,samasti\/noosfero,coletivoEITA\/noosfero,AlessandroCaetano\/noosfero,coletivoEITA\/noosfero,blogoosfero\/noosfero,evandrojr\/noosferogov,hebertdougl\/noosfero,EcoAlternative\/noosfero-ecosol,hackathon-oscs\/rede-osc,vfcosta\/noosfero,LuisBelo\/tccnoosfero,samasti\/noosfero,arthurmde\/noosfero,pr-snas\/noosfero-sgpr,macartur\/noosfero,hebertdougl\/noosfero,hackathon-oscs\/cartografias,evandrojr\/noosfero,pr-snas\/noosfero-sgpr,abner\/noosfero,evandrojr\/noosferogov,evandrojr\/noosferogov,macartur\/noosfero,cesarfex\/noosfero,tallysmartins\/noosfero,EcoAlternative\/noosfero-ecosol,evandrojr\/noosferogov,hackathon-oscs\/rede-osc,hackathon-oscs\/cartografias,macartur\/noosfero,coletivoEITA\/noosfero,macartur\/noosfero,alexandreab\/noosfero,danielafeitosa\/noosfero,ludaac\/noosfero-mx,cesarfex\/noosfero,tallysmartins\/noosfero,abner\/noosfero,evandrojr\/noosfero,cesarfex\/noosfero,hackathon-oscs\/cartografias,ludaac\/noosfero-mx,LuisBelo\/tccnoosfero,blogoosfero\/noosfero,abner\/noosfero,hackathon-oscs\/rede-osc,coletivoEITA\/noosfero-ecosol,vfcosta\/noosfero,AlessandroCaetano\/noosfero,CIRANDAS\/noosfero-ecosol,hebertdougl\/noosfero,blogoosfero\/noosfero,rafamanzo\/mezuro-travis,hebertdougl\/noosfero,evandrojr\/noosfero,pr-snas\/noosfero-sgpr,LuisBelo\/tccnoosfero,hackathon-oscs\/cartografias,EcoAlternative\/noosfero-ecosol,hebertdougl\/noosfero,ludaac\/noosfero-mx,coletivoEITA\/noosfero-ecosol,CIRANDAS\/noosfero-ecosol,samasti\/noosfero,LuisBelo\/tccnoosfero,evandrojr\/noosfero,larissa\/noosfero,marcosronaldo\/noosfero,evandrojr\/noosferogov,CIRANDAS\/noosfero-ecosol,alexandreab\/noosfero,larissa\/noosfero,arthurmde\/noosfero,EcoAlternative\/noosfero-ecosol,abner\/noosfero,cesarfex\/noosfero,pr-snas\/noosfero-sgpr,vfcosta\/noosfero,hackathon-oscs\/cartografias,evandrojr\/noosfero,alexandreab\/noosfero,pr-snas\/noosfero-sgpr,coletivoEITA\/noosfero-ecosol,EcoAlternative\/noosfero-ecosol,vfcosta\/noosfero,uniteddiversity\/noosfero,blogoosfero\/noosfero,blogoosfero\/noosfero,marcosronaldo\/noosfero,blogoosfero\/noosfero,macartur\/noosfero,ludaac\/noosfero-mx,uniteddiversity\/noosfero,abner\/noosfero,cesarfex\/noosfero,larissa\/noosfero,EcoAlternative\/noosfero-ecosol,larissa\/noosfero,pr-snas\/noosfero-sgpr,vfcosta\/noosfero,hackathon-oscs\/rede-osc,tallysmartins\/noosfero,EcoAlternative\/noosfero-ecosol,tallysmartins\/noosfero,evandrojr\/noosferogov","old_file":"etc\/noosfero\/varnish-noosfero.vcl","new_file":"etc\/noosfero\/varnish-noosfero.vcl","new_contents":"sub vcl_recv {\n if (req.http.Cookie) {\n # We only care about the \"_noosfero_session.*\" cookie, used for\n # authentication.\n if (req.http.Cookie ~ \"_noosfero_session.*\" ) {\n return (pass);\n }\n # Else strip all cookies\n unset req.http.Cookie;\n }\n}\n\nsub vcl_error {\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n\n synthetic {\"\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Transitional\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-transitional.dtd\">\n<html xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n <head>\n <meta http-equiv=\"Content-Type\" content=\"text\/html; charset=utf-8\"\/>\n <meta http-equiv=\"refresh\" content=\"60\"\/>\n <title>Technical problems<\/title>\n <link rel=\"stylesheet\" type=\"text\/css\" href=\"\/designs\/themes\/default\/errors.css\"\/>\n <link rel=\"shortcut icon\" href='\/designs\/themes\/default\/favicon.ico' type=\"image\/x-icon\" \/>\n <script type='text\/javascript' src='https:\/\/ajax.googleapis.com\/ajax\/libs\/prototype\/1.7.0.0\/prototype.js'><\/script>\n <script type='text\/javascript'>\n function display_error_message(language) {\n if (!language) {\n var language = ((navigator.language) ? navigator.language : navigator.userLanguage).replace('-', '_');\n }\n element = $(language);\n if (!element) {\n element = $(language.replace(\/_.*$\/, ''));\n }\n if (!element) {\n element = $('en');\n }\n $$('.message').each(function(item) { item.hide() });\n element.getElementsBySelector('h1').each(function(title) { document.title = title.innerHTML; });\n element.show();\n }\n <\/script>\n<\/head>\n<body onload='display_error_message()'>\n <div id='wrap'>\n <div id='header'>\n <div id='logo'> <\/div>\n <div id='details'><b>\"} obj.status \"<\/b> - \" obj.response {\"<\/div>\n <\/div>\n\n <div id='de' style='display: none' class='message'>\n <h1>Kurzzeitiges Systemproblem<\/h1>\n <p>\n Unser technisches Team arbeitet gerade daran, bitte probieren Sie es nachher erneut. Wir entschuldigen uns für die Unannehmlichkeiten.\n <\/p>\n <ul>\n <li><a href='javascript: history.back()'>Zurück<\/a><\/li>\n <li><a href='\/'>Gehe zur Homepage<\/a><\/li>\n <\/ul>\n <\/div>\n\n <div id='en' style='display: none' class='message'>\n <h1>Temporary system problem<\/h1>\n <p>\n Our technical team is working on it, please try again later. Sorry for the inconvenience.\n <\/p>\n <ul>\n <li><a href='javascript: history.back()'>Go back<\/a><\/li>\n <li><a href='\/'>Go to the site home page<\/a><\/li>\n <\/ul>\n <\/div>\n\n <div id='es' style='display: none' class='message'>\n <h1>Temporary system problem<\/h1>\n <p>\n Our technical team is working on it, please try again later. Sorry for the inconvenience.\n <\/p>\n <ul>\n <li><a href='javascript: history.back()'>Go back<\/a><\/li>\n <li><a href='\/'>Go to the site home page<\/a><\/li>\n <\/ul>\n <\/div>\n\n <div id='fr' style='display: none' class='message'>\n <h1>Problème temporaire du système.<\/h1>\n <p>\n Notre équipe technique est en train d'y travailler. Merci de réessayer plus tard. Nous sommes désolés de la gêne occasionnée.\n <\/p>\n <ul>\n <li><a href='javascript: history.back()'>Retour<\/a><\/li>\n <li><a href='\/'>Aller à la page d'accueil du site<\/a><\/li>\n <\/ul>\n <\/div>\n\n <div id='hy' style='display: none' class='message'>\n <h1>Temporary system problem<\/h1>\n <p>\n Our technical team is working on it, please try again later. Sorry for the inconvenience.\n <\/p>\n <ul>\n <li><a href='javascript: history.back()'>Վերադառնալ<\/a><\/li>\n <li><a href='\/'>Go to the site home page<\/a><\/li>\n <\/ul>\n <\/div>\n\n <div id='pt' style='display: none' class='message'>\n <h1>Problema temporário no sistema<\/h1>\n <p>\n Nossa equipe técnica está trabalhando nele, por favor tente mais tarde. Perdoe o incoveniente.\n <\/p>\n <ul>\n <li><a href='javascript: history.back()'>Voltar<\/a><\/li>\n <li><a href='\/'>Ir para a página inicial do site.<\/a><\/li>\n <\/ul>\n <\/div>\n\n <div id='ru' style='display: none' class='message'>\n <h1>Временная ошибка системы<\/h1>\n <p>\n Техники уже работают над проблемой, пожалуйста, попробуйте позже.\n <\/p>\n <ul>\n <li><a href='javascript:history.back()'>Назад<\/a><\/li>\n <li><a href='\/'>Перейти на домашнюю страницу сайта<\/a><\/li>\n <\/ul>\n <\/div>\n\n <div id='languages'>\n <a href=\"javascript: display_error_message('de')\">Deutsch<\/a>\n <a href=\"javascript: display_error_message('en')\">English<\/a>\n <a href=\"javascript: display_error_message('es')\">Español<\/a>\n <a href=\"javascript: display_error_message('fr')\">Français<\/a>\n <a href=\"javascript: display_error_message('hy')\">հայերեն լեզու<\/a>\n <a href=\"javascript: display_error_message('pt')\">Português<\/a>\n <a href=\"javascript: display_error_message('ru')\">русский язык<\/a>\n <\/div>\n\n <\/div>\n<\/body>\n<\/html>\n \"};\n return(deliver);\n}\n","old_contents":"\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\n\nsub vcl_error {\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n\n synthetic {\"\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Transitional\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-transitional.dtd\">\n<html xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n <head>\n <meta http-equiv=\"Content-Type\" content=\"text\/html; charset=utf-8\"\/>\n <meta http-equiv=\"refresh\" content=\"60\"\/>\n <title>Technical problems<\/title>\n <link rel=\"stylesheet\" type=\"text\/css\" href=\"\/designs\/themes\/default\/errors.css\"\/>\n <link rel=\"shortcut icon\" href='\/designs\/themes\/default\/favicon.ico' type=\"image\/x-icon\" \/>\n <script type='text\/javascript' src='https:\/\/ajax.googleapis.com\/ajax\/libs\/prototype\/1.7.0.0\/prototype.js'><\/script>\n <script type='text\/javascript'>\n function display_error_message(language) {\n if (!language) {\n var language = ((navigator.language) ? navigator.language : navigator.userLanguage).replace('-', '_');\n }\n element = $(language);\n if (!element) {\n element = $(language.replace(\/_.*$\/, ''));\n }\n if (!element) {\n element = $('en');\n }\n $$('.message').each(function(item) { item.hide() });\n element.getElementsBySelector('h1').each(function(title) { document.title = title.innerHTML; });\n element.show();\n }\n <\/script>\n<\/head>\n<body onload='display_error_message()'>\n <div id='wrap'>\n <div id='header'>\n <div id='logo'> <\/div>\n <div id='details'><b>\"} obj.status \"<\/b> - \" obj.response {\"<\/div>\n <\/div>\n\n <div id='de' style='display: none' class='message'>\n <h1>Kurzzeitiges Systemproblem<\/h1>\n <p>\n Unser technisches Team arbeitet gerade daran, bitte probieren Sie es nachher erneut. Wir entschuldigen uns für die Unannehmlichkeiten.\n <\/p>\n <ul>\n <li><a href='javascript: history.back()'>Zurück<\/a><\/li>\n <li><a href='\/'>Gehe zur Homepage<\/a><\/li>\n <\/ul>\n <\/div>\n\n <div id='en' style='display: none' class='message'>\n <h1>Temporary system problem<\/h1>\n <p>\n Our technical team is working on it, please try again later. Sorry for the inconvenience.\n <\/p>\n <ul>\n <li><a href='javascript: history.back()'>Go back<\/a><\/li>\n <li><a href='\/'>Go to the site home page<\/a><\/li>\n <\/ul>\n <\/div>\n\n <div id='es' style='display: none' class='message'>\n <h1>Temporary system problem<\/h1>\n <p>\n Our technical team is working on it, please try again later. Sorry for the inconvenience.\n <\/p>\n <ul>\n <li><a href='javascript: history.back()'>Go back<\/a><\/li>\n <li><a href='\/'>Go to the site home page<\/a><\/li>\n <\/ul>\n <\/div>\n\n <div id='fr' style='display: none' class='message'>\n <h1>Problème temporaire du système.<\/h1>\n <p>\n Notre équipe technique est en train d'y travailler. Merci de réessayer plus tard. Nous sommes désolés de la gêne occasionnée.\n <\/p>\n <ul>\n <li><a href='javascript: history.back()'>Retour<\/a><\/li>\n <li><a href='\/'>Aller à la page d'accueil du site<\/a><\/li>\n <\/ul>\n <\/div>\n\n <div id='hy' style='display: none' class='message'>\n <h1>Temporary system problem<\/h1>\n <p>\n Our technical team is working on it, please try again later. Sorry for the inconvenience.\n <\/p>\n <ul>\n <li><a href='javascript: history.back()'>Վերադառնալ<\/a><\/li>\n <li><a href='\/'>Go to the site home page<\/a><\/li>\n <\/ul>\n <\/div>\n\n <div id='pt' style='display: none' class='message'>\n <h1>Problema temporário no sistema<\/h1>\n <p>\n Nossa equipe técnica está trabalhando nele, por favor tente mais tarde. Perdoe o incoveniente.\n <\/p>\n <ul>\n <li><a href='javascript: history.back()'>Voltar<\/a><\/li>\n <li><a href='\/'>Ir para a página inicial do site.<\/a><\/li>\n <\/ul>\n <\/div>\n\n <div id='ru' style='display: none' class='message'>\n <h1>Временная ошибка системы<\/h1>\n <p>\n Техники уже работают над проблемой, пожалуйста, попробуйте позже.\n <\/p>\n <ul>\n <li><a href='javascript:history.back()'>Назад<\/a><\/li>\n <li><a href='\/'>Перейти на домашнюю страницу сайта<\/a><\/li>\n <\/ul>\n <\/div>\n\n <div id='languages'>\n <a href=\"javascript: display_error_message('de')\">Deutsch<\/a>\n <a href=\"javascript: display_error_message('en')\">English<\/a>\n <a href=\"javascript: display_error_message('es')\">Español<\/a>\n <a href=\"javascript: display_error_message('fr')\">Français<\/a>\n <a href=\"javascript: display_error_message('hy')\">հայերեն լեզու<\/a>\n <a href=\"javascript: display_error_message('pt')\">Português<\/a>\n <a href=\"javascript: display_error_message('ru')\">русский язык<\/a>\n <\/div>\n\n <\/div>\n<\/body>\n<\/html>\n \"};\n return(deliver);\n}\n","returncode":0,"stderr":"","license":"agpl-3.0","lang":"VCL"} {"commit":"7754ced89631d0090a4680e6bbd64bf0c0d0b65b","subject":"Configuration for Varnish.","message":"Configuration for Varnish.\n","repos":"cebartling\/reverse-proxy-url-rewrite-experiment,cebartling\/reverse-proxy-url-rewrite-experiment","old_file":"proxy-servers\/varnish\/default.vcl","new_file":"proxy-servers\/varnish\/default.vcl","new_contents":"# This is a Varnish 4.x VCL file\nvcl 4.0;\n\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"3000\";\n # .probe = {\n # .url = \"\/ping\";\n # .timeout = 1s;\n # .interval = 10s;\n # .window = 5;\n # .threshold = 2;\n # }\n # .first_byte_timeout = 300s; # How long to wait before we receive a first byte from our backend?\n # .connect_timeout = 5s; # How long to wait for a backend connection?\n # .between_bytes_timeout = 2s; # How long to wait between bytes received from our backend?\n}\n\nbackend sinatra {\n .host = \"127.0.0.1\";\n .port = \"4567\";\n}\n\n# backend nodejs {\n# .host = \"127.0.0.1\";\n# .port = \"5678\";\n# }\n\n# Handle the HTTP request received by the client\nsub vcl_recv {\n\tif (req.url ~ \"^\/api\/v1\/products\") {\n set req.backend_hint = sinatra;\n } else if (req.url ~ \"^\/api\/v2\/products\") {\n set req.backend_hint = sinatra;\n } else {\n set req.backend_hint = default;\n }\n}\n\n","old_contents":"# This is a Varnish 4.x VCL file\nvcl 4.0;\n\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"3000\";\n # .probe = {\n # .url = \"\/ping\";\n # .timeout = 1s;\n # .interval = 10s;\n # .window = 5;\n # .threshold = 2;\n # }\n # .first_byte_timeout = 300s; # How long to wait before we receive a first byte from our backend?\n # .connect_timeout = 5s; # How long to wait for a backend connection?\n # .between_bytes_timeout = 2s; # How long to wait between bytes received from our backend?\n}\n\n# backend sinatra {\n# .host = \"127.0.0.1\";\n# .port = \"4567\";\n# }\n\n# backend nodejs {\n# .host = \"127.0.0.1\";\n# .port = \"5678\";\n# }\n\n# Handle the HTTP request received by the client\nsub vcl_recv {\n\tif (req.url ~ \"^\/api\/v1\/products\") {\n set req.backend_hint = default;\n } else {\n set req.backend_hint = default;\n }\n}\n\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"4177afe9a5dd48d7aa5cae7f6ff273f0a75a34de","subject":"Simplify logic for when to set the Vary header on the final response","message":"Simplify logic for when to set the Vary header on the final response\n","repos":"JakeChampion\/polyfill-service,JakeChampion\/polyfill-service","old_file":"fastly\/vcl\/polyfill-service.vcl","new_file":"fastly\/vcl\/polyfill-service.vcl","new_contents":"sub set_backend {\n\t# The Fastly macro is inserted before the backend is selected because the\n\t# macro has the code which defines the values avaiable for req.http.Host\n\t# but it also contains a default backend which is always set to the EU. I wish we could disable the default backend setting.\n\t#FASTLY recv\n\t\n\t# Calculate the ideal region to route the request to.\n \tdeclare local var.region STRING; \n\tif (server.region ~ \"(APAC|Asia|North-America|South-America|US-Central|US-East|US-West)\") {\n\t\tset var.region = \"US\";\n \t} else {\n\t\tset var.region = \"EU\";\n \t}\n\n\t# Gather the health of the shields and origins.\n\tdeclare local var.v3_eu_is_healthy BOOL;\n\tset req.backend = F_v3_eu;\n\tset var.v3_eu_is_healthy = req.backend.healthy;\n\n\tdeclare local var.v3_us_is_healthy BOOL;\n \tset req.backend = F_v3_us;\n \tset var.v3_us_is_healthy = req.backend.healthy;\n\n \tdeclare local var.shield_eu_is_healthy BOOL;\n \tset req.backend = ssl_shield_london_city_uk;\n \tset var.shield_eu_is_healthy = req.backend.healthy;\n\n \tdeclare local var.shield_us_is_healthy BOOL;\n \tset req.backend = ssl_shield_dca_dc_us;\n \tset var.shield_us_is_healthy = req.backend.healthy;\n\n \t# Set some sort of default, that shouldn't get used.\n \tset req.backend = F_v3_eu;\n\n\tdeclare local var.EU_shield_server_name STRING;\n\tset var.EU_shield_server_name = \"LCY\";\n\n\tdeclare local var.US_shield_server_name STRING;\n\tset var.US_shield_server_name = \"DCA\";\n\n\t# Route EU requests to the nearest healthy shield or origin.\n \tif (var.region == \"EU\") {\n\t\tif (server.datacenter != var.EU_shield_server_name && fastly.ff.visits_this_service == 0 && req.restarts == 0 && var.shield_eu_is_healthy) {\n\t\t\tset req.backend = ssl_shield_london_city_uk;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} elseif (var.shield_us_is_healthy) {\n\t\t\tset req.backend = ssl_shield_dca_dc_us;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_eu;\n\t\t}\n \t}\n\n\t# Route US requests to the nearest healthy shield or origin.\n \tif (var.region == \"US\") {\n\t\tif (server.datacenter != var.US_shield_server_name && fastly.ff.visits_this_service == 0 && req.restarts == 0 && var.shield_us_is_healthy) {\n\t\t\tset req.backend = ssl_shield_dca_dc_us;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} elseif (var.shield_eu_is_healthy) {\n\t\t\tset req.backend = ssl_shield_london_city_uk;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_us;\n\t\t}\n\t}\n\n\t# Persist the decision so we can debug the result.\n \tset req.http.Debug-Backend = req.backend;\n}\n\nsub vcl_recv {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_recv;\n\t}\n\n\tif (req.method != \"GET\" && req.method != \"HEAD\" && req.method != \"OPTIONS\" && req.method != \"FASTLYPURGE\" && req.method != \"PURGE\") {\n\t\terror 911;\n\t}\n\n\tif (req.method == \"OPTIONS\") {\n\t\terror 912;\n\t}\n\n\t# Because the old service had a router which allowed any words between \/v2\/polyfill. and .js\n\tif (req.url.path ~ \"^\/v2\/polyfill(\\.\\w+)(\\.\\w+)?\" && req.url.ext == \"js\") {\n\t\tif (re.group.2) {\n\t\t\tset req.url = \"\/v2\/polyfill.min.js?\" req.url.qs;\n\t\t} else {\n\t\t\tset req.url = \"\/v2\/polyfill.js?\" req.url.qs;\n\t\t}\n\t}\n\n\t# Override the v3 defaults with the defaults of v2\n\tif (req.url ~ \"^\/v2\/polyfill(\\.min)?\\.js\") {\n\t\tset req.url = regsub(req.url, \"^\/v2\", \"\/v3\");\n\t\tset req.url = querystring.set(req.url, \"version\", \"3.25.1\");\n\t\tdeclare local var.unknown STRING;\n\t\tset var.unknown = subfield(req.url.qs, \"unknown\", \"&\");\n\t\tset req.url = querystring.set(req.url, \"unknown\", if(var.unknown != \"\", var.unknown, \"ignore\"));\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\") {\n\t\tcall normalise_querystring_parameters_for_polyfill_bundle;\n\t\t# Sort the querystring parameters alphabetically to improve chances of hitting a cached copy.\n\t\t# If querystring is empty, remove the ? from the url.\n\t\tset req.url = querystring.clean(querystring.sort(req.url));\n\t\tcall set_backend;\n\t} else {\n\t\t# The request is to an endpoint which doesn't use query parameters, let's remove them to increase our cache-hit-ratio\n\t\tset req.url = querystring.remove(req.url);\n\t\tcall set_backend;\n\t}\n\t\n\tif (req.backend == ssl_shield_dca_dc_us || req.backend == ssl_shield_london_city_uk) {\n\t\t# avoid passing stale content from Shield POP to Edge POP\n\t\tset req.max_stale_while_revalidate = 0s;\n\t} else {\n\t\tset req.http.referer_domain = if(req.http.referer ~ \"^https?\\:\\\/\\\/([^\\\/:?#]+)(?:[\\\/:?#]|$)\", re.group.1, \"\");\n\t}\n}\n\nsub vcl_hash {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_hash;\n\t}\n\n\t# We are not adding req.http.host to the hash because we want https:\/\/cdn.polyfill.io and https:\/\/polyfill.io to be a single object in the cache.\n\t# set req.hash += req.http.host;\n\tset req.hash += req.url;\n\t# We include return(hash) to stop the function falling through to the default VCL built into varnish, which for vcl_hash will add req.url and req.http.Host to the hash.\n\treturn(hash);\n}\n\nsub vcl_miss {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_miss;\n\t}\n}\n\nsub vcl_pass {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_pass;\n\t}\n}\n\nsub vcl_fetch {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_fetch;\n\t}\n\n\t# These header are only required for HTML documents.\n\tif (beresp.http.Content-Type ~ \"text\/html\") {\n\t\t# Enables the cross-site scripting filter built into most modern web browsers.\n\t\tset beresp.http.X-XSS-Protection = \"1; mode=block\";\t\n\t}\n\t# Prevents MIME-sniffing a response away from the declared content type.\n\tset beresp.http.X-Content-Type-Options = \"nosniff\";\n\n\t# Ensure the site is only served over HTTPS and reduce the chances of someone performing a MITM attack.\n\tset beresp.http.Strict-Transport-Security = \"max-age=31536000; includeSubdomains; preload\";\n\n\t# The Referrer-Policy header governs which referrer information, sent in the Referer header, should be included with requests made.\n\t# Send a full URL when performing a same-origin request, but only send the origin of the document for other cases.\n\tset beresp.http.Referrer-Policy = \"origin-when-cross-origin\";\n\n\t# Enable purging of all objects in the Fastly cache by issuing a purge with the key \"polyfill-service\".\n\tif (beresp.http.Surrogate-Key !~ \"\\bpolyfill-service\\b\") {\n\t\tset beresp.http.Surrogate-Key = if(beresp.http.Surrogate-Key, beresp.http.Surrogate-Key \" polyfill-service\", \"polyfill-service\");\n\t}\n\n\tset beresp.http.Timing-Allow-Origin = \"*\";\n\n\tif (req.http.Normalized-User-Agent) {\n\t\tset beresp.http.Normalized-User-Agent = req.http.Normalized-User-Agent;\n\t\tset beresp.http.Detected-User-Agent = req.http.useragent_parser_family \"\/\" req.http.useragent_parser_major \".\" req.http.useragent_parser_minor \".\" req.http.useragent_parser_patch;\n\t}\n}\n\nsub vcl_deliver {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_deliver;\n\t}\n\n\tset req.http.Fastly-Force-Shield = \"yes\";\n\n\t# Allow cross origin GET, HEAD, and OPTIONS requests to be made.\n\tif (req.http.Origin) {\n\t\tset resp.http.Access-Control-Allow-Origin = \"*\";\n\t\tset resp.http.Access-Control-Allow-Methods = \"GET,HEAD,OPTIONS\";\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\" && fastly.ff.visits_this_service == 0) {\n\t\t# Need to add \"Vary: User-Agent\" in after vcl_fetch to avoid the\n\t\t# \"Vary: User-Agent\" entering the Varnish cache.\n\t\t# We need \"Vary: User-Agent\" in the browser cache because a browser\n\t\t# may update itself to a version which needs different polyfills\n\t\t# So we need to have it ignore the browser cached bundle when the user-agent changes.\n\t\tset resp.http.Vary = \"User-Agent, Accept-Encoding\";\n\t}\n\n\tif (resp.status == 304) {\n\t\tset resp.http.Age = \"0\";\n\t}\n\n\tadd resp.http.Server-Timing = fastly_info.state {\", fastly;desc=\"Edge time\";dur=\"} time.elapsed.msec;\n\n\tif (req.http.Fastly-Debug) {\n\t\tset resp.http.Debug-Backend = req.http.Debug-Backend;\n\t\tset resp.http.Debug-Host = req.http.Host;\n\t\tset resp.http.Debug-Fastly-Restarts = req.restarts;\n\t\tset resp.http.Debug-Orig-URL = req.http.Orig-URL;\n\t\tset resp.http.Debug-VCL-Route = req.http.X-VCL-Route;\n\t\tset resp.http.useragent_parser_family = req.http.useragent_parser_family;\n\t\tset resp.http.useragent_parser_major = req.http.useragent_parser_major;\n\t\tset resp.http.useragent_parser_minor = req.http.useragent_parser_minor;\n\t\tset resp.http.useragent_parser_patch = req.http.useragent_parser_patch;\n\t} else {\n\t\tunset resp.http.Server;\n\t\tunset resp.http.Via;\n\t\tunset resp.http.X-Cache;\n\t\tunset resp.http.X-Cache-Hits;\n\t\tunset resp.http.X-Served-By;\n\t\tunset resp.http.X-Timer;\n\t\tunset resp.http.Fastly-Restarts;\n\t\tunset resp.http.X-PreFetch-Pass;\n\t\tunset resp.http.X-PreFetch-Miss;\n\t\tunset resp.http.X-PostFetch;\n\t}\n}\n\nsub vcl_error {\n\tif (obj.status == 911) {\n\t\tset obj.status = 405;\n\t\tset obj.response = \"METHOD NOT ALLOWED\";\n\t\tset obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n\t\tset obj.http.Cache-Control = \"private, no-store\";\n\t\tsynthetic req.method \" METHOD NOT ALLOWED\";\n\t\treturn (deliver);\n\t}\n\tif (obj.status == 912) {\n\t\tset obj.status = 200;\n\t\tset obj.response = \"OK\";\n\t\tset obj.http.Allow = \"OPTIONS, GET, HEAD\";\n\t\treturn (deliver);\n\t}\n}\n","old_contents":"sub set_backend {\n\t# The Fastly macro is inserted before the backend is selected because the\n\t# macro has the code which defines the values avaiable for req.http.Host\n\t# but it also contains a default backend which is always set to the EU. I wish we could disable the default backend setting.\n\t#FASTLY recv\n\t\n\t# Calculate the ideal region to route the request to.\n \tdeclare local var.region STRING; \n\tif (server.region ~ \"(APAC|Asia|North-America|South-America|US-Central|US-East|US-West)\") {\n\t\tset var.region = \"US\";\n \t} else {\n\t\tset var.region = \"EU\";\n \t}\n\n\t# Gather the health of the shields and origins.\n\tdeclare local var.v3_eu_is_healthy BOOL;\n\tset req.backend = F_v3_eu;\n\tset var.v3_eu_is_healthy = req.backend.healthy;\n\n\tdeclare local var.v3_us_is_healthy BOOL;\n \tset req.backend = F_v3_us;\n \tset var.v3_us_is_healthy = req.backend.healthy;\n\n \tdeclare local var.shield_eu_is_healthy BOOL;\n \tset req.backend = ssl_shield_london_city_uk;\n \tset var.shield_eu_is_healthy = req.backend.healthy;\n\n \tdeclare local var.shield_us_is_healthy BOOL;\n \tset req.backend = ssl_shield_dca_dc_us;\n \tset var.shield_us_is_healthy = req.backend.healthy;\n\n \t# Set some sort of default, that shouldn't get used.\n \tset req.backend = F_v3_eu;\n\n\tdeclare local var.EU_shield_server_name STRING;\n\tset var.EU_shield_server_name = \"LCY\";\n\n\tdeclare local var.US_shield_server_name STRING;\n\tset var.US_shield_server_name = \"DCA\";\n\n\t# Route EU requests to the nearest healthy shield or origin.\n \tif (var.region == \"EU\") {\n\t\tif (server.datacenter != var.EU_shield_server_name && fastly.ff.visits_this_service == 0 && req.restarts == 0 && var.shield_eu_is_healthy) {\n\t\t\tset req.backend = ssl_shield_london_city_uk;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} elseif (var.shield_us_is_healthy) {\n\t\t\tset req.backend = ssl_shield_dca_dc_us;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_eu;\n\t\t}\n \t}\n\n\t# Route US requests to the nearest healthy shield or origin.\n \tif (var.region == \"US\") {\n\t\tif (server.datacenter != var.US_shield_server_name && fastly.ff.visits_this_service == 0 && req.restarts == 0 && var.shield_us_is_healthy) {\n\t\t\tset req.backend = ssl_shield_dca_dc_us;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} elseif (var.shield_eu_is_healthy) {\n\t\t\tset req.backend = ssl_shield_london_city_uk;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_us;\n\t\t}\n\t}\n\n\t# Persist the decision so we can debug the result.\n \tset req.http.Debug-Backend = req.backend;\n}\n\nsub vcl_recv {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_recv;\n\t}\n\n\tif (req.method != \"GET\" && req.method != \"HEAD\" && req.method != \"OPTIONS\" && req.method != \"FASTLYPURGE\" && req.method != \"PURGE\") {\n\t\terror 911;\n\t}\n\n\tif (req.method == \"OPTIONS\") {\n\t\terror 912;\n\t}\n\n\t# Because the old service had a router which allowed any words between \/v2\/polyfill. and .js\n\tif (req.url.path ~ \"^\/v2\/polyfill(\\.\\w+)(\\.\\w+)?\" && req.url.ext == \"js\") {\n\t\tif (re.group.2) {\n\t\t\tset req.url = \"\/v2\/polyfill.min.js?\" req.url.qs;\n\t\t} else {\n\t\t\tset req.url = \"\/v2\/polyfill.js?\" req.url.qs;\n\t\t}\n\t}\n\n\t# Override the v3 defaults with the defaults of v2\n\tif (req.url ~ \"^\/v2\/polyfill(\\.min)?\\.js\") {\n\t\tset req.url = regsub(req.url, \"^\/v2\", \"\/v3\");\n\t\tset req.url = querystring.set(req.url, \"version\", \"3.25.1\");\n\t\tdeclare local var.unknown STRING;\n\t\tset var.unknown = subfield(req.url.qs, \"unknown\", \"&\");\n\t\tset req.url = querystring.set(req.url, \"unknown\", if(var.unknown != \"\", var.unknown, \"ignore\"));\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\") {\n\t\tcall normalise_querystring_parameters_for_polyfill_bundle;\n\t\t# Sort the querystring parameters alphabetically to improve chances of hitting a cached copy.\n\t\t# If querystring is empty, remove the ? from the url.\n\t\tset req.url = querystring.clean(querystring.sort(req.url));\n\t\tcall set_backend;\n\t} else {\n\t\t# The request is to an endpoint which doesn't use query parameters, let's remove them to increase our cache-hit-ratio\n\t\tset req.url = querystring.remove(req.url);\n\t\tcall set_backend;\n\t}\n\t\n\tif (req.backend == ssl_shield_dca_dc_us || req.backend == ssl_shield_london_city_uk) {\n\t\t# avoid passing stale content from Shield POP to Edge POP\n\t\tset req.max_stale_while_revalidate = 0s;\n\t} else {\n\t\tset req.http.referer_domain = if(req.http.referer ~ \"^https?\\:\\\/\\\/([^\\\/:?#]+)(?:[\\\/:?#]|$)\", re.group.1, \"\");\n\t}\n}\n\nsub vcl_hash {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_hash;\n\t}\n\n\t# We are not adding req.http.host to the hash because we want https:\/\/cdn.polyfill.io and https:\/\/polyfill.io to be a single object in the cache.\n\t# set req.hash += req.http.host;\n\tset req.hash += req.url;\n\t# We include return(hash) to stop the function falling through to the default VCL built into varnish, which for vcl_hash will add req.url and req.http.Host to the hash.\n\treturn(hash);\n}\n\nsub vcl_miss {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_miss;\n\t}\n}\n\nsub vcl_pass {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_pass;\n\t}\n}\n\nsub vcl_fetch {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_fetch;\n\t}\n\n\t# These header are only required for HTML documents.\n\tif (beresp.http.Content-Type ~ \"text\/html\") {\n\t\t# Enables the cross-site scripting filter built into most modern web browsers.\n\t\tset beresp.http.X-XSS-Protection = \"1; mode=block\";\t\n\t}\n\t# Prevents MIME-sniffing a response away from the declared content type.\n\tset beresp.http.X-Content-Type-Options = \"nosniff\";\n\n\t# Ensure the site is only served over HTTPS and reduce the chances of someone performing a MITM attack.\n\tset beresp.http.Strict-Transport-Security = \"max-age=31536000; includeSubdomains; preload\";\n\n\t# The Referrer-Policy header governs which referrer information, sent in the Referer header, should be included with requests made.\n\t# Send a full URL when performing a same-origin request, but only send the origin of the document for other cases.\n\tset beresp.http.Referrer-Policy = \"origin-when-cross-origin\";\n\n\t# Enable purging of all objects in the Fastly cache by issuing a purge with the key \"polyfill-service\".\n\tif (beresp.http.Surrogate-Key !~ \"\\bpolyfill-service\\b\") {\n\t\tset beresp.http.Surrogate-Key = if(beresp.http.Surrogate-Key, beresp.http.Surrogate-Key \" polyfill-service\", \"polyfill-service\");\n\t}\n\n\tset beresp.http.Timing-Allow-Origin = \"*\";\n\n\tif (req.http.Normalized-User-Agent) {\n\t\tset beresp.http.Normalized-User-Agent = req.http.Normalized-User-Agent;\n\t\tset beresp.http.Detected-User-Agent = req.http.useragent_parser_family \"\/\" req.http.useragent_parser_major \".\" req.http.useragent_parser_minor \".\" req.http.useragent_parser_patch;\n\t}\n}\n\nsub vcl_deliver {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_deliver;\n\t}\n\n\tset req.http.Fastly-Force-Shield = \"yes\";\n\n\t# Allow cross origin GET, HEAD, and OPTIONS requests to be made.\n\tif (req.http.Origin) {\n\t\tset resp.http.Access-Control-Allow-Origin = \"*\";\n\t\tset resp.http.Access-Control-Allow-Methods = \"GET,HEAD,OPTIONS\";\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\" && fastly.ff.visits_this_service == 0 && req.restarts == 0 && req.backend != ssl_shield_dca_dc_us && req.backend != ssl_shield_london_city_uk) {\n\t\t# Need to add \"Vary: User-Agent\" in after vcl_fetch to avoid the \n\t\t# \"Vary: User-Agent\" entering the Varnish cache.\n\t\t# We need \"Vary: User-Agent\" in the browser cache because a browser\n\t\t# may update itself to a version which needs different polyfills\n\t\t# So we need to have it ignore the browser cached bundle when the user-agent changes.\n\t\tset resp.http.Vary = \"User-Agent, Accept-Encoding\";\n\t}\n\n\tif (resp.status == 304) {\n\t\tset resp.http.Age = \"0\";\n\t}\n\n\tadd resp.http.Server-Timing = fastly_info.state {\", fastly;desc=\"Edge time\";dur=\"} time.elapsed.msec;\n\n\tif (req.http.Fastly-Debug) {\n\t\tset resp.http.Debug-Backend = req.http.Debug-Backend;\n\t\tset resp.http.Debug-Host = req.http.Host;\n\t\tset resp.http.Debug-Fastly-Restarts = req.restarts;\n\t\tset resp.http.Debug-Orig-URL = req.http.Orig-URL;\n\t\tset resp.http.Debug-VCL-Route = req.http.X-VCL-Route;\n\t\tset resp.http.useragent_parser_family = req.http.useragent_parser_family;\n\t\tset resp.http.useragent_parser_major = req.http.useragent_parser_major;\n\t\tset resp.http.useragent_parser_minor = req.http.useragent_parser_minor;\n\t\tset resp.http.useragent_parser_patch = req.http.useragent_parser_patch;\n\t} else {\n\t\tunset resp.http.Server;\n\t\tunset resp.http.Via;\n\t\tunset resp.http.X-Cache;\n\t\tunset resp.http.X-Cache-Hits;\n\t\tunset resp.http.X-Served-By;\n\t\tunset resp.http.X-Timer;\n\t\tunset resp.http.Fastly-Restarts;\n\t\tunset resp.http.X-PreFetch-Pass;\n\t\tunset resp.http.X-PreFetch-Miss;\n\t\tunset resp.http.X-PostFetch;\n\t}\n}\n\nsub vcl_error {\n\tif (obj.status == 911) {\n\t\tset obj.status = 405;\n\t\tset obj.response = \"METHOD NOT ALLOWED\";\n\t\tset obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n\t\tset obj.http.Cache-Control = \"private, no-store\";\n\t\tsynthetic req.method \" METHOD NOT ALLOWED\";\n\t\treturn (deliver);\n\t}\n\tif (obj.status == 912) {\n\t\tset obj.status = 200;\n\t\tset obj.response = \"OK\";\n\t\tset obj.http.Allow = \"OPTIONS, GET, HEAD\";\n\t\treturn (deliver);\n\t}\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"0c91a1410046fa0af99a282c54df3f94355b59d5","subject":"Set a shorter default TTL","message":"Set a shorter default TTL\n","repos":"HonzaKral\/warehouse,pypa\/warehouse,karan\/warehouse,ismail-s\/warehouse,alex\/warehouse,karan\/warehouse,dstufft\/warehouse,dstufft\/warehouse,karan\/warehouse,pypa\/warehouse,karan\/warehouse,HonzaKral\/warehouse,dstufft\/warehouse,ismail-s\/warehouse,HonzaKral\/warehouse,alex\/warehouse,karan\/warehouse,wlonk\/warehouse,ismail-s\/warehouse,pypa\/warehouse,wlonk\/warehouse,wlonk\/warehouse,dstufft\/warehouse,alex\/warehouse,pypa\/warehouse,ismail-s\/warehouse,alex\/warehouse,ismail-s\/warehouse,HonzaKral\/warehouse,alex\/warehouse","old_file":"vcl\/main.vcl","new_file":"vcl\/main.vcl","new_contents":"\nsub vcl_recv {\n#FASTLY recv\n\n # We want to Force SSL for the WebUI by redirecting to the HTTPS version of\n # the page, however for API calls we want to return an error code directing\n # people to instead use HTTPS.\n if (!req.http.Fastly-SSL) {\n\n # The \/simple\/ and \/packages\/ API.\n if (req.url ~ \"^\/(simple|packages)\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy JSON API.\n if (req.url ~ \"^\/pypi\/.+\/json$\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy ?:action= API.\n if (req.url ~ \"^\/pypi.*(\\?|&)=:action\") {\n error 803 \"SSL is required\";\n }\n\n # If we're on the \/pypi page and we've received something other than a\n # GET or HEAD request, then we have no way to determine if a particular\n # request is an API call or not because it'll be in the request body\n # and that isn't available to us here. So in those cases, we won't\n # do a redirect.\n if (req.url ~ \"^\/pypi\") {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n error 801 \"Force SSL\";\n }\n }\n else {\n # This isn't a \/pypi URL so we'll just unconditionally redirect to\n # HTTPS.\n error 801 \"Force SSL\";\n }\n }\n\n # Set a header to tell the backend if we're using https or http.\n if (req.http.Fastly-SSL) {\n set req.http.Warehouse-Proto = \"https\";\n } else {\n set req.http.Warehouse-Proto = \"http\";\n }\n\n # Pass the client IP address back to the backend.\n if (req.http.Fastly-Client-IP) {\n set req.http.Warehouse-IP = req.http.Fastly-Client-IP;\n }\n\n # Pass the real host value back to the backend.\n if (req.http.Host) {\n set req.http.Warehouse-Host = req.http.Host;\n }\n\n # Do not bother to attempt to run the caching mechanisms for methods that\n # are not generally safe to cache.\n if (req.request != \"HEAD\" &&\n req.request != \"GET\" &&\n req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n # Finally, return the default lookup action.\n return(lookup);\n}\n\n\nsub vcl_fetch {\n#FASTLY fetch\n\n # Trigger a \"SSL is required\" error if the backend has indicated to do so.\n if (beresp.http.X-Fastly-Error == \"803\") {\n error 803 \"SSL is required\";\n }\n\n # If we've gotten a 500 or a 503 from the backend, we'll go ahead and retry\n # the request.\n if ((beresp.status == 500 || beresp.status == 503) &&\n req.restarts < 1 &&\n (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n # If we've restarted, then we'll record the number of restarts.\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n # If there is a Set-Cookie header, we'll ensure that we do not cache the\n # response.\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n # If the response has the private Cache-Control directive then we won't\n # cache it.\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # If we've gotten an error after the restarts we'll deliver the response\n # with a very short cache time.\n if (beresp.status == 500 || beresp.status == 503) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n # Apply a default TTL if there isn't a max-age or s-maxage.\n if (beresp.http.Expires ||\n beresp.http.Surrogate-Control ~ \"max-age\" ||\n beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # Keep the ttl here\n }\n else {\n # Apply the default ttl\n set beresp.ttl = 60s;\n }\n\n # Actually deliver the fetched response.\n return(deliver);\n}\n\n\nsub vcl_error {\n#FASTLY error\n\n if (obj.status == 803) {\n set obj.status = 403;\n set obj.response = \"SSL is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic {\"SSL is required.\"};\n return (deliver);\n }\n}\n","old_contents":"\nsub vcl_recv {\n#FASTLY recv\n\n # We want to Force SSL for the WebUI by redirecting to the HTTPS version of\n # the page, however for API calls we want to return an error code directing\n # people to instead use HTTPS.\n if (!req.http.Fastly-SSL) {\n\n # The \/simple\/ and \/packages\/ API.\n if (req.url ~ \"^\/(simple|packages)\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy JSON API.\n if (req.url ~ \"^\/pypi\/.+\/json$\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy ?:action= API.\n if (req.url ~ \"^\/pypi.*(\\?|&)=:action\") {\n error 803 \"SSL is required\";\n }\n\n # If we're on the \/pypi page and we've received something other than a\n # GET or HEAD request, then we have no way to determine if a particular\n # request is an API call or not because it'll be in the request body\n # and that isn't available to us here. So in those cases, we won't\n # do a redirect.\n if (req.url ~ \"^\/pypi\") {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n error 801 \"Force SSL\";\n }\n }\n else {\n # This isn't a \/pypi URL so we'll just unconditionally redirect to\n # HTTPS.\n error 801 \"Force SSL\";\n }\n }\n\n # Set a header to tell the backend if we're using https or http.\n if (req.http.Fastly-SSL) {\n set req.http.Warehouse-Proto = \"https\";\n } else {\n set req.http.Warehouse-Proto = \"http\";\n }\n\n # Pass the client IP address back to the backend.\n if (req.http.Fastly-Client-IP) {\n set req.http.Warehouse-IP = req.http.Fastly-Client-IP;\n }\n\n # Pass the real host value back to the backend.\n if (req.http.Host) {\n set req.http.Warehouse-Host = req.http.Host;\n }\n\n # Do not bother to attempt to run the caching mechanisms for methods that\n # are not generally safe to cache.\n if (req.request != \"HEAD\" &&\n req.request != \"GET\" &&\n req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n # Finally, return the default lookup action.\n return(lookup);\n}\n\n\nsub vcl_fetch {\n#FASTLY fetch\n\n # Trigger a \"SSL is required\" error if the backend has indicated to do so.\n if (beresp.http.X-Fastly-Error == \"803\") {\n error 803 \"SSL is required\";\n }\n\n # If we've gotten a 500 or a 503 from the backend, we'll go ahead and retry\n # the request.\n if ((beresp.status == 500 || beresp.status == 503) &&\n req.restarts < 1 &&\n (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n # If we've restarted, then we'll record the number of restarts.\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n # If there is a Set-Cookie header, we'll ensure that we do not cache the\n # response.\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n # If the response has the private Cache-Control directive then we won't\n # cache it.\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # If we've gotten an error after the restarts we'll deliver the response\n # with a very short cache time.\n if (beresp.status == 500 || beresp.status == 503) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n # Apply a default TTL if there isn't a max-age or s-maxage.\n if (beresp.http.Expires ||\n beresp.http.Surrogate-Control ~ \"max-age\" ||\n beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # Keep the ttl here\n }\n else {\n # Apply the default ttl\n set beresp.ttl = 3600s;\n }\n\n # Actually deliver the fetched response.\n return(deliver);\n}\n\n\nsub vcl_error {\n#FASTLY error\n\n if (obj.status == 803) {\n set obj.status = 403;\n set obj.response = \"SSL is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic {\"SSL is required.\"};\n return (deliver);\n }\n}\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"936d3e7f71ba072becb4dc5e2eba55d22ed2c78d","subject":"Vary on user-agent only in browser cache and not in fastly cache","message":"Vary on user-agent only in browser cache and not in fastly cache\n","repos":"JakeChampion\/polyfill-service,JakeChampion\/polyfill-service","old_file":"fastly\/vcl\/polyfill-service.vcl","new_file":"fastly\/vcl\/polyfill-service.vcl","new_contents":"sub set_backend {\n\t# Calculate the ideal region to route the request to.\n\tdeclare local var.region STRING;\n\tif (server.region ~ \"(APAC|Asia|North-America|South-America|US-Central|US-East|US-West)\") {\n\t\tset var.region = \"US\";\n\t} else {\n\t\tset var.region = \"EU\";\n\t}\n\n\t# Gather the health of the shields and origins.\n\tdeclare local var.v3_eu_is_healthy BOOL;\n\tset req.backend = F_v3_eu;\n\tset var.v3_eu_is_healthy = req.backend.healthy;\n\n\tdeclare local var.v3_us_is_healthy BOOL;\n\tset req.backend = F_v3_us;\n\tset var.v3_us_is_healthy = req.backend.healthy;\n\n\t# Set some sort of default, that shouldn't get used.\n\tset req.backend = F_v3_eu;\n\n\t# Route EU requests to the nearest healthy shield or origin.\n\tif (var.region == \"EU\") {\n\t\tif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_eu;\n\t\t}\n\t}\n\n\t# Route US requests to the nearest healthy shield or origin.\n\tif (var.region == \"US\") {\n\t\tif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_us;\n\t\t}\n\t}\n\n\t# Persist the decision so we can debug the result.\n\tset req.http.Debug-Backend = req.backend;\n\n\t# The Fastly macro is inserted after the backend is selected because the\n\t# macro has the code to select the correct req.http.Host value based on the backend.\n\t#FASTLY recv\n}\n\nsub vcl_recv {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_recv;\n\t}\n\n\tif (req.method != \"GET\" && req.method != \"HEAD\" && req.method != \"OPTIONS\") {\n\t\terror 911;\n\t}\n\n\tif (req.method == \"OPTIONS\") {\n\t\terror 912;\n\t}\n\n\t# Override the v3 defaults with the defaults of v2\n\tif (req.url ~ \"^\/v2\/polyfill(\\.min)?\\.js\") {\n\t\tset req.url = regsub(req.url, \"^\/v2\", \"\/v3\");\n\t\tset req.url = querystring.set(req.url, \"version\", \"3.25.1\");\n\t\tdeclare local var.unknown STRING;\n\t\tset var.unknown = subfield(req.url.qs, \"unknown\", \"&\");\n\t\tset req.url = querystring.set(req.url, \"unknown\", if(var.unknown != \"\", var.unknown, \"ignore\"));\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\") {\n\t\tcall normalise_querystring_parameters_for_polyfill_bundle;\n\t}\n\n\t# Sort the querystring parameters alphabetically to improve chances of hitting a cached copy.\n\t# If querystring is empty, remove the ? from the url.\n\tset req.url = querystring.clean(querystring.sort(req.url));\n\tcall set_backend;\n}\n\nsub vcl_hash {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_hash;\n\t}\n\n\t# We are not adding req.http.host to the hash because we want https:\/\/cdn.polyfill.io and https:\/\/polyfill.io to be a single object in the cache.\n\t# set req.hash += req.http.host;\n\tset req.hash += req.url;\n\t# We include return(hash) to stop the function falling through to the default VCL built into varnish, which for vcl_hash will add req.url and req.http.Host to the hash.\n\treturn(hash);\n}\n\nsub vcl_miss {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_miss;\n\t}\n}\n\nsub vcl_pass {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_pass;\n\t}\n}\n\nsub vcl_fetch {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_fetch;\n\t}\n\n\t# These header are only required for HTML documents.\n\tif (beresp.http.Content-Type ~ \"text\/html\") {\n\t\t# Enables the cross-site scripting filter built into most modern web browsers.\n\t\tset beresp.http.X-XSS-Protection = \"1; mode=block\";\n\t\t\n\t\t# Prevents MIME-sniffing a response away from the declared content type.\n\t\tset beresp.http.X-Content-Type-Options = \"nosniff\";\n\n\t\t# Allow only content from the site's own origin (this excludes subdomains) and www.ft.com.\n\t\t# Don't allow the website to be used within an iframe\n\t\tif (!beresp.http.Content-Security-Policy) {\n\t\t\tset beresp.http.Content-Security-Policy = \"default-src 'self'; font-src 'self' https:\/\/www.ft.com; img-src 'self' https:\/\/www.ft.com; frame-ancestors 'none'; base-uri 'self'; form-action 'self'\";\n\t\t}\n\t}\n\n\t# Ensure the site is only served over HTTPS and reduce the chances of someone performing a MITM attack.\n\tset beresp.http.Strict-Transport-Security = \"max-age=31536000; includeSubdomains; preload\";\n\n\t# The Referrer-Policy header governs which referrer information, sent in the Referer header, should be included with requests made.\n\t# Send a full URL when performing a same-origin request, but only send the origin of the document for other cases.\n\tset beresp.http.Referrer-Policy = \"origin-when-cross-origin\";\n\n\t# Enable purging of all objects in the Fastly cache by issuing a purge with the key \"polyfill-service\".\n\tif (beresp.http.Surrogate-Key !~ \"\\bpolyfill-service\\b\") {\n\t\tset beresp.http.Surrogate-Key = if(beresp.http.Surrogate-Key, beresp.http.Surrogate-Key \" polyfill-service\", \"polyfill-service\");\n\t}\n\n\tset beresp.http.Timing-Allow-Origin = \"*\";\n\n\tif (req.http.Normalized-User-Agent) {\n\t\tset beresp.http.Normalized-User-Agent = req.http.Normalized-User-Agent;\n\t\tset beresp.http.Detected-User-Agent = req.http.useragent_parser_family \"\/\" req.http.useragent_parser_major \".\" req.http.useragent_parser_minor \".\" req.http.useragent_parser_patch;\n\t}\n}\n\nsub vcl_deliver {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_deliver;\n\t}\n\n\tset req.http.Fastly-Force-Shield = \"yes\";\n\n\t# Allow cross origin GET, HEAD, and OPTIONS requests to be made.\n\tif (req.http.Origin) {\n\t\tset resp.http.Access-Control-Allow-Origin = \"*\";\n\t\tset resp.http.Access-Control-Allow-Methods = \"GET,HEAD,OPTIONS\";\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\") {\n\t\t# Need to add \"Vary: User-Agent\" in after vcl_fetch to avoid the \n\t\t# \"Vary: User-Agent\" entering the Varnish cache.\n\t\t# We need \"Vary: User-Agent\" in the browser cache because a browser\n\t\t# may update itself to a version which needs different polyfills\n\t\t# So we need to have it ignore the browser cached bundle when the user-agent changes.\n\t\tadd resp.http.Vary = \"User-Agent\";\n\t}\n\n\tadd resp.http.Server-Timing = fastly_info.state {\", fastly;desc=\"Edge time\";dur=\"} time.elapsed.msec;\n\n\tif (req.http.Fastly-Debug) {\n\t\tset resp.http.Debug-Backend = req.http.Debug-Backend;\n\t\tset resp.http.Debug-Host = req.http.Host;\n\t\tset resp.http.Debug-Fastly-Restarts = req.restarts;\n\t\tset resp.http.Debug-Orig-URL = req.http.Orig-URL;\n\t\tset resp.http.Debug-VCL-Route = req.http.X-VCL-Route;\n\t\tset resp.http.useragent_parser_family = req.http.useragent_parser_family;\n\t\tset resp.http.useragent_parser_major = req.http.useragent_parser_major;\n\t\tset resp.http.useragent_parser_minor = req.http.useragent_parser_minor;\n\t\tset resp.http.useragent_parser_patch = req.http.useragent_parser_patch;\n\t} else {\n\t\tunset resp.http.Server;\n\t\tunset resp.http.Via;\n\t\tunset resp.http.X-Cache;\n\t\tunset resp.http.X-Cache-Hits;\n\t\tunset resp.http.X-Served-By;\n\t\tunset resp.http.X-Timer;\n\t\tunset resp.http.Fastly-Restarts;\n\t}\n}\n\nsub vcl_error {\n\tif (obj.status == 911) {\n\t\tset obj.status = 405;\n\t\tset obj.response = \"METHOD NOT ALLOWED\";\n\t\tset obj.http.Content-Type = \"text\/html; charset=utf-8\";\n\t\tset obj.http.Cache-Control = \"private, no-store\";\n\t\tsynthetic req.method \" METHOD NOT ALLOWED\";\n\t\treturn (deliver);\n\t}\n\tif (obj.status == 912) {\n\t\tset obj.status = 200;\n\t\tset obj.response = \"OK\";\n\t\tset obj.http.Allow = \"OPTIONS, GET, HEAD\";\n\t\treturn (deliver);\n\t}\n}\n","old_contents":"sub set_backend {\n\t# Calculate the ideal region to route the request to.\n\tdeclare local var.region STRING;\n\tif (server.region ~ \"(APAC|Asia|North-America|South-America|US-Central|US-East|US-West)\") {\n\t\tset var.region = \"US\";\n\t} else {\n\t\tset var.region = \"EU\";\n\t}\n\n\t# Gather the health of the shields and origins.\n\tdeclare local var.v3_eu_is_healthy BOOL;\n\tset req.backend = F_v3_eu;\n\tset var.v3_eu_is_healthy = req.backend.healthy;\n\n\tdeclare local var.v3_us_is_healthy BOOL;\n\tset req.backend = F_v3_us;\n\tset var.v3_us_is_healthy = req.backend.healthy;\n\n\t# Set some sort of default, that shouldn't get used.\n\tset req.backend = F_v3_eu;\n\n\t# Route EU requests to the nearest healthy shield or origin.\n\tif (var.region == \"EU\") {\n\t\tif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_eu;\n\t\t}\n\t}\n\n\t# Route US requests to the nearest healthy shield or origin.\n\tif (var.region == \"US\") {\n\t\tif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_us;\n\t\t}\n\t}\n\n\t# Persist the decision so we can debug the result.\n\tset req.http.Debug-Backend = req.backend;\n\n\t# The Fastly macro is inserted after the backend is selected because the\n\t# macro has the code to select the correct req.http.Host value based on the backend.\n\t#FASTLY recv\n}\n\nsub vcl_recv {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_recv;\n\t}\n\n\tif (req.method != \"GET\" && req.method != \"HEAD\" && req.method != \"OPTIONS\") {\n\t\terror 911;\n\t}\n\n\tif (req.method == \"OPTIONS\") {\n\t\terror 912;\n\t}\n\n\t# Override the v3 defaults with the defaults of v2\n\tif (req.url ~ \"^\/v2\/polyfill(\\.min)?\\.js\") {\n\t\tset req.url = regsub(req.url, \"^\/v2\", \"\/v3\");\n\t\tset req.url = querystring.set(req.url, \"version\", \"3.25.1\");\n\t\tdeclare local var.unknown STRING;\n\t\tset var.unknown = subfield(req.url.qs, \"unknown\", \"&\");\n\t\tset req.url = querystring.set(req.url, \"unknown\", if(var.unknown != \"\", var.unknown, \"ignore\"));\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\") {\n\t\tcall normalise_querystring_parameters_for_polyfill_bundle;\n\t}\n\n\t# Sort the querystring parameters alphabetically to improve chances of hitting a cached copy.\n\t# If querystring is empty, remove the ? from the url.\n\tset req.url = querystring.clean(querystring.sort(req.url));\n\tcall set_backend;\n}\n\nsub vcl_hash {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_hash;\n\t}\n\n\t# We are not adding req.http.host to the hash because we want https:\/\/cdn.polyfill.io and https:\/\/polyfill.io to be a single object in the cache.\n\t# set req.hash += req.http.host;\n\tset req.hash += req.url;\n\t# We include return(hash) to stop the function falling through to the default VCL built into varnish, which for vcl_hash will add req.url and req.http.Host to the hash.\n\treturn(hash);\n}\n\nsub vcl_miss {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_miss;\n\t}\n}\n\nsub vcl_pass {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_pass;\n\t}\n}\n\nsub vcl_fetch {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_fetch;\n\t}\n\n\t# These header are only required for HTML documents.\n\tif (beresp.http.Content-Type ~ \"text\/html\") {\n\t\t# Enables the cross-site scripting filter built into most modern web browsers.\n\t\tset beresp.http.X-XSS-Protection = \"1; mode=block\";\n\t\t\n\t\t# Prevents MIME-sniffing a response away from the declared content type.\n\t\tset beresp.http.X-Content-Type-Options = \"nosniff\";\n\n\t\t# Allow only content from the site's own origin (this excludes subdomains) and www.ft.com.\n\t\t# Don't allow the website to be used within an iframe\n\t\tif (!beresp.http.Content-Security-Policy) {\n\t\t\tset beresp.http.Content-Security-Policy = \"default-src 'self'; font-src 'self' https:\/\/www.ft.com; img-src 'self' https:\/\/www.ft.com; frame-ancestors 'none'; base-uri 'self'; form-action 'self'\";\n\t\t}\n\t}\n\n\t# Ensure the site is only served over HTTPS and reduce the chances of someone performing a MITM attack.\n\tset beresp.http.Strict-Transport-Security = \"max-age=31536000; includeSubdomains; preload\";\n\n\t# The Referrer-Policy header governs which referrer information, sent in the Referer header, should be included with requests made.\n\t# Send a full URL when performing a same-origin request, but only send the origin of the document for other cases.\n\tset beresp.http.Referrer-Policy = \"origin-when-cross-origin\";\n\n\t# Enable purging of all objects in the Fastly cache by issuing a purge with the key \"polyfill-service\".\n\tif (beresp.http.Surrogate-Key !~ \"\\bpolyfill-service\\b\") {\n\t\tset beresp.http.Surrogate-Key = if(beresp.http.Surrogate-Key, beresp.http.Surrogate-Key \" polyfill-service\", \"polyfill-service\");\n\t}\n\n\tset beresp.http.Timing-Allow-Origin = \"*\";\n\n\tif (req.http.Normalized-User-Agent) {\n\t\tset beresp.http.Normalized-User-Agent = req.http.Normalized-User-Agent;\n\t\tset beresp.http.Detected-User-Agent = req.http.useragent_parser_family \"\/\" req.http.useragent_parser_major \".\" req.http.useragent_parser_minor \".\" req.http.useragent_parser_patch;\n\t}\n}\n\nsub vcl_deliver {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_deliver;\n\t}\n\n\tset req.http.Fastly-Force-Shield = \"yes\";\n\n\t# Allow cross origin GET, HEAD, and OPTIONS requests to be made.\n\tif (req.http.Origin) {\n\t\tset resp.http.Access-Control-Allow-Origin = \"*\";\n\t\tset resp.http.Access-Control-Allow-Methods = \"GET,HEAD,OPTIONS\";\n\t}\n\n\tadd resp.http.Server-Timing = fastly_info.state {\", fastly;desc=\"Edge time\";dur=\"} time.elapsed.msec;\n\n\tif (req.http.Fastly-Debug) {\n\t\tset resp.http.Debug-Backend = req.http.Debug-Backend;\n\t\tset resp.http.Debug-Host = req.http.Host;\n\t\tset resp.http.Debug-Fastly-Restarts = req.restarts;\n\t\tset resp.http.Debug-Orig-URL = req.http.Orig-URL;\n\t\tset resp.http.Debug-VCL-Route = req.http.X-VCL-Route;\n\t\tset resp.http.useragent_parser_family = req.http.useragent_parser_family;\n\t\tset resp.http.useragent_parser_major = req.http.useragent_parser_major;\n\t\tset resp.http.useragent_parser_minor = req.http.useragent_parser_minor;\n\t\tset resp.http.useragent_parser_patch = req.http.useragent_parser_patch;\n\t} else {\n\t\tunset resp.http.Server;\n\t\tunset resp.http.Via;\n\t\tunset resp.http.X-Cache;\n\t\tunset resp.http.X-Cache-Hits;\n\t\tunset resp.http.X-Served-By;\n\t\tunset resp.http.X-Timer;\n\t\tunset resp.http.Fastly-Restarts;\n\t}\n}\n\nsub vcl_error {\n\tif (obj.status == 911) {\n\t\tset obj.status = 405;\n\t\tset obj.response = \"METHOD NOT ALLOWED\";\n\t\tset obj.http.Content-Type = \"text\/html; charset=utf-8\";\n\t\tset obj.http.Cache-Control = \"private, no-store\";\n\t\tsynthetic req.method \" METHOD NOT ALLOWED\";\n\t\treturn (deliver);\n\t}\n\tif (obj.status == 912) {\n\t\tset obj.status = 200;\n\t\tset obj.response = \"OK\";\n\t\tset obj.http.Allow = \"OPTIONS, GET, HEAD\";\n\t\treturn (deliver);\n\t}\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"e7c01054cc9d5048b5f0bb958352165f68bc999c","subject":"fixed varnish config","message":"fixed varnish config\n","repos":"jleck\/elasticbeanstalk-nginx-php,jleck\/elasticbeanstalk-nginx-php,jleck\/elasticbeanstalk-nginx-php","old_file":"varnish\/etc\/varnish\/default.vcl","new_file":"varnish\/etc\/varnish\/default.vcl","new_contents":"#############################################################################\r\n# AWS Elastic Beanstalk Nginx\/PHP-FPM Configuration\r\n# Copyright 2012 Carbon Coders Ltd.\r\n#\r\n# MIT LICENSE\r\n#\r\n# Permission is hereby granted, free of charge, to any person obtaining a copy\r\n# of this software and associated documentation files (the \"Software\"), to deal\r\n# in the Software without restriction, including without limitation the rights\r\n# to use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\r\n# copies of the Software, and to permit persons to whom the Software is\r\n# furnished to do so, subject to the following conditions:\r\n# \r\n# The above copyright notice and this permission notice shall be included in all\r\n# copies or substantial portions of the Software.\r\n# \r\n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r\n# SOFTWARE.\r\n#\r\n\r\nbackend default {\r\n .host = \"127.0.0.1\";\r\n .port = \"8080\";\r\n}\r\nsub vcl_recv {\r\n unset req.http.Cookie;\r\n return (lookup); \r\n}\r\nsub vcl_fetch {\r\n if (beresp.http.Set-Cookie) {\r\n set beresp.ttl = 5d;\r\n return (deliver);\r\n }\r\n}","old_contents":"#############################################################################\r\n# AWS Elastic Beanstalk Nginx\/PHP-FPM Configuration\r\n# Copyright 2012 Carbon Coders Ltd.\r\n#\r\n# MIT LICENSE\r\n#\r\n# Permission is hereby granted, free of charge, to any person obtaining a copy\r\n# of this software and associated documentation files (the \"Software\"), to deal\r\n# in the Software without restriction, including without limitation the rights\r\n# to use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\r\n# copies of the Software, and to permit persons to whom the Software is\r\n# furnished to do so, subject to the following conditions:\r\n# \r\n# The above copyright notice and this permission notice shall be included in all\r\n# copies or substantial portions of the Software.\r\n# \r\n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r\n# SOFTWARE.\r\n#\r\n\r\nClient = unset req.http.Cookie;\r\nServer = set beresp.ttl = 5d;\r\nbackend default {\r\n .host = \"127.0.0.1\";\r\n .port = \"8080\";\r\n}\r\nsub vcl_recv {\r\n unset req.http.Cookie;\r\n return (lookup); \r\n}\r\nsub vcl_fetch {\r\n if (beresp.http.Set-Cookie) {\r\n set beresp.ttl = 5d;\r\n return (deliver);\r\n }\r\n}","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"e1963abc86a81251aa3a94bbd9e289d3e1acf087","subject":"add the original accept-encoding header so that the compute-at-edge service can detect brotli support","message":"add the original accept-encoding header so that the compute-at-edge service can detect brotli support\n","repos":"JakeChampion\/polyfill-service,JakeChampion\/polyfill-service","old_file":"fastly\/vcl\/polyfill-service.vcl","new_file":"fastly\/vcl\/polyfill-service.vcl","new_contents":"sub set_backend {\n\t# The Fastly macro is inserted before the backend is selected because the\n\t# macro has the code which defines the values avaiable for req.http.Host\n\t# but it also contains a default backend which is always set to the EU. I wish we could disable the default backend setting.\n\t#FASTLY recv\n\n\t# Calculate the ideal region to route the request to.\n\tdeclare local var.region STRING;\n\tif (server.region ~ \"(APAC|Asia|North-America|South-America|US-Central|US-East|US-West)\") {\n\t\tset var.region = \"US\";\n\t} else {\n\t\tset var.region = \"EU\";\n\t}\n\n\t# Gather the health of the shields and origins.\n\tdeclare local var.v3_eu_is_healthy BOOL;\n\tset req.backend = F_v3_eu;\n\tset var.v3_eu_is_healthy = req.backend.healthy;\n\n\tdeclare local var.v3_us_is_healthy BOOL;\n\tset req.backend = F_v3_us;\n\tset var.v3_us_is_healthy = req.backend.healthy;\n\n\tdeclare local var.shield_eu_is_healthy BOOL;\n\tset req.backend = ssl_shield_london_city_uk;\n\tset var.shield_eu_is_healthy = req.backend.healthy;\n\n\tdeclare local var.shield_us_is_healthy BOOL;\n\tset req.backend = ssl_shield_iad_va_us;\n\tset var.shield_us_is_healthy = req.backend.healthy;\n\n\t# Set some sort of default, that shouldn't get used.\n\tset req.backend = F_v3_eu;\n\n\tdeclare local var.EU_shield_server_name STRING;\n\tset var.EU_shield_server_name = \"LCY\";\n\n\tdeclare local var.US_shield_server_name STRING;\n\tset var.US_shield_server_name = \"IAD\";\n\n\t# Route EU requests to the nearest healthy shield or origin.\n\tif (var.region == \"EU\") {\n\t\tif (server.datacenter != var.EU_shield_server_name && fastly.ff.visits_this_service == 0 && req.restarts == 0 && var.shield_eu_is_healthy) {\n\t\t\tset req.backend = ssl_shield_london_city_uk;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} elseif (var.shield_us_is_healthy) {\n\t\t\tset req.backend = ssl_shield_iad_va_us;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_eu;\n\t\t}\n\t}\n\n\t# Route US requests to the nearest healthy shield or origin.\n\tif (var.region == \"US\") {\n\t\tif (server.datacenter != var.US_shield_server_name && fastly.ff.visits_this_service == 0 && req.restarts == 0 && var.shield_us_is_healthy) {\n\t\t\tset req.backend = ssl_shield_iad_va_us;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} elseif (var.shield_eu_is_healthy) {\n\t\t\tset req.backend = ssl_shield_london_city_uk;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_us;\n\t\t}\n\t}\n\n\t# Persist the decision so we can debug the result.\n\tset req.http.Debug-Backend = req.backend;\n}\n\nsub vcl_recv {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_recv;\n\t}\n\n # We use this edge dictionary item as a flag for whether to use compute-at-edge for any requests.\n # If the item is not found, then we default to `\"0\"`, which we interpret to mean the flag is off.\n\tdeclare local var.compute-at-edge-active BOOL;\n\tif (std.atoi(table.lookup(compute_at_edge_config, \"active\", \"0\")) == 1) {\n\t\tset var.compute-at-edge-active = true;\n\t} else {\n\t\tset var.compute-at-edge-active = false;\n\t}\n\tif (var.compute-at-edge-active) {\n\t\t# if the querystring parameter `use-compute-at-edge-backend` is set to yes`\n\t\t# then use the c@e backend.\n\t\t# The querystring parameter is used within our tests, so that we can confirm\n\t\t# the compute-at-edge backend is working as we expect it to.\n\t\tdeclare local var.use-compute-at-edge-backend STRING;\n\t\tset var.use-compute-at-edge-backend = querystring.get(req.url, \"use-compute-at-edge-backend\");\n\t\tif (var.use-compute-at-edge-backend == \"yes\" && (std.prefixof(req.url.path, \"\/v3\/polyfill.js\") || std.prefixof(req.url.path, \"\/v3\/polyfill.min.js\"))) {\n\t\t\tset req.backend = F_compute_at_edge;\n\t\t\tif (req.backend.healthy) {\n\t\t\t\t# add the original accept-encoding header so that the compute-at-edge service can detect brotli support\n\t\t\t\tset req.http.Accept-Encoding = req.http.Fastly-Orig-Accept-Encoding;\n\t\t\t\t# if using the c@e backend then do not use the cache at all\n\t\t\t\treturn(pass);\n\t\t\t}\n # requests can set the querystring parameter to `no` to avoid ever user compute-at-edge\n # if the querystring parameter is not set to no, then we run some logic to decide whether\n # to use compute-at-edge for this request or not.\n\t\t} else if (var.use-compute-at-edge-backend != \"no\") {\n\t\t\tdeclare local var.selected BOOL;\n\t\t\tset var.selected = randombool(1, std.atoi(table.lookup(compute_at_edge_config, \"sample\", \"1000\")));\n\t\t\t# this logic is saying, only use compute-at-edge for a request which has come from outside this Fastly\n\t\t\t# service. I.E. The request has directly from a client.\n\t\t\t# We also have logic which decides how many of those direct client requests use compute-at-edge.\n\t\t\t# We default to 1 in 1000 requests using compute-at-edge, this can be configured by the edge dictionary\n\t\t\t# named `compute_at_edge_config` and the item in the dictionary named `sample`\n\t\t\tif (var.selected && fastly_info.edge.is_tls && !req.is_background_fetch && !req.is_purge && req.restarts == 0 && fastly.ff.visits_this_service == 0 && (std.prefixof(req.url.path, \"\/v3\/polyfill.js\") || std.prefixof(req.url.path, \"\/v3\/polyfill.min.js\"))) {\n\t\t\t\tset req.backend = F_compute_at_edge;\n\t\t\t\tif (req.backend.healthy) {\n\t\t\t\t\t# add the original accept-encoding header so that the compute-at-edge service can detect brotli support\n\t\t\t\t\tset req.http.Accept-Encoding = req.http.Fastly-Orig-Accept-Encoding;\n\t\t\t\t\t# if using the c@e backend then do not use the cache at all\n\t\t\t\t\treturn(pass);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif (req.method != \"GET\" && req.method != \"HEAD\" && req.method != \"OPTIONS\" && req.method != \"FASTLYPURGE\" && req.method != \"PURGE\") {\n\t\terror 911;\n\t}\n\n\tif (req.method == \"OPTIONS\") {\n\t\terror 912;\n\t}\n\n\t# Because the old service had a router which allowed any words between \/v2\/polyfill. and .js\n\tif (req.url.path ~ \"^\/v2\/polyfill(\\.\\w+)(\\.\\w+)?\" && req.url.ext == \"js\") {\n\t\tif (re.group.2) {\n\t\t\tset req.url = \"\/v2\/polyfill.min.js?\" req.url.qs;\n\t\t} else {\n\t\t\tset req.url = \"\/v2\/polyfill.js?\" req.url.qs;\n\t\t}\n\t}\n\n\t# Override the v3 defaults with the defaults of v2\n\tif (req.url ~ \"^\/v2\/polyfill(\\.min)?\\.js\") {\n\t\tset req.url = regsub(req.url, \"^\/v2\", \"\/v3\");\n\t\tset req.url = querystring.set(req.url, \"version\", \"3.25.1\");\n\t\tdeclare local var.unknown STRING;\n\t\tset var.unknown = subfield(req.url.qs, \"unknown\", \"&\");\n\t\tset req.url = querystring.set(req.url, \"unknown\", if(var.unknown != \"\", var.unknown, \"ignore\"));\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\") {\n\t\tcall normalise_querystring_parameters_for_polyfill_bundle;\n\t\t# Sort the querystring parameters alphabetically to improve chances of hitting a cached copy.\n\t\t# If querystring is empty, remove the ? from the url.\n\t\tset req.url = querystring.clean(querystring.sort(req.url));\n\t\tcall set_backend;\n\t} else {\n\t\t# The request is to an endpoint which doesn't use query parameters, let's remove them to increase our cache-hit-ratio\n\t\tset req.url = querystring.remove(req.url);\n\t\tcall set_backend;\n\t}\n\n\tif (req.backend == ssl_shield_iad_va_us || req.backend == ssl_shield_london_city_uk) {\n\t\t# avoid passing stale content from Shield POP to Edge POP\n\t\tset req.max_stale_while_revalidate = 0s;\n\t} else {\n\t\tset req.http.referer_domain = if(req.http.referer ~ \"^https?\\:\\\/\\\/([^\\\/:?#]+)(?:[\\\/:?#]|$)\", re.group.1, \"\");\n\t}\n}\n\nsub vcl_hash {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_hash;\n\t}\n\n\t# We are not adding req.http.host to the hash because we want https:\/\/cdn.polyfill.io and https:\/\/polyfill.io to be a single object in the cache.\n\t# As well as any other domains we support such as polyfills.io and cdn.polyfills.io\n\t# set req.hash += req.http.host;\n\tset req.hash += req.url;\n\t# We include return(hash) to stop the function falling through to the default VCL built into varnish, which for vcl_hash will add req.url and req.http.Host to the hash.\n\treturn(hash);\n}\n\nsub vcl_miss {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_miss;\n\t}\n}\n\nsub vcl_pass {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_pass;\n\t}\n}\n\nsub vcl_fetch {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_fetch;\n\t}\n\n\t# https:\/\/yann.mandragor.org\/posts\/purge-group-pattern\/\n\tif (beresp.http.Surrogate-Key && !std.strstr(beresp.http.Surrogate-Key, \"PurgeGroup\")) {\n\t\tset beresp.http.Surrogate-Key = beresp.http.Surrogate-Key \" PurgeGroup\" randomint(0, 999);\n\t} else if (!beresp.http.Surrogate-Key) {\n\t\tset beresp.http.Surrogate-Key = \"PurgeGroup\" randomint(0, 999);\n\t}\n\n\t# These header are only required for HTML documents.\n\tif (beresp.http.Content-Type ~ \"text\/html\") {\n\t\t# Enables the cross-site scripting filter built into most modern web browsers.\n\t\tset beresp.http.X-XSS-Protection = \"1; mode=block\";\n\t}\n\t# Prevents MIME-sniffing a response away from the declared content type.\n\tset beresp.http.X-Content-Type-Options = \"nosniff\";\n\n\t# Ensure the site is only served over HTTPS and reduce the chances of someone performing a MITM attack.\n\tset beresp.http.Strict-Transport-Security = \"max-age=31536000; includeSubdomains; preload\";\n\n\t# The Referrer-Policy header governs which referrer information, sent in the Referer header, should be included with requests made.\n\t# Send a full URL when performing a same-origin request, but only send the origin of the document for other cases.\n\tset beresp.http.Referrer-Policy = \"origin-when-cross-origin\";\n\n\t# Enable purging of all objects in the Fastly cache by issuing a purge with the key \"polyfill-service\".\n\tif (beresp.http.Surrogate-Key !~ \"\\bpolyfill-service\\b\") {\n\t\tset beresp.http.Surrogate-Key = if(beresp.http.Surrogate-Key, beresp.http.Surrogate-Key \" polyfill-service\", \"polyfill-service\");\n\t}\n\n\tset beresp.http.Timing-Allow-Origin = \"*\";\n\n\tif (req.http.Normalized-User-Agent) {\n\t\tset beresp.http.Normalized-User-Agent = req.http.Normalized-User-Agent;\n\t\tset beresp.http.Detected-User-Agent = req.http.useragent_parser_family \"\/\" req.http.useragent_parser_major \".\" req.http.useragent_parser_minor \".\" req.http.useragent_parser_patch;\n\t}\n\n\t# We end up here if\n\t# - The origin is HEALTHY; and\n\t# - It returned a valid HTTP response\n\t#\n\t# We may still not want to *use* that response, if it's an HTTP error,\n\t# so that's the case we need to catch here.\n\tif (beresp.status >= 500 && beresp.status < 600) {\n\t\t# There's a stale version available! Serve it.\n\t\tif (stale.exists) {\n\t\t\treturn(deliver_stale);\n\t\t}\n\t\t# Cache the error for 1s to allow it to be used for any collapsed requests\n\t\tset beresp.cacheable = true;\n\t\tset beresp.ttl = 1s;\n\t\treturn(deliver);\n\t}\n\t# If the response is not an error, but it is stale content that's being\n\t# served from a cache upstream, cache it for a very brief period to\n\t# clear the request queue.\n\tif (beresp.status == 200 && beresp.http.x-resp-is-stale) {\n\t\tset beresp.ttl = 1s;\n\t\tset beresp.stale_while_revalidate = 0s;\n\t\tset beresp.stale_if_error = 0s;\n\t\treturn (deliver);\n\t}\n}\n\nsub vcl_deliver {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_deliver;\n\t}\n\tif (fastly_info.state ~ \"STALE\") {\n\t\tset resp.http.x-resp-is-stale = \"true\";\n\t}\n\n\tset req.http.Fastly-Force-Shield = \"yes\";\n\n\t# Allow cross origin GET, HEAD, and OPTIONS requests to be made.\n\tif (req.http.Origin) {\n\t\tset resp.http.Access-Control-Allow-Origin = \"*\";\n\t\tset resp.http.Access-Control-Allow-Methods = \"GET,HEAD,OPTIONS\";\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\" && fastly.ff.visits_this_service == 0) {\n\t\t# Need to add \"Vary: User-Agent\" in after vcl_fetch to avoid the\n\t\t# \"Vary: User-Agent\" entering the Varnish cache.\n\t\t# We need \"Vary: User-Agent\" in the browser cache because a browser\n\t\t# may update itself to a version which needs different polyfills\n\t\t# So we need to have it ignore the browser cached bundle when the user-agent changes.\n\t\tset resp.http.Vary = \"User-Agent, Accept-Encoding\";\n\t}\n\n\tif (resp.status == 304) {\n\t\tset resp.http.Age = \"0\";\n\t}\n\n\tadd resp.http.Server-Timing = fastly_info.state {\", fastly;desc=\"Edge time\";dur=\"} time.elapsed.msec;\n\n\tif (req.http.Fastly-Debug) {\n\t\tset resp.http.Debug-Backend = req.http.Debug-Backend;\n\t\tset resp.http.Debug-Host = req.http.Host;\n\t\tset resp.http.Debug-Fastly-Restarts = req.restarts;\n\t\tset resp.http.Debug-Orig-URL = req.http.Orig-URL;\n\t\tset resp.http.Debug-VCL-Route = req.http.X-VCL-Route;\n\t\tset resp.http.useragent_parser_family = req.http.useragent_parser_family;\n\t\tset resp.http.useragent_parser_major = req.http.useragent_parser_major;\n\t\tset resp.http.useragent_parser_minor = req.http.useragent_parser_minor;\n\t\tset resp.http.useragent_parser_patch = req.http.useragent_parser_patch;\n\t} else {\n\t\tunset resp.http.Server;\n\t\tunset resp.http.Via;\n\t\tunset resp.http.X-Cache;\n\t\tunset resp.http.X-Cache-Hits;\n\t\tunset resp.http.X-Served-By;\n\t\tunset resp.http.X-Timer;\n\t\tunset resp.http.Fastly-Restarts;\n\t\tunset resp.http.X-PreFetch-Pass;\n\t\tunset resp.http.X-PreFetch-Miss;\n\t\tunset resp.http.X-PostFetch;\n\t}\n}\n\nsub vcl_error {\n\tif (obj.status >= 500 && obj.status < 600) {\n\t\tif (stale.exists) {\n\t\t\treturn(deliver_stale);\n\t\t}\n\t\treturn(deliver);\n\t}\n\tif (obj.status == 911) {\n\t\tset obj.status = 405;\n\t\tset obj.response = \"METHOD NOT ALLOWED\";\n\t\tset obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n\t\tset obj.http.Cache-Control = \"private, no-store\";\n\t\tsynthetic req.method \" METHOD NOT ALLOWED\";\n\t\treturn (deliver);\n\t}\n\tif (obj.status == 912) {\n\t\tset obj.status = 200;\n\t\tset obj.response = \"OK\";\n\t\tset obj.http.Allow = \"OPTIONS, GET, HEAD\";\n\t\treturn (deliver);\n\t}\n}\n","old_contents":"sub set_backend {\n\t# The Fastly macro is inserted before the backend is selected because the\n\t# macro has the code which defines the values avaiable for req.http.Host\n\t# but it also contains a default backend which is always set to the EU. I wish we could disable the default backend setting.\n\t#FASTLY recv\n\n\t# Calculate the ideal region to route the request to.\n\tdeclare local var.region STRING;\n\tif (server.region ~ \"(APAC|Asia|North-America|South-America|US-Central|US-East|US-West)\") {\n\t\tset var.region = \"US\";\n\t} else {\n\t\tset var.region = \"EU\";\n\t}\n\n\t# Gather the health of the shields and origins.\n\tdeclare local var.v3_eu_is_healthy BOOL;\n\tset req.backend = F_v3_eu;\n\tset var.v3_eu_is_healthy = req.backend.healthy;\n\n\tdeclare local var.v3_us_is_healthy BOOL;\n\tset req.backend = F_v3_us;\n\tset var.v3_us_is_healthy = req.backend.healthy;\n\n\tdeclare local var.shield_eu_is_healthy BOOL;\n\tset req.backend = ssl_shield_london_city_uk;\n\tset var.shield_eu_is_healthy = req.backend.healthy;\n\n\tdeclare local var.shield_us_is_healthy BOOL;\n\tset req.backend = ssl_shield_iad_va_us;\n\tset var.shield_us_is_healthy = req.backend.healthy;\n\n\t# Set some sort of default, that shouldn't get used.\n\tset req.backend = F_v3_eu;\n\n\tdeclare local var.EU_shield_server_name STRING;\n\tset var.EU_shield_server_name = \"LCY\";\n\n\tdeclare local var.US_shield_server_name STRING;\n\tset var.US_shield_server_name = \"IAD\";\n\n\t# Route EU requests to the nearest healthy shield or origin.\n\tif (var.region == \"EU\") {\n\t\tif (server.datacenter != var.EU_shield_server_name && fastly.ff.visits_this_service == 0 && req.restarts == 0 && var.shield_eu_is_healthy) {\n\t\t\tset req.backend = ssl_shield_london_city_uk;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} elseif (var.shield_us_is_healthy) {\n\t\t\tset req.backend = ssl_shield_iad_va_us;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_eu;\n\t\t}\n\t}\n\n\t# Route US requests to the nearest healthy shield or origin.\n\tif (var.region == \"US\") {\n\t\tif (server.datacenter != var.US_shield_server_name && fastly.ff.visits_this_service == 0 && req.restarts == 0 && var.shield_us_is_healthy) {\n\t\t\tset req.backend = ssl_shield_iad_va_us;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} elseif (var.shield_eu_is_healthy) {\n\t\t\tset req.backend = ssl_shield_london_city_uk;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_us;\n\t\t}\n\t}\n\n\t# Persist the decision so we can debug the result.\n\tset req.http.Debug-Backend = req.backend;\n}\n\nsub vcl_recv {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_recv;\n\t}\n\n\n # We use this edge dictionary item as a flag for whether to use compute-at-edge for any requests.\n # If the item is not found, then we default to `\"0\"`, which we interpret to mean the flag is off.\n\tdeclare local var.compute-at-edge-active BOOL;\n\tif (std.atoi(table.lookup(compute_at_edge_config, \"active\", \"0\")) == 1) {\n\t\tset var.compute-at-edge-active = true;\n\t} else {\n\t\tset var.compute-at-edge-active = false;\n\t}\n\tif (var.compute-at-edge-active) {\n\t\t# if the querystring parameter `use-compute-at-edge-backend` is set to yes`\n\t\t# then use the c@e backend.\n\t\t# The querystring parameter is used within our tests, so that we can confirm \n\t\t# the compute-at-edge backend is working as we expect it to.\n\t\tdeclare local var.use-compute-at-edge-backend STRING;\n\t\tset var.use-compute-at-edge-backend = querystring.get(req.url, \"use-compute-at-edge-backend\");\n\t\tif (var.use-compute-at-edge-backend == \"yes\" && (std.prefixof(req.url.path, \"\/v3\/polyfill.js\") || std.prefixof(req.url.path, \"\/v3\/polyfill.min.js\"))) {\n\t\t\tset req.backend = F_compute_at_edge;\n\t\t\tif (req.backend.healthy) {\n\t\t\t\t# if using the c@e backend then do not use the cache at all\n\t\t\t\treturn(pass);\n\t\t\t}\n # requests can set the querystring parameter to `no` to avoid ever user compute-at-edge\n # if the querystring parameter is not set to no, then we run some logic to decide whether\n # to use compute-at-edge for this request or not.\n\t\t} else if (var.use-compute-at-edge-backend != \"no\") {\n\t\t\tdeclare local var.selected BOOL;\n\t\t\tset var.selected = randombool(1, std.atoi(table.lookup(compute_at_edge_config, \"sample\", \"1000\")));\n\t\t\t# this logic is saying, only use compute-at-edge for a request which has come from outside this Fastly\n\t\t\t# service. I.E. The request has directly from a client.\n\t\t\t# We also have logic which decides how many of those direct client requests use compute-at-edge.\n\t\t\t# We default to 1 in 1000 requests using compute-at-edge, this can be configured by the edge dictionary\n\t\t\t# named `compute_at_edge_config` and the item in the dictionary named `sample`\n\t\t\tif (var.selected && fastly_info.edge.is_tls && !req.is_background_fetch && !req.is_purge && req.restarts == 0 && fastly.ff.visits_this_service == 0 && (std.prefixof(req.url.path, \"\/v3\/polyfill.js\") || std.prefixof(req.url.path, \"\/v3\/polyfill.min.js\"))) {\n\t\t\t\tset req.backend = F_compute_at_edge;\n\t\t\t\tif (req.backend.healthy) {\n\t\t\t\t\t# if using the c@e backend then do not use the cache at all\n\t\t\t\t\treturn(pass);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif (req.method != \"GET\" && req.method != \"HEAD\" && req.method != \"OPTIONS\" && req.method != \"FASTLYPURGE\" && req.method != \"PURGE\") {\n\t\terror 911;\n\t}\n\n\tif (req.method == \"OPTIONS\") {\n\t\terror 912;\n\t}\n\n\t# Because the old service had a router which allowed any words between \/v2\/polyfill. and .js\n\tif (req.url.path ~ \"^\/v2\/polyfill(\\.\\w+)(\\.\\w+)?\" && req.url.ext == \"js\") {\n\t\tif (re.group.2) {\n\t\t\tset req.url = \"\/v2\/polyfill.min.js?\" req.url.qs;\n\t\t} else {\n\t\t\tset req.url = \"\/v2\/polyfill.js?\" req.url.qs;\n\t\t}\n\t}\n\n\t# Override the v3 defaults with the defaults of v2\n\tif (req.url ~ \"^\/v2\/polyfill(\\.min)?\\.js\") {\n\t\tset req.url = regsub(req.url, \"^\/v2\", \"\/v3\");\n\t\tset req.url = querystring.set(req.url, \"version\", \"3.25.1\");\n\t\tdeclare local var.unknown STRING;\n\t\tset var.unknown = subfield(req.url.qs, \"unknown\", \"&\");\n\t\tset req.url = querystring.set(req.url, \"unknown\", if(var.unknown != \"\", var.unknown, \"ignore\"));\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\") {\n\t\tcall normalise_querystring_parameters_for_polyfill_bundle;\n\t\t# Sort the querystring parameters alphabetically to improve chances of hitting a cached copy.\n\t\t# If querystring is empty, remove the ? from the url.\n\t\tset req.url = querystring.clean(querystring.sort(req.url));\n\t\tcall set_backend;\n\t} else {\n\t\t# The request is to an endpoint which doesn't use query parameters, let's remove them to increase our cache-hit-ratio\n\t\tset req.url = querystring.remove(req.url);\n\t\tcall set_backend;\n\t}\n\n\tif (req.backend == ssl_shield_iad_va_us || req.backend == ssl_shield_london_city_uk) {\n\t\t# avoid passing stale content from Shield POP to Edge POP\n\t\tset req.max_stale_while_revalidate = 0s;\n\t} else {\n\t\tset req.http.referer_domain = if(req.http.referer ~ \"^https?\\:\\\/\\\/([^\\\/:?#]+)(?:[\\\/:?#]|$)\", re.group.1, \"\");\n\t}\n}\n\nsub vcl_hash {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_hash;\n\t}\n\n\t# We are not adding req.http.host to the hash because we want https:\/\/cdn.polyfill.io and https:\/\/polyfill.io to be a single object in the cache.\n\t# As well as any other domains we support such as polyfills.io and cdn.polyfills.io\n\t# set req.hash += req.http.host;\n\tset req.hash += req.url;\n\t# We include return(hash) to stop the function falling through to the default VCL built into varnish, which for vcl_hash will add req.url and req.http.Host to the hash.\n\treturn(hash);\n}\n\nsub vcl_miss {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_miss;\n\t}\n}\n\nsub vcl_pass {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_pass;\n\t}\n}\n\nsub vcl_fetch {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_fetch;\n\t}\n\n\t# https:\/\/yann.mandragor.org\/posts\/purge-group-pattern\/\n\tif (beresp.http.Surrogate-Key && !std.strstr(beresp.http.Surrogate-Key, \"PurgeGroup\")) {\n\t\tset beresp.http.Surrogate-Key = beresp.http.Surrogate-Key \" PurgeGroup\" randomint(0, 999);\n\t} else if (!beresp.http.Surrogate-Key) {\n\t\tset beresp.http.Surrogate-Key = \"PurgeGroup\" randomint(0, 999);\n\t}\n\n\t# These header are only required for HTML documents.\n\tif (beresp.http.Content-Type ~ \"text\/html\") {\n\t\t# Enables the cross-site scripting filter built into most modern web browsers.\n\t\tset beresp.http.X-XSS-Protection = \"1; mode=block\";\n\t}\n\t# Prevents MIME-sniffing a response away from the declared content type.\n\tset beresp.http.X-Content-Type-Options = \"nosniff\";\n\n\t# Ensure the site is only served over HTTPS and reduce the chances of someone performing a MITM attack.\n\tset beresp.http.Strict-Transport-Security = \"max-age=31536000; includeSubdomains; preload\";\n\n\t# The Referrer-Policy header governs which referrer information, sent in the Referer header, should be included with requests made.\n\t# Send a full URL when performing a same-origin request, but only send the origin of the document for other cases.\n\tset beresp.http.Referrer-Policy = \"origin-when-cross-origin\";\n\n\t# Enable purging of all objects in the Fastly cache by issuing a purge with the key \"polyfill-service\".\n\tif (beresp.http.Surrogate-Key !~ \"\\bpolyfill-service\\b\") {\n\t\tset beresp.http.Surrogate-Key = if(beresp.http.Surrogate-Key, beresp.http.Surrogate-Key \" polyfill-service\", \"polyfill-service\");\n\t}\n\n\tset beresp.http.Timing-Allow-Origin = \"*\";\n\n\tif (req.http.Normalized-User-Agent) {\n\t\tset beresp.http.Normalized-User-Agent = req.http.Normalized-User-Agent;\n\t\tset beresp.http.Detected-User-Agent = req.http.useragent_parser_family \"\/\" req.http.useragent_parser_major \".\" req.http.useragent_parser_minor \".\" req.http.useragent_parser_patch;\n\t}\n\n\t# We end up here if\n\t# - The origin is HEALTHY; and\n\t# - It returned a valid HTTP response\n\t#\n\t# We may still not want to *use* that response, if it's an HTTP error,\n\t# so that's the case we need to catch here.\n\tif (beresp.status >= 500 && beresp.status < 600) {\n\t\t# There's a stale version available! Serve it.\n\t\tif (stale.exists) {\n\t\t\treturn(deliver_stale);\n\t\t}\n\t\t# Cache the error for 1s to allow it to be used for any collapsed requests\n\t\tset beresp.cacheable = true;\n\t\tset beresp.ttl = 1s;\n\t\treturn(deliver);\n\t}\n\t# If the response is not an error, but it is stale content that's being\n\t# served from a cache upstream, cache it for a very brief period to\n\t# clear the request queue.\n\tif (beresp.status == 200 && beresp.http.x-resp-is-stale) {\n\t\tset beresp.ttl = 1s;\n\t\tset beresp.stale_while_revalidate = 0s;\n\t\tset beresp.stale_if_error = 0s;\n\t\treturn (deliver);\n\t}\n}\n\nsub vcl_deliver {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_deliver;\n\t}\n\tif (fastly_info.state ~ \"STALE\") {\n\t\tset resp.http.x-resp-is-stale = \"true\";\n\t}\n\n\tset req.http.Fastly-Force-Shield = \"yes\";\n\n\t# Allow cross origin GET, HEAD, and OPTIONS requests to be made.\n\tif (req.http.Origin) {\n\t\tset resp.http.Access-Control-Allow-Origin = \"*\";\n\t\tset resp.http.Access-Control-Allow-Methods = \"GET,HEAD,OPTIONS\";\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\" && fastly.ff.visits_this_service == 0) {\n\t\t# Need to add \"Vary: User-Agent\" in after vcl_fetch to avoid the\n\t\t# \"Vary: User-Agent\" entering the Varnish cache.\n\t\t# We need \"Vary: User-Agent\" in the browser cache because a browser\n\t\t# may update itself to a version which needs different polyfills\n\t\t# So we need to have it ignore the browser cached bundle when the user-agent changes.\n\t\tset resp.http.Vary = \"User-Agent, Accept-Encoding\";\n\t}\n\n\tif (resp.status == 304) {\n\t\tset resp.http.Age = \"0\";\n\t}\n\n\tadd resp.http.Server-Timing = fastly_info.state {\", fastly;desc=\"Edge time\";dur=\"} time.elapsed.msec;\n\n\tif (req.http.Fastly-Debug) {\n\t\tset resp.http.Debug-Backend = req.http.Debug-Backend;\n\t\tset resp.http.Debug-Host = req.http.Host;\n\t\tset resp.http.Debug-Fastly-Restarts = req.restarts;\n\t\tset resp.http.Debug-Orig-URL = req.http.Orig-URL;\n\t\tset resp.http.Debug-VCL-Route = req.http.X-VCL-Route;\n\t\tset resp.http.useragent_parser_family = req.http.useragent_parser_family;\n\t\tset resp.http.useragent_parser_major = req.http.useragent_parser_major;\n\t\tset resp.http.useragent_parser_minor = req.http.useragent_parser_minor;\n\t\tset resp.http.useragent_parser_patch = req.http.useragent_parser_patch;\n\t} else {\n\t\tunset resp.http.Server;\n\t\tunset resp.http.Via;\n\t\tunset resp.http.X-Cache;\n\t\tunset resp.http.X-Cache-Hits;\n\t\tunset resp.http.X-Served-By;\n\t\tunset resp.http.X-Timer;\n\t\tunset resp.http.Fastly-Restarts;\n\t\tunset resp.http.X-PreFetch-Pass;\n\t\tunset resp.http.X-PreFetch-Miss;\n\t\tunset resp.http.X-PostFetch;\n\t}\n}\n\nsub vcl_error {\n\tif (obj.status >= 500 && obj.status < 600) {\n\t\tif (stale.exists) {\n\t\t\treturn(deliver_stale);\n\t\t}\n\t\treturn(deliver);\n\t}\n\tif (obj.status == 911) {\n\t\tset obj.status = 405;\n\t\tset obj.response = \"METHOD NOT ALLOWED\";\n\t\tset obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n\t\tset obj.http.Cache-Control = \"private, no-store\";\n\t\tsynthetic req.method \" METHOD NOT ALLOWED\";\n\t\treturn (deliver);\n\t}\n\tif (obj.status == 912) {\n\t\tset obj.status = 200;\n\t\tset obj.response = \"OK\";\n\t\tset obj.http.Allow = \"OPTIONS, GET, HEAD\";\n\t\treturn (deliver);\n\t}\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"fd835cef04c4e4964049d889c79930cdf3fae3d2","subject":"Update fixture","message":"Update fixture","repos":"dayvson\/libvmod-api-auth,dayvson\/libvmod-api-auth,dayvson\/libvmod-api-auth,dayvson\/libvmod-api-auth","old_file":"examples\/authentication-redis.vcl","new_file":"examples\/authentication-redis.vcl","new_contents":"import authorization;\n\nsub vcl_init {\n authorization.database(\"redis\");\n authorization.database_connect(\"127.0.0.1\", 6379, \"11\");\n authorization.database_scheme(\"token\", \"secretkey\", \"ratelimit\");\n}\n\nsub vcl_recv {\n if (req.http.Authorization && req.http.X-Custom-Date) {\n if(authorization.is_valid(req.http.Authorization, req.url, req.http.X-Custom-Date)){\n return (pass);\n }else{\n error 401 \"Not Authorized\";\n }\n }\n}\n","old_contents":"import authorization;\n\nsub vcl_init {\n authorization.database(\"redis\");\n authorization.database_connect(\"127.0.0.1\", 6379, \"\");\n authorization.database_scheme(\"token\", \"secretkey\");\n}\n\nsub vcl_recv {\n if (req.http.Authorization && req.http.X-Custom-Date) {\n if(authorization.is_valid(req.http.Authorization, req.url, req.http.X-NYTV-Date)){\n return (pass);\n }else{\n error 401 \"Not Authorized\";\n }\n }\n}","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"1a2da1853621a3202844fc1db55993bc56207dcc","subject":"#722 - allow bigpipe header to stream","message":"#722 - allow bigpipe header to stream\n","repos":"amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon","old_file":"images\/varnish-drupal\/drupal.vcl","new_file":"images\/varnish-drupal\/drupal.vcl","new_contents":"vcl 4.0;\n\nimport std;\nimport dynamic;\n\n# set backend default\nbackend default {\n .host = \"${VARNISH_BACKEND_HOST:-nginx}\";\n .port = \"${VARNISH_BACKEND_PORT:-8080}\";\n .first_byte_timeout = 35m;\n .between_bytes_timeout = 10m;\n}\n\n# Allow purging from localhost\n# @TODO allow from openshift network\nacl purge {\n \"127.0.0.1\";\n \"10.0.0.0\"\/8;\n \"172.16.0.0\"\/12;\n \"192.168.0.0\"\/16;\n}\n\nsub vcl_init {\n new www_dir = dynamic.director(\n port = \"${VARNISH_BACKEND_PORT:-8080}\",\n first_byte_timeout = 90s,\n between_bytes_timeout = 90s,\n ttl = 60s);\n}\n\n# This configuration is optimized for Drupal hosting:\n# Respond to incoming requests.\nsub vcl_recv {\n if (req.url ~ \"^\/varnish_status$\") {\n return (synth(200,\"OK\"));\n }\n # set the backend, which should be used:\n set req.backend_hint = www_dir.backend(\"${VARNISH_BACKEND_HOST:-nginx}\");\n\n # Always set the forward ip.\n if (req.restarts == 0) {\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n\n\n if (req.http.X-LAGOON-VARNISH ) {\n ## Pass all Requests which are handled via an upstream Varnish\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, \" + req.http.X-LAGOON-VARNISH;\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n } else if (req.http.Fastly-FF) {\n ## Pass all Requests which are handled via Fastly\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, fastly\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n set req.http.X-Forwarded-For = req.http.Fastly-Client-IP;\n } else if (req.http.CF-RAY) {\n ## Pass all Requests which are handled via CloudFlare\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, cloudflare\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n set req.http.X-Forwarded-For = req.http.CF-Connecting-IP;\n } else if (req.http.X-Pull) {\n ## Pass all Requests which are handled via KeyCDN\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, keycdn\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n } else {\n ## We set a header to let a Varnish Chain know that it already has been varnishcached\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}\";\n\n ## Allow to bypass based on env variable `VARNISH_BYPASS`\n set req.http.X-LAGOON-VARNISH-BYPASS = \"${VARNISH_BYPASS:-false}\";\n }\n\n # Websockets are piped\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n if (req.http.X-LAGOON-VARNISH-BYPASS == \"true\" || req.http.X-LAGOON-VARNISH-BYPASS == \"TRUE\") {\n return (pass);\n }\n\n # SA-CORE-2014-004 preventing access to \/xmlrpc.php\n if (req.url ~ \"^\/xmlrpc.php$\") {\n return (synth(701, \"Unauthorized\"));\n }\n\n # Strip out Google Analytics campaign variables. They are only needed\n # by the javascript running on the page\n # utm_source, utm_medium, utm_campaign, gclid\n if(req.url ~ \"(\\?|&)(gclid|utm_[a-z]+)=\") {\n set req.url = regsuball(req.url, \"(gclid|utm_[a-z]+)=[^\\&]+&?\", \"\");\n set req.url = regsub(req.url, \"(\\?|&)$\", \"\");\n }\n\n # Bypass a cache hit (the request is still sent to the backend)\n if (req.method == \"REFRESH\") {\n if (!client.ip ~ purge) { return (synth(405, \"Not allowed\")); }\n set req.method = \"GET\";\n set req.hash_always_miss = true;\n }\n\n # Only allow BAN requests from IP addresses in the 'purge' ACL.\n if (req.method == \"BAN\" || req.method == \"URIBAN\" || req.method == \"PURGE\") {\n # Only allow BAN from defined ACL\n if (!client.ip ~ purge) {\n return (synth(403, \"Your IP is not allowed.\"));\n }\n\n # Only allows BAN if the Host Header has the style of with \"${SERVICE_NAME:-varnish}:8080\" or \"${SERVICE_NAME:-varnish}\".\n # Such a request is only possible from within the Docker network, as a request from external goes trough the Kubernetes Router and for that needs a proper Host Header\n if (!req.http.host ~ \"^${SERVICE_NAME:-varnish}(:\\d+)?$\") {\n return (synth(403, \"Only allowed from within own network.\"));\n }\n\n if (req.method == \"BAN\") {\n # Logic for the ban, using the Cache-Tags header.\n if (req.http.Cache-Tags) {\n ban(\"obj.http.Cache-Tags ~ \" + req.http.Cache-Tags);\n # Throw a synthetic page so the request won't go to the backend.\n return (synth(200, \"Ban added.\"));\n }\n else {\n return (synth(403, \"Cache-Tags header missing.\"));\n }\n }\n\n if (req.method == \"URIBAN\" || req.method == \"PURGE\") {\n ban(\"req.url ~ \" + req.url);\n # Throw a synthetic page so the request won't go to the backend.\n return (synth(200, \"Ban added.\"));\n }\n\n }\n\n # Non-RFC2616 or CONNECT which is weird, we pipe that\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n return (pipe);\n }\n\n # We only try to cache GET and HEAD, other things are passed\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n # Any requests with Basic Auth are passed\n if (req.http.Authorization || req.http.Authenticate)\n {\n return (pass);\n }\n\n ## Pass requests which are from blackfire\n if (req.http.X-Blackfire-Query) {\n return (pass);\n }\n\n # Some URLs should never be cached\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/admin([\/?]|$).*$\" ||\n req.url ~ \"^\/info([\/?]|$).*$\" ||\n req.url ~ \"^\/flag([\/?]|$).*$\" ||\n req.url ~ \"^.*\/system\/files([\/?]|$).*$\" ||\n req.url ~ \"^\/cgi\" ||\n req.url ~ \"^\/cgi-bin\"\n ) {\n return (pass);\n }\n\n # Plupload likes to get piped\n if (req.url ~ \"^.*\/plupload-handle-uploads.*$\"\n ) {\n return (pipe);\n }\n\n # Handle compression correctly. Different browsers send different\n # \"Accept-Encoding\" headers, even though they mostly all support the same\n # compression mechanisms. By consolidating these compression headers into\n # a consistent format, we can reduce the size of the cache and get more hits.=\n # @see: http:\/\/ varnish.projects.linpro.no\/wiki\/FAQ\/Compression\n if (req.http.Accept-Encoding) {\n if (req.http.Accept-Encoding ~ \"gzip\") {\n # If the browser supports it, we'll use gzip.\n set req.http.Accept-Encoding = \"gzip\";\n }\n else if (req.http.Accept-Encoding ~ \"deflate\") {\n # Next, try deflate if it is supported.\n set req.http.Accept-Encoding = \"deflate\";\n }\n else {\n # Unknown algorithm. Remove it and send unencoded.\n unset req.http.Accept-Encoding;\n }\n }\n\n # Always cache the following file types for all users.\n if (req.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n unset req.http.Cookie;\n }\n\n # Remove all cookies that Drupal doesn't need to know about. ANY remaining\n # cookie will cause the request to pass-through to a backend. For the most part\n # we always set the NO_CACHE cookie after any POST request, disabling the\n # Varnish cache temporarily. The session cookie allows all authenticated users\n # to pass through as long as they're logged in.\n #\n # 1. Append a semi-colon to the front of the cookie string.\n # 2. Remove all spaces that appear after semi-colons.\n # 3. Match the cookies we want to keep, adding the space we removed\n # previously, back. (\\1) is first matching group in the regsuball.\n # 4. Remove all other cookies, identifying them by the fact that they have\n # no space after the preceding semi-colon.\n # 5. Remove all spaces and semi-colons from the beginning and end of the\n # cookie string.\n if (req.http.Cookie) {\n set req.http.CookieCheck = \";\" + req.http.Cookie;\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"; +\", \";\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";(${VARNISH_COOKIECHECK:-SESS[a-z0-9]+|SSESS[a-z0-9]+|NO_CACHE})=\", \"; \\1=\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";[^ ][^;]*\", \"\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"^[; ]+|[; ]+$\", \"\");\n\n set req.http.Cookie = req.http.Cookie + \";\";\n\n if (req.http.CookieCheck == \"\") {\n # If there are no remaining cookies, remove the cookie header. If there\n # aren't any cookie headers, Varnish's default behavior will be to cache\n # the page.\n\n unset req.http.CookieCheck;\n unset req.http.Cookie;\n }\n else {\n # If there is any cookies left (a session or NO_CACHE cookie), do not\n # cache the page. Pass it on to Apache directly.\n unset req.http.CookieCheck;\n return (pass);\n }\n }\n\n # Cacheable, lookup in cache.\n return (hash);\n}\n\nsub vcl_pipe {\n # Support for Websockets\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n set bereq.http.connection = req.http.connection;\n }\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n # normal hit\n return (deliver);\n }\n # We have no fresh fish. Lets look at the stale ones.\n if (std.healthy(req.backend_hint)) {\n # Backend is healthy. If the object is not older then 30secs, deliver it to the client\n # and automatically create a separate backend request to warm the cache for this request.\n if (obj.ttl + 30s > 0s) {\n set req.http.grace = \"normal(limited)\";\n return (deliver);\n } else {\n # No candidate for grace. Fetch a fresh object.\n return(miss);\n }\n } else {\n # backend is sick - use full grace\n if (obj.ttl + obj.grace > 0s) {\n set req.http.grace = \"full\";\n return (deliver);\n } else {\n # no graced object.\n return (miss);\n }\n }\n}\n\nsub vcl_backend_response {\n # Allow items to be stale if needed.\n set beresp.grace = 6h;\n\n # Set ban-lurker friendly custom headers.\n set beresp.http.X-Url = bereq.url;\n set beresp.http.X-Host = bereq.http.host;\n\n # If the backend sends a X-LAGOON-VARNISH-BACKEND-BYPASS header we directly deliver\n if(beresp.http.X-LAGOON-VARNISH-BACKEND-BYPASS == \"TRUE\") {\n return (deliver);\n }\n\n # Cache 404 and 403 for 10 seconds\n if(beresp.status == 404 || beresp.status == 403) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n # Don't allow static files to set cookies.\n if (bereq.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n # beresp == Back-end response from the web server.\n unset beresp.http.set-cookie;\n unset beresp.http.Cache-Control;\n\n # If an asset would come back with statuscode 500 we only cache it for 10 seconds instead of the usual static file cache\n if (beresp.status == 500) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n set beresp.ttl = ${VARNISH_ASSETS_TTL:-2628001}s;\n set beresp.http.Cache-Control = \"public, max-age=${VARNISH_ASSETS_TTL:-2628001}\";\n set beresp.http.Expires = \"\" + (now + beresp.ttl);\n }\n # Disable buffering only for BigPipe responses\n if (beresp.http.Surrogate-Control ~ \"BigPipe\/1.0\") {\n set beresp.do_stream = true;\n set beresp.ttl = 0s;\n }\n\n return (deliver);\n}\n\n# Set a header to track a cache HIT\/MISS.\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Varnish-Cache = \"HIT\";\n }\n else {\n set resp.http.X-Varnish-Cache = \"MISS\";\n }\n\n # Remove ban-lurker friendly custom headers when delivering to client.\n unset resp.http.X-Url;\n unset resp.http.X-Host;\n\n # unset Cache-Tags Header by default, can be disabled with VARNISH_UNSET_HEADER_CACHE_TAGS=true\n if (!${VARNISH_UNSET_HEADER_CACHE_TAGS:-false}) {\n unset resp.http.Cache-Tags;\n }\n\n unset resp.http.X-Generator;\n unset resp.http.Server;\n # Inject information about grace\n if (req.http.grace) {\n set resp.http.X-Varnish-Grace = req.http.grace;\n }\n set resp.http.X-LAGOON = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}>\" + resp.http.X-LAGOON;\n return (deliver);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n if (req.http.X-Forwarded-Proto) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n if (req.http.HTTPS) {\n hash_data(req.http.HTTPS);\n }\n return (lookup);\n}\n\nsub vcl_synth {\n if (resp.status == 701) {\n set resp.status = 401;\n set resp.http.Content-Type = \"text\/plain; charset=utf-8\";\n synthetic({\"XMLRPC Interface is blocked due to SA-CORE-2014-004 - mail support@amazee.io if you need it.\"});\n return (deliver);\n }\n if (resp.status == 700) {\n # Set a status the client will understand\n set resp.status = 200;\n # Create our synthetic response\n synthetic(\"\");\n return(deliver);\n}\n return (deliver);\n}\n\nsub vcl_backend_error {\n # Restart the request, when we have a backend server error, to try another backend.\n # Restart max twice.\n if (bereq.retries < 2) {\n return(retry);\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<head>\n <title>Server Error<\/title>\n <style type=\"text\/css\">\n body {\n font-family: helvetica, arial, sans-serif;\n }\n img {\n margin-top: 50px;\n }\n p {\n width: 6 00px;\n margin-top: 10px\n }\n div {\n background: #ccc;\n width: 600px;\n margin: auto;\n padding: 50px;\n }\n span {\n color: #ccc\n }\n <\/style>\n<\/head>\n<body>\n <div>\n <h1>We are sorry...<\/h1>\n <p>We encountered a server-side error. This means that the problem is not with your computer or Internet connection, but rather with the website's server.<\/p>\n <p>We are currently working on solving this problem and apologise for the inconvenience.<\/p>\n <span>\n <strong>Technical Information<\/strong><br \/>\n Error \"} + beresp.status + \" \" + beresp.reason + {\"<br \/>\n XID: \"} + bereq.xid + {\"<br \/>\n <\/span>\n <\/div>\n<\/body>\n<\/html>\n\n\"} );\n return (deliver);\n}\n","old_contents":"vcl 4.0;\n\nimport std;\nimport dynamic;\n\n# set backend default\nbackend default {\n .host = \"${VARNISH_BACKEND_HOST:-nginx}\";\n .port = \"${VARNISH_BACKEND_PORT:-8080}\";\n .first_byte_timeout = 35m;\n .between_bytes_timeout = 10m;\n}\n\n# Allow purging from localhost\n# @TODO allow from openshift network\nacl purge {\n \"127.0.0.1\";\n \"10.0.0.0\"\/8;\n \"172.16.0.0\"\/12;\n \"192.168.0.0\"\/16;\n}\n\nsub vcl_init {\n new www_dir = dynamic.director(\n port = \"${VARNISH_BACKEND_PORT:-8080}\",\n first_byte_timeout = 90s,\n between_bytes_timeout = 90s,\n ttl = 60s);\n}\n\n# This configuration is optimized for Drupal hosting:\n# Respond to incoming requests.\nsub vcl_recv {\n if (req.url ~ \"^\/varnish_status$\") {\n return (synth(200,\"OK\"));\n }\n # set the backend, which should be used:\n set req.backend_hint = www_dir.backend(\"${VARNISH_BACKEND_HOST:-nginx}\");\n\n # Always set the forward ip.\n if (req.restarts == 0) {\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n\n\n if (req.http.X-LAGOON-VARNISH ) {\n ## Pass all Requests which are handled via an upstream Varnish\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, \" + req.http.X-LAGOON-VARNISH;\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n } else if (req.http.Fastly-FF) {\n ## Pass all Requests which are handled via Fastly\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, fastly\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n set req.http.X-Forwarded-For = req.http.Fastly-Client-IP;\n } else if (req.http.CF-RAY) {\n ## Pass all Requests which are handled via CloudFlare\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, cloudflare\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n set req.http.X-Forwarded-For = req.http.CF-Connecting-IP;\n } else if (req.http.X-Pull) {\n ## Pass all Requests which are handled via KeyCDN\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, keycdn\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n } else {\n ## We set a header to let a Varnish Chain know that it already has been varnishcached\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}\";\n\n ## Allow to bypass based on env variable `VARNISH_BYPASS`\n set req.http.X-LAGOON-VARNISH-BYPASS = \"${VARNISH_BYPASS:-false}\";\n }\n\n # Websockets are piped\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n if (req.http.X-LAGOON-VARNISH-BYPASS == \"true\" || req.http.X-LAGOON-VARNISH-BYPASS == \"TRUE\") {\n return (pass);\n }\n\n # SA-CORE-2014-004 preventing access to \/xmlrpc.php\n if (req.url ~ \"^\/xmlrpc.php$\") {\n return (synth(701, \"Unauthorized\"));\n }\n\n # Strip out Google Analytics campaign variables. They are only needed\n # by the javascript running on the page\n # utm_source, utm_medium, utm_campaign, gclid\n if(req.url ~ \"(\\?|&)(gclid|utm_[a-z]+)=\") {\n set req.url = regsuball(req.url, \"(gclid|utm_[a-z]+)=[^\\&]+&?\", \"\");\n set req.url = regsub(req.url, \"(\\?|&)$\", \"\");\n }\n\n # Bypass a cache hit (the request is still sent to the backend)\n if (req.method == \"REFRESH\") {\n if (!client.ip ~ purge) { return (synth(405, \"Not allowed\")); }\n set req.method = \"GET\";\n set req.hash_always_miss = true;\n }\n\n # Only allow BAN requests from IP addresses in the 'purge' ACL.\n if (req.method == \"BAN\" || req.method == \"URIBAN\" || req.method == \"PURGE\") {\n # Only allow BAN from defined ACL\n if (!client.ip ~ purge) {\n return (synth(403, \"Your IP is not allowed.\"));\n }\n\n # Only allows BAN if the Host Header has the style of with \"${SERVICE_NAME:-varnish}:8080\" or \"${SERVICE_NAME:-varnish}\".\n # Such a request is only possible from within the Docker network, as a request from external goes trough the Kubernetes Router and for that needs a proper Host Header\n if (!req.http.host ~ \"^${SERVICE_NAME:-varnish}(:\\d+)?$\") {\n return (synth(403, \"Only allowed from within own network.\"));\n }\n\n if (req.method == \"BAN\") {\n # Logic for the ban, using the Cache-Tags header.\n if (req.http.Cache-Tags) {\n ban(\"obj.http.Cache-Tags ~ \" + req.http.Cache-Tags);\n # Throw a synthetic page so the request won't go to the backend.\n return (synth(200, \"Ban added.\"));\n }\n else {\n return (synth(403, \"Cache-Tags header missing.\"));\n }\n }\n\n if (req.method == \"URIBAN\" || req.method == \"PURGE\") {\n ban(\"req.url ~ \" + req.url);\n # Throw a synthetic page so the request won't go to the backend.\n return (synth(200, \"Ban added.\"));\n }\n\n }\n\n # Non-RFC2616 or CONNECT which is weird, we pipe that\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n return (pipe);\n }\n\n # We only try to cache GET and HEAD, other things are passed\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n # Any requests with Basic Auth are passed\n if (req.http.Authorization || req.http.Authenticate)\n {\n return (pass);\n }\n\n ## Pass requests which are from blackfire\n if (req.http.X-Blackfire-Query) {\n return (pass);\n }\n\n # Some URLs should never be cached\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/admin([\/?]|$).*$\" ||\n req.url ~ \"^\/info([\/?]|$).*$\" ||\n req.url ~ \"^\/flag([\/?]|$).*$\" ||\n req.url ~ \"^.*\/system\/files([\/?]|$).*$\" ||\n req.url ~ \"^\/cgi\" ||\n req.url ~ \"^\/cgi-bin\"\n ) {\n return (pass);\n }\n\n # Plupload likes to get piped\n if (req.url ~ \"^.*\/plupload-handle-uploads.*$\"\n ) {\n return (pipe);\n }\n\n # Handle compression correctly. Different browsers send different\n # \"Accept-Encoding\" headers, even though they mostly all support the same\n # compression mechanisms. By consolidating these compression headers into\n # a consistent format, we can reduce the size of the cache and get more hits.=\n # @see: http:\/\/ varnish.projects.linpro.no\/wiki\/FAQ\/Compression\n if (req.http.Accept-Encoding) {\n if (req.http.Accept-Encoding ~ \"gzip\") {\n # If the browser supports it, we'll use gzip.\n set req.http.Accept-Encoding = \"gzip\";\n }\n else if (req.http.Accept-Encoding ~ \"deflate\") {\n # Next, try deflate if it is supported.\n set req.http.Accept-Encoding = \"deflate\";\n }\n else {\n # Unknown algorithm. Remove it and send unencoded.\n unset req.http.Accept-Encoding;\n }\n }\n\n # Always cache the following file types for all users.\n if (req.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n unset req.http.Cookie;\n }\n\n # Remove all cookies that Drupal doesn't need to know about. ANY remaining\n # cookie will cause the request to pass-through to a backend. For the most part\n # we always set the NO_CACHE cookie after any POST request, disabling the\n # Varnish cache temporarily. The session cookie allows all authenticated users\n # to pass through as long as they're logged in.\n #\n # 1. Append a semi-colon to the front of the cookie string.\n # 2. Remove all spaces that appear after semi-colons.\n # 3. Match the cookies we want to keep, adding the space we removed\n # previously, back. (\\1) is first matching group in the regsuball.\n # 4. Remove all other cookies, identifying them by the fact that they have\n # no space after the preceding semi-colon.\n # 5. Remove all spaces and semi-colons from the beginning and end of the\n # cookie string.\n if (req.http.Cookie) {\n set req.http.CookieCheck = \";\" + req.http.Cookie;\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"; +\", \";\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";(${VARNISH_COOKIECHECK:-SESS[a-z0-9]+|SSESS[a-z0-9]+|NO_CACHE})=\", \"; \\1=\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";[^ ][^;]*\", \"\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"^[; ]+|[; ]+$\", \"\");\n\n set req.http.Cookie = req.http.Cookie + \";\";\n\n if (req.http.CookieCheck == \"\") {\n # If there are no remaining cookies, remove the cookie header. If there\n # aren't any cookie headers, Varnish's default behavior will be to cache\n # the page.\n\n unset req.http.CookieCheck;\n unset req.http.Cookie;\n }\n else {\n # If there is any cookies left (a session or NO_CACHE cookie), do not\n # cache the page. Pass it on to Apache directly.\n unset req.http.CookieCheck;\n return (pass);\n }\n }\n\n # Cacheable, lookup in cache.\n return (hash);\n}\n\nsub vcl_pipe {\n # Support for Websockets\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n set bereq.http.connection = req.http.connection;\n }\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n # normal hit\n return (deliver);\n }\n # We have no fresh fish. Lets look at the stale ones.\n if (std.healthy(req.backend_hint)) {\n # Backend is healthy. If the object is not older then 30secs, deliver it to the client\n # and automatically create a separate backend request to warm the cache for this request.\n if (obj.ttl + 30s > 0s) {\n set req.http.grace = \"normal(limited)\";\n return (deliver);\n } else {\n # No candidate for grace. Fetch a fresh object.\n return(miss);\n }\n } else {\n # backend is sick - use full grace\n if (obj.ttl + obj.grace > 0s) {\n set req.http.grace = \"full\";\n return (deliver);\n } else {\n # no graced object.\n return (miss);\n }\n }\n}\n\nsub vcl_backend_response {\n # Allow items to be stale if needed.\n set beresp.grace = 6h;\n\n # Set ban-lurker friendly custom headers.\n set beresp.http.X-Url = bereq.url;\n set beresp.http.X-Host = bereq.http.host;\n\n # If the backend sends a X-LAGOON-VARNISH-BACKEND-BYPASS header we directly deliver\n if(beresp.http.X-LAGOON-VARNISH-BACKEND-BYPASS == \"TRUE\") {\n return (deliver);\n }\n\n # Cache 404 and 403 for 10 seconds\n if(beresp.status == 404 || beresp.status == 403) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n # Don't allow static files to set cookies.\n if (bereq.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n # beresp == Back-end response from the web server.\n unset beresp.http.set-cookie;\n unset beresp.http.Cache-Control;\n\n # If an asset would come back with statuscode 500 we only cache it for 10 seconds instead of the usual static file cache\n if (beresp.status == 500) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n set beresp.ttl = ${VARNISH_ASSETS_TTL:-2628001}s;\n set beresp.http.Cache-Control = \"public, max-age=${VARNISH_ASSETS_TTL:-2628001}\";\n set beresp.http.Expires = \"\" + (now + beresp.ttl);\n }\n\n return (deliver);\n}\n\n# Set a header to track a cache HIT\/MISS.\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Varnish-Cache = \"HIT\";\n }\n else {\n set resp.http.X-Varnish-Cache = \"MISS\";\n }\n\n # Remove ban-lurker friendly custom headers when delivering to client.\n unset resp.http.X-Url;\n unset resp.http.X-Host;\n\n # unset Cache-Tags Header by default, can be disabled with VARNISH_UNSET_HEADER_CACHE_TAGS=true\n if (!${VARNISH_UNSET_HEADER_CACHE_TAGS:-false}) {\n unset resp.http.Cache-Tags;\n }\n\n unset resp.http.X-Generator;\n unset resp.http.Server;\n # Inject information about grace\n if (req.http.grace) {\n set resp.http.X-Varnish-Grace = req.http.grace;\n }\n set resp.http.X-LAGOON = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}>\" + resp.http.X-LAGOON;\n return (deliver);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n if (req.http.X-Forwarded-Proto) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n if (req.http.HTTPS) {\n hash_data(req.http.HTTPS);\n }\n return (lookup);\n}\n\nsub vcl_synth {\n if (resp.status == 701) {\n set resp.status = 401;\n set resp.http.Content-Type = \"text\/plain; charset=utf-8\";\n synthetic({\"XMLRPC Interface is blocked due to SA-CORE-2014-004 - mail support@amazee.io if you need it.\"});\n return (deliver);\n }\n if (resp.status == 700) {\n # Set a status the client will understand\n set resp.status = 200;\n # Create our synthetic response\n synthetic(\"\");\n return(deliver);\n}\n return (deliver);\n}\n\nsub vcl_backend_error {\n # Restart the request, when we have a backend server error, to try another backend.\n # Restart max twice.\n if (bereq.retries < 2) {\n return(retry);\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<head>\n <title>Server Error<\/title>\n <style type=\"text\/css\">\n body {\n font-family: helvetica, arial, sans-serif;\n }\n img {\n margin-top: 50px;\n }\n p {\n width: 6 00px;\n margin-top: 10px\n }\n div {\n background: #ccc;\n width: 600px;\n margin: auto;\n padding: 50px;\n }\n span {\n color: #ccc\n }\n <\/style>\n<\/head>\n<body>\n <div>\n <h1>We are sorry...<\/h1>\n <p>We encountered a server-side error. This means that the problem is not with your computer or Internet connection, but rather with the website's server.<\/p>\n <p>We are currently working on solving this problem and apologise for the inconvenience.<\/p>\n <span>\n <strong>Technical Information<\/strong><br \/>\n Error \"} + beresp.status + \" \" + beresp.reason + {\"<br \/>\n XID: \"} + bereq.xid + {\"<br \/>\n <\/span>\n <\/div>\n<\/body>\n<\/html>\n\n\"} );\n return (deliver);\n}\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"4d82af2dc12cda27ef83144752675f0d32edd719","subject":"Simplified regexp as a result of previous aggressive filtration.","message":"Simplified regexp as a result of previous aggressive filtration.\n","repos":"telusdigital\/ansible-varnish,noqcks\/ansible-varnish,gotofbi\/ansible-varnish,killerwails\/ansible-varnish,kkwoker\/ansible-varnish,gotofbi\/ansible-varnish,killerwails\/ansible-varnish,colstrom\/ansible-varnish","old_file":"templates\/etc\/varnish\/default.vcl","new_file":"templates\/etc\/varnish\/default.vcl","new_contents":"vcl 4.0;\n\nimport directors;\nimport std;\n\n###\n# Varnish Documentation\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-built-in-subs.html\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/reference\/vcl.html\n##\n\n{% for backend in varnish_backend_hosts %}\nbackend application_{{ loop.index }} {\n .host = \"{{ backend }}\";\n .port = \"{{ varnish_backend_port }}\";\n{% if varnish_health_checks_enabled %}\n .probe = {\n .url = \"{{ varnish_health_check_url }}\";\n .interval = {{ varnish_health_check_interval }};\n .timeout = {{ varnish_health_check_timeout }};\n .window = {{ varnish_health_check_window }};\n .threshold = {{ varnish_health_check_threshold }};\n }\n{% endif %}\n}\n{% endfor %}\n\n###\n# vcl_init\n# Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n###\n# The vcl_init subroutine may terminate with calling return() with one of the following keywords:\n#\n# ok\n# Normal return, VCL continues loading.\n##\n\nsub vcl_init {\n new application = directors.round_robin();\n{% for backend in varnish_backend_hosts %}\n application.add_backend(application_{{ loop.index }});\n{% endfor %}\n}\n\n###\n# vcl_recv\n# Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use. \n# It is also used to modify the request\n###\n# The vcl_recv subroutine may terminate with calling return() on one of the following keywords:\n#\n# synth(status code, reason)\n# Return a synthetic object with the specified status code to the client and abandon the request.\n# pass\n# Switch to pass mode. Control will eventually pass to vcl_pass.\n# pipe\n# Switch to pipe mode. Control will eventually pass to vcl_pipe.\n# hash\n# Continue processing the object as a potential candidate for caching. Passes the control over to vcl_hash.\n# purge\n# Purge the object and it's variants. Control passes through vcl_hash to vcl_purge.\n#\n\nsub vcl_recv {\n set req.backend_hint = application.backend();\n\n ###\n # Avoid processing uncacheable requests\n ###\n\n if (req.http.Authorization) {\n return (pass);\n }\n\n ###\n # Inject X-Forwarded-For headers, but only once.\n ###\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n{% if varnish_header_sanitization_enabled %}\n ###\n # Header Sanitization\n ###\n\n{% if varnish_discards_port_from_host_header %}\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n{% endif %}\n\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_enabled %}\n ###\n # Cookie Sanitization\n ###\n\n ### Google Analytics\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n\n ### Quantcast\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n \n ### AddThis\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n\n ### General Cleanup\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n{% endif %}\n\n{% if varnish_uri_sanitization_enabled %}\n ###\n # URI Sanitization\n ###\n \n if (req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=\") {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n{% endif %}\n\n{% if varnish_workaround_telusdotcom_browser_profile %}\n ###\n # Workaround for BrowserProfile and Language\/Region Detection on TELUS.com\n ###\n\n if (req.http.Cookie ~ \"BrowserProfile\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.Cookie, \"(.*)language..:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n set req.http.X-Province = std.tolower(regsuball(regsuball(req.http.Cookie, \"geo\\\\.\\:{(.*)\\}\", \"\"), \"(.*)region..:\\\\.([^\\\\]*)(.*)\", \"\\3\"));\n } else {\n if (req.http.Cookie ~ \"lang=\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.Cookie, \"(.*)lang=([^;]*)(.*)\", \"\\2\"));\n } else {\n set req.http.X-Language = \"en\";\n }\n\n if (req.http.Cookie ~ \"prov=\") {\n set req.http.X-Province = std.tolower(regsuball(req.http.Cookie, \"(.*)prov=([^;]*)(.*)\", \"\\2\"));\n } else {\n set req.http.X-Province = \"BC\";\n }\n }\n\n if (req.url ~ \"\/(en|fr)\/\") {\n if (req.url ~ \"\/en\/\" && req.http.X-Language != \"en\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Language)\";\n return(pass);\n }\n if (req.url ~ \"\/fr\/\" && req.http.X-Language != \"fr\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Language)\";\n return(pass);\n }\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Language)\";\n return(pass);\n }\n\n if (req.url ~ \"\/(ab|bc|mb|nb|nl|ns|nt|nu|on|pe|qc|sk|yt)\/\") {\n {% for province in ['ab', 'bc', 'mb', 'nb', 'nl', 'ns', 'nt', 'nu', 'on', 'pe', 'qc', 'sk', 'yt'] %}\n if (req.url ~ \"\/{{ province }}\/\" && req.http.X-Province != \"{{ province }}\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Province)\";\n return(pass);\n }\n {% endfor %}\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Province)\";\n return(pass);\n }\n{% endif %}\n\n{% if varnish_blacklist_enabled %}\n if ((req.url ~ \"{{ varnish_blacklist_regexp }}\")) {\n set req.http.X-Passthrough-Reason = \"Path in Blacklist\";\n return(pass);\n } else {\n{% if varnish_discards_client_cookies %}\n unset req.http.Cookie;\n{% endif %}\n }\n{% endif %}\n\n}\n\n###\n# vcl_hit\n# Called when a cache lookup is successful.\n###\n# The vcl_hit subroutine may terminate with calling return() with one of the following keywords:\n#\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n# deliver\n# Deliver the object. Control passes to vcl_deliver.\n# synth(status code, reason)\n# Return the specified status code to the client and abandon the request.\n###\n\nsub vcl_hit {\n if (obj.ttl > 0s) {\n return (deliver);\n }\n{% if varnish_health_checks_enabled %}\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (fetch);\n }\n{% else %}\n if (obj.ttl + obj.grace > 0s) {\n return (deliver);\n }\n\n return (fetch);\n{% endif %}\n}\n\n###\n# vcl_backend_response\n# Called after the response headers has been successfully retrieved from the backend.\n###\n# The vcl_backend_response subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Possibly insert the object into the cache, then deliver it to the Control will eventually pass to vcl_deliver.\n# abandon\n# Abandon the backend request and generates an error.\n# retry\n# Retry the backend transaction. Increases the retries counter. If the number of retries is higher than max_retries Varnish emits a guru meditation error.\n###\n\nsub vcl_backend_response {\n{% if varnish_workaround_telusdotcom_browser_profile %}\n if (bereq.http.X-Language) {\n set beresp.http.X-Language = bereq.http.X-Language;\n }\n if (bereq.http.X-Province) {\n set beresp.http.X-Province = bereq.http.X-Province;\n }\n{% endif %}\n\n{% if varnish_blacklist_enabled %}\n if (bereq.url ~ \"{{ varnish_blacklist_regexp }}\") {\n set beresp.http.X-Cacheable = \"NO:Path in Blacklist\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n if (bereq.http.X-Passthrough-Reason) {\n set beresp.http.X-Passthrough-Reason = bereq.http.X-Passthrough-Reason;\n return(deliver);\n } else {\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n }\n }\n{% else %}\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n{% endif %}\n\n{% if varnish_cache_diagnostics_enabled %}\n if (bereq.http.Cookie) {\n set beresp.http.X-Cacheable = \"NO:Cookie in Request\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO:Set-Cookie in Response\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.X-No-Cache) {\n set beresp.http.X-Cacheable = \"NO:X-No-Cache\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.ttl <= 0s) {\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n{% endif %}\n\n set beresp.grace = {{ varnish_grace_period }};\n}\n\n###\n# vcl_deliver\n# Called before a cached object is delivered to the client.\n###\n# The vcl_deliver subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Deliver the object to the client.\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n###\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n","old_contents":"vcl 4.0;\n\nimport directors;\nimport std;\n\n###\n# Varnish Documentation\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-built-in-subs.html\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/reference\/vcl.html\n##\n\n{% for backend in varnish_backend_hosts %}\nbackend application_{{ loop.index }} {\n .host = \"{{ backend }}\";\n .port = \"{{ varnish_backend_port }}\";\n{% if varnish_health_checks_enabled %}\n .probe = {\n .url = \"{{ varnish_health_check_url }}\";\n .interval = {{ varnish_health_check_interval }};\n .timeout = {{ varnish_health_check_timeout }};\n .window = {{ varnish_health_check_window }};\n .threshold = {{ varnish_health_check_threshold }};\n }\n{% endif %}\n}\n{% endfor %}\n\n###\n# vcl_init\n# Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n###\n# The vcl_init subroutine may terminate with calling return() with one of the following keywords:\n#\n# ok\n# Normal return, VCL continues loading.\n##\n\nsub vcl_init {\n new application = directors.round_robin();\n{% for backend in varnish_backend_hosts %}\n application.add_backend(application_{{ loop.index }});\n{% endfor %}\n}\n\n###\n# vcl_recv\n# Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use. \n# It is also used to modify the request\n###\n# The vcl_recv subroutine may terminate with calling return() on one of the following keywords:\n#\n# synth(status code, reason)\n# Return a synthetic object with the specified status code to the client and abandon the request.\n# pass\n# Switch to pass mode. Control will eventually pass to vcl_pass.\n# pipe\n# Switch to pipe mode. Control will eventually pass to vcl_pipe.\n# hash\n# Continue processing the object as a potential candidate for caching. Passes the control over to vcl_hash.\n# purge\n# Purge the object and it's variants. Control passes through vcl_hash to vcl_purge.\n#\n\nsub vcl_recv {\n set req.backend_hint = application.backend();\n\n ###\n # Avoid processing uncacheable requests\n ###\n\n if (req.http.Authorization) {\n return (pass);\n }\n\n ###\n # Inject X-Forwarded-For headers, but only once.\n ###\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n{% if varnish_header_sanitization_enabled %}\n ###\n # Header Sanitization\n ###\n\n{% if varnish_discards_port_from_host_header %}\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n{% endif %}\n\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_enabled %}\n ###\n # Cookie Sanitization\n ###\n\n ### Google Analytics\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n\n ### Quantcast\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n \n ### AddThis\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n\n ### General Cleanup\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n{% endif %}\n\n{% if varnish_uri_sanitization_enabled %}\n ###\n # URI Sanitization\n ###\n \n if (req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=\") {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n{% endif %}\n\n{% if varnish_workaround_telusdotcom_browser_profile %}\n ###\n # Workaround for BrowserProfile and Language\/Region Detection on TELUS.com\n ###\n\n if (req.http.Cookie ~ \"BrowserProfile\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.Cookie, \"(.*)language..:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n set req.http.X-Province = std.tolower(regsuball(regsuball(req.http.Cookie, \"geo\\\\.\\:{(.*)\\}\", \"\"), \"(.*)language..:(.*)region..:\\\\.([^\\\\]*)(.*)\", \"\\3\"));\n } else {\n if (req.http.Cookie ~ \"lang=\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.Cookie, \"(.*)lang=([^;]*)(.*)\", \"\\2\"));\n } else {\n set req.http.X-Language = \"en\";\n }\n\n if (req.http.Cookie ~ \"prov=\") {\n set req.http.X-Province = std.tolower(regsuball(req.http.Cookie, \"(.*)prov=([^;]*)(.*)\", \"\\2\"));\n } else {\n set req.http.X-Province = \"BC\";\n }\n }\n\n if (req.url ~ \"\/(en|fr)\/\") {\n if (req.url ~ \"\/en\/\" && req.http.X-Language != \"en\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Language)\";\n return(pass);\n }\n if (req.url ~ \"\/fr\/\" && req.http.X-Language != \"fr\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Language)\";\n return(pass);\n }\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Language)\";\n return(pass);\n }\n\n if (req.url ~ \"\/(ab|bc|mb|nb|nl|ns|nt|nu|on|pe|qc|sk|yt)\/\") {\n {% for province in ['ab', 'bc', 'mb', 'nb', 'nl', 'ns', 'nt', 'nu', 'on', 'pe', 'qc', 'sk', 'yt'] %}\n if (req.url ~ \"\/{{ province }}\/\" && req.http.X-Province != \"{{ province }}\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Province)\";\n return(pass);\n }\n {% endfor %}\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Province)\";\n return(pass);\n }\n{% endif %}\n\n{% if varnish_blacklist_enabled %}\n if ((req.url ~ \"{{ varnish_blacklist_regexp }}\")) {\n set req.http.X-Passthrough-Reason = \"Path in Blacklist\";\n return(pass);\n } else {\n{% if varnish_discards_client_cookies %}\n unset req.http.Cookie;\n{% endif %}\n }\n{% endif %}\n\n}\n\n###\n# vcl_hit\n# Called when a cache lookup is successful.\n###\n# The vcl_hit subroutine may terminate with calling return() with one of the following keywords:\n#\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n# deliver\n# Deliver the object. Control passes to vcl_deliver.\n# synth(status code, reason)\n# Return the specified status code to the client and abandon the request.\n###\n\nsub vcl_hit {\n if (obj.ttl > 0s) {\n return (deliver);\n }\n{% if varnish_health_checks_enabled %}\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (fetch);\n }\n{% else %}\n if (obj.ttl + obj.grace > 0s) {\n return (deliver);\n }\n\n return (fetch);\n{% endif %}\n}\n\n###\n# vcl_backend_response\n# Called after the response headers has been successfully retrieved from the backend.\n###\n# The vcl_backend_response subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Possibly insert the object into the cache, then deliver it to the Control will eventually pass to vcl_deliver.\n# abandon\n# Abandon the backend request and generates an error.\n# retry\n# Retry the backend transaction. Increases the retries counter. If the number of retries is higher than max_retries Varnish emits a guru meditation error.\n###\n\nsub vcl_backend_response {\n{% if varnish_workaround_telusdotcom_browser_profile %}\n if (bereq.http.X-Language) {\n set beresp.http.X-Language = bereq.http.X-Language;\n }\n if (bereq.http.X-Province) {\n set beresp.http.X-Province = bereq.http.X-Province;\n }\n{% endif %}\n\n{% if varnish_blacklist_enabled %}\n if (bereq.url ~ \"{{ varnish_blacklist_regexp }}\") {\n set beresp.http.X-Cacheable = \"NO:Path in Blacklist\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n if (bereq.http.X-Passthrough-Reason) {\n set beresp.http.X-Passthrough-Reason = bereq.http.X-Passthrough-Reason;\n return(deliver);\n } else {\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n }\n }\n{% else %}\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n{% endif %}\n\n{% if varnish_cache_diagnostics_enabled %}\n if (bereq.http.Cookie) {\n set beresp.http.X-Cacheable = \"NO:Cookie in Request\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO:Set-Cookie in Response\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.X-No-Cache) {\n set beresp.http.X-Cacheable = \"NO:X-No-Cache\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.ttl <= 0s) {\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n{% endif %}\n\n set beresp.grace = {{ varnish_grace_period }};\n}\n\n###\n# vcl_deliver\n# Called before a cached object is delivered to the client.\n###\n# The vcl_deliver subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Deliver the object to the client.\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n###\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"eb722a39a9d90aff01619b49c7eec5cd9740f882","subject":"Revert \"remove default backend, now that we're using dns director.\"","message":"Revert \"remove default backend, now that we're using dns director.\"\n\nThis reverts commit 04582cfe4f92aef64f7d25932d4c2926b7877417.\n","repos":"amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon","old_file":"images\/varnish-drupal\/drupal.vcl","new_file":"images\/varnish-drupal\/drupal.vcl","new_contents":"vcl 4.0;\n\nimport std;\nimport dynamic;\n\n# set backend default\nbackend default {\n .host = \"${VARNISH_BACKEND_HOST:-nginx}\";\n .port = \"${VARNISH_BACKEND_PORT:-8080}\";\n .first_byte_timeout = 35m;\n .between_bytes_timeout = 10m;\n}\n\n# Allow purging from localhost\n# @TODO allow from openshift network\nacl purge {\n \"127.0.0.1\";\n \"10.0.0.0\"\/8;\n \"172.16.0.0\"\/12;\n \"192.168.0.0\"\/16;\n}\n\nsub vcl_init {\n new www_dir = dynamic.director(\n port = \"${VARNISH_BACKEND_PORT:-8080}\",\n first_byte_timeout = 90s,\n between_bytes_timeout = 90s,\n ttl = 60s);\n }\n\n# This configuration is optimized for Drupal hosting:\n# Respond to incoming requests.\nsub vcl_recv {\n\n if (req.url ~ \"^\/varnish_status$\") {\n return (synth(200,\"OK\"));\n }\n # set the backend, which should be used:\n set req.backend_hint = www_dir.backend(\"${VARNISH_BACKEND_HOST:-nginx}\");\n\n # Always set the forward ip.\n if (req.restarts == 0) {\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n\n\n if (req.http.X-LAGOON-VARNISH ) {\n ## Pass all Requests which are handled via an upstream Varnish\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, \" + req.http.X-LAGOON-VARNISH;\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n } else if (req.http.Fastly-FF) {\n ## Pass all Requests which are handled via Fastly\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, fastly\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n set req.http.X-Forwarded-For = req.http.Fastly-Client-IP;\n } else if (req.http.CF-RAY) {\n ## Pass all Requests which are handled via CloudFlare\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, cloudflare\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n set req.http.X-Forwarded-For = req.http.CF-Connecting-IP;\n } else if (req.http.X-Pull) {\n ## Pass all Requests which are handled via KeyCDN\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, keycdn\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n } else {\n ## We set a header to let a Varnish Chain know that it already has been varnishcached\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}\";\n\n ## Allow to bypass based on env variable `VARNISH_BYPASS`\n set req.http.X-LAGOON-VARNISH-BYPASS = \"${VARNISH_BYPASS:-false}\";\n }\n\n # Websockets are piped\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n if (req.http.X-LAGOON-VARNISH-BYPASS == \"true\" || req.http.X-LAGOON-VARNISH-BYPASS == \"TRUE\") {\n return (pass);\n }\n\n # SA-CORE-2014-004 preventing access to \/xmlrpc.php\n if (req.url ~ \"^\/xmlrpc.php$\") {\n return (synth(701, \"Unauthorized\"));\n }\n\n # Strip out Google Analytics campaign variables. They are only needed\n # by the javascript running on the page\n # utm_source, utm_medium, utm_campaign, gclid\n if(req.url ~ \"(\\?|&)(gclid|utm_[a-z]+)=\") {\n set req.url = regsuball(req.url, \"(gclid|utm_[a-z]+)=[^\\&]+&?\", \"\");\n set req.url = regsub(req.url, \"(\\?|&)$\", \"\");\n }\n\n # Bypass a cache hit (the request is still sent to the backend)\n if (req.method == \"REFRESH\") {\n if (!client.ip ~ purge) { return (synth(405, \"Not allowed\")); }\n set req.method = \"GET\";\n set req.hash_always_miss = true;\n }\n\n # Only allow BAN requests from IP addresses in the 'purge' ACL.\n if (req.method == \"BAN\" || req.method == \"URIBAN\" || req.method == \"PURGE\") {\n # Only allow BAN from defined ACL\n if (!client.ip ~ purge) {\n return (synth(403, \"Your IP is not allowed.\"));\n }\n\n # Only allows BAN if the Host Header has the style of with \"${SERVICE_NAME:-varnish}:8080\" or \"${SERVICE_NAME:-varnish}\".\n # Such a request is only possible from within the Docker network, as a request from external goes trough the Kubernetes Router and for that needs a proper Host Header\n if (!req.http.host ~ \"^${SERVICE_NAME:-varnish}(:\\d+)?$\") {\n return (synth(403, \"Only allowed from within own network.\"));\n }\n\n if (req.method == \"BAN\") {\n # Logic for the ban, using the Cache-Tags header.\n if (req.http.Cache-Tags) {\n ban(\"obj.http.Cache-Tags ~ \" + req.http.Cache-Tags);\n # Throw a synthetic page so the request won't go to the backend.\n return (synth(200, \"Ban added.\"));\n }\n else {\n return (synth(403, \"Cache-Tags header missing.\"));\n }\n }\n\n if (req.method == \"URIBAN\" || req.method == \"PURGE\") {\n ban(\"req.url ~ \" + req.url);\n # Throw a synthetic page so the request won't go to the backend.\n return (synth(200, \"Ban added.\"));\n }\n\n }\n\n # Non-RFC2616 or CONNECT which is weird, we pipe that\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n return (pipe);\n }\n\n # We only try to cache GET and HEAD, other things are passed\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n # Any requests with Basic Auth are passed\n if (req.http.Authorization || req.http.Authenticate)\n {\n return (pass);\n }\n\n ## Pass requests which are from blackfire\n if (req.http.X-Blackfire-Query) {\n return (pass);\n }\n\n # Some URLs should never be cached\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/admin([\/?]|$).*$\" ||\n req.url ~ \"^\/info([\/?]|$).*$\" ||\n req.url ~ \"^\/flag([\/?]|$).*$\" ||\n req.url ~ \"^.*\/system\/files([\/?]|$).*$\" ||\n req.url ~ \"^\/cgi\" ||\n req.url ~ \"^\/cgi-bin\"\n ) {\n return (pass);\n }\n\n # Plupload likes to get piped\n if (req.url ~ \"^.*\/plupload-handle-uploads.*$\"\n ) {\n return (pipe);\n }\n\n # Handle compression correctly. Different browsers send different\n # \"Accept-Encoding\" headers, even though they mostly all support the same\n # compression mechanisms. By consolidating these compression headers into\n # a consistent format, we can reduce the size of the cache and get more hits.=\n # @see: http:\/\/ varnish.projects.linpro.no\/wiki\/FAQ\/Compression\n if (req.http.Accept-Encoding) {\n if (req.http.Accept-Encoding ~ \"gzip\") {\n # If the browser supports it, we'll use gzip.\n set req.http.Accept-Encoding = \"gzip\";\n }\n else if (req.http.Accept-Encoding ~ \"deflate\") {\n # Next, try deflate if it is supported.\n set req.http.Accept-Encoding = \"deflate\";\n }\n else {\n # Unknown algorithm. Remove it and send unencoded.\n unset req.http.Accept-Encoding;\n }\n }\n\n # Always cache the following file types for all users.\n if (req.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n unset req.http.Cookie;\n }\n\n # Remove all cookies that Drupal doesn't need to know about. ANY remaining\n # cookie will cause the request to pass-through to a backend. For the most part\n # we always set the NO_CACHE cookie after any POST request, disabling the\n # Varnish cache temporarily. The session cookie allows all authenticated users\n # to pass through as long as they're logged in.\n #\n # 1. Append a semi-colon to the front of the cookie string.\n # 2. Remove all spaces that appear after semi-colons.\n # 3. Match the cookies we want to keep, adding the space we removed\n # previously, back. (\\1) is first matching group in the regsuball.\n # 4. Remove all other cookies, identifying them by the fact that they have\n # no space after the preceding semi-colon.\n # 5. Remove all spaces and semi-colons from the beginning and end of the\n # cookie string.\n if (req.http.Cookie) {\n set req.http.CookieCheck = \";\" + req.http.Cookie;\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"; +\", \";\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";(${VARNISH_COOKIECHECK:-SESS[a-z0-9]+|SSESS[a-z0-9]+|NO_CACHE})=\", \"; \\1=\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";[^ ][^;]*\", \"\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"^[; ]+|[; ]+$\", \"\");\n\n set req.http.Cookie = req.http.Cookie + \";\";\n\n if (req.http.CookieCheck == \"\") {\n # If there are no remaining cookies, remove the cookie header. If there\n # aren't any cookie headers, Varnish's default behavior will be to cache\n # the page.\n\n unset req.http.CookieCheck;\n unset req.http.Cookie;\n }\n else {\n # If there is any cookies left (a session or NO_CACHE cookie), do not\n # cache the page. Pass it on to Apache directly.\n unset req.http.CookieCheck;\n return (pass);\n }\n }\n\n # Cacheable, lookup in cache.\n return (hash);\n}\n\nsub vcl_pipe {\n # Support for Websockets\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n set bereq.http.connection = req.http.connection;\n }\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n # normal hit\n return (deliver);\n }\n # We have no fresh fish. Lets look at the stale ones.\n if (std.healthy(req.backend_hint)) {\n # Backend is healthy. If the object is not older then 30secs, deliver it to the client\n # and automatically create a separate backend request to warm the cache for this request.\n if (obj.ttl + 30s > 0s) {\n set req.http.grace = \"normal(limited)\";\n return (deliver);\n } else {\n # No candidate for grace. Fetch a fresh object.\n return(miss);\n }\n } else {\n # backend is sick - use full grace\n if (obj.ttl + obj.grace > 0s) {\n set req.http.grace = \"full\";\n return (deliver);\n } else {\n # no graced object.\n return (miss);\n }\n }\n}\n\nsub vcl_backend_response {\n # Allow items to be stale if needed.\n set beresp.grace = 6h;\n\n # Set ban-lurker friendly custom headers.\n set beresp.http.X-Url = bereq.url;\n set beresp.http.X-Host = bereq.http.host;\n\n # If the backend sends a X-LAGOON-VARNISH-BACKEND-BYPASS header we directly deliver\n if(beresp.http.X-LAGOON-VARNISH-BACKEND-BYPASS == \"TRUE\") {\n return (deliver);\n }\n\n # Cache 404 and 403 for 10 seconds\n if(beresp.status == 404 || beresp.status == 403) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n # Don't allow static files to set cookies.\n if (bereq.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n # beresp == Back-end response from the web server.\n unset beresp.http.set-cookie;\n unset beresp.http.Cache-Control;\n\n # If an asset would come back with statuscode 500 we only cache it for 10 seconds instead of the usual static file cache\n if (beresp.status == 500) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n set beresp.ttl = ${VARNISH_ASSETS_TTL:-2628001}s;\n set beresp.http.Cache-Control = \"public, max-age=${VARNISH_ASSETS_TTL:-2628001}\";\n set beresp.http.Expires = \"\" + (now + beresp.ttl);\n }\n\n return (deliver);\n}\n\n# Set a header to track a cache HIT\/MISS.\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Varnish-Cache = \"HIT\";\n }\n else {\n set resp.http.X-Varnish-Cache = \"MISS\";\n }\n\n # Remove ban-lurker friendly custom headers when delivering to client.\n unset resp.http.X-Url;\n unset resp.http.X-Host;\n\n # unset Cache-Tags Header by default, can be disabled with VARNISH_UNSET_HEADER_CACHE_TAGS=true\n if (!${VARNISH_UNSET_HEADER_CACHE_TAGS:-false}) {\n unset resp.http.Cache-Tags;\n }\n\n unset resp.http.X-Generator;\n unset resp.http.Server;\n # Inject information about grace\n if (req.http.grace) {\n set resp.http.X-Varnish-Grace = req.http.grace;\n }\n set resp.http.X-LAGOON = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}>\" + resp.http.X-LAGOON;\n return (deliver);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n if (req.http.X-Forwarded-Proto) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n if (req.http.HTTPS) {\n hash_data(req.http.HTTPS);\n }\n return (lookup);\n}\n\nsub vcl_synth {\n if (resp.status == 701) {\n set resp.status = 401;\n set resp.http.Content-Type = \"text\/plain; charset=utf-8\";\n synthetic({\"XMLRPC Interface is blocked due to SA-CORE-2014-004 - mail support@amazee.io if you need it.\"});\n return (deliver);\n }\n if (resp.status == 700) {\n # Set a status the client will understand\n set resp.status = 200;\n # Create our synthetic response\n synthetic(\"\");\n return(deliver);\n}\n return (deliver);\n}\n\nsub vcl_backend_error {\n # Restart the request, when we have a backend server error, to try another backend.\n # Restart max twice.\n if (bereq.retries < 2) {\n return(retry);\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<head>\n <title>Server Error<\/title>\n <style type=\"text\/css\">\n body {\n font-family: helvetica, arial, sans-serif;\n }\n img {\n margin-top: 50px;\n }\n p {\n width: 6 00px;\n margin-top: 10px\n }\n div {\n background: #ccc;\n width: 600px;\n margin: auto;\n padding: 50px;\n }\n span {\n color: #ccc\n }\n <\/style>\n<\/head>\n<body>\n <div>\n <h1>We are sorry...<\/h1>\n <p>We encountered a server-side error. This means that the problem is not with your computer or Internet connection, but rather with the website's server.<\/p>\n <p>We are currently working on solving this problem and apologise for the inconvenience.<\/p>\n <span>\n <strong>Technical Information<\/strong><br \/>\n Error \"} + beresp.status + \" \" + beresp.reason + {\"<br \/>\n XID: \"} + bereq.xid + {\"<br \/>\n <\/span>\n <\/div>\n<\/body>\n<\/html>\n\n\"} );\n return (deliver);\n}\n","old_contents":"vcl 4.0;\n\nimport std;\nimport dynamic;\n\n# Allow purging from localhost\n# @TODO allow from openshift network\nacl purge {\n \"127.0.0.1\";\n \"10.0.0.0\"\/8;\n \"172.16.0.0\"\/12;\n \"192.168.0.0\"\/16;\n}\n\nsub vcl_init {\n new www_dir = dynamic.director(\n port = \"${VARNISH_BACKEND_PORT:-8080}\",\n first_byte_timeout = 90s,\n between_bytes_timeout = 90s,\n ttl = 60s);\n }\n\n# This configuration is optimized for Drupal hosting:\n# Respond to incoming requests.\nsub vcl_recv {\n\n if (req.url ~ \"^\/varnish_status$\") {\n return (synth(200,\"OK\"));\n }\n # set the backend, which should be used:\n set req.backend_hint = www_dir.backend(\"${VARNISH_BACKEND_HOST:-nginx}\");\n\n # Always set the forward ip.\n if (req.restarts == 0) {\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n\n\n if (req.http.X-LAGOON-VARNISH ) {\n ## Pass all Requests which are handled via an upstream Varnish\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, \" + req.http.X-LAGOON-VARNISH;\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n } else if (req.http.Fastly-FF) {\n ## Pass all Requests which are handled via Fastly\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, fastly\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n set req.http.X-Forwarded-For = req.http.Fastly-Client-IP;\n } else if (req.http.CF-RAY) {\n ## Pass all Requests which are handled via CloudFlare\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, cloudflare\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n set req.http.X-Forwarded-For = req.http.CF-Connecting-IP;\n } else if (req.http.X-Pull) {\n ## Pass all Requests which are handled via KeyCDN\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, keycdn\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n } else {\n ## We set a header to let a Varnish Chain know that it already has been varnishcached\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}\";\n\n ## Allow to bypass based on env variable `VARNISH_BYPASS`\n set req.http.X-LAGOON-VARNISH-BYPASS = \"${VARNISH_BYPASS:-false}\";\n }\n\n # Websockets are piped\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n if (req.http.X-LAGOON-VARNISH-BYPASS == \"true\" || req.http.X-LAGOON-VARNISH-BYPASS == \"TRUE\") {\n return (pass);\n }\n\n # SA-CORE-2014-004 preventing access to \/xmlrpc.php\n if (req.url ~ \"^\/xmlrpc.php$\") {\n return (synth(701, \"Unauthorized\"));\n }\n\n # Strip out Google Analytics campaign variables. They are only needed\n # by the javascript running on the page\n # utm_source, utm_medium, utm_campaign, gclid\n if(req.url ~ \"(\\?|&)(gclid|utm_[a-z]+)=\") {\n set req.url = regsuball(req.url, \"(gclid|utm_[a-z]+)=[^\\&]+&?\", \"\");\n set req.url = regsub(req.url, \"(\\?|&)$\", \"\");\n }\n\n # Bypass a cache hit (the request is still sent to the backend)\n if (req.method == \"REFRESH\") {\n if (!client.ip ~ purge) { return (synth(405, \"Not allowed\")); }\n set req.method = \"GET\";\n set req.hash_always_miss = true;\n }\n\n # Only allow BAN requests from IP addresses in the 'purge' ACL.\n if (req.method == \"BAN\" || req.method == \"URIBAN\" || req.method == \"PURGE\") {\n # Only allow BAN from defined ACL\n if (!client.ip ~ purge) {\n return (synth(403, \"Your IP is not allowed.\"));\n }\n\n # Only allows BAN if the Host Header has the style of with \"${SERVICE_NAME:-varnish}:8080\" or \"${SERVICE_NAME:-varnish}\".\n # Such a request is only possible from within the Docker network, as a request from external goes trough the Kubernetes Router and for that needs a proper Host Header\n if (!req.http.host ~ \"^${SERVICE_NAME:-varnish}(:\\d+)?$\") {\n return (synth(403, \"Only allowed from within own network.\"));\n }\n\n if (req.method == \"BAN\") {\n # Logic for the ban, using the Cache-Tags header.\n if (req.http.Cache-Tags) {\n ban(\"obj.http.Cache-Tags ~ \" + req.http.Cache-Tags);\n # Throw a synthetic page so the request won't go to the backend.\n return (synth(200, \"Ban added.\"));\n }\n else {\n return (synth(403, \"Cache-Tags header missing.\"));\n }\n }\n\n if (req.method == \"URIBAN\" || req.method == \"PURGE\") {\n ban(\"req.url ~ \" + req.url);\n # Throw a synthetic page so the request won't go to the backend.\n return (synth(200, \"Ban added.\"));\n }\n\n }\n\n # Non-RFC2616 or CONNECT which is weird, we pipe that\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n return (pipe);\n }\n\n # We only try to cache GET and HEAD, other things are passed\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n # Any requests with Basic Auth are passed\n if (req.http.Authorization || req.http.Authenticate)\n {\n return (pass);\n }\n\n ## Pass requests which are from blackfire\n if (req.http.X-Blackfire-Query) {\n return (pass);\n }\n\n # Some URLs should never be cached\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/admin([\/?]|$).*$\" ||\n req.url ~ \"^\/info([\/?]|$).*$\" ||\n req.url ~ \"^\/flag([\/?]|$).*$\" ||\n req.url ~ \"^.*\/system\/files([\/?]|$).*$\" ||\n req.url ~ \"^\/cgi\" ||\n req.url ~ \"^\/cgi-bin\"\n ) {\n return (pass);\n }\n\n # Plupload likes to get piped\n if (req.url ~ \"^.*\/plupload-handle-uploads.*$\"\n ) {\n return (pipe);\n }\n\n # Handle compression correctly. Different browsers send different\n # \"Accept-Encoding\" headers, even though they mostly all support the same\n # compression mechanisms. By consolidating these compression headers into\n # a consistent format, we can reduce the size of the cache and get more hits.=\n # @see: http:\/\/ varnish.projects.linpro.no\/wiki\/FAQ\/Compression\n if (req.http.Accept-Encoding) {\n if (req.http.Accept-Encoding ~ \"gzip\") {\n # If the browser supports it, we'll use gzip.\n set req.http.Accept-Encoding = \"gzip\";\n }\n else if (req.http.Accept-Encoding ~ \"deflate\") {\n # Next, try deflate if it is supported.\n set req.http.Accept-Encoding = \"deflate\";\n }\n else {\n # Unknown algorithm. Remove it and send unencoded.\n unset req.http.Accept-Encoding;\n }\n }\n\n # Always cache the following file types for all users.\n if (req.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n unset req.http.Cookie;\n }\n\n # Remove all cookies that Drupal doesn't need to know about. ANY remaining\n # cookie will cause the request to pass-through to a backend. For the most part\n # we always set the NO_CACHE cookie after any POST request, disabling the\n # Varnish cache temporarily. The session cookie allows all authenticated users\n # to pass through as long as they're logged in.\n #\n # 1. Append a semi-colon to the front of the cookie string.\n # 2. Remove all spaces that appear after semi-colons.\n # 3. Match the cookies we want to keep, adding the space we removed\n # previously, back. (\\1) is first matching group in the regsuball.\n # 4. Remove all other cookies, identifying them by the fact that they have\n # no space after the preceding semi-colon.\n # 5. Remove all spaces and semi-colons from the beginning and end of the\n # cookie string.\n if (req.http.Cookie) {\n set req.http.CookieCheck = \";\" + req.http.Cookie;\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"; +\", \";\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";(${VARNISH_COOKIECHECK:-SESS[a-z0-9]+|SSESS[a-z0-9]+|NO_CACHE})=\", \"; \\1=\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";[^ ][^;]*\", \"\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"^[; ]+|[; ]+$\", \"\");\n\n set req.http.Cookie = req.http.Cookie + \";\";\n\n if (req.http.CookieCheck == \"\") {\n # If there are no remaining cookies, remove the cookie header. If there\n # aren't any cookie headers, Varnish's default behavior will be to cache\n # the page.\n\n unset req.http.CookieCheck;\n unset req.http.Cookie;\n }\n else {\n # If there is any cookies left (a session or NO_CACHE cookie), do not\n # cache the page. Pass it on to Apache directly.\n unset req.http.CookieCheck;\n return (pass);\n }\n }\n\n # Cacheable, lookup in cache.\n return (hash);\n}\n\nsub vcl_pipe {\n # Support for Websockets\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n set bereq.http.connection = req.http.connection;\n }\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n # normal hit\n return (deliver);\n }\n # We have no fresh fish. Lets look at the stale ones.\n if (std.healthy(req.backend_hint)) {\n # Backend is healthy. If the object is not older then 30secs, deliver it to the client\n # and automatically create a separate backend request to warm the cache for this request.\n if (obj.ttl + 30s > 0s) {\n set req.http.grace = \"normal(limited)\";\n return (deliver);\n } else {\n # No candidate for grace. Fetch a fresh object.\n return(miss);\n }\n } else {\n # backend is sick - use full grace\n if (obj.ttl + obj.grace > 0s) {\n set req.http.grace = \"full\";\n return (deliver);\n } else {\n # no graced object.\n return (miss);\n }\n }\n}\n\nsub vcl_backend_response {\n # Allow items to be stale if needed.\n set beresp.grace = 6h;\n\n # Set ban-lurker friendly custom headers.\n set beresp.http.X-Url = bereq.url;\n set beresp.http.X-Host = bereq.http.host;\n\n # If the backend sends a X-LAGOON-VARNISH-BACKEND-BYPASS header we directly deliver\n if(beresp.http.X-LAGOON-VARNISH-BACKEND-BYPASS == \"TRUE\") {\n return (deliver);\n }\n\n # Cache 404 and 403 for 10 seconds\n if(beresp.status == 404 || beresp.status == 403) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n # Don't allow static files to set cookies.\n if (bereq.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n # beresp == Back-end response from the web server.\n unset beresp.http.set-cookie;\n unset beresp.http.Cache-Control;\n\n # If an asset would come back with statuscode 500 we only cache it for 10 seconds instead of the usual static file cache\n if (beresp.status == 500) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n set beresp.ttl = ${VARNISH_ASSETS_TTL:-2628001}s;\n set beresp.http.Cache-Control = \"public, max-age=${VARNISH_ASSETS_TTL:-2628001}\";\n set beresp.http.Expires = \"\" + (now + beresp.ttl);\n }\n\n return (deliver);\n}\n\n# Set a header to track a cache HIT\/MISS.\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Varnish-Cache = \"HIT\";\n }\n else {\n set resp.http.X-Varnish-Cache = \"MISS\";\n }\n\n # Remove ban-lurker friendly custom headers when delivering to client.\n unset resp.http.X-Url;\n unset resp.http.X-Host;\n\n # unset Cache-Tags Header by default, can be disabled with VARNISH_UNSET_HEADER_CACHE_TAGS=true\n if (!${VARNISH_UNSET_HEADER_CACHE_TAGS:-false}) {\n unset resp.http.Cache-Tags;\n }\n\n unset resp.http.X-Generator;\n unset resp.http.Server;\n # Inject information about grace\n if (req.http.grace) {\n set resp.http.X-Varnish-Grace = req.http.grace;\n }\n set resp.http.X-LAGOON = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}>\" + resp.http.X-LAGOON;\n return (deliver);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n if (req.http.X-Forwarded-Proto) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n if (req.http.HTTPS) {\n hash_data(req.http.HTTPS);\n }\n return (lookup);\n}\n\nsub vcl_synth {\n if (resp.status == 701) {\n set resp.status = 401;\n set resp.http.Content-Type = \"text\/plain; charset=utf-8\";\n synthetic({\"XMLRPC Interface is blocked due to SA-CORE-2014-004 - mail support@amazee.io if you need it.\"});\n return (deliver);\n }\n if (resp.status == 700) {\n # Set a status the client will understand\n set resp.status = 200;\n # Create our synthetic response\n synthetic(\"\");\n return(deliver);\n}\n return (deliver);\n}\n\nsub vcl_backend_error {\n # Restart the request, when we have a backend server error, to try another backend.\n # Restart max twice.\n if (bereq.retries < 2) {\n return(retry);\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<head>\n <title>Server Error<\/title>\n <style type=\"text\/css\">\n body {\n font-family: helvetica, arial, sans-serif;\n }\n img {\n margin-top: 50px;\n }\n p {\n width: 6 00px;\n margin-top: 10px\n }\n div {\n background: #ccc;\n width: 600px;\n margin: auto;\n padding: 50px;\n }\n span {\n color: #ccc\n }\n <\/style>\n<\/head>\n<body>\n <div>\n <h1>We are sorry...<\/h1>\n <p>We encountered a server-side error. This means that the problem is not with your computer or Internet connection, but rather with the website's server.<\/p>\n <p>We are currently working on solving this problem and apologise for the inconvenience.<\/p>\n <span>\n <strong>Technical Information<\/strong><br \/>\n Error \"} + beresp.status + \" \" + beresp.reason + {\"<br \/>\n XID: \"} + bereq.xid + {\"<br \/>\n <\/span>\n <\/div>\n<\/body>\n<\/html>\n\n\"} );\n return (deliver);\n}\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"be86ae4cade35ffd2ff3564345c5a6ef8de56e25","subject":"Reindent","message":"Reindent\n\n\ngit-svn-id: 2c9807fa3ff65b17195bd55dc8a6c4261e10127b@3009 d4fa192b-c00b-0410-8231-f00ffab90ce4\n","repos":"gauthier-delacroix\/Varnish-Cache,franciscovg\/Varnish-Cache,feld\/Varnish-Cache,gquintard\/Varnish-Cache,feld\/Varnish-Cache,varnish\/Varnish-Cache,ambernetas\/varnish-cache,ssm\/pkg-varnish,gquintard\/Varnish-Cache,zhoualbeart\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,ambernetas\/varnish-cache,mrhmouse\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,alarky\/varnish-cache-doc-ja,alarky\/varnish-cache-doc-ja,ajasty-cavium\/Varnish-Cache,franciscovg\/Varnish-Cache,drwilco\/varnish-cache-drwilco,1HLtd\/Varnish-Cache,wikimedia\/operations-debs-varnish,gauthier-delacroix\/Varnish-Cache,franciscovg\/Varnish-Cache,wikimedia\/operations-debs-varnish,gquintard\/Varnish-Cache,franciscovg\/Varnish-Cache,wikimedia\/operations-debs-varnish,ssm\/pkg-varnish,varnish\/Varnish-Cache,wikimedia\/operations-debs-varnish,varnish\/Varnish-Cache,ssm\/pkg-varnish,ambernetas\/varnish-cache,gauthier-delacroix\/Varnish-Cache,wikimedia\/operations-debs-varnish,ajasty-cavium\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,zhoualbeart\/Varnish-Cache,chrismoulton\/Varnish-Cache,mrhmouse\/Varnish-Cache,1HLtd\/Varnish-Cache,mrhmouse\/Varnish-Cache,chrismoulton\/Varnish-Cache,drwilco\/varnish-cache-old,feld\/Varnish-Cache,alarky\/varnish-cache-doc-ja,drwilco\/varnish-cache-old,drwilco\/varnish-cache-drwilco,ssm\/pkg-varnish,mrhmouse\/Varnish-Cache,zhoualbeart\/Varnish-Cache,chrismoulton\/Varnish-Cache,1HLtd\/Varnish-Cache,drwilco\/varnish-cache-drwilco,feld\/Varnish-Cache,ssm\/pkg-varnish,varnish\/Varnish-Cache,feld\/Varnish-Cache,chrismoulton\/Varnish-Cache,1HLtd\/Varnish-Cache,franciscovg\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,drwilco\/varnish-cache-old,alarky\/varnish-cache-doc-ja,alarky\/varnish-cache-doc-ja,chrismoulton\/Varnish-Cache,mrhmouse\/Varnish-Cache,zhoualbeart\/Varnish-Cache,zhoualbeart\/Varnish-Cache,varnish\/Varnish-Cache,gquintard\/Varnish-Cache","old_file":"etc\/default.vcl","new_file":"etc\/default.vcl","new_contents":"#\n# This is a basic VCL configuration file for varnish. See the vcl(7)\n# man page for details on VCL syntax and semantics.\n#\n# $Id$\n#\n\n# Default backend definition. Set this to point to your content\n# server.\n\nbackend default {\n\t.host = \"127.0.0.1\";\n\t.port = \"8080\";\n}\n\n# Below is a commented-out copy of the default VCL logic. If you\n# redefine any of these subroutines, the built-in logic will be\n# appended to your code.\n\n## Called when a client request is received\n#\n#sub vcl_recv {\n#\tif (req.request != \"GET\" &&\n#\t req.request != \"HEAD\" &&\n#\t req.request != \"PUT\" &&\n#\t req.request != \"POST\" &&\n#\t req.request != \"TRACE\" &&\n#\t req.request != \"OPTIONS\" &&\n#\t req.request != \"DELETE\") {\n#\t\tpipe;\n#\t}\n#\tif (req.http.Expect) {\n#\t\tpipe;\n#\t}\n#\tif (req.request != \"GET\" && req.request != \"HEAD\") {\n#\t\tpass;\n#\t}\n#\tif (req.http.Authorization || req.http.Cookie) {\n#\t\tpass;\n#\t}\n#\tlookup;\n#}\n#\n## Called when entering pipe mode\n#\n#sub vcl_pipe {\n#\tpipe;\n#}\n#\n## Called when entering pass mode\n#\n#sub vcl_pass {\n#\tpass;\n#}\n#\n## Called when entering an object into the cache\n#\n#sub vcl_hash {\n#\tset req.hash += req.url;\n#\tif (req.http.host) {\n#\t\tset req.hash += req.http.host;\n#\t} else {\n#\t\tset req.hash += server.ip;\n#\t}\n#\thash;\n#}\n#\n## Called when the requested object was found in the cache\n#\n#sub vcl_hit {\n#\tif (!obj.cacheable) {\n#\t\tpass;\n#\t}\n#\tdeliver;\n#}\n#\n## Called when the requested object was not found in the cache\n#\n#sub vcl_miss {\n#\tfetch;\n#}\n#\n## Called when the requested object has been retrieved from the\n## backend, or the request to the backend has failed\n#\n#sub vcl_fetch {\n#\tif (!obj.valid) {\n#\t\terror obj.status;\n#\t}\n#\tif (!obj.cacheable) {\n#\t\tpass;\n#\t}\n#\tif (obj.http.Set-Cookie) {\n#\t\tpass;\n#\t}\n#\t set obj.prefetch = -30s;\tinsert;\n#}\n#\n## Called before a cached object is delivered to the client\n#\n#sub vcl_deliver {\n#\tdeliver;\n#}\n#\n## Called when an object nears its expiry time\n#\n#sub vcl_timeout {\n#\tdiscard;\n#}\n#\n# Called when an object is about to be discarded\n#\n#sub vcl_discard {\n#\tdiscard;\n#}\n","old_contents":"#\n# This is a basic VCL configuration file for varnish. See the vcl(7)\n# man page for details on VCL syntax and semantics.\n#\n# $Id$\n#\n\n# Default backend definition. Set this to point to your content\n# server.\n\nbackend default {\n\t.host = \"127.0.0.1\";\n\t.port = \"8080\";\n}\n\n# Below is a commented-out copy of the default VCL logic. If you\n# redefine any of these subroutines, the built-in logic will be\n# appended to your code.\n\n## Called when a client request is received\n#\n#sub vcl_recv {\n# if (req.request != \"GET\" &&\n# req.request != \"HEAD\" &&\n# req.request != \"PUT\" &&\n# req.request != \"POST\" &&\n# req.request != \"TRACE\" &&\n# req.request != \"OPTIONS\" &&\n# req.request != \"DELETE\") {\n# pipe;\n# }\n# if (req.http.Expect) {\n# pipe;\n# }\n# if (req.request != \"GET\" && req.request != \"HEAD\") {\n# pass;\n# }\n# if (req.http.Authorization || req.http.Cookie) {\n# pass;\n# }\n# lookup;\n#}\n#\n## Called when entering pipe mode\n#\n#sub vcl_pipe {\n#\tpipe;\n#}\n#\n## Called when entering pass mode\n#\n#sub vcl_pass {\n#\tpass;\n#}\n#\n## Called when entering an object into the cache\n#\n#sub vcl_hash {\n# set req.hash += req.url;\n# if (req.http.host) {\n# set req.hash += req.http.host;\n# } else {\n# set req.hash += server.ip;\n# }\n# hash;\n#}\n#\n## Called when the requested object was found in the cache\n#\n#sub vcl_hit {\n#\tif (!obj.cacheable) {\n#\t\tpass;\n#\t}\n#\tdeliver;\n#}\n#\n## Called when the requested object was not found in the cache\n#\n#sub vcl_miss {\n#\tfetch;\n#}\n#\n## Called when the requested object has been retrieved from the\n## backend, or the request to the backend has failed\n#\n#sub vcl_fetch {\n# if (!obj.valid) {\n# error obj.status;\n# }\n# if (!obj.cacheable) {\n# pass;\n# }\n# if (obj.http.Set-Cookie) {\n# pass;\n# }\n#\t set obj.prefetch = -30s; insert;\n#}\n#\n## Called before a cached object is delivered to the client\n#\n#sub vcl_deliver {\n# deliver;\n#}\n#\n## Called when an object nears its expiry time\n#\n#sub vcl_timeout {\n#\tdiscard;\n#}\n#\n# Called when an object is about to be discarded\n#\n#sub vcl_discard {\n# discard;\n#}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"6620354190d2e3eb409355f0f96b21dc6ce0e504","subject":"Added commands for making development easier","message":"Added commands for making development easier\n","repos":"aschneiderman\/atom-voice-vocola","old_file":"atom.vcl","new_file":"atom.vcl","new_contents":"# Voice commands for atom\n\ninclude folders.vch;\ninclude letters.vch;\n\nGo Strawberry = {Ctrl+Alt+F8};\nGo Blueberry ={Ctrl+Alt+o};\nGo Banana = {Ctrl+Alt+F7};\n\n\n# Commands for developing Atom: init.config, packages; also for navigating existing packages\/commands\nReload Atom = {Ctrl+s} Wait(100) {Shift+Ctrl+Alt+F5};\nCommand Palette = {Ctrl+Shift+p};\nKeyboard Shortcuts = {Ctrl+.};\nRun Specs = {Ctrl+Alt+p};\nShow Console = {Ctrl+Alt+i};\n\n# Commands for developing D3: D3 visualizations, D3 Sandwiches\nSave and Reload = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Ctrl+r};\t\nSave and Really Reload = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Ctrl+Shift+r};\n\n# File commands\nFind (File | Document) = {Ctrl+t};\nSave As = {Ctrl+Shift+s};\n\n\n# --- Navigation commands ------------------------------------\n<delimiters> := (Quote = '\"' | 'Single Quote' = \"'\" | Comma = ',' | 'Equal Sign' = '=' | Equals = '=' \n\t| Period = '.' | Colon = ':' | 'Semi-Colon' = ';' | Hyphen = '-' | Underscore = '_' | Slash = '\/'\n\t| Paren = \"(\" | \"Close Paren\" = \")\"\n\t| Bracket = '[' | \"Close Bracket\" = ']' | Brace = '{' | 'Close Brace' = '}'\t);\n\nLine 1..200 = {Ctrl+g} $1 {Enter};\n(Left = 'b' | Right = 'f') Word = {Alt+$1};\nTop = {Ctrl+Home};\nBottom = {Ctrl+End};\n(Find = 'Right' | 'Insert After' = 'Right' | 'Insert Before' = 'Left') (Next = 'Enter' | Last = 'Shift+F3') <delimiters> \n\t\t= {Ctrl+f} $3 {$2} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') <delimiters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') 1..20 <delimiters> = {Ctrl+f} $3 {Enter} {Esc} Wait(100) {F3_$2} {Shift+F3} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') Enda <delimiters> = {End} {Ctrl+f} $2 {Enter} {Esc} {Shift+F3} Wait(100) {$1};\n\nFine Alpha <letters> = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Left};\nInsert (Before = 'Left' | After = 'Right') Alpha <letters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nFine Number 0..9 = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Right};\nFind Again = {F3} {Right};\nFind Again 1..20 Times = {F3_$1} {Right};\n\nFind Symbol = {Ctrl+r};\n\n(Set | Add | Clear | Hide | Delete) Bookmark = {Ctrl+Alt+F2};\n(Next = 'F2' | Last = 'Shift+F2') Bookmark = {$1};\n\nNext Window = {Ctrl+Tab};\nLast Window = {Ctrl+Shift+Tab};\n\n\n# --- Editing commands ----------------------------------------\nSelect Line = {Ctrl+l};\nSelect (Next = 'Down' | Last = 'Up') 1..20 Lines = {Home} {Shift+$1_$2};\n(Join = 'j' | Indent = ']' | Dedent = '[') That = {Ctrl+$1};\nMove Line (Up | Down) 1..20 = {Ctrl+$1_$2};\n\n\n\nDelete Word = {Ctrl+Del};\nDelete 1..20 Words = {Ctrl+Del_$1};\nDelete (Back | Last) Word = {Ctrl+Backspace};\nDelete (Back | Last) 1..20 Words = {Ctrl+Backspace_$2};\nDelete Enda Word = {End} {Ctrl+Backspace};\n\n(Delete Line | Dede) = {Ctrl+Shift+k};\nDelete 1..20 Lines = {Ctrl+Shift+k_$1};\n(Cut = 'x' | Paste = 'v' | Copy = 'c') That = {Ctrl+$1};\n\nComment (That | Line) = {Ctrl+\/};\nComment 1..20 Lines = {Home} {Shift+Down_$1} {Ctrl+\/};\n\nSelect between (Delimiters | Brackets) ={Ctrl+m} {Ctrl+Alt+m};\n\nDelete Tags = {Ctrl+Alt+F4};\n\nReplace = {Ctrl+f};\nReplace All = {Ctrl+Enter};\n\n\n\n\n# --- Code commands -------------------------------------------\nStart (Item = 'li' | List = 'ul' | HTML = 'html' | pre = \"pre\"\n\t| 'Bold ID' = 'bold-id' | 'Input' = 'ds-input-text'\n\t| 'Fix Line' = 'fix-current-line' | 'Fix Current Line' = 'fix-current-line'\n\t| Snippet = 'my-snippet' | 'Recipe Row' = 'recipe-row' | 'Recipe Play' = 'recipe-play') = $1 {Tab};\nStart (para = '<p>' ) = $1;\nAdd (para = 'p') = '<' $1 '>' {End} '<\/' $1 '>';\nReplace With (para = 'p') = {Ctrl+Alt+F4} '<' $1 '>' {End} '<\/' $1 '>';\n\nStart (Header | Heading) 1..7 = h $2 {Tab};\nAdd (Header | Heading) 1..7 = '<h' $2 '>' {End} '<\/h' $2 '>';\nReplace With (Header | Heading) 1..7 = {Ctrl+Alt+F4} '<h' $2 '>' {End} '<\/h' $2 '>' {Home};\nMid HREF = '\">';\n\nPaste Function = 'function ' {Ctrl+v} ' {' {Enter} {Enter} '};' {Up};\n\nPre-Format Code = {Ctrl+Alt+F5};\n\n# TO ADD:\n# adding HTML comments, using a snippet\n\n\n\n","old_contents":"# Voice commands for atom\n\ninclude folders.vch;\ninclude letters.vch;\n\nGo Strawberry = {Ctrl+Alt+F8};\n\n\n# Commands for developing Atom: init.config, packages; also for navigating existing packages\/commands\nReload Atom = {Ctrl+s} Wait(100) {Shift+Ctrl+Alt+F5};\nCommand Palette = {Ctrl+Shift+p};\nKeyboard Shortcuts = {Ctrl+.};\nRun Atom Specs = {Ctrl+Alt+p};\nShow Console = {Ctrl+Alt+i};\n\n# Commands for developing D3: D3 visualizations, D3 Sandwiches\nSave and Reload = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Ctrl+r};\t\nSave and Really Reload = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Ctrl+Shift+r};\n\n# File commands\nFind (File | Document) = {Ctrl+t};\nSave As = {Ctrl+Shift+s};\n\n\n# --- Navigation commands ------------------------------------\n<delimiters> := (Quote = '\"' | 'Single Quote' = \"'\" | Comma = ',' | 'Equal Sign' = '=' | Equals = '=' \n\t| Period = '.' | Colon = ':' | 'Semi-Colon' = ';' | Hyphen = '-' | Underscore = '_' | Slash = '\/'\n\t| Paren = \"(\" | \"Close Paren\" = \")\"\n\t| Bracket = '[' | \"Close Bracket\" = ']' | Brace = '{' | 'Close Brace' = '}'\t);\n\nLine 1..200 = {Ctrl+g} $1 {Enter};\n(Left = 'b' | Right = 'f') Word = {Alt+$1};\nTop = {Ctrl+Home};\nBottom = {Ctrl+End};\n(Find = 'Right' | 'Insert After' = 'Right' | 'Insert Before' = 'Left') (Next = 'Enter' | Last = 'Shift+F3') <delimiters> \n\t\t= {Ctrl+f} $3 {$2} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') <delimiters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') 1..20 <delimiters> = {Ctrl+f} $3 {Enter} {Esc} Wait(100) {F3_$2} {Shift+F3} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') Enda <delimiters> = {End} {Ctrl+f} $2 {Enter} {Esc} {Shift+F3} Wait(100) {$1};\n\nFine Alpha <letters> = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Left};\nInsert (Before = 'Left' | After = 'Right') Alpha <letters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nFine Number 0..9 = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Right};\nFind Again = {F3} {Right};\nFind Again 1..20 Times = {F3_$1} {Right};\n\nFind Symbol = {Ctrl+r};\n\n(Set | Add | Clear | Hide | Delete) Bookmark = {Ctrl+Alt+F2};\n(Next = 'F2' | Last = 'Shift+F2') Bookmark = {$1};\n\nNext Window = {Ctrl+Tab};\nLast Window = {Ctrl+Shift+Tab};\n\n\n# --- Editing commands ----------------------------------------\nSelect Line = {Ctrl+l};\nSelect (Next = 'Down' | Last = 'Up') 1..20 Lines = {Home} {Shift+$1_$2};\n(Join = 'j' | Indent = ']' | Dedent = '[') That = {Ctrl+$1};\nMove Line (Up | Down) 1..20 = {Ctrl+$1_$2};\n\n\n\nDelete Word = {Ctrl+Del};\nDelete 1..20 Words = {Ctrl+Del_$1};\nDelete (Back | Last) Word = {Ctrl+Backspace};\nDelete (Back | Last) 1..20 Words = {Ctrl+Backspace_$2};\nDelete Enda Word = {End} {Ctrl+Backspace};\n\n(Delete Line | Dede) = {Ctrl+Shift+k};\nDelete 1..20 Lines = {Ctrl+Shift+k_$1};\n(Cut = 'x' | Paste = 'v' | Copy = 'c') That = {Ctrl+$1};\n\nComment (That | Line) = {Ctrl+\/};\nComment 1..20 Lines = {Home} {Shift+Down_$1} {Ctrl+\/};\n\nSelect between (Delimiters | Brackets) ={Ctrl+m} {Ctrl+Alt+m};\n\nDelete Tags = {Ctrl+Alt+F4};\n\nReplace = {Ctrl+f};\nReplace All = {Ctrl+Enter};\n\n\n\n\n# --- Code commands -------------------------------------------\nStart (Item = 'li' | List = 'ul' | HTML = 'html' | pre = \"pre\"\n\t| 'Bold ID' = 'bold-id' | 'Input' = 'ds-input-text'\n\t| 'Fix Line' = 'fix-current-line' | 'Fix Current Line' = 'fix-current-line'\n\t| Snippet = 'my-snippet' | 'Recipe Row' = 'recipe-row' | 'Recipe Play' = 'recipe-play') = $1 {Tab};\nStart (para = '<p>' ) = $1;\nAdd (para = 'p') = '<' $1 '>' {End} '<\/' $1 '>';\nReplace With (para = 'p') = {Ctrl+Alt+F4} '<' $1 '>' {End} '<\/' $1 '>';\n\nStart (Header | Heading) 1..7 = h $2 {Tab};\nAdd (Header | Heading) 1..7 = '<h' $2 '>' {End} '<\/h' $2 '>';\nReplace With (Header | Heading) 1..7 = {Ctrl+Alt+F4} '<h' $2 '>' {End} '<\/h' $2 '>' {Home};\nMid HREF = '\">';\n\nPaste Function = 'function ' {Ctrl+v} ' {' {Enter} {Enter} '};' {Up};\n\nPre-Format Code = {Ctrl+Alt+F5};\n\n# TO ADD:\n# adding HTML comments, using a snippet\n\n\n\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"63088a32475ae89f75b6a4722f6bdf8e86713fb6","subject":"Modified several voice commands","message":"Modified several voice commands\n","repos":"aschneiderman\/atom-voice-vocola","old_file":"atom.vcl","new_file":"atom.vcl","new_contents":"# Voice commands for atom\n\ninclude folders.vch;\ninclude letters.vch;\n\n\n# Reload Atom = {Shift+Ctrl+Alt+F5};\nReload Atom = {Ctrl+s} Wait(100) {Shift+Ctrl+Alt+F5};\n\nFind (File | Document) = {Ctrl+t};\nSave As = {Ctrl+Shift+s};\nSave and Reload = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Ctrl+r};\n\n<delimiters> := (Quote = '\"' | 'Single Quote' = \"'\" | Comma = ',' | 'Equal Sign' = '=' | Equals = '=' \n\t| Period = '.' | Colon = ':' | 'Semi-Colon' = ';' | Hyphen = '-' | Underscore = '_'\n\t| Paren = \"(\" | \"Close Paren\" = \")\"\n\t| Bracket = '[' | \"Close Bracket\" = ']' | Brace = '{' | 'Close Brace' = '}'\t);\n\n# --- Navigation commands ------------------------------------\nLine 1..200 = {Ctrl+g} $1 {Enter};\n(Left = 'b' | Right = 'f') Word = {Alt+$1};\nTop = {Ctrl+Home};\nBottom = {Ctrl+End};\n(Find = 'Right' | 'Insert After' = 'Right' | 'Insert Before' = 'Left') (Next = 'Enter' | Last = 'Shift+F3') <delimiters> \n\t\t= {Ctrl+f} $3 {$2} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') <delimiters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') 1..20 <delimiters> = {Ctrl+f} $3 {Enter} {Esc} Wait(100) {F3_$2} {Shift+F3} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') Enda <delimiters> = {End} {Ctrl+f} $2 {Enter} {Esc} {Shift+F3} Wait(100) {$1};\n\nFine Alpha <letters> = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Right};\nInsert (Before = 'Left' | After = 'Right') Alpha <letters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nFine Number 0..9 = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Right};\nFind Again = {F3} {Right};\nFind Again 1..20 Times = {F3_$1} {Right};\n\nFind Symbol = {Ctrl+r};\n\n(Set | Add | Clear | Hide | Delete) Bookmark = {Ctrl+Alt+F2};\n(Next = 'F2' | Last = 'Shift+F2') Bookmark = {$1};\n\nNext Window = {Ctrl+Tab};\nLast Window = {Ctrl+Shift+Tab};\n\n\n# --- Editing commands ----------------------------------------\nSelect Line = {Ctrl+l};\nSelect (Next = 'Down' | Last = 'Up') 1..20 Lines = {Home} {Shift+$1_$2};\n(Join = 'j' | Indent = ']' | Dedent = '[') That = {Ctrl+$1};\nMove Line (Up | Down) 1..20 = {Ctrl+$1_$2};\n\n\n\nDelete Word = {Ctrl+Del};\nDelete 1..20 Words = {Ctrl+Del_$1};\nDelete (Back | Last) Word = {Ctrl+Backspace};\nDelete (Back | Last) 1..20 Words = {Ctrl+Backspace_$2};\nDelete Enda Word = {End} {Ctrl+Backspace};\n\n(Delete Line | Dede) = {Ctrl+Shift+k};\nDelete 1..20 Lines = {Ctrl+Shift+k_$1};\n(Cut = 'x' | Paste = 'v' | Copy = 'c') That = {Ctrl+$1};\n\nComment (That | Line) = {Ctrl+\/};\nComment 1..20 Lines = {Home} {Shift+Down_$1} {Ctrl+\/};\n\nSelect between (Delimiters | Brackets) ={Ctrl+m} {Ctrl+Alt+m};\n\nDelete Tags = {Ctrl+Alt+F4};\n\n\n\n\n# --- Code commands -------------------------------------------\nStart (Item = 'li' | List = 'ul' | HTML = 'html' | pre = \"pre\"\n\t| 'Bold ID' = 'bold-id' | 'Input' = 'ds-input-text'\n\t| 'Fix Line' = 'fix-current-line' | 'Fix Current Line' = 'fix-current-line'\n\t| Snippet = 'my-snippet' | 'Recipe Row' = 'recipe-row' | 'Recipe Play' = 'recipe-play') = $1 {Tab};\nStart (para = '<p>' ) = $1;\nAdd (para = 'p') = '<' $1 '>' {End} '<\/' $1 '>';\nReplace With (para = 'p') = {Ctrl+Alt+F4} '<' $1 '>' {End} '<\/' $1 '>';\n\nStart (Header | Heading) 1..7 = h $2 {Tab};\nAdd (Header | Heading) 1..7 = '<h' $2 '>' {End} '<\/h' $2 '>';\nReplace With (Header | Heading) 1..7 = {Ctrl+Alt+F4} '<h' $2 '>' {End} '<\/h' $2 '>' {Home};\nMid HREF = '\">';\n\nPaste Function = 'function ' {Ctrl+v} ' {' {Enter} {Enter} '};' {Up};\n\nPre-Format Code = {Ctrl+Alt+F5};\n\n# TO ADD:\n# adding HTML comments, using a snippet\n\nShortcut Keys = {Ctrl+Shift+p};\n\n","old_contents":"# Voice commands for atom\n\ninclude folders.vch;\ninclude letters.vch;\n\n\n# Reload Atom = {Shift+Ctrl+Alt+F5};\nReload Atom = {Ctrl+s} Wait(100) {Shift+Ctrl+Alt+F5};\n\nFind (File | Document) = {Ctrl+t};\nSave As = {Ctrl+Shift+s};\nSave and Reload = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Ctrl+r};\n\n<delimiters> := (Quote = '\"' | 'Single Quote' = \"'\" | Comma = ',' | 'Equal Sign' = '=' | Equals = '=' \n\t| Period = '.' | Colon = ':' | 'Semi-Colon' = ';' | Hyphen = '-' | Underscore = '_'\n\t| Paren = \"(\" | \"Close Paren\" = \")\"\n\t| Bracket = '[' | \"Close Bracket\" = ']' | Brace = '{' | 'Close Brace' = '}'\t);\n\n# --- Navigation commands ------------------------------------\nLine 1..200 = {Ctrl+g} $1 {Enter};\n(Left = 'b' | Right = 'f') Word = {Alt+$1};\nTop = {Ctrl+Home};\nBottom = {Ctrl+End};\n(Find = 'Right' | 'Insert After' = 'Right' | 'Insert Before' = 'Left') (Next = 'Enter' | Last = 'Shift+F3') <delimiters> \n\t\t= {Ctrl+f} $3 {$2} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') <delimiters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') 1..20 <delimiters> = {Ctrl+f} $3 {Enter} {Esc} Wait(100) {F3_$2} {Shift+F3} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') Enda <delimiters> = {End} {Ctrl+f} $2 {Enter} {Esc} {Shift+F3} Wait(100) {$1};\n\nFine Alpha <letters> = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Right};\nInsert (Before = 'Left' | After = 'Right') Alpha <letters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nFine Number 0..9 = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Right};\nFind Again = {F3} {Right};\nFind Again 1..20 Times = {F3_$1} {Right};\n\nFind Symbol = {Ctrl+r};\n\n(Set | Add | Clear | Hide | Delete) Bookmark = {Ctrl+Alt+F2};\n(Next = 'F2' | Last = 'Shift+F2') Bookmark = {$1};\n\nNext Window = {Ctrl+Tab};\nLast Window = {Ctrl+Shift+Tab};\n\n\n# --- Editing commands ----------------------------------------\nSelect Line = {Ctrl+l};\nSelect (Next = 'Down' | Last = 'Up') 1..20 Lines = {Home} {Shift+$1_$2};\n(Join = 'j' | Indent = ']' | Dedent = '[') That = {Ctrl+$1};\nMove Line (Up | Down) 1..20 = {Ctrl+$1_$2};\n\n\n\nDelete Word = {Ctrl+Del};\nDelete 1..20 Words = {Ctrl+Del_$1};\nDelete (Back | Last) Word = {Ctrl+Backspace};\nDelete (Back | Last) 1..20 Words = {Ctrl+Backspace_$2};\nDelete Enda Word = {End} {Ctrl+Backspace};\n\n(Delete Line | Dede) = {Ctrl+Shift+k};\nDelete 1..20 Lines = {Ctrl+Shift+k_$1};\n(Cut = 'x' | Paste = 'v' | Copy = 'c') That = {Ctrl+$1};\n\nComment (That | Line) = {Ctrl+\/};\nComment 1..20 Lines = {Home} {Shift+Down_$1} {Ctrl+\/};\n\nSelect between (Delimiters | Brackets) ={Ctrl+m} {Ctrl+Alt+m};\nDelete Tags = {Ctrl+Alt+F4};\n\n\n\n\n# --- Code commands -------------------------------------------\nStart (Item = 'li' | List = 'ul' | HTML = 'html' | pre = \"pre\"\n\t| 'Bold ID' = 'bold-id' | 'Input' = 'ds-input-text'\n\t| 'Fix Line' = 'fix-current-line' | 'Fix Current Line' = 'fix-current-line'\n\t| Snippet = 'my-snippet' | 'Recipe Row' = 'recipe-row' | 'Recipe Play' = 'recipe-play') = $1 {Tab};\nStart (para = '<p>' ) = $1;\nAdd (para = 'p') = '<' $1 '>' {End} '<\/' $1 '>';\nReplace With (para = 'p') = {Ctrl+Alt+F4} '<' $1 '>' {End} '<\/' $1 '>';\n\nStart (Header | Heading) 1..7 = h $2 {Tab};\nAdd (Header | Heading) 1..7 = '<h' $2 '>' {End} '<\/h' $2 '>';\nReplace With (Header | Heading) 1..7 = {Ctrl+Alt+F4} '<h' $2 '>' {End} '<\/h' $2 '>' {Home};\nMid HREF = '\">';\n\nPaste Function = 'function ' {Ctrl+v} ' {' {Enter} {Enter} '};' {Up};\n\n# TO ADD:\n# adding HTML comments, using a snippet\n\nShortcut Keys = {Ctrl+Shift+p};\n\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"cc48ffe44e353f06d8409fdac9f28469de835e6a","subject":"Clearer diagnostics.","message":"Clearer diagnostics.\n","repos":"telusdigital\/ansible-varnish,killerwails\/ansible-varnish,kkwoker\/ansible-varnish,gotofbi\/ansible-varnish,gotofbi\/ansible-varnish,noqcks\/ansible-varnish,killerwails\/ansible-varnish,colstrom\/ansible-varnish","old_file":"templates\/etc\/varnish\/default.vcl","new_file":"templates\/etc\/varnish\/default.vcl","new_contents":"vcl 4.0;\n\nimport directors;\nimport std;\n\n###\n# Varnish Documentation\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-built-in-subs.html\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/reference\/vcl.html\n##\n\n{% for backend in varnish_backend_hosts %}\nbackend application_{{ loop.index }} {\n .host = \"{{ backend }}\";\n .port = \"{{ varnish_backend_port }}\";\n{% if varnish_health_checks_enabled %}\n .probe = {\n .url = \"{{ varnish_health_check_url }}\";\n .interval = {{ varnish_health_check_interval }};\n .timeout = {{ varnish_health_check_timeout }};\n .window = {{ varnish_health_check_window }};\n .threshold = {{ varnish_health_check_threshold }};\n }\n{% endif %}\n}\n{% endfor %}\n\n###\n# vcl_init\n# Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n###\n# The vcl_init subroutine may terminate with calling return() with one of the following keywords:\n#\n# ok\n# Normal return, VCL continues loading.\n##\n\nsub vcl_init {\n new application = directors.round_robin();\n{% for backend in varnish_backend_hosts %}\n application.add_backend(application_{{ loop.index }});\n{% endfor %}\n}\n\n###\n# vcl_recv\n# Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use. \n# It is also used to modify the request\n###\n# The vcl_recv subroutine may terminate with calling return() on one of the following keywords:\n#\n# synth(status code, reason)\n# Return a synthetic object with the specified status code to the client and abandon the request.\n# pass\n# Switch to pass mode. Control will eventually pass to vcl_pass.\n# pipe\n# Switch to pipe mode. Control will eventually pass to vcl_pipe.\n# hash\n# Continue processing the object as a potential candidate for caching. Passes the control over to vcl_hash.\n# purge\n# Purge the object and it's variants. Control passes through vcl_hash to vcl_purge.\n#\n\nsub vcl_recv {\n set req.backend_hint = application.backend();\n\n ###\n # Avoid processing uncacheable requests\n ###\n\n if (req.http.Authorization) {\n set req.http.X-Passthrough-Reason = \"No Caching Authenticated Content\";\n return (pass);\n }\n\n{% if varnish_uri_blacklist_enabled %}\n if ((req.url ~ \"{{ varnish_uri_blacklist_regexp }}\")) {\n set req.http.X-Passthrough-Reason = \"Path in Blacklist\";\n return(pass);\n }\n{% endif %}\n\n{% if varnish_diagnostic_headers_forwarded_for %}\n ###\n # Inject X-Forwarded-For headers, but only once.\n ###\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_enabled %}\n ###\n # Cookie Sanitization\n ###\n if (req.http.Cookie) {\n set req.http.X-Cookie-Unmodified = req.http.Cookie;\n\n {% for cookie in varnish_cookie_sanitization_blacklist %}\n set req.http.Cookie = regsuball(req.http.Cookie, \"{{ cookie }}=[^;]+(; )?\", \"\");\n {% endfor %}\n\n ### General Cleanup\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n if (req.http.Cookie ~ \"^\\s*$\") {\n set req.http.X-Cookie-Discarded = \"YES:Empty\";\n unset req.http.Cookie;\n }\n if (req.http.Cookie) {\n set req.http.X-Cookie-Sanitized = req.http.Cookie;\n }\n }\n{% endif %}\n\n{% if varnish_header_sanitization_enabled %}\n ###\n # Header Sanitization\n ###\n\n{% if varnish_header_sanitization_discard_host_port %}\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n{% endif %}\n\n{% if varnish_header_sanitization_normalize_accept_encoding %}\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n{% endif %}\n\n{% endif %}\n\n{% if varnish_uri_sanitization_enabled %}\n ###\n # URI Sanitization\n ###\n \n if (req.url ~ \"(\\?|&){{ varnish_uri_sanitization_regexp }}=\") {\n set req.url = regsuball(req.url, \"&{{ varnish_uri_sanitization_regexp }}=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?{{ varnish_uri_sanitization_regexp }}=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n{% endif %}\n\n{% if varnish_workaround_telusdotcom_browser_profile %}\n ###\n # Workaround and Diagnostics for BrowserProfile and Language\/Region Detection on TELUS.com\n ###\n\n if (req.http.Cookie ~ \"BrowserProfile\") {\n set req.http.X-BrowserProfile = regsuball(req.http.Cookie, \"(.*)BrowserProfile=([^;]*)(.*)\", \"\\2\");\n if (req.http.X-BrowserProfile ~ \"language\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.X-BrowserProfile, \"(.*)language\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n set req.http.X-Language-Found = \"YES:BrowserProfile\";\n }\n if (req.http.X-BrowserProfile ~ \"region\") {\n set req.http.X-Region = std.tolower(regsuball(regsuball(req.http.X-BrowserProfile, \"geo\\\\.\\:{(.*)\\}\", \"\"), \"(.*)region\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n set req.http.X-Region-Found = \"YES:BrowserProfile\";\n }\n if (req.http.X-BrowserProfile ~ \"geo\") {\n set req.http.X-BrowserProfile-Geolocation = regsuball(req.http.X-BrowserProfile, \"(.*)geo..:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n set req.http.X-BrowserProfile-Geolocation-Found = \"YES\";\n\n if (req.http.X-BrowserProfile-Geolocation ~ \"country\") {\n set req.http.X-BrowserProfile-Geolocation-Country = regsuball(req.http.X-BrowserProfile-Geolocation, \"(.*)country\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-BrowserProfile-Geolocation ~ \"region\") {\n set req.http.X-BrowserProfile-Geolocation-Region = regsuball(req.http.X-BrowserProfile-Geolocation, \"(.*)region\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-BrowserProfile-Geolocation ~ \"city\") {\n set req.http.X-BrowserProfile-Geolocation-City = regsuball(req.http.X-BrowserProfile-Geolocation, \"(.*)city\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-BrowserProfile-Geolocation ~ \"isp\") {\n set req.http.X-BrowserProfile-Geolocation-ISP = regsuball(req.http.X-BrowserProfile-Geolocation, \"(.*)isp\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n } else {\n set req.http.X-BrowserProfile-Geolocation-Found = \"NO\";\n }\n }\n\n if (!req.http.X-Language) {\n if (req.http.Cookie ~ \"lang=\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.Cookie, \"(.*)lang=([^;]*)(.*)\", \"\\2\"));\n set req.http.X-Language-Found = \"YES:lang\";\n } else {\n set req.http.X-Language = \"en\";\n set req.http.X-Language-Found = \"NO\";\n }\n }\n\n if (!req.http.X-Region) {\n if (req.http.Cookie ~ \"prov=\") {\n set req.http.X-Region = std.tolower(regsuball(req.http.Cookie, \"(.*)prov=([^;]*)(.*)\", \"\\2\"));\n set req.http.X-Region-Found = \"YES:prov\";\n } else {\n set req.http.X-Region = \"bc\";\n set req.http.X-Region-Found = \"NO\";\n }\n }\n\n\n if (req.url ~ \"\/(en|fr)\/\") {\n if (req.url ~ \"\/en\/\" && req.http.X-Language != \"en\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Language (Path: \/en\/) vs (Cookie: \" + req.http.X-Language + \")\";\n return(pass);\n }\n if (req.url ~ \"\/fr\/\" && req.http.X-Language != \"fr\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Language (Path: \/fr\/) vs (Cookie: \" + req.http.X-Language + \")\";\n return(pass);\n }\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Language)\";\n return(pass);\n }\n\n if (req.url ~ \"\/(ab|bc|mb|nb|nl|ns|nt|nu|on|pe|qc|sk|yt)\/\") {\n {% for province in ['ab', 'bc', 'mb', 'nb', 'nl', 'ns', 'nt', 'nu', 'on', 'pe', 'qc', 'sk', 'yt'] %}\n if (req.url ~ \"\/{{ province }}\/\" && req.http.X-Region != \"{{ province }}\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Region (Path: \/{{ province }}\/) vs (Cookie: \" + req.http.X-Region + \")\";\n return(pass);\n }\n {% endfor %}\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Province)\";\n return(pass);\n }\n\n if (req.http.Cookie) {\n if (req.http.Cookie ~ \"***REMOVED***\") {\n set req.http.X-Screen-Resolution = regsuball(req.http.Cookie, \"(.*)***REMOVED***=([^;]*)(.*)\", \"\\2\");\n }\n\n if (req.http.Cookie ~ \"***REMOVED***\") {\n set req.http.X-Customer-Type = regsuball(req.http.Cookie, \"(.*)***REMOVED***=([^;]*)(.*)\", \"\\2\");\n }\n if (req.http.Cookie ~ \"***REMOVED***\") {\n set req.http.X-Outdated-Browser = regsuball(req.http.Cookie, \"(.*)***REMOVED***=([^;]*)(.*)\", \"\\2\");\n }\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_discard_from_client %}\n set req.http.X-Cookie-Discarded = \"YES:No Reason Not To\";\n unset req.http.Cookie;\n{% endif %}\n}\n\n###\n# vcl_hit\n# Called when a cache lookup is successful.\n###\n# The vcl_hit subroutine may terminate with calling return() with one of the following keywords:\n#\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n# deliver\n# Deliver the object. Control passes to vcl_deliver.\n# synth(status code, reason)\n# Return the specified status code to the client and abandon the request.\n###\n\nsub vcl_hit {\n if (obj.ttl > 0s) {\n return (deliver);\n }\n{% if varnish_health_checks_enabled %}\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (fetch);\n }\n{% else %}\n if (obj.ttl + obj.grace > 0s) {\n return (deliver);\n }\n\n return (fetch);\n{% endif %}\n}\n\n###\n# vcl_backend_response\n# Called after the response headers has been successfully retrieved from the backend.\n###\n# The vcl_backend_response subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Possibly insert the object into the cache, then deliver it to the Control will eventually pass to vcl_deliver.\n# abandon\n# Abandon the backend request and generates an error.\n# retry\n# Retry the backend transaction. Increases the retries counter. If the number of retries is higher than max_retries Varnish emits a guru meditation error.\n###\n\nsub vcl_backend_response {\n{% if varnish_workaround_telusdotcom_browser_profile %}\n if (bereq.http.X-Language) {\n set beresp.http.X-Language = bereq.http.X-Language;\n# if (bereq.http.X-Language-Found) {\n# set beresp.http.X-Language-Found = bereq.http.X-Language-Found;\n# }\n }\n if (bereq.http.X-Region) {\n set beresp.http.X-Region = bereq.http.X-Region;\n# if (bereq.http.X-Region-Found) {\n# set beresp.http.X-Region-Found = bereq.http.X-Region-Found;\n# }\n }\n{% endif %}\n\n{% if varnish_uri_blacklist_enabled %}\n if (bereq.url ~ \"{{ varnish_uri_blacklist_regexp }}\") {\n set beresp.http.X-Cacheable = \"NO:Path in Blacklist\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n if (bereq.http.X-Passthrough-Reason) {\n{% if varnish_diagnostic_headers_passthrough_reason %}\n set beresp.http.X-Passthrough-Reason = bereq.http.X-Passthrough-Reason;\n{% endif %}\n return(deliver);\n } else {\n{% if varnish_cookie_sanitization_discard_from_server %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n }\n }\n{% else %}\n{% if varnish_cookie_sanitization_discard_from_server %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n{% endif %}\n\n{% if varnish_diagnostic_headers_enabled %}\n if (bereq.http.Cookie) {\n set beresp.http.X-Cacheable = \"NO:Cookie in Request\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO:Set-Cookie in Response\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.X-No-Cache) {\n set beresp.http.X-Cacheable = \"NO:X-No-Cache\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.ttl <= 0s) {\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n{% endif %}\n\n set beresp.grace = {{ varnish_grace_period }};\n}\n\n###\n# vcl_deliver\n# Called before a cached object is delivered to the client.\n###\n# The vcl_deliver subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Deliver the object to the client.\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n###\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n","old_contents":"vcl 4.0;\n\nimport directors;\nimport std;\n\n###\n# Varnish Documentation\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-built-in-subs.html\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/reference\/vcl.html\n##\n\n{% for backend in varnish_backend_hosts %}\nbackend application_{{ loop.index }} {\n .host = \"{{ backend }}\";\n .port = \"{{ varnish_backend_port }}\";\n{% if varnish_health_checks_enabled %}\n .probe = {\n .url = \"{{ varnish_health_check_url }}\";\n .interval = {{ varnish_health_check_interval }};\n .timeout = {{ varnish_health_check_timeout }};\n .window = {{ varnish_health_check_window }};\n .threshold = {{ varnish_health_check_threshold }};\n }\n{% endif %}\n}\n{% endfor %}\n\n###\n# vcl_init\n# Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n###\n# The vcl_init subroutine may terminate with calling return() with one of the following keywords:\n#\n# ok\n# Normal return, VCL continues loading.\n##\n\nsub vcl_init {\n new application = directors.round_robin();\n{% for backend in varnish_backend_hosts %}\n application.add_backend(application_{{ loop.index }});\n{% endfor %}\n}\n\n###\n# vcl_recv\n# Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use. \n# It is also used to modify the request\n###\n# The vcl_recv subroutine may terminate with calling return() on one of the following keywords:\n#\n# synth(status code, reason)\n# Return a synthetic object with the specified status code to the client and abandon the request.\n# pass\n# Switch to pass mode. Control will eventually pass to vcl_pass.\n# pipe\n# Switch to pipe mode. Control will eventually pass to vcl_pipe.\n# hash\n# Continue processing the object as a potential candidate for caching. Passes the control over to vcl_hash.\n# purge\n# Purge the object and it's variants. Control passes through vcl_hash to vcl_purge.\n#\n\nsub vcl_recv {\n set req.backend_hint = application.backend();\n\n ###\n # Avoid processing uncacheable requests\n ###\n\n if (req.http.Authorization) {\n set req.http.X-Passthrough-Reason = \"No Caching Authenticated Content\";\n return (pass);\n }\n\n{% if varnish_uri_blacklist_enabled %}\n if ((req.url ~ \"{{ varnish_uri_blacklist_regexp }}\")) {\n set req.http.X-Passthrough-Reason = \"Path in Blacklist\";\n return(pass);\n }\n{% endif %}\n\n{% if varnish_diagnostic_headers_forwarded_for %}\n ###\n # Inject X-Forwarded-For headers, but only once.\n ###\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_enabled %}\n ###\n # Cookie Sanitization\n ###\n if (req.http.Cookie) {\n set req.http.X-Cookie-Unmodified = req.http.Cookie;\n\n {% for cookie in varnish_cookie_sanitization_blacklist %}\n set req.http.Cookie = regsuball(req.http.Cookie, \"{{ cookie }}=[^;]+(; )?\", \"\");\n {% endfor %}\n\n ### General Cleanup\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n if (req.http.Cookie ~ \"^\\s*$\") {\n set req.http.X-Cookie-Discarded = \"YES\";\n unset req.http.Cookie;\n }\n if (req.http.Cookie) {\n set req.http.X-Cookie-Sanitized = req.http.Cookie;\n }\n }\n{% endif %}\n\n{% if varnish_header_sanitization_enabled %}\n ###\n # Header Sanitization\n ###\n\n{% if varnish_header_sanitization_discard_host_port %}\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n{% endif %}\n\n{% if varnish_header_sanitization_normalize_accept_encoding %}\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n{% endif %}\n\n{% endif %}\n\n{% if varnish_uri_sanitization_enabled %}\n ###\n # URI Sanitization\n ###\n \n if (req.url ~ \"(\\?|&){{ varnish_uri_sanitization_regexp }}=\") {\n set req.url = regsuball(req.url, \"&{{ varnish_uri_sanitization_regexp }}=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?{{ varnish_uri_sanitization_regexp }}=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n{% endif %}\n\n{% if varnish_workaround_telusdotcom_browser_profile %}\n ###\n # Workaround and Diagnostics for BrowserProfile and Language\/Region Detection on TELUS.com\n ###\n\n if (req.http.Cookie ~ \"BrowserProfile\") {\n set req.http.X-BrowserProfile = regsuball(req.http.Cookie, \"(.*)BrowserProfile=([^;]*)(.*)\", \"\\2\");\n if (req.http.X-BrowserProfile ~ \"language\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.X-BrowserProfile, \"(.*)language\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n set req.http.X-Language-Found = \"YES:BrowserProfile\";\n }\n if (req.http.X-BrowserProfile ~ \"region\") {\n set req.http.X-Region = std.tolower(regsuball(regsuball(req.http.X-BrowserProfile, \"geo\\\\.\\:{(.*)\\}\", \"\"), \"(.*)region\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n set req.http.X-Region-Found = \"YES:BrowserProfile\";\n }\n if (req.http.X-BrowserProfile ~ \"geo\") {\n set req.http.X-BrowserProfile-Geolocation = regsuball(req.http.X-BrowserProfile, \"(.*)geo..:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n set req.http.X-BrowserProfile-Geolocation-Found = \"YES\";\n\n if (req.http.X-BrowserProfile-Geolocation ~ \"country\") {\n set req.http.X-BrowserProfile-Geolocation-Country = regsuball(req.http.X-BrowserProfile-Geolocation, \"(.*)country\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-BrowserProfile-Geolocation ~ \"region\") {\n set req.http.X-BrowserProfile-Geolocation-Region = regsuball(req.http.X-BrowserProfile-Geolocation, \"(.*)region\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-BrowserProfile-Geolocation ~ \"city\") {\n set req.http.X-BrowserProfile-Geolocation-City = regsuball(req.http.X-BrowserProfile-Geolocation, \"(.*)city\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-BrowserProfile-Geolocation ~ \"isp\") {\n set req.http.X-BrowserProfile-Geolocation-ISP = regsuball(req.http.X-BrowserProfile-Geolocation, \"(.*)isp\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n } else {\n set req.http.X-BrowserProfile-Geolocation-Found = \"NO\";\n }\n }\n\n if (!req.http.X-Language) {\n if (req.http.Cookie ~ \"lang=\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.Cookie, \"(.*)lang=([^;]*)(.*)\", \"\\2\"));\n set req.http.X-Language-Found = \"YES:lang\";\n } else {\n set req.http.X-Language = \"en\";\n set req.http.X-Language-Found = \"NO\";\n }\n }\n\n if (!req.http.X-Region) {\n if (req.http.Cookie ~ \"prov=\") {\n set req.http.X-Region = std.tolower(regsuball(req.http.Cookie, \"(.*)prov=([^;]*)(.*)\", \"\\2\"));\n set req.http.X-Region-Found = \"YES:prov\";\n } else {\n set req.http.X-Region = \"bc\";\n set req.http.X-Region-Found = \"NO\";\n }\n }\n\n\n if (req.url ~ \"\/(en|fr)\/\") {\n if (req.url ~ \"\/en\/\" && req.http.X-Language != \"en\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Language (Path: \/en\/) vs (Cookie: \" + req.http.X-Language + \")\";\n return(pass);\n }\n if (req.url ~ \"\/fr\/\" && req.http.X-Language != \"fr\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Language (Path: \/fr\/) vs (Cookie: \" + req.http.X-Language + \")\";\n return(pass);\n }\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Language)\";\n return(pass);\n }\n\n if (req.url ~ \"\/(ab|bc|mb|nb|nl|ns|nt|nu|on|pe|qc|sk|yt)\/\") {\n {% for province in ['ab', 'bc', 'mb', 'nb', 'nl', 'ns', 'nt', 'nu', 'on', 'pe', 'qc', 'sk', 'yt'] %}\n if (req.url ~ \"\/{{ province }}\/\" && req.http.X-Region != \"{{ province }}\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Region (Path: \/{{ province }}\/) vs (Cookie: \" + req.http.X-Region + \")\";\n return(pass);\n }\n {% endfor %}\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Province)\";\n return(pass);\n }\n\n if (req.http.Cookie) {\n if (req.http.Cookie ~ \"***REMOVED***\") {\n set req.http.X-Screen-Resolution = regsuball(req.http.Cookie, \"(.*)***REMOVED***=([^;]*)(.*)\", \"\\2\");\n }\n\n if (req.http.Cookie ~ \"***REMOVED***\") {\n set req.http.X-Customer-Type = regsuball(req.http.Cookie, \"(.*)***REMOVED***=([^;]*)(.*)\", \"\\2\");\n }\n if (req.http.Cookie ~ \"***REMOVED***\") {\n set req.http.X-Outdated-Browser = regsuball(req.http.Cookie, \"(.*)***REMOVED***=([^;]*)(.*)\", \"\\2\");\n }\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_discard_from_client %}\n set req.http.X-Cookie-Discarded = \"YES\";\n unset req.http.Cookie;\n{% endif %}\n}\n\n###\n# vcl_hit\n# Called when a cache lookup is successful.\n###\n# The vcl_hit subroutine may terminate with calling return() with one of the following keywords:\n#\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n# deliver\n# Deliver the object. Control passes to vcl_deliver.\n# synth(status code, reason)\n# Return the specified status code to the client and abandon the request.\n###\n\nsub vcl_hit {\n if (obj.ttl > 0s) {\n return (deliver);\n }\n{% if varnish_health_checks_enabled %}\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (fetch);\n }\n{% else %}\n if (obj.ttl + obj.grace > 0s) {\n return (deliver);\n }\n\n return (fetch);\n{% endif %}\n}\n\n###\n# vcl_backend_response\n# Called after the response headers has been successfully retrieved from the backend.\n###\n# The vcl_backend_response subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Possibly insert the object into the cache, then deliver it to the Control will eventually pass to vcl_deliver.\n# abandon\n# Abandon the backend request and generates an error.\n# retry\n# Retry the backend transaction. Increases the retries counter. If the number of retries is higher than max_retries Varnish emits a guru meditation error.\n###\n\nsub vcl_backend_response {\n{% if varnish_workaround_telusdotcom_browser_profile %}\n if (bereq.http.X-Language) {\n set beresp.http.X-Language = bereq.http.X-Language;\n# if (bereq.http.X-Language-Found) {\n# set beresp.http.X-Language-Found = bereq.http.X-Language-Found;\n# }\n }\n if (bereq.http.X-Region) {\n set beresp.http.X-Region = bereq.http.X-Region;\n# if (bereq.http.X-Region-Found) {\n# set beresp.http.X-Region-Found = bereq.http.X-Region-Found;\n# }\n }\n{% endif %}\n\n{% if varnish_uri_blacklist_enabled %}\n if (bereq.url ~ \"{{ varnish_uri_blacklist_regexp }}\") {\n set beresp.http.X-Cacheable = \"NO:Path in Blacklist\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n if (bereq.http.X-Passthrough-Reason) {\n{% if varnish_diagnostic_headers_passthrough_reason %}\n set beresp.http.X-Passthrough-Reason = bereq.http.X-Passthrough-Reason;\n{% endif %}\n return(deliver);\n } else {\n{% if varnish_cookie_sanitization_discard_from_server %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n }\n }\n{% else %}\n{% if varnish_cookie_sanitization_discard_from_server %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n{% endif %}\n\n{% if varnish_diagnostic_headers_enabled %}\n if (bereq.http.Cookie) {\n set beresp.http.X-Cacheable = \"NO:Cookie in Request\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO:Set-Cookie in Response\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.X-No-Cache) {\n set beresp.http.X-Cacheable = \"NO:X-No-Cache\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.ttl <= 0s) {\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n{% endif %}\n\n set beresp.grace = {{ varnish_grace_period }};\n}\n\n###\n# vcl_deliver\n# Called before a cached object is delivered to the client.\n###\n# The vcl_deliver subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Deliver the object to the client.\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n###\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"1638628650486090595bf53a127c5b38d79d41e6","subject":"Example VCL: Cleanup and update for varnish version >= 1.2","message":"Example VCL: Cleanup and update for varnish version >= 1.2\n\n\ngit-svn-id: 2c9807fa3ff65b17195bd55dc8a6c4261e10127b@2634 d4fa192b-c00b-0410-8231-f00ffab90ce4\n","repos":"feld\/Varnish-Cache,ssm\/pkg-varnish,varnish\/Varnish-Cache,drwilco\/varnish-cache-drwilco,chrismoulton\/Varnish-Cache,franciscovg\/Varnish-Cache,alarky\/varnish-cache-doc-ja,ssm\/pkg-varnish,varnish\/Varnish-Cache,1HLtd\/Varnish-Cache,wikimedia\/operations-debs-varnish,ajasty-cavium\/Varnish-Cache,franciscovg\/Varnish-Cache,chrismoulton\/Varnish-Cache,alarky\/varnish-cache-doc-ja,ajasty-cavium\/Varnish-Cache,mrhmouse\/Varnish-Cache,gquintard\/Varnish-Cache,ambernetas\/varnish-cache,varnish\/Varnish-Cache,drwilco\/varnish-cache-old,feld\/Varnish-Cache,feld\/Varnish-Cache,drwilco\/varnish-cache-drwilco,chrismoulton\/Varnish-Cache,drwilco\/varnish-cache-old,ssm\/pkg-varnish,franciscovg\/Varnish-Cache,zhoualbeart\/Varnish-Cache,varnish\/Varnish-Cache,1HLtd\/Varnish-Cache,drwilco\/varnish-cache-drwilco,wikimedia\/operations-debs-varnish,mrhmouse\/Varnish-Cache,alarky\/varnish-cache-doc-ja,varnish\/Varnish-Cache,feld\/Varnish-Cache,chrismoulton\/Varnish-Cache,1HLtd\/Varnish-Cache,zhoualbeart\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,zhoualbeart\/Varnish-Cache,alarky\/varnish-cache-doc-ja,wikimedia\/operations-debs-varnish,ssm\/pkg-varnish,gauthier-delacroix\/Varnish-Cache,gquintard\/Varnish-Cache,wikimedia\/operations-debs-varnish,ssm\/pkg-varnish,mrhmouse\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,gquintard\/Varnish-Cache,mrhmouse\/Varnish-Cache,zhoualbeart\/Varnish-Cache,drwilco\/varnish-cache-old,ambernetas\/varnish-cache,wikimedia\/operations-debs-varnish,zhoualbeart\/Varnish-Cache,franciscovg\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,1HLtd\/Varnish-Cache,feld\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,chrismoulton\/Varnish-Cache,mrhmouse\/Varnish-Cache,ambernetas\/varnish-cache,gquintard\/Varnish-Cache,franciscovg\/Varnish-Cache,alarky\/varnish-cache-doc-ja","old_file":"etc\/zope-plone.vcl","new_file":"etc\/zope-plone.vcl","new_contents":"#\n# This is an example VCL configuration file for varnish, meant for the\n# Plone CMS running within Zope. It defines a \"default\" backend for\n# serving static content from a normal web server, and a \"zope\"\n# backend for requests to the Zope CMS\n#\n# See the vcl(7) man page for details on VCL syntax and semantics.\n#\n# $Id$\n#\n\n# Default backend definition. Set this to point to your content\n# server.\n\n# Default backend is the Zope CMS\nbackend default {\n\tset backend.host = \"127.0.0.1\";\n\tset backend.port = \"9673\";\n}\n\nacl purge {\n\t\"localhost\";\n\t\"192.0.2.0\"\/24;\n}\n\nsub vcl_recv {\n\n\t# Normalize host headers, and do rewriting for the zope sites. Reject\n\t# requests for unknown hosts\n if (req.http.host ~ \"(www.)?example.com\") {\n set req.http.host = \"example.com\";\n set req.url = \"\/VirtualHostBase\/http\/example.com:80\/example.com\/VirtualHostRoot\" req.url;\n } elsif (req.http.host ~ \"(www.)?example.org\") {\n set req.http.host = \"example.org\";\n set req.url = \"\/VirtualHostBase\/http\/example.org:80\/example.org\/VirtualHostRoot\" req.url;\n } else {\n error 404 \"Unknown virtual host.\";\n }\n\n # Handle special requests\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n\n # POST - Logins and edits\n if (req.request == \"POST\") {\n pass;\n }\n \n # PURGE - The CacheFu product can invalidate updated URLs\n if (req.request == \"PURGE\") {\n if (!client.ip ~ purge) {\n error 405 \"Not allowed.\";\n }\n lookup;\n }\n }\n\n # Don't cache authenticated requests\n if (req.http.Cookie && req.http.Cookie ~ \"__ac(|_(name|password|persistent))=\") {\n\n\t\t# Force lookup of specific urls unlikely to need protection\n\t\tif (req.url ~ \"\\.(js|css)\") {\n remove req.http.cookie;\n lookup;\n }\n pass;\n }\n\n # The default vcl_recv is used from here.\n }\n\n# Do the PURGE thing\nsub vcl_hit {\n if (req.request == \"PURGE\") {\n set obj.ttl = 0s;\n error 200 \"Purged\";\n }\n}\nsub vcl_miss {\n if (req.request == \"PURGE\") {\n error 404 \"Not in cache\";\n }\n}\n\n# Enforce a minimum TTL, since we can PURGE changed objects actively\n# from Zope by using the CacheFu product\n\nsub vcl_fetch {\n if (obj.ttl < 3600s) {\n set obj.ttl = 3600s;\n }\n}\n","old_contents":"#\n# This is a basic VCL configuration file for varnish. See the vcl(7)\n# man page for details on VCL syntax and semantics.\n#\n# $Id: default.vcl 1424 2007-05-15 19:38:56Z des $\n#\n\n# Default backend definition. Set this to point to your content\n# server.\n\nbackend default {\n\tset backend.host = \"127.0.0.1\";\n\tset backend.port = \"9673\";\n}\n\nacl purge {\n\t\"localhost\";\n\t\"192.0.2.0\"\/24;\n}\n\nsub vcl_recv {\n\tif (req.request != \"GET\" && req.request != \"HEAD\") {\n \t# PURGE request if zope asks nicely\n \tif (req.request == \"PURGE\") {\n \t if (!client.ip ~ purge) {\n \t error 405 \"Not allowed.\";\n \t }\n \t lookup;\n \t}\n\t\tpipe;\n\t}\n\tif (req.http.Expect) {\n\t\tpipe;\n\t}\n\tif (req.http.Authenticate || req.http.Authorization) {\n\t\tpass;\n\t}\n\t# We only care about the \"__ac.*\" cookies, used for authentication\n\tif (req.http.Cookie && req.http.Cookie ~ \"__ac(|_(name|password|persistent))=\") {\n\t\tpass;\n\t}\n\tlookup;\n}\n\n# Do the PURGE thing\nsub vcl_hit {\n if (req.request == \"PURGE\") {\n set obj.ttl = 0s;\n error 200 \"Purged\";\n }\n}\nsub vcl_miss {\n if (req.request == \"PURGE\") {\n error 404 \"Not in cache\";\n }\n}\n\n# Enforce a minimum TTL, since we PURGE changed objects actively from Zope.\nsub vcl_fetch {\n if (obj.ttl < 3600s) {\n set obj.ttl = 3600s;\n }\n}\n\n# Below is a commented-out copy of the default VCL logic. If you\n# redefine any of these subroutines, the built-in logic will be\n# appended to your code.\n\n## Called when a client request is received\n#\n#sub vcl_recv {\n#\tif (req.request != \"GET\" && req.request != \"HEAD\") {\n#\t\tpipe;\n#\t}\n#\tif (req.http.Expect) {\n#\t\tpipe;\n#\t}\n#\tif (req.http.Authenticate || req.http.Cookie) {\n#\t\tpass;\n#\t}\n#\tlookup;\n#}\n#\n## Called when entering pipe mode\n#\n#sub vcl_pipe {\n#\tpipe;\n#}\n#\n## Called when entering pass mode\n#\n#sub vcl_pass {\n#\tpass;\n#}\n#\n## Called when entering an object into the cache\n#\n#sub vcl_hash {\n#\thash;\n#}\n#\n## Called when the requested object was found in the cache\n#\n#sub vcl_hit {\n#\tif (!obj.cacheable) {\n#\t\tpass;\n#\t}\n#\tdeliver;\n#}\n#\n## Called when the requested object was not found in the cache\n#\n#sub vcl_miss {\n#\tfetch;\n#}\n#\n## Called when the requested object has been retrieved from the\n## backend, or the request to the backend has failed\n#\n#sub vcl_fetch {\n#\tif (!obj.valid) {\n#\t\terror;\n#\t}\n#\tif (!obj.cacheable) {\n#\t\tpass;\n#\t}\n#\tif (resp.http.Set-Cookie) {\n#\t\tpass;\n#\t}\n#\tinsert;\n#}\n#\n## Called when an object nears its expiry time\n#\n#sub vcl_timeout {\n#\tdiscard;\n#}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"c1f857e2187c3734e49b53709a2b3344a3e2e4bf","subject":"Revert c79f16a..5ff1ccc","message":"Revert c79f16a..5ff1ccc\n\nThis rolls back to commit c79f16ac55170b1cc95a7e62259406f4f1aa6424.\n","repos":"derbyjs\/candygram","old_file":"varnish_default.vcl","new_file":"varnish_default.vcl","new_contents":"# This is a basic VCL configuration file for varnish. See the vcl(7)\n# man page for details on VCL syntax and semantics.\n\nimport std;\n\n# static\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"4000\";\n}\nbackend examples {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\nbackend components {\n .host = \"127.0.0.1\";\n .port = \"3330\";\n}\n\nsub vcl_recv {\n if (!req.http.Host) {\n error 404 \"Need a host header\";\n }\n\n set req.http.Host = regsub(req.http.Host, \"^www\\.\", \"\");\n set req.http.Host = regsub(req.http.Host, \":80$\", \"\");\n\n if (req.restarts == 0) {\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For =\n req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n if (\n req.http.Host ~ \"^chat\\.\" ||\n req.http.Host ~ \"^charts\\.\" ||\n req.http.Host ~ \"^directory\\.\" ||\n req.http.Host ~ \"^codemirror\\.\" ||\n req.http.Host ~ \"^hello\\.\" ||\n req.http.Host ~ \"^sink\\.\" ||\n req.http.Host ~ \"^todos\\.\" ||\n req.http.Host ~ \"^widgets\\.\"\n ) {\n set req.backend = examples;\n } else if (req.http.Host ~ \"^components\\.\") {\n set req.backend = components;\n }\n\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization || req.http.Cookie) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n return (lookup);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n if (req.http.Origin) {\n hash_data(req.http.Origin);\n }\n return (hash);\n}\n\nsub vcl_pipe {\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n set bereq.http.connection = \"close\";\n # here. It is not set by default as it might break some broken web\n # applications, like IIS with NTLM authentication.\n\n # Websockets\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n\n return (pipe);\n}\n\nsub vcl_fetch {\n # Compress responses\n if (beresp.http.content-type ~ \"text\"\n || beresp.http.content-type ~ \"json\"\n || beresp.http.content-type ~ \"javascript\") {\n set beresp.do_gzip = true;\n }\n}\n\nsub vcl_error {\n if (obj.status == 750) {\n # moved permanently\n set obj.http.Location = req.http.Location;\n set obj.status = 301;\n } else if (obj.status == 752) {\n # moved temporarily\n set obj.http.Location = req.http.Location;\n set obj.status = 302;\n } else {\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic std.fileread(\"\/etc\/varnish\/503.html\");\n }\n return (deliver);\n}\n","old_contents":"# This is a basic VCL configuration file for varnish. See the vcl(7)\n# man page for details on VCL syntax and semantics.\n\nimport std;\n\n# static\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"4000\";\n}\nbackend examples {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\nbackend components {\n .host = \"127.0.0.1\";\n .port = \"3330\";\n}\n\nsub vcl_recv {\n if (!req.http.Host) {\n error 404 \"Need a host header\";\n }\n\n set req.http.Host = regsub(req.http.Host, \"^www\\.\", \"\");\n set req.http.Host = regsub(req.http.Host, \":80$\", \"\");\n\n if (\n req.http.Host ~ \"^chat\\.\" ||\n req.http.Host ~ \"^charts\\.\" ||\n req.http.Host ~ \"^directory\\.\" ||\n req.http.Host ~ \"^codemirror\\.\" ||\n req.http.Host ~ \"^hello\\.\" ||\n req.http.Host ~ \"^sink\\.\" ||\n req.http.Host ~ \"^todos\\.\" ||\n req.http.Host ~ \"^widgets\\.\"\n ) {\n set req.backend = examples;\n } else if (req.http.Host ~ \"^components\\.\") {\n set req.backend = components;\n }\n\n if (req.http.upgrade ~ \"(?i)websocket\" || req.url ~ \"^\/channel\") {\n return (pipe);\n }\n\n if (req.restarts == 0) {\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For =\n req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization || req.http.Cookie) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n return (lookup);\n}\n\nsub vcl_pipe {\n # Websockets\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n return (pipe);\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"fe2375745b6c81f6ea063b3a7bf56ad44ed47906","subject":"Remove Set-Cookie on all cached objects, not just text","message":"Remove Set-Cookie on all cached objects, not just text\n","repos":"fastly\/fastly-magento,fastly\/fastly-magento,fastly\/fastly-magento,fastly\/fastly-magento","old_file":"app\/code\/community\/Fastly\/CDN\/etc\/vcl_snippets\/fetch.vcl","new_file":"app\/code\/community\/Fastly\/CDN\/etc\/vcl_snippets\/fetch.vcl","new_contents":" if (beresp.status >= 500 && beresp.status < 600) {\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n \/* deliver stale if the object is available *\/\n if (stale.exists) {\n return(deliver_stale);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n \/* else go to vcl_error to deliver a synthetic *\/\n error beresp.status beresp.response;\n\n }\n\n if (beresp.http.X-Esi || beresp.http.Content-Type ~ \"^text\/(html|xml)\") {\n # enable ESI feature for Magento response by default\n esi;\n if (!beresp.http.Vary ~ \"Fastly-Cdn-Env,Https\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \",Fastly-Cdn-Env,Https\";\n } else {\n set beresp.http.Vary = \"Fastly-Cdn-Env,Https\";\n }\n }\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content\n if (http_status_matches(beresp.status, \"200,404\") && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url.ext ~ \"(?i)(css|js|html|eot|ico|otf|ttf|json)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # Force any responses with private, no-cache or no-store in Cache-Control to pass\n if (beresp.http.Cache-Control ~ \"private|no-cache|no-store\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # Just in case the Request Setting for x-pass is missing\n if (req.http.x-pass) {\n return (pass);\n }\n\n # Varnish sets default TTL if none of these are present\n if (!beresp.http.Expires && !beresp.http.Surrogate-Control ~ \"max-age\" && !beresp.http.Cache-Control ~ \"(s-maxage|max-age)\") {\n set beresp.ttl = 0s;\n }\n\n # If origin provides TTL for an object we cache it\n if ( beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\") && !req.http.x-pass ) {\n # Don't cache cookies - this is here because Magento sets cookies even for anonymous users\n # which busts cache\n unset beresp.http.set-cookie;\n\n if (beresp.http.Content-Type ~ \"^text\/(html|xml)\") {\n # marker for vcl_deliver to reset Age:\n set beresp.http.magentomarker = \"1\";\n\n # init surrogate keys\n if (beresp.http.Surrogate-Key) {\n set beresp.http.Surrogate-Key = beresp.http.Surrogate-Key \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n } else if (beresp.http.Content-Type ~ \"(image|script|css)\") {\n # set surrogate keys by content type if they are image\/script or CSS\n if (beresp.http.Surrogate-Key) {\n set beresp.http.Surrogate-Key = beresp.http.Surrogate-Key \" \" re.group.1;\n } else {\n set beresp.http.Surrogate-Key = re.group.1;\n }\n }\n }\n","old_contents":" if (beresp.status >= 500 && beresp.status < 600) {\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n \/* deliver stale if the object is available *\/\n if (stale.exists) {\n return(deliver_stale);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n \/* else go to vcl_error to deliver a synthetic *\/\n error beresp.status beresp.response;\n\n }\n\n if (beresp.http.X-Esi || beresp.http.Content-Type ~ \"^text\/(html|xml)\") {\n # enable ESI feature for Magento response by default\n esi;\n if (!beresp.http.Vary ~ \"Fastly-Cdn-Env,Https\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \",Fastly-Cdn-Env,Https\";\n } else {\n set beresp.http.Vary = \"Fastly-Cdn-Env,Https\";\n }\n }\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content\n if (http_status_matches(beresp.status, \"200,404\") && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url.ext ~ \"(?i)(css|js|html|eot|ico|otf|ttf|json)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # Force any responses with private, no-cache or no-store in Cache-Control to pass\n if (beresp.http.Cache-Control ~ \"private|no-cache|no-store\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # Just in case the Request Setting for x-pass is missing\n if (req.http.x-pass) {\n return (pass);\n }\n\n # Varnish sets default TTL if none of these are present\n if (!beresp.http.Expires && !beresp.http.Surrogate-Control ~ \"max-age\" && !beresp.http.Cache-Control ~ \"(s-maxage|max-age)\") {\n set beresp.ttl = 0s;\n }\n\n # If origin provides TTL for an object we cache it\n if ( beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\") && !req.http.x-pass ) {\n if (beresp.http.Content-Type ~ \"^text\/(html|xml)\") {\n # marker for vcl_deliver to reset Age:\n set beresp.http.magentomarker = \"1\";\n\n # Don't cache cookies - this is here because Magento sets cookies even for anonymous users\n # which busts cache\n unset beresp.http.set-cookie;\n\n # init surrogate keys\n if (beresp.http.Surrogate-Key) {\n set beresp.http.Surrogate-Key = beresp.http.Surrogate-Key \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n } else if (beresp.http.Content-Type ~ \"(image|script|css)\") {\n # set surrogate keys by content type if they are image\/script or CSS\n if (beresp.http.Surrogate-Key) {\n set beresp.http.Surrogate-Key = beresp.http.Surrogate-Key \" \" re.group.1;\n } else {\n set beresp.http.Surrogate-Key = re.group.1;\n }\n }\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"6bf9178f6e46ddcc2cba33e1a54d8b506f66688f","subject":"Fix varnish invalidators config","message":"Fix varnish invalidators config\n","repos":"api-platform\/demo,api-platform\/demo,api-platform\/demo,api-platform\/demo","old_file":"api\/docker\/varnish\/conf\/default.vcl","new_file":"api\/docker\/varnish\/conf\/default.vcl","new_contents":"vcl 4.0;\n\nimport std;\n\nbackend default {\n .host = \"api\";\n .port = \"80\";\n # Health check\n #.probe = {\n # .url = \"\/\";\n # .timeout = 5s;\n # .interval = 10s;\n # .window = 5;\n # .threshold = 3;\n #}\n}\n\n# Hosts allowed to send BAN requests\nacl invalidators {\n \"localhost\";\n \"php\";\n # local Kubernetes network\n \"10.0.0.0\"\/8;\n \"172.16.0.0\"\/12;\n \"192.168.0.0\"\/16;\n}\n\nsub vcl_backend_response {\n # Ban lurker friendly header\n set beresp.http.url = bereq.url;\n\n # Add a grace in case the backend is down\n set beresp.grace = 1h;\n}\n\nsub vcl_deliver {\n # Don't send cache tags related headers to the client\n unset resp.http.url;\n # Uncomment the following line to NOT send the \"Cache-Tags\" header to the client (prevent using CloudFlare cache tags)\n #unset resp.http.Cache-Tags;\n}\n\nsub vcl_recv {\n # Remove the \"Forwarded\" HTTP header if exists (security)\n unset req.http.forwarded;\n\n # To allow API Platform to ban by cache tags\n if (req.method == \"BAN\") {\n if (client.ip !~ invalidators) {\n return(synth(405, \"Not allowed\"));\n }\n\n if (req.http.ApiPlatform-Ban-Regex) {\n ban(\"obj.http.Cache-Tags ~ \" + req.http.ApiPlatform-Ban-Regex);\n\n return(synth(200, \"Ban added\"));\n }\n\n return(synth(400, \"ApiPlatform-Ban-Regex HTTP header must be set.\"));\n }\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n # A pure unadulterated hit, deliver it\n return (deliver);\n }\n if (std.healthy(req.backend_hint)) {\n # The backend is healthy\n # Fetch the object from the backend\n return (miss);\n }\n # No fresh object and the backend is not healthy\n if (obj.ttl + obj.grace > 0s) {\n # Deliver graced object\n # Automatically triggers a background fetch\n return (deliver);\n }\n # No valid object to deliver\n # No healthy backend to handle request\n # Return error\n return (synth(503, \"API is down\"));\n}\n","old_contents":"vcl 4.0;\n\nimport std;\n\nbackend default {\n .host = \"api\";\n .port = \"80\";\n # Health check\n #.probe = {\n # .url = \"\/\";\n # .timeout = 5s;\n # .interval = 10s;\n # .window = 5;\n # .threshold = 3;\n #}\n}\n\n# Hosts allowed to send BAN requests\nacl invalidators {\n \"localhost\";\n \"php\";\n}\n\nsub vcl_backend_response {\n # Ban lurker friendly header\n set beresp.http.url = bereq.url;\n\n # Add a grace in case the backend is down\n set beresp.grace = 1h;\n}\n\nsub vcl_deliver {\n # Don't send cache tags related headers to the client\n unset resp.http.url;\n # Uncomment the following line to NOT send the \"Cache-Tags\" header to the client (prevent using CloudFlare cache tags)\n #unset resp.http.Cache-Tags;\n}\n\nsub vcl_recv {\n # Remove the \"Forwarded\" HTTP header if exists (security)\n unset req.http.forwarded;\n\n # To allow API Platform to ban by cache tags\n if (req.method == \"BAN\") {\n if (client.ip !~ invalidators) {\n return(synth(405, \"Not allowed\"));\n }\n\n if (req.http.ApiPlatform-Ban-Regex) {\n ban(\"obj.http.Cache-Tags ~ \" + req.http.ApiPlatform-Ban-Regex);\n\n return(synth(200, \"Ban added\"));\n }\n\n return(synth(400, \"ApiPlatform-Ban-Regex HTTP header must be set.\"));\n }\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n # A pure unadulterated hit, deliver it\n return (deliver);\n }\n if (std.healthy(req.backend_hint)) {\n # The backend is healthy\n # Fetch the object from the backend\n return (miss);\n }\n # No fresh object and the backend is not healthy\n if (obj.ttl + obj.grace > 0s) {\n # Deliver graced object\n # Automatically triggers a background fetch\n return (deliver);\n }\n # No valid object to deliver\n # No healthy backend to handle request\n # Return error\n return (synth(503, \"API is down\"));\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"9627e2d9375ec26449a0188f7f7db0617f1ffbba","subject":"cleanup + fix regex so it workish. fails miserably if the clients send an empty override cookie, but enough is enough","message":"cleanup + fix regex so it workish. fails miserably if the clients send an empty override cookie, but enough is enough\n","repos":"kevinquinnyo\/varnish-devicedetect,varnish\/varnish-devicedetect,wikp\/varnish-devicedetect,varnish\/varnish-devicedetect,wikp\/varnish-devicedetect,kevinquinnyo\/varnish-devicedetect","old_file":"devicedetect.vcl","new_file":"devicedetect.vcl","new_contents":"#\n# detectdevice.vcl - regex based device detection for Varnish\n# http:\/\/github.com\/lkarsten\/varnish-devicedetect\/\n#\n# Author: Lasse Karstensen <lasse@varnish-software.com>\n\nsub devicedetect {\n unset req.http.X-hash-input;\n unset req.http.X-UA-Device;\n set req.http.X-UA-Device = \"pc\";\n\n if (req.http.User-Agent ~ \"(?i)ip(hone|od)\") { set req.http.X-UA-Device = \"mobile-iphone\"; }\n elsif (req.http.User-Agent ~ \"(?i)ipad\") { set req.http.X-UA-Device = \"tablet-ipad\"; }\n # how do we differ between an android phone and an android tablet?\n # http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent\n elsif (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") { set req.http.X-UA-Device = \"mobile-android\"; } \n # may very well give false positives towards android tablets. Suggestions welcome.\n elsif (req.http.User-Agent ~ \"(?i)android\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\n elsif (req.http.User-Agent ~ \"^HTC\" ||\n req.http.User-Agent ~ \"Fennec\" || \n req.http.User-Agent ~ \"IEMobile\" ||\n req.http.User-Agent ~ \"BlackBerry\" ||\n req.http.User-Agent ~ \"SymbianOS.*AppleWebKit\" ||\n req.http.User-Agent ~ \"Opera Mobi\") {\n set req.http.X-VG-Device = \"mobile-smartphone\";\n }\n elsif (req.http.User-Agent ~ \"(?i)symbian\" ||\n req.http.User-Agent ~ \"(?i)^sonyericsson\" ||\n req.http.User-Agent ~ \"(?i)^nokia\" ||\n req.http.User-Agent ~ \"(?i)^samsung\" ||\n req.http.User-Agent ~ \"(?i)^lg\" ||\n\treq.http.User-Agent ~ \"(?i)bada\" ||\n\treq.http.User-Agent ~ \"(?i)blazer\" ||\n\treq.http.User-Agent ~ \"(?i)cellphone\" ||\n\treq.http.User-Agent ~ \"(?i)iemobile\" ||\n\treq.http.User-Agent ~ \"(?i)midp-2.0\" ||\n\treq.http.User-Agent ~ \"(?i)u990\" ||\n\treq.http.User-Agent ~ \"(?i)netfront\" ||\n\treq.http.User-Agent ~ \"(?i)opera mini\" ||\n\treq.http.User-Agent ~ \"(?i)palm\" ||\n\treq.http.User-Agent ~ \"(?i)nintendo wii\" ||\n\treq.http.User-Agent ~ \"(?i)playstation portable\" ||\n\treq.http.User-Agent ~ \"(?i)portalmmm\" ||\n\treq.http.User-Agent ~ \"(?i)proxinet\" ||\n\treq.http.User-Agent ~ \"(?i)sonyericsson\" ||\n\treq.http.User-Agent ~ \"(?i)symbian\" ||\n\treq.http.User-Agent ~ \"(?i)windows\\ ?ce\" ||\n\treq.http.User-Agent ~ \"(?i)winwap\" ||\n\treq.http.User-Agent ~ \"(?i)eudoraweb\" ||\n\treq.http.User-Agent ~ \"(?i)htc\" ||\n\treq.http.User-Agent ~ \"(?i)240x320\" ||\n\treq.http.User-Agent ~ \"(?i)avantgo\") { \n set req.http.X-UA-Device = \"mobile-generic\";\n }\n\n # handle overrides\n if (req.http.Cookie ~ \"(i?)X-UA-Device-force\") {\n # ;?? means zero or one ;, non-greedy to match the first.\n set req.http.X-UA-Device = regsub(req.http.Cookie, \"(?i).*X-UA-Device-force=([^;]+);??.*\", \"\\1\");\n }\n set req.http.X-hash-input = req.http.X-UA-Device;\n}\n\n# vim: sw=4:tw=120 # meh\n","old_contents":"#\n# detectdevice.vcl - regex based device detection for Varnish\n# http:\/\/github.com\/lkarsten\/varnish-devicedetect\/\n#\n# Author: Lasse Karstensen <lasse@varnish-software.com>\n\nsub devicedetect {\n unset req.http.X-hash-input;\n set req.http.X-UA-Device = \"pc\";\n\n if (req.http.User-Agent ~ \"(?i)ip(hone|od)\") { set req.http.X-UA-Device = \"mobile-iphone\"; }\n elsif (req.http.User-Agent ~ \"(?i)ipad\") { set req.http.X-UA-Device = \"tablet-ipad\"; }\n # how do we differ between an android phone and an android tablet?\n # http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent\n elsif (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") { set req.http.X-UA-Device = \"mobile-android\"; } \n # may very well give false positives towards android tablets. Suggestions welcome.\n elsif (req.http.User-Agent ~ \"(?i)android\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\n elsif (req.http.User-Agent ~ \"^HTC\" ||\n req.http.User-Agent ~ \"Fennec\" || \n req.http.User-Agent ~ \"IEMobile\" ||\n req.http.User-Agent ~ \"BlackBerry\" ||\n req.http.User-Agent ~ \"SymbianOS.*AppleWebKit\" ||\n req.http.User-Agent ~ \"Opera Mobi\") {\n set req.http.X-VG-Device = \"mobile-smartphone\";\n }\n elsif (req.http.User-Agent ~ \"(?i)symbian\" ||\n req.http.User-Agent ~ \"(?i)^sonyericsson\" ||\n req.http.User-Agent ~ \"(?i)^nokia\" ||\n req.http.User-Agent ~ \"(?i)^samsung\" ||\n req.http.User-Agent ~ \"(?i)^lg\" ||\n\treq.http.User-Agent ~ \"(?i)bada\" ||\n\treq.http.User-Agent ~ \"(?i)blazer\" ||\n\treq.http.User-Agent ~ \"(?i)cellphone\" ||\n\treq.http.User-Agent ~ \"(?i)iemobile\" ||\n\treq.http.User-Agent ~ \"(?i)midp-2.0\" ||\n\treq.http.User-Agent ~ \"(?i)u990\" ||\n\treq.http.User-Agent ~ \"(?i)netfront\" ||\n\treq.http.User-Agent ~ \"(?i)opera mini\" ||\n\treq.http.User-Agent ~ \"(?i)palm\" ||\n\treq.http.User-Agent ~ \"(?i)nintendo wii\" ||\n\treq.http.User-Agent ~ \"(?i)playstation portable\" ||\n\treq.http.User-Agent ~ \"(?i)portalmmm\" ||\n\treq.http.User-Agent ~ \"(?i)proxinet\" ||\n\treq.http.User-Agent ~ \"(?i)sonyericsson\" ||\n\treq.http.User-Agent ~ \"(?i)symbian\" ||\n\treq.http.User-Agent ~ \"(?i)windows\\ ?ce\" ||\n\treq.http.User-Agent ~ \"(?i)winwap\" ||\n\treq.http.User-Agent ~ \"(?i)eudoraweb\" ||\n\treq.http.User-Agent ~ \"(?i)htc\" ||\n\treq.http.User-Agent ~ \"(?i)240x320\" ||\n\treq.http.User-Agent ~ \"(?i)avantgo\") { \n set req.http.X-UA-Device = \"mobile-generic\";\n }\n\n # handle overrides\n if (req.http.Cookie ~ \"X-force-UA\") {\n set req.http.X-UA-Device = regsub(req.http.Cookie, \"X-force-UA=(.+);\", \"\\1\");\n }\n #(req.http.Cookie ~ \"X-force-UA=mobile-generic\") set req.http.X-UA-Device = \"mobile-generic\";\n #if (req.url ~ \"force-ua-device=mobile-android$\") { set req.http.X-UA-Device = \"mobile-android\"; }\n #elsif (req.url ~ \"force-ua-device=mobile-ipad$\") { set req.http.X-UA-Device = \"mobile-ipad\"; }\n #elsif (req.url ~ \"force-ua-device=mobile-iphone$\") { set req.http.X-UA-Device = \"mobile-iphone\"; }\n #elsif (req.url ~ \"force-ua-device=mobile-generic$\") { set req.http.X-UA-Device = \"mobile-generic\"; }\n #elsif (req.url ~ \"force-ua-device=pc-forced$\") { set req.http.X-UA-Device = \"pc-forced\"; }\n\n # XXX: why?\n #if (req.http.X-UA-Device != \"pc\" && req.http.X-UA-Device != \"pc-forced\") {\n set req.http.X-hash-input = req.http.X-UA-Device;\n #}\n}\n\n# vim: sw=4:tw=120 # meh\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"641c30281dc9c53c0a683d317614c866862e0785","subject":"vanish cache user esi based on cookie","message":"vanish cache user esi based on cookie\n","repos":"KhanovaSkola\/khanovaskola-v3,KhanovaSkola\/khanovaskola-v3,KhanovaSkola\/khanovaskola-v3,KhanovaSkola\/khanovaskola-v3,KhanovaSkola\/khanovaskola-v3,KhanovaSkola\/khanovaskola-v3","old_file":"production\/varnish.vcl","new_file":"production\/varnish.vcl","new_contents":"vcl 4.0;\n\n# Disable esi xml check on varnish Startup\n# Example:\n# DAEMON_OPTS=\"-a :6081 \\\n# -T localhost:6082 \\\n# -p feature=+esi_disable_xml_check\n# -p feature=+esi_ignore_https\n#\n\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8085\";\n}\n\nimport std;\n\nsub vcl_recv {\n if (req.method != \"GET\")\n {\n return (pass);\n }\n if (req.http.Cookie ~ \"\\bvarnish-force=pass\")\n {\n return (pass);\n }\n\n if (req.url ~ \"\/esi\/header\")\n {\n set req.http.Cookie = \";\" + req.http.Cookie;\n set req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n set req.http.Cookie = regsuball(req.http.Cookie, \";(PHPSESSID)=\", \"; \\1=\");\n set req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n if (req.http.Cookie == \"\")\n {\n unset req.http.Cookie;\n }\n }\n\n return (hash);\n}\n\nsub vcl_hash {\n hash_data(req.http.host);\n hash_data(req.url);\n if (req.url ~ \"\/esi\/header\/\")\n {\n hash_data(req.http.Cookie);\n }\n return(lookup);\n}\n\nsub vcl_backend_response {\n if (bereq.url ~ \"\/esi\/header\/\")\n {\n unset beresp.http.Pragma;\n unset beresp.http.Cache-control;\n set beresp.ttl = 30m;\n }\n else if (beresp.http.Cache-Control != \"public\")\n {\n set beresp.uncacheable = true;\n set beresp.ttl = 3m;\n return (deliver);\n }\n\n set beresp.do_esi = true;\n set beresp.ttl = std.duration(beresp.http.Varnish-TTL, 15m);\n\n unset beresp.http.Set-Cookie;\n}\n","old_contents":"vcl 4.0;\n\n# Disable esi xml check on varnish Startup\n# Example:\n# DAEMON_OPTS=\"-a :6081 \\\n# -T localhost:6082 \\\n# -p feature=+esi_disable_xml_check\n# -p feature=+esi_ignore_https\n#\n\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8085\";\n}\n\nimport std;\n\nsub vcl_recv {\n if (req.method != \"GET\") {\n return (pass);\n }\n if (req.http.Cookie ~ \"\\bvarnish-force=pass\") {\n return (pass);\n }\n\n return (hash);\n}\n\nsub vcl_hash {\n hash_data(req.http.host);\n hash_data(req.url);\n return(lookup);\n}\n\nsub vcl_backend_response {\n if (beresp.http.Cache-Control != \"public\") {\n set beresp.uncacheable = true;\n set beresp.ttl = 3m;\n return (deliver);\n }\n\n set beresp.do_esi = true;\n set beresp.ttl = std.duration(beresp.http.Varnish-TTL, 15m);\n\n unset beresp.http.Set-Cookie;\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"e51b6b5fcaa3cb4e15e9b8532311930cdb3f3e11","subject":"Exclude \/rest and \/oauth from basic auth","message":"Exclude \/rest and \/oauth from basic auth\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets_basic_auth\/recv.vcl","new_file":"etc\/vcl_snippets_basic_auth\/recv.vcl","new_contents":" # Check Basic auth against a table. \/admin URLs are not basic auth protected to avoid the possibility of people\n # locking themselves out. \/oauth and \/rest have their own auth so we can skip Basic Auth on them as well\n if ( table.lookup(magentomodule_basic_auth, regsub(req.http.Authorization, \"^Basic \", \"\"), \"NOTFOUND\") == \"NOTFOUND\" &&\n !req.url ~ \"^\/(index\\.php\/)?admin(_.*)?\/\" &&\n !req.url ~ \"^\/(index\\.php\/)?(rest|oauth)\/\" &&\n !req.url ~ \"^\/pub\/static\/\" ) {\n error 971;\n }\n","old_contents":" # Check Basic auth against a table. \/admin URLs are not basic auth protected to avoid the possibility of people\n # locking themselves out\n if ( table.lookup(magentomodule_basic_auth, regsub(req.http.Authorization, \"^Basic \", \"\"), \"NOTFOUND\") == \"NOTFOUND\" &&\n !req.url ~ \"^\/(index\\.php\/)?admin(_.*)?\/\" &&\n !req.url ~ \"^\/pub\/static\/\" ) {\n error 971;\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"c4a85eada332dbfb6867d8ec1c80b57f04d6c960","subject":"fix redirects","message":"fix redirects\n","repos":"JakeChampion\/polyfill-service,JakeChampion\/polyfill-service","old_file":"fastly\/vcl\/redirects.vcl","new_file":"fastly\/vcl\/redirects.vcl","new_contents":"sub vcl_recv {\n\tif (req.http.Host ~ \"polyfills.io\") {\n\t\t# Fastly recommend using the 900-999 range of status codes for custom errors within an application's VCL.\n\t\t# Do the canonicalise check before the HTTPS check to avoid a double redirect\n\t\terror 901 \"Canonicalise\";\n\t}\n\tif (!req.http.Fastly-SSL) {\n\t\t# 801 is a special error code that Fastly uses to Force HTTPS on the request\n\t\terror 801 \"Redirect to HTTPS\";\n\t}\n\tif (req.http.Orig-URL ~ \"^\/v1\") {\n\t\terror 902 \"Redirect to V2\";\n\t}\n\n\tif (req.url.path == \"\/\" || req.url.path == \"\/v2\" || req.url.path == \"\/v2\/docs\/\") {\n\t\terror 908;\n\t}\n}\n\nsub vcl_error {\n # Redirect to canonical prod\/qa origins\n\tif (obj.status == 901) {\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\tset obj.http.Location = \"https:\/\/polyfill.io\" req.url;\n\t\tsynthetic {\"\"};\n\t\treturn (deliver);\n\t}\n\t# Redirect to v2\n\tif (obj.status == 902) {\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\t# Remove libVersion and gated query parameters if they exist.\n\t\tset req.url = querystring.regfilter(req.url, \"^\\b(libVersion|gated)\\b.*\");\n\t\tset obj.http.Location = if(req.url.path == \"\/v1\", \"\/v3\/\", regsub(req.url, \"^\/v1\", \"\/v2\"));\n\t\tset obj.http.Deprecation-Notice = \"API version 1 has been decommissioned - see the body of this response for more information.\";\n\t\tsynthetic {\"API version 1 has been decommissioned. Your request is being redirected to v2. The `libVersion` and `gated` query string parameters are no longer supported and if present have been removed from your request.\\n\\nA deprecation period for v1 existed between August and December 2015, during which time v1 requests were honoured but a deprecation warning was added to output.\"};\n\t\treturn (deliver);\n\t}\n\n\t# Redirect to v3\n\tif (obj.status == 908) {\n\t\tset obj.status = 301;\n\t\tset obj.http.Location = \"\/v3\/\";\n\t\treturn (deliver);\n\t}\n}\n","old_contents":"sub vcl_recv {\n\tif (req.http.Host ~ \"polyfills.io\") {\n\t\t# Fastly recommend using the 900-999 range of status codes for custom errors within an application's VCL.\n\t\t# Do the canonicalise check before the HTTPS check to avoid a double redirect\n\t\terror 901 \"Canonicalise\";\n\t}\n\tif (!req.http.Fastly-SSL) {\n\t\t# 801 is a special error code that Fastly uses to Force HTTPS on the request\n\t\terror 801 \"Redirect to HTTPS\";\n\t}\n\tif (req.http.Orig-URL ~ \"^\/v1\") {\n\t\terror 902 \"Redirect to V2\";\n\t}\n\n\tif (req.url.path == \"\/\" || req.url.path == \"\/v2\") {\n\t\terror 908;\n\t}\n}\n\nsub vcl_error {\n # Redirect to canonical prod\/qa origins\n\tif (obj.status == 901) {\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\tset obj.http.Location = \"https:\/\/polyfill.io\" req.url;\n\t\tsynthetic {\"\"};\n\t\treturn (deliver);\n\t}\n\t# Redirect to v2\n\tif (obj.status == 902) {\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\t# Remove libVersion and gated query parameters if they exist.\n\t\tset req.url = querystring.regfilter(req.url, \"^\\b(libVersion|gated)\\b.*\");\n\t\tset obj.http.Location = if(req.url.path == \"\/v1\", \"\/v3\/\", regsub(req.url, \"^\/v1\", \"\/v2\"));\n\t\tset obj.http.Deprecation-Notice = \"API version 1 has been decommissioned - see the body of this response for more information.\";\n\t\tsynthetic {\"API version 1 has been decommissioned. Your request is being redirected to v2. The `libVersion` and `gated` query string parameters are no longer supported and if present have been removed from your request.\\n\\nA deprecation period for v1 existed between August and December 2015, during which time v1 requests were honoured but a deprecation warning was added to output.\"};\n\t\treturn (deliver);\n\t}\n\n\t# Redirect to v3\n\tif (obj.status == 908) {\n\t\tset obj.status = 301;\n\t\tset obj.http.Location = \"\/v3\/\";\n\t\treturn (deliver);\n\t}\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"8ec4ae01a03efa44ccd9a3cb39c201ed76450f8e","subject":"Remove message\/compose blacklist.","message":"Remove message\/compose blacklist.\n","repos":"ajacksified\/reddit-mobile,ajacksified\/reddit-mobile,ajacksified\/reddit-mobile,ajacksified\/reddit-mobile","old_file":"default.vcl","new_file":"default.vcl","new_contents":"backend mweb {\n .host = \"mweb\";\n .port = \"4444\";\n}\n\/* backend www {\n .host = \"www.reddit.com\";\n .port = \"80\";\n} *\/\n\n\nsub vcl_recv {\n call device_detect;\n\n # Check mweb override cookie.\n if (req.http.Cookie ~ \"(^|;\\s*)(mweb-no-redirect=1)(;|$)\") {\n call set_www_backend;\n } elsif (\n (req.http.X-UA-Device ~ \"^mobile-\" || req.http.X-UA-Device ~ \"^tablet-\")\n # We don't host endpoints with extensions in mweb.\n # The Fastly equivalent is: && !req.url.ext\n && !reg.url ~ \"\\\/.+\\.[a-z]{3,4}(\\?.*|$)\"\n && (\n # Whitelisted 2X endpoints from router\/index.js\n req.url == \"\/\"\n || req.url ~ \"^\/actions\/\"\n || req.url ~ \"^\/comments\/?\"\n || req.url ~ \"^\/login\/?$\"\n || req.url ~ \"^\/message\/\"\n || req.url ~ \"^\/r\/\"\n || req.url ~ \"^\/register\/?$\"\n || req.url ~ \"^\/search\/?$\"\n || req.url ~ \"^\/submit\/?$\"\n || req.url ~ \"^\/submit_to_community\/?$\"\n || req.url ~ \"^\/u\/\"\n || req.url ~ \"^\/user\/\"\n || req.url ~ \"^\/(help|w|wiki)\/?\"\n # Whitelisted 2X Ajax endpoints\n || req.url ~ \"^\/csp-report$\"\n || req.url == \"\/error\"\n || req.url ~ \"^\/(login|refresh|register)proxy$\"\n || req.url ~ \"^\/logout\"\n || req.url == \"\/routes\"\n || req.url ~ \"^\/timings$\"\n || req.url ~ \"^\/(u\/)?XXX\\?.*\"\n # Whitelisted dev endpoints (these will be hosted on www in production)\n || req.url == \"\/apple-app-site-association\"\n || req.url ~ \"^\/favicon\/\"\n || req.url ~ \"^\/favicon\\.ico\"\n || req.url ~ \"^\/fonts\/\"\n || req.url == \"\/health\"\n || req.url ~ \"^\/img\/\"\n || req.url ~ \"^\/ProductionClient\\..*\\.(css|js)$\"\n || req.url == \"\/robots.txt\"\n )) {\n # If it's a mobile device and a whitelisted endpoint, use mweb.\n set req.backend = mweb;\n } else {\n call set_www_backend;\n }\n}\n\n\nsub set_www_backend {\n # NOTE(wting|2016-09-26): Normally we would redirect the user to a different\n # backend, but instead we're using a 400 status code for easy programmatic testing.\n error 400;\n # set req.backend = www;\n}\n\n\n# Vendorized from https:\/\/github.com\/varnish\/varnish-devicedetect\/blob\/master\/devicedetect.vcl\n# BSD-2 License\nsub device_detect {\n unset req.http.X-UA-Device;\n set req.http.X-UA-Device = \"pc\";\n\n # Handle that a cookie may override the detection alltogether.\n if (req.http.Cookie ~ \"(?i)X-UA-Device-force\") {\n \/* ;?? means zero or one ;, non-greedy to match the first. *\/\n set req.http.X-UA-Device = regsub(req.http.Cookie, \"(?i).*X-UA-Device-force=([^;]+);??.*\", \"\\1\");\n \/* Clean up our mess in the cookie header *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \"(^|; ) *X-UA-Device-force=[^;]+;? *\", \"\\1\");\n \/* If the cookie header is now empty, or just whitespace, unset it. *\/\n if (req.http.Cookie ~ \"^ *$\") {\n unset req.http.Cookie;\n }\n } else {\n if (req.http.User-Agent ~ \"\\(compatible; Googlebot-Mobile\/2.1; \\+http:\/\/www.google.com\/bot.html\\)\"\n || (req.http.User-Agent ~ \"(Android|iPhone)\"\n && req.http.User-Agent ~ \"\\(compatible.?; Googlebot\/2.1.?; \\+http:\/\/www.google.com\/bot.html\")\n || (req.http.User-Agent ~ \"(iPhone|Windows Phone)\"\n && req.http.User-Agent ~ \"\\(compatible; bingbot\/2.0; \\+http:\/\/www.bing.com\/bingbot.htm\")\n ) {\n set req.http.X-UA-Device = \"mobile-bot\";\n } elsif (req.http.User-Agent ~ \"(?i)(ads|google|bing|msn|yandex|baidu|ro|career|seznam|)bot\"\n || req.http.User-Agent ~ \"(?i)(baidu|jike|symantec)spider\"\n || req.http.User-Agent ~ \"(?i)scanner\"\n || req.http.User-Agent ~ \"(?i)(web)crawler\"\n ) {\n set req.http.X-UA-Device = \"bot\";\n } elsif (req.http.User-Agent ~ \"(?i)ipad\") {\n set req.http.X-UA-Device = \"tablet-ipad\";\n } elsif (req.http.User-Agent ~ \"(?i)ip(hone|od)\") {\n set req.http.X-UA-Device = \"mobile-iphone\";\n } elsif (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") {\n \/* how do we differ between an android phone and an android tablet? *\/\n \/* http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent *\/\n set req.http.X-UA-Device = \"mobile-android\";\n }\n elsif (req.http.User-Agent ~ \"(?i)android 3\") {\n \/* https:\/\/github.com\/varnish\/varnish-devicedetect\/blob\/master\/devicedetect.vcl *\/\n set req.http.X-UA-Device = \"tablet-android\";\n } elsif (req.http.User-Agent ~ \"Opera Mobi\") {\n \/* Opera Mobile *\/\n set req.http.X-UA-Device = \"mobile-smartphone\";\n }\n elsif (req.http.User-Agent ~ \"(?i)android\") {\n \/* May very well give false positives towards android tablets. Suggestions welcome. *\/\n set req.http.X-UA-Device = \"tablet-android\";\n } elsif (req.http.User-Agent ~ \"PlayBook; U; RIM Tablet\") {\n set req.http.X-UA-Device = \"tablet-rim\";\n } elsif (req.http.User-Agent ~ \"hp-tablet.*TouchPad\") {\n set req.http.X-UA-Device = \"tablet-hp\";\n } elsif (req.http.User-Agent ~ \"Kindle\/3\") {\n set req.http.X-UA-Device = \"tablet-kindle\";\n } elsif (req.http.User-Agent ~ \"Touch.+Tablet PC\" || req.http.User-Agent ~ \"Windows NT [0-9.]+; ARM;\" ) {\n set req.http.X-UA-Device = \"tablet-microsoft\";\n } elsif (req.http.User-Agent ~ \"Mobile.+Firefox\") {\n set req.http.X-UA-Device = \"mobile-firefoxos\";\n } elsif (req.http.User-Agent ~ \"^HTC\"\n || req.http.User-Agent ~ \"Fennec\"\n || req.http.User-Agent ~ \"IEMobile\"\n || req.http.User-Agent ~ \"BlackBerry\"\n || req.http.User-Agent ~ \"BB10.*Mobile\"\n || req.http.User-Agent ~ \"GT-.*Build\/GINGERBREAD\"\n || req.http.User-Agent ~ \"SymbianOS.*AppleWebKit\") {\n set req.http.X-UA-Device = \"mobile-smartphone\";\n }\n elsif (req.http.User-Agent ~ \"(?i)symbian\"\n || req.http.User-Agent ~ \"(?i)^sonyericsson\"\n || req.http.User-Agent ~ \"(?i)^nokia\"\n || req.http.User-Agent ~ \"(?i)^samsung\"\n || req.http.User-Agent ~ \"(?i)^lg\"\n || req.http.User-Agent ~ \"(?i)bada\"\n || req.http.User-Agent ~ \"(?i)blazer\"\n || req.http.User-Agent ~ \"(?i)cellphone\"\n || req.http.User-Agent ~ \"(?i)iemobile\"\n || req.http.User-Agent ~ \"(?i)midp-2.0\"\n || req.http.User-Agent ~ \"(?i)u990\"\n || req.http.User-Agent ~ \"(?i)netfront\"\n || req.http.User-Agent ~ \"(?i)opera mini\"\n || req.http.User-Agent ~ \"(?i)palm\"\n || req.http.User-Agent ~ \"(?i)nintendo wii\"\n || req.http.User-Agent ~ \"(?i)playstation portable\"\n || req.http.User-Agent ~ \"(?i)portalmmm\"\n || req.http.User-Agent ~ \"(?i)proxinet\"\n || req.http.User-Agent ~ \"(?i)sonyericsson\"\n || req.http.User-Agent ~ \"(?i)symbian\"\n || req.http.User-Agent ~ \"(?i)windows\\ ?ce\"\n || req.http.User-Agent ~ \"(?i)winwap\"\n || req.http.User-Agent ~ \"(?i)eudoraweb\"\n || req.http.User-Agent ~ \"(?i)htc\"\n || req.http.User-Agent ~ \"(?i)240x320\"\n || req.http.User-Agent ~ \"(?i)avantgo\") {\n set req.http.X-UA-Device = \"mobile-generic\";\n }\n }\n}\n","old_contents":"backend mweb {\n .host = \"mweb\";\n .port = \"4444\";\n}\n\/* backend www {\n .host = \"www.reddit.com\";\n .port = \"80\";\n} *\/\n\n\nsub vcl_recv {\n call device_detect;\n\n # Check mweb override cookie.\n if (req.http.Cookie ~ \"(^|;\\s*)(mweb-no-redirect=1)(;|$)\") {\n call set_www_backend;\n } elsif (\n (req.http.X-UA-Device ~ \"^mobile-\" || req.http.X-UA-Device ~ \"^tablet-\")\n # We don't host endpoints with extensions in mweb.\n # The Fastly equivalent is: && !req.url.ext\n && !reg.url ~ \"\\\/.+\\.[a-z]{3,4}(\\?.*|$)\"\n && (\n # Blacklisted endpoints\n # This endpoint 200's for mweb, but the current implementation has issues\n req.url !~ \"^\/message\/compose\/?$\"\n )\n && (\n # Whitelisted 2X endpoints from router\/index.js\n req.url == \"\/\"\n || req.url ~ \"^\/actions\/\"\n || req.url ~ \"^\/comments\/?\"\n || req.url ~ \"^\/login\/?$\"\n || req.url ~ \"^\/message\/\"\n || req.url ~ \"^\/r\/\"\n || req.url ~ \"^\/register\/?$\"\n || req.url ~ \"^\/search\/?$\"\n || req.url ~ \"^\/submit\/?$\"\n || req.url ~ \"^\/submit_to_community\/?$\"\n || req.url ~ \"^\/u\/\"\n || req.url ~ \"^\/user\/\"\n || req.url ~ \"^\/(help|w|wiki)\/?\"\n # Whitelisted 2X Ajax endpoints\n || req.url ~ \"^\/csp-report$\"\n || req.url == \"\/error\"\n || req.url ~ \"^\/(login|refresh|register)proxy$\"\n || req.url ~ \"^\/logout\"\n || req.url == \"\/routes\"\n || req.url ~ \"^\/timings$\"\n || req.url ~ \"^\/(u\/)?XXX\\?.*\"\n # Whitelisted dev endpoints (these will be hosted on www in production)\n || req.url == \"\/apple-app-site-association\"\n || req.url ~ \"^\/favicon\/\"\n || req.url ~ \"^\/favicon\\.ico\"\n || req.url ~ \"^\/fonts\/\"\n || req.url == \"\/health\"\n || req.url ~ \"^\/img\/\"\n || req.url ~ \"^\/ProductionClient\\..*\\.(css|js)$\"\n || req.url == \"\/robots.txt\"\n )) {\n # If it's a mobile device and a whitelisted endpoint, use mweb.\n set req.backend = mweb;\n } else {\n call set_www_backend;\n }\n}\n\n\nsub set_www_backend {\n # NOTE(wting|2016-09-26): Normally we would redirect the user to a different\n # backend, but instead we're using a 400 status code for easy programmatic testing.\n error 400;\n # set req.backend = www;\n}\n\n\n# Vendorized from https:\/\/github.com\/varnish\/varnish-devicedetect\/blob\/master\/devicedetect.vcl\n# BSD-2 License\nsub device_detect {\n unset req.http.X-UA-Device;\n set req.http.X-UA-Device = \"pc\";\n\n # Handle that a cookie may override the detection alltogether.\n if (req.http.Cookie ~ \"(?i)X-UA-Device-force\") {\n \/* ;?? means zero or one ;, non-greedy to match the first. *\/\n set req.http.X-UA-Device = regsub(req.http.Cookie, \"(?i).*X-UA-Device-force=([^;]+);??.*\", \"\\1\");\n \/* Clean up our mess in the cookie header *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \"(^|; ) *X-UA-Device-force=[^;]+;? *\", \"\\1\");\n \/* If the cookie header is now empty, or just whitespace, unset it. *\/\n if (req.http.Cookie ~ \"^ *$\") {\n unset req.http.Cookie;\n }\n } else {\n if (req.http.User-Agent ~ \"\\(compatible; Googlebot-Mobile\/2.1; \\+http:\/\/www.google.com\/bot.html\\)\"\n || (req.http.User-Agent ~ \"(Android|iPhone)\"\n && req.http.User-Agent ~ \"\\(compatible.?; Googlebot\/2.1.?; \\+http:\/\/www.google.com\/bot.html\")\n || (req.http.User-Agent ~ \"(iPhone|Windows Phone)\"\n && req.http.User-Agent ~ \"\\(compatible; bingbot\/2.0; \\+http:\/\/www.bing.com\/bingbot.htm\")\n ) {\n set req.http.X-UA-Device = \"mobile-bot\";\n } elsif (req.http.User-Agent ~ \"(?i)(ads|google|bing|msn|yandex|baidu|ro|career|seznam|)bot\"\n || req.http.User-Agent ~ \"(?i)(baidu|jike|symantec)spider\"\n || req.http.User-Agent ~ \"(?i)scanner\"\n || req.http.User-Agent ~ \"(?i)(web)crawler\"\n ) {\n set req.http.X-UA-Device = \"bot\";\n } elsif (req.http.User-Agent ~ \"(?i)ipad\") {\n set req.http.X-UA-Device = \"tablet-ipad\";\n } elsif (req.http.User-Agent ~ \"(?i)ip(hone|od)\") {\n set req.http.X-UA-Device = \"mobile-iphone\";\n } elsif (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") {\n \/* how do we differ between an android phone and an android tablet? *\/\n \/* http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent *\/\n set req.http.X-UA-Device = \"mobile-android\";\n }\n elsif (req.http.User-Agent ~ \"(?i)android 3\") {\n \/* https:\/\/github.com\/varnish\/varnish-devicedetect\/blob\/master\/devicedetect.vcl *\/\n set req.http.X-UA-Device = \"tablet-android\";\n } elsif (req.http.User-Agent ~ \"Opera Mobi\") {\n \/* Opera Mobile *\/\n set req.http.X-UA-Device = \"mobile-smartphone\";\n }\n elsif (req.http.User-Agent ~ \"(?i)android\") {\n \/* May very well give false positives towards android tablets. Suggestions welcome. *\/\n set req.http.X-UA-Device = \"tablet-android\";\n } elsif (req.http.User-Agent ~ \"PlayBook; U; RIM Tablet\") {\n set req.http.X-UA-Device = \"tablet-rim\";\n } elsif (req.http.User-Agent ~ \"hp-tablet.*TouchPad\") {\n set req.http.X-UA-Device = \"tablet-hp\";\n } elsif (req.http.User-Agent ~ \"Kindle\/3\") {\n set req.http.X-UA-Device = \"tablet-kindle\";\n } elsif (req.http.User-Agent ~ \"Touch.+Tablet PC\" || req.http.User-Agent ~ \"Windows NT [0-9.]+; ARM;\" ) {\n set req.http.X-UA-Device = \"tablet-microsoft\";\n } elsif (req.http.User-Agent ~ \"Mobile.+Firefox\") {\n set req.http.X-UA-Device = \"mobile-firefoxos\";\n } elsif (req.http.User-Agent ~ \"^HTC\"\n || req.http.User-Agent ~ \"Fennec\"\n || req.http.User-Agent ~ \"IEMobile\"\n || req.http.User-Agent ~ \"BlackBerry\"\n || req.http.User-Agent ~ \"BB10.*Mobile\"\n || req.http.User-Agent ~ \"GT-.*Build\/GINGERBREAD\"\n || req.http.User-Agent ~ \"SymbianOS.*AppleWebKit\") {\n set req.http.X-UA-Device = \"mobile-smartphone\";\n }\n elsif (req.http.User-Agent ~ \"(?i)symbian\"\n || req.http.User-Agent ~ \"(?i)^sonyericsson\"\n || req.http.User-Agent ~ \"(?i)^nokia\"\n || req.http.User-Agent ~ \"(?i)^samsung\"\n || req.http.User-Agent ~ \"(?i)^lg\"\n || req.http.User-Agent ~ \"(?i)bada\"\n || req.http.User-Agent ~ \"(?i)blazer\"\n || req.http.User-Agent ~ \"(?i)cellphone\"\n || req.http.User-Agent ~ \"(?i)iemobile\"\n || req.http.User-Agent ~ \"(?i)midp-2.0\"\n || req.http.User-Agent ~ \"(?i)u990\"\n || req.http.User-Agent ~ \"(?i)netfront\"\n || req.http.User-Agent ~ \"(?i)opera mini\"\n || req.http.User-Agent ~ \"(?i)palm\"\n || req.http.User-Agent ~ \"(?i)nintendo wii\"\n || req.http.User-Agent ~ \"(?i)playstation portable\"\n || req.http.User-Agent ~ \"(?i)portalmmm\"\n || req.http.User-Agent ~ \"(?i)proxinet\"\n || req.http.User-Agent ~ \"(?i)sonyericsson\"\n || req.http.User-Agent ~ \"(?i)symbian\"\n || req.http.User-Agent ~ \"(?i)windows\\ ?ce\"\n || req.http.User-Agent ~ \"(?i)winwap\"\n || req.http.User-Agent ~ \"(?i)eudoraweb\"\n || req.http.User-Agent ~ \"(?i)htc\"\n || req.http.User-Agent ~ \"(?i)240x320\"\n || req.http.User-Agent ~ \"(?i)avantgo\") {\n set req.http.X-UA-Device = \"mobile-generic\";\n }\n }\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"5711f4bf5dbece9ed758be8f6c2a8b1459b8180d","subject":"Fix VCL regexes to support parameters and\/or subreddit searches.","message":"Fix VCL regexes to support parameters and\/or subreddit searches.\n","repos":"ajacksified\/reddit-mobile,ajacksified\/reddit-mobile,ajacksified\/reddit-mobile,ajacksified\/reddit-mobile","old_file":"default.vcl","new_file":"default.vcl","new_contents":"backend mweb {\n .host = \"mweb\";\n .port = \"4444\";\n}\n\/* backend www {\n .host = \"www.reddit.com\";\n .port = \"80\";\n} *\/\n\n\nsub vcl_recv {\n call device_detect;\n\n # Check mweb override cookie.\n if (req.http.Cookie ~ \"(^|;\\s*)(mweb-no-redirect=1)(;|$)\") {\n call set_www_backend;\n } elsif (\n (req.http.X-UA-Device ~ \"^mobile-\" || req.http.X-UA-Device ~ \"^tablet-\")\n # We don't host endpoints with extensions in mweb.\n # The Fastly equivalent is: && !req.url.ext\n && !reg.url ~ \"\\\/.+\\.[a-z]{3,4}(\\?.*|$)\"\n && (\n # Blacklisted endpoints\n req.url !~ \"\\.json$\"\n && (\n # Whitelisted 2X endpoints from router\/index.js\n req.url == \"\/\"\n || req.url ~ \"^\/actions\/\"\n || req.url ~ \"^\/comments\/?\"\n || req.url ~ \"^\/login\/?$\"\n || req.url ~ \"^\/message\/\"\n || req.url ~ \"^\/r\/\"\n || req.url ~ \"^\/register\/?$\"\n || req.url ~ \"\/search\/?$\"\n || req.url ~ \"\/submit\/?$\"\n || req.url ~ \"^\/submit\/to_community\/?$\"\n || req.url ~ \"^\/u\/\"\n || req.url ~ \"^\/user\/\"\n || req.url ~ \"^\/(help|w|wiki)\/?\"\n # Whitelisted 2X Ajax endpoints\n || req.url ~ \"^\/csp-report$\"\n || req.url == \"\/error\"\n || req.url ~ \"^\/(login|refresh|register)proxy$\"\n || req.url ~ \"^\/logout\"\n || req.url == \"\/routes\"\n || req.url ~ \"^\/timings\"\n || req.url ~ \"^\/(u\/)?XXX\\?.*\"\n # Whitelisted dev endpoints (these will be hosted on www in production)\n || req.url == \"\/apple-app-site-association\"\n || req.url ~ \"^\/favicon\/\"\n || req.url ~ \"^\/favicon\\.ico\"\n || req.url ~ \"^\/fonts\/\"\n || req.url == \"\/health\"\n || req.url ~ \"^\/img\/\"\n || req.url ~ \"^\/ProductionClient\\..*\\.(css|js)$\"\n || req.url == \"\/robots.txt\"\n )) {\n # If it's a mobile device and a whitelisted endpoint, use mweb.\n set req.backend = mweb;\n } else {\n call set_www_backend;\n }\n}\n\n\nsub set_www_backend {\n # NOTE(wting|2016-09-26): Normally we would redirect the user to a different\n # backend, but instead we're using a 400 status code for easy programmatic testing.\n error 400;\n # set req.backend = www;\n}\n\n\n# Vendorized from https:\/\/github.com\/varnish\/varnish-devicedetect\/blob\/master\/devicedetect.vcl\n# BSD-2 License\nsub device_detect {\n unset req.http.X-UA-Device;\n set req.http.X-UA-Device = \"pc\";\n\n # Handle that a cookie may override the detection alltogether.\n if (req.http.Cookie ~ \"(?i)X-UA-Device-force\") {\n \/* ;?? means zero or one ;, non-greedy to match the first. *\/\n set req.http.X-UA-Device = regsub(req.http.Cookie, \"(?i).*X-UA-Device-force=([^;]+);??.*\", \"\\1\");\n \/* Clean up our mess in the cookie header *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \"(^|; ) *X-UA-Device-force=[^;]+;? *\", \"\\1\");\n \/* If the cookie header is now empty, or just whitespace, unset it. *\/\n if (req.http.Cookie ~ \"^ *$\") {\n unset req.http.Cookie;\n }\n } else {\n if (req.http.User-Agent ~ \"\\(compatible; Googlebot-Mobile\/2.1; \\+http:\/\/www.google.com\/bot.html\\)\"\n || (req.http.User-Agent ~ \"(Android|iPhone)\"\n && req.http.User-Agent ~ \"\\(compatible.?; Googlebot\/2.1.?; \\+http:\/\/www.google.com\/bot.html\")\n || (req.http.User-Agent ~ \"(iPhone|Windows Phone)\"\n && req.http.User-Agent ~ \"\\(compatible; bingbot\/2.0; \\+http:\/\/www.bing.com\/bingbot.htm\")\n ) {\n set req.http.X-UA-Device = \"mobile-bot\";\n } elsif (req.http.User-Agent ~ \"(?i)(ads|google|bing|msn|yandex|baidu|ro|career|seznam|)bot\"\n || req.http.User-Agent ~ \"(?i)(baidu|jike|symantec)spider\"\n || req.http.User-Agent ~ \"(?i)scanner\"\n || req.http.User-Agent ~ \"(?i)(web)crawler\"\n ) {\n set req.http.X-UA-Device = \"bot\";\n } elsif (req.http.User-Agent ~ \"(?i)ipad\") {\n set req.http.X-UA-Device = \"tablet-ipad\";\n } elsif (req.http.User-Agent ~ \"(?i)ip(hone|od)\") {\n set req.http.X-UA-Device = \"mobile-iphone\";\n } elsif (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") {\n \/* how do we differ between an android phone and an android tablet? *\/\n \/* http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent *\/\n set req.http.X-UA-Device = \"mobile-android\";\n }\n elsif (req.http.User-Agent ~ \"(?i)android 3\") {\n \/* https:\/\/github.com\/varnish\/varnish-devicedetect\/blob\/master\/devicedetect.vcl *\/\n set req.http.X-UA-Device = \"tablet-android\";\n } elsif (req.http.User-Agent ~ \"Opera Mobi\") {\n \/* Opera Mobile *\/\n set req.http.X-UA-Device = \"mobile-smartphone\";\n }\n elsif (req.http.User-Agent ~ \"(?i)android\") {\n \/* May very well give false positives towards android tablets. Suggestions welcome. *\/\n set req.http.X-UA-Device = \"tablet-android\";\n } elsif (req.http.User-Agent ~ \"PlayBook; U; RIM Tablet\") {\n set req.http.X-UA-Device = \"tablet-rim\";\n } elsif (req.http.User-Agent ~ \"hp-tablet.*TouchPad\") {\n set req.http.X-UA-Device = \"tablet-hp\";\n } elsif (req.http.User-Agent ~ \"Kindle\/3\") {\n set req.http.X-UA-Device = \"tablet-kindle\";\n } elsif (req.http.User-Agent ~ \"Touch.+Tablet PC\" || req.http.User-Agent ~ \"Windows NT [0-9.]+; ARM;\" ) {\n set req.http.X-UA-Device = \"tablet-microsoft\";\n } elsif (req.http.User-Agent ~ \"Mobile.+Firefox\") {\n set req.http.X-UA-Device = \"mobile-firefoxos\";\n } elsif (req.http.User-Agent ~ \"^HTC\"\n || req.http.User-Agent ~ \"Fennec\"\n || req.http.User-Agent ~ \"IEMobile\"\n || req.http.User-Agent ~ \"BlackBerry\"\n || req.http.User-Agent ~ \"BB10.*Mobile\"\n || req.http.User-Agent ~ \"GT-.*Build\/GINGERBREAD\"\n || req.http.User-Agent ~ \"SymbianOS.*AppleWebKit\") {\n set req.http.X-UA-Device = \"mobile-smartphone\";\n }\n elsif (req.http.User-Agent ~ \"(?i)symbian\"\n || req.http.User-Agent ~ \"(?i)^sonyericsson\"\n || req.http.User-Agent ~ \"(?i)^nokia\"\n || req.http.User-Agent ~ \"(?i)^samsung\"\n || req.http.User-Agent ~ \"(?i)^lg\"\n || req.http.User-Agent ~ \"(?i)bada\"\n || req.http.User-Agent ~ \"(?i)blazer\"\n || req.http.User-Agent ~ \"(?i)cellphone\"\n || req.http.User-Agent ~ \"(?i)iemobile\"\n || req.http.User-Agent ~ \"(?i)midp-2.0\"\n || req.http.User-Agent ~ \"(?i)u990\"\n || req.http.User-Agent ~ \"(?i)netfront\"\n || req.http.User-Agent ~ \"(?i)opera mini\"\n || req.http.User-Agent ~ \"(?i)palm\"\n || req.http.User-Agent ~ \"(?i)nintendo wii\"\n || req.http.User-Agent ~ \"(?i)playstation portable\"\n || req.http.User-Agent ~ \"(?i)portalmmm\"\n || req.http.User-Agent ~ \"(?i)proxinet\"\n || req.http.User-Agent ~ \"(?i)sonyericsson\"\n || req.http.User-Agent ~ \"(?i)symbian\"\n || req.http.User-Agent ~ \"(?i)windows\\ ?ce\"\n || req.http.User-Agent ~ \"(?i)winwap\"\n || req.http.User-Agent ~ \"(?i)eudoraweb\"\n || req.http.User-Agent ~ \"(?i)htc\"\n || req.http.User-Agent ~ \"(?i)240x320\"\n || req.http.User-Agent ~ \"(?i)avantgo\") {\n set req.http.X-UA-Device = \"mobile-generic\";\n }\n }\n}\n","old_contents":"backend mweb {\n .host = \"mweb\";\n .port = \"4444\";\n}\n\/* backend www {\n .host = \"www.reddit.com\";\n .port = \"80\";\n} *\/\n\n\nsub vcl_recv {\n call device_detect;\n\n # Check mweb override cookie.\n if (req.http.Cookie ~ \"(^|;\\s*)(mweb-no-redirect=1)(;|$)\") {\n call set_www_backend;\n } elsif (\n (req.http.X-UA-Device ~ \"^mobile-\" || req.http.X-UA-Device ~ \"^tablet-\")\n # We don't host endpoints with extensions in mweb.\n # The Fastly equivalent is: && !req.url.ext\n && !reg.url ~ \"\\\/.+\\.[a-z]{3,4}(\\?.*|$)\"\n && (\n # Blacklisted endpoints\n req.url !~ \"\\.json$\"\n && (\n # Whitelisted 2X endpoints from router\/index.js\n req.url == \"\/\"\n || req.url ~ \"^\/actions\/\"\n || req.url ~ \"^\/comments\/?\"\n || req.url ~ \"^\/login\/?$\"\n || req.url ~ \"^\/message\/\"\n || req.url ~ \"^\/r\/\"\n || req.url ~ \"^\/register\/?$\"\n || req.url ~ \"^\/search\/?$\"\n || req.url ~ \"^\/submit\/?$\"\n || req.url ~ \"^\/submit_to_community\/?$\"\n || req.url ~ \"^\/u\/\"\n || req.url ~ \"^\/user\/\"\n || req.url ~ \"^\/(help|w|wiki)\/?\"\n # Whitelisted 2X Ajax endpoints\n || req.url ~ \"^\/csp-report$\"\n || req.url == \"\/error\"\n || req.url ~ \"^\/(login|refresh|register)proxy$\"\n || req.url ~ \"^\/logout\"\n || req.url == \"\/routes\"\n || req.url ~ \"^\/timings$\"\n || req.url ~ \"^\/(u\/)?XXX\\?.*\"\n # Whitelisted dev endpoints (these will be hosted on www in production)\n || req.url == \"\/apple-app-site-association\"\n || req.url ~ \"^\/favicon\/\"\n || req.url ~ \"^\/favicon\\.ico\"\n || req.url ~ \"^\/fonts\/\"\n || req.url == \"\/health\"\n || req.url ~ \"^\/img\/\"\n || req.url ~ \"^\/ProductionClient\\..*\\.(css|js)$\"\n || req.url == \"\/robots.txt\"\n )) {\n # If it's a mobile device and a whitelisted endpoint, use mweb.\n set req.backend = mweb;\n } else {\n call set_www_backend;\n }\n}\n\n\nsub set_www_backend {\n # NOTE(wting|2016-09-26): Normally we would redirect the user to a different\n # backend, but instead we're using a 400 status code for easy programmatic testing.\n error 400;\n # set req.backend = www;\n}\n\n\n# Vendorized from https:\/\/github.com\/varnish\/varnish-devicedetect\/blob\/master\/devicedetect.vcl\n# BSD-2 License\nsub device_detect {\n unset req.http.X-UA-Device;\n set req.http.X-UA-Device = \"pc\";\n\n # Handle that a cookie may override the detection alltogether.\n if (req.http.Cookie ~ \"(?i)X-UA-Device-force\") {\n \/* ;?? means zero or one ;, non-greedy to match the first. *\/\n set req.http.X-UA-Device = regsub(req.http.Cookie, \"(?i).*X-UA-Device-force=([^;]+);??.*\", \"\\1\");\n \/* Clean up our mess in the cookie header *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \"(^|; ) *X-UA-Device-force=[^;]+;? *\", \"\\1\");\n \/* If the cookie header is now empty, or just whitespace, unset it. *\/\n if (req.http.Cookie ~ \"^ *$\") {\n unset req.http.Cookie;\n }\n } else {\n if (req.http.User-Agent ~ \"\\(compatible; Googlebot-Mobile\/2.1; \\+http:\/\/www.google.com\/bot.html\\)\"\n || (req.http.User-Agent ~ \"(Android|iPhone)\"\n && req.http.User-Agent ~ \"\\(compatible.?; Googlebot\/2.1.?; \\+http:\/\/www.google.com\/bot.html\")\n || (req.http.User-Agent ~ \"(iPhone|Windows Phone)\"\n && req.http.User-Agent ~ \"\\(compatible; bingbot\/2.0; \\+http:\/\/www.bing.com\/bingbot.htm\")\n ) {\n set req.http.X-UA-Device = \"mobile-bot\";\n } elsif (req.http.User-Agent ~ \"(?i)(ads|google|bing|msn|yandex|baidu|ro|career|seznam|)bot\"\n || req.http.User-Agent ~ \"(?i)(baidu|jike|symantec)spider\"\n || req.http.User-Agent ~ \"(?i)scanner\"\n || req.http.User-Agent ~ \"(?i)(web)crawler\"\n ) {\n set req.http.X-UA-Device = \"bot\";\n } elsif (req.http.User-Agent ~ \"(?i)ipad\") {\n set req.http.X-UA-Device = \"tablet-ipad\";\n } elsif (req.http.User-Agent ~ \"(?i)ip(hone|od)\") {\n set req.http.X-UA-Device = \"mobile-iphone\";\n } elsif (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") {\n \/* how do we differ between an android phone and an android tablet? *\/\n \/* http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent *\/\n set req.http.X-UA-Device = \"mobile-android\";\n }\n elsif (req.http.User-Agent ~ \"(?i)android 3\") {\n \/* https:\/\/github.com\/varnish\/varnish-devicedetect\/blob\/master\/devicedetect.vcl *\/\n set req.http.X-UA-Device = \"tablet-android\";\n } elsif (req.http.User-Agent ~ \"Opera Mobi\") {\n \/* Opera Mobile *\/\n set req.http.X-UA-Device = \"mobile-smartphone\";\n }\n elsif (req.http.User-Agent ~ \"(?i)android\") {\n \/* May very well give false positives towards android tablets. Suggestions welcome. *\/\n set req.http.X-UA-Device = \"tablet-android\";\n } elsif (req.http.User-Agent ~ \"PlayBook; U; RIM Tablet\") {\n set req.http.X-UA-Device = \"tablet-rim\";\n } elsif (req.http.User-Agent ~ \"hp-tablet.*TouchPad\") {\n set req.http.X-UA-Device = \"tablet-hp\";\n } elsif (req.http.User-Agent ~ \"Kindle\/3\") {\n set req.http.X-UA-Device = \"tablet-kindle\";\n } elsif (req.http.User-Agent ~ \"Touch.+Tablet PC\" || req.http.User-Agent ~ \"Windows NT [0-9.]+; ARM;\" ) {\n set req.http.X-UA-Device = \"tablet-microsoft\";\n } elsif (req.http.User-Agent ~ \"Mobile.+Firefox\") {\n set req.http.X-UA-Device = \"mobile-firefoxos\";\n } elsif (req.http.User-Agent ~ \"^HTC\"\n || req.http.User-Agent ~ \"Fennec\"\n || req.http.User-Agent ~ \"IEMobile\"\n || req.http.User-Agent ~ \"BlackBerry\"\n || req.http.User-Agent ~ \"BB10.*Mobile\"\n || req.http.User-Agent ~ \"GT-.*Build\/GINGERBREAD\"\n || req.http.User-Agent ~ \"SymbianOS.*AppleWebKit\") {\n set req.http.X-UA-Device = \"mobile-smartphone\";\n }\n elsif (req.http.User-Agent ~ \"(?i)symbian\"\n || req.http.User-Agent ~ \"(?i)^sonyericsson\"\n || req.http.User-Agent ~ \"(?i)^nokia\"\n || req.http.User-Agent ~ \"(?i)^samsung\"\n || req.http.User-Agent ~ \"(?i)^lg\"\n || req.http.User-Agent ~ \"(?i)bada\"\n || req.http.User-Agent ~ \"(?i)blazer\"\n || req.http.User-Agent ~ \"(?i)cellphone\"\n || req.http.User-Agent ~ \"(?i)iemobile\"\n || req.http.User-Agent ~ \"(?i)midp-2.0\"\n || req.http.User-Agent ~ \"(?i)u990\"\n || req.http.User-Agent ~ \"(?i)netfront\"\n || req.http.User-Agent ~ \"(?i)opera mini\"\n || req.http.User-Agent ~ \"(?i)palm\"\n || req.http.User-Agent ~ \"(?i)nintendo wii\"\n || req.http.User-Agent ~ \"(?i)playstation portable\"\n || req.http.User-Agent ~ \"(?i)portalmmm\"\n || req.http.User-Agent ~ \"(?i)proxinet\"\n || req.http.User-Agent ~ \"(?i)sonyericsson\"\n || req.http.User-Agent ~ \"(?i)symbian\"\n || req.http.User-Agent ~ \"(?i)windows\\ ?ce\"\n || req.http.User-Agent ~ \"(?i)winwap\"\n || req.http.User-Agent ~ \"(?i)eudoraweb\"\n || req.http.User-Agent ~ \"(?i)htc\"\n || req.http.User-Agent ~ \"(?i)240x320\"\n || req.http.User-Agent ~ \"(?i)avantgo\") {\n set req.http.X-UA-Device = \"mobile-generic\";\n }\n }\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"782955c52d36a77cf3649d1b645f74a3edf4eaa9","subject":"Reorganize, added commands","message":"Reorganize, added commands\n","repos":"aschneiderman\/atom-voice-vocola","old_file":"atom.vcl","new_file":"atom.vcl","new_contents":"# Voice commands for atom\n\ninclude folders.vch;\ninclude letters.vch;\n\nGo Strawberry = {Ctrl+Alt+F8};\nGo Blueberry ={Ctrl+Alt+o};\nGo Banana = {Ctrl+Alt+F7};\n\n# Commands for developing Atom: init.config, packages; also for navigating existing packages\/commands\nReload Atom = {Ctrl+s} Wait(100) {Shift+Ctrl+Alt+F5};\nCommand Palette = {Ctrl+Shift+p};\nKeyboard Shortcuts = {Ctrl+.};\nRun Specs = {Ctrl+Alt+p};\nShow Console = {Ctrl+Alt+i};\n\n# Commands for developing D3: D3 visualizations, D3 Sandwiches\nSave and Reload = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Ctrl+r};\t\nSave and Really Reload = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Ctrl+Shift+r};\n\n# File commands\nFind (File | Document) = {Ctrl+t};\nSave As = {Ctrl+Shift+s};\nNext Window = {Ctrl+Tab};\nLast Window = {Ctrl+Shift+Tab};\n\n\n# --- Text navigation commands ------------------------------------\n<delimiters> := (Quote = '\"' | 'Single Quote' = \"'\" | Comma = ',' | 'Equal Sign' = '=' | Equals = '=' \n\t| Period = '.' | Colon = ':' | 'Semi-Colon' = ';' | Hyphen = '-' | Underscore = '_' | Slash = '\/'\n\t| Paren = \"(\" | \"Close Paren\" = \")\" | Parentheses = \"(\" | \"Open Parenthesis\" = \"(\" | \"Close Parentheses\" = \")\"\n\t| Bracket = '[' | \"Close Bracket\" = ']' | Brace = '{' | 'Close Brace' = '}'\t);\n\nLine 1..200 = {Ctrl+g} $1 {Enter};\n(Left = 'b' | Right = 'f') Word = {Alt+$1};\nTop = {Ctrl+Home};\nBottom = {Ctrl+End};\n(Find = 'Right' | 'Insert After' = 'Right' | 'Insert Before' = 'Left') (Next = 'Enter' | Last = 'Shift+F3') <delimiters> \n\t\t= {Ctrl+f} $3 {$2} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') <delimiters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') 1..20 <delimiters> = {Ctrl+f} $3 {Enter} {Esc} Wait(100) {F3_$2} {Shift+F3} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') Enda <delimiters> = {End} {Ctrl+f} $2 {Enter} {Esc} {Shift+F3} Wait(100) {$1};\n\nFine Alpha <letters> = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Left};\nInsert (Before = 'Left' | After = 'Right') Alpha <letters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nFine Number 0..9 = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Right};\n(Find | Insert) Again = {F3} {Right};\n(Find | Insert) Again 1..20 Times = {F3_$1} {Right};\n\n(Set | Add | Clear | Hide | Delete) Bookmark = {Ctrl+Alt+F2};\n(Next = 'F2' | Last = 'Shift+F2') Bookmark = {$1};\n\n\n# --- Editing commands ----------------------------------------\nSelect Line = {Ctrl+l};\nSelect (Next = 'Down' | Forward = 'Down' | Last = 'Up' | Back = 'Up' | Previous = 'Up') 1..20 Lines = {Home} {Shift+$1_$2};\nMove Line (Up | Down) 1..20 = {Ctrl+$1_$2};\nAdd 1..20 (Lines = 'Down' | Line = 'Down' | Pages = 'PgDn' | Page = 'PgDn') = {Shift+$2_$1};\n\n\n\nSelect between (Delimiters | Brackets | Tags) ={Ctrl+m} {Ctrl+Alt+m};\nDelete between Tags = {Ctrl+m} {Ctrl+Alt+m} {Del};\nDelete Tags = {Ctrl+Alt+F4};\nReplace With (Header | Heading) 1..7 = {Ctrl+Alt+F4} '<h' $2 '>' {End} '<\/h' $2 '>' {Home};\nReplace With (para = 'p') = {Ctrl+Alt+F4} '<' $1 '>' {End} '<\/' $1 '>';\n\n\nDelete Word = {Ctrl+Del};\nDelete 1..20 Words = {Ctrl+Del_$1};\nDelete (Back | Last) Word = {Ctrl+Backspace};\nDelete (Back | Last) 1..20 Words = {Ctrl+Backspace_$2};\nDelete Enda Word = {End} {Ctrl+Backspace};\n\n(Delete Line | Dede) = {Ctrl+Shift+k};\nDelete 1..20 Lines = {Ctrl+Shift+k_$1};\n(Cut = 'x' | Paste = 'v' | Copy = 'c') That = {Ctrl+$1};\n\nComment (That | Line) = {Ctrl+\/};\nComment 1..20 Lines = {Home} {Shift+Down_$1} {Ctrl+\/};\n\nReplace = {Ctrl+f};\nReplace All = {Ctrl+Enter};\n\n(Join = 'j' | Indent = ']' | Dedent = '[') That = {Ctrl+$1};\n\n\n# --- Commands to create code\/tags -------------------------------------------\n# NOTE: basic HTML commands are stored in my global Vocala commands\n\nStart (\t# HTML commands\n\t'HTML page' = 'html' | pre = \"pre\" | 'Comment' = 'comment-html'\n\t| div = 'div' \n\n\t# D3 Recipe commands\n\t| 'Recipe Page' = 'recipe-page' | 'Recipe Row' = 'recipe-row' \n\t| 'Recipe Toy' = 'recipe-toy' | Toy = 'recipe-toy'\n\n\t# Coffeescript commands\n\t| Snippet = 'my-snippet' \n\t| 'Fix Line' = 'fix-current-line' | 'Fix Current Line' = 'fix-current-line'\n) = $1 {Tab};\n\nStop (\t#HTML commands\n\t'div comment' = 'comment-div-end' | Comment = 'comment-html-end' \n) = $1 {Tab};\n\n# HTML commands\nDot HTML = '.html';\nStart (Header | Heading) 1..7 = h $2 {Tab};\nAdd (Header | Heading) 1..7 = '<h' $2 '>' {End} '<\/h' $2 '>';\nAdd (para = 'p') = '<' $1 '>' {End} '<\/' $1 '>';\n\n# D3 Recipe commands\nPre-Format Code = {Ctrl+Alt+F5};\n\n# D3 commands\nPaste Function = 'function ' {Ctrl+v} ' {' {Enter} {Enter} '};' {Up};\n\n# Coffeescript commands\n\n# Python commands\n\n\n# --- D3 commands -------------------------------------------\n\n\n# --- Python commands -------------------------------------------\n\n\n# --- Coffeescript commands -------------------------------------------","old_contents":"# Voice commands for atom\n\ninclude folders.vch;\ninclude letters.vch;\n\nGo Strawberry = {Ctrl+Alt+F8};\nGo Blueberry ={Ctrl+Alt+o};\nGo Banana = {Ctrl+Alt+F7};\n\nStart Far = 'var ';\n\n# Commands for developing Atom: init.config, packages; also for navigating existing packages\/commands\nReload Atom = {Ctrl+s} Wait(100) {Shift+Ctrl+Alt+F5};\nCommand Palette = {Ctrl+Shift+p};\nKeyboard Shortcuts = {Ctrl+.};\nRun Specs = {Ctrl+Alt+p};\nShow Console = {Ctrl+Alt+i};\n\n# Commands for developing D3: D3 visualizations, D3 Sandwiches\nSave and Reload = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Ctrl+r};\t\nSave and Really Reload = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Ctrl+Shift+r};\n\n# File commands\nFind (File | Document) = {Ctrl+t};\nSave As = {Ctrl+Shift+s};\n\n\n# --- Navigation commands ------------------------------------\n<delimiters> := (Quote = '\"' | 'Single Quote' = \"'\" | Comma = ',' | 'Equal Sign' = '=' | Equals = '=' \n\t| Period = '.' | Colon = ':' | 'Semi-Colon' = ';' | Hyphen = '-' | Underscore = '_' | Slash = '\/'\n\t| Paren = \"(\" | \"Close Paren\" = \")\" | Parentheses = \"(\" | \"Close Parentheses\" = \")\"\n\t| Bracket = '[' | \"Close Bracket\" = ']' | Brace = '{' | 'Close Brace' = '}'\t);\n\nLine 1..200 = {Ctrl+g} $1 {Enter};\n(Left = 'b' | Right = 'f') Word = {Alt+$1};\nTop = {Ctrl+Home};\nBottom = {Ctrl+End};\n(Find = 'Right' | 'Insert After' = 'Right' | 'Insert Before' = 'Left') (Next = 'Enter' | Last = 'Shift+F3') <delimiters> \n\t\t= {Ctrl+f} $3 {$2} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') <delimiters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') 1..20 <delimiters> = {Ctrl+f} $3 {Enter} {Esc} Wait(100) {F3_$2} {Shift+F3} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') Enda <delimiters> = {End} {Ctrl+f} $2 {Enter} {Esc} {Shift+F3} Wait(100) {$1};\n\nFine Alpha <letters> = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Left};\nInsert (Before = 'Left' | After = 'Right') Alpha <letters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nFine Number 0..9 = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Right};\nFind Again = {F3} {Right};\nFind Again 1..20 Times = {F3_$1} {Right};\n\nFind Symbol = {Ctrl+r};\n\n(Set | Add | Clear | Hide | Delete) Bookmark = {Ctrl+Alt+F2};\n(Next = 'F2' | Last = 'Shift+F2') Bookmark = {$1};\n\nNext Window = {Ctrl+Tab};\nLast Window = {Ctrl+Shift+Tab};\n\n\n# --- Editing commands ----------------------------------------\nSelect Line = {Ctrl+l};\nSelect (Next = 'Down' | Forward = 'Down' | Last = 'Up' | Back = 'Up' | Previous = 'Up') 1..20 Lines = {Home} {Shift+$1_$2};\nGrab 1..20 Lines = {Home} {Shift+Down_$1};\nAdd 1..20 (Lines = 'Down' | Line = 'Down' | Pages = 'PgDn' | Page = 'PgDn') = {Shift+$2_$1};\n\n(Join = 'j' | Indent = ']' | Dedent = '[') That = {Ctrl+$1};\nMove Line (Up | Down) 1..20 = {Ctrl+$1_$2};\n\n\n\nDelete Word = {Ctrl+Del};\nDelete 1..20 Words = {Ctrl+Del_$1};\nDelete (Back | Last) Word = {Ctrl+Backspace};\nDelete (Back | Last) 1..20 Words = {Ctrl+Backspace_$2};\nDelete Enda Word = {End} {Ctrl+Backspace};\n\n(Delete Line | Dede) = {Ctrl+Shift+k};\nDelete 1..20 Lines = {Ctrl+Shift+k_$1};\n(Cut = 'x' | Paste = 'v' | Copy = 'c') That = {Ctrl+$1};\n\nComment (That | Line) = {Ctrl+\/};\nComment 1..20 Lines = {Home} {Shift+Down_$1} {Ctrl+\/};\n\nSelect between (Delimiters | Brackets | Tags) ={Ctrl+m} {Ctrl+Alt+m};\n\nDelete Tags = {Ctrl+Alt+F4};\n\nReplace = {Ctrl+f};\nReplace All = {Ctrl+Enter};\n\n\n\n\n# --- Code commands -------------------------------------------\nStart (Item = 'li' | List = 'ul' | HTML = 'html' | pre = \"pre\"\n\t| div = 'div' | 'Comment' = 'comment-html'\n\t| 'Bold ID' = 'bold-id' | 'Input' = 'ds-input-text'\n\t| 'Fix Line' = 'fix-current-line' | 'Fix Current Line' = 'fix-current-line'\n\t| Snippet = 'my-snippet' | 'Recipe Row' = 'recipe-row' | 'Recipe Play' = 'recipe-play') = $1 {Tab};\nStop (Comment = 'comment-html-end' ) = $1 {Tab};\nStart (para = '<p>' ) = $1;\nAdd (para = 'p') = '<' $1 '>' {End} '<\/' $1 '>';\nReplace With (para = 'p') = {Ctrl+Alt+F4} '<' $1 '>' {End} '<\/' $1 '>';\n\nStart (Header | Heading) 1..7 = h $2 {Tab};\nAdd (Header | Heading) 1..7 = '<h' $2 '>' {End} '<\/h' $2 '>';\nReplace With (Header | Heading) 1..7 = {Ctrl+Alt+F4} '<h' $2 '>' {End} '<\/h' $2 '>' {Home};\nMid HREF = '\">';\n\nPaste Function = 'function ' {Ctrl+v} ' {' {Enter} {Enter} '};' {Up};\n\nPre-Format Code = {Ctrl+Alt+F5};\n\n# TO ADD:\n# adding HTML comments, using a snippet\n\n\n\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"e6d2f8575bf4e8efe6af8d0ce23b7f9637016cf9","subject":"do the sensible thing when working behind a proxy under our control","message":"do the sensible thing when working behind a proxy under our control\n","repos":"NITEMAN\/varnish-bites,NITEMAN\/Varnish_VCL_samps-hacks","old_file":"varnish3\/drupal-base.vcl","new_file":"varnish3\/drupal-base.vcl","new_contents":"\/* Varnish 3 example config for Drupal 7 \/ Pressflow 6 & 7 *\/\n# Original source: https:\/\/github.com\/NITEMAN\/varnish-bites\/varnish4\/drupal-base.vcl\n# Copyright (c) 2015 Pedro Gonz\u00e1lez Serrano and individual contributors.\n# MIT License\n\n# Intended to be used both in simple production environments and with learning\/teaching purposes.\n# Loosely based on http:\/\/www.lullabot.com\/sites\/default\/files\/default_varnish3.vcl_.txt\n\n\/* Backend probes \/ healthchecks *\/\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#backend-probes\nprobe basic {\n \/* Only test that backend's IP serves content for '\/' *\/\n # This might be a too heavy probe\n # .url = \"\/\";\n \/* Only test that backend's IP has apache working *\/\n # Nginx would fail this probe with a default config\n .request =\n \"OPTIONS * HTTP\/1.1\"\n \"Host: *\"\n \"Connection: close\";\n .interval = 10s;\n .timeout = 2s;\n .window = 8;\n .threshold = 6;\n}\n\n\n\/* Backend definitions.*\/\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#backend-declarations\nbackend default {\n \/* Default backend on the same machine. WARNING: timeouts could be not big enought for certain POST request *\/\n .host = \"127.0.0.1\";\n .port = \"8008\";\n .connect_timeout = 60s;\n .first_byte_timeout = 60s;\n .between_bytes_timeout = 60s;\n .probe = basic;\n}\n\n\n\/* Directors. *\/\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#directors\n# Empty in simple configs\n\n\n\/* Access Control Lists *\/\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#acls\nacl purge_ban {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use '\"localhost\";' instead\n}\nacl allowed_monitors {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n}\nacl own_proxys {\n \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n}\n\n\n\/* Custom routines *\/\n# Empty in simple configs.\n# We can name subs with no restrictions but as a task can need several chunks of code in diferent states,\n# it's a good idea to identify what main sub will call each with a suffix.\n# \/* Example 301 client redirection removing \"www\" prefix from request *\/\n# sub perm_redirections_recv {\n# if ( req.http.host ~ \"^www.*$\" ) {\n# error 751 \"http:\/\/\" + regsub(req.http.host, \"^www\\.\", \"\") + req.url;\n# }\n# }\n# sub perm_redirections_error {\n# if (obj.status == 751) {\n# \/* Get new URL from the response *\/\n# set obj.http.Location = obj.response;\n# \/* Set HTTP 301 for permanent redirect *\/\n# set obj.status = 301;\n# return(deliver);\n# }\n# }\n\n\n\/* VCL logigc overrides *\/\n# Note that the built-in logic will be appended to our code if no return is performed before.\n# Built-in logic is included commented out right after our's for reference purposes in that cases.\n# See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleDefault\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#subroutines\n\n# vcl_recv: Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use.\nsub vcl_recv {\n \/* 0th: general bypass, general return & authorization checks *\/\n # Empty in simple configs.\n # Useful for debugging we can pipe or pass the request to default backend here to bypass completely Varnish.\n # return (pipe);\n # return (pass);\n # We can also return here a 200 Ok for network performance benchmarking.\n # error 200 \"Ok\";\n # Finally we can perform basic HTTP authentification here by example.\n # See http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* 1st: Check for Varnish special requests *\/ \n # Purge logic.\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/purging.html#http-purges\n # See https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if (req.request == \"PURGE\") {\n if (!client.ip ~ purge_ban) {\n error 405 \"Not allowed.\";\n }\n return (lookup);\n }\n # Ban logic. See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/purging.html#bans\n if (req.request == \"BAN\") {\n if (!client.ip ~ purge_ban) {\n error 405 \"Not allowed.\";\n }\n ban(\"req.http.host == \" + req.http.host +\n \"&& req.url == \" + req.url); \n error 200 \"Ban added\";\n }\n # Custom response implementation example in order to check that Varnish is working properly.\n # This is usefull for automatic monitoring with monit or when Varnish is behind another proxies like HAProxy.\n if (req.http.host == \"monitor.server.health\" && \n client.ip ~ allowed_monitors && \n (req.request == \"OPTIONS\" || req.request == \"GET\")) {\n error 200 \"Ok\";\n }\n\n \/* 2nd: Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_recv;\n # Here we can also enforce SSL when Varnish run behind some SSL termination point.\n\n \/* 3rd: Time for backend choice *\/\n # Empty in simple configs.\n\n \/* 4th: Set custom headers for backend like X-Forwarded-For (copied from built-in logic) *\/\n if ( req.restarts == 0 ) {\n \/* See also vcl_pipe section *\/\n if ( ! client.ip ~ own_proxys ) {\n if ( req.http.x-forwarded-for ) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n }\n\n \/* 5th: Bypass breakpoint 1 *\/\n # Useful for debugging we can now pipe or pass the request to backend with headers setted.\n # return (pipe);\n # return (pass);\n\n \/* 6th: Decide if we should deal with a request (mostly copied from built-in logic) *\/\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n\n \/* 7th: Access control for some URLs by ACL *\/\n # Empty in simple configs.\n # By example denial some URLs depending on client-ip, we'll need to define corresponding ACL 'internal'.\n # if (req.url ~ \"^\/(cron|install)\\.php$\" && !client.ip ~ internal) {\n # # Have Varnish throw the error directly.\n # error 403 \"Forbidden.\";\n # # Use a custom error page that you've defined in Drupal at the path \"404\".\n # # set req.url = \"\/403\";\n # }\n\n \/* 8th: Custom exceptions *\/\n # Host exception example:\n # if (req.http.host == \"ejemplo.exception.com\") {\n # return (pass);\n # }\n # Drupal exceptions, edit if we want to cache some AJAX\/AHAH request.\n # Add here filters for never cache URLs such as Payment Gateway's callbacks\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/ooyala\/ping$\" ||\n req.url ~ \"^\/admin\/build\/features\" ||\n req.url ~ \"^\/info\/.*$\" ||\n req.url ~ \"^\/flag\/.*$\" ||\n req.url ~ \"^.*\/ajax\/.*$\" ||\n req.url ~ \"^.*\/ahah\/.*$\") {\n \/* Do not cache these paths *\/\n return (pass);\n }\n # Pipe these paths directly to backend for streaming.\n if (req.url ~ \"^\/admin\/content\/backup_migrate\/export\") {\n return (pipe);\n }\n if (req.url ~ \"^\/system\/files\") {\n return (pipe);\n }\n\n \/* 9th: Enable grace mode *\/\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/handling_misbehaving_servers.html#grace-mode\n if (! req.backend.healthy) {\n \/* Use a longer grace period if all backends are down *\/\n set req.grace = 1h;\n \/* Use anonymous, cached pages if all backends are down. *\/\n unset req.http.Cookie;\n # TO-DO: Add sick marker\n } else {\n \/* Allow the backend to serve up stale content if it is responding slowly. *\/\n set req.grace = 30s;\n }\n\n \/* 10th: Deal with compression and the Accept-Encoding header *\/\n # Althought Varnish 3 handles gziped content itself by default, just to be sure we want to \n # remove Accept-Encoding for some compressed formats.\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/phk\/gzip.html#what-does-http-gzip-support-do\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/varnishd.html?highlight=http_gzip_support\n # See (for older configs) https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleNormalizeAcceptEncoding\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|mp4|flv|zip|rar)$\") {\n \/* Already compressed formats, no sense trying to compress again *\/\n remove req.http.Accept-Encoding;\n }\n }\n\n \/* 11th: Another header manipulation *\/\n # Empty in simple configs.\n # We could add here a custom header grouping User-agent families.\n\n \/* 12th: Cookie removal *\/\n # Always cache the following static file types for all users. \n # Use with care if we control certain downloads depending on cookies. \n # Be carefull also if appending .htm[l] via Drupal's clean URLs.\n if (req.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|svg|pdf)(\\?[a-z0-9]+)?$\") {\n unset req.http.Cookie;\n }\n # Remove all cookies that backend doesn't need to know about.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRemovingSomeCookies\n if (req.http.Cookie) {\n \/* Warning: Not a pretty solution *\/\n \/* Prefix header containing cookies with ';' *\/\n set req.http.Cookie = \";\" + req.http.Cookie;\n \/* Remove any spaces after ';' in header containing cookies *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n \/* Prefix cookies we want to preserve with one space *\/\n \/* 'S{1,2}ESS[a-z0-9]+' is the regular expression matching a Drupal session cookie ({1,2} added for HTTPS support) *\/\n \/* 'NO_CACHE' is usually set after a POST request to make sure issuing user see the results of his post *\/\n \/* 'OATMEAL' & 'CHOCOLATECHIP' are special cookies used by Drupal's Bakery module to provide Single Sign On *\/\n \/* Keep in mind we should add here any cookie that should reach the backend such as splahs avoiding cookies *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \";(S{1,2}ESS[a-z0-9]+|NO_CACHE|OATMEAL|CHOCOLATECHIP)=\", \"; \\1=\");\n \/* Remove from the header any single Cookie not prefixed with a space until next ';' separator *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n \/* Remove any '; ' at the start or the end of the header *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n\n if (req.http.Cookie == \"\") {\n \/* If there are no remaining cookies, remove the cookie header. *\/\n unset req.http.Cookie;\n }\n }\n\n \/* 13th: Session cookie & special cookies bypass caching stage *\/\n # As we might want to cache some requests, hashed with its cookies, \n # we don't simply pass when some cookies remain present at this point.\n # Instead we look for request that must be passed due to the cookie header.\n if (req.http.Cookie ~ \"SESS\" ||\n req.http.Cookie ~ \"SSESS\" ||\n req.http.Cookie ~ \"NO_CACHE\" ||\n req.http.Cookie ~ \"OATMEAL\" ||\n req.http.Cookie ~ \"CHOCOLATECHIP\") {\n return (pass);\n }\n\n \/* 14th: Bypass breakpoint 2 *\/\n # Useful for debugging we can now pipe or pass the request to backend to bypass cache.\n # return (pipe);\n # return (pass);\n\n \/* 15th: Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning a lookup.\n return (lookup);\n}\n\n# vcl_pipe: Called upon entering pipe mode.\n# In this mode, the request is passed on to the backend, \n# and any further data from either client or backend is passed on unaltered until either end closes the connection.\nsub vcl_pipe {\n \/* Prevent connection re-using for piped requests *\/\n # Note that only the first request to the backend will have X-Forwarded-For set.\n # As we use X-Forwarded-For and want to have it set for all requests, \n # we have to make sure connection won't be reused after the request.\n # It is not set by default as it might break some broken web applications, like IIS with NTLM authentication.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExamplePipe\n # TO-DO: make sure this is compatible with websockets piping,\n # reference https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/websockets.html\n set bereq.http.connection = \"close\";\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this point.\n return (pipe);\n}\n\n# vcl_pass: Called upon entering pass mode. \n# In this mode, the request is passed on to the backend, and the backend's response is passed on to the client, \n# but is not entered into the cache.\n# Subsequent requests submitted over the same client connection are handled normally.\n# sub vcl_pass {\n# return (pass);\n# }\n\n# vcl_hash: You may call hash_data() on the data you would like to add to the hash.\n# Hash is used by Varnish to uniquely identify objects.\nsub vcl_hash {\n \/* Hash cookie data *\/\n # As requests with same URL and host can produce diferent results when issued with different cookies,\n # we need to store items hashed with the associated cookies. Note that cookies are already sanitized when we reach this point.\n if (req.http.Cookie) {\n \/* Include cookie in cache hash *\/\n hash_data(req.http.Cookie);\n }\n\n \/* Custom header hashing *\/\n # Empty in simple configs.\n # Example for caching differents object versions by device previously detected (when static content could also vary):\n # if (req.http.X-UA-Device) {\n # hash_data(req.http.X-UA-Device);\n # }\n # Example for caching diferent object versions by X-Forwarded-Proto, trying to be smart about what kind of request\n # could generate diffetent responses.\n # if (req.http.X-Forwarded-Proto &&\n # req.url !~ \"(?i)\\.(png|gif|jpeg|jpg|ico|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|svg|pdf)$\") {\n # hash_data(req.http.X-Forwarded-Proto);\n # }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (hash);\n# }\n\n# vcl_hit: Called after a cache lookup if the requested document was found in the cache.\nsub vcl_hit {\n \/* Check for Varnish special requests *\/ \n # Purge logic.\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/purging.html#http-purges\n # See https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged.\";\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hit {\n# return (deliver);\n# }\n\n# vcl_miss: Called after a cache lookup if the requested document was not found in the cache.\n# Its purpose is to decide whether or not to attempt to retrieve the document from the backend, and which backend to use.\nsub vcl_miss {\n \/* Check for Varnish special requests *\/ \n # Purge logic.\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/purging.html#http-purges\n # See https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged.\";\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_miss {\n# return (fetch);\n# }\n\n# vcl_fetch: Called after a document has been successfully retrieved from the backend.\nsub vcl_fetch {\n \/* Caching exceptions *\/\n # Varnish will cache objects with response codes: 200, 203, 300, 301, 302, 307, 404 & 410.\n # See https:\/\/www.varnish-software.com\/static\/book\/VCL_Basics.html#the-initial-value-of-beresp-ttl\n # Drupal's Imagecache module can return a 307 redirection to the requested url itself and, depending on Drupal's cache settings,\n # this could lead to a redirection loop being cached for a long time but also we want Varnish to shield a little the backend.\n # See http:\/\/drupal.org\/node\/1248010\n # See http:\/\/drupal.org\/node\/310656\n if (beresp.status == 307 &&\n \/* TO-DO: verify that this work better than 'req.url ~ \"imagecache\"' *\/\n beresp.http.Location == req.url &&\n beresp.ttl > 5s) {\n set beresp.ttl = 5s;\n set beresp.http.cache-control = \"max-age=5\";\n }\n\n \/* Enable grace mode. Related with our 9th stage on vcl_recv *\/\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/handling_misbehaving_servers.html#grace-mode\n set beresp.grace = 1h;\n\n \/* Enable saint mode. Related with our 9th stage on vcl_recv *\/\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/handling_misbehaving_servers.html#saint-mode\n if (beresp.status == 500) {\n set beresp.saintmode = 20s;\n # TO-DO: consider not restarting POST requests as seen on https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleSaintMode\n return(restart);\n }\n\n \/* Strip cookies from the following static file types for all users. Related with our 12th stage on vcl_recv *\/\n if (req.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|svg|pdf)(\\?[a-z0-9]+)?$\") {\n unset beresp.http.set-cookie;\n }\n\n \/* Gzip response *\/\n # Empty in simple configs\n # Use Varnish to Gzip respone, if suitable, before storing it on cache\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/phk\/gzip.html\n # if (! beresp.http.Content-Encoding &&\n # (beresp.http.content-type ~ \"text\" ||\n # beresp.http.content-type ~ \"application\/x-javascript\" ||\n # beresp.http.content-type ~ \"application\/javascript\" ||\n # beresp.http.content-type ~ \"application\/rss+xml\" ||\n # beresp.http.content-type ~ \"application\/xml\" ||\n # beresp.http.content-type ~ \"Application\/JSON\")\n # ) {\n # set beresp.do_gzip = true;\n # if ( beresp.http.Vary ) {\n # if ( ! beresp.http.Vary ~ \"Accept-Encoding\" ) {\n # set beresp.http.Vary = beresp.http.Vary + \",Accept-Encoding\";\n # }\n # } else {\n # set beresp.http.Vary = \"Accept-Encoding\";\n # }\n # }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # We can add the name of the backend that has processed the request:\n # set beresp.http.X-Backend = beresp.backend.name;\n # We can use a header to tell if the object was gziped by Varnish\n # if (beresp.do_gzip) {\n # set beresp.http.X-Varnish-Gzipped = \"yes\";\n # } else {\n # set beresp.http.X-Varnish-Gizipped = \"no\";\n # }\n # We can also add headers informing whether the object is cacheable or not and why.\n # https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Varnish3.0\n if (beresp.ttl <= 0s) {\n \/* Varnish determined the object was not cacheable *\/\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n } elsif (req.http.Cookie ~ \"(SESS|SSESS|NO_CACHE|OATMEAL|CHOCOLATECHIP)\") {\n \/* We don't wish to cache content for logged in users or with certain cookies. Related with our 9th stage on vcl_recv *\/\n set beresp.http.X-Cacheable = \"NO:Cookies\";\n # return(hit_for_pass);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n \/* We are respecting the Cache-Control=private header from the backend *\/\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n # return(hit_for_pass);\n } else {\n \/* Varnish determined the object was cacheable *\/\n set beresp.http.X-Cacheable = \"YES\";\n }\n\n \/* Further header manipulation *\/\n # Empty in simple configs.\n # We can also unset some headers to prevent information disclosure and save some cache space\n # unset beresp.http.Server;\n # unset beresp.http.X-Powered-By;\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_fetch {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Vary == \"*\") {\n# \/*\n# * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# *\/\n# set beresp.ttl = 120 s;\n# return (hit_for_pass);\n# }\n# return (deliver);\n# }\n\n# vcl_deliver: Called before an object is delivered to the client\nsub vcl_deliver {\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # Add whether the object is a cache hit or miss and the number of hits for the object.\n # https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Addingaheaderindicatinghitmiss\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n set resp.http.X-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Cache = \"MISS\";\n \/* Show the results of cookie sanitization *\/\n set resp.http.X-Cookie = req.http.Cookie;\n }\n # TO-DO: Add sick marker\n # Restart count\n if ( req.restarts > 0) {\n set resp.http.X-Restarts = req.restarts;\n }\n # Add the Varnish server hostname\n set resp.http.X-Varnish-Server = server.hostname;\n # If we have setted a custom header with device family detected we can show it:\n # if (req.http.X-UA-Device) {\n # set resp.http.X-UA-Device = req.http.X-UA-Device;\n # }\n # If we have recived a custom header with the protocol in the request we can show it:\n # if (req.http.X-Forwarded-Proto) {\n # set resp.http.X-Forwarded-Proto = req.http.X-Forwarded-Proto;\n # }\n\n \/* Vary header manipulation *\/\n # Empty in simple configs.\n # By example, if we are storing & serving diferent objects depending on User-Agent header we must set the correct Vary header:\n # if (resp.http.Vary) {\n # set resp.http.Vary = resp.http.Vary + \",User-Agent\";\n # } else {\n # set resp.http.Vary = \"User-Agent\";\n # }\n\n \/* Fake headers *\/\n # Empty in simple configs\n # We can fake server headers here, by example:\n # set resp.http.Server = \"Deep thought\";\n # set resp.http.X-Powered-By = \"BOFH\";\n # Or have some fun with headers:\n # See http:\/\/www.nextthing.org\/archives\/2005\/08\/07\/fun-with-http-headers\n # See http:\/\/royal.pingdom.com\/2012\/08\/15\/fun-and-unusual-http-response-headers\/\n # set resp.http.X-Thank-You = \"for bothering to look at my HTTP headers\";\n # set resp.http.X-Answer = \"42\";\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_deliver {\n# return (deliver);\n# }\n\n# vcl_error: Called when we hit an error, either explicitly or implicitly due to backend or internal errors.\nsub vcl_error {\n \/* Avoid DOS vulnerability CVE-2013-4484 *\/\n # See https:\/\/www.varnish-cache.org\/lists\/pipermail\/varnish-announce\/2013-October\/000686.html\n if (obj.status == 400 || obj.status == 413) {\n return(deliver);\n }\n\n \/* Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_error;\n\n \/* Try to restart request in case of failure *\/\n # Note that max_restarts defaults to 4\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if (obj.status == 503 && req.restarts < 4) {\n set obj.http.X-Restarts = req.restarts;\n return(restart);\n }\n\n \/* Set common headers for synthetic responses *\/\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n\n \/* HTTP Authentification client request *\/\n # Empty in simple configs. See http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* We're using error 200 for monitoring puposes *\/\n # Consider adding some analytics stuff to trace accesses\n if (obj.status == 200) {\n synthetic {\"\n <?xml version=\"1.0\" encoding=\"utf-8\"?>\n <!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n <html>\n <head>\n <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n <\/head>\n <body><h1>\"} + obj.status + \": \" + obj.response + {\"<\/h1><\/body>\n \"};\n return(deliver);\n }\n\n \/* Error page & refresh \/ redirections *\/\n # We have plenty of choices when we have to serve an error to the client, \n # from the default error page to javascript black magic or plain redirections.\n # Adding some external statistic javascript to track failures served to clients is strongly suggested.\n # We can't use external resources on synthetic content, everything must be inlined.\n # If we need to include images we can embed them in base64 encoding.\n # Here is the default error page for Varnish 3 (not so pretty)\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + obj.status + \" \" + obj.response + {\"<\/h1>\n <p>\"} + obj.response + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"};\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this point.\n return (deliver);\n}\n\n# vcl_init: Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n# sub vcl_init {\n# return (ok);\n# }\n\n# vcl_fini: Called when VCL is discarded only after all requests have exited the VCL. Typically used to clean up VMODs.\n# sub vcl_fini {\n# return (ok);\n# }\n","old_contents":"\/* Varnish 3 example config for Drupal 7 \/ Pressflow 6 & 7 *\/\n# Original source: https:\/\/github.com\/NITEMAN\/varnish-bites\/varnish4\/drupal-base.vcl\n# Copyright (c) 2015 Pedro Gonz\u00e1lez Serrano and individual contributors.\n# MIT License\n\n# Intended to be used both in simple production environments and with learning\/teaching purposes.\n# Loosely based on http:\/\/www.lullabot.com\/sites\/default\/files\/default_varnish3.vcl_.txt\n\n\/* Backend probes \/ healthchecks *\/\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#backend-probes\nprobe basic {\n \/* Only test that backend's IP serves content for '\/' *\/\n # This might be a too heavy probe\n # .url = \"\/\";\n \/* Only test that backend's IP has apache working *\/\n # Nginx would fail this probe with a default config\n .request =\n \"OPTIONS * HTTP\/1.1\"\n \"Host: *\"\n \"Connection: close\";\n .interval = 10s;\n .timeout = 2s;\n .window = 8;\n .threshold = 6;\n}\n\n\n\/* Backend definitions.*\/\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#backend-declarations\nbackend default {\n \/* Default backend on the same machine. WARNING: timeouts could be not big enought for certain POST request *\/\n .host = \"127.0.0.1\";\n .port = \"8008\";\n .connect_timeout = 60s;\n .first_byte_timeout = 60s;\n .between_bytes_timeout = 60s;\n .probe = basic;\n}\n\n\n\/* Directors. *\/\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#directors\n# Empty in simple configs\n\n\n\/* Access Control Lists *\/\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#acls\nacl purge_ban {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use '\"localhost\";' instead\n}\nacl allowed_monitors {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n}\n\n\n\/* Custom routines *\/\n# Empty in simple configs.\n# We can name subs with no restrictions but as a task can need several chunks of code in diferent states,\n# it's a good idea to identify what main sub will call each with a suffix.\n# \/* Example 301 client redirection removing \"www\" prefix from request *\/\n# sub perm_redirections_recv {\n# if ( req.http.host ~ \"^www.*$\" ) {\n# error 751 \"http:\/\/\" + regsub(req.http.host, \"^www\\.\", \"\") + req.url;\n# }\n# }\n# sub perm_redirections_error {\n# if (obj.status == 751) {\n# \/* Get new URL from the response *\/\n# set obj.http.Location = obj.response;\n# \/* Set HTTP 301 for permanent redirect *\/\n# set obj.status = 301;\n# return(deliver);\n# }\n# }\n\n\n\/* VCL logigc overrides *\/\n# Note that the built-in logic will be appended to our code if no return is performed before.\n# Built-in logic is included commented out right after our's for reference purposes in that cases.\n# See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleDefault\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#subroutines\n\n# vcl_recv: Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use.\nsub vcl_recv {\n \/* 0th: general bypass, general return & authorization checks *\/\n # Empty in simple configs.\n # Useful for debugging we can pipe or pass the request to default backend here to bypass completely Varnish.\n # return (pipe);\n # return (pass);\n # We can also return here a 200 Ok for network performance benchmarking.\n # error 200 \"Ok\";\n # Finally we can perform basic HTTP authentification here by example.\n # See http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* 1st: Check for Varnish special requests *\/ \n # Purge logic.\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/purging.html#http-purges\n # See https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if (req.request == \"PURGE\") {\n if (!client.ip ~ purge_ban) {\n error 405 \"Not allowed.\";\n }\n return (lookup);\n }\n # Ban logic. See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/purging.html#bans\n if (req.request == \"BAN\") {\n if (!client.ip ~ purge_ban) {\n error 405 \"Not allowed.\";\n }\n ban(\"req.http.host == \" + req.http.host +\n \"&& req.url == \" + req.url); \n error 200 \"Ban added\";\n }\n # Custom response implementation example in order to check that Varnish is working properly.\n # This is usefull for automatic monitoring with monit or when Varnish is behind another proxies like HAProxy.\n if (req.http.host == \"monitor.server.health\" && \n client.ip ~ allowed_monitors && \n (req.request == \"OPTIONS\" || req.request == \"GET\")) {\n error 200 \"Ok\";\n }\n\n \/* 2nd: Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_recv;\n # Here we can also enforce SSL when Varnish run behind some SSL termination point.\n\n \/* 3rd: Time for backend choice *\/\n # Empty in simple configs.\n\n \/* 4th: Set custom headers for backend like X-Forwarded-For (copied from built-in logic) *\/\n if (req.restarts == 0) {\n \/* See also vcl_pipe section *\/\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n \/* 5th: Bypass breakpoint 1 *\/\n # Useful for debugging we can now pipe or pass the request to backend with headers setted.\n # return (pipe);\n # return (pass);\n\n \/* 6th: Decide if we should deal with a request (mostly copied from built-in logic) *\/\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n\n \/* 7th: Access control for some URLs by ACL *\/\n # Empty in simple configs.\n # By example denial some URLs depending on client-ip, we'll need to define corresponding ACL 'internal'.\n # if (req.url ~ \"^\/(cron|install)\\.php$\" && !client.ip ~ internal) {\n # # Have Varnish throw the error directly.\n # error 403 \"Forbidden.\";\n # # Use a custom error page that you've defined in Drupal at the path \"404\".\n # # set req.url = \"\/403\";\n # }\n\n \/* 8th: Custom exceptions *\/\n # Host exception example:\n # if (req.http.host == \"ejemplo.exception.com\") {\n # return (pass);\n # }\n # Drupal exceptions, edit if we want to cache some AJAX\/AHAH request.\n # Add here filters for never cache URLs such as Payment Gateway's callbacks\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/ooyala\/ping$\" ||\n req.url ~ \"^\/admin\/build\/features\" ||\n req.url ~ \"^\/info\/.*$\" ||\n req.url ~ \"^\/flag\/.*$\" ||\n req.url ~ \"^.*\/ajax\/.*$\" ||\n req.url ~ \"^.*\/ahah\/.*$\") {\n \/* Do not cache these paths *\/\n return (pass);\n }\n # Pipe these paths directly to backend for streaming.\n if (req.url ~ \"^\/admin\/content\/backup_migrate\/export\") {\n return (pipe);\n }\n if (req.url ~ \"^\/system\/files\") {\n return (pipe);\n }\n\n \/* 9th: Enable grace mode *\/\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/handling_misbehaving_servers.html#grace-mode\n if (! req.backend.healthy) {\n \/* Use a longer grace period if all backends are down *\/\n set req.grace = 1h;\n \/* Use anonymous, cached pages if all backends are down. *\/\n unset req.http.Cookie;\n # TO-DO: Add sick marker\n } else {\n \/* Allow the backend to serve up stale content if it is responding slowly. *\/\n set req.grace = 30s;\n }\n\n \/* 10th: Deal with compression and the Accept-Encoding header *\/\n # Althought Varnish 3 handles gziped content itself by default, just to be sure we want to \n # remove Accept-Encoding for some compressed formats.\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/phk\/gzip.html#what-does-http-gzip-support-do\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/varnishd.html?highlight=http_gzip_support\n # See (for older configs) https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleNormalizeAcceptEncoding\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|mp4|flv|zip|rar)$\") {\n \/* Already compressed formats, no sense trying to compress again *\/\n remove req.http.Accept-Encoding;\n }\n }\n\n \/* 11th: Another header manipulation *\/\n # Empty in simple configs.\n # We could add here a custom header grouping User-agent families.\n\n \/* 12th: Cookie removal *\/\n # Always cache the following static file types for all users. \n # Use with care if we control certain downloads depending on cookies. \n # Be carefull also if appending .htm[l] via Drupal's clean URLs.\n if (req.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|svg|pdf)(\\?[a-z0-9]+)?$\") {\n unset req.http.Cookie;\n }\n # Remove all cookies that backend doesn't need to know about.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRemovingSomeCookies\n if (req.http.Cookie) {\n \/* Warning: Not a pretty solution *\/\n \/* Prefix header containing cookies with ';' *\/\n set req.http.Cookie = \";\" + req.http.Cookie;\n \/* Remove any spaces after ';' in header containing cookies *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n \/* Prefix cookies we want to preserve with one space *\/\n \/* 'S{1,2}ESS[a-z0-9]+' is the regular expression matching a Drupal session cookie ({1,2} added for HTTPS support) *\/\n \/* 'NO_CACHE' is usually set after a POST request to make sure issuing user see the results of his post *\/\n \/* 'OATMEAL' & 'CHOCOLATECHIP' are special cookies used by Drupal's Bakery module to provide Single Sign On *\/\n \/* Keep in mind we should add here any cookie that should reach the backend such as splahs avoiding cookies *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \";(S{1,2}ESS[a-z0-9]+|NO_CACHE|OATMEAL|CHOCOLATECHIP)=\", \"; \\1=\");\n \/* Remove from the header any single Cookie not prefixed with a space until next ';' separator *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n \/* Remove any '; ' at the start or the end of the header *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n\n if (req.http.Cookie == \"\") {\n \/* If there are no remaining cookies, remove the cookie header. *\/\n unset req.http.Cookie;\n }\n }\n\n \/* 13th: Session cookie & special cookies bypass caching stage *\/\n # As we might want to cache some requests, hashed with its cookies, \n # we don't simply pass when some cookies remain present at this point.\n # Instead we look for request that must be passed due to the cookie header.\n if (req.http.Cookie ~ \"SESS\" ||\n req.http.Cookie ~ \"SSESS\" ||\n req.http.Cookie ~ \"NO_CACHE\" ||\n req.http.Cookie ~ \"OATMEAL\" ||\n req.http.Cookie ~ \"CHOCOLATECHIP\") {\n return (pass);\n }\n\n \/* 14th: Bypass breakpoint 2 *\/\n # Useful for debugging we can now pipe or pass the request to backend to bypass cache.\n # return (pipe);\n # return (pass);\n\n \/* 15th: Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning a lookup.\n return (lookup);\n}\n\n# vcl_pipe: Called upon entering pipe mode.\n# In this mode, the request is passed on to the backend, \n# and any further data from either client or backend is passed on unaltered until either end closes the connection.\nsub vcl_pipe {\n \/* Prevent connection re-using for piped requests *\/\n # Note that only the first request to the backend will have X-Forwarded-For set.\n # As we use X-Forwarded-For and want to have it set for all requests, \n # we have to make sure connection won't be reused after the request.\n # It is not set by default as it might break some broken web applications, like IIS with NTLM authentication.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExamplePipe\n # TO-DO: make sure this is compatible with websockets piping,\n # reference https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/websockets.html\n set bereq.http.connection = \"close\";\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this point.\n return (pipe);\n}\n\n# vcl_pass: Called upon entering pass mode. \n# In this mode, the request is passed on to the backend, and the backend's response is passed on to the client, \n# but is not entered into the cache.\n# Subsequent requests submitted over the same client connection are handled normally.\n# sub vcl_pass {\n# return (pass);\n# }\n\n# vcl_hash: You may call hash_data() on the data you would like to add to the hash.\n# Hash is used by Varnish to uniquely identify objects.\nsub vcl_hash {\n \/* Hash cookie data *\/\n # As requests with same URL and host can produce diferent results when issued with different cookies,\n # we need to store items hashed with the associated cookies. Note that cookies are already sanitized when we reach this point.\n if (req.http.Cookie) {\n \/* Include cookie in cache hash *\/\n hash_data(req.http.Cookie);\n }\n\n \/* Custom header hashing *\/\n # Empty in simple configs.\n # Example for caching differents object versions by device previously detected (when static content could also vary):\n # if (req.http.X-UA-Device) {\n # hash_data(req.http.X-UA-Device);\n # }\n # Example for caching diferent object versions by X-Forwarded-Proto, trying to be smart about what kind of request\n # could generate diffetent responses.\n # if (req.http.X-Forwarded-Proto &&\n # req.url !~ \"(?i)\\.(png|gif|jpeg|jpg|ico|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|svg|pdf)$\") {\n # hash_data(req.http.X-Forwarded-Proto);\n # }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (hash);\n# }\n\n# vcl_hit: Called after a cache lookup if the requested document was found in the cache.\nsub vcl_hit {\n \/* Check for Varnish special requests *\/ \n # Purge logic.\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/purging.html#http-purges\n # See https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged.\";\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hit {\n# return (deliver);\n# }\n\n# vcl_miss: Called after a cache lookup if the requested document was not found in the cache.\n# Its purpose is to decide whether or not to attempt to retrieve the document from the backend, and which backend to use.\nsub vcl_miss {\n \/* Check for Varnish special requests *\/ \n # Purge logic.\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/purging.html#http-purges\n # See https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged.\";\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_miss {\n# return (fetch);\n# }\n\n# vcl_fetch: Called after a document has been successfully retrieved from the backend.\nsub vcl_fetch {\n \/* Caching exceptions *\/\n # Varnish will cache objects with response codes: 200, 203, 300, 301, 302, 307, 404 & 410.\n # See https:\/\/www.varnish-software.com\/static\/book\/VCL_Basics.html#the-initial-value-of-beresp-ttl\n # Drupal's Imagecache module can return a 307 redirection to the requested url itself and, depending on Drupal's cache settings,\n # this could lead to a redirection loop being cached for a long time but also we want Varnish to shield a little the backend.\n # See http:\/\/drupal.org\/node\/1248010\n # See http:\/\/drupal.org\/node\/310656\n if (beresp.status == 307 &&\n \/* TO-DO: verify that this work better than 'req.url ~ \"imagecache\"' *\/\n beresp.http.Location == req.url &&\n beresp.ttl > 5s) {\n set beresp.ttl = 5s;\n set beresp.http.cache-control = \"max-age=5\";\n }\n\n \/* Enable grace mode. Related with our 9th stage on vcl_recv *\/\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/handling_misbehaving_servers.html#grace-mode\n set beresp.grace = 1h;\n\n \/* Enable saint mode. Related with our 9th stage on vcl_recv *\/\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/handling_misbehaving_servers.html#saint-mode\n if (beresp.status == 500) {\n set beresp.saintmode = 20s;\n # TO-DO: consider not restarting POST requests as seen on https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleSaintMode\n return(restart);\n }\n\n \/* Strip cookies from the following static file types for all users. Related with our 12th stage on vcl_recv *\/\n if (req.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|svg|pdf)(\\?[a-z0-9]+)?$\") {\n unset beresp.http.set-cookie;\n }\n\n \/* Gzip response *\/\n # Empty in simple configs\n # Use Varnish to Gzip respone, if suitable, before storing it on cache\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/phk\/gzip.html\n # if (! beresp.http.Content-Encoding &&\n # (beresp.http.content-type ~ \"text\" ||\n # beresp.http.content-type ~ \"application\/x-javascript\" ||\n # beresp.http.content-type ~ \"application\/javascript\" ||\n # beresp.http.content-type ~ \"application\/rss+xml\" ||\n # beresp.http.content-type ~ \"application\/xml\" ||\n # beresp.http.content-type ~ \"Application\/JSON\")\n # ) {\n # set beresp.do_gzip = true;\n # if ( beresp.http.Vary ) {\n # if ( ! beresp.http.Vary ~ \"Accept-Encoding\" ) {\n # set beresp.http.Vary = beresp.http.Vary + \",Accept-Encoding\";\n # }\n # } else {\n # set beresp.http.Vary = \"Accept-Encoding\";\n # }\n # }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # We can add the name of the backend that has processed the request:\n # set beresp.http.X-Backend = beresp.backend.name;\n # We can use a header to tell if the object was gziped by Varnish\n # if (beresp.do_gzip) {\n # set beresp.http.X-Varnish-Gzipped = \"yes\";\n # } else {\n # set beresp.http.X-Varnish-Gizipped = \"no\";\n # }\n # We can also add headers informing whether the object is cacheable or not and why.\n # https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Varnish3.0\n if (beresp.ttl <= 0s) {\n \/* Varnish determined the object was not cacheable *\/\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n } elsif (req.http.Cookie ~ \"(SESS|SSESS|NO_CACHE|OATMEAL|CHOCOLATECHIP)\") {\n \/* We don't wish to cache content for logged in users or with certain cookies. Related with our 9th stage on vcl_recv *\/\n set beresp.http.X-Cacheable = \"NO:Cookies\";\n # return(hit_for_pass);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n \/* We are respecting the Cache-Control=private header from the backend *\/\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n # return(hit_for_pass);\n } else {\n \/* Varnish determined the object was cacheable *\/\n set beresp.http.X-Cacheable = \"YES\";\n }\n\n \/* Further header manipulation *\/\n # Empty in simple configs.\n # We can also unset some headers to prevent information disclosure and save some cache space\n # unset beresp.http.Server;\n # unset beresp.http.X-Powered-By;\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_fetch {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Vary == \"*\") {\n# \/*\n# * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# *\/\n# set beresp.ttl = 120 s;\n# return (hit_for_pass);\n# }\n# return (deliver);\n# }\n\n# vcl_deliver: Called before an object is delivered to the client\nsub vcl_deliver {\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # Add whether the object is a cache hit or miss and the number of hits for the object.\n # https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Addingaheaderindicatinghitmiss\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n set resp.http.X-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Cache = \"MISS\";\n \/* Show the results of cookie sanitization *\/\n set resp.http.X-Cookie = req.http.Cookie;\n }\n # TO-DO: Add sick marker\n # Restart count\n if ( req.restarts > 0) {\n set resp.http.X-Restarts = req.restarts;\n }\n # Add the Varnish server hostname\n set resp.http.X-Varnish-Server = server.hostname;\n # If we have setted a custom header with device family detected we can show it:\n # if (req.http.X-UA-Device) {\n # set resp.http.X-UA-Device = req.http.X-UA-Device;\n # }\n # If we have recived a custom header with the protocol in the request we can show it:\n # if (req.http.X-Forwarded-Proto) {\n # set resp.http.X-Forwarded-Proto = req.http.X-Forwarded-Proto;\n # }\n\n \/* Vary header manipulation *\/\n # Empty in simple configs.\n # By example, if we are storing & serving diferent objects depending on User-Agent header we must set the correct Vary header:\n # if (resp.http.Vary) {\n # set resp.http.Vary = resp.http.Vary + \",User-Agent\";\n # } else {\n # set resp.http.Vary = \"User-Agent\";\n # }\n\n \/* Fake headers *\/\n # Empty in simple configs\n # We can fake server headers here, by example:\n # set resp.http.Server = \"Deep thought\";\n # set resp.http.X-Powered-By = \"BOFH\";\n # Or have some fun with headers:\n # See http:\/\/www.nextthing.org\/archives\/2005\/08\/07\/fun-with-http-headers\n # See http:\/\/royal.pingdom.com\/2012\/08\/15\/fun-and-unusual-http-response-headers\/\n # set resp.http.X-Thank-You = \"for bothering to look at my HTTP headers\";\n # set resp.http.X-Answer = \"42\";\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_deliver {\n# return (deliver);\n# }\n\n# vcl_error: Called when we hit an error, either explicitly or implicitly due to backend or internal errors.\nsub vcl_error {\n \/* Avoid DOS vulnerability CVE-2013-4484 *\/\n # See https:\/\/www.varnish-cache.org\/lists\/pipermail\/varnish-announce\/2013-October\/000686.html\n if (obj.status == 400 || obj.status == 413) {\n return(deliver);\n }\n\n \/* Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_error;\n\n \/* Try to restart request in case of failure *\/\n # Note that max_restarts defaults to 4\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if (obj.status == 503 && req.restarts < 4) {\n set obj.http.X-Restarts = req.restarts;\n return(restart);\n }\n\n \/* Set common headers for synthetic responses *\/\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n\n \/* HTTP Authentification client request *\/\n # Empty in simple configs. See http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* We're using error 200 for monitoring puposes *\/\n # Consider adding some analytics stuff to trace accesses\n if (obj.status == 200) {\n synthetic {\"\n <?xml version=\"1.0\" encoding=\"utf-8\"?>\n <!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n <html>\n <head>\n <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n <\/head>\n <body><h1>\"} + obj.status + \": \" + obj.response + {\"<\/h1><\/body>\n \"};\n return(deliver);\n }\n\n \/* Error page & refresh \/ redirections *\/\n # We have plenty of choices when we have to serve an error to the client, \n # from the default error page to javascript black magic or plain redirections.\n # Adding some external statistic javascript to track failures served to clients is strongly suggested.\n # We can't use external resources on synthetic content, everything must be inlined.\n # If we need to include images we can embed them in base64 encoding.\n # Here is the default error page for Varnish 3 (not so pretty)\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + obj.status + \" \" + obj.response + {\"<\/h1>\n <p>\"} + obj.response + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"};\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this point.\n return (deliver);\n}\n\n# vcl_init: Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n# sub vcl_init {\n# return (ok);\n# }\n\n# vcl_fini: Called when VCL is discarded only after all requests have exited the VCL. Typically used to clean up VMODs.\n# sub vcl_fini {\n# return (ok);\n# }\n","returncode":0,"stderr":"","license":"unknown","lang":"VCL"} {"commit":"6d8b6f0b567fdd5d8bc3d2558f4073b9e6bb492d","subject":"Configuration for Varnish.","message":"Configuration for Varnish.\n","repos":"cebartling\/reverse-proxy-url-rewrite-experiment,cebartling\/reverse-proxy-url-rewrite-experiment","old_file":"proxy-servers\/varnish\/default.vcl","new_file":"proxy-servers\/varnish\/default.vcl","new_contents":"# This is a Varnish 4.x VCL file\nvcl 4.0;\n\n# Rails server\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"3000\";\n}\n\n# Sinatra server\n# backend sinatra {\n# .host = \"127.0.0.1\";\n# .port = \"4567\";\n# }\n\n# Node.js server\n# backend nodejs {\n# .host = \"127.0.0.1\";\n# .port = \"5678\";\n# }\n\n# Handle the HTTP request received by the client\nsub vcl_recv {\n\tif (req.url ~ \"^\/api\/v1\") {\n set req.backend_hint = default;\n }\n\n\t# if (req.url ~ \"^\/api\/v1\/products\") {\n\t# set req.backend_hint = sinatra;\n\t# } else if (req.url ~ \"^\/api\/v2\/products\") {\n\t# set req.backend_hint = sinatra;\n\t# } else {\n\t# set req.backend_hint = default;\n\t# }\n\n\n\t# if (req.url ~ \"^\/api\/v1\/products\") {\n\t# set req.backend_hint = sinatra;\n\t# } else if (req.url ~ \"^\/api\/v2\/products\") {\n\t# set req.backend_hint = sinatra;\n\t# } else if (req.url ~ \"^\/api\/v3\/products\") {\n\t# set req.backend_hint = nodejs;\n\t# } else {\n\t# set req.backend_hint = default;\n\t# }\n}\n\n","old_contents":"# This is a Varnish 4.x VCL file\nvcl 4.0;\n\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"3000\";\n}\n\nbackend sinatra {\n .host = \"127.0.0.1\";\n .port = \"4567\";\n}\n\nbackend nodejs {\n .host = \"127.0.0.1\";\n .port = \"5678\";\n}\n\n# Handle the HTTP request received by the client\nsub vcl_recv {\n\tif (req.url ~ \"^\/api\/v1\/products\") {\n set req.backend_hint = sinatra;\n } else if (req.url ~ \"^\/api\/v2\/products\") {\n set req.backend_hint = sinatra;\n } else if (req.url ~ \"^\/api\/v3\/products\") {\n set req.backend_hint = nodejs;\n } else {\n set req.backend_hint = default;\n }\n}\n\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"521122ea8611de83b9ba8df3b091f9c4f38c3676","subject":"Add varnish configuration for caching http and https requests differently","message":"Add varnish configuration for caching http and https requests differently\n","repos":"andreicristianpetcu\/alaveteli,nzherald\/alaveteli,hasadna\/alaveteli,hasadna\/alaveteli,datauy\/alaveteli,obshtestvo\/alaveteli-bulgaria,Br3nda\/alaveteli,4bic\/alaveteli,andreicristianpetcu\/alaveteli_old,andreicristianpetcu\/alaveteli_old,TEDICpy\/QueremoSaber,nzherald\/alaveteli,10layer\/alaveteli,TEDICpy\/QueremoSaber,10layer\/alaveteli,obshtestvo\/alaveteli-bulgaria,Br3nda\/alaveteli,4bic\/alaveteli,4bic\/alaveteli,petterreinholdtsen\/alaveteli,hasadna\/alaveteli,TEDICpy\/QueremoSaber,10layer\/alaveteli,andreicristianpetcu\/alaveteli_old,petterreinholdtsen\/alaveteli,codeforcroatia\/alaveteli,andreicristianpetcu\/alaveteli,codeforcroatia\/alaveteli,hasadna\/alaveteli,hasadna\/alaveteli,andreicristianpetcu\/alaveteli,codeforcroatia\/alaveteli,TEDICpy\/QueremoSaber,andreicristianpetcu\/alaveteli,petterreinholdtsen\/alaveteli,andreicristianpetcu\/alaveteli_old,andreicristianpetcu\/alaveteli_old,nzherald\/alaveteli,Br3nda\/alaveteli,nzherald\/alaveteli,petterreinholdtsen\/alaveteli,datauy\/alaveteli,codeforcroatia\/alaveteli,petterreinholdtsen\/alaveteli,obshtestvo\/alaveteli-bulgaria,obshtestvo\/alaveteli-bulgaria,andreicristianpetcu\/alaveteli,Br3nda\/alaveteli,4bic\/alaveteli,nzherald\/alaveteli,obshtestvo\/alaveteli-bulgaria,TEDICpy\/QueremoSaber,4bic\/alaveteli,hasadna\/alaveteli,datauy\/alaveteli,Br3nda\/alaveteli","old_file":"config\/varnish-alaveteli.vcl","new_file":"config\/varnish-alaveteli.vcl","new_contents":"# This is a sample VCL configuration file for varnish running in front\n# of Alaveteli. See the vcl(7) man page for details on VCL syntax and\n# semantics.\n\n# \n# Default backend definition. Set this to point to your content\n# server. In this case, apache + Passenger running on port 80\n# \n\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"80\";\n .connect_timeout = 600s;\n .first_byte_timeout = 600s;\n .between_bytes_timeout = 600s;\n}\n\n\/\/ set the servers alaveteli can issue a purge from\nacl purge {\n \"localhost\";\n \"127.0.0.1\";\n}\n\nsub vcl_recv {\n\n # Handle IPv6\n if (req.http.Host ~ \"^ipv6.*\") {\n set req.http.host = regsub(req.http.host, \"^ipv6\\.(.*)\",\"www\\.\\1\");\n }\n\n\n # Sanitise X-Forwarded-For...\n remove req.http.X-Forwarded-For;\n set req.http.X-Forwarded-For = client.ip;\n \n # Remove Google Analytics, has_js, and last-seen cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"(^|;\\s*)(__[a-z]+|has_js|has_seen_country_message|seen_foi2)=[^;]*\", \"\");\n\n # Normalize the Accept-Encoding header\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|flv|pdf|ico)$\") {\n # No point in compressing these\n remove req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n # unknown algorithm\n remove req.http.Accept-Encoding;\n }\n }\n \n # Ignore empty cookies\n if (req.http.Cookie ~ \"^\\s*$\") {\n remove req.http.Cookie;\n }\n \n if (req.request != \"GET\" &&\n req.request != \"HEAD\" && \n req.request != \"POST\" &&\n req.request != \"PUT\" &&\n req.request != \"PURGE\" &&\n req.request != \"DELETE\" ) {\n # We don't allow any other methods.\n error 405 \"Method Not Allowed\";\n }\n\n if (req.request != \"GET\" && req.request != \"HEAD\" && req.request != \"PURGE\") {\n \/* We only deal with GET and HEAD by default, the rest get passed direct to backend *\/\n return (pass);\n }\n \n # Ignore Cookies on images...\n if (req.url ~ \"\\.(png|gif|jpg|jpeg|swf|css|js|rdf|ico|txt)(\\?.*|)$\") {\n remove req.http.Cookie;\n return (lookup);\n }\n\n if (req.http.Authorization || req.http.Cookie) {\n return (pass);\n }\n # Let's have a little grace\n set req.grace = 30s;\n # Handle PURGE requests\n if (req.request == \"PURGE\") {\n if (!client.ip ~ purge) {\n error 405 \"Not allowed.\";\n }\n\n # For an explanation of the followng roundabout way of defining\n # ban lists, see\n # http:\/\/kristianlyng.wordpress.com\/2010\/07\/28\/smart-bans-with-varnish\/\n\n # XXX in Varnish 2.x, the following would be\n # purge(\"obj.http.x-url ~ \" req.url);\n ban(\"obj.http.x-url ~ \" + req.url);\n error 200 \"Banned\";\n }\n return (lookup);\n}\n\nsub vcl_fetch {\n set beresp.http.x-url = req.url;\n if (req.url ~ \"\\.(png|gif|jpg|jpeg|swf|css|js|rdf|ico|txt)(\\?.*|)$\") {\n # Ignore backend headers..\n remove beresp.http.set-Cookie;\n set beresp.ttl = 3600s;\n return (deliver);\n }\n\n if (beresp.status == 404 || beresp.status == 301 || beresp.status == 500) {\n set beresp.ttl = 1m;\n return (deliver);\n }\n}\n\n# We need to separately cache requests originating via http and via https\n# since we are serving very slightly different content in each case\n\n# Varnish 2.x version of vcl_hash\n#sub vcl_hash {\n# set req.hash += req.url;\n# if (req.http.host) {\n# set req.hash += req.http.host;\n# } else {\n# set req.hash += server.ip;\n# }\n#\n# # Include the X-Forward-Proto header, since we want to treat HTTPS\n# # requests differently, and make sure this header is always passed\n# # properly to the backend server.\n# if (req.http.X-Forwarded-Proto) {\n# set req.hash += req.http.X-Forwarded-Proto;\n# }\n#\n# return (hash);\n#}\n\n# Varnish 3 version of vcl_hash\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n\n # Include the X-Forward-Proto header, since we want to treat HTTPS\n # requests differently, and make sure this header is always passed\n # properly to the backend server.\n if (req.http.X-Forwarded-Proto) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n\n return (hash);\n}\n","old_contents":"# This is a sample VCL configuration file for varnish running in front\n# of Alaveteli. See the vcl(7) man page for details on VCL syntax and\n# semantics.\n\n# \n# Default backend definition. Set this to point to your content\n# server. In this case, apache + Passenger running on port 80\n# \n\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"80\";\n .connect_timeout = 600s;\n .first_byte_timeout = 600s;\n .between_bytes_timeout = 600s;\n}\n\n\/\/ set the servers alaveteli can issue a purge from\nacl purge {\n \"localhost\";\n \"127.0.0.1\";\n}\n\nsub vcl_recv {\n\n # Handle IPv6\n if (req.http.Host ~ \"^ipv6.*\") {\n set req.http.host = regsub(req.http.host, \"^ipv6\\.(.*)\",\"www\\.\\1\");\n }\n\n\n # Sanitise X-Forwarded-For...\n remove req.http.X-Forwarded-For;\n set req.http.X-Forwarded-For = client.ip;\n \n # Remove Google Analytics, has_js, and last-seen cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"(^|;\\s*)(__[a-z]+|has_js|has_seen_country_message|seen_foi2)=[^;]*\", \"\");\n\n # Normalize the Accept-Encoding header\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|flv|pdf|ico)$\") {\n # No point in compressing these\n remove req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n # unknown algorithm\n remove req.http.Accept-Encoding;\n }\n }\n \n # Ignore empty cookies\n if (req.http.Cookie ~ \"^\\s*$\") {\n remove req.http.Cookie;\n }\n \n if (req.request != \"GET\" &&\n req.request != \"HEAD\" && \n req.request != \"POST\" &&\n req.request != \"PUT\" &&\n req.request != \"PURGE\" &&\n req.request != \"DELETE\" ) {\n # We don't allow any other methods.\n error 405 \"Method Not Allowed\";\n }\n\n if (req.request != \"GET\" && req.request != \"HEAD\" && req.request != \"PURGE\") {\n \/* We only deal with GET and HEAD by default, the rest get passed direct to backend *\/\n return (pass);\n }\n \n # Ignore Cookies on images...\n if (req.url ~ \"\\.(png|gif|jpg|jpeg|swf|css|js|rdf|ico|txt)(\\?.*|)$\") {\n remove req.http.Cookie;\n return (lookup);\n }\n\n if (req.http.Authorization || req.http.Cookie) {\n return (pass);\n }\n # Let's have a little grace\n set req.grace = 30s;\n # Handle PURGE requests\n if (req.request == \"PURGE\") {\n if (!client.ip ~ purge) {\n error 405 \"Not allowed.\";\n }\n\n # For an explanation of the followng roundabout way of defining\n # ban lists, see\n # http:\/\/kristianlyng.wordpress.com\/2010\/07\/28\/smart-bans-with-varnish\/\n\n # XXX in Varnish 2.x, the following would be\n # purge(\"obj.http.x-url ~ \" req.url);\n ban(\"obj.http.x-url ~ \" + req.url);\n error 200 \"Banned\";\n }\n return (lookup);\n}\n\nsub vcl_fetch {\n set beresp.http.x-url = req.url;\n if (req.url ~ \"\\.(png|gif|jpg|jpeg|swf|css|js|rdf|ico|txt)(\\?.*|)$\") {\n # Ignore backend headers..\n remove beresp.http.set-Cookie;\n set beresp.ttl = 3600s;\n return (deliver);\n }\n\n if (beresp.status == 404 || beresp.status == 301 || beresp.status == 500) {\n set beresp.ttl = 1m;\n return (deliver);\n }\n}\n\n","returncode":0,"stderr":"","license":"agpl-3.0","lang":"VCL"} {"commit":"e60c783916c1746a9e6c9ed1e3f1c6b7297b6b7a","subject":"Added X-Language and X-Province headers to response.","message":"Added X-Language and X-Province headers to response.\n","repos":"gotofbi\/ansible-varnish,kkwoker\/ansible-varnish,noqcks\/ansible-varnish,telusdigital\/ansible-varnish,gotofbi\/ansible-varnish,colstrom\/ansible-varnish,killerwails\/ansible-varnish,killerwails\/ansible-varnish","old_file":"templates\/etc\/varnish\/default.vcl","new_file":"templates\/etc\/varnish\/default.vcl","new_contents":"vcl 4.0;\n\nimport directors;\nimport std;\n\n###\n# Varnish Documentation\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-built-in-subs.html\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/reference\/vcl.html\n##\n\n{% for backend in varnish_backend_hosts %}\nbackend application_{{ loop.index }} {\n .host = \"{{ backend }}\";\n .port = \"{{ varnish_backend_port }}\";\n{% if varnish_health_checks_enabled %}\n .probe = {\n .url = \"{{ varnish_health_check_url }}\";\n .interval = {{ varnish_health_check_interval }};\n .timeout = {{ varnish_health_check_timeout }};\n .window = {{ varnish_health_check_window }};\n .threshold = {{ varnish_health_check_threshold }};\n }\n{% endif %}\n}\n{% endfor %}\n\n###\n# vcl_init\n# Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n###\n# The vcl_init subroutine may terminate with calling return() with one of the following keywords:\n#\n# ok\n# Normal return, VCL continues loading.\n##\n\nsub vcl_init {\n new application = directors.round_robin();\n{% for backend in varnish_backend_hosts %}\n application.add_backend(application_{{ loop.index }});\n{% endfor %}\n}\n\n###\n# vcl_recv\n# Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use. \n# It is also used to modify the request\n###\n# The vcl_recv subroutine may terminate with calling return() on one of the following keywords:\n#\n# synth(status code, reason)\n# Return a synthetic object with the specified status code to the client and abandon the request.\n# pass\n# Switch to pass mode. Control will eventually pass to vcl_pass.\n# pipe\n# Switch to pipe mode. Control will eventually pass to vcl_pipe.\n# hash\n# Continue processing the object as a potential candidate for caching. Passes the control over to vcl_hash.\n# purge\n# Purge the object and it's variants. Control passes through vcl_hash to vcl_purge.\n#\n\nsub vcl_recv {\n set req.backend_hint = application.backend();\n\n ###\n # Avoid processing uncacheable requests\n ###\n\n if (req.http.Authorization) {\n return (pass);\n }\n\n ###\n # Inject X-Forwarded-For headers, but only once.\n ###\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n{% if varnish_header_sanitization_enabled %}\n ###\n # Header Sanitization\n ###\n\n{% if varnish_discards_port_from_host_header %}\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n{% endif %}\n\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_enabled %}\n ###\n # Cookie Sanitization\n ###\n\n ### Google Analytics\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n\n ### Quantcast\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n \n ### AddThis\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n\n ### General Cleanup\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n{% endif %}\n\n{% if varnish_uri_sanitization_enabled %}\n ###\n # URI Sanitization\n ###\n \n if (req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=\") {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n{% endif %}\n\n{% if varnish_workaround_telusdotcom_browser_profile %}\n ###\n # Workaround for BrowserProfile and Language\/Region Detection on TELUS.com\n ###\n\n if (req.http.Cookie ~ \"BrowserProfile\") {\n set req.http.X-Language = regsuball(req.http.Cookie, \"language..:\\\\.(.*)\\\\.,\", \"\\1\");\n set req.http.X-Province = regsuball(req.http.Cookie, \"region..:\\\\.(.*)\\\\.,\", \"\\1\");\n } else {\n if (req.http.Cookie ~ \"lang=\") {\n set req.http.X-Language = regsuball(req.http.Cookie, \"lang=(.*);\", \"\\1\");\n } else {\n set req.http.X-Language = \"en\";\n }\n\n if (req.http.Cookie ~ \"prov=\") {\n set req.http.X-Province = regsuball(req.http.Cookie, \"prov=(.*);\", \"\\1\");\n } else {\n set req.http.X-Province = \"BC\";\n }\n }\n\n if (req.url ~ \"\/(en|fr)\/\") {\n if (req.url ~ \"\/en\/\" && req.http.X-Language != \"en\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Language)\";\n return(pass);\n }\n if (req.url ~ \"\/fr\/\" && req.http.X-Language != \"fr\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Language)\";\n return(pass);\n }\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Language)\";\n return(pass);\n }\n\n if (req.url ~ \"\/(ab|bc|mb|nb|nl|ns|nt|nu|on|pe|qc|sk|yt)\/\") {\n {% for province in ['ab', 'bc', 'mb', 'nb', 'nl', 'ns', 'nt', 'nu', 'on', 'pe', 'qc', 'sk', 'yt'] %}\n if (req.url ~ \"{{ province }}\" && req.http.X-Province != \"{{ province }}\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Province)\";\n return(pass);\n }\n {% endfor %}\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Province)\";\n return(pass);\n }\n{% endif %}\n\n{% if varnish_blacklist_enabled %}\n if ((req.url ~ \"{{ varnish_blacklist_regexp }}\")) {\n set req.http.X-Passthrough-Reason = \"Path in Blacklist\";\n return(pass);\n } else {\n{% if varnish_discards_client_cookies %}\n unset req.http.Cookie;\n{% endif %}\n }\n{% endif %}\n\n}\n\n###\n# vcl_hit\n# Called when a cache lookup is successful.\n###\n# The vcl_hit subroutine may terminate with calling return() with one of the following keywords:\n#\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n# deliver\n# Deliver the object. Control passes to vcl_deliver.\n# synth(status code, reason)\n# Return the specified status code to the client and abandon the request.\n###\n\nsub vcl_hit {\n if (obj.ttl > 0s) {\n return (deliver);\n }\n{% if varnish_health_checks_enabled %}\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (fetch);\n }\n{% else %}\n if (obj.ttl + obj.grace > 0s) {\n return (deliver);\n }\n\n return (fetch);\n{% endif %}\n}\n\n###\n# vcl_backend_response\n# Called after the response headers has been successfully retrieved from the backend.\n###\n# The vcl_backend_response subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Possibly insert the object into the cache, then deliver it to the Control will eventually pass to vcl_deliver.\n# abandon\n# Abandon the backend request and generates an error.\n# retry\n# Retry the backend transaction. Increases the retries counter. If the number of retries is higher than max_retries Varnish emits a guru meditation error.\n###\n\nsub vcl_backend_response {\n{% if varnish_workaround_telusdotcom_browser_profile %}\n if (bereq.http.X-Language) {\n set bereq.http.X-Language;\n }\n if (bereq.http.X-Province) {\n set bereq.http.X-Province;\n }\n{% endif %}\n\n{% if varnish_blacklist_enabled %}\n if (bereq.url ~ \"{{ varnish_blacklist_regexp }}\") {\n set beresp.http.X-Cacheable = \"NO:Path in Blacklist\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n if (bereq.http.X-Passthrough-Reason) {\n set beresp.http.X-Passthrough-Reason = bereq.http.X-Passthrough-Reason;\n return(deliver);\n } else {\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n }\n }\n{% else %}\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n{% endif %}\n\n{% if varnish_cache_diagnostics_enabled %}\n if (bereq.http.Cookie) {\n set beresp.http.X-Cacheable = \"NO:Cookie in Request\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO:Set-Cookie in Response\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.X-No-Cache) {\n set beresp.http.X-Cacheable = \"NO:X-No-Cache\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.ttl <= 0s) {\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n{% endif %}\n\n set beresp.grace = {{ varnish_grace_period }};\n}\n\n###\n# vcl_deliver\n# Called before a cached object is delivered to the client.\n###\n# The vcl_deliver subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Deliver the object to the client.\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n###\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n","old_contents":"vcl 4.0;\n\nimport directors;\nimport std;\n\n###\n# Varnish Documentation\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-built-in-subs.html\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/reference\/vcl.html\n##\n\n{% for backend in varnish_backend_hosts %}\nbackend application_{{ loop.index }} {\n .host = \"{{ backend }}\";\n .port = \"{{ varnish_backend_port }}\";\n{% if varnish_health_checks_enabled %}\n .probe = {\n .url = \"{{ varnish_health_check_url }}\";\n .interval = {{ varnish_health_check_interval }};\n .timeout = {{ varnish_health_check_timeout }};\n .window = {{ varnish_health_check_window }};\n .threshold = {{ varnish_health_check_threshold }};\n }\n{% endif %}\n}\n{% endfor %}\n\n###\n# vcl_init\n# Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n###\n# The vcl_init subroutine may terminate with calling return() with one of the following keywords:\n#\n# ok\n# Normal return, VCL continues loading.\n##\n\nsub vcl_init {\n new application = directors.round_robin();\n{% for backend in varnish_backend_hosts %}\n application.add_backend(application_{{ loop.index }});\n{% endfor %}\n}\n\n###\n# vcl_recv\n# Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use. \n# It is also used to modify the request\n###\n# The vcl_recv subroutine may terminate with calling return() on one of the following keywords:\n#\n# synth(status code, reason)\n# Return a synthetic object with the specified status code to the client and abandon the request.\n# pass\n# Switch to pass mode. Control will eventually pass to vcl_pass.\n# pipe\n# Switch to pipe mode. Control will eventually pass to vcl_pipe.\n# hash\n# Continue processing the object as a potential candidate for caching. Passes the control over to vcl_hash.\n# purge\n# Purge the object and it's variants. Control passes through vcl_hash to vcl_purge.\n#\n\nsub vcl_recv {\n set req.backend_hint = application.backend();\n\n ###\n # Avoid processing uncacheable requests\n ###\n\n if (req.http.Authorization) {\n return (pass);\n }\n\n ###\n # Inject X-Forwarded-For headers, but only once.\n ###\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n{% if varnish_header_sanitization_enabled %}\n ###\n # Header Sanitization\n ###\n\n{% if varnish_discards_port_from_host_header %}\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n{% endif %}\n\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_enabled %}\n ###\n # Cookie Sanitization\n ###\n\n ### Google Analytics\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n\n ### Quantcast\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n \n ### AddThis\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n\n ### General Cleanup\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n{% endif %}\n\n{% if varnish_uri_sanitization_enabled %}\n ###\n # URI Sanitization\n ###\n \n if (req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=\") {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n{% endif %}\n\n{% if varnish_workaround_telusdotcom_browser_profile %}\n ###\n # Workaround for BrowserProfile and Language\/Region Detection on TELUS.com\n ###\n\n if (req.http.Cookie ~ \"BrowserProfile\") {\n set req.http.X-Language = regsuball(req.http.Cookie, \"language..:\\\\.(.*)\\\\.,\", \"\\1\");\n set req.http.X-Province = regsuball(req.http.Cookie, \"region..:\\\\.(.*)\\\\.,\", \"\\1\");\n } else {\n if (req.http.Cookie ~ \"lang=\") {\n set req.http.X-Language = regsuball(req.http.Cookie, \"lang=(.*);\", \"\\1\");\n } else {\n set req.http.X-Language = \"en\";\n }\n\n if (req.http.Cookie ~ \"prov=\") {\n set req.http.X-Province = regsuball(req.http.Cookie, \"prov=(.*);\", \"\\1\");\n } else {\n set req.http.X-Province = \"BC\";\n }\n }\n\n if (req.url ~ \"\/(en|fr)\/\") {\n if (req.url ~ \"\/en\/\" && req.http.X-Language != \"en\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Language)\";\n return(pass);\n }\n if (req.url ~ \"\/fr\/\" && req.http.X-Language != \"fr\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Language)\";\n return(pass);\n }\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Language)\";\n return(pass);\n }\n\n if (req.url ~ \"\/(ab|bc|mb|nb|nl|ns|nt|nu|on|pe|qc|sk|yt)\/\") {\n {% for province in ['ab', 'bc', 'mb', 'nb', 'nl', 'ns', 'nt', 'nu', 'on', 'pe', 'qc', 'sk', 'yt'] %}\n if (req.url ~ \"{{ province }}\" && req.http.X-Province != \"{{ province }}\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Province)\";\n return(pass);\n }\n {% endfor %}\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Province)\";\n return(pass);\n }\n{% endif %}\n\n{% if varnish_blacklist_enabled %}\n if ((req.url ~ \"{{ varnish_blacklist_regexp }}\")) {\n set req.http.X-Passthrough-Reason = \"Path in Blacklist\";\n return(pass);\n } else {\n{% if varnish_discards_client_cookies %}\n unset req.http.Cookie;\n{% endif %}\n }\n{% endif %}\n\n}\n\n###\n# vcl_hit\n# Called when a cache lookup is successful.\n###\n# The vcl_hit subroutine may terminate with calling return() with one of the following keywords:\n#\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n# deliver\n# Deliver the object. Control passes to vcl_deliver.\n# synth(status code, reason)\n# Return the specified status code to the client and abandon the request.\n###\n\nsub vcl_hit {\n if (obj.ttl > 0s) {\n return (deliver);\n }\n{% if varnish_health_checks_enabled %}\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (fetch);\n }\n{% else %}\n if (obj.ttl + obj.grace > 0s) {\n return (deliver);\n }\n\n return (fetch);\n{% endif %}\n}\n\n###\n# vcl_backend_response\n# Called after the response headers has been successfully retrieved from the backend.\n###\n# The vcl_backend_response subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Possibly insert the object into the cache, then deliver it to the Control will eventually pass to vcl_deliver.\n# abandon\n# Abandon the backend request and generates an error.\n# retry\n# Retry the backend transaction. Increases the retries counter. If the number of retries is higher than max_retries Varnish emits a guru meditation error.\n###\n\nsub vcl_backend_response {\n{% if varnish_blacklist_enabled %}\n if (bereq.url ~ \"{{ varnish_blacklist_regexp }}\") {\n set beresp.http.X-Cacheable = \"NO:Path in Blacklist\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n if (bereq.http.X-Passthrough-Reason) {\n set beresp.http.X-Passthrough-Reason = bereq.http.X-Passthrough-Reason;\n return(deliver);\n } else {\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n }\n }\n{% else %}\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n{% endif %}\n\n{% if varnish_cache_diagnostics_enabled %}\n if (bereq.http.Cookie) {\n set beresp.http.X-Cacheable = \"NO:Cookie in Request\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO:Set-Cookie in Response\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.X-No-Cache) {\n set beresp.http.X-Cacheable = \"NO:X-No-Cache\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.ttl <= 0s) {\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n{% endif %}\n\n set beresp.grace = {{ varnish_grace_period }};\n}\n\n###\n# vcl_deliver\n# Called before a cached object is delivered to the client.\n###\n# The vcl_deliver subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Deliver the object to the client.\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n###\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"6672163efd5e710d663b2e2f3aaf71cc335d96f9","subject":"Use Cookie accessors to simplify VCL","message":"Use Cookie accessors to simplify VCL\n","repos":"fastly\/fastly-magento,fastly\/fastly-magento,fastly\/fastly-magento,fastly\/fastly-magento","old_file":"app\/code\/community\/Fastly\/CDN\/etc\/default.vcl","new_file":"app\/code\/community\/Fastly\/CDN\/etc\/default.vcl","new_contents":"###############################################################################\n#\n# Fastly CDN for Magento\n#\n# NOTICE OF LICENSE\n#\n# This source file is subject to the Fastly CDN for Magento End User License\n# Agreement that is bundled with this package in the file LICENSE_FASTLY_CDN.txt.\n#\n# @copyright Copyright (c) 2015 Fastly, Inc. (http:\/\/www.fastly.com)\n# @license BSD, see LICENSE_FASTLY_CDN.txt\n#\n###############################################################################\n\n# This is a basic VCL configuration file for fastly CDN for Magento module.\n\nsub vcl_recv {\n#FASTLY recv\n # we only deal with GET and HEAD by default\n if (req.request != \"GET\" && req.request != \"HEAD\" && req.request != \"FASTLYPURGE\") {\n return (pass);\n }\n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n set req.http.X-Sig = regsub(req.http.X-Purge-Token, \"^[^_]+_(.*)\", \"\\1\");\n set req.http.X-Exp = regsub(req.http.X-Purge-Token, \"^([^_]+)_.*\", \"\\1\");\n\n # validate signature\n if (req.http.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path req.http.X-Exp), \"^0x\", \"\")) {\n\n # use vcl time math to check expiration timestamp\n set req.http.X-Original-Grace = req.grace;\n set req.grace = std.atoi(strftime({\"%s\"}, now));\n set req.grace -= std.atoi(req.http.X-Exp);\n\n if (std.atoi(req.grace) > 0) {\n error 410;\n }\n\n # clean up grace since we used it for time math\n set req.grace = std.atoi(req.http.X-Original-Grace);\n unset req.http.X-Original-Grace;\n\n } else {\n error 403;\n }\n\n # cleanup variables\n unset req.http.X-Purge-Token;\n unset req.http.X-Sig;\n unset req.http.X-Exp;\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n # disable ESI processing on Origin Shield\n if (req.http.Fastly-FF) {\n set req.esi = false;\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(media|js|skin)\/.*\\.(png|jpg|jpeg|gif|css|js|swf|ico)$\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n # formkey lookup\n if (req.url ~ \"\/fastlycdn\/getformkey\/\") {\n # check if we have a formkey cookie\n if (req.http.Cookie:FASTLY_CDN_FORMKEY) {\n set req.http.Formkey = req.http.Cookie:FASTLY_CDN_FORMKEY;\n } else {\n # create formkey\n set req.http.seed = req.http.Cookie client.ip remote.port geoip.longitude geoip.latitude geoip.postal_code;\n set req.http.Formkey = regsub(digest.hash_md5(req.http.seed), \"^0x\", \"\");\n }\n error 760 req.http.Formkey;\n }\n\n # geoip lookup\n if (req.url ~ \"fastlycdn\/esi\/getcountry\/\") {\n # check if GeoIP has been already processed by client\n if (req.http.Cookie:FASTLY_CDN_GEOIP_PROCESSED) {\n error 200 \"\";\n } else {\n # modify req.url and restart request processing\n error 750 geoip.country_code;\n }\n }\n\n # geoip get country code\n if (req.url ~ \"fastlycdn\/esi\/getcountrycode\/\") {\n # create and set req.http.X-Country-Code\n error 755 geoip.country_code;\n }\n\n # check for ESI calls\n if (req.url ~ \"esi_data=\") {\n # check for valid cookie data\n if (req.http.Cookie ~ \"FASTLY_CDN-\") {\n # get the cookie name to look for\n set req.http.fastlyCDNEsiCookieName = regsub(\n req.url,\n \"(.*)esi_data=([^&]*)(.*)\",\n \"\\2\"\n );\n\n # get the cookie value for the cookie name\n # tmp string is NAMESPACE-COOKIENAME@@@@@COMPLETE_COOKIE\n # left of @@@@@ is back-referenced in regex to extract value from cookie\n set req.http.fastlyTmp = \"FASTLY_CDN-\" req.http.fastlyCDNEsiCookieName \"@@@@@\" req.http.Cookie;\n set req.http.fastlyCDNRequest = regsub(\n req.http.fastlyTmp,\n \"^([A-Za-z0-9-_]+)@@@@@.*\\1=([^;]*)\",\n \"\\2\"\n );\n\n # do we have a value for the cookie name?\n if (!req.http.fastlyCDNRequest) {\n set req.http.fastlyCDNRequest = \"default\";\n }\n\n # build backend url\n set req.url = regsub(\n req.url,\n \"(.*)esi_data=([^&]*)[&]?(.*)\",\n \"\\1\\3\"\n )\n \"&esi_data=\"\n req.http.fastlyCDNRequest;\n\n # clean up temp variables\n remove req.http.fastlyCDNEsiCookieName;\n remove req.http.fastlyCDNRequest;\n\n return (lookup);\n }\n }\n\n return(lookup);\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n\nsub vcl_hash {\n set req.hash += req.http.Https;\n set req.hash += req.http.host;\n set req.hash += req.url;\n\n if (req.http.cookie:FASTLY_CDN_ENV) {\n set req.hash += req.http.cookie:FASTLY_CDN_ENV;\n }\n\n set req.hash += \"#####GENERATION#####\";\n\n if (!(req.url ~ \"^\/(media|js|skin)\/.*\\.(png|jpg|jpeg|gif|css|js|swf|ico)$\")) {\n call design_exception;\n }\n return (hash);\n}\n\nsub vcl_hit {\n#FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\nsub vcl_miss {\n # Deactivate gzip on origin\n unset bereq.http.Accept-Encoding;\n\n#FASTLY miss\n\n return(fetch);\n}\n\nsub vcl_fetch {\n#FASTLY fetch\n\n if (beresp.status >= 500) {\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n }\n\n if (req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Content-Type ~ \"text\/html\" || beresp.http.Content-Type ~ \"text\/xml\") {\n # enable ESI feature for Magento response by default\n esi;\n } else {\n # enable gzip for all static content\n if ((beresp.status == 200 || beresp.status == 404) && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url ~ \"\\.(css|js|html|eot|ico|otf|ttf|json)($|\\?)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.status == 500 || beresp.status == 503) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n if (beresp.status == 200 || beresp.status == 301 || beresp.status == 404) {\n if (beresp.http.Content-Type ~ \"text\/html\" || beresp.http.Content-Type ~ \"text\/xml\") {\n # marker for vcl_deliver to reset Age:\n set beresp.http.magentomarker = \"1\";\n\n # Don't cache cookies\n unset beresp.http.set-cookie;\n } else {\n if (beresp.http.Expires || beresp.http.Surrogate-Control ~ \"max-age\" || beresp.http.Cache-Control ~ \"(s-maxage|max-age)\") {\n # keep the ttl here\n } else {\n # apply the default ttl\n set beresp.ttl = 3600s;\n }\n }\n\n # init surrogate keys\n if (beresp.http.Surrogate-Key) {\n set beresp.http.Surrogate-Key = beresp.http.Surrogate-Key \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type\n if (beresp.http.Content-Type ~ \"image\") {\n set beresp.http.Surrogate-Key = \"image\";\n } elsif (beresp.http.Content-Type ~ \"script\") {\n set beresp.http.Surrogate-Key = \"script\";\n } elsif (beresp.http.Content-Type ~ \"css\") {\n set beresp.http.Surrogate-Key = \"css\";\n }\n\n set beresp.http.X-Surrogate-Key = beresp.http.Surrogate-Key;\n }\n\n return (deliver);\n}\n\nsub vcl_deliver {\n # debug info\n if (resp.http.X-Cache-Debug) {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n set resp.http.X-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n set resp.http.X-Cache-Expires = resp.http.Expires;\n } else {\n # remove Varnish\/proxy header\n remove resp.http.X-Varnish;\n remove resp.http.Via;\n remove resp.http.Age;\n remove resp.http.X-Purge-URL;\n remove resp.http.X-Purge-Host;\n remove resp.http.X-Surrogate-Key;\n }\n\n if (resp.http.magentomarker) {\n # Remove the magic marker\n unset resp.http.magentomarker;\n\n set resp.http.Cache-Control = \"no-store, no-cache, must-revalidate, post-check=0, pre-check=0\";\n set resp.http.Pragma = \"no-cache\";\n set resp.http.Expires = \"Mon, 31 Mar 2008 10:00:00 GMT\";\n set resp.http.Age = \"0\";\n }\n\n#FASTLY deliver\n\n return (deliver);\n}\n\nsub vcl_error {\n # workaround for possible security issue\n if (req.url ~ \"^\\s\") {\n set obj.status = 400;\n set obj.response = \"Malformed request\";\n synthetic \"\";\n return (deliver);\n }\n\n # geo ip request\n if (obj.status == 750) {\n set req.url = regsub(req.url, \"(\/fastlycdn\/esi\/getcountry\/.*)\", \"\/fastlycdn\/esi\/getcountryaction\/?country_code=\") obj.response;\n return (restart);\n }\n\n # geo ip country code\n if (obj.status == 755) {\n set obj.status = 200;\n\t synthetic obj.response;\n return(deliver);\n }\n\n # formkey request\n if (obj.status == 760) {\n set obj.status = 200;\n\t synthetic obj.response;\n return (deliver);\n }\n\n # error 200\n if (obj.status == 200) {\n return (deliver);\n }\n\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} obj.status \" \" obj.response {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} obj.status \" \" obj.response {\"<\/h1>\n <p>\"} obj.response {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} req.xid {\"<\/p>\n <hr>\n <p>Fastly CDN server<\/p>\n <\/body>\n<\/html>\n\"};\n\n#FASTLY error\n}\n\nsub design_exception {\n}\n","old_contents":"###############################################################################\n#\n# Fastly CDN for Magento\n#\n# NOTICE OF LICENSE\n#\n# This source file is subject to the Fastly CDN for Magento End User License\n# Agreement that is bundled with this package in the file LICENSE_FASTLY_CDN.txt.\n#\n# @copyright Copyright (c) 2015 Fastly, Inc. (http:\/\/www.fastly.com)\n# @license BSD, see LICENSE_FASTLY_CDN.txt\n#\n###############################################################################\n\n# This is a basic VCL configuration file for fastly CDN for Magento module.\n\nsub vcl_recv {\n#FASTLY recv\n # we only deal with GET and HEAD by default\n if (req.request != \"GET\" && req.request != \"HEAD\" && req.request != \"FASTLYPURGE\") {\n return (pass);\n }\n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n set req.http.X-Sig = regsub(req.http.X-Purge-Token, \"^[^_]+_(.*)\", \"\\1\");\n set req.http.X-Exp = regsub(req.http.X-Purge-Token, \"^([^_]+)_.*\", \"\\1\");\n\n # validate signature\n if (req.http.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path req.http.X-Exp), \"^0x\", \"\")) {\n\n # use vcl time math to check expiration timestamp\n set req.http.X-Original-Grace = req.grace;\n set req.grace = std.atoi(strftime({\"%s\"}, now));\n set req.grace -= std.atoi(req.http.X-Exp);\n\n if (std.atoi(req.grace) > 0) {\n error 410;\n }\n\n # clean up grace since we used it for time math\n set req.grace = std.atoi(req.http.X-Original-Grace);\n unset req.http.X-Original-Grace;\n\n } else {\n error 403;\n }\n\n # cleanup variables\n unset req.http.X-Purge-Token;\n unset req.http.X-Sig;\n unset req.http.X-Exp;\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n # disable ESI processing on Origin Shield\n if (req.http.Fastly-FF) {\n set req.esi = false;\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(media|js|skin)\/.*\\.(png|jpg|jpeg|gif|css|js|swf|ico)$\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n # formkey lookup\n if (req.url ~ \"\/fastlycdn\/getformkey\/\") {\n # check if we have a formkey cookie\n if (req.http.Cookie ~ \"FASTLY_CDN_FORMKEY\") {\n set req.http.Formkey = regsub(req.http.cookie, \".*FASTLY_CDN_FORMKEY=([^;]*)(;*.*)?\", \"\\1\");\n } else {\n # create formkey\n set req.http.seed = req.http.Cookie client.ip remote.port geoip.longitude geoip.latitude geoip.postal_code;\n set req.http.Formkey = regsub(digest.hash_md5(req.http.seed), \"^0x\", \"\");\n }\n error 760 req.http.Formkey;\n }\n\n # geoip lookup\n if (req.url ~ \"fastlycdn\/esi\/getcountry\/\") {\n # check if GeoIP has been already processed by client\n if (req.http.Cookie ~ \"FASTLY_CDN_GEOIP_PROCESSED\") {\n error 200 \"\";\n } else {\n # modify req.url and restart request processing\n error 750 geoip.country_code;\n }\n }\n\n # geoip get country code\n if (req.url ~ \"fastlycdn\/esi\/getcountrycode\/\") {\n # create and set req.http.X-Country-Code\n error 755 geoip.country_code;\n }\n\n # check for ESI calls\n if (req.url ~ \"esi_data=\") {\n # check for valid cookie data\n if (req.http.Cookie ~ \"FASTLY_CDN-\") {\n # get the cookie name to look for\n set req.http.fastlyCDNEsiCookieName = regsub(\n req.url,\n \"(.*)esi_data=([^&]*)(.*)\",\n \"\\2\"\n );\n\n # get the cookie value for the cookie name\n # tmp string is NAMESPACE-COOKIENAME@@@@@COMPLETE_COOKIE\n # left of @@@@@ is back-referenced in regex to extract value from cookie\n set req.http.fastlyTmp = \"FASTLY_CDN-\" req.http.fastlyCDNEsiCookieName \"@@@@@\" req.http.Cookie;\n set req.http.fastlyCDNRequest = regsub(\n req.http.fastlyTmp,\n \"^([A-Za-z0-9-_]+)@@@@@.*\\1=([^;]*)\",\n \"\\2\"\n );\n\n # do we have a value for the cookie name?\n if (!req.http.fastlyCDNRequest) {\n set req.http.fastlyCDNRequest = \"default\";\n }\n\n # build backend url\n set req.url = regsub(\n req.url,\n \"(.*)esi_data=([^&]*)[&]?(.*)\",\n \"\\1\\3\"\n )\n \"&esi_data=\"\n req.http.fastlyCDNRequest;\n\n # clean up temp variables\n remove req.http.fastlyCDNEsiCookieName;\n remove req.http.fastlyCDNRequest;\n\n return (lookup);\n }\n }\n\n return(lookup);\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n\nsub vcl_hash {\n set req.hash += req.http.Https;\n set req.hash += req.http.host;\n set req.hash += req.url;\n\n if (req.http.cookie ~ \"FASTLY_CDN_ENV=\") {\n set req.http.fastlyCDNEnv = regsub(\n req.http.cookie,\n \"(.*)FASTLY_CDN_ENV=([^;]*)(.*)\",\n \"\\2\"\n );\n set req.hash += req.http.fastlyCDNEnv;\n unset req.http.fastlyCDNEnv;\n }\n\n set req.hash += \"#####GENERATION#####\";\n\n if (!(req.url ~ \"^\/(media|js|skin)\/.*\\.(png|jpg|jpeg|gif|css|js|swf|ico)$\")) {\n call design_exception;\n }\n return (hash);\n}\n\nsub vcl_hit {\n#FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\nsub vcl_miss {\n # Deactivate gzip on origin\n unset bereq.http.Accept-Encoding;\n\n#FASTLY miss\n\n return(fetch);\n}\n\nsub vcl_fetch {\n#FASTLY fetch\n\n if (beresp.status >= 500) {\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n }\n\n if (req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Content-Type ~ \"text\/html\" || beresp.http.Content-Type ~ \"text\/xml\") {\n # enable ESI feature for Magento response by default\n esi;\n } else {\n # enable gzip for all static content\n if ((beresp.status == 200 || beresp.status == 404) && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url ~ \"\\.(css|js|html|eot|ico|otf|ttf|json)($|\\?)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.status == 500 || beresp.status == 503) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n if (beresp.status == 200 || beresp.status == 301 || beresp.status == 404) {\n if (beresp.http.Content-Type ~ \"text\/html\" || beresp.http.Content-Type ~ \"text\/xml\") {\n # marker for vcl_deliver to reset Age:\n set beresp.http.magentomarker = \"1\";\n\n # Don't cache cookies\n unset beresp.http.set-cookie;\n } else {\n if (beresp.http.Expires || beresp.http.Surrogate-Control ~ \"max-age\" || beresp.http.Cache-Control ~ \"(s-maxage|max-age)\") {\n # keep the ttl here\n } else {\n # apply the default ttl\n set beresp.ttl = 3600s;\n }\n }\n\n # init surrogate keys\n if (beresp.http.Surrogate-Key) {\n set beresp.http.Surrogate-Key = beresp.http.Surrogate-Key \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type\n if (beresp.http.Content-Type ~ \"image\") {\n set beresp.http.Surrogate-Key = \"image\";\n } elsif (beresp.http.Content-Type ~ \"script\") {\n set beresp.http.Surrogate-Key = \"script\";\n } elsif (beresp.http.Content-Type ~ \"css\") {\n set beresp.http.Surrogate-Key = \"css\";\n }\n\n set beresp.http.X-Surrogate-Key = beresp.http.Surrogate-Key;\n }\n\n return (deliver);\n}\n\nsub vcl_deliver {\n # debug info\n if (resp.http.X-Cache-Debug) {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n set resp.http.X-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n set resp.http.X-Cache-Expires = resp.http.Expires;\n } else {\n # remove Varnish\/proxy header\n remove resp.http.X-Varnish;\n remove resp.http.Via;\n remove resp.http.Age;\n remove resp.http.X-Purge-URL;\n remove resp.http.X-Purge-Host;\n remove resp.http.X-Surrogate-Key;\n }\n\n if (resp.http.magentomarker) {\n # Remove the magic marker\n unset resp.http.magentomarker;\n\n set resp.http.Cache-Control = \"no-store, no-cache, must-revalidate, post-check=0, pre-check=0\";\n set resp.http.Pragma = \"no-cache\";\n set resp.http.Expires = \"Mon, 31 Mar 2008 10:00:00 GMT\";\n set resp.http.Age = \"0\";\n }\n\n#FASTLY deliver\n\n return (deliver);\n}\n\nsub vcl_error {\n # workaround for possible security issue\n if (req.url ~ \"^\\s\") {\n set obj.status = 400;\n set obj.response = \"Malformed request\";\n synthetic \"\";\n return (deliver);\n }\n\n # geo ip request\n if (obj.status == 750) {\n set req.url = regsub(req.url, \"(\/fastlycdn\/esi\/getcountry\/.*)\", \"\/fastlycdn\/esi\/getcountryaction\/?country_code=\") obj.response;\n return (restart);\n }\n\n # geo ip country code\n if (obj.status == 755) {\n set obj.status = 200;\n\t synthetic obj.response;\n return(deliver);\n }\n\n # formkey request\n if (obj.status == 760) {\n set obj.status = 200;\n\t synthetic obj.response;\n return (deliver);\n }\n\n # error 200\n if (obj.status == 200) {\n return (deliver);\n }\n\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} obj.status \" \" obj.response {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} obj.status \" \" obj.response {\"<\/h1>\n <p>\"} obj.response {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} req.xid {\"<\/p>\n <hr>\n <p>Fastly CDN server<\/p>\n <\/body>\n<\/html>\n\"};\n\n#FASTLY error\n}\n\nsub design_exception {\n}\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"6f3d9fc272f54a6f617a4e59b3b975bdbc91e9be","subject":"Make varnish forward the x forwarded for header.","message":"Make varnish forward the x forwarded for header.\n","repos":"Floens\/uchan,Floens\/uchan,Floens\/uchan,Floens\/uchan,Floens\/uchan","old_file":"docker\/varnish\/uchan.vcl","new_file":"docker\/varnish\/uchan.vcl","new_contents":"vcl 4.0;\n\nbackend default {\n .host = \"nginx\";\n .port = \"5003\";\n}\n\nacl app {\n \"app\";\n \"worker\";\n}\n\n#sub vcl_fetch {\n# set obj.ttl = 1m;\n#}\n\nsub vcl_recv {\n # Happens before we check if we have this in cache already.\n #\n # Typically you clean up the request here, removing cookies you don't need,\n # rewriting the request, etc.\n # set req.backend = default;\n\n if (req.method == \"PURGE\") {\n if (!client.ip ~ app) {\n return (synth(405, \"Not allowed.\"));\n }\n\n return (purge);\n }\n\n # IP forwarding.\n if (req.restarts == 0) {\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n # Only cache GET or HEAD requests. This makes sure the POST requests are always passed.\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n # The endpoints change their content based on ip, etc. Never cache them.\n if (req.url ~ \"^\/banned\/\" || req.url ~ \"^\/verify\/\" || req.url ~ \"^\/post\/\" || req.url ~ \"^\/post_manage\/\") {\n return (pass);\n }\n\n # Remove verification cookie from client\n # The verification cookie has been designed to not interfere with any requests,\n # except for \/verify\/ and POST requests, which are never cached.\n set req.http.Cookie = regsuball(req.http.Cookie, \"verification=[^;]+(; )?\", \"\");\n\n # Remove a \";\" prefix in the cookie if present\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n\n # Are there cookies left with only spaces or that are empty?\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n}\n\nsub vcl_backend_response {\n set beresp.grace = 10m;\n}\n\n","old_contents":"vcl 4.0;\n\nbackend default {\n .host = \"nginx\";\n .port = \"5003\";\n}\n\nacl app {\n \"app\";\n \"worker\";\n}\n\n#sub vcl_fetch {\n# set obj.ttl = 1m;\n#}\n\nsub vcl_recv {\n # Happens before we check if we have this in cache already.\n #\n # Typically you clean up the request here, removing cookies you don't need,\n # rewriting the request, etc.\n # set req.backend = default;\n\n if (req.method == \"PURGE\") {\n if (!client.ip ~ app) {\n return (synth(405, \"Not allowed.\"));\n }\n\n return (purge);\n }\n\n set req.http.X-Forwarded-For = client.ip;\n\n # Only cache GET or HEAD requests. This makes sure the POST requests are always passed.\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n # The endpoints change their content based on ip, etc. Never cache them.\n if (req.url ~ \"^\/banned\/\" || req.url ~ \"^\/verify\/\" || req.url ~ \"^\/post\/\" || req.url ~ \"^\/post_manage\/\") {\n return (pass);\n }\n\n # Remove verification cookie from client\n # The verification cookie has been designed to not interfere with any requests,\n # except for \/verify\/ and POST requests, which are never cached.\n set req.http.Cookie = regsuball(req.http.Cookie, \"verification=[^;]+(; )?\", \"\");\n\n # Remove a \";\" prefix in the cookie if present\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n\n # Are there cookies left with only spaces or that are empty?\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n}\n\nsub vcl_backend_response {\n set beresp.grace = 10m;\n}\n\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"a923ab8fddcb695bb11367b7878b10b8933e4020","subject":"re #444 - Set the secret to the vagrant box default","message":"re #444 - Set the secret to the vagrant box default\n","repos":"timble\/kodekit-platform,nooku\/nooku-platform,timble\/kodekit-platform,timble\/kodekit-platform,nooku\/nooku-platform,nooku\/nooku-platform,nooku\/nooku-platform,nooku\/nooku-platform,timble\/kodekit-platform,timble\/kodekit-platform","old_file":"component\/varnish\/resources\/varnish\/nooku.vcl","new_file":"component\/varnish\/resources\/varnish\/nooku.vcl","new_contents":"vcl 4.0;\n# Based on: https:\/\/github.com\/mattiasgeniar\/varnish-4.0-configuration-templates\/blob\/master\/default.vcl\n\nimport std;\nimport directors;\n\nprobe health\n{\n #.url = \"\/varnish-enabled\";\n # We prefer to only do a HEAD \/\n .request =\n \"HEAD \/varnish-enabled HTTP\/1.1\"\n \"Host: localhost\"\n \"Connection: close\";\n .interval = 5s; # check the health of each backend every 5 seconds\n .timeout = 1s; # timing out after 1 second.\n # If 3 out of the last 5 polls succeeded the backend is considered healthy, otherwise it will be marked as sick\n .window = 5;\n .threshold = 3;\n .expected_response = 200;\n}\n\nbackend default\n{\n .host = \"127.0.0.1\"; # IP or Hostname of backend\n .port = \"8080\"; # Port Apache or whatever is listening\n .max_connections = 300; # That's it\n .probe = health;\n .connect_timeout = 600s; # How long to wait before we receive a first byte from our backend?\n .first_byte_timeout = 600s; # How long to wait for a backend connection?\n .between_bytes_timeout = 600s; # How long to wait between bytes received from our backend?\n}\n\nbackend passthrough\n{\n .host = \"127.0.0.1\"; # IP or Hostname of backend\n .port = \"8080\"; # Port Apache or whatever is listening\n}\n\nacl localhost\n{\n \"localhost\";\n \"33.33.33.63\";\n \"::1\";\n}\n\nsub vcl_init\n{\n # Called when VCL is loaded, before any requests pass through it.\n # Typically used to initialize VMODs.\n\n new vdir = directors.round_robin();\n vdir.add_backend(default);\n # vdir.add_backend(server...);\n # vdir.add_backend(servern);\n}\n\nsub vcl_recv\n{\n # Called at the beginning of a request, after the complete request has been received and parsed.\n # Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable,\n # which backend to use and if needed to modify the request.\n\n # Send all traffic to the vdir director\n set req.backend_hint = vdir.backend();\n\n if (req.restarts == 0)\n {\n # Set or append the client.ip to X-Forwarded-For header\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n\n set req.http.X-Forwarded-By = server.ip;\n set req.http.X-Forwarded-Port = std.port(client.ip);\n }\n\n # Normalize the header, remove the port (in case you're testing this on various TCP ports)\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n # Normalize the query arguments\n set req.url = std.querysort(req.url);\n\n # Allow purging\n if (req.method == \"PURGE\")\n {\n # purge is the ACL defined at the begining\n if (!client.ip ~ localhost) {\n return (synth(405, \"This IP is not allowed to send PURGE requests.\"));\n }\n\n # If you got this stage (and didn't error out above), purge the cached result\n return (purge);\n }\n\n # Check if we've still enabled Varnish, if not, passthrough every request\n if (! std.healthy(req.backend_hint))\n {\n set req.backend_hint = passthrough;\n return (pass);\n }\n\n # Only deal with \"normal\" types\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"PATCH\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n # Implementing websocket support (https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html)\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n # Only cache GET or HEAD requests. This makes sure the POST requests are always passed.\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n # Specific Nooku Platform rules\n\n # Do not cache \/administrator\n if(req.url ~ \"^\/administrator\") {\n return (pass);\n }\n\n # Specific Nooku Server rules\n\n # Do not cache webgrind.nooku.dev\n if (req.http.host == \"webgrind.nooku.dev\") {\n return (pass);\n }\n\n # Do not cache phpmyadmin.nooku.dev\n if (req.http.host == \"phpmyadmin.nooku.dev\") {\n return (pass);\n }\n\n # Do not cache \/apc and \/phpinfo\n if (req.url == \"\/apc\" || req.url == \"\/phpinfo\") {\n return (pass);\n }\n\n # Generic URL manipulation, useful for all templates that follow\n\n # Remove the Google Analytics added parameters, useless for our backend\n if (req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=\") {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # Strip hash, server doesn't need it.\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n # Strip a trailing ? if it exists\n if (req.url ~ \"\\?$\") {\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # Cookie manipulation\n\n # Remove the \"has_js\" cookie\n set req.http.Cookie = regsuball(req.http.Cookie, \"has_js=[^;]+(; )?\", \"\");\n\n # Remove any Google Analytics based cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__utm.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"_ga=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmctr=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmcmd.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmccn.=[^;]+(; )?\", \"\");\n\n # Remove DoubleClick offensive cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__gads=[^;]+(; )?\", \"\");\n\n # Remove the Quant Capital cookies (added by some plugin, all __qca)\n set req.http.Cookie = regsuball(req.http.Cookie, \"__qc.=[^;]+(; )?\", \"\");\n\n # Remove the AddThis cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__atuv.=[^;]+(; )?\", \"\");\n\n # Remove a \";\" prefix in the cookie if present\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n\n # Remove the csrf_token cookie\n set req.http.Cookie = regsuball(req.http.Cookie, \"csrf_token=[^;]+(; )?\", \"\");\n\n # Are there cookies left with only spaces or that are empty?\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n\n # Large static files are delivered directly to the end-user without waiting for Varnish to fully read the file first.\n # Varnish 4 supports Streaming, so set do_stream in vcl_backend_response()\n if (req.url ~ \"^[^?]*\\.(mp[34]|rar|tar|tgz|gz|wav|zip|bz2|xz|7z|avi|mov|og[gvaxm]|mpe?g|mk[av])(\\?.*)?$\") {\n unset req.http.Cookie;\n return (hash);\n }\n\n # Remove all cookies for static files\n # Before you blindly enable this read: https:\/\/ma.ttias.be\/stop-caching-static-files\/\n #if (req.method == \"GET\")\n #{\n # # Cache files with these extensions and remove cookie\n # if (req.url ~ \"^[^?]*\\.(bmp|bz2|css|doc|eot|flv|gif|gz|ico|jpeg|jpg|js|less|pdf|png|rtf|swf|txt|woff|xml)(\\?.*)?$\") {\n # unset req.http.Cookie;\n # return (hash);\n # }\n #}\n\n # Normalize Accept-Encoding header\n # straight from the manual: https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/vary.html\n # TODO: Test if it's still needed, Varnish 4 now does this by itself if http_gzip_support = on\n # https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/compression.html\n # https:\/\/www.varnish-cache.org\/docs\/trunk\/phk\/gzip.html\n if (req.http.Accept-Encoding)\n {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n # No point in compressing these\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n # unkown algorithm\n unset req.http.Accept-Encoding;\n }\n }\n\n if (req.http.Cache-Control ~ \"(?i)no-cache\" && client.ip ~ localhost)\n {\n # http:\/\/varnish.projects.linpro.no\/wiki\/VCLExampleEnableForceRefresh\n # Ignore requests via proxy caches and badly behaved crawlers\n # like msnbot that send no-cache with every request.\n if (! (req.http.Via || req.http.User-Agent ~ \"(?i)bot\" || req.http.X-Purge))\n {\n # Doesn't seems to refresh the object in the cache\n set req.hash_always_miss = true;\n\n # Couple this with restart in vcl_purge and X-Purge header to avoid loops\n return(purge);\n }\n }\n\n # Send Surrogate-Capability headers to announce ESI support to backend\n set req.http.Surrogate-Capability = \"varnish=ESI\/1.0\";\n\n # Requests that require authorization are not cacheable by default\n if (req.http.Authorization) {\n return (pass);\n }\n\n # We do not support SPDY or HTTP\/2.0\n if (req.method == \"PRI\") {\n return (synth(405));\n }\n\n return (hash);\n}\n\n# Called upon entering pipe mode. In this mode, the request is passed on to the backend, and any further data from both\n# the client and backend is passed on unaltered until either end closes the connection. Basically, Varnish will degrade\n# into a simple TCP proxy, shuffling bytes back and forth. For a connection in pipe mode, no other VCL subroutine will\n# ever get called after vcl_pipe.\nsub vcl_pipe\n{\n # Note that only the first request to the backend will have X-Forwarded-For set.\n # If you use X-Forwarded-For and want to have it set for all requests, make sure to have:\n # set bereq.http.connection = \"close\";\n # It is not set by default as it might break some broken web applications, like IIS with NTLM authentication.\n # set bereq.http.Connection = \"Close\";\n\n # Implementing websocket support (https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html)\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n\n return (pipe);\n}\n\n# Called upon entering pass mode. In this mode, the request is passed on to the backend, and the backend's response\n# is passed on to the client, but is not entered into the cache. Subsequent requests submitted over the same client\n# connection are handled normally.\nsub vcl_pass\n{\n return (fetch);\n}\n\n# Called after vcl_recv to create a hash value for the request. This is used as a key to look up the object in Varnish.\nsub vcl_hash\n{\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n\n # hash cookies for requests that have them\n if (req.http.Cookie) {\n hash_data(req.http.Cookie);\n }\n}\n\n# Called when a cache lookup is successful.\nsub vcl_hit\n{\n # A pure unadultered hit, deliver it\n if (obj.ttl >= 0s) {\n return (deliver);\n }\n\n # https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-grace.html\n # When several clients are requesting the same page Varnish will send one request to the backend and place the\n # others on hold while fetching one copy from the backend. In some products this is called request coalescing and\n # Varnish does this automatically.\n\n # If you are serving thousands of hits per second the queue of waiting requests can get huge. There are two\n # potential problems - one is a thundering herd problem - suddenly releasing a thousand threads to serve content\n # might send the load sky high. Secondly - nobody likes to wait. To deal with this we can instruct Varnish to keep\n # the objects in cache beyond their TTL and to serve the waiting requests somewhat stale content.\n\n # if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n # return (deliver);\n # } else {\n # return (fetch);\n # }\n\n # We have no fresh fish. Lets look at the stale ones.\n if (std.healthy(req.backend_hint))\n {\n # Backend is healthy. Limit age to 10s.\n if (obj.ttl + 10s > 0s)\n {\n #set req.http.grace = \"normal(limited)\";\n return (deliver);\n }\n else\n {\n # No candidate for grace. Fetch a fresh object.\n return(fetch);\n }\n }\n else\n {\n # backend is sick - use full grace\n if (obj.ttl + obj.grace > 0s)\n {\n #set req.http.grace = \"full\";\n return (deliver);\n }\n else\n {\n # no graced object.\n return (fetch);\n }\n }\n\n # fetch & deliver once we get the result\n return (fetch); # Dead code, keep as a safeguard\n}\n\n# Called after a cache lookup if the requested document was not found in the cache. Its purpose is to decide whether\n# or not to attempt to retrieve the document from the backend, and which backend to use.\nsub vcl_miss\n{\n return (fetch);\n}\n\n # Called after the response headers has been successfully retrieved from the backend.\nsub vcl_backend_response\n{\n # Enable ESI handling\n if (beresp.http.Surrogate-Control ~ \"ESI\/1.0\" ) {\n set beresp.do_esi = true;\n }\n\n # Store the csrf_token cookie temporarily if the response is cacheabale\n if (beresp.http.Set-Cookie && !beresp.uncacheable)\n {\n set beresp.http.X-Varnish-Cookie = beresp.http.Set-Cookie;\n unset beresp.http.Set-Cookie;\n }\n\n # Cache handling all static files\n if (bereq.method == \"GET\")\n {\n # Before you blindly enable this, read: https:\/\/ma.ttias.be\/stop-caching-static-files\/\n #if (bereq.url ~ \"^[^?]*\\.(bmp|bz2|css|doc|eot|flv|gif|gz|ico|jpeg|jpg|js|less|mp[34]|pdf|png|rar|rtf|swf|tar|tgz|txt|wav|woff|xml|zip)(\\?.*)?$\") {\n # unset beresp.http.Set-Cookie;\n #}\n\n # Large static files are delivered directly to the end-user without waiting for Varnish to fully read the\n # file first. Check memory usage it'll grow in fetch_chunksize blocks (128k by default) if the backend\n # doesn't send a Content-Length header. Only enable it for large files\n if (bereq.url ~ \"^[^?]*\\.(mp[34]|rar|tar|tgz|gz|wav|zip|bz2|xz|7z|avi|mov|og[gvaxm]|mpe?g|mk[av])(\\?.*)?$\")\n {\n unset beresp.http.Set-Cookie;\n\n # Use streaming to avoid locking\n set beresp.do_stream = true;\n\n # Don't try to compress it for storage\n set beresp.do_gzip = false;\n\n # Disable Transfer-encoding chunked when serving HTML5 video\n # See : http:\/\/stackoverflow.com\/questions\/23643233\/how-do-i-disable-transfer-encoding-chunked-encoding-in-varnish\n # See : https:\/\/www.varnish-cache.org\/trac\/ticket\/1506\n if(beresp.http.Content-Type ~ \"video\") {\n set beresp.do_stream = true;\n set beresp.do_esi = true;\n }\n }\n\n # Set 2min cache if unset for static files\n if (beresp.ttl <= 0s || beresp.http.Set-Cookie || beresp.http.Vary == \"*\")\n {\n set beresp.ttl = 120s; # Important, you shouldn't rely on this, SET YOUR HEADERS in the backend\n set beresp.uncacheable = true;\n\n return (deliver);\n }\n }\n\n # Sometimes, a 301 or 302 redirect formed via Apache's mod_rewrite can mess with the HTTP port that is being passed along.\n # This often happens with simple rewrite rules in a scenario where Varnish runs on :80 and Apache on :8080 on the same box.\n # A redirect can then often redirect the end-user to a URL on :8080, where it should be :80.\n # This may need finetuning on your setup.\n #\n # To prevent accidental replace, we only filter the 301\/302 redirects for now.\n if (beresp.status == 301 || beresp.status == 302) {\n set beresp.http.Location = regsub(beresp.http.Location, \":[0-9]+\", \"\");\n }\n\n # Do not cache errors from the backend\n if (beresp.status >= 400)\n {\n set beresp.uncacheable = true;\n set beresp.ttl = 0s;\n\n return (deliver);\n }\n\n # Allow stale content, in case the backend goes down. Make Varnish keep all objects for 6 hours beyond their TTL\n set beresp.grace = 6h;\n\n # Set ban-lurker friendly custom headers\n set beresp.http.X-Varnish-Url = bereq.url;\n set beresp.http.X-Varnish-Host = bereq.http.host;\n\n return (deliver);\n}\n\n# Called when the backend returns an error\nsub vcl_backend_error\n{\n if (beresp.status == 503 && bereq.retries < 5)\n {\n set beresp.http.X-Varnish-Retries = bereq.retries;\n return(retry);\n }\n\n return(deliver);\n}\n\n# Called before a cached object is delivered to the client.\nsub vcl_deliver\n{\n # Send the Cookie header again if a temporay header was stored\n if (req.http.X-Varnish-Cookie) {\n set resp.http.Set-Cookie = req.http.X-Varnish-Cookie;\n }\n\n # Add extra headers if debugging is enabled\n if (resp.http.x-varnish-debug && server.ip ~ localhost)\n {\n set resp.http.X-Served-By = server.hostname;\n\n if (resp.http.x-varnish ~ \" \") {\n set resp.http.X-Varnish-Status = \"HIT\";\n } else {\n set resp.http.X-Varnish-Status = \"MISS\";\n }\n\n # Please note that obj.hits behaviour changed in 4.0, now it counts per objecthead, not per object\n # and obj.hits may not be reset in some cases where bans are in use. See bug 1492 for details.\n # So take hits with a grain of salt\n set resp.http.X-Varnish-Hits = obj.hits;\n }\n else\n {\n # Remove ban-lurker friendly custom headers when delivering to client\n unset resp.http.X-Url;\n unset resp.http.X-Host;\n\n # Remove some headers: PHP version\n unset resp.http.X-Powered-By;\n\n # Remove some headers: Apache version & OS\n unset resp.http.Server;\n unset resp.http.Via;\n unset resp.http.Link;\n unset resp.http.X-Varnish;\n unset resp.http.X-Varnish-Tag;\n unset resp.http.X-Varnish-Debug;\n unset resp.http.X-Varnish-Host;\n unset resp.http.X-Varnish-Url;\n unset resp.http.X-Varnish-Retries;\n unset resp.http.X-Varnish-Cookie;\n unset resp.http.Surrogate-Control;\n }\n\n return (deliver);\n}\n\nsub vcl_purge\n{\n # Only handle actual PURGE HTTP methods, everything else is discarded\n if (req.method != \"PURGE\" && server.ip ~ localhost)\n {\n set req.http.X-Varnish-Purge = \"Yes\";\n return (restart);\n }\n}\n\nsub vcl_synth\n{\n if (resp.status == 720)\n {\n # We use this special error status 720 to force redirects with 301 (permanent) redirects\n # To use this, call the following from anywhere in vcl_recv: return (synth(720, \"http:\/\/host\/new.html\"));\n set resp.http.Location = resp.reason;\n set resp.status = 301;\n\n return (deliver);\n }\n elseif (resp.status == 721)\n {\n # And we use error status 721 to force redirects with a 302 (temporary) redirect\n # To use this, call the following from anywhere in vcl_recv: return (synth(720, \"http:\/\/host\/new.html\"));\n\n set resp.http.Location = resp.reason;\n set resp.status = 302;\n\n return (deliver);\n }\n\n return (deliver);\n}\n\n# Called when VCL is discarded only after all requests have exited the VCL. Typically used to clean up VMODs.\nsub vcl_fini\n{\n return (ok);\n}\n","old_contents":"vcl 4.0;\n\n# Based on: https:\/\/github.com\/mattiasgeniar\/varnish-4.0-configuration-templates\/blob\/master\/default.vcl\n# Corrected & improved for 4.0.2 by jnerin@gmail.com\n\nimport std;\nimport directors;\n\n# Backend definitions\nbackend default\n{\n .host = \"127.0.0.1\"; # IP or Hostname of backend\n .port = \"8080\"; # Port Apache or whatever is listening\n .max_connections = 300; # That's it\n .probe = {\n #.url = \"\/varnish-enabled\";\n # We prefer to only do a HEAD \/\n .request =\n \"HEAD \/varnish-enabled HTTP\/1.1\"\n \"Host: localhost\"\n \"Connection: close\";\n .interval = 5s; # check the health of each backend every 5 seconds\n .timeout = 1s; # timing out after 1 second.\n # If 3 out of the last 5 polls succeeded the backend is considered healthy, otherwise it will be marked as sick\n .window = 5;\n .threshold = 3;\n }\n\n .connect_timeout = 600s; # How long to wait before we receive a first byte from our backend?\n .first_byte_timeout = 600s; # How long to wait for a backend connection?\n .between_bytes_timeout = 600s; # How long to wait between bytes received from our backend?\n}\n\n# Acl definitions\nacl localhost\n{\n \"localhost\";\n \"33.33.33.63\";\n \"::1\";\n}\n\n# Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\nsub vcl_init\n{\n new vdir = directors.round_robin();\n vdir.add_backend(default);\n # vdir.add_backend(server...);\n # vdir.add_backend(servern);\n}\n\n# Called at the beginning of a request, after the complete request has been received and parsed. Its purpose is to\n# decide whether or not to serve the request, how to do it, and, if applicable, which backend to use also used to\n# modify the request\nsub vcl_recv\n{\n # Add a Surrogate-Capability header to announce ESI support.\n set req.http.Surrogate-Capability = \"varnish=ESI\/1.0\";\n\n # Send all traffic to the vdir director\n set req.backend_hint = vdir.backend(); # send all traffic to the vdir director\n\n if (req.restarts == 0)\n {\n # Set or append the client.ip to X-Forwarded-For header\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n\n set req.http.X-Forwarded-By = server.ip;\n set req.http.X-Forwarded-Port = std.port(client.ip);\n }\n\n # Normalize the header, remove the port (in case you're testing this on various TCP ports)\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n # Normalize the query arguments\n set req.url = std.querysort(req.url);\n\n # Allow purging\n if (req.method == \"PURGE\")\n {\n # purge is the ACL defined at the begining\n if (!client.ip ~ localhost) {\n return (synth(405, \"This IP is not allowed to send PURGE requests.\"));\n }\n\n return (purge);\n }\n\n # Only deal with \"normal\" types\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"PATCH\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n # Implementing websocket support (https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html)\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n # Only cache GET or HEAD requests. This makes sure the POST requests are always passed.\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n # Send Surrogate-Capability headers to announce ESI support to backend\n set req.http.Surrogate-Capability = \"key=ESI\/1.0\";\n if (req.http.Authorization)\n {\n # Not cacheable by default\n return (pass);\n }\n\n # Check if we've still enabled Varnish, if not, passthrough every request\n if (! std.healthy(req.backend_hint))\n {\n set req.backend_hint = default;\n return (pass);\n }\n\n # Specific Nooku Platform rules\n\n # Do not cache \/administrator\n if(req.url ~ \"^\/administrator\") {\n return (pass);\n }\n\n # Specific Nooku Server rules\n\n # Do not cache webgrind.nooku.dev\n if (req.http.host == \"webgrind.nooku.dev\") {\n return (pass);\n }\n\n # Do not cache phpmyadmin.nooku.dev\n if (req.http.host == \"phpmyadmin.nooku.dev\") {\n return (pass);\n }\n\n # Do not cache \/apc and \/phpinfo\n if (req.url == \"\/apc\" || req.url == \"\/phpinfo\") {\n return (pass);\n }\n\n # Generic URL manipulation, useful for all templates that follow\n\n # Remove the Google Analytics added parameters, useless for our backend\n if (req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=\") {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # Strip hash, server doesn't need it.\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n # Strip a trailing ? if it exists\n if (req.url ~ \"\\?$\") {\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # Cookie manipulation\n\n # Remove the \"has_js\" cookie\n set req.http.Cookie = regsuball(req.http.Cookie, \"has_js=[^;]+(; )?\", \"\");\n\n # Remove any Google Analytics based cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__utm.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"_ga=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmctr=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmcmd.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmccn.=[^;]+(; )?\", \"\");\n\n # Remove DoubleClick offensive cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__gads=[^;]+(; )?\", \"\");\n\n # Remove the Quant Capital cookies (added by some plugin, all __qca)\n set req.http.Cookie = regsuball(req.http.Cookie, \"__qc.=[^;]+(; )?\", \"\");\n\n # Remove the AddThis cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__atuv.=[^;]+(; )?\", \"\");\n\n # Remove a \";\" prefix in the cookie if present\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n\n # Remove the csrf_token cookie\n set req.http.Cookie = regsuball(req.http.Cookie, \"csrf_token=[^;]+(; )?\", \"\");\n\n # Are there cookies left with only spaces or that are empty?\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n\n # We do not support SPDY or HTTP\/2.0\n if (req.method == \"PRI\") {\n return (synth(405));\n }\n\n # Normalize Accept-Encoding header\n # straight from the manual: https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/vary.html\n # TODO: Test if it's still needed, Varnish 4 now does this by itself if http_gzip_support = on\n # https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/compression.html\n # https:\/\/www.varnish-cache.org\/docs\/trunk\/phk\/gzip.html\n if (req.http.Accept-Encoding)\n {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n # No point in compressing these\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n # unkown algorithm\n unset req.http.Accept-Encoding;\n }\n }\n\n if (req.http.Cache-Control ~ \"(?i)no-cache\" && client.ip ~ localhost)\n {\n # http:\/\/varnish.projects.linpro.no\/wiki\/VCLExampleEnableForceRefresh\n # Ignore requests via proxy caches and badly behaved crawlers\n # like msnbot that send no-cache with every request.\n if (! (req.http.Via || req.http.User-Agent ~ \"(?i)bot\" || req.http.X-Purge))\n {\n # Doesn't seems to refresh the object in the cache\n set req.hash_always_miss = true;\n\n # Couple this with restart in vcl_purge and X-Purge header to avoid loops\n return(purge);\n }\n }\n\n # Large static files are delivered directly to the end-user without waiting for Varnish to fully read the file first.\n # Varnish 4 fully supports Streaming, so set do_stream in vcl_backend_response()\n if (req.url ~ \"^[^?]*\\.(mp[34]|rar|tar|tgz|gz|wav|zip|bz2|xz|7z|avi|mov|ogm|mpe?g|mk[av])(\\?.*)?$\") {\n unset req.http.Cookie;\n return (hash);\n }\n\n # Remove all cookies for static files\n # Before you blindly enable this, have a read here: https:\/\/ma.ttias.be\/stop-caching-static-files\/\n if (req.method == \"GET\")\n {\n # Cache files with these extensions and remove cookie\n if (req.url ~ \"^[^?]*\\.(bmp|bz2|css|doc|eot|flv|gif|gz|ico|jpeg|jpg|js|less|pdf|png|rtf|swf|txt|woff|xml)(\\?.*)?$\") {\n unset req.http.Cookie;\n return (hash);\n }\n }\n\n return (hash);\n}\n\n# Called upon entering pipe mode. In this mode, the request is passed on to the backend, and any further data from both\n# the client and backend is passed on unaltered until either end closes the connection. Basically, Varnish will degrade\n# into a simple TCP proxy, shuffling bytes back and forth. For a connection in pipe mode, no other VCL subroutine will\n# ever get called after vcl_pipe.\nsub vcl_pipe\n{\n # Note that only the first request to the backend will have X-Forwarded-For set.\n # If you use X-Forwarded-For and want to have it set for all requests, make sure to have:\n # set bereq.http.connection = \"close\";\n # It is not set by default as it might break some broken web applications, like IIS with NTLM authentication.\n # set bereq.http.Connection = \"Close\";\n\n # Implementing websocket support (https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html)\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n\n return (pipe);\n}\n\n# Called upon entering pass mode. In this mode, the request is passed on to the backend, and the backend's response\n# is passed on to the client, but is not entered into the cache. Subsequent requests submitted over the same client\n# connection are handled normally.\nsub vcl_pass\n{\n return (fetch);\n}\n\n# Called after vcl_recv to create a hash value for the request. This is used as a key to look up the object in Varnish.\nsub vcl_hash\n{\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n\n # hash cookies for requests that have them\n if (req.http.Cookie) {\n hash_data(req.http.Cookie);\n }\n}\n\n# Called when a cache lookup is successful.\nsub vcl_hit\n{\n # A pure unadultered hit, deliver it\n if (obj.ttl >= 0s) {\n return (deliver);\n }\n\n # https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-grace.html\n # When several clients are requesting the same page Varnish will send one request to the backend and place the\n # others on hold while fetching one copy from the backend. In some products this is called request coalescing and\n # Varnish does this automatically.\n\n # If you are serving thousands of hits per second the queue of waiting requests can get huge. There are two\n # potential problems - one is a thundering herd problem - suddenly releasing a thousand threads to serve content\n # might send the load sky high. Secondly - nobody likes to wait. To deal with this we can instruct Varnish to keep\n # the objects in cache beyond their TTL and to serve the waiting requests somewhat stale content.\n\n # if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n # return (deliver);\n # } else {\n # return (fetch);\n # }\n\n # We have no fresh fish. Lets look at the stale ones.\n if (std.healthy(req.backend_hint))\n {\n # Backend is healthy. Limit age to 10s.\n if (obj.ttl + 10s > 0s)\n {\n #set req.http.grace = \"normal(limited)\";\n return (deliver);\n }\n else\n {\n # No candidate for grace. Fetch a fresh object.\n return(fetch);\n }\n }\n else\n {\n # backend is sick - use full grace\n if (obj.ttl + obj.grace > 0s)\n {\n #set req.http.grace = \"full\";\n return (deliver);\n }\n else\n {\n # no graced object.\n return (fetch);\n }\n }\n\n # fetch & deliver once we get the result\n return (fetch); # Dead code, keep as a safeguard\n}\n\n# Called after a cache lookup if the requested document was not found in the cache. Its purpose is to decide whether\n# or not to attempt to retrieve the document from the backend, and which backend to use.\nsub vcl_miss\n{\n return (fetch);\n}\n\n # Called after the response headers has been successfully retrieved from the backend.\nsub vcl_backend_response\n{\n # Enable ESI handling\n if (beresp.http.Surrogate-Control ~ \"ESI\/1.0\" ) {\n set beresp.do_esi = true;\n }\n\n # Store the csrf_token cookie temporarily if the response is cacheabale\n if (beresp.http.Set-Cookie && beresp.uncacheable )\n {\n set beresp.http.X-Varnish-Cookie = beresp.http.Set-Cookie;\n unset beresp.http.Set-Cookie;\n }\n\n # Enable cache for all static files\n # Before you blindly enable this, have a read here: https:\/\/ma.ttias.be\/stop-caching-static-files\/\n if (bereq.method == \"GET\")\n {\n if (bereq.url ~ \"^[^?]*\\.(bmp|bz2|css|doc|eot|flv|gif|gz|ico|jpeg|jpg|js|less|mp[34]|pdf|png|rar|rtf|swf|tar|tgz|txt|wav|woff|xml|zip)(\\?.*)?$\") {\n unset beresp.http.Set-Cookie;\n }\n }\n\n # Large static files are delivered directly to the end-user without waiting for Varnish to fully read the file first.\n # Varnish 4 fully supports Streaming, so use streaming here to avoid locking.\n if (bereq.url ~ \"^[^?]*\\.(mp[34]|rar|tar|tgz|gz|wav|zip|bz2|xz|7z|avi|mov|ogm|mpe?g|mk[av])(\\?.*)?$\")\n {\n unset beresp.http.Set-Cookie;\n set beresp.do_stream = true;\n # Check memory usage it'll grow in fetch_chunksize blocks (128k by default) if\n # the backend doesn't send a Content-Length header, so only enable it for big objects\n set beresp.do_gzip = false; # Don't try to compress it for storage\n }\n\n # Sometimes, a 301 or 302 redirect formed via Apache's mod_rewrite can mess with the HTTP port that is being passed along.\n # This often happens with simple rewrite rules in a scenario where Varnish runs on :80 and Apache on :8080 on the same box.\n # A redirect can then often redirect the end-user to a URL on :8080, where it should be :80.\n # This may need finetuning on your setup.\n #\n # To prevent accidental replace, we only filter the 301\/302 redirects for now.\n if (beresp.status == 301 || beresp.status == 302) {\n set beresp.http.Location = regsub(beresp.http.Location, \":[0-9]+\", \"\");\n }\n\n # Set 2min cache if unset for static files\n if (beresp.ttl <= 0s || beresp.http.Set-Cookie || beresp.http.Vary == \"*\")\n {\n set beresp.ttl = 120s; # Important, you shouldn't rely on this, SET YOUR HEADERS in the backend\n set beresp.uncacheable = true;\n\n return (deliver);\n }\n\n # Do not cache errors from the backend\n if (beresp.status >= 400)\n {\n set beresp.uncacheable = true;\n set beresp.ttl = 0s;\n\n return (deliver);\n }\n\n # Allow stale content, in case the backend goes down. Make Varnish keep all objects for 6 hours beyond their TTL\n set beresp.grace = 6h;\n\n # Set ban-lurker friendly custom headers\n set beresp.http.X-Varnish-Url = bereq.url;\n set beresp.http.X-Varnish-Host = bereq.http.host;\n\n return (deliver);\n}\n\n# Called when the backend returns an error\nsub vcl_backend_error\n{\n if (beresp.status == 503 && bereq.retries < 5)\n {\n set beresp.http.X-Varnish-Retries = bereq.retries;\n return(retry);\n }\n\n return(deliver);\n}\n\n# Called before a cached object is delivered to the client.\nsub vcl_deliver\n{\n # Send the Cookie header again if a temporay header was stored\n if (req.http.X-Varnish-Cookie) {\n set resp.http.Set-Cookie = req.http.X-Varnish-Cookie;\n }\n\n # Add extra headers if debugging is enabled\n if (resp.http.x-varnish-debug && server.ip ~ localhost)\n {\n set resp.http.X-Served-By = server.hostname;\n\n if (resp.http.x-varnish ~ \" \") {\n set resp.http.X-Varnish-Status = \"HIT\";\n } else {\n set resp.http.X-Varnish-Status = \"MISS\";\n }\n\n # Please note that obj.hits behaviour changed in 4.0, now it counts per objecthead, not per object\n # and obj.hits may not be reset in some cases where bans are in use. See bug 1492 for details.\n # So take hits with a grain of salt\n set resp.http.X-Varnish-Hits = obj.hits;\n }\n else\n {\n # Remove ban-lurker friendly custom headers when delivering to client\n unset resp.http.X-Url;\n unset resp.http.X-Host;\n\n # Remove some headers: PHP version\n unset resp.http.X-Powered-By;\n\n # Remove some headers: Apache version & OS\n unset resp.http.Server;\n unset resp.http.Via;\n unset resp.http.Link;\n unset resp.http.X-Varnish;\n unset resp.http.X-Varnish-Tag;\n unset resp.http.X-Varnish-Debug;\n unset resp.http.X-Varnish-Host;\n unset resp.http.X-Varnish-Url;\n unset resp.http.X-Varnish-Retries;\n unset resp.http.X-Varnish-Cookie;\n unset resp.http.Surrogate-Control;\n }\n\n return (deliver);\n}\n\nsub vcl_purge\n{\n # Only handle actual PURGE HTTP methods, everything else is discarded\n if (req.method != \"PURGE\" && server.ip ~ localhost)\n {\n set req.http.X-Varnish-Purge = \"Yes\";\n return(restart);\n }\n}\n\nsub vcl_synth\n{\n if (resp.status == 720)\n {\n # We use this special error status 720 to force redirects with 301 (permanent) redirects\n # To use this, call the following from anywhere in vcl_recv: return (synth(720, \"http:\/\/host\/new.html\"));\n set resp.status = 301;\n set resp.http.Location = resp.reason;\n\n return (deliver);\n }\n elseif (resp.status == 721)\n {\n # And we use error status 721 to force redirects with a 302 (temporary) redirect\n # To use this, call the following from anywhere in vcl_recv: return (synth(720, \"http:\/\/host\/new.html\"));\n\n set resp.status = 302;\n set resp.http.Location = resp.reason;\n\n return (deliver);\n }\n\n return (deliver);\n}\n\n# Called when VCL is discarded only after all requests have exited the VCL. Typically used to clean up VMODs.\nsub vcl_fini\n{\n return (ok);\n}\n","returncode":0,"stderr":"","license":"mpl-2.0","lang":"VCL"} {"commit":"6507bf0cfc2d273d31ac32a7b52f9825b578be0c","subject":"remove \/v2\/docs redirects","message":"remove \/v2\/docs redirects\n","repos":"JakeChampion\/polyfill-service,JakeChampion\/polyfill-service","old_file":"fastly\/vcl\/redirects.vcl","new_file":"fastly\/vcl\/redirects.vcl","new_contents":"sub vcl_recv {\n\tif (req.http.Host ~ \"polyfills.io\") {\n\t\t# Fastly recommend using the 900-999 range of status codes for custom errors within an application's VCL.\n\t\t# Do the canonicalise check before the HTTPS check to avoid a double redirect\n\t\terror 901 \"Canonicalise\";\n\t}\n\tif (!req.http.Fastly-SSL) {\n\t\t# 801 is a special error code that Fastly uses to Force HTTPS on the request\n\t\terror 801 \"Redirect to HTTPS\";\n\t}\n\tif (req.http.Orig-URL ~ \"^\/v1\") {\n\t\terror 902 \"Redirect to V2\";\n\t}\n\n\tif (req.url.path == \"\/\") {\n\t\terror 908;\n\t}\n}\n\nsub vcl_error {\n # Redirect to canonical prod\/qa origins\n\tif (obj.status == 901) {\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\tset obj.http.Location = \"https:\/\/polyfill.io\" req.url;\n\t\tsynthetic {\"\"};\n\t\treturn (deliver);\n\t}\n\t# Redirect to v2\n\tif (obj.status == 902) {\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\t# Remove libVersion and gated query parameters if they exist.\n\t\tset req.url = querystring.regfilter(req.url, \"^\\b(libVersion|gated)\\b.*\");\n\t\tset obj.http.Location = if(req.url.path == \"\/v1\", \"\/v3\/\", regsub(req.url, \"^\/v1\", \"\/v2\"));\n\t\tset obj.http.Deprecation-Notice = \"API version 1 has been decommissioned - see the body of this response for more information.\";\n\t\tsynthetic {\"API version 1 has been decommissioned. Your request is being redirected to v2. The `libVersion` and `gated` query string parameters are no longer supported and if present have been removed from your request.\\n\\nA deprecation period for v1 existed between August and December 2015, during which time v1 requests were honoured but a deprecation warning was added to output.\"};\n\t\treturn (deliver);\n\t}\n\n\t# Redirect to v3\n\tif (obj.status == 908) {\n\t\tset obj.status = 301;\n\t\tset obj.http.Location = \"\/v3\/\";\n\t\treturn (deliver);\n\t}\n}\n","old_contents":"sub vcl_recv {\n\tif (req.http.Host ~ \"polyfills.io\") {\n\t\t# Fastly recommend using the 900-999 range of status codes for custom errors within an application's VCL.\n\t\t# Do the canonicalise check before the HTTPS check to avoid a double redirect\n\t\terror 901 \"Canonicalise\";\n\t}\n\tif (!req.http.Fastly-SSL) {\n\t\t# 801 is a special error code that Fastly uses to Force HTTPS on the request\n\t\terror 801 \"Redirect to HTTPS\";\n\t}\n\tif (req.http.Orig-URL ~ \"^\/v1\") {\n\t\terror 902 \"Redirect to V2\";\n\t}\n\t\n\tif (req.url.path != \"\/v2\/polyfill.js\" && req.url.path != \"\/v2\/polyfill.min.js\") {\n\t\tif (req.url.path ~ \"^\/v2($|\/)\") {\n\t\t\terror 908;\n\t\t}\n\t}\n\tif (req.url.path == \"\/\") {\n\t\terror 908;\n\t}\n}\n\nsub vcl_error {\n # Redirect to canonical prod\/qa origins\n\tif (obj.status == 901) {\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\tset obj.http.Location = \"https:\/\/polyfill.io\" req.url;\n\t\tsynthetic {\"\"};\n\t\treturn (deliver);\n\t}\n\t# Redirect to v2\n\tif (obj.status == 902) {\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\t# Remove libVersion and gated query parameters if they exist.\n\t\tset req.url = querystring.regfilter(req.url, \"^\\b(libVersion|gated)\\b.*\");\n\t\tset obj.http.Location = if(req.url.path == \"\/v1\", \"\/v3\/\", regsub(req.url, \"^\/v1\", \"\/v2\"));\n\t\tset obj.http.Deprecation-Notice = \"API version 1 has been decommissioned - see the body of this response for more information.\";\n\t\tsynthetic {\"API version 1 has been decommissioned. Your request is being redirected to v2. The `libVersion` and `gated` query string parameters are no longer supported and if present have been removed from your request.\\n\\nA deprecation period for v1 existed between August and December 2015, during which time v1 requests were honoured but a deprecation warning was added to output.\"};\n\t\treturn (deliver);\n\t}\n\n\t# Redirect to v3\n\tif (obj.status == 908) {\n\t\tset obj.status = 301;\n\t\tset obj.http.Location = \"\/v3\/\";\n\t\treturn (deliver);\n\t}\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"d588ced83c6d35963ed0fac2986908d1fd6fe432","subject":"Revert \"fix redirects\"","message":"Revert \"fix redirects\"\n\nThis reverts commit c4a85eada332dbfb6867d8ec1c80b57f04d6c960.\n","repos":"JakeChampion\/polyfill-service,JakeChampion\/polyfill-service","old_file":"fastly\/vcl\/redirects.vcl","new_file":"fastly\/vcl\/redirects.vcl","new_contents":"sub vcl_recv {\n\tif (req.http.Host ~ \"polyfills.io\") {\n\t\t# Fastly recommend using the 900-999 range of status codes for custom errors within an application's VCL.\n\t\t# Do the canonicalise check before the HTTPS check to avoid a double redirect\n\t\terror 901 \"Canonicalise\";\n\t}\n\tif (!req.http.Fastly-SSL) {\n\t\t# 801 is a special error code that Fastly uses to Force HTTPS on the request\n\t\terror 801 \"Redirect to HTTPS\";\n\t}\n\tif (req.http.Orig-URL ~ \"^\/v1\") {\n\t\terror 902 \"Redirect to V2\";\n\t}\n\n\tif (req.url.path == \"\/\" || req.url.path == \"\/v2\") {\n\t\terror 908;\n\t}\n}\n\nsub vcl_error {\n # Redirect to canonical prod\/qa origins\n\tif (obj.status == 901) {\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\tset obj.http.Location = \"https:\/\/polyfill.io\" req.url;\n\t\tsynthetic {\"\"};\n\t\treturn (deliver);\n\t}\n\t# Redirect to v2\n\tif (obj.status == 902) {\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\t# Remove libVersion and gated query parameters if they exist.\n\t\tset req.url = querystring.regfilter(req.url, \"^\\b(libVersion|gated)\\b.*\");\n\t\tset obj.http.Location = if(req.url.path == \"\/v1\", \"\/v3\/\", regsub(req.url, \"^\/v1\", \"\/v2\"));\n\t\tset obj.http.Deprecation-Notice = \"API version 1 has been decommissioned - see the body of this response for more information.\";\n\t\tsynthetic {\"API version 1 has been decommissioned. Your request is being redirected to v2. The `libVersion` and `gated` query string parameters are no longer supported and if present have been removed from your request.\\n\\nA deprecation period for v1 existed between August and December 2015, during which time v1 requests were honoured but a deprecation warning was added to output.\"};\n\t\treturn (deliver);\n\t}\n\n\t# Redirect to v3\n\tif (obj.status == 908) {\n\t\tset obj.status = 301;\n\t\tset obj.http.Location = \"\/v3\/\";\n\t\treturn (deliver);\n\t}\n}\n","old_contents":"sub vcl_recv {\n\tif (req.http.Host ~ \"polyfills.io\") {\n\t\t# Fastly recommend using the 900-999 range of status codes for custom errors within an application's VCL.\n\t\t# Do the canonicalise check before the HTTPS check to avoid a double redirect\n\t\terror 901 \"Canonicalise\";\n\t}\n\tif (!req.http.Fastly-SSL) {\n\t\t# 801 is a special error code that Fastly uses to Force HTTPS on the request\n\t\terror 801 \"Redirect to HTTPS\";\n\t}\n\tif (req.http.Orig-URL ~ \"^\/v1\") {\n\t\terror 902 \"Redirect to V2\";\n\t}\n\n\tif (req.url.path == \"\/\" || req.url.path == \"\/v2\" || req.url.path == \"\/v2\/docs\/\") {\n\t\terror 908;\n\t}\n}\n\nsub vcl_error {\n # Redirect to canonical prod\/qa origins\n\tif (obj.status == 901) {\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\tset obj.http.Location = \"https:\/\/polyfill.io\" req.url;\n\t\tsynthetic {\"\"};\n\t\treturn (deliver);\n\t}\n\t# Redirect to v2\n\tif (obj.status == 902) {\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\t# Remove libVersion and gated query parameters if they exist.\n\t\tset req.url = querystring.regfilter(req.url, \"^\\b(libVersion|gated)\\b.*\");\n\t\tset obj.http.Location = if(req.url.path == \"\/v1\", \"\/v3\/\", regsub(req.url, \"^\/v1\", \"\/v2\"));\n\t\tset obj.http.Deprecation-Notice = \"API version 1 has been decommissioned - see the body of this response for more information.\";\n\t\tsynthetic {\"API version 1 has been decommissioned. Your request is being redirected to v2. The `libVersion` and `gated` query string parameters are no longer supported and if present have been removed from your request.\\n\\nA deprecation period for v1 existed between August and December 2015, during which time v1 requests were honoured but a deprecation warning was added to output.\"};\n\t\treturn (deliver);\n\t}\n\n\t# Redirect to v3\n\tif (obj.status == 908) {\n\t\tset obj.status = 301;\n\t\tset obj.http.Location = \"\/v3\/\";\n\t\treturn (deliver);\n\t}\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"c46a1ac1f55150f020fa83915266dbf565ef1e0c","subject":"Correct the S3 regex for packages URLs","message":"Correct the S3 regex for packages URLs\n","repos":"karan\/warehouse,dstufft\/warehouse,alex\/warehouse,pypa\/warehouse,karan\/warehouse,alex\/warehouse,wlonk\/warehouse,dstufft\/warehouse,karan\/warehouse,pypa\/warehouse,pypa\/warehouse,karan\/warehouse,karan\/warehouse,dstufft\/warehouse,wlonk\/warehouse,alex\/warehouse,wlonk\/warehouse,pypa\/warehouse,alex\/warehouse,alex\/warehouse,dstufft\/warehouse","old_file":"vcl\/main.vcl","new_file":"vcl\/main.vcl","new_contents":"\nsub vcl_recv {\n\n # I'm not 100% sure on what this is exactly for, it was taken from the\n # Fastly documentation, however, what I *believe* it does is just ensure\n # that we don't serve a stale copy of the page from the shield node when\n # an edge node is requesting content.\n if (req.http.Fastly-FF) {\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Some (Older) clients will send a hash fragment as part of the URL even\n # though that is a local only modification. This breaks this badly for the\n # files in S3, and in general it's just not needed.\n set req.url = regsub(req.url, \"#.*$\", \"\");\n\n # Most of the URLs in Warehouse do not support or require any sort of query\n # parameter. If we strip these at the edge then we'll increase our cache\n # efficiency when they won't otherwise change the output of the pages.\n #\n # This will match any URL except those that start with:\n #\n # * \/search\/\n # * \/account\/login\/\n # * \/account\/logout\/\n # * \/account\/register\/\n # * \/pypi\n if (req.url !~ \"^\/(search\/|account\/(login|logout|register)\/|pypi)\") {\n set req.url = req.url.path;\n }\n\n # Sort all of our query parameters, this will ensure that the same query\n # parameters in a different order will end up being represented as the same\n # thing, reducing cache misses due to ordering differences.\n set req.url = boltsort.sort(req.url);\n\n\n#FASTLY recv\n\n\n # We want to Force SSL for the WebUI by redirecting to the HTTPS version of\n # the page, however for API calls we want to return an error code directing\n # people to instead use HTTPS.\n if (!req.http.Fastly-SSL) {\n\n # The \/simple\/ and \/packages\/ API.\n if (req.url ~ \"^\/(simple|packages)\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy JSON API.\n if (req.url ~ \"^\/pypi\/.+\/json$\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy ?:action= API.\n if (req.url ~ \"^\/pypi.*(\\?|&)=:action\") {\n error 803 \"SSL is required\";\n }\n\n # If we're on the \/pypi page and we've received something other than a\n # GET or HEAD request, then we have no way to determine if a particular\n # request is an API call or not because it'll be in the request body\n # and that isn't available to us here. So in those cases, we won't\n # do a redirect.\n if (req.url ~ \"^\/pypi\") {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n error 801 \"Force SSL\";\n }\n }\n else {\n # This isn't a \/pypi URL so we'll just unconditionally redirect to\n # HTTPS.\n error 801 \"Force SSL\";\n }\n }\n\n # Canonicalize our domains by redirecting any domain that doesn't match our\n # primary domain to our primary domain. We do this *after* the HTTPS check\n # on purpose.\n if (std.tolower(req.http.host) != std.tolower(req.http.Primary-Domain)) {\n set req.http.Location = \"https:\/\/\" req.http.Primary-Domain req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n\n # Requests to \/packages\/ get dispatched to Amazon instead of to our typical\n # Origin. This requires a a bit of setup to make it work.\n if (req.url ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\") {\n # Setup our environment to better match what S3 expects\/needs\n set req.http.Host = req.http.AWS-Bucket-Name \".s3.amazonaws.com\";\n set req.http.Date = now;\n set req.url = regsuball(req.url, \"\\+\", urlencode(\"+\"));\n\n # Compute the Authorization header that S3 requires to be able to\n # access the files stored there.\n set req.http.Authorization = \"AWS \" req.http.AWS-Access-Key-ID \":\" digest.hmac_sha1_base64(req.http.AWS-Secret-Access-Key, \"GET\" LF LF LF req.http.Date LF \"\/\" req.http.AWS-Bucket-Name req.url.path);\n\n # We don't want to send our Warehouse-Token to S3, so we'll go ahead\n # and remove it.\n unset req.http.Warehouse-Token;\n }\n\n # We no longer need any of these variables, which would exist only to\n # shuffle configuration from the Fastly UI into our VCL.\n unset req.http.Primary-Domain;\n unset req.http.AWS-Access-Key-ID;\n unset req.http.AWS-Secret-Access-Key;\n unset req.http.AWS-Bucket-Name;\n\n # We have a number of items that we'll pass back to the origin, but only\n # if we have a Warehouse-Token that will allow them to be accepted.\n if (req.http.Warehouse-Token) {\n # Set a header to tell the backend if we're using https or http.\n if (req.http.Fastly-SSL) {\n set req.http.Warehouse-Proto = \"https\";\n } else {\n set req.http.Warehouse-Proto = \"http\";\n }\n\n # Pass the client IP address back to the backend.\n if (req.http.Fastly-Client-IP) {\n set req.http.Warehouse-IP = req.http.Fastly-Client-IP;\n }\n\n # Pass the real host value back to the backend.\n if (req.http.Host) {\n set req.http.Warehouse-Host = req.http.Host;\n }\n }\n\n # On a POST, we want to skip the shielding and hit backends directly.\n if (req.request == \"POST\") {\n set req.backend = F_Heroku;\n }\n\n # Do not bother to attempt to run the caching mechanisms for methods that\n # are not generally safe to cache.\n if (req.request != \"HEAD\" &&\n req.request != \"GET\" &&\n req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n # We don't ever want to cache our health URL. Outside systems should be\n # able to use it to reach past Fastly and get an end to end health check.\n if (req.url == \"\/_health\/\") {\n return(pass);\n }\n\n # Finally, return the default lookup action.\n return(lookup);\n}\n\n\nsub vcl_fetch {\n\n # For any 5xx status code we want to see if a stale object exists for it,\n # if so we'll go ahead and serve it.\n if (beresp.status >= 500 && beresp.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n\n#FASTLY fetch\n\n\n # Trigger a \"SSL is required\" error if the backend has indicated to do so.\n if (beresp.http.X-Fastly-Error == \"803\") {\n error 803 \"SSL is required\";\n }\n\n # If we've gotten a 502 or a 503 from the backend, we'll go ahead and retry\n # the request.\n if ((beresp.status == 502 || beresp.status == 503) &&\n req.restarts < 1 &&\n (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n # If we've restarted, then we'll record the number of restarts.\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n # If there is a Set-Cookie header, we'll ensure that we do not cache the\n # response.\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n # If the response has the private Cache-Control directive then we won't\n # cache it.\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # If we've gotten an error after the restarts we'll deliver the response\n # with a very short cache time.\n if (http_status_matches(beresp.status, \"500,502,503\")) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n # Apply a default TTL if there isn't a max-age or s-maxage.\n if (beresp.http.Expires ||\n beresp.http.Surrogate-Control ~ \"max-age\" ||\n beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # Keep the ttl here\n }\n else {\n # Apply the default ttl\n set beresp.ttl = 60s;\n }\n\n # Actually deliver the fetched response.\n return(deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n # If the object we have isn't cacheable, then just serve it directly\n # without going through any of the caching mechanisms.\n if (!obj.cacheable) {\n return(pass);\n }\n\n return(deliver);\n}\n\n\nsub vcl_deliver {\n # If this is an error and we have a stale response available, restart so\n # that we can pick it up and serve it.\n if (resp.status >= 500 && resp.status < 600) {\n if (stale.exists) {\n restart;\n }\n }\n\n#FASTLY deliver\n\n # Unset headers that we don't need\/want to send on to the client because\n # they are not generally useful.\n unset resp.http.Server;\n unset resp.http.Via;\n\n # Unset a few headers set by Amazon that we don't really have a need\/desire\n # to send to clients.\n unset resp.http.X-AMZ-Replication-Status;\n unset resp.http.X-AMZ-Meta-Python-Version;\n unset resp.http.X-AMZ-Meta-Version;\n unset resp.http.X-AMZ-Meta-Package-Type;\n unset resp.http.X-AMZ-Meta-Project;\n\n # Set our standard security headers, we do this in VCL rather than in\n # Warehouse itself so that we always get these headers, regardless of the\n # origin server being used.\n set resp.http.Strict-Transport-Security = \"max-age=31536000; includeSubDomains; preload\";\n set resp.http.X-Frame-Options = \"deny\";\n set resp.http.X-XSS-Protection = \"1; mode=block\";\n set resp.http.X-Content-Type-Options = \"nosniff\";\n set resp.http.X-Permitted-Cross-Domain-Policies = \"none\";\n\n return(deliver);\n}\n\n\nsub vcl_error {\n#FASTLY error\n\n # If we have a 5xx error and there is a stale object available, then we\n # will deliver that stale object.\n if (obj.status >= 500 && obj.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n if (obj.status == 803) {\n set obj.status = 403;\n set obj.response = \"SSL is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic {\"SSL is required.\"};\n return (deliver);\n } else if (obj.status == 750) {\n set obj.status = 301;\n set obj.http.Location = req.http.Location;\n set obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n synthetic {\"<html><head><title>301 Moved Permanently<\/title><\/head><body><center><h1>301 Moved Permanently<\/h1><\/center><\/body><\/html>\"};\n return(deliver);\n }\n\n}\n","old_contents":"\nsub vcl_recv {\n\n # I'm not 100% sure on what this is exactly for, it was taken from the\n # Fastly documentation, however, what I *believe* it does is just ensure\n # that we don't serve a stale copy of the page from the shield node when\n # an edge node is requesting content.\n if (req.http.Fastly-FF) {\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Some (Older) clients will send a hash fragment as part of the URL even\n # though that is a local only modification. This breaks this badly for the\n # files in S3, and in general it's just not needed.\n set req.url = regsub(req.url, \"#.*$\", \"\");\n\n # Most of the URLs in Warehouse do not support or require any sort of query\n # parameter. If we strip these at the edge then we'll increase our cache\n # efficiency when they won't otherwise change the output of the pages.\n #\n # This will match any URL except those that start with:\n #\n # * \/search\/\n # * \/account\/login\/\n # * \/account\/logout\/\n # * \/account\/register\/\n # * \/pypi\n if (req.url !~ \"^\/(search\/|account\/(login|logout|register)\/|pypi)\") {\n set req.url = req.url.path;\n }\n\n # Sort all of our query parameters, this will ensure that the same query\n # parameters in a different order will end up being represented as the same\n # thing, reducing cache misses due to ordering differences.\n set req.url = boltsort.sort(req.url);\n\n\n#FASTLY recv\n\n\n # We want to Force SSL for the WebUI by redirecting to the HTTPS version of\n # the page, however for API calls we want to return an error code directing\n # people to instead use HTTPS.\n if (!req.http.Fastly-SSL) {\n\n # The \/simple\/ and \/packages\/ API.\n if (req.url ~ \"^\/(simple|packages)\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy JSON API.\n if (req.url ~ \"^\/pypi\/.+\/json$\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy ?:action= API.\n if (req.url ~ \"^\/pypi.*(\\?|&)=:action\") {\n error 803 \"SSL is required\";\n }\n\n # If we're on the \/pypi page and we've received something other than a\n # GET or HEAD request, then we have no way to determine if a particular\n # request is an API call or not because it'll be in the request body\n # and that isn't available to us here. So in those cases, we won't\n # do a redirect.\n if (req.url ~ \"^\/pypi\") {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n error 801 \"Force SSL\";\n }\n }\n else {\n # This isn't a \/pypi URL so we'll just unconditionally redirect to\n # HTTPS.\n error 801 \"Force SSL\";\n }\n }\n\n # Canonicalize our domains by redirecting any domain that doesn't match our\n # primary domain to our primary domain. We do this *after* the HTTPS check\n # on purpose.\n if (std.tolower(req.http.host) != std.tolower(req.http.Primary-Domain)) {\n set req.http.Location = \"https:\/\/\" req.http.Primary-Domain req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n\n # Requests to \/packages\/ get dispatched to Amazon instead of to our typical\n # Origin. This requires a a bit of setup to make it work.\n if (req.url ~ \"^\/packages\/\") {\n # Setup our environment to better match what S3 expects\/needs\n set req.http.Host = req.http.AWS-Bucket-Name \".s3.amazonaws.com\";\n set req.http.Date = now;\n set req.url = regsuball(req.url, \"\\+\", urlencode(\"+\"));\n\n # Compute the Authorization header that S3 requires to be able to\n # access the files stored there.\n set req.http.Authorization = \"AWS \" req.http.AWS-Access-Key-ID \":\" digest.hmac_sha1_base64(req.http.AWS-Secret-Access-Key, \"GET\" LF LF LF req.http.Date LF \"\/\" req.http.AWS-Bucket-Name req.url.path);\n\n # We don't want to send our Warehouse-Token to S3, so we'll go ahead\n # and remove it.\n unset req.http.Warehouse-Token;\n }\n\n # We no longer need any of these variables, which would exist only to\n # shuffle configuration from the Fastly UI into our VCL.\n unset req.http.Primary-Domain;\n unset req.http.AWS-Access-Key-ID;\n unset req.http.AWS-Secret-Access-Key;\n unset req.http.AWS-Bucket-Name;\n\n # We have a number of items that we'll pass back to the origin, but only\n # if we have a Warehouse-Token that will allow them to be accepted.\n if (req.http.Warehouse-Token) {\n # Set a header to tell the backend if we're using https or http.\n if (req.http.Fastly-SSL) {\n set req.http.Warehouse-Proto = \"https\";\n } else {\n set req.http.Warehouse-Proto = \"http\";\n }\n\n # Pass the client IP address back to the backend.\n if (req.http.Fastly-Client-IP) {\n set req.http.Warehouse-IP = req.http.Fastly-Client-IP;\n }\n\n # Pass the real host value back to the backend.\n if (req.http.Host) {\n set req.http.Warehouse-Host = req.http.Host;\n }\n }\n\n # On a POST, we want to skip the shielding and hit backends directly.\n if (req.request == \"POST\") {\n set req.backend = F_Heroku;\n }\n\n # Do not bother to attempt to run the caching mechanisms for methods that\n # are not generally safe to cache.\n if (req.request != \"HEAD\" &&\n req.request != \"GET\" &&\n req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n # We don't ever want to cache our health URL. Outside systems should be\n # able to use it to reach past Fastly and get an end to end health check.\n if (req.url == \"\/_health\/\") {\n return(pass);\n }\n\n # Finally, return the default lookup action.\n return(lookup);\n}\n\n\nsub vcl_fetch {\n\n # For any 5xx status code we want to see if a stale object exists for it,\n # if so we'll go ahead and serve it.\n if (beresp.status >= 500 && beresp.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n\n#FASTLY fetch\n\n\n # Trigger a \"SSL is required\" error if the backend has indicated to do so.\n if (beresp.http.X-Fastly-Error == \"803\") {\n error 803 \"SSL is required\";\n }\n\n # If we've gotten a 502 or a 503 from the backend, we'll go ahead and retry\n # the request.\n if ((beresp.status == 502 || beresp.status == 503) &&\n req.restarts < 1 &&\n (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n # If we've restarted, then we'll record the number of restarts.\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n # If there is a Set-Cookie header, we'll ensure that we do not cache the\n # response.\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n # If the response has the private Cache-Control directive then we won't\n # cache it.\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # If we've gotten an error after the restarts we'll deliver the response\n # with a very short cache time.\n if (http_status_matches(beresp.status, \"500,502,503\")) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n # Apply a default TTL if there isn't a max-age or s-maxage.\n if (beresp.http.Expires ||\n beresp.http.Surrogate-Control ~ \"max-age\" ||\n beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # Keep the ttl here\n }\n else {\n # Apply the default ttl\n set beresp.ttl = 60s;\n }\n\n # Actually deliver the fetched response.\n return(deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n # If the object we have isn't cacheable, then just serve it directly\n # without going through any of the caching mechanisms.\n if (!obj.cacheable) {\n return(pass);\n }\n\n return(deliver);\n}\n\n\nsub vcl_deliver {\n # If this is an error and we have a stale response available, restart so\n # that we can pick it up and serve it.\n if (resp.status >= 500 && resp.status < 600) {\n if (stale.exists) {\n restart;\n }\n }\n\n#FASTLY deliver\n\n # Unset headers that we don't need\/want to send on to the client because\n # they are not generally useful.\n unset resp.http.Server;\n unset resp.http.Via;\n\n # Unset a few headers set by Amazon that we don't really have a need\/desire\n # to send to clients.\n unset resp.http.X-AMZ-Replication-Status;\n unset resp.http.X-AMZ-Meta-Python-Version;\n unset resp.http.X-AMZ-Meta-Version;\n unset resp.http.X-AMZ-Meta-Package-Type;\n unset resp.http.X-AMZ-Meta-Project;\n\n # Set our standard security headers, we do this in VCL rather than in\n # Warehouse itself so that we always get these headers, regardless of the\n # origin server being used.\n set resp.http.Strict-Transport-Security = \"max-age=31536000; includeSubDomains; preload\";\n set resp.http.X-Frame-Options = \"deny\";\n set resp.http.X-XSS-Protection = \"1; mode=block\";\n set resp.http.X-Content-Type-Options = \"nosniff\";\n set resp.http.X-Permitted-Cross-Domain-Policies = \"none\";\n\n return(deliver);\n}\n\n\nsub vcl_error {\n#FASTLY error\n\n # If we have a 5xx error and there is a stale object available, then we\n # will deliver that stale object.\n if (obj.status >= 500 && obj.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n if (obj.status == 803) {\n set obj.status = 403;\n set obj.response = \"SSL is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic {\"SSL is required.\"};\n return (deliver);\n } else if (obj.status == 750) {\n set obj.status = 301;\n set obj.http.Location = req.http.Location;\n set obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n synthetic {\"<html><head><title>301 Moved Permanently<\/title><\/head><body><center><h1>301 Moved Permanently<\/h1><\/center><\/body><\/html>\"};\n return(deliver);\n }\n\n}\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"e2a4a056ca04a83fb0d24075503cb40408d0fd64","subject":"Don't pipe PATCH","message":"Don't pipe PATCH\n\npipe might receive a complete overhaul in the future but until then\nmake sure we pass this by default.\n\nPrompted by simon on #varnish @ irc.linpro.no.\n","repos":"gquintard\/Varnish-Cache,feld\/Varnish-Cache,feld\/Varnish-Cache,gquintard\/Varnish-Cache,feld\/Varnish-Cache,gquintard\/Varnish-Cache,feld\/Varnish-Cache,feld\/Varnish-Cache,gquintard\/Varnish-Cache","old_file":"bin\/varnishd\/builtin.vcl","new_file":"bin\/varnishd\/builtin.vcl","new_contents":"\/*-\n * Copyright (c) 2006 Verdens Gang AS\n * Copyright (c) 2006-2015 Varnish Software AS\n * All rights reserved.\n *\n * Author: Poul-Henning Kamp <phk@phk.freebsd.dk>\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in the\n * documentation and\/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n\n *\n * The built-in (previously called default) VCL code.\n *\n * NB! You do NOT need to copy & paste all of these functions into your\n * own vcl code, if you do not provide a definition of one of these\n * functions, the compiler will automatically fall back to the default\n * code from this file.\n *\n * This code will be prefixed with a backend declaration built from the\n * -b argument.\n *\/\n\nvcl 4.0;\n\n#######################################################################\n# Client side\n\nsub vcl_recv {\n if (req.method == \"PRI\") {\n\t\/* We do not support SPDY or HTTP\/2.0 *\/\n\treturn (synth(405));\n }\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\" &&\n req.method != \"PATCH\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization || req.http.Cookie) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n return (hash);\n}\n\nsub vcl_pipe {\n # By default Connection: close is set on all piped requests, to stop\n # connection reuse from sending future requests directly to the\n # (potentially) wrong backend. If you do want this to happen, you can undo\n # it here.\n # unset bereq.http.connection;\n return (pipe);\n}\n\nsub vcl_pass {\n return (fetch);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n return (lookup);\n}\n\nsub vcl_purge {\n return (synth(200, \"Purged\"));\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n \/\/ A pure unadultered hit, deliver it\n return (deliver);\n }\n if (obj.ttl + obj.grace > 0s) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n return (deliver);\n }\n \/\/ fetch & deliver once we get the result\n return (miss);\n}\n\nsub vcl_miss {\n return (fetch);\n}\n\nsub vcl_deliver {\n return (deliver);\n}\n\n\/*\n * We can come here \"invisibly\" with the following errors: 500 & 503\n *\/\nsub vcl_synth {\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n set resp.http.Retry-After = \"5\";\n set resp.body = {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"};\n return (deliver);\n}\n\n#######################################################################\n# Backend Fetch\n\nsub vcl_backend_fetch {\n if (bereq.method == \"GET\") {\n unset bereq.body;\n }\n return (fetch);\n}\n\nsub vcl_backend_response {\n if (beresp.ttl <= 0s ||\n beresp.http.Set-Cookie ||\n beresp.http.Surrogate-control ~ \"no-store\" ||\n (!beresp.http.Surrogate-Control &&\n beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n beresp.http.Vary == \"*\") {\n \/*\n * Mark as \"Hit-For-Pass\" for the next 2 minutes\n *\/\n set beresp.ttl = 120s;\n set beresp.uncacheable = true;\n }\n return (deliver);\n}\n\nsub vcl_backend_error {\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n set beresp.body = {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + beresp.status + \" \" + beresp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + beresp.status + \" \" + beresp.reason + {\"<\/h1>\n <p>\"} + beresp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + bereq.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"};\n return (deliver);\n}\n\n#######################################################################\n# Housekeeping\n\nsub vcl_init {\n}\n\nsub vcl_fini {\n return (ok);\n}\n","old_contents":"\/*-\n * Copyright (c) 2006 Verdens Gang AS\n * Copyright (c) 2006-2015 Varnish Software AS\n * All rights reserved.\n *\n * Author: Poul-Henning Kamp <phk@phk.freebsd.dk>\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in the\n * documentation and\/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n\n *\n * The built-in (previously called default) VCL code.\n *\n * NB! You do NOT need to copy & paste all of these functions into your\n * own vcl code, if you do not provide a definition of one of these\n * functions, the compiler will automatically fall back to the default\n * code from this file.\n *\n * This code will be prefixed with a backend declaration built from the\n * -b argument.\n *\/\n\nvcl 4.0;\n\n#######################################################################\n# Client side\n\nsub vcl_recv {\n if (req.method == \"PRI\") {\n\t\/* We do not support SPDY or HTTP\/2.0 *\/\n\treturn (synth(405));\n }\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization || req.http.Cookie) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n return (hash);\n}\n\nsub vcl_pipe {\n # By default Connection: close is set on all piped requests, to stop\n # connection reuse from sending future requests directly to the\n # (potentially) wrong backend. If you do want this to happen, you can undo\n # it here.\n # unset bereq.http.connection;\n return (pipe);\n}\n\nsub vcl_pass {\n return (fetch);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n return (lookup);\n}\n\nsub vcl_purge {\n return (synth(200, \"Purged\"));\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n \/\/ A pure unadultered hit, deliver it\n return (deliver);\n }\n if (obj.ttl + obj.grace > 0s) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n return (deliver);\n }\n \/\/ fetch & deliver once we get the result\n return (miss);\n}\n\nsub vcl_miss {\n return (fetch);\n}\n\nsub vcl_deliver {\n return (deliver);\n}\n\n\/*\n * We can come here \"invisibly\" with the following errors: 500 & 503\n *\/\nsub vcl_synth {\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n set resp.http.Retry-After = \"5\";\n set resp.body = {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"};\n return (deliver);\n}\n\n#######################################################################\n# Backend Fetch\n\nsub vcl_backend_fetch {\n if (bereq.method == \"GET\") {\n unset bereq.body;\n }\n return (fetch);\n}\n\nsub vcl_backend_response {\n if (beresp.ttl <= 0s ||\n beresp.http.Set-Cookie ||\n beresp.http.Surrogate-control ~ \"no-store\" ||\n (!beresp.http.Surrogate-Control &&\n beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n beresp.http.Vary == \"*\") {\n \/*\n * Mark as \"Hit-For-Pass\" for the next 2 minutes\n *\/\n set beresp.ttl = 120s;\n set beresp.uncacheable = true;\n }\n return (deliver);\n}\n\nsub vcl_backend_error {\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n set beresp.body = {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + beresp.status + \" \" + beresp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + beresp.status + \" \" + beresp.reason + {\"<\/h1>\n <p>\"} + beresp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + bereq.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"};\n return (deliver);\n}\n\n#######################################################################\n# Housekeeping\n\nsub vcl_init {\n}\n\nsub vcl_fini {\n return (ok);\n}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"7ec1637def75906fc91f3e19f0450223472fff81","subject":"wrap to 80 columns","message":"wrap to 80 columns\n","repos":"NITEMAN\/varnish-bites,NITEMAN\/Varnish_VCL_samps-hacks","old_file":"varnish4\/drupal-base.vcl","new_file":"varnish4\/drupal-base.vcl","new_contents":"\/*\n * Varnish 4 example config for Drupal 7 \/ Pressflow 6 & 7\n *\/\n\n# Original source: https:\/\/github.com\/NITEMAN\/varnish-bites\/varnish4\/drupal-base.vcl\n# Copyright (c) 2015 Pedro Gonz\u00e1lez Serrano and individual contributors.\n# MIT License\n\n# Intended to be used both in simple production environments and with\n# learning\/teaching purposes.\n# Some references may not be yet updated to VCL 4.0, we use SeeV3 then.\n\n# WARNING:\n# Note that the built-in logic will be appended to our code if no return is\n# performed before.\n# Built-in logic is included commented out right after our's for reference\n# purposes in that cases.\n# See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleDefault\n\n#######################################################################\n# Initialization: Version & imports;\n\n\/* Version statement *\/\n# Since Varnish 4.0 it's mandatory to declare VCL version on first line.\nvcl 4.0;\n\n\/* Module (VMOD) imports *\/\n# Standard module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_std.generated.html\nimport std;\n\n# Directors module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# Unused in simple configs.\n#import directors;\n\n\n#######################################################################\n# Probe, backend, ACL and subroutine definitions\n\n\/* Backend probes \/ healthchecks *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#probes\nprobe basic {\n \/* Only test that backend's IP serves content for '\/' *\/\n # This might be a too heavy probe\n # .url = \"\/\";\n\n \/* Only test that backend's IP has apache working *\/\n # Nginx would fail this probe with a default config\n .request =\n \"OPTIONS * HTTP\/1.1\"\n \"Host: *\"\n \"Connection: close\";\n\n \/* Common options *\/\n .interval = 10s;\n .timeout = 2s;\n .window = 8;\n .threshold = 6;\n}\n\n\/* Backend definitions.*\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#backend-definition\nbackend default {\n \/* Default backend on the same machine. *\/\n # WARNING: timeouts could be not big enought for certain POST requests.\n .host = \"127.0.0.1\";\n .port = \"8008\";\n .max_connections = 100;\n .connect_timeout = 60s;\n .first_byte_timeout = 60s;\n .between_bytes_timeout = 60s;\n .probe = basic;\n}\n\n\/* Access Control Lists *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#access-control-list-acl\nacl purge_ban {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use '\"localhost\";' instead\n}\nacl allowed_monitors {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n}\n# acl own_proxys {\n# \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n# }\n\n\/* Custom subroutines *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#subroutines\n#TODO# Test in Varnihs 4\n# Empty in simple configs.\n# The only restriction naming subs is that the 'vlc_' prefix is reserverd for\n# Varnish use. As a task can need several chunks of code in diferent states,\n# it's a good idea to identify what main sub will call each with a suffix.\n# \/* Example 301 client redirection removing \"www\" prefix from request *\/\n# sub perm_redirections_recv {\n# if ( req.http.host ~ \"^www.*$\" ) {\n# return(\n# synth(751, \"http:\/\/\" + regsub(req.http.host, \"^www\\.\", \"\") + req.url)\n# );\n# }\n# }\n# sub perm_redirections_synth {\n# if (resp.status == 751) {\n# \/* Get new URL from the response *\/\n# set resp.http.Location = resp.response;\n# \/* Set HTTP 301 for permanent redirect *\/\n# set resp.status = 301;\n# return (deliver);\n# }\n# }\n\n\n#######################################################################\n# Client side\n\n# vcl_recv: Called at the beginning of a request, after the complete request\n# has been received and parsed. Its purpose is to decide whether or not to\n# serve the request, how to do it, and, if applicable, which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-recv\nsub vcl_recv {\n \/* 0th: general bypass, general return & authorization checks *\/\n # Empty in simple configs.\n # Useful for debugging we can pipe or pass the request to default backend\n # here to bypass completely Varnish.\n # return (pipe);\n # return (pass);\n # We can also return here a 200 Ok for network performance benchmarking.\n # return(synth(200, \"Ok\"));\n # Finally we can perform basic HTTP authentification here, by example.\n # SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* 1st: Check for Varnish special requests *\/ \n # Custom response implementation example in order to check that Varnish is\n # working properly.\n # This is usefull for automatic monitoring with monit or when Varnish is\n # behind another proxies like HAProxy.\n if ( ( req.http.host == \"monitor.server.health\"\n || req.http.host == \"health.varnish\" )\n && client.ip ~ allowed_monitors\n && ( req.method == \"OPTIONS\" || req.method == \"GET\" )\n ) {\n return(synth(200, \"Ban added\"));\n }\n # Purge logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#http-purging\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if ( req.method == \"PURGE\" ) {\n if ( ! client.ip ~ purge_ban ) {\n return(synth(405, \"Not allowed.\"));\n }\n return (purge);\n }\n # Ban logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#bans\n if ( req.method == \"BAN\" ) {\n if ( ! client.ip ~ purge_ban ) {\n return(synth(405, \"Not allowed.\"));\n }\n ban( \"req.http.host == \" + req.http.host +\n \"&& req.url == \" + req.url);\n return(synth(200, \"Ban added\"));\n }\n\n \/* 2nd: Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_recv;\n # Here we can also enforce SSL when Varnish run behind some SSL termination\n # point.\n\n \/* 3rd: Time for backend choice *\/\n # Empty in simple configs.\n\n \/* 4th: Prepare request for the backend *\/\n # Empty in simple configs.\n # Example remove own_proxys from X-Forwarded-For\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/whats-new\/upgrading.html#x-forwarded-for-is-now-set-before-vcl-recv\n # if ( req.restarts == 0\n # && client.ip ~ own_proxys\n # && req.http.x-forwarded-for\n # ) {\n # set req.http.X-Forwarded-For\n # = regsub(req.http.X-Forwarded-For, \",( )?\" + client.ip, \"\");\n # }\n # Example normalize the host header, remove the port (in case you're testing\n # this on various TCP ports)\n # set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n \/* 5th: Bypass breakpoint 1 *\/\n # Useful for debugging we can now pipe or pass the request to backend with\n # headers setted.\n # return (pipe);\n # return (pass);\n\n \/* 6th: Decide if we should deal with a request (mostly from built-in logic) *\/\n if (req.method == \"PRI\") {\n \/* We do not support SPDY or HTTP\/2.0 *\/\n return (synth(405));\n }\n if ( req.method != \"GET\"\n && req.method != \"HEAD\"\n && req.method != \"PUT\"\n && req.method != \"POST\"\n && req.method != \"TRACE\"\n && req.method != \"OPTIONS\"\n && req.method != \"DELETE\"\n ) {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n\n \/* 7th: Access control for some URLs by ACL *\/\n # Empty in simple configs.\n # By example denial some URLs depending on client-ip, we'll need to define\n # corresponding ACL 'internal'.\n # if ( req.url ~ \"^\/(cron|install)\\.php\"\n # && ! client.ip ~ internal\n # ) {\n # # Have Varnish throw the error directly.\n # return(synth(403, \"Forbidden.\"));\n # # Use a custom error page that you've defined in Drupal at the path \"404\".\n # # set req.url = \"\/403\";\n # }\n\n \/* 8th: Custom exceptions *\/\n # Host exception example:\n # if (req.http.host == \"ejemplo.exception.com\") {\n # return (pass);\n # }\n # Drupal exceptions, edit if we want to cache some AJAX\/AHAH request.\n # Add here filters for never cache URLs such as Payment Gateway's callbacks.\n if ( req.url ~ \"^\/status\\.php$\"\n || req.url ~ \"^\/update\\.php$\"\n || req.url ~ \"^\/ooyala\/ping$\"\n || req.url ~ \"^\/admin\/build\/features\"\n || req.url ~ \"^\/info\/.*$\"\n || req.url ~ \"^\/flag\/.*$\"\n || req.url ~ \"^.*\/ajax\/.*$\"\n || req.url ~ \"^.*\/ahah\/.*$\"\n ) {\n \/* Do not cache these paths *\/\n return (pass);\n }\n # Pipe these paths directly to backend for streaming.\n if (req.url ~ \"^\/admin\/content\/backup_migrate\/export\") {\n return (pipe);\n }\n if (req.url ~ \"^\/system\/files\") {\n return (pipe);\n }\n\n \/* 9th: Graced objets & Serve from anonymous cahe if all backends are down *\/\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n # set req.http.grace = \"none\";\n if ( ! std.healthy(req.backend_hint) ) {\n # We must do this here since cookie hashing\n unset req.http.Cookie;\n #TODO# Add sick marker\n } \n\n \/* 10th: Deal with compression and the Accept-Encoding header *\/\n # Althought Varnish 3 handles gziped content itself by default, just to be\n # sure we want to remove Accept-Encoding for some compressed formats.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html#what-does-http-gzip-support-do\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/varnishd.html?highlight=http_gzip_support\n # See (for older configs) https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleNormalizeAcceptEncoding\n if (req.http.Accept-Encoding) {\n if ( req.url\n ~ \"\\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|mp4|flv|zip|rar)$\"\n ) {\n \/* Already compressed formats, no sense trying to compress again *\/\n unset req.http.Accept-Encoding;\n }\n }\n\n \/* 11th: Another request manipulation *\/\n # Empty in simple configs.\n # We could add here a custom header grouping User-agent families.\n\n \/* 12th: Cookie removal *\/\n # Always cache the following static file types for all users. \n # Use with care if we control certain downloads depending on cookies. \n # Be carefull also if appending .htm[l] via Drupal's clean URLs.\n if ( req.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|woff2|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n && ! req.url ~ \"\/system\/storage\/serve\"\n ) {\n unset req.http.Cookie;\n }\n # Remove all cookies that backend doesn't need to know about.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRemovingSomeCookies\n if (req.http.Cookie) {\n \/* Warning: Not a pretty solution *\/\n # Prefix header containing cookies with ';'\n set req.http.Cookie = \";\" + req.http.Cookie;\n # Remove any spaces after ';' in header containing cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n # Prefix cookies we want to preserve with one space:\n # 'S{1,2}ESS[a-z0-9]+' is the regular expression matching a Drupal session\n # cookie ({1,2} added for HTTPS support).\n # 'NO_CACHE' is usually set after a POST request to make sure issuing user\n # see the results of his post.\n # 'OATMEAL' & 'CHOCOLATECHIP' are special cookies used by Drupal's Bakery\n # module to provide Single Sign On.\n # Keep in mind we should add here any cookie that should reach the backend\n # such as splash avoiding cookies.\n set req.http.Cookie\n = regsuball(\n req.http.Cookie,\n \";(S{1,2}ESS[a-z0-9]+|NO_CACHE|OATMEAL|CHOCOLATECHIP)=\",\n \"; \\1=\"\n );\n # Remove from the header any single Cookie not prefixed with a space until\n # next ';' separator.\n set req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n # Remove any '; ' at the start or the end of the header.\n set req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n #If there are no remaining cookies, remove the cookie header.\n if (req.http.Cookie == \"\") {\n unset req.http.Cookie;\n }\n }\n\n \/* 13th: Session cookie & special cookies bypass caching stage *\/\n # As we might want to cache some requests, hashed with its cookies, we don't\n # simply pass when some cookies remain present at this point.\n # Instead we look for request that must be passed due to the cookie header.\n if ( req.http.Cookie ~ \"SESS\"\n || req.http.Cookie ~ \"SSESS\"\n || req.http.Cookie ~ \"NO_CACHE\"\n || req.http.Cookie ~ \"OATMEAL\"\n || req.http.Cookie ~ \"CHOCOLATECHIP\"\n ) {\n return (pass);\n }\n\n \/* 14th: Bypass breakpoint 2 *\/\n # Useful for debugging we can now pipe or pass the request to backend to\n # bypass cache.\n # return (pipe);\n # return (pass);\n\n \/* 15th: Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n return (hash);\n}\n\n# vcl_pipe: Called upon entering pipe mode.\n# In this mode, the request is passed on to the backend, and any further data\n# from either client or backend is passed on unaltered until either end closes\n# the connection.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pipe\n# sub vcl_pipe {\n# # By default Connection: close is set on all piped requests, to stop\n# # connection reuse from sending future requests directly to the\n# # (potentially) wrong backend. If you do want this to happen, you can undo\n# # it here.\n# # unset bereq.http.connection;\n# return (pipe);\n# }\n\n# vcl_pass: Called upon entering pass mode. \n# In this mode, the request is passed on to the backend, and the backend's\n# response is passed on to the client, but is not entered into the cache.\n# Subsequent requests submitted over the same client connection are handled normally.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pass\n# sub vcl_pass {\n# return (fetch);\n# }\n\n# vcl_hash: You may call hash_data() on the data you would like to add to the\n# hash.\n# Hash is used by Varnish to uniquely identify objects.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hash\nsub vcl_hash {\n \/* Hash cookie data *\/\n # As requests with same URL and host can produce diferent results when issued\n # with different cookies, we need to store items hashed with the associated\n # cookies. Note that cookies are already sanitized when we reach this point.\n if (req.http.Cookie) {\n \/* Include cookie in cache hash *\/\n hash_data(req.http.Cookie);\n }\n\n \/* Custom header hashing *\/\n # Empty in simple configs.\n # Example for caching differents object versions by device previously\n # detected (when static content could also vary):\n # if (req.http.X-UA-Device) {\n # hash_data(req.http.X-UA-Device);\n # }\n # Example for caching diferent object versions by X-Forwarded-Proto, trying\n # to be smart about what kind of request could generate diffetent responses.\n if ( req.http.X-Forwarded-Proto\n && req.url !~ \"(?i)\\.(png|gif|jpeg|jpg|ico|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|woff2|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\") {\n hash_data(req.http.X-Forwarded-Proto);\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (lookup);\n# }\n\n# vcl_purge: Called after the purge has been executed and all its variants have\n# been evited.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-purge\n# sub vcl_purge {\n# return (synth(200, \"Purged\"));\n# }\n\n# vcl_hit: Called after a cache lookup if the requested document was found in\n# the cache.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hit\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n \/\/ A pure unadultered hit, deliver it\n return (deliver);\n }\n \/* Allow varnish to serve up stale content if it is responding slowly *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n if (obj.ttl + 60s > 0s) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n set req.http.grace = \"normal\";\n return (deliver);\n }\n \/* Allow varish to serve up stale content if all backends are down *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n if ( ! std.healthy(req.backend_hint)\n && obj.ttl + obj.grace > 0s\n ) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n set req.http.grace = \"extended\";\n return (deliver);\n }\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\n# vcl_miss: Called after a cache lookup if the requested document was not found\n# in the cache.\n# Its purpose is to decide whether or not to attempt to retrieve the document\n# from the backend, and which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-miss\n# sub vcl_miss {\n# return (fetch);\n# }\n\n# vcl_deliver: Called before an object is delivered to the client\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-deliver\nsub vcl_deliver {\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # Add whether the object is a cache hit or miss and the number of hits for\n # the object.\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Addingaheaderindicatinghitmiss\n # In Varnish 4 the obj.hits counter behaviour has changed (see bug 1492), so\n # we use a different method: if X-Varnish contains only 1 id, we have a miss,\n # if it contains more (and therefore a space), we have a hit.\n if (resp.http.x-varnish ~ \" \") {\n set resp.http.X-Cache = \"HIT\";\n # Since in Varnish 4 the behaviour of obj.hits changed, this might not be\n # accurate.\n # See https:\/\/www.varnish-cache.org\/trac\/ticket\/1492\n set resp.http.X-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Cache = \"MISS\";\n \/* Show the results of cookie sanitization *\/\n set resp.http.X-Cookie = req.http.Cookie;\n }\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n set resp.http.grace = req.http.grace;\n\n #TODO# Add sick marker\n\n # Restart count\n if ( req.restarts > 0) {\n set resp.http.X-Restarts = req.restarts;\n }\n\n # Add the Varnish server hostname\n set resp.http.X-Varnish-Server = server.hostname;\n # If we have setted a custom header with device's family detected we can show\n # it:\n # if (req.http.X-UA-Device) {\n # set resp.http.X-UA-Device = req.http.X-UA-Device;\n # }\n # If we have recived a custom header indicating the protocol in the request we\n # can show it:\n # if (req.http.X-Forwarded-Proto) {\n # set resp.http.X-Forwarded-Proto = req.http.X-Forwarded-Proto;\n # }\n\n \/* Vary header manipulation *\/\n # Empty in simple configs.\n # By example, if we are storing & serving diferent objects depending on\n # User-Agent header we must set the correct Vary header:\n # if (resp.http.Vary) {\n # set resp.http.Vary = resp.http.Vary + \",User-Agent\";\n # } else {\n # set resp.http.Vary = \"User-Agent\";\n # }\n\n \/* Fake headers *\/\n # Empty in simple configs\n # We can fake server headers here, by example:\n # set resp.http.Server = \"Deep thought\";\n # set resp.http.X-Powered-By = \"BOFH\";\n # Or have some fun with headers:\n # See http:\/\/www.nextthing.org\/archives\/2005\/08\/07\/fun-with-http-headers\n # See http:\/\/royal.pingdom.com\/2012\/08\/15\/fun-and-unusual-http-response-headers\/\n # set resp.http.X-Thank-You = \"for bothering to look at my HTTP headers\";\n # set resp.http.X-Answer = \"42\";\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_deliver {\n# return (deliver);\n# }\n\n# vcl_synth: Called to deliver a synthetic object. A synthetic object is\n# generated in VCL, not fetched from the backend. It is typically contructed\n# using the synthetic() function.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-synth\n\/*\n * We can come here \"invisibly\" with the following errors: 413, 417 & 503\n *\/\nsub vcl_synth {\n \/* Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_synth;\n\n \/* Try to restart request in case of failure *\/\n # Note that max_restarts defaults to 4\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if (resp.status == 503 && req.restarts < 4) {\n return(restart);\n }\n\n \/* Set common headers for synthetic responses *\/\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n\n \/* HTTP Authentification client request *\/\n # Empty in simple configs.\n # SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* Load synthetic responses from disk *\/\n # Note that files loaded this way are never re-readed (even after a reload).\n # You should consider PROS\/CONS of doing an include instead.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_std.generated.html#func-fileread\n # Example custom 403 error page.\n # if (resp.status == 403) {\n # synthetic(std.fileread(\"\/403.html\"));\n # return(deliver);\n # }\n\n \/* Error page & refresh \/ redirections *\/\n # We have plenty of choices when we have to serve an error to the client, \n # from the default error page to javascript black magic or plain redirections.\n # Adding some external statistic javascript to track failures served to\n # clients is strongly suggested.\n # We can't use external resources on synthetic content, everything must be\n # inlined.\n # If we need to include images we can embed them in base64 encoding.\n # We're using error 200 for monitoring puposes which should not be retried\n # client side.\n if ( resp.status != 200) {\n set resp.http.Retry-After = \"5\";\n }\n\n # Here is the default error page for Varnish 4 (not so pretty)\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n return (deliver);\n}\n\n#######################################################################\n# Backend Fetch\n\n# vcl_backend_fetch: Called before sending the backend request. In this\n# subroutine you typically alter the request before it gets to the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-fetch\n# sub vcl_backend_fetch {\n# return (fetch);\n# }\n\n# vcl_backend_response: Called after the response headers has been successfully\n# retrieved from the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-response\nsub vcl_backend_response {\n \/* Caching exceptions *\/\n # Varnish will cache objects with response codes:\n # 200, 203, 300, 301, 302, 307, 404 & 410.\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/VCL_Basics.html#the-initial-value-of-beresp-ttl\n # Drupal's Imagecache module can return a 307 redirection to the requested\n # url itself and, depending on Drupal's cache settings, this could lead to a\n # redirection loop being cached for a long time but also we want Varnish to\n # shield a little the backend.\n # See http:\/\/drupal.org\/node\/1248010\n # See http:\/\/drupal.org\/node\/310656\n if (beresp.status == 307 &&\n #TODO# verify that this work better than 'bereq.url ~ \"imagecache\"'\n beresp.http.Location == bereq.url &&\n beresp.ttl > 5s) {\n set beresp.ttl = 5s;\n set beresp.http.cache-control = \"max-age=5\";\n }\n\n \/* Request retrial *\/\n if ( beresp.status == 500\n || beresp.status == 503\n ) {\n #TODO# consider not restarting POST requests as seenV3 on https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleSaintMode\n return (retry);\n }\n\n \/* Enable grace mode. Related with vcl_hit *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n set beresp.grace = 1h;\n\n \/* Strip cookies from the following static file types for all users. *\/\n # Related with our 12th stage on vcl_recv\n if (bereq.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|woff2|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\") {\n unset beresp.http.set-cookie;\n }\n\n \/* Gzip response *\/\n # Empty in simple configs.\n # Use Varnish to Gzip respone, if suitable, before storing it on cache.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html\n if ( ! beresp.http.Content-Encoding\n && ( beresp.http.content-type ~ \"text\"\n || beresp.http.content-type ~ \"application\/x-javascript\"\n || beresp.http.content-type ~ \"application\/javascript\"\n || beresp.http.content-type ~ \"application\/rss+xml\"\n || beresp.http.content-type ~ \"application\/xml\"\n || beresp.http.content-type ~ \"Application\/JSON\")\n ) {\n set beresp.do_gzip = true;\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # We can add the name of the backend that has processed the request:\n # set beresp.http.X-Backend = beresp.backend.name;\n # We can use a header to tell if the object was gziped by Varnish:\n # if (beresp.do_gzip) {\n # set beresp.http.X-Varnish-Gzipped = \"yes\";\n # } else {\n # set beresp.http.X-Varnish-Gizipped = \"no\";\n # }\n # We can also add headers informing whether the object is cacheable or not and why:\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Varnish3.0\n if (beresp.ttl <= 0s) {\n \/* Varnish determined the object was not cacheable *\/\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n } elsif (bereq.http.Cookie ~ \"(SESS|SSESS|NO_CACHE|OATMEAL|CHOCOLATECHIP)\") {\n \/* We don't wish to cache content for logged in users or with certain cookies. *\/\n # Related with our 9th stage on vcl_recv\n set beresp.http.X-Cacheable = \"NO:Cookies\";\n # return(hit_for_pass);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n \/* We are respecting the Cache-Control=private header from the backend *\/\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n # return(hit_for_pass);\n } else {\n \/* Varnish determined the object was cacheable *\/\n set beresp.http.X-Cacheable = \"YES\";\n }\n\n \/* Further header manipulation *\/\n # Empty in simple configs.\n # We can also unset some headers to prevent information disclosure and save\n # some cache space.\n # unset beresp.http.Server;\n # unset beresp.http.X-Powered-By;\n # Retry count.\n if ( bereq.retries > 0) {\n set beresp.http.X-Retries = bereq.retries;\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_backend_response {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Surrogate-control ~ \"no-store\" ||\n# (!beresp.http.Surrogate-Control &&\n# beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n# beresp.http.Vary == \"*\") {\n# \/*\n# * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# *\/\n# set beresp.ttl = 120s;\n# set beresp.uncacheable = true;\n# }\n# return (deliver);\n# }\n\n# vcl_backend_error: This subroutine is called if we fail the backend fetch.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-error\nsub vcl_backend_error {\n\n \/* Try to restart request in case of failure *\/\n #TODO# Confirm max_retries default value\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if (bereq.retries < 4) {\n return (retry);\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # Retry count\n if ( bereq.retries > 0) {\n set beresp.http.X-Retries = bereq.retries;\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + beresp.status + \" \" + beresp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + beresp.status + \" \" + beresp.reason + {\"<\/h1>\n <p>\"} + beresp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + bereq.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this\n # point.\n return (deliver);\n}\n\n#######################################################################\n# Housekeeping\n\n# vcl_init: Called when VCL is loaded, before any requests pass through it.\n# Typically used to initialize VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-init\n# Here is where you should declare your directors now.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-backends.html#directors\n# Empty in simple configs\n# sub vcl_init {\n# return (ok);\n# }\n\n# vcl_fini: Called when VCL is discarded only after all requests have exited\n# the VCL. Typically used to clean up VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-fini\n# sub vcl_fini {\n# return (ok);\n# }\n\n","old_contents":"\/* Varnish 4 example config for Drupal 7 \/ Pressflow 6 & 7 *\/\n# Original source: https:\/\/github.com\/NITEMAN\/varnish-bites\/varnish4\/drupal-base.vcl\n# Copyright (c) 2015 Pedro Gonz\u00e1lez Serrano and individual contributors.\n# MIT License\n\n# Intended to be used both in simple production environments and with\n# learning\/teaching purposes.\n# Some references may not be yet updated to VCL 4.0, we use SeeV3 then.\n\n# WARNING:\n# Note that the built-in logic will be appended to our code if no return is performed before.\n# Built-in logic is included commented out right after our's for reference purposes in that cases.\n# See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleDefault\n\n#######################################################################\n# Initialization: Version & imports;\n\n\/* Version statement *\/\n# Since Varnish 4.0 it's mandatory to declare VCL version on first line.\nvcl 4.0;\n\n\/* Module (VMOD) imports *\/\n# Standard module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_std.generated.html\nimport std;\n\n# Directors module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# Unused in simple configs.\n#import directors;\n\n\n#######################################################################\n# Probe, backend, ACL and subroutine definitions\n\n\/* Backend probes \/ healthchecks *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#probes\nprobe basic {\n \/* Only test that backend's IP serves content for '\/' *\/\n # This might be a too heavy probe\n # .url = \"\/\";\n \/* Only test that backend's IP has apache working *\/\n # Nginx would fail this probe with a default config\n .request =\n \"OPTIONS * HTTP\/1.1\"\n \"Host: *\"\n \"Connection: close\";\n .interval = 10s;\n .timeout = 2s;\n .window = 8;\n .threshold = 6;\n}\n\n\/* Backend definitions.*\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#backend-definition\nbackend default {\n \/* Default backend on the same machine. WARNING: timeouts could be not big enought for certain POST request *\/\n .host = \"127.0.0.1\";\n .port = \"8008\";\n .max_connections = 100;\n .connect_timeout = 60s;\n .first_byte_timeout = 60s;\n .between_bytes_timeout = 60s;\n .probe = basic;\n}\n\n\/* Access Control Lists *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#access-control-list-acl\nacl purge_ban {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use '\"localhost\";' instead\n}\nacl allowed_monitors {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n}\n#acl own_proxys {\n# \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n#}\n\n\/* Custom subroutines *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#subroutines\n#TODO# Test in Varnihs 4\n# Empty in simple configs.\n# We can name subs with no restrictions but as a task can need several chunks of code in diferent states,\n# it's a good idea to identify what main sub will call each with a suffix.\n# \/* Example 301 client redirection removing \"www\" prefix from request *\/\n# sub perm_redirections_recv {\n# if ( req.http.host ~ \"^www.*$\" ) {\n# return(synth(751, \"http:\/\/\" + regsub(req.http.host, \"^www\\.\", \"\") + req.url));\n# }\n# }\n# sub perm_redirections_synth {\n# if (resp.status == 751) {\n# \/* Get new URL from the response *\/\n# set resp.http.Location = resp.response;\n# \/* Set HTTP 301 for permanent redirect *\/\n# set resp.status = 301;\n# return (deliver);\n# }\n# }\n\n\n#######################################################################\n# Client side\n\n# vcl_recv: Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-recv\nsub vcl_recv {\n \/* 0th: general bypass, general return & authorization checks *\/\n # Empty in simple configs.\n # Useful for debugging we can pipe or pass the request to default backend here to bypass completely Varnish.\n # return (pipe);\n # return (pass);\n # We can also return here a 200 Ok for network performance benchmarking.\n # return(synth(200, \"Ok\"));\n # Finally we can perform basic HTTP authentification here, by example.\n # SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* 1st: Check for Varnish special requests *\/ \n # Custom response implementation example in order to check that Varnish is working properly.\n # This is usefull for automatic monitoring with monit or when Varnish is behind another proxies like HAProxy.\n if ( ( req.http.host == \"monitor.server.health\"\n || req.http.host == \"health.varnish\" )\n && client.ip ~ allowed_monitors\n && ( req.method == \"OPTIONS\" || req.method == \"GET\" )\n ) {\n return(synth(200, \"Ban added\"));\n }\n # Purge logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#http-purging\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if (req.method == \"PURGE\") {\n if (!client.ip ~ purge_ban) {\n return(synth(405, \"Not allowed.\"));\n }\n return (purge);\n }\n # Ban logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#bans\n if (req.method == \"BAN\") {\n if (!client.ip ~ purge_ban) {\n return(synth(405, \"Not allowed.\"));\n }\n ban(\"req.http.host == \" + req.http.host +\n \"&& req.url == \" + req.url); \n return(synth(200, \"Ban added\"));\n }\n\n \/* 2nd: Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_recv;\n # Here we can also enforce SSL when Varnish run behind some SSL termination point.\n\n \/* 3rd: Time for backend choice *\/\n # Empty in simple configs.\n\n \/* 4th: Prepare headers for the backend *\/\n # Empty in simple configs.\n # Example remove own_proxys from X-Forwarded-For\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/whats-new\/upgrading.html#x-forwarded-for-is-now-set-before-vcl-recv\n # if ( req.restarts == 0\n # && client.ip ~ own_proxys\n # && req.http.x-forwarded-for\n # ) {\n # set req.http.X-Forwarded-For = regsub(req.http.X-Forwarded-For, \",( )?\" + client.ip, \"\");\n # }\n\n \/* 5th: Bypass breakpoint 1 *\/\n # Useful for debugging we can now pipe or pass the request to backend with headers setted.\n # return (pipe);\n # return (pass);\n\n \/* 6th: Decide if we should deal with a request (mostly copied from built-in logic) *\/\n if (req.method == \"PRI\") {\n \/* We do not support SPDY or HTTP\/2.0 *\/\n return (synth(405));\n }\n if ( req.method != \"GET\"\n && req.method != \"HEAD\"\n && req.method != \"PUT\"\n && req.method != \"POST\"\n && req.method != \"TRACE\"\n && req.method != \"OPTIONS\"\n && req.method != \"DELETE\"\n ) {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n\n \/* 7th: Access control for some URLs by ACL *\/\n # Empty in simple configs.\n # By example denial some URLs depending on client-ip, we'll need to define corresponding ACL 'internal'.\n # if ( req.url ~ \"^\/(cron|install)\\.php\"\n # && ! client.ip ~ internal\n # ) {\n # # Have Varnish throw the error directly.\n # return(synth(403, \"Forbidden.\"));\n # # Use a custom error page that you've defined in Drupal at the path \"404\".\n # # set req.url = \"\/403\";\n # }\n\n \/* 8th: Custom exceptions *\/\n # Host exception example:\n # if (req.http.host == \"ejemplo.exception.com\") {\n # return (pass);\n # }\n # Drupal exceptions, edit if we want to cache some AJAX\/AHAH request.\n # Add here filters for never cache URLs such as Payment Gateway's callbacks\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/ooyala\/ping$\" ||\n req.url ~ \"^\/admin\/build\/features\" ||\n req.url ~ \"^\/info\/.*$\" ||\n req.url ~ \"^\/flag\/.*$\" ||\n req.url ~ \"^.*\/ajax\/.*$\" ||\n req.url ~ \"^.*\/ahah\/.*$\") {\n \/* Do not cache these paths *\/\n return (pass);\n }\n # Pipe these paths directly to backend for streaming.\n if (req.url ~ \"^\/admin\/content\/backup_migrate\/export\") {\n return (pipe);\n }\n if (req.url ~ \"^\/system\/files\") {\n return (pipe);\n }\n\n \/* 9th: Graced objets & Serve from anonymous cahe if all backends are down *\/\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n # set req.http.grace = \"none\";\n if (! std.healthy(req.backend_hint) ) {\n # We must do this here since cookie hashing\n unset req.http.Cookie;\n #TODO# Add sick marker\n } \n\n \/* 10th: Deal with compression and the Accept-Encoding header *\/\n # Althought Varnish 3 handles gziped content itself by default, just to be sure we want to \n # remove Accept-Encoding for some compressed formats.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html#what-does-http-gzip-support-do\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/varnishd.html?highlight=http_gzip_support\n # See (for older configs) https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleNormalizeAcceptEncoding\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|mp4|flv|zip|rar)$\") {\n \/* Already compressed formats, no sense trying to compress again *\/\n unset req.http.Accept-Encoding;\n }\n }\n\n \/* 11th: Another header manipulation *\/\n # Empty in simple configs.\n # We could add here a custom header grouping User-agent families.\n\n \/* 12th: Cookie removal *\/\n # Always cache the following static file types for all users. \n # Use with care if we control certain downloads depending on cookies. \n # Be carefull also if appending .htm[l] via Drupal's clean URLs.\n if ( req.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|woff2|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n && req.url !~ \"\/system\/storage\/serve\"\n ) {\n unset req.http.Cookie;\n }\n # Remove all cookies that backend doesn't need to know about.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRemovingSomeCookies\n if (req.http.Cookie) {\n \/* Warning: Not a pretty solution *\/\n \/* Prefix header containing cookies with ';' *\/\n set req.http.Cookie = \";\" + req.http.Cookie;\n \/* Remove any spaces after ';' in header containing cookies *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n \/* Prefix cookies we want to preserve with one space *\/\n \/* 'S{1,2}ESS[a-z0-9]+' is the regular expression matching a Drupal session cookie ({1,2} added for HTTPS support) *\/\n \/* 'NO_CACHE' is usually set after a POST request to make sure issuing user see the results of his post *\/\n \/* 'OATMEAL' & 'CHOCOLATECHIP' are special cookies used by Drupal's Bakery module to provide Single Sign On *\/\n \/* Keep in mind we should add here any cookie that should reach the backend such as splahs avoiding cookies *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \";(S{1,2}ESS[a-z0-9]+|NO_CACHE|OATMEAL|CHOCOLATECHIP)=\", \"; \\1=\");\n \/* Remove from the header any single Cookie not prefixed with a space until next ';' separator *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n \/* Remove any '; ' at the start or the end of the header *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n\n if (req.http.Cookie == \"\") {\n \/* If there are no remaining cookies, remove the cookie header. *\/\n unset req.http.Cookie;\n }\n }\n\n \/* 13th: Session cookie & special cookies bypass caching stage *\/\n # As we might want to cache some requests, hashed with its cookies, \n # we don't simply pass when some cookies remain present at this point.\n # Instead we look for request that must be passed due to the cookie header.\n if ( req.http.Cookie ~ \"SESS\"\n || req.http.Cookie ~ \"SSESS\"\n || req.http.Cookie ~ \"NO_CACHE\"\n || req.http.Cookie ~ \"OATMEAL\"\n || req.http.Cookie ~ \"CHOCOLATECHIP\"\n ) {\n return (pass);\n }\n\n \/* 14th: Bypass breakpoint 2 *\/\n # Useful for debugging we can now pipe or pass the request to backend to bypass cache.\n # return (pipe);\n # return (pass);\n\n \/* 15th: Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning inconditionally.\n return (hash);\n}\n\n# vcl_pipe: Called upon entering pipe mode.\n# In this mode, the request is passed on to the backend, \n# and any further data from either client or backend is passed on unaltered until either end closes the connection.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pipe\n# sub vcl_pipe {\n# # By default Connection: close is set on all piped requests, to stop\n# # connection reuse from sending future requests directly to the\n# # (potentially) wrong backend. If you do want this to happen, you can undo\n# # it here.\n# # unset bereq.http.connection;\n# return (pipe);\n# }\n\n# vcl_pass: Called upon entering pass mode. \n# In this mode, the request is passed on to the backend, and the backend's response is passed on to the client, \n# but is not entered into the cache.\n# Subsequent requests submitted over the same client connection are handled normally.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pass\n# sub vcl_pass {\n# return (fetch);\n# }\n\n# vcl_hash: You may call hash_data() on the data you would like to add to the hash.\n# Hash is used by Varnish to uniquely identify objects.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hash\nsub vcl_hash {\n \/* Hash cookie data *\/\n # As requests with same URL and host can produce diferent results when issued with different cookies,\n # we need to store items hashed with the associated cookies. Note that cookies are already sanitized when we reach this point.\n if (req.http.Cookie) {\n \/* Include cookie in cache hash *\/\n hash_data(req.http.Cookie);\n }\n\n \/* Custom header hashing *\/\n # Empty in simple configs.\n # Example for caching differents object versions by device previously detected (when static content could also vary):\n # if (req.http.X-UA-Device) {\n # hash_data(req.http.X-UA-Device);\n # }\n # Example for caching diferent object versions by X-Forwarded-Proto, trying to be smart about what kind of request\n # could generate diffetent responses.\n if ( req.http.X-Forwarded-Proto\n && req.url !~ \"(?i)\\.(png|gif|jpeg|jpg|ico|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|woff2|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\") {\n hash_data(req.http.X-Forwarded-Proto);\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (lookup);\n# }\n\n# vcl_purge: Called after the purge has been executed and all its variants have been evited.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-purge\n# sub vcl_purge {\n# return (synth(200, \"Purged\"));\n# }\n\n# vcl_hit: Called after a cache lookup if the requested document was found in the cache.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hit\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n \/\/ A pure unadultered hit, deliver it\n return (deliver);\n }\n \/* Allow varnish to serve up stale content if it is responding slowly *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n if (obj.ttl + 60s > 0s) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n set req.http.grace = \"normal\";\n return (deliver);\n }\n \/* Allow varish to serve up stale content if all backends are down *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n if ( ! std.healthy(req.backend_hint)\n && obj.ttl + obj.grace > 0s\n ) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n set req.http.grace = \"extended\";\n return (deliver);\n }\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning inconditionally.\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\n# vcl_miss: Called after a cache lookup if the requested document was not found in the cache.\n# Its purpose is to decide whether or not to attempt to retrieve the document from the backend, and which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-miss\n# sub vcl_miss {\n# return (fetch);\n# }\n\n# vcl_deliver: Called before an object is delivered to the client\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-deliver\nsub vcl_deliver {\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # Add whether the object is a cache hit or miss and the number of hits for the object.\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Addingaheaderindicatinghitmiss\n # In Varnish 4 the obj.hits counter behaviour has changed (see bug 1492), so\n # we use a different method: if X-Varnish contains only 1 id, we have a miss,\n # if it contains more (and therefore a space), we have a hit.\n if (resp.http.x-varnish ~ \" \") {\n set resp.http.X-Cache = \"HIT\";\n # Since in Varnish 4 the behaviour of obj.hits changed, this might not be accurate\n # See https:\/\/www.varnish-cache.org\/trac\/ticket\/1492\n set resp.http.X-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Cache = \"MISS\";\n \/* Show the results of cookie sanitization *\/\n set resp.http.X-Cookie = req.http.Cookie;\n }\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n set resp.http.grace = req.http.grace;\n\n #TODO# Add sick marker\n\n # Restart count\n if ( req.restarts > 0) {\n set resp.http.X-Restarts = req.restarts;\n }\n\n # Add the Varnish server hostname\n set resp.http.X-Varnish-Server = server.hostname;\n # If we have setted a custom header with device family detected we can show it:\n # if (req.http.X-UA-Device) {\n # set resp.http.X-UA-Device = req.http.X-UA-Device;\n # }\n # If we have recived a custom header with the protocol in the request we can show it:\n # if (req.http.X-Forwarded-Proto) {\n # set resp.http.X-Forwarded-Proto = req.http.X-Forwarded-Proto;\n # }\n\n \/* Vary header manipulation *\/\n # Empty in simple configs.\n # By example, if we are storing & serving diferent objects depending on User-Agent header we must set the correct Vary header:\n # if (resp.http.Vary) {\n # set resp.http.Vary = resp.http.Vary + \",User-Agent\";\n # } else {\n # set resp.http.Vary = \"User-Agent\";\n # }\n\n \/* Fake headers *\/\n # Empty in simple configs\n # We can fake server headers here, by example:\n # set resp.http.Server = \"Deep thought\";\n # set resp.http.X-Powered-By = \"BOFH\";\n # Or have some fun with headers:\n # See http:\/\/www.nextthing.org\/archives\/2005\/08\/07\/fun-with-http-headers\n # See http:\/\/royal.pingdom.com\/2012\/08\/15\/fun-and-unusual-http-response-headers\/\n # set resp.http.X-Thank-You = \"for bothering to look at my HTTP headers\";\n # set resp.http.X-Answer = \"42\";\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_deliver {\n# return (deliver);\n# }\n\n# vcl_synth: Called to deliver a synthetic object. A synthetic object is generated in VCL,\n# not fetched from the backend. It is typically contructed using the synthetic() function.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-synth\n\/*\n * We can come here \"invisibly\" with the following errors: 413, 417 & 503\n *\/\nsub vcl_synth {\n \/* Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_synth;\n\n \/* Try to restart request in case of failure *\/\n # Note that max_restarts defaults to 4\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if (resp.status == 503 && req.restarts < 4) {\n return(restart);\n }\n\n \/* Set common headers for synthetic responses *\/\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n\n \/* HTTP Authentification client request *\/\n # Empty in simple configs. SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* Load synthetic responses from disk *\/\n # Note that files loaded this way are never re-readed (even after a reload).\n # You should consider PROS\/CONS of doing an include instead.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_std.generated.html#func-fileread\n # Example custom 403 error page.\n # if (resp.status == 403) {\n # synthetic(std.fileread(\"\/403.html\"));\n # return(deliver);\n # }\n\n \/* Error page & refresh \/ redirections *\/\n # We have plenty of choices when we have to serve an error to the client, \n # from the default error page to javascript black magic or plain redirections.\n # Adding some external statistic javascript to track failures served to clients is strongly suggested.\n # We can't use external resources on synthetic content, everything must be inlined.\n # If we need to include images we can embed them in base64 encoding.\n # Here is the default error page for Varnish 4 (not so pretty)\n # We're using error 200 for monitoring puposes which should not be retried client side *\/\n if ( resp.status != 200) {\n set resp.http.Retry-After = \"5\";\n }\n\n # Consider add some analytics stuff to trace accesses\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning inconditionally.\n return (deliver);\n}\n\n#######################################################################\n# Backend Fetch\n\n# vcl_backend_fetch: Called before sending the backend request. In this subroutine you typically alter the request before it gets to the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-fetch\n# sub vcl_backend_fetch {\n# return (fetch);\n# }\n\n# vcl_backend_response: Called after the response headers has been successfully retrieved from the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-response\nsub vcl_backend_response {\n \/* Caching exceptions *\/\n # Varnish will cache objects with response codes: 200, 203, 300, 301, 302, 307, 404 & 410.\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/VCL_Basics.html#the-initial-value-of-beresp-ttl\n # Drupal's Imagecache module can return a 307 redirection to the requested url itself and, depending on Drupal's cache settings,\n # this could lead to a redirection loop being cached for a long time but also we want Varnish to shield a little the backend.\n # See http:\/\/drupal.org\/node\/1248010\n # See http:\/\/drupal.org\/node\/310656\n if (beresp.status == 307 &&\n #TODO# verify that this work better than 'bereq.url ~ \"imagecache\"' *\/\n beresp.http.Location == bereq.url &&\n beresp.ttl > 5s) {\n set beresp.ttl = 5s;\n set beresp.http.cache-control = \"max-age=5\";\n }\n\n \/* Request retrial *\/\n if ( beresp.status == 500\n || beresp.status == 503\n ) {\n #TODO# consider not restarting POST requests as seenV3 on https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleSaintMode\n return (retry);\n }\n\n \/* Enable grace mode. Related with vcl_hit *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n set beresp.grace = 1h;\n\n \/* Strip cookies from the following static file types for all users. Related with our 12th stage on vcl_recv *\/\n if (bereq.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|woff2|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\") {\n unset beresp.http.set-cookie;\n }\n\n \/* Gzip response *\/\n # Empty in simple configs\n # Use Varnish to Gzip respone, if suitable, before storing it on cache\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html\n if ( ! beresp.http.Content-Encoding\n && ( beresp.http.content-type ~ \"text\"\n || beresp.http.content-type ~ \"application\/x-javascript\"\n || beresp.http.content-type ~ \"application\/javascript\"\n || beresp.http.content-type ~ \"application\/rss+xml\"\n || beresp.http.content-type ~ \"application\/xml\"\n || beresp.http.content-type ~ \"Application\/JSON\")\n ) {\n set beresp.do_gzip = true;\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # We can add the name of the backend that has processed the request:\n # set beresp.http.X-Backend = beresp.backend.name;\n # We can use a header to tell if the object was gziped by Varnish\n # if (beresp.do_gzip) {\n # set beresp.http.X-Varnish-Gzipped = \"yes\";\n # } else {\n # set beresp.http.X-Varnish-Gizipped = \"no\";\n # }\n # We can also add headers informing whether the object is cacheable or not and why.\n # https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Varnish3.0\n if (beresp.ttl <= 0s) {\n \/* Varnish determined the object was not cacheable *\/\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n } elsif (bereq.http.Cookie ~ \"(SESS|SSESS|NO_CACHE|OATMEAL|CHOCOLATECHIP)\") {\n \/* We don't wish to cache content for logged in users or with certain cookies. Related with our 9th stage on vcl_recv *\/\n set beresp.http.X-Cacheable = \"NO:Cookies\";\n # return(hit_for_pass);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n \/* We are respecting the Cache-Control=private header from the backend *\/\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n # return(hit_for_pass);\n } else {\n \/* Varnish determined the object was cacheable *\/\n set beresp.http.X-Cacheable = \"YES\";\n }\n\n \/* Further header manipulation *\/\n # Empty in simple configs.\n # We can also unset some headers to prevent information disclosure and save some cache space\n # unset beresp.http.Server;\n # unset beresp.http.X-Powered-By;\n # Retry count\n if ( bereq.retries > 0) {\n set beresp.http.X-Retries = bereq.retries;\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_backend_response {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Surrogate-control ~ \"no-store\" ||\n# (!beresp.http.Surrogate-Control &&\n# beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n# beresp.http.Vary == \"*\") {\n# \/*\n# * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# *\/\n# set beresp.ttl = 120s;\n# set beresp.uncacheable = true;\n# }\n# return (deliver);\n# }\n\n# vcl_backend_error: This subroutine is called if we fail the backend fetch.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-error\nsub vcl_backend_error {\n\n \/* Try to restart request in case of failure *\/\n #TODO# Confirm max_retries default value\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if (bereq.retries < 4) {\n return (retry);\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # Retry count\n if ( bereq.retries > 0) {\n set beresp.http.X-Retries = bereq.retries;\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + beresp.status + \" \" + beresp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + beresp.status + \" \" + beresp.reason + {\"<\/h1>\n <p>\"} + beresp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + bereq.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this point.\n return (deliver);\n}\n\n#######################################################################\n# Housekeeping\n\n# vcl_init: Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-init\n# Here is where you should declare your directors now.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-backends.html#directors\n# Empty in simple configs\n# sub vcl_init {\n# return (ok);\n# }\n\n# vcl_fini: Called when VCL is discarded only after all requests have exited the VCL. Typically used to clean up VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-fini\n# sub vcl_fini {\n# return (ok);\n# }\n\n","returncode":0,"stderr":"","license":"unknown","lang":"VCL"} {"commit":"7c9374bc4b4da0cf3e2da21bf982e31691d7fbb0","subject":"ESI workaround snippet no longer required","message":"ESI workaround snippet no longer required\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets\/recv.vcl","new_file":"etc\/vcl_snippets\/recv.vcl","new_contents":" # When using Magento tester to test whether your site is configured properly\n # this uses a bypass secret. By default we will use service ID as the bypass secret\n # however user can override this by defining a bypass_secret key in the\n # magentomodule_config edge dictionary\n if ( req.http.bypass-secret ) {\n declare local var.bypass-secret STRING;\n set var.bypass-secret = table.lookup(magentomodule_config, \"bypass_secret\", \"NONE\");\n if ( var.bypass-secret == req.http.bypass-secret ) {\n set req.http.x-pass = \"1\";\n set var.fastly_req_do_shield = false;\n set req.hash_always_miss = true;\n } else if ( var.bypass-secret == \"NONE\" && req.http.bypass-secret == req.service_id ) {\n set req.http.x-pass = \"1\";\n set var.fastly_req_do_shield = false;\n set req.hash_always_miss = true;\n } else {\n error 403 \"Bypass Secret incorrect\";\n }\n\n if (req.url == \"\/fastly-io-tester\") {\n # IO won't work for PASS requests\n unset req.http.x-pass;\n set req.hash_always_miss = true;\n set req.http.X-Fastly-Imageopto-Api = \"fastly\";\n }\n }\n\n # VCL required to support maintenance mode. Don't maintenance mode admin pages and supporting assets\n if (table.lookup(magentomodule_config, \"allow_super_users_during_maint\", \"0\") == \"1\" &&\n !req.http.Fastly-Client-Ip ~ maint_allowlist &&\n !req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" &&\n !req.url ~ \"^\/pub\/static\/\") {\n\n # If we end up here after a restart and there is a ResponseObject it means we got here after error\n # page VCL restart. We shouldn't touch it. Otherwise return a plain 503 error page\n if ( req.restarts > 0 && req.http.ResponseObject ) {\n set req.http.ResponseObject = \"970\";\n } else {\n error 503 \"Maintenance mode\";\n }\n }\n\n unset req.http.x-long-cache;\n\n # We want to force long cache times on any of the versioned assets\n if (req.url.path ~ \"^\/static\/version\\d*\/\") {\n set req.http.x-long-cache = \"1\";\n }\n\n # User's Cookie may contain some Magento Vary items we should vary on\n if (req.http.cookie:X-Magento-Vary) {\n set req.http.X-Magento-Vary = req.http.cookie:X-Magento-Vary;\n } else {\n unset req.http.X-Magento-Vary;\n }\n\n ############################################################################################################\n # Following code block controls purge by URL. By default we want to protect all URL purges. In general this\n # is addressed by adding Fastly-Purge-Requires-Auth request header in vcl_recv however this runs the risk of\n # exposing API tokens if user attempts to purge non-https URLs. For this reason inside the Magento module\n # we use X-Purge-Token. Unfortunately this breaks purge from the Fastly UI. Therefore in the next code block\n # we check for presence of X-Purge-Token. If it's not present we force the Fastly-Purge-Requires-Auth\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n if (req.http.X-Purge-Token && req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n } else {\n error 403;\n }\n } else {\n set req.http.Fastly-Purge-Requires-Auth = \"1\";\n }\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (fastly.ff.visits_this_service > 0) {\n # disable ESI processing on Origin Shield\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Make sure we lookup end user geo not shielding. More at https:\/\/docs.fastly.com\/vcl\/geolocation\/#using-geographic-variables-with-shielding\n set client.geo.ip_override = req.http.Fastly-Client-IP;\n\n if ((req.request == \"GET\" || req.request == \"HEAD\") && req.url.path ~ \"\/graphql\" && req.url.qs ~ \"query=\") {\n set req.http.graphql = \"1\";\n } else {\n unset req.http.graphql;\n }\n\n # geoip lookup\n if (req.url.path ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie:X-Magento-Vary || req.http.cookie:form_key) {\n error 980 \"GeoIP already processed\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url.qs !~ \"country_code=\" ) {\n set req.url = querystring.set(req.url, \"country_code\", if ( req.http.geo_override, req.http.geo_override, client.geo.country_code));\n }\n }\n } else if ( req.url.path !~ \"\/graphql\" ) {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking by default\n # and allow custom parameters to be set. List of parameters is configurable in admin\n set req.http.Magento-Original-URL = req.url;\n # Change the list of ignored parameters by configuring them in the Advanced section\n set req.url = querystring.regfilter(req.url, \"^(####QUERY_PARAMETERS####)$\");\n }\n\n # Don't allow clients to force a pass\n if (req.restarts == 0) {\n unset req.http.x-pass;\n unset req.http.Rate-Limit;\n unset req.http.magento-admin-path;\n }\n\n # Pass on checkout URLs. Because it's a snippet we want to execute this after backend selection so we handle it\n # in the request condition\n if (!req.http.x-long-cache && req.url ~ \"\/(checkout|customer\/section\/load)\") {\n set req.http.x-pass = \"1\";\n # Pass all admin actions\n # ####ADMIN_PATH#### is replaced with value of frontName from app\/etc\/env.php\n } else if ( req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" ) {\n set req.http.x-pass = \"1\";\n set req.http.magento-admin-path = \"1\";\n } else {\n # Sort the query arguments to increase cache hit ratio with query arguments that\n # may be out od order. In case you want to restore the unsorted URL add a snippet\n # after this one that sets req.url to req.http.Magento-Original-URL\n if ( !req.http.x-pass ) {\n set req.url = boltsort.sort(req.url);\n }\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.http.x-long-cache || req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n # GraphQL special headers handling because this area doesn't rely on X-Magento-Vary cookie\n if (req.http.graphql && !req.http.X-Magento-Cache-Id && req.http.Authorization ~ \"^Bearer\" ) {\n unset req.http.graphql;\n set req.http.x-pass = \"1\";\n }\n","old_contents":" # When using Magento tester to test whether your site is configured properly\n # this uses a bypass secret. By default we will use service ID as the bypass secret\n # however user can override this by defining a bypass_secret key in the\n # magentomodule_config edge dictionary\n if ( req.http.bypass-secret ) {\n declare local var.bypass-secret STRING;\n set var.bypass-secret = table.lookup(magentomodule_config, \"bypass_secret\", \"NONE\");\n if ( var.bypass-secret == req.http.bypass-secret ) {\n set req.http.x-pass = \"1\";\n set var.fastly_req_do_shield = false;\n set req.hash_always_miss = true;\n } else if ( var.bypass-secret == \"NONE\" && req.http.bypass-secret == req.service_id ) {\n set req.http.x-pass = \"1\";\n set var.fastly_req_do_shield = false;\n set req.hash_always_miss = true;\n } else {\n error 403 \"Bypass Secret incorrect\";\n }\n\n if (req.url == \"\/fastly-io-tester\") {\n # IO won't work for PASS requests\n unset req.http.x-pass;\n set req.hash_always_miss = true;\n set req.http.X-Fastly-Imageopto-Api = \"fastly\";\n }\n }\n\n # VCL required to support maintenance mode. Don't maintenance mode admin pages and supporting assets\n if (table.lookup(magentomodule_config, \"allow_super_users_during_maint\", \"0\") == \"1\" &&\n !req.http.Fastly-Client-Ip ~ maint_allowlist &&\n !req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" &&\n !req.url ~ \"^\/pub\/static\/\") {\n\n # If we end up here after a restart and there is a ResponseObject it means we got here after error\n # page VCL restart. We shouldn't touch it. Otherwise return a plain 503 error page\n if ( req.restarts > 0 && req.http.ResponseObject ) {\n set req.http.ResponseObject = \"970\";\n } else {\n error 503 \"Maintenance mode\";\n }\n }\n\n # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n unset req.http.x-long-cache;\n\n # We want to force long cache times on any of the versioned assets\n if (req.url.path ~ \"^\/static\/version\\d*\/\") {\n set req.http.x-long-cache = \"1\";\n }\n\n # User's Cookie may contain some Magento Vary items we should vary on\n if (req.http.cookie:X-Magento-Vary) {\n set req.http.X-Magento-Vary = req.http.cookie:X-Magento-Vary;\n } else {\n unset req.http.X-Magento-Vary;\n }\n\n ############################################################################################################\n # Following code block controls purge by URL. By default we want to protect all URL purges. In general this\n # is addressed by adding Fastly-Purge-Requires-Auth request header in vcl_recv however this runs the risk of\n # exposing API tokens if user attempts to purge non-https URLs. For this reason inside the Magento module\n # we use X-Purge-Token. Unfortunately this breaks purge from the Fastly UI. Therefore in the next code block\n # we check for presence of X-Purge-Token. If it's not present we force the Fastly-Purge-Requires-Auth\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n if (req.http.X-Purge-Token && req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n } else {\n error 403;\n }\n } else {\n set req.http.Fastly-Purge-Requires-Auth = \"1\";\n }\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (fastly.ff.visits_this_service > 0) {\n # disable ESI processing on Origin Shield\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Make sure we lookup end user geo not shielding. More at https:\/\/docs.fastly.com\/vcl\/geolocation\/#using-geographic-variables-with-shielding\n set client.geo.ip_override = req.http.Fastly-Client-IP;\n\n if ((req.request == \"GET\" || req.request == \"HEAD\") && req.url.path ~ \"\/graphql\" && req.url.qs ~ \"query=\") {\n set req.http.graphql = \"1\";\n } else {\n unset req.http.graphql;\n }\n\n # geoip lookup\n if (req.url.path ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie:X-Magento-Vary || req.http.cookie:form_key) {\n error 980 \"GeoIP already processed\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url.qs !~ \"country_code=\" ) {\n set req.url = querystring.set(req.url, \"country_code\", if ( req.http.geo_override, req.http.geo_override, client.geo.country_code));\n }\n }\n } else if ( req.url.path !~ \"\/graphql\" ) {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking by default\n # and allow custom parameters to be set. List of parameters is configurable in admin\n set req.http.Magento-Original-URL = req.url;\n # Change the list of ignored parameters by configuring them in the Advanced section\n set req.url = querystring.regfilter(req.url, \"^(####QUERY_PARAMETERS####)$\");\n }\n\n # Don't allow clients to force a pass\n if (req.restarts == 0) {\n unset req.http.x-pass;\n unset req.http.Rate-Limit;\n unset req.http.magento-admin-path;\n }\n\n # Pass on checkout URLs. Because it's a snippet we want to execute this after backend selection so we handle it\n # in the request condition\n if (!req.http.x-long-cache && req.url ~ \"\/(checkout|customer\/section\/load)\") {\n set req.http.x-pass = \"1\";\n # Pass all admin actions\n # ####ADMIN_PATH#### is replaced with value of frontName from app\/etc\/env.php\n } else if ( req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" ) {\n set req.http.x-pass = \"1\";\n set req.http.magento-admin-path = \"1\";\n } else {\n # Sort the query arguments to increase cache hit ratio with query arguments that\n # may be out od order. In case you want to restore the unsorted URL add a snippet\n # after this one that sets req.url to req.http.Magento-Original-URL\n if ( !req.http.x-pass ) {\n set req.url = boltsort.sort(req.url);\n }\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.http.x-long-cache || req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n # GraphQL special headers handling because this area doesn't rely on X-Magento-Vary cookie\n if (req.http.graphql && !req.http.X-Magento-Cache-Id && req.http.Authorization ~ \"^Bearer\" ) {\n unset req.http.graphql;\n set req.http.x-pass = \"1\";\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"66344fbb74349d90d15eaee14182827aeef212c6","subject":"Updated.","message":"Updated.\n","repos":"normabuttz\/libvmod-rtstatus,normabuttz\/libvmod-rtstatus,normabuttz\/libvmod-rtstatus","old_file":"example.vcl","new_file":"example.vcl","new_contents":"vcl 4.0;\nimport std;\nimport directors;\nimport rtstatus;\n\nbackend default {\n\t.host = \"127.0.0.1\";\n\t.port = \"8080\";\n}\nbackend server1 {\n\t.host = \"192.168.0.10\";\n\t.port =\"8081\";\n}\nbackend server2 {\n\t.host = \"192.168.0.10\";\n\t.port = \"8082\";\n}\n\nsub vcl_init {\n\tnew bar = directors.round_robin();\n\tbar.add_backend(server1);\n\tbar.add_backend(server2);\n\tbar.add_backend(default);\n}\n\nsub vcl_recv {\n\tif (req.url ~ \"\/rtstatus.json\") {\n\t\treturn(synth(700, \"OK\"));\n\t}\n\tif (req.url ~ \"\/rtstatus\") {\n\t\treturn(synth(800, \"OK\"));\n\t}\n}\n\nsub vcl_synth {\n\tif (resp.status == 700) {\n\t\tset resp.status = 200;\n\t\tset resp.http.Content-Type = \"text\/html; charset=utf-8\";\n\t\tsynthetic(rtstatus.rtstatus());\n\t\treturn (deliver);\n\t}\n\tif (resp.status == 800) {\n\t\tset resp.status = 200;\n\t\tset resp.http.Content-Type = \"text\/html; charset=utf-8\";\n\t\tsynthetic(rtstatus.html());\n\t\treturn (deliver);\n\t}\n}\n\n\n\n\n","old_contents":"vcl 4.0;\nimport std;\nimport directors;\nimport rtstatus;\n\nbackend default {\n\t.host = \"127.0.0.1\";\n\t.port = \"8080\";\n}\nbackend server1 {\n\t.host = \"192.168.0.10\";\n\t.port =\"8081\";\n}\nbackend server2 {\n\t.host = \"192.168.0.10\";\n\t.port = \"8082\";\n}\n\nsub vcl_init {\n\tnew bar = directors.round_robin();\n\tbar.add_backend(server1);\n\tbar.add_backend(server2);\n\tbar.add_backend(default);\n}\n\nsub vcl_recv {\n\tif (req.url ~ \"\/rtstatus.json\") {\n\t\treturn(synth(700, \"OK\"));\n\t}\n\tif (req.url ~ \"\/rtstatus\") {\n\t\treturn(synth(800, \"OK\"));\n\t}\n}\n\nsub vcl_synth {\n\tif (resp.status == 700) {\n\t\tset resp.status = 200;\n\t\tsynthetic(rtstatus.rtstatus());\n\t\treturn (deliver);\n\t}\n\tif (resp.status == 800) {\n\t\tset resp.status = 200;\n\t\tset resp.http.Content-Type = \"text\/html; charset=utf-8\";\n\t\tsynthetic(rtstatus.html());\n\t\treturn (deliver);\n\t}\n}\n\n\n\n\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"046f00356a5a7edaff239338a5797aeeb10a3cc5","subject":"changed vcl to match Fastly boilerplate more closely","message":"changed vcl to match Fastly boilerplate more closely\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/fastly.vcl","new_file":"etc\/fastly.vcl","new_contents":"###############################################################################\n#\n# Fastly CDN for Magento 2\n#\n# NOTICE OF LICENSE\n#\n# This source file is subject to the Fastly CDN for Magento 2 End User License\n# Agreement that is bundled with this package in the file LICENSE_FASTLY_CDN.txt.\n#\n# @copyright Copyright (c) 2016 Fastly, Inc. (http:\/\/www.fastly.com)\n# @license BSD, see LICENSE_FASTLY_CDN.txt\n#\n###############################################################################\n\n# This is a basic VCL configuration file for Fastly CDN for Magento 2 module.\n\nsub vcl_recv {\n#FASTLY recv\n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n set req.http.X-Sig = regsub(req.http.X-Purge-Token, \"^[^_]+_(.*)\", \"\\1\");\n set req.http.X-Exp = regsub(req.http.X-Purge-Token, \"^([^_]+)_.*\", \"\\1\");\n\n # validate signature\n if (req.http.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path req.http.X-Exp), \"^0x\", \"\")) {\n\n # use vcl time math to check expiration timestamp\n set req.http.X-Original-Grace = req.grace;\n set req.grace = std.atoi(strftime({\"%s\"}, now));\n set req.grace -= std.atoi(req.http.X-Exp);\n\n if (std.atoi(req.grace) > 0) {\n error 410;\n }\n\n # clean up grace since we used it for time math\n set req.grace = std.atoi(req.http.X-Original-Grace);\n unset req.http.X-Original-Grace;\n\n } else {\n error 403;\n }\n\n # cleanup variables\n unset req.http.X-Purge-Token;\n unset req.http.X-Sig;\n unset req.http.X-Exp;\n }\n\n # Deactivate gzip\n set req.http.X-Orig-Accept-Encoding = req.http.Accept-Encoding;\n unset req.http.Accept-Encoding;\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n # disable ESI processing on Origin Shield\n if (req.http.Fastly-FF) {\n set req.esi = false;\n }\n\n # We only deal with GET and HEAD by default\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n return (pass);\n }\n\n # Bypass shopping cart and checkout requests\n if (req.url ~ \"\/checkout\") {\n return (pass);\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie ~ \"(X-Magento-Vary|form_key)=\") {\n error 200 \"\";\n } else {\n # append parameter with country code\n set req.url = req.url \"?country_code=\" geoip.country_code;\n }\n }\n\n return(lookup);\n}\n\nsub vcl_fetch {\n#FASTLY fetch\n\n if (beresp.status >= 500) {\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n }\n\n if (req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Content-Type ~ \"text\/html\" || beresp.http.Content-Type ~ \"text\/xml\") {\n # enable ESI feature for Magento response by default\n esi;\n } else {\n # enable gzip for all static content\n if ((beresp.status == 200 || beresp.status == 404) && (beresp.http.content-type ~ \"^(text\\\/html|application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain|text\\\/xml)\\s*($|;)\" || req.url ~ \"\\.(css|js|html|eot|ico|otf|ttf|json)($|\\?)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.X-Orig-Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # cache only successfully responses and 404s\n if (beresp.status != 200 && beresp.status != 301 && beresp.status != 404) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\")) {\n unset beresp.http.set-cookie;\n if (req.url !~ \"^\/(pub\/)?(media|static)\/.*\") {\n set beresp.http.Pragma = \"no-cache\";\n set beresp.http.Expires = \"-1\";\n set beresp.http.Cache-Control = \"no-store, no-cache, must-revalidate, max-age=0\";\n set beresp.grace = 1m;\n }\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type\n if (beresp.http.Content-Type ~ \"image\") {\n set beresp.http.Surrogate-Key = \"image\";\n } elsif (beresp.http.Content-Type ~ \"script\") {\n set beresp.http.Surrogate-Key = \"script\";\n } elsif (beresp.http.Content-Type ~ \"css\") {\n set beresp.http.Surrogate-Key = \"css\";\n }\n\n set beresp.http.X-Surrogate-Key = beresp.http.Surrogate-Key;\n return (deliver);\n }\n\n return (deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\n\nsub vcl_miss {\n#FASTLY miss\n\n return(fetch);\n}\n\nsub vcl_deliver {\n # debug info\n if (resp.http.X-Magento-Debug) {\n if (obj.hits > 0) {\n set resp.http.X-Magento-Cache-Debug = \"HIT\";\n set resp.http.X-Magento-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Magento-Cache-Debug = \"MISS\";\n }\n } else {\n # remove Varnish\/proxy header\n remove resp.http.Age;\n remove resp.http.X-Magento-Debug;\n remove resp.http.X-Magento-Tags;\n remove resp.http.X-Surrogate-Key;\n remove resp.http.X-Magento-Cache-Control;\n remove resp.http.X-Powered-By;\n remove resp.http.Server;\n remove resp.http.X-Varnish;\n remove resp.http.Via;\n remove resp.http.Link;\n remove resp.http.X-Purge-URL;\n remove resp.http.X-Purge-Host;\n }\n\n#FASTLY deliver\n\n return (deliver);\n}\n\n\nsub vcl_error {\n # workaround for possible security issue\n if (req.url ~ \"^\\s\") {\n set obj.status = 400;\n set obj.response = \"Malformed request\";\n synthetic \"\";\n return (deliver);\n }\n\n # error 200\n if (obj.status == 200) {\n return (deliver);\n }\n\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} obj.status \" \" obj.response {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} obj.status \" \" obj.response {\"<\/h1>\n <p>\"} obj.response {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} req.xid {\"<\/p>\n <hr>\n <p>Fastly CDN server<\/p>\n <\/body>\n<\/html>\n\"};\n\n#FASTLY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n\nsub vcl_hash {\n set req.hash += req.http.Https;\n set req.hash += req.http.host;\n set req.hash += req.url;\n\n if (req.http.cookie ~ \"X-Magento-Vary=\") {\n set req.http.X-Magento-Vary = regsub(req.http.cookie, \"^.*?X-Magento-Vary=([^;]+);*.*$\", \"\\1\");\n set req.hash += req.http.X-Magento-Vary;\n unset req.http.X-Magento-Vary;\n }\n \n set req.hash += \"#####GENERATION#####\";\n\n ### {{ design_exceptions_code }} ###\n\n return (hash);\n}\n\n","old_contents":"###############################################################################\n#\n# Fastly CDN for Magento 2\n#\n# NOTICE OF LICENSE\n#\n# This source file is subject to the Fastly CDN for Magento 2 End User License\n# Agreement that is bundled with this package in the file LICENSE_FASTLY_CDN.txt.\n#\n# @copyright Copyright (c) 2016 Fastly, Inc. (http:\/\/www.fastly.com)\n# @license BSD, see LICENSE_FASTLY_CDN.txt\n#\n###############################################################################\n\n# This is a basic VCL configuration file for Fastly CDN for Magento 2 module.\n\nsub vcl_recv {\n#FASTLY recv\n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n set req.http.X-Sig = regsub(req.http.X-Purge-Token, \"^[^_]+_(.*)\", \"\\1\");\n set req.http.X-Exp = regsub(req.http.X-Purge-Token, \"^([^_]+)_.*\", \"\\1\");\n\n # validate signature\n if (req.http.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path req.http.X-Exp), \"^0x\", \"\")) {\n\n # use vcl time math to check expiration timestamp\n set req.http.X-Original-Grace = req.grace;\n set req.grace = std.atoi(strftime({\"%s\"}, now));\n set req.grace -= std.atoi(req.http.X-Exp);\n\n if (std.atoi(req.grace) > 0) {\n error 410;\n }\n\n # clean up grace since we used it for time math\n set req.grace = std.atoi(req.http.X-Original-Grace);\n unset req.http.X-Original-Grace;\n\n } else {\n error 403;\n }\n\n # cleanup variables\n unset req.http.X-Purge-Token;\n unset req.http.X-Sig;\n unset req.http.X-Exp;\n }\n\n # Deactivate gzip\n set req.http.X-Orig-Accept-Encoding = req.http.Accept-Encoding;\n unset req.http.Accept-Encoding;\n\n # We only deal with GET and HEAD by default\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n return (pass);\n }\n\n # Bypass shopping cart and checkout requests\n if (req.url ~ \"\/checkout\") {\n return (pass);\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n # disable ESI processing on Origin Shield\n if (req.http.Fastly-FF) {\n set req.esi = false;\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie ~ \"(X-Magento-Vary|form_key)=\") {\n error 200 \"\";\n } else {\n # append parameter with country code\n set req.url = req.url \"?country_code=\" geoip.country_code;\n }\n }\n\n return(lookup);\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n\nsub vcl_hash {\n set req.hash += req.http.Https;\n set req.hash += req.http.host;\n set req.hash += req.url;\n\n if (req.http.cookie ~ \"X-Magento-Vary=\") {\n set req.http.X-Magento-Vary = regsub(req.http.cookie, \"^.*?X-Magento-Vary=([^;]+);*.*$\", \"\\1\");\n set req.hash += req.http.X-Magento-Vary;\n unset req.http.X-Magento-Vary;\n }\n \n set req.hash += \"#####GENERATION#####\";\n\n ### {{ design_exceptions_code }} ###\n\n return (hash);\n}\n\nsub vcl_hit {\n#FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\nsub vcl_miss {\n#FASTLY miss\n\n return(fetch);\n}\n\nsub vcl_fetch {\n#FASTLY fetch\n\n if (beresp.status >= 500) {\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n }\n\n if (req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Content-Type ~ \"text\/html\" || beresp.http.Content-Type ~ \"text\/xml\") {\n # enable ESI feature for Magento response by default\n esi;\n } else {\n # enable gzip for all static content\n if ((beresp.status == 200 || beresp.status == 404) && (beresp.http.content-type ~ \"^(text\\\/html|application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain|text\\\/xml)\\s*($|;)\" || req.url ~ \"\\.(css|js|html|eot|ico|otf|ttf|json)($|\\?)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.X-Orig-Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # cache only successfully responses and 404s\n if (beresp.status != 200 && beresp.status != 301 && beresp.status != 404) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\")) {\n unset beresp.http.set-cookie;\n if (req.url !~ \"^\/(pub\/)?(media|static)\/.*\") {\n set beresp.http.Pragma = \"no-cache\";\n set beresp.http.Expires = \"-1\";\n set beresp.http.Cache-Control = \"no-store, no-cache, must-revalidate, max-age=0\";\n set beresp.grace = 1m;\n }\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type\n if (beresp.http.Content-Type ~ \"image\") {\n set beresp.http.Surrogate-Key = \"image\";\n } elsif (beresp.http.Content-Type ~ \"script\") {\n set beresp.http.Surrogate-Key = \"script\";\n } elsif (beresp.http.Content-Type ~ \"css\") {\n set beresp.http.Surrogate-Key = \"css\";\n }\n\n set beresp.http.X-Surrogate-Key = beresp.http.Surrogate-Key;\n return (deliver);\n }\n\n return (deliver);\n}\n\nsub vcl_deliver {\n # debug info\n if (resp.http.X-Magento-Debug) {\n if (obj.hits > 0) {\n set resp.http.X-Magento-Cache-Debug = \"HIT\";\n set resp.http.X-Magento-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Magento-Cache-Debug = \"MISS\";\n }\n } else {\n # remove Varnish\/proxy header\n remove resp.http.Age;\n remove resp.http.X-Magento-Debug;\n remove resp.http.X-Magento-Tags;\n remove resp.http.X-Surrogate-Key;\n remove resp.http.X-Magento-Cache-Control;\n remove resp.http.X-Powered-By;\n remove resp.http.Server;\n remove resp.http.X-Varnish;\n remove resp.http.Via;\n remove resp.http.Link;\n remove resp.http.X-Purge-URL;\n remove resp.http.X-Purge-Host;\n }\n\n#FASTLY deliver\n\n return (deliver);\n}\n\nsub vcl_error {\n # workaround for possible security issue\n if (req.url ~ \"^\\s\") {\n set obj.status = 400;\n set obj.response = \"Malformed request\";\n synthetic \"\";\n return (deliver);\n }\n\n # error 200\n if (obj.status == 200) {\n return (deliver);\n }\n\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} obj.status \" \" obj.response {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} obj.status \" \" obj.response {\"<\/h1>\n <p>\"} obj.response {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} req.xid {\"<\/p>\n <hr>\n <p>Fastly CDN server<\/p>\n <\/body>\n<\/html>\n\"};\n\n#FASTLY error\n}","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"600b03f256c55b4bd7e4067fc26f66000d873699","subject":"remove hit_for_pass from examples, it's now deprecated","message":"remove hit_for_pass from examples, it's now deprecated\n","repos":"NITEMAN\/varnish-bites,NITEMAN\/Varnish_VCL_samps-hacks","old_file":"varnish4\/drupal-base.vcl","new_file":"varnish4\/drupal-base.vcl","new_contents":"\/*\n * Varnish 4 example config for Drupal 7 \/ Pressflow 6 & 7\n *\/\n\n# Original source: https:\/\/github.com\/NITEMAN\/varnish-bites\/varnish4\/drupal-base.vcl\n# Copyright (c) 2015 Pedro Gonz\u00e1lez Serrano and individual contributors.\n# MIT License\n\n# Intended to be used both in simple production environments and with\n# learning\/teaching purposes.\n# Some references may not be yet updated to VCL 4.0, we use SeeV3 then.\n\n# WARNING:\n# Note that the built-in logic will be appended to our code if no return is\n# performed before.\n# Built-in logic is included commented out right after our's for reference\n# purposes in that cases.\n# See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleDefault\n\n#######################################################################\n# Initialization: Version & imports;\n\n\/* Version statement *\/\n# Since Varnish 4.0 it's mandatory to declare VCL version on first line.\nvcl 4.0;\n\n\/* Module (VMOD) imports *\/\n# Standard module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_std.generated.html\nimport std;\n\n# Directors module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# Unused in simple configs.\n#import directors;\n\n\n#######################################################################\n# Probe, backend, ACL and subroutine definitions\n\n\/* Backend probes \/ healthchecks *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#probes\nprobe basic {\n \/* Only test that backend's IP serves content for '\/' *\/\n # This might be a too heavy probe\n # .url = \"\/\";\n\n \/* Only test that backend's IP has apache working *\/\n # Nginx would fail this probe with a default config\n .request =\n \"OPTIONS * HTTP\/1.1\"\n \"Host: *\"\n \"Connection: close\";\n\n \/* Common options *\/\n .interval = 10s;\n .timeout = 2s;\n .window = 8;\n .threshold = 6;\n}\n\n\/* Backend definitions.*\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#backend-definition\nbackend default {\n \/* Default backend on the same machine. *\/\n # WARNING: timeouts could be not big enought for certain POST requests.\n .host = \"127.0.0.1\";\n .port = \"8008\";\n .max_connections = 100;\n .connect_timeout = 60s;\n .first_byte_timeout = 60s;\n .between_bytes_timeout = 60s;\n .probe = basic;\n}\n\n\/* Access Control Lists *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#access-control-list-acl\nacl purge_ban {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use '\"localhost\";' instead\n}\nacl allowed_monitors {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n}\n# acl own_proxys {\n# \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n# }\n\n\/* Custom subroutines *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#subroutines\n#TODO# Test in Varnihs 4\n# Empty in simple configs.\n# The only restriction naming subs is that the 'vlc_' prefix is reserverd for\n# Varnish use. As a task can need several chunks of code in diferent states,\n# it's a good idea to identify what main sub will call each with a suffix.\n# \/* Example 301 client redirection removing \"www\" prefix from request *\/\n# sub perm_redirections_recv {\n# if ( req.http.host ~ \"^www.*$\" ) {\n# return(\n# synth(751, \"http:\/\/\" + regsub(req.http.host, \"^www\\.\", \"\") + req.url)\n# );\n# }\n# }\n# sub perm_redirections_synth {\n# if (resp.status == 751) {\n# \/* Get new URL from the response *\/\n# set resp.http.Location = resp.response;\n# \/* Set HTTP 301 for permanent redirect *\/\n# set resp.status = 301;\n# return (deliver);\n# }\n# }\n\n\n#######################################################################\n# Client side\n\n# vcl_recv: Called at the beginning of a request, after the complete request\n# has been received and parsed. Its purpose is to decide whether or not to\n# serve the request, how to do it, and, if applicable, which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-recv\nsub vcl_recv {\n \/* 0th: general bypass, general return & authorization checks *\/\n # Empty in simple configs.\n # Useful for debugging we can pipe or pass the request to default backend\n # here to bypass completely Varnish.\n # return (pipe);\n # return (pass);\n # We can also return here a 200 Ok for network performance benchmarking.\n # return(synth(200, \"Ok\"));\n # Finally we can perform basic HTTP authentification here, by example.\n # SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* 1st: Check for Varnish special requests *\/ \n # Custom response implementation example in order to check that Varnish is\n # working properly.\n # This is usefull for automatic monitoring with monit or when Varnish is\n # behind another proxies like HAProxy.\n if ( ( req.http.host == \"monitor.server.health\"\n || req.http.host == \"health.varnish\" )\n && client.ip ~ allowed_monitors\n && ( req.method == \"OPTIONS\" || req.method == \"GET\" )\n ) {\n return(synth(200, \"Ban added\"));\n }\n # Purge logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#http-purging\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if ( req.method == \"PURGE\" ) {\n if ( ! client.ip ~ purge_ban ) {\n return(synth(405, \"Not allowed.\"));\n }\n return (purge);\n }\n # Ban logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#bans\n if ( req.method == \"BAN\" ) {\n if ( ! client.ip ~ purge_ban ) {\n return(synth(405, \"Not allowed.\"));\n }\n ban( \"req.http.host == \" + req.http.host +\n \"&& req.url == \" + req.url);\n return(synth(200, \"Ban added\"));\n }\n\n \/* 2nd: Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_recv;\n # Here we can also enforce SSL when Varnish run behind some SSL termination\n # point.\n\n \/* 3rd: Time for backend choice *\/\n # Empty in simple configs.\n\n \/* 4th: Prepare request for the backend *\/\n # Empty in simple configs.\n # Example remove own_proxys from X-Forwarded-For\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/whats-new\/upgrading.html#x-forwarded-for-is-now-set-before-vcl-recv\n # if ( req.restarts == 0\n # && client.ip ~ own_proxys\n # && req.http.x-forwarded-for\n # ) {\n # set req.http.X-Forwarded-For\n # = regsub(req.http.X-Forwarded-For, \",( )?\" + client.ip, \"\");\n # }\n # Example normalize the host header, remove the port (in case you're testing\n # this on various TCP ports)\n # set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n \/* 5th: Bypass breakpoint 1 *\/\n # Useful for debugging we can now pipe or pass the request to backend with\n # headers setted.\n # return (pipe);\n # return (pass);\n\n \/* 6th: Decide if we should deal with a request (mostly from built-in logic) *\/\n if (req.method == \"PRI\") {\n \/* We do not support SPDY or HTTP\/2.0 *\/\n return (synth(405));\n }\n if ( req.method != \"GET\"\n && req.method != \"HEAD\"\n && req.method != \"PUT\"\n && req.method != \"POST\"\n && req.method != \"TRACE\"\n && req.method != \"OPTIONS\"\n && req.method != \"DELETE\"\n ) {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n\n \/* 7th: Access control for some URLs by ACL *\/\n # Empty in simple configs.\n # By example denial some URLs depending on client-ip, we'll need to define\n # corresponding ACL 'internal'.\n # if ( req.url ~ \"^\/(cron|install)\\.php\"\n # && ! client.ip ~ internal\n # ) {\n # # Have Varnish throw the error directly.\n # return(synth(403, \"Forbidden.\"));\n # # Use a custom error page that you've defined in Drupal at the path \"404\".\n # # set req.url = \"\/403\";\n # }\n\n \/* 8th: Custom exceptions *\/\n # Host exception example:\n # if (req.http.host == \"ejemplo.exception.com\") {\n # return (pass);\n # }\n # Drupal exceptions, edit if we want to cache some AJAX\/AHAH request.\n # Add here filters for never cache URLs such as Payment Gateway's callbacks.\n if ( req.url ~ \"^\/status\\.php$\"\n || req.url ~ \"^\/update\\.php$\"\n || req.url ~ \"^\/ooyala\/ping$\"\n || req.url ~ \"^\/admin\/build\/features\"\n || req.url ~ \"^\/info\/.*$\"\n || req.url ~ \"^\/flag\/.*$\"\n || req.url ~ \"^.*\/ajax\/.*$\"\n || req.url ~ \"^.*\/ahah\/.*$\"\n ) {\n \/* Do not cache these paths *\/\n return (pass);\n }\n # Pipe these paths directly to backend for streaming.\n if (req.url ~ \"^\/admin\/content\/backup_migrate\/export\") {\n return (pipe);\n }\n if (req.url ~ \"^\/system\/files\") {\n return (pipe);\n }\n\n \/* 9th: Graced objets & Serve from anonymous cahe if all backends are down *\/\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n # set req.http.grace = \"none\";\n if ( ! std.healthy(req.backend_hint) ) {\n # We must do this here since cookie hashing\n unset req.http.Cookie;\n #TODO# Add sick marker\n } \n\n \/* 10th: Deal with compression and the Accept-Encoding header *\/\n # Althought Varnish 3 handles gziped content itself by default, just to be\n # sure we want to remove Accept-Encoding for some compressed formats.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html#what-does-http-gzip-support-do\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/varnishd.html?highlight=http_gzip_support\n # See (for older configs) https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleNormalizeAcceptEncoding\n if (req.http.Accept-Encoding) {\n if ( req.url\n ~ \"\\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|mp4|flv|zip|rar)$\"\n ) {\n \/* Already compressed formats, no sense trying to compress again *\/\n unset req.http.Accept-Encoding;\n }\n }\n\n \/* 11th: Another request manipulation *\/\n # Empty in simple configs.\n # We could add here a custom header grouping User-agent families.\n\n \/* 12th: Cookie removal *\/\n # Always cache the following static file types for all users. \n # Use with care if we control certain downloads depending on cookies. \n # Be carefull also if appending .htm[l] via Drupal's clean URLs.\n if ( req.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|woff2|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n && ! req.url ~ \"\/system\/storage\/serve\"\n ) {\n unset req.http.Cookie;\n }\n # Remove all cookies that backend doesn't need to know about.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRemovingSomeCookies\n if (req.http.Cookie) {\n \/* Warning: Not a pretty solution *\/\n # Prefix header containing cookies with ';'\n set req.http.Cookie = \";\" + req.http.Cookie;\n # Remove any spaces after ';' in header containing cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n # Prefix cookies we want to preserve with one space:\n # 'S{1,2}ESS[a-z0-9]+' is the regular expression matching a Drupal session\n # cookie ({1,2} added for HTTPS support).\n # 'NO_CACHE' is usually set after a POST request to make sure issuing user\n # see the results of his post.\n # 'OATMEAL' & 'CHOCOLATECHIP' are special cookies used by Drupal's Bakery\n # module to provide Single Sign On.\n # Keep in mind we should add here any cookie that should reach the backend\n # such as splash avoiding cookies.\n set req.http.Cookie\n = regsuball(\n req.http.Cookie,\n \";(S{1,2}ESS[a-z0-9]+|NO_CACHE|OATMEAL|CHOCOLATECHIP)=\",\n \"; \\1=\"\n );\n # Remove from the header any single Cookie not prefixed with a space until\n # next ';' separator.\n set req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n # Remove any '; ' at the start or the end of the header.\n set req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n #If there are no remaining cookies, remove the cookie header.\n if (req.http.Cookie == \"\") {\n unset req.http.Cookie;\n }\n }\n\n \/* 13th: Session cookie & special cookies bypass caching stage *\/\n # As we might want to cache some requests, hashed with its cookies, we don't\n # simply pass when some cookies remain present at this point.\n # Instead we look for request that must be passed due to the cookie header.\n if ( req.http.Cookie ~ \"SESS\"\n || req.http.Cookie ~ \"SSESS\"\n || req.http.Cookie ~ \"NO_CACHE\"\n || req.http.Cookie ~ \"OATMEAL\"\n || req.http.Cookie ~ \"CHOCOLATECHIP\"\n ) {\n return (pass);\n }\n\n \/* 14th: Bypass breakpoint 2 *\/\n # Useful for debugging we can now pipe or pass the request to backend to\n # bypass cache.\n # return (pipe);\n # return (pass);\n\n \/* 15th: Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n return (hash);\n}\n\n# vcl_pipe: Called upon entering pipe mode.\n# In this mode, the request is passed on to the backend, and any further data\n# from either client or backend is passed on unaltered until either end closes\n# the connection.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pipe\n# sub vcl_pipe {\n# # By default Connection: close is set on all piped requests, to stop\n# # connection reuse from sending future requests directly to the\n# # (potentially) wrong backend. If you do want this to happen, you can undo\n# # it here.\n# # unset bereq.http.connection;\n# return (pipe);\n# }\n\n# vcl_pass: Called upon entering pass mode. \n# In this mode, the request is passed on to the backend, and the backend's\n# response is passed on to the client, but is not entered into the cache.\n# Subsequent requests submitted over the same client connection are handled normally.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pass\n# sub vcl_pass {\n# return (fetch);\n# }\n\n# vcl_hash: You may call hash_data() on the data you would like to add to the\n# hash.\n# Hash is used by Varnish to uniquely identify objects.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hash\nsub vcl_hash {\n \/* Hash cookie data *\/\n # As requests with same URL and host can produce diferent results when issued\n # with different cookies, we need to store items hashed with the associated\n # cookies. Note that cookies are already sanitized when we reach this point.\n if (req.http.Cookie) {\n \/* Include cookie in cache hash *\/\n hash_data(req.http.Cookie);\n }\n\n \/* Custom header hashing *\/\n # Empty in simple configs.\n # Example for caching differents object versions by device previously\n # detected (when static content could also vary):\n # if (req.http.X-UA-Device) {\n # hash_data(req.http.X-UA-Device);\n # }\n # Example for caching diferent object versions by X-Forwarded-Proto, trying\n # to be smart about what kind of request could generate diffetent responses.\n if ( req.http.X-Forwarded-Proto\n && req.url !~ \"(?i)\\.(png|gif|jpeg|jpg|ico|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|woff2|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\") {\n hash_data(req.http.X-Forwarded-Proto);\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (lookup);\n# }\n\n# vcl_purge: Called after the purge has been executed and all its variants have\n# been evited.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-purge\n# sub vcl_purge {\n# return (synth(200, \"Purged\"));\n# }\n\n# vcl_hit: Called after a cache lookup if the requested document was found in\n# the cache.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hit\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n \/\/ A pure unadultered hit, deliver it\n return (deliver);\n }\n \/* Allow varnish to serve up stale content if it is responding slowly *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n if (obj.ttl + 60s > 0s) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n set req.http.grace = \"normal\";\n return (deliver);\n }\n \/* Allow varish to serve up stale content if all backends are down *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n if ( ! std.healthy(req.backend_hint)\n && obj.ttl + obj.grace > 0s\n ) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n set req.http.grace = \"extended\";\n return (deliver);\n }\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\n# vcl_miss: Called after a cache lookup if the requested document was not found\n# in the cache.\n# Its purpose is to decide whether or not to attempt to retrieve the document\n# from the backend, and which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-miss\n# sub vcl_miss {\n# return (fetch);\n# }\n\n# vcl_deliver: Called before an object is delivered to the client\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-deliver\nsub vcl_deliver {\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # Add whether the object is a cache hit or miss and the number of hits for\n # the object.\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Addingaheaderindicatinghitmiss\n # In Varnish 4 the obj.hits counter behaviour has changed (see bug 1492), so\n # we use a different method: if X-Varnish contains only 1 id, we have a miss,\n # if it contains more (and therefore a space), we have a hit.\n if (resp.http.x-varnish ~ \" \") {\n set resp.http.X-Cache = \"HIT\";\n # Since in Varnish 4 the behaviour of obj.hits changed, this might not be\n # accurate.\n # See https:\/\/www.varnish-cache.org\/trac\/ticket\/1492\n set resp.http.X-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Cache = \"MISS\";\n \/* Show the results of cookie sanitization *\/\n set resp.http.X-Cookie = req.http.Cookie;\n }\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n set resp.http.grace = req.http.grace;\n\n #TODO# Add sick marker\n\n # Restart count\n if ( req.restarts > 0) {\n set resp.http.X-Restarts = req.restarts;\n }\n\n # Add the Varnish server hostname\n set resp.http.X-Varnish-Server = server.hostname;\n # If we have setted a custom header with device's family detected we can show\n # it:\n # if (req.http.X-UA-Device) {\n # set resp.http.X-UA-Device = req.http.X-UA-Device;\n # }\n # If we have recived a custom header indicating the protocol in the request we\n # can show it:\n # if (req.http.X-Forwarded-Proto) {\n # set resp.http.X-Forwarded-Proto = req.http.X-Forwarded-Proto;\n # }\n\n \/* Vary header manipulation *\/\n # Empty in simple configs.\n # By example, if we are storing & serving diferent objects depending on\n # User-Agent header we must set the correct Vary header:\n # if (resp.http.Vary) {\n # set resp.http.Vary = resp.http.Vary + \",User-Agent\";\n # } else {\n # set resp.http.Vary = \"User-Agent\";\n # }\n\n \/* Fake headers *\/\n # Empty in simple configs\n # We can fake server headers here, by example:\n # set resp.http.Server = \"Deep thought\";\n # set resp.http.X-Powered-By = \"BOFH\";\n # Or have some fun with headers:\n # See http:\/\/www.nextthing.org\/archives\/2005\/08\/07\/fun-with-http-headers\n # See http:\/\/royal.pingdom.com\/2012\/08\/15\/fun-and-unusual-http-response-headers\/\n # set resp.http.X-Thank-You = \"for bothering to look at my HTTP headers\";\n # set resp.http.X-Answer = \"42\";\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_deliver {\n# return (deliver);\n# }\n\n# vcl_synth: Called to deliver a synthetic object. A synthetic object is\n# generated in VCL, not fetched from the backend. It is typically contructed\n# using the synthetic() function.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-synth\n\/*\n * We can come here \"invisibly\" with the following errors: 413, 417 & 503\n *\/\nsub vcl_synth {\n \/* Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_synth;\n\n \/* Try to restart request in case of failure *\/\n # Note that max_restarts defaults to 4\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if (resp.status == 503 && req.restarts < 4) {\n return(restart);\n }\n\n \/* Set common headers for synthetic responses *\/\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n\n \/* HTTP Authentification client request *\/\n # Empty in simple configs.\n # SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* Load synthetic responses from disk *\/\n # Note that files loaded this way are never re-readed (even after a reload).\n # You should consider PROS\/CONS of doing an include instead.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_std.generated.html#func-fileread\n # Example custom 403 error page.\n # if (resp.status == 403) {\n # synthetic(std.fileread(\"\/403.html\"));\n # return(deliver);\n # }\n\n \/* Error page & refresh \/ redirections *\/\n # We have plenty of choices when we have to serve an error to the client, \n # from the default error page to javascript black magic or plain redirections.\n # Adding some external statistic javascript to track failures served to\n # clients is strongly suggested.\n # We can't use external resources on synthetic content, everything must be\n # inlined.\n # If we need to include images we can embed them in base64 encoding.\n # We're using error 200 for monitoring puposes which should not be retried\n # client side.\n if ( resp.status != 200) {\n set resp.http.Retry-After = \"5\";\n }\n\n # Here is the default error page for Varnish 4 (not so pretty)\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n return (deliver);\n}\n\n#######################################################################\n# Backend Fetch\n\n# vcl_backend_fetch: Called before sending the backend request. In this\n# subroutine you typically alter the request before it gets to the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-fetch\n# sub vcl_backend_fetch {\n# return (fetch);\n# }\n\n# vcl_backend_response: Called after the response headers has been successfully\n# retrieved from the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-response\nsub vcl_backend_response {\n \/* Caching exceptions *\/\n # Varnish will cache objects with response codes:\n # 200, 203, 300, 301, 302, 307, 404 & 410.\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/VCL_Basics.html#the-initial-value-of-beresp-ttl\n # Drupal's Imagecache module can return a 307 redirection to the requested\n # url itself and, depending on Drupal's cache settings, this could lead to a\n # redirection loop being cached for a long time but also we want Varnish to\n # shield a little the backend.\n # See http:\/\/drupal.org\/node\/1248010\n # See http:\/\/drupal.org\/node\/310656\n if (beresp.status == 307 &&\n #TODO# verify that this work better than 'bereq.url ~ \"imagecache\"'\n beresp.http.Location == bereq.url &&\n beresp.ttl > 5s) {\n set beresp.ttl = 5s;\n set beresp.http.cache-control = \"max-age=5\";\n }\n\n \/* Request retrial *\/\n if ( beresp.status == 500\n || beresp.status == 503\n ) {\n #TODO# consider not restarting POST requests as seenV3 on https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleSaintMode\n return (retry);\n }\n\n \/* Enable grace mode. Related with vcl_hit *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n set beresp.grace = 1h;\n\n \/* Strip cookies from the following static file types for all users. *\/\n # Related with our 12th stage on vcl_recv\n if (bereq.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|woff2|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\") {\n unset beresp.http.set-cookie;\n }\n\n \/* Gzip response *\/\n # Empty in simple configs.\n # Use Varnish to Gzip respone, if suitable, before storing it on cache.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html\n if ( ! beresp.http.Content-Encoding\n && ( beresp.http.content-type ~ \"text\"\n || beresp.http.content-type ~ \"application\/x-javascript\"\n || beresp.http.content-type ~ \"application\/javascript\"\n || beresp.http.content-type ~ \"application\/rss+xml\"\n || beresp.http.content-type ~ \"application\/xml\"\n || beresp.http.content-type ~ \"Application\/JSON\")\n ) {\n set beresp.do_gzip = true;\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # We can add the name of the backend that has processed the request:\n # set beresp.http.X-Backend = beresp.backend.name;\n # We can use a header to tell if the object was gziped by Varnish:\n # if (beresp.do_gzip) {\n # set beresp.http.X-Varnish-Gzipped = \"yes\";\n # } else {\n # set beresp.http.X-Varnish-Gizipped = \"no\";\n # }\n # We can also add headers informing whether the object is cacheable or not and why:\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Varnish3.0\n if (beresp.ttl <= 0s) {\n \/* Varnish determined the object was not cacheable *\/\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n } elsif (bereq.http.Cookie ~ \"(SESS|SSESS|NO_CACHE|OATMEAL|CHOCOLATECHIP)\") {\n \/* We don't wish to cache content for logged in users or with certain cookies. *\/\n # Related with our 9th stage on vcl_recv\n set beresp.http.X-Cacheable = \"NO:Cookies\";\n # set beresp.uncacheable = true;\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n \/* We are respecting the Cache-Control=private header from the backend *\/\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n # set beresp.uncacheable = true;\n } else {\n \/* Varnish determined the object was cacheable *\/\n set beresp.http.X-Cacheable = \"YES\";\n }\n\n \/* Further header manipulation *\/\n # Empty in simple configs.\n # We can also unset some headers to prevent information disclosure and save\n # some cache space.\n # unset beresp.http.Server;\n # unset beresp.http.X-Powered-By;\n # Retry count.\n if ( bereq.retries > 0) {\n set beresp.http.X-Retries = bereq.retries;\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_backend_response {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Surrogate-control ~ \"no-store\" ||\n# (!beresp.http.Surrogate-Control &&\n# beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n# beresp.http.Vary == \"*\") {\n# \/*\n# * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# *\/\n# set beresp.ttl = 120s;\n# set beresp.uncacheable = true;\n# }\n# return (deliver);\n# }\n\n# vcl_backend_error: This subroutine is called if we fail the backend fetch.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-error\nsub vcl_backend_error {\n\n \/* Try to restart request in case of failure *\/\n #TODO# Confirm max_retries default value\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if (bereq.retries < 4) {\n return (retry);\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # Retry count\n if ( bereq.retries > 0) {\n set beresp.http.X-Retries = bereq.retries;\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + beresp.status + \" \" + beresp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + beresp.status + \" \" + beresp.reason + {\"<\/h1>\n <p>\"} + beresp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + bereq.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this\n # point.\n return (deliver);\n}\n\n#######################################################################\n# Housekeeping\n\n# vcl_init: Called when VCL is loaded, before any requests pass through it.\n# Typically used to initialize VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-init\n# Here is where you should declare your directors now.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-backends.html#directors\n# Empty in simple configs\n# sub vcl_init {\n# return (ok);\n# }\n\n# vcl_fini: Called when VCL is discarded only after all requests have exited\n# the VCL. Typically used to clean up VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-fini\n# sub vcl_fini {\n# return (ok);\n# }\n\n","old_contents":"\/*\n * Varnish 4 example config for Drupal 7 \/ Pressflow 6 & 7\n *\/\n\n# Original source: https:\/\/github.com\/NITEMAN\/varnish-bites\/varnish4\/drupal-base.vcl\n# Copyright (c) 2015 Pedro Gonz\u00e1lez Serrano and individual contributors.\n# MIT License\n\n# Intended to be used both in simple production environments and with\n# learning\/teaching purposes.\n# Some references may not be yet updated to VCL 4.0, we use SeeV3 then.\n\n# WARNING:\n# Note that the built-in logic will be appended to our code if no return is\n# performed before.\n# Built-in logic is included commented out right after our's for reference\n# purposes in that cases.\n# See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleDefault\n\n#######################################################################\n# Initialization: Version & imports;\n\n\/* Version statement *\/\n# Since Varnish 4.0 it's mandatory to declare VCL version on first line.\nvcl 4.0;\n\n\/* Module (VMOD) imports *\/\n# Standard module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_std.generated.html\nimport std;\n\n# Directors module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# Unused in simple configs.\n#import directors;\n\n\n#######################################################################\n# Probe, backend, ACL and subroutine definitions\n\n\/* Backend probes \/ healthchecks *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#probes\nprobe basic {\n \/* Only test that backend's IP serves content for '\/' *\/\n # This might be a too heavy probe\n # .url = \"\/\";\n\n \/* Only test that backend's IP has apache working *\/\n # Nginx would fail this probe with a default config\n .request =\n \"OPTIONS * HTTP\/1.1\"\n \"Host: *\"\n \"Connection: close\";\n\n \/* Common options *\/\n .interval = 10s;\n .timeout = 2s;\n .window = 8;\n .threshold = 6;\n}\n\n\/* Backend definitions.*\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#backend-definition\nbackend default {\n \/* Default backend on the same machine. *\/\n # WARNING: timeouts could be not big enought for certain POST requests.\n .host = \"127.0.0.1\";\n .port = \"8008\";\n .max_connections = 100;\n .connect_timeout = 60s;\n .first_byte_timeout = 60s;\n .between_bytes_timeout = 60s;\n .probe = basic;\n}\n\n\/* Access Control Lists *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#access-control-list-acl\nacl purge_ban {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use '\"localhost\";' instead\n}\nacl allowed_monitors {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n}\n# acl own_proxys {\n# \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n# }\n\n\/* Custom subroutines *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#subroutines\n#TODO# Test in Varnihs 4\n# Empty in simple configs.\n# The only restriction naming subs is that the 'vlc_' prefix is reserverd for\n# Varnish use. As a task can need several chunks of code in diferent states,\n# it's a good idea to identify what main sub will call each with a suffix.\n# \/* Example 301 client redirection removing \"www\" prefix from request *\/\n# sub perm_redirections_recv {\n# if ( req.http.host ~ \"^www.*$\" ) {\n# return(\n# synth(751, \"http:\/\/\" + regsub(req.http.host, \"^www\\.\", \"\") + req.url)\n# );\n# }\n# }\n# sub perm_redirections_synth {\n# if (resp.status == 751) {\n# \/* Get new URL from the response *\/\n# set resp.http.Location = resp.response;\n# \/* Set HTTP 301 for permanent redirect *\/\n# set resp.status = 301;\n# return (deliver);\n# }\n# }\n\n\n#######################################################################\n# Client side\n\n# vcl_recv: Called at the beginning of a request, after the complete request\n# has been received and parsed. Its purpose is to decide whether or not to\n# serve the request, how to do it, and, if applicable, which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-recv\nsub vcl_recv {\n \/* 0th: general bypass, general return & authorization checks *\/\n # Empty in simple configs.\n # Useful for debugging we can pipe or pass the request to default backend\n # here to bypass completely Varnish.\n # return (pipe);\n # return (pass);\n # We can also return here a 200 Ok for network performance benchmarking.\n # return(synth(200, \"Ok\"));\n # Finally we can perform basic HTTP authentification here, by example.\n # SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* 1st: Check for Varnish special requests *\/ \n # Custom response implementation example in order to check that Varnish is\n # working properly.\n # This is usefull for automatic monitoring with monit or when Varnish is\n # behind another proxies like HAProxy.\n if ( ( req.http.host == \"monitor.server.health\"\n || req.http.host == \"health.varnish\" )\n && client.ip ~ allowed_monitors\n && ( req.method == \"OPTIONS\" || req.method == \"GET\" )\n ) {\n return(synth(200, \"Ban added\"));\n }\n # Purge logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#http-purging\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if ( req.method == \"PURGE\" ) {\n if ( ! client.ip ~ purge_ban ) {\n return(synth(405, \"Not allowed.\"));\n }\n return (purge);\n }\n # Ban logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#bans\n if ( req.method == \"BAN\" ) {\n if ( ! client.ip ~ purge_ban ) {\n return(synth(405, \"Not allowed.\"));\n }\n ban( \"req.http.host == \" + req.http.host +\n \"&& req.url == \" + req.url);\n return(synth(200, \"Ban added\"));\n }\n\n \/* 2nd: Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_recv;\n # Here we can also enforce SSL when Varnish run behind some SSL termination\n # point.\n\n \/* 3rd: Time for backend choice *\/\n # Empty in simple configs.\n\n \/* 4th: Prepare request for the backend *\/\n # Empty in simple configs.\n # Example remove own_proxys from X-Forwarded-For\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/whats-new\/upgrading.html#x-forwarded-for-is-now-set-before-vcl-recv\n # if ( req.restarts == 0\n # && client.ip ~ own_proxys\n # && req.http.x-forwarded-for\n # ) {\n # set req.http.X-Forwarded-For\n # = regsub(req.http.X-Forwarded-For, \",( )?\" + client.ip, \"\");\n # }\n # Example normalize the host header, remove the port (in case you're testing\n # this on various TCP ports)\n # set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n \/* 5th: Bypass breakpoint 1 *\/\n # Useful for debugging we can now pipe or pass the request to backend with\n # headers setted.\n # return (pipe);\n # return (pass);\n\n \/* 6th: Decide if we should deal with a request (mostly from built-in logic) *\/\n if (req.method == \"PRI\") {\n \/* We do not support SPDY or HTTP\/2.0 *\/\n return (synth(405));\n }\n if ( req.method != \"GET\"\n && req.method != \"HEAD\"\n && req.method != \"PUT\"\n && req.method != \"POST\"\n && req.method != \"TRACE\"\n && req.method != \"OPTIONS\"\n && req.method != \"DELETE\"\n ) {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n\n \/* 7th: Access control for some URLs by ACL *\/\n # Empty in simple configs.\n # By example denial some URLs depending on client-ip, we'll need to define\n # corresponding ACL 'internal'.\n # if ( req.url ~ \"^\/(cron|install)\\.php\"\n # && ! client.ip ~ internal\n # ) {\n # # Have Varnish throw the error directly.\n # return(synth(403, \"Forbidden.\"));\n # # Use a custom error page that you've defined in Drupal at the path \"404\".\n # # set req.url = \"\/403\";\n # }\n\n \/* 8th: Custom exceptions *\/\n # Host exception example:\n # if (req.http.host == \"ejemplo.exception.com\") {\n # return (pass);\n # }\n # Drupal exceptions, edit if we want to cache some AJAX\/AHAH request.\n # Add here filters for never cache URLs such as Payment Gateway's callbacks.\n if ( req.url ~ \"^\/status\\.php$\"\n || req.url ~ \"^\/update\\.php$\"\n || req.url ~ \"^\/ooyala\/ping$\"\n || req.url ~ \"^\/admin\/build\/features\"\n || req.url ~ \"^\/info\/.*$\"\n || req.url ~ \"^\/flag\/.*$\"\n || req.url ~ \"^.*\/ajax\/.*$\"\n || req.url ~ \"^.*\/ahah\/.*$\"\n ) {\n \/* Do not cache these paths *\/\n return (pass);\n }\n # Pipe these paths directly to backend for streaming.\n if (req.url ~ \"^\/admin\/content\/backup_migrate\/export\") {\n return (pipe);\n }\n if (req.url ~ \"^\/system\/files\") {\n return (pipe);\n }\n\n \/* 9th: Graced objets & Serve from anonymous cahe if all backends are down *\/\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n # set req.http.grace = \"none\";\n if ( ! std.healthy(req.backend_hint) ) {\n # We must do this here since cookie hashing\n unset req.http.Cookie;\n #TODO# Add sick marker\n } \n\n \/* 10th: Deal with compression and the Accept-Encoding header *\/\n # Althought Varnish 3 handles gziped content itself by default, just to be\n # sure we want to remove Accept-Encoding for some compressed formats.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html#what-does-http-gzip-support-do\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/varnishd.html?highlight=http_gzip_support\n # See (for older configs) https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleNormalizeAcceptEncoding\n if (req.http.Accept-Encoding) {\n if ( req.url\n ~ \"\\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|mp4|flv|zip|rar)$\"\n ) {\n \/* Already compressed formats, no sense trying to compress again *\/\n unset req.http.Accept-Encoding;\n }\n }\n\n \/* 11th: Another request manipulation *\/\n # Empty in simple configs.\n # We could add here a custom header grouping User-agent families.\n\n \/* 12th: Cookie removal *\/\n # Always cache the following static file types for all users. \n # Use with care if we control certain downloads depending on cookies. \n # Be carefull also if appending .htm[l] via Drupal's clean URLs.\n if ( req.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|woff2|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n && ! req.url ~ \"\/system\/storage\/serve\"\n ) {\n unset req.http.Cookie;\n }\n # Remove all cookies that backend doesn't need to know about.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRemovingSomeCookies\n if (req.http.Cookie) {\n \/* Warning: Not a pretty solution *\/\n # Prefix header containing cookies with ';'\n set req.http.Cookie = \";\" + req.http.Cookie;\n # Remove any spaces after ';' in header containing cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n # Prefix cookies we want to preserve with one space:\n # 'S{1,2}ESS[a-z0-9]+' is the regular expression matching a Drupal session\n # cookie ({1,2} added for HTTPS support).\n # 'NO_CACHE' is usually set after a POST request to make sure issuing user\n # see the results of his post.\n # 'OATMEAL' & 'CHOCOLATECHIP' are special cookies used by Drupal's Bakery\n # module to provide Single Sign On.\n # Keep in mind we should add here any cookie that should reach the backend\n # such as splash avoiding cookies.\n set req.http.Cookie\n = regsuball(\n req.http.Cookie,\n \";(S{1,2}ESS[a-z0-9]+|NO_CACHE|OATMEAL|CHOCOLATECHIP)=\",\n \"; \\1=\"\n );\n # Remove from the header any single Cookie not prefixed with a space until\n # next ';' separator.\n set req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n # Remove any '; ' at the start or the end of the header.\n set req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n #If there are no remaining cookies, remove the cookie header.\n if (req.http.Cookie == \"\") {\n unset req.http.Cookie;\n }\n }\n\n \/* 13th: Session cookie & special cookies bypass caching stage *\/\n # As we might want to cache some requests, hashed with its cookies, we don't\n # simply pass when some cookies remain present at this point.\n # Instead we look for request that must be passed due to the cookie header.\n if ( req.http.Cookie ~ \"SESS\"\n || req.http.Cookie ~ \"SSESS\"\n || req.http.Cookie ~ \"NO_CACHE\"\n || req.http.Cookie ~ \"OATMEAL\"\n || req.http.Cookie ~ \"CHOCOLATECHIP\"\n ) {\n return (pass);\n }\n\n \/* 14th: Bypass breakpoint 2 *\/\n # Useful for debugging we can now pipe or pass the request to backend to\n # bypass cache.\n # return (pipe);\n # return (pass);\n\n \/* 15th: Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n return (hash);\n}\n\n# vcl_pipe: Called upon entering pipe mode.\n# In this mode, the request is passed on to the backend, and any further data\n# from either client or backend is passed on unaltered until either end closes\n# the connection.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pipe\n# sub vcl_pipe {\n# # By default Connection: close is set on all piped requests, to stop\n# # connection reuse from sending future requests directly to the\n# # (potentially) wrong backend. If you do want this to happen, you can undo\n# # it here.\n# # unset bereq.http.connection;\n# return (pipe);\n# }\n\n# vcl_pass: Called upon entering pass mode. \n# In this mode, the request is passed on to the backend, and the backend's\n# response is passed on to the client, but is not entered into the cache.\n# Subsequent requests submitted over the same client connection are handled normally.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pass\n# sub vcl_pass {\n# return (fetch);\n# }\n\n# vcl_hash: You may call hash_data() on the data you would like to add to the\n# hash.\n# Hash is used by Varnish to uniquely identify objects.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hash\nsub vcl_hash {\n \/* Hash cookie data *\/\n # As requests with same URL and host can produce diferent results when issued\n # with different cookies, we need to store items hashed with the associated\n # cookies. Note that cookies are already sanitized when we reach this point.\n if (req.http.Cookie) {\n \/* Include cookie in cache hash *\/\n hash_data(req.http.Cookie);\n }\n\n \/* Custom header hashing *\/\n # Empty in simple configs.\n # Example for caching differents object versions by device previously\n # detected (when static content could also vary):\n # if (req.http.X-UA-Device) {\n # hash_data(req.http.X-UA-Device);\n # }\n # Example for caching diferent object versions by X-Forwarded-Proto, trying\n # to be smart about what kind of request could generate diffetent responses.\n if ( req.http.X-Forwarded-Proto\n && req.url !~ \"(?i)\\.(png|gif|jpeg|jpg|ico|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|woff2|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\") {\n hash_data(req.http.X-Forwarded-Proto);\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (lookup);\n# }\n\n# vcl_purge: Called after the purge has been executed and all its variants have\n# been evited.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-purge\n# sub vcl_purge {\n# return (synth(200, \"Purged\"));\n# }\n\n# vcl_hit: Called after a cache lookup if the requested document was found in\n# the cache.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hit\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n \/\/ A pure unadultered hit, deliver it\n return (deliver);\n }\n \/* Allow varnish to serve up stale content if it is responding slowly *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n if (obj.ttl + 60s > 0s) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n set req.http.grace = \"normal\";\n return (deliver);\n }\n \/* Allow varish to serve up stale content if all backends are down *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n if ( ! std.healthy(req.backend_hint)\n && obj.ttl + obj.grace > 0s\n ) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n set req.http.grace = \"extended\";\n return (deliver);\n }\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\n# vcl_miss: Called after a cache lookup if the requested document was not found\n# in the cache.\n# Its purpose is to decide whether or not to attempt to retrieve the document\n# from the backend, and which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-miss\n# sub vcl_miss {\n# return (fetch);\n# }\n\n# vcl_deliver: Called before an object is delivered to the client\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-deliver\nsub vcl_deliver {\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # Add whether the object is a cache hit or miss and the number of hits for\n # the object.\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Addingaheaderindicatinghitmiss\n # In Varnish 4 the obj.hits counter behaviour has changed (see bug 1492), so\n # we use a different method: if X-Varnish contains only 1 id, we have a miss,\n # if it contains more (and therefore a space), we have a hit.\n if (resp.http.x-varnish ~ \" \") {\n set resp.http.X-Cache = \"HIT\";\n # Since in Varnish 4 the behaviour of obj.hits changed, this might not be\n # accurate.\n # See https:\/\/www.varnish-cache.org\/trac\/ticket\/1492\n set resp.http.X-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Cache = \"MISS\";\n \/* Show the results of cookie sanitization *\/\n set resp.http.X-Cookie = req.http.Cookie;\n }\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n set resp.http.grace = req.http.grace;\n\n #TODO# Add sick marker\n\n # Restart count\n if ( req.restarts > 0) {\n set resp.http.X-Restarts = req.restarts;\n }\n\n # Add the Varnish server hostname\n set resp.http.X-Varnish-Server = server.hostname;\n # If we have setted a custom header with device's family detected we can show\n # it:\n # if (req.http.X-UA-Device) {\n # set resp.http.X-UA-Device = req.http.X-UA-Device;\n # }\n # If we have recived a custom header indicating the protocol in the request we\n # can show it:\n # if (req.http.X-Forwarded-Proto) {\n # set resp.http.X-Forwarded-Proto = req.http.X-Forwarded-Proto;\n # }\n\n \/* Vary header manipulation *\/\n # Empty in simple configs.\n # By example, if we are storing & serving diferent objects depending on\n # User-Agent header we must set the correct Vary header:\n # if (resp.http.Vary) {\n # set resp.http.Vary = resp.http.Vary + \",User-Agent\";\n # } else {\n # set resp.http.Vary = \"User-Agent\";\n # }\n\n \/* Fake headers *\/\n # Empty in simple configs\n # We can fake server headers here, by example:\n # set resp.http.Server = \"Deep thought\";\n # set resp.http.X-Powered-By = \"BOFH\";\n # Or have some fun with headers:\n # See http:\/\/www.nextthing.org\/archives\/2005\/08\/07\/fun-with-http-headers\n # See http:\/\/royal.pingdom.com\/2012\/08\/15\/fun-and-unusual-http-response-headers\/\n # set resp.http.X-Thank-You = \"for bothering to look at my HTTP headers\";\n # set resp.http.X-Answer = \"42\";\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_deliver {\n# return (deliver);\n# }\n\n# vcl_synth: Called to deliver a synthetic object. A synthetic object is\n# generated in VCL, not fetched from the backend. It is typically contructed\n# using the synthetic() function.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-synth\n\/*\n * We can come here \"invisibly\" with the following errors: 413, 417 & 503\n *\/\nsub vcl_synth {\n \/* Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_synth;\n\n \/* Try to restart request in case of failure *\/\n # Note that max_restarts defaults to 4\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if (resp.status == 503 && req.restarts < 4) {\n return(restart);\n }\n\n \/* Set common headers for synthetic responses *\/\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n\n \/* HTTP Authentification client request *\/\n # Empty in simple configs.\n # SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* Load synthetic responses from disk *\/\n # Note that files loaded this way are never re-readed (even after a reload).\n # You should consider PROS\/CONS of doing an include instead.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_std.generated.html#func-fileread\n # Example custom 403 error page.\n # if (resp.status == 403) {\n # synthetic(std.fileread(\"\/403.html\"));\n # return(deliver);\n # }\n\n \/* Error page & refresh \/ redirections *\/\n # We have plenty of choices when we have to serve an error to the client, \n # from the default error page to javascript black magic or plain redirections.\n # Adding some external statistic javascript to track failures served to\n # clients is strongly suggested.\n # We can't use external resources on synthetic content, everything must be\n # inlined.\n # If we need to include images we can embed them in base64 encoding.\n # We're using error 200 for monitoring puposes which should not be retried\n # client side.\n if ( resp.status != 200) {\n set resp.http.Retry-After = \"5\";\n }\n\n # Here is the default error page for Varnish 4 (not so pretty)\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n return (deliver);\n}\n\n#######################################################################\n# Backend Fetch\n\n# vcl_backend_fetch: Called before sending the backend request. In this\n# subroutine you typically alter the request before it gets to the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-fetch\n# sub vcl_backend_fetch {\n# return (fetch);\n# }\n\n# vcl_backend_response: Called after the response headers has been successfully\n# retrieved from the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-response\nsub vcl_backend_response {\n \/* Caching exceptions *\/\n # Varnish will cache objects with response codes:\n # 200, 203, 300, 301, 302, 307, 404 & 410.\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/VCL_Basics.html#the-initial-value-of-beresp-ttl\n # Drupal's Imagecache module can return a 307 redirection to the requested\n # url itself and, depending on Drupal's cache settings, this could lead to a\n # redirection loop being cached for a long time but also we want Varnish to\n # shield a little the backend.\n # See http:\/\/drupal.org\/node\/1248010\n # See http:\/\/drupal.org\/node\/310656\n if (beresp.status == 307 &&\n #TODO# verify that this work better than 'bereq.url ~ \"imagecache\"'\n beresp.http.Location == bereq.url &&\n beresp.ttl > 5s) {\n set beresp.ttl = 5s;\n set beresp.http.cache-control = \"max-age=5\";\n }\n\n \/* Request retrial *\/\n if ( beresp.status == 500\n || beresp.status == 503\n ) {\n #TODO# consider not restarting POST requests as seenV3 on https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleSaintMode\n return (retry);\n }\n\n \/* Enable grace mode. Related with vcl_hit *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n set beresp.grace = 1h;\n\n \/* Strip cookies from the following static file types for all users. *\/\n # Related with our 12th stage on vcl_recv\n if (bereq.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|woff2|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\") {\n unset beresp.http.set-cookie;\n }\n\n \/* Gzip response *\/\n # Empty in simple configs.\n # Use Varnish to Gzip respone, if suitable, before storing it on cache.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html\n if ( ! beresp.http.Content-Encoding\n && ( beresp.http.content-type ~ \"text\"\n || beresp.http.content-type ~ \"application\/x-javascript\"\n || beresp.http.content-type ~ \"application\/javascript\"\n || beresp.http.content-type ~ \"application\/rss+xml\"\n || beresp.http.content-type ~ \"application\/xml\"\n || beresp.http.content-type ~ \"Application\/JSON\")\n ) {\n set beresp.do_gzip = true;\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # We can add the name of the backend that has processed the request:\n # set beresp.http.X-Backend = beresp.backend.name;\n # We can use a header to tell if the object was gziped by Varnish:\n # if (beresp.do_gzip) {\n # set beresp.http.X-Varnish-Gzipped = \"yes\";\n # } else {\n # set beresp.http.X-Varnish-Gizipped = \"no\";\n # }\n # We can also add headers informing whether the object is cacheable or not and why:\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Varnish3.0\n if (beresp.ttl <= 0s) {\n \/* Varnish determined the object was not cacheable *\/\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n } elsif (bereq.http.Cookie ~ \"(SESS|SSESS|NO_CACHE|OATMEAL|CHOCOLATECHIP)\") {\n \/* We don't wish to cache content for logged in users or with certain cookies. *\/\n # Related with our 9th stage on vcl_recv\n set beresp.http.X-Cacheable = \"NO:Cookies\";\n # return(hit_for_pass);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n \/* We are respecting the Cache-Control=private header from the backend *\/\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n # return(hit_for_pass);\n } else {\n \/* Varnish determined the object was cacheable *\/\n set beresp.http.X-Cacheable = \"YES\";\n }\n\n \/* Further header manipulation *\/\n # Empty in simple configs.\n # We can also unset some headers to prevent information disclosure and save\n # some cache space.\n # unset beresp.http.Server;\n # unset beresp.http.X-Powered-By;\n # Retry count.\n if ( bereq.retries > 0) {\n set beresp.http.X-Retries = bereq.retries;\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_backend_response {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Surrogate-control ~ \"no-store\" ||\n# (!beresp.http.Surrogate-Control &&\n# beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n# beresp.http.Vary == \"*\") {\n# \/*\n# * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# *\/\n# set beresp.ttl = 120s;\n# set beresp.uncacheable = true;\n# }\n# return (deliver);\n# }\n\n# vcl_backend_error: This subroutine is called if we fail the backend fetch.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-error\nsub vcl_backend_error {\n\n \/* Try to restart request in case of failure *\/\n #TODO# Confirm max_retries default value\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if (bereq.retries < 4) {\n return (retry);\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # Retry count\n if ( bereq.retries > 0) {\n set beresp.http.X-Retries = bereq.retries;\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + beresp.status + \" \" + beresp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + beresp.status + \" \" + beresp.reason + {\"<\/h1>\n <p>\"} + beresp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + bereq.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this\n # point.\n return (deliver);\n}\n\n#######################################################################\n# Housekeeping\n\n# vcl_init: Called when VCL is loaded, before any requests pass through it.\n# Typically used to initialize VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-init\n# Here is where you should declare your directors now.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-backends.html#directors\n# Empty in simple configs\n# sub vcl_init {\n# return (ok);\n# }\n\n# vcl_fini: Called when VCL is discarded only after all requests have exited\n# the VCL. Typically used to clean up VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-fini\n# sub vcl_fini {\n# return (ok);\n# }\n\n","returncode":0,"stderr":"","license":"unknown","lang":"VCL"} {"commit":"603da453af1c7926b62ea23cc58ffd38d251ff15","subject":"Rename the varnish template and edit it for new json","message":"Rename the varnish template and edit it for new json\n","repos":"EOL\/eol-docker-cookbook,EOL\/eol-docker-cookbook,EOL\/eol-docker-cookbook","old_file":"templates\/default\/varnish_default.vcl","new_file":"templates\/default\/varnish_default.vcl","new_contents":"","old_contents":"################### backends ###################\n\n#### CONTENT ####\nbackend content {\n .host = \"<%= @params['content_ip'] %>\";\n .port = \"<%= @params['content_port'] %>\";\n .probe = {\n .url = \"\/status.html\";\n .interval = 5s;\n .timeout = 1s;\n .window = 5;\n .threshold = 3;\n }\n}\n# backend content_mbl {\n# .host = \"<%= @params['content_backup_ip'] %>\";\n# .port = \"<%= @params['content_backup_port'] %>\";\n# }\n\n### APPSERVERS ####\nbackend app1 {\n .host= \"<%= @params['app1_ip'] %>\";\n .port = \"<%= @params['app1_port'] %>\";\n .first_byte_timeout = 120s;\n .probe = { .url = \"\/api\/ping.json\"; .interval = 5s;\n .timeout = 3s; .window = 5; .threshold = 3; }\n}\nbackend app2 {\n .host= \"<%= @params['app2_ip'] %>\";\n .port = \"<%= @params['app2_port'] %>\";\n .first_byte_timeout = 120s;\n .probe = { .url = \"\/api\/ping.json\"; .interval = 5s;\n .timeout = 3s; .window = 5; .threshold = 3; }\n}\nbackend app3 {\n .host= \"<%= @params['app3_ip'] %>\";\n .port = \"<%= @params['app3_port'] %>\";\n .first_byte_timeout = 120s;\n .probe = { .url = \"\/api\/ping.json\"; .interval = 5s;\n .timeout = 3s; .window = 5; .threshold = 3; }\n}\n\n################## directors ###################\n\n# These are our public app servers:\ndirector appfarm random {\n .retries = 5;\n { .backend = app1; .weight = 5; }\n { .backend = app2; .weight = 5; }\n { .backend = app3; .weight = 5; }\n}\n\ndirector searchbots random {\n .retries = 5;\n { .backend = app1; .weight = 5; }\n { .backend = app2; .weight = 5; }\n { .backend = app3; .weight = 5; }\n}\n\ndirector apirequests random {\n .retries = 5;\n { .backend = app1; .weight = 5; }\n { .backend = app2; .weight = 5; }\n { .backend = app3; .weight = 5; }\n}\n\nsub vcl_recv {\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n# No point in compressing these\n remove req.http.Accept-Encoding;\n } else if (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } else if (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n# unknown algorithm\n remove req.http.Accept-Encoding;\n }\n }\n if (req.http.user-agent ~ \"Googlebot\" ||\n req.http.user-agent ~ \"Googlebot-Mobile\" ||\n req.http.user-agent ~ \"Googlebot-Image\" ||\n req.http.user-agent ~ \"rogerbot\" ||\n req.http.user-agent ~ \"msnbot-UDiscovery\" ||\n req.http.user-agent ~ \"msnbot-Udiscovery\" ||\n req.http.user-agent ~ \"Gigabot\" ||\n req.http.user-agent ~ \"msnbot-media\" ||\n req.http.user-agent ~ \"bingbot\" ||\n req.http.user-agent ~ \"YandexBot\" ||\n req.http.user-agent ~ \"NAVER Blog Rssbot\" ||\n req.http.user-agent ~ \"ScoutJet\" ||\n req.http.user-agent ~ \"Exabot-Thumbnails\" ||\n req.http.user-agent ~ \"Exabot\" ||\n req.http.user-agent ~ \"FriendFeedBot\" ||\n req.http.user-agent ~ \"Ezooms\" ||\n req.http.user-agent ~ \"Netluchs\" ||\n req.http.user-agent ~ \"msnbot\" ||\n req.http.user-agent ~ \"YodaoBot\" ||\n req.http.user-agent ~ \"Yahoo! Slurp\" ||\n req.http.user-agent ~ \"Diffbot\" ||\n req.http.user-agent ~ \"gsa-crawler\" ||\n req.http.user-agent ~ \"psbot\" ||\n req.http.user-agent ~ \"Yeti\" ||\n req.http.user-agent ~ \"microbot\" ||\n req.http.user-agent ~ \"magpie-crawler\" ||\n req.http.user-agent ~ \"ia_archiver(OS-Wayback)\" ||\n req.http.user-agent ~ \"ia_archiver\" ||\n req.http.user-agent ~ \"AdsBot-Google\" ||\n req.http.user-agent ~ \"EdisterBot\" ||\n req.http.user-agent ~ \"MLBot\" ||\n req.http.user-agent ~ \"PiplBot\" ||\n req.http.user-agent ~ \"MS Search 5.0 Robot\" ||\n req.http.user-agent ~ \"HuaweiSymantecSpider\" ||\n req.http.user-agent ~ \"ShopWiki\" ||\n req.http.user-agent ~ \"itim\" ||\n req.http.user-agent ~ \"suggybot\" ||\n req.http.user-agent ~ \"AhrefsBot\" ||\n req.http.user-agent ~ \"yacybot\" ||\n req.http.user-agent ~ \"Daumoa\" ||\n req.http.user-agent ~ \"YodaoBot-Image\" ||\n req.http.user-agent ~ \"YodaoBot\" ||\n req.http.user-agent ~ \"Speedy Spider\" ||\n req.http.user-agent ~ \"discobot\" ||\n req.http.user-agent ~ \"MJ12bot\" ||\n req.http.user-agent ~ \"Baiduspider\" ||\n req.http.user-agent ~ \"Doubanbot\" ||\n req.http.user-agent ~ \"Setooz\" ||\n req.http.user-agent ~ \"Spinn3r\" ||\n req.http.user-agent ~ \"WebTrends\" ||\n req.http.user-agent ~ \"Slurp\" ||\n req.http.user-agent ~ \"YandexBot\" ||\n req.http.user-agent ~ \"msnbot\" ||\n req.http.user-agent ~ \"Smithsonian-Public-GSA\" ||\n req.http.user-agent ~ \"PaperLiBot\") {\n set req.backend = searchbots;\n } elseif (req.url ~ \"\/testaction\" ) {\n return(error);\n } elseif (req.url ~ \"^\/api\" ) {\n set req.backend = apirequests;\n } elseif (req.url ~ \"^\/content\/20\") {\n unset req.http.Cookie;\n unset req.http.Authorization;\n unset req.http.cache-control;\n unset req.http.pragma;\n unset req.http.expires;\n unset req.http.etag;\n unset req.http.X-Forwarded-For;\n set req.backend = content;\n set req.http.host = \"10.0.0.31\";\n } elseif (req.http.host ~ \"10.0.0.31$\") {\n unset req.http.Cookie;\n unset req.http.Authorization;\n set req.backend = content_mbl;\n } else {\n set req.backend = appfarm;\n }\n}\n\n# ################### vcl_recv ###################\n# sub vcl_recv {\n# # Before anything else we need to fix gzip compression\n# if (req.http.Accept-Encoding) {\n# if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n# # No point in compressing these\n# remove req.http.Accept-Encoding;\n# } else if (req.http.Accept-Encoding ~ \"gzip\") {\n# set req.http.Accept-Encoding = \"gzip\";\n# } else if (req.http.Accept-Encoding ~ \"deflate\") {\n# set req.http.Accept-Encoding = \"deflate\";\n# } else {\n# # unknown algorithm\n# remove req.http.Accept-Encoding;\n# }\n# }\n# # Temporary redirect to mbl while we fix edge\n# # comment out this after it is done\n# # } elseif (req.url ~ \"^\/content\/20\") {\n# # unset req.http.Cookie;\n# # unset req.http.Authorization;\n# # unset req.http.cache-control;\n# # unset req.http.pragma;\n# # unset req.http.expires;\n# # unset req.http.etag;\n# # unset req.http.X-Forwarded-For;\n# # set req.backend = content_mbl;\n# # set req.http.host = \"content_mbl.eol.org\";\n# } elseif (req.http.host ~ \"content_mbl.eol.org$\") {\n# unset req.http.Cookie;\n# unset req.http.Authorization;\n# set req.backend = content_mbl;\n# } else {\n# set req.backend = appfarm;\n# }\n#\n# #forbidden clients\n# if (client.ip ~ forbidden) {\n# error 403 \"Forbidden\";\n# }\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"44b0adab53333c48bf3f8d89893ecbb0f294ed06","subject":"fix features which are above 100 characters. Fixes #1853","message":"fix features which are above 100 characters. Fixes #1853\n","repos":"JakeChampion\/polyfill-service,JakeChampion\/polyfill-service","old_file":"fastly\/vcl\/main.vcl","new_file":"fastly\/vcl\/main.vcl","new_contents":"import querystring;\n\nsub sort_comma_separated_value {\n\t# This function takes a CSV and tranforms it into a url where each\n\t# comma-separated-value is a query-string parameter and then uses \n\t# Fastly's querystring.sort function to sort the values. Once sorted\n\t# it then turn the query-parameters back into a CSV.\n\t# Set the CSV on the header `Sort-Value`.\n\t# Returns the sorted CSV on the header `Sorted-Value`.\n\tdeclare local var.value STRING;\n\tset var.value = req.http.Sort-value;\n\n\t# If query value does not exist or is empty, set it to \"\"\n\tset var.value = if(var.value != \"\", var.value, \"\");\n\n\t# Replace all `&` characters with `^`, this is because `&` would break the value up into pieces.\n\tset var.value = regsuball(var.value, \"&\", \"^\");\n\n\t# Replace all `,` characters with `&` to break them into individual query values\n\t# Append `1-` infront of all the query values to make them simpler to transform later\n\tset var.value = \"1-\" regsuball(var.value, \",\", \"&1-\");\n\t\n\t# Create a querystring-like string in order for querystring.sort to work.\n\tset var.value = querystring.sort(\"?\" var.value);\n\n\t# Grab all the query values from the sorted url\n\tset var.value = regsub(var.value, \"\\?\", \"\");\n\t\n\t# Reverse all the previous transformations to get back the single `features` query value value\n\tset var.value = regsuball(var.value, \"1-\", \"\");\n\tset var.value = regsuball(var.value, \"&\", \",\");\n\tset var.value = regsuball(var.value, \"\\^\", \"&\");\n\n\tset req.http.Sorted-Value = var.value;\n}\n\nsub normalise_querystring_parameters_for_polyfill_bundle {\n\t# Store the url without the querystring into a temporary header.\n\tdeclare local var.url STRING;\n\tset var.url = querystring.remove(req.url);\n\n\tdeclare local var.querystring STRING;\n\tset var.querystring = \"?\";\n\n\t# Remove all querystring parameters which are not part of the public API.\n\t# set req.url = querystring.regfilter_except(req.url, \"^(features|excludes|rum|unknown|flags|version|ua|callback|compression)$\");\n\n\t# (?i) makes the regex case-insensitive\n\t# The regex will match only if their are characters after `features=` which are not an ampersand (&).\n\tif (req.url.qs ~ \"(?i)[^&=]*features=([^&]+)\") {\n\t\t# Parameter has already been set, use the already set value.\n\t\t# re.group.1 is the first regex capture group in the regex above.\n\t\tif (std.strlen(re.group.1) < 100) {\n\t\t\t# We add the value of the features parameter to this header\n\t\t\t# This is to be able to have sort_comma_separated_value sort the value\n\t\t\tset req.http.Sort-Value = urldecode(re.group.1);\n\t\t\tcall sort_comma_separated_value;\n\t\t\t# The header Sorted-Value now contains the sorted version of the features parameter.\n\t\t\tset var.querystring = querystring.set(var.querystring, \"features\", req.http.Sorted-Value);\n\t\t} else {\n\t\t\tset var.querystring = querystring.set(var.querystring, \"features\", re.group.1);\n\t\t}\n\t} else {\n\t\t# Parameter has not been set, use the default value.\n\t\tset var.querystring = querystring.set(var.querystring, \"features\", \"default\");\n\t}\n\t\n\t# (?i) makes the regex case-insensitive\n\t# The regex will match only if their are characters after `excludes=` which are not an ampersand (&).\n\tif (req.url.qs ~ \"(?i)[^&=]*excludes=([^&]+)\") {\n\t\t# Parameter has already been set, use the already set value.\n\t\t# re.group.1 is the first regex capture group in the regex above.\n\t\tif (std.strlen(re.group.1) < 100) {\n\t\t\t# We add the value of the excludes parameter to this header\n\t\t\t# This is to be able to have sort_comma_separated_value sort the value\n\t\t\tset req.http.Sort-Value = urldecode(re.group.1);\n\t\t\tcall sort_comma_separated_value;\n\t\t\t# The header Sorted-Value now contains the sorted version of the excludes parameter.\n\t\t\tset var.querystring = querystring.set(var.querystring, \"excludes\", req.http.Sorted-Value);\n\t\t}\n\t} else {\n\t\t# If excludes is not set, set to default value \"\"\n\t\tset var.querystring = var.querystring \"&excludes=\";\n\t}\n\t\n\t# If rum is not set, set to default value \"0\"\n\tif (req.url.qs !~ \"(?i)[^&=]*rum=([^&]+)\") {\n\t\tset var.querystring = querystring.set(var.querystring, \"rum\", \"0\");\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"rum\", re.group.1);\n\t}\n\t\n\t# If unknown is not set, set to default value \"polyfill\"\n\tif (req.url.qs !~ \"(?i)[^&=]*unknown=([^&]+)\") {\n\t\tset var.querystring = querystring.set(var.querystring, \"unknown\", \"polyfill\");\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"unknown\", re.group.1);\n\t}\n\n\t# If flags is not set, set to default value \"\"\n\tif (req.url.qs !~ \"(?i)[^&=]*flags=([^&]+)\") {\n\t\tset var.querystring = var.querystring \"&flags=\";\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"flags\", re.group.1);\n\t}\n\n\t# If version is not set, set to default value \"\"\n\tdeclare local var.version STRING;\n\tif (req.url.qs !~ \"(?i)[^&=]*version=([^&]+)\") {\n\t\tset var.querystring = var.querystring \"&version=\";\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"version\", re.group.1);\n\t}\n\t\n\t# If ua is not set, normalise the User-Agent header based upon the version of the polyfill-library that has been requested.\n\tif (req.url.qs !~ \"(?i)[^&=]*ua=([^&]+)\") {\n\t\tif (req.url.qs ~ \"(?i)[^&=]*version=3\\.25\\.1(&|$)\") {\n\t\t\tcall normalise_user_agent_3_25_1;\n\t\t} else {\n\t\t\tcall normalise_user_agent_latest;\n\t\t}\n\t\tset var.querystring = querystring.set(var.querystring, \"ua\", req.http.Normalized-User-Agent);\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"ua\", re.group.1);\n\t}\n\n\t# If callback is not set, set to default value \"\"\n\tif (req.url.qs !~ \"(?i)[^&=]*callback=([^&]+)\") {\n\t\tset var.querystring = var.querystring \"&callback=\";\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"callback\", re.group.1);\n\t}\n\t\n\t# If compression is not set, use the best compression that the user-agent supports.\n\tif (req.url.qs !~ \"(?i)[^&=]*compression=([^&]+)\") {\n\t\t# When Fastly adds Brotli into the Accept-Encoding normalisation we can replace this with: \n\t\t# `set var.querystring = querystring.set(var.querystring, \"compression\", req.http.Accept-Encoding || \"\")`\n\n\t\t# Before SP2, IE\/6 doesn't always read and cache gzipped content correctly.\n\t\tif (req.http.Fastly-Orig-Accept-Encoding && req.http.User-Agent !~ \"MSIE 6\") {\n\t\t\tif (req.http.Fastly-Orig-Accept-Encoding ~ \"br\") {\n\t\t\t\tset var.querystring = querystring.set(var.querystring, \"compression\", \"br\");\n\t\t\t} elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"gzip\") {\n\t\t\t\tset var.querystring = querystring.set(var.querystring, \"compression\", \"gzip\");\n\t\t\t} else {\n\t\t\t\tset var.querystring = var.querystring \"&compression=\";\n\t\t\t}\n\t\t} else {\n\t\t\tset var.querystring = var.querystring \"&compression=\";\n\t\t}\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"compression\", re.group.1);\n\t}\n\tset req.url = var.url var.querystring;\n}\n\ninclude \"ua_parser.vcl\";\ninclude \"normalise-user-agent-3-25-1.vcl\";\ninclude \"normalise-user-agent-latest.vcl\";\n\n# The Fastly VCL boilerplate.\ninclude \"fastly-boilerplate-begin.vcl\";\n\ninclude \"breadcrumbs.vcl\";\ninclude \"redirects.vcl\";\ninclude \"synthetic-responses.vcl\";\ninclude \"polyfill-service.vcl\";\n\n# Finally include the last bit of VCL, this _must_ be last!\ninclude \"fastly-boilerplate-end.vcl\";\n","old_contents":"import querystring;\n\nsub sort_comma_separated_value {\n\t# This function takes a CSV and tranforms it into a url where each\n\t# comma-separated-value is a query-string parameter and then uses \n\t# Fastly's querystring.sort function to sort the values. Once sorted\n\t# it then turn the query-parameters back into a CSV.\n\t# Set the CSV on the header `Sort-Value`.\n\t# Returns the sorted CSV on the header `Sorted-Value`.\n\tdeclare local var.value STRING;\n\tset var.value = req.http.Sort-value;\n\n\t# If query value does not exist or is empty, set it to \"\"\n\tset var.value = if(var.value != \"\", var.value, \"\");\n\n\t# Replace all `&` characters with `^`, this is because `&` would break the value up into pieces.\n\tset var.value = regsuball(var.value, \"&\", \"^\");\n\n\t# Replace all `,` characters with `&` to break them into individual query values\n\t# Append `1-` infront of all the query values to make them simpler to transform later\n\tset var.value = \"1-\" regsuball(var.value, \",\", \"&1-\");\n\t\n\t# Create a querystring-like string in order for querystring.sort to work.\n\tset var.value = querystring.sort(\"?\" var.value);\n\n\t# Grab all the query values from the sorted url\n\tset var.value = regsub(var.value, \"\\?\", \"\");\n\t\n\t# Reverse all the previous transformations to get back the single `features` query value value\n\tset var.value = regsuball(var.value, \"1-\", \"\");\n\tset var.value = regsuball(var.value, \"&\", \",\");\n\tset var.value = regsuball(var.value, \"\\^\", \"&\");\n\n\tset req.http.Sorted-Value = var.value;\n}\n\nsub normalise_querystring_parameters_for_polyfill_bundle {\n\t# Store the url without the querystring into a temporary header.\n\tdeclare local var.url STRING;\n\tset var.url = querystring.remove(req.url);\n\n\tdeclare local var.querystring STRING;\n\tset var.querystring = \"?\";\n\n\t# Remove all querystring parameters which are not part of the public API.\n\t# set req.url = querystring.regfilter_except(req.url, \"^(features|excludes|rum|unknown|flags|version|ua|callback|compression)$\");\n\n\t# (?i) makes the regex case-insensitive\n\t# The regex will match only if their are characters after `features=` which are not an ampersand (&).\n\tif (req.url.qs ~ \"(?i)[^&=]*features=([^&]+)\") {\n\t\t# Parameter has already been set, use the already set value.\n\t\t# re.group.1 is the first regex capture group in the regex above.\n\t\tif (std.strlen(re.group.1) < 100) {\n\t\t\t# We add the value of the features parameter to this header\n\t\t\t# This is to be able to have sort_comma_separated_value sort the value\n\t\t\tset req.http.Sort-Value = urldecode(re.group.1);\n\t\t\tcall sort_comma_separated_value;\n\t\t\t# The header Sorted-Value now contains the sorted version of the features parameter.\n\t\t\tset var.querystring = querystring.set(var.querystring, \"features\", req.http.Sorted-Value);\n\t\t}\n\t} else {\n\t\t# Parameter has not been set, use the default value.\n\t\tset var.querystring = querystring.set(var.querystring, \"features\", \"default\");\n\t}\n\t\n\t# (?i) makes the regex case-insensitive\n\t# The regex will match only if their are characters after `excludes=` which are not an ampersand (&).\n\tif (req.url.qs ~ \"(?i)[^&=]*excludes=([^&]+)\") {\n\t\t# Parameter has already been set, use the already set value.\n\t\t# re.group.1 is the first regex capture group in the regex above.\n\t\tif (std.strlen(re.group.1) < 100) {\n\t\t\t# We add the value of the excludes parameter to this header\n\t\t\t# This is to be able to have sort_comma_separated_value sort the value\n\t\t\tset req.http.Sort-Value = urldecode(re.group.1);\n\t\t\tcall sort_comma_separated_value;\n\t\t\t# The header Sorted-Value now contains the sorted version of the excludes parameter.\n\t\t\tset var.querystring = querystring.set(var.querystring, \"excludes\", req.http.Sorted-Value);\n\t\t}\n\t} else {\n\t\t# If excludes is not set, set to default value \"\"\n\t\tset var.querystring = var.querystring \"&excludes=\";\n\t}\n\t\n\t# If rum is not set, set to default value \"0\"\n\tif (req.url.qs !~ \"(?i)[^&=]*rum=([^&]+)\") {\n\t\tset var.querystring = querystring.set(var.querystring, \"rum\", \"0\");\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"rum\", re.group.1);\n\t}\n\t\n\t# If unknown is not set, set to default value \"polyfill\"\n\tif (req.url.qs !~ \"(?i)[^&=]*unknown=([^&]+)\") {\n\t\tset var.querystring = querystring.set(var.querystring, \"unknown\", \"polyfill\");\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"unknown\", re.group.1);\n\t}\n\n\t# If flags is not set, set to default value \"\"\n\tif (req.url.qs !~ \"(?i)[^&=]*flags=([^&]+)\") {\n\t\tset var.querystring = var.querystring \"&flags=\";\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"flags\", re.group.1);\n\t}\n\n\t# If version is not set, set to default value \"\"\n\tdeclare local var.version STRING;\n\tif (req.url.qs !~ \"(?i)[^&=]*version=([^&]+)\") {\n\t\tset var.querystring = var.querystring \"&version=\";\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"version\", re.group.1);\n\t}\n\t\n\t# If ua is not set, normalise the User-Agent header based upon the version of the polyfill-library that has been requested.\n\tif (req.url.qs !~ \"(?i)[^&=]*ua=([^&]+)\") {\n\t\tif (req.url.qs ~ \"(?i)[^&=]*version=3\\.25\\.1(&|$)\") {\n\t\t\tcall normalise_user_agent_3_25_1;\n\t\t} else {\n\t\t\tcall normalise_user_agent_latest;\n\t\t}\n\t\tset var.querystring = querystring.set(var.querystring, \"ua\", req.http.Normalized-User-Agent);\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"ua\", re.group.1);\n\t}\n\n\t# If callback is not set, set to default value \"\"\n\tif (req.url.qs !~ \"(?i)[^&=]*callback=([^&]+)\") {\n\t\tset var.querystring = var.querystring \"&callback=\";\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"callback\", re.group.1);\n\t}\n\t\n\t# If compression is not set, use the best compression that the user-agent supports.\n\tif (req.url.qs !~ \"(?i)[^&=]*compression=([^&]+)\") {\n\t\t# When Fastly adds Brotli into the Accept-Encoding normalisation we can replace this with: \n\t\t# `set var.querystring = querystring.set(var.querystring, \"compression\", req.http.Accept-Encoding || \"\")`\n\n\t\t# Before SP2, IE\/6 doesn't always read and cache gzipped content correctly.\n\t\tif (req.http.Fastly-Orig-Accept-Encoding && req.http.User-Agent !~ \"MSIE 6\") {\n\t\t\tif (req.http.Fastly-Orig-Accept-Encoding ~ \"br\") {\n\t\t\t\tset var.querystring = querystring.set(var.querystring, \"compression\", \"br\");\n\t\t\t} elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"gzip\") {\n\t\t\t\tset var.querystring = querystring.set(var.querystring, \"compression\", \"gzip\");\n\t\t\t} else {\n\t\t\t\tset var.querystring = var.querystring \"&compression=\";\n\t\t\t}\n\t\t} else {\n\t\t\tset var.querystring = var.querystring \"&compression=\";\n\t\t}\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"compression\", re.group.1);\n\t}\n\tset req.url = var.url var.querystring;\n}\n\ninclude \"ua_parser.vcl\";\ninclude \"normalise-user-agent-3-25-1.vcl\";\ninclude \"normalise-user-agent-latest.vcl\";\n\n# The Fastly VCL boilerplate.\ninclude \"fastly-boilerplate-begin.vcl\";\n\ninclude \"breadcrumbs.vcl\";\ninclude \"redirects.vcl\";\ninclude \"synthetic-responses.vcl\";\ninclude \"polyfill-service.vcl\";\n\n# Finally include the last bit of VCL, this _must_ be last!\ninclude \"fastly-boilerplate-end.vcl\";\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"6c18429d87876b963ed380c14138ef2055177caf","subject":"varnish example","message":"varnish example\n","repos":"TheWeatherChannel\/dClass,TheWeatherChannel\/dClass,wikimedia\/analytics-dclass,wikimedia\/analytics-dclass,ottomata\/dclass,ottomata\/dclass,ottomata\/dclass,wikimedia\/analytics-dclass,TheWeatherChannel\/dClass,wikimedia\/analytics-dclass,TheWeatherChannel\/dClass","old_file":"servers\/varnish\/dclass.vcl","new_file":"servers\/varnish\/dclass.vcl","new_contents":"import dclass;\n#import urlcode;\n\nbackend default {\n\t.host = \"localhost\";\n\t.port = \"80\";\n}\n\nsub vcl_init {\n\t# load openddr \n\tdclass.init_dclass(\"\/some\/path\/dClass\/dtrees\/openddr.dtree\");\n\t#dclass.init_dclass_p(\"\/some\/path\/OpenDDR\/1.0.0.0\/resources\",0);\n\n\t# load browser dtree\n\tdclass.init_dclass_p(\"\/some\/path\/dClass\/dtrees\/browser.dtree\",1);\n}\n\nsub vcl_recv {\n\t# ua override\n\tif(req.url ~ \"[^\\w]ua=\"){\n\t\tset req.http.user-agent = regsub(req.url,\"^.*[^\\w]ua=([^&]*).*\",\"\\1\");\n\t\t#set req.http.user-agent = urlcode.decode(regsub(req.url,\"^.*[^\\w]ua=([^&]*).*\",\"\\1\"));\n\t}\n\n\t# do the lookup\n\tset req.http.dclass_openddr = dclass.classify(req.http.user-agent);\n\t#set req.http.dclass_openddr = dclass.classify_p(req.http.user-agent,0);\n\tset req.http.dclass_browser = dclass.classify_p(req.http.user-agent,1);\n\n\t# set dclass_type\n\tset req.http.dclass_type = \"unknown\";\n\tif(dclass.get_field(\"is_tablet\") == \"true\"){\n\t\tset req.http.dclass_type = \"tablet\";\n\t} else if(dclass.get_field(\"is_wireless_device\") == \"true\" && dclass.get_field(\"inputDevices\") == \"touchscreen\"){\n\t\tset req.http.dclass_type = \"smartphone\";\n\t} else if(dclass.get_field(\"is_wireless_device\") == \"true\"){\n\t\tset req.http.dclass_type = \"phone\";\n\t} else if(dclass.get_field(\"is_crawler\") == \"true\"){\n\t\tset req.http.dclass_type = \"crawler\";\n\t} else if(dclass.get_field(\"is_desktop\") == \"true\"){\n\t\tset req.http.dclass_type = \"desktop\";\n\t}\n\n\t# \/uadiag commands\n\tif(req.url ~ \"^\/uadiag.js\"){\n\t\terror 849 \"uadiag.js\";\n\t} else if(req.url ~ \"^\/uadiag\"){\n\t\terror 848 \"uadiag\";\n\t}\n}\n\n# add dclass_type to the hash\nsub vcl_hash {\n\thash_data(req.url);\n\n\tif (req.http.host) {\n\t\thash_data(req.http.host);\n\t} else {\n\t\thash_data(server.ip);\n\t}\n\n\thash_data(req.http.dclass_type);\n\n\treturn (hash);\n}\n\nsub vcl_error {\n\t# plain text ua diag\n\tif(obj.status == 848){\n\t\tset obj.status = 200;\n\t\tset obj.http.Content-Type = \"text\/html; charset=utf-8\";\n\t\tsynthetic\n{\"<html><title>UADIAG<\/title>\n<body>\n<h1>UADIAG<\/h1>\n<pre>\nUser-Agent: \"} + req.http.User-Agent + {\"\n\ndClass version: \"} + dclass.get_version() + {\"\n\ndClass type: \"} + req.http.dclass_type + {\"\n\nOpenDDR id: \"} + req.http.dclass_openddr + {\"\nOpenDDR device: \"} + dclass.get_field(\"vendor\") + {\" \"} + dclass.get_field(\"model\") + {\"\nOpenDDR display: \"} + dclass.get_ifield(\"displayWidth\") + {\"x\"} + dclass.get_ifield(\"displayHeight\") + {\"\nOpenDDR input: \"} + dclass.get_field(\"inputDevices\") + {\"\nOpenDDR js: \"} + dclass.get_field(\"ajax_support_javascript\") + {\"\nOpenDDR wireless: \"} + dclass.get_field(\"is_wireless_device\") + {\"\nOpenDDR tablet: \"} + dclass.get_field(\"is_tablet\") + {\"\nOpenDDR crawler: \"} + dclass.get_field(\"is_crawler\") + {\"\nOpenDDR desktop: \"} + dclass.get_field(\"is_desktop\") + {\"\n\nbrowser id: \"} + req.http.dclass_browser + {\"\nbrowser name: \"} + dclass.get_field_p(\"browser\",1) + {\"\nbrowser ver: \"} + dclass.get_ifield_p(\"version\",1) + {\"\nbrowser os: \"} + dclass.get_field_p(\"os\",1) + {\"\n<\/pre>\n<\/body>\n<\/html>\"};\n\t\treturn(deliver);\n\t}\n\t# json ua diag with optional jsonp callback parameter\n\telse if(obj.status == 849){\n\t\tset obj.status = 200;\n\t\tset req.http.dclass_cb = \"\";\n\t\tset req.http.dclass_cbe = \"\";\n\t\tif(req.url ~ \"[^\\w]callback=\\w+\"){\n\t\t\tset obj.http.Content-Type = \"application\/javascript; charset=utf-8\";\n\t\t\tset req.http.dclass_cb = regsub(req.url,\"^.*[^\\w]callback=(\\w+).*\",\"\\1(\");\n\t\t\tset req.http.dclass_cbe = \");\";\n\t\t} else {\n\t\t\tset obj.http.Content-Type = \"application\/json; charset=utf-8\";\n\t\t}\n\t\tsynthetic\nreq.http.dclass_cb + {\"{\n\"user_agent\":\"\"} + req.http.User-Agent + {\"\",\n\"dclass_version\":\"\"} + dclass.get_version() + {\"\",\n\"openddr_id\":\"\"} + req.http.dclass_openddr + {\"\",\n\"openddr_type\":\"\"} + req.http.dclass_type + {\"\",\n\"openddr_device\":\"\"} + dclass.get_field(\"vendor\") + {\" \"} + dclass.get_field(\"model\") + {\"\",\n\"openddr_display\":\"\"} + dclass.get_ifield(\"displayWidth\") + {\"x\"} + dclass.get_ifield(\"displayHeight\") + {\"\",\n\"openddr_input\":\"\"} + dclass.get_field(\"inputDevices\") + {\"\",\n\"openddr_js\":\"\"} + dclass.get_field(\"ajax_support_javascript\") + {\"\",\n\"openddr_wireless\":\"\"} + dclass.get_field(\"is_wireless_device\") + {\"\",\n\"openddr_tablet\":\"\"} + dclass.get_field(\"is_tablet\") + {\"\",\n\"openddr_crawler\":\"\"} + dclass.get_field(\"is_crawler\") + {\"\",\n\"openddr_desktop\":\"\"} + dclass.get_field(\"is_desktop\") + {\"\",\n\"browser_id\":\"\"} + req.http.dclass_browser + {\"\",\n\"browser_name\":\"\"} + dclass.get_field_p(\"browser\",1) + {\"\",\n\"browser_ver\":\"\"} + dclass.get_ifield_p(\"version\",1) + {\"\",\n\"browser_os\":\"\"} + dclass.get_field_p(\"os\",1) + {\"\"\n}\"} + req.http.dclass_cbe;\n\t\treturn(deliver);\n\t}\n}\n\n","old_contents":"import dclass;\n\nbackend default {\n\t.host = \"localhost\";\n\t.port = \"80\";\n}\n\nsub vcl_init {\n\t# load openddr \n\tdclass.init_dclass(\"\/some\/path\/dClass\/dtrees\/openddr.dtree\");\n\t#dclass.init_dclass_p(\"\/some\/path\/OpenDDR\/1.0.0.0\/resources\",0);\n\n\t# load browser dtree\n\tdclass.init_dclass_p(\"\/some\/path\/dClass\/dtrees\/browser.dtree\",1);\n}\n\nsub vcl_recv {\n\t# ua override\n\tif(req.url ~ \"[^\\w]ua=\"){\n\t\t# TODO this needs to be URL decoded...\n\t\tset req.http.user-agent = regsub(req.url,\"^.*[^\\w]ua=([^&]*).*\",\"\\1\");\n\t}\n\n\t# do the lookup\n\tset req.http.dclass_openddr = dclass.classify(req.http.user-agent);\n\t#set req.http.dclass_openddr = dclass.classify_p(req.http.user-agent,0);\n\tset req.http.dclass_browser = dclass.classify_p(req.http.user-agent,1);\n\n\tif(req.url == \"\/uadiag\"){\n\t\terror 848 \"uadiag\";\n\t} else if(req.url ~ \"^\/uadiag.js\"){\n\t\terror 849 \"uadiag.js\";\n\t}\n}\n\nsub vcl_error {\n\t# plain text ua diag\n\tif(obj.status == 848){\n\t\tset obj.status = 200;\n\t\tset obj.http.Content-Type = \"text\/html; charset=utf-8\";\n\t\tsynthetic\n{\"<html><title>UADIAG<\/title>\n<body>\n<h1>UADIAG<\/h1>\n<pre>\nUser-Agent: \"} + req.http.User-Agent + {\"\n\ndClass version: \"} + dclass.get_version() + {\"\n\nOpenDDR id: \"} + req.http.dclass_openddr + {\"\nOpenDDR device: \"} + dclass.get_field(\"vendor\") + {\" \"} + dclass.get_field(\"model\") + {\"\nOpenDDR display: \"} + dclass.get_ifield(\"displayWidth\") + {\"x\"} + dclass.get_ifield(\"displayHeight\") + {\"\nOpenDDR js: \"} + dclass.get_field(\"ajax_support_javascript\") + {\"\nOpenDDR wireless: \"} + dclass.get_field(\"is_wireless_device\") + {\"\nOpenDDR tablet: \"} + dclass.get_field(\"is_tablet\") + {\"\nOpenDDR crawler: \"} + dclass.get_field(\"is_crawler\") + {\"\nOpenDDR desktop: \"} + dclass.get_field(\"is_desktop\") + {\"\n\nbrowser id: \"} + req.http.dclass_browser + {\"\nbrowser name: \"} + dclass.get_field_p(\"browser\",1) + {\"\nbrowser ver: \"} + dclass.get_ifield_p(\"version\",1) + {\"\nbrowser os: \"} + dclass.get_field_p(\"os\",1) + {\"\n<\/pre>\n<\/body>\n<\/html>\"};\n\t\treturn(deliver);\n\t}\n\t# json ua diag with optional jsonp callback parameter\n\telse if(obj.status == 849){\n\t\tset obj.status = 200;\n\t\tset req.http.dclass_cb = \"\";\n\t\tset req.http.dclass_cbe = \"\";\n\t\tif(req.url ~ \"[^\\w]callback=\\w+\"){\n\t\t\tset obj.http.Content-Type = \"application\/javascript; charset=utf-8\";\n\t\t\tset req.http.dclass_cb = regsub(req.url,\"^.*[^\\w]callback=(\\w+).*\",\"\\1(\");\n\t\t\tset req.http.dclass_cbe = \");\";\n\t\t} else {\n\t\t\tset obj.http.Content-Type = \"application\/json; charset=utf-8\";\n\t\t}\n\t\tsynthetic\nreq.http.dclass_cb + {\"{\n\"user_agent\":\"\"} + req.http.User-Agent + {\"\",\n\"dclass_version\":\"\"} + dclass.get_version() + {\"\",\n\"openddr_id\":\"\"} + req.http.dclass_openddr + {\"\",\n\"openddr_device\":\"\"} + dclass.get_field(\"vendor\") + {\" \"} + dclass.get_field(\"model\") + {\"\",\n\"openddr_display\":\"\"} + dclass.get_ifield(\"displayWidth\") + {\"x\"} + dclass.get_ifield(\"displayHeight\") + {\"\",\n\"openddr_js\":\"\"} + dclass.get_field(\"ajax_support_javascript\") + {\"\",\n\"openddr_wireless\":\"\"} + dclass.get_field(\"is_wireless_device\") + {\"\",\n\"openddr_tablet\":\"\"} + dclass.get_field(\"is_tablet\") + {\"\",\n\"openddr_crawler\":\"\"} + dclass.get_field(\"is_crawler\") + {\"\",\n\"openddr_desktop\":\"\"} + dclass.get_field(\"is_desktop\") + {\"\",\n\"browser_id\":\"\"} + req.http.dclass_browser + {\"\",\n\"browser_name\":\"\"} + dclass.get_field_p(\"browser\",1) + {\"\",\n\"browser_ver\":\"\"} + dclass.get_ifield_p(\"version\",1) + {\"\",\n\"browser_os\":\"\"} + dclass.get_field_p(\"os\",1) + {\"\"\n}\"} + req.http.dclass_cbe;\n\t\treturn(deliver);\n\t}\n}\n\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"98ef3f44ac0f35a1ca5b04f6488ebbbaadfffb86","subject":"This is unnecessary as it's never going to be used","message":"This is unnecessary as it's never going to be used\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets\/error.vcl","new_file":"etc\/vcl_snippets\/error.vcl","new_contents":" # workaround for possible security issue\n if (req.url ~ \"^\\s\") {\n set obj.status = 400;\n set obj.response = \"Malformed request\";\n synthetic \"\";\n return (deliver);\n }\n\n \/* handle 503s *\/\n if (obj.status >= 500 && obj.status < 600) {\n\n \/* deliver stale object if it is available *\/\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n # error 200\n if (obj.status == 200) {\n return (deliver);\n }\n","old_contents":" # workaround for possible security issue\n if (req.url ~ \"^\\s\") {\n set obj.status = 400;\n set obj.response = \"Malformed request\";\n synthetic \"\";\n return (deliver);\n }\n\n \/* handle 503s *\/\n if (obj.status >= 500 && obj.status < 600) {\n\n \/* deliver stale object if it is available *\/\n if (stale.exists) {\n return(deliver_stale);\n }\n\n \/* otherwise, return a synthetic *\/\n \/* uncomment below and include your HTML response here *\/\n \/* synthetic {\"<!DOCTYPE html><html>Trouble connecting to origin<\/html>\"};\n return(deliver); *\/\n }\n\n # error 200\n if (obj.status == 200) {\n return (deliver);\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"03ccecc4e8c46d7dce4337f5a16ea5c63c65e9bb","subject":"Reduce variance in QA\/prod code paths (#1328)","message":"Reduce variance in QA\/prod code paths (#1328)\n\n* Reduce variance in QA\/prod code paths\r\n\r\n* Deliver stale on error from origin\r\n\r\n* Update main.vcl\r\n\r\n* Update main.vcl\r\n\r\n* Update main.vcl\r\n\r\n* Update main.vcl\r\n\r\n* Remove statement which would not change to other backend if current one is unhealthy\r\n","repos":"JakeChampion\/polyfill-service,JakeChampion\/polyfill-service","old_file":"vcl\/main.vcl","new_file":"vcl\/main.vcl","new_contents":"import boltsort;\n\ntable origin_hosts {\n \"us-prod\": \"ft-polyfill-service-us.herokuapp.com\",\n \"us-qa\": \"ft-polyfill-service-us-qa.herokuapp.com\",\n \"eu-prod\": \"ft-polyfill-service.herokuapp.com\",\n \"eu-qa\": \"ft-polyfill-service-qa.herokuapp.com\"\n}\n\nsub vcl_recv {\n\n\tdeclare local var.env STRING;\n\tdeclare local var.geo STRING;\n\tdeclare local var.server STRING;\n\n#FASTLY recv\n\n\t# Enable API key authentication for URL purge requests\n\tif ( req.request == \"FASTLYPURGE\" ) {\n\t\tset req.http.Fastly-Purge-Requires-Auth = \"1\";\n\t}\n\n\tif (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n\t\treturn(pass);\n\t}\n\n\tif (req.http.Host ~ \"polyfills.io\") {\n\t\t# Do the canonicalise check before the SSL check to avoid a double redirect\n\t\terror 751 \"Canonicalise\";\n\t}\n\n\tif (!req.http.Fastly-SSL) {\n\t\t# 801 is a special error code that Fastly uses to Force SSL on the request\n\t\terror 801 \"Redirect to prod HTTPS\";\n\t}\n\n\tif (req.url ~ \"^\/v2\/(polyfill\\.|recordRumData)\" && req.url !~ \"[\\?\\&]ua=\") {\n\t\tset req.http.X-Orig-URL = req.url;\n\t\tset req.url = \"\/v2\/normalizeUa?ua=\" urlencode(req.http.User-Agent);\n\t}\n\n\tif (req.url ~ \"^\/v2\/recordRumData\" && req.http.Normalized-User-Agent) {\n\t\tset req.http.Log = regsub(req.url, \"^.*?\\?(.*)$\", \"\\1\") \"&ip=\" client.ip \"&refer_domain=\" regsub(req.http.Referer, \"^(https?\\:\\\/\\\/)?(www\\.)?(.+?)(\\:\\d+)?([\\\/\\?].*)?$\", \"\\3\") \"&country=\" geoip.country_code \"&data_center=\" if(req.http.Cookie:FastlyDC, req.http.Cookie:FastlyDC, server.datacenter);\n\t\terror 204 \"No Content\";\n\t}\n\n\tset req.url = boltsort.sort(req.url);\n\n\tif (req.restarts == 0) {\n\t\tset req.http.X-Original-Host = req.http.Host;\n\n\t\t# Set origin geography - US servers or EU servers\n\t\tset var.geo = if (client.geo.continent_code ~ \"(NA|SA|OC|AS)\", \"us\", \"eu\");\n\t\tif (var.geo == \"us\") {\n\t\t\tset req.backend = origami_polyfill_service_us;\n\t\t} else {\n\t\t\tset req.backend = origami_polyfill_service_eu;\n\t\t}\n\t\t\n\t\t# Swap to the other geography if the primary one is down\n\t\tif (!req.backend.healthy) {\n\t\t\tset var.geo = if (var.geo == \"us\", \"eu\", \"us\");\n\n\t\t\tif (var.geo == \"us\") {\n\t\t\t\tset req.backend = origami_polyfill_service_us;\n\t\t\t} else {\n\t\t\t\tset req.backend = origami_polyfill_service_eu;\n\t\t\t}\n\t\t}\n\t\t\n\t\t# Set origin environment - by default match VCL environment, but allow override via header for testing\n\t\tset var.env = if (req.http.X-Origin-Env, req.http.X-Origin-Env, if(req.http.Host == \"qa.polyfill.io\", \"qa\", \"prod\"));\n\t\tset var.server = var.geo \"-\" var.env;\n\t\tset req.http.Host = table.lookup(origin_hosts, var.server);\n\t}\n\n\t# https:\/\/community.fastly.com\/t\/brotli-compression-support\/578\/6\n\tif (req.http.Fastly-Orig-Accept-Encoding) {\n\t\tif (req.http.User-Agent ~ \"MSIE 6\") {\n\t\t\t# For that 0.3% of stubborn users out there\n\t\t\tunset req.http.Accept-Encoding;\n\t\t} elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"br\") {\n\t\t\tset req.http.Accept-Encoding = \"br\";\n\t\t} elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"gzip\") {\n\t\t\tset req.http.Accept-Encoding = \"gzip\";\n\t\t} else {\n\t\t\tunset req.http.Accept-Encoding;\n\t\t}\n\t}\n\n\treturn(lookup);\n}\n\nsub vcl_fetch {\n\n\t# Deliver stale if possible when unexpected errors are received from origin\n\t# This includes 404s because Heroku will deliver a 404 if you hit the 'no app\n\t# found' page.\n\tif ((beresp.status >= 500 && beresp.status < 600) || beresp.status == 404) {\n\t\tif (stale.exists) {\n\t\t\treturn(deliver_stale);\n\t\t}\n\t}\n\n#FASTLY fetch\n\n\treturn(deliver);\n}\n\nsub vcl_deliver {\n#FASTLY deliver\n\n\t# If the response is to a normalise request and there's a parked \"original request\", use the normalised UA response to modify the original request and restart it\n\tif (req.url ~ \"^\/v\\d\/normalizeUa\" && resp.status == 200 && req.http.X-Orig-URL ~ \"^\/v2\/(polyfill\\.|recordRumData)\") {\n\t\tset req.http.Fastly-force-Shield = \"1\";\n\t\tset req.http.Normalized-User-Agent = resp.http.Normalized-User-Agent;\n\t\tif (req.http.X-Orig-URL ~ \"\\?\") {\n\t\t\tset req.url = req.http.X-Orig-URL \"&ua=\" resp.http.Normalized-User-Agent;\n\t\t} else {\n\t\t\tset req.url = req.http.X-Orig-URL \"?ua=\" resp.http.Normalized-User-Agent;\n\t\t}\n\t\trestart;\n\n\t# If the original request didn't specify a UA override, and we added one when the request was sent to the backend, the backend won't have included a Vary:user-agent header (correctly) but we need to add one\n\t} else if (req.url ~ \"^\/v\\d\/polyfill\\..*[\\?\\&]ua=\" && req.http.X-Orig-URL && req.http.X-Orig-URL !~ \"[\\?\\&]ua=\") {\n\t\tadd resp.http.Vary = \"User-Agent\";\n\t}\n\n\tif (req.url ~ \"[\\&\\?]rum=1\") {\n\t\tadd resp.http.Set-Cookie = \"FastlyDC=\" server.datacenter \"; Path=\/; HttpOnly; max-age=60\";\n\t}\n\n\tif (req.http.Fastly-Debug) {\n\t\tset resp.http.Debug-Host = req.http.Host;\n\t\tset resp.http.Debug-X-Original-Host = req.http.X-Original-Host;\n\t}\n\t\n\tset resp.http.Age = \"0\";\n\n\treturn(deliver);\n}\n\nsub vcl_error {\n#FASTLY error\n\n\t# Redirect to canonical prod\/qa origins\n\tif (obj.status == 751) {\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\tset obj.http.Location = \"https:\/\/polyfill.io\" req.url;\n\t\tsynthetic {\"\"};\n\t\treturn (deliver);\n\t}\n}\n","old_contents":"import boltsort;\n\nsub vcl_recv {\n#FASTLY recv\n\n\t# Enable API key authentication for URL purge requests\n\tif ( req.request == \"FASTLYPURGE\" ) {\n\t\tset req.http.Fastly-Purge-Requires-Auth = \"1\";\n\t}\n\n\tif (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n\t\treturn(pass);\n\t}\n\n\tif (req.http.Host ~ \"polyfills.io\") {\n\t\t# Do the canonicalise check before the SSL check to avoid a double redirect\n\t\terror 751 \"Canonicalise\";\n\t}\n\n\tif (!req.http.Fastly-SSL) {\n\t\t# 801 is a special error code that Fastly uses to Force SSL on the request\n\t\terror 801 \"Redirect to prod HTTPS\";\n\t}\n\n\tif (req.url ~ \"^\/v2\/(polyfill\\.|recordRumData)\" && req.url !~ \"[\\?\\&]ua=\") {\n\t\tset req.http.X-Orig-URL = req.url;\n\t\tset req.url = \"\/v2\/normalizeUa?ua=\" urlencode(req.http.User-Agent);\n\t}\n\n\tif (req.url ~ \"^\/v2\/recordRumData\" && req.http.Normalized-User-Agent) {\n\t\tset req.http.Log = regsub(req.url, \"^.*?\\?(.*)$\", \"\\1\") \"&ip=\" client.ip \"&refer_domain=\" regsub(req.http.Referer, \"^(https?\\:\\\/\\\/)?(www\\.)?(.+?)(\\:\\d+)?([\\\/\\?].*)?$\", \"\\3\") \"&country=\" geoip.country_code \"&data_center=\" if(req.http.Cookie:FastlyDC, req.http.Cookie:FastlyDC, server.datacenter);\n\t\terror 204 \"No Content\";\n\t}\n\n\tset req.url = boltsort.sort(req.url);\n\n\tif (req.restarts == 0) {\n\t\tset req.http.X-Original-Host = req.http.Host;\n\n\t\tif (req.http.Host == \"qa.polyfill.io\") {\n\t\t\tif (req.http.X-Geoip-Continent ~ \"(NA|SA|OC|AS)\") {\n\t\t\t\tset req.backend = origami_polyfill_service_us;\n\t\t\t\tset req.http.Host = \"ft-polyfill-service-us-qa.herokuapp.com\";\n\n\t\t\t\tif (!req.backend.healthy) {\n\t\t\t\t\tset req.backend = origami_polyfill_service_eu;\n\t\t\t\t\tset req.http.Host = \"ft-polyfill-service-qa.herokuapp.com\";\n\t\t\t\t}\n\n\t\t\t} else {\n\t\t\t\tset req.backend = origami_polyfill_service_eu;\n\t\t\t\tset req.http.Host = \"ft-polyfill-service-qa.herokuapp.com\";\n\n\t\t\t\tif (!req.backend.healthy) {\n\t\t\t\t\tset req.backend = origami_polyfill_service_us;\n\t\t\t\t\tset req.http.Host = \"ft-polyfill-service-us-qa.herokuapp.com\";\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tif (req.http.X-Geoip-Continent ~ \"(NA|SA|OC|AS)\") {\n\t\t\t\tset req.backend = origami_polyfill_service_us;\n\t\t\t\tset req.http.Host = \"ft-polyfill-service-us.herokuapp.com\";\n\n\t\t\t\tif (!req.backend.healthy) {\n\t\t\t\t\tset req.backend = origami_polyfill_service_eu;\n\t\t\t\t\tset req.http.Host = \"ft-polyfill-service.herokuapp.com\";\n\t\t\t\t}\n\n\t\t\t} else {\n\t\t\t\tset req.backend = origami_polyfill_service_eu;\n\t\t\t\tset req.http.Host = \"ft-polyfill-service.herokuapp.com\";\n\n\t\t\t\tif (!req.backend.healthy) {\n\t\t\t\t\tset req.backend = origami_polyfill_service_us;\n\t\t\t\t\tset req.http.Host = \"ft-polyfill-service-us.herokuapp.com\";\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t# https:\/\/community.fastly.com\/t\/brotli-compression-support\/578\/6\n\tif (req.http.Fastly-Orig-Accept-Encoding) {\n\t\tif (req.http.User-Agent ~ \"MSIE 6\") {\n\t\t\t# For that 0.3% of stubborn users out there\n\t\t\tunset req.http.Accept-Encoding;\n\t\t} elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"br\") {\n\t\t\tset req.http.Accept-Encoding = \"br\";\n\t\t} elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"gzip\") {\n\t\t\tset req.http.Accept-Encoding = \"gzip\";\n\t\t} else {\n\t\t\tunset req.http.Accept-Encoding;\n\t\t}\n\t}\n\n\treturn(lookup);\n}\n\nsub vcl_deliver {\n#FASTLY deliver\n\n\t# If the response is to a normalise request and there's a parked \"original request\", use the normalised UA response to modify the original request and restart it\n\tif (req.url ~ \"^\/v\\d\/normalizeUa\" && resp.status == 200 && req.http.X-Orig-URL ~ \"^\/v2\/(polyfill\\.|recordRumData)\") {\n\t\tset req.http.Fastly-force-Shield = \"1\";\n\t\tset req.http.Normalized-User-Agent = resp.http.Normalized-User-Agent;\n\t\tif (req.http.X-Orig-URL ~ \"\\?\") {\n\t\t\tset req.url = req.http.X-Orig-URL \"&ua=\" resp.http.Normalized-User-Agent;\n\t\t} else {\n\t\t\tset req.url = req.http.X-Orig-URL \"?ua=\" resp.http.Normalized-User-Agent;\n\t\t}\n\t\trestart;\n\n\t# If the original request didn't specify a UA override, and we added one when the request was sent to the backend, the backend won't have included a Vary:user-agent header (correctly) but we need to add one\n\t} else if (req.url ~ \"^\/v\\d\/polyfill\\..*[\\?\\&]ua=\" && req.http.X-Orig-URL && req.http.X-Orig-URL !~ \"[\\?\\&]ua=\") {\n\t\tadd resp.http.Vary = \"User-Agent\";\n\t}\n\n\tif (req.url ~ \"[\\&\\?]rum=1\") {\n\t\tadd resp.http.Set-Cookie = \"FastlyDC=\" server.datacenter \"; Path=\/; HttpOnly; max-age=60\";\n\t}\n\n\tif (req.http.Fastly-Debug) {\n\t\tset resp.http.Debug-Host = req.http.Host;\n\t\tset resp.http.Debug-X-Original-Host = req.http.X-Original-Host;\n\t}\n\t\n\tset resp.http.Age = \"0\";\n\n\treturn(deliver);\n}\n\nsub vcl_error {\n#FASTLY error\n\n\t# Redirect to canonical prod\/qa origins\n\tif (obj.status == 751) {\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\tset obj.http.Location = \"https:\/\/polyfill.io\" req.url;\n\t\tsynthetic {\"\"};\n\t\treturn (deliver);\n\t}\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"70ce39f8dc808dd5f5d6eebd60dd031658521f69","subject":"enable on-the-fly gzip encoding out-of-the-box","message":"enable on-the-fly gzip encoding out-of-the-box\n","repos":"NITEMAN\/varnish-bites,NITEMAN\/Varnish_VCL_samps-hacks","old_file":"varnish3\/drupal-base.vcl","new_file":"varnish3\/drupal-base.vcl","new_contents":"\/* Varnish 3 example config for Drupal 7 \/ Pressflow 6 & 7 *\/\n# Original source: https:\/\/github.com\/NITEMAN\/varnish-bites\/varnish4\/drupal-base.vcl\n# Copyright (c) 2015 Pedro Gonz\u00e1lez Serrano and individual contributors.\n# MIT License\n\n# Intended to be used both in simple production environments and with learning\/teaching purposes.\n# Loosely based on http:\/\/www.lullabot.com\/sites\/default\/files\/default_varnish3.vcl_.txt\n\n\/* Backend probes \/ healthchecks *\/\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#backend-probes\nprobe basic {\n \/* Only test that backend's IP serves content for '\/' *\/\n # This might be a too heavy probe\n # .url = \"\/\";\n \/* Only test that backend's IP has apache working *\/\n # Nginx would fail this probe with a default config\n .request =\n \"OPTIONS * HTTP\/1.1\"\n \"Host: *\"\n \"Connection: close\";\n .interval = 10s;\n .timeout = 2s;\n .window = 8;\n .threshold = 6;\n}\n\n\n\/* Backend definitions.*\/\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#backend-declarations\nbackend default {\n \/* Default backend on the same machine. WARNING: timeouts could be not big enought for certain POST request *\/\n .host = \"127.0.0.1\";\n .port = \"8008\";\n .connect_timeout = 60s;\n .first_byte_timeout = 60s;\n .between_bytes_timeout = 60s;\n .probe = basic;\n}\n\n\n\/* Directors. *\/\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#directors\n# Empty in simple configs\n\n\n\/* Access Control Lists *\/\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#acls\nacl purge_ban {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use '\"localhost\";' instead\n}\nacl allowed_monitors {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n}\nacl own_proxys {\n \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n}\n\n\n\/* Custom routines *\/\n# Empty in simple configs.\n# We can name subs with no restrictions but as a task can need several chunks of code in diferent states,\n# it's a good idea to identify what main sub will call each with a suffix.\n# \/* Example 301 client redirection removing \"www\" prefix from request *\/\n# sub perm_redirections_recv {\n# if ( req.http.host ~ \"^www.*$\" ) {\n# error 751 \"http:\/\/\" + regsub(req.http.host, \"^www\\.\", \"\") + req.url;\n# }\n# }\n# sub perm_redirections_error {\n# if (obj.status == 751) {\n# \/* Get new URL from the response *\/\n# set obj.http.Location = obj.response;\n# \/* Set HTTP 301 for permanent redirect *\/\n# set obj.status = 301;\n# return(deliver);\n# }\n# }\n\n\n\/* VCL logigc overrides *\/\n# Note that the built-in logic will be appended to our code if no return is performed before.\n# Built-in logic is included commented out right after our's for reference purposes in that cases.\n# See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleDefault\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#subroutines\n\n# vcl_recv: Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use.\nsub vcl_recv {\n \/* 0th: general bypass, general return & authorization checks *\/\n # Empty in simple configs.\n # Useful for debugging we can pipe or pass the request to default backend here to bypass completely Varnish.\n # return (pipe);\n # return (pass);\n # We can also return here a 200 Ok for network performance benchmarking.\n # error 200 \"Ok\";\n # Finally we can perform basic HTTP authentification here by example.\n # See http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* 1st: Check for Varnish special requests *\/ \n # Purge logic.\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/purging.html#http-purges\n # See https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if (req.request == \"PURGE\") {\n if (!client.ip ~ purge_ban) {\n error 405 \"Not allowed.\";\n }\n return (lookup);\n }\n # Ban logic. See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/purging.html#bans\n if (req.request == \"BAN\") {\n if (!client.ip ~ purge_ban) {\n error 405 \"Not allowed.\";\n }\n ban(\"req.http.host == \" + req.http.host +\n \"&& req.url == \" + req.url); \n error 200 \"Ban added\";\n }\n # Custom response implementation example in order to check that Varnish is working properly.\n # This is usefull for automatic monitoring with monit or when Varnish is behind another proxies like HAProxy.\n if ( ( req.http.host == \"monitor.server.health\"\n || req.http.host == \"health.varnish\" )\n && client.ip ~ allowed_monitors\n && ( req.request == \"OPTIONS\" || req.request == \"GET\" )\n ) {\n error 200 \"Ok\";\n }\n\n \/* 2nd: Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_recv;\n # Here we can also enforce SSL when Varnish run behind some SSL termination point.\n\n \/* 3rd: Time for backend choice *\/\n # Empty in simple configs.\n\n \/* 4th: Set custom headers for backend like X-Forwarded-For (copied from built-in logic) *\/\n if ( req.restarts == 0 ) {\n \/* See also vcl_pipe section *\/\n if ( ! client.ip ~ own_proxys ) {\n if ( req.http.x-forwarded-for ) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n }\n\n \/* 5th: Bypass breakpoint 1 *\/\n # Useful for debugging we can now pipe or pass the request to backend with headers setted.\n # return (pipe);\n # return (pass);\n\n \/* 6th: Decide if we should deal with a request (mostly copied from built-in logic) *\/\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n\n \/* 7th: Access control for some URLs by ACL *\/\n # Empty in simple configs.\n # By example denial some URLs depending on client-ip, we'll need to define corresponding ACL 'internal'.\n # if (req.url ~ \"^\/(cron|install)\\.php$\" && !client.ip ~ internal) {\n # # Have Varnish throw the error directly.\n # error 403 \"Forbidden.\";\n # # Use a custom error page that you've defined in Drupal at the path \"404\".\n # # set req.url = \"\/403\";\n # }\n\n \/* 8th: Custom exceptions *\/\n # Host exception example:\n # if (req.http.host == \"ejemplo.exception.com\") {\n # return (pass);\n # }\n # Drupal exceptions, edit if we want to cache some AJAX\/AHAH request.\n # Add here filters for never cache URLs such as Payment Gateway's callbacks\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/ooyala\/ping$\" ||\n req.url ~ \"^\/admin\/build\/features\" ||\n req.url ~ \"^\/info\/.*$\" ||\n req.url ~ \"^\/flag\/.*$\" ||\n req.url ~ \"^.*\/ajax\/.*$\" ||\n req.url ~ \"^.*\/ahah\/.*$\") {\n \/* Do not cache these paths *\/\n return (pass);\n }\n # Pipe these paths directly to backend for streaming.\n if (req.url ~ \"^\/admin\/content\/backup_migrate\/export\") {\n return (pipe);\n }\n if (req.url ~ \"^\/system\/files\") {\n return (pipe);\n }\n\n \/* 9th: Enable grace mode *\/\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/handling_misbehaving_servers.html#grace-mode\n if (! req.backend.healthy) {\n \/* Use a longer grace period if all backends are down *\/\n set req.grace = 1h;\n \/* Use anonymous, cached pages if all backends are down. *\/\n unset req.http.Cookie;\n # TO-DO: Add sick marker\n } else {\n \/* Allow the backend to serve up stale content if it is responding slowly. *\/\n set req.grace = 30s;\n }\n\n \/* 10th: Deal with compression and the Accept-Encoding header *\/\n # Althought Varnish 3 handles gziped content itself by default, just to be sure we want to \n # remove Accept-Encoding for some compressed formats.\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/phk\/gzip.html#what-does-http-gzip-support-do\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/varnishd.html?highlight=http_gzip_support\n # See (for older configs) https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleNormalizeAcceptEncoding\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|mp4|flv|zip|rar)$\") {\n \/* Already compressed formats, no sense trying to compress again *\/\n remove req.http.Accept-Encoding;\n }\n }\n\n \/* 11th: Another header manipulation *\/\n # Empty in simple configs.\n # We could add here a custom header grouping User-agent families.\n\n \/* 12th: Cookie removal *\/\n # Always cache the following static file types for all users. \n # Use with care if we control certain downloads depending on cookies. \n # Be carefull also if appending .htm[l] via Drupal's clean URLs.\n if ( req.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n && req.url !~ \"\/system\/storage\/serve\"\n ) {\n unset req.http.Cookie;\n }\n # Remove all cookies that backend doesn't need to know about.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRemovingSomeCookies\n if (req.http.Cookie) {\n \/* Warning: Not a pretty solution *\/\n \/* Prefix header containing cookies with ';' *\/\n set req.http.Cookie = \";\" + req.http.Cookie;\n \/* Remove any spaces after ';' in header containing cookies *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n \/* Prefix cookies we want to preserve with one space *\/\n \/* 'S{1,2}ESS[a-z0-9]+' is the regular expression matching a Drupal session cookie ({1,2} added for HTTPS support) *\/\n \/* 'NO_CACHE' is usually set after a POST request to make sure issuing user see the results of his post *\/\n \/* 'OATMEAL' & 'CHOCOLATECHIP' are special cookies used by Drupal's Bakery module to provide Single Sign On *\/\n \/* Keep in mind we should add here any cookie that should reach the backend such as splahs avoiding cookies *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \";(S{1,2}ESS[a-z0-9]+|NO_CACHE|OATMEAL|CHOCOLATECHIP)=\", \"; \\1=\");\n \/* Remove from the header any single Cookie not prefixed with a space until next ';' separator *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n \/* Remove any '; ' at the start or the end of the header *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n\n if (req.http.Cookie == \"\") {\n \/* If there are no remaining cookies, remove the cookie header. *\/\n unset req.http.Cookie;\n }\n }\n\n \/* 13th: Session cookie & special cookies bypass caching stage *\/\n # As we might want to cache some requests, hashed with its cookies, \n # we don't simply pass when some cookies remain present at this point.\n # Instead we look for request that must be passed due to the cookie header.\n if (req.http.Cookie ~ \"SESS\" ||\n req.http.Cookie ~ \"SSESS\" ||\n req.http.Cookie ~ \"NO_CACHE\" ||\n req.http.Cookie ~ \"OATMEAL\" ||\n req.http.Cookie ~ \"CHOCOLATECHIP\") {\n return (pass);\n }\n\n \/* 14th: Bypass breakpoint 2 *\/\n # Useful for debugging we can now pipe or pass the request to backend to bypass cache.\n # return (pipe);\n # return (pass);\n\n \/* 15th: Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning a lookup.\n return (lookup);\n}\n\n# vcl_pipe: Called upon entering pipe mode.\n# In this mode, the request is passed on to the backend, \n# and any further data from either client or backend is passed on unaltered until either end closes the connection.\nsub vcl_pipe {\n \/* Prevent connection re-using for piped requests *\/\n # Note that only the first request to the backend will have X-Forwarded-For set.\n # As we use X-Forwarded-For and want to have it set for all requests, \n # we have to make sure connection won't be reused after the request.\n # It is not set by default as it might break some broken web applications, like IIS with NTLM authentication.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExamplePipe\n # TO-DO: make sure this is compatible with websockets piping,\n # reference https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/websockets.html\n set bereq.http.connection = \"close\";\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this point.\n return (pipe);\n}\n\n# vcl_pass: Called upon entering pass mode. \n# In this mode, the request is passed on to the backend, and the backend's response is passed on to the client, \n# but is not entered into the cache.\n# Subsequent requests submitted over the same client connection are handled normally.\n# sub vcl_pass {\n# return (pass);\n# }\n\n# vcl_hash: You may call hash_data() on the data you would like to add to the hash.\n# Hash is used by Varnish to uniquely identify objects.\nsub vcl_hash {\n \/* Hash cookie data *\/\n # As requests with same URL and host can produce diferent results when issued with different cookies,\n # we need to store items hashed with the associated cookies. Note that cookies are already sanitized when we reach this point.\n if (req.http.Cookie) {\n \/* Include cookie in cache hash *\/\n hash_data(req.http.Cookie);\n }\n\n \/* Custom header hashing *\/\n # Empty in simple configs.\n # Example for caching differents object versions by device previously detected (when static content could also vary):\n # if (req.http.X-UA-Device) {\n # hash_data(req.http.X-UA-Device);\n # }\n # Example for caching diferent object versions by X-Forwarded-Proto, trying to be smart about what kind of request\n # could generate diffetent responses.\n if ( req.http.X-Forwarded-Proto\n && req.url !~ \"(?i)\\.(png|gif|jpeg|jpg|ico|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\") {\n hash_data(req.http.X-Forwarded-Proto);\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (hash);\n# }\n\n# vcl_hit: Called after a cache lookup if the requested document was found in the cache.\nsub vcl_hit {\n \/* Check for Varnish special requests *\/ \n # Purge logic.\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/purging.html#http-purges\n # See https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged.\";\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hit {\n# return (deliver);\n# }\n\n# vcl_miss: Called after a cache lookup if the requested document was not found in the cache.\n# Its purpose is to decide whether or not to attempt to retrieve the document from the backend, and which backend to use.\nsub vcl_miss {\n \/* Check for Varnish special requests *\/ \n # Purge logic.\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/purging.html#http-purges\n # See https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged.\";\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_miss {\n# return (fetch);\n# }\n\n# vcl_fetch: Called after a document has been successfully retrieved from the backend.\nsub vcl_fetch {\n \/* Caching exceptions *\/\n # Varnish will cache objects with response codes: 200, 203, 300, 301, 302, 307, 404 & 410.\n # See https:\/\/www.varnish-software.com\/static\/book\/VCL_Basics.html#the-initial-value-of-beresp-ttl\n # Drupal's Imagecache module can return a 307 redirection to the requested url itself and, depending on Drupal's cache settings,\n # this could lead to a redirection loop being cached for a long time but also we want Varnish to shield a little the backend.\n # See http:\/\/drupal.org\/node\/1248010\n # See http:\/\/drupal.org\/node\/310656\n if (beresp.status == 307 &&\n \/* TO-DO: verify that this work better than 'req.url ~ \"imagecache\"' *\/\n beresp.http.Location == req.url &&\n beresp.ttl > 5s) {\n set beresp.ttl = 5s;\n set beresp.http.cache-control = \"max-age=5\";\n }\n\n \/* Enable grace mode. Related with our 9th stage on vcl_recv *\/\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/handling_misbehaving_servers.html#grace-mode\n set beresp.grace = 1h;\n\n \/* Enable saint mode. Related with our 9th stage on vcl_recv *\/\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/handling_misbehaving_servers.html#saint-mode\n if (beresp.status == 500) {\n set beresp.saintmode = 20s;\n # TO-DO: consider not restarting POST requests as seen on https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleSaintMode\n return(restart);\n }\n\n \/* Strip cookies from the following static file types for all users. Related with our 12th stage on vcl_recv *\/\n if (req.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\") {\n unset beresp.http.set-cookie;\n }\n\n \/* Gzip response *\/\n # Empty in simple configs\n # Use Varnish to Gzip respone, if suitable, before storing it on cache\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/phk\/gzip.html\n if (! beresp.http.Content-Encoding &&\n (beresp.http.content-type ~ \"text\" ||\n beresp.http.content-type ~ \"application\/x-javascript\" ||\n beresp.http.content-type ~ \"application\/javascript\" ||\n beresp.http.content-type ~ \"application\/rss+xml\" ||\n beresp.http.content-type ~ \"application\/xml\" ||\n beresp.http.content-type ~ \"Application\/JSON\")\n ) {\n set beresp.do_gzip = true;\n if ( beresp.http.Vary ) {\n if ( ! beresp.http.Vary ~ \"Accept-Encoding\" ) {\n set beresp.http.Vary = beresp.http.Vary + \",Accept-Encoding\";\n }\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # We can add the name of the backend that has processed the request:\n # set beresp.http.X-Backend = beresp.backend.name;\n # We can use a header to tell if the object was gziped by Varnish\n # if (beresp.do_gzip) {\n # set beresp.http.X-Varnish-Gzipped = \"yes\";\n # } else {\n # set beresp.http.X-Varnish-Gizipped = \"no\";\n # }\n # We can also add headers informing whether the object is cacheable or not and why.\n # https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Varnish3.0\n if (beresp.ttl <= 0s) {\n \/* Varnish determined the object was not cacheable *\/\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n } elsif (req.http.Cookie ~ \"(SESS|SSESS|NO_CACHE|OATMEAL|CHOCOLATECHIP)\") {\n \/* We don't wish to cache content for logged in users or with certain cookies. Related with our 9th stage on vcl_recv *\/\n set beresp.http.X-Cacheable = \"NO:Cookies\";\n # return(hit_for_pass);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n \/* We are respecting the Cache-Control=private header from the backend *\/\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n # return(hit_for_pass);\n } else {\n \/* Varnish determined the object was cacheable *\/\n set beresp.http.X-Cacheable = \"YES\";\n }\n\n \/* Further header manipulation *\/\n # Empty in simple configs.\n # We can also unset some headers to prevent information disclosure and save some cache space\n # unset beresp.http.Server;\n # unset beresp.http.X-Powered-By;\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_fetch {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Vary == \"*\") {\n# \/*\n# * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# *\/\n# set beresp.ttl = 120 s;\n# return (hit_for_pass);\n# }\n# return (deliver);\n# }\n\n# vcl_deliver: Called before an object is delivered to the client\nsub vcl_deliver {\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # Add whether the object is a cache hit or miss and the number of hits for the object.\n # https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Addingaheaderindicatinghitmiss\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n set resp.http.X-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Cache = \"MISS\";\n \/* Show the results of cookie sanitization *\/\n set resp.http.X-Cookie = req.http.Cookie;\n }\n # TO-DO: Add sick marker\n # Restart count\n if ( req.restarts > 0) {\n set resp.http.X-Restarts = req.restarts;\n }\n # Add the Varnish server hostname\n set resp.http.X-Varnish-Server = server.hostname;\n # If we have setted a custom header with device family detected we can show it:\n # if (req.http.X-UA-Device) {\n # set resp.http.X-UA-Device = req.http.X-UA-Device;\n # }\n # If we have recived a custom header with the protocol in the request we can show it:\n # if (req.http.X-Forwarded-Proto) {\n # set resp.http.X-Forwarded-Proto = req.http.X-Forwarded-Proto;\n # }\n\n \/* Vary header manipulation *\/\n # Empty in simple configs.\n # By example, if we are storing & serving diferent objects depending on User-Agent header we must set the correct Vary header:\n # if (resp.http.Vary) {\n # set resp.http.Vary = resp.http.Vary + \",User-Agent\";\n # } else {\n # set resp.http.Vary = \"User-Agent\";\n # }\n\n \/* Fake headers *\/\n # Empty in simple configs\n # We can fake server headers here, by example:\n # set resp.http.Server = \"Deep thought\";\n # set resp.http.X-Powered-By = \"BOFH\";\n # Or have some fun with headers:\n # See http:\/\/www.nextthing.org\/archives\/2005\/08\/07\/fun-with-http-headers\n # See http:\/\/royal.pingdom.com\/2012\/08\/15\/fun-and-unusual-http-response-headers\/\n # set resp.http.X-Thank-You = \"for bothering to look at my HTTP headers\";\n # set resp.http.X-Answer = \"42\";\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_deliver {\n# return (deliver);\n# }\n\n# vcl_error: Called when we hit an error, either explicitly or implicitly due to backend or internal errors.\nsub vcl_error {\n \/* Avoid DOS vulnerability CVE-2013-4484 *\/\n # See https:\/\/www.varnish-cache.org\/lists\/pipermail\/varnish-announce\/2013-October\/000686.html\n if (obj.status == 400 || obj.status == 413) {\n return(deliver);\n }\n\n \/* Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_error;\n\n \/* Try to restart request in case of failure *\/\n # Note that max_restarts defaults to 4\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if (obj.status == 503 && req.restarts < 4) {\n set obj.http.X-Restarts = req.restarts;\n return(restart);\n }\n\n \/* Set common headers for synthetic responses *\/\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n\n \/* HTTP Authentification client request *\/\n # Empty in simple configs. See http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* We're using error 200 for monitoring puposes *\/\n # Consider adding some analytics stuff to trace accesses\n if (obj.status == 200) {\n synthetic {\"\n <?xml version=\"1.0\" encoding=\"utf-8\"?>\n <!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n <html>\n <head>\n <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n <\/head>\n <body><h1>\"} + obj.status + \": \" + obj.response + {\"<\/h1><\/body>\n \"};\n return(deliver);\n }\n\n \/* Error page & refresh \/ redirections *\/\n # We have plenty of choices when we have to serve an error to the client, \n # from the default error page to javascript black magic or plain redirections.\n # Adding some external statistic javascript to track failures served to clients is strongly suggested.\n # We can't use external resources on synthetic content, everything must be inlined.\n # If we need to include images we can embed them in base64 encoding.\n # Here is the default error page for Varnish 3 (not so pretty)\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + obj.status + \" \" + obj.response + {\"<\/h1>\n <p>\"} + obj.response + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"};\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this point.\n return (deliver);\n}\n\n# vcl_init: Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n# sub vcl_init {\n# return (ok);\n# }\n\n# vcl_fini: Called when VCL is discarded only after all requests have exited the VCL. Typically used to clean up VMODs.\n# sub vcl_fini {\n# return (ok);\n# }\n","old_contents":"\/* Varnish 3 example config for Drupal 7 \/ Pressflow 6 & 7 *\/\n# Original source: https:\/\/github.com\/NITEMAN\/varnish-bites\/varnish4\/drupal-base.vcl\n# Copyright (c) 2015 Pedro Gonz\u00e1lez Serrano and individual contributors.\n# MIT License\n\n# Intended to be used both in simple production environments and with learning\/teaching purposes.\n# Loosely based on http:\/\/www.lullabot.com\/sites\/default\/files\/default_varnish3.vcl_.txt\n\n\/* Backend probes \/ healthchecks *\/\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#backend-probes\nprobe basic {\n \/* Only test that backend's IP serves content for '\/' *\/\n # This might be a too heavy probe\n # .url = \"\/\";\n \/* Only test that backend's IP has apache working *\/\n # Nginx would fail this probe with a default config\n .request =\n \"OPTIONS * HTTP\/1.1\"\n \"Host: *\"\n \"Connection: close\";\n .interval = 10s;\n .timeout = 2s;\n .window = 8;\n .threshold = 6;\n}\n\n\n\/* Backend definitions.*\/\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#backend-declarations\nbackend default {\n \/* Default backend on the same machine. WARNING: timeouts could be not big enought for certain POST request *\/\n .host = \"127.0.0.1\";\n .port = \"8008\";\n .connect_timeout = 60s;\n .first_byte_timeout = 60s;\n .between_bytes_timeout = 60s;\n .probe = basic;\n}\n\n\n\/* Directors. *\/\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#directors\n# Empty in simple configs\n\n\n\/* Access Control Lists *\/\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#acls\nacl purge_ban {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use '\"localhost\";' instead\n}\nacl allowed_monitors {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n}\nacl own_proxys {\n \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n}\n\n\n\/* Custom routines *\/\n# Empty in simple configs.\n# We can name subs with no restrictions but as a task can need several chunks of code in diferent states,\n# it's a good idea to identify what main sub will call each with a suffix.\n# \/* Example 301 client redirection removing \"www\" prefix from request *\/\n# sub perm_redirections_recv {\n# if ( req.http.host ~ \"^www.*$\" ) {\n# error 751 \"http:\/\/\" + regsub(req.http.host, \"^www\\.\", \"\") + req.url;\n# }\n# }\n# sub perm_redirections_error {\n# if (obj.status == 751) {\n# \/* Get new URL from the response *\/\n# set obj.http.Location = obj.response;\n# \/* Set HTTP 301 for permanent redirect *\/\n# set obj.status = 301;\n# return(deliver);\n# }\n# }\n\n\n\/* VCL logigc overrides *\/\n# Note that the built-in logic will be appended to our code if no return is performed before.\n# Built-in logic is included commented out right after our's for reference purposes in that cases.\n# See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleDefault\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#subroutines\n\n# vcl_recv: Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use.\nsub vcl_recv {\n \/* 0th: general bypass, general return & authorization checks *\/\n # Empty in simple configs.\n # Useful for debugging we can pipe or pass the request to default backend here to bypass completely Varnish.\n # return (pipe);\n # return (pass);\n # We can also return here a 200 Ok for network performance benchmarking.\n # error 200 \"Ok\";\n # Finally we can perform basic HTTP authentification here by example.\n # See http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* 1st: Check for Varnish special requests *\/ \n # Purge logic.\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/purging.html#http-purges\n # See https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if (req.request == \"PURGE\") {\n if (!client.ip ~ purge_ban) {\n error 405 \"Not allowed.\";\n }\n return (lookup);\n }\n # Ban logic. See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/purging.html#bans\n if (req.request == \"BAN\") {\n if (!client.ip ~ purge_ban) {\n error 405 \"Not allowed.\";\n }\n ban(\"req.http.host == \" + req.http.host +\n \"&& req.url == \" + req.url); \n error 200 \"Ban added\";\n }\n # Custom response implementation example in order to check that Varnish is working properly.\n # This is usefull for automatic monitoring with monit or when Varnish is behind another proxies like HAProxy.\n if ( ( req.http.host == \"monitor.server.health\"\n || req.http.host == \"health.varnish\" )\n && client.ip ~ allowed_monitors\n && ( req.request == \"OPTIONS\" || req.request == \"GET\" )\n ) {\n error 200 \"Ok\";\n }\n\n \/* 2nd: Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_recv;\n # Here we can also enforce SSL when Varnish run behind some SSL termination point.\n\n \/* 3rd: Time for backend choice *\/\n # Empty in simple configs.\n\n \/* 4th: Set custom headers for backend like X-Forwarded-For (copied from built-in logic) *\/\n if ( req.restarts == 0 ) {\n \/* See also vcl_pipe section *\/\n if ( ! client.ip ~ own_proxys ) {\n if ( req.http.x-forwarded-for ) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n }\n\n \/* 5th: Bypass breakpoint 1 *\/\n # Useful for debugging we can now pipe or pass the request to backend with headers setted.\n # return (pipe);\n # return (pass);\n\n \/* 6th: Decide if we should deal with a request (mostly copied from built-in logic) *\/\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n\n \/* 7th: Access control for some URLs by ACL *\/\n # Empty in simple configs.\n # By example denial some URLs depending on client-ip, we'll need to define corresponding ACL 'internal'.\n # if (req.url ~ \"^\/(cron|install)\\.php$\" && !client.ip ~ internal) {\n # # Have Varnish throw the error directly.\n # error 403 \"Forbidden.\";\n # # Use a custom error page that you've defined in Drupal at the path \"404\".\n # # set req.url = \"\/403\";\n # }\n\n \/* 8th: Custom exceptions *\/\n # Host exception example:\n # if (req.http.host == \"ejemplo.exception.com\") {\n # return (pass);\n # }\n # Drupal exceptions, edit if we want to cache some AJAX\/AHAH request.\n # Add here filters for never cache URLs such as Payment Gateway's callbacks\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/ooyala\/ping$\" ||\n req.url ~ \"^\/admin\/build\/features\" ||\n req.url ~ \"^\/info\/.*$\" ||\n req.url ~ \"^\/flag\/.*$\" ||\n req.url ~ \"^.*\/ajax\/.*$\" ||\n req.url ~ \"^.*\/ahah\/.*$\") {\n \/* Do not cache these paths *\/\n return (pass);\n }\n # Pipe these paths directly to backend for streaming.\n if (req.url ~ \"^\/admin\/content\/backup_migrate\/export\") {\n return (pipe);\n }\n if (req.url ~ \"^\/system\/files\") {\n return (pipe);\n }\n\n \/* 9th: Enable grace mode *\/\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/handling_misbehaving_servers.html#grace-mode\n if (! req.backend.healthy) {\n \/* Use a longer grace period if all backends are down *\/\n set req.grace = 1h;\n \/* Use anonymous, cached pages if all backends are down. *\/\n unset req.http.Cookie;\n # TO-DO: Add sick marker\n } else {\n \/* Allow the backend to serve up stale content if it is responding slowly. *\/\n set req.grace = 30s;\n }\n\n \/* 10th: Deal with compression and the Accept-Encoding header *\/\n # Althought Varnish 3 handles gziped content itself by default, just to be sure we want to \n # remove Accept-Encoding for some compressed formats.\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/phk\/gzip.html#what-does-http-gzip-support-do\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/varnishd.html?highlight=http_gzip_support\n # See (for older configs) https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleNormalizeAcceptEncoding\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|mp4|flv|zip|rar)$\") {\n \/* Already compressed formats, no sense trying to compress again *\/\n remove req.http.Accept-Encoding;\n }\n }\n\n \/* 11th: Another header manipulation *\/\n # Empty in simple configs.\n # We could add here a custom header grouping User-agent families.\n\n \/* 12th: Cookie removal *\/\n # Always cache the following static file types for all users. \n # Use with care if we control certain downloads depending on cookies. \n # Be carefull also if appending .htm[l] via Drupal's clean URLs.\n if ( req.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n && req.url !~ \"\/system\/storage\/serve\"\n ) {\n unset req.http.Cookie;\n }\n # Remove all cookies that backend doesn't need to know about.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRemovingSomeCookies\n if (req.http.Cookie) {\n \/* Warning: Not a pretty solution *\/\n \/* Prefix header containing cookies with ';' *\/\n set req.http.Cookie = \";\" + req.http.Cookie;\n \/* Remove any spaces after ';' in header containing cookies *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n \/* Prefix cookies we want to preserve with one space *\/\n \/* 'S{1,2}ESS[a-z0-9]+' is the regular expression matching a Drupal session cookie ({1,2} added for HTTPS support) *\/\n \/* 'NO_CACHE' is usually set after a POST request to make sure issuing user see the results of his post *\/\n \/* 'OATMEAL' & 'CHOCOLATECHIP' are special cookies used by Drupal's Bakery module to provide Single Sign On *\/\n \/* Keep in mind we should add here any cookie that should reach the backend such as splahs avoiding cookies *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \";(S{1,2}ESS[a-z0-9]+|NO_CACHE|OATMEAL|CHOCOLATECHIP)=\", \"; \\1=\");\n \/* Remove from the header any single Cookie not prefixed with a space until next ';' separator *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n \/* Remove any '; ' at the start or the end of the header *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n\n if (req.http.Cookie == \"\") {\n \/* If there are no remaining cookies, remove the cookie header. *\/\n unset req.http.Cookie;\n }\n }\n\n \/* 13th: Session cookie & special cookies bypass caching stage *\/\n # As we might want to cache some requests, hashed with its cookies, \n # we don't simply pass when some cookies remain present at this point.\n # Instead we look for request that must be passed due to the cookie header.\n if (req.http.Cookie ~ \"SESS\" ||\n req.http.Cookie ~ \"SSESS\" ||\n req.http.Cookie ~ \"NO_CACHE\" ||\n req.http.Cookie ~ \"OATMEAL\" ||\n req.http.Cookie ~ \"CHOCOLATECHIP\") {\n return (pass);\n }\n\n \/* 14th: Bypass breakpoint 2 *\/\n # Useful for debugging we can now pipe or pass the request to backend to bypass cache.\n # return (pipe);\n # return (pass);\n\n \/* 15th: Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning a lookup.\n return (lookup);\n}\n\n# vcl_pipe: Called upon entering pipe mode.\n# In this mode, the request is passed on to the backend, \n# and any further data from either client or backend is passed on unaltered until either end closes the connection.\nsub vcl_pipe {\n \/* Prevent connection re-using for piped requests *\/\n # Note that only the first request to the backend will have X-Forwarded-For set.\n # As we use X-Forwarded-For and want to have it set for all requests, \n # we have to make sure connection won't be reused after the request.\n # It is not set by default as it might break some broken web applications, like IIS with NTLM authentication.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExamplePipe\n # TO-DO: make sure this is compatible with websockets piping,\n # reference https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/websockets.html\n set bereq.http.connection = \"close\";\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this point.\n return (pipe);\n}\n\n# vcl_pass: Called upon entering pass mode. \n# In this mode, the request is passed on to the backend, and the backend's response is passed on to the client, \n# but is not entered into the cache.\n# Subsequent requests submitted over the same client connection are handled normally.\n# sub vcl_pass {\n# return (pass);\n# }\n\n# vcl_hash: You may call hash_data() on the data you would like to add to the hash.\n# Hash is used by Varnish to uniquely identify objects.\nsub vcl_hash {\n \/* Hash cookie data *\/\n # As requests with same URL and host can produce diferent results when issued with different cookies,\n # we need to store items hashed with the associated cookies. Note that cookies are already sanitized when we reach this point.\n if (req.http.Cookie) {\n \/* Include cookie in cache hash *\/\n hash_data(req.http.Cookie);\n }\n\n \/* Custom header hashing *\/\n # Empty in simple configs.\n # Example for caching differents object versions by device previously detected (when static content could also vary):\n # if (req.http.X-UA-Device) {\n # hash_data(req.http.X-UA-Device);\n # }\n # Example for caching diferent object versions by X-Forwarded-Proto, trying to be smart about what kind of request\n # could generate diffetent responses.\n if ( req.http.X-Forwarded-Proto\n && req.url !~ \"(?i)\\.(png|gif|jpeg|jpg|ico|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\") {\n hash_data(req.http.X-Forwarded-Proto);\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (hash);\n# }\n\n# vcl_hit: Called after a cache lookup if the requested document was found in the cache.\nsub vcl_hit {\n \/* Check for Varnish special requests *\/ \n # Purge logic.\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/purging.html#http-purges\n # See https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged.\";\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hit {\n# return (deliver);\n# }\n\n# vcl_miss: Called after a cache lookup if the requested document was not found in the cache.\n# Its purpose is to decide whether or not to attempt to retrieve the document from the backend, and which backend to use.\nsub vcl_miss {\n \/* Check for Varnish special requests *\/ \n # Purge logic.\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/purging.html#http-purges\n # See https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged.\";\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_miss {\n# return (fetch);\n# }\n\n# vcl_fetch: Called after a document has been successfully retrieved from the backend.\nsub vcl_fetch {\n \/* Caching exceptions *\/\n # Varnish will cache objects with response codes: 200, 203, 300, 301, 302, 307, 404 & 410.\n # See https:\/\/www.varnish-software.com\/static\/book\/VCL_Basics.html#the-initial-value-of-beresp-ttl\n # Drupal's Imagecache module can return a 307 redirection to the requested url itself and, depending on Drupal's cache settings,\n # this could lead to a redirection loop being cached for a long time but also we want Varnish to shield a little the backend.\n # See http:\/\/drupal.org\/node\/1248010\n # See http:\/\/drupal.org\/node\/310656\n if (beresp.status == 307 &&\n \/* TO-DO: verify that this work better than 'req.url ~ \"imagecache\"' *\/\n beresp.http.Location == req.url &&\n beresp.ttl > 5s) {\n set beresp.ttl = 5s;\n set beresp.http.cache-control = \"max-age=5\";\n }\n\n \/* Enable grace mode. Related with our 9th stage on vcl_recv *\/\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/handling_misbehaving_servers.html#grace-mode\n set beresp.grace = 1h;\n\n \/* Enable saint mode. Related with our 9th stage on vcl_recv *\/\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/handling_misbehaving_servers.html#saint-mode\n if (beresp.status == 500) {\n set beresp.saintmode = 20s;\n # TO-DO: consider not restarting POST requests as seen on https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleSaintMode\n return(restart);\n }\n\n \/* Strip cookies from the following static file types for all users. Related with our 12th stage on vcl_recv *\/\n if (req.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\") {\n unset beresp.http.set-cookie;\n }\n\n \/* Gzip response *\/\n # Empty in simple configs\n # Use Varnish to Gzip respone, if suitable, before storing it on cache\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/phk\/gzip.html\n # if (! beresp.http.Content-Encoding &&\n # (beresp.http.content-type ~ \"text\" ||\n # beresp.http.content-type ~ \"application\/x-javascript\" ||\n # beresp.http.content-type ~ \"application\/javascript\" ||\n # beresp.http.content-type ~ \"application\/rss+xml\" ||\n # beresp.http.content-type ~ \"application\/xml\" ||\n # beresp.http.content-type ~ \"Application\/JSON\")\n # ) {\n # set beresp.do_gzip = true;\n # if ( beresp.http.Vary ) {\n # if ( ! beresp.http.Vary ~ \"Accept-Encoding\" ) {\n # set beresp.http.Vary = beresp.http.Vary + \",Accept-Encoding\";\n # }\n # } else {\n # set beresp.http.Vary = \"Accept-Encoding\";\n # }\n # }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # We can add the name of the backend that has processed the request:\n # set beresp.http.X-Backend = beresp.backend.name;\n # We can use a header to tell if the object was gziped by Varnish\n # if (beresp.do_gzip) {\n # set beresp.http.X-Varnish-Gzipped = \"yes\";\n # } else {\n # set beresp.http.X-Varnish-Gizipped = \"no\";\n # }\n # We can also add headers informing whether the object is cacheable or not and why.\n # https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Varnish3.0\n if (beresp.ttl <= 0s) {\n \/* Varnish determined the object was not cacheable *\/\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n } elsif (req.http.Cookie ~ \"(SESS|SSESS|NO_CACHE|OATMEAL|CHOCOLATECHIP)\") {\n \/* We don't wish to cache content for logged in users or with certain cookies. Related with our 9th stage on vcl_recv *\/\n set beresp.http.X-Cacheable = \"NO:Cookies\";\n # return(hit_for_pass);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n \/* We are respecting the Cache-Control=private header from the backend *\/\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n # return(hit_for_pass);\n } else {\n \/* Varnish determined the object was cacheable *\/\n set beresp.http.X-Cacheable = \"YES\";\n }\n\n \/* Further header manipulation *\/\n # Empty in simple configs.\n # We can also unset some headers to prevent information disclosure and save some cache space\n # unset beresp.http.Server;\n # unset beresp.http.X-Powered-By;\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_fetch {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Vary == \"*\") {\n# \/*\n# * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# *\/\n# set beresp.ttl = 120 s;\n# return (hit_for_pass);\n# }\n# return (deliver);\n# }\n\n# vcl_deliver: Called before an object is delivered to the client\nsub vcl_deliver {\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # Add whether the object is a cache hit or miss and the number of hits for the object.\n # https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Addingaheaderindicatinghitmiss\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n set resp.http.X-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Cache = \"MISS\";\n \/* Show the results of cookie sanitization *\/\n set resp.http.X-Cookie = req.http.Cookie;\n }\n # TO-DO: Add sick marker\n # Restart count\n if ( req.restarts > 0) {\n set resp.http.X-Restarts = req.restarts;\n }\n # Add the Varnish server hostname\n set resp.http.X-Varnish-Server = server.hostname;\n # If we have setted a custom header with device family detected we can show it:\n # if (req.http.X-UA-Device) {\n # set resp.http.X-UA-Device = req.http.X-UA-Device;\n # }\n # If we have recived a custom header with the protocol in the request we can show it:\n # if (req.http.X-Forwarded-Proto) {\n # set resp.http.X-Forwarded-Proto = req.http.X-Forwarded-Proto;\n # }\n\n \/* Vary header manipulation *\/\n # Empty in simple configs.\n # By example, if we are storing & serving diferent objects depending on User-Agent header we must set the correct Vary header:\n # if (resp.http.Vary) {\n # set resp.http.Vary = resp.http.Vary + \",User-Agent\";\n # } else {\n # set resp.http.Vary = \"User-Agent\";\n # }\n\n \/* Fake headers *\/\n # Empty in simple configs\n # We can fake server headers here, by example:\n # set resp.http.Server = \"Deep thought\";\n # set resp.http.X-Powered-By = \"BOFH\";\n # Or have some fun with headers:\n # See http:\/\/www.nextthing.org\/archives\/2005\/08\/07\/fun-with-http-headers\n # See http:\/\/royal.pingdom.com\/2012\/08\/15\/fun-and-unusual-http-response-headers\/\n # set resp.http.X-Thank-You = \"for bothering to look at my HTTP headers\";\n # set resp.http.X-Answer = \"42\";\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_deliver {\n# return (deliver);\n# }\n\n# vcl_error: Called when we hit an error, either explicitly or implicitly due to backend or internal errors.\nsub vcl_error {\n \/* Avoid DOS vulnerability CVE-2013-4484 *\/\n # See https:\/\/www.varnish-cache.org\/lists\/pipermail\/varnish-announce\/2013-October\/000686.html\n if (obj.status == 400 || obj.status == 413) {\n return(deliver);\n }\n\n \/* Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_error;\n\n \/* Try to restart request in case of failure *\/\n # Note that max_restarts defaults to 4\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if (obj.status == 503 && req.restarts < 4) {\n set obj.http.X-Restarts = req.restarts;\n return(restart);\n }\n\n \/* Set common headers for synthetic responses *\/\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n\n \/* HTTP Authentification client request *\/\n # Empty in simple configs. See http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* We're using error 200 for monitoring puposes *\/\n # Consider adding some analytics stuff to trace accesses\n if (obj.status == 200) {\n synthetic {\"\n <?xml version=\"1.0\" encoding=\"utf-8\"?>\n <!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n <html>\n <head>\n <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n <\/head>\n <body><h1>\"} + obj.status + \": \" + obj.response + {\"<\/h1><\/body>\n \"};\n return(deliver);\n }\n\n \/* Error page & refresh \/ redirections *\/\n # We have plenty of choices when we have to serve an error to the client, \n # from the default error page to javascript black magic or plain redirections.\n # Adding some external statistic javascript to track failures served to clients is strongly suggested.\n # We can't use external resources on synthetic content, everything must be inlined.\n # If we need to include images we can embed them in base64 encoding.\n # Here is the default error page for Varnish 3 (not so pretty)\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + obj.status + \" \" + obj.response + {\"<\/h1>\n <p>\"} + obj.response + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"};\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this point.\n return (deliver);\n}\n\n# vcl_init: Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n# sub vcl_init {\n# return (ok);\n# }\n\n# vcl_fini: Called when VCL is discarded only after all requests have exited the VCL. Typically used to clean up VMODs.\n# sub vcl_fini {\n# return (ok);\n# }\n","returncode":0,"stderr":"","license":"unknown","lang":"VCL"} {"commit":"4c6f38363bb81971342b80a8e574a7a2e1fe3b2e","subject":"add streaming debug example","message":"add streaming debug example\n","repos":"NITEMAN\/varnish-bites,NITEMAN\/Varnish_VCL_samps-hacks","old_file":"varnish4\/drupal-base.vcl","new_file":"varnish4\/drupal-base.vcl","new_contents":"\/*\n * Varnish 4 example config for Drupal 7 \/ Pressflow 6 & 7\n *\/\n\n# Original source: https:\/\/github.com\/NITEMAN\/varnish-bites\/varnish4\/drupal-base.vcl\n# Copyright (c) 2015 Pedro Gonz\u00e1lez Serrano and individual contributors.\n# MIT License\n\n# Intended to be used both in simple production environments and with\n# learning\/teaching purposes.\n# Some references may not be yet updated to VCL 4.0, we use SeeV3 then.\n\n# WARNING:\n# Note that the built-in logic will be appended to our code if no return is\n# performed before.\n# Built-in logic is included commented out right after our's for reference\n# purposes in that cases.\n# See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleDefault\n\n#######################################################################\n# Initialization: Version & imports;\n\n\/* Version statement *\/\n# Since Varnish 4.0 it's mandatory to declare VCL version on first line.\nvcl 4.0;\n\n\/* Module (VMOD) imports *\/\n# Standard module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_std.generated.html\nimport std;\n\n# Directors module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# Unused in simple configs.\n#import directors;\n\n\n#######################################################################\n# Probe, backend, ACL and subroutine definitions\n\n\/* Backend probes \/ healthchecks *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#probes\nprobe basic {\n \/* Only test that backend's IP serves content for '\/' *\/\n # This might be a too heavy probe\n # .url = \"\/\";\n\n \/* Only test that backend's IP has apache working *\/\n # Nginx would fail this probe with a default config\n .request =\n \"OPTIONS * HTTP\/1.1\"\n \"Host: *\"\n \"Connection: close\";\n\n \/* Common options *\/\n .interval = 10s;\n .timeout = 2s;\n .window = 8;\n .threshold = 6;\n}\n\n\/* Backend definitions.*\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#backend-definition\nbackend default {\n \/* Default backend on the same machine. *\/\n # WARNING: timeouts could be not big enought for certain POST requests.\n .host = \"127.0.0.1\";\n .port = \"8008\";\n .max_connections = 100;\n .connect_timeout = 60s;\n .first_byte_timeout = 60s;\n .between_bytes_timeout = 60s;\n .probe = basic;\n}\n\n\/* Access Control Lists *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#access-control-list-acl\nacl purge_ban {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use '\"localhost\";' instead\n}\nacl allowed_monitors {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n}\n# acl own_proxys {\n# \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n# }\n\n\/* Custom subroutines *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#subroutines\n#TODO# Test in Varnihs 4\n# Empty in simple configs.\n# The only restriction naming subs is that the 'vlc_' prefix is reserverd for\n# Varnish use. As a task can need several chunks of code in diferent states,\n# it's a good idea to identify what main sub will call each with a suffix.\n# \/* Example 301 client redirection removing \"www\" prefix from request *\/\n# sub perm_redirections_recv {\n# if ( req.http.host ~ \"^www.*$\" ) {\n# return (\n# synth(751, \"http:\/\/\" + regsub(req.http.host, \"^www\\.\", \"\") + req.url)\n# );\n# }\n# }\n# sub perm_redirections_synth {\n# if ( resp.status == 751 ) {\n# \/* Get new URL from the response *\/\n# set resp.http.Location = resp.response;\n# \/* Set HTTP 301 for permanent redirect *\/\n# set resp.status = 301;\n# return (deliver);\n# }\n# }\n\n\n#######################################################################\n# Client side\n\n# vcl_recv: Called at the beginning of a request, after the complete request\n# has been received and parsed. Its purpose is to decide whether or not to\n# serve the request, how to do it, and, if applicable, which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-recv\nsub vcl_recv {\n \/* 0th: general bypass, general return & authorization checks *\/\n # Empty in simple configs.\n # Useful for debugging we can pipe or pass the request to default backend\n # here to bypass completely Varnish.\n # return (pipe);\n # return (pass);\n # We can also return here a 200 Ok for network performance benchmarking.\n # return (synth(200, \"Ok\"));\n # Finally we can perform basic HTTP authentification here, by example.\n # SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* 1st: Check for Varnish special requests *\/ \n # Custom response implementation example in order to check that Varnish is\n # working properly.\n # This is usefull for automatic monitoring with monit or when Varnish is\n # behind another proxies like HAProxy.\n if ( ( req.http.host == \"monitor.server.health\"\n || req.http.host == \"health.varnish\" )\n && client.ip ~ allowed_monitors\n && ( req.method == \"OPTIONS\" || req.method == \"GET\" )\n ) {\n return (synth(200, \"Ban added\"));\n }\n # Purge logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#http-purging\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if ( req.method == \"PURGE\" ) {\n if ( client.ip !~ purge_ban ) {\n return (synth(405, \"Not allowed.\"));\n }\n return (purge);\n }\n # Ban logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#bans\n if ( req.method == \"BAN\" ) {\n if ( client.ip !~ purge_ban ) {\n return (synth(405, \"Not allowed.\"));\n }\n ban( \"req.http.host == \" + req.http.host +\n \"&& req.url == \" + req.url);\n return (synth(200, \"Ban added\"));\n }\n\n \/* 2nd: Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_recv;\n # Here we can also enforce SSL when Varnish run behind some SSL termination\n # point.\n\n \/* 3rd: Time for backend choice *\/\n # Empty in simple configs.\n\n \/* 4th: Prepare request for the backend *\/\n # Empty in simple configs.\n # Example remove own_proxys from X-Forwarded-For\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/whats-new\/upgrading.html#x-forwarded-for-is-now-set-before-vcl-recv\n # if ( req.restarts == 0\n # && client.ip ~ own_proxys\n # && req.http.x-forwarded-for\n # ) {\n # set req.http.X-Forwarded-For\n # = regsub(req.http.X-Forwarded-For, \",( )?\" + client.ip, \"\");\n # }\n # Example normalize the host header, remove the port (in case you're testing\n # this on various TCP ports)\n # set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n \/* 5th: Bypass breakpoint 1 *\/\n # Useful for debugging we can now pipe or pass the request to backend with\n # headers setted.\n # return (pipe);\n # return (pass);\n\n \/* 6th: Decide if we should deal with a request (mostly from built-in logic) *\/\n if ( req.method == \"PRI\" ) {\n \/* We do not support SPDY or HTTP\/2.0 *\/\n return (synth(405));\n }\n if ( req.method != \"GET\"\n && req.method != \"HEAD\"\n && req.method != \"PUT\"\n && req.method != \"POST\"\n && req.method != \"TRACE\"\n && req.method != \"OPTIONS\"\n && req.method != \"DELETE\"\n ) {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if ( req.method != \"GET\"\n && req.method != \"HEAD\"\n ) {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if ( req.http.Authorization ) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n # Websocket support\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html\n if ( req.http.Upgrade ~ \"(?i)websocket\" ) {\n return (pipe);\n }\n\n \/* 7th: Access control for some URLs by ACL *\/\n # Empty in simple configs.\n # By example denial some URLs depending on client-ip, we'll need to define\n # corresponding ACL 'internal'.\n # if ( req.url ~ \"^\/(cron|install)\\.php\"\n # && client.ip !~ internal\n # ) {\n # # Have Varnish throw the error directly.\n # return (synth(403, \"Forbidden.\"));\n # # Use a custom error page that you've defined in Drupal at the path \"404\".\n # # set req.url = \"\/403\";\n # }\n\n \/* 8th: Custom exceptions *\/\n # Host exception example:\n # if ( req.http.host == \"ejemplo.exception.com\" ) {\n # return (pass);\n # }\n # Drupal exceptions, edit if we want to cache some AJAX\/AHAH request.\n # Add here filters for never cache URLs such as Payment Gateway's callbacks.\n if ( req.url ~ \"^\/status\\.php$\"\n || req.url ~ \"^\/update\\.php$\"\n || req.url ~ \"^\/ooyala\/ping$\"\n || req.url ~ \"^\/admin\/build\/features\"\n || req.url ~ \"^\/info\/.*$\"\n || req.url ~ \"^\/flag\/.*$\"\n || req.url ~ \"^.*\/ajax\/.*$\"\n || req.url ~ \"^.*\/ahah\/.*$\"\n ) {\n \/* Do not cache these paths *\/\n return (pass);\n }\n # Pipe these paths directly to backend for streaming.\n if ( req.url ~ \"^\/admin\/content\/backup_migrate\/export\" ) {\n return (pipe);\n }\n if ( req.url ~ \"^\/system\/files\" ) {\n return (pipe);\n }\n\n \/* 9th: Graced objets & Serve from anonymous cahe if all backends are down *\/\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n # set req.http.grace = \"none\";\n if ( ! std.healthy(req.backend_hint) ) {\n # We must do this here since cookie hashing\n unset req.http.Cookie;\n #TODO# Add sick marker\n } \n\n \/* 10th: Deal with compression and the Accept-Encoding header *\/\n # Althought Varnish 3 handles gziped content itself by default, just to be\n # sure we want to remove Accept-Encoding for some compressed formats.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html#what-does-http-gzip-support-do\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/varnishd.html?highlight=http_gzip_support\n # See (for older configs) https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleNormalizeAcceptEncoding\n if ( req.http.Accept-Encoding ) {\n if ( req.url ~ \"(?i)\\.(7z|avi|bz2|flv|gif|gz|jpe?g|mpe?g|mk[av]|mov|mp[34]|og[gm]|pdf|png|rar|swf|tar|tbz|tgz|woff2?|zip|xz)(\\?.*)?$\"\n ) {\n \/* Already compressed formats, no sense trying to compress again *\/\n unset req.http.Accept-Encoding;\n }\n }\n\n \/* 11th: Another request manipulation *\/\n # Empty in simple configs.\n # We could add here a custom header grouping User-agent families.\n # Generic URL manipulation.\n # Remove Google Analytics added parameters, useless for our backends.\n if ( req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=\" ) {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n # Strip anchors, server doesn't need it.\n if ( req.url ~ \"\\#\" ) {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n # Strip a trailing ? if it exists\n if ( req.url ~ \"\\?$\" ) {\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n # Normalize the querystring arguments\n set req.url = std.querysort(req.url);\n\n \/* 12th: Cookie removal *\/\n # Always cache the following static file types for all users. \n # Use with care if we control certain downloads depending on cookies. \n # Be carefull also if appending .htm[l] via Drupal's clean URLs.\n if ( req.url ~ \"(?i)\\.(bz2|css|eot|gif|gz|html?|ico|jpe?g|js|mp3|ogg|otf|pdf|png|rar|svg|swf|tbz|tgz|ttf|woff2?|zip)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n && req.url !~ \"\/system\/storage\/serve\"\n ) {\n unset req.http.Cookie;\n }\n # Remove all cookies that backend doesn't need to know about.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRemovingSomeCookies\n if ( req.http.Cookie ) {\n \/* Warning: Not a pretty solution *\/\n # Prefix header containing cookies with ';'\n set req.http.Cookie = \";\" + req.http.Cookie;\n # Remove any spaces after ';' in header containing cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n # Prefix cookies we want to preserve with one space:\n # 'S{1,2}ESS[a-z0-9]+' is the regular expression matching a Drupal session\n # cookie ({1,2} added for HTTPS support).\n # 'NO_CACHE' is usually set after a POST request to make sure issuing user\n # see the results of his post.\n # 'OATMEAL' & 'CHOCOLATECHIP' are special cookies used by Drupal's Bakery\n # module to provide Single Sign On.\n # Keep in mind we should add here any cookie that should reach the backend\n # such as splash avoiding cookies.\n set req.http.Cookie\n = regsuball(\n req.http.Cookie,\n \";(S{1,2}ESS[a-z0-9]+|NO_CACHE|OATMEAL|CHOCOLATECHIP)=\",\n \"; \\1=\"\n );\n # Remove from the header any single Cookie not prefixed with a space until\n # next ';' separator.\n set req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n # Remove any '; ' at the start or the end of the header.\n set req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n #If there are no remaining cookies, remove the cookie header.\n if ( req.http.Cookie == \"\" ) {\n unset req.http.Cookie;\n }\n }\n\n \/* 13th: Session cookie & special cookies bypass caching stage *\/\n # As we might want to cache some requests, hashed with its cookies, we don't\n # simply pass when some cookies remain present at this point.\n # Instead we look for request that must be passed due to the cookie header.\n if ( req.http.Cookie ~ \"SESS\"\n || req.http.Cookie ~ \"SSESS\"\n || req.http.Cookie ~ \"NO_CACHE\"\n || req.http.Cookie ~ \"OATMEAL\"\n || req.http.Cookie ~ \"CHOCOLATECHIP\"\n ) {\n return (pass);\n }\n\n \/* 14th: Announce ESI Support *\/\n # Empty in simple configs.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/esi.html\n # Note that ESI included requests inherits its parent's modified request, so\n # depending on the case you will end playing with req.esi_level to know\n # current depth.\n # Send Surrogate-Capability headers\n # See http:\/\/www.w3.org\/TR\/edge-arch\n # Note that myproxyname is an identifier that should avoid collitions\n # set req.http.Surrogate-Capability = \"myproxyname=ESI\/1.0\";\n\n \/* 15th: Bypass breakpoint 2 *\/\n # Useful for debugging we can now pipe or pass the request to backend to\n # bypass cache.\n # return (pipe);\n # return (pass);\n\n \/* 16th: Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n return (hash);\n}\n\n# vcl_pipe: Called upon entering pipe mode.\n# In this mode, the request is passed on to the backend, and any further data\n# from either client or backend is passed on unaltered until either end closes\n# the connection.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pipe\nsub vcl_pipe {\n # Websocket support\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html\n if ( req.http.upgrade ) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n}\n# sub vcl_pipe {\n# # By default Connection: close is set on all piped requests, to stop\n# # connection reuse from sending future requests directly to the\n# # (potentially) wrong backend. If you do want this to happen, you can undo\n# # it here.\n# # unset bereq.http.connection;\n# return (pipe);\n# }\n\n# vcl_pass: Called upon entering pass mode. \n# In this mode, the request is passed on to the backend, and the backend's\n# response is passed on to the client, but is not entered into the cache.\n# Subsequent requests submitted over the same client connection are handled normally.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pass\n# sub vcl_pass {\n# return (fetch);\n# }\n\n# vcl_hash: You may call hash_data() on the data you would like to add to the\n# hash.\n# Hash is used by Varnish to uniquely identify objects.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hash\nsub vcl_hash {\n \/* Hash cookie data *\/\n # As requests with same URL and host can produce diferent results when issued\n # with different cookies, we need to store items hashed with the associated\n # cookies. Note that cookies are already sanitized when we reach this point.\n if ( req.http.Cookie ) {\n \/* Include cookie in cache hash *\/\n hash_data(req.http.Cookie);\n }\n\n \/* Custom header hashing *\/\n # Empty in simple configs.\n # Example for caching differents object versions by device previously\n # detected (when static content could also vary):\n # if ( req.http.X-UA-Device ) {\n # hash_data(req.http.X-UA-Device);\n # }\n # Example for caching diferent object versions by X-Forwarded-Proto, trying\n # to be smart about what kind of request could generate diffetent responses.\n if ( req.http.X-Forwarded-Proto\n && req.url !~ \"(?i)\\.(bz2|css|eot|gif|gz|html?|ico|jpe?g|js|mp3|ogg|otf|pdf|png|rar|svg|swf|tbz|tgz|ttf|woff2?|zip)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n ) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (lookup);\n# }\n\n# vcl_purge: Called after the purge has been executed and all its variants have\n# been evited.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-purge\n# sub vcl_purge {\n# return (synth(200, \"Purged\"));\n# }\n\n# vcl_hit: Called after a cache lookup if the requested document was found in\n# the cache.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hit\nsub vcl_hit {\n if ( obj.ttl >= 0s ) {\n \/\/ A pure unadultered hit, deliver it\n return (deliver);\n }\n \/* Allow varnish to serve up stale content if it is responding slowly *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n if ( obj.ttl + 60s > 0s ) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n set req.http.grace = \"normal\";\n return (deliver);\n }\n \/* Allow varish to serve up stale content if all backends are down *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n if ( ! std.healthy(req.backend_hint)\n && obj.ttl + obj.grace > 0s\n ) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n set req.http.grace = \"extended\";\n return (deliver);\n }\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\n# vcl_miss: Called after a cache lookup if the requested document was not found\n# in the cache.\n# Its purpose is to decide whether or not to attempt to retrieve the document\n# from the backend, and which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-miss\n# sub vcl_miss {\n# return (fetch);\n# }\n\n# vcl_deliver: Called before an object is delivered to the client\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-deliver\nsub vcl_deliver {\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # Add whether the object is a cache hit or miss and the number of hits for\n # the object.\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Addingaheaderindicatinghitmiss\n # In Varnish 4 the obj.hits counter behaviour has changed (see bug 1492), so\n # we use a different method: if X-Varnish contains only 1 id, we have a miss,\n # if it contains more (and therefore a space), we have a hit.\n if ( resp.http.x-varnish ~ \" \" ) {\n set resp.http.X-Cache = \"HIT\";\n # Since in Varnish 4 the behaviour of obj.hits changed, this might not be\n # accurate.\n # See https:\/\/www.varnish-cache.org\/trac\/ticket\/1492\n set resp.http.X-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Cache = \"MISS\";\n \/* Show the results of cookie sanitization *\/\n set resp.http.X-Cookie = req.http.Cookie;\n }\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n set resp.http.grace = req.http.grace;\n\n #TODO# Add sick marker\n\n # Restart count\n if ( req.restarts > 0 ) {\n set resp.http.X-Restarts = req.restarts;\n }\n\n # Add the Varnish server hostname\n set resp.http.X-Varnish-Server = server.hostname;\n # If we have setted a custom header with device's family detected we can show\n # it:\n # if ( req.http.X-UA-Device ) {\n # set resp.http.X-UA-Device = req.http.X-UA-Device;\n # }\n # If we have recived a custom header indicating the protocol in the request we\n # can show it:\n # if ( req.http.X-Forwarded-Proto ) {\n # set resp.http.X-Forwarded-Proto = req.http.X-Forwarded-Proto;\n # }\n\n \/* Vary header manipulation *\/\n # Empty in simple configs.\n # By example, if we are storing & serving diferent objects depending on\n # User-Agent header we must set the correct Vary header:\n # if ( resp.http.Vary ) {\n # set resp.http.Vary = resp.http.Vary + \",User-Agent\";\n # } else {\n # set resp.http.Vary = \"User-Agent\";\n # }\n\n \/* Fake headers *\/\n # Empty in simple configs\n # We can fake server headers here, by example:\n # set resp.http.Server = \"Deep thought\";\n # set resp.http.X-Powered-By = \"BOFH\";\n # Or have some fun with headers:\n # See http:\/\/www.nextthing.org\/archives\/2005\/08\/07\/fun-with-http-headers\n # See http:\/\/royal.pingdom.com\/2012\/08\/15\/fun-and-unusual-http-response-headers\/\n # set resp.http.X-Thank-You = \"for bothering to look at my HTTP headers\";\n # set resp.http.X-Answer = \"42\";\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_deliver {\n# return (deliver);\n# }\n\n# vcl_synth: Called to deliver a synthetic object. A synthetic object is\n# generated in VCL, not fetched from the backend. It is typically contructed\n# using the synthetic() function.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-synth\n\/*\n * We can come here \"invisibly\" with the following errors: 413, 417 & 503\n *\/\nsub vcl_synth {\n \/* Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_synth;\n\n \/* Try to restart request in case of failure *\/\n # Note that max_restarts defaults to 4\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if ( resp.status == 503\n && req.restarts < 4\n ) {\n return (restart);\n }\n\n \/* Set common headers for synthetic responses *\/\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n\n \/* HTTP Authentification client request *\/\n # Empty in simple configs.\n # SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* Load synthetic responses from disk *\/\n # Note that files loaded this way are never re-readed (even after a reload).\n # You should consider PROS\/CONS of doing an include instead.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_std.generated.html#func-fileread\n # Example custom 403 error page.\n # if ( resp.status == 403 ) {\n # synthetic(std.fileread(\"\/403.html\"));\n # return (deliver);\n # }\n\n \/* Error page & refresh \/ redirections *\/\n # We have plenty of choices when we have to serve an error to the client, \n # from the default error page to javascript black magic or plain redirections.\n # Adding some external statistic javascript to track failures served to\n # clients is strongly suggested.\n # We can't use external resources on synthetic content, everything must be\n # inlined.\n # If we need to include images we can embed them in base64 encoding.\n # We're using error 200 for monitoring puposes which should not be retried\n # client side.\n if ( resp.status != 200 ) {\n set resp.http.Retry-After = \"5\";\n }\n\n # Here is the default error page for Varnish 4 (not so pretty)\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n return (deliver);\n}\n\n#######################################################################\n# Backend Fetch\n\n# vcl_backend_fetch: Called before sending the backend request. In this\n# subroutine you typically alter the request before it gets to the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-fetch\n# sub vcl_backend_fetch {\n# return (fetch);\n# }\n\n# vcl_backend_response: Called after the response headers has been successfully\n# retrieved from the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-response\nsub vcl_backend_response {\n \/* Caching exceptions *\/\n # Varnish will cache objects with response codes:\n # 200, 203, 300, 301, 302, 307, 404 & 410.\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/VCL_Basics.html#the-initial-value-of-beresp-ttl\n # Drupal's Imagecache module can return a 307 redirection to the requested\n # url itself and, depending on Drupal's cache settings, this could lead to a\n # redirection loop being cached for a long time but also we want Varnish to\n # shield a little the backend.\n # See http:\/\/drupal.org\/node\/1248010\n # See http:\/\/drupal.org\/node\/310656\n if ( beresp.status == 307\n #TODO# verify that this work better than 'bereq.url ~ \"imagecache\"'\n && beresp.http.Location == bereq.url\n && beresp.ttl > 5s\n ) {\n set beresp.ttl = 5s;\n set beresp.http.cache-control = \"max-age=5\";\n }\n\n \/* Request retrial *\/\n if ( beresp.status == 500\n || beresp.status == 503\n ) {\n #TODO# consider not restarting POST requests as seenV3 on https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleSaintMode\n return (retry);\n }\n\n \/* Enable grace mode. Related with vcl_hit *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n set beresp.grace = 1h;\n\n \/* Strip cookies from the following static file types for all users. *\/\n # Related with our 12th stage on vcl_recv\n if ( bereq.url ~ \"(?i)\\.(bz2|css|eot|gif|gz|html?|ico|jpe?g|js|mp3|ogg|otf|pdf|png|rar|svg|swf|tbz|tgz|ttf|woff2?|zip)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n ) {\n unset beresp.http.set-cookie;\n }\n\n \/* Process ESI responses *\/\n # Empty in simple configs.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/esi.html\n # Send Surrogate-Capability headers\n # See http:\/\/www.w3.org\/TR\/edge-arch\n # Note that myproxyname is an identifier that should avoid collitions\n # Check for ESI acknowledgement and remove Surrogate-Control header\n #TODO# Add support for Surrogate-Control Targetting\n # if ( beresp.http.Surrogate-Control ~ \"ESI\/1.0\" ) {\n # unset beresp.http.Surrogate-Control;\n # set beresp.do_esi = true;\n # }\n\n \/* Gzip response *\/\n # Empty in simple configs.\n # Use Varnish to Gzip respone, if suitable, before storing it on cache.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html\n if ( ! beresp.http.Content-Encoding\n && ( beresp.http.content-type ~ \"text\"\n || beresp.http.content-type ~ \"application\/x-javascript\"\n || beresp.http.content-type ~ \"application\/javascript\"\n || beresp.http.content-type ~ \"application\/rss+xml\"\n || beresp.http.content-type ~ \"application\/xml\"\n || beresp.http.content-type ~ \"Application\/JSON\")\n ) {\n set beresp.do_gzip = true;\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # We can add the name of the backend that has processed the request:\n # set beresp.http.X-Backend = beresp.backend.name;\n # We can use a header to tell if the object was gziped by Varnish:\n # if ( beresp.do_gzip ) {\n # set beresp.http.X-Varnish-Gzipped = \"yes\";\n # } else {\n # set beresp.http.X-Varnish-Gizipped = \"no\";\n # }\n # We can do the same to tell if Varnish is streaming it:\n # if ( beresp.do_stream ) {\n # set beresp.http.X-Varnish-Streaming = \"yes\";\n # } else {\n # set beresp.http.X-Varnish-Streaming = \"no\";\n # }\n # We can also add headers informing whether the object is cacheable or not and why:\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Varnish3.0\n if ( beresp.ttl <= 0s ) {\n \/* Varnish determined the object was not cacheable *\/\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n } elsif ( bereq.http.Cookie ~ \"(SESS|SSESS|NO_CACHE|OATMEAL|CHOCOLATECHIP)\" ) {\n \/* We don't wish to cache content for logged in users or with certain cookies. *\/\n # Related with our 9th stage on vcl_recv\n set beresp.http.X-Cacheable = \"NO:Cookies\";\n # set beresp.uncacheable = true;\n } elsif ( beresp.http.Cache-Control ~ \"private\" ) {\n \/* We are respecting the Cache-Control=private header from the backend *\/\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n # set beresp.uncacheable = true;\n } else {\n \/* Varnish determined the object was cacheable *\/\n set beresp.http.X-Cacheable = \"YES\";\n }\n\n \/* Further header manipulation *\/\n # Empty in simple configs.\n # We can also unset some headers to prevent information disclosure and save\n # some cache space.\n # unset beresp.http.Server;\n # unset beresp.http.X-Powered-By;\n # Retry count.\n if ( bereq.retries > 0 ) {\n set beresp.http.X-Retries = bereq.retries;\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_backend_response {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Surrogate-control ~ \"no-store\" ||\n# (!beresp.http.Surrogate-Control &&\n# beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n# beresp.http.Vary == \"*\") {\n# \/*\n# * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# *\/\n# set beresp.ttl = 120s;\n# set beresp.uncacheable = true;\n# }\n# return (deliver);\n# }\n\n# vcl_backend_error: This subroutine is called if we fail the backend fetch.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-error\nsub vcl_backend_error {\n\n \/* Try to restart request in case of failure *\/\n #TODO# Confirm max_retries default value\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if ( bereq.retries < 4 ) {\n return (retry);\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # Retry count\n if ( bereq.retries > 0 ) {\n set beresp.http.X-Retries = bereq.retries;\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + beresp.status + \" \" + beresp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + beresp.status + \" \" + beresp.reason + {\"<\/h1>\n <p>\"} + beresp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + bereq.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this\n # point.\n return (deliver);\n}\n\n#######################################################################\n# Housekeeping\n\n# vcl_init: Called when VCL is loaded, before any requests pass through it.\n# Typically used to initialize VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-init\n# Here is where you should declare your directors now.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-backends.html#directors\n# Empty in simple configs\n# sub vcl_init {\n# return (ok);\n# }\n\n# vcl_fini: Called when VCL is discarded only after all requests have exited\n# the VCL. Typically used to clean up VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-fini\n# sub vcl_fini {\n# return (ok);\n# }\n\n","old_contents":"\/*\n * Varnish 4 example config for Drupal 7 \/ Pressflow 6 & 7\n *\/\n\n# Original source: https:\/\/github.com\/NITEMAN\/varnish-bites\/varnish4\/drupal-base.vcl\n# Copyright (c) 2015 Pedro Gonz\u00e1lez Serrano and individual contributors.\n# MIT License\n\n# Intended to be used both in simple production environments and with\n# learning\/teaching purposes.\n# Some references may not be yet updated to VCL 4.0, we use SeeV3 then.\n\n# WARNING:\n# Note that the built-in logic will be appended to our code if no return is\n# performed before.\n# Built-in logic is included commented out right after our's for reference\n# purposes in that cases.\n# See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleDefault\n\n#######################################################################\n# Initialization: Version & imports;\n\n\/* Version statement *\/\n# Since Varnish 4.0 it's mandatory to declare VCL version on first line.\nvcl 4.0;\n\n\/* Module (VMOD) imports *\/\n# Standard module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_std.generated.html\nimport std;\n\n# Directors module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# Unused in simple configs.\n#import directors;\n\n\n#######################################################################\n# Probe, backend, ACL and subroutine definitions\n\n\/* Backend probes \/ healthchecks *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#probes\nprobe basic {\n \/* Only test that backend's IP serves content for '\/' *\/\n # This might be a too heavy probe\n # .url = \"\/\";\n\n \/* Only test that backend's IP has apache working *\/\n # Nginx would fail this probe with a default config\n .request =\n \"OPTIONS * HTTP\/1.1\"\n \"Host: *\"\n \"Connection: close\";\n\n \/* Common options *\/\n .interval = 10s;\n .timeout = 2s;\n .window = 8;\n .threshold = 6;\n}\n\n\/* Backend definitions.*\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#backend-definition\nbackend default {\n \/* Default backend on the same machine. *\/\n # WARNING: timeouts could be not big enought for certain POST requests.\n .host = \"127.0.0.1\";\n .port = \"8008\";\n .max_connections = 100;\n .connect_timeout = 60s;\n .first_byte_timeout = 60s;\n .between_bytes_timeout = 60s;\n .probe = basic;\n}\n\n\/* Access Control Lists *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#access-control-list-acl\nacl purge_ban {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use '\"localhost\";' instead\n}\nacl allowed_monitors {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n}\n# acl own_proxys {\n# \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n# }\n\n\/* Custom subroutines *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#subroutines\n#TODO# Test in Varnihs 4\n# Empty in simple configs.\n# The only restriction naming subs is that the 'vlc_' prefix is reserverd for\n# Varnish use. As a task can need several chunks of code in diferent states,\n# it's a good idea to identify what main sub will call each with a suffix.\n# \/* Example 301 client redirection removing \"www\" prefix from request *\/\n# sub perm_redirections_recv {\n# if ( req.http.host ~ \"^www.*$\" ) {\n# return (\n# synth(751, \"http:\/\/\" + regsub(req.http.host, \"^www\\.\", \"\") + req.url)\n# );\n# }\n# }\n# sub perm_redirections_synth {\n# if ( resp.status == 751 ) {\n# \/* Get new URL from the response *\/\n# set resp.http.Location = resp.response;\n# \/* Set HTTP 301 for permanent redirect *\/\n# set resp.status = 301;\n# return (deliver);\n# }\n# }\n\n\n#######################################################################\n# Client side\n\n# vcl_recv: Called at the beginning of a request, after the complete request\n# has been received and parsed. Its purpose is to decide whether or not to\n# serve the request, how to do it, and, if applicable, which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-recv\nsub vcl_recv {\n \/* 0th: general bypass, general return & authorization checks *\/\n # Empty in simple configs.\n # Useful for debugging we can pipe or pass the request to default backend\n # here to bypass completely Varnish.\n # return (pipe);\n # return (pass);\n # We can also return here a 200 Ok for network performance benchmarking.\n # return (synth(200, \"Ok\"));\n # Finally we can perform basic HTTP authentification here, by example.\n # SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* 1st: Check for Varnish special requests *\/ \n # Custom response implementation example in order to check that Varnish is\n # working properly.\n # This is usefull for automatic monitoring with monit or when Varnish is\n # behind another proxies like HAProxy.\n if ( ( req.http.host == \"monitor.server.health\"\n || req.http.host == \"health.varnish\" )\n && client.ip ~ allowed_monitors\n && ( req.method == \"OPTIONS\" || req.method == \"GET\" )\n ) {\n return (synth(200, \"Ban added\"));\n }\n # Purge logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#http-purging\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if ( req.method == \"PURGE\" ) {\n if ( client.ip !~ purge_ban ) {\n return (synth(405, \"Not allowed.\"));\n }\n return (purge);\n }\n # Ban logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#bans\n if ( req.method == \"BAN\" ) {\n if ( client.ip !~ purge_ban ) {\n return (synth(405, \"Not allowed.\"));\n }\n ban( \"req.http.host == \" + req.http.host +\n \"&& req.url == \" + req.url);\n return (synth(200, \"Ban added\"));\n }\n\n \/* 2nd: Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_recv;\n # Here we can also enforce SSL when Varnish run behind some SSL termination\n # point.\n\n \/* 3rd: Time for backend choice *\/\n # Empty in simple configs.\n\n \/* 4th: Prepare request for the backend *\/\n # Empty in simple configs.\n # Example remove own_proxys from X-Forwarded-For\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/whats-new\/upgrading.html#x-forwarded-for-is-now-set-before-vcl-recv\n # if ( req.restarts == 0\n # && client.ip ~ own_proxys\n # && req.http.x-forwarded-for\n # ) {\n # set req.http.X-Forwarded-For\n # = regsub(req.http.X-Forwarded-For, \",( )?\" + client.ip, \"\");\n # }\n # Example normalize the host header, remove the port (in case you're testing\n # this on various TCP ports)\n # set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n \/* 5th: Bypass breakpoint 1 *\/\n # Useful for debugging we can now pipe or pass the request to backend with\n # headers setted.\n # return (pipe);\n # return (pass);\n\n \/* 6th: Decide if we should deal with a request (mostly from built-in logic) *\/\n if ( req.method == \"PRI\" ) {\n \/* We do not support SPDY or HTTP\/2.0 *\/\n return (synth(405));\n }\n if ( req.method != \"GET\"\n && req.method != \"HEAD\"\n && req.method != \"PUT\"\n && req.method != \"POST\"\n && req.method != \"TRACE\"\n && req.method != \"OPTIONS\"\n && req.method != \"DELETE\"\n ) {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if ( req.method != \"GET\"\n && req.method != \"HEAD\"\n ) {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if ( req.http.Authorization ) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n # Websocket support\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html\n if ( req.http.Upgrade ~ \"(?i)websocket\" ) {\n return (pipe);\n }\n\n \/* 7th: Access control for some URLs by ACL *\/\n # Empty in simple configs.\n # By example denial some URLs depending on client-ip, we'll need to define\n # corresponding ACL 'internal'.\n # if ( req.url ~ \"^\/(cron|install)\\.php\"\n # && client.ip !~ internal\n # ) {\n # # Have Varnish throw the error directly.\n # return (synth(403, \"Forbidden.\"));\n # # Use a custom error page that you've defined in Drupal at the path \"404\".\n # # set req.url = \"\/403\";\n # }\n\n \/* 8th: Custom exceptions *\/\n # Host exception example:\n # if ( req.http.host == \"ejemplo.exception.com\" ) {\n # return (pass);\n # }\n # Drupal exceptions, edit if we want to cache some AJAX\/AHAH request.\n # Add here filters for never cache URLs such as Payment Gateway's callbacks.\n if ( req.url ~ \"^\/status\\.php$\"\n || req.url ~ \"^\/update\\.php$\"\n || req.url ~ \"^\/ooyala\/ping$\"\n || req.url ~ \"^\/admin\/build\/features\"\n || req.url ~ \"^\/info\/.*$\"\n || req.url ~ \"^\/flag\/.*$\"\n || req.url ~ \"^.*\/ajax\/.*$\"\n || req.url ~ \"^.*\/ahah\/.*$\"\n ) {\n \/* Do not cache these paths *\/\n return (pass);\n }\n # Pipe these paths directly to backend for streaming.\n if ( req.url ~ \"^\/admin\/content\/backup_migrate\/export\" ) {\n return (pipe);\n }\n if ( req.url ~ \"^\/system\/files\" ) {\n return (pipe);\n }\n\n \/* 9th: Graced objets & Serve from anonymous cahe if all backends are down *\/\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n # set req.http.grace = \"none\";\n if ( ! std.healthy(req.backend_hint) ) {\n # We must do this here since cookie hashing\n unset req.http.Cookie;\n #TODO# Add sick marker\n } \n\n \/* 10th: Deal with compression and the Accept-Encoding header *\/\n # Althought Varnish 3 handles gziped content itself by default, just to be\n # sure we want to remove Accept-Encoding for some compressed formats.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html#what-does-http-gzip-support-do\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/varnishd.html?highlight=http_gzip_support\n # See (for older configs) https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleNormalizeAcceptEncoding\n if ( req.http.Accept-Encoding ) {\n if ( req.url ~ \"(?i)\\.(7z|avi|bz2|flv|gif|gz|jpe?g|mpe?g|mk[av]|mov|mp[34]|og[gm]|pdf|png|rar|swf|tar|tbz|tgz|woff2?|zip|xz)(\\?.*)?$\"\n ) {\n \/* Already compressed formats, no sense trying to compress again *\/\n unset req.http.Accept-Encoding;\n }\n }\n\n \/* 11th: Another request manipulation *\/\n # Empty in simple configs.\n # We could add here a custom header grouping User-agent families.\n # Generic URL manipulation.\n # Remove Google Analytics added parameters, useless for our backends.\n if ( req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=\" ) {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n # Strip anchors, server doesn't need it.\n if ( req.url ~ \"\\#\" ) {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n # Strip a trailing ? if it exists\n if ( req.url ~ \"\\?$\" ) {\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n # Normalize the querystring arguments\n set req.url = std.querysort(req.url);\n\n \/* 12th: Cookie removal *\/\n # Always cache the following static file types for all users. \n # Use with care if we control certain downloads depending on cookies. \n # Be carefull also if appending .htm[l] via Drupal's clean URLs.\n if ( req.url ~ \"(?i)\\.(bz2|css|eot|gif|gz|html?|ico|jpe?g|js|mp3|ogg|otf|pdf|png|rar|svg|swf|tbz|tgz|ttf|woff2?|zip)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n && req.url !~ \"\/system\/storage\/serve\"\n ) {\n unset req.http.Cookie;\n }\n # Remove all cookies that backend doesn't need to know about.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRemovingSomeCookies\n if ( req.http.Cookie ) {\n \/* Warning: Not a pretty solution *\/\n # Prefix header containing cookies with ';'\n set req.http.Cookie = \";\" + req.http.Cookie;\n # Remove any spaces after ';' in header containing cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n # Prefix cookies we want to preserve with one space:\n # 'S{1,2}ESS[a-z0-9]+' is the regular expression matching a Drupal session\n # cookie ({1,2} added for HTTPS support).\n # 'NO_CACHE' is usually set after a POST request to make sure issuing user\n # see the results of his post.\n # 'OATMEAL' & 'CHOCOLATECHIP' are special cookies used by Drupal's Bakery\n # module to provide Single Sign On.\n # Keep in mind we should add here any cookie that should reach the backend\n # such as splash avoiding cookies.\n set req.http.Cookie\n = regsuball(\n req.http.Cookie,\n \";(S{1,2}ESS[a-z0-9]+|NO_CACHE|OATMEAL|CHOCOLATECHIP)=\",\n \"; \\1=\"\n );\n # Remove from the header any single Cookie not prefixed with a space until\n # next ';' separator.\n set req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n # Remove any '; ' at the start or the end of the header.\n set req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n #If there are no remaining cookies, remove the cookie header.\n if ( req.http.Cookie == \"\" ) {\n unset req.http.Cookie;\n }\n }\n\n \/* 13th: Session cookie & special cookies bypass caching stage *\/\n # As we might want to cache some requests, hashed with its cookies, we don't\n # simply pass when some cookies remain present at this point.\n # Instead we look for request that must be passed due to the cookie header.\n if ( req.http.Cookie ~ \"SESS\"\n || req.http.Cookie ~ \"SSESS\"\n || req.http.Cookie ~ \"NO_CACHE\"\n || req.http.Cookie ~ \"OATMEAL\"\n || req.http.Cookie ~ \"CHOCOLATECHIP\"\n ) {\n return (pass);\n }\n\n \/* 14th: Announce ESI Support *\/\n # Empty in simple configs.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/esi.html\n # Note that ESI included requests inherits its parent's modified request, so\n # depending on the case you will end playing with req.esi_level to know\n # current depth.\n # Send Surrogate-Capability headers\n # See http:\/\/www.w3.org\/TR\/edge-arch\n # Note that myproxyname is an identifier that should avoid collitions\n # set req.http.Surrogate-Capability = \"myproxyname=ESI\/1.0\";\n\n \/* 15th: Bypass breakpoint 2 *\/\n # Useful for debugging we can now pipe or pass the request to backend to\n # bypass cache.\n # return (pipe);\n # return (pass);\n\n \/* 16th: Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n return (hash);\n}\n\n# vcl_pipe: Called upon entering pipe mode.\n# In this mode, the request is passed on to the backend, and any further data\n# from either client or backend is passed on unaltered until either end closes\n# the connection.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pipe\nsub vcl_pipe {\n # Websocket support\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html\n if ( req.http.upgrade ) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n}\n# sub vcl_pipe {\n# # By default Connection: close is set on all piped requests, to stop\n# # connection reuse from sending future requests directly to the\n# # (potentially) wrong backend. If you do want this to happen, you can undo\n# # it here.\n# # unset bereq.http.connection;\n# return (pipe);\n# }\n\n# vcl_pass: Called upon entering pass mode. \n# In this mode, the request is passed on to the backend, and the backend's\n# response is passed on to the client, but is not entered into the cache.\n# Subsequent requests submitted over the same client connection are handled normally.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pass\n# sub vcl_pass {\n# return (fetch);\n# }\n\n# vcl_hash: You may call hash_data() on the data you would like to add to the\n# hash.\n# Hash is used by Varnish to uniquely identify objects.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hash\nsub vcl_hash {\n \/* Hash cookie data *\/\n # As requests with same URL and host can produce diferent results when issued\n # with different cookies, we need to store items hashed with the associated\n # cookies. Note that cookies are already sanitized when we reach this point.\n if ( req.http.Cookie ) {\n \/* Include cookie in cache hash *\/\n hash_data(req.http.Cookie);\n }\n\n \/* Custom header hashing *\/\n # Empty in simple configs.\n # Example for caching differents object versions by device previously\n # detected (when static content could also vary):\n # if ( req.http.X-UA-Device ) {\n # hash_data(req.http.X-UA-Device);\n # }\n # Example for caching diferent object versions by X-Forwarded-Proto, trying\n # to be smart about what kind of request could generate diffetent responses.\n if ( req.http.X-Forwarded-Proto\n && req.url !~ \"(?i)\\.(bz2|css|eot|gif|gz|html?|ico|jpe?g|js|mp3|ogg|otf|pdf|png|rar|svg|swf|tbz|tgz|ttf|woff2?|zip)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n ) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (lookup);\n# }\n\n# vcl_purge: Called after the purge has been executed and all its variants have\n# been evited.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-purge\n# sub vcl_purge {\n# return (synth(200, \"Purged\"));\n# }\n\n# vcl_hit: Called after a cache lookup if the requested document was found in\n# the cache.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hit\nsub vcl_hit {\n if ( obj.ttl >= 0s ) {\n \/\/ A pure unadultered hit, deliver it\n return (deliver);\n }\n \/* Allow varnish to serve up stale content if it is responding slowly *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n if ( obj.ttl + 60s > 0s ) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n set req.http.grace = \"normal\";\n return (deliver);\n }\n \/* Allow varish to serve up stale content if all backends are down *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n if ( ! std.healthy(req.backend_hint)\n && obj.ttl + obj.grace > 0s\n ) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n set req.http.grace = \"extended\";\n return (deliver);\n }\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\n# vcl_miss: Called after a cache lookup if the requested document was not found\n# in the cache.\n# Its purpose is to decide whether or not to attempt to retrieve the document\n# from the backend, and which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-miss\n# sub vcl_miss {\n# return (fetch);\n# }\n\n# vcl_deliver: Called before an object is delivered to the client\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-deliver\nsub vcl_deliver {\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # Add whether the object is a cache hit or miss and the number of hits for\n # the object.\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Addingaheaderindicatinghitmiss\n # In Varnish 4 the obj.hits counter behaviour has changed (see bug 1492), so\n # we use a different method: if X-Varnish contains only 1 id, we have a miss,\n # if it contains more (and therefore a space), we have a hit.\n if ( resp.http.x-varnish ~ \" \" ) {\n set resp.http.X-Cache = \"HIT\";\n # Since in Varnish 4 the behaviour of obj.hits changed, this might not be\n # accurate.\n # See https:\/\/www.varnish-cache.org\/trac\/ticket\/1492\n set resp.http.X-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Cache = \"MISS\";\n \/* Show the results of cookie sanitization *\/\n set resp.http.X-Cookie = req.http.Cookie;\n }\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n set resp.http.grace = req.http.grace;\n\n #TODO# Add sick marker\n\n # Restart count\n if ( req.restarts > 0 ) {\n set resp.http.X-Restarts = req.restarts;\n }\n\n # Add the Varnish server hostname\n set resp.http.X-Varnish-Server = server.hostname;\n # If we have setted a custom header with device's family detected we can show\n # it:\n # if ( req.http.X-UA-Device ) {\n # set resp.http.X-UA-Device = req.http.X-UA-Device;\n # }\n # If we have recived a custom header indicating the protocol in the request we\n # can show it:\n # if ( req.http.X-Forwarded-Proto ) {\n # set resp.http.X-Forwarded-Proto = req.http.X-Forwarded-Proto;\n # }\n\n \/* Vary header manipulation *\/\n # Empty in simple configs.\n # By example, if we are storing & serving diferent objects depending on\n # User-Agent header we must set the correct Vary header:\n # if ( resp.http.Vary ) {\n # set resp.http.Vary = resp.http.Vary + \",User-Agent\";\n # } else {\n # set resp.http.Vary = \"User-Agent\";\n # }\n\n \/* Fake headers *\/\n # Empty in simple configs\n # We can fake server headers here, by example:\n # set resp.http.Server = \"Deep thought\";\n # set resp.http.X-Powered-By = \"BOFH\";\n # Or have some fun with headers:\n # See http:\/\/www.nextthing.org\/archives\/2005\/08\/07\/fun-with-http-headers\n # See http:\/\/royal.pingdom.com\/2012\/08\/15\/fun-and-unusual-http-response-headers\/\n # set resp.http.X-Thank-You = \"for bothering to look at my HTTP headers\";\n # set resp.http.X-Answer = \"42\";\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_deliver {\n# return (deliver);\n# }\n\n# vcl_synth: Called to deliver a synthetic object. A synthetic object is\n# generated in VCL, not fetched from the backend. It is typically contructed\n# using the synthetic() function.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-synth\n\/*\n * We can come here \"invisibly\" with the following errors: 413, 417 & 503\n *\/\nsub vcl_synth {\n \/* Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_synth;\n\n \/* Try to restart request in case of failure *\/\n # Note that max_restarts defaults to 4\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if ( resp.status == 503\n && req.restarts < 4\n ) {\n return (restart);\n }\n\n \/* Set common headers for synthetic responses *\/\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n\n \/* HTTP Authentification client request *\/\n # Empty in simple configs.\n # SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* Load synthetic responses from disk *\/\n # Note that files loaded this way are never re-readed (even after a reload).\n # You should consider PROS\/CONS of doing an include instead.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_std.generated.html#func-fileread\n # Example custom 403 error page.\n # if ( resp.status == 403 ) {\n # synthetic(std.fileread(\"\/403.html\"));\n # return (deliver);\n # }\n\n \/* Error page & refresh \/ redirections *\/\n # We have plenty of choices when we have to serve an error to the client, \n # from the default error page to javascript black magic or plain redirections.\n # Adding some external statistic javascript to track failures served to\n # clients is strongly suggested.\n # We can't use external resources on synthetic content, everything must be\n # inlined.\n # If we need to include images we can embed them in base64 encoding.\n # We're using error 200 for monitoring puposes which should not be retried\n # client side.\n if ( resp.status != 200 ) {\n set resp.http.Retry-After = \"5\";\n }\n\n # Here is the default error page for Varnish 4 (not so pretty)\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n return (deliver);\n}\n\n#######################################################################\n# Backend Fetch\n\n# vcl_backend_fetch: Called before sending the backend request. In this\n# subroutine you typically alter the request before it gets to the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-fetch\n# sub vcl_backend_fetch {\n# return (fetch);\n# }\n\n# vcl_backend_response: Called after the response headers has been successfully\n# retrieved from the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-response\nsub vcl_backend_response {\n \/* Caching exceptions *\/\n # Varnish will cache objects with response codes:\n # 200, 203, 300, 301, 302, 307, 404 & 410.\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/VCL_Basics.html#the-initial-value-of-beresp-ttl\n # Drupal's Imagecache module can return a 307 redirection to the requested\n # url itself and, depending on Drupal's cache settings, this could lead to a\n # redirection loop being cached for a long time but also we want Varnish to\n # shield a little the backend.\n # See http:\/\/drupal.org\/node\/1248010\n # See http:\/\/drupal.org\/node\/310656\n if ( beresp.status == 307\n #TODO# verify that this work better than 'bereq.url ~ \"imagecache\"'\n && beresp.http.Location == bereq.url\n && beresp.ttl > 5s\n ) {\n set beresp.ttl = 5s;\n set beresp.http.cache-control = \"max-age=5\";\n }\n\n \/* Request retrial *\/\n if ( beresp.status == 500\n || beresp.status == 503\n ) {\n #TODO# consider not restarting POST requests as seenV3 on https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleSaintMode\n return (retry);\n }\n\n \/* Enable grace mode. Related with vcl_hit *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n set beresp.grace = 1h;\n\n \/* Strip cookies from the following static file types for all users. *\/\n # Related with our 12th stage on vcl_recv\n if ( bereq.url ~ \"(?i)\\.(bz2|css|eot|gif|gz|html?|ico|jpe?g|js|mp3|ogg|otf|pdf|png|rar|svg|swf|tbz|tgz|ttf|woff2?|zip)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n ) {\n unset beresp.http.set-cookie;\n }\n\n \/* Process ESI responses *\/\n # Empty in simple configs.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/esi.html\n # Send Surrogate-Capability headers\n # See http:\/\/www.w3.org\/TR\/edge-arch\n # Note that myproxyname is an identifier that should avoid collitions\n # Check for ESI acknowledgement and remove Surrogate-Control header\n #TODO# Add support for Surrogate-Control Targetting\n # if ( beresp.http.Surrogate-Control ~ \"ESI\/1.0\" ) {\n # unset beresp.http.Surrogate-Control;\n # set beresp.do_esi = true;\n # }\n\n \/* Gzip response *\/\n # Empty in simple configs.\n # Use Varnish to Gzip respone, if suitable, before storing it on cache.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html\n if ( ! beresp.http.Content-Encoding\n && ( beresp.http.content-type ~ \"text\"\n || beresp.http.content-type ~ \"application\/x-javascript\"\n || beresp.http.content-type ~ \"application\/javascript\"\n || beresp.http.content-type ~ \"application\/rss+xml\"\n || beresp.http.content-type ~ \"application\/xml\"\n || beresp.http.content-type ~ \"Application\/JSON\")\n ) {\n set beresp.do_gzip = true;\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # We can add the name of the backend that has processed the request:\n # set beresp.http.X-Backend = beresp.backend.name;\n # We can use a header to tell if the object was gziped by Varnish:\n # if ( beresp.do_gzip ) {\n # set beresp.http.X-Varnish-Gzipped = \"yes\";\n # } else {\n # set beresp.http.X-Varnish-Gizipped = \"no\";\n # }\n # We can also add headers informing whether the object is cacheable or not and why:\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Varnish3.0\n if ( beresp.ttl <= 0s ) {\n \/* Varnish determined the object was not cacheable *\/\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n } elsif ( bereq.http.Cookie ~ \"(SESS|SSESS|NO_CACHE|OATMEAL|CHOCOLATECHIP)\" ) {\n \/* We don't wish to cache content for logged in users or with certain cookies. *\/\n # Related with our 9th stage on vcl_recv\n set beresp.http.X-Cacheable = \"NO:Cookies\";\n # set beresp.uncacheable = true;\n } elsif ( beresp.http.Cache-Control ~ \"private\" ) {\n \/* We are respecting the Cache-Control=private header from the backend *\/\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n # set beresp.uncacheable = true;\n } else {\n \/* Varnish determined the object was cacheable *\/\n set beresp.http.X-Cacheable = \"YES\";\n }\n\n \/* Further header manipulation *\/\n # Empty in simple configs.\n # We can also unset some headers to prevent information disclosure and save\n # some cache space.\n # unset beresp.http.Server;\n # unset beresp.http.X-Powered-By;\n # Retry count.\n if ( bereq.retries > 0 ) {\n set beresp.http.X-Retries = bereq.retries;\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_backend_response {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Surrogate-control ~ \"no-store\" ||\n# (!beresp.http.Surrogate-Control &&\n# beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n# beresp.http.Vary == \"*\") {\n# \/*\n# * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# *\/\n# set beresp.ttl = 120s;\n# set beresp.uncacheable = true;\n# }\n# return (deliver);\n# }\n\n# vcl_backend_error: This subroutine is called if we fail the backend fetch.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-error\nsub vcl_backend_error {\n\n \/* Try to restart request in case of failure *\/\n #TODO# Confirm max_retries default value\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if ( bereq.retries < 4 ) {\n return (retry);\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # Retry count\n if ( bereq.retries > 0 ) {\n set beresp.http.X-Retries = bereq.retries;\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + beresp.status + \" \" + beresp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + beresp.status + \" \" + beresp.reason + {\"<\/h1>\n <p>\"} + beresp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + bereq.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this\n # point.\n return (deliver);\n}\n\n#######################################################################\n# Housekeeping\n\n# vcl_init: Called when VCL is loaded, before any requests pass through it.\n# Typically used to initialize VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-init\n# Here is where you should declare your directors now.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-backends.html#directors\n# Empty in simple configs\n# sub vcl_init {\n# return (ok);\n# }\n\n# vcl_fini: Called when VCL is discarded only after all requests have exited\n# the VCL. Typically used to clean up VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-fini\n# sub vcl_fini {\n# return (ok);\n# }\n\n","returncode":0,"stderr":"","license":"unknown","lang":"VCL"} {"commit":"40b19aeaa30020e97d5a8bb42d64794ad5572ab5","subject":"IO-346: httpoxy fix","message":"IO-346: httpoxy fix\n","repos":"telusdigital\/ansible-varnish","old_file":"templates\/etc\/varnish\/default.vcl","new_file":"templates\/etc\/varnish\/default.vcl","new_contents":"vcl 4.0;\n\n# {{ ansible_managed }}\n\nimport directors;\nimport std;\n\n###\n# Varnish Documentation\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-built-in-subs.html\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/reference\/vcl.html\n##\n\n{% for backend in varnish_backend_hosts %}\nbackend application_{{ loop.index }} {\n .host = \"{{ backend }}\";\n .port = \"{{ varnish_backend_port }}\";\n{% if varnish_health_checks_enabled %}\n .probe = {\n .url = \"{{ varnish_health_check_url }}\";\n .interval = {{ varnish_health_check_interval }};\n .timeout = {{ varnish_health_check_timeout }};\n .window = {{ varnish_health_check_window }};\n .threshold = {{ varnish_health_check_threshold }};\n }\n{% endif %}\n}\n{% endfor %}\n\n###\n# vcl_init\n# Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n###\n# The vcl_init subroutine may terminate with calling return() with one of the following keywords:\n#\n# ok\n# Normal return, VCL continues loading.\n##\n\nsub vcl_init {\n new application = directors.round_robin();\n{% for backend in varnish_backend_hosts %}\n application.add_backend(application_{{ loop.index }});\n{% endfor %}\n}\n\n###\n# vcl_recv\n# Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use.\n# It is also used to modify the request\n###\n# The vcl_recv subroutine may terminate with calling return() on one of the following keywords:\n#\n# synth(status code, reason)\n# Return a synthetic object with the specified status code to the client and abandon the request.\n# pass\n# Switch to pass mode. Control will eventually pass to vcl_pass.\n# pipe\n# Switch to pipe mode. Control will eventually pass to vcl_pipe.\n# hash\n# Continue processing the object as a potential candidate for caching. Passes the control over to vcl_hash.\n# purge\n# Purge the object and it's variants. Control passes through vcl_hash to vcl_purge.\n#\n\nsub vcl_recv {\n set req.backend_hint = application.backend();\n\n ###\n # Avoid processing uncacheable requests\n ###\n\n if (req.http.Authorization) {\n set req.http.X-Passthrough-Reason = \"No Caching Authenticated Content\";\n return (pass);\n }\n\n\n ###\n # Block httpoxy https:\/\/httpoxy.org\/\n ###\n unset req.http.proxy;\n\n{% if varnish_uri_blacklist_enabled %}\n if ((req.url ~ \"{{ varnish_uri_blacklist_regexp }}\")) {\n set req.http.X-Passthrough-Reason = \"Path in Blacklist\";\n return(pass);\n }\n{% endif %}\n\n{% if varnish_diagnostic_headers_forwarded_for %}\n ###\n # Inject X-Forwarded-For headers, but only once.\n ###\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_enabled %}\n ###\n # Cookie Sanitization\n ###\n if (req.http.Cookie) {\n set req.http.X-Cookie-Unmodified = req.http.Cookie;\n\n {% for cookie in varnish_cookie_sanitization_blacklist %}\n# set req.http.Cookie = regsuball(req.http.Cookie, \"{{ cookie }}=[^;]+(; )?\", \"\");\n {% endfor %}\n\n ### General Cleanup\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n if (req.http.Cookie ~ \"^\\s*$\") {\n set req.http.X-Cookie-Discarded = \"YES:Empty\";\n unset req.http.Cookie;\n }\n if (req.http.Cookie) {\n set req.http.X-Cookie-Sanitized = req.http.Cookie;\n }\n }\n{% endif %}\n\n{% if varnish_header_sanitization_enabled %}\n ###\n # Header Sanitization\n ###\n\n{% if varnish_header_sanitization_discard_host_port %}\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n{% endif %}\n\n{% if varnish_header_sanitization_normalize_accept_encoding %}\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n{% endif %}\n\n{% endif %}\n\n{% if varnish_uri_sanitization_enabled %}\n ###\n # URI Sanitization\n ###\n\n if (req.url ~ \"(\\?|&){{ varnish_uri_sanitization_regexp }}=\") {\n set req.url = regsuball(req.url, \"&{{ varnish_uri_sanitization_regexp }}=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?{{ varnish_uri_sanitization_regexp }}=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n{% endif %}\n\n{% if varnish_workaround_telusdotcom_browser_profile %}\n ###\n # Workaround and Diagnostics for BrowserProfile and Language\/Region Detection on TELUS.com\n ###\n\n if (req.http.Cookie ~ \"BrowserProfile\") {\n set req.http.X-BrowserProfile = regsuball(req.http.Cookie, \"(.*)BrowserProfile=([^;]*)(.*)\", \"\\2\");\n if (req.http.X-BrowserProfile ~ \"language\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.X-BrowserProfile, \"(.*)language\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n set req.http.X-Language-Found = \"YES:BrowserProfile\";\n }\n if (req.http.X-BrowserProfile ~ \"region\") {\n set req.http.X-Region = std.tolower(regsuball(regsuball(req.http.X-BrowserProfile, \"geo\\\\.\\:{(.*)\\}\", \"\"), \"(.*)region\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n set req.http.X-Region-Found = \"YES:BrowserProfile\";\n }\n if (req.http.X-BrowserProfile ~ \"geo\") {\n set req.http.X-Geolocation = regsuball(req.http.X-BrowserProfile, \"(.*)geo..:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n set req.http.X-Geolocation-Found = \"YES:BrowserProfile\";\n\n if (req.http.X-Geolocation ~ \"country\") {\n set req.http.X-Geolocation-Country = regsuball(req.http.X-Geolocation, \"(.*)country\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-Geolocation ~ \"region\") {\n set req.http.X-Geolocation-Region = regsuball(req.http.X-Geolocation, \"(.*)region\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-Geolocation ~ \"city\") {\n set req.http.X-Geolocation-City = regsuball(req.http.X-Geolocation, \"(.*)city\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-Geolocation ~ \"isp\") {\n set req.http.X-Geolocation-ISP = regsuball(req.http.X-Geolocation, \"(.*)isp\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n } else {\n set req.http.X-Geolocation-Found = \"NO\";\n }\n }\n\n if (!req.http.X-Language) {\n if (req.http.Cookie ~ \"lang=\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.Cookie, \"(.*)lang=([^;]*)(.*)\", \"\\2\"));\n set req.http.X-Language-Found = \"YES:lang\";\n } else {\n set req.http.X-Language = \"en\";\n set req.http.X-Language-Found = \"NO\";\n }\n }\n\n if (!req.http.X-Region) {\n if (req.http.Cookie ~ \"prov=\") {\n set req.http.X-Region = std.tolower(regsuball(req.http.Cookie, \"(.*)prov=([^;]*)(.*)\", \"\\2\"));\n set req.http.X-Region-Found = \"YES:prov\";\n } else {\n set req.http.X-Region = \"bc\";\n set req.http.X-Region-Found = \"NO\";\n }\n }\n\n\n if (req.url ~ \"\/(en|fr)\/\") {\n if (req.url ~ \"\/en\/\" && req.http.X-Language != \"en\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Language (Path: \/en\/) vs (Cookie: \" + req.http.X-Language + \")\";\n return(pass);\n }\n if (req.url ~ \"\/fr\/\" && req.http.X-Language != \"fr\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Language (Path: \/fr\/) vs (Cookie: \" + req.http.X-Language + \")\";\n return(pass);\n }\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Language)\";\n return(pass);\n }\n\n if (req.url ~ \"\/(ab|bc|mb|nb|nl|ns|nt|nu|on|pe|qc|sk|yt)\/\") {\n {% for province in ['ab', 'bc', 'mb', 'nb', 'nl', 'ns', 'nt', 'nu', 'on', 'pe', 'qc', 'sk', 'yt'] %}\n if (req.url ~ \"\/{{ province }}\/\" && req.http.X-Region != \"{{ province }}\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Region (Path: \/{{ province }}\/) vs (Cookie: \" + req.http.X-Region + \")\";\n return(pass);\n }\n {% endfor %}\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Province)\";\n return(pass);\n }\n\n if (req.http.Cookie) {\n if (req.http.Cookie ~ \"resolution\") {\n set req.http.X-Screen-Resolution = regsuball(req.http.Cookie, \"(.*)resolution=([^;]*)(.*)\", \"\\2\");\n }\n\n if (req.http.Cookie ~ \"CustomerType\") {\n set req.http.X-Customer-Type = regsuball(req.http.Cookie, \"(.*)CustomerType=([^;]*)(.*)\", \"\\2\");\n }\n if (req.http.Cookie ~ \"outdated-browser-notification\") {\n set req.http.X-Outdated-Browser = regsuball(req.http.Cookie, \"(.*)outdated-browser-notification=([^;]*)(.*)\", \"\\2\");\n }\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_discard_from_client %}\n set req.http.X-Cookie-Discarded = \"YES:No Reason Not To\";\n unset req.http.Cookie;\n{% endif %}\n}\n\n###\n# vcl_hit\n# Called when a cache lookup is successful.\n###\n# The vcl_hit subroutine may terminate with calling return() with one of the following keywords:\n#\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n# deliver\n# Deliver the object. Control passes to vcl_deliver.\n# synth(status code, reason)\n# Return the specified status code to the client and abandon the request.\n###\n\nsub vcl_hit {\n if (obj.ttl > 0s) {\n return (deliver);\n }\n{% if varnish_health_checks_enabled %}\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (fetch);\n }\n{% else %}\n if (obj.ttl + obj.grace > 0s) {\n return (deliver);\n }\n\n return (fetch);\n{% endif %}\n}\n\n###\n# vcl_backend_response\n# Called after the response headers has been successfully retrieved from the backend.\n###\n# The vcl_backend_response subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Possibly insert the object into the cache, then deliver it to the Control will eventually pass to vcl_deliver.\n# abandon\n# Abandon the backend request and generates an error.\n# retry\n# Retry the backend transaction. Increases the retries counter. If the number of retries is higher than max_retries Varnish emits a guru meditation error.\n###\n\nsub vcl_backend_response {\n{% if varnish_workaround_telusdotcom_browser_profile %}\n if (bereq.http.X-Language) {\n set beresp.http.X-Language = bereq.http.X-Language;\n# if (bereq.http.X-Language-Found) {\n# set beresp.http.X-Language-Found = bereq.http.X-Language-Found;\n# }\n }\n if (bereq.http.X-Region) {\n set beresp.http.X-Region = bereq.http.X-Region;\n# if (bereq.http.X-Region-Found) {\n# set beresp.http.X-Region-Found = bereq.http.X-Region-Found;\n# }\n }\n{% endif %}\n\n{% if varnish_uri_blacklist_enabled %}\n if (bereq.url ~ \"{{ varnish_uri_blacklist_regexp }}\") {\n set beresp.http.X-Cacheable = \"NO:Path in Blacklist\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n if (bereq.http.X-Passthrough-Reason) {\n{% if varnish_diagnostic_headers_passthrough_reason %}\n set beresp.http.X-Passthrough-Reason = bereq.http.X-Passthrough-Reason;\n{% endif %}\n return(deliver);\n } else {\n{% if varnish_cookie_sanitization_discard_from_server %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n }\n }\n{% else %}\n{% if varnish_cookie_sanitization_discard_from_server %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n{% endif %}\n\n{% if varnish_diagnostic_headers_enabled %}\n if (bereq.http.Cookie) {\n set beresp.http.X-Cacheable = \"NO:Cookie in Request\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO:Set-Cookie in Response\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.X-No-Cache) {\n set beresp.http.X-Cacheable = \"NO:X-No-Cache\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.ttl <= 0s) {\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n{% endif %}\n\n set beresp.grace = {{ varnish_grace_period }};\n}\n\n###\n# vcl_deliver\n# Called before a cached object is delivered to the client.\n###\n# The vcl_deliver subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Deliver the object to the client.\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n###\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n","old_contents":"vcl 4.0;\n\n# {{ ansible_managed }}\n\nimport directors;\nimport std;\n\n###\n# Varnish Documentation\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-built-in-subs.html\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/reference\/vcl.html\n##\n\n{% for backend in varnish_backend_hosts %}\nbackend application_{{ loop.index }} {\n .host = \"{{ backend }}\";\n .port = \"{{ varnish_backend_port }}\";\n{% if varnish_health_checks_enabled %}\n .probe = {\n .url = \"{{ varnish_health_check_url }}\";\n .interval = {{ varnish_health_check_interval }};\n .timeout = {{ varnish_health_check_timeout }};\n .window = {{ varnish_health_check_window }};\n .threshold = {{ varnish_health_check_threshold }};\n }\n{% endif %}\n}\n{% endfor %}\n\n###\n# vcl_init\n# Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n###\n# The vcl_init subroutine may terminate with calling return() with one of the following keywords:\n#\n# ok\n# Normal return, VCL continues loading.\n##\n\nsub vcl_init {\n new application = directors.round_robin();\n{% for backend in varnish_backend_hosts %}\n application.add_backend(application_{{ loop.index }});\n{% endfor %}\n}\n\n###\n# vcl_recv\n# Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use.\n# It is also used to modify the request\n###\n# The vcl_recv subroutine may terminate with calling return() on one of the following keywords:\n#\n# synth(status code, reason)\n# Return a synthetic object with the specified status code to the client and abandon the request.\n# pass\n# Switch to pass mode. Control will eventually pass to vcl_pass.\n# pipe\n# Switch to pipe mode. Control will eventually pass to vcl_pipe.\n# hash\n# Continue processing the object as a potential candidate for caching. Passes the control over to vcl_hash.\n# purge\n# Purge the object and it's variants. Control passes through vcl_hash to vcl_purge.\n#\n\nsub vcl_recv {\n set req.backend_hint = application.backend();\n\n ###\n # Avoid processing uncacheable requests\n ###\n\n if (req.http.Authorization) {\n set req.http.X-Passthrough-Reason = \"No Caching Authenticated Content\";\n return (pass);\n }\n\n{% if varnish_uri_blacklist_enabled %}\n if ((req.url ~ \"{{ varnish_uri_blacklist_regexp }}\")) {\n set req.http.X-Passthrough-Reason = \"Path in Blacklist\";\n return(pass);\n }\n{% endif %}\n\n{% if varnish_diagnostic_headers_forwarded_for %}\n ###\n # Inject X-Forwarded-For headers, but only once.\n ###\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_enabled %}\n ###\n # Cookie Sanitization\n ###\n if (req.http.Cookie) {\n set req.http.X-Cookie-Unmodified = req.http.Cookie;\n\n {% for cookie in varnish_cookie_sanitization_blacklist %}\n# set req.http.Cookie = regsuball(req.http.Cookie, \"{{ cookie }}=[^;]+(; )?\", \"\");\n {% endfor %}\n\n ### General Cleanup\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n if (req.http.Cookie ~ \"^\\s*$\") {\n set req.http.X-Cookie-Discarded = \"YES:Empty\";\n unset req.http.Cookie;\n }\n if (req.http.Cookie) {\n set req.http.X-Cookie-Sanitized = req.http.Cookie;\n }\n }\n{% endif %}\n\n{% if varnish_header_sanitization_enabled %}\n ###\n # Header Sanitization\n ###\n\n{% if varnish_header_sanitization_discard_host_port %}\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n{% endif %}\n\n{% if varnish_header_sanitization_normalize_accept_encoding %}\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n{% endif %}\n\n{% endif %}\n\n{% if varnish_uri_sanitization_enabled %}\n ###\n # URI Sanitization\n ###\n\n if (req.url ~ \"(\\?|&){{ varnish_uri_sanitization_regexp }}=\") {\n set req.url = regsuball(req.url, \"&{{ varnish_uri_sanitization_regexp }}=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?{{ varnish_uri_sanitization_regexp }}=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n{% endif %}\n\n{% if varnish_workaround_telusdotcom_browser_profile %}\n ###\n # Workaround and Diagnostics for BrowserProfile and Language\/Region Detection on TELUS.com\n ###\n\n if (req.http.Cookie ~ \"BrowserProfile\") {\n set req.http.X-BrowserProfile = regsuball(req.http.Cookie, \"(.*)BrowserProfile=([^;]*)(.*)\", \"\\2\");\n if (req.http.X-BrowserProfile ~ \"language\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.X-BrowserProfile, \"(.*)language\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n set req.http.X-Language-Found = \"YES:BrowserProfile\";\n }\n if (req.http.X-BrowserProfile ~ \"region\") {\n set req.http.X-Region = std.tolower(regsuball(regsuball(req.http.X-BrowserProfile, \"geo\\\\.\\:{(.*)\\}\", \"\"), \"(.*)region\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n set req.http.X-Region-Found = \"YES:BrowserProfile\";\n }\n if (req.http.X-BrowserProfile ~ \"geo\") {\n set req.http.X-Geolocation = regsuball(req.http.X-BrowserProfile, \"(.*)geo..:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n set req.http.X-Geolocation-Found = \"YES:BrowserProfile\";\n\n if (req.http.X-Geolocation ~ \"country\") {\n set req.http.X-Geolocation-Country = regsuball(req.http.X-Geolocation, \"(.*)country\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-Geolocation ~ \"region\") {\n set req.http.X-Geolocation-Region = regsuball(req.http.X-Geolocation, \"(.*)region\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-Geolocation ~ \"city\") {\n set req.http.X-Geolocation-City = regsuball(req.http.X-Geolocation, \"(.*)city\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-Geolocation ~ \"isp\") {\n set req.http.X-Geolocation-ISP = regsuball(req.http.X-Geolocation, \"(.*)isp\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n } else {\n set req.http.X-Geolocation-Found = \"NO\";\n }\n }\n\n if (!req.http.X-Language) {\n if (req.http.Cookie ~ \"lang=\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.Cookie, \"(.*)lang=([^;]*)(.*)\", \"\\2\"));\n set req.http.X-Language-Found = \"YES:lang\";\n } else {\n set req.http.X-Language = \"en\";\n set req.http.X-Language-Found = \"NO\";\n }\n }\n\n if (!req.http.X-Region) {\n if (req.http.Cookie ~ \"prov=\") {\n set req.http.X-Region = std.tolower(regsuball(req.http.Cookie, \"(.*)prov=([^;]*)(.*)\", \"\\2\"));\n set req.http.X-Region-Found = \"YES:prov\";\n } else {\n set req.http.X-Region = \"bc\";\n set req.http.X-Region-Found = \"NO\";\n }\n }\n\n\n if (req.url ~ \"\/(en|fr)\/\") {\n if (req.url ~ \"\/en\/\" && req.http.X-Language != \"en\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Language (Path: \/en\/) vs (Cookie: \" + req.http.X-Language + \")\";\n return(pass);\n }\n if (req.url ~ \"\/fr\/\" && req.http.X-Language != \"fr\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Language (Path: \/fr\/) vs (Cookie: \" + req.http.X-Language + \")\";\n return(pass);\n }\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Language)\";\n return(pass);\n }\n\n if (req.url ~ \"\/(ab|bc|mb|nb|nl|ns|nt|nu|on|pe|qc|sk|yt)\/\") {\n {% for province in ['ab', 'bc', 'mb', 'nb', 'nl', 'ns', 'nt', 'nu', 'on', 'pe', 'qc', 'sk', 'yt'] %}\n if (req.url ~ \"\/{{ province }}\/\" && req.http.X-Region != \"{{ province }}\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Region (Path: \/{{ province }}\/) vs (Cookie: \" + req.http.X-Region + \")\";\n return(pass);\n }\n {% endfor %}\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Province)\";\n return(pass);\n }\n\n if (req.http.Cookie) {\n if (req.http.Cookie ~ \"resolution\") {\n set req.http.X-Screen-Resolution = regsuball(req.http.Cookie, \"(.*)resolution=([^;]*)(.*)\", \"\\2\");\n }\n\n if (req.http.Cookie ~ \"CustomerType\") {\n set req.http.X-Customer-Type = regsuball(req.http.Cookie, \"(.*)CustomerType=([^;]*)(.*)\", \"\\2\");\n }\n if (req.http.Cookie ~ \"outdated-browser-notification\") {\n set req.http.X-Outdated-Browser = regsuball(req.http.Cookie, \"(.*)outdated-browser-notification=([^;]*)(.*)\", \"\\2\");\n }\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_discard_from_client %}\n set req.http.X-Cookie-Discarded = \"YES:No Reason Not To\";\n unset req.http.Cookie;\n{% endif %}\n}\n\n###\n# vcl_hit\n# Called when a cache lookup is successful.\n###\n# The vcl_hit subroutine may terminate with calling return() with one of the following keywords:\n#\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n# deliver\n# Deliver the object. Control passes to vcl_deliver.\n# synth(status code, reason)\n# Return the specified status code to the client and abandon the request.\n###\n\nsub vcl_hit {\n if (obj.ttl > 0s) {\n return (deliver);\n }\n{% if varnish_health_checks_enabled %}\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (fetch);\n }\n{% else %}\n if (obj.ttl + obj.grace > 0s) {\n return (deliver);\n }\n\n return (fetch);\n{% endif %}\n}\n\n###\n# vcl_backend_response\n# Called after the response headers has been successfully retrieved from the backend.\n###\n# The vcl_backend_response subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Possibly insert the object into the cache, then deliver it to the Control will eventually pass to vcl_deliver.\n# abandon\n# Abandon the backend request and generates an error.\n# retry\n# Retry the backend transaction. Increases the retries counter. If the number of retries is higher than max_retries Varnish emits a guru meditation error.\n###\n\nsub vcl_backend_response {\n{% if varnish_workaround_telusdotcom_browser_profile %}\n if (bereq.http.X-Language) {\n set beresp.http.X-Language = bereq.http.X-Language;\n# if (bereq.http.X-Language-Found) {\n# set beresp.http.X-Language-Found = bereq.http.X-Language-Found;\n# }\n }\n if (bereq.http.X-Region) {\n set beresp.http.X-Region = bereq.http.X-Region;\n# if (bereq.http.X-Region-Found) {\n# set beresp.http.X-Region-Found = bereq.http.X-Region-Found;\n# }\n }\n{% endif %}\n\n{% if varnish_uri_blacklist_enabled %}\n if (bereq.url ~ \"{{ varnish_uri_blacklist_regexp }}\") {\n set beresp.http.X-Cacheable = \"NO:Path in Blacklist\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n if (bereq.http.X-Passthrough-Reason) {\n{% if varnish_diagnostic_headers_passthrough_reason %}\n set beresp.http.X-Passthrough-Reason = bereq.http.X-Passthrough-Reason;\n{% endif %}\n return(deliver);\n } else {\n{% if varnish_cookie_sanitization_discard_from_server %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n }\n }\n{% else %}\n{% if varnish_cookie_sanitization_discard_from_server %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n{% endif %}\n\n{% if varnish_diagnostic_headers_enabled %}\n if (bereq.http.Cookie) {\n set beresp.http.X-Cacheable = \"NO:Cookie in Request\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO:Set-Cookie in Response\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.X-No-Cache) {\n set beresp.http.X-Cacheable = \"NO:X-No-Cache\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.ttl <= 0s) {\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n{% endif %}\n\n set beresp.grace = {{ varnish_grace_period }};\n}\n\n###\n# vcl_deliver\n# Called before a cached object is delivered to the client.\n###\n# The vcl_deliver subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Deliver the object to the client.\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n###\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"f746cc4455d599d6053f0837e81b8330f8379e63","subject":"Indentation","message":"Indentation\n","repos":"hansjorg\/rust-ci,youprofit\/rust-ci-1,youprofit\/rust-ci-1,youprofit\/rust-ci-1,hansjorg\/rust-ci,youprofit\/rust-ci-1","old_file":"config\/varnish\/rust-ci.vcl","new_file":"config\/varnish\/rust-ci.vcl","new_contents":"# Varnish VCL config for www.rust-ci.org\n\nbackend nginx {\n .host = \"127.0.0.1\";\n .port = \"8000\";\n}\n\nacl purge {\n \"localhost\";\n}\n\nsub vcl_recv {\n set req.backend = nginx;\n\n if ((req.url ~ \"\/p\/\") || (req.url ~ \"\/admin\") || (req.url ~ \"\/artifacts\") || (req.url ~ \"\/callback\")) {\n return(pass);\n }\n\n # Normalize host header (for test env)\n set req.http.Host = \"www.rust-ci.org\";\n\n # Remove cookies from request\n unset req.http.cookie;\n\n if (req.request == \"PURGE\") {\n # Ignore query string (python-varnish adds \"?\" to PURGE URLs)\n set req.url = regsub(req.url, \"\\?.*$\", \"\");\n if (!client.ip ~ purge) {\n error 405 \"Not allowed.\";\n }\n return (lookup);\n }\n}\n\nsub vcl_hash {\n\n # All the project\/doc\/.* static files are the same, except for search-index.js\n # Normalize the hashed req.url so that these files are only fetched once from S3\n\n if (req.url ~ \"doc\\\/[^.]*\\.(woff|css|js)$\" && req.url !~ \"search-index.js$\") {\n hash_data(regsub(req.url, \"(.*)\\\/doc\", \"\/normalized\"));\n } else {\n hash_data(req.url);\n }\n\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n return (hash);\n}\n\nsub vcl_hit {\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged.\";\n }\n}\n\nsub vcl_miss {\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged.\";\n }\n}\n\nsub vcl_fetch {\n # Remove set-cookie from backend response\n if (!(req.url ~ \"\/p\/\") && !(req.url ~ \"\/admin\") && !(req.url ~ \"\/artifacts\") && !(req.url ~ \"\/callback\")) {\n unset beresp.http.set-cookie;\n }\n\n # Remove Expires from backend\n unset beresp.http.expires;\n\n # Set the clients TTL on this object\n if (req.url ~ \"^\/static\") {\n set beresp.http.cache-control = \"max-age=31536000\";\n } else {\n set beresp.http.cache-control = \"max-age=0\";\n }\n\n # Set how long Varnish will keep it\n set beresp.ttl = 10w;\n\n # marker for vcl_deliver to reset Age:\n set beresp.http.magicmarker = \"1\";\n}\n\nsub vcl_deliver {\n if (resp.http.magicmarker) {\n # Remove the magic marker\n unset resp.http.magicmarker;\n\n # By definition we have a fresh object\n set resp.http.age = \"0\";\n }\n\n # Set HIT\/MISS indicator\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n\n","old_contents":"# Varnish VCL config for www.rust-ci.org\n\nbackend nginx {\n .host = \"127.0.0.1\";\n .port = \"8000\";\n}\n\nacl purge {\n \"localhost\";\n}\n\nsub vcl_recv {\n set req.backend = nginx;\n\n if ((req.url ~ \"\/p\/\") || (req.url ~ \"\/admin\") || (req.url ~ \"\/artifacts\") || (req.url ~ \"\/callback\")) {\n return(pass);\n }\n\n # Normalize host header (for test env)\n set req.http.Host = \"www.rust-ci.org\";\n\n # Remove cookies from request\n unset req.http.cookie;\n\n if (req.request == \"PURGE\") {\n # Ignore query string (python-varnish adds \"?\" to PURGE URLs)\n set req.url = regsub(req.url, \"\\?.*$\", \"\");\n if (!client.ip ~ purge) {\n error 405 \"Not allowed.\";\n }\n return (lookup);\n }\n}\n\nsub vcl_hash {\n\n\t# All the project\/doc\/.* static files are the same, except for search-index.js\n\t# Normalize the hashed req.url so that these files are only fetched once from S3\n\n\tif (req.url ~ \"doc\\\/[^.]*\\.(woff|css|js)$\" && req.url !~ \"search-index.js$\") {\n\t\thash_data(regsub(req.url, \"(.*)\\\/doc\", \"\/normalized\"));\n\t} else {\n\t\thash_data(req.url);\n\t}\n\n\tif (req.http.host) {\n\t\t\thash_data(req.http.host);\n\t} else {\n\t\t\thash_data(server.ip);\n\t}\n\treturn (hash);\n}\n\nsub vcl_hit {\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged.\";\n }\n}\n\nsub vcl_miss {\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged.\";\n }\n}\n\nsub vcl_fetch {\n # Remove set-cookie from backend response\n if (!(req.url ~ \"\/p\/\") && !(req.url ~ \"\/admin\") && !(req.url ~ \"\/artifacts\") && !(req.url ~ \"\/callback\")) {\n unset beresp.http.set-cookie;\n }\n\n # Remove Expires from backend\n unset beresp.http.expires;\n\n # Set the clients TTL on this object\n if (req.url ~ \"^\/static\") {\n set beresp.http.cache-control = \"max-age=31536000\";\n } else {\n set beresp.http.cache-control = \"max-age=0\";\n }\n\n # Set how long Varnish will keep it\n set beresp.ttl = 10w;\n\n # marker for vcl_deliver to reset Age:\n set beresp.http.magicmarker = \"1\";\n}\n\nsub vcl_deliver {\n if (resp.http.magicmarker) {\n # Remove the magic marker\n unset resp.http.magicmarker;\n\n # By definition we have a fresh object\n set resp.http.age = \"0\";\n }\n\n # Set HIT\/MISS indicator\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"2cbf8fe9df0b4c11925fd122c458519a93ee2979","subject":"basic ESI support example","message":"basic ESI support example\n","repos":"NITEMAN\/varnish-bites,NITEMAN\/Varnish_VCL_samps-hacks","old_file":"varnish4\/drupal-base.vcl","new_file":"varnish4\/drupal-base.vcl","new_contents":"\/*\n * Varnish 4 example config for Drupal 7 \/ Pressflow 6 & 7\n *\/\n\n# Original source: https:\/\/github.com\/NITEMAN\/varnish-bites\/varnish4\/drupal-base.vcl\n# Copyright (c) 2015 Pedro Gonz\u00e1lez Serrano and individual contributors.\n# MIT License\n\n# Intended to be used both in simple production environments and with\n# learning\/teaching purposes.\n# Some references may not be yet updated to VCL 4.0, we use SeeV3 then.\n\n# WARNING:\n# Note that the built-in logic will be appended to our code if no return is\n# performed before.\n# Built-in logic is included commented out right after our's for reference\n# purposes in that cases.\n# See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleDefault\n\n#######################################################################\n# Initialization: Version & imports;\n\n\/* Version statement *\/\n# Since Varnish 4.0 it's mandatory to declare VCL version on first line.\nvcl 4.0;\n\n\/* Module (VMOD) imports *\/\n# Standard module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_std.generated.html\nimport std;\n\n# Directors module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# Unused in simple configs.\n#import directors;\n\n\n#######################################################################\n# Probe, backend, ACL and subroutine definitions\n\n\/* Backend probes \/ healthchecks *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#probes\nprobe basic {\n \/* Only test that backend's IP serves content for '\/' *\/\n # This might be a too heavy probe\n # .url = \"\/\";\n\n \/* Only test that backend's IP has apache working *\/\n # Nginx would fail this probe with a default config\n .request =\n \"OPTIONS * HTTP\/1.1\"\n \"Host: *\"\n \"Connection: close\";\n\n \/* Common options *\/\n .interval = 10s;\n .timeout = 2s;\n .window = 8;\n .threshold = 6;\n}\n\n\/* Backend definitions.*\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#backend-definition\nbackend default {\n \/* Default backend on the same machine. *\/\n # WARNING: timeouts could be not big enought for certain POST requests.\n .host = \"127.0.0.1\";\n .port = \"8008\";\n .max_connections = 100;\n .connect_timeout = 60s;\n .first_byte_timeout = 60s;\n .between_bytes_timeout = 60s;\n .probe = basic;\n}\n\n\/* Access Control Lists *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#access-control-list-acl\nacl purge_ban {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use '\"localhost\";' instead\n}\nacl allowed_monitors {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n}\n# acl own_proxys {\n# \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n# }\n\n\/* Custom subroutines *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#subroutines\n#TODO# Test in Varnihs 4\n# Empty in simple configs.\n# The only restriction naming subs is that the 'vlc_' prefix is reserverd for\n# Varnish use. As a task can need several chunks of code in diferent states,\n# it's a good idea to identify what main sub will call each with a suffix.\n# \/* Example 301 client redirection removing \"www\" prefix from request *\/\n# sub perm_redirections_recv {\n# if ( req.http.host ~ \"^www.*$\" ) {\n# return(\n# synth(751, \"http:\/\/\" + regsub(req.http.host, \"^www\\.\", \"\") + req.url)\n# );\n# }\n# }\n# sub perm_redirections_synth {\n# if (resp.status == 751) {\n# \/* Get new URL from the response *\/\n# set resp.http.Location = resp.response;\n# \/* Set HTTP 301 for permanent redirect *\/\n# set resp.status = 301;\n# return (deliver);\n# }\n# }\n\n\n#######################################################################\n# Client side\n\n# vcl_recv: Called at the beginning of a request, after the complete request\n# has been received and parsed. Its purpose is to decide whether or not to\n# serve the request, how to do it, and, if applicable, which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-recv\nsub vcl_recv {\n \/* 0th: general bypass, general return & authorization checks *\/\n # Empty in simple configs.\n # Useful for debugging we can pipe or pass the request to default backend\n # here to bypass completely Varnish.\n # return (pipe);\n # return (pass);\n # We can also return here a 200 Ok for network performance benchmarking.\n # return(synth(200, \"Ok\"));\n # Finally we can perform basic HTTP authentification here, by example.\n # SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* 1st: Check for Varnish special requests *\/ \n # Custom response implementation example in order to check that Varnish is\n # working properly.\n # This is usefull for automatic monitoring with monit or when Varnish is\n # behind another proxies like HAProxy.\n if ( ( req.http.host == \"monitor.server.health\"\n || req.http.host == \"health.varnish\" )\n && client.ip ~ allowed_monitors\n && ( req.method == \"OPTIONS\" || req.method == \"GET\" )\n ) {\n return(synth(200, \"Ban added\"));\n }\n # Purge logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#http-purging\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if ( req.method == \"PURGE\" ) {\n if ( ! client.ip ~ purge_ban ) {\n return(synth(405, \"Not allowed.\"));\n }\n return (purge);\n }\n # Ban logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#bans\n if ( req.method == \"BAN\" ) {\n if ( ! client.ip ~ purge_ban ) {\n return(synth(405, \"Not allowed.\"));\n }\n ban( \"req.http.host == \" + req.http.host +\n \"&& req.url == \" + req.url);\n return(synth(200, \"Ban added\"));\n }\n\n \/* 2nd: Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_recv;\n # Here we can also enforce SSL when Varnish run behind some SSL termination\n # point.\n\n \/* 3rd: Time for backend choice *\/\n # Empty in simple configs.\n\n \/* 4th: Prepare request for the backend *\/\n # Empty in simple configs.\n # Example remove own_proxys from X-Forwarded-For\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/whats-new\/upgrading.html#x-forwarded-for-is-now-set-before-vcl-recv\n # if ( req.restarts == 0\n # && client.ip ~ own_proxys\n # && req.http.x-forwarded-for\n # ) {\n # set req.http.X-Forwarded-For\n # = regsub(req.http.X-Forwarded-For, \",( )?\" + client.ip, \"\");\n # }\n # Example normalize the host header, remove the port (in case you're testing\n # this on various TCP ports)\n # set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n \/* 5th: Bypass breakpoint 1 *\/\n # Useful for debugging we can now pipe or pass the request to backend with\n # headers setted.\n # return (pipe);\n # return (pass);\n\n \/* 6th: Decide if we should deal with a request (mostly from built-in logic) *\/\n if (req.method == \"PRI\") {\n \/* We do not support SPDY or HTTP\/2.0 *\/\n return (synth(405));\n }\n if ( req.method != \"GET\"\n && req.method != \"HEAD\"\n && req.method != \"PUT\"\n && req.method != \"POST\"\n && req.method != \"TRACE\"\n && req.method != \"OPTIONS\"\n && req.method != \"DELETE\"\n ) {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n # Websocket support\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n \/* 7th: Access control for some URLs by ACL *\/\n # Empty in simple configs.\n # By example denial some URLs depending on client-ip, we'll need to define\n # corresponding ACL 'internal'.\n # if ( req.url ~ \"^\/(cron|install)\\.php\"\n # && ! client.ip ~ internal\n # ) {\n # # Have Varnish throw the error directly.\n # return(synth(403, \"Forbidden.\"));\n # # Use a custom error page that you've defined in Drupal at the path \"404\".\n # # set req.url = \"\/403\";\n # }\n\n \/* 8th: Custom exceptions *\/\n # Host exception example:\n # if (req.http.host == \"ejemplo.exception.com\") {\n # return (pass);\n # }\n # Drupal exceptions, edit if we want to cache some AJAX\/AHAH request.\n # Add here filters for never cache URLs such as Payment Gateway's callbacks.\n if ( req.url ~ \"^\/status\\.php$\"\n || req.url ~ \"^\/update\\.php$\"\n || req.url ~ \"^\/ooyala\/ping$\"\n || req.url ~ \"^\/admin\/build\/features\"\n || req.url ~ \"^\/info\/.*$\"\n || req.url ~ \"^\/flag\/.*$\"\n || req.url ~ \"^.*\/ajax\/.*$\"\n || req.url ~ \"^.*\/ahah\/.*$\"\n ) {\n \/* Do not cache these paths *\/\n return (pass);\n }\n # Pipe these paths directly to backend for streaming.\n if (req.url ~ \"^\/admin\/content\/backup_migrate\/export\") {\n return (pipe);\n }\n if (req.url ~ \"^\/system\/files\") {\n return (pipe);\n }\n\n \/* 9th: Graced objets & Serve from anonymous cahe if all backends are down *\/\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n # set req.http.grace = \"none\";\n if ( ! std.healthy(req.backend_hint) ) {\n # We must do this here since cookie hashing\n unset req.http.Cookie;\n #TODO# Add sick marker\n } \n\n \/* 10th: Deal with compression and the Accept-Encoding header *\/\n # Althought Varnish 3 handles gziped content itself by default, just to be\n # sure we want to remove Accept-Encoding for some compressed formats.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html#what-does-http-gzip-support-do\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/varnishd.html?highlight=http_gzip_support\n # See (for older configs) https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleNormalizeAcceptEncoding\n if (req.http.Accept-Encoding) {\n if ( req.url\n ~ \"\\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|mp4|flv|zip|rar)$\"\n ) {\n \/* Already compressed formats, no sense trying to compress again *\/\n unset req.http.Accept-Encoding;\n }\n }\n\n \/* 11th: Another request manipulation *\/\n # Empty in simple configs.\n # We could add here a custom header grouping User-agent families.\n\n \/* 12th: Cookie removal *\/\n # Always cache the following static file types for all users. \n # Use with care if we control certain downloads depending on cookies. \n # Be carefull also if appending .htm[l] via Drupal's clean URLs.\n if ( req.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|woff2|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n && ! req.url ~ \"\/system\/storage\/serve\"\n ) {\n unset req.http.Cookie;\n }\n # Remove all cookies that backend doesn't need to know about.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRemovingSomeCookies\n if (req.http.Cookie) {\n \/* Warning: Not a pretty solution *\/\n # Prefix header containing cookies with ';'\n set req.http.Cookie = \";\" + req.http.Cookie;\n # Remove any spaces after ';' in header containing cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n # Prefix cookies we want to preserve with one space:\n # 'S{1,2}ESS[a-z0-9]+' is the regular expression matching a Drupal session\n # cookie ({1,2} added for HTTPS support).\n # 'NO_CACHE' is usually set after a POST request to make sure issuing user\n # see the results of his post.\n # 'OATMEAL' & 'CHOCOLATECHIP' are special cookies used by Drupal's Bakery\n # module to provide Single Sign On.\n # Keep in mind we should add here any cookie that should reach the backend\n # such as splash avoiding cookies.\n set req.http.Cookie\n = regsuball(\n req.http.Cookie,\n \";(S{1,2}ESS[a-z0-9]+|NO_CACHE|OATMEAL|CHOCOLATECHIP)=\",\n \"; \\1=\"\n );\n # Remove from the header any single Cookie not prefixed with a space until\n # next ';' separator.\n set req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n # Remove any '; ' at the start or the end of the header.\n set req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n #If there are no remaining cookies, remove the cookie header.\n if (req.http.Cookie == \"\") {\n unset req.http.Cookie;\n }\n }\n\n \/* 13th: Session cookie & special cookies bypass caching stage *\/\n # As we might want to cache some requests, hashed with its cookies, we don't\n # simply pass when some cookies remain present at this point.\n # Instead we look for request that must be passed due to the cookie header.\n if ( req.http.Cookie ~ \"SESS\"\n || req.http.Cookie ~ \"SSESS\"\n || req.http.Cookie ~ \"NO_CACHE\"\n || req.http.Cookie ~ \"OATMEAL\"\n || req.http.Cookie ~ \"CHOCOLATECHIP\"\n ) {\n return (pass);\n }\n\n \/* 14th: Announce ESI Support *\/\n # Empty in simple configs.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/esi.html\n # Note that ESI included requests inherits its parent's modified request, so\n # depending on the case you will end playing with req.esi_level to know\n # current depth.\n # Send Surrogate-Capability headers\n # See http:\/\/www.w3.org\/TR\/edge-arch\n # Note that myproxyname is an identifier that should avoid collitions\n # set req.http.Surrogate-Capability = \"myproxyname=ESI\/1.0\";\n\n \/* 15th: Bypass breakpoint 2 *\/\n # Useful for debugging we can now pipe or pass the request to backend to\n # bypass cache.\n # return (pipe);\n # return (pass);\n\n \/* 16th: Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n return (hash);\n}\n\n# vcl_pipe: Called upon entering pipe mode.\n# In this mode, the request is passed on to the backend, and any further data\n# from either client or backend is passed on unaltered until either end closes\n# the connection.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pipe\nsub vcl_pipe {\n # Websocket support\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n}\n# sub vcl_pipe {\n# # By default Connection: close is set on all piped requests, to stop\n# # connection reuse from sending future requests directly to the\n# # (potentially) wrong backend. If you do want this to happen, you can undo\n# # it here.\n# # unset bereq.http.connection;\n# return (pipe);\n# }\n\n# vcl_pass: Called upon entering pass mode. \n# In this mode, the request is passed on to the backend, and the backend's\n# response is passed on to the client, but is not entered into the cache.\n# Subsequent requests submitted over the same client connection are handled normally.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pass\n# sub vcl_pass {\n# return (fetch);\n# }\n\n# vcl_hash: You may call hash_data() on the data you would like to add to the\n# hash.\n# Hash is used by Varnish to uniquely identify objects.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hash\nsub vcl_hash {\n \/* Hash cookie data *\/\n # As requests with same URL and host can produce diferent results when issued\n # with different cookies, we need to store items hashed with the associated\n # cookies. Note that cookies are already sanitized when we reach this point.\n if (req.http.Cookie) {\n \/* Include cookie in cache hash *\/\n hash_data(req.http.Cookie);\n }\n\n \/* Custom header hashing *\/\n # Empty in simple configs.\n # Example for caching differents object versions by device previously\n # detected (when static content could also vary):\n # if (req.http.X-UA-Device) {\n # hash_data(req.http.X-UA-Device);\n # }\n # Example for caching diferent object versions by X-Forwarded-Proto, trying\n # to be smart about what kind of request could generate diffetent responses.\n if ( req.http.X-Forwarded-Proto\n && req.url !~ \"(?i)\\.(png|gif|jpeg|jpg|ico|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|woff2|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\") {\n hash_data(req.http.X-Forwarded-Proto);\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (lookup);\n# }\n\n# vcl_purge: Called after the purge has been executed and all its variants have\n# been evited.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-purge\n# sub vcl_purge {\n# return (synth(200, \"Purged\"));\n# }\n\n# vcl_hit: Called after a cache lookup if the requested document was found in\n# the cache.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hit\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n \/\/ A pure unadultered hit, deliver it\n return (deliver);\n }\n \/* Allow varnish to serve up stale content if it is responding slowly *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n if (obj.ttl + 60s > 0s) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n set req.http.grace = \"normal\";\n return (deliver);\n }\n \/* Allow varish to serve up stale content if all backends are down *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n if ( ! std.healthy(req.backend_hint)\n && obj.ttl + obj.grace > 0s\n ) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n set req.http.grace = \"extended\";\n return (deliver);\n }\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\n# vcl_miss: Called after a cache lookup if the requested document was not found\n# in the cache.\n# Its purpose is to decide whether or not to attempt to retrieve the document\n# from the backend, and which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-miss\n# sub vcl_miss {\n# return (fetch);\n# }\n\n# vcl_deliver: Called before an object is delivered to the client\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-deliver\nsub vcl_deliver {\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # Add whether the object is a cache hit or miss and the number of hits for\n # the object.\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Addingaheaderindicatinghitmiss\n # In Varnish 4 the obj.hits counter behaviour has changed (see bug 1492), so\n # we use a different method: if X-Varnish contains only 1 id, we have a miss,\n # if it contains more (and therefore a space), we have a hit.\n if (resp.http.x-varnish ~ \" \") {\n set resp.http.X-Cache = \"HIT\";\n # Since in Varnish 4 the behaviour of obj.hits changed, this might not be\n # accurate.\n # See https:\/\/www.varnish-cache.org\/trac\/ticket\/1492\n set resp.http.X-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Cache = \"MISS\";\n \/* Show the results of cookie sanitization *\/\n set resp.http.X-Cookie = req.http.Cookie;\n }\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n set resp.http.grace = req.http.grace;\n\n #TODO# Add sick marker\n\n # Restart count\n if ( req.restarts > 0) {\n set resp.http.X-Restarts = req.restarts;\n }\n\n # Add the Varnish server hostname\n set resp.http.X-Varnish-Server = server.hostname;\n # If we have setted a custom header with device's family detected we can show\n # it:\n # if (req.http.X-UA-Device) {\n # set resp.http.X-UA-Device = req.http.X-UA-Device;\n # }\n # If we have recived a custom header indicating the protocol in the request we\n # can show it:\n # if (req.http.X-Forwarded-Proto) {\n # set resp.http.X-Forwarded-Proto = req.http.X-Forwarded-Proto;\n # }\n\n \/* Vary header manipulation *\/\n # Empty in simple configs.\n # By example, if we are storing & serving diferent objects depending on\n # User-Agent header we must set the correct Vary header:\n # if (resp.http.Vary) {\n # set resp.http.Vary = resp.http.Vary + \",User-Agent\";\n # } else {\n # set resp.http.Vary = \"User-Agent\";\n # }\n\n \/* Fake headers *\/\n # Empty in simple configs\n # We can fake server headers here, by example:\n # set resp.http.Server = \"Deep thought\";\n # set resp.http.X-Powered-By = \"BOFH\";\n # Or have some fun with headers:\n # See http:\/\/www.nextthing.org\/archives\/2005\/08\/07\/fun-with-http-headers\n # See http:\/\/royal.pingdom.com\/2012\/08\/15\/fun-and-unusual-http-response-headers\/\n # set resp.http.X-Thank-You = \"for bothering to look at my HTTP headers\";\n # set resp.http.X-Answer = \"42\";\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_deliver {\n# return (deliver);\n# }\n\n# vcl_synth: Called to deliver a synthetic object. A synthetic object is\n# generated in VCL, not fetched from the backend. It is typically contructed\n# using the synthetic() function.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-synth\n\/*\n * We can come here \"invisibly\" with the following errors: 413, 417 & 503\n *\/\nsub vcl_synth {\n \/* Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_synth;\n\n \/* Try to restart request in case of failure *\/\n # Note that max_restarts defaults to 4\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if (resp.status == 503 && req.restarts < 4) {\n return(restart);\n }\n\n \/* Set common headers for synthetic responses *\/\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n\n \/* HTTP Authentification client request *\/\n # Empty in simple configs.\n # SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* Load synthetic responses from disk *\/\n # Note that files loaded this way are never re-readed (even after a reload).\n # You should consider PROS\/CONS of doing an include instead.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_std.generated.html#func-fileread\n # Example custom 403 error page.\n # if (resp.status == 403) {\n # synthetic(std.fileread(\"\/403.html\"));\n # return(deliver);\n # }\n\n \/* Error page & refresh \/ redirections *\/\n # We have plenty of choices when we have to serve an error to the client, \n # from the default error page to javascript black magic or plain redirections.\n # Adding some external statistic javascript to track failures served to\n # clients is strongly suggested.\n # We can't use external resources on synthetic content, everything must be\n # inlined.\n # If we need to include images we can embed them in base64 encoding.\n # We're using error 200 for monitoring puposes which should not be retried\n # client side.\n if ( resp.status != 200) {\n set resp.http.Retry-After = \"5\";\n }\n\n # Here is the default error page for Varnish 4 (not so pretty)\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n return (deliver);\n}\n\n#######################################################################\n# Backend Fetch\n\n# vcl_backend_fetch: Called before sending the backend request. In this\n# subroutine you typically alter the request before it gets to the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-fetch\n# sub vcl_backend_fetch {\n# return (fetch);\n# }\n\n# vcl_backend_response: Called after the response headers has been successfully\n# retrieved from the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-response\nsub vcl_backend_response {\n \/* Caching exceptions *\/\n # Varnish will cache objects with response codes:\n # 200, 203, 300, 301, 302, 307, 404 & 410.\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/VCL_Basics.html#the-initial-value-of-beresp-ttl\n # Drupal's Imagecache module can return a 307 redirection to the requested\n # url itself and, depending on Drupal's cache settings, this could lead to a\n # redirection loop being cached for a long time but also we want Varnish to\n # shield a little the backend.\n # See http:\/\/drupal.org\/node\/1248010\n # See http:\/\/drupal.org\/node\/310656\n if ( beresp.status == 307\n #TODO# verify that this work better than 'bereq.url ~ \"imagecache\"'\n && beresp.http.Location == bereq.url\n && beresp.ttl > 5s\n ) {\n set beresp.ttl = 5s;\n set beresp.http.cache-control = \"max-age=5\";\n }\n\n \/* Request retrial *\/\n if ( beresp.status == 500\n || beresp.status == 503\n ) {\n #TODO# consider not restarting POST requests as seenV3 on https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleSaintMode\n return (retry);\n }\n\n \/* Enable grace mode. Related with vcl_hit *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n set beresp.grace = 1h;\n\n \/* Strip cookies from the following static file types for all users. *\/\n # Related with our 12th stage on vcl_recv\n if (bereq.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|woff2|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\") {\n unset beresp.http.set-cookie;\n }\n\n \/* Process ESI responses *\/\n # Empty in simple configs.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/esi.html\n # Send Surrogate-Capability headers\n # See http:\/\/www.w3.org\/TR\/edge-arch\n # Note that myproxyname is an identifier that should avoid collitions\n # Check for ESI acknowledgement and remove Surrogate-Control header\n #TODO# Add support for Surrogate-Control Targetting\n # if ( beresp.http.Surrogate-Control ~ \"ESI\/1.0\" ) {\n # unset beresp.http.Surrogate-Control;\n # set beresp.do_esi = true;\n # }\n\n \/* Gzip response *\/\n # Empty in simple configs.\n # Use Varnish to Gzip respone, if suitable, before storing it on cache.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html\n if ( ! beresp.http.Content-Encoding\n && ( beresp.http.content-type ~ \"text\"\n || beresp.http.content-type ~ \"application\/x-javascript\"\n || beresp.http.content-type ~ \"application\/javascript\"\n || beresp.http.content-type ~ \"application\/rss+xml\"\n || beresp.http.content-type ~ \"application\/xml\"\n || beresp.http.content-type ~ \"Application\/JSON\")\n ) {\n set beresp.do_gzip = true;\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # We can add the name of the backend that has processed the request:\n # set beresp.http.X-Backend = beresp.backend.name;\n # We can use a header to tell if the object was gziped by Varnish:\n # if (beresp.do_gzip) {\n # set beresp.http.X-Varnish-Gzipped = \"yes\";\n # } else {\n # set beresp.http.X-Varnish-Gizipped = \"no\";\n # }\n # We can also add headers informing whether the object is cacheable or not and why:\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Varnish3.0\n if (beresp.ttl <= 0s) {\n \/* Varnish determined the object was not cacheable *\/\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n } elsif (bereq.http.Cookie ~ \"(SESS|SSESS|NO_CACHE|OATMEAL|CHOCOLATECHIP)\") {\n \/* We don't wish to cache content for logged in users or with certain cookies. *\/\n # Related with our 9th stage on vcl_recv\n set beresp.http.X-Cacheable = \"NO:Cookies\";\n # set beresp.uncacheable = true;\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n \/* We are respecting the Cache-Control=private header from the backend *\/\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n # set beresp.uncacheable = true;\n } else {\n \/* Varnish determined the object was cacheable *\/\n set beresp.http.X-Cacheable = \"YES\";\n }\n\n \/* Further header manipulation *\/\n # Empty in simple configs.\n # We can also unset some headers to prevent information disclosure and save\n # some cache space.\n # unset beresp.http.Server;\n # unset beresp.http.X-Powered-By;\n # Retry count.\n if ( bereq.retries > 0) {\n set beresp.http.X-Retries = bereq.retries;\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_backend_response {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Surrogate-control ~ \"no-store\" ||\n# (!beresp.http.Surrogate-Control &&\n# beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n# beresp.http.Vary == \"*\") {\n# \/*\n# * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# *\/\n# set beresp.ttl = 120s;\n# set beresp.uncacheable = true;\n# }\n# return (deliver);\n# }\n\n# vcl_backend_error: This subroutine is called if we fail the backend fetch.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-error\nsub vcl_backend_error {\n\n \/* Try to restart request in case of failure *\/\n #TODO# Confirm max_retries default value\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if (bereq.retries < 4) {\n return (retry);\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # Retry count\n if ( bereq.retries > 0) {\n set beresp.http.X-Retries = bereq.retries;\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + beresp.status + \" \" + beresp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + beresp.status + \" \" + beresp.reason + {\"<\/h1>\n <p>\"} + beresp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + bereq.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this\n # point.\n return (deliver);\n}\n\n#######################################################################\n# Housekeeping\n\n# vcl_init: Called when VCL is loaded, before any requests pass through it.\n# Typically used to initialize VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-init\n# Here is where you should declare your directors now.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-backends.html#directors\n# Empty in simple configs\n# sub vcl_init {\n# return (ok);\n# }\n\n# vcl_fini: Called when VCL is discarded only after all requests have exited\n# the VCL. Typically used to clean up VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-fini\n# sub vcl_fini {\n# return (ok);\n# }\n\n","old_contents":"\/*\n * Varnish 4 example config for Drupal 7 \/ Pressflow 6 & 7\n *\/\n\n# Original source: https:\/\/github.com\/NITEMAN\/varnish-bites\/varnish4\/drupal-base.vcl\n# Copyright (c) 2015 Pedro Gonz\u00e1lez Serrano and individual contributors.\n# MIT License\n\n# Intended to be used both in simple production environments and with\n# learning\/teaching purposes.\n# Some references may not be yet updated to VCL 4.0, we use SeeV3 then.\n\n# WARNING:\n# Note that the built-in logic will be appended to our code if no return is\n# performed before.\n# Built-in logic is included commented out right after our's for reference\n# purposes in that cases.\n# See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleDefault\n\n#######################################################################\n# Initialization: Version & imports;\n\n\/* Version statement *\/\n# Since Varnish 4.0 it's mandatory to declare VCL version on first line.\nvcl 4.0;\n\n\/* Module (VMOD) imports *\/\n# Standard module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_std.generated.html\nimport std;\n\n# Directors module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# Unused in simple configs.\n#import directors;\n\n\n#######################################################################\n# Probe, backend, ACL and subroutine definitions\n\n\/* Backend probes \/ healthchecks *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#probes\nprobe basic {\n \/* Only test that backend's IP serves content for '\/' *\/\n # This might be a too heavy probe\n # .url = \"\/\";\n\n \/* Only test that backend's IP has apache working *\/\n # Nginx would fail this probe with a default config\n .request =\n \"OPTIONS * HTTP\/1.1\"\n \"Host: *\"\n \"Connection: close\";\n\n \/* Common options *\/\n .interval = 10s;\n .timeout = 2s;\n .window = 8;\n .threshold = 6;\n}\n\n\/* Backend definitions.*\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#backend-definition\nbackend default {\n \/* Default backend on the same machine. *\/\n # WARNING: timeouts could be not big enought for certain POST requests.\n .host = \"127.0.0.1\";\n .port = \"8008\";\n .max_connections = 100;\n .connect_timeout = 60s;\n .first_byte_timeout = 60s;\n .between_bytes_timeout = 60s;\n .probe = basic;\n}\n\n\/* Access Control Lists *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#access-control-list-acl\nacl purge_ban {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use '\"localhost\";' instead\n}\nacl allowed_monitors {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n}\n# acl own_proxys {\n# \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n# }\n\n\/* Custom subroutines *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#subroutines\n#TODO# Test in Varnihs 4\n# Empty in simple configs.\n# The only restriction naming subs is that the 'vlc_' prefix is reserverd for\n# Varnish use. As a task can need several chunks of code in diferent states,\n# it's a good idea to identify what main sub will call each with a suffix.\n# \/* Example 301 client redirection removing \"www\" prefix from request *\/\n# sub perm_redirections_recv {\n# if ( req.http.host ~ \"^www.*$\" ) {\n# return(\n# synth(751, \"http:\/\/\" + regsub(req.http.host, \"^www\\.\", \"\") + req.url)\n# );\n# }\n# }\n# sub perm_redirections_synth {\n# if (resp.status == 751) {\n# \/* Get new URL from the response *\/\n# set resp.http.Location = resp.response;\n# \/* Set HTTP 301 for permanent redirect *\/\n# set resp.status = 301;\n# return (deliver);\n# }\n# }\n\n\n#######################################################################\n# Client side\n\n# vcl_recv: Called at the beginning of a request, after the complete request\n# has been received and parsed. Its purpose is to decide whether or not to\n# serve the request, how to do it, and, if applicable, which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-recv\nsub vcl_recv {\n \/* 0th: general bypass, general return & authorization checks *\/\n # Empty in simple configs.\n # Useful for debugging we can pipe or pass the request to default backend\n # here to bypass completely Varnish.\n # return (pipe);\n # return (pass);\n # We can also return here a 200 Ok for network performance benchmarking.\n # return(synth(200, \"Ok\"));\n # Finally we can perform basic HTTP authentification here, by example.\n # SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* 1st: Check for Varnish special requests *\/ \n # Custom response implementation example in order to check that Varnish is\n # working properly.\n # This is usefull for automatic monitoring with monit or when Varnish is\n # behind another proxies like HAProxy.\n if ( ( req.http.host == \"monitor.server.health\"\n || req.http.host == \"health.varnish\" )\n && client.ip ~ allowed_monitors\n && ( req.method == \"OPTIONS\" || req.method == \"GET\" )\n ) {\n return(synth(200, \"Ban added\"));\n }\n # Purge logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#http-purging\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if ( req.method == \"PURGE\" ) {\n if ( ! client.ip ~ purge_ban ) {\n return(synth(405, \"Not allowed.\"));\n }\n return (purge);\n }\n # Ban logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#bans\n if ( req.method == \"BAN\" ) {\n if ( ! client.ip ~ purge_ban ) {\n return(synth(405, \"Not allowed.\"));\n }\n ban( \"req.http.host == \" + req.http.host +\n \"&& req.url == \" + req.url);\n return(synth(200, \"Ban added\"));\n }\n\n \/* 2nd: Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_recv;\n # Here we can also enforce SSL when Varnish run behind some SSL termination\n # point.\n\n \/* 3rd: Time for backend choice *\/\n # Empty in simple configs.\n\n \/* 4th: Prepare request for the backend *\/\n # Empty in simple configs.\n # Example remove own_proxys from X-Forwarded-For\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/whats-new\/upgrading.html#x-forwarded-for-is-now-set-before-vcl-recv\n # if ( req.restarts == 0\n # && client.ip ~ own_proxys\n # && req.http.x-forwarded-for\n # ) {\n # set req.http.X-Forwarded-For\n # = regsub(req.http.X-Forwarded-For, \",( )?\" + client.ip, \"\");\n # }\n # Example normalize the host header, remove the port (in case you're testing\n # this on various TCP ports)\n # set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n \/* 5th: Bypass breakpoint 1 *\/\n # Useful for debugging we can now pipe or pass the request to backend with\n # headers setted.\n # return (pipe);\n # return (pass);\n\n \/* 6th: Decide if we should deal with a request (mostly from built-in logic) *\/\n if (req.method == \"PRI\") {\n \/* We do not support SPDY or HTTP\/2.0 *\/\n return (synth(405));\n }\n if ( req.method != \"GET\"\n && req.method != \"HEAD\"\n && req.method != \"PUT\"\n && req.method != \"POST\"\n && req.method != \"TRACE\"\n && req.method != \"OPTIONS\"\n && req.method != \"DELETE\"\n ) {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n # Websocket support\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n \/* 7th: Access control for some URLs by ACL *\/\n # Empty in simple configs.\n # By example denial some URLs depending on client-ip, we'll need to define\n # corresponding ACL 'internal'.\n # if ( req.url ~ \"^\/(cron|install)\\.php\"\n # && ! client.ip ~ internal\n # ) {\n # # Have Varnish throw the error directly.\n # return(synth(403, \"Forbidden.\"));\n # # Use a custom error page that you've defined in Drupal at the path \"404\".\n # # set req.url = \"\/403\";\n # }\n\n \/* 8th: Custom exceptions *\/\n # Host exception example:\n # if (req.http.host == \"ejemplo.exception.com\") {\n # return (pass);\n # }\n # Drupal exceptions, edit if we want to cache some AJAX\/AHAH request.\n # Add here filters for never cache URLs such as Payment Gateway's callbacks.\n if ( req.url ~ \"^\/status\\.php$\"\n || req.url ~ \"^\/update\\.php$\"\n || req.url ~ \"^\/ooyala\/ping$\"\n || req.url ~ \"^\/admin\/build\/features\"\n || req.url ~ \"^\/info\/.*$\"\n || req.url ~ \"^\/flag\/.*$\"\n || req.url ~ \"^.*\/ajax\/.*$\"\n || req.url ~ \"^.*\/ahah\/.*$\"\n ) {\n \/* Do not cache these paths *\/\n return (pass);\n }\n # Pipe these paths directly to backend for streaming.\n if (req.url ~ \"^\/admin\/content\/backup_migrate\/export\") {\n return (pipe);\n }\n if (req.url ~ \"^\/system\/files\") {\n return (pipe);\n }\n\n \/* 9th: Graced objets & Serve from anonymous cahe if all backends are down *\/\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n # set req.http.grace = \"none\";\n if ( ! std.healthy(req.backend_hint) ) {\n # We must do this here since cookie hashing\n unset req.http.Cookie;\n #TODO# Add sick marker\n } \n\n \/* 10th: Deal with compression and the Accept-Encoding header *\/\n # Althought Varnish 3 handles gziped content itself by default, just to be\n # sure we want to remove Accept-Encoding for some compressed formats.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html#what-does-http-gzip-support-do\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/varnishd.html?highlight=http_gzip_support\n # See (for older configs) https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleNormalizeAcceptEncoding\n if (req.http.Accept-Encoding) {\n if ( req.url\n ~ \"\\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|mp4|flv|zip|rar)$\"\n ) {\n \/* Already compressed formats, no sense trying to compress again *\/\n unset req.http.Accept-Encoding;\n }\n }\n\n \/* 11th: Another request manipulation *\/\n # Empty in simple configs.\n # We could add here a custom header grouping User-agent families.\n\n \/* 12th: Cookie removal *\/\n # Always cache the following static file types for all users. \n # Use with care if we control certain downloads depending on cookies. \n # Be carefull also if appending .htm[l] via Drupal's clean URLs.\n if ( req.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|woff2|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n && ! req.url ~ \"\/system\/storage\/serve\"\n ) {\n unset req.http.Cookie;\n }\n # Remove all cookies that backend doesn't need to know about.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRemovingSomeCookies\n if (req.http.Cookie) {\n \/* Warning: Not a pretty solution *\/\n # Prefix header containing cookies with ';'\n set req.http.Cookie = \";\" + req.http.Cookie;\n # Remove any spaces after ';' in header containing cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n # Prefix cookies we want to preserve with one space:\n # 'S{1,2}ESS[a-z0-9]+' is the regular expression matching a Drupal session\n # cookie ({1,2} added for HTTPS support).\n # 'NO_CACHE' is usually set after a POST request to make sure issuing user\n # see the results of his post.\n # 'OATMEAL' & 'CHOCOLATECHIP' are special cookies used by Drupal's Bakery\n # module to provide Single Sign On.\n # Keep in mind we should add here any cookie that should reach the backend\n # such as splash avoiding cookies.\n set req.http.Cookie\n = regsuball(\n req.http.Cookie,\n \";(S{1,2}ESS[a-z0-9]+|NO_CACHE|OATMEAL|CHOCOLATECHIP)=\",\n \"; \\1=\"\n );\n # Remove from the header any single Cookie not prefixed with a space until\n # next ';' separator.\n set req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n # Remove any '; ' at the start or the end of the header.\n set req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n #If there are no remaining cookies, remove the cookie header.\n if (req.http.Cookie == \"\") {\n unset req.http.Cookie;\n }\n }\n\n \/* 13th: Session cookie & special cookies bypass caching stage *\/\n # As we might want to cache some requests, hashed with its cookies, we don't\n # simply pass when some cookies remain present at this point.\n # Instead we look for request that must be passed due to the cookie header.\n if ( req.http.Cookie ~ \"SESS\"\n || req.http.Cookie ~ \"SSESS\"\n || req.http.Cookie ~ \"NO_CACHE\"\n || req.http.Cookie ~ \"OATMEAL\"\n || req.http.Cookie ~ \"CHOCOLATECHIP\"\n ) {\n return (pass);\n }\n\n \/* 14th: Bypass breakpoint 2 *\/\n # Useful for debugging we can now pipe or pass the request to backend to\n # bypass cache.\n # return (pipe);\n # return (pass);\n\n \/* 15th: Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n return (hash);\n}\n\n# vcl_pipe: Called upon entering pipe mode.\n# In this mode, the request is passed on to the backend, and any further data\n# from either client or backend is passed on unaltered until either end closes\n# the connection.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pipe\nsub vcl_pipe {\n # Websocket support\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n}\n# sub vcl_pipe {\n# # By default Connection: close is set on all piped requests, to stop\n# # connection reuse from sending future requests directly to the\n# # (potentially) wrong backend. If you do want this to happen, you can undo\n# # it here.\n# # unset bereq.http.connection;\n# return (pipe);\n# }\n\n# vcl_pass: Called upon entering pass mode. \n# In this mode, the request is passed on to the backend, and the backend's\n# response is passed on to the client, but is not entered into the cache.\n# Subsequent requests submitted over the same client connection are handled normally.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pass\n# sub vcl_pass {\n# return (fetch);\n# }\n\n# vcl_hash: You may call hash_data() on the data you would like to add to the\n# hash.\n# Hash is used by Varnish to uniquely identify objects.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hash\nsub vcl_hash {\n \/* Hash cookie data *\/\n # As requests with same URL and host can produce diferent results when issued\n # with different cookies, we need to store items hashed with the associated\n # cookies. Note that cookies are already sanitized when we reach this point.\n if (req.http.Cookie) {\n \/* Include cookie in cache hash *\/\n hash_data(req.http.Cookie);\n }\n\n \/* Custom header hashing *\/\n # Empty in simple configs.\n # Example for caching differents object versions by device previously\n # detected (when static content could also vary):\n # if (req.http.X-UA-Device) {\n # hash_data(req.http.X-UA-Device);\n # }\n # Example for caching diferent object versions by X-Forwarded-Proto, trying\n # to be smart about what kind of request could generate diffetent responses.\n if ( req.http.X-Forwarded-Proto\n && req.url !~ \"(?i)\\.(png|gif|jpeg|jpg|ico|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|woff2|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\") {\n hash_data(req.http.X-Forwarded-Proto);\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (lookup);\n# }\n\n# vcl_purge: Called after the purge has been executed and all its variants have\n# been evited.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-purge\n# sub vcl_purge {\n# return (synth(200, \"Purged\"));\n# }\n\n# vcl_hit: Called after a cache lookup if the requested document was found in\n# the cache.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hit\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n \/\/ A pure unadultered hit, deliver it\n return (deliver);\n }\n \/* Allow varnish to serve up stale content if it is responding slowly *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n if (obj.ttl + 60s > 0s) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n set req.http.grace = \"normal\";\n return (deliver);\n }\n \/* Allow varish to serve up stale content if all backends are down *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n if ( ! std.healthy(req.backend_hint)\n && obj.ttl + obj.grace > 0s\n ) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n set req.http.grace = \"extended\";\n return (deliver);\n }\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\n# vcl_miss: Called after a cache lookup if the requested document was not found\n# in the cache.\n# Its purpose is to decide whether or not to attempt to retrieve the document\n# from the backend, and which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-miss\n# sub vcl_miss {\n# return (fetch);\n# }\n\n# vcl_deliver: Called before an object is delivered to the client\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-deliver\nsub vcl_deliver {\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # Add whether the object is a cache hit or miss and the number of hits for\n # the object.\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Addingaheaderindicatinghitmiss\n # In Varnish 4 the obj.hits counter behaviour has changed (see bug 1492), so\n # we use a different method: if X-Varnish contains only 1 id, we have a miss,\n # if it contains more (and therefore a space), we have a hit.\n if (resp.http.x-varnish ~ \" \") {\n set resp.http.X-Cache = \"HIT\";\n # Since in Varnish 4 the behaviour of obj.hits changed, this might not be\n # accurate.\n # See https:\/\/www.varnish-cache.org\/trac\/ticket\/1492\n set resp.http.X-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Cache = \"MISS\";\n \/* Show the results of cookie sanitization *\/\n set resp.http.X-Cookie = req.http.Cookie;\n }\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n set resp.http.grace = req.http.grace;\n\n #TODO# Add sick marker\n\n # Restart count\n if ( req.restarts > 0) {\n set resp.http.X-Restarts = req.restarts;\n }\n\n # Add the Varnish server hostname\n set resp.http.X-Varnish-Server = server.hostname;\n # If we have setted a custom header with device's family detected we can show\n # it:\n # if (req.http.X-UA-Device) {\n # set resp.http.X-UA-Device = req.http.X-UA-Device;\n # }\n # If we have recived a custom header indicating the protocol in the request we\n # can show it:\n # if (req.http.X-Forwarded-Proto) {\n # set resp.http.X-Forwarded-Proto = req.http.X-Forwarded-Proto;\n # }\n\n \/* Vary header manipulation *\/\n # Empty in simple configs.\n # By example, if we are storing & serving diferent objects depending on\n # User-Agent header we must set the correct Vary header:\n # if (resp.http.Vary) {\n # set resp.http.Vary = resp.http.Vary + \",User-Agent\";\n # } else {\n # set resp.http.Vary = \"User-Agent\";\n # }\n\n \/* Fake headers *\/\n # Empty in simple configs\n # We can fake server headers here, by example:\n # set resp.http.Server = \"Deep thought\";\n # set resp.http.X-Powered-By = \"BOFH\";\n # Or have some fun with headers:\n # See http:\/\/www.nextthing.org\/archives\/2005\/08\/07\/fun-with-http-headers\n # See http:\/\/royal.pingdom.com\/2012\/08\/15\/fun-and-unusual-http-response-headers\/\n # set resp.http.X-Thank-You = \"for bothering to look at my HTTP headers\";\n # set resp.http.X-Answer = \"42\";\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_deliver {\n# return (deliver);\n# }\n\n# vcl_synth: Called to deliver a synthetic object. A synthetic object is\n# generated in VCL, not fetched from the backend. It is typically contructed\n# using the synthetic() function.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-synth\n\/*\n * We can come here \"invisibly\" with the following errors: 413, 417 & 503\n *\/\nsub vcl_synth {\n \/* Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_synth;\n\n \/* Try to restart request in case of failure *\/\n # Note that max_restarts defaults to 4\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if (resp.status == 503 && req.restarts < 4) {\n return(restart);\n }\n\n \/* Set common headers for synthetic responses *\/\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n\n \/* HTTP Authentification client request *\/\n # Empty in simple configs.\n # SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* Load synthetic responses from disk *\/\n # Note that files loaded this way are never re-readed (even after a reload).\n # You should consider PROS\/CONS of doing an include instead.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_std.generated.html#func-fileread\n # Example custom 403 error page.\n # if (resp.status == 403) {\n # synthetic(std.fileread(\"\/403.html\"));\n # return(deliver);\n # }\n\n \/* Error page & refresh \/ redirections *\/\n # We have plenty of choices when we have to serve an error to the client, \n # from the default error page to javascript black magic or plain redirections.\n # Adding some external statistic javascript to track failures served to\n # clients is strongly suggested.\n # We can't use external resources on synthetic content, everything must be\n # inlined.\n # If we need to include images we can embed them in base64 encoding.\n # We're using error 200 for monitoring puposes which should not be retried\n # client side.\n if ( resp.status != 200) {\n set resp.http.Retry-After = \"5\";\n }\n\n # Here is the default error page for Varnish 4 (not so pretty)\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n return (deliver);\n}\n\n#######################################################################\n# Backend Fetch\n\n# vcl_backend_fetch: Called before sending the backend request. In this\n# subroutine you typically alter the request before it gets to the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-fetch\n# sub vcl_backend_fetch {\n# return (fetch);\n# }\n\n# vcl_backend_response: Called after the response headers has been successfully\n# retrieved from the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-response\nsub vcl_backend_response {\n \/* Caching exceptions *\/\n # Varnish will cache objects with response codes:\n # 200, 203, 300, 301, 302, 307, 404 & 410.\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/VCL_Basics.html#the-initial-value-of-beresp-ttl\n # Drupal's Imagecache module can return a 307 redirection to the requested\n # url itself and, depending on Drupal's cache settings, this could lead to a\n # redirection loop being cached for a long time but also we want Varnish to\n # shield a little the backend.\n # See http:\/\/drupal.org\/node\/1248010\n # See http:\/\/drupal.org\/node\/310656\n if ( beresp.status == 307\n #TODO# verify that this work better than 'bereq.url ~ \"imagecache\"'\n && beresp.http.Location == bereq.url\n && beresp.ttl > 5s\n ) {\n set beresp.ttl = 5s;\n set beresp.http.cache-control = \"max-age=5\";\n }\n\n \/* Request retrial *\/\n if ( beresp.status == 500\n || beresp.status == 503\n ) {\n #TODO# consider not restarting POST requests as seenV3 on https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleSaintMode\n return (retry);\n }\n\n \/* Enable grace mode. Related with vcl_hit *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n set beresp.grace = 1h;\n\n \/* Strip cookies from the following static file types for all users. *\/\n # Related with our 12th stage on vcl_recv\n if (bereq.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|woff2|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\") {\n unset beresp.http.set-cookie;\n }\n\n \/* Gzip response *\/\n # Empty in simple configs.\n # Use Varnish to Gzip respone, if suitable, before storing it on cache.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html\n if ( ! beresp.http.Content-Encoding\n && ( beresp.http.content-type ~ \"text\"\n || beresp.http.content-type ~ \"application\/x-javascript\"\n || beresp.http.content-type ~ \"application\/javascript\"\n || beresp.http.content-type ~ \"application\/rss+xml\"\n || beresp.http.content-type ~ \"application\/xml\"\n || beresp.http.content-type ~ \"Application\/JSON\")\n ) {\n set beresp.do_gzip = true;\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # We can add the name of the backend that has processed the request:\n # set beresp.http.X-Backend = beresp.backend.name;\n # We can use a header to tell if the object was gziped by Varnish:\n # if (beresp.do_gzip) {\n # set beresp.http.X-Varnish-Gzipped = \"yes\";\n # } else {\n # set beresp.http.X-Varnish-Gizipped = \"no\";\n # }\n # We can also add headers informing whether the object is cacheable or not and why:\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Varnish3.0\n if (beresp.ttl <= 0s) {\n \/* Varnish determined the object was not cacheable *\/\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n } elsif (bereq.http.Cookie ~ \"(SESS|SSESS|NO_CACHE|OATMEAL|CHOCOLATECHIP)\") {\n \/* We don't wish to cache content for logged in users or with certain cookies. *\/\n # Related with our 9th stage on vcl_recv\n set beresp.http.X-Cacheable = \"NO:Cookies\";\n # set beresp.uncacheable = true;\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n \/* We are respecting the Cache-Control=private header from the backend *\/\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n # set beresp.uncacheable = true;\n } else {\n \/* Varnish determined the object was cacheable *\/\n set beresp.http.X-Cacheable = \"YES\";\n }\n\n \/* Further header manipulation *\/\n # Empty in simple configs.\n # We can also unset some headers to prevent information disclosure and save\n # some cache space.\n # unset beresp.http.Server;\n # unset beresp.http.X-Powered-By;\n # Retry count.\n if ( bereq.retries > 0) {\n set beresp.http.X-Retries = bereq.retries;\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_backend_response {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Surrogate-control ~ \"no-store\" ||\n# (!beresp.http.Surrogate-Control &&\n# beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n# beresp.http.Vary == \"*\") {\n# \/*\n# * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# *\/\n# set beresp.ttl = 120s;\n# set beresp.uncacheable = true;\n# }\n# return (deliver);\n# }\n\n# vcl_backend_error: This subroutine is called if we fail the backend fetch.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-error\nsub vcl_backend_error {\n\n \/* Try to restart request in case of failure *\/\n #TODO# Confirm max_retries default value\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if (bereq.retries < 4) {\n return (retry);\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # Retry count\n if ( bereq.retries > 0) {\n set beresp.http.X-Retries = bereq.retries;\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + beresp.status + \" \" + beresp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + beresp.status + \" \" + beresp.reason + {\"<\/h1>\n <p>\"} + beresp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + bereq.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this\n # point.\n return (deliver);\n}\n\n#######################################################################\n# Housekeeping\n\n# vcl_init: Called when VCL is loaded, before any requests pass through it.\n# Typically used to initialize VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-init\n# Here is where you should declare your directors now.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-backends.html#directors\n# Empty in simple configs\n# sub vcl_init {\n# return (ok);\n# }\n\n# vcl_fini: Called when VCL is discarded only after all requests have exited\n# the VCL. Typically used to clean up VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-fini\n# sub vcl_fini {\n# return (ok);\n# }\n\n","returncode":0,"stderr":"","license":"unknown","lang":"VCL"} {"commit":"0fbc16683241dc9a32fcf27e5cfd775e65961e8e","subject":"Change Varnish footer in default.vcl","message":"Change Varnish footer in default.vcl\n\nHopefully make it slightly more obvious we are just the provider of\nthe caching software in the default vcl_error.\n\ngit-svn-id: 2c9807fa3ff65b17195bd55dc8a6c4261e10127b@4091 d4fa192b-c00b-0410-8231-f00ffab90ce4\n","repos":"zhoualbeart\/Varnish-Cache,mrhmouse\/Varnish-Cache,1HLtd\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,ambernetas\/varnish-cache,gquintard\/Varnish-Cache,zhoualbeart\/Varnish-Cache,zhoualbeart\/Varnish-Cache,franciscovg\/Varnish-Cache,alarky\/varnish-cache-doc-ja,wikimedia\/operations-debs-varnish,drwilco\/varnish-cache-old,ajasty-cavium\/Varnish-Cache,ambernetas\/varnish-cache,feld\/Varnish-Cache,wikimedia\/operations-debs-varnish,alarky\/varnish-cache-doc-ja,feld\/Varnish-Cache,chrismoulton\/Varnish-Cache,gquintard\/Varnish-Cache,zhoualbeart\/Varnish-Cache,franciscovg\/Varnish-Cache,zhoualbeart\/Varnish-Cache,franciscovg\/Varnish-Cache,chrismoulton\/Varnish-Cache,ssm\/pkg-varnish,1HLtd\/Varnish-Cache,varnish\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,1HLtd\/Varnish-Cache,varnish\/Varnish-Cache,varnish\/Varnish-Cache,chrismoulton\/Varnish-Cache,ambernetas\/varnish-cache,feld\/Varnish-Cache,chrismoulton\/Varnish-Cache,alarky\/varnish-cache-doc-ja,ssm\/pkg-varnish,gquintard\/Varnish-Cache,mrhmouse\/Varnish-Cache,alarky\/varnish-cache-doc-ja,feld\/Varnish-Cache,ssm\/pkg-varnish,mrhmouse\/Varnish-Cache,wikimedia\/operations-debs-varnish,drwilco\/varnish-cache-drwilco,franciscovg\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,varnish\/Varnish-Cache,mrhmouse\/Varnish-Cache,wikimedia\/operations-debs-varnish,alarky\/varnish-cache-doc-ja,varnish\/Varnish-Cache,mrhmouse\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,gquintard\/Varnish-Cache,drwilco\/varnish-cache-drwilco,franciscovg\/Varnish-Cache,drwilco\/varnish-cache-drwilco,wikimedia\/operations-debs-varnish,ssm\/pkg-varnish,gauthier-delacroix\/Varnish-Cache,feld\/Varnish-Cache,ssm\/pkg-varnish,drwilco\/varnish-cache-old,gauthier-delacroix\/Varnish-Cache,chrismoulton\/Varnish-Cache,drwilco\/varnish-cache-old,gauthier-delacroix\/Varnish-Cache,1HLtd\/Varnish-Cache","old_file":"bin\/varnishd\/default.vcl","new_file":"bin\/varnishd\/default.vcl","new_contents":"\/*-\n * Copyright (c) 2006 Verdens Gang AS\n * Copyright (c) 2006-2009 Linpro AS\n * All rights reserved.\n *\n * Author: Poul-Henning Kamp <phk@phk.freebsd.dk>\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in the\n * documentation and\/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR \n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\n * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n * $Id$\n *\n * The default VCL code.\n *\n * NB! You do NOT need to copy & paste all of these functions into your\n * own vcl code, if you do not provide a definition of one of these\n * functions, the compiler will automatically fall back to the default\n * code from this file.\n *\n * This code will be prefixed with a backend declaration built from the\n * -b argument.\n *\/\n\nsub vcl_recv {\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization || req.http.Cookie) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n return (lookup);\n}\n\nsub vcl_pipe {\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n # set req.http.connection = \"close\";\n # here. It is not set by default as it might break some broken web\n # applications, like IIS with NTLM authentication.\n return (pipe);\n}\n\nsub vcl_pass {\n return (pass);\n}\n\nsub vcl_hash {\n set req.hash += req.url;\n if (req.http.host) {\n set req.hash += req.http.host;\n } else {\n set req.hash += server.ip;\n }\n return (hash);\n}\n\nsub vcl_hit {\n if (!obj.cacheable) {\n return (pass);\n }\n return (deliver);\n}\n\nsub vcl_miss {\n return (fetch);\n}\n\nsub vcl_fetch {\n if (!beresp.cacheable) {\n return (pass);\n }\n if (beresp.http.Set-Cookie) {\n return (pass);\n }\n return (deliver);\n}\n\nsub vcl_deliver {\n return (deliver);\n}\n\nsub vcl_discard {\n \/* XXX: Do not redefine vcl_discard{}, it is not yet supported *\/\n return (discard);\n}\n\nsub vcl_timeout {\n \/* XXX: Do not redefine vcl_timeout{}, it is not yet supported *\/\n return (discard);\n}\n\nsub vcl_error {\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} obj.status \" \" obj.response {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} obj.status \" \" obj.response {\"<\/h1>\n <p>\"} obj.response {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} req.xid {\"<\/p>\n <hr>\n <address>\n <a href=\"http:\/\/www.varnish-cache.org\/\">Varnish cache server<\/a>\n <\/address>\n <\/body>\n<\/html>\n\"};\n return (deliver);\n}\n","old_contents":"\/*-\n * Copyright (c) 2006 Verdens Gang AS\n * Copyright (c) 2006-2009 Linpro AS\n * All rights reserved.\n *\n * Author: Poul-Henning Kamp <phk@phk.freebsd.dk>\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in the\n * documentation and\/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR \n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\n * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n * $Id$\n *\n * The default VCL code.\n *\n * NB! You do NOT need to copy & paste all of these functions into your\n * own vcl code, if you do not provide a definition of one of these\n * functions, the compiler will automatically fall back to the default\n * code from this file.\n *\n * This code will be prefixed with a backend declaration built from the\n * -b argument.\n *\/\n\nsub vcl_recv {\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization || req.http.Cookie) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n return (lookup);\n}\n\nsub vcl_pipe {\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n # set req.http.connection = \"close\";\n # here. It is not set by default as it might break some broken web\n # applications, like IIS with NTLM authentication.\n return (pipe);\n}\n\nsub vcl_pass {\n return (pass);\n}\n\nsub vcl_hash {\n set req.hash += req.url;\n if (req.http.host) {\n set req.hash += req.http.host;\n } else {\n set req.hash += server.ip;\n }\n return (hash);\n}\n\nsub vcl_hit {\n if (!obj.cacheable) {\n return (pass);\n }\n return (deliver);\n}\n\nsub vcl_miss {\n return (fetch);\n}\n\nsub vcl_fetch {\n if (!beresp.cacheable) {\n return (pass);\n }\n if (beresp.http.Set-Cookie) {\n return (pass);\n }\n return (deliver);\n}\n\nsub vcl_deliver {\n return (deliver);\n}\n\nsub vcl_discard {\n \/* XXX: Do not redefine vcl_discard{}, it is not yet supported *\/\n return (discard);\n}\n\nsub vcl_timeout {\n \/* XXX: Do not redefine vcl_timeout{}, it is not yet supported *\/\n return (discard);\n}\n\nsub vcl_error {\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} obj.status \" \" obj.response {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} obj.status \" \" obj.response {\"<\/h1>\n <p>\"} obj.response {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} req.xid {\"<\/p>\n <address>\n <a href=\"http:\/\/www.varnish-cache.org\/\">Varnish<\/a>\n <\/address>\n <\/body>\n<\/html>\n\"};\n return (deliver);\n}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"3f9c0553c5cb79dc230493e68de6ae6c23b06d78","subject":"Strip query parameters from *most* URLs","message":"Strip query parameters from *most* URLs\n","repos":"dstufft\/warehouse,wlonk\/warehouse,karan\/warehouse,karan\/warehouse,dstufft\/warehouse,alex\/warehouse,karan\/warehouse,karan\/warehouse,karan\/warehouse,wlonk\/warehouse,dstufft\/warehouse,pypa\/warehouse,alex\/warehouse,dstufft\/warehouse,pypa\/warehouse,pypa\/warehouse,alex\/warehouse,alex\/warehouse,wlonk\/warehouse,alex\/warehouse,pypa\/warehouse","old_file":"vcl\/main.vcl","new_file":"vcl\/main.vcl","new_contents":"\nsub vcl_recv {\n\n # Some (Older) clients will send a hash fragment as part of the URL even\n # though that is a local only modification. This breaks this badly for the\n # files in S3, and in general it's just not needed.\n set req.url = regsub(req.url, \"#.*$\", \"\");\n\n # Most of the URLs in Warehouse do not support or require any sort of query\n # parameter. If we strip these at the edge then we'll increase our cache\n # efficiency when they won't otherwise change the output of the pages.\n #\n # This will match any URL except those that start with:\n #\n # * \/search\/\n # * \/account\/login\/\n # * \/account\/logout\/\n # * \/account\/register\/\n # * \/pypi\n if (req.url !~ '^\/(search\/|account\/(login|logout|register)\/|pypi)') {\n set req.url = req.url.path;\n }\n\n # Sort all of our query parameters, this will ensure that the same query\n # parameters in a different order will end up being represented as the same\n # thing, reducing cache misses due to ordering differences.\n set req.url = boltsort.sort(req.url);\n\n\n#FASTLY recv\n\n\n # We want to Force SSL for the WebUI by redirecting to the HTTPS version of\n # the page, however for API calls we want to return an error code directing\n # people to instead use HTTPS.\n if (!req.http.Fastly-SSL) {\n\n # The \/simple\/ and \/packages\/ API.\n if (req.url ~ \"^\/(simple|packages)\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy JSON API.\n if (req.url ~ \"^\/pypi\/.+\/json$\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy ?:action= API.\n if (req.url ~ \"^\/pypi.*(\\?|&)=:action\") {\n error 803 \"SSL is required\";\n }\n\n # If we're on the \/pypi page and we've received something other than a\n # GET or HEAD request, then we have no way to determine if a particular\n # request is an API call or not because it'll be in the request body\n # and that isn't available to us here. So in those cases, we won't\n # do a redirect.\n if (req.url ~ \"^\/pypi\") {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n error 801 \"Force SSL\";\n }\n }\n else {\n # This isn't a \/pypi URL so we'll just unconditionally redirect to\n # HTTPS.\n error 801 \"Force SSL\";\n }\n }\n\n # Canonicalize our domains by redirecting any domain that doesn't match our\n # primary domain to our primary domain. We do this *after* the HTTPS check\n # on purpose.\n if (std.tolower(req.http.host) != std.tolower(req.http.Primary-Domain)) {\n set req.http.Location = \"https:\/\/\" req.http.Primary-Domain req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n\n # Requests to \/packages\/ get dispatched to Amazon instead of to our typical\n # Origin. This requires a a bit of setup to make it work.\n if (req.url ~ \"^\/packages\/\") {\n # Setup our environment to better match what S3 expects\/needs\n set req.http.Host = req.http.AWS-Bucket-Name \".s3.amazonaws.com\";\n set req.http.Date = now;\n set req.url = regsuball(req.url, \"\\+\", urlencode(\"+\"));\n\n # Compute the Authorization header that S3 requires to be able to\n # access the files stored there.\n set req.http.Authorization = \"AWS \" req.http.AWS-Access-Key-ID \":\" digest.hmac_sha1_base64(req.http.AWS-Secret-Access-Key, \"GET\" LF LF LF req.http.Date LF \"\/\" req.http.AWS-Bucket-Name req.url.path);\n\n # We don't want to send our Warehouse-Token to S3, so we'll go ahead\n # and remove it.\n unset req.http.Warehouse-Token;\n }\n\n # We no longer need any of these variables, which would exist only to\n # shuffle configuration from the Fastly UI into our VCL.\n unset req.http.Primary-Domain;\n unset req.http.AWS-Access-Key-ID;\n unset req.http.AWS-Secret-Access-Key;\n unset req.http.AWS-Bucket-Name;\n\n # We have a number of items that we'll pass back to the origin, but only\n # if we have a Warehouse-Token that will allow them to be accepted.\n if (req.http.Warehouse-Token) {\n # Set a header to tell the backend if we're using https or http.\n if (req.http.Fastly-SSL) {\n set req.http.Warehouse-Proto = \"https\";\n } else {\n set req.http.Warehouse-Proto = \"http\";\n }\n\n # Pass the client IP address back to the backend.\n if (req.http.Fastly-Client-IP) {\n set req.http.Warehouse-IP = req.http.Fastly-Client-IP;\n }\n\n # Pass the real host value back to the backend.\n if (req.http.Host) {\n set req.http.Warehouse-Host = req.http.Host;\n }\n }\n\n # Do not bother to attempt to run the caching mechanisms for methods that\n # are not generally safe to cache.\n if (req.request != \"HEAD\" &&\n req.request != \"GET\" &&\n req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n # Finally, return the default lookup action.\n return(lookup);\n}\n\n\nsub vcl_fetch {\n#FASTLY fetch\n\n # Trigger a \"SSL is required\" error if the backend has indicated to do so.\n if (beresp.http.X-Fastly-Error == \"803\") {\n error 803 \"SSL is required\";\n }\n\n # If we've gotten a 502 or a 503 from the backend, we'll go ahead and retry\n # the request.\n if ((beresp.status == 502 || beresp.status == 503) &&\n req.restarts < 1 &&\n (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n # If we've restarted, then we'll record the number of restarts.\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n # If there is a Set-Cookie header, we'll ensure that we do not cache the\n # response.\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n # If the response has the private Cache-Control directive then we won't\n # cache it.\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # If we've gotten an error after the restarts we'll deliver the response\n # with a very short cache time.\n if (beresp.status == 500 || beresp.status == 503) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n # Apply a default TTL if there isn't a max-age or s-maxage.\n if (beresp.http.Expires ||\n beresp.http.Surrogate-Control ~ \"max-age\" ||\n beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # Keep the ttl here\n }\n else {\n # Apply the default ttl\n set beresp.ttl = 60s;\n }\n\n # Actually deliver the fetched response.\n return(deliver);\n}\n\n\nsub vcl_deliver {\n#FASTLY deliver\n\n # Unset headers that we don't need\/want to send on to the client because\n # they are not generally useful.\n unset resp.http.Server;\n unset resp.http.Via;\n\n # Unset a few headers set by Amazon that we don't really have a need\/desire\n # to send to clients.\n unset resp.http.X-AMZ-Replication-Status;\n unset resp.http.X-AMZ-Meta-Python-Version;\n unset resp.http.X-AMZ-Meta-Version;\n unset resp.http.X-AMZ-Meta-Package-Type;\n unset resp.http.X-AMZ-Meta-Project;\n\n # Set our standard security headers, we do this in VCL rather than in\n # Warehouse itself so that we always get these headers, regardless of the\n # origin server being used.\n set resp.http.Strict-Transport-Security = \"max-age=31536000; includeSubDomains; preload\";\n set resp.http.X-Frame-Options = \"deny\";\n set resp.http.X-XSS-Protection = \"1; mode=block\";\n set resp.http.X-Content-Type-Options = \"nosniff\";\n set resp.http.X-Permitted-Cross-Domain-Policies = \"none\";\n\n return(deliver);\n}\n\n\nsub vcl_error {\n#FASTLY error\n\n if (obj.status == 803) {\n set obj.status = 403;\n set obj.response = \"SSL is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic {\"SSL is required.\"};\n return (deliver);\n } else if (obj.status == 750) {\n set obj.status = 301;\n set obj.http.Location = req.http.Location;\n set obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n synthetic {\"<html><head><title>301 Moved Permanently<\/title><\/head><body><center><h1>301 Moved Permanently<\/h1><\/center><\/body><\/html>\"};\n return(deliver);\n }\n\n}\n","old_contents":"\nsub vcl_recv {\n\n # Some (Older) clients will send a hash fragment as part of the URL even\n # though that is a local only modification. This breaks this badly for the\n # files in S3, and in general it's just not needed.\n set req.url = regsub(req.url, \"#.*$\", \"\");\n\n # Sort all of our query parameters, this will ensure that the same query\n # parameters in a different order will end up being represented as the same\n # thing, reducing cache misses due to ordering differences.\n set req.url = boltsort.sort(req.url);\n\n\n#FASTLY recv\n\n\n # We want to Force SSL for the WebUI by redirecting to the HTTPS version of\n # the page, however for API calls we want to return an error code directing\n # people to instead use HTTPS.\n if (!req.http.Fastly-SSL) {\n\n # The \/simple\/ and \/packages\/ API.\n if (req.url ~ \"^\/(simple|packages)\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy JSON API.\n if (req.url ~ \"^\/pypi\/.+\/json$\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy ?:action= API.\n if (req.url ~ \"^\/pypi.*(\\?|&)=:action\") {\n error 803 \"SSL is required\";\n }\n\n # If we're on the \/pypi page and we've received something other than a\n # GET or HEAD request, then we have no way to determine if a particular\n # request is an API call or not because it'll be in the request body\n # and that isn't available to us here. So in those cases, we won't\n # do a redirect.\n if (req.url ~ \"^\/pypi\") {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n error 801 \"Force SSL\";\n }\n }\n else {\n # This isn't a \/pypi URL so we'll just unconditionally redirect to\n # HTTPS.\n error 801 \"Force SSL\";\n }\n }\n\n # Canonicalize our domains by redirecting any domain that doesn't match our\n # primary domain to our primary domain. We do this *after* the HTTPS check\n # on purpose.\n if (std.tolower(req.http.host) != std.tolower(req.http.Primary-Domain)) {\n set req.http.Location = \"https:\/\/\" req.http.Primary-Domain req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n\n # Requests to \/packages\/ get dispatched to Amazon instead of to our typical\n # Origin. This requires a a bit of setup to make it work.\n if (req.url ~ \"^\/packages\/\") {\n # Setup our environment to better match what S3 expects\/needs\n set req.http.Host = req.http.AWS-Bucket-Name \".s3.amazonaws.com\";\n set req.http.Date = now;\n set req.url = regsuball(req.url, \"\\+\", urlencode(\"+\"));\n\n # Compute the Authorization header that S3 requires to be able to\n # access the files stored there.\n set req.http.Authorization = \"AWS \" req.http.AWS-Access-Key-ID \":\" digest.hmac_sha1_base64(req.http.AWS-Secret-Access-Key, \"GET\" LF LF LF req.http.Date LF \"\/\" req.http.AWS-Bucket-Name req.url.path);\n\n # We don't want to send our Warehouse-Token to S3, so we'll go ahead\n # and remove it.\n unset req.http.Warehouse-Token;\n }\n\n # We no longer need any of these variables, which would exist only to\n # shuffle configuration from the Fastly UI into our VCL.\n unset req.http.Primary-Domain;\n unset req.http.AWS-Access-Key-ID;\n unset req.http.AWS-Secret-Access-Key;\n unset req.http.AWS-Bucket-Name;\n\n # We have a number of items that we'll pass back to the origin, but only\n # if we have a Warehouse-Token that will allow them to be accepted.\n if (req.http.Warehouse-Token) {\n # Set a header to tell the backend if we're using https or http.\n if (req.http.Fastly-SSL) {\n set req.http.Warehouse-Proto = \"https\";\n } else {\n set req.http.Warehouse-Proto = \"http\";\n }\n\n # Pass the client IP address back to the backend.\n if (req.http.Fastly-Client-IP) {\n set req.http.Warehouse-IP = req.http.Fastly-Client-IP;\n }\n\n # Pass the real host value back to the backend.\n if (req.http.Host) {\n set req.http.Warehouse-Host = req.http.Host;\n }\n }\n\n # Do not bother to attempt to run the caching mechanisms for methods that\n # are not generally safe to cache.\n if (req.request != \"HEAD\" &&\n req.request != \"GET\" &&\n req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n # Finally, return the default lookup action.\n return(lookup);\n}\n\n\nsub vcl_fetch {\n#FASTLY fetch\n\n # Trigger a \"SSL is required\" error if the backend has indicated to do so.\n if (beresp.http.X-Fastly-Error == \"803\") {\n error 803 \"SSL is required\";\n }\n\n # If we've gotten a 502 or a 503 from the backend, we'll go ahead and retry\n # the request.\n if ((beresp.status == 502 || beresp.status == 503) &&\n req.restarts < 1 &&\n (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n # If we've restarted, then we'll record the number of restarts.\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n # If there is a Set-Cookie header, we'll ensure that we do not cache the\n # response.\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n # If the response has the private Cache-Control directive then we won't\n # cache it.\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # If we've gotten an error after the restarts we'll deliver the response\n # with a very short cache time.\n if (beresp.status == 500 || beresp.status == 503) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n # Apply a default TTL if there isn't a max-age or s-maxage.\n if (beresp.http.Expires ||\n beresp.http.Surrogate-Control ~ \"max-age\" ||\n beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # Keep the ttl here\n }\n else {\n # Apply the default ttl\n set beresp.ttl = 60s;\n }\n\n # Actually deliver the fetched response.\n return(deliver);\n}\n\n\nsub vcl_deliver {\n#FASTLY deliver\n\n # Unset headers that we don't need\/want to send on to the client because\n # they are not generally useful.\n unset resp.http.Server;\n unset resp.http.Via;\n\n # Unset a few headers set by Amazon that we don't really have a need\/desire\n # to send to clients.\n unset resp.http.X-AMZ-Replication-Status;\n unset resp.http.X-AMZ-Meta-Python-Version;\n unset resp.http.X-AMZ-Meta-Version;\n unset resp.http.X-AMZ-Meta-Package-Type;\n unset resp.http.X-AMZ-Meta-Project;\n\n # Set our standard security headers, we do this in VCL rather than in\n # Warehouse itself so that we always get these headers, regardless of the\n # origin server being used.\n set resp.http.Strict-Transport-Security = \"max-age=31536000; includeSubDomains; preload\";\n set resp.http.X-Frame-Options = \"deny\";\n set resp.http.X-XSS-Protection = \"1; mode=block\";\n set resp.http.X-Content-Type-Options = \"nosniff\";\n set resp.http.X-Permitted-Cross-Domain-Policies = \"none\";\n\n return(deliver);\n}\n\n\nsub vcl_error {\n#FASTLY error\n\n if (obj.status == 803) {\n set obj.status = 403;\n set obj.response = \"SSL is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic {\"SSL is required.\"};\n return (deliver);\n } else if (obj.status == 750) {\n set obj.status = 301;\n set obj.http.Location = req.http.Location;\n set obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n synthetic {\"<html><head><title>301 Moved Permanently<\/title><\/head><body><center><h1>301 Moved Permanently<\/h1><\/center><\/body><\/html>\"};\n return(deliver);\n }\n\n}\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"8a1176907b13c66d1bbf6219a7126c35d72cb07c","subject":"Varnish: Strip away simplesamlphp cookie, as it prevents caching","message":"Varnish: Strip away simplesamlphp cookie, as it prevents caching\n","repos":"reinier-vegter\/Simple-Drupal-Docker-Toolset,reinier-vegter\/Simple-Drupal-Docker-Toolset,reinier-vegter\/Simple-Drupal-Docker-Toolset","old_file":"dockerfiles\/d7\/bootstrap\/varnish-default.vcl","new_file":"dockerfiles\/d7\/bootstrap\/varnish-default.vcl","new_contents":"backend default {\n .host = \"127.0.0.1\";\n .port = \"90\";\n .connect_timeout = 600s;\n .first_byte_timeout = 600s;\n .between_bytes_timeout = 600s;\n .max_connections = 800;\n}\n## Internal IPs (office etc)\nacl internal {\n \"212.78.164.66\";\n \"185.54.180.250\";\n \"176.74.250.121\";\n}\n## Purges are allowed from these IPs, as well as from 'internal' IPs.\nacl purge {\n \"localhost\";\n \"127.0.0.1\";\n}\n# Code determining what to do when serving items from the Apache servers.\n# beresp == Back-end response from the web server.\nsub vcl_fetch {\n\n # We need this to cache 404s, 301s, 500s. Otherwise, depending on backend but\n # definitely in Drupal's case these responses are not cacheable by default.\n if (beresp.status == 404 || beresp.status == 301 || beresp.status == 500) {\n set beresp.ttl = 10m;\n }\n ## 403's mogen niet gecached worden\n if (beresp.status == 403) {\n return (hit_for_pass);\n }\n # Don't allow static files to set cookies.\n # (?i) denotes case insensitive in PCRE (perl compatible regular expressions).\n # This list of extensions appears twice, once here and again in vcl_recv so\n # make sure you edit both and keep them equal.\n if (req.url ~ \"(?i)\\.(pdf|asc|dat|txt|doc|xls|ppt|tgz|csv|png|gif|jpeg|jpg|ico|swf|svg|css|js|woff|eot|ttf)(\\?.*)?$\") {\n unset beresp.http.set-cookie;\n }\n\n # cache images, if Drupal didn't say we can't.\n if (req.url ~ \"(?i)\\.(pdf|asc|dat|txt|doc|xls|ppt|tgz|csv|png|gif|jpeg|jpg|ico|swf|svg|css|js|woff|eot|ttf)(\\?.*)?$\" &&\n !beresp.http.Cache-Control) {\n set beresp.ttl = 601s;\n set beresp.http.Cache-Control = \"public,max-age=601\";\n }\n\n # Allow items to be stale if needed.\n set beresp.grace = 10m;\n\n # cache robots.txt for 1 hour.\n if(req.url == \"\/robots.txt\") {\n # Robots.txt is updated rarely and should be cached for 4 days\n # Purge manually as required\n set beresp.ttl = 3600s;\n set beresp.http.Cache-Control = \"public,max-age=3600s\";\n }\n}\n\n# Respond to incoming requests.\nsub vcl_recv {\n ## Allow purging from drupal.\n # Check the incoming request type is \"PURGE\", not \"GET\" or \"POST\"\n if (req.request == \"PURGE\") {\n # Check if the ip coresponds with the acl purge\n if (!client.ip ~ purge && !client.ip ~ internal) {\n # Return error code 405 (Forbidden) when not\n error 405 \"Not allowed.\";\n }\n return (lookup);\n }\n # Get rid of progress.js query params\n if (req.url ~ \"^\/misc\/progress\\.js\\?[0-9]+$\") {\n set req.url = \"\/misc\/progress.js\";\n }\n\n # Pipe these paths directly to Apache for streaming.\n if (req.url ~ \"^\/admin\/content\/backup_migrate\/export\") {\n return (pipe);\n }\n\n # If global redirect is on\n # if (req.url ~ \"node\\?page=[0-9]+$\") {\n # set req.url = regsub(req.url, \"node(\\?page=[0-9]+$)\", \"\\1\");\n # return (lookup);\n # }\n\n # Do not cache these paths.\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php\" ||\n req.url ~ \"^\/install\\.php\" ||\n req.url ~ \"^\/admin\" ||\n req.url ~ \"^\/admin\/.*$\" ||\n req.url ~ \"^\/user\" ||\n req.url ~ \"^\/user\/.*$\" ||\n req.url ~ \"^\/users\/.*$\" ||\n req.url ~ \"^\/info\/.*$\" ||\n req.url ~ \"^\/flag\/.*$\" ||\n req.url ~ \"^.*\/ajax\/.*$\" ||\n req.url ~ \"^.*\/ahah\/.*$\" ||\n req.url ~ \"^\/saml\") {\n return (pass);\n }\n\n # Disallow outside access to cron.php or install.php\n if (req.url ~ \"^\/(cron|install)\\.php$\" && !client.ip ~ internal) {\n # Either let Varnish throw the error directly,\n error 404 \"Page not found.\";\n # Or, use a custom error page that you've defined in Drupal at the path \"404\".\n # set req.url = \"\/404\";\n }\n\n # Always cache the following file types for all users.\n if (req.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm)(\\?[a-z0-9]+)?$\") {\n unset req.http.Cookie;\n }\n # Remove all cookies that Drupal doesn't need to know about. ANY remaining\n # cookie will cause the request to pass-through to Apache. For the most part\n # we always set the NO_CACHE cookie after any POST request, disabling the\n # Varnish cache temporarily. The session cookie allows all authenticated users\n # to pass through as long as they're logged in.\n # @see http:\/\/drupal.stackexchange.com\/questions\/53467\n #\n # 1. Append a semi-colon to the front of the cookie string.\n # 2. Remove all spaces that appear after semi-colons.\n # 3. Match the cookies we want to keep, adding the space we removed\n # previously, back. (\\1) is first matching group in the regsuball.\n # 4. Remove all other cookies, identifying them by the fact that they have\n # no space after the preceding semi-colon.\n # 5. Remove all spaces and semi-colons from the beginning and end of the\n # cookie string.\n if (req.http.Cookie) {\n set req.http.Cookie = \";\" + req.http.Cookie;\n set req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n set req.http.Cookie = regsuball(req.http.Cookie, \";(S{1,2}ESS[a-z0-9]+|NO_CACHE)=\", \"; \\1=\");\n set req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n\n # Remove the \"has_js\" cookie\n set req.http.Cookie = regsuball(req.http.Cookie, \"has_js=[^;]+(; )?\", \"\");\n # Remove the \"Drupal.toolbar.collapsed\" cookie\n set req.http.Cookie = regsuball(req.http.Cookie, \"Drupal.toolbar.collapsed=[^;]+(; )?\", \"\");\n # Remove AdminToolbar cookie for drupal6\n set req.http.Cookie = regsuball(req.http.Cookie, \"DrupalAdminToolbar=[^;]+(; )?\", \"\");\n # Remove any Google Analytics based cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__utm.=[^;]+(; )?\", \"\");\n # Remove the Quant Capital cookies (added by some plugin, all __qca)\n set req.http.Cookie = regsuball(req.http.Cookie, \"__qc.=[^;]+(; )?\", \"\");\n\n # Remove simplesaml cookie, if no Drupal session cookie is provided.\n if (req.url !~ \"saml\" && req.http.Cookie !~ \"S{1,2}ESS\") {\n set req.http.Cookie = regsuball(req.http.Cookie, \"SimpleSAMLSessionID=[^;]+(; )?\", \"\");\n }\n\n # If there are no remaining cookies, remove the cookie header. If there\n # aren't any cookie headers, Varnish's default behavior will be to cache\n # the page.\n if (req.http.Cookie == \"\") {\n unset req.http.Cookie;\n }\n\n # If there are any cookies left (a session or NO_CACHE cookie), do not\n # cache the page; pass it on to Apache directly.\n else {\n return (pass);\n }\n }\n}\n# Set a header to track a cache HIT\/MISS.\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Varnish-Cache = \"HIT\";\n }\n else {\n set resp.http.X-Varnish-Cache = \"MISS\";\n }\n}\n## Purging responses.\nsub vcl_hit {\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged.\";\n }\n}\nsub vcl_miss {\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged.\";\n }\n}\n","old_contents":"backend default {\n .host = \"127.0.0.1\";\n .port = \"90\";\n .connect_timeout = 600s;\n .first_byte_timeout = 600s;\n .between_bytes_timeout = 600s;\n .max_connections = 800;\n}\n## Internal IPs (office etc)\nacl internal {\n \"212.78.164.66\";\n \"185.54.180.250\";\n \"176.74.250.121\";\n}\n## Purges are allowed from these IPs, as well as from 'internal' IPs.\nacl purge {\n \"localhost\";\n \"127.0.0.1\";\n}\n# Code determining what to do when serving items from the Apache servers.\n# beresp == Back-end response from the web server.\nsub vcl_fetch {\n\n # We need this to cache 404s, 301s, 500s. Otherwise, depending on backend but\n # definitely in Drupal's case these responses are not cacheable by default.\n if (beresp.status == 404 || beresp.status == 301 || beresp.status == 500) {\n set beresp.ttl = 10m;\n }\n ## 403's mogen niet gecached worden\n if (beresp.status == 403) {\n return (hit_for_pass);\n }\n # Don't allow static files to set cookies.\n # (?i) denotes case insensitive in PCRE (perl compatible regular expressions).\n # This list of extensions appears twice, once here and again in vcl_recv so\n # make sure you edit both and keep them equal.\n if (req.url ~ \"(?i)\\.(pdf|asc|dat|txt|doc|xls|ppt|tgz|csv|png|gif|jpeg|jpg|ico|swf|svg|css|js|woff|eot|ttf)(\\?.*)?$\") {\n unset beresp.http.set-cookie;\n }\n\n # cache images, if Drupal didn't say we can't.\n if (req.url ~ \"(?i)\\.(pdf|asc|dat|txt|doc|xls|ppt|tgz|csv|png|gif|jpeg|jpg|ico|swf|svg|css|js|woff|eot|ttf)(\\?.*)?$\" &&\n !beresp.http.Cache-Control) {\n set beresp.ttl = 601s;\n set beresp.http.Cache-Control = \"public,max-age=601\";\n }\n\n # Allow items to be stale if needed.\n set beresp.grace = 10m;\n\n # cache robots.txt for 1 hour.\n if(req.url == \"\/robots.txt\") {\n # Robots.txt is updated rarely and should be cached for 4 days\n # Purge manually as required\n set beresp.ttl = 3600s;\n set beresp.http.Cache-Control = \"public,max-age=3600s\";\n }\n}\n\n# Respond to incoming requests.\nsub vcl_recv {\n ## Allow purging from drupal.\n # Check the incoming request type is \"PURGE\", not \"GET\" or \"POST\"\n if (req.request == \"PURGE\") {\n # Check if the ip coresponds with the acl purge\n if (!client.ip ~ purge && !client.ip ~ internal) {\n # Return error code 405 (Forbidden) when not\n error 405 \"Not allowed.\";\n }\n return (lookup);\n }\n # Get rid of progress.js query params\n if (req.url ~ \"^\/misc\/progress\\.js\\?[0-9]+$\") {\n set req.url = \"\/misc\/progress.js\";\n }\n\n # Pipe these paths directly to Apache for streaming.\n if (req.url ~ \"^\/admin\/content\/backup_migrate\/export\") {\n return (pipe);\n }\n\n # If global redirect is on\n # if (req.url ~ \"node\\?page=[0-9]+$\") {\n # set req.url = regsub(req.url, \"node(\\?page=[0-9]+$)\", \"\\1\");\n # return (lookup);\n # }\n\n # Do not cache these paths.\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php\" ||\n req.url ~ \"^\/install\\.php\" ||\n req.url ~ \"^\/admin\" ||\n req.url ~ \"^\/admin\/.*$\" ||\n req.url ~ \"^\/user\" ||\n req.url ~ \"^\/user\/.*$\" ||\n req.url ~ \"^\/users\/.*$\" ||\n req.url ~ \"^\/info\/.*$\" ||\n req.url ~ \"^\/flag\/.*$\" ||\n req.url ~ \"^.*\/ajax\/.*$\" ||\n req.url ~ \"^.*\/ahah\/.*$\") {\n return (pass);\n }\n\n # Disallow outside access to cron.php or install.php\n if (req.url ~ \"^\/(cron|install)\\.php$\" && !client.ip ~ internal) {\n # Either let Varnish throw the error directly,\n error 404 \"Page not found.\";\n # Or, use a custom error page that you've defined in Drupal at the path \"404\".\n # set req.url = \"\/404\";\n }\n\n # Always cache the following file types for all users.\n if (req.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm)(\\?[a-z0-9]+)?$\") {\n unset req.http.Cookie;\n }\n # Remove all cookies that Drupal doesn't need to know about. ANY remaining\n # cookie will cause the request to pass-through to Apache. For the most part\n # we always set the NO_CACHE cookie after any POST request, disabling the\n # Varnish cache temporarily. The session cookie allows all authenticated users\n # to pass through as long as they're logged in.\n # @see http:\/\/drupal.stackexchange.com\/questions\/53467\n #\n # 1. Append a semi-colon to the front of the cookie string.\n # 2. Remove all spaces that appear after semi-colons.\n # 3. Match the cookies we want to keep, adding the space we removed\n # previously, back. (\\1) is first matching group in the regsuball.\n # 4. Remove all other cookies, identifying them by the fact that they have\n # no space after the preceding semi-colon.\n # 5. Remove all spaces and semi-colons from the beginning and end of the\n # cookie string.\n if (req.http.Cookie) {\n set req.http.Cookie = \";\" + req.http.Cookie;\n set req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n set req.http.Cookie = regsuball(req.http.Cookie, \";(S{1,2}ESS[a-z0-9]+|NO_CACHE)=\", \"; \\1=\");\n set req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n\n # Remove the \"has_js\" cookie\n set req.http.Cookie = regsuball(req.http.Cookie, \"has_js=[^;]+(; )?\", \"\");\n # Remove the \"Drupal.toolbar.collapsed\" cookie\n set req.http.Cookie = regsuball(req.http.Cookie, \"Drupal.toolbar.collapsed=[^;]+(; )?\", \"\");\n # Remove AdminToolbar cookie for drupal6\n set req.http.Cookie = regsuball(req.http.Cookie, \"DrupalAdminToolbar=[^;]+(; )?\", \"\");\n # Remove any Google Analytics based cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__utm.=[^;]+(; )?\", \"\");\n # Remove the Quant Capital cookies (added by some plugin, all __qca)\n set req.http.Cookie = regsuball(req.http.Cookie, \"__qc.=[^;]+(; )?\", \"\");\n\n # If there are no remaining cookies, remove the cookie header. If there\n # aren't any cookie headers, Varnish's default behavior will be to cache\n # the page.\n if (req.http.Cookie == \"\") {\n unset req.http.Cookie;\n }\n\n # If there are any cookies left (a session or NO_CACHE cookie), do not\n # cache the page; pass it on to Apache directly.\n else {\n return (pass);\n }\n }\n}\n# Set a header to track a cache HIT\/MISS.\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Varnish-Cache = \"HIT\";\n }\n else {\n set resp.http.X-Varnish-Cache = \"MISS\";\n }\n}\n## Purging responses.\nsub vcl_hit {\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged.\";\n }\n}\nsub vcl_miss {\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged.\";\n }\n}","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"c25781a5aea2dc3fa5ea4bf85708db9007a4c90f","subject":"Only redirect www.pypi.io not any non primary domain","message":"Only redirect www.pypi.io not any non primary domain\n","repos":"pypa\/warehouse,dstufft\/warehouse,dstufft\/warehouse,dstufft\/warehouse,karan\/warehouse,alex\/warehouse,pypa\/warehouse,karan\/warehouse,alex\/warehouse,karan\/warehouse,karan\/warehouse,alex\/warehouse,karan\/warehouse,wlonk\/warehouse,dstufft\/warehouse,alex\/warehouse,pypa\/warehouse,alex\/warehouse,pypa\/warehouse,wlonk\/warehouse,wlonk\/warehouse","old_file":"vcl\/main.vcl","new_file":"vcl\/main.vcl","new_contents":"\nsub vcl_recv {\n\n # I'm not 100% sure on what this is exactly for, it was taken from the\n # Fastly documentation, however, what I *believe* it does is just ensure\n # that we don't serve a stale copy of the page from the shield node when\n # an edge node is requesting content.\n if (req.http.Fastly-FF) {\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Some (Older) clients will send a hash fragment as part of the URL even\n # though that is a local only modification. This breaks this badly for the\n # files in S3, and in general it's just not needed.\n set req.url = regsub(req.url, \"#.*$\", \"\");\n\n # Most of the URLs in Warehouse do not support or require any sort of query\n # parameter. If we strip these at the edge then we'll increase our cache\n # efficiency when they won't otherwise change the output of the pages.\n #\n # This will match any URL except those that start with:\n #\n # * \/search\/\n # * \/account\/login\/\n # * \/account\/logout\/\n # * \/account\/register\/\n # * \/pypi\n if (req.url !~ \"^\/(search\/|account\/(login|logout|register)\/|pypi)\") {\n set req.url = req.url.path;\n }\n\n # Sort all of our query parameters, this will ensure that the same query\n # parameters in a different order will end up being represented as the same\n # thing, reducing cache misses due to ordering differences.\n set req.url = boltsort.sort(req.url);\n\n\n#FASTLY recv\n\n\n # We want to Force SSL for the WebUI by redirecting to the HTTPS version of\n # the page, however for API calls we want to return an error code directing\n # people to instead use HTTPS.\n if (!req.http.Fastly-SSL) {\n\n # The \/simple\/ and \/packages\/ API.\n if (req.url ~ \"^\/(simple|packages)\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy JSON API.\n if (req.url ~ \"^\/pypi\/.+\/json$\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy ?:action= API.\n if (req.url ~ \"^\/pypi.*(\\?|&)=:action\") {\n error 803 \"SSL is required\";\n }\n\n # If we're on the \/pypi page and we've received something other than a\n # GET or HEAD request, then we have no way to determine if a particular\n # request is an API call or not because it'll be in the request body\n # and that isn't available to us here. So in those cases, we won't\n # do a redirect.\n if (req.url ~ \"^\/pypi\") {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n error 801 \"Force SSL\";\n }\n }\n else {\n # This isn't a \/pypi URL so we'll just unconditionally redirect to\n # HTTPS.\n error 801 \"Force SSL\";\n }\n }\n\n # Redirect www.pypi.io to pypi.io, this is purposely done *after* the HTTPS\n # checks.\n if (std.tolower(req.http.host) == \"www.pypi.io\") {\n set req.http.Location = \"https:\/\/pypi.io\" req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n\n # Requests to \/packages\/ get dispatched to Amazon instead of to our typical\n # Origin. This requires a a bit of setup to make it work.\n if (req.url ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\") {\n # Setup our environment to better match what S3 expects\/needs\n set req.http.Host = req.http.AWS-Bucket-Name \".s3.amazonaws.com\";\n set req.http.Date = now;\n set req.url = regsuball(req.url, \"\\+\", urlencode(\"+\"));\n\n # Compute the Authorization header that S3 requires to be able to\n # access the files stored there.\n set req.http.Authorization = \"AWS \" req.http.AWS-Access-Key-ID \":\" digest.hmac_sha1_base64(req.http.AWS-Secret-Access-Key, \"GET\" LF LF LF req.http.Date LF \"\/\" req.http.AWS-Bucket-Name req.url.path);\n\n # We don't want to send our Warehouse-Token to S3, so we'll go ahead\n # and remove it.\n unset req.http.Warehouse-Token;\n }\n\n # We no longer need any of these variables, which would exist only to\n # shuffle configuration from the Fastly UI into our VCL.\n unset req.http.AWS-Access-Key-ID;\n unset req.http.AWS-Secret-Access-Key;\n unset req.http.AWS-Bucket-Name;\n\n # We have a number of items that we'll pass back to the origin, but only\n # if we have a Warehouse-Token that will allow them to be accepted.\n if (req.http.Warehouse-Token) {\n # Set a header to tell the backend if we're using https or http.\n if (req.http.Fastly-SSL) {\n set req.http.Warehouse-Proto = \"https\";\n } else {\n set req.http.Warehouse-Proto = \"http\";\n }\n\n # Pass the client IP address back to the backend.\n if (req.http.Fastly-Client-IP) {\n set req.http.Warehouse-IP = req.http.Fastly-Client-IP;\n }\n\n # Pass the real host value back to the backend.\n if (req.http.Host) {\n set req.http.Warehouse-Host = req.http.host;\n }\n }\n\n # On a POST, we want to skip the shielding and hit backends directly.\n if (req.request == \"POST\") {\n set req.backend = F_Heroku;\n }\n\n # Do not bother to attempt to run the caching mechanisms for methods that\n # are not generally safe to cache.\n if (req.request != \"HEAD\" &&\n req.request != \"GET\" &&\n req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n # We don't ever want to cache our health URL. Outside systems should be\n # able to use it to reach past Fastly and get an end to end health check.\n if (req.url == \"\/_health\/\") {\n return(pass);\n }\n\n # Finally, return the default lookup action.\n return(lookup);\n}\n\n\nsub vcl_fetch {\n\n # These are newer kinds of redirects which should be able to be cached by\n # default, even though Fastly doesn't currently have them in their default\n # list of cacheable status codes.\n if (http_status_matches(beresp.status, \"303,307,308\")) {\n set beresp.cacheable = true;\n }\n\n # For any 5xx status code we want to see if a stale object exists for it,\n # if so we'll go ahead and serve it.\n if (beresp.status >= 500 && beresp.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n\n#FASTLY fetch\n\n\n # Trigger a \"SSL is required\" error if the backend has indicated to do so.\n if (beresp.http.X-Fastly-Error == \"803\") {\n error 803 \"SSL is required\";\n }\n\n # If we've gotten a 502 or a 503 from the backend, we'll go ahead and retry\n # the request.\n if ((beresp.status == 502 || beresp.status == 503) &&\n req.restarts < 1 &&\n (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n # If we've restarted, then we'll record the number of restarts.\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n # If there is a Set-Cookie header, we'll ensure that we do not cache the\n # response.\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n # If the response has the private Cache-Control directive then we won't\n # cache it.\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # If we've gotten an error after the restarts we'll deliver the response\n # with a very short cache time.\n if (http_status_matches(beresp.status, \"500,502,503\")) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n # Apply a default TTL if there isn't a max-age or s-maxage.\n if (beresp.http.Expires ||\n beresp.http.Surrogate-Control ~ \"max-age\" ||\n beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # Keep the ttl here\n }\n else {\n # Apply the default ttl\n set beresp.ttl = 60s;\n }\n\n # Actually deliver the fetched response.\n return(deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n # If the object we have isn't cacheable, then just serve it directly\n # without going through any of the caching mechanisms.\n if (!obj.cacheable) {\n return(pass);\n }\n\n return(deliver);\n}\n\n\nsub vcl_deliver {\n # If this is an error and we have a stale response available, restart so\n # that we can pick it up and serve it.\n if (resp.status >= 500 && resp.status < 600) {\n if (stale.exists) {\n restart;\n }\n }\n\n#FASTLY deliver\n\n # Unset headers that we don't need\/want to send on to the client because\n # they are not generally useful.\n unset resp.http.Server;\n unset resp.http.Via;\n\n # Unset a few headers set by Amazon that we don't really have a need\/desire\n # to send to clients.\n unset resp.http.X-AMZ-Replication-Status;\n unset resp.http.X-AMZ-Meta-Python-Version;\n unset resp.http.X-AMZ-Meta-Version;\n unset resp.http.X-AMZ-Meta-Package-Type;\n unset resp.http.X-AMZ-Meta-Project;\n\n # Set our standard security headers, we do this in VCL rather than in\n # Warehouse itself so that we always get these headers, regardless of the\n # origin server being used.\n set resp.http.Strict-Transport-Security = \"max-age=31536000; includeSubDomains; preload\";\n set resp.http.X-Frame-Options = \"deny\";\n set resp.http.X-XSS-Protection = \"1; mode=block\";\n set resp.http.X-Content-Type-Options = \"nosniff\";\n set resp.http.X-Permitted-Cross-Domain-Policies = \"none\";\n\n return(deliver);\n}\n\n\nsub vcl_error {\n#FASTLY error\n\n # If we have a 5xx error and there is a stale object available, then we\n # will deliver that stale object.\n if (obj.status >= 500 && obj.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n if (obj.status == 803) {\n set obj.status = 403;\n set obj.response = \"SSL is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic {\"SSL is required.\"};\n return (deliver);\n } else if (obj.status == 750) {\n set obj.status = 301;\n set obj.http.Location = req.http.Location;\n set obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n synthetic {\"<html><head><title>301 Moved Permanently<\/title><\/head><body><center><h1>301 Moved Permanently<\/h1><\/center><\/body><\/html>\"};\n return(deliver);\n }\n\n}\n","old_contents":"\nsub vcl_recv {\n\n # I'm not 100% sure on what this is exactly for, it was taken from the\n # Fastly documentation, however, what I *believe* it does is just ensure\n # that we don't serve a stale copy of the page from the shield node when\n # an edge node is requesting content.\n if (req.http.Fastly-FF) {\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Some (Older) clients will send a hash fragment as part of the URL even\n # though that is a local only modification. This breaks this badly for the\n # files in S3, and in general it's just not needed.\n set req.url = regsub(req.url, \"#.*$\", \"\");\n\n # Most of the URLs in Warehouse do not support or require any sort of query\n # parameter. If we strip these at the edge then we'll increase our cache\n # efficiency when they won't otherwise change the output of the pages.\n #\n # This will match any URL except those that start with:\n #\n # * \/search\/\n # * \/account\/login\/\n # * \/account\/logout\/\n # * \/account\/register\/\n # * \/pypi\n if (req.url !~ \"^\/(search\/|account\/(login|logout|register)\/|pypi)\") {\n set req.url = req.url.path;\n }\n\n # Sort all of our query parameters, this will ensure that the same query\n # parameters in a different order will end up being represented as the same\n # thing, reducing cache misses due to ordering differences.\n set req.url = boltsort.sort(req.url);\n\n\n#FASTLY recv\n\n\n # We want to Force SSL for the WebUI by redirecting to the HTTPS version of\n # the page, however for API calls we want to return an error code directing\n # people to instead use HTTPS.\n if (!req.http.Fastly-SSL) {\n\n # The \/simple\/ and \/packages\/ API.\n if (req.url ~ \"^\/(simple|packages)\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy JSON API.\n if (req.url ~ \"^\/pypi\/.+\/json$\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy ?:action= API.\n if (req.url ~ \"^\/pypi.*(\\?|&)=:action\") {\n error 803 \"SSL is required\";\n }\n\n # If we're on the \/pypi page and we've received something other than a\n # GET or HEAD request, then we have no way to determine if a particular\n # request is an API call or not because it'll be in the request body\n # and that isn't available to us here. So in those cases, we won't\n # do a redirect.\n if (req.url ~ \"^\/pypi\") {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n error 801 \"Force SSL\";\n }\n }\n else {\n # This isn't a \/pypi URL so we'll just unconditionally redirect to\n # HTTPS.\n error 801 \"Force SSL\";\n }\n }\n\n # Canonicalize our domains by redirecting any domain that doesn't match our\n # primary domain to our primary domain. We do this *after* the HTTPS check\n # on purpose.\n if (std.tolower(req.http.host) != std.tolower(req.http.Primary-Domain)) {\n set req.http.Location = \"https:\/\/\" req.http.Primary-Domain req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n\n # Requests to \/packages\/ get dispatched to Amazon instead of to our typical\n # Origin. This requires a a bit of setup to make it work.\n if (req.url ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\") {\n # Setup our environment to better match what S3 expects\/needs\n set req.http.Host = req.http.AWS-Bucket-Name \".s3.amazonaws.com\";\n set req.http.Date = now;\n set req.url = regsuball(req.url, \"\\+\", urlencode(\"+\"));\n\n # Compute the Authorization header that S3 requires to be able to\n # access the files stored there.\n set req.http.Authorization = \"AWS \" req.http.AWS-Access-Key-ID \":\" digest.hmac_sha1_base64(req.http.AWS-Secret-Access-Key, \"GET\" LF LF LF req.http.Date LF \"\/\" req.http.AWS-Bucket-Name req.url.path);\n\n # We don't want to send our Warehouse-Token to S3, so we'll go ahead\n # and remove it.\n unset req.http.Warehouse-Token;\n }\n\n # We no longer need any of these variables, which would exist only to\n # shuffle configuration from the Fastly UI into our VCL.\n unset req.http.Primary-Domain;\n unset req.http.AWS-Access-Key-ID;\n unset req.http.AWS-Secret-Access-Key;\n unset req.http.AWS-Bucket-Name;\n\n # We have a number of items that we'll pass back to the origin, but only\n # if we have a Warehouse-Token that will allow them to be accepted.\n if (req.http.Warehouse-Token) {\n # Set a header to tell the backend if we're using https or http.\n if (req.http.Fastly-SSL) {\n set req.http.Warehouse-Proto = \"https\";\n } else {\n set req.http.Warehouse-Proto = \"http\";\n }\n\n # Pass the client IP address back to the backend.\n if (req.http.Fastly-Client-IP) {\n set req.http.Warehouse-IP = req.http.Fastly-Client-IP;\n }\n\n # Pass the real host value back to the backend.\n if (req.http.Host) {\n set req.http.Warehouse-Host = req.http.host;\n }\n }\n\n # On a POST, we want to skip the shielding and hit backends directly.\n if (req.request == \"POST\") {\n set req.backend = F_Heroku;\n }\n\n # Do not bother to attempt to run the caching mechanisms for methods that\n # are not generally safe to cache.\n if (req.request != \"HEAD\" &&\n req.request != \"GET\" &&\n req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n # We don't ever want to cache our health URL. Outside systems should be\n # able to use it to reach past Fastly and get an end to end health check.\n if (req.url == \"\/_health\/\") {\n return(pass);\n }\n\n # Finally, return the default lookup action.\n return(lookup);\n}\n\n\nsub vcl_fetch {\n\n # These are newer kinds of redirects which should be able to be cached by\n # default, even though Fastly doesn't currently have them in their default\n # list of cacheable status codes.\n if (http_status_matches(beresp.status, \"303,307,308\")) {\n set beresp.cacheable = true;\n }\n\n # For any 5xx status code we want to see if a stale object exists for it,\n # if so we'll go ahead and serve it.\n if (beresp.status >= 500 && beresp.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n\n#FASTLY fetch\n\n\n # Trigger a \"SSL is required\" error if the backend has indicated to do so.\n if (beresp.http.X-Fastly-Error == \"803\") {\n error 803 \"SSL is required\";\n }\n\n # If we've gotten a 502 or a 503 from the backend, we'll go ahead and retry\n # the request.\n if ((beresp.status == 502 || beresp.status == 503) &&\n req.restarts < 1 &&\n (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n # If we've restarted, then we'll record the number of restarts.\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n # If there is a Set-Cookie header, we'll ensure that we do not cache the\n # response.\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n # If the response has the private Cache-Control directive then we won't\n # cache it.\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # If we've gotten an error after the restarts we'll deliver the response\n # with a very short cache time.\n if (http_status_matches(beresp.status, \"500,502,503\")) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n # Apply a default TTL if there isn't a max-age or s-maxage.\n if (beresp.http.Expires ||\n beresp.http.Surrogate-Control ~ \"max-age\" ||\n beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # Keep the ttl here\n }\n else {\n # Apply the default ttl\n set beresp.ttl = 60s;\n }\n\n # Actually deliver the fetched response.\n return(deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n # If the object we have isn't cacheable, then just serve it directly\n # without going through any of the caching mechanisms.\n if (!obj.cacheable) {\n return(pass);\n }\n\n return(deliver);\n}\n\n\nsub vcl_deliver {\n # If this is an error and we have a stale response available, restart so\n # that we can pick it up and serve it.\n if (resp.status >= 500 && resp.status < 600) {\n if (stale.exists) {\n restart;\n }\n }\n\n#FASTLY deliver\n\n # Unset headers that we don't need\/want to send on to the client because\n # they are not generally useful.\n unset resp.http.Server;\n unset resp.http.Via;\n\n # Unset a few headers set by Amazon that we don't really have a need\/desire\n # to send to clients.\n unset resp.http.X-AMZ-Replication-Status;\n unset resp.http.X-AMZ-Meta-Python-Version;\n unset resp.http.X-AMZ-Meta-Version;\n unset resp.http.X-AMZ-Meta-Package-Type;\n unset resp.http.X-AMZ-Meta-Project;\n\n # Set our standard security headers, we do this in VCL rather than in\n # Warehouse itself so that we always get these headers, regardless of the\n # origin server being used.\n set resp.http.Strict-Transport-Security = \"max-age=31536000; includeSubDomains; preload\";\n set resp.http.X-Frame-Options = \"deny\";\n set resp.http.X-XSS-Protection = \"1; mode=block\";\n set resp.http.X-Content-Type-Options = \"nosniff\";\n set resp.http.X-Permitted-Cross-Domain-Policies = \"none\";\n\n return(deliver);\n}\n\n\nsub vcl_error {\n#FASTLY error\n\n # If we have a 5xx error and there is a stale object available, then we\n # will deliver that stale object.\n if (obj.status >= 500 && obj.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n if (obj.status == 803) {\n set obj.status = 403;\n set obj.response = \"SSL is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic {\"SSL is required.\"};\n return (deliver);\n } else if (obj.status == 750) {\n set obj.status = 301;\n set obj.http.Location = req.http.Location;\n set obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n synthetic {\"<html><head><title>301 Moved Permanently<\/title><\/head><body><center><h1>301 Moved Permanently<\/h1><\/center><\/body><\/html>\"};\n return(deliver);\n }\n\n}\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"215fe8eb8c47450d1e67e35603c8e28f128ffaf6","subject":"Update device detection VCL","message":"Update device detection VCL\n","repos":"gquintard\/Varnish-Cache,gquintard\/Varnish-Cache,gquintard\/Varnish-Cache,gquintard\/Varnish-Cache","old_file":"etc\/devicedetect.vcl","new_file":"etc\/devicedetect.vcl","new_contents":"#\n# Copyright (c) 2016-2018 Varnish Cache project\n# Copyright (c) 2012-2016 Varnish Software AS\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions\n# are met:\n# 1. Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n# 2. Redistributions in binary form must reproduce the above copyright\n# notice, this list of conditions and the following disclaimer in the\n# documentation and\/or other materials provided with the distribution.\n#\n# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n# ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n# SUCH DAMAGE.\n#\n# detectdevice.vcl - regex based device detection for Varnish\n# https:\/\/github.com\/varnishcache\/varnish-devicedetect\/\n#\n# Original author: Lasse Karstensen <lkarsten@varnish-software.com>\n\nsub devicedetect {\n\tunset req.http.X-UA-Device;\n\tset req.http.X-UA-Device = \"pc\";\n\n\t# Handle that a cookie may override the detection alltogether.\n\tif (req.http.Cookie ~ \"(?i)X-UA-Device-force\") {\n\t\t\/* ;?? means zero or one ;, non-greedy to match the first. *\/\n\t\tset req.http.X-UA-Device = regsub(req.http.Cookie, \"(?i).*X-UA-Device-force=([^;]+);??.*\", \"\\1\");\n\t\t\/* Clean up our mess in the cookie header *\/\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|; ) *X-UA-Device-force=[^;]+;? *\", \"\\1\");\n\t\t\/* If the cookie header is now empty, or just whitespace, unset it. *\/\n\t\tif (req.http.Cookie ~ \"^ *$\") { unset req.http.Cookie; }\n\t} else {\n if (req.http.User-Agent ~ \"\\(compatible; Googlebot-Mobile\/2.1; \\+http:\/\/www.google.com\/bot.html\\)\" ||\n (req.http.User-Agent ~ \"(Android|iPhone)\" && req.http.User-Agent ~ \"\\(compatible.?; Googlebot\/2.1.?; \\+http:\/\/www.google.com\/bot.html\") ||\n\t\t\t(req.http.User-Agent ~ \"(iPhone|Windows Phone)\" && req.http.User-Agent ~ \"\\(compatible; bingbot\/2.0; \\+http:\/\/www.bing.com\/bingbot.htm\")) {\n set req.http.X-UA-Device = \"mobile-bot\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)(ads|google|bing|msn|yandex|baidu|ro|career|seznam|)bot\" ||\n\t\t req.http.User-Agent ~ \"(?i)(baidu|jike|symantec)spider\" ||\n\t\t req.http.User-Agent ~ \"(?i)pingdom\" ||\n\t\t req.http.User-Agent ~ \"(?i)facebookexternalhit\" ||\n\t\t req.http.User-Agent ~ \"(?i)scanner\" ||\n\t\t req.http.User-Agent ~ \"(?i)slurp\" ||\n\t\t req.http.User-Agent ~ \"(?i)(web)crawler\") {\n\t\t\tset req.http.X-UA-Device = \"bot\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ipad\") { set req.http.X-UA-Device = \"tablet-ipad\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ip(hone|od)\") { set req.http.X-UA-Device = \"mobile-iphone\"; }\n\t\t\/* how do we differ between an android phone and an android tablet?\n\t\t http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent *\/\n\t\telsif (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") { set req.http.X-UA-Device = \"mobile-android\"; }\n\t\t\/\/ android 3\/honeycomb was just about tablet-only, and any phones will probably handle a bigger page layout.\n\t\telsif (req.http.User-Agent ~ \"(?i)android 3\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\t\/* Opera Mobile *\/\n\t\telsif (req.http.User-Agent ~ \"Opera Mobi\") { set req.http.X-UA-Device = \"mobile-smartphone\"; }\n\t\t\/\/ May very well give false positives towards android tablets. Suggestions welcome.\n\t\telsif (req.http.User-Agent ~ \"(?i)android\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\telsif (req.http.User-Agent ~ \"PlayBook; U; RIM Tablet\") { set req.http.X-UA-Device = \"tablet-rim\"; }\n\t\telsif (req.http.User-Agent ~ \"hp-tablet.*TouchPad\") { set req.http.X-UA-Device = \"tablet-hp\"; }\n\t\telsif (req.http.User-Agent ~ \"Kindle\/3\") { set req.http.X-UA-Device = \"tablet-kindle\"; }\n\t\telsif (req.http.User-Agent ~ \"Touch.+Tablet PC\" ||\n\t\t req.http.User-Agent ~ \"Windows NT [0-9.]+; ARM;\" ) {\n\t\t set req.http.X-UA-Device = \"tablet-microsoft\";\n\t\t}\n\t\telsif (req.http.User-Agent ~ \"Mobile.+Firefox\") { set req.http.X-UA-Device = \"mobile-firefoxos\"; }\n\t\telsif (req.http.User-Agent ~ \"^HTC\" ||\n\t\t req.http.User-Agent ~ \"Fennec\" ||\n\t\t req.http.User-Agent ~ \"IEMobile\" ||\n\t\t req.http.User-Agent ~ \"BlackBerry\" ||\n\t\t req.http.User-Agent ~ \"BB10.*Mobile\" ||\n\t\t req.http.User-Agent ~ \"GT-.*Build\/GINGERBREAD\" ||\n\t\t req.http.User-Agent ~ \"SymbianOS.*AppleWebKit\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-smartphone\";\n\t\t}\n\t\telsif (req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)^sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)^nokia\" ||\n\t\t req.http.User-Agent ~ \"(?i)^samsung\" ||\n\t\t req.http.User-Agent ~ \"(?i)^lg\" ||\n\t\t req.http.User-Agent ~ \"(?i)bada\" ||\n\t\t req.http.User-Agent ~ \"(?i)blazer\" ||\n\t\t req.http.User-Agent ~ \"(?i)cellphone\" ||\n\t\t req.http.User-Agent ~ \"(?i)iemobile\" ||\n\t\t req.http.User-Agent ~ \"(?i)midp-2.0\" ||\n\t\t req.http.User-Agent ~ \"(?i)u990\" ||\n\t\t req.http.User-Agent ~ \"(?i)netfront\" ||\n\t\t req.http.User-Agent ~ \"(?i)opera mini\" ||\n\t\t req.http.User-Agent ~ \"(?i)palm\" ||\n\t\t req.http.User-Agent ~ \"(?i)nintendo wii\" ||\n\t\t req.http.User-Agent ~ \"(?i)playstation portable\" ||\n\t\t req.http.User-Agent ~ \"(?i)portalmmm\" ||\n\t\t req.http.User-Agent ~ \"(?i)proxinet\" ||\n\t\t req.http.User-Agent ~ \"(?i)windows\\ ?ce\" ||\n\t\t req.http.User-Agent ~ \"(?i)winwap\" ||\n\t\t req.http.User-Agent ~ \"(?i)eudoraweb\" ||\n\t\t req.http.User-Agent ~ \"(?i)htc\" ||\n\t\t req.http.User-Agent ~ \"(?i)240x320\" ||\n\t\t req.http.User-Agent ~ \"(?i)avantgo\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-generic\";\n\t\t}\n\t}\n}\n","old_contents":"# Copyright (c) 2012-2014 Varnish Software AS\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions\n# are met:\n# 1. Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n# 2. Redistributions in binary form must reproduce the above copyright\n# notice, this list of conditions and the following disclaimer in the\n# documentation and\/or other materials provided with the distribution.\n#\n# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n# ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n# SUCH DAMAGE.\n#\n# detectdevice.vcl - regex based device detection for Varnish\n# https:\/\/github.com\/varnishcache\/varnish-devicedetect\/\n#\n# Author: Lasse Karstensen <lkarsten@varnish-software.com>\n\nsub devicedetect {\n\tunset req.http.X-UA-Device;\n\tset req.http.X-UA-Device = \"pc\";\n\n\t# Handle that a cookie may override the detection alltogether.\n\tif (req.http.Cookie ~ \"(?i)X-UA-Device-force\") {\n\t\t\/* ;?? means zero or one ;, non-greedy to match the first. *\/\n\t\tset req.http.X-UA-Device = regsub(req.http.Cookie, \"(?i).*X-UA-Device-force=([^;]+);??.*\", \"\\1\");\n\t\t\/* Clean up our mess in the cookie header *\/\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|; ) *X-UA-Device-force=[^;]+;? *\", \"\\1\");\n\t\t\/* If the cookie header is now empty, or just whitespace, unset it. *\/\n\t\tif (req.http.Cookie ~ \"^ *$\") { unset req.http.Cookie; }\n\t} else {\n if (req.http.User-Agent ~ \"\\(compatible; Googlebot-Mobile\/2.1; \\+http:\/\/www.google.com\/bot.html\\)\" ||\n (req.http.User-Agent ~ \"(Android|iPhone)\" && req.http.User-Agent ~ \"\\(compatible.?; Googlebot\/2.1.?; \\+http:\/\/www.google.com\/bot.html\") ||\n\t\t\t(req.http.User-Agent ~ \"(iPhone|Windows Phone)\" && req.http.User-Agent ~ \"\\(compatible; bingbot\/2.0; \\+http:\/\/www.bing.com\/bingbot.htm\")) {\n set req.http.X-UA-Device = \"mobile-bot\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)(ads|google|bing|msn|yandex|baidu|ro|career|seznam|)bot\" ||\n\t\t req.http.User-Agent ~ \"(?i)(baidu|jike|symantec)spider\" ||\n\t\t req.http.User-Agent ~ \"(?i)scanner\" ||\n\t\t req.http.User-Agent ~ \"(?i)(web)crawler\") {\n\t\t\tset req.http.X-UA-Device = \"bot\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ipad\") { set req.http.X-UA-Device = \"tablet-ipad\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ip(hone|od)\") { set req.http.X-UA-Device = \"mobile-iphone\"; }\n\t\t\/* how do we differ between an android phone and an android tablet?\n\t\t http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent *\/\n\t\telsif (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") { set req.http.X-UA-Device = \"mobile-android\"; }\n\t\t\/\/ android 3\/honeycomb was just about tablet-only, and any phones will probably handle a bigger page layout.\n\t\telsif (req.http.User-Agent ~ \"(?i)android 3\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\t\/* Opera Mobile *\/\n\t\telsif (req.http.User-Agent ~ \"Opera Mobi\") { set req.http.X-UA-Device = \"mobile-smartphone\"; }\n\t\t\/\/ May very well give false positives towards android tablets. Suggestions welcome.\n\t\telsif (req.http.User-Agent ~ \"(?i)android\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\telsif (req.http.User-Agent ~ \"PlayBook; U; RIM Tablet\") { set req.http.X-UA-Device = \"tablet-rim\"; }\n\t\telsif (req.http.User-Agent ~ \"hp-tablet.*TouchPad\") { set req.http.X-UA-Device = \"tablet-hp\"; }\n\t\telsif (req.http.User-Agent ~ \"Kindle\/3\") { set req.http.X-UA-Device = \"tablet-kindle\"; }\n\t\telsif (req.http.User-Agent ~ \"Touch.+Tablet PC\" ||\n\t\t req.http.User-Agent ~ \"Windows NT [0-9.]+; ARM;\" ) {\n\t\t set req.http.X-UA-Device = \"tablet-microsoft\";\n\t\t}\n\t\telsif (req.http.User-Agent ~ \"Mobile.+Firefox\") { set req.http.X-UA-Device = \"mobile-firefoxos\"; }\n\t\telsif (req.http.User-Agent ~ \"^HTC\" ||\n\t\t req.http.User-Agent ~ \"Fennec\" ||\n\t\t req.http.User-Agent ~ \"IEMobile\" ||\n\t\t req.http.User-Agent ~ \"BlackBerry\" ||\n\t\t req.http.User-Agent ~ \"BB10.*Mobile\" ||\n\t\t req.http.User-Agent ~ \"GT-.*Build\/GINGERBREAD\" ||\n\t\t req.http.User-Agent ~ \"SymbianOS.*AppleWebKit\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-smartphone\";\n\t\t}\n\t\telsif (req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)^sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)^nokia\" ||\n\t\t req.http.User-Agent ~ \"(?i)^samsung\" ||\n\t\t req.http.User-Agent ~ \"(?i)^lg\" ||\n\t\t req.http.User-Agent ~ \"(?i)bada\" ||\n\t\t req.http.User-Agent ~ \"(?i)blazer\" ||\n\t\t req.http.User-Agent ~ \"(?i)cellphone\" ||\n\t\t req.http.User-Agent ~ \"(?i)iemobile\" ||\n\t\t req.http.User-Agent ~ \"(?i)midp-2.0\" ||\n\t\t req.http.User-Agent ~ \"(?i)u990\" ||\n\t\t req.http.User-Agent ~ \"(?i)netfront\" ||\n\t\t req.http.User-Agent ~ \"(?i)opera mini\" ||\n\t\t req.http.User-Agent ~ \"(?i)palm\" ||\n\t\t req.http.User-Agent ~ \"(?i)nintendo wii\" ||\n\t\t req.http.User-Agent ~ \"(?i)playstation portable\" ||\n\t\t req.http.User-Agent ~ \"(?i)portalmmm\" ||\n\t\t req.http.User-Agent ~ \"(?i)proxinet\" ||\n\t\t req.http.User-Agent ~ \"(?i)sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)windows\\ ?ce\" ||\n\t\t req.http.User-Agent ~ \"(?i)winwap\" ||\n\t\t req.http.User-Agent ~ \"(?i)eudoraweb\" ||\n\t\t req.http.User-Agent ~ \"(?i)htc\" ||\n\t\t req.http.User-Agent ~ \"(?i)240x320\" ||\n\t\t req.http.User-Agent ~ \"(?i)avantgo\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-generic\";\n\t\t}\n\t}\n}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"47507d75bd03879303c26167feccd36d4dcfc97d","subject":"Bypass shielding on POST requests","message":"Bypass shielding on POST requests\n","repos":"wlonk\/warehouse,karan\/warehouse,pypa\/warehouse,karan\/warehouse,dstufft\/warehouse,alex\/warehouse,karan\/warehouse,dstufft\/warehouse,wlonk\/warehouse,dstufft\/warehouse,alex\/warehouse,wlonk\/warehouse,pypa\/warehouse,alex\/warehouse,dstufft\/warehouse,karan\/warehouse,karan\/warehouse,pypa\/warehouse,pypa\/warehouse,alex\/warehouse,alex\/warehouse","old_file":"vcl\/main.vcl","new_file":"vcl\/main.vcl","new_contents":"\nsub vcl_recv {\n\n # I'm not 100% sure on what this is exactly for, it was taken from the\n # Fastly documentation, however, what I *believe* it does is just ensure\n # that we don't serve a stale copy of the page from the shield node when\n # an edge node is requesting content.\n if (req.http.Fastly-FF) {\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Some (Older) clients will send a hash fragment as part of the URL even\n # though that is a local only modification. This breaks this badly for the\n # files in S3, and in general it's just not needed.\n set req.url = regsub(req.url, \"#.*$\", \"\");\n\n # Most of the URLs in Warehouse do not support or require any sort of query\n # parameter. If we strip these at the edge then we'll increase our cache\n # efficiency when they won't otherwise change the output of the pages.\n #\n # This will match any URL except those that start with:\n #\n # * \/search\/\n # * \/account\/login\/\n # * \/account\/logout\/\n # * \/account\/register\/\n # * \/pypi\n if (req.url !~ \"^\/(search\/|account\/(login|logout|register)\/|pypi)\") {\n set req.url = req.url.path;\n }\n\n # Sort all of our query parameters, this will ensure that the same query\n # parameters in a different order will end up being represented as the same\n # thing, reducing cache misses due to ordering differences.\n set req.url = boltsort.sort(req.url);\n\n\n#FASTLY recv\n\n\n # We want to Force SSL for the WebUI by redirecting to the HTTPS version of\n # the page, however for API calls we want to return an error code directing\n # people to instead use HTTPS.\n if (!req.http.Fastly-SSL) {\n\n # The \/simple\/ and \/packages\/ API.\n if (req.url ~ \"^\/(simple|packages)\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy JSON API.\n if (req.url ~ \"^\/pypi\/.+\/json$\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy ?:action= API.\n if (req.url ~ \"^\/pypi.*(\\?|&)=:action\") {\n error 803 \"SSL is required\";\n }\n\n # If we're on the \/pypi page and we've received something other than a\n # GET or HEAD request, then we have no way to determine if a particular\n # request is an API call or not because it'll be in the request body\n # and that isn't available to us here. So in those cases, we won't\n # do a redirect.\n if (req.url ~ \"^\/pypi\") {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n error 801 \"Force SSL\";\n }\n }\n else {\n # This isn't a \/pypi URL so we'll just unconditionally redirect to\n # HTTPS.\n error 801 \"Force SSL\";\n }\n }\n\n # Canonicalize our domains by redirecting any domain that doesn't match our\n # primary domain to our primary domain. We do this *after* the HTTPS check\n # on purpose.\n if (std.tolower(req.http.host) != std.tolower(req.http.Primary-Domain)) {\n set req.http.Location = \"https:\/\/\" req.http.Primary-Domain req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n\n # Requests to \/packages\/ get dispatched to Amazon instead of to our typical\n # Origin. This requires a a bit of setup to make it work.\n if (req.url ~ \"^\/packages\/\") {\n # Setup our environment to better match what S3 expects\/needs\n set req.http.Host = req.http.AWS-Bucket-Name \".s3.amazonaws.com\";\n set req.http.Date = now;\n set req.url = regsuball(req.url, \"\\+\", urlencode(\"+\"));\n\n # Compute the Authorization header that S3 requires to be able to\n # access the files stored there.\n set req.http.Authorization = \"AWS \" req.http.AWS-Access-Key-ID \":\" digest.hmac_sha1_base64(req.http.AWS-Secret-Access-Key, \"GET\" LF LF LF req.http.Date LF \"\/\" req.http.AWS-Bucket-Name req.url.path);\n\n # We don't want to send our Warehouse-Token to S3, so we'll go ahead\n # and remove it.\n unset req.http.Warehouse-Token;\n }\n\n # We no longer need any of these variables, which would exist only to\n # shuffle configuration from the Fastly UI into our VCL.\n unset req.http.Primary-Domain;\n unset req.http.AWS-Access-Key-ID;\n unset req.http.AWS-Secret-Access-Key;\n unset req.http.AWS-Bucket-Name;\n\n # We have a number of items that we'll pass back to the origin, but only\n # if we have a Warehouse-Token that will allow them to be accepted.\n if (req.http.Warehouse-Token) {\n # Set a header to tell the backend if we're using https or http.\n if (req.http.Fastly-SSL) {\n set req.http.Warehouse-Proto = \"https\";\n } else {\n set req.http.Warehouse-Proto = \"http\";\n }\n\n # Pass the client IP address back to the backend.\n if (req.http.Fastly-Client-IP) {\n set req.http.Warehouse-IP = req.http.Fastly-Client-IP;\n }\n\n # Pass the real host value back to the backend.\n if (req.http.Host) {\n set req.http.Warehouse-Host = req.http.Host;\n }\n }\n\n # On a POST, we want to skip the shielding and hit backends directly.\n if (req.request == \"POST\") {\n set req.backend = F_Heroku;\n }\n\n # Do not bother to attempt to run the caching mechanisms for methods that\n # are not generally safe to cache.\n if (req.request != \"HEAD\" &&\n req.request != \"GET\" &&\n req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n # We don't ever want to cache our health URL. Outside systems should be\n # able to use it to reach past Fastly and get an end to end health check.\n if (req.url == \"\/_health\/\") {\n return(pass);\n }\n\n # Finally, return the default lookup action.\n return(lookup);\n}\n\n\nsub vcl_fetch {\n\n # For any 5xx status code we want to see if a stale object exists for it,\n # if so we'll go ahead and serve it.\n if (beresp.status >= 500 && beresp.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n\n#FASTLY fetch\n\n\n # Trigger a \"SSL is required\" error if the backend has indicated to do so.\n if (beresp.http.X-Fastly-Error == \"803\") {\n error 803 \"SSL is required\";\n }\n\n # If we've gotten a 502 or a 503 from the backend, we'll go ahead and retry\n # the request.\n if ((beresp.status == 502 || beresp.status == 503) &&\n req.restarts < 1 &&\n (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n # If we've restarted, then we'll record the number of restarts.\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n # If there is a Set-Cookie header, we'll ensure that we do not cache the\n # response.\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n # If the response has the private Cache-Control directive then we won't\n # cache it.\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # If we've gotten an error after the restarts we'll deliver the response\n # with a very short cache time.\n if (http_status_matches(beresp.status, \"500,502,503\")) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n # Apply a default TTL if there isn't a max-age or s-maxage.\n if (beresp.http.Expires ||\n beresp.http.Surrogate-Control ~ \"max-age\" ||\n beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # Keep the ttl here\n }\n else {\n # Apply the default ttl\n set beresp.ttl = 60s;\n }\n\n # Actually deliver the fetched response.\n return(deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n # If the object we have isn't cacheable, then just serve it directly\n # without going through any of the caching mechanisms.\n if (!obj.cacheable) {\n return(pass);\n }\n\n return(deliver);\n}\n\n\nsub vcl_deliver {\n # If this is an error and we have a stale response available, restart so\n # that we can pick it up and serve it.\n if (resp.status >= 500 && resp.status < 600) {\n if (stale.exists) {\n restart;\n }\n }\n\n#FASTLY deliver\n\n # Unset headers that we don't need\/want to send on to the client because\n # they are not generally useful.\n unset resp.http.Server;\n unset resp.http.Via;\n\n # Unset a few headers set by Amazon that we don't really have a need\/desire\n # to send to clients.\n unset resp.http.X-AMZ-Replication-Status;\n unset resp.http.X-AMZ-Meta-Python-Version;\n unset resp.http.X-AMZ-Meta-Version;\n unset resp.http.X-AMZ-Meta-Package-Type;\n unset resp.http.X-AMZ-Meta-Project;\n\n # Set our standard security headers, we do this in VCL rather than in\n # Warehouse itself so that we always get these headers, regardless of the\n # origin server being used.\n set resp.http.Strict-Transport-Security = \"max-age=31536000; includeSubDomains; preload\";\n set resp.http.X-Frame-Options = \"deny\";\n set resp.http.X-XSS-Protection = \"1; mode=block\";\n set resp.http.X-Content-Type-Options = \"nosniff\";\n set resp.http.X-Permitted-Cross-Domain-Policies = \"none\";\n\n return(deliver);\n}\n\n\nsub vcl_error {\n#FASTLY error\n\n # If we have a 5xx error and there is a stale object available, then we\n # will deliver that stale object.\n if (obj.status >= 500 && obj.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n if (obj.status == 803) {\n set obj.status = 403;\n set obj.response = \"SSL is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic {\"SSL is required.\"};\n return (deliver);\n } else if (obj.status == 750) {\n set obj.status = 301;\n set obj.http.Location = req.http.Location;\n set obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n synthetic {\"<html><head><title>301 Moved Permanently<\/title><\/head><body><center><h1>301 Moved Permanently<\/h1><\/center><\/body><\/html>\"};\n return(deliver);\n }\n\n}\n","old_contents":"\nsub vcl_recv {\n\n # I'm not 100% sure on what this is exactly for, it was taken from the\n # Fastly documentation, however, what I *believe* it does is just ensure\n # that we don't serve a stale copy of the page from the shield node when\n # an edge node is requesting content.\n if (req.http.Fastly-FF) {\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Some (Older) clients will send a hash fragment as part of the URL even\n # though that is a local only modification. This breaks this badly for the\n # files in S3, and in general it's just not needed.\n set req.url = regsub(req.url, \"#.*$\", \"\");\n\n # Most of the URLs in Warehouse do not support or require any sort of query\n # parameter. If we strip these at the edge then we'll increase our cache\n # efficiency when they won't otherwise change the output of the pages.\n #\n # This will match any URL except those that start with:\n #\n # * \/search\/\n # * \/account\/login\/\n # * \/account\/logout\/\n # * \/account\/register\/\n # * \/pypi\n if (req.url !~ \"^\/(search\/|account\/(login|logout|register)\/|pypi)\") {\n set req.url = req.url.path;\n }\n\n # Sort all of our query parameters, this will ensure that the same query\n # parameters in a different order will end up being represented as the same\n # thing, reducing cache misses due to ordering differences.\n set req.url = boltsort.sort(req.url);\n\n\n#FASTLY recv\n\n\n # We want to Force SSL for the WebUI by redirecting to the HTTPS version of\n # the page, however for API calls we want to return an error code directing\n # people to instead use HTTPS.\n if (!req.http.Fastly-SSL) {\n\n # The \/simple\/ and \/packages\/ API.\n if (req.url ~ \"^\/(simple|packages)\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy JSON API.\n if (req.url ~ \"^\/pypi\/.+\/json$\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy ?:action= API.\n if (req.url ~ \"^\/pypi.*(\\?|&)=:action\") {\n error 803 \"SSL is required\";\n }\n\n # If we're on the \/pypi page and we've received something other than a\n # GET or HEAD request, then we have no way to determine if a particular\n # request is an API call or not because it'll be in the request body\n # and that isn't available to us here. So in those cases, we won't\n # do a redirect.\n if (req.url ~ \"^\/pypi\") {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n error 801 \"Force SSL\";\n }\n }\n else {\n # This isn't a \/pypi URL so we'll just unconditionally redirect to\n # HTTPS.\n error 801 \"Force SSL\";\n }\n }\n\n # Canonicalize our domains by redirecting any domain that doesn't match our\n # primary domain to our primary domain. We do this *after* the HTTPS check\n # on purpose.\n if (std.tolower(req.http.host) != std.tolower(req.http.Primary-Domain)) {\n set req.http.Location = \"https:\/\/\" req.http.Primary-Domain req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n\n # Requests to \/packages\/ get dispatched to Amazon instead of to our typical\n # Origin. This requires a a bit of setup to make it work.\n if (req.url ~ \"^\/packages\/\") {\n # Setup our environment to better match what S3 expects\/needs\n set req.http.Host = req.http.AWS-Bucket-Name \".s3.amazonaws.com\";\n set req.http.Date = now;\n set req.url = regsuball(req.url, \"\\+\", urlencode(\"+\"));\n\n # Compute the Authorization header that S3 requires to be able to\n # access the files stored there.\n set req.http.Authorization = \"AWS \" req.http.AWS-Access-Key-ID \":\" digest.hmac_sha1_base64(req.http.AWS-Secret-Access-Key, \"GET\" LF LF LF req.http.Date LF \"\/\" req.http.AWS-Bucket-Name req.url.path);\n\n # We don't want to send our Warehouse-Token to S3, so we'll go ahead\n # and remove it.\n unset req.http.Warehouse-Token;\n }\n\n # We no longer need any of these variables, which would exist only to\n # shuffle configuration from the Fastly UI into our VCL.\n unset req.http.Primary-Domain;\n unset req.http.AWS-Access-Key-ID;\n unset req.http.AWS-Secret-Access-Key;\n unset req.http.AWS-Bucket-Name;\n\n # We have a number of items that we'll pass back to the origin, but only\n # if we have a Warehouse-Token that will allow them to be accepted.\n if (req.http.Warehouse-Token) {\n # Set a header to tell the backend if we're using https or http.\n if (req.http.Fastly-SSL) {\n set req.http.Warehouse-Proto = \"https\";\n } else {\n set req.http.Warehouse-Proto = \"http\";\n }\n\n # Pass the client IP address back to the backend.\n if (req.http.Fastly-Client-IP) {\n set req.http.Warehouse-IP = req.http.Fastly-Client-IP;\n }\n\n # Pass the real host value back to the backend.\n if (req.http.Host) {\n set req.http.Warehouse-Host = req.http.Host;\n }\n }\n\n # Do not bother to attempt to run the caching mechanisms for methods that\n # are not generally safe to cache.\n if (req.request != \"HEAD\" &&\n req.request != \"GET\" &&\n req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n # We don't ever want to cache our health URL. Outside systems should be\n # able to use it to reach past Fastly and get an end to end health check.\n if (req.url == \"\/_health\/\") {\n return(pass);\n }\n\n # Finally, return the default lookup action.\n return(lookup);\n}\n\n\nsub vcl_fetch {\n\n # For any 5xx status code we want to see if a stale object exists for it,\n # if so we'll go ahead and serve it.\n if (beresp.status >= 500 && beresp.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n\n#FASTLY fetch\n\n\n # Trigger a \"SSL is required\" error if the backend has indicated to do so.\n if (beresp.http.X-Fastly-Error == \"803\") {\n error 803 \"SSL is required\";\n }\n\n # If we've gotten a 502 or a 503 from the backend, we'll go ahead and retry\n # the request.\n if ((beresp.status == 502 || beresp.status == 503) &&\n req.restarts < 1 &&\n (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n # If we've restarted, then we'll record the number of restarts.\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n # If there is a Set-Cookie header, we'll ensure that we do not cache the\n # response.\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n # If the response has the private Cache-Control directive then we won't\n # cache it.\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # If we've gotten an error after the restarts we'll deliver the response\n # with a very short cache time.\n if (http_status_matches(beresp.status, \"500,502,503\")) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n # Apply a default TTL if there isn't a max-age or s-maxage.\n if (beresp.http.Expires ||\n beresp.http.Surrogate-Control ~ \"max-age\" ||\n beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # Keep the ttl here\n }\n else {\n # Apply the default ttl\n set beresp.ttl = 60s;\n }\n\n # Actually deliver the fetched response.\n return(deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n # If the object we have isn't cacheable, then just serve it directly\n # without going through any of the caching mechanisms.\n if (!obj.cacheable) {\n return(pass);\n }\n\n return(deliver);\n}\n\n\nsub vcl_deliver {\n # If this is an error and we have a stale response available, restart so\n # that we can pick it up and serve it.\n if (resp.status >= 500 && resp.status < 600) {\n if (stale.exists) {\n restart;\n }\n }\n\n#FASTLY deliver\n\n # Unset headers that we don't need\/want to send on to the client because\n # they are not generally useful.\n unset resp.http.Server;\n unset resp.http.Via;\n\n # Unset a few headers set by Amazon that we don't really have a need\/desire\n # to send to clients.\n unset resp.http.X-AMZ-Replication-Status;\n unset resp.http.X-AMZ-Meta-Python-Version;\n unset resp.http.X-AMZ-Meta-Version;\n unset resp.http.X-AMZ-Meta-Package-Type;\n unset resp.http.X-AMZ-Meta-Project;\n\n # Set our standard security headers, we do this in VCL rather than in\n # Warehouse itself so that we always get these headers, regardless of the\n # origin server being used.\n set resp.http.Strict-Transport-Security = \"max-age=31536000; includeSubDomains; preload\";\n set resp.http.X-Frame-Options = \"deny\";\n set resp.http.X-XSS-Protection = \"1; mode=block\";\n set resp.http.X-Content-Type-Options = \"nosniff\";\n set resp.http.X-Permitted-Cross-Domain-Policies = \"none\";\n\n return(deliver);\n}\n\n\nsub vcl_error {\n#FASTLY error\n\n # If we have a 5xx error and there is a stale object available, then we\n # will deliver that stale object.\n if (obj.status >= 500 && obj.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n if (obj.status == 803) {\n set obj.status = 403;\n set obj.response = \"SSL is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic {\"SSL is required.\"};\n return (deliver);\n } else if (obj.status == 750) {\n set obj.status = 301;\n set obj.http.Location = req.http.Location;\n set obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n synthetic {\"<html><head><title>301 Moved Permanently<\/title><\/head><body><center><h1>301 Moved Permanently<\/h1><\/center><\/body><\/html>\"};\n return(deliver);\n }\n\n}\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"a68410c283532c80670402388e5835365e0f07d4","subject":"When backend doesn't supply any cache control headers we want to make sure we don't cache since we can't be sure if it's cacheable. We also need to set the Surrogate-Control header since otherwise we'll end up with default TTL","message":"When backend doesn't supply any cache control headers we want to make sure we don't cache since we can't be sure if it's cacheable. We also need to set the Surrogate-Control header since otherwise we'll end up with default TTL\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets\/fetch.vcl","new_file":"etc\/vcl_snippets\/fetch.vcl","new_contents":" \/* handle 5XX (or any other unwanted status code) *\/\n if (beresp.status >= 500 && beresp.status < 600) {\n\n \/* deliver stale if the object is available *\/\n if (stale.exists) {\n return(deliver_stale);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n \/* else go to vcl_error to deliver a synthetic *\/\n error beresp.status beresp.response;\n }\n\n # Remove Set-Cookies from responses for static content to match the cookie removal in recv.\n if (req.http.x-long-cache || req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's since those can be temporary during the site build\/index\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n set beresp.http.Cache-Control = \"max-age=0\";\n } else if (req.http.x-long-cache) {\n # Force caching for signed cached assets.\n set beresp.ttl = 31536000s;\n # Add immutable as it avoids IMS and INM revalidations\n set beresp.http.Cache-Control = \"max-age=31536000, immutable\";\n }\n }\n\n # Fix Vary Header in some cases. In 99.9% of cases Varying on User-Agent is counterproductive\n # https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleFixupVary\n if (beresp.http.Vary ~ \"User-Agent\") {\n set beresp.http.Vary = regsub(beresp.http.Vary, \",? *User-Agent *\", \"\");\n set beresp.http.Vary = regsub(beresp.http.Vary, \"^, *\", \"\");\n if (beresp.http.Vary == \"\") {\n unset beresp.http.Vary;\n }\n }\n\n # All the Magento responses should emit X-Esi headers\n if (beresp.http.x-esi) {\n # enable ESI feature for Magento response by default\n esi;\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content except\n if ( http_status_matches(beresp.status, \"200,404\") && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|text\\\/html|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url.ext ~ \"(?i)(css|js|html|eot|ico|otf|ttf|json)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # Add Varying on X-Magento-Vary\n if (beresp.http.Content-Type ~ \"text\/(html|xml)\") {\n if (!beresp.http.Vary ~ \"X-Magento-Vary,Https\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \",X-Magento-Vary,Https\";\n } else {\n set beresp.http.Vary = \"X-Magento-Vary,Https\";\n }\n }\n }\n\n if (beresp.http.Cache-Control ~ \"private|no-cache|no-store\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # Never cache 302s\n if (beresp.status == 302) {\n return (pass);\n }\n\n # Just in case the Request Setting for x-pass is missing\n if (req.http.x-pass) {\n return (pass);\n }\n\n # Varnish sets default TTL if none of these are present\n if (!beresp.http.Expires && !beresp.http.Surrogate-Control ~ \"max-age\" && !beresp.http.Cache-Control ~ \"(s-maxage|max-age)\") {\n set beresp.ttl = 0s;\n\t# We need to also set Surrogate-Control to avoid falling through to default TTL\n set beresp.http.Surrogate-Control = \"max-age=0\";\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\") && !req.http.x-pass ) {\n unset beresp.http.set-cookie;\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type if they are image\/script or CSS\n if (beresp.http.Content-Type ~ \"(image|script|css)\") {\n set beresp.http.Surrogate-Key = re.group.1;\n }\n }\n","old_contents":" \/* handle 5XX (or any other unwanted status code) *\/\n if (beresp.status >= 500 && beresp.status < 600) {\n\n \/* deliver stale if the object is available *\/\n if (stale.exists) {\n return(deliver_stale);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n \/* else go to vcl_error to deliver a synthetic *\/\n error beresp.status beresp.response;\n }\n\n # Remove Set-Cookies from responses for static content to match the cookie removal in recv.\n if (req.http.x-long-cache || req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's since those can be temporary during the site build\/index\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n set beresp.http.Cache-Control = \"max-age=0\";\n } else if (req.http.x-long-cache) {\n # Force caching for signed cached assets.\n set beresp.ttl = 31536000s;\n # Add immutable as it avoids IMS and INM revalidations\n set beresp.http.Cache-Control = \"max-age=31536000, immutable\";\n }\n }\n\n # Fix Vary Header in some cases. In 99.9% of cases Varying on User-Agent is counterproductive\n # https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleFixupVary\n if (beresp.http.Vary ~ \"User-Agent\") {\n set beresp.http.Vary = regsub(beresp.http.Vary, \",? *User-Agent *\", \"\");\n set beresp.http.Vary = regsub(beresp.http.Vary, \"^, *\", \"\");\n if (beresp.http.Vary == \"\") {\n unset beresp.http.Vary;\n }\n }\n\n # All the Magento responses should emit X-Esi headers\n if (beresp.http.x-esi) {\n # enable ESI feature for Magento response by default\n esi;\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content except\n if ( http_status_matches(beresp.status, \"200,404\") && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|text\\\/html|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url.ext ~ \"(?i)(css|js|html|eot|ico|otf|ttf|json)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # Add Varying on X-Magento-Vary\n if (beresp.http.Content-Type ~ \"text\/(html|xml)\") {\n if (!beresp.http.Vary ~ \"X-Magento-Vary,Https\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \",X-Magento-Vary,Https\";\n } else {\n set beresp.http.Vary = \"X-Magento-Vary,Https\";\n }\n }\n }\n\n if (beresp.http.Cache-Control ~ \"private|no-cache|no-store\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # Never cache 302s\n if (beresp.status == 302) {\n return (pass);\n }\n\n # Just in case the Request Setting for x-pass is missing\n if (req.http.x-pass) {\n return (pass);\n }\n\n # Varnish sets default TTL if none of these are present\n if (!beresp.http.Expires && !beresp.http.Surrogate-Control ~ \"max-age\" && !beresp.http.Cache-Control ~ \"(s-maxage|max-age)\") {\n set beresp.ttl = 0s;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\") && !req.http.x-pass ) {\n unset beresp.http.set-cookie;\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type if they are image\/script or CSS\n if (beresp.http.Content-Type ~ \"(image|script|css)\") {\n set beresp.http.Surrogate-Key = re.group.1;\n }\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"519b33693e3238565576f1dec4155d6b274c5533","subject":"re #230 - Always pass requests to \/ZendServer","message":"re #230 - Always pass requests to \/ZendServer\n","repos":"gokuale\/joomla-vagrant,gokuale\/joomla-vagrant,joomlatools\/joomla-vagrant,joomlatools\/joomla-vagrant,joomlatools\/joomla-vagrant,joomlatools\/joomlatools-vagrant,joomlatools\/joomlatools-vagrant,joomlatools\/joomla-vagrant,joomlatools\/joomla-vagrant,gokuale\/joomla-vagrant,joomlatools\/joomla-vagrant,joomlatools\/joomlatools-vagrant,gokuale\/joomla-vagrant,gokuale\/joomla-vagrant,joomlatools\/joomlatools-vagrant,joomlatools\/joomlatools-vagrant,gokuale\/joomla-vagrant","old_file":"puppet\/modules\/varnish\/files\/joomla.box.vcl","new_file":"puppet\/modules\/varnish\/files\/joomla.box.vcl","new_contents":"vcl 4.0;\n\n# This Varnish configuration is a very basic template to get started with caching Joomla sites.\n# In no way is this configuration complete: every site is unique and needs customisation!\n# For demonstration purposes this VCL will cache all front-end pages (including pages with cookies).\n\nimport std;\n\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n .probe = {\n .url = \"\/varnish-enabled\";\n .interval = 1s;\n .timeout = 1s;\n }\n}\n\nbackend alternative {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\n\nsub vcl_recv {\n # Forward client's IP to backend\n unset req.http.X-Forwarded-For;\n set req.http.X-Forwarded-For = client.ip;\n\n set req.http.X-Forwarded-By = server.ip;\n set req.http.X-Forwarded-Port = 80;\n\n # Check if we've still enabled Varnish, if not, passthrough every request\n if (! std.healthy(req.backend_hint))\n {\n set req.backend_hint = alternative;\n return (pass);\n }\n\n # Do not cache phpmyadmin\n if (req.http.host == \"phpmyadmin.joomla.box\") {\n return (pass);\n }\n\n # Do not cache system tools on joomla.box:\n if (req.http.host == \"joomla.box\")\n {\n if (req.url ~ \"^\/apc\" || req.url ~ \"^\/phpinfo\" || req.url ~ \"^\/pimpmylog\" || req.url ~ \"^\/dashboard\") {\n return (pass);\n }\n }\n\n # Do not cache ZendServer endpoint\n if (req.url ~ \"^\/ZendServer\") {\n return (pass);\n }\n\n # Do not cache POST requests\n if (req.method == \"POST\") {\n return (pass);\n }\n\n # Proxy (pass) any request that goes to the backend admin, the banner component links, ..\n if(req.url ~ \"\/administrator\" || req.url ~ \"\/component\/banners\" || req.url ~ \"\/component\/users\" || req.url ~ \"\/installation\") {\n return (pass);\n }\n\n # Do not cache if user is logged in\n if (req.http.Authorization || req.http.Authenticate) {\n return (pass);\n }\n\n # Don't cache ajax requests\n if(req.http.X-Requested-With == \"XMLHttpRequest\" || req.url ~ \"nocache\") {\n return (pass);\n }\n\n # Properly handle different encoding types\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf)$\") {\n # No point in compressing these\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n # unknown algorithm (aka crappy browser)\n unset req.http.Accept-Encoding;\n }\n }\n\n return (hash);\n}\n\nsub vcl_backend_response {\n # Unset the \"etag\" header (suggested)\n unset beresp.http.etag;\n\n # This is Joomla! specific: fix stupid \"no-cache\" header sent by Joomla! even\n # when caching is on - make sure to replace 300 with the number of seconds that\n # you want the browser to cache content\n if(beresp.http.Cache-Control ~ \"no-cache\" || beresp.http.Cache-Control == \"\"){\n set beresp.http.Cache-Control = \"max-age=300, public, must-revalidate\";\n }\n\n # Check for the custom \"x-Logged-In\" header to identify if the visitor is a guest,\n # then unset any cookie (including session cookies) provided it's not a POST request.\n if(bereq.method != \"POST\" && beresp.http.X-Logged-In == \"false\") {\n unset beresp.http.Set-Cookie;\n }\n\n # This is how long Varnish will cache content\n set beresp.ttl = 1w;\n\n return (deliver);\n}\n\nsub vcl_hash\n{\n hash_data(req.url);\n\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n\n # Hash cookies for requests that have them\n if (req.http.Cookie) {\n hash_data(req.http.Cookie);\n }\n}\n\nsub vcl_deliver {\n if (resp.http.x-varnish ~ \" \") {\n set resp.http.X-Varnish-Status = \"HIT\";\n } else {\n set resp.http.X-Varnish-Status = \"MISS\";\n }\n\n # Please note that obj.hits behaviour changed in 4.0, now it counts per objecthead, not per object\n # and obj.hits may not be reset in some cases where bans are in use. See bug 1492 for details.\n # So take hits with a grain of salt\n set resp.http.X-Varnish-Hits = obj.hits;\n}","old_contents":"vcl 4.0;\n\n# This Varnish configuration is a very basic template to get started with caching Joomla sites.\n# In no way is this configuration complete: every site is unique and needs customisation!\n# For demonstration purposes this VCL will cache all front-end pages (including pages with cookies).\n\nimport std;\n\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n .probe = {\n .url = \"\/varnish-enabled\";\n .interval = 1s;\n .timeout = 1s;\n }\n}\n\nbackend alternative {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\n\nsub vcl_recv {\n # Forward client's IP to backend\n unset req.http.X-Forwarded-For;\n set req.http.X-Forwarded-For = client.ip;\n\n set req.http.X-Forwarded-By = server.ip;\n set req.http.X-Forwarded-Port = 80;\n\n # Check if we've still enabled Varnish, if not, passthrough every request\n if (! std.healthy(req.backend_hint))\n {\n set req.backend_hint = alternative;\n return (pass);\n }\n\n # Do not cache phpmyadmin\n if (req.http.host == \"phpmyadmin.joomla.box\") {\n return (pass);\n }\n\n # Do not cache system tools on joomla.box:\n if (req.http.host == \"joomla.box\")\n {\n if (req.url ~ \"^\/apc\" || req.url ~ \"^\/phpinfo\" || req.url ~ \"^\/pimpmylog\" || req.url ~ \"^\/dashboard\") {\n return (pass);\n }\n }\n\n # Do not cache POST requests\n if (req.method == \"POST\") {\n return (pass);\n }\n\n # Proxy (pass) any request that goes to the backend admin, the banner component links, ..\n if(req.url ~ \"\/administrator\" || req.url ~ \"\/component\/banners\" || req.url ~ \"\/component\/users\" || req.url ~ \"\/installation\") {\n return (pass);\n }\n\n # Do not cache if user is logged in\n if (req.http.Authorization || req.http.Authenticate) {\n return (pass);\n }\n\n # Don't cache ajax requests\n if(req.http.X-Requested-With == \"XMLHttpRequest\" || req.url ~ \"nocache\") {\n return (pass);\n }\n\n # Properly handle different encoding types\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf)$\") {\n # No point in compressing these\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n # unknown algorithm (aka crappy browser)\n unset req.http.Accept-Encoding;\n }\n }\n\n return (hash);\n}\n\nsub vcl_backend_response {\n # Unset the \"etag\" header (suggested)\n unset beresp.http.etag;\n\n # This is Joomla! specific: fix stupid \"no-cache\" header sent by Joomla! even\n # when caching is on - make sure to replace 300 with the number of seconds that\n # you want the browser to cache content\n if(beresp.http.Cache-Control ~ \"no-cache\" || beresp.http.Cache-Control == \"\"){\n set beresp.http.Cache-Control = \"max-age=300, public, must-revalidate\";\n }\n\n # Check for the custom \"x-Logged-In\" header to identify if the visitor is a guest,\n # then unset any cookie (including session cookies) provided it's not a POST request.\n if(bereq.method != \"POST\" && beresp.http.X-Logged-In == \"false\") {\n unset beresp.http.Set-Cookie;\n }\n\n # This is how long Varnish will cache content\n set beresp.ttl = 1w;\n\n return (deliver);\n}\n\nsub vcl_hash\n{\n hash_data(req.url);\n\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n\n # Hash cookies for requests that have them\n if (req.http.Cookie) {\n hash_data(req.http.Cookie);\n }\n}\n\nsub vcl_deliver {\n if (resp.http.x-varnish ~ \" \") {\n set resp.http.X-Varnish-Status = \"HIT\";\n } else {\n set resp.http.X-Varnish-Status = \"MISS\";\n }\n\n # Please note that obj.hits behaviour changed in 4.0, now it counts per objecthead, not per object\n # and obj.hits may not be reset in some cases where bans are in use. See bug 1492 for details.\n # So take hits with a grain of salt\n set resp.http.X-Varnish-Hits = obj.hits;\n}","returncode":0,"stderr":"","license":"mpl-2.0","lang":"VCL"} {"commit":"e809086bf18f6fef946c1c3644364b7239a76ee4","subject":"harmonize comments for ban between varnish 3 and 4","message":"harmonize comments for ban between varnish 3 and 4","repos":"stof\/FOSHttpCache,stof\/FOSHttpCache,stof\/FOSHttpCache,dantleech\/FOSHttpCache,dantleech\/FOSHttpCache,dantleech\/FOSHttpCache","old_file":"tests\/Functional\/Fixtures\/varnish-4\/ban.vcl","new_file":"tests\/Functional\/Fixtures\/varnish-4\/ban.vcl","new_contents":"sub vcl_recv {\n\n if (req.method == \"BAN\") {\n if (!client.ip ~ invalidators) {\n return (synth(405, \"Not allowed\"));\n }\n\n if (req.http.x-cache-tags) {\n ban(\"obj.http.x-host ~ \" + req.http.x-host\n + \" && obj.http.x-url ~ \" + req.http.x-url\n + \" && obj.http.content-type ~ \" + req.http.x-content-type\n + \" && obj.http.x-cache-tags ~ \" + req.http.x-cache-tags\n );\n } else {\n ban(\"obj.http.x-host ~ \" + req.http.x-host\n + \" && obj.http.x-url ~ \" + req.http.x-url\n + \" && obj.http.content-type ~ \" + req.http.x-content-type\n );\n }\n\n return (synth(200, \"Banned\"));\n }\n}\n\nsub vcl_backend_response {\n\n # Set ban-lurker friendly custom headers\n set beresp.http.x-url = bereq.url;\n set beresp.http.x-host = bereq.http.host;\n}\n\nsub vcl_deliver {\n # Keep ban-lurker headers only if debugging is enabled\n if (!resp.http.x-cache-debug) {\n # Remove ban-lurker friendly custom headers when delivering to client\n unset resp.http.x-url;\n unset resp.http.x-host;\n }\n}\n","old_contents":"sub vcl_recv {\n\n if (req.method == \"BAN\") {\n if (!client.ip ~ invalidators) {\n return (synth(405, \"Not allowed\"));\n }\n\n if (req.http.x-cache-tags) {\n ban(\"obj.http.x-host ~ \" + req.http.x-host\n + \" && obj.http.x-url ~ \" + req.http.x-url\n + \" && obj.http.content-type ~ \" + req.http.x-content-type\n + \" && obj.http.x-cache-tags ~ \" + req.http.x-cache-tags\n );\n } else {\n ban(\"obj.http.x-host ~ \" + req.http.x-host\n + \" && obj.http.x-url ~ \" + req.http.x-url\n + \" && obj.http.content-type ~ \" + req.http.x-content-type\n );\n }\n\n return (synth(200, \"Banned\"));\n }\n}\n\nsub vcl_backend_response {\n\n # Set ban-lurker friendly custom headers\n set beresp.http.x-url = bereq.url;\n set beresp.http.x-host = bereq.http.host;\n}\n\nsub vcl_deliver {\n\n # Add extra headers if debugging is enabled\n if (!resp.http.x-cache-debug) {\n # Remove ban-lurker friendly custom headers when delivering to client\n unset resp.http.x-url;\n unset resp.http.x-host;\n }\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"b7c7eb23c8e0f240461745988bc074c781f1c2fd","subject":"Renamed sub names","message":"Renamed sub names\n","repos":"karto\/varnish-forwarded","old_file":"forwarded.vcl","new_file":"forwarded.vcl","new_contents":"\/\/ \n\/\/ Forwarded rules for Varnish 4\n\/\/ \n\/\/ Author Karto Martin <source@karto.net>\n\/\/ Copyright (c) 2015 Karto Martin. All Right Reserved.\n\/\/ License The MIT License\n\/\/ \n\n#######################################################################\n# Client side\n\nsub forwarded_recv {\n \n ####\n # This is only necessary on the first roundtrip\n #\n if (0 == req.restarts) {\n \n ####\n # Forwarding and nginx requests\n #\n # Forwarding for akamai request\n if (req.http.Via ~ \"akamai.net\" && req.http.Akamai-Origin-Hop) {\n std.log(\"forwarded_recv: Accepting xff from akamai\");\n }\n # Forwarding for direct request. Test client.ip agenst forwarders acl.\n elsif (regsub(client.ip, \"\", \"\") != \"\"+server.ip && # NOT a local ssl request (STRING + IP not possible. server.ip != client.ip)\n req.http.X-Forwarded-For ~ \",\" && \n client.ip !~ forwarders_acl) {\n std.log(\"forwarded_recv: Restricting xff to client because \"+client.ip+\" is not in forwarders_acl\");\n set req.http.X-Forwarded-For = client.ip;\n }\n # Forwarding for SSL termination request. Test previous xff agenst forwarders acl.\n elsif (regsub(client.ip, \"\", \"\") == \"\"+server.ip && # Nginx local ssl request (STRING + IP not possible. server.ip == client.ip)\n req.http.X-Forwarded-For ~ \",.*,\" &&\n std.ip(regsub(req.http.X-Forwarded-For, \"^.*,\\s*([^,]+?)\\s*,[^,]*$\", \"\\1\"), \"0.0.0.0\") !~ forwarders_acl) {\n std.log(\"forwarded_recv: Restricting xff to client from ssl because \"+regsub(req.http.X-Forwarded-For, \"^.*,\\s*([^,]+?)\\s*,[^,]*$\", \"\\1\")+\" is not in forwarders_acl\");\n set req.http.X-Forwarded-For = regsub(req.http.X-Forwarded-For, \"^.*,\\s*([^,]+?\\s*,[^,]*)$\", \"\\1\");\n }\n # Use buildin xff \n else {\n std.log(\"forwarded_recv: Accepting xff from request\");\n }\n # Set X-Client-IP to the first xff address\n set req.http.X-Client-IP = regsub(req.http.X-Forwarded-For, \"^([^,]+?)(:?\\s*,.+)?$\", \"\\1\");\n if ( ! req.http.X-Forwarded-Proto) {\n set req.http.X-Forwarded-Proto = \"http\";\n }\n\n }\n\n}\n#sub forwarded_pipe {\n#}\n#sub forwarded_pass {\n#}\n#sub forwarded_hash {\n#}\n#sub forwarded_purge {\n#}\n#sub forwarded_hit {\n#}\n#sub forwarded_miss {\n#}\n#sub forwarded_deliver {\n#}\n#sub forwarded_synth {\n#}\n\n\n#######################################################################\n# Backend Fetch\n\n#sub forwarded_backend_fetch {\n#}\n#sub forwarded_backend_response {\n#}\n#sub forwarded_backend_error {\n#}\n\n\n#######################################################################\n# Housekeeping\n\n#sub forwarded_init {\n#}\n#sub forwarded_fini {\n#}\n","old_contents":"\/\/ \n\/\/ Forwarded rules for Varnish 4\n\/\/ \n\/\/ Author Karto Martin <source@karto.net>\n\/\/ Copyright (c) 2015 Karto Martin. All Right Reserved.\n\/\/ License The MIT License\n\/\/ \n\n#######################################################################\n# Client side\n\nsub forwarded_recv {\n \n ####\n # This is only necessary on the first roundtrip\n #\n if (0 == req.restarts) {\n \n ####\n # Forwarding and nginx requests\n #\n # Forwarding for akamai request\n if (req.http.Via ~ \"akamai.net\" && req.http.Akamai-Origin-Hop) {\n std.log(\"vcl_recv: Accepting xff from akamai\");\n }\n # Forwarding for direct request. Test client.ip agenst forwarders acl.\n elsif (regsub(client.ip, \"\", \"\") != \"\"+server.ip && # NOT a local ssl request (STRING + IP not possible. server.ip != client.ip)\n req.http.X-Forwarded-For ~ \",\" && \n client.ip !~ forwarders_acl) {\n std.log(\"vcl_recv: Restricting xff to client because \"+client.ip+\" is not in forwarders_acl\");\n set req.http.X-Forwarded-For = client.ip;\n }\n # Forwarding for SSL termination request. Test previous xff agenst forwarders acl.\n elsif (regsub(client.ip, \"\", \"\") == \"\"+server.ip && # Nginx local ssl request (STRING + IP not possible. server.ip == client.ip)\n req.http.X-Forwarded-For ~ \",.*,\" &&\n std.ip(regsub(req.http.X-Forwarded-For, \"^.*,\\s*([^,]+?)\\s*,[^,]*$\", \"\\1\"), \"0.0.0.0\") !~ forwarders_acl) {\n std.log(\"vcl_recv: Restricting xff to client from ssl because \"+regsub(req.http.X-Forwarded-For, \"^.*,\\s*([^,]+?)\\s*,[^,]*$\", \"\\1\")+\" is not in forwarders_acl\");\n set req.http.X-Forwarded-For = regsub(req.http.X-Forwarded-For, \"^.*,\\s*([^,]+?\\s*,[^,]*)$\", \"\\1\");\n }\n # Use buildin xff \n else {\n std.log(\"vcl_recv: Accepting xff from request\");\n }\n # Set X-Client-IP to the first xff address\n set req.http.X-Client-IP = regsub(req.http.X-Forwarded-For, \"^([^,]+?)(:?\\s*,.+)?$\", \"\\1\");\n if ( ! req.http.X-Forwarded-Proto) {\n set req.http.X-Forwarded-Proto = \"http\";\n }\n\n }\n\n}\n#sub vcl_pipe {\n#}\n#sub vcl_pass {\n#}\n#sub vcl_hash {\n#}\n#sub vcl_purge {\n#}\n#sub vcl_hit {\n#}\n#sub vcl_miss {\n#}\n#sub vcl_deliver {\n#}\n#sub vcl_synth {\n#}\n\n\n#######################################################################\n# Backend Fetch\n\n#sub vcl_backend_fetch {\n#}\n#sub vcl_backend_response {\n#}\n#sub vcl_backend_error {\n#}\n\n\n#######################################################################\n# Housekeeping\n\n#sub vcl_init {\n#}\n#sub vcl_fini {\n#}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"a800287d8fc93a878793ddd2021642ef22e1176b","subject":"test from my desktop at work","message":"test from my desktop at work\n","repos":"aschneiderman\/atom-voice-vocola","old_file":"atom.vcl","new_file":"atom.vcl","new_contents":"# Voice commands for atom\n\nTest Command = \"This Is a Test Command\"; # see if working on laptop and on my desktop at work\n\ninclude folders.vch;\ninclude letters.vch;\n\n# Commands for developing D3: D3 visualizations, D3 Sandwiches\nSave and Reload = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Ctrl+r};\t\nSave and Really Reload = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Ctrl+Shift+r};\nSave and Run = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Up}{Enter};\n\n# File commands\nFind (File | Document) = {Ctrl+t};\nSave As = {Ctrl+Shift+s};\nNext Window = {Ctrl+Tab};\nLast Window = {Ctrl+Shift+Tab};\nLatest File = {Ctrl+Shift+t};\n(Tree View | List Files) = {Alt+o};\t# NOTE: to make this work, I had to create a new keyboard shortcut in Atom (my personal keymap.cson)\n\n\n# --- Text navigation commands ------------------------------------\n<delimiters> := (Quote = '\"' | 'Double Quote' = '\"' | 'Single Quote' = \"'\" | Comma = ',' | 'Equal Sign' = '=' | Equals = '=' \n\t| Period = '.' | Colon = ':' | 'Semi-Colon' = ';' | Hyphen = '-' | Underscore = '_' | Slash = '\/'\n\t| Paren = \"(\" | \"Close Paren\" = \")\" | Parentheses = \"(\" | \"Open Parenthesis\" = \"(\" | \"Close Parentheses\" = \")\"\n\t| Bracket = '[' | \"Close Bracket\" = ']' | Brace = '{' | 'Close Brace' = '}'\t);\n\nLine 1..200 = {Ctrl+g} $1 {Enter};\n(Left = 'b' | Right = 'f') Word = {Alt+$1};\nTop = {Ctrl+Home};\nBottom = {Ctrl+End};\n(Find = 'Right' | 'Insert After' = 'Right' | 'Insert Before' = 'Left') (Next = 'Enter' | Last = 'Shift+F3') <delimiters> \n\t\t= {Ctrl+f} $3 {$2} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') <delimiters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') 1..20 <delimiters> = {Ctrl+f} $3 {Enter} {Esc} Wait(100) {F3_$2} {Shift+F3} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') Enda <delimiters> = {End} {Ctrl+f} $2 {Enter} {Esc} {Shift+F3} Wait(100) {$1};\n\nFine Alpha <letters> = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Left};\nInsert (Before = 'Left' | After = 'Right') Alpha <letters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nFine Number 0..9 = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Right};\n(Find | Insert) Again = {F3} {Right};\n(Find | Insert) Again 1..20 Times = {F3_$1} {Right};\n\n(Set | Add | Clear | Hide | Delete) Bookmark = {Ctrl+Alt+F2};\n(Next = 'F2' | Last = 'Shift+F2') Bookmark = {$1};\n\n\n# --- Editing commands ----------------------------------------\nSelect Line = {Ctrl+l};\nSelect (Next = 'Down' | Forward = 'Down' | Last = 'Up' | Back = 'Up' | Previous = 'Up') 1..20 Lines = {Home} {Shift+$1_$2};\nMove Line (Up | Down) 1..20 = {Ctrl+$1_$2};\nAdd 1..20 (Lines = 'Down' | Line = 'Down' | Pages = 'PgDn' | Page = 'PgDn') = {Shift+$2_$1};\nStart Adding 1..20 Lines = {Home}{Shift+Down_$1};\n\n\nSelect between (Delimiters | Brackets | Tags) ={Ctrl+m} {Ctrl+Alt+m};\nDelete between Tags = {Ctrl+m} {Ctrl+Alt+m} {Del};\nDelete Tags = {Ctrl+Alt+F4};\nReplace With (Header | Heading) 1..7 = {Ctrl+Alt+F4} '<h' $2 '>' {End} '<\/h' $2 '>' {Home};\nReplace With (para = 'p') = {Ctrl+Alt+F4} '<' $1 '>' {End} '<\/' $1 '>';\n\n\nDelete Word = {Ctrl+Del};\nDelete 1..20 Words = {Ctrl+Del_$1};\nDelete (Back | Last) Word = {Ctrl+Backspace};\nDelete (Back | Last) 1..20 Words = {Ctrl+Backspace_$2};\nDelete Enda Word = {End} {Ctrl+Backspace};\nKill Word = {Ctrl+Backspace}{Ctrl+Del};\n\n(Delete Line | Dede) = {Ctrl+Shift+k};\nDelete 1..20 Lines = {Ctrl+Shift+k_$1};\n(Cut = 'x' | Paste = 'v' | Copy = 'c') That = {Ctrl+$1};\n\nComment (That | Line) = {Ctrl+\/};\nComment 1..20 Lines = {Home} {Shift+Down_$1} {Ctrl+\/};\n\nReplace = {Ctrl+f};\nReplace All = {Ctrl+Enter};\n\n(Join = 'j' | Indent = ']' | Dedent = '[') That = {Ctrl+$1};\n\n\n# --- Commands to create code\/tags -------------------------------------------\n# NOTE: basic HTML commands are stored in my global Vocala commands\n\nStart (\t# HTML commands\n\t'HTML page' = 'html' | pre = \"pre\" | 'Comment' = 'comment-html'\n\t| div = 'div' \n\t| 'class example' = 'class-example'\t\t# Used in A Taste of D3\n\n\t# D3 Recipe commands\n\t| 'Recipe Page' = 'recipe-page' | 'Recipe Row' = 'recipe-row' \n\t| 'Recipe Toy' = 'recipe-toy' | Toy = 'recipe-toy'\n\t| 'Bold ID'\n\n\t# D3 and JavaScript commands\n\t| Console = 'console' | Log = 'console'\n\t| Var = 'variable' | Variable = 'variable'\n\t# Coffeescript commands\n\t| Snippet = 'my-snippet' \n\t| 'Fix Line' = 'fix-current-line' | 'Fix Current Line' = 'fix-current-line'\n) = $1 {Tab};\n\nStop (\t#HTML commands\n\t'div comment' = 'comment-div-end' | Comment = 'comment-html-end' | 'div' = 'div-end'\n) = $1 {Tab};\n\n# HTML commands\nDot HTML = '.html';\nStart (Header | Heading) 1..7 = h $2 {Tab};\nAdd (Header | Heading) 1..7 = '<h' $2 '>' {End} '<\/h' $2 '>';\nAdd (para = 'p') = '<' $1 '>' {End} '<\/' $1 '>';\n\n# D3 Recipe commands\nPre-Format Code = {Ctrl+Alt+F5};\nReload Atom = {Ctrl+s} Wait(100) {Shift+Ctrl+Alt+F5};\nCommand Palette = {Ctrl+Shift+p};\nKeyboard Shortcuts = {Ctrl+.};\nRun Specs = {Ctrl+Alt+p};\nShow Console = {Ctrl+Alt+i};\n\n\n\n# D3 commands\nPaste Function = 'function ' {Ctrl+v} ' {' {Enter} {Enter} '};' {Up};\n\n# Coffeescript commands\n\n# Python commands\n\n\n# --- D3 commands -------------------------------------------\n\n\n# --- Python commands -------------------------------------------\n\n\n# --- Coffeescript commands -------------------------------------------","old_contents":"# Voice commands for atom\n\nTest Command = \"This Is a Test Command\"; # see if working on laptop\n\ninclude folders.vch;\ninclude letters.vch;\n\n# Commands for developing D3: D3 visualizations, D3 Sandwiches\nSave and Reload = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Ctrl+r};\t\nSave and Really Reload = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Ctrl+Shift+r};\nSave and Run = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Up}{Enter};\n\n# File commands\nFind (File | Document) = {Ctrl+t};\nSave As = {Ctrl+Shift+s};\nNext Window = {Ctrl+Tab};\nLast Window = {Ctrl+Shift+Tab};\nLatest File = {Ctrl+Shift+t};\n(Tree View | List Files) = {Alt+o};\t# NOTE: to make this work, I had to create a new keyboard shortcut in Atom (my personal keymap.cson)\n\n\n# --- Text navigation commands ------------------------------------\n<delimiters> := (Quote = '\"' | 'Double Quote' = '\"' | 'Single Quote' = \"'\" | Comma = ',' | 'Equal Sign' = '=' | Equals = '=' \n\t| Period = '.' | Colon = ':' | 'Semi-Colon' = ';' | Hyphen = '-' | Underscore = '_' | Slash = '\/'\n\t| Paren = \"(\" | \"Close Paren\" = \")\" | Parentheses = \"(\" | \"Open Parenthesis\" = \"(\" | \"Close Parentheses\" = \")\"\n\t| Bracket = '[' | \"Close Bracket\" = ']' | Brace = '{' | 'Close Brace' = '}'\t);\n\nLine 1..200 = {Ctrl+g} $1 {Enter};\n(Left = 'b' | Right = 'f') Word = {Alt+$1};\nTop = {Ctrl+Home};\nBottom = {Ctrl+End};\n(Find = 'Right' | 'Insert After' = 'Right' | 'Insert Before' = 'Left') (Next = 'Enter' | Last = 'Shift+F3') <delimiters> \n\t\t= {Ctrl+f} $3 {$2} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') <delimiters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') 1..20 <delimiters> = {Ctrl+f} $3 {Enter} {Esc} Wait(100) {F3_$2} {Shift+F3} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') Enda <delimiters> = {End} {Ctrl+f} $2 {Enter} {Esc} {Shift+F3} Wait(100) {$1};\n\nFine Alpha <letters> = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Left};\nInsert (Before = 'Left' | After = 'Right') Alpha <letters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nFine Number 0..9 = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Right};\n(Find | Insert) Again = {F3} {Right};\n(Find | Insert) Again 1..20 Times = {F3_$1} {Right};\n\n(Set | Add | Clear | Hide | Delete) Bookmark = {Ctrl+Alt+F2};\n(Next = 'F2' | Last = 'Shift+F2') Bookmark = {$1};\n\n\n# --- Editing commands ----------------------------------------\nSelect Line = {Ctrl+l};\nSelect (Next = 'Down' | Forward = 'Down' | Last = 'Up' | Back = 'Up' | Previous = 'Up') 1..20 Lines = {Home} {Shift+$1_$2};\nMove Line (Up | Down) 1..20 = {Ctrl+$1_$2};\nAdd 1..20 (Lines = 'Down' | Line = 'Down' | Pages = 'PgDn' | Page = 'PgDn') = {Shift+$2_$1};\nStart Adding 1..20 Lines = {Home}{Shift+Down_$1};\n\n\nSelect between (Delimiters | Brackets | Tags) ={Ctrl+m} {Ctrl+Alt+m};\nDelete between Tags = {Ctrl+m} {Ctrl+Alt+m} {Del};\nDelete Tags = {Ctrl+Alt+F4};\nReplace With (Header | Heading) 1..7 = {Ctrl+Alt+F4} '<h' $2 '>' {End} '<\/h' $2 '>' {Home};\nReplace With (para = 'p') = {Ctrl+Alt+F4} '<' $1 '>' {End} '<\/' $1 '>';\n\n\nDelete Word = {Ctrl+Del};\nDelete 1..20 Words = {Ctrl+Del_$1};\nDelete (Back | Last) Word = {Ctrl+Backspace};\nDelete (Back | Last) 1..20 Words = {Ctrl+Backspace_$2};\nDelete Enda Word = {End} {Ctrl+Backspace};\nKill Word = {Ctrl+Backspace}{Ctrl+Del};\n\n(Delete Line | Dede) = {Ctrl+Shift+k};\nDelete 1..20 Lines = {Ctrl+Shift+k_$1};\n(Cut = 'x' | Paste = 'v' | Copy = 'c') That = {Ctrl+$1};\n\nComment (That | Line) = {Ctrl+\/};\nComment 1..20 Lines = {Home} {Shift+Down_$1} {Ctrl+\/};\n\nReplace = {Ctrl+f};\nReplace All = {Ctrl+Enter};\n\n(Join = 'j' | Indent = ']' | Dedent = '[') That = {Ctrl+$1};\n\n\n# --- Commands to create code\/tags -------------------------------------------\n# NOTE: basic HTML commands are stored in my global Vocala commands\n\nStart (\t# HTML commands\n\t'HTML page' = 'html' | pre = \"pre\" | 'Comment' = 'comment-html'\n\t| div = 'div' \n\t| 'class example' = 'class-example'\t\t# Used in A Taste of D3\n\n\t# D3 Recipe commands\n\t| 'Recipe Page' = 'recipe-page' | 'Recipe Row' = 'recipe-row' \n\t| 'Recipe Toy' = 'recipe-toy' | Toy = 'recipe-toy'\n\t| 'Bold ID'\n\n\t# D3 and JavaScript commands\n\t| Console = 'console' | Log = 'console'\n\t| Var = 'variable' | Variable = 'variable'\n\t# Coffeescript commands\n\t| Snippet = 'my-snippet' \n\t| 'Fix Line' = 'fix-current-line' | 'Fix Current Line' = 'fix-current-line'\n) = $1 {Tab};\n\nStop (\t#HTML commands\n\t'div comment' = 'comment-div-end' | Comment = 'comment-html-end' | 'div' = 'div-end'\n) = $1 {Tab};\n\n# HTML commands\nDot HTML = '.html';\nStart (Header | Heading) 1..7 = h $2 {Tab};\nAdd (Header | Heading) 1..7 = '<h' $2 '>' {End} '<\/h' $2 '>';\nAdd (para = 'p') = '<' $1 '>' {End} '<\/' $1 '>';\n\n# D3 Recipe commands\nPre-Format Code = {Ctrl+Alt+F5};\nReload Atom = {Ctrl+s} Wait(100) {Shift+Ctrl+Alt+F5};\nCommand Palette = {Ctrl+Shift+p};\nKeyboard Shortcuts = {Ctrl+.};\nRun Specs = {Ctrl+Alt+p};\nShow Console = {Ctrl+Alt+i};\n\n\n\n# D3 commands\nPaste Function = 'function ' {Ctrl+v} ' {' {Enter} {Enter} '};' {Up};\n\n# Coffeescript commands\n\n# Python commands\n\n\n# --- D3 commands -------------------------------------------\n\n\n# --- Python commands -------------------------------------------\n\n\n# --- Coffeescript commands -------------------------------------------","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"670c408702417011ab5ae131df2694548d74f2ec","subject":"Add class example, stop div commands","message":"Add class example, stop div commands\n","repos":"aschneiderman\/atom-voice-vocola","old_file":"atom.vcl","new_file":"atom.vcl","new_contents":"# Voice commands for atom\n\nTest Command = \"This Is a Test Command\"; # see if working on laptop\n\ninclude folders.vch;\ninclude letters.vch;\n\n# Commands for developing D3: D3 visualizations, D3 Sandwiches\nSave and Reload = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Ctrl+r};\t\nSave and Really Reload = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Ctrl+Shift+r};\nSave and Run = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Up}{Enter};\n\n# File commands\nFind (File | Document) = {Ctrl+t};\nSave As = {Ctrl+Shift+s};\nNext Window = {Ctrl+Tab};\nLast Window = {Ctrl+Shift+Tab};\nLatest File = {Ctrl+Shift+t};\n(Tree View | List Files) = {Alt+o};\t# NOTE: to make this work, I had to create a new keyboard shortcut in Atom (my personal keymap.cson)\n\n\n# --- Text navigation commands ------------------------------------\n<delimiters> := (Quote = '\"' | 'Double Quote' = '\"' | 'Single Quote' = \"'\" | Comma = ',' | 'Equal Sign' = '=' | Equals = '=' \n\t| Period = '.' | Colon = ':' | 'Semi-Colon' = ';' | Hyphen = '-' | Underscore = '_' | Slash = '\/'\n\t| Paren = \"(\" | \"Close Paren\" = \")\" | Parentheses = \"(\" | \"Open Parenthesis\" = \"(\" | \"Close Parentheses\" = \")\"\n\t| Bracket = '[' | \"Close Bracket\" = ']' | Brace = '{' | 'Close Brace' = '}'\t);\n\nLine 1..200 = {Ctrl+g} $1 {Enter};\n(Left = 'b' | Right = 'f') Word = {Alt+$1};\nTop = {Ctrl+Home};\nBottom = {Ctrl+End};\n(Find = 'Right' | 'Insert After' = 'Right' | 'Insert Before' = 'Left') (Next = 'Enter' | Last = 'Shift+F3') <delimiters> \n\t\t= {Ctrl+f} $3 {$2} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') <delimiters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') 1..20 <delimiters> = {Ctrl+f} $3 {Enter} {Esc} Wait(100) {F3_$2} {Shift+F3} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') Enda <delimiters> = {End} {Ctrl+f} $2 {Enter} {Esc} {Shift+F3} Wait(100) {$1};\n\nFine Alpha <letters> = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Left};\nInsert (Before = 'Left' | After = 'Right') Alpha <letters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nFine Number 0..9 = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Right};\n(Find | Insert) Again = {F3} {Right};\n(Find | Insert) Again 1..20 Times = {F3_$1} {Right};\n\n(Set | Add | Clear | Hide | Delete) Bookmark = {Ctrl+Alt+F2};\n(Next = 'F2' | Last = 'Shift+F2') Bookmark = {$1};\n\n\n# --- Editing commands ----------------------------------------\nSelect Line = {Ctrl+l};\nSelect (Next = 'Down' | Forward = 'Down' | Last = 'Up' | Back = 'Up' | Previous = 'Up') 1..20 Lines = {Home} {Shift+$1_$2};\nMove Line (Up | Down) 1..20 = {Ctrl+$1_$2};\nAdd 1..20 (Lines = 'Down' | Line = 'Down' | Pages = 'PgDn' | Page = 'PgDn') = {Shift+$2_$1};\nStart Adding 1..20 Lines = {Home}{Shift+Down_$1};\n\n\nSelect between (Delimiters | Brackets | Tags) ={Ctrl+m} {Ctrl+Alt+m};\nDelete between Tags = {Ctrl+m} {Ctrl+Alt+m} {Del};\nDelete Tags = {Ctrl+Alt+F4};\nReplace With (Header | Heading) 1..7 = {Ctrl+Alt+F4} '<h' $2 '>' {End} '<\/h' $2 '>' {Home};\nReplace With (para = 'p') = {Ctrl+Alt+F4} '<' $1 '>' {End} '<\/' $1 '>';\n\n\nDelete Word = {Ctrl+Del};\nDelete 1..20 Words = {Ctrl+Del_$1};\nDelete (Back | Last) Word = {Ctrl+Backspace};\nDelete (Back | Last) 1..20 Words = {Ctrl+Backspace_$2};\nDelete Enda Word = {End} {Ctrl+Backspace};\nKill Word = {Ctrl+Backspace}{Ctrl+Del};\n\n(Delete Line | Dede) = {Ctrl+Shift+k};\nDelete 1..20 Lines = {Ctrl+Shift+k_$1};\n(Cut = 'x' | Paste = 'v' | Copy = 'c') That = {Ctrl+$1};\n\nComment (That | Line) = {Ctrl+\/};\nComment 1..20 Lines = {Home} {Shift+Down_$1} {Ctrl+\/};\n\nReplace = {Ctrl+f};\nReplace All = {Ctrl+Enter};\n\n(Join = 'j' | Indent = ']' | Dedent = '[') That = {Ctrl+$1};\n\n\n# --- Commands to create code\/tags -------------------------------------------\n# NOTE: basic HTML commands are stored in my global Vocala commands\n\nStart (\t# HTML commands\n\t'HTML page' = 'html' | pre = \"pre\" | 'Comment' = 'comment-html'\n\t| div = 'div' \n\t| 'class example' = 'class-example'\t\t# Used in A Taste of D3\n\n\t# D3 Recipe commands\n\t| 'Recipe Page' = 'recipe-page' | 'Recipe Row' = 'recipe-row' \n\t| 'Recipe Toy' = 'recipe-toy' | Toy = 'recipe-toy'\n\t| 'Bold ID'\n\n\t# D3 and JavaScript commands\n\t| Console = 'console' | Log = 'console'\n\t| Var = 'variable' | Variable = 'variable'\n\t# Coffeescript commands\n\t| Snippet = 'my-snippet' \n\t| 'Fix Line' = 'fix-current-line' | 'Fix Current Line' = 'fix-current-line'\n) = $1 {Tab};\n\nStop (\t#HTML commands\n\t'div comment' = 'comment-div-end' | Comment = 'comment-html-end' | 'div' = 'div-end'\n) = $1 {Tab};\n\n# HTML commands\nDot HTML = '.html';\nStart (Header | Heading) 1..7 = h $2 {Tab};\nAdd (Header | Heading) 1..7 = '<h' $2 '>' {End} '<\/h' $2 '>';\nAdd (para = 'p') = '<' $1 '>' {End} '<\/' $1 '>';\n\n# D3 Recipe commands\nPre-Format Code = {Ctrl+Alt+F5};\nReload Atom = {Ctrl+s} Wait(100) {Shift+Ctrl+Alt+F5};\nCommand Palette = {Ctrl+Shift+p};\nKeyboard Shortcuts = {Ctrl+.};\nRun Specs = {Ctrl+Alt+p};\nShow Console = {Ctrl+Alt+i};\n\n\n\n# D3 commands\nPaste Function = 'function ' {Ctrl+v} ' {' {Enter} {Enter} '};' {Up};\n\n# Coffeescript commands\n\n# Python commands\n\n\n# --- D3 commands -------------------------------------------\n\n\n# --- Python commands -------------------------------------------\n\n\n# --- Coffeescript commands -------------------------------------------","old_contents":"# Voice commands for atom\n\nTest Command = \"This Is a Test Command\"; # see if working on laptop\n\ninclude folders.vch;\ninclude letters.vch;\n\n# Commands for developing D3: D3 visualizations, D3 Sandwiches\nSave and Reload = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Ctrl+r};\t\nSave and Really Reload = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Ctrl+Shift+r};\nSave and Run = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Up}{Enter};\n\n# File commands\nFind (File | Document) = {Ctrl+t};\nSave As = {Ctrl+Shift+s};\nNext Window = {Ctrl+Tab};\nLast Window = {Ctrl+Shift+Tab};\nLatest File = {Ctrl+Shift+t};\n(Tree View | List Files) = {Alt+o};\t# NOTE: to make this work, I had to create a new keyboard shortcut in Atom (my personal keymap.cson)\n\n\n# --- Text navigation commands ------------------------------------\n<delimiters> := (Quote = '\"' | 'Double Quote' = '\"' | 'Single Quote' = \"'\" | Comma = ',' | 'Equal Sign' = '=' | Equals = '=' \n\t| Period = '.' | Colon = ':' | 'Semi-Colon' = ';' | Hyphen = '-' | Underscore = '_' | Slash = '\/'\n\t| Paren = \"(\" | \"Close Paren\" = \")\" | Parentheses = \"(\" | \"Open Parenthesis\" = \"(\" | \"Close Parentheses\" = \")\"\n\t| Bracket = '[' | \"Close Bracket\" = ']' | Brace = '{' | 'Close Brace' = '}'\t);\n\nLine 1..200 = {Ctrl+g} $1 {Enter};\n(Left = 'b' | Right = 'f') Word = {Alt+$1};\nTop = {Ctrl+Home};\nBottom = {Ctrl+End};\n(Find = 'Right' | 'Insert After' = 'Right' | 'Insert Before' = 'Left') (Next = 'Enter' | Last = 'Shift+F3') <delimiters> \n\t\t= {Ctrl+f} $3 {$2} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') <delimiters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') 1..20 <delimiters> = {Ctrl+f} $3 {Enter} {Esc} Wait(100) {F3_$2} {Shift+F3} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') Enda <delimiters> = {End} {Ctrl+f} $2 {Enter} {Esc} {Shift+F3} Wait(100) {$1};\n\nFine Alpha <letters> = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Left};\nInsert (Before = 'Left' | After = 'Right') Alpha <letters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nFine Number 0..9 = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Right};\n(Find | Insert) Again = {F3} {Right};\n(Find | Insert) Again 1..20 Times = {F3_$1} {Right};\n\n(Set | Add | Clear | Hide | Delete) Bookmark = {Ctrl+Alt+F2};\n(Next = 'F2' | Last = 'Shift+F2') Bookmark = {$1};\n\n\n# --- Editing commands ----------------------------------------\nSelect Line = {Ctrl+l};\nSelect (Next = 'Down' | Forward = 'Down' | Last = 'Up' | Back = 'Up' | Previous = 'Up') 1..20 Lines = {Home} {Shift+$1_$2};\nMove Line (Up | Down) 1..20 = {Ctrl+$1_$2};\nAdd 1..20 (Lines = 'Down' | Line = 'Down' | Pages = 'PgDn' | Page = 'PgDn') = {Shift+$2_$1};\nStart Adding 1..20 Lines = {Home}{Shift+Down_$1};\n\n\nSelect between (Delimiters | Brackets | Tags) ={Ctrl+m} {Ctrl+Alt+m};\nDelete between Tags = {Ctrl+m} {Ctrl+Alt+m} {Del};\nDelete Tags = {Ctrl+Alt+F4};\nReplace With (Header | Heading) 1..7 = {Ctrl+Alt+F4} '<h' $2 '>' {End} '<\/h' $2 '>' {Home};\nReplace With (para = 'p') = {Ctrl+Alt+F4} '<' $1 '>' {End} '<\/' $1 '>';\n\n\nDelete Word = {Ctrl+Del};\nDelete 1..20 Words = {Ctrl+Del_$1};\nDelete (Back | Last) Word = {Ctrl+Backspace};\nDelete (Back | Last) 1..20 Words = {Ctrl+Backspace_$2};\nDelete Enda Word = {End} {Ctrl+Backspace};\nKill Word = {Ctrl+Backspace}{Ctrl+Del};\n\n(Delete Line | Dede) = {Ctrl+Shift+k};\nDelete 1..20 Lines = {Ctrl+Shift+k_$1};\n(Cut = 'x' | Paste = 'v' | Copy = 'c') That = {Ctrl+$1};\n\nComment (That | Line) = {Ctrl+\/};\nComment 1..20 Lines = {Home} {Shift+Down_$1} {Ctrl+\/};\n\nReplace = {Ctrl+f};\nReplace All = {Ctrl+Enter};\n\n(Join = 'j' | Indent = ']' | Dedent = '[') That = {Ctrl+$1};\n\n\n# --- Commands to create code\/tags -------------------------------------------\n# NOTE: basic HTML commands are stored in my global Vocala commands\n\nStart (\t# HTML commands\n\t'HTML page' = 'html' | pre = \"pre\" | 'Comment' = 'comment-html'\n\t| div = 'div' \n\n\t# D3 Recipe commands\n\t| 'Recipe Page' = 'recipe-page' | 'Recipe Row' = 'recipe-row' \n\t| 'Recipe Toy' = 'recipe-toy' | Toy = 'recipe-toy'\n\t| 'Bold ID'\n\n\t# D3 and JavaScript commands\n\t| Console = 'console' | Log = 'console'\n\t| Var = 'variable' | Variable = 'variable'\n\t# Coffeescript commands\n\t| Snippet = 'my-snippet' \n\t| 'Fix Line' = 'fix-current-line' | 'Fix Current Line' = 'fix-current-line'\n) = $1 {Tab};\n\nStop (\t#HTML commands\n\t'div comment' = 'comment-div-end' | Comment = 'comment-html-end' \n) = $1 {Tab};\n\n# HTML commands\nDot HTML = '.html';\nStart (Header | Heading) 1..7 = h $2 {Tab};\nAdd (Header | Heading) 1..7 = '<h' $2 '>' {End} '<\/h' $2 '>';\nAdd (para = 'p') = '<' $1 '>' {End} '<\/' $1 '>';\n\n# D3 Recipe commands\nPre-Format Code = {Ctrl+Alt+F5};\nReload Atom = {Ctrl+s} Wait(100) {Shift+Ctrl+Alt+F5};\nCommand Palette = {Ctrl+Shift+p};\nKeyboard Shortcuts = {Ctrl+.};\nRun Specs = {Ctrl+Alt+p};\nShow Console = {Ctrl+Alt+i};\n\n\n\n# D3 commands\nPaste Function = 'function ' {Ctrl+v} ' {' {Enter} {Enter} '};' {Up};\n\n# Coffeescript commands\n\n# Python commands\n\n\n# --- D3 commands -------------------------------------------\n\n\n# --- Python commands -------------------------------------------\n\n\n# --- Coffeescript commands -------------------------------------------","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"2ba5ba39cc5035659a82550ae4c00db854bc2c39","subject":"#65: Escape % characters in kodekit.vcl","message":"#65: Escape % characters in kodekit.vcl\n","repos":"nooku\/nooku-platform,nooku\/nooku-platform,nooku\/nooku-platform,nooku\/nooku-platform,nooku\/nooku-platform","old_file":"component\/varnish\/resources\/varnish\/kodekit.vcl","new_file":"component\/varnish\/resources\/varnish\/kodekit.vcl","new_contents":"vcl 4.0;\n# Based on: https:\/\/github.com\/mattiasgeniar\/varnish-4.0-configuration-templates\/blob\/master\/default.vcl\n\nimport std;\nimport directors;\n\nprobe health\n{\n #.url = \"\/varnish-enabled\";\n # We prefer to only do a HEAD \/\n .request =\n \"HEAD \/varnish-enabled HTTP\/1.1\"\n \"Host: localhost\"\n \"Connection: close\";\n \"User-Agent: Varnish Health Probe\";\n .interval = 5s; # check the health of each backend every 5 seconds\n .timeout = 1s; # timing out after 1 second.\n # If 3 out of the last 5 polls succeeded the backend is considered healthy, otherwise it will be marked as sick\n .window = 5;\n .threshold = 3;\n .expected_response = 200;\n}\n\nbackend default\n{\n .host = \"127.0.0.1\"; # IP or Hostname of backend\n .port = \"%1$s\"; # Port Apache or whatever is listening\n .max_connections = 300; # That's it\n .probe = health;\n .connect_timeout = 600s; # How long to wait before we receive a first byte from our backend?\n .first_byte_timeout = 600s; # How long to wait for a backend connection?\n .between_bytes_timeout = 600s; # How long to wait between bytes received from our backend?\n}\n\nbackend passthrough\n{\n .host = \"127.0.0.1\"; # IP or Hostname of backend\n .port = \"%1$s\"; # Port Apache or whatever is listening\n}\n\nacl localhost\n{\n \"localhost\";\n \"33.33.33.63\";\n \"::1\";\n}\n\nsub vcl_init\n{\n # Called when VCL is loaded, before any requests pass through it.\n # Typically used to initialize VMODs.\n\n new vdir = directors.round_robin();\n vdir.add_backend(default);\n # vdir.add_backend(server...);\n # vdir.add_backend(servern);\n}\n\nsub vcl_recv\n{\n # Called at the beginning of a request, after the complete request has been received and parsed.\n # Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable,\n # which backend to use and if needed to modify the request.\n\n # Send all traffic to the vdir director\n set req.backend_hint = vdir.backend();\n\n # Normalize the header, remove the port (in case you're testing this on various TCP ports)\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n # Normalize the query arguments\n set req.url = std.querysort(req.url);\n\n # Allow purging\n if (req.method == \"PURGE\")\n {\n # purge is the ACL defined at the begining\n if (!client.ip ~ localhost) {\n return (synth(405, \"This IP is not allowed to send PURGE requests.\"));\n }\n\n # If you got this stage (and didn't error out above), purge the cached result\n return (purge);\n }\n\n # Check if we've still enabled Varnish, if not, passthrough every request\n if (! std.healthy(req.backend_hint))\n {\n set req.backend_hint = passthrough;\n return (pass);\n }\n\n # Only deal with \"normal\" types\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"PATCH\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n # Implementing websocket support (https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html)\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n # Only cache GET or HEAD requests. This makes sure the POST requests are always passed.\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n # Specific Nooku Platform rules\n\n # Do not cache \/administrator\n if(req.url ~ \"^\/administrator\") {\n return (pass);\n }\n\n # Specific Nooku Server rules\n\n # Do not cache webgrind.nooku.dev\n if (req.http.host == \"webgrind.nooku.dev\") {\n return (pass);\n }\n\n # Do not cache phpmyadmin.nooku.dev\n if (req.http.host == \"phpmyadmin.nooku.dev\") {\n return (pass);\n }\n\n # Do not cache \/apc and \/phpinfo\n if (req.url == \"\/apc\" || req.url == \"\/phpinfo\") {\n return (pass);\n }\n\n # Generic URL manipulation, useful for all templates that follow\n\n # Remove the Google Analytics added parameters, useless for our backend\n if (req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=\") {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # Strip hash, server doesn't need it.\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n # Strip a trailing ? if it exists\n if (req.url ~ \"\\?$\") {\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # Cookie manipulation\n\n # Remove the \"has_js\" cookie\n set req.http.Cookie = regsuball(req.http.Cookie, \"has_js=[^;]+(; )?\", \"\");\n\n # Remove any Google Analytics based cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__utm.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"_ga=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"_gat=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmctr=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmcmd.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmccn.=[^;]+(; )?\", \"\");\n\n # Remove DoubleClick offensive cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__gads=[^;]+(; )?\", \"\");\n\n # Remove the Quant Capital cookies (added by some plugin, all __qca)\n set req.http.Cookie = regsuball(req.http.Cookie, \"__qc.=[^;]+(; )?\", \"\");\n\n # Remove the AddThis cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__atuv.=[^;]+(; )?\", \"\");\n\n # Remove a \";\" prefix in the cookie if present\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n\n # Remove the csrf_token cookie\n set req.http.Cookie = regsuball(req.http.Cookie, \"csrf_token=[^;]+(; )?\", \"\");\n\n # Are there cookies left with only spaces or that are empty?\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n\n # Large static files are delivered directly to the end-user without waiting for Varnish to fully read the file first.\n # Varnish 4 supports Streaming, so set do_stream in vcl_backend_response()\n if (req.url ~ \"^[^?]*\\.(7z|avi|bz2|flac|flv|gz|mka|mkv|mov|mp3|mp4|mpeg|mpg|ogg|ogm|opus|rar|tar|tgz|tbz|txz|wav|webm|xz|zip)(\\?.*)?$\") {\n unset req.http.Cookie;\n return (hash);\n }\n\n # Remove all cookies for static files\n # Before you blindly enable this read: https:\/\/ma.ttias.be\/stop-caching-static-files\/\n #if (req.method == \"GET\")\n #{\n # # Cache files with these extensions and remove cookie\n # if (req.url ~ \"^[^?]*\\.(7z|avi|bmp|bz2|css|csv|doc|docx|eot|flac|flv|gif|gz|ico|jpeg|jpg|js|less|mka|mkv|mov|mp3|mp4|mpeg|mpg|odt|otf|ogg|ogm|opus|pdf|png|ppt|pptx|rar|rtf|svg|svgz|swf|tar|tbz|tgz|ttf|txt|txz|wav|webm|webp|woff|woff2|xls|xlsx|xml|xz|zip)(\\?.*)?$\") {\n # unset req.http.Cookie;\n # return (hash);\n # }\n #}\n\n if (req.http.Cache-Control ~ \"(?i)no-cache\" && client.ip ~ localhost)\n {\n # http:\/\/varnish.projects.linpro.no\/wiki\/VCLExampleEnableForceRefresh\n # Ignore requests via proxy caches and badly behaved crawlers\n # like msnbot that send no-cache with every request.\n if (! (req.http.Via || req.http.User-Agent ~ \"(?i)bot\" || req.http.X-Purge))\n {\n # Doesn't seems to refresh the object in the cache\n set req.hash_always_miss = true;\n\n # Couple this with restart in vcl_purge and X-Purge header to avoid loops\n return(purge);\n }\n }\n\n # Send Surrogate-Capability headers to announce ESI support to backend\n set req.http.Surrogate-Capability = \"varnish=ESI\/1.0\";\n\n # Requests that require authorization are not cacheable by default\n if (req.http.Authorization) {\n return (pass);\n }\n\n # We do not support SPDY or HTTP\/2.0\n if (req.method == \"PRI\") {\n return (synth(405));\n }\n\n return (hash);\n}\n\n# Called upon entering pipe mode. In this mode, the request is passed on to the backend, and any further data from both\n# the client and backend is passed on unaltered until either end closes the connection. Basically, Varnish will degrade\n# into a simple TCP proxy, shuffling bytes back and forth. For a connection in pipe mode, no other VCL subroutine will\n# ever get called after vcl_pipe.\nsub vcl_pipe\n{\n # Note that only the first request to the backend will have X-Forwarded-For set.\n # If you use X-Forwarded-For and want to have it set for all requests, make sure to have:\n # set bereq.http.connection = \"close\";\n # It is not set by default as it might break some broken web applications, like IIS with NTLM authentication.\n # set bereq.http.Connection = \"Close\";\n\n # Implementing websocket support (https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html)\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n\n return (pipe);\n}\n\n# Called upon entering pass mode. In this mode, the request is passed on to the backend, and the backend's response\n# is passed on to the client, but is not entered into the cache. Subsequent requests submitted over the same client\n# connection are handled normally.\nsub vcl_pass\n{\n return (fetch);\n}\n\n# Called after vcl_recv to create a hash value for the request. This is used as a key to look up the object in Varnish.\nsub vcl_hash\n{\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n\n # hash cookies for requests that have them\n if (req.http.Cookie) {\n hash_data(req.http.Cookie);\n }\n}\n\n# Called when a cache lookup is successful.\nsub vcl_hit\n{\n # A pure unadultered hit, deliver it\n if (obj.ttl >= 0s) {\n return (deliver);\n }\n\n # https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-grace.html\n # When several clients are requesting the same page Varnish will send one request to the backend and place the\n # others on hold while fetching one copy from the backend. In some products this is called request coalescing and\n # Varnish does this automatically.\n\n # If you are serving thousands of hits per second the queue of waiting requests can get huge. There are two\n # potential problems - one is a thundering herd problem - suddenly releasing a thousand threads to serve content\n # might send the load sky high. Secondly - nobody likes to wait. To deal with this we can instruct Varnish to keep\n # the objects in cache beyond their TTL and to serve the waiting requests somewhat stale content.\n\n # if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n # return (deliver);\n # } else {\n # return (fetch);\n # }\n\n # We have no fresh fish. Lets look at the stale ones.\n if (std.healthy(req.backend_hint))\n {\n # Backend is healthy. Limit age to 10s.\n if (obj.ttl + 10s > 0s)\n {\n #set req.http.grace = \"normal(limited)\";\n return (deliver);\n }\n else\n {\n # No candidate for grace. Fetch a fresh object.\n return(fetch);\n }\n }\n else\n {\n # backend is sick - use full grace\n if (obj.ttl + obj.grace > 0s)\n {\n #set req.http.grace = \"full\";\n return (deliver);\n }\n else\n {\n # no graced object.\n return (fetch);\n }\n }\n\n # fetch & deliver once we get the result\n return (fetch); # Dead code, keep as a safeguard\n}\n\n# Called after a cache lookup if the requested document was not found in the cache. Its purpose is to decide whether\n# or not to attempt to retrieve the document from the backend, and which backend to use.\nsub vcl_miss\n{\n return (fetch);\n}\n\n # Called after the response headers has been successfully retrieved from the backend.\nsub vcl_backend_response\n{\n # Enable ESI handling\n if (beresp.http.Surrogate-Control ~ \"ESI\/1.0\" ) {\n set beresp.do_esi = true;\n }\n\n # Store the csrf_token cookie temporarily if the response is cacheabale\n if (beresp.http.Set-Cookie && !beresp.uncacheable)\n {\n set beresp.http.X-Varnish-Cookie = beresp.http.Set-Cookie;\n unset beresp.http.Set-Cookie;\n }\n\n # Cache handling all static files\n if (bereq.method == \"GET\")\n {\n # Before you blindly enable this, read: https:\/\/ma.ttias.be\/stop-caching-static-files\/\n #if (bereq.url ~ \"^[^?]*\\.(7z|avi|bmp|bz2|css|csv|doc|docx|eot|flac|flv|gif|gz|ico|jpeg|jpg|js|less|mka|mkv|mov|mp3|mp4|mpeg|mpg|odt|otf|ogg|ogm|opus|pdf|png|ppt|pptx|rar|rtf|svg|svgz|swf|tar|tbz|tgz|ttf|txt|txz|wav|webm|webp|woff|woff2|xls|xlsx|xml|xz|zip)(\\?.*)?$\") {\n # unset beresp.http.Set-Cookie;\n #}\n\n # Large static files are delivered directly to the end-user without waiting for Varnish to fully read the\n # file first. Check memory usage it'll grow in fetch_chunksize blocks (128k by default) if the backend\n # doesn't send a Content-Length header. Only enable it for large files\n if (bereq.url ~ \"^[^?]*\\.(7z|avi|bz2|flac|flv|gz|mka|mkv|mov|mp3|mp4|mpeg|mpg|ogg|ogm|opus|rar|tar|tgz|tbz|txz|wav|webm|xz|zip)(\\?.*)?$\") {\n {\n unset beresp.http.Set-Cookie;\n\n # Use streaming to avoid locking\n set beresp.do_stream = true;\n\n # Don't try to compress it for storage\n set beresp.do_gzip = false;\n\n # Disable Transfer-encoding chunked when serving HTML5 video\n # See : http:\/\/stackoverflow.com\/questions\/23643233\/how-do-i-disable-transfer-encoding-chunked-encoding-in-varnish\n # See : https:\/\/www.varnish-cache.org\/trac\/ticket\/1506\n if(beresp.http.Content-Type ~ \"video\") {\n set beresp.do_stream = true;\n set beresp.do_esi = true;\n }\n }\n\n # Set 2min cache if unset for static files\n if (beresp.ttl <= 0s || beresp.http.Set-Cookie || beresp.http.Vary == \"*\")\n {\n set beresp.ttl = 120s; # Important, you shouldn't rely on this, SET YOUR HEADERS in the backend\n set beresp.uncacheable = true;\n\n return (deliver);\n }\n }\n\n # Sometimes, a 301 or 302 redirect formed via Apache's mod_rewrite can mess with the HTTP port that is being passed along.\n # This often happens with simple rewrite rules in a scenario where Varnish runs on :80 and Apache on :8080 on the same box.\n # A redirect can then often redirect the end-user to a URL on :8080, where it should be :80.\n # This may need finetuning on your setup.\n #\n # To prevent accidental replace, we only filter the 301\/302 redirects for now.\n if (beresp.status == 301 || beresp.status == 302) {\n set beresp.http.Location = regsub(beresp.http.Location, \":[0-9]+\", \"\");\n }\n\n # Never cache 50x responses\n if (beresp.status >= 500) {\n return (abandon);\n }\n\n # Do not cache errors from the backend\n if (beresp.status >= 400)\n {\n set beresp.uncacheable = true;\n set beresp.ttl = 0s;\n\n return (deliver);\n }\n\n # Allow stale content, in case the backend goes down. Make Varnish keep all objects for 6 hours beyond their TTL\n set beresp.grace = 6h;\n\n # Set ban-lurker friendly custom headers\n set beresp.http.X-Varnish-Url = bereq.url;\n set beresp.http.X-Varnish-Host = bereq.http.host;\n\n return (deliver);\n}\n\n# Called when the backend returns an error\nsub vcl_backend_error\n{\n if (beresp.status == 503 && bereq.retries < 5)\n {\n set beresp.http.X-Varnish-Retries = bereq.retries;\n return(retry);\n }\n\n return(deliver);\n}\n\n# Called before a cached object is delivered to the client.\nsub vcl_deliver\n{\n # Send the Cookie header again if a temporay header was stored\n if (req.http.X-Varnish-Cookie) {\n set resp.http.Set-Cookie = req.http.X-Varnish-Cookie;\n }\n\n # Add extra headers if debugging is enabled\n if (resp.http.x-varnish-debug && server.ip ~ localhost)\n {\n set resp.http.X-Served-By = server.hostname;\n\n if (resp.http.x-varnish ~ \" \") {\n set resp.http.X-Varnish-Status = \"HIT\";\n } else {\n set resp.http.X-Varnish-Status = \"MISS\";\n }\n\n # Please note that obj.hits behaviour changed in 4.0, now it counts per objecthead, not per object\n # and obj.hits may not be reset in some cases where bans are in use. See bug 1492 for details.\n # So take hits with a grain of salt\n set resp.http.X-Varnish-Hits = obj.hits;\n }\n else\n {\n # Remove ban-lurker friendly custom headers when delivering to client\n unset resp.http.X-Url;\n unset resp.http.X-Host;\n\n # Remove some headers: PHP version\n unset resp.http.X-Powered-By;\n\n # Remove some headers: Apache version & OS\n unset resp.http.Server;\n unset resp.http.Via;\n unset resp.http.Link;\n unset resp.http.X-Varnish;\n unset resp.http.X-Varnish-Tag;\n unset resp.http.X-Varnish-Debug;\n unset resp.http.X-Varnish-Host;\n unset resp.http.X-Varnish-Url;\n unset resp.http.X-Varnish-Retries;\n unset resp.http.X-Varnish-Cookie;\n unset resp.http.Surrogate-Control;\n }\n\n return (deliver);\n}\n\nsub vcl_purge\n{\n # Only handle actual PURGE HTTP methods, everything else is discarded\n if (req.method != \"PURGE\" && server.ip ~ localhost)\n {\n set req.http.X-Varnish-Purge = \"Yes\";\n return (restart);\n }\n}\n\nsub vcl_synth\n{\n if (resp.status == 720)\n {\n # We use this special error status 720 to force redirects with 301 (permanent) redirects\n # To use this, call the following from anywhere in vcl_recv: return (synth(720, \"http:\/\/host\/new.html\"));\n set resp.http.Location = resp.reason;\n set resp.status = 301;\n\n return (deliver);\n }\n elseif (resp.status == 721)\n {\n # And we use error status 721 to force redirects with a 302 (temporary) redirect\n # To use this, call the following from anywhere in vcl_recv: return (synth(720, \"http:\/\/host\/new.html\"));\n\n set resp.http.Location = resp.reason;\n set resp.status = 302;\n\n return (deliver);\n }\n\n return (deliver);\n}\n\n# Called when VCL is discarded only after all requests have exited the VCL. Typically used to clean up VMODs.\nsub vcl_fini\n{\n return (ok);\n}\n","old_contents":"vcl 4.0;\n# Based on: https:\/\/github.com\/mattiasgeniar\/varnish-4.0-configuration-templates\/blob\/master\/default.vcl\n\nimport std;\nimport directors;\n\nprobe health\n{\n #.url = \"\/varnish-enabled\";\n # We prefer to only do a HEAD \/\n .request =\n \"HEAD \/varnish-enabled HTTP\/1.1\"\n \"Host: localhost\"\n \"Connection: close\";\n \"User-Agent: Varnish Health Probe\";\n .interval = 5s; # check the health of each backend every 5 seconds\n .timeout = 1s; # timing out after 1 second.\n # If 3 out of the last 5 polls succeeded the backend is considered healthy, otherwise it will be marked as sick\n .window = 5;\n .threshold = 3;\n .expected_response = 200;\n}\n\nbackend default\n{\n .host = \"127.0.0.1\"; # IP or Hostname of backend\n .port = \"%1$s\"; # Port Apache or whatever is listening\n .max_connections = 300; # That's it\n .probe = health;\n .connect_timeout = 600s; # How long to wait before we receive a first byte from our backend?\n .first_byte_timeout = 600s; # How long to wait for a backend connection?\n .between_bytes_timeout = 600s; # How long to wait between bytes received from our backend?\n}\n\nbackend passthrough\n{\n .host = \"127.0.0.1\"; # IP or Hostname of backend\n .port = \"%1$s\"; # Port Apache or whatever is listening\n}\n\nacl localhost\n{\n \"localhost\";\n \"33.33.33.63\";\n \"::1\";\n}\n\nsub vcl_init\n{\n # Called when VCL is loaded, before any requests pass through it.\n # Typically used to initialize VMODs.\n\n new vdir = directors.round_robin();\n vdir.add_backend(default);\n # vdir.add_backend(server...);\n # vdir.add_backend(servern);\n}\n\nsub vcl_recv\n{\n # Called at the beginning of a request, after the complete request has been received and parsed.\n # Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable,\n # which backend to use and if needed to modify the request.\n\n # Send all traffic to the vdir director\n set req.backend_hint = vdir.backend();\n\n # Normalize the header, remove the port (in case you're testing this on various TCP ports)\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n # Normalize the query arguments\n set req.url = std.querysort(req.url);\n\n # Allow purging\n if (req.method == \"PURGE\")\n {\n # purge is the ACL defined at the begining\n if (!client.ip ~ localhost) {\n return (synth(405, \"This IP is not allowed to send PURGE requests.\"));\n }\n\n # If you got this stage (and didn't error out above), purge the cached result\n return (purge);\n }\n\n # Check if we've still enabled Varnish, if not, passthrough every request\n if (! std.healthy(req.backend_hint))\n {\n set req.backend_hint = passthrough;\n return (pass);\n }\n\n # Only deal with \"normal\" types\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"PATCH\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n # Implementing websocket support (https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html)\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n # Only cache GET or HEAD requests. This makes sure the POST requests are always passed.\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n # Specific Nooku Platform rules\n\n # Do not cache \/administrator\n if(req.url ~ \"^\/administrator\") {\n return (pass);\n }\n\n # Specific Nooku Server rules\n\n # Do not cache webgrind.nooku.dev\n if (req.http.host == \"webgrind.nooku.dev\") {\n return (pass);\n }\n\n # Do not cache phpmyadmin.nooku.dev\n if (req.http.host == \"phpmyadmin.nooku.dev\") {\n return (pass);\n }\n\n # Do not cache \/apc and \/phpinfo\n if (req.url == \"\/apc\" || req.url == \"\/phpinfo\") {\n return (pass);\n }\n\n # Generic URL manipulation, useful for all templates that follow\n\n # Remove the Google Analytics added parameters, useless for our backend\n if (req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=\") {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # Strip hash, server doesn't need it.\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n # Strip a trailing ? if it exists\n if (req.url ~ \"\\?$\") {\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # Cookie manipulation\n\n # Remove the \"has_js\" cookie\n set req.http.Cookie = regsuball(req.http.Cookie, \"has_js=[^;]+(; )?\", \"\");\n\n # Remove any Google Analytics based cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__utm.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"_ga=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"_gat=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmctr=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmcmd.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmccn.=[^;]+(; )?\", \"\");\n\n # Remove DoubleClick offensive cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__gads=[^;]+(; )?\", \"\");\n\n # Remove the Quant Capital cookies (added by some plugin, all __qca)\n set req.http.Cookie = regsuball(req.http.Cookie, \"__qc.=[^;]+(; )?\", \"\");\n\n # Remove the AddThis cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__atuv.=[^;]+(; )?\", \"\");\n\n # Remove a \";\" prefix in the cookie if present\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n\n # Remove the csrf_token cookie\n set req.http.Cookie = regsuball(req.http.Cookie, \"csrf_token=[^;]+(; )?\", \"\");\n\n # Are there cookies left with only spaces or that are empty?\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n\n # Large static files are delivered directly to the end-user without waiting for Varnish to fully read the file first.\n # Varnish 4 supports Streaming, so set do_stream in vcl_backend_response()\n if (req.url ~ \"^[^?]*\\.(7z|avi|bz2|flac|flv|gz|mka|mkv|mov|mp3|mp4|mpeg|mpg|ogg|ogm|opus|rar|tar|tgz|tbz|txz|wav|webm|xz|zip)(\\?.*)?$\") {\n unset req.http.Cookie;\n return (hash);\n }\n\n # Remove all cookies for static files\n # Before you blindly enable this read: https:\/\/ma.ttias.be\/stop-caching-static-files\/\n #if (req.method == \"GET\")\n #{\n # # Cache files with these extensions and remove cookie\n # if (req.url ~ \"^[^?]*\\.(7z|avi|bmp|bz2|css|csv|doc|docx|eot|flac|flv|gif|gz|ico|jpeg|jpg|js|less|mka|mkv|mov|mp3|mp4|mpeg|mpg|odt|otf|ogg|ogm|opus|pdf|png|ppt|pptx|rar|rtf|svg|svgz|swf|tar|tbz|tgz|ttf|txt|txz|wav|webm|webp|woff|woff2|xls|xlsx|xml|xz|zip)(\\?.*)?$\") {\n # unset req.http.Cookie;\n # return (hash);\n # }\n #}\n\n if (req.http.Cache-Control ~ \"(?i)no-cache\" && client.ip ~ localhost)\n {\n # http:\/\/varnish.projects.linpro.no\/wiki\/VCLExampleEnableForceRefresh\n # Ignore requests via proxy caches and badly behaved crawlers\n # like msnbot that send no-cache with every request.\n if (! (req.http.Via || req.http.User-Agent ~ \"(?i)bot\" || req.http.X-Purge))\n {\n # Doesn't seems to refresh the object in the cache\n set req.hash_always_miss = true;\n\n # Couple this with restart in vcl_purge and X-Purge header to avoid loops\n return(purge);\n }\n }\n\n # Send Surrogate-Capability headers to announce ESI support to backend\n set req.http.Surrogate-Capability = \"varnish=ESI\/1.0\";\n\n # Requests that require authorization are not cacheable by default\n if (req.http.Authorization) {\n return (pass);\n }\n\n # We do not support SPDY or HTTP\/2.0\n if (req.method == \"PRI\") {\n return (synth(405));\n }\n\n return (hash);\n}\n\n# Called upon entering pipe mode. In this mode, the request is passed on to the backend, and any further data from both\n# the client and backend is passed on unaltered until either end closes the connection. Basically, Varnish will degrade\n# into a simple TCP proxy, shuffling bytes back and forth. For a connection in pipe mode, no other VCL subroutine will\n# ever get called after vcl_pipe.\nsub vcl_pipe\n{\n # Note that only the first request to the backend will have X-Forwarded-For set.\n # If you use X-Forwarded-For and want to have it set for all requests, make sure to have:\n # set bereq.http.connection = \"close\";\n # It is not set by default as it might break some broken web applications, like IIS with NTLM authentication.\n # set bereq.http.Connection = \"Close\";\n\n # Implementing websocket support (https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html)\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n\n return (pipe);\n}\n\n# Called upon entering pass mode. In this mode, the request is passed on to the backend, and the backend's response\n# is passed on to the client, but is not entered into the cache. Subsequent requests submitted over the same client\n# connection are handled normally.\nsub vcl_pass\n{\n return (fetch);\n}\n\n# Called after vcl_recv to create a hash value for the request. This is used as a key to look up the object in Varnish.\nsub vcl_hash\n{\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n\n # hash cookies for requests that have them\n if (req.http.Cookie) {\n hash_data(req.http.Cookie);\n }\n}\n\n# Called when a cache lookup is successful.\nsub vcl_hit\n{\n # A pure unadultered hit, deliver it\n if (obj.ttl >= 0s) {\n return (deliver);\n }\n\n # https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-grace.html\n # When several clients are requesting the same page Varnish will send one request to the backend and place the\n # others on hold while fetching one copy from the backend. In some products this is called request coalescing and\n # Varnish does this automatically.\n\n # If you are serving thousands of hits per second the queue of waiting requests can get huge. There are two\n # potential problems - one is a thundering herd problem - suddenly releasing a thousand threads to serve content\n # might send the load sky high. Secondly - nobody likes to wait. To deal with this we can instruct Varnish to keep\n # the objects in cache beyond their TTL and to serve the waiting requests somewhat stale content.\n\n # if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n # return (deliver);\n # } else {\n # return (fetch);\n # }\n\n # We have no fresh fish. Lets look at the stale ones.\n if (std.healthy(req.backend_hint))\n {\n # Backend is healthy. Limit age to 10s.\n if (obj.ttl + 10s > 0s)\n {\n #set req.http.grace = \"normal(limited)\";\n return (deliver);\n }\n else\n {\n # No candidate for grace. Fetch a fresh object.\n return(fetch);\n }\n }\n else\n {\n # backend is sick - use full grace\n if (obj.ttl + obj.grace > 0s)\n {\n #set req.http.grace = \"full\";\n return (deliver);\n }\n else\n {\n # no graced object.\n return (fetch);\n }\n }\n\n # fetch & deliver once we get the result\n return (fetch); # Dead code, keep as a safeguard\n}\n\n# Called after a cache lookup if the requested document was not found in the cache. Its purpose is to decide whether\n# or not to attempt to retrieve the document from the backend, and which backend to use.\nsub vcl_miss\n{\n return (fetch);\n}\n\n # Called after the response headers has been successfully retrieved from the backend.\nsub vcl_backend_response\n{\n # Enable ESI handling\n if (beresp.http.Surrogate-Control ~ \"ESI\/1.0\" ) {\n set beresp.do_esi = true;\n }\n\n # Store the csrf_token cookie temporarily if the response is cacheabale\n if (beresp.http.Set-Cookie && !beresp.uncacheable)\n {\n set beresp.http.X-Varnish-Cookie = beresp.http.Set-Cookie;\n unset beresp.http.Set-Cookie;\n }\n\n # Cache handling all static files\n if (bereq.method == \"GET\")\n {\n # Before you blindly enable this, read: https:\/\/ma.ttias.be\/stop-caching-static-files\/\n #if (bereq.url ~ \"^[^?]*\\.(7z|avi|bmp|bz2|css|csv|doc|docx|eot|flac|flv|gif|gz|ico|jpeg|jpg|js|less|mka|mkv|mov|mp3|mp4|mpeg|mpg|odt|otf|ogg|ogm|opus|pdf|png|ppt|pptx|rar|rtf|svg|svgz|swf|tar|tbz|tgz|ttf|txt|txz|wav|webm|webp|woff|woff2|xls|xlsx|xml|xz|zip)(\\?.*)?$\") {\n # unset beresp.http.Set-Cookie;\n #}\n\n # Large static files are delivered directly to the end-user without waiting for Varnish to fully read the\n # file first. Check memory usage it'll grow in fetch_chunksize blocks (128k by default) if the backend\n # doesn't send a Content-Length header. Only enable it for large files\n if (bereq.url ~ \"^[^?]*\\.(7z|avi|bz2|flac|flv|gz|mka|mkv|mov|mp3|mp4|mpeg|mpg|ogg|ogm|opus|rar|tar|tgz|tbz|txz|wav|webm|xz|zip)(\\?.*)?$\") {\n {\n unset beresp.http.Set-Cookie;\n\n # Use streaming to avoid locking\n set beresp.do_stream = true;\n\n # Don't try to compress it for storage\n set beresp.do_gzip = false;\n\n # Disable Transfer-encoding chunked when serving HTML5 video\n # See : http:\/\/stackoverflow.com\/questions\/23643233\/how-do-i-disable-transfer-encoding-chunked-encoding-in-varnish\n # See : https:\/\/www.varnish-cache.org\/trac\/ticket\/1506\n if(beresp.http.Content-Type ~ \"video\") {\n set beresp.do_stream = true;\n set beresp.do_esi = true;\n }\n }\n\n # Set 2min cache if unset for static files\n if (beresp.ttl <= 0s || beresp.http.Set-Cookie || beresp.http.Vary == \"*\")\n {\n set beresp.ttl = 120s; # Important, you shouldn't rely on this, SET YOUR HEADERS in the backend\n set beresp.uncacheable = true;\n\n return (deliver);\n }\n }\n\n # Sometimes, a 301 or 302 redirect formed via Apache's mod_rewrite can mess with the HTTP port that is being passed along.\n # This often happens with simple rewrite rules in a scenario where Varnish runs on :80 and Apache on :8080 on the same box.\n # A redirect can then often redirect the end-user to a URL on :8080, where it should be :80.\n # This may need finetuning on your setup.\n #\n # To prevent accidental replace, we only filter the 301\/302 redirects for now.\n if (beresp.status == 301 || beresp.status == 302) {\n set beresp.http.Location = regsub(beresp.http.Location, \":[0-9]+\", \"\");\n }\n\n # Never cache 50x responses\n if (beresp.status >= 500) {\n return (abandon);\n }\n\n # Do not cache errors from the backend\n if (beresp.status >= 400)\n {\n set beresp.uncacheable = true;\n set beresp.ttl = 0s;\n\n return (deliver);\n }\n\n # Allow stale content, in case the backend goes down. Make Varnish keep all objects for 6 hours beyond their TTL\n set beresp.grace = 6h;\n\n # Set ban-lurker friendly custom headers\n set beresp.http.X-Varnish-Url = bereq.url;\n set beresp.http.X-Varnish-Host = bereq.http.host;\n\n return (deliver);\n}\n\n# Called when the backend returns an error\nsub vcl_backend_error\n{\n if (beresp.status == 503 && bereq.retries < 5)\n {\n set beresp.http.X-Varnish-Retries = bereq.retries;\n return(retry);\n }\n\n return(deliver);\n}\n\n# Called before a cached object is delivered to the client.\nsub vcl_deliver\n{\n # Send the Cookie header again if a temporay header was stored\n if (req.http.X-Varnish-Cookie) {\n set resp.http.Set-Cookie = req.http.X-Varnish-Cookie;\n }\n\n # Add extra headers if debugging is enabled\n if (resp.http.x-varnish-debug && server.ip ~ localhost)\n {\n set resp.http.X-Served-By = server.hostname;\n\n if (resp.http.x-varnish ~ \" \") {\n set resp.http.X-Varnish-Status = \"HIT\";\n } else {\n set resp.http.X-Varnish-Status = \"MISS\";\n }\n\n # Please note that obj.hits behaviour changed in 4.0, now it counts per objecthead, not per object\n # and obj.hits may not be reset in some cases where bans are in use. See bug 1492 for details.\n # So take hits with a grain of salt\n set resp.http.X-Varnish-Hits = obj.hits;\n }\n else\n {\n # Remove ban-lurker friendly custom headers when delivering to client\n unset resp.http.X-Url;\n unset resp.http.X-Host;\n\n # Remove some headers: PHP version\n unset resp.http.X-Powered-By;\n\n # Remove some headers: Apache version & OS\n unset resp.http.Server;\n unset resp.http.Via;\n unset resp.http.Link;\n unset resp.http.X-Varnish;\n unset resp.http.X-Varnish-Tag;\n unset resp.http.X-Varnish-Debug;\n unset resp.http.X-Varnish-Host;\n unset resp.http.X-Varnish-Url;\n unset resp.http.X-Varnish-Retries;\n unset resp.http.X-Varnish-Cookie;\n unset resp.http.Surrogate-Control;\n }\n\n return (deliver);\n}\n\nsub vcl_purge\n{\n # Only handle actual PURGE HTTP methods, everything else is discarded\n if (req.method != \"PURGE\" && server.ip ~ localhost)\n {\n set req.http.X-Varnish-Purge = \"Yes\";\n return (restart);\n }\n}\n\nsub vcl_synth\n{\n if (resp.status == 720)\n {\n # We use this special error status 720 to force redirects with 301 (permanent) redirects\n # To use this, call the following from anywhere in vcl_recv: return (synth(720, \"http:\/\/host\/new.html\"));\n set resp.http.Location = resp.reason;\n set resp.status = 301;\n\n return (deliver);\n }\n elseif (resp.status == 721)\n {\n # And we use error status 721 to force redirects with a 302 (temporary) redirect\n # To use this, call the following from anywhere in vcl_recv: return (synth(720, \"http:\/\/host\/new.html\"));\n\n set resp.http.Location = resp.reason;\n set resp.status = 302;\n\n return (deliver);\n }\n\n return (deliver);\n}\n\n# Called when VCL is discarded only after all requests have exited the VCL. Typically used to clean up VMODs.\nsub vcl_fini\n{\n return (ok);\n}\n","returncode":0,"stderr":"","license":"mpl-2.0","lang":"VCL"} {"commit":"51677c58a53c683edafe78e3f45aa16a341977db","subject":"added bb10 device","message":"added bb10 device\n\nbb10 has a different UA from the other BBs, so it's not correctly classified and is interpreted as the default \"pc\"","repos":"kevinquinnyo\/varnish-devicedetect,kevinquinnyo\/varnish-devicedetect,wikp\/varnish-devicedetect,varnish\/varnish-devicedetect,wikp\/varnish-devicedetect,varnish\/varnish-devicedetect","old_file":"devicedetect.vcl","new_file":"devicedetect.vcl","new_contents":"# Copyright (c) 2012-2013 Varnish Software AS\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions\n# are met:\n# 1. Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n# 2. Redistributions in binary form must reproduce the above copyright\n# notice, this list of conditions and the following disclaimer in the\n# documentation and\/or other materials provided with the distribution.\n#\n# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n# ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n# SUCH DAMAGE.\n#\n# detectdevice.vcl - regex based device detection for Varnish\n# http:\/\/github.com\/varnish\/varnish-devicedetect\/\n#\n# Author: Lasse Karstensen <lasse@varnish-software.com>\n\nsub devicedetect {\n\tunset req.http.X-UA-Device;\n\tset req.http.X-UA-Device = \"pc\";\n\n\t# Handle that a cookie may override the detection alltogether.\n\tif (req.http.Cookie ~ \"(?i)X-UA-Device-force\") {\n\t\t\/* ;?? means zero or one ;, non-greedy to match the first. *\/\n\t\tset req.http.X-UA-Device = regsub(req.http.Cookie, \"(?i).*X-UA-Device-force=([^;]+);??.*\", \"\\1\");\n\t\t\/* Clean up our mess in the cookie header *\/\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|; ) *X-UA-Device-force=[^;]+;? *\", \"\\1\");\n\t\t\/* If the cookie header is now empty, or just whitespace, unset it. *\/\n\t\tif (req.http.Cookie ~ \"^ *$\") { unset req.http.Cookie; }\n\t} else {\n\t\tif (req.http.User-Agent ~ \"(?i)(ads|google|bing|msn|yandex|baidu|ro|career|)bot\" ||\n\t\t req.http.User-Agent ~ \"(?i)(baidu|jike|symantec)spider\" ||\n\t\t req.http.User-Agent ~ \"(?i)scanner\" ||\n\t\t req.http.User-Agent ~ \"(?i)(web)crawler\") {\n\t\t\tset req.http.X-UA-Device = \"bot\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ipad\") { set req.http.X-UA-Device = \"tablet-ipad\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ip(hone|od)\") { set req.http.X-UA-Device = \"mobile-iphone\"; }\n\t\t\/* how do we differ between an android phone and an android tablet?\n\t\t http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent *\/\n\t\telsif (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") { set req.http.X-UA-Device = \"mobile-android\"; }\n\t\t\/\/ android 3\/honeycomb was just about tablet-only, and any phones will probably handle a bigger page layout.\n\t\telsif (req.http.User-Agent ~ \"(?i)android 3\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\t\/\/ May very well give false positives towards android tablets. Suggestions welcome.\n\t\telsif (req.http.User-Agent ~ \"(?i)android\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\telsif (req.http.User-Agent ~ \"Mobile.+Firefox\") { set req.http.X-UA-Device = \"mobile-firefoxos\"; }\n\t\telsif (req.http.User-Agent ~ \"^HTC\" ||\n\t\t req.http.User-Agent ~ \"Fennec\" ||\n\t\t req.http.User-Agent ~ \"IEMobile\" ||\n\t\t req.http.User-Agent ~ \"BlackBerry\" ||\n\t\t req.http.User-Agent ~ \"BB10.*Mobile\" ||\n\t\t req.http.User-Agent ~ \"SymbianOS.*AppleWebKit\" ||\n\t\t req.http.User-Agent ~ \"Opera Mobi\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-smartphone\";\n\t\t}\n\t\telsif (req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)^sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)^nokia\" ||\n\t\t req.http.User-Agent ~ \"(?i)^samsung\" ||\n\t\t req.http.User-Agent ~ \"(?i)^lg\" ||\n\t\t req.http.User-Agent ~ \"(?i)bada\" ||\n\t\t req.http.User-Agent ~ \"(?i)blazer\" ||\n\t\t req.http.User-Agent ~ \"(?i)cellphone\" ||\n\t\t req.http.User-Agent ~ \"(?i)iemobile\" ||\n\t\t req.http.User-Agent ~ \"(?i)midp-2.0\" ||\n\t\t req.http.User-Agent ~ \"(?i)u990\" ||\n\t\t req.http.User-Agent ~ \"(?i)netfront\" ||\n\t\t req.http.User-Agent ~ \"(?i)opera mini\" ||\n\t\t req.http.User-Agent ~ \"(?i)palm\" ||\n\t\t req.http.User-Agent ~ \"(?i)nintendo wii\" ||\n\t\t req.http.User-Agent ~ \"(?i)playstation portable\" ||\n\t\t req.http.User-Agent ~ \"(?i)portalmmm\" ||\n\t\t req.http.User-Agent ~ \"(?i)proxinet\" ||\n\t\t req.http.User-Agent ~ \"(?i)sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)windows\\ ?ce\" ||\n\t\t req.http.User-Agent ~ \"(?i)winwap\" ||\n\t\t req.http.User-Agent ~ \"(?i)eudoraweb\" ||\n\t\t req.http.User-Agent ~ \"(?i)htc\" ||\n\t\t req.http.User-Agent ~ \"(?i)240x320\" ||\n\t\t req.http.User-Agent ~ \"(?i)avantgo\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-generic\";\n\t\t}\n\t}\n}\n","old_contents":"# Copyright (c) 2012-2013 Varnish Software AS\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions\n# are met:\n# 1. Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n# 2. Redistributions in binary form must reproduce the above copyright\n# notice, this list of conditions and the following disclaimer in the\n# documentation and\/or other materials provided with the distribution.\n#\n# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n# ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n# SUCH DAMAGE.\n#\n# detectdevice.vcl - regex based device detection for Varnish\n# http:\/\/github.com\/varnish\/varnish-devicedetect\/\n#\n# Author: Lasse Karstensen <lasse@varnish-software.com>\n\nsub devicedetect {\n\tunset req.http.X-UA-Device;\n\tset req.http.X-UA-Device = \"pc\";\n\n\t# Handle that a cookie may override the detection alltogether.\n\tif (req.http.Cookie ~ \"(?i)X-UA-Device-force\") {\n\t\t\/* ;?? means zero or one ;, non-greedy to match the first. *\/\n\t\tset req.http.X-UA-Device = regsub(req.http.Cookie, \"(?i).*X-UA-Device-force=([^;]+);??.*\", \"\\1\");\n\t\t\/* Clean up our mess in the cookie header *\/\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|; ) *X-UA-Device-force=[^;]+;? *\", \"\\1\");\n\t\t\/* If the cookie header is now empty, or just whitespace, unset it. *\/\n\t\tif (req.http.Cookie ~ \"^ *$\") { unset req.http.Cookie; }\n\t} else {\n\t\tif (req.http.User-Agent ~ \"(?i)(ads|google|bing|msn|yandex|baidu|ro|career|)bot\" ||\n\t\t req.http.User-Agent ~ \"(?i)(baidu|jike|symantec)spider\" ||\n\t\t req.http.User-Agent ~ \"(?i)scanner\" ||\n\t\t req.http.User-Agent ~ \"(?i)(web)crawler\") {\n\t\t\tset req.http.X-UA-Device = \"bot\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ipad\") { set req.http.X-UA-Device = \"tablet-ipad\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ip(hone|od)\") { set req.http.X-UA-Device = \"mobile-iphone\"; }\n\t\t\/* how do we differ between an android phone and an android tablet?\n\t\t http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent *\/\n\t\telsif (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") { set req.http.X-UA-Device = \"mobile-android\"; }\n\t\t\/\/ android 3\/honeycomb was just about tablet-only, and any phones will probably handle a bigger page layout.\n\t\telsif (req.http.User-Agent ~ \"(?i)android 3\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\t\/\/ May very well give false positives towards android tablets. Suggestions welcome.\n\t\telsif (req.http.User-Agent ~ \"(?i)android\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\telsif (req.http.User-Agent ~ \"Mobile.+Firefox\") { set req.http.X-UA-Device = \"mobile-firefoxos\"; }\n\t\telsif (req.http.User-Agent ~ \"^HTC\" ||\n\t\t req.http.User-Agent ~ \"Fennec\" ||\n\t\t req.http.User-Agent ~ \"IEMobile\" ||\n\t\t req.http.User-Agent ~ \"BlackBerry\" ||\n\t\t req.http.User-Agent ~ \"SymbianOS.*AppleWebKit\" ||\n\t\t req.http.User-Agent ~ \"Opera Mobi\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-smartphone\";\n\t\t}\n\t\telsif (req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)^sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)^nokia\" ||\n\t\t req.http.User-Agent ~ \"(?i)^samsung\" ||\n\t\t req.http.User-Agent ~ \"(?i)^lg\" ||\n\t\t req.http.User-Agent ~ \"(?i)bada\" ||\n\t\t req.http.User-Agent ~ \"(?i)blazer\" ||\n\t\t req.http.User-Agent ~ \"(?i)cellphone\" ||\n\t\t req.http.User-Agent ~ \"(?i)iemobile\" ||\n\t\t req.http.User-Agent ~ \"(?i)midp-2.0\" ||\n\t\t req.http.User-Agent ~ \"(?i)u990\" ||\n\t\t req.http.User-Agent ~ \"(?i)netfront\" ||\n\t\t req.http.User-Agent ~ \"(?i)opera mini\" ||\n\t\t req.http.User-Agent ~ \"(?i)palm\" ||\n\t\t req.http.User-Agent ~ \"(?i)nintendo wii\" ||\n\t\t req.http.User-Agent ~ \"(?i)playstation portable\" ||\n\t\t req.http.User-Agent ~ \"(?i)portalmmm\" ||\n\t\t req.http.User-Agent ~ \"(?i)proxinet\" ||\n\t\t req.http.User-Agent ~ \"(?i)sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)windows\\ ?ce\" ||\n\t\t req.http.User-Agent ~ \"(?i)winwap\" ||\n\t\t req.http.User-Agent ~ \"(?i)eudoraweb\" ||\n\t\t req.http.User-Agent ~ \"(?i)htc\" ||\n\t\t req.http.User-Agent ~ \"(?i)240x320\" ||\n\t\t req.http.User-Agent ~ \"(?i)avantgo\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-generic\";\n\t\t}\n\t}\n}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"782ed193573075cdbbeaec584c1eecfaffa31177","subject":"Match varnish config to production env","message":"Match varnish config to production env\n","repos":"hasadna\/alaveteli,hasadna\/alaveteli,hasadna\/alaveteli,hasadna\/alaveteli,hasadna\/alaveteli,hasadna\/alaveteli","old_file":"config\/varnish-alaveteli.vcl","new_file":"config\/varnish-alaveteli.vcl","new_contents":"# This is a sample VCL configuration file for varnish running in front\n# of Alaveteli. See the vcl(7) man page for details on VCL syntax and\n# semantics.\n\n# \n# Default backend definition. Set this to point to your content\n# server. In this case, apache + Passenger running on port 80\n# \n\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n .connect_timeout = 600s;\n .first_byte_timeout = 600s;\n .between_bytes_timeout = 600s;\n}\n\n\/\/ set the servers alaveteli can issue a purge from\nacl purge {\n \"localhost\";\n \"127.0.0.1\";\n}\n\nsub vcl_recv {\n\n # Handle IPv6\n if (req.http.Host ~ \"^ipv6.*\") {\n set req.http.host = regsub(req.http.host, \"^ipv6\\.(.*)\",\"www\\.\\1\");\n }\n\n\n # Sanitise X-Forwarded-For...\n remove req.http.X-Forwarded-For;\n set req.http.X-Forwarded-For = client.ip;\n \n # Remove Google Analytics, has_js, and last-seen cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"(^|;\\s*)(__[a-z]+|has_js|has_seen_country_message|seen_foi2)=[^;]*\", \"\");\n\n # Normalize the Accept-Encoding header\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|flv|pdf|ico)$\") {\n # No point in compressing these\n remove req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n # unknown algorithm\n remove req.http.Accept-Encoding;\n }\n }\n \n # Ignore empty cookies\n if (req.http.Cookie ~ \"^\\s*$\") {\n remove req.http.Cookie;\n }\n \n if (req.request != \"GET\" &&\n req.request != \"HEAD\" && \n req.request != \"POST\" &&\n req.request != \"PUT\" &&\n req.request != \"PURGE\" &&\n req.request != \"DELETE\" ) {\n # We don't allow any other methods.\n error 405 \"Method Not Allowed\";\n }\n\n if (req.request != \"GET\" && req.request != \"HEAD\" && req.request != \"PURGE\") {\n \/* We only deal with GET and HEAD by default, the rest get passed direct to backend *\/\n return (pass);\n }\n \n # Ignore Cookies on images...\n if (req.url ~ \"\\.(png|gif|jpg|jpeg|swf|css|js|rdf|ico|txt)(\\?.*|)$\") {\n remove req.http.Cookie;\n return (lookup);\n }\n\n if (req.http.Authorization || req.http.Cookie) {\n return (pass);\n }\n # Let's have a little grace\n set req.grace = 30s;\n # Handle PURGE requests\n if (req.request == \"PURGE\") {\n if (!client.ip ~ purge) {\n error 405 \"Not allowed.\";\n }\n\n # For an explanation of the followng roundabout way of defining\n # ban lists, see\n # http:\/\/kristianlyng.wordpress.com\/2010\/07\/28\/smart-bans-with-varnish\/\n\n # XXX in Varnish 2.x, the following would be\n # purge(\"obj.http.x-url ~ \" req.url);\n ban(\"obj.http.x-url ~ \" + req.url);\n error 200 \"Banned\";\n }\n return (lookup);\n}\n\nsub vcl_fetch {\n set beresp.http.x-url = req.url;\n if (req.url ~ \"\\.(png|gif|jpg|jpeg|swf|css|js|rdf|ico|txt)(\\?.*|)$\") {\n # Ignore backend headers..\n remove beresp.http.set-Cookie;\n set beresp.ttl = 3600s;\n return (deliver);\n }\n\n if (beresp.status == 404 || beresp.status == 301 || beresp.status == 500) {\n set beresp.ttl = 1m;\n return (deliver);\n }\n}\n\n# We need to separately cache requests originating via http and via https\n# since we are serving very slightly different content in each case\n\n# Varnish 2.x version of vcl_hash\n#sub vcl_hash {\n# set req.hash += req.url;\n# if (req.http.host) {\n# set req.hash += req.http.host;\n# } else {\n# set req.hash += server.ip;\n# }\n#\n# # Include the X-Forward-Proto header, since we want to treat HTTPS\n# # requests differently, and make sure this header is always passed\n# # properly to the backend server.\n# if (req.http.X-Forwarded-Proto) {\n# set req.hash += req.http.X-Forwarded-Proto;\n# }\n#\n# return (hash);\n#}\n\n# Varnish 3 version of vcl_hash\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n\n # Include the X-Forward-Proto header, since we want to treat HTTPS\n # requests differently, and make sure this header is always passed\n # properly to the backend server.\n if (req.http.X-Forwarded-Proto) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n\n return (hash);\n}\n","old_contents":"# This is a sample VCL configuration file for varnish running in front\n# of Alaveteli. See the vcl(7) man page for details on VCL syntax and\n# semantics.\n\n# \n# Default backend definition. Set this to point to your content\n# server. In this case, apache + Passenger running on port 80\n# \n\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"80\";\n .connect_timeout = 600s;\n .first_byte_timeout = 600s;\n .between_bytes_timeout = 600s;\n}\n\n\/\/ set the servers alaveteli can issue a purge from\nacl purge {\n \"localhost\";\n \"127.0.0.1\";\n}\n\nsub vcl_recv {\n\n # Handle IPv6\n if (req.http.Host ~ \"^ipv6.*\") {\n set req.http.host = regsub(req.http.host, \"^ipv6\\.(.*)\",\"www\\.\\1\");\n }\n\n\n # Sanitise X-Forwarded-For...\n remove req.http.X-Forwarded-For;\n set req.http.X-Forwarded-For = client.ip;\n \n # Remove Google Analytics, has_js, and last-seen cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"(^|;\\s*)(__[a-z]+|has_js|has_seen_country_message|seen_foi2)=[^;]*\", \"\");\n\n # Normalize the Accept-Encoding header\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|flv|pdf|ico)$\") {\n # No point in compressing these\n remove req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n # unknown algorithm\n remove req.http.Accept-Encoding;\n }\n }\n \n # Ignore empty cookies\n if (req.http.Cookie ~ \"^\\s*$\") {\n remove req.http.Cookie;\n }\n \n if (req.request != \"GET\" &&\n req.request != \"HEAD\" && \n req.request != \"POST\" &&\n req.request != \"PUT\" &&\n req.request != \"PURGE\" &&\n req.request != \"DELETE\" ) {\n # We don't allow any other methods.\n error 405 \"Method Not Allowed\";\n }\n\n if (req.request != \"GET\" && req.request != \"HEAD\" && req.request != \"PURGE\") {\n \/* We only deal with GET and HEAD by default, the rest get passed direct to backend *\/\n return (pass);\n }\n \n # Ignore Cookies on images...\n if (req.url ~ \"\\.(png|gif|jpg|jpeg|swf|css|js|rdf|ico|txt)(\\?.*|)$\") {\n remove req.http.Cookie;\n return (lookup);\n }\n\n if (req.http.Authorization || req.http.Cookie) {\n return (pass);\n }\n # Let's have a little grace\n set req.grace = 30s;\n # Handle PURGE requests\n if (req.request == \"PURGE\") {\n if (!client.ip ~ purge) {\n error 405 \"Not allowed.\";\n }\n\n # For an explanation of the followng roundabout way of defining\n # ban lists, see\n # http:\/\/kristianlyng.wordpress.com\/2010\/07\/28\/smart-bans-with-varnish\/\n\n # XXX in Varnish 2.x, the following would be\n # purge(\"obj.http.x-url ~ \" req.url);\n ban(\"obj.http.x-url ~ \" + req.url);\n error 200 \"Banned\";\n }\n return (lookup);\n}\n\nsub vcl_fetch {\n set beresp.http.x-url = req.url;\n if (req.url ~ \"\\.(png|gif|jpg|jpeg|swf|css|js|rdf|ico|txt)(\\?.*|)$\") {\n # Ignore backend headers..\n remove beresp.http.set-Cookie;\n set beresp.ttl = 3600s;\n return (deliver);\n }\n\n if (beresp.status == 404 || beresp.status == 301 || beresp.status == 500) {\n set beresp.ttl = 1m;\n return (deliver);\n }\n}\n\n# We need to separately cache requests originating via http and via https\n# since we are serving very slightly different content in each case\n\n# Varnish 2.x version of vcl_hash\n#sub vcl_hash {\n# set req.hash += req.url;\n# if (req.http.host) {\n# set req.hash += req.http.host;\n# } else {\n# set req.hash += server.ip;\n# }\n#\n# # Include the X-Forward-Proto header, since we want to treat HTTPS\n# # requests differently, and make sure this header is always passed\n# # properly to the backend server.\n# if (req.http.X-Forwarded-Proto) {\n# set req.hash += req.http.X-Forwarded-Proto;\n# }\n#\n# return (hash);\n#}\n\n# Varnish 3 version of vcl_hash\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n\n # Include the X-Forward-Proto header, since we want to treat HTTPS\n # requests differently, and make sure this header is always passed\n # properly to the backend server.\n if (req.http.X-Forwarded-Proto) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n\n return (hash);\n}\n","returncode":0,"stderr":"","license":"agpl-3.0","lang":"VCL"} {"commit":"6ab02c4f500d5770eb54dc86405c819f9cd3ca38","subject":" In order to be able to quickly determine whether user has uploaded custom VCL to their config add a response flag.","message":" In order to be able to quickly determine whether user has uploaded custom\n VCL to their config add a response flag.\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/fastly.vcl","new_file":"etc\/fastly.vcl","new_contents":"###############################################################################\n#\n# Fastly CDN for Magento 2\n#\n# NOTICE OF LICENSE\n#\n# This source file is subject to the Fastly CDN for Magento 2 End User License\n# Agreement that is bundled with this package in the file LICENSE_FASTLY_CDN.txt.\n#\n# @copyright Copyright (c) 2016 Fastly, Inc. (http:\/\/www.fastly.com)\n# @license BSD, see LICENSE_FASTLY_CDN.txt\n#\n###############################################################################\n\n# This is a basic VCL configuration file for Fastly CDN for Magento 2 module.\n\nsub vcl_recv {\n#FASTLY recv\n\n if (req.url ~ \"^\/static\/version(\\d*\/)?(.*)$\") {\n set req.url = \"\/static\/\" + re.group.2 + \"?\" + re.group.1;\n } \n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n set req.http.X-Sig = regsub(req.http.X-Purge-Token, \"^[^_]+_(.*)\", \"\\1\");\n set req.http.X-Exp = regsub(req.http.X-Purge-Token, \"^([^_]+)_.*\", \"\\1\");\n\n # validate signature\n if (req.http.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path req.http.X-Exp), \"^0x\", \"\")) {\n\n # use vcl time math to check expiration timestamp\n set req.http.X-Original-Grace = req.grace;\n set req.grace = std.atoi(strftime({\"%s\"}, now));\n set req.grace -= std.atoi(req.http.X-Exp);\n\n if (std.atoi(req.grace) > 0) {\n error 410;\n }\n\n # clean up grace since we used it for time math\n set req.grace = std.atoi(req.http.X-Original-Grace);\n unset req.http.X-Original-Grace;\n\n } else {\n error 403;\n }\n\n # cleanup variables\n unset req.http.X-Purge-Token;\n unset req.http.X-Sig;\n unset req.http.X-Exp;\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n # disable ESI processing on Origin Shield\n if (req.http.Fastly-FF) {\n set req.esi = false;\n }\n\n # We only deal with GET and HEAD by default\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n return (pass);\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n return (lookup);\n }\n\n # Bypass shopping cart and checkout requests\n if (req.url ~ \"\/checkout\") {\n return (pass);\n }\n\n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie ~ \"(X-Magento-Vary|form_key)=\") {\n error 200 \"\";\n } else {\n # append parameter with country code\n set req.url = req.url \"?country_code=\" geoip.country_code;\n }\n }\n\n return(lookup);\n}\n\nsub vcl_fetch {\n\n # Remove Set-Cookies from responses for static content\n # to match the cookie removal in recv.\n if (req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n }\n\n }\n\n#FASTLY fetch\n\n if (beresp.status >= 500) {\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n }\n\n if (req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Content-Type ~ \"text\/html\" || beresp.http.Content-Type ~ \"text\/xml\") {\n # enable ESI feature for Magento response by default\n esi;\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content\n if ((beresp.status == 200 || beresp.status == 404) && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url ~ \"\\.(css|js|html|eot|ico|otf|ttf|json)($|\\?)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # cache only successfully responses and 404s\n if (beresp.status != 200 && beresp.status != 301 && beresp.status != 404) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\")) {\n unset beresp.http.set-cookie;\n if (req.url !~ \"^\/(pub\/)?(media|static)\/.*\") {\n set beresp.http.Pragma = \"no-cache\";\n set beresp.http.Expires = \"-1\";\n set beresp.http.Cache-Control = \"no-store, no-cache, must-revalidate, max-age=0\";\n set beresp.grace = 1m;\n }\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type\n if (beresp.http.Content-Type ~ \"image\") {\n set beresp.http.Surrogate-Key = \"image\";\n } elsif (beresp.http.Content-Type ~ \"script\") {\n set beresp.http.Surrogate-Key = \"script\";\n } elsif (beresp.http.Content-Type ~ \"css\") {\n set beresp.http.Surrogate-Key = \"css\";\n }\n\n set beresp.http.X-Surrogate-Key = beresp.http.Surrogate-Key;\n return (deliver);\n }\n\n return (deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\n\nsub vcl_miss {\n # Deactivate gzip on origin\n unset bereq.http.Accept-Encoding;\n\n#FASTLY miss\n\n return(fetch);\n}\n\nsub vcl_deliver {\n\n # Add an easy way to see whether custom Fastly VCL has been uploaded\n if ( req.http.Fastly-Debug ) {\n set resp.http.X-Fastly-Magento-VCL-Uploaded = \"yes\";\n }\n # debug info\n if (resp.http.X-Magento-Debug) {\n if (obj.hits > 0) {\n set resp.http.X-Magento-Cache-Debug = \"HIT\";\n set resp.http.X-Magento-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Magento-Cache-Debug = \"MISS\";\n }\n } else {\n # remove Varnish\/proxy header\n remove resp.http.Age;\n remove resp.http.X-Magento-Debug;\n remove resp.http.X-Magento-Tags;\n remove resp.http.X-Surrogate-Key;\n remove resp.http.X-Magento-Cache-Control;\n remove resp.http.X-Powered-By;\n remove resp.http.Server;\n remove resp.http.X-Varnish;\n remove resp.http.Via;\n remove resp.http.Link;\n remove resp.http.X-Purge-URL;\n remove resp.http.X-Purge-Host;\n }\n\n#FASTLY deliver\n\n return (deliver);\n}\n\n\nsub vcl_error {\n # workaround for possible security issue\n if (req.url ~ \"^\\s\") {\n set obj.status = 400;\n set obj.response = \"Malformed request\";\n synthetic \"\";\n return (deliver);\n }\n\n # error 200\n if (obj.status == 200) {\n return (deliver);\n }\n\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} obj.status \" \" obj.response {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} obj.status \" \" obj.response {\"<\/h1>\n <p>\"} obj.response {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} req.xid {\"<\/p>\n <hr>\n <p>Fastly CDN server<\/p>\n <\/body>\n<\/html>\n\"};\n\n#FASTLY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n\nsub vcl_hash {\n set req.hash += req.http.Https;\n set req.hash += req.http.host;\n set req.hash += req.url;\n\n if (req.http.cookie:X-Magento-Vary ) {\n set req.hash += req.http.cookie:X-Magento-Vary;\n }\n \n set req.hash += \"#####GENERATION#####\";\n\n ### {{ design_exceptions_code }} ###\n\n return (hash);\n}\n\n","old_contents":"###############################################################################\n#\n# Fastly CDN for Magento 2\n#\n# NOTICE OF LICENSE\n#\n# This source file is subject to the Fastly CDN for Magento 2 End User License\n# Agreement that is bundled with this package in the file LICENSE_FASTLY_CDN.txt.\n#\n# @copyright Copyright (c) 2016 Fastly, Inc. (http:\/\/www.fastly.com)\n# @license BSD, see LICENSE_FASTLY_CDN.txt\n#\n###############################################################################\n\n# This is a basic VCL configuration file for Fastly CDN for Magento 2 module.\n\nsub vcl_recv {\n#FASTLY recv\n\n if (req.url ~ \"^\/static\/version(\\d*\/)?(.*)$\") {\n set req.url = \"\/static\/\" + re.group.2 + \"?\" + re.group.1;\n } \n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n set req.http.X-Sig = regsub(req.http.X-Purge-Token, \"^[^_]+_(.*)\", \"\\1\");\n set req.http.X-Exp = regsub(req.http.X-Purge-Token, \"^([^_]+)_.*\", \"\\1\");\n\n # validate signature\n if (req.http.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path req.http.X-Exp), \"^0x\", \"\")) {\n\n # use vcl time math to check expiration timestamp\n set req.http.X-Original-Grace = req.grace;\n set req.grace = std.atoi(strftime({\"%s\"}, now));\n set req.grace -= std.atoi(req.http.X-Exp);\n\n if (std.atoi(req.grace) > 0) {\n error 410;\n }\n\n # clean up grace since we used it for time math\n set req.grace = std.atoi(req.http.X-Original-Grace);\n unset req.http.X-Original-Grace;\n\n } else {\n error 403;\n }\n\n # cleanup variables\n unset req.http.X-Purge-Token;\n unset req.http.X-Sig;\n unset req.http.X-Exp;\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n # disable ESI processing on Origin Shield\n if (req.http.Fastly-FF) {\n set req.esi = false;\n }\n\n # We only deal with GET and HEAD by default\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n return (pass);\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n return (lookup);\n }\n\n # Bypass shopping cart and checkout requests\n if (req.url ~ \"\/checkout\") {\n return (pass);\n }\n\n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie ~ \"(X-Magento-Vary|form_key)=\") {\n error 200 \"\";\n } else {\n # append parameter with country code\n set req.url = req.url \"?country_code=\" geoip.country_code;\n }\n }\n\n return(lookup);\n}\n\nsub vcl_fetch {\n\n # Remove Set-Cookies from responses for static content\n # to match the cookie removal in recv.\n if (req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n }\n\n }\n\n#FASTLY fetch\n\n if (beresp.status >= 500) {\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n }\n\n if (req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Content-Type ~ \"text\/html\" || beresp.http.Content-Type ~ \"text\/xml\") {\n # enable ESI feature for Magento response by default\n esi;\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content\n if ((beresp.status == 200 || beresp.status == 404) && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url ~ \"\\.(css|js|html|eot|ico|otf|ttf|json)($|\\?)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # cache only successfully responses and 404s\n if (beresp.status != 200 && beresp.status != 301 && beresp.status != 404) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\")) {\n unset beresp.http.set-cookie;\n if (req.url !~ \"^\/(pub\/)?(media|static)\/.*\") {\n set beresp.http.Pragma = \"no-cache\";\n set beresp.http.Expires = \"-1\";\n set beresp.http.Cache-Control = \"no-store, no-cache, must-revalidate, max-age=0\";\n set beresp.grace = 1m;\n }\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type\n if (beresp.http.Content-Type ~ \"image\") {\n set beresp.http.Surrogate-Key = \"image\";\n } elsif (beresp.http.Content-Type ~ \"script\") {\n set beresp.http.Surrogate-Key = \"script\";\n } elsif (beresp.http.Content-Type ~ \"css\") {\n set beresp.http.Surrogate-Key = \"css\";\n }\n\n set beresp.http.X-Surrogate-Key = beresp.http.Surrogate-Key;\n return (deliver);\n }\n\n return (deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\n\nsub vcl_miss {\n # Deactivate gzip on origin\n unset bereq.http.Accept-Encoding;\n\n#FASTLY miss\n\n return(fetch);\n}\n\nsub vcl_deliver {\n # debug info\n if (resp.http.X-Magento-Debug) {\n if (obj.hits > 0) {\n set resp.http.X-Magento-Cache-Debug = \"HIT\";\n set resp.http.X-Magento-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Magento-Cache-Debug = \"MISS\";\n }\n } else {\n # remove Varnish\/proxy header\n remove resp.http.Age;\n remove resp.http.X-Magento-Debug;\n remove resp.http.X-Magento-Tags;\n remove resp.http.X-Surrogate-Key;\n remove resp.http.X-Magento-Cache-Control;\n remove resp.http.X-Powered-By;\n remove resp.http.Server;\n remove resp.http.X-Varnish;\n remove resp.http.Via;\n remove resp.http.Link;\n remove resp.http.X-Purge-URL;\n remove resp.http.X-Purge-Host;\n }\n\n#FASTLY deliver\n\n return (deliver);\n}\n\n\nsub vcl_error {\n # workaround for possible security issue\n if (req.url ~ \"^\\s\") {\n set obj.status = 400;\n set obj.response = \"Malformed request\";\n synthetic \"\";\n return (deliver);\n }\n\n # error 200\n if (obj.status == 200) {\n return (deliver);\n }\n\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} obj.status \" \" obj.response {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} obj.status \" \" obj.response {\"<\/h1>\n <p>\"} obj.response {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} req.xid {\"<\/p>\n <hr>\n <p>Fastly CDN server<\/p>\n <\/body>\n<\/html>\n\"};\n\n#FASTLY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n\nsub vcl_hash {\n set req.hash += req.http.Https;\n set req.hash += req.http.host;\n set req.hash += req.url;\n\n if (req.http.cookie:X-Magento-Vary ) {\n set req.hash += req.http.cookie:X-Magento-Vary;\n }\n \n set req.hash += \"#####GENERATION#####\";\n\n ### {{ design_exceptions_code }} ###\n\n return (hash);\n}\n\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"f8e6fa4992a8dfc78838da67a07194ecc97ddc64","subject":"Fixed capture group index. Derp.","message":"Fixed capture group index. Derp.\n","repos":"killerwails\/ansible-varnish,killerwails\/ansible-varnish,gotofbi\/ansible-varnish,gotofbi\/ansible-varnish,kkwoker\/ansible-varnish,colstrom\/ansible-varnish,noqcks\/ansible-varnish,telusdigital\/ansible-varnish","old_file":"templates\/etc\/varnish\/default.vcl","new_file":"templates\/etc\/varnish\/default.vcl","new_contents":"vcl 4.0;\n\nimport directors;\nimport std;\n\n###\n# Varnish Documentation\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-built-in-subs.html\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/reference\/vcl.html\n##\n\n{% for backend in varnish_backend_hosts %}\nbackend application_{{ loop.index }} {\n .host = \"{{ backend }}\";\n .port = \"{{ varnish_backend_port }}\";\n{% if varnish_health_checks_enabled %}\n .probe = {\n .url = \"{{ varnish_health_check_url }}\";\n .interval = {{ varnish_health_check_interval }};\n .timeout = {{ varnish_health_check_timeout }};\n .window = {{ varnish_health_check_window }};\n .threshold = {{ varnish_health_check_threshold }};\n }\n{% endif %}\n}\n{% endfor %}\n\n###\n# vcl_init\n# Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n###\n# The vcl_init subroutine may terminate with calling return() with one of the following keywords:\n#\n# ok\n# Normal return, VCL continues loading.\n##\n\nsub vcl_init {\n new application = directors.round_robin();\n{% for backend in varnish_backend_hosts %}\n application.add_backend(application_{{ loop.index }});\n{% endfor %}\n}\n\n###\n# vcl_recv\n# Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use. \n# It is also used to modify the request\n###\n# The vcl_recv subroutine may terminate with calling return() on one of the following keywords:\n#\n# synth(status code, reason)\n# Return a synthetic object with the specified status code to the client and abandon the request.\n# pass\n# Switch to pass mode. Control will eventually pass to vcl_pass.\n# pipe\n# Switch to pipe mode. Control will eventually pass to vcl_pipe.\n# hash\n# Continue processing the object as a potential candidate for caching. Passes the control over to vcl_hash.\n# purge\n# Purge the object and it's variants. Control passes through vcl_hash to vcl_purge.\n#\n\nsub vcl_recv {\n set req.backend_hint = application.backend();\n\n ###\n # Avoid processing uncacheable requests\n ###\n\n if (req.http.Authorization) {\n return (pass);\n }\n\n ###\n # Inject X-Forwarded-For headers, but only once.\n ###\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n{% if varnish_header_sanitization_enabled %}\n ###\n # Header Sanitization\n ###\n\n{% if varnish_discards_port_from_host_header %}\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n{% endif %}\n\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_enabled %}\n ###\n # Cookie Sanitization\n ###\n\n ### Google Analytics\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n\n ### Quantcast\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n \n ### AddThis\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n\n ### General Cleanup\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n{% endif %}\n\n{% if varnish_uri_sanitization_enabled %}\n ###\n # URI Sanitization\n ###\n \n if (req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=\") {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n{% endif %}\n\n{% if varnish_workaround_telusdotcom_browser_profile %}\n ###\n # Workaround for BrowserProfile and Language\/Region Detection on TELUS.com\n ###\n\n if (req.http.Cookie ~ \"BrowserProfile\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.Cookie, \"(.*)language..:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n set req.http.X-Province = std.tolower(regsuball(regsuball(req.http.Cookie, \"geo\\\\.\\:{(.*)\\}\", \"\"), \"(.*)region..:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n } else {\n if (req.http.Cookie ~ \"lang=\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.Cookie, \"(.*)lang=([^;]*)(.*)\", \"\\2\"));\n } else {\n set req.http.X-Language = \"en\";\n }\n\n if (req.http.Cookie ~ \"prov=\") {\n set req.http.X-Province = std.tolower(regsuball(req.http.Cookie, \"(.*)prov=([^;]*)(.*)\", \"\\2\"));\n } else {\n set req.http.X-Province = \"BC\";\n }\n }\n\n if (req.url ~ \"\/(en|fr)\/\") {\n if (req.url ~ \"\/en\/\" && req.http.X-Language != \"en\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Language)\";\n return(pass);\n }\n if (req.url ~ \"\/fr\/\" && req.http.X-Language != \"fr\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Language)\";\n return(pass);\n }\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Language)\";\n return(pass);\n }\n\n if (req.url ~ \"\/(ab|bc|mb|nb|nl|ns|nt|nu|on|pe|qc|sk|yt)\/\") {\n {% for province in ['ab', 'bc', 'mb', 'nb', 'nl', 'ns', 'nt', 'nu', 'on', 'pe', 'qc', 'sk', 'yt'] %}\n if (req.url ~ \"\/{{ province }}\/\" && req.http.X-Province != \"{{ province }}\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Province)\";\n return(pass);\n }\n {% endfor %}\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Province)\";\n return(pass);\n }\n{% endif %}\n\n{% if varnish_blacklist_enabled %}\n if ((req.url ~ \"{{ varnish_blacklist_regexp }}\")) {\n set req.http.X-Passthrough-Reason = \"Path in Blacklist\";\n return(pass);\n } else {\n{% if varnish_discards_client_cookies %}\n unset req.http.Cookie;\n{% endif %}\n }\n{% endif %}\n\n}\n\n###\n# vcl_hit\n# Called when a cache lookup is successful.\n###\n# The vcl_hit subroutine may terminate with calling return() with one of the following keywords:\n#\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n# deliver\n# Deliver the object. Control passes to vcl_deliver.\n# synth(status code, reason)\n# Return the specified status code to the client and abandon the request.\n###\n\nsub vcl_hit {\n if (obj.ttl > 0s) {\n return (deliver);\n }\n{% if varnish_health_checks_enabled %}\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (fetch);\n }\n{% else %}\n if (obj.ttl + obj.grace > 0s) {\n return (deliver);\n }\n\n return (fetch);\n{% endif %}\n}\n\n###\n# vcl_backend_response\n# Called after the response headers has been successfully retrieved from the backend.\n###\n# The vcl_backend_response subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Possibly insert the object into the cache, then deliver it to the Control will eventually pass to vcl_deliver.\n# abandon\n# Abandon the backend request and generates an error.\n# retry\n# Retry the backend transaction. Increases the retries counter. If the number of retries is higher than max_retries Varnish emits a guru meditation error.\n###\n\nsub vcl_backend_response {\n{% if varnish_workaround_telusdotcom_browser_profile %}\n if (bereq.http.X-Language) {\n set beresp.http.X-Language = bereq.http.X-Language;\n }\n if (bereq.http.X-Province) {\n set beresp.http.X-Province = bereq.http.X-Province;\n }\n{% endif %}\n\n{% if varnish_blacklist_enabled %}\n if (bereq.url ~ \"{{ varnish_blacklist_regexp }}\") {\n set beresp.http.X-Cacheable = \"NO:Path in Blacklist\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n if (bereq.http.X-Passthrough-Reason) {\n set beresp.http.X-Passthrough-Reason = bereq.http.X-Passthrough-Reason;\n return(deliver);\n } else {\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n }\n }\n{% else %}\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n{% endif %}\n\n{% if varnish_cache_diagnostics_enabled %}\n if (bereq.http.Cookie) {\n set beresp.http.X-Cacheable = \"NO:Cookie in Request\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO:Set-Cookie in Response\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.X-No-Cache) {\n set beresp.http.X-Cacheable = \"NO:X-No-Cache\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.ttl <= 0s) {\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n{% endif %}\n\n set beresp.grace = {{ varnish_grace_period }};\n}\n\n###\n# vcl_deliver\n# Called before a cached object is delivered to the client.\n###\n# The vcl_deliver subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Deliver the object to the client.\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n###\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n","old_contents":"vcl 4.0;\n\nimport directors;\nimport std;\n\n###\n# Varnish Documentation\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-built-in-subs.html\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/reference\/vcl.html\n##\n\n{% for backend in varnish_backend_hosts %}\nbackend application_{{ loop.index }} {\n .host = \"{{ backend }}\";\n .port = \"{{ varnish_backend_port }}\";\n{% if varnish_health_checks_enabled %}\n .probe = {\n .url = \"{{ varnish_health_check_url }}\";\n .interval = {{ varnish_health_check_interval }};\n .timeout = {{ varnish_health_check_timeout }};\n .window = {{ varnish_health_check_window }};\n .threshold = {{ varnish_health_check_threshold }};\n }\n{% endif %}\n}\n{% endfor %}\n\n###\n# vcl_init\n# Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n###\n# The vcl_init subroutine may terminate with calling return() with one of the following keywords:\n#\n# ok\n# Normal return, VCL continues loading.\n##\n\nsub vcl_init {\n new application = directors.round_robin();\n{% for backend in varnish_backend_hosts %}\n application.add_backend(application_{{ loop.index }});\n{% endfor %}\n}\n\n###\n# vcl_recv\n# Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use. \n# It is also used to modify the request\n###\n# The vcl_recv subroutine may terminate with calling return() on one of the following keywords:\n#\n# synth(status code, reason)\n# Return a synthetic object with the specified status code to the client and abandon the request.\n# pass\n# Switch to pass mode. Control will eventually pass to vcl_pass.\n# pipe\n# Switch to pipe mode. Control will eventually pass to vcl_pipe.\n# hash\n# Continue processing the object as a potential candidate for caching. Passes the control over to vcl_hash.\n# purge\n# Purge the object and it's variants. Control passes through vcl_hash to vcl_purge.\n#\n\nsub vcl_recv {\n set req.backend_hint = application.backend();\n\n ###\n # Avoid processing uncacheable requests\n ###\n\n if (req.http.Authorization) {\n return (pass);\n }\n\n ###\n # Inject X-Forwarded-For headers, but only once.\n ###\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n{% if varnish_header_sanitization_enabled %}\n ###\n # Header Sanitization\n ###\n\n{% if varnish_discards_port_from_host_header %}\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n{% endif %}\n\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_enabled %}\n ###\n # Cookie Sanitization\n ###\n\n ### Google Analytics\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n\n ### Quantcast\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n \n ### AddThis\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n\n ### General Cleanup\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n{% endif %}\n\n{% if varnish_uri_sanitization_enabled %}\n ###\n # URI Sanitization\n ###\n \n if (req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=\") {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n{% endif %}\n\n{% if varnish_workaround_telusdotcom_browser_profile %}\n ###\n # Workaround for BrowserProfile and Language\/Region Detection on TELUS.com\n ###\n\n if (req.http.Cookie ~ \"BrowserProfile\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.Cookie, \"(.*)language..:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n set req.http.X-Province = std.tolower(regsuball(regsuball(req.http.Cookie, \"geo\\\\.\\:{(.*)\\}\", \"\"), \"(.*)region..:\\\\.([^\\\\]*)(.*)\", \"\\3\"));\n } else {\n if (req.http.Cookie ~ \"lang=\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.Cookie, \"(.*)lang=([^;]*)(.*)\", \"\\2\"));\n } else {\n set req.http.X-Language = \"en\";\n }\n\n if (req.http.Cookie ~ \"prov=\") {\n set req.http.X-Province = std.tolower(regsuball(req.http.Cookie, \"(.*)prov=([^;]*)(.*)\", \"\\2\"));\n } else {\n set req.http.X-Province = \"BC\";\n }\n }\n\n if (req.url ~ \"\/(en|fr)\/\") {\n if (req.url ~ \"\/en\/\" && req.http.X-Language != \"en\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Language)\";\n return(pass);\n }\n if (req.url ~ \"\/fr\/\" && req.http.X-Language != \"fr\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Language)\";\n return(pass);\n }\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Language)\";\n return(pass);\n }\n\n if (req.url ~ \"\/(ab|bc|mb|nb|nl|ns|nt|nu|on|pe|qc|sk|yt)\/\") {\n {% for province in ['ab', 'bc', 'mb', 'nb', 'nl', 'ns', 'nt', 'nu', 'on', 'pe', 'qc', 'sk', 'yt'] %}\n if (req.url ~ \"\/{{ province }}\/\" && req.http.X-Province != \"{{ province }}\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Province)\";\n return(pass);\n }\n {% endfor %}\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Province)\";\n return(pass);\n }\n{% endif %}\n\n{% if varnish_blacklist_enabled %}\n if ((req.url ~ \"{{ varnish_blacklist_regexp }}\")) {\n set req.http.X-Passthrough-Reason = \"Path in Blacklist\";\n return(pass);\n } else {\n{% if varnish_discards_client_cookies %}\n unset req.http.Cookie;\n{% endif %}\n }\n{% endif %}\n\n}\n\n###\n# vcl_hit\n# Called when a cache lookup is successful.\n###\n# The vcl_hit subroutine may terminate with calling return() with one of the following keywords:\n#\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n# deliver\n# Deliver the object. Control passes to vcl_deliver.\n# synth(status code, reason)\n# Return the specified status code to the client and abandon the request.\n###\n\nsub vcl_hit {\n if (obj.ttl > 0s) {\n return (deliver);\n }\n{% if varnish_health_checks_enabled %}\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (fetch);\n }\n{% else %}\n if (obj.ttl + obj.grace > 0s) {\n return (deliver);\n }\n\n return (fetch);\n{% endif %}\n}\n\n###\n# vcl_backend_response\n# Called after the response headers has been successfully retrieved from the backend.\n###\n# The vcl_backend_response subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Possibly insert the object into the cache, then deliver it to the Control will eventually pass to vcl_deliver.\n# abandon\n# Abandon the backend request and generates an error.\n# retry\n# Retry the backend transaction. Increases the retries counter. If the number of retries is higher than max_retries Varnish emits a guru meditation error.\n###\n\nsub vcl_backend_response {\n{% if varnish_workaround_telusdotcom_browser_profile %}\n if (bereq.http.X-Language) {\n set beresp.http.X-Language = bereq.http.X-Language;\n }\n if (bereq.http.X-Province) {\n set beresp.http.X-Province = bereq.http.X-Province;\n }\n{% endif %}\n\n{% if varnish_blacklist_enabled %}\n if (bereq.url ~ \"{{ varnish_blacklist_regexp }}\") {\n set beresp.http.X-Cacheable = \"NO:Path in Blacklist\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n if (bereq.http.X-Passthrough-Reason) {\n set beresp.http.X-Passthrough-Reason = bereq.http.X-Passthrough-Reason;\n return(deliver);\n } else {\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n }\n }\n{% else %}\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n{% endif %}\n\n{% if varnish_cache_diagnostics_enabled %}\n if (bereq.http.Cookie) {\n set beresp.http.X-Cacheable = \"NO:Cookie in Request\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO:Set-Cookie in Response\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.X-No-Cache) {\n set beresp.http.X-Cacheable = \"NO:X-No-Cache\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.ttl <= 0s) {\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n{% endif %}\n\n set beresp.grace = {{ varnish_grace_period }};\n}\n\n###\n# vcl_deliver\n# Called before a cached object is delivered to the client.\n###\n# The vcl_deliver subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Deliver the object to the client.\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n###\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"43db6e6719d8d09e907ecff8513bac597ac69224","subject":"#65: Configure port for health probe, fix typo and remove unused rules","message":"#65: Configure port for health probe, fix typo and remove unused rules\n","repos":"nooku\/nooku-platform,nooku\/nooku-platform,nooku\/nooku-platform,nooku\/nooku-platform,nooku\/nooku-platform","old_file":"component\/varnish\/resources\/varnish\/kodekit.vcl","new_file":"component\/varnish\/resources\/varnish\/kodekit.vcl","new_contents":"vcl 4.0;\n# Based on: https:\/\/github.com\/mattiasgeniar\/varnish-4.0-configuration-templates\/blob\/master\/default.vcl\n\nimport std;\nimport directors;\n\nprobe health\n{\n #.url = \"\/varnish-enabled\";\n # We prefer to only do a HEAD \/\n .request =\n \"HEAD \/ HTTP\/1.1\"\n \"Host: localhost:%1$s\"\n \"Connection: close\"\n \"User-Agent: Varnish Health Probe\";\n .interval = 5s; # check the health of each backend every 5 seconds\n .timeout = 1s; # timing out after 1 second.\n # If 3 out of the last 5 polls succeeded the backend is considered healthy, otherwise it will be marked as sick\n .window = 5;\n .threshold = 3;\n .expected_response = 200;\n}\n\nbackend default\n{\n .host = \"127.0.0.1\"; # IP or Hostname of backend\n .port = \"%1$s\"; # Port Apache or whatever is listening\n .max_connections = 300; # That's it\n .probe = health;\n .connect_timeout = 600s; # How long to wait before we receive a first byte from our backend?\n .first_byte_timeout = 600s; # How long to wait for a backend connection?\n .between_bytes_timeout = 600s; # How long to wait between bytes received from our backend?\n}\n\nbackend passthrough\n{\n .host = \"127.0.0.1\"; # IP or Hostname of backend\n .port = \"%1$s\"; # Port Apache or whatever is listening\n}\n\nacl localhost\n{\n \"localhost\";\n \"33.33.33.63\";\n \"::1\";\n}\n\nsub vcl_init\n{\n # Called when VCL is loaded, before any requests pass through it.\n # Typically used to initialize VMODs.\n\n new vdir = directors.round_robin();\n vdir.add_backend(default);\n # vdir.add_backend(server...);\n # vdir.add_backend(servern);\n}\n\nsub vcl_recv\n{\n # Called at the beginning of a request, after the complete request has been received and parsed.\n # Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable,\n # which backend to use and if needed to modify the request.\n\n # Send all traffic to the vdir director\n set req.backend_hint = vdir.backend();\n\n # Normalize the header, remove the port (in case you're testing this on various TCP ports)\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n # Normalize the query arguments\n set req.url = std.querysort(req.url);\n\n # Allow purging\n if (req.method == \"PURGE\")\n {\n # purge is the ACL defined at the begining\n if (!client.ip ~ localhost) {\n return (synth(405, \"This IP is not allowed to send PURGE requests.\"));\n }\n\n # If you got this stage (and didn't error out above), purge the cached result\n return (purge);\n }\n\n # Check if we've still enabled Varnish, if not, passthrough every request\n if (! std.healthy(req.backend_hint))\n {\n set req.backend_hint = passthrough;\n return (pass);\n }\n\n # Only deal with \"normal\" types\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"PATCH\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n # Implementing websocket support (https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html)\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n # Only cache GET or HEAD requests. This makes sure the POST requests are always passed.\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n # Specific Kodekit Platform rules\n\n # Do not cache \/administrator\n if(req.url ~ \"^\/administrator\") {\n return (pass);\n }\n\n # Generic URL manipulation, useful for all templates that follow\n\n # Remove the Google Analytics added parameters, useless for our backend\n if (req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=\") {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # Strip hash, server doesn't need it.\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n # Strip a trailing ? if it exists\n if (req.url ~ \"\\?$\") {\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # Cookie manipulation\n\n # Remove the \"has_js\" cookie\n set req.http.Cookie = regsuball(req.http.Cookie, \"has_js=[^;]+(; )?\", \"\");\n\n # Remove any Google Analytics based cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__utm.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"_ga=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"_gat=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmctr=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmcmd.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmccn.=[^;]+(; )?\", \"\");\n\n # Remove DoubleClick offensive cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__gads=[^;]+(; )?\", \"\");\n\n # Remove the Quant Capital cookies (added by some plugin, all __qca)\n set req.http.Cookie = regsuball(req.http.Cookie, \"__qc.=[^;]+(; )?\", \"\");\n\n # Remove the AddThis cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__atuv.=[^;]+(; )?\", \"\");\n\n # Remove a \";\" prefix in the cookie if present\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n\n # Remove the csrf_token cookie\n set req.http.Cookie = regsuball(req.http.Cookie, \"csrf_token=[^;]+(; )?\", \"\");\n\n # Are there cookies left with only spaces or that are empty?\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n\n # Large static files are delivered directly to the end-user without waiting for Varnish to fully read the file first.\n # Varnish 4 supports Streaming, so set do_stream in vcl_backend_response()\n if (req.url ~ \"^[^?]*\\.(7z|avi|bz2|flac|flv|gz|mka|mkv|mov|mp3|mp4|mpeg|mpg|ogg|ogm|opus|rar|tar|tgz|tbz|txz|wav|webm|xz|zip)(\\?.*)?$\") {\n unset req.http.Cookie;\n return (hash);\n }\n\n # Remove all cookies for static files\n # Before you blindly enable this read: https:\/\/ma.ttias.be\/stop-caching-static-files\/\n #if (req.method == \"GET\")\n #{\n # # Cache files with these extensions and remove cookie\n # if (req.url ~ \"^[^?]*\\.(7z|avi|bmp|bz2|css|csv|doc|docx|eot|flac|flv|gif|gz|ico|jpeg|jpg|js|less|mka|mkv|mov|mp3|mp4|mpeg|mpg|odt|otf|ogg|ogm|opus|pdf|png|ppt|pptx|rar|rtf|svg|svgz|swf|tar|tbz|tgz|ttf|txt|txz|wav|webm|webp|woff|woff2|xls|xlsx|xml|xz|zip)(\\?.*)?$\") {\n # unset req.http.Cookie;\n # return (hash);\n # }\n #}\n\n if (req.http.Cache-Control ~ \"(?i)no-cache\" && client.ip ~ localhost)\n {\n # http:\/\/varnish.projects.linpro.no\/wiki\/VCLExampleEnableForceRefresh\n # Ignore requests via proxy caches and badly behaved crawlers\n # like msnbot that send no-cache with every request.\n if (! (req.http.Via || req.http.User-Agent ~ \"(?i)bot\" || req.http.X-Purge))\n {\n # Doesn't seems to refresh the object in the cache\n set req.hash_always_miss = true;\n\n # Couple this with restart in vcl_purge and X-Purge header to avoid loops\n return(purge);\n }\n }\n\n # Send Surrogate-Capability headers to announce ESI support to backend\n set req.http.Surrogate-Capability = \"varnish=ESI\/1.0\";\n\n # Requests that require authorization are not cacheable by default\n if (req.http.Authorization) {\n return (pass);\n }\n\n # We do not support SPDY or HTTP\/2.0\n if (req.method == \"PRI\") {\n return (synth(405));\n }\n\n return (hash);\n}\n\n# Called upon entering pipe mode. In this mode, the request is passed on to the backend, and any further data from both\n# the client and backend is passed on unaltered until either end closes the connection. Basically, Varnish will degrade\n# into a simple TCP proxy, shuffling bytes back and forth. For a connection in pipe mode, no other VCL subroutine will\n# ever get called after vcl_pipe.\nsub vcl_pipe\n{\n # Note that only the first request to the backend will have X-Forwarded-For set.\n # If you use X-Forwarded-For and want to have it set for all requests, make sure to have:\n # set bereq.http.connection = \"close\";\n # It is not set by default as it might break some broken web applications, like IIS with NTLM authentication.\n # set bereq.http.Connection = \"Close\";\n\n # Implementing websocket support (https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html)\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n\n return (pipe);\n}\n\n# Called upon entering pass mode. In this mode, the request is passed on to the backend, and the backend's response\n# is passed on to the client, but is not entered into the cache. Subsequent requests submitted over the same client\n# connection are handled normally.\nsub vcl_pass\n{\n return (fetch);\n}\n\n# Called after vcl_recv to create a hash value for the request. This is used as a key to look up the object in Varnish.\nsub vcl_hash\n{\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n\n # hash cookies for requests that have them\n if (req.http.Cookie) {\n hash_data(req.http.Cookie);\n }\n}\n\n# Called when a cache lookup is successful.\nsub vcl_hit\n{\n # A pure unadultered hit, deliver it\n if (obj.ttl >= 0s) {\n return (deliver);\n }\n\n # https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-grace.html\n # When several clients are requesting the same page Varnish will send one request to the backend and place the\n # others on hold while fetching one copy from the backend. In some products this is called request coalescing and\n # Varnish does this automatically.\n\n # If you are serving thousands of hits per second the queue of waiting requests can get huge. There are two\n # potential problems - one is a thundering herd problem - suddenly releasing a thousand threads to serve content\n # might send the load sky high. Secondly - nobody likes to wait. To deal with this we can instruct Varnish to keep\n # the objects in cache beyond their TTL and to serve the waiting requests somewhat stale content.\n\n # if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n # return (deliver);\n # } else {\n # return (fetch);\n # }\n\n # We have no fresh fish. Lets look at the stale ones.\n if (std.healthy(req.backend_hint))\n {\n # Backend is healthy. Limit age to 10s.\n if (obj.ttl + 10s > 0s)\n {\n #set req.http.grace = \"normal(limited)\";\n return (deliver);\n }\n else\n {\n # No candidate for grace. Fetch a fresh object.\n return(fetch);\n }\n }\n else\n {\n # backend is sick - use full grace\n if (obj.ttl + obj.grace > 0s)\n {\n #set req.http.grace = \"full\";\n return (deliver);\n }\n else\n {\n # no graced object.\n return (fetch);\n }\n }\n\n # fetch & deliver once we get the result\n return (fetch); # Dead code, keep as a safeguard\n}\n\n# Called after a cache lookup if the requested document was not found in the cache. Its purpose is to decide whether\n# or not to attempt to retrieve the document from the backend, and which backend to use.\nsub vcl_miss\n{\n return (fetch);\n}\n\n # Called after the response headers has been successfully retrieved from the backend.\nsub vcl_backend_response\n{\n # Enable ESI handling\n if (beresp.http.Surrogate-Control ~ \"ESI\/1.0\" ) {\n set beresp.do_esi = true;\n }\n\n # Store the csrf_token cookie temporarily if the response is cacheabale\n if (beresp.http.Set-Cookie && !beresp.uncacheable)\n {\n set beresp.http.X-Varnish-Cookie = beresp.http.Set-Cookie;\n unset beresp.http.Set-Cookie;\n }\n\n # Cache handling all static files\n if (bereq.method == \"GET\")\n {\n # Before you blindly enable this, read: https:\/\/ma.ttias.be\/stop-caching-static-files\/\n #if (bereq.url ~ \"^[^?]*\\.(7z|avi|bmp|bz2|css|csv|doc|docx|eot|flac|flv|gif|gz|ico|jpeg|jpg|js|less|mka|mkv|mov|mp3|mp4|mpeg|mpg|odt|otf|ogg|ogm|opus|pdf|png|ppt|pptx|rar|rtf|svg|svgz|swf|tar|tbz|tgz|ttf|txt|txz|wav|webm|webp|woff|woff2|xls|xlsx|xml|xz|zip)(\\?.*)?$\") {\n # unset beresp.http.Set-Cookie;\n #}\n\n # Large static files are delivered directly to the end-user without waiting for Varnish to fully read the\n # file first. Check memory usage it'll grow in fetch_chunksize blocks (128k by default) if the backend\n # doesn't send a Content-Length header. Only enable it for large files\n if (bereq.url ~ \"^[^?]*\\.(7z|avi|bz2|flac|flv|gz|mka|mkv|mov|mp3|mp4|mpeg|mpg|ogg|ogm|opus|rar|tar|tgz|tbz|txz|wav|webm|xz|zip)(\\?.*)?$\")\n {\n unset beresp.http.Set-Cookie;\n\n # Use streaming to avoid locking\n set beresp.do_stream = true;\n\n # Don't try to compress it for storage\n set beresp.do_gzip = false;\n\n # Disable Transfer-encoding chunked when serving HTML5 video\n # See : http:\/\/stackoverflow.com\/questions\/23643233\/how-do-i-disable-transfer-encoding-chunked-encoding-in-varnish\n # See : https:\/\/www.varnish-cache.org\/trac\/ticket\/1506\n if(beresp.http.Content-Type ~ \"video\") {\n set beresp.do_stream = true;\n set beresp.do_esi = true;\n }\n }\n\n # Set 2min cache if unset for static files\n if (beresp.ttl <= 0s || beresp.http.Set-Cookie || beresp.http.Vary == \"*\")\n {\n set beresp.ttl = 120s; # Important, you shouldn't rely on this, SET YOUR HEADERS in the backend\n set beresp.uncacheable = true;\n\n return (deliver);\n }\n }\n\n # Sometimes, a 301 or 302 redirect formed via Apache's mod_rewrite can mess with the HTTP port that is being passed along.\n # This often happens with simple rewrite rules in a scenario where Varnish runs on :80 and Apache on :8080 on the same box.\n # A redirect can then often redirect the end-user to a URL on :8080, where it should be :80.\n # This may need finetuning on your setup.\n #\n # To prevent accidental replace, we only filter the 301\/302 redirects for now.\n if (beresp.status == 301 || beresp.status == 302) {\n set beresp.http.Location = regsub(beresp.http.Location, \":[0-9]+\", \"\");\n }\n\n # Never cache 50x responses\n if (beresp.status >= 500) {\n return (abandon);\n }\n\n # Do not cache errors from the backend\n if (beresp.status >= 400)\n {\n set beresp.uncacheable = true;\n set beresp.ttl = 0s;\n\n return (deliver);\n }\n\n # Allow stale content, in case the backend goes down. Make Varnish keep all objects for 6 hours beyond their TTL\n set beresp.grace = 6h;\n\n # Set ban-lurker friendly custom headers\n set beresp.http.X-Varnish-Url = bereq.url;\n set beresp.http.X-Varnish-Host = bereq.http.host;\n\n return (deliver);\n}\n\n# Called when the backend returns an error\nsub vcl_backend_error\n{\n if (beresp.status == 503 && bereq.retries < 5)\n {\n set beresp.http.X-Varnish-Retries = bereq.retries;\n return(retry);\n }\n\n return(deliver);\n}\n\n# Called before a cached object is delivered to the client.\nsub vcl_deliver\n{\n # Send the Cookie header again if a temporay header was stored\n if (req.http.X-Varnish-Cookie) {\n set resp.http.Set-Cookie = req.http.X-Varnish-Cookie;\n }\n\n # Add extra headers if debugging is enabled\n if (resp.http.x-varnish-debug && server.ip ~ localhost)\n {\n set resp.http.X-Served-By = server.hostname;\n\n if (resp.http.x-varnish ~ \" \") {\n set resp.http.X-Varnish-Status = \"HIT\";\n } else {\n set resp.http.X-Varnish-Status = \"MISS\";\n }\n\n # Please note that obj.hits behaviour changed in 4.0, now it counts per objecthead, not per object\n # and obj.hits may not be reset in some cases where bans are in use. See bug 1492 for details.\n # So take hits with a grain of salt\n set resp.http.X-Varnish-Hits = obj.hits;\n }\n else\n {\n # Remove ban-lurker friendly custom headers when delivering to client\n unset resp.http.X-Url;\n unset resp.http.X-Host;\n\n # Remove some headers: PHP version\n unset resp.http.X-Powered-By;\n\n # Remove some headers: Apache version & OS\n unset resp.http.Server;\n unset resp.http.Via;\n unset resp.http.Link;\n unset resp.http.X-Varnish;\n unset resp.http.X-Varnish-Tag;\n unset resp.http.X-Varnish-Debug;\n unset resp.http.X-Varnish-Host;\n unset resp.http.X-Varnish-Url;\n unset resp.http.X-Varnish-Retries;\n unset resp.http.X-Varnish-Cookie;\n unset resp.http.Surrogate-Control;\n }\n\n return (deliver);\n}\n\nsub vcl_purge\n{\n # Only handle actual PURGE HTTP methods, everything else is discarded\n if (req.method != \"PURGE\" && server.ip ~ localhost)\n {\n set req.http.X-Varnish-Purge = \"Yes\";\n return (restart);\n }\n}\n\nsub vcl_synth\n{\n if (resp.status == 720)\n {\n # We use this special error status 720 to force redirects with 301 (permanent) redirects\n # To use this, call the following from anywhere in vcl_recv: return (synth(720, \"http:\/\/host\/new.html\"));\n set resp.http.Location = resp.reason;\n set resp.status = 301;\n\n return (deliver);\n }\n elseif (resp.status == 721)\n {\n # And we use error status 721 to force redirects with a 302 (temporary) redirect\n # To use this, call the following from anywhere in vcl_recv: return (synth(720, \"http:\/\/host\/new.html\"));\n\n set resp.http.Location = resp.reason;\n set resp.status = 302;\n\n return (deliver);\n }\n\n return (deliver);\n}\n\n# Called when VCL is discarded only after all requests have exited the VCL. Typically used to clean up VMODs.\nsub vcl_fini\n{\n return (ok);\n}\n","old_contents":"vcl 4.0;\n# Based on: https:\/\/github.com\/mattiasgeniar\/varnish-4.0-configuration-templates\/blob\/master\/default.vcl\n\nimport std;\nimport directors;\n\nprobe health\n{\n #.url = \"\/varnish-enabled\";\n # We prefer to only do a HEAD \/\n .request =\n \"HEAD \/varnish-enabled HTTP\/1.1\"\n \"Host: localhost\"\n \"Connection: close\";\n \"User-Agent: Varnish Health Probe\";\n .interval = 5s; # check the health of each backend every 5 seconds\n .timeout = 1s; # timing out after 1 second.\n # If 3 out of the last 5 polls succeeded the backend is considered healthy, otherwise it will be marked as sick\n .window = 5;\n .threshold = 3;\n .expected_response = 200;\n}\n\nbackend default\n{\n .host = \"127.0.0.1\"; # IP or Hostname of backend\n .port = \"%1$s\"; # Port Apache or whatever is listening\n .max_connections = 300; # That's it\n .probe = health;\n .connect_timeout = 600s; # How long to wait before we receive a first byte from our backend?\n .first_byte_timeout = 600s; # How long to wait for a backend connection?\n .between_bytes_timeout = 600s; # How long to wait between bytes received from our backend?\n}\n\nbackend passthrough\n{\n .host = \"127.0.0.1\"; # IP or Hostname of backend\n .port = \"%1$s\"; # Port Apache or whatever is listening\n}\n\nacl localhost\n{\n \"localhost\";\n \"33.33.33.63\";\n \"::1\";\n}\n\nsub vcl_init\n{\n # Called when VCL is loaded, before any requests pass through it.\n # Typically used to initialize VMODs.\n\n new vdir = directors.round_robin();\n vdir.add_backend(default);\n # vdir.add_backend(server...);\n # vdir.add_backend(servern);\n}\n\nsub vcl_recv\n{\n # Called at the beginning of a request, after the complete request has been received and parsed.\n # Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable,\n # which backend to use and if needed to modify the request.\n\n # Send all traffic to the vdir director\n set req.backend_hint = vdir.backend();\n\n # Normalize the header, remove the port (in case you're testing this on various TCP ports)\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n # Normalize the query arguments\n set req.url = std.querysort(req.url);\n\n # Allow purging\n if (req.method == \"PURGE\")\n {\n # purge is the ACL defined at the begining\n if (!client.ip ~ localhost) {\n return (synth(405, \"This IP is not allowed to send PURGE requests.\"));\n }\n\n # If you got this stage (and didn't error out above), purge the cached result\n return (purge);\n }\n\n # Check if we've still enabled Varnish, if not, passthrough every request\n if (! std.healthy(req.backend_hint))\n {\n set req.backend_hint = passthrough;\n return (pass);\n }\n\n # Only deal with \"normal\" types\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"PATCH\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n # Implementing websocket support (https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html)\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n # Only cache GET or HEAD requests. This makes sure the POST requests are always passed.\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n # Specific Nooku Platform rules\n\n # Do not cache \/administrator\n if(req.url ~ \"^\/administrator\") {\n return (pass);\n }\n\n # Specific Nooku Server rules\n\n # Do not cache webgrind.nooku.dev\n if (req.http.host == \"webgrind.nooku.dev\") {\n return (pass);\n }\n\n # Do not cache phpmyadmin.nooku.dev\n if (req.http.host == \"phpmyadmin.nooku.dev\") {\n return (pass);\n }\n\n # Do not cache \/apc and \/phpinfo\n if (req.url == \"\/apc\" || req.url == \"\/phpinfo\") {\n return (pass);\n }\n\n # Generic URL manipulation, useful for all templates that follow\n\n # Remove the Google Analytics added parameters, useless for our backend\n if (req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=\") {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # Strip hash, server doesn't need it.\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n # Strip a trailing ? if it exists\n if (req.url ~ \"\\?$\") {\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # Cookie manipulation\n\n # Remove the \"has_js\" cookie\n set req.http.Cookie = regsuball(req.http.Cookie, \"has_js=[^;]+(; )?\", \"\");\n\n # Remove any Google Analytics based cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__utm.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"_ga=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"_gat=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmctr=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmcmd.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmccn.=[^;]+(; )?\", \"\");\n\n # Remove DoubleClick offensive cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__gads=[^;]+(; )?\", \"\");\n\n # Remove the Quant Capital cookies (added by some plugin, all __qca)\n set req.http.Cookie = regsuball(req.http.Cookie, \"__qc.=[^;]+(; )?\", \"\");\n\n # Remove the AddThis cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__atuv.=[^;]+(; )?\", \"\");\n\n # Remove a \";\" prefix in the cookie if present\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n\n # Remove the csrf_token cookie\n set req.http.Cookie = regsuball(req.http.Cookie, \"csrf_token=[^;]+(; )?\", \"\");\n\n # Are there cookies left with only spaces or that are empty?\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n\n # Large static files are delivered directly to the end-user without waiting for Varnish to fully read the file first.\n # Varnish 4 supports Streaming, so set do_stream in vcl_backend_response()\n if (req.url ~ \"^[^?]*\\.(7z|avi|bz2|flac|flv|gz|mka|mkv|mov|mp3|mp4|mpeg|mpg|ogg|ogm|opus|rar|tar|tgz|tbz|txz|wav|webm|xz|zip)(\\?.*)?$\") {\n unset req.http.Cookie;\n return (hash);\n }\n\n # Remove all cookies for static files\n # Before you blindly enable this read: https:\/\/ma.ttias.be\/stop-caching-static-files\/\n #if (req.method == \"GET\")\n #{\n # # Cache files with these extensions and remove cookie\n # if (req.url ~ \"^[^?]*\\.(7z|avi|bmp|bz2|css|csv|doc|docx|eot|flac|flv|gif|gz|ico|jpeg|jpg|js|less|mka|mkv|mov|mp3|mp4|mpeg|mpg|odt|otf|ogg|ogm|opus|pdf|png|ppt|pptx|rar|rtf|svg|svgz|swf|tar|tbz|tgz|ttf|txt|txz|wav|webm|webp|woff|woff2|xls|xlsx|xml|xz|zip)(\\?.*)?$\") {\n # unset req.http.Cookie;\n # return (hash);\n # }\n #}\n\n if (req.http.Cache-Control ~ \"(?i)no-cache\" && client.ip ~ localhost)\n {\n # http:\/\/varnish.projects.linpro.no\/wiki\/VCLExampleEnableForceRefresh\n # Ignore requests via proxy caches and badly behaved crawlers\n # like msnbot that send no-cache with every request.\n if (! (req.http.Via || req.http.User-Agent ~ \"(?i)bot\" || req.http.X-Purge))\n {\n # Doesn't seems to refresh the object in the cache\n set req.hash_always_miss = true;\n\n # Couple this with restart in vcl_purge and X-Purge header to avoid loops\n return(purge);\n }\n }\n\n # Send Surrogate-Capability headers to announce ESI support to backend\n set req.http.Surrogate-Capability = \"varnish=ESI\/1.0\";\n\n # Requests that require authorization are not cacheable by default\n if (req.http.Authorization) {\n return (pass);\n }\n\n # We do not support SPDY or HTTP\/2.0\n if (req.method == \"PRI\") {\n return (synth(405));\n }\n\n return (hash);\n}\n\n# Called upon entering pipe mode. In this mode, the request is passed on to the backend, and any further data from both\n# the client and backend is passed on unaltered until either end closes the connection. Basically, Varnish will degrade\n# into a simple TCP proxy, shuffling bytes back and forth. For a connection in pipe mode, no other VCL subroutine will\n# ever get called after vcl_pipe.\nsub vcl_pipe\n{\n # Note that only the first request to the backend will have X-Forwarded-For set.\n # If you use X-Forwarded-For and want to have it set for all requests, make sure to have:\n # set bereq.http.connection = \"close\";\n # It is not set by default as it might break some broken web applications, like IIS with NTLM authentication.\n # set bereq.http.Connection = \"Close\";\n\n # Implementing websocket support (https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html)\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n\n return (pipe);\n}\n\n# Called upon entering pass mode. In this mode, the request is passed on to the backend, and the backend's response\n# is passed on to the client, but is not entered into the cache. Subsequent requests submitted over the same client\n# connection are handled normally.\nsub vcl_pass\n{\n return (fetch);\n}\n\n# Called after vcl_recv to create a hash value for the request. This is used as a key to look up the object in Varnish.\nsub vcl_hash\n{\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n\n # hash cookies for requests that have them\n if (req.http.Cookie) {\n hash_data(req.http.Cookie);\n }\n}\n\n# Called when a cache lookup is successful.\nsub vcl_hit\n{\n # A pure unadultered hit, deliver it\n if (obj.ttl >= 0s) {\n return (deliver);\n }\n\n # https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-grace.html\n # When several clients are requesting the same page Varnish will send one request to the backend and place the\n # others on hold while fetching one copy from the backend. In some products this is called request coalescing and\n # Varnish does this automatically.\n\n # If you are serving thousands of hits per second the queue of waiting requests can get huge. There are two\n # potential problems - one is a thundering herd problem - suddenly releasing a thousand threads to serve content\n # might send the load sky high. Secondly - nobody likes to wait. To deal with this we can instruct Varnish to keep\n # the objects in cache beyond their TTL and to serve the waiting requests somewhat stale content.\n\n # if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n # return (deliver);\n # } else {\n # return (fetch);\n # }\n\n # We have no fresh fish. Lets look at the stale ones.\n if (std.healthy(req.backend_hint))\n {\n # Backend is healthy. Limit age to 10s.\n if (obj.ttl + 10s > 0s)\n {\n #set req.http.grace = \"normal(limited)\";\n return (deliver);\n }\n else\n {\n # No candidate for grace. Fetch a fresh object.\n return(fetch);\n }\n }\n else\n {\n # backend is sick - use full grace\n if (obj.ttl + obj.grace > 0s)\n {\n #set req.http.grace = \"full\";\n return (deliver);\n }\n else\n {\n # no graced object.\n return (fetch);\n }\n }\n\n # fetch & deliver once we get the result\n return (fetch); # Dead code, keep as a safeguard\n}\n\n# Called after a cache lookup if the requested document was not found in the cache. Its purpose is to decide whether\n# or not to attempt to retrieve the document from the backend, and which backend to use.\nsub vcl_miss\n{\n return (fetch);\n}\n\n # Called after the response headers has been successfully retrieved from the backend.\nsub vcl_backend_response\n{\n # Enable ESI handling\n if (beresp.http.Surrogate-Control ~ \"ESI\/1.0\" ) {\n set beresp.do_esi = true;\n }\n\n # Store the csrf_token cookie temporarily if the response is cacheabale\n if (beresp.http.Set-Cookie && !beresp.uncacheable)\n {\n set beresp.http.X-Varnish-Cookie = beresp.http.Set-Cookie;\n unset beresp.http.Set-Cookie;\n }\n\n # Cache handling all static files\n if (bereq.method == \"GET\")\n {\n # Before you blindly enable this, read: https:\/\/ma.ttias.be\/stop-caching-static-files\/\n #if (bereq.url ~ \"^[^?]*\\.(7z|avi|bmp|bz2|css|csv|doc|docx|eot|flac|flv|gif|gz|ico|jpeg|jpg|js|less|mka|mkv|mov|mp3|mp4|mpeg|mpg|odt|otf|ogg|ogm|opus|pdf|png|ppt|pptx|rar|rtf|svg|svgz|swf|tar|tbz|tgz|ttf|txt|txz|wav|webm|webp|woff|woff2|xls|xlsx|xml|xz|zip)(\\?.*)?$\") {\n # unset beresp.http.Set-Cookie;\n #}\n\n # Large static files are delivered directly to the end-user without waiting for Varnish to fully read the\n # file first. Check memory usage it'll grow in fetch_chunksize blocks (128k by default) if the backend\n # doesn't send a Content-Length header. Only enable it for large files\n if (bereq.url ~ \"^[^?]*\\.(7z|avi|bz2|flac|flv|gz|mka|mkv|mov|mp3|mp4|mpeg|mpg|ogg|ogm|opus|rar|tar|tgz|tbz|txz|wav|webm|xz|zip)(\\?.*)?$\") {\n {\n unset beresp.http.Set-Cookie;\n\n # Use streaming to avoid locking\n set beresp.do_stream = true;\n\n # Don't try to compress it for storage\n set beresp.do_gzip = false;\n\n # Disable Transfer-encoding chunked when serving HTML5 video\n # See : http:\/\/stackoverflow.com\/questions\/23643233\/how-do-i-disable-transfer-encoding-chunked-encoding-in-varnish\n # See : https:\/\/www.varnish-cache.org\/trac\/ticket\/1506\n if(beresp.http.Content-Type ~ \"video\") {\n set beresp.do_stream = true;\n set beresp.do_esi = true;\n }\n }\n\n # Set 2min cache if unset for static files\n if (beresp.ttl <= 0s || beresp.http.Set-Cookie || beresp.http.Vary == \"*\")\n {\n set beresp.ttl = 120s; # Important, you shouldn't rely on this, SET YOUR HEADERS in the backend\n set beresp.uncacheable = true;\n\n return (deliver);\n }\n }\n\n # Sometimes, a 301 or 302 redirect formed via Apache's mod_rewrite can mess with the HTTP port that is being passed along.\n # This often happens with simple rewrite rules in a scenario where Varnish runs on :80 and Apache on :8080 on the same box.\n # A redirect can then often redirect the end-user to a URL on :8080, where it should be :80.\n # This may need finetuning on your setup.\n #\n # To prevent accidental replace, we only filter the 301\/302 redirects for now.\n if (beresp.status == 301 || beresp.status == 302) {\n set beresp.http.Location = regsub(beresp.http.Location, \":[0-9]+\", \"\");\n }\n\n # Never cache 50x responses\n if (beresp.status >= 500) {\n return (abandon);\n }\n\n # Do not cache errors from the backend\n if (beresp.status >= 400)\n {\n set beresp.uncacheable = true;\n set beresp.ttl = 0s;\n\n return (deliver);\n }\n\n # Allow stale content, in case the backend goes down. Make Varnish keep all objects for 6 hours beyond their TTL\n set beresp.grace = 6h;\n\n # Set ban-lurker friendly custom headers\n set beresp.http.X-Varnish-Url = bereq.url;\n set beresp.http.X-Varnish-Host = bereq.http.host;\n\n return (deliver);\n}\n\n# Called when the backend returns an error\nsub vcl_backend_error\n{\n if (beresp.status == 503 && bereq.retries < 5)\n {\n set beresp.http.X-Varnish-Retries = bereq.retries;\n return(retry);\n }\n\n return(deliver);\n}\n\n# Called before a cached object is delivered to the client.\nsub vcl_deliver\n{\n # Send the Cookie header again if a temporay header was stored\n if (req.http.X-Varnish-Cookie) {\n set resp.http.Set-Cookie = req.http.X-Varnish-Cookie;\n }\n\n # Add extra headers if debugging is enabled\n if (resp.http.x-varnish-debug && server.ip ~ localhost)\n {\n set resp.http.X-Served-By = server.hostname;\n\n if (resp.http.x-varnish ~ \" \") {\n set resp.http.X-Varnish-Status = \"HIT\";\n } else {\n set resp.http.X-Varnish-Status = \"MISS\";\n }\n\n # Please note that obj.hits behaviour changed in 4.0, now it counts per objecthead, not per object\n # and obj.hits may not be reset in some cases where bans are in use. See bug 1492 for details.\n # So take hits with a grain of salt\n set resp.http.X-Varnish-Hits = obj.hits;\n }\n else\n {\n # Remove ban-lurker friendly custom headers when delivering to client\n unset resp.http.X-Url;\n unset resp.http.X-Host;\n\n # Remove some headers: PHP version\n unset resp.http.X-Powered-By;\n\n # Remove some headers: Apache version & OS\n unset resp.http.Server;\n unset resp.http.Via;\n unset resp.http.Link;\n unset resp.http.X-Varnish;\n unset resp.http.X-Varnish-Tag;\n unset resp.http.X-Varnish-Debug;\n unset resp.http.X-Varnish-Host;\n unset resp.http.X-Varnish-Url;\n unset resp.http.X-Varnish-Retries;\n unset resp.http.X-Varnish-Cookie;\n unset resp.http.Surrogate-Control;\n }\n\n return (deliver);\n}\n\nsub vcl_purge\n{\n # Only handle actual PURGE HTTP methods, everything else is discarded\n if (req.method != \"PURGE\" && server.ip ~ localhost)\n {\n set req.http.X-Varnish-Purge = \"Yes\";\n return (restart);\n }\n}\n\nsub vcl_synth\n{\n if (resp.status == 720)\n {\n # We use this special error status 720 to force redirects with 301 (permanent) redirects\n # To use this, call the following from anywhere in vcl_recv: return (synth(720, \"http:\/\/host\/new.html\"));\n set resp.http.Location = resp.reason;\n set resp.status = 301;\n\n return (deliver);\n }\n elseif (resp.status == 721)\n {\n # And we use error status 721 to force redirects with a 302 (temporary) redirect\n # To use this, call the following from anywhere in vcl_recv: return (synth(720, \"http:\/\/host\/new.html\"));\n\n set resp.http.Location = resp.reason;\n set resp.status = 302;\n\n return (deliver);\n }\n\n return (deliver);\n}\n\n# Called when VCL is discarded only after all requests have exited the VCL. Typically used to clean up VMODs.\nsub vcl_fini\n{\n return (ok);\n}\n","returncode":0,"stderr":"","license":"mpl-2.0","lang":"VCL"} {"commit":"0617523b17306d5cc63d13cfa3cd18a6d9840fec","subject":"Revert \"Skip vulcain headers from varnish request\"","message":"Revert \"Skip vulcain headers from varnish request\"\n","repos":"api-platform\/api-platform,teohhanhui\/api-platform,api-platform\/api-platform,teohhanhui\/api-platform,teohhanhui\/api-platform,teohhanhui\/api-platform,api-platform\/api-platform,api-platform\/api-platform","old_file":"api\/docker\/varnish\/conf\/default.vcl","new_file":"api\/docker\/varnish\/conf\/default.vcl","new_contents":"vcl 4.0;\n\nimport std;\n\nbackend default {\n .host = \"api\";\n .port = \"80\";\n # Health check\n #.probe = {\n # .url = \"\/\";\n # .timeout = 5s;\n # .interval = 10s;\n # .window = 5;\n # .threshold = 3;\n #}\n}\n\n# Hosts allowed to send BAN requests\nacl invalidators {\n \"localhost\";\n \"php\";\n # local Kubernetes network\n \"10.0.0.0\"\/8;\n \"172.16.0.0\"\/12;\n \"192.168.0.0\"\/16;\n}\n\nsub vcl_recv {\n if (req.restarts > 0) {\n set req.hash_always_miss = true;\n }\n\n # Remove the \"Forwarded\" HTTP header if exists (security)\n unset req.http.forwarded;\n\n # To allow API Platform to ban by cache tags\n if (req.method == \"BAN\") {\n if (client.ip !~ invalidators) {\n return (synth(405, \"Not allowed\"));\n }\n\n if (req.http.ApiPlatform-Ban-Regex) {\n ban(\"obj.http.Cache-Tags ~ \" + req.http.ApiPlatform-Ban-Regex);\n\n return (synth(200, \"Ban added\"));\n }\n\n return (synth(400, \"ApiPlatform-Ban-Regex HTTP header must be set.\"));\n }\n\n # For health checks\n if (req.method == \"GET\" && req.url == \"\/healthz\") {\n return (synth(200, \"OK\"));\n }\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n # A pure unadulterated hit, deliver it\n return (deliver);\n }\n\n if (std.healthy(req.backend_hint)) {\n # The backend is healthy\n # Fetch the object from the backend\n return (restart);\n }\n\n # No fresh object and the backend is not healthy\n if (obj.ttl + obj.grace > 0s) {\n # Deliver graced object\n # Automatically triggers a background fetch\n return (deliver);\n }\n\n # No valid object to deliver\n # No healthy backend to handle request\n # Return error\n return (synth(503, \"API is down\"));\n}\n\nsub vcl_deliver {\n # Don't send cache tags related headers to the client\n unset resp.http.url;\n # Comment the following line to send the \"Cache-Tags\" header to the client (e.g. to use CloudFlare cache tags)\n unset resp.http.Cache-Tags;\n}\n\nsub vcl_backend_response {\n # Ban lurker friendly header\n set beresp.http.url = bereq.url;\n\n # Add a grace in case the backend is down\n set beresp.grace = 1h;\n}\n","old_contents":"vcl 4.0;\n\nimport std;\n\nbackend default {\n .host = \"api\";\n .port = \"80\";\n # Health check\n #.probe = {\n # .url = \"\/\";\n # .timeout = 5s;\n # .interval = 10s;\n # .window = 5;\n # .threshold = 3;\n #}\n}\n\n# Hosts allowed to send BAN requests\nacl invalidators {\n \"localhost\";\n \"php\";\n # local Kubernetes network\n \"10.0.0.0\"\/8;\n \"172.16.0.0\"\/12;\n \"192.168.0.0\"\/16;\n}\n\nsub vcl_recv {\n if (req.restarts > 0) {\n set req.hash_always_miss = true;\n }\n\n # Remove the \"Forwarded\" HTTP header if exists (security)\n unset req.http.forwarded;\n # Remove \"Preload\" and \"Fields\" HTTP header to improve Vulcain's performance\n unset req.http.preload;\n unset req.http.fields;\n\n # To allow API Platform to ban by cache tags\n if (req.method == \"BAN\") {\n if (client.ip !~ invalidators) {\n return (synth(405, \"Not allowed\"));\n }\n\n if (req.http.ApiPlatform-Ban-Regex) {\n ban(\"obj.http.Cache-Tags ~ \" + req.http.ApiPlatform-Ban-Regex);\n\n return (synth(200, \"Ban added\"));\n }\n\n return (synth(400, \"ApiPlatform-Ban-Regex HTTP header must be set.\"));\n }\n\n # For health checks\n if (req.method == \"GET\" && req.url == \"\/healthz\") {\n return (synth(200, \"OK\"));\n }\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n # A pure unadulterated hit, deliver it\n return (deliver);\n }\n\n if (std.healthy(req.backend_hint)) {\n # The backend is healthy\n # Fetch the object from the backend\n return (restart);\n }\n\n # No fresh object and the backend is not healthy\n if (obj.ttl + obj.grace > 0s) {\n # Deliver graced object\n # Automatically triggers a background fetch\n return (deliver);\n }\n\n # No valid object to deliver\n # No healthy backend to handle request\n # Return error\n return (synth(503, \"API is down\"));\n}\n\nsub vcl_deliver {\n # Don't send cache tags related headers to the client\n unset resp.http.url;\n # Comment the following line to send the \"Cache-Tags\" header to the client (e.g. to use CloudFlare cache tags)\n unset resp.http.Cache-Tags;\n}\n\nsub vcl_backend_response {\n # Ban lurker friendly header\n set beresp.http.url = bereq.url;\n\n # Add a grace in case the backend is down\n set beresp.grace = 1h;\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"18fe643e6c8a754ce34a24e01a7cfb7ed8db2fd0","subject":"Temporarily cache ttl to 10 seconds","message":"Temporarily cache ttl to 10 seconds\n\nNeed to properly handle ttl for content.\n","repos":"micktwomey\/docker-django-varnish","old_file":"default.vcl","new_file":"default.vcl","new_contents":"vcl 4.0;\nimport std;\n\nbackend default {\n .host = \"::BACKEND_PORT_8000_TCP_ADDR::\";\n .port = \"::BACKEND_PORT_8000_TCP_PORT::\";\n # .probe = {\n # .url = \"\/\";\n # .interval = 5s;\n # .timeout = 1 s;\n # .window = 5;\n # .threshold = 3;\n # }\n}\n\nsub vcl_recv {\n # Ignore all cookies except for \/admin\n if (!(req.url ~ \"^\/admin\/\")) {\n unset req.http.Cookie;\n }\n\n # # Give ourself some restart time\n # set req.backend_hint = default;\n # if (! std.healthy(req.backend)) {\n # set req.grace = 5m;\n # } else {\n # set req.grace = 15s;\n # }\n}\n\nsub vcl_backend_response {\n # Unset any cookies for static content and cache for 1 hour\n if (bereq.url ~ \"^\/static\/\") {\n unset beresp.http.set-cookie;\n set beresp.ttl = 1h;\n }\n else {\n set beresp.ttl = 10s;\n }\n # # Add some grace for backend restarts\n # set beresp.grace = 30m;\n}\n","old_contents":"vcl 4.0;\nimport std;\n\nbackend default {\n .host = \"::BACKEND_PORT_8000_TCP_ADDR::\";\n .port = \"::BACKEND_PORT_8000_TCP_PORT::\";\n # .probe = {\n # .url = \"\/\";\n # .interval = 5s;\n # .timeout = 1 s;\n # .window = 5;\n # .threshold = 3;\n # }\n}\n\nsub vcl_recv {\n # Ignore all cookies except for \/admin\n if (!(req.url ~ \"^\/admin\/\")) {\n unset req.http.Cookie;\n }\n\n # # Give ourself some restart time\n # set req.backend_hint = default;\n # if (! std.healthy(req.backend)) {\n # set req.grace = 5m;\n # } else {\n # set req.grace = 15s;\n # }\n}\n\nsub vcl_backend_response {\n # Unset any cookies for static content and cache for 1 hour\n if (bereq.url ~ \"^\/static\/\") {\n unset beresp.http.set-cookie;\n set beresp.ttl = 1h;\n }\n # # Add some grace for backend restarts\n # set beresp.grace = 30m;\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"b11ec449b0bd0e83074b434da2c2cc7384019de4","subject":"Removed working comments","message":"Removed working comments\n","repos":"3scale\/libvmod-3scale,3scale\/libvmod-3scale","old_file":"vcl\/default_3scale_proxy_oauth.vcl","new_file":"vcl\/default_3scale_proxy_oauth.vcl","new_contents":"# This is a the VCL configuration file for 3scale's varnish plugin.\n# \n# Default backend definition. Set this to point to the 3scale's\n# backend. \n# \n# set the beresp.ttl in vcl_fetch to have a default global TTL\n# you can define custom TTL via regular expressions\n#\n\n## the backend of your API\nbackend backend_api {\n .host = \"YOU API ENDPOINT, for instance api.mydomain.com\"; \n .port = \"80\";\n}\n\n## real 3scale backend\nbackend backend_3scale {\n .host = \"su1.3scale.net\"; \n .port = \"80\";\n}\n\nimport std;\nimport threescale;\n\nsub vcl_recv {\n\n unset req.http.cookie;\n\n if (!req.http.X-3scale-authorization) {\n ## this request was send by the end-user\n ##set req.backend = backend_api;\n\n ## need to generate the string for the 3scale authorization,\n set req.http.X-3scale-auth = \"\/transactions\/oauth_authorize.xml?provider_key=\";\n ## set your 3scale provider_key\n set req.http.X-3scale-auth = req.http.X-3scale-auth + \"CHANGEME: YOUR 3SCALE PROVIDER_KEY\";\n \n ## extract the parameters sent by the user\n set req.http.X-3scale-app_id = regsub(req.url,\".*[&?]app_id.([^&]*).*\",\"\\1\");\n \n set req.http.X-3scale-auth = req.http.X-3scale-auth + \"&app_id=\" + req.http.X-3scale-app_id; \n \n ## set the appropriate usage in a similar way than above, the basic one is...\n set req.http.X-3scale-auth = req.http.X-3scale-auth + \"&usage[hits]=1\";\n ## if you need to add the service_id\n #set req.http.X-3scale-auth = req.http.X-3scale-auth + \"&service_id=SERVICE_ID\";\n \n ## build the request for the report\n set req.http.X-3scale-report = \"provider_key=\" + \"CHANGEME: YOUR 3SCALE PROVIDER_KEY\";\n #set req.http.X-3scale-report = req.http.X-3scale-report + \"&service_id=\";\n #set req.http.X-3scale-report = req.http.X-3scale-report + \"CHANGEME: SERVICE_ID\";\n set req.http.X-3scale-report = req.http.X-3scale-report + \"&transactions[0][app_id]=\";\n set req.http.X-3scale-report = req.http.X-3scale-report + req.http.X-3scale-app_id;\n \n ## set the usage, you can specify the metric that you want\n set req.http.X-3scale-report = req.http.X-3scale-report + \"&transactions[0][usage][hits]=1\";\n ##\u00a0-----\n \n unset req.http.X-3scale-app_id;\n \n set req.http.X-3scale-auth-res = threescale.send_get_request_body(\"localhost\",\"CHANGEME: THE PORT THAT VARNISH IS LISTENING TO\",req.http.X-3scale-auth,\"X-3scale-authorization: true;\");\n\n set req.http.X-3scale-auth-code = threescale.response_http_code(req.http.X-3scale-auth-res);\n\n ## THE OAUTH SECRET FROM THE APPLICATION WILL BE SENT TO THE API BACKEND\n set req.http.X-3scale-auth-secret = threescale.response_key(req.http.X-3scale-auth-res);\n\n unset req.http.X-3scale-auth-res;\n unset req.http.X-3scale-auth;\n\n \n if (req.http.X-3scale-auth-code == \"200\") {\n ## the request has been authorized, proceed as normal. Send always to the backend.\n ## because we always do a pass, no caching of the backend. \n\n unset req.http.X-3scale-auth-code;\n if (threescale.send_post_request_threaded(\"su1.3scale.net\",\"80\",\"\/transactions.xml\",\"\",req.http.X-3scale-report)==0) {} \n unset req.http.X-3scale-auth-report;\n\n return(pass);\n }\n else {\n ## the request from the users has not been authorized!! Returning an error\n ## FIXME: convert req.http.X-3scale-authrep-result; to int\n\n unset req.http.X-3scale-auth-code;\n error 401;\n } \n \n }\n else {\n ## the request was not send by the end-user but by varnish itself\n set req.backend = backend_3scale;\n set req.http.host = \"su1.3scale.net\";\n set req.grace = 5s;\n\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n std.log(\"This should never happen!!\");\n } \n else {\n return(lookup);\n }\n\n }\n\n\t \n}\n\n# the hash of the request needs to be customized to remove all fields that are not \n# associated to the user\n\nsub vcl_hash {\n\n if (req.http.X-3scale-authorization) { \n ## remove no_body\n set req.http.X-url-tmp = regsub(req.url,\"[&?]no_body.[^&]*\",\"\");\n ## remove object_id\n set req.http.X-url-tmp = regsub(req.http.X-url-tmp,\"[&?]object.[^&]*\",\"\");\n ## remove object\n set req.http.X-url-tmp = regsub(req.http.X-url-tmp,\"[&?]object_id.[^&]*\",\"\");\n\n hash_data(req.http.X-url-tmp);\t\n unset req.http.X-url-tmp;\n }\n else {\n ## the default has of varnish for the end-user request, however we better remove the \n ## parameters specific to 3scale from the end-user request. If you want to remove other\n ## parameters from the original request so that they are not taken into account for the\n ## cache this is the place.\n\n set req.http.X-url-tmp = regsub(req.url,\"[&?]user_key.[^&]*\",\"\");\n set req.http.X-url-tmp = regsub(req.url,\"[&?]user_id.[^&]*\",\"\");\n set req.http.X-url-tmp = regsub(req.url,\"[&?]app_key.[^&]*\",\"\");\n set req.http.X-url-tmp = regsub(req.url,\"[&?]app_id.[^&]*\",\"\");\n\n hash_data(req.http.X-url-tmp);\n\n if (req.http.host) {\n hash_data(req.http.host);\n } \n else {\n hash_data(server.ip);\n }\n\n\t unset req.http.X-url-tmp;\n\n }\n\n return (hash);\n\n}\n\n#A HIT means that the request to your local cache of 3scale is still fresh and the\n#response will not have to fetch the data from the remote 3scale backend.\n#vmod_3scale plugin will send a replica of the call asynchronously to 3scale's remote\n#backend on its own\n\nsub vcl_hit {\n\n if (req.http.X-3scale-authorization) {\n if (req.url ~ \"^\/transactions\/oauth_authorize.xml\\?\") {\n\t ##if (threescale.send_get_request_threaded(\"su1.3scale.net\",\"80\",req.url,\"\")==0) {}\n }\n }\n\n}\n\n\nsub vcl_fetch {\n\n if (req.http.X-3scale-authorization) {\n ## cache the authorization from 3scale\n ## CHANGEME: below the TTL of the response of 3scale's backend\n \tset beresp.ttl = 60s;\n }\n else {\n \n }\n \n}\n\nsub vcl_deliver {\n ## remove control headers\n unset req.http.X-3scale-authrep;\n}\n\n\n\nsub vcl_error {\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n <\/head>\n <body>\n <div style=\"background-color:yellow;\">\n <h2>Authorization error trying to access this API<\/h2>\n <p>Did you forget to send your credentials?<\/p>\n <p>Are you over the limits of your account?<\/p> \n <p><b>Please go to your account at 3scale to find out<\/b><\/p>\n <\/div>\n <\/body>\n<\/html>\n\"};\n return (deliver);\n}\n\n\n\n\n","old_contents":"# This is a the VCL configuration file for 3scale's varnish plugin.\n# \n# Default backend definition. Set this to point to the 3scale's\n# backend. \n# \n# set the beresp.ttl in vcl_fetch to have a default global TTL\n# you can define custom TTL via regular expressions\n#\n\n##varnishd -a :80 -T localhost:81 -f vcl\/default_3scale_proxy_oauth.vcl -s malloc,10M -F\n##curl -v -g \"localhost:80\/word\/hello?app_id=7f92ed8c\" \n\n## the backend of your API\nbackend backend_api {\n .host = \"YOU API ENDPOINT, for instance api.mydomain.com\"; \n .port = \"80\";\n}\n\n## real 3scale backend\nbackend backend_3scale {\n .host = \"su1.3scale.net\"; \n .port = \"80\";\n}\n\nimport std;\nimport threescale;\n\nsub vcl_recv {\n\n unset req.http.cookie;\n\n if (!req.http.X-3scale-authorization) {\n ## this request was send by the end-user\n ##set req.backend = backend_api;\n\n ## need to generate the string for the 3scale authorization,\n set req.http.X-3scale-auth = \"\/transactions\/oauth_authorize.xml?provider_key=\";\n ## set your 3scale provider_key\n set req.http.X-3scale-auth = req.http.X-3scale-auth + \"CHANGEME: YOUR 3SCALE PROVIDER_KEY\";\n \n ## extract the parameters sent by the user\n set req.http.X-3scale-app_id = regsub(req.url,\".*[&?]app_id.([^&]*).*\",\"\\1\");\n \n set req.http.X-3scale-auth = req.http.X-3scale-auth + \"&app_id=\" + req.http.X-3scale-app_id; \n \n ## set the appropriate usage in a similar way than above, the basic one is...\n set req.http.X-3scale-auth = req.http.X-3scale-auth + \"&usage[hits]=1\";\n ## if you need to add the service_id\n #set req.http.X-3scale-auth = req.http.X-3scale-auth + \"&service_id=SERVICE_ID\";\n \n ## build the request for the report\n set req.http.X-3scale-report = \"provider_key=\" + \"CHANGEME: YOUR 3SCALE PROVIDER_KEY\";\n #set req.http.X-3scale-report = req.http.X-3scale-report + \"&service_id=\";\n #set req.http.X-3scale-report = req.http.X-3scale-report + \"CHANGEME: SERVICE_ID\";\n set req.http.X-3scale-report = req.http.X-3scale-report + \"&transactions[0][app_id]=\";\n set req.http.X-3scale-report = req.http.X-3scale-report + req.http.X-3scale-app_id;\n \n ## set the usage, you can specify the metric that you want\n set req.http.X-3scale-report = req.http.X-3scale-report + \"&transactions[0][usage][hits]=1\";\n ##\u00a0-----\n \n unset req.http.X-3scale-app_id;\n \n set req.http.X-3scale-auth-res = threescale.send_get_request_body(\"localhost\",\"CHANGEME: THE PORT THAT VARNISH IS LISTENING TO\",req.http.X-3scale-auth,\"X-3scale-authorization: true;\");\n\n set req.http.X-3scale-auth-code = threescale.response_http_code(req.http.X-3scale-auth-res);\n\n ## THE OAUTH SECRET FROM THE APPLICATION WILL BE SENT TO THE API BACKEND\n set req.http.X-3scale-auth-secret = threescale.response_key(req.http.X-3scale-auth-res);\n\n unset req.http.X-3scale-auth-res;\n unset req.http.X-3scale-auth;\n\n \n if (req.http.X-3scale-auth-code == \"200\") {\n ## the request has been authorized, proceed as normal. Send always to the backend.\n ## because we always do a pass, no caching of the backend. \n\n unset req.http.X-3scale-auth-code;\n if (threescale.send_post_request_threaded(\"su1.3scale.net\",\"80\",\"\/transactions.xml\",\"\",req.http.X-3scale-report)==0) {} \n unset req.http.X-3scale-auth-report;\n\n return(pass);\n }\n else {\n ## the request from the users has not been authorized!! Returning an error\n ## FIXME: convert req.http.X-3scale-authrep-result; to int\n\n unset req.http.X-3scale-auth-code;\n error 401;\n } \n \n }\n else {\n ## the request was not send by the end-user but by varnish itself\n set req.backend = backend_3scale;\n set req.http.host = \"su1.3scale.net\";\n set req.grace = 5s;\n\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n std.log(\"This should never happen!!\");\n } \n else {\n return(lookup);\n }\n\n }\n\n\t \n}\n\n# the hash of the request needs to be customized to remove all fields that are not \n# associated to the user\n\nsub vcl_hash {\n\n if (req.http.X-3scale-authorization) { \n ## remove no_body\n set req.http.X-url-tmp = regsub(req.url,\"[&?]no_body.[^&]*\",\"\");\n ## remove object_id\n set req.http.X-url-tmp = regsub(req.http.X-url-tmp,\"[&?]object.[^&]*\",\"\");\n ## remove object\n set req.http.X-url-tmp = regsub(req.http.X-url-tmp,\"[&?]object_id.[^&]*\",\"\");\n\n hash_data(req.http.X-url-tmp);\t\n unset req.http.X-url-tmp;\n }\n else {\n ## the default has of varnish for the end-user request, however we better remove the \n ## parameters specific to 3scale from the end-user request. If you want to remove other\n ## parameters from the original request so that they are not taken into account for the\n ## cache this is the place.\n\n set req.http.X-url-tmp = regsub(req.url,\"[&?]user_key.[^&]*\",\"\");\n set req.http.X-url-tmp = regsub(req.url,\"[&?]user_id.[^&]*\",\"\");\n set req.http.X-url-tmp = regsub(req.url,\"[&?]app_key.[^&]*\",\"\");\n set req.http.X-url-tmp = regsub(req.url,\"[&?]app_id.[^&]*\",\"\");\n\n hash_data(req.http.X-url-tmp);\n\n if (req.http.host) {\n hash_data(req.http.host);\n } \n else {\n hash_data(server.ip);\n }\n\n\t unset req.http.X-url-tmp;\n\n }\n\n return (hash);\n\n}\n\n#A HIT means that the request to your local cache of 3scale is still fresh and the\n#response will not have to fetch the data from the remote 3scale backend.\n#vmod_3scale plugin will send a replica of the call asynchronously to 3scale's remote\n#backend on its own\n\nsub vcl_hit {\n\n if (req.http.X-3scale-authorization) {\n if (req.url ~ \"^\/transactions\/oauth_authorize.xml\\?\") {\n\t ##if (threescale.send_get_request_threaded(\"su1.3scale.net\",\"80\",req.url,\"\")==0) {}\n }\n }\n\n}\n\n\nsub vcl_fetch {\n\n if (req.http.X-3scale-authorization) {\n ## cache the authorization from 3scale\n ## CHANGEME: below the TTL of the response of 3scale's backend\n \tset beresp.ttl = 60s;\n }\n else {\n \n }\n \n}\n\nsub vcl_deliver {\n ## remove control headers\n unset req.http.X-3scale-authrep;\n}\n\n\n\nsub vcl_error {\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n <\/head>\n <body>\n <div style=\"background-color:yellow;\">\n <h2>Authorization error trying to access this API<\/h2>\n <p>Did you forget to send your credentials?<\/p>\n <p>Are you over the limits of your account?<\/p> \n <p><b>Please go to your account at 3scale to find out<\/b><\/p>\n <\/div>\n <\/body>\n<\/html>\n\"};\n return (deliver);\n}\n\n\n\n\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"6ff79cf5e5a776082675520f2fd1c1aa60a98224","subject":"Make sure we don't unset cookies on x-pass requests","message":"Make sure we don't unset cookies on x-pass requests\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets\/fetch.vcl","new_file":"etc\/vcl_snippets\/fetch.vcl","new_contents":" \/* handle 5XX (or any other unwanted status code) *\/\n if (beresp.status >= 500 && beresp.status < 600) {\n\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n \/* deliver stale if the object is available *\/\n if (stale.exists) {\n return(deliver_stale);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n \/* else go to vcl_error to deliver a synthetic *\/\n error 503;\n }\n\n # Remove Set-Cookies from responses for static content\n # to match the cookie removal in recv.\n if (req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's since those can be temporary during the site build\/index\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n }\n\n }\n\n if (req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Content-Type ~ \"text\/(html|xml)\") {\n # enable ESI feature for Magento response by default\n esi;\n if (!beresp.http.Vary ~ \"X-Magento-Vary,Https\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \",X-Magento-Vary,Https\";\n } else {\n set beresp.http.Vary = \"X-Magento-Vary,Https\";\n }\n }\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content\n if (http_status_matches(beresp.status, \"200,404\") && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url.ext ~ \"(?i)(css|js|html|eot|ico|otf|ttf|json)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # cache only successfully responses and 404s\n if ( !http_status_matches(beresp.status, \"200,301,404\")) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\") && !req.http.x-pass ) {\n unset beresp.http.set-cookie;\n if (req.url !~ \"^\/(pub\/)?(media|static)\/.*\") {\n set beresp.grace = 86400m;\n }\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type\n if (beresp.http.Content-Type ~ \"image\") {\n set beresp.http.Surrogate-Key = \"image\";\n } elsif (beresp.http.Content-Type ~ \"script\") {\n set beresp.http.Surrogate-Key = \"script\";\n } elsif (beresp.http.Content-Type ~ \"css\") {\n set beresp.http.Surrogate-Key = \"css\";\n }\n return (deliver);\n }\n","old_contents":" \/* handle 5XX (or any other unwanted status code) *\/\n if (beresp.status >= 500 && beresp.status < 600) {\n\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n \/* deliver stale if the object is available *\/\n if (stale.exists) {\n return(deliver_stale);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n \/* else go to vcl_error to deliver a synthetic *\/\n error 503;\n }\n\n # Remove Set-Cookies from responses for static content\n # to match the cookie removal in recv.\n if (req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's since those can be temporary during the site build\/index\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n }\n\n }\n\n if (req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Content-Type ~ \"text\/(html|xml)\") {\n # enable ESI feature for Magento response by default\n esi;\n if (!beresp.http.Vary ~ \"X-Magento-Vary,Https\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \",X-Magento-Vary,Https\";\n } else {\n set beresp.http.Vary = \"X-Magento-Vary,Https\";\n }\n }\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content\n if (http_status_matches(beresp.status, \"200,404\") && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url.ext ~ \"(?i)(css|js|html|eot|ico|otf|ttf|json)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # cache only successfully responses and 404s\n if ( !http_status_matches(beresp.status, \"200,301,404\")) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\")) {\n unset beresp.http.set-cookie;\n if (req.url !~ \"^\/(pub\/)?(media|static)\/.*\") {\n set beresp.grace = 86400m;\n }\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type\n if (beresp.http.Content-Type ~ \"image\") {\n set beresp.http.Surrogate-Key = \"image\";\n } elsif (beresp.http.Content-Type ~ \"script\") {\n set beresp.http.Surrogate-Key = \"script\";\n } elsif (beresp.http.Content-Type ~ \"css\") {\n set beresp.http.Surrogate-Key = \"css\";\n }\n return (deliver);\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"6c329bd81e7101b13c59f298eeca2906c747f467","subject":"Reduce default Fastly TTL","message":"Reduce default Fastly TTL\n","repos":"elifesciences\/builder,elifesciences\/builder","old_file":"src\/buildercore\/fastly\/vcl\/main.vcl","new_file":"src\/buildercore\/fastly\/vcl\/main.vcl","new_contents":"sub vcl_recv {\n if (req.restarts < 1) {\n # Sanitise header\n unset req.http.X-eLife-Restart;\n }\n\n # Disable Stale-While-Revalidate if a shield request to avoid double SWR\n if (req.http.Fastly-FF) {\n set req.max_stale_while_revalidate = 0s;\n }\n\n #FASTLY recv\n\n if (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n return(lookup);\n}\n\nsub vcl_fetch {\n #FASTLY fetch\n\n if (beresp.status >= 500 && beresp.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n set req.http.X-eLife-Restart = \"fetch,\" beresp.status;\n unset req.http.Cookie; # Temporarily log out the user\n\n restart;\n }\n\n if (!beresp.http.Content-Length || beresp.http.Content-Length == \"0\") {\n # Elastic Load Balancer returns empty error responses\n error beresp.status;\n }\n }\n\n if (req.restarts > 0) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return(pass);\n }\n\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return(pass);\n }\n\n if (beresp.status == 500 || beresp.status == 503) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return(deliver);\n }\n\n if (beresp.http.Expires || beresp.http.Surrogate-Control ~ \"max-age\" || beresp.http.Cache-Control ~ \"(s-maxage|max-age)\") {\n # keep the ttl here\n } else {\n # apply the default ttl\n set beresp.ttl = 300s;\n }\n\n return(deliver);\n}\n\nsub vcl_hit {\n #FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\nsub vcl_miss {\n #FASTLY miss\n\n if (!req.backend.is_shield) {\n unset bereq.http.host;\n }\n\n return(fetch);\n}\n\nsub vcl_deliver {\n if (resp.status >= 500 && resp.status < 600 && stale.exists) {\n set req.http.X-eLife-Restart = \"deliver,\" resp.status;\n\n restart;\n }\n\n if (req.http.Fastly-Debug && req.http.X-eLife-Restart) {\n set resp.http.X-eLife-Restart = req.http.X-eLife-Restart;\n }\n\n #FASTLY deliver\n return(deliver);\n}\n\nsub vcl_error {\n if (obj.status >= 500 && obj.status < 600 && stale.exists) {\n return(deliver_stale);\n }\n\n #FASTLY error\n}\n\nsub vcl_pass {\n #FASTLY pass\n\n if (!req.backend.is_shield) {\n unset bereq.http.host;\n }\n}\n\nsub vcl_log {\n #FASTLY log\n}\n","old_contents":"sub vcl_recv {\n if (req.restarts < 1) {\n # Sanitise header\n unset req.http.X-eLife-Restart;\n }\n\n # Disable Stale-While-Revalidate if a shield request to avoid double SWR\n if (req.http.Fastly-FF) {\n set req.max_stale_while_revalidate = 0s;\n }\n\n #FASTLY recv\n\n if (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n return(lookup);\n}\n\nsub vcl_fetch {\n #FASTLY fetch\n\n if (beresp.status >= 500 && beresp.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n set req.http.X-eLife-Restart = \"fetch,\" beresp.status;\n unset req.http.Cookie; # Temporarily log out the user\n\n restart;\n }\n\n if (!beresp.http.Content-Length || beresp.http.Content-Length == \"0\") {\n # Elastic Load Balancer returns empty error responses\n error beresp.status;\n }\n }\n\n if (req.restarts > 0) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return(pass);\n }\n\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return(pass);\n }\n\n if (beresp.status == 500 || beresp.status == 503) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return(deliver);\n }\n\n if (beresp.http.Expires || beresp.http.Surrogate-Control ~ \"max-age\" || beresp.http.Cache-Control ~ \"(s-maxage|max-age)\") {\n # keep the ttl here\n } else {\n # apply the default ttl\n set beresp.ttl = 3600s;\n }\n\n return(deliver);\n}\n\nsub vcl_hit {\n #FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\nsub vcl_miss {\n #FASTLY miss\n\n if (!req.backend.is_shield) {\n unset bereq.http.host;\n }\n\n return(fetch);\n}\n\nsub vcl_deliver {\n if (resp.status >= 500 && resp.status < 600 && stale.exists) {\n set req.http.X-eLife-Restart = \"deliver,\" resp.status;\n\n restart;\n }\n\n if (req.http.Fastly-Debug && req.http.X-eLife-Restart) {\n set resp.http.X-eLife-Restart = req.http.X-eLife-Restart;\n }\n\n #FASTLY deliver\n return(deliver);\n}\n\nsub vcl_error {\n if (obj.status >= 500 && obj.status < 600 && stale.exists) {\n return(deliver_stale);\n }\n\n #FASTLY error\n}\n\nsub vcl_pass {\n #FASTLY pass\n\n if (!req.backend.is_shield) {\n unset bereq.http.host;\n }\n}\n\nsub vcl_log {\n #FASTLY log\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"6743e0beb2f0b25f7c21f2dc662ecb81cbe1956c","subject":"Implement conditions according to controlset","message":"Implement conditions according to controlset\n","repos":"borisguery\/varnish-device-detect","old_file":"devicedetect.vcl","new_file":"devicedetect.vcl","new_contents":"sub devicedetect {\n unset req.http.X-UA-Device-Type;\n\n \/\/ sensible defaults\n set req.http.X-UA-Device-Type = \"generic\";\n set req.http.X-UA-Device-OS = \"unknown\";\n\n if (req.http.Cookie ~ \"(?i)X-UA-Device-Force\") {\n } else {\n if (req.http.User-Agent ~ \"(?i)ipad\") {\n set req.http.X-UA-Device-Type = \"tablet\";\n set req.http.X-UA-Device-OS = \"ios\";\n } elsif (req.http.User-Agent ~ \"(?i)ip(hone|od)\") {\n set req.http.X-UA-Device-Type = \"mobile\";\n set req.http.X-UA-Device-OS = \"ios\";\n } elsif (req.http.User-Agent ~ \"(?i)android\") {\n \/\/ http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent\n set req.http.X-UA-Device-OS = \"android\";\n if (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") {\n set req.http.X-UA-Device-Type = \"mobile\";\n } elseif (req.http.User-Agent ~ \"(?i)android 3\") { \/\/ looks like android 3\/honeycomb are mostly tablet-only\n set req.http.X-UA-Device-Type = \"tablet\";\n } elseif (req.http.User-Agent ~ \"(?i)android 2\") { \/\/ it should not exist any tablet prior to android 3\n set req.http.X-UA-Device-Type = \"mobile\";\n } else {\n \/\/ fallback on tablet\n set req.http.X-UA-Device-Type = \"tablet\";\n }\n } elseif (req.http.User-Agent ~ \"(?i)windows phone\" || req.http.User-Agent ~ \"(?i)windowsphone\") { \/\/ Should we match IEMobile too or instead?\n set req.http.X-UA-Device-Type = \"mobile\";\n set req.http.X-UA-Device-OS = \"windowsphone\";\n } elseif (req.http.User-Agent ~ \"(?i)blackberry[0-9]?\" || req.http.User-Agent ~ \"(?i)BB10\") {\n set req.http.X-UA-Device-OS = \"blackberry\";\n \/\/ For now, let's assume all blackberry devices are mobile\n \/\/ Afaik, it does not exist blackberry tablets\n set req.http.X-UA-Device-Type = \"mobile\";\n }\n }\n}\n","old_contents":"sub devicedetect {\n unset req.http.X-UA-Device-Type;\n\n \/\/ sensible defaults\n set req.http.X-UA-Device-Type = \"generic\";\n set req.http.X-UA-Device-OS = \"unknown\";\n\n if (req.http.Cookie ~ \"(?i)X-UA-Device-Force\") {\n } else {\n if (req.http.User-Agent ~ \"(?i)ipad\") {\n set req.http.X-UA-Device-Type = \"tablet\";\n set req.http.X-UA-Device-OS = \"ios\";\n } elsif (req.http.User-Agent ~ \"(?i)ip(hone|od)\") {\n set req.http.X-UA-Device-Type = \"mobile\";\n set req.http.X-UA-Device-OS = \"ios\";\n } elsif (req.http.User-Agent ~ \"(?i)android\") {\n \/\/ http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent\n set req.http.X-UA-Device-OS = \"android\";\n if (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") {\n set req.http.X-UA-Device-Type = \"mobile\";\n } elseif (req.http.User-Agent ~ \"(?i)android 3\") { \/\/ looks like android 3\/honeycomb are mostly tablet-only\n set req.http.X-UA-Device-Type = \"tablet\";\n }\n \/\/ fallback on tablet\n set req.http.X-UA-Device-Type = \"tablet\";\n } elseif (req.http.user-Agent ~ \"(?i)windows\") {\n set req.http.X-UA-Device-OS = \"windows\";\n }\n }\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"512a3251eea10b752bb874feb6d18967133563d3","subject":"ban\u304c\u8b0e\u306e\u30de\u30c3\u30c1\u306b\u306a\u3063\u3066\u3044\u305f\u306e\u3092\u4fee\u6b63","message":"ban\u304c\u8b0e\u306e\u30de\u30c3\u30c1\u306b\u306a\u3063\u3066\u3044\u305f\u306e\u3092\u4fee\u6b63\n","repos":"dekokun\/isucon6-qualify,dekokun\/isucon6-qualify,dekokun\/isucon6-qualify,dekokun\/isucon6-qualify,dekokun\/isucon6-qualify,dekokun\/isucon6-qualify,dekokun\/isucon6-qualify,dekokun\/isucon6-qualify","old_file":"webapp\/config\/default.vcl","new_file":"webapp\/config\/default.vcl","new_contents":"#\n# This is an example VCL file for Varnish.\n#\n# It does not do anything by default, delegating control to the\n# builtin VCL. The builtin VCL is called when there is no explicit\n# return statement.\n#\n# See the VCL chapters in the Users Guide at https:\/\/www.varnish-cache.org\/docs\/\n# and https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExamples for more examples.\n\n# Marker to tell the VCL compiler that this VCL has been adapted to the\n# new 4.0 format.\nvcl 4.0;\n\nimport directors;\n\n# Default backend definition. Set this to point to your content server.\nbackend localhost {\n .host = \"127.0.0.1\";\n .port = \"5000\";\n}\n\nsub vcl_init {\n new backend = directors.round_robin();\n\n backend.add_backend(localhost);\n}\n\nsub vcl_recv {\n set req.backend_hint = backend.backend();\n\n if (req.method == \"INVALIDATE\") {\n ban(\"obj.http.Keyword = \" + req.http.X-Invalidated-Keyword);\n return(synth(200, req.http.X-Invalidated-Keyword + \" Purged. Success !!\"));\n }\n\n\n # if (req.http.Cookie) {\n # return(pass);\n # }\n\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return(pass);\n }\n\n return(hash);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n return (lookup);\n}\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n\n return(deliver);\n}\n\nsub vcl_backend_response {\n\n set beresp.do_esi = true;\n # this is same as builtin vcl_backend_response\n # https:\/\/www.varnish-cache.org\/trac\/browser\/bin\/varnishd\/builtin.vcl?rev=ae548683b8f91d0a92799f6c746b80773a4c9f05\n if (beresp.ttl <= 0s ||\n beresp.http.Set-Cookie ||\n beresp.http.Surrogate-control ~ \"no-store\" ||\n beresp.http.Cache-Control ~ \"no-cache\" ||\n (!beresp.http.Surrogate-Control &&\n beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n beresp.http.Vary == \"*\") {\n \/*\n * Mark as \"Hit-For-Pass\" for the next 2 minutes\n *\/\n set beresp.uncacheable = true;\n }\n\n # this is hatena original config\n if (beresp.ttl > 0s && ! beresp.uncacheable) {\n set beresp.grace = 1m;\n }\n return (deliver);\n}\n\nsub vcl_synth {\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n set resp.http.Retry-After = \"5\";\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>\"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <p>XID: \"} + req.xid + {\"<\/p>\n <\/body>\n<\/html>\n\"} );\n return (deliver);\n}\n\n","old_contents":"#\n# This is an example VCL file for Varnish.\n#\n# It does not do anything by default, delegating control to the\n# builtin VCL. The builtin VCL is called when there is no explicit\n# return statement.\n#\n# See the VCL chapters in the Users Guide at https:\/\/www.varnish-cache.org\/docs\/\n# and https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExamples for more examples.\n\n# Marker to tell the VCL compiler that this VCL has been adapted to the\n# new 4.0 format.\nvcl 4.0;\n\nimport directors;\n\n# Default backend definition. Set this to point to your content server.\nbackend localhost {\n .host = \"127.0.0.1\";\n .port = \"5000\";\n}\n\nsub vcl_init {\n new backend = directors.round_robin();\n\n backend.add_backend(localhost);\n}\n\nsub vcl_recv {\n set req.backend_hint = backend.backend();\n\n if (req.method == \"INVALIDATE\") {\n ban(\"obj.http.Keyword = ^.*\" + req.http.X-Invalidated-Keyword + \".*$\");\n return(synth(200, req.http.X-Invalidated-Keyword + \" Purged. Success !!\"));\n }\n\n\n # if (req.http.Cookie) {\n # return(pass);\n # }\n\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return(pass);\n }\n\n return(hash);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n return (lookup);\n}\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n\n return(deliver);\n}\n\nsub vcl_backend_response {\n\n set beresp.do_esi = true;\n # this is same as builtin vcl_backend_response\n # https:\/\/www.varnish-cache.org\/trac\/browser\/bin\/varnishd\/builtin.vcl?rev=ae548683b8f91d0a92799f6c746b80773a4c9f05\n if (beresp.ttl <= 0s ||\n beresp.http.Set-Cookie ||\n beresp.http.Surrogate-control ~ \"no-store\" ||\n beresp.http.Cache-Control ~ \"no-cache\" ||\n (!beresp.http.Surrogate-Control &&\n beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n beresp.http.Vary == \"*\") {\n \/*\n * Mark as \"Hit-For-Pass\" for the next 2 minutes\n *\/\n set beresp.uncacheable = true;\n }\n\n # this is hatena original config\n if (beresp.ttl > 0s && ! beresp.uncacheable) {\n set beresp.grace = 1m;\n }\n return (deliver);\n}\n\nsub vcl_synth {\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n set resp.http.Retry-After = \"5\";\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>\"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <p>XID: \"} + req.xid + {\"<\/p>\n <\/body>\n<\/html>\n\"} );\n return (deliver);\n}\n\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"3dfeabdf0450626c14463746067fb02c276d5af0","subject":"Add command for nonblank space","message":"Add command for nonblank space\n","repos":"aschneiderman\/atom-voice-vocola","old_file":"atom.vcl","new_file":"atom.vcl","new_contents":"# Voice commands for atom\n\nTest Command = \"This Is a Test Command\"; # see if working on laptop and on my desktop at work\n\ninclude folders.vch;\ninclude letters.vch;\n\n# Commands for developing D3: D3 visualizations, D3 Sandwiches\nSave and Reload = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Ctrl+r};\t\nSave and Really Reload = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Ctrl+Shift+r};\nSave and Run = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Up}{Enter};\n\n# File commands\nFind (File | Document) = {Ctrl+t};\nSave As = {Ctrl+Shift+s};\nNext Window = {Ctrl+Tab};\nLast Window = {Ctrl+Shift+Tab};\nLatest File = {Ctrl+Shift+t};\n(Tree View | List Files) = {Alt+o};\t# NOTE: to make this work, I had to create a new keyboard shortcut in Atom (my personal keymap.cson)\n\n\n# --- Text navigation commands ------------------------------------\n<delimiters> := (Quote = '\"' | 'Double Quote' = '\"' | 'Single Quote' = \"'\" | Comma = ',' | 'Equal Sign' = '=' | Equals = '=' \n\t| Period = '.' | Colon = ':' | 'Semi-Colon' = ';' | Hyphen = '-' | Underscore = '_' | Slash = '\/'\n\t| Paren = \"(\" | \"Close Paren\" = \")\" | Parentheses = \"(\" | \"Open Parenthesis\" = \"(\" | \"Close Parentheses\" = \")\"\n\t| Bracket = '[' | \"Close Bracket\" = ']' | Brace = '{' | 'Close Brace' = '}'\t);\n\nLine 1..200 = {Ctrl+g} $1 {Enter};\n(Left = 'b' | Right = 'f') Word = {Alt+$1};\nTop = {Ctrl+Home};\nBottom = {Ctrl+End};\n(Find = 'Right' | 'Insert After' = 'Right' | 'Insert Before' = 'Left') (Next = 'Enter' | Last = 'Shift+F3') <delimiters> \n\t\t= {Ctrl+f} $3 {$2} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') <delimiters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') 1..20 <delimiters> = {Ctrl+f} $3 {Enter} {Esc} Wait(100) {F3_$2} {Shift+F3} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') Enda <delimiters> = {End} {Ctrl+f} $2 {Enter} {Esc} {Shift+F3} Wait(100) {$1};\n\nFine Alpha <letters> = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Left};\nInsert (Before = 'Left' | After = 'Right') Alpha <letters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nFine Number 0..9 = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Right};\n(Find | Insert) Again = {F3} {Right};\n(Find | Insert) Again 1..20 Times = {F3_$1} {Right};\n\n(Set | Add | Clear | Hide | Delete) Bookmark = {Ctrl+Alt+F2};\n(Next = 'F2' | Last = 'Shift+F2') Bookmark = {$1};\n\n\n# --- Editing commands ----------------------------------------\nSelect Line = {Ctrl+l};\nSelect (Next = 'Down' | Forward = 'Down' | Last = 'Up' | Back = 'Up' | Previous = 'Up') 1..20 Lines = {Home} {Shift+$1_$2};\nMove Line (Up | Down) 1..20 = {Ctrl+$1_$2};\nAdd 1..20 (Lines = 'Down' | Line = 'Down' | Pages = 'PgDn' | Page = 'PgDn') = {Shift+$2_$1};\nStart Adding 1..20 Lines = {Home}{Shift+Down_$1};\n\n\nSelect between (Delimiters | Brackets | Tags) ={Ctrl+m} {Ctrl+Alt+m};\nDelete between Tags = {Ctrl+m} {Ctrl+Alt+m} {Del};\nDelete Tags = {Ctrl+Alt+F4};\nReplace With (Header | Heading) 1..7 = {Ctrl+Alt+F4} '<h' $2 '>' {End} '<\/h' $2 '>' {Home};\nReplace With (para = 'p') = {Ctrl+Alt+F4} '<' $1 '>' {End} '<\/' $1 '>';\n\n\nDelete Word = {Ctrl+Del};\nDelete 1..20 Words = {Ctrl+Del_$1};\nDelete (Back | Last) Word = {Ctrl+Backspace};\nDelete (Back | Last) 1..20 Words = {Ctrl+Backspace_$2};\nDelete Enda Word = {End} {Ctrl+Backspace};\nKill Word = {Ctrl+Backspace}{Ctrl+Del};\n\n(Delete Line | Dede) = {Ctrl+Shift+k};\nDelete 1..20 Lines = {Ctrl+Shift+k_$1};\n(Cut = 'x' | Paste = 'v' | Copy = 'c') That = {Ctrl+$1};\n\nComment (That | Line) = {Ctrl+\/};\nComment 1..20 Lines = {Home} {Shift+Down_$1} {Ctrl+\/};\n\nReplace = {Ctrl+f};\nReplace All = {Ctrl+Enter};\n\n(Join = 'j' | Indent = ']' | Dedent = '[') That = {Ctrl+$1};\n\n\n# --- Commands to create code\/tags -------------------------------------------\n# NOTE: basic HTML commands are stored in my global Vocala commands\n\nStart (\t# HTML commands\n\t'HTML page' = 'html' | pre = \"pre\" | 'Comment' = 'comment-html'\n\t| div = 'div' \n\t| 'class example' = 'class-example'\t\t# Used in A Taste of D3\n\n\t# D3 Recipe commands\n\t| 'Recipe Page' = 'recipe-page' | 'Recipe Row' = 'recipe-row' \n\t| 'Recipe Toy' = 'recipe-toy' | Toy = 'recipe-toy'\n\t| 'Bold ID'\n\n\t# D3 and JavaScript commands\n\t| Console = 'console' | Log = 'console'\n\t| Var = 'variable' | Variable = 'variable'\n\t# Coffeescript commands\n\t| Snippet = 'my-snippet' \n\t| 'Fix Line' = 'fix-current-line' | 'Fix Current Line' = 'fix-current-line'\n) = $1 {Tab};\n\nStop (\t#HTML commands\n\t'div comment' = 'comment-div-end' | Comment = 'comment-html-end' | 'div' = 'div-end'\n) = $1 {Tab};\n\n# HTML commands\nStart (Nibs | Non-Blank Space) = ' ';\nDot HTML = '.html';\nStart (Header | Heading) 1..7 = h $2 {Tab};\nAdd (Header | Heading) 1..7 = '<h' $2 '>' {End} '<\/h' $2 '>';\nAdd (para = 'p') = '<' $1 '>' {End} '<\/' $1 '>';\n\n# D3 Recipe commands\nPre-Format Code = {Ctrl+Alt+F5};\nReload Atom = {Ctrl+s} Wait(100) {Shift+Ctrl+Alt+F5};\nCommand Palette = {Ctrl+Shift+p};\nKeyboard Shortcuts = {Ctrl+.};\nRun Specs = {Ctrl+Alt+p};\nShow Console = {Ctrl+Alt+i};\n\n\n\n# D3 commands\nPaste Function = 'function ' {Ctrl+v} ' {' {Enter} {Enter} '};' {Up};\n\n# Coffeescript commands\n\n# Python commands\n\n\n# --- D3 commands -------------------------------------------\n\n\n# --- Python commands -------------------------------------------\n\n\n# --- Coffeescript commands -------------------------------------------","old_contents":"# Voice commands for atom\n\nTest Command = \"This Is a Test Command\"; # see if working on laptop and on my desktop at work\n\ninclude folders.vch;\ninclude letters.vch;\n\n# Commands for developing D3: D3 visualizations, D3 Sandwiches\nSave and Reload = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Ctrl+r};\t\nSave and Really Reload = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Ctrl+Shift+r};\nSave and Run = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Up}{Enter};\n\n# File commands\nFind (File | Document) = {Ctrl+t};\nSave As = {Ctrl+Shift+s};\nNext Window = {Ctrl+Tab};\nLast Window = {Ctrl+Shift+Tab};\nLatest File = {Ctrl+Shift+t};\n(Tree View | List Files) = {Alt+o};\t# NOTE: to make this work, I had to create a new keyboard shortcut in Atom (my personal keymap.cson)\n\n\n# --- Text navigation commands ------------------------------------\n<delimiters> := (Quote = '\"' | 'Double Quote' = '\"' | 'Single Quote' = \"'\" | Comma = ',' | 'Equal Sign' = '=' | Equals = '=' \n\t| Period = '.' | Colon = ':' | 'Semi-Colon' = ';' | Hyphen = '-' | Underscore = '_' | Slash = '\/'\n\t| Paren = \"(\" | \"Close Paren\" = \")\" | Parentheses = \"(\" | \"Open Parenthesis\" = \"(\" | \"Close Parentheses\" = \")\"\n\t| Bracket = '[' | \"Close Bracket\" = ']' | Brace = '{' | 'Close Brace' = '}'\t);\n\nLine 1..200 = {Ctrl+g} $1 {Enter};\n(Left = 'b' | Right = 'f') Word = {Alt+$1};\nTop = {Ctrl+Home};\nBottom = {Ctrl+End};\n(Find = 'Right' | 'Insert After' = 'Right' | 'Insert Before' = 'Left') (Next = 'Enter' | Last = 'Shift+F3') <delimiters> \n\t\t= {Ctrl+f} $3 {$2} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') <delimiters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') 1..20 <delimiters> = {Ctrl+f} $3 {Enter} {Esc} Wait(100) {F3_$2} {Shift+F3} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') Enda <delimiters> = {End} {Ctrl+f} $2 {Enter} {Esc} {Shift+F3} Wait(100) {$1};\n\nFine Alpha <letters> = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Left};\nInsert (Before = 'Left' | After = 'Right') Alpha <letters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nFine Number 0..9 = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Right};\n(Find | Insert) Again = {F3} {Right};\n(Find | Insert) Again 1..20 Times = {F3_$1} {Right};\n\n(Set | Add | Clear | Hide | Delete) Bookmark = {Ctrl+Alt+F2};\n(Next = 'F2' | Last = 'Shift+F2') Bookmark = {$1};\n\n\n# --- Editing commands ----------------------------------------\nSelect Line = {Ctrl+l};\nSelect (Next = 'Down' | Forward = 'Down' | Last = 'Up' | Back = 'Up' | Previous = 'Up') 1..20 Lines = {Home} {Shift+$1_$2};\nMove Line (Up | Down) 1..20 = {Ctrl+$1_$2};\nAdd 1..20 (Lines = 'Down' | Line = 'Down' | Pages = 'PgDn' | Page = 'PgDn') = {Shift+$2_$1};\nStart Adding 1..20 Lines = {Home}{Shift+Down_$1};\n\n\nSelect between (Delimiters | Brackets | Tags) ={Ctrl+m} {Ctrl+Alt+m};\nDelete between Tags = {Ctrl+m} {Ctrl+Alt+m} {Del};\nDelete Tags = {Ctrl+Alt+F4};\nReplace With (Header | Heading) 1..7 = {Ctrl+Alt+F4} '<h' $2 '>' {End} '<\/h' $2 '>' {Home};\nReplace With (para = 'p') = {Ctrl+Alt+F4} '<' $1 '>' {End} '<\/' $1 '>';\n\n\nDelete Word = {Ctrl+Del};\nDelete 1..20 Words = {Ctrl+Del_$1};\nDelete (Back | Last) Word = {Ctrl+Backspace};\nDelete (Back | Last) 1..20 Words = {Ctrl+Backspace_$2};\nDelete Enda Word = {End} {Ctrl+Backspace};\nKill Word = {Ctrl+Backspace}{Ctrl+Del};\n\n(Delete Line | Dede) = {Ctrl+Shift+k};\nDelete 1..20 Lines = {Ctrl+Shift+k_$1};\n(Cut = 'x' | Paste = 'v' | Copy = 'c') That = {Ctrl+$1};\n\nComment (That | Line) = {Ctrl+\/};\nComment 1..20 Lines = {Home} {Shift+Down_$1} {Ctrl+\/};\n\nReplace = {Ctrl+f};\nReplace All = {Ctrl+Enter};\n\n(Join = 'j' | Indent = ']' | Dedent = '[') That = {Ctrl+$1};\n\n\n# --- Commands to create code\/tags -------------------------------------------\n# NOTE: basic HTML commands are stored in my global Vocala commands\n\nStart (\t# HTML commands\n\t'HTML page' = 'html' | pre = \"pre\" | 'Comment' = 'comment-html'\n\t| div = 'div' \n\t| 'class example' = 'class-example'\t\t# Used in A Taste of D3\n\n\t# D3 Recipe commands\n\t| 'Recipe Page' = 'recipe-page' | 'Recipe Row' = 'recipe-row' \n\t| 'Recipe Toy' = 'recipe-toy' | Toy = 'recipe-toy'\n\t| 'Bold ID'\n\n\t# D3 and JavaScript commands\n\t| Console = 'console' | Log = 'console'\n\t| Var = 'variable' | Variable = 'variable'\n\t# Coffeescript commands\n\t| Snippet = 'my-snippet' \n\t| 'Fix Line' = 'fix-current-line' | 'Fix Current Line' = 'fix-current-line'\n) = $1 {Tab};\n\nStop (\t#HTML commands\n\t'div comment' = 'comment-div-end' | Comment = 'comment-html-end' | 'div' = 'div-end'\n) = $1 {Tab};\n\n# HTML commands\nDot HTML = '.html';\nStart (Header | Heading) 1..7 = h $2 {Tab};\nAdd (Header | Heading) 1..7 = '<h' $2 '>' {End} '<\/h' $2 '>';\nAdd (para = 'p') = '<' $1 '>' {End} '<\/' $1 '>';\n\n# D3 Recipe commands\nPre-Format Code = {Ctrl+Alt+F5};\nReload Atom = {Ctrl+s} Wait(100) {Shift+Ctrl+Alt+F5};\nCommand Palette = {Ctrl+Shift+p};\nKeyboard Shortcuts = {Ctrl+.};\nRun Specs = {Ctrl+Alt+p};\nShow Console = {Ctrl+Alt+i};\n\n\n\n# D3 commands\nPaste Function = 'function ' {Ctrl+v} ' {' {Enter} {Enter} '};' {Up};\n\n# Coffeescript commands\n\n# Python commands\n\n\n# --- D3 commands -------------------------------------------\n\n\n# --- Python commands -------------------------------------------\n\n\n# --- Coffeescript commands -------------------------------------------","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"f0391d4f66f71320da1dae7cf0cd11539efda0e4","subject":"Support v2 API endpoints in Fastly config","message":"Support v2 API endpoints in Fastly config\n","repos":"kdzwinel\/polyfill-service,mcshaz\/polyfill-service,jonathan-fielding\/polyfill-service,JakeChampion\/polyfill-service,jonathan-fielding\/polyfill-service,JakeChampion\/polyfill-service,kdzwinel\/polyfill-service,mcshaz\/polyfill-service,mcshaz\/polyfill-service,kdzwinel\/polyfill-service,jonathan-fielding\/polyfill-service","old_file":"fastly-config.vcl","new_file":"fastly-config.vcl","new_contents":"sub vcl_recv {\n#FASTLY recv\n\n\tif (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n\t\treturn(pass);\n\t}\n\n\tif (req.url ~ \"^\/v\\d\/polyfill\\.\" && req.url !~ \"[\\?\\&]ua=\") {\n\t\tset req.http.X-Orig-URL = req.url;\n\t\tset req.url = \"\/v2\/normalizeUa?ua=\" urlencode(req.http.User-Agent);\n\t}\n\n\treturn(lookup);\n}\n\nsub vcl_deliver {\n#FASTLY deliver\n\n\t# If the response is to a normalise request and there's a parked \"original request\", use the normalised UA response to modify the original request and restart it\n\tif (req.url ~ \"^\/v\\d\/normalizeUa\" && resp.status == 200 && req.http.X-Orig-URL) {\n\t\tset req.http.Fastly-force-Shield = \"1\";\n\t\tif (req.http.X-Orig-URL ~ \"\\?\") {\n\t\t\tset req.url = req.http.X-Orig-URL \"&ua=\" resp.http.Normalized-User-Agent;\n\t\t} else {\n\t\t\tset req.url = req.http.X-Orig-URL \"?ua=\" resp.http.Normalized-User-Agent;\n\t\t}\n\t\trestart;\n\n\t# If the original request didn't specify a UA override, and we added one when the request was sent to the backend, the backend won't have included a Vary:user-agent header (correctly) but we need to add one\n\t} else if (req.url ~ \"^\/v\\d\/polyfill\\..*[\\?\\&]ua=\" && req.http.X-Orig-URL && req.http.X-Orig-URL !~ \"[\\?\\&]ua=\") {\n\t\tset resp.http.Vary = \"Accept-Encoding, User-Agent\";\n\t}\n\treturn(deliver);\n}\n","old_contents":"sub vcl_recv {\n#FASTLY recv\n\n\tif (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n\t\treturn(pass);\n\t}\n\n\tif (req.url ~ \"^\/v1\/polyfill\\.\" && req.url !~ \"[\\?\\&]ua=\") {\n\t\tset req.http.X-Orig-URL = req.url;\n\t\tset req.url = \"\/v1\/normalizeUa?ua=\" urlencode(req.http.User-Agent);\n\t}\n\n\treturn(lookup);\n}\n\nsub vcl_deliver {\n#FASTLY deliver\n\n\t# If the response is to a normalise request and there's a parked \"original request\", use the normalised UA response to modify the original request and restart it\n\tif (req.url ~ \"^\/v1\/normalizeUa\" && resp.status == 200 && req.http.X-Orig-URL) {\n\t\tset req.http.Fastly-force-Shield = \"1\";\n\t\tif (req.http.X-Orig-URL ~ \"\\?\") {\n\t\t\tset req.url = req.http.X-Orig-URL \"&ua=\" resp.http.Normalized-User-Agent;\n\t\t} else {\n\t\t\tset req.url = req.http.X-Orig-URL \"?ua=\" resp.http.Normalized-User-Agent;\n\t\t}\n\t\trestart;\n\n\t# If the original request didn't specify a UA override, and we added one when the request was sent to the backend, the backend won't have included a Vary:user-agent header (correctly) but we need to add one\n\t} else if (req.url ~ \"^\/v1\/polyfill\\..*[\\?\\&]ua=\" && req.http.X-Orig-URL && req.http.X-Orig-URL !~ \"[\\?\\&]ua=\") {\n\t\tset resp.http.Vary = \"Accept-Encoding, User-Agent\";\n\t}\n\treturn(deliver);\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"f5488a2fc3d2ca60f24183eacd5984bb239b3702","subject":"Support polyfills.io with redirect to polyfill.io","message":"Support polyfills.io with redirect to polyfill.io\n","repos":"JakeChampion\/polyfill-service,kdzwinel\/polyfill-service,mcshaz\/polyfill-service,mcshaz\/polyfill-service,jonathan-fielding\/polyfill-service,jonathan-fielding\/polyfill-service,mcshaz\/polyfill-service,kdzwinel\/polyfill-service,JakeChampion\/polyfill-service,kdzwinel\/polyfill-service,jonathan-fielding\/polyfill-service","old_file":"fastly-config.vcl","new_file":"fastly-config.vcl","new_contents":"import boltsort;\n\nsub vcl_recv {\n#FASTLY recv\n\tif ( req.request == \"FASTLYPURGE\" ) {\n\t\tset req.http.Fastly-Purge-Requires-Auth = \"1\";\n\t}\n\n\tif (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n\t\treturn(pass);\n\t}\n\n\tif (!req.http.Fastly-SSL && (req.http.Host == \"cdn.polyfill.io\" || req.http.Host == \"polyfill.io\")) {\n\t\terror 751 \"Canonicalise\";\n\t}\n\n\tif (req.http.Host ~ \"polyfills.io\") {\n\t\terror 751 \"Canonicalise\";\n\t}\n\n\tif (req.url ~ \"^\/v2\/(polyfill\\.|recordRumData)\" && req.url !~ \"[\\?\\&]ua=\") {\n\t\tset req.http.X-Orig-URL = req.url;\n\t\tset req.url = \"\/v2\/normalizeUa?ua=\" urlencode(req.http.User-Agent);\n\t}\n\n\tif (req.url ~ \"^\/v2\/recordRumData\" && req.http.Normalized-User-Agent) {\n\t\tset req.http.Log = regsub(req.url, \"^.*?\\?(.*)$\", \"\\1\") \"&ip=\" client.ip \"&refer_domain=\" regsub(req.http.Referer, \"^(https?\\:\\\/\\\/)?(www\\.)?(.+?)(\\:\\d+)?([\\\/\\?].*)?$\", \"\\3\") \"&country=\" geoip.country_code \"&data_center=\" if(req.http.Cookie:FastlyDC, req.http.Cookie:FastlyDC, server.datacenter);\n\t\terror 204 \"No Content\";\n\t}\n\n\tset req.url = boltsort.sort(req.url);\n\n\treturn(lookup);\n}\n\nsub vcl_deliver {\n#FASTLY deliver\n\n\t# If the response is to a normalise request and there's a parked \"original request\", use the normalised UA response to modify the original request and restart it\n\tif (req.url ~ \"^\/v\\d\/normalizeUa\" && resp.status == 200 && req.http.X-Orig-URL ~ \"^\/v2\/(polyfill\\.|recordRumData)\") {\n\t\tset req.http.Fastly-force-Shield = \"1\";\n\t\tset req.http.Normalized-User-Agent = resp.http.Normalized-User-Agent;\n\t\tif (req.http.X-Orig-URL ~ \"\\?\") {\n\t\t\tset req.url = req.http.X-Orig-URL \"&ua=\" resp.http.Normalized-User-Agent;\n\t\t} else {\n\t\t\tset req.url = req.http.X-Orig-URL \"?ua=\" resp.http.Normalized-User-Agent;\n\t\t}\n\t\trestart;\n\n\t# If the original request didn't specify a UA override, and we added one when the request was sent to the backend, the backend won't have included a Vary:user-agent header (correctly) but we need to add one\n\t} else if (req.url ~ \"^\/v\\d\/polyfill\\..*[\\?\\&]ua=\" && req.http.X-Orig-URL && req.http.X-Orig-URL !~ \"[\\?\\&]ua=\") {\n\t\tadd resp.http.Vary = \"User-Agent\";\n\t}\n\n\tif (req.url ~ \"[\\&\\?]rum=1\") {\n\t\tadd resp.http.Set-Cookie = \"FastlyDC=\" server.datacenter \"; Path=\/; HttpOnly; max-age=60\";\n\t}\n\n\treturn(deliver);\n}\n\nsub vcl_error {\n\n\t# Redirect to SSL\n\tif (obj.status == 751) {\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\tset obj.http.Location = \"https:\/\/polyfill.io\" req.url;\n\t\tsynthetic {\"\"};\n\t\treturn (deliver);\n\t}\n}\n","old_contents":"import boltsort;\n\nsub vcl_recv {\n#FASTLY recv\n\tif ( req.request == \"FASTLYPURGE\" ) {\n\t\tset req.http.Fastly-Purge-Requires-Auth = \"1\";\n\t}\n\n\tif (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n\t\treturn(pass);\n\t}\n\n\tif (!req.http.Fastly-SSL && (req.http.Host == \"cdn.polyfill.io\" || req.http.Host == \"polyfill.io\")) {\n\t\terror 751 \"Force TLS\";\n\t}\n\n\tif (req.url ~ \"^\/v2\/(polyfill\\.|recordRumData)\" && req.url !~ \"[\\?\\&]ua=\") {\n\t\tset req.http.X-Orig-URL = req.url;\n\t\tset req.url = \"\/v2\/normalizeUa?ua=\" urlencode(req.http.User-Agent);\n\t}\n\n\tif (req.url ~ \"^\/v2\/recordRumData\" && req.http.Normalized-User-Agent) {\n\t\tset req.http.Log = regsub(req.url, \"^.*?\\?(.*)$\", \"\\1\") \"&ip=\" client.ip \"&refer_domain=\" regsub(req.http.Referer, \"^(https?\\:\\\/\\\/)?(www\\.)?(.+?)(\\:\\d+)?([\\\/\\?].*)?$\", \"\\3\") \"&country=\" geoip.country_code \"&data_center=\" if(req.http.Cookie:FastlyDC, req.http.Cookie:FastlyDC, server.datacenter);\n\t\terror 204 \"No Content\";\n\t}\n\n\tset req.url = boltsort.sort(req.url);\n\n\treturn(lookup);\n}\n\nsub vcl_deliver {\n#FASTLY deliver\n\n\t# If the response is to a normalise request and there's a parked \"original request\", use the normalised UA response to modify the original request and restart it\n\tif (req.url ~ \"^\/v\\d\/normalizeUa\" && resp.status == 200 && req.http.X-Orig-URL ~ \"^\/v2\/(polyfill\\.|recordRumData)\") {\n\t\tset req.http.Fastly-force-Shield = \"1\";\n\t\tset req.http.Normalized-User-Agent = resp.http.Normalized-User-Agent;\n\t\tif (req.http.X-Orig-URL ~ \"\\?\") {\n\t\t\tset req.url = req.http.X-Orig-URL \"&ua=\" resp.http.Normalized-User-Agent;\n\t\t} else {\n\t\t\tset req.url = req.http.X-Orig-URL \"?ua=\" resp.http.Normalized-User-Agent;\n\t\t}\n\t\trestart;\n\n\t# If the original request didn't specify a UA override, and we added one when the request was sent to the backend, the backend won't have included a Vary:user-agent header (correctly) but we need to add one\n\t} else if (req.url ~ \"^\/v\\d\/polyfill\\..*[\\?\\&]ua=\" && req.http.X-Orig-URL && req.http.X-Orig-URL !~ \"[\\?\\&]ua=\") {\n\t\tadd resp.http.Vary = \"User-Agent\";\n\t}\n\n\tif (req.url ~ \"[\\&\\?]rum=1\") {\n\t\tadd resp.http.Set-Cookie = \"FastlyDC=\" server.datacenter \"; Path=\/; HttpOnly; max-age=60\";\n\t}\n\n\treturn(deliver);\n}\n\nsub vcl_error {\n\n\t# Redirect to SSL\n\tif (obj.status == 751) {\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\tset obj.http.Location = \"https:\/\/\" req.http.host req.url;\n\t\tsynthetic {\"\"};\n\t\treturn (deliver);\n\t}\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"c3ee7e698d6e862441058e98197c5599104c0f5c","subject":"#85: Don't remove etags in vcl_backend_response","message":"#85: Don't remove etags in vcl_backend_response\n","repos":"joomlatools\/joomla-vagrant,joomlatools\/joomlatools-vagrant,joomlatools\/joomla-vagrant,joomlatools\/joomlatools-vagrant,joomlatools\/joomla-vagrant,joomlatools\/joomlatools-vagrant,joomlatools\/joomla-vagrant,joomlatools\/joomlatools-vagrant,joomlatools\/joomlatools-vagrant,joomlatools\/joomla-vagrant,joomlatools\/joomla-vagrant","old_file":"puppet\/modules\/custom\/profiles\/files\/varnish\/joomla.box.vcl","new_file":"puppet\/modules\/custom\/profiles\/files\/varnish\/joomla.box.vcl","new_contents":"vcl 4.0;\n\n# This Varnish configuration is a very basic template to get started with caching Joomla sites.\n# In no way is this configuration complete: every site is unique and needs customisation!\n# For demonstration purposes this VCL will cache all front-end pages (including pages with cookies).\n\nimport std;\n\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n .probe = {\n .url = \"\/varnish-enabled\";\n .interval = 1s;\n .timeout = 1s;\n }\n}\n\nbackend alternative {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\n\nsub vcl_recv {\n # Forward client's IP to backend\n unset req.http.X-Forwarded-For;\n set req.http.X-Forwarded-For = client.ip;\n\n set req.http.X-Forwarded-By = server.ip;\n set req.http.X-Forwarded-Port = 80;\n\n # Check if we've still enabled Varnish, if not, passthrough every request\n set req.http.backend = \"default\";\n if (! std.healthy(req.backend_hint))\n {\n set req.backend_hint = alternative;\n set req.http.backend = \"alternative\";\n return (pass);\n }\n\n # Do not cache phpmyadmin\n if (req.http.host == \"phpmyadmin.joomla.box\") {\n return (pass);\n }\n\n # Do not cache system tools on joomla.box:\n if (req.http.host == \"joomla.box\")\n {\n if (req.url ~ \"^\/apc\" || req.url ~ \"^\/phpinfo\" || req.url ~ \"^\/pimpmylog\" || req.url ~ \"^\/dashboard\") {\n return (pass);\n }\n }\n\n # Do not cache ZendServer endpoint\n if (req.url ~ \"^\/ZendServer\") {\n return (pass);\n }\n\n # Do not cache POST requests\n if (req.method == \"POST\") {\n return (pass);\n }\n\n # Proxy (pass) any request that goes to the backend admin, the banner component links, ..\n if(req.url ~ \"\/administrator\" || req.url ~ \"\/component\/banners\" || req.url ~ \"\/component\/users\" || req.url ~ \"\/installation\") {\n return (pass);\n }\n\n # Do not cache if user is logged in\n if (req.http.Authorization || req.http.Authenticate) {\n return (pass);\n }\n\n # Don't cache ajax requests\n if(req.http.X-Requested-With == \"XMLHttpRequest\" || req.url ~ \"nocache\") {\n return (pass);\n }\n\n # Properly handle different encoding types\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf)$\") {\n # No point in compressing these\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n # unknown algorithm (aka crappy browser)\n unset req.http.Accept-Encoding;\n }\n }\n\n return (hash);\n}\n\nsub vcl_backend_response {\n if(bereq.http.backend == \"alternative\")\n {\n set beresp.uncacheable = true;\n\n return(deliver);\n }\n\n # This is Joomla! specific: fix stupid \"no-cache\" header sent by Joomla! even\n # when caching is on - make sure to replace 300 with the number of seconds that\n # you want the browser to cache content\n if(beresp.http.Cache-Control ~ \"no-cache\" || beresp.http.Cache-Control == \"\"){\n set beresp.http.Cache-Control = \"max-age=300, public, must-revalidate\";\n }\n\n # Check for the custom \"x-Logged-In\" header to identify if the visitor is a guest,\n # then unset any cookie (including session cookies) provided it's not a POST request.\n if(bereq.method != \"POST\" && beresp.http.X-Logged-In == \"false\") {\n unset beresp.http.Set-Cookie;\n }\n\n # This is how long Varnish will cache content\n set beresp.ttl = 1w;\n\n return (deliver);\n}\n\nsub vcl_hash\n{\n hash_data(req.url);\n\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n\n # Hash cookies for requests that have them\n if (req.http.Cookie) {\n hash_data(req.http.Cookie);\n }\n}\n\nsub vcl_deliver {\n if (resp.http.x-varnish ~ \" \") {\n set resp.http.X-Varnish-Status = \"HIT\";\n } else {\n set resp.http.X-Varnish-Status = \"MISS\";\n }\n\n # Please note that obj.hits behaviour changed in 4.0, now it counts per objecthead, not per object\n # and obj.hits may not be reset in some cases where bans are in use. See bug 1492 for details.\n # So take hits with a grain of salt\n set resp.http.X-Varnish-Hits = obj.hits;\n}","old_contents":"vcl 4.0;\n\n# This Varnish configuration is a very basic template to get started with caching Joomla sites.\n# In no way is this configuration complete: every site is unique and needs customisation!\n# For demonstration purposes this VCL will cache all front-end pages (including pages with cookies).\n\nimport std;\n\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n .probe = {\n .url = \"\/varnish-enabled\";\n .interval = 1s;\n .timeout = 1s;\n }\n}\n\nbackend alternative {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\n\nsub vcl_recv {\n # Forward client's IP to backend\n unset req.http.X-Forwarded-For;\n set req.http.X-Forwarded-For = client.ip;\n\n set req.http.X-Forwarded-By = server.ip;\n set req.http.X-Forwarded-Port = 80;\n\n # Check if we've still enabled Varnish, if not, passthrough every request\n set req.http.backend = \"default\";\n if (! std.healthy(req.backend_hint))\n {\n set req.backend_hint = alternative;\n set req.http.backend = \"alternative\";\n return (pass);\n }\n\n # Do not cache phpmyadmin\n if (req.http.host == \"phpmyadmin.joomla.box\") {\n return (pass);\n }\n\n # Do not cache system tools on joomla.box:\n if (req.http.host == \"joomla.box\")\n {\n if (req.url ~ \"^\/apc\" || req.url ~ \"^\/phpinfo\" || req.url ~ \"^\/pimpmylog\" || req.url ~ \"^\/dashboard\") {\n return (pass);\n }\n }\n\n # Do not cache ZendServer endpoint\n if (req.url ~ \"^\/ZendServer\") {\n return (pass);\n }\n\n # Do not cache POST requests\n if (req.method == \"POST\") {\n return (pass);\n }\n\n # Proxy (pass) any request that goes to the backend admin, the banner component links, ..\n if(req.url ~ \"\/administrator\" || req.url ~ \"\/component\/banners\" || req.url ~ \"\/component\/users\" || req.url ~ \"\/installation\") {\n return (pass);\n }\n\n # Do not cache if user is logged in\n if (req.http.Authorization || req.http.Authenticate) {\n return (pass);\n }\n\n # Don't cache ajax requests\n if(req.http.X-Requested-With == \"XMLHttpRequest\" || req.url ~ \"nocache\") {\n return (pass);\n }\n\n # Properly handle different encoding types\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf)$\") {\n # No point in compressing these\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n # unknown algorithm (aka crappy browser)\n unset req.http.Accept-Encoding;\n }\n }\n\n return (hash);\n}\n\nsub vcl_backend_response {\n if(bereq.http.backend == \"alternative\")\n {\n set beresp.uncacheable = true;\n\n return(deliver);\n }\n\n # Unset the \"etag\" header (suggested)\n unset beresp.http.etag;\n\n # This is Joomla! specific: fix stupid \"no-cache\" header sent by Joomla! even\n # when caching is on - make sure to replace 300 with the number of seconds that\n # you want the browser to cache content\n if(beresp.http.Cache-Control ~ \"no-cache\" || beresp.http.Cache-Control == \"\"){\n set beresp.http.Cache-Control = \"max-age=300, public, must-revalidate\";\n }\n\n # Check for the custom \"x-Logged-In\" header to identify if the visitor is a guest,\n # then unset any cookie (including session cookies) provided it's not a POST request.\n if(bereq.method != \"POST\" && beresp.http.X-Logged-In == \"false\") {\n unset beresp.http.Set-Cookie;\n }\n\n # This is how long Varnish will cache content\n set beresp.ttl = 1w;\n\n return (deliver);\n}\n\nsub vcl_hash\n{\n hash_data(req.url);\n\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n\n # Hash cookies for requests that have them\n if (req.http.Cookie) {\n hash_data(req.http.Cookie);\n }\n}\n\nsub vcl_deliver {\n if (resp.http.x-varnish ~ \" \") {\n set resp.http.X-Varnish-Status = \"HIT\";\n } else {\n set resp.http.X-Varnish-Status = \"MISS\";\n }\n\n # Please note that obj.hits behaviour changed in 4.0, now it counts per objecthead, not per object\n # and obj.hits may not be reset in some cases where bans are in use. See bug 1492 for details.\n # So take hits with a grain of salt\n set resp.http.X-Varnish-Hits = obj.hits;\n}","returncode":0,"stderr":"","license":"mpl-2.0","lang":"VCL"} {"commit":"074968fe80a642fb2b41aeb4cea2ef8d84564929","subject":"Renamed variables; fixed unset bug","message":"Renamed variables; fixed unset bug\n","repos":"rhargreaves\/fastly-vcl-experiments,rhargreaves\/fastly-vcl-experiments","old_file":"oauth_sig_check.vcl","new_file":"oauth_sig_check.vcl","new_contents":"\ntable consumer_secrets {\n\t\"foo\": \"super_secret\"\n}\n\ntable access_tokens {\n\t\"bar\": \"token_secret\"\n}\n\nsub vcl_recv {\n#FASTLY recv\n#DEPLOY recv\n\tset req.http.X-OAuth-Consumer-Key = if(req.url ~ \"(?i)oauth_consumer_key=([^&]*)\", urldecode(re.group.1), \"\");\n\tif(req.http.X-OAuth-Consumer-Key == \"\") {\n\t\terror 401 \"Missing Consumer Key\";\n\t}\n\tset req.http.X-OAuth-Consumer-Secret = table.lookup(consumer_secrets, req.http.X-OAuth-Consumer-Key);\n\tif(!req.http.X-OAuth-Consumer-Secret) {\n\t\terror 401 \"Invalid Consumer Key\";\n\t}\n\tset req.http.X-OAuth-Access-Token = if(req.url ~ \"(?i)oauth_token=([^&]*)\", urldecode(re.group.1), \"\");\n\tif(req.http.X-OAuth-Access-Token != \"\") {\n\t\tset req.http.X-OAuth-Access-Token-Secret = table.lookup(access_tokens, req.http.X-OAuth-Access-Token);\n\t\tif(!req.http.X-OAuth-Access-Token-Secret) {\n\t\t\terror 401 \"Invalid Access Token\";\n\t\t}\n\t} else {\n\t\tset req.http.X-OAuth-Access-Token-Secret = \"\";\n\t}\n\tset req.http.X-OAuth-Provided-Signature = if(req.url ~ \"(?i)oauth_signature=([^&]*)\", urldecode(re.group.1), \"\");\n\tif(req.http.X-OAuth-Provided-Signature == \"\") {\n\t\terror 401 \"Missing Signature\";\n\t}\n\tset req.http.X-OAuth-Ordered-Url = boltsort.sort(req.url);\n\tset req.http.X-OAuth-Parameters = regsub(regsub(req.http.X-OAuth-Ordered-Url, \".*\\?\", \"\"), \"&oauth_signature=[^&]*\", \"\");\n\tset req.http.X-OAuth-Base-String-Uri = \n\t\tif(req.http.Fastly-SSL, \"https\", \"http\") \n\t\t\":\/\/\"\n\t\tstd.tolower(req.http.host)\n\t\treq.url.path;\n\tset req.http.X-OAuth-Signature-Base-String = \n\t\treq.request\n\t\t\"&\"\n\t\turlencode(req.http.X-OAuth-Base-String-Uri)\n\t\t\"&\"\n\t\turlencode(req.http.X-OAuth-Parameters);\n\n\tset req.http.X-OAuth-Calculated-Signature = digest.hmac_sha1_base64(\n\t\t\treq.http.X-OAuth-Consumer-Secret \"&\" req.http.X-OAuth-Access-Token-Secret, \n\t\t\treq.http.X-OAuth-Signature-Base-String);\n\n\tunset req.http.X-OAuth-Consumer-Secret;\n\tunset req.http.X-OAuth-Access-Token-Secret;\n\tunset req.http.X-OAuth-Base-String-Uri;\n\n\tif(req.http.X-OAuth-Provided-Signature != req.http.X-OAuth-Calculated-Signature) {\n\t\terror 401 \"Invalid OAuth Signature\";\n\t}\n\n\terror 200 \"Authenticated!\";\n\n\treturn(lookup);\n}\n\nsub vcl_fetch {\n#FASTLY fetch\n\treturn(deliver);\n}\n\nsub vcl_hit {\n#FASTLY hit\n\tif (!obj.cacheable) {\n\t\treturn(pass);\n\t}\n\treturn(deliver);\n}\n\nsub vcl_miss {\n#FASTLY miss\n\treturn(fetch);\n}\n\nsub vcl_deliver{\n#FASTLY deliver\n\t# Expose variables for debugging\n\tset resp.http.X-OAuth-Consumer-Key = req.http.X-OAuth-Consumer-Key;\n\tset resp.http.X-OAuth-Access-Token = req.http.X-OAuth-Access-Token;\n\tset resp.http.X-OAuth-Provided-Signature = req.http.X-OAuth-Provided-Signature;\n\tset resp.http.X-OAuth-Calculated-Signature = req.http.X-OAuth-Calculated-Signature;\n\tset resp.http.X-OAuth-Parameters = req.http.X-OAuth-Parameters;\n\tset resp.http.X-OAuth-Signature-Base-String = req.http.X-OAuth-Signature-Base-String;\n\treturn(deliver);\n}\n\nsub vcl_error {\n#FASTLY error\n#DEPLOY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n","old_contents":"\ntable consumer_secrets {\n\t\"foo\": \"super_secret\"\n}\n\ntable access_tokens {\n\t\"bar\": \"token_secret\"\n}\n\nsub vcl_recv {\n#FASTLY recv\n#DEPLOY recv\n\tset req.http.X-Consumer-Key = if(req.url ~ \"(?i)oauth_consumer_key=([^&]*)\", urldecode(re.group.1), \"\");\n\tif(req.http.X-Consumer-Key == \"\") {\n\t\terror 401 \"Missing Consumer Key\";\n\t}\n\tset req.http.X-Consumer-Secret = table.lookup(consumer_secrets, req.http.X-Consumer-Key);\n\tif(!req.http.X-Consumer-Secret) {\n\t\terror 401 \"Invalid Consumer Key\";\n\t}\n\tset req.http.X-Access-Token = if(req.url ~ \"(?i)oauth_token=([^&]*)\", urldecode(re.group.1), \"\");\n\tif(req.http.X-Access-Token != \"\") {\n\t\tset req.http.X-Access-Token-Secret = table.lookup(access_tokens, req.http.X-Access-Token);\n\t\tif(!req.http.X-Access-Token-Secret) {\n\t\t\terror 401 \"Invalid Access Token\";\n\t\t}\n\t} else {\n\t\tset req.http.X-Access-Token-Secret = \"\";\n\t}\n\tset req.http.X-Provided-Signature = if(req.url ~ \"(?i)oauth_signature=([^&]*)\", urldecode(re.group.1), \"\");\n\tif(req.http.X-Provided-Signature == \"\") {\n\t\terror 401 \"Missing Signature\";\n\t}\n\tset req.http.X-Ordered-Url = boltsort.sort(req.url);\n\tset req.http.X-Parameters = regsub(regsub(req.http.X-Ordered-Url, \".*\\?\", \"\"), \"&oauth_signature=[^&]*\", \"\");\n\tset req.http.X-Base-String-Uri = \n\t\tif(req.http.Fastly-SSL, \"https\", \"http\") \n\t\t\":\/\/\"\n\t\tstd.tolower(req.http.host)\n\t\treq.url.path;\n\tset req.http.X-Signature-Base-String = \n\t\treq.request\n\t\t\"&\"\n\t\turlencode(req.http.X-Base-String-Uri)\n\t\t\"&\"\n\t\turlencode(req.http.X-Parameters);\n\n\tset req.http.X-Calculated-Signature = digest.hmac_sha1_base64(\n\t\t\treq.http.X-Consumer-Secret \"&\" req.http.X-Access-Token-Secret, \n\t\t\treq.http.X-Signature-Base-String);\n\n\tunset req.http.X-Consumer-Secret;\n\tunset req.http.X-Access-Token-Scret;\n\tunset req.http.X-Base-String-Uri;\n\n\tif(req.http.X-Provided-Signature != req.http.X-Calculated-Signature) {\n\t\terror 401 \"Invalid OAuth Signature\";\n\t}\n\n\terror 200 \"Authenticated!\";\n\n\treturn(lookup);\n}\n\nsub vcl_fetch {\n#FASTLY fetch\n\treturn(deliver);\n}\n\nsub vcl_hit {\n#FASTLY hit\n\tif (!obj.cacheable) {\n\t\treturn(pass);\n\t}\n\treturn(deliver);\n}\n\nsub vcl_miss {\n#FASTLY miss\n\treturn(fetch);\n}\n\nsub vcl_deliver{\n#FASTLY deliver\n\tset resp.http.X-Consumer-Key = req.http.X-Consumer-Key;\n\tset resp.http.X-Access-Token = req.http.X-Access-Token;\n\tset resp.http.X-Provided-Signature = req.http.X-Provided-Signature;\n\tset resp.http.X-Calculated-Signature = req.http.X-Calculated-Signature;\n\tset resp.http.X-Parameters = req.http.X-Parameters;\n\tset resp.http.X-Signature-Base-String = req.http.X-Signature-Base-String;\n\treturn(deliver);\n}\n\nsub vcl_error {\n#FASTLY error\n#DEPLOY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"666958d7edc03557fdd5b5b8b23a8b9e68dcc26b","subject":"Updated synth code","message":"Updated synth code","repos":"NITEMAN\/Varnish_VCL_samps-hacks,NITEMAN\/varnish-bites","old_file":"varnish4\/drupal-base.vcl","new_file":"varnish4\/drupal-base.vcl","new_contents":"\/*\n * Varnish 4 example config for Drupal 7 \/ Pressflow 6 & 7\n *\/\n\n# Original source: https:\/\/github.com\/NITEMAN\/varnish-bites\/varnish4\/drupal-base.vcl\n# Copyright (c) 2015 Pedro Gonz\u00e1lez Serrano and individual contributors.\n# MIT License\n\n# Intended to be used both in simple production environments and with\n# learning\/teaching purposes.\n# Some references may not be yet updated to VCL 4.0, we use SeeV3 then.\n\n# WARNING:\n# Note that the built-in logic will be appended to our code if no return is\n# performed before.\n# Built-in logic is included commented out right after our's for reference\n# purposes in that cases.\n# See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleDefault\n\n#######################################################################\n# Initialization: Version & imports;\n\n\/* Version statement *\/\n# Since Varnish 4.0 it's mandatory to declare VCL version on first line.\nvcl 4.0;\n\n\/* Module (VMOD) imports *\/\n# Standard module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_std.generated.html\nimport std;\n\n# Directors module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# Unused in simple configs.\n#import directors;\n\n\n#######################################################################\n# Probe, backend, ACL and subroutine definitions\n\n\/* Backend probes \/ healthchecks *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#probes\nprobe basic {\n \/* Only test that backend's IP serves content for '\/' *\/\n # This might be a too heavy probe\n # .url = \"\/\";\n\n \/* Only test that backend's IP has apache working *\/\n # Nginx would fail this probe with a default config\n .request =\n \"OPTIONS * HTTP\/1.1\"\n \"Host: *\"\n \"Connection: close\";\n\n \/* Common options *\/\n .interval = 10s;\n .timeout = 2s;\n .window = 8;\n .threshold = 6;\n}\n\n\/* Backend definitions.*\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#backend-definition\nbackend default {\n \/* Default backend on the same machine. *\/\n # WARNING: timeouts could be not big enought for certain POST requests.\n .host = \"127.0.0.1\";\n .port = \"8008\";\n .max_connections = 100;\n .connect_timeout = 60s;\n .first_byte_timeout = 60s;\n .between_bytes_timeout = 60s;\n .probe = basic;\n}\n\n\/* Access Control Lists *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#access-control-list-acl\nacl purge_ban {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use '\"localhost\";' instead\n}\nacl allowed_monitors {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n}\n# acl own_proxys {\n# \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n# }\n\n\/* Custom subroutines *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#subroutines\n#TODO# Test in Varnihs 4\n# Empty in simple configs.\n# The only restriction naming subs is that the 'vlc_' prefix is reserverd for\n# Varnish use. As a task can need several chunks of code in diferent states,\n# it's a good idea to identify what main sub will call each with a suffix.\n# \/* Example 301 client redirection removing \"www\" prefix from request *\/\n# sub perm_redirections_recv {\n# if ( req.http.host ~ \"^www.*$\" ) {\n# return (\n# synth(751, \"http:\/\/\" + regsub(req.http.host, \"^www\\.\", \"\") + req.url)\n# );\n# }\n# }\n# sub perm_redirections_synth {\n# if ( resp.status == 751 ) {\n# \/* Get new URL from the response *\/\n# set resp.http.Location = resp.reason;\n# \/* Set HTTP 301 for permanent redirect *\/\n# set resp.status = 301;\n# set resp.reason = \"Moved Permanently\";\n# return (deliver);\n# }\n# }\n\n\n#######################################################################\n# Client side\n\n# vcl_recv: Called at the beginning of a request, after the complete request\n# has been received and parsed. Its purpose is to decide whether or not to\n# serve the request, how to do it, and, if applicable, which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-recv\nsub vcl_recv {\n \/* 0th: general bypass, general return & authorization checks *\/\n # Empty in simple configs.\n # Useful for debugging we can pipe or pass the request to default backend\n # here to bypass completely Varnish.\n # return (pipe);\n # return (pass);\n # We can also return here a 200 Ok for network performance benchmarking.\n # return (synth(200, \"Ok\"));\n # Finally we can perform basic HTTP authentification here, by example.\n # SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* 1st: Check for Varnish special requests *\/\n # Custom response implementation example in order to check that Varnish is\n # working properly.\n # This is usefull for automatic monitoring with monit or when Varnish is\n # behind another proxies like HAProxy.\n if ( ( req.http.host == \"monitor.server.health\"\n || req.http.host == \"health.varnish\" )\n && client.ip ~ allowed_monitors\n && ( req.method == \"OPTIONS\" || req.method == \"GET\" )\n ) {\n return (synth(200, \"OK\"));\n }\n # Purge logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#http-purging\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if ( req.method == \"PURGE\" ) {\n if ( client.ip !~ purge_ban ) {\n return (synth(405, \"Not allowed.\"));\n }\n return (purge);\n }\n # Ban logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#bans\n if ( req.method == \"BAN\" ) {\n if ( client.ip !~ purge_ban ) {\n return (synth(405, \"Not allowed.\"));\n }\n ban( \"req.http.host == \" + req.http.host +\n \"&& req.url == \" + req.url);\n return (synth(200, \"Ban added\"));\n }\n\n \/* 2nd: Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_recv;\n # Here we can also enforce SSL when Varnish run behind some SSL termination\n # point.\n\n \/* 3rd: Time for backend choice *\/\n # Empty in simple configs.\n\n \/* 4th: Prepare request for the backend *\/\n # Empty in simple configs.\n # Example remove own_proxys from X-Forwarded-For\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/whats-new\/upgrading.html#x-forwarded-for-is-now-set-before-vcl-recv\n # if ( req.restarts == 0\n # && client.ip ~ own_proxys\n # && req.http.x-forwarded-for\n # ) {\n # set req.http.X-Forwarded-For\n # = regsub(req.http.X-Forwarded-For, \",( )?\" + client.ip, \"\");\n # }\n # Example normalize the host header, remove the port (in case you're testing\n # this on various TCP ports)\n # set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n \/* 5th: Bypass breakpoint 1 *\/\n # Useful for debugging we can now pipe or pass the request to backend with\n # headers setted.\n # return (pipe);\n # return (pass);\n\n \/* 6th: Decide if we should deal with a request (mostly from built-in logic) *\/\n if ( req.method == \"PRI\" ) {\n \/* We do not support SPDY or HTTP\/2.0 *\/\n return (synth(405));\n }\n if ( req.method != \"GET\"\n && req.method != \"HEAD\"\n && req.method != \"PUT\"\n && req.method != \"POST\"\n && req.method != \"TRACE\"\n && req.method != \"OPTIONS\"\n && req.method != \"DELETE\"\n ) {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if ( req.method != \"GET\"\n && req.method != \"HEAD\"\n ) {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if ( req.http.Authorization ) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n # Websocket support\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html\n if ( req.http.Upgrade ~ \"(?i)websocket\" ) {\n return (pipe);\n }\n\n \/* 7th: Access control for some URLs by ACL *\/\n # Empty in simple configs.\n # By example denial some URLs depending on client-ip, we'll need to define\n # corresponding ACL 'internal'.\n # if ( req.url ~ \"^\/(cron|install)\\.php\"\n # && client.ip !~ internal\n # ) {\n # # Have Varnish throw the error directly.\n # return (synth(403, \"Forbidden.\"));\n # # Use a custom error page that you've defined in Drupal at the path \"404\".\n # # set req.url = \"\/403\";\n # }\n\n \/* 8th: Custom exceptions *\/\n # Host exception example:\n # if ( req.http.host == \"ejemplo.exception.com\" ) {\n # return (pass);\n # }\n # Drupal exceptions, edit if we want to cache some AJAX\/AHAH request.\n # Add here filters for never cache URLs such as Payment Gateway's callbacks.\n if ( req.url ~ \"^\/status\\.php$\"\n || req.url ~ \"^\/update\\.php$\"\n || req.url ~ \"^\/ooyala\/ping$\"\n || req.url ~ \"^\/admin\/build\/features\"\n || req.url ~ \"^\/info\/.*$\"\n || req.url ~ \"^\/flag\/.*$\"\n || req.url ~ \"^.*\/ajax\/.*$\"\n || req.url ~ \"^.*\/ahah\/.*$\"\n ) {\n \/* Do not cache these paths *\/\n return (pass);\n }\n # Pipe these paths directly to backend for streaming.\n if ( req.url ~ \"^\/admin\/content\/backup_migrate\/export\" ) {\n return (pipe);\n }\n if ( req.url ~ \"^\/system\/files\" ) {\n return (pipe);\n }\n\n \/* 9th: Graced objets & Serve from anonymous cahe if all backends are down *\/\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n # set req.http.grace = \"none\";\n if ( ! std.healthy(req.backend_hint) ) {\n # We must do this here since cookie hashing\n unset req.http.Cookie;\n #TODO# Add sick marker\n }\n\n \/* 10th: Deal with compression and the Accept-Encoding header *\/\n # Althought Varnish 3 handles gziped content itself by default, just to be\n # sure we want to remove Accept-Encoding for some compressed formats.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html#what-does-http-gzip-support-do\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/varnishd.html?highlight=http_gzip_support\n # See (for older configs) https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleNormalizeAcceptEncoding\n if ( req.http.Accept-Encoding ) {\n if ( req.url ~ \"(?i)\\.(7z|avi|bz2|flv|gif|gz|jpe?g|mpe?g|mk[av]|mov|mp[34]|og[gm]|pdf|png|rar|swf|tar|tbz|tgz|woff2?|zip|xz)(\\?.*)?$\"\n ) {\n \/* Already compressed formats, no sense trying to compress again *\/\n unset req.http.Accept-Encoding;\n }\n }\n\n \/* 11th: Further request manipulation *\/\n # Empty in simple configs.\n # We could add here a custom header grouping User-agent families.\n # Generic URL manipulation.\n # Remove Google Analytics added parameters, useless for our backends.\n if ( req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=\" ) {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n # Strip anchors, server doesn't need it.\n if ( req.url ~ \"\\#\" ) {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n # Strip a trailing ? if it exists\n if ( req.url ~ \"\\?$\" ) {\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n # Normalize the querystring arguments\n set req.url = std.querysort(req.url);\n\n \/* 12th: Cookie removal *\/\n # Always cache the following static file types for all users.\n # Use with care if we control certain downloads depending on cookies.\n # Be carefull also if appending .htm[l] via Drupal's clean URLs.\n if ( req.url ~ \"(?i)\\.(bz2|css|eot|gif|gz|html?|ico|jpe?g|js|mp3|ogg|otf|pdf|png|rar|svg|swf|tbz|tgz|ttf|woff2?|zip)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n && req.url !~ \"\/system\/storage\/serve\"\n ) {\n unset req.http.Cookie;\n }\n # Remove all cookies that backend doesn't need to know about.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRemovingSomeCookies\n if ( req.http.Cookie ) {\n \/* Warning: Not a pretty solution *\/\n # Prefix header containing cookies with ';'\n set req.http.Cookie = \";\" + req.http.Cookie;\n # Remove any spaces after ';' in header containing cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n # Prefix cookies we want to preserve with one space:\n # 'S{1,2}ESS[a-z0-9]+' is the regular expression matching a Drupal session\n # cookie ({1,2} added for HTTPS support).\n # 'NO_CACHE' is usually set after a POST request to make sure issuing user\n # see the results of his post.\n # 'OATMEAL' & 'CHOCOLATECHIP' are special cookies used by Drupal's Bakery\n # module to provide Single Sign On.\n # Keep in mind we should add here any cookie that should reach the backend\n # such as splash avoiding cookies.\n set req.http.Cookie\n = regsuball(\n req.http.Cookie,\n \";(S{1,2}ESS[a-z0-9]+|NO_CACHE|OATMEAL|CHOCOLATECHIP)=\",\n \"; \\1=\"\n );\n # Remove from the header any single Cookie not prefixed with a space until\n # next ';' separator.\n set req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n # Remove any '; ' at the start or the end of the header.\n set req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n #If there are no remaining cookies, remove the cookie header.\n if ( req.http.Cookie == \"\" ) {\n unset req.http.Cookie;\n }\n }\n\n \/* 13th: Session cookie & special cookies bypass caching stage *\/\n # As we might want to cache some requests, hashed with its cookies, we don't\n # simply pass when some cookies remain present at this point.\n # Instead we look for request that must be passed due to the cookie header.\n if ( req.http.Cookie ~ \"SESS\"\n || req.http.Cookie ~ \"SSESS\"\n || req.http.Cookie ~ \"NO_CACHE\"\n || req.http.Cookie ~ \"OATMEAL\"\n || req.http.Cookie ~ \"CHOCOLATECHIP\"\n ) {\n return (pass);\n }\n\n \/* 14th: Announce ESI Support *\/\n # Empty in simple configs.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/esi.html\n # Note that ESI included requests inherits its parent's modified request, so\n # depending on the case you will end playing with req.esi_level to know\n # current depth.\n # Send Surrogate-Capability headers\n # See http:\/\/www.w3.org\/TR\/edge-arch\n # Note that myproxyname is an identifier that should avoid collitions\n # set req.http.Surrogate-Capability = \"myproxyname=ESI\/1.0\";\n\n \/* 15th: Bypass breakpoint 2 *\/\n # Useful for debugging we can now pipe or pass the request to backend to\n # bypass cache.\n # return (pipe);\n # return (pass);\n\n \/* 16th: Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n return (hash);\n}\n\n# vcl_pipe: Called upon entering pipe mode.\n# In this mode, the request is passed on to the backend, and any further data\n# from either client or backend is passed on unaltered until either end closes\n# the connection.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pipe\nsub vcl_pipe {\n # Websocket support\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html\n if ( req.http.upgrade ) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n}\n# sub vcl_pipe {\n# # By default Connection: close is set on all piped requests, to stop\n# # connection reuse from sending future requests directly to the\n# # (potentially) wrong backend. If you do want this to happen, you can undo\n# # it here.\n# # unset bereq.http.connection;\n# return (pipe);\n# }\n\n# vcl_pass: Called upon entering pass mode.\n# In this mode, the request is passed on to the backend, and the backend's\n# response is passed on to the client, but is not entered into the cache.\n# Subsequent requests submitted over the same client connection are handled normally.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pass\n# sub vcl_pass {\n# return (fetch);\n# }\n\n# vcl_hash: You may call hash_data() on the data you would like to add to the\n# hash.\n# Hash is used by Varnish to uniquely identify objects.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hash\nsub vcl_hash {\n \/* Hash cookie data *\/\n # As requests with same URL and host can produce diferent results when issued\n # with different cookies, we need to store items hashed with the associated\n # cookies. Note that cookies are already sanitized when we reach this point.\n if ( req.http.Cookie ) {\n \/* Include cookie in cache hash *\/\n hash_data(req.http.Cookie);\n }\n\n \/* Custom header hashing *\/\n # Empty in simple configs.\n # Example for caching differents object versions by device previously\n # detected (when static content could also vary):\n # if ( req.http.X-UA-Device ) {\n # hash_data(req.http.X-UA-Device);\n # }\n # Example for caching diferent object versions by X-Forwarded-Proto, trying\n # to be smart about what kind of request could generate diffetent responses.\n if ( req.http.X-Forwarded-Proto\n && req.url !~ \"(?i)\\.(bz2|css|eot|gif|gz|html?|ico|jpe?g|js|mp3|ogg|otf|pdf|png|rar|svg|swf|tbz|tgz|ttf|woff2?|zip)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n ) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (lookup);\n# }\n\n# vcl_purge: Called after the purge has been executed and all its variants have\n# been evited.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-purge\n# sub vcl_purge {\n# return (synth(200, \"Purged\"));\n# }\n\n# vcl_hit: Called after a cache lookup if the requested document was found in\n# the cache.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hit\nsub vcl_hit {\n if ( obj.ttl >= 0s ) {\n \/\/ A pure unadultered hit, deliver it\n return (deliver);\n }\n \/* Allow varnish to serve up stale content if it is responding slowly *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n if ( obj.ttl + 60s > 0s ) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n set req.http.grace = \"normal\";\n return (deliver);\n }\n \/* Allow varish to serve up stale content if all backends are down *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n if ( ! std.healthy(req.backend_hint)\n && obj.ttl + obj.grace > 0s\n ) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n set req.http.grace = \"extended\";\n return (deliver);\n }\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\n# vcl_miss: Called after a cache lookup if the requested document was not found\n# in the cache.\n# Its purpose is to decide whether or not to attempt to retrieve the document\n# from the backend, and which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-miss\n# sub vcl_miss {\n# return (fetch);\n# }\n\n# vcl_deliver: Called before an object is delivered to the client\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-deliver\nsub vcl_deliver {\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # Add whether the object is a cache hit or miss and the number of hits for\n # the object.\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Addingaheaderindicatinghitmiss\n # In Varnish 4 the obj.hits counter behaviour has changed (see bug 1492), so\n # we use a different method: if X-Varnish contains only 1 id, we have a miss,\n # if it contains more (and therefore a space), we have a hit.\n if ( resp.http.x-varnish ~ \" \" ) {\n set resp.http.X-Cache = \"HIT\";\n # Since in Varnish 4 the behaviour of obj.hits changed, this might not be\n # accurate.\n # See https:\/\/www.varnish-cache.org\/trac\/ticket\/1492\n set resp.http.X-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Cache = \"MISS\";\n \/* Show the results of cookie sanitization *\/\n set resp.http.X-Cookie = req.http.Cookie;\n }\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n set resp.http.grace = req.http.grace;\n\n #TODO# Add sick marker\n\n # Restart count\n if ( req.restarts > 0 ) {\n set resp.http.X-Restarts = req.restarts;\n }\n\n # Add the Varnish server hostname\n set resp.http.X-Varnish-Server = server.hostname;\n # If we have setted a custom header with device's family detected we can show\n # it:\n # if ( req.http.X-UA-Device ) {\n # set resp.http.X-UA-Device = req.http.X-UA-Device;\n # }\n # If we have recived a custom header indicating the protocol in the request we\n # can show it:\n # if ( req.http.X-Forwarded-Proto ) {\n # set resp.http.X-Forwarded-Proto = req.http.X-Forwarded-Proto;\n # }\n\n \/* Vary header manipulation *\/\n # Empty in simple configs.\n # By example, if we are storing & serving diferent objects depending on\n # User-Agent header we must set the correct Vary header:\n # if ( resp.http.Vary ) {\n # set resp.http.Vary = resp.http.Vary + \",User-Agent\";\n # } else {\n # set resp.http.Vary = \"User-Agent\";\n # }\n\n \/* Fake headers *\/\n # Empty in simple configs\n # We can fake server headers here, by example:\n # set resp.http.Server = \"Deep thought\";\n # set resp.http.X-Powered-By = \"BOFH\";\n # Or have some fun with headers:\n # See http:\/\/www.nextthing.org\/archives\/2005\/08\/07\/fun-with-http-headers\n # See http:\/\/royal.pingdom.com\/2012\/08\/15\/fun-and-unusual-http-response-headers\/\n # set resp.http.X-Thank-You = \"for bothering to look at my HTTP headers\";\n # set resp.http.X-Answer = \"42\";\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_deliver {\n# return (deliver);\n# }\n\n# vcl_synth: Called to deliver a synthetic object. A synthetic object is\n# generated in VCL, not fetched from the backend. It is typically contructed\n# using the synthetic() function.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-synth\n\/*\n * We can come here \"invisibly\" with the following errors: 413, 417 & 503\n *\/\nsub vcl_synth {\n \/* Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_synth;\n\n \/* Try to restart request in case of failure *\/\n # Note that max_restarts defaults to 4\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if ( resp.status == 503\n && req.restarts < 4\n ) {\n return (restart);\n }\n\n \/* Set common headers for synthetic responses *\/\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n\n \/* HTTP Authentification client request *\/\n # Empty in simple configs.\n # SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* Load synthetic responses from disk *\/\n # Note that files loaded this way are never re-readed (even after a reload).\n # You should consider PROS\/CONS of doing an include instead.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_std.generated.html#func-fileread\n # Example custom 403 error page.\n # if ( resp.status == 403 ) {\n # synthetic(std.fileread(\"\/403.html\"));\n # return (deliver);\n # }\n\n \/* Error page & refresh \/ redirections *\/\n # We have plenty of choices when we have to serve an error to the client,\n # from the default error page to javascript black magic or plain redirections.\n # Adding some external statistic javascript to track failures served to\n # clients is strongly suggested.\n # We can't use external resources on synthetic content, everything must be\n # inlined.\n # If we need to include images we can embed them in base64 encoding.\n # We're using error 200 for monitoring puposes which should not be retried\n # client side.\n if ( resp.status != 200 ) {\n set resp.http.Retry-After = \"5\";\n }\n\n # Here is the default error page for Varnish 4 (not so pretty)\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n return (deliver);\n}\n\n#######################################################################\n# Backend Fetch\n\n# vcl_backend_fetch: Called before sending the backend request. In this\n# subroutine you typically alter the request before it gets to the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-fetch\n# sub vcl_backend_fetch {\n# return (fetch);\n# }\n\n# vcl_backend_response: Called after the response headers has been successfully\n# retrieved from the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-response\nsub vcl_backend_response {\n \/* Caching exceptions *\/\n # Varnish will cache objects with response codes:\n # 200, 203, 300, 301, 302, 307, 404 & 410.\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/VCL_Basics.html#the-initial-value-of-beresp-ttl\n # Drupal's Imagecache module can return a 307 redirection to the requested\n # url itself and, depending on Drupal's cache settings, this could lead to a\n # redirection loop being cached for a long time but also we want Varnish to\n # shield a little the backend.\n # See http:\/\/drupal.org\/node\/1248010\n # See http:\/\/drupal.org\/node\/310656\n if ( beresp.status == 307\n #TODO# verify that this work better than 'bereq.url ~ \"imagecache\"'\n && beresp.http.Location == bereq.url\n && beresp.ttl > 5s\n ) {\n set beresp.ttl = 5s;\n set beresp.http.cache-control = \"max-age=5\";\n }\n\n \/* Request retrial *\/\n if ( beresp.status == 500\n || beresp.status == 503\n ) {\n #TODO# consider not restarting POST requests as seenV3 on https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleSaintMode\n return (retry);\n }\n\n \/* Enable grace mode. Related with vcl_hit *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n set beresp.grace = 1h;\n\n \/* Strip cookies from the following static file types for all users. *\/\n # Related with our 12th stage on vcl_recv\n if ( bereq.url ~ \"(?i)\\.(bz2|css|eot|gif|gz|html?|ico|jpe?g|js|mp3|ogg|otf|pdf|png|rar|svg|swf|tbz|tgz|ttf|woff2?|zip)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n ) {\n unset beresp.http.set-cookie;\n }\n\n \/* Process ESI responses *\/\n # Empty in simple configs.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/esi.html\n # Send Surrogate-Capability headers\n # See http:\/\/www.w3.org\/TR\/edge-arch\n # Note that myproxyname is an identifier that should avoid collitions\n # Check for ESI acknowledgement and remove Surrogate-Control header\n #TODO# Add support for Surrogate-Control Targetting\n # if ( beresp.http.Surrogate-Control ~ \"ESI\/1.0\" ) {\n # unset beresp.http.Surrogate-Control;\n # set beresp.do_esi = true;\n # }\n\n \/* Gzip response *\/\n # Empty in simple configs.\n # Use Varnish to Gzip respone, if suitable, before storing it on cache.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html\n if ( ! beresp.http.Content-Encoding\n && ( beresp.http.content-type ~ \"text\"\n || beresp.http.content-type ~ \"application\/x-javascript\"\n || beresp.http.content-type ~ \"application\/javascript\"\n || beresp.http.content-type ~ \"application\/rss+xml\"\n || beresp.http.content-type ~ \"application\/xml\"\n || beresp.http.content-type ~ \"Application\/JSON\")\n ) {\n set beresp.do_gzip = true;\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # We can add the name of the backend that has processed the request:\n # set beresp.http.X-Backend = beresp.backend.name;\n # We can use a header to tell if the object was gziped by Varnish:\n # if ( beresp.do_gzip ) {\n # set beresp.http.X-Varnish-Gzipped = \"yes\";\n # } else {\n # set beresp.http.X-Varnish-Gizipped = \"no\";\n # }\n # We can do the same to tell if Varnish is streaming it:\n # if ( beresp.do_stream ) {\n # set beresp.http.X-Varnish-Streaming = \"yes\";\n # } else {\n # set beresp.http.X-Varnish-Streaming = \"no\";\n # }\n # We can also add headers informing whether the object is cacheable or not and why:\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Varnish3.0\n if ( beresp.ttl <= 0s ) {\n \/* Varnish determined the object was not cacheable *\/\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n } elsif ( bereq.http.Cookie ~ \"(SESS|SSESS|NO_CACHE|OATMEAL|CHOCOLATECHIP)\" ) {\n \/* We don't wish to cache content for logged in users or with certain cookies. *\/\n # Related with our 9th stage on vcl_recv\n set beresp.http.X-Cacheable = \"NO:Cookies\";\n # set beresp.uncacheable = true;\n } elsif ( beresp.http.Cache-Control ~ \"private\" ) {\n \/* We are respecting the Cache-Control=private header from the backend *\/\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n # set beresp.uncacheable = true;\n } else {\n \/* Varnish determined the object was cacheable *\/\n set beresp.http.X-Cacheable = \"YES\";\n }\n\n \/* Further header manipulation *\/\n # Empty in simple configs.\n # We can also unset some headers to prevent information disclosure and save\n # some cache space.\n # unset beresp.http.Server;\n # unset beresp.http.X-Powered-By;\n # Retry count.\n if ( bereq.retries > 0 ) {\n set beresp.http.X-Retries = bereq.retries;\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_backend_response {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Surrogate-control ~ \"no-store\" ||\n# (!beresp.http.Surrogate-Control &&\n# beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n# beresp.http.Vary == \"*\") {\n# \/*\n# * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# *\/\n# set beresp.ttl = 120s;\n# set beresp.uncacheable = true;\n# }\n# return (deliver);\n# }\n\n# vcl_backend_error: This subroutine is called if we fail the backend fetch.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-error\nsub vcl_backend_error {\n\n \/* Try to restart request in case of failure *\/\n #TODO# Confirm max_retries default value\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if ( bereq.retries < 4 ) {\n return (retry);\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # Retry count\n if ( bereq.retries > 0 ) {\n set beresp.http.X-Retries = bereq.retries;\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + beresp.status + \" \" + beresp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + beresp.status + \" \" + beresp.reason + {\"<\/h1>\n <p>\"} + beresp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + bereq.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this\n # point.\n return (deliver);\n}\n\n#######################################################################\n# Housekeeping\n\n# vcl_init: Called when VCL is loaded, before any requests pass through it.\n# Typically used to initialize VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-init\n# Here is where you should declare your directors now.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-backends.html#directors\n# Empty in simple configs\n# sub vcl_init {\n# return (ok);\n# }\n\n# vcl_fini: Called when VCL is discarded only after all requests have exited\n# the VCL. Typically used to clean up VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-fini\n# sub vcl_fini {\n# return (ok);\n# }\n","old_contents":"\/*\n * Varnish 4 example config for Drupal 7 \/ Pressflow 6 & 7\n *\/\n\n# Original source: https:\/\/github.com\/NITEMAN\/varnish-bites\/varnish4\/drupal-base.vcl\n# Copyright (c) 2015 Pedro Gonz\u00e1lez Serrano and individual contributors.\n# MIT License\n\n# Intended to be used both in simple production environments and with\n# learning\/teaching purposes.\n# Some references may not be yet updated to VCL 4.0, we use SeeV3 then.\n\n# WARNING:\n# Note that the built-in logic will be appended to our code if no return is\n# performed before.\n# Built-in logic is included commented out right after our's for reference\n# purposes in that cases.\n# See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleDefault\n\n#######################################################################\n# Initialization: Version & imports;\n\n\/* Version statement *\/\n# Since Varnish 4.0 it's mandatory to declare VCL version on first line.\nvcl 4.0;\n\n\/* Module (VMOD) imports *\/\n# Standard module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_std.generated.html\nimport std;\n\n# Directors module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# Unused in simple configs.\n#import directors;\n\n\n#######################################################################\n# Probe, backend, ACL and subroutine definitions\n\n\/* Backend probes \/ healthchecks *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#probes\nprobe basic {\n \/* Only test that backend's IP serves content for '\/' *\/\n # This might be a too heavy probe\n # .url = \"\/\";\n\n \/* Only test that backend's IP has apache working *\/\n # Nginx would fail this probe with a default config\n .request =\n \"OPTIONS * HTTP\/1.1\"\n \"Host: *\"\n \"Connection: close\";\n\n \/* Common options *\/\n .interval = 10s;\n .timeout = 2s;\n .window = 8;\n .threshold = 6;\n}\n\n\/* Backend definitions.*\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#backend-definition\nbackend default {\n \/* Default backend on the same machine. *\/\n # WARNING: timeouts could be not big enought for certain POST requests.\n .host = \"127.0.0.1\";\n .port = \"8008\";\n .max_connections = 100;\n .connect_timeout = 60s;\n .first_byte_timeout = 60s;\n .between_bytes_timeout = 60s;\n .probe = basic;\n}\n\n\/* Access Control Lists *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#access-control-list-acl\nacl purge_ban {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use '\"localhost\";' instead\n}\nacl allowed_monitors {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n}\n# acl own_proxys {\n# \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n# }\n\n\/* Custom subroutines *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#subroutines\n#TODO# Test in Varnihs 4\n# Empty in simple configs.\n# The only restriction naming subs is that the 'vlc_' prefix is reserverd for\n# Varnish use. As a task can need several chunks of code in diferent states,\n# it's a good idea to identify what main sub will call each with a suffix.\n# \/* Example 301 client redirection removing \"www\" prefix from request *\/\n# sub perm_redirections_recv {\n# if ( req.http.host ~ \"^www.*$\" ) {\n# return (\n# synth(751, \"http:\/\/\" + regsub(req.http.host, \"^www\\.\", \"\") + req.url)\n# );\n# }\n# }\n# sub perm_redirections_synth {\n# if ( resp.status == 751 ) {\n# \/* Get new URL from the response *\/\n# set resp.http.Location = resp.response;\n# \/* Set HTTP 301 for permanent redirect *\/\n# set resp.status = 301;\n# return (deliver);\n# }\n# }\n\n\n#######################################################################\n# Client side\n\n# vcl_recv: Called at the beginning of a request, after the complete request\n# has been received and parsed. Its purpose is to decide whether or not to\n# serve the request, how to do it, and, if applicable, which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-recv\nsub vcl_recv {\n \/* 0th: general bypass, general return & authorization checks *\/\n # Empty in simple configs.\n # Useful for debugging we can pipe or pass the request to default backend\n # here to bypass completely Varnish.\n # return (pipe);\n # return (pass);\n # We can also return here a 200 Ok for network performance benchmarking.\n # return (synth(200, \"Ok\"));\n # Finally we can perform basic HTTP authentification here, by example.\n # SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* 1st: Check for Varnish special requests *\/ \n # Custom response implementation example in order to check that Varnish is\n # working properly.\n # This is usefull for automatic monitoring with monit or when Varnish is\n # behind another proxies like HAProxy.\n if ( ( req.http.host == \"monitor.server.health\"\n || req.http.host == \"health.varnish\" )\n && client.ip ~ allowed_monitors\n && ( req.method == \"OPTIONS\" || req.method == \"GET\" )\n ) {\n return (synth(200, \"OK\"));\n }\n # Purge logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#http-purging\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if ( req.method == \"PURGE\" ) {\n if ( client.ip !~ purge_ban ) {\n return (synth(405, \"Not allowed.\"));\n }\n return (purge);\n }\n # Ban logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#bans\n if ( req.method == \"BAN\" ) {\n if ( client.ip !~ purge_ban ) {\n return (synth(405, \"Not allowed.\"));\n }\n ban( \"req.http.host == \" + req.http.host +\n \"&& req.url == \" + req.url);\n return (synth(200, \"Ban added\"));\n }\n\n \/* 2nd: Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_recv;\n # Here we can also enforce SSL when Varnish run behind some SSL termination\n # point.\n\n \/* 3rd: Time for backend choice *\/\n # Empty in simple configs.\n\n \/* 4th: Prepare request for the backend *\/\n # Empty in simple configs.\n # Example remove own_proxys from X-Forwarded-For\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/whats-new\/upgrading.html#x-forwarded-for-is-now-set-before-vcl-recv\n # if ( req.restarts == 0\n # && client.ip ~ own_proxys\n # && req.http.x-forwarded-for\n # ) {\n # set req.http.X-Forwarded-For\n # = regsub(req.http.X-Forwarded-For, \",( )?\" + client.ip, \"\");\n # }\n # Example normalize the host header, remove the port (in case you're testing\n # this on various TCP ports)\n # set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n \/* 5th: Bypass breakpoint 1 *\/\n # Useful for debugging we can now pipe or pass the request to backend with\n # headers setted.\n # return (pipe);\n # return (pass);\n\n \/* 6th: Decide if we should deal with a request (mostly from built-in logic) *\/\n if ( req.method == \"PRI\" ) {\n \/* We do not support SPDY or HTTP\/2.0 *\/\n return (synth(405));\n }\n if ( req.method != \"GET\"\n && req.method != \"HEAD\"\n && req.method != \"PUT\"\n && req.method != \"POST\"\n && req.method != \"TRACE\"\n && req.method != \"OPTIONS\"\n && req.method != \"DELETE\"\n ) {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if ( req.method != \"GET\"\n && req.method != \"HEAD\"\n ) {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if ( req.http.Authorization ) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n # Websocket support\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html\n if ( req.http.Upgrade ~ \"(?i)websocket\" ) {\n return (pipe);\n }\n\n \/* 7th: Access control for some URLs by ACL *\/\n # Empty in simple configs.\n # By example denial some URLs depending on client-ip, we'll need to define\n # corresponding ACL 'internal'.\n # if ( req.url ~ \"^\/(cron|install)\\.php\"\n # && client.ip !~ internal\n # ) {\n # # Have Varnish throw the error directly.\n # return (synth(403, \"Forbidden.\"));\n # # Use a custom error page that you've defined in Drupal at the path \"404\".\n # # set req.url = \"\/403\";\n # }\n\n \/* 8th: Custom exceptions *\/\n # Host exception example:\n # if ( req.http.host == \"ejemplo.exception.com\" ) {\n # return (pass);\n # }\n # Drupal exceptions, edit if we want to cache some AJAX\/AHAH request.\n # Add here filters for never cache URLs such as Payment Gateway's callbacks.\n if ( req.url ~ \"^\/status\\.php$\"\n || req.url ~ \"^\/update\\.php$\"\n || req.url ~ \"^\/ooyala\/ping$\"\n || req.url ~ \"^\/admin\/build\/features\"\n || req.url ~ \"^\/info\/.*$\"\n || req.url ~ \"^\/flag\/.*$\"\n || req.url ~ \"^.*\/ajax\/.*$\"\n || req.url ~ \"^.*\/ahah\/.*$\"\n ) {\n \/* Do not cache these paths *\/\n return (pass);\n }\n # Pipe these paths directly to backend for streaming.\n if ( req.url ~ \"^\/admin\/content\/backup_migrate\/export\" ) {\n return (pipe);\n }\n if ( req.url ~ \"^\/system\/files\" ) {\n return (pipe);\n }\n\n \/* 9th: Graced objets & Serve from anonymous cahe if all backends are down *\/\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n # set req.http.grace = \"none\";\n if ( ! std.healthy(req.backend_hint) ) {\n # We must do this here since cookie hashing\n unset req.http.Cookie;\n #TODO# Add sick marker\n } \n\n \/* 10th: Deal with compression and the Accept-Encoding header *\/\n # Althought Varnish 3 handles gziped content itself by default, just to be\n # sure we want to remove Accept-Encoding for some compressed formats.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html#what-does-http-gzip-support-do\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/varnishd.html?highlight=http_gzip_support\n # See (for older configs) https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleNormalizeAcceptEncoding\n if ( req.http.Accept-Encoding ) {\n if ( req.url ~ \"(?i)\\.(7z|avi|bz2|flv|gif|gz|jpe?g|mpe?g|mk[av]|mov|mp[34]|og[gm]|pdf|png|rar|swf|tar|tbz|tgz|woff2?|zip|xz)(\\?.*)?$\"\n ) {\n \/* Already compressed formats, no sense trying to compress again *\/\n unset req.http.Accept-Encoding;\n }\n }\n\n \/* 11th: Further request manipulation *\/\n # Empty in simple configs.\n # We could add here a custom header grouping User-agent families.\n # Generic URL manipulation.\n # Remove Google Analytics added parameters, useless for our backends.\n if ( req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=\" ) {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n # Strip anchors, server doesn't need it.\n if ( req.url ~ \"\\#\" ) {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n # Strip a trailing ? if it exists\n if ( req.url ~ \"\\?$\" ) {\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n # Normalize the querystring arguments\n set req.url = std.querysort(req.url);\n\n \/* 12th: Cookie removal *\/\n # Always cache the following static file types for all users. \n # Use with care if we control certain downloads depending on cookies. \n # Be carefull also if appending .htm[l] via Drupal's clean URLs.\n if ( req.url ~ \"(?i)\\.(bz2|css|eot|gif|gz|html?|ico|jpe?g|js|mp3|ogg|otf|pdf|png|rar|svg|swf|tbz|tgz|ttf|woff2?|zip)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n && req.url !~ \"\/system\/storage\/serve\"\n ) {\n unset req.http.Cookie;\n }\n # Remove all cookies that backend doesn't need to know about.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRemovingSomeCookies\n if ( req.http.Cookie ) {\n \/* Warning: Not a pretty solution *\/\n # Prefix header containing cookies with ';'\n set req.http.Cookie = \";\" + req.http.Cookie;\n # Remove any spaces after ';' in header containing cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n # Prefix cookies we want to preserve with one space:\n # 'S{1,2}ESS[a-z0-9]+' is the regular expression matching a Drupal session\n # cookie ({1,2} added for HTTPS support).\n # 'NO_CACHE' is usually set after a POST request to make sure issuing user\n # see the results of his post.\n # 'OATMEAL' & 'CHOCOLATECHIP' are special cookies used by Drupal's Bakery\n # module to provide Single Sign On.\n # Keep in mind we should add here any cookie that should reach the backend\n # such as splash avoiding cookies.\n set req.http.Cookie\n = regsuball(\n req.http.Cookie,\n \";(S{1,2}ESS[a-z0-9]+|NO_CACHE|OATMEAL|CHOCOLATECHIP)=\",\n \"; \\1=\"\n );\n # Remove from the header any single Cookie not prefixed with a space until\n # next ';' separator.\n set req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n # Remove any '; ' at the start or the end of the header.\n set req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n #If there are no remaining cookies, remove the cookie header.\n if ( req.http.Cookie == \"\" ) {\n unset req.http.Cookie;\n }\n }\n\n \/* 13th: Session cookie & special cookies bypass caching stage *\/\n # As we might want to cache some requests, hashed with its cookies, we don't\n # simply pass when some cookies remain present at this point.\n # Instead we look for request that must be passed due to the cookie header.\n if ( req.http.Cookie ~ \"SESS\"\n || req.http.Cookie ~ \"SSESS\"\n || req.http.Cookie ~ \"NO_CACHE\"\n || req.http.Cookie ~ \"OATMEAL\"\n || req.http.Cookie ~ \"CHOCOLATECHIP\"\n ) {\n return (pass);\n }\n\n \/* 14th: Announce ESI Support *\/\n # Empty in simple configs.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/esi.html\n # Note that ESI included requests inherits its parent's modified request, so\n # depending on the case you will end playing with req.esi_level to know\n # current depth.\n # Send Surrogate-Capability headers\n # See http:\/\/www.w3.org\/TR\/edge-arch\n # Note that myproxyname is an identifier that should avoid collitions\n # set req.http.Surrogate-Capability = \"myproxyname=ESI\/1.0\";\n\n \/* 15th: Bypass breakpoint 2 *\/\n # Useful for debugging we can now pipe or pass the request to backend to\n # bypass cache.\n # return (pipe);\n # return (pass);\n\n \/* 16th: Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n return (hash);\n}\n\n# vcl_pipe: Called upon entering pipe mode.\n# In this mode, the request is passed on to the backend, and any further data\n# from either client or backend is passed on unaltered until either end closes\n# the connection.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pipe\nsub vcl_pipe {\n # Websocket support\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html\n if ( req.http.upgrade ) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n}\n# sub vcl_pipe {\n# # By default Connection: close is set on all piped requests, to stop\n# # connection reuse from sending future requests directly to the\n# # (potentially) wrong backend. If you do want this to happen, you can undo\n# # it here.\n# # unset bereq.http.connection;\n# return (pipe);\n# }\n\n# vcl_pass: Called upon entering pass mode. \n# In this mode, the request is passed on to the backend, and the backend's\n# response is passed on to the client, but is not entered into the cache.\n# Subsequent requests submitted over the same client connection are handled normally.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pass\n# sub vcl_pass {\n# return (fetch);\n# }\n\n# vcl_hash: You may call hash_data() on the data you would like to add to the\n# hash.\n# Hash is used by Varnish to uniquely identify objects.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hash\nsub vcl_hash {\n \/* Hash cookie data *\/\n # As requests with same URL and host can produce diferent results when issued\n # with different cookies, we need to store items hashed with the associated\n # cookies. Note that cookies are already sanitized when we reach this point.\n if ( req.http.Cookie ) {\n \/* Include cookie in cache hash *\/\n hash_data(req.http.Cookie);\n }\n\n \/* Custom header hashing *\/\n # Empty in simple configs.\n # Example for caching differents object versions by device previously\n # detected (when static content could also vary):\n # if ( req.http.X-UA-Device ) {\n # hash_data(req.http.X-UA-Device);\n # }\n # Example for caching diferent object versions by X-Forwarded-Proto, trying\n # to be smart about what kind of request could generate diffetent responses.\n if ( req.http.X-Forwarded-Proto\n && req.url !~ \"(?i)\\.(bz2|css|eot|gif|gz|html?|ico|jpe?g|js|mp3|ogg|otf|pdf|png|rar|svg|swf|tbz|tgz|ttf|woff2?|zip)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n ) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (lookup);\n# }\n\n# vcl_purge: Called after the purge has been executed and all its variants have\n# been evited.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-purge\n# sub vcl_purge {\n# return (synth(200, \"Purged\"));\n# }\n\n# vcl_hit: Called after a cache lookup if the requested document was found in\n# the cache.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hit\nsub vcl_hit {\n if ( obj.ttl >= 0s ) {\n \/\/ A pure unadultered hit, deliver it\n return (deliver);\n }\n \/* Allow varnish to serve up stale content if it is responding slowly *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n if ( obj.ttl + 60s > 0s ) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n set req.http.grace = \"normal\";\n return (deliver);\n }\n \/* Allow varish to serve up stale content if all backends are down *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n if ( ! std.healthy(req.backend_hint)\n && obj.ttl + obj.grace > 0s\n ) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n set req.http.grace = \"extended\";\n return (deliver);\n }\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\n# vcl_miss: Called after a cache lookup if the requested document was not found\n# in the cache.\n# Its purpose is to decide whether or not to attempt to retrieve the document\n# from the backend, and which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-miss\n# sub vcl_miss {\n# return (fetch);\n# }\n\n# vcl_deliver: Called before an object is delivered to the client\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-deliver\nsub vcl_deliver {\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # Add whether the object is a cache hit or miss and the number of hits for\n # the object.\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Addingaheaderindicatinghitmiss\n # In Varnish 4 the obj.hits counter behaviour has changed (see bug 1492), so\n # we use a different method: if X-Varnish contains only 1 id, we have a miss,\n # if it contains more (and therefore a space), we have a hit.\n if ( resp.http.x-varnish ~ \" \" ) {\n set resp.http.X-Cache = \"HIT\";\n # Since in Varnish 4 the behaviour of obj.hits changed, this might not be\n # accurate.\n # See https:\/\/www.varnish-cache.org\/trac\/ticket\/1492\n set resp.http.X-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Cache = \"MISS\";\n \/* Show the results of cookie sanitization *\/\n set resp.http.X-Cookie = req.http.Cookie;\n }\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n set resp.http.grace = req.http.grace;\n\n #TODO# Add sick marker\n\n # Restart count\n if ( req.restarts > 0 ) {\n set resp.http.X-Restarts = req.restarts;\n }\n\n # Add the Varnish server hostname\n set resp.http.X-Varnish-Server = server.hostname;\n # If we have setted a custom header with device's family detected we can show\n # it:\n # if ( req.http.X-UA-Device ) {\n # set resp.http.X-UA-Device = req.http.X-UA-Device;\n # }\n # If we have recived a custom header indicating the protocol in the request we\n # can show it:\n # if ( req.http.X-Forwarded-Proto ) {\n # set resp.http.X-Forwarded-Proto = req.http.X-Forwarded-Proto;\n # }\n\n \/* Vary header manipulation *\/\n # Empty in simple configs.\n # By example, if we are storing & serving diferent objects depending on\n # User-Agent header we must set the correct Vary header:\n # if ( resp.http.Vary ) {\n # set resp.http.Vary = resp.http.Vary + \",User-Agent\";\n # } else {\n # set resp.http.Vary = \"User-Agent\";\n # }\n\n \/* Fake headers *\/\n # Empty in simple configs\n # We can fake server headers here, by example:\n # set resp.http.Server = \"Deep thought\";\n # set resp.http.X-Powered-By = \"BOFH\";\n # Or have some fun with headers:\n # See http:\/\/www.nextthing.org\/archives\/2005\/08\/07\/fun-with-http-headers\n # See http:\/\/royal.pingdom.com\/2012\/08\/15\/fun-and-unusual-http-response-headers\/\n # set resp.http.X-Thank-You = \"for bothering to look at my HTTP headers\";\n # set resp.http.X-Answer = \"42\";\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_deliver {\n# return (deliver);\n# }\n\n# vcl_synth: Called to deliver a synthetic object. A synthetic object is\n# generated in VCL, not fetched from the backend. It is typically contructed\n# using the synthetic() function.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-synth\n\/*\n * We can come here \"invisibly\" with the following errors: 413, 417 & 503\n *\/\nsub vcl_synth {\n \/* Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_synth;\n\n \/* Try to restart request in case of failure *\/\n # Note that max_restarts defaults to 4\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if ( resp.status == 503\n && req.restarts < 4\n ) {\n return (restart);\n }\n\n \/* Set common headers for synthetic responses *\/\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n\n \/* HTTP Authentification client request *\/\n # Empty in simple configs.\n # SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* Load synthetic responses from disk *\/\n # Note that files loaded this way are never re-readed (even after a reload).\n # You should consider PROS\/CONS of doing an include instead.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_std.generated.html#func-fileread\n # Example custom 403 error page.\n # if ( resp.status == 403 ) {\n # synthetic(std.fileread(\"\/403.html\"));\n # return (deliver);\n # }\n\n \/* Error page & refresh \/ redirections *\/\n # We have plenty of choices when we have to serve an error to the client, \n # from the default error page to javascript black magic or plain redirections.\n # Adding some external statistic javascript to track failures served to\n # clients is strongly suggested.\n # We can't use external resources on synthetic content, everything must be\n # inlined.\n # If we need to include images we can embed them in base64 encoding.\n # We're using error 200 for monitoring puposes which should not be retried\n # client side.\n if ( resp.status != 200 ) {\n set resp.http.Retry-After = \"5\";\n }\n\n # Here is the default error page for Varnish 4 (not so pretty)\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n return (deliver);\n}\n\n#######################################################################\n# Backend Fetch\n\n# vcl_backend_fetch: Called before sending the backend request. In this\n# subroutine you typically alter the request before it gets to the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-fetch\n# sub vcl_backend_fetch {\n# return (fetch);\n# }\n\n# vcl_backend_response: Called after the response headers has been successfully\n# retrieved from the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-response\nsub vcl_backend_response {\n \/* Caching exceptions *\/\n # Varnish will cache objects with response codes:\n # 200, 203, 300, 301, 302, 307, 404 & 410.\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/VCL_Basics.html#the-initial-value-of-beresp-ttl\n # Drupal's Imagecache module can return a 307 redirection to the requested\n # url itself and, depending on Drupal's cache settings, this could lead to a\n # redirection loop being cached for a long time but also we want Varnish to\n # shield a little the backend.\n # See http:\/\/drupal.org\/node\/1248010\n # See http:\/\/drupal.org\/node\/310656\n if ( beresp.status == 307\n #TODO# verify that this work better than 'bereq.url ~ \"imagecache\"'\n && beresp.http.Location == bereq.url\n && beresp.ttl > 5s\n ) {\n set beresp.ttl = 5s;\n set beresp.http.cache-control = \"max-age=5\";\n }\n\n \/* Request retrial *\/\n if ( beresp.status == 500\n || beresp.status == 503\n ) {\n #TODO# consider not restarting POST requests as seenV3 on https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleSaintMode\n return (retry);\n }\n\n \/* Enable grace mode. Related with vcl_hit *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n set beresp.grace = 1h;\n\n \/* Strip cookies from the following static file types for all users. *\/\n # Related with our 12th stage on vcl_recv\n if ( bereq.url ~ \"(?i)\\.(bz2|css|eot|gif|gz|html?|ico|jpe?g|js|mp3|ogg|otf|pdf|png|rar|svg|swf|tbz|tgz|ttf|woff2?|zip)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n ) {\n unset beresp.http.set-cookie;\n }\n\n \/* Process ESI responses *\/\n # Empty in simple configs.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/esi.html\n # Send Surrogate-Capability headers\n # See http:\/\/www.w3.org\/TR\/edge-arch\n # Note that myproxyname is an identifier that should avoid collitions\n # Check for ESI acknowledgement and remove Surrogate-Control header\n #TODO# Add support for Surrogate-Control Targetting\n # if ( beresp.http.Surrogate-Control ~ \"ESI\/1.0\" ) {\n # unset beresp.http.Surrogate-Control;\n # set beresp.do_esi = true;\n # }\n\n \/* Gzip response *\/\n # Empty in simple configs.\n # Use Varnish to Gzip respone, if suitable, before storing it on cache.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html\n if ( ! beresp.http.Content-Encoding\n && ( beresp.http.content-type ~ \"text\"\n || beresp.http.content-type ~ \"application\/x-javascript\"\n || beresp.http.content-type ~ \"application\/javascript\"\n || beresp.http.content-type ~ \"application\/rss+xml\"\n || beresp.http.content-type ~ \"application\/xml\"\n || beresp.http.content-type ~ \"Application\/JSON\")\n ) {\n set beresp.do_gzip = true;\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # We can add the name of the backend that has processed the request:\n # set beresp.http.X-Backend = beresp.backend.name;\n # We can use a header to tell if the object was gziped by Varnish:\n # if ( beresp.do_gzip ) {\n # set beresp.http.X-Varnish-Gzipped = \"yes\";\n # } else {\n # set beresp.http.X-Varnish-Gizipped = \"no\";\n # }\n # We can do the same to tell if Varnish is streaming it:\n # if ( beresp.do_stream ) {\n # set beresp.http.X-Varnish-Streaming = \"yes\";\n # } else {\n # set beresp.http.X-Varnish-Streaming = \"no\";\n # }\n # We can also add headers informing whether the object is cacheable or not and why:\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Varnish3.0\n if ( beresp.ttl <= 0s ) {\n \/* Varnish determined the object was not cacheable *\/\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n } elsif ( bereq.http.Cookie ~ \"(SESS|SSESS|NO_CACHE|OATMEAL|CHOCOLATECHIP)\" ) {\n \/* We don't wish to cache content for logged in users or with certain cookies. *\/\n # Related with our 9th stage on vcl_recv\n set beresp.http.X-Cacheable = \"NO:Cookies\";\n # set beresp.uncacheable = true;\n } elsif ( beresp.http.Cache-Control ~ \"private\" ) {\n \/* We are respecting the Cache-Control=private header from the backend *\/\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n # set beresp.uncacheable = true;\n } else {\n \/* Varnish determined the object was cacheable *\/\n set beresp.http.X-Cacheable = \"YES\";\n }\n\n \/* Further header manipulation *\/\n # Empty in simple configs.\n # We can also unset some headers to prevent information disclosure and save\n # some cache space.\n # unset beresp.http.Server;\n # unset beresp.http.X-Powered-By;\n # Retry count.\n if ( bereq.retries > 0 ) {\n set beresp.http.X-Retries = bereq.retries;\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_backend_response {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Surrogate-control ~ \"no-store\" ||\n# (!beresp.http.Surrogate-Control &&\n# beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n# beresp.http.Vary == \"*\") {\n# \/*\n# * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# *\/\n# set beresp.ttl = 120s;\n# set beresp.uncacheable = true;\n# }\n# return (deliver);\n# }\n\n# vcl_backend_error: This subroutine is called if we fail the backend fetch.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-error\nsub vcl_backend_error {\n\n \/* Try to restart request in case of failure *\/\n #TODO# Confirm max_retries default value\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if ( bereq.retries < 4 ) {\n return (retry);\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # Retry count\n if ( bereq.retries > 0 ) {\n set beresp.http.X-Retries = bereq.retries;\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + beresp.status + \" \" + beresp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + beresp.status + \" \" + beresp.reason + {\"<\/h1>\n <p>\"} + beresp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + bereq.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this\n # point.\n return (deliver);\n}\n\n#######################################################################\n# Housekeeping\n\n# vcl_init: Called when VCL is loaded, before any requests pass through it.\n# Typically used to initialize VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-init\n# Here is where you should declare your directors now.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-backends.html#directors\n# Empty in simple configs\n# sub vcl_init {\n# return (ok);\n# }\n\n# vcl_fini: Called when VCL is discarded only after all requests have exited\n# the VCL. Typically used to clean up VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-fini\n# sub vcl_fini {\n# return (ok);\n# }\n\n","returncode":0,"stderr":"","license":"unknown","lang":"VCL"} {"commit":"71c57fd30e96b49988789086d38142e9705e1ca4","subject":"- adding authorize and extra checks","message":"- adding authorize and extra checks\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets\/recv.vcl","new_file":"etc\/vcl_snippets\/recv.vcl","new_contents":" # VCL required to support maintenance mode. Don't maintenance mode admin pages and supporting assets\n if (table.lookup(magentomodule_config, \"allow_super_users_during_maint\", \"0\") == \"1\" &&\n !req.http.Fastly-Client-Ip ~ maint_allowlist &&\n !req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" &&\n !req.url ~ \"^\/pub\/static\/\") {\n\n # If we end up here after a restart and there is a ResponseObject it means we got here after error\n # page VCL restart. We shouldn't touch it. Otherwise return a plain 503 error page\n if ( req.restarts > 0 && req.http.ResponseObject ) {\n set req.http.ResponseObject = \"970\";\n } else {\n error 503 \"Maintenance mode\";\n }\n }\n\n # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n unset req.http.x-long-cache;\n\n # We want to force long cache times on any of the versioned assets\n if (req.url.path ~ \"^\/static\/version\\d*\/\") {\n set req.http.x-long-cache = \"1\";\n }\n \n # User's Cookie may contain some Magento Vary items we should vary on\n if (req.http.cookie:X-Magento-Vary) {\n set req.http.X-Magento-Vary = req.http.cookie:X-Magento-Vary;\n } else {\n unset req.http.X-Magento-Vary;\n }\n\n # GraphQl special headers handling because this area doesn't rely on X-Magento-Vary cookie\n if (req.url ~ \"\/graphql\" && req.request == \"GET\" && req.url.qs ~ \"query=\") {\n if (req.http.Store) {\n if (req.http.X-Magento-Vary) {\n set req.http.X-Magento-Vary = req.http.X-Magento-Vary req.http.Store;\n } else {\n set req.http.X-Magento-Vary = req.http.Store;\n }\n }\n if (req.http.Content-Currency) {\n if (req.http.X-Magento-Vary) {\n set req.http.X-Magento-Vary = req.http.X-Magento-Vary req.http.Content-Currency;\n } else {\n set req.http.X-Magento-Vary = req.http.Content-Currency;\n }\n }\n }\n\n ############################################################################################################\n # Following code block controls purge by URL. By default we want to protect all URL purges. In general this\n # is addressed by adding Fastly-Purge-Requires-Auth request header in vcl_recv however this runs the risk of\n # exposing API tokens if user attempts to purge non-https URLs. For this reason inside the Magento module\n # we use X-Purge-Token. Unfortunately this breaks purge from the Fastly UI. Therefore in the next code block\n # we check for presence of X-Purge-Token. If it's not present we force the Fastly-Purge-Requires-Auth\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n if (req.http.X-Purge-Token && req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n } else {\n error 403;\n }\n } else {\n set req.http.Fastly-Purge-Requires-Auth = \"1\";\n }\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (fastly.ff.visits_this_service > 0) {\n # disable ESI processing on Origin Shield\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Make sure we lookup end user geo not shielding. More at https:\/\/docs.fastly.com\/vcl\/geolocation\/#using-geographic-variables-with-shielding\n set client.geo.ip_override = req.http.Fastly-Client-IP;\n\n # geoip lookup\n if (req.url.path ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie:X-Magento-Vary || req.http.cookie:form_key) {\n error 980 \"GeoIP already processed\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url.qs !~ \"country_code=\" ) {\n set req.url = querystring.set(req.url, \"country_code\", if ( req.http.geo_override, req.http.geo_override, client.geo.country_code));\n }\n }\n } else {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking by default\n # and allow custom parameters to be set. List of parameters is configurable in admin\n set req.http.Magento-Original-URL = req.url;\n # Change the list of ignored parameters by configuring them in the Advanced section\n set req.url = querystring.regfilter(req.url, \"^(####QUERY_PARAMETERS####)\");\n }\n\n # Don't allow clients to force a pass\n if (req.restarts == 0) {\n unset req.http.x-pass;\n unset req.http.Rate-Limit;\n }\n \n # Pass on checkout URLs. Because it's a snippet we want to execute this after backend selection so we handle it\n # in the request condition\n if (!req.http.x-long-cache && req.url ~ \"\/(catalogsearch|checkout|customer\/section\/load)\") {\n set req.http.x-pass = \"1\";\n # Pass all admin actions\n # ####ADMIN_PATH#### is replaced with value of frontName from app\/etc\/env.php\n } else if ( req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" ) {\n set req.http.x-pass = \"1\";\n } else {\n # Sort the query arguments to increase cache hit ratio with query arguments that\n # may be out od order. In case you want to restore the unsorted URL add a snippet\n # after this one that sets req.url to req.http.Magento-Original-URL\n if ( !req.http.x-pass ) {\n set req.url = boltsort.sort(req.url);\n }\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.http.x-long-cache || req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n # GraphQl doesn't yet cache the authenticated\/logged-in customer queries\n if (req.request == \"GET\" && req.url.path ~ \"\/graphql\" && req.http.Authorization ~ \"^Bearer\" && req.url.qs ~ \"query=\") {\n set req.http.x-pass = \"1\";\n }\n","old_contents":" # VCL required to support maintenance mode. Don't maintenance mode admin pages and supporting assets\n if (table.lookup(magentomodule_config, \"allow_super_users_during_maint\", \"0\") == \"1\" &&\n !req.http.Fastly-Client-Ip ~ maint_allowlist &&\n !req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" &&\n !req.url ~ \"^\/pub\/static\/\") {\n\n # If we end up here after a restart and there is a ResponseObject it means we got here after error\n # page VCL restart. We shouldn't touch it. Otherwise return a plain 503 error page\n if ( req.restarts > 0 && req.http.ResponseObject ) {\n set req.http.ResponseObject = \"970\";\n } else {\n error 503 \"Maintenance mode\";\n }\n }\n\n # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n unset req.http.x-long-cache;\n\n # We want to force long cache times on any of the versioned assets\n if (req.url.path ~ \"^\/static\/version\\d*\/\") {\n set req.http.x-long-cache = \"1\";\n }\n \n # User's Cookie may contain some Magento Vary items we should vary on\n if (req.http.cookie:X-Magento-Vary) {\n set req.http.X-Magento-Vary = req.http.cookie:X-Magento-Vary;\n } else {\n unset req.http.X-Magento-Vary;\n }\n\n # GraphQl special headers handling because this area doesn't rely on X-Magento-Vary cookie\n if (req.url ~ \"\/graphql\" && req.request == \"GET\") {\n if (req.http.Store) {\n if (req.http.X-Magento-Vary) {\n set req.http.X-Magento-Vary = req.http.X-Magento-Vary req.http.Store;\n } else {\n set req.http.X-Magento-Vary = req.http.Store;\n }\n }\n if (req.http.Content-Currency) {\n if (req.http.X-Magento-Vary) {\n set req.http.X-Magento-Vary = req.http.X-Magento-Vary req.http.Content-Currency;\n } else {\n set req.http.X-Magento-Vary = req.http.Content-Currency;\n }\n }\n # GraphQl doesn't cache yet the logged in customer queries\n if (req.http.Authorization) {\n set req.http.x-pass = \"1\";\n }\n }\n\n ############################################################################################################\n # Following code block controls purge by URL. By default we want to protect all URL purges. In general this\n # is addressed by adding Fastly-Purge-Requires-Auth request header in vcl_recv however this runs the risk of\n # exposing API tokens if user attempts to purge non-https URLs. For this reason inside the Magento module\n # we use X-Purge-Token. Unfortunately this breaks purge from the Fastly UI. Therefore in the next code block\n # we check for presence of X-Purge-Token. If it's not present we force the Fastly-Purge-Requires-Auth\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n if (req.http.X-Purge-Token && req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n } else {\n error 403;\n }\n } else {\n set req.http.Fastly-Purge-Requires-Auth = \"1\";\n }\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (fastly.ff.visits_this_service > 0) {\n # disable ESI processing on Origin Shield\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Make sure we lookup end user geo not shielding. More at https:\/\/docs.fastly.com\/vcl\/geolocation\/#using-geographic-variables-with-shielding\n set client.geo.ip_override = req.http.Fastly-Client-IP;\n\n # geoip lookup\n if (req.url.path ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie:X-Magento-Vary || req.http.cookie:form_key) {\n error 980 \"GeoIP already processed\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url.qs !~ \"country_code=\" ) {\n set req.url = querystring.set(req.url, \"country_code\", if ( req.http.geo_override, req.http.geo_override, client.geo.country_code));\n }\n }\n } else {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking by default\n # and allow custom parameters to be set. List of parameters is configurable in admin\n set req.http.Magento-Original-URL = req.url;\n # Change the list of ignored parameters by configuring them in the Advanced section\n set req.url = querystring.regfilter(req.url, \"^(####QUERY_PARAMETERS####)\");\n }\n\n # Don't allow clients to force a pass\n if (req.restarts == 0) {\n unset req.http.x-pass;\n unset req.http.Rate-Limit;\n }\n \n # Pass on checkout URLs. Because it's a snippet we want to execute this after backend selection so we handle it\n # in the request condition\n if (!req.http.x-long-cache && req.url ~ \"\/(catalogsearch|checkout|customer\/section\/load)\") {\n set req.http.x-pass = \"1\";\n # Pass all admin actions\n # ####ADMIN_PATH#### is replaced with value of frontName from app\/etc\/env.php\n } else if ( req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" ) {\n set req.http.x-pass = \"1\";\n } else {\n # Sort the query arguments to increase cache hit ratio with query arguments that\n # may be out od order. In case you want to restore the unsorted URL add a snippet\n # after this one that sets req.url to req.http.Magento-Original-URL\n if ( !req.http.x-pass ) {\n set req.url = boltsort.sort(req.url);\n }\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.http.x-long-cache || req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"d6664c1cb001fee307d39aab04f307ec5efac907","subject":"Match whole query parameter","message":"Match whole query parameter\n\nThe default value for the associated configuration option explicitly handles\nmatching \"query parameters starting with\"; this suggests that values not using\nthis pattern will match the whole parameter only. The code behaves differently.\nThis change makes the code match expectations and examples.\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets\/recv.vcl","new_file":"etc\/vcl_snippets\/recv.vcl","new_contents":" # When using Magento tester to test whether your site is configured properly\n # this uses a bypass secret. By default we will use service ID as the bypass secret\n # however user can override this by defining a bypass_secret key in the\n # magentomodule_config edge dictionary\n if ( req.http.bypass-secret ) {\n declare local var.bypass-secret STRING;\n set var.bypass-secret = table.lookup(magentomodule_config, \"bypass_secret\", \"NONE\");\n if ( var.bypass-secret == req.http.bypass-secret ) {\n set req.http.x-pass = \"1\";\n set var.fastly_req_do_shield = false;\n set req.hash_always_miss = true;\n } else if ( var.bypass-secret == \"NONE\" && req.http.bypass-secret == req.service_id ) {\n set req.http.x-pass = \"1\";\n set var.fastly_req_do_shield = false;\n set req.hash_always_miss = true;\n } else {\n error 403 \"Bypass Secret incorrect\";\n }\n }\n\n # VCL required to support maintenance mode. Don't maintenance mode admin pages and supporting assets\n if (table.lookup(magentomodule_config, \"allow_super_users_during_maint\", \"0\") == \"1\" &&\n !req.http.Fastly-Client-Ip ~ maint_allowlist &&\n !req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" &&\n !req.url ~ \"^\/pub\/static\/\") {\n\n # If we end up here after a restart and there is a ResponseObject it means we got here after error\n # page VCL restart. We shouldn't touch it. Otherwise return a plain 503 error page\n if ( req.restarts > 0 && req.http.ResponseObject ) {\n set req.http.ResponseObject = \"970\";\n } else {\n error 503 \"Maintenance mode\";\n }\n }\n\n # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n unset req.http.x-long-cache;\n\n # We want to force long cache times on any of the versioned assets\n if (req.url.path ~ \"^\/static\/version\\d*\/\") {\n set req.http.x-long-cache = \"1\";\n }\n\n # User's Cookie may contain some Magento Vary items we should vary on\n if (req.http.cookie:X-Magento-Vary) {\n set req.http.X-Magento-Vary = req.http.cookie:X-Magento-Vary;\n } else {\n unset req.http.X-Magento-Vary;\n }\n\n ############################################################################################################\n # Following code block controls purge by URL. By default we want to protect all URL purges. In general this\n # is addressed by adding Fastly-Purge-Requires-Auth request header in vcl_recv however this runs the risk of\n # exposing API tokens if user attempts to purge non-https URLs. For this reason inside the Magento module\n # we use X-Purge-Token. Unfortunately this breaks purge from the Fastly UI. Therefore in the next code block\n # we check for presence of X-Purge-Token. If it's not present we force the Fastly-Purge-Requires-Auth\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n if (req.http.X-Purge-Token && req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n } else {\n error 403;\n }\n } else {\n set req.http.Fastly-Purge-Requires-Auth = \"1\";\n }\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (fastly.ff.visits_this_service > 0) {\n # disable ESI processing on Origin Shield\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Make sure we lookup end user geo not shielding. More at https:\/\/docs.fastly.com\/vcl\/geolocation\/#using-geographic-variables-with-shielding\n set client.geo.ip_override = req.http.Fastly-Client-IP;\n\n # geoip lookup\n if (req.url.path ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie:X-Magento-Vary || req.http.cookie:form_key) {\n error 980 \"GeoIP already processed\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url.qs !~ \"country_code=\" ) {\n set req.url = querystring.set(req.url, \"country_code\", if ( req.http.geo_override, req.http.geo_override, client.geo.country_code));\n }\n }\n } else if ( req.url.path !~ \"\/graphql\" ) {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking by default\n # and allow custom parameters to be set. List of parameters is configurable in admin\n set req.http.Magento-Original-URL = req.url;\n # Change the list of ignored parameters by configuring them in the Advanced section\n set req.url = querystring.regfilter(req.url, \"^(####QUERY_PARAMETERS####)(=|&|$)\");\n }\n\n # Don't allow clients to force a pass\n if (req.restarts == 0) {\n unset req.http.x-pass;\n unset req.http.Rate-Limit;\n unset req.http.magento-admin-path;\n }\n\n # Pass on checkout URLs. Because it's a snippet we want to execute this after backend selection so we handle it\n # in the request condition\n if (!req.http.x-long-cache && req.url ~ \"\/(checkout|customer\/section\/load)\") {\n set req.http.x-pass = \"1\";\n # Pass all admin actions\n # ####ADMIN_PATH#### is replaced with value of frontName from app\/etc\/env.php\n } else if ( req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" ) {\n set req.http.x-pass = \"1\";\n set req.http.magento-admin-path = \"1\";\n } else {\n # Sort the query arguments to increase cache hit ratio with query arguments that\n # may be out od order. In case you want to restore the unsorted URL add a snippet\n # after this one that sets req.url to req.http.Magento-Original-URL\n if ( !req.http.x-pass ) {\n set req.url = boltsort.sort(req.url);\n }\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.http.x-long-cache || req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n unset req.http.graphql;\n # GraphQL special headers handling because this area doesn't rely on X-Magento-Vary cookie\n if (req.request == \"GET\" && req.url.path ~ \"\/graphql\" && req.url.qs ~ \"query=\") {\n if ( req.http.Authorization ~ \"^Bearer\" ) {\n set req.http.x-pass = \"1\";\n } else {\n set req.http.graphql = \"1\";\n if (req.http.Store) {\n set req.http.X-Magento-Vary = req.http.Store;\n }\n if (req.http.Content-Currency) {\n if (req.http.X-Magento-Vary) {\n set req.http.X-Magento-Vary = req.http.X-Magento-Vary req.http.Content-Currency;\n } else {\n set req.http.X-Magento-Vary = req.http.Content-Currency;\n }\n }\n }\n }\n","old_contents":" # When using Magento tester to test whether your site is configured properly\n # this uses a bypass secret. By default we will use service ID as the bypass secret\n # however user can override this by defining a bypass_secret key in the \n # magentomodule_config edge dictionary\n if ( req.http.bypass-secret ) {\n declare local var.bypass-secret STRING;\n set var.bypass-secret = table.lookup(magentomodule_config, \"bypass_secret\", \"NONE\");\n if ( var.bypass-secret == req.http.bypass-secret ) {\n set req.http.x-pass = \"1\";\n set var.fastly_req_do_shield = false;\n set req.hash_always_miss = true;\n } else if ( var.bypass-secret == \"NONE\" && req.http.bypass-secret == req.service_id ) {\n set req.http.x-pass = \"1\";\n set var.fastly_req_do_shield = false;\n set req.hash_always_miss = true;\n } else {\n error 403 \"Bypass Secret incorrect\";\n }\n }\n\n # VCL required to support maintenance mode. Don't maintenance mode admin pages and supporting assets\n if (table.lookup(magentomodule_config, \"allow_super_users_during_maint\", \"0\") == \"1\" &&\n !req.http.Fastly-Client-Ip ~ maint_allowlist &&\n !req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" &&\n !req.url ~ \"^\/pub\/static\/\") {\n\n # If we end up here after a restart and there is a ResponseObject it means we got here after error\n # page VCL restart. We shouldn't touch it. Otherwise return a plain 503 error page\n if ( req.restarts > 0 && req.http.ResponseObject ) {\n set req.http.ResponseObject = \"970\";\n } else {\n error 503 \"Maintenance mode\";\n }\n }\n\n # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n unset req.http.x-long-cache;\n\n # We want to force long cache times on any of the versioned assets\n if (req.url.path ~ \"^\/static\/version\\d*\/\") {\n set req.http.x-long-cache = \"1\";\n }\n \n # User's Cookie may contain some Magento Vary items we should vary on\n if (req.http.cookie:X-Magento-Vary) {\n set req.http.X-Magento-Vary = req.http.cookie:X-Magento-Vary;\n } else {\n unset req.http.X-Magento-Vary;\n }\n\n ############################################################################################################\n # Following code block controls purge by URL. By default we want to protect all URL purges. In general this\n # is addressed by adding Fastly-Purge-Requires-Auth request header in vcl_recv however this runs the risk of\n # exposing API tokens if user attempts to purge non-https URLs. For this reason inside the Magento module\n # we use X-Purge-Token. Unfortunately this breaks purge from the Fastly UI. Therefore in the next code block\n # we check for presence of X-Purge-Token. If it's not present we force the Fastly-Purge-Requires-Auth\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n if (req.http.X-Purge-Token && req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n } else {\n error 403;\n }\n } else {\n set req.http.Fastly-Purge-Requires-Auth = \"1\";\n }\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (fastly.ff.visits_this_service > 0) {\n # disable ESI processing on Origin Shield\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Make sure we lookup end user geo not shielding. More at https:\/\/docs.fastly.com\/vcl\/geolocation\/#using-geographic-variables-with-shielding\n set client.geo.ip_override = req.http.Fastly-Client-IP;\n\n # geoip lookup\n if (req.url.path ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie:X-Magento-Vary || req.http.cookie:form_key) {\n error 980 \"GeoIP already processed\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url.qs !~ \"country_code=\" ) {\n set req.url = querystring.set(req.url, \"country_code\", if ( req.http.geo_override, req.http.geo_override, client.geo.country_code));\n }\n }\n } else if ( req.url.path !~ \"\/graphql\" ) {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking by default\n # and allow custom parameters to be set. List of parameters is configurable in admin\n set req.http.Magento-Original-URL = req.url;\n # Change the list of ignored parameters by configuring them in the Advanced section\n set req.url = querystring.regfilter(req.url, \"^(####QUERY_PARAMETERS####)\");\n }\n\n # Don't allow clients to force a pass\n if (req.restarts == 0) {\n unset req.http.x-pass;\n unset req.http.Rate-Limit;\n unset req.http.magento-admin-path;\n }\n \n # Pass on checkout URLs. Because it's a snippet we want to execute this after backend selection so we handle it\n # in the request condition\n if (!req.http.x-long-cache && req.url ~ \"\/(checkout|customer\/section\/load)\") {\n set req.http.x-pass = \"1\";\n # Pass all admin actions\n # ####ADMIN_PATH#### is replaced with value of frontName from app\/etc\/env.php\n } else if ( req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" ) {\n set req.http.x-pass = \"1\";\n set req.http.magento-admin-path = \"1\";\n } else {\n # Sort the query arguments to increase cache hit ratio with query arguments that\n # may be out od order. In case you want to restore the unsorted URL add a snippet\n # after this one that sets req.url to req.http.Magento-Original-URL\n if ( !req.http.x-pass ) {\n set req.url = boltsort.sort(req.url);\n }\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.http.x-long-cache || req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n unset req.http.graphql;\n # GraphQL special headers handling because this area doesn't rely on X-Magento-Vary cookie\n if (req.request == \"GET\" && req.url.path ~ \"\/graphql\" && req.url.qs ~ \"query=\") {\n if ( req.http.Authorization ~ \"^Bearer\" ) {\n set req.http.x-pass = \"1\";\n } else {\n set req.http.graphql = \"1\";\n if (req.http.Store) {\n set req.http.X-Magento-Vary = req.http.Store;\n }\n if (req.http.Content-Currency) {\n if (req.http.X-Magento-Vary) {\n set req.http.X-Magento-Vary = req.http.X-Magento-Vary req.http.Content-Currency;\n } else {\n set req.http.X-Magento-Vary = req.http.Content-Currency;\n }\n }\n }\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"586de14457eb56ff7b2df19f3a6fb42192452fb8","subject":"samsung GT smartphones, playbook tablet, kindle3, hp touchpad","message":"samsung GT smartphones, playbook tablet, kindle3, hp touchpad\n\nMozilla\/5.0 (Linux; U; it-it; GT-I9070 Build\/GINGERBREAD)\nAppleWebKit\/533.1 (KHTML, like Gecko) Version\/4.0 Safari\/533.1\n\nMozilla\/5.0 (PlayBook; U; RIM Tablet OS 2.1.0; en-US)\nAppleWebKit\/536.2+ (KHTML, like Gecko) Version\/7.2.1.0 Safari\/536.2+\n\nMozilla\/5.0 (Linux; U; it-IT) AppleWebKit\/528.5+ (KHTML, like Gecko,\nSafari\/528.5+) Version\/4.0 Kindle\/3.0 (screen 600x800; rotate)\n\nMozilla\/5.0 (hp-tablet; Linux; hpwOS\/3.0.5; U; it-IT) AppleWebKit\/534.6\n(KHTML, like Gecko) wOSBrowser\/234.83 Safari\/534.6 TouchPad\/1.0\n","repos":"wikp\/varnish-devicedetect,wikp\/varnish-devicedetect,kevinquinnyo\/varnish-devicedetect,varnish\/varnish-devicedetect,kevinquinnyo\/varnish-devicedetect,varnish\/varnish-devicedetect","old_file":"devicedetect.vcl","new_file":"devicedetect.vcl","new_contents":"# Copyright (c) 2012-2013 Varnish Software AS\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions\n# are met:\n# 1. Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n# 2. Redistributions in binary form must reproduce the above copyright\n# notice, this list of conditions and the following disclaimer in the\n# documentation and\/or other materials provided with the distribution.\n#\n# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n# ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n# SUCH DAMAGE.\n#\n# detectdevice.vcl - regex based device detection for Varnish\n# http:\/\/github.com\/varnish\/varnish-devicedetect\/\n#\n# Author: Lasse Karstensen <lasse@varnish-software.com>\n\nsub devicedetect {\n\tunset req.http.X-UA-Device;\n\tset req.http.X-UA-Device = \"pc\";\n\n\t# Handle that a cookie may override the detection alltogether.\n\tif (req.http.Cookie ~ \"(?i)X-UA-Device-force\") {\n\t\t\/* ;?? means zero or one ;, non-greedy to match the first. *\/\n\t\tset req.http.X-UA-Device = regsub(req.http.Cookie, \"(?i).*X-UA-Device-force=([^;]+);??.*\", \"\\1\");\n\t\t\/* Clean up our mess in the cookie header *\/\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|; ) *X-UA-Device-force=[^;]+;? *\", \"\\1\");\n\t\t\/* If the cookie header is now empty, or just whitespace, unset it. *\/\n\t\tif (req.http.Cookie ~ \"^ *$\") { unset req.http.Cookie; }\n\t} else {\n\t\tif (req.http.User-Agent ~ \"(?i)(ads|google|bing|msn|yandex|baidu|ro|career|)bot\" ||\n\t\t req.http.User-Agent ~ \"(?i)(baidu|jike|symantec)spider\" ||\n\t\t req.http.User-Agent ~ \"(?i)scanner\" ||\n\t\t req.http.User-Agent ~ \"(?i)(web)crawler\") {\n\t\t\tset req.http.X-UA-Device = \"bot\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ipad\") { set req.http.X-UA-Device = \"tablet-ipad\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ip(hone|od)\") { set req.http.X-UA-Device = \"mobile-iphone\"; }\n\t\t\/* how do we differ between an android phone and an android tablet?\n\t\t http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent *\/\n\t\telsif (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") { set req.http.X-UA-Device = \"mobile-android\"; }\n\t\t\/\/ android 3\/honeycomb was just about tablet-only, and any phones will probably handle a bigger page layout.\n\t\telsif (req.http.User-Agent ~ \"(?i)android 3\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\t\/\/ May very well give false positives towards android tablets. Suggestions welcome.\n\t\telsif (req.http.User-Agent ~ \"(?i)android\") { set req.http.X-UA-Device = \"tablet-android\"; }\n elsif (req.http.User-Agent ~ \"PlayBook; U; RIM Tablet\") { set req.http.X-UA-Device = \"tablet-rim\"; }\n elsif (req.http.User-Agent ~ \"hp-tablet.*TouchPad\") { set req.http.X-UA-Device = \"tablet-hp\"; }\n elsif (req.http.User-Agent ~ \"Kindle\/3\") { set req.http.X-UA-Device = \"tablet-kindle\"; }\n\t\telsif (req.http.User-Agent ~ \"Mobile.+Firefox\") { set req.http.X-UA-Device = \"mobile-firefoxos\"; }\n\t\telsif (req.http.User-Agent ~ \"^HTC\" ||\n\t\t req.http.User-Agent ~ \"Fennec\" ||\n\t\t req.http.User-Agent ~ \"IEMobile\" ||\n\t\t req.http.User-Agent ~ \"BlackBerry\" ||\n\t\t req.http.User-Agent ~ \"BB10.*Mobile\" ||\n req.http.User-Agent ~ \"GT-.*Build\/GINGERBREAD\" ||\n\t\t req.http.User-Agent ~ \"SymbianOS.*AppleWebKit\" ||\n\t\t req.http.User-Agent ~ \"Opera Mobi\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-smartphone\";\n\t\t}\n\t\telsif (req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)^sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)^nokia\" ||\n\t\t req.http.User-Agent ~ \"(?i)^samsung\" ||\n\t\t req.http.User-Agent ~ \"(?i)^lg\" ||\n\t\t req.http.User-Agent ~ \"(?i)bada\" ||\n\t\t req.http.User-Agent ~ \"(?i)blazer\" ||\n\t\t req.http.User-Agent ~ \"(?i)cellphone\" ||\n\t\t req.http.User-Agent ~ \"(?i)iemobile\" ||\n\t\t req.http.User-Agent ~ \"(?i)midp-2.0\" ||\n\t\t req.http.User-Agent ~ \"(?i)u990\" ||\n\t\t req.http.User-Agent ~ \"(?i)netfront\" ||\n\t\t req.http.User-Agent ~ \"(?i)opera mini\" ||\n\t\t req.http.User-Agent ~ \"(?i)palm\" ||\n\t\t req.http.User-Agent ~ \"(?i)nintendo wii\" ||\n\t\t req.http.User-Agent ~ \"(?i)playstation portable\" ||\n\t\t req.http.User-Agent ~ \"(?i)portalmmm\" ||\n\t\t req.http.User-Agent ~ \"(?i)proxinet\" ||\n\t\t req.http.User-Agent ~ \"(?i)sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)windows\\ ?ce\" ||\n\t\t req.http.User-Agent ~ \"(?i)winwap\" ||\n\t\t req.http.User-Agent ~ \"(?i)eudoraweb\" ||\n\t\t req.http.User-Agent ~ \"(?i)htc\" ||\n\t\t req.http.User-Agent ~ \"(?i)240x320\" ||\n\t\t req.http.User-Agent ~ \"(?i)avantgo\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-generic\";\n\t\t}\n\t}\n}\n","old_contents":"# Copyright (c) 2012-2013 Varnish Software AS\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions\n# are met:\n# 1. Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n# 2. Redistributions in binary form must reproduce the above copyright\n# notice, this list of conditions and the following disclaimer in the\n# documentation and\/or other materials provided with the distribution.\n#\n# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n# ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n# SUCH DAMAGE.\n#\n# detectdevice.vcl - regex based device detection for Varnish\n# http:\/\/github.com\/varnish\/varnish-devicedetect\/\n#\n# Author: Lasse Karstensen <lasse@varnish-software.com>\n\nsub devicedetect {\n\tunset req.http.X-UA-Device;\n\tset req.http.X-UA-Device = \"pc\";\n\n\t# Handle that a cookie may override the detection alltogether.\n\tif (req.http.Cookie ~ \"(?i)X-UA-Device-force\") {\n\t\t\/* ;?? means zero or one ;, non-greedy to match the first. *\/\n\t\tset req.http.X-UA-Device = regsub(req.http.Cookie, \"(?i).*X-UA-Device-force=([^;]+);??.*\", \"\\1\");\n\t\t\/* Clean up our mess in the cookie header *\/\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|; ) *X-UA-Device-force=[^;]+;? *\", \"\\1\");\n\t\t\/* If the cookie header is now empty, or just whitespace, unset it. *\/\n\t\tif (req.http.Cookie ~ \"^ *$\") { unset req.http.Cookie; }\n\t} else {\n\t\tif (req.http.User-Agent ~ \"(?i)(ads|google|bing|msn|yandex|baidu|ro|career|)bot\" ||\n\t\t req.http.User-Agent ~ \"(?i)(baidu|jike|symantec)spider\" ||\n\t\t req.http.User-Agent ~ \"(?i)scanner\" ||\n\t\t req.http.User-Agent ~ \"(?i)(web)crawler\") {\n\t\t\tset req.http.X-UA-Device = \"bot\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ipad\") { set req.http.X-UA-Device = \"tablet-ipad\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ip(hone|od)\") { set req.http.X-UA-Device = \"mobile-iphone\"; }\n\t\t\/* how do we differ between an android phone and an android tablet?\n\t\t http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent *\/\n\t\telsif (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") { set req.http.X-UA-Device = \"mobile-android\"; }\n\t\t\/\/ android 3\/honeycomb was just about tablet-only, and any phones will probably handle a bigger page layout.\n\t\telsif (req.http.User-Agent ~ \"(?i)android 3\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\t\/\/ May very well give false positives towards android tablets. Suggestions welcome.\n\t\telsif (req.http.User-Agent ~ \"(?i)android\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\telsif (req.http.User-Agent ~ \"Mobile.+Firefox\") { set req.http.X-UA-Device = \"mobile-firefoxos\"; }\n\t\telsif (req.http.User-Agent ~ \"^HTC\" ||\n\t\t req.http.User-Agent ~ \"Fennec\" ||\n\t\t req.http.User-Agent ~ \"IEMobile\" ||\n\t\t req.http.User-Agent ~ \"BlackBerry\" ||\n\t\t req.http.User-Agent ~ \"BB10.*Mobile\" ||\n\t\t req.http.User-Agent ~ \"SymbianOS.*AppleWebKit\" ||\n\t\t req.http.User-Agent ~ \"Opera Mobi\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-smartphone\";\n\t\t}\n\t\telsif (req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)^sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)^nokia\" ||\n\t\t req.http.User-Agent ~ \"(?i)^samsung\" ||\n\t\t req.http.User-Agent ~ \"(?i)^lg\" ||\n\t\t req.http.User-Agent ~ \"(?i)bada\" ||\n\t\t req.http.User-Agent ~ \"(?i)blazer\" ||\n\t\t req.http.User-Agent ~ \"(?i)cellphone\" ||\n\t\t req.http.User-Agent ~ \"(?i)iemobile\" ||\n\t\t req.http.User-Agent ~ \"(?i)midp-2.0\" ||\n\t\t req.http.User-Agent ~ \"(?i)u990\" ||\n\t\t req.http.User-Agent ~ \"(?i)netfront\" ||\n\t\t req.http.User-Agent ~ \"(?i)opera mini\" ||\n\t\t req.http.User-Agent ~ \"(?i)palm\" ||\n\t\t req.http.User-Agent ~ \"(?i)nintendo wii\" ||\n\t\t req.http.User-Agent ~ \"(?i)playstation portable\" ||\n\t\t req.http.User-Agent ~ \"(?i)portalmmm\" ||\n\t\t req.http.User-Agent ~ \"(?i)proxinet\" ||\n\t\t req.http.User-Agent ~ \"(?i)sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)windows\\ ?ce\" ||\n\t\t req.http.User-Agent ~ \"(?i)winwap\" ||\n\t\t req.http.User-Agent ~ \"(?i)eudoraweb\" ||\n\t\t req.http.User-Agent ~ \"(?i)htc\" ||\n\t\t req.http.User-Agent ~ \"(?i)240x320\" ||\n\t\t req.http.User-Agent ~ \"(?i)avantgo\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-generic\";\n\t\t}\n\t}\n}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"f0b5b7e79f0b3f08651490f2cdc3cf58576f8abd","subject":"Updated Varnish to cache SQL API \/ Windshaft","message":"Updated Varnish to cache SQL API \/ Windshaft\n\nThe previous version of this file was enough to cache requests for the\nSQL API, but unfortunately no traffic was ever reaching Varnish to be\ncached. Nginx was proxying directly to the SQL API port, and Varnish was\nset to listen on 6081, so it wasn't able to intercept those requests. I\nupdated the Nginx proxy config to aim at 6081 for requests to both SQL\nAPI and Windshaft, so now Varnish is receiving traffic. However, in\norder to know which backend to send traffic to, I had to add a custom\nHTTP header in the Nginx proxy pass. That header is picked up in the\n`vcl_recv` varnish subroutine and used to switch between backends.\n\nAdditionally I've added logic for controlling what hosts can issue an\nHTTP PURGE command--in this case just localhost, since everything is on\na single image. The purges will typically come from a Postgres trigger.\n\nAs an overview of the purge related changes, see the Varnish docs here:\n\nhttps:\/\/varnish-cache.org\/docs\/3.0\/tutorial\/purging.html#http-purges\n","repos":"sverhoeven\/docker-cartodb,sverhoeven\/docker-cartodb","old_file":"config\/varnish.vcl","new_file":"config\/varnish.vcl","new_contents":"acl purge {\n \"localhost\";\n \"127.0.0.1\";\n}\n\nbackend sqlapi {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\n\nbackend windshaft {\n .host = \"127.0.0.1\";\n .port = \"8181\";\n}\n\nsub vcl_recv {\n # Allowing PURGE from localhost\n if (req.request == \"PURGE\") {\n if (!client.ip ~ purge) {\n error 405 \"Not allowed.\";\n }\n return (lookup);\n }\n\n # Routing request to backend based on X-Carto-Service header from nginx\n if (req.http.X-Carto-Service == \"sqlapi\") {\n set req.backend = sqlapi;\n remove req.http.X-Carto-Service;\n }\n if (req.http.X-Carto-Service == \"windshaft\") {\n set req.backend = windshaft;\n remove req.http.X-Carto-Service;\n }\n}\n\nsub vcl_hit {\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged.\";\n }\n}\n\nsub vcl_miss {\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged.\";\n }\n}\n","old_contents":"backend default {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"d03fc324d85a6919c3103fa802788999277380e5","subject":"not sure how the second one got in here.","message":"not sure how the second one got in here.\n","repos":"amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon","old_file":"images\/varnish-drupal\/drupal.vcl","new_file":"images\/varnish-drupal\/drupal.vcl","new_contents":"vcl 4.0;\n\nimport std;\n\n# set backend default\nbackend default {\n .host = \"${VARNISH_BACKEND_HOST:-nginx}\";\n .port = \"${VARNISH_BACKEND_PORT:-8080}\";\n .first_byte_timeout = 35m;\n .between_bytes_timeout = 10m;\n}\n\n# Allow purging from localhost\n# @TODO allow from openshift network\nacl purge {\n \"127.0.0.1\";\n \"10.0.0.0\"\/8;\n \"172.16.0.0\"\/12;\n \"192.168.0.0\"\/16;\n}\n\nsub vcl_init {\n new www_dir = dynamic.director(\n port = \"${VARNISH_BACKEND_PORT:-8080}\",\n first_byte_timeout = 90s,\n between_bytes_timeout = 90s,\n ttl = 60s);\n}\n\n# This configuration is optimized for Drupal hosting:\n# Respond to incoming requests.\nsub vcl_recv {\n if (req.url ~ \"^\/varnish_status$\") {\n return (synth(200,\"OK\"));\n }\n # set the backend, which should be used:\n set req.backend_hint = default;\n\n # Always set the forward ip.\n if (req.restarts == 0) {\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n\n\n if (req.http.X-LAGOON-VARNISH ) {\n ## Pass all Requests which are handled via an upstream Varnish\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, \" + req.http.X-LAGOON-VARNISH;\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n } else if (req.http.Fastly-FF) {\n ## Pass all Requests which are handled via Fastly\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, fastly\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n set req.http.X-Forwarded-For = req.http.Fastly-Client-IP;\n } else if (req.http.CF-RAY) {\n ## Pass all Requests which are handled via CloudFlare\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, cloudflare\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n set req.http.X-Forwarded-For = req.http.CF-Connecting-IP;\n } else if (req.http.X-Pull) {\n ## Pass all Requests which are handled via KeyCDN\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, keycdn\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n } else {\n ## We set a header to let a Varnish Chain know that it already has been varnishcached\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}\";\n\n ## Allow to bypass based on env variable `VARNISH_BYPASS`\n set req.http.X-LAGOON-VARNISH-BYPASS = \"${VARNISH_BYPASS:-false}\";\n }\n\n # Websockets are piped\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n if (req.http.X-LAGOON-VARNISH-BYPASS == \"true\" || req.http.X-LAGOON-VARNISH-BYPASS == \"TRUE\") {\n return (pass);\n }\n\n # SA-CORE-2014-004 preventing access to \/xmlrpc.php\n if (req.url ~ \"^\/xmlrpc.php$\") {\n return (synth(701, \"Unauthorized\"));\n }\n\n # Strip out Google Analytics campaign variables. They are only needed\n # by the javascript running on the page\n # utm_source, utm_medium, utm_campaign, gclid\n if(req.url ~ \"(\\?|&)(gclid|utm_[a-z]+)=\") {\n set req.url = regsuball(req.url, \"(gclid|utm_[a-z]+)=[^\\&]+&?\", \"\");\n set req.url = regsub(req.url, \"(\\?|&)$\", \"\");\n }\n\n # Bypass a cache hit (the request is still sent to the backend)\n if (req.method == \"REFRESH\") {\n if (!client.ip ~ purge) { return (synth(405, \"Not allowed\")); }\n set req.method = \"GET\";\n set req.hash_always_miss = true;\n }\n\n # Only allow BAN requests from IP addresses in the 'purge' ACL.\n if (req.method == \"BAN\" || req.method == \"URIBAN\" || req.method == \"PURGE\") {\n # Only allow BAN from defined ACL\n if (!client.ip ~ purge) {\n return (synth(403, \"Your IP is not allowed.\"));\n }\n\n # Only allows BAN if the Host Header has the style of with \"${SERVICE_NAME:-varnish}:8080\" or \"${SERVICE_NAME:-varnish}\".\n # Such a request is only possible from within the Docker network, as a request from external goes trough the Kubernetes Router and for that needs a proper Host Header\n if (!req.http.host ~ \"^${SERVICE_NAME:-varnish}(:\\d+)?$\") {\n return (synth(403, \"Only allowed from within own network.\"));\n }\n\n if (req.method == \"BAN\") {\n # Logic for the ban, using the Cache-Tags header.\n if (req.http.Cache-Tags) {\n ban(\"obj.http.Cache-Tags ~ \" + req.http.Cache-Tags);\n # Throw a synthetic page so the request won't go to the backend.\n return (synth(200, \"Ban added.\"));\n }\n else {\n return (synth(403, \"Cache-Tags header missing.\"));\n }\n }\n\n if (req.method == \"URIBAN\" || req.method == \"PURGE\") {\n ban(\"req.url ~ \" + req.url);\n # Throw a synthetic page so the request won't go to the backend.\n return (synth(200, \"Ban added.\"));\n }\n\n }\n\n # Non-RFC2616 or CONNECT which is weird, we pipe that\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n return (pipe);\n }\n\n # We only try to cache GET and HEAD, other things are passed\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n # Any requests with Basic Auth are passed\n if (req.http.Authorization || req.http.Authenticate)\n {\n return (pass);\n }\n\n ## Pass requests which are from blackfire\n if (req.http.X-Blackfire-Query) {\n return (pass);\n }\n\n # Some URLs should never be cached\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/admin([\/?]|$).*$\" ||\n req.url ~ \"^\/info([\/?]|$).*$\" ||\n req.url ~ \"^\/flag([\/?]|$).*$\" ||\n req.url ~ \"^.*\/system\/files([\/?]|$).*$\" ||\n req.url ~ \"^\/cgi\" ||\n req.url ~ \"^\/cgi-bin\"\n ) {\n return (pass);\n }\n\n # Plupload likes to get piped\n if (req.url ~ \"^.*\/plupload-handle-uploads.*$\"\n ) {\n return (pipe);\n }\n\n # Handle compression correctly. Different browsers send different\n # \"Accept-Encoding\" headers, even though they mostly all support the same\n # compression mechanisms. By consolidating these compression headers into\n # a consistent format, we can reduce the size of the cache and get more hits.=\n # @see: http:\/\/ varnish.projects.linpro.no\/wiki\/FAQ\/Compression\n if (req.http.Accept-Encoding) {\n if (req.http.Accept-Encoding ~ \"gzip\") {\n # If the browser supports it, we'll use gzip.\n set req.http.Accept-Encoding = \"gzip\";\n }\n else if (req.http.Accept-Encoding ~ \"deflate\") {\n # Next, try deflate if it is supported.\n set req.http.Accept-Encoding = \"deflate\";\n }\n else {\n # Unknown algorithm. Remove it and send unencoded.\n unset req.http.Accept-Encoding;\n }\n }\n\n # Always cache the following file types for all users.\n if (req.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n unset req.http.Cookie;\n }\n\n # Remove all cookies that Drupal doesn't need to know about. ANY remaining\n # cookie will cause the request to pass-through to a backend. For the most part\n # we always set the NO_CACHE cookie after any POST request, disabling the\n # Varnish cache temporarily. The session cookie allows all authenticated users\n # to pass through as long as they're logged in.\n #\n # 1. Append a semi-colon to the front of the cookie string.\n # 2. Remove all spaces that appear after semi-colons.\n # 3. Match the cookies we want to keep, adding the space we removed\n # previously, back. (\\1) is first matching group in the regsuball.\n # 4. Remove all other cookies, identifying them by the fact that they have\n # no space after the preceding semi-colon.\n # 5. Remove all spaces and semi-colons from the beginning and end of the\n # cookie string.\n if (req.http.Cookie) {\n set req.http.CookieCheck = \";\" + req.http.Cookie;\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"; +\", \";\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";(${VARNISH_COOKIECHECK:-SESS[a-z0-9]+|SSESS[a-z0-9]+|NO_CACHE})=\", \"; \\1=\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";[^ ][^;]*\", \"\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"^[; ]+|[; ]+$\", \"\");\n\n set req.http.Cookie = req.http.Cookie + \";\";\n\n if (req.http.CookieCheck == \"\") {\n # If there are no remaining cookies, remove the cookie header. If there\n # aren't any cookie headers, Varnish's default behavior will be to cache\n # the page.\n\n unset req.http.CookieCheck;\n unset req.http.Cookie;\n }\n else {\n # If there is any cookies left (a session or NO_CACHE cookie), do not\n # cache the page. Pass it on to Apache directly.\n unset req.http.CookieCheck;\n return (pass);\n }\n }\n\n # Cacheable, lookup in cache.\n return (hash);\n}\n\nsub vcl_pipe {\n # Support for Websockets\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n set bereq.http.connection = req.http.connection;\n }\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n # normal hit\n return (deliver);\n }\n # We have no fresh fish. Lets look at the stale ones.\n if (std.healthy(req.backend_hint)) {\n # Backend is healthy. If the object is not older then 30secs, deliver it to the client\n # and automatically create a separate backend request to warm the cache for this request.\n if (obj.ttl + 30s > 0s) {\n set req.http.grace = \"normal(limited)\";\n return (deliver);\n } else {\n # No candidate for grace. Fetch a fresh object.\n return(miss);\n }\n } else {\n # backend is sick - use full grace\n if (obj.ttl + obj.grace > 0s) {\n set req.http.grace = \"full\";\n return (deliver);\n } else {\n # no graced object.\n return (miss);\n }\n }\n}\n\nsub vcl_backend_response {\n # Allow items to be stale if needed.\n set beresp.grace = 6h;\n\n # Set ban-lurker friendly custom headers.\n set beresp.http.X-Url = bereq.url;\n set beresp.http.X-Host = bereq.http.host;\n\n # If the backend sends a X-LAGOON-VARNISH-BACKEND-BYPASS header we directly deliver\n if(beresp.http.X-LAGOON-VARNISH-BACKEND-BYPASS == \"TRUE\") {\n return (deliver);\n }\n\n # Cache 404 and 403 for 10 seconds\n if(beresp.status == 404 || beresp.status == 403) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n # Don't allow static files to set cookies.\n if (bereq.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n # beresp == Back-end response from the web server.\n unset beresp.http.set-cookie;\n unset beresp.http.Cache-Control;\n\n # If an asset would come back with statuscode 500 we only cache it for 10 seconds instead of the usual static file cache\n if (beresp.status == 500) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n set beresp.ttl = ${VARNISH_ASSETS_TTL:-2628001}s;\n set beresp.http.Cache-Control = \"public, max-age=${VARNISH_ASSETS_TTL:-2628001}\";\n set beresp.http.Expires = \"\" + (now + beresp.ttl);\n }\n\n return (deliver);\n}\n\n# Set a header to track a cache HIT\/MISS.\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Varnish-Cache = \"HIT\";\n }\n else {\n set resp.http.X-Varnish-Cache = \"MISS\";\n }\n\n # Remove ban-lurker friendly custom headers when delivering to client.\n unset resp.http.X-Url;\n unset resp.http.X-Host;\n\n # unset Cache-Tags Header by default, can be disabled with VARNISH_UNSET_HEADER_CACHE_TAGS=true\n if (!${VARNISH_UNSET_HEADER_CACHE_TAGS:-false}) {\n unset resp.http.Cache-Tags;\n }\n\n unset resp.http.X-Generator;\n unset resp.http.Server;\n # Inject information about grace\n if (req.http.grace) {\n set resp.http.X-Varnish-Grace = req.http.grace;\n }\n set resp.http.X-LAGOON = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}>\" + resp.http.X-LAGOON;\n return (deliver);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n if (req.http.X-Forwarded-Proto) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n if (req.http.HTTPS) {\n hash_data(req.http.HTTPS);\n }\n return (lookup);\n}\n\nsub vcl_synth {\n if (resp.status == 701) {\n set resp.status = 401;\n set resp.http.Content-Type = \"text\/plain; charset=utf-8\";\n synthetic({\"XMLRPC Interface is blocked due to SA-CORE-2014-004 - mail support@amazee.io if you need it.\"});\n return (deliver);\n }\n if (resp.status == 700) {\n # Set a status the client will understand\n set resp.status = 200;\n # Create our synthetic response\n synthetic(\"\");\n return(deliver);\n}\n return (deliver);\n}\n\nsub vcl_backend_error {\n # Restart the request, when we have a backend server error, to try another backend.\n # Restart max twice.\n if (bereq.retries < 2) {\n return(retry);\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<head>\n <title>Server Error<\/title>\n <style type=\"text\/css\">\n body {\n font-family: helvetica, arial, sans-serif;\n }\n img {\n margin-top: 50px;\n }\n p {\n width: 6 00px;\n margin-top: 10px\n }\n div {\n background: #ccc;\n width: 600px;\n margin: auto;\n padding: 50px;\n }\n span {\n color: #ccc\n }\n <\/style>\n<\/head>\n<body>\n <div>\n <h1>We are sorry...<\/h1>\n <p>We encountered a server-side error. This means that the problem is not with your computer or Internet connection, but rather with the website's server.<\/p>\n <p>We are currently working on solving this problem and apologise for the inconvenience.<\/p>\n <span>\n <strong>Technical Information<\/strong><br \/>\n Error \"} + beresp.status + \" \" + beresp.reason + {\"<br \/>\n XID: \"} + bereq.xid + {\"<br \/>\n <\/span>\n <\/div>\n<\/body>\n<\/html>\n\n\"} );\n return (deliver);\n}\n","old_contents":"vcl 4.0;\n\nimport std;\n\n# set backend default\nbackend default {\n .host = \"${VARNISH_BACKEND_HOST:-nginx}\";\n .port = \"${VARNISH_BACKEND_PORT:-8080}\";\n .first_byte_timeout = 35m;\n .between_bytes_timeout = 10m;\n}\n\n# set backend default\nbackend default {\n .host = \"${VARNISH_BACKEND_HOST:-nginx}\";\n .port = \"${VARNISH_BACKEND_PORT:-8080}\";\n .first_byte_timeout = 35m;\n .between_bytes_timeout = 10m;\n}\n\n# Allow purging from localhost\n# @TODO allow from openshift network\nacl purge {\n \"127.0.0.1\";\n \"10.0.0.0\"\/8;\n \"172.16.0.0\"\/12;\n \"192.168.0.0\"\/16;\n}\n\nsub vcl_init {\n new www_dir = dynamic.director(\n port = \"${VARNISH_BACKEND_PORT:-8080}\",\n first_byte_timeout = 90s,\n between_bytes_timeout = 90s,\n ttl = 60s);\n}\n\n# This configuration is optimized for Drupal hosting:\n# Respond to incoming requests.\nsub vcl_recv {\n if (req.url ~ \"^\/varnish_status$\") {\n return (synth(200,\"OK\"));\n }\n # set the backend, which should be used:\n set req.backend_hint = default;\n\n # Always set the forward ip.\n if (req.restarts == 0) {\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n\n\n if (req.http.X-LAGOON-VARNISH ) {\n ## Pass all Requests which are handled via an upstream Varnish\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, \" + req.http.X-LAGOON-VARNISH;\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n } else if (req.http.Fastly-FF) {\n ## Pass all Requests which are handled via Fastly\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, fastly\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n set req.http.X-Forwarded-For = req.http.Fastly-Client-IP;\n } else if (req.http.CF-RAY) {\n ## Pass all Requests which are handled via CloudFlare\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, cloudflare\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n set req.http.X-Forwarded-For = req.http.CF-Connecting-IP;\n } else if (req.http.X-Pull) {\n ## Pass all Requests which are handled via KeyCDN\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, keycdn\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n } else {\n ## We set a header to let a Varnish Chain know that it already has been varnishcached\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}\";\n\n ## Allow to bypass based on env variable `VARNISH_BYPASS`\n set req.http.X-LAGOON-VARNISH-BYPASS = \"${VARNISH_BYPASS:-false}\";\n }\n\n # Websockets are piped\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n if (req.http.X-LAGOON-VARNISH-BYPASS == \"true\" || req.http.X-LAGOON-VARNISH-BYPASS == \"TRUE\") {\n return (pass);\n }\n\n # SA-CORE-2014-004 preventing access to \/xmlrpc.php\n if (req.url ~ \"^\/xmlrpc.php$\") {\n return (synth(701, \"Unauthorized\"));\n }\n\n # Strip out Google Analytics campaign variables. They are only needed\n # by the javascript running on the page\n # utm_source, utm_medium, utm_campaign, gclid\n if(req.url ~ \"(\\?|&)(gclid|utm_[a-z]+)=\") {\n set req.url = regsuball(req.url, \"(gclid|utm_[a-z]+)=[^\\&]+&?\", \"\");\n set req.url = regsub(req.url, \"(\\?|&)$\", \"\");\n }\n\n # Bypass a cache hit (the request is still sent to the backend)\n if (req.method == \"REFRESH\") {\n if (!client.ip ~ purge) { return (synth(405, \"Not allowed\")); }\n set req.method = \"GET\";\n set req.hash_always_miss = true;\n }\n\n # Only allow BAN requests from IP addresses in the 'purge' ACL.\n if (req.method == \"BAN\" || req.method == \"URIBAN\" || req.method == \"PURGE\") {\n # Only allow BAN from defined ACL\n if (!client.ip ~ purge) {\n return (synth(403, \"Your IP is not allowed.\"));\n }\n\n # Only allows BAN if the Host Header has the style of with \"${SERVICE_NAME:-varnish}:8080\" or \"${SERVICE_NAME:-varnish}\".\n # Such a request is only possible from within the Docker network, as a request from external goes trough the Kubernetes Router and for that needs a proper Host Header\n if (!req.http.host ~ \"^${SERVICE_NAME:-varnish}(:\\d+)?$\") {\n return (synth(403, \"Only allowed from within own network.\"));\n }\n\n if (req.method == \"BAN\") {\n # Logic for the ban, using the Cache-Tags header.\n if (req.http.Cache-Tags) {\n ban(\"obj.http.Cache-Tags ~ \" + req.http.Cache-Tags);\n # Throw a synthetic page so the request won't go to the backend.\n return (synth(200, \"Ban added.\"));\n }\n else {\n return (synth(403, \"Cache-Tags header missing.\"));\n }\n }\n\n if (req.method == \"URIBAN\" || req.method == \"PURGE\") {\n ban(\"req.url ~ \" + req.url);\n # Throw a synthetic page so the request won't go to the backend.\n return (synth(200, \"Ban added.\"));\n }\n\n }\n\n # Non-RFC2616 or CONNECT which is weird, we pipe that\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n return (pipe);\n }\n\n # We only try to cache GET and HEAD, other things are passed\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n # Any requests with Basic Auth are passed\n if (req.http.Authorization || req.http.Authenticate)\n {\n return (pass);\n }\n\n ## Pass requests which are from blackfire\n if (req.http.X-Blackfire-Query) {\n return (pass);\n }\n\n # Some URLs should never be cached\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/admin([\/?]|$).*$\" ||\n req.url ~ \"^\/info([\/?]|$).*$\" ||\n req.url ~ \"^\/flag([\/?]|$).*$\" ||\n req.url ~ \"^.*\/system\/files([\/?]|$).*$\" ||\n req.url ~ \"^\/cgi\" ||\n req.url ~ \"^\/cgi-bin\"\n ) {\n return (pass);\n }\n\n # Plupload likes to get piped\n if (req.url ~ \"^.*\/plupload-handle-uploads.*$\"\n ) {\n return (pipe);\n }\n\n # Handle compression correctly. Different browsers send different\n # \"Accept-Encoding\" headers, even though they mostly all support the same\n # compression mechanisms. By consolidating these compression headers into\n # a consistent format, we can reduce the size of the cache and get more hits.=\n # @see: http:\/\/ varnish.projects.linpro.no\/wiki\/FAQ\/Compression\n if (req.http.Accept-Encoding) {\n if (req.http.Accept-Encoding ~ \"gzip\") {\n # If the browser supports it, we'll use gzip.\n set req.http.Accept-Encoding = \"gzip\";\n }\n else if (req.http.Accept-Encoding ~ \"deflate\") {\n # Next, try deflate if it is supported.\n set req.http.Accept-Encoding = \"deflate\";\n }\n else {\n # Unknown algorithm. Remove it and send unencoded.\n unset req.http.Accept-Encoding;\n }\n }\n\n # Always cache the following file types for all users.\n if (req.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n unset req.http.Cookie;\n }\n\n # Remove all cookies that Drupal doesn't need to know about. ANY remaining\n # cookie will cause the request to pass-through to a backend. For the most part\n # we always set the NO_CACHE cookie after any POST request, disabling the\n # Varnish cache temporarily. The session cookie allows all authenticated users\n # to pass through as long as they're logged in.\n #\n # 1. Append a semi-colon to the front of the cookie string.\n # 2. Remove all spaces that appear after semi-colons.\n # 3. Match the cookies we want to keep, adding the space we removed\n # previously, back. (\\1) is first matching group in the regsuball.\n # 4. Remove all other cookies, identifying them by the fact that they have\n # no space after the preceding semi-colon.\n # 5. Remove all spaces and semi-colons from the beginning and end of the\n # cookie string.\n if (req.http.Cookie) {\n set req.http.CookieCheck = \";\" + req.http.Cookie;\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"; +\", \";\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";(${VARNISH_COOKIECHECK:-SESS[a-z0-9]+|SSESS[a-z0-9]+|NO_CACHE})=\", \"; \\1=\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";[^ ][^;]*\", \"\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"^[; ]+|[; ]+$\", \"\");\n\n set req.http.Cookie = req.http.Cookie + \";\";\n\n if (req.http.CookieCheck == \"\") {\n # If there are no remaining cookies, remove the cookie header. If there\n # aren't any cookie headers, Varnish's default behavior will be to cache\n # the page.\n\n unset req.http.CookieCheck;\n unset req.http.Cookie;\n }\n else {\n # If there is any cookies left (a session or NO_CACHE cookie), do not\n # cache the page. Pass it on to Apache directly.\n unset req.http.CookieCheck;\n return (pass);\n }\n }\n\n # Cacheable, lookup in cache.\n return (hash);\n}\n\nsub vcl_pipe {\n # Support for Websockets\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n set bereq.http.connection = req.http.connection;\n }\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n # normal hit\n return (deliver);\n }\n # We have no fresh fish. Lets look at the stale ones.\n if (std.healthy(req.backend_hint)) {\n # Backend is healthy. If the object is not older then 30secs, deliver it to the client\n # and automatically create a separate backend request to warm the cache for this request.\n if (obj.ttl + 30s > 0s) {\n set req.http.grace = \"normal(limited)\";\n return (deliver);\n } else {\n # No candidate for grace. Fetch a fresh object.\n return(miss);\n }\n } else {\n # backend is sick - use full grace\n if (obj.ttl + obj.grace > 0s) {\n set req.http.grace = \"full\";\n return (deliver);\n } else {\n # no graced object.\n return (miss);\n }\n }\n}\n\nsub vcl_backend_response {\n # Allow items to be stale if needed.\n set beresp.grace = 6h;\n\n # Set ban-lurker friendly custom headers.\n set beresp.http.X-Url = bereq.url;\n set beresp.http.X-Host = bereq.http.host;\n\n # If the backend sends a X-LAGOON-VARNISH-BACKEND-BYPASS header we directly deliver\n if(beresp.http.X-LAGOON-VARNISH-BACKEND-BYPASS == \"TRUE\") {\n return (deliver);\n }\n\n # Cache 404 and 403 for 10 seconds\n if(beresp.status == 404 || beresp.status == 403) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n # Don't allow static files to set cookies.\n if (bereq.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n # beresp == Back-end response from the web server.\n unset beresp.http.set-cookie;\n unset beresp.http.Cache-Control;\n\n # If an asset would come back with statuscode 500 we only cache it for 10 seconds instead of the usual static file cache\n if (beresp.status == 500) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n set beresp.ttl = ${VARNISH_ASSETS_TTL:-2628001}s;\n set beresp.http.Cache-Control = \"public, max-age=${VARNISH_ASSETS_TTL:-2628001}\";\n set beresp.http.Expires = \"\" + (now + beresp.ttl);\n }\n\n return (deliver);\n}\n\n# Set a header to track a cache HIT\/MISS.\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Varnish-Cache = \"HIT\";\n }\n else {\n set resp.http.X-Varnish-Cache = \"MISS\";\n }\n\n # Remove ban-lurker friendly custom headers when delivering to client.\n unset resp.http.X-Url;\n unset resp.http.X-Host;\n\n # unset Cache-Tags Header by default, can be disabled with VARNISH_UNSET_HEADER_CACHE_TAGS=true\n if (!${VARNISH_UNSET_HEADER_CACHE_TAGS:-false}) {\n unset resp.http.Cache-Tags;\n }\n\n unset resp.http.X-Generator;\n unset resp.http.Server;\n # Inject information about grace\n if (req.http.grace) {\n set resp.http.X-Varnish-Grace = req.http.grace;\n }\n set resp.http.X-LAGOON = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}>\" + resp.http.X-LAGOON;\n return (deliver);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n if (req.http.X-Forwarded-Proto) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n if (req.http.HTTPS) {\n hash_data(req.http.HTTPS);\n }\n return (lookup);\n}\n\nsub vcl_synth {\n if (resp.status == 701) {\n set resp.status = 401;\n set resp.http.Content-Type = \"text\/plain; charset=utf-8\";\n synthetic({\"XMLRPC Interface is blocked due to SA-CORE-2014-004 - mail support@amazee.io if you need it.\"});\n return (deliver);\n }\n if (resp.status == 700) {\n # Set a status the client will understand\n set resp.status = 200;\n # Create our synthetic response\n synthetic(\"\");\n return(deliver);\n}\n return (deliver);\n}\n\nsub vcl_backend_error {\n # Restart the request, when we have a backend server error, to try another backend.\n # Restart max twice.\n if (bereq.retries < 2) {\n return(retry);\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<head>\n <title>Server Error<\/title>\n <style type=\"text\/css\">\n body {\n font-family: helvetica, arial, sans-serif;\n }\n img {\n margin-top: 50px;\n }\n p {\n width: 6 00px;\n margin-top: 10px\n }\n div {\n background: #ccc;\n width: 600px;\n margin: auto;\n padding: 50px;\n }\n span {\n color: #ccc\n }\n <\/style>\n<\/head>\n<body>\n <div>\n <h1>We are sorry...<\/h1>\n <p>We encountered a server-side error. This means that the problem is not with your computer or Internet connection, but rather with the website's server.<\/p>\n <p>We are currently working on solving this problem and apologise for the inconvenience.<\/p>\n <span>\n <strong>Technical Information<\/strong><br \/>\n Error \"} + beresp.status + \" \" + beresp.reason + {\"<br \/>\n XID: \"} + bereq.xid + {\"<br \/>\n <\/span>\n <\/div>\n<\/body>\n<\/html>\n\n\"} );\n return (deliver);\n}\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"829df0e320d0036353d7346bc910b46a265e0a54","subject":"Added support to override varish cookie check rule.","message":"Added support to override varish cookie check rule.\n","repos":"amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon","old_file":"images\/varnish-drupal\/drupal.vcl","new_file":"images\/varnish-drupal\/drupal.vcl","new_contents":"vcl 4.0;\n\nimport std;\n\n# set backend default\nbackend default {\n .host = \"${VARNISH_BACKEND_HOST:-nginx}\";\n .port = \"${VARNISH_BACKEND_PORT:-8080}\";\n .first_byte_timeout = 35m;\n .between_bytes_timeout = 10m;\n}\n\n# Allow purging from localhost\n# @TODO allow from openshift network\nacl purge {\n \"127.0.0.1\";\n \"10.0.0.0\"\/8;\n \"172.16.0.0\"\/12;\n \"192.168.0.0\"\/16;\n}\n\n# This configuration is optimized for Drupal hosting:\n# Respond to incoming requests.\nsub vcl_recv {\n if (req.url ~ \"^\/varnish_status$\") {\n return (synth(200,\"OK\"));\n }\n # set the backend, which should be used:\n set req.backend_hint = default;\n\n # Always set the forward ip.\n if (req.restarts == 0) {\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n\n\n if (req.http.X-LAGOON-VARNISH ) {\n ## Pass all Requests which are handled via an upstream Varnish\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, \" + req.http.X-LAGOON-VARNISH;\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n } else if (req.http.Fastly-FF) {\n ## Pass all Requests which are handled via Fastly\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, fastly\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n set req.http.X-Forwarded-For = req.http.Fastly-Client-IP;\n } else if (req.http.CF-RAY) {\n ## Pass all Requests which are handled via CloudFlare\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, cloudflare\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n set req.http.X-Forwarded-For = req.http.CF-Connecting-IP;\n } else if (req.http.X-Pull) {\n ## Pass all Requests which are handled via KeyCDN\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, keycdn\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n } else {\n ## We set a header to let a Varnish Chain know that it already has been varnishcached\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}\";\n\n ## Allow to bypass based on env variable `VARNISH_BYPASS`\n set req.http.X-LAGOON-VARNISH-BYPASS = \"${VARNISH_BYPASS:-false}\";\n }\n\n # Websockets are piped\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n if (req.http.X-LAGOON-VARNISH-BYPASS == \"true\" || req.http.X-LAGOON-VARNISH-BYPASS == \"TRUE\") {\n return (pass);\n }\n\n # SA-CORE-2014-004 preventing access to \/xmlrpc.php\n if (req.url ~ \"^\/xmlrpc.php$\") {\n return (synth(701, \"Unauthorized\"));\n }\n\n # Strip out Google Analytics campaign variables. They are only needed\n # by the javascript running on the page\n # utm_source, utm_medium, utm_campaign, gclid\n if(req.url ~ \"(\\?|&)(gclid|utm_[a-z]+)=\") {\n set req.url = regsuball(req.url, \"(gclid|utm_[a-z]+)=[^\\&]+&?\", \"\");\n set req.url = regsub(req.url, \"(\\?|&)$\", \"\");\n }\n\n # Bypass a cache hit (the request is still sent to the backend)\n if (req.method == \"REFRESH\") {\n if (!client.ip ~ purge) { return (synth(405, \"Not allowed\")); }\n set req.method = \"GET\";\n set req.hash_always_miss = true;\n }\n\n # Only allow BAN requests from IP addresses in the 'purge' ACL.\n if (req.method == \"BAN\") {\n # Only allow BAN from defined ACL\n if (!client.ip ~ purge) {\n return (synth(403, \"Your IP is not allowed.\"));\n }\n\n # Only allows BAN if the Host Header has the style of with \"${SERVICE_NAME:-varnish}:8080\" or \"${SERVICE_NAME:-varnish}\".\n # Such a request is only possible from within the Docker network, as a request from external goes trough the Kubernetes Router and for that needs a proper Host Header\n if (!req.http.host ~ \"^${SERVICE_NAME:-varnish}(:\\d+)?$\") {\n return (synth(403, \"BAN only allowed from within own network.\"));\n }\n\n # Logic for the ban, using the Cache-Tags header.\n if (req.http.Cache-Tags) {\n ban(\"obj.http.Cache-Tags ~ \" + req.http.Cache-Tags);\n }\n else {\n return (synth(403, \"Cache-Tags header missing.\"));\n }\n\n # Throw a synthetic page so the request won't go to the backend.\n return (synth(200, \"Ban added.\"));\n }\n\n if (req.method == \"URIBAN\") {\n ban(\"req.http.host == \" + req.http.host + \" && req.url == \" + req.url);\n # Throw a synthetic page so the request won't go to the backend.\n return (synth(200, \"Ban added.\"));\n }\n\n # Non-RFC2616 or CONNECT which is weird, we pipe that\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n return (pipe);\n }\n\n # We only try to cache GET and HEAD, other things are passed\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n # Any requests with Basic Auth are passed\n if (req.http.Authorization || req.http.Authenticate)\n {\n return (pass);\n }\n\n ## Pass requests which are from blackfire\n if (req.http.X-Blackfire-Query) {\n return (pass);\n }\n\n # Some URLs should never be cached\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/admin([\/?]|$).*$\" ||\n req.url ~ \"^\/info([\/?]|$).*$\" ||\n req.url ~ \"^\/flag([\/?]|$).*$\" ||\n req.url ~ \"^.*\/system\/files([\/?]|$).*$\" ||\n req.url ~ \"^\/cgi\" ||\n req.url ~ \"^\/cgi-bin\"\n ) {\n return (pass);\n }\n\n # Plupload likes to get piped\n if (req.url ~ \"^.*\/plupload-handle-uploads.*$\"\n ) {\n return (pipe);\n }\n\n # Handle compression correctly. Different browsers send different\n # \"Accept-Encoding\" headers, even though they mostly all support the same\n # compression mechanisms. By consolidating these compression headers into\n # a consistent format, we can reduce the size of the cache and get more hits.=\n # @see: http:\/\/ varnish.projects.linpro.no\/wiki\/FAQ\/Compression\n if (req.http.Accept-Encoding) {\n if (req.http.Accept-Encoding ~ \"gzip\") {\n # If the browser supports it, we'll use gzip.\n set req.http.Accept-Encoding = \"gzip\";\n }\n else if (req.http.Accept-Encoding ~ \"deflate\") {\n # Next, try deflate if it is supported.\n set req.http.Accept-Encoding = \"deflate\";\n }\n else {\n # Unknown algorithm. Remove it and send unencoded.\n unset req.http.Accept-Encoding;\n }\n }\n\n # Always cache the following file types for all users.\n if (req.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n unset req.http.Cookie;\n }\n\n # Remove all cookies that Drupal doesn't need to know about. ANY remaining\n # cookie will cause the request to pass-through to a backend. For the most part\n # we always set the NO_CACHE cookie after any POST request, disabling the\n # Varnish cache temporarily. The session cookie allows all authenticated users\n # to pass through as long as they're logged in.\n #\n # 1. Append a semi-colon to the front of the cookie string.\n # 2. Remove all spaces that appear after semi-colons.\n # 3. Match the cookies we want to keep, adding the space we removed\n # previously, back. (\\1) is first matching group in the regsuball.\n # 4. Remove all other cookies, identifying them by the fact that they have\n # no space after the preceding semi-colon.\n # 5. Remove all spaces and semi-colons from the beginning and end of the\n # cookie string.\n if (req.http.Cookie) {\n set req.http.CookieCheck = \";\" + req.http.Cookie;\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"; +\", \";\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";(${VARNISH_COOKIECHECK:-SESS[a-z0-9]+|SSESS[a-z0-9]+|NO_CACHE})=\", \"; \\1=\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";[^ ][^;]*\", \"\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"^[; ]+|[; ]+$\", \"\");\n\n set req.http.Cookie = req.http.Cookie + \";\";\n\n if (req.http.CookieCheck == \"\") {\n # If there are no remaining cookies, remove the cookie header. If there\n # aren't any cookie headers, Varnish's default behavior will be to cache\n # the page.\n\n unset req.http.CookieCheck;\n unset req.http.Cookie;\n }\n else {\n # If there is any cookies left (a session or NO_CACHE cookie), do not\n # cache the page. Pass it on to Apache directly.\n unset req.http.CookieCheck;\n return (pass);\n }\n }\n\n # Cacheable, lookup in cache.\n return (hash);\n}\n\nsub vcl_pipe {\n # Support for Websockets\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n set bereq.http.connection = req.http.connection;\n }\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n # normal hit\n return (deliver);\n }\n # We have no fresh fish. Lets look at the stale ones.\n if (std.healthy(req.backend_hint)) {\n # Backend is healthy. If the object is not older then 30secs, deliver it to the client\n # and automatically create a separate backend request to warm the cache for this request.\n if (obj.ttl + 30s > 0s) {\n set req.http.grace = \"normal(limited)\";\n return (deliver);\n } else {\n # No candidate for grace. Fetch a fresh object.\n return(miss);\n }\n } else {\n # backend is sick - use full grace\n if (obj.ttl + obj.grace > 0s) {\n set req.http.grace = \"full\";\n return (deliver);\n } else {\n # no graced object.\n return (miss);\n }\n }\n}\n\nsub vcl_backend_response {\n # Allow items to be stale if needed.\n set beresp.grace = 6h;\n\n # Set ban-lurker friendly custom headers.\n set beresp.http.X-Url = bereq.url;\n set beresp.http.X-Host = bereq.http.host;\n\n # If the backend sends a X-LAGOON-VARNISH-BACKEND-BYPASS header we directly deliver\n if(beresp.http.X-LAGOON-VARNISH-BACKEND-BYPASS == \"TRUE\") {\n return (deliver);\n }\n\n # Cache 404 and 403 for 10 seconds\n if(beresp.status == 404 || beresp.status == 403) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n # Don't allow static files to set cookies.\n if (bereq.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n # beresp == Back-end response from the web server.\n unset beresp.http.set-cookie;\n unset beresp.http.Cache-Control;\n\n # If an asset would come back with statuscode 500 we only cache it for 10 seconds instead of the usual static file cache\n if (beresp.status == 500) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n set beresp.ttl = ${VARNISH_ASSETS_TTL:-2628001}s;\n set beresp.http.Cache-Control = \"public, max-age=${VARNISH_ASSETS_TTL:-2628001}\";\n set beresp.http.Expires = \"\" + (now + beresp.ttl);\n }\n\n return (deliver);\n}\n\n# Set a header to track a cache HIT\/MISS.\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Varnish-Cache = \"HIT\";\n }\n else {\n set resp.http.X-Varnish-Cache = \"MISS\";\n }\n\n # Remove ban-lurker friendly custom headers when delivering to client.\n unset resp.http.X-Url;\n unset resp.http.X-Host;\n\n # unset Cache-Tags Header by default, can be disabled with VARNISH_UNSET_HEADER_CACHE_TAGS=true\n if (!${VARNISH_UNSET_HEADER_CACHE_TAGS:-false}) {\n unset resp.http.Cache-Tags;\n }\n\n unset resp.http.X-Generator;\n unset resp.http.Server;\n # Inject information about grace\n if (req.http.grace) {\n set resp.http.X-Varnish-Grace = req.http.grace;\n }\n set resp.http.X-LAGOON = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}>\" + resp.http.X-LAGOON;\n return (deliver);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n if (req.http.X-Forwarded-Proto) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n if (req.http.HTTPS) {\n hash_data(req.http.HTTPS);\n }\n return (lookup);\n}\n\nsub vcl_synth {\n if (resp.status == 701) {\n set resp.status = 401;\n set resp.http.Content-Type = \"text\/plain; charset=utf-8\";\n synthetic({\"XMLRPC Interface is blocked due to SA-CORE-2014-004 - mail support@amazee.io if you need it.\"});\n return (deliver);\n }\n if (resp.status == 700) {\n # Set a status the client will understand\n set resp.status = 200;\n # Create our synthetic response\n synthetic(\"\");\n return(deliver);\n}\n return (deliver);\n}\n\nsub vcl_backend_error {\n # Restart the request, when we have a backend server error, to try another backend.\n # Restart max twice.\n if (bereq.retries < 2) {\n return(retry);\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<head>\n <title>Server Error<\/title>\n <style type=\"text\/css\">\n body {\n font-family: helvetica, arial, sans-serif;\n }\n img {\n margin-top: 50px;\n }\n p {\n width: 6 00px;\n margin-top: 10px\n }\n div {\n background: #ccc;\n width: 600px;\n margin: auto;\n padding: 50px;\n }\n span {\n color: #ccc\n }\n <\/style>\n<\/head>\n<body>\n <div>\n <h1>We are sorry...<\/h1>\n <p>We encountered a server-side error. This means that the problem is not with your computer or Internet connection, but rather with the website's server.<\/p>\n <p>We are currently working on solving this problem and apologise for the inconvenience.<\/p>\n <span>\n <strong>Technical Information<\/strong><br \/>\n Error \"} + beresp.status + \" \" + beresp.reason + {\"<br \/>\n XID: \"} + bereq.xid + {\"<br \/>\n <\/span>\n <\/div>\n<\/body>\n<\/html>\n\n\"} );\n return (deliver);\n}\n","old_contents":"vcl 4.0;\n\nimport std;\n\n# set backend default\nbackend default {\n .host = \"${VARNISH_BACKEND_HOST:-nginx}\";\n .port = \"${VARNISH_BACKEND_PORT:-8080}\";\n .first_byte_timeout = 35m;\n .between_bytes_timeout = 10m;\n}\n\n# Allow purging from localhost\n# @TODO allow from openshift network\nacl purge {\n \"127.0.0.1\";\n \"10.0.0.0\"\/8;\n \"172.16.0.0\"\/12;\n \"192.168.0.0\"\/16;\n}\n\n# This configuration is optimized for Drupal hosting:\n# Respond to incoming requests.\nsub vcl_recv {\n if (req.url ~ \"^\/varnish_status$\") {\n return (synth(200,\"OK\"));\n }\n # set the backend, which should be used:\n set req.backend_hint = default;\n\n # Always set the forward ip.\n if (req.restarts == 0) {\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n\n\n if (req.http.X-LAGOON-VARNISH ) {\n ## Pass all Requests which are handled via an upstream Varnish\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, \" + req.http.X-LAGOON-VARNISH;\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n } else if (req.http.Fastly-FF) {\n ## Pass all Requests which are handled via Fastly\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, fastly\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n set req.http.X-Forwarded-For = req.http.Fastly-Client-IP;\n } else if (req.http.CF-RAY) {\n ## Pass all Requests which are handled via CloudFlare\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, cloudflare\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n set req.http.X-Forwarded-For = req.http.CF-Connecting-IP;\n } else if (req.http.X-Pull) {\n ## Pass all Requests which are handled via KeyCDN\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, keycdn\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n } else {\n ## We set a header to let a Varnish Chain know that it already has been varnishcached\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}\";\n\n ## Allow to bypass based on env variable `VARNISH_BYPASS`\n set req.http.X-LAGOON-VARNISH-BYPASS = \"${VARNISH_BYPASS:-false}\";\n }\n\n # Websockets are piped\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n if (req.http.X-LAGOON-VARNISH-BYPASS == \"true\" || req.http.X-LAGOON-VARNISH-BYPASS == \"TRUE\") {\n return (pass);\n }\n\n # SA-CORE-2014-004 preventing access to \/xmlrpc.php\n if (req.url ~ \"^\/xmlrpc.php$\") {\n return (synth(701, \"Unauthorized\"));\n }\n\n # Strip out Google Analytics campaign variables. They are only needed\n # by the javascript running on the page\n # utm_source, utm_medium, utm_campaign, gclid\n if(req.url ~ \"(\\?|&)(gclid|utm_[a-z]+)=\") {\n set req.url = regsuball(req.url, \"(gclid|utm_[a-z]+)=[^\\&]+&?\", \"\");\n set req.url = regsub(req.url, \"(\\?|&)$\", \"\");\n }\n\n # Bypass a cache hit (the request is still sent to the backend)\n if (req.method == \"REFRESH\") {\n if (!client.ip ~ purge) { return (synth(405, \"Not allowed\")); }\n set req.method = \"GET\";\n set req.hash_always_miss = true;\n }\n\n # Only allow BAN requests from IP addresses in the 'purge' ACL.\n if (req.method == \"BAN\") {\n # Only allow BAN from defined ACL\n if (!client.ip ~ purge) {\n return (synth(403, \"Your IP is not allowed.\"));\n }\n\n # Only allows BAN if the Host Header has the style of with \"${SERVICE_NAME:-varnish}:8080\" or \"${SERVICE_NAME:-varnish}\".\n # Such a request is only possible from within the Docker network, as a request from external goes trough the Kubernetes Router and for that needs a proper Host Header\n if (!req.http.host ~ \"^${SERVICE_NAME:-varnish}(:\\d+)?$\") {\n return (synth(403, \"BAN only allowed from within own network.\"));\n }\n\n # Logic for the ban, using the Cache-Tags header.\n if (req.http.Cache-Tags) {\n ban(\"obj.http.Cache-Tags ~ \" + req.http.Cache-Tags);\n }\n else {\n return (synth(403, \"Cache-Tags header missing.\"));\n }\n\n # Throw a synthetic page so the request won't go to the backend.\n return (synth(200, \"Ban added.\"));\n }\n\n if (req.method == \"URIBAN\") {\n ban(\"req.http.host == \" + req.http.host + \" && req.url == \" + req.url);\n # Throw a synthetic page so the request won't go to the backend.\n return (synth(200, \"Ban added.\"));\n }\n\n # Non-RFC2616 or CONNECT which is weird, we pipe that\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n return (pipe);\n }\n\n # We only try to cache GET and HEAD, other things are passed\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n # Any requests with Basic Auth are passed\n if (req.http.Authorization || req.http.Authenticate)\n {\n return (pass);\n }\n\n ## Pass requests which are from blackfire\n if (req.http.X-Blackfire-Query) {\n return (pass);\n }\n\n # Some URLs should never be cached\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/admin([\/?]|$).*$\" ||\n req.url ~ \"^\/info([\/?]|$).*$\" ||\n req.url ~ \"^\/flag([\/?]|$).*$\" ||\n req.url ~ \"^.*\/system\/files([\/?]|$).*$\" ||\n req.url ~ \"^\/cgi\" ||\n req.url ~ \"^\/cgi-bin\"\n ) {\n return (pass);\n }\n\n # Plupload likes to get piped\n if (req.url ~ \"^.*\/plupload-handle-uploads.*$\"\n ) {\n return (pipe);\n }\n\n # Handle compression correctly. Different browsers send different\n # \"Accept-Encoding\" headers, even though they mostly all support the same\n # compression mechanisms. By consolidating these compression headers into\n # a consistent format, we can reduce the size of the cache and get more hits.=\n # @see: http:\/\/ varnish.projects.linpro.no\/wiki\/FAQ\/Compression\n if (req.http.Accept-Encoding) {\n if (req.http.Accept-Encoding ~ \"gzip\") {\n # If the browser supports it, we'll use gzip.\n set req.http.Accept-Encoding = \"gzip\";\n }\n else if (req.http.Accept-Encoding ~ \"deflate\") {\n # Next, try deflate if it is supported.\n set req.http.Accept-Encoding = \"deflate\";\n }\n else {\n # Unknown algorithm. Remove it and send unencoded.\n unset req.http.Accept-Encoding;\n }\n }\n\n # Always cache the following file types for all users.\n if (req.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n unset req.http.Cookie;\n }\n\n # Remove all cookies that Drupal doesn't need to know about. ANY remaining\n # cookie will cause the request to pass-through to a backend. For the most part\n # we always set the NO_CACHE cookie after any POST request, disabling the\n # Varnish cache temporarily. The session cookie allows all authenticated users\n # to pass through as long as they're logged in.\n #\n # 1. Append a semi-colon to the front of the cookie string.\n # 2. Remove all spaces that appear after semi-colons.\n # 3. Match the cookies we want to keep, adding the space we removed\n # previously, back. (\\1) is first matching group in the regsuball.\n # 4. Remove all other cookies, identifying them by the fact that they have\n # no space after the preceding semi-colon.\n # 5. Remove all spaces and semi-colons from the beginning and end of the\n # cookie string.\n if (req.http.Cookie) {\n set req.http.CookieCheck = \";\" + req.http.Cookie;\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"; +\", \";\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";(SESS[a-z0-9]+|SSESS[a-z0-9]+|NO_CACHE)=\", \"; \\1=\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";[^ ][^;]*\", \"\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"^[; ]+|[; ]+$\", \"\");\n\n set req.http.Cookie = req.http.Cookie + \";\";\n\n if (req.http.CookieCheck == \"\") {\n # If there are no remaining cookies, remove the cookie header. If there\n # aren't any cookie headers, Varnish's default behavior will be to cache\n # the page.\n\n unset req.http.CookieCheck;\n unset req.http.Cookie;\n }\n else {\n # If there is any cookies left (a session or NO_CACHE cookie), do not\n # cache the page. Pass it on to Apache directly.\n unset req.http.CookieCheck;\n return (pass);\n }\n }\n\n # Cacheable, lookup in cache.\n return (hash);\n}\n\nsub vcl_pipe {\n # Support for Websockets\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n set bereq.http.connection = req.http.connection;\n }\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n # normal hit\n return (deliver);\n }\n # We have no fresh fish. Lets look at the stale ones.\n if (std.healthy(req.backend_hint)) {\n # Backend is healthy. If the object is not older then 30secs, deliver it to the client\n # and automatically create a separate backend request to warm the cache for this request.\n if (obj.ttl + 30s > 0s) {\n set req.http.grace = \"normal(limited)\";\n return (deliver);\n } else {\n # No candidate for grace. Fetch a fresh object.\n return(miss);\n }\n } else {\n # backend is sick - use full grace\n if (obj.ttl + obj.grace > 0s) {\n set req.http.grace = \"full\";\n return (deliver);\n } else {\n # no graced object.\n return (miss);\n }\n }\n}\n\nsub vcl_backend_response {\n # Allow items to be stale if needed.\n set beresp.grace = 6h;\n\n # Set ban-lurker friendly custom headers.\n set beresp.http.X-Url = bereq.url;\n set beresp.http.X-Host = bereq.http.host;\n\n # If the backend sends a X-LAGOON-VARNISH-BACKEND-BYPASS header we directly deliver\n if(beresp.http.X-LAGOON-VARNISH-BACKEND-BYPASS == \"TRUE\") {\n return (deliver);\n }\n\n # Cache 404 and 403 for 10 seconds\n if(beresp.status == 404 || beresp.status == 403) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n # Don't allow static files to set cookies.\n if (bereq.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n # beresp == Back-end response from the web server.\n unset beresp.http.set-cookie;\n unset beresp.http.Cache-Control;\n\n # If an asset would come back with statuscode 500 we only cache it for 10 seconds instead of the usual static file cache\n if (beresp.status == 500) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n set beresp.ttl = ${VARNISH_ASSETS_TTL:-2628001}s;\n set beresp.http.Cache-Control = \"public, max-age=${VARNISH_ASSETS_TTL:-2628001}\";\n set beresp.http.Expires = \"\" + (now + beresp.ttl);\n }\n\n return (deliver);\n}\n\n# Set a header to track a cache HIT\/MISS.\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Varnish-Cache = \"HIT\";\n }\n else {\n set resp.http.X-Varnish-Cache = \"MISS\";\n }\n\n # Remove ban-lurker friendly custom headers when delivering to client.\n unset resp.http.X-Url;\n unset resp.http.X-Host;\n\n # unset Cache-Tags Header by default, can be disabled with VARNISH_UNSET_HEADER_CACHE_TAGS=true\n if (!${VARNISH_UNSET_HEADER_CACHE_TAGS:-false}) {\n unset resp.http.Cache-Tags;\n }\n\n unset resp.http.X-Generator;\n unset resp.http.Server;\n # Inject information about grace\n if (req.http.grace) {\n set resp.http.X-Varnish-Grace = req.http.grace;\n }\n set resp.http.X-LAGOON = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}>\" + resp.http.X-LAGOON;\n return (deliver);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n if (req.http.X-Forwarded-Proto) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n if (req.http.HTTPS) {\n hash_data(req.http.HTTPS);\n }\n return (lookup);\n}\n\nsub vcl_synth {\n if (resp.status == 701) {\n set resp.status = 401;\n set resp.http.Content-Type = \"text\/plain; charset=utf-8\";\n synthetic({\"XMLRPC Interface is blocked due to SA-CORE-2014-004 - mail support@amazee.io if you need it.\"});\n return (deliver);\n }\n if (resp.status == 700) {\n # Set a status the client will understand\n set resp.status = 200;\n # Create our synthetic response\n synthetic(\"\");\n return(deliver);\n}\n return (deliver);\n}\n\nsub vcl_backend_error {\n # Restart the request, when we have a backend server error, to try another backend.\n # Restart max twice.\n if (bereq.retries < 2) {\n return(retry);\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<head>\n <title>Server Error<\/title>\n <style type=\"text\/css\">\n body {\n font-family: helvetica, arial, sans-serif;\n }\n img {\n margin-top: 50px;\n }\n p {\n width: 6 00px;\n margin-top: 10px\n }\n div {\n background: #ccc;\n width: 600px;\n margin: auto;\n padding: 50px;\n }\n span {\n color: #ccc\n }\n <\/style>\n<\/head>\n<body>\n <div>\n <h1>We are sorry...<\/h1>\n <p>We encountered a server-side error. This means that the problem is not with your computer or Internet connection, but rather with the website's server.<\/p>\n <p>We are currently working on solving this problem and apologise for the inconvenience.<\/p>\n <span>\n <strong>Technical Information<\/strong><br \/>\n Error \"} + beresp.status + \" \" + beresp.reason + {\"<br \/>\n XID: \"} + bereq.xid + {\"<br \/>\n <\/span>\n <\/div>\n<\/body>\n<\/html>\n\n\"} );\n return (deliver);\n}\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"3add621b5812f2a245c4ec9dc9c0523ab13909fd","subject":"don't strip set-cookie header when editing","message":"don't strip set-cookie header when editing\n","repos":"jclgoodwin\/bustimes.org.uk,jclgoodwin\/bustimes.org.uk,jclgoodwin\/bustimes.org.uk,jclgoodwin\/bustimes.org.uk","old_file":"config\/varnish\/default.vcl","new_file":"config\/varnish\/default.vcl","new_contents":"# Marker to tell the VCL compiler that this VCL has been adapted to the\n# new 4.0 format.\nvcl 4.0;\n\n# Default backend definition. Set this to point to your content server.\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\n\nsub vcl_recv {\n # Happens before we check if we have this in cache already.\n #\n # Typically you clean up the request here, removing cookies you don't need,\n # rewriting the request, etc.\n\n if (req.url ~ \"^\/(admin\/|contact|awin-transaction)\" || req.url ~ \"\/edit\") {\n return (pass);\n }\n\n # special features on fleet lists for logged in users\n if (req.http.Cookie ~ \"sessionid\" && req.url ~ \"operator\" && req.url ~ \"vehicles\") {\n return (pass);\n }\n\n unset req.http.Cookie;\n}\n\nsub vcl_backend_response {\n # Happens after we have read the response headers from the backend.\n #\n # Here you clean the response headers, removing silly Set-Cookie headers\n # and other mistakes your backend does.\n\n if (bereq.url !~ \"^\/(admin\/|contact)\" || req.url !~ \"\/edit\") {\n unset beresp.http.set-cookie;\n\n if (beresp.status >= 200 && beresp.status < 400) {\n if (bereq.url ~ \"^\/stops\/\") {\n set beresp.ttl = 50s;\n } elif (bereq.url ~ \"\/(vehicles|journeys\/)\") {\n set beresp.ttl = 6s;\n } else {\n set beresp.ttl = 1h;\n }\n }\n }\n}\n","old_contents":"# Marker to tell the VCL compiler that this VCL has been adapted to the\n# new 4.0 format.\nvcl 4.0;\n\n# Default backend definition. Set this to point to your content server.\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\n\nsub vcl_recv {\n # Happens before we check if we have this in cache already.\n #\n # Typically you clean up the request here, removing cookies you don't need,\n # rewriting the request, etc.\n\n if (req.url ~ \"^\/(admin\/|contact|awin-transaction)\" || req.url ~ \"\/edit\") {\n return (pass);\n }\n\n # special features on fleet lists for logged in users\n if (req.http.Cookie ~ \"sessionid\" && req.url ~ \"operator\" && req.url ~ \"vehicles\") {\n return (pass);\n }\n\n unset req.http.Cookie;\n}\n\nsub vcl_backend_response {\n # Happens after we have read the response headers from the backend.\n #\n # Here you clean the response headers, removing silly Set-Cookie headers\n # and other mistakes your backend does.\n\n if (bereq.url !~ \"^\/(admin\/|contact|edit)\") {\n unset beresp.http.set-cookie;\n\n if (beresp.status >= 200 && beresp.status < 400) {\n if (bereq.url ~ \"^\/stops\/\") {\n set beresp.ttl = 50s;\n } elif (bereq.url ~ \"\/(vehicles|journeys\/)\") {\n set beresp.ttl = 6s;\n } else {\n set beresp.ttl = 1h;\n }\n }\n }\n}\n","returncode":0,"stderr":"","license":"mpl-2.0","lang":"VCL"} {"commit":"8ec39b679922a35f49dd381036e78daade11873a","subject":"Update authentication-with-cache-for-get-requests.vcl","message":"Update authentication-with-cache-for-get-requests.vcl","repos":"dayvson\/libvmod-api-auth,dayvson\/libvmod-api-auth,dayvson\/libvmod-api-auth,dayvson\/libvmod-api-auth","old_file":"examples\/authentication-with-cache-for-get-requests.vcl","new_file":"examples\/authentication-with-cache-for-get-requests.vcl","new_contents":"import authorization;\n\nsub vcl_init {\n authorization.database(\"mongodb\");\n authorization.database_connect(\"127.0.0.1\", 27017, \"database.collection\");\n authorization.database_scheme(\"token\", \"secretkey\", \"ratelimit\");\n}\n\nsub vcl_recv {\n if (req.http.Authorization && req.http.X-Custom-Date) {\n if(authorization.is_valid(req.http.Authorization, req.url, req.http.X-Custom-Date)){\n unset req.http.Authorization;\n if(req.request != \"GET\"){\n return (pass);\n }else{\n return (lookup); \n }\n }else{\n error 401 \"Not Authorized\";\n }\n }\n}\n","old_contents":"import authorization;\n\nsub vcl_init {\n authorization.database(\"mongodb\");\n authorization.database_connect(\"127.0.0.1\", 27017, \"database.collection\");\n authorization.database_scheme(\"token\", \"secretkey\");\n}\n\nsub vcl_recv {\n if (req.http.Authorization && req.http.X-Custom-Date) {\n if(authorization.is_valid(req.http.Authorization, req.url, req.http.X-NYTV-Date)){\n unset req.http.Authorization;\n if(req.request != \"GET\"){\n return (pass);\n }else{\n return (lookup); \n }\n }else{\n error 401 \"Not Authorized\";\n }\n }\n}","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"9f1b8cfad305eafff3d24fa2f744188f89cc2e31","subject":"Add few more guardrails","message":"Add few more guardrails\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets\/fetch.vcl","new_file":"etc\/vcl_snippets\/fetch.vcl","new_contents":" \/* handle 5XX (or any other unwanted status code) *\/\n if (beresp.status >= 500 && beresp.status < 600) {\n\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n \/* deliver stale if the object is available *\/\n if (stale.exists) {\n return(deliver_stale);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n \/* else go to vcl_error to deliver a synthetic *\/\n error 503;\n }\n\n # Remove Set-Cookies from responses for static content\n # to match the cookie removal in recv.\n if (req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's since those can be temporary during the site build\/index\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n }\n\n }\n\n if (beresp.http.Content-Type ~ \"text\/(html|xml)\") {\n # enable ESI feature for Magento response by default\n esi;\n if (!beresp.http.Vary ~ \"X-Magento-Vary,Https\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \",X-Magento-Vary,Https\";\n } else {\n set beresp.http.Vary = \"X-Magento-Vary,Https\";\n }\n }\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content\n if (http_status_matches(beresp.status, \"200,404\") && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url.ext ~ \"(?i)(css|js|html|eot|ico|otf|ttf|json)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n if (beresp.http.Cache-Control ~ \"private|no-cache|no-store\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # Never cache 302s\n if (beresp.status == 302) {\n return (pass);\n }\n\n # Cache non-successful responses for 1 second to avoid onslaught of traffic if backend starts\n # spewing 500s. Also set 5 second grace in case backend is timing out or otherwise messed up\n if ( !http_status_matches(beresp.status, \"200,203,300,301,302,404,410\")) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n # Remove Set-Cookies so we don't inadvertenly cache them\n unset beresp.http.Set-Cookie;\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\") && !req.http.x-pass ) {\n unset beresp.http.set-cookie;\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type if they are image\/script or CSS\n if (beresp.http.Content-Type ~ \"(image|script|css)\") {\n set beresp.http.Surrogate-Key = re.group.1;\n }\n return (deliver);\n }\n","old_contents":" \/* handle 5XX (or any other unwanted status code) *\/\n if (beresp.status >= 500 && beresp.status < 600) {\n\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n \/* deliver stale if the object is available *\/\n if (stale.exists) {\n return(deliver_stale);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n \/* else go to vcl_error to deliver a synthetic *\/\n error 503;\n }\n\n # Remove Set-Cookies from responses for static content\n # to match the cookie removal in recv.\n if (req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's since those can be temporary during the site build\/index\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n }\n\n }\n\n if (beresp.http.Content-Type ~ \"text\/(html|xml)\") {\n # enable ESI feature for Magento response by default\n esi;\n if (!beresp.http.Vary ~ \"X-Magento-Vary,Https\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \",X-Magento-Vary,Https\";\n } else {\n set beresp.http.Vary = \"X-Magento-Vary,Https\";\n }\n }\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content\n if (http_status_matches(beresp.status, \"200,404\") && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url.ext ~ \"(?i)(css|js|html|eot|ico|otf|ttf|json)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # Cache non-successful responses for 1 second to avoid onslaught of traffic if backend starts\n # spewing 500s. Also set 5 second grace in case backend is timing out or otherwise messed up\n if ( !http_status_matches(beresp.status, \"200,203,300,301,302,404,410\")) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n # Remove Set-Cookies so we don't inadvertenly cache them\n unset beresp.http.Set-Cookie;\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\") && !req.http.x-pass ) {\n unset beresp.http.set-cookie;\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type if they are image\/script or CSS\n if (beresp.http.Content-Type ~ \"(image|script|css)\") {\n set beresp.http.Surrogate-Key = re.group.1;\n }\n return (deliver);\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"788d4393af9bcb8715c7f5e7fb15009c9b58f5c0","subject":"updated varnish config","message":"updated varnish config\n","repos":"slugalisk\/overrustlelogs,slugalisk\/overrustlelogs,slugalisk\/overrustlelogs","old_file":"package\/etc\/varnish\/default.vcl","new_file":"package\/etc\/varnish\/default.vcl","new_contents":"vcl 4.0;\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n .probe = {\n .url = \"\/\";\n .timeout = 5000 ms;\n .interval = 5s;\n .window = 2;\n .threshold = 2;\n }\n}\n\n\/\/backend stalk {\n\/\/ .host = \"127.0.0.1\";\n\/\/ .port = \"5000\";\n\/\/ .probe = {\n\/\/ .url = \"\/\";\n\/\/ .timeout = 5000 ms;\n\/\/ .interval = 5s;\n\/\/ .window = 2;\n\/\/ .threshold = 2;\n\/\/ }\n\/\/}\n\nsub vcl_recv {\n\/\/ if ( req.http.host ~ \"^stalk\" ) {\n\/\/ set req.backend_hint = stalk;\n\/\/ }\n\n \/\/ Handle compression correctly. Different browsers send different\n \/\/ \"Accept-Encoding\" headers, even though they mostly all support the same\n \/\/ compression mechanisms. By consolidating these compression headers into\n \/\/ a consistent format, we can reduce the size of the cache and get more hits.\n \/\/ @see: http:\/\/varnish.projects.linpro.no\/wiki\/FAQ\/Compression\n if ( req.http.Accept-Encoding ) {\n if ( req.http.Accept-Encoding ~ \"gzip\" ) {\n # If the browser supports it, we'll use gzip.\n set req.http.Accept-Encoding = \"gzip\";\n }\n else if ( req.http.Accept-Encoding ~ \"deflate\" ) {\n # Next, try deflate if it is supported.\n set req.http.Accept-Encoding = \"deflate\";\n }\n else {\n # Unknown algorithm. Remove it and send unencoded.\n unset req.http.Accept-Encoding;\n }\n }\n unset req.http.cookie;\n}\n\nsub vcl_backend_response {\n \/\/ cache static content - cloudflare should help with this\n if (bereq.url ~ \"\\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|pdf|tar|wav|bmp|rtf|js|flv|swf|html|htm)$\") {\n set beresp.ttl = 1h;\n }\n\n \/\/ the content is all public so we never care about cookies\n unset beresp.http.set-cookie;\n\n \/\/ Set the TTL for cache object to five minutes\n set beresp.ttl = 5m;\n}\n\nsub vcl_hash {\n hash_data(req.http.X-Forwarded-Proto);\n}\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = resp.http.Age;\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n\n unset resp.http.Age;\n unset resp.http.X-Varnish;\n unset resp.http.WP-Super-Cache;\n unset resp.http.Via;\n}\n","old_contents":"vcl 4.0;\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n .probe = {\n .url = \"\/\";\n .timeout = 5000 ms;\n .interval = 5s;\n .window = 2;\n .threshold = 2;\n }\n}\n\nsub vcl_recv {\n \/\/ Handle compression correctly. Different browsers send different\n \/\/ \"Accept-Encoding\" headers, even though they mostly all support the same\n \/\/ compression mechanisms. By consolidating these compression headers into\n \/\/ a consistent format, we can reduce the size of the cache and get more hits.\n \/\/ @see: http:\/\/varnish.projects.linpro.no\/wiki\/FAQ\/Compression\n if ( req.http.Accept-Encoding ) {\n if ( req.http.Accept-Encoding ~ \"gzip\" ) {\n # If the browser supports it, we'll use gzip.\n set req.http.Accept-Encoding = \"gzip\";\n }\n else if ( req.http.Accept-Encoding ~ \"deflate\" ) {\n # Next, try deflate if it is supported.\n set req.http.Accept-Encoding = \"deflate\";\n }\n else {\n # Unknown algorithm. Remove it and send unencoded.\n unset req.http.Accept-Encoding;\n }\n }\n unset req.http.cookie;\n}\n\nsub vcl_backend_response {\n \/\/ cache static content - cloudflare should help with this\n if (bereq.url ~ \"\\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|pdf|tar|wav|bmp|rtf|js|flv|swf|html|htm)$\") {\n set beresp.ttl = 1h;\n }\n\n \/\/ the content is all public so we never care about cookies\n unset beresp.http.set-cookie;\n\n \/\/ Set the TTL for cache object to five minutes\n set beresp.ttl = 5m;\n}\n\nsub vcl_hash {\n hash_data(req.http.X-Forwarded-Proto);\n}\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = resp.http.Age;\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n\n unset resp.http.Age;\n unset resp.http.X-Varnish;\n unset resp.http.WP-Super-Cache;\n unset resp.http.Via;\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"cff97c896e98c893c9b33c830a6ba3e2dce62e68","subject":"Use 7digital's Fastly deploy verification mechanism","message":"Use 7digital's Fastly deploy verification mechanism\n","repos":"rhargreaves\/fastly-vcl-experiments,rhargreaves\/fastly-vcl-experiments","old_file":"oauth_sig_check.vcl","new_file":"oauth_sig_check.vcl","new_contents":"\ntable consumer_secrets {\n\t\"foo\": \"foo_secret\"\n}\n\ntable access_tokens {\n\t\"bar\": \"bar_secret\"\n}\n\nsub vcl_recv {\n#FASTLY recv\n#7D_DEPLOY recv\n\tdeclare local var.consumer_key STRING;\n\tdeclare local var.consumer_secret STRING;\n\tdeclare local var.access_token STRING;\n\tdeclare local var.access_token_secret STRING;\n\tdeclare local var.provided_signature STRING;\n\tdeclare local var.parameters STRING;\n\tdeclare local var.base_string_uri STRING;\n\tdeclare local var.base_string STRING;\n\tdeclare local var.calculated_signature STRING;\n\tdeclare local var.timestamp STRING;\n\n\tset req.url = boltsort.sort(req.url);\n\n\tset var.consumer_key = if(req.url ~ \"(?i)oauth_consumer_key=([^&]*)\",\n\t\t\turldecode(re.group.1), \"\");\n\tif(var.consumer_key == \"\") {\n\t\terror 401 \"Missing Consumer Key\";\n\t}\n\tset var.consumer_secret = table.lookup(consumer_secrets, var.consumer_key, \"\");\n\tif(var.consumer_secret == \"\") {\n\t\terror 401 \"Invalid Consumer Key\";\n\t}\n\tset var.access_token = if(req.url ~ \"(?i)oauth_token=([^&]*)\",\n\t\t\turldecode(re.group.1), \"\");\n\tif(var.access_token != \"\") {\n\t\tset var.access_token_secret = table.lookup(access_tokens, var.access_token, \"\");\n\t\tif(var.access_token_secret == \"\") {\n\t\t\terror 401 \"Invalid Access Token\";\n\t\t}\n\t} else {\n\t\tset var.access_token_secret = \"\";\n\t}\n\tset var.provided_signature = if(req.url ~ \"(?i)oauth_signature=([^&]*)\",\n\t\t\turldecode(re.group.1), \"\");\n\tif(var.provided_signature == \"\") {\n\t\terror 401 \"Missing Signature\";\n\t}\n\tset var.parameters = regsub(\n\t\t\treq.url.qs,\n\t\t\t\"&oauth_signature=[^&]*\", \"\");\n\tset var.base_string_uri =\n\t\tif(req.http.Fastly-SSL, \"https\", \"http\")\n\t\t\t\":\/\/\"\n\t\t\t\tstd.tolower(req.http.host)\n\t\t\t\treq.url.path;\n\tset var.base_string =\n\t\treq.request\n\t\t\"&\"\n\t\turlencode(var.base_string_uri)\n\t\t\"&\"\n\t\turlencode(var.parameters);\n\n\tset var.calculated_signature = digest.hmac_sha1_base64(\n\t\t\tvar.consumer_secret \"&\" var.access_token_secret,\n\t\t\tvar.base_string);\n\n\tif(!digest.secure_is_equal(var.provided_signature,\n\t\t\tvar.calculated_signature)) {\n\t\terror 401 \"Invalid OAuth Signature\";\n\t}\n\n\tset var.timestamp = if(req.url ~ \"(?i)oauth_timestamp=([0-9]*)\",\n\t\t\turldecode(re.group.1), \"\");\n\tif(var.timestamp == \"\") {\n\t\terror 401 \"Missing\/Invalid Timestamp\";\n\t}\n\n\tif(time.is_after(\n\t\t\t\tnow,\n\t\t\t\ttime.add(std.integer2time(std.atoi(var.timestamp)), 30m))) {\n\t\terror 401 \"Timestamp expired\";\n\t}\n\n\tif(time.is_after(\n\t\t\t\tstd.integer2time(std.atoi(var.timestamp)),\n\t\t\t\ttime.add(now, 1m))) {\n\t\terror 401 \"Timestamp too far in future\";\n\t}\n\n\terror 200 \"Authenticated!\";\n\n\treturn(lookup);\n}\n\nsub vcl_fetch {\n#FASTLY fetch\n\treturn(deliver);\n}\n\nsub vcl_hit {\n#FASTLY hit\n\tif (!obj.cacheable) {\n\t\treturn(pass);\n\t}\n\treturn(deliver);\n}\n\nsub vcl_miss {\n#FASTLY miss\n\treturn(fetch);\n}\n\nsub vcl_deliver{\n#FASTLY deliver\n\treturn(deliver);\n}\n\nsub vcl_error {\n#FASTLY error\n#7D_DEPLOY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n","old_contents":"\ntable consumer_secrets {\n\t\"foo\": \"foo_secret\"\n}\n\ntable access_tokens {\n\t\"bar\": \"bar_secret\"\n}\n\nsub vcl_recv {\n#FASTLY recv\n#DEPLOY recv\n\tdeclare local var.consumer_key STRING;\n\tdeclare local var.consumer_secret STRING;\n\tdeclare local var.access_token STRING;\n\tdeclare local var.access_token_secret STRING;\n\tdeclare local var.provided_signature STRING;\n\tdeclare local var.parameters STRING;\n\tdeclare local var.base_string_uri STRING;\n\tdeclare local var.base_string STRING;\n\tdeclare local var.calculated_signature STRING;\n\tdeclare local var.timestamp STRING;\n\n\tset req.url = boltsort.sort(req.url);\n\n\tset var.consumer_key = if(req.url ~ \"(?i)oauth_consumer_key=([^&]*)\",\n\t\t\turldecode(re.group.1), \"\");\n\tif(var.consumer_key == \"\") {\n\t\terror 401 \"Missing Consumer Key\";\n\t}\n\tset var.consumer_secret = table.lookup(consumer_secrets, var.consumer_key, \"\");\n\tif(var.consumer_secret == \"\") {\n\t\terror 401 \"Invalid Consumer Key\";\n\t}\n\tset var.access_token = if(req.url ~ \"(?i)oauth_token=([^&]*)\",\n\t\t\turldecode(re.group.1), \"\");\n\tif(var.access_token != \"\") {\n\t\tset var.access_token_secret = table.lookup(access_tokens, var.access_token, \"\");\n\t\tif(var.access_token_secret == \"\") {\n\t\t\terror 401 \"Invalid Access Token\";\n\t\t}\n\t} else {\n\t\tset var.access_token_secret = \"\";\n\t}\n\tset var.provided_signature = if(req.url ~ \"(?i)oauth_signature=([^&]*)\",\n\t\t\turldecode(re.group.1), \"\");\n\tif(var.provided_signature == \"\") {\n\t\terror 401 \"Missing Signature\";\n\t}\n\tset var.parameters = regsub(\n\t\t\treq.url.qs,\n\t\t\t\"&oauth_signature=[^&]*\", \"\");\n\tset var.base_string_uri =\n\t\tif(req.http.Fastly-SSL, \"https\", \"http\")\n\t\t\t\":\/\/\"\n\t\t\t\tstd.tolower(req.http.host)\n\t\t\t\treq.url.path;\n\tset var.base_string =\n\t\treq.request\n\t\t\"&\"\n\t\turlencode(var.base_string_uri)\n\t\t\"&\"\n\t\turlencode(var.parameters);\n\n\tset var.calculated_signature = digest.hmac_sha1_base64(\n\t\t\tvar.consumer_secret \"&\" var.access_token_secret,\n\t\t\tvar.base_string);\n\n\tif(!digest.secure_is_equal(var.provided_signature,\n\t\t\tvar.calculated_signature)) {\n\t\terror 401 \"Invalid OAuth Signature\";\n\t}\n\n\tset var.timestamp = if(req.url ~ \"(?i)oauth_timestamp=([0-9]*)\",\n\t\t\turldecode(re.group.1), \"\");\n\tif(var.timestamp == \"\") {\n\t\terror 401 \"Missing\/Invalid Timestamp\";\n\t}\n\n\tif(time.is_after(\n\t\t\t\tnow,\n\t\t\t\ttime.add(std.integer2time(std.atoi(var.timestamp)), 30m))) {\n\t\terror 401 \"Timestamp expired\";\n\t}\n\n\tif(time.is_after(\n\t\t\t\tstd.integer2time(std.atoi(var.timestamp)),\n\t\t\t\ttime.add(now, 1m))) {\n\t\terror 401 \"Timestamp too far in future\";\n\t}\n\n\terror 200 \"Authenticated!\";\n\n\treturn(lookup);\n}\n\nsub vcl_fetch {\n#FASTLY fetch\n\treturn(deliver);\n}\n\nsub vcl_hit {\n#FASTLY hit\n\tif (!obj.cacheable) {\n\t\treturn(pass);\n\t}\n\treturn(deliver);\n}\n\nsub vcl_miss {\n#FASTLY miss\n\treturn(fetch);\n}\n\nsub vcl_deliver{\n#FASTLY deliver\n\treturn(deliver);\n}\n\nsub vcl_error {\n#FASTLY error\n#DEPLOY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"d852029abd087fa8becd25b7faf929f9995262e8","subject":"Yielded priority to blacklist.","message":"Yielded priority to blacklist.\n","repos":"telusdigital\/ansible-varnish,colstrom\/ansible-varnish,killerwails\/ansible-varnish,noqcks\/ansible-varnish,killerwails\/ansible-varnish,gotofbi\/ansible-varnish,kkwoker\/ansible-varnish,gotofbi\/ansible-varnish","old_file":"templates\/etc\/varnish\/default.vcl","new_file":"templates\/etc\/varnish\/default.vcl","new_contents":"vcl 4.0;\n\nimport directors;\nimport std;\n\n###\n# Varnish Documentation\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-built-in-subs.html\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/reference\/vcl.html\n##\n\n{% for backend in varnish_backend_hosts %}\nbackend application_{{ loop.index }} {\n .host = \"{{ backend }}\";\n .port = \"{{ varnish_backend_port }}\";\n{% if varnish_health_checks_enabled %}\n .probe = {\n .url = \"{{ varnish_health_check_url }}\";\n .interval = {{ varnish_health_check_interval }};\n .timeout = {{ varnish_health_check_timeout }};\n .window = {{ varnish_health_check_window }};\n .threshold = {{ varnish_health_check_threshold }};\n }\n{% endif %}\n}\n{% endfor %}\n\n###\n# vcl_init\n# Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n###\n# The vcl_init subroutine may terminate with calling return() with one of the following keywords:\n#\n# ok\n# Normal return, VCL continues loading.\n##\n\nsub vcl_init {\n new application = directors.round_robin();\n{% for backend in varnish_backend_hosts %}\n application.add_backend(application_{{ loop.index }});\n{% endfor %}\n}\n\n###\n# vcl_recv\n# Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use. \n# It is also used to modify the request\n###\n# The vcl_recv subroutine may terminate with calling return() on one of the following keywords:\n#\n# synth(status code, reason)\n# Return a synthetic object with the specified status code to the client and abandon the request.\n# pass\n# Switch to pass mode. Control will eventually pass to vcl_pass.\n# pipe\n# Switch to pipe mode. Control will eventually pass to vcl_pipe.\n# hash\n# Continue processing the object as a potential candidate for caching. Passes the control over to vcl_hash.\n# purge\n# Purge the object and it's variants. Control passes through vcl_hash to vcl_purge.\n#\n\nsub vcl_recv {\n set req.backend_hint = application.backend();\n\n ###\n # Avoid processing uncacheable requests\n ###\n\n if (req.http.Authorization) {\n return (pass);\n }\n\n{% if varnish_blacklist_enabled %}\n if ((req.url ~ \"{{ varnish_blacklist_regexp }}\")) {\n set req.http.X-Passthrough-Reason = \"Path in Blacklist\";\n return(pass);\n }\n{% endif %}\n\n ###\n # Inject X-Forwarded-For headers, but only once.\n ###\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n{% if varnish_header_sanitization_enabled %}\n ###\n # Header Sanitization\n ###\n\n{% if varnish_discards_port_from_host_header %}\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n{% endif %}\n\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_enabled %}\n ###\n # Cookie Sanitization\n ###\n\n ### Google Analytics\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n\n ### Quantcast\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n \n ### AddThis\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n\n ### General Cleanup\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n{% endif %}\n\n{% if varnish_uri_sanitization_enabled %}\n ###\n # URI Sanitization\n ###\n \n if (req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=\") {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n{% endif %}\n\n{% if varnish_workaround_telusdotcom_browser_profile %}\n ###\n # Workaround for BrowserProfile and Language\/Region Detection on TELUS.com\n ###\n\n if (req.http.Cookie ~ \"BrowserProfile\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.Cookie, \"(.*)language..:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n set req.http.X-Province = std.tolower(regsuball(regsuball(req.http.Cookie, \"geo\\\\.\\:{(.*)\\}\", \"\"), \"(.*)region..:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n } else {\n if (req.http.Cookie ~ \"lang=\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.Cookie, \"(.*)lang=([^;]*)(.*)\", \"\\2\"));\n } else {\n set req.http.X-Language = \"en\";\n }\n\n if (req.http.Cookie ~ \"prov=\") {\n set req.http.X-Province = std.tolower(regsuball(req.http.Cookie, \"(.*)prov=([^;]*)(.*)\", \"\\2\"));\n } else {\n set req.http.X-Province = \"BC\";\n }\n }\n\n if (req.url ~ \"\/(en|fr)\/\") {\n if (req.url ~ \"\/en\/\" && req.http.X-Language != \"en\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Language)\";\n return(pass);\n }\n if (req.url ~ \"\/fr\/\" && req.http.X-Language != \"fr\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Language)\";\n return(pass);\n }\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Language)\";\n return(pass);\n }\n\n if (req.url ~ \"\/(ab|bc|mb|nb|nl|ns|nt|nu|on|pe|qc|sk|yt)\/\") {\n {% for province in ['ab', 'bc', 'mb', 'nb', 'nl', 'ns', 'nt', 'nu', 'on', 'pe', 'qc', 'sk', 'yt'] %}\n if (req.url ~ \"\/{{ province }}\/\" && req.http.X-Province != \"{{ province }}\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Province)\";\n return(pass);\n }\n {% endfor %}\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Province)\";\n return(pass);\n }\n{% endif %}\n\n{% if varnish_discards_client_cookies %}\n unset req.http.Cookie;\n{% endif %}\n}\n\n###\n# vcl_hit\n# Called when a cache lookup is successful.\n###\n# The vcl_hit subroutine may terminate with calling return() with one of the following keywords:\n#\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n# deliver\n# Deliver the object. Control passes to vcl_deliver.\n# synth(status code, reason)\n# Return the specified status code to the client and abandon the request.\n###\n\nsub vcl_hit {\n if (obj.ttl > 0s) {\n return (deliver);\n }\n{% if varnish_health_checks_enabled %}\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (fetch);\n }\n{% else %}\n if (obj.ttl + obj.grace > 0s) {\n return (deliver);\n }\n\n return (fetch);\n{% endif %}\n}\n\n###\n# vcl_backend_response\n# Called after the response headers has been successfully retrieved from the backend.\n###\n# The vcl_backend_response subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Possibly insert the object into the cache, then deliver it to the Control will eventually pass to vcl_deliver.\n# abandon\n# Abandon the backend request and generates an error.\n# retry\n# Retry the backend transaction. Increases the retries counter. If the number of retries is higher than max_retries Varnish emits a guru meditation error.\n###\n\nsub vcl_backend_response {\n{% if varnish_workaround_telusdotcom_browser_profile %}\n if (bereq.http.X-Language) {\n set beresp.http.X-Language = bereq.http.X-Language;\n }\n if (bereq.http.X-Province) {\n set beresp.http.X-Province = bereq.http.X-Province;\n }\n{% endif %}\n\n{% if varnish_blacklist_enabled %}\n if (bereq.url ~ \"{{ varnish_blacklist_regexp }}\") {\n set beresp.http.X-Cacheable = \"NO:Path in Blacklist\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n if (bereq.http.X-Passthrough-Reason) {\n set beresp.http.X-Passthrough-Reason = bereq.http.X-Passthrough-Reason;\n return(deliver);\n } else {\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n }\n }\n{% else %}\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n{% endif %}\n\n{% if varnish_cache_diagnostics_enabled %}\n if (bereq.http.Cookie) {\n set beresp.http.X-Cacheable = \"NO:Cookie in Request\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO:Set-Cookie in Response\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.X-No-Cache) {\n set beresp.http.X-Cacheable = \"NO:X-No-Cache\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.ttl <= 0s) {\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n{% endif %}\n\n set beresp.grace = {{ varnish_grace_period }};\n}\n\n###\n# vcl_deliver\n# Called before a cached object is delivered to the client.\n###\n# The vcl_deliver subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Deliver the object to the client.\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n###\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n","old_contents":"vcl 4.0;\n\nimport directors;\nimport std;\n\n###\n# Varnish Documentation\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-built-in-subs.html\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/reference\/vcl.html\n##\n\n{% for backend in varnish_backend_hosts %}\nbackend application_{{ loop.index }} {\n .host = \"{{ backend }}\";\n .port = \"{{ varnish_backend_port }}\";\n{% if varnish_health_checks_enabled %}\n .probe = {\n .url = \"{{ varnish_health_check_url }}\";\n .interval = {{ varnish_health_check_interval }};\n .timeout = {{ varnish_health_check_timeout }};\n .window = {{ varnish_health_check_window }};\n .threshold = {{ varnish_health_check_threshold }};\n }\n{% endif %}\n}\n{% endfor %}\n\n###\n# vcl_init\n# Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n###\n# The vcl_init subroutine may terminate with calling return() with one of the following keywords:\n#\n# ok\n# Normal return, VCL continues loading.\n##\n\nsub vcl_init {\n new application = directors.round_robin();\n{% for backend in varnish_backend_hosts %}\n application.add_backend(application_{{ loop.index }});\n{% endfor %}\n}\n\n###\n# vcl_recv\n# Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use. \n# It is also used to modify the request\n###\n# The vcl_recv subroutine may terminate with calling return() on one of the following keywords:\n#\n# synth(status code, reason)\n# Return a synthetic object with the specified status code to the client and abandon the request.\n# pass\n# Switch to pass mode. Control will eventually pass to vcl_pass.\n# pipe\n# Switch to pipe mode. Control will eventually pass to vcl_pipe.\n# hash\n# Continue processing the object as a potential candidate for caching. Passes the control over to vcl_hash.\n# purge\n# Purge the object and it's variants. Control passes through vcl_hash to vcl_purge.\n#\n\nsub vcl_recv {\n set req.backend_hint = application.backend();\n\n ###\n # Avoid processing uncacheable requests\n ###\n\n if (req.http.Authorization) {\n return (pass);\n }\n\n ###\n # Inject X-Forwarded-For headers, but only once.\n ###\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n{% if varnish_header_sanitization_enabled %}\n ###\n # Header Sanitization\n ###\n\n{% if varnish_discards_port_from_host_header %}\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n{% endif %}\n\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_enabled %}\n ###\n # Cookie Sanitization\n ###\n\n ### Google Analytics\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n\n ### Quantcast\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n \n ### AddThis\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n\n ### General Cleanup\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n{% endif %}\n\n{% if varnish_uri_sanitization_enabled %}\n ###\n # URI Sanitization\n ###\n \n if (req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=\") {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n{% endif %}\n\n{% if varnish_workaround_telusdotcom_browser_profile %}\n ###\n # Workaround for BrowserProfile and Language\/Region Detection on TELUS.com\n ###\n\n if (req.http.Cookie ~ \"BrowserProfile\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.Cookie, \"(.*)language..:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n set req.http.X-Province = std.tolower(regsuball(regsuball(req.http.Cookie, \"geo\\\\.\\:{(.*)\\}\", \"\"), \"(.*)region..:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n } else {\n if (req.http.Cookie ~ \"lang=\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.Cookie, \"(.*)lang=([^;]*)(.*)\", \"\\2\"));\n } else {\n set req.http.X-Language = \"en\";\n }\n\n if (req.http.Cookie ~ \"prov=\") {\n set req.http.X-Province = std.tolower(regsuball(req.http.Cookie, \"(.*)prov=([^;]*)(.*)\", \"\\2\"));\n } else {\n set req.http.X-Province = \"BC\";\n }\n }\n\n if (req.url ~ \"\/(en|fr)\/\") {\n if (req.url ~ \"\/en\/\" && req.http.X-Language != \"en\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Language)\";\n return(pass);\n }\n if (req.url ~ \"\/fr\/\" && req.http.X-Language != \"fr\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Language)\";\n return(pass);\n }\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Language)\";\n return(pass);\n }\n\n if (req.url ~ \"\/(ab|bc|mb|nb|nl|ns|nt|nu|on|pe|qc|sk|yt)\/\") {\n {% for province in ['ab', 'bc', 'mb', 'nb', 'nl', 'ns', 'nt', 'nu', 'on', 'pe', 'qc', 'sk', 'yt'] %}\n if (req.url ~ \"\/{{ province }}\/\" && req.http.X-Province != \"{{ province }}\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Province)\";\n return(pass);\n }\n {% endfor %}\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Province)\";\n return(pass);\n }\n{% endif %}\n\n{% if varnish_blacklist_enabled %}\n if ((req.url ~ \"{{ varnish_blacklist_regexp }}\")) {\n set req.http.X-Passthrough-Reason = \"Path in Blacklist\";\n return(pass);\n } else {\n{% if varnish_discards_client_cookies %}\n unset req.http.Cookie;\n{% endif %}\n }\n{% endif %}\n\n}\n\n###\n# vcl_hit\n# Called when a cache lookup is successful.\n###\n# The vcl_hit subroutine may terminate with calling return() with one of the following keywords:\n#\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n# deliver\n# Deliver the object. Control passes to vcl_deliver.\n# synth(status code, reason)\n# Return the specified status code to the client and abandon the request.\n###\n\nsub vcl_hit {\n if (obj.ttl > 0s) {\n return (deliver);\n }\n{% if varnish_health_checks_enabled %}\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (fetch);\n }\n{% else %}\n if (obj.ttl + obj.grace > 0s) {\n return (deliver);\n }\n\n return (fetch);\n{% endif %}\n}\n\n###\n# vcl_backend_response\n# Called after the response headers has been successfully retrieved from the backend.\n###\n# The vcl_backend_response subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Possibly insert the object into the cache, then deliver it to the Control will eventually pass to vcl_deliver.\n# abandon\n# Abandon the backend request and generates an error.\n# retry\n# Retry the backend transaction. Increases the retries counter. If the number of retries is higher than max_retries Varnish emits a guru meditation error.\n###\n\nsub vcl_backend_response {\n{% if varnish_workaround_telusdotcom_browser_profile %}\n if (bereq.http.X-Language) {\n set beresp.http.X-Language = bereq.http.X-Language;\n }\n if (bereq.http.X-Province) {\n set beresp.http.X-Province = bereq.http.X-Province;\n }\n{% endif %}\n\n{% if varnish_blacklist_enabled %}\n if (bereq.url ~ \"{{ varnish_blacklist_regexp }}\") {\n set beresp.http.X-Cacheable = \"NO:Path in Blacklist\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n if (bereq.http.X-Passthrough-Reason) {\n set beresp.http.X-Passthrough-Reason = bereq.http.X-Passthrough-Reason;\n return(deliver);\n } else {\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n }\n }\n{% else %}\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n{% endif %}\n\n{% if varnish_cache_diagnostics_enabled %}\n if (bereq.http.Cookie) {\n set beresp.http.X-Cacheable = \"NO:Cookie in Request\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO:Set-Cookie in Response\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.X-No-Cache) {\n set beresp.http.X-Cacheable = \"NO:X-No-Cache\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.ttl <= 0s) {\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n{% endif %}\n\n set beresp.grace = {{ varnish_grace_period }};\n}\n\n###\n# vcl_deliver\n# Called before a cached object is delivered to the client.\n###\n# The vcl_deliver subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Deliver the object to the client.\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n###\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"6bc9c26c2d4ff0dbccf17405ea1e2e77f8863cba","subject":"All responses should include 'x-content-type-options' header","message":"All responses should include 'x-content-type-options' header\n","repos":"JakeChampion\/polyfill-service,JakeChampion\/polyfill-service","old_file":"fastly\/vcl\/polyfill-service.vcl","new_file":"fastly\/vcl\/polyfill-service.vcl","new_contents":"sub set_backend {\n\t# Calculate the ideal region to route the request to.\n\tdeclare local var.region STRING;\n\tif (server.region ~ \"(APAC|Asia|North-America|South-America|US-Central|US-East|US-West)\") {\n\t\tset var.region = \"US\";\n\t} else {\n\t\tset var.region = \"EU\";\n\t}\n\n\t# Gather the health of the shields and origins.\n\tdeclare local var.v3_eu_is_healthy BOOL;\n\tset req.backend = F_v3_eu;\n\tset var.v3_eu_is_healthy = req.backend.healthy;\n\n\tdeclare local var.v3_us_is_healthy BOOL;\n\tset req.backend = F_v3_us;\n\tset var.v3_us_is_healthy = req.backend.healthy;\n\n\t# Set some sort of default, that shouldn't get used.\n\tset req.backend = F_v3_eu;\n\n\t# Route EU requests to the nearest healthy shield or origin.\n\tif (var.region == \"EU\") {\n\t\tif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_eu;\n\t\t}\n\t}\n\n\t# Route US requests to the nearest healthy shield or origin.\n\tif (var.region == \"US\") {\n\t\tif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_us;\n\t\t}\n\t}\n\n\t# Persist the decision so we can debug the result.\n\tset req.http.Debug-Backend = req.backend;\n\n\t# The Fastly macro is inserted after the backend is selected because the\n\t# macro has the code to select the correct req.http.Host value based on the backend.\n\t#FASTLY recv\n}\n\nsub vcl_recv {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_recv;\n\t}\n\n\tif (req.method != \"GET\" && req.method != \"HEAD\" && req.method != \"OPTIONS\") {\n\t\terror 911;\n\t}\n\n\tif (req.method == \"OPTIONS\") {\n\t\terror 912;\n\t}\n\n\t# Override the v3 defaults with the defaults of v2\n\tif (req.url ~ \"^\/v2\/polyfill(\\.min)?\\.js\") {\n\t\tset req.url = regsub(req.url, \"^\/v2\", \"\/v3\");\n\t\tset req.url = querystring.set(req.url, \"version\", \"3.25.1\");\n\t\tdeclare local var.unknown STRING;\n\t\tset var.unknown = subfield(req.url.qs, \"unknown\", \"&\");\n\t\tset req.url = querystring.set(req.url, \"unknown\", if(var.unknown != \"\", var.unknown, \"ignore\"));\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\") {\n\t\tcall normalise_querystring_parameters_for_polyfill_bundle;\n\t}\n\n\t# Sort the querystring parameters alphabetically to improve chances of hitting a cached copy.\n\t# If querystring is empty, remove the ? from the url.\n\tset req.url = querystring.clean(querystring.sort(req.url));\n\tcall set_backend;\n}\n\nsub vcl_hash {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_hash;\n\t}\n\n\t# We are not adding req.http.host to the hash because we want https:\/\/cdn.polyfill.io and https:\/\/polyfill.io to be a single object in the cache.\n\t# set req.hash += req.http.host;\n\tset req.hash += req.url;\n\t# We include return(hash) to stop the function falling through to the default VCL built into varnish, which for vcl_hash will add req.url and req.http.Host to the hash.\n\treturn(hash);\n}\n\nsub vcl_miss {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_miss;\n\t}\n}\n\nsub vcl_pass {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_pass;\n\t}\n}\n\nsub vcl_fetch {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_fetch;\n\t}\n\n\t# These header are only required for HTML documents.\n\tif (beresp.http.Content-Type ~ \"text\/html\") {\n\t\t# Enables the cross-site scripting filter built into most modern web browsers.\n\t\tset beresp.http.X-XSS-Protection = \"1; mode=block\";\t\n\n\t\t# Allow only content from the site's own origin (this excludes subdomains) and www.ft.com.\n\t\t# Don't allow the website to be used within an iframe\n\t\tif (!beresp.http.Content-Security-Policy) {\n\t\t\tset beresp.http.Content-Security-Policy = \"default-src 'self'; font-src 'self' https:\/\/www.ft.com; img-src 'self' https:\/\/www.ft.com; frame-ancestors 'none'; base-uri 'self'; form-action 'self'\";\n\t\t}\n\t}\n\t# Prevents MIME-sniffing a response away from the declared content type.\n\tset beresp.http.X-Content-Type-Options = \"nosniff\";\n\n\t# Ensure the site is only served over HTTPS and reduce the chances of someone performing a MITM attack.\n\tset beresp.http.Strict-Transport-Security = \"max-age=31536000; includeSubdomains; preload\";\n\n\t# The Referrer-Policy header governs which referrer information, sent in the Referer header, should be included with requests made.\n\t# Send a full URL when performing a same-origin request, but only send the origin of the document for other cases.\n\tset beresp.http.Referrer-Policy = \"origin-when-cross-origin\";\n\n\t# Enable purging of all objects in the Fastly cache by issuing a purge with the key \"polyfill-service\".\n\tif (beresp.http.Surrogate-Key !~ \"\\bpolyfill-service\\b\") {\n\t\tset beresp.http.Surrogate-Key = if(beresp.http.Surrogate-Key, beresp.http.Surrogate-Key \" polyfill-service\", \"polyfill-service\");\n\t}\n\n\tset beresp.http.Timing-Allow-Origin = \"*\";\n\n\tif (req.http.Normalized-User-Agent) {\n\t\tset beresp.http.Normalized-User-Agent = req.http.Normalized-User-Agent;\n\t\tset beresp.http.Detected-User-Agent = req.http.useragent_parser_family \"\/\" req.http.useragent_parser_major \".\" req.http.useragent_parser_minor \".\" req.http.useragent_parser_patch;\n\t}\n}\n\nsub vcl_deliver {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_deliver;\n\t}\n\n\tset req.http.Fastly-Force-Shield = \"yes\";\n\n\t# Allow cross origin GET, HEAD, and OPTIONS requests to be made.\n\tif (req.http.Origin) {\n\t\tset resp.http.Access-Control-Allow-Origin = \"*\";\n\t\tset resp.http.Access-Control-Allow-Methods = \"GET,HEAD,OPTIONS\";\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\") {\n\t\t# Need to add \"Vary: User-Agent\" in after vcl_fetch to avoid the \n\t\t# \"Vary: User-Agent\" entering the Varnish cache.\n\t\t# We need \"Vary: User-Agent\" in the browser cache because a browser\n\t\t# may update itself to a version which needs different polyfills\n\t\t# So we need to have it ignore the browser cached bundle when the user-agent changes.\n\t\tadd resp.http.Vary = \"User-Agent\";\n\t\tadd resp.http.Vary = \"Accept-Encoding\";\n\t}\n\n\tadd resp.http.Server-Timing = fastly_info.state {\", fastly;desc=\"Edge time\";dur=\"} time.elapsed.msec;\n\n\tif (req.http.Fastly-Debug) {\n\t\tset resp.http.Debug-Backend = req.http.Debug-Backend;\n\t\tset resp.http.Debug-Host = req.http.Host;\n\t\tset resp.http.Debug-Fastly-Restarts = req.restarts;\n\t\tset resp.http.Debug-Orig-URL = req.http.Orig-URL;\n\t\tset resp.http.Debug-VCL-Route = req.http.X-VCL-Route;\n\t\tset resp.http.useragent_parser_family = req.http.useragent_parser_family;\n\t\tset resp.http.useragent_parser_major = req.http.useragent_parser_major;\n\t\tset resp.http.useragent_parser_minor = req.http.useragent_parser_minor;\n\t\tset resp.http.useragent_parser_patch = req.http.useragent_parser_patch;\n\t} else {\n\t\tunset resp.http.Server;\n\t\tunset resp.http.Via;\n\t\tunset resp.http.X-Cache;\n\t\tunset resp.http.X-Cache-Hits;\n\t\tunset resp.http.X-Served-By;\n\t\tunset resp.http.X-Timer;\n\t\tunset resp.http.Fastly-Restarts;\n\t}\n}\n\nsub vcl_error {\n\tif (obj.status == 911) {\n\t\tset obj.status = 405;\n\t\tset obj.response = \"METHOD NOT ALLOWED\";\n\t\tset obj.http.Content-Type = \"text\/html; charset=utf-8\";\n\t\tset obj.http.Cache-Control = \"private, no-store\";\n\t\tsynthetic req.method \" METHOD NOT ALLOWED\";\n\t\treturn (deliver);\n\t}\n\tif (obj.status == 912) {\n\t\tset obj.status = 200;\n\t\tset obj.response = \"OK\";\n\t\tset obj.http.Allow = \"OPTIONS, GET, HEAD\";\n\t\treturn (deliver);\n\t}\n}\n","old_contents":"sub set_backend {\n\t# Calculate the ideal region to route the request to.\n\tdeclare local var.region STRING;\n\tif (server.region ~ \"(APAC|Asia|North-America|South-America|US-Central|US-East|US-West)\") {\n\t\tset var.region = \"US\";\n\t} else {\n\t\tset var.region = \"EU\";\n\t}\n\n\t# Gather the health of the shields and origins.\n\tdeclare local var.v3_eu_is_healthy BOOL;\n\tset req.backend = F_v3_eu;\n\tset var.v3_eu_is_healthy = req.backend.healthy;\n\n\tdeclare local var.v3_us_is_healthy BOOL;\n\tset req.backend = F_v3_us;\n\tset var.v3_us_is_healthy = req.backend.healthy;\n\n\t# Set some sort of default, that shouldn't get used.\n\tset req.backend = F_v3_eu;\n\n\t# Route EU requests to the nearest healthy shield or origin.\n\tif (var.region == \"EU\") {\n\t\tif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_eu;\n\t\t}\n\t}\n\n\t# Route US requests to the nearest healthy shield or origin.\n\tif (var.region == \"US\") {\n\t\tif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_us;\n\t\t}\n\t}\n\n\t# Persist the decision so we can debug the result.\n\tset req.http.Debug-Backend = req.backend;\n\n\t# The Fastly macro is inserted after the backend is selected because the\n\t# macro has the code to select the correct req.http.Host value based on the backend.\n\t#FASTLY recv\n}\n\nsub vcl_recv {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_recv;\n\t}\n\n\tif (req.method != \"GET\" && req.method != \"HEAD\" && req.method != \"OPTIONS\") {\n\t\terror 911;\n\t}\n\n\tif (req.method == \"OPTIONS\") {\n\t\terror 912;\n\t}\n\n\t# Override the v3 defaults with the defaults of v2\n\tif (req.url ~ \"^\/v2\/polyfill(\\.min)?\\.js\") {\n\t\tset req.url = regsub(req.url, \"^\/v2\", \"\/v3\");\n\t\tset req.url = querystring.set(req.url, \"version\", \"3.25.1\");\n\t\tdeclare local var.unknown STRING;\n\t\tset var.unknown = subfield(req.url.qs, \"unknown\", \"&\");\n\t\tset req.url = querystring.set(req.url, \"unknown\", if(var.unknown != \"\", var.unknown, \"ignore\"));\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\") {\n\t\tcall normalise_querystring_parameters_for_polyfill_bundle;\n\t}\n\n\t# Sort the querystring parameters alphabetically to improve chances of hitting a cached copy.\n\t# If querystring is empty, remove the ? from the url.\n\tset req.url = querystring.clean(querystring.sort(req.url));\n\tcall set_backend;\n}\n\nsub vcl_hash {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_hash;\n\t}\n\n\t# We are not adding req.http.host to the hash because we want https:\/\/cdn.polyfill.io and https:\/\/polyfill.io to be a single object in the cache.\n\t# set req.hash += req.http.host;\n\tset req.hash += req.url;\n\t# We include return(hash) to stop the function falling through to the default VCL built into varnish, which for vcl_hash will add req.url and req.http.Host to the hash.\n\treturn(hash);\n}\n\nsub vcl_miss {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_miss;\n\t}\n}\n\nsub vcl_pass {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_pass;\n\t}\n}\n\nsub vcl_fetch {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_fetch;\n\t}\n\n\t# These header are only required for HTML documents.\n\tif (beresp.http.Content-Type ~ \"text\/html\") {\n\t\t# Enables the cross-site scripting filter built into most modern web browsers.\n\t\tset beresp.http.X-XSS-Protection = \"1; mode=block\";\n\t\t\n\t\t# Prevents MIME-sniffing a response away from the declared content type.\n\t\tset beresp.http.X-Content-Type-Options = \"nosniff\";\n\n\t\t# Allow only content from the site's own origin (this excludes subdomains) and www.ft.com.\n\t\t# Don't allow the website to be used within an iframe\n\t\tif (!beresp.http.Content-Security-Policy) {\n\t\t\tset beresp.http.Content-Security-Policy = \"default-src 'self'; font-src 'self' https:\/\/www.ft.com; img-src 'self' https:\/\/www.ft.com; frame-ancestors 'none'; base-uri 'self'; form-action 'self'\";\n\t\t}\n\t}\n\n\t# Ensure the site is only served over HTTPS and reduce the chances of someone performing a MITM attack.\n\tset beresp.http.Strict-Transport-Security = \"max-age=31536000; includeSubdomains; preload\";\n\n\t# The Referrer-Policy header governs which referrer information, sent in the Referer header, should be included with requests made.\n\t# Send a full URL when performing a same-origin request, but only send the origin of the document for other cases.\n\tset beresp.http.Referrer-Policy = \"origin-when-cross-origin\";\n\n\t# Enable purging of all objects in the Fastly cache by issuing a purge with the key \"polyfill-service\".\n\tif (beresp.http.Surrogate-Key !~ \"\\bpolyfill-service\\b\") {\n\t\tset beresp.http.Surrogate-Key = if(beresp.http.Surrogate-Key, beresp.http.Surrogate-Key \" polyfill-service\", \"polyfill-service\");\n\t}\n\n\tset beresp.http.Timing-Allow-Origin = \"*\";\n\n\tif (req.http.Normalized-User-Agent) {\n\t\tset beresp.http.Normalized-User-Agent = req.http.Normalized-User-Agent;\n\t\tset beresp.http.Detected-User-Agent = req.http.useragent_parser_family \"\/\" req.http.useragent_parser_major \".\" req.http.useragent_parser_minor \".\" req.http.useragent_parser_patch;\n\t}\n}\n\nsub vcl_deliver {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_deliver;\n\t}\n\n\tset req.http.Fastly-Force-Shield = \"yes\";\n\n\t# Allow cross origin GET, HEAD, and OPTIONS requests to be made.\n\tif (req.http.Origin) {\n\t\tset resp.http.Access-Control-Allow-Origin = \"*\";\n\t\tset resp.http.Access-Control-Allow-Methods = \"GET,HEAD,OPTIONS\";\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\") {\n\t\t# Need to add \"Vary: User-Agent\" in after vcl_fetch to avoid the \n\t\t# \"Vary: User-Agent\" entering the Varnish cache.\n\t\t# We need \"Vary: User-Agent\" in the browser cache because a browser\n\t\t# may update itself to a version which needs different polyfills\n\t\t# So we need to have it ignore the browser cached bundle when the user-agent changes.\n\t\tadd resp.http.Vary = \"User-Agent\";\n\t\tadd resp.http.Vary = \"Accept-Encoding\";\n\t}\n\n\tadd resp.http.Server-Timing = fastly_info.state {\", fastly;desc=\"Edge time\";dur=\"} time.elapsed.msec;\n\n\tif (req.http.Fastly-Debug) {\n\t\tset resp.http.Debug-Backend = req.http.Debug-Backend;\n\t\tset resp.http.Debug-Host = req.http.Host;\n\t\tset resp.http.Debug-Fastly-Restarts = req.restarts;\n\t\tset resp.http.Debug-Orig-URL = req.http.Orig-URL;\n\t\tset resp.http.Debug-VCL-Route = req.http.X-VCL-Route;\n\t\tset resp.http.useragent_parser_family = req.http.useragent_parser_family;\n\t\tset resp.http.useragent_parser_major = req.http.useragent_parser_major;\n\t\tset resp.http.useragent_parser_minor = req.http.useragent_parser_minor;\n\t\tset resp.http.useragent_parser_patch = req.http.useragent_parser_patch;\n\t} else {\n\t\tunset resp.http.Server;\n\t\tunset resp.http.Via;\n\t\tunset resp.http.X-Cache;\n\t\tunset resp.http.X-Cache-Hits;\n\t\tunset resp.http.X-Served-By;\n\t\tunset resp.http.X-Timer;\n\t\tunset resp.http.Fastly-Restarts;\n\t}\n}\n\nsub vcl_error {\n\tif (obj.status == 911) {\n\t\tset obj.status = 405;\n\t\tset obj.response = \"METHOD NOT ALLOWED\";\n\t\tset obj.http.Content-Type = \"text\/html; charset=utf-8\";\n\t\tset obj.http.Cache-Control = \"private, no-store\";\n\t\tsynthetic req.method \" METHOD NOT ALLOWED\";\n\t\treturn (deliver);\n\t}\n\tif (obj.status == 912) {\n\t\tset obj.status = 200;\n\t\tset obj.response = \"OK\";\n\t\tset obj.http.Allow = \"OPTIONS, GET, HEAD\";\n\t\treturn (deliver);\n\t}\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"130ae7628779e3c0fe40077d67ed8d69578fe90a","subject":"According to your docs -> https:\/\/github.com\/fastly\/fastly-magento2\/blob\/master\/Documentation\/Guides\/RATE-LIMITING.md","message":"According to your docs -> https:\/\/github.com\/fastly\/fastly-magento2\/blob\/master\/Documentation\/Guides\/RATE-LIMITING.md\n\nFollowing users are exempt from blocking:\n\nIPs defined in var\/.maintenance.ip (See Maintenance Mode guide for more details)\n\nvar\/.maintenance.ip updates acl maint_allowlist but this acl is never used to exempt the ips from getting blocked.\n\nAs a result rate limit will return 429 also for ips that are on the maintenance list.\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets_rate_limiting\/recv.vcl","new_file":"etc\/vcl_snippets_rate_limiting\/recv.vcl","new_contents":"if (####RATE_LIMITED_PATHS####) {\n if (req.http.Fastly-Client-Ip !~ maint_allowlist) {\n set req.http.Rate-Limit = \"1\";\n set req.http.X-Orig-Method = req.method;\n set req.hash_ignore_busy = true;\n if (req.method !~ \"^(GET|POST)$\") {\n set req.method = \"POST\";\n }\n }\n}\n","old_contents":"if (####RATE_LIMITED_PATHS####) {\n set req.http.Rate-Limit = \"1\";\n set req.http.X-Orig-Method = req.method;\n set req.hash_ignore_busy = true;\n if (req.method !~ \"^(GET|POST)$\") {\n set req.method = \"POST\";\n }\n}\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"c787117e8640906371e63db9604db56b7e4f4396","subject":"fixup! fix varnish with multiple hosts","message":"fixup! fix varnish with multiple hosts\n","repos":"KhanovaSkola\/khanovaskola-v3,KhanovaSkola\/khanovaskola-v3,KhanovaSkola\/khanovaskola-v3,KhanovaSkola\/khanovaskola-v3,KhanovaSkola\/khanovaskola-v3,KhanovaSkola\/khanovaskola-v3","old_file":"production\/varnish.vcl","new_file":"production\/varnish.vcl","new_contents":"vcl 4.0;\n\n# Disable esi xml check on varnish Startup\n# Example:\n# DAEMON_OPTS=\"-a :6081 \\\n# -T localhost:6082 \\\n# -p feature=+esi_disable_xml_check\n# -p feature=+esi_ignore_https\n#\n\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8085\";\n}\n\nsub vcl_recv {\n if (req.method != \"GET\") {\n return (pass);\n }\n if (req.http.Cookie ~ \"\\bvarnish-force=pass\") {\n return (pass);\n }\n\n return (hash);\n}\n\nsub vcl_hash {\n hash_data(req.http.host);\n hash_data(req.url);\n return(lookup);\n}\n\nsub vcl_backend_response {\n if (beresp.http.Cache-Control != \"public\") {\n set beresp.uncacheable = true;\n set beresp.ttl = 3m;\n return (deliver);\n }\n\n set beresp.do_esi = true;\n set beresp.ttl = 15m;\n\n unset beresp.http.Set-Cookie;\n}\n","old_contents":"vcl 4.0;\n\n# Disable esi xml check on varnish Startup\n# Example:\n# DAEMON_OPTS=\"-a :6081 \\\n# -T localhost:6082 \\\n# -p feature=+esi_disable_xml_check\n# -p feature=+esi_ignore_https\n#\n\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8085\";\n}\n\nsub vcl_recv {\n if (req.method != \"GET\") {\n return (pass);\n }\n if (req.http.Cookie ~ \"\\bvarnish-force=pass\") {\n return (pass);\n }\n\n return (hash);\n}\n\nsub vcl_hash {\n hash_data(req.host);\n hash_data(req.url);\n return(lookup);\n}\n\nsub vcl_backend_response {\n if (beresp.http.Cache-Control != \"public\") {\n set beresp.uncacheable = true;\n set beresp.ttl = 3m;\n return (deliver);\n }\n\n set beresp.do_esi = true;\n set beresp.ttl = 15m;\n\n unset beresp.http.Set-Cookie;\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"358fd1957e8168ea9610b50232760cf8bb90e021","subject":"Add more delimiters, delimiter commands, commands to switch tags","message":"Add more delimiters, delimiter commands, commands to switch tags\n","repos":"aschneiderman\/atom-voice-vocola","old_file":"atom.vcl","new_file":"atom.vcl","new_contents":"# Voice commands for atom\n\ninclude folders.vch;\ninclude letters.vch;\n\n\nReload Atom = {Shift+Ctrl+Alt+F5};\n\nFind (File | Document) = {Ctrl+t};\nSave As = {Ctrl+Shift+s};\nSave and Reload = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Ctrl+r};\n\n<delimiters> := (Quote = '\"' | 'Single Quote' = \"'\" | Comma = ',' | 'Equal Sign' = '=' | Equals = '=' \n\t| Period = '.' | Colon = ':' | 'Semi-Colon' = ';' | Hyphen = '-' | Underscore = '_'\n\t| Paren = \"(\" | \"Close Paren\" = \")\"\n\t| Bracket = '[' | \"Close Bracket\" = ']' | Brace = '{' | 'Close Brace' = '}'\t);\n\n# --- Navigation commands ------------------------------------\nLine 1..200 = {Ctrl+g} $1 {Enter};\n(Left = 'b' | Right = 'f') Word = {Alt+$1};\nTop = {Ctrl+Home};\nBottom = {Ctrl+End};\n(Find = 'Right' | 'Insert After' = 'Right' | 'Insert Before' = 'Left') (Next = 'Enter' | Last = 'Shift+F3') <delimiters> \n\t\t= {Ctrl+f} $3 {$2} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') <delimiters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') 1..20 <delimiters> = {Ctrl+f} $3 {Enter} {Esc} Wait(100) {F3_$2} {Shift+F3} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') Enda <delimiters> = {End} {Ctrl+f} $2 {Enter} {Esc} {Shift+F3} Wait(100) {$1};\n\nFine Alpha <letters> = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Right};\nInsert (Before = 'Left' | After = 'Right') Alpha <letters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nFine Number 0..9 = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Right};\nFind Again = {F3} {Right};\nFind Again 1..20 Times = {F3_$1} {Right};\n\nFind Symbol = {Ctrl+r};\n\n(Set | Add | Clear | Hide | Delete) Bookmark = {Ctrl+Alt+F2};\n(Next = 'F2' | Last = 'Shift+F2') Bookmark = {$1};\n\nNext Window = {Ctrl+Tab};\nLast Window = {Ctrl+Shift+Tab};\n\n\n# --- Editing commands ----------------------------------------\nSelect Line = {Ctrl+l};\nSelect (Next = 'Down' | Last = 'Up') 1..20 Lines = {Home} {Shift+$1_$2};\n(Join = 'j' | Indent = ']' | Dedent = '[') That = {Ctrl+$1};\nMove Line (Up | Down) 1..20 = {Ctrl+$1_$2};\n\n\n\nDelete Word = {Ctrl+Del};\nDelete 1..20 Words = {Ctrl+Del_$1};\nDelete (Back | Last) Word = {Ctrl+Backspace};\nDelete (Back | Last) 1..20 Words = {Ctrl+Backspace_$2};\nDelete Enda Word = {End} {Ctrl+Backspace};\n\n(Delete Line | Dede) = {Ctrl+Shift+k};\nDelete 1..20 Lines = {Ctrl+Shift+k_$1};\n(Cut = 'x' | Paste = 'v' | Copy = 'c') That = {Ctrl+$1};\n\nComment (That | Line) = {Ctrl+\/};\nComment 1..20 Lines = {Home} {Shift+Down_$1} {Ctrl+\/};\n\nSelect between (Delimiters | Brackets) ={Ctrl+m} {Ctrl+Alt+m};\nDelete Tags = {Ctrl+Alt+F4} {Up};\n\n\n\n\n# --- Code commands -------------------------------------------\nStart (Item = 'li' | List = 'ul' | HTML = 'html' | pre = \"pre\"\n\t| 'Bold ID' = 'bold-id' | 'Input' = 'ds-input-text'\n\t| Snippet = 'snip' | 'Recipe Row' = 'recipe-row' | 'Recipe Play' = 'recipe-play') = $1 {Tab};\nStart (para = '<p>' ) = $1;\nAdd (para = 'p') = {Home} '<' $1 '>' {End} '<\/' $1 '>';\nReplace With (para = 'p') = {Home} {Ctrl+Alt+F4} {Up} {Home} '<' $1 '>' {End} '<\/' $1 '>';\n\nStart (Header | Heading) 1..7 = h $2 {Tab};\nAdd (Header | Heading) 1..7 = {Home} '<h' $2 '>' {End} '<\/h' $2 '>';\nReplace With (Header | Heading) 1..7 = {Home} {Ctrl+Alt+F4} {Up} {Home} '<h' $2 '>' {End} '<\/h' $2 '>' {Home};\nMid HREF = '\">';\n\nPaste Function = 'function ' {Ctrl+v} ' {' {Enter} {Enter} '};' {Up};\n\n# TO ADD:\n# adding HTML comments, using a snippet\n\nShortcut Keys = {Ctrl+Shift+p};\n\n","old_contents":"# Voice commands for atom\n\ninclude folders.vch;\ninclude letters.vch;\n\nGo Strawberry = {Ctrl+Alt+F4};\nReload Atom = {Shift+Ctrl+Alt+F5};\n\nFind (File | Document) = {Ctrl+t};\nSave As = {Ctrl+Shift+s};\nSave and Reload = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Ctrl+r};\n\n<delimiters> := (Quote = '\"' | 'Single Quote' = \"'\" | Comma = ',' | 'Equal Sign' = '=' | Equals = '=' \n\t| Period = '.' | 'Semi-Colon' = ';');\n\n# --- Navigation commands ------------------------------------\nLine 1..200 = {Ctrl+g} $1 {Enter};\n(Left = 'b' | Right = 'f') Word = {Alt+$1};\nTop = {Ctrl+Home};\nBottom = {Ctrl+End};\n(Find = 'Right' | 'Insert After' = 'Right' | 'Insert Before' = 'Left') (Next = 'Enter' | Last = 'Shift+F3') <delimiters> \n\t\t= {Ctrl+f} $3 {$2} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') <delimiters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nFine Alpha <letters> = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Right};\nInsert (Before = 'Left' | After = 'Right') Alpha <letters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nFine Number 0..9 = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Right};\nFind Again = {F3} {Right};\nFind Again 1..20 Times = {F3_$1} {Right};\n\nFind Symbol = {Ctrl+r};\n\n(Set | Add | Clear | Hide | Delete) Bookmark = {Ctrl+Alt+F2};\n(Next = 'F2' | Last = 'Shift+F2') Bookmark = {$1};\n\nNext Window = {Ctrl+Tab};\nLast Window = {Ctrl+Shift+Tab};\n\n\n# --- Editing commands ----------------------------------------\nSelect Line = {Ctrl+l};\nSelect (Next = 'Down' | Last = 'Up') 1..20 Lines = {Home} {Shift+$1_$2};\n(Join = 'j' | Indent = ']' | Dedent = '[') That = {Ctrl+$1};\nMove Line (Up | Down) 1..20 = {Ctrl+$1_$2};\n\n\n\nDelete Word = {Ctrl+Del};\nDelete 1..20 Words = {Ctrl+Del_$1};\nDelete (Back | Last) Word = {Ctrl+Backspace};\nDelete (Back | Last) 1..20 Words = {Ctrl+Backspace_$2};\n(Delete Line | Dede) = {Ctrl+Shift+k};\nDelete 1..20 Lines = {Ctrl+Shift+k_$1};\n(Cut = 'x' | Paste = 'v' | Copy = 'c') That = {Ctrl+$1};\n\nComment (That | Line) = {Ctrl+\/};\nComment 1..20 Lines = {Home} {Shift+Down_$1} {Ctrl+\/};\n\n\nSelect between (Delimiters | Brackets) ={Ctrl+m} {Ctrl+Alt+m};\n# TO ADD:\n# delete between next tags\n\n\n\n\n# --- Code commands -------------------------------------------\nStart (Item = 'li' | List = 'ul' | HTML = 'html' | pre = \"pre\"\n\t| 'Bold ID' = 'bold-id' | 'Input' = 'ds-input-text'\n\t| Snippet = 'snip' | 'Recipe Row' = 'recipe-row' | 'Recipe Play' = 'recipe-play') = $1 {Tab};\nStart (para = '<p>' ) = $1;\nStart (Header | Heading) 1..7 = h $2 {Tab}; \nMid HREF = '\">';\n\nPaste Function = 'function ' {Ctrl+v} ' {' {Enter} {Enter} '};' {Up};\n\n# TO ADD:\n# adding HTML comments, using a snippet\n\nShortcut Keys = {Ctrl+Shift+p};\n\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"28a3e2be5332b3fee974faac125d117fa0e9d89b","subject":"Only synthetic if no content, and keep original status code","message":"Only synthetic if no content, and keep original status code\n","repos":"elifesciences\/builder,elifesciences\/builder","old_file":"src\/buildercore\/fastly\/vcl\/main.vcl","new_file":"src\/buildercore\/fastly\/vcl\/main.vcl","new_contents":"sub vcl_recv {\n #FASTLY recv\n\n if (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n return(lookup);\n}\n\nsub vcl_fetch {\n #FASTLY fetch\n\n if (beresp.status >= 500 && beresp.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n unset req.http.Cookie;\n\n restart;\n }\n\n if (!beresp.http.Content-Length || beresp.http.Content-Length == \"0\") {\n error beresp.status;\n }\n }\n\n if (req.restarts > 0) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return(pass);\n }\n\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return(pass);\n }\n\n if (beresp.status == 500 || beresp.status == 503) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return(deliver);\n }\n\n if (beresp.http.Expires || beresp.http.Surrogate-Control ~ \"max-age\" || beresp.http.Cache-Control ~ \"(s-maxage|max-age)\") {\n # keep the ttl here\n } else {\n # apply the default ttl\n set beresp.ttl = 3600s;\n }\n\n return(deliver);\n}\n\nsub vcl_hit {\n #FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\nsub vcl_miss {\n #FASTLY miss\n return(fetch);\n}\n\nsub vcl_deliver {\n if (resp.status >= 500 && resp.status < 600 && stale.exists) {\n unset req.http.Cookie;\n\n restart;\n }\n\n #FASTLY deliver\n return(deliver);\n}\n\nsub vcl_error {\n if (obj.status >= 500 && obj.status < 600 && stale.exists) {\n return(deliver_stale);\n }\n\n #FASTLY error\n}\n\nsub vcl_pass {\n #FASTLY pass\n}\n\nsub vcl_log {\n #FASTLY log\n}\n","old_contents":"sub vcl_recv {\n #FASTLY recv\n\n if (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n return(lookup);\n}\n\nsub vcl_fetch {\n #FASTLY fetch\n\n if (beresp.status >= 500 && beresp.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n unset req.http.Cookie;\n\n restart;\n }\n\n error 503;\n }\n\n if (req.restarts > 0) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return(pass);\n }\n\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return(pass);\n }\n\n if (beresp.http.Expires || beresp.http.Surrogate-Control ~ \"max-age\" || beresp.http.Cache-Control ~ \"(s-maxage|max-age)\") {\n # keep the ttl here\n } else {\n # apply the default ttl\n set beresp.ttl = 3600s;\n }\n\n return(deliver);\n}\n\nsub vcl_hit {\n #FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\nsub vcl_miss {\n #FASTLY miss\n return(fetch);\n}\n\nsub vcl_deliver {\n if (resp.status >= 500 && resp.status < 600 && stale.exists) {\n unset req.http.Cookie;\n\n restart;\n }\n\n #FASTLY deliver\n return(deliver);\n}\n\nsub vcl_error {\n if (obj.status >= 500 && obj.status < 600 && stale.exists) {\n return(deliver_stale);\n }\n\n #FASTLY error\n}\n\nsub vcl_pass {\n #FASTLY pass\n}\n\nsub vcl_log {\n #FASTLY log\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"cdece29d4038123b15f64c0130e56b6d6da786cc","subject":"add missing boolean or","message":"add missing boolean or\n","repos":"JakeChampion\/polyfill-service,JakeChampion\/polyfill-service","old_file":"fastly\/vcl\/main.vcl","new_file":"fastly\/vcl\/main.vcl","new_contents":"import querystring;\n\nsub sort_comma_separated_value {\n\t# This function takes a CSV and tranforms it into a url where each\n\t# comma-separated-value is a query-string parameter and then uses\n\t# Fastly's querystring.sort function to sort the values. Once sorted\n\t# it then turn the query-parameters back into a CSV.\n\t# Set the CSV on the header `Sort-Value`.\n\t# Returns the sorted CSV on the header `Sorted-Value`.\n\tdeclare local var.value STRING;\n\tset var.value = req.http.Sort-value;\n\n\t# If query value does not exist or is empty, set it to \"\"\n\tset var.value = if(var.value != \"\", var.value, \"\");\n\n\t# Replace all `&` characters with `^`, this is because `&` would break the value up into pieces.\n\tset var.value = regsuball(var.value, \"&\", \"^\");\n\n\t# Replace all `,` characters with `&` to break them into individual query values\n\t# Append `1-` infront of all the query values to make them simpler to transform later\n\tset var.value = \"1-\" regsuball(var.value, \",\", \"&1-\");\n\n\t# Create a querystring-like string in order for querystring.sort to work.\n\tset var.value = querystring.sort(\"?\" var.value);\n\n\t# Grab all the query values from the sorted url\n\tset var.value = regsub(var.value, \"\\?\", \"\");\n\n\t# Reverse all the previous transformations to get back the single `features` query value value\n\tset var.value = regsuball(var.value, \"1-\", \"\");\n\tset var.value = regsuball(var.value, \"&\", \",\");\n\tset var.value = regsuball(var.value, \"\\^\", \"&\");\n\n\tset req.http.Sorted-Value = var.value;\n}\n\nsub normalise_querystring_parameters_for_polyfill_bundle {\n\t# Store the url without the querystring into a temporary header.\n\tdeclare local var.url STRING;\n\tset var.url = querystring.remove(req.url);\n\n\tdeclare local var.querystring STRING;\n\tset var.querystring = \"?\";\n\n\t# Remove all querystring parameters which are not part of the public API.\n\t# set req.url = querystring.regfilter_except(req.url, \"^(features|excludes|rum|unknown|flags|version|ua|callback|compression)$\");\n\n\t# (?i) makes the regex case-insensitive\n\t# The regex will match only if their are characters after `features=` which are not an ampersand (&).\n\tif (req.url.qs ~ \"(?i)[^&=]*features=([^&]+)\") {\n\t\t# Parameter has already been set, use the already set value.\n\t\t# re.group.1 is the first regex capture group in the regex above.\n\t\tif (std.strlen(re.group.1) < 100) {\n\t\t\t# We add the value of the features parameter to this header\n\t\t\t# This is to be able to have sort_comma_separated_value sort the value\n\t\t\tset req.http.Sort-Value = urldecode(re.group.1);\n\t\t\tcall sort_comma_separated_value;\n\t\t\t# The header Sorted-Value now contains the sorted version of the features parameter.\n\t\t\tset var.querystring = querystring.set(var.querystring, \"features\", req.http.Sorted-Value);\n\t\t} else {\n\t\t\tset var.querystring = querystring.set(var.querystring, \"features\", urldecode(re.group.1));\n\t\t}\n\t} else {\n\t\t# Parameter has not been set, use the default value.\n\t\tset var.querystring = querystring.set(var.querystring, \"features\", \"default\");\n\t}\n\n\t# (?i) makes the regex case-insensitive\n\t# The regex will match only if their are characters after `excludes=` which are not an ampersand (&).\n\tif (req.url.qs ~ \"(?i)[^&=]*excludes=([^&]+)\") {\n\t\t# Parameter has already been set, use the already set value.\n\t\t# re.group.1 is the first regex capture group in the regex above.\n\t\tif (std.strlen(re.group.1) < 100) {\n\t\t\t# We add the value of the excludes parameter to this header\n\t\t\t# This is to be able to have sort_comma_separated_value sort the value\n\t\t\tset req.http.Sort-Value = urldecode(re.group.1);\n\t\t\tcall sort_comma_separated_value;\n\t\t\t# The header Sorted-Value now contains the sorted version of the excludes parameter.\n\t\t\tset var.querystring = querystring.set(var.querystring, \"excludes\", req.http.Sorted-Value);\n\t\t} else {\n\t\t\tset var.querystring = querystring.set(var.querystring, \"excludes\", urldecode(re.group.1));\n\t\t}\n\t} else {\n\t\t# If excludes is not set, set to default value \"\"\n\t\tset var.querystring = var.querystring \"&excludes=\";\n\t}\n\n\t# If rum is not set, set to default value \"0\"\n\tif (req.url.qs !~ \"(?i)[^&=]*rum=([^&]+)\") {\n\t\tset var.querystring = querystring.set(var.querystring, \"rum\", \"0\");\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"rum\", re.group.1);\n\t}\n\n\t# If unknown is not set, set to default value \"polyfill\"\n\tif (req.url.qs !~ \"(?i)[^&=]*unknown=([^&]+)\") {\n\t\tset var.querystring = querystring.set(var.querystring, \"unknown\", \"polyfill\");\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"unknown\", re.group.1);\n\t}\n\n\t# If flags is not set, set to default value \"\"\n\tif (req.url.qs !~ \"(?i)[^&=]*flags=([^&]+)\") {\n\t\tset var.querystring = var.querystring \"&flags=\";\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"flags\", urldecode(re.group.1));\n\t}\n\n\t# If version is not set, set to default value \"\"\n\tdeclare local var.version STRING;\n\tif (req.url.qs !~ \"(?i)[^&=]*version=([^&]+)\") {\n\t\tset var.querystring = var.querystring \"&version=\";\n\t} else {\n\t\tif (re.group.1 == \"3.50.2\" || re.group.1 == \"3.49.0\" || re.group.1 == \"3.48.0\" || re.group.1 == \"3.46.0\" || re.group.1 == \"3.45.0\" || re.group.1 == \"3.44.0\" || re.group.1 == \"3.43.0\" || re.group.1 == \"3.42.0\" || re.group.1 == \"3.41.0\" || re.group.1 == \"3.40.0\" || re.group.1 == \"3.39.0\" || re.group.1 == \"3.38.0\" || re.group.1 == \"3.37.0\" || re.group.1 == \"3.36.0\" || re.group.1 == \"3.35.0\" || re.group.1 == \"3.34.0\" || re.group.1 == \"3.28.1\" || re.group.1 == \"3.27.4\" || re.group.1 == \"3.25.3\" || re.group.1 == \"3.25.2\" || re.group.1 == \"3.25.1\") {\n\t\t\tset var.querystring = querystring.set(var.querystring, \"version\", re.group.1);\n\t\t} else {\n\t\t\tset var.querystring = var.querystring \"&version=\";\n\t\t}\n\t}\n\n\t# If ua is not set, normalise the User-Agent header based upon the version of the polyfill-library that has been requested.\n\tif (req.url.qs !~ \"(?i)[^&=]*ua=([^&]+)\") {\n\t\tif (req.url.qs ~ \"(?i)[^&=]*version=3\\.25\\.1(&|$)\") {\n\t\t\tcall normalise_user_agent_3_25_1;\n\t\t} else {\n\t\t\tcall normalise_user_agent_1_5_0;\n\t\t}\n\t\tset var.querystring = querystring.set(var.querystring, \"ua\", req.http.Normalized-User-Agent);\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"ua\", urldecode(re.group.1));\n\t}\n\n\t# If callback is not set, set to default value \"\"\n\tif (req.url.qs !~ \"(?i)[^&=]*callback=([^&]+)\") {\n\t\tset var.querystring = var.querystring \"&callback=\";\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"callback\", re.group.1);\n\t}\n\n\t# If compression is not set, use the best compression that the user-agent supports.\n\tif (req.url.qs !~ \"(?i)[^&=]*compression=([^&]+)\") {\n\t\t# When Fastly adds Brotli into the Accept-Encoding normalisation we can replace this with:\n\t\t# `set var.querystring = querystring.set(var.querystring, \"compression\", req.http.Accept-Encoding || \"\")`\n\n\t\t# Before SP2, IE\/6 doesn't always read and cache gzipped content correctly.\n\t\tif (req.http.Fastly-Orig-Accept-Encoding && req.http.User-Agent !~ \"MSIE 6\") {\n\t\t\tif (req.http.Fastly-Orig-Accept-Encoding ~ \"br\") {\n\t\t\t\tset var.querystring = querystring.set(var.querystring, \"compression\", \"br\");\n\t\t\t} elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"gzip\") {\n\t\t\t\tset var.querystring = querystring.set(var.querystring, \"compression\", \"gzip\");\n\t\t\t} else {\n\t\t\t\tset var.querystring = var.querystring \"&compression=\";\n\t\t\t}\n\t\t} else {\n\t\t\tset var.querystring = var.querystring \"&compression=\";\n\t\t}\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"compression\", re.group.1);\n\t}\n\tset req.url = var.url var.querystring;\n}\n\ninclude \"top_pops.vcl\";\ninclude \"normalise-user-agent-3-25-1.vcl\";\ninclude \"normalise-user-agent.vcl\";\n\n# The Fastly VCL boilerplate.\ninclude \"fastly-boilerplate-begin.vcl\";\n\ninclude \"breadcrumbs.vcl\";\ninclude \"redirects.vcl\";\ninclude \"synthetic-responses.vcl\";\ninclude \"polyfill-service.vcl\";\n\n# Finally include the last bit of VCL, this _must_ be last!\ninclude \"fastly-boilerplate-end.vcl\";\n","old_contents":"import querystring;\n\nsub sort_comma_separated_value {\n\t# This function takes a CSV and tranforms it into a url where each\n\t# comma-separated-value is a query-string parameter and then uses\n\t# Fastly's querystring.sort function to sort the values. Once sorted\n\t# it then turn the query-parameters back into a CSV.\n\t# Set the CSV on the header `Sort-Value`.\n\t# Returns the sorted CSV on the header `Sorted-Value`.\n\tdeclare local var.value STRING;\n\tset var.value = req.http.Sort-value;\n\n\t# If query value does not exist or is empty, set it to \"\"\n\tset var.value = if(var.value != \"\", var.value, \"\");\n\n\t# Replace all `&` characters with `^`, this is because `&` would break the value up into pieces.\n\tset var.value = regsuball(var.value, \"&\", \"^\");\n\n\t# Replace all `,` characters with `&` to break them into individual query values\n\t# Append `1-` infront of all the query values to make them simpler to transform later\n\tset var.value = \"1-\" regsuball(var.value, \",\", \"&1-\");\n\n\t# Create a querystring-like string in order for querystring.sort to work.\n\tset var.value = querystring.sort(\"?\" var.value);\n\n\t# Grab all the query values from the sorted url\n\tset var.value = regsub(var.value, \"\\?\", \"\");\n\n\t# Reverse all the previous transformations to get back the single `features` query value value\n\tset var.value = regsuball(var.value, \"1-\", \"\");\n\tset var.value = regsuball(var.value, \"&\", \",\");\n\tset var.value = regsuball(var.value, \"\\^\", \"&\");\n\n\tset req.http.Sorted-Value = var.value;\n}\n\nsub normalise_querystring_parameters_for_polyfill_bundle {\n\t# Store the url without the querystring into a temporary header.\n\tdeclare local var.url STRING;\n\tset var.url = querystring.remove(req.url);\n\n\tdeclare local var.querystring STRING;\n\tset var.querystring = \"?\";\n\n\t# Remove all querystring parameters which are not part of the public API.\n\t# set req.url = querystring.regfilter_except(req.url, \"^(features|excludes|rum|unknown|flags|version|ua|callback|compression)$\");\n\n\t# (?i) makes the regex case-insensitive\n\t# The regex will match only if their are characters after `features=` which are not an ampersand (&).\n\tif (req.url.qs ~ \"(?i)[^&=]*features=([^&]+)\") {\n\t\t# Parameter has already been set, use the already set value.\n\t\t# re.group.1 is the first regex capture group in the regex above.\n\t\tif (std.strlen(re.group.1) < 100) {\n\t\t\t# We add the value of the features parameter to this header\n\t\t\t# This is to be able to have sort_comma_separated_value sort the value\n\t\t\tset req.http.Sort-Value = urldecode(re.group.1);\n\t\t\tcall sort_comma_separated_value;\n\t\t\t# The header Sorted-Value now contains the sorted version of the features parameter.\n\t\t\tset var.querystring = querystring.set(var.querystring, \"features\", req.http.Sorted-Value);\n\t\t} else {\n\t\t\tset var.querystring = querystring.set(var.querystring, \"features\", urldecode(re.group.1));\n\t\t}\n\t} else {\n\t\t# Parameter has not been set, use the default value.\n\t\tset var.querystring = querystring.set(var.querystring, \"features\", \"default\");\n\t}\n\n\t# (?i) makes the regex case-insensitive\n\t# The regex will match only if their are characters after `excludes=` which are not an ampersand (&).\n\tif (req.url.qs ~ \"(?i)[^&=]*excludes=([^&]+)\") {\n\t\t# Parameter has already been set, use the already set value.\n\t\t# re.group.1 is the first regex capture group in the regex above.\n\t\tif (std.strlen(re.group.1) < 100) {\n\t\t\t# We add the value of the excludes parameter to this header\n\t\t\t# This is to be able to have sort_comma_separated_value sort the value\n\t\t\tset req.http.Sort-Value = urldecode(re.group.1);\n\t\t\tcall sort_comma_separated_value;\n\t\t\t# The header Sorted-Value now contains the sorted version of the excludes parameter.\n\t\t\tset var.querystring = querystring.set(var.querystring, \"excludes\", req.http.Sorted-Value);\n\t\t} else {\n\t\t\tset var.querystring = querystring.set(var.querystring, \"excludes\", urldecode(re.group.1));\n\t\t}\n\t} else {\n\t\t# If excludes is not set, set to default value \"\"\n\t\tset var.querystring = var.querystring \"&excludes=\";\n\t}\n\n\t# If rum is not set, set to default value \"0\"\n\tif (req.url.qs !~ \"(?i)[^&=]*rum=([^&]+)\") {\n\t\tset var.querystring = querystring.set(var.querystring, \"rum\", \"0\");\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"rum\", re.group.1);\n\t}\n\n\t# If unknown is not set, set to default value \"polyfill\"\n\tif (req.url.qs !~ \"(?i)[^&=]*unknown=([^&]+)\") {\n\t\tset var.querystring = querystring.set(var.querystring, \"unknown\", \"polyfill\");\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"unknown\", re.group.1);\n\t}\n\n\t# If flags is not set, set to default value \"\"\n\tif (req.url.qs !~ \"(?i)[^&=]*flags=([^&]+)\") {\n\t\tset var.querystring = var.querystring \"&flags=\";\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"flags\", urldecode(re.group.1));\n\t}\n\n\t# If version is not set, set to default value \"\"\n\tdeclare local var.version STRING;\n\tif (req.url.qs !~ \"(?i)[^&=]*version=([^&]+)\") {\n\t\tset var.querystring = var.querystring \"&version=\";\n\t} else {\n\t\tif (re.group.1 == \"3.50.2\" re.group.1 == \"3.49.0\" || re.group.1 == \"3.48.0\" || re.group.1 == \"3.46.0\" || re.group.1 == \"3.45.0\" || re.group.1 == \"3.44.0\" || re.group.1 == \"3.43.0\" || re.group.1 == \"3.42.0\" || re.group.1 == \"3.41.0\" || re.group.1 == \"3.40.0\" || re.group.1 == \"3.39.0\" || re.group.1 == \"3.38.0\" || re.group.1 == \"3.37.0\" || re.group.1 == \"3.36.0\" || re.group.1 == \"3.35.0\" || re.group.1 == \"3.34.0\" || re.group.1 == \"3.28.1\" || re.group.1 == \"3.27.4\" || re.group.1 == \"3.25.3\" || re.group.1 == \"3.25.2\" || re.group.1 == \"3.25.1\") {\n\t\t\tset var.querystring = querystring.set(var.querystring, \"version\", re.group.1);\n\t\t} else {\n\t\t\tset var.querystring = var.querystring \"&version=\";\n\t\t}\n\t}\n\n\t# If ua is not set, normalise the User-Agent header based upon the version of the polyfill-library that has been requested.\n\tif (req.url.qs !~ \"(?i)[^&=]*ua=([^&]+)\") {\n\t\tif (req.url.qs ~ \"(?i)[^&=]*version=3\\.25\\.1(&|$)\") {\n\t\t\tcall normalise_user_agent_3_25_1;\n\t\t} else {\n\t\t\tcall normalise_user_agent_1_5_0;\n\t\t}\n\t\tset var.querystring = querystring.set(var.querystring, \"ua\", req.http.Normalized-User-Agent);\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"ua\", urldecode(re.group.1));\n\t}\n\n\t# If callback is not set, set to default value \"\"\n\tif (req.url.qs !~ \"(?i)[^&=]*callback=([^&]+)\") {\n\t\tset var.querystring = var.querystring \"&callback=\";\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"callback\", re.group.1);\n\t}\n\n\t# If compression is not set, use the best compression that the user-agent supports.\n\tif (req.url.qs !~ \"(?i)[^&=]*compression=([^&]+)\") {\n\t\t# When Fastly adds Brotli into the Accept-Encoding normalisation we can replace this with:\n\t\t# `set var.querystring = querystring.set(var.querystring, \"compression\", req.http.Accept-Encoding || \"\")`\n\n\t\t# Before SP2, IE\/6 doesn't always read and cache gzipped content correctly.\n\t\tif (req.http.Fastly-Orig-Accept-Encoding && req.http.User-Agent !~ \"MSIE 6\") {\n\t\t\tif (req.http.Fastly-Orig-Accept-Encoding ~ \"br\") {\n\t\t\t\tset var.querystring = querystring.set(var.querystring, \"compression\", \"br\");\n\t\t\t} elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"gzip\") {\n\t\t\t\tset var.querystring = querystring.set(var.querystring, \"compression\", \"gzip\");\n\t\t\t} else {\n\t\t\t\tset var.querystring = var.querystring \"&compression=\";\n\t\t\t}\n\t\t} else {\n\t\t\tset var.querystring = var.querystring \"&compression=\";\n\t\t}\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"compression\", re.group.1);\n\t}\n\tset req.url = var.url var.querystring;\n}\n\ninclude \"top_pops.vcl\";\ninclude \"normalise-user-agent-3-25-1.vcl\";\ninclude \"normalise-user-agent.vcl\";\n\n# The Fastly VCL boilerplate.\ninclude \"fastly-boilerplate-begin.vcl\";\n\ninclude \"breadcrumbs.vcl\";\ninclude \"redirects.vcl\";\ninclude \"synthetic-responses.vcl\";\ninclude \"polyfill-service.vcl\";\n\n# Finally include the last bit of VCL, this _must_ be last!\ninclude \"fastly-boilerplate-end.vcl\";\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"66e4bbdc3bc383c0543b59a33c37208124280799","subject":"Rearrange default.vcl vcl_recv.","message":"Rearrange default.vcl vcl_recv.\n","repos":"hummingbird-me\/ansible-deploy","old_file":"roles\/varnish\/templates\/default.vcl","new_file":"roles\/varnish\/templates\/default.vcl","new_contents":"backend s3 {\n .host = \"{{aws_bucket}}.s3.amazonaws.com\";\n .port = \"80\";\n}\n\nbackend s3forum {\n .host = \"{{forum_aws_bucket}}.s3.amazonaws.com\";\n .port = \"80\";\n}\n\nsub vcl_recv {\n unset req.http.cookie;\n unset req.http.cache-control;\n unset req.http.pragma;\n unset req.http.expires;\n unset req.http.etag;\n unset req.http.X-Forwarded-For;\n\n if (req.http.host == \"{{varnish_host}}\") {\n set req.backend = s3;\n set req.http.host = \"{{aws_bucket}}.s3.amazonaws.com\";\n return (lookup);\n }\n if (req.http.host == \"{{forum_varnish_host}}\") {\n set req.backend = s3forum;\n set req.http.host = \"{{forum_aws_bucket}}.s3.amazonaws.com\";\n return (lookup);\n }\n}\n\nsub vcl_fetch {\n unset beresp.http.X-Amz-Id-2;\n unset beresp.http.X-Amz-Meta-Group;\n unset beresp.http.X-Amz-Meta-Owner;\n unset beresp.http.X-Amz-Meta-Permissions;\n unset beresp.http.X-Amz-Request-Id;\n unset beresp.http.expires;\n\n set beresp.ttl = 1w;\n set beresp.grace = 30s;\n set beresp.http.cache-control = \"max-age=2592000\";\n}\n\n#\n# Below is a commented-out copy of the default VCL logic. If you\n# redefine any of these subroutines, the built-in logic will be\n# appended to your code.\n# sub vcl_recv {\n# if (req.restarts == 0) {\n# \tif (req.http.x-forwarded-for) {\n# \t set req.http.X-Forwarded-For =\n# \t\treq.http.X-Forwarded-For + \", \" + client.ip;\n# \t} else {\n# \t set req.http.X-Forwarded-For = client.ip;\n# \t}\n# }\n# if (req.request != \"GET\" &&\n# req.request != \"HEAD\" &&\n# req.request != \"PUT\" &&\n# req.request != \"POST\" &&\n# req.request != \"TRACE\" &&\n# req.request != \"OPTIONS\" &&\n# req.request != \"DELETE\") {\n# \/* Non-RFC2616 or CONNECT which is weird. *\/\n# return (pipe);\n# }\n# if (req.request != \"GET\" && req.request != \"HEAD\") {\n# \/* We only deal with GET and HEAD by default *\/\n# return (pass);\n# }\n# if (req.http.Authorization || req.http.Cookie) {\n# \/* Not cacheable by default *\/\n# return (pass);\n# }\n# return (lookup);\n# }\n#\n# sub vcl_pipe {\n# # Note that only the first request to the backend will have\n# # X-Forwarded-For set. If you use X-Forwarded-For and want to\n# # have it set for all requests, make sure to have:\n# # set bereq.http.connection = \"close\";\n# # here. It is not set by default as it might break some broken web\n# # applications, like IIS with NTLM authentication.\n# return (pipe);\n# }\n#\n# sub vcl_pass {\n# return (pass);\n# }\n#\n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (hash);\n# }\n#\n# sub vcl_hit {\n# return (deliver);\n# }\n#\n# sub vcl_miss {\n# return (fetch);\n# }\n#\n# sub vcl_fetch {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Vary == \"*\") {\n# \t\t\/*\n# \t\t * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# \t\t *\/\n# \t\tset beresp.ttl = 120 s;\n# \t\treturn (hit_for_pass);\n# }\n# return (deliver);\n# }\n#\n# sub vcl_deliver {\n# return (deliver);\n# }\n#\n# sub vcl_error {\n# set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n# set obj.http.Retry-After = \"5\";\n# synthetic {\"\n# <?xml version=\"1.0\" encoding=\"utf-8\"?>\n# <!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n# \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n# <html>\n# <head>\n# <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n# <\/head>\n# <body>\n# <h1>Error \"} + obj.status + \" \" + obj.response + {\"<\/h1>\n# <p>\"} + obj.response + {\"<\/p>\n# <h3>Guru Meditation:<\/h3>\n# <p>XID: \"} + req.xid + {\"<\/p>\n# <hr>\n# <p>Varnish cache server<\/p>\n# <\/body>\n# <\/html>\n# \"};\n# return (deliver);\n# }\n#\n# sub vcl_init {\n# \treturn (ok);\n# }\n#\n# sub vcl_fini {\n# \treturn (ok);\n# }\n","old_contents":"backend s3 {\n .host = \"{{aws_bucket}}.s3.amazonaws.com\";\n .port = \"80\";\n}\n\nbackend s3forum {\n .host = \"{{forum_aws_bucket}}.s3.amazonaws.com\";\n .port = \"80\";\n}\n\nsub vcl_recv {\n unset req.http.cookie;\n unset req.http.cache-control;\n unset req.http.pragma;\n unset req.http.expires;\n unset req.http.etag;\n unset req.http.X-Forwarded-For;\n\n if (req.http.host == \"{{varnish_host}}\") {\n set req.backend = s3;\n set req.http.host = \"{{aws_bucket}}.s3.amazonaws.com\";\n }\n if (req.http.host == \"{{forum_varnish_host}}\") {\n set req.backend = s3forum;\n set req.http.host = \"{{forum_aws_bucket}}.s3.amazonaws.com\";\n }\n\n return (lookup);\n}\n\nsub vcl_fetch {\n unset beresp.http.X-Amz-Id-2;\n unset beresp.http.X-Amz-Meta-Group;\n unset beresp.http.X-Amz-Meta-Owner;\n unset beresp.http.X-Amz-Meta-Permissions;\n unset beresp.http.X-Amz-Request-Id;\n unset beresp.http.expires;\n\n set beresp.ttl = 1w;\n set beresp.grace = 30s;\n set beresp.http.cache-control = \"max-age=2592000\";\n}\n\n#\n# Below is a commented-out copy of the default VCL logic. If you\n# redefine any of these subroutines, the built-in logic will be\n# appended to your code.\n# sub vcl_recv {\n# if (req.restarts == 0) {\n# \tif (req.http.x-forwarded-for) {\n# \t set req.http.X-Forwarded-For =\n# \t\treq.http.X-Forwarded-For + \", \" + client.ip;\n# \t} else {\n# \t set req.http.X-Forwarded-For = client.ip;\n# \t}\n# }\n# if (req.request != \"GET\" &&\n# req.request != \"HEAD\" &&\n# req.request != \"PUT\" &&\n# req.request != \"POST\" &&\n# req.request != \"TRACE\" &&\n# req.request != \"OPTIONS\" &&\n# req.request != \"DELETE\") {\n# \/* Non-RFC2616 or CONNECT which is weird. *\/\n# return (pipe);\n# }\n# if (req.request != \"GET\" && req.request != \"HEAD\") {\n# \/* We only deal with GET and HEAD by default *\/\n# return (pass);\n# }\n# if (req.http.Authorization || req.http.Cookie) {\n# \/* Not cacheable by default *\/\n# return (pass);\n# }\n# return (lookup);\n# }\n#\n# sub vcl_pipe {\n# # Note that only the first request to the backend will have\n# # X-Forwarded-For set. If you use X-Forwarded-For and want to\n# # have it set for all requests, make sure to have:\n# # set bereq.http.connection = \"close\";\n# # here. It is not set by default as it might break some broken web\n# # applications, like IIS with NTLM authentication.\n# return (pipe);\n# }\n#\n# sub vcl_pass {\n# return (pass);\n# }\n#\n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (hash);\n# }\n#\n# sub vcl_hit {\n# return (deliver);\n# }\n#\n# sub vcl_miss {\n# return (fetch);\n# }\n#\n# sub vcl_fetch {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Vary == \"*\") {\n# \t\t\/*\n# \t\t * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# \t\t *\/\n# \t\tset beresp.ttl = 120 s;\n# \t\treturn (hit_for_pass);\n# }\n# return (deliver);\n# }\n#\n# sub vcl_deliver {\n# return (deliver);\n# }\n#\n# sub vcl_error {\n# set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n# set obj.http.Retry-After = \"5\";\n# synthetic {\"\n# <?xml version=\"1.0\" encoding=\"utf-8\"?>\n# <!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n# \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n# <html>\n# <head>\n# <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n# <\/head>\n# <body>\n# <h1>Error \"} + obj.status + \" \" + obj.response + {\"<\/h1>\n# <p>\"} + obj.response + {\"<\/p>\n# <h3>Guru Meditation:<\/h3>\n# <p>XID: \"} + req.xid + {\"<\/p>\n# <hr>\n# <p>Varnish cache server<\/p>\n# <\/body>\n# <\/html>\n# \"};\n# return (deliver);\n# }\n#\n# sub vcl_init {\n# \treturn (ok);\n# }\n#\n# sub vcl_fini {\n# \treturn (ok);\n# }\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"3bf9609232074243dea371adea9bb1ebad34a4b4","subject":"Remove slash from GraphQL exclusion (#461)","message":"Remove slash from GraphQL exclusion (#461)\n\n* Remove slash from GraphQL exclusion\r\n\r\n* tweak regex\r\n\r\nCo-authored-by: Shohei Maeda <8845b3d1ebb2afe277cb5f4b74ca5e249c746bff@ntworkers.com>","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets_basic_auth\/recv.vcl","new_file":"etc\/vcl_snippets_basic_auth\/recv.vcl","new_contents":" # Check Basic auth against a table. \/admin URLs are not basic auth protected to avoid the possibility of people\n # locking themselves out. \/oauth and \/rest have their own auth so we can skip Basic Auth on them as well\n if ( req.method != \"FASTLYPURGE\" &&\n table.lookup(magentomodule_basic_auth, regsub(req.http.Authorization, \"^Basic \", \"\"), \"NOTFOUND\") == \"NOTFOUND\" &&\n !req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" &&\n !req.url ~ \"^\/(index\\.php\/)?(rest|oauth|graphql)($|[\\\/?])\" &&\n !req.url ~ \"^\/pub\/static\/\" ) {\n error 771;\n }\n","old_contents":" # Check Basic auth against a table. \/admin URLs are not basic auth protected to avoid the possibility of people\n # locking themselves out. \/oauth and \/rest have their own auth so we can skip Basic Auth on them as well\n if ( req.method != \"FASTLYPURGE\" &&\n table.lookup(magentomodule_basic_auth, regsub(req.http.Authorization, \"^Basic \", \"\"), \"NOTFOUND\") == \"NOTFOUND\" &&\n !req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" &&\n !req.url ~ \"^\/(index\\.php\/)?(rest|oauth|graphql)\/\" &&\n !req.url ~ \"^\/pub\/static\/\" ) {\n error 771;\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"dbef371ca378423d34ed02133800f8e05cc515f3","subject":"Fix redirect loop on TestPyPI (#3729)","message":"Fix redirect loop on TestPyPI (#3729)\n\n","repos":"pypa\/warehouse,dstufft\/warehouse,pypa\/warehouse,dstufft\/warehouse,dstufft\/warehouse,pypa\/warehouse,pypa\/warehouse,dstufft\/warehouse","old_file":"vcl\/main.vcl","new_file":"vcl\/main.vcl","new_contents":"# Note: This is *ONLY* used for test.pypi.org, for the pypi.org, see python\/pypi-infra\n\n# Note: It is VERY important to ensure that any changes to VCL will work\n# properly with both the current version of ``master`` and the version in\n# the pull request that adds any new changes. This is because the\n# configuration will be applied automatically as part of the deployment\n# process, but while the previous version of the code is still up and\n# running. Thus backwards incompatible changes must be broken up over\n# multiple pull requests in order to phase them in over multiple deploys.\n\nsub vcl_recv {\n\n # Fastly is dropping support for TLSv1.0 and TLSv1.1, in preperation for\n # for that, we're going to block support for it now, using VCL. This will\n # let us present a better error message in the interim before Fastly shuts\n # off TLSv1.0 and TLSv1.1 support completely.\n if (tls.client.protocol ~ \"^TLSv1(\\.(0|1))?$\") {\n set req.http.Error-Message = \"Support for \" tls.client.protocol \" has been removed, please upgrade to a TLSv1.2+ client. Please see https:\/\/pyfound.blogspot.com\/2017\/01\/time-to-upgrade-your-python-tls-v12.html\";\n error 804 \"Bad SSL Version\";\n }\n\n # I'm not 100% sure on what this is exactly for, it was taken from the\n # Fastly documentation, however, what I *believe* it does is just ensure\n # that we don't serve a stale copy of the page from the shield node when\n # an edge node is requesting content.\n if (req.http.Fastly-FF) {\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Some (Older) clients will send a hash fragment as part of the URL even\n # though that is a local only modification. This breaks this badly for the\n # files in S3, and in general it's just not needed.\n set req.url = regsub(req.url, \"#.*$\", \"\");\n\n # Fastly does some normalization of the Accept-Encoding header so that it\n # reduces the number of cached copies (when served with the common,\n # Vary: Accept-Encoding) that are cached for any one URL. This makes a lot\n # of sense, except for the fact that we want to enable brotli compression\n # for our static files. Thus we need to work around the normalized encoding\n # in a way that still minimizes cached copies, but which will allow our\n # static files to be served using brotli.\n if (req.url ~ \"^\/static\/\" && req.http.Fastly-Orig-Accept-Encoding) {\n if (req.http.User-Agent ~ \"MSIE 6\") {\n # For that 0.3% of stubborn users out there\n unset req.http.Accept-Encoding;\n } elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"br\") {\n set req.http.Accept-Encoding = \"br\";\n } elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n\n # Most of the URLs in Warehouse do not support or require any sort of query\n # parameter. If we strip these at the edge then we'll increase our cache\n # efficiency when they won't otherwise change the output of the pages.\n #\n # This will match any URL except those that start with:\n #\n # * \/admin\/\n # * \/search\/\n # * \/account\/login\/\n # * \/account\/logout\/\n # * \/account\/register\/\n # * \/account\/reset-password\/\n # * \/account\/verify-email\/\n # * \/pypi\n if (req.url.path !~ \"^\/(admin\/|search(\/|$)|account\/(login|logout|register|reset-password|verify-email)\/|pypi)\") {\n set req.url = req.url.path;\n }\n\n # Sort all of our query parameters, this will ensure that the same query\n # parameters in a different order will end up being represented as the same\n # thing, reducing cache misses due to ordering differences.\n set req.url = boltsort.sort(req.url);\n\n # We have a number of items that we'll pass back to the origin.\n # Set a header to tell the backend if we're using https or http.\n if (req.http.Fastly-SSL) {\n set req.http.Warehouse-Proto = \"https\";\n } else {\n set req.http.Warehouse-Proto = \"http\";\n }\n # Pass the client IP address back to the backend.\n if (req.http.Fastly-Client-IP) {\n set req.http.Warehouse-IP = req.http.Fastly-Client-IP;\n }\n # Pass the real host value back to the backend.\n if (req.http.Host) {\n set req.http.Warehouse-Host = req.http.host;\n }\n\n # Currently Fastly does not provide a way to access response headers when\n # the response is a 304 response. This is because the RFC states that only\n # a limit set of headers should be sent with a 304 response, and the rest\n # are SHOULD NOT. Since this stripping happens *prior* to vcl_deliver being\n # ran, that breaks our ability to log on 304 responses. Ideally at some\n # point Fastly offers us a way to access the \"real\" response headers even\n # for a 304 response, but for now, we are going to remove the headers that\n # allow a conditional response to be made. If at some point Fastly does\n # allow this, then we can delete this code.\n if (!req.http.Fastly-FF\n && std.tolower(req.http.Warehouse-Host) == \"files.pythonhosted.org\"\n && req.url.path ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\") {\n unset req.http.If-None-Match;\n unset req.http.If-Modified-Since;\n }\n\n\n#FASTLY recv\n\n\n # We want to Force SSL for the WebUI by redirecting to the HTTPS version of\n # the page, however for API calls we want to return an error code directing\n # people to instead use HTTPS.\n if (!req.http.Fastly-SSL) {\n\n # The \/simple\/ and \/packages\/ API.\n if (req.url ~ \"^\/(simple|packages)\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy JSON API.\n if (req.url ~ \"^\/pypi\/.+\/json$\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy ?:action= API.\n if (req.url ~ \"^\/pypi.*(\\?|&)=:action\") {\n error 803 \"SSL is required\";\n }\n\n # If we're on the \/pypi page and we've received something other than a\n # GET or HEAD request, then we have no way to determine if a particular\n # request is an API call or not because it'll be in the request body\n # and that isn't available to us here. So in those cases, we won't\n # do a redirect.\n if (req.url ~ \"^\/pypi\") {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n error 801 \"Force SSL\";\n }\n }\n else {\n # This isn't a \/pypi URL so we'll just unconditionally redirect to\n # HTTPS.\n error 801 \"Force SSL\";\n }\n }\n\n # Redirect pypi.io, www.pypi.io, and warehouse.python.org to pypi.org, this\n # is purposely done *after* the HTTPS checks.\n if (std.tolower(req.http.host) ~ \"^(www.pypi.org|(www.)?pypi.io|warehouse.python.org)$\") {\n set req.http.Location = \"https:\/\/pypi.org\" req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n # Redirect warehouse-staging.python.org to test.pypi.io.\n if (std.tolower(req.http.host) ~ \"^(test.pypi.io|warehouse-staging.python.org)$\") {\n set req.http.Location = \"https:\/\/test.pypi.org\" req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n\n # Requests to \/packages\/ get dispatched to Amazon instead of to our typical\n # Origin. This requires a a bit of setup to make it work.\n if (req.backend == F_S3 && req.http.host ~ \"^(test-)?files.pythonhosted.org$\"\n && req.url ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\") {\n # Setup our environment to better match what S3 expects\/needs\n set req.http.Host = req.http.AWS-Bucket-Name \".s3.amazonaws.com\";\n set req.http.Date = now;\n set req.url = regsuball(req.url, \"\\+\", urlencode(\"+\"));\n\n # Compute the Authorization header that S3 requires to be able to\n # access the files stored there.\n set req.http.Authorization = \"AWS \" req.http.AWS-Access-Key-ID \":\" digest.hmac_sha1_base64(req.http.AWS-Secret-Access-Key, \"GET\" LF LF LF req.http.Date LF \"\/\" req.http.AWS-Bucket-Name req.url.path);\n\n # We don't want to send our Warehouse-Token to S3, so we'll go ahead\n # and remove it.\n unset req.http.Warehouse-Token;\n }\n\n # We no longer need any of these variables, which would exist only to\n # shuffle configuration from the Fastly UI into our VCL.\n unset req.http.AWS-Access-Key-ID;\n unset req.http.AWS-Secret-Access-Key;\n unset req.http.AWS-Bucket-Name;\n\n # On a POST, we want to skip the shielding and hit backends directly.\n if (req.request == \"POST\") {\n set req.backend = F_Heroku;\n }\n\n # Do not bother to attempt to run the caching mechanisms for methods that\n # are not generally safe to cache.\n if (req.request != \"HEAD\" &&\n req.request != \"GET\" &&\n req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n # We don't ever want to cache our health URL. Outside systems should be\n # able to use it to reach past Fastly and get an end to end health check.\n if (req.url == \"\/_health\/\") {\n return(pass);\n }\n\n # We never want to cache our admin URLs, while this should be \"safe\" due to\n # the architecure of Warehouse, it'll just be easier to debug issues if\n # these always are uncached.\n if (req.url ~ \"^\/admin\/\") {\n return(pass);\n }\n\n # Finally, return the default lookup action.\n return(lookup);\n}\n\n\nsub vcl_fetch {\n\n # These are newer kinds of redirects which should be able to be cached by\n # default, even though Fastly doesn't currently have them in their default\n # list of cacheable status codes.\n if (http_status_matches(beresp.status, \"303,307,308\")) {\n set beresp.cacheable = true;\n }\n\n # For any 5xx status code we want to see if a stale object exists for it,\n # if so we'll go ahead and serve it.\n if (beresp.status >= 500 && beresp.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n\n#FASTLY fetch\n\n\n # Trigger a \"SSL is required\" error if the backend has indicated to do so.\n if (beresp.http.X-Fastly-Error == \"803\") {\n error 803 \"SSL is required\";\n }\n\n # If we've gotten a 502 or a 503 from the backend, we'll go ahead and retry\n # the request.\n if ((beresp.status == 502 || beresp.status == 503) &&\n req.restarts < 1 &&\n (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n # If we've restarted, then we'll record the number of restarts.\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n # If there is a Set-Cookie header, we'll ensure that we do not cache the\n # response.\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n # If the response has the private Cache-Control directive then we won't\n # cache it.\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # If we've gotten an error after the restarts we'll deliver the response\n # with a very short cache time.\n if (http_status_matches(beresp.status, \"500,502,503\")) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n # Apply a default TTL if there isn't a max-age or s-maxage.\n if (beresp.http.Expires ||\n beresp.http.Surrogate-Control ~ \"max-age\" ||\n beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # Keep the ttl here\n }\n else {\n # Apply the default ttl\n set beresp.ttl = 60s;\n }\n\n # Actually deliver the fetched response.\n return(deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n # If the object we have isn't cacheable, then just serve it directly\n # without going through any of the caching mechanisms.\n if (!obj.cacheable) {\n return(pass);\n }\n\n return(deliver);\n}\n\n\nsub vcl_deliver {\n # If this is an error and we have a stale response available, restart so\n # that we can pick it up and serve it.\n if (resp.status >= 500 && resp.status < 600) {\n if (stale.exists) {\n restart;\n }\n }\n\n#FASTLY deliver\n\n # Unset headers that we don't need\/want to send on to the client because\n # they are not generally useful.\n unset resp.http.Via;\n\n # Set our standard security headers, we do this in VCL rather than in\n # Warehouse itself so that we always get these headers, regardless of the\n # origin server being used.\n set resp.http.Strict-Transport-Security = \"max-age=31536000; includeSubDomains; preload\";\n set resp.http.X-Frame-Options = \"deny\";\n set resp.http.X-XSS-Protection = \"1; mode=block\";\n set resp.http.X-Content-Type-Options = \"nosniff\";\n set resp.http.X-Permitted-Cross-Domain-Policies = \"none\";\n\n # Currently Fastly does not provide a way to access response headers when\n # the response is a 304 response. This is because the RFC states that only\n # a limit set of headers should be sent with a 304 response, and the rest\n # are SHOULD NOT. Since this stripping happens *prior* to vcl_deliver being\n # ran, that breaks our ability to log on 304 responses. Ideally at some\n # point Fastly offers us a way to access the \"real\" response headers even\n # for a 304 response, but for now, we are going to remove the headers that\n # allow a conditional response to be made. If at some point Fastly does\n # allow this, then we can delete this code, and also allow a 304 response\n # in the http_status_matches() check further down.\n if (!req.http.Fastly-FF\n && std.tolower(req.http.Warehouse-Host) == \"files.pythonhosted.org\"\n && req.url.path ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\") {\n unset resp.http.ETag;\n unset resp.http.Last-Modified;\n }\n\n # If we're not executing a shielding request, and the URL is one of our file\n # URLs, and it's a GET request, and the response is either a 200 or a 304\n # then we want to log an event stating that a download has taken place.\n if (!req.http.Fastly-FF\n && std.tolower(req.http.Warehouse-Host) == \"files.pythonhosted.org\"\n && req.url.path ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\"\n && req.request == \"GET\"\n && http_status_matches(resp.status, \"200\")) {\n log {\"syslog \"} req.service_id {\" linehaul :: \"} \"2@\" now \"|\" geoip.country_code \"|\" req.url.path \"|\" tls.client.protocol \"|\" tls.client.cipher \"|\" resp.http.x-amz-meta-project \"|\" resp.http.x-amz-meta-version \"|\" resp.http.x-amz-meta-package-type \"|\" req.http.user-agent;\n log {\"syslog \"} req.service_id {\" downloads :: \"} \"2@\" now \"|\" geoip.country_code \"|\" req.url.path \"|\" tls.client.protocol \"|\" tls.client.cipher \"|\" resp.http.x-amz-meta-project \"|\" resp.http.x-amz-meta-version \"|\" resp.http.x-amz-meta-package-type \"|\" req.http.user-agent;\n }\n\n # Set X-Robots-Header for everything _but_ prod\n if (std.tolower(req.http.host) !~ \"^pypi.org$\") {\n set resp.http.X-Robots-Header = \"noindex\";\n }\n\n # Unset a few headers set by Amazon that we don't really have a need\/desire\n # to send to clients.\n unset resp.http.x-amz-replication-status;\n unset resp.http.x-amz-meta-python-version;\n unset resp.http.x-amz-meta-version;\n unset resp.http.x-amz-meta-package-type;\n unset resp.http.x-amz-meta-project;\n\n\n return(deliver);\n}\n\n\nsub vcl_error {\n#FASTLY error\n\n # If we have a 5xx error and there is a stale object available, then we\n # will deliver that stale object.\n if (obj.status >= 500 && obj.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n if (obj.status == 803) {\n set obj.status = 403;\n set obj.response = \"SSL is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic {\"SSL is required.\"};\n return (deliver);\n } else if(obj.status == 804) {\n set obj.status = 403;\n set obj.response = \"TLSv1.2+ is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic req.http.Error-Message;\n return (deliver);\n } else if (obj.status == 750) {\n set obj.status = 301;\n set obj.http.Location = req.http.Location;\n set obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n synthetic {\"<html><head><title>301 Moved Permanently<\/title><\/head><body><center><h1>301 Moved Permanently<\/h1><\/center><\/body><\/html>\"};\n return(deliver);\n }\n\n}\n","old_contents":"# Note: This is *ONLY* used for test.pypi.org, for the pypi.org, see python\/pypi-infra\n\n# Note: It is VERY important to ensure that any changes to VCL will work\n# properly with both the current version of ``master`` and the version in\n# the pull request that adds any new changes. This is because the\n# configuration will be applied automatically as part of the deployment\n# process, but while the previous version of the code is still up and\n# running. Thus backwards incompatible changes must be broken up over\n# multiple pull requests in order to phase them in over multiple deploys.\n\nsub vcl_recv {\n\n # Fastly is dropping support for TLSv1.0 and TLSv1.1, in preperation for\n # for that, we're going to block support for it now, using VCL. This will\n # let us present a better error message in the interim before Fastly shuts\n # off TLSv1.0 and TLSv1.1 support completely.\n if (tls.client.protocol ~ \"^TLSv1(\\.(0|1))?$\") {\n set req.http.Error-Message = \"Support for \" tls.client.protocol \" has been removed, please upgrade to a TLSv1.2+ client. Please see https:\/\/pyfound.blogspot.com\/2017\/01\/time-to-upgrade-your-python-tls-v12.html\";\n error 804 \"Bad SSL Version\";\n }\n\n # I'm not 100% sure on what this is exactly for, it was taken from the\n # Fastly documentation, however, what I *believe* it does is just ensure\n # that we don't serve a stale copy of the page from the shield node when\n # an edge node is requesting content.\n if (req.http.Fastly-FF) {\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Some (Older) clients will send a hash fragment as part of the URL even\n # though that is a local only modification. This breaks this badly for the\n # files in S3, and in general it's just not needed.\n set req.url = regsub(req.url, \"#.*$\", \"\");\n\n # Fastly does some normalization of the Accept-Encoding header so that it\n # reduces the number of cached copies (when served with the common,\n # Vary: Accept-Encoding) that are cached for any one URL. This makes a lot\n # of sense, except for the fact that we want to enable brotli compression\n # for our static files. Thus we need to work around the normalized encoding\n # in a way that still minimizes cached copies, but which will allow our\n # static files to be served using brotli.\n if (req.url ~ \"^\/static\/\" && req.http.Fastly-Orig-Accept-Encoding) {\n if (req.http.User-Agent ~ \"MSIE 6\") {\n # For that 0.3% of stubborn users out there\n unset req.http.Accept-Encoding;\n } elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"br\") {\n set req.http.Accept-Encoding = \"br\";\n } elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n\n # Most of the URLs in Warehouse do not support or require any sort of query\n # parameter. If we strip these at the edge then we'll increase our cache\n # efficiency when they won't otherwise change the output of the pages.\n #\n # This will match any URL except those that start with:\n #\n # * \/admin\/\n # * \/search\/\n # * \/account\/login\/\n # * \/account\/logout\/\n # * \/account\/register\/\n # * \/account\/reset-password\/\n # * \/account\/verify-email\/\n # * \/pypi\n if (req.url.path !~ \"^\/(admin\/|search(\/|$)|account\/(login|logout|register|reset-password|verify-email)\/|pypi)\") {\n set req.url = req.url.path;\n }\n\n # Sort all of our query parameters, this will ensure that the same query\n # parameters in a different order will end up being represented as the same\n # thing, reducing cache misses due to ordering differences.\n set req.url = boltsort.sort(req.url);\n\n # We have a number of items that we'll pass back to the origin.\n # Set a header to tell the backend if we're using https or http.\n if (req.http.Fastly-SSL) {\n set req.http.Warehouse-Proto = \"https\";\n } else {\n set req.http.Warehouse-Proto = \"http\";\n }\n # Pass the client IP address back to the backend.\n if (req.http.Fastly-Client-IP) {\n set req.http.Warehouse-IP = req.http.Fastly-Client-IP;\n }\n # Pass the real host value back to the backend.\n if (req.http.Host) {\n set req.http.Warehouse-Host = req.http.host;\n }\n\n # Currently Fastly does not provide a way to access response headers when\n # the response is a 304 response. This is because the RFC states that only\n # a limit set of headers should be sent with a 304 response, and the rest\n # are SHOULD NOT. Since this stripping happens *prior* to vcl_deliver being\n # ran, that breaks our ability to log on 304 responses. Ideally at some\n # point Fastly offers us a way to access the \"real\" response headers even\n # for a 304 response, but for now, we are going to remove the headers that\n # allow a conditional response to be made. If at some point Fastly does\n # allow this, then we can delete this code.\n if (!req.http.Fastly-FF\n && std.tolower(req.http.Warehouse-Host) == \"files.pythonhosted.org\"\n && req.url.path ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\") {\n unset req.http.If-None-Match;\n unset req.http.If-Modified-Since;\n }\n\n\n#FASTLY recv\n\n\n # We want to Force SSL for the WebUI by redirecting to the HTTPS version of\n # the page, however for API calls we want to return an error code directing\n # people to instead use HTTPS.\n if (!req.http.Fastly-SSL) {\n\n # The \/simple\/ and \/packages\/ API.\n if (req.url ~ \"^\/(simple|packages)\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy JSON API.\n if (req.url ~ \"^\/pypi\/.+\/json$\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy ?:action= API.\n if (req.url ~ \"^\/pypi.*(\\?|&)=:action\") {\n error 803 \"SSL is required\";\n }\n\n # If we're on the \/pypi page and we've received something other than a\n # GET or HEAD request, then we have no way to determine if a particular\n # request is an API call or not because it'll be in the request body\n # and that isn't available to us here. So in those cases, we won't\n # do a redirect.\n if (req.url ~ \"^\/pypi\") {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n error 801 \"Force SSL\";\n }\n }\n else {\n # This isn't a \/pypi URL so we'll just unconditionally redirect to\n # HTTPS.\n error 801 \"Force SSL\";\n }\n }\n\n # Redirect pypi.io, www.pypi.io, and warehouse.python.org to pypi.org, this\n # is purposely done *after* the HTTPS checks.\n if (std.tolower(req.http.host) ~ \"^(www.pypi.org|(www.)?pypi.io|warehouse.python.org)$\") {\n set req.http.Location = \"https:\/\/pypi.org\" req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n # Redirect warehouse-staging.python.org to test.pypi.io.\n if (std.tolower(req.http.host) ~ \"^(test.pypi.io|warehouse-staging.python.org)$\") {\n set req.http.Location = \"https:\/\/test.pypi.org\" req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n\n # Requests to \/packages\/ get dispatched to Amazon instead of to our typical\n # Origin. This requires a a bit of setup to make it work.\n if (req.http.host ~ \"^(test-)?files.pythonhosted.org$\"\n && req.url ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\") {\n # Setup our environment to better match what S3 expects\/needs\n set req.http.Host = req.http.AWS-Bucket-Name \".s3.amazonaws.com\";\n set req.http.Date = now;\n set req.url = regsuball(req.url, \"\\+\", urlencode(\"+\"));\n\n # Compute the Authorization header that S3 requires to be able to\n # access the files stored there.\n set req.http.Authorization = \"AWS \" req.http.AWS-Access-Key-ID \":\" digest.hmac_sha1_base64(req.http.AWS-Secret-Access-Key, \"GET\" LF LF LF req.http.Date LF \"\/\" req.http.AWS-Bucket-Name req.url.path);\n\n # We don't want to send our Warehouse-Token to S3, so we'll go ahead\n # and remove it.\n unset req.http.Warehouse-Token;\n }\n\n # We no longer need any of these variables, which would exist only to\n # shuffle configuration from the Fastly UI into our VCL.\n unset req.http.AWS-Access-Key-ID;\n unset req.http.AWS-Secret-Access-Key;\n unset req.http.AWS-Bucket-Name;\n\n # On a POST, we want to skip the shielding and hit backends directly.\n if (req.request == \"POST\") {\n set req.backend = F_Heroku;\n }\n\n # Do not bother to attempt to run the caching mechanisms for methods that\n # are not generally safe to cache.\n if (req.request != \"HEAD\" &&\n req.request != \"GET\" &&\n req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n # We don't ever want to cache our health URL. Outside systems should be\n # able to use it to reach past Fastly and get an end to end health check.\n if (req.url == \"\/_health\/\") {\n return(pass);\n }\n\n # We never want to cache our admin URLs, while this should be \"safe\" due to\n # the architecure of Warehouse, it'll just be easier to debug issues if\n # these always are uncached.\n if (req.url ~ \"^\/admin\/\") {\n return(pass);\n }\n\n # Finally, return the default lookup action.\n return(lookup);\n}\n\n\nsub vcl_fetch {\n\n # These are newer kinds of redirects which should be able to be cached by\n # default, even though Fastly doesn't currently have them in their default\n # list of cacheable status codes.\n if (http_status_matches(beresp.status, \"303,307,308\")) {\n set beresp.cacheable = true;\n }\n\n # For any 5xx status code we want to see if a stale object exists for it,\n # if so we'll go ahead and serve it.\n if (beresp.status >= 500 && beresp.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n\n#FASTLY fetch\n\n\n # Trigger a \"SSL is required\" error if the backend has indicated to do so.\n if (beresp.http.X-Fastly-Error == \"803\") {\n error 803 \"SSL is required\";\n }\n\n # If we've gotten a 502 or a 503 from the backend, we'll go ahead and retry\n # the request.\n if ((beresp.status == 502 || beresp.status == 503) &&\n req.restarts < 1 &&\n (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n # If we've restarted, then we'll record the number of restarts.\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n # If there is a Set-Cookie header, we'll ensure that we do not cache the\n # response.\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n # If the response has the private Cache-Control directive then we won't\n # cache it.\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # If we've gotten an error after the restarts we'll deliver the response\n # with a very short cache time.\n if (http_status_matches(beresp.status, \"500,502,503\")) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n # Apply a default TTL if there isn't a max-age or s-maxage.\n if (beresp.http.Expires ||\n beresp.http.Surrogate-Control ~ \"max-age\" ||\n beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # Keep the ttl here\n }\n else {\n # Apply the default ttl\n set beresp.ttl = 60s;\n }\n\n # Actually deliver the fetched response.\n return(deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n # If the object we have isn't cacheable, then just serve it directly\n # without going through any of the caching mechanisms.\n if (!obj.cacheable) {\n return(pass);\n }\n\n return(deliver);\n}\n\n\nsub vcl_deliver {\n # If this is an error and we have a stale response available, restart so\n # that we can pick it up and serve it.\n if (resp.status >= 500 && resp.status < 600) {\n if (stale.exists) {\n restart;\n }\n }\n\n#FASTLY deliver\n\n # Unset headers that we don't need\/want to send on to the client because\n # they are not generally useful.\n unset resp.http.Via;\n\n # Set our standard security headers, we do this in VCL rather than in\n # Warehouse itself so that we always get these headers, regardless of the\n # origin server being used.\n set resp.http.Strict-Transport-Security = \"max-age=31536000; includeSubDomains; preload\";\n set resp.http.X-Frame-Options = \"deny\";\n set resp.http.X-XSS-Protection = \"1; mode=block\";\n set resp.http.X-Content-Type-Options = \"nosniff\";\n set resp.http.X-Permitted-Cross-Domain-Policies = \"none\";\n\n # Currently Fastly does not provide a way to access response headers when\n # the response is a 304 response. This is because the RFC states that only\n # a limit set of headers should be sent with a 304 response, and the rest\n # are SHOULD NOT. Since this stripping happens *prior* to vcl_deliver being\n # ran, that breaks our ability to log on 304 responses. Ideally at some\n # point Fastly offers us a way to access the \"real\" response headers even\n # for a 304 response, but for now, we are going to remove the headers that\n # allow a conditional response to be made. If at some point Fastly does\n # allow this, then we can delete this code, and also allow a 304 response\n # in the http_status_matches() check further down.\n if (!req.http.Fastly-FF\n && std.tolower(req.http.Warehouse-Host) == \"files.pythonhosted.org\"\n && req.url.path ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\") {\n unset resp.http.ETag;\n unset resp.http.Last-Modified;\n }\n\n # If we're not executing a shielding request, and the URL is one of our file\n # URLs, and it's a GET request, and the response is either a 200 or a 304\n # then we want to log an event stating that a download has taken place.\n if (!req.http.Fastly-FF\n && std.tolower(req.http.Warehouse-Host) == \"files.pythonhosted.org\"\n && req.url.path ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\"\n && req.request == \"GET\"\n && http_status_matches(resp.status, \"200\")) {\n log {\"syslog \"} req.service_id {\" linehaul :: \"} \"2@\" now \"|\" geoip.country_code \"|\" req.url.path \"|\" tls.client.protocol \"|\" tls.client.cipher \"|\" resp.http.x-amz-meta-project \"|\" resp.http.x-amz-meta-version \"|\" resp.http.x-amz-meta-package-type \"|\" req.http.user-agent;\n log {\"syslog \"} req.service_id {\" downloads :: \"} \"2@\" now \"|\" geoip.country_code \"|\" req.url.path \"|\" tls.client.protocol \"|\" tls.client.cipher \"|\" resp.http.x-amz-meta-project \"|\" resp.http.x-amz-meta-version \"|\" resp.http.x-amz-meta-package-type \"|\" req.http.user-agent;\n }\n\n # Set X-Robots-Header for everything _but_ prod\n if (std.tolower(req.http.host) !~ \"^pypi.org$\") {\n set resp.http.X-Robots-Header = \"noindex\";\n }\n\n # Unset a few headers set by Amazon that we don't really have a need\/desire\n # to send to clients.\n unset resp.http.x-amz-replication-status;\n unset resp.http.x-amz-meta-python-version;\n unset resp.http.x-amz-meta-version;\n unset resp.http.x-amz-meta-package-type;\n unset resp.http.x-amz-meta-project;\n\n\n return(deliver);\n}\n\n\nsub vcl_error {\n#FASTLY error\n\n # If we have a 5xx error and there is a stale object available, then we\n # will deliver that stale object.\n if (obj.status >= 500 && obj.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n if (obj.status == 803) {\n set obj.status = 403;\n set obj.response = \"SSL is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic {\"SSL is required.\"};\n return (deliver);\n } else if(obj.status == 804) {\n set obj.status = 403;\n set obj.response = \"TLSv1.2+ is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic req.http.Error-Message;\n return (deliver);\n } else if (obj.status == 750) {\n set obj.status = 301;\n set obj.http.Location = req.http.Location;\n set obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n synthetic {\"<html><head><title>301 Moved Permanently<\/title><\/head><body><center><h1>301 Moved Permanently<\/h1><\/center><\/body><\/html>\"};\n return(deliver);\n }\n\n}\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"2ce673e93ae65fa8bb0e0ddf344a7a863adad081","subject":"Use Cookie accessors instead of regex to extract cookie values","message":"Use Cookie accessors instead of regex to extract cookie values\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/fastly.vcl","new_file":"etc\/fastly.vcl","new_contents":"###############################################################################\n#\n# Fastly CDN for Magento 2\n#\n# NOTICE OF LICENSE\n#\n# This source file is subject to the Fastly CDN for Magento 2 End User License\n# Agreement that is bundled with this package in the file LICENSE_FASTLY_CDN.txt.\n#\n# @copyright Copyright (c) 2016 Fastly, Inc. (http:\/\/www.fastly.com)\n# @license BSD, see LICENSE_FASTLY_CDN.txt\n#\n###############################################################################\n\n# This is a basic VCL configuration file for Fastly CDN for Magento 2 module.\n\nsub vcl_recv {\n#FASTLY recv\n\n if (req.url ~ \"^\/static\/version(\\d*\/)?(.*)$\") {\n set req.url = \"\/static\/\" + re.group.2 + \"?\" + re.group.1;\n } \n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n set req.http.X-Sig = regsub(req.http.X-Purge-Token, \"^[^_]+_(.*)\", \"\\1\");\n set req.http.X-Exp = regsub(req.http.X-Purge-Token, \"^([^_]+)_.*\", \"\\1\");\n\n # validate signature\n if (req.http.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path req.http.X-Exp), \"^0x\", \"\")) {\n\n # use vcl time math to check expiration timestamp\n set req.http.X-Original-Grace = req.grace;\n set req.grace = std.atoi(strftime({\"%s\"}, now));\n set req.grace -= std.atoi(req.http.X-Exp);\n\n if (std.atoi(req.grace) > 0) {\n error 410;\n }\n\n # clean up grace since we used it for time math\n set req.grace = std.atoi(req.http.X-Original-Grace);\n unset req.http.X-Original-Grace;\n\n } else {\n error 403;\n }\n\n # cleanup variables\n unset req.http.X-Purge-Token;\n unset req.http.X-Sig;\n unset req.http.X-Exp;\n }\n\n # Deactivate gzip\n set req.http.X-Orig-Accept-Encoding = req.http.Accept-Encoding;\n unset req.http.Accept-Encoding;\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n # disable ESI processing on Origin Shield\n if (req.http.Fastly-FF) {\n set req.esi = false;\n }\n\n # We only deal with GET and HEAD by default\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n return (pass);\n }\n\n # Bypass shopping cart and checkout requests\n if (req.url ~ \"\/checkout\") {\n return (pass);\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie ~ \"(X-Magento-Vary|form_key)=\") {\n error 200 \"\";\n } else {\n # append parameter with country code\n set req.url = req.url \"?country_code=\" geoip.country_code;\n }\n }\n\n return(lookup);\n}\n\nsub vcl_fetch {\n\n # Remove Set-Cookies from responses for static content\n # to match the cookie removal in recv.\n if (req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n }\n\n }\n\n#FASTLY fetch\n\n if (beresp.status >= 500) {\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n }\n\n if (req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Content-Type ~ \"text\/html\" || beresp.http.Content-Type ~ \"text\/xml\") {\n # enable ESI feature for Magento response by default\n esi;\n } else {\n # enable gzip for all static content\n if ((beresp.status == 200 || beresp.status == 404) && (beresp.http.content-type ~ \"^(text\\\/html|application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain|text\\\/xml)\\s*($|;)\" || req.url ~ \"\\.(css|js|html|eot|ico|otf|ttf|json)($|\\?)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.X-Orig-Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # cache only successfully responses and 404s\n if (beresp.status != 200 && beresp.status != 301 && beresp.status != 404) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\")) {\n unset beresp.http.set-cookie;\n if (req.url !~ \"^\/(pub\/)?(media|static)\/.*\") {\n set beresp.http.Pragma = \"no-cache\";\n set beresp.http.Expires = \"-1\";\n set beresp.http.Cache-Control = \"no-store, no-cache, must-revalidate, max-age=0\";\n set beresp.grace = 1m;\n }\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type\n if (beresp.http.Content-Type ~ \"image\") {\n set beresp.http.Surrogate-Key = \"image\";\n } elsif (beresp.http.Content-Type ~ \"script\") {\n set beresp.http.Surrogate-Key = \"script\";\n } elsif (beresp.http.Content-Type ~ \"css\") {\n set beresp.http.Surrogate-Key = \"css\";\n }\n\n set beresp.http.X-Surrogate-Key = beresp.http.Surrogate-Key;\n return (deliver);\n }\n\n return (deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\n\nsub vcl_miss {\n#FASTLY miss\n\n return(fetch);\n}\n\nsub vcl_deliver {\n # debug info\n if (resp.http.X-Magento-Debug) {\n if (obj.hits > 0) {\n set resp.http.X-Magento-Cache-Debug = \"HIT\";\n set resp.http.X-Magento-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Magento-Cache-Debug = \"MISS\";\n }\n } else {\n # remove Varnish\/proxy header\n remove resp.http.Age;\n remove resp.http.X-Magento-Debug;\n remove resp.http.X-Magento-Tags;\n remove resp.http.X-Surrogate-Key;\n remove resp.http.X-Magento-Cache-Control;\n remove resp.http.X-Powered-By;\n remove resp.http.Server;\n remove resp.http.X-Varnish;\n remove resp.http.Via;\n remove resp.http.Link;\n remove resp.http.X-Purge-URL;\n remove resp.http.X-Purge-Host;\n }\n\n#FASTLY deliver\n\n return (deliver);\n}\n\n\nsub vcl_error {\n # workaround for possible security issue\n if (req.url ~ \"^\\s\") {\n set obj.status = 400;\n set obj.response = \"Malformed request\";\n synthetic \"\";\n return (deliver);\n }\n\n # error 200\n if (obj.status == 200) {\n return (deliver);\n }\n\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} obj.status \" \" obj.response {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} obj.status \" \" obj.response {\"<\/h1>\n <p>\"} obj.response {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} req.xid {\"<\/p>\n <hr>\n <p>Fastly CDN server<\/p>\n <\/body>\n<\/html>\n\"};\n\n#FASTLY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n\nsub vcl_hash {\n set req.hash += req.http.Https;\n set req.hash += req.http.host;\n set req.hash += req.url;\n\n if (req.http.cookie:X-Magento-Vary ) {\n set req.hash += req.http.cookie:X-Magento-Vary;\n }\n \n set req.hash += \"#####GENERATION#####\";\n\n ### {{ design_exceptions_code }} ###\n\n return (hash);\n}\n\n","old_contents":"###############################################################################\n#\n# Fastly CDN for Magento 2\n#\n# NOTICE OF LICENSE\n#\n# This source file is subject to the Fastly CDN for Magento 2 End User License\n# Agreement that is bundled with this package in the file LICENSE_FASTLY_CDN.txt.\n#\n# @copyright Copyright (c) 2016 Fastly, Inc. (http:\/\/www.fastly.com)\n# @license BSD, see LICENSE_FASTLY_CDN.txt\n#\n###############################################################################\n\n# This is a basic VCL configuration file for Fastly CDN for Magento 2 module.\n\nsub vcl_recv {\n#FASTLY recv\n\n if (req.url ~ \"^\/static\/version(\\d*\/)?(.*)$\") {\n set req.url = \"\/static\/\" + re.group.2 + \"?\" + re.group.1;\n } \n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n set req.http.X-Sig = regsub(req.http.X-Purge-Token, \"^[^_]+_(.*)\", \"\\1\");\n set req.http.X-Exp = regsub(req.http.X-Purge-Token, \"^([^_]+)_.*\", \"\\1\");\n\n # validate signature\n if (req.http.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path req.http.X-Exp), \"^0x\", \"\")) {\n\n # use vcl time math to check expiration timestamp\n set req.http.X-Original-Grace = req.grace;\n set req.grace = std.atoi(strftime({\"%s\"}, now));\n set req.grace -= std.atoi(req.http.X-Exp);\n\n if (std.atoi(req.grace) > 0) {\n error 410;\n }\n\n # clean up grace since we used it for time math\n set req.grace = std.atoi(req.http.X-Original-Grace);\n unset req.http.X-Original-Grace;\n\n } else {\n error 403;\n }\n\n # cleanup variables\n unset req.http.X-Purge-Token;\n unset req.http.X-Sig;\n unset req.http.X-Exp;\n }\n\n # Deactivate gzip\n set req.http.X-Orig-Accept-Encoding = req.http.Accept-Encoding;\n unset req.http.Accept-Encoding;\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n # disable ESI processing on Origin Shield\n if (req.http.Fastly-FF) {\n set req.esi = false;\n }\n\n # We only deal with GET and HEAD by default\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n return (pass);\n }\n\n # Bypass shopping cart and checkout requests\n if (req.url ~ \"\/checkout\") {\n return (pass);\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie ~ \"(X-Magento-Vary|form_key)=\") {\n error 200 \"\";\n } else {\n # append parameter with country code\n set req.url = req.url \"?country_code=\" geoip.country_code;\n }\n }\n\n return(lookup);\n}\n\nsub vcl_fetch {\n\n # Remove Set-Cookies from responses for static content\n # to match the cookie removal in recv.\n if (req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n }\n\n }\n\n#FASTLY fetch\n\n if (beresp.status >= 500) {\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n }\n\n if (req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Content-Type ~ \"text\/html\" || beresp.http.Content-Type ~ \"text\/xml\") {\n # enable ESI feature for Magento response by default\n esi;\n } else {\n # enable gzip for all static content\n if ((beresp.status == 200 || beresp.status == 404) && (beresp.http.content-type ~ \"^(text\\\/html|application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain|text\\\/xml)\\s*($|;)\" || req.url ~ \"\\.(css|js|html|eot|ico|otf|ttf|json)($|\\?)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.X-Orig-Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # cache only successfully responses and 404s\n if (beresp.status != 200 && beresp.status != 301 && beresp.status != 404) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\")) {\n unset beresp.http.set-cookie;\n if (req.url !~ \"^\/(pub\/)?(media|static)\/.*\") {\n set beresp.http.Pragma = \"no-cache\";\n set beresp.http.Expires = \"-1\";\n set beresp.http.Cache-Control = \"no-store, no-cache, must-revalidate, max-age=0\";\n set beresp.grace = 1m;\n }\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type\n if (beresp.http.Content-Type ~ \"image\") {\n set beresp.http.Surrogate-Key = \"image\";\n } elsif (beresp.http.Content-Type ~ \"script\") {\n set beresp.http.Surrogate-Key = \"script\";\n } elsif (beresp.http.Content-Type ~ \"css\") {\n set beresp.http.Surrogate-Key = \"css\";\n }\n\n set beresp.http.X-Surrogate-Key = beresp.http.Surrogate-Key;\n return (deliver);\n }\n\n return (deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\n\nsub vcl_miss {\n#FASTLY miss\n\n return(fetch);\n}\n\nsub vcl_deliver {\n # debug info\n if (resp.http.X-Magento-Debug) {\n if (obj.hits > 0) {\n set resp.http.X-Magento-Cache-Debug = \"HIT\";\n set resp.http.X-Magento-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Magento-Cache-Debug = \"MISS\";\n }\n } else {\n # remove Varnish\/proxy header\n remove resp.http.Age;\n remove resp.http.X-Magento-Debug;\n remove resp.http.X-Magento-Tags;\n remove resp.http.X-Surrogate-Key;\n remove resp.http.X-Magento-Cache-Control;\n remove resp.http.X-Powered-By;\n remove resp.http.Server;\n remove resp.http.X-Varnish;\n remove resp.http.Via;\n remove resp.http.Link;\n remove resp.http.X-Purge-URL;\n remove resp.http.X-Purge-Host;\n }\n\n#FASTLY deliver\n\n return (deliver);\n}\n\n\nsub vcl_error {\n # workaround for possible security issue\n if (req.url ~ \"^\\s\") {\n set obj.status = 400;\n set obj.response = \"Malformed request\";\n synthetic \"\";\n return (deliver);\n }\n\n # error 200\n if (obj.status == 200) {\n return (deliver);\n }\n\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} obj.status \" \" obj.response {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} obj.status \" \" obj.response {\"<\/h1>\n <p>\"} obj.response {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} req.xid {\"<\/p>\n <hr>\n <p>Fastly CDN server<\/p>\n <\/body>\n<\/html>\n\"};\n\n#FASTLY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n\nsub vcl_hash {\n set req.hash += req.http.Https;\n set req.hash += req.http.host;\n set req.hash += req.url;\n\n if (req.http.cookie ~ \"X-Magento-Vary=\") {\n set req.http.X-Magento-Vary = regsub(req.http.cookie, \"^.*?X-Magento-Vary=([^;]+);*.*$\", \"\\1\");\n set req.hash += req.http.X-Magento-Vary;\n unset req.http.X-Magento-Vary;\n }\n \n set req.hash += \"#####GENERATION#####\";\n\n ### {{ design_exceptions_code }} ###\n\n return (hash);\n}\n\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"6e696fee831ff4443b38acbb24dc763ab16f3258","subject":"Fixed VCL cookie removal logic","message":"Fixed VCL cookie removal logic\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/fastly.vcl","new_file":"etc\/fastly.vcl","new_contents":"###############################################################################\n#\n# Fastly CDN for Magento 2\n#\n# NOTICE OF LICENSE\n#\n# This source file is subject to the Fastly CDN for Magento 2 End User License\n# Agreement that is bundled with this package in the file LICENSE_FASTLY_CDN.txt.\n#\n# @copyright Copyright (c) 2016 Fastly, Inc. (http:\/\/www.fastly.com)\n# @license BSD, see LICENSE_FASTLY_CDN.txt\n#\n###############################################################################\n\n# This is a basic VCL configuration file for Fastly CDN for Magento 2 module.\n\nsub vcl_recv {\n#FASTLY recv\n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n set req.http.X-Sig = regsub(req.http.X-Purge-Token, \"^[^_]+_(.*)\", \"\\1\");\n set req.http.X-Exp = regsub(req.http.X-Purge-Token, \"^([^_]+)_.*\", \"\\1\");\n\n # validate signature\n if (req.http.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path req.http.X-Exp), \"^0x\", \"\")) {\n\n # use vcl time math to check expiration timestamp\n set req.http.X-Original-Grace = req.grace;\n set req.grace = std.atoi(strftime({\"%s\"}, now));\n set req.grace -= std.atoi(req.http.X-Exp);\n\n if (std.atoi(req.grace) > 0) {\n error 410;\n }\n\n # clean up grace since we used it for time math\n set req.grace = std.atoi(req.http.X-Original-Grace);\n unset req.http.X-Original-Grace;\n\n } else {\n error 403;\n }\n\n # cleanup variables\n unset req.http.X-Purge-Token;\n unset req.http.X-Sig;\n unset req.http.X-Exp;\n }\n\n # Deactivate gzip\n set req.http.X-Orig-Accept-Encoding = req.http.Accept-Encoding;\n unset req.http.Accept-Encoding;\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n # disable ESI processing on Origin Shield\n if (req.http.Fastly-FF) {\n set req.esi = false;\n }\n\n # We only deal with GET and HEAD by default\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n return (pass);\n }\n\n # Bypass shopping cart and checkout requests\n if (req.url ~ \"\/checkout\") {\n return (pass);\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie ~ \"(X-Magento-Vary|form_key)=\") {\n error 200 \"\";\n } else {\n # append parameter with country code\n set req.url = req.url \"?country_code=\" geoip.country_code;\n }\n }\n\n return(lookup);\n}\n\nsub vcl_fetch {\n\n if (req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset beresp.http.set-cookie;\n }\n\n#FASTLY fetch\n\n if (beresp.status >= 500) {\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n }\n\n if (req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Content-Type ~ \"text\/html\" || beresp.http.Content-Type ~ \"text\/xml\") {\n # enable ESI feature for Magento response by default\n esi;\n } else {\n # enable gzip for all static content\n if ((beresp.status == 200 || beresp.status == 404) && (beresp.http.content-type ~ \"^(text\\\/html|application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain|text\\\/xml)\\s*($|;)\" || req.url ~ \"\\.(css|js|html|eot|ico|otf|ttf|json)($|\\?)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.X-Orig-Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # cache only successfully responses and 404s\n if (beresp.status != 200 && beresp.status != 301 && beresp.status != 404) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\")) {\n unset beresp.http.set-cookie;\n if (req.url !~ \"^\/(pub\/)?(media|static)\/.*\") {\n set beresp.http.Pragma = \"no-cache\";\n set beresp.http.Expires = \"-1\";\n set beresp.http.Cache-Control = \"no-store, no-cache, must-revalidate, max-age=0\";\n set beresp.grace = 1m;\n }\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type\n if (beresp.http.Content-Type ~ \"image\") {\n set beresp.http.Surrogate-Key = \"image\";\n } elsif (beresp.http.Content-Type ~ \"script\") {\n set beresp.http.Surrogate-Key = \"script\";\n } elsif (beresp.http.Content-Type ~ \"css\") {\n set beresp.http.Surrogate-Key = \"css\";\n }\n\n set beresp.http.X-Surrogate-Key = beresp.http.Surrogate-Key;\n return (deliver);\n }\n\n return (deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\n\nsub vcl_miss {\n#FASTLY miss\n\n return(fetch);\n}\n\nsub vcl_deliver {\n # debug info\n if (resp.http.X-Magento-Debug) {\n if (obj.hits > 0) {\n set resp.http.X-Magento-Cache-Debug = \"HIT\";\n set resp.http.X-Magento-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Magento-Cache-Debug = \"MISS\";\n }\n } else {\n # remove Varnish\/proxy header\n remove resp.http.Age;\n remove resp.http.X-Magento-Debug;\n remove resp.http.X-Magento-Tags;\n remove resp.http.X-Surrogate-Key;\n remove resp.http.X-Magento-Cache-Control;\n remove resp.http.X-Powered-By;\n remove resp.http.Server;\n remove resp.http.X-Varnish;\n remove resp.http.Via;\n remove resp.http.Link;\n remove resp.http.X-Purge-URL;\n remove resp.http.X-Purge-Host;\n }\n\n#FASTLY deliver\n\n return (deliver);\n}\n\n\nsub vcl_error {\n # workaround for possible security issue\n if (req.url ~ \"^\\s\") {\n set obj.status = 400;\n set obj.response = \"Malformed request\";\n synthetic \"\";\n return (deliver);\n }\n\n # error 200\n if (obj.status == 200) {\n return (deliver);\n }\n\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} obj.status \" \" obj.response {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} obj.status \" \" obj.response {\"<\/h1>\n <p>\"} obj.response {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} req.xid {\"<\/p>\n <hr>\n <p>Fastly CDN server<\/p>\n <\/body>\n<\/html>\n\"};\n\n#FASTLY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n\nsub vcl_hash {\n set req.hash += req.http.Https;\n set req.hash += req.http.host;\n set req.hash += req.url;\n\n if (req.http.cookie ~ \"X-Magento-Vary=\") {\n set req.http.X-Magento-Vary = regsub(req.http.cookie, \"^.*?X-Magento-Vary=([^;]+);*.*$\", \"\\1\");\n set req.hash += req.http.X-Magento-Vary;\n unset req.http.X-Magento-Vary;\n }\n \n set req.hash += \"#####GENERATION#####\";\n\n ### {{ design_exceptions_code }} ###\n\n return (hash);\n}\n\n","old_contents":"###############################################################################\n#\n# Fastly CDN for Magento 2\n#\n# NOTICE OF LICENSE\n#\n# This source file is subject to the Fastly CDN for Magento 2 End User License\n# Agreement that is bundled with this package in the file LICENSE_FASTLY_CDN.txt.\n#\n# @copyright Copyright (c) 2016 Fastly, Inc. (http:\/\/www.fastly.com)\n# @license BSD, see LICENSE_FASTLY_CDN.txt\n#\n###############################################################################\n\n# This is a basic VCL configuration file for Fastly CDN for Magento 2 module.\n\nsub vcl_recv {\n#FASTLY recv\n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n set req.http.X-Sig = regsub(req.http.X-Purge-Token, \"^[^_]+_(.*)\", \"\\1\");\n set req.http.X-Exp = regsub(req.http.X-Purge-Token, \"^([^_]+)_.*\", \"\\1\");\n\n # validate signature\n if (req.http.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path req.http.X-Exp), \"^0x\", \"\")) {\n\n # use vcl time math to check expiration timestamp\n set req.http.X-Original-Grace = req.grace;\n set req.grace = std.atoi(strftime({\"%s\"}, now));\n set req.grace -= std.atoi(req.http.X-Exp);\n\n if (std.atoi(req.grace) > 0) {\n error 410;\n }\n\n # clean up grace since we used it for time math\n set req.grace = std.atoi(req.http.X-Original-Grace);\n unset req.http.X-Original-Grace;\n\n } else {\n error 403;\n }\n\n # cleanup variables\n unset req.http.X-Purge-Token;\n unset req.http.X-Sig;\n unset req.http.X-Exp;\n }\n\n # Deactivate gzip\n set req.http.X-Orig-Accept-Encoding = req.http.Accept-Encoding;\n unset req.http.Accept-Encoding;\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n # disable ESI processing on Origin Shield\n if (req.http.Fastly-FF) {\n set req.esi = false;\n }\n\n # We only deal with GET and HEAD by default\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n return (pass);\n }\n\n # Bypass shopping cart and checkout requests\n if (req.url ~ \"\/checkout\") {\n return (pass);\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie ~ \"(X-Magento-Vary|form_key)=\") {\n error 200 \"\";\n } else {\n # append parameter with country code\n set req.url = req.url \"?country_code=\" geoip.country_code;\n }\n }\n\n return(lookup);\n}\n\nsub vcl_fetch {\n#FASTLY fetch\n\n if (beresp.status >= 500) {\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n }\n\n if (req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Content-Type ~ \"text\/html\" || beresp.http.Content-Type ~ \"text\/xml\") {\n # enable ESI feature for Magento response by default\n esi;\n } else {\n # enable gzip for all static content\n if ((beresp.status == 200 || beresp.status == 404) && (beresp.http.content-type ~ \"^(text\\\/html|application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain|text\\\/xml)\\s*($|;)\" || req.url ~ \"\\.(css|js|html|eot|ico|otf|ttf|json)($|\\?)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.X-Orig-Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # cache only successfully responses and 404s\n if (beresp.status != 200 && beresp.status != 301 && beresp.status != 404) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\")) {\n unset beresp.http.set-cookie;\n if (req.url !~ \"^\/(pub\/)?(media|static)\/.*\") {\n set beresp.http.Pragma = \"no-cache\";\n set beresp.http.Expires = \"-1\";\n set beresp.http.Cache-Control = \"no-store, no-cache, must-revalidate, max-age=0\";\n set beresp.grace = 1m;\n }\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type\n if (beresp.http.Content-Type ~ \"image\") {\n set beresp.http.Surrogate-Key = \"image\";\n } elsif (beresp.http.Content-Type ~ \"script\") {\n set beresp.http.Surrogate-Key = \"script\";\n } elsif (beresp.http.Content-Type ~ \"css\") {\n set beresp.http.Surrogate-Key = \"css\";\n }\n\n set beresp.http.X-Surrogate-Key = beresp.http.Surrogate-Key;\n return (deliver);\n }\n\n return (deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\n\nsub vcl_miss {\n#FASTLY miss\n\n return(fetch);\n}\n\nsub vcl_deliver {\n # debug info\n if (resp.http.X-Magento-Debug) {\n if (obj.hits > 0) {\n set resp.http.X-Magento-Cache-Debug = \"HIT\";\n set resp.http.X-Magento-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Magento-Cache-Debug = \"MISS\";\n }\n } else {\n # remove Varnish\/proxy header\n remove resp.http.Age;\n remove resp.http.X-Magento-Debug;\n remove resp.http.X-Magento-Tags;\n remove resp.http.X-Surrogate-Key;\n remove resp.http.X-Magento-Cache-Control;\n remove resp.http.X-Powered-By;\n remove resp.http.Server;\n remove resp.http.X-Varnish;\n remove resp.http.Via;\n remove resp.http.Link;\n remove resp.http.X-Purge-URL;\n remove resp.http.X-Purge-Host;\n }\n\n#FASTLY deliver\n\n return (deliver);\n}\n\n\nsub vcl_error {\n # workaround for possible security issue\n if (req.url ~ \"^\\s\") {\n set obj.status = 400;\n set obj.response = \"Malformed request\";\n synthetic \"\";\n return (deliver);\n }\n\n # error 200\n if (obj.status == 200) {\n return (deliver);\n }\n\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} obj.status \" \" obj.response {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} obj.status \" \" obj.response {\"<\/h1>\n <p>\"} obj.response {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} req.xid {\"<\/p>\n <hr>\n <p>Fastly CDN server<\/p>\n <\/body>\n<\/html>\n\"};\n\n#FASTLY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n\nsub vcl_hash {\n set req.hash += req.http.Https;\n set req.hash += req.http.host;\n set req.hash += req.url;\n\n if (req.http.cookie ~ \"X-Magento-Vary=\") {\n set req.http.X-Magento-Vary = regsub(req.http.cookie, \"^.*?X-Magento-Vary=([^;]+);*.*$\", \"\\1\");\n set req.hash += req.http.X-Magento-Vary;\n unset req.http.X-Magento-Vary;\n }\n \n set req.hash += \"#####GENERATION#####\";\n\n ### {{ design_exceptions_code }} ###\n\n return (hash);\n}\n\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"9e410104a53e7b4abeccdeb6721a55b61403d771","subject":"Add callback to vcl exception","message":"Add callback to vcl exception\n","repos":"youprofit\/rust-ci-1,youprofit\/rust-ci-1,youprofit\/rust-ci-1,youprofit\/rust-ci-1,hansjorg\/rust-ci,hansjorg\/rust-ci","old_file":"config\/rust-ci.vcl","new_file":"config\/rust-ci.vcl","new_contents":"# Varnish VCL config for www.rust-ci.org\n\nbackend nginx {\n .host = \"127.0.0.1\";\n .port = \"8000\";\n}\n\nacl purge {\n \"localhost\";\n}\n\nsub vcl_recv {\n set req.backend = nginx;\n\n if ((req.url ~ \"\/p\/\") || (req.url ~ \"\/admin\") || (req.url ~ \"\/artifacts\") || (req.url ~ \"\/callback\")) {\n return(pass);\n }\n\n # Normalize host header (for test env)\n set req.http.Host = \"www.rust-ci.org\";\n\n # Remove cookies from request\n unset req.http.cookie;\n\n if (req.request == \"PURGE\") {\n # Ignore query string (python-varnish adds \"?\" to PURGE URLs)\n set req.url = regsub(req.url, \"\\?.*$\", \"\");\n if (!client.ip ~ purge) {\n error 405 \"Not allowed.\";\n }\n return (lookup);\n }\n}\n\nsub vcl_hit {\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged.\";\n }\n}\n\nsub vcl_miss {\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged.\";\n }\n}\n\nsub vcl_fetch {\n # Remove set-cookie from backend response\n if (!(req.url ~ \"\/p\/\") && !(req.url ~ \"\/admin\") && !(req.url ~ \"\/artifacts\") && !(req.url ~ \"\/callback\")) {\n unset beresp.http.set-cookie;\n }\n\n # Remove Expires from backend\n unset beresp.http.expires;\n\n # Set the clients TTL on this object\n if (req.url ~ \"^\/static\") {\n set beresp.http.cache-control = \"max-age=31536000\";\n } else {\n set beresp.http.cache-control = \"max-age=0\";\n }\n\n # Set how long Varnish will keep it\n set beresp.ttl = 10w;\n\n # marker for vcl_deliver to reset Age:\n set beresp.http.magicmarker = \"1\";\n}\n\nsub vcl_deliver {\n if (resp.http.magicmarker) {\n # Remove the magic marker\n unset resp.http.magicmarker;\n\n # By definition we have a fresh object\n set resp.http.age = \"0\";\n }\n\n # Set HIT\/MISS indicator\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n } \n}\n\n","old_contents":"# Varnish VCL config for www.rust-ci.org\n\nbackend nginx {\n .host = \"127.0.0.1\";\n .port = \"8000\";\n}\n\nacl purge {\n \"localhost\";\n}\n\nsub vcl_recv {\n set req.backend = nginx;\n\n if ((req.url ~ \"\/p\/\") || (req.url ~ \"\/admin\") || (req.url ~ \"\/artifacts\")) {\n return(pass);\n } \n \n # Normalize host header (for test env)\n set req.http.Host = \"www.rust-ci.org\";\n\n # Remove cookies from request\n unset req.http.cookie;\n\n if (req.request == \"PURGE\") {\n # Ignore query string (python-varnish adds \"?\" to PURGE URLs)\n set req.url = regsub(req.url, \"\\?.*$\", \"\");\n if (!client.ip ~ purge) {\n error 405 \"Not allowed.\";\n }\n return (lookup);\n }\n}\n\nsub vcl_hit {\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged.\";\n }\n}\n\nsub vcl_miss {\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged.\";\n }\n}\n\nsub vcl_fetch {\n # Remove set-cookie from backend response\n if (!(req.url ~ \"\/p\/\") && !(req.url ~ \"\/admin\") && !(req.url ~ \"\/artifacts\")) {\n unset beresp.http.set-cookie;\n }\n\n # Remove Expires from backend\n unset beresp.http.expires;\n\n # Set the clients TTL on this object\n if (req.url ~ \"^\/static\") {\n set beresp.http.cache-control = \"max-age=31536000\";\n } else {\n set beresp.http.cache-control = \"max-age=0\";\n }\n\n # Set how long Varnish will keep it\n set beresp.ttl = 10w;\n\n # marker for vcl_deliver to reset Age:\n set beresp.http.magicmarker = \"1\";\n}\n\nsub vcl_deliver {\n if (resp.http.magicmarker) {\n # Remove the magic marker\n unset resp.http.magicmarker;\n\n # By definition we have a fresh object\n set resp.http.age = \"0\";\n }\n\n # Set HIT\/MISS indicator\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n } \n}\n\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"ae7ae883f4d5d37b6873c0b6fb82de4a2ab28bc9","subject":"fix redirects","message":"fix redirects\n","repos":"JakeChampion\/polyfill-service,JakeChampion\/polyfill-service","old_file":"fastly\/vcl\/redirects.vcl","new_file":"fastly\/vcl\/redirects.vcl","new_contents":"sub vcl_recv {\n\tif (req.http.Host ~ \"polyfills.io\") {\n\t\t# Fastly recommend using the 900-999 range of status codes for custom errors within an application's VCL.\n\t\t# Do the canonicalise check before the HTTPS check to avoid a double redirect\n\t\terror 901 \"Canonicalise\";\n\t}\n\tif (!req.http.Fastly-SSL) {\n\t\t# 801 is a special error code that Fastly uses to Force HTTPS on the request\n\t\terror 801 \"Redirect to HTTPS\";\n\t}\n\tif (req.http.Orig-URL ~ \"^\/v1\") {\n\t\terror 902 \"Redirect to V2\";\n\t}\n\n\tif (req.url.path == \"\/\" || req.url.path == \"\/v2\") {\n\t\terror 908;\n\t}\n}\n\nsub vcl_error {\n # Redirect to canonical prod\/qa origins\n\tif (obj.status == 901) {\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\tset obj.http.Location = \"https:\/\/polyfill.io\" req.url;\n\t\tsynthetic {\"\"};\n\t\treturn (deliver);\n\t}\n\t# Redirect to v2\n\tif (obj.status == 902) {\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\t# Remove libVersion and gated query parameters if they exist.\n\t\tset req.url = querystring.regfilter(req.url, \"^\\b(libVersion|gated)\\b.*\");\n\t\tset obj.http.Location = if(req.url.path == \"\/v1\", \"\/v3\/\", regsub(req.url, \"^\/v1\", \"\/v2\"));\n\t\tset obj.http.Deprecation-Notice = \"API version 1 has been decommissioned - see the body of this response for more information.\";\n\t\tsynthetic {\"API version 1 has been decommissioned. Your request is being redirected to v2. The `libVersion` and `gated` query string parameters are no longer supported and if present have been removed from your request.\\n\\nA deprecation period for v1 existed between August and December 2015, during which time v1 requests were honoured but a deprecation warning was added to output.\"};\n\t\treturn (deliver);\n\t}\n\n\t# Redirect to v3\n\tif (obj.status == 908) {\n\t\tset obj.status = 301;\n\t\tset obj.http.Location = \"\/v3\/\";\n\t\treturn (deliver);\n\t}\n}\n","old_contents":"sub vcl_recv {\n\tif (req.http.Host ~ \"polyfills.io\") {\n\t\t# Fastly recommend using the 900-999 range of status codes for custom errors within an application's VCL.\n\t\t# Do the canonicalise check before the HTTPS check to avoid a double redirect\n\t\terror 901 \"Canonicalise\";\n\t}\n\tif (!req.http.Fastly-SSL) {\n\t\t# 801 is a special error code that Fastly uses to Force HTTPS on the request\n\t\terror 801 \"Redirect to HTTPS\";\n\t}\n\tif (req.http.Orig-URL ~ \"^\/v1\") {\n\t\terror 902 \"Redirect to V2\";\n\t}\n\n\tif (req.url.path == \"\/\") {\n\t\terror 908;\n\t}\n}\n\nsub vcl_error {\n # Redirect to canonical prod\/qa origins\n\tif (obj.status == 901) {\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\tset obj.http.Location = \"https:\/\/polyfill.io\" req.url;\n\t\tsynthetic {\"\"};\n\t\treturn (deliver);\n\t}\n\t# Redirect to v2\n\tif (obj.status == 902) {\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\t# Remove libVersion and gated query parameters if they exist.\n\t\tset req.url = querystring.regfilter(req.url, \"^\\b(libVersion|gated)\\b.*\");\n\t\tset obj.http.Location = if(req.url.path == \"\/v1\", \"\/v3\/\", regsub(req.url, \"^\/v1\", \"\/v2\"));\n\t\tset obj.http.Deprecation-Notice = \"API version 1 has been decommissioned - see the body of this response for more information.\";\n\t\tsynthetic {\"API version 1 has been decommissioned. Your request is being redirected to v2. The `libVersion` and `gated` query string parameters are no longer supported and if present have been removed from your request.\\n\\nA deprecation period for v1 existed between August and December 2015, during which time v1 requests were honoured but a deprecation warning was added to output.\"};\n\t\treturn (deliver);\n\t}\n\n\t# Redirect to v3\n\tif (obj.status == 908) {\n\t\tset obj.status = 301;\n\t\tset obj.http.Location = \"\/v3\/\";\n\t\treturn (deliver);\n\t}\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"81e9e1a579da7e9cab1b97764a75cfff348eff84","subject":"Reverted snippet edit","message":"Reverted snippet edit\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets_basic_auth\/recv.vcl","new_file":"etc\/vcl_snippets_basic_auth\/recv.vcl","new_contents":" # Check Basic auth against a table. \/admin URLs are not basic auth protected to avoid the possibility of people\n # locking themselves out\n if ( table.lookup(magentomodule_basic_auth, regsub(req.http.Authorization, \"^Basic \", \"\"), \"NOTFOUND\") == \"NOTFOUND\" &&\n !req.url ~ \"^\/(index\\.php\/)?admin(_.*)?\/\" &&\n !req.url ~ \"^\/pub\/static\/\" ) {\n error 971;\n }\n","old_contents":" # Check Basic auth against a table. \/admin URLs are not basic auth protected to avoid the possibility of people\n # locking themselves out\n if ( table.lookup(magentomodule_basic_auth, regsub(req.http.Authorization, \"^Basic \", \"\"), \"NOTFOUND\") == \"NOTFOUND\" &&\n !req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" &&\n !req.url ~ \"^\/pub\/static\/\" ) {\n error 971;\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"742155535ddc16b8069e8baba60cb2740be1b990","subject":"update to vcl 4.0 syntax","message":"update to vcl 4.0 syntax\n","repos":"adzerk-oss\/docker-s3-cache,adzerk-oss\/docker-s3-cache","old_file":"default.vcl","new_file":"default.vcl","new_contents":"# This is a VCL configuration file for varnish. See the vcl(7)\n# man page for details on VCL syntax and semantics.\n#\nvcl 4.0;\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\n\nsub vcl_backend_response {\n if (beresp.status == 302) {\n set beresp.status = 301;\n }\n}\n","old_contents":"# This is a VCL configuration file for varnish. See the vcl(7)\n# man page for details on VCL syntax and semantics.\n#\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\n\nsub vcl_fetch {\n if (beresp.status == 302) {\n set beresp.status = 301;\n set beresp.response = \"Moved Permanently\";\n }\n}\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"07a120ba9766e88578dd719aa14223da2af25c3b","subject":"some docs","message":"some docs\n","repos":"Fsero\/varnish-fire-and-forget,Fsero\/varnish-fire-and-forget,Fsero\/varnish-fire-and-forget","old_file":"etc\/varnish\/default.vcl","new_file":"etc\/varnish\/default.vcl","new_contents":"# This is a basic VCL configuration file for varnish. See the vcl(7)\n# man page for details on VCL syntax and semantics.\n#\n# Default backend definition. Set this to point to your content\n# server.\n#\nbackend hidden {\n .host = \"web\";\n .port = \"80\";\n .connect_timeout = \"1s\";\n}\nbackend visible {\n .host = \"54.164.7.175\";\n .port = \"80\";\n}\n#\n# Below is a commented-out copy of the default VCL logic. If you\n# redefine any of these subroutines, the built-in logic will be\n# appended to your code.\nsub vcl_recv {\n # first time we send the request to the hidden backend, we retry and then request the visible one.\n # This affects latency so we need to ensure that backend is healthy enough, for that\n # we need to set good timeouts.\n if (req.restarts == 0) {\n set req.backend = hidden;\n }else {\n set req.backend = visible;\n }\n}\n# if (req.restarts == 0) {\n# \tif (req.http.x-forwarded-for) {\n# \t set req.http.X-Forwarded-For =\n# \t\treq.http.X-Forwarded-For + \", \" + client.ip;\n# \t} else {\n# \t set req.http.X-Forwarded-For = client.ip;\n# \t}\n# }\n# if (req.request != \"GET\" &&\n# req.request != \"HEAD\" &&\n# req.request != \"PUT\" &&\n# req.request != \"POST\" &&\n# req.request != \"TRACE\" &&\n# req.request != \"OPTIONS\" &&\n# req.request != \"DELETE\") {\n# \/* Non-RFC2616 or CONNECT which is weird. *\/\n# return (pipe);\n# }\n# if (req.request != \"GET\" && req.request != \"HEAD\") {\n# \/* We only deal with GET and HEAD by default *\/\n# return (pass);\n# }\n# if (req.http.Authorization || req.http.Cookie) {\n# \/* Not cacheable by default *\/\n# return (pass);\n# }\n# return (lookup);\n# }\n#\nsub vcl_pipe {\n # when we pipe we are proxying request to clients, ensure that the requests goes to the good backend.\n # this causes that hidden backend loses requests, but is safer i think.\n if (req.backend == hidden) {\n set req.backend = visible;\n }\n}\n# # Note that only the first request to the backend will have\n# # X-Forwarded-For set. If you use X-Forwarded-For and want to\n# # have it set for all requests, make sure to have:\n# # set bereq.http.connection = \"close\";\n# # here. It is not set by default as it might break some broken web\n# # applications, like IIS with NTLM authentication.\n# return (pipe);\n# }\n#\n# sub vcl_pass {\n# return (pass);\n# }\n#\n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (hash);\n# }\n#\n# sub vcl_hit {\n# return (deliver);\n# }\n#\n# sub vcl_miss {\n# return (fetch);\n# }\n#\nsub vcl_fetch {\n # this is the key of the thing, if we just made the request to the hidden backend we discard it and then retry with the other.\n if (req.backend == hidden) {\n return (restart);\n }\n}\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Vary == \"*\") {\n# \t\t\/*\n# \t\t * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# \t\t *\/\n# \t\tset beresp.ttl = 120 s;\n# \t\treturn (hit_for_pass);\n# }\n# return (deliver);\n# }\n#\n# sub vcl_deliver {\n# return (deliver);\n# }\n#\n# sub vcl_error {\n# set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n# set obj.http.Retry-After = \"5\";\n# synthetic {\"\n# <?xml version=\"1.0\" encoding=\"utf-8\"?>\n# <!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n# \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n# <html>\n# <head>\n# <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n# <\/head>\n# <body>\n# <h1>Error \"} + obj.status + \" \" + obj.response + {\"<\/h1>\n# <p>\"} + obj.response + {\"<\/p>\n# <h3>Guru Meditation:<\/h3>\n# <p>XID: \"} + req.xid + {\"<\/p>\n# <hr>\n# <p>Varnish cache server<\/p>\n# <\/body>\n# <\/html>\n# \"};\n# return (deliver);\n# }\n#\n# sub vcl_init {\n# \treturn (ok);\n# }\n#\n# sub vcl_fini {\n# \treturn (ok);\n# }\n","old_contents":"# This is a basic VCL configuration file for varnish. See the vcl(7)\n# man page for details on VCL syntax and semantics.\n#\n# Default backend definition. Set this to point to your content\n# server.\n#\nbackend hidden {\n .host = \"web\";\n .port = \"80\";\n .connect_timeout = \"1s\";\n}\nbackend visible {\n .host = \"54.164.7.175\";\n .port = \"80\";\n}\n#\n# Below is a commented-out copy of the default VCL logic. If you\n# redefine any of these subroutines, the built-in logic will be\n# appended to your code.\nsub vcl_recv {\n if (req.restarts == 0) {\n set req.backend = hidden;\n }else {\n set req.backend = visible;\n }\n}\n# if (req.restarts == 0) {\n# \tif (req.http.x-forwarded-for) {\n# \t set req.http.X-Forwarded-For =\n# \t\treq.http.X-Forwarded-For + \", \" + client.ip;\n# \t} else {\n# \t set req.http.X-Forwarded-For = client.ip;\n# \t}\n# }\n# if (req.request != \"GET\" &&\n# req.request != \"HEAD\" &&\n# req.request != \"PUT\" &&\n# req.request != \"POST\" &&\n# req.request != \"TRACE\" &&\n# req.request != \"OPTIONS\" &&\n# req.request != \"DELETE\") {\n# \/* Non-RFC2616 or CONNECT which is weird. *\/\n# return (pipe);\n# }\n# if (req.request != \"GET\" && req.request != \"HEAD\") {\n# \/* We only deal with GET and HEAD by default *\/\n# return (pass);\n# }\n# if (req.http.Authorization || req.http.Cookie) {\n# \/* Not cacheable by default *\/\n# return (pass);\n# }\n# return (lookup);\n# }\n#\nsub vcl_pipe {\n if (req.backend == hidden) {\n set req.backend = visible;\n }\n}\n# # Note that only the first request to the backend will have\n# # X-Forwarded-For set. If you use X-Forwarded-For and want to\n# # have it set for all requests, make sure to have:\n# # set bereq.http.connection = \"close\";\n# # here. It is not set by default as it might break some broken web\n# # applications, like IIS with NTLM authentication.\n# return (pipe);\n# }\n#\n# sub vcl_pass {\n# return (pass);\n# }\n#\n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (hash);\n# }\n#\n# sub vcl_hit {\n# return (deliver);\n# }\n#\n# sub vcl_miss {\n# return (fetch);\n# }\n#\nsub vcl_fetch {\n if (req.backend == hidden) {\n return (restart);\n }\n}\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Vary == \"*\") {\n# \t\t\/*\n# \t\t * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# \t\t *\/\n# \t\tset beresp.ttl = 120 s;\n# \t\treturn (hit_for_pass);\n# }\n# return (deliver);\n# }\n#\n# sub vcl_deliver {\n# return (deliver);\n# }\n#\n# sub vcl_error {\n# set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n# set obj.http.Retry-After = \"5\";\n# synthetic {\"\n# <?xml version=\"1.0\" encoding=\"utf-8\"?>\n# <!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n# \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n# <html>\n# <head>\n# <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n# <\/head>\n# <body>\n# <h1>Error \"} + obj.status + \" \" + obj.response + {\"<\/h1>\n# <p>\"} + obj.response + {\"<\/p>\n# <h3>Guru Meditation:<\/h3>\n# <p>XID: \"} + req.xid + {\"<\/p>\n# <hr>\n# <p>Varnish cache server<\/p>\n# <\/body>\n# <\/html>\n# \"};\n# return (deliver);\n# }\n#\n# sub vcl_init {\n# \treturn (ok);\n# }\n#\n# sub vcl_fini {\n# \treturn (ok);\n# }\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"88c0c6552cc552f2559b676fb3e439065820fc48","subject":"improve BigPipe support","message":"improve BigPipe support\n","repos":"NITEMAN\/Varnish_VCL_samps-hacks,NITEMAN\/varnish-bites","old_file":"varnish4\/drupal-base.vcl","new_file":"varnish4\/drupal-base.vcl","new_contents":"\/*\n * Varnish 4 example config for Drupal 7 & 8 \/ Pressflow 6 & 7\n *\/\n\n# Original source: https:\/\/github.com\/NITEMAN\/varnish-bites\/varnish4\/drupal-base.vcl\n# Copyright (c) 2015 Pedro Gonz\u00e1lez Serrano and individual contributors.\n# MIT License\n\n# Intended to be used both in simple production environments and with\n# learning\/teaching purposes.\n# Some references may not be yet updated to VCL 4.0, we use SeeV3 then.\n\n# WARNING:\n# Note that the built-in logic will be appended to our code if no return is\n# performed before.\n# Built-in logic is included commented out right after our's for reference\n# purposes in that cases.\n# See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleDefault\n\n#######################################################################\n# Initialization: Version & imports;\n\n\/* Version statement *\/\n# Since Varnish 4.0 it's mandatory to declare VCL version on first line.\nvcl 4.0;\n\n\/* Module (VMOD) imports *\/\n# Standard module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_std.generated.html\nimport std;\n\n# Directors module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# Unused in simple configs.\n#import directors;\n\n\n#######################################################################\n# Probe, backend, ACL and subroutine definitions\n\n\/* Backend probes \/ healthchecks *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#probes\nprobe basic {\n \/* Only test that backend's IP serves content for '\/' *\/\n # This might be a too heavy probe\n # .url = \"\/\";\n\n \/* Only test that backend's IP has apache working *\/\n # Nginx would fail this probe with a default config\n .request =\n \"OPTIONS * HTTP\/1.1\"\n \"Host: *\"\n \"Connection: close\";\n\n \/* Common options *\/\n .interval = 10s;\n .timeout = 2s;\n .window = 8;\n .threshold = 6;\n}\n\n\/* Backend definitions.*\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#backend-definition\nbackend default {\n \/* Default backend on the same machine. *\/\n # WARNING: timeouts could be not big enought for certain POST requests.\n .host = \"127.0.0.1\";\n .port = \"8008\";\n .max_connections = 100;\n .connect_timeout = 60s;\n .first_byte_timeout = 60s;\n .between_bytes_timeout = 60s;\n .probe = basic;\n}\n\n\/* Access Control Lists *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#access-control-list-acl\nacl purge_ban {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use '\"localhost\";' instead\n}\nacl allowed_monitors {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n}\n# acl own_proxys {\n# \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n# }\n\n\/* Custom subroutines *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#subroutines\n#TODO# Test in Varnihs 4\n# Empty in simple configs.\n# The only restriction naming subs is that the 'vlc_' prefix is reserverd for\n# Varnish use. As a task can need several chunks of code in diferent states,\n# it's a good idea to identify what main sub will call each with a suffix.\n# \/* Example 301 client redirection removing \"www\" prefix from request *\/\n# sub perm_redirections_recv {\n# if ( req.http.host ~ \"^www.*$\" ) {\n# return (\n# synth(751, \"http:\/\/\" + regsub(req.http.host, \"^www\\.\", \"\") + req.url)\n# );\n# }\n# }\n# sub perm_redirections_synth {\n# if ( resp.status == 751 ) {\n# \/* Get new URL from the response *\/\n# set resp.http.Location = resp.reason;\n# \/* Set HTTP 301 for permanent redirect *\/\n# set resp.status = 301;\n# set resp.reason = \"Moved Permanently\";\n# return (deliver);\n# }\n# }\n\n\n#######################################################################\n# Client side\n\n# vcl_recv: Called at the beginning of a request, after the complete request\n# has been received and parsed. Its purpose is to decide whether or not to\n# serve the request, how to do it, and, if applicable, which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-recv\nsub vcl_recv {\n \/* 0th: general bypass, general return & authorization checks *\/\n # Empty in simple configs.\n # Useful for debugging we can pipe or pass the request to default backend\n # here to bypass completely Varnish.\n # return (pipe);\n # return (pass);\n # We can also return here a 200 Ok for network performance benchmarking.\n # return (synth(200, \"Ok\"));\n # Finally we can perform basic HTTP authentification here, by example.\n # SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* 1st: Check for Varnish special requests *\/\n # Custom response implementation example in order to check that Varnish is\n # working properly.\n # This is usefull for automatic monitoring with monit or when Varnish is\n # behind another proxies like HAProxy.\n if ( ( req.http.host == \"monitor.server.health\"\n || req.http.host == \"health.varnish\" )\n && client.ip ~ allowed_monitors\n && ( req.method == \"OPTIONS\" || req.method == \"GET\" )\n ) {\n return (synth(200, \"OK\"));\n }\n # Purge logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#http-purging\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if ( req.method == \"PURGE\" ) {\n if ( client.ip !~ purge_ban ) {\n return (synth(405, \"Not allowed.\"));\n }\n return (purge);\n }\n # Ban logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#bans\n if ( req.method == \"BAN\" ) {\n if ( client.ip !~ purge_ban ) {\n return (synth(405, \"Not allowed.\"));\n }\n if (req.http.Purge-Cache-Tags) {\n ban( \"obj.http.X-Host == \" + req.http.host +\n \" && obj.http.Purge-Cache-Tags ~ \" + req.http.Purge-Cache-Tags\n );\n }\n else {\n # Assumes req.url is a regex. This might be a bit too simple\n ban( \"obj.http.X-Host == \" + req.http.host +\n \" && obj.http.X-Url ~ \" + req.url\n );\n }\n return (synth(200, \"Ban added\"));\n }\n\n \/* 2nd: Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_recv;\n # Here we can also enforce SSL when Varnish run behind some SSL termination\n # point.\n\n \/* 3rd: Time for backend choice *\/\n # Empty in simple configs.\n\n \/* 4th: Prepare request for the backend *\/\n # Empty in simple configs.\n # Example remove own_proxys from X-Forwarded-For\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/whats-new\/upgrading.html#x-forwarded-for-is-now-set-before-vcl-recv\n # Varnish 4 regsub doesn't accept anything but plain regexp, so we can't use\n # client.ip to exclude the proxy ips from the request:\n # set req.http.X-Forwarded-For\n # = regsub(req.http.X-Forwarded-For, \",( )?\" + client.ip, \"\");\n # Instead, we need to add the proxy ips manually in the exclude list:\n # if ( req.restarts == 0\n # && client.ip ~ own_proxys\n # && req.http.X-Forwarded-For\n # ) {\n # set req.http.X-Forwarded-For\n # = regsub(req.http.X-Forwarded-For,\n # \"(, )?(10\\.10\\.10\\.10|10\\.11\\.11\\.11)\", \"\");\n # }\n # An alternative could be to skip all this and try to modify the header\n # manually so Varnish doesn't touch it.\n # set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \"\";\n #\n # Example normalize the host header, remove the port (in case you're testing\n # this on various TCP ports)\n # set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n \/* 5th: Bypass breakpoint 1 *\/\n # Useful for debugging we can now pipe or pass the request to backend with\n # headers setted.\n # return (pipe);\n # return (pass);\n\n \/* 6th: Decide if we should deal with a request (mostly from built-in logic) *\/\n if ( req.method == \"PRI\" ) {\n \/* We do not support SPDY or HTTP\/2.0 *\/\n return (synth(405));\n }\n if ( req.method != \"GET\"\n && req.method != \"HEAD\"\n && req.method != \"PUT\"\n && req.method != \"POST\"\n && req.method != \"TRACE\"\n && req.method != \"OPTIONS\"\n && req.method != \"DELETE\"\n ) {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if ( req.method != \"GET\"\n && req.method != \"HEAD\"\n ) {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if ( req.http.Authorization ) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n # Websocket support\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html\n if ( req.http.Upgrade ~ \"(?i)websocket\" ) {\n return (pipe);\n }\n\n \/* 7th: Access control for some URLs by ACL *\/\n # Empty in simple configs.\n # By example denial some URLs depending on client-ip, we'll need to define\n # corresponding ACL 'internal'.\n # if ( req.url ~ \"^\/(cron|install)\\.php\"\n # && client.ip !~ internal\n # ) {\n # # Have Varnish throw the error directly.\n # return (synth(403, \"Forbidden.\"));\n # # Use a custom error page that you've defined in Drupal at the path \"404\".\n # # set req.url = \"\/403\";\n # }\n\n \/* 8th: Custom exceptions *\/\n # Host exception example:\n # if ( req.http.host == \"ejemplo.exception.com\" ) {\n # return (pass);\n # }\n # Drupal exceptions, edit if we want to cache some AJAX\/AHAH request.\n # Add here filters for never cache URLs such as Payment Gateway's callbacks.\n if ( req.url ~ \"^\/status\\.php$\"\n || req.url ~ \"^\/update\\.php$\"\n || req.url ~ \"^\/ooyala\/ping$\"\n || req.url ~ \"^\/admin\/build\/features\"\n || req.url ~ \"^\/info\/.*$\"\n || req.url ~ \"^\/flag\/.*$\"\n || req.url ~ \"^.*\/ajax\/.*$\"\n || req.url ~ \"^.*\/ahah\/.*$\"\n ) {\n \/* Do not cache these paths *\/\n return (pass);\n }\n # Pipe these paths directly to backend for streaming.\n if ( req.url ~ \"^\/admin\/content\/backup_migrate\/export\"\n || req.url ~ \"^\/admin\/config\/system\/backup_migrate\"\n ) {\n return (pipe);\n }\n if ( req.url ~ \"^\/system\/files\" ) {\n return (pipe);\n }\n\n \/* 9th: Graced objets & Serve from anonymous cahe if all backends are down *\/\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n # set req.http.X-Varnish-Grace = \"none\";\n if ( ! std.healthy(req.backend_hint) ) {\n # We must do this here since cookie hashing\n unset req.http.Cookie;\n #TODO# Add sick marker\n }\n\n \/* 10th: Deal with compression and the Accept-Encoding header *\/\n # Althought Varnish 4 handles gziped content itself by default, just to be\n # sure we want to remove Accept-Encoding for some compressed formats.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html#what-does-http-gzip-support-do\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/varnishd.html?highlight=http_gzip_support\n # See (for older configs) https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleNormalizeAcceptEncoding\n if ( req.http.Accept-Encoding ) {\n if ( req.url ~ \"(?i)\\.(7z|avi|bz2|flv|gif|gz|jpe?g|mpe?g|mk[av]|mov|mp[34]|og[gm]|pdf|png|rar|swf|tar|tbz|tgz|woff2?|zip|xz)(\\?.*)?$\"\n ) {\n \/* Already compressed formats, no sense trying to compress again *\/\n unset req.http.Accept-Encoding;\n }\n }\n\n \/* 11th: Further request manipulation *\/\n # Empty in simple configs.\n # We could add here a custom header grouping User-agent families.\n # Generic URL manipulation.\n # Remove Google Analytics added parameters, useless for our backends.\n if ( req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=\" ) {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n # Strip anchors, server doesn't need it.\n if ( req.url ~ \"\\#\" ) {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n # Strip a trailing ? if it exists\n if ( req.url ~ \"\\?$\" ) {\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n # Normalize the querystring arguments\n set req.url = std.querysort(req.url);\n\n \/* 12th: Cookie removal *\/\n # Always cache the following static file types for all users.\n # Use with care if we control certain downloads depending on cookies.\n # Be carefull also if appending .htm[l] via Drupal's clean URLs.\n if ( req.url ~ \"(?i)\\.(bz2|css|eot|gif|gz|html?|ico|jpe?g|js|mp3|ogg|otf|pdf|png|rar|svg|swf|tbz|tgz|ttf|woff2?|zip)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n && req.url !~ \"\/system\/storage\/serve\"\n ) {\n unset req.http.Cookie;\n }\n # Remove all cookies that backend doesn't need to know about.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRemovingSomeCookies\n if ( req.http.Cookie ) {\n \/* Warning: Not a pretty solution *\/\n # Prefix header containing cookies with ';'\n set req.http.Cookie = \";\" + req.http.Cookie;\n # Remove any spaces after ';' in header containing cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n # Prefix cookies we want to preserve with one space:\n # 'S{1,2}ESS[a-z0-9]+' is the regular expression matching a Drupal session\n # cookie ({1,2} added for HTTPS support).\n # 'NO_CACHE' is usually set after a POST request to make sure issuing user\n # see the results of his post.\n # 'OATMEAL' & 'CHOCOLATECHIP' are special cookies used by Drupal's Bakery\n # module to provide Single Sign On.\n # Keep in mind we should add here any cookie that should reach the backend\n # such as splash avoiding cookies.\n set req.http.Cookie\n = regsuball(\n req.http.Cookie,\n \";(S{1,2}ESS[a-z0-9]+|NO_CACHE|OATMEAL|CHOCOLATECHIP)=\",\n \"; \\1=\"\n );\n # Remove from the header any single Cookie not prefixed with a space until\n # next ';' separator.\n set req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n # Remove any '; ' at the start or the end of the header.\n set req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n #If there are no remaining cookies, remove the cookie header.\n if ( req.http.Cookie == \"\" ) {\n unset req.http.Cookie;\n }\n }\n\n \/* 13th: Session cookie & special cookies bypass caching stage *\/\n # As we might want to cache some requests, hashed with its cookies, we don't\n # simply pass when some cookies remain present at this point.\n # Instead we look for request that must be passed due to the cookie header.\n if ( req.http.Cookie ~ \"SESS\"\n || req.http.Cookie ~ \"SSESS\"\n || req.http.Cookie ~ \"NO_CACHE\"\n || req.http.Cookie ~ \"OATMEAL\"\n || req.http.Cookie ~ \"CHOCOLATECHIP\"\n ) {\n return (pass);\n }\n\n \/* 14th: Announce ESI Support *\/\n # Empty in simple configs.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/esi.html\n # Note that ESI included requests inherits its parent's modified request, so\n # depending on the case you will end playing with req.esi_level to know\n # current depth.\n # Send Surrogate-Capability headers\n # See http:\/\/www.w3.org\/TR\/edge-arch\n # Note that myproxyname is an identifier that should avoid collitions\n # set req.http.Surrogate-Capability = \"myproxyname=ESI\/1.0\";\n\n \/* 15th: Bypass breakpoint 2 *\/\n # Useful for debugging we can now pipe or pass the request to backend to\n # bypass cache.\n # return (pipe);\n # return (pass);\n\n \/* 16th: Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n return (hash);\n}\n\n# vcl_pipe: Called upon entering pipe mode.\n# In this mode, the request is passed on to the backend, and any further data\n# from either client or backend is passed on unaltered until either end closes\n# the connection.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pipe\nsub vcl_pipe {\n # Websocket support\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html\n if ( req.http.upgrade ) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n}\n# sub vcl_pipe {\n# # By default Connection: close is set on all piped requests, to stop\n# # connection reuse from sending future requests directly to the\n# # (potentially) wrong backend. If you do want this to happen, you can undo\n# # it here.\n# # unset bereq.http.connection;\n# return (pipe);\n# }\n\n# vcl_pass: Called upon entering pass mode.\n# In this mode, the request is passed on to the backend, and the backend's\n# response is passed on to the client, but is not entered into the cache.\n# Subsequent requests submitted over the same client connection are handled normally.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pass\n# sub vcl_pass {\n# return (fetch);\n# }\n\n# vcl_hash: You may call hash_data() on the data you would like to add to the\n# hash.\n# Hash is used by Varnish to uniquely identify objects.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hash\nsub vcl_hash {\n \/* Hash cookie data *\/\n # As requests with same URL and host can produce diferent results when issued\n # with different cookies, we need to store items hashed with the associated\n # cookies. Note that cookies are already sanitized when we reach this point.\n if ( req.http.Cookie ) {\n \/* Include cookie in cache hash *\/\n hash_data(req.http.Cookie);\n }\n\n \/* Custom header hashing *\/\n # Empty in simple configs.\n # Example for caching differents object versions by device previously\n # detected (when static content could also vary):\n # if ( req.http.X-UA-Device ) {\n # hash_data(req.http.X-UA-Device);\n # }\n # Example for caching diferent object versions by X-Forwarded-Proto, trying\n # to be smart about what kind of request could generate diffetent responses.\n if ( req.http.X-Forwarded-Proto\n && req.url !~ \"(?i)\\.(bz2|css|eot|gif|gz|html?|ico|jpe?g|js|mp3|ogg|otf|pdf|png|rar|svg|swf|tbz|tgz|ttf|woff2?|zip)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n ) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (lookup);\n# }\n\n# vcl_purge: Called after the purge has been executed and all its variants have\n# been evited.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-purge\n# sub vcl_purge {\n# return (synth(200, \"Purged\"));\n# }\n\n# vcl_hit: Called after a cache lookup if the requested document was found in\n# the cache.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hit\nsub vcl_hit {\n if ( obj.ttl >= 0s ) {\n \/\/ A pure unadultered hit, deliver it\n return (deliver);\n }\n \/* Allow varnish to serve up stale content if it is responding slowly *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n if ( obj.ttl + 60s > 0s ) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n set req.http.X-Varnish-Grace = \"normal\";\n return (deliver);\n }\n \/* Allow varish to serve up stale content if all backends are down *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n if ( ! std.healthy(req.backend_hint)\n && obj.ttl + obj.grace > 0s\n ) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n set req.http.X-Varnish-Grace = \"extended\";\n return (deliver);\n }\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\n# vcl_miss: Called after a cache lookup if the requested document was not found\n# in the cache.\n# Its purpose is to decide whether or not to attempt to retrieve the document\n# from the backend, and which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-miss\n# sub vcl_miss {\n# return (fetch);\n# }\n\n# vcl_deliver: Called before an object is delivered to the client\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-deliver\nsub vcl_deliver {\n \/* Ban lurker friendly bans support *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#bans\n unset resp.http.X-Host;\n unset resp.http.X-Url;\n\n \/* Drupal 8 Purge's module header cleanup *\/\n # Purge's headers can become quite big, causing issues in upstream proxies, so we clean it here\n unset resp.http.Purge-Cache-Tags;\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # Add whether the object is a cache hit or miss and the number of hits for\n # the object.\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Addingaheaderindicatinghitmiss\n # In Varnish 4 the obj.hits counter behaviour has changed (see bug 1492), so\n # we use a different method: if X-Varnish contains only 1 id, we have a miss,\n # if it contains more (and therefore a space), we have a hit.\n if ( resp.http.X-Varnish ~ \" \" ) {\n set resp.http.X-Varnish-Cache = \"HIT\";\n # Since in Varnish 4 the behaviour of obj.hits changed, this might not be\n # accurate.\n # See https:\/\/www.varnish-cache.org\/trac\/ticket\/1492\n set resp.http.X-Varnish-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Varnish-Cache = \"MISS\";\n \/* Show the results of cookie sanitization *\/\n if ( req.http.Cookie ) {\n set resp.http.X-Varnish-Cookie = req.http.Cookie;\n }\n }\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n if ( req.http.X-Varnish-Grace ) {\n set resp.http.X-Varnish-Grace = req.http.X-Varnish-Grace;\n }\n\n #TODO# Add sick marker\n\n # Restart count\n if ( req.restarts > 0 ) {\n set resp.http.X-Varnish-Restarts = req.restarts;\n }\n\n # Add the Varnish server hostname\n set resp.http.X-Varnish-Server = server.hostname;\n # If we have setted a custom header with device's family detected we can show\n # it:\n # if ( req.http.X-UA-Device ) {\n # set resp.http.X-UA-Device = req.http.X-UA-Device;\n # }\n # If we have recived a custom header indicating the protocol in the request we\n # can show it:\n # if ( req.http.X-Forwarded-Proto ) {\n # set resp.http.X-Forwarded-Proto = req.http.X-Forwarded-Proto;\n # }\n\n \/* Vary header manipulation *\/\n # Empty in simple configs.\n # By example, if we are storing & serving diferent objects depending on\n # User-Agent header we must set the correct Vary header:\n # if ( resp.http.Vary ) {\n # set resp.http.Vary = resp.http.Vary + \",User-Agent\";\n # } else {\n # set resp.http.Vary = \"User-Agent\";\n # }\n\n \/* Fake headers *\/\n # Empty in simple configs\n # We can fake server headers here, by example:\n # set resp.http.Server = \"Deep thought\";\n # set resp.http.X-Powered-By = \"BOFH\";\n # Or have some fun with headers:\n # See http:\/\/www.nextthing.org\/archives\/2005\/08\/07\/fun-with-http-headers\n # See http:\/\/royal.pingdom.com\/2012\/08\/15\/fun-and-unusual-http-response-headers\/\n # set resp.http.X-Thank-You = \"for bothering to look at my HTTP headers\";\n # set resp.http.X-Answer = \"42\";\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_deliver {\n# return (deliver);\n# }\n\n# vcl_synth: Called to deliver a synthetic object. A synthetic object is\n# generated in VCL, not fetched from the backend. It is typically contructed\n# using the synthetic() function.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-synth\n\/*\n * We can come here \"invisibly\" with the following errors: 413, 417 & 503\n *\/\nsub vcl_synth {\n \/* Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_synth;\n\n \/* Try to restart request in case of failure *\/\n # Note that max_restarts defaults to 4\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if ( resp.status == 503\n && req.restarts < 4\n ) {\n return (restart);\n }\n\n \/* Set common headers for synthetic responses *\/\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n\n \/* HTTP Authentification client request *\/\n # Empty in simple configs.\n # SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* Load synthetic responses from disk *\/\n # Note that files loaded this way are never re-readed (even after a reload).\n # You should consider PROS\/CONS of doing an include instead.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_std.generated.html#func-fileread\n # Example custom 403 error page.\n # if ( resp.status == 403 ) {\n # synthetic(std.fileread(\"\/403.html\"));\n # return (deliver);\n # }\n\n \/* Error page & refresh \/ redirections *\/\n # We have plenty of choices when we have to serve an error to the client,\n # from the default error page to javascript black magic or plain redirections.\n # Adding some external statistic javascript to track failures served to\n # clients is strongly suggested.\n # We can't use external resources on synthetic content, everything must be\n # inlined.\n # If we need to include images we can embed them in base64 encoding.\n # We're using error 200 for monitoring puposes which should not be retried\n # client side.\n if ( resp.status != 200 ) {\n set resp.http.Retry-After = \"5\";\n }\n\n # Here is the default error page for Varnish 4 (not so pretty)\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n return (deliver);\n}\n\n#######################################################################\n# Backend Fetch\n\n# vcl_backend_fetch: Called before sending the backend request. In this\n# subroutine you typically alter the request before it gets to the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-fetch\n# sub vcl_backend_fetch {\n# return (fetch);\n# }\n\n# vcl_backend_response: Called after the response headers has been successfully\n# retrieved from the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-response\nsub vcl_backend_response {\n \/* Ban lurker friendly bans support *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#bans\n set beresp.http.X-Host = bereq.http.host;\n set beresp.http.X-Url = bereq.url;\n\n \/* Caching exceptions *\/\n # Varnish will cache objects with response codes:\n # 200, 203, 300, 301, 302, 307, 404 & 410.\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/VCL_Basics.html#the-initial-value-of-beresp-ttl\n # Drupal's Imagecache module can return a 307 redirection to the requested\n # url itself and, depending on Drupal's cache settings, this could lead to a\n # redirection loop being cached for a long time but also we want Varnish to\n # shield a little the backend.\n # See http:\/\/drupal.org\/node\/1248010\n # See http:\/\/drupal.org\/node\/310656\n if ( beresp.status == 307\n #TODO# verify that this work better than 'bereq.url ~ \"imagecache\"'\n && beresp.http.Location == bereq.url\n && beresp.ttl > 5s\n ) {\n set beresp.ttl = 5s;\n set beresp.http.cache-control = \"max-age=5\";\n }\n\n \/* Request retrial *\/\n if ( beresp.status == 500\n || beresp.status == 503\n ) {\n #TODO# consider not restarting POST requests as seenV3 on https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleSaintMode\n return (retry);\n }\n\n \/* Enable grace mode. Related with vcl_hit *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n set beresp.grace = 1h;\n\n \/* Strip cookies from the following static file types for all users. *\/\n # Related with our 12th stage on vcl_recv\n if ( bereq.url ~ \"(?i)\\.(bz2|css|eot|gif|gz|html?|ico|jpe?g|js|mp3|ogg|otf|pdf|png|rar|svg|swf|tbz|tgz|ttf|woff2?|zip)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n ) {\n unset beresp.http.set-cookie;\n }\n\n \/* Process ESI responses *\/\n # Empty in simple configs.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/esi.html\n # Send Surrogate-Capability headers\n # See http:\/\/www.w3.org\/TR\/edge-arch\n # Note that myproxyname is an identifier that should avoid collitions\n # Check for ESI acknowledgement and remove Surrogate-Control header\n #TODO# Add support for Surrogate-Control Targetting\n # if ( beresp.http.Surrogate-Control ~ \"ESI\/1.0\" ) {\n # unset beresp.http.Surrogate-Control;\n # set beresp.do_esi = true;\n # }\n\n \/* Gzip response *\/\n # Empty in simple configs.\n # Use Varnish to Gzip respone, if suitable, before storing it on cache.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html\n if ( ! beresp.http.Content-Encoding\n && ( beresp.http.content-type ~ \"(?i)text\"\n || beresp.http.content-type ~ \"(?i)application\/x-javascript\"\n || beresp.http.content-type ~ \"(?i)application\/javascript\"\n || beresp.http.content-type ~ \"(?i)application\/rss+xml\"\n || beresp.http.content-type ~ \"(?i)application\/xml\"\n || beresp.http.content-type ~ \"(?i)Application\/JSON\")\n ) {\n set beresp.do_gzip = true;\n }\n\n \/* Drupal 8's Big Pipe support *\/\n # Tentative support, maybe 'set beresp.ttl = 0s;' is also needed\n if ( beresp.http.Surrogate-Control ~ \"BigPipe\/1.0\" ) {\n set beresp.do_stream = true;\n # Varnish gzipping breaks streaming of the first response\n set beresp.do_gzip = false;\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # We can add the name of the backend that has processed the request:\n # set beresp.http.X-Varnish-Backend = beresp.backend.name;\n # We can use a header to tell if the object was gziped by Varnish:\n # if ( beresp.do_gzip ) {\n # set beresp.http.X-Varnish-Gzipped = \"yes\";\n # } else {\n # set beresp.http.X-Varnish-Gzipped = \"no\";\n # }\n # We can do the same to tell if Varnish is streaming it:\n # if ( beresp.do_stream ) {\n # set beresp.http.X-Varnish-Streaming = \"yes\";\n # } else {\n # set beresp.http.X-Varnish-Streaming = \"no\";\n # }\n # We can also add headers informing whether the object is cacheable or not and why:\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Varnish3.0\n if ( beresp.ttl <= 0s ) {\n \/* Varnish determined the object was not cacheable *\/\n set beresp.http.X-Varnish-Cacheable = \"NO:Not Cacheable\";\n } elsif ( bereq.http.Cookie ~ \"(SESS|SSESS|NO_CACHE|OATMEAL|CHOCOLATECHIP)\" ) {\n \/* We don't wish to cache content for logged in users or with certain cookies. *\/\n # Related with our 9th stage on vcl_recv\n set beresp.http.X-Varnish-Cacheable = \"NO:Cookies\";\n # set beresp.uncacheable = true;\n } elsif ( beresp.http.Cache-Control ~ \"private\" ) {\n \/* We are respecting the Cache-Control=private header from the backend *\/\n set beresp.http.X-Varnish-Cacheable = \"NO:Cache-Control=private\";\n # set beresp.uncacheable = true;\n } else {\n \/* Varnish determined the object was cacheable *\/\n set beresp.http.X-Varnish-Cacheable = \"YES\";\n }\n\n \/* Further header manipulation *\/\n # Empty in simple configs.\n # We can also unset some headers to prevent information disclosure and save\n # some cache space.\n # unset beresp.http.Server;\n # unset beresp.http.X-Powered-By;\n # Retry count.\n if ( bereq.retries > 0 ) {\n set beresp.http.X-Varnish-Retries = bereq.retries;\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_backend_response {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Surrogate-control ~ \"no-store\" ||\n# (!beresp.http.Surrogate-Control &&\n# beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n# beresp.http.Vary == \"*\") {\n# \/*\n# * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# *\/\n# set beresp.ttl = 120s;\n# set beresp.uncacheable = true;\n# }\n# return (deliver);\n# }\n\n# vcl_backend_error: This subroutine is called if we fail the backend fetch.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-error\nsub vcl_backend_error {\n\n \/* Try to restart request in case of failure *\/\n #TODO# Confirm max_retries default value\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if ( bereq.retries < 4 ) {\n return (retry);\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # Retry count\n if ( bereq.retries > 0 ) {\n set beresp.http.X-Varnish-Retries = bereq.retries;\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + beresp.status + \" \" + beresp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + beresp.status + \" \" + beresp.reason + {\"<\/h1>\n <p>\"} + beresp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + bereq.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this\n # point.\n return (deliver);\n}\n\n#######################################################################\n# Housekeeping\n\n# vcl_init: Called when VCL is loaded, before any requests pass through it.\n# Typically used to initialize VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-init\n# Here is where you should declare your directors now.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-backends.html#directors\n# Empty in simple configs\n# sub vcl_init {\n# return (ok);\n# }\n\n# vcl_fini: Called when VCL is discarded only after all requests have exited\n# the VCL. Typically used to clean up VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-fini\n# sub vcl_fini {\n# return (ok);\n# }\n","old_contents":"\/*\n * Varnish 4 example config for Drupal 7 & 8 \/ Pressflow 6 & 7\n *\/\n\n# Original source: https:\/\/github.com\/NITEMAN\/varnish-bites\/varnish4\/drupal-base.vcl\n# Copyright (c) 2015 Pedro Gonz\u00e1lez Serrano and individual contributors.\n# MIT License\n\n# Intended to be used both in simple production environments and with\n# learning\/teaching purposes.\n# Some references may not be yet updated to VCL 4.0, we use SeeV3 then.\n\n# WARNING:\n# Note that the built-in logic will be appended to our code if no return is\n# performed before.\n# Built-in logic is included commented out right after our's for reference\n# purposes in that cases.\n# See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleDefault\n\n#######################################################################\n# Initialization: Version & imports;\n\n\/* Version statement *\/\n# Since Varnish 4.0 it's mandatory to declare VCL version on first line.\nvcl 4.0;\n\n\/* Module (VMOD) imports *\/\n# Standard module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_std.generated.html\nimport std;\n\n# Directors module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# Unused in simple configs.\n#import directors;\n\n\n#######################################################################\n# Probe, backend, ACL and subroutine definitions\n\n\/* Backend probes \/ healthchecks *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#probes\nprobe basic {\n \/* Only test that backend's IP serves content for '\/' *\/\n # This might be a too heavy probe\n # .url = \"\/\";\n\n \/* Only test that backend's IP has apache working *\/\n # Nginx would fail this probe with a default config\n .request =\n \"OPTIONS * HTTP\/1.1\"\n \"Host: *\"\n \"Connection: close\";\n\n \/* Common options *\/\n .interval = 10s;\n .timeout = 2s;\n .window = 8;\n .threshold = 6;\n}\n\n\/* Backend definitions.*\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#backend-definition\nbackend default {\n \/* Default backend on the same machine. *\/\n # WARNING: timeouts could be not big enought for certain POST requests.\n .host = \"127.0.0.1\";\n .port = \"8008\";\n .max_connections = 100;\n .connect_timeout = 60s;\n .first_byte_timeout = 60s;\n .between_bytes_timeout = 60s;\n .probe = basic;\n}\n\n\/* Access Control Lists *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#access-control-list-acl\nacl purge_ban {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use '\"localhost\";' instead\n}\nacl allowed_monitors {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n}\n# acl own_proxys {\n# \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n# }\n\n\/* Custom subroutines *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#subroutines\n#TODO# Test in Varnihs 4\n# Empty in simple configs.\n# The only restriction naming subs is that the 'vlc_' prefix is reserverd for\n# Varnish use. As a task can need several chunks of code in diferent states,\n# it's a good idea to identify what main sub will call each with a suffix.\n# \/* Example 301 client redirection removing \"www\" prefix from request *\/\n# sub perm_redirections_recv {\n# if ( req.http.host ~ \"^www.*$\" ) {\n# return (\n# synth(751, \"http:\/\/\" + regsub(req.http.host, \"^www\\.\", \"\") + req.url)\n# );\n# }\n# }\n# sub perm_redirections_synth {\n# if ( resp.status == 751 ) {\n# \/* Get new URL from the response *\/\n# set resp.http.Location = resp.reason;\n# \/* Set HTTP 301 for permanent redirect *\/\n# set resp.status = 301;\n# set resp.reason = \"Moved Permanently\";\n# return (deliver);\n# }\n# }\n\n\n#######################################################################\n# Client side\n\n# vcl_recv: Called at the beginning of a request, after the complete request\n# has been received and parsed. Its purpose is to decide whether or not to\n# serve the request, how to do it, and, if applicable, which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-recv\nsub vcl_recv {\n \/* 0th: general bypass, general return & authorization checks *\/\n # Empty in simple configs.\n # Useful for debugging we can pipe or pass the request to default backend\n # here to bypass completely Varnish.\n # return (pipe);\n # return (pass);\n # We can also return here a 200 Ok for network performance benchmarking.\n # return (synth(200, \"Ok\"));\n # Finally we can perform basic HTTP authentification here, by example.\n # SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* 1st: Check for Varnish special requests *\/\n # Custom response implementation example in order to check that Varnish is\n # working properly.\n # This is usefull for automatic monitoring with monit or when Varnish is\n # behind another proxies like HAProxy.\n if ( ( req.http.host == \"monitor.server.health\"\n || req.http.host == \"health.varnish\" )\n && client.ip ~ allowed_monitors\n && ( req.method == \"OPTIONS\" || req.method == \"GET\" )\n ) {\n return (synth(200, \"OK\"));\n }\n # Purge logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#http-purging\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if ( req.method == \"PURGE\" ) {\n if ( client.ip !~ purge_ban ) {\n return (synth(405, \"Not allowed.\"));\n }\n return (purge);\n }\n # Ban logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#bans\n if ( req.method == \"BAN\" ) {\n if ( client.ip !~ purge_ban ) {\n return (synth(405, \"Not allowed.\"));\n }\n if (req.http.Purge-Cache-Tags) {\n ban( \"obj.http.X-Host == \" + req.http.host +\n \" && obj.http.Purge-Cache-Tags ~ \" + req.http.Purge-Cache-Tags\n );\n }\n else {\n # Assumes req.url is a regex. This might be a bit too simple\n ban( \"obj.http.X-Host == \" + req.http.host +\n \" && obj.http.X-Url ~ \" + req.url\n );\n }\n return (synth(200, \"Ban added\"));\n }\n\n \/* 2nd: Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_recv;\n # Here we can also enforce SSL when Varnish run behind some SSL termination\n # point.\n\n \/* 3rd: Time for backend choice *\/\n # Empty in simple configs.\n\n \/* 4th: Prepare request for the backend *\/\n # Empty in simple configs.\n # Example remove own_proxys from X-Forwarded-For\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/whats-new\/upgrading.html#x-forwarded-for-is-now-set-before-vcl-recv\n # Varnish 4 regsub doesn't accept anything but plain regexp, so we can't use\n # client.ip to exclude the proxy ips from the request:\n # set req.http.X-Forwarded-For\n # = regsub(req.http.X-Forwarded-For, \",( )?\" + client.ip, \"\");\n # Instead, we need to add the proxy ips manually in the exclude list:\n # if ( req.restarts == 0\n # && client.ip ~ own_proxys\n # && req.http.X-Forwarded-For\n # ) {\n # set req.http.X-Forwarded-For\n # = regsub(req.http.X-Forwarded-For,\n # \"(, )?(10\\.10\\.10\\.10|10\\.11\\.11\\.11)\", \"\");\n # }\n # An alternative could be to skip all this and try to modify the header\n # manually so Varnish doesn't touch it.\n # set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \"\";\n #\n # Example normalize the host header, remove the port (in case you're testing\n # this on various TCP ports)\n # set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n \/* 5th: Bypass breakpoint 1 *\/\n # Useful for debugging we can now pipe or pass the request to backend with\n # headers setted.\n # return (pipe);\n # return (pass);\n\n \/* 6th: Decide if we should deal with a request (mostly from built-in logic) *\/\n if ( req.method == \"PRI\" ) {\n \/* We do not support SPDY or HTTP\/2.0 *\/\n return (synth(405));\n }\n if ( req.method != \"GET\"\n && req.method != \"HEAD\"\n && req.method != \"PUT\"\n && req.method != \"POST\"\n && req.method != \"TRACE\"\n && req.method != \"OPTIONS\"\n && req.method != \"DELETE\"\n ) {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if ( req.method != \"GET\"\n && req.method != \"HEAD\"\n ) {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if ( req.http.Authorization ) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n # Websocket support\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html\n if ( req.http.Upgrade ~ \"(?i)websocket\" ) {\n return (pipe);\n }\n\n \/* 7th: Access control for some URLs by ACL *\/\n # Empty in simple configs.\n # By example denial some URLs depending on client-ip, we'll need to define\n # corresponding ACL 'internal'.\n # if ( req.url ~ \"^\/(cron|install)\\.php\"\n # && client.ip !~ internal\n # ) {\n # # Have Varnish throw the error directly.\n # return (synth(403, \"Forbidden.\"));\n # # Use a custom error page that you've defined in Drupal at the path \"404\".\n # # set req.url = \"\/403\";\n # }\n\n \/* 8th: Custom exceptions *\/\n # Host exception example:\n # if ( req.http.host == \"ejemplo.exception.com\" ) {\n # return (pass);\n # }\n # Drupal exceptions, edit if we want to cache some AJAX\/AHAH request.\n # Add here filters for never cache URLs such as Payment Gateway's callbacks.\n if ( req.url ~ \"^\/status\\.php$\"\n || req.url ~ \"^\/update\\.php$\"\n || req.url ~ \"^\/ooyala\/ping$\"\n || req.url ~ \"^\/admin\/build\/features\"\n || req.url ~ \"^\/info\/.*$\"\n || req.url ~ \"^\/flag\/.*$\"\n || req.url ~ \"^.*\/ajax\/.*$\"\n || req.url ~ \"^.*\/ahah\/.*$\"\n ) {\n \/* Do not cache these paths *\/\n return (pass);\n }\n # Pipe these paths directly to backend for streaming.\n if ( req.url ~ \"^\/admin\/content\/backup_migrate\/export\"\n || req.url ~ \"^\/admin\/config\/system\/backup_migrate\"\n ) {\n return (pipe);\n }\n if ( req.url ~ \"^\/system\/files\" ) {\n return (pipe);\n }\n\n \/* 9th: Graced objets & Serve from anonymous cahe if all backends are down *\/\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n # set req.http.X-Varnish-Grace = \"none\";\n if ( ! std.healthy(req.backend_hint) ) {\n # We must do this here since cookie hashing\n unset req.http.Cookie;\n #TODO# Add sick marker\n }\n\n \/* 10th: Deal with compression and the Accept-Encoding header *\/\n # Althought Varnish 4 handles gziped content itself by default, just to be\n # sure we want to remove Accept-Encoding for some compressed formats.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html#what-does-http-gzip-support-do\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/varnishd.html?highlight=http_gzip_support\n # See (for older configs) https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleNormalizeAcceptEncoding\n if ( req.http.Accept-Encoding ) {\n if ( req.url ~ \"(?i)\\.(7z|avi|bz2|flv|gif|gz|jpe?g|mpe?g|mk[av]|mov|mp[34]|og[gm]|pdf|png|rar|swf|tar|tbz|tgz|woff2?|zip|xz)(\\?.*)?$\"\n ) {\n \/* Already compressed formats, no sense trying to compress again *\/\n unset req.http.Accept-Encoding;\n }\n }\n\n \/* 11th: Further request manipulation *\/\n # Empty in simple configs.\n # We could add here a custom header grouping User-agent families.\n # Generic URL manipulation.\n # Remove Google Analytics added parameters, useless for our backends.\n if ( req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=\" ) {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n # Strip anchors, server doesn't need it.\n if ( req.url ~ \"\\#\" ) {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n # Strip a trailing ? if it exists\n if ( req.url ~ \"\\?$\" ) {\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n # Normalize the querystring arguments\n set req.url = std.querysort(req.url);\n\n \/* 12th: Cookie removal *\/\n # Always cache the following static file types for all users.\n # Use with care if we control certain downloads depending on cookies.\n # Be carefull also if appending .htm[l] via Drupal's clean URLs.\n if ( req.url ~ \"(?i)\\.(bz2|css|eot|gif|gz|html?|ico|jpe?g|js|mp3|ogg|otf|pdf|png|rar|svg|swf|tbz|tgz|ttf|woff2?|zip)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n && req.url !~ \"\/system\/storage\/serve\"\n ) {\n unset req.http.Cookie;\n }\n # Remove all cookies that backend doesn't need to know about.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRemovingSomeCookies\n if ( req.http.Cookie ) {\n \/* Warning: Not a pretty solution *\/\n # Prefix header containing cookies with ';'\n set req.http.Cookie = \";\" + req.http.Cookie;\n # Remove any spaces after ';' in header containing cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n # Prefix cookies we want to preserve with one space:\n # 'S{1,2}ESS[a-z0-9]+' is the regular expression matching a Drupal session\n # cookie ({1,2} added for HTTPS support).\n # 'NO_CACHE' is usually set after a POST request to make sure issuing user\n # see the results of his post.\n # 'OATMEAL' & 'CHOCOLATECHIP' are special cookies used by Drupal's Bakery\n # module to provide Single Sign On.\n # Keep in mind we should add here any cookie that should reach the backend\n # such as splash avoiding cookies.\n set req.http.Cookie\n = regsuball(\n req.http.Cookie,\n \";(S{1,2}ESS[a-z0-9]+|NO_CACHE|OATMEAL|CHOCOLATECHIP)=\",\n \"; \\1=\"\n );\n # Remove from the header any single Cookie not prefixed with a space until\n # next ';' separator.\n set req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n # Remove any '; ' at the start or the end of the header.\n set req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n #If there are no remaining cookies, remove the cookie header.\n if ( req.http.Cookie == \"\" ) {\n unset req.http.Cookie;\n }\n }\n\n \/* 13th: Session cookie & special cookies bypass caching stage *\/\n # As we might want to cache some requests, hashed with its cookies, we don't\n # simply pass when some cookies remain present at this point.\n # Instead we look for request that must be passed due to the cookie header.\n if ( req.http.Cookie ~ \"SESS\"\n || req.http.Cookie ~ \"SSESS\"\n || req.http.Cookie ~ \"NO_CACHE\"\n || req.http.Cookie ~ \"OATMEAL\"\n || req.http.Cookie ~ \"CHOCOLATECHIP\"\n ) {\n return (pass);\n }\n\n \/* 14th: Announce ESI Support *\/\n # Empty in simple configs.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/esi.html\n # Note that ESI included requests inherits its parent's modified request, so\n # depending on the case you will end playing with req.esi_level to know\n # current depth.\n # Send Surrogate-Capability headers\n # See http:\/\/www.w3.org\/TR\/edge-arch\n # Note that myproxyname is an identifier that should avoid collitions\n # set req.http.Surrogate-Capability = \"myproxyname=ESI\/1.0\";\n\n \/* 15th: Bypass breakpoint 2 *\/\n # Useful for debugging we can now pipe or pass the request to backend to\n # bypass cache.\n # return (pipe);\n # return (pass);\n\n \/* 16th: Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n return (hash);\n}\n\n# vcl_pipe: Called upon entering pipe mode.\n# In this mode, the request is passed on to the backend, and any further data\n# from either client or backend is passed on unaltered until either end closes\n# the connection.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pipe\nsub vcl_pipe {\n # Websocket support\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html\n if ( req.http.upgrade ) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n}\n# sub vcl_pipe {\n# # By default Connection: close is set on all piped requests, to stop\n# # connection reuse from sending future requests directly to the\n# # (potentially) wrong backend. If you do want this to happen, you can undo\n# # it here.\n# # unset bereq.http.connection;\n# return (pipe);\n# }\n\n# vcl_pass: Called upon entering pass mode.\n# In this mode, the request is passed on to the backend, and the backend's\n# response is passed on to the client, but is not entered into the cache.\n# Subsequent requests submitted over the same client connection are handled normally.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pass\n# sub vcl_pass {\n# return (fetch);\n# }\n\n# vcl_hash: You may call hash_data() on the data you would like to add to the\n# hash.\n# Hash is used by Varnish to uniquely identify objects.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hash\nsub vcl_hash {\n \/* Hash cookie data *\/\n # As requests with same URL and host can produce diferent results when issued\n # with different cookies, we need to store items hashed with the associated\n # cookies. Note that cookies are already sanitized when we reach this point.\n if ( req.http.Cookie ) {\n \/* Include cookie in cache hash *\/\n hash_data(req.http.Cookie);\n }\n\n \/* Custom header hashing *\/\n # Empty in simple configs.\n # Example for caching differents object versions by device previously\n # detected (when static content could also vary):\n # if ( req.http.X-UA-Device ) {\n # hash_data(req.http.X-UA-Device);\n # }\n # Example for caching diferent object versions by X-Forwarded-Proto, trying\n # to be smart about what kind of request could generate diffetent responses.\n if ( req.http.X-Forwarded-Proto\n && req.url !~ \"(?i)\\.(bz2|css|eot|gif|gz|html?|ico|jpe?g|js|mp3|ogg|otf|pdf|png|rar|svg|swf|tbz|tgz|ttf|woff2?|zip)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n ) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (lookup);\n# }\n\n# vcl_purge: Called after the purge has been executed and all its variants have\n# been evited.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-purge\n# sub vcl_purge {\n# return (synth(200, \"Purged\"));\n# }\n\n# vcl_hit: Called after a cache lookup if the requested document was found in\n# the cache.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hit\nsub vcl_hit {\n if ( obj.ttl >= 0s ) {\n \/\/ A pure unadultered hit, deliver it\n return (deliver);\n }\n \/* Allow varnish to serve up stale content if it is responding slowly *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n if ( obj.ttl + 60s > 0s ) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n set req.http.X-Varnish-Grace = \"normal\";\n return (deliver);\n }\n \/* Allow varish to serve up stale content if all backends are down *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n if ( ! std.healthy(req.backend_hint)\n && obj.ttl + obj.grace > 0s\n ) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n set req.http.X-Varnish-Grace = \"extended\";\n return (deliver);\n }\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\n# vcl_miss: Called after a cache lookup if the requested document was not found\n# in the cache.\n# Its purpose is to decide whether or not to attempt to retrieve the document\n# from the backend, and which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-miss\n# sub vcl_miss {\n# return (fetch);\n# }\n\n# vcl_deliver: Called before an object is delivered to the client\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-deliver\nsub vcl_deliver {\n \/* Ban lurker friendly bans support *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#bans\n unset resp.http.X-Host;\n unset resp.http.X-Url;\n\n \/* Drupal 8 Purge's module header cleanup *\/\n # Purge's headers can become quite big, causing issues in upstream proxies, so we clean it here\n unset resp.http.Purge-Cache-Tags;\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # Add whether the object is a cache hit or miss and the number of hits for\n # the object.\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Addingaheaderindicatinghitmiss\n # In Varnish 4 the obj.hits counter behaviour has changed (see bug 1492), so\n # we use a different method: if X-Varnish contains only 1 id, we have a miss,\n # if it contains more (and therefore a space), we have a hit.\n if ( resp.http.X-Varnish ~ \" \" ) {\n set resp.http.X-Varnish-Cache = \"HIT\";\n # Since in Varnish 4 the behaviour of obj.hits changed, this might not be\n # accurate.\n # See https:\/\/www.varnish-cache.org\/trac\/ticket\/1492\n set resp.http.X-Varnish-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Varnish-Cache = \"MISS\";\n \/* Show the results of cookie sanitization *\/\n if ( req.http.Cookie ) {\n set resp.http.X-Varnish-Cookie = req.http.Cookie;\n }\n }\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n if ( req.http.X-Varnish-Grace ) {\n set resp.http.X-Varnish-Grace = req.http.X-Varnish-Grace;\n }\n\n #TODO# Add sick marker\n\n # Restart count\n if ( req.restarts > 0 ) {\n set resp.http.X-Varnish-Restarts = req.restarts;\n }\n\n # Add the Varnish server hostname\n set resp.http.X-Varnish-Server = server.hostname;\n # If we have setted a custom header with device's family detected we can show\n # it:\n # if ( req.http.X-UA-Device ) {\n # set resp.http.X-UA-Device = req.http.X-UA-Device;\n # }\n # If we have recived a custom header indicating the protocol in the request we\n # can show it:\n # if ( req.http.X-Forwarded-Proto ) {\n # set resp.http.X-Forwarded-Proto = req.http.X-Forwarded-Proto;\n # }\n\n \/* Vary header manipulation *\/\n # Empty in simple configs.\n # By example, if we are storing & serving diferent objects depending on\n # User-Agent header we must set the correct Vary header:\n # if ( resp.http.Vary ) {\n # set resp.http.Vary = resp.http.Vary + \",User-Agent\";\n # } else {\n # set resp.http.Vary = \"User-Agent\";\n # }\n\n \/* Fake headers *\/\n # Empty in simple configs\n # We can fake server headers here, by example:\n # set resp.http.Server = \"Deep thought\";\n # set resp.http.X-Powered-By = \"BOFH\";\n # Or have some fun with headers:\n # See http:\/\/www.nextthing.org\/archives\/2005\/08\/07\/fun-with-http-headers\n # See http:\/\/royal.pingdom.com\/2012\/08\/15\/fun-and-unusual-http-response-headers\/\n # set resp.http.X-Thank-You = \"for bothering to look at my HTTP headers\";\n # set resp.http.X-Answer = \"42\";\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_deliver {\n# return (deliver);\n# }\n\n# vcl_synth: Called to deliver a synthetic object. A synthetic object is\n# generated in VCL, not fetched from the backend. It is typically contructed\n# using the synthetic() function.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-synth\n\/*\n * We can come here \"invisibly\" with the following errors: 413, 417 & 503\n *\/\nsub vcl_synth {\n \/* Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_synth;\n\n \/* Try to restart request in case of failure *\/\n # Note that max_restarts defaults to 4\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if ( resp.status == 503\n && req.restarts < 4\n ) {\n return (restart);\n }\n\n \/* Set common headers for synthetic responses *\/\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n\n \/* HTTP Authentification client request *\/\n # Empty in simple configs.\n # SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* Load synthetic responses from disk *\/\n # Note that files loaded this way are never re-readed (even after a reload).\n # You should consider PROS\/CONS of doing an include instead.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_std.generated.html#func-fileread\n # Example custom 403 error page.\n # if ( resp.status == 403 ) {\n # synthetic(std.fileread(\"\/403.html\"));\n # return (deliver);\n # }\n\n \/* Error page & refresh \/ redirections *\/\n # We have plenty of choices when we have to serve an error to the client,\n # from the default error page to javascript black magic or plain redirections.\n # Adding some external statistic javascript to track failures served to\n # clients is strongly suggested.\n # We can't use external resources on synthetic content, everything must be\n # inlined.\n # If we need to include images we can embed them in base64 encoding.\n # We're using error 200 for monitoring puposes which should not be retried\n # client side.\n if ( resp.status != 200 ) {\n set resp.http.Retry-After = \"5\";\n }\n\n # Here is the default error page for Varnish 4 (not so pretty)\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n return (deliver);\n}\n\n#######################################################################\n# Backend Fetch\n\n# vcl_backend_fetch: Called before sending the backend request. In this\n# subroutine you typically alter the request before it gets to the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-fetch\n# sub vcl_backend_fetch {\n# return (fetch);\n# }\n\n# vcl_backend_response: Called after the response headers has been successfully\n# retrieved from the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-response\nsub vcl_backend_response {\n \/* Ban lurker friendly bans support *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#bans\n set beresp.http.X-Host = bereq.http.host;\n set beresp.http.X-Url = bereq.url;\n\n \/* Caching exceptions *\/\n # Varnish will cache objects with response codes:\n # 200, 203, 300, 301, 302, 307, 404 & 410.\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/VCL_Basics.html#the-initial-value-of-beresp-ttl\n # Drupal's Imagecache module can return a 307 redirection to the requested\n # url itself and, depending on Drupal's cache settings, this could lead to a\n # redirection loop being cached for a long time but also we want Varnish to\n # shield a little the backend.\n # See http:\/\/drupal.org\/node\/1248010\n # See http:\/\/drupal.org\/node\/310656\n if ( beresp.status == 307\n #TODO# verify that this work better than 'bereq.url ~ \"imagecache\"'\n && beresp.http.Location == bereq.url\n && beresp.ttl > 5s\n ) {\n set beresp.ttl = 5s;\n set beresp.http.cache-control = \"max-age=5\";\n }\n\n \/* Request retrial *\/\n if ( beresp.status == 500\n || beresp.status == 503\n ) {\n #TODO# consider not restarting POST requests as seenV3 on https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleSaintMode\n return (retry);\n }\n\n \/* Enable grace mode. Related with vcl_hit *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n set beresp.grace = 1h;\n\n \/* Strip cookies from the following static file types for all users. *\/\n # Related with our 12th stage on vcl_recv\n if ( bereq.url ~ \"(?i)\\.(bz2|css|eot|gif|gz|html?|ico|jpe?g|js|mp3|ogg|otf|pdf|png|rar|svg|swf|tbz|tgz|ttf|woff2?|zip)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n ) {\n unset beresp.http.set-cookie;\n }\n\n \/* Process ESI responses *\/\n # Empty in simple configs.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/esi.html\n # Send Surrogate-Capability headers\n # See http:\/\/www.w3.org\/TR\/edge-arch\n # Note that myproxyname is an identifier that should avoid collitions\n # Check for ESI acknowledgement and remove Surrogate-Control header\n #TODO# Add support for Surrogate-Control Targetting\n # if ( beresp.http.Surrogate-Control ~ \"ESI\/1.0\" ) {\n # unset beresp.http.Surrogate-Control;\n # set beresp.do_esi = true;\n # }\n\n \/* Drupal 8's Big Pipe support *\/\n # Tentative support, maybe 'set beresp.ttl = 0s;' is also needed\n if ( beresp.http.Surrogate-Control ~ \"BigPipe\/1.0\" ) {\n set beresp.do_stream = true;\n }\n\n \/* Gzip response *\/\n # Empty in simple configs.\n # Use Varnish to Gzip respone, if suitable, before storing it on cache.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html\n if ( ! beresp.http.Content-Encoding\n && ( beresp.http.content-type ~ \"(?i)text\"\n || beresp.http.content-type ~ \"(?i)application\/x-javascript\"\n || beresp.http.content-type ~ \"(?i)application\/javascript\"\n || beresp.http.content-type ~ \"(?i)application\/rss+xml\"\n || beresp.http.content-type ~ \"(?i)application\/xml\"\n || beresp.http.content-type ~ \"(?i)Application\/JSON\")\n ) {\n set beresp.do_gzip = true;\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # We can add the name of the backend that has processed the request:\n # set beresp.http.X-Varnish-Backend = beresp.backend.name;\n # We can use a header to tell if the object was gziped by Varnish:\n # if ( beresp.do_gzip ) {\n # set beresp.http.X-Varnish-Gzipped = \"yes\";\n # } else {\n # set beresp.http.X-Varnish-Gzipped = \"no\";\n # }\n # We can do the same to tell if Varnish is streaming it:\n # if ( beresp.do_stream ) {\n # set beresp.http.X-Varnish-Streaming = \"yes\";\n # } else {\n # set beresp.http.X-Varnish-Streaming = \"no\";\n # }\n # We can also add headers informing whether the object is cacheable or not and why:\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Varnish3.0\n if ( beresp.ttl <= 0s ) {\n \/* Varnish determined the object was not cacheable *\/\n set beresp.http.X-Varnish-Cacheable = \"NO:Not Cacheable\";\n } elsif ( bereq.http.Cookie ~ \"(SESS|SSESS|NO_CACHE|OATMEAL|CHOCOLATECHIP)\" ) {\n \/* We don't wish to cache content for logged in users or with certain cookies. *\/\n # Related with our 9th stage on vcl_recv\n set beresp.http.X-Varnish-Cacheable = \"NO:Cookies\";\n # set beresp.uncacheable = true;\n } elsif ( beresp.http.Cache-Control ~ \"private\" ) {\n \/* We are respecting the Cache-Control=private header from the backend *\/\n set beresp.http.X-Varnish-Cacheable = \"NO:Cache-Control=private\";\n # set beresp.uncacheable = true;\n } else {\n \/* Varnish determined the object was cacheable *\/\n set beresp.http.X-Varnish-Cacheable = \"YES\";\n }\n\n \/* Further header manipulation *\/\n # Empty in simple configs.\n # We can also unset some headers to prevent information disclosure and save\n # some cache space.\n # unset beresp.http.Server;\n # unset beresp.http.X-Powered-By;\n # Retry count.\n if ( bereq.retries > 0 ) {\n set beresp.http.X-Varnish-Retries = bereq.retries;\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_backend_response {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Surrogate-control ~ \"no-store\" ||\n# (!beresp.http.Surrogate-Control &&\n# beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n# beresp.http.Vary == \"*\") {\n# \/*\n# * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# *\/\n# set beresp.ttl = 120s;\n# set beresp.uncacheable = true;\n# }\n# return (deliver);\n# }\n\n# vcl_backend_error: This subroutine is called if we fail the backend fetch.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-error\nsub vcl_backend_error {\n\n \/* Try to restart request in case of failure *\/\n #TODO# Confirm max_retries default value\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if ( bereq.retries < 4 ) {\n return (retry);\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # Retry count\n if ( bereq.retries > 0 ) {\n set beresp.http.X-Varnish-Retries = bereq.retries;\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + beresp.status + \" \" + beresp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + beresp.status + \" \" + beresp.reason + {\"<\/h1>\n <p>\"} + beresp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + bereq.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this\n # point.\n return (deliver);\n}\n\n#######################################################################\n# Housekeeping\n\n# vcl_init: Called when VCL is loaded, before any requests pass through it.\n# Typically used to initialize VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-init\n# Here is where you should declare your directors now.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-backends.html#directors\n# Empty in simple configs\n# sub vcl_init {\n# return (ok);\n# }\n\n# vcl_fini: Called when VCL is discarded only after all requests have exited\n# the VCL. Typically used to clean up VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-fini\n# sub vcl_fini {\n# return (ok);\n# }\n","returncode":0,"stderr":"","license":"unknown","lang":"VCL"} {"commit":"d04143c99318e36bac9b49a864df90ee541dc6ce","subject":"Allow sweetalert cookie","message":"Allow sweetalert cookie\n","repos":"EFForg\/action-center-platform,EFForg\/action-center-platform,EFForg\/action-center-platform,EFForg\/action-center-platform","old_file":"varnish.vcl","new_file":"varnish.vcl","new_contents":"# See https:\/\/github.com\/EFForg\/action-center-platform\/wiki\/Deployment-Notes#cache-configuration\n\nsub vcl_recv {\n#FASTLY recv\n\n if (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n if (req.http.cookie ~ \"logged_in\" && req.url !~ \"^\/assets\/\") {\n set req.hash_always_miss = true;\n return(pass);\n }\n\n if (req.http.cookie ~ \"^sweetAlert\") {\n return(pass);\n }\n\n if (req.url !~ \"^\/(ahoy)\/\") {\n unset req.http.Cookie;\n }\n\n return(lookup);\n}\n\nsub vcl_fetch {\n if (req.http.cookie !~ \"logged_in\" && beresp.http.Set-Cookie !~ \"^sweetAlert\" && req.url !~ \"^\/(login)|(register)|(confirmation\/new)|(unlock\/new)|(password\/new)|(password\/edit)|(ahoy\/)\") {\n unset beresp.http.Set-Cookie;\n }\n\n#FASTLY fetch\n\n if ((beresp.status == 500 || beresp.status == 503) && req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n if (req.restarts > 0) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return(pass);\n }\n\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return(pass);\n }\n\n if (beresp.status == 500 || beresp.status == 503) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return(deliver);\n }\n\n if (beresp.http.Expires || beresp.http.Surrogate-Control ~ \"max-age\" || beresp.http.Cache-Control ~ \"(s-maxage|max-age)\") {\n # keep the ttl here\n } else {\n # apply the default ttl\n set beresp.ttl = 3600s;\n }\n\n return(deliver);\n}\n\nsub vcl_hit {\n#FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\nsub vcl_miss {\n#FASTLY miss\n return(fetch);\n}\n\nsub vcl_deliver {\n#FASTLY deliver\n return(deliver);\n}\n\nsub vcl_error {\n#FASTLY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n\nsub vcl_log {\n#FASTLY log\n}\n","old_contents":"# See https:\/\/github.com\/EFForg\/action-center-platform\/wiki\/Deployment-Notes#cache-configuration\n\nsub vcl_recv {\n#FASTLY recv\n\n if (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n if (req.http.cookie ~ \"logged_in\" && req.url !~ \"^\/assets\/\") {\n set req.hash_always_miss = true;\n return(pass);\n }\n\n if (req.url !~ \"^\/(ahoy)\/\") {\n unset req.http.Cookie;\n }\n\n return(lookup);\n}\n\nsub vcl_fetch {\n if (req.http.cookie !~ \"logged_in\" && req.url !~ \"^\/(login)|(register)|(confirmation\/new)|(unlock\/new)|(password\/new)|(password\/edit)|(ahoy\/)\") {\n unset beresp.http.Set-Cookie;\n }\n\n#FASTLY fetch\n\n if ((beresp.status == 500 || beresp.status == 503) && req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n if (req.restarts > 0) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return(pass);\n }\n\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return(pass);\n }\n\n if (beresp.status == 500 || beresp.status == 503) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return(deliver);\n }\n\n if (beresp.http.Expires || beresp.http.Surrogate-Control ~ \"max-age\" || beresp.http.Cache-Control ~ \"(s-maxage|max-age)\") {\n # keep the ttl here\n } else {\n # apply the default ttl\n set beresp.ttl = 3600s;\n }\n\n return(deliver);\n}\n\nsub vcl_hit {\n#FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\nsub vcl_miss {\n#FASTLY miss\n return(fetch);\n}\n\nsub vcl_deliver {\n#FASTLY deliver\n return(deliver);\n}\n\nsub vcl_error {\n#FASTLY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n\nsub vcl_log {\n#FASTLY log\n}\n","returncode":0,"stderr":"","license":"agpl-3.0","lang":"VCL"} {"commit":"996aee3632f764c4e9565ebd94ecf9318852a4b5","subject":"check IO status more reliably (#465)","message":"check IO status more reliably (#465)\n\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets\/recv.vcl","new_file":"etc\/vcl_snippets\/recv.vcl","new_contents":" # When using Magento tester to test whether your site is configured properly\n # this uses a bypass secret. By default we will use service ID as the bypass secret\n # however user can override this by defining a bypass_secret key in the\n # magentomodule_config edge dictionary\n if ( req.http.bypass-secret ) {\n declare local var.bypass-secret STRING;\n set var.bypass-secret = table.lookup(magentomodule_config, \"bypass_secret\", \"NONE\");\n if ( var.bypass-secret == req.http.bypass-secret ) {\n set req.http.x-pass = \"1\";\n set var.fastly_req_do_shield = false;\n set req.hash_always_miss = true;\n } else if ( var.bypass-secret == \"NONE\" && req.http.bypass-secret == req.service_id ) {\n set req.http.x-pass = \"1\";\n set var.fastly_req_do_shield = false;\n set req.hash_always_miss = true;\n } else {\n error 403 \"Bypass Secret incorrect\";\n }\n\n if (req.url == \"\/fastly-io-tester\") {\n # IO won't work for PASS requests\n unset req.http.x-pass;\n set req.hash_always_miss = true;\n set req.http.X-Fastly-Imageopto-Api = \"fastly\";\n }\n }\n\n # VCL required to support maintenance mode. Don't maintenance mode admin pages and supporting assets\n if (table.lookup(magentomodule_config, \"allow_super_users_during_maint\", \"0\") == \"1\" &&\n !req.http.Fastly-Client-Ip ~ maint_allowlist &&\n !req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" &&\n !req.url ~ \"^\/pub\/static\/\") {\n\n # If we end up here after a restart and there is a ResponseObject it means we got here after error\n # page VCL restart. We shouldn't touch it. Otherwise return a plain 503 error page\n if ( req.restarts > 0 && req.http.ResponseObject ) {\n set req.http.ResponseObject = \"970\";\n } else {\n error 503 \"Maintenance mode\";\n }\n }\n\n # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n unset req.http.x-long-cache;\n\n # We want to force long cache times on any of the versioned assets\n if (req.url.path ~ \"^\/static\/version\\d*\/\") {\n set req.http.x-long-cache = \"1\";\n }\n\n # User's Cookie may contain some Magento Vary items we should vary on\n if (req.http.cookie:X-Magento-Vary) {\n set req.http.X-Magento-Vary = req.http.cookie:X-Magento-Vary;\n } else {\n unset req.http.X-Magento-Vary;\n }\n\n ############################################################################################################\n # Following code block controls purge by URL. By default we want to protect all URL purges. In general this\n # is addressed by adding Fastly-Purge-Requires-Auth request header in vcl_recv however this runs the risk of\n # exposing API tokens if user attempts to purge non-https URLs. For this reason inside the Magento module\n # we use X-Purge-Token. Unfortunately this breaks purge from the Fastly UI. Therefore in the next code block\n # we check for presence of X-Purge-Token. If it's not present we force the Fastly-Purge-Requires-Auth\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n if (req.http.X-Purge-Token && req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n } else {\n error 403;\n }\n } else {\n set req.http.Fastly-Purge-Requires-Auth = \"1\";\n }\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (fastly.ff.visits_this_service > 0) {\n # disable ESI processing on Origin Shield\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Make sure we lookup end user geo not shielding. More at https:\/\/docs.fastly.com\/vcl\/geolocation\/#using-geographic-variables-with-shielding\n set client.geo.ip_override = req.http.Fastly-Client-IP;\n\n if (req.request == \"GET\" && req.url.path ~ \"\/graphql\" && req.url.qs ~ \"query=\") {\n set req.http.graphql = \"1\";\n } else {\n unset req.http.graphql;\n }\n\n # geoip lookup\n if (req.url.path ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie:X-Magento-Vary || req.http.cookie:form_key) {\n error 980 \"GeoIP already processed\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url.qs !~ \"country_code=\" ) {\n set req.url = querystring.set(req.url, \"country_code\", if ( req.http.geo_override, req.http.geo_override, client.geo.country_code));\n }\n }\n } else if ( req.url.path !~ \"\/graphql\" ) {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking by default\n # and allow custom parameters to be set. List of parameters is configurable in admin\n set req.http.Magento-Original-URL = req.url;\n # Change the list of ignored parameters by configuring them in the Advanced section\n set req.url = querystring.regfilter(req.url, \"^(####QUERY_PARAMETERS####)$\");\n }\n\n # Don't allow clients to force a pass\n if (req.restarts == 0) {\n unset req.http.x-pass;\n unset req.http.Rate-Limit;\n unset req.http.magento-admin-path;\n }\n\n # Pass on checkout URLs. Because it's a snippet we want to execute this after backend selection so we handle it\n # in the request condition\n if (!req.http.x-long-cache && req.url ~ \"\/(checkout|customer\/section\/load)\") {\n set req.http.x-pass = \"1\";\n # Pass all admin actions\n # ####ADMIN_PATH#### is replaced with value of frontName from app\/etc\/env.php\n } else if ( req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" ) {\n set req.http.x-pass = \"1\";\n set req.http.magento-admin-path = \"1\";\n } else {\n # Sort the query arguments to increase cache hit ratio with query arguments that\n # may be out od order. In case you want to restore the unsorted URL add a snippet\n # after this one that sets req.url to req.http.Magento-Original-URL\n if ( !req.http.x-pass ) {\n set req.url = boltsort.sort(req.url);\n }\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.http.x-long-cache || req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n # GraphQL special headers handling because this area doesn't rely on X-Magento-Vary cookie\n if (req.http.graphql && !req.http.X-Magento-Cache-Id && req.http.Authorization ~ \"^Bearer\" ) {\n unset req.http.graphql;\n set req.http.x-pass = \"1\";\n }\n","old_contents":" # When using Magento tester to test whether your site is configured properly\n # this uses a bypass secret. By default we will use service ID as the bypass secret\n # however user can override this by defining a bypass_secret key in the\n # magentomodule_config edge dictionary\n if ( req.http.bypass-secret ) {\n declare local var.bypass-secret STRING;\n set var.bypass-secret = table.lookup(magentomodule_config, \"bypass_secret\", \"NONE\");\n if ( var.bypass-secret == req.http.bypass-secret ) {\n set req.http.x-pass = \"1\";\n set var.fastly_req_do_shield = false;\n set req.hash_always_miss = true;\n } else if ( var.bypass-secret == \"NONE\" && req.http.bypass-secret == req.service_id ) {\n set req.http.x-pass = \"1\";\n set var.fastly_req_do_shield = false;\n set req.hash_always_miss = true;\n } else {\n error 403 \"Bypass Secret incorrect\";\n }\n }\n\n # VCL required to support maintenance mode. Don't maintenance mode admin pages and supporting assets\n if (table.lookup(magentomodule_config, \"allow_super_users_during_maint\", \"0\") == \"1\" &&\n !req.http.Fastly-Client-Ip ~ maint_allowlist &&\n !req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" &&\n !req.url ~ \"^\/pub\/static\/\") {\n\n # If we end up here after a restart and there is a ResponseObject it means we got here after error\n # page VCL restart. We shouldn't touch it. Otherwise return a plain 503 error page\n if ( req.restarts > 0 && req.http.ResponseObject ) {\n set req.http.ResponseObject = \"970\";\n } else {\n error 503 \"Maintenance mode\";\n }\n }\n\n # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n unset req.http.x-long-cache;\n\n # We want to force long cache times on any of the versioned assets\n if (req.url.path ~ \"^\/static\/version\\d*\/\") {\n set req.http.x-long-cache = \"1\";\n }\n\n # User's Cookie may contain some Magento Vary items we should vary on\n if (req.http.cookie:X-Magento-Vary) {\n set req.http.X-Magento-Vary = req.http.cookie:X-Magento-Vary;\n } else {\n unset req.http.X-Magento-Vary;\n }\n\n ############################################################################################################\n # Following code block controls purge by URL. By default we want to protect all URL purges. In general this\n # is addressed by adding Fastly-Purge-Requires-Auth request header in vcl_recv however this runs the risk of\n # exposing API tokens if user attempts to purge non-https URLs. For this reason inside the Magento module\n # we use X-Purge-Token. Unfortunately this breaks purge from the Fastly UI. Therefore in the next code block\n # we check for presence of X-Purge-Token. If it's not present we force the Fastly-Purge-Requires-Auth\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n if (req.http.X-Purge-Token && req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n } else {\n error 403;\n }\n } else {\n set req.http.Fastly-Purge-Requires-Auth = \"1\";\n }\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (fastly.ff.visits_this_service > 0) {\n # disable ESI processing on Origin Shield\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Make sure we lookup end user geo not shielding. More at https:\/\/docs.fastly.com\/vcl\/geolocation\/#using-geographic-variables-with-shielding\n set client.geo.ip_override = req.http.Fastly-Client-IP;\n\n if (req.request == \"GET\" && req.url.path ~ \"\/graphql\" && req.url.qs ~ \"query=\") {\n set req.http.graphql = \"1\";\n } else {\n unset req.http.graphql;\n }\n\n # geoip lookup\n if (req.url.path ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie:X-Magento-Vary || req.http.cookie:form_key) {\n error 980 \"GeoIP already processed\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url.qs !~ \"country_code=\" ) {\n set req.url = querystring.set(req.url, \"country_code\", if ( req.http.geo_override, req.http.geo_override, client.geo.country_code));\n }\n }\n } else if ( req.url.path !~ \"\/graphql\" ) {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking by default\n # and allow custom parameters to be set. List of parameters is configurable in admin\n set req.http.Magento-Original-URL = req.url;\n # Change the list of ignored parameters by configuring them in the Advanced section\n set req.url = querystring.regfilter(req.url, \"^(####QUERY_PARAMETERS####)$\");\n }\n\n # Don't allow clients to force a pass\n if (req.restarts == 0) {\n unset req.http.x-pass;\n unset req.http.Rate-Limit;\n unset req.http.magento-admin-path;\n }\n\n # Pass on checkout URLs. Because it's a snippet we want to execute this after backend selection so we handle it\n # in the request condition\n if (!req.http.x-long-cache && req.url ~ \"\/(checkout|customer\/section\/load)\") {\n set req.http.x-pass = \"1\";\n # Pass all admin actions\n # ####ADMIN_PATH#### is replaced with value of frontName from app\/etc\/env.php\n } else if ( req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" ) {\n set req.http.x-pass = \"1\";\n set req.http.magento-admin-path = \"1\";\n } else {\n # Sort the query arguments to increase cache hit ratio with query arguments that\n # may be out od order. In case you want to restore the unsorted URL add a snippet\n # after this one that sets req.url to req.http.Magento-Original-URL\n if ( !req.http.x-pass ) {\n set req.url = boltsort.sort(req.url);\n }\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.http.x-long-cache || req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n # GraphQL special headers handling because this area doesn't rely on X-Magento-Vary cookie\n if (req.http.graphql && !req.http.X-Magento-Cache-Id && req.http.Authorization ~ \"^Bearer\" ) {\n unset req.http.graphql;\n set req.http.x-pass = \"1\";\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"6cdbc96ffe4b3acba233fc782ba23589b2440524","subject":"vcl only deal with GET\/HEAD","message":"vcl only deal with GET\/HEAD","repos":"hummer2k\/ConVarnish,hummer2k\/ConVarnish","old_file":"config\/default-4.vcl","new_file":"config\/default-4.vcl","new_contents":"vcl 4.0;\n\nimport std;\n\nbackend default {\n .host = \"localhost\";\n .port = \"8080\";\n}\n\nacl purge {\n \"localhost\";\n \"127.0.0.1\";\n}\n\nsub vcl_recv {\n # Purge\n if (req.method == \"PURGE\") {\n if (client.ip !~ purge) {\n return (synth(405, \"Method not allowed\"));\n }\n if (!req.http.X-Purge-Host) {\n return (synth(400, \"Please specify X-Purge-Host header\"));\n }\n if (req.http.X-Purge-Tags) { \n ban(\"obj.http.X-Purge-Tags ~ \" + req.http.X-Purge-Tags + \" && obj.http.X-Purge-Host ~ \" + req.http.X-Purge-Host);\n return (synth(200, \"Purged by Tags: \" + req.http.X-Purge-Tags + \", Host: \" + req.http.X-Purge-Host));\n } elsif (req.http.X-Purge-URL) {\n ban(\"obj.http.X-Purge-URL ~ \" + req.http.X-Purge-URL + \" && obj.http.X-Purge-Host ~ \" + req.http.X-Purge-Host);\n return (synth(200, \"Purged by URL: \" + req.http.X-Purge-URL + \", Host: \" + req.http.X-Purge-Host));\n }\n return (synth(400, \"Please specify X-Purge-URL or X-Purge-Tags headers\"));\n }\n\n if (\n req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\"\n ) {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n \n # tell backend support for esi\n set req.http.Surrogate-Capability = \"varnish=ESI\/1.0\";\n\n # We only deal with GET and HEAD by default\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n # normalize url in case of leading HTTP scheme and domain\n set req.url = regsub(req.url, \"^http[s]?:\/\/[^\/]+\", \"\");\n \n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"\\.(css|js|jpg|png|gif|tiff|bmp|gz|tgz|bz2|tbz|mp3|ogg|svg|swf|woff)(\\?|$)\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n # not cacheable by default\n if (req.http.Authorization || req.http.Https) {\n return (pass);\n }\n\n # remove Google gclid parameters\n set req.url = regsuball(req.url,\"\\?gclid=[^&]+$\",\"\"); # strips when QS = \"?gclid=AAA\"\n set req.url = regsuball(req.url,\"\\?gclid=[^&]+&\",\"?\"); # strips when QS = \"?gclid=AAA&foo=bar\"\n set req.url = regsuball(req.url,\"&gclid=[^&]+\",\"\"); # strips when QS = \"?foo=bar&gclid=AAA\" or QS = \"?foo=bar&gclid=AAA&bar=baz\"\n\n return (hash);\n}\n\nsub vcl_backend_response {\n # Enable esi processing \n if (beresp.http.Surrogate-Control ~ \"ESI\/1.0\") {\n unset beresp.http.Surrogate-Control;\n set beresp.do_esi = true;\n }\n\n set beresp.http.X-Purge-URL = bereq.url;\n set beresp.http.X-Purge-Host = bereq.http.host;\n\n if (beresp.http.X-Cache-Debug) {\n set beresp.http.X-Cache-Control = beresp.http.Cache-Control;\n set beresp.http.X-TTL = beresp.ttl;\n }\n\n if (\n beresp.status == 200 || \n beresp.status == 301 || \n beresp.status == 404\n ) {\n if (\n beresp.http.Content-Type ~ \"text\/html\" || \n beresp.http.Content-Type ~ \"text\/xml\" ||\n beresp.http.Content-Type ~ \"application\/json\"\n ) {\n if (beresp.ttl < 1s) {\n set beresp.ttl = 0s;\n set beresp.uncacheable = true;\n return (deliver);\n }\n set beresp.http.magicmarker = \"1\";\n unset beresp.http.set-cookie;\n } else {\n set beresp.ttl = 4h;\n }\n return (deliver);\n }\n \n set beresp.ttl = 0s;\n set beresp.uncacheable = true;\n \n return (deliver);\n}\n\nsub vcl_deliver {\n if (resp.http.X-Cache-Debug) {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n set resp.http.X-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n } else {\n unset resp.http.Age;\n unset resp.http.X-Cache-Debug;\n unset resp.http.X-Purge-Tags; \n unset resp.http.X-Purge-Host;\n unset resp.http.X-Purge-URL;\n unset resp.http.X-Powered-By;\n unset resp.http.Server;\n unset resp.http.X-Varnish;\n unset resp.http.Via;\n unset resp.http.Link;\n }\n \n if (resp.http.magicmarker) {\n unset resp.http.magicmarker;\n\n set resp.http.Cache-Control = \"no-store, no-cache, must-revalidate, post-check=0, pre-check=0\";\n set resp.http.Pragma = \"no-cache\";\n set resp.http.Expires = \"Mon, 31 Mar 2008 10:00:00 GMT\";\n set resp.http.Age = \"0\";\n }\n}\n","old_contents":"vcl 4.0;\n\nimport std;\n\nbackend default {\n .host = \"localhost\";\n .port = \"8080\";\n}\n\nacl purge {\n \"localhost\";\n \"127.0.0.1\";\n}\n\nsub vcl_recv {\n # Purge\n if (req.method == \"PURGE\") {\n if (client.ip !~ purge) {\n return (synth(405, \"Method not allowed\"));\n }\n if (!req.http.X-Purge-Host) {\n return (synth(400, \"Please specify X-Purge-Host header\"));\n }\n if (req.http.X-Purge-Tags) { \n ban(\"obj.http.X-Purge-Tags ~ \" + req.http.X-Purge-Tags + \" && obj.http.X-Purge-Host ~ \" + req.http.X-Purge-Host);\n return (synth(200, \"Purged by Tags: \" + req.http.X-Purge-Tags + \", Host: \" + req.http.X-Purge-Host));\n } elsif (req.http.X-Purge-URL) {\n ban(\"obj.http.X-Purge-URL ~ \" + req.http.X-Purge-URL + \" && obj.http.X-Purge-Host ~ \" + req.http.X-Purge-Host);\n return (synth(200, \"Purged by URL: \" + req.http.X-Purge-URL + \", Host: \" + req.http.X-Purge-Host));\n }\n return (synth(400, \"Please specify X-Purge-URL or X-Purge-Tags headers\"));\n }\n\n if (\n req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\"\n ) {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n \n # tell backend support for esi\n set req.http.Surrogate-Capability = \"varnish=ESI\/1.0\";\n\n # normalize url in case of leading HTTP scheme and domain\n set req.url = regsub(req.url, \"^http[s]?:\/\/[^\/]+\", \"\");\n \n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"\\.(css|js|jpg|png|gif|tiff|bmp|gz|tgz|bz2|tbz|mp3|ogg|svg|swf|woff)(\\?|$)\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n # not cacheable by default\n if (req.http.Authorization || req.http.Https) {\n return (pass);\n }\n\n # remove Google gclid parameters\n set req.url = regsuball(req.url,\"\\?gclid=[^&]+$\",\"\"); # strips when QS = \"?gclid=AAA\"\n set req.url = regsuball(req.url,\"\\?gclid=[^&]+&\",\"?\"); # strips when QS = \"?gclid=AAA&foo=bar\"\n set req.url = regsuball(req.url,\"&gclid=[^&]+\",\"\"); # strips when QS = \"?foo=bar&gclid=AAA\" or QS = \"?foo=bar&gclid=AAA&bar=baz\"\n\n return (hash);\n}\n\nsub vcl_backend_response {\n # Enable esi processing \n if (beresp.http.Surrogate-Control ~ \"ESI\/1.0\") {\n unset beresp.http.Surrogate-Control;\n set beresp.do_esi = true;\n }\n\n set beresp.http.X-Purge-URL = bereq.url;\n set beresp.http.X-Purge-Host = bereq.http.host;\n\n if (beresp.http.X-Cache-Debug) {\n set beresp.http.X-Cache-Control = beresp.http.Cache-Control;\n set beresp.http.X-TTL = beresp.ttl;\n }\n\n if (\n beresp.status == 200 || \n beresp.status == 301 || \n beresp.status == 404\n ) {\n if (\n beresp.http.Content-Type ~ \"text\/html\" || \n beresp.http.Content-Type ~ \"text\/xml\" ||\n beresp.http.Content-Type ~ \"application\/json\"\n ) {\n if (beresp.ttl < 1s) {\n set beresp.ttl = 0s;\n set beresp.uncacheable = true;\n return (deliver);\n }\n set beresp.http.magicmarker = \"1\";\n unset beresp.http.set-cookie;\n } else {\n set beresp.ttl = 4h;\n }\n return (deliver);\n }\n \n set beresp.ttl = 0s;\n set beresp.uncacheable = true;\n \n return (deliver);\n}\n\nsub vcl_deliver {\n if (resp.http.X-Cache-Debug) {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n set resp.http.X-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n } else {\n unset resp.http.Age;\n unset resp.http.X-Cache-Debug;\n unset resp.http.X-Purge-Tags; \n unset resp.http.X-Purge-Host;\n unset resp.http.X-Purge-URL;\n unset resp.http.X-Powered-By;\n unset resp.http.Server;\n unset resp.http.X-Varnish;\n unset resp.http.Via;\n unset resp.http.Link;\n }\n \n if (resp.http.magicmarker) {\n unset resp.http.magicmarker;\n\n set resp.http.Cache-Control = \"no-store, no-cache, must-revalidate, post-check=0, pre-check=0\";\n set resp.http.Pragma = \"no-cache\";\n set resp.http.Expires = \"Mon, 31 Mar 2008 10:00:00 GMT\";\n set resp.http.Age = \"0\";\n }\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"ffa042dd342b03d450e5f505499111fb31fcb108","subject":"Added caching 404s for 1 minute","message":"Added caching 404s for 1 minute\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/fastly.vcl","new_file":"etc\/fastly.vcl","new_contents":"###############################################################################\n#\n# Fastly CDN for Magento 2\n#\n# NOTICE OF LICENSE\n#\n# This source file is subject to the Fastly CDN for Magento 2 End User License\n# Agreement that is bundled with this package in the file LICENSE_FASTLY_CDN.txt.\n#\n# @copyright Copyright (c) 2016 Fastly, Inc. (http:\/\/www.fastly.com)\n# @license BSD, see LICENSE_FASTLY_CDN.txt\n#\n###############################################################################\n\n# This is a basic VCL configuration file for Fastly CDN for Magento 2 module.\n\nsub vcl_recv {\n#FASTLY recv\n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n set req.http.X-Sig = regsub(req.http.X-Purge-Token, \"^[^_]+_(.*)\", \"\\1\");\n set req.http.X-Exp = regsub(req.http.X-Purge-Token, \"^([^_]+)_.*\", \"\\1\");\n\n # validate signature\n if (req.http.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path req.http.X-Exp), \"^0x\", \"\")) {\n\n # use vcl time math to check expiration timestamp\n set req.http.X-Original-Grace = req.grace;\n set req.grace = std.atoi(strftime({\"%s\"}, now));\n set req.grace -= std.atoi(req.http.X-Exp);\n\n if (std.atoi(req.grace) > 0) {\n error 410;\n }\n\n # clean up grace since we used it for time math\n set req.grace = std.atoi(req.http.X-Original-Grace);\n unset req.http.X-Original-Grace;\n\n } else {\n error 403;\n }\n\n # cleanup variables\n unset req.http.X-Purge-Token;\n unset req.http.X-Sig;\n unset req.http.X-Exp;\n }\n\n # Deactivate gzip\n set req.http.X-Orig-Accept-Encoding = req.http.Accept-Encoding;\n unset req.http.Accept-Encoding;\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n # disable ESI processing on Origin Shield\n if (req.http.Fastly-FF) {\n set req.esi = false;\n }\n\n # We only deal with GET and HEAD by default\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n return (pass);\n }\n\n # Bypass shopping cart and checkout requests\n if (req.url ~ \"\/checkout\") {\n return (pass);\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie ~ \"(X-Magento-Vary|form_key)=\") {\n error 200 \"\";\n } else {\n # append parameter with country code\n set req.url = req.url \"?country_code=\" geoip.country_code;\n }\n }\n\n return(lookup);\n}\n\nsub vcl_fetch {\n\n if (req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset beresp.http.set-cookie;\n }\n\n#FASTLY fetch\n\n if (beresp.status >= 500) {\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n }\n\n if (req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Content-Type ~ \"text\/html\" || beresp.http.Content-Type ~ \"text\/xml\") {\n # enable ESI feature for Magento response by default\n esi;\n } else {\n # enable gzip for all static content\n if ((beresp.status == 200 || beresp.status == 404) && (beresp.http.content-type ~ \"^(text\\\/html|application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain|text\\\/xml)\\s*($|;)\" || req.url ~ \"\\.(css|js|html|eot|ico|otf|ttf|json)($|\\?)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.X-Orig-Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # cache only successfully responses and 404s\n if (beresp.status != 200 && beresp.status != 301 && beresp.status != 404) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\")) {\n unset beresp.http.set-cookie;\n if (req.url !~ \"^\/(pub\/)?(media|static)\/.*\") {\n set beresp.http.Pragma = \"no-cache\";\n set beresp.http.Expires = \"-1\";\n set beresp.http.Cache-Control = \"no-store, no-cache, must-revalidate, max-age=0\";\n set beresp.grace = 1m;\n }\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type\n if (beresp.http.Content-Type ~ \"image\") {\n set beresp.http.Surrogate-Key = \"image\";\n } elsif (beresp.http.Content-Type ~ \"script\") {\n set beresp.http.Surrogate-Key = \"script\";\n } elsif (beresp.http.Content-Type ~ \"css\") {\n set beresp.http.Surrogate-Key = \"css\";\n }\n\n set beresp.http.X-Surrogate-Key = beresp.http.Surrogate-Key;\n return (deliver);\n }\n\n # Cache 404's for 1 minute.\n if (beresp.status == 404 && req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n set beresp.ttl = 60s;\n }\n\n return (deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\n\nsub vcl_miss {\n#FASTLY miss\n\n return(fetch);\n}\n\nsub vcl_deliver {\n # debug info\n if (resp.http.X-Magento-Debug) {\n if (obj.hits > 0) {\n set resp.http.X-Magento-Cache-Debug = \"HIT\";\n set resp.http.X-Magento-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Magento-Cache-Debug = \"MISS\";\n }\n } else {\n # remove Varnish\/proxy header\n remove resp.http.Age;\n remove resp.http.X-Magento-Debug;\n remove resp.http.X-Magento-Tags;\n remove resp.http.X-Surrogate-Key;\n remove resp.http.X-Magento-Cache-Control;\n remove resp.http.X-Powered-By;\n remove resp.http.Server;\n remove resp.http.X-Varnish;\n remove resp.http.Via;\n remove resp.http.Link;\n remove resp.http.X-Purge-URL;\n remove resp.http.X-Purge-Host;\n }\n\n#FASTLY deliver\n\n return (deliver);\n}\n\n\nsub vcl_error {\n # workaround for possible security issue\n if (req.url ~ \"^\\s\") {\n set obj.status = 400;\n set obj.response = \"Malformed request\";\n synthetic \"\";\n return (deliver);\n }\n\n # error 200\n if (obj.status == 200) {\n return (deliver);\n }\n\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} obj.status \" \" obj.response {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} obj.status \" \" obj.response {\"<\/h1>\n <p>\"} obj.response {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} req.xid {\"<\/p>\n <hr>\n <p>Fastly CDN server<\/p>\n <\/body>\n<\/html>\n\"};\n\n#FASTLY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n\nsub vcl_hash {\n set req.hash += req.http.Https;\n set req.hash += req.http.host;\n set req.hash += req.url;\n\n if (req.http.cookie ~ \"X-Magento-Vary=\") {\n set req.http.X-Magento-Vary = regsub(req.http.cookie, \"^.*?X-Magento-Vary=([^;]+);*.*$\", \"\\1\");\n set req.hash += req.http.X-Magento-Vary;\n unset req.http.X-Magento-Vary;\n }\n \n set req.hash += \"#####GENERATION#####\";\n\n ### {{ design_exceptions_code }} ###\n\n return (hash);\n}\n\n","old_contents":"###############################################################################\n#\n# Fastly CDN for Magento 2\n#\n# NOTICE OF LICENSE\n#\n# This source file is subject to the Fastly CDN for Magento 2 End User License\n# Agreement that is bundled with this package in the file LICENSE_FASTLY_CDN.txt.\n#\n# @copyright Copyright (c) 2016 Fastly, Inc. (http:\/\/www.fastly.com)\n# @license BSD, see LICENSE_FASTLY_CDN.txt\n#\n###############################################################################\n\n# This is a basic VCL configuration file for Fastly CDN for Magento 2 module.\n\nsub vcl_recv {\n#FASTLY recv\n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n set req.http.X-Sig = regsub(req.http.X-Purge-Token, \"^[^_]+_(.*)\", \"\\1\");\n set req.http.X-Exp = regsub(req.http.X-Purge-Token, \"^([^_]+)_.*\", \"\\1\");\n\n # validate signature\n if (req.http.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path req.http.X-Exp), \"^0x\", \"\")) {\n\n # use vcl time math to check expiration timestamp\n set req.http.X-Original-Grace = req.grace;\n set req.grace = std.atoi(strftime({\"%s\"}, now));\n set req.grace -= std.atoi(req.http.X-Exp);\n\n if (std.atoi(req.grace) > 0) {\n error 410;\n }\n\n # clean up grace since we used it for time math\n set req.grace = std.atoi(req.http.X-Original-Grace);\n unset req.http.X-Original-Grace;\n\n } else {\n error 403;\n }\n\n # cleanup variables\n unset req.http.X-Purge-Token;\n unset req.http.X-Sig;\n unset req.http.X-Exp;\n }\n\n # Deactivate gzip\n set req.http.X-Orig-Accept-Encoding = req.http.Accept-Encoding;\n unset req.http.Accept-Encoding;\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n # disable ESI processing on Origin Shield\n if (req.http.Fastly-FF) {\n set req.esi = false;\n }\n\n # We only deal with GET and HEAD by default\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n return (pass);\n }\n\n # Bypass shopping cart and checkout requests\n if (req.url ~ \"\/checkout\") {\n return (pass);\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie ~ \"(X-Magento-Vary|form_key)=\") {\n error 200 \"\";\n } else {\n # append parameter with country code\n set req.url = req.url \"?country_code=\" geoip.country_code;\n }\n }\n\n return(lookup);\n}\n\nsub vcl_fetch {\n\n if (req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset beresp.http.set-cookie;\n }\n\n#FASTLY fetch\n\n if (beresp.status >= 500) {\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n }\n\n if (req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Content-Type ~ \"text\/html\" || beresp.http.Content-Type ~ \"text\/xml\") {\n # enable ESI feature for Magento response by default\n esi;\n } else {\n # enable gzip for all static content\n if ((beresp.status == 200 || beresp.status == 404) && (beresp.http.content-type ~ \"^(text\\\/html|application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain|text\\\/xml)\\s*($|;)\" || req.url ~ \"\\.(css|js|html|eot|ico|otf|ttf|json)($|\\?)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.X-Orig-Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # cache only successfully responses and 404s\n if (beresp.status != 200 && beresp.status != 301 && beresp.status != 404) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\")) {\n unset beresp.http.set-cookie;\n if (req.url !~ \"^\/(pub\/)?(media|static)\/.*\") {\n set beresp.http.Pragma = \"no-cache\";\n set beresp.http.Expires = \"-1\";\n set beresp.http.Cache-Control = \"no-store, no-cache, must-revalidate, max-age=0\";\n set beresp.grace = 1m;\n }\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type\n if (beresp.http.Content-Type ~ \"image\") {\n set beresp.http.Surrogate-Key = \"image\";\n } elsif (beresp.http.Content-Type ~ \"script\") {\n set beresp.http.Surrogate-Key = \"script\";\n } elsif (beresp.http.Content-Type ~ \"css\") {\n set beresp.http.Surrogate-Key = \"css\";\n }\n\n set beresp.http.X-Surrogate-Key = beresp.http.Surrogate-Key;\n return (deliver);\n }\n\n return (deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\n\nsub vcl_miss {\n#FASTLY miss\n\n return(fetch);\n}\n\nsub vcl_deliver {\n # debug info\n if (resp.http.X-Magento-Debug) {\n if (obj.hits > 0) {\n set resp.http.X-Magento-Cache-Debug = \"HIT\";\n set resp.http.X-Magento-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Magento-Cache-Debug = \"MISS\";\n }\n } else {\n # remove Varnish\/proxy header\n remove resp.http.Age;\n remove resp.http.X-Magento-Debug;\n remove resp.http.X-Magento-Tags;\n remove resp.http.X-Surrogate-Key;\n remove resp.http.X-Magento-Cache-Control;\n remove resp.http.X-Powered-By;\n remove resp.http.Server;\n remove resp.http.X-Varnish;\n remove resp.http.Via;\n remove resp.http.Link;\n remove resp.http.X-Purge-URL;\n remove resp.http.X-Purge-Host;\n }\n\n#FASTLY deliver\n\n return (deliver);\n}\n\n\nsub vcl_error {\n # workaround for possible security issue\n if (req.url ~ \"^\\s\") {\n set obj.status = 400;\n set obj.response = \"Malformed request\";\n synthetic \"\";\n return (deliver);\n }\n\n # error 200\n if (obj.status == 200) {\n return (deliver);\n }\n\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} obj.status \" \" obj.response {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} obj.status \" \" obj.response {\"<\/h1>\n <p>\"} obj.response {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} req.xid {\"<\/p>\n <hr>\n <p>Fastly CDN server<\/p>\n <\/body>\n<\/html>\n\"};\n\n#FASTLY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n\nsub vcl_hash {\n set req.hash += req.http.Https;\n set req.hash += req.http.host;\n set req.hash += req.url;\n\n if (req.http.cookie ~ \"X-Magento-Vary=\") {\n set req.http.X-Magento-Vary = regsub(req.http.cookie, \"^.*?X-Magento-Vary=([^;]+);*.*$\", \"\\1\");\n set req.hash += req.http.X-Magento-Vary;\n unset req.http.X-Magento-Vary;\n }\n \n set req.hash += \"#####GENERATION#####\";\n\n ### {{ design_exceptions_code }} ###\n\n return (hash);\n}\n\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"fc15e0d3fa6bc4b8178fbffd5dc8282995838064","subject":"Put comments in the default VCL to make people stop frobbing stuff we don't support yet.","message":"Put comments in the default VCL to make people stop frobbing stuff\nwe don't support yet.\n\n\n\ngit-svn-id: 2c9807fa3ff65b17195bd55dc8a6c4261e10127b@3186 d4fa192b-c00b-0410-8231-f00ffab90ce4\n","repos":"ajasty-cavium\/Varnish-Cache,varnish\/Varnish-Cache,1HLtd\/Varnish-Cache,franciscovg\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,chrismoulton\/Varnish-Cache,1HLtd\/Varnish-Cache,franciscovg\/Varnish-Cache,drwilco\/varnish-cache-old,1HLtd\/Varnish-Cache,franciscovg\/Varnish-Cache,franciscovg\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,varnish\/Varnish-Cache,drwilco\/varnish-cache-old,varnish\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,varnish\/Varnish-Cache,ssm\/pkg-varnish,drwilco\/varnish-cache-drwilco,alarky\/varnish-cache-doc-ja,mrhmouse\/Varnish-Cache,drwilco\/varnish-cache-drwilco,1HLtd\/Varnish-Cache,varnish\/Varnish-Cache,alarky\/varnish-cache-doc-ja,ssm\/pkg-varnish,ambernetas\/varnish-cache,ssm\/pkg-varnish,ssm\/pkg-varnish,zhoualbeart\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,feld\/Varnish-Cache,zhoualbeart\/Varnish-Cache,wikimedia\/operations-debs-varnish,mrhmouse\/Varnish-Cache,drwilco\/varnish-cache-old,feld\/Varnish-Cache,mrhmouse\/Varnish-Cache,ssm\/pkg-varnish,gquintard\/Varnish-Cache,ambernetas\/varnish-cache,gquintard\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,franciscovg\/Varnish-Cache,gquintard\/Varnish-Cache,wikimedia\/operations-debs-varnish,alarky\/varnish-cache-doc-ja,wikimedia\/operations-debs-varnish,ajasty-cavium\/Varnish-Cache,drwilco\/varnish-cache-drwilco,gquintard\/Varnish-Cache,ambernetas\/varnish-cache,zhoualbeart\/Varnish-Cache,mrhmouse\/Varnish-Cache,feld\/Varnish-Cache,feld\/Varnish-Cache,wikimedia\/operations-debs-varnish,mrhmouse\/Varnish-Cache,alarky\/varnish-cache-doc-ja,chrismoulton\/Varnish-Cache,feld\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,chrismoulton\/Varnish-Cache,wikimedia\/operations-debs-varnish,zhoualbeart\/Varnish-Cache,zhoualbeart\/Varnish-Cache,alarky\/varnish-cache-doc-ja,chrismoulton\/Varnish-Cache,chrismoulton\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache","old_file":"bin\/varnishd\/default.vcl","new_file":"bin\/varnishd\/default.vcl","new_contents":"\/*-\n * Copyright (c) 2006 Verdens Gang AS\n * Copyright (c) 2006-2008 Linpro AS\n * All rights reserved.\n *\n * Author: Poul-Henning Kamp <phk@phk.freebsd.dk>\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in the\n * documentation and\/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * $Id$\n *\n * The default VCL code.\n *\n * NB! You do NOT need to copy & paste all of this into your won vcl code,\n * if you do not handle one of the functions, the compiler will automaticall\n * fall back to the default code.\n *\n * This code will be prefixed with a backend declaration built from the\n * -b argument.\n *\/\n\nsub vcl_recv {\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n pipe;\n }\n if (req.http.Expect) {\n \/* Expect is just too hard at present. *\/\n pipe;\n }\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n pass;\n }\n if (req.http.Authorization || req.http.Cookie) {\n \/* Not cacheable by default *\/\n pass;\n }\n lookup;\n}\n\nsub vcl_pipe {\n pipe;\n}\n\nsub vcl_pass {\n pass;\n}\n\nsub vcl_hash {\n set req.hash += req.url;\n if (req.http.host) {\n set req.hash += req.http.host;\n } else {\n set req.hash += server.ip;\n }\n hash;\n}\n\nsub vcl_hit {\n if (!obj.cacheable) {\n pass;\n }\n deliver;\n}\n\nsub vcl_miss {\n fetch;\n}\n\nsub vcl_fetch {\n if (!obj.cacheable) {\n pass;\n }\n if (obj.http.Set-Cookie) {\n pass;\n }\n set obj.prefetch = -30s;\n deliver;\n}\n\nsub vcl_deliver {\n deliver;\n}\n\nsub vcl_discard {\n \/* XXX: Do not redefine vcl_discard{}, it is not yet supported *\/\n discard;\n}\n\nsub vcl_prefetch {\n \/* XXX: Do not redefine vcl_prefetch{}, it is not yet supported *\/\n fetch;\n}\n\nsub vcl_timeout {\n \/* XXX: Do not redefine vcl_timeout{}, it is not yet supported *\/\n discard;\n}\n\nsub vcl_error {\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} obj.status \" \" obj.response {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} obj.status \" \" obj.response {\"<\/h1>\n <p>\"} obj.response {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} req.xid {\"<\/p>\n <address><a href=\"http:\/\/www.varnish-cache.org\/\">Varnish<\/a><\/address>\n <\/body>\n<\/html>\n\"};\n deliver;\n}\n","old_contents":"\/*-\n * Copyright (c) 2006 Verdens Gang AS\n * Copyright (c) 2006-2008 Linpro AS\n * All rights reserved.\n *\n * Author: Poul-Henning Kamp <phk@phk.freebsd.dk>\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in the\n * documentation and\/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * $Id$\n *\n * The default VCL code.\n *\n * NB! You do NOT need to copy & paste all of this into your won vcl code,\n * if you do not handle one of the functions, the compiler will automaticall\n * fall back to the default code.\n *\n * This code will be prefixed with a backend declaration built from the\n * -b argument.\n *\/\n\nsub vcl_recv {\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n pipe;\n }\n if (req.http.Expect) {\n \/* Expect is just too hard at present. *\/\n pipe;\n }\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n pass;\n }\n if (req.http.Authorization || req.http.Cookie) {\n \/* Not cacheable by default *\/\n pass;\n }\n lookup;\n}\n\nsub vcl_pipe {\n pipe;\n}\n\nsub vcl_pass {\n pass;\n}\n\nsub vcl_hash {\n set req.hash += req.url;\n if (req.http.host) {\n set req.hash += req.http.host;\n } else {\n set req.hash += server.ip;\n }\n hash;\n}\n\nsub vcl_hit {\n if (!obj.cacheable) {\n pass;\n }\n deliver;\n}\n\nsub vcl_miss {\n fetch;\n}\n\nsub vcl_fetch {\n if (!obj.cacheable) {\n pass;\n }\n if (obj.http.Set-Cookie) {\n pass;\n }\n set obj.prefetch = -30s;\n deliver;\n}\n\nsub vcl_deliver {\n deliver;\n}\n\nsub vcl_discard {\n discard;\n}\n\nsub vcl_prefetch {\n fetch;\n}\n\nsub vcl_timeout {\n discard;\n}\n\nsub vcl_error {\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} obj.status \" \" obj.response {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} obj.status \" \" obj.response {\"<\/h1>\n <p>\"} obj.response {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} req.xid {\"<\/p>\n <address><a href=\"http:\/\/www.varnish-cache.org\/\">Varnish<\/a><\/address>\n <\/body>\n<\/html>\n\"};\n deliver;\n}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"104e4fe75a8d990be3eae60b8b4568e0a8b69aa5","subject":"Added logic to set a TTL for 404s.","message":"Added logic to set a TTL for 404s.\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/fastly.vcl","new_file":"etc\/fastly.vcl","new_contents":"###############################################################################\n#\n# Fastly CDN for Magento 2\n#\n# NOTICE OF LICENSE\n#\n# This source file is subject to the Fastly CDN for Magento 2 End User License\n# Agreement that is bundled with this package in the file LICENSE_FASTLY_CDN.txt.\n#\n# @copyright Copyright (c) 2016 Fastly, Inc. (http:\/\/www.fastly.com)\n# @license BSD, see LICENSE_FASTLY_CDN.txt\n#\n###############################################################################\n\n# This is a basic VCL configuration file for Fastly CDN for Magento 2 module.\n\nsub vcl_recv {\n#FASTLY recv\n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n set req.http.X-Sig = regsub(req.http.X-Purge-Token, \"^[^_]+_(.*)\", \"\\1\");\n set req.http.X-Exp = regsub(req.http.X-Purge-Token, \"^([^_]+)_.*\", \"\\1\");\n\n # validate signature\n if (req.http.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path req.http.X-Exp), \"^0x\", \"\")) {\n\n # use vcl time math to check expiration timestamp\n set req.http.X-Original-Grace = req.grace;\n set req.grace = std.atoi(strftime({\"%s\"}, now));\n set req.grace -= std.atoi(req.http.X-Exp);\n\n if (std.atoi(req.grace) > 0) {\n error 410;\n }\n\n # clean up grace since we used it for time math\n set req.grace = std.atoi(req.http.X-Original-Grace);\n unset req.http.X-Original-Grace;\n\n } else {\n error 403;\n }\n\n # cleanup variables\n unset req.http.X-Purge-Token;\n unset req.http.X-Sig;\n unset req.http.X-Exp;\n }\n\n # Deactivate gzip\n set req.http.X-Orig-Accept-Encoding = req.http.Accept-Encoding;\n unset req.http.Accept-Encoding;\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n # disable ESI processing on Origin Shield\n if (req.http.Fastly-FF) {\n set req.esi = false;\n }\n\n # We only deal with GET and HEAD by default\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n return (pass);\n }\n\n # Bypass shopping cart and checkout requests\n if (req.url ~ \"\/checkout\") {\n return (pass);\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie ~ \"(X-Magento-Vary|form_key)=\") {\n error 200 \"\";\n } else {\n # append parameter with country code\n set req.url = req.url \"?country_code=\" geoip.country_code;\n }\n }\n\n return(lookup);\n}\n\nsub vcl_fetch {\n\n # Remove Set-Cookies from responses for static content\n # to match the cookie removal in recv.\n if (req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n }\n\n }\n\n#FASTLY fetch\n\n if (beresp.status >= 500) {\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n }\n\n if (req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Content-Type ~ \"text\/html\" || beresp.http.Content-Type ~ \"text\/xml\") {\n # enable ESI feature for Magento response by default\n esi;\n } else {\n # enable gzip for all static content\n if ((beresp.status == 200 || beresp.status == 404) && (beresp.http.content-type ~ \"^(text\\\/html|application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain|text\\\/xml)\\s*($|;)\" || req.url ~ \"\\.(css|js|html|eot|ico|otf|ttf|json)($|\\?)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.X-Orig-Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # cache only successfully responses and 404s\n if (beresp.status != 200 && beresp.status != 301 && beresp.status != 404) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\")) {\n unset beresp.http.set-cookie;\n if (req.url !~ \"^\/(pub\/)?(media|static)\/.*\") {\n set beresp.http.Pragma = \"no-cache\";\n set beresp.http.Expires = \"-1\";\n set beresp.http.Cache-Control = \"no-store, no-cache, must-revalidate, max-age=0\";\n set beresp.grace = 1m;\n }\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type\n if (beresp.http.Content-Type ~ \"image\") {\n set beresp.http.Surrogate-Key = \"image\";\n } elsif (beresp.http.Content-Type ~ \"script\") {\n set beresp.http.Surrogate-Key = \"script\";\n } elsif (beresp.http.Content-Type ~ \"css\") {\n set beresp.http.Surrogate-Key = \"css\";\n }\n\n set beresp.http.X-Surrogate-Key = beresp.http.Surrogate-Key;\n return (deliver);\n }\n\n return (deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\n\nsub vcl_miss {\n#FASTLY miss\n\n return(fetch);\n}\n\nsub vcl_deliver {\n # debug info\n if (resp.http.X-Magento-Debug) {\n if (obj.hits > 0) {\n set resp.http.X-Magento-Cache-Debug = \"HIT\";\n set resp.http.X-Magento-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Magento-Cache-Debug = \"MISS\";\n }\n } else {\n # remove Varnish\/proxy header\n remove resp.http.Age;\n remove resp.http.X-Magento-Debug;\n remove resp.http.X-Magento-Tags;\n remove resp.http.X-Surrogate-Key;\n remove resp.http.X-Magento-Cache-Control;\n remove resp.http.X-Powered-By;\n remove resp.http.Server;\n remove resp.http.X-Varnish;\n remove resp.http.Via;\n remove resp.http.Link;\n remove resp.http.X-Purge-URL;\n remove resp.http.X-Purge-Host;\n }\n\n#FASTLY deliver\n\n return (deliver);\n}\n\n\nsub vcl_error {\n # workaround for possible security issue\n if (req.url ~ \"^\\s\") {\n set obj.status = 400;\n set obj.response = \"Malformed request\";\n synthetic \"\";\n return (deliver);\n }\n\n # error 200\n if (obj.status == 200) {\n return (deliver);\n }\n\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} obj.status \" \" obj.response {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} obj.status \" \" obj.response {\"<\/h1>\n <p>\"} obj.response {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} req.xid {\"<\/p>\n <hr>\n <p>Fastly CDN server<\/p>\n <\/body>\n<\/html>\n\"};\n\n#FASTLY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n\nsub vcl_hash {\n set req.hash += req.http.Https;\n set req.hash += req.http.host;\n set req.hash += req.url;\n\n if (req.http.cookie ~ \"X-Magento-Vary=\") {\n set req.http.X-Magento-Vary = regsub(req.http.cookie, \"^.*?X-Magento-Vary=([^;]+);*.*$\", \"\\1\");\n set req.hash += req.http.X-Magento-Vary;\n unset req.http.X-Magento-Vary;\n }\n \n set req.hash += \"#####GENERATION#####\";\n\n ### {{ design_exceptions_code }} ###\n\n return (hash);\n}\n\n","old_contents":"###############################################################################\n#\n# Fastly CDN for Magento 2\n#\n# NOTICE OF LICENSE\n#\n# This source file is subject to the Fastly CDN for Magento 2 End User License\n# Agreement that is bundled with this package in the file LICENSE_FASTLY_CDN.txt.\n#\n# @copyright Copyright (c) 2016 Fastly, Inc. (http:\/\/www.fastly.com)\n# @license BSD, see LICENSE_FASTLY_CDN.txt\n#\n###############################################################################\n\n# This is a basic VCL configuration file for Fastly CDN for Magento 2 module.\n\nsub vcl_recv {\n#FASTLY recv\n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n set req.http.X-Sig = regsub(req.http.X-Purge-Token, \"^[^_]+_(.*)\", \"\\1\");\n set req.http.X-Exp = regsub(req.http.X-Purge-Token, \"^([^_]+)_.*\", \"\\1\");\n\n # validate signature\n if (req.http.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path req.http.X-Exp), \"^0x\", \"\")) {\n\n # use vcl time math to check expiration timestamp\n set req.http.X-Original-Grace = req.grace;\n set req.grace = std.atoi(strftime({\"%s\"}, now));\n set req.grace -= std.atoi(req.http.X-Exp);\n\n if (std.atoi(req.grace) > 0) {\n error 410;\n }\n\n # clean up grace since we used it for time math\n set req.grace = std.atoi(req.http.X-Original-Grace);\n unset req.http.X-Original-Grace;\n\n } else {\n error 403;\n }\n\n # cleanup variables\n unset req.http.X-Purge-Token;\n unset req.http.X-Sig;\n unset req.http.X-Exp;\n }\n\n # Deactivate gzip\n set req.http.X-Orig-Accept-Encoding = req.http.Accept-Encoding;\n unset req.http.Accept-Encoding;\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n # disable ESI processing on Origin Shield\n if (req.http.Fastly-FF) {\n set req.esi = false;\n }\n\n # We only deal with GET and HEAD by default\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n return (pass);\n }\n\n # Bypass shopping cart and checkout requests\n if (req.url ~ \"\/checkout\") {\n return (pass);\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie ~ \"(X-Magento-Vary|form_key)=\") {\n error 200 \"\";\n } else {\n # append parameter with country code\n set req.url = req.url \"?country_code=\" geoip.country_code;\n }\n }\n\n return(lookup);\n}\n\nsub vcl_fetch {\n\n if (req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset beresp.http.set-cookie;\n }\n\n#FASTLY fetch\n\n if (beresp.status >= 500) {\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n }\n\n if (req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Content-Type ~ \"text\/html\" || beresp.http.Content-Type ~ \"text\/xml\") {\n # enable ESI feature for Magento response by default\n esi;\n } else {\n # enable gzip for all static content\n if ((beresp.status == 200 || beresp.status == 404) && (beresp.http.content-type ~ \"^(text\\\/html|application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain|text\\\/xml)\\s*($|;)\" || req.url ~ \"\\.(css|js|html|eot|ico|otf|ttf|json)($|\\?)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.X-Orig-Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # cache only successfully responses and 404s\n if (beresp.status != 200 && beresp.status != 301 && beresp.status != 404) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\")) {\n unset beresp.http.set-cookie;\n if (req.url !~ \"^\/(pub\/)?(media|static)\/.*\") {\n set beresp.http.Pragma = \"no-cache\";\n set beresp.http.Expires = \"-1\";\n set beresp.http.Cache-Control = \"no-store, no-cache, must-revalidate, max-age=0\";\n set beresp.grace = 1m;\n }\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type\n if (beresp.http.Content-Type ~ \"image\") {\n set beresp.http.Surrogate-Key = \"image\";\n } elsif (beresp.http.Content-Type ~ \"script\") {\n set beresp.http.Surrogate-Key = \"script\";\n } elsif (beresp.http.Content-Type ~ \"css\") {\n set beresp.http.Surrogate-Key = \"css\";\n }\n\n set beresp.http.X-Surrogate-Key = beresp.http.Surrogate-Key;\n return (deliver);\n }\n\n # Cache 404's for 1 minute.\n if (beresp.status == 404 && req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n set beresp.ttl = 60s;\n }\n\n return (deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\n\nsub vcl_miss {\n#FASTLY miss\n\n return(fetch);\n}\n\nsub vcl_deliver {\n # debug info\n if (resp.http.X-Magento-Debug) {\n if (obj.hits > 0) {\n set resp.http.X-Magento-Cache-Debug = \"HIT\";\n set resp.http.X-Magento-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Magento-Cache-Debug = \"MISS\";\n }\n } else {\n # remove Varnish\/proxy header\n remove resp.http.Age;\n remove resp.http.X-Magento-Debug;\n remove resp.http.X-Magento-Tags;\n remove resp.http.X-Surrogate-Key;\n remove resp.http.X-Magento-Cache-Control;\n remove resp.http.X-Powered-By;\n remove resp.http.Server;\n remove resp.http.X-Varnish;\n remove resp.http.Via;\n remove resp.http.Link;\n remove resp.http.X-Purge-URL;\n remove resp.http.X-Purge-Host;\n }\n\n#FASTLY deliver\n\n return (deliver);\n}\n\n\nsub vcl_error {\n # workaround for possible security issue\n if (req.url ~ \"^\\s\") {\n set obj.status = 400;\n set obj.response = \"Malformed request\";\n synthetic \"\";\n return (deliver);\n }\n\n # error 200\n if (obj.status == 200) {\n return (deliver);\n }\n\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} obj.status \" \" obj.response {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} obj.status \" \" obj.response {\"<\/h1>\n <p>\"} obj.response {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} req.xid {\"<\/p>\n <hr>\n <p>Fastly CDN server<\/p>\n <\/body>\n<\/html>\n\"};\n\n#FASTLY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n\nsub vcl_hash {\n set req.hash += req.http.Https;\n set req.hash += req.http.host;\n set req.hash += req.url;\n\n if (req.http.cookie ~ \"X-Magento-Vary=\") {\n set req.http.X-Magento-Vary = regsub(req.http.cookie, \"^.*?X-Magento-Vary=([^;]+);*.*$\", \"\\1\");\n set req.hash += req.http.X-Magento-Vary;\n unset req.http.X-Magento-Vary;\n }\n \n set req.hash += \"#####GENERATION#####\";\n\n ### {{ design_exceptions_code }} ###\n\n return (hash);\n}\n\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"31002caa887e8d448502ce1dc9de869a80f8c998","subject":"Do not trow away existing headers listed in Vary:","message":"Do not trow away existing headers listed in Vary:\n","repos":"hebertdougl\/noosfero,macartur\/noosfero,uniteddiversity\/noosfero,ludaac\/noosfero-mx,arthurmde\/noosfero,cesarfex\/noosfero,coletivoEITA\/noosfero-ecosol,blogoosfero\/noosfero,hackathon-oscs\/cartografias,AlessandroCaetano\/noosfero,marcosronaldo\/noosfero,coletivoEITA\/noosfero,arthurmde\/noosfero,hackathon-oscs\/rede-osc,CIRANDAS\/noosfero-ecosol,alexandreab\/noosfero,blogoosfero\/noosfero,tallysmartins\/noosfero,abner\/noosfero,macartur\/noosfero,danielafeitosa\/noosfero,tallysmartins\/noosfero,samasti\/noosfero,vfcosta\/noosfero,EcoAlternative\/noosfero-ecosol,larissa\/noosfero,uniteddiversity\/noosfero,hackathon-oscs\/rede-osc,hackathon-oscs\/cartografias,rafamanzo\/mezuro-travis,macartur\/noosfero,macartur\/noosfero,hackathon-oscs\/rede-osc,vfcosta\/noosfero,hackathon-oscs\/rede-osc,cesarfex\/noosfero,AlessandroCaetano\/noosfero,hebertdougl\/noosfero,hackathon-oscs\/cartografias,cesarfex\/noosfero,tallysmartins\/noosfero,arthurmde\/noosfero,CIRANDAS\/noosfero-ecosol,larissa\/noosfero,danielafeitosa\/noosfero,rafamanzo\/mezuro-travis,abner\/noosfero,AlessandroCaetano\/noosfero,evandrojr\/noosferogov,CIRANDAS\/noosfero-ecosol,vfcosta\/noosfero,alexandreab\/noosfero,alexandreab\/noosfero,hebertdougl\/noosfero,coletivoEITA\/noosfero,samasti\/noosfero,larissa\/noosfero,vfcosta\/noosfero,arthurmde\/noosfero,hackathon-oscs\/cartografias,pr-snas\/noosfero-sgpr,evandrojr\/noosfero,marcosronaldo\/noosfero,hebertdougl\/noosfero,larissa\/noosfero,danielafeitosa\/noosfero,evandrojr\/noosfero,macartur\/noosfero,evandrojr\/noosferogov,hackathon-oscs\/cartografias,hebertdougl\/noosfero,AlessandroCaetano\/noosfero,cesarfex\/noosfero,blogoosfero\/noosfero,LuisBelo\/tccnoosfero,coletivoEITA\/noosfero,macartur\/noosfero,evandrojr\/noosfero,ludaac\/noosfero-mx,rafamanzo\/mezuro-travis,pr-snas\/noosfero-sgpr,alexandreab\/noosfero,arthurmde\/noosfero,evandrojr\/noosferogov,evandrojr\/noosfero,cesarfex\/noosfero,abner\/noosfero,AlessandroCaetano\/noosfero,alexandreab\/noosfero,abner\/noosfero,uniteddiversity\/noosfero,samasti\/noosfero,alexandreab\/noosfero,hackathon-oscs\/rede-osc,danielafeitosa\/noosfero,uniteddiversity\/noosfero,coletivoEITA\/noosfero,tallysmartins\/noosfero,evandrojr\/noosferogov,coletivoEITA\/noosfero-ecosol,uniteddiversity\/noosfero,hackathon-oscs\/cartografias,evandrojr\/noosferogov,LuisBelo\/tccnoosfero,samasti\/noosfero,coletivoEITA\/noosfero,marcosronaldo\/noosfero,arthurmde\/noosfero,hackathon-oscs\/rede-osc,marcosronaldo\/noosfero,uniteddiversity\/noosfero,EcoAlternative\/noosfero-ecosol,larissa\/noosfero,coletivoEITA\/noosfero-ecosol,coletivoEITA\/noosfero-ecosol,pr-snas\/noosfero-sgpr,evandrojr\/noosfero,coletivoEITA\/noosfero,rafamanzo\/mezuro-travis,evandrojr\/noosfero,samasti\/noosfero,marcosronaldo\/noosfero,uniteddiversity\/noosfero,ludaac\/noosfero-mx,samasti\/noosfero,coletivoEITA\/noosfero-ecosol,marcosronaldo\/noosfero,LuisBelo\/tccnoosfero,CIRANDAS\/noosfero-ecosol,LuisBelo\/tccnoosfero,blogoosfero\/noosfero,vfcosta\/noosfero,rafamanzo\/mezuro-travis,evandrojr\/noosferogov,EcoAlternative\/noosfero-ecosol,pr-snas\/noosfero-sgpr,abner\/noosfero,vfcosta\/noosfero,hebertdougl\/noosfero,coletivoEITA\/noosfero-ecosol,LuisBelo\/tccnoosfero,coletivoEITA\/noosfero,blogoosfero\/noosfero,arthurmde\/noosfero,AlessandroCaetano\/noosfero,hackathon-oscs\/cartografias,tallysmartins\/noosfero,EcoAlternative\/noosfero-ecosol,larissa\/noosfero,EcoAlternative\/noosfero-ecosol,macartur\/noosfero,abner\/noosfero,tallysmartins\/noosfero,danielafeitosa\/noosfero,tallysmartins\/noosfero,larissa\/noosfero,LuisBelo\/tccnoosfero,pr-snas\/noosfero-sgpr,evandrojr\/noosfero,EcoAlternative\/noosfero-ecosol,EcoAlternative\/noosfero-ecosol,ludaac\/noosfero-mx,marcosronaldo\/noosfero,cesarfex\/noosfero,alexandreab\/noosfero,cesarfex\/noosfero,danielafeitosa\/noosfero,blogoosfero\/noosfero,ludaac\/noosfero-mx,AlessandroCaetano\/noosfero,hackathon-oscs\/rede-osc,hebertdougl\/noosfero,abner\/noosfero,blogoosfero\/noosfero,evandrojr\/noosferogov,pr-snas\/noosfero-sgpr,CIRANDAS\/noosfero-ecosol","old_file":"etc\/noosfero\/varnish-accept-language.vcl","new_file":"etc\/noosfero\/varnish-accept-language.vcl","new_contents":"C{\n\n\/* ------------------------------------------------------------------ *\/\n\/* THIS FILE IS AUTOMATICALLY GENERATED BY .\/gen_vcl.pl. DO NOT EDIT. *\/\n\n\/*\n * Accept-language header normalization\n *\n * Cosimo, 21\/01\/2010\n *\n *\/\n\n#include <ctype.h> \/* isupper *\/\n#include <stdio.h>\n#include <stdlib.h> \/* qsort *\/\n#include <string.h>\n\n#define DEFAULT_LANGUAGE \"en\"\n#define SUPPORTED_LANGUAGES \":de:fr:es:ru:pt:hy:en:\"\n\n#define vcl_string char\n#define LANG_LIST_SIZE 16 \n#define LANG_MAXLEN 16\n#define RETURN_LANG(x) { \\\n strncpy(lang, x, LANG_MAXLEN); \\\n return; \\\n}\n#define RETURN_DEFAULT_LANG RETURN_LANG(DEFAULT_LANGUAGE)\n#define PUSH_LANG(x,y) { \\\n \/* fprintf(stderr, \"Pushing lang [%d] %s %.4f\\n\", curr_lang, x, y); *\/ \\\n \/* We have to copy, otherwise root_lang will be the same every time *\/ \\\n strncpy(pl[curr_lang].lang, x, LANG_MAXLEN); \\\n pl[curr_lang].q = y; \\\n curr_lang++; \\\n}\n\nstruct lang_list {\n vcl_string lang[LANG_MAXLEN];\n float q;\n};\n\n\/* In-place lowercase of a string *\/\nstatic void strtolower(char *s) {\n register char *c;\n for (c=s; *c; c++) {\n if (isupper(*c)) {\n *c = tolower(*c);\n }\n }\n return;\n}\n\n\/* Checks if a given language is in the static list of the ones we support *\/\nint is_supported(vcl_string *lang) {\n vcl_string *supported_languages = SUPPORTED_LANGUAGES;\n vcl_string match_str[LANG_MAXLEN + 3] = \"\"; \/* :, :, \\0 = 3 *\/\n int is_supported = 0;\n\n \/* We want to match 'zh-cn' and 'zh-CN' too *\/\n strtolower(lang);\n\n \/* Search \":<lang>:\" in supported languages string *\/\n strncpy(match_str, \":\", 1);\n strncat(match_str, lang, LANG_MAXLEN);\n strncat(match_str, \":\\0\", 2);\n\n if (strstr(supported_languages, match_str)) {\n is_supported = 1;\n }\n\n return is_supported;\n}\n\n\/* Used by qsort() below *\/\nint sort_by_q(const void *x, const void *y) {\n struct lang_list *a = (struct lang_list *)x;\n struct lang_list *b = (struct lang_list *)y;\n if (a->q > b->q) return -1;\n if (a->q < b->q) return 1;\n return 0;\n}\n\n\/* Reads Accept-Language, parses it, and finds the first match\n among the supported languages. In case of no match,\n returns the default language.\n*\/\nvoid select_language(const vcl_string *incoming_header, char *lang) {\n\n struct lang_list pl[LANG_LIST_SIZE];\n vcl_string *lang_tok = NULL;\n vcl_string root_lang[3];\n vcl_string *header;\n vcl_string *pos = NULL;\n vcl_string *q_spec = NULL;\n unsigned int curr_lang = 0, i = 0;\n float q;\n\n \/* Empty or default string, return default language immediately *\/\n if (\n !incoming_header\n || (0 == strcmp(incoming_header, \"en-US\"))\n || (0 == strcmp(incoming_header, \"en-GB\"))\n || (0 == strcmp(incoming_header, DEFAULT_LANGUAGE))\n || (0 == strcmp(incoming_header, \"\"))\n )\n RETURN_DEFAULT_LANG;\n\n \/* Tokenize Accept-Language *\/\n header = (vcl_string *) incoming_header;\n\n while ((lang_tok = strtok_r(header, \" ,\", &pos))) {\n\n q = 1.0;\n\n if ((q_spec = strstr(lang_tok, \";q=\"))) {\n \/* Truncate language name before ';' *\/\n *q_spec = '\\0';\n \/* Get q value *\/\n sscanf(q_spec + 3, \"%f\", &q);\n }\n\n \/* Wildcard language '*' should be last in list *\/\n if ((*lang_tok) == '*') q = 0.0;\n\n \/* Push in the prioritized list *\/\n PUSH_LANG(lang_tok, q);\n\n \/* For cases like 'en-GB', we also want the root language in the final list *\/\n if ('-' == lang_tok[2]) {\n root_lang[0] = lang_tok[0];\n root_lang[1] = lang_tok[1];\n root_lang[2] = '\\0';\n PUSH_LANG(root_lang, q - 0.001);\n }\n\n \/* For strtok_r() to proceed from where it left off *\/\n header = NULL;\n\n \/* Break out if stored max no. of languages *\/\n if (curr_lang >= LANG_MAXLEN) break;\n }\n\n \/* Sort by priority *\/\n qsort(pl, curr_lang, sizeof(struct lang_list), &sort_by_q);\n\n \/* Match with supported languages *\/\n for (i = 0; i < curr_lang; i++) {\n if (is_supported(pl[i].lang))\n RETURN_LANG(pl[i].lang);\n }\n\n RETURN_DEFAULT_LANG;\n}\n\n\/* Reads req.http.Accept-Language and writes X-Varnish-Accept-Language *\/\nvoid vcl_rewrite_accept_language(const struct sess *sp) {\n vcl_string *in_hdr;\n vcl_string lang[LANG_MAXLEN];\n\n memset(lang, 0, LANG_MAXLEN);\n\n \/* Get Accept-Language header from client *\/\n in_hdr = VRT_GetHdr(sp, HDR_REQ, \"\\020Accept-Language:\");\n\n \/* Normalize and filter out by list of supported languages *\/\n select_language(in_hdr, lang);\n\n \/* By default, use a different header name: don't mess with backend logic *\/\n VRT_SetHdr(sp, HDR_REQ, \"\\032X-Varnish-Accept-Language:\", lang, vrt_magic_string_end);\n\n return;\n}\n\n\/* vim: syn=c ts=4 et sts=4 sw=4 tw=0\n*\/\n\n\/* THIS FILE IS AUTOMATICALLY GENERATED BY .\/gen_vcl.pl. DO NOT EDIT. *\/\n\/* ------------------------------------------------------------------ *\/\n}C\n\nsub vcl_recv {\n C{\n vcl_rewrite_accept_language(sp);\n }C\n}\n\nsub vcl_fetch {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", X-Varnish-Accept-Language\";\n } else {\n set beresp.http.Vary = \"X-Varnish-Accept-Language\";\n }\n}\n","old_contents":"C{\n\n\/* ------------------------------------------------------------------ *\/\n\/* THIS FILE IS AUTOMATICALLY GENERATED BY .\/gen_vcl.pl. DO NOT EDIT. *\/\n\n\/*\n * Accept-language header normalization\n *\n * Cosimo, 21\/01\/2010\n *\n *\/\n\n#include <ctype.h> \/* isupper *\/\n#include <stdio.h>\n#include <stdlib.h> \/* qsort *\/\n#include <string.h>\n\n#define DEFAULT_LANGUAGE \"en\"\n#define SUPPORTED_LANGUAGES \":de:fr:es:ru:pt:hy:en:\"\n\n#define vcl_string char\n#define LANG_LIST_SIZE 16 \n#define LANG_MAXLEN 16\n#define RETURN_LANG(x) { \\\n strncpy(lang, x, LANG_MAXLEN); \\\n return; \\\n}\n#define RETURN_DEFAULT_LANG RETURN_LANG(DEFAULT_LANGUAGE)\n#define PUSH_LANG(x,y) { \\\n \/* fprintf(stderr, \"Pushing lang [%d] %s %.4f\\n\", curr_lang, x, y); *\/ \\\n \/* We have to copy, otherwise root_lang will be the same every time *\/ \\\n strncpy(pl[curr_lang].lang, x, LANG_MAXLEN); \\\n pl[curr_lang].q = y; \\\n curr_lang++; \\\n}\n\nstruct lang_list {\n vcl_string lang[LANG_MAXLEN];\n float q;\n};\n\n\/* In-place lowercase of a string *\/\nstatic void strtolower(char *s) {\n register char *c;\n for (c=s; *c; c++) {\n if (isupper(*c)) {\n *c = tolower(*c);\n }\n }\n return;\n}\n\n\/* Checks if a given language is in the static list of the ones we support *\/\nint is_supported(vcl_string *lang) {\n vcl_string *supported_languages = SUPPORTED_LANGUAGES;\n vcl_string match_str[LANG_MAXLEN + 3] = \"\"; \/* :, :, \\0 = 3 *\/\n int is_supported = 0;\n\n \/* We want to match 'zh-cn' and 'zh-CN' too *\/\n strtolower(lang);\n\n \/* Search \":<lang>:\" in supported languages string *\/\n strncpy(match_str, \":\", 1);\n strncat(match_str, lang, LANG_MAXLEN);\n strncat(match_str, \":\\0\", 2);\n\n if (strstr(supported_languages, match_str)) {\n is_supported = 1;\n }\n\n return is_supported;\n}\n\n\/* Used by qsort() below *\/\nint sort_by_q(const void *x, const void *y) {\n struct lang_list *a = (struct lang_list *)x;\n struct lang_list *b = (struct lang_list *)y;\n if (a->q > b->q) return -1;\n if (a->q < b->q) return 1;\n return 0;\n}\n\n\/* Reads Accept-Language, parses it, and finds the first match\n among the supported languages. In case of no match,\n returns the default language.\n*\/\nvoid select_language(const vcl_string *incoming_header, char *lang) {\n\n struct lang_list pl[LANG_LIST_SIZE];\n vcl_string *lang_tok = NULL;\n vcl_string root_lang[3];\n vcl_string *header;\n vcl_string *pos = NULL;\n vcl_string *q_spec = NULL;\n unsigned int curr_lang = 0, i = 0;\n float q;\n\n \/* Empty or default string, return default language immediately *\/\n if (\n !incoming_header\n || (0 == strcmp(incoming_header, \"en-US\"))\n || (0 == strcmp(incoming_header, \"en-GB\"))\n || (0 == strcmp(incoming_header, DEFAULT_LANGUAGE))\n || (0 == strcmp(incoming_header, \"\"))\n )\n RETURN_DEFAULT_LANG;\n\n \/* Tokenize Accept-Language *\/\n header = (vcl_string *) incoming_header;\n\n while ((lang_tok = strtok_r(header, \" ,\", &pos))) {\n\n q = 1.0;\n\n if ((q_spec = strstr(lang_tok, \";q=\"))) {\n \/* Truncate language name before ';' *\/\n *q_spec = '\\0';\n \/* Get q value *\/\n sscanf(q_spec + 3, \"%f\", &q);\n }\n\n \/* Wildcard language '*' should be last in list *\/\n if ((*lang_tok) == '*') q = 0.0;\n\n \/* Push in the prioritized list *\/\n PUSH_LANG(lang_tok, q);\n\n \/* For cases like 'en-GB', we also want the root language in the final list *\/\n if ('-' == lang_tok[2]) {\n root_lang[0] = lang_tok[0];\n root_lang[1] = lang_tok[1];\n root_lang[2] = '\\0';\n PUSH_LANG(root_lang, q - 0.001);\n }\n\n \/* For strtok_r() to proceed from where it left off *\/\n header = NULL;\n\n \/* Break out if stored max no. of languages *\/\n if (curr_lang >= LANG_MAXLEN) break;\n }\n\n \/* Sort by priority *\/\n qsort(pl, curr_lang, sizeof(struct lang_list), &sort_by_q);\n\n \/* Match with supported languages *\/\n for (i = 0; i < curr_lang; i++) {\n if (is_supported(pl[i].lang))\n RETURN_LANG(pl[i].lang);\n }\n\n RETURN_DEFAULT_LANG;\n}\n\n\/* Reads req.http.Accept-Language and writes X-Varnish-Accept-Language *\/\nvoid vcl_rewrite_accept_language(const struct sess *sp) {\n vcl_string *in_hdr;\n vcl_string lang[LANG_MAXLEN];\n\n memset(lang, 0, LANG_MAXLEN);\n\n \/* Get Accept-Language header from client *\/\n in_hdr = VRT_GetHdr(sp, HDR_REQ, \"\\020Accept-Language:\");\n\n \/* Normalize and filter out by list of supported languages *\/\n select_language(in_hdr, lang);\n\n \/* By default, use a different header name: don't mess with backend logic *\/\n VRT_SetHdr(sp, HDR_REQ, \"\\032X-Varnish-Accept-Language:\", lang, vrt_magic_string_end);\n\n return;\n}\n\n\/* vim: syn=c ts=4 et sts=4 sw=4 tw=0\n*\/\n\n\/* THIS FILE IS AUTOMATICALLY GENERATED BY .\/gen_vcl.pl. DO NOT EDIT. *\/\n\/* ------------------------------------------------------------------ *\/\n}C\n\nsub vcl_recv {\n C{\n vcl_rewrite_accept_language(sp);\n }C\n}\n\nsub vcl_fetch {\n set beresp.http.Vary = \"X-Varnish-Accept-Language\";\n}\n","returncode":0,"stderr":"","license":"agpl-3.0","lang":"VCL"} {"commit":"0575218ceba5bc2dba8b8d37c0aa132f6319c727","subject":"Our current VCL logic picks out the first value of FASTLY_CDN cookie and replaces it in the esi_data query string. This is incorrect. We need to find out what value of the esi_data is being asked for e.g. message, customer-quote find the matching cookie (if it exists) then replace that value inside esi_data.","message":"Our current VCL logic picks out the first value of FASTLY_CDN cookie and\nreplaces it in the esi_data query string. This is incorrect. We need to find out\nwhat value of the esi_data is being asked for e.g. message, customer-quote find\nthe matching cookie (if it exists) then replace that value inside esi_data.\n\nThis patch does that ie.\n1. Identifies the esi_data cookie being asked for\n2. Parses the value out\n","repos":"fastly\/fastly-magento,fastly\/fastly-magento,fastly\/fastly-magento,fastly\/fastly-magento","old_file":"app\/code\/community\/Fastly\/CDN\/etc\/vcl_snippets\/recv.vcl","new_file":"app\/code\/community\/Fastly\/CDN\/etc\/vcl_snippets\/recv.vcl","new_contents":" # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n # Pass any checkout, cart or customer\/myaccount urls\n if (req.url.path ~ \"\/(cart|checkout|customer)\") {\n set req.http.x-pass = \"1\";\n # Pass all admin actions\n } else if (req.url.path ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\") {\n set req.http.x-pass = \"1\";\n # bypass language switcher\n } else if (req.url.qs ~ \"(?i)___from_store=.*&___store=.*\") {\n set req.http.x-pass = \"1\";\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (req.http.cookie:FASTLY_CDN_ENV) {\n set req.http.Fastly-Cdn-Env = req.http.cookie:FASTLY_CDN_ENV;\n } else {\n unset req.http.Fastly-Cdn-Env;\n }\n\n ############################################################################################################\n # Following code block controls purge by URL. By default we want to protect all URL purges. In general this\n # is addressed by adding Fastly-Purge-Requires-Auth request header in vcl_recv however this runs the risk of\n # exposing API tokens if user attempts to purge non-https URLs. For this reason inside the Magento module\n # we use X-Purge-Token. Unfortunately this breaks purge from the Fastly UI. Therefore in the next code block\n # we check for presence of X-Purge-Token. If it's not present we force the Fastly-Purge-Requires-Auth\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n if (req.http.X-Purge-Token && req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n } else {\n error 403;\n }\n } else {\n set req.http.Fastly-Purge-Requires-Auth = \"1\";\n }\n }\n\n # disable ESI processing on Origin Shield\n if (req.http.Fastly-FF) {\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url.path ~ \"^\/(media|js|skin)\/.*\\.(png|jpg|jpeg|gif|css|js|swf|ico|webp|svg)$\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n # formkey lookup\n if (req.url.path ~ \"\/fastlycdn\/getformkey\/\") {\n # check if we have a formkey cookie\n if (req.http.Cookie:FASTLY_CDN_FORMKEY) {\n set req.http.Formkey = req.http.Cookie:FASTLY_CDN_FORMKEY;\n } else {\n # create formkey\n set req.http.seed = req.http.Cookie client.ip remote.port client.geo.longitude client.geo.latitude client.geo.postal_code;\n set req.http.Formkey = regsub(digest.hash_md5(req.http.seed), \"^0x\", \"\");\n }\n error 760 req.http.Formkey;\n }\n\n # client.geo lookup\n if (req.url.path ~ \"fastlycdn\/esi\/getcountry\/\") {\n # check if GeoIP has been already processed by client\n if (req.http.Cookie:FASTLY_CDN_GEOIP_PROCESSED) {\n error 200 \"\";\n } else {\n # modify req.url and restart request processing\n error 750 client.geo.country_code;\n }\n }\n\n # client.geo get country code\n if (req.url.path ~ \"fastlycdn\/esi\/getcountrycode\/\") {\n # create and set req.http.X-Country-Code\n error 755 client.geo.country_code;\n }\n\n # check for ESI calls\n if (req.url.qs ~ \"esi_data=\") {\n # check for valid cookie data\n declare local var.esi_data_field STRING;\n declare local var.cookie_data STRING;\n # Based on esi_data value requested we will need to search for cookie FASTLY_CDN-<type> e.g. FASTLY_CDN-customer_quote\n set var.esi_data_field = \"FASTLY_CDN-\" subfield(req.url.qs, \"esi_data\", \"&\");\n # We can't use variables in either subfield or regex so we need to use this workaround\n # to extract value of cookie that we compiled in esi_data_field\n set var.cookie_data = std.strstr(req.http.Cookie,var.esi_data_field);\n set var.cookie_data = regsub(var.cookie_data,\"^[^=]*=([^;]*).*\",\"\\1\");\n # If found a value we replace the query string with the contents of that cookie\n if ( var.cookie_data != \"\" ) {\n set req.url = querystring.set(req.url, \"esi_data\", var.cookie_data);\n }\n }\n\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking\n set req.http.Magento-Original-URL = req.url;\n set req.url = querystring.regfilter(req.url, \"^(####QUERY_PARAMETERS####)\");\n # Sort the query arguments to increase cache hit ratio with query arguments that\n # may be out of order however only on URLs that are not being passed. \n if ( !req.http.x-pass ) {\n set req.url = boltsort.sort(req.url);\n }\n","old_contents":" # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n # Pass any checkout, cart or customer\/myaccount urls\n if (req.url.path ~ \"\/(cart|checkout|customer)\") {\n set req.http.x-pass = \"1\";\n # Pass all admin actions\n } else if (req.url.path ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\") {\n set req.http.x-pass = \"1\";\n # bypass language switcher\n } else if (req.url.qs ~ \"(?i)___from_store=.*&___store=.*\") {\n set req.http.x-pass = \"1\";\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (req.http.cookie:FASTLY_CDN_ENV) {\n set req.http.Fastly-Cdn-Env = req.http.cookie:FASTLY_CDN_ENV;\n } else {\n unset req.http.Fastly-Cdn-Env;\n }\n\n ############################################################################################################\n # Following code block controls purge by URL. By default we want to protect all URL purges. In general this\n # is addressed by adding Fastly-Purge-Requires-Auth request header in vcl_recv however this runs the risk of\n # exposing API tokens if user attempts to purge non-https URLs. For this reason inside the Magento module\n # we use X-Purge-Token. Unfortunately this breaks purge from the Fastly UI. Therefore in the next code block\n # we check for presence of X-Purge-Token. If it's not present we force the Fastly-Purge-Requires-Auth\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n if (req.http.X-Purge-Token && req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n } else {\n error 403;\n }\n } else {\n set req.http.Fastly-Purge-Requires-Auth = \"1\";\n }\n }\n\n # disable ESI processing on Origin Shield\n if (req.http.Fastly-FF) {\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url.path ~ \"^\/(media|js|skin)\/.*\\.(png|jpg|jpeg|gif|css|js|swf|ico|webp|svg)$\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n # formkey lookup\n if (req.url.path ~ \"\/fastlycdn\/getformkey\/\") {\n # check if we have a formkey cookie\n if (req.http.Cookie:FASTLY_CDN_FORMKEY) {\n set req.http.Formkey = req.http.Cookie:FASTLY_CDN_FORMKEY;\n } else {\n # create formkey\n set req.http.seed = req.http.Cookie client.ip remote.port client.geo.longitude client.geo.latitude client.geo.postal_code;\n set req.http.Formkey = regsub(digest.hash_md5(req.http.seed), \"^0x\", \"\");\n }\n error 760 req.http.Formkey;\n }\n\n # client.geo lookup\n if (req.url.path ~ \"fastlycdn\/esi\/getcountry\/\") {\n # check if GeoIP has been already processed by client\n if (req.http.Cookie:FASTLY_CDN_GEOIP_PROCESSED) {\n error 200 \"\";\n } else {\n # modify req.url and restart request processing\n error 750 client.geo.country_code;\n }\n }\n\n # client.geo get country code\n if (req.url.path ~ \"fastlycdn\/esi\/getcountrycode\/\") {\n # create and set req.http.X-Country-Code\n error 755 client.geo.country_code;\n }\n\n # check for ESI calls\n if (req.url.qs ~ \"esi_data=\") {\n # check for valid cookie data\n if (req.http.Cookie ~ \"FASTLY_CDN-([A-Za-z0-9-_]+)=([^;]*)\") {\n set req.url = querystring.filter(req.url, \"esi_data\") + \"&esi_data=\" + re.group.2;\n }\n }\n\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking\n set req.http.Magento-Original-URL = req.url;\n set req.url = querystring.regfilter(req.url, \"^(####QUERY_PARAMETERS####)\");\n # Sort the query arguments to increase cache hit ratio with query arguments that\n # may be out of order however only on URLs that are not being passed. \n if ( !req.http.x-pass ) {\n set req.url = boltsort.sort(req.url);\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"610bb4bad0e69d9d33f8bfbace6242689ecdd75a","subject":"changed to correct hostname","message":"changed to correct hostname\n","repos":"3scale\/libvmod-3scale,3scale\/libvmod-3scale","old_file":"vcl\/default_3scale_with_proxy.vcl","new_file":"vcl\/default_3scale_with_proxy.vcl","new_contents":"# This is a the VCL configuration file for 3scale's varnish plugin.\n# \n# Default backend definition. Set this to point to the 3scale's\n# backend. \n# \n# set the beresp.ttl in vcl_fetch to have a default global TTL\n# you can define custom TTL via regular expressions\n#\n# Integration mode: API proxy.\n# Traffic from API consumers will go through Varnish \n# Varnish will check with 3scale backend for API call authorization and reporting\n# (see https:\/\/support.3scale.net\/howtos\/api-configuration\/varnish)\n\n# Replace placeholders at lines 18, 19 and 42.\n\n## the backend of your API\nbackend backend_api {\n .host = \"YOUR_API_ENDPOINT\"; \n .port = \"YOUR_API_ENDPOINT\";\n}\n\n## real 3scale backend\nbackend backend_3scale {\n .host = \"su1.3scale.net\"; \n .port = \"80\";\n}\n\nimport std;\nimport threescale;\n\nsub vcl_recv {\n\n unset req.http.cookie;\n\n if (!req.http.X-3scale-authorization) {\n ## this request was send by the end-user\n set req.backend = backend_api;\n\n ## need to generate the string for the 3scale authorization,\n set req.http.X-3scale-authrep = \"\/transactions\/authrep.xml?provider_key=\";\n ## set your 3scale provider_key\n ## set req.http.X-3scale-authrep = req.http.X-3scale-authrep + \"YOUR_PROVIDER_KEY\";\n \n ## extract the parameters sent by the user\n set req.http.X-3scale-app_id = regsub(req.url,\".*[&?](app_id.[^&]*).*\",\"\\1\");\n set req.http.X-3scale-app_key = regsub(req.url,\".*[&?](app_key.[^&]*).*\",\"\\1\");\n set req.http.X-3scale-user_key = regsub(req.url,\".*[&?](user_key.[^&]*).*\",\"\\1\");\n set req.http.X-3scale-user_id = regsub(req.url,\".*[&?](user_id.[^&]*).*\",\"\\1\");\n\n if (req.http.X-3scale-app_id != req.url) {\n set req.http.X-3scale-authrep = req.http.X-3scale-authrep + \"&\" + req.http.X-3scale-app_id; \n }\n\n if (req.http.X-3scale-app_key != req.url ) {\n set req.http.X-3scale-authrep = req.http.X-3scale-authrep + \"&\" + req.http.X-3scale-app_key; \n }\n\n if (req.http.X-3scale-user_id != req.url) {\n set req.http.X-3scale-authrep = req.http.X-3scale-authrep + \"&\" + req.http.X-3scale-user_id; \n }\n\n if (req.http.X-3scale-user_key != req.url) {\n set req.http.X-3scale-authrep = req.http.X-3scale-authrep + \"&\" + req.http.X-3scale-user_key; \n }\n \n unset req.http.X-3scale-app_id;\n unset req.http.X-3scale-app_key;\n unset req.http.X-3scale-user_id;\n unset req.http.X-3scale-user_key;\n\n ## set the appropriate usage in a similar why than above, the basic one is...\n set req.http.X-3scale-authrep = req.http.X-3scale-authrep + \"&usage[hits]=1\"; \n\n ## now the additional paramters, for instance if you want to pass the url path \n set req.http.X-3scale-authrep = req.http.X-3scale-authrep + \"&object=\" + req.url;\n\n set req.http.X-3scale-authrep-result = threescale.send_get_request(\"su1.3scale.net\",\"80\",req.http.X-3scale-authrep,\"X-3scale-authorization: true;\");\n\n if (req.http.X-3scale-authrep-result == \"200\") {\n ## the request from the user has been authorized, proceed as normal\n\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n return(pass);\n } \n else {\n return(lookup);\n }\n \n }\n else {\n ## the request from the users has not been authorized!! Returning an error\n ## FIXME: convert req.http.X-3scale-authrep-result; to int\n error 401;\n } \n\n unset req.http.X-3scale-authrep;\n unset req.http.X-3scale-authrep-result;\n\n\n }\n else {\n ## the request was not send by the end-user but by varnish itself\n set req.backend = backend_3scale;\n set req.http.host = \"su1.3scale.net\";\n\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n std.syslog(0,\"This should never happen!!\");\n } \n else {\n return(lookup);\n }\n\n }\n\n\t \n}\n\n# the hash of the request needs to be customized to remove all fields that are not \n# associated to the user\n\nsub vcl_hash {\n\n if (req.http.X-3scale-authorization) { \n ## remove no_body\n set req.http.X-url-tmp = regsub(req.url,\"[&?]no_body.[^&]*\",\"\");\n ## remove object_id\n set req.http.X-url-tmp = regsub(req.http.X-url-tmp,\"[&?]object.[^&]*\",\"\");\n ## remove object\n set req.http.X-url-tmp = regsub(req.http.X-url-tmp,\"[&?]object_id.[^&]*\",\"\");\n\n hash_data(req.http.X-url-tmp);\t\n unset req.http.X-url-tmp;\n }\n else {\n ## the default has of varnish for the end-user request, however we better remove the \n ## parameters specific to 3scale from the end-user request. If you want to remove other\n ## parameters from the original request so that they are not taken into account for the\n ## cache this is the place.\n\n set req.http.X-url-tmp = regsub(req.url,\"[&?]user_key.[^&]*\",\"\");\n set req.http.X-url-tmp = regsub(req.url,\"[&?]user_id.[^&]*\",\"\");\n set req.http.X-url-tmp = regsub(req.url,\"[&?]app_key.[^&]*\",\"\");\n set req.http.X-url-tmp = regsub(req.url,\"[&?]app_id.[^&]*\",\"\");\n\n hash_data(req.http.X-url-tmp);\n\n if (req.http.host) {\n hash_data(req.http.host);\n } \n else {\n hash_data(server.ip);\n }\n\n\t unset req.http.X-url-tmp;\n\n }\n\n return (hash);\n\n}\n\n#A HIT means that the request to your local cache of 3scale is still fresh and the\n#response will not have to fetch the data from the remote 3scale backend.\n#vmod_3scale plugin will send a replica of the call asynchronously to 3scale's remote\n#backend on its own\n\nsub vcl_hit {\n\n if (req.http.X-3scale-authorization) {\n if (req.url ~ \"^\/transactions\/authrep.xml\\?\") {\n\t if (threescale.send_get_request_threaded(\"su1.3scale.net\",\"80\",req.url,\"\")==0) {}\n }\n }\n \n\n}\n\n\nsub vcl_fetch {\n\n if (req.http.X-3scale-authorization) {\n ## cache the authorization from 3scale\n \tset beresp.ttl = 30s;\n }\n else {\n ## cache of the content of your API\n\t set beresp.ttl = 60s;\n }\n\n}\n\nsub vcl_deliver {\n ## remove control headers\n unset req.http.X-3scale-authrep;\n}\n\n\n\nsub vcl_error {\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n <\/head>\n <body>\n <div style=\"background-color:yellow;\">\n <h2>Authorization error trying to access this API<\/h2>\n <p>Did you forget to send your credentials?<\/p>\n <p>Are you over the limits of your account?<\/p> \n <p><b>Please go to your account at 3scale to find out<\/b><\/p>\n <\/div>\n <\/body>\n<\/html>\n\"};\n return (deliver);\n}\n\n\n\n\n","old_contents":"# This is a the VCL configuration file for 3scale's varnish plugin.\n# \n# Default backend definition. Set this to point to the 3scale's\n# backend. \n# \n# set the beresp.ttl in vcl_fetch to have a default global TTL\n# you can define custom TTL via regular expressions\n#\n# Integration mode: API proxy.\n# Traffic from API consumers will go through Varnish \n# Varnish will check with 3scale backend for API call authorization and reporting\n# (see https:\/\/support.3scale.net\/howtos\/api-configuration\/varnish)\n\n# Replace placeholders at lines 18, 19 and 42.\n\n## the backend of your API\nbackend backend_api {\n .host = \"YOUR_API_ENDPOINT\"; \n .port = \"YOUR_API_ENDPOINT\";\n}\n\n## real 3scale backend\nbackend backend_3scale {\n .host = \"su1.3scale.net\"; \n .port = \"80\";\n}\n\nimport std;\nimport threescale;\n\nsub vcl_recv {\n\n unset req.http.cookie;\n\n if (!req.http.X-3scale-authorization) {\n ## this request was send by the end-user\n set req.backend = backend_api;\n\n ## need to generate the string for the 3scale authorization,\n set req.http.X-3scale-authrep = \"\/transactions\/authrep.xml?provider_key=\";\n ## set your 3scale provider_key\n ## set req.http.X-3scale-authrep = req.http.X-3scale-authrep + \"YOUR_PROVIDER_KEY\";\n \n ## extract the parameters sent by the user\n set req.http.X-3scale-app_id = regsub(req.url,\".*[&?](app_id.[^&]*).*\",\"\\1\");\n set req.http.X-3scale-app_key = regsub(req.url,\".*[&?](app_key.[^&]*).*\",\"\\1\");\n set req.http.X-3scale-user_key = regsub(req.url,\".*[&?](user_key.[^&]*).*\",\"\\1\");\n set req.http.X-3scale-user_id = regsub(req.url,\".*[&?](user_id.[^&]*).*\",\"\\1\");\n\n if (req.http.X-3scale-app_id != req.url) {\n set req.http.X-3scale-authrep = req.http.X-3scale-authrep + \"&\" + req.http.X-3scale-app_id; \n }\n\n if (req.http.X-3scale-app_key != req.url ) {\n set req.http.X-3scale-authrep = req.http.X-3scale-authrep + \"&\" + req.http.X-3scale-app_key; \n }\n\n if (req.http.X-3scale-user_id != req.url) {\n set req.http.X-3scale-authrep = req.http.X-3scale-authrep + \"&\" + req.http.X-3scale-user_id; \n }\n\n if (req.http.X-3scale-user_key != req.url) {\n set req.http.X-3scale-authrep = req.http.X-3scale-authrep + \"&\" + req.http.X-3scale-user_key; \n }\n \n unset req.http.X-3scale-app_id;\n unset req.http.X-3scale-app_key;\n unset req.http.X-3scale-user_id;\n unset req.http.X-3scale-user_key;\n\n ## set the appropriate usage in a similar why than above, the basic one is...\n set req.http.X-3scale-authrep = req.http.X-3scale-authrep + \"&usage[hits]=1\"; \n\n ## now the additional paramters, for instance if you want to pass the url path \n set req.http.X-3scale-authrep = req.http.X-3scale-authrep + \"&object=\" + req.url;\n\n set req.http.X-3scale-authrep-result = threescale.send_get_request(\"localhost\",\"80\",req.http.X-3scale-authrep,\"X-3scale-authorization: true;\");\n\n if (req.http.X-3scale-authrep-result == \"200\") {\n ## the request from the user has been authorized, proceed as normal\n\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n return(pass);\n } \n else {\n return(lookup);\n }\n \n }\n else {\n ## the request from the users has not been authorized!! Returning an error\n ## FIXME: convert req.http.X-3scale-authrep-result; to int\n error 401;\n } \n\n unset req.http.X-3scale-authrep;\n unset req.http.X-3scale-authrep-result;\n\n\n }\n else {\n ## the request was not send by the end-user but by varnish itself\n set req.backend = backend_3scale;\n set req.http.host = \"su1.3scale.net\";\n\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n std.syslog(0,\"This should never happen!!\");\n } \n else {\n return(lookup);\n }\n\n }\n\n\t \n}\n\n# the hash of the request needs to be customized to remove all fields that are not \n# associated to the user\n\nsub vcl_hash {\n\n if (req.http.X-3scale-authorization) { \n ## remove no_body\n set req.http.X-url-tmp = regsub(req.url,\"[&?]no_body.[^&]*\",\"\");\n ## remove object_id\n set req.http.X-url-tmp = regsub(req.http.X-url-tmp,\"[&?]object.[^&]*\",\"\");\n ## remove object\n set req.http.X-url-tmp = regsub(req.http.X-url-tmp,\"[&?]object_id.[^&]*\",\"\");\n\n hash_data(req.http.X-url-tmp);\t\n unset req.http.X-url-tmp;\n }\n else {\n ## the default has of varnish for the end-user request, however we better remove the \n ## parameters specific to 3scale from the end-user request. If you want to remove other\n ## parameters from the original request so that they are not taken into account for the\n ## cache this is the place.\n\n set req.http.X-url-tmp = regsub(req.url,\"[&?]user_key.[^&]*\",\"\");\n set req.http.X-url-tmp = regsub(req.url,\"[&?]user_id.[^&]*\",\"\");\n set req.http.X-url-tmp = regsub(req.url,\"[&?]app_key.[^&]*\",\"\");\n set req.http.X-url-tmp = regsub(req.url,\"[&?]app_id.[^&]*\",\"\");\n\n hash_data(req.http.X-url-tmp);\n\n if (req.http.host) {\n hash_data(req.http.host);\n } \n else {\n hash_data(server.ip);\n }\n\n\t unset req.http.X-url-tmp;\n\n }\n\n return (hash);\n\n}\n\n#A HIT means that the request to your local cache of 3scale is still fresh and the\n#response will not have to fetch the data from the remote 3scale backend.\n#vmod_3scale plugin will send a replica of the call asynchronously to 3scale's remote\n#backend on its own\n\nsub vcl_hit {\n\n if (req.http.X-3scale-authorization) {\n if (req.url ~ \"^\/transactions\/authrep.xml\\?\") {\n\t if (threescale.send_get_request_threaded(\"su1.3scale.net\",\"80\",req.url,\"\")==0) {}\n }\n }\n \n\n}\n\n\nsub vcl_fetch {\n\n if (req.http.X-3scale-authorization) {\n ## cache the authorization from 3scale\n \tset beresp.ttl = 30s;\n }\n else {\n ## cache of the content of your API\n\t set beresp.ttl = 60s;\n }\n\n}\n\nsub vcl_deliver {\n ## remove control headers\n unset req.http.X-3scale-authrep;\n}\n\n\n\nsub vcl_error {\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n <\/head>\n <body>\n <div style=\"background-color:yellow;\">\n <h2>Authorization error trying to access this API<\/h2>\n <p>Did you forget to send your credentials?<\/p>\n <p>Are you over the limits of your account?<\/p> \n <p><b>Please go to your account at 3scale to find out<\/b><\/p>\n <\/div>\n <\/body>\n<\/html>\n\"};\n return (deliver);\n}\n\n\n\n\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"e05f75d22e12bd8e4fc3ceb0c5604f66a2f6eac2","subject":"update varnish config","message":"update varnish config\n","repos":"jclgoodwin\/bustimes.org.uk,jclgoodwin\/bustimes.org.uk,jclgoodwin\/bustimes.org.uk,jclgoodwin\/bustimes.org.uk","old_file":"config\/varnish\/default.vcl","new_file":"config\/varnish\/default.vcl","new_contents":"# Marker to tell the VCL compiler that this VCL has been adapted to the\n# new 4.0 format.\nvcl 4.0;\n\n# Default backend definition. Set this to point to your content server.\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\n\nsub vcl_recv {\n # Happens before we check if we have this in cache already.\n #\n # Typically you clean up the request here, removing cookies you don't need,\n # rewriting the request, etc.\n\n if (req.url ~ \"^\/(admin\/|contact|awin-transaction)\" || req.url ~ \"\/edit\") {\n return (pass);\n }\n\n # special features on fleet lists for logged in users\n if (req.http.Cookie ~ \"sessionid\" && req.url ~ \"operator\" && req.url ~ \"vehicles\") {\n return (pass);\n }\n\n unset req.http.Cookie;\n}\n\nsub vcl_backend_response {\n # Happens after we have read the response headers from the backend.\n #\n # Here you clean the response headers, removing silly Set-Cookie headers\n # and other mistakes your backend does.\n\n if (bereq.url !~ \"^\/(admin\/|contact|edit)\") {\n unset beresp.http.set-cookie;\n\n if (beresp.status >= 200 && beresp.status < 400) {\n if (bereq.url ~ \"^\/stops\/\") {\n set beresp.ttl = 50s;\n } elif (bereq.url ~ \"\/(vehicles|journeys\/)\") {\n set beresp.ttl = 6s;\n } else {\n set beresp.ttl = 1h;\n }\n }\n }\n}\n","old_contents":"vcl 4.0;\n\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8081\";\n}\n\nbackend bustimesio {\n .host = \"127.0.0.1\";\n .port = \"8082\";\n}\n\nbackend supermarket {\n .host = \"127.0.0.1\";\n .port = \"8000\";\n}\n\nbackend basiltherat {\n .host = \"127.0.0.1\";\n .port = \"8083\";\n}\n\nbackend tileserver {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\n\nsub vcl_recv {\n if (req.http.host == \"bustimes.io\") {\n set req.backend_hint = bustimesio;\n } elif (req.http.host == \"www.supermarketmarket.co.uk\") {\n set req.backend_hint = supermarket;\n } elif (req.http.host == \"hygieneratings.co.uk\") {\n set req.backend_hint = basiltherat;\n } elif (req.url ~ \"^\/styles\/\") {\n set req.backend_hint = tileserver;\n }\n\n if (req.url ~ \"^\/(admin\/|contact|awin-transaction)\") {\n return (pass);\n }\n\n unset req.http.Cookie;\n}\n\nsub vcl_backend_response {\n if (bereq.url !~ \"^\/(admin\/|contact)\") {\n unset beresp.http.set-cookie;\n\n if (beresp.status >= 200 && beresp.status < 400) {\n if (bereq.url ~ \"^\/stops\/\") {\n set beresp.ttl = 30s;\n } elif (bereq.url ~ \"^\/vehicles\\.json\") {\n set beresp.ttl = 5s;\n } elif (bereq.url ~ \"^\/styles\/\") {\n set beresp.ttl = 30d;\n } else {\n set beresp.ttl = 1h;\n }\n }\n\n }\n}\n\nsub vcl_deliver {\n if (req.url ~ \"\/stops\/\" && resp.status >= 200 && resp.status < 400) {\n set resp.http.X-Accel-Buffering = \"no\";\n }\n}\n","returncode":0,"stderr":"","license":"mpl-2.0","lang":"VCL"} {"commit":"46d0e91e4df52cbbee3c76d46beeea95f20bbfb3","subject":"Adjusting Varnish to cache most GET requests even when cookies are present","message":"Adjusting Varnish to cache most GET requests even when cookies are present\n","repos":"jakefeasel\/sqlfiddle2,jakefeasel\/sqlfiddle2,alexanderlaw\/sqlfiddle2,alexanderlaw\/sqlfiddle2,alexanderlaw\/sqlfiddle2,alexanderlaw\/sqlfiddle2,alexanderlaw\/sqlfiddle2,jakefeasel\/sqlfiddle2,jakefeasel\/sqlfiddle2","old_file":"src\/main\/resources\/varnish\/default.vcl","new_file":"src\/main\/resources\/varnish\/default.vcl","new_contents":"backend default {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\n\n sub vcl_recv {\n\n if (! (req.url ~ \"^\/openidm\/\") ) {\n set req.url = regsub(req.url, \"^\/\", \"\/sqlfiddle\/\");\n }\n\n if ( req.url == \"\/sqlfiddle\/\") {\n set req.url = \"\/sqlfiddle\/index.html\"; \n }\n\n if (req.request == \"GET\" && req.url != \"\/openidm\/info\/login\") {\n unset req.http.cookie;\n }\n\n }","old_contents":"backend default {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\n\n sub vcl_recv {\n\n if (! (req.url ~ \"^\/openidm\/\") ) {\n set req.url = regsub(req.url, \"^\/\", \"\/sqlfiddle\/\");\n }\n\n if ( req.url == \"\/sqlfiddle\/\") {\n set req.url = \"\/sqlfiddle\/index.html\"; \n }\n }\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"faf3eb0bdabd305f9d3da0660217879cf8b9ad5b","subject":"update port for examples","message":"update port for examples\n","repos":"derbyjs\/candygram","old_file":"varnish_default.vcl","new_file":"varnish_default.vcl","new_contents":"# This is a basic VCL configuration file for varnish. See the vcl(7)\n# man page for details on VCL syntax and semantics.\n\nimport std;\n\n# static\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"4000\";\n}\nbackend examples {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\nbackend components {\n .host = \"127.0.0.1\";\n .port = \"3330\";\n}\n\nsub vcl_recv {\n if (!req.http.Host) {\n error 404 \"Need a host header\";\n }\n\n set req.http.Host = regsub(req.http.Host, \"^www\\.\", \"\");\n set req.http.Host = regsub(req.http.Host, \":80$\", \"\");\n\n if (req.restarts == 0) {\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For =\n req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n if (\n req.http.Host ~ \"^chat\\.\" ||\n req.http.Host ~ \"^charts\\.\" ||\n req.http.Host ~ \"^directory\\.\" ||\n req.http.Host ~ \"^codemirror\\.\" ||\n req.http.Host ~ \"^hello\\.\" ||\n req.http.Host ~ \"^sink\\.\" ||\n req.http.Host ~ \"^todos\\.\" ||\n req.http.Host ~ \"^widgets\\.\"\n ) {\n set req.backend = examples;\n } else if (req.http.Host ~ \"^components\\.\") {\n set req.backend = components;\n }\n\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization || req.http.Cookie) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n return (lookup);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n if (req.http.Origin) {\n hash_data(req.http.Origin);\n }\n return (hash);\n}\n\nsub vcl_pipe {\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n set bereq.http.connection = \"close\";\n # here. It is not set by default as it might break some broken web\n # applications, like IIS with NTLM authentication.\n\n # Websockets\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n\n return (pipe);\n}\n\nsub vcl_fetch {\n # Compress responses\n if (beresp.http.content-type ~ \"text\"\n || beresp.http.content-type ~ \"json\"\n || beresp.http.content-type ~ \"javascript\") {\n set beresp.do_gzip = true;\n }\n}\n\nsub vcl_error {\n if (obj.status == 750) {\n # moved permanently\n set obj.http.Location = req.http.Location;\n set obj.status = 301;\n } else if (obj.status == 752) {\n # moved temporarily\n set obj.http.Location = req.http.Location;\n set obj.status = 302;\n } else {\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic std.fileread(\"\/etc\/varnish\/503.html\");\n }\n return (deliver);\n}\n","old_contents":"# This is a basic VCL configuration file for varnish. See the vcl(7)\n# man page for details on VCL syntax and semantics.\n\nimport std;\n\n# static\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"4000\";\n}\nbackend examples {\n .host = \"127.0.0.1\";\n .port = \"3000\";\n}\nbackend components {\n .host = \"127.0.0.1\";\n .port = \"3330\";\n}\n\nsub vcl_recv {\n if (!req.http.Host) {\n error 404 \"Need a host header\";\n }\n\n set req.http.Host = regsub(req.http.Host, \"^www\\.\", \"\");\n set req.http.Host = regsub(req.http.Host, \":80$\", \"\");\n\n if (req.restarts == 0) {\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For =\n req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n if (\n req.http.Host ~ \"^chat\\.\" ||\n req.http.Host ~ \"^charts\\.\" ||\n req.http.Host ~ \"^directory\\.\" ||\n req.http.Host ~ \"^codemirror\\.\" ||\n req.http.Host ~ \"^hello\\.\" ||\n req.http.Host ~ \"^sink\\.\" ||\n req.http.Host ~ \"^todos\\.\" ||\n req.http.Host ~ \"^widgets\\.\"\n ) {\n set req.backend = examples;\n } else if (req.http.Host ~ \"^components\\.\") {\n set req.backend = components;\n }\n\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization || req.http.Cookie) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n return (lookup);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n if (req.http.Origin) {\n hash_data(req.http.Origin);\n }\n return (hash);\n}\n\nsub vcl_pipe {\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n set bereq.http.connection = \"close\";\n # here. It is not set by default as it might break some broken web\n # applications, like IIS with NTLM authentication.\n\n # Websockets\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n\n return (pipe);\n}\n\nsub vcl_fetch {\n # Compress responses\n if (beresp.http.content-type ~ \"text\"\n || beresp.http.content-type ~ \"json\"\n || beresp.http.content-type ~ \"javascript\") {\n set beresp.do_gzip = true;\n }\n}\n\nsub vcl_error {\n if (obj.status == 750) {\n # moved permanently\n set obj.http.Location = req.http.Location;\n set obj.status = 301;\n } else if (obj.status == 752) {\n # moved temporarily\n set obj.http.Location = req.http.Location;\n set obj.status = 302;\n } else {\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic std.fileread(\"\/etc\/varnish\/503.html\");\n }\n return (deliver);\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"4e9d923fecb497e7accc6d4c1b43848e73536d09","subject":"Revert \"fix cache of images\"","message":"Revert \"fix cache of images\"\n\nThis reverts commit 9cac58ae16a1e12a97ce54f220a84a61c90ebcd7.\n","repos":"ecreall\/nova-ideo,ecreall\/nova-ideo,ecreall\/nova-ideo,ecreall\/nova-ideo,ecreall\/nova-ideo","old_file":"etc\/varnish.vcl","new_file":"etc\/varnish.vcl","new_contents":"# This a configuration file for varnish.\n# It was generated by plone.recipe.varnish.\n# See the vcl(7) man page for details on VCL syntax and semantics.\n#\nvcl 4.0;\n\nimport std;\n\n# configure all backends\nbackend backend_000 {\n .host = \"127.0.0.1\";\n .port = \"5001\";\n .connect_timeout = 0.4s;\n .first_byte_timeout = 300s;\n .between_bytes_timeout = 60s;\n}\n\n\nsub vcl_init {\n\n}\n\nacl purge {\n \"localhost\";\n \"127.0.0.1\";\n}\n\nsub vcl_recv {\n set req.backend_hint = backend_000;\n set req.http.grace = \"none\";\n\n if (req.method == \"PURGE\") {\n # Not from an allowed IP? Then die with an error.\n if (!client.ip ~ purge) {\n return (synth(405, \"This IP is not allowed to send PURGE requests.\"));\n }\n return(purge);\n }\n\n if (req.method == \"BAN\") {\n # Same ACL check as above:\n if (!client.ip ~ purge) {\n return(synth(403, \"Not allowed.\"));\n }\n #ban(\"req.url ~ \" + req.url);\n ban(\"req.http.host == \" + req.http.host +\n \" && req.url == \" + req.url);\n # Throw a synthetic page so the\n # request won't go to the backend.\n return(synth(200, \"Ban added\"));\n }\n\n if (req.method == \"USERINFO\" ||\n req.method == \"CONNECT\" ||\n req.method == \"QUIT\") {\n return (synth(501, \"Not implemented\"));\n }\n\n # Only deal with \"normal\" types\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return(pipe);\n }\n\n # Only cache GET or HEAD requests. This makes sure the POST requests are always passed.\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return(pass);\n }\n\n if (req.http.Expect) {\n return(pipe);\n }\n\n if (req.http.If-None-Match && !req.http.If-Modified-Since) {\n return(pass);\n }\n\n \/* Do not cache other authorized content by default *\/\n if (req.http.Authenticate || req.http.Authorization) {\n return(pass);\n }\n\n if (req.url ~ \"@@registration|@@login|@@resetpassword\") {\n return(pass);\n }\n\n if (req.url ~ \"^[^?]*\\.(css|js|png|gif|jpeg|jpg|woff|woff2)(\\?.*)?$\") {\n unset req.http.Cookie;\n }\n\n if (req.http.Cookie && req.http.Cookie ~ \"auth_tkt\") {\n return(pass);\n }\n\n unset req.http.Accept-Encoding;\n\n return(hash);\n}\n\nsub vcl_pipe {\n # By default Connection: close is set on all piped requests, to stop\n # connection reuse from sending future requests directly to the\n # (potentially) wrong backend. If you do want this to happen, you can undo\n # it here.\n # unset bereq.http.connection;\n\n return(pipe);\n}\n\nsub vcl_pass {\n return (fetch);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n if (req.http.X-Forwarded-Proto) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n return (lookup);\n}\n\nsub vcl_purge {\n return (synth(200, \"Purged\"));\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n \/\/ A pure unadultered hit, deliver it\n # normal hit\n return (deliver);\n }\n\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n if (obj.ttl + obj.grace > 0s) {\n set req.http.grace = \"normal(limited)\";\n return (deliver);\n }\n\n if (req.method == \"PURGE\") {\n set req.method = \"GET\";\n set req.http.X-purger = \"Purged\";\n return(synth(200, \"Purged. in hit \" + req.url));\n }\n\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\nsub vcl_miss {\n if (req.method == \"PURGE\") {\n set req.method = \"GET\";\n set req.http.X-purger = \"Purged-possibly\";\n return(synth(200, \"Purged. in miss \" + req.url));\n }\n\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\nsub vcl_backend_fetch{\n return (fetch);\n}\n\nsub vcl_backend_response {\n # The object is not cacheable\n if (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO - Set Cookie\";\n set beresp.ttl = 0s;\n set beresp.uncacheable = true;\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO - Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = 120s;\n } elsif (beresp.http.Surrogate-control ~ \"no-store\") {\n set beresp.http.X-Cacheable = \"NO - Surrogate-control=no-store\";\n set beresp.uncacheable = true;\n set beresp.ttl = 120s;\n } elsif (!beresp.http.Surrogate-Control && beresp.http.Cache-Control ~ \"no-cache|no-store\") {\n set beresp.http.X-Cacheable = \"NO - Cache-Control=no-cache|no-store\";\n set beresp.uncacheable = true;\n set beresp.ttl = 120s;\n } elsif (beresp.http.Vary == \"*\") {\n set beresp.http.X-Cacheable = \"NO - Vary=*\";\n set beresp.uncacheable = true;\n set beresp.ttl = 120s;\n\n\n # ttl handling\n } elsif (beresp.ttl < 0s) {\n set beresp.http.X-Cacheable = \"NO - TTL < 0\";\n set beresp.uncacheable = true;\n } elsif (beresp.ttl == 0s) {\n if (bereq.http.Cookie && bereq.http.Cookie ~ \"auth_tkt\") {\n set beresp.http.X-Cacheable = \"NO - TTL = 0\";\n set beresp.uncacheable = true;\n } else {\n set beresp.http.X-Cacheable = \"YES, 3600s\";\n set beresp.ttl = 3600s;\n set beresp.grace = 36000s;\n }\n\n # Varnish determined the object was cacheable\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n\n# https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleLongerCaching\n if (beresp.ttl == 31536000s) { # for deform.js, jquery.form-3.09.js from deformstatic\n \/* Remove Expires from backend, it's too long *\/\n unset beresp.http.expires;\n\n \/* Set the clients TTL on this object *\/\n set beresp.http.cache-control = \"max-age=86400\";\n\n \/* Set how long Varnish will keep it *\/\n set beresp.ttl = 86400s;\n }\n\n # Do not cache 5xx errors\n if (beresp.status >= 500 && beresp.status < 600) {\n unset beresp.http.Cache-Control;\n set beresp.http.X-Cache = \"NOCACHE\";\n set beresp.http.Cache-Control = \"no-cache, max-age=0, must-revalidate\";\n set beresp.ttl = 0s;\n set beresp.http.Pragma = \"no-cache\";\n set beresp.uncacheable = true;\n return(deliver);\n }\n\n return (deliver);\n}\n\nsub vcl_deliver {\n set resp.http.grace = req.http.grace;\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n \/* Rewrite s-maxage to exclude from intermediary proxies\n (to cache *everywhere*, just use 'max-age' token in the response to avoid\n this override) *\/\n if (resp.http.Cache-Control ~ \"s-maxage\") {\n set resp.http.Cache-Control = regsub(resp.http.Cache-Control, \"s-maxage=[0-9]+\", \"s-maxage=0\");\n }\n \/* Remove proxy-revalidate for intermediary proxies *\/\n if (resp.http.Cache-Control ~ \", proxy-revalidate\") {\n set resp.http.Cache-Control = regsub(resp.http.Cache-Control, \", proxy-revalidate\", \"\");\n }\n\n unset resp.http.Server;\n\n}\n\n\/*\n We can come here \"invisibly\" with the following errors: 413, 417 & 503\n*\/\nsub vcl_synth {\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n set resp.http.Retry-After = \"5\";\n\n synthetic( {\"\n <?xml version=\"1.0\" encoding=\"utf-8\"?>\n <!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n <html>\n <head>\n <title>Varnish cache server: \"} + resp.status + \" \" + resp.reason + {\" <\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n <\/html>\n \"} );\n\n return (deliver);\n}\n","old_contents":"# This a configuration file for varnish.\n# It was generated by plone.recipe.varnish.\n# See the vcl(7) man page for details on VCL syntax and semantics.\n#\nvcl 4.0;\n\nimport std;\n\n# configure all backends\nbackend backend_000 {\n .host = \"127.0.0.1\";\n .port = \"5001\";\n .connect_timeout = 0.4s;\n .first_byte_timeout = 300s;\n .between_bytes_timeout = 60s;\n}\n\n\nsub vcl_init {\n\n}\n\nacl purge {\n \"localhost\";\n \"127.0.0.1\";\n}\n\nsub vcl_recv {\n set req.backend_hint = backend_000;\n set req.http.grace = \"none\";\n\n if (req.method == \"PURGE\") {\n # Not from an allowed IP? Then die with an error.\n if (!client.ip ~ purge) {\n return (synth(405, \"This IP is not allowed to send PURGE requests.\"));\n }\n return(purge);\n }\n\n if (req.method == \"BAN\") {\n # Same ACL check as above:\n if (!client.ip ~ purge) {\n return(synth(403, \"Not allowed.\"));\n }\n #ban(\"req.url ~ \" + req.url);\n ban(\"req.http.host == \" + req.http.host +\n \" && req.url == \" + req.url);\n # Throw a synthetic page so the\n # request won't go to the backend.\n return(synth(200, \"Ban added\"));\n }\n\n if (req.method == \"USERINFO\" ||\n req.method == \"CONNECT\" ||\n req.method == \"QUIT\") {\n return (synth(501, \"Not implemented\"));\n }\n\n # Only deal with \"normal\" types\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return(pipe);\n }\n\n # Only cache GET or HEAD requests. This makes sure the POST requests are always passed.\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return(pass);\n }\n\n if (req.http.Expect) {\n return(pipe);\n }\n\n if (req.http.If-None-Match && !req.http.If-Modified-Since) {\n return(pass);\n }\n\n \/* Do not cache other authorized content by default *\/\n if (req.http.Authenticate || req.http.Authorization) {\n return(pass);\n }\n\n if (req.url ~ \"@@registration|@@login|@@resetpassword\") {\n return(pass);\n }\n\n if (req.url ~ \"^[^?]*\\.(css|js|png|png\/|gif|gif\/|jpeg|jpeg\/|jpg|jpg\/|small\/|medium\/|large\/|xlarge\/|woff|woff2)(\\?.*)?$\") {\n unset req.http.Cookie;\n }\n\n if (req.http.Cookie && req.http.Cookie ~ \"auth_tkt\") {\n return(pass);\n }\n\n unset req.http.Accept-Encoding;\n\n return(hash);\n}\n\nsub vcl_pipe {\n # By default Connection: close is set on all piped requests, to stop\n # connection reuse from sending future requests directly to the\n # (potentially) wrong backend. If you do want this to happen, you can undo\n # it here.\n # unset bereq.http.connection;\n\n return(pipe);\n}\n\nsub vcl_pass {\n return (fetch);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n if (req.http.X-Forwarded-Proto) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n return (lookup);\n}\n\nsub vcl_purge {\n return (synth(200, \"Purged\"));\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n \/\/ A pure unadultered hit, deliver it\n # normal hit\n return (deliver);\n }\n\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n if (obj.ttl + obj.grace > 0s) {\n set req.http.grace = \"normal(limited)\";\n return (deliver);\n }\n\n if (req.method == \"PURGE\") {\n set req.method = \"GET\";\n set req.http.X-purger = \"Purged\";\n return(synth(200, \"Purged. in hit \" + req.url));\n }\n\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\nsub vcl_miss {\n if (req.method == \"PURGE\") {\n set req.method = \"GET\";\n set req.http.X-purger = \"Purged-possibly\";\n return(synth(200, \"Purged. in miss \" + req.url));\n }\n\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\nsub vcl_backend_fetch{\n return (fetch);\n}\n\nsub vcl_backend_response {\n # The object is not cacheable\n if (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO - Set Cookie\";\n set beresp.ttl = 0s;\n set beresp.uncacheable = true;\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO - Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = 120s;\n } elsif (beresp.http.Surrogate-control ~ \"no-store\") {\n set beresp.http.X-Cacheable = \"NO - Surrogate-control=no-store\";\n set beresp.uncacheable = true;\n set beresp.ttl = 120s;\n } elsif (!beresp.http.Surrogate-Control && beresp.http.Cache-Control ~ \"no-cache|no-store\") {\n set beresp.http.X-Cacheable = \"NO - Cache-Control=no-cache|no-store\";\n set beresp.uncacheable = true;\n set beresp.ttl = 120s;\n } elsif (beresp.http.Vary == \"*\") {\n set beresp.http.X-Cacheable = \"NO - Vary=*\";\n set beresp.uncacheable = true;\n set beresp.ttl = 120s;\n\n\n # ttl handling\n } elsif (beresp.ttl < 0s) {\n set beresp.http.X-Cacheable = \"NO - TTL < 0\";\n set beresp.uncacheable = true;\n } elsif (beresp.ttl == 0s) {\n if (bereq.http.Cookie && bereq.http.Cookie ~ \"auth_tkt\") {\n set beresp.http.X-Cacheable = \"NO - TTL = 0\";\n set beresp.uncacheable = true;\n } else {\n set beresp.http.X-Cacheable = \"YES, 3600s\";\n set beresp.ttl = 3600s;\n set beresp.grace = 36000s;\n }\n\n # Varnish determined the object was cacheable\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n\n# https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleLongerCaching\n if (beresp.ttl == 31536000s) { # for deform.js, jquery.form-3.09.js from deformstatic\n \/* Remove Expires from backend, it's too long *\/\n unset beresp.http.expires;\n\n \/* Set the clients TTL on this object *\/\n set beresp.http.cache-control = \"max-age=86400\";\n\n \/* Set how long Varnish will keep it *\/\n set beresp.ttl = 86400s;\n }\n\n # Do not cache 5xx errors\n if (beresp.status >= 500 && beresp.status < 600) {\n unset beresp.http.Cache-Control;\n set beresp.http.X-Cache = \"NOCACHE\";\n set beresp.http.Cache-Control = \"no-cache, max-age=0, must-revalidate\";\n set beresp.ttl = 0s;\n set beresp.http.Pragma = \"no-cache\";\n set beresp.uncacheable = true;\n return(deliver);\n }\n\n return (deliver);\n}\n\nsub vcl_deliver {\n set resp.http.grace = req.http.grace;\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n \/* Rewrite s-maxage to exclude from intermediary proxies\n (to cache *everywhere*, just use 'max-age' token in the response to avoid\n this override) *\/\n if (resp.http.Cache-Control ~ \"s-maxage\") {\n set resp.http.Cache-Control = regsub(resp.http.Cache-Control, \"s-maxage=[0-9]+\", \"s-maxage=0\");\n }\n \/* Remove proxy-revalidate for intermediary proxies *\/\n if (resp.http.Cache-Control ~ \", proxy-revalidate\") {\n set resp.http.Cache-Control = regsub(resp.http.Cache-Control, \", proxy-revalidate\", \"\");\n }\n\n unset resp.http.Server;\n\n}\n\n\/*\n We can come here \"invisibly\" with the following errors: 413, 417 & 503\n*\/\nsub vcl_synth {\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n set resp.http.Retry-After = \"5\";\n\n synthetic( {\"\n <?xml version=\"1.0\" encoding=\"utf-8\"?>\n <!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n <html>\n <head>\n <title>Varnish cache server: \"} + resp.status + \" \" + resp.reason + {\" <\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n <\/html>\n \"} );\n\n return (deliver);\n}\n","returncode":0,"stderr":"","license":"agpl-3.0","lang":"VCL"} {"commit":"b7397daa84be91b5b2191a37ae14ec21459af26c","subject":"remove example vcl","message":"remove example vcl\n","repos":"nytm\/varnish-mmdb-vmod,nytm\/varnish-mmdb-vmod,nytm\/varnish-mmdb-vmod","old_file":"geo-example.vcl","new_file":"geo-example.vcl","new_contents":"","old_contents":"# This is a basic VCL configuration file for varnish. See the vcl(7)\n# man page for details on VCL syntax and semantics.\n# \n# Default backend definition. Set this to point to your content\n# server.\n# \nbackend default {\n .host = \"www.varnish-cache.org\";\n .port = \"80\";\n}\nimport geo;\nimport std;\n\nsub vcl_recv{\n if (req.restarts == 0) {\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For =\n req.http.x-real-ip + \", \" + req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = req.http.x-real-ip + \", \" + client.ip;\n }\n }\n if (req.url ~ \"\/svc\/location\/v1\/current.json\") {\n set req.http.IP = regsuball(req.http.X-Forwarded-For, \",.*\", \"\");\n return (error);\n }\n \/\/ logic to do weather based on IP or NYT-W2 cookie\n if ((req.url ~ \"\/svc\/weather\/v2\/current.json\") || (req.url ~ \"\/svc\/weather\/v2\/current-and-five-day-forecast.json\") || (req.url ~ \"\/svc\/weather\/v2\/current-and-seven-day-forecast.json\")) {\n if (req.restarts == 0) {\n if (req.http.Cookie ~ \"NYT_W2=[a-zA-Z0-9%:\\-|]+\") {\n set req.http.X-Weather = geo.get_weather_cookie(req.http.Cookie, \"NYT_W2\");\n set req.url = regsub(req.url, \".json\", \"\/\" + req.http.X-Weather + \".json\");\n set req.url = regsub(req.url, \" \", \"%20\");\n } else {\n \/\/ i think we want the first forwarded for ip.\n if (req.http.X-Forwarded-For ~ \",\") {\n if (!req.http.IP) {\n set req.http.IP = regsuball(req.http.X-Forwarded-For, \",.*\", \"\");\n }\n } else {\n if (!req.http.IP) {\n set req.http.IP = req.http.x-real-ip;\n }\n }\n set req.http.X-Weather = geo.weather_code(req.http.IP);\n set req.http.X-Weather = regsuball(req.http.X-Weather, \" \", \"%20\");\n set req.http.X-Timezone = geo.timezone(req.http.IP);\n set req.url = regsub(req.url, \".json\", \"\/\" + req.http.X-Weather + \".json\");\n }\n }\n }\n}\n\nsub vcl_error {\n if (req.url ~ \"\/svc\/location\/v1\/current.json\") {\n set obj.http.Content-Type = \"text\/json; charset=utf-8\";\n synthetic \n geo.location(req.http.IP)\n ; \n return (deliver);\n } \n}","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"fd4c963f51e1c0d4485ad6a4ddc09b6ade7df955","subject":"Fastly PASS for uncacheable Journal content","message":"Fastly PASS for uncacheable Journal content\n","repos":"elifesciences\/builder,elifesciences\/builder","old_file":"src\/buildercore\/fastly\/vcl\/strip-non-journal-cookies.vcl","new_file":"src\/buildercore\/fastly\/vcl\/strip-non-journal-cookies.vcl","new_contents":"","old_contents":"","returncode":0,"stderr":"unknown","license":"mit","lang":"VCL"} {"commit":"afc5d33c789237e79949d77f1a08c1ca1ac8866b","subject":"Remove unused endpoints.","message":"Remove unused endpoints.\n\n- report removed in this\n [commit](https:\/\/github.com\/reddit\/reddit-mobile\/commit\/3af0b33161df61231387292fa61470fa9e1597b3#diff-79dad35511a55ef6ebdf34a68b034bdfL49)\n- vote removed in this\n [commit](https:\/\/github.com\/reddit\/reddit-mobile\/commit\/d0cda057c9da770bf0339546d4a1d947855d1cdb#diff-79dad35511a55ef6ebdf34a68b034bdfL53)\n","repos":"ajacksified\/reddit-mobile,ajacksified\/reddit-mobile,ajacksified\/reddit-mobile,ajacksified\/reddit-mobile","old_file":"default.vcl","new_file":"default.vcl","new_contents":"backend mweb {\n .host = \"mweb\";\n .port = \"4444\";\n}\n\/* backend www {\n .host = \"www.reddit.com\";\n .port = \"80\";\n} *\/\n\n\nsub vcl_recv {\n call device_detect;\n\n # Check mweb override cookie.\n if (req.http.Cookie ~ \"(^|;\\s*)(mweb-no-redirect=1)(;|$)\") {\n call set_www_backend;\n } elsif (\n (req.http.X-UA-Device ~ \"^mobile-\" || req.http.X-UA-Device ~ \"^tablet-\")\n # We don't host endpoints with extensions in mweb.\n # The Fastly equivalent is: && !req.url.ext\n && !reg.url ~ \"\\\/.+\\.[a-z]{3,4}(\\?.*|$)\"\n && (\n # Blacklisted endpoints\n # This endpoint 200's for mweb, but the current implementation has issues\n req.url !~ \"^\/message\/compose\/?$\"\n )\n && (\n # Whitelisted 2X endpoints from router\/index.js\n req.url == \"\/\"\n || req.url ~ \"^\/actions\/\"\n || req.url ~ \"^\/comments\/?\"\n || req.url ~ \"^\/login\/?$\"\n || req.url ~ \"^\/message\/\"\n || req.url ~ \"^\/r\/\"\n || req.url ~ \"^\/register\/?$\"\n || req.url ~ \"^\/search\/?$\"\n || req.url ~ \"^\/submit\/?$\"\n || req.url ~ \"^\/submit_to_community\/?$\"\n || req.url ~ \"^\/u\/\"\n || req.url ~ \"^\/user\/\"\n || req.url ~ \"^\/(help|w|wiki)\/?\"\n # Whitelisted 2X Ajax endpoints\n || req.url ~ \"^\/csp-report$\"\n || req.url == \"\/error\"\n || req.url ~ \"^\/(login|refresh|register)proxy$\"\n || req.url ~ \"^\/logout\"\n || req.url == \"\/routes\"\n || req.url ~ \"^\/timings$\"\n || req.url ~ \"^\/(u\/)?XXX\\?.*\"\n # Whitelisted dev endpoints (these will be hosted on www in production)\n || req.url == \"\/apple-app-site-association\"\n || req.url ~ \"^\/favicon\/\"\n || req.url ~ \"^\/favicon\\.ico\"\n || req.url ~ \"^\/fonts\/\"\n || req.url == \"\/health\"\n || req.url ~ \"^\/img\/\"\n || req.url ~ \"^\/ProductionClient\\..*\\.(css|js)$\"\n || req.url == \"\/robots.txt\"\n )) {\n # If it's a mobile device and a whitelisted endpoint, use mweb.\n set req.backend = mweb;\n } else {\n call set_www_backend;\n }\n}\n\n\nsub set_www_backend {\n # NOTE(wting|2016-09-26): Normally we would redirect the user to a different\n # backend, but instead we're using a 400 status code for easy programmatic testing.\n error 400;\n # set req.backend = www;\n}\n\n\n# Vendorized from https:\/\/github.com\/varnish\/varnish-devicedetect\/blob\/master\/devicedetect.vcl\n# BSD-2 License\nsub device_detect {\n unset req.http.X-UA-Device;\n set req.http.X-UA-Device = \"pc\";\n\n # Handle that a cookie may override the detection alltogether.\n if (req.http.Cookie ~ \"(?i)X-UA-Device-force\") {\n \/* ;?? means zero or one ;, non-greedy to match the first. *\/\n set req.http.X-UA-Device = regsub(req.http.Cookie, \"(?i).*X-UA-Device-force=([^;]+);??.*\", \"\\1\");\n \/* Clean up our mess in the cookie header *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \"(^|; ) *X-UA-Device-force=[^;]+;? *\", \"\\1\");\n \/* If the cookie header is now empty, or just whitespace, unset it. *\/\n if (req.http.Cookie ~ \"^ *$\") {\n unset req.http.Cookie;\n }\n } else {\n if (req.http.User-Agent ~ \"\\(compatible; Googlebot-Mobile\/2.1; \\+http:\/\/www.google.com\/bot.html\\)\"\n || (req.http.User-Agent ~ \"(Android|iPhone)\"\n && req.http.User-Agent ~ \"\\(compatible.?; Googlebot\/2.1.?; \\+http:\/\/www.google.com\/bot.html\")\n || (req.http.User-Agent ~ \"(iPhone|Windows Phone)\"\n && req.http.User-Agent ~ \"\\(compatible; bingbot\/2.0; \\+http:\/\/www.bing.com\/bingbot.htm\")\n ) {\n set req.http.X-UA-Device = \"mobile-bot\";\n } elsif (req.http.User-Agent ~ \"(?i)(ads|google|bing|msn|yandex|baidu|ro|career|seznam|)bot\"\n || req.http.User-Agent ~ \"(?i)(baidu|jike|symantec)spider\"\n || req.http.User-Agent ~ \"(?i)scanner\"\n || req.http.User-Agent ~ \"(?i)(web)crawler\"\n ) {\n set req.http.X-UA-Device = \"bot\";\n } elsif (req.http.User-Agent ~ \"(?i)ipad\") {\n set req.http.X-UA-Device = \"tablet-ipad\";\n } elsif (req.http.User-Agent ~ \"(?i)ip(hone|od)\") {\n set req.http.X-UA-Device = \"mobile-iphone\";\n } elsif (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") {\n \/* how do we differ between an android phone and an android tablet? *\/\n \/* http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent *\/\n set req.http.X-UA-Device = \"mobile-android\";\n }\n elsif (req.http.User-Agent ~ \"(?i)android 3\") {\n \/* https:\/\/github.com\/varnish\/varnish-devicedetect\/blob\/master\/devicedetect.vcl *\/\n set req.http.X-UA-Device = \"tablet-android\";\n } elsif (req.http.User-Agent ~ \"Opera Mobi\") {\n \/* Opera Mobile *\/\n set req.http.X-UA-Device = \"mobile-smartphone\";\n }\n elsif (req.http.User-Agent ~ \"(?i)android\") {\n \/* May very well give false positives towards android tablets. Suggestions welcome. *\/\n set req.http.X-UA-Device = \"tablet-android\";\n } elsif (req.http.User-Agent ~ \"PlayBook; U; RIM Tablet\") {\n set req.http.X-UA-Device = \"tablet-rim\";\n } elsif (req.http.User-Agent ~ \"hp-tablet.*TouchPad\") {\n set req.http.X-UA-Device = \"tablet-hp\";\n } elsif (req.http.User-Agent ~ \"Kindle\/3\") {\n set req.http.X-UA-Device = \"tablet-kindle\";\n } elsif (req.http.User-Agent ~ \"Touch.+Tablet PC\" || req.http.User-Agent ~ \"Windows NT [0-9.]+; ARM;\" ) {\n set req.http.X-UA-Device = \"tablet-microsoft\";\n } elsif (req.http.User-Agent ~ \"Mobile.+Firefox\") {\n set req.http.X-UA-Device = \"mobile-firefoxos\";\n } elsif (req.http.User-Agent ~ \"^HTC\"\n || req.http.User-Agent ~ \"Fennec\"\n || req.http.User-Agent ~ \"IEMobile\"\n || req.http.User-Agent ~ \"BlackBerry\"\n || req.http.User-Agent ~ \"BB10.*Mobile\"\n || req.http.User-Agent ~ \"GT-.*Build\/GINGERBREAD\"\n || req.http.User-Agent ~ \"SymbianOS.*AppleWebKit\") {\n set req.http.X-UA-Device = \"mobile-smartphone\";\n }\n elsif (req.http.User-Agent ~ \"(?i)symbian\"\n || req.http.User-Agent ~ \"(?i)^sonyericsson\"\n || req.http.User-Agent ~ \"(?i)^nokia\"\n || req.http.User-Agent ~ \"(?i)^samsung\"\n || req.http.User-Agent ~ \"(?i)^lg\"\n || req.http.User-Agent ~ \"(?i)bada\"\n || req.http.User-Agent ~ \"(?i)blazer\"\n || req.http.User-Agent ~ \"(?i)cellphone\"\n || req.http.User-Agent ~ \"(?i)iemobile\"\n || req.http.User-Agent ~ \"(?i)midp-2.0\"\n || req.http.User-Agent ~ \"(?i)u990\"\n || req.http.User-Agent ~ \"(?i)netfront\"\n || req.http.User-Agent ~ \"(?i)opera mini\"\n || req.http.User-Agent ~ \"(?i)palm\"\n || req.http.User-Agent ~ \"(?i)nintendo wii\"\n || req.http.User-Agent ~ \"(?i)playstation portable\"\n || req.http.User-Agent ~ \"(?i)portalmmm\"\n || req.http.User-Agent ~ \"(?i)proxinet\"\n || req.http.User-Agent ~ \"(?i)sonyericsson\"\n || req.http.User-Agent ~ \"(?i)symbian\"\n || req.http.User-Agent ~ \"(?i)windows\\ ?ce\"\n || req.http.User-Agent ~ \"(?i)winwap\"\n || req.http.User-Agent ~ \"(?i)eudoraweb\"\n || req.http.User-Agent ~ \"(?i)htc\"\n || req.http.User-Agent ~ \"(?i)240x320\"\n || req.http.User-Agent ~ \"(?i)avantgo\") {\n set req.http.X-UA-Device = \"mobile-generic\";\n }\n }\n}\n","old_contents":"backend mweb {\n .host = \"mweb\";\n .port = \"4444\";\n}\n\/* backend www {\n .host = \"www.reddit.com\";\n .port = \"80\";\n} *\/\n\n\nsub vcl_recv {\n call device_detect;\n\n # Check mweb override cookie.\n if (req.http.Cookie ~ \"(^|;\\s*)(mweb-no-redirect=1)(;|$)\") {\n call set_www_backend;\n } elsif (\n (req.http.X-UA-Device ~ \"^mobile-\" || req.http.X-UA-Device ~ \"^tablet-\")\n # We don't host endpoints with extensions in mweb.\n # The Fastly equivalent is: && !req.url.ext\n && !reg.url ~ \"\\\/.+\\.[a-z]{3,4}(\\?.*|$)\"\n && (\n # Blacklisted endpoints\n # This endpoint 200's for mweb, but the current implementation has issues\n req.url !~ \"^\/message\/compose\/?$\"\n )\n && (\n # Whitelisted 2X endpoints from router\/index.js\n req.url == \"\/\"\n || req.url ~ \"^\/actions\/\"\n || req.url ~ \"^\/comments\/?\"\n || req.url ~ \"^\/login\/?$\"\n || req.url ~ \"^\/message\/\"\n || req.url ~ \"^\/r\/\"\n || req.url ~ \"^\/register\/?$\"\n || req.url ~ \"^\/report\/?$\"\n || req.url ~ \"^\/search\/?$\"\n || req.url ~ \"^\/submit\/?$\"\n || req.url ~ \"^\/submit_to_community\/?$\"\n || req.url ~ \"^\/u\/\"\n || req.url ~ \"^\/user\/\"\n || req.url ~ \"^\/vote\/\"\n || req.url ~ \"^\/(help|w|wiki)\/?\"\n # Whitelisted 2X Ajax endpoints\n || req.url ~ \"^\/csp-report$\"\n || req.url == \"\/error\"\n || req.url ~ \"^\/(login|refresh|register)proxy$\"\n || req.url ~ \"^\/logout\"\n || req.url == \"\/routes\"\n || req.url ~ \"^\/timings$\"\n || req.url ~ \"^\/(u\/)?XXX\\?.*\"\n # Whitelisted dev endpoints (these will be hosted on www in production)\n || req.url == \"\/apple-app-site-association\"\n || req.url ~ \"^\/favicon\/\"\n || req.url ~ \"^\/favicon\\.ico\"\n || req.url ~ \"^\/fonts\/\"\n || req.url == \"\/health\"\n || req.url ~ \"^\/img\/\"\n || req.url ~ \"^\/ProductionClient\\..*\\.(css|js)$\"\n || req.url == \"\/robots.txt\"\n )) {\n # If it's a mobile device and a whitelisted endpoint, use mweb.\n set req.backend = mweb;\n } else {\n call set_www_backend;\n }\n}\n\n\nsub set_www_backend {\n # NOTE(wting|2016-09-26): Normally we would redirect the user to a different\n # backend, but instead we're using a 400 status code for easy programmatic testing.\n error 400;\n # set req.backend = www;\n}\n\n\n# Vendorized from https:\/\/github.com\/varnish\/varnish-devicedetect\/blob\/master\/devicedetect.vcl\n# BSD-2 License\nsub device_detect {\n unset req.http.X-UA-Device;\n set req.http.X-UA-Device = \"pc\";\n\n # Handle that a cookie may override the detection alltogether.\n if (req.http.Cookie ~ \"(?i)X-UA-Device-force\") {\n \/* ;?? means zero or one ;, non-greedy to match the first. *\/\n set req.http.X-UA-Device = regsub(req.http.Cookie, \"(?i).*X-UA-Device-force=([^;]+);??.*\", \"\\1\");\n \/* Clean up our mess in the cookie header *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \"(^|; ) *X-UA-Device-force=[^;]+;? *\", \"\\1\");\n \/* If the cookie header is now empty, or just whitespace, unset it. *\/\n if (req.http.Cookie ~ \"^ *$\") {\n unset req.http.Cookie;\n }\n } else {\n if (req.http.User-Agent ~ \"\\(compatible; Googlebot-Mobile\/2.1; \\+http:\/\/www.google.com\/bot.html\\)\"\n || (req.http.User-Agent ~ \"(Android|iPhone)\"\n && req.http.User-Agent ~ \"\\(compatible.?; Googlebot\/2.1.?; \\+http:\/\/www.google.com\/bot.html\")\n || (req.http.User-Agent ~ \"(iPhone|Windows Phone)\"\n && req.http.User-Agent ~ \"\\(compatible; bingbot\/2.0; \\+http:\/\/www.bing.com\/bingbot.htm\")\n ) {\n set req.http.X-UA-Device = \"mobile-bot\";\n } elsif (req.http.User-Agent ~ \"(?i)(ads|google|bing|msn|yandex|baidu|ro|career|seznam|)bot\"\n || req.http.User-Agent ~ \"(?i)(baidu|jike|symantec)spider\"\n || req.http.User-Agent ~ \"(?i)scanner\"\n || req.http.User-Agent ~ \"(?i)(web)crawler\"\n ) {\n set req.http.X-UA-Device = \"bot\";\n } elsif (req.http.User-Agent ~ \"(?i)ipad\") {\n set req.http.X-UA-Device = \"tablet-ipad\";\n } elsif (req.http.User-Agent ~ \"(?i)ip(hone|od)\") {\n set req.http.X-UA-Device = \"mobile-iphone\";\n } elsif (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") {\n \/* how do we differ between an android phone and an android tablet? *\/\n \/* http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent *\/\n set req.http.X-UA-Device = \"mobile-android\";\n }\n elsif (req.http.User-Agent ~ \"(?i)android 3\") {\n \/* https:\/\/github.com\/varnish\/varnish-devicedetect\/blob\/master\/devicedetect.vcl *\/\n set req.http.X-UA-Device = \"tablet-android\";\n } elsif (req.http.User-Agent ~ \"Opera Mobi\") {\n \/* Opera Mobile *\/\n set req.http.X-UA-Device = \"mobile-smartphone\";\n }\n elsif (req.http.User-Agent ~ \"(?i)android\") {\n \/* May very well give false positives towards android tablets. Suggestions welcome. *\/\n set req.http.X-UA-Device = \"tablet-android\";\n } elsif (req.http.User-Agent ~ \"PlayBook; U; RIM Tablet\") {\n set req.http.X-UA-Device = \"tablet-rim\";\n } elsif (req.http.User-Agent ~ \"hp-tablet.*TouchPad\") {\n set req.http.X-UA-Device = \"tablet-hp\";\n } elsif (req.http.User-Agent ~ \"Kindle\/3\") {\n set req.http.X-UA-Device = \"tablet-kindle\";\n } elsif (req.http.User-Agent ~ \"Touch.+Tablet PC\" || req.http.User-Agent ~ \"Windows NT [0-9.]+; ARM;\" ) {\n set req.http.X-UA-Device = \"tablet-microsoft\";\n } elsif (req.http.User-Agent ~ \"Mobile.+Firefox\") {\n set req.http.X-UA-Device = \"mobile-firefoxos\";\n } elsif (req.http.User-Agent ~ \"^HTC\"\n || req.http.User-Agent ~ \"Fennec\"\n || req.http.User-Agent ~ \"IEMobile\"\n || req.http.User-Agent ~ \"BlackBerry\"\n || req.http.User-Agent ~ \"BB10.*Mobile\"\n || req.http.User-Agent ~ \"GT-.*Build\/GINGERBREAD\"\n || req.http.User-Agent ~ \"SymbianOS.*AppleWebKit\") {\n set req.http.X-UA-Device = \"mobile-smartphone\";\n }\n elsif (req.http.User-Agent ~ \"(?i)symbian\"\n || req.http.User-Agent ~ \"(?i)^sonyericsson\"\n || req.http.User-Agent ~ \"(?i)^nokia\"\n || req.http.User-Agent ~ \"(?i)^samsung\"\n || req.http.User-Agent ~ \"(?i)^lg\"\n || req.http.User-Agent ~ \"(?i)bada\"\n || req.http.User-Agent ~ \"(?i)blazer\"\n || req.http.User-Agent ~ \"(?i)cellphone\"\n || req.http.User-Agent ~ \"(?i)iemobile\"\n || req.http.User-Agent ~ \"(?i)midp-2.0\"\n || req.http.User-Agent ~ \"(?i)u990\"\n || req.http.User-Agent ~ \"(?i)netfront\"\n || req.http.User-Agent ~ \"(?i)opera mini\"\n || req.http.User-Agent ~ \"(?i)palm\"\n || req.http.User-Agent ~ \"(?i)nintendo wii\"\n || req.http.User-Agent ~ \"(?i)playstation portable\"\n || req.http.User-Agent ~ \"(?i)portalmmm\"\n || req.http.User-Agent ~ \"(?i)proxinet\"\n || req.http.User-Agent ~ \"(?i)sonyericsson\"\n || req.http.User-Agent ~ \"(?i)symbian\"\n || req.http.User-Agent ~ \"(?i)windows\\ ?ce\"\n || req.http.User-Agent ~ \"(?i)winwap\"\n || req.http.User-Agent ~ \"(?i)eudoraweb\"\n || req.http.User-Agent ~ \"(?i)htc\"\n || req.http.User-Agent ~ \"(?i)240x320\"\n || req.http.User-Agent ~ \"(?i)avantgo\") {\n set req.http.X-UA-Device = \"mobile-generic\";\n }\n }\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"23f7060c5a08630bdfb7d840fbcd9d038883fbec","subject":"Guard against missing x-pass Request Setting","message":"Guard against missing x-pass Request Setting\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets\/fetch.vcl","new_file":"etc\/vcl_snippets\/fetch.vcl","new_contents":" \/* handle 5XX (or any other unwanted status code) *\/\n if (beresp.status >= 500 && beresp.status < 600) {\n\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n \/* deliver stale if the object is available *\/\n if (stale.exists) {\n return(deliver_stale);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n \/* else go to vcl_error to deliver a synthetic *\/\n error beresp.status beresp.response;\n }\n\n # Remove Set-Cookies from responses for static content\n # to match the cookie removal in recv.\n if (req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's since those can be temporary during the site build\/index\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n }\n\n }\n\n if (beresp.http.Content-Type ~ \"text\/(html|xml)\") {\n # enable ESI feature for Magento response by default\n esi;\n if (!beresp.http.Vary ~ \"X-Magento-Vary,Https\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \",X-Magento-Vary,Https\";\n } else {\n set beresp.http.Vary = \"X-Magento-Vary,Https\";\n }\n }\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content\n if (http_status_matches(beresp.status, \"200,404\") && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url.ext ~ \"(?i)(css|js|html|eot|ico|otf|ttf|json)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n if (beresp.http.Cache-Control ~ \"private|no-cache|no-store\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # Never cache 302s\n if (beresp.status == 302) {\n return (pass);\n }\n\n # Just in case the Request Setting for x-pass is missing\n if (req.http.x-pass) {\n return (pass);\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\") && !req.http.x-pass ) {\n unset beresp.http.set-cookie;\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type if they are image\/script or CSS\n if (beresp.http.Content-Type ~ \"(image|script|css)\") {\n set beresp.http.Surrogate-Key = re.group.1;\n }\n return (deliver);\n }\n","old_contents":" \/* handle 5XX (or any other unwanted status code) *\/\n if (beresp.status >= 500 && beresp.status < 600) {\n\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n \/* deliver stale if the object is available *\/\n if (stale.exists) {\n return(deliver_stale);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n \/* else go to vcl_error to deliver a synthetic *\/\n error beresp.status beresp.response;\n }\n\n # Remove Set-Cookies from responses for static content\n # to match the cookie removal in recv.\n if (req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's since those can be temporary during the site build\/index\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n }\n\n }\n\n if (beresp.http.Content-Type ~ \"text\/(html|xml)\") {\n # enable ESI feature for Magento response by default\n esi;\n if (!beresp.http.Vary ~ \"X-Magento-Vary,Https\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \",X-Magento-Vary,Https\";\n } else {\n set beresp.http.Vary = \"X-Magento-Vary,Https\";\n }\n }\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content\n if (http_status_matches(beresp.status, \"200,404\") && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url.ext ~ \"(?i)(css|js|html|eot|ico|otf|ttf|json)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n if (beresp.http.Cache-Control ~ \"private|no-cache|no-store\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # Never cache 302s\n if (beresp.status == 302) {\n return (pass);\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\") && !req.http.x-pass ) {\n unset beresp.http.set-cookie;\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type if they are image\/script or CSS\n if (beresp.http.Content-Type ~ \"(image|script|css)\") {\n set beresp.http.Surrogate-Key = re.group.1;\n }\n return (deliver);\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"3bb83beb8593ef970bb397669782549f2ca0e6a8","subject":"Move the error message into vcl_recv (#3360)","message":"Move the error message into vcl_recv (#3360)\n\n","repos":"pypa\/warehouse,dstufft\/warehouse,dstufft\/warehouse,pypa\/warehouse,pypa\/warehouse,dstufft\/warehouse,dstufft\/warehouse,pypa\/warehouse","old_file":"vcl\/main.vcl","new_file":"vcl\/main.vcl","new_contents":"# Note: It is VERY important to ensure that any changes to VCL will work\n# properly with both the current version of ``master`` and the version in\n# the pull request that adds any new changes. This is because the\n# configuration will be applied automatically as part of the deployment\n# process, but while the previous version of the code is still up and\n# running. Thus backwards incompatible changes must be broken up over\n# multiple pull requests in order to phase them in over multiple deploys.\n\nsub vcl_recv {\n\n # Fastly is dropping support for TLSv1.0 and TLSv1.1, in preperation for\n # for that, we're going to block support for it now, using VCL. This will\n # let us present a better error message in the interim before Fastly shuts\n # off TLSv1.0 and TLSv1.1 support completely.\n if (tls.client.protocol ~ \"^TLSv1(\\.(0|1))?$\") {\n set req.http.Error-Message = \"Support for \" tls.client.protocol \" has been removed, please upgrade to a TLSv1.2+ client. Please see https:\/\/pyfound.blogspot.com\/2017\/01\/time-to-upgrade-your-python-tls-v12.html\";\n error 804 \"Bad SSL Version\";\n }\n\n # I'm not 100% sure on what this is exactly for, it was taken from the\n # Fastly documentation, however, what I *believe* it does is just ensure\n # that we don't serve a stale copy of the page from the shield node when\n # an edge node is requesting content.\n if (req.http.Fastly-FF) {\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Some (Older) clients will send a hash fragment as part of the URL even\n # though that is a local only modification. This breaks this badly for the\n # files in S3, and in general it's just not needed.\n set req.url = regsub(req.url, \"#.*$\", \"\");\n\n # Fastly does some normalization of the Accept-Encoding header so that it\n # reduces the number of cached copies (when served with the common,\n # Vary: Accept-Encoding) that are cached for any one URL. This makes a lot\n # of sense, except for the fact that we want to enable brotli compression\n # for our static files. Thus we need to work around the normalized encoding\n # in a way that still minimizes cached copies, but which will allow our\n # static files to be served using brotli.\n if (req.url ~ \"^\/static\/\" && req.http.Fastly-Orig-Accept-Encoding) {\n if (req.http.User-Agent ~ \"MSIE 6\") {\n # For that 0.3% of stubborn users out there\n unset req.http.Accept-Encoding;\n } elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"br\") {\n set req.http.Accept-Encoding = \"br\";\n } elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n\n # Most of the URLs in Warehouse do not support or require any sort of query\n # parameter. If we strip these at the edge then we'll increase our cache\n # efficiency when they won't otherwise change the output of the pages.\n #\n # This will match any URL except those that start with:\n #\n # * \/admin\/\n # * \/search\/\n # * \/account\/login\/\n # * \/account\/logout\/\n # * \/account\/register\/\n # * \/account\/reset-password\/\n # * \/account\/verify-email\/\n # * \/pypi\n if (req.url.path !~ \"^\/(admin\/|search(\/|$)|account\/(login|logout|register|reset-password|verify-email)\/|pypi)\") {\n set req.url = req.url.path;\n }\n\n # Sort all of our query parameters, this will ensure that the same query\n # parameters in a different order will end up being represented as the same\n # thing, reducing cache misses due to ordering differences.\n set req.url = boltsort.sort(req.url);\n\n # We have a number of items that we'll pass back to the origin.\n # Set a header to tell the backend if we're using https or http.\n if (req.http.Fastly-SSL) {\n set req.http.Warehouse-Proto = \"https\";\n } else {\n set req.http.Warehouse-Proto = \"http\";\n }\n # Pass the client IP address back to the backend.\n if (req.http.Fastly-Client-IP) {\n set req.http.Warehouse-IP = req.http.Fastly-Client-IP;\n }\n # Pass the real host value back to the backend.\n if (req.http.Host) {\n set req.http.Warehouse-Host = req.http.host;\n }\n\n # Currently Fastly does not provide a way to access response headers when\n # the response is a 304 response. This is because the RFC states that only\n # a limit set of headers should be sent with a 304 response, and the rest\n # are SHOULD NOT. Since this stripping happens *prior* to vcl_deliver being\n # ran, that breaks our ability to log on 304 responses. Ideally at some\n # point Fastly offers us a way to access the \"real\" response headers even\n # for a 304 response, but for now, we are going to remove the headers that\n # allow a conditional response to be made. If at some point Fastly does\n # allow this, then we can delete this code.\n if (!req.http.Fastly-FF\n && std.tolower(req.http.Warehouse-Host) == \"files.pythonhosted.org\"\n && req.url.path ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\") {\n unset req.http.If-None-Match;\n unset req.http.If-Modified-Since;\n }\n\n\n#FASTLY recv\n\n\n # We want to Force SSL for the WebUI by redirecting to the HTTPS version of\n # the page, however for API calls we want to return an error code directing\n # people to instead use HTTPS.\n if (!req.http.Fastly-SSL) {\n\n # The \/simple\/ and \/packages\/ API.\n if (req.url ~ \"^\/(simple|packages)\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy JSON API.\n if (req.url ~ \"^\/pypi\/.+\/json$\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy ?:action= API.\n if (req.url ~ \"^\/pypi.*(\\?|&)=:action\") {\n error 803 \"SSL is required\";\n }\n\n # If we're on the \/pypi page and we've received something other than a\n # GET or HEAD request, then we have no way to determine if a particular\n # request is an API call or not because it'll be in the request body\n # and that isn't available to us here. So in those cases, we won't\n # do a redirect.\n if (req.url ~ \"^\/pypi\") {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n error 801 \"Force SSL\";\n }\n }\n else {\n # This isn't a \/pypi URL so we'll just unconditionally redirect to\n # HTTPS.\n error 801 \"Force SSL\";\n }\n }\n\n # Redirect pypi.io, www.pypi.io, and warehouse.python.org to pypi.org, this\n # is purposely done *after* the HTTPS checks.\n if (std.tolower(req.http.host) ~ \"^(www.pypi.org|(www.)?pypi.io|warehouse.python.org)$\") {\n set req.http.Location = \"https:\/\/pypi.org\" req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n # Redirect warehouse-staging.python.org to test.pypi.io.\n if (std.tolower(req.http.host) ~ \"^(test.pypi.io|warehouse-staging.python.org)$\") {\n set req.http.Location = \"https:\/\/test.pypi.org\" req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n\n # Requests to \/packages\/ get dispatched to Amazon instead of to our typical\n # Origin. This requires a a bit of setup to make it work.\n if (req.http.host ~ \"^(test-)?files.pythonhosted.org$\"\n && req.url ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\") {\n # Setup our environment to better match what S3 expects\/needs\n set req.http.Host = req.http.AWS-Bucket-Name \".s3.amazonaws.com\";\n set req.http.Date = now;\n set req.url = regsuball(req.url, \"\\+\", urlencode(\"+\"));\n\n # Compute the Authorization header that S3 requires to be able to\n # access the files stored there.\n set req.http.Authorization = \"AWS \" req.http.AWS-Access-Key-ID \":\" digest.hmac_sha1_base64(req.http.AWS-Secret-Access-Key, \"GET\" LF LF LF req.http.Date LF \"\/\" req.http.AWS-Bucket-Name req.url.path);\n\n # We don't want to send our Warehouse-Token to S3, so we'll go ahead\n # and remove it.\n unset req.http.Warehouse-Token;\n }\n\n # We no longer need any of these variables, which would exist only to\n # shuffle configuration from the Fastly UI into our VCL.\n unset req.http.AWS-Access-Key-ID;\n unset req.http.AWS-Secret-Access-Key;\n unset req.http.AWS-Bucket-Name;\n\n # On a POST, we want to skip the shielding and hit backends directly.\n if (req.request == \"POST\") {\n set req.backend = F_Heroku;\n }\n\n # Do not bother to attempt to run the caching mechanisms for methods that\n # are not generally safe to cache.\n if (req.request != \"HEAD\" &&\n req.request != \"GET\" &&\n req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n # We don't ever want to cache our health URL. Outside systems should be\n # able to use it to reach past Fastly and get an end to end health check.\n if (req.url == \"\/_health\/\") {\n return(pass);\n }\n\n # We never want to cache our admin URLs, while this should be \"safe\" due to\n # the architecure of Warehouse, it'll just be easier to debug issues if\n # these always are uncached.\n if (req.url ~ \"^\/admin\/\") {\n return(pass);\n }\n\n # Finally, return the default lookup action.\n return(lookup);\n}\n\n\nsub vcl_fetch {\n\n # These are newer kinds of redirects which should be able to be cached by\n # default, even though Fastly doesn't currently have them in their default\n # list of cacheable status codes.\n if (http_status_matches(beresp.status, \"303,307,308\")) {\n set beresp.cacheable = true;\n }\n\n # For any 5xx status code we want to see if a stale object exists for it,\n # if so we'll go ahead and serve it.\n if (beresp.status >= 500 && beresp.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n\n#FASTLY fetch\n\n\n # Trigger a \"SSL is required\" error if the backend has indicated to do so.\n if (beresp.http.X-Fastly-Error == \"803\") {\n error 803 \"SSL is required\";\n }\n\n # If we've gotten a 502 or a 503 from the backend, we'll go ahead and retry\n # the request.\n if ((beresp.status == 502 || beresp.status == 503) &&\n req.restarts < 1 &&\n (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n # If we've restarted, then we'll record the number of restarts.\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n # If there is a Set-Cookie header, we'll ensure that we do not cache the\n # response.\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n # If the response has the private Cache-Control directive then we won't\n # cache it.\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # If we've gotten an error after the restarts we'll deliver the response\n # with a very short cache time.\n if (http_status_matches(beresp.status, \"500,502,503\")) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n # Apply a default TTL if there isn't a max-age or s-maxage.\n if (beresp.http.Expires ||\n beresp.http.Surrogate-Control ~ \"max-age\" ||\n beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # Keep the ttl here\n }\n else {\n # Apply the default ttl\n set beresp.ttl = 60s;\n }\n\n # Actually deliver the fetched response.\n return(deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n # If the object we have isn't cacheable, then just serve it directly\n # without going through any of the caching mechanisms.\n if (!obj.cacheable) {\n return(pass);\n }\n\n return(deliver);\n}\n\n\nsub vcl_deliver {\n # If this is an error and we have a stale response available, restart so\n # that we can pick it up and serve it.\n if (resp.status >= 500 && resp.status < 600) {\n if (stale.exists) {\n restart;\n }\n }\n\n#FASTLY deliver\n\n # Unset headers that we don't need\/want to send on to the client because\n # they are not generally useful.\n unset resp.http.Via;\n\n # Set our standard security headers, we do this in VCL rather than in\n # Warehouse itself so that we always get these headers, regardless of the\n # origin server being used.\n set resp.http.Strict-Transport-Security = \"max-age=31536000; includeSubDomains; preload\";\n set resp.http.X-Frame-Options = \"deny\";\n set resp.http.X-XSS-Protection = \"1; mode=block\";\n set resp.http.X-Content-Type-Options = \"nosniff\";\n set resp.http.X-Permitted-Cross-Domain-Policies = \"none\";\n\n # Currently Fastly does not provide a way to access response headers when\n # the response is a 304 response. This is because the RFC states that only\n # a limit set of headers should be sent with a 304 response, and the rest\n # are SHOULD NOT. Since this stripping happens *prior* to vcl_deliver being\n # ran, that breaks our ability to log on 304 responses. Ideally at some\n # point Fastly offers us a way to access the \"real\" response headers even\n # for a 304 response, but for now, we are going to remove the headers that\n # allow a conditional response to be made. If at some point Fastly does\n # allow this, then we can delete this code, and also allow a 304 response\n # in the http_status_matches() check further down.\n if (!req.http.Fastly-FF\n && std.tolower(req.http.Warehouse-Host) == \"files.pythonhosted.org\"\n && req.url.path ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\") {\n unset resp.http.ETag;\n unset resp.http.Last-Modified;\n }\n\n # If we're not executing a shielding request, and the URL is one of our file\n # URLs, and it's a GET request, and the response is either a 200 or a 304\n # then we want to log an event stating that a download has taken place.\n if (!req.http.Fastly-FF\n && std.tolower(req.http.Warehouse-Host) == \"files.pythonhosted.org\"\n && req.url.path ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\"\n && req.request == \"GET\"\n && http_status_matches(resp.status, \"200\")) {\n log {\"syslog \"} req.service_id {\" linehaul :: \"} \"2@\" now \"|\" geoip.country_code \"|\" req.url.path \"|\" tls.client.protocol \"|\" tls.client.cipher \"|\" resp.http.x-amz-meta-project \"|\" resp.http.x-amz-meta-version \"|\" resp.http.x-amz-meta-package-type \"|\" req.http.user-agent;\n log {\"syslog \"} req.service_id {\" downloads :: \"} \"2@\" now \"|\" geoip.country_code \"|\" req.url.path \"|\" tls.client.protocol \"|\" tls.client.cipher \"|\" resp.http.x-amz-meta-project \"|\" resp.http.x-amz-meta-version \"|\" resp.http.x-amz-meta-package-type \"|\" req.http.user-agent;\n }\n\n # Set X-Robots-Header for everything _but_ prod\n if (std.tolower(req.http.host) !~ \"^pypi.org$\") {\n set resp.http.X-Robots-Header = \"noindex\";\n }\n\n # Unset a few headers set by Amazon that we don't really have a need\/desire\n # to send to clients.\n unset resp.http.x-amz-replication-status;\n unset resp.http.x-amz-meta-python-version;\n unset resp.http.x-amz-meta-version;\n unset resp.http.x-amz-meta-package-type;\n unset resp.http.x-amz-meta-project;\n\n\n return(deliver);\n}\n\n\nsub vcl_error {\n#FASTLY error\n\n # If we have a 5xx error and there is a stale object available, then we\n # will deliver that stale object.\n if (obj.status >= 500 && obj.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n if (obj.status == 803) {\n set obj.status = 403;\n set obj.response = \"SSL is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic {\"SSL is required.\"};\n return (deliver);\n } else if(obj.status == 804) {\n set obj.status = 403;\n set obj.response = \"TLSv1.2+ is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic req.http.Error-Message;\n return (deliver);\n } else if (obj.status == 750) {\n set obj.status = 301;\n set obj.http.Location = req.http.Location;\n set obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n synthetic {\"<html><head><title>301 Moved Permanently<\/title><\/head><body><center><h1>301 Moved Permanently<\/h1><\/center><\/body><\/html>\"};\n return(deliver);\n }\n\n}\n","old_contents":"# Note: It is VERY important to ensure that any changes to VCL will work\n# properly with both the current version of ``master`` and the version in\n# the pull request that adds any new changes. This is because the\n# configuration will be applied automatically as part of the deployment\n# process, but while the previous version of the code is still up and\n# running. Thus backwards incompatible changes must be broken up over\n# multiple pull requests in order to phase them in over multiple deploys.\n\nsub vcl_recv {\n\n # Fastly is dropping support for TLSv1.0 and TLSv1.1, in preperation for\n # for that, we're going to block support for it now, using VCL. This will\n # let us present a better error message in the interim before Fastly shuts\n # off TLSv1.0 and TLSv1.1 support completely.\n if (tls.client.protocol ~ \"^TLSv1(\\.(0|1))?$\") {\n error 804 \"Bad SSL Version\";\n }\n\n # I'm not 100% sure on what this is exactly for, it was taken from the\n # Fastly documentation, however, what I *believe* it does is just ensure\n # that we don't serve a stale copy of the page from the shield node when\n # an edge node is requesting content.\n if (req.http.Fastly-FF) {\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Some (Older) clients will send a hash fragment as part of the URL even\n # though that is a local only modification. This breaks this badly for the\n # files in S3, and in general it's just not needed.\n set req.url = regsub(req.url, \"#.*$\", \"\");\n\n # Fastly does some normalization of the Accept-Encoding header so that it\n # reduces the number of cached copies (when served with the common,\n # Vary: Accept-Encoding) that are cached for any one URL. This makes a lot\n # of sense, except for the fact that we want to enable brotli compression\n # for our static files. Thus we need to work around the normalized encoding\n # in a way that still minimizes cached copies, but which will allow our\n # static files to be served using brotli.\n if (req.url ~ \"^\/static\/\" && req.http.Fastly-Orig-Accept-Encoding) {\n if (req.http.User-Agent ~ \"MSIE 6\") {\n # For that 0.3% of stubborn users out there\n unset req.http.Accept-Encoding;\n } elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"br\") {\n set req.http.Accept-Encoding = \"br\";\n } elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n\n # Most of the URLs in Warehouse do not support or require any sort of query\n # parameter. If we strip these at the edge then we'll increase our cache\n # efficiency when they won't otherwise change the output of the pages.\n #\n # This will match any URL except those that start with:\n #\n # * \/admin\/\n # * \/search\/\n # * \/account\/login\/\n # * \/account\/logout\/\n # * \/account\/register\/\n # * \/account\/reset-password\/\n # * \/account\/verify-email\/\n # * \/pypi\n if (req.url.path !~ \"^\/(admin\/|search(\/|$)|account\/(login|logout|register|reset-password|verify-email)\/|pypi)\") {\n set req.url = req.url.path;\n }\n\n # Sort all of our query parameters, this will ensure that the same query\n # parameters in a different order will end up being represented as the same\n # thing, reducing cache misses due to ordering differences.\n set req.url = boltsort.sort(req.url);\n\n # We have a number of items that we'll pass back to the origin.\n # Set a header to tell the backend if we're using https or http.\n if (req.http.Fastly-SSL) {\n set req.http.Warehouse-Proto = \"https\";\n } else {\n set req.http.Warehouse-Proto = \"http\";\n }\n # Pass the client IP address back to the backend.\n if (req.http.Fastly-Client-IP) {\n set req.http.Warehouse-IP = req.http.Fastly-Client-IP;\n }\n # Pass the real host value back to the backend.\n if (req.http.Host) {\n set req.http.Warehouse-Host = req.http.host;\n }\n\n # Currently Fastly does not provide a way to access response headers when\n # the response is a 304 response. This is because the RFC states that only\n # a limit set of headers should be sent with a 304 response, and the rest\n # are SHOULD NOT. Since this stripping happens *prior* to vcl_deliver being\n # ran, that breaks our ability to log on 304 responses. Ideally at some\n # point Fastly offers us a way to access the \"real\" response headers even\n # for a 304 response, but for now, we are going to remove the headers that\n # allow a conditional response to be made. If at some point Fastly does\n # allow this, then we can delete this code.\n if (!req.http.Fastly-FF\n && std.tolower(req.http.Warehouse-Host) == \"files.pythonhosted.org\"\n && req.url.path ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\") {\n unset req.http.If-None-Match;\n unset req.http.If-Modified-Since;\n }\n\n\n#FASTLY recv\n\n\n # We want to Force SSL for the WebUI by redirecting to the HTTPS version of\n # the page, however for API calls we want to return an error code directing\n # people to instead use HTTPS.\n if (!req.http.Fastly-SSL) {\n\n # The \/simple\/ and \/packages\/ API.\n if (req.url ~ \"^\/(simple|packages)\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy JSON API.\n if (req.url ~ \"^\/pypi\/.+\/json$\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy ?:action= API.\n if (req.url ~ \"^\/pypi.*(\\?|&)=:action\") {\n error 803 \"SSL is required\";\n }\n\n # If we're on the \/pypi page and we've received something other than a\n # GET or HEAD request, then we have no way to determine if a particular\n # request is an API call or not because it'll be in the request body\n # and that isn't available to us here. So in those cases, we won't\n # do a redirect.\n if (req.url ~ \"^\/pypi\") {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n error 801 \"Force SSL\";\n }\n }\n else {\n # This isn't a \/pypi URL so we'll just unconditionally redirect to\n # HTTPS.\n error 801 \"Force SSL\";\n }\n }\n\n # Redirect pypi.io, www.pypi.io, and warehouse.python.org to pypi.org, this\n # is purposely done *after* the HTTPS checks.\n if (std.tolower(req.http.host) ~ \"^(www.pypi.org|(www.)?pypi.io|warehouse.python.org)$\") {\n set req.http.Location = \"https:\/\/pypi.org\" req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n # Redirect warehouse-staging.python.org to test.pypi.io.\n if (std.tolower(req.http.host) ~ \"^(test.pypi.io|warehouse-staging.python.org)$\") {\n set req.http.Location = \"https:\/\/test.pypi.org\" req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n\n # Requests to \/packages\/ get dispatched to Amazon instead of to our typical\n # Origin. This requires a a bit of setup to make it work.\n if (req.http.host ~ \"^(test-)?files.pythonhosted.org$\"\n && req.url ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\") {\n # Setup our environment to better match what S3 expects\/needs\n set req.http.Host = req.http.AWS-Bucket-Name \".s3.amazonaws.com\";\n set req.http.Date = now;\n set req.url = regsuball(req.url, \"\\+\", urlencode(\"+\"));\n\n # Compute the Authorization header that S3 requires to be able to\n # access the files stored there.\n set req.http.Authorization = \"AWS \" req.http.AWS-Access-Key-ID \":\" digest.hmac_sha1_base64(req.http.AWS-Secret-Access-Key, \"GET\" LF LF LF req.http.Date LF \"\/\" req.http.AWS-Bucket-Name req.url.path);\n\n # We don't want to send our Warehouse-Token to S3, so we'll go ahead\n # and remove it.\n unset req.http.Warehouse-Token;\n }\n\n # We no longer need any of these variables, which would exist only to\n # shuffle configuration from the Fastly UI into our VCL.\n unset req.http.AWS-Access-Key-ID;\n unset req.http.AWS-Secret-Access-Key;\n unset req.http.AWS-Bucket-Name;\n\n # On a POST, we want to skip the shielding and hit backends directly.\n if (req.request == \"POST\") {\n set req.backend = F_Heroku;\n }\n\n # Do not bother to attempt to run the caching mechanisms for methods that\n # are not generally safe to cache.\n if (req.request != \"HEAD\" &&\n req.request != \"GET\" &&\n req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n # We don't ever want to cache our health URL. Outside systems should be\n # able to use it to reach past Fastly and get an end to end health check.\n if (req.url == \"\/_health\/\") {\n return(pass);\n }\n\n # We never want to cache our admin URLs, while this should be \"safe\" due to\n # the architecure of Warehouse, it'll just be easier to debug issues if\n # these always are uncached.\n if (req.url ~ \"^\/admin\/\") {\n return(pass);\n }\n\n # Finally, return the default lookup action.\n return(lookup);\n}\n\n\nsub vcl_fetch {\n\n # These are newer kinds of redirects which should be able to be cached by\n # default, even though Fastly doesn't currently have them in their default\n # list of cacheable status codes.\n if (http_status_matches(beresp.status, \"303,307,308\")) {\n set beresp.cacheable = true;\n }\n\n # For any 5xx status code we want to see if a stale object exists for it,\n # if so we'll go ahead and serve it.\n if (beresp.status >= 500 && beresp.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n\n#FASTLY fetch\n\n\n # Trigger a \"SSL is required\" error if the backend has indicated to do so.\n if (beresp.http.X-Fastly-Error == \"803\") {\n error 803 \"SSL is required\";\n }\n\n # If we've gotten a 502 or a 503 from the backend, we'll go ahead and retry\n # the request.\n if ((beresp.status == 502 || beresp.status == 503) &&\n req.restarts < 1 &&\n (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n # If we've restarted, then we'll record the number of restarts.\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n # If there is a Set-Cookie header, we'll ensure that we do not cache the\n # response.\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n # If the response has the private Cache-Control directive then we won't\n # cache it.\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # If we've gotten an error after the restarts we'll deliver the response\n # with a very short cache time.\n if (http_status_matches(beresp.status, \"500,502,503\")) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n # Apply a default TTL if there isn't a max-age or s-maxage.\n if (beresp.http.Expires ||\n beresp.http.Surrogate-Control ~ \"max-age\" ||\n beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # Keep the ttl here\n }\n else {\n # Apply the default ttl\n set beresp.ttl = 60s;\n }\n\n # Actually deliver the fetched response.\n return(deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n # If the object we have isn't cacheable, then just serve it directly\n # without going through any of the caching mechanisms.\n if (!obj.cacheable) {\n return(pass);\n }\n\n return(deliver);\n}\n\n\nsub vcl_deliver {\n # If this is an error and we have a stale response available, restart so\n # that we can pick it up and serve it.\n if (resp.status >= 500 && resp.status < 600) {\n if (stale.exists) {\n restart;\n }\n }\n\n#FASTLY deliver\n\n # Unset headers that we don't need\/want to send on to the client because\n # they are not generally useful.\n unset resp.http.Via;\n\n # Set our standard security headers, we do this in VCL rather than in\n # Warehouse itself so that we always get these headers, regardless of the\n # origin server being used.\n set resp.http.Strict-Transport-Security = \"max-age=31536000; includeSubDomains; preload\";\n set resp.http.X-Frame-Options = \"deny\";\n set resp.http.X-XSS-Protection = \"1; mode=block\";\n set resp.http.X-Content-Type-Options = \"nosniff\";\n set resp.http.X-Permitted-Cross-Domain-Policies = \"none\";\n\n # Currently Fastly does not provide a way to access response headers when\n # the response is a 304 response. This is because the RFC states that only\n # a limit set of headers should be sent with a 304 response, and the rest\n # are SHOULD NOT. Since this stripping happens *prior* to vcl_deliver being\n # ran, that breaks our ability to log on 304 responses. Ideally at some\n # point Fastly offers us a way to access the \"real\" response headers even\n # for a 304 response, but for now, we are going to remove the headers that\n # allow a conditional response to be made. If at some point Fastly does\n # allow this, then we can delete this code, and also allow a 304 response\n # in the http_status_matches() check further down.\n if (!req.http.Fastly-FF\n && std.tolower(req.http.Warehouse-Host) == \"files.pythonhosted.org\"\n && req.url.path ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\") {\n unset resp.http.ETag;\n unset resp.http.Last-Modified;\n }\n\n # If we're not executing a shielding request, and the URL is one of our file\n # URLs, and it's a GET request, and the response is either a 200 or a 304\n # then we want to log an event stating that a download has taken place.\n if (!req.http.Fastly-FF\n && std.tolower(req.http.Warehouse-Host) == \"files.pythonhosted.org\"\n && req.url.path ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\"\n && req.request == \"GET\"\n && http_status_matches(resp.status, \"200\")) {\n log {\"syslog \"} req.service_id {\" linehaul :: \"} \"2@\" now \"|\" geoip.country_code \"|\" req.url.path \"|\" tls.client.protocol \"|\" tls.client.cipher \"|\" resp.http.x-amz-meta-project \"|\" resp.http.x-amz-meta-version \"|\" resp.http.x-amz-meta-package-type \"|\" req.http.user-agent;\n log {\"syslog \"} req.service_id {\" downloads :: \"} \"2@\" now \"|\" geoip.country_code \"|\" req.url.path \"|\" tls.client.protocol \"|\" tls.client.cipher \"|\" resp.http.x-amz-meta-project \"|\" resp.http.x-amz-meta-version \"|\" resp.http.x-amz-meta-package-type \"|\" req.http.user-agent;\n }\n\n # Set X-Robots-Header for everything _but_ prod\n if (std.tolower(req.http.host) !~ \"^pypi.org$\") {\n set resp.http.X-Robots-Header = \"noindex\";\n }\n\n # Unset a few headers set by Amazon that we don't really have a need\/desire\n # to send to clients.\n unset resp.http.x-amz-replication-status;\n unset resp.http.x-amz-meta-python-version;\n unset resp.http.x-amz-meta-version;\n unset resp.http.x-amz-meta-package-type;\n unset resp.http.x-amz-meta-project;\n\n\n return(deliver);\n}\n\n\nsub vcl_error {\n#FASTLY error\n\n # If we have a 5xx error and there is a stale object available, then we\n # will deliver that stale object.\n if (obj.status >= 500 && obj.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n if (obj.status == 803) {\n set obj.status = 403;\n set obj.response = \"SSL is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic {\"SSL is required.\"};\n return (deliver);\n } else if(obj.status == 804) {\n set obj.status = 403;\n set obj.response = \"TLSv1.2+ is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic \"Support for \" tls.client.protocol \" has been removed, please upgrade to a TLSv1.2+ client.\";\n return (deliver);\n } else if (obj.status == 750) {\n set obj.status = 301;\n set obj.http.Location = req.http.Location;\n set obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n synthetic {\"<html><head><title>301 Moved Permanently<\/title><\/head><body><center><h1>301 Moved Permanently<\/h1><\/center><\/body><\/html>\"};\n return(deliver);\n }\n\n}\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"91e321e282cb6874426a4d3ce7557f125720bf86","subject":"Redirect test.pypi.io to test.pypi.org (#1416)","message":"Redirect test.pypi.io to test.pypi.org (#1416)\n\n","repos":"alex\/warehouse,pypa\/warehouse,alex\/warehouse,dstufft\/warehouse,pypa\/warehouse,dstufft\/warehouse,dstufft\/warehouse,pypa\/warehouse,alex\/warehouse,dstufft\/warehouse,pypa\/warehouse,alex\/warehouse,alex\/warehouse","old_file":"vcl\/main.vcl","new_file":"vcl\/main.vcl","new_contents":"\nsub vcl_recv {\n\n # I'm not 100% sure on what this is exactly for, it was taken from the\n # Fastly documentation, however, what I *believe* it does is just ensure\n # that we don't serve a stale copy of the page from the shield node when\n # an edge node is requesting content.\n if (req.http.Fastly-FF) {\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Some (Older) clients will send a hash fragment as part of the URL even\n # though that is a local only modification. This breaks this badly for the\n # files in S3, and in general it's just not needed.\n set req.url = regsub(req.url, \"#.*$\", \"\");\n\n # Fastly does some normalization of the Accept-Encoding header so that it\n # reduces the number of cached copies (when served with the common,\n # Vary: Accept-Encoding) that are cached for any one URL. This makes a lot\n # of sense, except for the fact that we want to enable brotli compression\n # for our static files. Thus we need to work around the normalized encoding\n # in a way that still minimizes cached copies, but which will allow our\n # static files to be served using brotli.\n if (req.url ~ \"^\/static\/\" && req.http.Fastly-Orig-Accept-Encoding) {\n if (req.http.User-Agent ~ \"MSIE 6\") {\n # For that 0.3% of stubborn users out there\n unset req.http.Accept-Encoding;\n } elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"br\") {\n set req.http.Accept-Encoding = \"br\";\n } elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n\n # Most of the URLs in Warehouse do not support or require any sort of query\n # parameter. If we strip these at the edge then we'll increase our cache\n # efficiency when they won't otherwise change the output of the pages.\n #\n # This will match any URL except those that start with:\n #\n # * \/search\/\n # * \/account\/login\/\n # * \/account\/logout\/\n # * \/account\/register\/\n # * \/pypi\n if (req.url !~ \"^\/(search\/|account\/(login|logout|register)\/|pypi)\") {\n set req.url = req.url.path;\n }\n\n # Sort all of our query parameters, this will ensure that the same query\n # parameters in a different order will end up being represented as the same\n # thing, reducing cache misses due to ordering differences.\n set req.url = boltsort.sort(req.url);\n\n\n#FASTLY recv\n\n\n # We want to Force SSL for the WebUI by redirecting to the HTTPS version of\n # the page, however for API calls we want to return an error code directing\n # people to instead use HTTPS.\n if (!req.http.Fastly-SSL) {\n\n # The \/simple\/ and \/packages\/ API.\n if (req.url ~ \"^\/(simple|packages)\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy JSON API.\n if (req.url ~ \"^\/pypi\/.+\/json$\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy ?:action= API.\n if (req.url ~ \"^\/pypi.*(\\?|&)=:action\") {\n error 803 \"SSL is required\";\n }\n\n # If we're on the \/pypi page and we've received something other than a\n # GET or HEAD request, then we have no way to determine if a particular\n # request is an API call or not because it'll be in the request body\n # and that isn't available to us here. So in those cases, we won't\n # do a redirect.\n if (req.url ~ \"^\/pypi\") {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n error 801 \"Force SSL\";\n }\n }\n else {\n # This isn't a \/pypi URL so we'll just unconditionally redirect to\n # HTTPS.\n error 801 \"Force SSL\";\n }\n }\n\n # Redirect www.pypi.io and warehouse.python.org to pypi.io, this is\n # purposely done *after* the HTTPS checks.\n if (std.tolower(req.http.host) ~ \"^(www.pypi.io|warehouse.python.org)$\") {\n set req.http.Location = \"https:\/\/pypi.io\" req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n # Redirect warehouse-staging.python.org to test.pypi.io.\n if (std.tolower(req.http.host) ~ \"^(test.pypi.io|warehouse-staging.python.org)$\") {\n set req.http.Location = \"https:\/\/test.pypi.org\" req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n\n # Requests to \/packages\/ get dispatched to Amazon instead of to our typical\n # Origin. This requires a a bit of setup to make it work.\n if (req.http.host ~ \"^(test-)?files.pythonhosted.org$\"\n && req.url ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\") {\n # Setup our environment to better match what S3 expects\/needs\n set req.http.Host = req.http.AWS-Bucket-Name \".s3.amazonaws.com\";\n set req.http.Date = now;\n set req.url = regsuball(req.url, \"\\+\", urlencode(\"+\"));\n\n # Compute the Authorization header that S3 requires to be able to\n # access the files stored there.\n set req.http.Authorization = \"AWS \" req.http.AWS-Access-Key-ID \":\" digest.hmac_sha1_base64(req.http.AWS-Secret-Access-Key, \"GET\" LF LF LF req.http.Date LF \"\/\" req.http.AWS-Bucket-Name req.url.path);\n\n # We don't want to send our Warehouse-Token to S3, so we'll go ahead\n # and remove it.\n unset req.http.Warehouse-Token;\n }\n\n # We no longer need any of these variables, which would exist only to\n # shuffle configuration from the Fastly UI into our VCL.\n unset req.http.AWS-Access-Key-ID;\n unset req.http.AWS-Secret-Access-Key;\n unset req.http.AWS-Bucket-Name;\n\n # We have a number of items that we'll pass back to the origin, but only\n # if we have a Warehouse-Token that will allow them to be accepted.\n if (req.http.Warehouse-Token) {\n # Set a header to tell the backend if we're using https or http.\n if (req.http.Fastly-SSL) {\n set req.http.Warehouse-Proto = \"https\";\n } else {\n set req.http.Warehouse-Proto = \"http\";\n }\n\n # Pass the client IP address back to the backend.\n if (req.http.Fastly-Client-IP) {\n set req.http.Warehouse-IP = req.http.Fastly-Client-IP;\n }\n\n # Pass the real host value back to the backend.\n if (req.http.Host) {\n set req.http.Warehouse-Host = req.http.host;\n }\n }\n\n # On a POST, we want to skip the shielding and hit backends directly.\n if (req.request == \"POST\") {\n set req.backend = F_Heroku;\n }\n\n # Do not bother to attempt to run the caching mechanisms for methods that\n # are not generally safe to cache.\n if (req.request != \"HEAD\" &&\n req.request != \"GET\" &&\n req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n # We don't ever want to cache our health URL. Outside systems should be\n # able to use it to reach past Fastly and get an end to end health check.\n if (req.url == \"\/_health\/\") {\n return(pass);\n }\n\n # Finally, return the default lookup action.\n return(lookup);\n}\n\n\nsub vcl_fetch {\n\n # These are newer kinds of redirects which should be able to be cached by\n # default, even though Fastly doesn't currently have them in their default\n # list of cacheable status codes.\n if (http_status_matches(beresp.status, \"303,307,308\")) {\n set beresp.cacheable = true;\n }\n\n # For any 5xx status code we want to see if a stale object exists for it,\n # if so we'll go ahead and serve it.\n if (beresp.status >= 500 && beresp.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n # When delivering a 304 response, we don't always have access to all the\n # headers in the resp because a 304 response is supposed to remove most of\n # the headers. So we'll instead stash these headers on the request so that\n # we can log this data from there instead of from the response.\n if (beresp.http.x-amz-meta-project\n || beresp.http.x-amz-meta-version\n || beresp.http.x-amz-meta-package-type) {\n set req.http.Fastly-amz-meta-project = beresp.http.x-amz-meta-project;\n set req.http.Fastly-amz-meta-version = beresp.http.x-amz-meta-version;\n set req.http.Fastly-amz-meta-package-type = beresp.http.x-amz-meta-package-type;\n }\n\n\n#FASTLY fetch\n\n\n # Trigger a \"SSL is required\" error if the backend has indicated to do so.\n if (beresp.http.X-Fastly-Error == \"803\") {\n error 803 \"SSL is required\";\n }\n\n # If we've gotten a 502 or a 503 from the backend, we'll go ahead and retry\n # the request.\n if ((beresp.status == 502 || beresp.status == 503) &&\n req.restarts < 1 &&\n (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n # If we've restarted, then we'll record the number of restarts.\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n # If there is a Set-Cookie header, we'll ensure that we do not cache the\n # response.\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n # If the response has the private Cache-Control directive then we won't\n # cache it.\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # If we've gotten an error after the restarts we'll deliver the response\n # with a very short cache time.\n if (http_status_matches(beresp.status, \"500,502,503\")) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n # Apply a default TTL if there isn't a max-age or s-maxage.\n if (beresp.http.Expires ||\n beresp.http.Surrogate-Control ~ \"max-age\" ||\n beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # Keep the ttl here\n }\n else {\n # Apply the default ttl\n set beresp.ttl = 60s;\n }\n\n # Actually deliver the fetched response.\n return(deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n # If the object we have isn't cacheable, then just serve it directly\n # without going through any of the caching mechanisms.\n if (!obj.cacheable) {\n return(pass);\n }\n\n return(deliver);\n}\n\n\nsub vcl_deliver {\n # If this is an error and we have a stale response available, restart so\n # that we can pick it up and serve it.\n if (resp.status >= 500 && resp.status < 600) {\n if (stale.exists) {\n restart;\n }\n }\n\n#FASTLY deliver\n\n # Unset headers that we don't need\/want to send on to the client because\n # they are not generally useful.\n unset resp.http.Server;\n unset resp.http.Via;\n\n # Unset a few headers set by Amazon that we don't really have a need\/desire\n # to send to clients.\n unset resp.http.X-AMZ-Replication-Status;\n unset resp.http.X-AMZ-Meta-Python-Version;\n unset resp.http.X-AMZ-Meta-Version;\n unset resp.http.X-AMZ-Meta-Package-Type;\n unset resp.http.X-AMZ-Meta-Project;\n\n # Set our standard security headers, we do this in VCL rather than in\n # Warehouse itself so that we always get these headers, regardless of the\n # origin server being used.\n set resp.http.Strict-Transport-Security = \"max-age=31536000; includeSubDomains; preload\";\n set resp.http.X-Frame-Options = \"deny\";\n set resp.http.X-XSS-Protection = \"1; mode=block\";\n set resp.http.X-Content-Type-Options = \"nosniff\";\n set resp.http.X-Permitted-Cross-Domain-Policies = \"none\";\n\n # Unstash our information about what project\/version\/package-type a\n # particular file download was for.\n if (req.http.Fastly-amz-meta-project\n || req.http.Fastly-amz-meta-version\n || req.http.Fastly-amz-meta-package-type) {\n set resp.http.x-amz-meta-project = req.http.Fastly-amz-meta-project;\n set resp.http.x-amz-meta-version = req.http.Fastly-amz-meta-version;\n set resp.http.x-amz-meta-package-type = req.http.Fastly-amz-meta-package-type;\n }\n\n # If we're not executing a shielding request, and the URL is one of our file\n # URLs, and it's a GET request, and the response is either a 200 or a 304\n # then we want to log an event stating that a download has taken place.\n if (!req.http.Fastly-FF\n && std.tolower(req.http.host) == \"files.pythonhosted.org\"\n && req.url.path ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\"\n && req.request == \"GET\"\n && http_status_matches(resp.status, \"200,304\")) {\n log {\"syslog \"} req.service_id {\" linehaul :: \"} \"2@\" now \"|\" geoip.country_code \"|\" req.url.path \"|\" tls.client.protocol \"|\" tls.client.cipher \"|\" resp.http.x-amz-meta-project \"|\" resp.http.x-amz-meta-version \"|\" resp.http.x-amz-meta-package-type \"|\" req.http.user-agent;\n log {\"syslog \"} req.service_id {\" downloads :: \"} \"2@\" now \"|\" geoip.country_code \"|\" req.url.path \"|\" tls.client.protocol \"|\" tls.client.cipher \"|\" resp.http.x-amz-meta-project \"|\" resp.http.x-amz-meta-version \"|\" resp.http.x-amz-meta-package-type \"|\" req.http.user-agent;\n }\n\n return(deliver);\n}\n\n\nsub vcl_error {\n#FASTLY error\n\n # If we have a 5xx error and there is a stale object available, then we\n # will deliver that stale object.\n if (obj.status >= 500 && obj.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n if (obj.status == 803) {\n set obj.status = 403;\n set obj.response = \"SSL is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic {\"SSL is required.\"};\n return (deliver);\n } else if (obj.status == 750) {\n set obj.status = 301;\n set obj.http.Location = req.http.Location;\n set obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n synthetic {\"<html><head><title>301 Moved Permanently<\/title><\/head><body><center><h1>301 Moved Permanently<\/h1><\/center><\/body><\/html>\"};\n return(deliver);\n }\n\n}\n","old_contents":"\nsub vcl_recv {\n\n # I'm not 100% sure on what this is exactly for, it was taken from the\n # Fastly documentation, however, what I *believe* it does is just ensure\n # that we don't serve a stale copy of the page from the shield node when\n # an edge node is requesting content.\n if (req.http.Fastly-FF) {\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Some (Older) clients will send a hash fragment as part of the URL even\n # though that is a local only modification. This breaks this badly for the\n # files in S3, and in general it's just not needed.\n set req.url = regsub(req.url, \"#.*$\", \"\");\n\n # Fastly does some normalization of the Accept-Encoding header so that it\n # reduces the number of cached copies (when served with the common,\n # Vary: Accept-Encoding) that are cached for any one URL. This makes a lot\n # of sense, except for the fact that we want to enable brotli compression\n # for our static files. Thus we need to work around the normalized encoding\n # in a way that still minimizes cached copies, but which will allow our\n # static files to be served using brotli.\n if (req.url ~ \"^\/static\/\" && req.http.Fastly-Orig-Accept-Encoding) {\n if (req.http.User-Agent ~ \"MSIE 6\") {\n # For that 0.3% of stubborn users out there\n unset req.http.Accept-Encoding;\n } elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"br\") {\n set req.http.Accept-Encoding = \"br\";\n } elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n\n # Most of the URLs in Warehouse do not support or require any sort of query\n # parameter. If we strip these at the edge then we'll increase our cache\n # efficiency when they won't otherwise change the output of the pages.\n #\n # This will match any URL except those that start with:\n #\n # * \/search\/\n # * \/account\/login\/\n # * \/account\/logout\/\n # * \/account\/register\/\n # * \/pypi\n if (req.url !~ \"^\/(search\/|account\/(login|logout|register)\/|pypi)\") {\n set req.url = req.url.path;\n }\n\n # Sort all of our query parameters, this will ensure that the same query\n # parameters in a different order will end up being represented as the same\n # thing, reducing cache misses due to ordering differences.\n set req.url = boltsort.sort(req.url);\n\n\n#FASTLY recv\n\n\n # We want to Force SSL for the WebUI by redirecting to the HTTPS version of\n # the page, however for API calls we want to return an error code directing\n # people to instead use HTTPS.\n if (!req.http.Fastly-SSL) {\n\n # The \/simple\/ and \/packages\/ API.\n if (req.url ~ \"^\/(simple|packages)\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy JSON API.\n if (req.url ~ \"^\/pypi\/.+\/json$\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy ?:action= API.\n if (req.url ~ \"^\/pypi.*(\\?|&)=:action\") {\n error 803 \"SSL is required\";\n }\n\n # If we're on the \/pypi page and we've received something other than a\n # GET or HEAD request, then we have no way to determine if a particular\n # request is an API call or not because it'll be in the request body\n # and that isn't available to us here. So in those cases, we won't\n # do a redirect.\n if (req.url ~ \"^\/pypi\") {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n error 801 \"Force SSL\";\n }\n }\n else {\n # This isn't a \/pypi URL so we'll just unconditionally redirect to\n # HTTPS.\n error 801 \"Force SSL\";\n }\n }\n\n # Redirect www.pypi.io and warehouse.python.org to pypi.io, this is\n # purposely done *after* the HTTPS checks.\n if (std.tolower(req.http.host) ~ \"^(www.pypi.io|warehouse.python.org)$\") {\n set req.http.Location = \"https:\/\/pypi.io\" req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n # Redirect warehouse-staging.python.org to test.pypi.io.\n if (std.tolower(req.http.host) == \"warehouse-staging.python.org\") {\n set req.http.Location = \"https:\/\/test.pypi.io\" req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n\n # Requests to \/packages\/ get dispatched to Amazon instead of to our typical\n # Origin. This requires a a bit of setup to make it work.\n if (req.http.host ~ \"^(test-)?files.pythonhosted.org$\"\n && req.url ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\") {\n # Setup our environment to better match what S3 expects\/needs\n set req.http.Host = req.http.AWS-Bucket-Name \".s3.amazonaws.com\";\n set req.http.Date = now;\n set req.url = regsuball(req.url, \"\\+\", urlencode(\"+\"));\n\n # Compute the Authorization header that S3 requires to be able to\n # access the files stored there.\n set req.http.Authorization = \"AWS \" req.http.AWS-Access-Key-ID \":\" digest.hmac_sha1_base64(req.http.AWS-Secret-Access-Key, \"GET\" LF LF LF req.http.Date LF \"\/\" req.http.AWS-Bucket-Name req.url.path);\n\n # We don't want to send our Warehouse-Token to S3, so we'll go ahead\n # and remove it.\n unset req.http.Warehouse-Token;\n }\n\n # We no longer need any of these variables, which would exist only to\n # shuffle configuration from the Fastly UI into our VCL.\n unset req.http.AWS-Access-Key-ID;\n unset req.http.AWS-Secret-Access-Key;\n unset req.http.AWS-Bucket-Name;\n\n # We have a number of items that we'll pass back to the origin, but only\n # if we have a Warehouse-Token that will allow them to be accepted.\n if (req.http.Warehouse-Token) {\n # Set a header to tell the backend if we're using https or http.\n if (req.http.Fastly-SSL) {\n set req.http.Warehouse-Proto = \"https\";\n } else {\n set req.http.Warehouse-Proto = \"http\";\n }\n\n # Pass the client IP address back to the backend.\n if (req.http.Fastly-Client-IP) {\n set req.http.Warehouse-IP = req.http.Fastly-Client-IP;\n }\n\n # Pass the real host value back to the backend.\n if (req.http.Host) {\n set req.http.Warehouse-Host = req.http.host;\n }\n }\n\n # On a POST, we want to skip the shielding and hit backends directly.\n if (req.request == \"POST\") {\n set req.backend = F_Heroku;\n }\n\n # Do not bother to attempt to run the caching mechanisms for methods that\n # are not generally safe to cache.\n if (req.request != \"HEAD\" &&\n req.request != \"GET\" &&\n req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n # We don't ever want to cache our health URL. Outside systems should be\n # able to use it to reach past Fastly and get an end to end health check.\n if (req.url == \"\/_health\/\") {\n return(pass);\n }\n\n # Finally, return the default lookup action.\n return(lookup);\n}\n\n\nsub vcl_fetch {\n\n # These are newer kinds of redirects which should be able to be cached by\n # default, even though Fastly doesn't currently have them in their default\n # list of cacheable status codes.\n if (http_status_matches(beresp.status, \"303,307,308\")) {\n set beresp.cacheable = true;\n }\n\n # For any 5xx status code we want to see if a stale object exists for it,\n # if so we'll go ahead and serve it.\n if (beresp.status >= 500 && beresp.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n # When delivering a 304 response, we don't always have access to all the\n # headers in the resp because a 304 response is supposed to remove most of\n # the headers. So we'll instead stash these headers on the request so that\n # we can log this data from there instead of from the response.\n if (beresp.http.x-amz-meta-project\n || beresp.http.x-amz-meta-version\n || beresp.http.x-amz-meta-package-type) {\n set req.http.Fastly-amz-meta-project = beresp.http.x-amz-meta-project;\n set req.http.Fastly-amz-meta-version = beresp.http.x-amz-meta-version;\n set req.http.Fastly-amz-meta-package-type = beresp.http.x-amz-meta-package-type;\n }\n\n\n#FASTLY fetch\n\n\n # Trigger a \"SSL is required\" error if the backend has indicated to do so.\n if (beresp.http.X-Fastly-Error == \"803\") {\n error 803 \"SSL is required\";\n }\n\n # If we've gotten a 502 or a 503 from the backend, we'll go ahead and retry\n # the request.\n if ((beresp.status == 502 || beresp.status == 503) &&\n req.restarts < 1 &&\n (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n # If we've restarted, then we'll record the number of restarts.\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n # If there is a Set-Cookie header, we'll ensure that we do not cache the\n # response.\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n # If the response has the private Cache-Control directive then we won't\n # cache it.\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # If we've gotten an error after the restarts we'll deliver the response\n # with a very short cache time.\n if (http_status_matches(beresp.status, \"500,502,503\")) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n # Apply a default TTL if there isn't a max-age or s-maxage.\n if (beresp.http.Expires ||\n beresp.http.Surrogate-Control ~ \"max-age\" ||\n beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # Keep the ttl here\n }\n else {\n # Apply the default ttl\n set beresp.ttl = 60s;\n }\n\n # Actually deliver the fetched response.\n return(deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n # If the object we have isn't cacheable, then just serve it directly\n # without going through any of the caching mechanisms.\n if (!obj.cacheable) {\n return(pass);\n }\n\n return(deliver);\n}\n\n\nsub vcl_deliver {\n # If this is an error and we have a stale response available, restart so\n # that we can pick it up and serve it.\n if (resp.status >= 500 && resp.status < 600) {\n if (stale.exists) {\n restart;\n }\n }\n\n#FASTLY deliver\n\n # Unset headers that we don't need\/want to send on to the client because\n # they are not generally useful.\n unset resp.http.Server;\n unset resp.http.Via;\n\n # Unset a few headers set by Amazon that we don't really have a need\/desire\n # to send to clients.\n unset resp.http.X-AMZ-Replication-Status;\n unset resp.http.X-AMZ-Meta-Python-Version;\n unset resp.http.X-AMZ-Meta-Version;\n unset resp.http.X-AMZ-Meta-Package-Type;\n unset resp.http.X-AMZ-Meta-Project;\n\n # Set our standard security headers, we do this in VCL rather than in\n # Warehouse itself so that we always get these headers, regardless of the\n # origin server being used.\n set resp.http.Strict-Transport-Security = \"max-age=31536000; includeSubDomains; preload\";\n set resp.http.X-Frame-Options = \"deny\";\n set resp.http.X-XSS-Protection = \"1; mode=block\";\n set resp.http.X-Content-Type-Options = \"nosniff\";\n set resp.http.X-Permitted-Cross-Domain-Policies = \"none\";\n\n # Unstash our information about what project\/version\/package-type a\n # particular file download was for.\n if (req.http.Fastly-amz-meta-project\n || req.http.Fastly-amz-meta-version\n || req.http.Fastly-amz-meta-package-type) {\n set resp.http.x-amz-meta-project = req.http.Fastly-amz-meta-project;\n set resp.http.x-amz-meta-version = req.http.Fastly-amz-meta-version;\n set resp.http.x-amz-meta-package-type = req.http.Fastly-amz-meta-package-type;\n }\n\n # If we're not executing a shielding request, and the URL is one of our file\n # URLs, and it's a GET request, and the response is either a 200 or a 304\n # then we want to log an event stating that a download has taken place.\n if (!req.http.Fastly-FF\n && std.tolower(req.http.host) == \"files.pythonhosted.org\"\n && req.url.path ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\"\n && req.request == \"GET\"\n && http_status_matches(resp.status, \"200,304\")) {\n log {\"syslog \"} req.service_id {\" linehaul :: \"} \"2@\" now \"|\" geoip.country_code \"|\" req.url.path \"|\" tls.client.protocol \"|\" tls.client.cipher \"|\" resp.http.x-amz-meta-project \"|\" resp.http.x-amz-meta-version \"|\" resp.http.x-amz-meta-package-type \"|\" req.http.user-agent;\n log {\"syslog \"} req.service_id {\" downloads :: \"} \"2@\" now \"|\" geoip.country_code \"|\" req.url.path \"|\" tls.client.protocol \"|\" tls.client.cipher \"|\" resp.http.x-amz-meta-project \"|\" resp.http.x-amz-meta-version \"|\" resp.http.x-amz-meta-package-type \"|\" req.http.user-agent;\n }\n\n return(deliver);\n}\n\n\nsub vcl_error {\n#FASTLY error\n\n # If we have a 5xx error and there is a stale object available, then we\n # will deliver that stale object.\n if (obj.status >= 500 && obj.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n if (obj.status == 803) {\n set obj.status = 403;\n set obj.response = \"SSL is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic {\"SSL is required.\"};\n return (deliver);\n } else if (obj.status == 750) {\n set obj.status = 301;\n set obj.http.Location = req.http.Location;\n set obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n synthetic {\"<html><head><title>301 Moved Permanently<\/title><\/head><body><center><h1>301 Moved Permanently<\/h1><\/center><\/body><\/html>\"};\n return(deliver);\n }\n\n}\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"3fd9d0c5c6086c35a37c76fd1a2ebd8d7df48cdd","subject":"Simplified varnish cookie cleanup rules","message":"Simplified varnish cookie cleanup rules\n\n* Removed cleanup of 'has_js' (remnant of drupal stuff from vcl template)\n* Removed specific cookie checks, instead removing any underscore prefixed\n* Left in removal of Google Analytics \"utm\" prefixed cookies (debateable, @ericclemmons might have opinion here)\n\nFixes #28 but more vcl cleanup to do...\n","repos":"evolution\/wordpress,genesis\/wordpress,jalevin\/wordpress,evolution\/genesis-wordpress,evolution\/wordpress,evolution\/wordpress,evolution\/genesis-wordpress,genesis\/wordpress,evolution\/genesis-wordpress,jalevin\/wordpress,jalevin\/wordpress,genesis\/wordpress,evolution\/genesis-wordpress,evolution\/wordpress,genesis\/wordpress,evolution\/wordpress,evolution\/genesis-wordpress,genesis\/wordpress,jalevin\/wordpress,evolution\/genesis-wordpress,genesis\/wordpress,jalevin\/wordpress","old_file":"provisioning\/roles\/varnish\/files\/etc-varnish\/production.vcl","new_file":"provisioning\/roles\/varnish\/files\/etc-varnish\/production.vcl","new_contents":"# Default backend definition. Set this to point to your content server.\n# all paths relative to varnish option vcl_dir\n\ninclude \"custom.backend.vcl\";\ninclude \"custom.acl.vcl\";\n\n# Handle the HTTP request received by the client\nsub vcl_recv {\n # varnish serves stale (but cacheable) objects while retriving object from backend\n if (req.backend.healthy) {\n set req.grace = 30s;\n } else {\n set req.grace = 1h;\n }\n\n # shortcut for DFind requests\n if (req.url ~ \"^\/w00tw00t\") {\n error 404 \"Not Found\";\n }\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n # Normalize the header, remove the port (in case you're testing this on various TCP ports)\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n # Allow purging\n if (req.request == \"PURGE\") {\n if (!client.ip ~ purge) {\n # Not from an allowed IP? Then die with an error.\n error 405 \"This IP is not allowed to send PURGE requests.\";\n }\n\n # If you got this stage (and didn't error out above), do a cache-lookup\n # That will force entry into vcl_hit() or vcl_miss() below and purge the actual cache\n return (lookup);\n }\n\n # Only deal with \"normal\" types\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"PATCH\" &&\n req.request != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n # We only deal with GET and HEAD by default\n return (pass);\n }\n\n # Some generic URL manipulation, useful for all templates that follow\n # First remove the Google Analytics added parameters, useless for our backend\n if (req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=\") {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # Strip hash, server doesn't need it.\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n # Strip a trailing ? if it exists\n if (req.url ~ \"\\?$\") {\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # This is an example to redirect with a 301\/302 HTTP status code from within Varnish\n # if (req.http.Host ~ \"secure.mysite.tld\") {\n # # We may want to force our users from the secure site to the HTTPs version?\n # error 720 \"https:\/\/secure.mysite.tld\";\n # # If you want to keep the URLs intact, this also works:\n # error 720 \"https:\/\/\" + req.http.Host + req.url;\n # }\n #\n # Or to force a 302 temporary redirect, use error 721\n # if (req.http.Host ~ \"temp.mysite.tld\") {\n # # Temporary redirect\n # error 721 \"http:\/\/mysite.tld\/temp\";\n # }\n #\n\n # Some generic cookie manipulation, useful for all templates that follow\n\n # Remove any '_' prefixed cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"_[^=]+=[^;]+(; )?\", \"\");\n\n # Remove any Google Analytics based cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmctr=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmcmd.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmccn.=[^;]+(; )?\", \"\");\n\n # Remove a \";\" prefix in the cookie if present\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n\n # Are there cookies left with only spaces or that are empty?\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n\n # Normalize Accept-Encoding header\n # straight from the manual: https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/vary.html\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n # No point in compressing these\n remove req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n # unkown algorithm\n remove req.http.Accept-Encoding;\n }\n }\n\n # Include custom vcl_recv logic\n include \"conf.d\/receive\/wordpress.vcl\";\n\n # Remove all cookies for static files\n # A valid discussion could be held on this line: do you really need to cache static files that don't cause load? Only if you have memory left.\n # Sure, there's disk I\/O, but chances are your OS will already have these files in their buffers (thus memory).\n # Before you blindly enable this, have a read here: http:\/\/mattiasgeniar.be\/2012\/11\/28\/stop-caching-static-files\/\n if (req.url ~ \"^[^?]*\\.(bmp|bz2|css|doc|eot|flv|gif|gz|ico|jpeg|jpg|js|less|mp[34]|pdf|png|rar|rtf|swf|tar|tgz|txt|wav|woff|xml|zip)(\\?.*)?$\") {\n unset req.http.Cookie;\n return (lookup);\n }\n\n # Send Surrogate-Capability headers to announce ESI support to backend\n set req.http.Surrogate-Capability = \"key=ESI\/1.0\";\n\n if (req.http.Authorization || req.http.Cookie) {\n # Not cacheable by default\n return (pass);\n }\n\n return (lookup);\n}\n\nsub vcl_pipe {\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n # set bereq.http.connection = \"close\";\n # here. It is not set by default as it might break some broken web\n # applications, like IIS with NTLM authentication.\n\n #set bereq.http.Connection = \"Close\";\n return (pipe);\n}\n\nsub vcl_pass {\n return (pass);\n}\n\n# The data on which the hashing will take place\nsub vcl_hash {\n hash_data(req.url);\n\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n\n # hash cookies for object with auth\n if (req.http.Cookie) {\n hash_data(req.http.Cookie);\n }\n if (req.http.Authorization) {\n hash_data(req.http.Authorization);\n }\n\n return (hash);\n}\n\nsub vcl_hit {\n # Allow purges\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"purged\";\n }\n\n return (deliver);\n}\n\nsub vcl_miss {\n # Allow purges\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"purged\";\n }\n\n return (fetch);\n}\n\n# Handle the HTTP request coming from our backend\nsub vcl_fetch {\n set beresp.grace = 1h;\n\n # Include custom vcl_fetch logic\n include \"conf.d\/fetch\/wordpress.vcl\";\n\n # Parse ESI request and remove Surrogate-Control header\n if (beresp.http.Surrogate-Control ~ \"ESI\/1.0\") {\n unset beresp.http.Surrogate-Control;\n set beresp.do_esi = true;\n }\n\n # If the request to the backend returns a code is 5xx, restart the loop\n # If the number of restarts reaches the value of the parameter max_restarts,\n # the request will be error'ed. max_restarts defaults to 4. This prevents\n # an eternal loop in the event that, e.g., the object does not exist at all.\n if (beresp.status >= 500 && beresp.status <= 599){\n return(restart);\n }\n\n # Enable cache for all static files\n # The same argument as the static caches from above: monitor your cache size, if you get data nuked out of it, consider giving up the static file cache.\n # Before you blindly enable this, have a read here: http:\/\/mattiasgeniar.be\/2012\/11\/28\/stop-caching-static-files\/\n if (req.url ~ \"^[^?]*\\.(bmp|bz2|css|doc|eot|flv|gif|gz|ico|jpeg|jpg|js|less|mp[34]|pdf|png|rar|rtf|swf|tar|tgz|txt|wav|woff|xml|zip)(\\?.*)?$\") {\n unset beresp.http.set-cookie;\n }\n\n # Sometimes, a 301 or 302 redirect formed via Apache's mod_rewrite can mess with the HTTP port that is being passed along.\n # This often happens with simple rewrite rules in a scenario where Varnish runs on :80 and Apache on :8080 on the same box.\n # A redirect can then often redirect the end-user to a URL on :8080, where it should be :80.\n # This may need finetuning on your setup.\n #\n # To prevent accidental replace, we only filter the 301\/302 redirects for now.\n if (beresp.status == 301 || beresp.status == 302) {\n set beresp.http.Location = regsub(beresp.http.Location, \":[0-9]+\", \"\");\n }\n\n # Don't cache user & server errors\n if (beresp.status >= 400) {\n return (hit_for_pass);\n }\n\n # Non private responses without cookies and with a ttl of 0 should be artificially extended to 1 hour\n if (beresp.ttl <= 0s && beresp.http.Cache-Control !~ \"private\" && (!beresp.http.Set-Cookie)) {\n set beresp.ttl = 1h;\n set beresp.http.X-Cache-Extended = \"1\";\n }\n\n # Set 2min cache if unset for static files\n if (beresp.ttl <= 0s || beresp.http.Set-Cookie || beresp.http.Vary == \"*\") {\n set beresp.ttl = 120s;\n return (hit_for_pass);\n }\n\n return (deliver);\n}\n\n# The routine when we deliver the HTTP request to the user\n# Last chance to modify headers that are sent to the client\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"cached\";\n } else {\n set resp.http.x-Cache = \"uncached\";\n }\n\n # Remove some headers: PHP version\n unset resp.http.X-Powered-By;\n\n # Remove some headers: Apache version & OS\n unset resp.http.Server;\n unset resp.http.X-Drupal-Cache;\n unset resp.http.X-Varnish;\n unset resp.http.Via;\n unset resp.http.Link;\n\n return (deliver);\n}\n\nsub vcl_error {\n if (obj.status == 720) {\n # We use this special error status 720 to force redirects with 301 (permanent) redirects\n # To use this, call the following from anywhere in vcl_recv: error 720 \"http:\/\/host\/new.html\"\n set obj.status = 301;\n set obj.http.Location = obj.response;\n return (deliver);\n } elseif (obj.status == 721) {\n # And we use error status 721 to force redirects with a 302 (temporary) redirect\n # To use this, call the following from anywhere in vcl_recv: error 720 \"http:\/\/host\/new.html\"\n set obj.status = 302;\n set obj.http.Location = obj.response;\n return (deliver);\n }\n\n return (deliver);\n}\n\nsub vcl_init {\n return (ok);\n}\n\nsub vcl_fini {\n return (ok);\n}\n","old_contents":"# Default backend definition. Set this to point to your content server.\n# all paths relative to varnish option vcl_dir\n\ninclude \"custom.backend.vcl\";\ninclude \"custom.acl.vcl\";\n\n# Handle the HTTP request received by the client\nsub vcl_recv {\n # varnish serves stale (but cacheable) objects while retriving object from backend\n if (req.backend.healthy) {\n set req.grace = 30s;\n } else {\n set req.grace = 1h;\n }\n\n # shortcut for DFind requests\n if (req.url ~ \"^\/w00tw00t\") {\n error 404 \"Not Found\";\n }\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n # Normalize the header, remove the port (in case you're testing this on various TCP ports)\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n # Allow purging\n if (req.request == \"PURGE\") {\n if (!client.ip ~ purge) {\n # Not from an allowed IP? Then die with an error.\n error 405 \"This IP is not allowed to send PURGE requests.\";\n }\n\n # If you got this stage (and didn't error out above), do a cache-lookup\n # That will force entry into vcl_hit() or vcl_miss() below and purge the actual cache\n return (lookup);\n }\n\n # Only deal with \"normal\" types\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"PATCH\" &&\n req.request != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n # We only deal with GET and HEAD by default\n return (pass);\n }\n\n # Some generic URL manipulation, useful for all templates that follow\n # First remove the Google Analytics added parameters, useless for our backend\n if (req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=\") {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # Strip hash, server doesn't need it.\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n # Strip a trailing ? if it exists\n if (req.url ~ \"\\?$\") {\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # This is an example to redirect with a 301\/302 HTTP status code from within Varnish\n # if (req.http.Host ~ \"secure.mysite.tld\") {\n # # We may want to force our users from the secure site to the HTTPs version?\n # error 720 \"https:\/\/secure.mysite.tld\";\n # # If you want to keep the URLs intact, this also works:\n # error 720 \"https:\/\/\" + req.http.Host + req.url;\n # }\n #\n # Or to force a 302 temporary redirect, use error 721\n # if (req.http.Host ~ \"temp.mysite.tld\") {\n # # Temporary redirect\n # error 721 \"http:\/\/mysite.tld\/temp\";\n # }\n #\n\n # Some generic cookie manipulation, useful for all templates that follow\n # Remove the \"has_js\" cookie\n set req.http.Cookie = regsuball(req.http.Cookie, \"has_js=[^;]+(; )?\", \"\");\n\n # Remove any Satallite cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__gaid=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"_sdsat_[^=]+=[^;]+(; )?\", \"\");\n\n # Remove any Google Analytics based cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__utm.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"_ga=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmctr=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmcmd.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmccn.=[^;]+(; )?\", \"\");\n\n # Remove any Cloudflare cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__cfduid=[^;]+(; )?\", \"\");\n\n # Remove the Quant Capital cookies (added by some plugin, all __qca)\n set req.http.Cookie = regsuball(req.http.Cookie, \"__qc.=[^;]+(; )?\", \"\");\n\n # Remove the AddThis cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__atuvc=[^;]+(; )?\", \"\");\n\n # Remove a \";\" prefix in the cookie if present\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n\n # Are there cookies left with only spaces or that are empty?\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n\n # Normalize Accept-Encoding header\n # straight from the manual: https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/vary.html\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n # No point in compressing these\n remove req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n # unkown algorithm\n remove req.http.Accept-Encoding;\n }\n }\n\n # Include custom vcl_recv logic\n include \"conf.d\/receive\/wordpress.vcl\";\n\n # Remove all cookies for static files\n # A valid discussion could be held on this line: do you really need to cache static files that don't cause load? Only if you have memory left.\n # Sure, there's disk I\/O, but chances are your OS will already have these files in their buffers (thus memory).\n # Before you blindly enable this, have a read here: http:\/\/mattiasgeniar.be\/2012\/11\/28\/stop-caching-static-files\/\n if (req.url ~ \"^[^?]*\\.(bmp|bz2|css|doc|eot|flv|gif|gz|ico|jpeg|jpg|js|less|mp[34]|pdf|png|rar|rtf|swf|tar|tgz|txt|wav|woff|xml|zip)(\\?.*)?$\") {\n unset req.http.Cookie;\n return (lookup);\n }\n\n # Send Surrogate-Capability headers to announce ESI support to backend\n set req.http.Surrogate-Capability = \"key=ESI\/1.0\";\n\n if (req.http.Authorization || req.http.Cookie) {\n # Not cacheable by default\n return (pass);\n }\n\n return (lookup);\n}\n\nsub vcl_pipe {\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n # set bereq.http.connection = \"close\";\n # here. It is not set by default as it might break some broken web\n # applications, like IIS with NTLM authentication.\n\n #set bereq.http.Connection = \"Close\";\n return (pipe);\n}\n\nsub vcl_pass {\n return (pass);\n}\n\n# The data on which the hashing will take place\nsub vcl_hash {\n hash_data(req.url);\n\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n\n # hash cookies for object with auth\n if (req.http.Cookie) {\n hash_data(req.http.Cookie);\n }\n if (req.http.Authorization) {\n hash_data(req.http.Authorization);\n }\n\n return (hash);\n}\n\nsub vcl_hit {\n # Allow purges\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"purged\";\n }\n\n return (deliver);\n}\n\nsub vcl_miss {\n # Allow purges\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"purged\";\n }\n\n return (fetch);\n}\n\n# Handle the HTTP request coming from our backend\nsub vcl_fetch {\n set beresp.grace = 1h;\n\n # Include custom vcl_fetch logic\n include \"conf.d\/fetch\/wordpress.vcl\";\n\n # Parse ESI request and remove Surrogate-Control header\n if (beresp.http.Surrogate-Control ~ \"ESI\/1.0\") {\n unset beresp.http.Surrogate-Control;\n set beresp.do_esi = true;\n }\n\n # If the request to the backend returns a code is 5xx, restart the loop\n # If the number of restarts reaches the value of the parameter max_restarts,\n # the request will be error'ed. max_restarts defaults to 4. This prevents\n # an eternal loop in the event that, e.g., the object does not exist at all.\n if (beresp.status >= 500 && beresp.status <= 599){\n return(restart);\n }\n\n # Enable cache for all static files\n # The same argument as the static caches from above: monitor your cache size, if you get data nuked out of it, consider giving up the static file cache.\n # Before you blindly enable this, have a read here: http:\/\/mattiasgeniar.be\/2012\/11\/28\/stop-caching-static-files\/\n if (req.url ~ \"^[^?]*\\.(bmp|bz2|css|doc|eot|flv|gif|gz|ico|jpeg|jpg|js|less|mp[34]|pdf|png|rar|rtf|swf|tar|tgz|txt|wav|woff|xml|zip)(\\?.*)?$\") {\n unset beresp.http.set-cookie;\n }\n\n # Sometimes, a 301 or 302 redirect formed via Apache's mod_rewrite can mess with the HTTP port that is being passed along.\n # This often happens with simple rewrite rules in a scenario where Varnish runs on :80 and Apache on :8080 on the same box.\n # A redirect can then often redirect the end-user to a URL on :8080, where it should be :80.\n # This may need finetuning on your setup.\n #\n # To prevent accidental replace, we only filter the 301\/302 redirects for now.\n if (beresp.status == 301 || beresp.status == 302) {\n set beresp.http.Location = regsub(beresp.http.Location, \":[0-9]+\", \"\");\n }\n\n # Don't cache user & server errors\n if (beresp.status >= 400) {\n return (hit_for_pass);\n }\n\n # Non private responses without cookies and with a ttl of 0 should be artificially extended to 1 hour\n if (beresp.ttl <= 0s && beresp.http.Cache-Control !~ \"private\" && (!beresp.http.Set-Cookie)) {\n set beresp.ttl = 1h;\n set beresp.http.X-Cache-Extended = \"1\";\n }\n\n # Set 2min cache if unset for static files\n if (beresp.ttl <= 0s || beresp.http.Set-Cookie || beresp.http.Vary == \"*\") {\n set beresp.ttl = 120s;\n return (hit_for_pass);\n }\n\n return (deliver);\n}\n\n# The routine when we deliver the HTTP request to the user\n# Last chance to modify headers that are sent to the client\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"cached\";\n } else {\n set resp.http.x-Cache = \"uncached\";\n }\n\n # Remove some headers: PHP version\n unset resp.http.X-Powered-By;\n\n # Remove some headers: Apache version & OS\n unset resp.http.Server;\n unset resp.http.X-Drupal-Cache;\n unset resp.http.X-Varnish;\n unset resp.http.Via;\n unset resp.http.Link;\n\n return (deliver);\n}\n\nsub vcl_error {\n if (obj.status == 720) {\n # We use this special error status 720 to force redirects with 301 (permanent) redirects\n # To use this, call the following from anywhere in vcl_recv: error 720 \"http:\/\/host\/new.html\"\n set obj.status = 301;\n set obj.http.Location = obj.response;\n return (deliver);\n } elseif (obj.status == 721) {\n # And we use error status 721 to force redirects with a 302 (temporary) redirect\n # To use this, call the following from anywhere in vcl_recv: error 720 \"http:\/\/host\/new.html\"\n set obj.status = 302;\n set obj.http.Location = obj.response;\n return (deliver);\n }\n\n return (deliver);\n}\n\nsub vcl_init {\n return (ok);\n}\n\nsub vcl_fini {\n return (ok);\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"64bd8c9208d73c64ff3a77178de2c987ad22a80e","subject":"update varnish","message":"update varnish\n","repos":"derbyjs\/candygram","old_file":"varnish_default.vcl","new_file":"varnish_default.vcl","new_contents":"# This is a basic VCL configuration file for varnish. See the vcl(7)\n# man page for details on VCL syntax and semantics.\n\nimport std;\n\n# static\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"4000\";\n}\nbackend components {\n .host = \"127.0.0.1\";\n .port = \"3330\";\n}\nbackend charts {\n .host = \"127.0.0.1\";\n .port = \"8001\";\n}\nbackend chat {\n .host = \"127.0.0.1\";\n .port = \"8002\";\n}\nbackend codemirror {\n .host = \"127.0.0.1\";\n .port = \"8003\";\n}\nbackend directory {\n .host = \"127.0.0.1\";\n .port = \"8004\";\n}\nbackend hello {\n .host = \"127.0.0.1\";\n .port = \"8005\";\n}\nbackend sink {\n .host = \"127.0.0.1\";\n .port = \"8006\";\n}\nbackend todos {\n .host = \"127.0.0.1\";\n .port = \"8007\";\n}\nbackend widgets {\n .host = \"127.0.0.1\";\n .port = \"8008\";\n}\n\n\nsub vcl_recv {\n if (!req.http.Host) {\n error 404 \"Need a host header\";\n }\n\n set req.http.Host = regsub(req.http.Host, \"^www\\.\", \"\");\n set req.http.Host = regsub(req.http.Host, \":80$\", \"\");\n\n if (req.restarts == 0) {\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For =\n req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n if (req.http.Host ~ \"^components\\.\") {\n set req.backend = components;\n } else if (req.http.Host ~ \"^charts\\.\") {\n set req.backend = charts;\n } else if (req.http.Host ~ \"^chat\\.\") {\n set req.backend = chat;\n } else if (req.http.Host ~ \"^codemirror\\.\") {\n set req.backend = codemirror;\n } else if (req.http.Host ~ \"^directory\\.\") {\n set req.backend = directory;\n } else if (req.http.Host ~ \"^hello\\.\") {\n set req.backend = hello;\n } else if (req.http.Host ~ \"^sink\\.\") {\n set req.backend = sink;\n } else if (req.http.Host ~ \"^todos\\.\") {\n set req.backend = todos;\n } else if (req.http.Host ~ \"^widgets\\.\") {\n set req.backend = widgets;\n }\n\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization || req.http.Cookie) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n return (lookup);\n}\n\nsub vcl_pipe {\n # Websockets\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n set bereq.http.connection = \"close\";\n\n return (pipe);\n}\n\nsub vcl_fetch {\n # Compress responses\n if (beresp.http.content-type ~ \"text\"\n || beresp.http.content-type ~ \"json\"\n || beresp.http.content-type ~ \"javascript\") {\n set beresp.do_gzip = true;\n }\n}\n\nsub vcl_error {\n if (obj.status == 750) {\n # moved permanently\n set obj.http.Location = req.http.Location;\n set obj.status = 301;\n } else if (obj.status == 752) {\n # moved temporarily\n set obj.http.Location = req.http.Location;\n set obj.status = 302;\n } else {\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic std.fileread(\"\/etc\/varnish\/503.html\");\n }\n return (deliver);\n}\n","old_contents":"# This is a basic VCL configuration file for varnish. See the vcl(7)\n# man page for details on VCL syntax and semantics.\n\nimport std;\n\n# static\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"4000\";\n}\nbackend examples {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\nbackend components {\n .host = \"127.0.0.1\";\n .port = \"3330\";\n}\n\nsub vcl_recv {\n if (!req.http.Host) {\n error 404 \"Need a host header\";\n }\n\n set req.http.Host = regsub(req.http.Host, \"^www\\.\", \"\");\n set req.http.Host = regsub(req.http.Host, \":80$\", \"\");\n\n if (req.restarts == 0) {\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For =\n req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n if (\n req.http.Host ~ \"^chat\\.\" ||\n req.http.Host ~ \"^charts\\.\" ||\n req.http.Host ~ \"^directory\\.\" ||\n req.http.Host ~ \"^codemirror\\.\" ||\n req.http.Host ~ \"^hello\\.\" ||\n req.http.Host ~ \"^sink\\.\" ||\n req.http.Host ~ \"^todos\\.\" ||\n req.http.Host ~ \"^widgets\\.\"\n ) {\n set req.backend = examples;\n } else if (req.http.Host ~ \"^components\\.\") {\n set req.backend = components;\n }\n\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization || req.http.Cookie) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n return (lookup);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n if (req.http.Origin) {\n hash_data(req.http.Origin);\n }\n return (hash);\n}\n\nsub vcl_pipe {\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n set bereq.http.connection = \"close\";\n # here. It is not set by default as it might break some broken web\n # applications, like IIS with NTLM authentication.\n\n # Websockets\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n\n return (pipe);\n}\n\nsub vcl_fetch {\n # Compress responses\n if (beresp.http.content-type ~ \"text\"\n || beresp.http.content-type ~ \"json\"\n || beresp.http.content-type ~ \"javascript\") {\n set beresp.do_gzip = true;\n }\n}\n\nsub vcl_error {\n if (obj.status == 750) {\n # moved permanently\n set obj.http.Location = req.http.Location;\n set obj.status = 301;\n } else if (obj.status == 752) {\n # moved temporarily\n set obj.http.Location = req.http.Location;\n set obj.status = 302;\n } else {\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic std.fileread(\"\/etc\/varnish\/503.html\");\n }\n return (deliver);\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"dc99ac7cd5854c65af22844b15bcc35d5ddd3b41","subject":"Revert \"fix redirects\"","message":"Revert \"fix redirects\"\n\nThis reverts commit 2a9026b004e148db83e807411adfde4deece4515.\n","repos":"JakeChampion\/polyfill-service,JakeChampion\/polyfill-service","old_file":"fastly\/vcl\/redirects.vcl","new_file":"fastly\/vcl\/redirects.vcl","new_contents":"sub vcl_recv {\n\tif (req.http.Host ~ \"polyfills.io\") {\n\t\t# Fastly recommend using the 900-999 range of status codes for custom errors within an application's VCL.\n\t\t# Do the canonicalise check before the HTTPS check to avoid a double redirect\n\t\terror 901 \"Canonicalise\";\n\t}\n\tif (!req.http.Fastly-SSL) {\n\t\t# 801 is a special error code that Fastly uses to Force HTTPS on the request\n\t\terror 801 \"Redirect to HTTPS\";\n\t}\n\tif (req.http.Orig-URL ~ \"^\/v1\") {\n\t\terror 902 \"Redirect to V2\";\n\t}\n\n\tif (req.url.path == \"\/\" || req.url.path == \"\/v2\" || req.url.path == \"\/v2\/docs\/\") {\n\t\terror 908;\n\t}\n}\n\nsub vcl_error {\n # Redirect to canonical prod\/qa origins\n\tif (obj.status == 901) {\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\tset obj.http.Location = \"https:\/\/polyfill.io\" req.url;\n\t\tsynthetic {\"\"};\n\t\treturn (deliver);\n\t}\n\t# Redirect to v2\n\tif (obj.status == 902) {\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\t# Remove libVersion and gated query parameters if they exist.\n\t\tset req.url = querystring.regfilter(req.url, \"^\\b(libVersion|gated)\\b.*\");\n\t\tset obj.http.Location = if(req.url.path == \"\/v1\", \"\/v3\/\", regsub(req.url, \"^\/v1\", \"\/v2\"));\n\t\tset obj.http.Deprecation-Notice = \"API version 1 has been decommissioned - see the body of this response for more information.\";\n\t\tsynthetic {\"API version 1 has been decommissioned. Your request is being redirected to v2. The `libVersion` and `gated` query string parameters are no longer supported and if present have been removed from your request.\\n\\nA deprecation period for v1 existed between August and December 2015, during which time v1 requests were honoured but a deprecation warning was added to output.\"};\n\t\treturn (deliver);\n\t}\n\n\t# Redirect to v3\n\tif (obj.status == 908) {\n\t\tset obj.status = 301;\n\t\tset obj.http.Location = \"\/v3\/\";\n\t\treturn (deliver);\n\t}\n}\n","old_contents":"sub vcl_recv {\n\tif (req.http.Host ~ \"polyfills.io\") {\n\t\t# Fastly recommend using the 900-999 range of status codes for custom errors within an application's VCL.\n\t\t# Do the canonicalise check before the HTTPS check to avoid a double redirect\n\t\terror 901 \"Canonicalise\";\n\t}\n\tif (!req.http.Fastly-SSL) {\n\t\t# 801 is a special error code that Fastly uses to Force HTTPS on the request\n\t\terror 801 \"Redirect to HTTPS\";\n\t}\n\tif (req.http.Orig-URL ~ \"^\/v1\") {\n\t\terror 902 \"Redirect to V2\";\n\t}\n\n\tif (req.url.path == \"\/\" || req.url.path == \"\/v2\" || req.url.path == \"\/v2\/docs\" || req.url.path == \"\/v2\/docs\/\") {\n\t\terror 908;\n\t}\n}\n\nsub vcl_error {\n # Redirect to canonical prod\/qa origins\n\tif (obj.status == 901) {\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\tset obj.http.Location = \"https:\/\/polyfill.io\" req.url;\n\t\tsynthetic {\"\"};\n\t\treturn (deliver);\n\t}\n\t# Redirect to v2\n\tif (obj.status == 902) {\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\t# Remove libVersion and gated query parameters if they exist.\n\t\tset req.url = querystring.regfilter(req.url, \"^\\b(libVersion|gated)\\b.*\");\n\t\tset obj.http.Location = if(req.url.path == \"\/v1\", \"\/v3\/\", regsub(req.url, \"^\/v1\", \"\/v2\"));\n\t\tset obj.http.Deprecation-Notice = \"API version 1 has been decommissioned - see the body of this response for more information.\";\n\t\tsynthetic {\"API version 1 has been decommissioned. Your request is being redirected to v2. The `libVersion` and `gated` query string parameters are no longer supported and if present have been removed from your request.\\n\\nA deprecation period for v1 existed between August and December 2015, during which time v1 requests were honoured but a deprecation warning was added to output.\"};\n\t\treturn (deliver);\n\t}\n\n\t# Redirect to v3\n\tif (obj.status == 908) {\n\t\tset obj.status = 301;\n\t\tset obj.http.Location = \"\/v3\/\";\n\t\treturn (deliver);\n\t}\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"f1e7b88ef4e8d559e2623f752f94a29627c4ee19","subject":"Sort querystring using boltsort for better caching (#812)","message":"Sort querystring using boltsort for better caching (#812)\n\n* Sort querystring using boltsort for better caching\r\n\r\n* Update fastly-config.vcl\r\n","repos":"kdzwinel\/polyfill-service,mcshaz\/polyfill-service,jonathan-fielding\/polyfill-service,jonathan-fielding\/polyfill-service,kdzwinel\/polyfill-service,mcshaz\/polyfill-service,kdzwinel\/polyfill-service,jonathan-fielding\/polyfill-service,JakeChampion\/polyfill-service,mcshaz\/polyfill-service,JakeChampion\/polyfill-service","old_file":"fastly-config.vcl","new_file":"fastly-config.vcl","new_contents":"import boltsort;\n\nsub vcl_recv {\n#FASTLY recv\n\tif ( req.request == \"FASTLYPURGE\" ) {\n\t\tset req.http.Fastly-Purge-Requires-Auth = \"1\";\n\t}\n\n\tif (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n\t\treturn(pass);\n\t}\n\n\tif (!req.http.Fastly-SSL && (req.http.Host == \"cdn.polyfill.io\" || req.http.Host == \"polyfill.io\")) {\n\t\terror 751 \"Force TLS\";\n\t}\n\n\tif (req.url ~ \"^\/v2\/polyfill\\.\" && req.url !~ \"[\\?\\&]ua=\") {\n\t\tset req.http.X-Orig-URL = req.url;\n\t\tset req.url = \"\/v2\/normalizeUa?ua=\" urlencode(req.http.User-Agent);\n\t}\n\n\tif (req.url ~ \"^\/v2\/recordRumData\") {\n\t\terror 204 \"No Content\";\n\t}\n\n\tset req.url = boltsort.sort(req.url);\n\n\treturn(lookup);\n}\n\nsub vcl_deliver {\n#FASTLY deliver\n\n\t# If the response is to a normalise request and there's a parked \"original request\", use the normalised UA response to modify the original request and restart it\n\tif (req.url ~ \"^\/v\\d\/normalizeUa\" && resp.status == 200 && req.http.X-Orig-URL) {\n\t\tset req.http.Fastly-force-Shield = \"1\";\n\t\tif (req.http.X-Orig-URL ~ \"\\?\") {\n\t\t\tset req.url = req.http.X-Orig-URL \"&ua=\" resp.http.Normalized-User-Agent;\n\t\t} else {\n\t\t\tset req.url = req.http.X-Orig-URL \"?ua=\" resp.http.Normalized-User-Agent;\n\t\t}\n\t\trestart;\n\n\t# If the original request didn't specify a UA override, and we added one when the request was sent to the backend, the backend won't have included a Vary:user-agent header (correctly) but we need to add one\n\t} else if (req.url ~ \"^\/v\\d\/polyfill\\..*[\\?\\&]ua=\" && req.http.X-Orig-URL && req.http.X-Orig-URL !~ \"[\\?\\&]ua=\") {\n\t\tadd resp.http.Vary = \"User-Agent\";\n\t}\n\treturn(deliver);\n}\n\nsub vcl_error {\n\n\t# Redirect to SSL\n\tif (obj.status == 751) {\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\tset obj.http.Location = \"https:\/\/\" req.http.host req.url;\n\t\tsynthetic {\"\"};\n\t\treturn (deliver);\n\t}\n}\n","old_contents":"sub vcl_recv {\n#FASTLY recv\n\tif ( req.request == \"FASTLYPURGE\" ) {\n\t\tset req.http.Fastly-Purge-Requires-Auth = \"1\";\n\t}\n\n\tif (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n\t\treturn(pass);\n\t}\n\n\tif (!req.http.Fastly-SSL && (req.http.Host == \"cdn.polyfill.io\" || req.http.Host == \"polyfill.io\")) {\n\t\terror 751 \"Force TLS\";\n\t}\n\n\tif (req.url ~ \"^\/v2\/polyfill\\.\" && req.url !~ \"[\\?\\&]ua=\") {\n\t\tset req.http.X-Orig-URL = req.url;\n\t\tset req.url = \"\/v2\/normalizeUa?ua=\" urlencode(req.http.User-Agent);\n\t}\n\n\tif (req.url ~ \"^\/v2\/recordRumData\") {\n\t\terror 204 \"No Content\";\n\t}\n\n\treturn(lookup);\n}\n\nsub vcl_deliver {\n#FASTLY deliver\n\n\t# If the response is to a normalise request and there's a parked \"original request\", use the normalised UA response to modify the original request and restart it\n\tif (req.url ~ \"^\/v\\d\/normalizeUa\" && resp.status == 200 && req.http.X-Orig-URL) {\n\t\tset req.http.Fastly-force-Shield = \"1\";\n\t\tif (req.http.X-Orig-URL ~ \"\\?\") {\n\t\t\tset req.url = req.http.X-Orig-URL \"&ua=\" resp.http.Normalized-User-Agent;\n\t\t} else {\n\t\t\tset req.url = req.http.X-Orig-URL \"?ua=\" resp.http.Normalized-User-Agent;\n\t\t}\n\t\trestart;\n\n\t# If the original request didn't specify a UA override, and we added one when the request was sent to the backend, the backend won't have included a Vary:user-agent header (correctly) but we need to add one\n\t} else if (req.url ~ \"^\/v\\d\/polyfill\\..*[\\?\\&]ua=\" && req.http.X-Orig-URL && req.http.X-Orig-URL !~ \"[\\?\\&]ua=\") {\n\t\tadd resp.http.Vary = \"User-Agent\";\n\t}\n\treturn(deliver);\n}\n\nsub vcl_error {\n\n\t# Redirect to SSL\n\tif (obj.status == 751) {\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\tset obj.http.Location = \"https:\/\/\" req.http.host req.url;\n\t\tsynthetic {\"\"};\n\t\treturn (deliver);\n\t}\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"8b35e6c4fab9ac5b94a99448f2278fa2ab51a632","subject":"Reindent according to Varnish coding standards.","message":"Reindent according to Varnish coding standards.\n\nThanks to Sergey Syrota for pointing this out.\n","repos":"kevinquinnyo\/varnish-devicedetect,varnish\/varnish-devicedetect,varnish\/varnish-devicedetect,kevinquinnyo\/varnish-devicedetect,wikp\/varnish-devicedetect,wikp\/varnish-devicedetect","old_file":"devicedetect-dev.vcl","new_file":"devicedetect-dev.vcl","new_contents":"#\n# devicedetect-dev.vcl\n#\n# Enable test URLs and cookie overrides.\n#\n\nbackend devicetest {\n\t.host = \"127.0.0.1\";\n\t.port = \"5911\";\n}\n\nsub vcl_recv {\n\t# 701\/702 are arbitrary chosen return codes that is only used internally in varnish.\n\tif (req.url ~ \"^\/set_ua_device\/.+\") {\n\t\terror 701 regsub(req.url, \"^\/set_ua_device\/\", \"\");\n\t}\n\t# set expired cookie if nothing is specified\n\tif (req.url ~ \"^\/set_ua_device\/\") {\n\t\terror 702 \"OK\";\n\t}\n\tif (req.url ~ \"^\/devicetest\") {\n\t\tset req.backend = devicetest;\n\t}\n}\n\nsub vcl_error {\n\tif (obj.status == 701 || obj.status == 702) {\n\t\tif (obj.status == 702) {\n\t\t\tset obj.status = 200;\n\t\t\tset obj.http.Set-Cookie = \"X-UA-Device-force=expiring; Path=\/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;\";\n\t\t} else {\n\t\t\tset obj.status = 200;\n\t\t\tset obj.http.Set-Cookie = \"X-UA-Device-force=\" + obj.response + \"; Path=\/;\";\n\t\t}\n\t\tset obj.http.Content-Type = \"text\/html; charset=utf-8\";\n\t\tsynthetic {\"<html><body><h1>OK, Cookie updated<\/h1><a href='\/devicetest\/'>\/devicetest\/<\/a><\/body><\/html>\"};\n\t\tset obj.response = \"OK\";\n\t\treturn(deliver);\n\t}\n}\n","old_contents":"#\n# devicedetect-dev.vcl\n#\n# Enable test URLs and cookie overrides.\n#\n\nbackend devicetest {\n .host = \"127.0.0.1\";\n .port = \"5911\";\n}\n\nsub vcl_recv {\n # 701\/702 are arbitrary chosen return codes that is only used internally in varnish.\n if (req.url ~ \"^\/set_ua_device\/.+\") { error 701 regsub(req.url, \"^\/set_ua_device\/\", \"\"); }\n # set expired cookie if nothing is specified\n if (req.url ~ \"^\/set_ua_device\/\") { error 702 \"OK\"; }\n if (req.url ~ \"^\/devicetest\") { set req.backend = devicetest; }\n}\n\nsub vcl_error {\n if (obj.status == 701 || obj.status == 702) {\n if (obj.status == 702) {\n set obj.status = 200;\n set obj.http.Set-Cookie = \"X-UA-Device-force=expiring; Path=\/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;\";\n\n\t} else {\n\t set obj.status = 200;\n\t set obj.http.Set-Cookie = \"X-UA-Device-force=\" + obj.response + \"; Path=\/;\";\n\t}\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n synthetic {\"<html><body><h1>OK, Cookie updated<\/h1><a href='\/devicetest\/'>\/devicetest\/<\/a><\/body><\/html>\"};\n set obj.response = \"OK\";\n return(deliver);\n }\n}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"c93a3c9dc955b1577cd4e96575b76476ecfc7b48","subject":"Do not cache readiness probe","message":"Do not cache readiness probe\n","repos":"epfl-idevelop\/jahia2wp,epfl-idevelop\/jahia2wp,epfl-idevelop\/jahia2wp,epfl-idevelop\/jahia2wp","old_file":"build\/varnish\/default.vcl","new_file":"build\/varnish\/default.vcl","new_contents":"vcl 4.0;\n\nbackend default {\n .host = \"localhost\";\n .port = \"8080\";\n}\n\n\n# Set the allowed IPs of purge requests\nacl purge {\n \"localhost\";\n \"127.0.0.1\";\n}\n\n\nsub vcl_recv {\n\n # Handle purge requests\n if (req.method == \"PURGE\") {\n if (client.ip !~ purge) {\n return (synth(405));\n }\n\n if (req.http.X-Purge-Method == \"regex\") {\n ban(\"req.url ~ \" + req.url + \" && req.http.host ~ \" + req.http.host);\n return (synth(200, \"Banned.\"));\n } else {\n return (purge);\n }\n }\n\n # Do not cache readiness probe\n if (req.url ~ \"\/ready(\/)?\") {\n\t return ( pass );\n }\n\n # Do not cache rss feed\n if (req.url ~ \"\/feed(\/)?\") {\n\t return ( pass );\n }\n\n # Do not cache cron\n if (req.url ~ \"wp-cron\\.php.*\") {\n return ( pass );\n }\n\n # Do not cache search result\n if (req.url ~ \"\/\\?s\\=\") {\n\t return ( pass );\n }\n\n # Exclude admin and login urls\n if (req.url ~ \"wp-admin|wp-login\") {\n return (pass);\n }\n\n # Ignore some wp cookies\n set req.http.cookie = regsuball(req.http.cookie, \"wp-settings-\\d+=[^;]+(; )?\", \"\");\n set req.http.cookie = regsuball(req.http.cookie, \"wp-settings-time-\\d+=[^;]+(; )?\", \"\");\n set req.http.cookie = regsuball(req.http.cookie, \"wordpress_test_cookie=[^;]+(; )?\", \"\");\n if (req.http.cookie == \"\") {\n unset req.http.cookie;\n }\n\n}\n\n\n# Extend cache\nsub vcl_backend_response {\n if (beresp.ttl == 120s) {\n set beresp.ttl = 1h;\n }\n}\n","old_contents":"vcl 4.0;\n\nbackend default {\n .host = \"localhost\";\n .port = \"8080\";\n}\n\n\n# Set the allowed IPs of purge requests\nacl purge {\n \"localhost\";\n \"127.0.0.1\";\n}\n\n\nsub vcl_recv {\n\n # Handle purge requests\n if (req.method == \"PURGE\") {\n if (client.ip !~ purge) {\n return (synth(405));\n }\n\n if (req.http.X-Purge-Method == \"regex\") {\n ban(\"req.url ~ \" + req.url + \" && req.http.host ~ \" + req.http.host);\n return (synth(200, \"Banned.\"));\n } else {\n return (purge);\n }\n }\n\n # Do not cache rss feed\n if (req.url ~ \"\/feed(\/)?\") {\n\t return ( pass );\n }\n\n # Do not cache cron\n if (req.url ~ \"wp-cron\\.php.*\") {\n return ( pass );\n }\n\n # Do not cache search result\n if (req.url ~ \"\/\\?s\\=\") {\n\t return ( pass );\n }\n\n # Exclude admin and login urls\n if (req.url ~ \"wp-admin|wp-login\") {\n return (pass);\n }\n\n # Ignore some wp cookies\n set req.http.cookie = regsuball(req.http.cookie, \"wp-settings-\\d+=[^;]+(; )?\", \"\");\n set req.http.cookie = regsuball(req.http.cookie, \"wp-settings-time-\\d+=[^;]+(; )?\", \"\");\n set req.http.cookie = regsuball(req.http.cookie, \"wordpress_test_cookie=[^;]+(; )?\", \"\");\n if (req.http.cookie == \"\") {\n unset req.http.cookie;\n }\n\n}\n\n\n# Extend cache\nsub vcl_backend_response {\n if (beresp.ttl == 120s) {\n set beresp.ttl = 1h;\n }\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"5b7766c25a95825ac13d39f2a6d5b7d5298f103c","subject":"This check is not necessary as Fastly already does this","message":"This check is not necessary as Fastly already does this\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets\/error.vcl","new_file":"etc\/vcl_snippets\/error.vcl","new_contents":" \/* handle 503s *\/\n if (obj.status >= 500 && obj.status < 600) {\n\n \/* deliver stale object if it is available *\/\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n","old_contents":" # workaround for possible security issue\n if (req.url ~ \"^\\s\") {\n set obj.status = 400;\n set obj.response = \"Malformed request\";\n synthetic \"\";\n return (deliver);\n }\n\n \/* handle 503s *\/\n if (obj.status >= 500 && obj.status < 600) {\n\n \/* deliver stale object if it is available *\/\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"9213565c4204842df652139f25dabcb94668a045","subject":"84 - varnish bypass is a direct route to nginx-php now","message":"84 - varnish bypass is a direct route to nginx-php now\n","repos":"amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon","old_file":"images\/varnish\/default.vcl","new_file":"images\/varnish\/default.vcl","new_contents":"vcl 4.0;\n\nimport std;\nimport directors;\n\n# set backend backend\nbackend backend {\n .host = \"${VARNISH_HOST:-nginx-php}\";\n .port = \"8080\";\n .first_byte_timeout = 35m;\n .between_bytes_timeout = 10m;\n}\n\nsub vcl_init {\n # set director webworker\n new webworker = directors.round_robin();\n webworker.add_backend(backend);\n}\n\n# Allow purging from localhost\n# @TODO allow from openshift network\nacl purge {\n \"127.0.0.1\";\n}\n\n# This configuration is optimized for Drupal hosting:\n# Respond to incoming requests.\nsub vcl_recv {\n if (req.url ~ \"^\/varnish_status$\") {\n return (synth(700,\"OK\"));\n }\n # set the backend, which should be used:\n set req.backend_hint = webworker.backend();\n\n # Always set the forward ip.\n if (req.restarts == 0) {\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n # SA-CORE-2014-004 preventing access to \/xmlrpc.php\n if (req.url ~ \"^\/xmlrpc.php$\") {\n return (synth(701, \"Unauthorized\"));\n }\n\n # Strip out Google Analytics campaign variables. They are only needed\n # by the javascript running on the page\n # utm_source, utm_medium, utm_campaign, gclid\n if(req.url ~ \"(\\?|&)(gclid|utm_[a-z]+)=\") {\n set req.url = regsuball(req.url, \"(gclid|utm_[a-z]+)=[^\\&]+&?\", \"\");\n set req.url = regsub(req.url, \"(\\?|&)$\", \"\");\n }\n\n # We set a header to let a Varnish Chain know that it already has been varnishcached\n set req.http.X-LAGOON-VARNISH = \"d3659c5e113e.amazee.io\";\n\n # Bypass a cache hit\n if (req.method == \"REFRESH\") {\n if (!client.ip ~ purge) { return (synth(405, \"Not allowed\")); }\n set req.method = \"GET\";\n set req.hash_always_miss = true;\n }\n\n # Non-RFC2616 or CONNECT which is weird, we pipe that\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n return (pipe);\n }\n\n # We only try to cache GET and HEAD, other things are passed\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n # Any requests with Basic Auth are passed\n if (req.http.Authorization || req.http.Authenticate)\n {\n return (pass);\n }\n\n ## Pass requests which are from blackfire\n if (req.http.X-Blackfire-Query) {\n return (pass);\n }\n\n # Some URLs should never be cached\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/admin([\/?]|$).*$\" ||\n req.url ~ \"^\/info([\/?]|$).*$\" ||\n req.url ~ \"^\/flag([\/?]|$).*$\" ||\n req.url ~ \"^.*\/system\/files([\/?]|$).*$\" ||\n req.url ~ \"^\/amazeeadmin\" ||\n req.url ~ \"^\/lithium\" ||\n req.url ~ \"^\/cgi\" ||\n req.url ~ \"^\/cgi-bin\"\n ) {\n return (pass);\n }\n\n # Plupload likes to get piped\n if (req.url ~ \"^.*\/plupload-handle-uploads.*$\"\n ) {\n return (pipe);\n }\n\n # Handle compression correctly. Different browsers send different\n # \"Accept-Encoding\" headers, even though they mostly all support the same\n # compression mechanisms. By consolidating these compression headers into\n # a consistent format, we can reduce the size of the cache and get more hits.=\n # @see: http:\/\/ varnish.projects.linpro.no\/wiki\/FAQ\/Compression\n if (req.http.Accept-Encoding) {\n if (req.http.Accept-Encoding ~ \"gzip\") {\n # If the browser supports it, we'll use gzip.\n set req.http.Accept-Encoding = \"gzip\";\n }\n else if (req.http.Accept-Encoding ~ \"deflate\") {\n # Next, try deflate if it is supported.\n set req.http.Accept-Encoding = \"deflate\";\n }\n else {\n # Unknown algorithm. Remove it and send unencoded.\n unset req.http.Accept-Encoding;\n }\n }\n\n # Always cache the following file types for all users.\n if (req.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n unset req.http.Cookie;\n }\n\n # Remove all cookies that Drupal doesn't need to know about. ANY remaining\n # cookie will cause the request to pass-through to a backend. For the most part\n # we always set the NO_CACHE cookie after any POST request, disabling the\n # Varnish cache temporarily. The session cookie allows all authenticated users\n # to pass through as long as they're logged in.\n #\n # 1. Append a semi-colon to the front of the cookie string.\n # 2. Remove all spaces that appear after semi-colons.\n # 3. Match the cookies we want to keep, adding the space we removed\n # previously, back. (\\1) is first matching group in the regsuball.\n # 4. Remove all other cookies, identifying them by the fact that they have\n # no space after the preceding semi-colon.\n # 5. Remove all spaces and semi-colons from the beginning and end of the\n # cookie string.\n if (req.http.Cookie) {\n set req.http.CookieCheck = \";\" + req.http.Cookie;\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"; +\", \";\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";(SESS[a-z0-9]+|SSESS[a-z0-9]+|NO_CACHE)=\", \"; \\1=\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";[^ ][^;]*\", \"\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"^[; ]+|[; ]+$\", \"\");\n\n set req.http.Cookie = req.http.Cookie + \";\";\n\n if (req.http.CookieCheck == \"\") {\n # If there are no remaining cookies, remove the cookie header. If there\n # aren't any cookie headers, Varnish's default behavior will be to cache\n # the page.\n\n unset req.http.CookieCheck;\n unset req.http.Cookie;\n }\n else {\n # If there is any cookies left (a session or NO_CACHE cookie), do not\n # cache the page. Pass it on to Apache directly.\n unset req.http.CookieCheck;\n return (pass);\n }\n }\n\n # Cacheable, lookup in cache.\n return (hash);\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n # normal hit\n return (deliver);\n }\n # We have no fresh fish. Lets look at the stale ones.\n if (std.healthy(req.backend_hint)) {\n # Backend is healthy. If the object is not older then 30secs, deliver it to the client\n # and automatically create a separate backend request to warm the cache for this request.\n if (obj.ttl + 30s > 0s) {\n set req.http.grace = \"normal(limited)\";\n return (deliver);\n } else {\n # No candidate for grace. Fetch a fresh object.\n return(miss);\n }\n } else {\n # backend is sick - use full grace\n if (obj.ttl + obj.grace > 0s) {\n set req.http.grace = \"full\";\n return (deliver);\n } else {\n # no graced object.\n return (miss);\n }\n }\n}\n\nsub vcl_backend_response {\n # Temporarily disable streaming on files to be tested and removed after Varnish 4.1.x upgrade\n set beresp.do_stream = false;\n\n # Allow items to be stale if needed.\n set beresp.grace = 6h;\n\n ## FIXME: rename X-AMAZEEIO-VARNISH-BYPASS to X-AMAZEEIO-VARNISH-BACKEND-BYPASS to avoid confusion\n # If the backend sends a X-AMAZEEIO-VARNISH-BYPASS header we directly deliver\n if(beresp.http.X-AMAZEEIO-VARNISH-BYPASS == \"TRUE\") {\n return (deliver);\n }\n\n # Cache 404 and 403 for 10 seconds\n if(beresp.status == 404 || beresp.status == 403) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n # Don't allow static files to set cookies.\n if (bereq.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n # beresp == Back-end response from the web server.\n unset beresp.http.set-cookie;\n unset beresp.http.Cache-Control;\n set beresp.ttl = 2628001s;\n set beresp.http.Cache-Control = \"public, max-age=2628001\";\n set beresp.http.Expires = \"\" + (now + beresp.ttl);\n }\n\n return (deliver);\n}\n\n# Set a header to track a cache HIT\/MISS.\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Varnish-Cache = \"HIT\";\n }\n else {\n set resp.http.X-Varnish-Cache = \"MISS\";\n }\n unset resp.http.X-Generator;\n unset resp.http.Server;\n # Inject information about grace\n if (req.http.grace) {\n set resp.http.X-Varnish-Grace = req.http.grace;\n }\n set resp.http.X-AMAZEEIO = \"varnish>\" + resp.http.X-AMAZEEIO;\n return (deliver);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n if (req.http.X-Forwarded-Proto) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n if (req.http.HTTPS) {\n hash_data(req.http.HTTPS);\n }\n return (lookup);\n}\n\nsub vcl_synth {\n if (resp.status == 701) {\n set resp.status = 401;\n set resp.http.Content-Type = \"text\/plain; charset=utf-8\";\n synthetic({\"XMLRPC Interface is blocked due to SA-CORE-2014-004 - mail support@amazee.io if you need it.\"});\n return (deliver);\n }\n if (resp.status == 700) {\n # Set a status the client will understand\n set resp.status = 200;\n # Create our synthetic response\n synthetic(\"\");\n return(deliver);\n}\n return (deliver);\n}\n\nsub vcl_backend_error {\n # Restart the request, when we have a backend server error, to try another backend.\n # Restart max twice.\n if (bereq.retries < 2) {\n return(retry);\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<head>\n <title>Server Error<\/title>\n <style type=\"text\/css\">\n body {\n font-family: helvetica, arial, sans-serif;\n }\n img {\n margin-top: 50px;\n }\n p {\n width: 6 00px;\n margin-top: 10px\n }\n div {\n background: #ccc;\n width: 600px;\n margin: auto;\n padding: 50px;\n }\n span {\n color: #ccc\n }\n <\/style>\n<\/head>\n<body>\n <div>\n <h1>We are sorry...<\/h1>\n <p>We encountered a server-side error. This means that the problem is not with your computer or Internet connection, but rather with the website's server.<\/p>\n <p>We are currently working on solving this problem and apologise for the inconvenience.<\/p>\n <span>\n <strong>Technical Information<\/strong><br \/>\n Error \"} + beresp.status + \" \" + beresp.reason + {\"<br \/>\n XID: \"} + bereq.xid + {\"<br \/>\n <\/span>\n <\/div>\n<\/body>\n<\/html>\n\n\"} );\n return (deliver);\n}\n","old_contents":"vcl 4.0;\n\nimport std;\nimport directors;\n\n# set backend backend\nbackend backend {\n .host = \"${VARNISH_HOST:-nginx-php}\";\n .port = \"8080\";\n .first_byte_timeout = 35m;\n .between_bytes_timeout = 10m;\n}\n\nsub vcl_init {\n # set director webworker\n new webworker = directors.round_robin();\n webworker.add_backend(backend);\n}\n\n# Allow purging from localhost\n# @TODO allow from openshift network\nacl purge {\n \"127.0.0.1\";\n}\n\n# This configuration is optimized for Drupal hosting:\n# Respond to incoming requests.\nsub vcl_recv {\n if (req.url ~ \"^\/varnish_status$\") {\n return (synth(700,\"OK\"));\n }\n # set the backend, which should be used:\n set req.backend_hint = webworker.backend();\n\n # Always set the forward ip.\n if (req.restarts == 0) {\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n # SA-CORE-2014-004 preventing access to \/xmlrpc.php\n if (req.url ~ \"^\/xmlrpc.php$\") {\n return (synth(701, \"Unauthorized\"));\n }\n\n # Strip out Google Analytics campaign variables. They are only needed\n # by the javascript running on the page\n # utm_source, utm_medium, utm_campaign, gclid\n if(req.url ~ \"(\\?|&)(gclid|utm_[a-z]+)=\") {\n set req.url = regsuball(req.url, \"(gclid|utm_[a-z]+)=[^\\&]+&?\", \"\");\n set req.url = regsub(req.url, \"(\\?|&)$\", \"\");\n }\n\n ## Pass all Requests which are handled via an upstream Varnish\n if (req.http.X-AMAZEEIO-VARNISH) {\n set req.http.X-AMAZEEIO-VARNISH = \"d3659c5e113e.amazee.io, \" + req.http.X-AMAZEEIO-VARNISH;\n set req.http.X-AMAZEEIO-VARNISH-BYPASS = \"TRUE\";\n return (pass);\n } else if (req.http.Fastly-FF) {\n ## Pass all Requests which are handled via Fastly\n set req.http.X-AMAZEEIO-VARNISH = \"d3659c5e113e.amazee.io\";\n set req.http.X-AMAZEEIO-VARNISH-BYPASS = \"TRUE\";\n set req.http.X-Forwarded-For = req.http.Fastly-Client-IP;\n return (pass);\n } else if (req.http.CF-RAY) {\n ## Pass all Requests which are handled via CloudFlare\n set req.http.X-AMAZEEIO-VARNISH = \"d3659c5e113e.amazee.io\";\n set req.http.X-AMAZEEIO-VARNISH-BYPASS = \"TRUE\";\n set req.http.X-Forwarded-For = req.http.CF-Connecting-IP;\n return (pass);\n } else if (req.http.X-Pull) {\n ## Pass all Requests which are handled via KeyCDN\n set req.http.X-AMAZEEIO-VARNISH = \"d3659c5e113e.amazee.io\";\n set req.http.X-AMAZEEIO-VARNISH-BYPASS = \"TRUE\";\n return (pass);\n } else {\n # We set a header to let a Varnish Chain know that it already has been varnishcached\n set req.http.X-AMAZEEIO-VARNISH = \"d3659c5e113e.amazee.io\";\n }\n\n # Bypass a cache hit\n if (req.method == \"REFRESH\") {\n if (!client.ip ~ purge) { return (synth(405, \"Not allowed\")); }\n set req.method = \"GET\";\n set req.hash_always_miss = true;\n }\n\n # Non-RFC2616 or CONNECT which is weird, we pipe that\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n return (pipe);\n }\n\n # We only try to cache GET and HEAD, other things are passed\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n # Any requests with Basic Auth are passed\n if (req.http.Authorization || req.http.Authenticate)\n {\n return (pass);\n }\n\n ## Pass requests which are from blackfire\n if (req.http.X-Blackfire-Query) {\n return (pass);\n }\n\n # Some URLs should never be cached\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/admin([\/?]|$).*$\" ||\n req.url ~ \"^\/info([\/?]|$).*$\" ||\n req.url ~ \"^\/flag([\/?]|$).*$\" ||\n req.url ~ \"^.*\/system\/files([\/?]|$).*$\" ||\n req.url ~ \"^\/amazeeadmin\" ||\n req.url ~ \"^\/lithium\" ||\n req.url ~ \"^\/cgi\" ||\n req.url ~ \"^\/cgi-bin\"\n ) {\n return (pass);\n }\n\n # Plupload likes to get piped\n if (req.url ~ \"^.*\/plupload-handle-uploads.*$\"\n ) {\n return (pipe);\n }\n\n # Handle compression correctly. Different browsers send different\n # \"Accept-Encoding\" headers, even though they mostly all support the same\n # compression mechanisms. By consolidating these compression headers into\n # a consistent format, we can reduce the size of the cache and get more hits.=\n # @see: http:\/\/ varnish.projects.linpro.no\/wiki\/FAQ\/Compression\n if (req.http.Accept-Encoding) {\n if (req.http.Accept-Encoding ~ \"gzip\") {\n # If the browser supports it, we'll use gzip.\n set req.http.Accept-Encoding = \"gzip\";\n }\n else if (req.http.Accept-Encoding ~ \"deflate\") {\n # Next, try deflate if it is supported.\n set req.http.Accept-Encoding = \"deflate\";\n }\n else {\n # Unknown algorithm. Remove it and send unencoded.\n unset req.http.Accept-Encoding;\n }\n }\n\n # Always cache the following file types for all users.\n if (req.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n unset req.http.Cookie;\n }\n\n # Remove all cookies that Drupal doesn't need to know about. ANY remaining\n # cookie will cause the request to pass-through to a backend. For the most part\n # we always set the NO_CACHE cookie after any POST request, disabling the\n # Varnish cache temporarily. The session cookie allows all authenticated users\n # to pass through as long as they're logged in.\n #\n # 1. Append a semi-colon to the front of the cookie string.\n # 2. Remove all spaces that appear after semi-colons.\n # 3. Match the cookies we want to keep, adding the space we removed\n # previously, back. (\\1) is first matching group in the regsuball.\n # 4. Remove all other cookies, identifying them by the fact that they have\n # no space after the preceding semi-colon.\n # 5. Remove all spaces and semi-colons from the beginning and end of the\n # cookie string.\n if (req.http.Cookie) {\n set req.http.CookieCheck = \";\" + req.http.Cookie;\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"; +\", \";\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";(SESS[a-z0-9]+|SSESS[a-z0-9]+|NO_CACHE)=\", \"; \\1=\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";[^ ][^;]*\", \"\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"^[; ]+|[; ]+$\", \"\");\n\n set req.http.Cookie = req.http.Cookie + \";\";\n\n if (req.http.CookieCheck == \"\") {\n # If there are no remaining cookies, remove the cookie header. If there\n # aren't any cookie headers, Varnish's default behavior will be to cache\n # the page.\n\n unset req.http.CookieCheck;\n unset req.http.Cookie;\n }\n else {\n # If there is any cookies left (a session or NO_CACHE cookie), do not\n # cache the page. Pass it on to Apache directly.\n unset req.http.CookieCheck;\n return (pass);\n }\n }\n\n # Cacheable, lookup in cache.\n return (hash);\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n # normal hit\n return (deliver);\n }\n # We have no fresh fish. Lets look at the stale ones.\n if (std.healthy(req.backend_hint)) {\n # Backend is healthy. If the object is not older then 30secs, deliver it to the client\n # and automatically create a separate backend request to warm the cache for this request.\n if (obj.ttl + 30s > 0s) {\n set req.http.grace = \"normal(limited)\";\n return (deliver);\n } else {\n # No candidate for grace. Fetch a fresh object.\n return(miss);\n }\n } else {\n # backend is sick - use full grace\n if (obj.ttl + obj.grace > 0s) {\n set req.http.grace = \"full\";\n return (deliver);\n } else {\n # no graced object.\n return (miss);\n }\n }\n}\n\nsub vcl_backend_response {\n # Temporarily disable streaming on files to be tested and removed after Varnish 4.1.x upgrade\n set beresp.do_stream = false;\n\n # Allow items to be stale if needed.\n set beresp.grace = 6h;\n\n ## FIXME: rename X-AMAZEEIO-VARNISH-BYPASS to X-AMAZEEIO-VARNISH-BACKEND-BYPASS to avoid confusion\n # If the backend sends a X-AMAZEEIO-VARNISH-BYPASS header we directly deliver\n if(beresp.http.X-AMAZEEIO-VARNISH-BYPASS == \"TRUE\") {\n return (deliver);\n }\n\n # Cache 404 and 403 for 10 seconds\n if(beresp.status == 404 || beresp.status == 403) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n # Don't allow static files to set cookies.\n if (bereq.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n # beresp == Back-end response from the web server.\n unset beresp.http.set-cookie;\n unset beresp.http.Cache-Control;\n set beresp.ttl = 2628001s;\n set beresp.http.Cache-Control = \"public, max-age=2628001\";\n set beresp.http.Expires = \"\" + (now + beresp.ttl);\n }\n\n return (deliver);\n}\n\n# Set a header to track a cache HIT\/MISS.\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Varnish-Cache = \"HIT\";\n }\n else {\n set resp.http.X-Varnish-Cache = \"MISS\";\n }\n unset resp.http.X-Generator;\n unset resp.http.Server;\n # Inject information about grace\n if (req.http.grace) {\n set resp.http.X-Varnish-Grace = req.http.grace;\n }\n set resp.http.X-AMAZEEIO = \"varnish>\" + resp.http.X-AMAZEEIO;\n return (deliver);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n if (req.http.X-Forwarded-Proto) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n if (req.http.HTTPS) {\n hash_data(req.http.HTTPS);\n }\n return (lookup);\n}\n\nsub vcl_synth {\n if (resp.status == 701) {\n set resp.status = 401;\n set resp.http.Content-Type = \"text\/plain; charset=utf-8\";\n synthetic({\"XMLRPC Interface is blocked due to SA-CORE-2014-004 - mail support@amazee.io if you need it.\"});\n return (deliver);\n }\n if (resp.status == 700) {\n # Set a status the client will understand\n set resp.status = 200;\n # Create our synthetic response\n synthetic(\"\");\n return(deliver);\n}\n return (deliver);\n}\n\nsub vcl_backend_error {\n # Restart the request, when we have a backend server error, to try another backend.\n # Restart max twice.\n if (bereq.retries < 2) {\n return(retry);\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<head>\n <title>Server Error<\/title>\n <style type=\"text\/css\">\n body {\n font-family: helvetica, arial, sans-serif;\n }\n img {\n margin-top: 50px;\n }\n p {\n width: 6 00px;\n margin-top: 10px\n }\n div {\n background: #ccc;\n width: 600px;\n margin: auto;\n padding: 50px;\n }\n span {\n color: #ccc\n }\n <\/style>\n<\/head>\n<body>\n <div>\n <h1>We are sorry...<\/h1>\n <p>We encountered a server-side error. This means that the problem is not with your computer or Internet connection, but rather with the website's server.<\/p>\n <p>We are currently working on solving this problem and apologise for the inconvenience.<\/p>\n <span>\n <strong>Technical Information<\/strong><br \/>\n Error \"} + beresp.status + \" \" + beresp.reason + {\"<br \/>\n XID: \"} + bereq.xid + {\"<br \/>\n <\/span>\n <\/div>\n<\/body>\n<\/html>\n\n\"} );\n return (deliver);\n}\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"b5f4227f0039533b26b93deaf4d621610226fef3","subject":"Revert \"remove \/v2\/docs redirects\"","message":"Revert \"remove \/v2\/docs redirects\"\n\nThis reverts commit 6507bf0cfc2d273d31ac32a7b52f9825b578be0c.\n","repos":"JakeChampion\/polyfill-service,JakeChampion\/polyfill-service","old_file":"fastly\/vcl\/redirects.vcl","new_file":"fastly\/vcl\/redirects.vcl","new_contents":"sub vcl_recv {\n\tif (req.http.Host ~ \"polyfills.io\") {\n\t\t# Fastly recommend using the 900-999 range of status codes for custom errors within an application's VCL.\n\t\t# Do the canonicalise check before the HTTPS check to avoid a double redirect\n\t\terror 901 \"Canonicalise\";\n\t}\n\tif (!req.http.Fastly-SSL) {\n\t\t# 801 is a special error code that Fastly uses to Force HTTPS on the request\n\t\terror 801 \"Redirect to HTTPS\";\n\t}\n\tif (req.http.Orig-URL ~ \"^\/v1\") {\n\t\terror 902 \"Redirect to V2\";\n\t}\n\t\n\tif (req.url.path != \"\/v2\/polyfill.js\" && req.url.path != \"\/v2\/polyfill.min.js\") {\n\t\tif (req.url.path ~ \"^\/v2($|\/)\") {\n\t\t\terror 908;\n\t\t}\n\t}\n\tif (req.url.path == \"\/\") {\n\t\terror 908;\n\t}\n}\n\nsub vcl_error {\n # Redirect to canonical prod\/qa origins\n\tif (obj.status == 901) {\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\tset obj.http.Location = \"https:\/\/polyfill.io\" req.url;\n\t\tsynthetic {\"\"};\n\t\treturn (deliver);\n\t}\n\t# Redirect to v2\n\tif (obj.status == 902) {\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\t# Remove libVersion and gated query parameters if they exist.\n\t\tset req.url = querystring.regfilter(req.url, \"^\\b(libVersion|gated)\\b.*\");\n\t\tset obj.http.Location = if(req.url.path == \"\/v1\", \"\/v3\/\", regsub(req.url, \"^\/v1\", \"\/v2\"));\n\t\tset obj.http.Deprecation-Notice = \"API version 1 has been decommissioned - see the body of this response for more information.\";\n\t\tsynthetic {\"API version 1 has been decommissioned. Your request is being redirected to v2. The `libVersion` and `gated` query string parameters are no longer supported and if present have been removed from your request.\\n\\nA deprecation period for v1 existed between August and December 2015, during which time v1 requests were honoured but a deprecation warning was added to output.\"};\n\t\treturn (deliver);\n\t}\n\n\t# Redirect to v3\n\tif (obj.status == 908) {\n\t\tset obj.status = 301;\n\t\tset obj.http.Location = \"\/v3\/\";\n\t\treturn (deliver);\n\t}\n}\n","old_contents":"sub vcl_recv {\n\tif (req.http.Host ~ \"polyfills.io\") {\n\t\t# Fastly recommend using the 900-999 range of status codes for custom errors within an application's VCL.\n\t\t# Do the canonicalise check before the HTTPS check to avoid a double redirect\n\t\terror 901 \"Canonicalise\";\n\t}\n\tif (!req.http.Fastly-SSL) {\n\t\t# 801 is a special error code that Fastly uses to Force HTTPS on the request\n\t\terror 801 \"Redirect to HTTPS\";\n\t}\n\tif (req.http.Orig-URL ~ \"^\/v1\") {\n\t\terror 902 \"Redirect to V2\";\n\t}\n\n\tif (req.url.path == \"\/\") {\n\t\terror 908;\n\t}\n}\n\nsub vcl_error {\n # Redirect to canonical prod\/qa origins\n\tif (obj.status == 901) {\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\tset obj.http.Location = \"https:\/\/polyfill.io\" req.url;\n\t\tsynthetic {\"\"};\n\t\treturn (deliver);\n\t}\n\t# Redirect to v2\n\tif (obj.status == 902) {\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\t# Remove libVersion and gated query parameters if they exist.\n\t\tset req.url = querystring.regfilter(req.url, \"^\\b(libVersion|gated)\\b.*\");\n\t\tset obj.http.Location = if(req.url.path == \"\/v1\", \"\/v3\/\", regsub(req.url, \"^\/v1\", \"\/v2\"));\n\t\tset obj.http.Deprecation-Notice = \"API version 1 has been decommissioned - see the body of this response for more information.\";\n\t\tsynthetic {\"API version 1 has been decommissioned. Your request is being redirected to v2. The `libVersion` and `gated` query string parameters are no longer supported and if present have been removed from your request.\\n\\nA deprecation period for v1 existed between August and December 2015, during which time v1 requests were honoured but a deprecation warning was added to output.\"};\n\t\treturn (deliver);\n\t}\n\n\t# Redirect to v3\n\tif (obj.status == 908) {\n\t\tset obj.status = 301;\n\t\tset obj.http.Location = \"\/v3\/\";\n\t\treturn (deliver);\n\t}\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"cd2e297fabde5356d906abb9d44f803263bcd730","subject":"Reflect new C: close default in vcl_pipe","message":"Reflect new C: close default in vcl_pipe\n\nWe now set Connection: Close on all piped backend requests, to avoid some of\nthe debugging pain seen over the last 2-3 years.\n\nBasic problem is that request backend routing done in vcl_recv would not be\nhonored for subsequent requests after one was piped.\n\nThis was, at least for new users, a rather nasty surprise.\n\nOriginal change in commit 880c3c2.\n","repos":"gauthier-delacroix\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,franciscovg\/Varnish-Cache,feld\/Varnish-Cache,feld\/Varnish-Cache,alarky\/varnish-cache-doc-ja,alarky\/varnish-cache-doc-ja,varnish\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,mrhmouse\/Varnish-Cache,gquintard\/Varnish-Cache,zhoualbeart\/Varnish-Cache,mrhmouse\/Varnish-Cache,zhoualbeart\/Varnish-Cache,varnish\/Varnish-Cache,feld\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,franciscovg\/Varnish-Cache,gquintard\/Varnish-Cache,mrhmouse\/Varnish-Cache,franciscovg\/Varnish-Cache,alarky\/varnish-cache-doc-ja,franciscovg\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,varnish\/Varnish-Cache,mrhmouse\/Varnish-Cache,zhoualbeart\/Varnish-Cache,chrismoulton\/Varnish-Cache,feld\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,chrismoulton\/Varnish-Cache,chrismoulton\/Varnish-Cache,zhoualbeart\/Varnish-Cache,feld\/Varnish-Cache,alarky\/varnish-cache-doc-ja,franciscovg\/Varnish-Cache,gquintard\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,alarky\/varnish-cache-doc-ja,varnish\/Varnish-Cache,zhoualbeart\/Varnish-Cache,chrismoulton\/Varnish-Cache,varnish\/Varnish-Cache,gquintard\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,mrhmouse\/Varnish-Cache,chrismoulton\/Varnish-Cache","old_file":"bin\/varnishd\/builtin.vcl","new_file":"bin\/varnishd\/builtin.vcl","new_contents":"\/*-\n * Copyright (c) 2006 Verdens Gang AS\n * Copyright (c) 2006-2014 Varnish Software AS\n * All rights reserved.\n *\n * Author: Poul-Henning Kamp <phk@phk.freebsd.dk>\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in the\n * documentation and\/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n\n *\n * The built-in (previously called default) VCL code.\n *\n * NB! You do NOT need to copy & paste all of these functions into your\n * own vcl code, if you do not provide a definition of one of these\n * functions, the compiler will automatically fall back to the default\n * code from this file.\n *\n * This code will be prefixed with a backend declaration built from the\n * -b argument.\n *\/\n\nvcl 4.0;\n\n#######################################################################\n# Client side\n\nsub vcl_recv {\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization || req.http.Cookie) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n return (hash);\n}\n\nsub vcl_pipe {\n # By default Connection: close is set on all piped requests, to stop\n # connection reuse from sending future requests directly to the\n # (potentially) wrong backend. If you do want this to happen, you can undo\n # it here.\n # unset bereq.http.connection;\n return (pipe);\n}\n\nsub vcl_pass {\n return (fetch);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n return (lookup);\n}\n\nsub vcl_purge {\n return (synth(200, \"Purged\"));\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n \/\/ A pure unadultered hit, deliver it\n return (deliver);\n }\n if (obj.ttl + obj.grace > 0s) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n return (deliver);\n }\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\nsub vcl_miss {\n return (fetch);\n}\n\nsub vcl_deliver {\n return (deliver);\n}\n\n\/*\n * We can come here \"invisibly\" with the following errors: 413, 417 & 503\n *\/\nsub vcl_synth {\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n set resp.http.Retry-After = \"5\";\n synthetic( {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n return (deliver);\n}\n\n#######################################################################\n# Backend Fetch\n\nsub vcl_backend_fetch {\n return (fetch);\n}\n\nsub vcl_backend_response {\n if (beresp.ttl <= 0s ||\n beresp.http.Set-Cookie ||\n beresp.http.Surrogate-control ~ \"no-store\" ||\n (!beresp.http.Surrogate-Control &&\n beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n beresp.http.Vary == \"*\") {\n \/*\n * Mark as \"Hit-For-Pass\" for the next 2 minutes\n *\/\n set beresp.ttl = 120s;\n set beresp.uncacheable = true;\n }\n return (deliver);\n}\n\nsub vcl_backend_error {\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} + beresp.status + \" \" + beresp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + beresp.status + \" \" + beresp.reason + {\"<\/h1>\n <p>\"} + beresp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + bereq.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n return (deliver);\n}\n\n#######################################################################\n# Housekeeping\n\nsub vcl_init {\n return (ok);\n}\n\nsub vcl_fini {\n return (ok);\n}\n","old_contents":"\/*-\n * Copyright (c) 2006 Verdens Gang AS\n * Copyright (c) 2006-2014 Varnish Software AS\n * All rights reserved.\n *\n * Author: Poul-Henning Kamp <phk@phk.freebsd.dk>\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in the\n * documentation and\/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n\n *\n * The built-in (previously called default) VCL code.\n *\n * NB! You do NOT need to copy & paste all of these functions into your\n * own vcl code, if you do not provide a definition of one of these\n * functions, the compiler will automatically fall back to the default\n * code from this file.\n *\n * This code will be prefixed with a backend declaration built from the\n * -b argument.\n *\/\n\nvcl 4.0;\n\n#######################################################################\n# Client side\n\nsub vcl_recv {\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization || req.http.Cookie) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n return (hash);\n}\n\nsub vcl_pipe {\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n # set bereq.http.connection = \"close\";\n # here. It is not set by default as it might break some broken web\n # applications, like IIS with NTLM authentication.\n return (pipe);\n}\n\nsub vcl_pass {\n return (fetch);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n return (lookup);\n}\n\nsub vcl_purge {\n return (synth(200, \"Purged\"));\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n \/\/ A pure unadultered hit, deliver it\n return (deliver);\n }\n if (obj.ttl + obj.grace > 0s) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n return (deliver);\n }\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\nsub vcl_miss {\n return (fetch);\n}\n\nsub vcl_deliver {\n return (deliver);\n}\n\n\/*\n * We can come here \"invisibly\" with the following errors: 413, 417 & 503\n *\/\nsub vcl_synth {\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n set resp.http.Retry-After = \"5\";\n synthetic( {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n return (deliver);\n}\n\n#######################################################################\n# Backend Fetch\n\nsub vcl_backend_fetch {\n return (fetch);\n}\n\nsub vcl_backend_response {\n if (beresp.ttl <= 0s ||\n beresp.http.Set-Cookie ||\n beresp.http.Surrogate-control ~ \"no-store\" ||\n (!beresp.http.Surrogate-Control &&\n beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n beresp.http.Vary == \"*\") {\n \/*\n * Mark as \"Hit-For-Pass\" for the next 2 minutes\n *\/\n set beresp.ttl = 120s;\n set beresp.uncacheable = true;\n }\n return (deliver);\n}\n\nsub vcl_backend_error {\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} + beresp.status + \" \" + beresp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + beresp.status + \" \" + beresp.reason + {\"<\/h1>\n <p>\"} + beresp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + bereq.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n return (deliver);\n}\n\n#######################################################################\n# Housekeeping\n\nsub vcl_init {\n return (ok);\n}\n\nsub vcl_fini {\n return (ok);\n}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"85aed1f4b39b84fc680905e529b45b3c8eead327","subject":"Added more snippets, function command","message":"Added more snippets, function command\n","repos":"aschneiderman\/atom-voice-vocola","old_file":"atom.vcl","new_file":"atom.vcl","new_contents":"# Voice commands for atom\n\ninclude folders.vch;\ninclude letters.vch;\n\nFind (File | Document) = {Ctrl+t};\nSave As = {Ctrl+Shift+s};\nSave and Reload = {Ctrl+s} Wait(100) {Alt+Tab} Wait(300);\n\n<delimiters> := (Quote = '\"' | 'Single Quote' = \"'\" | Comma = ',' | 'Equal Sign' = '=' | Equals = '=' \n\t| Period = '.' | 'Semi-Colon' = ';');\n\n# --- Navigation commands ------------------------------------\nLine 1..200 = {Ctrl+g} $1 {Enter};\n(Left = 'b' | Right = 'f') Word = {Alt+$1};\nTop = {Ctrl+Home};\nBottom = {Ctrl+End};\n(Find = 'Right' | 'Insert After' = 'Right' | 'Insert Before' = 'Left') (Next = 'Enter' | Last = 'Shift+F3') <delimiters> \n\t\t= {Ctrl+f} $3 {$2} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') <delimiters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nFine Alpha <letters> = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Right};\nInsert (Before = 'Left' | After = 'Right') Alpha <letters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nFine Number 0..9 = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Right};\nFind Again = {F3} {Right};\nFind Again 1..20 Times = {F3_$1} {Right};\n\nFind Symbol = {Ctrl+r};\n\n(Set | Add | Clear | Hide | Delete) Bookmark = {Ctrl+Alt+F2};\n(Next = 'F2' | Last = 'Shift+F2') Bookmark = {$1};\n\nNext Window = {Ctrl+Tab};\nLast Window = {Ctrl+Shift+Tab};\n\n\n# --- Editing commands ----------------------------------------\nSelect (Next = 'Down' | Last = 'Up') 1..20 Lines = {Home} {Shift+$1_$2};\n(Join = 'j' | Indent = ']' | Dedent = '[') That = {Ctrl+$1};\nMove Line (Up | Down) 1..20 = {Ctrl+$1_$2};\n\n\n\nDelete Word = {Ctrl+Del};\nDelete 1..20 Words = {Ctrl+Del_$1};\n(Delete Line | Dede) = {Ctrl+Shift+k};\nDelete 1..20 Lines = {Ctrl+Shift+k_$1};\n(Cut = 'x' | Paste = 'v' | Copy = 'c') That = {Ctrl+$1};\n\nSelect between (Delimiters | Brackets) ={Ctrl+m} {Ctrl+Alt+m};\n# TO ADD:\n# Delete back three words\n# delete between next tags\n\n\n\n\n# --- Code commands -------------------------------------------\nStart (Item = 'li' | List = 'ul' | HTML = 'html' | pre = \"pre\"\n\t| 'Bold ID' = 'bold-id' | 'Input' = 'ds-input-text'\n\t| Snippet = 'snip' | 'Recipe Row' = 'recipe-row' | 'Recipe Play' = 'recipe-play') = $1 {Tab};\nStart (para = '<p>' ) = $1;\nStart (Header | Heading) 1..7 = h $2 {Tab}; \nMid HREF = '\">';\n\nPaste Function = 'function ' {Ctrl+v} ' {' {Enter} {Enter} '};' {Up};\n\n# TO ADD:\n# adding HTML comments, using a snippet\n\nShortcut Keys = {Ctrl+Shift+p};\n\n","old_contents":"# Voice commands for atom\n\ninclude folders.vch;\ninclude letters.vch;\n\nFind (File | Document) = {Ctrl+t};\nSave As = {Ctrl+Shift+s};\nSave and Reload = {Ctrl+s} Wait(100) {Alt+Tab} Wait(300);\n\n<delimiters> := (Quote = '\"' | 'Single Quote' = \"'\" | Comma = ',' | 'Equal Sign' = '=' | Equals = '=' \n\t| Period = '.' | 'Semi-Colon' = ';');\n\n# --- Navigation commands ------------------------------------\nLine 1..200 = {Ctrl+g} $1 {Enter};\n(Left = 'b' | Right = 'f') Word = {Alt+$1};\nTop = {Ctrl+Home};\nBottom = {Ctrl+End};\n(Find = 'Right' | 'Insert After' = 'Right' | 'Insert Before' = 'Left') (Next = 'Enter' | Last = 'Shift+F3') <delimiters> \n\t\t= {Ctrl+f} $3 {$2} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') <delimiters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nFine Alpha <letters> = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Right};\nInsert (Before = 'Left' | After = 'Right') Alpha <letters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nFine Number 0..9 = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Right};\nFind Again = {F3} {Right};\nFind Again 1..20 Times = {F3_$1} {Right};\n\nFind Symbol = {Ctrl+r};\n\n(Set | Add | Clear | Hide | Delete) Bookmark = {Ctrl+Alt+F2};\n(Next = 'F2' | Last = 'Shift+F2') Bookmark = {$1};\n\nNext Window = {Ctrl+Tab};\nLast Window = {Ctrl+Shift+Tab};\n\n\n# --- Editing commands ----------------------------------------\nSelect (Next = 'Down' | Last = 'Up') 1..20 Lines = {Home} {Shift+$1_$2};\n(Join = 'j' | Indent = ']' | Dedent = '[') That = {Ctrl+$1};\nMove Line (Up | Down) 1..20 = {Ctrl+$1_$2};\n\n\n\nDelete Word = {Ctrl+Del};\nDelete 1..20 Words = {Ctrl+Del_$1};\n(Delete Line | Dede) = {Ctrl+Shift+k};\nDelete 1..20 Lines = {Ctrl+Shift+k_$1};\n(Cut = 'x' | Paste = 'v' | Copy = 'c') That = {Ctrl+$1};\n\nSelect between (Delimiters | Brackets) ={Ctrl+m} {Ctrl+Alt+m};\n# TO ADD:\n# Delete back three words\n# delete between next tags\n\n\n\n\n# --- Code commands -------------------------------------------\nStart (para = 'p' | Item = 'li' | List = 'ul' | HTML = 'html' | pre = \"pre\"\n\t| Snippet = 'snip' | 'Recipe Row' = 'recipe-row') = $1 {Tab};\nStart (Header | Heading) 1..7 = h $2 {Tab}; \nMid HREF = '\">';\n\n# TO ADD:\n# adding HTML comments, using a snippet\n\nShortcut Keys = {Ctrl+Shift+p};\n\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"23b46bda0924733b37a8724e029e865176b17ae0","subject":"If using https and no haproxy, redirect non-https and non-www URLs to https:\/\/www.example.com","message":"If using https and no haproxy, redirect non-https and non-www URLs to https:\/\/www.example.com\n","repos":"alexisbellido\/salt-django-stack,alexisbellido\/salt-django-stack,alexisbellido\/salt-django-stack,alexisbellido\/salt-django-stack","old_file":"zinibu\/varnish\/files\/etc\/varnish\/default-4.vcl","new_file":"zinibu\/varnish\/files\/etc\/varnish\/default-4.vcl","new_contents":"# Managed by saltstack.\n# host id: {{ salt['grains.get']('id', '') }}\n{% set settings = salt['pillar.get']('varnish', {}) -%}\n{% set zinibu_basic = salt['pillar.get']('zinibu_basic', {}) -%}\n#\n# This is an example VCL file for Varnish.\n#\n# It does not do anything by default, delegating control to the\n# builtin VCL. The builtin VCL is called when there is no explicit\n# return statement.\n#\n# See the VCL chapters in the Users Guide at https:\/\/www.varnish-cache.org\/docs\/\n# and https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExamples for more examples.\n\n# Marker to tell the VCL compiler that this VCL has been adapted to the\n# new 4.0 format.\nvcl 4.0;\n\nimport std;\nimport directors;\n\n{%- for id, haproxy_server in zinibu_basic.project.haproxy_servers.iteritems() %}\nbackend bk_appsrv_static_{{ id }} {\n .host = \"{{ haproxy_server.private_ip }}\";\n .port = \"{{ haproxy_server.port }}\";\n .probe = {\n .url = \"{{ zinibu_basic.project.haproxy_check }}\";\n .expected_response = 200;\n .timeout = 1s;\n .interval = 3s;\n .window = 2;\n .threshold = 2;\n .initial = 2;\n }\n}\n{%- endfor %}\n\nsub vcl_init {\n new bar = directors.round_robin();\n{%- for id, haproxy_server in zinibu_basic.project.haproxy_servers.iteritems() %}\n bar.add_backend(bk_appsrv_static_{{ id }});\n{%- endfor %}\n}\n\nacl purge {\n \"localhost\";\n \"127.0.0.1\";\n}\n\nsub vcl_recv {\n # Happens before we check if we have this in cache already.\n #\n # Typically you clean up the request here, removing cookies you don't need,\n # rewriting the request, etc.\n\n # debug bypass\n #return (pass);\n\n #std.log(\"vcl recv: \"+req.request);\n\n # Health Checking\n if (req.url == \"{{ zinibu_basic.project.varnish_check }}\") {\n return (synth(751, \"health check OK!\"));\n }\n\n # If using https and no haproxy, redirect non-https and non-www URLs to https:\/\/www.example.com\n #if ( (req.http.host ~ \"^(?i)www.example.com\" && req.http.X-Forwarded-Proto !~ \"(?i)https\") || (req.http.host ~ \"^(?i)example.com\") ) {\n # return (synth(750, \"\"));\n #}\n\n # send all traffic to the bar director:\n set req.backend_hint = bar.backend();\n\n # Normalize the header, remove the port (in case you're testing this on various TCP ports)\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n # Normalize the query arguments\n set req.url = std.querysort(req.url);\n\n # Allow purging\n if (req.method == \"PURGE\") {\n if (!client.ip ~ purge) { # purge is the ACL defined at the begining\n\t # Not from an allowed IP? Then die with an error.\n return (synth(405, \"This IP is not allowed to send PURGE requests.\"));\n }\n # If you got this stage (and didn't error out above), purge the cached result\n return (purge);\n }\n\n # Only deal with \"normal\" types\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"PATCH\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n # Implementing websocket support (https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html)\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n # Only cache GET or HEAD requests. This makes sure the POST requests are always passed.\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n if (req.url ~ \"^\/search\/\") {\n return (pass);\n }\n\n # Don't think is needed anymore, just check for sessionid cookie\n # Django is setting this cookie so we only check here\n #if (req.http.Cookie ~ \"LOGGED_IN\") {\n # return (pass);\n #}\n\n if (req.http.Authorization) {\n # Not cacheable by default\n return (pass);\n }\n\n set req.http.X-Varnish-Use-Cache = \"TRUE\";\n # unless Django's sessionid or message cookies are in the request, don't pass ANY cookies (referral_source, utm, etc)\n # also, anything inside \/media or \/static should be cached\n if (req.url ~ \"^\/media\" || req.url ~ \"^\/static\" || (req.http.Cookie !~ \"logged_in\" && req.http.Cookie !~ \"sessionid\" && req.http.Cookie !~ \"messages\" && req.http.Cookie !~ \"csrftoken\")) {\n unset req.http.Cookie;\n return (hash);\n }\n\n # Large static files are delivered directly to the end-user without\n # waiting for Varnish to fully read the file first.\n # Varnish 4 fully supports Streaming, so set do_stream in vcl_backend_response()\n if (req.url ~ \"^[^?]*\\.(7z|avi|bz2|flac|flv|gz|mka|mkv|mov|mp3|mp4|mpeg|mpg|ogg|ogm|opus|rar|tar|tgz|tbz|txz|wav|webm|xz|zip)(\\?.*)?$\") {\n unset req.http.Cookie;\n return (hash);\n }\n\n # Remove all cookies for static files\n # A valid discussion could be held on this line: do you really need to cache static files that don't cause load? Only if you have memory left.\n # Sure, there's disk I\/O, but chances are your OS will already have these files in their buffers (thus memory).\n # Before you blindly enable this, have a read here: https:\/\/ma.ttias.be\/stop-caching-static-files\/\n if (req.url ~ \"^[^?]*\\.(7z|avi|bmp|bz2|css|csv|doc|docx|eot|flac|flv|gif|gz|ico|jpeg|jpg|js|less|mka|mkv|mov|mp3|mp4|mpeg|mpg|odt|otf|ogg|ogm|opus|pdf|png|ppt|pptx|rar|rtf|svg|svgz|swf|tar|tbz|tgz|ttf|txt|txz|wav|webm|webp|woff|woff2|xls|xlsx|xml|xz|zip)(\\?.*)?$\") {\n unset req.http.Cookie;\n return (hash);\n }\n \n # Are there cookies left with only spaces or that are empty?\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.Cookie;\n }\n\n # Some generic cookie manipulation, useful for all templates that follow\n # Remove the \"has_js\" cookie\n set req.http.Cookie = regsuball(req.http.Cookie, \"has_js=[^;]+(; )?\", \"\");\n\n # Remove any Google Analytics based cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__utm.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"_ga=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"_gat=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmctr=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmcmd.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmccn.=[^;]+(; )?\", \"\");\n\n # Remove DoubleClick offensive cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__gads=[^;]+(; )?\", \"\");\n\n # Remove the Quant Capital cookies (added by some plugin, all __qca)\n #set req.http.Cookie = regsuball(req.http.Cookie, \"__qc.=[^;]+(; )?\", \"\");\n\n # Remove the AddThis cookies\n #set req.http.Cookie = regsuball(req.http.Cookie, \"__atuv.=[^;]+(; )?\", \"\");\n\n # Remove a \";\" prefix in the cookie if present\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n\n if (req.http.Cache-Control ~ \"(?i)no-cache\") {\n #if (req.http.Cache-Control ~ \"(?i)no-cache\" && client.ip ~ editors) { # create the acl editors if you want to restrict the Ctrl-F5\n # http:\/\/varnish.projects.linpro.no\/wiki\/VCLExampleEnableForceRefresh\n # Ignore requests via proxy caches and badly behaved crawlers\n # like msnbot that send no-cache with every request.\n if (! (req.http.Via || req.http.User-Agent ~ \"(?i)bot\" || req.http.X-Purge)) {\n #set req.hash_always_miss = true; # Doesn't seems to refresh the object in the cache\n return(purge); # Couple this with restart in vcl_purge and X-Purge header to avoid loops\n }\n }\n\n # Strip hash, server doesn't need it.\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n # Strip a trailing ? if it exists\n if (req.url ~ \"\\?$\") {\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n return (hash);\n}\n\nsub vcl_pipe {\n # Called upon entering pipe mode.\n # In this mode, the request is passed on to the backend, and any further data from both the client\n # and backend is passed on unaltered until either end closes the connection. Basically, Varnish will\n # degrade into a simple TCP proxy, shuffling bytes back and forth. For a connection in pipe mode,\n # no other VCL subroutine will ever get called after vcl_pipe.\n\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n # set bereq.http.connection = \"close\";\n # here. It is not set by default as it might break some broken web\n # applications, like IIS with NTLM authentication.\n\n # set bereq.http.Connection = \"Close\";\n\n # Implementing websocket support (https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html)\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n\n return (pipe);\n}\n\nsub vcl_pass {\n # Called upon entering pass mode. In this mode, the request is passed on to the backend, and the\n # backend's response is passed on to the client, but is not entered into the cache. Subsequent\n # requests submitted over the same client connection are handled normally.\n\n # return (pass);\n}\n\nsub vcl_hash {\n # Called after vcl_recv to create a hash value for the request. This is used as a key\n # to look up the object in Varnish.\n \n hash_data(req.url);\n \n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n \n # hash cookies for requests that have them\n if (req.http.Cookie) {\n hash_data(req.http.Cookie);\n }\n\n return (lookup);\n}\n\nsub vcl_backend_response {\n # Happens after we have read the response headers from the backend.\n #\n # Here you clean the response headers, removing silly Set-Cookie headers\n # and other mistakes your backend does.\n\n # Called after the response headers has been successfully retrieved from the backend.\n # Enable ESI\n # TODO see if I need to add conditions to enable ESI\n set beresp.do_esi = true;\n # and make sure everything under \/no-cache is, well, not cached\n if (bereq.url ~ \"^\/no-cache\/\") {\n set beresp.uncacheable = true;\n return(deliver); \n }\n\n # Pause ESI request and remove Surrogate-Control header\n if (beresp.http.Surrogate-Control ~ \"ESI\/1.0\") {\n unset beresp.http.Surrogate-Control;\n set beresp.do_esi = true;\n }\n\n # Enable cache for all static files\n # The same argument as the static caches from above: monitor your cache size, if you get data nuked out of it, consider giving up the static file cache.\n # Before you blindly enable this, have a read here: https:\/\/ma.ttias.be\/stop-caching-static-files\/\n if (bereq.url ~ \"^[^?]*\\.(7z|avi|bmp|bz2|css|csv|doc|docx|eot|flac|flv|gif|gz|ico|jpeg|jpg|js|less|mka|mkv|mov|mp3|mp4|mpeg|mpg|odt|otf|ogg|ogm|opus|pdf|png|ppt|pptx|rar|rtf|svg|svgz|swf|tar|tbz|tgz|ttf|txt|txz|wav|webm|webp|woff|woff2|xls|xlsx|xml|xz|zip)(\\?.*)?$\") {\n unset beresp.http.set-cookie;\n }\n\n # Large static files are delivered directly to the end-user without\n # waiting for Varnish to fully read the file first.\n # Varnish 4 fully supports Streaming, so use streaming here to avoid locking.\n if (bereq.url ~ \"^[^?]*\\.(7z|avi|bz2|flac|flv|gz|mka|mkv|mov|mp3|mp4|mpeg|mpg|ogg|ogm|opus|rar|tar|tgz|tbz|txz|wav|webm|xz|zip)(\\?.*)?$\") {\n unset beresp.http.set-cookie;\n set beresp.do_stream = true; # Check memory usage it'll grow in fetch_chunksize blocks (128k by default) if the backend doesn't send a Content-Length header, so only enable it for big objects\n set beresp.do_gzip = false; # Don't try to compress it for storage\n }\n\n # Sometimes, a 301 or 302 redirect formed via Apache's mod_rewrite can mess with the HTTP port that is being passed along.\n # This often happens with simple rewrite rules in a scenario where Varnish runs on :80 and Apache on :8080 on the same box.\n # A redirect can then often redirect the end-user to a URL on :8080, where it should be :80.\n # This may need finetuning on your setup.\n #\n # To prevent accidental replace, we only filter the 301\/302 redirects for now.\n if (beresp.status == 301 || beresp.status == 302) {\n set beresp.http.Location = regsub(beresp.http.Location, \":[0-9]+\", \"\");\n }\n\n # Set 2min cache if unset for static files\n if (beresp.ttl <= 0s || beresp.http.Set-Cookie || beresp.http.Vary == \"*\") {\n set beresp.ttl = 120s; # Important, you shouldn't rely on this, SET YOUR HEADERS in the backend\n set beresp.uncacheable = true;\n\n # Study and test this\n # Mark as \"Hit-For-Pass\" for the next 60 minutes - 24 hours\n #if (bereq.url ~ \"\\.(jpe?g|png|gif|pdf|gz|tgz|bz2|tbz|tar|zip|tiff|tif)$\" || bereq.url ~ \"\/(image|(image_(?:[^\/]|(?!view.*).+)))$\") {\n # set beresp.ttl = std.duration(beresp.http.age+\"s\",0s) + 6h;\n #} elseif (bereq.url ~ \"\\.(svg|swf|ico|mp3|mp4|m4a|ogg|mov|avi|wmv|flv)$\") {\n # set beresp.ttl = std.duration(beresp.http.age+\"s\",0s) + 6h;\n #} elseif (bereq.url ~ \"\\.(xls|vsd|doc|ppt|pps|vsd|doc|ppt|pps|xls|pdf|sxw|rar|odc|odb|odf|odg|odi|odp|ods|odt|sxc|sxd|sxi|sxw|dmg|torrent|deb|msi|iso|rpm)$\") {\n # set beresp.ttl = std.duration(beresp.http.age+\"s\",0s) + 6h;\n #} elseif (bereq.url ~ \"\\.(css|js)$\") {\n # set beresp.ttl = std.duration(beresp.http.age+\"s\",0s) + 24h;\n #} else {\n # set beresp.ttl = std.duration(beresp.http.age+\"s\",0s) + 1h;\n #}\n\n return (deliver);\n }\n\n # Don't cache 50x responses\n if (beresp.status == 500 || beresp.status == 502 || beresp.status == 503 || beresp.status == 504) {\n return (abandon);\n }\n\n # Allow stale content, in case the backend goes down.\n # make Varnish keep all objects for 6 hours beyond their TTL\n set beresp.grace = 6h;\n\n return (deliver);\n}\n\nsub vcl_deliver {\n # Happens when we have all the pieces we need, and are about to send the\n # response to the client.\n #\n # You can do accounting or modifying the final object here.\n\n # Called before a cached object is delivered to the client.\n\n if (obj.hits > 0) { # Add debug header to see if it's a HIT\/MISS and the number of hits, disable when not needed\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n\n # Please note that obj.hits behaviour changed in 4.0, now it counts per objecthead, not per object\n # and obj.hits may not be reset in some cases where bans are in use. See bug 1492 for details.\n # So take hits with a grain of salt\n set resp.http.X-Cache-Hits = obj.hits;\n\n # Remove some headers: PHP version\n unset resp.http.X-Powered-By;\n\n # Remove some headers: Apache version & OS\n unset resp.http.Server;\n unset resp.http.X-Drupal-Cache;\n unset resp.http.X-Varnish;\n unset resp.http.Via;\n unset resp.http.Link;\n unset resp.http.X-Generator;\n\n return (deliver);\n}\n\nsub vcl_purge {\n # Only handle actual PURGE HTTP methods, everything else is discarded\n if (req.method != \"PURGE\") {\n # restart request\n set req.http.X-Purge = \"Yes\";\n return(restart);\n }\n}\n\nsub vcl_synth {\n # Health check\n if (resp.status == 751) {\n set resp.status = 200;\n return (deliver);\n }\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n set resp.http.Retry-After = \"5\";\n synthetic (\"Error\");\n return (deliver);\n}\n","old_contents":"# Managed by saltstack.\n# host id: {{ salt['grains.get']('id', '') }}\n{% set settings = salt['pillar.get']('varnish', {}) -%}\n{% set zinibu_basic = salt['pillar.get']('zinibu_basic', {}) -%}\n#\n# This is an example VCL file for Varnish.\n#\n# It does not do anything by default, delegating control to the\n# builtin VCL. The builtin VCL is called when there is no explicit\n# return statement.\n#\n# See the VCL chapters in the Users Guide at https:\/\/www.varnish-cache.org\/docs\/\n# and https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExamples for more examples.\n\n# Marker to tell the VCL compiler that this VCL has been adapted to the\n# new 4.0 format.\nvcl 4.0;\n\nimport std;\nimport directors;\n\n{%- for id, haproxy_server in zinibu_basic.project.haproxy_servers.iteritems() %}\nbackend bk_appsrv_static_{{ id }} {\n .host = \"{{ haproxy_server.private_ip }}\";\n .port = \"{{ haproxy_server.port }}\";\n .probe = {\n .url = \"{{ zinibu_basic.project.haproxy_check }}\";\n .expected_response = 200;\n .timeout = 1s;\n .interval = 3s;\n .window = 2;\n .threshold = 2;\n .initial = 2;\n }\n}\n{%- endfor %}\n\nsub vcl_init {\n new bar = directors.round_robin();\n{%- for id, haproxy_server in zinibu_basic.project.haproxy_servers.iteritems() %}\n bar.add_backend(bk_appsrv_static_{{ id }});\n{%- endfor %}\n}\n\nacl purge {\n \"localhost\";\n \"127.0.0.1\";\n}\n\nsub vcl_recv {\n # Happens before we check if we have this in cache already.\n #\n # Typically you clean up the request here, removing cookies you don't need,\n # rewriting the request, etc.\n\n # debug bypass\n #return (pass);\n\n #std.log(\"vcl recv: \"+req.request);\n\n # Health Checking\n if (req.url == \"{{ zinibu_basic.project.varnish_check }}\") {\n return (synth(751, \"health check OK!\"));\n }\n\n # send all traffic to the bar director:\n set req.backend_hint = bar.backend();\n\n # Normalize the header, remove the port (in case you're testing this on various TCP ports)\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n # Normalize the query arguments\n set req.url = std.querysort(req.url);\n\n # Allow purging\n if (req.method == \"PURGE\") {\n if (!client.ip ~ purge) { # purge is the ACL defined at the begining\n\t # Not from an allowed IP? Then die with an error.\n return (synth(405, \"This IP is not allowed to send PURGE requests.\"));\n }\n # If you got this stage (and didn't error out above), purge the cached result\n return (purge);\n }\n\n # Only deal with \"normal\" types\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"PATCH\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n # Implementing websocket support (https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html)\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n # Only cache GET or HEAD requests. This makes sure the POST requests are always passed.\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n if (req.url ~ \"^\/search\/\") {\n return (pass);\n }\n\n # Don't think is needed anymore, just check for sessionid cookie\n # Django is setting this cookie so we only check here\n #if (req.http.Cookie ~ \"LOGGED_IN\") {\n # return (pass);\n #}\n\n if (req.http.Authorization) {\n # Not cacheable by default\n return (pass);\n }\n\n set req.http.X-Varnish-Use-Cache = \"TRUE\";\n # unless Django's sessionid or message cookies are in the request, don't pass ANY cookies (referral_source, utm, etc)\n # also, anything inside \/media or \/static should be cached\n if (req.url ~ \"^\/media\" || req.url ~ \"^\/static\" || (req.http.Cookie !~ \"logged_in\" && req.http.Cookie !~ \"sessionid\" && req.http.Cookie !~ \"messages\" && req.http.Cookie !~ \"csrftoken\")) {\n unset req.http.Cookie;\n return (hash);\n }\n\n # Large static files are delivered directly to the end-user without\n # waiting for Varnish to fully read the file first.\n # Varnish 4 fully supports Streaming, so set do_stream in vcl_backend_response()\n if (req.url ~ \"^[^?]*\\.(7z|avi|bz2|flac|flv|gz|mka|mkv|mov|mp3|mp4|mpeg|mpg|ogg|ogm|opus|rar|tar|tgz|tbz|txz|wav|webm|xz|zip)(\\?.*)?$\") {\n unset req.http.Cookie;\n return (hash);\n }\n\n # Remove all cookies for static files\n # A valid discussion could be held on this line: do you really need to cache static files that don't cause load? Only if you have memory left.\n # Sure, there's disk I\/O, but chances are your OS will already have these files in their buffers (thus memory).\n # Before you blindly enable this, have a read here: https:\/\/ma.ttias.be\/stop-caching-static-files\/\n if (req.url ~ \"^[^?]*\\.(7z|avi|bmp|bz2|css|csv|doc|docx|eot|flac|flv|gif|gz|ico|jpeg|jpg|js|less|mka|mkv|mov|mp3|mp4|mpeg|mpg|odt|otf|ogg|ogm|opus|pdf|png|ppt|pptx|rar|rtf|svg|svgz|swf|tar|tbz|tgz|ttf|txt|txz|wav|webm|webp|woff|woff2|xls|xlsx|xml|xz|zip)(\\?.*)?$\") {\n unset req.http.Cookie;\n return (hash);\n }\n \n # Are there cookies left with only spaces or that are empty?\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.Cookie;\n }\n\n # Some generic cookie manipulation, useful for all templates that follow\n # Remove the \"has_js\" cookie\n set req.http.Cookie = regsuball(req.http.Cookie, \"has_js=[^;]+(; )?\", \"\");\n\n # Remove any Google Analytics based cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__utm.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"_ga=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"_gat=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmctr=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmcmd.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmccn.=[^;]+(; )?\", \"\");\n\n # Remove DoubleClick offensive cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__gads=[^;]+(; )?\", \"\");\n\n # Remove the Quant Capital cookies (added by some plugin, all __qca)\n #set req.http.Cookie = regsuball(req.http.Cookie, \"__qc.=[^;]+(; )?\", \"\");\n\n # Remove the AddThis cookies\n #set req.http.Cookie = regsuball(req.http.Cookie, \"__atuv.=[^;]+(; )?\", \"\");\n\n # Remove a \";\" prefix in the cookie if present\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n\n if (req.http.Cache-Control ~ \"(?i)no-cache\") {\n #if (req.http.Cache-Control ~ \"(?i)no-cache\" && client.ip ~ editors) { # create the acl editors if you want to restrict the Ctrl-F5\n # http:\/\/varnish.projects.linpro.no\/wiki\/VCLExampleEnableForceRefresh\n # Ignore requests via proxy caches and badly behaved crawlers\n # like msnbot that send no-cache with every request.\n if (! (req.http.Via || req.http.User-Agent ~ \"(?i)bot\" || req.http.X-Purge)) {\n #set req.hash_always_miss = true; # Doesn't seems to refresh the object in the cache\n return(purge); # Couple this with restart in vcl_purge and X-Purge header to avoid loops\n }\n }\n\n # Strip hash, server doesn't need it.\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n # Strip a trailing ? if it exists\n if (req.url ~ \"\\?$\") {\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n return (hash);\n}\n\nsub vcl_pipe {\n # Called upon entering pipe mode.\n # In this mode, the request is passed on to the backend, and any further data from both the client\n # and backend is passed on unaltered until either end closes the connection. Basically, Varnish will\n # degrade into a simple TCP proxy, shuffling bytes back and forth. For a connection in pipe mode,\n # no other VCL subroutine will ever get called after vcl_pipe.\n\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n # set bereq.http.connection = \"close\";\n # here. It is not set by default as it might break some broken web\n # applications, like IIS with NTLM authentication.\n\n # set bereq.http.Connection = \"Close\";\n\n # Implementing websocket support (https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html)\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n\n return (pipe);\n}\n\nsub vcl_pass {\n # Called upon entering pass mode. In this mode, the request is passed on to the backend, and the\n # backend's response is passed on to the client, but is not entered into the cache. Subsequent\n # requests submitted over the same client connection are handled normally.\n\n # return (pass);\n}\n\nsub vcl_hash {\n # Called after vcl_recv to create a hash value for the request. This is used as a key\n # to look up the object in Varnish.\n \n hash_data(req.url);\n \n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n \n # hash cookies for requests that have them\n if (req.http.Cookie) {\n hash_data(req.http.Cookie);\n }\n\n return (lookup);\n}\n\nsub vcl_backend_response {\n # Happens after we have read the response headers from the backend.\n #\n # Here you clean the response headers, removing silly Set-Cookie headers\n # and other mistakes your backend does.\n\n # Called after the response headers has been successfully retrieved from the backend.\n # Enable ESI\n # TODO see if I need to add conditions to enable ESI\n set beresp.do_esi = true;\n # and make sure everything under \/no-cache is, well, not cached\n if (bereq.url ~ \"^\/no-cache\/\") {\n set beresp.uncacheable = true;\n return(deliver); \n }\n\n # Pause ESI request and remove Surrogate-Control header\n if (beresp.http.Surrogate-Control ~ \"ESI\/1.0\") {\n unset beresp.http.Surrogate-Control;\n set beresp.do_esi = true;\n }\n\n # Enable cache for all static files\n # The same argument as the static caches from above: monitor your cache size, if you get data nuked out of it, consider giving up the static file cache.\n # Before you blindly enable this, have a read here: https:\/\/ma.ttias.be\/stop-caching-static-files\/\n if (bereq.url ~ \"^[^?]*\\.(7z|avi|bmp|bz2|css|csv|doc|docx|eot|flac|flv|gif|gz|ico|jpeg|jpg|js|less|mka|mkv|mov|mp3|mp4|mpeg|mpg|odt|otf|ogg|ogm|opus|pdf|png|ppt|pptx|rar|rtf|svg|svgz|swf|tar|tbz|tgz|ttf|txt|txz|wav|webm|webp|woff|woff2|xls|xlsx|xml|xz|zip)(\\?.*)?$\") {\n unset beresp.http.set-cookie;\n }\n\n # Large static files are delivered directly to the end-user without\n # waiting for Varnish to fully read the file first.\n # Varnish 4 fully supports Streaming, so use streaming here to avoid locking.\n if (bereq.url ~ \"^[^?]*\\.(7z|avi|bz2|flac|flv|gz|mka|mkv|mov|mp3|mp4|mpeg|mpg|ogg|ogm|opus|rar|tar|tgz|tbz|txz|wav|webm|xz|zip)(\\?.*)?$\") {\n unset beresp.http.set-cookie;\n set beresp.do_stream = true; # Check memory usage it'll grow in fetch_chunksize blocks (128k by default) if the backend doesn't send a Content-Length header, so only enable it for big objects\n set beresp.do_gzip = false; # Don't try to compress it for storage\n }\n\n # Sometimes, a 301 or 302 redirect formed via Apache's mod_rewrite can mess with the HTTP port that is being passed along.\n # This often happens with simple rewrite rules in a scenario where Varnish runs on :80 and Apache on :8080 on the same box.\n # A redirect can then often redirect the end-user to a URL on :8080, where it should be :80.\n # This may need finetuning on your setup.\n #\n # To prevent accidental replace, we only filter the 301\/302 redirects for now.\n if (beresp.status == 301 || beresp.status == 302) {\n set beresp.http.Location = regsub(beresp.http.Location, \":[0-9]+\", \"\");\n }\n\n # Set 2min cache if unset for static files\n if (beresp.ttl <= 0s || beresp.http.Set-Cookie || beresp.http.Vary == \"*\") {\n set beresp.ttl = 120s; # Important, you shouldn't rely on this, SET YOUR HEADERS in the backend\n set beresp.uncacheable = true;\n\n # Study and test this\n # Mark as \"Hit-For-Pass\" for the next 60 minutes - 24 hours\n #if (bereq.url ~ \"\\.(jpe?g|png|gif|pdf|gz|tgz|bz2|tbz|tar|zip|tiff|tif)$\" || bereq.url ~ \"\/(image|(image_(?:[^\/]|(?!view.*).+)))$\") {\n # set beresp.ttl = std.duration(beresp.http.age+\"s\",0s) + 6h;\n #} elseif (bereq.url ~ \"\\.(svg|swf|ico|mp3|mp4|m4a|ogg|mov|avi|wmv|flv)$\") {\n # set beresp.ttl = std.duration(beresp.http.age+\"s\",0s) + 6h;\n #} elseif (bereq.url ~ \"\\.(xls|vsd|doc|ppt|pps|vsd|doc|ppt|pps|xls|pdf|sxw|rar|odc|odb|odf|odg|odi|odp|ods|odt|sxc|sxd|sxi|sxw|dmg|torrent|deb|msi|iso|rpm)$\") {\n # set beresp.ttl = std.duration(beresp.http.age+\"s\",0s) + 6h;\n #} elseif (bereq.url ~ \"\\.(css|js)$\") {\n # set beresp.ttl = std.duration(beresp.http.age+\"s\",0s) + 24h;\n #} else {\n # set beresp.ttl = std.duration(beresp.http.age+\"s\",0s) + 1h;\n #}\n\n return (deliver);\n }\n\n # Don't cache 50x responses\n if (beresp.status == 500 || beresp.status == 502 || beresp.status == 503 || beresp.status == 504) {\n return (abandon);\n }\n\n # Allow stale content, in case the backend goes down.\n # make Varnish keep all objects for 6 hours beyond their TTL\n set beresp.grace = 6h;\n\n return (deliver);\n}\n\nsub vcl_deliver {\n # Happens when we have all the pieces we need, and are about to send the\n # response to the client.\n #\n # You can do accounting or modifying the final object here.\n\n # Called before a cached object is delivered to the client.\n\n if (obj.hits > 0) { # Add debug header to see if it's a HIT\/MISS and the number of hits, disable when not needed\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n\n # Please note that obj.hits behaviour changed in 4.0, now it counts per objecthead, not per object\n # and obj.hits may not be reset in some cases where bans are in use. See bug 1492 for details.\n # So take hits with a grain of salt\n set resp.http.X-Cache-Hits = obj.hits;\n\n # Remove some headers: PHP version\n unset resp.http.X-Powered-By;\n\n # Remove some headers: Apache version & OS\n unset resp.http.Server;\n unset resp.http.X-Drupal-Cache;\n unset resp.http.X-Varnish;\n unset resp.http.Via;\n unset resp.http.Link;\n unset resp.http.X-Generator;\n\n return (deliver);\n}\n\nsub vcl_purge {\n # Only handle actual PURGE HTTP methods, everything else is discarded\n if (req.method != \"PURGE\") {\n # restart request\n set req.http.X-Purge = \"Yes\";\n return(restart);\n }\n}\n\nsub vcl_synth {\n # Health check\n if (resp.status == 751) {\n set resp.status = 200;\n return (deliver);\n }\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n set resp.http.Retry-After = \"5\";\n synthetic (\"Error\");\n return (deliver);\n}\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"0477e8a48c18bd3236b92bebb814f1530ac74945","subject":"Cleanup for generated varnish config.","message":"Cleanup for generated varnish config.\n","repos":"killerwails\/ansible-varnish,gotofbi\/ansible-varnish,killerwails\/ansible-varnish,colstrom\/ansible-varnish,gotofbi\/ansible-varnish,telusdigital\/ansible-varnish,kkwoker\/ansible-varnish,noqcks\/ansible-varnish","old_file":"templates\/etc\/varnish\/default.vcl","new_file":"templates\/etc\/varnish\/default.vcl","new_contents":"vcl 4.0;\n\nimport directors;\n\n{% for backend in varnish_backend_hosts %}\n backend application_{{ loop.index }} {\n .host = \"{{ backend }}\";\n .port = \"{{ varnish_backend_port }}\";\n{% if varnish_health_checks_enabled %}\n .probe = {\n .url = '{{ varnish_health_check_url }}';\n .interval = {{ varnish_health_check_interval }};\n .timeout = {{ varnish_health_check_timeout }};\n .window = {{ varnish_health_check_window }};\n .threshold = {{ varnish_health_check_threshold }};\n }\n{% endif %}\n }\n{% endfor %}\n\nsub vcl_init {\n new application = directors.round_robin();\n{% for backend in varnish_backend_hosts %}\n application.add_backend(application_{{ loop.index }});\n{% endfor %}\n}\nsub vcl_recv {\n set req.backend_hint = application.backend();\n}\n\nsub vcl_hit {\n if (obj.ttl > 0s) {\n return (deliver);\n }\n{% if varnish_health_checks_enabled %}\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (fetch);\n }\n{% else %}\n if (obj.ttl + obj.grace > 0s) {\n return (deliver);\n }\n\n return (fetch);\n{% endif %}\n}\n\n{% if varnish_grace_enabled %}\nsub vcl_backend_response {\n set beresp.grace = {{ varnish_grace_period }};\n}\n{% endif %}","old_contents":"vcl 4.0;\n\nimport directors;\n\n{% for backend in varnish_backend_hosts %}\n backend application_{{ loop.index }} {\n .host = \"{{ backend }}\";\n .port = \"{{ varnish_backend_port }}\";\n {% if varnish_health_checks_enabled %}\n .probe = {\n .url = '{{ varnish_health_check_url }}';\n .interval = {{ varnish_health_check_interval }};\n .timeout = {{ varnish_health_check_timeout }};\n .window = {{ varnish_health_check_window }};\n .threshold = {{ varnish_health_check_threshold }};\n }\n {% endif %}\n }\n{% endfor %}\n\nsub vcl_init {\n new application = directors.round_robin();\n {% for backend in varnish_backend_hosts %}\n application.add_backend(application_{{ loop.index }});\n {% endfor %}\n}\nsub vcl_recv {\n set req.backend_hint = application.backend();\n}\n\nsub vcl_hit {\n if (obj.ttl > 0s) {\n return (deliver);\n }\n {% if varnish_health_checks_enabled %}\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (fetch);\n }\n {% else %}\n if (obj.ttl + obj.grace > 0s) {\n return (deliver);\n }\n\n return (fetch);\n {% endif %}\n}\n\n{% if varnish_grace_enabled %}\n sub vcl_backend_response {\n set beresp.grace = {{ varnish_grace_period }};\n }\n{% endif %}","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"3eeacd1f08c11c369bdfaf7e9bee4eeba7810525","subject":"Setting Original-Magento-URL header appears to break Apache for certain queries. In addition there is no need to sort query arguments for GraphQL queries.","message":"Setting Original-Magento-URL header appears to break Apache for certain queries.\nIn addition there is no need to sort query arguments for GraphQL queries.\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets\/recv.vcl","new_file":"etc\/vcl_snippets\/recv.vcl","new_contents":" # VCL required to support maintenance mode. Don't maintenance mode admin pages and supporting assets\n if (table.lookup(magentomodule_config, \"allow_super_users_during_maint\", \"0\") == \"1\" &&\n !req.http.Fastly-Client-Ip ~ maint_allowlist &&\n !req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" &&\n !req.url ~ \"^\/pub\/static\/\") {\n\n # If we end up here after a restart and there is a ResponseObject it means we got here after error\n # page VCL restart. We shouldn't touch it. Otherwise return a plain 503 error page\n if ( req.restarts > 0 && req.http.ResponseObject ) {\n set req.http.ResponseObject = \"970\";\n } else {\n error 503 \"Maintenance mode\";\n }\n }\n\n # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n unset req.http.x-long-cache;\n\n # We want to force long cache times on any of the versioned assets\n if (req.url.path ~ \"^\/static\/version\\d*\/\") {\n set req.http.x-long-cache = \"1\";\n }\n \n # User's Cookie may contain some Magento Vary items we should vary on\n if (req.http.cookie:X-Magento-Vary) {\n set req.http.X-Magento-Vary = req.http.cookie:X-Magento-Vary;\n } else {\n unset req.http.X-Magento-Vary;\n }\n\n ############################################################################################################\n # Following code block controls purge by URL. By default we want to protect all URL purges. In general this\n # is addressed by adding Fastly-Purge-Requires-Auth request header in vcl_recv however this runs the risk of\n # exposing API tokens if user attempts to purge non-https URLs. For this reason inside the Magento module\n # we use X-Purge-Token. Unfortunately this breaks purge from the Fastly UI. Therefore in the next code block\n # we check for presence of X-Purge-Token. If it's not present we force the Fastly-Purge-Requires-Auth\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n if (req.http.X-Purge-Token && req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n } else {\n error 403;\n }\n } else {\n set req.http.Fastly-Purge-Requires-Auth = \"1\";\n }\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (fastly.ff.visits_this_service > 0) {\n # disable ESI processing on Origin Shield\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Make sure we lookup end user geo not shielding. More at https:\/\/docs.fastly.com\/vcl\/geolocation\/#using-geographic-variables-with-shielding\n set client.geo.ip_override = req.http.Fastly-Client-IP;\n\n # geoip lookup\n if (req.url.path ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie:X-Magento-Vary || req.http.cookie:form_key) {\n error 980 \"GeoIP already processed\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url.qs !~ \"country_code=\" ) {\n set req.url = querystring.set(req.url, \"country_code\", if ( req.http.geo_override, req.http.geo_override, client.geo.country_code));\n }\n }\n } else if ( req.url.path !~ \"\/graphql\" ) {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking by default\n # and allow custom parameters to be set. List of parameters is configurable in admin\n set req.http.Magento-Original-URL = req.url;\n # Change the list of ignored parameters by configuring them in the Advanced section\n set req.url = querystring.regfilter(req.url, \"^(####QUERY_PARAMETERS####)\");\n }\n\n # Don't allow clients to force a pass\n if (req.restarts == 0) {\n unset req.http.x-pass;\n unset req.http.Rate-Limit;\n }\n \n # Pass on checkout URLs. Because it's a snippet we want to execute this after backend selection so we handle it\n # in the request condition\n if (!req.http.x-long-cache && req.url ~ \"\/(catalogsearch|checkout|customer\/section\/load)\") {\n set req.http.x-pass = \"1\";\n # Pass all admin actions\n # ####ADMIN_PATH#### is replaced with value of frontName from app\/etc\/env.php\n } else if ( req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" ) {\n set req.http.x-pass = \"1\";\n } else {\n # Sort the query arguments to increase cache hit ratio with query arguments that\n # may be out od order. In case you want to restore the unsorted URL add a snippet\n # after this one that sets req.url to req.http.Magento-Original-URL\n if ( !req.http.x-pass ) {\n set req.url = boltsort.sort(req.url);\n }\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.http.x-long-cache || req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n unset req.http.graphql;\n # GraphQL special headers handling because this area doesn't rely on X-Magento-Vary cookie\n if (req.request == \"GET\" && req.url.path ~ \"\/graphql\" && req.url.qs ~ \"query=\") {\n if ( req.http.Authorization ~ \"^Bearer\" ) {\n set req.http.x-pass = \"1\";\n } else {\n set req.http.graphql = \"1\";\n if (req.http.Store) {\n set req.http.X-Magento-Vary = req.http.Store;\n }\n if (req.http.Content-Currency) {\n if (req.http.X-Magento-Vary) {\n set req.http.X-Magento-Vary = req.http.X-Magento-Vary req.http.Content-Currency;\n } else {\n set req.http.X-Magento-Vary = req.http.Content-Currency;\n }\n }\n }\n }\n","old_contents":" # VCL required to support maintenance mode. Don't maintenance mode admin pages and supporting assets\n if (table.lookup(magentomodule_config, \"allow_super_users_during_maint\", \"0\") == \"1\" &&\n !req.http.Fastly-Client-Ip ~ maint_allowlist &&\n !req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" &&\n !req.url ~ \"^\/pub\/static\/\") {\n\n # If we end up here after a restart and there is a ResponseObject it means we got here after error\n # page VCL restart. We shouldn't touch it. Otherwise return a plain 503 error page\n if ( req.restarts > 0 && req.http.ResponseObject ) {\n set req.http.ResponseObject = \"970\";\n } else {\n error 503 \"Maintenance mode\";\n }\n }\n\n # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n unset req.http.x-long-cache;\n\n # We want to force long cache times on any of the versioned assets\n if (req.url.path ~ \"^\/static\/version\\d*\/\") {\n set req.http.x-long-cache = \"1\";\n }\n \n # User's Cookie may contain some Magento Vary items we should vary on\n if (req.http.cookie:X-Magento-Vary) {\n set req.http.X-Magento-Vary = req.http.cookie:X-Magento-Vary;\n } else {\n unset req.http.X-Magento-Vary;\n }\n\n ############################################################################################################\n # Following code block controls purge by URL. By default we want to protect all URL purges. In general this\n # is addressed by adding Fastly-Purge-Requires-Auth request header in vcl_recv however this runs the risk of\n # exposing API tokens if user attempts to purge non-https URLs. For this reason inside the Magento module\n # we use X-Purge-Token. Unfortunately this breaks purge from the Fastly UI. Therefore in the next code block\n # we check for presence of X-Purge-Token. If it's not present we force the Fastly-Purge-Requires-Auth\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n if (req.http.X-Purge-Token && req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n } else {\n error 403;\n }\n } else {\n set req.http.Fastly-Purge-Requires-Auth = \"1\";\n }\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (fastly.ff.visits_this_service > 0) {\n # disable ESI processing on Origin Shield\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Make sure we lookup end user geo not shielding. More at https:\/\/docs.fastly.com\/vcl\/geolocation\/#using-geographic-variables-with-shielding\n set client.geo.ip_override = req.http.Fastly-Client-IP;\n\n # geoip lookup\n if (req.url.path ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie:X-Magento-Vary || req.http.cookie:form_key) {\n error 980 \"GeoIP already processed\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url.qs !~ \"country_code=\" ) {\n set req.url = querystring.set(req.url, \"country_code\", if ( req.http.geo_override, req.http.geo_override, client.geo.country_code));\n }\n }\n } else {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking by default\n # and allow custom parameters to be set. List of parameters is configurable in admin\n set req.http.Magento-Original-URL = req.url;\n # Change the list of ignored parameters by configuring them in the Advanced section\n set req.url = querystring.regfilter(req.url, \"^(####QUERY_PARAMETERS####)\");\n }\n\n # Don't allow clients to force a pass\n if (req.restarts == 0) {\n unset req.http.x-pass;\n unset req.http.Rate-Limit;\n }\n \n # Pass on checkout URLs. Because it's a snippet we want to execute this after backend selection so we handle it\n # in the request condition\n if (!req.http.x-long-cache && req.url ~ \"\/(catalogsearch|checkout|customer\/section\/load)\") {\n set req.http.x-pass = \"1\";\n # Pass all admin actions\n # ####ADMIN_PATH#### is replaced with value of frontName from app\/etc\/env.php\n } else if ( req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" ) {\n set req.http.x-pass = \"1\";\n } else {\n # Sort the query arguments to increase cache hit ratio with query arguments that\n # may be out od order. In case you want to restore the unsorted URL add a snippet\n # after this one that sets req.url to req.http.Magento-Original-URL\n if ( !req.http.x-pass ) {\n set req.url = boltsort.sort(req.url);\n }\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.http.x-long-cache || req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n unset req.http.graphql;\n # GraphQL special headers handling because this area doesn't rely on X-Magento-Vary cookie\n if (req.request == \"GET\" && req.url.path ~ \"\/graphql\" && req.url.qs ~ \"query=\") {\n if ( req.http.Authorization ~ \"^Bearer\" ) {\n set req.http.x-pass = \"1\";\n } else {\n set req.http.graphql = \"1\";\n if (req.http.Store) {\n set req.http.X-Magento-Vary = req.http.Store;\n }\n if (req.http.Content-Currency) {\n if (req.http.X-Magento-Vary) {\n set req.http.X-Magento-Vary = req.http.X-Magento-Vary req.http.Content-Currency;\n } else {\n set req.http.X-Magento-Vary = req.http.Content-Currency;\n }\n }\n }\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"d84d1412d8be6972eb21f30804de06bbb7acc096","subject":"Text tweak","message":"Text tweak\n","repos":"holderdeord\/hdo-puppet,holderdeord\/hdo-puppet,holderdeord\/hdo-puppet,holderdeord\/hdo-puppet,holderdeord\/hdo-puppet","old_file":"modules\/varnish\/templates\/fastly.vcl_error.vcl","new_file":"modules\/varnish\/templates\/fastly.vcl_error.vcl","new_contents":"sub vcl_error {\n if (obj.status == 801) {\n set obj.status = 301;\n set obj.response = \"Moved Permanently\";\n set obj.http.Location = \"https:\/\/\" req.http.host req.url;\n synthetic {\"\"};\n return (deliver);\n }\n\n if (req.http.Fastly-Restart-On-Error) {\n if (obj.status == 503 && req.restarts == 0) {\n restart;\n }\n }\n\n#--FASTLY ERROR START\n {\n if (obj.status == 550) {\n return(deliver);\n }\n }\n#--FASTLY ERROR END\n\n #\n # error response if all else fails\n #\n\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n\n if (req.url ~ \"widget\") {\n # no HTML response for widgets\n synthetic {\"\"};\n } else {\n\n synthetic {\"\n <!DOCTYPE html>\n <html>\n <head>\n <meta http-equiv='Content-Type' content='text\/html; charset=UTF-8' \/>\n <title>Holder de ord<\/title>\n <meta name='title' content='Holder de ord' \/>\n <meta property='og:description' content='Holder de ord er en politisk uavhengig organisasjon som kartlegger norske politiske partiers l\u00f8fter og sammenligner disse med hva de gj\u00f8r p\u00e5 storting og i regjering.' \/>\n <style type='text\/css' media='screen'>\n body{-webkit-font-smoothing:antialiased !important;}html body{margin:0;}#container{position:relative;}#logo{margin-left:auto;margin-right:auto;position:relative;width:300px;padding-bottom:20px;}.information{font-family:Verdana;font-size:16px;font-weight:100;color:#111;text-align:center;position:absolute;top:40%;left:50%;height:30%;width:50%;margin:-15% 0 0 -25%;}\n <\/style>\n <\/head>\n <body>\n <div class='container'>\n <div class='information'>\n <div id='logo'><a href='http:\/\/www.holderdeord.no'><img alt='Holder de ord - Bringer politikken til folket' src='data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAASwAAAC9CAYAAAAJMEAnAAAEJGlDQ1BJQ0MgUHJvZmlsZQAAOBGFVd9v21QUPolvUqQWPyBYR4eKxa9VU1u5GxqtxgZJk6XtShal6dgqJOQ6N4mpGwfb6baqT3uBNwb8AUDZAw9IPCENBmJ72fbAtElThyqqSUh76MQPISbtBVXhu3ZiJ1PEXPX6yznfOec7517bRD1fabWaGVWIlquunc8klZOnFpSeTYrSs9RLA9Sr6U4tkcvNEi7BFffO6+EdigjL7ZHu\/k72I796i9zRiSJPwG4VHX0Z+AxRzNRrtksUvwf7+Gm3BtzzHPDTNgQCqwKXfZwSeNHHJz1OIT8JjtAq6xWtCLwGPLzYZi+3YV8DGMiT4VVuG7oiZpGzrZJhcs\/hL49xtzH\/Dy6bdfTsXYNY+5yluWO4D4neK\/ZUvok\/17X0HPBLsF+vuUlhfwX4j\/rSfAJ4H1H0qZJ9dN7nR19frRTeBt4Fe9FwpwtN+2p1MXscGLHR9SXrmMgjONd1ZxKzpBeA71b4tNhj6JGoyFNp4GHgwUp9qplfmnFW5oTdy7NamcwCI49kv6fN5IAHgD+0rbyoBc3SOjczohbyS1drbq6pQdqumllRC\/0ymTtej8gpbbuVwpQfyw66dqEZyxZKxtHpJn+tZnpnEdrYBbueF9qQn93S7HQGGHnYP7w6L+YGHNtd1FJitqPAR+hERCNOFi1i1alKO6RQnjKUxL1GNjwlMsiEhcPLYTEiT9ISbN15OY\/jx4SMshe9LaJRpTvHr3C\/ybFYP1PZAfwfYrPsMBtnE6SwN9ib7AhLwTrBDgUKcm06FSrTfSj187xPdVQWOk5Q8vxAfSiIUc7Z7xr6zY\/+hpqwSyv0I0\/QMTRb7RMgBxNodTfSPqdraz\/sDjzKBrv4zu2+a2t0\/HHzjd2Lbcc2sG7GtsL42K+xLfxtUgI7YHqKlqHK8HbCCXgjHT1cAdMlDetv4FnQ2lLasaOl6vmB0CMmwT\/IPszSueHQqv6i\/qluqF+oF9TfO2qEGTumJH0qfSv9KH0nfS\/9TIp0Wboi\/SRdlb6RLgU5u++9nyXYe69fYRPdil1o1WufNSdTTsp75BfllPy8\/LI8G7AUuV8ek6fkvfDsCfbNDP0dvRh0CrNqTbV7LfEEGDQPJQadBtfGVMWEq3QWWdufk6ZSNsjG2PQjp3ZcnOWWing6noonSInvi0\/Ex+IzAreevPhe+CawpgP1\/pMTMDo64G0sTCXIM+KdOnFWRfQKdJvQzV1+Bt8OokmrdtY2yhVX2a+qrykJfMq4Ml3VR4cVzTQVz+UoNne4vcKLoyS+gyKO6EHe+75Fdt0Mbe5bRIf\/wjvrVmhbqBN97RD1vxrahvBOfOYzoosH9bq94uejSOQGkVM6sN\/7HelL4t10t9F4gPdVzydEOx83Gv+uNxo7XyL\/FtFl8z9ZAHF4bBsrEwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAXFpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IlhNUCBDb3JlIDQuNC4wIj4KICAgPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4KICAgICAgPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIKICAgICAgICAgICAgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIj4KICAgICAgICAgPHhtcDpDcmVhdG9yVG9vbD5BZG9iZSBQaG90b3Nob3AgQ1M1IE1hY2ludG9zaDwveG1wOkNyZWF0b3JUb29sPgogICAgICA8L3JkZjpEZXNjcmlwdGlvbj4KICAgPC9yZGY6UkRGPgo8L3g6eG1wbWV0YT4KJMk4MgAAQABJREFUeAHsvQmAXEd17l\/3dvcsWmzLsrzgRaPFtjbbITZgCMRjICSQAC+ABAmQsATvxiwJj38WyyYkL3\/AYGxLtpU4bEkIEiRAgLBG4zzALHLAWJstjUbyJtuyvEmzdt973+87dW9PjzQz6pnukWbkLmn67lWnTp3z1alTW5AkibvgggsKTz\/99KzWOA7CMEzi9BhFUVgcaCqd98j9T61NksgdhvD8efOOKzrXksvl4srkREvLwMCzGx5+uKfy\/kScB9d35N2SPUmyfHk5z8HNNx\/jguAsF+aXuSRZ4hJ3pgv4S9xcjjM4Oo6OZ928t5PrbVxv47jFhclGl8\/fn1xyyTMZvcG6dTk3Z06QtLeXsnv1PAaEpUuXTi90d+efpUyzuI+hbHU9a9asng0bNsDqIxvOWbjw9GLRnREELoHkGHEUF8cdciGSEgS9+WLY4\/LR\/ub+\/n3DyQxpheeff37u7rvvjtCBIbI27sSH+fC8k0+eHra2FirLYJjXJuxWVt6tra29GzduHKg2IWHCvn37ji0MDOT70MUMG6r9vvI94UlpoLmUzEgGZsyY0Tec3F0cXJx3rsOtT5JR9SEQYC1esOCcIHarkOpjkJZ+boUIUIQIzUADd4Y5d8XGzs4HVMgTUbhZvCL6sbYHPgYdr4GOpzmGWcaDJJgehMH1m3ZsW6t72TfZ83ocDUQ2bw6SlSuNacH114eAyvkuCn4LNXoFf893hcIs19TkkyvyGtrm4gp5DyG5UOAP\/isMICMDxaf59peA2X+5IPmuO\/HEDRkYkgbguGQIOPoPx\/eb8eXMM888plBMbiC9c5Mk2E95hqQPAAfT4Gsff3+9def29byfo0zLwDy+VMf2FWkaKJFusqRt4V\/Am5XQJmUaoGBz0DbugEBHxIcMBz0k8hTy+xiR7eTe\/S52m6I4v+W+B+97uDIBKWc9gUv5U96UBvn7aBIkr4Lv3Vwm0GR5r0x\/gs6pApIS+N9K\/H1BEv\/d5l07vrcC\/o5mfIgXApSlc89cGofJDUHizuB7dDEpQPn4igYiAhdQvkkPEVBpB7vhUCd82RwXC5sqyyMti1LGvwN5Y1oFCh0HNrwsDzJZFYfOid9YOa4Ylc4oxtG09MOJYrbFu+\/8fYHbGzy\/KZ8\/m3qSJNPkOOSC0JVKJTEvC3WlJVizpoAFZBaHAdXxc17pZp\/4dorod930abPEcgMnAVSxCJjzj1KAGIHqIC1i3EB\/7Pr70+dBDoA7DhBrh6ntrqfnA+7xJ74V3HLrP7m9j3+vDI4V6WcZHM9xeUpLvjdfSPIDr2jKF+ZFUWzkizQsaCvjOIk\/q\/jbXbv0q6xg40mzlm9IeUYY5grQpr\/pJtq1RegLQyUiNUnjUt5RwIEwLG1d0rbghzz73kDO\/Xj79u2PZzV+pqy1JJ9+q2RNufl5MWXwAqyMOkQ7tijK5R2T9zj+F3294\/zzJa8jVlB9fX3GsjhwxyCvFxXyhZZSHJn+jQ+tSI0PfRUlCnyw8oiTUpgvbV7ctvC7vPFvW3Zuu0tlYQI5QkVqgJUkuSJZeiaJo2OJboCaiDYE6Jy4Fojem8POzhI6DMdnBFYwuJ9M5JA4SMNOCJM8J70V6Y+bfxVxSKADd31HLlmZgtXq1S8AqN7LO292M2cUXD8VQ2+PpE08UGFjqTjRNRgqz60STZ+LQqDAFQdi+9N3Aq\/mpj90+\/avcLPnrAtuvvWm5OrLfyKwNGtr5cqIz2rOWy7Yj6nRtLcURfMQjn54iOWSFKmQVOMOIBR9gxk4omcDUuY0wwP4IySTNecfqPJslPyo6nAuj9I0hUHuXOq+c6M4vqIpSn6KsqxLXOnftu7c2SVluTgI8h3YzPCsLghD8k9TBjIAVBmKFsnQYBiv1TIYw\/Bn5Dkrb45Y1L68Z86cWRVvKZNSGAZ7AatTKZMe2hLNnqfDJzeWu9Aj\/Mohg3kqq3M5P7cUx++hIvknNOTT8Gob8dGyP9j6TwHLAFAFqpLKQ1iouknXZDRXB\/mpPj+gJ2YA6SJgZEoljdaLFGhTe6t+wSwpopOVg4U1zQ2UAKrgTwGq2a4Pfd6\/v2gCRlOYt2jnlQMaJoEO+ZOVf2CQssR8o+9MQOGhQIz7AwORgVc+X3CtrX\/g9u\/7neCW1Te4vpk3Qke3aCJCNUtrVhhKMOf5lhQ4+jKlXLGuVO7D0H1gPib+mqZbKGmDnypqCbEVvk\/ZdMt+xkYJ4nJQ7igwajyaRj6+wOVzYe5FJPuiKMn9yZJ5C27rD91nO5PE\/IxyT6xP1o\/qT6mKJpROpJA3KlxjegVlFadVRTaGl4gaN4ppDlku0O4fU2KFfIJDEVCBkcBLpos+BygFeYl4dsiyETilVEuHQ4GK6BJHVCsEcSwfIoZ\/eCx\/V0Zx9Kql8878s01d277G\/YNAywBrODb4hCAWxMpSHO69qXovWIHTe9114lkSrFp1Frz8OADyOmXYgErMTZza7QQrF5USAgy3wzDv8oWQNjNSIVyq4JC+F5apSVvidczeNAIAK6HABML8RaUIsIpdczPNzfCjuDguDG655c8Aqq1KUf60zM+l69pDBY1EX3t8kzMGcV8FgFoI8FVwsjSkePLLivd2m2KKsbJk+uRxfSzieGNzFP8eFtfKLTu3\/1hgdfHFgNb6OoCWkiR4pg+yHrqk9LLcB2\/am\/X5If4S+ZWOF2M6NMYR6wF0pZcwEqlXJXzIQP48y3nTAEgtFX8TA8kqJ1VXlFiCQqAYudyZlMvapW0LLt+0s\/MfU9Aq+85lAQwbiNOKdtiHU\/xmsGJFLlm7XMie0CR7Gdj0VTdj5utcH63Q\/n5ZVbKmsmYf5S6HIWxuaSm46TPy5lQfKA643r5H8EltdN37f+p6un\/kj1z39T2Mn6sfUHNu+vS8fWdOb+KxBq4xUMpDk5P0+mjpzpjxe9DxNUCrXU8FVtYJYK8+F38oGylGiPdyDH9YTaEQKBeGBUw3moBBwRSD6gMu0izzVTDy7SskbtL8UVNZyvJKlOfrS9rO\/BNxXGAl0NJ5fYNUy8wK0dkkWiforxVeOOJuATbkCnD0\/B0AQqPmbBgM4Jb\/r0NVf8In1RZpuTRRHgWLwgwApQ9JPCa2HGDVr3IDXVfRRPzdlDo+IQLCBBRGmsQkPajJlaxdq1rNBTevfhWM+rybNuMkt+9ZCbRM1tSqsgx48JrW0oSlBJj1PcHdDfz9DHm7l0ZrF9Kue\/vpFSwBUoBZfrrri+ZQQm2uVFyGA\/6FxHkBltSJLsw14Q\/jdRSnbL0BWgKxfc\/GgOFZAN+6YNVt70yuvOwbGWjV19JS8pM4SAtgrgSU0234Vb+HkY+BkOSNT6ORbhV\/MI33jiGO2bx6EqV8CgozE8zLUz9RjPx44KKc0QFzpzg5\/GVxyW8zm3f+fvG8Bc\/b0tX5kQy06mlppQpKayh5iDbRIxBE9pRfy\/xoORzDM3IdJLiD41Zy2QtrHtHHM++uzoeVJmQgkSUKfTHAozEy+yD1RprX9yPnMxi1YPqUvTfkGLjmxEWMPghOgNen8t1CmL6IioXeajzT1gJR2ZKUQClJAKu4SOXRAvGfOPv0s39J2TzMI1l00XMKsMxntXKlSUVwy20vB6z+yU2bPsd1dxdhlniRFRC8xGfd3FyQP8319HVicP4bf19306ZtSN7xjtEc1nuJ5wH+7ubvK4zfanZB069jSb2W6zcQ59kUmiwrmetqIvo\/uZi6uweI\/wRA6wuA6ZuTq6\/4rluxIg6uuy6sh0+L9KdA8IhCLYt6RD\/dvLPzyrESra77bW1tM\/vC8ERa5\/PpFz2vFAcvIZ4XoyhzUJgC5rWag9IRayaiULK4UJZEHRJNXF+\/dN6C3KauzpUGWsjH+kOMEaqOTp+odJP0PxM3Fz5O73drfgCnZn5AVn8mg9VFN8pbpEF0HvufLg08q1dr8cvBEyoODW2Ke+iWu2PTjh27Rkl+2EdL2tpOwVV5fpREbwCkl1NBzIhwqoJU+k8SRnSojhgsw0WMrrqGiD5EPuTPMiUdNuKj7SZSEDDeSbV2HNx8+3mAz2dorgFWPSlYlQVFtUUIkOVdb+8+pOoOCmdNcsUVWzKeWFxr1gyC\/e7dg1XjKVToWbjkklJy9dW0M91d+gtuuv0zANW7UYxLAKZZNCf1ptKj9rD0m7gHaE0\/DtC6A9\/a6ymo\/wFoJd6ifTAdfXmUBzJb9pNIWKV91WQ5HWf0NO\/q737+vq0hC91PPP0C+p\/fzPUf0DyZg0XFqZqJ5gLQuUITyQygOU2w\/Fqc8U9u7ur89HrAChJqHrOmDEhA9Mc4pL1bt25FxrBYDkMYCw+HI4daHBkEVwTuERaTc7vmzZvX0razreTah\/vCuTkdHck6skowZm\/euXM3b35Df4vmn\/lVTN5PAkwLKAuBlpgi1FIlUiIpOiqSNy2ZP3\/VZg+OOI+fK2HdutCaWKtWzQbFb6X5dQY+J5gi0K4AK9W4LS1YVd3\/g1j9ZXLV5f+ZsQjgQIhpvl13nWpCCfqoQQISrF2bc5s3M2xi5UDy3kvVXfthrLtvA0wfca0tL2PYBIPfYiscL8VOzcYiPq3TsLhWB7fd9jq+fZy08y4d0DpqokfRQ7Evyw6j0uWkVbO9fC97lh4zLNBl0N7eHmT+mnRQqMrrx\/rDsf4lmhsfJL438FfAqqKJroGRRO1jaUJRBmj+NNFk+ZtF8xbet7Vr+7cZ41bXQFLmV4KGcOHChYXTtp8W2VjEOqWiIQzigY4dHR1qDY\/H8T4cNYlmFOiBwOpQVhv5s8Drml0QaqyXRt1v3bHt68vmLniSpvE6eghPBrO8pZWWA\/TK4JoHSr6cbz8j\/j8nAGtIj1sSXIdl9WIACXmhphhUAHovGDnbhKO8t\/crdOC8D+voIZ6rx67JLV9eFOjoGuCww6F+YLjEXwVLbxCKtm5dAdAcSK66rAPr6fdx8n8CB\/476K\/Ku1I0CFoql\/3d+LSmvwg6r+P7K0i7NCQf3DzqA6iR5RHQkcLpunwve1ZxHPGZmombly7NSVHUC8iwhZ89OvcBjbe7Frf+sbRKaKLjS8lAC0tLzUN8KdNpmn5k0RmLfrU1SR6p4+BSTGbv+yFbamoVtyXb6gUoFSyZ4NP2Q8eflpteNF3QScbHjbs6f7h47sK\/RT9uggfWG8i5xoGim95Zz8DEC\/nkM7KcpbBHdTCgWL7cBCG4adXrYcJVNMuUZ93L8u\/BSlNq+gf+0cWltwqsNPo9BYkBNGFEZaiGgfpeYCU\/miy15Mor9+JYfyfjsm42P1kuJ6eyLAgFrGKuNBYsCC7Hn\/UG3TQLUdOFGmHMHJCwC6ykFMuWLWuSVbBlZ+cnaZK8jebIQ9TwVN5YcFkpIzgoWh5LjDERuReEuZJ8KS4diV1uqo6ZkMoP1L4aDJXng3eP0jM\/SPdiM5jyuZjiSbapJ9GCLCuBllmEpgqL5tH01LOjX\/jVFET2ghtvPA6\/9l8y1gqcN3NWzm6eGHDlGH2uIQ1fck8sulR+JznLNfpcIGFMrNMPllIsS82c8Ur+qsvfy0DS25kcTWmYT9GnZ2O1sLrUPA2DP8ciU6+XwtFfZj6fE\/IrJRBwqYZXAlt2dX4D+fgjWiOP4ADGwjKfltBKzRFkRM1QSZB7N82Xl+obNWt0bITaODDHdVj1cO+OHY9RLj8z69ZHKeZTFBo7Ztr7vOl0oOjRUc14WTNlwMk3v50eugvMavE1m4crcaEFEOvtvQv+XJmsbFfTqyl1luvphAQDRTU1FWJ6Qvr7v+ma00pEICrqNNCxp5dJES3nA7lv06vWNGQcmc4bYfwcyKbhAEqBTQJPgvfR5uznUkAm36bpCvpSwMdSYsDUbNr171KK2bfjT73xpTiAM74cAKedwia4bgaGPTAvPGdBMpN5gsx3PsoBy23aJLV3wQ03nIAAvscLIY5HpFL3YRBDF5pCBm7uZRLCB9RMs0nQNN3s+QT\/WBOxDI7Rn+Js7wKcRJv3ZQhYtWqGD+8JPv0PJ9np8nq7f9MUnmOH9fT8yZmvbG\/atW0dRtUNXmDoncoc1LqB4hBUGK9d3Hbmi\/X+vvPP9zKki0aonQOJY9iFEOtgtsL5MIhCs4iPWgvLrKt0gKhrnvZahjGfwzIvMNasUHElsik2CCLhpuTyy3\/CzcAxFEE3DltYscImPSdXXcWUnOBjDDTF5U770HfrigwWS+FeU\/NSly\/ZyN+GL6t+pSNrST4txdiUd5\/GmrqLbnbVaVnTHJHBl0WbET8XXfkJMxLKvqyjVn+Ux8MagnRoianjQSkn+LesEj96Gb5piUG1gAvpe5NNp6GP2qwrD1JIKHI6ULzHtTTdYixK\/V0HsWsCb1jVzXpYlsRJJ\/wjoyXXW0+lrF+PreSDQY7ycSXJm2QBpuQcvWU3gfweLupNmzZpSZPcPSw1Q9P7Vo3PgulMH4HvFniKL8tX\/smr6DF8nm6zQKJZZ\/6dxu9YOVDZTkDUT1bdLCEvxyOjloCB2xtEiY1VOyqFXtLllm72GZ8z51xA4CU2EVl2vfKvZlbIJKsSFlcQ\/GPy7nc\/acCW9iaWGXaYTsxi6ujIq4mIwvwDfqsYgKVsNHFaI4ChmKmL\/L6E6T\/npGSpK9wK9DCRedQmo0ojc6SHcd83yeidWFOq23zTnBu8ksP60r3zgmDgfDFjzqY55ee6boTxccAs3MAt09coqAZFmveKCsNOOTySK07XgNOj1Ol+3XWDy7NE7qW2BpUf56Y8+6AVQUul7S5p+rLdwN8lZmWPD\/txzx6fdlLSKOANZlEJkHRXEKuVH5qaj2V4ym+INvU2MoC1AVhiRh0C47w0kj3Y+OCDTwJOX8cBr1hlZRkoweiQsVrMpQuZTB2+UA81NIJPjspKX\/mrKnRU9dZBL4nXe1y7yW9pX98LqBEuzNyGqhXEdw6aASLY+tU9j97TrUhGNGnL6MZLuYgxQgRG4+bpDg6rXQRM31QTiFe9XlHTY4\/le3JM46onbIQMOtMyMPJfwQHiltPd97Kx6mRy5bseMRrXrj2yteXgnMFnGQn\/PYZeMGmagax0IUI4zUMUh64qClBO35uNZqYa2bHxUzMHZGWlvixGuMc\/Aq8eA5xOQii06omZWzBbzUKVwa9prfZ7Hn20G8tMsjQ+2amAuuXON5AQ0bqWqfJVM3PqHIGASFiyftt69crmFs+d\/+dYtC1+eg6VM4E6WksEhdxTs\/x7uqfBvyMCFi9bRsE6FLz0pD7Ytm0b3t8JCebo\/vGDD\/ayBjaD++qTRnDjZ1maOFiaNosZuGwWpRRfY66EyT9QStYcTCdF1yflscciwYIOL\/xBdKcbSN6HZTgdJ7wahOIIUItesLdEcMOaE5IPXqJVIhqhjhxoaWnxMl8qbUvyzVtQppPUFky5Ly3yohS4s4rTp8uPtS1bUrhWMva4PXWS+lopqep7FvfLG9w+tPAhLbqYVPqjshg0bEH3zZJq93eZIiRRFwhFWroHsLqR9YNek1q0km+MCjFdXYPUE0nws0Lf\/m\/ra81JHBGwpM2+pFxznOQuXDR\/\/la6Fmdk3nqffH1+IVYeg75SPp7GSmsnGLnjjJr8BjSV\/NeF7lOx5E8zRUffTeIkFgKsUvFhXES\/9C8KDeyF7PLIHDPne7HILjvNDzBdfbHXkpQcNWsTd5prdqdw5wnmKPqp+LUw7MjkdFKmquk\/IkzNQiY9b+G0HdbaiqFpOaA\/Jkcn02BBtty2DOT0XZUhFUTMstgxlcGHbD4e6el5XYN0oh7xyoiR+oAotI1ja6KNx4iBnHDJGfMvJrIPcPoaZZk\/s6gs43RwgIYFmuDIe3CrLFm+scp8RMCCMM1MJyIAJEjWBHFITwrr10yAYhOvxIDVu4wjs4S2Sn9cpca3hLTQ88+jo+c4pl\/AZSVhyci855Wgi5+H9PKkCQCQaEne977dbFKxAxoXwwjxgYLg168uwAC6WLX7vQCzFRDnjVAfDlhHhpQbMdpucoiicIEypfPbrIS0QYOVgdPE6rEkrXhUlipQaunfp0VxImKp9aBkTvBEsllbMEBJbACslPir0P9DgYTyUUvM0IwCQV8CeCTB8+bNm7erOYqOLzU1jTgUSNuDBVFhepwvzeZU62EtXTx3wW8AVi\/FgpopUIIurbxqC2b6c8d+OCzKG8df2rxr2xdSmnmkyZ4jBhFmi+nksKpgql6snZnDJ5fFq\/XGVZpWcNnN4T8Z6S5LsZQVOYlZSE9z9ExCVEFwYs1Cfb1rokezj0TiiPeHNksf9P5eM5HVzy45pN7BFC+W5igOFeBkaM6OmJ8p9kD8TFcYLaHdDzL0KkKprGaH+6HXVgSIIkHNsjIog1x12fVibWUXBO20e9oNBOz2+ES+Ml3FICnXWDIFlP5RDj9sd+26URNgEbdAT9EeBzNua01y+1m2IcfiYrp3UOB92n4ComgakD+T62MBzmb+DLBZv130qJWg5WQkz7KytFwsLtz4f6Io90FFKt8Vz6xiGAWw9Kopi0Yvka6inPgAYdoEQ3wfdyAOT2sQHGsTi71lAkeIMt3wgPPHx53ABH5Ixs0M5LA3tQxJzfLjS0CdUkEwcwJJeE5HvWfPHtP0OMztwX37LJI4S7pUZopkC5Sh7tAOU1mQvA6+k90d\/ahylpKO\/tYYn1psFqm13hAV21NgjLGM9LrHAyLNA+RnVa2mps2+kSDSVBEAUrJatTpGOt6QyleSjX6yU889IM47tF+hwIxvylbsIQBLhEOkrbfMaX15OyxXlFjdQhwVbHhAOUJlAHmUkASBFnebXEE4raEK3tLSGk3QCYllvhvdXMfTy4SnA2TL142TunAAtsu\/dGAnk0DGrF0Ua7AMfCmNMV3qHwOW2qyeYRJFxwM2UE1s9D76VJNVdXD8BlpOK7YSd1kyD36v4k6FsUOWZTLIauWPM4vBozbOd9pA8c\/yQfK6ex\/c8Vg6QX1Ic7MKwCJqz1lFXR2BFbSO9ZQsmAkx1u+GfZ9m+7D3ddM3D0d8fMQfWD0\/EhUV+0RmA2RHerVxf1wcoJ5Hi4YtBDNdRno4lsSQdSnUsImMJZ7KdxUnIT34i\/r\/AlW2A5Gp18g6liXs34AmmSMpaUO\/0k0wlpuJOz0Kwt\/m+vOaNgX4ij\/lt0cHLIvGox\/jJMC\/NLGMkAk4Yi6m+FiHxALXa36fMtmeL+I2fKs06ScgJ+OI0rPaF452QVZdVDaGFR\/XVqjx\/nHE3vhkDBygZ1xO4APBRGWDH8dKgmU0agmKxGtjLbEM9y0xM7hVsi5xiWXN1D+kRgwARGfBIaIX16TVJrwGPl4DjY362CJgqAQL9IXhKbz2OTYBadMmIHwlH6F8Z2Ypjg5YSsO4ipMxTh5mN4sOou7HS0ZBGhWHoLS6x4bXWuDfL+1xMQSeTtKWdnUxVLxFcwoaUz9QvNcU3vymaXRZtLGz+WAVX06KU6j0jE3Y8cXYTDnJK2vlyo+GNkzG5uyk4F7tRJSHKYTxDHrGp3lzKuU\/0SObFIIVkc1tS1P0ZTam5K1JSOHWt8kGKIjCImJuaxWh7kOaVGMiccSXiZ1UNABrxFfSB2KMfwtzBymW+gl7pN+c4sfyriu9TmRMf4ojOgxyKPD1i+cvfHTLju1r7Blf65NRAEvxEQm1PF73u2HrOzY\/0LlR9yYqQFO4pG3+V+mYOT2mm0AZGFda6in0fqBH4Uw3lsp0b6mIdYbUqjnna7dnFumznSDGlU69P0rptiWZg+AMK2k\/Mt+kW5t7s5Sy9ja0DgMyk+Wz3pQ8Z+Obn47FCqLcSdhSM5Af2A0IwGrpmnguVeNkj5gkmeVgulId0\/iYjwjyht3Bh5\/lrxkTQr3xGBkGkdVFNcxbxIqoa\/yRlhjGq10I7tOxw3UMsdV1bzyBnAsRRb2c59\/k5BskVWLAgyzSoXzwcwSKeNVb+OoEPpkLaefAgXPpXGxVXjXdyX8mFhuiMQVK6+mzN2ESXb94wYK7eO9e9RTy\/QjbfIka1puGrDxgJQfe\/9kywWBFikLdePG8haOhqF4bNcAxEyp7KQge4upxegrnSbfFaw4YiqrY3AKWJ17Ae\/fqXZUB6Q9luEVyGH+yqTa7n5yLssyXskA01ZFNocKlYmW2l\/mEfjoRAGdzCg8jiUdzUqkMeMUOkjYbvqAJz\/Izeckw8wVF7UWmrAza29vDsexZqGikXvrjZ+Pmru0\/1ulEhvrJthQIZgAs8OCO3iC+qqurqzz4tZo8LFiw4NjmOFzMcIs3AVTvxJo6nrhgC8Ju9YLpYR6wYjR57mRGPvwZ8f6RlrgmH6PvmgNd6ll\/LBcF94iYedrSp40tfTp0Vb+g4f0aMXv66ae3zsw15bxs1CH+JUt2u41bOg2wBFXAO4zxzSrtTxe7F5OKAZYHhzqkWUsUmzebHDPN9gVEc5o1\/8rxQbemEgauy+Ujm7mubcvKjxsnNXOg3bWrRiixQUXetbmlKIhEht5aPwiTa6wB1fTBbuz\/B5VgNgxiPIlTotZs07dKs15W0IG01Ksihl5N\/taqFfujnLu9q7Orb6xg2NnZ+Qz0\/UR\/bD7xRfYkvAnQekklaAmYeM7kX3YyYv2xZQsWvGBjZ+fPl8P44ZuEUGZGL9ohMI2avHm5c+fOARDVnF8HMqWWawmCvmdCZPGxrgdIvT4haWe5401bfkFmXkmMADrWihyp8gNprfS+6NXcXyMr5UgPwDTVGNzG65XQF7LTtMiWUxOeUBJWju4X7JHYcLrXR0SGxLJnqR+D9UjbTmbjh7+e2ttmYqkEFAzDnLuvaUaTAVbZ5+Uf1\/QrYBEA1BTJAR\/XC6wULQIoG0jYsB9EMcsKndXW84DLIUNAhcDXwLLsIHRxy67td5932plvLuaTr+JsPx+rq9w85HkoUGCowyxajVo08eeaSygkGzaIOD2g0CoZWHk+7HfjvGnxZvvIjTOOwc9Sx7u\/Ef7IFF\/NqbSxzP1S2iy8KLjllgvsPayVegvLIEFVnPmJzy5YvXohdF5sX1hHhDVHKAVERauRxsmPyrGlU3nK142TmjjAQn7WHMwlwW8gLGem00aYKaFopfoJSydbEhvYyMIqjbFOzRlCYEXVjxrblaVSx58h6dV4ISNG2UcY2ZbQt86ev3074z9wHB36L9J8yfXItN7VGCtEOrznoW0PEeO1gBWzCmwcEslIVW1UvSxaYdBvaAaCvhsRsCrzxse+mCpvTuJziKWP4XoDQfbI\/DmkbvcrdqaQJZ9EkUqhqXkWEP52ZUWL6IkzRyIYUG5KVx2N3Zuhtc0v2JfVttClLchK0QNsSCxzWnslanPWCpE\/EpQfPWlKgVCI6IJTT50Gd9+QTm0pZmYt99TlHjCdpBczwyqNTInqxAUvr3WKbIKjgQW4tgl72tvHRbfGWMn\/pzjwhf0Xh5+oTvZBZpKu1PKyZBY80fnQXD2rCrDSWKbkgbXSHyHP37cpOj6\/vlko60UhCd4S3LLGr+KZWjmHPaO3355P1i6P6LU8g7T\/iK4d+dlEH2ahSoyC1EpAQfL95Ko\/6Trs9B3lCUo35t8938C\/p6n1dWT31bROZFN5\/ZAe4RqRs5n\/G1wxv0EsqVuLQJE9B4OWmlG2zXHP2onW3paUpyhVNi+Yg8jkTtuA5egFrMpmYeK+wjZeJZcvNwvFp9CaWC0t7HfGjjUELJZScJi30JLvTPsfKn03UPoAu+acZU1YVTAKMpA1G7S3h7NwrW7xIGAnalMwXTdCbRyQH2ZtsjY6Z\/58lCJ5H7NvpTS2zrvFDHJxbPKH4BtbHtqyV\/drag5axI2fjAPI9DNp1ZzdsqMhGrxn8qZNhTpqActQmk0lLNfNuTvB7fWu0CQAEBDoV13VJSdDJnBvDW5Z\/WZ7ly20zAFvFxP7Y8DjLjIag1W3\/R41zHusWRqzbbpZV6nLoLlZhHyH5m2HTmjuqic1LUu70\/gZJwfUFMzWdCrFwYfCIPci22dXYxTFYUkLTmV6x3B7JtsjF31dSWl1UgCsUWmIGXUI2K448Y3h4vjQoOFVaY\/qUQtYluNsgTtZMEl4u22X5Z0TmaDlWSudvQlbZHr9TXDT7WeaL4uP1UwYyrX6XhlYrVmTt41b5Wh3ycfY0HUaY8OEoLT\/CKrSqe6xruRsX22br4qulSvNOVxfip57sQms5EtRzhlVfQlK8wGPQRod7svfQClx1HQUR5D8031dXVt1joNelUoj1IkDjI8ecQA3ZVBgfSx2Oz7KfVjmlF671oPy3se+RhX5n7bLs8+3t7WQTJpgCVvYL2D802ptaW\/fLU+\/q1OBVEZjFlxHR05NweDWW2cxQeF20l\/Mhq7ev+ahUtVN7FoZfpEkX3TvvfIbFsd11zWsq0pmjuMczA8rwWpp24K3MuT6Uzarw+8H6SsM1Sp4l9UiZyDjL\/O54B+VXOqgzyq9cVDQ+CTlgGTcApVFr11UmgnSUG7yTKPfj37AMk7g6zE\/kcY4BfHfue7uHs1XMOvFs0tNwwSwcIDGK+k5XMP7LeYE156GdQ7EbcpgY8RWrZrNPIovkO7L8bEBTJaYH1VNj5Vrac67\/fsfA7f+D7VMop5Blp957lhXSGo92S+gskGhcDqzrJgKdiXI8w\/0ALLInHXEDDYF5ceiW5YmopxYH7t3+\/YHFQe+q4Z1Vc+CIS6kewQLyxBL\/hsDLF+T1DnxyRQd2S1P1WEr+v\/GV\/V33PqIRqTBJdWSoapR7mmRwhw2zekACN10g+tt1yM\/BjZEJMe+4gs+fevZjFyXZXWRgSWef0vfJ1aiKZhnuUhV8dcmV17lR+PTxFXwr4z\/N0UBO8xxc2qOb\/yUTPyXAph2Vtuc4zrEOoG9WUbL5s07OXbhSuTgMj\/VJAUrkSRp0FQQF9AU0fTN4JYtXdu\/qEftyMv6rIdZN2oJoc10qSWGo+Zb5sv15kYYFipBRUifG4CVlSiZTrtLw80pEEgq\/eOErYQKbFTeg5kThH+dfOhD+1KrzIQ7i2MsRxSFnjyalUttuk0MUJUtIxzsv8\/swE8AVvOxrGTfyfjVEAYFvZe3pmt3923JVZf72epYZhnY2Vvj\/TFlxKPHQD1FsaedhTXRwPFGN6HfVQCDNjqFpSoPye9IIWD6ht+lhSODMcGdQZDSR+edfN704rTuN7KDwIewqpZqcChDGARO5WYg31i5qylYiuPvFJLiSn1rzciEqTp1ClgVlZba5CyDOuX1UNFQqKYIle+hFlJb+4eGMD5ulH0JKz+c8ueMYkca4uBTn2p1Ta2X2xb1fX0SSjW\/8BshrNq2vlj6anLlpd8ysFm7Ng9ojQOwLiLaO7VyKCDFYNSKwHivReDR+ymB97jmZlbr6tVzlYhvevqlqEM3gx7c7v3fwuj73\/pczci6gJUigxHkL2TdR6uxNBdOAyDndMxJ6rnVVAVYKNWxBAESfLcND041WgEQraKwASThmf7GHM5ZuPD0qBS\/yrUE72CCyUvlrwKnFCFaYSsBqCTMsiLyIE9nBwuGbCgkuSt+tWv7U5U+rzEnfuAHyoGp4uBcQoZWaOR3CWtQ+Z+QQJnYiPQJiXx8kdpUJIpVyNQn5vvWzgGRiSN4mXX3qG8SylISeJg11dT0WgaQvsJGuSv3nhEJ4OFcT\/cuhgau1G0xkMOAzscX2sufBWxB73615TwmGqygMP7ItU472Xor+\/rVBBRQeQGVNSHgnA5Y7e++kyfvplfw2fqBlbLkd0LCstDmBBog+XmmmNSQT0U5ehD4p\/wc\/cXsqbXOqUUku869jIXc3sajz2u2fvbKoY5K85wzzjhuIJc7PRcH5xDTRXzzcubtLlDtMGhVsfAAJrWVgLHHxl4V1JEMWP2CFtsf\/2rXfTvk99qQ+N7EQ6V9qOepyAHINg3lNefOnbv6V7t2PZUNrTjU97U+H3N51Jpgld9jNfRRGCX4w27bQ4N4hgI\/NwBLKxqgMDjeP9viZofeuupVb1zqt2JhHtsGPgnuSN576bahrKr+SoIAMBbc8ce3AIqzqAvmYiE9H8F8OeDT7qZNP8bS6emR9UDENuufI5qpnqkcw9tbAM793d\/FCntncsVVj5ad7CtXVk\/IyG9a7QUvmCDPXntB8Eb23rsVt8FqTI193FcWDpSVkWMb5Uk+yueisNizZdeux4z3ipgwyidDHiGgtsIkY59YZiS5aem8BYtZNcRGl4vO7OU0WjGyhbvNZJBdWdxJi9sWnM44loVhHMynnGez0JRV3gJBwMqsWqXhZcAqKFufnHtYOTQDo3g9W85dsvHBbdu1DlOHb6ZnydZ2NC57QGamz0tKSeH2s89Y8HFmXj1WigqUCxvnTkCI46aQ+X\/PwD8b9DoBSYw3SpUnAhl1M7GgSJnIf5yFirJ+DlhYQ6yr2T2vZz2pdhvdbuxAxK0S56IU4ZdILsS3dAfLT7WqEs44VtVRrZebV8taVTsbsHKnUiecih+q2ZaEGSB6AZVPEasKtZJYJgwQRYCx8Aq2rmB3z+ddqf8a9iV8WpaVu24lbZbqFZ0YRw+kqeYPUdqyswDCZaDXHyIuT5hk1KwqAj1XjMKYbeHy3\/21trZLIehp\/E\/iDUyoNsgOYpCJ9utk5yMw48MMLPAwTwKVQQlarvSBHnCtO+KaikXsA4BUnsqd3q4EKvFB6ywVbGCoXFdJvAaf1Yd\/9eCupy7G4u0ArOpdBkaGj5SWKW63MHlNFAWPYWCQPuhq7laorUMgMrGCdKJjwkJpNVGuVLTkeUyVSB1IOSgKsUB02IM4v59e\/D4Im+YL74DXk2CG7hzdTcIh1lVwuWvGT9WL78rLNKWG8DJ8mSPWzbTX+AnSGVaJj5LxakL6rl6XeKgSLyF8fQzeDXCie2A0fUqj9M7WfMH7znp7mJYQ\/C0O9o8pNQ9W16EoK6sloBoiy++QfVkwmmJPmyg8BqPimPLDmk68JaNsFYulBX0lDcgVG\/q8UI4xbtEJjSCVMCUV7GHikImqKsbDk3E445vS1YdERS4VeELWFaHACqDy93G8b4+D5G+3dnV+Rq\/Jr7e+wumve\/UNkCVCrAyC6dAx38c\/LlaNSJoYoYzLDVAqlahIy0EJZXwq3zzg5FDPD3h9XJeW4TgsdaOOWnb6+CwWKzd4JLil8rE9GEYELArf3s8+nmpHs66y1QxO6PtflNhFjCLPsmFMsuLKwEvNRBWgf5K9V8tRciJLyvf+CbikVgLJXB6gwvLtZ7mYnp7v885Hkqsv+79KTGBlDva6NAOHlOGQnEmDpbqyYki\/XoKpNAYwaFowErpzwf6xxutprKBUoGWVgAT30IFMKV+ELA6+EpBhbGHNKiZMGEw2fqxcAIw9vP1FFmP41Naurp36VD4rLYWi84kNQmFrHlIGVeVvzOTAjzTimOktAYP9yqEqfpbfnqAT9eoqxANN+8Om0jO+VtEdkScfhfkuNbnzhPNOPnl6BWBxywcVMZLuM2ocTR8cjoOlBwVKX3ToR4Uq4iVwVdOQ9QzefHMzzZPLXAH\/UH+f+S+IS9EqkcEwttgHvxt6JgoFevqVU11HpUMzBF9ZoZCzJqIsr97S3WTp791JJ3yG6UCGpOmSMXVUlMEyhQwtjlaZY6OcG7p30P2h2RrDFTqYRlZVnIikb+tR0nxZpMS1ka64VhGqimrwffE9DRQAbaxAq+HnjTLDP4YyJMkDyMA34codWkhOr\/NcIAYJNiYrjaHmg9HCjx0rSCtHTO6UwTFmsvz5qCfkP+WFCXj1aQgrVDL+C5PjwXJJoxw15eoeUltYCoVZhWfj7tJj6aWIRl5pANhQFq0Xn5zaP23aaRWA5RPwRPF6mbNZhqsjoNa3ZOZY1Uf6pGyc4UfHqplt1lXWMxjksK7oJZJ1pfgEHuVCHEKtSrTqNIZ8OfRCPhIyQTJaNFBHXauJONCvGek\/h54vQ8Xa5PLLntKn1gRknFY2j3FodDVdGf9UpmQ9QwG7VxFrPfJs0Y0nIuy7gsY7CaMo8GYktIK08Zzyvf\/Px9mJd3IDUntI5F508buRi7+WzQtUKukI+Pr6qw4m3+SYnwkrg4OTrOlOBZ2IkECMAFfL5wx2qynMSXmh3urFbQvvI\/LfSiNM2eRdbaR+Wi525xpghXGUZ8+OGSz6TnnG3EOAWE9Z7d5ilBzHeBXDkJooq\/rjYIYJcMR6zqnbQZ9aV3NcYmJdOcC3kYOqyeCOO2gPB3\/pjsMPrgnEGhxoCnGwpTFyTGN8gkvMHOjMqWYRvj4GR1BrJPeT7k\/BjB+4pvBH2XIyB45+H2NKo74eJTPIafEYdYLiN07L1D4ZlW+jRlrFQ2CnWWmy0N3MYjxNgjRqSGtQWCS+qdBqQyzkV3YBbe2gG\/2iQkh2w\/f7if2eXBj\/rD+fu2fbtu0890G+KtZlElDV0bLNYueYJMiz1KxCmLmoeGOiTy0trz+xDb5ME9R92DJ8iGxF0fg4lSUdq82aGEJeDBNKYAKdBIYdrn3476u9u66SBtYaU+lrDBzlAZe4SNjBmiPdt7liqfRmSzQu0EMRu8+VotIMXhngBTll1f09HXx7GJKfSQkYMYPVEjjCexavBgdubFvw7WKx2M2NZzMTnW8Cds9Q1\/XGiu+HpYVvvG2mF3sjnIzBve7JJ+8j55hYQ4SmIqoaT2WNeuNZNHUjjk9yfASrtgtr6n6c+dszkFJKZaDSKqd1DpkA5AZy\/XFh4CvFqLQI4nqwsiSg+pvQIMUfiAdmUVY\/LxQLtH2dm7NpU9aTYWnzTrl3iE66\/2CUxePgPE5wdVBoFdzMGBwLqaQoR3oYIDvxU4ypeyKKw8dmlvY\/uuHhh4fMU5Nctbv2gIGUEwVUZdlELL4zEJXgv8tomPAyOIBrRgvzIafD2B9WPCvTWHGPsppjZZWP3eOlXPB5aNfGpvvgmZYoFiZM48PHg1z8hL7LFuGrjGMs58Spzg9vRrnoTsDwMzBIDvZ+4ZDFpZcEXGz+oRfHEv+UejdYwTLCrOQ5GYi2Zuopp+Tc7t0RTvUhCjwZ6DsSNAwK6sSnfrEG5ba3S8GQfY1faISpyIGjGrCOVIFIEZ2WtXnqqdCddVbi7rwzZlApenIU1w7jZDasCrF2fE06zjiGfNY+uHTxzJkzk9QCEEgdvTXzEAYc3RdlwJLgjJRVyvqw1Uim7CM3XSR3VQuexXXddYfXBGdpZrW+xkLnSHyv9f4heFlr9If6fkxldajIpurzI1wGB7JtTGUC7YcdE0ZLU5kpA9aBOWtcNzjQ4ECDA5ONAyMi6GQjtEFPgwMNDjQ40ACshgw0ONDgwJThQAOwpkxRNQhtcKDBgQZgNWSgwYEGB6YMBxqANWWKqkFogwMNDjQAqyEDDQ40ODBlONAArClTVA1CGxxocKABWA0ZaHCgwYEpw4EGYE2ZomoQ2uBAgwMNwGrIQIMDDQ5MGQ40AGvKFFWD0AYHGhxoAFZDBhocaHBgynCgAVhTpqgahDY40OBAA7AaMtDgQIMDU4YDDcCaMkXVILTBgQYH\/ELyDT40OHAYOWCL2mkdxuuv94srbtoUuKVLBxdmnESLIB5GtjSSqoID5QX8DrXSXxVxHfjKoADyZBKtwHkgnYf7Wko6ppUfDzeB9U6PDAcpOHmLXluawYPR0rE18LV905Ilidu8OZkMS0wb0I68Gu5o2Rnp2RAeHC4dSfMxEk11uT9ReSkDVl2oHCaSlDlhOwU9xy1P1rl1KiQrqInK1DBkNG4dZg5YufvlqUM3AkDZO5\/5TLOL4wL72bP1bFRMrr66vAVXJckGYGyOK\/A62jbxgA8hOyCbtZnuejQlK7RU1wPlRRukdng9N32vl65POGBVCl3lOZnL9jq09eLrlaHKNBrnh58DJrQCKu28XbGNWbBmzTTXFy1ml9xlVFdno56ncTwBmZ7O7msFjhJs7Xa7jw2\/HsO22sVztmfL3ev27r6\/EqRsm7SjELiy0hKAcS4AOyo2z5BMAGJhPcDYAGvZ\/PnnxXFwLQxiW\/dA26aP1xkvobMmD8c+BG4fq8Zrj75H2cxyVxTGO4Kmph1bt27dx71yWAF41SMz5QgrTsSsDAwXz5\/\/qiAJ\/4TrIpvY0SxJxpvPihSqP4UUNYWOY4+Kr2zesf3z+pJ72gPysG3yUT21Y38zs4IyoAKkCm4gfhky8DvE9hvIw5kc57gmtpjTxpwwYtgg7Iq0EW2RzU2TR3lvE+\/dCZB9O7n6sl9k3xhwLV9uW9dm9+p91Ear69evLy2eN68tSHJ\/AT1tUPcM5VYP\/28vOM1mr8FuZLEzDpNNM48\/fvOGDRuKygdpiEG2R6iuawmKK9ODpW0LX81us+8ivgESEP9GKIjqUyQC9hF0z6LnT7AFC5vXul0ll+8674H7d61lP8MspixPXI8LjD3Tk\/AUNqB8g7YJJ1NZ3OM8Ku9pHJxqf1GLk22Ic0nwZNJffGBJ28JfcvfOMB\/8973btz+YZUjAlfK1ngo8SFAcnsOuski46NOfHh2+oBTZl116+DinBljtfoureub38GUoTcmE8LrrclhBtnty8IkvTHet3W+m4N8Kn1\/kmpqnO+1ALVwWEJWEQ5yz46l+0EyxRqfUI1YogQFaoZB3udxpPD\/NlYq\/DePeH6y6bT0q\/Pnk8su\/WQbGdew\/WWHNpWTV5bBnzx6QFTvPFY6LXfTGQr4wq0QeyDN3PdnjSyj93nROUbGdbBI83v3E05uXzF347SSMUItkJ08i0lJrZFwKznfloHIiTnYuTc4r5PJvigVVNeWhHHX5ZDDGpDt0pcc3zp3fuXjegp8HcbI+nDntLpLfz8sGYOPJlwEWhJewqdiVPikQYQQrrZDKVIzrhJJI8cAOQVDgxklI50nUuC8gzfdEJbd98byFP+Dev27p2taRAdd4MlIViYkbiFAU8qi\/GHqG5jOlt6q4xvGSeMs2tzkK1XZEHkcUk+4Ts6quu86VwWr1bW91LclVaPSFrqU1tZQEUAMSUm0jL7kQp9OjFYHnvP3CHQGZtCnCIPW2Rghwha65ZQ47aa9wvX3\/K7jl1m+DIp8EuO4UWE20tVUKSmxJHTwbxfEspKefrYibIVT6WUOo0BEsBq7QjeAk5ORi4OtSKvbPNgfRzVw\/zUOFmqxx4vH0ogdxDIt1afdIuTJkV3o7O698XnmecaDiPTsNQ+00PY8I5sGvVyZBfE3c3bsR8PomKa+9r6trK0kLjBWqzldVZm1KU0ZaJbkjnUOzkMEeG5eoQ+1oO5KbJUXxB24hbyyEeW9byhb11Furtu7cvj7NSP2tLcw6owm60BY0gu3NpR5ZGDzL7tT1SMFIaVVbVqTUUdc0DmdkAgmAyteWN9++BJZ+hEJ9o2sFqIogTW9vDKP1PCTHOc4zv6XPv5VGBSsy4jNAk4SY9CM9MWZNf4mXaYo1FZpcLv8619f78mDVrWvcQN\/fJO9\/\/5O8GghAK\/1dWZT1Pw6lmyvdGHpz9ESlI+JA9o1BBxkVcoW5MJjPg4\/0J7nXLG478wM8vEvxj0W5R0oerpou+uTNyjUul9\/PKNKNyvPyC8OcDL7Hmdd23cryE4ThNBJ5IfdeGMTBpUvmLViLQ+ZW8nW\/XlsRrMAttO6QVuSghWHbfxohVu4q+8G\/qsnOclImn0hC\/UFTHuHLI4E5iBRhJVl2QnkyM50ieiN8\/OaStgWrlrS1ncJzDD6sIG8OZ\/HWdvS1O9kSIxPoInZSlxB4GmuL\/rn0NcCQz5phWDtvQ0a\/46a1vhFLCPuxN6LZVzL20gqG2dakkfTCo9TKguX5fAj48Nfk\/wqc57GkTPaMm3rXNxsF9PIbBVwPDJRII3GFphlYXR9whZb\/DFatejFCZz2IZm1NTGEgJhYkOpwM6ojJETRyd5Q\/XB7++aDe+Ugq9IMcJs50A\/l3uTC8EN5+Df\/ra9O0BVoZHemtsR2kchYBvxylB\/6vdj1QvMqLylvGEPoO9dJldB3rVHpPaz94XhiE76Ox+4PFbQs\/KD\/h2mStVWyHylsl44bJtbIGBeMJoJCAANYQgwDC2uCyamiKkSnEVX8CJWUmjqOEZFrDMHcF+fzukrkLXmnfkVn5toYhrn63xEXIHE82x\/IN+W6ioChCOjfKob18NlVOgo6OfLkJuOrW68nPF1xr82lYVKiaHFRW7nngQ8rnQQr2GjhNaw3NApNYRKU+LLEnAKBHXFF\/xac0tAEgc7wT8AeAAWqSQuQkjQvZCaUMNGz6S66fURDTpr0Qkfo6wPmH4mG5iXhYGJrpiOQnd4i\/0D\/P5YIcNhRgZEE6kumH4Zd0QwoPN6MoLuXDcA716x2L5i78DURVxoB0y\/Sq1iwqsnIYrx6g6xDkaSrrO1qNrhM\/QoD+kifpPUmAW95QwYo8jQ8\/8ejOB\/7tnDPOXKBnooUoRsQlMWaEQFJ86SNJNKxiAFaNGNGQSALXBHGtfDsNBc0Ju3guOxG5sz+Ez7CQFIw4MoJgxyBxkFA+4TIA7KuL5y58\/5Zd2\/9evq2LqV3XY5UNSacuF2k+XdKHSjyBGIjEugjDgeTBzVKxVDyRApTT3cIc1zFEZrL7k\/Wonr\/kkkuKsrDc7JM+7Zqbr8DfhFXVV6R4TTCtelJ5Cq5U2TSl7p6B\/icApg0o30+pv7bw95BLCk\/xVtEgvFhscVF4gosH5uJkP4f7LyKuX3et01ppEoYAm9iCUFvvripD5BEh7+lB2lpOwLf1OUBrdnLV5TdnoJVZgRPBTymkFBWB6UYz\/wVaHkB+pwU4bEZID9EyHToGOcOf607nej4ZOVHIRc0t4cMnrncQwbRCN9DKhXMiF33y3Llzf4d3nkJvVImbgo+Q1hhvS+oFnKYHe6HPGj+HjITKl2LG9+1a+LwFfkC39B1OcFMZFp\/4ITsCNWRE9wRcPFAe82HuteTt7CXz57+H+\/9NPCJlWL\/W8ICl5HB5EjuRJ4\/D\/reHuXgjN47JFcN4gLgOzIhMBo3403EgLBaSUjAzyCfHQ+upcRIsgrZfg+TnE+cc\/igcZQZhoxb2GcmASxmJZW1N5501i9sWzNyys\/OT6wGri+sOWmKnr65I6+fU2++CngE6e5uKZFjP6hpILZcv5aK+HF3ZPmQdDdn1ZD6aZSWwWrEu5y468SbX0ny5G8BXFWMV0UCTjkkYOUqRcoCZd7r39W5AAr\/Ii99xhcL9Arxq8hl8gd7GZ3vOlZOd6u7NNP\/mYoGpm1VlI2FXBSqQTHgH0GtmGEX\/TYCWK4PWBPq0kFu5LKRYz9LF94ktnZ3yx1QdFi1aNDPp7z+VLFwYJPEfwLhXGXDRdCJLWJZeccldjFmCWRW+sBQUriKBv+ZPaQsUDtLFqgmofDEISqRdwFD4OcOPrgaBHiuFwbFJVDiorDJdbwJbB3Ilyj1oLsTBTAplDlbHGRTMEorn+dB9DlZkC9fikel7CsYi3YCLd0qYkSG992dFcbSWltXbePf7ekHhwPwND1hkBFZ5jzTDEUpRfut9u+57jNv6G1e44IILCs8+8cRCXFmvQK7fCkpdCINy6q0gKxGpWbMPGgWSsiWLnDOg0N2ApbVPltZ6QEvPeVzHmkXZsQph\/8bt27ePK3PPgY\/MZ5UOW3C\/ueejrrl1EKzkpxJYyYhG8\/BjMQqAouvr20JZ3kDxrkuuuvrZA9kkB7nd01xCBc0nZB4hGmhKmLz97d3cvUt\/+KhWu77+9xD\/FTQVZ+HD0hdUeAZY+r7g+jHBmpubAK0bAK29gBZWj5UuhPk4dV33IFwpBgwuI60RLIPh0kzHI27l2Va++8KStvl\/BPc+jl7MRi\/KoMVzuU40loKRD8lbl82b9\/dcP6q0eFYfwCIeK4Qk2H\/ezh0b04r00eHorubemWeeeUxuIDkHTf49DJYV1okA\/coXSZENo12Fo6YvXSoxgJk7KQ6iL9D0fRP5+5F0nT9siUFQHhGwMquhvsEAAEAASURBVKKIGj\/CwExdC3TuvvtuX7uZHAxhlvJ7IPOUlt1LB8PRDHBbzjv5vM8UW\/a9hTbDn4LAi3glB1UaTgFY8QuVxFQAyIpYY4B3fCPI27V5V+f3lQaPD0Je7tcQIJGmqPInOuUE7OjoUD4nIohPQwphIhKpZ5wClrLP6ubV7wGQPmzjqeRvCgAKH1SFxq65KWdWV6n\/FjwWf5NceUVZ6A2gNL1GQfMDK8DJR2FCZT19Gimfvadev+TKK3dx\/ZfBLbd\/FV\/Z\/49193IsrRzN0Qy0pAdN+LSKAFqBd24MVt3exbd3CWxJawLcCRnVSGxolatra2trQjzVdvX0l18ZPGHUtwUGSytIP6QmqoQ\/Q6fT42jMF7GmZtLS8KCFOqDgekfHs6MgvJh3sVilKXXTBU8vo2O3nnHGMcT9FKDTTB0uC0vPKnU7y1vlPdFXvt62bZsqqB\/p77zTzlxVzCeXEcWVeO6OS5u+6Lu3ssiCWWBgWYm67mQXxWtoHr6G6HZdrI4WRu7xZ+GQgKW3QHxT3vmA1d1VKpsYqW9FjA4qJI1mJ8T3PHqPas476A38FhFfy+PLZG1hVkEYvYke68WiAvZXkUxMK8XRDWeffrYy8bAAhe\/LmeC8HiFJwdgJrERnPSI9KuI45RRZv3Fw8630WNEcUVOvt3eAc7MqKD+BVeRaWvJYVU9x\/\/1YN59T3k0O1q4Nq50DiMQbkGV8Q4iCrNdP\/qjkqks34Ed7resb+Ft6FK+hGy2nRgVfqWmokIe2yE2fNsd193wyuPXW1wBaT9kQjAkaXEqaSRRqRKxzs2fPjrq6usYkO9KRZcuWFTZu3DiweWcnPeULP05j9yMotPlxyBY+GPnt5NjHuRQnLyWpLyKjNo5J6dYzdOfzRv+xxx5blR5YGUNAqusixZcEfJEe3fPQtoe495dnL1jwNRw+f4e19XISsJbSAaCVRIy9C3O5JdhhH+ObN6\/3rSrjgyL2JrnORgmkbsipGkEUjPJq+ZHeS4MyrWG72TAFjCYz9YLNO3fu3tzVeTkRXgZY7acwAKJAoFWOhwTztHEjHHPnhvnoQ3qgqRIXBwZag+\/V56wi4fpEONVjKTvZV6+egRhe62bMPAlAUK3rwUocE1i1tgJW\/TjR3YrkyhSsZNkwr9CABitpPLwg+sS+TweHGvBccklPctVl78NZ8Vc8BaJogspv5ksPHSClXpqMLc0XcvfPla7i4HamSOMhZcK+QT9igVVaEePndJ\/l1i70xKcpywra9Z7dCIIlAFxaWdQ3T2IhxoPnZJU5TvVcBwM4jtJ1AbhaQ2rWmbvnvs7On++P+mkiJp9WzgACBlHbe7xJBu09pq+p1ejcisXzF16iEwWeGTOqAiz\/SX1+00wpM0EGOlu6tt+OmfhOKH1mELSy9Dyh1CoqmcuWzl3wCj3pcB3mdMzeahzrzwEpibv0Um\/JJsEfMyzh1dYjJ2e3iQ9p4uM0y6q3dw\/TM9+RXH3590WJmmFqRqo5Vy\/KBDpuxfLY5igSKWl9lKER1yLNJJjN\/bHUaCom6ggQfe\/B\/\/Wbdvf6601x7HwS\/mDZG1BouhqE\/1TIq5xxE+E3PbDnXJ6ae7r\/xDQLWUnULUfmPqtDbOi6goGXwEjDkx588MHezV3b3wcG\/5UycyBocQt\/ncPfT95j92fLFiw4gzgkQ4ZVhx2wMj6IiPXJoKW0ddeOLwdxeDXoSyekLC2afGlRQLrMxxL+ribmR1yjtrW+b29vn9QCmOV1yh6vv15TtZLgllvmoTKXmSM9juWf8XxHsFwe73o\/PXRheA1+ph8or2YFTZDPCGFObFiFJlYTkquu+GtA6zZrplp3usGUgCqP853O9tZjaU1dY+9Ck\/nRdDHJA\/ncLpwiI9ICAyr0wI6g13H9TdHxykLmD9N5vcJYLaxq0kWMIlposfzEen\/zzu0fJVcfFw4LzChWX7GRW87laVfzdyF3L0\/jNwPliAFWlslK0Nq8a9sXoPMT9syPQaFnxL9JJkJ17eJ0fG2hGL9Cd6mRJqQN71N8bv9KsbGOBE7oTG4FVtSy1LryTnY\/zkqTk\/XGx5MrLpUTGMuKQaUT5ytSEhYqQQsZ+XPX23MXNEpaEHwptil6yToHXPJqeg1fnX56xGU+pWO4gwGSPQhYZkchlX8758e\/kDRRuc\/I7qHwB7yVPZlcR1V+6tTKQOukeaf\/OdbcN2wwtZGq6khZNme8WfZc\/kE6qDQBnLXGx5EPAq0sE0lL\/u\/IVwcoL8LJgC8iSkQjnulFEMnBW0S1GNCwsias\/GTlOqyr5\/H7JgOmZEjvV+SmTWfwXd8PXV\/uU\/buunVNycp234ScMLIqIr7kErOYmAD9FNLxF\/it+nEA2bCYVLXz9CQmNvDUJW\/Xl2qmTgkrK7HBsRWZHTyVVoSBd\/IP3p06Z3Ru4YNmIDi+aJZ7+jDjxR9D3+U4o7IxxOLXW1l4H+aWwujNyp067SYFYIkYIa8ciRqbAlDdiJ+915qGjHDJapksE+DYq5bNPZPBaYxUS9v9Om+E+nAgrbFT4Mm1Y6xcQO8fkccGYqo4HOusuJ5uObpvSj54yRPms1q+3Ftk9SHjkLEg2qrNTIaTK65Yz+UdttaW\/1LPGB5Dz7NVekF7cONqBi9bmDRyn9KTHSospZAmH5fKRUXwLwQ9FM4z2W1V3Nn5VDiK3o40Z5t2bdsE8TcqX8idVjKxpiHXvhdRTUYX\/t4Fp546jc\/wCE2isGnTJjnj3aaubV+DzG+LVIhMa0xd0b2L8x0T8qQ4jC\/Su+p9JKOTKh+ia0oHv7aV79QI3CuZq8cQzXSOoDKmUXLNLTr7lpvR+h86caec4nXJLg7fj1lMrBphKeaC22m2PmlzFhGclAoWTqJTM58\/Ba\/Wq+ye1omfnMHoUoUBixeLRDUxYKw4rvOUx8njzXFsg7hldUzOrIxOFcVTniNMD8ln6XS7T452Cyo7AZUGjVr2knN78y0v1rNJpejKRLlpGCTrNJBMpiLlVenLEkCp0nw5RxNUmoX1zseUFAJf2nX59fxctWoBsb3E5gqqee7lKaJ5WHDdDKULwi8n73hHn1lXVU63qQt1B0ayebNRRtPwV5D5VescsHfky6KDgGHUgBj0Bi\/jRRtmMdmahchycP7555s8Lz59wVLIfFGKueSBwaE4pTN558amX+3alU3vmrKyCtha2NjV9Sjl8iVdcFTT0PJE\/m1AKXORpzM+ol3P663oirOmMPPuu43YIIk6GNzLnA2JWLkW4YLcCICZl8iytadZYh0ddqjxJ8iAr921a+wIgF\/3P6O\/Rjon\/vMlS8zSZZUQFMcttEnHGsqgwBxTb10lv3JJ6U67d6TliDW5KCvP29h91fUwBkvOTi8okh8\/RitJlrpVq86cSJpnzpw5JgAR3Rres3TpUptlYbSFyfvpIZudApZpMfKuVU40RYLr4Pt6j08nnf4a\/dX\/CITTPMTfwkDp4dp\/rWwKvGgGCgOwLV+gd71PovoEJvzNjnQGugaVsjrhL9CQ8xA8pumIZuXG5iiIjrlBFCzkuEvfkJlap+skGuGuiBnjpbEjYxI8fXc0BFkeNLNSwIqW4bDO2dpTmFMya5EdrACxJrgrnS7jmEbj3z9CDDDZuO46yTK9gnkmWkebXaF5iYvZiScL8lEHwSmIj3yf99e5CctsfoZ7Evbdf38TA0Ddvn24Yg8RNHMEMRPvUn8hrGxb+GfQ+S4Bk1lVxndxnDlyKoI42VzM0xRPw1SWU9HO2CwDrIF8fkuhFN+LGr\/I5Ew\/ptRUNvK1sx\/A2XPnzp10gKVMQGc6bN\/do4LjWiWmZmFeDRNJoQaY8qpqyx+k3yjjgwKaFmh1B8PBEvEYYCm+6r4b31tWDhOcxvgos6\/ER9Xm1A\/hQt87iFJpXJMsFeZNeAd88j96e4KnvBhBY\/lJ3nfJ7uCW1Rug2zplTCJkHQqwcrkWpvGcZfHNmmVlPZa4R3yXIR5xGGm6mdvw8MOsdTP2sOz0hQtZh+IaRP0qIR1yrzLwA3Tp5EBm8hJKgOuO7ds7H5cM2eXYk5qUX2juIcul\/xJlfxEEmo4rg8icKSPnJ4ZJbv6kAyzRSFteSqO1sTYz7mofZYOdPQgiBizqBk2CeXpfgTEalj9\/VfWvviFiw6czYNgfE2kJOzWPONQNtAIttejCVkzE7afsOv3\/Qr8E0Mzdqik9XC9mzvM1azQB9nSfrMmPTmOc10xu7mehvWSbPdu8WX4XWQlHNgx1pN\/L\/H\/oofbG7qYkNQGPtY+aWLo5OkOEZlN1KOTayxlAxMKarnhPP\/301oUPLSy6dl0NDWZ17d5dwJpo7o2apjfl2UEodGcyi+NlDJV+PQvHna6JwYCVnxiMdCIrlhGmpoG50Q\/2RwO3prEOTtUZmsyUusKPVeY\/un6vtFFgbDpucJXqdeBmUJBtkxKwMj8AOdkF5XuRO1aLKOdLBWLdJWTq1Kx09rS3jwOw7BMWREGYg2AZ0v1Zjt5ZMyS5LJXxHVncy++WU4q+\/eRJW35GLKXUwVq\/Wn58pB381e7dno+l0jFw+YRsALJkR9rjLS73hCsEjxz88RG8w3Zf5dSDsJOlZlSmqp8FV0Y8ckThJnPK711\/faAVI8rXYzxBgVhlRJIZHAsifmzJvIVPzMw3Nz8294HYdSlNE1rPTztHEZtYSjVJZhTyyWy+PwklPV6rQotM1oOyPECuOd91kyzgjcNAjKMHqKI\/+ODOB3t1j0dHvpIYI79GeF15FECh08kOwNsQK3sXHhn\/VIQYEqdOSsDKxlYl\/YW9rhDthfg2SYWJQJoTk7IgOEE1muYnZRkc3xGeSPDKhsT4YhnpKwkXxcAE3aTINl\/jVpCR4q\/r\/VNO8fTFMRZDfgbVvWGVMUgFAAZweJrq3o\/Ezt6vKxHjiAy6guuuk\/9NC6w9jjHYxyBSmoDKgDWt1KzV8kUz69WMJUUDRPSthZay1nmrKhiD+UEZDag0uV8f8j0tCzFYQU81QJSdS6JoNx6sSzbu2HYPl9Zk9+8cNb\/KM8AV7mYrtWcxHI71ubf8GT+MK3FwwqQELMxECz1hTze7DNgAOTIADHva7SGlCSxPb2lp0VSRXjzlNYZUgmqMZZjPkTHtlqOF+ScIEYdJtA63WJSP9aVAWv5MNyVTabzdWFo1VhJ1oLAiCquhV6yTMmvIYR+NVzb2DGywWMVrQoUW99RTrI\/jesprbg15YawXBlpqrqkZB7OqC5Ln9E3pYgVQ6S654UdDenBl3Y9Z+JbNXdt+cbFfG+qo6hCycksd76zTsC\/IBc9SRsz\/PJiP1A7TJyVgqcRE7osfemhg49wFWnlZgXIdmguMrhDvkC\/4dnunlh8it224aolj2G9TC0vifLSY8cPm84jfxJFpQYvfoOrp1WE4AFUa74V8kqiadYdKWyCl\/\/ahEXjAF\/ace4qPBuMsvbM+9X1WEb9FOeV+mlievMQC5WR+uKBq09dIwz2dBPc2L12qZlQGqpTdgTlhZJlNQYLYjnEQXI5OUVvA2S6He93\/2A3IEmspqiKeGkHLs7BIH+Ri23qS0yM+GEyK1kmXDa1iqpDTFCKt+JGRDd2yEk1+kl43a5avBLP3a80IMZOA2p426wL5sTWgRjlmeqfhDAN8zBGALUuGqSzDvOMIR\/wiBpF9l2XCLxGZVH4VY5dqJXxyfU\/TWKA\/8mJcMDhj3OSi3EsWq932tyBn1vti5rYv0FQKpUeu59geTasitNvv+H+QF2RB8lD3P4hixyHIDtzApPdhZU73MFQ3\/X7mQUkbCWI+J2a4BMdyoV5E57L37eLI\/UBdhQM9PxtK8L9h7JgNI94jLZ72Z+u9mkQGIix+ymKaJHiIP73DArvypucZW6UllTVkQb638nislHDWQNeySjkA0K1iQ5Y3ZBzmG68N2Y2pfTQJo7RaqFZM34fLDhnuy6yX4Z4fsXvtKi2FXncM9eRxdo642TH9seJKgifvfuQR70vpqHxa5bkJMM4EzB9waiNJfAqbjc0vYtaRH3GrpiojH\/IaHZFRKzFum\/nIWTZBmBnrk7N5mDnRBwb2uXyzemjTjEjp+Wf+YfW05VnFwWkDhckR6PEzh7uoiaP5bPuFeGNISZLUUpOfRADm3KP6sVBDD2EWhSwrsMPsZ9wTd9Ei+G8kqgiI0TrILNPsbSNHg\/3wocWzkWH1cs9DDOezDLh6\/mSnydqSv1PIpwqCnsi4SEuiwOiYjy9qa\/sF73WRJu9MfRdDJfCGSZ6mb3zQiABxzyt\/sHdSAta+8883wGpuip7HCs8nZOSK8DTYc5zuD1N4Q4Ase6HKo30rPWTs385NOzv\/scrvanpNhQTZpj01RTQRH+\/e7fn5zDPPutknPuiTyJpTWOSaA53LH4dmadDufx3pUe4VLBCyep6GwXlaZ9gF\/ZqSI8VmJx8el3BuJeFOfVOfnkLfzqQ4wRW2Lm7OXXnfffc9ofirCfPmzWvBV3A6AxReCNi9ljhexxCGVu1zZ\/Uz\/UyAlmSFTRWUhWB+FOc\/QNxXc68eszuqIXOi3ynrAqM3TgPsW8sKjZbT0SbhE3918cikBKxsHBZFdDaKcYI17vVjMAXdVPvKADnZnnGT6TQ1AICY4Zq1kikjbvu1zM2cOWyxVsegQYPa5EKCxl+5TOqYRL2isnzLWmHE+DazqKw2Nz8QE+sxsaYxXaen59eVoA3AZLWEejezxpuZ4NP\/cBIQdaEfOEosXmb81mP9\/TRzg\/st7qeeEsDVZOVSiDGWD5unxN24Um\/YfN\/2J7QMML3cKmfgRibSwSEr\/66uLq3Zsy39+2em5fw+VtTfaicpAIzoTcgVDcMxXAl5x7+aLF8698zbtCwL39Wch4OpO+x3yjwCp5fSUEblo0H9EHKLjcwzxLvVOekAS6VDgVpbnuMFFJ7fdFVDUpA+laJOkAhWZgu3iL18ooIbzOT4eJ6kWxo5lrkpT9MZX1RT9ysDqjIABZtYFE+j2xm5yM40ftdeKbmslguDG29rS9532U52xDmizRPEOWCzi4hBoKjwwAupz5bZhO2KSo4pRSqUh5nkYjKD761WeSFRX\/uzDu7TbJsjn5\/7xcKF+YRKT3Ks6+FC+kzPtUJD2NfXF\/gdc7b\/O3sOdtHxvQ43xUJAy1taSLhVz1CM90t7972ebwVYao5KX2rOy3B0Ho57y9NE\/CotNi3HdNzKVM8EV1zA40cBsm1S9EkV2lkpQQSdferZjLJmaRNR6+dSaTiwHqnm0r3tSdRvtaVWWZjKhaZMTargAQgpCTehIdttaRYtiawg0OpXJ1twLjtHXmT3JE9HMrC5RLn8g+D3HTvbUyMDsAYaEpq0Yg42GsB6WutGM5CRD0J2QCZoaywdRc8hglnbWrhSYCWFhdwcS60wn44NGpB1rv1SK+QAibfh8JajIPxNe6aX7JFSnHqBPARYo8qD637qqUUg7wsB5jQj5FQM9P488p9s2bpzZ9ekA6x95\/tZ7mFT6bcopF\/zZVIuDMsN+eRGctfWBx6YXNNDymRO+ROvzE892onQ\/MRbJzRIvCxpUlvRTbfOnDcGn\/1sC1ZZKdvJ5ojkPJ1HGNx8+3mk\/3rbyNXcS0az1u+if1Z9HckPRV+6SUbdAEsRMzm0pvgEXJm1Uejd\/x8o6s\/Vm+iDRy\/Y79NIkrNwvp+RPsxeSi+n1EGGhuWJlVdeT2PqeDodfAbIlfIrUBMGYFn+WA8mFWBdTPdutkg9xvbbyUAeq5gmiDZXtQyo1rHt7Tn5blY02bIw2XXjWCMHaF6ly8wwZzv8rm0+kcvLSkkVBvnpx\/2SJK92+\/t+11KrQxNrPFQPcZ4H0Z\/gXzueFUZpQQxqOzv7QHn0MIbW9y2NdMG\/8aQ3kd9gbVi459FHu5H\/X8p4Qm\/LC9qpCWrqHAQodk49jBbI6lQGLccGycrLHyszALVGglt+yFYs0AbTngzCyMpuUgFW1jvYvffpP4T03\/HISvPdykMoG0S2JlDiNlKn\/bcyqM0nM5TWdSPUzgH4Kb3wzaiQIbkJG363aJaLNrnVgWclutymz+Cd5Gp2V55lVhabUNjzw\/STCbaRtHr1Szi+0xXNkrJb\/Eh2WBbH5P\/\/Jlddcq8eEDzw+vPJ+RskTxphw2FRwpSp0NH9P3UDYFSewJ3LRez8HuCzMzhGvgylwC4NGreyu2vjjh1aNGDyWFjqoZN1xSqibUDUhzSwDr2Rgph1xREtYiEv6Of+Oi3wx73GJhRiwsQEA6fkssseRoC+nI6\/EiB5qdJwgR6Wfmpuvojx3e8VCfQUDmi55IkhZ5hY16yxLcWCm29upvFwLdbVdNu23iwOE3RtlhHQcaDR5H4JXr\/B66QHLJgsE3aYTJs+a6trzYeckoHiCdpduxXQsrkLXopOX6MqEv3WNJDUiKKRyPA2eg5lV\/6rMqoe2ElhYWXDCcgHHYC5j9EUXEJLsAxQvlSCyHoM4\/hBIMwyoKVltQnFlCy1SU609Ramm5UiMWtZtG+zmz5NUsVgJgJOBS6YviOlSj7Evn+vs\/vyO7BqaXo+YQdrCmbryIf5P2Otq992vabjUgT+JD4MwLSWbHKn2\/v4NzL6Joyo2iMuIxStiZ7yRWW8xm6twJtMvqlRlXSOcC6w0nLQ2trvvIULT4xC90laTTMBJg9WsijNxPejQijFH7eW+v9N0clBP+GCNQLd5dsZWOnG4rb5nyQ\/y4WqlIuNIPaVjLTCRv8KhW\/d0tl5v95n7NWwZapnjVAHDuzebZUBmzvsILbbXBGji923Oc8qiQJNsKJrbZ0GRHw6uOX2CwR0PA+DFelONnUg48AozL+WbtYKUC5HKK71o9it8spkuuSamkOsKwA2WG1N1iliXSm\/SPwIK5ci8igJGjLlAAuyQ4GVekUZ6zijGLk1jLt6AWt90TuiCjBr\/5rrB1819wN3k1Zx5VuNHjg0YKk1eaDA1ONa1pH8TxqoqSOrfX6aWuUalRQpakVODZbzIQjYQDWHeRj9NB7I\/71upr6rTHHSFxuHenJgiJXVs++zrtj\/7dTKshrF0kpcAVCIAK026pjPBTff9nyBg1u7PA46OurePESwy1NwglW3\/R5AuZpmKcDJEHxbcwyq\/BCMAs1Baf6Xk6su\/2rKl0nfFEzpJFtxr+lCduOAI574DLAyLTngjfFdwt8JCdluWAKrs88++4R4f9\/ncai\/XsYJgTyANN644kbCnG+VdLB2c9d2a8rrHYWsNhqRSPADl5Kiqk+4GCeoiJdJqJ1ftQ31o10P\/CvEez+IJoDKqatiUKqBY25fUGAmN2scJX9138P3PcF1qG3q60NRORafWvmycSIO2JbwAE\/yoQ+xYF\/yEXZX2AM4acyRvNtZGcmS0Qj4JUjLvwY3rb6Y4kvYlrtE061Jomfv1uNnxYoKmU1+3c2YeQLjwnB0UEMrFcmNfppw8XR3b8K\/dr3uyLeWWn+6nPQB02IECytjeUD7fGKCjVetQ9ToaSDDQvou\/zR4Ey+dN+9Fuf7Sv+Nk\/30GogmFtI5YWnbWscbsAYyTONrJyPZrRYaMG32r84rC1+VgICoTMnBP3YwmBjzNjoMvHuJMRMtZlg6MC9fjSM+GLiydt+CdUZj8B7PR3whBEH8AWOnasRgvP+Torzbv2vG9NDk55MdMy2ikwqpKAKxr3KOlOyWe3XmnrwavvPIuJOCvbExTIc\/ifqk\/y+sQoNUjS+sslwvWYv1crrzJEQ8zE43TqodvK1m71oZceL7Fn3P7nt1ED6bkGAHiVy0CZI6mqy42J9dcfp9\/dwr0DIpi0a6jC3oPFELppL9nzZ4JsbC8feI5lk2R81fV\/Yr+i1OjRF\/IKJG+L1iw4FjtCISNBFjlXgooerDyTT0fObu8Y1nlaSLKgf2ncv0QXYjrp6ybI5rsMMzzJnH5XJG5l4S2trYmiCnNqQCuPeKta\/cJ6pfTbIujim2MlKAlumjRopmud+C3sajewb3fxcGuQclCH\/msBi2rFLxwtNNBFa3evLPzE7yfoa31YOm6xqBMkjdSdon67S2famcDsmUm1ZjGQZ+LZx3wkDBhaRyUaA03rGnoLZRScvUVtzPHcL5rav0QBVfgT054WVy+XuntLbmWZqyegdXBqlt\/E6\/DDclVl26QpSYSZOnYFlvatUbrUWnFBK+jenzIYBXVkiWm1NpmDGD8JAJyB3HgQrBamBHhVHRxJNl+abBqzYuSKy\/5KedCMCvfQyZy5F7wOucJ7aNW9n7cA+kh9wywzADrwKdjvzZuGtxTiEnYuq\/V5FJblqEZcTu8q9T5LIE96unj4TD6XtZPzVgJmkqvbU7cuyjml4I\/Wp9e8RN16vbx6RfBnIKowDj58Kad27+SpWNlnl6MCFiG5mJf4J5XyiWv5KwznayZxVP1Ecf6MbmB5BwW9bmIjsrfpva7EKBq0uYPtGGZE6hJnRU+K\/Y2Id2CwIqm4D\/3BfEHlZjMSzUlq074UC\/CQRCL0R80jRN3zpK2thfyyU\/Vzj7Up\/V6rlKrLJB6xVvveOSXkpVkwLN3z1+42SfNYgrMexhAWkACrbxIU6KXp4lWZLWEAlN63sKmpu0A3Jdg8b8kV1\/2M\/NvHUAcH6EnZV094OnQS3t3xYo4uP12T8v0ln9x+3vewpiw33I93d7KksxrZPu0aae43u7LiOGnRj\/pkEp1CQ1N9rBfIZl9MAUlduj60CAmo\/fWJJTsSIaGvjGOKybmEhXMCX4tnt6\/jBh+UrFl2ZiA\/ty5c2cVw6bzEOxXoOW\/DdNfwJJe1G1mVSlPLL\/N72DGBsgv4EiNEid\/s3nndjNOyFZ5rFaWo+EBi4j4lnV4Es1GxwRKrl06d373QFPuO819fYa+3AZvqAAKhUKx1AS29CVR1AwMlaazbvEs\/J+nQNE8GLCI1cmWQszZRHoC5qBMC1lNarvymCZfmXgeyCwMIB4K2WH8H6YX+67Z8vDDfWrH1hWsMg7g4NN0ACabstNu+OlFcxd+MGoK7iWfw\/Om\/N34TsS3YjQtHGgeKO3YsWMfvBiTMIwv1fp8Zf4sgdbKlUXGPl3tKHLX1HKZCyM5vUEIBjSq4CSQJZzgUSmkuXYy969xfQNvoUfvh2DJf\/H+zwG1zuT9739SL8ODQdHVjUMF\/7pZbMk73tGHo\/9\/u+6e83GyM8q95P1ZqvQi6EqC1wWrbn9xcuWld7nrO3JuZXv9KrxD0Tm+5+IgXueoh2kG8FTjrWCP55Dnrl5wQf0sLIs7oSnG+PkwnMPxhqXz5394IJe7J9\/bW8DQGLZ8pPuulJtRdPEslw+fh+NpIQQucWF+GQvMnY1OHec3f8UwieKSjCAC1jhvWZbMgmQweNBk\/qzYXQtY\/bXYlvqtDiqrUZQSOFGbGVQk4eehzHcUisn9cb5J40M0cUoue15xoFSJePIxI1ZDXGgtcZCbwdNjIK5FSyU6efwRMiMqYjCoIjaUNc6LPqLxzaO8II8mLO9ct3XXjo9KoScMrKwYDC2lM5Abvoil\/L4WluJO8imelqHUiKzDT5wwIC5fPK45Dn61eO7c9xPlbrMcaevXIfoJj6LshL\/66n6ad1e62XP2YDH\/FQvmNeHDUk8dTS\/qf3WcqFj7+rz11dJyEnLwRhbVeyON\/8ddoWUnAPYQHN6DbOzjfQ3uRCyqDJI8Fo2hzmMZZ6uxn+XL4znXEwXtn+ig63jGZ72H67sSwIoEpH3+DXttkv5Euf1Q2g83Zw5LLRuw1Jdyr+\/SURziL8FU+fd8Eu8ICs2aG2cafGB6vNrC9OxpPJwJThwL8LSgRKnWpPrOqirQr3JVKyrlvNgfqCy0hRkLE0ZPIwN\/unnnjjuUxmgtqVEAS596ZcaSYkkXlnLNBcuGZZ7IGRIMSyEOom24vQcpQIE84aeyIOIJWIGytLA8WC5WC1rGW7j+C7oz\/12vjUa8j6cevyQsWqywwtno2+xh81lrUuITaTBEQ73wM\/JJs9WSe\/bskX9lygTr\/VPPoYYvOHdtsPq2+wCFv6PH7jQb\/U4zn\/saliLgkl8iBrhkmWsgZ+iamk5EK06EGS9UgxyHDH\/jzL54qjhKeBY0TgyhtZhsYCtWVpzIv\/Z6ei5fkrz3ih+7jo6co\/fS3plkPxJA9MPoj3PsJJ0E3WSHBSx94IHJKWopdDkmu89R34yXg4PREK8pwVj0wKiVvosC6bsaDEzh8hqFvYJFlT6DQt7wfkQWIwQHzD\/9Q4Zo\/H8bd+34oQg5VOVdhaIYd9S+LUFMkT8dB\/8QTvmhhv6xVhXIClpjKolGq23p7TPHqHiCiOkZC5gEtG5Z25o7+0HaG10YvxqzcBCsDpfloWwSANiSzNcheazMby3nxMsCbb20hlV2TxXDAWsOslVZ7cIm4g9jMNC6vsMqn+SKy\/4ZMWQi9P4vWV08bZrMfmSLikpgJck0K4hfNRVldWktfq21pUnURfBNK5mO508gJRsgLT9TjowPGpeVWVm54E9029N9fRVyn0Vy2I8eAgaa9yMUz9iFkWAiklqHquKDEy449dSahzYMxi\/mGBsH9WA4fa+U\/7LeD+q7xeKta+m7LYkjfReIEb0Mk1wejQcvHkPH\/jKMBl6\/cVenByu5fQ6h7yZwxo\/MkDayjTn2Y8\/8C+mcvgNu+9EPg69VnKXMALEgmJ\/sEbJVXqwf5e2O4uArINiarTs7f6R3eB6w1Ea4Pl3IL\/uuzkfoMZL0o9z7owdXbtmzOidJEZo\/wAQuNwrr6pzuxERnTays9\/C9l22kifg2d\/ycr+GEvxp\/0otdgc3YtXZWCb9SGbis0hIjYLD9R5hVqdXAb\/+pxE2dJ2kgfgx3qv4BrCy1718fMEE6uQIr65RTNGraKovs7SqP5dgtnUGdqfLz6l\/LHZfbF+9nQ9hMiaBXAMCl+EUFkJzSn6NTgc4w\/tK3qo8\/ywhHxLBCEiv1wF7K3jwwbpI84FFGqgcoRYrB5tUZfccXzgu0oJ5AGP6VMVZ\/v7Wr81eKVXjAgc+o4A4RDLCUNBHLsNbHGEYHUGKRDHdPD0a6bx\/JbCFKGG1WrOSUhHzv4DZY\/w1aDeu2dG27y97mRyYhh3hC5ggaLFEihLHnM6OwlqPxCnOAuWB4B2uJabJ8a71vfu6gdl2WwH0x+NQd32Fc6WtZl+oPuW5ndLwAIyxbUl7pvOAgD3UK8pSo2ZmGVC4xRbCyIkbDH8\/xnTz8sfnhoBl6qy4D5EV2gmbiSn6UjgDEdAZpYrHAUfUgI6rqo3qql7Qt2MYHr1Q65E1iizaxVDJDjfg7mbUMlvK8s921Q17anKsiBXTQ8k18GjbBmKLhFP5Q+Rn2+bD6TqvCRUl0bxAHX43D+Cv37dhxT0ZmOgJeK\/wOG2H2Xnb0FhZeehClWWMkyEMB\/0L2fFzHShkUHeZsj+MnEZ3tsGoDYHsnzu2fbOzsfCBLAMblxPiJ6QnMUnEt8h\/RvlVbnbZ1bfksxzqGE8SdFrCWRk+OzcdNRoCWyB1DFJPu1VTxNenZ\/FrJ+9+t3r\/PMQxiHVXqC2j+vQrAugigXuoKheOwvKhtlWVktDo5HV+epQKqvSNwVKuQDvS\/O1h9+1eSKy79Nk\/E+6oBK4xwW9AbprIj2lbkVbTT4aRxhKXjc3Q5jY\/Ig74S1WlI\/kfp5HKBRnpDMSQniTm2cQ610Dn1Rl78unSG9w4pQ3qHeBRTK51bsMYUnpPa9KAyZcXu9T3Zi6zfD5D\/lEK4E4n\/ycadXY9mObsYX3aHciOn\/BiCARZV02P\/r70zgfOrqPL93f69JGlCgBi2JL2FrGwmijsdF5znzCgDbqM+ZeYpI0\/BEdFRZxSfuL4ZwYURxhHUUXAeDDroDAOipnFkCwlbdnpPAgFCAll6+S\/33vf91b3179vd\/+50QsDmw7+gc++tOnXq1DmnTp06Vff+aeRWRlEtFrzA5P9segA\/XP301h5o3wmLHsU57PVcv8cpDW5dv22b2cq2NMI0v62tTYw8oDto6xzqlYMYfYRJHoCJ\/E6gdilwrZ\/v5MalYinm2Ef8cMnNm58oO9w\/ePF8d8m2V\/a2WHLJi+FPr5fcoT\/369+b6cyMmgmML8aILUCr56Nrsxn9Myln8kBbNFQPOOyAmWwy+CRifKN8QT+7Vc9UL6\/kVkMrrQEiqHGTjS\/qZ9T5EHJ7sVRshcbd+Ca8BB6XwjhqgOTtKheShrUNE+Ibt6HhAhN410hmFP43Y\/J2xs9RINW5LKOvMEqeHkF3N9JB7M2bN6ttcW7CtoVTzeCx9ZTCkj4QOCT7At5D5npKl04OPANxT4Bpu8Y7nlRXfRxvfaCn5xm1aZMMleO0OasOcbzLUMjS+suPP57zHocpHXdcUcfxJ8Jmln7tHN1ndpgI7nCW6csQM0qlenFQ56FYmh6yoA6VLrU7vVTyCvX1JX4Sqh\/+T3qWP9Q2\/xD18LY858wzPYfXesZbeuk9Q45J1zp79ybeybRpfKNg4PDKxOLUNQw93JXIOf\/8vQwwM3gnyxuNkdbW1unoj7c31R3J8gh0aH8QRPyAiWSZWZJOFvPEcPqqQa6\/P1CbgpTO2nb1fGRj4\/4DBaoFl03PdhzYsaOrTsXnZ+aL+ohBto3sPbxzcUr82e3t8bMN9Ug5jJuYbeC5uJfA5UnxTRh9FkZxsud1oIpptHlQSvpc8GE0zqlK12g6D\/VZ\/XNuuMFzZs92nZ0746nyc2AH05\/JymiycAfT9mRgD6bdg4GdTNvjwdBOdryPEycbr\/b4+dbDcokfcT5lfMBDKmnHNCUzmQzUH9xYwEQPo2nc6kPqz+GoBEPEZ802NzJhTgW+HI5uTRaH8bz0LuAf4rvqZ57pON\/9Lj95esNBe0Ia6OUx0k5v2zI95hlNP2yD0mIe0abNzFwP1WN5zsZBwgeN8+dMr43ByvCgelvlQJUDVQ5MWQ78Yb2NKcuWKmFVDlQ5MBU5UDVYU1EqVZqqHKhyoCIHqgarIluqmVUOVDkwFTlQNVhTUSpVmqocqHKgIgeqBqsiW6qZVQ5UOTAVOVA1WFNRKlWaqhyocqAiB6oGqyJbqplVDlQ5MBU5UDVYU1EqVZqqHKhyoCIHqgarIluqmVUOVDkwFTlQNVhTUSpVmqocqHKgIgeqBqsiW6qZVQ5UOTAVOVA1WFNRKlWaqhyocqAiB8znZSqWVDOrHKhyoMqBKcaBqoc1xQRSJafKgSoHKnNAn2Kqfl6mMm+quVUOVDkwBTngLm5sOXsK0lUlqcqBKgde7BzQ7yDxwXn+4+eJIn5o2e\/Sr3Hc9GLnS7X\/VQ5UOTD1OECAnRWgfiTD8fjxVZfv2V8bcFONY009WVUpqnKgygE4wPeWfe0M8oMX+u5yQ8Avsa6tcqbKgSoHqhyYihzQDw7zW7gedmoa9+uDsNb\/o6lIaJWmKgeqHKhywNkPD2YkP2\/m+8FQdZewqhNVDlQ58ILhgPsO1ogvGGqrhFY5UOXAi5IDOwnAt+NoVT2sF6X4q52ucuCFyYHqDuELU25VqqsceFFyoGqwXpRir3a6yoEXJgeqBuuFKbcq1VUOvCg5UDVYL0qxVztd5cALkwMjDJY7Mnn28XB0DVzeypUrA10PB74qjgNzIJWfkWMWOiOLQ9ohFt6V7spgpetKnjqIXE48qr2DkvGh1Ck3+AK4oX\/wy4VfK4PR5KqMNEZGo+HGe1ZdjasVK1bkuD8keWZxixjSGHqS7LH52brPx71hoAhsc9qkZKE+4ZA2bK4iVIzeuXSnt2TDhvCGOA4PljDhAG1EPf1V0\/PEgVSWVp6m1Wcri7S+cJYqdSOVc6WicfMOpc64yKZgQSqH8fglXo6Q0WS6IDlwJMkDt8bjYRtXKa1j6BkvfzK0Hk4YzY4yJmMIHK8RGa92pz1r2MYDHZEvBi9dujS3YcOGEs0dNgaPaKT6MGkOLFu2rGYiWUheQjaebmhGb1jbEK+KV5mBKPjRsJXysgRWKq+Ul60zVe9Ft2gbzQNL72T4ZWEPdB3NoxUnnDBtV01N1NPTM6S6o8sPhG+iOoeCazLtHQhG7QpmND\/NOayFCxce4xfDt1B6HJarlnd3cnzWoQa7X+C6j+87bPNib\/PGvs6HQWA8rMl0JAuzpKn13eC7iL9\/n7N17uVSdMp9i+9AHaiWT44D8FSzbiSDFO4f\/CjaexLf6Pjhxp6OeyyGpfOb3xe53gVoxC2b+rq+IqXIysrisPD2upJlzao4Li2dv2Bp7MVfotpAFAef29K3pVswSxobj3Oc4CPoUF0QON9a19m5DVwVZWzbWDZ\/wZLQi\/8K1dxVCrxvdnR07LVltt2pfh2PXpu\/uKXlZDd0voAsisWie0nH9o7t6pMm\/8fnbbuAoXkKQvvR+r6u3yufemOMv\/KVsmVLm5rOiGP\/g7gcJzmxezQ8fMAP3M9OxPcEy8h\/LZ26Lmls\/gBfczmT77n8eENf128s5OKmlj9Hj96MjbhhY2\/XLcq39SzM4bpOhNcsCYOh4h\/Fnvcjj9CD3oqGMOzKsNOFYjphFO3l21m3LWluvnJjd\/fvyBuh5OMQa5aZSVl85rS6+lcO5Ifc7a3bryZv7\/LlyzPl42CoZh8UB1gmmJlpcHCwvtZxLqwJco2FUqEHJGWDxbukZ02rq30Vsph+4oknXk7ZIH\/oCXJPUkUPeOfSpZKXE\/pOS43nnx1FseNH4TVkGYPlxX5L5Dl\/66NHpTD+Jfnb2traDD2qZ5MaamM5wzMYwpfm\/NxFxVJpyC8Wf0zeXtsHCz+Vr+oLLBvDrxF9LMULgyB3DgbF8WpK4rcxWLvn7K6F5RfU1OQWFwrFreQbg8V1onFhypa1trZGjvejmiBYWAxxcl2niNHyWL4cSf1thHjG8J38igkZGVmgC7WM+r+oq6l97WA+\/yjAxmCpL4sam\/+c\/D8dKgxJV4zBog1TryLSZ5FZiZ8WnTFYsece7WOoMEqFqBT+C4VbeTPaw9Py6cCRiGQRNuv1tbncOwrF0qsxWudhtG4HzjDPIste1cnsM8zcV4pCmcE90\/btM15aQ0MDj5WTra\/xUxni8OXatoTxYNuzdQ+13nPaJt5xKJ7HXjHLLQSzh7ff0XH3mbq6OjPYZCSIT5r7Zc3NL48i9zympAc29XX+s+qqn0wwRhZu7OTRFYfvExEacPNZ3DQ2QMk0j68Xjcgf9TBbo5cUua4QacDthR6Td+Mo2AM9HqoMhPfZ1pXclzQteIUTR++nS2s39fVcqzz46dEP0x8i2IOwyjx4TlDI9odxtj9CFlyzMjL1snAprTZm5cRh\/EYM\/UIM\/WOR514QuNGDxVIQRF4kQ+MobJOtP5l+zkHo\/Y47IJ1Bjlm5eshmyOQ7o+SdbWSCe9u+QMSf0aAqt\/mLG1tfxdT5XizQQ5u6O78nWFueGKzIHYhlXuJ4N2G8L2GM+rIIAfYWNba+Ll8qfrsmlzsZo\/WZBQsWyMvKq0z4NJO2t7fHWF3XaTNEaclXVlrXDW8qFuNBwoP3PfzEEwPCD3yo+gwEv3ntWgPbjde1lntwG4bLbRasjZXoPpuor7b9ffv2uRMZwNnQNnrDgKq+9fJoz7Sv9vYt3+dCg2JtIxhraRV96qfgoGUMXJY+ey86acv0pXlts9pSHw3+DF7FBss8s3V1zcCUeUOeoR96KtYbJn4kSkzV9cVSYTfLwrUswYxiPtDaKtoMz8PIe2d9bc0FQ4X87U1NTT9WbIQJvUY8ES1x6K+LvOInXMfLO2GwWXlKJQyOl4xRxw0T45OUJAoHz3zxjGu8kyGlRB8McTCSlUiFOqlsxXN4Y+hL6xm9yeZPxA\/KjJ6gdI6MpfRMOmdxqm6qw+LlMOsMlWP\/kZ7QDxWUMFbvq62pvWCoWLi1sbHxOvKG7j7xxBpn+3YTUwrD4EE\/KF2McS\/m3GKvKinl\/KfiglNn7k3\/zd34\/xADloyMwYtid64eIHTz5u6OX2Rrqa\/qg67SuVH9HMO3bF17LxT2nqvu0+csb9oNyDvhnfip8acxneWfHU8AmnEimrSrqYqrViXxT90rvs0lMeau84HaXO35+WL+d9S\/VmNf5VQtmooevrz8IXro+UXiVyQhtg1zlVK1L21s+Saz6jVYv9P8fHwyeWsQmjeeMbH1U1z3Aq8\/k5SnmxR3dkSVlVLlFjfgMoxCWWakzct2XHUmk8RkUKmt8doTiZrRkgHFQ3qfpXVEU6oATJk+W5jJz86itngED0RXJcMKWtE5ou00z9BPG6Y\/We8ED9nwWNJUY8CIh2rvbi76MymlrzyjAjzISAbOeaqnNwnkWsMmZdu8dfNjVNTSxqSmpqY6GbUADYIY0xhtJG1jINQuz6LdGLy0mrnQCkS5dIxqfPooLdNgq1hHtAKjsknxQ\/hUB3jJJdu+4ZvKlVJ85h5w27Z5Hv1Piq+MC4LyQk8jZX5t27ZNSycTp9oSb5HXc4XFo0Fs9Vpmmv8mldavX1\/2zqgyoHowzbSTRaC+ZvowQucokhyMHq1MY5JO+4jahho8vtFU2Wd7NZVoZ8w4En9SjOJjmU\/KE21cTB5gVh+jEX2L42IC5u62fLLlxmDR7fIgKwahydNsCEJ1zGV2DaSwKNXmxH13p7m+gnzG9YwXNy1oQ9leGrnRLVEQPFZTCN+KO7cCrPdt6O26TkQumteywvPclSBcu7m387fKU\/2TG09aXHKitzhetK7k+3fUlEqnsdJvg+XHoGYhPe8tlYJfAi6hl5VPnSXPMP7k5uY5cOBUL3JPRII1LIF4lKEnIocxplZNHMUbN\/Z1\/TrFYRS+iYFWH3tvoJw2nVmwoYCP0O2FcTuVO4GNrQHhOVbw1Ands6D8nhmlwQcGcnUr0beV0LnNm15\/DSD7ocsKUE2V6ZWS7mjqa+HjGAu9ODqBfh2Lss6Ap3glzuNh7Ny9ua\/zThmrbN+y+Ba2tLzMj5xXM8aPT5DHO+jjPZt6O+6mbVPP5I\/5J+E1MIZfSxoXvBRD8XrXix7S0p78eNH81lfz7dnlaBRfIHKXh2EIK92FBGE\/aNjI8tEPC7c\/3Nf39KJ5i473\/dKfgmyozglvxlg9oyblYTGARrS+vbXVjzs6kIfj4KWvpN8vdTxnX43n\/PtDnZ1PeghbAy+b5ElYBV3atOBt0LQA\/Xq8UOPfCKkyrMbYLJvf8hoU5OXQexxDBHLix0LPuWtLV9d9wIkfyD7xZLUhEDvBuejgk3uLQ7880q9vRF\/fBGdONG278Q4v8m5b39exkbqsVIf1K0ub7imPl85rfi3TPHx090D+KWbp7biLFs9v\/RDDhmxvfzFwb+mIO\/aKXy78omo+rg1u2hxv3ic8xRDqjXugp8oJOqyxdbRUD0PvDGI1\/UC\/EueBi9tsZISQYP+u\/WHhFhlL9UEYzQaJG50Jf+bileGlxDu92L2PgPoqYLQK8vAsBZqm1BaY2jbPXEcKlqzexsYgZqJaOH9hMx8wfn3sRsewxpc+2Y+ChmZDrxC+AX1bjGo0oFP9GMNNgRvLBjxhW5D+STfg3QAqsSThZ9yCk\/SXCCPHsnp3MLDvltRg2Wq4qXzrXU86d9U2u83ZuXOnN3v27GQ2ct0GOi6BFfQnOBkztxhdyMe1zimF4bl+Ma71gmB54AcOLt3tgFwnOI6cvZvl5CfyxcJNK133d6tSyytjFfjeP5RCZ3sQxR0EEs\/MBQkNmnoUK\/H98IMYvA9v3tq1xuBKjYKEuWh+y0dYmlxAh5Z4fExVXDUdcAJTVxO9vgJdiqPfAk6zsSxZpN2petf7v1iUPxat9Eqo1TcGXtSD4n1V8Zust8My5218Uvoy+rkJY7ULWb+GuJ76udUZHPw51ffbJaZBxj8ogwZNacf8ba9lQHwHpVrKx\/TZ3IBWmjTffwUgKpUGEc5V7oz6S6HBGD6yuY3DJgxrneN9noDih4MgmEV+OUHLviVNLd+PanOqt0\/b5xSO8B7KwOkNSvGOXJD7dKFUuo0syQg2OGcjw0uSQQAPsFhswrzU9YJ\/ps9OoVjcmw+CNwJ6n+cVT4fLV9ODfUUn9xB5DwpHNsFrw9DaWsVxHYcNm3OQyz\/T7lGFUvG6Ad\/7VwOPgBLOi4bkluMWxitY2tR6EWXfMvKL4q9aL2\/hCexq50pfRD0+gK5My7Ybh+GepU0tV9UXhi6DHwPp8gOD6Z8Oz78jHjUENfeETvQK+tWQ1JUsIulIN3R+clNv18\/Il5dSNhaCyz5HnvfOnO9\/FHzM4YZfhJK8FejgCt\/Lwa9Cfy7vvIJq650gXIFhvlr0xIWCPNstwjfJJHU28owi709yOf9zpk3pqZGRu9hDRr7nO4Rsdk7zpqnNbvX7id6tH4HoT\/m+fzy66vipjhP3Chc1tvz45NbWz4NrG\/pVQx0zqUySJgPGRDVEaGh24EVXMYbOKobxk7R3h8WxuLn5LD\/2\/g9j8xXQSLYkzcxCjCyM4rWL57d8gV3q\/xC878bn+EHAsplPITPm6Zv4eTL8vCaX9G1vmJuRxFRkTMUVxIa9CHcLgZ3hdG8TXyt9hx\/kGFzFXkL0JnYxc2DA76+p58QzjXruqzAwg\/zdGIaFLfA0swSMdSpaUs\/tTHebErxRrTEqnnciHdFs9\/swLP2e2eAp1KWVqeo9GIXlCOMyturfAYP3462AyAyCT4Lz63TMQXZ3hWF8J9k6hnEkxu6VlL0ST5CyaCMaeQV1jeDN9rvnX8vgOQPh5UsMIDr\/CCrawPA5i521lxVLxX9CeftR3uvVVppqwC1jsxgdZUqPb8UAP8z9w7n+\/l2CUTzJAuuq2Jqu8PY4z\/OXqj79\/AnxzYdZAOUZokwgzqtxBd\/NxsfFYf+gJoLPiFboN7ZXxirw\/M8IT7EU\/hajdwe+DCxyXkOdN9PXj8dDJWnERWvWrBmxBFCd0Ql6azQZMBpVxySm5+vR416U6igy3sYAWI4cu90w+q9CGNbR1janEDwmYGjTZrIGalCMwoo+QoSmClZ6xCbN62jtyppcDcaqcHsUBn\/T0btlr8rRSjYdkxSGOXML\/hjev4fcy5EFfS5e6w\/Uf0VQ8MRfPL\/56xjuv0wV+2ZYep+KoOyV0P0W+Pnp\/hoTG\/pMOVzguhzTQXau14BxehOye6gUltrRvW3UPRb5nFubq2lGnl9eMrdlHSR0pMa\/zE\/RJRqU4Ne16A1jwDsKRp6DHE6DH13o2m384ck4O4Ia50nBsv8QoDS6zfmhGbm6n2wa9nUi5wZo3oGeqs230ubLGfjbMdI3o\/91cGBrriFn2sRYfYi+ftPTZF0K72cs\/Qe7G4Po28vg4TkY+vPQ\/WnLXrLsf\/U82aPvejpPsByZAfJxCCvnU98YcsbjjFwp\/g7Bf4xVKQ9Pzt+At6\/68gYR7rW5XHACZzl2QOe\/wZPtyOBY6Pwzxt7yQli6llXDHxuP2PGuQ7d7aGQWY\/Dt9O0UfimnLwrdX9K3eups87zSLqOwBEqTqQ1FZqP6dBRsI2o0QxrgeKWaKPZOoBtvR0vVSXK9b3MWY4cIG5o1q+T2m61OWcZfu5H78Y1bO9erbFQaggBpVZ6dqbLg6TsBeKxuHG7FEv\/V+p7OW7P18HQeYEb+J+r9UdifX07ZHVrXLm5qanRi\/yK8MwxS6WvTjpn1+exgbZJXEvt\/78fuR6kzVAic\/+ZqEpuf5+X84IxisfQU0+j7NvV2ytMwadncuZcXY\/fKXC7355RfvPjExbdt2r7JGCO4ZGl9hMjLhZu6O35l6+maCnJYwTKF6qf6D\/NY\/gWX2rNLKciVeEkPMrF8DQN9Md7kTfImGR+RBM+i8ULDo6j0tVLO+0JHR2de9cDpMUv9LQb0iyjDhSzNb9rU03GHyo7AIuZZ1eh+TMJQJrQ4gynNMYr2AHD6wxtqrcP7wGCF9yNn8c8ktWdumMwV40ImgyjWCAOdgqILycA0y0\/Tq1mPAAAcOElEQVTX\/R6TznH5YvG3LJPe19mz5UkZAysvQySaZusubWz9H3TuuzV+wPHA0o\/mNM37K2t4lsxvOYuyv0SJBf6xjT2d37b11Bf48Vk8si\/Bnf9t+ahyFDwvgtFRBmf08c19PT+Av2XawXsbXtEN9HsR8\/+bqNKhgL7Fnb2mPCvzC9nNwos5LYpLazb2dH0kC6t7ms3HWDN0bSD0WEscRILGsgzTcWXGFueiINV\/eRiXNtBmWUZCnSzR3E94eMalUunHtW540QPpsl3lWrYyjr\/HeHtnOH3oFrJ+pPx0l7DcnvLGpNjJWZrC\/qFv4GW+C1xEA5x3b+jpuNnCYzMu5sjFCYzdhznD+Z6NfR0bbNmyua3fLcSln1K+AvleQv67NvZ23M9Vf5zna5mD6E+JitG6Db2d6P5wMkqiicfwxXWPwgO4kTl\/IxP4atb497EguxcF+Q9m+PNg+tOUvwfk31dMRmiM8YljRfCxbu6DWWNFXlkJkRa+DqLjpNtw88mdma4dZ0fd0Uf+RjmKG9m6vheyAxI\/gnSkdAtsXRZ6p9HkCfCqnw2pH1rllzIJRu4qW7zfZ2AWyHlpXclZoXydCoaOt+oevDcywI2x0kFL1V2\/bRs7pdHVMsz09TQ3KMjFTpLxLAz6XmusbHsCsIJMoUdcKEM\/1H\/W44Hxhpy0TcOPsBBcE8bRQxjSGrj2OltZywAG4AwGaFch8C63yyKVgzPyBuquoI8Pij9k\/Imth3dkCLXP2SsF4i+kuPqZN6OgTRh4C8P8aWhCeCNwsNxNZJfs0dj6I2CEQxlMFE+wXDgCHv5TbVCzkJ3ltUHknt9J3Cr1XGxzBl513Hp358mNjYsh6Pso80yU+WYM3EUyVtCb6KoT\/7GWiHiJd7rT664WEi1\/hFN9wWG7Bl71Bp53BCvvN5YbEX7j5cT7mHh+DagxHOmS0ZmzdV47IHdJF2m\/RfUEY9vVs01qx+q\/8tD7hC\/JQsWAqR5\/Jh9wnA8S46SGoWLxHOxV+mLr4GGzxyFej\/WI8ETOgEct8O9JpPsta6wsPUyG14LnRoVCoOmNFu\/+hgbbD9tM9kpDRkqKn2FUWv8Om3A+SzdR8CEmjn9XF1V28rwF8C9uM5Oi6\/7jhtRYoQ+1Kl+\/rbMTZlybTJrxmThI85VfTgzu9H4Mr8oGRQAwlhnF7eVvM7Q9wnULTOngbxdlPLrTYVSzCLPR+xRxctHpeJIMjv7asgKUXElQYK66H06oNa5dfvduLUecu9kSbksOpTnETQao8WTCrLgcv8HNnmH44zr7PQ61qt6pxx47XdufMkp6ptfPUHcvdIupZkAO1NbOpq1WLSeIQ5S9OS1d6KOhrej793LXzfICFHGjcGUTxjdoaWmZqTy1J35ky8e9T3vuFlmekPL5vKmn+lse3fIUfdwkBnFdXMbhOgu15IVD92CsdipfCqaBRjVv\/ZPr9zNgzNKbXi5RXrnu+DeJLEBqQY4++ujyzK\/JRfkYNN8q2Wgjk9RL+GVx6Er7Pr7EIJPdQtaLV9XV5FawDHyE9fN567Z2dKlcy+bR3guk7HPz4atC1\/8Bsc7jMXCrCr5zPn3eKxqkm9QVvxal7d1hwxYyaHbCWt\/T8zhE3CueQU1TCiv+wR7zROdyOlzpCK9itLpvd9rRfedx6Rn\/HaG8NBkZ2Qd7Bb7MLwZ9wi8MU1Nq+BsbG42MLXx6LfN7VP6kHvUurwWEH6ZN+uRLNilvbPFJMrzQtW5WlN+oTOlMGwyR3lAXPPFdRt1dZ0FxT5GTHoQbisVxdQdY3HU0jY0wPPCPIonLNJTRgAs39XT+UPWJZ5s+I\/tGil6iGBuxqfIYy062fOv4t4pTCc4tOfNU3yZaMbMGjXl2YrATi\/GS6CwBVpZlrruLA3\/vXd\/d\/dCiRYsagt1BPNgw6KMtRxICezsgX5G7jdutwf85NTA0NEQ2zWaSDVSDd1wGZMDTW9cp5AMjkDlz5pTatxsFcgjaRlFpkD4AZjbUEnAyHlcQhVlzDkwjCOzseOjxx431574gKObHk6HgGIwTXfPMso6Iez3xbnYSwRA7r13UvIBrNB0lZSMxZu52B4LYOYb2YL665Y0I6govya3fV29oJUCsIP6I\/icgFf5VH4C0y6iZM2fS5PCyhEIZWJoeNszkmcFFVRObEFa9AyhMtl36Ycro0ZHLjz9esmHpKgiJ5uATlZL+YCRO7+wywVgZmbKHVUY5Er3vR3jqnM3S75y4zqUYjVNYBnYwdt7HUn99qg8iO1qJdyc0cC4dCO4xPFzBQFuMgfsdq9m\/6OzsflITH8I1NDQ2NireWU991VzI615nc0N8wRgjEaNzgeCNjxcMA3as7BB0yS3JODmnd3YavLoXTSxFdEsC30EkWjL4VLGxt9Hg1ATQ29t7EFgODpR+Jm0ybJGNOeNkMUC80Rm49PTd27eb8IE2MugjGpHqBLFg8YiuTnf9fCXjatGZKzjxC5jkHeds7k+UBAgZfJoY75UCkNHEezbxvtQ5MDzEAXs7cupGRvUGEf8ggkH+FvOnGFGA\/9lgy9IrLOWOStYx0vkulRmlUc\/NfETQHQOwWwWbNydbr7on7eHvG7iBdSjhl9hFO4\/jCNev631kU39\/v1dPKNNAZf4pMyaTN\/GtWJAkGUF7P+JqhUSmN1h\/TzR96BcY2reVXOfyJc2tx\/gl985C7A3VuFFd5IZskXqXssRi+7h4p9dfa9b+2gXl3TXiGewtOs4lNHSJDLqSjLYxF3AqmaFFU1xJmFg2vQTgOG2qMNmUdlF6Y6uIT1Kk9NlebbGEZohDgkZgaYGtb+GNUoIpIKaYdGYYw7O5c3e2tdm2DogH68uOu5OHNwS241PEz1IU37yeYwaqzAyc0yyrPr9DPSP58IIbTTzagdZykCfeV+tJDi\/jUrrt6S4Zy3\/MEYdOYBe4zwXNuQI3IhhBpVmBqWCswRI0jFLhTme8viXlgplkGm69bZI1DhdYMrTVvunTaLTwyhpTsb1cLFFJc+E+sYPJ9dfw3fEWaTeekAMrL\/NWjPFUU7kO657r5pFRLVR9I2l3NHmMP2YyLQtDN0q8xTJ1FW9MH43Bsq3Qd14QcI21k7ssD8Aaj2TJ5NxKbOdL9PtEXLqTQbtJSuT4lcZ0xUafXWYiHINDSyECjw8wSN5WwysKdPxHJS8cwpfcz6q6nm3U6exassNU2ohB+pTgVbHolbSBxc6WAv3R9XDhYVhprb+4ChNcJgZORpmXv91fmwbH+QdferQkxoEUZv5GQaMEo3IMiCAPlLL1hkVY9sMOVH2S5e2ThAMMBytEL+rhK7O5sxqXlbM18QVsb\/9uU3f3L61SaxCtTEcPQSJFxOTe7mLwENvwzkDMnyAwfA\/HStbSfNTGmUDQ8+KJVjPEhpArVqud+fU28hUXsZzVFRLY28QbAHQNzyZNdlBa+Bf41eiP2Jrth3SNvOEySnkYCZStMOpeVWHsGmLZcxHCAuLbn8cD\/mgHZ+PSkEF5UqWpnHSd\/7+DSHaASnKy9GiM4eYyxtjIKhV9s9kzqrmKj8ZgZUvCIDIurdw7GjXWeWXqvmMxWYPxOg6NYygqzl5ZXM\/l\/ZKWFg4TOh+Axv3FSGdy4ia4r3eQpsGVRxk0vbzp1s4Rjp+t7+rcCrOTg6ZRDV+goIt0ggN0P9nQ0\/lfzyWdI3BbcWUyoWvYw2KX1hTxCkIGZEj39Gu6zWvjsd30oKwAZpJB+oP5mflM3QoNWiSTusIkGhs\/CT8wadLBUWyJjjkwa8dfoexdHGV4P8vCq9gtfDTdCVKXZWANcYwBxaZwqqJ9VP8Uq\/yvcrzgVdS5muMnb0W+O4i\/GD1tbGwssV1v4Km+alNP19ds2+Nd1Zb0WE2MB3MY8su47TGWw4DzWaBI3veDqFrFftIdVvFdwtKf\/Fp2sYwQrAc2cXuEjfCcdUToVk4J9DEdcD4v+PD6xuZeKn5dMcQ03ol9MEs98X2IKPA\/4GFvnRi5YzZOUjqzoIZm8JT5mxqs4SVKECrQ7DiKVwi6zSwJ2gyS2Asb6CfGitMRrvuMyZzkP7Q4rNmTrDMRGFb+eLyoJmjZ4zv+7et7HnlwPHjTj\/TNctaDe5ycuxPjeySuqAK4\/0W58VASxTZCVUzDMIkyVi3ZOFPSCuv3Q+6Plk7CsmvXLr0LqNuiaCQ2eLxRovRUvwqYEh+Tq4cxWig6ReN2To8vnzlT7RtlQ3oLBQvRj9ojD+b5MPxjg9LogcdgHIVxLAvEK3hbL6X248JfF4rO8ppcsJSzVN9dOHfhuZQ\/qgDw7A0bRg0Ud0bR9x7kJd4Pc7ygnXM6K0LO+DAI3ivPTA1LoYmHPG6IiJ2TLDFWRuKhzaOdspLbvOfjalcke\/bs8Vj2jurj80GBGWiPJuY5nv9UX9\/RtPoEy\/FAh3jtRgUrkcYk7OE+7pdKZtOKJRqnAlO2GQ0dQa\/lZ61OCRAeaoTDf0trX0MmfewS\/quNYXHmaiervQHwTyOs3gwW4zAIG2LRhGPkNEJG7Sotp7IcyRElIV62rnwMRP8ytenKVM\/RhyHFqxxZTBCGUhIFvkwjkft+bSmTtrJnYHYfjJtuDLVhlO2UYEYkKKAMfozIzTxMPANqxKp6GT9MXofRusVzPCLX4S0ETG+HiZdxfcuiefOOz2BObtuSi85U0a\/VibCcs5vY1eEZG5J4k1xNytQfJjl1sdUXG8PKwE14a5YkqohHwQra8FhHL+zuFh7Iyyk9Q0sZjFZ5KQPSu3DDyYpXLp3f0qZGNIDL9fhSANJ7PUQT1yl\/nkRgaqvML5OR\/ScpqVhOJpSSWFFbBZceNKxdOwJeriF6MTKPZpXBUZOX6DUeYD7GifqdHC48ww\/Cb4jfwtnLax2mDf4RvP74vMzRm7q61tGRj3NA0mGT9tygGH\/JwiXX+G41gMq\/UW8rKA8yzFLECC79J1PH9MUsGwzwBDxJx0Gm7mRvTRvwomT5JRndWDZYlkf2mkErGanzh5oyMi7v5LrRA0wQzIreqWHk\/6lQix5LG6+YnUST58Aq9XiNOcoDjP2KiiFlWOvNo\/5JB6FZWXFC\/XN8feUX6XGaf9QXFsBnahVznCzghIFsBfJ\/j6k78Rgrt6Eb6phPW6C\/xgYpzwbfjdJgbYExoDnPy53Gu09OkOOtQg4BERlr4CM7vCPV\/G4scNJJx\/3Jxq5Ojj04zvTp0yM+FJcyPcGi\/DEJxqZyGS0eUxeJj85PUCgmw2EKPWRhxGTeM\/seTDoLo3kctB7H7tsbJQRSP4f57meBcmvkR\/9GnmiV0TUeCmvBf+GMynt5ReZ1fFzlGj4P8p1c4GzHarHg5QOGvFtRdMDHM+9CraaudS0O3E+1XiFRUQFpKUg9AbLlHFDtdwLOQpdKhTCoO4UgzmV4FUcVwuJDvhOtsihKgfvzXCm6gLIz2Dy4mhPgX6AXd6qcNxxexqHRz9P\/GZxm3uh78c9tvX6+NFKjTWMSg9tcbdkwH61IbElypdwKdJ4OIeqQqzkqsnx5ebmZIhyBN8UCu3EhvcSI6CNwi5pa\/gZ+X8u5nXdNi+Ie4D4jYy14G1uCROLztTTtOBu7O\/+F+GQz1F2Kt3YJsuzmcORVKuOk+C9Cp\/QxliPzi3Hpe0xQX0GeG4oFSnyvxvUZLqF3DHHhI1jFPAApiUemygkbKtFsSgVgBWwzJnkdoh0ZzlYdaN7U09N76rGnagmvPpbjOnQ2RT+MVbJICEp0fLjkgHdjaLXeXcH3V3Mo7f8Fgf9ujiowiTfXRk7NLbWlsBjm4mW0dAn6dBLx3cfg\/022pd25XDRDTIKg0RMRMCmZyWqAvsaLGhv\/muOKJ3DIejkHRK\/i+ezNvb09XV1de9DTnwByOrr3IeT3NMp\/fbGYeypXU+J1WEfva9VhdI7ldcrBR7Z2S5+zfDIeH5w5nteH5rKkfLSRYyLSGeMuUbkWxcc2uUdz\/2+8K7aOwcDZHn81J9fvc\/3gBjp4DgNar8BcMeiGxCeSZA6Ouu4M43mxRWrz06tRQN1TdZrWwHBihmVsClOnurR7RDSN0MeoVDqKoH7sHJHC2OA4Z65OnQ5nzyM\/IPB\/DTb3FRztvxD6fkYbHM\/wXosCf5nV9O\/wXj4otDDQzAAEgH\/F06f1yCsKzADx3cVStCYM49VhEK\/hPbPVOd\/7De7Dv3oDpfmWJJhVb\/rpOg3hMcmScKfG3CQSxl7bigUCxjOg46eRX\/tIGPt3RkHN\/XRwFfx9DQq0iyjhJ3WWCIVxVxI7ZGbci928GC+lGy9lAUb5OhzjtRwZXcNJ5xvJO5n+70D4F63r7n7CnlsxJzngqXhOu3VZEvHXptl+2Hydi6LJVB\/iB3UgkLZewUHM25k9uwZq6m7d\/+TTpwoeeusp0+2RHHQve0qeHymMMB26ICdxxXl2N\/d0\/QAivqyRwPuKn17auOCzyhcCbGoZF1mQmqTNvd1f1CtM5sCw6313yfwF\/1Ml5iyX432MPu\/mtZ1Xs7v4n+JHLohW+25pDZPU6sB3f8\/sfAsvO5+RokMlIkRqeHGkH6W7Um22NLlC33SMKlQOxwtHQgw\/IcPy4VF6sha9c6CVF\/79X+PpdxTr+m9fPLdlsWqAry7lVwNjyDBO+WF0jDqMjKT\/cVZGFXUqq2vUqxet6L2JXwqfjrvAQ1\/eFCugS\/GyVgdB7lhCJ1d6TvH+Yo6AOSEQdO0NlA0gx0\/pDQd7xkkn3REcYxkecPxHOMtJ+YY37jT1XfkyTtxchG4+WZerYVc4uH5ZS8s8lc0KC1fBk2u0E8jk8ilOvq\/mhfk1LBbYjHHuw66s8d3gV5idK3R+Szih3fAmihiDGCDaW4FBbOd94Q7eWvnNknmty1Lmefcy2FcRD+qA+TpoyRFYV64f25LxbpZcq3nv59s4kCt5VeNiWTrrfmppAtfv4ttJvajyQyI2k4yBMM+8b8fXCrcimtU6E2Jh6HqHzuqAYxXvJZpzVLM3zFY9w5QZM2YMcfP7wXyhGy9ks62XnzbwBjp4Nkzp54To1zf0PHIvr9hcCX3nhgVeK4l5lScs\/SednoNb8496n011JVBdmbG\/Do\/+BMX\/GY\/bKEFAfIWC3QueH8fdvQ\/pfZ8TEI8JXgmiNvMlxh5Y+3teCDceQnvZ7Tcg4\/+Dk0vSNpe8CglaZzdeQptHkdfDDPUD7s\/a2Gc+jCg8HM6NzVKcft0Ve9Fb8LC+xWn4zfiBencTIUcdig0RPn3z8Ods2w0N9Iu4j3sHLy1vxE02y3dTIMRxtG4on++FBuOppfniuRkoQ\/rqRhx9BqPVg1LzXiZxiNidgfIJhhVb9BgKdS8adhtT9lNpfWq7Oxh4txOYvQtIxpfjNHJ2Std9Yf7L1LmCpV4fMCtQ7BOVzzTZjXe4FgNze5gLzU6uYlzwhNcMo0\/Cl5+y9O9lAL5m7ty5ZhAlr4B4b0In8bCjDvGDtnEO1Ld4t94YoI0f8qbDJuUpwckd8l6R\/235YmBo5mwPW43tpk8JlHv\/YCEvXbg\/eTb\/wqbKydblNP7PEevn6HcXBDDpx03QpIPNpi6e7zbK7oaKX5Uirxz7rZtXl8iIg7VMsGXdprWKbbZndI2h\/fBgocD5JudO8SqlUPVMjIil9SO85vln6MFlYRw+nJRjbJy4D535CbtnZ+lLKsq3GwXNjz2m15fuZJz2IeQtSR2IAT\/yWa3xC3\/LY1xn5KSb6MfH+BbYfUDOKsXeaap3F1+MGHSjj5ai6Dxo+DVlTyMjnAyNM16TcuJe9OG\/0ePriH0VVIeYn9G\/oGHaLzBaf8eqqRv9mwVsI3zVRC+DmvCmidgCHJ5JFp5jyGoocc9zXmGAdd9uu\/4VYgSRLK30QJLx2r9\/f91xxx03qFhHkjvyX838fAFCs0hhFC6f0+L1nPouamYYWSt50u5D7Z7a3OydG4bamZigmZdjWy\/hPcK\/h9Y1vF\/3GtUVHTa2o5o6jV4bunfiGi9lSfJZdpW+qnzRYtfEesbCv8Qv+kbha3JhkS9v71+3deszakfl9Fd8Mp+a2QitZI3og2DGS5YmXORzGPA3IXoGi\/vmfeHQpmlBMN+Na\/OcZNxr31cUHtve6Hs9q0+5MMTI1XLIZehpxYmUr5Stp+cmZDq9f3qwYeeGAci3Sk3\/3WDHwoX1LCXLcQ3BK2VxwPfZtUPxTPLiApsVjzz2iOJ\/ZiY8Zc6cet4ji9c8+uhAUjP591UYlX5OTOsjjYJNcRp9EW7qTds\/fXowa9asATPZpXlajuizKBYX2baOv3Q2+jEz76HYMmhCmygtD6c3NR3Jt1Rm5aIcvl5YCvO5\/objGvZYPVCbghe+U+acUr87t3tEO7Y9Xa0ea5K09bPlle4tfpVl+VWKgmc2P7p5d9q26ffoPqZ1iIXX6sdZ9EmY4WVRpcYyebRrxg1ZY3RRNAlUbeuqQ+BuPn80X47yh2qdvYwVM5moDNARY1mTBQamdvRYrpSfrStdQ79rCyTJMVvGPS+sz39JMcrxJVoF9nkXtS7aBx3J0k+EpAlYIy89ip+YdJb2XlxE\/8TPssGyFSa6Chnl6uC4jM02OBEulR0MrMUlq66T9KzLP8Ly4krNank\/Xq51s4WxV+Ff3Nh8f+AFp3H04TN2G5xs65ZLpmXlt\/UO59UaLJYJf0a7P2NJ8FQu9s94OP3hhmxbli5IKhsXlZMvvktWI\/Jt3fHq2XJdhWOyfZ0IdqKybHuj26TeiIExunx03bR8TB2br+t4\/FDZ85km4slEZaNpPBjY0XVHPwsXeRPpzITlo\/GN90wzFWUkeMoq7rCPh8vmi\/bxdNUMXAGsZNblohjEmD8ZCeULIYjGGCvKvJV4LbqO11AWxhIm2Ey+wW\/LsldgfIv\/xnKBfzcu417W2y01kftFBTvliclA6KqP+vHh\/M9D0mn6ljyxrDWqCi4JSk2bwW\/7Rna538pbmfJDdWwCxvZzXFot7Ogrrrjalc\/rluLQ7LQ0MSsJp9rTH8VlurL1lakyYA2crtn78eoJJuXbCAUg3\/bDGu5sc4YIwfCnduxV9waPrivhT8o70y8hUH6GdyPaFL8p9kWPrad+kQeuJG8EETxk6wBW5rnyVSw8KS7RVv6z+ITb4tS98rkIrpxvy3Ule0K+ZGGz92k\/yu2rjbF9HMuvtE0\/pWvcsZNty95naC3zxZbpKppIhucZHhlZ6jmFGTMBZvCO0I3x8tM24FvyQ7GCs3RQpuNP6Pc7R\/CGPPOsOln4TD1jF1K6R+ifCZiqZwBXXMpZJBNdRTTlYzqfrTMezHj5o+qWjSQdNMqmQ4jsPlxKnOpyAucXEZx7L1vgWwZ2Pb0\/R5CZtXQzS8YTTdfi+HJiPKyjTdJAMrRyVb\/LuNPycS9pvQn7OV5l6pqTFFQuv66vHdYU53jVyvnAHRStqkiVin1L25ywHylMuf3sDWUV9SXNr9jmePSMh8u2R3lFfAdqy9a31wO1k9InnkzIF4tv9HU8OlO8FfmVllXs32j8o59pb1K0TkTXaJwpPRXxTtTeJMoqNTVhXopzDEx5h2dMyRTNoCNmVtaVwPk3+ezuw3xq9v1YsTexy8lJdxl4nX+LnsYDu5mHn27q6zaOmYwd1Q5JIZ8tOzhW\/DTBN5atcR8vBpm1e\/a7YM8Wf7V+lQMvBg78fxAN2T5iTbNnAAAAAElFTkSuQmCC' \/><\/a><\/div>\n <h2>Hm, teknisk feil.<\/h2>\n <p>Straks tilbake!<\/p>\n <\/div>\n <\/div>\n <\/body>\n <\/html>\n \"};\n\n }\n\n return(deliver);\n}\n","old_contents":"sub vcl_error {\n if (obj.status == 801) {\n set obj.status = 301;\n set obj.response = \"Moved Permanently\";\n set obj.http.Location = \"https:\/\/\" req.http.host req.url;\n synthetic {\"\"};\n return (deliver);\n }\n\n if (req.http.Fastly-Restart-On-Error) {\n if (obj.status == 503 && req.restarts == 0) {\n restart;\n }\n }\n\n#--FASTLY ERROR START\n {\n if (obj.status == 550) {\n return(deliver);\n }\n }\n#--FASTLY ERROR END\n\n #\n # error response if all else fails\n #\n\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n\n if (req.url ~ \"widget\") {\n # no HTML response for widgets\n synthetic {\"\"};\n } else {\n\n synthetic {\"\n <!DOCTYPE html>\n <html>\n <head>\n <meta http-equiv='Content-Type' content='text\/html; charset=UTF-8' \/>\n <title>Holder de ord<\/title>\n <meta name='title' content='Holder de ord' \/>\n <meta property='og:description' content='Holder de ord er en politisk uavhengig organisasjon som kartlegger norske politiske partiers l\u00f8fter og sammenligner disse med hva de gj\u00f8r p\u00e5 storting og i regjering.' \/>\n <style type='text\/css' media='screen'>\n body{-webkit-font-smoothing:antialiased !important;}html body{margin:0;}#container{position:relative;}#logo{margin-left:auto;margin-right:auto;position:relative;width:300px;padding-bottom:20px;}.information{font-family:Verdana;font-size:16px;font-weight:100;color:#111;text-align:center;position:absolute;top:40%;left:50%;height:30%;width:50%;margin:-15% 0 0 -25%;}\n <\/style>\n <\/head>\n <body>\n <div class='container'>\n <div class='information'>\n <div id='logo'><a href='http:\/\/www.holderdeord.no'><img alt='Holder de ord - Bringer politikken til folket' src='data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAASwAAAC9CAYAAAAJMEAnAAAEJGlDQ1BJQ0MgUHJvZmlsZQAAOBGFVd9v21QUPolvUqQWPyBYR4eKxa9VU1u5GxqtxgZJk6XtShal6dgqJOQ6N4mpGwfb6baqT3uBNwb8AUDZAw9IPCENBmJ72fbAtElThyqqSUh76MQPISbtBVXhu3ZiJ1PEXPX6yznfOec7517bRD1fabWaGVWIlquunc8klZOnFpSeTYrSs9RLA9Sr6U4tkcvNEi7BFffO6+EdigjL7ZHu\/k72I796i9zRiSJPwG4VHX0Z+AxRzNRrtksUvwf7+Gm3BtzzHPDTNgQCqwKXfZwSeNHHJz1OIT8JjtAq6xWtCLwGPLzYZi+3YV8DGMiT4VVuG7oiZpGzrZJhcs\/hL49xtzH\/Dy6bdfTsXYNY+5yluWO4D4neK\/ZUvok\/17X0HPBLsF+vuUlhfwX4j\/rSfAJ4H1H0qZJ9dN7nR19frRTeBt4Fe9FwpwtN+2p1MXscGLHR9SXrmMgjONd1ZxKzpBeA71b4tNhj6JGoyFNp4GHgwUp9qplfmnFW5oTdy7NamcwCI49kv6fN5IAHgD+0rbyoBc3SOjczohbyS1drbq6pQdqumllRC\/0ymTtej8gpbbuVwpQfyw66dqEZyxZKxtHpJn+tZnpnEdrYBbueF9qQn93S7HQGGHnYP7w6L+YGHNtd1FJitqPAR+hERCNOFi1i1alKO6RQnjKUxL1GNjwlMsiEhcPLYTEiT9ISbN15OY\/jx4SMshe9LaJRpTvHr3C\/ybFYP1PZAfwfYrPsMBtnE6SwN9ib7AhLwTrBDgUKcm06FSrTfSj187xPdVQWOk5Q8vxAfSiIUc7Z7xr6zY\/+hpqwSyv0I0\/QMTRb7RMgBxNodTfSPqdraz\/sDjzKBrv4zu2+a2t0\/HHzjd2Lbcc2sG7GtsL42K+xLfxtUgI7YHqKlqHK8HbCCXgjHT1cAdMlDetv4FnQ2lLasaOl6vmB0CMmwT\/IPszSueHQqv6i\/qluqF+oF9TfO2qEGTumJH0qfSv9KH0nfS\/9TIp0Wboi\/SRdlb6RLgU5u++9nyXYe69fYRPdil1o1WufNSdTTsp75BfllPy8\/LI8G7AUuV8ek6fkvfDsCfbNDP0dvRh0CrNqTbV7LfEEGDQPJQadBtfGVMWEq3QWWdufk6ZSNsjG2PQjp3ZcnOWWing6noonSInvi0\/Ex+IzAreevPhe+CawpgP1\/pMTMDo64G0sTCXIM+KdOnFWRfQKdJvQzV1+Bt8OokmrdtY2yhVX2a+qrykJfMq4Ml3VR4cVzTQVz+UoNne4vcKLoyS+gyKO6EHe+75Fdt0Mbe5bRIf\/wjvrVmhbqBN97RD1vxrahvBOfOYzoosH9bq94uejSOQGkVM6sN\/7HelL4t10t9F4gPdVzydEOx83Gv+uNxo7XyL\/FtFl8z9ZAHF4bBsrEwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAXFpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IlhNUCBDb3JlIDQuNC4wIj4KICAgPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4KICAgICAgPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIKICAgICAgICAgICAgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIj4KICAgICAgICAgPHhtcDpDcmVhdG9yVG9vbD5BZG9iZSBQaG90b3Nob3AgQ1M1IE1hY2ludG9zaDwveG1wOkNyZWF0b3JUb29sPgogICAgICA8L3JkZjpEZXNjcmlwdGlvbj4KICAgPC9yZGY6UkRGPgo8L3g6eG1wbWV0YT4KJMk4MgAAQABJREFUeAHsvQmAXEd17l\/3dvcsWmzLsrzgRaPFtjbbITZgCMRjICSQAC+ABAmQsATvxiwJj38WyyYkL3\/AYGxLtpU4bEkIEiRAgLBG4zzALHLAWJstjUbyJtuyvEmzdt973+87dW9PjzQz6pnukWbkLmn67lWnTp3z1alTW5AkibvgggsKTz\/99KzWOA7CMEzi9BhFUVgcaCqd98j9T61NksgdhvD8efOOKzrXksvl4srkREvLwMCzGx5+uKfy\/kScB9d35N2SPUmyfHk5z8HNNx\/jguAsF+aXuSRZ4hJ3pgv4S9xcjjM4Oo6OZ928t5PrbVxv47jFhclGl8\/fn1xyyTMZvcG6dTk3Z06QtLeXsnv1PAaEpUuXTi90d+efpUyzuI+hbHU9a9asng0bNsDqIxvOWbjw9GLRnREELoHkGHEUF8cdciGSEgS9+WLY4\/LR\/ub+\/n3DyQxpheeff37u7rvvjtCBIbI27sSH+fC8k0+eHra2FirLYJjXJuxWVt6tra29GzduHKg2IWHCvn37ji0MDOT70MUMG6r9vvI94UlpoLmUzEgGZsyY0Tec3F0cXJx3rsOtT5JR9SEQYC1esOCcIHarkOpjkJZ+boUIUIQIzUADd4Y5d8XGzs4HVMgTUbhZvCL6sbYHPgYdr4GOpzmGWcaDJJgehMH1m3ZsW6t72TfZ83ocDUQ2bw6SlSuNacH114eAyvkuCn4LNXoFf893hcIs19TkkyvyGtrm4gp5DyG5UOAP\/isMICMDxaf59peA2X+5IPmuO\/HEDRkYkgbguGQIOPoPx\/eb8eXMM888plBMbiC9c5Mk2E95hqQPAAfT4Gsff3+9def29byfo0zLwDy+VMf2FWkaKJFusqRt4V\/Am5XQJmUaoGBz0DbugEBHxIcMBz0k8hTy+xiR7eTe\/S52m6I4v+W+B+97uDIBKWc9gUv5U96UBvn7aBIkr4Lv3Vwm0GR5r0x\/gs6pApIS+N9K\/H1BEv\/d5l07vrcC\/o5mfIgXApSlc89cGofJDUHizuB7dDEpQPn4igYiAhdQvkkPEVBpB7vhUCd82RwXC5sqyyMti1LGvwN5Y1oFCh0HNrwsDzJZFYfOid9YOa4Ylc4oxtG09MOJYrbFu+\/8fYHbGzy\/KZ8\/m3qSJNPkOOSC0JVKJTEvC3WlJVizpoAFZBaHAdXxc17pZp\/4dorod930abPEcgMnAVSxCJjzj1KAGIHqIC1i3EB\/7Pr70+dBDoA7DhBrh6ntrqfnA+7xJ74V3HLrP7m9j3+vDI4V6WcZHM9xeUpLvjdfSPIDr2jKF+ZFUWzkizQsaCvjOIk\/q\/jbXbv0q6xg40mzlm9IeUYY5grQpr\/pJtq1RegLQyUiNUnjUt5RwIEwLG1d0rbghzz73kDO\/Xj79u2PZzV+pqy1JJ9+q2RNufl5MWXwAqyMOkQ7tijK5R2T9zj+F3294\/zzJa8jVlB9fX3GsjhwxyCvFxXyhZZSHJn+jQ+tSI0PfRUlCnyw8oiTUpgvbV7ctvC7vPFvW3Zuu0tlYQI5QkVqgJUkuSJZeiaJo2OJboCaiDYE6Jy4Fojem8POzhI6DMdnBFYwuJ9M5JA4SMNOCJM8J70V6Y+bfxVxSKADd31HLlmZgtXq1S8AqN7LO292M2cUXD8VQ2+PpE08UGFjqTjRNRgqz60STZ+LQqDAFQdi+9N3Aq\/mpj90+\/avcLPnrAtuvvWm5OrLfyKwNGtr5cqIz2rOWy7Yj6nRtLcURfMQjn54iOWSFKmQVOMOIBR9gxk4omcDUuY0wwP4IySTNecfqPJslPyo6nAuj9I0hUHuXOq+c6M4vqIpSn6KsqxLXOnftu7c2SVluTgI8h3YzPCsLghD8k9TBjIAVBmKFsnQYBiv1TIYw\/Bn5Dkrb45Y1L68Z86cWRVvKZNSGAZ7AatTKZMe2hLNnqfDJzeWu9Aj\/Mohg3kqq3M5P7cUx++hIvknNOTT8Gob8dGyP9j6TwHLAFAFqpLKQ1iouknXZDRXB\/mpPj+gJ2YA6SJgZEoljdaLFGhTe6t+wSwpopOVg4U1zQ2UAKrgTwGq2a4Pfd6\/v2gCRlOYt2jnlQMaJoEO+ZOVf2CQssR8o+9MQOGhQIz7AwORgVc+X3CtrX\/g9u\/7neCW1Te4vpk3Qke3aCJCNUtrVhhKMOf5lhQ4+jKlXLGuVO7D0H1gPib+mqZbKGmDnypqCbEVvk\/ZdMt+xkYJ4nJQ7igwajyaRj6+wOVzYe5FJPuiKMn9yZJ5C27rD91nO5PE\/IxyT6xP1o\/qT6mKJpROpJA3KlxjegVlFadVRTaGl4gaN4ppDlku0O4fU2KFfIJDEVCBkcBLpos+BygFeYl4dsiyETilVEuHQ4GK6BJHVCsEcSwfIoZ\/eCx\/V0Zx9Kql8878s01d277G\/YNAywBrODb4hCAWxMpSHO69qXovWIHTe9114lkSrFp1Frz8OADyOmXYgErMTZza7QQrF5USAgy3wzDv8oWQNjNSIVyq4JC+F5apSVvidczeNAIAK6HABML8RaUIsIpdczPNzfCjuDguDG655c8Aqq1KUf60zM+l69pDBY1EX3t8kzMGcV8FgFoI8FVwsjSkePLLivd2m2KKsbJk+uRxfSzieGNzFP8eFtfKLTu3\/1hgdfHFgNb6OoCWkiR4pg+yHrqk9LLcB2\/am\/X5If4S+ZWOF2M6NMYR6wF0pZcwEqlXJXzIQP48y3nTAEgtFX8TA8kqJ1VXlFiCQqAYudyZlMvapW0LLt+0s\/MfU9Aq+85lAQwbiNOKdtiHU\/xmsGJFLlm7XMie0CR7Gdj0VTdj5utcH63Q\/n5ZVbKmsmYf5S6HIWxuaSm46TPy5lQfKA643r5H8EltdN37f+p6un\/kj1z39T2Mn6sfUHNu+vS8fWdOb+KxBq4xUMpDk5P0+mjpzpjxe9DxNUCrXU8FVtYJYK8+F38oGylGiPdyDH9YTaEQKBeGBUw3moBBwRSD6gMu0izzVTDy7SskbtL8UVNZyvJKlOfrS9rO\/BNxXGAl0NJ5fYNUy8wK0dkkWiforxVeOOJuATbkCnD0\/B0AQqPmbBgM4Jb\/r0NVf8In1RZpuTRRHgWLwgwApQ9JPCa2HGDVr3IDXVfRRPzdlDo+IQLCBBRGmsQkPajJlaxdq1rNBTevfhWM+rybNuMkt+9ZCbRM1tSqsgx48JrW0oSlBJj1PcHdDfz9DHm7l0ZrF9Kue\/vpFSwBUoBZfrrri+ZQQm2uVFyGA\/6FxHkBltSJLsw14Q\/jdRSnbL0BWgKxfc\/GgOFZAN+6YNVt70yuvOwbGWjV19JS8pM4SAtgrgSU0234Vb+HkY+BkOSNT6ORbhV\/MI33jiGO2bx6EqV8CgozE8zLUz9RjPx44KKc0QFzpzg5\/GVxyW8zm3f+fvG8Bc\/b0tX5kQy06mlppQpKayh5iDbRIxBE9pRfy\/xoORzDM3IdJLiD41Zy2QtrHtHHM++uzoeVJmQgkSUKfTHAozEy+yD1RprX9yPnMxi1YPqUvTfkGLjmxEWMPghOgNen8t1CmL6IioXeajzT1gJR2ZKUQClJAKu4SOXRAvGfOPv0s39J2TzMI1l00XMKsMxntXKlSUVwy20vB6z+yU2bPsd1dxdhlniRFRC8xGfd3FyQP8319HVicP4bf19306ZtSN7xjtEc1nuJ5wH+7ubvK4zfanZB069jSb2W6zcQ59kUmiwrmetqIvo\/uZi6uweI\/wRA6wuA6ZuTq6\/4rluxIg6uuy6sh0+L9KdA8IhCLYt6RD\/dvLPzyrESra77bW1tM\/vC8ERa5\/PpFz2vFAcvIZ4XoyhzUJgC5rWag9IRayaiULK4UJZEHRJNXF+\/dN6C3KauzpUGWsjH+kOMEaqOTp+odJP0PxM3Fz5O73drfgCnZn5AVn8mg9VFN8pbpEF0HvufLg08q1dr8cvBEyoODW2Ke+iWu2PTjh27Rkl+2EdL2tpOwVV5fpREbwCkl1NBzIhwqoJU+k8SRnSojhgsw0WMrrqGiD5EPuTPMiUdNuKj7SZSEDDeSbV2HNx8+3mAz2dorgFWPSlYlQVFtUUIkOVdb+8+pOoOCmdNcsUVWzKeWFxr1gyC\/e7dg1XjKVToWbjkklJy9dW0M91d+gtuuv0zANW7UYxLAKZZNCf1ptKj9rD0m7gHaE0\/DtC6A9\/a6ymo\/wFoJd6ifTAdfXmUBzJb9pNIWKV91WQ5HWf0NO\/q737+vq0hC91PPP0C+p\/fzPUf0DyZg0XFqZqJ5gLQuUITyQygOU2w\/Fqc8U9u7ur89HrAChJqHrOmDEhA9Mc4pL1bt25FxrBYDkMYCw+HI4daHBkEVwTuERaTc7vmzZvX0razreTah\/vCuTkdHck6skowZm\/euXM3b35Df4vmn\/lVTN5PAkwLKAuBlpgi1FIlUiIpOiqSNy2ZP3\/VZg+OOI+fK2HdutCaWKtWzQbFb6X5dQY+J5gi0K4AK9W4LS1YVd3\/g1j9ZXLV5f+ZsQjgQIhpvl13nWpCCfqoQQISrF2bc5s3M2xi5UDy3kvVXfthrLtvA0wfca0tL2PYBIPfYiscL8VOzcYiPq3TsLhWB7fd9jq+fZy08y4d0DpqokfRQ7Evyw6j0uWkVbO9fC97lh4zLNBl0N7eHmT+mnRQqMrrx\/rDsf4lmhsfJL438FfAqqKJroGRRO1jaUJRBmj+NNFk+ZtF8xbet7Vr+7cZ41bXQFLmV4KGcOHChYXTtp8W2VjEOqWiIQzigY4dHR1qDY\/H8T4cNYlmFOiBwOpQVhv5s8Drml0QaqyXRt1v3bHt68vmLniSpvE6eghPBrO8pZWWA\/TK4JoHSr6cbz8j\/j8nAGtIj1sSXIdl9WIACXmhphhUAHovGDnbhKO8t\/crdOC8D+voIZ6rx67JLV9eFOjoGuCww6F+YLjEXwVLbxCKtm5dAdAcSK66rAPr6fdx8n8CB\/476K\/Ku1I0CFoql\/3d+LSmvwg6r+P7K0i7NCQf3DzqA6iR5RHQkcLpunwve1ZxHPGZmombly7NSVHUC8iwhZ89OvcBjbe7Frf+sbRKaKLjS8lAC0tLzUN8KdNpmn5k0RmLfrU1SR6p4+BSTGbv+yFbamoVtyXb6gUoFSyZ4NP2Q8eflpteNF3QScbHjbs6f7h47sK\/RT9uggfWG8i5xoGim95Zz8DEC\/nkM7KcpbBHdTCgWL7cBCG4adXrYcJVNMuUZ93L8u\/BSlNq+gf+0cWltwqsNPo9BYkBNGFEZaiGgfpeYCU\/miy15Mor9+JYfyfjsm42P1kuJ6eyLAgFrGKuNBYsCC7Hn\/UG3TQLUdOFGmHMHJCwC6ykFMuWLWuSVbBlZ+cnaZK8jebIQ9TwVN5YcFkpIzgoWh5LjDERuReEuZJ8KS4diV1uqo6ZkMoP1L4aDJXng3eP0jM\/SPdiM5jyuZjiSbapJ9GCLCuBllmEpgqL5tH01LOjX\/jVFET2ghtvPA6\/9l8y1gqcN3NWzm6eGHDlGH2uIQ1fck8sulR+JznLNfpcIGFMrNMPllIsS82c8Ur+qsvfy0DS25kcTWmYT9GnZ2O1sLrUPA2DP8ciU6+XwtFfZj6fE\/IrJRBwqYZXAlt2dX4D+fgjWiOP4ADGwjKfltBKzRFkRM1QSZB7N82Xl+obNWt0bITaODDHdVj1cO+OHY9RLj8z69ZHKeZTFBo7Ztr7vOl0oOjRUc14WTNlwMk3v50eugvMavE1m4crcaEFEOvtvQv+XJmsbFfTqyl1luvphAQDRTU1FWJ6Qvr7v+ma00pEICrqNNCxp5dJES3nA7lv06vWNGQcmc4bYfwcyKbhAEqBTQJPgvfR5uznUkAm36bpCvpSwMdSYsDUbNr171KK2bfjT73xpTiAM74cAKedwia4bgaGPTAvPGdBMpN5gsx3PsoBy23aJLV3wQ03nIAAvscLIY5HpFL3YRBDF5pCBm7uZRLCB9RMs0nQNN3s+QT\/WBOxDI7Rn+Js7wKcRJv3ZQhYtWqGD+8JPv0PJ9np8nq7f9MUnmOH9fT8yZmvbG\/atW0dRtUNXmDoncoc1LqB4hBUGK9d3Hbmi\/X+vvPP9zKki0aonQOJY9iFEOtgtsL5MIhCs4iPWgvLrKt0gKhrnvZahjGfwzIvMNasUHElsik2CCLhpuTyy3\/CzcAxFEE3DltYscImPSdXXcWUnOBjDDTF5U770HfrigwWS+FeU\/NSly\/ZyN+GL6t+pSNrST4txdiUd5\/GmrqLbnbVaVnTHJHBl0WbET8XXfkJMxLKvqyjVn+Ux8MagnRoianjQSkn+LesEj96Gb5piUG1gAvpe5NNp6GP2qwrD1JIKHI6ULzHtTTdYixK\/V0HsWsCb1jVzXpYlsRJJ\/wjoyXXW0+lrF+PreSDQY7ycSXJm2QBpuQcvWU3gfweLupNmzZpSZPcPSw1Q9P7Vo3PgulMH4HvFniKL8tX\/smr6DF8nm6zQKJZZ\/6dxu9YOVDZTkDUT1bdLCEvxyOjloCB2xtEiY1VOyqFXtLllm72GZ8z51xA4CU2EVl2vfKvZlbIJKsSFlcQ\/GPy7nc\/acCW9iaWGXaYTsxi6ujIq4mIwvwDfqsYgKVsNHFaI4ChmKmL\/L6E6T\/npGSpK9wK9DCRedQmo0ojc6SHcd83yeidWFOq23zTnBu8ksP60r3zgmDgfDFjzqY55ee6boTxccAs3MAt09coqAZFmveKCsNOOTySK07XgNOj1Ol+3XWDy7NE7qW2BpUf56Y8+6AVQUul7S5p+rLdwN8lZmWPD\/txzx6fdlLSKOANZlEJkHRXEKuVH5qaj2V4ym+INvU2MoC1AVhiRh0C47w0kj3Y+OCDTwJOX8cBr1hlZRkoweiQsVrMpQuZTB2+UA81NIJPjspKX\/mrKnRU9dZBL4nXe1y7yW9pX98LqBEuzNyGqhXEdw6aASLY+tU9j97TrUhGNGnL6MZLuYgxQgRG4+bpDg6rXQRM31QTiFe9XlHTY4\/le3JM46onbIQMOtMyMPJfwQHiltPd97Kx6mRy5bseMRrXrj2yteXgnMFnGQn\/PYZeMGmagax0IUI4zUMUh64qClBO35uNZqYa2bHxUzMHZGWlvixGuMc\/Aq8eA5xOQii06omZWzBbzUKVwa9prfZ7Hn20G8tMsjQ+2amAuuXON5AQ0bqWqfJVM3PqHIGASFiyftt69crmFs+d\/+dYtC1+eg6VM4E6WksEhdxTs\/x7uqfBvyMCFi9bRsE6FLz0pD7Ytm0b3t8JCebo\/vGDD\/ayBjaD++qTRnDjZ1maOFiaNosZuGwWpRRfY66EyT9QStYcTCdF1yflscciwYIOL\/xBdKcbSN6HZTgdJ7wahOIIUItesLdEcMOaE5IPXqJVIhqhjhxoaWnxMl8qbUvyzVtQppPUFky5Ly3yohS4s4rTp8uPtS1bUrhWMva4PXWS+lopqep7FvfLG9w+tPAhLbqYVPqjshg0bEH3zZJq93eZIiRRFwhFWroHsLqR9YNek1q0km+MCjFdXYPUE0nws0Lf\/m\/ra81JHBGwpM2+pFxznOQuXDR\/\/la6Fmdk3nqffH1+IVYeg75SPp7GSmsnGLnjjJr8BjSV\/NeF7lOx5E8zRUffTeIkFgKsUvFhXES\/9C8KDeyF7PLIHDPne7HILjvNDzBdfbHXkpQcNWsTd5prdqdw5wnmKPqp+LUw7MjkdFKmquk\/IkzNQiY9b+G0HdbaiqFpOaA\/Jkcn02BBtty2DOT0XZUhFUTMstgxlcGHbD4e6el5XYN0oh7xyoiR+oAotI1ja6KNx4iBnHDJGfMvJrIPcPoaZZk\/s6gs43RwgIYFmuDIe3CrLFm+scp8RMCCMM1MJyIAJEjWBHFITwrr10yAYhOvxIDVu4wjs4S2Sn9cpca3hLTQ88+jo+c4pl\/AZSVhyci855Wgi5+H9PKkCQCQaEne977dbFKxAxoXwwjxgYLg168uwAC6WLX7vQCzFRDnjVAfDlhHhpQbMdpucoiicIEypfPbrIS0QYOVgdPE6rEkrXhUlipQaunfp0VxImKp9aBkTvBEsllbMEBJbACslPir0P9DgYTyUUvM0IwCQV8CeCTB8+bNm7erOYqOLzU1jTgUSNuDBVFhepwvzeZU62EtXTx3wW8AVi\/FgpopUIIurbxqC2b6c8d+OCzKG8df2rxr2xdSmnmkyZ4jBhFmi+nksKpgql6snZnDJ5fFq\/XGVZpWcNnN4T8Z6S5LsZQVOYlZSE9z9ExCVEFwYs1Cfb1rokezj0TiiPeHNksf9P5eM5HVzy45pN7BFC+W5igOFeBkaM6OmJ8p9kD8TFcYLaHdDzL0KkKprGaH+6HXVgSIIkHNsjIog1x12fVibWUXBO20e9oNBOz2+ES+Ml3FICnXWDIFlP5RDj9sd+26URNgEbdAT9EeBzNua01y+1m2IcfiYrp3UOB92n4ComgakD+T62MBzmb+DLBZv130qJWg5WQkz7KytFwsLtz4f6Io90FFKt8Vz6xiGAWw9Kopi0Yvka6inPgAYdoEQ3wfdyAOT2sQHGsTi71lAkeIMt3wgPPHx53ABH5Ixs0M5LA3tQxJzfLjS0CdUkEwcwJJeE5HvWfPHtP0OMztwX37LJI4S7pUZopkC5Sh7tAOU1mQvA6+k90d\/ahylpKO\/tYYn1psFqm13hAV21NgjLGM9LrHAyLNA+RnVa2mps2+kSDSVBEAUrJatTpGOt6QyleSjX6yU889IM47tF+hwIxvylbsIQBLhEOkrbfMaX15OyxXlFjdQhwVbHhAOUJlAHmUkASBFnebXEE4raEK3tLSGk3QCYllvhvdXMfTy4SnA2TL142TunAAtsu\/dGAnk0DGrF0Ua7AMfCmNMV3qHwOW2qyeYRJFxwM2UE1s9D76VJNVdXD8BlpOK7YSd1kyD36v4k6FsUOWZTLIauWPM4vBozbOd9pA8c\/yQfK6ex\/c8Vg6QX1Ic7MKwCJqz1lFXR2BFbSO9ZQsmAkx1u+GfZ9m+7D3ddM3D0d8fMQfWD0\/EhUV+0RmA2RHerVxf1wcoJ5Hi4YtBDNdRno4lsSQdSnUsImMJZ7KdxUnIT34i\/r\/AlW2A5Gp18g6liXs34AmmSMpaUO\/0k0wlpuJOz0Kwt\/m+vOaNgX4ij\/lt0cHLIvGox\/jJMC\/NLGMkAk4Yi6m+FiHxALXa36fMtmeL+I2fKs06ScgJ+OI0rPaF452QVZdVDaGFR\/XVqjx\/nHE3vhkDBygZ1xO4APBRGWDH8dKgmU0agmKxGtjLbEM9y0xM7hVsi5xiWXN1D+kRgwARGfBIaIX16TVJrwGPl4DjY362CJgqAQL9IXhKbz2OTYBadMmIHwlH6F8Z2Ypjg5YSsO4ipMxTh5mN4sOou7HS0ZBGhWHoLS6x4bXWuDfL+1xMQSeTtKWdnUxVLxFcwoaUz9QvNcU3vymaXRZtLGz+WAVX06KU6j0jE3Y8cXYTDnJK2vlyo+GNkzG5uyk4F7tRJSHKYTxDHrGp3lzKuU\/0SObFIIVkc1tS1P0ZTam5K1JSOHWt8kGKIjCImJuaxWh7kOaVGMiccSXiZ1UNABrxFfSB2KMfwtzBymW+gl7pN+c4sfyriu9TmRMf4ojOgxyKPD1i+cvfHTLju1r7Blf65NRAEvxEQm1PF73u2HrOzY\/0LlR9yYqQFO4pG3+V+mYOT2mm0AZGFda6in0fqBH4Uw3lsp0b6mIdYbUqjnna7dnFumznSDGlU69P0rptiWZg+AMK2k\/Mt+kW5t7s5Sy9ja0DgMyk+Wz3pQ8Z+Obn47FCqLcSdhSM5Af2A0IwGrpmnguVeNkj5gkmeVgulId0\/iYjwjyht3Bh5\/lrxkTQr3xGBkGkdVFNcxbxIqoa\/yRlhjGq10I7tOxw3UMsdV1bzyBnAsRRb2c59\/k5BskVWLAgyzSoXzwcwSKeNVb+OoEPpkLaefAgXPpXGxVXjXdyX8mFhuiMQVK6+mzN2ESXb94wYK7eO9e9RTy\/QjbfIka1puGrDxgJQfe\/9kywWBFikLdePG8haOhqF4bNcAxEyp7KQge4upxegrnSbfFaw4YiqrY3AKWJ17Ae\/fqXZUB6Q9luEVyGH+yqTa7n5yLssyXskA01ZFNocKlYmW2l\/mEfjoRAGdzCg8jiUdzUqkMeMUOkjYbvqAJz\/Izeckw8wVF7UWmrAza29vDsexZqGikXvrjZ+Pmru0\/1ulEhvrJthQIZgAs8OCO3iC+qqurqzz4tZo8LFiw4NjmOFzMcIs3AVTvxJo6nrhgC8Ju9YLpYR6wYjR57mRGPvwZ8f6RlrgmH6PvmgNd6ll\/LBcF94iYedrSp40tfTp0Vb+g4f0aMXv66ae3zsw15bxs1CH+JUt2u41bOg2wBFXAO4zxzSrtTxe7F5OKAZYHhzqkWUsUmzebHDPN9gVEc5o1\/8rxQbemEgauy+Ujm7mubcvKjxsnNXOg3bWrRiixQUXetbmlKIhEht5aPwiTa6wB1fTBbuz\/B5VgNgxiPIlTotZs07dKs15W0IG01Ksihl5N\/taqFfujnLu9q7Orb6xg2NnZ+Qz0\/UR\/bD7xRfYkvAnQekklaAmYeM7kX3YyYv2xZQsWvGBjZ+fPl8P44ZuEUGZGL9ohMI2avHm5c+fOARDVnF8HMqWWawmCvmdCZPGxrgdIvT4haWe5401bfkFmXkmMADrWihyp8gNprfS+6NXcXyMr5UgPwDTVGNzG65XQF7LTtMiWUxOeUBJWju4X7JHYcLrXR0SGxLJnqR+D9UjbTmbjh7+e2ttmYqkEFAzDnLuvaUaTAVbZ5+Uf1\/QrYBEA1BTJAR\/XC6wULQIoG0jYsB9EMcsKndXW84DLIUNAhcDXwLLsIHRxy67td5932plvLuaTr+JsPx+rq9w85HkoUGCowyxajVo08eeaSygkGzaIOD2g0CoZWHk+7HfjvGnxZvvIjTOOwc9Sx7u\/Ef7IFF\/NqbSxzP1S2iy8KLjllgvsPayVegvLIEFVnPmJzy5YvXohdF5sX1hHhDVHKAVERauRxsmPyrGlU3nK142TmjjAQn7WHMwlwW8gLGem00aYKaFopfoJSydbEhvYyMIqjbFOzRlCYEXVjxrblaVSx58h6dV4ISNG2UcY2ZbQt86ev3074z9wHB36L9J8yfXItN7VGCtEOrznoW0PEeO1gBWzCmwcEslIVW1UvSxaYdBvaAaCvhsRsCrzxse+mCpvTuJziKWP4XoDQfbI\/DmkbvcrdqaQJZ9EkUqhqXkWEP52ZUWL6IkzRyIYUG5KVx2N3Zuhtc0v2JfVttClLchK0QNsSCxzWnslanPWCpE\/EpQfPWlKgVCI6IJTT50Gd9+QTm0pZmYt99TlHjCdpBczwyqNTInqxAUvr3WKbIKjgQW4tgl72tvHRbfGWMn\/pzjwhf0Xh5+oTvZBZpKu1PKyZBY80fnQXD2rCrDSWKbkgbXSHyHP37cpOj6\/vlko60UhCd4S3LLGr+KZWjmHPaO3355P1i6P6LU8g7T\/iK4d+dlEH2ahSoyC1EpAQfL95Ko\/6Trs9B3lCUo35t8938C\/p6n1dWT31bROZFN5\/ZAe4RqRs5n\/G1wxv0EsqVuLQJE9B4OWmlG2zXHP2onW3paUpyhVNi+Yg8jkTtuA5egFrMpmYeK+wjZeJZcvNwvFp9CaWC0t7HfGjjUELJZScJi30JLvTPsfKn03UPoAu+acZU1YVTAKMpA1G7S3h7NwrW7xIGAnalMwXTdCbRyQH2ZtsjY6Z\/58lCJ5H7NvpTS2zrvFDHJxbPKH4BtbHtqyV\/drag5axI2fjAPI9DNp1ZzdsqMhGrxn8qZNhTpqActQmk0lLNfNuTvB7fWu0CQAEBDoV13VJSdDJnBvDW5Z\/WZ7ly20zAFvFxP7Y8DjLjIag1W3\/R41zHusWRqzbbpZV6nLoLlZhHyH5m2HTmjuqic1LUu70\/gZJwfUFMzWdCrFwYfCIPci22dXYxTFYUkLTmV6x3B7JtsjF31dSWl1UgCsUWmIGXUI2K448Y3h4vjQoOFVaY\/qUQtYluNsgTtZMEl4u22X5Z0TmaDlWSudvQlbZHr9TXDT7WeaL4uP1UwYyrX6XhlYrVmTt41b5Wh3ycfY0HUaY8OEoLT\/CKrSqe6xruRsX22br4qulSvNOVxfip57sQms5EtRzhlVfQlK8wGPQRod7svfQClx1HQUR5D8031dXVt1joNelUoj1IkDjI8ecQA3ZVBgfSx2Oz7KfVjmlF671oPy3se+RhX5n7bLs8+3t7WQTJpgCVvYL2D802ptaW\/fLU+\/q1OBVEZjFlxHR05NweDWW2cxQeF20l\/Mhq7ev+ahUtVN7FoZfpEkX3TvvfIbFsd11zWsq0pmjuMczA8rwWpp24K3MuT6Uzarw+8H6SsM1Sp4l9UiZyDjL\/O54B+VXOqgzyq9cVDQ+CTlgGTcApVFr11UmgnSUG7yTKPfj37AMk7g6zE\/kcY4BfHfue7uHs1XMOvFs0tNwwSwcIDGK+k5XMP7LeYE156GdQ7EbcpgY8RWrZrNPIovkO7L8bEBTJaYH1VNj5Vrac67\/fsfA7f+D7VMop5Blp957lhXSGo92S+gskGhcDqzrJgKdiXI8w\/0ALLInHXEDDYF5ceiW5YmopxYH7t3+\/YHFQe+q4Z1Vc+CIS6kewQLyxBL\/hsDLF+T1DnxyRQd2S1P1WEr+v\/GV\/V33PqIRqTBJdWSoapR7mmRwhw2zekACN10g+tt1yM\/BjZEJMe+4gs+fevZjFyXZXWRgSWef0vfJ1aiKZhnuUhV8dcmV17lR+PTxFXwr4z\/N0UBO8xxc2qOb\/yUTPyXAph2Vtuc4zrEOoG9WUbL5s07OXbhSuTgMj\/VJAUrkSRp0FQQF9AU0fTN4JYtXdu\/qEftyMv6rIdZN2oJoc10qSWGo+Zb5sv15kYYFipBRUifG4CVlSiZTrtLw80pEEgq\/eOErYQKbFTeg5kThH+dfOhD+1KrzIQ7i2MsRxSFnjyalUttuk0MUJUtIxzsv8\/swE8AVvOxrGTfyfjVEAYFvZe3pmt3923JVZf72epYZhnY2Vvj\/TFlxKPHQD1FsaedhTXRwPFGN6HfVQCDNjqFpSoPye9IIWD6ht+lhSODMcGdQZDSR+edfN704rTuN7KDwIewqpZqcChDGARO5WYg31i5qylYiuPvFJLiSn1rzciEqTp1ClgVlZba5CyDOuX1UNFQqKYIle+hFlJb+4eGMD5ulH0JKz+c8ueMYkca4uBTn2p1Ta2X2xb1fX0SSjW\/8BshrNq2vlj6anLlpd8ysFm7Ng9ojQOwLiLaO7VyKCDFYNSKwHivReDR+ymB97jmZlbr6tVzlYhvevqlqEM3gx7c7v3fwuj73\/pczci6gJUigxHkL2TdR6uxNBdOAyDndMxJ6rnVVAVYKNWxBAESfLcND041WgEQraKwASThmf7GHM5ZuPD0qBS\/yrUE72CCyUvlrwKnFCFaYSsBqCTMsiLyIE9nBwuGbCgkuSt+tWv7U5U+rzEnfuAHyoGp4uBcQoZWaOR3CWtQ+Z+QQJnYiPQJiXx8kdpUJIpVyNQn5vvWzgGRiSN4mXX3qG8SylISeJg11dT0WgaQvsJGuSv3nhEJ4OFcT\/cuhgau1G0xkMOAzscX2sufBWxB73615TwmGqygMP7ItU472Xor+\/rVBBRQeQGVNSHgnA5Y7e++kyfvplfw2fqBlbLkd0LCstDmBBog+XmmmNSQT0U5ehD4p\/wc\/cXsqbXOqUUku869jIXc3sajz2u2fvbKoY5K85wzzjhuIJc7PRcH5xDTRXzzcubtLlDtMGhVsfAAJrWVgLHHxl4V1JEMWP2CFtsf\/2rXfTvk99qQ+N7EQ6V9qOepyAHINg3lNefOnbv6V7t2PZUNrTjU97U+H3N51Jpgld9jNfRRGCX4w27bQ4N4hgI\/NwBLKxqgMDjeP9viZofeuupVb1zqt2JhHtsGPgnuSN576bahrKr+SoIAMBbc8ce3AIqzqAvmYiE9H8F8OeDT7qZNP8bS6emR9UDENuufI5qpnqkcw9tbAM793d\/FCntncsVVj5ad7CtXVk\/IyG9a7QUvmCDPXntB8Eb23rsVt8FqTI193FcWDpSVkWMb5Uk+yueisNizZdeux4z3ipgwyidDHiGgtsIkY59YZiS5aem8BYtZNcRGl4vO7OU0WjGyhbvNZJBdWdxJi9sWnM44loVhHMynnGez0JRV3gJBwMqsWqXhZcAqKFufnHtYOTQDo3g9W85dsvHBbdu1DlOHb6ZnydZ2NC57QGamz0tKSeH2s89Y8HFmXj1WigqUCxvnTkCI46aQ+X\/PwD8b9DoBSYw3SpUnAhl1M7GgSJnIf5yFirJ+DlhYQ6yr2T2vZz2pdhvdbuxAxK0S56IU4ZdILsS3dAfLT7WqEs44VtVRrZebV8taVTsbsHKnUiecih+q2ZaEGSB6AZVPEasKtZJYJgwQRYCx8Aq2rmB3z+ddqf8a9iV8WpaVu24lbZbqFZ0YRw+kqeYPUdqyswDCZaDXHyIuT5hk1KwqAj1XjMKYbeHy3\/21trZLIehp\/E\/iDUyoNsgOYpCJ9utk5yMw48MMLPAwTwKVQQlarvSBHnCtO+KaikXsA4BUnsqd3q4EKvFB6ywVbGCoXFdJvAaf1Yd\/9eCupy7G4u0ArOpdBkaGj5SWKW63MHlNFAWPYWCQPuhq7laorUMgMrGCdKJjwkJpNVGuVLTkeUyVSB1IOSgKsUB02IM4v59e\/D4Im+YL74DXk2CG7hzdTcIh1lVwuWvGT9WL78rLNKWG8DJ8mSPWzbTX+AnSGVaJj5LxakL6rl6XeKgSLyF8fQzeDXCie2A0fUqj9M7WfMH7znp7mJYQ\/C0O9o8pNQ9W16EoK6sloBoiy++QfVkwmmJPmyg8BqPimPLDmk68JaNsFYulBX0lDcgVG\/q8UI4xbtEJjSCVMCUV7GHikImqKsbDk3E445vS1YdERS4VeELWFaHACqDy93G8b4+D5G+3dnV+Rq\/Jr7e+wumve\/UNkCVCrAyC6dAx38c\/LlaNSJoYoYzLDVAqlahIy0EJZXwq3zzg5FDPD3h9XJeW4TgsdaOOWnb6+CwWKzd4JLil8rE9GEYELArf3s8+nmpHs66y1QxO6PtflNhFjCLPsmFMsuLKwEvNRBWgf5K9V8tRciJLyvf+CbikVgLJXB6gwvLtZ7mYnp7v885Hkqsv+79KTGBlDva6NAOHlOGQnEmDpbqyYki\/XoKpNAYwaFowErpzwf6xxutprKBUoGWVgAT30IFMKV+ELA6+EpBhbGHNKiZMGEw2fqxcAIw9vP1FFmP41Naurp36VD4rLYWi84kNQmFrHlIGVeVvzOTAjzTimOktAYP9yqEqfpbfnqAT9eoqxANN+8Om0jO+VtEdkScfhfkuNbnzhPNOPnl6BWBxywcVMZLuM2ocTR8cjoOlBwVKX3ToR4Uq4iVwVdOQ9QzefHMzzZPLXAH\/UH+f+S+IS9EqkcEwttgHvxt6JgoFevqVU11HpUMzBF9ZoZCzJqIsr97S3WTp791JJ3yG6UCGpOmSMXVUlMEyhQwtjlaZY6OcG7p30P2h2RrDFTqYRlZVnIikb+tR0nxZpMS1ka64VhGqimrwffE9DRQAbaxAq+HnjTLDP4YyJMkDyMA34codWkhOr\/NcIAYJNiYrjaHmg9HCjx0rSCtHTO6UwTFmsvz5qCfkP+WFCXj1aQgrVDL+C5PjwXJJoxw15eoeUltYCoVZhWfj7tJj6aWIRl5pANhQFq0Xn5zaP23aaRWA5RPwRPF6mbNZhqsjoNa3ZOZY1Uf6pGyc4UfHqplt1lXWMxjksK7oJZJ1pfgEHuVCHEKtSrTqNIZ8OfRCPhIyQTJaNFBHXauJONCvGek\/h54vQ8Xa5PLLntKn1gRknFY2j3FodDVdGf9UpmQ9QwG7VxFrPfJs0Y0nIuy7gsY7CaMo8GYktIK08Zzyvf\/Px9mJd3IDUntI5F508buRi7+WzQtUKukI+Pr6qw4m3+SYnwkrg4OTrOlOBZ2IkECMAFfL5wx2qynMSXmh3urFbQvvI\/LfSiNM2eRdbaR+Wi525xpghXGUZ8+OGSz6TnnG3EOAWE9Z7d5ilBzHeBXDkJooq\/rjYIYJcMR6zqnbQZ9aV3NcYmJdOcC3kYOqyeCOO2gPB3\/pjsMPrgnEGhxoCnGwpTFyTGN8gkvMHOjMqWYRvj4GR1BrJPeT7k\/BjB+4pvBH2XIyB45+H2NKo74eJTPIafEYdYLiN07L1D4ZlW+jRlrFQ2CnWWmy0N3MYjxNgjRqSGtQWCS+qdBqQyzkV3YBbe2gG\/2iQkh2w\/f7if2eXBj\/rD+fu2fbtu0890G+KtZlElDV0bLNYueYJMiz1KxCmLmoeGOiTy0trz+xDb5ME9R92DJ8iGxF0fg4lSUdq82aGEJeDBNKYAKdBIYdrn3476u9u66SBtYaU+lrDBzlAZe4SNjBmiPdt7liqfRmSzQu0EMRu8+VotIMXhngBTll1f09HXx7GJKfSQkYMYPVEjjCexavBgdubFvw7WKx2M2NZzMTnW8Cds9Q1\/XGiu+HpYVvvG2mF3sjnIzBve7JJ+8j55hYQ4SmIqoaT2WNeuNZNHUjjk9yfASrtgtr6n6c+dszkFJKZaDSKqd1DpkA5AZy\/XFh4CvFqLQI4nqwsiSg+pvQIMUfiAdmUVY\/LxQLtH2dm7NpU9aTYWnzTrl3iE66\/2CUxePgPE5wdVBoFdzMGBwLqaQoR3oYIDvxU4ypeyKKw8dmlvY\/uuHhh4fMU5Nctbv2gIGUEwVUZdlELL4zEJXgv8tomPAyOIBrRgvzIafD2B9WPCvTWHGPsppjZZWP3eOlXPB5aNfGpvvgmZYoFiZM48PHg1z8hL7LFuGrjGMs58Spzg9vRrnoTsDwMzBIDvZ+4ZDFpZcEXGz+oRfHEv+UejdYwTLCrOQ5GYi2Zuopp+Tc7t0RTvUhCjwZ6DsSNAwK6sSnfrEG5ba3S8GQfY1faISpyIGjGrCOVIFIEZ2WtXnqqdCddVbi7rwzZlApenIU1w7jZDasCrF2fE06zjiGfNY+uHTxzJkzk9QCEEgdvTXzEAYc3RdlwJLgjJRVyvqw1Uim7CM3XSR3VQuexXXddYfXBGdpZrW+xkLnSHyv9f4heFlr9If6fkxldajIpurzI1wGB7JtTGUC7YcdE0ZLU5kpA9aBOWtcNzjQ4ECDA5ONAyMi6GQjtEFPgwMNDjQ40ACshgw0ONDgwJThQAOwpkxRNQhtcKDBgQZgNWSgwYEGB6YMBxqANWWKqkFogwMNDjQAqyEDDQ40ODBlONAArClTVA1CGxxocKABWA0ZaHCgwYEpw4EGYE2ZomoQ2uBAgwMNwGrIQIMDDQ5MGQ40AGvKFFWD0AYHGhxoAFZDBhocaHBgynCgAVhTpqgahDY40OBAA7AaMtDgQIMDU4YDDcCaMkXVILTBgQYH\/ELyDT40OHAYOWCL2mkdxuuv94srbtoUuKVLBxdmnESLIB5GtjSSqoID5QX8DrXSXxVxHfjKoADyZBKtwHkgnYf7Wko6ppUfDzeB9U6PDAcpOHmLXluawYPR0rE18LV905Ilidu8OZkMS0wb0I68Gu5o2Rnp2RAeHC4dSfMxEk11uT9ReSkDVl2oHCaSlDlhOwU9xy1P1rl1KiQrqInK1DBkNG4dZg5YufvlqUM3AkDZO5\/5TLOL4wL72bP1bFRMrr66vAVXJckGYGyOK\/A62jbxgA8hOyCbtZnuejQlK7RU1wPlRRukdng9N32vl65POGBVCl3lOZnL9jq09eLrlaHKNBrnh58DJrQCKu28XbGNWbBmzTTXFy1ml9xlVFdno56ncTwBmZ7O7msFjhJs7Xa7jw2\/HsO22sVztmfL3ev27r6\/EqRsm7SjELiy0hKAcS4AOyo2z5BMAGJhPcDYAGvZ\/PnnxXFwLQxiW\/dA26aP1xkvobMmD8c+BG4fq8Zrj75H2cxyVxTGO4Kmph1bt27dx71yWAF41SMz5QgrTsSsDAwXz5\/\/qiAJ\/4TrIpvY0SxJxpvPihSqP4UUNYWOY4+Kr2zesf3z+pJ72gPysG3yUT21Y38zs4IyoAKkCm4gfhky8DvE9hvIw5kc57gmtpjTxpwwYtgg7Iq0EW2RzU2TR3lvE+\/dCZB9O7n6sl9k3xhwLV9uW9dm9+p91Ear69evLy2eN68tSHJ\/AT1tUPcM5VYP\/28vOM1mr8FuZLEzDpNNM48\/fvOGDRuKygdpiEG2R6iuawmKK9ODpW0LX81us+8ivgESEP9GKIjqUyQC9hF0z6LnT7AFC5vXul0ll+8674H7d61lP8MspixPXI8LjD3Tk\/AUNqB8g7YJJ1NZ3OM8Ku9pHJxqf1GLk22Ic0nwZNJffGBJ28JfcvfOMB\/8973btz+YZUjAlfK1ngo8SFAcnsOuski46NOfHh2+oBTZl116+DinBljtfoureub38GUoTcmE8LrrclhBtnty8IkvTHet3W+m4N8Kn1\/kmpqnO+1ALVwWEJWEQ5yz46l+0EyxRqfUI1YogQFaoZB3udxpPD\/NlYq\/DePeH6y6bT0q\/Pnk8su\/WQbGdew\/WWHNpWTV5bBnzx6QFTvPFY6LXfTGQr4wq0QeyDN3PdnjSyj93nROUbGdbBI83v3E05uXzF347SSMUItkJ08i0lJrZFwKznfloHIiTnYuTc4r5PJvigVVNeWhHHX5ZDDGpDt0pcc3zp3fuXjegp8HcbI+nDntLpLfz8sGYOPJlwEWhJewqdiVPikQYQQrrZDKVIzrhJJI8cAOQVDgxklI50nUuC8gzfdEJbd98byFP+Dev27p2taRAdd4MlIViYkbiFAU8qi\/GHqG5jOlt6q4xvGSeMs2tzkK1XZEHkcUk+4Ts6quu86VwWr1bW91LclVaPSFrqU1tZQEUAMSUm0jL7kQp9OjFYHnvP3CHQGZtCnCIPW2Rghwha65ZQ47aa9wvX3\/K7jl1m+DIp8EuO4UWE20tVUKSmxJHTwbxfEspKefrYibIVT6WUOo0BEsBq7QjeAk5ORi4OtSKvbPNgfRzVw\/zUOFmqxx4vH0ogdxDIt1afdIuTJkV3o7O698XnmecaDiPTsNQ+00PY8I5sGvVyZBfE3c3bsR8PomKa+9r6trK0kLjBWqzldVZm1KU0ZaJbkjnUOzkMEeG5eoQ+1oO5KbJUXxB24hbyyEeW9byhb11Furtu7cvj7NSP2tLcw6owm60BY0gu3NpR5ZGDzL7tT1SMFIaVVbVqTUUdc0DmdkAgmAyteWN9++BJZ+hEJ9o2sFqIogTW9vDKP1PCTHOc4zv6XPv5VGBSsy4jNAk4SY9CM9MWZNf4mXaYo1FZpcLv8619f78mDVrWvcQN\/fJO9\/\/5O8GghAK\/1dWZT1Pw6lmyvdGHpz9ESlI+JA9o1BBxkVcoW5MJjPg4\/0J7nXLG478wM8vEvxj0W5R0oerpou+uTNyjUul9\/PKNKNyvPyC8OcDL7Hmdd23cryE4ThNBJ5IfdeGMTBpUvmLViLQ+ZW8nW\/XlsRrMAttO6QVuSghWHbfxohVu4q+8G\/qsnOclImn0hC\/UFTHuHLI4E5iBRhJVl2QnkyM50ieiN8\/OaStgWrlrS1ncJzDD6sIG8OZ\/HWdvS1O9kSIxPoInZSlxB4GmuL\/rn0NcCQz5phWDtvQ0a\/46a1vhFLCPuxN6LZVzL20gqG2dakkfTCo9TKguX5fAj48Nfk\/wqc57GkTPaMm3rXNxsF9PIbBVwPDJRII3GFphlYXR9whZb\/DFatejFCZz2IZm1NTGEgJhYkOpwM6ojJETRyd5Q\/XB7++aDe+Ugq9IMcJs50A\/l3uTC8EN5+Df\/ra9O0BVoZHemtsR2kchYBvxylB\/6vdj1QvMqLylvGEPoO9dJldB3rVHpPaz94XhiE76Ox+4PFbQs\/KD\/h2mStVWyHylsl44bJtbIGBeMJoJCAANYQgwDC2uCyamiKkSnEVX8CJWUmjqOEZFrDMHcF+fzukrkLXmnfkVn5toYhrn63xEXIHE82x\/IN+W6ioChCOjfKob18NlVOgo6OfLkJuOrW68nPF1xr82lYVKiaHFRW7nngQ8rnQQr2GjhNaw3NApNYRKU+LLEnAKBHXFF\/xac0tAEgc7wT8AeAAWqSQuQkjQvZCaUMNGz6S66fURDTpr0Qkfo6wPmH4mG5iXhYGJrpiOQnd4i\/0D\/P5YIcNhRgZEE6kumH4Zd0QwoPN6MoLuXDcA716x2L5i78DURVxoB0y\/Sq1iwqsnIYrx6g6xDkaSrrO1qNrhM\/QoD+kifpPUmAW95QwYo8jQ8\/8ejOB\/7tnDPOXKBnooUoRsQlMWaEQFJ86SNJNKxiAFaNGNGQSALXBHGtfDsNBc0Ju3guOxG5sz+Ez7CQFIw4MoJgxyBxkFA+4TIA7KuL5y58\/5Zd2\/9evq2LqV3XY5UNSacuF2k+XdKHSjyBGIjEugjDgeTBzVKxVDyRApTT3cIc1zFEZrL7k\/Wonr\/kkkuKsrDc7JM+7Zqbr8DfhFXVV6R4TTCtelJ5Cq5U2TSl7p6B\/icApg0o30+pv7bw95BLCk\/xVtEgvFhscVF4gosH5uJkP4f7LyKuX3et01ppEoYAm9iCUFvvripD5BEh7+lB2lpOwLf1OUBrdnLV5TdnoJVZgRPBTymkFBWB6UYz\/wVaHkB+pwU4bEZID9EyHToGOcOf607nej4ZOVHIRc0t4cMnrncQwbRCN9DKhXMiF33y3Llzf4d3nkJvVImbgo+Q1hhvS+oFnKYHe6HPGj+HjITKl2LG9+1a+LwFfkC39B1OcFMZFp\/4ITsCNWRE9wRcPFAe82HuteTt7CXz57+H+\/9NPCJlWL\/W8ICl5HB5EjuRJ4\/D\/reHuXgjN47JFcN4gLgOzIhMBo3403EgLBaSUjAzyCfHQ+upcRIsgrZfg+TnE+cc\/igcZQZhoxb2GcmASxmJZW1N5501i9sWzNyys\/OT6wGri+sOWmKnr65I6+fU2++CngE6e5uKZFjP6hpILZcv5aK+HF3ZPmQdDdn1ZD6aZSWwWrEu5y468SbX0ny5G8BXFWMV0UCTjkkYOUqRcoCZd7r39W5AAr\/Ii99xhcL9Arxq8hl8gd7GZ3vOlZOd6u7NNP\/mYoGpm1VlI2FXBSqQTHgH0GtmGEX\/TYCWK4PWBPq0kFu5LKRYz9LF94ktnZ3yx1QdFi1aNDPp7z+VLFwYJPEfwLhXGXDRdCJLWJZeccldjFmCWRW+sBQUriKBv+ZPaQsUDtLFqgmofDEISqRdwFD4OcOPrgaBHiuFwbFJVDiorDJdbwJbB3Ilyj1oLsTBTAplDlbHGRTMEorn+dB9DlZkC9fikel7CsYi3YCLd0qYkSG992dFcbSWltXbePf7ekHhwPwND1hkBFZ5jzTDEUpRfut9u+57jNv6G1e44IILCs8+8cRCXFmvQK7fCkpdCINy6q0gKxGpWbMPGgWSsiWLnDOg0N2ApbVPltZ6QEvPeVzHmkXZsQph\/8bt27ePK3PPgY\/MZ5UOW3C\/ueejrrl1EKzkpxJYyYhG8\/BjMQqAouvr20JZ3kDxrkuuuvrZA9kkB7nd01xCBc0nZB4hGmhKmLz97d3cvUt\/+KhWu77+9xD\/FTQVZ+HD0hdUeAZY+r7g+jHBmpubAK0bAK29gBZWj5UuhPk4dV33IFwpBgwuI60RLIPh0kzHI27l2Va++8KStvl\/BPc+jl7MRi\/KoMVzuU40loKRD8lbl82b9\/dcP6q0eFYfwCIeK4Qk2H\/ezh0b04r00eHorubemWeeeUxuIDkHTf49DJYV1okA\/coXSZENo12Fo6YvXSoxgJk7KQ6iL9D0fRP5+5F0nT9siUFQHhGwMquhvsEAAEAASURBVKKIGj\/CwExdC3TuvvtuX7uZHAxhlvJ7IPOUlt1LB8PRDHBbzjv5vM8UW\/a9hTbDn4LAi3glB1UaTgFY8QuVxFQAyIpYY4B3fCPI27V5V+f3lQaPD0Je7tcQIJGmqPInOuUE7OjoUD4nIohPQwphIhKpZ5wClrLP6ubV7wGQPmzjqeRvCgAKH1SFxq65KWdWV6n\/FjwWf5NceUVZ6A2gNL1GQfMDK8DJR2FCZT19Gimfvadev+TKK3dx\/ZfBLbd\/FV\/Z\/49193IsrRzN0Qy0pAdN+LSKAFqBd24MVt3exbd3CWxJawLcCRnVSGxolatra2trQjzVdvX0l18ZPGHUtwUGSytIP6QmqoQ\/Q6fT42jMF7GmZtLS8KCFOqDgekfHs6MgvJh3sVilKXXTBU8vo2O3nnHGMcT9FKDTTB0uC0vPKnU7y1vlPdFXvt62bZsqqB\/p77zTzlxVzCeXEcWVeO6OS5u+6Lu3ssiCWWBgWYm67mQXxWtoHr6G6HZdrI4WRu7xZ+GQgKW3QHxT3vmA1d1VKpsYqW9FjA4qJI1mJ8T3PHqPas476A38FhFfy+PLZG1hVkEYvYke68WiAvZXkUxMK8XRDWeffrYy8bAAhe\/LmeC8HiFJwdgJrERnPSI9KuI45RRZv3Fw8630WNEcUVOvt3eAc7MqKD+BVeRaWvJYVU9x\/\/1YN59T3k0O1q4Nq50DiMQbkGV8Q4iCrNdP\/qjkqks34Ed7resb+Ft6FK+hGy2nRgVfqWmokIe2yE2fNsd193wyuPXW1wBaT9kQjAkaXEqaSRRqRKxzs2fPjrq6usYkO9KRZcuWFTZu3DiweWcnPeULP05j9yMotPlxyBY+GPnt5NjHuRQnLyWpLyKjNo5J6dYzdOfzRv+xxx5blR5YGUNAqusixZcEfJEe3fPQtoe495dnL1jwNRw+f4e19XISsJbSAaCVRIy9C3O5JdhhH+ObN6\/3rSrjgyL2JrnORgmkbsipGkEUjPJq+ZHeS4MyrWG72TAFjCYz9YLNO3fu3tzVeTkRXgZY7acwAKJAoFWOhwTztHEjHHPnhvnoQ3qgqRIXBwZag+\/V56wi4fpEONVjKTvZV6+egRhe62bMPAlAUK3rwUocE1i1tgJW\/TjR3YrkyhSsZNkwr9CABitpPLwg+sS+TweHGvBccklPctVl78NZ8Vc8BaJogspv5ksPHSClXpqMLc0XcvfPla7i4HamSOMhZcK+QT9igVVaEePndJ\/l1i70xKcpywra9Z7dCIIlAFxaWdQ3T2IhxoPnZJU5TvVcBwM4jtJ1AbhaQ2rWmbvnvs7On++P+mkiJp9WzgACBlHbe7xJBu09pq+p1ejcisXzF16iEwWeGTOqAiz\/SX1+00wpM0EGOlu6tt+OmfhOKH1mELSy9Dyh1CoqmcuWzl3wCj3pcB3mdMzeahzrzwEpibv0Um\/JJsEfMyzh1dYjJ2e3iQ9p4uM0y6q3dw\/TM9+RXH3590WJmmFqRqo5Vy\/KBDpuxfLY5igSKWl9lKER1yLNJJjN\/bHUaCom6ggQfe\/B\/\/Wbdvf6601x7HwS\/mDZG1BouhqE\/1TIq5xxE+E3PbDnXJ6ae7r\/xDQLWUnULUfmPqtDbOi6goGXwEjDkx588MHezV3b3wcG\/5UycyBocQt\/ncPfT95j92fLFiw4gzgkQ4ZVhx2wMj6IiPXJoKW0ddeOLwdxeDXoSyekLC2afGlRQLrMxxL+ribmR1yjtrW+b29vn9QCmOV1yh6vv15TtZLgllvmoTKXmSM9juWf8XxHsFwe73o\/PXRheA1+ph8or2YFTZDPCGFObFiFJlYTkquu+GtA6zZrplp3usGUgCqP853O9tZjaU1dY+9Ck\/nRdDHJA\/ncLpwiI9ICAyr0wI6g13H9TdHxykLmD9N5vcJYLaxq0kWMIlposfzEen\/zzu0fJVcfFw4LzChWX7GRW87laVfzdyF3L0\/jNwPliAFWlslK0Nq8a9sXoPMT9syPQaFnxL9JJkJ17eJ0fG2hGL9Cd6mRJqQN71N8bv9KsbGOBE7oTG4FVtSy1LryTnY\/zkqTk\/XGx5MrLpUTGMuKQaUT5ytSEhYqQQsZ+XPX23MXNEpaEHwptil6yToHXPJqeg1fnX56xGU+pWO4gwGSPQhYZkchlX8758e\/kDRRuc\/I7qHwB7yVPZlcR1V+6tTKQOukeaf\/OdbcN2wwtZGq6khZNme8WfZc\/kE6qDQBnLXGx5EPAq0sE0lL\/u\/IVwcoL8LJgC8iSkQjnulFEMnBW0S1GNCwsias\/GTlOqyr5\/H7JgOmZEjvV+SmTWfwXd8PXV\/uU\/buunVNycp234ScMLIqIr7kErOYmAD9FNLxF\/it+nEA2bCYVLXz9CQmNvDUJW\/Xl2qmTgkrK7HBsRWZHTyVVoSBd\/IP3p06Z3Ru4YNmIDi+aJZ7+jDjxR9D3+U4o7IxxOLXW1l4H+aWwujNyp067SYFYIkYIa8ciRqbAlDdiJ+915qGjHDJapksE+DYq5bNPZPBaYxUS9v9Om+E+nAgrbFT4Mm1Y6xcQO8fkccGYqo4HOusuJ5uObpvSj54yRPms1q+3Ftk9SHjkLEg2qrNTIaTK65Yz+UdttaW\/1LPGB5Dz7NVekF7cONqBi9bmDRyn9KTHSospZAmH5fKRUXwLwQ9FM4z2W1V3Nn5VDiK3o40Z5t2bdsE8TcqX8idVjKxpiHXvhdRTUYX\/t4Fp546jc\/wCE2isGnTJjnj3aaubV+DzG+LVIhMa0xd0b2L8x0T8qQ4jC\/Su+p9JKOTKh+ia0oHv7aV79QI3CuZq8cQzXSOoDKmUXLNLTr7lpvR+h86caec4nXJLg7fj1lMrBphKeaC22m2PmlzFhGclAoWTqJTM58\/Ba\/Wq+ye1omfnMHoUoUBixeLRDUxYKw4rvOUx8njzXFsg7hldUzOrIxOFcVTniNMD8ln6XS7T452Cyo7AZUGjVr2knN78y0v1rNJpejKRLlpGCTrNJBMpiLlVenLEkCp0nw5RxNUmoX1zseUFAJf2nX59fxctWoBsb3E5gqqee7lKaJ5WHDdDKULwi8n73hHn1lXVU63qQt1B0ayebNRRtPwV5D5VescsHfky6KDgGHUgBj0Bi\/jRRtmMdmahchycP7555s8Lz59wVLIfFGKueSBwaE4pTN558amX+3alU3vmrKyCtha2NjV9Sjl8iVdcFTT0PJE\/m1AKXORpzM+ol3P663oirOmMPPuu43YIIk6GNzLnA2JWLkW4YLcCICZl8iytadZYh0ddqjxJ8iAr921a+wIgF\/3P6O\/Rjon\/vMlS8zSZZUQFMcttEnHGsqgwBxTb10lv3JJ6U67d6TliDW5KCvP29h91fUwBkvOTi8okh8\/RitJlrpVq86cSJpnzpw5JgAR3Rres3TpUptlYbSFyfvpIZudApZpMfKuVU40RYLr4Pt6j08nnf4a\/dX\/CITTPMTfwkDp4dp\/rWwKvGgGCgOwLV+gd71PovoEJvzNjnQGugaVsjrhL9CQ8xA8pumIZuXG5iiIjrlBFCzkuEvfkJlap+skGuGuiBnjpbEjYxI8fXc0BFkeNLNSwIqW4bDO2dpTmFMya5EdrACxJrgrnS7jmEbj3z9CDDDZuO46yTK9gnkmWkebXaF5iYvZiScL8lEHwSmIj3yf99e5CctsfoZ7Evbdf38TA0Ddvn24Yg8RNHMEMRPvUn8hrGxb+GfQ+S4Bk1lVxndxnDlyKoI42VzM0xRPw1SWU9HO2CwDrIF8fkuhFN+LGr\/I5Ew\/ptRUNvK1sx\/A2XPnzp10gKVMQGc6bN\/do4LjWiWmZmFeDRNJoQaY8qpqyx+k3yjjgwKaFmh1B8PBEvEYYCm+6r4b31tWDhOcxvgos6\/ER9Xm1A\/hQt87iFJpXJMsFeZNeAd88j96e4KnvBhBY\/lJ3nfJ7uCW1Rug2zplTCJkHQqwcrkWpvGcZfHNmmVlPZa4R3yXIR5xGGm6mdvw8MOsdTP2sOz0hQtZh+IaRP0qIR1yrzLwA3Tp5EBm8hJKgOuO7ds7H5cM2eXYk5qUX2juIcul\/xJlfxEEmo4rg8icKSPnJ4ZJbv6kAyzRSFteSqO1sTYz7mofZYOdPQgiBizqBk2CeXpfgTEalj9\/VfWvviFiw6czYNgfE2kJOzWPONQNtAIttejCVkzE7afsOv3\/Qr8E0Mzdqik9XC9mzvM1azQB9nSfrMmPTmOc10xu7mehvWSbPdu8WX4XWQlHNgx1pN\/L\/H\/oofbG7qYkNQGPtY+aWLo5OkOEZlN1KOTayxlAxMKarnhPP\/301oUPLSy6dl0NDWZ17d5dwJpo7o2apjfl2UEodGcyi+NlDJV+PQvHna6JwYCVnxiMdCIrlhGmpoG50Q\/2RwO3prEOTtUZmsyUusKPVeY\/un6vtFFgbDpucJXqdeBmUJBtkxKwMj8AOdkF5XuRO1aLKOdLBWLdJWTq1Kx09rS3jwOw7BMWREGYg2AZ0v1Zjt5ZMyS5LJXxHVncy++WU4q+\/eRJW35GLKXUwVq\/Wn58pB381e7dno+l0jFw+YRsALJkR9rjLS73hCsEjxz88RG8w3Zf5dSDsJOlZlSmqp8FV0Y8ckThJnPK711\/faAVI8rXYzxBgVhlRJIZHAsifmzJvIVPzMw3Nz8294HYdSlNE1rPTztHEZtYSjVJZhTyyWy+PwklPV6rQotM1oOyPECuOd91kyzgjcNAjKMHqKI\/+ODOB3t1j0dHvpIYI79GeF15FECh08kOwNsQK3sXHhn\/VIQYEqdOSsDKxlYl\/YW9rhDthfg2SYWJQJoTk7IgOEE1muYnZRkc3xGeSPDKhsT4YhnpKwkXxcAE3aTINl\/jVpCR4q\/r\/VNO8fTFMRZDfgbVvWGVMUgFAAZweJrq3o\/Ezt6vKxHjiAy6guuuk\/9NC6w9jjHYxyBSmoDKgDWt1KzV8kUz69WMJUUDRPSthZay1nmrKhiD+UEZDag0uV8f8j0tCzFYQU81QJSdS6JoNx6sSzbu2HYPl9Zk9+8cNb\/KM8AV7mYrtWcxHI71ubf8GT+MK3FwwqQELMxECz1hTze7DNgAOTIADHva7SGlCSxPb2lp0VSRXjzlNYZUgmqMZZjPkTHtlqOF+ScIEYdJtA63WJSP9aVAWv5MNyVTabzdWFo1VhJ1oLAiCquhV6yTMmvIYR+NVzb2DGywWMVrQoUW99RTrI\/jesprbg15YawXBlpqrqkZB7OqC5Ln9E3pYgVQ6S654UdDenBl3Y9Z+JbNXdt+cbFfG+qo6hCycksd76zTsC\/IBc9SRsz\/PJiP1A7TJyVgqcRE7osfemhg49wFWnlZgXIdmguMrhDvkC\/4dnunlh8it224aolj2G9TC0vifLSY8cPm84jfxJFpQYvfoOrp1WE4AFUa74V8kqiadYdKWyCl\/\/ahEXjAF\/ace4qPBuMsvbM+9X1WEb9FOeV+mlievMQC5WR+uKBq09dIwz2dBPc2L12qZlQGqpTdgTlhZJlNQYLYjnEQXI5OUVvA2S6He93\/2A3IEmspqiKeGkHLs7BIH+Ri23qS0yM+GEyK1kmXDa1iqpDTFCKt+JGRDd2yEk1+kl43a5avBLP3a80IMZOA2p426wL5sTWgRjlmeqfhDAN8zBGALUuGqSzDvOMIR\/wiBpF9l2XCLxGZVH4VY5dqJXxyfU\/TWKA\/8mJcMDhj3OSi3EsWq932tyBn1vti5rYv0FQKpUeu59geTasitNvv+H+QF2RB8lD3P4hixyHIDtzApPdhZU73MFQ3\/X7mQUkbCWI+J2a4BMdyoV5E57L37eLI\/UBdhQM9PxtK8L9h7JgNI94jLZ72Z+u9mkQGIix+ymKaJHiIP73DArvypucZW6UllTVkQb638nislHDWQNeySjkA0K1iQ5Y3ZBzmG68N2Y2pfTQJo7RaqFZM34fLDhnuy6yX4Z4fsXvtKi2FXncM9eRxdo642TH9seJKgifvfuQR70vpqHxa5bkJMM4EzB9waiNJfAqbjc0vYtaRH3GrpiojH\/IaHZFRKzFum\/nIWTZBmBnrk7N5mDnRBwb2uXyzemjTjEjp+Wf+YfW05VnFwWkDhckR6PEzh7uoiaP5bPuFeGNISZLUUpOfRADm3KP6sVBDD2EWhSwrsMPsZ9wTd9Ei+G8kqgiI0TrILNPsbSNHg\/3wocWzkWH1cs9DDOezDLh6\/mSnydqSv1PIpwqCnsi4SEuiwOiYjy9qa\/sF73WRJu9MfRdDJfCGSZ6mb3zQiABxzyt\/sHdSAta+8883wGpuip7HCs8nZOSK8DTYc5zuD1N4Q4Ase6HKo30rPWTs385NOzv\/scrvanpNhQTZpj01RTQRH+\/e7fn5zDPPutknPuiTyJpTWOSaA53LH4dmadDufx3pUe4VLBCyep6GwXlaZ9gF\/ZqSI8VmJx8el3BuJeFOfVOfnkLfzqQ4wRW2Lm7OXXnfffc9ofirCfPmzWvBV3A6AxReCNi9ljhexxCGVu1zZ\/Uz\/UyAlmSFTRWUhWB+FOc\/QNxXc68eszuqIXOi3ynrAqM3TgPsW8sKjZbT0SbhE3918cikBKxsHBZFdDaKcYI17vVjMAXdVPvKADnZnnGT6TQ1AICY4Zq1kikjbvu1zM2cOWyxVsegQYPa5EKCxl+5TOqYRL2isnzLWmHE+DazqKw2Nz8QE+sxsaYxXaen59eVoA3AZLWEejezxpuZ4NP\/cBIQdaEfOEosXmb81mP9\/TRzg\/st7qeeEsDVZOVSiDGWD5unxN24Um\/YfN\/2J7QMML3cKmfgRibSwSEr\/66uLq3Zsy39+2em5fw+VtTfaicpAIzoTcgVDcMxXAl5x7+aLF8698zbtCwL39Wch4OpO+x3yjwCp5fSUEblo0H9EHKLjcwzxLvVOekAS6VDgVpbnuMFFJ7fdFVDUpA+laJOkAhWZgu3iL18ooIbzOT4eJ6kWxo5lrkpT9MZX1RT9ysDqjIABZtYFE+j2xm5yM40ftdeKbmslguDG29rS9532U52xDmizRPEOWCzi4hBoKjwwAupz5bZhO2KSo4pRSqUh5nkYjKD761WeSFRX\/uzDu7TbJsjn5\/7xcKF+YRKT3Ks6+FC+kzPtUJD2NfXF\/gdc7b\/O3sOdtHxvQ43xUJAy1taSLhVz1CM90t7972ebwVYao5KX2rOy3B0Ho57y9NE\/CotNi3HdNzKVM8EV1zA40cBsm1S9EkV2lkpQQSdferZjLJmaRNR6+dSaTiwHqnm0r3tSdRvtaVWWZjKhaZMTargAQgpCTehIdttaRYtiawg0OpXJ1twLjtHXmT3JE9HMrC5RLn8g+D3HTvbUyMDsAYaEpq0Yg42GsB6WutGM5CRD0J2QCZoaywdRc8hglnbWrhSYCWFhdwcS60wn44NGpB1rv1SK+QAibfh8JajIPxNe6aX7JFSnHqBPARYo8qD637qqUUg7wsB5jQj5FQM9P488p9s2bpzZ9ekA6x95\/tZ7mFT6bcopF\/zZVIuDMsN+eRGctfWBx6YXNNDymRO+ROvzE892onQ\/MRbJzRIvCxpUlvRTbfOnDcGn\/1sC1ZZKdvJ5ojkPJ1HGNx8+3mk\/3rbyNXcS0az1u+if1Z9HckPRV+6SUbdAEsRMzm0pvgEXJm1Uejd\/x8o6s\/Vm+iDRy\/Y79NIkrNwvp+RPsxeSi+n1EGGhuWJlVdeT2PqeDodfAbIlfIrUBMGYFn+WA8mFWBdTPdutkg9xvbbyUAeq5gmiDZXtQyo1rHt7Tn5blY02bIw2XXjWCMHaF6ly8wwZzv8rm0+kcvLSkkVBvnpx\/2SJK92+\/t+11KrQxNrPFQPcZ4H0Z\/gXzueFUZpQQxqOzv7QHn0MIbW9y2NdMG\/8aQ3kd9gbVi459FHu5H\/X8p4Qm\/LC9qpCWrqHAQodk49jBbI6lQGLccGycrLHyszALVGglt+yFYs0AbTngzCyMpuUgFW1jvYvffpP4T03\/HISvPdykMoG0S2JlDiNlKn\/bcyqM0nM5TWdSPUzgH4Kb3wzaiQIbkJG363aJaLNrnVgWclutymz+Cd5Gp2V55lVhabUNjzw\/STCbaRtHr1Szi+0xXNkrJb\/Eh2WBbH5P\/\/Jlddcq8eEDzw+vPJ+RskTxphw2FRwpSp0NH9P3UDYFSewJ3LRez8HuCzMzhGvgylwC4NGreyu2vjjh1aNGDyWFjqoZN1xSqibUDUhzSwDr2Rgph1xREtYiEv6Of+Oi3wx73GJhRiwsQEA6fkssseRoC+nI6\/EiB5qdJwgR6Wfmpuvojx3e8VCfQUDmi55IkhZ5hY16yxLcWCm29upvFwLdbVdNu23iwOE3RtlhHQcaDR5H4JXr\/B66QHLJgsE3aYTJs+a6trzYeckoHiCdpduxXQsrkLXopOX6MqEv3WNJDUiKKRyPA2eg5lV\/6rMqoe2ElhYWXDCcgHHYC5j9EUXEJLsAxQvlSCyHoM4\/hBIMwyoKVltQnFlCy1SU609Ramm5UiMWtZtG+zmz5NUsVgJgJOBS6YviOlSj7Evn+vs\/vyO7BqaXo+YQdrCmbryIf5P2Otq992vabjUgT+JD4MwLSWbHKn2\/v4NzL6Joyo2iMuIxStiZ7yRWW8xm6twJtMvqlRlXSOcC6w0nLQ2trvvIULT4xC90laTTMBJg9WsijNxPejQijFH7eW+v9N0clBP+GCNQLd5dsZWOnG4rb5nyQ\/y4WqlIuNIPaVjLTCRv8KhW\/d0tl5v95n7NWwZapnjVAHDuzebZUBmzvsILbbXBGji923Oc8qiQJNsKJrbZ0GRHw6uOX2CwR0PA+DFelONnUg48AozL+WbtYKUC5HKK71o9it8spkuuSamkOsKwA2WG1N1iliXSm\/SPwIK5ci8igJGjLlAAuyQ4GVekUZ6zijGLk1jLt6AWt90TuiCjBr\/5rrB1819wN3k1Zx5VuNHjg0YKk1eaDA1ONa1pH8TxqoqSOrfX6aWuUalRQpakVODZbzIQjYQDWHeRj9NB7I\/71upr6rTHHSFxuHenJgiJXVs++zrtj\/7dTKshrF0kpcAVCIAK026pjPBTff9nyBg1u7PA46OurePESwy1NwglW3\/R5AuZpmKcDJEHxbcwyq\/BCMAs1Baf6Xk6su\/2rKl0nfFEzpJFtxr+lCduOAI574DLAyLTngjfFdwt8JCdluWAKrs88++4R4f9\/ncai\/XsYJgTyANN644kbCnG+VdLB2c9d2a8rrHYWsNhqRSPADl5Kiqk+4GCeoiJdJqJ1ftQ31o10P\/CvEez+IJoDKqatiUKqBY25fUGAmN2scJX9138P3PcF1qG3q60NRORafWvmycSIO2JbwAE\/yoQ+xYF\/yEXZX2AM4acyRvNtZGcmS0Qj4JUjLvwY3rb6Y4kvYlrtE061Jomfv1uNnxYoKmU1+3c2YeQLjwnB0UEMrFcmNfppw8XR3b8K\/dr3uyLeWWn+6nPQB02IECytjeUD7fGKCjVetQ9ToaSDDQvou\/zR4Ey+dN+9Fuf7Sv+Nk\/30GogmFtI5YWnbWscbsAYyTONrJyPZrRYaMG32r84rC1+VgICoTMnBP3YwmBjzNjoMvHuJMRMtZlg6MC9fjSM+GLiydt+CdUZj8B7PR3whBEH8AWOnasRgvP+Torzbv2vG9NDk55MdMy2ikwqpKAKxr3KOlOyWe3XmnrwavvPIuJOCvbExTIc\/ifqk\/y+sQoNUjS+sslwvWYv1crrzJEQ8zE43TqodvK1m71oZceL7Fn3P7nt1ED6bkGAHiVy0CZI6mqy42J9dcfp9\/dwr0DIpi0a6jC3oPFELppL9nzZ4JsbC8feI5lk2R81fV\/Yr+i1OjRF\/IKJG+L1iw4FjtCISNBFjlXgooerDyTT0fObu8Y1nlaSLKgf2ncv0QXYjrp6ybI5rsMMzzJnH5XJG5l4S2trYmiCnNqQCuPeKta\/cJ6pfTbIujim2MlKAlumjRopmud+C3sajewb3fxcGuQclCH\/msBi2rFLxwtNNBFa3evLPzE7yfoa31YOm6xqBMkjdSdon67S2famcDsmUm1ZjGQZ+LZx3wkDBhaRyUaA03rGnoLZRScvUVtzPHcL5rav0QBVfgT054WVy+XuntLbmWZqyegdXBqlt\/E6\/DDclVl26QpSYSZOnYFlvatUbrUWnFBK+jenzIYBXVkiWm1NpmDGD8JAJyB3HgQrBamBHhVHRxJNl+abBqzYuSKy\/5KedCMCvfQyZy5F7wOucJ7aNW9n7cA+kh9wywzADrwKdjvzZuGtxTiEnYuq\/V5FJblqEZcTu8q9T5LIE96unj4TD6XtZPzVgJmkqvbU7cuyjml4I\/Wp9e8RN16vbx6RfBnIKowDj58Kad27+SpWNlnl6MCFiG5mJf4J5XyiWv5KwznayZxVP1Ecf6MbmB5BwW9bmIjsrfpva7EKBq0uYPtGGZE6hJnRU+K\/Y2Id2CwIqm4D\/3BfEHlZjMSzUlq074UC\/CQRCL0R80jRN3zpK2thfyyU\/Vzj7Up\/V6rlKrLJB6xVvveOSXkpVkwLN3z1+42SfNYgrMexhAWkACrbxIU6KXp4lWZLWEAlN63sKmpu0A3Jdg8b8kV1\/2M\/NvHUAcH6EnZV094OnQS3t3xYo4uP12T8v0ln9x+3vewpiw33I93d7KksxrZPu0aae43u7LiOGnRj\/pkEp1CQ1N9rBfIZl9MAUlduj60CAmo\/fWJJTsSIaGvjGOKybmEhXMCX4tnt6\/jBh+UrFl2ZiA\/ty5c2cVw6bzEOxXoOW\/DdNfwJJe1G1mVSlPLL\/N72DGBsgv4EiNEid\/s3nndjNOyFZ5rFaWo+EBi4j4lnV4Es1GxwRKrl06d373QFPuO819fYa+3AZvqAAKhUKx1AS29CVR1AwMlaazbvEs\/J+nQNE8GLCI1cmWQszZRHoC5qBMC1lNarvymCZfmXgeyCwMIB4K2WH8H6YX+67Z8vDDfWrH1hWsMg7g4NN0ACabstNu+OlFcxd+MGoK7iWfw\/Om\/N34TsS3YjQtHGgeKO3YsWMfvBiTMIwv1fp8Zf4sgdbKlUXGPl3tKHLX1HKZCyM5vUEIBjSq4CSQJZzgUSmkuXYy969xfQNvoUfvh2DJf\/H+zwG1zuT9739SL8ODQdHVjUMF\/7pZbMk73tGHo\/9\/u+6e83GyM8q95P1ZqvQi6EqC1wWrbn9xcuWld7nrO3JuZXv9KrxD0Tm+5+IgXueoh2kG8FTjrWCP55Dnrl5wQf0sLIs7oSnG+PkwnMPxhqXz5394IJe7J9\/bW8DQGLZ8pPuulJtRdPEslw+fh+NpIQQucWF+GQvMnY1OHec3f8UwieKSjCAC1jhvWZbMgmQweNBk\/qzYXQtY\/bXYlvqtDiqrUZQSOFGbGVQk4eehzHcUisn9cb5J40M0cUoue15xoFSJePIxI1ZDXGgtcZCbwdNjIK5FSyU6efwRMiMqYjCoIjaUNc6LPqLxzaO8II8mLO9ct3XXjo9KoScMrKwYDC2lM5Abvoil\/L4WluJO8imelqHUiKzDT5wwIC5fPK45Dn61eO7c9xPlbrMcaevXIfoJj6LshL\/66n6ad1e62XP2YDH\/FQvmNeHDUk8dTS\/qf3WcqFj7+rz11dJyEnLwRhbVeyON\/8ddoWUnAPYQHN6DbOzjfQ3uRCyqDJI8Fo2hzmMZZ6uxn+XL4znXEwXtn+ig63jGZ72H67sSwIoEpH3+DXttkv5Euf1Q2g83Zw5LLRuw1Jdyr+\/SURziL8FU+fd8Eu8ICs2aG2cafGB6vNrC9OxpPJwJThwL8LSgRKnWpPrOqirQr3JVKyrlvNgfqCy0hRkLE0ZPIwN\/unnnjjuUxmgtqVEAS596ZcaSYkkXlnLNBcuGZZ7IGRIMSyEOom24vQcpQIE84aeyIOIJWIGytLA8WC5WC1rGW7j+C7oz\/12vjUa8j6cevyQsWqywwtno2+xh81lrUuITaTBEQ73wM\/JJs9WSe\/bskX9lygTr\/VPPoYYvOHdtsPq2+wCFv6PH7jQb\/U4zn\/saliLgkl8iBrhkmWsgZ+iamk5EK06EGS9UgxyHDH\/jzL54qjhKeBY0TgyhtZhsYCtWVpzIv\/Z6ei5fkrz3ih+7jo6co\/fS3plkPxJA9MPoj3PsJJ0E3WSHBSx94IHJKWopdDkmu89R34yXg4PREK8pwVj0wKiVvosC6bsaDEzh8hqFvYJFlT6DQt7wfkQWIwQHzD\/9Q4Zo\/H8bd+34oQg5VOVdhaIYd9S+LUFMkT8dB\/8QTvmhhv6xVhXIClpjKolGq23p7TPHqHiCiOkZC5gEtG5Z25o7+0HaG10YvxqzcBCsDpfloWwSANiSzNcheazMby3nxMsCbb20hlV2TxXDAWsOslVZ7cIm4g9jMNC6vsMqn+SKy\/4ZMWQi9P4vWV08bZrMfmSLikpgJck0K4hfNRVldWktfq21pUnURfBNK5mO508gJRsgLT9TjowPGpeVWVm54E9029N9fRVyn0Vy2I8eAgaa9yMUz9iFkWAiklqHquKDEy449dSahzYMxi\/mGBsH9WA4fa+U\/7LeD+q7xeKta+m7LYkjfReIEb0Mk1wejQcvHkPH\/jKMBl6\/cVenByu5fQ6h7yZwxo\/MkDayjTn2Y8\/8C+mcvgNu+9EPg69VnKXMALEgmJ\/sEbJVXqwf5e2O4uArINiarTs7f6R3eB6w1Ea4Pl3IL\/uuzkfoMZL0o9z7owdXbtmzOidJEZo\/wAQuNwrr6pzuxERnTays9\/C9l22kifg2d\/ycr+GEvxp\/0otdgc3YtXZWCb9SGbis0hIjYLD9R5hVqdXAb\/+pxE2dJ2kgfgx3qv4BrCy1718fMEE6uQIr65RTNGraKovs7SqP5dgtnUGdqfLz6l\/LHZfbF+9nQ9hMiaBXAMCl+EUFkJzSn6NTgc4w\/tK3qo8\/ywhHxLBCEiv1wF7K3jwwbpI84FFGqgcoRYrB5tUZfccXzgu0oJ5AGP6VMVZ\/v7Wr81eKVXjAgc+o4A4RDLCUNBHLsNbHGEYHUGKRDHdPD0a6bx\/JbCFKGG1WrOSUhHzv4DZY\/w1aDeu2dG27y97mRyYhh3hC5ggaLFEihLHnM6OwlqPxCnOAuWB4B2uJabJ8a71vfu6gdl2WwH0x+NQd32Fc6WtZl+oPuW5ndLwAIyxbUl7pvOAgD3UK8pSo2ZmGVC4xRbCyIkbDH8\/xnTz8sfnhoBl6qy4D5EV2gmbiSn6UjgDEdAZpYrHAUfUgI6rqo3qql7Qt2MYHr1Q65E1iizaxVDJDjfg7mbUMlvK8s921Q17anKsiBXTQ8k18GjbBmKLhFP5Q+Rn2+bD6TqvCRUl0bxAHX43D+Cv37dhxT0ZmOgJeK\/wOG2H2Xnb0FhZeehClWWMkyEMB\/0L2fFzHShkUHeZsj+MnEZ3tsGoDYHsnzu2fbOzsfCBLAMblxPiJ6QnMUnEt8h\/RvlVbnbZ1bfksxzqGE8SdFrCWRk+OzcdNRoCWyB1DFJPu1VTxNenZ\/FrJ+9+t3r\/PMQxiHVXqC2j+vQrAugigXuoKheOwvKhtlWVktDo5HV+epQKqvSNwVKuQDvS\/O1h9+1eSKy79Nk\/E+6oBK4xwW9AbprIj2lbkVbTT4aRxhKXjc3Q5jY\/Ig74S1WlI\/kfp5HKBRnpDMSQniTm2cQ610Dn1Rl78unSG9w4pQ3qHeBRTK51bsMYUnpPa9KAyZcXu9T3Zi6zfD5D\/lEK4E4n\/ycadXY9mObsYX3aHciOn\/BiCARZV02P\/r70zgfOrqPL93f69JGlCgBi2JL2FrGwmijsdF5znzCgDbqM+ZeYpI0\/BEdFRZxSfuL4ZwYURxhHUUXAeDDroDAOipnFkCwlbdnpPAgFCAll6+S\/33vf91b3179vd\/+50QsDmw7+gc++tOnXq1DmnTp06Vff+aeRWRlEtFrzA5P9segA\/XP301h5o3wmLHsU57PVcv8cpDW5dv22b2cq2NMI0v62tTYw8oDto6xzqlYMYfYRJHoCJ\/E6gdilwrZ\/v5MalYinm2Ef8cMnNm58oO9w\/ePF8d8m2V\/a2WHLJi+FPr5fcoT\/369+b6cyMmgmML8aILUCr56Nrsxn9Myln8kBbNFQPOOyAmWwy+CRifKN8QT+7Vc9UL6\/kVkMrrQEiqHGTjS\/qZ9T5EHJ7sVRshcbd+Ca8BB6XwjhqgOTtKheShrUNE+Ibt6HhAhN410hmFP43Y\/J2xs9RINW5LKOvMEqeHkF3N9JB7M2bN6ttcW7CtoVTzeCx9ZTCkj4QOCT7At5D5npKl04OPANxT4Bpu8Y7nlRXfRxvfaCn5xm1aZMMleO0OasOcbzLUMjS+suPP57zHocpHXdcUcfxJ8Jmln7tHN1ndpgI7nCW6csQM0qlenFQ56FYmh6yoA6VLrU7vVTyCvX1JX4Sqh\/+T3qWP9Q2\/xD18LY858wzPYfXesZbeuk9Q45J1zp79ybeybRpfKNg4PDKxOLUNQw93JXIOf\/8vQwwM3gnyxuNkdbW1unoj7c31R3J8gh0aH8QRPyAiWSZWZJOFvPEcPqqQa6\/P1CbgpTO2nb1fGRj4\/4DBaoFl03PdhzYsaOrTsXnZ+aL+ohBto3sPbxzcUr82e3t8bMN9Ug5jJuYbeC5uJfA5UnxTRh9FkZxsud1oIpptHlQSvpc8GE0zqlK12g6D\/VZ\/XNuuMFzZs92nZ0746nyc2AH05\/JymiycAfT9mRgD6bdg4GdTNvjwdBOdryPEycbr\/b4+dbDcokfcT5lfMBDKmnHNCUzmQzUH9xYwEQPo2nc6kPqz+GoBEPEZ802NzJhTgW+HI5uTRaH8bz0LuAf4rvqZ57pON\/9Lj95esNBe0Ia6OUx0k5v2zI95hlNP2yD0mIe0abNzFwP1WN5zsZBwgeN8+dMr43ByvCgelvlQJUDVQ5MWQ78Yb2NKcuWKmFVDlQ5MBU5UDVYU1EqVZqqHKhyoCIHqgarIluqmVUOVDkwFTlQNVhTUSpVmqocqHKgIgeqBqsiW6qZVQ5UOTAVOVA1WFNRKlWaqhyocqAiB6oGqyJbqplVDlQ5MBU5UDVYU1EqVZqqHKhyoCIHqgarIluqmVUOVDkwFTlQNVhTUSpVmqocqHKgIgeqBqsiW6qZVQ5UOTAVOVA1WFNRKlWaqhyocqAiB8znZSqWVDOrHKhyoMqBKcaBqoc1xQRSJafKgSoHKnNAn2Kqfl6mMm+quVUOVDkwBTngLm5sOXsK0lUlqcqBKgde7BzQ7yDxwXn+4+eJIn5o2e\/Sr3Hc9GLnS7X\/VQ5UOTD1OECAnRWgfiTD8fjxVZfv2V8bcFONY009WVUpqnKgygE4wPeWfe0M8oMX+u5yQ8Avsa6tcqbKgSoHqhyYihzQDw7zW7gedmoa9+uDsNb\/o6lIaJWmKgeqHKhywNkPD2YkP2\/m+8FQdZewqhNVDlQ58ILhgPsO1ogvGGqrhFY5UOXAi5IDOwnAt+NoVT2sF6X4q52ucuCFyYHqDuELU25VqqsceFFyoGqwXpRir3a6yoEXJgeqBuuFKbcq1VUOvCg5UDVYL0qxVztd5cALkwMjDJY7Mnn28XB0DVzeypUrA10PB74qjgNzIJWfkWMWOiOLQ9ohFt6V7spgpetKnjqIXE48qr2DkvGh1Ck3+AK4oX\/wy4VfK4PR5KqMNEZGo+HGe1ZdjasVK1bkuD8keWZxixjSGHqS7LH52brPx71hoAhsc9qkZKE+4ZA2bK4iVIzeuXSnt2TDhvCGOA4PljDhAG1EPf1V0\/PEgVSWVp6m1Wcri7S+cJYqdSOVc6WicfMOpc64yKZgQSqH8fglXo6Q0WS6IDlwJMkDt8bjYRtXKa1j6BkvfzK0Hk4YzY4yJmMIHK8RGa92pz1r2MYDHZEvBi9dujS3YcOGEs0dNgaPaKT6MGkOLFu2rGYiWUheQjaebmhGb1jbEK+KV5mBKPjRsJXysgRWKq+Ul60zVe9Ft2gbzQNL72T4ZWEPdB3NoxUnnDBtV01N1NPTM6S6o8sPhG+iOoeCazLtHQhG7QpmND\/NOayFCxce4xfDt1B6HJarlnd3cnzWoQa7X+C6j+87bPNib\/PGvs6HQWA8rMl0JAuzpKn13eC7iL9\/n7N17uVSdMp9i+9AHaiWT44D8FSzbiSDFO4f\/CjaexLf6Pjhxp6OeyyGpfOb3xe53gVoxC2b+rq+IqXIysrisPD2upJlzao4Li2dv2Bp7MVfotpAFAef29K3pVswSxobj3Oc4CPoUF0QON9a19m5DVwVZWzbWDZ\/wZLQi\/8K1dxVCrxvdnR07LVltt2pfh2PXpu\/uKXlZDd0voAsisWie0nH9o7t6pMm\/8fnbbuAoXkKQvvR+r6u3yufemOMv\/KVsmVLm5rOiGP\/g7gcJzmxezQ8fMAP3M9OxPcEy8h\/LZ26Lmls\/gBfczmT77n8eENf128s5OKmlj9Hj96MjbhhY2\/XLcq39SzM4bpOhNcsCYOh4h\/Fnvcjj9CD3oqGMOzKsNOFYjphFO3l21m3LWluvnJjd\/fvyBuh5OMQa5aZSVl85rS6+lcO5Ifc7a3bryZv7\/LlyzPl42CoZh8UB1gmmJlpcHCwvtZxLqwJco2FUqEHJGWDxbukZ02rq30Vsph+4oknXk7ZIH\/oCXJPUkUPeOfSpZKXE\/pOS43nnx1FseNH4TVkGYPlxX5L5Dl\/66NHpTD+Jfnb2traDD2qZ5MaamM5wzMYwpfm\/NxFxVJpyC8Wf0zeXtsHCz+Vr+oLLBvDrxF9LMULgyB3DgbF8WpK4rcxWLvn7K6F5RfU1OQWFwrFreQbg8V1onFhypa1trZGjvejmiBYWAxxcl2niNHyWL4cSf1thHjG8J38igkZGVmgC7WM+r+oq6l97WA+\/yjAxmCpL4sam\/+c\/D8dKgxJV4zBog1TryLSZ5FZiZ8WnTFYsece7WOoMEqFqBT+C4VbeTPaw9Py6cCRiGQRNuv1tbncOwrF0qsxWudhtG4HzjDPIste1cnsM8zcV4pCmcE90\/btM15aQ0MDj5WTra\/xUxni8OXatoTxYNuzdQ+13nPaJt5xKJ7HXjHLLQSzh7ff0XH3mbq6OjPYZCSIT5r7Zc3NL48i9zympAc29XX+s+qqn0wwRhZu7OTRFYfvExEacPNZ3DQ2QMk0j68Xjcgf9TBbo5cUua4QacDthR6Td+Mo2AM9HqoMhPfZ1pXclzQteIUTR++nS2s39fVcqzz46dEP0x8i2IOwyjx4TlDI9odxtj9CFlyzMjL1snAprTZm5cRh\/EYM\/UIM\/WOR514QuNGDxVIQRF4kQ+MobJOtP5l+zkHo\/Y47IJ1Bjlm5eshmyOQ7o+SdbWSCe9u+QMSf0aAqt\/mLG1tfxdT5XizQQ5u6O78nWFueGKzIHYhlXuJ4N2G8L2GM+rIIAfYWNba+Ll8qfrsmlzsZo\/WZBQsWyMvKq0z4NJO2t7fHWF3XaTNEaclXVlrXDW8qFuNBwoP3PfzEEwPCD3yo+gwEv3ntWgPbjde1lntwG4bLbRasjZXoPpuor7b9ffv2uRMZwNnQNnrDgKq+9fJoz7Sv9vYt3+dCg2JtIxhraRV96qfgoGUMXJY+ey86acv0pXlts9pSHw3+DF7FBss8s3V1zcCUeUOeoR96KtYbJn4kSkzV9cVSYTfLwrUswYxiPtDaKtoMz8PIe2d9bc0FQ4X87U1NTT9WbIQJvUY8ES1x6K+LvOInXMfLO2GwWXlKJQyOl4xRxw0T45OUJAoHz3zxjGu8kyGlRB8McTCSlUiFOqlsxXN4Y+hL6xm9yeZPxA\/KjJ6gdI6MpfRMOmdxqm6qw+LlMOsMlWP\/kZ7QDxWUMFbvq62pvWCoWLi1sbHxOvKG7j7xxBpn+3YTUwrD4EE\/KF2McS\/m3GKvKinl\/KfiglNn7k3\/zd34\/xADloyMwYtid64eIHTz5u6OX2Rrqa\/qg67SuVH9HMO3bF17LxT2nqvu0+csb9oNyDvhnfip8acxneWfHU8AmnEimrSrqYqrViXxT90rvs0lMeau84HaXO35+WL+d9S\/VmNf5VQtmooevrz8IXro+UXiVyQhtg1zlVK1L21s+Saz6jVYv9P8fHwyeWsQmjeeMbH1U1z3Aq8\/k5SnmxR3dkSVlVLlFjfgMoxCWWakzct2XHUmk8RkUKmt8doTiZrRkgHFQ3qfpXVEU6oATJk+W5jJz86itngED0RXJcMKWtE5ou00z9BPG6Y\/We8ED9nwWNJUY8CIh2rvbi76MymlrzyjAjzISAbOeaqnNwnkWsMmZdu8dfNjVNTSxqSmpqY6GbUADYIY0xhtJG1jINQuz6LdGLy0mrnQCkS5dIxqfPooLdNgq1hHtAKjsknxQ\/hUB3jJJdu+4ZvKlVJ85h5w27Z5Hv1Piq+MC4LyQk8jZX5t27ZNSycTp9oSb5HXc4XFo0Fs9Vpmmv8mldavX1\/2zqgyoHowzbSTRaC+ZvowQucokhyMHq1MY5JO+4jahho8vtFU2Wd7NZVoZ8w4En9SjOJjmU\/KE21cTB5gVh+jEX2L42IC5u62fLLlxmDR7fIgKwahydNsCEJ1zGV2DaSwKNXmxH13p7m+gnzG9YwXNy1oQ9leGrnRLVEQPFZTCN+KO7cCrPdt6O26TkQumteywvPclSBcu7m387fKU\/2TG09aXHKitzhetK7k+3fUlEqnsdJvg+XHoGYhPe8tlYJfAi6hl5VPnSXPMP7k5uY5cOBUL3JPRII1LIF4lKEnIocxplZNHMUbN\/Z1\/TrFYRS+iYFWH3tvoJw2nVmwoYCP0O2FcTuVO4GNrQHhOVbw1Ands6D8nhmlwQcGcnUr0beV0LnNm15\/DSD7ocsKUE2V6ZWS7mjqa+HjGAu9ODqBfh2Lss6Ap3glzuNh7Ny9ua\/zThmrbN+y+Ba2tLzMj5xXM8aPT5DHO+jjPZt6O+6mbVPP5I\/5J+E1MIZfSxoXvBRD8XrXix7S0p78eNH81lfz7dnlaBRfIHKXh2EIK92FBGE\/aNjI8tEPC7c\/3Nf39KJ5i473\/dKfgmyozglvxlg9oyblYTGARrS+vbXVjzs6kIfj4KWvpN8vdTxnX43n\/PtDnZ1PeghbAy+b5ElYBV3atOBt0LQA\/Xq8UOPfCKkyrMbYLJvf8hoU5OXQexxDBHLix0LPuWtLV9d9wIkfyD7xZLUhEDvBuejgk3uLQ7880q9vRF\/fBGdONG278Q4v8m5b39exkbqsVIf1K0ub7imPl85rfi3TPHx090D+KWbp7biLFs9v\/RDDhmxvfzFwb+mIO\/aKXy78omo+rg1u2hxv3ic8xRDqjXugp8oJOqyxdbRUD0PvDGI1\/UC\/EueBi9tsZISQYP+u\/WHhFhlL9UEYzQaJG50Jf+bileGlxDu92L2PgPoqYLQK8vAsBZqm1BaY2jbPXEcKlqzexsYgZqJaOH9hMx8wfn3sRsewxpc+2Y+ChmZDrxC+AX1bjGo0oFP9GMNNgRvLBjxhW5D+STfg3QAqsSThZ9yCk\/SXCCPHsnp3MLDvltRg2Wq4qXzrXU86d9U2u83ZuXOnN3v27GQ2ct0GOi6BFfQnOBkztxhdyMe1zimF4bl+Ma71gmB54AcOLt3tgFwnOI6cvZvl5CfyxcJNK133d6tSyytjFfjeP5RCZ3sQxR0EEs\/MBQkNmnoUK\/H98IMYvA9v3tq1xuBKjYKEuWh+y0dYmlxAh5Z4fExVXDUdcAJTVxO9vgJdiqPfAk6zsSxZpN2petf7v1iUPxat9Eqo1TcGXtSD4n1V8Zust8My5218Uvoy+rkJY7ULWb+GuJ76udUZHPw51ffbJaZBxj8ogwZNacf8ba9lQHwHpVrKx\/TZ3IBWmjTffwUgKpUGEc5V7oz6S6HBGD6yuY3DJgxrneN9noDih4MgmEV+OUHLviVNLd+PanOqt0\/b5xSO8B7KwOkNSvGOXJD7dKFUuo0syQg2OGcjw0uSQQAPsFhswrzU9YJ\/ps9OoVjcmw+CNwJ6n+cVT4fLV9ODfUUn9xB5DwpHNsFrw9DaWsVxHYcNm3OQyz\/T7lGFUvG6Ad\/7VwOPgBLOi4bkluMWxitY2tR6EWXfMvKL4q9aL2\/hCexq50pfRD0+gK5My7Ybh+GepU0tV9UXhi6DHwPp8gOD6Z8Oz78jHjUENfeETvQK+tWQ1JUsIulIN3R+clNv18\/Il5dSNhaCyz5HnvfOnO9\/FHzM4YZfhJK8FejgCt\/Lwa9Cfy7vvIJq650gXIFhvlr0xIWCPNstwjfJJHU28owi709yOf9zpk3pqZGRu9hDRr7nO4Rsdk7zpqnNbvX7id6tH4HoT\/m+fzy66vipjhP3Chc1tvz45NbWz4NrG\/pVQx0zqUySJgPGRDVEaGh24EVXMYbOKobxk7R3h8WxuLn5LD\/2\/g9j8xXQSLYkzcxCjCyM4rWL57d8gV3q\/xC878bn+EHAsplPITPm6Zv4eTL8vCaX9G1vmJuRxFRkTMUVxIa9CHcLgZ3hdG8TXyt9hx\/kGFzFXkL0JnYxc2DA76+p58QzjXruqzAwg\/zdGIaFLfA0swSMdSpaUs\/tTHebErxRrTEqnnciHdFs9\/swLP2e2eAp1KWVqeo9GIXlCOMyturfAYP3462AyAyCT4Lz63TMQXZ3hWF8J9k6hnEkxu6VlL0ST5CyaCMaeQV1jeDN9rvnX8vgOQPh5UsMIDr\/CCrawPA5i521lxVLxX9CeftR3uvVVppqwC1jsxgdZUqPb8UAP8z9w7n+\/l2CUTzJAuuq2Jqu8PY4z\/OXqj79\/AnxzYdZAOUZokwgzqtxBd\/NxsfFYf+gJoLPiFboN7ZXxirw\/M8IT7EU\/hajdwe+DCxyXkOdN9PXj8dDJWnERWvWrBmxBFCd0Ql6azQZMBpVxySm5+vR416U6igy3sYAWI4cu90w+q9CGNbR1janEDwmYGjTZrIGalCMwoo+QoSmClZ6xCbN62jtyppcDcaqcHsUBn\/T0btlr8rRSjYdkxSGOXML\/hjev4fcy5EFfS5e6w\/Uf0VQ8MRfPL\/56xjuv0wV+2ZYep+KoOyV0P0W+Pnp\/hoTG\/pMOVzguhzTQXau14BxehOye6gUltrRvW3UPRb5nFubq2lGnl9eMrdlHSR0pMa\/zE\/RJRqU4Ne16A1jwDsKRp6DHE6DH13o2m384ck4O4Ia50nBsv8QoDS6zfmhGbm6n2wa9nUi5wZo3oGeqs230ubLGfjbMdI3o\/91cGBrriFn2sRYfYi+ftPTZF0K72cs\/Qe7G4Po28vg4TkY+vPQ\/WnLXrLsf\/U82aPvejpPsByZAfJxCCvnU98YcsbjjFwp\/g7Bf4xVKQ9Pzt+At6\/68gYR7rW5XHACZzl2QOe\/wZPtyOBY6Pwzxt7yQli6llXDHxuP2PGuQ7d7aGQWY\/Dt9O0UfimnLwrdX9K3eups87zSLqOwBEqTqQ1FZqP6dBRsI2o0QxrgeKWaKPZOoBtvR0vVSXK9b3MWY4cIG5o1q+T2m61OWcZfu5H78Y1bO9erbFQaggBpVZ6dqbLg6TsBeKxuHG7FEv\/V+p7OW7P18HQeYEb+J+r9UdifX07ZHVrXLm5qanRi\/yK8MwxS6WvTjpn1+exgbZJXEvt\/78fuR6kzVAic\/+ZqEpuf5+X84IxisfQU0+j7NvV2ytMwadncuZcXY\/fKXC7355RfvPjExbdt2r7JGCO4ZGl9hMjLhZu6O35l6+maCnJYwTKF6qf6D\/NY\/gWX2rNLKciVeEkPMrF8DQN9Md7kTfImGR+RBM+i8ULDo6j0tVLO+0JHR2de9cDpMUv9LQb0iyjDhSzNb9rU03GHyo7AIuZZ1eh+TMJQJrQ4gynNMYr2AHD6wxtqrcP7wGCF9yNn8c8ktWdumMwV40ImgyjWCAOdgqILycA0y0\/Tq1mPAAAcOElEQVTX\/R6TznH5YvG3LJPe19mz5UkZAysvQySaZusubWz9H3TuuzV+wPHA0o\/mNM37K2t4lsxvOYuyv0SJBf6xjT2d37b11Bf48Vk8si\/Bnf9t+ahyFDwvgtFRBmf08c19PT+Av2XawXsbXtEN9HsR8\/+bqNKhgL7Fnb2mPCvzC9nNwos5LYpLazb2dH0kC6t7ms3HWDN0bSD0WEscRILGsgzTcWXGFueiINV\/eRiXNtBmWUZCnSzR3E94eMalUunHtW540QPpsl3lWrYyjr\/HeHtnOH3oFrJ+pPx0l7DcnvLGpNjJWZrC\/qFv4GW+C1xEA5x3b+jpuNnCYzMu5sjFCYzdhznD+Z6NfR0bbNmyua3fLcSln1K+AvleQv67NvZ23M9Vf5zna5mD6E+JitG6Db2d6P5wMkqiicfwxXWPwgO4kTl\/IxP4atb497EguxcF+Q9m+PNg+tOUvwfk31dMRmiM8YljRfCxbu6DWWNFXlkJkRa+DqLjpNtw88mdma4dZ0fd0Uf+RjmKG9m6vheyAxI\/gnSkdAtsXRZ6p9HkCfCqnw2pH1rllzIJRu4qW7zfZ2AWyHlpXclZoXydCoaOt+oevDcywI2x0kFL1V2\/bRs7pdHVMsz09TQ3KMjFTpLxLAz6XmusbHsCsIJMoUdcKEM\/1H\/W44Hxhpy0TcOPsBBcE8bRQxjSGrj2OltZywAG4AwGaFch8C63yyKVgzPyBuquoI8Pij9k\/Imth3dkCLXP2SsF4i+kuPqZN6OgTRh4C8P8aWhCeCNwsNxNZJfs0dj6I2CEQxlMFE+wXDgCHv5TbVCzkJ3ltUHknt9J3Cr1XGxzBl513Hp358mNjYsh6Pso80yU+WYM3EUyVtCb6KoT\/7GWiHiJd7rT664WEi1\/hFN9wWG7Bl71Bp53BCvvN5YbEX7j5cT7mHh+DagxHOmS0ZmzdV47IHdJF2m\/RfUEY9vVs01qx+q\/8tD7hC\/JQsWAqR5\/Jh9wnA8S46SGoWLxHOxV+mLr4GGzxyFej\/WI8ETOgEct8O9JpPsta6wsPUyG14LnRoVCoOmNFu\/+hgbbD9tM9kpDRkqKn2FUWv8Om3A+SzdR8CEmjn9XF1V28rwF8C9uM5Oi6\/7jhtRYoQ+1Kl+\/rbMTZlybTJrxmThI85VfTgzu9H4Mr8oGRQAwlhnF7eVvM7Q9wnULTOngbxdlPLrTYVSzCLPR+xRxctHpeJIMjv7asgKUXElQYK66H06oNa5dfvduLUecu9kSbksOpTnETQao8WTCrLgcv8HNnmH44zr7PQ61qt6pxx47XdufMkp6ptfPUHcvdIupZkAO1NbOpq1WLSeIQ5S9OS1d6KOhrej793LXzfICFHGjcGUTxjdoaWmZqTy1J35ky8e9T3vuFlmekPL5vKmn+lse3fIUfdwkBnFdXMbhOgu15IVD92CsdipfCqaBRjVv\/ZPr9zNgzNKbXi5RXrnu+DeJLEBqQY4++ujyzK\/JRfkYNN8q2Wgjk9RL+GVx6Er7Pr7EIJPdQtaLV9XV5FawDHyE9fN567Z2dKlcy+bR3guk7HPz4atC1\/8Bsc7jMXCrCr5zPn3eKxqkm9QVvxal7d1hwxYyaHbCWt\/T8zhE3CueQU1TCiv+wR7zROdyOlzpCK9itLpvd9rRfedx6Rn\/HaG8NBkZ2Qd7Bb7MLwZ9wi8MU1Nq+BsbG42MLXx6LfN7VP6kHvUurwWEH6ZN+uRLNilvbPFJMrzQtW5WlN+oTOlMGwyR3lAXPPFdRt1dZ0FxT5GTHoQbisVxdQdY3HU0jY0wPPCPIonLNJTRgAs39XT+UPWJZ5s+I\/tGil6iGBuxqfIYy062fOv4t4pTCc4tOfNU3yZaMbMGjXl2YrATi\/GS6CwBVpZlrruLA3\/vXd\/d\/dCiRYsagt1BPNgw6KMtRxICezsgX5G7jdutwf85NTA0NEQ2zWaSDVSDd1wGZMDTW9cp5AMjkDlz5pTatxsFcgjaRlFpkD4AZjbUEnAyHlcQhVlzDkwjCOzseOjxx431574gKObHk6HgGIwTXfPMso6Iez3xbnYSwRA7r13UvIBrNB0lZSMxZu52B4LYOYb2YL665Y0I6govya3fV29oJUCsIP6I\/icgFf5VH4C0y6iZM2fS5PCyhEIZWJoeNszkmcFFVRObEFa9AyhMtl36Ycro0ZHLjz9esmHpKgiJ5uATlZL+YCRO7+wywVgZmbKHVUY5Er3vR3jqnM3S75y4zqUYjVNYBnYwdt7HUn99qg8iO1qJdyc0cC4dCO4xPFzBQFuMgfsdq9m\/6OzsflITH8I1NDQ2NireWU991VzI615nc0N8wRgjEaNzgeCNjxcMA3as7BB0yS3JODmnd3YavLoXTSxFdEsC30EkWjL4VLGxt9Hg1ATQ29t7EFgODpR+Jm0ybJGNOeNkMUC80Rm49PTd27eb8IE2MugjGpHqBLFg8YiuTnf9fCXjatGZKzjxC5jkHeds7k+UBAgZfJoY75UCkNHEezbxvtQ5MDzEAXs7cupGRvUGEf8ggkH+FvOnGFGA\/9lgy9IrLOWOStYx0vkulRmlUc\/NfETQHQOwWwWbNydbr7on7eHvG7iBdSjhl9hFO4\/jCNev631kU39\/v1dPKNNAZf4pMyaTN\/GtWJAkGUF7P+JqhUSmN1h\/TzR96BcY2reVXOfyJc2tx\/gl985C7A3VuFFd5IZskXqXssRi+7h4p9dfa9b+2gXl3TXiGewtOs4lNHSJDLqSjLYxF3AqmaFFU1xJmFg2vQTgOG2qMNmUdlF6Y6uIT1Kk9NlebbGEZohDgkZgaYGtb+GNUoIpIKaYdGYYw7O5c3e2tdm2DogH68uOu5OHNwS241PEz1IU37yeYwaqzAyc0yyrPr9DPSP58IIbTTzagdZykCfeV+tJDi\/jUrrt6S4Zy3\/MEYdOYBe4zwXNuQI3IhhBpVmBqWCswRI0jFLhTme8viXlgplkGm69bZI1DhdYMrTVvunTaLTwyhpTsb1cLFFJc+E+sYPJ9dfw3fEWaTeekAMrL\/NWjPFUU7kO657r5pFRLVR9I2l3NHmMP2YyLQtDN0q8xTJ1FW9MH43Bsq3Qd14QcI21k7ssD8Aaj2TJ5NxKbOdL9PtEXLqTQbtJSuT4lcZ0xUafXWYiHINDSyECjw8wSN5WwysKdPxHJS8cwpfcz6q6nm3U6exassNU2ohB+pTgVbHolbSBxc6WAv3R9XDhYVhprb+4ChNcJgZORpmXv91fmwbH+QdferQkxoEUZv5GQaMEo3IMiCAPlLL1hkVY9sMOVH2S5e2ThAMMBytEL+rhK7O5sxqXlbM18QVsb\/9uU3f3L61SaxCtTEcPQSJFxOTe7mLwENvwzkDMnyAwfA\/HStbSfNTGmUDQ8+KJVjPEhpArVqud+fU28hUXsZzVFRLY28QbAHQNzyZNdlBa+Bf41eiP2Jrth3SNvOEySnkYCZStMOpeVWHsGmLZcxHCAuLbn8cD\/mgHZ+PSkEF5UqWpnHSd\/7+DSHaASnKy9GiM4eYyxtjIKhV9s9kzqrmKj8ZgZUvCIDIurdw7GjXWeWXqvmMxWYPxOg6NYygqzl5ZXM\/l\/ZKWFg4TOh+Axv3FSGdy4ia4r3eQpsGVRxk0vbzp1s4Rjp+t7+rcCrOTg6ZRDV+goIt0ggN0P9nQ0\/lfzyWdI3BbcWUyoWvYw2KX1hTxCkIGZEj39Gu6zWvjsd30oKwAZpJB+oP5mflM3QoNWiSTusIkGhs\/CT8wadLBUWyJjjkwa8dfoexdHGV4P8vCq9gtfDTdCVKXZWANcYwBxaZwqqJ9VP8Uq\/yvcrzgVdS5muMnb0W+O4i\/GD1tbGwssV1v4Km+alNP19ds2+Nd1Zb0WE2MB3MY8su47TGWw4DzWaBI3veDqFrFftIdVvFdwtKf\/Fp2sYwQrAc2cXuEjfCcdUToVk4J9DEdcD4v+PD6xuZeKn5dMcQ03ol9MEs98X2IKPA\/4GFvnRi5YzZOUjqzoIZm8JT5mxqs4SVKECrQ7DiKVwi6zSwJ2gyS2Asb6CfGitMRrvuMyZzkP7Q4rNmTrDMRGFb+eLyoJmjZ4zv+7et7HnlwPHjTj\/TNctaDe5ycuxPjeySuqAK4\/0W58VASxTZCVUzDMIkyVi3ZOFPSCuv3Q+6Plk7CsmvXLr0LqNuiaCQ2eLxRovRUvwqYEh+Tq4cxWig6ReN2To8vnzlT7RtlQ3oLBQvRj9ojD+b5MPxjg9LogcdgHIVxLAvEK3hbL6X248JfF4rO8ppcsJSzVN9dOHfhuZQ\/qgDw7A0bRg0Ud0bR9x7kJd4Pc7ygnXM6K0LO+DAI3ivPTA1LoYmHPG6IiJ2TLDFWRuKhzaOdspLbvOfjalcke\/bs8Vj2jurj80GBGWiPJuY5nv9UX9\/RtPoEy\/FAh3jtRgUrkcYk7OE+7pdKZtOKJRqnAlO2GQ0dQa\/lZ61OCRAeaoTDf0trX0MmfewS\/quNYXHmaiervQHwTyOs3gwW4zAIG2LRhGPkNEJG7Sotp7IcyRElIV62rnwMRP8ytenKVM\/RhyHFqxxZTBCGUhIFvkwjkft+bSmTtrJnYHYfjJtuDLVhlO2UYEYkKKAMfozIzTxMPANqxKp6GT9MXofRusVzPCLX4S0ETG+HiZdxfcuiefOOz2BObtuSi85U0a\/VibCcs5vY1eEZG5J4k1xNytQfJjl1sdUXG8PKwE14a5YkqohHwQra8FhHL+zuFh7Iyyk9Q0sZjFZ5KQPSu3DDyYpXLp3f0qZGNIDL9fhSANJ7PUQT1yl\/nkRgaqvML5OR\/ScpqVhOJpSSWFFbBZceNKxdOwJeriF6MTKPZpXBUZOX6DUeYD7GifqdHC48ww\/Cb4jfwtnLax2mDf4RvP74vMzRm7q61tGRj3NA0mGT9tygGH\/JwiXX+G41gMq\/UW8rKA8yzFLECC79J1PH9MUsGwzwBDxJx0Gm7mRvTRvwomT5JRndWDZYlkf2mkErGanzh5oyMi7v5LrRA0wQzIreqWHk\/6lQix5LG6+YnUST58Aq9XiNOcoDjP2KiiFlWOvNo\/5JB6FZWXFC\/XN8feUX6XGaf9QXFsBnahVznCzghIFsBfJ\/j6k78Rgrt6Eb6phPW6C\/xgYpzwbfjdJgbYExoDnPy53Gu09OkOOtQg4BERlr4CM7vCPV\/G4scNJJx\/3Jxq5Ojj04zvTp0yM+FJcyPcGi\/DEJxqZyGS0eUxeJj85PUCgmw2EKPWRhxGTeM\/seTDoLo3kctB7H7tsbJQRSP4f57meBcmvkR\/9GnmiV0TUeCmvBf+GMynt5ReZ1fFzlGj4P8p1c4GzHarHg5QOGvFtRdMDHM+9CraaudS0O3E+1XiFRUQFpKUg9AbLlHFDtdwLOQpdKhTCoO4UgzmV4FUcVwuJDvhOtsihKgfvzXCm6gLIz2Dy4mhPgX6AXd6qcNxxexqHRz9P\/GZxm3uh78c9tvX6+NFKjTWMSg9tcbdkwH61IbElypdwKdJ4OIeqQqzkqsnx5ebmZIhyBN8UCu3EhvcSI6CNwi5pa\/gZ+X8u5nXdNi+Ie4D4jYy14G1uCROLztTTtOBu7O\/+F+GQz1F2Kt3YJsuzmcORVKuOk+C9Cp\/QxliPzi3Hpe0xQX0GeG4oFSnyvxvUZLqF3DHHhI1jFPAApiUemygkbKtFsSgVgBWwzJnkdoh0ZzlYdaN7U09N76rGnagmvPpbjOnQ2RT+MVbJICEp0fLjkgHdjaLXeXcH3V3Mo7f8Fgf9ujiowiTfXRk7NLbWlsBjm4mW0dAn6dBLx3cfg\/022pd25XDRDTIKg0RMRMCmZyWqAvsaLGhv\/muOKJ3DIejkHRK\/i+ezNvb09XV1de9DTnwByOrr3IeT3NMp\/fbGYeypXU+J1WEfva9VhdI7ldcrBR7Z2S5+zfDIeH5w5nteH5rKkfLSRYyLSGeMuUbkWxcc2uUdz\/2+8K7aOwcDZHn81J9fvc\/3gBjp4DgNar8BcMeiGxCeSZA6Ouu4M43mxRWrz06tRQN1TdZrWwHBihmVsClOnurR7RDSN0MeoVDqKoH7sHJHC2OA4Z65OnQ5nzyM\/IPB\/DTb3FRztvxD6fkYbHM\/wXosCf5nV9O\/wXj4otDDQzAAEgH\/F06f1yCsKzADx3cVStCYM49VhEK\/hPbPVOd\/7De7Dv3oDpfmWJJhVb\/rpOg3hMcmScKfG3CQSxl7bigUCxjOg46eRX\/tIGPt3RkHN\/XRwFfx9DQq0iyjhJ3WWCIVxVxI7ZGbci928GC+lGy9lAUb5OhzjtRwZXcNJ5xvJO5n+70D4F63r7n7CnlsxJzngqXhOu3VZEvHXptl+2Hydi6LJVB\/iB3UgkLZewUHM25k9uwZq6m7d\/+TTpwoeeusp0+2RHHQve0qeHymMMB26ICdxxXl2N\/d0\/QAivqyRwPuKn17auOCzyhcCbGoZF1mQmqTNvd1f1CtM5sCw6313yfwF\/1Ml5iyX432MPu\/mtZ1Xs7v4n+JHLohW+25pDZPU6sB3f8\/sfAsvO5+RokMlIkRqeHGkH6W7Um22NLlC33SMKlQOxwtHQgw\/IcPy4VF6sha9c6CVF\/79X+PpdxTr+m9fPLdlsWqAry7lVwNjyDBO+WF0jDqMjKT\/cVZGFXUqq2vUqxet6L2JXwqfjrvAQ1\/eFCugS\/GyVgdB7lhCJ1d6TvH+Yo6AOSEQdO0NlA0gx0\/pDQd7xkkn3REcYxkecPxHOMtJ+YY37jT1XfkyTtxchG4+WZerYVc4uH5ZS8s8lc0KC1fBk2u0E8jk8ilOvq\/mhfk1LBbYjHHuw66s8d3gV5idK3R+Szih3fAmihiDGCDaW4FBbOd94Q7eWvnNknmty1Lmefcy2FcRD+qA+TpoyRFYV64f25LxbpZcq3nv59s4kCt5VeNiWTrrfmppAtfv4ttJvajyQyI2k4yBMM+8b8fXCrcimtU6E2Jh6HqHzuqAYxXvJZpzVLM3zFY9w5QZM2YMcfP7wXyhGy9ks62XnzbwBjp4Nkzp54To1zf0PHIvr9hcCX3nhgVeK4l5lScs\/SednoNb8496n011JVBdmbG\/Do\/+BMX\/GY\/bKEFAfIWC3QueH8fdvQ\/pfZ8TEI8JXgmiNvMlxh5Y+3teCDceQnvZ7Tcg4\/+Dk0vSNpe8CglaZzdeQptHkdfDDPUD7s\/a2Gc+jCg8HM6NzVKcft0Ve9Fb8LC+xWn4zfiBencTIUcdig0RPn3z8Ods2w0N9Iu4j3sHLy1vxE02y3dTIMRxtG4on++FBuOppfniuRkoQ\/rqRhx9BqPVg1LzXiZxiNidgfIJhhVb9BgKdS8adhtT9lNpfWq7Oxh4txOYvQtIxpfjNHJ2Std9Yf7L1LmCpV4fMCtQ7BOVzzTZjXe4FgNze5gLzU6uYlzwhNcMo0\/Cl5+y9O9lAL5m7ty5ZhAlr4B4b0In8bCjDvGDtnEO1Ld4t94YoI0f8qbDJuUpwckd8l6R\/235YmBo5mwPW43tpk8JlHv\/YCEvXbg\/eTb\/wqbKydblNP7PEevn6HcXBDDpx03QpIPNpi6e7zbK7oaKX5Uirxz7rZtXl8iIg7VMsGXdprWKbbZndI2h\/fBgocD5JudO8SqlUPVMjIil9SO85vln6MFlYRw+nJRjbJy4D535CbtnZ+lLKsq3GwXNjz2m15fuZJz2IeQtSR2IAT\/yWa3xC3\/LY1xn5KSb6MfH+BbYfUDOKsXeaap3F1+MGHSjj5ai6Dxo+DVlTyMjnAyNM16TcuJe9OG\/0ePriH0VVIeYn9G\/oGHaLzBaf8eqqRv9mwVsI3zVRC+DmvCmidgCHJ5JFp5jyGoocc9zXmGAdd9uu\/4VYgSRLK30QJLx2r9\/f91xxx03qFhHkjvyX838fAFCs0hhFC6f0+L1nPouamYYWSt50u5D7Z7a3OydG4bamZigmZdjWy\/hPcK\/h9Y1vF\/3GtUVHTa2o5o6jV4bunfiGi9lSfJZdpW+qnzRYtfEesbCv8Qv+kbha3JhkS9v71+3deszakfl9Fd8Mp+a2QitZI3og2DGS5YmXORzGPA3IXoGi\/vmfeHQpmlBMN+Na\/OcZNxr31cUHtve6Hs9q0+5MMTI1XLIZehpxYmUr5Stp+cmZDq9f3qwYeeGAci3Sk3\/3WDHwoX1LCXLcQ3BK2VxwPfZtUPxTPLiApsVjzz2iOJ\/ZiY8Zc6cet4ji9c8+uhAUjP591UYlX5OTOsjjYJNcRp9EW7qTds\/fXowa9asATPZpXlajuizKBYX2baOv3Q2+jEz76HYMmhCmygtD6c3NR3Jt1Rm5aIcvl5YCvO5\/objGvZYPVCbghe+U+acUr87t3tEO7Y9Xa0ea5K09bPlle4tfpVl+VWKgmc2P7p5d9q26ffoPqZ1iIXX6sdZ9EmY4WVRpcYyebRrxg1ZY3RRNAlUbeuqQ+BuPn80X47yh2qdvYwVM5moDNARY1mTBQamdvRYrpSfrStdQ79rCyTJMVvGPS+sz39JMcrxJVoF9nkXtS7aBx3J0k+EpAlYIy89ip+YdJb2XlxE\/8TPssGyFSa6Chnl6uC4jM02OBEulR0MrMUlq66T9KzLP8Ly4krNank\/Xq51s4WxV+Ff3Nh8f+AFp3H04TN2G5xs65ZLpmXlt\/UO59UaLJYJf0a7P2NJ8FQu9s94OP3hhmxbli5IKhsXlZMvvktWI\/Jt3fHq2XJdhWOyfZ0IdqKybHuj26TeiIExunx03bR8TB2br+t4\/FDZ85km4slEZaNpPBjY0XVHPwsXeRPpzITlo\/GN90wzFWUkeMoq7rCPh8vmi\/bxdNUMXAGsZNblohjEmD8ZCeULIYjGGCvKvJV4LbqO11AWxhIm2Ey+wW\/LsldgfIv\/xnKBfzcu417W2y01kftFBTvliclA6KqP+vHh\/M9D0mn6ljyxrDWqCi4JSk2bwW\/7Rna538pbmfJDdWwCxvZzXFot7Ogrrrjalc\/rluLQ7LQ0MSsJp9rTH8VlurL1lakyYA2crtn78eoJJuXbCAUg3\/bDGu5sc4YIwfCnduxV9waPrivhT8o70y8hUH6GdyPaFL8p9kWPrad+kQeuJG8EETxk6wBW5rnyVSw8KS7RVv6z+ITb4tS98rkIrpxvy3Ule0K+ZGGz92k\/yu2rjbF9HMuvtE0\/pWvcsZNty95naC3zxZbpKppIhucZHhlZ6jmFGTMBZvCO0I3x8tM24FvyQ7GCs3RQpuNP6Pc7R\/CGPPOsOln4TD1jF1K6R+ifCZiqZwBXXMpZJBNdRTTlYzqfrTMezHj5o+qWjSQdNMqmQ4jsPlxKnOpyAucXEZx7L1vgWwZ2Pb0\/R5CZtXQzS8YTTdfi+HJiPKyjTdJAMrRyVb\/LuNPycS9pvQn7OV5l6pqTFFQuv66vHdYU53jVyvnAHRStqkiVin1L25ywHylMuf3sDWUV9SXNr9jmePSMh8u2R3lFfAdqy9a31wO1k9InnkzIF4tv9HU8OlO8FfmVllXs32j8o59pb1K0TkTXaJwpPRXxTtTeJMoqNTVhXopzDEx5h2dMyRTNoCNmVtaVwPk3+ezuw3xq9v1YsTexy8lJdxl4nX+LnsYDu5mHn27q6zaOmYwd1Q5JIZ8tOzhW\/DTBN5atcR8vBpm1e\/a7YM8Wf7V+lQMvBg78fxAN2T5iTbNnAAAAAElFTkSuQmCC' \/><\/a><\/div>\n <h2>Oj, det ser ut som om tjenesten for tiden er utilgjengelig.<\/h2>\n <p>Straks tilbake!<\/p>\n <\/div>\n <\/div>\n <\/body>\n <\/html>\n \"};\n\n }\n\n return(deliver);\n}\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"69d434c4a3f808d3960d9d0969fee368377ca9c7","subject":"Remove statement that conflicts with built-in WAF bypass","message":"Remove statement that conflicts with built-in WAF bypass\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets_waf\/recv.vcl","new_file":"etc\/vcl_snippets_waf\/recv.vcl","new_contents":"# Specify one or multiple ACLs that are allowed to bypass WAF blocking ie. no WAF rules are going to trigger for those IPs.\n if(####WAF_ALLOWLIST####) {\n set req.http.bypasswaf = \"1\";\n }\n","old_contents":"# Specify one or multiple ACLs that are allowed to bypass WAF blocking ie. no WAF rules are going to trigger for those IPs.\nunset req.http.bypasswaf;\n if(####WAF_ALLOWLIST####) {\n set req.http.bypasswaf = \"1\";\n }","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"461cbf7fa3968e130c17c28ee7761f0f1e2b4461","subject":"We want to sort query arguments only on URLs that are not being passed","message":"We want to sort query arguments only on URLs that are not being passed\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets\/recv.vcl","new_file":"etc\/vcl_snippets\/recv.vcl","new_contents":" # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n # Rewrite \/static\/versionxxxxx URLs. Avoids us having to rewrite on nginx layer\n if (req.url ~ \"^\/static\/version(\\d*\/)?(.*)$\") {\n set req.url = \"\/static\/\" + re.group.2 + \"?\" + re.group.1;\n }\n \n # User's Cookie may contain some Magento Vary items we should vary on\n if (req.http.cookie:X-Magento-Vary ) {\n set req.http.X-Magento-Vary = req.http.cookie:X-Magento-Vary;\n } else {\n unset req.http.X-Magento-Vary;\n }\n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n if (!req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n error 403;\n }\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n\n } else {\n error 403;\n }\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (req.http.Fastly-FF) {\n # disable ESI processing on Origin Shield\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie:X-Magento-Vary || req.http.cookie:form_key) {\n error 200 \"\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url.qs !~ \"country_code=\" ) {\n set req.url = req.url \"?country_code=\" if ( req.http.geo_override, req.http.geo_override, client.geo.country_code);\n }\n }\n } else {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking\n set req.http.Magento-Original-URL = req.url;\n set req.url = querystring.regfilter(req.url, \"^(utm_.*|gclid|gdftrk|_ga|mc_.*)\");\n }\n \n # Pass on checkout URLs. Because it's a snippet we want to execute this after backend selection so we handle it\n # in the request condition\n if (req.url ~ \"\/(catalogsearch|checkout)\") {\n set req.http.x-pass = \"1\";\n # Pass all admin actions\n } else if ( req.url ~ \"^\/(index\\.php\/)?admin(_.*)?\/\" ) {\n set req.http.x-pass = \"1\";\n } else {\n # Sort the query arguments to increase cache hit ratio with query arguments that\n # may be out od order\n set req.url = boltsort.sort(req.url);\n }\n\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n","old_contents":" # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n # Sort the query arguments to increase cache hit ratio with query arguments that\n # may be out od order\n set req.url = boltsort.sort(req.url);\n\n # Rewrite \/static\/versionxxxxx URLs. Avoids us having to rewrite on nginx layer\n if (req.url ~ \"^\/static\/version(\\d*\/)?(.*)$\") {\n set req.url = \"\/static\/\" + re.group.2 + \"?\" + re.group.1;\n }\n \n # User's Cookie may contain some Magento Vary items we should vary on\n if (req.http.cookie:X-Magento-Vary ) {\n set req.http.X-Magento-Vary = req.http.cookie:X-Magento-Vary;\n } else {\n unset req.http.X-Magento-Vary;\n }\n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n if (!req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n error 403;\n }\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n\n } else {\n error 403;\n }\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (req.http.Fastly-FF) {\n # disable ESI processing on Origin Shield\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie:X-Magento-Vary || req.http.cookie:form_key) {\n error 200 \"\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url.qs !~ \"country_code=\" ) {\n set req.url = req.url \"?country_code=\" if ( req.http.geo_override, req.http.geo_override, client.geo.country_code);\n }\n }\n } else {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking\n set req.http.Magento-Original-URL = req.url;\n set req.url = querystring.regfilter(req.url, \"^(utm_.*|gclid|gdftrk|_ga|mc_.*)\");\n }\n \n # Pass on checkout URLs. Because it's a snippet we want to execute this after backend selection so we handle it\n # in the request condition\n if (req.url ~ \"\/(catalogsearch|checkout)\") {\n set req.http.x-pass = \"1\";\n # Pass all admin actions\n } else if ( req.url ~ \"^\/(index\\.php\/)?admin(_.*)?\/\" ) {\n set req.http.x-pass = \"1\";\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"1b9586bbae38ba92e808fe2292e59ed7e6df9979","subject":"Making sure country_code is appended correctly even if there is an existing query argument","message":"Making sure country_code is appended correctly even if there is an existing query argument\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets\/recv.vcl","new_file":"etc\/vcl_snippets\/recv.vcl","new_contents":" # VCL required to support maintenance mode. Don't maintenance mode admin pages and supporting assets\n if (table.lookup(magentomodule_config, \"allow_super_users_during_maint\", \"0\") == \"1\" &&\n !req.http.Fastly-Client-Ip ~ maint_allowlist &&\n !req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" &&\n !req.url ~ \"^\/pub\/static\/\") {\n\n # If we end up here after a restart and there is a ResponseObject it means we got here after error\n # page VCL restart. We shouldn't touch it. Otherwise return a plain 503 error page\n if ( req.restarts > 0 && req.http.ResponseObject ) {\n set req.http.ResponseObject = \"970\";\n } else {\n error 503 \"Maintenance mode\";\n }\n }\n\n # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n unset req.http.x-long-cache;\n\n # We want to force long cache times on any of the versioned assets\n if (req.url.path ~ \"^\/static\/version\\d*\/\") {\n set req.http.x-long-cache = \"1\";\n }\n \n # User's Cookie may contain some Magento Vary items we should vary on\n if (req.http.cookie:X-Magento-Vary ) {\n set req.http.X-Magento-Vary = req.http.cookie:X-Magento-Vary;\n } else {\n unset req.http.X-Magento-Vary;\n }\n\n ############################################################################################################\n # Following code block controls purge by URL. By default we want to protect all URL purges. In general this\n # is addressed by adding Fastly-Purge-Requires-Auth request header in vcl_recv however this runs the risk of\n # exposing API tokens if user attempts to purge non-https URLs. For this reason inside the Magento module\n # we use X-Purge-Token. Unfortunately this breaks purge from the Fastly UI. Therefore in the next code block\n # we check for presence of X-Purge-Token. If it's not present we force the Fastly-Purge-Requires-Auth\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n if (req.http.X-Purge-Token && req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n } else {\n error 403;\n }\n } else {\n set req.http.Fastly-Purge-Requires-Auth = \"1\";\n }\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (fastly.ff.visits_this_service > 0) {\n # disable ESI processing on Origin Shield\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Make sure we lookup end user geo not shielding. More at https:\/\/docs.fastly.com\/vcl\/geolocation\/#using-geographic-variables-with-shielding\n set client.geo.ip_override = req.http.Fastly-Client-IP;\n\n # geoip lookup\n if (req.url.path ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie:X-Magento-Vary || req.http.cookie:form_key) {\n error 980 \"GeoIP already processed\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url.qs !~ \"country_code=\" ) {\n set req.url = querystring.set(req.url, \"country_code\", if ( req.http.geo_override, req.http.geo_override, client.geo.country_code));\n }\n }\n } else {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking by default\n # and allow custom parameters to be set. List of parameters is configurable in admin\n set req.http.Magento-Original-URL = req.url;\n # Change the list of ignored parameters by configuring them in the Advanced section\n set req.url = querystring.regfilter(req.url, \"^(####QUERY_PARAMETERS####)\");\n }\n\n # Don't allow clients to force a pass\n if (req.restarts == 0) {\n unset req.http.x-pass;\n unset req.http.Rate-Limit;\n }\n \n # Pass on checkout URLs. Because it's a snippet we want to execute this after backend selection so we handle it\n # in the request condition\n if (!req.http.x-long-cache && req.url ~ \"\/(catalogsearch|checkout|customer\/section\/load)\") {\n set req.http.x-pass = \"1\";\n # Pass all admin actions\n # ####ADMIN_PATH#### is replaced with value of frontName from app\/etc\/env.php\n } else if ( req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" ) {\n set req.http.x-pass = \"1\";\n } else {\n # Sort the query arguments to increase cache hit ratio with query arguments that\n # may be out od order. In case you want to restore the unsorted URL add a snippet\n # after this one that sets req.url to req.http.Magento-Original-URL\n if ( !req.http.x-pass ) {\n set req.url = boltsort.sort(req.url);\n }\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.http.x-long-cache || req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n","old_contents":" # VCL required to support maintenance mode. Don't maintenance mode admin pages and supporting assets\n if (table.lookup(magentomodule_config, \"allow_super_users_during_maint\", \"0\") == \"1\" &&\n !req.http.Fastly-Client-Ip ~ maint_allowlist &&\n !req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" &&\n !req.url ~ \"^\/pub\/static\/\") {\n\n # If we end up here after a restart and there is a ResponseObject it means we got here after error\n # page VCL restart. We shouldn't touch it. Otherwise return a plain 503 error page\n if ( req.restarts > 0 && req.http.ResponseObject ) {\n set req.http.ResponseObject = \"970\";\n } else {\n error 503 \"Maintenance mode\";\n }\n }\n\n # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n unset req.http.x-long-cache;\n\n # We want to force long cache times on any of the versioned assets\n if (req.url.path ~ \"^\/static\/version\\d*\/\") {\n set req.http.x-long-cache = \"1\";\n }\n \n # User's Cookie may contain some Magento Vary items we should vary on\n if (req.http.cookie:X-Magento-Vary ) {\n set req.http.X-Magento-Vary = req.http.cookie:X-Magento-Vary;\n } else {\n unset req.http.X-Magento-Vary;\n }\n\n ############################################################################################################\n # Following code block controls purge by URL. By default we want to protect all URL purges. In general this\n # is addressed by adding Fastly-Purge-Requires-Auth request header in vcl_recv however this runs the risk of\n # exposing API tokens if user attempts to purge non-https URLs. For this reason inside the Magento module\n # we use X-Purge-Token. Unfortunately this breaks purge from the Fastly UI. Therefore in the next code block\n # we check for presence of X-Purge-Token. If it's not present we force the Fastly-Purge-Requires-Auth\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n if (req.http.X-Purge-Token && req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n } else {\n error 403;\n }\n } else {\n set req.http.Fastly-Purge-Requires-Auth = \"1\";\n }\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (fastly.ff.visits_this_service > 0) {\n # disable ESI processing on Origin Shield\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Make sure we lookup end user geo not shielding. More at https:\/\/docs.fastly.com\/vcl\/geolocation\/#using-geographic-variables-with-shielding\n set client.geo.ip_override = req.http.Fastly-Client-IP;\n\n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie:X-Magento-Vary || req.http.cookie:form_key) {\n error 980 \"GeoIP already processed\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url.qs !~ \"country_code=\" && req.url.qs !~ \"uenc=\") {\n set req.url = req.url \"?country_code=\" if ( req.http.geo_override, req.http.geo_override, client.geo.country_code);\n } else {\n set req.url = req.url \"&country_code=\" if ( req.http.geo_override, req.http.geo_override, client.geo.country_code);\n }\n }\n } else {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking by default\n # and allow custom parameters to be set. List of parameters is configurable in admin\n set req.http.Magento-Original-URL = req.url;\n # Change the list of ignored parameters by configuring them in the Advanced section\n set req.url = querystring.regfilter(req.url, \"^(####QUERY_PARAMETERS####)\");\n }\n\n # Don't allow clients to force a pass\n if (req.restarts == 0) {\n unset req.http.x-pass;\n unset req.http.Rate-Limit;\n }\n \n # Pass on checkout URLs. Because it's a snippet we want to execute this after backend selection so we handle it\n # in the request condition\n if (!req.http.x-long-cache && req.url ~ \"\/(catalogsearch|checkout|customer\/section\/load)\") {\n set req.http.x-pass = \"1\";\n # Pass all admin actions\n # ####ADMIN_PATH#### is replaced with value of frontName from app\/etc\/env.php\n } else if ( req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" ) {\n set req.http.x-pass = \"1\";\n } else {\n # Sort the query arguments to increase cache hit ratio with query arguments that\n # may be out od order. In case you want to restore the unsorted URL add a snippet\n # after this one that sets req.url to req.http.Magento-Original-URL\n if ( !req.http.x-pass ) {\n set req.url = boltsort.sort(req.url);\n }\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.http.x-long-cache || req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"69c3a30d656ef32d2667b46dd04303efd5c0448a","subject":"Simplify Token calculation VCL","message":"Simplify Token calculation VCL\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets\/recv.vcl","new_file":"etc\/vcl_snippets\/recv.vcl","new_contents":" # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n # Sort the query arguments\n set req.url = boltsort.sort(req.url);\n\n if (req.url ~ \"^\/static\/version(\\d*\/)?(.*)$\") {\n set req.url = \"\/static\/\" + re.group.2 + \"?\" + re.group.1;\n }\n \n # User's Cookie may contain some Magento Vary items we should vary on\n if (req.http.cookie:X-Magento-Vary ) {\n set req.http.X-Magento-Vary = req.http.cookie:X-Magento-Vary;\n } else {\n unset req.http.X-Magento-Vary;\n }\n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n if (req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n error 403;\n }\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n\n } else {\n error 403;\n }\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (req.http.Fastly-FF) {\n # disable ESI processing on Origin Shield\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie ~ \"(X-Magento-Vary|form_key)=\") {\n error 200 \"\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url !~ \"country_code=\" ) {\n set req.url = req.url \"?country_code=\" if ( req.http.geo_override, req.http.geo_override, geoip.country_code);\n }\n }\n } else {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking\n set req.http.Magento-Original-URL = req.url;\n set req.url = querystring.regfilter(req.url, \"^(utm_.*|gclid|gdftrk|_ga|mc_.*)\");\n }\n \n # Pass on checkout URLs. Because it's a snippet we want to execute this after backend selection so we handle it\n # in the request condition\n if (req.url ~ \"\/(catalogsearch|checkout)\") {\n set req.http.x-pass = \"1\";\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n","old_contents":" # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n # Sort the query arguments\n set req.url = boltsort.sort(req.url);\n\n if (req.url ~ \"^\/static\/version(\\d*\/)?(.*)$\") {\n set req.url = \"\/static\/\" + re.group.2 + \"?\" + re.group.1;\n }\n \n # User's Cookie may contain some Magento Vary items we should vary on\n if (req.http.cookie:X-Magento-Vary ) {\n set req.http.X-Magento-Vary = req.http.cookie:X-Magento-Vary;\n } else {\n unset req.http.X-Magento-Vary;\n }\n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n set req.http.X-Sig = regsub(req.http.X-Purge-Token, \"^[^_]+_(.*)\", \"\\1\");\n set req.http.X-Exp = regsub(req.http.X-Purge-Token, \"^([^_]+)_.*\", \"\\1\");\n\n # validate signature\n if (req.http.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path req.http.X-Exp), \"^0x\", \"\")) {\n\n # use vcl time math to check expiration timestamp\n set req.http.X-Original-Grace = req.grace;\n set req.grace = std.atoi(strftime({\"%s\"}, now));\n set req.grace -= std.atoi(req.http.X-Exp);\n\n if (std.atoi(req.grace) > 0) {\n error 410;\n }\n\n # clean up grace since we used it for time math\n set req.grace = std.atoi(req.http.X-Original-Grace);\n unset req.http.X-Original-Grace;\n\n } else {\n error 403;\n }\n\n # cleanup variables\n unset req.http.X-Purge-Token;\n unset req.http.X-Sig;\n unset req.http.X-Exp;\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (req.http.Fastly-FF) {\n # disable ESI processing on Origin Shield\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie ~ \"(X-Magento-Vary|form_key)=\") {\n error 200 \"\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url !~ \"country_code=\" ) {\n set req.url = req.url \"?country_code=\" if ( req.http.geo_override, req.http.geo_override, geoip.country_code);\n }\n }\n } else {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking\n set req.http.Magento-Original-URL = req.url;\n set req.url = querystring.regfilter(req.url, \"^(utm_.*|gclid|gdftrk|_ga|mc_.*)\");\n }\n \n # Pass on checkout URLs. Because it's a snippet we want to execute this after backend selection so we handle it\n # in the request condition\n if (req.url ~ \"\/(catalogsearch|checkout)\") {\n set req.http.x-pass = \"1\";\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"46f628a975238ecea2e88087ef97ef5bb9e1ff13","subject":"Only restart on 502 and 503 errors","message":"Only restart on 502 and 503 errors\n\nIf our app is sending 500 errors we don't want to increase the\ntraffic to it incase it's a load issue, however restarting on\n502 and 503 is fine.\n","repos":"dstufft\/warehouse,alex\/warehouse,HonzaKral\/warehouse,wlonk\/warehouse,ismail-s\/warehouse,pypa\/warehouse,pypa\/warehouse,karan\/warehouse,alex\/warehouse,alex\/warehouse,pypa\/warehouse,ismail-s\/warehouse,HonzaKral\/warehouse,karan\/warehouse,ismail-s\/warehouse,HonzaKral\/warehouse,wlonk\/warehouse,dstufft\/warehouse,alex\/warehouse,HonzaKral\/warehouse,karan\/warehouse,karan\/warehouse,karan\/warehouse,dstufft\/warehouse,ismail-s\/warehouse,alex\/warehouse,dstufft\/warehouse,wlonk\/warehouse,pypa\/warehouse,ismail-s\/warehouse","old_file":"vcl\/main.vcl","new_file":"vcl\/main.vcl","new_contents":"\nsub vcl_recv {\n#FASTLY recv\n\n # Disable ESI processing when doing a shield request.\n if (req.http.Fastly-FF) {\n set req.esi = false;\n }\n\n # If we're serving an ESI request, and the request in question has NOT\n # opted into cookies, then we'll go ahead and strip any cookies from the\n # request. In addition, we'll strip out any Authorization or Authentication\n # headers.\n if (req.url ~ \"^\/_esi\/\") {\n unset req.http.Authenticate;\n unset req.http.Authorization;\n\n if (req.url !~ \"esi-cookies=1\") {\n unset req.http.Cookie;\n }\n }\n\n # We want to Force SSL for the WebUI by redirecting to the HTTPS version of\n # the page, however for API calls we want to return an error code directing\n # people to instead use HTTPS.\n if (!req.http.Fastly-SSL) {\n\n # The \/simple\/ and \/packages\/ API.\n if (req.url ~ \"^\/(simple|packages)\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy JSON API.\n if (req.url ~ \"^\/pypi\/.+\/json$\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy ?:action= API.\n if (req.url ~ \"^\/pypi.*(\\?|&)=:action\") {\n error 803 \"SSL is required\";\n }\n\n # If we're on the \/pypi page and we've received something other than a\n # GET or HEAD request, then we have no way to determine if a particular\n # request is an API call or not because it'll be in the request body\n # and that isn't available to us here. So in those cases, we won't\n # do a redirect.\n if (req.url ~ \"^\/pypi\") {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n error 801 \"Force SSL\";\n }\n }\n else {\n # This isn't a \/pypi URL so we'll just unconditionally redirect to\n # HTTPS.\n error 801 \"Force SSL\";\n }\n }\n\n # Set a header to tell the backend if we're using https or http.\n if (req.http.Fastly-SSL) {\n set req.http.Warehouse-Proto = \"https\";\n } else {\n set req.http.Warehouse-Proto = \"http\";\n }\n\n # Pass the client IP address back to the backend.\n if (req.http.Fastly-Client-IP) {\n set req.http.Warehouse-IP = req.http.Fastly-Client-IP;\n }\n\n # Pass the real host value back to the backend.\n if (req.http.Host) {\n set req.http.Warehouse-Host = req.http.Host;\n }\n\n # Do not bother to attempt to run the caching mechanisms for methods that\n # are not generally safe to cache.\n if (req.request != \"HEAD\" &&\n req.request != \"GET\" &&\n req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n # Finally, return the default lookup action.\n return(lookup);\n}\n\n\nsub vcl_fetch {\n#FASTLY fetch\n\n # Only enable ESI on responses that have opted into them.\n if (beresp.http.Warehouse-ESI-Enable) {\n # Conditional HTTP requests are not compatible with Varnish's\n # implementation of ESI, in particularl the ETag and the Last-Modified\n # won't be updated when the included content changes, causing Varnish\n # to return a 304 Not Modified.\n unset beresp.http.ETag;\n unset beresp.http.Last-Modified;\n\n # Enable ESI.\n esi;\n }\n\n # Trigger a \"SSL is required\" error if the backend has indicated to do so.\n if (beresp.http.X-Fastly-Error == \"803\") {\n error 803 \"SSL is required\";\n }\n\n # If we've gotten a 502 or a 503 from the backend, we'll go ahead and retry\n # the request.\n if ((beresp.status == 502 || beresp.status == 503) &&\n req.restarts < 1 &&\n (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n # If we've restarted, then we'll record the number of restarts.\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n # If there is a Set-Cookie header, we'll ensure that we do not cache the\n # response.\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n # If the response has the private Cache-Control directive then we won't\n # cache it.\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # If we've gotten an error after the restarts we'll deliver the response\n # with a very short cache time.\n if (beresp.status == 500 || beresp.status == 503) {\n # If this is a ESI request, then instead of returning the error we're\n # going to return a blank page so that our top level page acts as if it\n # did not have ESI rather than inlining the error page.\n if (req.url ~ \"^\/_esi\/\") {\n error 900 \"ESI Error\";\n }\n\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n # Apply a default TTL if there isn't a max-age or s-maxage.\n if (beresp.http.Expires ||\n beresp.http.Surrogate-Control ~ \"max-age\" ||\n beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # Keep the ttl here\n }\n else {\n # Apply the default ttl\n set beresp.ttl = 60s;\n }\n\n # Actually deliver the fetched response.\n return(deliver);\n}\n\n\nsub vcl_deliver {\n#FASTLY deliver\n\n # If the backend has indicated additional Vary headers to add once the\n # ESI result has been processed, then we'll go ahead and either append them\n # to our existing Vary header or we'll set the Vary header equal to it.\n # However, we only want this logic to happen on the edge nodes, not on the\n # shielding nodes.\n if (resp.http.Warehouse-ESI-Vary && !req.http.Fastly-FF) {\n if (resp.http.Vary) {\n set resp.http.Vary = resp.http.Vary \", \" resp.http.Warehouse-ESI-Vary;\n } else {\n set resp.http.Vary = resp.http.Warehouse-ESI-Vary;\n }\n\n unset resp.http.Warehouse-ESI-Vary;\n }\n\n # We no longer need the header that enables ESI, so we'll remove it from\n # the output if we're not on a shielding node, otherwise we want to pass\n # this header on to the edge nodes so that they can handle the ESI.\n if (!req.http.Fastly-FF) {\n unset resp.http.Warehouse-ESI-Enable;\n }\n\n # Unset headers that we don't need\/want to send on to the client because\n # they are not generally useful.\n unset resp.http.Server;\n unset resp.http.Via;\n\n return(deliver);\n}\n\n\nsub vcl_error {\n#FASTLY error\n\n if (obj.status == 803) {\n set obj.status = 403;\n set obj.response = \"SSL is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic {\"SSL is required.\"};\n return (deliver);\n } else if (obj.status == 900) {\n set obj.status = 500;\n set obj.response = \"500 ESI Error\";\n set obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n synthetic {\"\"};\n return(deliver);\n }\n}\n","old_contents":"\nsub vcl_recv {\n#FASTLY recv\n\n # Disable ESI processing when doing a shield request.\n if (req.http.Fastly-FF) {\n set req.esi = false;\n }\n\n # If we're serving an ESI request, and the request in question has NOT\n # opted into cookies, then we'll go ahead and strip any cookies from the\n # request. In addition, we'll strip out any Authorization or Authentication\n # headers.\n if (req.url ~ \"^\/_esi\/\") {\n unset req.http.Authenticate;\n unset req.http.Authorization;\n\n if (req.url !~ \"esi-cookies=1\") {\n unset req.http.Cookie;\n }\n }\n\n # We want to Force SSL for the WebUI by redirecting to the HTTPS version of\n # the page, however for API calls we want to return an error code directing\n # people to instead use HTTPS.\n if (!req.http.Fastly-SSL) {\n\n # The \/simple\/ and \/packages\/ API.\n if (req.url ~ \"^\/(simple|packages)\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy JSON API.\n if (req.url ~ \"^\/pypi\/.+\/json$\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy ?:action= API.\n if (req.url ~ \"^\/pypi.*(\\?|&)=:action\") {\n error 803 \"SSL is required\";\n }\n\n # If we're on the \/pypi page and we've received something other than a\n # GET or HEAD request, then we have no way to determine if a particular\n # request is an API call or not because it'll be in the request body\n # and that isn't available to us here. So in those cases, we won't\n # do a redirect.\n if (req.url ~ \"^\/pypi\") {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n error 801 \"Force SSL\";\n }\n }\n else {\n # This isn't a \/pypi URL so we'll just unconditionally redirect to\n # HTTPS.\n error 801 \"Force SSL\";\n }\n }\n\n # Set a header to tell the backend if we're using https or http.\n if (req.http.Fastly-SSL) {\n set req.http.Warehouse-Proto = \"https\";\n } else {\n set req.http.Warehouse-Proto = \"http\";\n }\n\n # Pass the client IP address back to the backend.\n if (req.http.Fastly-Client-IP) {\n set req.http.Warehouse-IP = req.http.Fastly-Client-IP;\n }\n\n # Pass the real host value back to the backend.\n if (req.http.Host) {\n set req.http.Warehouse-Host = req.http.Host;\n }\n\n # Do not bother to attempt to run the caching mechanisms for methods that\n # are not generally safe to cache.\n if (req.request != \"HEAD\" &&\n req.request != \"GET\" &&\n req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n # Finally, return the default lookup action.\n return(lookup);\n}\n\n\nsub vcl_fetch {\n#FASTLY fetch\n\n # Only enable ESI on responses that have opted into them.\n if (beresp.http.Warehouse-ESI-Enable) {\n # Conditional HTTP requests are not compatible with Varnish's\n # implementation of ESI, in particularl the ETag and the Last-Modified\n # won't be updated when the included content changes, causing Varnish\n # to return a 304 Not Modified.\n unset beresp.http.ETag;\n unset beresp.http.Last-Modified;\n\n # Enable ESI.\n esi;\n }\n\n # Trigger a \"SSL is required\" error if the backend has indicated to do so.\n if (beresp.http.X-Fastly-Error == \"803\") {\n error 803 \"SSL is required\";\n }\n\n # If we've gotten a 500 or a 503 from the backend, we'll go ahead and retry\n # the request.\n if ((beresp.status == 500 || beresp.status == 503) &&\n req.restarts < 1 &&\n (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n # If we've restarted, then we'll record the number of restarts.\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n # If there is a Set-Cookie header, we'll ensure that we do not cache the\n # response.\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n # If the response has the private Cache-Control directive then we won't\n # cache it.\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # If we've gotten an error after the restarts we'll deliver the response\n # with a very short cache time.\n if (beresp.status == 500 || beresp.status == 503) {\n # If this is a ESI request, then instead of returning the error we're\n # going to return a blank page so that our top level page acts as if it\n # did not have ESI rather than inlining the error page.\n if (req.url ~ \"^\/_esi\/\") {\n error 900 \"ESI Error\";\n }\n\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n # Apply a default TTL if there isn't a max-age or s-maxage.\n if (beresp.http.Expires ||\n beresp.http.Surrogate-Control ~ \"max-age\" ||\n beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # Keep the ttl here\n }\n else {\n # Apply the default ttl\n set beresp.ttl = 60s;\n }\n\n # Actually deliver the fetched response.\n return(deliver);\n}\n\n\nsub vcl_deliver {\n#FASTLY deliver\n\n # If the backend has indicated additional Vary headers to add once the\n # ESI result has been processed, then we'll go ahead and either append them\n # to our existing Vary header or we'll set the Vary header equal to it.\n # However, we only want this logic to happen on the edge nodes, not on the\n # shielding nodes.\n if (resp.http.Warehouse-ESI-Vary && !req.http.Fastly-FF) {\n if (resp.http.Vary) {\n set resp.http.Vary = resp.http.Vary \", \" resp.http.Warehouse-ESI-Vary;\n } else {\n set resp.http.Vary = resp.http.Warehouse-ESI-Vary;\n }\n\n unset resp.http.Warehouse-ESI-Vary;\n }\n\n # We no longer need the header that enables ESI, so we'll remove it from\n # the output if we're not on a shielding node, otherwise we want to pass\n # this header on to the edge nodes so that they can handle the ESI.\n if (!req.http.Fastly-FF) {\n unset resp.http.Warehouse-ESI-Enable;\n }\n\n # Unset headers that we don't need\/want to send on to the client because\n # they are not generally useful.\n unset resp.http.Server;\n unset resp.http.Via;\n\n return(deliver);\n}\n\n\nsub vcl_error {\n#FASTLY error\n\n if (obj.status == 803) {\n set obj.status = 403;\n set obj.response = \"SSL is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic {\"SSL is required.\"};\n return (deliver);\n } else if (obj.status == 900) {\n set obj.status = 500;\n set obj.response = \"500 ESI Error\";\n set obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n synthetic {\"\"};\n return(deliver);\n }\n}\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"2ccf1b62fff566763df7f483f5044268e6254cf4","subject":"Some minor improvements","message":"Some minor improvements\n","repos":"alarky\/varnish-cache-doc-ja,gauthier-delacroix\/Varnish-Cache,chrismoulton\/Varnish-Cache,mrhmouse\/Varnish-Cache,alarky\/varnish-cache-doc-ja,feld\/Varnish-Cache,franciscovg\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,mrhmouse\/Varnish-Cache,varnish\/Varnish-Cache,gquintard\/Varnish-Cache,gquintard\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,alarky\/varnish-cache-doc-ja,zhoualbeart\/Varnish-Cache,franciscovg\/Varnish-Cache,alarky\/varnish-cache-doc-ja,gauthier-delacroix\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,mrhmouse\/Varnish-Cache,varnish\/Varnish-Cache,zhoualbeart\/Varnish-Cache,chrismoulton\/Varnish-Cache,alarky\/varnish-cache-doc-ja,varnish\/Varnish-Cache,franciscovg\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,gquintard\/Varnish-Cache,mrhmouse\/Varnish-Cache,varnish\/Varnish-Cache,zhoualbeart\/Varnish-Cache,zhoualbeart\/Varnish-Cache,feld\/Varnish-Cache,chrismoulton\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,zhoualbeart\/Varnish-Cache,franciscovg\/Varnish-Cache,mrhmouse\/Varnish-Cache,feld\/Varnish-Cache,feld\/Varnish-Cache,feld\/Varnish-Cache,chrismoulton\/Varnish-Cache,chrismoulton\/Varnish-Cache,varnish\/Varnish-Cache,gquintard\/Varnish-Cache,franciscovg\/Varnish-Cache","old_file":"etc\/example.vcl","new_file":"etc\/example.vcl","new_contents":"#\n# This is an example VCL file for Varnish.\n#\n# It does not do anything by default, delegating control to the builtin vcl.\n# The builtin VCL is called when there is no explicit explicit return\n# statement.\n#\n# See the VCL tutorial at https:\/\/www.varnish-cache.org\/docs\/trunk\/tutorial\/\n# and http:\/\/varnish-cache.org\/trac\/wiki\/VCLExamples for more examples.\n\n# Marker to tell the VCL compiler that this VCL has been adapted to the\n# new 4.0 format.\nvcl 4.0;\n\n# Default backend definition. Set this to point to your content server.\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\n\nsub vcl_recv {\n # Happens before we check if we have this in cache already.\n # See http:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/vcl.html#vcl_recv\n}\n\nsub vcl_backend_response {\n # Happens after we have read the response headers from the backend.\n # See http:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/vcl.html#vcl_fetch\n}\n\nsub vcl_deliver {\n # Happens when we have all the pieces we need, and are about to send the\n # response to the client.\n # See http:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/vcl.html#vcl_fetch\n}\n","old_contents":"#\n# This is an example VCL file for Varnish.\n# It does not do anything by default, delegating control to the builtin vcl.\n# The builtin VCL is called when there is no explicit explicit return\n# statement.\n\n# See the VCL tutorial at https:\/\/www.varnish-cache.org\/docs\/trunk\/tutorial\/\n# See http:\/\/varnish-cache.org\/trac\/wiki\/VCLExamples for more examples.\n\n# Marker to tell the VCL compiler that this VCL has been adapted to the new 4.0\n# format.\nvcl 4.0;\n\n# Default backend definition. Set this to point to your content server.\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\n\nsub vcl_recv {\n # Happens before we check if we have this in cache already.\n # See http:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/vcl.html#vcl_recv\n}\n\nsub vcl_backend_response {\n # Happens after we have read the response headers from the backend.\n # See http:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/vcl.html#vcl_fetch\n#\n}\n\nsub vcl_deliver {\n # Happens when we have all the pieces we need, and are about to send the\n # response to the client.\n # See http:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/vcl.html#vcl_fetch\n}\n\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"39d11d2f58dc8bc10e3a88cd4dd056d8a583c467","subject":"Cleanup Varnish configuration","message":"Cleanup Varnish configuration\n","repos":"ewolff\/SCS-ESI,ewolff\/SCS-ESI,ewolff\/SCS-ESI,ewolff\/SCS-ESI","old_file":"docker\/varnish\/default.vcl","new_file":"docker\/varnish\/default.vcl","new_contents":"vcl 4.0;\n\nbackend default {\n .host = \"order\";\n .port = \"8080\";\n}\n\nbackend common {\n .host = \"common\";\n .port = \"8180\";\n}\n\nsub vcl_recv {\n \/* Redirect all requests to \/common to go to the common *\/\n if (req.url ~ \"^\/common\") {\n set req.backend_hint = common;\n }\n}\n\nsub vcl_backend_response {\n set beresp.do_esi = true;\n set beresp.ttl = 30s;\n set beresp.grace = 15m;\n}\n\n","old_contents":"# See the VCL chapters in the Users Guide at https:\/\/www.varnish-cache.org\/docs\/\n# and http:\/\/varnish-cache.org\/trac\/wiki\/VCLExamples for more examples.\n\n# Marker to tell the VCL compiler that this VCL has been adapted to the\n# new 4.0 format.\nvcl 4.0;\n\n# Default backend definition.\nbackend default {\n .host = \"order\";\n .port = \"8080\";\n}\n\nbackend common {\n .host = \"common\";\n .port = \"8180\";\n}\n\nsub vcl_recv {\n # Happens before we check if we have this in cache already.\n \/* Rewrite all requests to \/common to go to the common SCS *\/\n if (req.url ~ \"^\/common\") {\n set req.backend_hint = common;\n }\n}\n\nsub vcl_backend_response {\n # Happens after we have read the response headers from the backend.\n \/* Enable ESI *\/\n set beresp.do_esi = true;\n set beresp.ttl = 30s;\n set beresp.grace = 15m;\n}\n\nsub vcl_deliver {\n # Happens when we have all the pieces we need, and are about to send the\n # response to the client.\n #\n # You can do accounting or modifying the final object here.\n}","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"1df11b6009ca1277660a6a79f9a37796676ec609","subject":"For consistency do not use nested regex","message":"For consistency do not use nested regex\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets\/fetch.vcl","new_file":"etc\/vcl_snippets\/fetch.vcl","new_contents":" \/* handle 5XX (or any other unwanted status code) *\/\n if (beresp.status >= 500 && beresp.status < 600) {\n\n \/* deliver stale if the object is available *\/\n if (stale.exists) {\n return(deliver_stale);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n \/* else go to vcl_error to deliver a synthetic *\/\n error beresp.status beresp.response;\n }\n\n # Remove Set-Cookies from responses for static content\n # to match the cookie removal in recv.\n if (req.http.x-long-cache || req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's since those can be temporary during the site build\/index\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n }\n\n }\n\n # Force caching for signed cached assets.\n if (req.http.x-long-cache) {\n set beresp.ttl = 31536000s;\n set beresp.http.Cache-Control = \"max-age=31536000, immutable\";\n }\n\n # All the Magento responses should emit X-Esi headers\n if (beresp.http.x-esi) {\n # enable ESI feature for Magento response by default\n esi;\n if (!beresp.http.Vary ~ \"X-Magento-Vary,Https\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \",X-Magento-Vary,Https\";\n } else {\n set beresp.http.Vary = \"X-Magento-Vary,Https\";\n }\n }\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content except\n if ( http_status_matches(beresp.status, \"200,404\") && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|text\\\/html|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url.ext ~ \"(?i)(css|js|html|eot|ico|otf|ttf|json)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n if (beresp.http.Cache-Control ~ \"private|no-cache|no-store\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # Never cache 302s\n if (beresp.status == 302) {\n return (pass);\n }\n\n # Just in case the Request Setting for x-pass is missing\n if (req.http.x-pass) {\n return (pass);\n }\n\n # Varnish sets default TTL if none of these are present\n if (!beresp.http.Expires && !beresp.http.Surrogate-Control ~ \"max-age\" && !beresp.http.Cache-Control ~ \"(s-maxage|max-age)\") {\n set beresp.ttl = 0s;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\") && !req.http.x-pass ) {\n unset beresp.http.set-cookie;\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type if they are image\/script or CSS\n if (beresp.http.Content-Type ~ \"(image|script|css)\") {\n set beresp.http.Surrogate-Key = re.group.1;\n }\n }\n","old_contents":" \/* handle 5XX (or any other unwanted status code) *\/\n if (beresp.status >= 500 && beresp.status < 600) {\n\n \/* deliver stale if the object is available *\/\n if (stale.exists) {\n return(deliver_stale);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n \/* else go to vcl_error to deliver a synthetic *\/\n error beresp.status beresp.response;\n }\n\n # Remove Set-Cookies from responses for static content\n # to match the cookie removal in recv.\n if (req.http.x-long-cache || req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's since those can be temporary during the site build\/index\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n }\n\n }\n\n # Force caching for signed cached assets.\n if (req.http.x-long-cache) {\n set beresp.ttl = 31536000s;\n set beresp.http.Cache-Control = \"max-age=31536000, immutable\";\n }\n\n # All the Magento responses should emit X-Esi headers\n if (beresp.http.x-esi) {\n # enable ESI feature for Magento response by default\n esi;\n if (!beresp.http.Vary ~ \"X-Magento-Vary,Https\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \",X-Magento-Vary,Https\";\n } else {\n set beresp.http.Vary = \"X-Magento-Vary,Https\";\n }\n }\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content except\n if ( http_status_matches(beresp.status, \"200,404\") && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/(css|html)|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url.ext ~ \"(?i)(css|js|html|eot|ico|otf|ttf|json)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n if (beresp.http.Cache-Control ~ \"private|no-cache|no-store\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # Never cache 302s\n if (beresp.status == 302) {\n return (pass);\n }\n\n # Just in case the Request Setting for x-pass is missing\n if (req.http.x-pass) {\n return (pass);\n }\n\n # Varnish sets default TTL if none of these are present\n if (!beresp.http.Expires && !beresp.http.Surrogate-Control ~ \"max-age\" && !beresp.http.Cache-Control ~ \"(s-maxage|max-age)\") {\n set beresp.ttl = 0s;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\") && !req.http.x-pass ) {\n unset beresp.http.set-cookie;\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type if they are image\/script or CSS\n if (beresp.http.Content-Type ~ \"(image|script|css)\") {\n set beresp.http.Surrogate-Key = re.group.1;\n }\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"f887e2e08071e8ab40a2ea4951b652cd4ec63d7f","subject":"Added commands","message":"Added commands\n","repos":"aschneiderman\/atom-voice-vocola","old_file":"atom.vcl","new_file":"atom.vcl","new_contents":"# Voice commands for atom\n\ninclude folders.vch;\ninclude letters.vch;\n\nFind (File | Document) = {Ctrl+t};\nSave As = {Ctrl+Shift+s};\nSave and Reload = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Ctrl+r};\n\n<delimiters> := (Quote = '\"' | 'Single Quote' = \"'\" | Comma = ',' | 'Equal Sign' = '=' | Equals = '=' \n\t| Period = '.' | 'Semi-Colon' = ';');\n\n# --- Navigation commands ------------------------------------\nLine 1..200 = {Ctrl+g} $1 {Enter};\n(Left = 'b' | Right = 'f') Word = {Alt+$1};\nTop = {Ctrl+Home};\nBottom = {Ctrl+End};\n(Find = 'Right' | 'Insert After' = 'Right' | 'Insert Before' = 'Left') (Next = 'Enter' | Last = 'Shift+F3') <delimiters> \n\t\t= {Ctrl+f} $3 {$2} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') <delimiters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nFine Alpha <letters> = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Right};\nInsert (Before = 'Left' | After = 'Right') Alpha <letters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nFine Number 0..9 = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Right};\nFind Again = {F3} {Right};\nFind Again 1..20 Times = {F3_$1} {Right};\n\nFind Symbol = {Ctrl+r};\n\n(Set | Add | Clear | Hide | Delete) Bookmark = {Ctrl+Alt+F2};\n(Next = 'F2' | Last = 'Shift+F2') Bookmark = {$1};\n\nNext Window = {Ctrl+Tab};\nLast Window = {Ctrl+Shift+Tab};\n\n\n# --- Editing commands ----------------------------------------\nSelect (Next = 'Down' | Last = 'Up') 1..20 Lines = {Home} {Shift+$1_$2};\n(Join = 'j' | Indent = ']' | Dedent = '[') That = {Ctrl+$1};\nMove Line (Up | Down) 1..20 = {Ctrl+$1_$2};\n\n\n\nDelete Word = {Ctrl+Del};\nDelete 1..20 Words = {Ctrl+Del_$1};\n(Delete Line | Dede) = {Ctrl+Shift+k};\nDelete 1..20 Lines = {Ctrl+Shift+k_$1};\n(Cut = 'x' | Paste = 'v' | Copy = 'c') That = {Ctrl+$1};\n\nSelect between (Delimiters | Brackets) ={Ctrl+m} {Ctrl+Alt+m};\n# TO ADD:\n# Delete back three words\n# delete between next tags\n\n\n\n\n# --- Code commands -------------------------------------------\nStart (Item = 'li' | List = 'ul' | HTML = 'html' | pre = \"pre\"\n\t| 'Bold ID' = 'bold-id' | 'Input' = 'ds-input-text'\n\t| Snippet = 'snip' | 'Recipe Row' = 'recipe-row' | 'Recipe Play' = 'recipe-play') = $1 {Tab};\nStart (para = '<p>' ) = $1;\nStart (Header | Heading) 1..7 = h $2 {Tab}; \nMid HREF = '\">';\n\nPaste Function = 'function ' {Ctrl+v} ' {' {Enter} {Enter} '};' {Up};\n\n# TO ADD:\n# adding HTML comments, using a snippet\n\nShortcut Keys = {Ctrl+Shift+p};\n\n","old_contents":"# Voice commands for atom\n\ninclude folders.vch;\ninclude letters.vch;\n\nFind (File | Document) = {Ctrl+t};\nSave As = {Ctrl+Shift+s};\nSave and Reload = {Ctrl+s} Wait(100) {Alt+Tab} Wait(300);\n\n<delimiters> := (Quote = '\"' | 'Single Quote' = \"'\" | Comma = ',' | 'Equal Sign' = '=' | Equals = '=' \n\t| Period = '.' | 'Semi-Colon' = ';');\n\n# --- Navigation commands ------------------------------------\nLine 1..200 = {Ctrl+g} $1 {Enter};\n(Left = 'b' | Right = 'f') Word = {Alt+$1};\nTop = {Ctrl+Home};\nBottom = {Ctrl+End};\n(Find = 'Right' | 'Insert After' = 'Right' | 'Insert Before' = 'Left') (Next = 'Enter' | Last = 'Shift+F3') <delimiters> \n\t\t= {Ctrl+f} $3 {$2} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') <delimiters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nFine Alpha <letters> = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Right};\nInsert (Before = 'Left' | After = 'Right') Alpha <letters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nFine Number 0..9 = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Right};\nFind Again = {F3} {Right};\nFind Again 1..20 Times = {F3_$1} {Right};\n\nFind Symbol = {Ctrl+r};\n\n(Set | Add | Clear | Hide | Delete) Bookmark = {Ctrl+Alt+F2};\n(Next = 'F2' | Last = 'Shift+F2') Bookmark = {$1};\n\nNext Window = {Ctrl+Tab};\nLast Window = {Ctrl+Shift+Tab};\n\n\n# --- Editing commands ----------------------------------------\nSelect (Next = 'Down' | Last = 'Up') 1..20 Lines = {Home} {Shift+$1_$2};\n(Join = 'j' | Indent = ']' | Dedent = '[') That = {Ctrl+$1};\nMove Line (Up | Down) 1..20 = {Ctrl+$1_$2};\n\n\n\nDelete Word = {Ctrl+Del};\nDelete 1..20 Words = {Ctrl+Del_$1};\n(Delete Line | Dede) = {Ctrl+Shift+k};\nDelete 1..20 Lines = {Ctrl+Shift+k_$1};\n(Cut = 'x' | Paste = 'v' | Copy = 'c') That = {Ctrl+$1};\n\nSelect between (Delimiters | Brackets) ={Ctrl+m} {Ctrl+Alt+m};\n# TO ADD:\n# Delete back three words\n# delete between next tags\n\n\n\n\n# --- Code commands -------------------------------------------\nStart (Item = 'li' | List = 'ul' | HTML = 'html' | pre = \"pre\"\n\t| 'Bold ID' = 'bold-id' | 'Input' = 'ds-input-text'\n\t| Snippet = 'snip' | 'Recipe Row' = 'recipe-row' | 'Recipe Play' = 'recipe-play') = $1 {Tab};\nStart (para = '<p>' ) = $1;\nStart (Header | Heading) 1..7 = h $2 {Tab}; \nMid HREF = '\">';\n\nPaste Function = 'function ' {Ctrl+v} ' {' {Enter} {Enter} '};' {Up};\n\n# TO ADD:\n# adding HTML comments, using a snippet\n\nShortcut Keys = {Ctrl+Shift+p};\n\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"c2be73cbeb4b79c79a0f6105c64b3e01cf4ab8f2","subject":"readability counts","message":"readability counts\n","repos":"NITEMAN\/Varnish_VCL_samps-hacks,NITEMAN\/varnish-bites","old_file":"varnish3\/drupal-base.vcl","new_file":"varnish3\/drupal-base.vcl","new_contents":"\/* Varnish 3 example config for Drupal 7 \/ Pressflow 6 & 7 *\/\n# Original source: https:\/\/github.com\/NITEMAN\/varnish-bites\/varnish4\/drupal-base.vcl\n# Copyright (c) 2015 Pedro Gonz\u00e1lez Serrano and individual contributors.\n# MIT License\n\n# Intended to be used both in simple production environments and with learning\/teaching purposes.\n# Loosely based on http:\/\/www.lullabot.com\/sites\/default\/files\/default_varnish3.vcl_.txt\n\n\/* Backend probes \/ healthchecks *\/\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#backend-probes\nprobe basic {\n \/* Only test that backend's IP serves content for '\/' *\/\n # This might be a too heavy probe\n # .url = \"\/\";\n \/* Only test that backend's IP has apache working *\/\n # Nginx would fail this probe with a default config\n .request =\n \"OPTIONS * HTTP\/1.1\"\n \"Host: *\"\n \"Connection: close\";\n .interval = 10s;\n .timeout = 2s;\n .window = 8;\n .threshold = 6;\n}\n\n\n\/* Backend definitions.*\/\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#backend-declarations\nbackend default {\n \/* Default backend on the same machine. WARNING: timeouts could be not big enought for certain POST request *\/\n .host = \"127.0.0.1\";\n .port = \"8008\";\n .connect_timeout = 60s;\n .first_byte_timeout = 60s;\n .between_bytes_timeout = 60s;\n .probe = basic;\n}\n\n\n\/* Directors. *\/\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#directors\n# Empty in simple configs\n\n\n\/* Access Control Lists *\/\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#acls\nacl purge_ban {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use '\"localhost\";' instead\n}\nacl allowed_monitors {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n}\nacl own_proxys {\n \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n}\n\n\n\/* Custom routines *\/\n# Empty in simple configs.\n# We can name subs with no restrictions but as a task can need several chunks of code in diferent states,\n# it's a good idea to identify what main sub will call each with a suffix.\n# \/* Example 301 client redirection removing \"www\" prefix from request *\/\n# sub perm_redirections_recv {\n# if ( req.http.host ~ \"^www.*$\" ) {\n# error 751 \"http:\/\/\" + regsub(req.http.host, \"^www\\.\", \"\") + req.url;\n# }\n# }\n# sub perm_redirections_error {\n# if (obj.status == 751) {\n# \/* Get new URL from the response *\/\n# set obj.http.Location = obj.response;\n# \/* Set HTTP 301 for permanent redirect *\/\n# set obj.status = 301;\n# return(deliver);\n# }\n# }\n\n\n\/* VCL logigc overrides *\/\n# Note that the built-in logic will be appended to our code if no return is performed before.\n# Built-in logic is included commented out right after our's for reference purposes in that cases.\n# See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleDefault\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#subroutines\n\n# vcl_recv: Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use.\nsub vcl_recv {\n \/* 0th: general bypass, general return & authorization checks *\/\n # Empty in simple configs.\n # Useful for debugging we can pipe or pass the request to default backend here to bypass completely Varnish.\n # return (pipe);\n # return (pass);\n # We can also return here a 200 Ok for network performance benchmarking.\n # error 200 \"Ok\";\n # Finally we can perform basic HTTP authentification here by example.\n # See http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* 1st: Check for Varnish special requests *\/ \n # Purge logic.\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/purging.html#http-purges\n # See https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if (req.request == \"PURGE\") {\n if (!client.ip ~ purge_ban) {\n error 405 \"Not allowed.\";\n }\n return (lookup);\n }\n # Ban logic. See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/purging.html#bans\n if (req.request == \"BAN\") {\n if (!client.ip ~ purge_ban) {\n error 405 \"Not allowed.\";\n }\n ban(\"req.http.host == \" + req.http.host +\n \"&& req.url == \" + req.url); \n error 200 \"Ban added\";\n }\n # Custom response implementation example in order to check that Varnish is working properly.\n # This is usefull for automatic monitoring with monit or when Varnish is behind another proxies like HAProxy.\n if ( ( req.http.host == \"monitor.server.health\"\n || req.http.host == \"health.varnish\" )\n && client.ip ~ allowed_monitors\n && ( req.request == \"OPTIONS\" || req.request == \"GET\" )\n ) {\n error 200 \"Ok\";\n }\n\n \/* 2nd: Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_recv;\n # Here we can also enforce SSL when Varnish run behind some SSL termination point.\n\n \/* 3rd: Time for backend choice *\/\n # Empty in simple configs.\n\n \/* 4th: Set custom headers for backend like X-Forwarded-For (copied from built-in logic) *\/\n if ( req.restarts == 0 ) {\n \/* See also vcl_pipe section *\/\n if ( ! client.ip ~ own_proxys ) {\n if ( req.http.x-forwarded-for ) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n }\n\n \/* 5th: Bypass breakpoint 1 *\/\n # Useful for debugging we can now pipe or pass the request to backend with headers setted.\n # return (pipe);\n # return (pass);\n\n \/* 6th: Decide if we should deal with a request (mostly copied from built-in logic) *\/\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n\n \/* 7th: Access control for some URLs by ACL *\/\n # Empty in simple configs.\n # By example denial some URLs depending on client-ip, we'll need to define corresponding ACL 'internal'.\n # if (req.url ~ \"^\/(cron|install)\\.php$\" && !client.ip ~ internal) {\n # # Have Varnish throw the error directly.\n # error 403 \"Forbidden.\";\n # # Use a custom error page that you've defined in Drupal at the path \"404\".\n # # set req.url = \"\/403\";\n # }\n\n \/* 8th: Custom exceptions *\/\n # Host exception example:\n # if (req.http.host == \"ejemplo.exception.com\") {\n # return (pass);\n # }\n # Drupal exceptions, edit if we want to cache some AJAX\/AHAH request.\n # Add here filters for never cache URLs such as Payment Gateway's callbacks\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/ooyala\/ping$\" ||\n req.url ~ \"^\/admin\/build\/features\" ||\n req.url ~ \"^\/info\/.*$\" ||\n req.url ~ \"^\/flag\/.*$\" ||\n req.url ~ \"^.*\/ajax\/.*$\" ||\n req.url ~ \"^.*\/ahah\/.*$\") {\n \/* Do not cache these paths *\/\n return (pass);\n }\n # Pipe these paths directly to backend for streaming.\n if (req.url ~ \"^\/admin\/content\/backup_migrate\/export\") {\n return (pipe);\n }\n if (req.url ~ \"^\/system\/files\") {\n return (pipe);\n }\n\n \/* 9th: Enable grace mode *\/\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/handling_misbehaving_servers.html#grace-mode\n if (! req.backend.healthy) {\n \/* Use a longer grace period if all backends are down *\/\n set req.grace = 1h;\n \/* Use anonymous, cached pages if all backends are down. *\/\n unset req.http.Cookie;\n # TO-DO: Add sick marker\n } else {\n \/* Allow the backend to serve up stale content if it is responding slowly. *\/\n set req.grace = 30s;\n }\n\n \/* 10th: Deal with compression and the Accept-Encoding header *\/\n # Althought Varnish 3 handles gziped content itself by default, just to be sure we want to \n # remove Accept-Encoding for some compressed formats.\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/phk\/gzip.html#what-does-http-gzip-support-do\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/varnishd.html?highlight=http_gzip_support\n # See (for older configs) https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleNormalizeAcceptEncoding\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|mp4|flv|zip|rar)$\") {\n \/* Already compressed formats, no sense trying to compress again *\/\n remove req.http.Accept-Encoding;\n }\n }\n\n \/* 11th: Another header manipulation *\/\n # Empty in simple configs.\n # We could add here a custom header grouping User-agent families.\n\n \/* 12th: Cookie removal *\/\n # Always cache the following static file types for all users. \n # Use with care if we control certain downloads depending on cookies. \n # Be carefull also if appending .htm[l] via Drupal's clean URLs.\n if (req.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|svg|pdf)(\\?[a-z0-9]+)?$\") {\n unset req.http.Cookie;\n }\n # Remove all cookies that backend doesn't need to know about.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRemovingSomeCookies\n if (req.http.Cookie) {\n \/* Warning: Not a pretty solution *\/\n \/* Prefix header containing cookies with ';' *\/\n set req.http.Cookie = \";\" + req.http.Cookie;\n \/* Remove any spaces after ';' in header containing cookies *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n \/* Prefix cookies we want to preserve with one space *\/\n \/* 'S{1,2}ESS[a-z0-9]+' is the regular expression matching a Drupal session cookie ({1,2} added for HTTPS support) *\/\n \/* 'NO_CACHE' is usually set after a POST request to make sure issuing user see the results of his post *\/\n \/* 'OATMEAL' & 'CHOCOLATECHIP' are special cookies used by Drupal's Bakery module to provide Single Sign On *\/\n \/* Keep in mind we should add here any cookie that should reach the backend such as splahs avoiding cookies *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \";(S{1,2}ESS[a-z0-9]+|NO_CACHE|OATMEAL|CHOCOLATECHIP)=\", \"; \\1=\");\n \/* Remove from the header any single Cookie not prefixed with a space until next ';' separator *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n \/* Remove any '; ' at the start or the end of the header *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n\n if (req.http.Cookie == \"\") {\n \/* If there are no remaining cookies, remove the cookie header. *\/\n unset req.http.Cookie;\n }\n }\n\n \/* 13th: Session cookie & special cookies bypass caching stage *\/\n # As we might want to cache some requests, hashed with its cookies, \n # we don't simply pass when some cookies remain present at this point.\n # Instead we look for request that must be passed due to the cookie header.\n if (req.http.Cookie ~ \"SESS\" ||\n req.http.Cookie ~ \"SSESS\" ||\n req.http.Cookie ~ \"NO_CACHE\" ||\n req.http.Cookie ~ \"OATMEAL\" ||\n req.http.Cookie ~ \"CHOCOLATECHIP\") {\n return (pass);\n }\n\n \/* 14th: Bypass breakpoint 2 *\/\n # Useful for debugging we can now pipe or pass the request to backend to bypass cache.\n # return (pipe);\n # return (pass);\n\n \/* 15th: Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning a lookup.\n return (lookup);\n}\n\n# vcl_pipe: Called upon entering pipe mode.\n# In this mode, the request is passed on to the backend, \n# and any further data from either client or backend is passed on unaltered until either end closes the connection.\nsub vcl_pipe {\n \/* Prevent connection re-using for piped requests *\/\n # Note that only the first request to the backend will have X-Forwarded-For set.\n # As we use X-Forwarded-For and want to have it set for all requests, \n # we have to make sure connection won't be reused after the request.\n # It is not set by default as it might break some broken web applications, like IIS with NTLM authentication.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExamplePipe\n # TO-DO: make sure this is compatible with websockets piping,\n # reference https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/websockets.html\n set bereq.http.connection = \"close\";\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this point.\n return (pipe);\n}\n\n# vcl_pass: Called upon entering pass mode. \n# In this mode, the request is passed on to the backend, and the backend's response is passed on to the client, \n# but is not entered into the cache.\n# Subsequent requests submitted over the same client connection are handled normally.\n# sub vcl_pass {\n# return (pass);\n# }\n\n# vcl_hash: You may call hash_data() on the data you would like to add to the hash.\n# Hash is used by Varnish to uniquely identify objects.\nsub vcl_hash {\n \/* Hash cookie data *\/\n # As requests with same URL and host can produce diferent results when issued with different cookies,\n # we need to store items hashed with the associated cookies. Note that cookies are already sanitized when we reach this point.\n if (req.http.Cookie) {\n \/* Include cookie in cache hash *\/\n hash_data(req.http.Cookie);\n }\n\n \/* Custom header hashing *\/\n # Empty in simple configs.\n # Example for caching differents object versions by device previously detected (when static content could also vary):\n # if (req.http.X-UA-Device) {\n # hash_data(req.http.X-UA-Device);\n # }\n # Example for caching diferent object versions by X-Forwarded-Proto, trying to be smart about what kind of request\n # could generate diffetent responses.\n # if (req.http.X-Forwarded-Proto &&\n # req.url !~ \"(?i)\\.(png|gif|jpeg|jpg|ico|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|svg|pdf)$\") {\n # hash_data(req.http.X-Forwarded-Proto);\n # }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (hash);\n# }\n\n# vcl_hit: Called after a cache lookup if the requested document was found in the cache.\nsub vcl_hit {\n \/* Check for Varnish special requests *\/ \n # Purge logic.\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/purging.html#http-purges\n # See https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged.\";\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hit {\n# return (deliver);\n# }\n\n# vcl_miss: Called after a cache lookup if the requested document was not found in the cache.\n# Its purpose is to decide whether or not to attempt to retrieve the document from the backend, and which backend to use.\nsub vcl_miss {\n \/* Check for Varnish special requests *\/ \n # Purge logic.\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/purging.html#http-purges\n # See https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged.\";\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_miss {\n# return (fetch);\n# }\n\n# vcl_fetch: Called after a document has been successfully retrieved from the backend.\nsub vcl_fetch {\n \/* Caching exceptions *\/\n # Varnish will cache objects with response codes: 200, 203, 300, 301, 302, 307, 404 & 410.\n # See https:\/\/www.varnish-software.com\/static\/book\/VCL_Basics.html#the-initial-value-of-beresp-ttl\n # Drupal's Imagecache module can return a 307 redirection to the requested url itself and, depending on Drupal's cache settings,\n # this could lead to a redirection loop being cached for a long time but also we want Varnish to shield a little the backend.\n # See http:\/\/drupal.org\/node\/1248010\n # See http:\/\/drupal.org\/node\/310656\n if (beresp.status == 307 &&\n \/* TO-DO: verify that this work better than 'req.url ~ \"imagecache\"' *\/\n beresp.http.Location == req.url &&\n beresp.ttl > 5s) {\n set beresp.ttl = 5s;\n set beresp.http.cache-control = \"max-age=5\";\n }\n\n \/* Enable grace mode. Related with our 9th stage on vcl_recv *\/\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/handling_misbehaving_servers.html#grace-mode\n set beresp.grace = 1h;\n\n \/* Enable saint mode. Related with our 9th stage on vcl_recv *\/\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/handling_misbehaving_servers.html#saint-mode\n if (beresp.status == 500) {\n set beresp.saintmode = 20s;\n # TO-DO: consider not restarting POST requests as seen on https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleSaintMode\n return(restart);\n }\n\n \/* Strip cookies from the following static file types for all users. Related with our 12th stage on vcl_recv *\/\n if (req.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|svg|pdf)(\\?[a-z0-9]+)?$\") {\n unset beresp.http.set-cookie;\n }\n\n \/* Gzip response *\/\n # Empty in simple configs\n # Use Varnish to Gzip respone, if suitable, before storing it on cache\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/phk\/gzip.html\n # if (! beresp.http.Content-Encoding &&\n # (beresp.http.content-type ~ \"text\" ||\n # beresp.http.content-type ~ \"application\/x-javascript\" ||\n # beresp.http.content-type ~ \"application\/javascript\" ||\n # beresp.http.content-type ~ \"application\/rss+xml\" ||\n # beresp.http.content-type ~ \"application\/xml\" ||\n # beresp.http.content-type ~ \"Application\/JSON\")\n # ) {\n # set beresp.do_gzip = true;\n # if ( beresp.http.Vary ) {\n # if ( ! beresp.http.Vary ~ \"Accept-Encoding\" ) {\n # set beresp.http.Vary = beresp.http.Vary + \",Accept-Encoding\";\n # }\n # } else {\n # set beresp.http.Vary = \"Accept-Encoding\";\n # }\n # }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # We can add the name of the backend that has processed the request:\n # set beresp.http.X-Backend = beresp.backend.name;\n # We can use a header to tell if the object was gziped by Varnish\n # if (beresp.do_gzip) {\n # set beresp.http.X-Varnish-Gzipped = \"yes\";\n # } else {\n # set beresp.http.X-Varnish-Gizipped = \"no\";\n # }\n # We can also add headers informing whether the object is cacheable or not and why.\n # https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Varnish3.0\n if (beresp.ttl <= 0s) {\n \/* Varnish determined the object was not cacheable *\/\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n } elsif (req.http.Cookie ~ \"(SESS|SSESS|NO_CACHE|OATMEAL|CHOCOLATECHIP)\") {\n \/* We don't wish to cache content for logged in users or with certain cookies. Related with our 9th stage on vcl_recv *\/\n set beresp.http.X-Cacheable = \"NO:Cookies\";\n # return(hit_for_pass);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n \/* We are respecting the Cache-Control=private header from the backend *\/\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n # return(hit_for_pass);\n } else {\n \/* Varnish determined the object was cacheable *\/\n set beresp.http.X-Cacheable = \"YES\";\n }\n\n \/* Further header manipulation *\/\n # Empty in simple configs.\n # We can also unset some headers to prevent information disclosure and save some cache space\n # unset beresp.http.Server;\n # unset beresp.http.X-Powered-By;\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_fetch {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Vary == \"*\") {\n# \/*\n# * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# *\/\n# set beresp.ttl = 120 s;\n# return (hit_for_pass);\n# }\n# return (deliver);\n# }\n\n# vcl_deliver: Called before an object is delivered to the client\nsub vcl_deliver {\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # Add whether the object is a cache hit or miss and the number of hits for the object.\n # https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Addingaheaderindicatinghitmiss\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n set resp.http.X-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Cache = \"MISS\";\n \/* Show the results of cookie sanitization *\/\n set resp.http.X-Cookie = req.http.Cookie;\n }\n # TO-DO: Add sick marker\n # Restart count\n if ( req.restarts > 0) {\n set resp.http.X-Restarts = req.restarts;\n }\n # Add the Varnish server hostname\n set resp.http.X-Varnish-Server = server.hostname;\n # If we have setted a custom header with device family detected we can show it:\n # if (req.http.X-UA-Device) {\n # set resp.http.X-UA-Device = req.http.X-UA-Device;\n # }\n # If we have recived a custom header with the protocol in the request we can show it:\n # if (req.http.X-Forwarded-Proto) {\n # set resp.http.X-Forwarded-Proto = req.http.X-Forwarded-Proto;\n # }\n\n \/* Vary header manipulation *\/\n # Empty in simple configs.\n # By example, if we are storing & serving diferent objects depending on User-Agent header we must set the correct Vary header:\n # if (resp.http.Vary) {\n # set resp.http.Vary = resp.http.Vary + \",User-Agent\";\n # } else {\n # set resp.http.Vary = \"User-Agent\";\n # }\n\n \/* Fake headers *\/\n # Empty in simple configs\n # We can fake server headers here, by example:\n # set resp.http.Server = \"Deep thought\";\n # set resp.http.X-Powered-By = \"BOFH\";\n # Or have some fun with headers:\n # See http:\/\/www.nextthing.org\/archives\/2005\/08\/07\/fun-with-http-headers\n # See http:\/\/royal.pingdom.com\/2012\/08\/15\/fun-and-unusual-http-response-headers\/\n # set resp.http.X-Thank-You = \"for bothering to look at my HTTP headers\";\n # set resp.http.X-Answer = \"42\";\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_deliver {\n# return (deliver);\n# }\n\n# vcl_error: Called when we hit an error, either explicitly or implicitly due to backend or internal errors.\nsub vcl_error {\n \/* Avoid DOS vulnerability CVE-2013-4484 *\/\n # See https:\/\/www.varnish-cache.org\/lists\/pipermail\/varnish-announce\/2013-October\/000686.html\n if (obj.status == 400 || obj.status == 413) {\n return(deliver);\n }\n\n \/* Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_error;\n\n \/* Try to restart request in case of failure *\/\n # Note that max_restarts defaults to 4\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if (obj.status == 503 && req.restarts < 4) {\n set obj.http.X-Restarts = req.restarts;\n return(restart);\n }\n\n \/* Set common headers for synthetic responses *\/\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n\n \/* HTTP Authentification client request *\/\n # Empty in simple configs. See http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* We're using error 200 for monitoring puposes *\/\n # Consider adding some analytics stuff to trace accesses\n if (obj.status == 200) {\n synthetic {\"\n <?xml version=\"1.0\" encoding=\"utf-8\"?>\n <!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n <html>\n <head>\n <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n <\/head>\n <body><h1>\"} + obj.status + \": \" + obj.response + {\"<\/h1><\/body>\n \"};\n return(deliver);\n }\n\n \/* Error page & refresh \/ redirections *\/\n # We have plenty of choices when we have to serve an error to the client, \n # from the default error page to javascript black magic or plain redirections.\n # Adding some external statistic javascript to track failures served to clients is strongly suggested.\n # We can't use external resources on synthetic content, everything must be inlined.\n # If we need to include images we can embed them in base64 encoding.\n # Here is the default error page for Varnish 3 (not so pretty)\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + obj.status + \" \" + obj.response + {\"<\/h1>\n <p>\"} + obj.response + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"};\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this point.\n return (deliver);\n}\n\n# vcl_init: Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n# sub vcl_init {\n# return (ok);\n# }\n\n# vcl_fini: Called when VCL is discarded only after all requests have exited the VCL. Typically used to clean up VMODs.\n# sub vcl_fini {\n# return (ok);\n# }\n","old_contents":"\/* Varnish 3 example config for Drupal 7 \/ Pressflow 6 & 7 *\/\n# Original source: https:\/\/github.com\/NITEMAN\/varnish-bites\/varnish4\/drupal-base.vcl\n# Copyright (c) 2015 Pedro Gonz\u00e1lez Serrano and individual contributors.\n# MIT License\n\n# Intended to be used both in simple production environments and with learning\/teaching purposes.\n# Loosely based on http:\/\/www.lullabot.com\/sites\/default\/files\/default_varnish3.vcl_.txt\n\n\/* Backend probes \/ healthchecks *\/\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#backend-probes\nprobe basic {\n \/* Only test that backend's IP serves content for '\/' *\/\n # This might be a too heavy probe\n # .url = \"\/\";\n \/* Only test that backend's IP has apache working *\/\n # Nginx would fail this probe with a default config\n .request =\n \"OPTIONS * HTTP\/1.1\"\n \"Host: *\"\n \"Connection: close\";\n .interval = 10s;\n .timeout = 2s;\n .window = 8;\n .threshold = 6;\n}\n\n\n\/* Backend definitions.*\/\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#backend-declarations\nbackend default {\n \/* Default backend on the same machine. WARNING: timeouts could be not big enought for certain POST request *\/\n .host = \"127.0.0.1\";\n .port = \"8008\";\n .connect_timeout = 60s;\n .first_byte_timeout = 60s;\n .between_bytes_timeout = 60s;\n .probe = basic;\n}\n\n\n\/* Directors. *\/\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#directors\n# Empty in simple configs\n\n\n\/* Access Control Lists *\/\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#acls\nacl purge_ban {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use '\"localhost\";' instead\n}\nacl allowed_monitors {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n}\nacl own_proxys {\n \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n}\n\n\n\/* Custom routines *\/\n# Empty in simple configs.\n# We can name subs with no restrictions but as a task can need several chunks of code in diferent states,\n# it's a good idea to identify what main sub will call each with a suffix.\n# \/* Example 301 client redirection removing \"www\" prefix from request *\/\n# sub perm_redirections_recv {\n# if ( req.http.host ~ \"^www.*$\" ) {\n# error 751 \"http:\/\/\" + regsub(req.http.host, \"^www\\.\", \"\") + req.url;\n# }\n# }\n# sub perm_redirections_error {\n# if (obj.status == 751) {\n# \/* Get new URL from the response *\/\n# set obj.http.Location = obj.response;\n# \/* Set HTTP 301 for permanent redirect *\/\n# set obj.status = 301;\n# return(deliver);\n# }\n# }\n\n\n\/* VCL logigc overrides *\/\n# Note that the built-in logic will be appended to our code if no return is performed before.\n# Built-in logic is included commented out right after our's for reference purposes in that cases.\n# See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleDefault\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#subroutines\n\n# vcl_recv: Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use.\nsub vcl_recv {\n \/* 0th: general bypass, general return & authorization checks *\/\n # Empty in simple configs.\n # Useful for debugging we can pipe or pass the request to default backend here to bypass completely Varnish.\n # return (pipe);\n # return (pass);\n # We can also return here a 200 Ok for network performance benchmarking.\n # error 200 \"Ok\";\n # Finally we can perform basic HTTP authentification here by example.\n # See http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* 1st: Check for Varnish special requests *\/ \n # Purge logic.\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/purging.html#http-purges\n # See https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if (req.request == \"PURGE\") {\n if (!client.ip ~ purge_ban) {\n error 405 \"Not allowed.\";\n }\n return (lookup);\n }\n # Ban logic. See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/purging.html#bans\n if (req.request == \"BAN\") {\n if (!client.ip ~ purge_ban) {\n error 405 \"Not allowed.\";\n }\n ban(\"req.http.host == \" + req.http.host +\n \"&& req.url == \" + req.url); \n error 200 \"Ban added\";\n }\n # Custom response implementation example in order to check that Varnish is working properly.\n # This is usefull for automatic monitoring with monit or when Varnish is behind another proxies like HAProxy.\n if (req.http.host == \"monitor.server.health\" && \n client.ip ~ allowed_monitors && \n (req.request == \"OPTIONS\" || req.request == \"GET\")) {\n error 200 \"Ok\";\n }\n\n \/* 2nd: Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_recv;\n # Here we can also enforce SSL when Varnish run behind some SSL termination point.\n\n \/* 3rd: Time for backend choice *\/\n # Empty in simple configs.\n\n \/* 4th: Set custom headers for backend like X-Forwarded-For (copied from built-in logic) *\/\n if ( req.restarts == 0 ) {\n \/* See also vcl_pipe section *\/\n if ( ! client.ip ~ own_proxys ) {\n if ( req.http.x-forwarded-for ) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n }\n\n \/* 5th: Bypass breakpoint 1 *\/\n # Useful for debugging we can now pipe or pass the request to backend with headers setted.\n # return (pipe);\n # return (pass);\n\n \/* 6th: Decide if we should deal with a request (mostly copied from built-in logic) *\/\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n\n \/* 7th: Access control for some URLs by ACL *\/\n # Empty in simple configs.\n # By example denial some URLs depending on client-ip, we'll need to define corresponding ACL 'internal'.\n # if (req.url ~ \"^\/(cron|install)\\.php$\" && !client.ip ~ internal) {\n # # Have Varnish throw the error directly.\n # error 403 \"Forbidden.\";\n # # Use a custom error page that you've defined in Drupal at the path \"404\".\n # # set req.url = \"\/403\";\n # }\n\n \/* 8th: Custom exceptions *\/\n # Host exception example:\n # if (req.http.host == \"ejemplo.exception.com\") {\n # return (pass);\n # }\n # Drupal exceptions, edit if we want to cache some AJAX\/AHAH request.\n # Add here filters for never cache URLs such as Payment Gateway's callbacks\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/ooyala\/ping$\" ||\n req.url ~ \"^\/admin\/build\/features\" ||\n req.url ~ \"^\/info\/.*$\" ||\n req.url ~ \"^\/flag\/.*$\" ||\n req.url ~ \"^.*\/ajax\/.*$\" ||\n req.url ~ \"^.*\/ahah\/.*$\") {\n \/* Do not cache these paths *\/\n return (pass);\n }\n # Pipe these paths directly to backend for streaming.\n if (req.url ~ \"^\/admin\/content\/backup_migrate\/export\") {\n return (pipe);\n }\n if (req.url ~ \"^\/system\/files\") {\n return (pipe);\n }\n\n \/* 9th: Enable grace mode *\/\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/handling_misbehaving_servers.html#grace-mode\n if (! req.backend.healthy) {\n \/* Use a longer grace period if all backends are down *\/\n set req.grace = 1h;\n \/* Use anonymous, cached pages if all backends are down. *\/\n unset req.http.Cookie;\n # TO-DO: Add sick marker\n } else {\n \/* Allow the backend to serve up stale content if it is responding slowly. *\/\n set req.grace = 30s;\n }\n\n \/* 10th: Deal with compression and the Accept-Encoding header *\/\n # Althought Varnish 3 handles gziped content itself by default, just to be sure we want to \n # remove Accept-Encoding for some compressed formats.\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/phk\/gzip.html#what-does-http-gzip-support-do\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/varnishd.html?highlight=http_gzip_support\n # See (for older configs) https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleNormalizeAcceptEncoding\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|mp4|flv|zip|rar)$\") {\n \/* Already compressed formats, no sense trying to compress again *\/\n remove req.http.Accept-Encoding;\n }\n }\n\n \/* 11th: Another header manipulation *\/\n # Empty in simple configs.\n # We could add here a custom header grouping User-agent families.\n\n \/* 12th: Cookie removal *\/\n # Always cache the following static file types for all users. \n # Use with care if we control certain downloads depending on cookies. \n # Be carefull also if appending .htm[l] via Drupal's clean URLs.\n if (req.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|svg|pdf)(\\?[a-z0-9]+)?$\") {\n unset req.http.Cookie;\n }\n # Remove all cookies that backend doesn't need to know about.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRemovingSomeCookies\n if (req.http.Cookie) {\n \/* Warning: Not a pretty solution *\/\n \/* Prefix header containing cookies with ';' *\/\n set req.http.Cookie = \";\" + req.http.Cookie;\n \/* Remove any spaces after ';' in header containing cookies *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n \/* Prefix cookies we want to preserve with one space *\/\n \/* 'S{1,2}ESS[a-z0-9]+' is the regular expression matching a Drupal session cookie ({1,2} added for HTTPS support) *\/\n \/* 'NO_CACHE' is usually set after a POST request to make sure issuing user see the results of his post *\/\n \/* 'OATMEAL' & 'CHOCOLATECHIP' are special cookies used by Drupal's Bakery module to provide Single Sign On *\/\n \/* Keep in mind we should add here any cookie that should reach the backend such as splahs avoiding cookies *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \";(S{1,2}ESS[a-z0-9]+|NO_CACHE|OATMEAL|CHOCOLATECHIP)=\", \"; \\1=\");\n \/* Remove from the header any single Cookie not prefixed with a space until next ';' separator *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n \/* Remove any '; ' at the start or the end of the header *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n\n if (req.http.Cookie == \"\") {\n \/* If there are no remaining cookies, remove the cookie header. *\/\n unset req.http.Cookie;\n }\n }\n\n \/* 13th: Session cookie & special cookies bypass caching stage *\/\n # As we might want to cache some requests, hashed with its cookies, \n # we don't simply pass when some cookies remain present at this point.\n # Instead we look for request that must be passed due to the cookie header.\n if (req.http.Cookie ~ \"SESS\" ||\n req.http.Cookie ~ \"SSESS\" ||\n req.http.Cookie ~ \"NO_CACHE\" ||\n req.http.Cookie ~ \"OATMEAL\" ||\n req.http.Cookie ~ \"CHOCOLATECHIP\") {\n return (pass);\n }\n\n \/* 14th: Bypass breakpoint 2 *\/\n # Useful for debugging we can now pipe or pass the request to backend to bypass cache.\n # return (pipe);\n # return (pass);\n\n \/* 15th: Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning a lookup.\n return (lookup);\n}\n\n# vcl_pipe: Called upon entering pipe mode.\n# In this mode, the request is passed on to the backend, \n# and any further data from either client or backend is passed on unaltered until either end closes the connection.\nsub vcl_pipe {\n \/* Prevent connection re-using for piped requests *\/\n # Note that only the first request to the backend will have X-Forwarded-For set.\n # As we use X-Forwarded-For and want to have it set for all requests, \n # we have to make sure connection won't be reused after the request.\n # It is not set by default as it might break some broken web applications, like IIS with NTLM authentication.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExamplePipe\n # TO-DO: make sure this is compatible with websockets piping,\n # reference https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/websockets.html\n set bereq.http.connection = \"close\";\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this point.\n return (pipe);\n}\n\n# vcl_pass: Called upon entering pass mode. \n# In this mode, the request is passed on to the backend, and the backend's response is passed on to the client, \n# but is not entered into the cache.\n# Subsequent requests submitted over the same client connection are handled normally.\n# sub vcl_pass {\n# return (pass);\n# }\n\n# vcl_hash: You may call hash_data() on the data you would like to add to the hash.\n# Hash is used by Varnish to uniquely identify objects.\nsub vcl_hash {\n \/* Hash cookie data *\/\n # As requests with same URL and host can produce diferent results when issued with different cookies,\n # we need to store items hashed with the associated cookies. Note that cookies are already sanitized when we reach this point.\n if (req.http.Cookie) {\n \/* Include cookie in cache hash *\/\n hash_data(req.http.Cookie);\n }\n\n \/* Custom header hashing *\/\n # Empty in simple configs.\n # Example for caching differents object versions by device previously detected (when static content could also vary):\n # if (req.http.X-UA-Device) {\n # hash_data(req.http.X-UA-Device);\n # }\n # Example for caching diferent object versions by X-Forwarded-Proto, trying to be smart about what kind of request\n # could generate diffetent responses.\n # if (req.http.X-Forwarded-Proto &&\n # req.url !~ \"(?i)\\.(png|gif|jpeg|jpg|ico|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|svg|pdf)$\") {\n # hash_data(req.http.X-Forwarded-Proto);\n # }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (hash);\n# }\n\n# vcl_hit: Called after a cache lookup if the requested document was found in the cache.\nsub vcl_hit {\n \/* Check for Varnish special requests *\/ \n # Purge logic.\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/purging.html#http-purges\n # See https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged.\";\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hit {\n# return (deliver);\n# }\n\n# vcl_miss: Called after a cache lookup if the requested document was not found in the cache.\n# Its purpose is to decide whether or not to attempt to retrieve the document from the backend, and which backend to use.\nsub vcl_miss {\n \/* Check for Varnish special requests *\/ \n # Purge logic.\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/purging.html#http-purges\n # See https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged.\";\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_miss {\n# return (fetch);\n# }\n\n# vcl_fetch: Called after a document has been successfully retrieved from the backend.\nsub vcl_fetch {\n \/* Caching exceptions *\/\n # Varnish will cache objects with response codes: 200, 203, 300, 301, 302, 307, 404 & 410.\n # See https:\/\/www.varnish-software.com\/static\/book\/VCL_Basics.html#the-initial-value-of-beresp-ttl\n # Drupal's Imagecache module can return a 307 redirection to the requested url itself and, depending on Drupal's cache settings,\n # this could lead to a redirection loop being cached for a long time but also we want Varnish to shield a little the backend.\n # See http:\/\/drupal.org\/node\/1248010\n # See http:\/\/drupal.org\/node\/310656\n if (beresp.status == 307 &&\n \/* TO-DO: verify that this work better than 'req.url ~ \"imagecache\"' *\/\n beresp.http.Location == req.url &&\n beresp.ttl > 5s) {\n set beresp.ttl = 5s;\n set beresp.http.cache-control = \"max-age=5\";\n }\n\n \/* Enable grace mode. Related with our 9th stage on vcl_recv *\/\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/handling_misbehaving_servers.html#grace-mode\n set beresp.grace = 1h;\n\n \/* Enable saint mode. Related with our 9th stage on vcl_recv *\/\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/handling_misbehaving_servers.html#saint-mode\n if (beresp.status == 500) {\n set beresp.saintmode = 20s;\n # TO-DO: consider not restarting POST requests as seen on https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleSaintMode\n return(restart);\n }\n\n \/* Strip cookies from the following static file types for all users. Related with our 12th stage on vcl_recv *\/\n if (req.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|svg|pdf)(\\?[a-z0-9]+)?$\") {\n unset beresp.http.set-cookie;\n }\n\n \/* Gzip response *\/\n # Empty in simple configs\n # Use Varnish to Gzip respone, if suitable, before storing it on cache\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/phk\/gzip.html\n # if (! beresp.http.Content-Encoding &&\n # (beresp.http.content-type ~ \"text\" ||\n # beresp.http.content-type ~ \"application\/x-javascript\" ||\n # beresp.http.content-type ~ \"application\/javascript\" ||\n # beresp.http.content-type ~ \"application\/rss+xml\" ||\n # beresp.http.content-type ~ \"application\/xml\" ||\n # beresp.http.content-type ~ \"Application\/JSON\")\n # ) {\n # set beresp.do_gzip = true;\n # if ( beresp.http.Vary ) {\n # if ( ! beresp.http.Vary ~ \"Accept-Encoding\" ) {\n # set beresp.http.Vary = beresp.http.Vary + \",Accept-Encoding\";\n # }\n # } else {\n # set beresp.http.Vary = \"Accept-Encoding\";\n # }\n # }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # We can add the name of the backend that has processed the request:\n # set beresp.http.X-Backend = beresp.backend.name;\n # We can use a header to tell if the object was gziped by Varnish\n # if (beresp.do_gzip) {\n # set beresp.http.X-Varnish-Gzipped = \"yes\";\n # } else {\n # set beresp.http.X-Varnish-Gizipped = \"no\";\n # }\n # We can also add headers informing whether the object is cacheable or not and why.\n # https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Varnish3.0\n if (beresp.ttl <= 0s) {\n \/* Varnish determined the object was not cacheable *\/\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n } elsif (req.http.Cookie ~ \"(SESS|SSESS|NO_CACHE|OATMEAL|CHOCOLATECHIP)\") {\n \/* We don't wish to cache content for logged in users or with certain cookies. Related with our 9th stage on vcl_recv *\/\n set beresp.http.X-Cacheable = \"NO:Cookies\";\n # return(hit_for_pass);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n \/* We are respecting the Cache-Control=private header from the backend *\/\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n # return(hit_for_pass);\n } else {\n \/* Varnish determined the object was cacheable *\/\n set beresp.http.X-Cacheable = \"YES\";\n }\n\n \/* Further header manipulation *\/\n # Empty in simple configs.\n # We can also unset some headers to prevent information disclosure and save some cache space\n # unset beresp.http.Server;\n # unset beresp.http.X-Powered-By;\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_fetch {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Vary == \"*\") {\n# \/*\n# * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# *\/\n# set beresp.ttl = 120 s;\n# return (hit_for_pass);\n# }\n# return (deliver);\n# }\n\n# vcl_deliver: Called before an object is delivered to the client\nsub vcl_deliver {\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # Add whether the object is a cache hit or miss and the number of hits for the object.\n # https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Addingaheaderindicatinghitmiss\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n set resp.http.X-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Cache = \"MISS\";\n \/* Show the results of cookie sanitization *\/\n set resp.http.X-Cookie = req.http.Cookie;\n }\n # TO-DO: Add sick marker\n # Restart count\n if ( req.restarts > 0) {\n set resp.http.X-Restarts = req.restarts;\n }\n # Add the Varnish server hostname\n set resp.http.X-Varnish-Server = server.hostname;\n # If we have setted a custom header with device family detected we can show it:\n # if (req.http.X-UA-Device) {\n # set resp.http.X-UA-Device = req.http.X-UA-Device;\n # }\n # If we have recived a custom header with the protocol in the request we can show it:\n # if (req.http.X-Forwarded-Proto) {\n # set resp.http.X-Forwarded-Proto = req.http.X-Forwarded-Proto;\n # }\n\n \/* Vary header manipulation *\/\n # Empty in simple configs.\n # By example, if we are storing & serving diferent objects depending on User-Agent header we must set the correct Vary header:\n # if (resp.http.Vary) {\n # set resp.http.Vary = resp.http.Vary + \",User-Agent\";\n # } else {\n # set resp.http.Vary = \"User-Agent\";\n # }\n\n \/* Fake headers *\/\n # Empty in simple configs\n # We can fake server headers here, by example:\n # set resp.http.Server = \"Deep thought\";\n # set resp.http.X-Powered-By = \"BOFH\";\n # Or have some fun with headers:\n # See http:\/\/www.nextthing.org\/archives\/2005\/08\/07\/fun-with-http-headers\n # See http:\/\/royal.pingdom.com\/2012\/08\/15\/fun-and-unusual-http-response-headers\/\n # set resp.http.X-Thank-You = \"for bothering to look at my HTTP headers\";\n # set resp.http.X-Answer = \"42\";\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_deliver {\n# return (deliver);\n# }\n\n# vcl_error: Called when we hit an error, either explicitly or implicitly due to backend or internal errors.\nsub vcl_error {\n \/* Avoid DOS vulnerability CVE-2013-4484 *\/\n # See https:\/\/www.varnish-cache.org\/lists\/pipermail\/varnish-announce\/2013-October\/000686.html\n if (obj.status == 400 || obj.status == 413) {\n return(deliver);\n }\n\n \/* Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_error;\n\n \/* Try to restart request in case of failure *\/\n # Note that max_restarts defaults to 4\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if (obj.status == 503 && req.restarts < 4) {\n set obj.http.X-Restarts = req.restarts;\n return(restart);\n }\n\n \/* Set common headers for synthetic responses *\/\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n\n \/* HTTP Authentification client request *\/\n # Empty in simple configs. See http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* We're using error 200 for monitoring puposes *\/\n # Consider adding some analytics stuff to trace accesses\n if (obj.status == 200) {\n synthetic {\"\n <?xml version=\"1.0\" encoding=\"utf-8\"?>\n <!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n <html>\n <head>\n <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n <\/head>\n <body><h1>\"} + obj.status + \": \" + obj.response + {\"<\/h1><\/body>\n \"};\n return(deliver);\n }\n\n \/* Error page & refresh \/ redirections *\/\n # We have plenty of choices when we have to serve an error to the client, \n # from the default error page to javascript black magic or plain redirections.\n # Adding some external statistic javascript to track failures served to clients is strongly suggested.\n # We can't use external resources on synthetic content, everything must be inlined.\n # If we need to include images we can embed them in base64 encoding.\n # Here is the default error page for Varnish 3 (not so pretty)\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + obj.status + \" \" + obj.response + {\"<\/h1>\n <p>\"} + obj.response + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"};\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this point.\n return (deliver);\n}\n\n# vcl_init: Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n# sub vcl_init {\n# return (ok);\n# }\n\n# vcl_fini: Called when VCL is discarded only after all requests have exited the VCL. Typically used to clean up VMODs.\n# sub vcl_fini {\n# return (ok);\n# }\n","returncode":0,"stderr":"","license":"unknown","lang":"VCL"} {"commit":"d88c32209ad7c924b9e44665a07046888a04f1d2","subject":"Added health checks to varnish.","message":"Added health checks to varnish.","repos":"cgourlay\/readthedocs.org,jerel\/readthedocs.org,wijerasa\/readthedocs.org,agjohnson\/readthedocs.org,wanghaven\/readthedocs.org,kdkeyser\/readthedocs.org,jerel\/readthedocs.org,pombredanne\/readthedocs.org,nikolas\/readthedocs.org,emawind84\/readthedocs.org,d0ugal\/readthedocs.org,soulshake\/readthedocs.org,nyergler\/pythonslides,mhils\/readthedocs.org,VishvajitP\/readthedocs.org,asampat3090\/readthedocs.org,singingwolfboy\/readthedocs.org,tddv\/readthedocs.org,GovReady\/readthedocs.org,dirn\/readthedocs.org,Carreau\/readthedocs.org,SteveViss\/readthedocs.org,atsuyim\/readthedocs.org,kenwang76\/readthedocs.org,titiushko\/readthedocs.org,titiushko\/readthedocs.org,rtfd\/readthedocs.org,SteveViss\/readthedocs.org,clarkperkins\/readthedocs.org,jerel\/readthedocs.org,attakei\/readthedocs-oauth,sid-kap\/readthedocs.org,royalwang\/readthedocs.org,davidfischer\/readthedocs.org,titiushko\/readthedocs.org,espdev\/readthedocs.org,VishvajitP\/readthedocs.org,espdev\/readthedocs.org,KamranMackey\/readthedocs.org,singingwolfboy\/readthedocs.org,mrshoki\/readthedocs.org,agjohnson\/readthedocs.org,michaelmcandrew\/readthedocs.org,ojii\/readthedocs.org,davidfischer\/readthedocs.org,mrshoki\/readthedocs.org,safwanrahman\/readthedocs.org,pombredanne\/readthedocs.org,takluyver\/readthedocs.org,dirn\/readthedocs.org,royalwang\/readthedocs.org,rtfd\/readthedocs.org,wijerasa\/readthedocs.org,CedarLogic\/readthedocs.org,nyergler\/pythonslides,michaelmcandrew\/readthedocs.org,espdev\/readthedocs.org,wanghaven\/readthedocs.org,rtfd\/readthedocs.org,rtfd\/readthedocs.org,techtonik\/readthedocs.org,nikolas\/readthedocs.org,attakei\/readthedocs-oauth,Carreau\/readthedocs.org,attakei\/readthedocs-oauth,johncosta\/private-readthedocs.org,d0ugal\/readthedocs.org,pombredanne\/readthedocs.org,dirn\/readthedocs.org,hach-que\/readthedocs.org,atsuyim\/readthedocs.org,davidfischer\/readthedocs.org,GovReady\/readthedocs.org,Carreau\/readthedocs.org,Tazer\/readthedocs.org,d0ugal\/readthedocs.org,mhils\/readthedocs.org,CedarLogic\/readthedocs.org,kenshinthebattosai\/readthedocs.org,asampat3090\/readthedocs.org,hach-que\/readthedocs.org,hach-que\/readthedocs.org,sunnyzwh\/readthedocs.org,fujita-shintaro\/readthedocs.org,ojii\/readthedocs.org,fujita-shintaro\/readthedocs.org,CedarLogic\/readthedocs.org,techtonik\/readthedocs.org,stevepiercy\/readthedocs.org,sunnyzwh\/readthedocs.org,stevepiercy\/readthedocs.org,espdev\/readthedocs.org,kenshinthebattosai\/readthedocs.org,safwanrahman\/readthedocs.org,fujita-shintaro\/readthedocs.org,atsuyim\/readthedocs.org,wijerasa\/readthedocs.org,sunnyzwh\/readthedocs.org,fujita-shintaro\/readthedocs.org,alex\/readthedocs.org,techtonik\/readthedocs.org,laplaceliu\/readthedocs.org,raven47git\/readthedocs.org,sid-kap\/readthedocs.org,dirn\/readthedocs.org,clarkperkins\/readthedocs.org,sils1297\/readthedocs.org,stevepiercy\/readthedocs.org,gjtorikian\/readthedocs.org,VishvajitP\/readthedocs.org,Carreau\/readthedocs.org,istresearch\/readthedocs.org,cgourlay\/readthedocs.org,ojii\/readthedocs.org,sils1297\/readthedocs.org,cgourlay\/readthedocs.org,singingwolfboy\/readthedocs.org,cgourlay\/readthedocs.org,raven47git\/readthedocs.org,kenshinthebattosai\/readthedocs.org,emawind84\/readthedocs.org,jerel\/readthedocs.org,laplaceliu\/readthedocs.org,GovReady\/readthedocs.org,istresearch\/readthedocs.org,SteveViss\/readthedocs.org,LukasBoersma\/readthedocs.org,johncosta\/private-readthedocs.org,LukasBoersma\/readthedocs.org,agjohnson\/readthedocs.org,Tazer\/readthedocs.org,takluyver\/readthedocs.org,safwanrahman\/readthedocs.org,titiushko\/readthedocs.org,tddv\/readthedocs.org,singingwolfboy\/readthedocs.org,davidfischer\/readthedocs.org,LukasBoersma\/readthedocs.org,d0ugal\/readthedocs.org,laplaceliu\/readthedocs.org,espdev\/readthedocs.org,stevepiercy\/readthedocs.org,agjohnson\/readthedocs.org,nikolas\/readthedocs.org,sunnyzwh\/readthedocs.org,wanghaven\/readthedocs.org,nyergler\/pythonslides,CedarLogic\/readthedocs.org,gjtorikian\/readthedocs.org,VishvajitP\/readthedocs.org,Tazer\/readthedocs.org,sid-kap\/readthedocs.org,gjtorikian\/readthedocs.org,LukasBoersma\/readthedocs.org,soulshake\/readthedocs.org,attakei\/readthedocs-oauth,SteveViss\/readthedocs.org,soulshake\/readthedocs.org,kdkeyser\/readthedocs.org,KamranMackey\/readthedocs.org,nikolas\/readthedocs.org,tddv\/readthedocs.org,laplaceliu\/readthedocs.org,michaelmcandrew\/readthedocs.org,raven47git\/readthedocs.org,johncosta\/private-readthedocs.org,kenwang76\/readthedocs.org,sils1297\/readthedocs.org,takluyver\/readthedocs.org,takluyver\/readthedocs.org,kenshinthebattosai\/readthedocs.org,ojii\/readthedocs.org,clarkperkins\/readthedocs.org,alex\/readthedocs.org,asampat3090\/readthedocs.org,kdkeyser\/readthedocs.org,royalwang\/readthedocs.org,istresearch\/readthedocs.org,emawind84\/readthedocs.org,sid-kap\/readthedocs.org,royalwang\/readthedocs.org,asampat3090\/readthedocs.org,KamranMackey\/readthedocs.org,mhils\/readthedocs.org,techtonik\/readthedocs.org,mrshoki\/readthedocs.org,soulshake\/readthedocs.org,KamranMackey\/readthedocs.org,clarkperkins\/readthedocs.org,hach-que\/readthedocs.org,michaelmcandrew\/readthedocs.org,wijerasa\/readthedocs.org,emawind84\/readthedocs.org,nyergler\/pythonslides,Tazer\/readthedocs.org,istresearch\/readthedocs.org,mhils\/readthedocs.org,sils1297\/readthedocs.org,alex\/readthedocs.org,GovReady\/readthedocs.org,safwanrahman\/readthedocs.org,gjtorikian\/readthedocs.org,kenwang76\/readthedocs.org,wanghaven\/readthedocs.org,mrshoki\/readthedocs.org,kdkeyser\/readthedocs.org,kenwang76\/readthedocs.org,raven47git\/readthedocs.org,alex\/readthedocs.org,atsuyim\/readthedocs.org","old_file":"deploy\/cookbooks\/main\/files\/default\/readthedocs.vcl","new_file":"deploy\/cookbooks\/main\/files\/default\/readthedocs.vcl","new_contents":"backend chimera {\n .host = \"10.177.72.204\";\n .port = \"8000\";\n .probe = {\n .request =\n \"OPTIONS * HTTP\/1.1\"\n \"Host: readthedocs.org\"\n \"Connection: close\";\n }\n}\n\nbackend ladon {\n .host = \"10.177.73.65\";\n .port = \"8000\";\n .probe = {\n .request =\n \"OPTIONS * HTTP\/1.1\"\n \"Host: readthedocs.org\"\n \"Connection: close\";\n }\n}\n\ndirector doubleteam round-robin {\n {\n .backend = chimera;\n }\n # server2\n {\n .backend = ladon;\n }\n}\n\nacl purge {\n \"localhost\";\n \"192.0.2.14\";\n\t\"10.177.72.204\";\n}\n\nsub vcl_recv {\n set req.backend = doubleteam;\n\tif (req.request == \"PURGE\") {\n\t\tif (!client.ip ~ purge) {\n\t\t\terror 405 \"Not allowed.\";\n\t\t}\n\t\tpurge(\"req.url ~ \" req.url \" && req.http.host == \" req.http.host);\n\t\terror 200 \"Purged.\";\n\t}\n set req.grace = 2m;\n if (req.http.host != \"readthedocs.org\") {\n unset req.http.Cookie;\n unset req.http.cache-control;\n return(lookup);\n }\n\n \/\/ Remove has_js and Google Analytics cookies.\n set req.http.Cookie = regsuball(req.http.Cookie, \"(^|;\\s*)(__[a-z]+|has_js)=[^;]*\", \"\");\n \/\/ Remove a \";\" prefix, if present.\n set req.http.Cookie = regsub(req.http.Cookie, \"^;\\s*\", \"\");\n \/\/ Remove empty cookies.\n if (req.http.Cookie ~ \"^\\s*$\") {\n unset req.http.Cookie;\n }\n if (req.url ~ \"\\.(png|gif|jpg|swf|css|js|ico)$\") {\n unset req.http.cookie;\n }\n}\n\nsub vcl_fetch {\n set beresp.ttl = 1m;\n set req.grace = 5m;\n if (req.http.host != \"readthedocs.org\") {\n set beresp.ttl = 7d;\n }\n if (req.http.host ~ \"(.+).rtfd.org\") {\n set beresp.ttl = 10s;\n }\n}\n","old_contents":"backend chimera {\n .host = \"10.177.72.204\";\n .port = \"8000\";\n}\n\nbackend ladon {\n .host = \"10.177.73.65\";\n .port = \"8000\";\n}\n\ndirector doubleteam round-robin {\n {\n .backend = chimera;\n }\n # server2\n {\n .backend = ladon;\n }\n}\n\nacl purge {\n \"localhost\";\n \"192.0.2.14\";\n\t\"10.177.72.204\";\n}\n\nsub vcl_recv {\n set req.backend = doubleteam;\n\tif (req.request == \"PURGE\") {\n\t\tif (!client.ip ~ purge) {\n\t\t\terror 405 \"Not allowed.\";\n\t\t}\n\t\tpurge(\"req.url ~ \" req.url \" && req.http.host == \" req.http.host);\n\t\terror 200 \"Purged.\";\n\t}\n set req.grace = 2m;\n if (req.http.host != \"readthedocs.org\") {\n unset req.http.Cookie;\n unset req.http.cache-control;\n return(lookup);\n }\n\n \/\/ Remove has_js and Google Analytics cookies.\n set req.http.Cookie = regsuball(req.http.Cookie, \"(^|;\\s*)(__[a-z]+|has_js)=[^;]*\", \"\");\n \/\/ Remove a \";\" prefix, if present.\n set req.http.Cookie = regsub(req.http.Cookie, \"^;\\s*\", \"\");\n \/\/ Remove empty cookies.\n if (req.http.Cookie ~ \"^\\s*$\") {\n unset req.http.Cookie;\n }\n if (req.url ~ \"\\.(png|gif|jpg|swf|css|js|ico)$\") {\n unset req.http.cookie;\n }\n}\n\nsub vcl_fetch {\n set beresp.ttl = 1m;\n set req.grace = 5m;\n if (req.http.host != \"readthedocs.org\") {\n set beresp.ttl = 7d;\n }\n if (req.http.host ~ \"(.+).rtfd.org\") {\n set beresp.ttl = 10s;\n }\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"91e02f7830d8a5d9d7566ece902bd64145e2407c","subject":"Fix varnish localhost backend setting. #88","message":"Fix varnish localhost backend setting. #88\n","repos":"rinfo\/rdl,rinfo\/rdl,rinfo\/rdl,rinfo\/rdl,rinfo\/rdl,rinfo\/rdl","old_file":"manage\/sysconf\/dev-unix\/varnish\/backend.vcl","new_file":"manage\/sysconf\/dev-unix\/varnish\/backend.vcl","new_contents":"# Set rinfo-service backend for local environment (jetty)\nbackend default {\n\t.host = \"127.0.0.1\";\n\t.port = \"8181\";\n}","old_contents":"# Set rinfo-service backend for local environment (jetty)\nbackend default {\n\t.host = \"localhost\";\n\t.port = \"8181\";\n}","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"ee399dfbb054b74ceb7550551cb2872e47392100","subject":"Get cookie value for current URL in example VCL","message":"Get cookie value for current URL in example VCL","repos":"Destination\/libvmod-abtest,Destination\/libvmod-abtest","old_file":"vcl\/default.vcl","new_file":"vcl\/default.vcl","new_contents":" import std;\n import abtest;\n\n C{\n #include <syslog.h>\n }C\n\n\n backend default {\n .host = \"127.0.0.1\";\n .port = \"3000\";\n }\n\n\/* Only permit localhost to manipulate abtest configuration *\/\nacl abconfig {\n \"localhost\";\n}\n\nsub vcl_init {\n if (abtest.load_config(\"\/tmp\/abtest.cfg\") != 0) {\n C{ syslog(LOG_ALERT, \"Unable to load AB config from \/tmp\/abtest.cfg\"); }C\n }\n\n return (ok);\n}\n\nsub vcl_fini {\n}\n\nsub vcl_recv {\n std.log(abtest.get_rules());\n\n if (req.http.X-AB-Cfg) {\n if (!client.ip ~ abconfig) {\n std.log(\"AB Config request not allowed from \" + client.ip);\n error 405 \"Not allowed.\";\n } else {\n \/\/ curl localhost:8080 -X PUT -H \"X-AB-Cfg:base\" -H \"X-AB-Cfg-Val:a:25;b:75;\"\n if (req.request == \"PUT\") {\n std.log(\"AB Config PUT request: \" + req.http.X-AB-Cfg + \"|\" + req.http.X-AB-Cfg-Val);\n abtest.set_rule(req.http.X-AB-Cfg, req.http.X-AB-Cfg-Val);\n if (abtest.save_config(\"\/tmp\/abtest.cfg\") != 0) {\n std.log(\"ABTest - Error, could not save the configuration\");\n }\n }\n\n \/\/ curl localhost:8080 -X DELETE -H \"X-AB-Cfg:base\"\n if (req.request == \"DELETE\") {\n std.log(\"AB Config DELETE request: \" + req.http.X-AB-Cfg);\n abtest.rem_rule(req.http.X-AB-Cfg);\n }\n\n \/\/ curl localhost:8080 -X GET -H \"X-AB-Cfg;\"\n if (req.request == \"GET\") {\n std.log(\"AB Config GET request: \" + req.http.X-AB-Cfg);\n std.log(\"CFG -> \" + abtest.get_rules());\n if (req.http.X-AB-Cfg != \"\") {\n std.log(\"duration for '\" + req.http.X-AB-Cfg + \"': \" + abtest.get_duration(req.http.X-AB-Cfg));\n }\n }\n }\n }\n\n std.log(\"AB Cookie for '\" + req.url + \"': \" + abtest.get_rand(req.url));\n\n\/*\n if(req.http.Cookie ~ \"abtesting\") {\n }\n*\/\n}\n\nsub vcl_pipe {\n}\n\nsub vcl_pass {\n}\n\nsub vcl_hash {\n}\n\nsub vcl_hit {\n}\n\nsub vcl_miss {\n}\n\nsub vcl_fetch {\n}\n\nsub vcl_deliver {\n}\n\nsub vcl_error {\n}\n","old_contents":" import std;\n import abtest;\n\n C{\n #include <syslog.h>\n }C\n\n\n backend default {\n .host = \"127.0.0.1\";\n .port = \"3000\";\n }\n\n\/* Only permit localhost to manipulate abtest configuration *\/\nacl abconfig {\n \"localhost\";\n}\n\nsub vcl_init {\n if (abtest.load_config(\"\/tmp\/abtest.cfg\") != 0) {\n C{ syslog(LOG_ALERT, \"Unable to load AB config from \/tmp\/abtest.cfg\"); }C\n }\n abtest.set_rule(\"special\", \"a:10;b:90;\");\n abtest.rem_rule(\"base\");\n\n return (ok);\n}\n\nsub vcl_fini {\n}\n\nsub vcl_recv {\n std.log(abtest.get_rules());\n\n if (req.http.X-AB-Cfg) {\n if (!client.ip ~ abconfig) {\n std.log(\"AB Config request not allowed from \" + client.ip);\n error 405 \"Not allowed.\";\n } else {\n \/\/ curl localhost:8080 -X PUT -H \"X-AB-Cfg:base\" -H \"X-AB-Cfg-Val:a:25;b:75;\"\n if (req.request == \"PUT\") {\n std.log(\"AB Config PUT request: \" + req.http.X-AB-Cfg + \"|\" + req.http.X-AB-Cfg-Val);\n abtest.set_rule(req.http.X-AB-Cfg, req.http.X-AB-Cfg-Val);\n if (abtest.save_config(\"\/tmp\/abtest.cfg\") != 0) {\n std.log(\"ABTest - Error, could not save the configuration\");\n }\n }\n\n \/\/ curl localhost:8080 -X DELETE -H \"X-AB-Cfg:base\"\n if (req.request == \"DELETE\") {\n std.log(\"AB Config DELETE request: \" + req.http.X-AB-Cfg);\n abtest.rem_rule(req.http.X-AB-Cfg);\n }\n\n \/\/ curl localhost:8080 -X GET -H \"X-AB-Cfg;\"\n if (req.request == \"GET\") {\n std.log(\"AB Config GET request: \" + req.http.X-AB-Cfg);\n std.log(\"CFG -> \" + abtest.get_rules());\n if (req.http.X-AB-Cfg != \"\") {\n std.log(\"duration for '\" + req.http.X-AB-Cfg + \"': \" + abtest.get_duration(req.http.X-AB-Cfg));\n }\n }\n }\n }\n\n\/*\n if(req.http.Cookie ~ \"abtesting\") {\n }\n*\/\n}\n\nsub vcl_pipe {\n}\n\nsub vcl_pass {\n}\n\nsub vcl_hash {\n}\n\nsub vcl_hit {\n}\n\nsub vcl_miss {\n}\n\nsub vcl_fetch {\n}\n\nsub vcl_deliver {\n}\n\nsub vcl_error {\n}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"939e685da7b23af0613114ed2c2cbf81f1a507e7","subject":"hit-for-miss\/-pass terminology in the comments of builtin.vcl","message":"hit-for-miss\/-pass terminology in the comments of builtin.vcl\n","repos":"feld\/Varnish-Cache,feld\/Varnish-Cache,gquintard\/Varnish-Cache,gquintard\/Varnish-Cache,gquintard\/Varnish-Cache,feld\/Varnish-Cache,feld\/Varnish-Cache,gquintard\/Varnish-Cache,feld\/Varnish-Cache","old_file":"bin\/varnishd\/builtin.vcl","new_file":"bin\/varnishd\/builtin.vcl","new_contents":"\/*-\n * Copyright (c) 2006 Verdens Gang AS\n * Copyright (c) 2006-2015 Varnish Software AS\n * All rights reserved.\n *\n * Author: Poul-Henning Kamp <phk@phk.freebsd.dk>\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in the\n * documentation and\/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * This is the builtin VCL code\n *\/\n\nvcl 4.0;\n\n#######################################################################\n# Client side\n\nsub vcl_recv {\n if (req.method == \"PRI\") {\n\t\/* We do not support SPDY or HTTP\/2.0 *\/\n\treturn (synth(405));\n }\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\" &&\n req.method != \"PATCH\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization || req.http.Cookie) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n return (hash);\n}\n\nsub vcl_pipe {\n # By default Connection: close is set on all piped requests, to stop\n # connection reuse from sending future requests directly to the\n # (potentially) wrong backend. If you do want this to happen, you can undo\n # it here.\n # unset bereq.http.connection;\n return (pipe);\n}\n\nsub vcl_pass {\n return (fetch);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n return (lookup);\n}\n\nsub vcl_purge {\n return (synth(200, \"Purged\"));\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n \/\/ A pure unadulterated hit, deliver it\n return (deliver);\n }\n if (obj.ttl + obj.grace > 0s) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n return (deliver);\n }\n \/\/ fetch & deliver once we get the result\n return (miss);\n}\n\nsub vcl_miss {\n return (fetch);\n}\n\nsub vcl_deliver {\n return (deliver);\n}\n\n\/*\n * We can come here \"invisibly\" with the following errors: 500 & 503\n *\/\nsub vcl_synth {\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n set resp.http.Retry-After = \"5\";\n set resp.body = {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"};\n return (deliver);\n}\n\n#######################################################################\n# Backend Fetch\n\nsub vcl_backend_fetch {\n if (bereq.method == \"GET\") {\n unset bereq.body;\n }\n return (fetch);\n}\n\nsub vcl_backend_response {\n if (bereq.uncacheable) {\n return (deliver);\n } else if (beresp.ttl <= 0s ||\n beresp.http.Set-Cookie ||\n beresp.http.Surrogate-control ~ \"no-store\" ||\n (!beresp.http.Surrogate-Control &&\n beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n beresp.http.Vary == \"*\") {\n # Mark as \"Hit-For-Miss\" for the next 2 minutes\n set beresp.ttl = 120s;\n set beresp.uncacheable = true;\n }\n return (deliver);\n}\n\nsub vcl_backend_error {\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n set beresp.body = {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + beresp.status + \" \" + beresp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + beresp.status + \" \" + beresp.reason + {\"<\/h1>\n <p>\"} + beresp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + bereq.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"};\n return (deliver);\n}\n\n#######################################################################\n# Housekeeping\n\nsub vcl_init {\n return (ok);\n}\n\nsub vcl_fini {\n return (ok);\n}\n","old_contents":"\/*-\n * Copyright (c) 2006 Verdens Gang AS\n * Copyright (c) 2006-2015 Varnish Software AS\n * All rights reserved.\n *\n * Author: Poul-Henning Kamp <phk@phk.freebsd.dk>\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in the\n * documentation and\/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * This is the builtin VCL code\n *\/\n\nvcl 4.0;\n\n#######################################################################\n# Client side\n\nsub vcl_recv {\n if (req.method == \"PRI\") {\n\t\/* We do not support SPDY or HTTP\/2.0 *\/\n\treturn (synth(405));\n }\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\" &&\n req.method != \"PATCH\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization || req.http.Cookie) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n return (hash);\n}\n\nsub vcl_pipe {\n # By default Connection: close is set on all piped requests, to stop\n # connection reuse from sending future requests directly to the\n # (potentially) wrong backend. If you do want this to happen, you can undo\n # it here.\n # unset bereq.http.connection;\n return (pipe);\n}\n\nsub vcl_pass {\n return (fetch);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n return (lookup);\n}\n\nsub vcl_purge {\n return (synth(200, \"Purged\"));\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n \/\/ A pure unadulterated hit, deliver it\n return (deliver);\n }\n if (obj.ttl + obj.grace > 0s) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n return (deliver);\n }\n \/\/ fetch & deliver once we get the result\n return (miss);\n}\n\nsub vcl_miss {\n return (fetch);\n}\n\nsub vcl_deliver {\n return (deliver);\n}\n\n\/*\n * We can come here \"invisibly\" with the following errors: 500 & 503\n *\/\nsub vcl_synth {\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n set resp.http.Retry-After = \"5\";\n set resp.body = {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"};\n return (deliver);\n}\n\n#######################################################################\n# Backend Fetch\n\nsub vcl_backend_fetch {\n if (bereq.method == \"GET\") {\n unset bereq.body;\n }\n return (fetch);\n}\n\nsub vcl_backend_response {\n if (bereq.uncacheable) {\n return (deliver);\n } else if (beresp.ttl <= 0s ||\n beresp.http.Set-Cookie ||\n beresp.http.Surrogate-control ~ \"no-store\" ||\n (!beresp.http.Surrogate-Control &&\n beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n beresp.http.Vary == \"*\") {\n # Mark as \"Hit-For-Pass\" for the next 2 minutes\n set beresp.ttl = 120s;\n set beresp.uncacheable = true;\n }\n return (deliver);\n}\n\nsub vcl_backend_error {\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n set beresp.body = {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + beresp.status + \" \" + beresp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + beresp.status + \" \" + beresp.reason + {\"<\/h1>\n <p>\"} + beresp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + bereq.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"};\n return (deliver);\n}\n\n#######################################################################\n# Housekeeping\n\nsub vcl_init {\n return (ok);\n}\n\nsub vcl_fini {\n return (ok);\n}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"9c4a231f8bf6667aabcddffbdf864a8d2058d9c2","subject":"Unnecessary stanza","message":"Unnecessary stanza\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets\/fetch.vcl","new_file":"etc\/vcl_snippets\/fetch.vcl","new_contents":" \/* handle 5XX (or any other unwanted status code) *\/\n if (beresp.status >= 500 && beresp.status < 600) {\n\n \/* deliver stale if the object is available *\/\n if (stale.exists) {\n return(deliver_stale);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n \/* else go to vcl_error to deliver a synthetic *\/\n error beresp.status beresp.response;\n }\n\n # Remove Set-Cookies from responses for static content\n # to match the cookie removal in recv.\n if (req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's since those can be temporary during the site build\/index\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n }\n\n }\n\n if (beresp.http.Content-Type ~ \"text\/(html|xml)\") {\n # enable ESI feature for Magento response by default\n esi;\n if (!beresp.http.Vary ~ \"X-Magento-Vary,Https\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \",X-Magento-Vary,Https\";\n } else {\n set beresp.http.Vary = \"X-Magento-Vary,Https\";\n }\n }\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content\n if (http_status_matches(beresp.status, \"200,404\") && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url.ext ~ \"(?i)(css|js|html|eot|ico|otf|ttf|json)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n if (beresp.http.Cache-Control ~ \"private|no-cache|no-store\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # Never cache 302s\n if (beresp.status == 302) {\n return (pass);\n }\n\n # Just in case the Request Setting for x-pass is missing\n if (req.http.x-pass) {\n return (pass);\n }\n\n # Varnish sets default TTL if none of these are present\n if (!beresp.http.Expires && !beresp.http.Surrogate-Control ~ \"max-age\" && !beresp.http.Cache-Control ~ \"(s-maxage|max-age)\") {\n set beresp.ttl = 0s;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\") && !req.http.x-pass ) {\n unset beresp.http.set-cookie;\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type if they are image\/script or CSS\n if (beresp.http.Content-Type ~ \"(image|script|css)\") {\n set beresp.http.Surrogate-Key = re.group.1;\n }\n return (deliver);\n }\n","old_contents":" \/* handle 5XX (or any other unwanted status code) *\/\n if (beresp.status >= 500 && beresp.status < 600) {\n\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n \/* deliver stale if the object is available *\/\n if (stale.exists) {\n return(deliver_stale);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n \/* else go to vcl_error to deliver a synthetic *\/\n error beresp.status beresp.response;\n }\n\n # Remove Set-Cookies from responses for static content\n # to match the cookie removal in recv.\n if (req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's since those can be temporary during the site build\/index\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n }\n\n }\n\n if (beresp.http.Content-Type ~ \"text\/(html|xml)\") {\n # enable ESI feature for Magento response by default\n esi;\n if (!beresp.http.Vary ~ \"X-Magento-Vary,Https\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \",X-Magento-Vary,Https\";\n } else {\n set beresp.http.Vary = \"X-Magento-Vary,Https\";\n }\n }\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content\n if (http_status_matches(beresp.status, \"200,404\") && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url.ext ~ \"(?i)(css|js|html|eot|ico|otf|ttf|json)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n if (beresp.http.Cache-Control ~ \"private|no-cache|no-store\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # Never cache 302s\n if (beresp.status == 302) {\n return (pass);\n }\n\n # Just in case the Request Setting for x-pass is missing\n if (req.http.x-pass) {\n return (pass);\n }\n\n # Varnish sets default TTL if none of these are present\n if (!beresp.http.Expires && !beresp.http.Surrogate-Control ~ \"max-age\" && !beresp.http.Cache-Control ~ \"(s-maxage|max-age)\") {\n set beresp.ttl = 0s;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\") && !req.http.x-pass ) {\n unset beresp.http.set-cookie;\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type if they are image\/script or CSS\n if (beresp.http.Content-Type ~ \"(image|script|css)\") {\n set beresp.http.Surrogate-Key = re.group.1;\n }\n return (deliver);\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"1d99a46c4a4efeb634833284c7dad4baaa85916f","subject":"no need for checking GET method","message":"no need for checking GET method\n","repos":"alexisbellido\/salt-django-stack,alexisbellido\/salt-django-stack,alexisbellido\/salt-django-stack,alexisbellido\/salt-django-stack","old_file":"zinibu\/varnish\/files\/etc\/varnish\/default-4.vcl","new_file":"zinibu\/varnish\/files\/etc\/varnish\/default-4.vcl","new_contents":"# Managed by saltstack.\n# host id: {{ salt['grains.get']('id', '') }}\n{% set settings = salt['pillar.get']('varnish', {}) -%}\n{% set zinibu_basic = salt['pillar.get']('zinibu_basic', {}) -%}\n#\n# This is an example VCL file for Varnish.\n#\n# It does not do anything by default, delegating control to the\n# builtin VCL. The builtin VCL is called when there is no explicit\n# return statement.\n#\n# See the VCL chapters in the Users Guide at https:\/\/www.varnish-cache.org\/docs\/\n# and https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExamples for more examples.\n\n# Marker to tell the VCL compiler that this VCL has been adapted to the\n# new 4.0 format.\nvcl 4.0;\n\nimport std;\nimport directors;\n\n{%- for id, haproxy_server in zinibu_basic.project.haproxy_servers.iteritems() %}\nbackend bk_appsrv_static_{{ id }} {\n .host = \"{{ haproxy_server.private_ip }}\";\n .port = \"{{ haproxy_server.port }}\";\n .probe = {\n .url = \"{{ zinibu_basic.project.haproxy_check }}\";\n .expected_response = 200;\n .timeout = 1s;\n .interval = 3s;\n .window = 2;\n .threshold = 2;\n .initial = 2;\n }\n}\n{%- endfor %}\n\nsub vcl_init {\n new bar = directors.round_robin();\n{%- for id, haproxy_server in zinibu_basic.project.haproxy_servers.iteritems() %}\n bar.add_backend(bk_appsrv_static_{{ id }});\n{%- endfor %}\n}\n\nacl purge {\n \"localhost\";\n \"127.0.0.1\";\n}\n\nsub vcl_recv {\n # Happens before we check if we have this in cache already.\n #\n # Typically you clean up the request here, removing cookies you don't need,\n # rewriting the request, etc.\n\n # debug bypass\n #return (pass);\n\n #std.log(\"vcl recv: \"+req.request);\n\n # Health Checking\n if (req.url == \"{{ zinibu_basic.project.varnish_check }}\") {\n return (synth(751, \"health check OK!\"));\n }\n\n # send all traffic to the bar director:\n set req.backend_hint = bar.backend();\n\n # Normalize the header, remove the port (in case you're testing this on various TCP ports)\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n # Normalize the query arguments\n set req.url = std.querysort(req.url);\n\n # Allow purging\n if (req.method == \"PURGE\") {\n if (!client.ip ~ purge) { # purge is the ACL defined at the begining\n\t # Not from an allowed IP? Then die with an error.\n return (synth(405, \"This IP is not allowed to send PURGE requests.\"));\n }\n # If you got this stage (and didn't error out above), purge the cached result\n return (purge);\n }\n\n # Only deal with \"normal\" types\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"PATCH\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n # Implementing websocket support (https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html)\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n # Only cache GET or HEAD requests. This makes sure the POST requests are always passed.\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n # Don't think is needed anymore, just check for sessionid cookie\n # Django is setting this cookie so we only check here\n #if (req.http.Cookie ~ \"LOGGED_IN\") {\n # return (pass);\n #}\n\n if (req.http.Authorization) {\n # Not cacheable by default\n return (pass);\n }\n\n set req.http.X-Varnish-Use-Cache = \"TRUE\";\n # unless Django's sessionid or message cookies are in the request, don't pass ANY cookies (referral_source, utm, etc)\n # also, anything inside \/media or \/static should be cached\n if (req.url ~ \"^\/media\" || req.url ~ \"^\/static\" || (req.http.Cookie !~ \"sessionid\" && req.http.Cookie !~ \"messages\" && req.http.Cookie !~ \"csrftoken\")) {\n unset req.http.Cookie;\n return (hash);\n }\n\n # Large static files are delivered directly to the end-user without\n # waiting for Varnish to fully read the file first.\n # Varnish 4 fully supports Streaming, so set do_stream in vcl_backend_response()\n if (req.url ~ \"^[^?]*\\.(7z|avi|bz2|flac|flv|gz|mka|mkv|mov|mp3|mp4|mpeg|mpg|ogg|ogm|opus|rar|tar|tgz|tbz|txz|wav|webm|xz|zip)(\\?.*)?$\") {\n unset req.http.Cookie;\n return (hash);\n }\n\n # Remove all cookies for static files\n # A valid discussion could be held on this line: do you really need to cache static files that don't cause load? Only if you have memory left.\n # Sure, there's disk I\/O, but chances are your OS will already have these files in their buffers (thus memory).\n # Before you blindly enable this, have a read here: https:\/\/ma.ttias.be\/stop-caching-static-files\/\n if (req.url ~ \"^[^?]*\\.(7z|avi|bmp|bz2|css|csv|doc|docx|eot|flac|flv|gif|gz|ico|jpeg|jpg|js|less|mka|mkv|mov|mp3|mp4|mpeg|mpg|odt|otf|ogg|ogm|opus|pdf|png|ppt|pptx|rar|rtf|svg|svgz|swf|tar|tbz|tgz|ttf|txt|txz|wav|webm|webp|woff|woff2|xls|xlsx|xml|xz|zip)(\\?.*)?$\") {\n unset req.http.Cookie;\n return (hash);\n }\n \n # Are there cookies left with only spaces or that are empty?\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.Cookie;\n }\n\n # Some generic cookie manipulation, useful for all templates that follow\n # Remove the \"has_js\" cookie\n set req.http.Cookie = regsuball(req.http.Cookie, \"has_js=[^;]+(; )?\", \"\");\n\n # Remove any Google Analytics based cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__utm.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"_ga=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"_gat=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmctr=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmcmd.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmccn.=[^;]+(; )?\", \"\");\n\n # Remove DoubleClick offensive cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__gads=[^;]+(; )?\", \"\");\n\n # Remove the Quant Capital cookies (added by some plugin, all __qca)\n #set req.http.Cookie = regsuball(req.http.Cookie, \"__qc.=[^;]+(; )?\", \"\");\n\n # Remove the AddThis cookies\n #set req.http.Cookie = regsuball(req.http.Cookie, \"__atuv.=[^;]+(; )?\", \"\");\n\n # Remove a \";\" prefix in the cookie if present\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n\n if (req.http.Cache-Control ~ \"(?i)no-cache\") {\n #if (req.http.Cache-Control ~ \"(?i)no-cache\" && client.ip ~ editors) { # create the acl editors if you want to restrict the Ctrl-F5\n # http:\/\/varnish.projects.linpro.no\/wiki\/VCLExampleEnableForceRefresh\n # Ignore requests via proxy caches and badly behaved crawlers\n # like msnbot that send no-cache with every request.\n if (! (req.http.Via || req.http.User-Agent ~ \"(?i)bot\" || req.http.X-Purge)) {\n #set req.hash_always_miss = true; # Doesn't seems to refresh the object in the cache\n return(purge); # Couple this with restart in vcl_purge and X-Purge header to avoid loops\n }\n }\n\n # Strip hash, server doesn't need it.\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n # Strip a trailing ? if it exists\n if (req.url ~ \"\\?$\") {\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n return (hash);\n}\n\nsub vcl_pipe {\n # Called upon entering pipe mode.\n # In this mode, the request is passed on to the backend, and any further data from both the client\n # and backend is passed on unaltered until either end closes the connection. Basically, Varnish will\n # degrade into a simple TCP proxy, shuffling bytes back and forth. For a connection in pipe mode,\n # no other VCL subroutine will ever get called after vcl_pipe.\n\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n # set bereq.http.connection = \"close\";\n # here. It is not set by default as it might break some broken web\n # applications, like IIS with NTLM authentication.\n\n # set bereq.http.Connection = \"Close\";\n\n # Implementing websocket support (https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html)\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n\n return (pipe);\n}\n\nsub vcl_pass {\n # Called upon entering pass mode. In this mode, the request is passed on to the backend, and the\n # backend's response is passed on to the client, but is not entered into the cache. Subsequent\n # requests submitted over the same client connection are handled normally.\n\n # return (pass);\n}\n\nsub vcl_hash {\n # Called after vcl_recv to create a hash value for the request. This is used as a key\n # to look up the object in Varnish.\n \n hash_data(req.url);\n \n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n \n # hash cookies for requests that have them\n if (req.http.Cookie) {\n hash_data(req.http.Cookie);\n }\n\n return (lookup);\n}\n\nsub vcl_backend_response {\n # Happens after we have read the response headers from the backend.\n #\n # Here you clean the response headers, removing silly Set-Cookie headers\n # and other mistakes your backend does.\n\n # Called after the response headers has been successfully retrieved from the backend.\n # Enable ESI\n set beresp.do_esi = true;\n # and make sure everything under \/no-cache is, well, not cached\n if (bereq.url ~ \"^\/no-cache\/\") {\n set beresp.uncacheable = true;\n return(deliver); \n }\n\n # Pause ESI request and remove Surrogate-Control header\n if (beresp.http.Surrogate-Control ~ \"ESI\/1.0\") {\n unset beresp.http.Surrogate-Control;\n set beresp.do_esi = true;\n }\n\n # Enable cache for all static files\n # The same argument as the static caches from above: monitor your cache size, if you get data nuked out of it, consider giving up the static file cache.\n # Before you blindly enable this, have a read here: https:\/\/ma.ttias.be\/stop-caching-static-files\/\n if (bereq.url ~ \"^[^?]*\\.(7z|avi|bmp|bz2|css|csv|doc|docx|eot|flac|flv|gif|gz|ico|jpeg|jpg|js|less|mka|mkv|mov|mp3|mp4|mpeg|mpg|odt|otf|ogg|ogm|opus|pdf|png|ppt|pptx|rar|rtf|svg|svgz|swf|tar|tbz|tgz|ttf|txt|txz|wav|webm|webp|woff|woff2|xls|xlsx|xml|xz|zip)(\\?.*)?$\") {\n unset beresp.http.set-cookie;\n }\n\n # Large static files are delivered directly to the end-user without\n # waiting for Varnish to fully read the file first.\n # Varnish 4 fully supports Streaming, so use streaming here to avoid locking.\n if (bereq.url ~ \"^[^?]*\\.(7z|avi|bz2|flac|flv|gz|mka|mkv|mov|mp3|mp4|mpeg|mpg|ogg|ogm|opus|rar|tar|tgz|tbz|txz|wav|webm|xz|zip)(\\?.*)?$\") {\n unset beresp.http.set-cookie;\n set beresp.do_stream = true; # Check memory usage it'll grow in fetch_chunksize blocks (128k by default) if the backend doesn't send a Content-Length header, so only enable it for big objects\n set beresp.do_gzip = false; # Don't try to compress it for storage\n }\n\n # Sometimes, a 301 or 302 redirect formed via Apache's mod_rewrite can mess with the HTTP port that is being passed along.\n # This often happens with simple rewrite rules in a scenario where Varnish runs on :80 and Apache on :8080 on the same box.\n # A redirect can then often redirect the end-user to a URL on :8080, where it should be :80.\n # This may need finetuning on your setup.\n #\n # To prevent accidental replace, we only filter the 301\/302 redirects for now.\n if (beresp.status == 301 || beresp.status == 302) {\n set beresp.http.Location = regsub(beresp.http.Location, \":[0-9]+\", \"\");\n }\n\n # Set 2min cache if unset for static files\n if (beresp.ttl <= 0s || beresp.http.Set-Cookie || beresp.http.Vary == \"*\") {\n set beresp.ttl = 120s; # Important, you shouldn't rely on this, SET YOUR HEADERS in the backend\n set beresp.uncacheable = true;\n\n # Study and test this\n # Mark as \"Hit-For-Pass\" for the next 60 minutes - 24 hours\n #if (bereq.url ~ \"\\.(jpe?g|png|gif|pdf|gz|tgz|bz2|tbz|tar|zip|tiff|tif)$\" || bereq.url ~ \"\/(image|(image_(?:[^\/]|(?!view.*).+)))$\") {\n # set beresp.ttl = std.duration(beresp.http.age+\"s\",0s) + 6h;\n #} elseif (bereq.url ~ \"\\.(svg|swf|ico|mp3|mp4|m4a|ogg|mov|avi|wmv|flv)$\") {\n # set beresp.ttl = std.duration(beresp.http.age+\"s\",0s) + 6h;\n #} elseif (bereq.url ~ \"\\.(xls|vsd|doc|ppt|pps|vsd|doc|ppt|pps|xls|pdf|sxw|rar|odc|odb|odf|odg|odi|odp|ods|odt|sxc|sxd|sxi|sxw|dmg|torrent|deb|msi|iso|rpm)$\") {\n # set beresp.ttl = std.duration(beresp.http.age+\"s\",0s) + 6h;\n #} elseif (bereq.url ~ \"\\.(css|js)$\") {\n # set beresp.ttl = std.duration(beresp.http.age+\"s\",0s) + 24h;\n #} else {\n # set beresp.ttl = std.duration(beresp.http.age+\"s\",0s) + 1h;\n #}\n\n return (deliver);\n }\n\n # Don't cache 50x responses\n if (beresp.status == 500 || beresp.status == 502 || beresp.status == 503 || beresp.status == 504) {\n return (abandon);\n }\n\n # Allow stale content, in case the backend goes down.\n # make Varnish keep all objects for 6 hours beyond their TTL\n set beresp.grace = 6h;\n\n return (deliver);\n}\n\nsub vcl_deliver {\n # Happens when we have all the pieces we need, and are about to send the\n # response to the client.\n #\n # You can do accounting or modifying the final object here.\n\n # Called before a cached object is delivered to the client.\n\n if (obj.hits > 0) { # Add debug header to see if it's a HIT\/MISS and the number of hits, disable when not needed\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n\n # Please note that obj.hits behaviour changed in 4.0, now it counts per objecthead, not per object\n # and obj.hits may not be reset in some cases where bans are in use. See bug 1492 for details.\n # So take hits with a grain of salt\n set resp.http.X-Cache-Hits = obj.hits;\n\n # Remove some headers: PHP version\n unset resp.http.X-Powered-By;\n\n # Remove some headers: Apache version & OS\n unset resp.http.Server;\n unset resp.http.X-Drupal-Cache;\n unset resp.http.X-Varnish;\n unset resp.http.Via;\n unset resp.http.Link;\n unset resp.http.X-Generator;\n\n return (deliver);\n}\n\nsub vcl_purge {\n # Only handle actual PURGE HTTP methods, everything else is discarded\n if (req.method != \"PURGE\") {\n # restart request\n set req.http.X-Purge = \"Yes\";\n return(restart);\n }\n}\n\nsub vcl_synth {\n # Health check\n if (resp.status == 751) {\n set resp.status = 200;\n return (deliver);\n }\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n set resp.http.Retry-After = \"5\";\n synthetic (\"Error\");\n return (deliver);\n}\n","old_contents":"# Managed by saltstack.\n# host id: {{ salt['grains.get']('id', '') }}\n{% set settings = salt['pillar.get']('varnish', {}) -%}\n{% set zinibu_basic = salt['pillar.get']('zinibu_basic', {}) -%}\n#\n# This is an example VCL file for Varnish.\n#\n# It does not do anything by default, delegating control to the\n# builtin VCL. The builtin VCL is called when there is no explicit\n# return statement.\n#\n# See the VCL chapters in the Users Guide at https:\/\/www.varnish-cache.org\/docs\/\n# and https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExamples for more examples.\n\n# Marker to tell the VCL compiler that this VCL has been adapted to the\n# new 4.0 format.\nvcl 4.0;\n\nimport std;\nimport directors;\n\n{%- for id, haproxy_server in zinibu_basic.project.haproxy_servers.iteritems() %}\nbackend bk_appsrv_static_{{ id }} {\n .host = \"{{ haproxy_server.private_ip }}\";\n .port = \"{{ haproxy_server.port }}\";\n .probe = {\n .url = \"{{ zinibu_basic.project.haproxy_check }}\";\n .expected_response = 200;\n .timeout = 1s;\n .interval = 3s;\n .window = 2;\n .threshold = 2;\n .initial = 2;\n }\n}\n{%- endfor %}\n\nsub vcl_init {\n new bar = directors.round_robin();\n{%- for id, haproxy_server in zinibu_basic.project.haproxy_servers.iteritems() %}\n bar.add_backend(bk_appsrv_static_{{ id }});\n{%- endfor %}\n}\n\nacl purge {\n \"localhost\";\n \"127.0.0.1\";\n}\n\nsub vcl_recv {\n # Happens before we check if we have this in cache already.\n #\n # Typically you clean up the request here, removing cookies you don't need,\n # rewriting the request, etc.\n\n # debug bypass\n #return (pass);\n\n #std.log(\"vcl recv: \"+req.request);\n\n # Health Checking\n if (req.url == \"{{ zinibu_basic.project.varnish_check }}\") {\n return (synth(751, \"health check OK!\"));\n }\n\n # send all traffic to the bar director:\n set req.backend_hint = bar.backend();\n\n # Normalize the header, remove the port (in case you're testing this on various TCP ports)\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n # Normalize the query arguments\n set req.url = std.querysort(req.url);\n\n # Allow purging\n if (req.method == \"PURGE\") {\n if (!client.ip ~ purge) { # purge is the ACL defined at the begining\n\t # Not from an allowed IP? Then die with an error.\n return (synth(405, \"This IP is not allowed to send PURGE requests.\"));\n }\n # If you got this stage (and didn't error out above), purge the cached result\n return (purge);\n }\n\n # Only deal with \"normal\" types\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"PATCH\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n # Implementing websocket support (https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html)\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n # Only cache GET or HEAD requests. This makes sure the POST requests are always passed.\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n # Don't think is needed anymore, just check for sessionid cookie\n # Django is setting this cookie so we only check here\n #if (req.http.Cookie ~ \"LOGGED_IN\") {\n # return (pass);\n #}\n\n if (req.http.Authorization) {\n # Not cacheable by default\n return (pass);\n }\n\n set req.http.X-Varnish-Use-Cache = \"TRUE\";\n # unless Django's sessionid or message cookies are in the request, don't pass ANY cookies (referral_source, utm, etc)\n # also, anything inside \/media or \/static should be cached\n if (req.method == \"GET\" && (req.url ~ \"^\/media\" || req.url ~ \"^\/static\" || (req.http.Cookie !~ \"sessionid\" && req.http.Cookie !~ \"csrftoken\" && req.http.Cookie !~ \"messages\"))) {\n unset req.http.Cookie;\n return (hash);\n }\n\n # Large static files are delivered directly to the end-user without\n # waiting for Varnish to fully read the file first.\n # Varnish 4 fully supports Streaming, so set do_stream in vcl_backend_response()\n if (req.url ~ \"^[^?]*\\.(7z|avi|bz2|flac|flv|gz|mka|mkv|mov|mp3|mp4|mpeg|mpg|ogg|ogm|opus|rar|tar|tgz|tbz|txz|wav|webm|xz|zip)(\\?.*)?$\") {\n unset req.http.Cookie;\n return (hash);\n }\n\n # Remove all cookies for static files\n # A valid discussion could be held on this line: do you really need to cache static files that don't cause load? Only if you have memory left.\n # Sure, there's disk I\/O, but chances are your OS will already have these files in their buffers (thus memory).\n # Before you blindly enable this, have a read here: https:\/\/ma.ttias.be\/stop-caching-static-files\/\n if (req.url ~ \"^[^?]*\\.(7z|avi|bmp|bz2|css|csv|doc|docx|eot|flac|flv|gif|gz|ico|jpeg|jpg|js|less|mka|mkv|mov|mp3|mp4|mpeg|mpg|odt|otf|ogg|ogm|opus|pdf|png|ppt|pptx|rar|rtf|svg|svgz|swf|tar|tbz|tgz|ttf|txt|txz|wav|webm|webp|woff|woff2|xls|xlsx|xml|xz|zip)(\\?.*)?$\") {\n unset req.http.Cookie;\n return (hash);\n }\n \n # Are there cookies left with only spaces or that are empty?\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.Cookie;\n }\n\n # Some generic cookie manipulation, useful for all templates that follow\n # Remove the \"has_js\" cookie\n set req.http.Cookie = regsuball(req.http.Cookie, \"has_js=[^;]+(; )?\", \"\");\n\n # Remove any Google Analytics based cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__utm.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"_ga=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"_gat=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmctr=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmcmd.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmccn.=[^;]+(; )?\", \"\");\n\n # Remove DoubleClick offensive cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__gads=[^;]+(; )?\", \"\");\n\n # Remove the Quant Capital cookies (added by some plugin, all __qca)\n #set req.http.Cookie = regsuball(req.http.Cookie, \"__qc.=[^;]+(; )?\", \"\");\n\n # Remove the AddThis cookies\n #set req.http.Cookie = regsuball(req.http.Cookie, \"__atuv.=[^;]+(; )?\", \"\");\n\n # Remove a \";\" prefix in the cookie if present\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n\n if (req.http.Cache-Control ~ \"(?i)no-cache\") {\n #if (req.http.Cache-Control ~ \"(?i)no-cache\" && client.ip ~ editors) { # create the acl editors if you want to restrict the Ctrl-F5\n # http:\/\/varnish.projects.linpro.no\/wiki\/VCLExampleEnableForceRefresh\n # Ignore requests via proxy caches and badly behaved crawlers\n # like msnbot that send no-cache with every request.\n if (! (req.http.Via || req.http.User-Agent ~ \"(?i)bot\" || req.http.X-Purge)) {\n #set req.hash_always_miss = true; # Doesn't seems to refresh the object in the cache\n return(purge); # Couple this with restart in vcl_purge and X-Purge header to avoid loops\n }\n }\n\n # Strip hash, server doesn't need it.\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n # Strip a trailing ? if it exists\n if (req.url ~ \"\\?$\") {\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n return (hash);\n}\n\nsub vcl_pipe {\n # Called upon entering pipe mode.\n # In this mode, the request is passed on to the backend, and any further data from both the client\n # and backend is passed on unaltered until either end closes the connection. Basically, Varnish will\n # degrade into a simple TCP proxy, shuffling bytes back and forth. For a connection in pipe mode,\n # no other VCL subroutine will ever get called after vcl_pipe.\n\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n # set bereq.http.connection = \"close\";\n # here. It is not set by default as it might break some broken web\n # applications, like IIS with NTLM authentication.\n\n # set bereq.http.Connection = \"Close\";\n\n # Implementing websocket support (https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html)\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n\n return (pipe);\n}\n\nsub vcl_pass {\n # Called upon entering pass mode. In this mode, the request is passed on to the backend, and the\n # backend's response is passed on to the client, but is not entered into the cache. Subsequent\n # requests submitted over the same client connection are handled normally.\n\n # return (pass);\n}\n\nsub vcl_hash {\n # Called after vcl_recv to create a hash value for the request. This is used as a key\n # to look up the object in Varnish.\n \n hash_data(req.url);\n \n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n \n # hash cookies for requests that have them\n if (req.http.Cookie) {\n hash_data(req.http.Cookie);\n }\n\n return (lookup);\n}\n\nsub vcl_backend_response {\n # Happens after we have read the response headers from the backend.\n #\n # Here you clean the response headers, removing silly Set-Cookie headers\n # and other mistakes your backend does.\n\n # Called after the response headers has been successfully retrieved from the backend.\n # Enable ESI\n set beresp.do_esi = true;\n # and make sure everything under \/no-cache is, well, not cached\n if (bereq.url ~ \"^\/no-cache\/\") {\n set beresp.uncacheable = true;\n return(deliver); \n }\n\n # Pause ESI request and remove Surrogate-Control header\n if (beresp.http.Surrogate-Control ~ \"ESI\/1.0\") {\n unset beresp.http.Surrogate-Control;\n set beresp.do_esi = true;\n }\n\n # Enable cache for all static files\n # The same argument as the static caches from above: monitor your cache size, if you get data nuked out of it, consider giving up the static file cache.\n # Before you blindly enable this, have a read here: https:\/\/ma.ttias.be\/stop-caching-static-files\/\n if (bereq.url ~ \"^[^?]*\\.(7z|avi|bmp|bz2|css|csv|doc|docx|eot|flac|flv|gif|gz|ico|jpeg|jpg|js|less|mka|mkv|mov|mp3|mp4|mpeg|mpg|odt|otf|ogg|ogm|opus|pdf|png|ppt|pptx|rar|rtf|svg|svgz|swf|tar|tbz|tgz|ttf|txt|txz|wav|webm|webp|woff|woff2|xls|xlsx|xml|xz|zip)(\\?.*)?$\") {\n unset beresp.http.set-cookie;\n }\n\n # Large static files are delivered directly to the end-user without\n # waiting for Varnish to fully read the file first.\n # Varnish 4 fully supports Streaming, so use streaming here to avoid locking.\n if (bereq.url ~ \"^[^?]*\\.(7z|avi|bz2|flac|flv|gz|mka|mkv|mov|mp3|mp4|mpeg|mpg|ogg|ogm|opus|rar|tar|tgz|tbz|txz|wav|webm|xz|zip)(\\?.*)?$\") {\n unset beresp.http.set-cookie;\n set beresp.do_stream = true; # Check memory usage it'll grow in fetch_chunksize blocks (128k by default) if the backend doesn't send a Content-Length header, so only enable it for big objects\n set beresp.do_gzip = false; # Don't try to compress it for storage\n }\n\n # Sometimes, a 301 or 302 redirect formed via Apache's mod_rewrite can mess with the HTTP port that is being passed along.\n # This often happens with simple rewrite rules in a scenario where Varnish runs on :80 and Apache on :8080 on the same box.\n # A redirect can then often redirect the end-user to a URL on :8080, where it should be :80.\n # This may need finetuning on your setup.\n #\n # To prevent accidental replace, we only filter the 301\/302 redirects for now.\n if (beresp.status == 301 || beresp.status == 302) {\n set beresp.http.Location = regsub(beresp.http.Location, \":[0-9]+\", \"\");\n }\n\n # Set 2min cache if unset for static files\n if (beresp.ttl <= 0s || beresp.http.Set-Cookie || beresp.http.Vary == \"*\") {\n set beresp.ttl = 120s; # Important, you shouldn't rely on this, SET YOUR HEADERS in the backend\n set beresp.uncacheable = true;\n\n # Study and test this\n # Mark as \"Hit-For-Pass\" for the next 60 minutes - 24 hours\n #if (bereq.url ~ \"\\.(jpe?g|png|gif|pdf|gz|tgz|bz2|tbz|tar|zip|tiff|tif)$\" || bereq.url ~ \"\/(image|(image_(?:[^\/]|(?!view.*).+)))$\") {\n # set beresp.ttl = std.duration(beresp.http.age+\"s\",0s) + 6h;\n #} elseif (bereq.url ~ \"\\.(svg|swf|ico|mp3|mp4|m4a|ogg|mov|avi|wmv|flv)$\") {\n # set beresp.ttl = std.duration(beresp.http.age+\"s\",0s) + 6h;\n #} elseif (bereq.url ~ \"\\.(xls|vsd|doc|ppt|pps|vsd|doc|ppt|pps|xls|pdf|sxw|rar|odc|odb|odf|odg|odi|odp|ods|odt|sxc|sxd|sxi|sxw|dmg|torrent|deb|msi|iso|rpm)$\") {\n # set beresp.ttl = std.duration(beresp.http.age+\"s\",0s) + 6h;\n #} elseif (bereq.url ~ \"\\.(css|js)$\") {\n # set beresp.ttl = std.duration(beresp.http.age+\"s\",0s) + 24h;\n #} else {\n # set beresp.ttl = std.duration(beresp.http.age+\"s\",0s) + 1h;\n #}\n\n return (deliver);\n }\n\n # Don't cache 50x responses\n if (beresp.status == 500 || beresp.status == 502 || beresp.status == 503 || beresp.status == 504) {\n return (abandon);\n }\n\n # Allow stale content, in case the backend goes down.\n # make Varnish keep all objects for 6 hours beyond their TTL\n set beresp.grace = 6h;\n\n return (deliver);\n}\n\nsub vcl_deliver {\n # Happens when we have all the pieces we need, and are about to send the\n # response to the client.\n #\n # You can do accounting or modifying the final object here.\n\n # Called before a cached object is delivered to the client.\n\n if (obj.hits > 0) { # Add debug header to see if it's a HIT\/MISS and the number of hits, disable when not needed\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n\n # Please note that obj.hits behaviour changed in 4.0, now it counts per objecthead, not per object\n # and obj.hits may not be reset in some cases where bans are in use. See bug 1492 for details.\n # So take hits with a grain of salt\n set resp.http.X-Cache-Hits = obj.hits;\n\n # Remove some headers: PHP version\n unset resp.http.X-Powered-By;\n\n # Remove some headers: Apache version & OS\n unset resp.http.Server;\n unset resp.http.X-Drupal-Cache;\n unset resp.http.X-Varnish;\n unset resp.http.Via;\n unset resp.http.Link;\n unset resp.http.X-Generator;\n\n return (deliver);\n}\n\nsub vcl_purge {\n # Only handle actual PURGE HTTP methods, everything else is discarded\n if (req.method != \"PURGE\") {\n # restart request\n set req.http.X-Purge = \"Yes\";\n return(restart);\n }\n}\n\nsub vcl_synth {\n # Health check\n if (resp.status == 751) {\n set resp.status = 200;\n return (deliver);\n }\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n set resp.http.Retry-After = \"5\";\n synthetic (\"Error\");\n return (deliver);\n}\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"1400f18960f4f311a8c13cac2110ee048e26559b","subject":"Update openstreetmap4.vcl","message":"Update openstreetmap4.vcl","repos":"klausdk\/varnish","old_file":"openstreetmap\/openstreetmap4.vcl","new_file":"openstreetmap\/openstreetmap4.vcl","new_contents":"# VCL script for varnish 4\n\nvcl 4.0;\n\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"80\";\n}\n\n\nbackend a_tile {\n .host = \"a.tile.openstreetmap.org\";\n .port = \"80\";\n}\n\nbackend b_tile {\n .host = \"b.tile.openstreetmap.org\";\n .port = \"80\";\n}\n\nbackend c_tile {\n .host = \"c.tile.openstreetmap.org\";\n .port = \"80\";\n}\n\nsub vcl_recv {\n\n if (req.http.host ~ \"^a.tile\") {\n set req.backend_hint = a_tile;\n } else if (req.http.host ~ \"^b.tile\") {\n set req.backend_hint = b_tile;\n } else if (req.http.host ~ \"^c.tile\") {\n set req.backend_hint = c_tile;\n } else if (req.http.host ~ \"^a.map\") {\n set req.backend_hint = a_tile;\n } else if (req.http.host ~ \"^b.map\") {\n set req.backend_hint = b_tile;\n } else if (req.http.host ~ \"^c.map\") {\n set req.backend_hint = c_tile;\n }\n\n unset req.http.cookie;\n\n \/\/ Cache everything\n if (req.method == \"GET\") {\n return (hash);\n }\n\n\n}\n\nsub vcl_backend_response {\n\n \/\/ Cache tiles for 3 weeks\n set beresp.ttl = 3w;\n\n \/\/ Remove all cookies\n unset beresp.http.set-cookie;\n unset beresp.http.cookie;\n\n}\n\nsub vcl_deliver {\n\n \n if (obj.hits > 0) {\n set resp.http.X-Cache_v = \"HIT\";\n } else {\n set resp.http.X-Cache_v = \"MISS\";\n }\n}\n\nsub vcl_hash {\n\n \/\/ Cache using only url as a hash. \n \/\/ This means if a.tile\/1\/1\/1\/tile.png is accessed, b.tile\/1\/1\/1\/tile.png will also be fetch from cache\n hash_data(req.url);\n return (lookup);\n}\n\n","old_contents":"# VCL script for varnish 4\n\nvcl 4.0;\n\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"80\";\n}\n\n\nbackend a_tile {\n .host = \"a.tile.openstreetmap.org\";\n .port = \"80\";\n}\n\nbackend b_tile {\n .host = \"b.tile.openstreetmap.org\";\n .port = \"80\";\n}\n\nbackend c_tile {\n .host = \"c.tile.openstreetmap.org\";\n .port = \"80\";\n}\n\nsub vcl_recv {\n\n if (req.http.host ~ \"^a.tile\") {\n set req.backend_hint = a_tile;\n } else if (req.http.host ~ \"^b.tile\") {\n set req.backend_hint = b_tile;\n } else if (req.http.host ~ \"^c.tile\") {\n set req.backend_hint = c_tile;\n } else if (req.http.host ~ \"^a.map\") {\n set req.backend_hint = a_tile;\n } else if (req.http.host ~ \"^b.map\") {\n set req.backend_hint = b_tile;\n } else if (req.http.host ~ \"^c.map\") {\n set req.backend_hint = c_tile;\n }\n\n unset req.http.cookie;\n\n \/\/ Cache everything\n if (req.method == \"GET\") {\n return (hash);\n }\n\n\n}\n\nsub vcl_backend_response {\n\n \/\/ Cache tiles for 3 weeks\n set beresp.ttl = 3w;\n\n \/\/ Remove all cookies\n unset beresp.http.set-cookie;\n unset beresp.http.cookie;\n\n}\n\nsub vcl_deliver {\n\n \n if (obj.hits > 0) {\n set resp.http.X-Cache_v = \"HIT\";\n } else {\n set resp.http.X-Cache_v = \"MISS\";\n }\n}\n\nsub vcl_hash {\n\n \/\/ Cache using only url as a hash. \n \/\/ This means if a.tile\/1\/1\/1\/tile.png is access, b.tile\/1\/1\/1\/tile.png will also be fetch from cache\n hash_data(req.url);\n return (lookup);\n}\n\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"853e9edd7f7f11d64f93d471e54155b79ef1404b","subject":"Strip off Google Adwords, Mailchip etc. tracking query parameters","message":"Strip off Google Adwords, Mailchip etc. tracking query parameters\n","repos":"fastly\/fastly-magento,fastly\/fastly-magento,fastly\/fastly-magento,fastly\/fastly-magento","old_file":"app\/code\/community\/Fastly\/CDN\/etc\/vcl_snippets\/recv.vcl","new_file":"app\/code\/community\/Fastly\/CDN\/etc\/vcl_snippets\/recv.vcl","new_contents":" # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n # Sort the query arguments\n set req.url = boltsort.sort(req.url);\n\n # bypass language switcher\n if (req.url ~ \"(?i)___from_store=.*&___store=.*\") {\n set req.http.X-Pass = \"1\";\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (req.http.cookie:FASTLY_CDN_ENV) {\n set req.http.Fastly-Cdn-Env = req.http.cookie:FASTLY_CDN_ENV;\n } else {\n unset req.http.Fastly-Cdn-Env;\n }\n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n\n if (!req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n error 403;\n }\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n\n } else {\n error 403;\n }\n\n }\n\n # disable ESI processing on Origin Shield\n if (req.http.Fastly-FF) {\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(media|js|skin)\/.*\\.(png|jpg|jpeg|gif|css|js|swf|ico)$\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n # formkey lookup\n if (req.url ~ \"\/fastlycdn\/getformkey\/\") {\n # check if we have a formkey cookie\n if (req.http.Cookie:FASTLY_CDN_FORMKEY) {\n set req.http.Formkey = req.http.Cookie:FASTLY_CDN_FORMKEY;\n } else {\n # create formkey\n set req.http.seed = req.http.Cookie client.ip remote.port geoip.longitude geoip.latitude geoip.postal_code;\n set req.http.Formkey = regsub(digest.hash_md5(req.http.seed), \"^0x\", \"\");\n }\n error 760 req.http.Formkey;\n }\n\n # geoip lookup\n if (req.url ~ \"fastlycdn\/esi\/getcountry\/\") {\n # check if GeoIP has been already processed by client\n if (req.http.Cookie:FASTLY_CDN_GEOIP_PROCESSED) {\n error 200 \"\";\n } else {\n # modify req.url and restart request processing\n error 750 geoip.country_code;\n }\n }\n\n # geoip get country code\n if (req.url ~ \"fastlycdn\/esi\/getcountrycode\/\") {\n # create and set req.http.X-Country-Code\n error 755 geoip.country_code;\n }\n\n # check for ESI calls\n if (req.url ~ \"esi_data=\") {\n # check for valid cookie data\n if (req.http.Cookie ~ \"FASTLY_CDN-([A-Za-z0-9-_]+)=([^;]*)\") {\n set req.url = querystring.filter(req.url, \"esi_data\") + \"&esi_data=\" + re.group.2;\n }\n }\n\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking\n set req.http.Magento-Original-URL = req.url;\n set req.url = querystring.regfilter(req.url, \"^(utm_.*|gclid|gdftrk|_ga|mc_.*)\");\n\n # If object has been marked as pass pass it\n if ( req.http.X-Pass ) {\n return(pass);\n }\n","old_contents":" # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n # Sort the query arguments\n set req.url = boltsort.sort(req.url);\n\n # bypass language switcher\n if (req.url ~ \"(?i)___from_store=.*&___store=.*\") {\n set req.http.X-Pass = \"1\";\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (req.http.cookie:FASTLY_CDN_ENV) {\n set req.http.Fastly-Cdn-Env = req.http.cookie:FASTLY_CDN_ENV;\n } else {\n unset req.http.Fastly-Cdn-Env;\n }\n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n\n if (!req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n error 403;\n }\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n\n } else {\n error 403;\n }\n\n }\n\n # disable ESI processing on Origin Shield\n if (req.http.Fastly-FF) {\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(media|js|skin)\/.*\\.(png|jpg|jpeg|gif|css|js|swf|ico)$\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n # formkey lookup\n if (req.url ~ \"\/fastlycdn\/getformkey\/\") {\n # check if we have a formkey cookie\n if (req.http.Cookie:FASTLY_CDN_FORMKEY) {\n set req.http.Formkey = req.http.Cookie:FASTLY_CDN_FORMKEY;\n } else {\n # create formkey\n set req.http.seed = req.http.Cookie client.ip remote.port geoip.longitude geoip.latitude geoip.postal_code;\n set req.http.Formkey = regsub(digest.hash_md5(req.http.seed), \"^0x\", \"\");\n }\n error 760 req.http.Formkey;\n }\n\n # geoip lookup\n if (req.url ~ \"fastlycdn\/esi\/getcountry\/\") {\n # check if GeoIP has been already processed by client\n if (req.http.Cookie:FASTLY_CDN_GEOIP_PROCESSED) {\n error 200 \"\";\n } else {\n # modify req.url and restart request processing\n error 750 geoip.country_code;\n }\n }\n\n # geoip get country code\n if (req.url ~ \"fastlycdn\/esi\/getcountrycode\/\") {\n # create and set req.http.X-Country-Code\n error 755 geoip.country_code;\n }\n\n # check for ESI calls\n if (req.url ~ \"esi_data=\") {\n # check for valid cookie data\n if (req.http.Cookie ~ \"FASTLY_CDN-([A-Za-z0-9-_]+)=([^;]*)\") {\n set req.url = querystring.filter(req.url, \"esi_data\") + \"&esi_data=\" + re.group.2;\n }\n }\n\n # If object has been marked as pass pass it\n if ( req.http.X-Pass ) {\n return(pass);\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"42a7ca6e0d4da87db9f76011517416bffeb7c998","subject":"update varnish configuration file. :fire:","message":"update varnish configuration file. :fire:\n","repos":"Dogzhou\/xingishere,Dogzhou\/xingishere,Dogzhou\/xingishere,Dogzhou\/xingishere","old_file":"config\/varnish.vcl","new_file":"config\/varnish.vcl","new_contents":"vcl 4.0;\n\nimport directors;\n\nbackend server_rails {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\n\nsub vcl_init {\n new load_balancing_servers = directors.random();\n load_balancing_servers.add_backend(server_rails,10);\n}\n\nsub vcl_recv {\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n return (pipe);\n }\n\n if ((req.method == \"POST\" || req.method == \"PUT\") &&\n req.http.transfer-encoding ~ \"chunked\") {\n return(pipe);\n }\n\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|jpeg|bmp|swf|png|gif|gz|tgz|bz2|tbz|mp3|ogg|ico|pdf|cur)$\") {\n # No point in compressing these\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n\n set req.backend_hint = load_balancing_servers.backend();\n unset req.http.Cookie;\n\n return (hash);\n}\n\nsub vcl_pipe {\n return (pipe);\n}\n\nsub vcl_pass {\n return (fetch);\n}\n\nsub vcl_backend_response {\n # set beresp.grace = 1h;\n set beresp.ttl = 5m;\n\n if (beresp.status != 200 && beresp.status != 403 && beresp.status != 404 && beresp.status != 301 && beresp.status != 302 && beresp.status != 503) {\n # set beresp.saintmode = 10s;\n return (retry);\n }\n unset beresp.http.set-cookie;\n return (deliver);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n return (lookup);\n}\n\nsub vcl_deliver {\n unset resp.http.X-Varnish;\n unset resp.http.via;\n unset resp.http.Age;\n\n if (obj.hits > 0) {\n set resp.http.Cache = \"H\";\n }\n else {\n set resp.http.Cache = \"M\";\n }\n return (deliver);\n}\n\nsub vcl_hit {\n return (deliver);\n}\n\nsub vcl_miss {\n return (fetch);\n}\n\nsub vcl_backend_error {\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic({\"\n <?xml version=\"1.0\" encoding=\"utf-8\"?>\n <!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n <html>\n <head>\n <title>\"} + beresp.status + \" \" + beresp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + beresp.status + \" \" + beresp.reason + {\"<\/h1>\n <p>\"} + beresp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + bereq.xid + {\"<\/p>\n <hr>\n <p>Squid cache server<\/p>\n <\/body>\n <\/html>\n \"});\n return (deliver);\n}\n\nsub vcl_synth {\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n set resp.http.Retry-After = \"5\";\n synthetic({\"\n <?xml version=\"1.0\" encoding=\"utf-8\"?>\n <!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n <html>\n <head>\n <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Squid cache server<\/p>\n <\/body>\n <\/html>\n \"});\n return (deliver);\n}\n\nsub vcl_fini {\n return (ok);\n}\n","old_contents":"vcl 4.0;\n\nimport directors;\n\nbackend server_rails {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\n\nsub vcl_init {\n new load_balancing_servers = directors.random();\n load_balancing_servers.add_backend(server_rails,10);\n}\n\nsub vcl_recv {\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n return (pipe);\n }\n\n if ((req.method == \"POST\" || req.method == \"PUT\") &&\n req.http.transfer-encoding ~ \"chunked\") {\n return(pipe);\n }\n\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|jpeg|bmp|swf|png|gif|gz|tgz|bz2|tbz|mp3|ogg|ico|pdf|cur)$\") {\n # No point in compressing these\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n\n set req.backend_hint = load_balancing_servers.backend();\n unset req.http.Cookie;\n\n return (hash);\n}\n\nsub vcl_pipe {\n return (pipe);\n}\n\nsub vcl_pass {\n return (fetch);\n}\n\nsub vcl_backend_response {\n # set beresp.grace = 1h;\n set beresp.ttl = 5m;\n\n if (beresp.status != 200 && beresp.status != 403 && beresp.status != 404 && beresp.status != 301 && beresp.status != 302 && beresp.status != 503) {\n # set beresp.saintmode = 10s;\n return (retry);\n }\n unset beresp.http.set-cookie;\n return (deliver);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n return (lookup);\n}\n\nsub vcl_deliver {\n unset resp.http.X-Varnish;\n unset resp.http.via;\n unset resp.http.Age;\n\n if (obj.hits > 0) {\n set resp.http.Cache = \"H\";\n }\n else {\n set resp.http.Cache = \"M\";\n }\n return (deliver);\n}\n\nsub vcl_hit {\n return (deliver);\n}\n\nsub vcl_miss {\n return (fetch);\n}\n\nsub vcl_backend_error {\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic({\"\n <?xml version=\"1.0\" encoding=\"utf-8\"?>\n <!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n <html>\n <head>\n <title>\"} + beresp.status + \" \" + beresp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + beresp.status + \" \" + beresp.reason + {\"<\/h1>\n <p>\"} + beresp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + bereq.xid + {\"<\/p>\n <hr>\n <p>Squid cache server<\/p>\n <\/body>\n <\/html>\n \"});\n return (deliver);\n}\n\nsub vcl_synth {\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n set resp.http.Retry-After = \"5\";\n synthetic({\"\n <?xml version=\"1.0\" encoding=\"utf-8\"?>\n <!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n <html>\n <head>\n <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Squid cache server<\/p>\n <\/body>\n <\/html>\n \"});\n return (deliver);\n}\n\nsub vcl_fini {\n return (ok);\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"0de787b5794f41d5f41b484a30840ebdd3f204a0","subject":"Enable GZipping on origin","message":"Enable GZipping on origin\n","repos":"fastly\/fastly-magento,fastly\/fastly-magento,fastly\/fastly-magento,fastly\/fastly-magento","old_file":"app\/code\/community\/Fastly\/CDN\/etc\/default.vcl","new_file":"app\/code\/community\/Fastly\/CDN\/etc\/default.vcl","new_contents":"###############################################################################\n#\n# Fastly CDN for Magento\n#\n# NOTICE OF LICENSE\n#\n# This source file is subject to the Fastly CDN for Magento End User License\n# Agreement that is bundled with this package in the file LICENSE_FASTLY_CDN.txt.\n#\n# @copyright Copyright (c) 2015 Fastly, Inc. (http:\/\/www.fastly.com)\n# @license BSD, see LICENSE_FASTLY_CDN.txt\n#\n###############################################################################\n\n# This is a basic VCL configuration file for fastly CDN for Magento module.\n\nsub vcl_recv {\n#FASTLY recv\n # we only deal with GET and HEAD by default\n if (req.request != \"GET\" && req.request != \"HEAD\" && req.request != \"FASTLYPURGE\") {\n return (pass);\n }\n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n set req.http.X-Sig = regsub(req.http.X-Purge-Token, \"^[^_]+_(.*)\", \"\\1\");\n set req.http.X-Exp = regsub(req.http.X-Purge-Token, \"^([^_]+)_.*\", \"\\1\");\n\n # validate signature\n if (req.http.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path req.http.X-Exp), \"^0x\", \"\")) {\n\n # use vcl time math to check expiration timestamp\n set req.http.X-Original-Grace = req.grace;\n set req.grace = std.atoi(strftime({\"%s\"}, now));\n set req.grace -= std.atoi(req.http.X-Exp);\n\n if (std.atoi(req.grace) > 0) {\n error 410;\n }\n\n # clean up grace since we used it for time math\n set req.grace = std.atoi(req.http.X-Original-Grace);\n unset req.http.X-Original-Grace;\n\n } else {\n error 403;\n }\n\n # cleanup variables\n unset req.http.X-Purge-Token;\n unset req.http.X-Sig;\n unset req.http.X-Exp;\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n # disable ESI processing on Origin Shield\n if (req.http.Fastly-FF) {\n set req.esi = false;\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(media|js|skin)\/.*\\.(png|jpg|jpeg|gif|css|js|swf|ico)$\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n # formkey lookup\n if (req.url ~ \"\/fastlycdn\/getformkey\/\") {\n # check if we have a formkey cookie\n if (req.http.Cookie ~ \"FASTLY_CDN_FORMKEY\") {\n set req.http.Formkey = regsub(req.http.cookie, \".*FASTLY_CDN_FORMKEY=([^;]*)(;*.*)?\", \"\\1\");\n } else {\n # create formkey\n set req.http.seed = req.http.Cookie client.ip remote.port geoip.longitude geoip.latitude geoip.postal_code;\n set req.http.Formkey = regsub(digest.hash_md5(req.http.seed), \"^0x\", \"\");\n }\n error 760 req.http.Formkey;\n }\n\n # geoip lookup\n if (req.url ~ \"fastlycdn\/esi\/getcountry\/\") {\n # check if GeoIP has been already processed by client\n if (req.http.Cookie ~ \"FASTLY_CDN_GEOIP_PROCESSED\") {\n error 200 \"\";\n } else {\n # modify req.url and restart request processing\n error 750 geoip.country_code;\n }\n }\n\n # geoip get country code\n if (req.url ~ \"fastlycdn\/esi\/getcountrycode\/\") {\n # create and set req.http.X-Country-Code\n error 755 geoip.country_code;\n }\n\n # check for ESI calls\n if (req.url ~ \"esi_data=\") {\n # check for valid cookie data\n if (req.http.Cookie ~ \"FASTLY_CDN-\") {\n # get the cookie name to look for\n set req.http.fastlyCDNEsiCookieName = regsub(\n req.url,\n \"(.*)esi_data=([^&]*)(.*)\",\n \"\\2\"\n );\n\n # get the cookie value for the cookie name\n # tmp string is NAMESPACE-COOKIENAME@@@@@COMPLETE_COOKIE\n # left of @@@@@ is back-referenced in regex to extract value from cookie\n set req.http.fastlyTmp = \"FASTLY_CDN-\" req.http.fastlyCDNEsiCookieName \"@@@@@\" req.http.Cookie;\n set req.http.fastlyCDNRequest = regsub(\n req.http.fastlyTmp,\n \"^([A-Za-z0-9-_]+)@@@@@.*\\1=([^;]*)\",\n \"\\2\"\n );\n\n # do we have a value for the cookie name?\n if (!req.http.fastlyCDNRequest) {\n set req.http.fastlyCDNRequest = \"default\";\n }\n\n # build backend url\n set req.url = regsub(\n req.url,\n \"(.*)esi_data=([^&]*)[&]?(.*)\",\n \"\\1\\3\"\n )\n \"&esi_data=\"\n req.http.fastlyCDNRequest;\n\n # clean up temp variables\n remove req.http.fastlyCDNEsiCookieName;\n remove req.http.fastlyCDNRequest;\n\n return (lookup);\n }\n }\n\n return(lookup);\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n\nsub vcl_hash {\n set req.hash += req.http.Https;\n set req.hash += req.http.host;\n set req.hash += req.url;\n\n if (req.http.cookie ~ \"FASTLY_CDN_ENV=\") {\n set req.http.fastlyCDNEnv = regsub(\n req.http.cookie,\n \"(.*)FASTLY_CDN_ENV=([^;]*)(.*)\",\n \"\\2\"\n );\n set req.hash += req.http.fastlyCDNEnv;\n unset req.http.fastlyCDNEnv;\n }\n\n set req.hash += \"#####GENERATION#####\";\n\n if (!(req.url ~ \"^\/(media|js|skin)\/.*\\.(png|jpg|jpeg|gif|css|js|swf|ico)$\")) {\n call design_exception;\n }\n return (hash);\n}\n\nsub vcl_hit {\n#FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\nsub vcl_miss {\n # Deactivate gzip on origin\n unset bereq.http.Accept-Encoding;\n\n#FASTLY miss\n\n return(fetch);\n}\n\nsub vcl_fetch {\n#FASTLY fetch\n\n if (beresp.status >= 500) {\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n }\n\n if (req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Content-Type ~ \"text\/html\" || beresp.http.Content-Type ~ \"text\/xml\") {\n # enable ESI feature for Magento response by default\n esi;\n } else {\n # enable gzip for all static content\n if ((beresp.status == 200 || beresp.status == 404) && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url ~ \"\\.(css|js|html|eot|ico|otf|ttf|json)($|\\?)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.status == 500 || beresp.status == 503) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n if (beresp.status == 200 || beresp.status == 301 || beresp.status == 404) {\n if (beresp.http.Content-Type ~ \"text\/html\" || beresp.http.Content-Type ~ \"text\/xml\") {\n # marker for vcl_deliver to reset Age:\n set beresp.http.magentomarker = \"1\";\n\n # Don't cache cookies\n unset beresp.http.set-cookie;\n } else {\n if (beresp.http.Expires || beresp.http.Surrogate-Control ~ \"max-age\" || beresp.http.Cache-Control ~ \"(s-maxage|max-age)\") {\n # keep the ttl here\n } else {\n # apply the default ttl\n set beresp.ttl = 3600s;\n }\n }\n\n # init surrogate keys\n if (beresp.http.Surrogate-Key) {\n set beresp.http.Surrogate-Key = beresp.http.Surrogate-Key \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type\n if (beresp.http.Content-Type ~ \"image\") {\n set beresp.http.Surrogate-Key = \"image\";\n } elsif (beresp.http.Content-Type ~ \"script\") {\n set beresp.http.Surrogate-Key = \"script\";\n } elsif (beresp.http.Content-Type ~ \"css\") {\n set beresp.http.Surrogate-Key = \"css\";\n }\n\n set beresp.http.X-Surrogate-Key = beresp.http.Surrogate-Key;\n }\n\n return (deliver);\n}\n\nsub vcl_deliver {\n # debug info\n if (resp.http.X-Cache-Debug) {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n set resp.http.X-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n set resp.http.X-Cache-Expires = resp.http.Expires;\n } else {\n # remove Varnish\/proxy header\n remove resp.http.X-Varnish;\n remove resp.http.Via;\n remove resp.http.Age;\n remove resp.http.X-Purge-URL;\n remove resp.http.X-Purge-Host;\n remove resp.http.X-Surrogate-Key;\n }\n\n if (resp.http.magentomarker) {\n # Remove the magic marker\n unset resp.http.magentomarker;\n\n set resp.http.Cache-Control = \"no-store, no-cache, must-revalidate, post-check=0, pre-check=0\";\n set resp.http.Pragma = \"no-cache\";\n set resp.http.Expires = \"Mon, 31 Mar 2008 10:00:00 GMT\";\n set resp.http.Age = \"0\";\n }\n\n#FASTLY deliver\n\n return (deliver);\n}\n\nsub vcl_error {\n # workaround for possible security issue\n if (req.url ~ \"^\\s\") {\n set obj.status = 400;\n set obj.response = \"Malformed request\";\n synthetic \"\";\n return (deliver);\n }\n\n # geo ip request\n if (obj.status == 750) {\n set req.url = regsub(req.url, \"(\/fastlycdn\/esi\/getcountry\/.*)\", \"\/fastlycdn\/esi\/getcountryaction\/?country_code=\") obj.response;\n return (restart);\n }\n\n # geo ip country code\n if (obj.status == 755) {\n set obj.status = 200;\n\t synthetic obj.response;\n return(deliver);\n }\n\n # formkey request\n if (obj.status == 760) {\n set obj.status = 200;\n\t synthetic obj.response;\n return (deliver);\n }\n\n # error 200\n if (obj.status == 200) {\n return (deliver);\n }\n\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} obj.status \" \" obj.response {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} obj.status \" \" obj.response {\"<\/h1>\n <p>\"} obj.response {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} req.xid {\"<\/p>\n <hr>\n <p>Fastly CDN server<\/p>\n <\/body>\n<\/html>\n\"};\n\n#FASTLY error\n}\n\nsub design_exception {\n}\n","old_contents":"###############################################################################\n#\n# Fastly CDN for Magento\n#\n# NOTICE OF LICENSE\n#\n# This source file is subject to the Fastly CDN for Magento End User License\n# Agreement that is bundled with this package in the file LICENSE_FASTLY_CDN.txt.\n#\n# @copyright Copyright (c) 2015 Fastly, Inc. (http:\/\/www.fastly.com)\n# @license BSD, see LICENSE_FASTLY_CDN.txt\n#\n###############################################################################\n\n# This is a basic VCL configuration file for fastly CDN for Magento module.\n\nsub vcl_recv {\n#FASTLY recv\n # we only deal with GET and HEAD by default\n if (req.request != \"GET\" && req.request != \"HEAD\" && req.request != \"FASTLYPURGE\") {\n return (pass);\n }\n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n set req.http.X-Sig = regsub(req.http.X-Purge-Token, \"^[^_]+_(.*)\", \"\\1\");\n set req.http.X-Exp = regsub(req.http.X-Purge-Token, \"^([^_]+)_.*\", \"\\1\");\n\n # validate signature\n if (req.http.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path req.http.X-Exp), \"^0x\", \"\")) {\n\n # use vcl time math to check expiration timestamp\n set req.http.X-Original-Grace = req.grace;\n set req.grace = std.atoi(strftime({\"%s\"}, now));\n set req.grace -= std.atoi(req.http.X-Exp);\n\n if (std.atoi(req.grace) > 0) {\n error 410;\n }\n\n # clean up grace since we used it for time math\n set req.grace = std.atoi(req.http.X-Original-Grace);\n unset req.http.X-Original-Grace;\n\n } else {\n error 403;\n }\n\n # cleanup variables\n unset req.http.X-Purge-Token;\n unset req.http.X-Sig;\n unset req.http.X-Exp;\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n # disable ESI processing on Origin Shield\n if (req.http.Fastly-FF) {\n set req.esi = false;\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(media|js|skin)\/.*\\.(png|jpg|jpeg|gif|css|js|swf|ico)$\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n # formkey lookup\n if (req.url ~ \"\/fastlycdn\/getformkey\/\") {\n # check if we have a formkey cookie\n if (req.http.Cookie ~ \"FASTLY_CDN_FORMKEY\") {\n set req.http.Formkey = regsub(req.http.cookie, \".*FASTLY_CDN_FORMKEY=([^;]*)(;*.*)?\", \"\\1\");\n } else {\n # create formkey\n set req.http.seed = req.http.Cookie client.ip remote.port geoip.longitude geoip.latitude geoip.postal_code;\n set req.http.Formkey = regsub(digest.hash_md5(req.http.seed), \"^0x\", \"\");\n }\n error 760 req.http.Formkey;\n }\n\n # geoip lookup\n if (req.url ~ \"fastlycdn\/esi\/getcountry\/\") {\n # check if GeoIP has been already processed by client\n if (req.http.Cookie ~ \"FASTLY_CDN_GEOIP_PROCESSED\") {\n error 200 \"\";\n } else {\n # modify req.url and restart request processing\n error 750 geoip.country_code;\n }\n }\n\n # geoip get country code\n if (req.url ~ \"fastlycdn\/esi\/getcountrycode\/\") {\n # create and set req.http.X-Country-Code\n error 755 geoip.country_code;\n }\n\n # check for ESI calls\n if (req.url ~ \"esi_data=\") {\n # check for valid cookie data\n if (req.http.Cookie ~ \"FASTLY_CDN-\") {\n # get the cookie name to look for\n set req.http.fastlyCDNEsiCookieName = regsub(\n req.url,\n \"(.*)esi_data=([^&]*)(.*)\",\n \"\\2\"\n );\n\n # get the cookie value for the cookie name\n # tmp string is NAMESPACE-COOKIENAME@@@@@COMPLETE_COOKIE\n # left of @@@@@ is back-referenced in regex to extract value from cookie\n set req.http.fastlyTmp = \"FASTLY_CDN-\" req.http.fastlyCDNEsiCookieName \"@@@@@\" req.http.Cookie;\n set req.http.fastlyCDNRequest = regsub(\n req.http.fastlyTmp,\n \"^([A-Za-z0-9-_]+)@@@@@.*\\1=([^;]*)\",\n \"\\2\"\n );\n\n # do we have a value for the cookie name?\n if (!req.http.fastlyCDNRequest) {\n set req.http.fastlyCDNRequest = \"default\";\n }\n\n # build backend url\n set req.url = regsub(\n req.url,\n \"(.*)esi_data=([^&]*)[&]?(.*)\",\n \"\\1\\3\"\n )\n \"&esi_data=\"\n req.http.fastlyCDNRequest;\n\n # clean up temp variables\n remove req.http.fastlyCDNEsiCookieName;\n remove req.http.fastlyCDNRequest;\n\n return (lookup);\n }\n }\n\n return(lookup);\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n\nsub vcl_hash {\n set req.hash += req.http.Https;\n set req.hash += req.http.host;\n set req.hash += req.url;\n\n if (req.http.cookie ~ \"FASTLY_CDN_ENV=\") {\n set req.http.fastlyCDNEnv = regsub(\n req.http.cookie,\n \"(.*)FASTLY_CDN_ENV=([^;]*)(.*)\",\n \"\\2\"\n );\n set req.hash += req.http.fastlyCDNEnv;\n unset req.http.fastlyCDNEnv;\n }\n\n set req.hash += \"#####GENERATION#####\";\n\n if (!(req.url ~ \"^\/(media|js|skin)\/.*\\.(png|jpg|jpeg|gif|css|js|swf|ico)$\")) {\n call design_exception;\n }\n return (hash);\n}\n\nsub vcl_hit {\n#FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\nsub vcl_miss {\n#FASTLY miss\n\n return(fetch);\n}\n\nsub vcl_fetch {\n#FASTLY fetch\n\n if (beresp.status >= 500) {\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n }\n\n if (req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Content-Type ~ \"text\/html\" || beresp.http.Content-Type ~ \"text\/xml\") {\n # enable ESI feature for Magento response by default\n esi;\n }\n\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.status == 500 || beresp.status == 503) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n if (beresp.status == 200 || beresp.status == 301 || beresp.status == 404) {\n if (beresp.http.Content-Type ~ \"text\/html\" || beresp.http.Content-Type ~ \"text\/xml\") {\n # marker for vcl_deliver to reset Age:\n set beresp.http.magentomarker = \"1\";\n\n # Don't cache cookies\n unset beresp.http.set-cookie;\n } else {\n if (beresp.http.Expires || beresp.http.Surrogate-Control ~ \"max-age\" || beresp.http.Cache-Control ~ \"(s-maxage|max-age)\") {\n # keep the ttl here\n } else {\n # apply the default ttl\n set beresp.ttl = 3600s;\n }\n }\n\n # init surrogate keys\n if (beresp.http.Surrogate-Key) {\n set beresp.http.Surrogate-Key = beresp.http.Surrogate-Key \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type\n if (beresp.http.Content-Type ~ \"image\") {\n set beresp.http.Surrogate-Key = \"image\";\n } elsif (beresp.http.Content-Type ~ \"script\") {\n set beresp.http.Surrogate-Key = \"script\";\n } elsif (beresp.http.Content-Type ~ \"css\") {\n set beresp.http.Surrogate-Key = \"css\";\n }\n\n set beresp.http.X-Surrogate-Key = beresp.http.Surrogate-Key;\n }\n\n return (deliver);\n}\n\nsub vcl_deliver {\n # debug info\n if (resp.http.X-Cache-Debug) {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n set resp.http.X-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n set resp.http.X-Cache-Expires = resp.http.Expires;\n } else {\n # remove Varnish\/proxy header\n remove resp.http.X-Varnish;\n remove resp.http.Via;\n remove resp.http.Age;\n remove resp.http.X-Purge-URL;\n remove resp.http.X-Purge-Host;\n remove resp.http.X-Surrogate-Key;\n }\n\n if (resp.http.magentomarker) {\n # Remove the magic marker\n unset resp.http.magentomarker;\n\n set resp.http.Cache-Control = \"no-store, no-cache, must-revalidate, post-check=0, pre-check=0\";\n set resp.http.Pragma = \"no-cache\";\n set resp.http.Expires = \"Mon, 31 Mar 2008 10:00:00 GMT\";\n set resp.http.Age = \"0\";\n }\n\n#FASTLY deliver\n\n return (deliver);\n}\n\nsub vcl_error {\n # workaround for possible security issue\n if (req.url ~ \"^\\s\") {\n set obj.status = 400;\n set obj.response = \"Malformed request\";\n synthetic \"\";\n return (deliver);\n }\n\n # geo ip request\n if (obj.status == 750) {\n set req.url = regsub(req.url, \"(\/fastlycdn\/esi\/getcountry\/.*)\", \"\/fastlycdn\/esi\/getcountryaction\/?country_code=\") obj.response;\n return (restart);\n }\n\n # geo ip country code\n if (obj.status == 755) {\n set obj.status = 200;\n\t synthetic obj.response;\n return(deliver);\n }\n\n # formkey request\n if (obj.status == 760) {\n set obj.status = 200;\n\t synthetic obj.response;\n return (deliver);\n }\n\n # error 200\n if (obj.status == 200) {\n return (deliver);\n }\n\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} obj.status \" \" obj.response {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} obj.status \" \" obj.response {\"<\/h1>\n <p>\"} obj.response {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} req.xid {\"<\/p>\n <hr>\n <p>Fastly CDN server<\/p>\n <\/body>\n<\/html>\n\"};\n\n#FASTLY error\n}\n\nsub design_exception {\n}\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"01e46b733e65f8d0d76f0510421224f352b94721","subject":"Shortened header name.","message":"Shortened header name.\n","repos":"killerwails\/ansible-varnish,gotofbi\/ansible-varnish,kkwoker\/ansible-varnish,killerwails\/ansible-varnish,gotofbi\/ansible-varnish,colstrom\/ansible-varnish,noqcks\/ansible-varnish,telusdigital\/ansible-varnish","old_file":"templates\/etc\/varnish\/default.vcl","new_file":"templates\/etc\/varnish\/default.vcl","new_contents":"vcl 4.0;\n\nimport directors;\nimport std;\n\n###\n# Varnish Documentation\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-built-in-subs.html\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/reference\/vcl.html\n##\n\n{% for backend in varnish_backend_hosts %}\nbackend application_{{ loop.index }} {\n .host = \"{{ backend }}\";\n .port = \"{{ varnish_backend_port }}\";\n{% if varnish_health_checks_enabled %}\n .probe = {\n .url = \"{{ varnish_health_check_url }}\";\n .interval = {{ varnish_health_check_interval }};\n .timeout = {{ varnish_health_check_timeout }};\n .window = {{ varnish_health_check_window }};\n .threshold = {{ varnish_health_check_threshold }};\n }\n{% endif %}\n}\n{% endfor %}\n\n###\n# vcl_init\n# Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n###\n# The vcl_init subroutine may terminate with calling return() with one of the following keywords:\n#\n# ok\n# Normal return, VCL continues loading.\n##\n\nsub vcl_init {\n new application = directors.round_robin();\n{% for backend in varnish_backend_hosts %}\n application.add_backend(application_{{ loop.index }});\n{% endfor %}\n}\n\n###\n# vcl_recv\n# Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use. \n# It is also used to modify the request\n###\n# The vcl_recv subroutine may terminate with calling return() on one of the following keywords:\n#\n# synth(status code, reason)\n# Return a synthetic object with the specified status code to the client and abandon the request.\n# pass\n# Switch to pass mode. Control will eventually pass to vcl_pass.\n# pipe\n# Switch to pipe mode. Control will eventually pass to vcl_pipe.\n# hash\n# Continue processing the object as a potential candidate for caching. Passes the control over to vcl_hash.\n# purge\n# Purge the object and it's variants. Control passes through vcl_hash to vcl_purge.\n#\n\nsub vcl_recv {\n set req.backend_hint = application.backend();\n\n ###\n # Avoid processing uncacheable requests\n ###\n\n if (req.http.Authorization) {\n set req.http.X-Passthrough-Reason = \"No Caching Authenticated Content\";\n return (pass);\n }\n\n{% if varnish_uri_blacklist_enabled %}\n if ((req.url ~ \"{{ varnish_uri_blacklist_regexp }}\")) {\n set req.http.X-Passthrough-Reason = \"Path in Blacklist\";\n return(pass);\n }\n{% endif %}\n\n{% if varnish_diagnostic_headers_forwarded_for %}\n ###\n # Inject X-Forwarded-For headers, but only once.\n ###\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_enabled %}\n ###\n # Cookie Sanitization\n ###\n if (req.http.Cookie) {\n set req.http.X-Cookie-Unmodified = req.http.Cookie;\n\n {% for cookie in varnish_cookie_sanitization_blacklist %}\n# set req.http.Cookie = regsuball(req.http.Cookie, \"{{ cookie }}=[^;]+(; )?\", \"\");\n {% endfor %}\n\n ### General Cleanup\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n if (req.http.Cookie ~ \"^\\s*$\") {\n set req.http.X-Cookie-Discarded = \"YES:Empty\";\n unset req.http.Cookie;\n }\n if (req.http.Cookie) {\n set req.http.X-Cookie-Sanitized = req.http.Cookie;\n }\n }\n{% endif %}\n\n{% if varnish_header_sanitization_enabled %}\n ###\n # Header Sanitization\n ###\n\n{% if varnish_header_sanitization_discard_host_port %}\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n{% endif %}\n\n{% if varnish_header_sanitization_normalize_accept_encoding %}\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n{% endif %}\n\n{% endif %}\n\n{% if varnish_uri_sanitization_enabled %}\n ###\n # URI Sanitization\n ###\n \n if (req.url ~ \"(\\?|&){{ varnish_uri_sanitization_regexp }}=\") {\n set req.url = regsuball(req.url, \"&{{ varnish_uri_sanitization_regexp }}=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?{{ varnish_uri_sanitization_regexp }}=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n{% endif %}\n\n{% if varnish_workaround_telusdotcom_browser_profile %}\n ###\n # Workaround and Diagnostics for BrowserProfile and Language\/Region Detection on TELUS.com\n ###\n\n if (req.http.Cookie ~ \"BrowserProfile\") {\n set req.http.X-BrowserProfile = regsuball(req.http.Cookie, \"(.*)BrowserProfile=([^;]*)(.*)\", \"\\2\");\n if (req.http.X-BrowserProfile ~ \"language\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.X-BrowserProfile, \"(.*)language\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n set req.http.X-Language-Found = \"YES:BrowserProfile\";\n }\n if (req.http.X-BrowserProfile ~ \"region\") {\n set req.http.X-Region = std.tolower(regsuball(regsuball(req.http.X-BrowserProfile, \"geo\\\\.\\:{(.*)\\}\", \"\"), \"(.*)region\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n set req.http.X-Region-Found = \"YES:BrowserProfile\";\n }\n if (req.http.X-BrowserProfile ~ \"geo\") {\n set req.http.X-Geolocation = regsuball(req.http.X-BrowserProfile, \"(.*)geo..:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n set req.http.X-Geolocation-Found = \"YES:BrowserProfile\";\n\n if (req.http.X-Geolocation ~ \"country\") {\n set req.http.X-Geolocation-Country = regsuball(req.http.X-BrowserProfile-Geolocation, \"(.*)country\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-Geolocation ~ \"region\") {\n set req.http.X-Geolocation-Region = regsuball(req.http.X-BrowserProfile-Geolocation, \"(.*)region\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-Geolocation ~ \"city\") {\n set req.http.X-Geolocation-City = regsuball(req.http.X-BrowserProfile-Geolocation, \"(.*)city\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-Geolocation ~ \"isp\") {\n set req.http.X-Geolocation-ISP = regsuball(req.http.X-BrowserProfile-Geolocation, \"(.*)isp\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n } else {\n set req.http.X-Geolocation-Found = \"NO\";\n }\n }\n\n if (!req.http.X-Language) {\n if (req.http.Cookie ~ \"lang=\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.Cookie, \"(.*)lang=([^;]*)(.*)\", \"\\2\"));\n set req.http.X-Language-Found = \"YES:lang\";\n } else {\n set req.http.X-Language = \"en\";\n set req.http.X-Language-Found = \"NO\";\n }\n }\n\n if (!req.http.X-Region) {\n if (req.http.Cookie ~ \"prov=\") {\n set req.http.X-Region = std.tolower(regsuball(req.http.Cookie, \"(.*)prov=([^;]*)(.*)\", \"\\2\"));\n set req.http.X-Region-Found = \"YES:prov\";\n } else {\n set req.http.X-Region = \"bc\";\n set req.http.X-Region-Found = \"NO\";\n }\n }\n\n\n if (req.url ~ \"\/(en|fr)\/\") {\n if (req.url ~ \"\/en\/\" && req.http.X-Language != \"en\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Language (Path: \/en\/) vs (Cookie: \" + req.http.X-Language + \")\";\n return(pass);\n }\n if (req.url ~ \"\/fr\/\" && req.http.X-Language != \"fr\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Language (Path: \/fr\/) vs (Cookie: \" + req.http.X-Language + \")\";\n return(pass);\n }\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Language)\";\n return(pass);\n }\n\n if (req.url ~ \"\/(ab|bc|mb|nb|nl|ns|nt|nu|on|pe|qc|sk|yt)\/\") {\n {% for province in ['ab', 'bc', 'mb', 'nb', 'nl', 'ns', 'nt', 'nu', 'on', 'pe', 'qc', 'sk', 'yt'] %}\n if (req.url ~ \"\/{{ province }}\/\" && req.http.X-Region != \"{{ province }}\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Region (Path: \/{{ province }}\/) vs (Cookie: \" + req.http.X-Region + \")\";\n return(pass);\n }\n {% endfor %}\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Province)\";\n return(pass);\n }\n\n if (req.http.Cookie) {\n if (req.http.Cookie ~ \"***REMOVED***\") {\n set req.http.X-Screen-Resolution = regsuball(req.http.Cookie, \"(.*)***REMOVED***=([^;]*)(.*)\", \"\\2\");\n }\n\n if (req.http.Cookie ~ \"***REMOVED***\") {\n set req.http.X-Customer-Type = regsuball(req.http.Cookie, \"(.*)***REMOVED***=([^;]*)(.*)\", \"\\2\");\n }\n if (req.http.Cookie ~ \"***REMOVED***\") {\n set req.http.X-Outdated-Browser = regsuball(req.http.Cookie, \"(.*)***REMOVED***=([^;]*)(.*)\", \"\\2\");\n }\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_discard_from_client %}\n set req.http.X-Cookie-Discarded = \"YES:No Reason Not To\";\n unset req.http.Cookie;\n{% endif %}\n}\n\n###\n# vcl_hit\n# Called when a cache lookup is successful.\n###\n# The vcl_hit subroutine may terminate with calling return() with one of the following keywords:\n#\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n# deliver\n# Deliver the object. Control passes to vcl_deliver.\n# synth(status code, reason)\n# Return the specified status code to the client and abandon the request.\n###\n\nsub vcl_hit {\n if (obj.ttl > 0s) {\n return (deliver);\n }\n{% if varnish_health_checks_enabled %}\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (fetch);\n }\n{% else %}\n if (obj.ttl + obj.grace > 0s) {\n return (deliver);\n }\n\n return (fetch);\n{% endif %}\n}\n\n###\n# vcl_backend_response\n# Called after the response headers has been successfully retrieved from the backend.\n###\n# The vcl_backend_response subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Possibly insert the object into the cache, then deliver it to the Control will eventually pass to vcl_deliver.\n# abandon\n# Abandon the backend request and generates an error.\n# retry\n# Retry the backend transaction. Increases the retries counter. If the number of retries is higher than max_retries Varnish emits a guru meditation error.\n###\n\nsub vcl_backend_response {\n{% if varnish_workaround_telusdotcom_browser_profile %}\n if (bereq.http.X-Language) {\n set beresp.http.X-Language = bereq.http.X-Language;\n# if (bereq.http.X-Language-Found) {\n# set beresp.http.X-Language-Found = bereq.http.X-Language-Found;\n# }\n }\n if (bereq.http.X-Region) {\n set beresp.http.X-Region = bereq.http.X-Region;\n# if (bereq.http.X-Region-Found) {\n# set beresp.http.X-Region-Found = bereq.http.X-Region-Found;\n# }\n }\n{% endif %}\n\n{% if varnish_uri_blacklist_enabled %}\n if (bereq.url ~ \"{{ varnish_uri_blacklist_regexp }}\") {\n set beresp.http.X-Cacheable = \"NO:Path in Blacklist\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n if (bereq.http.X-Passthrough-Reason) {\n{% if varnish_diagnostic_headers_passthrough_reason %}\n set beresp.http.X-Passthrough-Reason = bereq.http.X-Passthrough-Reason;\n{% endif %}\n return(deliver);\n } else {\n{% if varnish_cookie_sanitization_discard_from_server %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n }\n }\n{% else %}\n{% if varnish_cookie_sanitization_discard_from_server %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n{% endif %}\n\n{% if varnish_diagnostic_headers_enabled %}\n if (bereq.http.Cookie) {\n set beresp.http.X-Cacheable = \"NO:Cookie in Request\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO:Set-Cookie in Response\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.X-No-Cache) {\n set beresp.http.X-Cacheable = \"NO:X-No-Cache\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.ttl <= 0s) {\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n{% endif %}\n\n set beresp.grace = {{ varnish_grace_period }};\n}\n\n###\n# vcl_deliver\n# Called before a cached object is delivered to the client.\n###\n# The vcl_deliver subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Deliver the object to the client.\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n###\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n","old_contents":"vcl 4.0;\n\nimport directors;\nimport std;\n\n###\n# Varnish Documentation\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-built-in-subs.html\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/reference\/vcl.html\n##\n\n{% for backend in varnish_backend_hosts %}\nbackend application_{{ loop.index }} {\n .host = \"{{ backend }}\";\n .port = \"{{ varnish_backend_port }}\";\n{% if varnish_health_checks_enabled %}\n .probe = {\n .url = \"{{ varnish_health_check_url }}\";\n .interval = {{ varnish_health_check_interval }};\n .timeout = {{ varnish_health_check_timeout }};\n .window = {{ varnish_health_check_window }};\n .threshold = {{ varnish_health_check_threshold }};\n }\n{% endif %}\n}\n{% endfor %}\n\n###\n# vcl_init\n# Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n###\n# The vcl_init subroutine may terminate with calling return() with one of the following keywords:\n#\n# ok\n# Normal return, VCL continues loading.\n##\n\nsub vcl_init {\n new application = directors.round_robin();\n{% for backend in varnish_backend_hosts %}\n application.add_backend(application_{{ loop.index }});\n{% endfor %}\n}\n\n###\n# vcl_recv\n# Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use. \n# It is also used to modify the request\n###\n# The vcl_recv subroutine may terminate with calling return() on one of the following keywords:\n#\n# synth(status code, reason)\n# Return a synthetic object with the specified status code to the client and abandon the request.\n# pass\n# Switch to pass mode. Control will eventually pass to vcl_pass.\n# pipe\n# Switch to pipe mode. Control will eventually pass to vcl_pipe.\n# hash\n# Continue processing the object as a potential candidate for caching. Passes the control over to vcl_hash.\n# purge\n# Purge the object and it's variants. Control passes through vcl_hash to vcl_purge.\n#\n\nsub vcl_recv {\n set req.backend_hint = application.backend();\n\n ###\n # Avoid processing uncacheable requests\n ###\n\n if (req.http.Authorization) {\n set req.http.X-Passthrough-Reason = \"No Caching Authenticated Content\";\n return (pass);\n }\n\n{% if varnish_uri_blacklist_enabled %}\n if ((req.url ~ \"{{ varnish_uri_blacklist_regexp }}\")) {\n set req.http.X-Passthrough-Reason = \"Path in Blacklist\";\n return(pass);\n }\n{% endif %}\n\n{% if varnish_diagnostic_headers_forwarded_for %}\n ###\n # Inject X-Forwarded-For headers, but only once.\n ###\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_enabled %}\n ###\n # Cookie Sanitization\n ###\n if (req.http.Cookie) {\n set req.http.X-Cookie-Unmodified = req.http.Cookie;\n\n {% for cookie in varnish_cookie_sanitization_blacklist %}\n# set req.http.Cookie = regsuball(req.http.Cookie, \"{{ cookie }}=[^;]+(; )?\", \"\");\n {% endfor %}\n\n ### General Cleanup\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n if (req.http.Cookie ~ \"^\\s*$\") {\n set req.http.X-Cookie-Discarded = \"YES:Empty\";\n unset req.http.Cookie;\n }\n if (req.http.Cookie) {\n set req.http.X-Cookie-Sanitized = req.http.Cookie;\n }\n }\n{% endif %}\n\n{% if varnish_header_sanitization_enabled %}\n ###\n # Header Sanitization\n ###\n\n{% if varnish_header_sanitization_discard_host_port %}\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n{% endif %}\n\n{% if varnish_header_sanitization_normalize_accept_encoding %}\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n{% endif %}\n\n{% endif %}\n\n{% if varnish_uri_sanitization_enabled %}\n ###\n # URI Sanitization\n ###\n \n if (req.url ~ \"(\\?|&){{ varnish_uri_sanitization_regexp }}=\") {\n set req.url = regsuball(req.url, \"&{{ varnish_uri_sanitization_regexp }}=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?{{ varnish_uri_sanitization_regexp }}=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n{% endif %}\n\n{% if varnish_workaround_telusdotcom_browser_profile %}\n ###\n # Workaround and Diagnostics for BrowserProfile and Language\/Region Detection on TELUS.com\n ###\n\n if (req.http.Cookie ~ \"BrowserProfile\") {\n set req.http.X-BrowserProfile = regsuball(req.http.Cookie, \"(.*)BrowserProfile=([^;]*)(.*)\", \"\\2\");\n if (req.http.X-BrowserProfile ~ \"language\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.X-BrowserProfile, \"(.*)language\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n set req.http.X-Language-Found = \"YES:BrowserProfile\";\n }\n if (req.http.X-BrowserProfile ~ \"region\") {\n set req.http.X-Region = std.tolower(regsuball(regsuball(req.http.X-BrowserProfile, \"geo\\\\.\\:{(.*)\\}\", \"\"), \"(.*)region\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n set req.http.X-Region-Found = \"YES:BrowserProfile\";\n }\n if (req.http.X-BrowserProfile ~ \"geo\") {\n set req.http.X-BrowserProfile-Geolocation = regsuball(req.http.X-BrowserProfile, \"(.*)geo..:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n set req.http.X-BrowserProfile-Geolocation-Found = \"YES\";\n\n if (req.http.X-BrowserProfile-Geolocation ~ \"country\") {\n set req.http.X-BrowserProfile-Geolocation-Country = regsuball(req.http.X-BrowserProfile-Geolocation, \"(.*)country\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-BrowserProfile-Geolocation ~ \"region\") {\n set req.http.X-BrowserProfile-Geolocation-Region = regsuball(req.http.X-BrowserProfile-Geolocation, \"(.*)region\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-BrowserProfile-Geolocation ~ \"city\") {\n set req.http.X-BrowserProfile-Geolocation-City = regsuball(req.http.X-BrowserProfile-Geolocation, \"(.*)city\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-BrowserProfile-Geolocation ~ \"isp\") {\n set req.http.X-BrowserProfile-Geolocation-ISP = regsuball(req.http.X-BrowserProfile-Geolocation, \"(.*)isp\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n } else {\n set req.http.X-BrowserProfile-Geolocation-Found = \"NO\";\n }\n }\n\n if (!req.http.X-Language) {\n if (req.http.Cookie ~ \"lang=\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.Cookie, \"(.*)lang=([^;]*)(.*)\", \"\\2\"));\n set req.http.X-Language-Found = \"YES:lang\";\n } else {\n set req.http.X-Language = \"en\";\n set req.http.X-Language-Found = \"NO\";\n }\n }\n\n if (!req.http.X-Region) {\n if (req.http.Cookie ~ \"prov=\") {\n set req.http.X-Region = std.tolower(regsuball(req.http.Cookie, \"(.*)prov=([^;]*)(.*)\", \"\\2\"));\n set req.http.X-Region-Found = \"YES:prov\";\n } else {\n set req.http.X-Region = \"bc\";\n set req.http.X-Region-Found = \"NO\";\n }\n }\n\n\n if (req.url ~ \"\/(en|fr)\/\") {\n if (req.url ~ \"\/en\/\" && req.http.X-Language != \"en\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Language (Path: \/en\/) vs (Cookie: \" + req.http.X-Language + \")\";\n return(pass);\n }\n if (req.url ~ \"\/fr\/\" && req.http.X-Language != \"fr\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Language (Path: \/fr\/) vs (Cookie: \" + req.http.X-Language + \")\";\n return(pass);\n }\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Language)\";\n return(pass);\n }\n\n if (req.url ~ \"\/(ab|bc|mb|nb|nl|ns|nt|nu|on|pe|qc|sk|yt)\/\") {\n {% for province in ['ab', 'bc', 'mb', 'nb', 'nl', 'ns', 'nt', 'nu', 'on', 'pe', 'qc', 'sk', 'yt'] %}\n if (req.url ~ \"\/{{ province }}\/\" && req.http.X-Region != \"{{ province }}\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Region (Path: \/{{ province }}\/) vs (Cookie: \" + req.http.X-Region + \")\";\n return(pass);\n }\n {% endfor %}\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Province)\";\n return(pass);\n }\n\n if (req.http.Cookie) {\n if (req.http.Cookie ~ \"***REMOVED***\") {\n set req.http.X-Screen-Resolution = regsuball(req.http.Cookie, \"(.*)***REMOVED***=([^;]*)(.*)\", \"\\2\");\n }\n\n if (req.http.Cookie ~ \"***REMOVED***\") {\n set req.http.X-Customer-Type = regsuball(req.http.Cookie, \"(.*)***REMOVED***=([^;]*)(.*)\", \"\\2\");\n }\n if (req.http.Cookie ~ \"***REMOVED***\") {\n set req.http.X-Outdated-Browser = regsuball(req.http.Cookie, \"(.*)***REMOVED***=([^;]*)(.*)\", \"\\2\");\n }\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_discard_from_client %}\n set req.http.X-Cookie-Discarded = \"YES:No Reason Not To\";\n unset req.http.Cookie;\n{% endif %}\n}\n\n###\n# vcl_hit\n# Called when a cache lookup is successful.\n###\n# The vcl_hit subroutine may terminate with calling return() with one of the following keywords:\n#\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n# deliver\n# Deliver the object. Control passes to vcl_deliver.\n# synth(status code, reason)\n# Return the specified status code to the client and abandon the request.\n###\n\nsub vcl_hit {\n if (obj.ttl > 0s) {\n return (deliver);\n }\n{% if varnish_health_checks_enabled %}\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (fetch);\n }\n{% else %}\n if (obj.ttl + obj.grace > 0s) {\n return (deliver);\n }\n\n return (fetch);\n{% endif %}\n}\n\n###\n# vcl_backend_response\n# Called after the response headers has been successfully retrieved from the backend.\n###\n# The vcl_backend_response subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Possibly insert the object into the cache, then deliver it to the Control will eventually pass to vcl_deliver.\n# abandon\n# Abandon the backend request and generates an error.\n# retry\n# Retry the backend transaction. Increases the retries counter. If the number of retries is higher than max_retries Varnish emits a guru meditation error.\n###\n\nsub vcl_backend_response {\n{% if varnish_workaround_telusdotcom_browser_profile %}\n if (bereq.http.X-Language) {\n set beresp.http.X-Language = bereq.http.X-Language;\n# if (bereq.http.X-Language-Found) {\n# set beresp.http.X-Language-Found = bereq.http.X-Language-Found;\n# }\n }\n if (bereq.http.X-Region) {\n set beresp.http.X-Region = bereq.http.X-Region;\n# if (bereq.http.X-Region-Found) {\n# set beresp.http.X-Region-Found = bereq.http.X-Region-Found;\n# }\n }\n{% endif %}\n\n{% if varnish_uri_blacklist_enabled %}\n if (bereq.url ~ \"{{ varnish_uri_blacklist_regexp }}\") {\n set beresp.http.X-Cacheable = \"NO:Path in Blacklist\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n if (bereq.http.X-Passthrough-Reason) {\n{% if varnish_diagnostic_headers_passthrough_reason %}\n set beresp.http.X-Passthrough-Reason = bereq.http.X-Passthrough-Reason;\n{% endif %}\n return(deliver);\n } else {\n{% if varnish_cookie_sanitization_discard_from_server %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n }\n }\n{% else %}\n{% if varnish_cookie_sanitization_discard_from_server %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n{% endif %}\n\n{% if varnish_diagnostic_headers_enabled %}\n if (bereq.http.Cookie) {\n set beresp.http.X-Cacheable = \"NO:Cookie in Request\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO:Set-Cookie in Response\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.X-No-Cache) {\n set beresp.http.X-Cacheable = \"NO:X-No-Cache\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.ttl <= 0s) {\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n{% endif %}\n\n set beresp.grace = {{ varnish_grace_period }};\n}\n\n###\n# vcl_deliver\n# Called before a cached object is delivered to the client.\n###\n# The vcl_deliver subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Deliver the object to the client.\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n###\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"69ee0c52e510d5e0afad5282ac97e3736663d2a4","subject":"Remove \/server-status probe","message":"Remove \/server-status probe\n","repos":"evolution\/genesis-wordpress,evolution\/genesis-wordpress,genesis\/wordpress,evolution\/wordpress,genesis\/wordpress,genesis\/wordpress,jalevin\/wordpress,evolution\/genesis-wordpress,genesis\/wordpress,jalevin\/wordpress,genesis\/wordpress,evolution\/wordpress,evolution\/wordpress,jalevin\/wordpress,evolution\/genesis-wordpress,jalevin\/wordpress,evolution\/genesis-wordpress,evolution\/wordpress,evolution\/genesis-wordpress,genesis\/wordpress,jalevin\/wordpress,evolution\/wordpress","old_file":"provisioning\/roles\/varnish\/files\/etc-varnish\/custom.backend.vcl","new_file":"provisioning\/roles\/varnish\/files\/etc-varnish\/custom.backend.vcl","new_contents":"backend default {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n .first_byte_timeout = 300s; # How long to wait before we receive a first byte from our backend?\n .connect_timeout = 5s; # How long to wait for a backend connection?\n .between_bytes_timeout = 2s; # How long to wait between bytes received from our backend?\n}\n","old_contents":"backend default {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n .probe = {\n .url = \"\/server-status\";\n .timeout = 1s;\n .interval = 10s;\n .window = 5;\n .threshold = 2;\n }\n .first_byte_timeout = 300s; # How long to wait before we receive a first byte from our backend?\n .connect_timeout = 5s; # How long to wait for a backend connection?\n .between_bytes_timeout = 2s; # How long to wait between bytes received from our backend?\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"903439a616817b83b9911927fa15b1e0e8576728","subject":"Pass on admin, cart and checkout by default","message":"Pass on admin, cart and checkout by default\n","repos":"fastly\/fastly-magento,fastly\/fastly-magento,fastly\/fastly-magento,fastly\/fastly-magento","old_file":"app\/code\/community\/Fastly\/CDN\/etc\/vcl_snippets\/recv.vcl","new_file":"app\/code\/community\/Fastly\/CDN\/etc\/vcl_snippets\/recv.vcl","new_contents":" # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n # Sort the query arguments\n set req.url = boltsort.sort(req.url);\n\n # bypass language switcher\n if (req.url ~ \"(?i)___from_store=.*&___store=.*\") {\n set req.http.x-pass = \"1\";\n # Pass any checkout or cart urls\n } else if ( if (req.url ~ \"\/(cart|checkout)\") {\n set req.http.x-pass = \"1\";\n # Pass all admin actions\n } else if ( req.url ~ \"^\/(index\\.php\/)?admin(_.*)?\/\" ) {\n set req.http.x-pass = \"1\";\n }\n\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (req.http.cookie:FASTLY_CDN_ENV) {\n set req.http.Fastly-Cdn-Env = req.http.cookie:FASTLY_CDN_ENV;\n } else {\n unset req.http.Fastly-Cdn-Env;\n }\n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n\n if (!req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n error 403;\n }\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n\n } else {\n error 403;\n }\n\n }\n\n # disable ESI processing on Origin Shield\n if (req.http.Fastly-FF) {\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(media|js|skin)\/.*\\.(png|jpg|jpeg|gif|css|js|swf|ico|webp|svg)$\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n # formkey lookup\n if (req.url ~ \"\/fastlycdn\/getformkey\/\") {\n # check if we have a formkey cookie\n if (req.http.Cookie:FASTLY_CDN_FORMKEY) {\n set req.http.Formkey = req.http.Cookie:FASTLY_CDN_FORMKEY;\n } else {\n # create formkey\n set req.http.seed = req.http.Cookie client.ip remote.port client.geo.longitude client.geo.latitude client.geo.postal_code;\n set req.http.Formkey = regsub(digest.hash_md5(req.http.seed), \"^0x\", \"\");\n }\n error 760 req.http.Formkey;\n }\n\n # client.geo lookup\n if (req.url ~ \"fastlycdn\/esi\/getcountry\/\") {\n # check if GeoIP has been already processed by client\n if (req.http.Cookie:FASTLY_CDN_GEOIP_PROCESSED) {\n error 200 \"\";\n } else {\n # modify req.url and restart request processing\n error 750 client.geo.country_code;\n }\n }\n\n # client.geo get country code\n if (req.url ~ \"fastlycdn\/esi\/getcountrycode\/\") {\n # create and set req.http.X-Country-Code\n error 755 client.geo.country_code;\n }\n\n # check for ESI calls\n if (req.url ~ \"esi_data=\") {\n # check for valid cookie data\n if (req.http.Cookie ~ \"FASTLY_CDN-([A-Za-z0-9-_]+)=([^;]*)\") {\n set req.url = querystring.filter(req.url, \"esi_data\") + \"&esi_data=\" + re.group.2;\n }\n }\n\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking\n set req.http.Magento-Original-URL = req.url;\n set req.url = querystring.regfilter(req.url, \"^(utm_.*|gclid|gdftrk|_ga|mc_.*)\");\n","old_contents":" # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n # Sort the query arguments\n set req.url = boltsort.sort(req.url);\n\n # bypass language switcher\n if (req.url ~ \"(?i)___from_store=.*&___store=.*\") {\n set req.http.X-Pass = \"1\";\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (req.http.cookie:FASTLY_CDN_ENV) {\n set req.http.Fastly-Cdn-Env = req.http.cookie:FASTLY_CDN_ENV;\n } else {\n unset req.http.Fastly-Cdn-Env;\n }\n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n\n if (!req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n error 403;\n }\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n\n } else {\n error 403;\n }\n\n }\n\n # disable ESI processing on Origin Shield\n if (req.http.Fastly-FF) {\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(media|js|skin)\/.*\\.(png|jpg|jpeg|gif|css|js|swf|ico|webp|svg)$\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n # formkey lookup\n if (req.url ~ \"\/fastlycdn\/getformkey\/\") {\n # check if we have a formkey cookie\n if (req.http.Cookie:FASTLY_CDN_FORMKEY) {\n set req.http.Formkey = req.http.Cookie:FASTLY_CDN_FORMKEY;\n } else {\n # create formkey\n set req.http.seed = req.http.Cookie client.ip remote.port client.geo.longitude client.geo.latitude client.geo.postal_code;\n set req.http.Formkey = regsub(digest.hash_md5(req.http.seed), \"^0x\", \"\");\n }\n error 760 req.http.Formkey;\n }\n\n # client.geo lookup\n if (req.url ~ \"fastlycdn\/esi\/getcountry\/\") {\n # check if GeoIP has been already processed by client\n if (req.http.Cookie:FASTLY_CDN_GEOIP_PROCESSED) {\n error 200 \"\";\n } else {\n # modify req.url and restart request processing\n error 750 client.geo.country_code;\n }\n }\n\n # client.geo get country code\n if (req.url ~ \"fastlycdn\/esi\/getcountrycode\/\") {\n # create and set req.http.X-Country-Code\n error 755 client.geo.country_code;\n }\n\n # check for ESI calls\n if (req.url ~ \"esi_data=\") {\n # check for valid cookie data\n if (req.http.Cookie ~ \"FASTLY_CDN-([A-Za-z0-9-_]+)=([^;]*)\") {\n set req.url = querystring.filter(req.url, \"esi_data\") + \"&esi_data=\" + re.group.2;\n }\n }\n\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking\n set req.http.Magento-Original-URL = req.url;\n set req.url = querystring.regfilter(req.url, \"^(utm_.*|gclid|gdftrk|_ga|mc_.*)\");\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"2a81dfb1d1d54bcbaadb20290fb769dd3a01ec3d","subject":"Renamed the variable to VARNISH_SET_HEADER_CACHE_TAGS","message":"Renamed the variable to VARNISH_SET_HEADER_CACHE_TAGS\n","repos":"amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon","old_file":"images\/varnish-drupal\/drupal.vcl","new_file":"images\/varnish-drupal\/drupal.vcl","new_contents":"vcl 4.0;\n\nimport std;\nimport dynamic;\n\n# set backend default\nbackend default {\n .host = \"${VARNISH_BACKEND_HOST:-nginx}\";\n .port = \"${VARNISH_BACKEND_PORT:-8080}\";\n .first_byte_timeout = 35m;\n .between_bytes_timeout = 10m;\n}\n\n# Allow purging from localhost\n# @TODO allow from openshift network\nacl purge {\n \"127.0.0.1\";\n \"10.0.0.0\"\/8;\n \"172.16.0.0\"\/12;\n \"192.168.0.0\"\/16;\n}\n\nsub vcl_init {\n new www_dir = dynamic.director(\n port = \"${VARNISH_BACKEND_PORT:-8080}\",\n first_byte_timeout = 90s,\n between_bytes_timeout = 90s,\n ttl = 60s);\n}\n\n# This configuration is optimized for Drupal hosting:\n# Respond to incoming requests.\nsub vcl_recv {\n if (req.url ~ \"^\/varnish_status$\") {\n return (synth(200,\"OK\"));\n }\n # set the backend, which should be used:\n set req.backend_hint = www_dir.backend(\"${VARNISH_BACKEND_HOST:-nginx}\");\n\n # Always set the forward ip.\n if (req.restarts == 0) {\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n\n\n if (req.http.X-LAGOON-VARNISH ) {\n ## Pass all Requests which are handled via an upstream Varnish\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, \" + req.http.X-LAGOON-VARNISH;\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n } else if (req.http.Fastly-FF) {\n ## Pass all Requests which are handled via Fastly\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, fastly\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n set req.http.X-Forwarded-For = req.http.Fastly-Client-IP;\n } else if (req.http.CF-RAY) {\n ## Pass all Requests which are handled via CloudFlare\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, cloudflare\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n set req.http.X-Forwarded-For = req.http.CF-Connecting-IP;\n } else if (req.http.X-Pull) {\n ## Pass all Requests which are handled via KeyCDN\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, keycdn\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n } else {\n ## We set a header to let a Varnish Chain know that it already has been varnishcached\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}\";\n\n ## Allow to bypass based on env variable `VARNISH_BYPASS`\n set req.http.X-LAGOON-VARNISH-BYPASS = \"${VARNISH_BYPASS:-false}\";\n }\n\n # Websockets are piped\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n if (req.http.X-LAGOON-VARNISH-BYPASS == \"true\" || req.http.X-LAGOON-VARNISH-BYPASS == \"TRUE\") {\n return (pass);\n }\n\n # SA-CORE-2014-004 preventing access to \/xmlrpc.php\n if (req.url ~ \"^\/xmlrpc.php$\") {\n return (synth(701, \"Unauthorized\"));\n }\n\n # Strip out Google Analytics campaign variables. They are only needed\n # by the javascript running on the page\n # utm_source, utm_medium, utm_campaign, gclid\n if(req.url ~ \"(\\?|&)(gclid|utm_[a-z]+)=\") {\n set req.url = regsuball(req.url, \"(gclid|utm_[a-z]+)=[^\\&]+&?\", \"\");\n set req.url = regsub(req.url, \"(\\?|&)$\", \"\");\n }\n\n # Bypass a cache hit (the request is still sent to the backend)\n if (req.method == \"REFRESH\") {\n if (!client.ip ~ purge) { return (synth(405, \"Not allowed\")); }\n set req.method = \"GET\";\n set req.hash_always_miss = true;\n }\n\n # Only allow BAN requests from IP addresses in the 'purge' ACL.\n if (req.method == \"BAN\" || req.method == \"URIBAN\" || req.method == \"PURGE\") {\n # Only allow BAN from defined ACL\n if (!client.ip ~ purge) {\n return (synth(403, \"Your IP is not allowed.\"));\n }\n\n # Only allows BAN if the Host Header has the style of with \"${SERVICE_NAME:-varnish}:8080\" or \"${SERVICE_NAME:-varnish}\".\n # Such a request is only possible from within the Docker network, as a request from external goes trough the Kubernetes Router and for that needs a proper Host Header\n if (!req.http.host ~ \"^${SERVICE_NAME:-varnish}(:\\d+)?$\") {\n return (synth(403, \"Only allowed from within own network.\"));\n }\n\n if (req.method == \"BAN\") {\n # Logic for the ban, using the Cache-Tags header.\n if (req.http.Cache-Tags) {\n ban(\"obj.http.Cache-Tags ~ \" + req.http.Cache-Tags);\n # Throw a synthetic page so the request won't go to the backend.\n return (synth(200, \"Ban added.\"));\n }\n else {\n return (synth(403, \"Cache-Tags header missing.\"));\n }\n }\n\n if (req.method == \"URIBAN\" || req.method == \"PURGE\") {\n ban(\"req.url ~ \" + req.url);\n # Throw a synthetic page so the request won't go to the backend.\n return (synth(200, \"Ban added.\"));\n }\n\n }\n\n # Non-RFC2616 or CONNECT which is weird, we pipe that\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n return (pipe);\n }\n\n # We only try to cache GET and HEAD, other things are passed\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n # Any requests with Basic Auth are passed\n if (req.http.Authorization || req.http.Authenticate)\n {\n return (pass);\n }\n\n ## Pass requests which are from blackfire\n if (req.http.X-Blackfire-Query) {\n return (pass);\n }\n\n # Some URLs should never be cached\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/admin([\/?]|$).*$\" ||\n req.url ~ \"^\/info([\/?]|$).*$\" ||\n req.url ~ \"^\/flag([\/?]|$).*$\" ||\n req.url ~ \"^.*\/system\/files([\/?]|$).*$\" ||\n req.url ~ \"^\/cgi\" ||\n req.url ~ \"^\/cgi-bin\"\n ) {\n return (pass);\n }\n\n # Plupload likes to get piped\n if (req.url ~ \"^.*\/plupload-handle-uploads.*$\"\n ) {\n return (pipe);\n }\n\n # Handle compression correctly. Different browsers send different\n # \"Accept-Encoding\" headers, even though they mostly all support the same\n # compression mechanisms. By consolidating these compression headers into\n # a consistent format, we can reduce the size of the cache and get more hits.=\n # @see: http:\/\/ varnish.projects.linpro.no\/wiki\/FAQ\/Compression\n if (req.http.Accept-Encoding) {\n if (req.http.Accept-Encoding ~ \"gzip\") {\n # If the browser supports it, we'll use gzip.\n set req.http.Accept-Encoding = \"gzip\";\n }\n else if (req.http.Accept-Encoding ~ \"deflate\") {\n # Next, try deflate if it is supported.\n set req.http.Accept-Encoding = \"deflate\";\n }\n else {\n # Unknown algorithm. Remove it and send unencoded.\n unset req.http.Accept-Encoding;\n }\n }\n\n # Always cache the following file types for all users.\n if (req.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n unset req.http.Cookie;\n }\n\n # Remove all cookies that Drupal doesn't need to know about. ANY remaining\n # cookie will cause the request to pass-through to a backend. For the most part\n # we always set the NO_CACHE cookie after any POST request, disabling the\n # Varnish cache temporarily. The session cookie allows all authenticated users\n # to pass through as long as they're logged in.\n #\n # 1. Append a semi-colon to the front of the cookie string.\n # 2. Remove all spaces that appear after semi-colons.\n # 3. Match the cookies we want to keep, adding the space we removed\n # previously, back. (\\1) is first matching group in the regsuball.\n # 4. Remove all other cookies, identifying them by the fact that they have\n # no space after the preceding semi-colon.\n # 5. Remove all spaces and semi-colons from the beginning and end of the\n # cookie string.\n if (req.http.Cookie) {\n set req.http.CookieCheck = \";\" + req.http.Cookie;\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"; +\", \";\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";(${VARNISH_COOKIECHECK:-SESS[a-z0-9]+|SSESS[a-z0-9]+|NO_CACHE})=\", \"; \\1=\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";[^ ][^;]*\", \"\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"^[; ]+|[; ]+$\", \"\");\n\n set req.http.Cookie = req.http.Cookie + \";\";\n\n if (req.http.CookieCheck == \"\") {\n # If there are no remaining cookies, remove the cookie header. If there\n # aren't any cookie headers, Varnish's default behavior will be to cache\n # the page.\n\n unset req.http.CookieCheck;\n unset req.http.Cookie;\n }\n else {\n # If there is any cookies left (a session or NO_CACHE cookie), do not\n # cache the page. Pass it on to Apache directly.\n unset req.http.CookieCheck;\n return (pass);\n }\n }\n\n # Cacheable, lookup in cache.\n return (hash);\n}\n\nsub vcl_pipe {\n # Support for Websockets\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n set bereq.http.connection = req.http.connection;\n }\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n # normal hit\n return (deliver);\n }\n # We have no fresh fish. Lets look at the stale ones.\n if (std.healthy(req.backend_hint)) {\n # Backend is healthy. If the object is not older then 30secs, deliver it to the client\n # and automatically create a separate backend request to warm the cache for this request.\n if (obj.ttl + 30s > 0s) {\n set req.http.grace = \"normal(limited)\";\n return (deliver);\n } else {\n # No candidate for grace. Fetch a fresh object.\n return(miss);\n }\n } else {\n # backend is sick - use full grace\n if (obj.ttl + obj.grace > 0s) {\n set req.http.grace = \"full\";\n return (deliver);\n } else {\n # no graced object.\n return (miss);\n }\n }\n}\n\nsub vcl_backend_response {\n # Allow items to be stale if needed.\n set beresp.grace = 6h;\n\n # Set ban-lurker friendly custom headers.\n set beresp.http.X-Url = bereq.url;\n set beresp.http.X-Host = bereq.http.host;\n\n # If the backend sends a X-LAGOON-VARNISH-BACKEND-BYPASS header we directly deliver\n if(beresp.http.X-LAGOON-VARNISH-BACKEND-BYPASS == \"TRUE\") {\n return (deliver);\n }\n\n # Cache 404 and 403 for 10 seconds\n if(beresp.status == 404 || beresp.status == 403) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n # Don't allow static files to set cookies.\n if (bereq.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n # beresp == Back-end response from the web server.\n unset beresp.http.set-cookie;\n unset beresp.http.Cache-Control;\n\n # If an asset would come back with statuscode 500 we only cache it for 10 seconds instead of the usual static file cache\n if (beresp.status == 500) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n set beresp.ttl = ${VARNISH_ASSETS_TTL:-2628001}s;\n set beresp.http.Cache-Control = \"public, max-age=${VARNISH_ASSETS_TTL:-2628001}\";\n set beresp.http.Expires = \"\" + (now + beresp.ttl);\n }\n # Disable buffering only for BigPipe responses\n if (beresp.http.Surrogate-Control ~ \"BigPipe\/1.0\") {\n set beresp.do_stream = true;\n set beresp.ttl = 0s;\n }\n\n return (deliver);\n}\n\n# Set a header to track a cache HIT\/MISS.\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Varnish-Cache = \"HIT\";\n }\n else {\n set resp.http.X-Varnish-Cache = \"MISS\";\n }\n\n # Remove ban-lurker friendly custom headers when delivering to client.\n unset resp.http.X-Url;\n unset resp.http.X-Host;\n\n # unset Cache-Tags Header by default, can be disabled with VARNISH_SET_HEADER_CACHE_TAGS=true\n if (!${VARNISH_SET_HEADER_CACHE_TAGS:-false}) {\n unset resp.http.Cache-Tags;\n }\n\n unset resp.http.X-Generator;\n unset resp.http.Server;\n # Inject information about grace\n if (req.http.grace) {\n set resp.http.X-Varnish-Grace = req.http.grace;\n }\n set resp.http.X-LAGOON = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}>\" + resp.http.X-LAGOON;\n return (deliver);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n if (req.http.X-Forwarded-Proto) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n if (req.http.HTTPS) {\n hash_data(req.http.HTTPS);\n }\n return (lookup);\n}\n\nsub vcl_synth {\n if (resp.status == 701) {\n set resp.status = 401;\n set resp.http.Content-Type = \"text\/plain; charset=utf-8\";\n synthetic({\"XMLRPC Interface is blocked due to SA-CORE-2014-004 - mail support@amazee.io if you need it.\"});\n return (deliver);\n }\n if (resp.status == 700) {\n # Set a status the client will understand\n set resp.status = 200;\n # Create our synthetic response\n synthetic(\"\");\n return(deliver);\n}\n return (deliver);\n}\n\nsub vcl_backend_error {\n # Restart the request, when we have a backend server error, to try another backend.\n # Restart max twice.\n if (bereq.retries < 2) {\n return(retry);\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<head>\n <title>Server Error<\/title>\n <style type=\"text\/css\">\n body {\n font-family: helvetica, arial, sans-serif;\n }\n img {\n margin-top: 50px;\n }\n p {\n width: 6 00px;\n margin-top: 10px\n }\n div {\n background: #ccc;\n width: 600px;\n margin: auto;\n padding: 50px;\n }\n span {\n color: #ccc\n }\n <\/style>\n<\/head>\n<body>\n <div>\n <h1>We are sorry...<\/h1>\n <p>We encountered a server-side error. This means that the problem is not with your computer or Internet connection, but rather with the website's server.<\/p>\n <p>We are currently working on solving this problem and apologise for the inconvenience.<\/p>\n <span>\n <strong>Technical Information<\/strong><br \/>\n Error \"} + beresp.status + \" \" + beresp.reason + {\"<br \/>\n XID: \"} + bereq.xid + {\"<br \/>\n <\/span>\n <\/div>\n<\/body>\n<\/html>\n\n\"} );\n return (deliver);\n}\n","old_contents":"vcl 4.0;\n\nimport std;\nimport dynamic;\n\n# set backend default\nbackend default {\n .host = \"${VARNISH_BACKEND_HOST:-nginx}\";\n .port = \"${VARNISH_BACKEND_PORT:-8080}\";\n .first_byte_timeout = 35m;\n .between_bytes_timeout = 10m;\n}\n\n# Allow purging from localhost\n# @TODO allow from openshift network\nacl purge {\n \"127.0.0.1\";\n \"10.0.0.0\"\/8;\n \"172.16.0.0\"\/12;\n \"192.168.0.0\"\/16;\n}\n\nsub vcl_init {\n new www_dir = dynamic.director(\n port = \"${VARNISH_BACKEND_PORT:-8080}\",\n first_byte_timeout = 90s,\n between_bytes_timeout = 90s,\n ttl = 60s);\n}\n\n# This configuration is optimized for Drupal hosting:\n# Respond to incoming requests.\nsub vcl_recv {\n if (req.url ~ \"^\/varnish_status$\") {\n return (synth(200,\"OK\"));\n }\n # set the backend, which should be used:\n set req.backend_hint = www_dir.backend(\"${VARNISH_BACKEND_HOST:-nginx}\");\n\n # Always set the forward ip.\n if (req.restarts == 0) {\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n\n\n if (req.http.X-LAGOON-VARNISH ) {\n ## Pass all Requests which are handled via an upstream Varnish\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, \" + req.http.X-LAGOON-VARNISH;\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n } else if (req.http.Fastly-FF) {\n ## Pass all Requests which are handled via Fastly\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, fastly\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n set req.http.X-Forwarded-For = req.http.Fastly-Client-IP;\n } else if (req.http.CF-RAY) {\n ## Pass all Requests which are handled via CloudFlare\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, cloudflare\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n set req.http.X-Forwarded-For = req.http.CF-Connecting-IP;\n } else if (req.http.X-Pull) {\n ## Pass all Requests which are handled via KeyCDN\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, keycdn\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n } else {\n ## We set a header to let a Varnish Chain know that it already has been varnishcached\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}\";\n\n ## Allow to bypass based on env variable `VARNISH_BYPASS`\n set req.http.X-LAGOON-VARNISH-BYPASS = \"${VARNISH_BYPASS:-false}\";\n }\n\n # Websockets are piped\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n if (req.http.X-LAGOON-VARNISH-BYPASS == \"true\" || req.http.X-LAGOON-VARNISH-BYPASS == \"TRUE\") {\n return (pass);\n }\n\n # SA-CORE-2014-004 preventing access to \/xmlrpc.php\n if (req.url ~ \"^\/xmlrpc.php$\") {\n return (synth(701, \"Unauthorized\"));\n }\n\n # Strip out Google Analytics campaign variables. They are only needed\n # by the javascript running on the page\n # utm_source, utm_medium, utm_campaign, gclid\n if(req.url ~ \"(\\?|&)(gclid|utm_[a-z]+)=\") {\n set req.url = regsuball(req.url, \"(gclid|utm_[a-z]+)=[^\\&]+&?\", \"\");\n set req.url = regsub(req.url, \"(\\?|&)$\", \"\");\n }\n\n # Bypass a cache hit (the request is still sent to the backend)\n if (req.method == \"REFRESH\") {\n if (!client.ip ~ purge) { return (synth(405, \"Not allowed\")); }\n set req.method = \"GET\";\n set req.hash_always_miss = true;\n }\n\n # Only allow BAN requests from IP addresses in the 'purge' ACL.\n if (req.method == \"BAN\" || req.method == \"URIBAN\" || req.method == \"PURGE\") {\n # Only allow BAN from defined ACL\n if (!client.ip ~ purge) {\n return (synth(403, \"Your IP is not allowed.\"));\n }\n\n # Only allows BAN if the Host Header has the style of with \"${SERVICE_NAME:-varnish}:8080\" or \"${SERVICE_NAME:-varnish}\".\n # Such a request is only possible from within the Docker network, as a request from external goes trough the Kubernetes Router and for that needs a proper Host Header\n if (!req.http.host ~ \"^${SERVICE_NAME:-varnish}(:\\d+)?$\") {\n return (synth(403, \"Only allowed from within own network.\"));\n }\n\n if (req.method == \"BAN\") {\n # Logic for the ban, using the Cache-Tags header.\n if (req.http.Cache-Tags) {\n ban(\"obj.http.Cache-Tags ~ \" + req.http.Cache-Tags);\n # Throw a synthetic page so the request won't go to the backend.\n return (synth(200, \"Ban added.\"));\n }\n else {\n return (synth(403, \"Cache-Tags header missing.\"));\n }\n }\n\n if (req.method == \"URIBAN\" || req.method == \"PURGE\") {\n ban(\"req.url ~ \" + req.url);\n # Throw a synthetic page so the request won't go to the backend.\n return (synth(200, \"Ban added.\"));\n }\n\n }\n\n # Non-RFC2616 or CONNECT which is weird, we pipe that\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n return (pipe);\n }\n\n # We only try to cache GET and HEAD, other things are passed\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n # Any requests with Basic Auth are passed\n if (req.http.Authorization || req.http.Authenticate)\n {\n return (pass);\n }\n\n ## Pass requests which are from blackfire\n if (req.http.X-Blackfire-Query) {\n return (pass);\n }\n\n # Some URLs should never be cached\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/admin([\/?]|$).*$\" ||\n req.url ~ \"^\/info([\/?]|$).*$\" ||\n req.url ~ \"^\/flag([\/?]|$).*$\" ||\n req.url ~ \"^.*\/system\/files([\/?]|$).*$\" ||\n req.url ~ \"^\/cgi\" ||\n req.url ~ \"^\/cgi-bin\"\n ) {\n return (pass);\n }\n\n # Plupload likes to get piped\n if (req.url ~ \"^.*\/plupload-handle-uploads.*$\"\n ) {\n return (pipe);\n }\n\n # Handle compression correctly. Different browsers send different\n # \"Accept-Encoding\" headers, even though they mostly all support the same\n # compression mechanisms. By consolidating these compression headers into\n # a consistent format, we can reduce the size of the cache and get more hits.=\n # @see: http:\/\/ varnish.projects.linpro.no\/wiki\/FAQ\/Compression\n if (req.http.Accept-Encoding) {\n if (req.http.Accept-Encoding ~ \"gzip\") {\n # If the browser supports it, we'll use gzip.\n set req.http.Accept-Encoding = \"gzip\";\n }\n else if (req.http.Accept-Encoding ~ \"deflate\") {\n # Next, try deflate if it is supported.\n set req.http.Accept-Encoding = \"deflate\";\n }\n else {\n # Unknown algorithm. Remove it and send unencoded.\n unset req.http.Accept-Encoding;\n }\n }\n\n # Always cache the following file types for all users.\n if (req.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n unset req.http.Cookie;\n }\n\n # Remove all cookies that Drupal doesn't need to know about. ANY remaining\n # cookie will cause the request to pass-through to a backend. For the most part\n # we always set the NO_CACHE cookie after any POST request, disabling the\n # Varnish cache temporarily. The session cookie allows all authenticated users\n # to pass through as long as they're logged in.\n #\n # 1. Append a semi-colon to the front of the cookie string.\n # 2. Remove all spaces that appear after semi-colons.\n # 3. Match the cookies we want to keep, adding the space we removed\n # previously, back. (\\1) is first matching group in the regsuball.\n # 4. Remove all other cookies, identifying them by the fact that they have\n # no space after the preceding semi-colon.\n # 5. Remove all spaces and semi-colons from the beginning and end of the\n # cookie string.\n if (req.http.Cookie) {\n set req.http.CookieCheck = \";\" + req.http.Cookie;\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"; +\", \";\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";(${VARNISH_COOKIECHECK:-SESS[a-z0-9]+|SSESS[a-z0-9]+|NO_CACHE})=\", \"; \\1=\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";[^ ][^;]*\", \"\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"^[; ]+|[; ]+$\", \"\");\n\n set req.http.Cookie = req.http.Cookie + \";\";\n\n if (req.http.CookieCheck == \"\") {\n # If there are no remaining cookies, remove the cookie header. If there\n # aren't any cookie headers, Varnish's default behavior will be to cache\n # the page.\n\n unset req.http.CookieCheck;\n unset req.http.Cookie;\n }\n else {\n # If there is any cookies left (a session or NO_CACHE cookie), do not\n # cache the page. Pass it on to Apache directly.\n unset req.http.CookieCheck;\n return (pass);\n }\n }\n\n # Cacheable, lookup in cache.\n return (hash);\n}\n\nsub vcl_pipe {\n # Support for Websockets\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n set bereq.http.connection = req.http.connection;\n }\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n # normal hit\n return (deliver);\n }\n # We have no fresh fish. Lets look at the stale ones.\n if (std.healthy(req.backend_hint)) {\n # Backend is healthy. If the object is not older then 30secs, deliver it to the client\n # and automatically create a separate backend request to warm the cache for this request.\n if (obj.ttl + 30s > 0s) {\n set req.http.grace = \"normal(limited)\";\n return (deliver);\n } else {\n # No candidate for grace. Fetch a fresh object.\n return(miss);\n }\n } else {\n # backend is sick - use full grace\n if (obj.ttl + obj.grace > 0s) {\n set req.http.grace = \"full\";\n return (deliver);\n } else {\n # no graced object.\n return (miss);\n }\n }\n}\n\nsub vcl_backend_response {\n # Allow items to be stale if needed.\n set beresp.grace = 6h;\n\n # Set ban-lurker friendly custom headers.\n set beresp.http.X-Url = bereq.url;\n set beresp.http.X-Host = bereq.http.host;\n\n # If the backend sends a X-LAGOON-VARNISH-BACKEND-BYPASS header we directly deliver\n if(beresp.http.X-LAGOON-VARNISH-BACKEND-BYPASS == \"TRUE\") {\n return (deliver);\n }\n\n # Cache 404 and 403 for 10 seconds\n if(beresp.status == 404 || beresp.status == 403) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n # Don't allow static files to set cookies.\n if (bereq.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n # beresp == Back-end response from the web server.\n unset beresp.http.set-cookie;\n unset beresp.http.Cache-Control;\n\n # If an asset would come back with statuscode 500 we only cache it for 10 seconds instead of the usual static file cache\n if (beresp.status == 500) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n set beresp.ttl = ${VARNISH_ASSETS_TTL:-2628001}s;\n set beresp.http.Cache-Control = \"public, max-age=${VARNISH_ASSETS_TTL:-2628001}\";\n set beresp.http.Expires = \"\" + (now + beresp.ttl);\n }\n # Disable buffering only for BigPipe responses\n if (beresp.http.Surrogate-Control ~ \"BigPipe\/1.0\") {\n set beresp.do_stream = true;\n set beresp.ttl = 0s;\n }\n\n return (deliver);\n}\n\n# Set a header to track a cache HIT\/MISS.\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Varnish-Cache = \"HIT\";\n }\n else {\n set resp.http.X-Varnish-Cache = \"MISS\";\n }\n\n # Remove ban-lurker friendly custom headers when delivering to client.\n unset resp.http.X-Url;\n unset resp.http.X-Host;\n\n # unset Cache-Tags Header by default, can be disabled with VARNISH_UNSET_HEADER_CACHE_TAGS=true\n if (!${VARNISH_UNSET_HEADER_CACHE_TAGS:-false}) {\n unset resp.http.Cache-Tags;\n }\n\n unset resp.http.X-Generator;\n unset resp.http.Server;\n # Inject information about grace\n if (req.http.grace) {\n set resp.http.X-Varnish-Grace = req.http.grace;\n }\n set resp.http.X-LAGOON = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}>\" + resp.http.X-LAGOON;\n return (deliver);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n if (req.http.X-Forwarded-Proto) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n if (req.http.HTTPS) {\n hash_data(req.http.HTTPS);\n }\n return (lookup);\n}\n\nsub vcl_synth {\n if (resp.status == 701) {\n set resp.status = 401;\n set resp.http.Content-Type = \"text\/plain; charset=utf-8\";\n synthetic({\"XMLRPC Interface is blocked due to SA-CORE-2014-004 - mail support@amazee.io if you need it.\"});\n return (deliver);\n }\n if (resp.status == 700) {\n # Set a status the client will understand\n set resp.status = 200;\n # Create our synthetic response\n synthetic(\"\");\n return(deliver);\n}\n return (deliver);\n}\n\nsub vcl_backend_error {\n # Restart the request, when we have a backend server error, to try another backend.\n # Restart max twice.\n if (bereq.retries < 2) {\n return(retry);\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<head>\n <title>Server Error<\/title>\n <style type=\"text\/css\">\n body {\n font-family: helvetica, arial, sans-serif;\n }\n img {\n margin-top: 50px;\n }\n p {\n width: 6 00px;\n margin-top: 10px\n }\n div {\n background: #ccc;\n width: 600px;\n margin: auto;\n padding: 50px;\n }\n span {\n color: #ccc\n }\n <\/style>\n<\/head>\n<body>\n <div>\n <h1>We are sorry...<\/h1>\n <p>We encountered a server-side error. This means that the problem is not with your computer or Internet connection, but rather with the website's server.<\/p>\n <p>We are currently working on solving this problem and apologise for the inconvenience.<\/p>\n <span>\n <strong>Technical Information<\/strong><br \/>\n Error \"} + beresp.status + \" \" + beresp.reason + {\"<br \/>\n XID: \"} + bereq.xid + {\"<br \/>\n <\/span>\n <\/div>\n<\/body>\n<\/html>\n\n\"} );\n return (deliver);\n}\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"e56f18330d618b62f86458e9fd20de6ff30a8956","subject":"Cleaned up regexp, refined a bit.","message":"Cleaned up regexp, refined a bit.\n","repos":"telusdigital\/ansible-varnish,gotofbi\/ansible-varnish,killerwails\/ansible-varnish,colstrom\/ansible-varnish,noqcks\/ansible-varnish,kkwoker\/ansible-varnish,gotofbi\/ansible-varnish,killerwails\/ansible-varnish","old_file":"templates\/etc\/varnish\/default.vcl","new_file":"templates\/etc\/varnish\/default.vcl","new_contents":"vcl 4.0;\n\nimport directors;\nimport std;\n\n###\n# Varnish Documentation\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-built-in-subs.html\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/reference\/vcl.html\n##\n\n{% for backend in varnish_backend_hosts %}\nbackend application_{{ loop.index }} {\n .host = \"{{ backend }}\";\n .port = \"{{ varnish_backend_port }}\";\n{% if varnish_health_checks_enabled %}\n .probe = {\n .url = \"{{ varnish_health_check_url }}\";\n .interval = {{ varnish_health_check_interval }};\n .timeout = {{ varnish_health_check_timeout }};\n .window = {{ varnish_health_check_window }};\n .threshold = {{ varnish_health_check_threshold }};\n }\n{% endif %}\n}\n{% endfor %}\n\n###\n# vcl_init\n# Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n###\n# The vcl_init subroutine may terminate with calling return() with one of the following keywords:\n#\n# ok\n# Normal return, VCL continues loading.\n##\n\nsub vcl_init {\n new application = directors.round_robin();\n{% for backend in varnish_backend_hosts %}\n application.add_backend(application_{{ loop.index }});\n{% endfor %}\n}\n\n###\n# vcl_recv\n# Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use. \n# It is also used to modify the request\n###\n# The vcl_recv subroutine may terminate with calling return() on one of the following keywords:\n#\n# synth(status code, reason)\n# Return a synthetic object with the specified status code to the client and abandon the request.\n# pass\n# Switch to pass mode. Control will eventually pass to vcl_pass.\n# pipe\n# Switch to pipe mode. Control will eventually pass to vcl_pipe.\n# hash\n# Continue processing the object as a potential candidate for caching. Passes the control over to vcl_hash.\n# purge\n# Purge the object and it's variants. Control passes through vcl_hash to vcl_purge.\n#\n\nsub vcl_recv {\n set req.backend_hint = application.backend();\n\n ###\n # Avoid processing uncacheable requests\n ###\n\n if (req.http.Authorization) {\n return (pass);\n }\n\n ###\n # Inject X-Forwarded-For headers, but only once.\n ###\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n{% if varnish_header_sanitization_enabled %}\n ###\n # Header Sanitization\n ###\n\n{% if varnish_discards_port_from_host_header %}\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n{% endif %}\n\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_enabled %}\n ###\n # Cookie Sanitization\n ###\n\n ### Google Analytics\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n\n ### Quantcast\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n \n ### AddThis\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n\n ### General Cleanup\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n{% endif %}\n\n{% if varnish_uri_sanitization_enabled %}\n ###\n # URI Sanitization\n ###\n \n if (req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=\") {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n{% endif %}\n\n{% if varnish_workaround_telusdotcom_browser_profile %}\n ###\n # Workaround for BrowserProfile and Language\/Region Detection on TELUS.com\n ###\n\n if (req.http.Cookie ~ \"BrowserProfile\") {\n set req.http.X-Language = regsuball(req.http.Cookie, \"language..:\\\\.([^\\\\]*)\", \"\\1\");\n set req.http.X-Province = regsuball(req.http.Cookie, \"region..:\\\\.([^\\\\]*)\", \"\\1\");\n } else {\n if (req.http.Cookie ~ \"lang=\") {\n set req.http.X-Language = regsuball(req.http.Cookie, \"lang=([^;]*)\", \"\\1\");\n } else {\n set req.http.X-Language = \"en\";\n }\n\n if (req.http.Cookie ~ \"prov=\") {\n set req.http.X-Province = regsuball(req.http.Cookie, \"prov=([^;]*)\", \"\\1\");\n } else {\n set req.http.X-Province = \"BC\";\n }\n }\n\n if (req.url ~ \"\/(en|fr)\/\") {\n if (req.url ~ \"\/en\/\" && req.http.X-Language != \"en\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Language)\";\n return(pass);\n }\n if (req.url ~ \"\/fr\/\" && req.http.X-Language != \"fr\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Language)\";\n return(pass);\n }\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Language)\";\n return(pass);\n }\n\n if (req.url ~ \"\/(ab|bc|mb|nb|nl|ns|nt|nu|on|pe|qc|sk|yt)\/\") {\n {% for province in ['ab', 'bc', 'mb', 'nb', 'nl', 'ns', 'nt', 'nu', 'on', 'pe', 'qc', 'sk', 'yt'] %}\n if (req.url ~ \"{{ province }}\" && req.http.X-Province != \"{{ province }}\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Province)\";\n return(pass);\n }\n {% endfor %}\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Province)\";\n return(pass);\n }\n{% endif %}\n\n{% if varnish_blacklist_enabled %}\n if ((req.url ~ \"{{ varnish_blacklist_regexp }}\")) {\n set req.http.X-Passthrough-Reason = \"Path in Blacklist\";\n return(pass);\n } else {\n{% if varnish_discards_client_cookies %}\n unset req.http.Cookie;\n{% endif %}\n }\n{% endif %}\n\n}\n\n###\n# vcl_hit\n# Called when a cache lookup is successful.\n###\n# The vcl_hit subroutine may terminate with calling return() with one of the following keywords:\n#\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n# deliver\n# Deliver the object. Control passes to vcl_deliver.\n# synth(status code, reason)\n# Return the specified status code to the client and abandon the request.\n###\n\nsub vcl_hit {\n if (obj.ttl > 0s) {\n return (deliver);\n }\n{% if varnish_health_checks_enabled %}\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (fetch);\n }\n{% else %}\n if (obj.ttl + obj.grace > 0s) {\n return (deliver);\n }\n\n return (fetch);\n{% endif %}\n}\n\n###\n# vcl_backend_response\n# Called after the response headers has been successfully retrieved from the backend.\n###\n# The vcl_backend_response subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Possibly insert the object into the cache, then deliver it to the Control will eventually pass to vcl_deliver.\n# abandon\n# Abandon the backend request and generates an error.\n# retry\n# Retry the backend transaction. Increases the retries counter. If the number of retries is higher than max_retries Varnish emits a guru meditation error.\n###\n\nsub vcl_backend_response {\n{% if varnish_workaround_telusdotcom_browser_profile %}\n if (bereq.http.X-Language) {\n set beresp.http.X-Language = bereq.http.X-Language;\n }\n if (bereq.http.X-Province) {\n set beresp.http.X-Province = bereq.http.X-Province;\n }\n{% endif %}\n\n{% if varnish_blacklist_enabled %}\n if (bereq.url ~ \"{{ varnish_blacklist_regexp }}\") {\n set beresp.http.X-Cacheable = \"NO:Path in Blacklist\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n if (bereq.http.X-Passthrough-Reason) {\n set beresp.http.X-Passthrough-Reason = bereq.http.X-Passthrough-Reason;\n return(deliver);\n } else {\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n }\n }\n{% else %}\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n{% endif %}\n\n{% if varnish_cache_diagnostics_enabled %}\n if (bereq.http.Cookie) {\n set beresp.http.X-Cacheable = \"NO:Cookie in Request\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO:Set-Cookie in Response\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.X-No-Cache) {\n set beresp.http.X-Cacheable = \"NO:X-No-Cache\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.ttl <= 0s) {\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n{% endif %}\n\n set beresp.grace = {{ varnish_grace_period }};\n}\n\n###\n# vcl_deliver\n# Called before a cached object is delivered to the client.\n###\n# The vcl_deliver subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Deliver the object to the client.\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n###\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n","old_contents":"vcl 4.0;\n\nimport directors;\nimport std;\n\n###\n# Varnish Documentation\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-built-in-subs.html\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/reference\/vcl.html\n##\n\n{% for backend in varnish_backend_hosts %}\nbackend application_{{ loop.index }} {\n .host = \"{{ backend }}\";\n .port = \"{{ varnish_backend_port }}\";\n{% if varnish_health_checks_enabled %}\n .probe = {\n .url = \"{{ varnish_health_check_url }}\";\n .interval = {{ varnish_health_check_interval }};\n .timeout = {{ varnish_health_check_timeout }};\n .window = {{ varnish_health_check_window }};\n .threshold = {{ varnish_health_check_threshold }};\n }\n{% endif %}\n}\n{% endfor %}\n\n###\n# vcl_init\n# Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n###\n# The vcl_init subroutine may terminate with calling return() with one of the following keywords:\n#\n# ok\n# Normal return, VCL continues loading.\n##\n\nsub vcl_init {\n new application = directors.round_robin();\n{% for backend in varnish_backend_hosts %}\n application.add_backend(application_{{ loop.index }});\n{% endfor %}\n}\n\n###\n# vcl_recv\n# Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use. \n# It is also used to modify the request\n###\n# The vcl_recv subroutine may terminate with calling return() on one of the following keywords:\n#\n# synth(status code, reason)\n# Return a synthetic object with the specified status code to the client and abandon the request.\n# pass\n# Switch to pass mode. Control will eventually pass to vcl_pass.\n# pipe\n# Switch to pipe mode. Control will eventually pass to vcl_pipe.\n# hash\n# Continue processing the object as a potential candidate for caching. Passes the control over to vcl_hash.\n# purge\n# Purge the object and it's variants. Control passes through vcl_hash to vcl_purge.\n#\n\nsub vcl_recv {\n set req.backend_hint = application.backend();\n\n ###\n # Avoid processing uncacheable requests\n ###\n\n if (req.http.Authorization) {\n return (pass);\n }\n\n ###\n # Inject X-Forwarded-For headers, but only once.\n ###\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n{% if varnish_header_sanitization_enabled %}\n ###\n # Header Sanitization\n ###\n\n{% if varnish_discards_port_from_host_header %}\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n{% endif %}\n\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_enabled %}\n ###\n # Cookie Sanitization\n ###\n\n ### Google Analytics\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n\n ### Quantcast\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n \n ### AddThis\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n\n ### General Cleanup\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n{% endif %}\n\n{% if varnish_uri_sanitization_enabled %}\n ###\n # URI Sanitization\n ###\n \n if (req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=\") {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n{% endif %}\n\n{% if varnish_workaround_telusdotcom_browser_profile %}\n ###\n # Workaround for BrowserProfile and Language\/Region Detection on TELUS.com\n ###\n\n if (req.http.Cookie ~ \"BrowserProfile\") {\n set req.http.X-Language = regsuball(req.http.Cookie, \"(language..:\\\\.)(.*)\\\\.,\", \"\\2\");\n set req.http.X-Province = regsuball(req.http.Cookie, \"(region..:\\\\.)(.*)\\\\.,\", \"\\2\");\n } else {\n if (req.http.Cookie ~ \"lang=\") {\n set req.http.X-Language = regsuball(req.http.Cookie, \"lang=(.*);\", \"\\1\");\n } else {\n set req.http.X-Language = \"en\";\n }\n\n if (req.http.Cookie ~ \"prov=\") {\n set req.http.X-Province = regsuball(req.http.Cookie, \"prov=(.*);\", \"\\1\");\n } else {\n set req.http.X-Province = \"BC\";\n }\n }\n\n if (req.url ~ \"\/(en|fr)\/\") {\n if (req.url ~ \"\/en\/\" && req.http.X-Language != \"en\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Language)\";\n return(pass);\n }\n if (req.url ~ \"\/fr\/\" && req.http.X-Language != \"fr\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Language)\";\n return(pass);\n }\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Language)\";\n return(pass);\n }\n\n if (req.url ~ \"\/(ab|bc|mb|nb|nl|ns|nt|nu|on|pe|qc|sk|yt)\/\") {\n {% for province in ['ab', 'bc', 'mb', 'nb', 'nl', 'ns', 'nt', 'nu', 'on', 'pe', 'qc', 'sk', 'yt'] %}\n if (req.url ~ \"{{ province }}\" && req.http.X-Province != \"{{ province }}\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Province)\";\n return(pass);\n }\n {% endfor %}\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Province)\";\n return(pass);\n }\n{% endif %}\n\n{% if varnish_blacklist_enabled %}\n if ((req.url ~ \"{{ varnish_blacklist_regexp }}\")) {\n set req.http.X-Passthrough-Reason = \"Path in Blacklist\";\n return(pass);\n } else {\n{% if varnish_discards_client_cookies %}\n unset req.http.Cookie;\n{% endif %}\n }\n{% endif %}\n\n}\n\n###\n# vcl_hit\n# Called when a cache lookup is successful.\n###\n# The vcl_hit subroutine may terminate with calling return() with one of the following keywords:\n#\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n# deliver\n# Deliver the object. Control passes to vcl_deliver.\n# synth(status code, reason)\n# Return the specified status code to the client and abandon the request.\n###\n\nsub vcl_hit {\n if (obj.ttl > 0s) {\n return (deliver);\n }\n{% if varnish_health_checks_enabled %}\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (fetch);\n }\n{% else %}\n if (obj.ttl + obj.grace > 0s) {\n return (deliver);\n }\n\n return (fetch);\n{% endif %}\n}\n\n###\n# vcl_backend_response\n# Called after the response headers has been successfully retrieved from the backend.\n###\n# The vcl_backend_response subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Possibly insert the object into the cache, then deliver it to the Control will eventually pass to vcl_deliver.\n# abandon\n# Abandon the backend request and generates an error.\n# retry\n# Retry the backend transaction. Increases the retries counter. If the number of retries is higher than max_retries Varnish emits a guru meditation error.\n###\n\nsub vcl_backend_response {\n{% if varnish_workaround_telusdotcom_browser_profile %}\n if (bereq.http.X-Language) {\n set beresp.http.X-Language = bereq.http.X-Language;\n }\n if (bereq.http.X-Province) {\n set beresp.http.X-Province = bereq.http.X-Province;\n }\n{% endif %}\n\n{% if varnish_blacklist_enabled %}\n if (bereq.url ~ \"{{ varnish_blacklist_regexp }}\") {\n set beresp.http.X-Cacheable = \"NO:Path in Blacklist\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n if (bereq.http.X-Passthrough-Reason) {\n set beresp.http.X-Passthrough-Reason = bereq.http.X-Passthrough-Reason;\n return(deliver);\n } else {\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n }\n }\n{% else %}\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n{% endif %}\n\n{% if varnish_cache_diagnostics_enabled %}\n if (bereq.http.Cookie) {\n set beresp.http.X-Cacheable = \"NO:Cookie in Request\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO:Set-Cookie in Response\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.X-No-Cache) {\n set beresp.http.X-Cacheable = \"NO:X-No-Cache\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.ttl <= 0s) {\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n{% endif %}\n\n set beresp.grace = {{ varnish_grace_period }};\n}\n\n###\n# vcl_deliver\n# Called before a cached object is delivered to the client.\n###\n# The vcl_deliver subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Deliver the object to the client.\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n###\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"1cb68eb8cf37516d35b81baabcc2464796a8dc48","subject":"Serve files directly from S3","message":"Serve files directly from S3\n","repos":"pypa\/warehouse,dstufft\/warehouse,pypa\/warehouse,karan\/warehouse,karan\/warehouse,wlonk\/warehouse,karan\/warehouse,alex\/warehouse,alex\/warehouse,pypa\/warehouse,pypa\/warehouse,alex\/warehouse,dstufft\/warehouse,wlonk\/warehouse,karan\/warehouse,wlonk\/warehouse,dstufft\/warehouse,alex\/warehouse,dstufft\/warehouse,karan\/warehouse,alex\/warehouse","old_file":"vcl\/main.vcl","new_file":"vcl\/main.vcl","new_contents":"\nsub vcl_recv {\n\n # Some (Older) clients will send a hash fragment as part of the URL even\n # though that is a local only modification. This breaks this badly for the\n # files in S3, and in general it's just not needed.\n set req.url = regsub(req.url, \"#.*$\", \"\");\n\n\n#FASTLY recv\n\n\n # We want to Force SSL for the WebUI by redirecting to the HTTPS version of\n # the page, however for API calls we want to return an error code directing\n # people to instead use HTTPS.\n if (!req.http.Fastly-SSL) {\n\n # The \/simple\/ and \/packages\/ API.\n if (req.url ~ \"^\/(simple|packages)\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy JSON API.\n if (req.url ~ \"^\/pypi\/.+\/json$\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy ?:action= API.\n if (req.url ~ \"^\/pypi.*(\\?|&)=:action\") {\n error 803 \"SSL is required\";\n }\n\n # If we're on the \/pypi page and we've received something other than a\n # GET or HEAD request, then we have no way to determine if a particular\n # request is an API call or not because it'll be in the request body\n # and that isn't available to us here. So in those cases, we won't\n # do a redirect.\n if (req.url ~ \"^\/pypi\") {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n error 801 \"Force SSL\";\n }\n }\n else {\n # This isn't a \/pypi URL so we'll just unconditionally redirect to\n # HTTPS.\n error 801 \"Force SSL\";\n }\n }\n\n # Canonicalize our domains by redirecting any domain that doesn't match our\n # primary domain to our primary domain. We do this *after* the HTTPS check\n # on purpose.\n if (std.tolower(req.http.host) != std.tolower(req.http.Primary-Domain)) {\n set req.http.Location = \"https:\/\/\" req.http.Primary-Domain req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n\n # Requests to \/packages\/ get dispatched to Amazon instead of to our typical\n # Origin. This requires a a bit of setup to make it work.\n if (req.url ~ \"^\/packages\/\") {\n # Setup our environment to better match what S3 expects\/needs\n set req.http.Host = req.http.AWS-Bucket-Name \".s3.amazonaws.com\";\n set req.http.Date = now;\n set req.url = regsuball(req.url, \"\\+\", urlencode(\"+\"));\n\n # Compute the Authorization header that S3 requires to be able to\n # access the files stored there.\n set req.http.Authorization = \"AWS \" req.http.AWS-Access-Key-ID \":\" digest.hmac_sha1_base64(req.http.AWS-Secret-Access-Key, \"GET\" LF LF LF req.http.Date LF \"\/\" req.http.AWS-Bucket-Name req.url.path);\n\n # We don't want to send our Warehouse-Token to S3, so we'll go ahead\n # and remove it.\n unset req.http.Warehouse-Token;\n }\n\n # We no longer need any of these variables, which would exist only to\n # shuffle configuration from the Fastly UI into our VCL.\n unset req.http.Primary-Domain;\n unset req.http.AWS-Access-Key-ID;\n unset req.http.AWS-Secret-Access-Key;\n unset req.http.AWS-Bucket-Name;\n\n # We have a number of items that we'll pass back to the origin, but only\n # if we have a Warehouse-Token that will allow them to be accepted.\n if (req.http.Warehouse-Token) {\n # Set a header to tell the backend if we're using https or http.\n if (req.http.Fastly-SSL) {\n set req.http.Warehouse-Proto = \"https\";\n } else {\n set req.http.Warehouse-Proto = \"http\";\n }\n\n # Pass the client IP address back to the backend.\n if (req.http.Fastly-Client-IP) {\n set req.http.Warehouse-IP = req.http.Fastly-Client-IP;\n }\n\n # Pass the real host value back to the backend.\n if (req.http.Host) {\n set req.http.Warehouse-Host = req.http.Host;\n }\n }\n\n # Do not bother to attempt to run the caching mechanisms for methods that\n # are not generally safe to cache.\n if (req.request != \"HEAD\" &&\n req.request != \"GET\" &&\n req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n # Finally, return the default lookup action.\n return(lookup);\n}\n\n\nsub vcl_fetch {\n#FASTLY fetch\n\n # Trigger a \"SSL is required\" error if the backend has indicated to do so.\n if (beresp.http.X-Fastly-Error == \"803\") {\n error 803 \"SSL is required\";\n }\n\n # If we've gotten a 502 or a 503 from the backend, we'll go ahead and retry\n # the request.\n if ((beresp.status == 502 || beresp.status == 503) &&\n req.restarts < 1 &&\n (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n # If we've restarted, then we'll record the number of restarts.\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n # If there is a Set-Cookie header, we'll ensure that we do not cache the\n # response.\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n # If the response has the private Cache-Control directive then we won't\n # cache it.\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # If we've gotten an error after the restarts we'll deliver the response\n # with a very short cache time.\n if (beresp.status == 500 || beresp.status == 503) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n # Apply a default TTL if there isn't a max-age or s-maxage.\n if (beresp.http.Expires ||\n beresp.http.Surrogate-Control ~ \"max-age\" ||\n beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # Keep the ttl here\n }\n else {\n # Apply the default ttl\n set beresp.ttl = 60s;\n }\n\n # Actually deliver the fetched response.\n return(deliver);\n}\n\n\nsub vcl_deliver {\n#FASTLY deliver\n\n # Unset headers that we don't need\/want to send on to the client because\n # they are not generally useful.\n unset resp.http.Server;\n unset resp.http.Via;\n\n # Unset a few headers set by Amazon that we don't really have a need\/desire\n # to send to clients.\n unset resp.http.X-AMZ-Replication-Status;\n unset resp.http.X-AMZ-Meta-Python-Version;\n unset resp.http.X-AMZ-Meta-Version;\n unset resp.http.X-AMZ-Meta-Package-Type;\n unset resp.http.X-AMZ-Meta-Project;\n\n # Set our standard security headers, we do this in VCL rather than in\n # Warehouse itself so that we always get these headers, regardless of the\n # origin server being used.\n set resp.http.Strict-Transport-Security = \"max-age=31536000; includeSubDomains; preload\";\n set resp.http.X-Frame-Options = \"deny\";\n set resp.http.X-XSS-Protection = \"1; mode=block\";\n set resp.http.X-Content-Type-Options = \"nosniff\";\n set resp.http.X-Permitted-Cross-Domain-Policies = \"none\";\n\n return(deliver);\n}\n\n\nsub vcl_error {\n#FASTLY error\n\n if (obj.status == 803) {\n set obj.status = 403;\n set obj.response = \"SSL is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic {\"SSL is required.\"};\n return (deliver);\n } else if (obj.status == 750) {\n set obj.status = 301;\n set obj.http.Location = req.http.Location;\n set obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n synthetic {\"<html><head><title>301 Moved Permanently<\/title><\/head><body><center><h1>301 Moved Permanently<\/h1><\/center><\/body><\/html>\"};\n return(deliver);\n }\n\n}\n","old_contents":"\nsub vcl_recv {\n#FASTLY recv\n\n # We want to Force SSL for the WebUI by redirecting to the HTTPS version of\n # the page, however for API calls we want to return an error code directing\n # people to instead use HTTPS.\n if (!req.http.Fastly-SSL) {\n\n # The \/simple\/ and \/packages\/ API.\n if (req.url ~ \"^\/(simple|packages)\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy JSON API.\n if (req.url ~ \"^\/pypi\/.+\/json$\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy ?:action= API.\n if (req.url ~ \"^\/pypi.*(\\?|&)=:action\") {\n error 803 \"SSL is required\";\n }\n\n # If we're on the \/pypi page and we've received something other than a\n # GET or HEAD request, then we have no way to determine if a particular\n # request is an API call or not because it'll be in the request body\n # and that isn't available to us here. So in those cases, we won't\n # do a redirect.\n if (req.url ~ \"^\/pypi\") {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n error 801 \"Force SSL\";\n }\n }\n else {\n # This isn't a \/pypi URL so we'll just unconditionally redirect to\n # HTTPS.\n error 801 \"Force SSL\";\n }\n }\n\n # Canonicalize our domains by redirecting any domain that doesn't match our\n # primary domain to our primary domain. We do this *after* the HTTPS check\n # on purpose.\n if (std.tolower(req.http.host) != std.tolower(req.http.Primary-Domain)) {\n set req.http.Location = \"https:\/\/\" req.http.Primary-Domain req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n\n # Set a header to tell the backend if we're using https or http.\n if (req.http.Fastly-SSL) {\n set req.http.Warehouse-Proto = \"https\";\n } else {\n set req.http.Warehouse-Proto = \"http\";\n }\n\n # Pass the client IP address back to the backend.\n if (req.http.Fastly-Client-IP) {\n set req.http.Warehouse-IP = req.http.Fastly-Client-IP;\n }\n\n # Pass the real host value back to the backend.\n if (req.http.Host) {\n set req.http.Warehouse-Host = req.http.Host;\n }\n\n # Do not bother to attempt to run the caching mechanisms for methods that\n # are not generally safe to cache.\n if (req.request != \"HEAD\" &&\n req.request != \"GET\" &&\n req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n # Finally, return the default lookup action.\n return(lookup);\n}\n\n\nsub vcl_fetch {\n#FASTLY fetch\n\n # Trigger a \"SSL is required\" error if the backend has indicated to do so.\n if (beresp.http.X-Fastly-Error == \"803\") {\n error 803 \"SSL is required\";\n }\n\n # If we've gotten a 502 or a 503 from the backend, we'll go ahead and retry\n # the request.\n if ((beresp.status == 502 || beresp.status == 503) &&\n req.restarts < 1 &&\n (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n # If we've restarted, then we'll record the number of restarts.\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n # If there is a Set-Cookie header, we'll ensure that we do not cache the\n # response.\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n # If the response has the private Cache-Control directive then we won't\n # cache it.\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # If we've gotten an error after the restarts we'll deliver the response\n # with a very short cache time.\n if (beresp.status == 500 || beresp.status == 503) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n # Apply a default TTL if there isn't a max-age or s-maxage.\n if (beresp.http.Expires ||\n beresp.http.Surrogate-Control ~ \"max-age\" ||\n beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # Keep the ttl here\n }\n else {\n # Apply the default ttl\n set beresp.ttl = 60s;\n }\n\n # Actually deliver the fetched response.\n return(deliver);\n}\n\n\nsub vcl_deliver {\n#FASTLY deliver\n\n # Unset headers that we don't need\/want to send on to the client because\n # they are not generally useful.\n unset resp.http.Server;\n unset resp.http.Via;\n\n # Set our standard security headers, we do this in VCL rather than in\n # Warehouse itself so that we always get these headers, regardless of the\n # origin server being used.\n set resp.http.Strict-Transport-Security = \"max-age=31536000; includeSubDomains; preload\";\n set resp.http.X-Frame-Options = \"deny\";\n set resp.http.X-XSS-Protection = \"1; mode=block\";\n set resp.http.X-Content-Type-Options = \"nosniff\";\n set resp.http.X-Permitted-Cross-Domain-Policies = \"none\";\n\n return(deliver);\n}\n\n\nsub vcl_error {\n#FASTLY error\n\n if (obj.status == 803) {\n set obj.status = 403;\n set obj.response = \"SSL is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic {\"SSL is required.\"};\n return (deliver);\n } else if (obj.status == 750) {\n set obj.status = 301;\n set obj.http.Location = req.http.Location;\n set obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n synthetic {\"<html><head><title>301 Moved Permanently<\/title><\/head><body><center><h1>301 Moved Permanently<\/h1><\/center><\/body><\/html>\"};\n return(deliver);\n }\n\n}\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"4e18f191a6714bf9b1bee31f5d3939b90e3aa016","subject":"Wrong error code","message":"Wrong error code\n","repos":"fastly\/fastly-magento,fastly\/fastly-magento,fastly\/fastly-magento,fastly\/fastly-magento","old_file":"app\/code\/community\/Fastly\/CDN\/etc\/vcl_snippets_force_tls\/recv.vcl","new_file":"app\/code\/community\/Fastly\/CDN\/etc\/vcl_snippets_force_tls\/recv.vcl","new_contents":"# Force SSL immediately to avoid magento module VCL stripping off\n# google campaign ids like gclid\n if (!req.http.Fastly-SSL) { \n error 801 \"Force SSL\";\n }\n","old_contents":"# Force SSL immediately to avoid magento module VCL stripping off\n# google campaign ids like gclid\n if (!req.http.Fastly-SSL) { \n error 972 \"Force SSL\"; \n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"0ea529cdb65090d49637878c197ae9692443b0ba","subject":"Fixing missing semicolons","message":"Fixing missing semicolons\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets\/deliver.vcl","new_file":"etc\/vcl_snippets\/deliver.vcl","new_contents":" # If we are doing a bypass for Magento Tester return early as not to affect any headers\n if ( req.http.bypass-secret ) {\n return(deliver);\n }\n\n # Send no cache headers to end users for non-static content created by Magento\n if (resp.http.X-Magento-Tags && fastly.ff.visits_this_service == 0 ) {\n set resp.http.Cache-Control = \"no-store, no-cache, must-revalidate, max-age=0\";\n }\n\n # Make sure GraphQl requests are covered by store and currency\n if (req.http.graphql && resp.http.Vary !~ \"(?i)Store, *Content-Currency\") {\n if (resp.http.Vary) {\n set resp.http.Vary = resp.http.Vary + \",Store,Content-Currency\";\n } else {\n set resp.http.Vary = \"Store,Content-Currency\";\n }\n }\n\n # Execute only on the edge nodes\n if ( fastly.ff.visits_this_service == 0 ) {\n if ( req.http.graphql ) {\n set resp.http.Vary = resp.http.Vary + \",Authorization\";\n if ( resp.http.X-Magento-Cache-Id ) {\n # GraphQl queries should be cached by the browser under X-Magento-Cache-Id if available\n set resp.http.Vary = resp.http.Vary + \",X-Magento-Cache-Id\";\n }\n } else {\n # Remove X-Magento-Vary and HTTPs Vary served to the user\n set resp.http.Vary = regsub(resp.http.Vary, \"(?i)X-Magento-Vary,Https\", \"Cookie\");\n }\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it and we only want to do this on the edge nodes\n if (resp.http.x-esi) {\n set resp.http.x-compress-hint = \"on\";\n }\n remove resp.http.X-Magento-Tags;\n }\n\n # Add an easy way to see whether custom Fastly VCL has been uploaded\n if ( req.http.Fastly-Debug ) {\n set resp.http.Fastly-Magento-VCL-Uploaded = \"1.2.157\";\n } else {\n remove resp.http.Fastly-Module-Enabled;\n remove resp.http.fastly-page-cacheable;\n }\n\n # X-Magento-Debug header is exposed when developer mode is activated in Magento\n if (!resp.http.X-Magento-Debug) {\n # remove Varnish\/proxy header\n remove resp.http.X-Magento-Debug;\n remove resp.http.X-Magento-Cache-Control;\n remove resp.http.X-Powered-By;\n remove resp.http.Server;\n remove resp.http.X-Varnish;\n remove resp.http.Via;\n remove resp.http.X-Purge-URL;\n remove resp.http.X-Purge-Host;\n }\n","old_contents":" # If we are doing a bypass for Magento Tester return early as not to affect any headers\n if ( req.http.bypass-secret ) {\n return(deliver);\n }\n\n # Send no cache headers to end users for non-static content created by Magento\n if (resp.http.X-Magento-Tags && fastly.ff.visits_this_service == 0 ) {\n set resp.http.Cache-Control = \"no-store, no-cache, must-revalidate, max-age=0\";\n }\n\n # Make sure GraphQl requests are covered by store and currency\n if (req.http.graphql && resp.http.Vary !~ \"(?i)Store, *Content-Currency\") {\n if (resp.http.Vary) {\n set resp.http.Vary = resp.http.Vary + \",Store,Content-Currency\"\n } else {\n set resp.http.Vary = \"Store,Content-Currency\"\n }\n }\n\n # Execute only on the edge nodes\n if ( fastly.ff.visits_this_service == 0 ) {\n if ( req.http.graphql ) {\n set resp.http.Vary = resp.http.Vary + \",Authorization\";\n if ( resp.http.X-Magento-Cache-Id ) {\n # GraphQl queries should be cached by the browser under X-Magento-Cache-Id if available\n set resp.http.Vary = resp.http.Vary + \",X-Magento-Cache-Id\";\n }\n } else {\n # Remove X-Magento-Vary and HTTPs Vary served to the user\n set resp.http.Vary = regsub(resp.http.Vary, \"(?i)X-Magento-Vary,Https\", \"Cookie\");\n }\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it and we only want to do this on the edge nodes\n if (resp.http.x-esi) {\n set resp.http.x-compress-hint = \"on\";\n }\n remove resp.http.X-Magento-Tags;\n }\n\n # Add an easy way to see whether custom Fastly VCL has been uploaded\n if ( req.http.Fastly-Debug ) {\n set resp.http.Fastly-Magento-VCL-Uploaded = \"1.2.157\";\n } else {\n remove resp.http.Fastly-Module-Enabled;\n remove resp.http.fastly-page-cacheable;\n }\n\n # X-Magento-Debug header is exposed when developer mode is activated in Magento\n if (!resp.http.X-Magento-Debug) {\n # remove Varnish\/proxy header\n remove resp.http.X-Magento-Debug;\n remove resp.http.X-Magento-Cache-Control;\n remove resp.http.X-Powered-By;\n remove resp.http.Server;\n remove resp.http.X-Varnish;\n remove resp.http.Via;\n remove resp.http.X-Purge-URL;\n remove resp.http.X-Purge-Host;\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"c117407bc8e4fd61b86d48dc7464f74354bc1e04","subject":"Set X-eLife-Restart","message":"Set X-eLife-Restart\n","repos":"elifesciences\/builder,elifesciences\/builder","old_file":"src\/buildercore\/fastly\/vcl\/main.vcl","new_file":"src\/buildercore\/fastly\/vcl\/main.vcl","new_contents":"sub vcl_recv {\n if (req.restarts < 1) {\n unset req.http.X-eLife-Restart;\n }\n\n #FASTLY recv\n\n if (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n return(lookup);\n}\n\nsub vcl_fetch {\n #FASTLY fetch\n\n if (beresp.status >= 500 && beresp.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n set req.http.X-eLife-Restart = \"fetch,\" beresp.status;\n unset req.http.Cookie;\n\n restart;\n }\n\n if (!beresp.http.Content-Length || beresp.http.Content-Length == \"0\") {\n error beresp.status;\n }\n }\n\n if (req.restarts > 0) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return(pass);\n }\n\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return(pass);\n }\n\n if (beresp.status == 500 || beresp.status == 503) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return(deliver);\n }\n\n if (beresp.http.Expires || beresp.http.Surrogate-Control ~ \"max-age\" || beresp.http.Cache-Control ~ \"(s-maxage|max-age)\") {\n # keep the ttl here\n } else {\n # apply the default ttl\n set beresp.ttl = 3600s;\n }\n\n return(deliver);\n}\n\nsub vcl_hit {\n #FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\nsub vcl_miss {\n #FASTLY miss\n return(fetch);\n}\n\nsub vcl_deliver {\n if (resp.status >= 500 && resp.status < 600 && stale.exists) {\n set req.http.X-eLife-Restart = \"deliver,\" resp.status;\n\n restart;\n }\n\n if (req.http.Fastly-Debug && req.http.X-eLife-Restart) {\n set resp.http.X-eLife-Restart = req.http.X-eLife-Restart;\n }\n\n #FASTLY deliver\n return(deliver);\n}\n\nsub vcl_error {\n if (obj.status >= 500 && obj.status < 600 && stale.exists) {\n return(deliver_stale);\n }\n\n #FASTLY error\n}\n\nsub vcl_pass {\n #FASTLY pass\n}\n\nsub vcl_log {\n #FASTLY log\n}\n","old_contents":"sub vcl_recv {\n #FASTLY recv\n\n if (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n return(lookup);\n}\n\nsub vcl_fetch {\n #FASTLY fetch\n\n if (beresp.status >= 500 && beresp.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n unset req.http.Cookie;\n\n restart;\n }\n\n if (!beresp.http.Content-Length || beresp.http.Content-Length == \"0\") {\n error beresp.status;\n }\n }\n\n if (req.restarts > 0) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return(pass);\n }\n\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return(pass);\n }\n\n if (beresp.status == 500 || beresp.status == 503) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return(deliver);\n }\n\n if (beresp.http.Expires || beresp.http.Surrogate-Control ~ \"max-age\" || beresp.http.Cache-Control ~ \"(s-maxage|max-age)\") {\n # keep the ttl here\n } else {\n # apply the default ttl\n set beresp.ttl = 3600s;\n }\n\n return(deliver);\n}\n\nsub vcl_hit {\n #FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\nsub vcl_miss {\n #FASTLY miss\n return(fetch);\n}\n\nsub vcl_deliver {\n if (resp.status >= 500 && resp.status < 600 && stale.exists) {\n unset req.http.Cookie;\n\n restart;\n }\n\n #FASTLY deliver\n return(deliver);\n}\n\nsub vcl_error {\n if (obj.status >= 500 && obj.status < 600 && stale.exists) {\n return(deliver_stale);\n }\n\n #FASTLY error\n}\n\nsub vcl_pass {\n #FASTLY pass\n}\n\nsub vcl_log {\n #FASTLY log\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"35678ac6c7290f3242c413af313d85ffbbae8ed2","subject":"remove duplicate hint.","message":"remove duplicate hint.\n","repos":"amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon","old_file":"images\/varnish-drupal\/drupal.vcl","new_file":"images\/varnish-drupal\/drupal.vcl","new_contents":"vcl 4.0;\n\nimport std;\n\n# set backend default\nbackend default {\n .host = \"${VARNISH_BACKEND_HOST:-nginx}\";\n .port = \"${VARNISH_BACKEND_PORT:-8080}\";\n .first_byte_timeout = 35m;\n .between_bytes_timeout = 10m;\n}\n\n# Allow purging from localhost\n# @TODO allow from openshift network\nacl purge {\n \"127.0.0.1\";\n \"10.0.0.0\"\/8;\n \"172.16.0.0\"\/12;\n \"192.168.0.0\"\/16;\n}\n\nsub vcl_init {\n new www_dir = dynamic.director(\n port = \"${VARNISH_BACKEND_PORT:-8080}\",\n probe = www_probe,\n whitelist = purge,\n ttl = 60s);\n }\n\n\n# This configuration is optimized for Drupal hosting:\n# Respond to incoming requests.\nsub vcl_recv {\n\n if (req.url ~ \"^\/varnish_status$\") {\n return (synth(200,\"OK\"));\n }\n # set the backend, which should be used:\n set req.backend_hint = www_dir.backend(\"${VARNISH_BACKEND_HOST:-nginx}\");\n\n # Always set the forward ip.\n if (req.restarts == 0) {\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n\n\n if (req.http.X-LAGOON-VARNISH ) {\n ## Pass all Requests which are handled via an upstream Varnish\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, \" + req.http.X-LAGOON-VARNISH;\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n } else if (req.http.Fastly-FF) {\n ## Pass all Requests which are handled via Fastly\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, fastly\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n set req.http.X-Forwarded-For = req.http.Fastly-Client-IP;\n } else if (req.http.CF-RAY) {\n ## Pass all Requests which are handled via CloudFlare\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, cloudflare\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n set req.http.X-Forwarded-For = req.http.CF-Connecting-IP;\n } else if (req.http.X-Pull) {\n ## Pass all Requests which are handled via KeyCDN\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, keycdn\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n } else {\n ## We set a header to let a Varnish Chain know that it already has been varnishcached\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}\";\n\n ## Allow to bypass based on env variable `VARNISH_BYPASS`\n set req.http.X-LAGOON-VARNISH-BYPASS = \"${VARNISH_BYPASS:-false}\";\n }\n\n # Websockets are piped\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n if (req.http.X-LAGOON-VARNISH-BYPASS == \"true\" || req.http.X-LAGOON-VARNISH-BYPASS == \"TRUE\") {\n return (pass);\n }\n\n # SA-CORE-2014-004 preventing access to \/xmlrpc.php\n if (req.url ~ \"^\/xmlrpc.php$\") {\n return (synth(701, \"Unauthorized\"));\n }\n\n # Strip out Google Analytics campaign variables. They are only needed\n # by the javascript running on the page\n # utm_source, utm_medium, utm_campaign, gclid\n if(req.url ~ \"(\\?|&)(gclid|utm_[a-z]+)=\") {\n set req.url = regsuball(req.url, \"(gclid|utm_[a-z]+)=[^\\&]+&?\", \"\");\n set req.url = regsub(req.url, \"(\\?|&)$\", \"\");\n }\n\n # Bypass a cache hit (the request is still sent to the backend)\n if (req.method == \"REFRESH\") {\n if (!client.ip ~ purge) { return (synth(405, \"Not allowed\")); }\n set req.method = \"GET\";\n set req.hash_always_miss = true;\n }\n\n # Only allow BAN requests from IP addresses in the 'purge' ACL.\n if (req.method == \"BAN\" || req.method == \"URIBAN\" || req.method == \"PURGE\") {\n # Only allow BAN from defined ACL\n if (!client.ip ~ purge) {\n return (synth(403, \"Your IP is not allowed.\"));\n }\n\n # Only allows BAN if the Host Header has the style of with \"${SERVICE_NAME:-varnish}:8080\" or \"${SERVICE_NAME:-varnish}\".\n # Such a request is only possible from within the Docker network, as a request from external goes trough the Kubernetes Router and for that needs a proper Host Header\n if (!req.http.host ~ \"^${SERVICE_NAME:-varnish}(:\\d+)?$\") {\n return (synth(403, \"Only allowed from within own network.\"));\n }\n\n if (req.method == \"BAN\") {\n # Logic for the ban, using the Cache-Tags header.\n if (req.http.Cache-Tags) {\n ban(\"obj.http.Cache-Tags ~ \" + req.http.Cache-Tags);\n # Throw a synthetic page so the request won't go to the backend.\n return (synth(200, \"Ban added.\"));\n }\n else {\n return (synth(403, \"Cache-Tags header missing.\"));\n }\n }\n\n if (req.method == \"URIBAN\" || req.method == \"PURGE\") {\n ban(\"req.url ~ \" + req.url);\n # Throw a synthetic page so the request won't go to the backend.\n return (synth(200, \"Ban added.\"));\n }\n\n }\n\n # Non-RFC2616 or CONNECT which is weird, we pipe that\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n return (pipe);\n }\n\n # We only try to cache GET and HEAD, other things are passed\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n # Any requests with Basic Auth are passed\n if (req.http.Authorization || req.http.Authenticate)\n {\n return (pass);\n }\n\n ## Pass requests which are from blackfire\n if (req.http.X-Blackfire-Query) {\n return (pass);\n }\n\n # Some URLs should never be cached\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/admin([\/?]|$).*$\" ||\n req.url ~ \"^\/info([\/?]|$).*$\" ||\n req.url ~ \"^\/flag([\/?]|$).*$\" ||\n req.url ~ \"^.*\/system\/files([\/?]|$).*$\" ||\n req.url ~ \"^\/cgi\" ||\n req.url ~ \"^\/cgi-bin\"\n ) {\n return (pass);\n }\n\n # Plupload likes to get piped\n if (req.url ~ \"^.*\/plupload-handle-uploads.*$\"\n ) {\n return (pipe);\n }\n\n # Handle compression correctly. Different browsers send different\n # \"Accept-Encoding\" headers, even though they mostly all support the same\n # compression mechanisms. By consolidating these compression headers into\n # a consistent format, we can reduce the size of the cache and get more hits.=\n # @see: http:\/\/ varnish.projects.linpro.no\/wiki\/FAQ\/Compression\n if (req.http.Accept-Encoding) {\n if (req.http.Accept-Encoding ~ \"gzip\") {\n # If the browser supports it, we'll use gzip.\n set req.http.Accept-Encoding = \"gzip\";\n }\n else if (req.http.Accept-Encoding ~ \"deflate\") {\n # Next, try deflate if it is supported.\n set req.http.Accept-Encoding = \"deflate\";\n }\n else {\n # Unknown algorithm. Remove it and send unencoded.\n unset req.http.Accept-Encoding;\n }\n }\n\n # Always cache the following file types for all users.\n if (req.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n unset req.http.Cookie;\n }\n\n # Remove all cookies that Drupal doesn't need to know about. ANY remaining\n # cookie will cause the request to pass-through to a backend. For the most part\n # we always set the NO_CACHE cookie after any POST request, disabling the\n # Varnish cache temporarily. The session cookie allows all authenticated users\n # to pass through as long as they're logged in.\n #\n # 1. Append a semi-colon to the front of the cookie string.\n # 2. Remove all spaces that appear after semi-colons.\n # 3. Match the cookies we want to keep, adding the space we removed\n # previously, back. (\\1) is first matching group in the regsuball.\n # 4. Remove all other cookies, identifying them by the fact that they have\n # no space after the preceding semi-colon.\n # 5. Remove all spaces and semi-colons from the beginning and end of the\n # cookie string.\n if (req.http.Cookie) {\n set req.http.CookieCheck = \";\" + req.http.Cookie;\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"; +\", \";\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";(${VARNISH_COOKIECHECK:-SESS[a-z0-9]+|SSESS[a-z0-9]+|NO_CACHE})=\", \"; \\1=\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";[^ ][^;]*\", \"\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"^[; ]+|[; ]+$\", \"\");\n\n set req.http.Cookie = req.http.Cookie + \";\";\n\n if (req.http.CookieCheck == \"\") {\n # If there are no remaining cookies, remove the cookie header. If there\n # aren't any cookie headers, Varnish's default behavior will be to cache\n # the page.\n\n unset req.http.CookieCheck;\n unset req.http.Cookie;\n }\n else {\n # If there is any cookies left (a session or NO_CACHE cookie), do not\n # cache the page. Pass it on to Apache directly.\n unset req.http.CookieCheck;\n return (pass);\n }\n }\n\n # Cacheable, lookup in cache.\n return (hash);\n}\n\nsub vcl_pipe {\n # Support for Websockets\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n set bereq.http.connection = req.http.connection;\n }\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n # normal hit\n return (deliver);\n }\n # We have no fresh fish. Lets look at the stale ones.\n if (std.healthy(req.backend_hint)) {\n # Backend is healthy. If the object is not older then 30secs, deliver it to the client\n # and automatically create a separate backend request to warm the cache for this request.\n if (obj.ttl + 30s > 0s) {\n set req.http.grace = \"normal(limited)\";\n return (deliver);\n } else {\n # No candidate for grace. Fetch a fresh object.\n return(miss);\n }\n } else {\n # backend is sick - use full grace\n if (obj.ttl + obj.grace > 0s) {\n set req.http.grace = \"full\";\n return (deliver);\n } else {\n # no graced object.\n return (miss);\n }\n }\n}\n\nsub vcl_backend_response {\n # Allow items to be stale if needed.\n set beresp.grace = 6h;\n\n # Set ban-lurker friendly custom headers.\n set beresp.http.X-Url = bereq.url;\n set beresp.http.X-Host = bereq.http.host;\n\n # If the backend sends a X-LAGOON-VARNISH-BACKEND-BYPASS header we directly deliver\n if(beresp.http.X-LAGOON-VARNISH-BACKEND-BYPASS == \"TRUE\") {\n return (deliver);\n }\n\n # Cache 404 and 403 for 10 seconds\n if(beresp.status == 404 || beresp.status == 403) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n # Don't allow static files to set cookies.\n if (bereq.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n # beresp == Back-end response from the web server.\n unset beresp.http.set-cookie;\n unset beresp.http.Cache-Control;\n\n # If an asset would come back with statuscode 500 we only cache it for 10 seconds instead of the usual static file cache\n if (beresp.status == 500) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n set beresp.ttl = ${VARNISH_ASSETS_TTL:-2628001}s;\n set beresp.http.Cache-Control = \"public, max-age=${VARNISH_ASSETS_TTL:-2628001}\";\n set beresp.http.Expires = \"\" + (now + beresp.ttl);\n }\n\n return (deliver);\n}\n\n# Set a header to track a cache HIT\/MISS.\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Varnish-Cache = \"HIT\";\n }\n else {\n set resp.http.X-Varnish-Cache = \"MISS\";\n }\n\n # Remove ban-lurker friendly custom headers when delivering to client.\n unset resp.http.X-Url;\n unset resp.http.X-Host;\n\n # unset Cache-Tags Header by default, can be disabled with VARNISH_UNSET_HEADER_CACHE_TAGS=true\n if (!${VARNISH_UNSET_HEADER_CACHE_TAGS:-false}) {\n unset resp.http.Cache-Tags;\n }\n\n unset resp.http.X-Generator;\n unset resp.http.Server;\n # Inject information about grace\n if (req.http.grace) {\n set resp.http.X-Varnish-Grace = req.http.grace;\n }\n set resp.http.X-LAGOON = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}>\" + resp.http.X-LAGOON;\n return (deliver);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n if (req.http.X-Forwarded-Proto) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n if (req.http.HTTPS) {\n hash_data(req.http.HTTPS);\n }\n return (lookup);\n}\n\nsub vcl_synth {\n if (resp.status == 701) {\n set resp.status = 401;\n set resp.http.Content-Type = \"text\/plain; charset=utf-8\";\n synthetic({\"XMLRPC Interface is blocked due to SA-CORE-2014-004 - mail support@amazee.io if you need it.\"});\n return (deliver);\n }\n if (resp.status == 700) {\n # Set a status the client will understand\n set resp.status = 200;\n # Create our synthetic response\n synthetic(\"\");\n return(deliver);\n}\n return (deliver);\n}\n\nsub vcl_backend_error {\n # Restart the request, when we have a backend server error, to try another backend.\n # Restart max twice.\n if (bereq.retries < 2) {\n return(retry);\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<head>\n <title>Server Error<\/title>\n <style type=\"text\/css\">\n body {\n font-family: helvetica, arial, sans-serif;\n }\n img {\n margin-top: 50px;\n }\n p {\n width: 6 00px;\n margin-top: 10px\n }\n div {\n background: #ccc;\n width: 600px;\n margin: auto;\n padding: 50px;\n }\n span {\n color: #ccc\n }\n <\/style>\n<\/head>\n<body>\n <div>\n <h1>We are sorry...<\/h1>\n <p>We encountered a server-side error. This means that the problem is not with your computer or Internet connection, but rather with the website's server.<\/p>\n <p>We are currently working on solving this problem and apologise for the inconvenience.<\/p>\n <span>\n <strong>Technical Information<\/strong><br \/>\n Error \"} + beresp.status + \" \" + beresp.reason + {\"<br \/>\n XID: \"} + bereq.xid + {\"<br \/>\n <\/span>\n <\/div>\n<\/body>\n<\/html>\n\n\"} );\n return (deliver);\n}\n","old_contents":"vcl 4.0;\n\nimport std;\n\n# set backend default\nbackend default {\n .host = \"${VARNISH_BACKEND_HOST:-nginx}\";\n .port = \"${VARNISH_BACKEND_PORT:-8080}\";\n .first_byte_timeout = 35m;\n .between_bytes_timeout = 10m;\n}\n\n# Allow purging from localhost\n# @TODO allow from openshift network\nacl purge {\n \"127.0.0.1\";\n \"10.0.0.0\"\/8;\n \"172.16.0.0\"\/12;\n \"192.168.0.0\"\/16;\n}\n\nsub vcl_init {\n new www_dir = dynamic.director(\n port = \"${VARNISH_BACKEND_PORT:-8080}\",\n probe = www_probe,\n whitelist = purge,\n ttl = 60s);\n }\n\n\n# This configuration is optimized for Drupal hosting:\n# Respond to incoming requests.\nsub vcl_recv {\n set req.backend_hint = www_dir.backend(\"${VARNISH_BACKEND_HOST:-nginx}\");\n\n if (req.url ~ \"^\/varnish_status$\") {\n return (synth(200,\"OK\"));\n }\n # set the backend, which should be used:\n set req.backend_hint = default;\n\n # Always set the forward ip.\n if (req.restarts == 0) {\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n\n\n if (req.http.X-LAGOON-VARNISH ) {\n ## Pass all Requests which are handled via an upstream Varnish\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, \" + req.http.X-LAGOON-VARNISH;\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n } else if (req.http.Fastly-FF) {\n ## Pass all Requests which are handled via Fastly\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, fastly\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n set req.http.X-Forwarded-For = req.http.Fastly-Client-IP;\n } else if (req.http.CF-RAY) {\n ## Pass all Requests which are handled via CloudFlare\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, cloudflare\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n set req.http.X-Forwarded-For = req.http.CF-Connecting-IP;\n } else if (req.http.X-Pull) {\n ## Pass all Requests which are handled via KeyCDN\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, keycdn\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n } else {\n ## We set a header to let a Varnish Chain know that it already has been varnishcached\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}\";\n\n ## Allow to bypass based on env variable `VARNISH_BYPASS`\n set req.http.X-LAGOON-VARNISH-BYPASS = \"${VARNISH_BYPASS:-false}\";\n }\n\n # Websockets are piped\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n if (req.http.X-LAGOON-VARNISH-BYPASS == \"true\" || req.http.X-LAGOON-VARNISH-BYPASS == \"TRUE\") {\n return (pass);\n }\n\n # SA-CORE-2014-004 preventing access to \/xmlrpc.php\n if (req.url ~ \"^\/xmlrpc.php$\") {\n return (synth(701, \"Unauthorized\"));\n }\n\n # Strip out Google Analytics campaign variables. They are only needed\n # by the javascript running on the page\n # utm_source, utm_medium, utm_campaign, gclid\n if(req.url ~ \"(\\?|&)(gclid|utm_[a-z]+)=\") {\n set req.url = regsuball(req.url, \"(gclid|utm_[a-z]+)=[^\\&]+&?\", \"\");\n set req.url = regsub(req.url, \"(\\?|&)$\", \"\");\n }\n\n # Bypass a cache hit (the request is still sent to the backend)\n if (req.method == \"REFRESH\") {\n if (!client.ip ~ purge) { return (synth(405, \"Not allowed\")); }\n set req.method = \"GET\";\n set req.hash_always_miss = true;\n }\n\n # Only allow BAN requests from IP addresses in the 'purge' ACL.\n if (req.method == \"BAN\" || req.method == \"URIBAN\" || req.method == \"PURGE\") {\n # Only allow BAN from defined ACL\n if (!client.ip ~ purge) {\n return (synth(403, \"Your IP is not allowed.\"));\n }\n\n # Only allows BAN if the Host Header has the style of with \"${SERVICE_NAME:-varnish}:8080\" or \"${SERVICE_NAME:-varnish}\".\n # Such a request is only possible from within the Docker network, as a request from external goes trough the Kubernetes Router and for that needs a proper Host Header\n if (!req.http.host ~ \"^${SERVICE_NAME:-varnish}(:\\d+)?$\") {\n return (synth(403, \"Only allowed from within own network.\"));\n }\n\n if (req.method == \"BAN\") {\n # Logic for the ban, using the Cache-Tags header.\n if (req.http.Cache-Tags) {\n ban(\"obj.http.Cache-Tags ~ \" + req.http.Cache-Tags);\n # Throw a synthetic page so the request won't go to the backend.\n return (synth(200, \"Ban added.\"));\n }\n else {\n return (synth(403, \"Cache-Tags header missing.\"));\n }\n }\n\n if (req.method == \"URIBAN\" || req.method == \"PURGE\") {\n ban(\"req.url ~ \" + req.url);\n # Throw a synthetic page so the request won't go to the backend.\n return (synth(200, \"Ban added.\"));\n }\n\n }\n\n # Non-RFC2616 or CONNECT which is weird, we pipe that\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n return (pipe);\n }\n\n # We only try to cache GET and HEAD, other things are passed\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n # Any requests with Basic Auth are passed\n if (req.http.Authorization || req.http.Authenticate)\n {\n return (pass);\n }\n\n ## Pass requests which are from blackfire\n if (req.http.X-Blackfire-Query) {\n return (pass);\n }\n\n # Some URLs should never be cached\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/admin([\/?]|$).*$\" ||\n req.url ~ \"^\/info([\/?]|$).*$\" ||\n req.url ~ \"^\/flag([\/?]|$).*$\" ||\n req.url ~ \"^.*\/system\/files([\/?]|$).*$\" ||\n req.url ~ \"^\/cgi\" ||\n req.url ~ \"^\/cgi-bin\"\n ) {\n return (pass);\n }\n\n # Plupload likes to get piped\n if (req.url ~ \"^.*\/plupload-handle-uploads.*$\"\n ) {\n return (pipe);\n }\n\n # Handle compression correctly. Different browsers send different\n # \"Accept-Encoding\" headers, even though they mostly all support the same\n # compression mechanisms. By consolidating these compression headers into\n # a consistent format, we can reduce the size of the cache and get more hits.=\n # @see: http:\/\/ varnish.projects.linpro.no\/wiki\/FAQ\/Compression\n if (req.http.Accept-Encoding) {\n if (req.http.Accept-Encoding ~ \"gzip\") {\n # If the browser supports it, we'll use gzip.\n set req.http.Accept-Encoding = \"gzip\";\n }\n else if (req.http.Accept-Encoding ~ \"deflate\") {\n # Next, try deflate if it is supported.\n set req.http.Accept-Encoding = \"deflate\";\n }\n else {\n # Unknown algorithm. Remove it and send unencoded.\n unset req.http.Accept-Encoding;\n }\n }\n\n # Always cache the following file types for all users.\n if (req.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n unset req.http.Cookie;\n }\n\n # Remove all cookies that Drupal doesn't need to know about. ANY remaining\n # cookie will cause the request to pass-through to a backend. For the most part\n # we always set the NO_CACHE cookie after any POST request, disabling the\n # Varnish cache temporarily. The session cookie allows all authenticated users\n # to pass through as long as they're logged in.\n #\n # 1. Append a semi-colon to the front of the cookie string.\n # 2. Remove all spaces that appear after semi-colons.\n # 3. Match the cookies we want to keep, adding the space we removed\n # previously, back. (\\1) is first matching group in the regsuball.\n # 4. Remove all other cookies, identifying them by the fact that they have\n # no space after the preceding semi-colon.\n # 5. Remove all spaces and semi-colons from the beginning and end of the\n # cookie string.\n if (req.http.Cookie) {\n set req.http.CookieCheck = \";\" + req.http.Cookie;\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"; +\", \";\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";(${VARNISH_COOKIECHECK:-SESS[a-z0-9]+|SSESS[a-z0-9]+|NO_CACHE})=\", \"; \\1=\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";[^ ][^;]*\", \"\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"^[; ]+|[; ]+$\", \"\");\n\n set req.http.Cookie = req.http.Cookie + \";\";\n\n if (req.http.CookieCheck == \"\") {\n # If there are no remaining cookies, remove the cookie header. If there\n # aren't any cookie headers, Varnish's default behavior will be to cache\n # the page.\n\n unset req.http.CookieCheck;\n unset req.http.Cookie;\n }\n else {\n # If there is any cookies left (a session or NO_CACHE cookie), do not\n # cache the page. Pass it on to Apache directly.\n unset req.http.CookieCheck;\n return (pass);\n }\n }\n\n # Cacheable, lookup in cache.\n return (hash);\n}\n\nsub vcl_pipe {\n # Support for Websockets\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n set bereq.http.connection = req.http.connection;\n }\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n # normal hit\n return (deliver);\n }\n # We have no fresh fish. Lets look at the stale ones.\n if (std.healthy(req.backend_hint)) {\n # Backend is healthy. If the object is not older then 30secs, deliver it to the client\n # and automatically create a separate backend request to warm the cache for this request.\n if (obj.ttl + 30s > 0s) {\n set req.http.grace = \"normal(limited)\";\n return (deliver);\n } else {\n # No candidate for grace. Fetch a fresh object.\n return(miss);\n }\n } else {\n # backend is sick - use full grace\n if (obj.ttl + obj.grace > 0s) {\n set req.http.grace = \"full\";\n return (deliver);\n } else {\n # no graced object.\n return (miss);\n }\n }\n}\n\nsub vcl_backend_response {\n # Allow items to be stale if needed.\n set beresp.grace = 6h;\n\n # Set ban-lurker friendly custom headers.\n set beresp.http.X-Url = bereq.url;\n set beresp.http.X-Host = bereq.http.host;\n\n # If the backend sends a X-LAGOON-VARNISH-BACKEND-BYPASS header we directly deliver\n if(beresp.http.X-LAGOON-VARNISH-BACKEND-BYPASS == \"TRUE\") {\n return (deliver);\n }\n\n # Cache 404 and 403 for 10 seconds\n if(beresp.status == 404 || beresp.status == 403) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n # Don't allow static files to set cookies.\n if (bereq.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n # beresp == Back-end response from the web server.\n unset beresp.http.set-cookie;\n unset beresp.http.Cache-Control;\n\n # If an asset would come back with statuscode 500 we only cache it for 10 seconds instead of the usual static file cache\n if (beresp.status == 500) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n set beresp.ttl = ${VARNISH_ASSETS_TTL:-2628001}s;\n set beresp.http.Cache-Control = \"public, max-age=${VARNISH_ASSETS_TTL:-2628001}\";\n set beresp.http.Expires = \"\" + (now + beresp.ttl);\n }\n\n return (deliver);\n}\n\n# Set a header to track a cache HIT\/MISS.\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Varnish-Cache = \"HIT\";\n }\n else {\n set resp.http.X-Varnish-Cache = \"MISS\";\n }\n\n # Remove ban-lurker friendly custom headers when delivering to client.\n unset resp.http.X-Url;\n unset resp.http.X-Host;\n\n # unset Cache-Tags Header by default, can be disabled with VARNISH_UNSET_HEADER_CACHE_TAGS=true\n if (!${VARNISH_UNSET_HEADER_CACHE_TAGS:-false}) {\n unset resp.http.Cache-Tags;\n }\n\n unset resp.http.X-Generator;\n unset resp.http.Server;\n # Inject information about grace\n if (req.http.grace) {\n set resp.http.X-Varnish-Grace = req.http.grace;\n }\n set resp.http.X-LAGOON = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}>\" + resp.http.X-LAGOON;\n return (deliver);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n if (req.http.X-Forwarded-Proto) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n if (req.http.HTTPS) {\n hash_data(req.http.HTTPS);\n }\n return (lookup);\n}\n\nsub vcl_synth {\n if (resp.status == 701) {\n set resp.status = 401;\n set resp.http.Content-Type = \"text\/plain; charset=utf-8\";\n synthetic({\"XMLRPC Interface is blocked due to SA-CORE-2014-004 - mail support@amazee.io if you need it.\"});\n return (deliver);\n }\n if (resp.status == 700) {\n # Set a status the client will understand\n set resp.status = 200;\n # Create our synthetic response\n synthetic(\"\");\n return(deliver);\n}\n return (deliver);\n}\n\nsub vcl_backend_error {\n # Restart the request, when we have a backend server error, to try another backend.\n # Restart max twice.\n if (bereq.retries < 2) {\n return(retry);\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<head>\n <title>Server Error<\/title>\n <style type=\"text\/css\">\n body {\n font-family: helvetica, arial, sans-serif;\n }\n img {\n margin-top: 50px;\n }\n p {\n width: 6 00px;\n margin-top: 10px\n }\n div {\n background: #ccc;\n width: 600px;\n margin: auto;\n padding: 50px;\n }\n span {\n color: #ccc\n }\n <\/style>\n<\/head>\n<body>\n <div>\n <h1>We are sorry...<\/h1>\n <p>We encountered a server-side error. This means that the problem is not with your computer or Internet connection, but rather with the website's server.<\/p>\n <p>We are currently working on solving this problem and apologise for the inconvenience.<\/p>\n <span>\n <strong>Technical Information<\/strong><br \/>\n Error \"} + beresp.status + \" \" + beresp.reason + {\"<br \/>\n XID: \"} + bereq.xid + {\"<br \/>\n <\/span>\n <\/div>\n<\/body>\n<\/html>\n\n\"} );\n return (deliver);\n}\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"76382675139e4201d9b57d1b8969f614c88bef41","subject":"Fixed Dev","message":"Fixed Dev\n","repos":"FredHutch\/Oncoscape,FredHutch\/Oncoscape,FredHutch\/Oncoscape,FredHutch\/Oncoscape,FredHutch\/Oncoscape","old_file":"server\/os.vcl","new_file":"server\/os.vcl","new_contents":"","old_contents":"","returncode":0,"stderr":"unknown","license":"mit","lang":"VCL"} {"commit":"f56250d79ff4532cf851510d904ceab10e648206","subject":"Allow the tarpit interval to be changed","message":"Allow the tarpit interval to be changed\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets_rate_limiting\/deliver.vcl","new_file":"etc\/vcl_snippets_rate_limiting\/deliver.vcl","new_contents":"# Tarpit Rate limited requests\nif ( resp.status == 429 && req.http.Rate-Limit ) {\n resp.tarpit(std.atoi(table.lookup(magentomodule_config, \"tarpit_interval\", \"5\")), 100000);\n}\n","old_contents":"# Tarpit Rate limited requests\nif ( resp.status == 429 && req.http.Rate-Limit ) {\n resp.tarpit(5, 100000);\n}\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"45bd60d79370670f556c314a3b862b7d5f98b926","subject":"FirefoxOS detection","message":"FirefoxOS detection\n","repos":"kevinquinnyo\/varnish-devicedetect,varnish\/varnish-devicedetect,wikp\/varnish-devicedetect,varnish\/varnish-devicedetect,wikp\/varnish-devicedetect,kevinquinnyo\/varnish-devicedetect","old_file":"devicedetect.vcl","new_file":"devicedetect.vcl","new_contents":"#\n# detectdevice.vcl - regex based device detection for Varnish\n# http:\/\/github.com\/varnish\/varnish-devicedetect\/\n#\n# Author: Lasse Karstensen <lasse@varnish-software.com>\n\nsub devicedetect {\n\tunset req.http.X-UA-Device;\n\tset req.http.X-UA-Device = \"pc\";\n\n\t# Handle that a cookie may override the detection alltogether.\n\tif (req.http.Cookie ~ \"(?i)X-UA-Device-force\") {\n\t\t\/* ;?? means zero or one ;, non-greedy to match the first. *\/\n\t\tset req.http.X-UA-Device = regsub(req.http.Cookie, \"(?i).*X-UA-Device-force=([^;]+);??.*\", \"\\1\");\n\t\t\/* Clean up our mess in the cookie header *\/\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|; ) *X-UA-Device-force=[^;]+;? *\", \"\\1\");\n\t\t\/* If the cookie header is now empty, or just whitespace, unset it. *\/\n\t\tif (req.http.Cookie ~ \"^ *$\") { unset req.http.Cookie; }\n\t} else {\n\t\tif (req.http.User-Agent ~ \"(?i)(ads|google|bing|msn|yandex|baidu|ro|career|)bot\" ||\n\t\t req.http.User-Agent ~ \"(?i)(baidu|jike|symantec)spider\" ||\n\t\t req.http.User-Agent ~ \"(?i)scanner\" ||\n\t\t req.http.User-Agent ~ \"(?i)(web)crawler\") {\n\t\t\tset req.http.X-UA-Device = \"bot\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ip(hone|od)\") { set req.http.X-UA-Device = \"mobile-iphone\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ipad\") { set req.http.X-UA-Device = \"tablet-ipad\"; }\n\t\t\/* how do we differ between an android phone and an android tablet?\n\t\t http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent *\/\n\t\telsif (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") { set req.http.X-UA-Device = \"mobile-android\"; }\n\t\t\/\/ android 3\/honeycomb was just about tablet-only, and any phones will probably handle a bigger page layout.\n\t\telsif (req.http.User-Agent ~ \"(?i)android 3\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\t\/\/ May very well give false positives towards android tablets. Suggestions welcome.\n\t\telsif (req.http.User-Agent ~ \"(?i)android\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\telsif (req.http.User-Agent ~ \"Mobile.+Firefox\") { set req.http.X-UA-Device = \"mobile-firefoxos\"; }\n\t\telsif (req.http.User-Agent ~ \"^HTC\" ||\n\t\t req.http.User-Agent ~ \"Fennec\" ||\n\t\t req.http.User-Agent ~ \"IEMobile\" ||\n\t\t req.http.User-Agent ~ \"BlackBerry\" ||\n\t\t req.http.User-Agent ~ \"SymbianOS.*AppleWebKit\" ||\n\t\t req.http.User-Agent ~ \"Opera Mobi\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-smartphone\";\n\t\t}\n\t\telsif (req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)^sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)^nokia\" ||\n\t\t req.http.User-Agent ~ \"(?i)^samsung\" ||\n\t\t req.http.User-Agent ~ \"(?i)^lg\" ||\n\t\t req.http.User-Agent ~ \"(?i)bada\" ||\n\t\t req.http.User-Agent ~ \"(?i)blazer\" ||\n\t\t req.http.User-Agent ~ \"(?i)cellphone\" ||\n\t\t req.http.User-Agent ~ \"(?i)iemobile\" ||\n\t\t req.http.User-Agent ~ \"(?i)midp-2.0\" ||\n\t\t req.http.User-Agent ~ \"(?i)u990\" ||\n\t\t req.http.User-Agent ~ \"(?i)netfront\" ||\n\t\t req.http.User-Agent ~ \"(?i)opera mini\" ||\n\t\t req.http.User-Agent ~ \"(?i)palm\" ||\n\t\t req.http.User-Agent ~ \"(?i)nintendo wii\" ||\n\t\t req.http.User-Agent ~ \"(?i)playstation portable\" ||\n\t\t req.http.User-Agent ~ \"(?i)portalmmm\" ||\n\t\t req.http.User-Agent ~ \"(?i)proxinet\" ||\n\t\t req.http.User-Agent ~ \"(?i)sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)windows\\ ?ce\" ||\n\t\t req.http.User-Agent ~ \"(?i)winwap\" ||\n\t\t req.http.User-Agent ~ \"(?i)eudoraweb\" ||\n\t\t req.http.User-Agent ~ \"(?i)htc\" ||\n\t\t req.http.User-Agent ~ \"(?i)240x320\" ||\n\t\t req.http.User-Agent ~ \"(?i)avantgo\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-generic\";\n\t\t}\n\t}\n}\n(\n","old_contents":"#\n# detectdevice.vcl - regex based device detection for Varnish\n# http:\/\/github.com\/varnish\/varnish-devicedetect\/\n#\n# Author: Lasse Karstensen <lasse@varnish-software.com>\n\nsub devicedetect {\n\tunset req.http.X-UA-Device;\n\tset req.http.X-UA-Device = \"pc\";\n\n\t# Handle that a cookie may override the detection alltogether.\n\tif (req.http.Cookie ~ \"(?i)X-UA-Device-force\") {\n\t\t\/* ;?? means zero or one ;, non-greedy to match the first. *\/\n\t\tset req.http.X-UA-Device = regsub(req.http.Cookie, \"(?i).*X-UA-Device-force=([^;]+);??.*\", \"\\1\");\n\t\t\/* Clean up our mess in the cookie header *\/\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|; ) *X-UA-Device-force=[^;]+;? *\", \"\\1\");\n\t\t\/* If the cookie header is now empty, or just whitespace, unset it. *\/\n\t\tif (req.http.Cookie ~ \"^ *$\") { unset req.http.Cookie; }\n\t} else {\n\t\tif (req.http.User-Agent ~ \"(?i)(ads|google|bing|msn|yandex|baidu|ro|career|)bot\" ||\n\t\t req.http.User-Agent ~ \"(?i)(baidu|jike|symantec)spider\" ||\n\t\t req.http.User-Agent ~ \"(?i)scanner\" ||\n\t\t req.http.User-Agent ~ \"(?i)(web)crawler\") {\n\t\t\tset req.http.X-UA-Device = \"bot\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ip(hone|od)\") { set req.http.X-UA-Device = \"mobile-iphone\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ipad\") { set req.http.X-UA-Device = \"tablet-ipad\"; }\n\t\t\/* how do we differ between an android phone and an android tablet?\n\t\t http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent *\/\n\t\telsif (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") { set req.http.X-UA-Device = \"mobile-android\"; }\n\t\t\/\/ android 3\/honeycomb was just about tablet-only, and any phones will probably handle a bigger page layout.\n\t\telsif (req.http.User-Agent ~ \"(?i)android 3\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\t\/\/ May very well give false positives towards android tablets. Suggestions welcome.\n\t\telsif (req.http.User-Agent ~ \"(?i)android\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\telsif (req.http.User-Agent ~ \"^HTC\" ||\n\t\t req.http.User-Agent ~ \"Fennec\" ||\n\t\t req.http.User-Agent ~ \"IEMobile\" ||\n\t\t req.http.User-Agent ~ \"BlackBerry\" ||\n\t\t req.http.User-Agent ~ \"SymbianOS.*AppleWebKit\" ||\n\t\t req.http.User-Agent ~ \"Opera Mobi\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-smartphone\";\n\t\t}\n\t\telsif (req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)^sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)^nokia\" ||\n\t\t req.http.User-Agent ~ \"(?i)^samsung\" ||\n\t\t req.http.User-Agent ~ \"(?i)^lg\" ||\n\t\t req.http.User-Agent ~ \"(?i)bada\" ||\n\t\t req.http.User-Agent ~ \"(?i)blazer\" ||\n\t\t req.http.User-Agent ~ \"(?i)cellphone\" ||\n\t\t req.http.User-Agent ~ \"(?i)iemobile\" ||\n\t\t req.http.User-Agent ~ \"(?i)midp-2.0\" ||\n\t\t req.http.User-Agent ~ \"(?i)u990\" ||\n\t\t req.http.User-Agent ~ \"(?i)netfront\" ||\n\t\t req.http.User-Agent ~ \"(?i)opera mini\" ||\n\t\t req.http.User-Agent ~ \"(?i)palm\" ||\n\t\t req.http.User-Agent ~ \"(?i)nintendo wii\" ||\n\t\t req.http.User-Agent ~ \"(?i)playstation portable\" ||\n\t\t req.http.User-Agent ~ \"(?i)portalmmm\" ||\n\t\t req.http.User-Agent ~ \"(?i)proxinet\" ||\n\t\t req.http.User-Agent ~ \"(?i)sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)windows\\ ?ce\" ||\n\t\t req.http.User-Agent ~ \"(?i)winwap\" ||\n\t\t req.http.User-Agent ~ \"(?i)eudoraweb\" ||\n\t\t req.http.User-Agent ~ \"(?i)htc\" ||\n\t\t req.http.User-Agent ~ \"(?i)240x320\" ||\n\t\t req.http.User-Agent ~ \"(?i)avantgo\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-generic\";\n\t\t}\n\t}\n}\n\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"a466e52ea53b95367080c084f972ef9cd18f6e20","subject":"Fix indentation","message":"Fix indentation\n","repos":"varnish\/varnish-devicedetect,varnish\/varnish-devicedetect","old_file":"samesite.vcl","new_file":"samesite.vcl","new_contents":"sub samesite {\n # See list here:\n # https:\/\/www.chromium.org\/updates\/same-site\/incompatible-clients\n unset req.http.X-UA-SameSiteNone;\n set req.http.X-UA-SameSiteNone = \"supported\";\n\n # Versions of Chrome from Chrome 51 to Chrome 66 (inclusive on both ends). These Chrome versions will reject a cookie with `SameSite=None`\n if (req.http.user-agent ~ \"Chrom(e|ium)\" &&\n (req.http.user-agent ~ \"Chrom[^ \\\/]+\\\/5[1-9][\\.\\d]*\" ||\n req.http.user-agent ~ \"Chrom[^ \\\/]+\\\/6[0-6][\\.\\d]*\")) {\n set req.http.X-UA-SameSiteNone = \"unsupported\";\n }\n\n # Versions of UC Browser on Android prior to version 12.13.2. Older versions will reject a cookie with `SameSite=None`\n if (req.http.user-agent ~ \"UCBrowser\\\/\" && (req.http.user-agent ~ \"UCBrowser\\\/[0-9]\\.\\d+\\.\\d+[\\.\\d]*\" || req.http.user-agent ~ \"UCBrowser\\\/1[0-1]\\.\\d+\\.\\d+[\\.\\d]*\" ||\n req.http.user-agent ~ \"UCBrowser\\\/12\\.[0-9]\\.\\d+[\\.\\d]*\" || req.http.user-agent ~ \"UCBrowser\\\/12\\.1[0-2]\\.\\d+[\\.\\d]*\" || req.http.user-agent ~ \"UCBrowser\\\/12\\.13\\.[0-1][\\.\\d]*\")) {\n set req.http.X-UA-SameSiteNone = \"unsupported\";\n }\n\n #######################\n # hasWebKitSameSiteBug:\n #\n # all browsers on iOS 12\n if (req.http.user-agent ~ \"\\(iP.+; CPU .*OS 12[_\\d]*.*\\) AppleWebKit\\\/\") {\n set req.http.X-UA-SameSiteNone = \"unsupported\";\n }\n # Safari & embedded browsers on MacOS 10.14\n if (req.http.user-agent ~ \"\\(Macintosh;.*Mac OS X 10_14[_\\d]*.*\\) AppleWebKit\\\/\") {\n # isSafari\n # ||\n # isMacEmbeddedBrowser\n if ((req.http.user-agent ~ \"Version\\\/.* Safari\\\/\" && req.http.user-agent !~ \"Chrom(e|ium)\") ||\n (req.http.user-agent ~ \"^Mozilla\\\/[\\.\\d]+ \\(Macintosh;.*Mac OS X [_\\d]+\\) AppleWebKit\\\/[\\.\\d]+ \\(KHTML, like Gecko\\)$\")) {\n set req.http.X-UA-SameSiteNone = \"unsupported\";\n }\n }\n}\n","old_contents":"sub samesite {\n # See list here:\n # https:\/\/www.chromium.org\/updates\/same-site\/incompatible-clients\n unset req.http.X-UA-SameSiteNone;\n set req.http.X-UA-SameSiteNone = \"supported\";\n\n # Versions of Chrome from Chrome 51 to Chrome 66 (inclusive on both ends). These Chrome versions will reject a cookie with `SameSite=None`\n if (req.http.user-agent ~ \"Chrom(e|ium)\" &&\n (req.http.user-agent ~ \"Chrom[^ \\\/]+\\\/5[1-9][\\.\\d]*\" ||\n req.http.user-agent ~ \"Chrom[^ \\\/]+\\\/6[0-6][\\.\\d]*\")) {\n set req.http.X-UA-SameSiteNone = \"unsupported\";\n }\n\n # Versions of UC Browser on Android prior to version 12.13.2. Older versions will reject a cookie with `SameSite=None`\n if (req.http.user-agent ~ \"UCBrowser\\\/\" && (req.http.user-agent ~ \"UCBrowser\\\/[0-9]\\.\\d+\\.\\d+[\\.\\d]*\" || req.http.user-agent ~ \"UCBrowser\\\/1[0-1]\\.\\d+\\.\\d+[\\.\\d]*\" ||\n req.http.user-agent ~ \"UCBrowser\\\/12\\.[0-9]\\.\\d+[\\.\\d]*\" || req.http.user-agent ~ \"UCBrowser\\\/12\\.1[0-2]\\.\\d+[\\.\\d]*\" || req.http.user-agent ~ \"UCBrowser\\\/12\\.13\\.[0-1][\\.\\d]*\")) {\n set req.http.X-UA-SameSiteNone = \"unsupported\";\n }\n\n #######################\n # hasWebKitSameSiteBug:\n #\n # all browsers on iOS 12\n if (req.http.user-agent ~ \"\\(iP.+; CPU .*OS 12[_\\d]*.*\\) AppleWebKit\\\/\") {\n set req.http.X-UA-SameSiteNone = \"unsupported\";\n }\n # Safari & embedded browsers on MacOS 10.14\n if (req.http.user-agent ~ \"\\(Macintosh;.*Mac OS X 10_14[_\\d]*.*\\) AppleWebKit\\\/\") {\n # isSafari\n # ||\n # isMacEmbeddedBrowser\n if ((req.http.user-agent ~ \"Version\\\/.* Safari\\\/\" && req.http.user-agent !~ \"Chrom(e|ium)\") ||\n (req.http.user-agent ~ \"^Mozilla\\\/[\\.\\d]+ \\(Macintosh;.*Mac OS X [_\\d]+\\) AppleWebKit\\\/[\\.\\d]+ \\(KHTML, like Gecko\\)$\")) {\n set req.http.X-UA-SameSiteNone = \"unsupported\";\n }\n }\n}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"3658ca3d3d016a26fd012a307aacc329ccd514d0","subject":"Fix #1865","message":"Fix #1865\n","repos":"JakeChampion\/polyfill-service,JakeChampion\/polyfill-service","old_file":"fastly\/vcl\/polyfill-service.vcl","new_file":"fastly\/vcl\/polyfill-service.vcl","new_contents":"sub set_backend {\n\t# Calculate the ideal region to route the request to.\n\tdeclare local var.region STRING;\n\tif (server.region ~ \"(APAC|Asia|North-America|South-America|US-Central|US-East|US-West)\") {\n\t\tset var.region = \"US\";\n\t} else {\n\t\tset var.region = \"EU\";\n\t}\n\n\t# Gather the health of the shields and origins.\n\tdeclare local var.v3_eu_is_healthy BOOL;\n\tset req.backend = F_v3_eu;\n\tset var.v3_eu_is_healthy = req.backend.healthy;\n\n\tdeclare local var.v3_us_is_healthy BOOL;\n\tset req.backend = F_v3_us;\n\tset var.v3_us_is_healthy = req.backend.healthy;\n\n\t# Set some sort of default, that shouldn't get used.\n\tset req.backend = F_v3_eu;\n\n\t# Route EU requests to the nearest healthy shield or origin.\n\tif (var.region == \"EU\") {\n\t\tif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_eu;\n\t\t}\n\t}\n\n\t# Route US requests to the nearest healthy shield or origin.\n\tif (var.region == \"US\") {\n\t\tif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_us;\n\t\t}\n\t}\n\n\t# Persist the decision so we can debug the result.\n\tset req.http.Debug-Backend = req.backend;\n\n\t# The Fastly macro is inserted after the backend is selected because the\n\t# macro has the code to select the correct req.http.Host value based on the backend.\n\t#FASTLY recv\n}\n\nsub vcl_recv {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_recv;\n\t}\n\n\tif (req.method != \"GET\" && req.method != \"HEAD\" && req.method != \"OPTIONS\" && req.method != \"FASTLYPURGE\" && req.method != \"PURGE\") {\n\t\terror 911;\n\t}\n\n\tif (req.method == \"OPTIONS\") {\n\t\terror 912;\n\t}\n\n\t# Because the old service had a router which allowed any words between \/v2\/polyfill. and .js\n\tif (req.url ~ \"^\/v2\/polyfill(\\.\\w+)?\\.js\") {\n\t\tset req.url = regsub(req.url, \"^\/v2\/polyfill(\\.\\w+)?\\.js\", \"\/v2\/polyfill.min.js\");\n\t}\n\n\t# Override the v3 defaults with the defaults of v2\n\tif (req.url ~ \"^\/v2\/polyfill(\\.min)?\\.js\") {\n\t\tset req.url = regsub(req.url, \"^\/v2\", \"\/v3\");\n\t\tset req.url = querystring.set(req.url, \"version\", \"3.25.1\");\n\t\tdeclare local var.unknown STRING;\n\t\tset var.unknown = subfield(req.url.qs, \"unknown\", \"&\");\n\t\tset req.url = querystring.set(req.url, \"unknown\", if(var.unknown != \"\", var.unknown, \"ignore\"));\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\") {\n\t\tcall normalise_querystring_parameters_for_polyfill_bundle;\n\t}\n\n\t# Sort the querystring parameters alphabetically to improve chances of hitting a cached copy.\n\t# If querystring is empty, remove the ? from the url.\n\tset req.url = querystring.clean(querystring.sort(req.url));\n\tcall set_backend;\n}\n\nsub vcl_hash {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_hash;\n\t}\n\n\t# We are not adding req.http.host to the hash because we want https:\/\/cdn.polyfill.io and https:\/\/polyfill.io to be a single object in the cache.\n\t# set req.hash += req.http.host;\n\tset req.hash += req.url;\n\t# We include return(hash) to stop the function falling through to the default VCL built into varnish, which for vcl_hash will add req.url and req.http.Host to the hash.\n\treturn(hash);\n}\n\nsub vcl_miss {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_miss;\n\t}\n}\n\nsub vcl_pass {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_pass;\n\t}\n}\n\nsub vcl_fetch {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_fetch;\n\t}\n\n\t# These header are only required for HTML documents.\n\tif (beresp.http.Content-Type ~ \"text\/html\") {\n\t\t# Enables the cross-site scripting filter built into most modern web browsers.\n\t\tset beresp.http.X-XSS-Protection = \"1; mode=block\";\t\n\n\t\t# Allow only content from the site's own origin (this excludes subdomains) and www.ft.com.\n\t\t# Don't allow the website to be used within an iframe\n\t\tif (!beresp.http.Content-Security-Policy) {\n\t\t\tset beresp.http.Content-Security-Policy = \"default-src 'self'; font-src 'self' https:\/\/www.ft.com; img-src 'self' https:\/\/www.ft.com; frame-ancestors 'none'; base-uri 'self'; form-action 'self'\";\n\t\t}\n\t}\n\t# Prevents MIME-sniffing a response away from the declared content type.\n\tset beresp.http.X-Content-Type-Options = \"nosniff\";\n\n\t# Ensure the site is only served over HTTPS and reduce the chances of someone performing a MITM attack.\n\tset beresp.http.Strict-Transport-Security = \"max-age=31536000; includeSubdomains; preload\";\n\n\t# The Referrer-Policy header governs which referrer information, sent in the Referer header, should be included with requests made.\n\t# Send a full URL when performing a same-origin request, but only send the origin of the document for other cases.\n\tset beresp.http.Referrer-Policy = \"origin-when-cross-origin\";\n\n\t# Enable purging of all objects in the Fastly cache by issuing a purge with the key \"polyfill-service\".\n\tif (beresp.http.Surrogate-Key !~ \"\\bpolyfill-service\\b\") {\n\t\tset beresp.http.Surrogate-Key = if(beresp.http.Surrogate-Key, beresp.http.Surrogate-Key \" polyfill-service\", \"polyfill-service\");\n\t}\n\n\tset beresp.http.Timing-Allow-Origin = \"*\";\n\n\tif (req.http.Normalized-User-Agent) {\n\t\tset beresp.http.Normalized-User-Agent = req.http.Normalized-User-Agent;\n\t\tset beresp.http.Detected-User-Agent = req.http.useragent_parser_family \"\/\" req.http.useragent_parser_major \".\" req.http.useragent_parser_minor \".\" req.http.useragent_parser_patch;\n\t}\n}\n\nsub vcl_deliver {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_deliver;\n\t}\n\n\tset req.http.Fastly-Force-Shield = \"yes\";\n\n\t# Allow cross origin GET, HEAD, and OPTIONS requests to be made.\n\tif (req.http.Origin) {\n\t\tset resp.http.Access-Control-Allow-Origin = \"*\";\n\t\tset resp.http.Access-Control-Allow-Methods = \"GET,HEAD,OPTIONS\";\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\") {\n\t\t# Need to add \"Vary: User-Agent\" in after vcl_fetch to avoid the \n\t\t# \"Vary: User-Agent\" entering the Varnish cache.\n\t\t# We need \"Vary: User-Agent\" in the browser cache because a browser\n\t\t# may update itself to a version which needs different polyfills\n\t\t# So we need to have it ignore the browser cached bundle when the user-agent changes.\n\t\tadd resp.http.Vary = \"User-Agent\";\n\t\tadd resp.http.Vary = \"Accept-Encoding\";\n\t}\n\n\tadd resp.http.Server-Timing = fastly_info.state {\", fastly;desc=\"Edge time\";dur=\"} time.elapsed.msec;\n\n\tif (req.http.Fastly-Debug) {\n\t\tset resp.http.Debug-Backend = req.http.Debug-Backend;\n\t\tset resp.http.Debug-Host = req.http.Host;\n\t\tset resp.http.Debug-Fastly-Restarts = req.restarts;\n\t\tset resp.http.Debug-Orig-URL = req.http.Orig-URL;\n\t\tset resp.http.Debug-VCL-Route = req.http.X-VCL-Route;\n\t\tset resp.http.useragent_parser_family = req.http.useragent_parser_family;\n\t\tset resp.http.useragent_parser_major = req.http.useragent_parser_major;\n\t\tset resp.http.useragent_parser_minor = req.http.useragent_parser_minor;\n\t\tset resp.http.useragent_parser_patch = req.http.useragent_parser_patch;\n\t} else {\n\t\tunset resp.http.Server;\n\t\tunset resp.http.Via;\n\t\tunset resp.http.X-Cache;\n\t\tunset resp.http.X-Cache-Hits;\n\t\tunset resp.http.X-Served-By;\n\t\tunset resp.http.X-Timer;\n\t\tunset resp.http.Fastly-Restarts;\n\t}\n}\n\nsub vcl_error {\n\tif (obj.status == 911) {\n\t\tset obj.status = 405;\n\t\tset obj.response = \"METHOD NOT ALLOWED\";\n\t\tset obj.http.Content-Type = \"text\/html; charset=utf-8\";\n\t\tset obj.http.Cache-Control = \"private, no-store\";\n\t\tsynthetic req.method \" METHOD NOT ALLOWED\";\n\t\treturn (deliver);\n\t}\n\tif (obj.status == 912) {\n\t\tset obj.status = 200;\n\t\tset obj.response = \"OK\";\n\t\tset obj.http.Allow = \"OPTIONS, GET, HEAD\";\n\t\treturn (deliver);\n\t}\n}\n","old_contents":"sub set_backend {\n\t# Calculate the ideal region to route the request to.\n\tdeclare local var.region STRING;\n\tif (server.region ~ \"(APAC|Asia|North-America|South-America|US-Central|US-East|US-West)\") {\n\t\tset var.region = \"US\";\n\t} else {\n\t\tset var.region = \"EU\";\n\t}\n\n\t# Gather the health of the shields and origins.\n\tdeclare local var.v3_eu_is_healthy BOOL;\n\tset req.backend = F_v3_eu;\n\tset var.v3_eu_is_healthy = req.backend.healthy;\n\n\tdeclare local var.v3_us_is_healthy BOOL;\n\tset req.backend = F_v3_us;\n\tset var.v3_us_is_healthy = req.backend.healthy;\n\n\t# Set some sort of default, that shouldn't get used.\n\tset req.backend = F_v3_eu;\n\n\t# Route EU requests to the nearest healthy shield or origin.\n\tif (var.region == \"EU\") {\n\t\tif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_eu;\n\t\t}\n\t}\n\n\t# Route US requests to the nearest healthy shield or origin.\n\tif (var.region == \"US\") {\n\t\tif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_us;\n\t\t}\n\t}\n\n\t# Persist the decision so we can debug the result.\n\tset req.http.Debug-Backend = req.backend;\n\n\t# The Fastly macro is inserted after the backend is selected because the\n\t# macro has the code to select the correct req.http.Host value based on the backend.\n\t#FASTLY recv\n}\n\nsub vcl_recv {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_recv;\n\t}\n\n\tif (req.method != \"GET\" && req.method != \"HEAD\" && req.method != \"OPTIONS\" && req.method != \"FASTLYPURGE\" && req.method != \"PURGE\") {\n\t\terror 911;\n\t}\n\n\tif (req.method == \"OPTIONS\") {\n\t\terror 912;\n\t}\n\n\t# Override the v3 defaults with the defaults of v2\n\tif (req.url ~ \"^\/v2\/polyfill(\\.min)?\\.js\") {\n\t\tset req.url = regsub(req.url, \"^\/v2\", \"\/v3\");\n\t\tset req.url = querystring.set(req.url, \"version\", \"3.25.1\");\n\t\tdeclare local var.unknown STRING;\n\t\tset var.unknown = subfield(req.url.qs, \"unknown\", \"&\");\n\t\tset req.url = querystring.set(req.url, \"unknown\", if(var.unknown != \"\", var.unknown, \"ignore\"));\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\") {\n\t\tcall normalise_querystring_parameters_for_polyfill_bundle;\n\t}\n\n\t# Sort the querystring parameters alphabetically to improve chances of hitting a cached copy.\n\t# If querystring is empty, remove the ? from the url.\n\tset req.url = querystring.clean(querystring.sort(req.url));\n\tcall set_backend;\n}\n\nsub vcl_hash {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_hash;\n\t}\n\n\t# We are not adding req.http.host to the hash because we want https:\/\/cdn.polyfill.io and https:\/\/polyfill.io to be a single object in the cache.\n\t# set req.hash += req.http.host;\n\tset req.hash += req.url;\n\t# We include return(hash) to stop the function falling through to the default VCL built into varnish, which for vcl_hash will add req.url and req.http.Host to the hash.\n\treturn(hash);\n}\n\nsub vcl_miss {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_miss;\n\t}\n}\n\nsub vcl_pass {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_pass;\n\t}\n}\n\nsub vcl_fetch {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_fetch;\n\t}\n\n\t# These header are only required for HTML documents.\n\tif (beresp.http.Content-Type ~ \"text\/html\") {\n\t\t# Enables the cross-site scripting filter built into most modern web browsers.\n\t\tset beresp.http.X-XSS-Protection = \"1; mode=block\";\t\n\n\t\t# Allow only content from the site's own origin (this excludes subdomains) and www.ft.com.\n\t\t# Don't allow the website to be used within an iframe\n\t\tif (!beresp.http.Content-Security-Policy) {\n\t\t\tset beresp.http.Content-Security-Policy = \"default-src 'self'; font-src 'self' https:\/\/www.ft.com; img-src 'self' https:\/\/www.ft.com; frame-ancestors 'none'; base-uri 'self'; form-action 'self'\";\n\t\t}\n\t}\n\t# Prevents MIME-sniffing a response away from the declared content type.\n\tset beresp.http.X-Content-Type-Options = \"nosniff\";\n\n\t# Ensure the site is only served over HTTPS and reduce the chances of someone performing a MITM attack.\n\tset beresp.http.Strict-Transport-Security = \"max-age=31536000; includeSubdomains; preload\";\n\n\t# The Referrer-Policy header governs which referrer information, sent in the Referer header, should be included with requests made.\n\t# Send a full URL when performing a same-origin request, but only send the origin of the document for other cases.\n\tset beresp.http.Referrer-Policy = \"origin-when-cross-origin\";\n\n\t# Enable purging of all objects in the Fastly cache by issuing a purge with the key \"polyfill-service\".\n\tif (beresp.http.Surrogate-Key !~ \"\\bpolyfill-service\\b\") {\n\t\tset beresp.http.Surrogate-Key = if(beresp.http.Surrogate-Key, beresp.http.Surrogate-Key \" polyfill-service\", \"polyfill-service\");\n\t}\n\n\tset beresp.http.Timing-Allow-Origin = \"*\";\n\n\tif (req.http.Normalized-User-Agent) {\n\t\tset beresp.http.Normalized-User-Agent = req.http.Normalized-User-Agent;\n\t\tset beresp.http.Detected-User-Agent = req.http.useragent_parser_family \"\/\" req.http.useragent_parser_major \".\" req.http.useragent_parser_minor \".\" req.http.useragent_parser_patch;\n\t}\n}\n\nsub vcl_deliver {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_deliver;\n\t}\n\n\tset req.http.Fastly-Force-Shield = \"yes\";\n\n\t# Allow cross origin GET, HEAD, and OPTIONS requests to be made.\n\tif (req.http.Origin) {\n\t\tset resp.http.Access-Control-Allow-Origin = \"*\";\n\t\tset resp.http.Access-Control-Allow-Methods = \"GET,HEAD,OPTIONS\";\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\") {\n\t\t# Need to add \"Vary: User-Agent\" in after vcl_fetch to avoid the \n\t\t# \"Vary: User-Agent\" entering the Varnish cache.\n\t\t# We need \"Vary: User-Agent\" in the browser cache because a browser\n\t\t# may update itself to a version which needs different polyfills\n\t\t# So we need to have it ignore the browser cached bundle when the user-agent changes.\n\t\tadd resp.http.Vary = \"User-Agent\";\n\t\tadd resp.http.Vary = \"Accept-Encoding\";\n\t}\n\n\tadd resp.http.Server-Timing = fastly_info.state {\", fastly;desc=\"Edge time\";dur=\"} time.elapsed.msec;\n\n\tif (req.http.Fastly-Debug) {\n\t\tset resp.http.Debug-Backend = req.http.Debug-Backend;\n\t\tset resp.http.Debug-Host = req.http.Host;\n\t\tset resp.http.Debug-Fastly-Restarts = req.restarts;\n\t\tset resp.http.Debug-Orig-URL = req.http.Orig-URL;\n\t\tset resp.http.Debug-VCL-Route = req.http.X-VCL-Route;\n\t\tset resp.http.useragent_parser_family = req.http.useragent_parser_family;\n\t\tset resp.http.useragent_parser_major = req.http.useragent_parser_major;\n\t\tset resp.http.useragent_parser_minor = req.http.useragent_parser_minor;\n\t\tset resp.http.useragent_parser_patch = req.http.useragent_parser_patch;\n\t} else {\n\t\tunset resp.http.Server;\n\t\tunset resp.http.Via;\n\t\tunset resp.http.X-Cache;\n\t\tunset resp.http.X-Cache-Hits;\n\t\tunset resp.http.X-Served-By;\n\t\tunset resp.http.X-Timer;\n\t\tunset resp.http.Fastly-Restarts;\n\t}\n}\n\nsub vcl_error {\n\tif (obj.status == 911) {\n\t\tset obj.status = 405;\n\t\tset obj.response = \"METHOD NOT ALLOWED\";\n\t\tset obj.http.Content-Type = \"text\/html; charset=utf-8\";\n\t\tset obj.http.Cache-Control = \"private, no-store\";\n\t\tsynthetic req.method \" METHOD NOT ALLOWED\";\n\t\treturn (deliver);\n\t}\n\tif (obj.status == 912) {\n\t\tset obj.status = 200;\n\t\tset obj.response = \"OK\";\n\t\tset obj.http.Allow = \"OPTIONS, GET, HEAD\";\n\t\treturn (deliver);\n\t}\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"b8cafd21688cd4460cea9d380e16a9c84ae1a492","subject":"enable X-Forwarded-Proto chache bucketing out-of-the-box","message":"enable X-Forwarded-Proto chache bucketing out-of-the-box\n","repos":"NITEMAN\/varnish-bites,NITEMAN\/Varnish_VCL_samps-hacks","old_file":"varnish3\/drupal-base.vcl","new_file":"varnish3\/drupal-base.vcl","new_contents":"\/* Varnish 3 example config for Drupal 7 \/ Pressflow 6 & 7 *\/\n# Original source: https:\/\/github.com\/NITEMAN\/varnish-bites\/varnish4\/drupal-base.vcl\n# Copyright (c) 2015 Pedro Gonz\u00e1lez Serrano and individual contributors.\n# MIT License\n\n# Intended to be used both in simple production environments and with learning\/teaching purposes.\n# Loosely based on http:\/\/www.lullabot.com\/sites\/default\/files\/default_varnish3.vcl_.txt\n\n\/* Backend probes \/ healthchecks *\/\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#backend-probes\nprobe basic {\n \/* Only test that backend's IP serves content for '\/' *\/\n # This might be a too heavy probe\n # .url = \"\/\";\n \/* Only test that backend's IP has apache working *\/\n # Nginx would fail this probe with a default config\n .request =\n \"OPTIONS * HTTP\/1.1\"\n \"Host: *\"\n \"Connection: close\";\n .interval = 10s;\n .timeout = 2s;\n .window = 8;\n .threshold = 6;\n}\n\n\n\/* Backend definitions.*\/\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#backend-declarations\nbackend default {\n \/* Default backend on the same machine. WARNING: timeouts could be not big enought for certain POST request *\/\n .host = \"127.0.0.1\";\n .port = \"8008\";\n .connect_timeout = 60s;\n .first_byte_timeout = 60s;\n .between_bytes_timeout = 60s;\n .probe = basic;\n}\n\n\n\/* Directors. *\/\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#directors\n# Empty in simple configs\n\n\n\/* Access Control Lists *\/\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#acls\nacl purge_ban {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use '\"localhost\";' instead\n}\nacl allowed_monitors {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n}\nacl own_proxys {\n \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n}\n\n\n\/* Custom routines *\/\n# Empty in simple configs.\n# We can name subs with no restrictions but as a task can need several chunks of code in diferent states,\n# it's a good idea to identify what main sub will call each with a suffix.\n# \/* Example 301 client redirection removing \"www\" prefix from request *\/\n# sub perm_redirections_recv {\n# if ( req.http.host ~ \"^www.*$\" ) {\n# error 751 \"http:\/\/\" + regsub(req.http.host, \"^www\\.\", \"\") + req.url;\n# }\n# }\n# sub perm_redirections_error {\n# if (obj.status == 751) {\n# \/* Get new URL from the response *\/\n# set obj.http.Location = obj.response;\n# \/* Set HTTP 301 for permanent redirect *\/\n# set obj.status = 301;\n# return(deliver);\n# }\n# }\n\n\n\/* VCL logigc overrides *\/\n# Note that the built-in logic will be appended to our code if no return is performed before.\n# Built-in logic is included commented out right after our's for reference purposes in that cases.\n# See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleDefault\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#subroutines\n\n# vcl_recv: Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use.\nsub vcl_recv {\n \/* 0th: general bypass, general return & authorization checks *\/\n # Empty in simple configs.\n # Useful for debugging we can pipe or pass the request to default backend here to bypass completely Varnish.\n # return (pipe);\n # return (pass);\n # We can also return here a 200 Ok for network performance benchmarking.\n # error 200 \"Ok\";\n # Finally we can perform basic HTTP authentification here by example.\n # See http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* 1st: Check for Varnish special requests *\/ \n # Purge logic.\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/purging.html#http-purges\n # See https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if (req.request == \"PURGE\") {\n if (!client.ip ~ purge_ban) {\n error 405 \"Not allowed.\";\n }\n return (lookup);\n }\n # Ban logic. See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/purging.html#bans\n if (req.request == \"BAN\") {\n if (!client.ip ~ purge_ban) {\n error 405 \"Not allowed.\";\n }\n ban(\"req.http.host == \" + req.http.host +\n \"&& req.url == \" + req.url); \n error 200 \"Ban added\";\n }\n # Custom response implementation example in order to check that Varnish is working properly.\n # This is usefull for automatic monitoring with monit or when Varnish is behind another proxies like HAProxy.\n if ( ( req.http.host == \"monitor.server.health\"\n || req.http.host == \"health.varnish\" )\n && client.ip ~ allowed_monitors\n && ( req.request == \"OPTIONS\" || req.request == \"GET\" )\n ) {\n error 200 \"Ok\";\n }\n\n \/* 2nd: Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_recv;\n # Here we can also enforce SSL when Varnish run behind some SSL termination point.\n\n \/* 3rd: Time for backend choice *\/\n # Empty in simple configs.\n\n \/* 4th: Set custom headers for backend like X-Forwarded-For (copied from built-in logic) *\/\n if ( req.restarts == 0 ) {\n \/* See also vcl_pipe section *\/\n if ( ! client.ip ~ own_proxys ) {\n if ( req.http.x-forwarded-for ) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n }\n\n \/* 5th: Bypass breakpoint 1 *\/\n # Useful for debugging we can now pipe or pass the request to backend with headers setted.\n # return (pipe);\n # return (pass);\n\n \/* 6th: Decide if we should deal with a request (mostly copied from built-in logic) *\/\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n\n \/* 7th: Access control for some URLs by ACL *\/\n # Empty in simple configs.\n # By example denial some URLs depending on client-ip, we'll need to define corresponding ACL 'internal'.\n # if (req.url ~ \"^\/(cron|install)\\.php$\" && !client.ip ~ internal) {\n # # Have Varnish throw the error directly.\n # error 403 \"Forbidden.\";\n # # Use a custom error page that you've defined in Drupal at the path \"404\".\n # # set req.url = \"\/403\";\n # }\n\n \/* 8th: Custom exceptions *\/\n # Host exception example:\n # if (req.http.host == \"ejemplo.exception.com\") {\n # return (pass);\n # }\n # Drupal exceptions, edit if we want to cache some AJAX\/AHAH request.\n # Add here filters for never cache URLs such as Payment Gateway's callbacks\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/ooyala\/ping$\" ||\n req.url ~ \"^\/admin\/build\/features\" ||\n req.url ~ \"^\/info\/.*$\" ||\n req.url ~ \"^\/flag\/.*$\" ||\n req.url ~ \"^.*\/ajax\/.*$\" ||\n req.url ~ \"^.*\/ahah\/.*$\") {\n \/* Do not cache these paths *\/\n return (pass);\n }\n # Pipe these paths directly to backend for streaming.\n if (req.url ~ \"^\/admin\/content\/backup_migrate\/export\") {\n return (pipe);\n }\n if (req.url ~ \"^\/system\/files\") {\n return (pipe);\n }\n\n \/* 9th: Enable grace mode *\/\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/handling_misbehaving_servers.html#grace-mode\n if (! req.backend.healthy) {\n \/* Use a longer grace period if all backends are down *\/\n set req.grace = 1h;\n \/* Use anonymous, cached pages if all backends are down. *\/\n unset req.http.Cookie;\n # TO-DO: Add sick marker\n } else {\n \/* Allow the backend to serve up stale content if it is responding slowly. *\/\n set req.grace = 30s;\n }\n\n \/* 10th: Deal with compression and the Accept-Encoding header *\/\n # Althought Varnish 3 handles gziped content itself by default, just to be sure we want to \n # remove Accept-Encoding for some compressed formats.\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/phk\/gzip.html#what-does-http-gzip-support-do\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/varnishd.html?highlight=http_gzip_support\n # See (for older configs) https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleNormalizeAcceptEncoding\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|mp4|flv|zip|rar)$\") {\n \/* Already compressed formats, no sense trying to compress again *\/\n remove req.http.Accept-Encoding;\n }\n }\n\n \/* 11th: Another header manipulation *\/\n # Empty in simple configs.\n # We could add here a custom header grouping User-agent families.\n\n \/* 12th: Cookie removal *\/\n # Always cache the following static file types for all users. \n # Use with care if we control certain downloads depending on cookies. \n # Be carefull also if appending .htm[l] via Drupal's clean URLs.\n if ( req.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n && req.url !~ \"\/system\/storage\/serve\"\n ) {\n unset req.http.Cookie;\n }\n # Remove all cookies that backend doesn't need to know about.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRemovingSomeCookies\n if (req.http.Cookie) {\n \/* Warning: Not a pretty solution *\/\n \/* Prefix header containing cookies with ';' *\/\n set req.http.Cookie = \";\" + req.http.Cookie;\n \/* Remove any spaces after ';' in header containing cookies *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n \/* Prefix cookies we want to preserve with one space *\/\n \/* 'S{1,2}ESS[a-z0-9]+' is the regular expression matching a Drupal session cookie ({1,2} added for HTTPS support) *\/\n \/* 'NO_CACHE' is usually set after a POST request to make sure issuing user see the results of his post *\/\n \/* 'OATMEAL' & 'CHOCOLATECHIP' are special cookies used by Drupal's Bakery module to provide Single Sign On *\/\n \/* Keep in mind we should add here any cookie that should reach the backend such as splahs avoiding cookies *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \";(S{1,2}ESS[a-z0-9]+|NO_CACHE|OATMEAL|CHOCOLATECHIP)=\", \"; \\1=\");\n \/* Remove from the header any single Cookie not prefixed with a space until next ';' separator *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n \/* Remove any '; ' at the start or the end of the header *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n\n if (req.http.Cookie == \"\") {\n \/* If there are no remaining cookies, remove the cookie header. *\/\n unset req.http.Cookie;\n }\n }\n\n \/* 13th: Session cookie & special cookies bypass caching stage *\/\n # As we might want to cache some requests, hashed with its cookies, \n # we don't simply pass when some cookies remain present at this point.\n # Instead we look for request that must be passed due to the cookie header.\n if (req.http.Cookie ~ \"SESS\" ||\n req.http.Cookie ~ \"SSESS\" ||\n req.http.Cookie ~ \"NO_CACHE\" ||\n req.http.Cookie ~ \"OATMEAL\" ||\n req.http.Cookie ~ \"CHOCOLATECHIP\") {\n return (pass);\n }\n\n \/* 14th: Bypass breakpoint 2 *\/\n # Useful for debugging we can now pipe or pass the request to backend to bypass cache.\n # return (pipe);\n # return (pass);\n\n \/* 15th: Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning a lookup.\n return (lookup);\n}\n\n# vcl_pipe: Called upon entering pipe mode.\n# In this mode, the request is passed on to the backend, \n# and any further data from either client or backend is passed on unaltered until either end closes the connection.\nsub vcl_pipe {\n \/* Prevent connection re-using for piped requests *\/\n # Note that only the first request to the backend will have X-Forwarded-For set.\n # As we use X-Forwarded-For and want to have it set for all requests, \n # we have to make sure connection won't be reused after the request.\n # It is not set by default as it might break some broken web applications, like IIS with NTLM authentication.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExamplePipe\n # TO-DO: make sure this is compatible with websockets piping,\n # reference https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/websockets.html\n set bereq.http.connection = \"close\";\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this point.\n return (pipe);\n}\n\n# vcl_pass: Called upon entering pass mode. \n# In this mode, the request is passed on to the backend, and the backend's response is passed on to the client, \n# but is not entered into the cache.\n# Subsequent requests submitted over the same client connection are handled normally.\n# sub vcl_pass {\n# return (pass);\n# }\n\n# vcl_hash: You may call hash_data() on the data you would like to add to the hash.\n# Hash is used by Varnish to uniquely identify objects.\nsub vcl_hash {\n \/* Hash cookie data *\/\n # As requests with same URL and host can produce diferent results when issued with different cookies,\n # we need to store items hashed with the associated cookies. Note that cookies are already sanitized when we reach this point.\n if (req.http.Cookie) {\n \/* Include cookie in cache hash *\/\n hash_data(req.http.Cookie);\n }\n\n \/* Custom header hashing *\/\n # Empty in simple configs.\n # Example for caching differents object versions by device previously detected (when static content could also vary):\n # if (req.http.X-UA-Device) {\n # hash_data(req.http.X-UA-Device);\n # }\n # Example for caching diferent object versions by X-Forwarded-Proto, trying to be smart about what kind of request\n # could generate diffetent responses.\n if ( req.http.X-Forwarded-Proto\n && req.url !~ \"(?i)\\.(png|gif|jpeg|jpg|ico|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\") {\n hash_data(req.http.X-Forwarded-Proto);\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (hash);\n# }\n\n# vcl_hit: Called after a cache lookup if the requested document was found in the cache.\nsub vcl_hit {\n \/* Check for Varnish special requests *\/ \n # Purge logic.\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/purging.html#http-purges\n # See https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged.\";\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hit {\n# return (deliver);\n# }\n\n# vcl_miss: Called after a cache lookup if the requested document was not found in the cache.\n# Its purpose is to decide whether or not to attempt to retrieve the document from the backend, and which backend to use.\nsub vcl_miss {\n \/* Check for Varnish special requests *\/ \n # Purge logic.\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/purging.html#http-purges\n # See https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged.\";\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_miss {\n# return (fetch);\n# }\n\n# vcl_fetch: Called after a document has been successfully retrieved from the backend.\nsub vcl_fetch {\n \/* Caching exceptions *\/\n # Varnish will cache objects with response codes: 200, 203, 300, 301, 302, 307, 404 & 410.\n # See https:\/\/www.varnish-software.com\/static\/book\/VCL_Basics.html#the-initial-value-of-beresp-ttl\n # Drupal's Imagecache module can return a 307 redirection to the requested url itself and, depending on Drupal's cache settings,\n # this could lead to a redirection loop being cached for a long time but also we want Varnish to shield a little the backend.\n # See http:\/\/drupal.org\/node\/1248010\n # See http:\/\/drupal.org\/node\/310656\n if (beresp.status == 307 &&\n \/* TO-DO: verify that this work better than 'req.url ~ \"imagecache\"' *\/\n beresp.http.Location == req.url &&\n beresp.ttl > 5s) {\n set beresp.ttl = 5s;\n set beresp.http.cache-control = \"max-age=5\";\n }\n\n \/* Enable grace mode. Related with our 9th stage on vcl_recv *\/\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/handling_misbehaving_servers.html#grace-mode\n set beresp.grace = 1h;\n\n \/* Enable saint mode. Related with our 9th stage on vcl_recv *\/\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/handling_misbehaving_servers.html#saint-mode\n if (beresp.status == 500) {\n set beresp.saintmode = 20s;\n # TO-DO: consider not restarting POST requests as seen on https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleSaintMode\n return(restart);\n }\n\n \/* Strip cookies from the following static file types for all users. Related with our 12th stage on vcl_recv *\/\n if (req.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\") {\n unset beresp.http.set-cookie;\n }\n\n \/* Gzip response *\/\n # Empty in simple configs\n # Use Varnish to Gzip respone, if suitable, before storing it on cache\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/phk\/gzip.html\n # if (! beresp.http.Content-Encoding &&\n # (beresp.http.content-type ~ \"text\" ||\n # beresp.http.content-type ~ \"application\/x-javascript\" ||\n # beresp.http.content-type ~ \"application\/javascript\" ||\n # beresp.http.content-type ~ \"application\/rss+xml\" ||\n # beresp.http.content-type ~ \"application\/xml\" ||\n # beresp.http.content-type ~ \"Application\/JSON\")\n # ) {\n # set beresp.do_gzip = true;\n # if ( beresp.http.Vary ) {\n # if ( ! beresp.http.Vary ~ \"Accept-Encoding\" ) {\n # set beresp.http.Vary = beresp.http.Vary + \",Accept-Encoding\";\n # }\n # } else {\n # set beresp.http.Vary = \"Accept-Encoding\";\n # }\n # }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # We can add the name of the backend that has processed the request:\n # set beresp.http.X-Backend = beresp.backend.name;\n # We can use a header to tell if the object was gziped by Varnish\n # if (beresp.do_gzip) {\n # set beresp.http.X-Varnish-Gzipped = \"yes\";\n # } else {\n # set beresp.http.X-Varnish-Gizipped = \"no\";\n # }\n # We can also add headers informing whether the object is cacheable or not and why.\n # https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Varnish3.0\n if (beresp.ttl <= 0s) {\n \/* Varnish determined the object was not cacheable *\/\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n } elsif (req.http.Cookie ~ \"(SESS|SSESS|NO_CACHE|OATMEAL|CHOCOLATECHIP)\") {\n \/* We don't wish to cache content for logged in users or with certain cookies. Related with our 9th stage on vcl_recv *\/\n set beresp.http.X-Cacheable = \"NO:Cookies\";\n # return(hit_for_pass);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n \/* We are respecting the Cache-Control=private header from the backend *\/\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n # return(hit_for_pass);\n } else {\n \/* Varnish determined the object was cacheable *\/\n set beresp.http.X-Cacheable = \"YES\";\n }\n\n \/* Further header manipulation *\/\n # Empty in simple configs.\n # We can also unset some headers to prevent information disclosure and save some cache space\n # unset beresp.http.Server;\n # unset beresp.http.X-Powered-By;\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_fetch {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Vary == \"*\") {\n# \/*\n# * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# *\/\n# set beresp.ttl = 120 s;\n# return (hit_for_pass);\n# }\n# return (deliver);\n# }\n\n# vcl_deliver: Called before an object is delivered to the client\nsub vcl_deliver {\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # Add whether the object is a cache hit or miss and the number of hits for the object.\n # https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Addingaheaderindicatinghitmiss\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n set resp.http.X-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Cache = \"MISS\";\n \/* Show the results of cookie sanitization *\/\n set resp.http.X-Cookie = req.http.Cookie;\n }\n # TO-DO: Add sick marker\n # Restart count\n if ( req.restarts > 0) {\n set resp.http.X-Restarts = req.restarts;\n }\n # Add the Varnish server hostname\n set resp.http.X-Varnish-Server = server.hostname;\n # If we have setted a custom header with device family detected we can show it:\n # if (req.http.X-UA-Device) {\n # set resp.http.X-UA-Device = req.http.X-UA-Device;\n # }\n # If we have recived a custom header with the protocol in the request we can show it:\n # if (req.http.X-Forwarded-Proto) {\n # set resp.http.X-Forwarded-Proto = req.http.X-Forwarded-Proto;\n # }\n\n \/* Vary header manipulation *\/\n # Empty in simple configs.\n # By example, if we are storing & serving diferent objects depending on User-Agent header we must set the correct Vary header:\n # if (resp.http.Vary) {\n # set resp.http.Vary = resp.http.Vary + \",User-Agent\";\n # } else {\n # set resp.http.Vary = \"User-Agent\";\n # }\n\n \/* Fake headers *\/\n # Empty in simple configs\n # We can fake server headers here, by example:\n # set resp.http.Server = \"Deep thought\";\n # set resp.http.X-Powered-By = \"BOFH\";\n # Or have some fun with headers:\n # See http:\/\/www.nextthing.org\/archives\/2005\/08\/07\/fun-with-http-headers\n # See http:\/\/royal.pingdom.com\/2012\/08\/15\/fun-and-unusual-http-response-headers\/\n # set resp.http.X-Thank-You = \"for bothering to look at my HTTP headers\";\n # set resp.http.X-Answer = \"42\";\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_deliver {\n# return (deliver);\n# }\n\n# vcl_error: Called when we hit an error, either explicitly or implicitly due to backend or internal errors.\nsub vcl_error {\n \/* Avoid DOS vulnerability CVE-2013-4484 *\/\n # See https:\/\/www.varnish-cache.org\/lists\/pipermail\/varnish-announce\/2013-October\/000686.html\n if (obj.status == 400 || obj.status == 413) {\n return(deliver);\n }\n\n \/* Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_error;\n\n \/* Try to restart request in case of failure *\/\n # Note that max_restarts defaults to 4\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if (obj.status == 503 && req.restarts < 4) {\n set obj.http.X-Restarts = req.restarts;\n return(restart);\n }\n\n \/* Set common headers for synthetic responses *\/\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n\n \/* HTTP Authentification client request *\/\n # Empty in simple configs. See http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* We're using error 200 for monitoring puposes *\/\n # Consider adding some analytics stuff to trace accesses\n if (obj.status == 200) {\n synthetic {\"\n <?xml version=\"1.0\" encoding=\"utf-8\"?>\n <!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n <html>\n <head>\n <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n <\/head>\n <body><h1>\"} + obj.status + \": \" + obj.response + {\"<\/h1><\/body>\n \"};\n return(deliver);\n }\n\n \/* Error page & refresh \/ redirections *\/\n # We have plenty of choices when we have to serve an error to the client, \n # from the default error page to javascript black magic or plain redirections.\n # Adding some external statistic javascript to track failures served to clients is strongly suggested.\n # We can't use external resources on synthetic content, everything must be inlined.\n # If we need to include images we can embed them in base64 encoding.\n # Here is the default error page for Varnish 3 (not so pretty)\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + obj.status + \" \" + obj.response + {\"<\/h1>\n <p>\"} + obj.response + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"};\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this point.\n return (deliver);\n}\n\n# vcl_init: Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n# sub vcl_init {\n# return (ok);\n# }\n\n# vcl_fini: Called when VCL is discarded only after all requests have exited the VCL. Typically used to clean up VMODs.\n# sub vcl_fini {\n# return (ok);\n# }\n","old_contents":"\/* Varnish 3 example config for Drupal 7 \/ Pressflow 6 & 7 *\/\n# Original source: https:\/\/github.com\/NITEMAN\/varnish-bites\/varnish4\/drupal-base.vcl\n# Copyright (c) 2015 Pedro Gonz\u00e1lez Serrano and individual contributors.\n# MIT License\n\n# Intended to be used both in simple production environments and with learning\/teaching purposes.\n# Loosely based on http:\/\/www.lullabot.com\/sites\/default\/files\/default_varnish3.vcl_.txt\n\n\/* Backend probes \/ healthchecks *\/\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#backend-probes\nprobe basic {\n \/* Only test that backend's IP serves content for '\/' *\/\n # This might be a too heavy probe\n # .url = \"\/\";\n \/* Only test that backend's IP has apache working *\/\n # Nginx would fail this probe with a default config\n .request =\n \"OPTIONS * HTTP\/1.1\"\n \"Host: *\"\n \"Connection: close\";\n .interval = 10s;\n .timeout = 2s;\n .window = 8;\n .threshold = 6;\n}\n\n\n\/* Backend definitions.*\/\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#backend-declarations\nbackend default {\n \/* Default backend on the same machine. WARNING: timeouts could be not big enought for certain POST request *\/\n .host = \"127.0.0.1\";\n .port = \"8008\";\n .connect_timeout = 60s;\n .first_byte_timeout = 60s;\n .between_bytes_timeout = 60s;\n .probe = basic;\n}\n\n\n\/* Directors. *\/\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#directors\n# Empty in simple configs\n\n\n\/* Access Control Lists *\/\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#acls\nacl purge_ban {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use '\"localhost\";' instead\n}\nacl allowed_monitors {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n}\nacl own_proxys {\n \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n}\n\n\n\/* Custom routines *\/\n# Empty in simple configs.\n# We can name subs with no restrictions but as a task can need several chunks of code in diferent states,\n# it's a good idea to identify what main sub will call each with a suffix.\n# \/* Example 301 client redirection removing \"www\" prefix from request *\/\n# sub perm_redirections_recv {\n# if ( req.http.host ~ \"^www.*$\" ) {\n# error 751 \"http:\/\/\" + regsub(req.http.host, \"^www\\.\", \"\") + req.url;\n# }\n# }\n# sub perm_redirections_error {\n# if (obj.status == 751) {\n# \/* Get new URL from the response *\/\n# set obj.http.Location = obj.response;\n# \/* Set HTTP 301 for permanent redirect *\/\n# set obj.status = 301;\n# return(deliver);\n# }\n# }\n\n\n\/* VCL logigc overrides *\/\n# Note that the built-in logic will be appended to our code if no return is performed before.\n# Built-in logic is included commented out right after our's for reference purposes in that cases.\n# See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleDefault\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#subroutines\n\n# vcl_recv: Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use.\nsub vcl_recv {\n \/* 0th: general bypass, general return & authorization checks *\/\n # Empty in simple configs.\n # Useful for debugging we can pipe or pass the request to default backend here to bypass completely Varnish.\n # return (pipe);\n # return (pass);\n # We can also return here a 200 Ok for network performance benchmarking.\n # error 200 \"Ok\";\n # Finally we can perform basic HTTP authentification here by example.\n # See http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* 1st: Check for Varnish special requests *\/ \n # Purge logic.\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/purging.html#http-purges\n # See https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if (req.request == \"PURGE\") {\n if (!client.ip ~ purge_ban) {\n error 405 \"Not allowed.\";\n }\n return (lookup);\n }\n # Ban logic. See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/purging.html#bans\n if (req.request == \"BAN\") {\n if (!client.ip ~ purge_ban) {\n error 405 \"Not allowed.\";\n }\n ban(\"req.http.host == \" + req.http.host +\n \"&& req.url == \" + req.url); \n error 200 \"Ban added\";\n }\n # Custom response implementation example in order to check that Varnish is working properly.\n # This is usefull for automatic monitoring with monit or when Varnish is behind another proxies like HAProxy.\n if ( ( req.http.host == \"monitor.server.health\"\n || req.http.host == \"health.varnish\" )\n && client.ip ~ allowed_monitors\n && ( req.request == \"OPTIONS\" || req.request == \"GET\" )\n ) {\n error 200 \"Ok\";\n }\n\n \/* 2nd: Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_recv;\n # Here we can also enforce SSL when Varnish run behind some SSL termination point.\n\n \/* 3rd: Time for backend choice *\/\n # Empty in simple configs.\n\n \/* 4th: Set custom headers for backend like X-Forwarded-For (copied from built-in logic) *\/\n if ( req.restarts == 0 ) {\n \/* See also vcl_pipe section *\/\n if ( ! client.ip ~ own_proxys ) {\n if ( req.http.x-forwarded-for ) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n }\n\n \/* 5th: Bypass breakpoint 1 *\/\n # Useful for debugging we can now pipe or pass the request to backend with headers setted.\n # return (pipe);\n # return (pass);\n\n \/* 6th: Decide if we should deal with a request (mostly copied from built-in logic) *\/\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n\n \/* 7th: Access control for some URLs by ACL *\/\n # Empty in simple configs.\n # By example denial some URLs depending on client-ip, we'll need to define corresponding ACL 'internal'.\n # if (req.url ~ \"^\/(cron|install)\\.php$\" && !client.ip ~ internal) {\n # # Have Varnish throw the error directly.\n # error 403 \"Forbidden.\";\n # # Use a custom error page that you've defined in Drupal at the path \"404\".\n # # set req.url = \"\/403\";\n # }\n\n \/* 8th: Custom exceptions *\/\n # Host exception example:\n # if (req.http.host == \"ejemplo.exception.com\") {\n # return (pass);\n # }\n # Drupal exceptions, edit if we want to cache some AJAX\/AHAH request.\n # Add here filters for never cache URLs such as Payment Gateway's callbacks\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/ooyala\/ping$\" ||\n req.url ~ \"^\/admin\/build\/features\" ||\n req.url ~ \"^\/info\/.*$\" ||\n req.url ~ \"^\/flag\/.*$\" ||\n req.url ~ \"^.*\/ajax\/.*$\" ||\n req.url ~ \"^.*\/ahah\/.*$\") {\n \/* Do not cache these paths *\/\n return (pass);\n }\n # Pipe these paths directly to backend for streaming.\n if (req.url ~ \"^\/admin\/content\/backup_migrate\/export\") {\n return (pipe);\n }\n if (req.url ~ \"^\/system\/files\") {\n return (pipe);\n }\n\n \/* 9th: Enable grace mode *\/\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/handling_misbehaving_servers.html#grace-mode\n if (! req.backend.healthy) {\n \/* Use a longer grace period if all backends are down *\/\n set req.grace = 1h;\n \/* Use anonymous, cached pages if all backends are down. *\/\n unset req.http.Cookie;\n # TO-DO: Add sick marker\n } else {\n \/* Allow the backend to serve up stale content if it is responding slowly. *\/\n set req.grace = 30s;\n }\n\n \/* 10th: Deal with compression and the Accept-Encoding header *\/\n # Althought Varnish 3 handles gziped content itself by default, just to be sure we want to \n # remove Accept-Encoding for some compressed formats.\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/phk\/gzip.html#what-does-http-gzip-support-do\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/varnishd.html?highlight=http_gzip_support\n # See (for older configs) https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleNormalizeAcceptEncoding\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|mp4|flv|zip|rar)$\") {\n \/* Already compressed formats, no sense trying to compress again *\/\n remove req.http.Accept-Encoding;\n }\n }\n\n \/* 11th: Another header manipulation *\/\n # Empty in simple configs.\n # We could add here a custom header grouping User-agent families.\n\n \/* 12th: Cookie removal *\/\n # Always cache the following static file types for all users. \n # Use with care if we control certain downloads depending on cookies. \n # Be carefull also if appending .htm[l] via Drupal's clean URLs.\n if ( req.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n && req.url !~ \"\/system\/storage\/serve\"\n ) {\n unset req.http.Cookie;\n }\n # Remove all cookies that backend doesn't need to know about.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRemovingSomeCookies\n if (req.http.Cookie) {\n \/* Warning: Not a pretty solution *\/\n \/* Prefix header containing cookies with ';' *\/\n set req.http.Cookie = \";\" + req.http.Cookie;\n \/* Remove any spaces after ';' in header containing cookies *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n \/* Prefix cookies we want to preserve with one space *\/\n \/* 'S{1,2}ESS[a-z0-9]+' is the regular expression matching a Drupal session cookie ({1,2} added for HTTPS support) *\/\n \/* 'NO_CACHE' is usually set after a POST request to make sure issuing user see the results of his post *\/\n \/* 'OATMEAL' & 'CHOCOLATECHIP' are special cookies used by Drupal's Bakery module to provide Single Sign On *\/\n \/* Keep in mind we should add here any cookie that should reach the backend such as splahs avoiding cookies *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \";(S{1,2}ESS[a-z0-9]+|NO_CACHE|OATMEAL|CHOCOLATECHIP)=\", \"; \\1=\");\n \/* Remove from the header any single Cookie not prefixed with a space until next ';' separator *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n \/* Remove any '; ' at the start or the end of the header *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n\n if (req.http.Cookie == \"\") {\n \/* If there are no remaining cookies, remove the cookie header. *\/\n unset req.http.Cookie;\n }\n }\n\n \/* 13th: Session cookie & special cookies bypass caching stage *\/\n # As we might want to cache some requests, hashed with its cookies, \n # we don't simply pass when some cookies remain present at this point.\n # Instead we look for request that must be passed due to the cookie header.\n if (req.http.Cookie ~ \"SESS\" ||\n req.http.Cookie ~ \"SSESS\" ||\n req.http.Cookie ~ \"NO_CACHE\" ||\n req.http.Cookie ~ \"OATMEAL\" ||\n req.http.Cookie ~ \"CHOCOLATECHIP\") {\n return (pass);\n }\n\n \/* 14th: Bypass breakpoint 2 *\/\n # Useful for debugging we can now pipe or pass the request to backend to bypass cache.\n # return (pipe);\n # return (pass);\n\n \/* 15th: Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning a lookup.\n return (lookup);\n}\n\n# vcl_pipe: Called upon entering pipe mode.\n# In this mode, the request is passed on to the backend, \n# and any further data from either client or backend is passed on unaltered until either end closes the connection.\nsub vcl_pipe {\n \/* Prevent connection re-using for piped requests *\/\n # Note that only the first request to the backend will have X-Forwarded-For set.\n # As we use X-Forwarded-For and want to have it set for all requests, \n # we have to make sure connection won't be reused after the request.\n # It is not set by default as it might break some broken web applications, like IIS with NTLM authentication.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExamplePipe\n # TO-DO: make sure this is compatible with websockets piping,\n # reference https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/websockets.html\n set bereq.http.connection = \"close\";\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this point.\n return (pipe);\n}\n\n# vcl_pass: Called upon entering pass mode. \n# In this mode, the request is passed on to the backend, and the backend's response is passed on to the client, \n# but is not entered into the cache.\n# Subsequent requests submitted over the same client connection are handled normally.\n# sub vcl_pass {\n# return (pass);\n# }\n\n# vcl_hash: You may call hash_data() on the data you would like to add to the hash.\n# Hash is used by Varnish to uniquely identify objects.\nsub vcl_hash {\n \/* Hash cookie data *\/\n # As requests with same URL and host can produce diferent results when issued with different cookies,\n # we need to store items hashed with the associated cookies. Note that cookies are already sanitized when we reach this point.\n if (req.http.Cookie) {\n \/* Include cookie in cache hash *\/\n hash_data(req.http.Cookie);\n }\n\n \/* Custom header hashing *\/\n # Empty in simple configs.\n # Example for caching differents object versions by device previously detected (when static content could also vary):\n # if (req.http.X-UA-Device) {\n # hash_data(req.http.X-UA-Device);\n # }\n # Example for caching diferent object versions by X-Forwarded-Proto, trying to be smart about what kind of request\n # could generate diffetent responses.\n # if (req.http.X-Forwarded-Proto &&\n # req.url !~ \"(?i)\\.(png|gif|jpeg|jpg|ico|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|svg|pdf)$\") {\n # hash_data(req.http.X-Forwarded-Proto);\n # }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (hash);\n# }\n\n# vcl_hit: Called after a cache lookup if the requested document was found in the cache.\nsub vcl_hit {\n \/* Check for Varnish special requests *\/ \n # Purge logic.\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/purging.html#http-purges\n # See https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged.\";\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hit {\n# return (deliver);\n# }\n\n# vcl_miss: Called after a cache lookup if the requested document was not found in the cache.\n# Its purpose is to decide whether or not to attempt to retrieve the document from the backend, and which backend to use.\nsub vcl_miss {\n \/* Check for Varnish special requests *\/ \n # Purge logic.\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/purging.html#http-purges\n # See https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged.\";\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_miss {\n# return (fetch);\n# }\n\n# vcl_fetch: Called after a document has been successfully retrieved from the backend.\nsub vcl_fetch {\n \/* Caching exceptions *\/\n # Varnish will cache objects with response codes: 200, 203, 300, 301, 302, 307, 404 & 410.\n # See https:\/\/www.varnish-software.com\/static\/book\/VCL_Basics.html#the-initial-value-of-beresp-ttl\n # Drupal's Imagecache module can return a 307 redirection to the requested url itself and, depending on Drupal's cache settings,\n # this could lead to a redirection loop being cached for a long time but also we want Varnish to shield a little the backend.\n # See http:\/\/drupal.org\/node\/1248010\n # See http:\/\/drupal.org\/node\/310656\n if (beresp.status == 307 &&\n \/* TO-DO: verify that this work better than 'req.url ~ \"imagecache\"' *\/\n beresp.http.Location == req.url &&\n beresp.ttl > 5s) {\n set beresp.ttl = 5s;\n set beresp.http.cache-control = \"max-age=5\";\n }\n\n \/* Enable grace mode. Related with our 9th stage on vcl_recv *\/\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/handling_misbehaving_servers.html#grace-mode\n set beresp.grace = 1h;\n\n \/* Enable saint mode. Related with our 9th stage on vcl_recv *\/\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/handling_misbehaving_servers.html#saint-mode\n if (beresp.status == 500) {\n set beresp.saintmode = 20s;\n # TO-DO: consider not restarting POST requests as seen on https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleSaintMode\n return(restart);\n }\n\n \/* Strip cookies from the following static file types for all users. Related with our 12th stage on vcl_recv *\/\n if (req.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\") {\n unset beresp.http.set-cookie;\n }\n\n \/* Gzip response *\/\n # Empty in simple configs\n # Use Varnish to Gzip respone, if suitable, before storing it on cache\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/phk\/gzip.html\n # if (! beresp.http.Content-Encoding &&\n # (beresp.http.content-type ~ \"text\" ||\n # beresp.http.content-type ~ \"application\/x-javascript\" ||\n # beresp.http.content-type ~ \"application\/javascript\" ||\n # beresp.http.content-type ~ \"application\/rss+xml\" ||\n # beresp.http.content-type ~ \"application\/xml\" ||\n # beresp.http.content-type ~ \"Application\/JSON\")\n # ) {\n # set beresp.do_gzip = true;\n # if ( beresp.http.Vary ) {\n # if ( ! beresp.http.Vary ~ \"Accept-Encoding\" ) {\n # set beresp.http.Vary = beresp.http.Vary + \",Accept-Encoding\";\n # }\n # } else {\n # set beresp.http.Vary = \"Accept-Encoding\";\n # }\n # }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # We can add the name of the backend that has processed the request:\n # set beresp.http.X-Backend = beresp.backend.name;\n # We can use a header to tell if the object was gziped by Varnish\n # if (beresp.do_gzip) {\n # set beresp.http.X-Varnish-Gzipped = \"yes\";\n # } else {\n # set beresp.http.X-Varnish-Gizipped = \"no\";\n # }\n # We can also add headers informing whether the object is cacheable or not and why.\n # https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Varnish3.0\n if (beresp.ttl <= 0s) {\n \/* Varnish determined the object was not cacheable *\/\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n } elsif (req.http.Cookie ~ \"(SESS|SSESS|NO_CACHE|OATMEAL|CHOCOLATECHIP)\") {\n \/* We don't wish to cache content for logged in users or with certain cookies. Related with our 9th stage on vcl_recv *\/\n set beresp.http.X-Cacheable = \"NO:Cookies\";\n # return(hit_for_pass);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n \/* We are respecting the Cache-Control=private header from the backend *\/\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n # return(hit_for_pass);\n } else {\n \/* Varnish determined the object was cacheable *\/\n set beresp.http.X-Cacheable = \"YES\";\n }\n\n \/* Further header manipulation *\/\n # Empty in simple configs.\n # We can also unset some headers to prevent information disclosure and save some cache space\n # unset beresp.http.Server;\n # unset beresp.http.X-Powered-By;\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_fetch {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Vary == \"*\") {\n# \/*\n# * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# *\/\n# set beresp.ttl = 120 s;\n# return (hit_for_pass);\n# }\n# return (deliver);\n# }\n\n# vcl_deliver: Called before an object is delivered to the client\nsub vcl_deliver {\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # Add whether the object is a cache hit or miss and the number of hits for the object.\n # https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Addingaheaderindicatinghitmiss\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n set resp.http.X-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Cache = \"MISS\";\n \/* Show the results of cookie sanitization *\/\n set resp.http.X-Cookie = req.http.Cookie;\n }\n # TO-DO: Add sick marker\n # Restart count\n if ( req.restarts > 0) {\n set resp.http.X-Restarts = req.restarts;\n }\n # Add the Varnish server hostname\n set resp.http.X-Varnish-Server = server.hostname;\n # If we have setted a custom header with device family detected we can show it:\n # if (req.http.X-UA-Device) {\n # set resp.http.X-UA-Device = req.http.X-UA-Device;\n # }\n # If we have recived a custom header with the protocol in the request we can show it:\n # if (req.http.X-Forwarded-Proto) {\n # set resp.http.X-Forwarded-Proto = req.http.X-Forwarded-Proto;\n # }\n\n \/* Vary header manipulation *\/\n # Empty in simple configs.\n # By example, if we are storing & serving diferent objects depending on User-Agent header we must set the correct Vary header:\n # if (resp.http.Vary) {\n # set resp.http.Vary = resp.http.Vary + \",User-Agent\";\n # } else {\n # set resp.http.Vary = \"User-Agent\";\n # }\n\n \/* Fake headers *\/\n # Empty in simple configs\n # We can fake server headers here, by example:\n # set resp.http.Server = \"Deep thought\";\n # set resp.http.X-Powered-By = \"BOFH\";\n # Or have some fun with headers:\n # See http:\/\/www.nextthing.org\/archives\/2005\/08\/07\/fun-with-http-headers\n # See http:\/\/royal.pingdom.com\/2012\/08\/15\/fun-and-unusual-http-response-headers\/\n # set resp.http.X-Thank-You = \"for bothering to look at my HTTP headers\";\n # set resp.http.X-Answer = \"42\";\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_deliver {\n# return (deliver);\n# }\n\n# vcl_error: Called when we hit an error, either explicitly or implicitly due to backend or internal errors.\nsub vcl_error {\n \/* Avoid DOS vulnerability CVE-2013-4484 *\/\n # See https:\/\/www.varnish-cache.org\/lists\/pipermail\/varnish-announce\/2013-October\/000686.html\n if (obj.status == 400 || obj.status == 413) {\n return(deliver);\n }\n\n \/* Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_error;\n\n \/* Try to restart request in case of failure *\/\n # Note that max_restarts defaults to 4\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if (obj.status == 503 && req.restarts < 4) {\n set obj.http.X-Restarts = req.restarts;\n return(restart);\n }\n\n \/* Set common headers for synthetic responses *\/\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n\n \/* HTTP Authentification client request *\/\n # Empty in simple configs. See http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* We're using error 200 for monitoring puposes *\/\n # Consider adding some analytics stuff to trace accesses\n if (obj.status == 200) {\n synthetic {\"\n <?xml version=\"1.0\" encoding=\"utf-8\"?>\n <!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n <html>\n <head>\n <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n <\/head>\n <body><h1>\"} + obj.status + \": \" + obj.response + {\"<\/h1><\/body>\n \"};\n return(deliver);\n }\n\n \/* Error page & refresh \/ redirections *\/\n # We have plenty of choices when we have to serve an error to the client, \n # from the default error page to javascript black magic or plain redirections.\n # Adding some external statistic javascript to track failures served to clients is strongly suggested.\n # We can't use external resources on synthetic content, everything must be inlined.\n # If we need to include images we can embed them in base64 encoding.\n # Here is the default error page for Varnish 3 (not so pretty)\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + obj.status + \" \" + obj.response + {\"<\/h1>\n <p>\"} + obj.response + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"};\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this point.\n return (deliver);\n}\n\n# vcl_init: Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n# sub vcl_init {\n# return (ok);\n# }\n\n# vcl_fini: Called when VCL is discarded only after all requests have exited the VCL. Typically used to clean up VMODs.\n# sub vcl_fini {\n# return (ok);\n# }\n","returncode":0,"stderr":"","license":"unknown","lang":"VCL"} {"commit":"679875c2407322dcfe8f2c6c5872daeae5f1e4ea","subject":"correct the backend name","message":"correct the backend name","repos":"JakeChampion\/polyfill-service,JakeChampion\/polyfill-service","old_file":"fastly\/vcl\/polyfill-service.vcl","new_file":"fastly\/vcl\/polyfill-service.vcl","new_contents":"sub set_backend {\n\t# The Fastly macro is inserted before the backend is selected because the\n\t# macro has the code which defines the values avaiable for req.http.Host\n\t# but it also contains a default backend which is always set to the EU. I wish we could disable the default backend setting.\n\t#FASTLY recv\n\t\n\t# Calculate the ideal region to route the request to.\n \tdeclare local var.region STRING; \n\tif (server.region ~ \"(APAC|Asia|North-America|South-America|US-Central|US-East|US-West)\") {\n\t\tset var.region = \"US\";\n \t} else {\n\t\tset var.region = \"EU\";\n \t}\n\n\t# Gather the health of the shields and origins.\n\tdeclare local var.v3_eu_is_healthy BOOL;\n\tset req.backend = F_v3_eu;\n\tset var.v3_eu_is_healthy = req.backend.healthy;\n\n\tdeclare local var.v3_us_is_healthy BOOL;\n \tset req.backend = F_v3_us;\n \tset var.v3_us_is_healthy = req.backend.healthy;\n\n \tdeclare local var.shield_eu_is_healthy BOOL;\n \tset req.backend = ssl_shield_london_city_uk;\n \tset var.shield_eu_is_healthy = req.backend.healthy;\n\n \tdeclare local var.shield_us_is_healthy BOOL;\n \tset req.backend = ssl_shield_dca_dc_us;\n \tset var.shield_us_is_healthy = req.backend.healthy;\n\n \t# Set some sort of default, that shouldn't get used.\n \tset req.backend = F_v3_eu;\n\n\tdeclare local var.EU_shield_server_name STRING;\n\tset var.EU_shield_server_name = \"LCY\";\n\n\tdeclare local var.US_shield_server_name STRING;\n\tset var.US_shield_server_name = \"DCA\";\n\n\t# Route EU requests to the nearest healthy shield or origin.\n \tif (var.region == \"EU\") {\n\t\tif (server.datacenter != var.EU_shield_server_name && req.http.Request_Came_From_Shield != var.EU_shield_server_name && var.shield_eu_is_healthy) {\n\t\t\tset req.backend = ssl_shield_london_city_uk;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} elseif (var.shield_us_is_healthy) {\n\t\t\tset req.backend = ssl_shield_dca_dc_us;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_eu;\n\t\t}\n \t}\n\n\t# Route US requests to the nearest healthy shield or origin.\n \tif (var.region == \"US\") {\n\t\tif (server.datacenter != var.US_shield_server_name && req.http.Request_Came_From_Shield != var.US_shield_server_name && var.shield_us_is_healthy) {\n\t\t\tset req.backend = ssl_shield_dca_dc_us;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} elseif (var.shield_eu_is_healthy) {\n\t\t\tset req.backend = ssl_shield_london_city_uk;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_us;\n\t\t}\n\t}\n\n\t# Persist the decision so we can debug the result.\n \tset req.http.Debug-Backend = req.backend;\n}\n\nsub vcl_recv {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_recv;\n\t}\n\n\tif (req.method != \"GET\" && req.method != \"HEAD\" && req.method != \"OPTIONS\" && req.method != \"FASTLYPURGE\" && req.method != \"PURGE\") {\n\t\terror 911;\n\t}\n\n\tif (req.method == \"OPTIONS\") {\n\t\terror 912;\n\t}\n\n\t# Because the old service had a router which allowed any words between \/v2\/polyfill. and .js\n\tif (req.url.path ~ \"^\/v2\/polyfill(\\.\\w+)(\\.\\w+)?\" && req.url.ext == \"js\") {\n\t\tif (re.group.2) {\n\t\t\tset req.url = \"\/v2\/polyfill.min.js?\" req.url.qs;\n\t\t} else {\n\t\t\tset req.url = \"\/v2\/polyfill.js?\" req.url.qs;\n\t\t}\n\t}\n\n\t# Override the v3 defaults with the defaults of v2\n\tif (req.url ~ \"^\/v2\/polyfill(\\.min)?\\.js\") {\n\t\tset req.url = regsub(req.url, \"^\/v2\", \"\/v3\");\n\t\tset req.url = querystring.set(req.url, \"version\", \"3.25.1\");\n\t\tdeclare local var.unknown STRING;\n\t\tset var.unknown = subfield(req.url.qs, \"unknown\", \"&\");\n\t\tset req.url = querystring.set(req.url, \"unknown\", if(var.unknown != \"\", var.unknown, \"ignore\"));\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\") {\n\t\tcall normalise_querystring_parameters_for_polyfill_bundle;\n\t\t# Sort the querystring parameters alphabetically to improve chances of hitting a cached copy.\n\t\t# If querystring is empty, remove the ? from the url.\n\t\tset req.url = querystring.clean(querystring.sort(req.url));\n\t\tcall set_backend;\n\t} else {\n\t\t# The request is to an endpoint which doesn't use query parameters, let's remove them to increase our cache-hit-ratio\n\t\tset req.url = querystring.remove(req.url);\n\t\tcall set_backend;\n\t}\n\t\n\tif (req.backend == ssl_shield_dca_dc_us || req.backend == ssl_shield_london_city_uk) {\n\t\t# avoid passing stale content from Shield POP to Edge POP\n\t\tset req.max_stale_while_revalidate = 0s;\n\t} else {\n\t\tset req.http.referer_domain = if(req.http.referer ~ \"^https?\\:\\\/\\\/([^\\\/:?#]+)(?:[\\\/:?#]|$)\", re.group.1, \"\");\n\t}\n}\n\nsub vcl_hash {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_hash;\n\t}\n\n\t# We are not adding req.http.host to the hash because we want https:\/\/cdn.polyfill.io and https:\/\/polyfill.io to be a single object in the cache.\n\t# set req.hash += req.http.host;\n\tset req.hash += req.url;\n\t# We include return(hash) to stop the function falling through to the default VCL built into varnish, which for vcl_hash will add req.url and req.http.Host to the hash.\n\treturn(hash);\n}\n\n\nsub shielding_header {\n\tif (req.backend == ssl_shield_dca_dc_us) {\n\t\tset req.http.Request_Came_From_Shield = server.datacenter;\n\t} elsif (req.backend == ssl_shield_london_city_uk) {\n\t\tset req.http.Request_Came_From_Shield = server.datacenter;\n\t}\n}\n\nsub vcl_miss {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_miss;\n\t}\n\tcall shielding_header;\n}\n\nsub vcl_pass {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_pass;\n\t}\n\tcall shielding_header;\n}\n\nsub vcl_fetch {\n\tset beresp.http.Request_Came_From_Shield = req.http.Request_Came_From_Shield;\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_fetch;\n\t}\n\n\t# These header are only required for HTML documents.\n\tif (beresp.http.Content-Type ~ \"text\/html\") {\n\t\t# Enables the cross-site scripting filter built into most modern web browsers.\n\t\tset beresp.http.X-XSS-Protection = \"1; mode=block\";\t\n\t}\n\t# Prevents MIME-sniffing a response away from the declared content type.\n\tset beresp.http.X-Content-Type-Options = \"nosniff\";\n\n\t# Ensure the site is only served over HTTPS and reduce the chances of someone performing a MITM attack.\n\tset beresp.http.Strict-Transport-Security = \"max-age=31536000; includeSubdomains; preload\";\n\n\t# The Referrer-Policy header governs which referrer information, sent in the Referer header, should be included with requests made.\n\t# Send a full URL when performing a same-origin request, but only send the origin of the document for other cases.\n\tset beresp.http.Referrer-Policy = \"origin-when-cross-origin\";\n\n\t# Enable purging of all objects in the Fastly cache by issuing a purge with the key \"polyfill-service\".\n\tif (beresp.http.Surrogate-Key !~ \"\\bpolyfill-service\\b\") {\n\t\tset beresp.http.Surrogate-Key = if(beresp.http.Surrogate-Key, beresp.http.Surrogate-Key \" polyfill-service\", \"polyfill-service\");\n\t}\n\n\tset beresp.http.Timing-Allow-Origin = \"*\";\n\n\tif (req.http.Normalized-User-Agent) {\n\t\tset beresp.http.Normalized-User-Agent = req.http.Normalized-User-Agent;\n\t\tset beresp.http.Detected-User-Agent = req.http.useragent_parser_family \"\/\" req.http.useragent_parser_major \".\" req.http.useragent_parser_minor \".\" req.http.useragent_parser_patch;\n\t}\n}\n\nsub vcl_deliver {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_deliver;\n\t}\n\n\tset req.http.Fastly-Force-Shield = \"yes\";\n\n\t# Allow cross origin GET, HEAD, and OPTIONS requests to be made.\n\tif (req.http.Origin) {\n\t\tset resp.http.Access-Control-Allow-Origin = \"*\";\n\t\tset resp.http.Access-Control-Allow-Methods = \"GET,HEAD,OPTIONS\";\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\" && !resp.http.Request_Came_From_Shield && req.backend != ssl_shield_dca_dc_us && req.backend != ssl_shield_london_city_uk) {\n\t\t# Need to add \"Vary: User-Agent\" in after vcl_fetch to avoid the \n\t\t# \"Vary: User-Agent\" entering the Varnish cache.\n\t\t# We need \"Vary: User-Agent\" in the browser cache because a browser\n\t\t# may update itself to a version which needs different polyfills\n\t\t# So we need to have it ignore the browser cached bundle when the user-agent changes.\n\t\tset resp.http.Vary = \"User-Agent, Accept-Encoding\";\n\t}\n\n\tif (resp.status == 304) {\n\t\tset resp.http.Age = \"0\";\n\t}\n\n\tadd resp.http.Server-Timing = fastly_info.state {\", fastly;desc=\"Edge time\";dur=\"} time.elapsed.msec;\n\n\tif (req.http.Fastly-Debug) {\n\t\tset resp.http.Debug-Backend = req.http.Debug-Backend;\n\t\tset resp.http.Debug-Host = req.http.Host;\n\t\tset resp.http.Debug-Fastly-Restarts = req.restarts;\n\t\tset resp.http.Debug-Orig-URL = req.http.Orig-URL;\n\t\tset resp.http.Debug-VCL-Route = req.http.X-VCL-Route;\n\t\tset resp.http.useragent_parser_family = req.http.useragent_parser_family;\n\t\tset resp.http.useragent_parser_major = req.http.useragent_parser_major;\n\t\tset resp.http.useragent_parser_minor = req.http.useragent_parser_minor;\n\t\tset resp.http.useragent_parser_patch = req.http.useragent_parser_patch;\n\t} else {\n\t\tunset resp.http.Server;\n\t\tunset resp.http.Via;\n\t\tunset resp.http.X-Cache;\n\t\tunset resp.http.X-Cache-Hits;\n\t\tunset resp.http.X-Served-By;\n\t\tunset resp.http.X-Timer;\n\t\tunset resp.http.Fastly-Restarts;\n\t\tunset resp.http.X-PreFetch-Pass;\n\t\tunset resp.http.X-PreFetch-Miss;\n\t\tunset resp.http.X-PostFetch;\n\t}\n}\n\nsub vcl_error {\n\tif (obj.status == 911) {\n\t\tset obj.status = 405;\n\t\tset obj.response = \"METHOD NOT ALLOWED\";\n\t\tset obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n\t\tset obj.http.Cache-Control = \"private, no-store\";\n\t\tsynthetic req.method \" METHOD NOT ALLOWED\";\n\t\treturn (deliver);\n\t}\n\tif (obj.status == 912) {\n\t\tset obj.status = 200;\n\t\tset obj.response = \"OK\";\n\t\tset obj.http.Allow = \"OPTIONS, GET, HEAD\";\n\t\treturn (deliver);\n\t}\n}\n","old_contents":"sub set_backend {\n\t# The Fastly macro is inserted before the backend is selected because the\n\t# macro has the code which defines the values avaiable for req.http.Host\n\t# but it also contains a default backend which is always set to the EU. I wish we could disable the default backend setting.\n\t#FASTLY recv\n\t\n\t# Calculate the ideal region to route the request to.\n \tdeclare local var.region STRING; \n\tif (server.region ~ \"(APAC|Asia|North-America|South-America|US-Central|US-East|US-West)\") {\n\t\tset var.region = \"US\";\n \t} else {\n\t\tset var.region = \"EU\";\n \t}\n\n\t# Gather the health of the shields and origins.\n\tdeclare local var.v3_eu_is_healthy BOOL;\n\tset req.backend = F_v3_eu;\n\tset var.v3_eu_is_healthy = req.backend.healthy;\n\n\tdeclare local var.v3_us_is_healthy BOOL;\n \tset req.backend = F_v3_us;\n \tset var.v3_us_is_healthy = req.backend.healthy;\n\n \tdeclare local var.shield_eu_is_healthy BOOL;\n \tset req.backend = ssl_shield_london_city_uk;\n \tset var.shield_eu_is_healthy = req.backend.healthy;\n\n \tdeclare local var.shield_us_is_healthy BOOL;\n \tset req.backend = ssl_shield_dca_dc_us;\n \tset var.shield_us_is_healthy = req.backend.healthy;\n\n \t# Set some sort of default, that shouldn't get used.\n \tset req.backend = F_v3_eu;\n\n\tdeclare local var.EU_shield_server_name STRING;\n\tset var.EU_shield_server_name = \"LCY\";\n\n\tdeclare local var.US_shield_server_name STRING;\n\tset var.US_shield_server_name = \"DCA\";\n\n\t# Route EU requests to the nearest healthy shield or origin.\n \tif (var.region == \"EU\") {\n\t\tif (server.datacenter != var.EU_shield_server_name && req.http.Request_Came_From_Shield != var.EU_shield_server_name && var.shield_eu_is_healthy) {\n\t\t\tset req.backend = ssl_shield_london_city_uk;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} elseif (var.shield_us_is_healthy) {\n\t\t\tset req.backend = ssl_shield_dca_dc_us;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_eu;\n\t\t}\n \t}\n\n\t# Route US requests to the nearest healthy shield or origin.\n \tif (var.region == \"US\") {\n\t\tif (server.datacenter != var.US_shield_server_name && req.http.Request_Came_From_Shield != var.US_shield_server_name && var.shield_us_is_healthy) {\n\t\t\tset req.backend = ssl_shield_dca_dc_us;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} elseif (var.shield_eu_is_healthy) {\n\t\t\tset req.backend = ssl_shield_london_city_uk;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_us;\n\t\t}\n\t}\n\n\t# Persist the decision so we can debug the result.\n \tset req.http.Debug-Backend = req.backend;\n}\n\nsub vcl_recv {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_recv;\n\t}\n\n\tif (req.method != \"GET\" && req.method != \"HEAD\" && req.method != \"OPTIONS\" && req.method != \"FASTLYPURGE\" && req.method != \"PURGE\") {\n\t\terror 911;\n\t}\n\n\tif (req.method == \"OPTIONS\") {\n\t\terror 912;\n\t}\n\n\t# Because the old service had a router which allowed any words between \/v2\/polyfill. and .js\n\tif (req.url.path ~ \"^\/v2\/polyfill(\\.\\w+)(\\.\\w+)?\" && req.url.ext == \"js\") {\n\t\tif (re.group.2) {\n\t\t\tset req.url = \"\/v2\/polyfill.min.js?\" req.url.qs;\n\t\t} else {\n\t\t\tset req.url = \"\/v2\/polyfill.js?\" req.url.qs;\n\t\t}\n\t}\n\n\t# Override the v3 defaults with the defaults of v2\n\tif (req.url ~ \"^\/v2\/polyfill(\\.min)?\\.js\") {\n\t\tset req.url = regsub(req.url, \"^\/v2\", \"\/v3\");\n\t\tset req.url = querystring.set(req.url, \"version\", \"3.25.1\");\n\t\tdeclare local var.unknown STRING;\n\t\tset var.unknown = subfield(req.url.qs, \"unknown\", \"&\");\n\t\tset req.url = querystring.set(req.url, \"unknown\", if(var.unknown != \"\", var.unknown, \"ignore\"));\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\") {\n\t\tcall normalise_querystring_parameters_for_polyfill_bundle;\n\t\t# Sort the querystring parameters alphabetically to improve chances of hitting a cached copy.\n\t\t# If querystring is empty, remove the ? from the url.\n\t\tset req.url = querystring.clean(querystring.sort(req.url));\n\t\tcall set_backend;\n\t} else {\n\t\t# The request is to an endpoint which doesn't use query parameters, let's remove them to increase our cache-hit-ratio\n\t\tset req.url = querystring.remove(req.url);\n\t\tcall set_backend;\n\t}\n\t\n\tif (req.backend == ssl_shield_dca_dc_us || req.backend == ssl_shield_london_city_uk) {\n\t\t# avoid passing stale content from Shield POP to Edge POP\n\t\tset req.max_stale_while_revalidate = 0s;\n\t} else {\n\t\tset req.http.referer_domain = if(req.http.referer ~ \"^https?\\:\\\/\\\/([^\\\/:?#]+)(?:[\\\/:?#]|$)\", re.group.1, \"\");\n\t}\n}\n\nsub vcl_hash {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_hash;\n\t}\n\n\t# We are not adding req.http.host to the hash because we want https:\/\/cdn.polyfill.io and https:\/\/polyfill.io to be a single object in the cache.\n\t# set req.hash += req.http.host;\n\tset req.hash += req.url;\n\t# We include return(hash) to stop the function falling through to the default VCL built into varnish, which for vcl_hash will add req.url and req.http.Host to the hash.\n\treturn(hash);\n}\n\n\nsub shielding_header {\n\tif (req.backend == ssl_shield_dca_dc_us) {\n\t\tset req.http.Request_Came_From_Shield = server.datacenter;\n\t} elsif (req.backend == ssl_shield_london_city_uk) {\n\t\tset req.http.Request_Came_From_Shield = server.datacenter;\n\t}\n}\n\nsub vcl_miss {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_miss;\n\t}\n\tcall shielding_header;\n}\n\nsub vcl_pass {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_pass;\n\t}\n\tcall shielding_header;\n}\n\nsub vcl_fetch {\n\tset beresp.http.Request_Came_From_Shield = req.http.Request_Came_From_Shield;\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_fetch;\n\t}\n\n\t# These header are only required for HTML documents.\n\tif (beresp.http.Content-Type ~ \"text\/html\") {\n\t\t# Enables the cross-site scripting filter built into most modern web browsers.\n\t\tset beresp.http.X-XSS-Protection = \"1; mode=block\";\t\n\t}\n\t# Prevents MIME-sniffing a response away from the declared content type.\n\tset beresp.http.X-Content-Type-Options = \"nosniff\";\n\n\t# Ensure the site is only served over HTTPS and reduce the chances of someone performing a MITM attack.\n\tset beresp.http.Strict-Transport-Security = \"max-age=31536000; includeSubdomains; preload\";\n\n\t# The Referrer-Policy header governs which referrer information, sent in the Referer header, should be included with requests made.\n\t# Send a full URL when performing a same-origin request, but only send the origin of the document for other cases.\n\tset beresp.http.Referrer-Policy = \"origin-when-cross-origin\";\n\n\t# Enable purging of all objects in the Fastly cache by issuing a purge with the key \"polyfill-service\".\n\tif (beresp.http.Surrogate-Key !~ \"\\bpolyfill-service\\b\") {\n\t\tset beresp.http.Surrogate-Key = if(beresp.http.Surrogate-Key, beresp.http.Surrogate-Key \" polyfill-service\", \"polyfill-service\");\n\t}\n\n\tset beresp.http.Timing-Allow-Origin = \"*\";\n\n\tif (req.http.Normalized-User-Agent) {\n\t\tset beresp.http.Normalized-User-Agent = req.http.Normalized-User-Agent;\n\t\tset beresp.http.Detected-User-Agent = req.http.useragent_parser_family \"\/\" req.http.useragent_parser_major \".\" req.http.useragent_parser_minor \".\" req.http.useragent_parser_patch;\n\t}\n}\n\nsub vcl_deliver {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_deliver;\n\t}\n\n\tset req.http.Fastly-Force-Shield = \"yes\";\n\n\t# Allow cross origin GET, HEAD, and OPTIONS requests to be made.\n\tif (req.http.Origin) {\n\t\tset resp.http.Access-Control-Allow-Origin = \"*\";\n\t\tset resp.http.Access-Control-Allow-Methods = \"GET,HEAD,OPTIONS\";\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\" && !resp.http.Request_Came_From_Shield && req.backend != ssl_shield_dca-dc-us && req.backend != ssl_shield_london_city_uk) {\n\t\t# Need to add \"Vary: User-Agent\" in after vcl_fetch to avoid the \n\t\t# \"Vary: User-Agent\" entering the Varnish cache.\n\t\t# We need \"Vary: User-Agent\" in the browser cache because a browser\n\t\t# may update itself to a version which needs different polyfills\n\t\t# So we need to have it ignore the browser cached bundle when the user-agent changes.\n\t\tset resp.http.Vary = \"User-Agent, Accept-Encoding\";\n\t}\n\n\tif (resp.status == 304) {\n\t\tset resp.http.Age = \"0\";\n\t}\n\n\tadd resp.http.Server-Timing = fastly_info.state {\", fastly;desc=\"Edge time\";dur=\"} time.elapsed.msec;\n\n\tif (req.http.Fastly-Debug) {\n\t\tset resp.http.Debug-Backend = req.http.Debug-Backend;\n\t\tset resp.http.Debug-Host = req.http.Host;\n\t\tset resp.http.Debug-Fastly-Restarts = req.restarts;\n\t\tset resp.http.Debug-Orig-URL = req.http.Orig-URL;\n\t\tset resp.http.Debug-VCL-Route = req.http.X-VCL-Route;\n\t\tset resp.http.useragent_parser_family = req.http.useragent_parser_family;\n\t\tset resp.http.useragent_parser_major = req.http.useragent_parser_major;\n\t\tset resp.http.useragent_parser_minor = req.http.useragent_parser_minor;\n\t\tset resp.http.useragent_parser_patch = req.http.useragent_parser_patch;\n\t} else {\n\t\tunset resp.http.Server;\n\t\tunset resp.http.Via;\n\t\tunset resp.http.X-Cache;\n\t\tunset resp.http.X-Cache-Hits;\n\t\tunset resp.http.X-Served-By;\n\t\tunset resp.http.X-Timer;\n\t\tunset resp.http.Fastly-Restarts;\n\t\tunset resp.http.X-PreFetch-Pass;\n\t\tunset resp.http.X-PreFetch-Miss;\n\t\tunset resp.http.X-PostFetch;\n\t}\n}\n\nsub vcl_error {\n\tif (obj.status == 911) {\n\t\tset obj.status = 405;\n\t\tset obj.response = \"METHOD NOT ALLOWED\";\n\t\tset obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n\t\tset obj.http.Cache-Control = \"private, no-store\";\n\t\tsynthetic req.method \" METHOD NOT ALLOWED\";\n\t\treturn (deliver);\n\t}\n\tif (obj.status == 912) {\n\t\tset obj.status = 200;\n\t\tset obj.response = \"OK\";\n\t\tset obj.http.Allow = \"OPTIONS, GET, HEAD\";\n\t\treturn (deliver);\n\t}\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"3f764214ca742b0bc01d83dfaf0216954b3e30a4","subject":"Remove some local domains","message":"Remove some local domains\n","repos":"JakeChampion\/polyfill-service,mcshaz\/polyfill-service,kdzwinel\/polyfill-service,jonathan-fielding\/polyfill-service,jonathan-fielding\/polyfill-service,kdzwinel\/polyfill-service,kdzwinel\/polyfill-service,mcshaz\/polyfill-service,JakeChampion\/polyfill-service,jonathan-fielding\/polyfill-service,mcshaz\/polyfill-service","old_file":"fastly-config.vcl","new_file":"fastly-config.vcl","new_contents":"sub vcl_recv {\n#FASTLY recv\n\n\tif (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n\t return(pass);\n\t}\n\n\t# Redirect legacy service users to legacy service\n\tset req.http.X-Referer-Host = regsub(req.http.Referer, \"^https?\\:\\\/\\\/([^\\\/]+)(\\\/.*)?$\", \"\\1\");\n\tif (req.url == \"\/normalize.js\" ||\n\t\treq.url == \"\/normalize.css\" ||\n\t\treq.url == \"\/normalise.js\" ||\n\t\treq.url == \"\/normalise.css\" ||\n\t\treq.http.X-Referer-Host == \"www.manrepeller.com\" ||\n\t\treq.http.X-Referer-Host == \"www.mulesoft.com\" ||\n\t\treq.http.X-Referer-Host == \"iluoghidelcuore.it\" ||\n\t\treq.http.X-Referer-Host == \"it.donga.com\" ||\n\t\treq.http.X-Referer-Host == \"www.watchguard.com\" ||\n\t\treq.http.X-Referer-Host == \"www.mulesoft.org\" ||\n\t\treq.http.X-Referer-Host == \"asmwall.com\" ||\n\t\treq.http.X-Referer-Host == \"www.jcsu.edu\" ||\n\t\treq.http.X-Referer-Host == \"adscendmedia.com\" ||\n\t\treq.http.X-Referer-Host == \"game.donga.com\" ||\n\t\treq.http.X-Referer-Host == \"framkino.no\" ||\n\t\treq.http.X-Referer-Host == \"www.accesswireless.com\" ||\n\t\treq.http.X-Referer-Host == \"represent.com\" ||\n\t\treq.http.X-Referer-Host == \"www.designergreek.com\" ||\n\t\treq.http.X-Referer-Host == \"www.plumbingoverstock.com\" ||\n\t\treq.http.X-Referer-Host == \"servicos.searh.rn.gov.br\" ||\n\t\treq.http.X-Referer-Host == \"www.jane-usa.com\" ||\n\t\treq.http.X-Referer-Host == \"www.juntaempresa.com.br\" ||\n\t\treq.http.X-Referer-Host == \"watchguard.com\" ||\n\t\treq.http.X-Referer-Host == \"www.logianalytics.com\" ||\n\t\treq.http.X-Referer-Host == \"www.thebathpoint.com\" ||\n\t\treq.http.X-Referer-Host == \"blogs.mulesoft.org\" ||\n\t\treq.http.X-Referer-Host == \"www.purecanadiangaming.com\" ||\n\t\treq.http.X-Referer-Host == \"play.egzaminatorius.lt\" ||\n\t\treq.http.X-Referer-Host == \"internetacademi.com\" ||\n\t\treq.http.X-Referer-Host == \"www.skyhighnetworks.com\" ||\n\t\treq.http.X-Referer-Host == \"interactive.guim.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"www.soloio.com\" ||\n\t\treq.http.X-Referer-Host == \"desenvolvimentoparaweb.com\" ||\n\t\treq.http.X-Referer-Host == \"daily-fantasy.trunk.development.manhattan.gq1.yahoo.com\" ||\n\t\treq.http.X-Referer-Host == \"blog.damyller.com.br\" ||\n\t\treq.http.X-Referer-Host == \"doggiebag.no\" ||\n\t\treq.http.X-Referer-Host == \"www.beverlydiamonds.com\" ||\n\t\treq.http.X-Referer-Host == \"www.rogerscup.com\" ||\n\t\treq.http.X-Referer-Host == \"blog.hudy.cz\" ||\n\t\treq.http.X-Referer-Host == \"techhamlet.com\" ||\n\t\treq.http.X-Referer-Host == \"www.flirtfachmann.de\" ||\n\t\treq.http.X-Referer-Host == \"alpacacomics.com\" ||\n\t\treq.http.X-Referer-Host == \"areariservata.fondoprevidenzafinanze.it\" ||\n\t\treq.http.X-Referer-Host == \"www.framkino.no\" ||\n\t\treq.http.X-Referer-Host == \"www.nationalsecurities.com\" ||\n\t\treq.http.X-Referer-Host == \"www.tenniscanada.com\" ||\n\t\treq.http.X-Referer-Host == \"libek.org.rs\" ||\n\t\treq.http.X-Referer-Host == \"learn.logianalytics.com\" ||\n\t\treq.http.X-Referer-Host == \"www.impartner.lt\" ||\n\t\treq.http.X-Referer-Host == \"chameleon.biworldwide.com\" ||\n\t\treq.http.X-Referer-Host == \"www.pujckapowebu.cz\" ||\n\t\treq.http.X-Referer-Host == \"www.dlcnetwork.com\" ||\n\t\treq.http.X-Referer-Host == \"www.forbes.com\" ||\n\t\treq.http.X-Referer-Host == \"blog.skyhighnetworks.com\" ||\n\t\treq.http.X-Referer-Host == \"rflx.bjornborg.com\" ||\n\t\treq.http.X-Referer-Host == \"www.coach-outlet-store.com\" ||\n\t\treq.http.X-Referer-Host == \"gist.io\" ||\n\t\treq.http.X-Referer-Host == \"www.suicideispreventable.org\" ||\n\t\treq.http.X-Referer-Host == \"www.rangemastertacticalgear.com\" ||\n\t\treq.http.X-Referer-Host == \"www.hcpozicka.sk\" ||\n\t\treq.http.X-Referer-Host == \"www.airsoftmegastore.com\" ||\n\t\treq.http.X-Referer-Host == \"colortile.github.io\" ||\n\t\treq.http.X-Referer-Host == \"brasstacksmadras.com\" ||\n\t\treq.http.X-Referer-Host == \"hotelcasadomingo.com.mx\" ||\n\t\treq.http.X-Referer-Host == \"client.local\" ||\n\t\treq.http.X-Referer-Host == \"www.worcesterpromotions.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"www.asmwall.com\" ||\n\t\treq.http.X-Referer-Host == \"training.mulesoft.com\" ||\n\t\treq.http.X-Referer-Host == \"exhilarateme.com\" ||\n\t\treq.http.X-Referer-Host == \"www.kommentatorskampen.viasatsport.se\" ||\n\t\treq.http.X-Referer-Host == \"www.golfgearselect.com\" ||\n\t\treq.http.X-Referer-Host == \"www.hcpujcka.cz\" ||\n\t\treq.http.X-Referer-Host == \"www.industriallawsociety.org.uk\" ||\n\t\treq.http.X-Referer-Host == \"www.locawebcorp.com.br\" ||\n\t\treq.http.X-Referer-Host == \"giffffr.giphy.com\" ||\n\t\treq.http.X-Referer-Host == \"mccall.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"kommentatorskampen.viasatsport.se\" ||\n\t\treq.http.X-Referer-Host == \"miraclebodyandpaint.com\" ||\n\t\treq.http.X-Referer-Host == \"www.tymprozdravi.cz\" ||\n\t\treq.http.X-Referer-Host == \"delicius.it\" ||\n\t\treq.http.X-Referer-Host == \"www.bluehighwaygames.com\" ||\n\t\treq.http.X-Referer-Host == \"tales-of-pikohan.de\" ||\n\t\treq.http.X-Referer-Host == \"demo.restoreadytest.com\" ||\n\t\treq.http.X-Referer-Host == \"mark.stratmann.me\" ||\n\t\treq.http.X-Referer-Host == \"apixtechnology.com\" ||\n\t\treq.http.X-Referer-Host == \"www.telefonickapozicka.sk\" ||\n\t\treq.http.X-Referer-Host == \"www.telefonnipujcka.cz\" ||\n\t\treq.http.X-Referer-Host == \"www.iteo.no\" ||\n\t\treq.http.X-Referer-Host == \"www.diktate.info\" ||\n\t\treq.http.X-Referer-Host == \"bpharm.192.168.56.102.xip.io\" ||\n\t\treq.http.X-Referer-Host == \"www.artisanprecast.com\" ||\n\t\treq.http.X-Referer-Host == \"tcisolutions.com\" ||\n\t\treq.http.X-Referer-Host == \"icelebrate.icehotel.com\" ||\n\t\treq.http.X-Referer-Host == \"www.thirtysevenwest.com\" ||\n\t\treq.http.X-Referer-Host == \"www.asgllc.com\" ||\n\t\treq.http.X-Referer-Host == \"www.mailinbox.net\" ||\n\t\treq.http.X-Referer-Host == \"rustyfelty.com\" ||\n\t\treq.http.X-Referer-Host == \"pulse.p2c.com\" ||\n\t\treq.http.X-Referer-Host == \"www.framkino.com\" ||\n\t\treq.http.X-Referer-Host == \"armourselfstorage.com\" ||\n\t\treq.http.X-Referer-Host == \"www.dezrezblog.com\" ||\n\t\treq.http.X-Referer-Host == \"goodpeople.com\" ||\n\t\treq.http.X-Referer-Host == \"www.eden-houlgate.com\" ||\n\t\treq.http.X-Referer-Host == \"www.patiovirtual.com.br\" ||\n\t\treq.http.X-Referer-Host == \"stats.egzaminatorius.lt\" ||\n\t\treq.http.X-Referer-Host == \"www.movieville.org\" ||\n\t\treq.http.X-Referer-Host == \"secure.watchguard.com\" ||\n\t\treq.http.X-Referer-Host == \"nationalsecurities.com\" ||\n\t\treq.http.X-Referer-Host == \"www.snaponindustrial.eu\" ||\n\t\treq.http.X-Referer-Host == \"www.fangear.com\" ||\n\t\treq.http.X-Referer-Host == \"www.scribbleshop.com\" ||\n\t\treq.http.X-Referer-Host == \"forums.mulesoft.org\" ||\n\t\treq.http.X-Referer-Host == \"dataentries.in\" ||\n\t\treq.http.X-Referer-Host == \"maki.alconost.com\" ||\n\t\treq.http.X-Referer-Host == \"dixso.github.io\" ||\n\t\treq.http.X-Referer-Host == \"citaprevia.volkswagen.es\" ||\n\t\treq.http.X-Referer-Host == \"movieville.org\" ||\n\t\treq.http.X-Referer-Host == \"www.seoestudios.com\" ||\n\t\treq.http.X-Referer-Host == \"tickets.campo.nu\" ||\n\t\treq.http.X-Referer-Host == \"perriehale.toucan\" ||\n\t\treq.http.X-Referer-Host == \"online.printstation.cz\" ||\n\t\treq.http.X-Referer-Host == \"www.le-bistrot-basque.com\" ||\n\t\treq.http.X-Referer-Host == \"www.thaiartofmassage.com\" ||\n\t\treq.http.X-Referer-Host == \"www.seevolution.com\" ||\n\t\treq.http.X-Referer-Host == \"janeusa.david\" ||\n\t\treq.http.X-Referer-Host == \"www.goodpeople.com\" ||\n\t\treq.http.X-Referer-Host == \"feeds.feedburner.com\" ||\n\t\treq.http.X-Referer-Host == \"www.millwardesque.com\" ||\n\t\treq.http.X-Referer-Host == \"cci.smartucs.a\" ||\n\t\treq.http.X-Referer-Host == \"forum.tales-of-pikohan.de\" ||\n\t\treq.http.X-Referer-Host == \"small.mu\" ||\n\t\treq.http.X-Referer-Host == \"crisp.toucan\" ||\n\t\treq.http.X-Referer-Host == \"www.fosterdenovo.local\" ||\n\t\treq.http.X-Referer-Host == \"dev1776.nationalsecurities.com\" ||\n\t\treq.http.X-Referer-Host == \"byose.net\" ||\n\t\treq.http.X-Referer-Host == \"www.eurodiary.ie\" ||\n\t\treq.http.X-Referer-Host == \"lemouvementassociatif.org\" ||\n\t\treq.http.X-Referer-Host == \"www.ey.com\" ||\n\t\treq.http.X-Referer-Host == \"cuterunslive.com\" ||\n\t\treq.http.X-Referer-Host == \"blog.odynia.org\" ||\n\t\treq.http.X-Referer-Host == \"solarenaymar.com.ar\" ||\n\t\treq.http.X-Referer-Host == \"www.aispaitalia.it\" ||\n\t\treq.http.X-Referer-Host == \"www.startupsaturday.it\" ||\n\t\treq.http.X-Referer-Host == \"support.watchguard.com\" ||\n\t\treq.http.X-Referer-Host == \"dax.absolnet.se\" ||\n\t\treq.http.X-Referer-Host == \"www.creativeinnovation.net.au\" ||\n\t\treq.http.X-Referer-Host == \"dev.raird.no\" ||\n\t\treq.http.X-Referer-Host == \"lesjeteursdencre.fr\" ||\n\t\treq.http.X-Referer-Host == \"itnotes.pl\" ||\n\t\treq.http.X-Referer-Host == \"www.thesocietyinternational.com\" ||\n\t\treq.http.X-Referer-Host == \"terminalfx.com\" ||\n\t\treq.http.X-Referer-Host == \"draft.sx\" ||\n\t\treq.http.X-Referer-Host == \"atelier-florent.fr\" ||\n\t\treq.http.X-Referer-Host == \"www.buona-tavola-ristorante.fr\" ||\n\t\treq.http.X-Referer-Host == \"www.terminalfx.com\" ||\n\t\treq.http.X-Referer-Host == \"www.taxattorney.com\" ||\n\t\treq.http.X-Referer-Host == \"proenter.dev\" ||\n\t\treq.http.X-Referer-Host == \"bodelo-advocaten.be\" ||\n\t\treq.http.X-Referer-Host == \"www.football1asia.com\" ||\n\t\treq.http.X-Referer-Host == \"rets.ly\" ||\n\t\treq.http.X-Referer-Host == \"erriol.com\" ||\n\t\treq.http.X-Referer-Host == \"shssandiego.com\" ||\n\t\treq.http.X-Referer-Host == \"notecrow.appspot.com\" ||\n\t\treq.http.X-Referer-Host == \"framkino.com\" ||\n\t\treq.http.X-Referer-Host == \"sexsite.daan\" ||\n\t\treq.http.X-Referer-Host == \"sro.dk\" ||\n\t\treq.http.X-Referer-Host == \"www.coloft.com\" ||\n\t\treq.http.X-Referer-Host == \"taxiplus.vsystem.hu\" ||\n\t\treq.http.X-Referer-Host == \"stage.mulesoft.com\" ||\n\t\treq.http.X-Referer-Host == \"local.dev.ugameplan.com\" ||\n\t\treq.http.X-Referer-Host == \"posh-nosh.com\" ||\n\t\treq.http.X-Referer-Host == \"phongthuyshop.vn\" ||\n\t\treq.http.X-Referer-Host == \"local.mansionhouse.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"www.compareaccounting.com\" ||\n\t\treq.http.X-Referer-Host == \"news.coinometrics.com\" ||\n\t\treq.http.X-Referer-Host == \"prod-yann.mailinbox.net\" ||\n\t\treq.http.X-Referer-Host == \"rachelree.se\" ||\n\t\treq.http.X-Referer-Host == \"dev1.accesswireless.usdigitalpartners.net\" ||\n\t\treq.http.X-Referer-Host == \"www.ewirisk.com\" ||\n\t\treq.http.X-Referer-Host == \"snapchan.com\" ||\n\t\treq.http.X-Referer-Host == \"www.trikatasieraakademija.lv\" ||\n\t\treq.http.X-Referer-Host == \"www.fosteringadoptionswindon.org.uk\" ||\n\t\treq.http.X-Referer-Host == \"patiovirtual.com.br\" ||\n\t\treq.http.X-Referer-Host == \"www.libmanpro.com\" ||\n\t\treq.http.X-Referer-Host == \"www.diktate.dev\" ||\n\t\treq.http.X-Referer-Host == \"idisco.pianetaitalia.intra\" ||\n\t\treq.http.X-Referer-Host == \"strudelfolhadinho.com.br\" ||\n\t\treq.http.X-Referer-Host == \"www.cunesoft.com\" ||\n\t\treq.http.X-Referer-Host == \"www.shropshirefoundation.org\" ||\n\t\treq.http.X-Referer-Host == \"speakingofbeauty.tv\" ||\n\t\treq.http.X-Referer-Host == \"www.sbs.com.au\" ||\n\t\treq.http.X-Referer-Host == \"bosch.pikmahosting.de\" ||\n\t\treq.http.X-Referer-Host == \"janeusa.lol\" ||\n\t\treq.http.X-Referer-Host == \"eso.toucan\" ||\n\t\treq.http.X-Referer-Host == \"www.lamedicis.com\" ||\n\t\treq.http.X-Referer-Host == \"cereseurope.com\" ||\n\t\treq.http.X-Referer-Host == \"www.pizza-moltobene.fr\" ||\n\t\treq.http.X-Referer-Host == \"www.kaptiva.com.br\" ||\n\t\treq.http.X-Referer-Host == \"flixified.com\" ||\n\t\treq.http.X-Referer-Host == \"www.12roundsboxing.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"www.tensionautomation.com\" ||\n\t\treq.http.X-Referer-Host == \"www.copyprint.nl\" ||\n\t\treq.http.X-Referer-Host == \"unisol\" ||\n\t\treq.http.X-Referer-Host == \"timepad.ews.co.rs\" ||\n\t\treq.http.X-Referer-Host == \"dev.rets.ly\" ||\n\t\treq.http.X-Referer-Host == \"www.vrhabilis.com\" ||\n\t\treq.http.X-Referer-Host == \"trondheggelund.no\" ||\n\t\treq.http.X-Referer-Host == \"www.ferienwohnungen-lebenswert.de\" ||\n\t\treq.http.X-Referer-Host == \"blog.mainline.com\" ||\n\t\treq.http.X-Referer-Host == \"arcstonepartners.com\" ||\n\t\treq.http.X-Referer-Host == \"dev-mj\" ||\n\t\treq.http.X-Referer-Host == \"www.crisp-cpd.com\" ||\n\t\treq.http.X-Referer-Host == \"purecanadiangaming.com\" ||\n\t\treq.http.X-Referer-Host == \"mainline.com\" ||\n\t\treq.http.X-Referer-Host == \"idx.dev.rets.ly\" ||\n\t\treq.http.X-Referer-Host == \"eneco.flicker.visualwind.com\" ||\n\t\treq.http.X-Referer-Host == \"mi.etoilemedia.it\" ||\n\t\treq.http.X-Referer-Host == \"www.atmosphericwatergenerator.net\" ||\n\t\treq.http.X-Referer-Host == \"www.gasnaturalenergyclass.com\" ||\n\t\treq.http.X-Referer-Host == \"salesmarketing.championpetfoods.com\" ||\n\t\treq.http.X-Referer-Host == \"www.watchgaurd.com\" ||\n\t\treq.http.X-Referer-Host == \"vm-sqlext-svil\" ||\n\t\treq.http.X-Referer-Host == \"dev.accesswireless.usdigitalpartners.net\" ||\n\t\treq.http.X-Referer-Host == \"kommentatorskampen.ohmytest.se\" ||\n\t\treq.http.X-Referer-Host == \"m.euvivoesporte.com.br\" ||\n\t\treq.http.X-Referer-Host == \"blog.dasroot.net\" ||\n\t\treq.http.X-Referer-Host == \"bugsdashboard.com\" ||\n\t\treq.http.X-Referer-Host == \"www.eurodiary.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"seecanadabetter-app.appspot.com\" ||\n\t\treq.http.X-Referer-Host == \"www.bobbychanblog.com\" ||\n\t\treq.http.X-Referer-Host == \"www.mybenefitsatwork.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"www.fotolotos.lt\" ||\n\t\treq.http.X-Referer-Host == \"robferguson.org\" ||\n\t\treq.http.X-Referer-Host == \"staging.motherapp.com\" ||\n\t\treq.http.X-Referer-Host == \"www.undergroundminingequipmentcompaniescalgaryquotes.com\" ||\n\t\treq.http.X-Referer-Host == \"idisco.pianetaitalia.com\" ||\n\t\treq.http.X-Referer-Host == \"cliocalman.com\" ||\n\t\treq.http.X-Referer-Host == \"sexymirror-app.com\" ||\n\t\treq.http.X-Referer-Host == \"taxes-in-serbia.192.168.56.102.xip.io\" ||\n\t\treq.http.X-Referer-Host == \"wunderbiz.com\" ||\n\t\treq.http.X-Referer-Host == \"thebathpoint.webdemo.es\" ||\n\t\treq.http.X-Referer-Host == \"www.restaurant-lemenhir.com\" ||\n\t\treq.http.X-Referer-Host == \"www.valdeure.fr\" ||\n\t\treq.http.X-Referer-Host == \"bpharm.ews.co.rs\" ||\n\t\treq.http.X-Referer-Host == \"teachersdunet.com\" ||\n\t\treq.http.X-Referer-Host == \"livesmartswmo.com\" ||\n\t\treq.http.X-Referer-Host == \"javiblog.com\" ||\n\t\treq.http.X-Referer-Host == \"portal.com.local\" ||\n\t\treq.http.X-Referer-Host == \"mi.etoilemedia.com\" ||\n\t\treq.http.X-Referer-Host == \"www.lens.org\" ||\n\t\treq.http.X-Referer-Host == \"blacknet.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"my-faith-be-like.ghost.io\" ||\n\t\treq.http.X-Referer-Host == \"laravel.dev\" ||\n\t\treq.http.X-Referer-Host == \"fi-hpotts.2014-mansionhouse\" ||\n\t\treq.http.X-Referer-Host == \"mi.mailinbox.net\" ||\n\t\treq.http.X-Referer-Host == \"www.schulkeplusrewards.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"sasha-project.s3.amazonaws.com\" ||\n\t\treq.http.X-Referer-Host == \"www.solarenaymar.com.ar\" ||\n\t\treq.http.X-Referer-Host == \"generate.visualwind.com\" ||\n\t\treq.http.X-Referer-Host == \"drupaltest.wgti.net\" ||\n\t\treq.http.X-Referer-Host == \"minasdev.org\" ||\n\t\treq.http.X-Referer-Host == \"ims-logistic.dev\" ||\n\t\treq.http.X-Referer-Host == \"viaresto.com\" ||\n\t\treq.http.X-Referer-Host == \"learn.logixml.com\" ||\n\t\treq.http.X-Referer-Host == \"ox.espadrill-admin\" ||\n\t\treq.http.X-Referer-Host == \"smallmu-sandbox.s3-ap-southeast-1.amazonaws.com\" ||\n\t\treq.http.X-Referer-Host == \"www.firstinternet.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"m.facebook.com\" ||\n\t\treq.http.X-Referer-Host == \"www.ace.media\" ||\n\t\treq.http.X-Referer-Host == \"www.ewiretx.com\" ||\n\t\treq.http.X-Referer-Host == \"crisp.test.tdev.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"www.mifabricavisual.com\" ||\n\t\treq.http.X-Referer-Host == \"www.targetintervention.no\" ||\n\t\treq.http.X-Referer-Host == \"www.couperogers.com\" ||\n\t\treq.http.X-Referer-Host == \"skyhighstaging.local.com\" ||\n\t\treq.http.X-Referer-Host == \"altorendimientoacademico.queretaro.itesm.mx\" ||\n\t\treq.http.X-Referer-Host == \"www.gall-holl.com\" ||\n\t\treq.http.X-Referer-Host == \"sbs-moad.s3-ap-southeast-2.amazonaws.com\" ||\n\t\treq.http.X-Referer-Host == \"firstint.recruitment-lite\" ||\n\t\treq.http.X-Referer-Host == \"www.sro.dk\" ||\n\t\treq.http.X-Referer-Host == \"www.menbur.com\" ||\n\t\treq.http.X-Referer-Host == \"libmanpro.com\" ||\n\t\treq.http.X-Referer-Host == \"blurayaustralia.com\" ||\n\t\treq.http.X-Referer-Host == \"www.adscendmedia.com\" ||\n\t\treq.http.X-Referer-Host == \"blog.vincentbrouillet.com\" ||\n\t\treq.http.X-Referer-Host == \"www.investiumonline.nl\" ||\n\t\treq.http.X-Referer-Host == \"burakkp.com\" ||\n\t\treq.http.X-Referer-Host == \"audreysystem.seeties.me\" ||\n\t\treq.http.X-Referer-Host == \"everestsalesconsultants.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"accesswireless.usdphosting.com\" ||\n\t\treq.http.X-Referer-Host == \"frota.searh.rn.gov.br\" ||\n\t\treq.http.X-Referer-Host == \"qa.ugameplan.com\" ||\n\t\treq.http.X-Referer-Host == \"secure.yec.co\" ||\n\t\treq.http.X-Referer-Host == \"connect.eu.mulesoft.com\" ||\n\t\treq.http.X-Referer-Host == \"www.lastlongerreview.com\" ||\n\t\treq.http.X-Referer-Host == \"kommentatorskampen.lo\" ||\n\t\treq.http.X-Referer-Host == \"kido.bigroominternet.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"ohmydev.se\" ||\n\t\treq.http.X-Referer-Host == \"www.bentogarcia.es\" ||\n\t\treq.http.X-Referer-Host == \"rearview.herokai.com\" ||\n\t\treq.http.X-Referer-Host == \"lecafelatin.resto-ready.com\" ||\n\t\treq.http.X-Referer-Host == \"html24-dev.dk\" ||\n\t\treq.http.X-Referer-Host == \"seecanadabetter.ddev\" ||\n\t\treq.http.X-Referer-Host == \"portal.ad1.wrvc.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"garthwunsch.com\" ||\n\t\treq.http.X-Referer-Host == \"www.elitecustomsigns.com\" ||\n\t\treq.http.X-Referer-Host == \"kaptiva.com.br\" ||\n\t\treq.http.X-Referer-Host == \"nordicinox.com\" ||\n\t\treq.http.X-Referer-Host == \"www.nataktivisterna.lo\" ||\n\t\treq.http.X-Referer-Host == \"www.fidalgobaycoffee.com\" ||\n\t\treq.http.X-Referer-Host == \"mailinbox.net\" ||\n\t\treq.http.X-Referer-Host == \"www.tension.com\" ||\n\t\treq.http.X-Referer-Host == \"www.mccall.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"petbucks.org\" ||\n\t\treq.http.X-Referer-Host == \"mulesoftcompdev.prod.acquia-sites.com\" ||\n\t\treq.http.X-Referer-Host == \"logidev.devcloud.acquia-sites.com\" ||\n\t\treq.http.X-Referer-Host == \"www.cuterunslive.com\" ||\n\t\treq.http.X-Referer-Host == \"ec2-54-86-27-137.compute-1.amazonaws.com\" ||\n\t\treq.http.X-Referer-Host == \"coloft.com\" ||\n\t\treq.http.X-Referer-Host == \"dev-yann.mailinbox.net\" ||\n\t\treq.http.X-Referer-Host == \"titistore.es\" ||\n\t\treq.http.X-Referer-Host == \"biztro.pl\" ||\n\t\treq.http.X-Referer-Host == \"zd.ews.co.rs\" ||\n\t\treq.http.X-Referer-Host == \"www.cafelatincaen.com\" ||\n\t\treq.http.X-Referer-Host == \"togume.com\" ||\n\t\treq.http.X-Referer-Host == \"connect.mulesoft.com\" ||\n\t\treq.http.X-Referer-Host == \"che.local\" ||\n\t\treq.http.X-Referer-Host == \"nataktivisterna.lo\" ||\n\t\treq.http.X-Referer-Host == \"livelean.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"copyprint.nl\" ||\n\t\treq.http.X-Referer-Host == \"jayhathaway.com\" ||\n\t\treq.http.X-Referer-Host == \"rugsejis.epratybos.lt\" ||\n\t\treq.http.X-Referer-Host == \"media-env.elasticbeanstalk.com\" ||\n\t\treq.http.X-Referer-Host == \"id.snowfire.io\" ||\n\t\treq.http.X-Referer-Host == \"employme.at\" ||\n\t\treq.http.X-Referer-Host == \"booleanbrothers.com\" ||\n\t\treq.http.X-Referer-Host == \"www.fusiongroup.ie\" ||\n\t\treq.http.X-Referer-Host == \"skyhighnetworks.gravitatestaging.com\" ||\n\t\treq.http.X-Referer-Host == \"www.teachers.youtalkonline.com\" ||\n\t\treq.http.X-Referer-Host == \"sunshineandfrank.com\" ||\n\t\treq.http.X-Referer-Host == \"proof.acemedia.bigroominternet.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"personaltrainersinlosangeles.com\" ||\n\t\treq.http.X-Referer-Host == \"www.shawn.co\" ||\n\t\treq.http.X-Referer-Host == \"solidproperty.com.my\" ||\n\t\treq.http.X-Referer-Host == \"www.nordicinox.com\" ||\n\t\treq.http.X-Referer-Host == \"tension.com\" ||\n\t\treq.http.X-Referer-Host == \"especiaiss3.gshow.globo.com\" ||\n\t\treq.http.X-Referer-Host == \"seebstore.com\" ||\n\t\treq.http.X-Referer-Host == \"packerz.uk\" ||\n\t\treq.http.X-Referer-Host == \"happyliving.jp\" ||\n\t\treq.http.X-Referer-Host == \"www.vacacionesdebuenrollito.com\" ||\n\t\treq.http.X-Referer-Host == \"plastpack.ind.br\" ||\n\t\treq.http.X-Referer-Host == \"finance.trunk.development.manhattan.gq1.yahoo.com\" ||\n\t\treq.http.X-Referer-Host == \"elearningpprd.biworldwide.com\" ||\n\t\treq.http.X-Referer-Host == \"millwardesque.com\" ||\n\t\treq.http.X-Referer-Host == \"icehotel.lo\" ||\n\t\treq.http.X-Referer-Host == \"ongair.im\" ||\n\t\treq.http.X-Referer-Host == \"mule01a.managed.contegix.com\" ||\n\t\treq.http.X-Referer-Host == \"ipated.org\" ||\n\t\treq.http.X-Referer-Host == \"cientifica-research.com\" ||\n\t\treq.http.X-Referer-Host == \"andreypopp.github.io\" ||\n\t\treq.http.X-Referer-Host == \"schools.medsense.in\" ||\n\t\treq.http.X-Referer-Host == \"d-ycl.cigna.com\" ||\n\t\treq.http.X-Referer-Host == \"romankorver.com\" ||\n\t\treq.http.X-Referer-Host == \"ihaveanidea.me\" ||\n\t\treq.http.X-Referer-Host == \"evoyan.org\" ||\n\t\treq.http.X-Referer-Host == \"cectserver.dyndns.org\" ||\n\t\treq.http.X-Referer-Host == \"test.idx.dev.rets.ly\" ||\n\t\treq.http.X-Referer-Host == \"vastgoedpro.dataquote.nl\" ||\n\t\treq.http.X-Referer-Host == \"sifopweb\" ||\n\t\treq.http.X-Referer-Host == \"instituteofselfmastery.com.au\" ||\n\t\treq.http.X-Referer-Host == \"www.automobrella.com\" ||\n\t\treq.http.X-Referer-Host == \"panel.mibubu.com\" ||\n\t\treq.http.X-Referer-Host == \"whsb.herokuapp.com\" ||\n\t\treq.http.X-Referer-Host == \"heastea.com\" ||\n\t\treq.http.X-Referer-Host == \"meishinkan.pl\" ||\n\t\treq.http.X-Referer-Host == \"manrepeller.staging.wpengine.com\" ||\n\t\treq.http.X-Referer-Host == \"derprecated.com\" ||\n\t\treq.http.X-Referer-Host == \"fobesfamily.com\" ||\n\t\treq.http.X-Referer-Host == \"tensionautomation.com\" ||\n\t\treq.http.X-Referer-Host == \"www.jesuisoriginale.com\" ||\n\t\treq.http.X-Referer-Host == \"www.domgonsa.com.ar\" ||\n\t\treq.http.X-Referer-Host == \"www.digitalpark.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"debray.jerome.free.fr\" ||\n\t\treq.http.X-Referer-Host == \"rainmakerthinking.training\" ||\n\t\treq.http.X-Referer-Host == \"thespineauthority.com.au\" ||\n\t\treq.http.X-Referer-Host == \"pseudocubic.com\" ||\n\t\treq.http.X-Referer-Host == \"mi.sky8.it\" ||\n\t\treq.http.X-Referer-Host == \"iteo.staging.wpengine.com\" ||\n\t\treq.http.X-Referer-Host == \"adscend-q.dev\" ||\n\t\treq.http.X-Referer-Host == \"taxes-in-serbia.ews.co.rs\" ||\n\t\treq.http.X-Referer-Host == \"s.codepen.io\" ||\n\t\treq.http.X-Referer-Host == \"seecanadabetter.ca\" ||\n\t\treq.http.X-Referer-Host == \"www.werkbund.com.br\" ||\n\t\treq.http.X-Referer-Host == \"www.art365.co.za\" ||\n\t\treq.http.X-Referer-Host == \"tensionpackaging.com\" ||\n\t\treq.http.X-Referer-Host == \"ec2-54-164-179-111.compute-1.amazonaws.com\" ||\n\t\treq.http.X-Referer-Host == \"sms.loc\" ||\n\t\treq.http.X-Referer-Host == \"timeclock.neonandmore.com\" ||\n\t\treq.http.X-Referer-Host == \"silverblingblack.com\" ||\n\t\treq.http.X-Referer-Host == \"www.modulolanguage.com\" ||\n\t\treq.http.X-Referer-Host == \"visualise.today\" ||\n\t\treq.http.X-Referer-Host == \"pickinglist.constance.com.br\" ||\n\t\treq.http.X-Referer-Host == \"mobileshoppingapps.net\" ||\n\t\treq.http.X-Referer-Host == \"ashleyandbarry.com\" ||\n\t\treq.http.X-Referer-Host == \"www.planetgreen.cl\" ||\n\t\treq.http.X-Referer-Host == \"portal-intranet.ti.sabesp.com.br\" ||\n\t\treq.http.X-Referer-Host == \"gordonrecords.net\" ||\n\t\treq.http.X-Referer-Host == \"cce.pathlore.net\" ||\n\t\treq.http.X-Referer-Host == \"www.myclaimvalue.com\" ||\n\t\treq.http.X-Referer-Host == \"stage.mulesoft.org\" ||\n\t\treq.http.X-Referer-Host == \"javiblog.javigs.es\"\n\t) {\n\t\tset req.http.X-Redir-URL = \"https:\/\/legacy.polyfill.io\" req.url;\n\t\terror 900 req.http.X-Redir-URL;\n\t}\n\n\tif (req.url ~ \"^\/v1\/polyfill\\.\" && req.url !~ \"[\\?\\&]ua=\") {\n\t\tset req.http.X-Orig-URL = req.url;\n\t\tset req.url = \"\/v1\/normalizeUa?ua=\" regsuball(regsuball(regsuball(req.http.User-Agent, {\"%\"}, {\"%25\"}), {\" \"}, {\"%20\"}), {\"&\"}, {\"%26\"});\n\t}\n\n\treturn(lookup);\n}\n\nsub vcl_deliver {\n#FASTLY deliver\n\tif (req.url ~ \"^\/v1\/normalizeUa\" && resp.status == 200) {\n\t\tset req.http.Fastly-force-Shield = \"1\";\n\t\tif (req.http.X-Orig-URL ~ \"\\?\") {\n\t\t\tset req.url = req.http.X-Orig-URL \"&ua=\" resp.http.Normalized-User-Agent;\n\t\t} else {\n\t\t\tset req.url = req.http.X-Orig-URL \"?ua=\" resp.http.Normalized-User-Agent;\n\t\t}\n\t\trestart;\n\t} else if (req.url ~ \"^\/v1\/polyfill\\..*[\\?\\&]ua=\" && req.http.X-Orig-URL && req.http.X-Orig-URL !~ \"[\\?\\&]ua=\") {\n\t\tset resp.http.Vary = \"Accept-Encoding, User-Agent\";\n\t}\n\treturn(deliver);\n}\n\nsub vcl_error {\n\tif (obj.status == 900) {\n\t\tset obj.http.Location = obj.response;\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\tsynthetic {\"The referer header or request URI supplied in your request is known to be an attempt to use the previous version of polyfill.io, so for backwards compatibility we're redirecting you to legacy.polyfill.io which will handle your request using the old version of the service. The legacy version will be discontinued in the future, so please update to the new version, and then let us know by raising an issue in our repo at https:\/\/github.com\/financial-times\/polyfill-service.\"};\n\t\treturn (deliver);\n\t}\n}\n","old_contents":"sub vcl_recv {\n#FASTLY recv\n\n\tif (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n\t return(pass);\n\t}\n\n\t# Redirect legacy service users to legacy service\n\tset req.http.X-Referer-Host = regsub(req.http.Referer, \"^https?\\:\\\/\\\/([^\\\/]+)(\\\/.*)?$\", \"\\1\");\n\tif (req.url == \"\/normalize.js\" ||\n\t\treq.url == \"\/normalize.css\" ||\n\t\treq.url == \"\/normalise.js\" ||\n\t\treq.url == \"\/normalise.css\" ||\n\t\treq.http.X-Referer-Host == \"www.manrepeller.com\" ||\n\t\treq.http.X-Referer-Host == \"www.mulesoft.com\" ||\n\t\treq.http.X-Referer-Host == \"iluoghidelcuore.it\" ||\n\t\treq.http.X-Referer-Host == \"it.donga.com\" ||\n\t\treq.http.X-Referer-Host == \"www.watchguard.com\" ||\n\t\treq.http.X-Referer-Host == \"www.mulesoft.org\" ||\n\t\treq.http.X-Referer-Host == \"asmwall.com\" ||\n\t\treq.http.X-Referer-Host == \"www.jcsu.edu\" ||\n\t\treq.http.X-Referer-Host == \"adscendmedia.com\" ||\n\t\treq.http.X-Referer-Host == \"game.donga.com\" ||\n\t\treq.http.X-Referer-Host == \"framkino.no\" ||\n\t\treq.http.X-Referer-Host == \"www.accesswireless.com\" ||\n\t\treq.http.X-Referer-Host == \"represent.com\" ||\n\t\treq.http.X-Referer-Host == \"www.designergreek.com\" ||\n\t\treq.http.X-Referer-Host == \"www.plumbingoverstock.com\" ||\n\t\treq.http.X-Referer-Host == \"servicos.searh.rn.gov.br\" ||\n\t\treq.http.X-Referer-Host == \"www.jane-usa.com\" ||\n\t\treq.http.X-Referer-Host == \"www.juntaempresa.com.br\" ||\n\t\treq.http.X-Referer-Host == \"watchguard.com\" ||\n\t\treq.http.X-Referer-Host == \"www.logianalytics.com\" ||\n\t\treq.http.X-Referer-Host == \"www.thebathpoint.com\" ||\n\t\treq.http.X-Referer-Host == \"blogs.mulesoft.org\" ||\n\t\treq.http.X-Referer-Host == \"www.purecanadiangaming.com\" ||\n\t\treq.http.X-Referer-Host == \"play.egzaminatorius.lt\" ||\n\t\treq.http.X-Referer-Host == \"internetacademi.com\" ||\n\t\treq.http.X-Referer-Host == \"www.skyhighnetworks.com\" ||\n\t\treq.http.X-Referer-Host == \"interactive.guim.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"www.soloio.com\" ||\n\t\treq.http.X-Referer-Host == \"desenvolvimentoparaweb.com\" ||\n\t\treq.http.X-Referer-Host == \"daily-fantasy.trunk.development.manhattan.gq1.yahoo.com\" ||\n\t\treq.http.X-Referer-Host == \"blog.damyller.com.br\" ||\n\t\treq.http.X-Referer-Host == \"doggiebag.no\" ||\n\t\treq.http.X-Referer-Host == \"www.beverlydiamonds.com\" ||\n\t\treq.http.X-Referer-Host == \"www.rogerscup.com\" ||\n\t\treq.http.X-Referer-Host == \"blog.hudy.cz\" ||\n\t\treq.http.X-Referer-Host == \"techhamlet.com\" ||\n\t\treq.http.X-Referer-Host == \"www.flirtfachmann.de\" ||\n\t\treq.http.X-Referer-Host == \"alpacacomics.com\" ||\n\t\treq.http.X-Referer-Host == \"areariservata.fondoprevidenzafinanze.it\" ||\n\t\treq.http.X-Referer-Host == \"www.framkino.no\" ||\n\t\treq.http.X-Referer-Host == \"www.nationalsecurities.com\" ||\n\t\treq.http.X-Referer-Host == \"www.tenniscanada.com\" ||\n\t\treq.http.X-Referer-Host == \"libek.org.rs\" ||\n\t\treq.http.X-Referer-Host == \"learn.logianalytics.com\" ||\n\t\treq.http.X-Referer-Host == \"www.impartner.lt\" ||\n\t\treq.http.X-Referer-Host == \"chameleon.biworldwide.com\" ||\n\t\treq.http.X-Referer-Host == \"www.pujckapowebu.cz\" ||\n\t\treq.http.X-Referer-Host == \"www.dlcnetwork.com\" ||\n\t\treq.http.X-Referer-Host == \"www.forbes.com\" ||\n\t\treq.http.X-Referer-Host == \"blog.skyhighnetworks.com\" ||\n\t\treq.http.X-Referer-Host == \"rflx.bjornborg.com\" ||\n\t\treq.http.X-Referer-Host == \"www.coach-outlet-store.com\" ||\n\t\treq.http.X-Referer-Host == \"gist.io\" ||\n\t\treq.http.X-Referer-Host == \"www.suicideispreventable.org\" ||\n\t\treq.http.X-Referer-Host == \"www.rangemastertacticalgear.com\" ||\n\t\treq.http.X-Referer-Host == \"www.hcpozicka.sk\" ||\n\t\treq.http.X-Referer-Host == \"www.airsoftmegastore.com\" ||\n\t\treq.http.X-Referer-Host == \"colortile.github.io\" ||\n\t\treq.http.X-Referer-Host == \"brasstacksmadras.com\" ||\n\t\treq.http.X-Referer-Host == \"hotelcasadomingo.com.mx\" ||\n\t\treq.http.X-Referer-Host == \"client.local\" ||\n\t\treq.http.X-Referer-Host == \"www.worcesterpromotions.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"www.asmwall.com\" ||\n\t\treq.http.X-Referer-Host == \"training.mulesoft.com\" ||\n\t\treq.http.X-Referer-Host == \"localhost\" ||\n\t\treq.http.X-Referer-Host == \"exhilarateme.com\" ||\n\t\treq.http.X-Referer-Host == \"www.kommentatorskampen.viasatsport.se\" ||\n\t\treq.http.X-Referer-Host == \"www.golfgearselect.com\" ||\n\t\treq.http.X-Referer-Host == \"www.hcpujcka.cz\" ||\n\t\treq.http.X-Referer-Host == \"www.industriallawsociety.org.uk\" ||\n\t\treq.http.X-Referer-Host == \"www.locawebcorp.com.br\" ||\n\t\treq.http.X-Referer-Host == \"giffffr.giphy.com\" ||\n\t\treq.http.X-Referer-Host == \"mccall.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"kommentatorskampen.viasatsport.se\" ||\n\t\treq.http.X-Referer-Host == \"bpharm.localhost\" ||\n\t\treq.http.X-Referer-Host == \"miraclebodyandpaint.com\" ||\n\t\treq.http.X-Referer-Host == \"www.tymprozdravi.cz\" ||\n\t\treq.http.X-Referer-Host == \"delicius.it\" ||\n\t\treq.http.X-Referer-Host == \"www.bluehighwaygames.com\" ||\n\t\treq.http.X-Referer-Host == \"tales-of-pikohan.de\" ||\n\t\treq.http.X-Referer-Host == \"demo.restoreadytest.com\" ||\n\t\treq.http.X-Referer-Host == \"mark.stratmann.me\" ||\n\t\treq.http.X-Referer-Host == \"apixtechnology.com\" ||\n\t\treq.http.X-Referer-Host == \"www.telefonickapozicka.sk\" ||\n\t\treq.http.X-Referer-Host == \"www.telefonnipujcka.cz\" ||\n\t\treq.http.X-Referer-Host == \"www.iteo.no\" ||\n\t\treq.http.X-Referer-Host == \"www.diktate.info\" ||\n\t\treq.http.X-Referer-Host == \"bpharm.192.168.56.102.xip.io\" ||\n\t\treq.http.X-Referer-Host == \"www.artisanprecast.com\" ||\n\t\treq.http.X-Referer-Host == \"tcisolutions.com\" ||\n\t\treq.http.X-Referer-Host == \"icelebrate.icehotel.com\" ||\n\t\treq.http.X-Referer-Host == \"www.thirtysevenwest.com\" ||\n\t\treq.http.X-Referer-Host == \"www.asgllc.com\" ||\n\t\treq.http.X-Referer-Host == \"www.mailinbox.net\" ||\n\t\treq.http.X-Referer-Host == \"rustyfelty.com\" ||\n\t\treq.http.X-Referer-Host == \"pulse.p2c.com\" ||\n\t\treq.http.X-Referer-Host == \"www.framkino.com\" ||\n\t\treq.http.X-Referer-Host == \"armourselfstorage.com\" ||\n\t\treq.http.X-Referer-Host == \"www.dezrezblog.com\" ||\n\t\treq.http.X-Referer-Host == \"goodpeople.com\" ||\n\t\treq.http.X-Referer-Host == \"survey-project.localhost\" ||\n\t\treq.http.X-Referer-Host == \"www.eden-houlgate.com\" ||\n\t\treq.http.X-Referer-Host == \"www.patiovirtual.com.br\" ||\n\t\treq.http.X-Referer-Host == \"stats.egzaminatorius.lt\" ||\n\t\treq.http.X-Referer-Host == \"www.movieville.org\" ||\n\t\treq.http.X-Referer-Host == \"secure.watchguard.com\" ||\n\t\treq.http.X-Referer-Host == \"nationalsecurities.com\" ||\n\t\treq.http.X-Referer-Host == \"timepad.localhost\" ||\n\t\treq.http.X-Referer-Host == \"www.snaponindustrial.eu\" ||\n\t\treq.http.X-Referer-Host == \"www.fangear.com\" ||\n\t\treq.http.X-Referer-Host == \"www.scribbleshop.com\" ||\n\t\treq.http.X-Referer-Host == \"forums.mulesoft.org\" ||\n\t\treq.http.X-Referer-Host == \"dataentries.in\" ||\n\t\treq.http.X-Referer-Host == \"maki.alconost.com\" ||\n\t\treq.http.X-Referer-Host == \"dixso.github.io\" ||\n\t\treq.http.X-Referer-Host == \"citaprevia.volkswagen.es\" ||\n\t\treq.http.X-Referer-Host == \"movieville.org\" ||\n\t\treq.http.X-Referer-Host == \"www.seoestudios.com\" ||\n\t\treq.http.X-Referer-Host == \"tickets.campo.nu\" ||\n\t\treq.http.X-Referer-Host == \"perriehale.toucan\" ||\n\t\treq.http.X-Referer-Host == \"online.printstation.cz\" ||\n\t\treq.http.X-Referer-Host == \"www.le-bistrot-basque.com\" ||\n\t\treq.http.X-Referer-Host == \"www.thaiartofmassage.com\" ||\n\t\treq.http.X-Referer-Host == \"www.seevolution.com\" ||\n\t\treq.http.X-Referer-Host == \"janeusa.david\" ||\n\t\treq.http.X-Referer-Host == \"www.goodpeople.com\" ||\n\t\treq.http.X-Referer-Host == \"feeds.feedburner.com\" ||\n\t\treq.http.X-Referer-Host == \"www.millwardesque.com\" ||\n\t\treq.http.X-Referer-Host == \"cci.smartucs.a\" ||\n\t\treq.http.X-Referer-Host == \"forum.tales-of-pikohan.de\" ||\n\t\treq.http.X-Referer-Host == \"small.mu\" ||\n\t\treq.http.X-Referer-Host == \"crisp.toucan\" ||\n\t\treq.http.X-Referer-Host == \"www.fosterdenovo.local\" ||\n\t\treq.http.X-Referer-Host == \"dev1776.nationalsecurities.com\" ||\n\t\treq.http.X-Referer-Host == \"byose.net\" ||\n\t\treq.http.X-Referer-Host == \"www.eurodiary.ie\" ||\n\t\treq.http.X-Referer-Host == \"lemouvementassociatif.org\" ||\n\t\treq.http.X-Referer-Host == \"www.ey.com\" ||\n\t\treq.http.X-Referer-Host == \"cuterunslive.com\" ||\n\t\treq.http.X-Referer-Host == \"taxes-in-serbia.localhost\" ||\n\t\treq.http.X-Referer-Host == \"blog.odynia.org\" ||\n\t\treq.http.X-Referer-Host == \"solarenaymar.com.ar\" ||\n\t\treq.http.X-Referer-Host == \"www.aispaitalia.it\" ||\n\t\treq.http.X-Referer-Host == \"www.startupsaturday.it\" ||\n\t\treq.http.X-Referer-Host == \"support.watchguard.com\" ||\n\t\treq.http.X-Referer-Host == \"dax.absolnet.se\" ||\n\t\treq.http.X-Referer-Host == \"www.creativeinnovation.net.au\" ||\n\t\treq.http.X-Referer-Host == \"dev.raird.no\" ||\n\t\treq.http.X-Referer-Host == \"lesjeteursdencre.fr\" ||\n\t\treq.http.X-Referer-Host == \"itnotes.pl\" ||\n\t\treq.http.X-Referer-Host == \"www.thesocietyinternational.com\" ||\n\t\treq.http.X-Referer-Host == \"terminalfx.com\" ||\n\t\treq.http.X-Referer-Host == \"draft.sx\" ||\n\t\treq.http.X-Referer-Host == \"atelier-florent.fr\" ||\n\t\treq.http.X-Referer-Host == \"www.buona-tavola-ristorante.fr\" ||\n\t\treq.http.X-Referer-Host == \"www.terminalfx.com\" ||\n\t\treq.http.X-Referer-Host == \"www.taxattorney.com\" ||\n\t\treq.http.X-Referer-Host == \"proenter.dev\" ||\n\t\treq.http.X-Referer-Host == \"bodelo-advocaten.be\" ||\n\t\treq.http.X-Referer-Host == \"www.football1asia.com\" ||\n\t\treq.http.X-Referer-Host == \"rets.ly\" ||\n\t\treq.http.X-Referer-Host == \"erriol.com\" ||\n\t\treq.http.X-Referer-Host == \"shssandiego.com\" ||\n\t\treq.http.X-Referer-Host == \"notecrow.appspot.com\" ||\n\t\treq.http.X-Referer-Host == \"framkino.com\" ||\n\t\treq.http.X-Referer-Host == \"sexsite.daan\" ||\n\t\treq.http.X-Referer-Host == \"sro.dk\" ||\n\t\treq.http.X-Referer-Host == \"www.coloft.com\" ||\n\t\treq.http.X-Referer-Host == \"taxiplus.vsystem.hu\" ||\n\t\treq.http.X-Referer-Host == \"stage.mulesoft.com\" ||\n\t\treq.http.X-Referer-Host == \"local.dev.ugameplan.com\" ||\n\t\treq.http.X-Referer-Host == \"posh-nosh.com\" ||\n\t\treq.http.X-Referer-Host == \"phongthuyshop.vn\" ||\n\t\treq.http.X-Referer-Host == \"local.mansionhouse.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"www.compareaccounting.com\" ||\n\t\treq.http.X-Referer-Host == \"news.coinometrics.com\" ||\n\t\treq.http.X-Referer-Host == \"prod-yann.mailinbox.net\" ||\n\t\treq.http.X-Referer-Host == \"rachelree.se\" ||\n\t\treq.http.X-Referer-Host == \"dev1.accesswireless.usdigitalpartners.net\" ||\n\t\treq.http.X-Referer-Host == \"www.ewirisk.com\" ||\n\t\treq.http.X-Referer-Host == \"snapchan.com\" ||\n\t\treq.http.X-Referer-Host == \"www.trikatasieraakademija.lv\" ||\n\t\treq.http.X-Referer-Host == \"www.fosteringadoptionswindon.org.uk\" ||\n\t\treq.http.X-Referer-Host == \"patiovirtual.com.br\" ||\n\t\treq.http.X-Referer-Host == \"www.libmanpro.com\" ||\n\t\treq.http.X-Referer-Host == \"www.diktate.dev\" ||\n\t\treq.http.X-Referer-Host == \"idisco.pianetaitalia.intra\" ||\n\t\treq.http.X-Referer-Host == \"strudelfolhadinho.com.br\" ||\n\t\treq.http.X-Referer-Host == \"www.cunesoft.com\" ||\n\t\treq.http.X-Referer-Host == \"www.shropshirefoundation.org\" ||\n\t\treq.http.X-Referer-Host == \"speakingofbeauty.tv\" ||\n\t\treq.http.X-Referer-Host == \"www.sbs.com.au\" ||\n\t\treq.http.X-Referer-Host == \"bosch.pikmahosting.de\" ||\n\t\treq.http.X-Referer-Host == \"janeusa.lol\" ||\n\t\treq.http.X-Referer-Host == \"eso.toucan\" ||\n\t\treq.http.X-Referer-Host == \"www.lamedicis.com\" ||\n\t\treq.http.X-Referer-Host == \"cereseurope.com\" ||\n\t\treq.http.X-Referer-Host == \"www.pizza-moltobene.fr\" ||\n\t\treq.http.X-Referer-Host == \"www.kaptiva.com.br\" ||\n\t\treq.http.X-Referer-Host == \"flixified.com\" ||\n\t\treq.http.X-Referer-Host == \"www.12roundsboxing.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"www.tensionautomation.com\" ||\n\t\treq.http.X-Referer-Host == \"www.copyprint.nl\" ||\n\t\treq.http.X-Referer-Host == \"unisol\" ||\n\t\treq.http.X-Referer-Host == \"timepad.ews.co.rs\" ||\n\t\treq.http.X-Referer-Host == \"dev.rets.ly\" ||\n\t\treq.http.X-Referer-Host == \"www.vrhabilis.com\" ||\n\t\treq.http.X-Referer-Host == \"trondheggelund.no\" ||\n\t\treq.http.X-Referer-Host == \"www.ferienwohnungen-lebenswert.de\" ||\n\t\treq.http.X-Referer-Host == \"blog.mainline.com\" ||\n\t\treq.http.X-Referer-Host == \"arcstonepartners.com\" ||\n\t\treq.http.X-Referer-Host == \"dev-mj\" ||\n\t\treq.http.X-Referer-Host == \"www.crisp-cpd.com\" ||\n\t\treq.http.X-Referer-Host == \"purecanadiangaming.com\" ||\n\t\treq.http.X-Referer-Host == \"mainline.com\" ||\n\t\treq.http.X-Referer-Host == \"idx.dev.rets.ly\" ||\n\t\treq.http.X-Referer-Host == \"eneco.flicker.visualwind.com\" ||\n\t\treq.http.X-Referer-Host == \"mi.etoilemedia.it\" ||\n\t\treq.http.X-Referer-Host == \"www.atmosphericwatergenerator.net\" ||\n\t\treq.http.X-Referer-Host == \"www.gasnaturalenergyclass.com\" ||\n\t\treq.http.X-Referer-Host == \"salesmarketing.championpetfoods.com\" ||\n\t\treq.http.X-Referer-Host == \"www.watchgaurd.com\" ||\n\t\treq.http.X-Referer-Host == \"vm-sqlext-svil\" ||\n\t\treq.http.X-Referer-Host == \"dev.accesswireless.usdigitalpartners.net\" ||\n\t\treq.http.X-Referer-Host == \"kommentatorskampen.ohmytest.se\" ||\n\t\treq.http.X-Referer-Host == \"m.euvivoesporte.com.br\" ||\n\t\treq.http.X-Referer-Host == \"blog.dasroot.net\" ||\n\t\treq.http.X-Referer-Host == \"bugsdashboard.com\" ||\n\t\treq.http.X-Referer-Host == \"www.eurodiary.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"seecanadabetter-app.appspot.com\" ||\n\t\treq.http.X-Referer-Host == \"www.bobbychanblog.com\" ||\n\t\treq.http.X-Referer-Host == \"www.mybenefitsatwork.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"www.fotolotos.lt\" ||\n\t\treq.http.X-Referer-Host == \"robferguson.org\" ||\n\t\treq.http.X-Referer-Host == \"staging.motherapp.com\" ||\n\t\treq.http.X-Referer-Host == \"www.undergroundminingequipmentcompaniescalgaryquotes.com\" ||\n\t\treq.http.X-Referer-Host == \"idisco.pianetaitalia.com\" ||\n\t\treq.http.X-Referer-Host == \"cliocalman.com\" ||\n\t\treq.http.X-Referer-Host == \"sexymirror-app.com\" ||\n\t\treq.http.X-Referer-Host == \"taxes-in-serbia.192.168.56.102.xip.io\" ||\n\t\treq.http.X-Referer-Host == \"wunderbiz.com\" ||\n\t\treq.http.X-Referer-Host == \"thebathpoint.webdemo.es\" ||\n\t\treq.http.X-Referer-Host == \"www.restaurant-lemenhir.com\" ||\n\t\treq.http.X-Referer-Host == \"www.valdeure.fr\" ||\n\t\treq.http.X-Referer-Host == \"bpharm.ews.co.rs\" ||\n\t\treq.http.X-Referer-Host == \"teachersdunet.com\" ||\n\t\treq.http.X-Referer-Host == \"livesmartswmo.com\" ||\n\t\treq.http.X-Referer-Host == \"javiblog.com\" ||\n\t\treq.http.X-Referer-Host == \"portal.com.local\" ||\n\t\treq.http.X-Referer-Host == \"mi.etoilemedia.com\" ||\n\t\treq.http.X-Referer-Host == \"www.lens.org\" ||\n\t\treq.http.X-Referer-Host == \"blacknet.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"my-faith-be-like.ghost.io\" ||\n\t\treq.http.X-Referer-Host == \"laravel.dev\" ||\n\t\treq.http.X-Referer-Host == \"fi-hpotts.2014-mansionhouse\" ||\n\t\treq.http.X-Referer-Host == \"mi.mailinbox.net\" ||\n\t\treq.http.X-Referer-Host == \"www.schulkeplusrewards.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"sasha-project.s3.amazonaws.com\" ||\n\t\treq.http.X-Referer-Host == \"www.solarenaymar.com.ar\" ||\n\t\treq.http.X-Referer-Host == \"generate.visualwind.com\" ||\n\t\treq.http.X-Referer-Host == \"drupaltest.wgti.net\" ||\n\t\treq.http.X-Referer-Host == \"minasdev.org\" ||\n\t\treq.http.X-Referer-Host == \"ims-logistic.dev\" ||\n\t\treq.http.X-Referer-Host == \"viaresto.com\" ||\n\t\treq.http.X-Referer-Host == \"learn.logixml.com\" ||\n\t\treq.http.X-Referer-Host == \"ox.espadrill-admin\" ||\n\t\treq.http.X-Referer-Host == \"smallmu-sandbox.s3-ap-southeast-1.amazonaws.com\" ||\n\t\treq.http.X-Referer-Host == \"www.firstinternet.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"m.facebook.com\" ||\n\t\treq.http.X-Referer-Host == \"www.ace.media\" ||\n\t\treq.http.X-Referer-Host == \"www.ewiretx.com\" ||\n\t\treq.http.X-Referer-Host == \"crisp.test.tdev.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"www.mifabricavisual.com\" ||\n\t\treq.http.X-Referer-Host == \"www.targetintervention.no\" ||\n\t\treq.http.X-Referer-Host == \"www.couperogers.com\" ||\n\t\treq.http.X-Referer-Host == \"skyhighstaging.local.com\" ||\n\t\treq.http.X-Referer-Host == \"altorendimientoacademico.queretaro.itesm.mx\" ||\n\t\treq.http.X-Referer-Host == \"www.gall-holl.com\" ||\n\t\treq.http.X-Referer-Host == \"sbs-moad.s3-ap-southeast-2.amazonaws.com\" ||\n\t\treq.http.X-Referer-Host == \"firstint.recruitment-lite\" ||\n\t\treq.http.X-Referer-Host == \"www.sro.dk\" ||\n\t\treq.http.X-Referer-Host == \"www.menbur.com\" ||\n\t\treq.http.X-Referer-Host == \"libmanpro.com\" ||\n\t\treq.http.X-Referer-Host == \"blurayaustralia.com\" ||\n\t\treq.http.X-Referer-Host == \"www.adscendmedia.com\" ||\n\t\treq.http.X-Referer-Host == \"blog.vincentbrouillet.com\" ||\n\t\treq.http.X-Referer-Host == \"www.investiumonline.nl\" ||\n\t\treq.http.X-Referer-Host == \"burakkp.com\" ||\n\t\treq.http.X-Referer-Host == \"audreysystem.seeties.me\" ||\n\t\treq.http.X-Referer-Host == \"everestsalesconsultants.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"accesswireless.usdphosting.com\" ||\n\t\treq.http.X-Referer-Host == \"frota.searh.rn.gov.br\" ||\n\t\treq.http.X-Referer-Host == \"qa.ugameplan.com\" ||\n\t\treq.http.X-Referer-Host == \"secure.yec.co\" ||\n\t\treq.http.X-Referer-Host == \"connect.eu.mulesoft.com\" ||\n\t\treq.http.X-Referer-Host == \"www.lastlongerreview.com\" ||\n\t\treq.http.X-Referer-Host == \"kommentatorskampen.lo\" ||\n\t\treq.http.X-Referer-Host == \"kido.bigroominternet.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"ohmydev.se\" ||\n\t\treq.http.X-Referer-Host == \"www.bentogarcia.es\" ||\n\t\treq.http.X-Referer-Host == \"rearview.herokai.com\" ||\n\t\treq.http.X-Referer-Host == \"lecafelatin.resto-ready.com\" ||\n\t\treq.http.X-Referer-Host == \"html24-dev.dk\" ||\n\t\treq.http.X-Referer-Host == \"seecanadabetter.ddev\" ||\n\t\treq.http.X-Referer-Host == \"portal.ad1.wrvc.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"garthwunsch.com\" ||\n\t\treq.http.X-Referer-Host == \"www.elitecustomsigns.com\" ||\n\t\treq.http.X-Referer-Host == \"kaptiva.com.br\" ||\n\t\treq.http.X-Referer-Host == \"nordicinox.com\" ||\n\t\treq.http.X-Referer-Host == \"www.nataktivisterna.lo\" ||\n\t\treq.http.X-Referer-Host == \"www.fidalgobaycoffee.com\" ||\n\t\treq.http.X-Referer-Host == \"mailinbox.net\" ||\n\t\treq.http.X-Referer-Host == \"www.tension.com\" ||\n\t\treq.http.X-Referer-Host == \"www.mccall.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"petbucks.org\" ||\n\t\treq.http.X-Referer-Host == \"mulesoftcompdev.prod.acquia-sites.com\" ||\n\t\treq.http.X-Referer-Host == \"logidev.devcloud.acquia-sites.com\" ||\n\t\treq.http.X-Referer-Host == \"www.cuterunslive.com\" ||\n\t\treq.http.X-Referer-Host == \"ec2-54-86-27-137.compute-1.amazonaws.com\" ||\n\t\treq.http.X-Referer-Host == \"coloft.com\" ||\n\t\treq.http.X-Referer-Host == \"dev-yann.mailinbox.net\" ||\n\t\treq.http.X-Referer-Host == \"titistore.es\" ||\n\t\treq.http.X-Referer-Host == \"biztro.pl\" ||\n\t\treq.http.X-Referer-Host == \"zd.ews.co.rs\" ||\n\t\treq.http.X-Referer-Host == \"www.cafelatincaen.com\" ||\n\t\treq.http.X-Referer-Host == \"togume.com\" ||\n\t\treq.http.X-Referer-Host == \"connect.mulesoft.com\" ||\n\t\treq.http.X-Referer-Host == \"che.local\" ||\n\t\treq.http.X-Referer-Host == \"nataktivisterna.lo\" ||\n\t\treq.http.X-Referer-Host == \"livelean.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"copyprint.nl\" ||\n\t\treq.http.X-Referer-Host == \"jayhathaway.com\" ||\n\t\treq.http.X-Referer-Host == \"rugsejis.epratybos.lt\" ||\n\t\treq.http.X-Referer-Host == \"media-env.elasticbeanstalk.com\" ||\n\t\treq.http.X-Referer-Host == \"id.snowfire.io\" ||\n\t\treq.http.X-Referer-Host == \"employme.at\" ||\n\t\treq.http.X-Referer-Host == \"booleanbrothers.com\" ||\n\t\treq.http.X-Referer-Host == \"www.fusiongroup.ie\" ||\n\t\treq.http.X-Referer-Host == \"skyhighnetworks.gravitatestaging.com\" ||\n\t\treq.http.X-Referer-Host == \"www.teachers.youtalkonline.com\" ||\n\t\treq.http.X-Referer-Host == \"sunshineandfrank.com\" ||\n\t\treq.http.X-Referer-Host == \"proof.acemedia.bigroominternet.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"personaltrainersinlosangeles.com\" ||\n\t\treq.http.X-Referer-Host == \"www.shawn.co\" ||\n\t\treq.http.X-Referer-Host == \"solidproperty.com.my\" ||\n\t\treq.http.X-Referer-Host == \"www.nordicinox.com\" ||\n\t\treq.http.X-Referer-Host == \"tension.com\" ||\n\t\treq.http.X-Referer-Host == \"especiaiss3.gshow.globo.com\" ||\n\t\treq.http.X-Referer-Host == \"seebstore.com\" ||\n\t\treq.http.X-Referer-Host == \"packerz.uk\" ||\n\t\treq.http.X-Referer-Host == \"happyliving.jp\" ||\n\t\treq.http.X-Referer-Host == \"www.vacacionesdebuenrollito.com\" ||\n\t\treq.http.X-Referer-Host == \"plastpack.ind.br\" ||\n\t\treq.http.X-Referer-Host == \"finance.trunk.development.manhattan.gq1.yahoo.com\" ||\n\t\treq.http.X-Referer-Host == \"elearningpprd.biworldwide.com\" ||\n\t\treq.http.X-Referer-Host == \"millwardesque.com\" ||\n\t\treq.http.X-Referer-Host == \"icehotel.lo\" ||\n\t\treq.http.X-Referer-Host == \"ongair.im\" ||\n\t\treq.http.X-Referer-Host == \"mule01a.managed.contegix.com\" ||\n\t\treq.http.X-Referer-Host == \"ipated.org\" ||\n\t\treq.http.X-Referer-Host == \"cientifica-research.com\" ||\n\t\treq.http.X-Referer-Host == \"andreypopp.github.io\" ||\n\t\treq.http.X-Referer-Host == \"schools.medsense.in\" ||\n\t\treq.http.X-Referer-Host == \"d-ycl.cigna.com\" ||\n\t\treq.http.X-Referer-Host == \"romankorver.com\" ||\n\t\treq.http.X-Referer-Host == \"ihaveanidea.me\" ||\n\t\treq.http.X-Referer-Host == \"evoyan.org\" ||\n\t\treq.http.X-Referer-Host == \"cectserver.dyndns.org\" ||\n\t\treq.http.X-Referer-Host == \"test.idx.dev.rets.ly\" ||\n\t\treq.http.X-Referer-Host == \"vastgoedpro.dataquote.nl\" ||\n\t\treq.http.X-Referer-Host == \"sifopweb\" ||\n\t\treq.http.X-Referer-Host == \"instituteofselfmastery.com.au\" ||\n\t\treq.http.X-Referer-Host == \"www.automobrella.com\" ||\n\t\treq.http.X-Referer-Host == \"panel.mibubu.com\" ||\n\t\treq.http.X-Referer-Host == \"whsb.herokuapp.com\" ||\n\t\treq.http.X-Referer-Host == \"heastea.com\" ||\n\t\treq.http.X-Referer-Host == \"meishinkan.pl\" ||\n\t\treq.http.X-Referer-Host == \"manrepeller.staging.wpengine.com\" ||\n\t\treq.http.X-Referer-Host == \"derprecated.com\" ||\n\t\treq.http.X-Referer-Host == \"fobesfamily.com\" ||\n\t\treq.http.X-Referer-Host == \"tensionautomation.com\" ||\n\t\treq.http.X-Referer-Host == \"www.jesuisoriginale.com\" ||\n\t\treq.http.X-Referer-Host == \"www.domgonsa.com.ar\" ||\n\t\treq.http.X-Referer-Host == \"www.digitalpark.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"debray.jerome.free.fr\" ||\n\t\treq.http.X-Referer-Host == \"rainmakerthinking.training\" ||\n\t\treq.http.X-Referer-Host == \"thespineauthority.com.au\" ||\n\t\treq.http.X-Referer-Host == \"pseudocubic.com\" ||\n\t\treq.http.X-Referer-Host == \"mi.sky8.it\" ||\n\t\treq.http.X-Referer-Host == \"iteo.staging.wpengine.com\" ||\n\t\treq.http.X-Referer-Host == \"adscend-q.dev\" ||\n\t\treq.http.X-Referer-Host == \"taxes-in-serbia.ews.co.rs\" ||\n\t\treq.http.X-Referer-Host == \"s.codepen.io\" ||\n\t\treq.http.X-Referer-Host == \"seecanadabetter.ca\" ||\n\t\treq.http.X-Referer-Host == \"www.werkbund.com.br\" ||\n\t\treq.http.X-Referer-Host == \"www.art365.co.za\" ||\n\t\treq.http.X-Referer-Host == \"tensionpackaging.com\" ||\n\t\treq.http.X-Referer-Host == \"ec2-54-164-179-111.compute-1.amazonaws.com\" ||\n\t\treq.http.X-Referer-Host == \"sms.loc\" ||\n\t\treq.http.X-Referer-Host == \"timeclock.neonandmore.com\" ||\n\t\treq.http.X-Referer-Host == \"silverblingblack.com\" ||\n\t\treq.http.X-Referer-Host == \"www.modulolanguage.com\" ||\n\t\treq.http.X-Referer-Host == \"visualise.today\" ||\n\t\treq.http.X-Referer-Host == \"pickinglist.constance.com.br\" ||\n\t\treq.http.X-Referer-Host == \"mobileshoppingapps.net\" ||\n\t\treq.http.X-Referer-Host == \"ashleyandbarry.com\" ||\n\t\treq.http.X-Referer-Host == \"www.planetgreen.cl\" ||\n\t\treq.http.X-Referer-Host == \"portal-intranet.ti.sabesp.com.br\" ||\n\t\treq.http.X-Referer-Host == \"gordonrecords.net\" ||\n\t\treq.http.X-Referer-Host == \"cce.pathlore.net\" ||\n\t\treq.http.X-Referer-Host == \"www.myclaimvalue.com\" ||\n\t\treq.http.X-Referer-Host == \"stage.mulesoft.org\" ||\n\t\treq.http.X-Referer-Host == \"javiblog.javigs.es\"\n\t) {\n\t\tset req.http.X-Redir-URL = \"https:\/\/legacy.polyfill.io\" req.url;\n\t\terror 900 req.http.X-Redir-URL;\n\t}\n\n\tif (req.url ~ \"^\/v1\/polyfill\\.\" && req.url !~ \"[\\?\\&]ua=\") {\n\t\tset req.http.X-Orig-URL = req.url;\n\t\tset req.url = \"\/v1\/normalizeUa?ua=\" regsuball(regsuball(regsuball(req.http.User-Agent, {\"%\"}, {\"%25\"}), {\" \"}, {\"%20\"}), {\"&\"}, {\"%26\"});\n\t}\n\n\treturn(lookup);\n}\n\nsub vcl_deliver {\n#FASTLY deliver\n\tif (req.url ~ \"^\/v1\/normalizeUa\" && resp.status == 200) {\n\t\tset req.http.Fastly-force-Shield = \"1\";\n\t\tif (req.http.X-Orig-URL ~ \"\\?\") {\n\t\t\tset req.url = req.http.X-Orig-URL \"&ua=\" resp.http.Normalized-User-Agent;\n\t\t} else {\n\t\t\tset req.url = req.http.X-Orig-URL \"?ua=\" resp.http.Normalized-User-Agent;\n\t\t}\n\t\trestart;\n\t} else if (req.url ~ \"^\/v1\/polyfill\\..*[\\?\\&]ua=\" && req.http.X-Orig-URL && req.http.X-Orig-URL !~ \"[\\?\\&]ua=\") {\n\t\tset resp.http.Vary = \"Accept-Encoding, User-Agent\";\n\t}\n\treturn(deliver);\n}\n\nsub vcl_error {\n\tif (obj.status == 900) {\n\t\tset obj.http.Location = obj.response;\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\tsynthetic {\"The referer header or request URI supplied in your request is known to be an attempt to use the previous version of polyfill.io, so for backwards compatibility we're redirecting you to legacy.polyfill.io which will handle your request using the old version of the service. The legacy version will be discontinued in the future, so please update to the new version, and then let us know by raising an issue in our repo at https:\/\/github.com\/financial-times\/polyfill-service.\"};\n\t\treturn (deliver);\n\t}\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"ca5dc8849a3e67a408c95672cdb1e0c9c91dd6ac","subject":"fix some syntax errors","message":"fix some syntax errors\n","repos":"NITEMAN\/Varnish_VCL_samps-hacks,NITEMAN\/varnish-bites","old_file":"varnish3\/drupal-base.vcl","new_file":"varnish3\/drupal-base.vcl","new_contents":"\/* Varnish 3 example config for Drupal 7 \/ Pressflow 6 & 7 *\/\n# Original source: https:\/\/github.com\/NITEMAN\/varnish-bites\/varnish4\/drupal-base.vcl\n# Copyright (c) 2015 Pedro Gonz\u00e1lez Serrano and individual contributors.\n# MIT License\n\n# Intended to be used both in simple production environments and with learning\/teaching purposes.\n# Loosely based on http:\/\/www.lullabot.com\/sites\/default\/files\/default_varnish3.vcl_.txt\n\n\/* Backend probes \/ healthchecks *\/\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#backend-probes\nprobe basic {\n \/* Only test that backend's IP serves content for '\/' *\/\n # This might be a too heavy probe\n # .url = \"\/\";\n \/* Only test that backend's IP has apache working *\/\n # Nginx would fail this probe with a default config\n .request =\n \"OPTIONS * HTTP\/1.1\"\n \"Host: *\"\n \"Connection: close\";\n .interval = 10s;\n .timeout = 2s;\n .window = 8;\n .threshold = 6;\n}\n\n\n\/* Backend definitions.*\/\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#backend-declarations\nbackend default {\n \/* Default backend on the same machine. WARNING: timeouts could be not big enought for certain POST request *\/\n .host = \"127.0.0.1\";\n .port = \"8008\";\n .connect_timeout = 60s;\n .first_byte_timeout = 60s;\n .between_bytes_timeout = 60s;\n .probe = basic;\n}\n\n\n\/* Directors. *\/\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#directors\n# Empty in simple configs\n\n\n\/* Access Control Lists *\/\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#acls\nacl purge_ban {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use '\"localhost\";' instead\n}\nacl allowed_monitors {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n}\nacl own_proxys {\n \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n}\n\n\n\/* Custom routines *\/\n# Empty in simple configs.\n# We can name subs with no restrictions but as a task can need several chunks of code in diferent states,\n# it's a good idea to identify what main sub will call each with a suffix.\n# \/* Example 301 client redirection removing \"www\" prefix from request *\/\n# sub perm_redirections_recv {\n# if ( req.http.host ~ \"^www.*$\" ) {\n# error 751 \"http:\/\/\" + regsub(req.http.host, \"^www\\.\", \"\") + req.url;\n# }\n# }\n# sub perm_redirections_error {\n# if (obj.status == 751) {\n# \/* Get new URL from the response *\/\n# set obj.http.Location = obj.response;\n# \/* Set HTTP 301 for permanent redirect *\/\n# set obj.status = 301;\n# return(deliver);\n# }\n# }\n\n\n\/* VCL logigc overrides *\/\n# Note that the built-in logic will be appended to our code if no return is performed before.\n# Built-in logic is included commented out right after our's for reference purposes in that cases.\n# See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleDefault\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#subroutines\n\n# vcl_recv: Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use.\nsub vcl_recv {\n \/* 0th: general bypass, general return & authorization checks *\/\n # Empty in simple configs.\n # Useful for debugging we can pipe or pass the request to default backend here to bypass completely Varnish.\n # return (pipe);\n # return (pass);\n # We can also return here a 200 Ok for network performance benchmarking.\n # error 200 \"Ok\";\n # Finally we can perform basic HTTP authentification here by example.\n # See http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* 1st: Check for Varnish special requests *\/ \n # Purge logic.\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/purging.html#http-purges\n # See https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if (req.request == \"PURGE\") {\n if (!client.ip ~ purge_ban) {\n error 405 \"Not allowed.\";\n }\n return (lookup);\n }\n # Ban logic. See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/purging.html#bans\n if (req.request == \"BAN\") {\n if (!client.ip ~ purge_ban) {\n error 405 \"Not allowed.\";\n }\n ban(\"req.http.host == \" + req.http.host +\n \"&& req.url == \" + req.url); \n error 200 \"Ban added\";\n }\n # Custom response implementation example in order to check that Varnish is working properly.\n # This is usefull for automatic monitoring with monit or when Varnish is behind another proxies like HAProxy.\n if ( ( req.http.host == \"monitor.server.health\"\n || req.http.host == \"health.varnish\" )\n && client.ip ~ allowed_monitors\n && ( req.request == \"OPTIONS\" || req.request == \"GET\" )\n ) {\n error 200 \"Ok\";\n }\n\n \/* 2nd: Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_recv;\n # Here we can also enforce SSL when Varnish run behind some SSL termination point.\n\n \/* 3rd: Time for backend choice *\/\n # Empty in simple configs.\n\n \/* 4th: Set custom headers for backend like X-Forwarded-For (copied from built-in logic) *\/\n if ( req.restarts == 0 ) {\n \/* See also vcl_pipe section *\/\n if ( ! client.ip ~ own_proxys ) {\n if ( req.http.x-forwarded-for ) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n }\n\n \/* 5th: Bypass breakpoint 1 *\/\n # Useful for debugging we can now pipe or pass the request to backend with headers setted.\n # return (pipe);\n # return (pass);\n\n \/* 6th: Decide if we should deal with a request (mostly copied from built-in logic) *\/\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n\n \/* 7th: Access control for some URLs by ACL *\/\n # Empty in simple configs.\n # By example denial some URLs depending on client-ip, we'll need to define corresponding ACL 'internal'.\n # if (req.url ~ \"^\/(cron|install)\\.php$\" && !client.ip ~ internal) {\n # # Have Varnish throw the error directly.\n # error 403 \"Forbidden.\";\n # # Use a custom error page that you've defined in Drupal at the path \"404\".\n # # set req.url = \"\/403\";\n # }\n\n \/* 8th: Custom exceptions *\/\n # Host exception example:\n # if (req.http.host == \"ejemplo.exception.com\") {\n # return (pass);\n # }\n # Drupal exceptions, edit if we want to cache some AJAX\/AHAH request.\n # Add here filters for never cache URLs such as Payment Gateway's callbacks\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/ooyala\/ping$\" ||\n req.url ~ \"^\/admin\/build\/features\" ||\n req.url ~ \"^\/info\/.*$\" ||\n req.url ~ \"^\/flag\/.*$\" ||\n req.url ~ \"^.*\/ajax\/.*$\" ||\n req.url ~ \"^.*\/ahah\/.*$\") {\n \/* Do not cache these paths *\/\n return (pass);\n }\n # Pipe these paths directly to backend for streaming.\n if (req.url ~ \"^\/admin\/content\/backup_migrate\/export\") {\n return (pipe);\n }\n if (req.url ~ \"^\/system\/files\") {\n return (pipe);\n }\n\n \/* 9th: Enable grace mode *\/\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/handling_misbehaving_servers.html#grace-mode\n if (! req.backend.healthy) {\n \/* Use a longer grace period if all backends are down *\/\n set req.grace = 1h;\n \/* Use anonymous, cached pages if all backends are down. *\/\n unset req.http.Cookie;\n # TO-DO: Add sick marker\n } else {\n \/* Allow the backend to serve up stale content if it is responding slowly. *\/\n set req.grace = 30s;\n }\n\n \/* 10th: Deal with compression and the Accept-Encoding header *\/\n # Althought Varnish 3 handles gziped content itself by default, just to be sure we want to \n # remove Accept-Encoding for some compressed formats.\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/phk\/gzip.html#what-does-http-gzip-support-do\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/varnishd.html?highlight=http_gzip_support\n # See (for older configs) https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleNormalizeAcceptEncoding\n if (req.http.Accept-Encoding) {\n if ( req.url ~ \"(?i)\\.(7z|avi|bz2|flv|gif|gz|jpe?g|mpe?g|mk[av]|mov|mp[34]|og[gm]|pdf|png|rar|swf|tar|tbz|tgz|woff2?|zip|xz)(\\?.*)?$\"\n ) {\n \/* Already compressed formats, no sense trying to compress again *\/\n remove req.http.Accept-Encoding;\n }\n }\n\n \/* 11th: Another header manipulation *\/\n # Empty in simple configs.\n # We could add here a custom header grouping User-agent families.\n\n \/* 12th: Cookie removal *\/\n # Always cache the following static file types for all users. \n # Use with care if we control certain downloads depending on cookies. \n # Be carefull also if appending .htm[l] via Drupal's clean URLs.\n if ( req.url ~ \"(?i)\\.(bz2|css|eot|gif|gz|html?|ico|jpe?g|js|mp3|ogg|otf|pdf|png|rar|svg|swf|tbz|tgz|ttf|woff2?|zip)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n && req.url !~ \"\/system\/storage\/serve\"\n ) {\n unset req.http.Cookie;\n }\n # Remove all cookies that backend doesn't need to know about.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRemovingSomeCookies\n if (req.http.Cookie) {\n \/* Warning: Not a pretty solution *\/\n \/* Prefix header containing cookies with ';' *\/\n set req.http.Cookie = \";\" + req.http.Cookie;\n \/* Remove any spaces after ';' in header containing cookies *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n \/* Prefix cookies we want to preserve with one space *\/\n \/* 'S{1,2}ESS[a-z0-9]+' is the regular expression matching a Drupal session cookie ({1,2} added for HTTPS support) *\/\n \/* 'NO_CACHE' is usually set after a POST request to make sure issuing user see the results of his post *\/\n \/* 'OATMEAL' & 'CHOCOLATECHIP' are special cookies used by Drupal's Bakery module to provide Single Sign On *\/\n \/* Keep in mind we should add here any cookie that should reach the backend such as splahs avoiding cookies *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \";(S{1,2}ESS[a-z0-9]+|NO_CACHE|OATMEAL|CHOCOLATECHIP)=\", \"; \\1=\");\n \/* Remove from the header any single Cookie not prefixed with a space until next ';' separator *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n \/* Remove any '; ' at the start or the end of the header *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n\n if (req.http.Cookie == \"\") {\n \/* If there are no remaining cookies, remove the cookie header. *\/\n unset req.http.Cookie;\n }\n }\n\n \/* 13th: Session cookie & special cookies bypass caching stage *\/\n # As we might want to cache some requests, hashed with its cookies, \n # we don't simply pass when some cookies remain present at this point.\n # Instead we look for request that must be passed due to the cookie header.\n if (req.http.Cookie ~ \"SESS\" ||\n req.http.Cookie ~ \"SSESS\" ||\n req.http.Cookie ~ \"NO_CACHE\" ||\n req.http.Cookie ~ \"OATMEAL\" ||\n req.http.Cookie ~ \"CHOCOLATECHIP\") {\n return (pass);\n }\n\n \/* 14th: Bypass breakpoint 2 *\/\n # Useful for debugging we can now pipe or pass the request to backend to bypass cache.\n # return (pipe);\n # return (pass);\n\n \/* 15th: Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning a lookup.\n return (lookup);\n}\n\n# vcl_pipe: Called upon entering pipe mode.\n# In this mode, the request is passed on to the backend, \n# and any further data from either client or backend is passed on unaltered until either end closes the connection.\nsub vcl_pipe {\n \/* Prevent connection re-using for piped requests *\/\n # Note that only the first request to the backend will have X-Forwarded-For set.\n # As we use X-Forwarded-For and want to have it set for all requests, \n # we have to make sure connection won't be reused after the request.\n # It is not set by default as it might break some broken web applications, like IIS with NTLM authentication.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExamplePipe\n # TO-DO: make sure this is compatible with websockets piping,\n # reference https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/websockets.html\n set bereq.http.connection = \"close\";\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this point.\n return (pipe);\n}\n\n# vcl_pass: Called upon entering pass mode. \n# In this mode, the request is passed on to the backend, and the backend's response is passed on to the client, \n# but is not entered into the cache.\n# Subsequent requests submitted over the same client connection are handled normally.\n# sub vcl_pass {\n# return (pass);\n# }\n\n# vcl_hash: You may call hash_data() on the data you would like to add to the hash.\n# Hash is used by Varnish to uniquely identify objects.\nsub vcl_hash {\n \/* Hash cookie data *\/\n # As requests with same URL and host can produce diferent results when issued with different cookies,\n # we need to store items hashed with the associated cookies. Note that cookies are already sanitized when we reach this point.\n if (req.http.Cookie) {\n \/* Include cookie in cache hash *\/\n hash_data(req.http.Cookie);\n }\n\n \/* Custom header hashing *\/\n # Empty in simple configs.\n # Example for caching differents object versions by device previously detected (when static content could also vary):\n # if (req.http.X-UA-Device) {\n # hash_data(req.http.X-UA-Device);\n # }\n # Example for caching diferent object versions by X-Forwarded-Proto, trying to be smart about what kind of request\n # could generate diffetent responses.\n if ( req.http.X-Forwarded-Proto\n && req.url !~ \"(?i)\\.(bz2|css|eot|gif|gz|html?|ico|jpe?g|js|mp3|ogg|otf|pdf|png|rar|svg|swf|tbz|tgz|ttf|woff2?|zip)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n ) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (hash);\n# }\n\n# vcl_hit: Called after a cache lookup if the requested document was found in the cache.\nsub vcl_hit {\n \/* Check for Varnish special requests *\/ \n # Purge logic.\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/purging.html#http-purges\n # See https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged.\";\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hit {\n# return (deliver);\n# }\n\n# vcl_miss: Called after a cache lookup if the requested document was not found in the cache.\n# Its purpose is to decide whether or not to attempt to retrieve the document from the backend, and which backend to use.\nsub vcl_miss {\n \/* Check for Varnish special requests *\/ \n # Purge logic.\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/purging.html#http-purges\n # See https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged.\";\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_miss {\n# return (fetch);\n# }\n\n# vcl_fetch: Called after a document has been successfully retrieved from the backend.\nsub vcl_fetch {\n \/* Caching exceptions *\/\n # Varnish will cache objects with response codes: 200, 203, 300, 301, 302, 307, 404 & 410.\n # See https:\/\/www.varnish-software.com\/static\/book\/VCL_Basics.html#the-initial-value-of-beresp-ttl\n # Drupal's Imagecache module can return a 307 redirection to the requested url itself and, depending on Drupal's cache settings,\n # this could lead to a redirection loop being cached for a long time but also we want Varnish to shield a little the backend.\n # See http:\/\/drupal.org\/node\/1248010\n # See http:\/\/drupal.org\/node\/310656\n if (beresp.status == 307 &&\n \/* TO-DO: verify that this work better than 'req.url ~ \"imagecache\"' *\/\n beresp.http.Location == req.url &&\n beresp.ttl > 5s) {\n set beresp.ttl = 5s;\n set beresp.http.cache-control = \"max-age=5\";\n }\n\n \/* Enable grace mode. Related with our 9th stage on vcl_recv *\/\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/handling_misbehaving_servers.html#grace-mode\n set beresp.grace = 1h;\n\n \/* Enable saint mode. Related with our 9th stage on vcl_recv *\/\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/handling_misbehaving_servers.html#saint-mode\n if (beresp.status == 500) {\n set beresp.saintmode = 20s;\n # TO-DO: consider not restarting POST requests as seen on https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleSaintMode\n return(restart);\n }\n\n \/* Strip cookies from the following static file types for all users. Related with our 12th stage on vcl_recv *\/\n if ( req.url ~ \"(?i)\\.(bz2|css|eot|gif|gz|html?|ico|jpe?g|js|mp3|ogg|otf|pdf|png|rar|svg|swf|tbz|tgz|ttf|woff2?|zip)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n ) {\n unset beresp.http.set-cookie;\n }\n\n \/* Gzip response *\/\n # Empty in simple configs\n # Use Varnish to Gzip respone, if suitable, before storing it on cache\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/phk\/gzip.html\n if (! beresp.http.Content-Encoding &&\n (beresp.http.content-type ~ \"text\" ||\n beresp.http.content-type ~ \"application\/x-javascript\" ||\n beresp.http.content-type ~ \"application\/javascript\" ||\n beresp.http.content-type ~ \"application\/rss+xml\" ||\n beresp.http.content-type ~ \"application\/xml\" ||\n beresp.http.content-type ~ \"Application\/JSON\")\n ) {\n set beresp.do_gzip = true;\n if ( beresp.http.Vary ) {\n if ( ! beresp.http.Vary ~ \"Accept-Encoding\" ) {\n set beresp.http.Vary = beresp.http.Vary + \",Accept-Encoding\";\n }\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # We can add the name of the backend that has processed the request:\n # set beresp.http.X-Backend = beresp.backend.name;\n # We can use a header to tell if the object was gziped by Varnish\n # if (beresp.do_gzip) {\n # set beresp.http.X-Varnish-Gzipped = \"yes\";\n # } else {\n # set beresp.http.X-Varnish-Gizipped = \"no\";\n # }\n # We can also add headers informing whether the object is cacheable or not and why.\n # https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Varnish3.0\n if (beresp.ttl <= 0s) {\n \/* Varnish determined the object was not cacheable *\/\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n } elsif (req.http.Cookie ~ \"(SESS|SSESS|NO_CACHE|OATMEAL|CHOCOLATECHIP)\") {\n \/* We don't wish to cache content for logged in users or with certain cookies. Related with our 9th stage on vcl_recv *\/\n set beresp.http.X-Cacheable = \"NO:Cookies\";\n # return(hit_for_pass);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n \/* We are respecting the Cache-Control=private header from the backend *\/\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n # return(hit_for_pass);\n } else {\n \/* Varnish determined the object was cacheable *\/\n set beresp.http.X-Cacheable = \"YES\";\n }\n\n \/* Further header manipulation *\/\n # Empty in simple configs.\n # We can also unset some headers to prevent information disclosure and save some cache space\n # unset beresp.http.Server;\n # unset beresp.http.X-Powered-By;\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_fetch {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Vary == \"*\") {\n# \/*\n# * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# *\/\n# set beresp.ttl = 120 s;\n# return (hit_for_pass);\n# }\n# return (deliver);\n# }\n\n# vcl_deliver: Called before an object is delivered to the client\nsub vcl_deliver {\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # Add whether the object is a cache hit or miss and the number of hits for the object.\n # https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Addingaheaderindicatinghitmiss\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n set resp.http.X-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Cache = \"MISS\";\n \/* Show the results of cookie sanitization *\/\n set resp.http.X-Cookie = req.http.Cookie;\n }\n # TO-DO: Add sick marker\n # Restart count\n if ( req.restarts > 0) {\n set resp.http.X-Restarts = req.restarts;\n }\n # Add the Varnish server hostname\n set resp.http.X-Varnish-Server = server.hostname;\n # If we have setted a custom header with device family detected we can show it:\n # if (req.http.X-UA-Device) {\n # set resp.http.X-UA-Device = req.http.X-UA-Device;\n # }\n # If we have recived a custom header with the protocol in the request we can show it:\n # if (req.http.X-Forwarded-Proto) {\n # set resp.http.X-Forwarded-Proto = req.http.X-Forwarded-Proto;\n # }\n\n \/* Vary header manipulation *\/\n # Empty in simple configs.\n # By example, if we are storing & serving diferent objects depending on User-Agent header we must set the correct Vary header:\n # if (resp.http.Vary) {\n # set resp.http.Vary = resp.http.Vary + \",User-Agent\";\n # } else {\n # set resp.http.Vary = \"User-Agent\";\n # }\n\n \/* Fake headers *\/\n # Empty in simple configs\n # We can fake server headers here, by example:\n # set resp.http.Server = \"Deep thought\";\n # set resp.http.X-Powered-By = \"BOFH\";\n # Or have some fun with headers:\n # See http:\/\/www.nextthing.org\/archives\/2005\/08\/07\/fun-with-http-headers\n # See http:\/\/royal.pingdom.com\/2012\/08\/15\/fun-and-unusual-http-response-headers\/\n # set resp.http.X-Thank-You = \"for bothering to look at my HTTP headers\";\n # set resp.http.X-Answer = \"42\";\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_deliver {\n# return (deliver);\n# }\n\n# vcl_error: Called when we hit an error, either explicitly or implicitly due to backend or internal errors.\nsub vcl_error {\n \/* Avoid DOS vulnerability CVE-2013-4484 *\/\n # See https:\/\/www.varnish-cache.org\/lists\/pipermail\/varnish-announce\/2013-October\/000686.html\n if (obj.status == 400 || obj.status == 413) {\n return(deliver);\n }\n\n \/* Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_error;\n\n \/* Try to restart request in case of failure *\/\n # Note that max_restarts defaults to 4\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if (obj.status == 503 && req.restarts < 4) {\n set obj.http.X-Restarts = req.restarts;\n return(restart);\n }\n\n \/* Set common headers for synthetic responses *\/\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n\n \/* HTTP Authentification client request *\/\n # Empty in simple configs. See http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* We're using error 200 for monitoring puposes *\/\n # Consider adding some analytics stuff to trace accesses\n if (obj.status == 200) {\n synthetic {\"\n <?xml version=\"1.0\" encoding=\"utf-8\"?>\n <!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n <html>\n <head>\n <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n <\/head>\n <body><h1>\"} + obj.status + \": \" + obj.response + {\"<\/h1><\/body>\n \"};\n return(deliver);\n }\n\n \/* Error page & refresh \/ redirections *\/\n # We have plenty of choices when we have to serve an error to the client, \n # from the default error page to javascript black magic or plain redirections.\n # Adding some external statistic javascript to track failures served to clients is strongly suggested.\n # We can't use external resources on synthetic content, everything must be inlined.\n # If we need to include images we can embed them in base64 encoding.\n # Here is the default error page for Varnish 3 (not so pretty)\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + obj.status + \" \" + obj.response + {\"<\/h1>\n <p>\"} + obj.response + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"};\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this point.\n return (deliver);\n}\n\n# vcl_init: Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n# sub vcl_init {\n# return (ok);\n# }\n\n# vcl_fini: Called when VCL is discarded only after all requests have exited the VCL. Typically used to clean up VMODs.\n# sub vcl_fini {\n# return (ok);\n# }\n","old_contents":"\/* Varnish 3 example config for Drupal 7 \/ Pressflow 6 & 7 *\/\n# Original source: https:\/\/github.com\/NITEMAN\/varnish-bites\/varnish4\/drupal-base.vcl\n# Copyright (c) 2015 Pedro Gonz\u00e1lez Serrano and individual contributors.\n# MIT License\n\n# Intended to be used both in simple production environments and with learning\/teaching purposes.\n# Loosely based on http:\/\/www.lullabot.com\/sites\/default\/files\/default_varnish3.vcl_.txt\n\n\/* Backend probes \/ healthchecks *\/\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#backend-probes\nprobe basic {\n \/* Only test that backend's IP serves content for '\/' *\/\n # This might be a too heavy probe\n # .url = \"\/\";\n \/* Only test that backend's IP has apache working *\/\n # Nginx would fail this probe with a default config\n .request =\n \"OPTIONS * HTTP\/1.1\"\n \"Host: *\"\n \"Connection: close\";\n .interval = 10s;\n .timeout = 2s;\n .window = 8;\n .threshold = 6;\n}\n\n\n\/* Backend definitions.*\/\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#backend-declarations\nbackend default {\n \/* Default backend on the same machine. WARNING: timeouts could be not big enought for certain POST request *\/\n .host = \"127.0.0.1\";\n .port = \"8008\";\n .connect_timeout = 60s;\n .first_byte_timeout = 60s;\n .between_bytes_timeout = 60s;\n .probe = basic;\n}\n\n\n\/* Directors. *\/\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#directors\n# Empty in simple configs\n\n\n\/* Access Control Lists *\/\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#acls\nacl purge_ban {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use '\"localhost\";' instead\n}\nacl allowed_monitors {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n}\nacl own_proxys {\n \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n}\n\n\n\/* Custom routines *\/\n# Empty in simple configs.\n# We can name subs with no restrictions but as a task can need several chunks of code in diferent states,\n# it's a good idea to identify what main sub will call each with a suffix.\n# \/* Example 301 client redirection removing \"www\" prefix from request *\/\n# sub perm_redirections_recv {\n# if ( req.http.host ~ \"^www.*$\" ) {\n# error 751 \"http:\/\/\" + regsub(req.http.host, \"^www\\.\", \"\") + req.url;\n# }\n# }\n# sub perm_redirections_error {\n# if (obj.status == 751) {\n# \/* Get new URL from the response *\/\n# set obj.http.Location = obj.response;\n# \/* Set HTTP 301 for permanent redirect *\/\n# set obj.status = 301;\n# return(deliver);\n# }\n# }\n\n\n\/* VCL logigc overrides *\/\n# Note that the built-in logic will be appended to our code if no return is performed before.\n# Built-in logic is included commented out right after our's for reference purposes in that cases.\n# See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleDefault\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#subroutines\n\n# vcl_recv: Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use.\nsub vcl_recv {\n \/* 0th: general bypass, general return & authorization checks *\/\n # Empty in simple configs.\n # Useful for debugging we can pipe or pass the request to default backend here to bypass completely Varnish.\n # return (pipe);\n # return (pass);\n # We can also return here a 200 Ok for network performance benchmarking.\n # error 200 \"Ok\";\n # Finally we can perform basic HTTP authentification here by example.\n # See http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* 1st: Check for Varnish special requests *\/ \n # Purge logic.\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/purging.html#http-purges\n # See https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if (req.request == \"PURGE\") {\n if (!client.ip ~ purge_ban) {\n error 405 \"Not allowed.\";\n }\n return (lookup);\n }\n # Ban logic. See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/purging.html#bans\n if (req.request == \"BAN\") {\n if (!client.ip ~ purge_ban) {\n error 405 \"Not allowed.\";\n }\n ban(\"req.http.host == \" + req.http.host +\n \"&& req.url == \" + req.url); \n error 200 \"Ban added\";\n }\n # Custom response implementation example in order to check that Varnish is working properly.\n # This is usefull for automatic monitoring with monit or when Varnish is behind another proxies like HAProxy.\n if ( ( req.http.host == \"monitor.server.health\"\n || req.http.host == \"health.varnish\" )\n && client.ip ~ allowed_monitors\n && ( req.request == \"OPTIONS\" || req.request == \"GET\" )\n ) {\n error 200 \"Ok\";\n }\n\n \/* 2nd: Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_recv;\n # Here we can also enforce SSL when Varnish run behind some SSL termination point.\n\n \/* 3rd: Time for backend choice *\/\n # Empty in simple configs.\n\n \/* 4th: Set custom headers for backend like X-Forwarded-For (copied from built-in logic) *\/\n if ( req.restarts == 0 ) {\n \/* See also vcl_pipe section *\/\n if ( ! client.ip ~ own_proxys ) {\n if ( req.http.x-forwarded-for ) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n }\n\n \/* 5th: Bypass breakpoint 1 *\/\n # Useful for debugging we can now pipe or pass the request to backend with headers setted.\n # return (pipe);\n # return (pass);\n\n \/* 6th: Decide if we should deal with a request (mostly copied from built-in logic) *\/\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n\n \/* 7th: Access control for some URLs by ACL *\/\n # Empty in simple configs.\n # By example denial some URLs depending on client-ip, we'll need to define corresponding ACL 'internal'.\n # if (req.url ~ \"^\/(cron|install)\\.php$\" && !client.ip ~ internal) {\n # # Have Varnish throw the error directly.\n # error 403 \"Forbidden.\";\n # # Use a custom error page that you've defined in Drupal at the path \"404\".\n # # set req.url = \"\/403\";\n # }\n\n \/* 8th: Custom exceptions *\/\n # Host exception example:\n # if (req.http.host == \"ejemplo.exception.com\") {\n # return (pass);\n # }\n # Drupal exceptions, edit if we want to cache some AJAX\/AHAH request.\n # Add here filters for never cache URLs such as Payment Gateway's callbacks\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/ooyala\/ping$\" ||\n req.url ~ \"^\/admin\/build\/features\" ||\n req.url ~ \"^\/info\/.*$\" ||\n req.url ~ \"^\/flag\/.*$\" ||\n req.url ~ \"^.*\/ajax\/.*$\" ||\n req.url ~ \"^.*\/ahah\/.*$\") {\n \/* Do not cache these paths *\/\n return (pass);\n }\n # Pipe these paths directly to backend for streaming.\n if (req.url ~ \"^\/admin\/content\/backup_migrate\/export\") {\n return (pipe);\n }\n if (req.url ~ \"^\/system\/files\") {\n return (pipe);\n }\n\n \/* 9th: Enable grace mode *\/\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/handling_misbehaving_servers.html#grace-mode\n if (! req.backend.healthy) {\n \/* Use a longer grace period if all backends are down *\/\n set req.grace = 1h;\n \/* Use anonymous, cached pages if all backends are down. *\/\n unset req.http.Cookie;\n # TO-DO: Add sick marker\n } else {\n \/* Allow the backend to serve up stale content if it is responding slowly. *\/\n set req.grace = 30s;\n }\n\n \/* 10th: Deal with compression and the Accept-Encoding header *\/\n # Althought Varnish 3 handles gziped content itself by default, just to be sure we want to \n # remove Accept-Encoding for some compressed formats.\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/phk\/gzip.html#what-does-http-gzip-support-do\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/varnishd.html?highlight=http_gzip_support\n # See (for older configs) https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleNormalizeAcceptEncoding\n if (req.http.Accept-Encoding) {\n if ( req.url ~ \"(?i)\\.(7z|avi|bz2|flv|gif|gz|jpe?g|mpe?g|mk[av]|mov|mp[34]|og[gm]|pdf|png|rar|swf|tar|tbz|tgz|woff2?|zip|xz)(\\?.*)?$\"\n \/* Already compressed formats, no sense trying to compress again *\/\n remove req.http.Accept-Encoding;\n }\n }\n\n \/* 11th: Another header manipulation *\/\n # Empty in simple configs.\n # We could add here a custom header grouping User-agent families.\n\n \/* 12th: Cookie removal *\/\n # Always cache the following static file types for all users. \n # Use with care if we control certain downloads depending on cookies. \n # Be carefull also if appending .htm[l] via Drupal's clean URLs.\n if ( req.url ~ \"(?i)\\.(bz2|css|eot|gif|gz|html?|ico|jpe?g|js|mp3|ogg|otf|pdf|png|rar|svg|swf|tbz|tgz|ttf|woff2?|zip)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n && req.url !~ \"\/system\/storage\/serve\"\n ) {\n unset req.http.Cookie;\n }\n # Remove all cookies that backend doesn't need to know about.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRemovingSomeCookies\n if (req.http.Cookie) {\n \/* Warning: Not a pretty solution *\/\n \/* Prefix header containing cookies with ';' *\/\n set req.http.Cookie = \";\" + req.http.Cookie;\n \/* Remove any spaces after ';' in header containing cookies *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n \/* Prefix cookies we want to preserve with one space *\/\n \/* 'S{1,2}ESS[a-z0-9]+' is the regular expression matching a Drupal session cookie ({1,2} added for HTTPS support) *\/\n \/* 'NO_CACHE' is usually set after a POST request to make sure issuing user see the results of his post *\/\n \/* 'OATMEAL' & 'CHOCOLATECHIP' are special cookies used by Drupal's Bakery module to provide Single Sign On *\/\n \/* Keep in mind we should add here any cookie that should reach the backend such as splahs avoiding cookies *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \";(S{1,2}ESS[a-z0-9]+|NO_CACHE|OATMEAL|CHOCOLATECHIP)=\", \"; \\1=\");\n \/* Remove from the header any single Cookie not prefixed with a space until next ';' separator *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n \/* Remove any '; ' at the start or the end of the header *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n\n if (req.http.Cookie == \"\") {\n \/* If there are no remaining cookies, remove the cookie header. *\/\n unset req.http.Cookie;\n }\n }\n\n \/* 13th: Session cookie & special cookies bypass caching stage *\/\n # As we might want to cache some requests, hashed with its cookies, \n # we don't simply pass when some cookies remain present at this point.\n # Instead we look for request that must be passed due to the cookie header.\n if (req.http.Cookie ~ \"SESS\" ||\n req.http.Cookie ~ \"SSESS\" ||\n req.http.Cookie ~ \"NO_CACHE\" ||\n req.http.Cookie ~ \"OATMEAL\" ||\n req.http.Cookie ~ \"CHOCOLATECHIP\") {\n return (pass);\n }\n\n \/* 14th: Bypass breakpoint 2 *\/\n # Useful for debugging we can now pipe or pass the request to backend to bypass cache.\n # return (pipe);\n # return (pass);\n\n \/* 15th: Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning a lookup.\n return (lookup);\n}\n\n# vcl_pipe: Called upon entering pipe mode.\n# In this mode, the request is passed on to the backend, \n# and any further data from either client or backend is passed on unaltered until either end closes the connection.\nsub vcl_pipe {\n \/* Prevent connection re-using for piped requests *\/\n # Note that only the first request to the backend will have X-Forwarded-For set.\n # As we use X-Forwarded-For and want to have it set for all requests, \n # we have to make sure connection won't be reused after the request.\n # It is not set by default as it might break some broken web applications, like IIS with NTLM authentication.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExamplePipe\n # TO-DO: make sure this is compatible with websockets piping,\n # reference https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/websockets.html\n set bereq.http.connection = \"close\";\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this point.\n return (pipe);\n}\n\n# vcl_pass: Called upon entering pass mode. \n# In this mode, the request is passed on to the backend, and the backend's response is passed on to the client, \n# but is not entered into the cache.\n# Subsequent requests submitted over the same client connection are handled normally.\n# sub vcl_pass {\n# return (pass);\n# }\n\n# vcl_hash: You may call hash_data() on the data you would like to add to the hash.\n# Hash is used by Varnish to uniquely identify objects.\nsub vcl_hash {\n \/* Hash cookie data *\/\n # As requests with same URL and host can produce diferent results when issued with different cookies,\n # we need to store items hashed with the associated cookies. Note that cookies are already sanitized when we reach this point.\n if (req.http.Cookie) {\n \/* Include cookie in cache hash *\/\n hash_data(req.http.Cookie);\n }\n\n \/* Custom header hashing *\/\n # Empty in simple configs.\n # Example for caching differents object versions by device previously detected (when static content could also vary):\n # if (req.http.X-UA-Device) {\n # hash_data(req.http.X-UA-Device);\n # }\n # Example for caching diferent object versions by X-Forwarded-Proto, trying to be smart about what kind of request\n # could generate diffetent responses.\n if ( req.http.X-Forwarded-Proto\n && req.url !~ \"(?i)\\.(bz2|css|eot|gif|gz|html?|ico|jpe?g|js|mp3|ogg|otf|pdf|png|rar|svg|swf|tbz|tgz|ttf|woff2?|zip)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n hash_data(req.http.X-Forwarded-Proto);\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (hash);\n# }\n\n# vcl_hit: Called after a cache lookup if the requested document was found in the cache.\nsub vcl_hit {\n \/* Check for Varnish special requests *\/ \n # Purge logic.\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/purging.html#http-purges\n # See https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged.\";\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hit {\n# return (deliver);\n# }\n\n# vcl_miss: Called after a cache lookup if the requested document was not found in the cache.\n# Its purpose is to decide whether or not to attempt to retrieve the document from the backend, and which backend to use.\nsub vcl_miss {\n \/* Check for Varnish special requests *\/ \n # Purge logic.\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/purging.html#http-purges\n # See https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged.\";\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_miss {\n# return (fetch);\n# }\n\n# vcl_fetch: Called after a document has been successfully retrieved from the backend.\nsub vcl_fetch {\n \/* Caching exceptions *\/\n # Varnish will cache objects with response codes: 200, 203, 300, 301, 302, 307, 404 & 410.\n # See https:\/\/www.varnish-software.com\/static\/book\/VCL_Basics.html#the-initial-value-of-beresp-ttl\n # Drupal's Imagecache module can return a 307 redirection to the requested url itself and, depending on Drupal's cache settings,\n # this could lead to a redirection loop being cached for a long time but also we want Varnish to shield a little the backend.\n # See http:\/\/drupal.org\/node\/1248010\n # See http:\/\/drupal.org\/node\/310656\n if (beresp.status == 307 &&\n \/* TO-DO: verify that this work better than 'req.url ~ \"imagecache\"' *\/\n beresp.http.Location == req.url &&\n beresp.ttl > 5s) {\n set beresp.ttl = 5s;\n set beresp.http.cache-control = \"max-age=5\";\n }\n\n \/* Enable grace mode. Related with our 9th stage on vcl_recv *\/\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/handling_misbehaving_servers.html#grace-mode\n set beresp.grace = 1h;\n\n \/* Enable saint mode. Related with our 9th stage on vcl_recv *\/\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/handling_misbehaving_servers.html#saint-mode\n if (beresp.status == 500) {\n set beresp.saintmode = 20s;\n # TO-DO: consider not restarting POST requests as seen on https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleSaintMode\n return(restart);\n }\n\n \/* Strip cookies from the following static file types for all users. Related with our 12th stage on vcl_recv *\/\n if ( req.url ~ \"(?i)\\.(bz2|css|eot|gif|gz|html?|ico|jpe?g|js|mp3|ogg|otf|pdf|png|rar|svg|swf|tbz|tgz|ttf|woff2?|zip)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n unset beresp.http.set-cookie;\n }\n\n \/* Gzip response *\/\n # Empty in simple configs\n # Use Varnish to Gzip respone, if suitable, before storing it on cache\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/phk\/gzip.html\n if (! beresp.http.Content-Encoding &&\n (beresp.http.content-type ~ \"text\" ||\n beresp.http.content-type ~ \"application\/x-javascript\" ||\n beresp.http.content-type ~ \"application\/javascript\" ||\n beresp.http.content-type ~ \"application\/rss+xml\" ||\n beresp.http.content-type ~ \"application\/xml\" ||\n beresp.http.content-type ~ \"Application\/JSON\")\n ) {\n set beresp.do_gzip = true;\n if ( beresp.http.Vary ) {\n if ( ! beresp.http.Vary ~ \"Accept-Encoding\" ) {\n set beresp.http.Vary = beresp.http.Vary + \",Accept-Encoding\";\n }\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # We can add the name of the backend that has processed the request:\n # set beresp.http.X-Backend = beresp.backend.name;\n # We can use a header to tell if the object was gziped by Varnish\n # if (beresp.do_gzip) {\n # set beresp.http.X-Varnish-Gzipped = \"yes\";\n # } else {\n # set beresp.http.X-Varnish-Gizipped = \"no\";\n # }\n # We can also add headers informing whether the object is cacheable or not and why.\n # https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Varnish3.0\n if (beresp.ttl <= 0s) {\n \/* Varnish determined the object was not cacheable *\/\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n } elsif (req.http.Cookie ~ \"(SESS|SSESS|NO_CACHE|OATMEAL|CHOCOLATECHIP)\") {\n \/* We don't wish to cache content for logged in users or with certain cookies. Related with our 9th stage on vcl_recv *\/\n set beresp.http.X-Cacheable = \"NO:Cookies\";\n # return(hit_for_pass);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n \/* We are respecting the Cache-Control=private header from the backend *\/\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n # return(hit_for_pass);\n } else {\n \/* Varnish determined the object was cacheable *\/\n set beresp.http.X-Cacheable = \"YES\";\n }\n\n \/* Further header manipulation *\/\n # Empty in simple configs.\n # We can also unset some headers to prevent information disclosure and save some cache space\n # unset beresp.http.Server;\n # unset beresp.http.X-Powered-By;\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_fetch {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Vary == \"*\") {\n# \/*\n# * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# *\/\n# set beresp.ttl = 120 s;\n# return (hit_for_pass);\n# }\n# return (deliver);\n# }\n\n# vcl_deliver: Called before an object is delivered to the client\nsub vcl_deliver {\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # Add whether the object is a cache hit or miss and the number of hits for the object.\n # https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Addingaheaderindicatinghitmiss\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n set resp.http.X-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Cache = \"MISS\";\n \/* Show the results of cookie sanitization *\/\n set resp.http.X-Cookie = req.http.Cookie;\n }\n # TO-DO: Add sick marker\n # Restart count\n if ( req.restarts > 0) {\n set resp.http.X-Restarts = req.restarts;\n }\n # Add the Varnish server hostname\n set resp.http.X-Varnish-Server = server.hostname;\n # If we have setted a custom header with device family detected we can show it:\n # if (req.http.X-UA-Device) {\n # set resp.http.X-UA-Device = req.http.X-UA-Device;\n # }\n # If we have recived a custom header with the protocol in the request we can show it:\n # if (req.http.X-Forwarded-Proto) {\n # set resp.http.X-Forwarded-Proto = req.http.X-Forwarded-Proto;\n # }\n\n \/* Vary header manipulation *\/\n # Empty in simple configs.\n # By example, if we are storing & serving diferent objects depending on User-Agent header we must set the correct Vary header:\n # if (resp.http.Vary) {\n # set resp.http.Vary = resp.http.Vary + \",User-Agent\";\n # } else {\n # set resp.http.Vary = \"User-Agent\";\n # }\n\n \/* Fake headers *\/\n # Empty in simple configs\n # We can fake server headers here, by example:\n # set resp.http.Server = \"Deep thought\";\n # set resp.http.X-Powered-By = \"BOFH\";\n # Or have some fun with headers:\n # See http:\/\/www.nextthing.org\/archives\/2005\/08\/07\/fun-with-http-headers\n # See http:\/\/royal.pingdom.com\/2012\/08\/15\/fun-and-unusual-http-response-headers\/\n # set resp.http.X-Thank-You = \"for bothering to look at my HTTP headers\";\n # set resp.http.X-Answer = \"42\";\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_deliver {\n# return (deliver);\n# }\n\n# vcl_error: Called when we hit an error, either explicitly or implicitly due to backend or internal errors.\nsub vcl_error {\n \/* Avoid DOS vulnerability CVE-2013-4484 *\/\n # See https:\/\/www.varnish-cache.org\/lists\/pipermail\/varnish-announce\/2013-October\/000686.html\n if (obj.status == 400 || obj.status == 413) {\n return(deliver);\n }\n\n \/* Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_error;\n\n \/* Try to restart request in case of failure *\/\n # Note that max_restarts defaults to 4\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if (obj.status == 503 && req.restarts < 4) {\n set obj.http.X-Restarts = req.restarts;\n return(restart);\n }\n\n \/* Set common headers for synthetic responses *\/\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n\n \/* HTTP Authentification client request *\/\n # Empty in simple configs. See http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* We're using error 200 for monitoring puposes *\/\n # Consider adding some analytics stuff to trace accesses\n if (obj.status == 200) {\n synthetic {\"\n <?xml version=\"1.0\" encoding=\"utf-8\"?>\n <!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n <html>\n <head>\n <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n <\/head>\n <body><h1>\"} + obj.status + \": \" + obj.response + {\"<\/h1><\/body>\n \"};\n return(deliver);\n }\n\n \/* Error page & refresh \/ redirections *\/\n # We have plenty of choices when we have to serve an error to the client, \n # from the default error page to javascript black magic or plain redirections.\n # Adding some external statistic javascript to track failures served to clients is strongly suggested.\n # We can't use external resources on synthetic content, everything must be inlined.\n # If we need to include images we can embed them in base64 encoding.\n # Here is the default error page for Varnish 3 (not so pretty)\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + obj.status + \" \" + obj.response + {\"<\/h1>\n <p>\"} + obj.response + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"};\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this point.\n return (deliver);\n}\n\n# vcl_init: Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n# sub vcl_init {\n# return (ok);\n# }\n\n# vcl_fini: Called when VCL is discarded only after all requests have exited the VCL. Typically used to clean up VMODs.\n# sub vcl_fini {\n# return (ok);\n# }\n","returncode":0,"stderr":"","license":"unknown","lang":"VCL"} {"commit":"dc110ab0cac39262e3774b01427ce3925125e554","subject":"Redirect to https if the host is just polyfill.io (#730)","message":"Redirect to https if the host is just polyfill.io (#730)","repos":"mcshaz\/polyfill-service,kdzwinel\/polyfill-service,mcshaz\/polyfill-service,jonathan-fielding\/polyfill-service,jonathan-fielding\/polyfill-service,JakeChampion\/polyfill-service,JakeChampion\/polyfill-service,kdzwinel\/polyfill-service,jonathan-fielding\/polyfill-service,mcshaz\/polyfill-service,kdzwinel\/polyfill-service","old_file":"fastly-config.vcl","new_file":"fastly-config.vcl","new_contents":"sub vcl_recv {\n#FASTLY recv\n\tif ( req.request == \"FASTLYPURGE\" ) {\n\t\tset req.http.Fastly-Purge-Requires-Auth = \"1\";\n\t}\n\n\tif (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n\t\treturn(pass);\n\t}\n\n\tif (!req.http.Fastly-SSL && (req.http.Host == \"cdn.polyfill.io\" || req.http.Host == \"polyfill.io\")) {\n\t\terror 751 \"Force TLS\";\n\t}\n\n\tif (req.url ~ \"^\/v2\/polyfill\\.\" && req.url !~ \"[\\?\\&]ua=\") {\n\t\tset req.http.X-Orig-URL = req.url;\n\t\tset req.url = \"\/v2\/normalizeUa?ua=\" urlencode(req.http.User-Agent);\n\t}\n\n\treturn(lookup);\n}\n\nsub vcl_deliver {\n#FASTLY deliver\n\n\t# If the response is to a normalise request and there's a parked \"original request\", use the normalised UA response to modify the original request and restart it\n\tif (req.url ~ \"^\/v\\d\/normalizeUa\" && resp.status == 200 && req.http.X-Orig-URL) {\n\t\tset req.http.Fastly-force-Shield = \"1\";\n\t\tif (req.http.X-Orig-URL ~ \"\\?\") {\n\t\t\tset req.url = req.http.X-Orig-URL \"&ua=\" resp.http.Normalized-User-Agent;\n\t\t} else {\n\t\t\tset req.url = req.http.X-Orig-URL \"?ua=\" resp.http.Normalized-User-Agent;\n\t\t}\n\t\trestart;\n\n\t# If the original request didn't specify a UA override, and we added one when the request was sent to the backend, the backend won't have included a Vary:user-agent header (correctly) but we need to add one\n\t} else if (req.url ~ \"^\/v\\d\/polyfill\\..*[\\?\\&]ua=\" && req.http.X-Orig-URL && req.http.X-Orig-URL !~ \"[\\?\\&]ua=\") {\n\t\tadd resp.http.Vary = \"User-Agent\";\n\t}\n\treturn(deliver);\n}\n\nsub vcl_error {\n\n\t# Redirect to SSL\n\tif (obj.status == 751) {\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\tset obj.http.Location = \"https:\/\/\" req.http.host req.url;\n\t\tsynthetic {\"\"};\n\t\treturn (deliver);\n\t}\n}\n","old_contents":"sub vcl_recv {\n#FASTLY recv\n\tif ( req.request == \"FASTLYPURGE\" ) {\n\t\tset req.http.Fastly-Purge-Requires-Auth = \"1\";\n\t}\n\n\tif (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n\t\treturn(pass);\n\t}\n\n\tif (!req.http.Fastly-SSL && req.http.Host == \"cdn.polyfill.io\") {\n\t\terror 751 \"Force TLS\";\n\t}\n\n\tif (req.url ~ \"^\/v2\/polyfill\\.\" && req.url !~ \"[\\?\\&]ua=\") {\n\t\tset req.http.X-Orig-URL = req.url;\n\t\tset req.url = \"\/v2\/normalizeUa?ua=\" urlencode(req.http.User-Agent);\n\t}\n\n\treturn(lookup);\n}\n\nsub vcl_deliver {\n#FASTLY deliver\n\n\t# If the response is to a normalise request and there's a parked \"original request\", use the normalised UA response to modify the original request and restart it\n\tif (req.url ~ \"^\/v\\d\/normalizeUa\" && resp.status == 200 && req.http.X-Orig-URL) {\n\t\tset req.http.Fastly-force-Shield = \"1\";\n\t\tif (req.http.X-Orig-URL ~ \"\\?\") {\n\t\t\tset req.url = req.http.X-Orig-URL \"&ua=\" resp.http.Normalized-User-Agent;\n\t\t} else {\n\t\t\tset req.url = req.http.X-Orig-URL \"?ua=\" resp.http.Normalized-User-Agent;\n\t\t}\n\t\trestart;\n\n\t# If the original request didn't specify a UA override, and we added one when the request was sent to the backend, the backend won't have included a Vary:user-agent header (correctly) but we need to add one\n\t} else if (req.url ~ \"^\/v\\d\/polyfill\\..*[\\?\\&]ua=\" && req.http.X-Orig-URL && req.http.X-Orig-URL !~ \"[\\?\\&]ua=\") {\n\t\tadd resp.http.Vary = \"User-Agent\";\n\t}\n\treturn(deliver);\n}\n\nsub vcl_error {\n\n\t# Redirect to SSL\n\tif (obj.status == 751) {\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\tset obj.http.Location = \"https:\/\/\" req.http.host req.url;\n\t\tsynthetic {\"\"};\n\t\treturn (deliver);\n\t}\n}","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"aa2c8a8e2cadc31a6aa94f73970a36fd7abd5c2f","subject":"Letting GQL cacheing work on HEAD requests as well","message":"Letting GQL cacheing work on HEAD requests as well\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets\/recv.vcl","new_file":"etc\/vcl_snippets\/recv.vcl","new_contents":" # When using Magento tester to test whether your site is configured properly\n # this uses a bypass secret. By default we will use service ID as the bypass secret\n # however user can override this by defining a bypass_secret key in the\n # magentomodule_config edge dictionary\n if ( req.http.bypass-secret ) {\n declare local var.bypass-secret STRING;\n set var.bypass-secret = table.lookup(magentomodule_config, \"bypass_secret\", \"NONE\");\n if ( var.bypass-secret == req.http.bypass-secret ) {\n set req.http.x-pass = \"1\";\n set var.fastly_req_do_shield = false;\n set req.hash_always_miss = true;\n } else if ( var.bypass-secret == \"NONE\" && req.http.bypass-secret == req.service_id ) {\n set req.http.x-pass = \"1\";\n set var.fastly_req_do_shield = false;\n set req.hash_always_miss = true;\n } else {\n error 403 \"Bypass Secret incorrect\";\n }\n\n if (req.url == \"\/fastly-io-tester\") {\n # IO won't work for PASS requests\n unset req.http.x-pass;\n set req.hash_always_miss = true;\n set req.http.X-Fastly-Imageopto-Api = \"fastly\";\n }\n }\n\n # VCL required to support maintenance mode. Don't maintenance mode admin pages and supporting assets\n if (table.lookup(magentomodule_config, \"allow_super_users_during_maint\", \"0\") == \"1\" &&\n !req.http.Fastly-Client-Ip ~ maint_allowlist &&\n !req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" &&\n !req.url ~ \"^\/pub\/static\/\") {\n\n # If we end up here after a restart and there is a ResponseObject it means we got here after error\n # page VCL restart. We shouldn't touch it. Otherwise return a plain 503 error page\n if ( req.restarts > 0 && req.http.ResponseObject ) {\n set req.http.ResponseObject = \"970\";\n } else {\n error 503 \"Maintenance mode\";\n }\n }\n\n # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n unset req.http.x-long-cache;\n\n # We want to force long cache times on any of the versioned assets\n if (req.url.path ~ \"^\/static\/version\\d*\/\") {\n set req.http.x-long-cache = \"1\";\n }\n\n # User's Cookie may contain some Magento Vary items we should vary on\n if (req.http.cookie:X-Magento-Vary) {\n set req.http.X-Magento-Vary = req.http.cookie:X-Magento-Vary;\n } else {\n unset req.http.X-Magento-Vary;\n }\n\n ############################################################################################################\n # Following code block controls purge by URL. By default we want to protect all URL purges. In general this\n # is addressed by adding Fastly-Purge-Requires-Auth request header in vcl_recv however this runs the risk of\n # exposing API tokens if user attempts to purge non-https URLs. For this reason inside the Magento module\n # we use X-Purge-Token. Unfortunately this breaks purge from the Fastly UI. Therefore in the next code block\n # we check for presence of X-Purge-Token. If it's not present we force the Fastly-Purge-Requires-Auth\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n if (req.http.X-Purge-Token && req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n } else {\n error 403;\n }\n } else {\n set req.http.Fastly-Purge-Requires-Auth = \"1\";\n }\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (fastly.ff.visits_this_service > 0) {\n # disable ESI processing on Origin Shield\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Make sure we lookup end user geo not shielding. More at https:\/\/docs.fastly.com\/vcl\/geolocation\/#using-geographic-variables-with-shielding\n set client.geo.ip_override = req.http.Fastly-Client-IP;\n\n if ((req.request == \"GET\" || req.request == \"HEAD\") && req.url.path ~ \"\/graphql\" && req.url.qs ~ \"query=\") {\n set req.http.graphql = \"1\";\n } else {\n unset req.http.graphql;\n }\n\n # geoip lookup\n if (req.url.path ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie:X-Magento-Vary || req.http.cookie:form_key) {\n error 980 \"GeoIP already processed\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url.qs !~ \"country_code=\" ) {\n set req.url = querystring.set(req.url, \"country_code\", if ( req.http.geo_override, req.http.geo_override, client.geo.country_code));\n }\n }\n } else if ( req.url.path !~ \"\/graphql\" ) {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking by default\n # and allow custom parameters to be set. List of parameters is configurable in admin\n set req.http.Magento-Original-URL = req.url;\n # Change the list of ignored parameters by configuring them in the Advanced section\n set req.url = querystring.regfilter(req.url, \"^(####QUERY_PARAMETERS####)$\");\n }\n\n # Don't allow clients to force a pass\n if (req.restarts == 0) {\n unset req.http.x-pass;\n unset req.http.Rate-Limit;\n unset req.http.magento-admin-path;\n }\n\n # Pass on checkout URLs. Because it's a snippet we want to execute this after backend selection so we handle it\n # in the request condition\n if (!req.http.x-long-cache && req.url ~ \"\/(checkout|customer\/section\/load)\") {\n set req.http.x-pass = \"1\";\n # Pass all admin actions\n # ####ADMIN_PATH#### is replaced with value of frontName from app\/etc\/env.php\n } else if ( req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" ) {\n set req.http.x-pass = \"1\";\n set req.http.magento-admin-path = \"1\";\n } else {\n # Sort the query arguments to increase cache hit ratio with query arguments that\n # may be out od order. In case you want to restore the unsorted URL add a snippet\n # after this one that sets req.url to req.http.Magento-Original-URL\n if ( !req.http.x-pass ) {\n set req.url = boltsort.sort(req.url);\n }\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.http.x-long-cache || req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n # GraphQL special headers handling because this area doesn't rely on X-Magento-Vary cookie\n if (req.http.graphql && !req.http.X-Magento-Cache-Id && req.http.Authorization ~ \"^Bearer\" ) {\n unset req.http.graphql;\n set req.http.x-pass = \"1\";\n }\n","old_contents":" # When using Magento tester to test whether your site is configured properly\n # this uses a bypass secret. By default we will use service ID as the bypass secret\n # however user can override this by defining a bypass_secret key in the\n # magentomodule_config edge dictionary\n if ( req.http.bypass-secret ) {\n declare local var.bypass-secret STRING;\n set var.bypass-secret = table.lookup(magentomodule_config, \"bypass_secret\", \"NONE\");\n if ( var.bypass-secret == req.http.bypass-secret ) {\n set req.http.x-pass = \"1\";\n set var.fastly_req_do_shield = false;\n set req.hash_always_miss = true;\n } else if ( var.bypass-secret == \"NONE\" && req.http.bypass-secret == req.service_id ) {\n set req.http.x-pass = \"1\";\n set var.fastly_req_do_shield = false;\n set req.hash_always_miss = true;\n } else {\n error 403 \"Bypass Secret incorrect\";\n }\n\n if (req.url == \"\/fastly-io-tester\") {\n # IO won't work for PASS requests\n unset req.http.x-pass;\n set req.hash_always_miss = true;\n set req.http.X-Fastly-Imageopto-Api = \"fastly\";\n }\n }\n\n # VCL required to support maintenance mode. Don't maintenance mode admin pages and supporting assets\n if (table.lookup(magentomodule_config, \"allow_super_users_during_maint\", \"0\") == \"1\" &&\n !req.http.Fastly-Client-Ip ~ maint_allowlist &&\n !req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" &&\n !req.url ~ \"^\/pub\/static\/\") {\n\n # If we end up here after a restart and there is a ResponseObject it means we got here after error\n # page VCL restart. We shouldn't touch it. Otherwise return a plain 503 error page\n if ( req.restarts > 0 && req.http.ResponseObject ) {\n set req.http.ResponseObject = \"970\";\n } else {\n error 503 \"Maintenance mode\";\n }\n }\n\n # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n unset req.http.x-long-cache;\n\n # We want to force long cache times on any of the versioned assets\n if (req.url.path ~ \"^\/static\/version\\d*\/\") {\n set req.http.x-long-cache = \"1\";\n }\n\n # User's Cookie may contain some Magento Vary items we should vary on\n if (req.http.cookie:X-Magento-Vary) {\n set req.http.X-Magento-Vary = req.http.cookie:X-Magento-Vary;\n } else {\n unset req.http.X-Magento-Vary;\n }\n\n ############################################################################################################\n # Following code block controls purge by URL. By default we want to protect all URL purges. In general this\n # is addressed by adding Fastly-Purge-Requires-Auth request header in vcl_recv however this runs the risk of\n # exposing API tokens if user attempts to purge non-https URLs. For this reason inside the Magento module\n # we use X-Purge-Token. Unfortunately this breaks purge from the Fastly UI. Therefore in the next code block\n # we check for presence of X-Purge-Token. If it's not present we force the Fastly-Purge-Requires-Auth\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n if (req.http.X-Purge-Token && req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n } else {\n error 403;\n }\n } else {\n set req.http.Fastly-Purge-Requires-Auth = \"1\";\n }\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (fastly.ff.visits_this_service > 0) {\n # disable ESI processing on Origin Shield\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Make sure we lookup end user geo not shielding. More at https:\/\/docs.fastly.com\/vcl\/geolocation\/#using-geographic-variables-with-shielding\n set client.geo.ip_override = req.http.Fastly-Client-IP;\n\n if (req.request == \"GET\" && req.url.path ~ \"\/graphql\" && req.url.qs ~ \"query=\") {\n set req.http.graphql = \"1\";\n } else {\n unset req.http.graphql;\n }\n\n # geoip lookup\n if (req.url.path ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie:X-Magento-Vary || req.http.cookie:form_key) {\n error 980 \"GeoIP already processed\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url.qs !~ \"country_code=\" ) {\n set req.url = querystring.set(req.url, \"country_code\", if ( req.http.geo_override, req.http.geo_override, client.geo.country_code));\n }\n }\n } else if ( req.url.path !~ \"\/graphql\" ) {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking by default\n # and allow custom parameters to be set. List of parameters is configurable in admin\n set req.http.Magento-Original-URL = req.url;\n # Change the list of ignored parameters by configuring them in the Advanced section\n set req.url = querystring.regfilter(req.url, \"^(####QUERY_PARAMETERS####)$\");\n }\n\n # Don't allow clients to force a pass\n if (req.restarts == 0) {\n unset req.http.x-pass;\n unset req.http.Rate-Limit;\n unset req.http.magento-admin-path;\n }\n\n # Pass on checkout URLs. Because it's a snippet we want to execute this after backend selection so we handle it\n # in the request condition\n if (!req.http.x-long-cache && req.url ~ \"\/(checkout|customer\/section\/load)\") {\n set req.http.x-pass = \"1\";\n # Pass all admin actions\n # ####ADMIN_PATH#### is replaced with value of frontName from app\/etc\/env.php\n } else if ( req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" ) {\n set req.http.x-pass = \"1\";\n set req.http.magento-admin-path = \"1\";\n } else {\n # Sort the query arguments to increase cache hit ratio with query arguments that\n # may be out od order. In case you want to restore the unsorted URL add a snippet\n # after this one that sets req.url to req.http.Magento-Original-URL\n if ( !req.http.x-pass ) {\n set req.url = boltsort.sort(req.url);\n }\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.http.x-long-cache || req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n # GraphQL special headers handling because this area doesn't rely on X-Magento-Vary cookie\n if (req.http.graphql && !req.http.X-Magento-Cache-Id && req.http.Authorization ~ \"^Bearer\" ) {\n unset req.http.graphql;\n set req.http.x-pass = \"1\";\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"77b4745fa748da5be7ddce6691baa2440db08348","subject":"Adding another acl for 192.*.","message":"Adding another acl for 192.*.\n","repos":"drsnyder\/poky,drsnyder\/poky,drsnyder\/poky","old_file":"config\/default.vcl","new_file":"config\/default.vcl","new_contents":"import std;\nbackend poky {\n .host = \"127.0.0.1\";\n .port = \"8081\"; # make sure this syncs up with the deploy config\n .connect_timeout = 1s;\n .first_byte_timeout = 5s;\n .between_bytes_timeout = 2s;\n .probe = {\n .url = \"\/status\";\n .interval = 5s;\n .timeout = 1s;\n .window = 5;\n .threshold = 3;\n }\n}\n\nacl purgers {\n \"127.0.0.1\";\n \"10.0.0.0\"\/8;\n \"192.0.0.0\"\/8;\n}\n\n\nsub vcl_recv {\n # If-Match is stripped before being sent to the backend\n set req.http.X-If-Match = req.http.If-Match;\n set req.backend = poky;\n set req.grace = 5m;\n\n if (req.request == \"PURGE\") {\n if (!client.ip ~ purgers) {\n error 405 \"Method not allowed\";\n }\n\n return (lookup);\n }\n\n if (req.url ~ \"^\/status$\") {\n return (pass);\n }\n}\n\nsub vcl_hash {\n # we only ever need to hash on the req.url since there is only one\n # host\/server.\n hash_data(req.url);\n return (hash);\n}\n\n\nsub vcl_fetch {\n set beresp.http.x-url = req.url;\n set beresp.http.x-host = req.http.host;\n set beresp.grace = 5m;\n\n if (beresp.status == 200) {\n set beresp.ttl = 4h;\n }\n\n if (beresp.status == 404) {\n # we want to bypass the default hit_for_pass object so we can get HITs on this immediately\n # if it's updated. otherwise, we will encounter misses for 120s\n set beresp.ttl = 0s;\n return (deliver);\n }\n\n if (beresp.status >= 500) {\n set beresp.ttl = 0s;\n }\n}\n\nsub vcl_deliver {\n set resp.http.X-Served-By = server.identity;\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n\nsub vcl_hit {\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged.\";\n }\n}\n\nsub vcl_miss {\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged.\";\n }\n}\n\nsub vcl_pass {\n if (req.request == \"PURGE\") {\n error 503 \"Shouldn't get to (pass) on PURGE.\";\n }\n}\n","old_contents":"import std;\nbackend poky {\n .host = \"127.0.0.1\";\n .port = \"8081\"; # make sure this syncs up with the deploy config\n .connect_timeout = 1s;\n .first_byte_timeout = 5s;\n .between_bytes_timeout = 2s;\n .probe = {\n .url = \"\/status\";\n .interval = 5s;\n .timeout = 1s;\n .window = 5;\n .threshold = 3;\n }\n}\n\nacl purgers {\n \"127.0.0.1\";\n \"10.0.0.0\"\/8;\n}\n\n\nsub vcl_recv {\n # If-Match is stripped before being sent to the backend\n set req.http.X-If-Match = req.http.If-Match;\n set req.backend = poky;\n set req.grace = 5m;\n\n if (req.request == \"PURGE\") {\n if (!client.ip ~ purgers) {\n error 405 \"Method not allowed\";\n }\n\n return (lookup);\n }\n\n if (req.url ~ \"^\/status$\") {\n return (pass);\n }\n}\n\nsub vcl_hash {\n # we only ever need to hash on the req.url since there is only one\n # host\/server.\n hash_data(req.url);\n return (hash);\n}\n\n\nsub vcl_fetch {\n set beresp.http.x-url = req.url;\n set beresp.http.x-host = req.http.host;\n set beresp.grace = 5m;\n\n if (beresp.status == 200) {\n set beresp.ttl = 4h;\n }\n\n if (beresp.status == 404) {\n # we want to bypass the default hit_for_pass object so we can get HITs on this immediately\n # if it's updated. otherwise, we will encounter misses for 120s\n set beresp.ttl = 0s;\n return (deliver);\n }\n\n if (beresp.status >= 500) {\n set beresp.ttl = 0s;\n }\n}\n\nsub vcl_deliver {\n set resp.http.X-Served-By = server.identity;\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n\nsub vcl_hit {\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged.\";\n }\n}\n\nsub vcl_miss {\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged.\";\n }\n}\n\nsub vcl_pass {\n if (req.request == \"PURGE\") {\n error 503 \"Shouldn't get to (pass) on PURGE.\";\n }\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"8dc9a8358ae2d5a62dc96a6e31abf44ff9214514","subject":"Improve lists of static files","message":"Improve lists of static files\n","repos":"nooku\/nooku-platform,timble\/kodekit-platform,nooku\/nooku-platform,timble\/kodekit-platform,timble\/kodekit-platform,nooku\/nooku-platform,nooku\/nooku-platform,nooku\/nooku-platform,timble\/kodekit-platform,timble\/kodekit-platform","old_file":"component\/varnish\/resources\/varnish\/kodekit.vcl","new_file":"component\/varnish\/resources\/varnish\/kodekit.vcl","new_contents":"vcl 4.0;\n# Based on: https:\/\/github.com\/mattiasgeniar\/varnish-4.0-configuration-templates\/blob\/master\/default.vcl\n\nimport std;\nimport directors;\n\nprobe health\n{\n #.url = \"\/varnish-enabled\";\n # We prefer to only do a HEAD \/\n .request =\n \"HEAD \/varnish-enabled HTTP\/1.1\"\n \"Host: localhost\"\n \"Connection: close\";\n .interval = 5s; # check the health of each backend every 5 seconds\n .timeout = 1s; # timing out after 1 second.\n # If 3 out of the last 5 polls succeeded the backend is considered healthy, otherwise it will be marked as sick\n .window = 5;\n .threshold = 3;\n .expected_response = 200;\n}\n\nbackend default\n{\n .host = \"127.0.0.1\"; # IP or Hostname of backend\n .port = \"8080\"; # Port Apache or whatever is listening\n .max_connections = 300; # That's it\n .probe = health;\n .connect_timeout = 600s; # How long to wait before we receive a first byte from our backend?\n .first_byte_timeout = 600s; # How long to wait for a backend connection?\n .between_bytes_timeout = 600s; # How long to wait between bytes received from our backend?\n}\n\nbackend passthrough\n{\n .host = \"127.0.0.1\"; # IP or Hostname of backend\n .port = \"8080\"; # Port Apache or whatever is listening\n}\n\nacl localhost\n{\n \"localhost\";\n \"33.33.33.63\";\n \"::1\";\n}\n\nsub vcl_init\n{\n # Called when VCL is loaded, before any requests pass through it.\n # Typically used to initialize VMODs.\n\n new vdir = directors.round_robin();\n vdir.add_backend(default);\n # vdir.add_backend(server...);\n # vdir.add_backend(servern);\n}\n\nsub vcl_recv\n{\n # Called at the beginning of a request, after the complete request has been received and parsed.\n # Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable,\n # which backend to use and if needed to modify the request.\n\n # Send all traffic to the vdir director\n set req.backend_hint = vdir.backend();\n\n # Normalize the header, remove the port (in case you're testing this on various TCP ports)\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n # Normalize the query arguments\n set req.url = std.querysort(req.url);\n\n # Allow purging\n if (req.method == \"PURGE\")\n {\n # purge is the ACL defined at the begining\n if (!client.ip ~ localhost) {\n return (synth(405, \"This IP is not allowed to send PURGE requests.\"));\n }\n\n # If you got this stage (and didn't error out above), purge the cached result\n return (purge);\n }\n\n # Check if we've still enabled Varnish, if not, passthrough every request\n if (! std.healthy(req.backend_hint))\n {\n set req.backend_hint = passthrough;\n return (pass);\n }\n\n # Only deal with \"normal\" types\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"PATCH\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n # Implementing websocket support (https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html)\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n # Only cache GET or HEAD requests. This makes sure the POST requests are always passed.\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n # Specific Nooku Platform rules\n\n # Do not cache \/administrator\n if(req.url ~ \"^\/administrator\") {\n return (pass);\n }\n\n # Specific Nooku Server rules\n\n # Do not cache webgrind.nooku.dev\n if (req.http.host == \"webgrind.nooku.dev\") {\n return (pass);\n }\n\n # Do not cache phpmyadmin.nooku.dev\n if (req.http.host == \"phpmyadmin.nooku.dev\") {\n return (pass);\n }\n\n # Do not cache \/apc and \/phpinfo\n if (req.url == \"\/apc\" || req.url == \"\/phpinfo\") {\n return (pass);\n }\n\n # Generic URL manipulation, useful for all templates that follow\n\n # Remove the Google Analytics added parameters, useless for our backend\n if (req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=\") {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # Strip hash, server doesn't need it.\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n # Strip a trailing ? if it exists\n if (req.url ~ \"\\?$\") {\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # Cookie manipulation\n\n # Remove the \"has_js\" cookie\n set req.http.Cookie = regsuball(req.http.Cookie, \"has_js=[^;]+(; )?\", \"\");\n\n # Remove any Google Analytics based cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__utm.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"_ga=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"_gat=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmctr=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmcmd.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmccn.=[^;]+(; )?\", \"\");\n\n # Remove DoubleClick offensive cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__gads=[^;]+(; )?\", \"\");\n\n # Remove the Quant Capital cookies (added by some plugin, all __qca)\n set req.http.Cookie = regsuball(req.http.Cookie, \"__qc.=[^;]+(; )?\", \"\");\n\n # Remove the AddThis cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__atuv.=[^;]+(; )?\", \"\");\n\n # Remove a \";\" prefix in the cookie if present\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n\n # Remove the csrf_token cookie\n set req.http.Cookie = regsuball(req.http.Cookie, \"csrf_token=[^;]+(; )?\", \"\");\n\n # Are there cookies left with only spaces or that are empty?\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n\n # Large static files are delivered directly to the end-user without waiting for Varnish to fully read the file first.\n # Varnish 4 supports Streaming, so set do_stream in vcl_backend_response()\n if (req.url ~ \"^[^?]*\\.(7z|avi|bz2|flac|flv|gz|mka|mkv|mov|mp3|mp4|mpeg|mpg|ogg|ogm|opus|rar|tar|tgz|tbz|txz|wav|webm|xz|zip)(\\?.*)?$\") {\n unset req.http.Cookie;\n return (hash);\n }\n\n # Remove all cookies for static files\n # Before you blindly enable this read: https:\/\/ma.ttias.be\/stop-caching-static-files\/\n #if (req.method == \"GET\")\n #{\n # # Cache files with these extensions and remove cookie\n # if (req.url ~ \"^[^?]*\\.(7z|avi|bmp|bz2|css|csv|doc|docx|eot|flac|flv|gif|gz|ico|jpeg|jpg|js|less|mka|mkv|mov|mp3|mp4|mpeg|mpg|odt|otf|ogg|ogm|opus|pdf|png|ppt|pptx|rar|rtf|svg|svgz|swf|tar|tbz|tgz|ttf|txt|txz|wav|webm|webp|woff|woff2|xls|xlsx|xml|xz|zip)(\\?.*)?$\") {\n # unset req.http.Cookie;\n # return (hash);\n # }\n #}\n\n if (req.http.Cache-Control ~ \"(?i)no-cache\" && client.ip ~ localhost)\n {\n # http:\/\/varnish.projects.linpro.no\/wiki\/VCLExampleEnableForceRefresh\n # Ignore requests via proxy caches and badly behaved crawlers\n # like msnbot that send no-cache with every request.\n if (! (req.http.Via || req.http.User-Agent ~ \"(?i)bot\" || req.http.X-Purge))\n {\n # Doesn't seems to refresh the object in the cache\n set req.hash_always_miss = true;\n\n # Couple this with restart in vcl_purge and X-Purge header to avoid loops\n return(purge);\n }\n }\n\n # Send Surrogate-Capability headers to announce ESI support to backend\n set req.http.Surrogate-Capability = \"varnish=ESI\/1.0\";\n\n # Requests that require authorization are not cacheable by default\n if (req.http.Authorization) {\n return (pass);\n }\n\n # We do not support SPDY or HTTP\/2.0\n if (req.method == \"PRI\") {\n return (synth(405));\n }\n\n return (hash);\n}\n\n# Called upon entering pipe mode. In this mode, the request is passed on to the backend, and any further data from both\n# the client and backend is passed on unaltered until either end closes the connection. Basically, Varnish will degrade\n# into a simple TCP proxy, shuffling bytes back and forth. For a connection in pipe mode, no other VCL subroutine will\n# ever get called after vcl_pipe.\nsub vcl_pipe\n{\n # Note that only the first request to the backend will have X-Forwarded-For set.\n # If you use X-Forwarded-For and want to have it set for all requests, make sure to have:\n # set bereq.http.connection = \"close\";\n # It is not set by default as it might break some broken web applications, like IIS with NTLM authentication.\n # set bereq.http.Connection = \"Close\";\n\n # Implementing websocket support (https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html)\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n\n return (pipe);\n}\n\n# Called upon entering pass mode. In this mode, the request is passed on to the backend, and the backend's response\n# is passed on to the client, but is not entered into the cache. Subsequent requests submitted over the same client\n# connection are handled normally.\nsub vcl_pass\n{\n return (fetch);\n}\n\n# Called after vcl_recv to create a hash value for the request. This is used as a key to look up the object in Varnish.\nsub vcl_hash\n{\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n\n # hash cookies for requests that have them\n if (req.http.Cookie) {\n hash_data(req.http.Cookie);\n }\n}\n\n# Called when a cache lookup is successful.\nsub vcl_hit\n{\n # A pure unadultered hit, deliver it\n if (obj.ttl >= 0s) {\n return (deliver);\n }\n\n # https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-grace.html\n # When several clients are requesting the same page Varnish will send one request to the backend and place the\n # others on hold while fetching one copy from the backend. In some products this is called request coalescing and\n # Varnish does this automatically.\n\n # If you are serving thousands of hits per second the queue of waiting requests can get huge. There are two\n # potential problems - one is a thundering herd problem - suddenly releasing a thousand threads to serve content\n # might send the load sky high. Secondly - nobody likes to wait. To deal with this we can instruct Varnish to keep\n # the objects in cache beyond their TTL and to serve the waiting requests somewhat stale content.\n\n # if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n # return (deliver);\n # } else {\n # return (fetch);\n # }\n\n # We have no fresh fish. Lets look at the stale ones.\n if (std.healthy(req.backend_hint))\n {\n # Backend is healthy. Limit age to 10s.\n if (obj.ttl + 10s > 0s)\n {\n #set req.http.grace = \"normal(limited)\";\n return (deliver);\n }\n else\n {\n # No candidate for grace. Fetch a fresh object.\n return(fetch);\n }\n }\n else\n {\n # backend is sick - use full grace\n if (obj.ttl + obj.grace > 0s)\n {\n #set req.http.grace = \"full\";\n return (deliver);\n }\n else\n {\n # no graced object.\n return (fetch);\n }\n }\n\n # fetch & deliver once we get the result\n return (fetch); # Dead code, keep as a safeguard\n}\n\n# Called after a cache lookup if the requested document was not found in the cache. Its purpose is to decide whether\n# or not to attempt to retrieve the document from the backend, and which backend to use.\nsub vcl_miss\n{\n return (fetch);\n}\n\n # Called after the response headers has been successfully retrieved from the backend.\nsub vcl_backend_response\n{\n # Enable ESI handling\n if (beresp.http.Surrogate-Control ~ \"ESI\/1.0\" ) {\n set beresp.do_esi = true;\n }\n\n # Store the csrf_token cookie temporarily if the response is cacheabale\n if (beresp.http.Set-Cookie && !beresp.uncacheable)\n {\n set beresp.http.X-Varnish-Cookie = beresp.http.Set-Cookie;\n unset beresp.http.Set-Cookie;\n }\n\n # Cache handling all static files\n if (bereq.method == \"GET\")\n {\n # Before you blindly enable this, read: https:\/\/ma.ttias.be\/stop-caching-static-files\/\n #if (bereq.url ~ \"^[^?]*\\.(7z|avi|bmp|bz2|css|csv|doc|docx|eot|flac|flv|gif|gz|ico|jpeg|jpg|js|less|mka|mkv|mov|mp3|mp4|mpeg|mpg|odt|otf|ogg|ogm|opus|pdf|png|ppt|pptx|rar|rtf|svg|svgz|swf|tar|tbz|tgz|ttf|txt|txz|wav|webm|webp|woff|woff2|xls|xlsx|xml|xz|zip)(\\?.*)?$\") {\n # unset beresp.http.Set-Cookie;\n #}\n\n # Large static files are delivered directly to the end-user without waiting for Varnish to fully read the\n # file first. Check memory usage it'll grow in fetch_chunksize blocks (128k by default) if the backend\n # doesn't send a Content-Length header. Only enable it for large files\n if (bereq.url ~ \"^[^?]*\\.(7z|avi|bz2|flac|flv|gz|mka|mkv|mov|mp3|mp4|mpeg|mpg|ogg|ogm|opus|rar|tar|tgz|tbz|txz|wav|webm|xz|zip)(\\?.*)?$\") {\n {\n unset beresp.http.Set-Cookie;\n\n # Use streaming to avoid locking\n set beresp.do_stream = true;\n\n # Don't try to compress it for storage\n set beresp.do_gzip = false;\n\n # Disable Transfer-encoding chunked when serving HTML5 video\n # See : http:\/\/stackoverflow.com\/questions\/23643233\/how-do-i-disable-transfer-encoding-chunked-encoding-in-varnish\n # See : https:\/\/www.varnish-cache.org\/trac\/ticket\/1506\n if(beresp.http.Content-Type ~ \"video\") {\n set beresp.do_stream = true;\n set beresp.do_esi = true;\n }\n }\n\n # Set 2min cache if unset for static files\n if (beresp.ttl <= 0s || beresp.http.Set-Cookie || beresp.http.Vary == \"*\")\n {\n set beresp.ttl = 120s; # Important, you shouldn't rely on this, SET YOUR HEADERS in the backend\n set beresp.uncacheable = true;\n\n return (deliver);\n }\n }\n\n # Sometimes, a 301 or 302 redirect formed via Apache's mod_rewrite can mess with the HTTP port that is being passed along.\n # This often happens with simple rewrite rules in a scenario where Varnish runs on :80 and Apache on :8080 on the same box.\n # A redirect can then often redirect the end-user to a URL on :8080, where it should be :80.\n # This may need finetuning on your setup.\n #\n # To prevent accidental replace, we only filter the 301\/302 redirects for now.\n if (beresp.status == 301 || beresp.status == 302) {\n set beresp.http.Location = regsub(beresp.http.Location, \":[0-9]+\", \"\");\n }\n\n # Do not cache errors from the backend\n if (beresp.status >= 400)\n {\n set beresp.uncacheable = true;\n set beresp.ttl = 0s;\n\n return (deliver);\n }\n\n # Allow stale content, in case the backend goes down. Make Varnish keep all objects for 6 hours beyond their TTL\n set beresp.grace = 6h;\n\n # Set ban-lurker friendly custom headers\n set beresp.http.X-Varnish-Url = bereq.url;\n set beresp.http.X-Varnish-Host = bereq.http.host;\n\n return (deliver);\n}\n\n# Called when the backend returns an error\nsub vcl_backend_error\n{\n if (beresp.status == 503 && bereq.retries < 5)\n {\n set beresp.http.X-Varnish-Retries = bereq.retries;\n return(retry);\n }\n\n return(deliver);\n}\n\n# Called before a cached object is delivered to the client.\nsub vcl_deliver\n{\n # Send the Cookie header again if a temporay header was stored\n if (req.http.X-Varnish-Cookie) {\n set resp.http.Set-Cookie = req.http.X-Varnish-Cookie;\n }\n\n # Add extra headers if debugging is enabled\n if (resp.http.x-varnish-debug && server.ip ~ localhost)\n {\n set resp.http.X-Served-By = server.hostname;\n\n if (resp.http.x-varnish ~ \" \") {\n set resp.http.X-Varnish-Status = \"HIT\";\n } else {\n set resp.http.X-Varnish-Status = \"MISS\";\n }\n\n # Please note that obj.hits behaviour changed in 4.0, now it counts per objecthead, not per object\n # and obj.hits may not be reset in some cases where bans are in use. See bug 1492 for details.\n # So take hits with a grain of salt\n set resp.http.X-Varnish-Hits = obj.hits;\n }\n else\n {\n # Remove ban-lurker friendly custom headers when delivering to client\n unset resp.http.X-Url;\n unset resp.http.X-Host;\n\n # Remove some headers: PHP version\n unset resp.http.X-Powered-By;\n\n # Remove some headers: Apache version & OS\n unset resp.http.Server;\n unset resp.http.Via;\n unset resp.http.Link;\n unset resp.http.X-Varnish;\n unset resp.http.X-Varnish-Tag;\n unset resp.http.X-Varnish-Debug;\n unset resp.http.X-Varnish-Host;\n unset resp.http.X-Varnish-Url;\n unset resp.http.X-Varnish-Retries;\n unset resp.http.X-Varnish-Cookie;\n unset resp.http.Surrogate-Control;\n }\n\n return (deliver);\n}\n\nsub vcl_purge\n{\n # Only handle actual PURGE HTTP methods, everything else is discarded\n if (req.method != \"PURGE\" && server.ip ~ localhost)\n {\n set req.http.X-Varnish-Purge = \"Yes\";\n return (restart);\n }\n}\n\nsub vcl_synth\n{\n if (resp.status == 720)\n {\n # We use this special error status 720 to force redirects with 301 (permanent) redirects\n # To use this, call the following from anywhere in vcl_recv: return (synth(720, \"http:\/\/host\/new.html\"));\n set resp.http.Location = resp.reason;\n set resp.status = 301;\n\n return (deliver);\n }\n elseif (resp.status == 721)\n {\n # And we use error status 721 to force redirects with a 302 (temporary) redirect\n # To use this, call the following from anywhere in vcl_recv: return (synth(720, \"http:\/\/host\/new.html\"));\n\n set resp.http.Location = resp.reason;\n set resp.status = 302;\n\n return (deliver);\n }\n\n return (deliver);\n}\n\n# Called when VCL is discarded only after all requests have exited the VCL. Typically used to clean up VMODs.\nsub vcl_fini\n{\n return (ok);\n}\n","old_contents":"vcl 4.0;\n# Based on: https:\/\/github.com\/mattiasgeniar\/varnish-4.0-configuration-templates\/blob\/master\/default.vcl\n\nimport std;\nimport directors;\n\nprobe health\n{\n #.url = \"\/varnish-enabled\";\n # We prefer to only do a HEAD \/\n .request =\n \"HEAD \/varnish-enabled HTTP\/1.1\"\n \"Host: localhost\"\n \"Connection: close\";\n .interval = 5s; # check the health of each backend every 5 seconds\n .timeout = 1s; # timing out after 1 second.\n # If 3 out of the last 5 polls succeeded the backend is considered healthy, otherwise it will be marked as sick\n .window = 5;\n .threshold = 3;\n .expected_response = 200;\n}\n\nbackend default\n{\n .host = \"127.0.0.1\"; # IP or Hostname of backend\n .port = \"8080\"; # Port Apache or whatever is listening\n .max_connections = 300; # That's it\n .probe = health;\n .connect_timeout = 600s; # How long to wait before we receive a first byte from our backend?\n .first_byte_timeout = 600s; # How long to wait for a backend connection?\n .between_bytes_timeout = 600s; # How long to wait between bytes received from our backend?\n}\n\nbackend passthrough\n{\n .host = \"127.0.0.1\"; # IP or Hostname of backend\n .port = \"8080\"; # Port Apache or whatever is listening\n}\n\nacl localhost\n{\n \"localhost\";\n \"33.33.33.63\";\n \"::1\";\n}\n\nsub vcl_init\n{\n # Called when VCL is loaded, before any requests pass through it.\n # Typically used to initialize VMODs.\n\n new vdir = directors.round_robin();\n vdir.add_backend(default);\n # vdir.add_backend(server...);\n # vdir.add_backend(servern);\n}\n\nsub vcl_recv\n{\n # Called at the beginning of a request, after the complete request has been received and parsed.\n # Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable,\n # which backend to use and if needed to modify the request.\n\n # Send all traffic to the vdir director\n set req.backend_hint = vdir.backend();\n\n # Normalize the header, remove the port (in case you're testing this on various TCP ports)\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n # Normalize the query arguments\n set req.url = std.querysort(req.url);\n\n # Allow purging\n if (req.method == \"PURGE\")\n {\n # purge is the ACL defined at the begining\n if (!client.ip ~ localhost) {\n return (synth(405, \"This IP is not allowed to send PURGE requests.\"));\n }\n\n # If you got this stage (and didn't error out above), purge the cached result\n return (purge);\n }\n\n # Check if we've still enabled Varnish, if not, passthrough every request\n if (! std.healthy(req.backend_hint))\n {\n set req.backend_hint = passthrough;\n return (pass);\n }\n\n # Only deal with \"normal\" types\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"PATCH\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n # Implementing websocket support (https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html)\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n # Only cache GET or HEAD requests. This makes sure the POST requests are always passed.\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n # Specific Nooku Platform rules\n\n # Do not cache \/administrator\n if(req.url ~ \"^\/administrator\") {\n return (pass);\n }\n\n # Specific Nooku Server rules\n\n # Do not cache webgrind.nooku.dev\n if (req.http.host == \"webgrind.nooku.dev\") {\n return (pass);\n }\n\n # Do not cache phpmyadmin.nooku.dev\n if (req.http.host == \"phpmyadmin.nooku.dev\") {\n return (pass);\n }\n\n # Do not cache \/apc and \/phpinfo\n if (req.url == \"\/apc\" || req.url == \"\/phpinfo\") {\n return (pass);\n }\n\n # Generic URL manipulation, useful for all templates that follow\n\n # Remove the Google Analytics added parameters, useless for our backend\n if (req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=\") {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # Strip hash, server doesn't need it.\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n # Strip a trailing ? if it exists\n if (req.url ~ \"\\?$\") {\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # Cookie manipulation\n\n # Remove the \"has_js\" cookie\n set req.http.Cookie = regsuball(req.http.Cookie, \"has_js=[^;]+(; )?\", \"\");\n\n # Remove any Google Analytics based cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__utm.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"_ga=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"_gat=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmctr=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmcmd.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmccn.=[^;]+(; )?\", \"\");\n\n # Remove DoubleClick offensive cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__gads=[^;]+(; )?\", \"\");\n\n # Remove the Quant Capital cookies (added by some plugin, all __qca)\n set req.http.Cookie = regsuball(req.http.Cookie, \"__qc.=[^;]+(; )?\", \"\");\n\n # Remove the AddThis cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__atuv.=[^;]+(; )?\", \"\");\n\n # Remove a \";\" prefix in the cookie if present\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n\n # Remove the csrf_token cookie\n set req.http.Cookie = regsuball(req.http.Cookie, \"csrf_token=[^;]+(; )?\", \"\");\n\n # Are there cookies left with only spaces or that are empty?\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n\n # Large static files are delivered directly to the end-user without waiting for Varnish to fully read the file first.\n # Varnish 4 supports Streaming, so set do_stream in vcl_backend_response()\n if (req.url ~ \"^[^?]*\\.(mp[34]|rar|tar|tgz|gz|wav|zip|bz2|xz|7z|avi|mov|og[gvaxm]|mpe?g|mk[av]|webm)(\\?.*)?$\") {\n unset req.http.Cookie;\n return (hash);\n }\n\n # Remove all cookies for static files\n # Before you blindly enable this read: https:\/\/ma.ttias.be\/stop-caching-static-files\/\n #if (req.method == \"GET\")\n #{\n # # Cache files with these extensions and remove cookie\n # if (req.url ~ \"^[^?]*\\.(bmp|bz2|css|doc|eot|flv|gif|gz|ico|jpeg|jpg|js|less|pdf|png|rtf|swf|txt|woff|xml)(\\?.*)?$\") {\n # unset req.http.Cookie;\n # return (hash);\n # }\n #}\n\n if (req.http.Cache-Control ~ \"(?i)no-cache\" && client.ip ~ localhost)\n {\n # http:\/\/varnish.projects.linpro.no\/wiki\/VCLExampleEnableForceRefresh\n # Ignore requests via proxy caches and badly behaved crawlers\n # like msnbot that send no-cache with every request.\n if (! (req.http.Via || req.http.User-Agent ~ \"(?i)bot\" || req.http.X-Purge))\n {\n # Doesn't seems to refresh the object in the cache\n set req.hash_always_miss = true;\n\n # Couple this with restart in vcl_purge and X-Purge header to avoid loops\n return(purge);\n }\n }\n\n # Send Surrogate-Capability headers to announce ESI support to backend\n set req.http.Surrogate-Capability = \"varnish=ESI\/1.0\";\n\n # Requests that require authorization are not cacheable by default\n if (req.http.Authorization) {\n return (pass);\n }\n\n # We do not support SPDY or HTTP\/2.0\n if (req.method == \"PRI\") {\n return (synth(405));\n }\n\n return (hash);\n}\n\n# Called upon entering pipe mode. In this mode, the request is passed on to the backend, and any further data from both\n# the client and backend is passed on unaltered until either end closes the connection. Basically, Varnish will degrade\n# into a simple TCP proxy, shuffling bytes back and forth. For a connection in pipe mode, no other VCL subroutine will\n# ever get called after vcl_pipe.\nsub vcl_pipe\n{\n # Note that only the first request to the backend will have X-Forwarded-For set.\n # If you use X-Forwarded-For and want to have it set for all requests, make sure to have:\n # set bereq.http.connection = \"close\";\n # It is not set by default as it might break some broken web applications, like IIS with NTLM authentication.\n # set bereq.http.Connection = \"Close\";\n\n # Implementing websocket support (https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html)\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n\n return (pipe);\n}\n\n# Called upon entering pass mode. In this mode, the request is passed on to the backend, and the backend's response\n# is passed on to the client, but is not entered into the cache. Subsequent requests submitted over the same client\n# connection are handled normally.\nsub vcl_pass\n{\n return (fetch);\n}\n\n# Called after vcl_recv to create a hash value for the request. This is used as a key to look up the object in Varnish.\nsub vcl_hash\n{\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n\n # hash cookies for requests that have them\n if (req.http.Cookie) {\n hash_data(req.http.Cookie);\n }\n}\n\n# Called when a cache lookup is successful.\nsub vcl_hit\n{\n # A pure unadultered hit, deliver it\n if (obj.ttl >= 0s) {\n return (deliver);\n }\n\n # https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-grace.html\n # When several clients are requesting the same page Varnish will send one request to the backend and place the\n # others on hold while fetching one copy from the backend. In some products this is called request coalescing and\n # Varnish does this automatically.\n\n # If you are serving thousands of hits per second the queue of waiting requests can get huge. There are two\n # potential problems - one is a thundering herd problem - suddenly releasing a thousand threads to serve content\n # might send the load sky high. Secondly - nobody likes to wait. To deal with this we can instruct Varnish to keep\n # the objects in cache beyond their TTL and to serve the waiting requests somewhat stale content.\n\n # if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n # return (deliver);\n # } else {\n # return (fetch);\n # }\n\n # We have no fresh fish. Lets look at the stale ones.\n if (std.healthy(req.backend_hint))\n {\n # Backend is healthy. Limit age to 10s.\n if (obj.ttl + 10s > 0s)\n {\n #set req.http.grace = \"normal(limited)\";\n return (deliver);\n }\n else\n {\n # No candidate for grace. Fetch a fresh object.\n return(fetch);\n }\n }\n else\n {\n # backend is sick - use full grace\n if (obj.ttl + obj.grace > 0s)\n {\n #set req.http.grace = \"full\";\n return (deliver);\n }\n else\n {\n # no graced object.\n return (fetch);\n }\n }\n\n # fetch & deliver once we get the result\n return (fetch); # Dead code, keep as a safeguard\n}\n\n# Called after a cache lookup if the requested document was not found in the cache. Its purpose is to decide whether\n# or not to attempt to retrieve the document from the backend, and which backend to use.\nsub vcl_miss\n{\n return (fetch);\n}\n\n # Called after the response headers has been successfully retrieved from the backend.\nsub vcl_backend_response\n{\n # Enable ESI handling\n if (beresp.http.Surrogate-Control ~ \"ESI\/1.0\" ) {\n set beresp.do_esi = true;\n }\n\n # Store the csrf_token cookie temporarily if the response is cacheabale\n if (beresp.http.Set-Cookie && !beresp.uncacheable)\n {\n set beresp.http.X-Varnish-Cookie = beresp.http.Set-Cookie;\n unset beresp.http.Set-Cookie;\n }\n\n # Cache handling all static files\n if (bereq.method == \"GET\")\n {\n # Before you blindly enable this, read: https:\/\/ma.ttias.be\/stop-caching-static-files\/\n #if (bereq.url ~ \"^[^?]*\\.(bmp|bz2|css|doc|eot|flv|gif|gz|ico|jpeg|jpg|js|less|mp[34]|pdf|png|rar|rtf|swf|tar|tgz|txt|wav|woff|xml|zip|webm)(\\?.*)?$\") {\n # unset beresp.http.Set-Cookie;\n #}\n\n # Large static files are delivered directly to the end-user without waiting for Varnish to fully read the\n # file first. Check memory usage it'll grow in fetch_chunksize blocks (128k by default) if the backend\n # doesn't send a Content-Length header. Only enable it for large files\n if (bereq.url ~ \"^[^?]*\\.(mp[34]|rar|tar|tgz|gz|wav|zip|bz2|xz|7z|avi|mov|og[gvaxm]|mpe?g|mk[av]|webm)(\\?.*)?$\")\n {\n unset beresp.http.Set-Cookie;\n\n # Use streaming to avoid locking\n set beresp.do_stream = true;\n\n # Don't try to compress it for storage\n set beresp.do_gzip = false;\n\n # Disable Transfer-encoding chunked when serving HTML5 video\n # See : http:\/\/stackoverflow.com\/questions\/23643233\/how-do-i-disable-transfer-encoding-chunked-encoding-in-varnish\n # See : https:\/\/www.varnish-cache.org\/trac\/ticket\/1506\n if(beresp.http.Content-Type ~ \"video\") {\n set beresp.do_stream = true;\n set beresp.do_esi = true;\n }\n }\n\n # Set 2min cache if unset for static files\n if (beresp.ttl <= 0s || beresp.http.Set-Cookie || beresp.http.Vary == \"*\")\n {\n set beresp.ttl = 120s; # Important, you shouldn't rely on this, SET YOUR HEADERS in the backend\n set beresp.uncacheable = true;\n\n return (deliver);\n }\n }\n\n # Sometimes, a 301 or 302 redirect formed via Apache's mod_rewrite can mess with the HTTP port that is being passed along.\n # This often happens with simple rewrite rules in a scenario where Varnish runs on :80 and Apache on :8080 on the same box.\n # A redirect can then often redirect the end-user to a URL on :8080, where it should be :80.\n # This may need finetuning on your setup.\n #\n # To prevent accidental replace, we only filter the 301\/302 redirects for now.\n if (beresp.status == 301 || beresp.status == 302) {\n set beresp.http.Location = regsub(beresp.http.Location, \":[0-9]+\", \"\");\n }\n\n # Do not cache errors from the backend\n if (beresp.status >= 400)\n {\n set beresp.uncacheable = true;\n set beresp.ttl = 0s;\n\n return (deliver);\n }\n\n # Allow stale content, in case the backend goes down. Make Varnish keep all objects for 6 hours beyond their TTL\n set beresp.grace = 6h;\n\n # Set ban-lurker friendly custom headers\n set beresp.http.X-Varnish-Url = bereq.url;\n set beresp.http.X-Varnish-Host = bereq.http.host;\n\n return (deliver);\n}\n\n# Called when the backend returns an error\nsub vcl_backend_error\n{\n if (beresp.status == 503 && bereq.retries < 5)\n {\n set beresp.http.X-Varnish-Retries = bereq.retries;\n return(retry);\n }\n\n return(deliver);\n}\n\n# Called before a cached object is delivered to the client.\nsub vcl_deliver\n{\n # Send the Cookie header again if a temporay header was stored\n if (req.http.X-Varnish-Cookie) {\n set resp.http.Set-Cookie = req.http.X-Varnish-Cookie;\n }\n\n # Add extra headers if debugging is enabled\n if (resp.http.x-varnish-debug && server.ip ~ localhost)\n {\n set resp.http.X-Served-By = server.hostname;\n\n if (resp.http.x-varnish ~ \" \") {\n set resp.http.X-Varnish-Status = \"HIT\";\n } else {\n set resp.http.X-Varnish-Status = \"MISS\";\n }\n\n # Please note that obj.hits behaviour changed in 4.0, now it counts per objecthead, not per object\n # and obj.hits may not be reset in some cases where bans are in use. See bug 1492 for details.\n # So take hits with a grain of salt\n set resp.http.X-Varnish-Hits = obj.hits;\n }\n else\n {\n # Remove ban-lurker friendly custom headers when delivering to client\n unset resp.http.X-Url;\n unset resp.http.X-Host;\n\n # Remove some headers: PHP version\n unset resp.http.X-Powered-By;\n\n # Remove some headers: Apache version & OS\n unset resp.http.Server;\n unset resp.http.Via;\n unset resp.http.Link;\n unset resp.http.X-Varnish;\n unset resp.http.X-Varnish-Tag;\n unset resp.http.X-Varnish-Debug;\n unset resp.http.X-Varnish-Host;\n unset resp.http.X-Varnish-Url;\n unset resp.http.X-Varnish-Retries;\n unset resp.http.X-Varnish-Cookie;\n unset resp.http.Surrogate-Control;\n }\n\n return (deliver);\n}\n\nsub vcl_purge\n{\n # Only handle actual PURGE HTTP methods, everything else is discarded\n if (req.method != \"PURGE\" && server.ip ~ localhost)\n {\n set req.http.X-Varnish-Purge = \"Yes\";\n return (restart);\n }\n}\n\nsub vcl_synth\n{\n if (resp.status == 720)\n {\n # We use this special error status 720 to force redirects with 301 (permanent) redirects\n # To use this, call the following from anywhere in vcl_recv: return (synth(720, \"http:\/\/host\/new.html\"));\n set resp.http.Location = resp.reason;\n set resp.status = 301;\n\n return (deliver);\n }\n elseif (resp.status == 721)\n {\n # And we use error status 721 to force redirects with a 302 (temporary) redirect\n # To use this, call the following from anywhere in vcl_recv: return (synth(720, \"http:\/\/host\/new.html\"));\n\n set resp.http.Location = resp.reason;\n set resp.status = 302;\n\n return (deliver);\n }\n\n return (deliver);\n}\n\n# Called when VCL is discarded only after all requests have exited the VCL. Typically used to clean up VMODs.\nsub vcl_fini\n{\n return (ok);\n}\n","returncode":0,"stderr":"","license":"mpl-2.0","lang":"VCL"} {"commit":"9531ff68570deb1dd7626c8fc022d68b6d2200bb","subject":"Couple optimizations and Vary cleanup","message":"Couple optimizations and Vary cleanup\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/fastly.vcl","new_file":"etc\/fastly.vcl","new_contents":"###############################################################################\n#\n# Fastly CDN for Magento 2\n#\n# NOTICE OF LICENSE\n#\n# This source file is subject to the Fastly CDN for Magento 2 End User License\n# Agreement that is bundled with this package in the file LICENSE_FASTLY_CDN.txt.\n#\n# @copyright Copyright (c) 2016 Fastly, Inc. (http:\/\/www.fastly.com)\n# @license BSD, see LICENSE_FASTLY_CDN.txt\n#\n###############################################################################\n\n# This is a basic VCL configuration file for Fastly CDN for Magento 2 module.\n\nsub vcl_recv {\n#FASTLY recv\n\n # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n # Sort the query arguments\n set req.url = boltsort.sort(req.url);\n\n if (req.url ~ \"^\/static\/version(\\d*\/)?(.*)$\") {\n set req.url = \"\/static\/\" + re.group.2 + \"?\" + re.group.1;\n }\n \n # User's Cookie may contain some Magento Vary items we should vary on\n if (req.http.cookie:X-Magento-Vary ) {\n set req.http.X-Magento-Vary = req.http.cookie:X-Magento-Vary;\n } else {\n unset req.http.X-Magento-Vary;\n }\n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n set req.http.X-Sig = regsub(req.http.X-Purge-Token, \"^[^_]+_(.*)\", \"\\1\");\n set req.http.X-Exp = regsub(req.http.X-Purge-Token, \"^([^_]+)_.*\", \"\\1\");\n\n # validate signature\n if (req.http.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path req.http.X-Exp), \"^0x\", \"\")) {\n\n # use vcl time math to check expiration timestamp\n set req.http.X-Original-Grace = req.grace;\n set req.grace = std.atoi(strftime({\"%s\"}, now));\n set req.grace -= std.atoi(req.http.X-Exp);\n\n if (std.atoi(req.grace) > 0) {\n error 410;\n }\n\n # clean up grace since we used it for time math\n set req.grace = std.atoi(req.http.X-Original-Grace);\n unset req.http.X-Original-Grace;\n\n } else {\n error 403;\n }\n\n # cleanup variables\n unset req.http.X-Purge-Token;\n unset req.http.X-Sig;\n unset req.http.X-Exp;\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n # disable ESI processing on Origin Shield\n if (req.http.Fastly-FF) {\n set req.esi = false;\n }\n\n # We only deal with GET and HEAD by default\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n return (pass);\n }\n \n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie ~ \"(X-Magento-Vary|form_key)=\") {\n error 200 \"\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url !~ \"country_code=\" ) {\n set req.url = req.url \"?country_code=\" if ( req.http.geo_override, req.http.geo_override, geoip.country_code);\n }\n }\n } else {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking\n set req.http.Fastly-Original-URL = req.url;\n set req.url = querystring.regfilter(req.url, \"^(utm_.*|gclid|gdftrk|_ga|mc_.*)\");\n }\n \n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n return (lookup);\n }\n\n # Bypass shopping cart and checkout requests\n if (req.url ~ \"\/checkout\") {\n return (pass);\n }\n\n return(lookup);\n}\n\nsub vcl_fetch {\n\n # Remove Set-Cookies from responses for static content\n # to match the cookie removal in recv.\n if (req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n }\n\n }\n\n#FASTLY fetch\n\n if (beresp.status >= 500) {\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n }\n\n if (req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Content-Type ~ \"text\/html\" || beresp.http.Content-Type ~ \"text\/xml\") {\n # enable ESI feature for Magento response by default\n esi;\n if (!beresp.http.Vary ~ \"X-Magento-Vary,Https\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \",X-Magento-Vary,Https\";\n } else {\n set beresp.http.Vary = \"X-Magento-Vary,Https\";\n }\n }\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content\n if ((beresp.status == 200 || beresp.status == 404) && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url ~ \"\\.(css|js|html|eot|ico|otf|ttf|json)($|\\?)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # cache only successfully responses and 404s\n if (beresp.status != 200 && beresp.status != 301 && beresp.status != 404) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\")) {\n unset beresp.http.set-cookie;\n if (req.url !~ \"^\/(pub\/)?(media|static)\/.*\") {\n set beresp.grace = 86400m;\n }\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type\n if (beresp.http.Content-Type ~ \"image\") {\n set beresp.http.Surrogate-Key = \"image\";\n } elsif (beresp.http.Content-Type ~ \"script\") {\n set beresp.http.Surrogate-Key = \"script\";\n } elsif (beresp.http.Content-Type ~ \"css\") {\n set beresp.http.Surrogate-Key = \"css\";\n }\n\n set beresp.http.X-Surrogate-Key = beresp.http.Surrogate-Key;\n return (deliver);\n }\n\n return (deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\n\nsub vcl_miss {\n # Deactivate gzip on origin\n unset bereq.http.Accept-Encoding;\n\n#FASTLY miss\n\n return(fetch);\n}\n\nsub vcl_deliver {\n\n\n # Send no cache headers to end users for non-static content. Also make sure\n # we only set this on the edge nodes and not on shields\n if (req.url !~ \"^\/(pub\/)?(media|static)\/.*\" && !req.http.Fastly-FF ) {\n set resp.http.Pragma = \"no-cache\";\n set resp.http.Cache-Control = \"no-store, no-cache, must-revalidate, max-age=0\";\n }\n\n # Remove X-Magento-Vary and HTTPs Vary served to the user\n if ( !req.http.Fastly-FF ) {\n set resp.http.Vary = regsub(resp.http.Vary, \"X-Magento-Vary,Https\", \"Cookie\");\n }\n\n # Add an easy way to see whether custom Fastly VCL has been uploaded\n if ( req.http.Fastly-Debug ) {\n set resp.http.Fastly-Magento-VCL-Uploaded = \"yes\";\n } else {\n remove resp.http.Fastly-Module-Enabled;\n }\n # debug info\n if (resp.http.X-Magento-Debug) {\n if (obj.hits > 0) {\n set resp.http.X-Magento-Cache-Debug = \"HIT\";\n set resp.http.X-Magento-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Magento-Cache-Debug = \"MISS\";\n }\n } else {\n # remove Varnish\/proxy header\n remove resp.http.Age;\n remove resp.http.X-Magento-Debug;\n remove resp.http.X-Magento-Tags;\n remove resp.http.X-Surrogate-Key;\n remove resp.http.X-Magento-Cache-Control;\n remove resp.http.X-Powered-By;\n remove resp.http.Server;\n remove resp.http.X-Varnish;\n remove resp.http.Via;\n remove resp.http.Link;\n remove resp.http.X-Purge-URL;\n remove resp.http.X-Purge-Host;\n }\n\n#FASTLY deliver\n\n return (deliver);\n}\n\n\nsub vcl_error {\n # workaround for possible security issue\n if (req.url ~ \"^\\s\") {\n set obj.status = 400;\n set obj.response = \"Malformed request\";\n synthetic \"\";\n return (deliver);\n }\n\n # error 200\n if (obj.status == 200) {\n return (deliver);\n }\n\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} obj.status \" \" obj.response {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} obj.status \" \" obj.response {\"<\/h1>\n <p>\"} obj.response {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} req.xid {\"<\/p>\n <hr>\n <p>Fastly CDN server<\/p>\n <\/body>\n<\/html>\n\"};\n\n#FASTLY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n\nsub vcl_hash {\n set req.hash += req.http.host;\n set req.hash += req.url;\n \n ### {{ design_exceptions_code }} ###\n\n# Please do not remove below. It's required for purge all functionality\n#FASTLY hash\n\n return (hash);\n\n}\n\n","old_contents":"###############################################################################\n#\n# Fastly CDN for Magento 2\n#\n# NOTICE OF LICENSE\n#\n# This source file is subject to the Fastly CDN for Magento 2 End User License\n# Agreement that is bundled with this package in the file LICENSE_FASTLY_CDN.txt.\n#\n# @copyright Copyright (c) 2016 Fastly, Inc. (http:\/\/www.fastly.com)\n# @license BSD, see LICENSE_FASTLY_CDN.txt\n#\n###############################################################################\n\n# This is a basic VCL configuration file for Fastly CDN for Magento 2 module.\n\nsub vcl_recv {\n#FASTLY recv\n\n # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n # Sort the query arguments\n set req.url = boltsort.sort(req.url);\n\n if (req.url ~ \"^\/static\/version(\\d*\/)?(.*)$\") {\n set req.url = \"\/static\/\" + re.group.2 + \"?\" + re.group.1;\n }\n\n if (req.http.cookie:X-Magento-Vary ) {\n set req.http.X-Magento-Vary = req.http.cookie:X-Magento-Vary;\n }\n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n set req.http.X-Sig = regsub(req.http.X-Purge-Token, \"^[^_]+_(.*)\", \"\\1\");\n set req.http.X-Exp = regsub(req.http.X-Purge-Token, \"^([^_]+)_.*\", \"\\1\");\n\n # validate signature\n if (req.http.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path req.http.X-Exp), \"^0x\", \"\")) {\n\n # use vcl time math to check expiration timestamp\n set req.http.X-Original-Grace = req.grace;\n set req.grace = std.atoi(strftime({\"%s\"}, now));\n set req.grace -= std.atoi(req.http.X-Exp);\n\n if (std.atoi(req.grace) > 0) {\n error 410;\n }\n\n # clean up grace since we used it for time math\n set req.grace = std.atoi(req.http.X-Original-Grace);\n unset req.http.X-Original-Grace;\n\n } else {\n error 403;\n }\n\n # cleanup variables\n unset req.http.X-Purge-Token;\n unset req.http.X-Sig;\n unset req.http.X-Exp;\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n # disable ESI processing on Origin Shield\n if (req.http.Fastly-FF) {\n set req.esi = false;\n }\n\n # We only deal with GET and HEAD by default\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n return (pass);\n }\n \n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie ~ \"(X-Magento-Vary|form_key)=\") {\n error 200 \"\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url !~ \"country_code=\" ) {\n set req.url = req.url \"?country_code=\" if ( req.http.geo_override, req.http.geo_override, geoip.country_code);\n }\n }\n } else {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking\n set req.http.Fastly-Original-URL = req.url;\n set req.url = querystring.regfilter(req.url, \"^(utm_.*|gclid|gdftrk|_ga|mc_.*)\");\n }\n \n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n return (lookup);\n }\n\n # Bypass shopping cart and checkout requests\n if (req.url ~ \"\/checkout\") {\n return (pass);\n }\n\n return(lookup);\n}\n\nsub vcl_fetch {\n\n # Remove Set-Cookies from responses for static content\n # to match the cookie removal in recv.\n if (req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n }\n\n }\n\n#FASTLY fetch\n\n if (beresp.status >= 500) {\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n }\n\n if (req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Content-Type ~ \"text\/html\" || beresp.http.Content-Type ~ \"text\/xml\") {\n # enable ESI feature for Magento response by default\n esi;\n if (!beresp.http.Vary ~ \"X-Magento-Vary, Https\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", X-Magento-Vary, Https\";\n } else {\n set beresp.http.Vary = \"X-Magento-Vary, Https\";\n }\n }\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content\n if ((beresp.status == 200 || beresp.status == 404) && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url ~ \"\\.(css|js|html|eot|ico|otf|ttf|json)($|\\?)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # cache only successfully responses and 404s\n if (beresp.status != 200 && beresp.status != 301 && beresp.status != 404) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\")) {\n unset beresp.http.set-cookie;\n if (req.url !~ \"^\/(pub\/)?(media|static)\/.*\") {\n set beresp.grace = 86400m;\n }\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type\n if (beresp.http.Content-Type ~ \"image\") {\n set beresp.http.Surrogate-Key = \"image\";\n } elsif (beresp.http.Content-Type ~ \"script\") {\n set beresp.http.Surrogate-Key = \"script\";\n } elsif (beresp.http.Content-Type ~ \"css\") {\n set beresp.http.Surrogate-Key = \"css\";\n }\n\n set beresp.http.X-Surrogate-Key = beresp.http.Surrogate-Key;\n return (deliver);\n }\n\n return (deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\n\nsub vcl_miss {\n # Deactivate gzip on origin\n unset bereq.http.Accept-Encoding;\n\n#FASTLY miss\n\n return(fetch);\n}\n\nsub vcl_deliver {\n\n # Send no cache headers to end users for non-static content. Also make sure\n # we only set this on the edge nodes and not on shields\n if (req.url !~ \"^\/(pub\/)?(media|static)\/.*\" && !req.http.Fastly-FF ) {\n set resp.http.Pragma = \"no-cache\";\n set resp.http.Cache-Control = \"no-store, no-cache, must-revalidate, max-age=0\";\n }\n\n # Add an easy way to see whether custom Fastly VCL has been uploaded\n if ( req.http.Fastly-Debug ) {\n set resp.http.Fastly-Magento-VCL-Uploaded = \"yes\";\n } else {\n remove resp.http.Fastly-Module-Enabled;\n }\n # debug info\n if (resp.http.X-Magento-Debug) {\n if (obj.hits > 0) {\n set resp.http.X-Magento-Cache-Debug = \"HIT\";\n set resp.http.X-Magento-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Magento-Cache-Debug = \"MISS\";\n }\n } else {\n # remove Varnish\/proxy header\n remove resp.http.Age;\n remove resp.http.X-Magento-Debug;\n remove resp.http.X-Magento-Tags;\n remove resp.http.X-Surrogate-Key;\n remove resp.http.X-Magento-Cache-Control;\n remove resp.http.X-Powered-By;\n remove resp.http.Server;\n remove resp.http.X-Varnish;\n remove resp.http.Via;\n remove resp.http.Link;\n remove resp.http.X-Purge-URL;\n remove resp.http.X-Purge-Host;\n }\n\n#FASTLY deliver\n\n return (deliver);\n}\n\n\nsub vcl_error {\n # workaround for possible security issue\n if (req.url ~ \"^\\s\") {\n set obj.status = 400;\n set obj.response = \"Malformed request\";\n synthetic \"\";\n return (deliver);\n }\n\n # error 200\n if (obj.status == 200) {\n return (deliver);\n }\n\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} obj.status \" \" obj.response {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} obj.status \" \" obj.response {\"<\/h1>\n <p>\"} obj.response {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} req.xid {\"<\/p>\n <hr>\n <p>Fastly CDN server<\/p>\n <\/body>\n<\/html>\n\"};\n\n#FASTLY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n\nsub vcl_hash {\n set req.hash += req.http.host;\n set req.hash += req.url;\n \n ### {{ design_exceptions_code }} ###\n\n# Please do not remove below. It's required for purge all functionality\n#FASTLY hash\n\n return (hash);\n\n}\n\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"bf8bcf76adb84930e9bfbebc95bd0a50677d878d","subject":"Code style. 2 spaces.","message":"Code style. 2 spaces.\n","repos":"amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon","old_file":"images\/varnish-drupal\/drupal.vcl","new_file":"images\/varnish-drupal\/drupal.vcl","new_contents":"vcl 4.0;\n\nimport std;\nimport dynamic;\n\n# set backend default\nbackend default {\n .host = \"${VARNISH_BACKEND_HOST:-nginx}\";\n .port = \"${VARNISH_BACKEND_PORT:-8080}\";\n .first_byte_timeout = 35m;\n .between_bytes_timeout = 10m;\n}\n\n# Allow purging from localhost\n# @TODO allow from openshift network\nacl purge {\n \"127.0.0.1\";\n \"10.0.0.0\"\/8;\n \"172.16.0.0\"\/12;\n \"192.168.0.0\"\/16;\n}\n\nsub vcl_init {\n new www_dir = dynamic.director(\n port = \"${VARNISH_BACKEND_PORT:-8080}\",\n first_byte_timeout = 90s,\n between_bytes_timeout = 90s,\n ttl = 60s);\n}\n\n# This configuration is optimized for Drupal hosting:\n# Respond to incoming requests.\nsub vcl_recv {\n if (req.url ~ \"^\/varnish_status$\") {\n return (synth(200,\"OK\"));\n }\n # set the backend, which should be used:\n set req.backend_hint = www_dir.backend(\"${VARNISH_BACKEND_HOST:-nginx}\");\n\n # Always set the forward ip.\n if (req.restarts == 0) {\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n }\n else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n if (req.http.X-LAGOON-VARNISH ) {\n # Pass all Requests which are handled via an upstream Varnish\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, \" + req.http.X-LAGOON-VARNISH;\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n }\n else if (req.http.Fastly-FF) {\n # Pass all Requests which are handled via Fastly\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, fastly\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n set req.http.X-Forwarded-For = req.http.Fastly-Client-IP;\n }\n else if (req.http.CF-RAY) {\n # Pass all Requests which are handled via CloudFlare\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, cloudflare\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n set req.http.X-Forwarded-For = req.http.CF-Connecting-IP;\n }\n else if (req.http.X-Pull) {\n # Pass all Requests which are handled via KeyCDN\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, keycdn\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n }\n else {\n # We set a header to let a Varnish chain know that it already has been varnishcached\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}\";\n\n # Allow to bypass based on env variable `VARNISH_BYPASS`\n set req.http.X-LAGOON-VARNISH-BYPASS = \"${VARNISH_BYPASS:-false}\";\n }\n\n # Websockets are piped\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n if (req.http.X-LAGOON-VARNISH-BYPASS == \"true\" || req.http.X-LAGOON-VARNISH-BYPASS == \"TRUE\") {\n return (pass);\n }\n\n # SA-CORE-2014-004 preventing access to \/xmlrpc.php\n if (req.url ~ \"^\/xmlrpc.php$\") {\n return (synth(701, \"Unauthorized\"));\n }\n\n # Strip out Google Analytics campaign variables. They are only needed\n # by the javascript running on the page\n # utm_source, utm_medium, utm_campaign, gclid\n if(req.url ~ \"(\\?|&)(gclid|utm_[a-z]+)=\") {\n set req.url = regsuball(req.url, \"(gclid|utm_[a-z]+)=[^\\&]+&?\", \"\");\n set req.url = regsub(req.url, \"(\\?|&)$\", \"\");\n }\n\n # Bypass a cache hit (the request is still sent to the backend)\n if (req.method == \"REFRESH\") {\n if (!client.ip ~ purge) {\n return (synth(405, \"Not allowed\"));\n }\n set req.method = \"GET\";\n set req.hash_always_miss = true;\n }\n\n # Only allow BAN requests from IP addresses in the 'purge' ACL.\n if (req.method == \"BAN\" || req.method == \"URIBAN\" || req.method == \"PURGE\") {\n # Only allow BAN from defined ACL\n if (!client.ip ~ purge) {\n return (synth(403, \"Your IP is not allowed.\"));\n }\n\n # Only allows BAN if the Host Header has the style of with \"${SERVICE_NAME:-varnish}:8080\" or \"${SERVICE_NAME:-varnish}\".\n # Such a request is only possible from within the Docker network, as a request from external goes trough the Kubernetes Router and for that needs a proper Host Header\n if (!req.http.host ~ \"^${SERVICE_NAME:-varnish}(:\\d+)?$\") {\n return (synth(403, \"Only allowed from within own network.\"));\n }\n\n if (req.method == \"BAN\") {\n # Logic for the ban, using the Cache-Tags header.\n if (req.http.Cache-Tags) {\n ban(\"obj.http.Cache-Tags ~ \" + req.http.Cache-Tags);\n # Throw a synthetic page so the request won't go to the backend.\n return (synth(200, \"Ban added.\"));\n }\n else {\n return (synth(403, \"Cache-Tags header missing.\"));\n }\n }\n\n if (req.method == \"URIBAN\" || req.method == \"PURGE\") {\n ban(\"req.url ~ \" + req.url);\n # Throw a synthetic page so the request won't go to the backend.\n return (synth(200, \"Ban added.\"));\n }\n }\n\n # Non-RFC2616 or CONNECT which is weird, we pipe that\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n return (pipe);\n }\n\n # We only try to cache GET and HEAD, other things are passed\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n # Any requests with Basic Authentication are passed.\n if (req.http.Authorization || req.http.Authenticate) {\n return (pass);\n }\n\n # Blackfire requests are passed.\n if (req.http.X-Blackfire-Query) {\n return (pass);\n }\n\n # Some URLs should never be cached.\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/admin([\/?]|$).*$\" ||\n req.url ~ \"^\/info([\/?]|$).*$\" ||\n req.url ~ \"^\/flag([\/?]|$).*$\" ||\n req.url ~ \"^.*\/system\/files([\/?]|$).*$\" ||\n req.url ~ \"^\/cgi\" ||\n req.url ~ \"^\/cgi-bin\"\n ) {\n return (pass);\n }\n\n # Plupload likes to get piped.\n if (req.url ~ \"^.*\/plupload-handle-uploads.*$\") {\n return (pipe);\n }\n\n # Handle compression correctly. Different browsers send different\n # \"Accept-Encoding\" headers, even though they mostly all support the same\n # compression mechanisms. By consolidating these compression headers into\n # a consistent format, we can reduce the size of the cache and get more hits.=\n # @see: http:\/\/ varnish.projects.linpro.no\/wiki\/FAQ\/Compression\n if (req.http.Accept-Encoding) {\n if (req.http.Accept-Encoding ~ \"gzip\") {\n # If the browser supports it, we'll use gzip.\n set req.http.Accept-Encoding = \"gzip\";\n }\n else if (req.http.Accept-Encoding ~ \"deflate\") {\n # Next, try deflate if it is supported.\n set req.http.Accept-Encoding = \"deflate\";\n }\n else {\n # Unknown algorithm. Remove it and send unencoded.\n unset req.http.Accept-Encoding;\n }\n }\n\n # Always cache the following file types for all users.\n if (req.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n unset req.http.Cookie;\n }\n\n # Remove all cookies that Drupal doesn't need to know about. ANY remaining\n # cookie will cause the request to pass-through to a backend. For the most part\n # we always set the NO_CACHE cookie after any POST request, disabling the\n # Varnish cache temporarily. The session cookie allows all authenticated users\n # to pass through as long as they're logged in.\n #\n # 1. Append a semi-colon to the front of the cookie string.\n # 2. Remove all spaces that appear after semi-colons.\n # 3. Match the cookies we want to keep, adding the space we removed\n # previously, back. (\\1) is first matching group in the regsuball.\n # 4. Remove all other cookies, identifying them by the fact that they have\n # no space after the preceding semi-colon.\n # 5. Remove all spaces and semi-colons from the beginning and end of the\n # cookie string.\n if (req.http.Cookie) {\n set req.http.CookieCheck = \";\" + req.http.Cookie;\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"; +\", \";\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";(${VARNISH_COOKIECHECK:-SESS[a-z0-9]+|SSESS[a-z0-9]+|NO_CACHE})=\", \"; \\1=\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";[^ ][^;]*\", \"\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"^[; ]+|[; ]+$\", \"\");\n\n set req.http.Cookie = req.http.Cookie + \";\";\n\n if (req.http.CookieCheck == \"\") {\n # If there are no remaining cookies, remove the cookie header. If there\n # aren't any cookie headers, Varnish's default behavior will be to cache\n # the page.\n\n unset req.http.CookieCheck;\n unset req.http.Cookie;\n }\n else {\n # If there is any cookies left (a session or NO_CACHE cookie), do not\n # cache the page. Pass it on to Apache directly.\n unset req.http.CookieCheck;\n return (pass);\n }\n }\n\n # Cacheable, lookup in cache.\n return (hash);\n}\n\nsub vcl_pipe {\n # Support for Websockets\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n set bereq.http.connection = req.http.connection;\n }\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n # normal hit\n return (deliver);\n }\n # We have no fresh fish. Lets look at the stale ones.\n if (std.healthy(req.backend_hint)) {\n # Backend is healthy. If the object is not older then 30secs, deliver it to the client\n # and automatically create a separate backend request to warm the cache for this request.\n if (obj.ttl + 30s > 0s) {\n set req.http.grace = \"normal(limited)\";\n return (deliver);\n } else {\n # No candidate for grace. Fetch a fresh object.\n return (miss);\n }\n }\n else {\n # backend is sick - use full grace\n if (obj.ttl + obj.grace > 0s) {\n set req.http.grace = \"full\";\n return (deliver);\n } else {\n # no graced object.\n return (miss);\n }\n }\n}\n\nsub vcl_backend_response {\n # Allow items to be stale if needed.\n set beresp.grace = 6h;\n\n # Set ban-lurker friendly custom headers.\n set beresp.http.X-Url = bereq.url;\n set beresp.http.X-Host = bereq.http.host;\n\n # If the backend sends a X-LAGOON-VARNISH-BACKEND-BYPASS header we directly deliver\n if (beresp.http.X-LAGOON-VARNISH-BACKEND-BYPASS == \"TRUE\") {\n return (deliver);\n }\n\n # Cache 404 and 403 for 10 seconds\n if (beresp.status == 404 || beresp.status == 403) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n # Don't allow static files to set cookies.\n if (bereq.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n # beresp == Back-end response from the web server.\n unset beresp.http.set-cookie;\n unset beresp.http.Cache-Control;\n\n # If an asset would come back with statuscode 500 we only cache it for 10 seconds instead of the usual static file cache\n if (beresp.status == 500) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n set beresp.ttl = ${VARNISH_ASSETS_TTL:-2628001}s;\n set beresp.http.Cache-Control = \"public, max-age=${VARNISH_ASSETS_TTL:-2628001}\";\n set beresp.http.Expires = \"\" + (now + beresp.ttl);\n }\n\n # Disable buffering only for BigPipe responses\n if (beresp.http.Surrogate-Control ~ \"BigPipe\/1.0\") {\n set beresp.do_stream = true;\n set beresp.ttl = 0s;\n }\n\n return (deliver);\n}\n\n# Set a header to track a cache HIT\/MISS.\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Varnish-Cache = \"HIT\";\n }\n else {\n set resp.http.X-Varnish-Cache = \"MISS\";\n }\n\n # Remove ban-lurker friendly custom headers when delivering to client.\n unset resp.http.X-Url;\n unset resp.http.X-Host;\n\n # unset Cache-Tags Header by default, can be disabled with VARNISH_SET_HEADER_CACHE_TAGS=true\n if (!${VARNISH_SET_HEADER_CACHE_TAGS:-false}) {\n unset resp.http.Cache-Tags;\n }\n\n unset resp.http.X-Generator;\n unset resp.http.Server;\n # Inject information about grace\n if (req.http.grace) {\n set resp.http.X-Varnish-Grace = req.http.grace;\n }\n set resp.http.X-LAGOON = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}>\" + resp.http.X-LAGOON;\n return (deliver);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n }\n else {\n hash_data(server.ip);\n }\n if (req.http.X-Forwarded-Proto) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n if (req.http.HTTPS) {\n hash_data(req.http.HTTPS);\n }\n return (lookup);\n}\n\nsub vcl_synth {\n if (resp.status == 701) {\n set resp.status = 401;\n set resp.http.Content-Type = \"text\/plain; charset=utf-8\";\n synthetic({\"XMLRPC Interface is blocked due to SA-CORE-2014-004 - mail support@amazee.io if you need it.\"});\n return (deliver);\n }\n if (resp.status == 700) {\n # Set a status the client will understand\n set resp.status = 200;\n # Create our synthetic response\n synthetic(\"\");\n return(deliver);\n }\n return (deliver);\n}\n\nsub vcl_backend_error {\n # Restart the request, when we have a backend server error, to try another backend.\n # Restart max twice.\n if (bereq.retries < 2) {\n return(retry);\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic({\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<head>\n <title>Server Error<\/title>\n <style type=\"text\/css\">\n body {\n font-family: helvetica, arial, sans-serif;\n }\n img {\n margin-top: 50px;\n }\n p {\n width: 6 00px;\n margin-top: 10px\n }\n div {\n background: #ccc;\n width: 600px;\n margin: auto;\n padding: 50px;\n }\n span {\n color: #ccc\n }\n <\/style>\n<\/head>\n<body>\n <div>\n <h1>We are sorry...<\/h1>\n <p>We encountered a server-side error. This means that the problem is not with your computer or Internet connection, but rather with the website's server.<\/p>\n <p>We are currently working on solving this problem and apologise for the inconvenience.<\/p>\n <span>\n <strong>Technical Information<\/strong><br \/>\n Error \"} + beresp.status + \" \" + beresp.reason + {\"<br \/>\n XID: \"} + bereq.xid + {\"<br \/>\n <\/span>\n <\/div>\n<\/body>\n<\/html>\n\n\"});\n return (deliver);\n}\n","old_contents":"vcl 4.0;\n\nimport std;\nimport dynamic;\n\n# set backend default\nbackend default {\n .host = \"${VARNISH_BACKEND_HOST:-nginx}\";\n .port = \"${VARNISH_BACKEND_PORT:-8080}\";\n .first_byte_timeout = 35m;\n .between_bytes_timeout = 10m;\n}\n\n# Allow purging from localhost\n# @TODO allow from openshift network\nacl purge {\n \"127.0.0.1\";\n \"10.0.0.0\"\/8;\n \"172.16.0.0\"\/12;\n \"192.168.0.0\"\/16;\n}\n\nsub vcl_init {\n new www_dir = dynamic.director(\n port = \"${VARNISH_BACKEND_PORT:-8080}\",\n first_byte_timeout = 90s,\n between_bytes_timeout = 90s,\n ttl = 60s);\n}\n\n# This configuration is optimized for Drupal hosting:\n# Respond to incoming requests.\nsub vcl_recv {\n if (req.url ~ \"^\/varnish_status$\") {\n return (synth(200,\"OK\"));\n }\n # set the backend, which should be used:\n set req.backend_hint = www_dir.backend(\"${VARNISH_BACKEND_HOST:-nginx}\");\n\n # Always set the forward ip.\n if (req.restarts == 0) {\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n\n\n if (req.http.X-LAGOON-VARNISH ) {\n ## Pass all Requests which are handled via an upstream Varnish\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, \" + req.http.X-LAGOON-VARNISH;\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n } else if (req.http.Fastly-FF) {\n ## Pass all Requests which are handled via Fastly\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, fastly\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n set req.http.X-Forwarded-For = req.http.Fastly-Client-IP;\n } else if (req.http.CF-RAY) {\n ## Pass all Requests which are handled via CloudFlare\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, cloudflare\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n set req.http.X-Forwarded-For = req.http.CF-Connecting-IP;\n } else if (req.http.X-Pull) {\n ## Pass all Requests which are handled via KeyCDN\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, keycdn\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n } else {\n ## We set a header to let a Varnish Chain know that it already has been varnishcached\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}\";\n\n ## Allow to bypass based on env variable `VARNISH_BYPASS`\n set req.http.X-LAGOON-VARNISH-BYPASS = \"${VARNISH_BYPASS:-false}\";\n }\n\n # Websockets are piped\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n if (req.http.X-LAGOON-VARNISH-BYPASS == \"true\" || req.http.X-LAGOON-VARNISH-BYPASS == \"TRUE\") {\n return (pass);\n }\n\n # SA-CORE-2014-004 preventing access to \/xmlrpc.php\n if (req.url ~ \"^\/xmlrpc.php$\") {\n return (synth(701, \"Unauthorized\"));\n }\n\n # Strip out Google Analytics campaign variables. They are only needed\n # by the javascript running on the page\n # utm_source, utm_medium, utm_campaign, gclid\n if(req.url ~ \"(\\?|&)(gclid|utm_[a-z]+)=\") {\n set req.url = regsuball(req.url, \"(gclid|utm_[a-z]+)=[^\\&]+&?\", \"\");\n set req.url = regsub(req.url, \"(\\?|&)$\", \"\");\n }\n\n # Bypass a cache hit (the request is still sent to the backend)\n if (req.method == \"REFRESH\") {\n if (!client.ip ~ purge) { return (synth(405, \"Not allowed\")); }\n set req.method = \"GET\";\n set req.hash_always_miss = true;\n }\n\n # Only allow BAN requests from IP addresses in the 'purge' ACL.\n if (req.method == \"BAN\" || req.method == \"URIBAN\" || req.method == \"PURGE\") {\n # Only allow BAN from defined ACL\n if (!client.ip ~ purge) {\n return (synth(403, \"Your IP is not allowed.\"));\n }\n\n # Only allows BAN if the Host Header has the style of with \"${SERVICE_NAME:-varnish}:8080\" or \"${SERVICE_NAME:-varnish}\".\n # Such a request is only possible from within the Docker network, as a request from external goes trough the Kubernetes Router and for that needs a proper Host Header\n if (!req.http.host ~ \"^${SERVICE_NAME:-varnish}(:\\d+)?$\") {\n return (synth(403, \"Only allowed from within own network.\"));\n }\n\n if (req.method == \"BAN\") {\n # Logic for the ban, using the Cache-Tags header.\n if (req.http.Cache-Tags) {\n ban(\"obj.http.Cache-Tags ~ \" + req.http.Cache-Tags);\n # Throw a synthetic page so the request won't go to the backend.\n return (synth(200, \"Ban added.\"));\n }\n else {\n return (synth(403, \"Cache-Tags header missing.\"));\n }\n }\n\n if (req.method == \"URIBAN\" || req.method == \"PURGE\") {\n ban(\"req.url ~ \" + req.url);\n # Throw a synthetic page so the request won't go to the backend.\n return (synth(200, \"Ban added.\"));\n }\n\n }\n\n # Non-RFC2616 or CONNECT which is weird, we pipe that\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n return (pipe);\n }\n\n # We only try to cache GET and HEAD, other things are passed\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n # Any requests with Basic Auth are passed\n if (req.http.Authorization || req.http.Authenticate)\n {\n return (pass);\n }\n\n ## Pass requests which are from blackfire\n if (req.http.X-Blackfire-Query) {\n return (pass);\n }\n\n # Some URLs should never be cached\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/admin([\/?]|$).*$\" ||\n req.url ~ \"^\/info([\/?]|$).*$\" ||\n req.url ~ \"^\/flag([\/?]|$).*$\" ||\n req.url ~ \"^.*\/system\/files([\/?]|$).*$\" ||\n req.url ~ \"^\/cgi\" ||\n req.url ~ \"^\/cgi-bin\"\n ) {\n return (pass);\n }\n\n # Plupload likes to get piped\n if (req.url ~ \"^.*\/plupload-handle-uploads.*$\"\n ) {\n return (pipe);\n }\n\n # Handle compression correctly. Different browsers send different\n # \"Accept-Encoding\" headers, even though they mostly all support the same\n # compression mechanisms. By consolidating these compression headers into\n # a consistent format, we can reduce the size of the cache and get more hits.=\n # @see: http:\/\/ varnish.projects.linpro.no\/wiki\/FAQ\/Compression\n if (req.http.Accept-Encoding) {\n if (req.http.Accept-Encoding ~ \"gzip\") {\n # If the browser supports it, we'll use gzip.\n set req.http.Accept-Encoding = \"gzip\";\n }\n else if (req.http.Accept-Encoding ~ \"deflate\") {\n # Next, try deflate if it is supported.\n set req.http.Accept-Encoding = \"deflate\";\n }\n else {\n # Unknown algorithm. Remove it and send unencoded.\n unset req.http.Accept-Encoding;\n }\n }\n\n # Always cache the following file types for all users.\n if (req.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n unset req.http.Cookie;\n }\n\n # Remove all cookies that Drupal doesn't need to know about. ANY remaining\n # cookie will cause the request to pass-through to a backend. For the most part\n # we always set the NO_CACHE cookie after any POST request, disabling the\n # Varnish cache temporarily. The session cookie allows all authenticated users\n # to pass through as long as they're logged in.\n #\n # 1. Append a semi-colon to the front of the cookie string.\n # 2. Remove all spaces that appear after semi-colons.\n # 3. Match the cookies we want to keep, adding the space we removed\n # previously, back. (\\1) is first matching group in the regsuball.\n # 4. Remove all other cookies, identifying them by the fact that they have\n # no space after the preceding semi-colon.\n # 5. Remove all spaces and semi-colons from the beginning and end of the\n # cookie string.\n if (req.http.Cookie) {\n set req.http.CookieCheck = \";\" + req.http.Cookie;\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"; +\", \";\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";(${VARNISH_COOKIECHECK:-SESS[a-z0-9]+|SSESS[a-z0-9]+|NO_CACHE})=\", \"; \\1=\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";[^ ][^;]*\", \"\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"^[; ]+|[; ]+$\", \"\");\n\n set req.http.Cookie = req.http.Cookie + \";\";\n\n if (req.http.CookieCheck == \"\") {\n # If there are no remaining cookies, remove the cookie header. If there\n # aren't any cookie headers, Varnish's default behavior will be to cache\n # the page.\n\n unset req.http.CookieCheck;\n unset req.http.Cookie;\n }\n else {\n # If there is any cookies left (a session or NO_CACHE cookie), do not\n # cache the page. Pass it on to Apache directly.\n unset req.http.CookieCheck;\n return (pass);\n }\n }\n\n # Cacheable, lookup in cache.\n return (hash);\n}\n\nsub vcl_pipe {\n # Support for Websockets\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n set bereq.http.connection = req.http.connection;\n }\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n # normal hit\n return (deliver);\n }\n # We have no fresh fish. Lets look at the stale ones.\n if (std.healthy(req.backend_hint)) {\n # Backend is healthy. If the object is not older then 30secs, deliver it to the client\n # and automatically create a separate backend request to warm the cache for this request.\n if (obj.ttl + 30s > 0s) {\n set req.http.grace = \"normal(limited)\";\n return (deliver);\n } else {\n # No candidate for grace. Fetch a fresh object.\n return(miss);\n }\n } else {\n # backend is sick - use full grace\n if (obj.ttl + obj.grace > 0s) {\n set req.http.grace = \"full\";\n return (deliver);\n } else {\n # no graced object.\n return (miss);\n }\n }\n}\n\nsub vcl_backend_response {\n # Allow items to be stale if needed.\n set beresp.grace = 6h;\n\n # Set ban-lurker friendly custom headers.\n set beresp.http.X-Url = bereq.url;\n set beresp.http.X-Host = bereq.http.host;\n\n # If the backend sends a X-LAGOON-VARNISH-BACKEND-BYPASS header we directly deliver\n if(beresp.http.X-LAGOON-VARNISH-BACKEND-BYPASS == \"TRUE\") {\n return (deliver);\n }\n\n # Cache 404 and 403 for 10 seconds\n if(beresp.status == 404 || beresp.status == 403) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n # Don't allow static files to set cookies.\n if (bereq.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n # beresp == Back-end response from the web server.\n unset beresp.http.set-cookie;\n unset beresp.http.Cache-Control;\n\n # If an asset would come back with statuscode 500 we only cache it for 10 seconds instead of the usual static file cache\n if (beresp.status == 500) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n set beresp.ttl = ${VARNISH_ASSETS_TTL:-2628001}s;\n set beresp.http.Cache-Control = \"public, max-age=${VARNISH_ASSETS_TTL:-2628001}\";\n set beresp.http.Expires = \"\" + (now + beresp.ttl);\n }\n # Disable buffering only for BigPipe responses\n if (beresp.http.Surrogate-Control ~ \"BigPipe\/1.0\") {\n set beresp.do_stream = true;\n set beresp.ttl = 0s;\n }\n\n return (deliver);\n}\n\n# Set a header to track a cache HIT\/MISS.\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Varnish-Cache = \"HIT\";\n }\n else {\n set resp.http.X-Varnish-Cache = \"MISS\";\n }\n\n # Remove ban-lurker friendly custom headers when delivering to client.\n unset resp.http.X-Url;\n unset resp.http.X-Host;\n\n # unset Cache-Tags Header by default, can be disabled with VARNISH_SET_HEADER_CACHE_TAGS=true\n if (!${VARNISH_SET_HEADER_CACHE_TAGS:-false}) {\n unset resp.http.Cache-Tags;\n }\n\n unset resp.http.X-Generator;\n unset resp.http.Server;\n # Inject information about grace\n if (req.http.grace) {\n set resp.http.X-Varnish-Grace = req.http.grace;\n }\n set resp.http.X-LAGOON = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}>\" + resp.http.X-LAGOON;\n return (deliver);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n if (req.http.X-Forwarded-Proto) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n if (req.http.HTTPS) {\n hash_data(req.http.HTTPS);\n }\n return (lookup);\n}\n\nsub vcl_synth {\n if (resp.status == 701) {\n set resp.status = 401;\n set resp.http.Content-Type = \"text\/plain; charset=utf-8\";\n synthetic({\"XMLRPC Interface is blocked due to SA-CORE-2014-004 - mail support@amazee.io if you need it.\"});\n return (deliver);\n }\n if (resp.status == 700) {\n # Set a status the client will understand\n set resp.status = 200;\n # Create our synthetic response\n synthetic(\"\");\n return(deliver);\n}\n return (deliver);\n}\n\nsub vcl_backend_error {\n # Restart the request, when we have a backend server error, to try another backend.\n # Restart max twice.\n if (bereq.retries < 2) {\n return(retry);\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<head>\n <title>Server Error<\/title>\n <style type=\"text\/css\">\n body {\n font-family: helvetica, arial, sans-serif;\n }\n img {\n margin-top: 50px;\n }\n p {\n width: 6 00px;\n margin-top: 10px\n }\n div {\n background: #ccc;\n width: 600px;\n margin: auto;\n padding: 50px;\n }\n span {\n color: #ccc\n }\n <\/style>\n<\/head>\n<body>\n <div>\n <h1>We are sorry...<\/h1>\n <p>We encountered a server-side error. This means that the problem is not with your computer or Internet connection, but rather with the website's server.<\/p>\n <p>We are currently working on solving this problem and apologise for the inconvenience.<\/p>\n <span>\n <strong>Technical Information<\/strong><br \/>\n Error \"} + beresp.status + \" \" + beresp.reason + {\"<br \/>\n XID: \"} + bereq.xid + {\"<br \/>\n <\/span>\n <\/div>\n<\/body>\n<\/html>\n\n\"} );\n return (deliver);\n}\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"59b043122416ed3d3f613e72327e14ab1927648d","subject":"Fix param stripping for reset-password route (#2801)","message":"Fix param stripping for reset-password route (#2801)\n\n","repos":"dstufft\/warehouse,dstufft\/warehouse,pypa\/warehouse,pypa\/warehouse,dstufft\/warehouse,dstufft\/warehouse,pypa\/warehouse,pypa\/warehouse","old_file":"vcl\/main.vcl","new_file":"vcl\/main.vcl","new_contents":"# Note: It is VERY important to ensure that any changes to VCL will work\n# properly with both the current version of ``master`` and the version in\n# the pull request that adds any new changes. This is because the\n# configuration will be applied automatically as part of the deployment\n# process, but while the previous version of the code is still up and\n# running. Thus backwards incompatible changes must be broken up over\n# multiple pull requests in order to phase them in over multiple deploys.\n\nsub vcl_recv {\n\n # I'm not 100% sure on what this is exactly for, it was taken from the\n # Fastly documentation, however, what I *believe* it does is just ensure\n # that we don't serve a stale copy of the page from the shield node when\n # an edge node is requesting content.\n if (req.http.Fastly-FF) {\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Some (Older) clients will send a hash fragment as part of the URL even\n # though that is a local only modification. This breaks this badly for the\n # files in S3, and in general it's just not needed.\n set req.url = regsub(req.url, \"#.*$\", \"\");\n\n # Fastly does some normalization of the Accept-Encoding header so that it\n # reduces the number of cached copies (when served with the common,\n # Vary: Accept-Encoding) that are cached for any one URL. This makes a lot\n # of sense, except for the fact that we want to enable brotli compression\n # for our static files. Thus we need to work around the normalized encoding\n # in a way that still minimizes cached copies, but which will allow our\n # static files to be served using brotli.\n if (req.url ~ \"^\/static\/\" && req.http.Fastly-Orig-Accept-Encoding) {\n if (req.http.User-Agent ~ \"MSIE 6\") {\n # For that 0.3% of stubborn users out there\n unset req.http.Accept-Encoding;\n } elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"br\") {\n set req.http.Accept-Encoding = \"br\";\n } elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n\n # Most of the URLs in Warehouse do not support or require any sort of query\n # parameter. If we strip these at the edge then we'll increase our cache\n # efficiency when they won't otherwise change the output of the pages.\n #\n # This will match any URL except those that start with:\n #\n # * \/admin\/\n # * \/search\/\n # * \/account\/login\/\n # * \/account\/logout\/\n # * \/account\/register\/\n # * \/pypi\n if (req.url.path !~ \"^\/(admin\/|search(\/|$)|account\/(login|logout|register|reset-password)\/|pypi)\") {\n set req.url = req.url.path;\n }\n\n # Sort all of our query parameters, this will ensure that the same query\n # parameters in a different order will end up being represented as the same\n # thing, reducing cache misses due to ordering differences.\n set req.url = boltsort.sort(req.url);\n\n # We have a number of items that we'll pass back to the origin.\n # Set a header to tell the backend if we're using https or http.\n if (req.http.Fastly-SSL) {\n set req.http.Warehouse-Proto = \"https\";\n } else {\n set req.http.Warehouse-Proto = \"http\";\n }\n # Pass the client IP address back to the backend.\n if (req.http.Fastly-Client-IP) {\n set req.http.Warehouse-IP = req.http.Fastly-Client-IP;\n }\n # Pass the real host value back to the backend.\n if (req.http.Host) {\n set req.http.Warehouse-Host = req.http.host;\n }\n\n # Currently Fastly does not provide a way to access response headers when\n # the response is a 304 response. This is because the RFC states that only\n # a limit set of headers should be sent with a 304 response, and the rest\n # are SHOULD NOT. Since this stripping happens *prior* to vcl_deliver being\n # ran, that breaks our ability to log on 304 responses. Ideally at some\n # point Fastly offers us a way to access the \"real\" response headers even\n # for a 304 response, but for now, we are going to remove the headers that\n # allow a conditional response to be made. If at some point Fastly does\n # allow this, then we can delete this code.\n if (!req.http.Fastly-FF\n && std.tolower(req.http.Warehouse-Host) == \"files.pythonhosted.org\"\n && req.url.path ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\") {\n unset req.http.If-None-Match;\n unset req.http.If-Modified-Since;\n }\n\n\n#FASTLY recv\n\n\n # We want to Force SSL for the WebUI by redirecting to the HTTPS version of\n # the page, however for API calls we want to return an error code directing\n # people to instead use HTTPS.\n if (!req.http.Fastly-SSL) {\n\n # The \/simple\/ and \/packages\/ API.\n if (req.url ~ \"^\/(simple|packages)\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy JSON API.\n if (req.url ~ \"^\/pypi\/.+\/json$\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy ?:action= API.\n if (req.url ~ \"^\/pypi.*(\\?|&)=:action\") {\n error 803 \"SSL is required\";\n }\n\n # If we're on the \/pypi page and we've received something other than a\n # GET or HEAD request, then we have no way to determine if a particular\n # request is an API call or not because it'll be in the request body\n # and that isn't available to us here. So in those cases, we won't\n # do a redirect.\n if (req.url ~ \"^\/pypi\") {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n error 801 \"Force SSL\";\n }\n }\n else {\n # This isn't a \/pypi URL so we'll just unconditionally redirect to\n # HTTPS.\n error 801 \"Force SSL\";\n }\n }\n\n # Redirect pypi.io, www.pypi.io, and warehouse.python.org to pypi.org, this\n # is purposely done *after* the HTTPS checks.\n if (std.tolower(req.http.host) ~ \"^(www.pypi.org|(www.)?pypi.io|warehouse.python.org)$\") {\n set req.http.Location = \"https:\/\/pypi.org\" req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n # Redirect warehouse-staging.python.org to test.pypi.io.\n if (std.tolower(req.http.host) ~ \"^(test.pypi.io|warehouse-staging.python.org)$\") {\n set req.http.Location = \"https:\/\/test.pypi.org\" req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n\n # Requests to \/packages\/ get dispatched to Amazon instead of to our typical\n # Origin. This requires a a bit of setup to make it work.\n if (req.http.host ~ \"^(test-)?files.pythonhosted.org$\"\n && req.url ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\") {\n # Setup our environment to better match what S3 expects\/needs\n set req.http.Host = req.http.AWS-Bucket-Name \".s3.amazonaws.com\";\n set req.http.Date = now;\n set req.url = regsuball(req.url, \"\\+\", urlencode(\"+\"));\n\n # Compute the Authorization header that S3 requires to be able to\n # access the files stored there.\n set req.http.Authorization = \"AWS \" req.http.AWS-Access-Key-ID \":\" digest.hmac_sha1_base64(req.http.AWS-Secret-Access-Key, \"GET\" LF LF LF req.http.Date LF \"\/\" req.http.AWS-Bucket-Name req.url.path);\n\n # We don't want to send our Warehouse-Token to S3, so we'll go ahead\n # and remove it.\n unset req.http.Warehouse-Token;\n }\n\n # We no longer need any of these variables, which would exist only to\n # shuffle configuration from the Fastly UI into our VCL.\n unset req.http.AWS-Access-Key-ID;\n unset req.http.AWS-Secret-Access-Key;\n unset req.http.AWS-Bucket-Name;\n\n # On a POST, we want to skip the shielding and hit backends directly.\n if (req.request == \"POST\") {\n set req.backend = F_Heroku;\n }\n\n # Do not bother to attempt to run the caching mechanisms for methods that\n # are not generally safe to cache.\n if (req.request != \"HEAD\" &&\n req.request != \"GET\" &&\n req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n # We don't ever want to cache our health URL. Outside systems should be\n # able to use it to reach past Fastly and get an end to end health check.\n if (req.url == \"\/_health\/\") {\n return(pass);\n }\n\n # We never want to cache our admin URLs, while this should be \"safe\" due to\n # the architecure of Warehouse, it'll just be easier to debug issues if\n # these always are uncached.\n if (req.url ~ \"^\/admin\/\") {\n return(pass);\n }\n\n # Finally, return the default lookup action.\n return(lookup);\n}\n\n\nsub vcl_fetch {\n\n # These are newer kinds of redirects which should be able to be cached by\n # default, even though Fastly doesn't currently have them in their default\n # list of cacheable status codes.\n if (http_status_matches(beresp.status, \"303,307,308\")) {\n set beresp.cacheable = true;\n }\n\n # For any 5xx status code we want to see if a stale object exists for it,\n # if so we'll go ahead and serve it.\n if (beresp.status >= 500 && beresp.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n\n#FASTLY fetch\n\n\n # Trigger a \"SSL is required\" error if the backend has indicated to do so.\n if (beresp.http.X-Fastly-Error == \"803\") {\n error 803 \"SSL is required\";\n }\n\n # If we've gotten a 502 or a 503 from the backend, we'll go ahead and retry\n # the request.\n if ((beresp.status == 502 || beresp.status == 503) &&\n req.restarts < 1 &&\n (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n # If we've restarted, then we'll record the number of restarts.\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n # If there is a Set-Cookie header, we'll ensure that we do not cache the\n # response.\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n # If the response has the private Cache-Control directive then we won't\n # cache it.\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # If we've gotten an error after the restarts we'll deliver the response\n # with a very short cache time.\n if (http_status_matches(beresp.status, \"500,502,503\")) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n # Apply a default TTL if there isn't a max-age or s-maxage.\n if (beresp.http.Expires ||\n beresp.http.Surrogate-Control ~ \"max-age\" ||\n beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # Keep the ttl here\n }\n else {\n # Apply the default ttl\n set beresp.ttl = 60s;\n }\n\n # Actually deliver the fetched response.\n return(deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n # If the object we have isn't cacheable, then just serve it directly\n # without going through any of the caching mechanisms.\n if (!obj.cacheable) {\n return(pass);\n }\n\n return(deliver);\n}\n\n\nsub vcl_deliver {\n # If this is an error and we have a stale response available, restart so\n # that we can pick it up and serve it.\n if (resp.status >= 500 && resp.status < 600) {\n if (stale.exists) {\n restart;\n }\n }\n\n#FASTLY deliver\n\n # Unset headers that we don't need\/want to send on to the client because\n # they are not generally useful.\n unset resp.http.Via;\n\n # Set our standard security headers, we do this in VCL rather than in\n # Warehouse itself so that we always get these headers, regardless of the\n # origin server being used.\n set resp.http.Strict-Transport-Security = \"max-age=31536000; includeSubDomains; preload\";\n set resp.http.X-Frame-Options = \"deny\";\n set resp.http.X-XSS-Protection = \"1; mode=block\";\n set resp.http.X-Content-Type-Options = \"nosniff\";\n set resp.http.X-Permitted-Cross-Domain-Policies = \"none\";\n\n # Currently Fastly does not provide a way to access response headers when\n # the response is a 304 response. This is because the RFC states that only\n # a limit set of headers should be sent with a 304 response, and the rest\n # are SHOULD NOT. Since this stripping happens *prior* to vcl_deliver being\n # ran, that breaks our ability to log on 304 responses. Ideally at some\n # point Fastly offers us a way to access the \"real\" response headers even\n # for a 304 response, but for now, we are going to remove the headers that\n # allow a conditional response to be made. If at some point Fastly does\n # allow this, then we can delete this code, and also allow a 304 response\n # in the http_status_matches() check further down.\n if (!req.http.Fastly-FF\n && std.tolower(req.http.Warehouse-Host) == \"files.pythonhosted.org\"\n && req.url.path ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\") {\n unset resp.http.ETag;\n unset resp.http.Last-Modified;\n }\n\n # If we're not executing a shielding request, and the URL is one of our file\n # URLs, and it's a GET request, and the response is either a 200 or a 304\n # then we want to log an event stating that a download has taken place.\n if (!req.http.Fastly-FF\n && std.tolower(req.http.Warehouse-Host) == \"files.pythonhosted.org\"\n && req.url.path ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\"\n && req.request == \"GET\"\n && http_status_matches(resp.status, \"200\")) {\n log {\"syslog \"} req.service_id {\" linehaul :: \"} \"2@\" now \"|\" geoip.country_code \"|\" req.url.path \"|\" tls.client.protocol \"|\" tls.client.cipher \"|\" resp.http.x-amz-meta-project \"|\" resp.http.x-amz-meta-version \"|\" resp.http.x-amz-meta-package-type \"|\" req.http.user-agent;\n log {\"syslog \"} req.service_id {\" downloads :: \"} \"2@\" now \"|\" geoip.country_code \"|\" req.url.path \"|\" tls.client.protocol \"|\" tls.client.cipher \"|\" resp.http.x-amz-meta-project \"|\" resp.http.x-amz-meta-version \"|\" resp.http.x-amz-meta-package-type \"|\" req.http.user-agent;\n }\n\n # Unset a few headers set by Amazon that we don't really have a need\/desire\n # to send to clients.\n unset resp.http.x-amz-replication-status;\n unset resp.http.x-amz-meta-python-version;\n unset resp.http.x-amz-meta-version;\n unset resp.http.x-amz-meta-package-type;\n unset resp.http.x-amz-meta-project;\n\n\n return(deliver);\n}\n\n\nsub vcl_error {\n#FASTLY error\n\n # If we have a 5xx error and there is a stale object available, then we\n # will deliver that stale object.\n if (obj.status >= 500 && obj.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n if (obj.status == 803) {\n set obj.status = 403;\n set obj.response = \"SSL is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic {\"SSL is required.\"};\n return (deliver);\n } else if (obj.status == 750) {\n set obj.status = 301;\n set obj.http.Location = req.http.Location;\n set obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n synthetic {\"<html><head><title>301 Moved Permanently<\/title><\/head><body><center><h1>301 Moved Permanently<\/h1><\/center><\/body><\/html>\"};\n return(deliver);\n }\n\n}\n","old_contents":"# Note: It is VERY important to ensure that any changes to VCL will work\n# properly with both the current version of ``master`` and the version in\n# the pull request that adds any new changes. This is because the\n# configuration will be applied automatically as part of the deployment\n# process, but while the previous version of the code is still up and\n# running. Thus backwards incompatible changes must be broken up over\n# multiple pull requests in order to phase them in over multiple deploys.\n\nsub vcl_recv {\n\n # I'm not 100% sure on what this is exactly for, it was taken from the\n # Fastly documentation, however, what I *believe* it does is just ensure\n # that we don't serve a stale copy of the page from the shield node when\n # an edge node is requesting content.\n if (req.http.Fastly-FF) {\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Some (Older) clients will send a hash fragment as part of the URL even\n # though that is a local only modification. This breaks this badly for the\n # files in S3, and in general it's just not needed.\n set req.url = regsub(req.url, \"#.*$\", \"\");\n\n # Fastly does some normalization of the Accept-Encoding header so that it\n # reduces the number of cached copies (when served with the common,\n # Vary: Accept-Encoding) that are cached for any one URL. This makes a lot\n # of sense, except for the fact that we want to enable brotli compression\n # for our static files. Thus we need to work around the normalized encoding\n # in a way that still minimizes cached copies, but which will allow our\n # static files to be served using brotli.\n if (req.url ~ \"^\/static\/\" && req.http.Fastly-Orig-Accept-Encoding) {\n if (req.http.User-Agent ~ \"MSIE 6\") {\n # For that 0.3% of stubborn users out there\n unset req.http.Accept-Encoding;\n } elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"br\") {\n set req.http.Accept-Encoding = \"br\";\n } elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n\n # Most of the URLs in Warehouse do not support or require any sort of query\n # parameter. If we strip these at the edge then we'll increase our cache\n # efficiency when they won't otherwise change the output of the pages.\n #\n # This will match any URL except those that start with:\n #\n # * \/admin\/\n # * \/search\/\n # * \/account\/login\/\n # * \/account\/logout\/\n # * \/account\/register\/\n # * \/pypi\n if (req.url.path !~ \"^\/(admin\/|search(\/|$)|account\/(login|logout|register)\/|pypi)\") {\n set req.url = req.url.path;\n }\n\n # Sort all of our query parameters, this will ensure that the same query\n # parameters in a different order will end up being represented as the same\n # thing, reducing cache misses due to ordering differences.\n set req.url = boltsort.sort(req.url);\n\n # We have a number of items that we'll pass back to the origin.\n # Set a header to tell the backend if we're using https or http.\n if (req.http.Fastly-SSL) {\n set req.http.Warehouse-Proto = \"https\";\n } else {\n set req.http.Warehouse-Proto = \"http\";\n }\n # Pass the client IP address back to the backend.\n if (req.http.Fastly-Client-IP) {\n set req.http.Warehouse-IP = req.http.Fastly-Client-IP;\n }\n # Pass the real host value back to the backend.\n if (req.http.Host) {\n set req.http.Warehouse-Host = req.http.host;\n }\n\n # Currently Fastly does not provide a way to access response headers when\n # the response is a 304 response. This is because the RFC states that only\n # a limit set of headers should be sent with a 304 response, and the rest\n # are SHOULD NOT. Since this stripping happens *prior* to vcl_deliver being\n # ran, that breaks our ability to log on 304 responses. Ideally at some\n # point Fastly offers us a way to access the \"real\" response headers even\n # for a 304 response, but for now, we are going to remove the headers that\n # allow a conditional response to be made. If at some point Fastly does\n # allow this, then we can delete this code.\n if (!req.http.Fastly-FF\n && std.tolower(req.http.Warehouse-Host) == \"files.pythonhosted.org\"\n && req.url.path ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\") {\n unset req.http.If-None-Match;\n unset req.http.If-Modified-Since;\n }\n\n\n#FASTLY recv\n\n\n # We want to Force SSL for the WebUI by redirecting to the HTTPS version of\n # the page, however for API calls we want to return an error code directing\n # people to instead use HTTPS.\n if (!req.http.Fastly-SSL) {\n\n # The \/simple\/ and \/packages\/ API.\n if (req.url ~ \"^\/(simple|packages)\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy JSON API.\n if (req.url ~ \"^\/pypi\/.+\/json$\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy ?:action= API.\n if (req.url ~ \"^\/pypi.*(\\?|&)=:action\") {\n error 803 \"SSL is required\";\n }\n\n # If we're on the \/pypi page and we've received something other than a\n # GET or HEAD request, then we have no way to determine if a particular\n # request is an API call or not because it'll be in the request body\n # and that isn't available to us here. So in those cases, we won't\n # do a redirect.\n if (req.url ~ \"^\/pypi\") {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n error 801 \"Force SSL\";\n }\n }\n else {\n # This isn't a \/pypi URL so we'll just unconditionally redirect to\n # HTTPS.\n error 801 \"Force SSL\";\n }\n }\n\n # Redirect pypi.io, www.pypi.io, and warehouse.python.org to pypi.org, this\n # is purposely done *after* the HTTPS checks.\n if (std.tolower(req.http.host) ~ \"^(www.pypi.org|(www.)?pypi.io|warehouse.python.org)$\") {\n set req.http.Location = \"https:\/\/pypi.org\" req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n # Redirect warehouse-staging.python.org to test.pypi.io.\n if (std.tolower(req.http.host) ~ \"^(test.pypi.io|warehouse-staging.python.org)$\") {\n set req.http.Location = \"https:\/\/test.pypi.org\" req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n\n # Requests to \/packages\/ get dispatched to Amazon instead of to our typical\n # Origin. This requires a a bit of setup to make it work.\n if (req.http.host ~ \"^(test-)?files.pythonhosted.org$\"\n && req.url ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\") {\n # Setup our environment to better match what S3 expects\/needs\n set req.http.Host = req.http.AWS-Bucket-Name \".s3.amazonaws.com\";\n set req.http.Date = now;\n set req.url = regsuball(req.url, \"\\+\", urlencode(\"+\"));\n\n # Compute the Authorization header that S3 requires to be able to\n # access the files stored there.\n set req.http.Authorization = \"AWS \" req.http.AWS-Access-Key-ID \":\" digest.hmac_sha1_base64(req.http.AWS-Secret-Access-Key, \"GET\" LF LF LF req.http.Date LF \"\/\" req.http.AWS-Bucket-Name req.url.path);\n\n # We don't want to send our Warehouse-Token to S3, so we'll go ahead\n # and remove it.\n unset req.http.Warehouse-Token;\n }\n\n # We no longer need any of these variables, which would exist only to\n # shuffle configuration from the Fastly UI into our VCL.\n unset req.http.AWS-Access-Key-ID;\n unset req.http.AWS-Secret-Access-Key;\n unset req.http.AWS-Bucket-Name;\n\n # On a POST, we want to skip the shielding and hit backends directly.\n if (req.request == \"POST\") {\n set req.backend = F_Heroku;\n }\n\n # Do not bother to attempt to run the caching mechanisms for methods that\n # are not generally safe to cache.\n if (req.request != \"HEAD\" &&\n req.request != \"GET\" &&\n req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n # We don't ever want to cache our health URL. Outside systems should be\n # able to use it to reach past Fastly and get an end to end health check.\n if (req.url == \"\/_health\/\") {\n return(pass);\n }\n\n # We never want to cache our admin URLs, while this should be \"safe\" due to\n # the architecure of Warehouse, it'll just be easier to debug issues if\n # these always are uncached.\n if (req.url ~ \"^\/admin\/\") {\n return(pass);\n }\n\n # Finally, return the default lookup action.\n return(lookup);\n}\n\n\nsub vcl_fetch {\n\n # These are newer kinds of redirects which should be able to be cached by\n # default, even though Fastly doesn't currently have them in their default\n # list of cacheable status codes.\n if (http_status_matches(beresp.status, \"303,307,308\")) {\n set beresp.cacheable = true;\n }\n\n # For any 5xx status code we want to see if a stale object exists for it,\n # if so we'll go ahead and serve it.\n if (beresp.status >= 500 && beresp.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n\n#FASTLY fetch\n\n\n # Trigger a \"SSL is required\" error if the backend has indicated to do so.\n if (beresp.http.X-Fastly-Error == \"803\") {\n error 803 \"SSL is required\";\n }\n\n # If we've gotten a 502 or a 503 from the backend, we'll go ahead and retry\n # the request.\n if ((beresp.status == 502 || beresp.status == 503) &&\n req.restarts < 1 &&\n (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n # If we've restarted, then we'll record the number of restarts.\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n # If there is a Set-Cookie header, we'll ensure that we do not cache the\n # response.\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n # If the response has the private Cache-Control directive then we won't\n # cache it.\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # If we've gotten an error after the restarts we'll deliver the response\n # with a very short cache time.\n if (http_status_matches(beresp.status, \"500,502,503\")) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n # Apply a default TTL if there isn't a max-age or s-maxage.\n if (beresp.http.Expires ||\n beresp.http.Surrogate-Control ~ \"max-age\" ||\n beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # Keep the ttl here\n }\n else {\n # Apply the default ttl\n set beresp.ttl = 60s;\n }\n\n # Actually deliver the fetched response.\n return(deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n # If the object we have isn't cacheable, then just serve it directly\n # without going through any of the caching mechanisms.\n if (!obj.cacheable) {\n return(pass);\n }\n\n return(deliver);\n}\n\n\nsub vcl_deliver {\n # If this is an error and we have a stale response available, restart so\n # that we can pick it up and serve it.\n if (resp.status >= 500 && resp.status < 600) {\n if (stale.exists) {\n restart;\n }\n }\n\n#FASTLY deliver\n\n # Unset headers that we don't need\/want to send on to the client because\n # they are not generally useful.\n unset resp.http.Via;\n\n # Set our standard security headers, we do this in VCL rather than in\n # Warehouse itself so that we always get these headers, regardless of the\n # origin server being used.\n set resp.http.Strict-Transport-Security = \"max-age=31536000; includeSubDomains; preload\";\n set resp.http.X-Frame-Options = \"deny\";\n set resp.http.X-XSS-Protection = \"1; mode=block\";\n set resp.http.X-Content-Type-Options = \"nosniff\";\n set resp.http.X-Permitted-Cross-Domain-Policies = \"none\";\n\n # Currently Fastly does not provide a way to access response headers when\n # the response is a 304 response. This is because the RFC states that only\n # a limit set of headers should be sent with a 304 response, and the rest\n # are SHOULD NOT. Since this stripping happens *prior* to vcl_deliver being\n # ran, that breaks our ability to log on 304 responses. Ideally at some\n # point Fastly offers us a way to access the \"real\" response headers even\n # for a 304 response, but for now, we are going to remove the headers that\n # allow a conditional response to be made. If at some point Fastly does\n # allow this, then we can delete this code, and also allow a 304 response\n # in the http_status_matches() check further down.\n if (!req.http.Fastly-FF\n && std.tolower(req.http.Warehouse-Host) == \"files.pythonhosted.org\"\n && req.url.path ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\") {\n unset resp.http.ETag;\n unset resp.http.Last-Modified;\n }\n\n # If we're not executing a shielding request, and the URL is one of our file\n # URLs, and it's a GET request, and the response is either a 200 or a 304\n # then we want to log an event stating that a download has taken place.\n if (!req.http.Fastly-FF\n && std.tolower(req.http.Warehouse-Host) == \"files.pythonhosted.org\"\n && req.url.path ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\"\n && req.request == \"GET\"\n && http_status_matches(resp.status, \"200\")) {\n log {\"syslog \"} req.service_id {\" linehaul :: \"} \"2@\" now \"|\" geoip.country_code \"|\" req.url.path \"|\" tls.client.protocol \"|\" tls.client.cipher \"|\" resp.http.x-amz-meta-project \"|\" resp.http.x-amz-meta-version \"|\" resp.http.x-amz-meta-package-type \"|\" req.http.user-agent;\n log {\"syslog \"} req.service_id {\" downloads :: \"} \"2@\" now \"|\" geoip.country_code \"|\" req.url.path \"|\" tls.client.protocol \"|\" tls.client.cipher \"|\" resp.http.x-amz-meta-project \"|\" resp.http.x-amz-meta-version \"|\" resp.http.x-amz-meta-package-type \"|\" req.http.user-agent;\n }\n\n # Unset a few headers set by Amazon that we don't really have a need\/desire\n # to send to clients.\n unset resp.http.x-amz-replication-status;\n unset resp.http.x-amz-meta-python-version;\n unset resp.http.x-amz-meta-version;\n unset resp.http.x-amz-meta-package-type;\n unset resp.http.x-amz-meta-project;\n\n\n return(deliver);\n}\n\n\nsub vcl_error {\n#FASTLY error\n\n # If we have a 5xx error and there is a stale object available, then we\n # will deliver that stale object.\n if (obj.status >= 500 && obj.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n if (obj.status == 803) {\n set obj.status = 403;\n set obj.response = \"SSL is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic {\"SSL is required.\"};\n return (deliver);\n } else if (obj.status == 750) {\n set obj.status = 301;\n set obj.http.Location = req.http.Location;\n set obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n synthetic {\"<html><head><title>301 Moved Permanently<\/title><\/head><body><center><h1>301 Moved Permanently<\/h1><\/center><\/body><\/html>\"};\n return(deliver);\n }\n\n}\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"fd3ed3dc388f527598848d4d5eb95e4da6eb5e7f","subject":"Updated Varnish example config with rules to stop login.out from being cached","message":"Updated Varnish example config with rules to stop login.out from being cached\n","repos":"AstunTechnology\/NRW_FishMapMon,AstunTechnology\/NRW_FishMapMon,AstunTechnology\/NRW_FishMapMon,AstunTechnology\/NRW_FishMapMon","old_file":"config\/varnish\/default.vcl","new_file":"config\/varnish\/default.vcl","new_contents":"# This is a basic VCL configuration file for varnish. See the vcl(7)\n# man page for details on VCL syntax and semantics.\n# \n# Default backend definition. Set this to point to your content\n# server.\n# \nbackend cy {\n .host = \"cy.blah\";\n .port = \"8001\";\n}\n\nbackend en {\n .host = \"en.blah\";\n .port = \"8002\";\n}\n\n\n# \n# Below is a commented-out copy of the default VCL logic. If you\n# redefine any of these subroutines, the built-in logic will be\n# appended to your code.\nsub vcl_recv {\n\tif (req.http.host ~ \"(?i)^(www.)?cy.blah\") {\n\t\tset req.http.host = \"cy.blah\";\n\t\tset req.backend = cy;\n\t}\n\telsif (req.http.host ~ \"(?i)^(www.)?en.blah\") {\n\t\tset req.http.host = \"en.blah\";\n\t\tset req.backend = en;\n\t}\n\n\tif ( req.url ~ \"^\/wms\\?map=fishmap\" ) {\n\t\treturn (pass);\n\t}\n\n\tif ( req.url ~ \"^\/static\/\" ) {\n\t\treturn (lookup);\n\t}\n\tif ( req.url ~ \"^\/wms\" ) {\n\t\treturn (lookup);\n\t}\n# if (req.restarts == 0) {\n# \tif (req.http.x-forwarded-for) {\n# \t set req.http.X-Forwarded-For =\n# \t\treq.http.X-Forwarded-For + \", \" + client.ip;\n# \t} else {\n# \t set req.http.X-Forwarded-For = client.ip;\n# \t}\n# }\n# if (req.request != \"GET\" &&\n# req.request != \"HEAD\" &&\n# req.request != \"PUT\" &&\n# req.request != \"POST\" &&\n# req.request != \"TRACE\" &&\n# req.request != \"OPTIONS\" &&\n# req.request != \"DELETE\") {\n# \/* Non-RFC2616 or CONNECT which is weird. *\/\n# return (pipe);\n# }\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization || req.http.Cookie) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n return (lookup);\n}\n# \n# sub vcl_pipe {\n# # Note that only the first request to the backend will have\n# # X-Forwarded-For set. If you use X-Forwarded-For and want to\n# # have it set for all requests, make sure to have:\n# # set bereq.http.connection = \"close\";\n# # here. It is not set by default as it might break some broken web\n# # applications, like IIS with NTLM authentication.\n# return (pipe);\n# }\n# \n# sub vcl_pass {\n# return (pass);\n# }\n# \n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (hash);\n# }\n# \n# sub vcl_hit {\n# return (deliver);\n# }\n# \n# sub vcl_miss {\n# return (fetch);\n# }\n# \nsub vcl_fetch {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Vary == \"*\") {\n# \t\t\/*\n# \t\t * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# \t\t *\/\n# \t\tset beresp.ttl = 120 s;\n# \t\treturn (hit_for_pass);\n# }\n\tif ( req.url ~ \"^\/wms\" ) {\n \t\tunset beresp.http.set-cookie;\n\t\tunset beresp.http.expires;\n \t\tset beresp.ttl = 1w;\n\t set beresp.http.Cache-Control = \"max-age=1900\";\n\t}\t\t\n return (deliver);\n}\n# \n# sub vcl_deliver {\n# return (deliver);\n# }\n# \n# sub vcl_error {\n# set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n# set obj.http.Retry-After = \"5\";\n# synthetic {\"\n# <?xml version=\"1.0\" encoding=\"utf-8\"?>\n# <!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n# \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n# <html>\n# <head>\n# <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n# <\/head>\n# <body>\n# <h1>Error \"} + obj.status + \" \" + obj.response + {\"<\/h1>\n# <p>\"} + obj.response + {\"<\/p>\n# <h3>Guru Meditation:<\/h3>\n# <p>XID: \"} + req.xid + {\"<\/p>\n# <hr>\n# <p>Varnish cache server<\/p>\n# <\/body>\n# <\/html>\n# \"};\n# return (deliver);\n# }\n# \n# sub vcl_init {\n# \treturn (ok);\n# }\n# \n# sub vcl_fini {\n# \treturn (ok);\n# }\n","old_contents":"# This is a basic VCL configuration file for varnish. See the vcl(7)\n# man page for details on VCL syntax and semantics.\n# \n# Default backend definition. Set this to point to your content\n# server.\n# \nbackend cy {\n .host = \"cy.blah\";\n .port = \"8001\";\n}\n\nbackend en {\n .host = \"en.blah\";\n .port = \"8002\";\n}\n\n\n# \n# Below is a commented-out copy of the default VCL logic. If you\n# redefine any of these subroutines, the built-in logic will be\n# appended to your code.\nsub vcl_recv {\n# if (req.restarts == 0) {\n# \tif (req.http.x-forwarded-for) {\n# \t set req.http.X-Forwarded-For =\n# \t\treq.http.X-Forwarded-For + \", \" + client.ip;\n# \t} else {\n# \t set req.http.X-Forwarded-For = client.ip;\n# \t}\n# }\n# if (req.request != \"GET\" &&\n# req.request != \"HEAD\" &&\n# req.request != \"PUT\" &&\n# req.request != \"POST\" &&\n# req.request != \"TRACE\" &&\n# req.request != \"OPTIONS\" &&\n# req.request != \"DELETE\") {\n# \/* Non-RFC2616 or CONNECT which is weird. *\/\n# return (pipe);\n# }\n# if (req.request != \"GET\" && req.request != \"HEAD\") {\n# \/* We only deal with GET and HEAD by default *\/\n# return (pass);\n# }\n# if (req.http.Authorization || req.http.Cookie) {\n# \/* Not cacheable by default *\/\n# return (pass);\n# }\n\tif (req.http.host ~ \"(?i)^(www.)?cy.blah\") {\n\t\tset req.http.host = \"cy.blah\";\n\t\tset req.backend = cy;\n\t}\n\telsif (req.http.host ~ \"(?i)^(www.)?en.blah\") {\n\t\tset req.http.host = \"en.blah\";\n\t\tset req.backend = en;\n\t}\n\n\tif ( req.url ~ \"^\/wms\\?map=fishmap\" ) {\n\t\treturn (pass);\n\t}\n\n\tif ( req.url ~ \"^\/static\/\" ) {\n\t\treturn (lookup);\n\t}\n\tif ( req.url ~ \"^\/wms\" ) {\n\t\treturn (lookup);\n\t}\n return (lookup);\n}\n# \n# sub vcl_pipe {\n# # Note that only the first request to the backend will have\n# # X-Forwarded-For set. If you use X-Forwarded-For and want to\n# # have it set for all requests, make sure to have:\n# # set bereq.http.connection = \"close\";\n# # here. It is not set by default as it might break some broken web\n# # applications, like IIS with NTLM authentication.\n# return (pipe);\n# }\n# \n# sub vcl_pass {\n# return (pass);\n# }\n# \n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (hash);\n# }\n# \n# sub vcl_hit {\n# return (deliver);\n# }\n# \n# sub vcl_miss {\n# return (fetch);\n# }\n# \nsub vcl_fetch {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Vary == \"*\") {\n# \t\t\/*\n# \t\t * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# \t\t *\/\n# \t\tset beresp.ttl = 120 s;\n# \t\treturn (hit_for_pass);\n# }\n\tif ( req.url ~ \"^\/wms\" ) {\n \t\tunset beresp.http.set-cookie;\n\t\tunset beresp.http.expires;\n \t\tset beresp.ttl = 1w;\n\t set beresp.http.Cache-Control = \"max-age=1900\";\n\t}\t\t\n return (deliver);\n}\n# \n# sub vcl_deliver {\n# return (deliver);\n# }\n# \n# sub vcl_error {\n# set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n# set obj.http.Retry-After = \"5\";\n# synthetic {\"\n# <?xml version=\"1.0\" encoding=\"utf-8\"?>\n# <!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n# \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n# <html>\n# <head>\n# <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n# <\/head>\n# <body>\n# <h1>Error \"} + obj.status + \" \" + obj.response + {\"<\/h1>\n# <p>\"} + obj.response + {\"<\/p>\n# <h3>Guru Meditation:<\/h3>\n# <p>XID: \"} + req.xid + {\"<\/p>\n# <hr>\n# <p>Varnish cache server<\/p>\n# <\/body>\n# <\/html>\n# \"};\n# return (deliver);\n# }\n# \n# sub vcl_init {\n# \treturn (ok);\n# }\n# \n# sub vcl_fini {\n# \treturn (ok);\n# }\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"95c37267d85c9fd58d5240fb1928c78202bc6379","subject":"Updating varnish config to reject large requests before hitting IDM","message":"Updating varnish config to reject large requests before hitting IDM\n","repos":"alexanderlaw\/sqlfiddle2,jakefeasel\/sqlfiddle2,alexanderlaw\/sqlfiddle2,alexanderlaw\/sqlfiddle2,jakefeasel\/sqlfiddle2,jakefeasel\/sqlfiddle2,alexanderlaw\/sqlfiddle2,alexanderlaw\/sqlfiddle2,jakefeasel\/sqlfiddle2","old_file":"src\/main\/resources\/varnish\/default.vcl","new_file":"src\/main\/resources\/varnish\/default.vcl","new_contents":"backend default {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\n\nsub vcl_recv {\n\n if (req.request == \"POST\" && !req.http.Content-Length) {\n error 411 \"Content-Length required\";\n }\n\n # Require that the content be less than 8000 characters\n if (req.request == \"POST\" && !req.http.Content-Length ~ \"^[1-7]?[0-9]{1,3}$\") {\n error 413 \"Request content too large\";\n }\n\n if (! (req.url ~ \"^\/openidm\/\") ) {\n set req.url = regsub(req.url, \"^\/\", \"\/sqlfiddle\/\");\n }\n\n if ( req.url == \"\/sqlfiddle\/\") {\n set req.url = \"\/sqlfiddle\/index.html\"; \n }\n\n if (req.request == \"GET\" && req.url != \"\/openidm\/info\/login\") {\n unset req.http.cookie;\n }\n}\n\nsub vcl_fetch {\n if (req.request == \"GET\" && req.url != \"\/openidm\/info\/login\") {\n set beresp.ttl = 60m;\n }\n if (beresp.status != 200) {\n set beresp.ttl = 0s;\n }\n}\n","old_contents":"backend default {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\n\n sub vcl_recv {\n\n if (! (req.url ~ \"^\/openidm\/\") ) {\n set req.url = regsub(req.url, \"^\/\", \"\/sqlfiddle\/\");\n }\n\n if ( req.url == \"\/sqlfiddle\/\") {\n set req.url = \"\/sqlfiddle\/index.html\"; \n }\n\n if (req.request == \"GET\" && req.url != \"\/openidm\/info\/login\") {\n unset req.http.cookie;\n }\n\n }\n\nsub vcl_fetch {\n if (req.request == \"GET\" && req.url != \"\/openidm\/info\/login\") {\n set beresp.ttl = 3600s;\n }\n if (beresp.status != 200) {\n set beresp.ttl = 0s;\n }\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"9a7f0b6e7950d7a5485b5e211d60ea82f83a53f0","subject":"Adding varnish config back in","message":"Adding varnish config back in\n\nTurns out it was working after all :)\n","repos":"micktwomey\/docker-django-varnish","old_file":"default.vcl","new_file":"default.vcl","new_contents":"","old_contents":"","returncode":0,"stderr":"unknown","license":"mit","lang":"VCL"} {"commit":"2e6c4a07ec4ae5699c5a9fca3fa83a8f432e293b","subject":"Don't go to early deliver. Let the code flow continue","message":"Don't go to early deliver. Let the code flow continue\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets\/fetch.vcl","new_file":"etc\/vcl_snippets\/fetch.vcl","new_contents":" \/* handle 5XX (or any other unwanted status code) *\/\n if (beresp.status >= 500 && beresp.status < 600) {\n\n \/* deliver stale if the object is available *\/\n if (stale.exists) {\n return(deliver_stale);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n \/* else go to vcl_error to deliver a synthetic *\/\n error beresp.status beresp.response;\n }\n\n # Remove Set-Cookies from responses for static content\n # to match the cookie removal in recv.\n if (req.http.x-long-cache || req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's since those can be temporary during the site build\/index\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n }\n\n }\n\n # Force caching for signed cached assets.\n if (req.http.x-long-cache) {\n set beresp.ttl = 31536000s;\n set beresp.http.Cache-Control = \"max-age=31536000, immutable\";\n }\n\n if (beresp.http.Content-Type ~ \"text\/(html|xml)\") {\n # enable ESI feature for Magento response by default\n esi;\n if (!beresp.http.Vary ~ \"X-Magento-Vary,Https\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \",X-Magento-Vary,Https\";\n } else {\n set beresp.http.Vary = \"X-Magento-Vary,Https\";\n }\n }\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content except\n if ( !req.http.x-long-cache && http_status_matches(beresp.status, \"200,404\") && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url.ext ~ \"(?i)(css|js|html|eot|ico|otf|ttf|json)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n if (beresp.http.Cache-Control ~ \"private|no-cache|no-store\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # Never cache 302s\n if (beresp.status == 302) {\n return (pass);\n }\n\n # Just in case the Request Setting for x-pass is missing\n if (req.http.x-pass) {\n return (pass);\n }\n\n # Varnish sets default TTL if none of these are present\n if (!beresp.http.Expires && !beresp.http.Surrogate-Control ~ \"max-age\" && !beresp.http.Cache-Control ~ \"(s-maxage|max-age)\") {\n set beresp.ttl = 0s;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\") && !req.http.x-pass ) {\n unset beresp.http.set-cookie;\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type if they are image\/script or CSS\n if (beresp.http.Content-Type ~ \"(image|script|css)\") {\n set beresp.http.Surrogate-Key = re.group.1;\n }\n }\n","old_contents":" \/* handle 5XX (or any other unwanted status code) *\/\n if (beresp.status >= 500 && beresp.status < 600) {\n\n \/* deliver stale if the object is available *\/\n if (stale.exists) {\n return(deliver_stale);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n \/* else go to vcl_error to deliver a synthetic *\/\n error beresp.status beresp.response;\n }\n\n # Remove Set-Cookies from responses for static content\n # to match the cookie removal in recv.\n if (req.http.x-long-cache || req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's since those can be temporary during the site build\/index\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n }\n\n }\n\n # Force caching for signed cached assets.\n if (req.http.x-long-cache) {\n set beresp.ttl = 31536000s;\n set beresp.http.Cache-Control = \"max-age=31536000, immutable\";\n }\n\n if (beresp.http.Content-Type ~ \"text\/(html|xml)\") {\n # enable ESI feature for Magento response by default\n esi;\n if (!beresp.http.Vary ~ \"X-Magento-Vary,Https\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \",X-Magento-Vary,Https\";\n } else {\n set beresp.http.Vary = \"X-Magento-Vary,Https\";\n }\n }\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content except\n if ( !req.http.x-long-cache && http_status_matches(beresp.status, \"200,404\") && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url.ext ~ \"(?i)(css|js|html|eot|ico|otf|ttf|json)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n if (beresp.http.Cache-Control ~ \"private|no-cache|no-store\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # Never cache 302s\n if (beresp.status == 302) {\n return (pass);\n }\n\n # Just in case the Request Setting for x-pass is missing\n if (req.http.x-pass) {\n return (pass);\n }\n\n # Varnish sets default TTL if none of these are present\n if (!beresp.http.Expires && !beresp.http.Surrogate-Control ~ \"max-age\" && !beresp.http.Cache-Control ~ \"(s-maxage|max-age)\") {\n set beresp.ttl = 0s;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\") && !req.http.x-pass ) {\n unset beresp.http.set-cookie;\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type if they are image\/script or CSS\n if (beresp.http.Content-Type ~ \"(image|script|css)\") {\n set beresp.http.Surrogate-Key = re.group.1;\n }\n return (deliver);\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"4cb1a3e837b4fde275c3b9bbc3975100a16f6c4e","subject":"Added login-social to varnish","message":"Added login-social to varnish\n","repos":"guillaume-sainthillier\/ByNight,guillaume-sainthillier\/ByNight,guillaume-sainthillier\/ByNight,guillaume-sainthillier\/ByNight","old_file":"docker\/prod\/varnish\/default.vcl","new_file":"docker\/prod\/varnish\/default.vcl","new_contents":"vcl 4.0;\n\nimport std;\nimport directors;\n\ninclude \"\/etc\/varnish\/fos\/fos_ban.vcl\";\ninclude \"\/etc\/varnish\/fos\/fos_custom_ttl.vcl\";\ninclude \"\/etc\/varnish\/fos\/fos_purge.vcl\";\ninclude \"\/etc\/varnish\/fos\/fos_refresh.vcl\";\n\n# by-night.fr\nbackend default {\n .host = \"app\";\n .port = \"80\";\n}\n\nacl invalidators {\n \"app\";\n \"localhost\";\n \"127.0.0.1\";\n \"::1\";\n \"172.19.0.0\"\/16;\n}\n\n# Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable,\n# which backend to use.\n# also used to modify the request\nsub vcl_recv {\n\n # Pass real client ip to request\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n # Normalize the header, remove the port (in case you're testing this on various TCP ports)\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n # Remove the proxy header (see https:\/\/httpoxy.org\/#mitigate-varnish)\n unset req.http.proxy;\n\n # Normalize the query arguments\n set req.url = std.querysort(req.url);\n\n # FOS purge & ban\n call fos_purge_recv;\n call fos_ban_recv;\n call fos_refresh_recv;\n\n # Only deal with \"normal\" types\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"PATCH\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (synth(404, \"Non-valid HTTP method!\"));\n }\n\n # Only cache GET or HEAD requests. This makes sure the POST requests are always passed.\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n # First remove the Google Analytics added parameters, useless for our backend\n if (req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=\") {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n }\n\n # Strip hash, server doesn't need it.\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n # Strip a trailing ? if it exists\n if (req.url ~ \"\\?$\") {\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # Suppression de tous les cookies sur les pages publiques\n if( ! req.url ~ \"^\/(login|login-social|inscription|resetting|logout|profile|commentaire|espace-perso|social|_administration|_private)\" ) {\n unset req.http.Cookie;\n set req.http.X-Cookie-State = \"Deleted\";\n }\n\n # Remove all cookies but no PHPSESSID\n if (req.http.Cookie) {\n set req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n set req.http.Cookie = regsuball(req.http.Cookie, \";(PHPSESSID|REMEMBERME|app_city)=\", \"; \\1=\");\n set req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n\n # Remove a \";\" prefix in the cookie if present\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n\n # Are there cookies left with only spaces or that are empty?\n if (req.http.Cookie ~ \"^\\s*$\") {\n unset req.http.Cookie;\n }\n\n set req.http.X-Cookie-State = \"Vanished\";\n set req.http.X-Cookie = req.http.Cookie;\n } else if(! req.http.X-Cookie-State) {\n set req.http.X-Cookie-State = \"Empty\";\n }\n\n # Send Surrogate-Capability headers to announce ESI support to backend\n set req.http.Surrogate-Capability = \"abc=ESI\/1.0\";\n\n # Delegating static files to nginx\n if (req.url ~ \"^[^?]*\\.(7z|avi|bz2|flac|flv|gz|mka|mkv|mov|mp3|mp4|mpeg|mpg|ogg|ogm|opus|rar|tar|tgz|tbz|txz|wav|webm|xz|zip)(\\?.*)?$\") {\n unset req.http.Cookie;\n return (pass);\n }\n\n # Delegating static files to nginx\n if (req.url ~ \"^[^?]*\\.(7z|avi|bmp|bz2|css|csv|doc|docx|eot|flac|flv|gif|gz|ico|jpeg|jpg|js|less|mka|mkv|mov|mp3|mp4|mpeg|mpg|odt|otf|ogg|ogm|opus|pdf|png|ppt|pptx|rar|rtf|svg|svgz|swf|tar|tbz|tgz|ttf|txt|txz|wav|webm|webp|woff|woff2|xls|xlsx|xml|xz|zip)(\\?.*)?$\") {\n unset req.http.Cookie;\n return (pass);\n }\n\n return (hash);\n}\n\n# The data on which the hashing will take place\nsub vcl_hash {\n # Called after vcl_recv to create a hash value for the request. This is used as a key\n # to look up the object in Varnish.\n\n hash_data(req.url);\n\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n\n # hash cookies for requests that have them\n if (req.http.Cookie) {\n hash_data(req.http.Cookie);\n }\n}\n\n# Called when a cache lookup is successful.\nsub vcl_hit {\n\n if (obj.ttl >= 0s) {\n # A pure unadultered hit, deliver it\n return (deliver);\n }\n\n # https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-grace.html\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (miss);\n }\n\n # We have no fresh fish. Lets look at the stale ones.\n if (std.healthy(req.backend_hint)) {\n # Backend is healthy. Limit age to 10s.\n if (obj.ttl + 10s > 0s) {\n #set req.http.grace = \"normal(limited)\";\n return (deliver);\n } else {\n # No candidate for grace. Fetch a fresh object.\n return (miss);\n }\n } else {\n # backend is sick - use full grace\n if (obj.ttl + obj.grace > 0s) {\n #set req.http.grace = \"full\";\n return (deliver);\n } else {\n # no graced object.\n return (miss);\n }\n }\n\n # fetch & deliver once we get the result\n return (miss); # Dead code, keep as a safeguard\n}\n\n# Handle the HTTP request coming from our backend\nsub vcl_backend_response {\n\t# Called after the response headers has been successfully retrieved from the backend.\n\n\t# Pause ESI request and remove Surrogate-Control header\n\tif (beresp.http.Surrogate-Control ~ \"ESI\/1.0\") {\n\t\tunset beresp.http.Surrogate-Control;\n\t\tset beresp.do_esi = true;\n\t}\n\n\t# Enable cache for all static files\n # The same argument as the static caches from above: monitor your cache size, if you get data nuked out of it, consider giving up the static file cache.\n # Before you blindly enable this, have a read here: https:\/\/ma.ttias.be\/stop-caching-static-files\/\n if (bereq.url ~ \"^[^?]*\\.(7z|avi|bmp|bz2|css|csv|doc|docx|eot|flac|flv|gif|gz|ico|jpeg|jpg|js|less|mka|mkv|mov|mp3|mp4|mpeg|mpg|odt|otf|ogg|ogm|opus|pdf|png|ppt|pptx|rar|rtf|svg|svgz|swf|tar|tbz|tgz|ttf|txt|txz|wav|webm|webp|woff|woff2|xls|xlsx|xml|xz|zip)(\\?.*)?$\") {\n unset beresp.http.set-cookie;\n }\n\n # Large static files are delivered directly to the end-user without\n # waiting for Varnish to fully read the file first.\n # Varnish 4 fully supports Streaming, so use streaming here to avoid locking.\n if (bereq.url ~ \"^[^?]*\\.(7z|avi|bz2|flac|flv|gz|mka|mkv|mov|mp3|mp4|mpeg|mpg|ogg|ogm|opus|rar|tar|tgz|tbz|txz|wav|webm|xz|zip)(\\?.*)?$\") {\n unset beresp.http.set-cookie;\n }\n\n \t# Don't cache 50x responses\n \tif (beresp.status == 500 || beresp.status == 502 || beresp.status == 503 || beresp.status == 504) {\n\t\treturn (abandon);\n \t}\n\n call fos_ban_backend_response;\n call fos_custom_ttl_backend_response;\n\n # Set 2min cache if unset for static files\n if (beresp.ttl <= 0s || beresp.http.Vary == \"*\") {\n set beresp.ttl = 0s; # Important, you shouldn't rely on this, SET YOUR HEADERS in the backend\n set beresp.uncacheable = true;\n return (deliver);\n }\n\n \t# Allow stale content, in case the backend goes down.\n \t# make Varnish keep all objects for 6 hours beyond their TTL\n \tset beresp.grace = 6h;\n\n \treturn (deliver);\n}\n\n\n# The routine when we deliver the HTTP request to the user\n# Last chance to modify headers that are sent to the client\nsub vcl_deliver {\n # Called before a cached object is delivered to the client.\n\n # Add debug header to see if it's a HIT\/MISS and the number of hits, disable when not needed\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n set resp.http.X-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n\n set resp.http.Server = \"By Night\";\n\n\tunset resp.http.Via;\n\tunset resp.http.X-Varnish;\n\n\tcall fos_ban_deliver;\n\n if (resp.http.X-Cache-Debug) {\n set resp.http.X-Cookie-Debug = req.http.X-Cookie;\n set resp.http.X-Cookie-State = req.http.X-Cookie-State;\n }\n\n return (deliver);\n}\n\nsub vcl_synth {\n if (resp.status == 720) {\n # We use this special error status 720 to force redirects with 301 (permanent) redirects\n # To use this, call the following from anywhere in vcl_recv: return (synth(720, \"http:\/\/host\/new.html\"));\n set resp.http.Location = resp.reason;\n set resp.status = 301;\n return (deliver);\n } elseif (resp.status == 721) {\n # And we use error status 721 to force redirects with a 302 (temporary) redirect\n # To use this, call the following from anywhere in vcl_recv: return (synth(720, \"http:\/\/host\/new.html\"));\n set resp.http.Location = resp.reason;\n set resp.status = 302;\n return (deliver);\n }\n\n return (deliver);\n}\n","old_contents":"vcl 4.0;\n\nimport std;\nimport directors;\n\ninclude \"\/etc\/varnish\/fos\/fos_ban.vcl\";\ninclude \"\/etc\/varnish\/fos\/fos_custom_ttl.vcl\";\ninclude \"\/etc\/varnish\/fos\/fos_purge.vcl\";\ninclude \"\/etc\/varnish\/fos\/fos_refresh.vcl\";\n\n# by-night.fr\nbackend default {\n .host = \"app\";\n .port = \"80\";\n}\n\nacl invalidators {\n \"app\";\n \"localhost\";\n \"127.0.0.1\";\n \"::1\";\n \"172.19.0.0\"\/16;\n}\n\n# Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable,\n# which backend to use.\n# also used to modify the request\nsub vcl_recv {\n\n # Pass real client ip to request\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n # Normalize the header, remove the port (in case you're testing this on various TCP ports)\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n # Remove the proxy header (see https:\/\/httpoxy.org\/#mitigate-varnish)\n unset req.http.proxy;\n\n # Normalize the query arguments\n set req.url = std.querysort(req.url);\n\n # FOS purge & ban\n call fos_purge_recv;\n call fos_ban_recv;\n call fos_refresh_recv;\n\n # Only deal with \"normal\" types\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"PATCH\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (synth(404, \"Non-valid HTTP method!\"));\n }\n\n # Only cache GET or HEAD requests. This makes sure the POST requests are always passed.\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n # First remove the Google Analytics added parameters, useless for our backend\n if (req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=\") {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n }\n\n # Strip hash, server doesn't need it.\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n # Strip a trailing ? if it exists\n if (req.url ~ \"\\?$\") {\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # Suppression de tous les cookies sur les pages publiques\n if( ! req.url ~ \"^\/(login|inscription|resetting|logout|profile|commentaire|espace-perso|social|_administration|_private)\" ) {\n unset req.http.Cookie;\n set req.http.X-Cookie-State = \"Deleted\";\n }\n\n # Remove all cookies but no PHPSESSID\n if (req.http.Cookie) {\n set req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n set req.http.Cookie = regsuball(req.http.Cookie, \";(PHPSESSID|REMEMBERME|app_city)=\", \"; \\1=\");\n set req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n\n # Remove a \";\" prefix in the cookie if present\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n\n # Are there cookies left with only spaces or that are empty?\n if (req.http.Cookie ~ \"^\\s*$\") {\n unset req.http.Cookie;\n }\n\n set req.http.X-Cookie-State = \"Vanished\";\n set req.http.X-Cookie = req.http.Cookie;\n } else if(! req.http.X-Cookie-State) {\n set req.http.X-Cookie-State = \"Empty\";\n }\n\n # Send Surrogate-Capability headers to announce ESI support to backend\n set req.http.Surrogate-Capability = \"abc=ESI\/1.0\";\n\n # Delegating static files to nginx\n if (req.url ~ \"^[^?]*\\.(7z|avi|bz2|flac|flv|gz|mka|mkv|mov|mp3|mp4|mpeg|mpg|ogg|ogm|opus|rar|tar|tgz|tbz|txz|wav|webm|xz|zip)(\\?.*)?$\") {\n unset req.http.Cookie;\n return (pass);\n }\n\n # Delegating static files to nginx\n if (req.url ~ \"^[^?]*\\.(7z|avi|bmp|bz2|css|csv|doc|docx|eot|flac|flv|gif|gz|ico|jpeg|jpg|js|less|mka|mkv|mov|mp3|mp4|mpeg|mpg|odt|otf|ogg|ogm|opus|pdf|png|ppt|pptx|rar|rtf|svg|svgz|swf|tar|tbz|tgz|ttf|txt|txz|wav|webm|webp|woff|woff2|xls|xlsx|xml|xz|zip)(\\?.*)?$\") {\n unset req.http.Cookie;\n return (pass);\n }\n\n return (hash);\n}\n\n# The data on which the hashing will take place\nsub vcl_hash {\n # Called after vcl_recv to create a hash value for the request. This is used as a key\n # to look up the object in Varnish.\n\n hash_data(req.url);\n\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n\n # hash cookies for requests that have them\n if (req.http.Cookie) {\n hash_data(req.http.Cookie);\n }\n}\n\n# Called when a cache lookup is successful.\nsub vcl_hit {\n\n if (obj.ttl >= 0s) {\n # A pure unadultered hit, deliver it\n return (deliver);\n }\n\n # https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-grace.html\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (miss);\n }\n\n # We have no fresh fish. Lets look at the stale ones.\n if (std.healthy(req.backend_hint)) {\n # Backend is healthy. Limit age to 10s.\n if (obj.ttl + 10s > 0s) {\n #set req.http.grace = \"normal(limited)\";\n return (deliver);\n } else {\n # No candidate for grace. Fetch a fresh object.\n return (miss);\n }\n } else {\n # backend is sick - use full grace\n if (obj.ttl + obj.grace > 0s) {\n #set req.http.grace = \"full\";\n return (deliver);\n } else {\n # no graced object.\n return (miss);\n }\n }\n\n # fetch & deliver once we get the result\n return (miss); # Dead code, keep as a safeguard\n}\n\n# Handle the HTTP request coming from our backend\nsub vcl_backend_response {\n\t# Called after the response headers has been successfully retrieved from the backend.\n\n\t# Pause ESI request and remove Surrogate-Control header\n\tif (beresp.http.Surrogate-Control ~ \"ESI\/1.0\") {\n\t\tunset beresp.http.Surrogate-Control;\n\t\tset beresp.do_esi = true;\n\t}\n\n\t# Enable cache for all static files\n # The same argument as the static caches from above: monitor your cache size, if you get data nuked out of it, consider giving up the static file cache.\n # Before you blindly enable this, have a read here: https:\/\/ma.ttias.be\/stop-caching-static-files\/\n if (bereq.url ~ \"^[^?]*\\.(7z|avi|bmp|bz2|css|csv|doc|docx|eot|flac|flv|gif|gz|ico|jpeg|jpg|js|less|mka|mkv|mov|mp3|mp4|mpeg|mpg|odt|otf|ogg|ogm|opus|pdf|png|ppt|pptx|rar|rtf|svg|svgz|swf|tar|tbz|tgz|ttf|txt|txz|wav|webm|webp|woff|woff2|xls|xlsx|xml|xz|zip)(\\?.*)?$\") {\n unset beresp.http.set-cookie;\n }\n\n # Large static files are delivered directly to the end-user without\n # waiting for Varnish to fully read the file first.\n # Varnish 4 fully supports Streaming, so use streaming here to avoid locking.\n if (bereq.url ~ \"^[^?]*\\.(7z|avi|bz2|flac|flv|gz|mka|mkv|mov|mp3|mp4|mpeg|mpg|ogg|ogm|opus|rar|tar|tgz|tbz|txz|wav|webm|xz|zip)(\\?.*)?$\") {\n unset beresp.http.set-cookie;\n }\n\n \t# Don't cache 50x responses\n \tif (beresp.status == 500 || beresp.status == 502 || beresp.status == 503 || beresp.status == 504) {\n\t\treturn (abandon);\n \t}\n\n call fos_ban_backend_response;\n call fos_custom_ttl_backend_response;\n\n # Set 2min cache if unset for static files\n if (beresp.ttl <= 0s || beresp.http.Vary == \"*\") {\n set beresp.ttl = 0s; # Important, you shouldn't rely on this, SET YOUR HEADERS in the backend\n set beresp.uncacheable = true;\n return (deliver);\n }\n\n \t# Allow stale content, in case the backend goes down.\n \t# make Varnish keep all objects for 6 hours beyond their TTL\n \tset beresp.grace = 6h;\n\n \treturn (deliver);\n}\n\n\n# The routine when we deliver the HTTP request to the user\n# Last chance to modify headers that are sent to the client\nsub vcl_deliver {\n # Called before a cached object is delivered to the client.\n\n # Add debug header to see if it's a HIT\/MISS and the number of hits, disable when not needed\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n set resp.http.X-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n\n set resp.http.Server = \"By Night\";\n\n\tunset resp.http.Via;\n\tunset resp.http.X-Varnish;\n\n\tcall fos_ban_deliver;\n\n if (resp.http.X-Cache-Debug) {\n set resp.http.X-Cookie-Debug = req.http.X-Cookie;\n set resp.http.X-Cookie-State = req.http.X-Cookie-State;\n }\n\n return (deliver);\n}\n\nsub vcl_synth {\n if (resp.status == 720) {\n # We use this special error status 720 to force redirects with 301 (permanent) redirects\n # To use this, call the following from anywhere in vcl_recv: return (synth(720, \"http:\/\/host\/new.html\"));\n set resp.http.Location = resp.reason;\n set resp.status = 301;\n return (deliver);\n } elseif (resp.status == 721) {\n # And we use error status 721 to force redirects with a 302 (temporary) redirect\n # To use this, call the following from anywhere in vcl_recv: return (synth(720, \"http:\/\/host\/new.html\"));\n set resp.http.Location = resp.reason;\n set resp.status = 302;\n return (deliver);\n }\n\n return (deliver);\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"774320967cbf038eae497538460f0476742a9ad3","subject":"Do not trigger hit-for-pass","message":"Do not trigger hit-for-pass\n\nVarnish by default remember for 120s to not cache a object.\n","repos":"ninech\/varnishworkbench,ninech\/varnishworkbench,ninech\/varnishworkbench,ninech\/varnishworkbench","old_file":"public\/varnishworkbench.vcl","new_file":"public\/varnishworkbench.vcl","new_contents":"\/*\n * Varnish Workbench VCL\n *\n * This Varnish VCL extends the default VLC by adding\n * PURGE\/BAN\/REFRESH support. For this demonstration we added\n * some further modifications which include:\n *\n * - Remove the jQuery AJAX nocache GET parameter\n * - Add debug output to the headers.\n * - Make the cache client.ip sensitiv.\n *\n *\/\n\n\/*\n * Localhost as Backend\n *\/\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"80\";\n .connect_timeout = 5s;\n .first_byte_timeout = 600s;\n .between_bytes_timeout = 600s;\n}\n\n\/*\n * Allow PURGE, BAN and REFRESH only from those IPs.\n *\/\nacl purge {\n \"127.0.0.1\";\n}\n\n\/*\n * Handle received requests\n *\/\nsub vcl_recv {\n \/\/ Save Client IP to X-Forwarded-For\n set req.http.X-Forwarded-For = client.ip;\n\n \/\/ Strip the jQuery no-cache option\n if (req.url ~ \"(\\?|\\&)_=[0-9]+\" ) {\n set req.url = regsub(req.url, \"(\\?|\\&)_=[0-9]+\", \"\");\n }\n\n \/\/ Get the IP the cache is for\n if (!req.http.X-Cache-For) {\n set req.http.X-Cache-For = client.ip;\n }\n\n \/\/ Lookup PURGE\n if (req.request == \"PURGE\") {\n if (!client.ip ~ purge) { error 405 \"Not allowed.\"; }\n return (lookup);\n }\n \/\/ Add BAN to the list\n if (req.request == \"BAN\") {\n if (!client.ip ~ purge) { error 405 \"Not allowed.\"; }\n ban(\"obj.http.x-ban-url ~ \" + req.http.x-ban-url +\n \" && obj.http.x-ban-host ~ \" + req.http.x-ban-host +\n \" && obj.http.x-ban-ip ~ \" + req.http.X-Cache-For);\n error 200 \"Banned\";\n }\n \/\/ Bypass a cache hit\n if (req.request == \"REFRESH\") {\n if (!client.ip ~ purge) { error 405 \"Not allowed.\"; }\n set req.request = \"GET\";\n set req.hash_always_miss = true;\n }\n}\n\n\/*\n * Modify page received from backend\n *\/\nsub vcl_fetch {\n \/\/ Remember request host, url and IP for purging\n set beresp.http.x-ban-url = req.url;\n set beresp.http.x-ban-host = req.http.host;\n set beresp.http.x-ban-ip = req.http.X-Cache-For;\n\n \/\/ Save the Varnish TTL\n set beresp.http.X-Varnish-Ttl = beresp.ttl;\n\n \/\/ Will Varnish cache this\n if (beresp.ttl <= 0s) {\n set beresp.http.X-Varnish-Cacheable = \"NO: Not Cacheable\";\n } else {\n set beresp.http.X-Varnish-Cacheable = \"YES\";\n }\n\n \/\/ Bypass \"Hit-For-Pass\"\n return (deliver);\n}\n\n\/*\n * PURGE handling for cache hits\n *\/\nsub vcl_hit {\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged\";\n }\n}\n\n\/*\n * PURGE handling for cache misses.\n *\/\nsub vcl_miss {\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged\";\n }\n}\n\n\/*\n * Send Object to Client\n *\/\nsub vcl_deliver {\n \/\/ Set Hit\/Miss Headeri\n if (obj.hits > 0) {\n set resp.http.X-Varnish-Cache = \"HIT\";\n }\n else {\n set resp.http.X-Varnish-Cache = \"MISS\";\n }\n\n \/\/ Remove internal informations\n unset resp.http.x-ban-url;\n unset resp.http.x-ban-host;\n unset resp.http.x-ban-ip;\n}\n\n\/*\n * Add X-Cache-For to the Hash to allow each user to have it's own cache.\n *\/\nsub vcl_hash {\n hash_data(req.http.X-Cache-For);\n}\n","old_contents":"\/*\n * Varnish Workbench VCL\n *\n * This Varnish VCL extends the default VLC by adding\n * PURGE\/BAN\/REFRESH support. For this demonstration we added\n * some further modifications which include:\n *\n * - Remove the jQuery AJAX nocache GET parameter\n * - Add debug output to the headers.\n * - Make the cache client.ip sensitiv.\n *\n *\/\n\n\/*\n * Localhost as Backend\n *\/\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"80\";\n .connect_timeout = 5s;\n .first_byte_timeout = 600s;\n .between_bytes_timeout = 600s;\n}\n\n\/*\n * Allow PURGE, BAN and REFRESH only from those IPs.\n *\/\nacl purge {\n \"127.0.0.1\";\n}\n\n\/*\n * Handle received requests\n *\/\nsub vcl_recv {\n \/\/ Save Client IP to X-Forwarded-For\n set req.http.X-Forwarded-For = client.ip;\n\n \/\/ Strip the jQuery no-cache option\n if (req.url ~ \"(\\?|\\&)_=[0-9]+\" ) {\n set req.url = regsub(req.url, \"(\\?|\\&)_=[0-9]+\", \"\");\n }\n\n \/\/ Get the IP the cache is for\n if (!req.http.X-Cache-For) {\n set req.http.X-Cache-For = client.ip;\n }\n\n \/\/ Lookup PURGE\n if (req.request == \"PURGE\") {\n if (!client.ip ~ purge) { error 405 \"Not allowed.\"; }\n return (lookup);\n }\n \/\/ Add BAN to the list\n if (req.request == \"BAN\") {\n if (!client.ip ~ purge) { error 405 \"Not allowed.\"; }\n ban(\"obj.http.x-ban-url ~ \" + req.http.x-ban-url +\n \" && obj.http.x-ban-host ~ \" + req.http.x-ban-host +\n \" && obj.http.x-ban-ip ~ \" + req.http.X-Cache-For);\n error 200 \"Banned\";\n }\n \/\/ Bypass a cache hit\n if (req.request == \"REFRESH\") {\n if (!client.ip ~ purge) { error 405 \"Not allowed.\"; }\n set req.request = \"GET\";\n set req.hash_always_miss = true;\n }\n}\n\n\/*\n * Modify page received from backend\n *\/\nsub vcl_fetch {\n \/\/ Remember request host, url and IP for purging\n set beresp.http.x-ban-url = req.url;\n set beresp.http.x-ban-host = req.http.host;\n set beresp.http.x-ban-ip = req.http.X-Cache-For;\n\n \/\/ Save the Varnish TTL\n set beresp.http.X-Varnish-Ttl = beresp.ttl;\n\n \/\/ Will Varnish cache this\n if (beresp.ttl <= 0s) {\n set beresp.http.X-Varnish-Cacheable = \"NO: Not Cacheable\";\n } else {\n set beresp.http.X-Varnish-Cacheable = \"YES\";\n }\n}\n\n\/*\n * PURGE handling for cache hits\n *\/\nsub vcl_hit {\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged\";\n }\n}\n\n\/*\n * PURGE handling for cache misses.\n *\/\nsub vcl_miss {\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged\";\n }\n}\n\n\/*\n * Send Object to Client\n *\/\nsub vcl_deliver {\n \/\/ Set Hit\/Miss Headeri\n if (obj.hits > 0) {\n set resp.http.X-Varnish-Cache = \"HIT\";\n }\n else {\n set resp.http.X-Varnish-Cache = \"MISS\";\n }\n\n \/\/ Remove internal informations\n unset resp.http.x-ban-url;\n unset resp.http.x-ban-host;\n unset resp.http.x-ban-ip;\n}\n\n\/*\n * Add X-Cache-For to the Hash to allow each user to have it's own cache.\n *\/\nsub vcl_hash {\n hash_data(req.http.X-Cache-For);\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"7100e3c4b03558402757c8c535999926a17c46c9","subject":"Inverted request match for blacklist, reordered header injection for blacklisted responses.","message":"Inverted request match for blacklist, reordered header injection for blacklisted responses.\n","repos":"kkwoker\/ansible-varnish,noqcks\/ansible-varnish,killerwails\/ansible-varnish,gotofbi\/ansible-varnish,killerwails\/ansible-varnish,colstrom\/ansible-varnish,telusdigital\/ansible-varnish,gotofbi\/ansible-varnish","old_file":"templates\/etc\/varnish\/default.vcl","new_file":"templates\/etc\/varnish\/default.vcl","new_contents":"vcl 4.0;\n\nimport directors;\nimport std;\n\n###\n# Varnish Documentation\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-built-in-subs.html\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/reference\/vcl.html\n##\n\n{% for backend in varnish_backend_hosts %}\nbackend application_{{ loop.index }} {\n .host = \"{{ backend }}\";\n .port = \"{{ varnish_backend_port }}\";\n{% if varnish_health_checks_enabled %}\n .probe = {\n .url = \"{{ varnish_health_check_url }}\";\n .interval = {{ varnish_health_check_interval }};\n .timeout = {{ varnish_health_check_timeout }};\n .window = {{ varnish_health_check_window }};\n .threshold = {{ varnish_health_check_threshold }};\n }\n{% endif %}\n}\n{% endfor %}\n\n###\n# vcl_init\n# Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n###\n# The vcl_init subroutine may terminate with calling return() with one of the following keywords:\n#\n# ok\n# Normal return, VCL continues loading.\n##\n\nsub vcl_init {\n new application = directors.round_robin();\n{% for backend in varnish_backend_hosts %}\n application.add_backend(application_{{ loop.index }});\n{% endfor %}\n}\n\n###\n# vcl_recv\n# Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use. \n# It is also used to modify the request\n###\n# The vcl_recv subroutine may terminate with calling return() on one of the following keywords:\n#\n# synth(status code, reason)\n# Return a synthetic object with the specified status code to the client and abandon the request.\n# pass\n# Switch to pass mode. Control will eventually pass to vcl_pass.\n# pipe\n# Switch to pipe mode. Control will eventually pass to vcl_pipe.\n# hash\n# Continue processing the object as a potential candidate for caching. Passes the control over to vcl_hash.\n# purge\n# Purge the object and it's variants. Control passes through vcl_hash to vcl_purge.\n#\n\nsub vcl_recv {\n{% if varnish_blacklist_enabled %}\n if ((req.url ~ \"{{ varnish_blacklist_regexp }}\")) {\n return(pass);\n } else {\n{% if varnish_discards_client_cookies %}\n unset req.http.Cookie;\n{% endif %}\n }\n{% endif %}\n\n set req.backend_hint = application.backend();\n}\n\n###\n# vcl_hit\n# Called when a cache lookup is successful.\n###\n# The vcl_hit subroutine may terminate with calling return() with one of the following keywords:\n#\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n# deliver\n# Deliver the object. Control passes to vcl_deliver.\n# synth(status code, reason)\n# Return the specified status code to the client and abandon the request.\n###\n\nsub vcl_hit {\n if (obj.ttl > 0s) {\n return (deliver);\n }\n{% if varnish_health_checks_enabled %}\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (fetch);\n }\n{% else %}\n if (obj.ttl + obj.grace > 0s) {\n return (deliver);\n }\n\n return (fetch);\n{% endif %}\n}\n\n###\n# vcl_backend_response\n# Called after the response headers has been successfully retrieved from the backend.\n###\n# The vcl_backend_response subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Possibly insert the object into the cache, then deliver it to the Control will eventually pass to vcl_deliver.\n# abandon\n# Abandon the backend request and generates an error.\n# retry\n# Retry the backend transaction. Increases the retries counter. If the number of retries is higher than max_retries Varnish emits a guru meditation error.\n###\n\nsub vcl_backend_response {\n{% if varnish_blacklist_enabled %}\n if (bereq.url ~ \"{{ varnish_blacklist_regexp }}\") {\n set beresp.http.X-Cacheable = \"NO:URL in Blacklist\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n }\n{% endif %}\n\n{% if varnish_cache_diagnostics_enabled %}\n if (beresp.ttl <= 0s) {\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (bereq.http.Cookie) {\n set beresp.http.X-Cacheable = \"NO:Cookie in Request\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO:Set-Cookie in Response\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.X-No-Cache) {\n set beresp.http.X-Cacheable = \"NO:X-No-Cache\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n{% endif %}\n\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n\n set beresp.grace = {{ varnish_grace_period }};\n}\n\n###\n# vcl_deliver\n# Called before a cached object is delivered to the client.\n###\n# The vcl_deliver subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Deliver the object to the client.\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n###\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n","old_contents":"vcl 4.0;\n\nimport directors;\nimport std;\n\n###\n# Varnish Documentation\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-built-in-subs.html\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/reference\/vcl.html\n##\n\n{% for backend in varnish_backend_hosts %}\nbackend application_{{ loop.index }} {\n .host = \"{{ backend }}\";\n .port = \"{{ varnish_backend_port }}\";\n{% if varnish_health_checks_enabled %}\n .probe = {\n .url = \"{{ varnish_health_check_url }}\";\n .interval = {{ varnish_health_check_interval }};\n .timeout = {{ varnish_health_check_timeout }};\n .window = {{ varnish_health_check_window }};\n .threshold = {{ varnish_health_check_threshold }};\n }\n{% endif %}\n}\n{% endfor %}\n\n###\n# vcl_init\n# Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n###\n# The vcl_init subroutine may terminate with calling return() with one of the following keywords:\n#\n# ok\n# Normal return, VCL continues loading.\n##\n\nsub vcl_init {\n new application = directors.round_robin();\n{% for backend in varnish_backend_hosts %}\n application.add_backend(application_{{ loop.index }});\n{% endfor %}\n}\n\n###\n# vcl_recv\n# Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use. \n# It is also used to modify the request\n###\n# The vcl_recv subroutine may terminate with calling return() on one of the following keywords:\n#\n# synth(status code, reason)\n# Return a synthetic object with the specified status code to the client and abandon the request.\n# pass\n# Switch to pass mode. Control will eventually pass to vcl_pass.\n# pipe\n# Switch to pipe mode. Control will eventually pass to vcl_pipe.\n# hash\n# Continue processing the object as a potential candidate for caching. Passes the control over to vcl_hash.\n# purge\n# Purge the object and it's variants. Control passes through vcl_hash to vcl_purge.\n#\n\nsub vcl_recv {\n{% if varnish_blacklist_enabled %}\n if (!(req.url ~ \"{{ varnish_blacklist_regexp }}\")) {\n return(pass);\n } else {\n{% if varnish_discards_client_cookies %}\n unset req.http.Cookie;\n{% endif %}\n }\n{% endif %}\n\n set req.backend_hint = application.backend();\n}\n\n###\n# vcl_hit\n# Called when a cache lookup is successful.\n###\n# The vcl_hit subroutine may terminate with calling return() with one of the following keywords:\n#\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n# deliver\n# Deliver the object. Control passes to vcl_deliver.\n# synth(status code, reason)\n# Return the specified status code to the client and abandon the request.\n###\n\nsub vcl_hit {\n if (obj.ttl > 0s) {\n return (deliver);\n }\n{% if varnish_health_checks_enabled %}\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (fetch);\n }\n{% else %}\n if (obj.ttl + obj.grace > 0s) {\n return (deliver);\n }\n\n return (fetch);\n{% endif %}\n}\n\n###\n# vcl_backend_response\n# Called after the response headers has been successfully retrieved from the backend.\n###\n# The vcl_backend_response subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Possibly insert the object into the cache, then deliver it to the Control will eventually pass to vcl_deliver.\n# abandon\n# Abandon the backend request and generates an error.\n# retry\n# Retry the backend transaction. Increases the retries counter. If the number of retries is higher than max_retries Varnish emits a guru meditation error.\n###\n\nsub vcl_backend_response {\n{% if varnish_cache_diagnostics_enabled %}\n if (beresp.ttl <= 0s) {\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (bereq.http.Cookie) {\n set beresp.http.X-Cacheable = \"NO:Cookie in Request\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO:Set-Cookie in Response\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.X-No-Cache) {\n set beresp.http.X-Cacheable = \"NO:X-No-Cache\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n{% endif %}\n\n{% if varnish_blacklist_enabled %}\n if (bereq.url ~ \"{{ varnish_blacklist_regexp }}\") {\n set beresp.http.X-Cacheable = \"NO:Blacklisted\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n }\n{% endif %}\n\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n\n set beresp.grace = {{ varnish_grace_period }};\n}\n\n###\n# vcl_deliver\n# Called before a cached object is delivered to the client.\n###\n# The vcl_deliver subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Deliver the object to the client.\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n###\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"e1f2d10ec7b9ad2c193cfdf500cd0877309d2055","subject":"Reorganize commands, add commands for Atom development","message":"Reorganize commands, add commands for Atom development\n","repos":"aschneiderman\/atom-voice-vocola","old_file":"atom.vcl","new_file":"atom.vcl","new_contents":"# Voice commands for atom\n\ninclude folders.vch;\ninclude letters.vch;\n\nGo Strawberry = {Ctrl+Alt+F8};\n\n\n# Commands for developing Atom: init.config, packages; also for navigating existing packages\/commands\nReload Atom = {Ctrl+s} Wait(100) {Shift+Ctrl+Alt+F5};\nCommand Palette = {Ctrl+Shift+p};\nKeyboard Shortcuts = {Ctrl+.};\n\n# Commands for developing D3: D3 visualizations, D3 Sandwiches\nSave and Reload = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Ctrl+r};\t\nSave and Really Reload = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Ctrl+Shift+r};\n\n# File commands\nFind (File | Document) = {Ctrl+t};\nSave As = {Ctrl+Shift+s};\n\n\n# --- Navigation commands ------------------------------------\n<delimiters> := (Quote = '\"' | 'Single Quote' = \"'\" | Comma = ',' | 'Equal Sign' = '=' | Equals = '=' \n\t| Period = '.' | Colon = ':' | 'Semi-Colon' = ';' | Hyphen = '-' | Underscore = '_' | Slash = '\/'\n\t| Paren = \"(\" | \"Close Paren\" = \")\"\n\t| Bracket = '[' | \"Close Bracket\" = ']' | Brace = '{' | 'Close Brace' = '}'\t);\n\nLine 1..200 = {Ctrl+g} $1 {Enter};\n(Left = 'b' | Right = 'f') Word = {Alt+$1};\nTop = {Ctrl+Home};\nBottom = {Ctrl+End};\n(Find = 'Right' | 'Insert After' = 'Right' | 'Insert Before' = 'Left') (Next = 'Enter' | Last = 'Shift+F3') <delimiters> \n\t\t= {Ctrl+f} $3 {$2} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') <delimiters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') 1..20 <delimiters> = {Ctrl+f} $3 {Enter} {Esc} Wait(100) {F3_$2} {Shift+F3} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') Enda <delimiters> = {End} {Ctrl+f} $2 {Enter} {Esc} {Shift+F3} Wait(100) {$1};\n\nFine Alpha <letters> = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Left};\nInsert (Before = 'Left' | After = 'Right') Alpha <letters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nFine Number 0..9 = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Right};\nFind Again = {F3} {Right};\nFind Again 1..20 Times = {F3_$1} {Right};\n\nFind Symbol = {Ctrl+r};\n\n(Set | Add | Clear | Hide | Delete) Bookmark = {Ctrl+Alt+F2};\n(Next = 'F2' | Last = 'Shift+F2') Bookmark = {$1};\n\nNext Window = {Ctrl+Tab};\nLast Window = {Ctrl+Shift+Tab};\n\n\n# --- Editing commands ----------------------------------------\nSelect Line = {Ctrl+l};\nSelect (Next = 'Down' | Last = 'Up') 1..20 Lines = {Home} {Shift+$1_$2};\n(Join = 'j' | Indent = ']' | Dedent = '[') That = {Ctrl+$1};\nMove Line (Up | Down) 1..20 = {Ctrl+$1_$2};\n\n\n\nDelete Word = {Ctrl+Del};\nDelete 1..20 Words = {Ctrl+Del_$1};\nDelete (Back | Last) Word = {Ctrl+Backspace};\nDelete (Back | Last) 1..20 Words = {Ctrl+Backspace_$2};\nDelete Enda Word = {End} {Ctrl+Backspace};\n\n(Delete Line | Dede) = {Ctrl+Shift+k};\nDelete 1..20 Lines = {Ctrl+Shift+k_$1};\n(Cut = 'x' | Paste = 'v' | Copy = 'c') That = {Ctrl+$1};\n\nComment (That | Line) = {Ctrl+\/};\nComment 1..20 Lines = {Home} {Shift+Down_$1} {Ctrl+\/};\n\nSelect between (Delimiters | Brackets) ={Ctrl+m} {Ctrl+Alt+m};\n\nDelete Tags = {Ctrl+Alt+F4};\n\n\n\n\n# --- Code commands -------------------------------------------\nStart (Item = 'li' | List = 'ul' | HTML = 'html' | pre = \"pre\"\n\t| 'Bold ID' = 'bold-id' | 'Input' = 'ds-input-text'\n\t| 'Fix Line' = 'fix-current-line' | 'Fix Current Line' = 'fix-current-line'\n\t| Snippet = 'my-snippet' | 'Recipe Row' = 'recipe-row' | 'Recipe Play' = 'recipe-play') = $1 {Tab};\nStart (para = '<p>' ) = $1;\nAdd (para = 'p') = '<' $1 '>' {End} '<\/' $1 '>';\nReplace With (para = 'p') = {Ctrl+Alt+F4} '<' $1 '>' {End} '<\/' $1 '>';\n\nStart (Header | Heading) 1..7 = h $2 {Tab};\nAdd (Header | Heading) 1..7 = '<h' $2 '>' {End} '<\/h' $2 '>';\nReplace With (Header | Heading) 1..7 = {Ctrl+Alt+F4} '<h' $2 '>' {End} '<\/h' $2 '>' {Home};\nMid HREF = '\">';\n\nPaste Function = 'function ' {Ctrl+v} ' {' {Enter} {Enter} '};' {Up};\n\nPre-Format Code = {Ctrl+Alt+F5};\n\n# TO ADD:\n# adding HTML comments, using a snippet\n\n\n\n","old_contents":"# Voice commands for atom\n\ninclude folders.vch;\ninclude letters.vch;\n\nGo Strawberry = {Ctrl+Alt+F8};\n\n\n# Reload Atom = {Shift+Ctrl+Alt+F5};\nReload Atom = {Ctrl+s} Wait(100) {Shift+Ctrl+Alt+F5};\n\nFind (File | Document) = {Ctrl+t};\nSave As = {Ctrl+Shift+s};\nSave and Reload = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Ctrl+r};\nSave and Really Reload = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Ctrl+Shift+r};\n\n<delimiters> := (Quote = '\"' | 'Single Quote' = \"'\" | Comma = ',' | 'Equal Sign' = '=' | Equals = '=' \n\t| Period = '.' | Colon = ':' | 'Semi-Colon' = ';' | Hyphen = '-' | Underscore = '_' | Slash = '\/'\n\t| Paren = \"(\" | \"Close Paren\" = \")\"\n\t| Bracket = '[' | \"Close Bracket\" = ']' | Brace = '{' | 'Close Brace' = '}'\t);\n\n# --- Navigation commands ------------------------------------\nLine 1..200 = {Ctrl+g} $1 {Enter};\n(Left = 'b' | Right = 'f') Word = {Alt+$1};\nTop = {Ctrl+Home};\nBottom = {Ctrl+End};\n(Find = 'Right' | 'Insert After' = 'Right' | 'Insert Before' = 'Left') (Next = 'Enter' | Last = 'Shift+F3') <delimiters> \n\t\t= {Ctrl+f} $3 {$2} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') <delimiters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') 1..20 <delimiters> = {Ctrl+f} $3 {Enter} {Esc} Wait(100) {F3_$2} {Shift+F3} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') Enda <delimiters> = {End} {Ctrl+f} $2 {Enter} {Esc} {Shift+F3} Wait(100) {$1};\n\nFine Alpha <letters> = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Left};\nInsert (Before = 'Left' | After = 'Right') Alpha <letters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nFine Number 0..9 = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Right};\nFind Again = {F3} {Right};\nFind Again 1..20 Times = {F3_$1} {Right};\n\nFind Symbol = {Ctrl+r};\n\n(Set | Add | Clear | Hide | Delete) Bookmark = {Ctrl+Alt+F2};\n(Next = 'F2' | Last = 'Shift+F2') Bookmark = {$1};\n\nNext Window = {Ctrl+Tab};\nLast Window = {Ctrl+Shift+Tab};\n\n\n# --- Editing commands ----------------------------------------\nSelect Line = {Ctrl+l};\nSelect (Next = 'Down' | Last = 'Up') 1..20 Lines = {Home} {Shift+$1_$2};\n(Join = 'j' | Indent = ']' | Dedent = '[') That = {Ctrl+$1};\nMove Line (Up | Down) 1..20 = {Ctrl+$1_$2};\n\n\n\nDelete Word = {Ctrl+Del};\nDelete 1..20 Words = {Ctrl+Del_$1};\nDelete (Back | Last) Word = {Ctrl+Backspace};\nDelete (Back | Last) 1..20 Words = {Ctrl+Backspace_$2};\nDelete Enda Word = {End} {Ctrl+Backspace};\n\n(Delete Line | Dede) = {Ctrl+Shift+k};\nDelete 1..20 Lines = {Ctrl+Shift+k_$1};\n(Cut = 'x' | Paste = 'v' | Copy = 'c') That = {Ctrl+$1};\n\nComment (That | Line) = {Ctrl+\/};\nComment 1..20 Lines = {Home} {Shift+Down_$1} {Ctrl+\/};\n\nSelect between (Delimiters | Brackets) ={Ctrl+m} {Ctrl+Alt+m};\n\nDelete Tags = {Ctrl+Alt+F4};\n\n\n\n\n# --- Code commands -------------------------------------------\nStart (Item = 'li' | List = 'ul' | HTML = 'html' | pre = \"pre\"\n\t| 'Bold ID' = 'bold-id' | 'Input' = 'ds-input-text'\n\t| 'Fix Line' = 'fix-current-line' | 'Fix Current Line' = 'fix-current-line'\n\t| Snippet = 'my-snippet' | 'Recipe Row' = 'recipe-row' | 'Recipe Play' = 'recipe-play') = $1 {Tab};\nStart (para = '<p>' ) = $1;\nAdd (para = 'p') = '<' $1 '>' {End} '<\/' $1 '>';\nReplace With (para = 'p') = {Ctrl+Alt+F4} '<' $1 '>' {End} '<\/' $1 '>';\n\nStart (Header | Heading) 1..7 = h $2 {Tab};\nAdd (Header | Heading) 1..7 = '<h' $2 '>' {End} '<\/h' $2 '>';\nReplace With (Header | Heading) 1..7 = {Ctrl+Alt+F4} '<h' $2 '>' {End} '<\/h' $2 '>' {Home};\nMid HREF = '\">';\n\nPaste Function = 'function ' {Ctrl+v} ' {' {Enter} {Enter} '};' {Up};\n\nPre-Format Code = {Ctrl+Alt+F5};\n\n# TO ADD:\n# adding HTML comments, using a snippet\n\nShortcut Keys = {Ctrl+Shift+p};\n\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"f8d274896489b6eaecec7a290afcbc376dda4870","subject":"Fixed regexp in VCL.","message":"Fixed regexp in VCL.\n","repos":"telusdigital\/ansible-varnish,gotofbi\/ansible-varnish,gotofbi\/ansible-varnish,killerwails\/ansible-varnish,killerwails\/ansible-varnish,colstrom\/ansible-varnish,kkwoker\/ansible-varnish,noqcks\/ansible-varnish","old_file":"templates\/etc\/varnish\/default.vcl","new_file":"templates\/etc\/varnish\/default.vcl","new_contents":"vcl 4.0;\n\nimport directors;\nimport std;\n\n###\n# Varnish Documentation\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-built-in-subs.html\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/reference\/vcl.html\n##\n\n{% for backend in varnish_backend_hosts %}\nbackend application_{{ loop.index }} {\n .host = \"{{ backend }}\";\n .port = \"{{ varnish_backend_port }}\";\n{% if varnish_health_checks_enabled %}\n .probe = {\n .url = \"{{ varnish_health_check_url }}\";\n .interval = {{ varnish_health_check_interval }};\n .timeout = {{ varnish_health_check_timeout }};\n .window = {{ varnish_health_check_window }};\n .threshold = {{ varnish_health_check_threshold }};\n }\n{% endif %}\n}\n{% endfor %}\n\n###\n# vcl_init\n# Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n###\n# The vcl_init subroutine may terminate with calling return() with one of the following keywords:\n#\n# ok\n# Normal return, VCL continues loading.\n##\n\nsub vcl_init {\n new application = directors.round_robin();\n{% for backend in varnish_backend_hosts %}\n application.add_backend(application_{{ loop.index }});\n{% endfor %}\n}\n\n###\n# vcl_recv\n# Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use. \n# It is also used to modify the request\n###\n# The vcl_recv subroutine may terminate with calling return() on one of the following keywords:\n#\n# synth(status code, reason)\n# Return a synthetic object with the specified status code to the client and abandon the request.\n# pass\n# Switch to pass mode. Control will eventually pass to vcl_pass.\n# pipe\n# Switch to pipe mode. Control will eventually pass to vcl_pipe.\n# hash\n# Continue processing the object as a potential candidate for caching. Passes the control over to vcl_hash.\n# purge\n# Purge the object and it's variants. Control passes through vcl_hash to vcl_purge.\n#\n\nsub vcl_recv {\n{% if varnish_workaround_telusdotcom_browser_profile %}\n if (req.http.Cookie ~ \"BrowserProfile\") {\n set req.http.X-Language = regsuball(req.http.Cookie, \"language..:\\\\.(.*)\\\\.,\", \"\\1\");\n set req.http.X-Province = regsuball(req.http.Cookie, \"region..:\\\\.(.*)\\\\.,\", \"\\1\");\n } else {\n if (req.http.Cookie ~ \"lang=\") {\n set req.http.X-Language = regsuball(req.http.Cookie, \"lang=(.*);\", \"\\1\");\n } else {\n set req.http.X-Language = \"en\";\n }\n\n if (req.http.Cookie ~ \"prov=\") {\n set req.http.X-Province = regsuball(req.http.Cookie, \"prov=(.*);\", \"\\1\");\n } else {\n set req.http.X-Province = \"BC\";\n }\n }\n\n if (req.url ~ \"\/(en|fr)\/\") {\n if (req.url ~ \"\/en\/\" && req.http.X-Language != \"en\") {\n return(pass);\n }\n if (req.url ~ \"\/fr\/\" && req.http.X-Language != \"fr\") {\n return(pass);\n }\n }\n\n if (req.url ~ \"\/(ab|bc|mb|nb|nl|ns|nt|nu|on|pe|qc|sk|yt)\/\") {\n {% for province in ['ab', 'bc', 'mb', 'nb', 'nl', 'ns', 'nt', 'nu', 'on', 'pe', 'qc', 'sk', 'yt'] %}\n if (req.url ~ \"{{ province }}\" && req.http.X-Province != \"{{ province }}\") {\n return(pass);\n }\n {% endfor %}\n }\n{% endif %}\n\n{% if varnish_blacklist_enabled %}\n if ((req.url ~ \"{{ varnish_blacklist_regexp }}\")) {\n return(pass);\n } else {\n{% if varnish_discards_client_cookies %}\n unset req.http.Cookie;\n{% endif %}\n }\n{% endif %}\n\n set req.backend_hint = application.backend();\n}\n\n###\n# vcl_hit\n# Called when a cache lookup is successful.\n###\n# The vcl_hit subroutine may terminate with calling return() with one of the following keywords:\n#\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n# deliver\n# Deliver the object. Control passes to vcl_deliver.\n# synth(status code, reason)\n# Return the specified status code to the client and abandon the request.\n###\n\nsub vcl_hit {\n if (obj.ttl > 0s) {\n return (deliver);\n }\n{% if varnish_health_checks_enabled %}\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (fetch);\n }\n{% else %}\n if (obj.ttl + obj.grace > 0s) {\n return (deliver);\n }\n\n return (fetch);\n{% endif %}\n}\n\n###\n# vcl_backend_response\n# Called after the response headers has been successfully retrieved from the backend.\n###\n# The vcl_backend_response subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Possibly insert the object into the cache, then deliver it to the Control will eventually pass to vcl_deliver.\n# abandon\n# Abandon the backend request and generates an error.\n# retry\n# Retry the backend transaction. Increases the retries counter. If the number of retries is higher than max_retries Varnish emits a guru meditation error.\n###\n\nsub vcl_backend_response {\n{% if varnish_blacklist_enabled %}\n if (bereq.url ~ \"{{ varnish_blacklist_regexp }}\") {\n set beresp.http.X-Cacheable = \"NO:Path in Blacklist\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n }\n{% else %}\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n{% endif %}\n\n{% if varnish_cache_diagnostics_enabled %}\n if (bereq.http.Cookie) {\n set beresp.http.X-Cacheable = \"NO:Cookie in Request\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO:Set-Cookie in Response\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.X-No-Cache) {\n set beresp.http.X-Cacheable = \"NO:X-No-Cache\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.ttl <= 0s) {\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n{% endif %}\n\n set beresp.grace = {{ varnish_grace_period }};\n}\n\n###\n# vcl_deliver\n# Called before a cached object is delivered to the client.\n###\n# The vcl_deliver subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Deliver the object to the client.\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n###\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n","old_contents":"vcl 4.0;\n\nimport directors;\nimport std;\n\n###\n# Varnish Documentation\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-built-in-subs.html\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/reference\/vcl.html\n##\n\n{% for backend in varnish_backend_hosts %}\nbackend application_{{ loop.index }} {\n .host = \"{{ backend }}\";\n .port = \"{{ varnish_backend_port }}\";\n{% if varnish_health_checks_enabled %}\n .probe = {\n .url = \"{{ varnish_health_check_url }}\";\n .interval = {{ varnish_health_check_interval }};\n .timeout = {{ varnish_health_check_timeout }};\n .window = {{ varnish_health_check_window }};\n .threshold = {{ varnish_health_check_threshold }};\n }\n{% endif %}\n}\n{% endfor %}\n\n###\n# vcl_init\n# Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n###\n# The vcl_init subroutine may terminate with calling return() with one of the following keywords:\n#\n# ok\n# Normal return, VCL continues loading.\n##\n\nsub vcl_init {\n new application = directors.round_robin();\n{% for backend in varnish_backend_hosts %}\n application.add_backend(application_{{ loop.index }});\n{% endfor %}\n}\n\n###\n# vcl_recv\n# Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use. \n# It is also used to modify the request\n###\n# The vcl_recv subroutine may terminate with calling return() on one of the following keywords:\n#\n# synth(status code, reason)\n# Return a synthetic object with the specified status code to the client and abandon the request.\n# pass\n# Switch to pass mode. Control will eventually pass to vcl_pass.\n# pipe\n# Switch to pipe mode. Control will eventually pass to vcl_pipe.\n# hash\n# Continue processing the object as a potential candidate for caching. Passes the control over to vcl_hash.\n# purge\n# Purge the object and it's variants. Control passes through vcl_hash to vcl_purge.\n#\n\nsub vcl_recv {\n{% if varnish_workaround_telusdotcom_browser_profile %}\n if (req.http.Cookie ~ \"BrowserProfile\") {\n set req.http.X-Language = regsuball(req.http.Cookie, \"language..:\\\\\\\"(.*)\\\\\\\",\", \"\\1\");\n set req.http.X-Province = regsuball(req.http.Cookie, \"region..:\\\\\\\"(.*)\\\\\\\",\", \"\\1\");\n } else {\n if (req.http.Cookie ~ \"lang=\") {\n set req.http.X-Language = regsuball(req.http.Cookie, \"lang=(.*);\", \"\\1\");\n } else {\n set req.http.X-Language = \"en\";\n }\n\n if (req.http.Cookie ~ \"prov=\") {\n set req.http.X-Province = regsuball(req.http.Cookie, \"prov=(.*);\", \"\\1\");\n } else {\n set req.http.X-Province = \"BC\";\n }\n }\n\n if (req.url ~ \"\/(en|fr)\/\") {\n if (req.url ~ \"\/en\/\" && req.http.X-Language != \"en\") {\n return(pass);\n }\n if (req.url ~ \"\/fr\/\" && req.http.X-Language != \"fr\") {\n return(pass);\n }\n }\n\n if (req.url ~ \"\/(ab|bc|mb|nb|nl|ns|nt|nu|on|pe|qc|sk|yt)\/\") {\n {% for province in ['ab', 'bc', 'mb', 'nb', 'nl', 'ns', 'nt', 'nu', 'on', 'pe', 'qc', 'sk', 'yt'] %}\n if (req.url ~ \"{{ province }}\" && req.http.X-Province != \"{{ province }}\") {\n return(pass);\n }\n {% endfor %}\n }\n{% endif %}\n\n{% if varnish_blacklist_enabled %}\n if ((req.url ~ \"{{ varnish_blacklist_regexp }}\")) {\n return(pass);\n } else {\n{% if varnish_discards_client_cookies %}\n unset req.http.Cookie;\n{% endif %}\n }\n{% endif %}\n\n set req.backend_hint = application.backend();\n}\n\n###\n# vcl_hit\n# Called when a cache lookup is successful.\n###\n# The vcl_hit subroutine may terminate with calling return() with one of the following keywords:\n#\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n# deliver\n# Deliver the object. Control passes to vcl_deliver.\n# synth(status code, reason)\n# Return the specified status code to the client and abandon the request.\n###\n\nsub vcl_hit {\n if (obj.ttl > 0s) {\n return (deliver);\n }\n{% if varnish_health_checks_enabled %}\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (fetch);\n }\n{% else %}\n if (obj.ttl + obj.grace > 0s) {\n return (deliver);\n }\n\n return (fetch);\n{% endif %}\n}\n\n###\n# vcl_backend_response\n# Called after the response headers has been successfully retrieved from the backend.\n###\n# The vcl_backend_response subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Possibly insert the object into the cache, then deliver it to the Control will eventually pass to vcl_deliver.\n# abandon\n# Abandon the backend request and generates an error.\n# retry\n# Retry the backend transaction. Increases the retries counter. If the number of retries is higher than max_retries Varnish emits a guru meditation error.\n###\n\nsub vcl_backend_response {\n{% if varnish_blacklist_enabled %}\n if (bereq.url ~ \"{{ varnish_blacklist_regexp }}\") {\n set beresp.http.X-Cacheable = \"NO:Path in Blacklist\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n }\n{% else %}\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n{% endif %}\n\n{% if varnish_cache_diagnostics_enabled %}\n if (bereq.http.Cookie) {\n set beresp.http.X-Cacheable = \"NO:Cookie in Request\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO:Set-Cookie in Response\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.X-No-Cache) {\n set beresp.http.X-Cacheable = \"NO:X-No-Cache\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.ttl <= 0s) {\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n{% endif %}\n\n set beresp.grace = {{ varnish_grace_period }};\n}\n\n###\n# vcl_deliver\n# Called before a cached object is delivered to the client.\n###\n# The vcl_deliver subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Deliver the object to the client.\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n###\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"b0841bb6f7673212dba56302a8769782fb2658f3","subject":"Add 3-legged support; error handling","message":"Add 3-legged support; error handling\n","repos":"rhargreaves\/fastly-vcl-experiments,rhargreaves\/fastly-vcl-experiments","old_file":"oauth_sig_check.vcl","new_file":"oauth_sig_check.vcl","new_contents":"\ntable consumer_secrets {\n\t\"foo\": \"super_secret\"\n}\n\ntable access_tokens {\n\t\"bar\": \"token_secret\"\n}\n\nsub vcl_recv {\n#FASTLY recv\n#DEPLOY recv\n\tset req.http.X-Consumer-Key = if(req.url ~ \"(?i)oauth_consumer_key=([^&]*)\", urldecode(re.group.1), \"\");\n\tif(req.http.X-Consumer-Key == \"\") {\n\t\terror 401 \"Missing Consumer Key\";\n\t}\n\tset req.http.X-Consumer-Secret = table.lookup(consumer_secrets, req.http.X-Consumer-Key);\n\tif(!req.http.X-Consumer-Secret) {\n\t\terror 401 \"Invalid Consumer Key\";\n\t}\n\tset req.http.X-Access-Token = if(req.url ~ \"(?i)oauth_token=([^&]*)\", urldecode(re.group.1), \"\");\n\tif(req.http.X-Access-Token != \"\") {\n\t\tset req.http.X-Access-Token-Secret = table.lookup(access_tokens, req.http.X-Access-Token);\n\t\tif(!req.http.X-Access-Token-Secret) {\n\t\t\terror 401 \"Invalid Access Token\";\n\t\t}\n\t} else {\n\t\tset req.http.X-Access-Token-Secret = \"\";\n\t}\n\tset req.http.X-Provided-Signature = if(req.url ~ \"(?i)oauth_signature=([^&]*)\", urldecode(re.group.1), \"\");\n\tif(req.http.X-Provided-Signature == \"\") {\n\t\terror 401 \"Missing Signature\";\n\t}\n\tset req.http.X-Ordered-Url = boltsort.sort(req.url);\n\tset req.http.X-Parameters = regsub(regsub(req.http.X-Ordered-Url, \".*\\?\", \"\"), \"&oauth_signature=[^&]*\", \"\");\n\tset req.http.X-Base-String-Uri = \n\t\tif(req.http.Fastly-SSL, \"https\", \"http\") \n\t\t\":\/\/\"\n\t\tstd.tolower(req.http.host)\n\t\treq.url.path;\n\tset req.http.X-Signature-Base-String = \n\t\treq.request\n\t\t\"&\"\n\t\turlencode(req.http.X-Base-String-Uri)\n\t\t\"&\"\n\t\turlencode(req.http.X-Parameters);\n\n\tset req.http.X-Calculated-Signature = digest.hmac_sha1_base64(\n\t\t\treq.http.X-Consumer-Secret \"&\" req.http.X-Access-Token-Secret, \n\t\t\treq.http.X-Signature-Base-String);\n\n\tunset req.http.X-Consumer-Secret;\n\tunset req.http.X-Access-Token-Scret;\n\tunset req.http.X-Base-String-Uri;\n\n\tif(req.http.X-Provided-Signature != req.http.X-Calculated-Signature) {\n\t\terror 401 \"Invalid OAuth Signature\";\n\t}\n\n\terror 200 \"Authenticated!\";\n\n\treturn(lookup);\n}\n\nsub vcl_fetch {\n#FASTLY fetch\n\treturn(deliver);\n}\n\nsub vcl_hit {\n#FASTLY hit\n\tif (!obj.cacheable) {\n\t\treturn(pass);\n\t}\n\treturn(deliver);\n}\n\nsub vcl_miss {\n#FASTLY miss\n\treturn(fetch);\n}\n\nsub vcl_deliver{\n#FASTLY deliver\n\tset resp.http.X-Consumer-Key = req.http.X-Consumer-Key;\n\tset resp.http.X-Access-Token = req.http.X-Access-Token;\n\tset resp.http.X-Provided-Signature = req.http.X-Provided-Signature;\n\tset resp.http.X-Calculated-Signature = req.http.X-Calculated-Signature;\n\tset resp.http.X-Parameters = req.http.X-Parameters;\n\tset resp.http.X-Signature-Base-String = req.http.X-Signature-Base-String;\n\treturn(deliver);\n}\n\nsub vcl_error {\n#FASTLY error\n#DEPLOY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n","old_contents":"\ntable consumer_secrets {\n\t\"foo\": \"super_secret\"\n}\n\nsub vcl_recv {\n#FASTLY recv\n#DEPLOY recv\n\tset req.url = boltsort.sort(req.url);\n\tset req.http.X-Consumer-Key = urldecode(regsub(req.url, \"(?i).*oauth_consumer_key=([^&]*).*\", \"\\1\"));\n\tset req.http.X-Consumer-Secret = table.lookup(consumer_secrets, req.http.X-Consumer-Key);\n\tset req.http.X-Provided-Signature = urldecode(regsub(req.url, \"(?i).*oauth_signature=([^&]*).*\", \"\\1\"));\n\tset req.http.X-Parameters = regsub(regsub(req.url, \".*\\?\", \"\"), \"&oauth_signature=[^&]*\", \"\");\n\tset req.http.X-Base-String-Uri = \n\t\tif(req.http.Fastly-SSL, \"https\", \"http\") \n\t\t\":\/\/\"\n\t\tstd.tolower(req.http.host)\n\t\treq.url.path;\n\n\t# Construct according to https:\/\/tools.ietf.org\/html\/rfc5849#page-18\n\tset req.http.X-Signature-Base-String = \n\t\treq.request\n\t\t\"&\"\n\t\turlencode(req.http.X-Base-String-Uri)\n\t\t\"&\"\n\t\turlencode(req.http.X-Parameters);\n\n\tset req.http.X-Calculated-Signature = digest.hmac_sha1_base64(\n\t\treq.http.X-Consumer-Secret \"&\", req.http.X-Signature-Base-String);\n\n\tunset req.http.X-Consumer-Secret;\n\tunset req.http.X-Base-String-Uri;\n\n\tif(req.http.X-Provided-Signature != req.http.X-Calculated-Signature) {\n\t\terror 401 \"Invalid OAuth signature\";\n\t}\n\n\n\treturn(lookup);\n}\n\nsub vcl_fetch {\n#FASTLY fetch\n\treturn(deliver);\n}\n\nsub vcl_hit {\n#FASTLY hit\n\tif (!obj.cacheable) {\n\t\treturn(pass);\n\t}\n\treturn(deliver);\n}\n\nsub vcl_miss {\n#FASTLY miss\n\treturn(fetch);\n}\n\nsub vcl_deliver{\n#FASTLY deliver\n\tset resp.http.X-Consumer-Key = req.http.X-Consumer-Key;\n\tset resp.http.X-Provided-Signature = req.http.X-Provided-Signature;\n\tset resp.http.X-Calculated-Signature = req.http.X-Calculated-Signature;\n\tset resp.http.X-Parameters = req.http.X-Parameters;\n\tset resp.http.X-Signature-Base-String = req.http.X-Signature-Base-String;\n\treturn(deliver);\n}\n\nsub vcl_error {\n#FASTLY error\n#DEPLOY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"fca98929db38f8283b3f727cabc00e31657c7190","subject":"Bug 1151803 - Vagrant: Remove socketio remnant from Varnish config","message":"Bug 1151803 - Vagrant: Remove socketio remnant from Varnish config\n\nLeftover from bug 1076710.\n","repos":"vaishalitekale\/treeherder,avih\/treeherder,tojon\/treeherder,tojonmz\/treeherder,avih\/treeherder,jgraham\/treeherder,wlach\/treeherder,vaishalitekale\/treeherder,deathping1994\/treeherder,parkouss\/treeherder,wlach\/treeherder,akhileshpillai\/treeherder,jgraham\/treeherder,adusca\/treeherder,edmorley\/treeherder,akhileshpillai\/treeherder,sylvestre\/treeherder,vaishalitekale\/treeherder,sylvestre\/treeherder,KWierso\/treeherder,rail\/treeherder,glenn124f\/treeherder,glenn124f\/treeherder,rail\/treeherder,edmorley\/treeherder,moijes12\/treeherder,moijes12\/treeherder,moijes12\/treeherder,kapy2010\/treeherder,tojon\/treeherder,kapy2010\/treeherder,jgraham\/treeherder,sylvestre\/treeherder,deathping1994\/treeherder,jgraham\/treeherder,parkouss\/treeherder,tojonmz\/treeherder,KWierso\/treeherder,edmorley\/treeherder,tojonmz\/treeherder,tojon\/treeherder,sylvestre\/treeherder,vaishalitekale\/treeherder,rail\/treeherder,deathping1994\/treeherder,sylvestre\/treeherder,vaishalitekale\/treeherder,KWierso\/treeherder,tojonmz\/treeherder,moijes12\/treeherder,parkouss\/treeherder,parkouss\/treeherder,adusca\/treeherder,vaishalitekale\/treeherder,akhileshpillai\/treeherder,adusca\/treeherder,tojonmz\/treeherder,wlach\/treeherder,wlach\/treeherder,kapy2010\/treeherder,gbrmachado\/treeherder,parkouss\/treeherder,edmorley\/treeherder,glenn124f\/treeherder,rail\/treeherder,avih\/treeherder,kapy2010\/treeherder,avih\/treeherder,jgraham\/treeherder,glenn124f\/treeherder,gbrmachado\/treeherder,avih\/treeherder,parkouss\/treeherder,rail\/treeherder,gbrmachado\/treeherder,sylvestre\/treeherder,jgraham\/treeherder,moijes12\/treeherder,deathping1994\/treeherder,glenn124f\/treeherder,deathping1994\/treeherder,adusca\/treeherder,adusca\/treeherder,akhileshpillai\/treeherder,deathping1994\/treeherder,akhileshpillai\/treeherder,KWierso\/treeherder,wlach\/treeherder,gbrmachado\/treeherder,wlach\/treeherder,gbrmachado\/treeherder,moijes12\/treeherder,tojon\/treeherder,akhileshpillai\/treeherder,tojonmz\/treeherder,adusca\/treeherder,glenn124f\/treeherder,avih\/treeherder,kapy2010\/treeherder,gbrmachado\/treeherder,rail\/treeherder","old_file":"puppet\/files\/varnish\/default.vcl","new_file":"puppet\/files\/varnish\/default.vcl","new_contents":"\/* This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, you can obtain one at http:\/\/mozilla.org\/MPL\/2.0\/. *\/\n\nbackend apache {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\n\nsub vcl_recv {\n set req.backend = apache;\n return (pass);\n}\n\nsub vcl_fetch {\n if (beresp.http.content-type ~ \"json\" || beresp.http.content-type ~ \"text\" ) {\n set beresp.do_gzip = true;\n }\n}\n","old_contents":"\/* This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, you can obtain one at http:\/\/mozilla.org\/MPL\/2.0\/. *\/\n\nbackend apache {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\nsub vcl_pipe {\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n}\nsub vcl_recv {\n set req.backend = apache;\n return (pass);\n}\n\nsub vcl_fetch {\n if (beresp.http.content-type ~ \"json\" || beresp.http.content-type ~ \"text\" ) {\n set beresp.do_gzip = true;\n }\n}\n","returncode":0,"stderr":"","license":"mpl-2.0","lang":"VCL"} {"commit":"dd6d17efc9150af7843b7dc52854c1543e3da128","subject":"Fix TLS redirect, fixes #707","message":"Fix TLS redirect, fixes #707\n","repos":"mcshaz\/polyfill-service,kdzwinel\/polyfill-service,jonathan-fielding\/polyfill-service,kdzwinel\/polyfill-service,JakeChampion\/polyfill-service,JakeChampion\/polyfill-service,mcshaz\/polyfill-service,mcshaz\/polyfill-service,kdzwinel\/polyfill-service,jonathan-fielding\/polyfill-service,jonathan-fielding\/polyfill-service","old_file":"fastly-config.vcl","new_file":"fastly-config.vcl","new_contents":"sub vcl_recv {\n#FASTLY recv\n\n\tif (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n\t\treturn(pass);\n\t}\n\n\tif (!req.http.Fastly-SSL && req.http.Host == \"cdn.polyfill.io\") {\n\t\terror 751 \"Force TLS\";\n\t}\n\n\tif (req.url ~ \"^\/v2\/polyfill\\.\" && req.url !~ \"[\\?\\&]ua=\") {\n\t\tset req.http.X-Orig-URL = req.url;\n\t\tset req.url = \"\/v2\/normalizeUa?ua=\" urlencode(req.http.User-Agent);\n\t}\n\n\treturn(lookup);\n}\n\nsub vcl_deliver {\n#FASTLY deliver\n\n\t# If the response is to a normalise request and there's a parked \"original request\", use the normalised UA response to modify the original request and restart it\n\tif (req.url ~ \"^\/v\\d\/normalizeUa\" && resp.status == 200 && req.http.X-Orig-URL) {\n\t\tset req.http.Fastly-force-Shield = \"1\";\n\t\tif (req.http.X-Orig-URL ~ \"\\?\") {\n\t\t\tset req.url = req.http.X-Orig-URL \"&ua=\" resp.http.Normalized-User-Agent;\n\t\t} else {\n\t\t\tset req.url = req.http.X-Orig-URL \"?ua=\" resp.http.Normalized-User-Agent;\n\t\t}\n\t\trestart;\n\n\t# If the original request didn't specify a UA override, and we added one when the request was sent to the backend, the backend won't have included a Vary:user-agent header (correctly) but we need to add one\n\t} else if (req.url ~ \"^\/v\\d\/polyfill\\..*[\\?\\&]ua=\" && req.http.X-Orig-URL && req.http.X-Orig-URL !~ \"[\\?\\&]ua=\") {\n\t\tadd resp.http.Vary = \"User-Agent\";\n\t}\n\treturn(deliver);\n}\n\nsub vcl_error {\n\n\t# Redirect to SSL\n\tif (obj.status == 751) {\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\tset obj.http.Location = \"https:\/\/\" req.http.host req.url;\n\t\tsynthetic {\"\"};\n\t\treturn (deliver);\n\t}\n}\n","old_contents":"sub vcl_recv {\n#FASTLY recv\n\n\tif (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n\t\treturn(pass);\n\t}\n\n\tif (req.url ~ \"^\/v2\/polyfill\\.\" && req.url !~ \"[\\?\\&]ua=\") {\n\t\tset req.http.X-Orig-URL = req.url;\n\t\tset req.url = \"\/v2\/normalizeUa?ua=\" urlencode(req.http.User-Agent);\n\t}\n\n\tif (!req.http.Fastly-SSL && req.http.Host == \"cdn.polyfill.io\") {\n\t\terror 751 \"Force TLS\";\n\t}\n\n\treturn(lookup);\n}\n\nsub vcl_deliver {\n#FASTLY deliver\n\n\t# If the response is to a normalise request and there's a parked \"original request\", use the normalised UA response to modify the original request and restart it\n\tif (req.url ~ \"^\/v\\d\/normalizeUa\" && resp.status == 200 && req.http.X-Orig-URL) {\n\t\tset req.http.Fastly-force-Shield = \"1\";\n\t\tif (req.http.X-Orig-URL ~ \"\\?\") {\n\t\t\tset req.url = req.http.X-Orig-URL \"&ua=\" resp.http.Normalized-User-Agent;\n\t\t} else {\n\t\t\tset req.url = req.http.X-Orig-URL \"?ua=\" resp.http.Normalized-User-Agent;\n\t\t}\n\t\trestart;\n\n\t# If the original request didn't specify a UA override, and we added one when the request was sent to the backend, the backend won't have included a Vary:user-agent header (correctly) but we need to add one\n\t} else if (req.url ~ \"^\/v\\d\/polyfill\\..*[\\?\\&]ua=\" && req.http.X-Orig-URL && req.http.X-Orig-URL !~ \"[\\?\\&]ua=\") {\n\t\tadd resp.http.Vary = \"User-Agent\";\n\t}\n\treturn(deliver);\n}\n\nsub vcl_error {\n\n\t# Redirect to SSL\n\tif (obj.status == 751) {\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\tset obj.http.Location = \"https:\/\/\" req.http.host req.url;\n\t\tsynthetic {\"\"};\n\t\treturn (deliver);\n\t}\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"98a44d43efd854230506c1349d6ca846274e066b","subject":"don't discard request body","message":"don't discard request body\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets_rate_limiting\/recv.vcl","new_file":"etc\/vcl_snippets_rate_limiting\/recv.vcl","new_contents":"if (####RATE_LIMITED_PATHS####) {\n set req.http.Rate-Limit = \"1\";\n set req.http.X-Orig-Method = req.method;\n set req.hash_ignore_busy = true;\n if (req.method !~ \"^(GET|POST)$\") {\n set req.method = \"POST\";\n }\n}\n","old_contents":"if (####RATE_LIMITED_PATHS####) {\n set req.http.Rate-Limit = \"1\";\n set req.http.X-Orig-Method = req.method;\n set req.hash_ignore_busy = true;\n}\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"34ce45ec65b0a5f74073ec8f617e8e66e623c031","subject":"add removal of legacy GA cookies to default.vcl","message":"add removal of legacy GA cookies to default.vcl\n","repos":"xini\/silverstripe-section-io","old_file":"default.vcl","new_file":"default.vcl","new_contents":"# See the VCL chapters in the Users Guide at https:\/\/www.varnish-cache.org\/docs\/\n# and http:\/\/varnish-cache.org\/trac\/wiki\/VCLExamples for more examples.\n\n# Marker to tell the VCL compiler that this VCL has been adapted to the\n# new 4.0 format.\nvcl 4.0;\n\nbackend default {\n\t.host = \"next-hop\";\n\t.port = \"80\";\n}\n\nsub vcl_recv {\n\t# Happens before we check if we have this in cache already.\n\t#\n\t# Typically you clean up the request here, removing cookies you don't need,\n\t# rewriting the request, etc.\n\t\n\t# clean up accept-encoding\n\tif (req.http.Accept-Encoding) {\n\t\tif (req.http.Accept-Encoding ~ \"gzip\") {\n\t\t\tset req.http.Accept-Encoding = \"gzip\";\n\t\t} else if (req.http.Accept-Encoding ~ \"deflate\") {\n\t\t\tset req.http.Accept-Encoding = \"deflate\";\n\t\t} else {\n\t\t\tunset req.http.Accept-Encoding;\n\t\t}\n\t}\t\n\t\n\t# remove cookies for static content based on \/assets\/.htaccess\n\tif (req.url ~ \".*\\.(?:js|css|bmp|png|gif|jpg|jpeg|ico|pcx|tif|tiff|au|mid|midi|mpa|mp3|ogg|m4a|ra|wma|wav|cda|avi|mpg|mpeg|asf|wmv|m4v|mov|mkv|mp4|ogv|webm|swf|flv|ram|rm|doc|docx|txt|rtf|xls|xlsx|pages|ppt|pptx|pps|csv|cab|arj|tar|zip|zipx|sit|sitx|gz|tgz|bz2|ace|arc|pkg|dmg|hqx|jar|pdf|woff|eot|ttf|otf|svg)(?=\\?|&|$)\") {\n\t\tunset req.http.Cookie;\n\t\treturn (hash);\n\t}\n\t\n\t# ss admin\n\tif (req.url ~ \"^\/(Security|admin|dev)\" || req.url ~ \"stage=\") {\n\t\treturn (pass);\n\t}\n\t\n\t# ss multistep form\n\tif( req.url ~ \"MultiFormSessionID=\" ) {\n\t\treturn (pass);\n\t}\n\t\n\t# check for login cookie\n\tif ( req.http.Cookie ~ \"sslogin=\" ) {\n\t\treturn (pass);\n\t}\n\t\n\t# remove tracking cookies\n\tif (req.http.Cookie) {\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|(?<=; )) *__utm.=[^;]+;? *\", \"\\1\"); # standard ga cookies\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|;\\s*)(_dc_gtm_[A-Z0-9\\-]+)=[^;]*\", \"\"); # gtm cookies\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|;\\s*)(_ga)=[^;]*\", \"\"); # gtm ga cookies\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|;\\s*)(_gat)=[^;]*\", \"\"); # legacy ga cookies\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|;\\s*)(AUA[0-9]+)=[^;]*\", \"\"); # avanser phone tracking cookies\n\n\t\tif (req.http.Cookie == \"\") {\n\t\t\tunset req.http.Cookie;\n\t\t}\n\t}\n\t\n\t# remove adwords gclid parameter\n\tset req.url = regsuball(req.url,\"\\?gclid=[^&]+$\",\"\"); # strips when QS = \"?gclid=AAA\"\n\tset req.url = regsuball(req.url,\"\\?gclid=[^&]+&\",\"?\"); # strips when QS = \"?gclid=AAA&foo=bar\"\n\tset req.url = regsuball(req.url,\"&gclid=[^&]+\",\"\"); # strips when QS = \"?foo=bar&gclid=AAA\" or QS = \"?foo=bar&gclid=AAA&bar=baz\"\n\t\n}\n\nsub vcl_backend_fetch {\n\t# Called before sending the backend request.\n\t#\n\t# Typically you alter the request for the backend here. Overriding to the\n\t# required hostname, upstream Proto matching, etc\n\t\n}\n\nsub vcl_backend_response {\n\t# Happens after we have read the response headers from the backend.\n\t#\n\t# Here you clean the response headers, removing silly Set-Cookie headers\n\t# and other mistakes your backend does.\n\t\n\t# cache static content\n\t# css & js\n\tif (bereq.url ~ \".*\\.(?:css|js)(?=\\?|&|$)\") { \n\t\tset beresp.ttl = 604800s; # The number of seconds to cache inside Varnish: 1 week\n\t\tset beresp.http.Cache-Control = \"public, max-age=604800\"; # The number of seconds to cache in browser: 1 week\n\t}\n\t# images, audio, video\n\tif (bereq.url ~ \".*\\.(?:bmp|png|gif|jpg|jpeg|ico|pcx|tif|tiff|au|mid|midi|mpa|mp3|ogg|m4a|ra|wma|wav|cda|avi|mpg|mpeg|asf|wmv|m4v|mov|mkv|mp4|ogv|webm|swf|flv|ram|rm)(?=\\?|&|$)\") {\n\t\tset beresp.ttl = 2592000s; # The number of seconds to cache inside Varnish: 1 month\n\t\tset beresp.http.Cache-Control = \"public, max-age=2592000\"; # The number of seconds to cache in browser: 1 month\n\t}\n\t# docs and archives\n\tif (bereq.url ~ \".*\\.(?:doc|docx|txt|rtf|xls|xlsx|pages|ppt|pptx|pps|csv|cab|arj|tar|zip|zipx|sit|sitx|gz|tgz|bz2|ace|arc|pkg|dmg|hqx|jar|pdf)(?=\\?|&|$)\") {\n\t\tset beresp.ttl = 2592000s; # The number of seconds to cache inside Varnish: 1 month\n\t\tset beresp.http.Cache-Control = \"public, max-age=2592000\"; # The number of seconds to cache in browser: 1 month\n\t}\n\t# fonts\n\tif (bereq.url ~ \".*\\.(?:woff|eot|ttf|otf|svg)(?=\\?|&|$)\") {\n\t\tset beresp.ttl = 2592000s; # The number of seconds to cache inside Varnish: 1 month\n\t\tset beresp.http.Cache-Control = \"public, max-age=2592000\"; # The number of seconds to cache in browser: 1 month\n\t}\n\t\n\t# set cache control header for pages\n if (beresp.http.Content-Type ~ \"^text\/html\" && !(bereq.url ~ \"^\/(Security|admin|dev)\") && !(bereq.http.Cookie ~ \"sslogin=\") && !(beresp.http.Pragma ~ \"no-cache\") ) {\n\t\t set beresp.ttl = 3600s;\n\t\t set beresp.http.Cache-Control = \"public, max-age=600\";\n }\n\t\n\t# set grace period\n\tset beresp.grace = 1d;\n\t\n\t### DO NOT CHANGE ###\n\t# store url in cached object to use in ban()\n\tset beresp.http.x-url = bereq.url;\n\t\n}\n\nsub vcl_deliver {\n\t# Happens when we have all the pieces we need, and are about to send the\n\t# response to the client.\n\t#\n\t# You can do accounting or modifying the final object here.\n\t\n\t# add cache response header\n\tif (obj.hits > 0) {\n\t\tset resp.http.X-Cache = \"HIT\";\n\t} else {\n\t\tset resp.http.X-Cache = \"MISS\";\n\t}\n\t\n\t### DO NOT CHANGE ###\n\t# remove saved url from object before delivery\n\tunset resp.http.x-url;\n\t\n}\n\nsub vcl_hit {\n\t# deliver if ttl > 0, normal hit\n\tif (obj.ttl >= 0s) {\n\t\treturn (deliver);\n\t}\n\t# deliver if ttl = 0 but grace still on\n\tif (obj.ttl + obj.grace > 0s) {\n\t\treturn (deliver);\n\t}\n\t# fetch new content\n\treturn (fetch);\n}","old_contents":"# See the VCL chapters in the Users Guide at https:\/\/www.varnish-cache.org\/docs\/\n# and http:\/\/varnish-cache.org\/trac\/wiki\/VCLExamples for more examples.\n\n# Marker to tell the VCL compiler that this VCL has been adapted to the\n# new 4.0 format.\nvcl 4.0;\n\nbackend default {\n\t.host = \"next-hop\";\n\t.port = \"80\";\n}\n\nsub vcl_recv {\n\t# Happens before we check if we have this in cache already.\n\t#\n\t# Typically you clean up the request here, removing cookies you don't need,\n\t# rewriting the request, etc.\n\t\n\t# clean up accept-encoding\n\tif (req.http.Accept-Encoding) {\n\t\tif (req.http.Accept-Encoding ~ \"gzip\") {\n\t\t\tset req.http.Accept-Encoding = \"gzip\";\n\t\t} else if (req.http.Accept-Encoding ~ \"deflate\") {\n\t\t\tset req.http.Accept-Encoding = \"deflate\";\n\t\t} else {\n\t\t\tunset req.http.Accept-Encoding;\n\t\t}\n\t}\t\n\t\n\t# remove cookies for static content based on \/assets\/.htaccess\n\tif (req.url ~ \".*\\.(?:js|css|bmp|png|gif|jpg|jpeg|ico|pcx|tif|tiff|au|mid|midi|mpa|mp3|ogg|m4a|ra|wma|wav|cda|avi|mpg|mpeg|asf|wmv|m4v|mov|mkv|mp4|ogv|webm|swf|flv|ram|rm|doc|docx|txt|rtf|xls|xlsx|pages|ppt|pptx|pps|csv|cab|arj|tar|zip|zipx|sit|sitx|gz|tgz|bz2|ace|arc|pkg|dmg|hqx|jar|pdf|woff|eot|ttf|otf|svg)(?=\\?|&|$)\") {\n\t\tunset req.http.Cookie;\n\t\treturn (hash);\n\t}\n\t\n\t# ss admin\n\tif (req.url ~ \"^\/(Security|admin|dev)\" || req.url ~ \"stage=\") {\n\t\treturn (pass);\n\t}\n\t\n\t# ss multistep form\n\tif( req.url ~ \"MultiFormSessionID=\" ) {\n\t\treturn (pass);\n\t}\n\t\n\t# check for login cookie\n\tif ( req.http.Cookie ~ \"sslogin=\" ) {\n\t\treturn (pass);\n\t}\n\t\n\t# remove tracking cookies\n\tif (req.http.Cookie) {\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|(?<=; )) *__utm.=[^;]+;? *\", \"\\1\"); # standard ga cookies\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|;\\s*)(_dc_gtm_[A-Z0-9\\-]+)=[^;]*\", \"\"); # gtm cookies\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|;\\s*)(_ga)=[^;]*\", \"\"); # gtm ga cookies\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|;\\s*)(AUA[0-9]+)=[^;]*\", \"\"); # avanser phone tracking cookies\n\n\t\tif (req.http.Cookie == \"\") {\n\t\t\tunset req.http.Cookie;\n\t\t}\n\t}\n\t\n\t# remove adwords gclid parameter\n\tset req.url = regsuball(req.url,\"\\?gclid=[^&]+$\",\"\"); # strips when QS = \"?gclid=AAA\"\n\tset req.url = regsuball(req.url,\"\\?gclid=[^&]+&\",\"?\"); # strips when QS = \"?gclid=AAA&foo=bar\"\n\tset req.url = regsuball(req.url,\"&gclid=[^&]+\",\"\"); # strips when QS = \"?foo=bar&gclid=AAA\" or QS = \"?foo=bar&gclid=AAA&bar=baz\"\n\t\n}\n\nsub vcl_backend_fetch {\n\t# Called before sending the backend request.\n\t#\n\t# Typically you alter the request for the backend here. Overriding to the\n\t# required hostname, upstream Proto matching, etc\n\t\n}\n\nsub vcl_backend_response {\n\t# Happens after we have read the response headers from the backend.\n\t#\n\t# Here you clean the response headers, removing silly Set-Cookie headers\n\t# and other mistakes your backend does.\n\t\n\t# cache static content\n\t# css & js\n\tif (bereq.url ~ \".*\\.(?:css|js)(?=\\?|&|$)\") { \n\t\tset beresp.ttl = 604800s; # The number of seconds to cache inside Varnish: 1 week\n\t\tset beresp.http.Cache-Control = \"public, max-age=604800\"; # The number of seconds to cache in browser: 1 week\n\t}\n\t# images, audio, video\n\tif (bereq.url ~ \".*\\.(?:bmp|png|gif|jpg|jpeg|ico|pcx|tif|tiff|au|mid|midi|mpa|mp3|ogg|m4a|ra|wma|wav|cda|avi|mpg|mpeg|asf|wmv|m4v|mov|mkv|mp4|ogv|webm|swf|flv|ram|rm)(?=\\?|&|$)\") {\n\t\tset beresp.ttl = 2592000s; # The number of seconds to cache inside Varnish: 1 month\n\t\tset beresp.http.Cache-Control = \"public, max-age=2592000\"; # The number of seconds to cache in browser: 1 month\n\t}\n\t# docs and archives\n\tif (bereq.url ~ \".*\\.(?:doc|docx|txt|rtf|xls|xlsx|pages|ppt|pptx|pps|csv|cab|arj|tar|zip|zipx|sit|sitx|gz|tgz|bz2|ace|arc|pkg|dmg|hqx|jar|pdf)(?=\\?|&|$)\") {\n\t\tset beresp.ttl = 2592000s; # The number of seconds to cache inside Varnish: 1 month\n\t\tset beresp.http.Cache-Control = \"public, max-age=2592000\"; # The number of seconds to cache in browser: 1 month\n\t}\n\t# fonts\n\tif (bereq.url ~ \".*\\.(?:woff|eot|ttf|otf|svg)(?=\\?|&|$)\") {\n\t\tset beresp.ttl = 2592000s; # The number of seconds to cache inside Varnish: 1 month\n\t\tset beresp.http.Cache-Control = \"public, max-age=2592000\"; # The number of seconds to cache in browser: 1 month\n\t}\n\t\n\t# set cache control header for pages\n if (beresp.http.Content-Type ~ \"^text\/html\" && !(bereq.url ~ \"^\/(Security|admin|dev)\") && !(bereq.http.Cookie ~ \"sslogin=\") && !(beresp.http.Pragma ~ \"no-cache\") ) {\n\t\t set beresp.ttl = 3600s;\n\t\t set beresp.http.Cache-Control = \"public, max-age=600\";\n }\n\t\n\t# set grace period\n\tset beresp.grace = 1d;\n\t\n\t### DO NOT CHANGE ###\n\t# store url in cached object to use in ban()\n\tset beresp.http.x-url = bereq.url;\n\t\n}\n\nsub vcl_deliver {\n\t# Happens when we have all the pieces we need, and are about to send the\n\t# response to the client.\n\t#\n\t# You can do accounting or modifying the final object here.\n\t\n\t# add cache response header\n\tif (obj.hits > 0) {\n\t\tset resp.http.X-Cache = \"HIT\";\n\t} else {\n\t\tset resp.http.X-Cache = \"MISS\";\n\t}\n\t\n\t### DO NOT CHANGE ###\n\t# remove saved url from object before delivery\n\tunset resp.http.x-url;\n\t\n}\n\nsub vcl_hit {\n\t# deliver if ttl > 0, normal hit\n\tif (obj.ttl >= 0s) {\n\t\treturn (deliver);\n\t}\n\t# deliver if ttl = 0 but grace still on\n\tif (obj.ttl + obj.grace > 0s) {\n\t\treturn (deliver);\n\t}\n\t# fetch new content\n\treturn (fetch);\n}","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"ff6b518f712bff6be596d41f1b0630aadfc60b74","subject":"fix bug caching with php session id","message":"fix bug caching with php session id","repos":"Arasaac\/dockerizePHPApp,Arasaac\/dockerizePHPApp,Arasaac\/dockerizePHPApp,Arasaac\/dockerizePHPApp,Arasaac\/dockerizePHPApp,Arasaac\/dockerizePHPApp","old_file":"varnish\/default.vcl","new_file":"varnish\/default.vcl","new_contents":"","old_contents":"","returncode":0,"stderr":"unknown","license":"mit","lang":"VCL"} {"commit":"1b157868c772baa24d136c40b968227b276d21af","subject":"Remove old varnish VCL","message":"Remove old varnish VCL\n\nReplaced with docker\/default.vcl.\n","repos":"mmb\/meme_captain_web,mmb\/meme_captain_web,mmb\/meme_captain_web,mmb\/meme_captain_web","old_file":"varnish\/default.vcl","new_file":"varnish\/default.vcl","new_contents":"","old_contents":"sub vcl_recv {\n if (req.request == \"GET\" &&\n req.url ~ \"^\/((gend|src)_thumbs\/\\d+|(gend|src)_images\/[\\w-]{6,})$\") {\n unset req.http.Cookie;\n }\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"91518ade7438da61c393e8b7cf215ffb0c40b4c7","subject":"Import fresh devicedetect.vcl","message":"Import fresh devicedetect.vcl\n","repos":"chrismoulton\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,chrismoulton\/Varnish-Cache,alarky\/varnish-cache-doc-ja,zhoualbeart\/Varnish-Cache,alarky\/varnish-cache-doc-ja,varnish\/Varnish-Cache,franciscovg\/Varnish-Cache,chrismoulton\/Varnish-Cache,mrhmouse\/Varnish-Cache,mrhmouse\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,alarky\/varnish-cache-doc-ja,feld\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,mrhmouse\/Varnish-Cache,feld\/Varnish-Cache,mrhmouse\/Varnish-Cache,feld\/Varnish-Cache,chrismoulton\/Varnish-Cache,feld\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,feld\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,gquintard\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,franciscovg\/Varnish-Cache,gquintard\/Varnish-Cache,franciscovg\/Varnish-Cache,alarky\/varnish-cache-doc-ja,franciscovg\/Varnish-Cache,mrhmouse\/Varnish-Cache,gquintard\/Varnish-Cache,zhoualbeart\/Varnish-Cache,gquintard\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,varnish\/Varnish-Cache,zhoualbeart\/Varnish-Cache,zhoualbeart\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,alarky\/varnish-cache-doc-ja,gauthier-delacroix\/Varnish-Cache,chrismoulton\/Varnish-Cache,varnish\/Varnish-Cache,zhoualbeart\/Varnish-Cache,varnish\/Varnish-Cache,varnish\/Varnish-Cache,franciscovg\/Varnish-Cache","old_file":"etc\/devicedetect.vcl","new_file":"etc\/devicedetect.vcl","new_contents":"# Copyright (c) 2012-2014 Varnish Software AS\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions\n# are met:\n# 1. Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n# 2. Redistributions in binary form must reproduce the above copyright\n# notice, this list of conditions and the following disclaimer in the\n# documentation and\/or other materials provided with the distribution.\n#\n# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n# ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n# SUCH DAMAGE.\n#\n# detectdevice.vcl - regex based device detection for Varnish\n# http:\/\/github.com\/varnish\/varnish-devicedetect\/\n#\n# Author: Lasse Karstensen <lasse@varnish-software.com>\n\nsub devicedetect {\n\tunset req.http.X-UA-Device;\n\tset req.http.X-UA-Device = \"pc\";\n\n\t# Handle that a cookie may override the detection alltogether.\n\tif (req.http.Cookie ~ \"(?i)X-UA-Device-force\") {\n\t\t\/* ;?? means zero or one ;, non-greedy to match the first. *\/\n\t\tset req.http.X-UA-Device = regsub(req.http.Cookie, \"(?i).*X-UA-Device-force=([^;]+);??.*\", \"\\1\");\n\t\t\/* Clean up our mess in the cookie header *\/\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|; ) *X-UA-Device-force=[^;]+;? *\", \"\\1\");\n\t\t\/* If the cookie header is now empty, or just whitespace, unset it. *\/\n\t\tif (req.http.Cookie ~ \"^ *$\") { unset req.http.Cookie; }\n\t} else {\n\t\tif (req.http.User-Agent ~ \"(?i)(ads|google|bing|msn|yandex|baidu|ro|career|)bot\" ||\n\t\t req.http.User-Agent ~ \"(?i)(baidu|jike|symantec)spider\" ||\n\t\t req.http.User-Agent ~ \"(?i)scanner\" ||\n\t\t req.http.User-Agent ~ \"(?i)(web)crawler\") {\n\t\t\tset req.http.X-UA-Device = \"bot\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ipad\") { set req.http.X-UA-Device = \"tablet-ipad\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ip(hone|od)\") { set req.http.X-UA-Device = \"mobile-iphone\"; }\n\t\t\/* how do we differ between an android phone and an android tablet?\n\t\t http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent *\/\n\t\telsif (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") { set req.http.X-UA-Device = \"mobile-android\"; }\n\t\t\/\/ android 3\/honeycomb was just about tablet-only, and any phones will probably handle a bigger page layout.\n\t\telsif (req.http.User-Agent ~ \"(?i)android 3\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\t\/* see http:\/\/my.opera.com\/community\/openweb\/idopera\/ *\/\n\t\telsif (req.http.User-Agent ~ \"Opera Mobi\") { set req.http.X-UA-Device = \"mobile-smartphone\"; }\n\t\t\/\/ May very well give false positives towards android tablets. Suggestions welcome.\n\t\telsif (req.http.User-Agent ~ \"(?i)android\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\telsif (req.http.User-Agent ~ \"PlayBook; U; RIM Tablet\") { set req.http.X-UA-Device = \"tablet-rim\"; }\n\t\telsif (req.http.User-Agent ~ \"hp-tablet.*TouchPad\") { set req.http.X-UA-Device = \"tablet-hp\"; }\n\t\telsif (req.http.User-Agent ~ \"Kindle\/3\") { set req.http.X-UA-Device = \"tablet-kindle\"; }\n\t\telsif (req.http.User-Agent ~ \"Mobile.+Firefox\") { set req.http.X-UA-Device = \"mobile-firefoxos\"; }\n\t\telsif (req.http.User-Agent ~ \"^HTC\" ||\n\t\t req.http.User-Agent ~ \"Fennec\" ||\n\t\t req.http.User-Agent ~ \"IEMobile\" ||\n\t\t req.http.User-Agent ~ \"BlackBerry\" ||\n\t\t req.http.User-Agent ~ \"BB10.*Mobile\" ||\n\t\t req.http.User-Agent ~ \"GT-.*Build\/GINGERBREAD\" ||\n\t\t req.http.User-Agent ~ \"SymbianOS.*AppleWebKit\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-smartphone\";\n\t\t}\n\t\telsif (req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)^sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)^nokia\" ||\n\t\t req.http.User-Agent ~ \"(?i)^samsung\" ||\n\t\t req.http.User-Agent ~ \"(?i)^lg\" ||\n\t\t req.http.User-Agent ~ \"(?i)bada\" ||\n\t\t req.http.User-Agent ~ \"(?i)blazer\" ||\n\t\t req.http.User-Agent ~ \"(?i)cellphone\" ||\n\t\t req.http.User-Agent ~ \"(?i)iemobile\" ||\n\t\t req.http.User-Agent ~ \"(?i)midp-2.0\" ||\n\t\t req.http.User-Agent ~ \"(?i)u990\" ||\n\t\t req.http.User-Agent ~ \"(?i)netfront\" ||\n\t\t req.http.User-Agent ~ \"(?i)opera mini\" ||\n\t\t req.http.User-Agent ~ \"(?i)palm\" ||\n\t\t req.http.User-Agent ~ \"(?i)nintendo wii\" ||\n\t\t req.http.User-Agent ~ \"(?i)playstation portable\" ||\n\t\t req.http.User-Agent ~ \"(?i)portalmmm\" ||\n\t\t req.http.User-Agent ~ \"(?i)proxinet\" ||\n\t\t req.http.User-Agent ~ \"(?i)sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)windows\\ ?ce\" ||\n\t\t req.http.User-Agent ~ \"(?i)winwap\" ||\n\t\t req.http.User-Agent ~ \"(?i)eudoraweb\" ||\n\t\t req.http.User-Agent ~ \"(?i)htc\" ||\n\t\t req.http.User-Agent ~ \"(?i)240x320\" ||\n\t\t req.http.User-Agent ~ \"(?i)avantgo\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-generic\";\n\t\t}\n\t}\n}\n","old_contents":"# Copyright (c) 2012-2014 Varnish Software AS\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions\n# are met:\n# 1. Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n# 2. Redistributions in binary form must reproduce the above copyright\n# notice, this list of conditions and the following disclaimer in the\n# documentation and\/or other materials provided with the distribution.\n#\n# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n# ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n# SUCH DAMAGE.\n#\n# detectdevice.vcl - regex based device detection for Varnish\n# http:\/\/github.com\/varnish\/varnish-devicedetect\/\n#\n# Author: Lasse Karstensen <lasse@varnish-software.com>\n\nsub devicedetect {\n\tunset req.http.X-UA-Device;\n\tset req.http.X-UA-Device = \"pc\";\n\n\t# Handle that a cookie may override the detection alltogether.\n\tif (req.http.Cookie ~ \"(?i)X-UA-Device-force\") {\n\t\t\/* ;?? means zero or one ;, non-greedy to match the first. *\/\n\t\tset req.http.X-UA-Device = regsub(req.http.Cookie, \"(?i).*X-UA-Device-force=([^;]+);??.*\", \"\\1\");\n\t\t\/* Clean up our mess in the cookie header *\/\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|; ) *X-UA-Device-force=[^;]+;? *\", \"\\1\");\n\t\t\/* If the cookie header is now empty, or just whitespace, unset it. *\/\n\t\tif (req.http.Cookie ~ \"^ *$\") { unset req.http.Cookie; }\n\t} else {\n\t\tif (req.http.User-Agent ~ \"(?i)(ads|google|bing|msn|yandex|baidu|ro|career|)bot\" ||\n\t\t req.http.User-Agent ~ \"(?i)(baidu|jike|symantec)spider\" ||\n\t\t req.http.User-Agent ~ \"(?i)scanner\" ||\n\t\t req.http.User-Agent ~ \"(?i)(web)crawler\") {\n\t\t\tset req.http.X-UA-Device = \"bot\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ipad\") { set req.http.X-UA-Device = \"tablet-ipad\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ip(hone|od)\") { set req.http.X-UA-Device = \"mobile-iphone\"; }\n\t\t\/* how do we differ between an android phone and an android tablet?\n\t\t http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent *\/\n\t\telsif (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") { set req.http.X-UA-Device = \"mobile-android\"; }\n\t\t\/\/ android 3\/honeycomb was just about tablet-only, and any phones will probably handle a bigger page layout.\n\t\telsif (req.http.User-Agent ~ \"(?i)android 3\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\t\/\/ May very well give false positives towards android tablets. Suggestions welcome.\n\t\telsif (req.http.User-Agent ~ \"(?i)android\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\telsif (req.http.User-Agent ~ \"Mobile.+Firefox\") { set req.http.X-UA-Device = \"mobile-firefoxos\"; }\n\t\telsif (req.http.User-Agent ~ \"^HTC\" ||\n\t\t req.http.User-Agent ~ \"Fennec\" ||\n\t\t req.http.User-Agent ~ \"IEMobile\" ||\n\t\t req.http.User-Agent ~ \"BlackBerry\" ||\n\t\t req.http.User-Agent ~ \"SymbianOS.*AppleWebKit\" ||\n\t\t req.http.User-Agent ~ \"Opera Mobi\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-smartphone\";\n\t\t}\n\t\telsif (req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)^sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)^nokia\" ||\n\t\t req.http.User-Agent ~ \"(?i)^samsung\" ||\n\t\t req.http.User-Agent ~ \"(?i)^lg\" ||\n\t\t req.http.User-Agent ~ \"(?i)bada\" ||\n\t\t req.http.User-Agent ~ \"(?i)blazer\" ||\n\t\t req.http.User-Agent ~ \"(?i)cellphone\" ||\n\t\t req.http.User-Agent ~ \"(?i)iemobile\" ||\n\t\t req.http.User-Agent ~ \"(?i)midp-2.0\" ||\n\t\t req.http.User-Agent ~ \"(?i)u990\" ||\n\t\t req.http.User-Agent ~ \"(?i)netfront\" ||\n\t\t req.http.User-Agent ~ \"(?i)opera mini\" ||\n\t\t req.http.User-Agent ~ \"(?i)palm\" ||\n\t\t req.http.User-Agent ~ \"(?i)nintendo wii\" ||\n\t\t req.http.User-Agent ~ \"(?i)playstation portable\" ||\n\t\t req.http.User-Agent ~ \"(?i)portalmmm\" ||\n\t\t req.http.User-Agent ~ \"(?i)proxinet\" ||\n\t\t req.http.User-Agent ~ \"(?i)sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)windows\\ ?ce\" ||\n\t\t req.http.User-Agent ~ \"(?i)winwap\" ||\n\t\t req.http.User-Agent ~ \"(?i)eudoraweb\" ||\n\t\t req.http.User-Agent ~ \"(?i)htc\" ||\n\t\t req.http.User-Agent ~ \"(?i)240x320\" ||\n\t\t req.http.User-Agent ~ \"(?i)avantgo\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-generic\";\n\t\t}\n\t}\n}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"c1971bcdac00a4487798e9edbf5bb366916852bd","subject":"Return a synthetic response when ESI errors","message":"Return a synthetic response when ESI errors\n","repos":"dstufft\/warehouse,pypa\/warehouse,wlonk\/warehouse,alex\/warehouse,ismail-s\/warehouse,HonzaKral\/warehouse,ismail-s\/warehouse,karan\/warehouse,alex\/warehouse,karan\/warehouse,HonzaKral\/warehouse,ismail-s\/warehouse,alex\/warehouse,HonzaKral\/warehouse,ismail-s\/warehouse,karan\/warehouse,ismail-s\/warehouse,alex\/warehouse,wlonk\/warehouse,pypa\/warehouse,pypa\/warehouse,wlonk\/warehouse,dstufft\/warehouse,karan\/warehouse,HonzaKral\/warehouse,alex\/warehouse,dstufft\/warehouse,dstufft\/warehouse,karan\/warehouse,pypa\/warehouse","old_file":"vcl\/main.vcl","new_file":"vcl\/main.vcl","new_contents":"\nsub vcl_recv {\n#FASTLY recv\n\n # Disable ESI processing when doing a shield request.\n if (req.http.Fastly-FF) {\n set req.esi = false;\n }\n\n # If we're serving an ESI request, and the request in question has NOT\n # opted into cookies, then we'll go ahead and strip any cookies from the\n # request. In addition, we'll strip out any Authorization or Authentication\n # headers.\n if (req.url ~ \"^\/_esi\/\") {\n unset req.http.Authenticate;\n unset req.http.Authorization;\n\n if (req.url !~ \"esi-cookies=1\") {\n unset req.http.Cookie;\n }\n }\n\n # We want to Force SSL for the WebUI by redirecting to the HTTPS version of\n # the page, however for API calls we want to return an error code directing\n # people to instead use HTTPS.\n if (!req.http.Fastly-SSL) {\n\n # The \/simple\/ and \/packages\/ API.\n if (req.url ~ \"^\/(simple|packages)\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy JSON API.\n if (req.url ~ \"^\/pypi\/.+\/json$\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy ?:action= API.\n if (req.url ~ \"^\/pypi.*(\\?|&)=:action\") {\n error 803 \"SSL is required\";\n }\n\n # If we're on the \/pypi page and we've received something other than a\n # GET or HEAD request, then we have no way to determine if a particular\n # request is an API call or not because it'll be in the request body\n # and that isn't available to us here. So in those cases, we won't\n # do a redirect.\n if (req.url ~ \"^\/pypi\") {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n error 801 \"Force SSL\";\n }\n }\n else {\n # This isn't a \/pypi URL so we'll just unconditionally redirect to\n # HTTPS.\n error 801 \"Force SSL\";\n }\n }\n\n # Set a header to tell the backend if we're using https or http.\n if (req.http.Fastly-SSL) {\n set req.http.Warehouse-Proto = \"https\";\n } else {\n set req.http.Warehouse-Proto = \"http\";\n }\n\n # Pass the client IP address back to the backend.\n if (req.http.Fastly-Client-IP) {\n set req.http.Warehouse-IP = req.http.Fastly-Client-IP;\n }\n\n # Pass the real host value back to the backend.\n if (req.http.Host) {\n set req.http.Warehouse-Host = req.http.Host;\n }\n\n # Do not bother to attempt to run the caching mechanisms for methods that\n # are not generally safe to cache.\n if (req.request != \"HEAD\" &&\n req.request != \"GET\" &&\n req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n # Finally, return the default lookup action.\n return(lookup);\n}\n\n\nsub vcl_fetch {\n#FASTLY fetch\n\n # Only enable ESI on responses that have opted into them.\n if (beresp.http.Warehouse-ESI-Enable) {\n # Conditional HTTP requests are not compatible with Varnish's\n # implementation of ESI, in particularl the ETag and the Last-Modified\n # won't be updated when the included content changes, causing Varnish\n # to return a 304 Not Modified.\n unset beresp.http.ETag;\n unset beresp.http.Last-Modified;\n\n # Enable ESI.\n esi;\n }\n\n # Trigger a \"SSL is required\" error if the backend has indicated to do so.\n if (beresp.http.X-Fastly-Error == \"803\") {\n error 803 \"SSL is required\";\n }\n\n # If we've gotten a 500 or a 503 from the backend, we'll go ahead and retry\n # the request.\n if ((beresp.status == 500 || beresp.status == 503) &&\n req.restarts < 1 &&\n (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n # If we've restarted, then we'll record the number of restarts.\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n # If there is a Set-Cookie header, we'll ensure that we do not cache the\n # response.\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n # If the response has the private Cache-Control directive then we won't\n # cache it.\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # If we've gotten an error after the restarts we'll deliver the response\n # with a very short cache time.\n if (beresp.status == 500 || beresp.status == 503) {\n # If this is a ESI request, then instead of returning the error we're\n # going to return a blank page so that our top level page acts as if it\n # did not have ESI rather than inlining the error page.\n if (req.url ~ \"^\/_esi\/\") {\n error 900 \"ESI Error\";\n }\n\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n # Apply a default TTL if there isn't a max-age or s-maxage.\n if (beresp.http.Expires ||\n beresp.http.Surrogate-Control ~ \"max-age\" ||\n beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # Keep the ttl here\n }\n else {\n # Apply the default ttl\n set beresp.ttl = 60s;\n }\n\n # Actually deliver the fetched response.\n return(deliver);\n}\n\n\nsub vcl_deliver {\n#FASTLY deliver\n\n # If the backend has indicated additional Vary headers to add once the\n # ESI result has been processed, then we'll go ahead and either append them\n # to our existing Vary header or we'll set the Vary header equal to it.\n if (resp.http.Warehouse-ESI-Vary) {\n if (resp.http.Vary) {\n set resp.http.Vary = resp.http.Vary \", \" resp.http.Warehouse-ESI-Vary;\n } else {\n set resp.http.Vary = resp.http.Warehouse-ESI-Vary;\n }\n\n unset resp.http.Warehouse-ESI-Vary;\n }\n\n # We no longer need the header that enables ESI, so we'll remove it from\n # the output.\n unset resp.http.Warehouse-ESI-Enable;\n\n # Unset headers that we don't need\/want to send on to the client because\n # they are not generally useful.\n unset resp.http.Server;\n unset resp.http.Via;\n\n return(deliver);\n}\n\n\nsub vcl_error {\n#FASTLY error\n\n if (obj.status == 803) {\n set obj.status = 403;\n set obj.response = \"SSL is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic {\"SSL is required.\"};\n return (deliver);\n } else if (obj.status == 900) {\n set obj.status = 500;\n set obj.response = \"500 ESI Error\";\n set obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n synthetic {\"\"};\n return(deliver);\n }\n}\n","old_contents":"\nsub vcl_recv {\n#FASTLY recv\n\n # Disable ESI processing when doing a shield request.\n if (req.http.Fastly-FF) {\n set req.esi = false;\n }\n\n # If we're serving an ESI request, and the request in question has NOT\n # opted into cookies, then we'll go ahead and strip any cookies from the\n # request. In addition, we'll strip out any Authorization or Authentication\n # headers.\n if (req.url ~ \"^\/_esi\/\") {\n unset req.http.Authenticate;\n unset req.http.Authorization;\n\n if (req.url !~ \"esi-cookies=1\") {\n unset req.http.Cookie;\n }\n }\n\n # We want to Force SSL for the WebUI by redirecting to the HTTPS version of\n # the page, however for API calls we want to return an error code directing\n # people to instead use HTTPS.\n if (!req.http.Fastly-SSL) {\n\n # The \/simple\/ and \/packages\/ API.\n if (req.url ~ \"^\/(simple|packages)\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy JSON API.\n if (req.url ~ \"^\/pypi\/.+\/json$\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy ?:action= API.\n if (req.url ~ \"^\/pypi.*(\\?|&)=:action\") {\n error 803 \"SSL is required\";\n }\n\n # If we're on the \/pypi page and we've received something other than a\n # GET or HEAD request, then we have no way to determine if a particular\n # request is an API call or not because it'll be in the request body\n # and that isn't available to us here. So in those cases, we won't\n # do a redirect.\n if (req.url ~ \"^\/pypi\") {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n error 801 \"Force SSL\";\n }\n }\n else {\n # This isn't a \/pypi URL so we'll just unconditionally redirect to\n # HTTPS.\n error 801 \"Force SSL\";\n }\n }\n\n # Set a header to tell the backend if we're using https or http.\n if (req.http.Fastly-SSL) {\n set req.http.Warehouse-Proto = \"https\";\n } else {\n set req.http.Warehouse-Proto = \"http\";\n }\n\n # Pass the client IP address back to the backend.\n if (req.http.Fastly-Client-IP) {\n set req.http.Warehouse-IP = req.http.Fastly-Client-IP;\n }\n\n # Pass the real host value back to the backend.\n if (req.http.Host) {\n set req.http.Warehouse-Host = req.http.Host;\n }\n\n # Do not bother to attempt to run the caching mechanisms for methods that\n # are not generally safe to cache.\n if (req.request != \"HEAD\" &&\n req.request != \"GET\" &&\n req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n # Finally, return the default lookup action.\n return(lookup);\n}\n\n\nsub vcl_fetch {\n#FASTLY fetch\n\n # Only enable ESI on responses that have opted into them.\n if (beresp.http.Warehouse-ESI-Enable) {\n # Conditional HTTP requests are not compatible with Varnish's\n # implementation of ESI, in particularl the ETag and the Last-Modified\n # won't be updated when the included content changes, causing Varnish\n # to return a 304 Not Modified.\n unset beresp.http.ETag;\n unset beresp.http.Last-Modified;\n\n # Enable ESI.\n esi;\n }\n\n # Trigger a \"SSL is required\" error if the backend has indicated to do so.\n if (beresp.http.X-Fastly-Error == \"803\") {\n error 803 \"SSL is required\";\n }\n\n # If we've gotten a 500 or a 503 from the backend, we'll go ahead and retry\n # the request.\n if ((beresp.status == 500 || beresp.status == 503) &&\n req.restarts < 1 &&\n (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n # If we've restarted, then we'll record the number of restarts.\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n # If there is a Set-Cookie header, we'll ensure that we do not cache the\n # response.\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n # If the response has the private Cache-Control directive then we won't\n # cache it.\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # If we've gotten an error after the restarts we'll deliver the response\n # with a very short cache time.\n if (beresp.status == 500 || beresp.status == 503) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n # Apply a default TTL if there isn't a max-age or s-maxage.\n if (beresp.http.Expires ||\n beresp.http.Surrogate-Control ~ \"max-age\" ||\n beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # Keep the ttl here\n }\n else {\n # Apply the default ttl\n set beresp.ttl = 60s;\n }\n\n # Actually deliver the fetched response.\n return(deliver);\n}\n\n\nsub vcl_deliver {\n#FASTLY deliver\n\n # If the backend has indicated additional Vary headers to add once the\n # ESI result has been processed, then we'll go ahead and either append them\n # to our existing Vary header or we'll set the Vary header equal to it.\n if (resp.http.Warehouse-ESI-Vary) {\n if (resp.http.Vary) {\n set resp.http.Vary = resp.http.Vary \", \" resp.http.Warehouse-ESI-Vary;\n } else {\n set resp.http.Vary = resp.http.Warehouse-ESI-Vary;\n }\n\n unset resp.http.Warehouse-ESI-Vary;\n }\n\n # We no longer need the header that enables ESI, so we'll remove it from\n # the output.\n unset resp.http.Warehouse-ESI-Enable;\n\n # Unset headers that we don't need\/want to send on to the client because\n # they are not generally useful.\n unset resp.http.Server;\n unset resp.http.Via;\n\n return(deliver);\n}\n\n\nsub vcl_error {\n#FASTLY error\n\n if (obj.status == 803) {\n set obj.status = 403;\n set obj.response = \"SSL is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic {\"SSL is required.\"};\n return (deliver);\n }\n}\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"4630f687a9afad90f65aa96d2631024348b5cf0c","subject":"Update copyright notice","message":"Update copyright notice\n","repos":"varnish\/varnish-devicedetect,wikp\/varnish-devicedetect,kevinquinnyo\/varnish-devicedetect,wikp\/varnish-devicedetect,varnish\/varnish-devicedetect,kevinquinnyo\/varnish-devicedetect","old_file":"devicedetect.vcl","new_file":"devicedetect.vcl","new_contents":"# Copyright (c) 2012-2014 Varnish Software AS\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions\n# are met:\n# 1. Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n# 2. Redistributions in binary form must reproduce the above copyright\n# notice, this list of conditions and the following disclaimer in the\n# documentation and\/or other materials provided with the distribution.\n#\n# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n# ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n# SUCH DAMAGE.\n#\n# detectdevice.vcl - regex based device detection for Varnish\n# http:\/\/github.com\/varnish\/varnish-devicedetect\/\n#\n# Author: Lasse Karstensen <lasse@varnish-software.com>\n\nsub devicedetect {\n\tunset req.http.X-UA-Device;\n\tset req.http.X-UA-Device = \"pc\";\n\n\t# Handle that a cookie may override the detection alltogether.\n\tif (req.http.Cookie ~ \"(?i)X-UA-Device-force\") {\n\t\t\/* ;?? means zero or one ;, non-greedy to match the first. *\/\n\t\tset req.http.X-UA-Device = regsub(req.http.Cookie, \"(?i).*X-UA-Device-force=([^;]+);??.*\", \"\\1\");\n\t\t\/* Clean up our mess in the cookie header *\/\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|; ) *X-UA-Device-force=[^;]+;? *\", \"\\1\");\n\t\t\/* If the cookie header is now empty, or just whitespace, unset it. *\/\n\t\tif (req.http.Cookie ~ \"^ *$\") { unset req.http.Cookie; }\n\t} else {\n\t\tif (req.http.User-Agent ~ \"(?i)(ads|google|bing|msn|yandex|baidu|ro|career|)bot\" ||\n\t\t req.http.User-Agent ~ \"(?i)(baidu|jike|symantec)spider\" ||\n\t\t req.http.User-Agent ~ \"(?i)scanner\" ||\n\t\t req.http.User-Agent ~ \"(?i)(web)crawler\") {\n\t\t\tset req.http.X-UA-Device = \"bot\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ipad\") { set req.http.X-UA-Device = \"tablet-ipad\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ip(hone|od)\") { set req.http.X-UA-Device = \"mobile-iphone\"; }\n\t\t\/* how do we differ between an android phone and an android tablet?\n\t\t http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent *\/\n\t\telsif (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") { set req.http.X-UA-Device = \"mobile-android\"; }\n\t\t\/\/ android 3\/honeycomb was just about tablet-only, and any phones will probably handle a bigger page layout.\n\t\telsif (req.http.User-Agent ~ \"(?i)android 3\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\t\/* see http:\/\/my.opera.com\/community\/openweb\/idopera\/ *\/\n\t\telsif (req.http.User-Agent ~ \"Opera Mobi\") { set req.http.X-UA-Device = \"mobile-smartphone\"; }\n\t\t\/\/ May very well give false positives towards android tablets. Suggestions welcome.\n\t\telsif (req.http.User-Agent ~ \"(?i)android\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\telsif (req.http.User-Agent ~ \"PlayBook; U; RIM Tablet\") { set req.http.X-UA-Device = \"tablet-rim\"; }\n\t\telsif (req.http.User-Agent ~ \"hp-tablet.*TouchPad\") { set req.http.X-UA-Device = \"tablet-hp\"; }\n\t\telsif (req.http.User-Agent ~ \"Kindle\/3\") { set req.http.X-UA-Device = \"tablet-kindle\"; }\n\t\telsif (req.http.User-Agent ~ \"Mobile.+Firefox\") { set req.http.X-UA-Device = \"mobile-firefoxos\"; }\n\t\telsif (req.http.User-Agent ~ \"^HTC\" ||\n\t\t req.http.User-Agent ~ \"Fennec\" ||\n\t\t req.http.User-Agent ~ \"IEMobile\" ||\n\t\t req.http.User-Agent ~ \"BlackBerry\" ||\n\t\t req.http.User-Agent ~ \"BB10.*Mobile\" ||\n\t\t req.http.User-Agent ~ \"GT-.*Build\/GINGERBREAD\" ||\n\t\t req.http.User-Agent ~ \"SymbianOS.*AppleWebKit\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-smartphone\";\n\t\t}\n\t\telsif (req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)^sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)^nokia\" ||\n\t\t req.http.User-Agent ~ \"(?i)^samsung\" ||\n\t\t req.http.User-Agent ~ \"(?i)^lg\" ||\n\t\t req.http.User-Agent ~ \"(?i)bada\" ||\n\t\t req.http.User-Agent ~ \"(?i)blazer\" ||\n\t\t req.http.User-Agent ~ \"(?i)cellphone\" ||\n\t\t req.http.User-Agent ~ \"(?i)iemobile\" ||\n\t\t req.http.User-Agent ~ \"(?i)midp-2.0\" ||\n\t\t req.http.User-Agent ~ \"(?i)u990\" ||\n\t\t req.http.User-Agent ~ \"(?i)netfront\" ||\n\t\t req.http.User-Agent ~ \"(?i)opera mini\" ||\n\t\t req.http.User-Agent ~ \"(?i)palm\" ||\n\t\t req.http.User-Agent ~ \"(?i)nintendo wii\" ||\n\t\t req.http.User-Agent ~ \"(?i)playstation portable\" ||\n\t\t req.http.User-Agent ~ \"(?i)portalmmm\" ||\n\t\t req.http.User-Agent ~ \"(?i)proxinet\" ||\n\t\t req.http.User-Agent ~ \"(?i)sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)windows\\ ?ce\" ||\n\t\t req.http.User-Agent ~ \"(?i)winwap\" ||\n\t\t req.http.User-Agent ~ \"(?i)eudoraweb\" ||\n\t\t req.http.User-Agent ~ \"(?i)htc\" ||\n\t\t req.http.User-Agent ~ \"(?i)240x320\" ||\n\t\t req.http.User-Agent ~ \"(?i)avantgo\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-generic\";\n\t\t}\n\t}\n}\n","old_contents":"# Copyright (c) 2012-2013 Varnish Software AS\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions\n# are met:\n# 1. Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n# 2. Redistributions in binary form must reproduce the above copyright\n# notice, this list of conditions and the following disclaimer in the\n# documentation and\/or other materials provided with the distribution.\n#\n# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n# ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n# SUCH DAMAGE.\n#\n# detectdevice.vcl - regex based device detection for Varnish\n# http:\/\/github.com\/varnish\/varnish-devicedetect\/\n#\n# Author: Lasse Karstensen <lasse@varnish-software.com>\n\nsub devicedetect {\n\tunset req.http.X-UA-Device;\n\tset req.http.X-UA-Device = \"pc\";\n\n\t# Handle that a cookie may override the detection alltogether.\n\tif (req.http.Cookie ~ \"(?i)X-UA-Device-force\") {\n\t\t\/* ;?? means zero or one ;, non-greedy to match the first. *\/\n\t\tset req.http.X-UA-Device = regsub(req.http.Cookie, \"(?i).*X-UA-Device-force=([^;]+);??.*\", \"\\1\");\n\t\t\/* Clean up our mess in the cookie header *\/\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|; ) *X-UA-Device-force=[^;]+;? *\", \"\\1\");\n\t\t\/* If the cookie header is now empty, or just whitespace, unset it. *\/\n\t\tif (req.http.Cookie ~ \"^ *$\") { unset req.http.Cookie; }\n\t} else {\n\t\tif (req.http.User-Agent ~ \"(?i)(ads|google|bing|msn|yandex|baidu|ro|career|)bot\" ||\n\t\t req.http.User-Agent ~ \"(?i)(baidu|jike|symantec)spider\" ||\n\t\t req.http.User-Agent ~ \"(?i)scanner\" ||\n\t\t req.http.User-Agent ~ \"(?i)(web)crawler\") {\n\t\t\tset req.http.X-UA-Device = \"bot\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ipad\") { set req.http.X-UA-Device = \"tablet-ipad\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ip(hone|od)\") { set req.http.X-UA-Device = \"mobile-iphone\"; }\n\t\t\/* how do we differ between an android phone and an android tablet?\n\t\t http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent *\/\n\t\telsif (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") { set req.http.X-UA-Device = \"mobile-android\"; }\n\t\t\/\/ android 3\/honeycomb was just about tablet-only, and any phones will probably handle a bigger page layout.\n\t\telsif (req.http.User-Agent ~ \"(?i)android 3\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\t\/* see http:\/\/my.opera.com\/community\/openweb\/idopera\/ *\/\n\t\telsif (req.http.User-Agent ~ \"Opera Mobi\") { set req.http.X-UA-Device = \"mobile-smartphone\"; }\n\t\t\/\/ May very well give false positives towards android tablets. Suggestions welcome.\n\t\telsif (req.http.User-Agent ~ \"(?i)android\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\telsif (req.http.User-Agent ~ \"PlayBook; U; RIM Tablet\") { set req.http.X-UA-Device = \"tablet-rim\"; }\n\t\telsif (req.http.User-Agent ~ \"hp-tablet.*TouchPad\") { set req.http.X-UA-Device = \"tablet-hp\"; }\n\t\telsif (req.http.User-Agent ~ \"Kindle\/3\") { set req.http.X-UA-Device = \"tablet-kindle\"; }\n\t\telsif (req.http.User-Agent ~ \"Mobile.+Firefox\") { set req.http.X-UA-Device = \"mobile-firefoxos\"; }\n\t\telsif (req.http.User-Agent ~ \"^HTC\" ||\n\t\t req.http.User-Agent ~ \"Fennec\" ||\n\t\t req.http.User-Agent ~ \"IEMobile\" ||\n\t\t req.http.User-Agent ~ \"BlackBerry\" ||\n\t\t req.http.User-Agent ~ \"BB10.*Mobile\" ||\n\t\t req.http.User-Agent ~ \"GT-.*Build\/GINGERBREAD\" ||\n\t\t req.http.User-Agent ~ \"SymbianOS.*AppleWebKit\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-smartphone\";\n\t\t}\n\t\telsif (req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)^sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)^nokia\" ||\n\t\t req.http.User-Agent ~ \"(?i)^samsung\" ||\n\t\t req.http.User-Agent ~ \"(?i)^lg\" ||\n\t\t req.http.User-Agent ~ \"(?i)bada\" ||\n\t\t req.http.User-Agent ~ \"(?i)blazer\" ||\n\t\t req.http.User-Agent ~ \"(?i)cellphone\" ||\n\t\t req.http.User-Agent ~ \"(?i)iemobile\" ||\n\t\t req.http.User-Agent ~ \"(?i)midp-2.0\" ||\n\t\t req.http.User-Agent ~ \"(?i)u990\" ||\n\t\t req.http.User-Agent ~ \"(?i)netfront\" ||\n\t\t req.http.User-Agent ~ \"(?i)opera mini\" ||\n\t\t req.http.User-Agent ~ \"(?i)palm\" ||\n\t\t req.http.User-Agent ~ \"(?i)nintendo wii\" ||\n\t\t req.http.User-Agent ~ \"(?i)playstation portable\" ||\n\t\t req.http.User-Agent ~ \"(?i)portalmmm\" ||\n\t\t req.http.User-Agent ~ \"(?i)proxinet\" ||\n\t\t req.http.User-Agent ~ \"(?i)sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)windows\\ ?ce\" ||\n\t\t req.http.User-Agent ~ \"(?i)winwap\" ||\n\t\t req.http.User-Agent ~ \"(?i)eudoraweb\" ||\n\t\t req.http.User-Agent ~ \"(?i)htc\" ||\n\t\t req.http.User-Agent ~ \"(?i)240x320\" ||\n\t\t req.http.User-Agent ~ \"(?i)avantgo\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-generic\";\n\t\t}\n\t}\n}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"e117ba262a016b61db35272537ff0047e69cf86d","subject":"Add HSTS header with long max-age, includeSubdomains and preload","message":"Add HSTS header with long max-age, includeSubdomains and preload\n","repos":"pypa\/warehouse,karan\/warehouse,karan\/warehouse,alex\/warehouse,dstufft\/warehouse,pypa\/warehouse,pypa\/warehouse,dstufft\/warehouse,pypa\/warehouse,wlonk\/warehouse,dstufft\/warehouse,dstufft\/warehouse,wlonk\/warehouse,alex\/warehouse,alex\/warehouse,wlonk\/warehouse,alex\/warehouse,karan\/warehouse,karan\/warehouse,alex\/warehouse,karan\/warehouse","old_file":"vcl\/main.vcl","new_file":"vcl\/main.vcl","new_contents":"\nsub vcl_recv {\n#FASTLY recv\n\n # We want to Force SSL for the WebUI by redirecting to the HTTPS version of\n # the page, however for API calls we want to return an error code directing\n # people to instead use HTTPS.\n if (!req.http.Fastly-SSL) {\n\n # The \/simple\/ and \/packages\/ API.\n if (req.url ~ \"^\/(simple|packages)\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy JSON API.\n if (req.url ~ \"^\/pypi\/.+\/json$\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy ?:action= API.\n if (req.url ~ \"^\/pypi.*(\\?|&)=:action\") {\n error 803 \"SSL is required\";\n }\n\n # If we're on the \/pypi page and we've received something other than a\n # GET or HEAD request, then we have no way to determine if a particular\n # request is an API call or not because it'll be in the request body\n # and that isn't available to us here. So in those cases, we won't\n # do a redirect.\n if (req.url ~ \"^\/pypi\") {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n error 801 \"Force SSL\";\n }\n }\n else {\n # This isn't a \/pypi URL so we'll just unconditionally redirect to\n # HTTPS.\n error 801 \"Force SSL\";\n }\n }\n\n # Set a header to tell the backend if we're using https or http.\n if (req.http.Fastly-SSL) {\n set req.http.Warehouse-Proto = \"https\";\n } else {\n set req.http.Warehouse-Proto = \"http\";\n }\n\n # Pass the client IP address back to the backend.\n if (req.http.Fastly-Client-IP) {\n set req.http.Warehouse-IP = req.http.Fastly-Client-IP;\n }\n\n # Pass the real host value back to the backend.\n if (req.http.Host) {\n set req.http.Warehouse-Host = req.http.Host;\n }\n\n # Do not bother to attempt to run the caching mechanisms for methods that\n # are not generally safe to cache.\n if (req.request != \"HEAD\" &&\n req.request != \"GET\" &&\n req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n # Finally, return the default lookup action.\n return(lookup);\n}\n\n\nsub vcl_fetch {\n#FASTLY fetch\n\n # Trigger a \"SSL is required\" error if the backend has indicated to do so.\n if (beresp.http.X-Fastly-Error == \"803\") {\n error 803 \"SSL is required\";\n }\n\n # If we've gotten a 502 or a 503 from the backend, we'll go ahead and retry\n # the request.\n if ((beresp.status == 502 || beresp.status == 503) &&\n req.restarts < 1 &&\n (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n # If we've restarted, then we'll record the number of restarts.\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n # If there is a Set-Cookie header, we'll ensure that we do not cache the\n # response.\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n # If the response has the private Cache-Control directive then we won't\n # cache it.\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # If we've gotten an error after the restarts we'll deliver the response\n # with a very short cache time.\n if (beresp.status == 500 || beresp.status == 503) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n # Apply a default TTL if there isn't a max-age or s-maxage.\n if (beresp.http.Expires ||\n beresp.http.Surrogate-Control ~ \"max-age\" ||\n beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # Keep the ttl here\n }\n else {\n # Apply the default ttl\n set beresp.ttl = 60s;\n }\n\n # Actually deliver the fetched response.\n return(deliver);\n}\n\n\nsub vcl_deliver {\n#FASTLY deliver\n\n # Unset headers that we don't need\/want to send on to the client because\n # they are not generally useful.\n unset resp.http.Server;\n unset resp.http.Via;\n\n # Set our standard security headers, we do this in VCL rather than in\n # Warehouse itself so that we always get these headers, regardless of the\n # origin server being used.\n set resp.http.Strict-Transport-Security = \"max-age=31536000; includeSubDomains; preload\";\n set resp.http.X-Frame-Options = \"deny\";\n set resp.http.X-XSS-Protection = \"1; mode=block\";\n set resp.http.X-Content-Type-Options = \"nosniff\";\n set resp.http.X-Permitted-Cross-Domain-Policies = \"none\";\n\n return(deliver);\n}\n\n\nsub vcl_error {\n#FASTLY error\n\n if (obj.status == 803) {\n set obj.status = 403;\n set obj.response = \"SSL is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic {\"SSL is required.\"};\n return (deliver);\n }\n\n}\n","old_contents":"\nsub vcl_recv {\n#FASTLY recv\n\n # We want to Force SSL for the WebUI by redirecting to the HTTPS version of\n # the page, however for API calls we want to return an error code directing\n # people to instead use HTTPS.\n if (!req.http.Fastly-SSL) {\n\n # The \/simple\/ and \/packages\/ API.\n if (req.url ~ \"^\/(simple|packages)\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy JSON API.\n if (req.url ~ \"^\/pypi\/.+\/json$\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy ?:action= API.\n if (req.url ~ \"^\/pypi.*(\\?|&)=:action\") {\n error 803 \"SSL is required\";\n }\n\n # If we're on the \/pypi page and we've received something other than a\n # GET or HEAD request, then we have no way to determine if a particular\n # request is an API call or not because it'll be in the request body\n # and that isn't available to us here. So in those cases, we won't\n # do a redirect.\n if (req.url ~ \"^\/pypi\") {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n error 801 \"Force SSL\";\n }\n }\n else {\n # This isn't a \/pypi URL so we'll just unconditionally redirect to\n # HTTPS.\n error 801 \"Force SSL\";\n }\n }\n\n # Set a header to tell the backend if we're using https or http.\n if (req.http.Fastly-SSL) {\n set req.http.Warehouse-Proto = \"https\";\n } else {\n set req.http.Warehouse-Proto = \"http\";\n }\n\n # Pass the client IP address back to the backend.\n if (req.http.Fastly-Client-IP) {\n set req.http.Warehouse-IP = req.http.Fastly-Client-IP;\n }\n\n # Pass the real host value back to the backend.\n if (req.http.Host) {\n set req.http.Warehouse-Host = req.http.Host;\n }\n\n # Do not bother to attempt to run the caching mechanisms for methods that\n # are not generally safe to cache.\n if (req.request != \"HEAD\" &&\n req.request != \"GET\" &&\n req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n # Finally, return the default lookup action.\n return(lookup);\n}\n\n\nsub vcl_fetch {\n#FASTLY fetch\n\n # Trigger a \"SSL is required\" error if the backend has indicated to do so.\n if (beresp.http.X-Fastly-Error == \"803\") {\n error 803 \"SSL is required\";\n }\n\n # If we've gotten a 502 or a 503 from the backend, we'll go ahead and retry\n # the request.\n if ((beresp.status == 502 || beresp.status == 503) &&\n req.restarts < 1 &&\n (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n # If we've restarted, then we'll record the number of restarts.\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n # If there is a Set-Cookie header, we'll ensure that we do not cache the\n # response.\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n # If the response has the private Cache-Control directive then we won't\n # cache it.\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # If we've gotten an error after the restarts we'll deliver the response\n # with a very short cache time.\n if (beresp.status == 500 || beresp.status == 503) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n # Apply a default TTL if there isn't a max-age or s-maxage.\n if (beresp.http.Expires ||\n beresp.http.Surrogate-Control ~ \"max-age\" ||\n beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # Keep the ttl here\n }\n else {\n # Apply the default ttl\n set beresp.ttl = 60s;\n }\n\n # Actually deliver the fetched response.\n return(deliver);\n}\n\n\nsub vcl_deliver {\n#FASTLY deliver\n\n # Unset headers that we don't need\/want to send on to the client because\n # they are not generally useful.\n unset resp.http.Server;\n unset resp.http.Via;\n\n # Set our standard security headers, we do this in VCL rather than in\n # Warehouse itself so that we always get these headers, regardless of the\n # origin server being used.\n set resp.http.X-Frame-Options = \"deny\";\n set resp.http.X-XSS-Protection = \"1; mode=block\";\n set resp.http.X-Content-Type-Options = \"nosniff\";\n set resp.http.X-Permitted-Cross-Domain-Policies = \"none\";\n\n return(deliver);\n}\n\n\nsub vcl_error {\n#FASTLY error\n\n if (obj.status == 803) {\n set obj.status = 403;\n set obj.response = \"SSL is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic {\"SSL is required.\"};\n return (deliver);\n }\n\n}\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"0e44df3b71bfe1890f0c0282d24caa8f9642a19c","subject":"Add commands for selecting multiple lines","message":"Add commands for selecting multiple lines\n","repos":"aschneiderman\/atom-voice-vocola","old_file":"atom.vcl","new_file":"atom.vcl","new_contents":"# Voice commands for atom\n\ninclude folders.vch;\ninclude letters.vch;\n\nGo Strawberry = {Ctrl+Alt+F8};\nGo Blueberry ={Ctrl+Alt+o};\nGo Banana = {Ctrl+Alt+F7};\n\n\n# Commands for developing Atom: init.config, packages; also for navigating existing packages\/commands\nReload Atom = {Ctrl+s} Wait(100) {Shift+Ctrl+Alt+F5};\nCommand Palette = {Ctrl+Shift+p};\nKeyboard Shortcuts = {Ctrl+.};\nRun Specs = {Ctrl+Alt+p};\nShow Console = {Ctrl+Alt+i};\n\n# Commands for developing D3: D3 visualizations, D3 Sandwiches\nSave and Reload = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Ctrl+r};\t\nSave and Really Reload = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Ctrl+Shift+r};\n\n# File commands\nFind (File | Document) = {Ctrl+t};\nSave As = {Ctrl+Shift+s};\n\n\n# --- Navigation commands ------------------------------------\n<delimiters> := (Quote = '\"' | 'Single Quote' = \"'\" | Comma = ',' | 'Equal Sign' = '=' | Equals = '=' \n\t| Period = '.' | Colon = ':' | 'Semi-Colon' = ';' | Hyphen = '-' | Underscore = '_' | Slash = '\/'\n\t| Paren = \"(\" | \"Close Paren\" = \")\" | Parentheses = \"(\" | \"Close Parentheses\" = \")\"\n\t| Bracket = '[' | \"Close Bracket\" = ']' | Brace = '{' | 'Close Brace' = '}'\t);\n\nLine 1..200 = {Ctrl+g} $1 {Enter};\n(Left = 'b' | Right = 'f') Word = {Alt+$1};\nTop = {Ctrl+Home};\nBottom = {Ctrl+End};\n(Find = 'Right' | 'Insert After' = 'Right' | 'Insert Before' = 'Left') (Next = 'Enter' | Last = 'Shift+F3') <delimiters> \n\t\t= {Ctrl+f} $3 {$2} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') <delimiters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') 1..20 <delimiters> = {Ctrl+f} $3 {Enter} {Esc} Wait(100) {F3_$2} {Shift+F3} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') Enda <delimiters> = {End} {Ctrl+f} $2 {Enter} {Esc} {Shift+F3} Wait(100) {$1};\n\nFine Alpha <letters> = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Left};\nInsert (Before = 'Left' | After = 'Right') Alpha <letters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nFine Number 0..9 = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Right};\nFind Again = {F3} {Right};\nFind Again 1..20 Times = {F3_$1} {Right};\n\nFind Symbol = {Ctrl+r};\n\n(Set | Add | Clear | Hide | Delete) Bookmark = {Ctrl+Alt+F2};\n(Next = 'F2' | Last = 'Shift+F2') Bookmark = {$1};\n\nNext Window = {Ctrl+Tab};\nLast Window = {Ctrl+Shift+Tab};\n\n\n# --- Editing commands ----------------------------------------\nSelect Line = {Ctrl+l};\nSelect (Next = 'Down' | Forward = 'Down' | Last = 'Up' | Back = 'Up' | Previous = 'Up') 1..20 Lines = {Home} {Shift+$1_$2};\nGrab 1..20 Lines = {Home} {Shift+Down_$1};\nAdd 1..20 (Lines = 'Down' | Line = 'Down' | Pages = 'PgDn' | Page = 'PgDn') = {Shift+$2_$1};\n\n(Join = 'j' | Indent = ']' | Dedent = '[') That = {Ctrl+$1};\nMove Line (Up | Down) 1..20 = {Ctrl+$1_$2};\n\n\n\nDelete Word = {Ctrl+Del};\nDelete 1..20 Words = {Ctrl+Del_$1};\nDelete (Back | Last) Word = {Ctrl+Backspace};\nDelete (Back | Last) 1..20 Words = {Ctrl+Backspace_$2};\nDelete Enda Word = {End} {Ctrl+Backspace};\n\n(Delete Line | Dede) = {Ctrl+Shift+k};\nDelete 1..20 Lines = {Ctrl+Shift+k_$1};\n(Cut = 'x' | Paste = 'v' | Copy = 'c') That = {Ctrl+$1};\n\nComment (That | Line) = {Ctrl+\/};\nComment 1..20 Lines = {Home} {Shift+Down_$1} {Ctrl+\/};\n\nSelect between (Delimiters | Brackets | Tags) ={Ctrl+m} {Ctrl+Alt+m};\n\nDelete Tags = {Ctrl+Alt+F4};\n\nReplace = {Ctrl+f};\nReplace All = {Ctrl+Enter};\n\n\n\n\n# --- Code commands -------------------------------------------\nStart (Item = 'li' | List = 'ul' | HTML = 'html' | pre = \"pre\"\n\t| div = 'div' | 'Comment' = 'comment-html'\n\t| 'Bold ID' = 'bold-id' | 'Input' = 'ds-input-text'\n\t| 'Fix Line' = 'fix-current-line' | 'Fix Current Line' = 'fix-current-line'\n\t| Snippet = 'my-snippet' | 'Recipe Row' = 'recipe-row' | 'Recipe Play' = 'recipe-play') = $1 {Tab};\nStop (Comment = 'comment-html-end' ) = $1 {Tab};\nStart (para = '<p>' ) = $1;\nAdd (para = 'p') = '<' $1 '>' {End} '<\/' $1 '>';\nReplace With (para = 'p') = {Ctrl+Alt+F4} '<' $1 '>' {End} '<\/' $1 '>';\n\nStart (Header | Heading) 1..7 = h $2 {Tab};\nAdd (Header | Heading) 1..7 = '<h' $2 '>' {End} '<\/h' $2 '>';\nReplace With (Header | Heading) 1..7 = {Ctrl+Alt+F4} '<h' $2 '>' {End} '<\/h' $2 '>' {Home};\nMid HREF = '\">';\n\nPaste Function = 'function ' {Ctrl+v} ' {' {Enter} {Enter} '};' {Up};\n\nPre-Format Code = {Ctrl+Alt+F5};\n\n# TO ADD:\n# adding HTML comments, using a snippet\n\n\n\n","old_contents":"# Voice commands for atom\n\ninclude folders.vch;\ninclude letters.vch;\n\nGo Strawberry = {Ctrl+Alt+F8};\nGo Blueberry ={Ctrl+Alt+o};\nGo Banana = {Ctrl+Alt+F7};\n\n\n# Commands for developing Atom: init.config, packages; also for navigating existing packages\/commands\nReload Atom = {Ctrl+s} Wait(100) {Shift+Ctrl+Alt+F5};\nCommand Palette = {Ctrl+Shift+p};\nKeyboard Shortcuts = {Ctrl+.};\nRun Specs = {Ctrl+Alt+p};\nShow Console = {Ctrl+Alt+i};\n\n# Commands for developing D3: D3 visualizations, D3 Sandwiches\nSave and Reload = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Ctrl+r};\t\nSave and Really Reload = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Ctrl+Shift+r};\n\n# File commands\nFind (File | Document) = {Ctrl+t};\nSave As = {Ctrl+Shift+s};\n\n\n# --- Navigation commands ------------------------------------\n<delimiters> := (Quote = '\"' | 'Single Quote' = \"'\" | Comma = ',' | 'Equal Sign' = '=' | Equals = '=' \n\t| Period = '.' | Colon = ':' | 'Semi-Colon' = ';' | Hyphen = '-' | Underscore = '_' | Slash = '\/'\n\t| Paren = \"(\" | \"Close Paren\" = \")\" | Parentheses = \"(\" | \"Close Parentheses\" = \")\"\n\t| Bracket = '[' | \"Close Bracket\" = ']' | Brace = '{' | 'Close Brace' = '}'\t);\n\nLine 1..200 = {Ctrl+g} $1 {Enter};\n(Left = 'b' | Right = 'f') Word = {Alt+$1};\nTop = {Ctrl+Home};\nBottom = {Ctrl+End};\n(Find = 'Right' | 'Insert After' = 'Right' | 'Insert Before' = 'Left') (Next = 'Enter' | Last = 'Shift+F3') <delimiters> \n\t\t= {Ctrl+f} $3 {$2} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') <delimiters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') 1..20 <delimiters> = {Ctrl+f} $3 {Enter} {Esc} Wait(100) {F3_$2} {Shift+F3} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') Enda <delimiters> = {End} {Ctrl+f} $2 {Enter} {Esc} {Shift+F3} Wait(100) {$1};\n\nFine Alpha <letters> = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Left};\nInsert (Before = 'Left' | After = 'Right') Alpha <letters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nFine Number 0..9 = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Right};\nFind Again = {F3} {Right};\nFind Again 1..20 Times = {F3_$1} {Right};\n\nFind Symbol = {Ctrl+r};\n\n(Set | Add | Clear | Hide | Delete) Bookmark = {Ctrl+Alt+F2};\n(Next = 'F2' | Last = 'Shift+F2') Bookmark = {$1};\n\nNext Window = {Ctrl+Tab};\nLast Window = {Ctrl+Shift+Tab};\n\n\n# --- Editing commands ----------------------------------------\nSelect Line = {Ctrl+l};\nSelect (Next = 'Down' | Last = 'Up') 1..20 Lines = {Home} {Shift+$1_$2};\n(Join = 'j' | Indent = ']' | Dedent = '[') That = {Ctrl+$1};\nMove Line (Up | Down) 1..20 = {Ctrl+$1_$2};\n\n\n\nDelete Word = {Ctrl+Del};\nDelete 1..20 Words = {Ctrl+Del_$1};\nDelete (Back | Last) Word = {Ctrl+Backspace};\nDelete (Back | Last) 1..20 Words = {Ctrl+Backspace_$2};\nDelete Enda Word = {End} {Ctrl+Backspace};\n\n(Delete Line | Dede) = {Ctrl+Shift+k};\nDelete 1..20 Lines = {Ctrl+Shift+k_$1};\n(Cut = 'x' | Paste = 'v' | Copy = 'c') That = {Ctrl+$1};\n\nComment (That | Line) = {Ctrl+\/};\nComment 1..20 Lines = {Home} {Shift+Down_$1} {Ctrl+\/};\n\nSelect between (Delimiters | Brackets | Tags) ={Ctrl+m} {Ctrl+Alt+m};\n\nDelete Tags = {Ctrl+Alt+F4};\n\nReplace = {Ctrl+f};\nReplace All = {Ctrl+Enter};\n\n\n\n\n# --- Code commands -------------------------------------------\nStart (Item = 'li' | List = 'ul' | HTML = 'html' | pre = \"pre\"\n\t| div = 'div' | 'Comment' = 'comment-html'\n\t| 'Bold ID' = 'bold-id' | 'Input' = 'ds-input-text'\n\t| 'Fix Line' = 'fix-current-line' | 'Fix Current Line' = 'fix-current-line'\n\t| Snippet = 'my-snippet' | 'Recipe Row' = 'recipe-row' | 'Recipe Play' = 'recipe-play') = $1 {Tab};\nStop (Comment = 'comment-html-end' ) = $1 {Tab};\nStart (para = '<p>' ) = $1;\nAdd (para = 'p') = '<' $1 '>' {End} '<\/' $1 '>';\nReplace With (para = 'p') = {Ctrl+Alt+F4} '<' $1 '>' {End} '<\/' $1 '>';\n\nStart (Header | Heading) 1..7 = h $2 {Tab};\nAdd (Header | Heading) 1..7 = '<h' $2 '>' {End} '<\/h' $2 '>';\nReplace With (Header | Heading) 1..7 = {Ctrl+Alt+F4} '<h' $2 '>' {End} '<\/h' $2 '>' {Home};\nMid HREF = '\">';\n\nPaste Function = 'function ' {Ctrl+v} ' {' {Enter} {Enter} '};' {Up};\n\nPre-Format Code = {Ctrl+Alt+F5};\n\n# TO ADD:\n# adding HTML comments, using a snippet\n\n\n\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"5d52ecd4d176d47de9449fe0964781e33a7f4e58","subject":"no longer operate with a dynamic whitelist.","message":"no longer operate with a dynamic whitelist.\n","repos":"amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon","old_file":"images\/varnish-drupal\/drupal.vcl","new_file":"images\/varnish-drupal\/drupal.vcl","new_contents":"vcl 4.0;\n\nimport std;\nimport dynamic;\n\n# set backend default\nbackend default {\n .host = \"${VARNISH_BACKEND_HOST:-nginx}\";\n .port = \"${VARNISH_BACKEND_PORT:-8080}\";\n .first_byte_timeout = 35m;\n .between_bytes_timeout = 10m;\n}\n\n# Allow purging from localhost\n# @TODO allow from openshift network\nacl purge {\n \"127.0.0.1\";\n \"10.0.0.0\"\/8;\n \"172.16.0.0\"\/12;\n \"192.168.0.0\"\/16;\n}\n\nsub vcl_init {\n new www_dir = dynamic.director(\n port = \"${VARNISH_BACKEND_PORT:-8080}\",\n first_byte_timeout = 90s,\n between_bytes_timeout = 90s,\n ttl = 60s);\n }\n\n# This configuration is optimized for Drupal hosting:\n# Respond to incoming requests.\nsub vcl_recv {\n\n if (req.url ~ \"^\/varnish_status$\") {\n return (synth(200,\"OK\"));\n }\n # set the backend, which should be used:\n set req.backend_hint = www_dir.backend(\"${VARNISH_BACKEND_HOST:-nginx}\");\n\n # Always set the forward ip.\n if (req.restarts == 0) {\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n\n\n if (req.http.X-LAGOON-VARNISH ) {\n ## Pass all Requests which are handled via an upstream Varnish\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, \" + req.http.X-LAGOON-VARNISH;\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n } else if (req.http.Fastly-FF) {\n ## Pass all Requests which are handled via Fastly\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, fastly\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n set req.http.X-Forwarded-For = req.http.Fastly-Client-IP;\n } else if (req.http.CF-RAY) {\n ## Pass all Requests which are handled via CloudFlare\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, cloudflare\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n set req.http.X-Forwarded-For = req.http.CF-Connecting-IP;\n } else if (req.http.X-Pull) {\n ## Pass all Requests which are handled via KeyCDN\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, keycdn\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n } else {\n ## We set a header to let a Varnish Chain know that it already has been varnishcached\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}\";\n\n ## Allow to bypass based on env variable `VARNISH_BYPASS`\n set req.http.X-LAGOON-VARNISH-BYPASS = \"${VARNISH_BYPASS:-false}\";\n }\n\n # Websockets are piped\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n if (req.http.X-LAGOON-VARNISH-BYPASS == \"true\" || req.http.X-LAGOON-VARNISH-BYPASS == \"TRUE\") {\n return (pass);\n }\n\n # SA-CORE-2014-004 preventing access to \/xmlrpc.php\n if (req.url ~ \"^\/xmlrpc.php$\") {\n return (synth(701, \"Unauthorized\"));\n }\n\n # Strip out Google Analytics campaign variables. They are only needed\n # by the javascript running on the page\n # utm_source, utm_medium, utm_campaign, gclid\n if(req.url ~ \"(\\?|&)(gclid|utm_[a-z]+)=\") {\n set req.url = regsuball(req.url, \"(gclid|utm_[a-z]+)=[^\\&]+&?\", \"\");\n set req.url = regsub(req.url, \"(\\?|&)$\", \"\");\n }\n\n # Bypass a cache hit (the request is still sent to the backend)\n if (req.method == \"REFRESH\") {\n if (!client.ip ~ purge) { return (synth(405, \"Not allowed\")); }\n set req.method = \"GET\";\n set req.hash_always_miss = true;\n }\n\n # Only allow BAN requests from IP addresses in the 'purge' ACL.\n if (req.method == \"BAN\" || req.method == \"URIBAN\" || req.method == \"PURGE\") {\n # Only allow BAN from defined ACL\n if (!client.ip ~ purge) {\n return (synth(403, \"Your IP is not allowed.\"));\n }\n\n # Only allows BAN if the Host Header has the style of with \"${SERVICE_NAME:-varnish}:8080\" or \"${SERVICE_NAME:-varnish}\".\n # Such a request is only possible from within the Docker network, as a request from external goes trough the Kubernetes Router and for that needs a proper Host Header\n if (!req.http.host ~ \"^${SERVICE_NAME:-varnish}(:\\d+)?$\") {\n return (synth(403, \"Only allowed from within own network.\"));\n }\n\n if (req.method == \"BAN\") {\n # Logic for the ban, using the Cache-Tags header.\n if (req.http.Cache-Tags) {\n ban(\"obj.http.Cache-Tags ~ \" + req.http.Cache-Tags);\n # Throw a synthetic page so the request won't go to the backend.\n return (synth(200, \"Ban added.\"));\n }\n else {\n return (synth(403, \"Cache-Tags header missing.\"));\n }\n }\n\n if (req.method == \"URIBAN\" || req.method == \"PURGE\") {\n ban(\"req.url ~ \" + req.url);\n # Throw a synthetic page so the request won't go to the backend.\n return (synth(200, \"Ban added.\"));\n }\n\n }\n\n # Non-RFC2616 or CONNECT which is weird, we pipe that\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n return (pipe);\n }\n\n # We only try to cache GET and HEAD, other things are passed\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n # Any requests with Basic Auth are passed\n if (req.http.Authorization || req.http.Authenticate)\n {\n return (pass);\n }\n\n ## Pass requests which are from blackfire\n if (req.http.X-Blackfire-Query) {\n return (pass);\n }\n\n # Some URLs should never be cached\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/admin([\/?]|$).*$\" ||\n req.url ~ \"^\/info([\/?]|$).*$\" ||\n req.url ~ \"^\/flag([\/?]|$).*$\" ||\n req.url ~ \"^.*\/system\/files([\/?]|$).*$\" ||\n req.url ~ \"^\/cgi\" ||\n req.url ~ \"^\/cgi-bin\"\n ) {\n return (pass);\n }\n\n # Plupload likes to get piped\n if (req.url ~ \"^.*\/plupload-handle-uploads.*$\"\n ) {\n return (pipe);\n }\n\n # Handle compression correctly. Different browsers send different\n # \"Accept-Encoding\" headers, even though they mostly all support the same\n # compression mechanisms. By consolidating these compression headers into\n # a consistent format, we can reduce the size of the cache and get more hits.=\n # @see: http:\/\/ varnish.projects.linpro.no\/wiki\/FAQ\/Compression\n if (req.http.Accept-Encoding) {\n if (req.http.Accept-Encoding ~ \"gzip\") {\n # If the browser supports it, we'll use gzip.\n set req.http.Accept-Encoding = \"gzip\";\n }\n else if (req.http.Accept-Encoding ~ \"deflate\") {\n # Next, try deflate if it is supported.\n set req.http.Accept-Encoding = \"deflate\";\n }\n else {\n # Unknown algorithm. Remove it and send unencoded.\n unset req.http.Accept-Encoding;\n }\n }\n\n # Always cache the following file types for all users.\n if (req.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n unset req.http.Cookie;\n }\n\n # Remove all cookies that Drupal doesn't need to know about. ANY remaining\n # cookie will cause the request to pass-through to a backend. For the most part\n # we always set the NO_CACHE cookie after any POST request, disabling the\n # Varnish cache temporarily. The session cookie allows all authenticated users\n # to pass through as long as they're logged in.\n #\n # 1. Append a semi-colon to the front of the cookie string.\n # 2. Remove all spaces that appear after semi-colons.\n # 3. Match the cookies we want to keep, adding the space we removed\n # previously, back. (\\1) is first matching group in the regsuball.\n # 4. Remove all other cookies, identifying them by the fact that they have\n # no space after the preceding semi-colon.\n # 5. Remove all spaces and semi-colons from the beginning and end of the\n # cookie string.\n if (req.http.Cookie) {\n set req.http.CookieCheck = \";\" + req.http.Cookie;\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"; +\", \";\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";(${VARNISH_COOKIECHECK:-SESS[a-z0-9]+|SSESS[a-z0-9]+|NO_CACHE})=\", \"; \\1=\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";[^ ][^;]*\", \"\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"^[; ]+|[; ]+$\", \"\");\n\n set req.http.Cookie = req.http.Cookie + \";\";\n\n if (req.http.CookieCheck == \"\") {\n # If there are no remaining cookies, remove the cookie header. If there\n # aren't any cookie headers, Varnish's default behavior will be to cache\n # the page.\n\n unset req.http.CookieCheck;\n unset req.http.Cookie;\n }\n else {\n # If there is any cookies left (a session or NO_CACHE cookie), do not\n # cache the page. Pass it on to Apache directly.\n unset req.http.CookieCheck;\n return (pass);\n }\n }\n\n # Cacheable, lookup in cache.\n return (hash);\n}\n\nsub vcl_pipe {\n # Support for Websockets\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n set bereq.http.connection = req.http.connection;\n }\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n # normal hit\n return (deliver);\n }\n # We have no fresh fish. Lets look at the stale ones.\n if (std.healthy(req.backend_hint)) {\n # Backend is healthy. If the object is not older then 30secs, deliver it to the client\n # and automatically create a separate backend request to warm the cache for this request.\n if (obj.ttl + 30s > 0s) {\n set req.http.grace = \"normal(limited)\";\n return (deliver);\n } else {\n # No candidate for grace. Fetch a fresh object.\n return(miss);\n }\n } else {\n # backend is sick - use full grace\n if (obj.ttl + obj.grace > 0s) {\n set req.http.grace = \"full\";\n return (deliver);\n } else {\n # no graced object.\n return (miss);\n }\n }\n}\n\nsub vcl_backend_response {\n # Allow items to be stale if needed.\n set beresp.grace = 6h;\n\n # Set ban-lurker friendly custom headers.\n set beresp.http.X-Url = bereq.url;\n set beresp.http.X-Host = bereq.http.host;\n\n # If the backend sends a X-LAGOON-VARNISH-BACKEND-BYPASS header we directly deliver\n if(beresp.http.X-LAGOON-VARNISH-BACKEND-BYPASS == \"TRUE\") {\n return (deliver);\n }\n\n # Cache 404 and 403 for 10 seconds\n if(beresp.status == 404 || beresp.status == 403) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n # Don't allow static files to set cookies.\n if (bereq.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n # beresp == Back-end response from the web server.\n unset beresp.http.set-cookie;\n unset beresp.http.Cache-Control;\n\n # If an asset would come back with statuscode 500 we only cache it for 10 seconds instead of the usual static file cache\n if (beresp.status == 500) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n set beresp.ttl = ${VARNISH_ASSETS_TTL:-2628001}s;\n set beresp.http.Cache-Control = \"public, max-age=${VARNISH_ASSETS_TTL:-2628001}\";\n set beresp.http.Expires = \"\" + (now + beresp.ttl);\n }\n\n return (deliver);\n}\n\n# Set a header to track a cache HIT\/MISS.\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Varnish-Cache = \"HIT\";\n }\n else {\n set resp.http.X-Varnish-Cache = \"MISS\";\n }\n\n # Remove ban-lurker friendly custom headers when delivering to client.\n unset resp.http.X-Url;\n unset resp.http.X-Host;\n\n # unset Cache-Tags Header by default, can be disabled with VARNISH_UNSET_HEADER_CACHE_TAGS=true\n if (!${VARNISH_UNSET_HEADER_CACHE_TAGS:-false}) {\n unset resp.http.Cache-Tags;\n }\n\n unset resp.http.X-Generator;\n unset resp.http.Server;\n # Inject information about grace\n if (req.http.grace) {\n set resp.http.X-Varnish-Grace = req.http.grace;\n }\n set resp.http.X-LAGOON = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}>\" + resp.http.X-LAGOON;\n return (deliver);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n if (req.http.X-Forwarded-Proto) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n if (req.http.HTTPS) {\n hash_data(req.http.HTTPS);\n }\n return (lookup);\n}\n\nsub vcl_synth {\n if (resp.status == 701) {\n set resp.status = 401;\n set resp.http.Content-Type = \"text\/plain; charset=utf-8\";\n synthetic({\"XMLRPC Interface is blocked due to SA-CORE-2014-004 - mail support@amazee.io if you need it.\"});\n return (deliver);\n }\n if (resp.status == 700) {\n # Set a status the client will understand\n set resp.status = 200;\n # Create our synthetic response\n synthetic(\"\");\n return(deliver);\n}\n return (deliver);\n}\n\nsub vcl_backend_error {\n # Restart the request, when we have a backend server error, to try another backend.\n # Restart max twice.\n if (bereq.retries < 2) {\n return(retry);\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<head>\n <title>Server Error<\/title>\n <style type=\"text\/css\">\n body {\n font-family: helvetica, arial, sans-serif;\n }\n img {\n margin-top: 50px;\n }\n p {\n width: 6 00px;\n margin-top: 10px\n }\n div {\n background: #ccc;\n width: 600px;\n margin: auto;\n padding: 50px;\n }\n span {\n color: #ccc\n }\n <\/style>\n<\/head>\n<body>\n <div>\n <h1>We are sorry...<\/h1>\n <p>We encountered a server-side error. This means that the problem is not with your computer or Internet connection, but rather with the website's server.<\/p>\n <p>We are currently working on solving this problem and apologise for the inconvenience.<\/p>\n <span>\n <strong>Technical Information<\/strong><br \/>\n Error \"} + beresp.status + \" \" + beresp.reason + {\"<br \/>\n XID: \"} + bereq.xid + {\"<br \/>\n <\/span>\n <\/div>\n<\/body>\n<\/html>\n\n\"} );\n return (deliver);\n}\n","old_contents":"vcl 4.0;\n\nimport std;\nimport dynamic;\n\n# set backend default\nbackend default {\n .host = \"${VARNISH_BACKEND_HOST:-nginx}\";\n .port = \"${VARNISH_BACKEND_PORT:-8080}\";\n .first_byte_timeout = 35m;\n .between_bytes_timeout = 10m;\n}\n\n# Allow purging from localhost\n# @TODO allow from openshift network\nacl purge {\n \"127.0.0.1\";\n \"10.0.0.0\"\/8;\n \"172.16.0.0\"\/12;\n \"192.168.0.0\"\/16;\n}\n\nsub vcl_init {\n new www_dir = dynamic.director(\n port = \"${VARNISH_BACKEND_PORT:-8080}\",\n first_byte_timeout = 90s,\n between_bytes_timeout = 90s,\n whitelist = purge,\n ttl = 60s);\n }\n\n# This configuration is optimized for Drupal hosting:\n# Respond to incoming requests.\nsub vcl_recv {\n\n if (req.url ~ \"^\/varnish_status$\") {\n return (synth(200,\"OK\"));\n }\n # set the backend, which should be used:\n set req.backend_hint = www_dir.backend(\"${VARNISH_BACKEND_HOST:-nginx}\");\n\n # Always set the forward ip.\n if (req.restarts == 0) {\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n\n\n if (req.http.X-LAGOON-VARNISH ) {\n ## Pass all Requests which are handled via an upstream Varnish\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, \" + req.http.X-LAGOON-VARNISH;\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n } else if (req.http.Fastly-FF) {\n ## Pass all Requests which are handled via Fastly\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, fastly\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n set req.http.X-Forwarded-For = req.http.Fastly-Client-IP;\n } else if (req.http.CF-RAY) {\n ## Pass all Requests which are handled via CloudFlare\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, cloudflare\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n set req.http.X-Forwarded-For = req.http.CF-Connecting-IP;\n } else if (req.http.X-Pull) {\n ## Pass all Requests which are handled via KeyCDN\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, keycdn\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n } else {\n ## We set a header to let a Varnish Chain know that it already has been varnishcached\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}\";\n\n ## Allow to bypass based on env variable `VARNISH_BYPASS`\n set req.http.X-LAGOON-VARNISH-BYPASS = \"${VARNISH_BYPASS:-false}\";\n }\n\n # Websockets are piped\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n if (req.http.X-LAGOON-VARNISH-BYPASS == \"true\" || req.http.X-LAGOON-VARNISH-BYPASS == \"TRUE\") {\n return (pass);\n }\n\n # SA-CORE-2014-004 preventing access to \/xmlrpc.php\n if (req.url ~ \"^\/xmlrpc.php$\") {\n return (synth(701, \"Unauthorized\"));\n }\n\n # Strip out Google Analytics campaign variables. They are only needed\n # by the javascript running on the page\n # utm_source, utm_medium, utm_campaign, gclid\n if(req.url ~ \"(\\?|&)(gclid|utm_[a-z]+)=\") {\n set req.url = regsuball(req.url, \"(gclid|utm_[a-z]+)=[^\\&]+&?\", \"\");\n set req.url = regsub(req.url, \"(\\?|&)$\", \"\");\n }\n\n # Bypass a cache hit (the request is still sent to the backend)\n if (req.method == \"REFRESH\") {\n if (!client.ip ~ purge) { return (synth(405, \"Not allowed\")); }\n set req.method = \"GET\";\n set req.hash_always_miss = true;\n }\n\n # Only allow BAN requests from IP addresses in the 'purge' ACL.\n if (req.method == \"BAN\" || req.method == \"URIBAN\" || req.method == \"PURGE\") {\n # Only allow BAN from defined ACL\n if (!client.ip ~ purge) {\n return (synth(403, \"Your IP is not allowed.\"));\n }\n\n # Only allows BAN if the Host Header has the style of with \"${SERVICE_NAME:-varnish}:8080\" or \"${SERVICE_NAME:-varnish}\".\n # Such a request is only possible from within the Docker network, as a request from external goes trough the Kubernetes Router and for that needs a proper Host Header\n if (!req.http.host ~ \"^${SERVICE_NAME:-varnish}(:\\d+)?$\") {\n return (synth(403, \"Only allowed from within own network.\"));\n }\n\n if (req.method == \"BAN\") {\n # Logic for the ban, using the Cache-Tags header.\n if (req.http.Cache-Tags) {\n ban(\"obj.http.Cache-Tags ~ \" + req.http.Cache-Tags);\n # Throw a synthetic page so the request won't go to the backend.\n return (synth(200, \"Ban added.\"));\n }\n else {\n return (synth(403, \"Cache-Tags header missing.\"));\n }\n }\n\n if (req.method == \"URIBAN\" || req.method == \"PURGE\") {\n ban(\"req.url ~ \" + req.url);\n # Throw a synthetic page so the request won't go to the backend.\n return (synth(200, \"Ban added.\"));\n }\n\n }\n\n # Non-RFC2616 or CONNECT which is weird, we pipe that\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n return (pipe);\n }\n\n # We only try to cache GET and HEAD, other things are passed\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n # Any requests with Basic Auth are passed\n if (req.http.Authorization || req.http.Authenticate)\n {\n return (pass);\n }\n\n ## Pass requests which are from blackfire\n if (req.http.X-Blackfire-Query) {\n return (pass);\n }\n\n # Some URLs should never be cached\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/admin([\/?]|$).*$\" ||\n req.url ~ \"^\/info([\/?]|$).*$\" ||\n req.url ~ \"^\/flag([\/?]|$).*$\" ||\n req.url ~ \"^.*\/system\/files([\/?]|$).*$\" ||\n req.url ~ \"^\/cgi\" ||\n req.url ~ \"^\/cgi-bin\"\n ) {\n return (pass);\n }\n\n # Plupload likes to get piped\n if (req.url ~ \"^.*\/plupload-handle-uploads.*$\"\n ) {\n return (pipe);\n }\n\n # Handle compression correctly. Different browsers send different\n # \"Accept-Encoding\" headers, even though they mostly all support the same\n # compression mechanisms. By consolidating these compression headers into\n # a consistent format, we can reduce the size of the cache and get more hits.=\n # @see: http:\/\/ varnish.projects.linpro.no\/wiki\/FAQ\/Compression\n if (req.http.Accept-Encoding) {\n if (req.http.Accept-Encoding ~ \"gzip\") {\n # If the browser supports it, we'll use gzip.\n set req.http.Accept-Encoding = \"gzip\";\n }\n else if (req.http.Accept-Encoding ~ \"deflate\") {\n # Next, try deflate if it is supported.\n set req.http.Accept-Encoding = \"deflate\";\n }\n else {\n # Unknown algorithm. Remove it and send unencoded.\n unset req.http.Accept-Encoding;\n }\n }\n\n # Always cache the following file types for all users.\n if (req.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n unset req.http.Cookie;\n }\n\n # Remove all cookies that Drupal doesn't need to know about. ANY remaining\n # cookie will cause the request to pass-through to a backend. For the most part\n # we always set the NO_CACHE cookie after any POST request, disabling the\n # Varnish cache temporarily. The session cookie allows all authenticated users\n # to pass through as long as they're logged in.\n #\n # 1. Append a semi-colon to the front of the cookie string.\n # 2. Remove all spaces that appear after semi-colons.\n # 3. Match the cookies we want to keep, adding the space we removed\n # previously, back. (\\1) is first matching group in the regsuball.\n # 4. Remove all other cookies, identifying them by the fact that they have\n # no space after the preceding semi-colon.\n # 5. Remove all spaces and semi-colons from the beginning and end of the\n # cookie string.\n if (req.http.Cookie) {\n set req.http.CookieCheck = \";\" + req.http.Cookie;\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"; +\", \";\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";(${VARNISH_COOKIECHECK:-SESS[a-z0-9]+|SSESS[a-z0-9]+|NO_CACHE})=\", \"; \\1=\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";[^ ][^;]*\", \"\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"^[; ]+|[; ]+$\", \"\");\n\n set req.http.Cookie = req.http.Cookie + \";\";\n\n if (req.http.CookieCheck == \"\") {\n # If there are no remaining cookies, remove the cookie header. If there\n # aren't any cookie headers, Varnish's default behavior will be to cache\n # the page.\n\n unset req.http.CookieCheck;\n unset req.http.Cookie;\n }\n else {\n # If there is any cookies left (a session or NO_CACHE cookie), do not\n # cache the page. Pass it on to Apache directly.\n unset req.http.CookieCheck;\n return (pass);\n }\n }\n\n # Cacheable, lookup in cache.\n return (hash);\n}\n\nsub vcl_pipe {\n # Support for Websockets\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n set bereq.http.connection = req.http.connection;\n }\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n # normal hit\n return (deliver);\n }\n # We have no fresh fish. Lets look at the stale ones.\n if (std.healthy(req.backend_hint)) {\n # Backend is healthy. If the object is not older then 30secs, deliver it to the client\n # and automatically create a separate backend request to warm the cache for this request.\n if (obj.ttl + 30s > 0s) {\n set req.http.grace = \"normal(limited)\";\n return (deliver);\n } else {\n # No candidate for grace. Fetch a fresh object.\n return(miss);\n }\n } else {\n # backend is sick - use full grace\n if (obj.ttl + obj.grace > 0s) {\n set req.http.grace = \"full\";\n return (deliver);\n } else {\n # no graced object.\n return (miss);\n }\n }\n}\n\nsub vcl_backend_response {\n # Allow items to be stale if needed.\n set beresp.grace = 6h;\n\n # Set ban-lurker friendly custom headers.\n set beresp.http.X-Url = bereq.url;\n set beresp.http.X-Host = bereq.http.host;\n\n # If the backend sends a X-LAGOON-VARNISH-BACKEND-BYPASS header we directly deliver\n if(beresp.http.X-LAGOON-VARNISH-BACKEND-BYPASS == \"TRUE\") {\n return (deliver);\n }\n\n # Cache 404 and 403 for 10 seconds\n if(beresp.status == 404 || beresp.status == 403) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n # Don't allow static files to set cookies.\n if (bereq.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n # beresp == Back-end response from the web server.\n unset beresp.http.set-cookie;\n unset beresp.http.Cache-Control;\n\n # If an asset would come back with statuscode 500 we only cache it for 10 seconds instead of the usual static file cache\n if (beresp.status == 500) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n set beresp.ttl = ${VARNISH_ASSETS_TTL:-2628001}s;\n set beresp.http.Cache-Control = \"public, max-age=${VARNISH_ASSETS_TTL:-2628001}\";\n set beresp.http.Expires = \"\" + (now + beresp.ttl);\n }\n\n return (deliver);\n}\n\n# Set a header to track a cache HIT\/MISS.\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Varnish-Cache = \"HIT\";\n }\n else {\n set resp.http.X-Varnish-Cache = \"MISS\";\n }\n\n # Remove ban-lurker friendly custom headers when delivering to client.\n unset resp.http.X-Url;\n unset resp.http.X-Host;\n\n # unset Cache-Tags Header by default, can be disabled with VARNISH_UNSET_HEADER_CACHE_TAGS=true\n if (!${VARNISH_UNSET_HEADER_CACHE_TAGS:-false}) {\n unset resp.http.Cache-Tags;\n }\n\n unset resp.http.X-Generator;\n unset resp.http.Server;\n # Inject information about grace\n if (req.http.grace) {\n set resp.http.X-Varnish-Grace = req.http.grace;\n }\n set resp.http.X-LAGOON = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}>\" + resp.http.X-LAGOON;\n return (deliver);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n if (req.http.X-Forwarded-Proto) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n if (req.http.HTTPS) {\n hash_data(req.http.HTTPS);\n }\n return (lookup);\n}\n\nsub vcl_synth {\n if (resp.status == 701) {\n set resp.status = 401;\n set resp.http.Content-Type = \"text\/plain; charset=utf-8\";\n synthetic({\"XMLRPC Interface is blocked due to SA-CORE-2014-004 - mail support@amazee.io if you need it.\"});\n return (deliver);\n }\n if (resp.status == 700) {\n # Set a status the client will understand\n set resp.status = 200;\n # Create our synthetic response\n synthetic(\"\");\n return(deliver);\n}\n return (deliver);\n}\n\nsub vcl_backend_error {\n # Restart the request, when we have a backend server error, to try another backend.\n # Restart max twice.\n if (bereq.retries < 2) {\n return(retry);\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<head>\n <title>Server Error<\/title>\n <style type=\"text\/css\">\n body {\n font-family: helvetica, arial, sans-serif;\n }\n img {\n margin-top: 50px;\n }\n p {\n width: 6 00px;\n margin-top: 10px\n }\n div {\n background: #ccc;\n width: 600px;\n margin: auto;\n padding: 50px;\n }\n span {\n color: #ccc\n }\n <\/style>\n<\/head>\n<body>\n <div>\n <h1>We are sorry...<\/h1>\n <p>We encountered a server-side error. This means that the problem is not with your computer or Internet connection, but rather with the website's server.<\/p>\n <p>We are currently working on solving this problem and apologise for the inconvenience.<\/p>\n <span>\n <strong>Technical Information<\/strong><br \/>\n Error \"} + beresp.status + \" \" + beresp.reason + {\"<br \/>\n XID: \"} + bereq.xid + {\"<br \/>\n <\/span>\n <\/div>\n<\/body>\n<\/html>\n\n\"} );\n return (deliver);\n}\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"6ef11ff86bad786df13f1e674112245239ae2538","subject":"#85: Don't pass ajax requests by default","message":"#85: Don't pass ajax requests by default\n","repos":"joomlatools\/joomla-vagrant,joomlatools\/joomla-vagrant,joomlatools\/joomla-vagrant,joomlatools\/joomlatools-vagrant,joomlatools\/joomlatools-vagrant,joomlatools\/joomla-vagrant,joomlatools\/joomlatools-vagrant,joomlatools\/joomlatools-vagrant,joomlatools\/joomla-vagrant,joomlatools\/joomlatools-vagrant,joomlatools\/joomla-vagrant","old_file":"puppet\/modules\/custom\/profiles\/files\/varnish\/joomla.box.vcl","new_file":"puppet\/modules\/custom\/profiles\/files\/varnish\/joomla.box.vcl","new_contents":"vcl 4.0;\n\n# This Varnish configuration is a very basic template to get started with caching Joomla sites.\n# In no way is this configuration complete: every site is unique and needs customisation!\n# For demonstration purposes this VCL will cache all front-end pages (including pages with cookies).\n\nimport std;\n\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n .probe = {\n .url = \"\/varnish-enabled\";\n .interval = 1s;\n .timeout = 1s;\n }\n}\n\nbackend alternative {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\n\nsub vcl_recv {\n # Forward client's IP to backend\n unset req.http.X-Forwarded-For;\n set req.http.X-Forwarded-For = client.ip;\n\n set req.http.X-Forwarded-By = server.ip;\n set req.http.X-Forwarded-Port = 80;\n\n # Check if we've still enabled Varnish, if not, passthrough every request\n set req.http.backend = \"default\";\n if (! std.healthy(req.backend_hint))\n {\n set req.backend_hint = alternative;\n set req.http.backend = \"alternative\";\n return (pass);\n }\n\n # Do not cache phpmyadmin\n if (req.http.host == \"phpmyadmin.joomla.box\") {\n return (pass);\n }\n\n # Do not cache system tools on joomla.box:\n if (req.http.host == \"joomla.box\")\n {\n if (req.url ~ \"^\/apc\" || req.url ~ \"^\/phpinfo\" || req.url ~ \"^\/pimpmylog\" || req.url ~ \"^\/dashboard\") {\n return (pass);\n }\n }\n\n # Do not cache ZendServer endpoint\n if (req.url ~ \"^\/ZendServer\") {\n return (pass);\n }\n\n # Do not cache POST requests\n if (req.method == \"POST\") {\n return (pass);\n }\n\n # Proxy (pass) any request that goes to the backend admin, the banner component links, ..\n if(req.url ~ \"\/administrator\" || req.url ~ \"\/component\/banners\" || req.url ~ \"\/component\/users\" || req.url ~ \"\/installation\") {\n return (pass);\n }\n\n # Do not cache if user is logged in\n if (req.http.Authorization || req.http.Authenticate) {\n return (pass);\n }\n\n # Properly handle different encoding types\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf)$\") {\n # No point in compressing these\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n # unknown algorithm (aka crappy browser)\n unset req.http.Accept-Encoding;\n }\n }\n\n return (hash);\n}\n\nsub vcl_backend_response {\n if(bereq.http.backend == \"alternative\")\n {\n set beresp.uncacheable = true;\n\n return(deliver);\n }\n\n # This is Joomla! specific: fix stupid \"no-cache\" header sent by Joomla! even\n # when caching is on - make sure to replace 300 with the number of seconds that\n # you want the browser to cache content\n if(beresp.http.Cache-Control ~ \"no-cache\" || beresp.http.Cache-Control == \"\"){\n set beresp.http.Cache-Control = \"max-age=300, public, must-revalidate\";\n }\n\n # Check for the custom \"x-Logged-In\" header to identify if the visitor is a guest,\n # then unset any cookie (including session cookies) provided it's not a POST request.\n if(bereq.method != \"POST\" && beresp.http.X-Logged-In == \"false\") {\n unset beresp.http.Set-Cookie;\n }\n\n # This is how long Varnish will cache content\n set beresp.ttl = 1w;\n\n return (deliver);\n}\n\nsub vcl_hash\n{\n hash_data(req.url);\n\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n\n # Hash cookies for requests that have them\n if (req.http.Cookie) {\n hash_data(req.http.Cookie);\n }\n}\n\nsub vcl_deliver {\n if (resp.http.x-varnish ~ \" \") {\n set resp.http.X-Varnish-Status = \"HIT\";\n } else {\n set resp.http.X-Varnish-Status = \"MISS\";\n }\n\n # Please note that obj.hits behaviour changed in 4.0, now it counts per objecthead, not per object\n # and obj.hits may not be reset in some cases where bans are in use. See bug 1492 for details.\n # So take hits with a grain of salt\n set resp.http.X-Varnish-Hits = obj.hits;\n}","old_contents":"vcl 4.0;\n\n# This Varnish configuration is a very basic template to get started with caching Joomla sites.\n# In no way is this configuration complete: every site is unique and needs customisation!\n# For demonstration purposes this VCL will cache all front-end pages (including pages with cookies).\n\nimport std;\n\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n .probe = {\n .url = \"\/varnish-enabled\";\n .interval = 1s;\n .timeout = 1s;\n }\n}\n\nbackend alternative {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\n\nsub vcl_recv {\n # Forward client's IP to backend\n unset req.http.X-Forwarded-For;\n set req.http.X-Forwarded-For = client.ip;\n\n set req.http.X-Forwarded-By = server.ip;\n set req.http.X-Forwarded-Port = 80;\n\n # Check if we've still enabled Varnish, if not, passthrough every request\n set req.http.backend = \"default\";\n if (! std.healthy(req.backend_hint))\n {\n set req.backend_hint = alternative;\n set req.http.backend = \"alternative\";\n return (pass);\n }\n\n # Do not cache phpmyadmin\n if (req.http.host == \"phpmyadmin.joomla.box\") {\n return (pass);\n }\n\n # Do not cache system tools on joomla.box:\n if (req.http.host == \"joomla.box\")\n {\n if (req.url ~ \"^\/apc\" || req.url ~ \"^\/phpinfo\" || req.url ~ \"^\/pimpmylog\" || req.url ~ \"^\/dashboard\") {\n return (pass);\n }\n }\n\n # Do not cache ZendServer endpoint\n if (req.url ~ \"^\/ZendServer\") {\n return (pass);\n }\n\n # Do not cache POST requests\n if (req.method == \"POST\") {\n return (pass);\n }\n\n # Proxy (pass) any request that goes to the backend admin, the banner component links, ..\n if(req.url ~ \"\/administrator\" || req.url ~ \"\/component\/banners\" || req.url ~ \"\/component\/users\" || req.url ~ \"\/installation\") {\n return (pass);\n }\n\n # Do not cache if user is logged in\n if (req.http.Authorization || req.http.Authenticate) {\n return (pass);\n }\n\n # Don't cache ajax requests\n if(req.http.X-Requested-With == \"XMLHttpRequest\" || req.url ~ \"nocache\") {\n return (pass);\n }\n\n # Properly handle different encoding types\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf)$\") {\n # No point in compressing these\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n # unknown algorithm (aka crappy browser)\n unset req.http.Accept-Encoding;\n }\n }\n\n return (hash);\n}\n\nsub vcl_backend_response {\n if(bereq.http.backend == \"alternative\")\n {\n set beresp.uncacheable = true;\n\n return(deliver);\n }\n\n # This is Joomla! specific: fix stupid \"no-cache\" header sent by Joomla! even\n # when caching is on - make sure to replace 300 with the number of seconds that\n # you want the browser to cache content\n if(beresp.http.Cache-Control ~ \"no-cache\" || beresp.http.Cache-Control == \"\"){\n set beresp.http.Cache-Control = \"max-age=300, public, must-revalidate\";\n }\n\n # Check for the custom \"x-Logged-In\" header to identify if the visitor is a guest,\n # then unset any cookie (including session cookies) provided it's not a POST request.\n if(bereq.method != \"POST\" && beresp.http.X-Logged-In == \"false\") {\n unset beresp.http.Set-Cookie;\n }\n\n # This is how long Varnish will cache content\n set beresp.ttl = 1w;\n\n return (deliver);\n}\n\nsub vcl_hash\n{\n hash_data(req.url);\n\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n\n # Hash cookies for requests that have them\n if (req.http.Cookie) {\n hash_data(req.http.Cookie);\n }\n}\n\nsub vcl_deliver {\n if (resp.http.x-varnish ~ \" \") {\n set resp.http.X-Varnish-Status = \"HIT\";\n } else {\n set resp.http.X-Varnish-Status = \"MISS\";\n }\n\n # Please note that obj.hits behaviour changed in 4.0, now it counts per objecthead, not per object\n # and obj.hits may not be reset in some cases where bans are in use. See bug 1492 for details.\n # So take hits with a grain of salt\n set resp.http.X-Varnish-Hits = obj.hits;\n}","returncode":0,"stderr":"","license":"mpl-2.0","lang":"VCL"} {"commit":"c8323dda31e1dc2fb16cbbabd0beb04a2640cb95","subject":"Updated instance name","message":"Updated instance name\n","repos":"karto\/varnish-edge_arch","old_file":"edge_arch.vcl","new_file":"edge_arch.vcl","new_contents":"\/\/ \n\/\/ Edge Architecture rules for Varnish 4\n\/\/ http:\/\/www.w3.org\/TR\/2001\/NOTE-edge-arch-20010804\n\/\/ \n\/\/ Author Karto Martin <source@karto.net>\n\/\/ Copyright (c) 2015 Karto Martin. All Right Reserved.\n\/\/ License The MIT License\n\/\/\n\n#######################################################################\n# Client side\n\n#sub edge_arch_recv {\n#}\n#sub edge_arch_pipe {\n#}\n#sub edge_arch_pass {\n#}\n#sub edge_arch_hash {\n#}\n#sub edge_arch_purge {\n#}\n#sub edge_arch_hit {\n#}\n#sub edge_arch_miss {\n#}\n#sub edge_arch_deliver {\n#}\n#sub edge_arch_synth {\n#}\n\n\n#######################################################################\n# Backend Fetch\n\nsub edge_arch_backend_fetch {\n # Send Surrogate-Capability headers to announce ESI support to backend\n if (bereq.http.Surrogate-Capability) {\n set bereq.http.Surrogate-Capability = bereq.http.Surrogate-Capability + \", \" + server.identity + {\"=\"Surrogate\/1.0 ESI\/1.0\"\"};\n }\n else {\n set bereq.http.Surrogate-Capability = server.identity + {\"=\"Surrogate\/1.0 ESI\/1.0\"\"};\n }\n}\nsub edge_arch_backend_response {\n \n ###\n # Parse Surrogate-Control for targeted or apply to all content=\"\"\n #\n call edge_arch_set_surrogate_control_content;\n \n ###\n # There are content to process\n #\n if (beresp.http.Surrogate-Control-Content) {\n \n ###\n # Just remove Surrogate\/1.0\n #\n if (beresp.http.Surrogate-Control-Content ~ \"(?i)(^|\\s)Surrogate\/1\\.0(\\s|$)\") {\n set beresp.http.Surrogate-Control-Content = regsub(regsub(beresp.http.Surrogate-Control-Content, \"(^|\\s)Surrogate\/1\\.0(?=\\s|$)\", \"\"), \"^\\s+\", \"\");\n }\n \n ###\n # Set do_esi and remove ESI\/1.0\n #\n if (beresp.http.Surrogate-Control-Content ~ \"(?i)(^|\\s)ESI\/1\\.0(\\s|$)\") {\n set beresp.http.Surrogate-Control-Content = regsub(regsub(beresp.http.Surrogate-Control-Content, \"(^|\\s)ESI\/1\\.0(?=\\s|$)\", \"\"), \"^\\s+\", \"\");\n set beresp.do_esi = true;\n }\n \n ###\n # Update Surrogate-Control with changes to targeted or apply to all content=\"\"\n #\n call edge_arch_set_surrogate_control;\n \n ###\n # Remove temp variable\n #\n unset beresp.http.Surrogate-Control-Content;\n \n }\n \n}\nsub edge_arch_backend_response_cacheable {\n\n ###\n # Only if caching have not already been determined\n #\n if ( ! beresp.http.X-Cacheable) {\n \n ###\n # Process Surrogate-Control and set X-Cacheable\n #\n call edge_arch_set_x_cacheable;\n \n ###\n # Surrogate-Control has a no-store directive\n #\n if (beresp.http.X-Cacheable ~ \"^sc:no-store\") {\n set beresp.ttl = 121s;\n set beresp.uncacheable = true;\n }\n \n ###\n # Surrogate-Control has a max-age directive\n #\n elsif (beresp.http.X-Cacheable ~ \"^sc:max-age\") {\n set beresp.ttl = std.duration(regsub(beresp.http.X-Cacheable, \"^.*=(\\d*)(\\+\\d*)?(;.*)?$\", \"\\1\")+\"s\", 0s);\n # Grace period\n if (beresp.http.Surrogate-Control ~ \"=\\d*\\+\\d*\") {\n set beresp.grace = std.duration(regsub(beresp.http.X-Cacheable, \"^.*=\\d*\\+(\\d*)(;.*)?$\", \"\\1\")+\"s\", 0s);\n }\n \/\/ https:\/\/tools.ietf.org\/html\/rfc7234#section-4.2\n \/\/ half Last-Modified: Sat, 23 May 2015 22:09:02 +0000\n # Calculating Heuristic Grace\n elsif (beresp.http.Last-Modified && std.time(beresp.http.Last-Modified, now) < now) {\n if ((now - std.time(beresp.http.Last-Modified, now)) * 0.5 > beresp.grace && \n (now - std.time(beresp.http.Last-Modified, now)) * 0.5 < beresp.keep) {\n if (\"edge_arch_vtc\" == server.identity) {\n set beresp.grace = std.duration(regsub(\"\"+((now - std.time(beresp.http.Last-Modified, now)) * 0.5), \"\\.\\d+$\", \"s\"), 0s);\n }\n else {\n set beresp.grace = (now - std.time(beresp.http.Last-Modified, now)) * 0.5;\n }\n }\n elsif ((now - std.time(beresp.http.Last-Modified, now)) * 0.5 >= beresp.keep) {\n set beresp.grace = beresp.keep;\n }\n }\n set beresp.uncacheable = false;\n }\n \n }\n}\n#sub edge_arch_backend_error {\n#}\n\n\n#######################################################################\n# Housekeeping\n\n#sub edge_arch_init {\n#}\n#sub edge_arch_fini {\n#}\n\n\n#######################################################################\n# Each Surrogate Control content\n\nsub edge_arch_set_surrogate_control_content {\n if (\"edge_arch_vtc\" != server.identity && \"www\" != server.identity && \"varnishdrupalol\" != server.identity) {\n std.log(\"edge_arch_backend_response: Need configuration to do Surrogate-Control Targeting for \"+server.identity+\"\");\n std.syslog(156, \"edge_arch_backend_response: Need configuration to do Surrogate-Control Targeting for \"+server.identity+\"\");\n header.append(beresp.http.Warning, \"699 \"+server.identity+{\" \"Need configuration to do Surrogate-Control Targeting for \"}+server.identity+{\"\" \"\"}+now+{\"\"\"});\n }\n if (\"edge_arch_vtc\" == server.identity && beresp.http.Surrogate-Control ~ {\"(?i)(^|,)\\s*content\\s*=\\s*\"[^\"]*\"\\s*;\\s*edge_arch_vtc\\s*(,|$)\"}) {\n set beresp.http.Surrogate-Control-Content = regsub(beresp.http.Surrogate-Control, {\"(?i)^(?:.*,)?\\s*content\\s*=\\s*\"([^\"]*)\"\\s*;\\s*edge_arch_vtc\\s*(?:,.*)?$\"}, \"\\1\");\n }\n elsif (\"www\" == server.identity && beresp.http.Surrogate-Control ~ {\"(?i)(^|,)\\s*content\\s*=\\s*\"[^\"]*\"\\s*;\\s*www\\s*(,|$)\"}) {\n set beresp.http.Surrogate-Control-Content = regsub(beresp.http.Surrogate-Control, {\"(?i)^(?:.*,)?\\s*content\\s*=\\s*\"([^\"]*)\"\\s*;\\s*www\\s*(?:,.*)?$\"}, \"\\1\");\n }\n elsif (\"varnishdrupalol\" == server.identity && beresp.http.Surrogate-Control ~ {\"(?i)(^|,)\\s*content\\s*=\\s*\"[^\"]*\"\\s*;\\s*varnishdrupalol\\s*(,|$)\"}) {\n set beresp.http.Surrogate-Control-Content = regsub(beresp.http.Surrogate-Control, {\"(?i)^(?:.*,)?\\s*content\\s*=\\s*\"([^\"]*)\"\\s*;\\s*varnishdrupalol\\s*(?:,.*)?$\"}, \"\\1\");\n }\n elsif (beresp.http.Surrogate-Control ~ {\"(?i)(^|,)\\s*content\\s*=\\s*\"[^\"]*\"\\s*(,|$)\"}) {\n set beresp.http.Surrogate-Control-Content = regsub(beresp.http.Surrogate-Control, {\"(?i)^(?:.*,)?\\s*content\\s*=\\s*\"([^\"]*)\"\\s*(?:,.*)?$\"}, \"\\1\");\n }\n}\n\nsub edge_arch_set_surrogate_control {\n \n ###\n # Update ;edge_arch_vtc\n #\n if (\"edge_arch_vtc\" == server.identity && beresp.http.Surrogate-Control ~ {\"(?i)(^|,)\\s*content\\s*=\\s*\"[^\"]*\"\\s*;\\s*edge_arch_vtc\\s*(,|$)\"}) {\n # Empty Surrogate-Control so unset\n if (beresp.http.Surrogate-Control-Content ~ \"^\\s*$\" && \n beresp.http.Surrogate-Control ~ {\"(?i)^\\s*content\\s*=\\s*\"[^\"]*\"\\s*;\\s*edge_arch_vtc\\s*$\"}) {\n unset beresp.http.Surrogate-Control;\n }\n # Empty Surrogate-Control-Content so remove\n elsif (beresp.http.Surrogate-Control-Content ~ \"^\\s*$\") {\n set beresp.http.Surrogate-Control = regsub(regsub(beresp.http.Surrogate-Control, \n {\"(?i)(^|,)\\s*content\\s*=\\s*\"[^\"]*\"\\s*;\\s*edge_arch_vtc\\s*(?=,|$)\"}, \"\"), \"^\\s*(,\\s*)?\", \"\");\n }\n # Update changed Surrogate-Control-Content\n elsif (beresp.http.Surrogate-Control-Content != regsub(beresp.http.Surrogate-Control, \n {\"(?i)^(?:.*,)?\\s*content\\s*=\\s*\"([^\"]*)\"\\s*;\\s*edge_arch_vtc\\s*(?:,.*)?$\"}, \"\\1\")) {\n set beresp.http.Surrogate-Control = regsub(beresp.http.Surrogate-Control, \n {\"(?i)((?:^|,)\\s*content\\s*=\\s*\")[^\"]*(\"\\s*;\\s*edge_arch_vtc\\s*)(?=,|$)\"}, \n \"\\1\"+beresp.http.Surrogate-Control-Content+\"\\2\");\n }\n }\n \n ###\n # Update ;www\n #\n elsif (\"www\" == server.identity && beresp.http.Surrogate-Control ~ {\"(?i)(^|,)\\s*content\\s*=\\s*\"[^\"]*\"\\s*;\\s*www\\s*(,|$)\"}) {\n # Empty Surrogate-Control so unset\n if (beresp.http.Surrogate-Control-Content ~ \"^\\s*$\" && \n beresp.http.Surrogate-Control ~ {\"(?i)^\\s*content\\s*=\\s*\"[^\"]*\"\\s*;\\s*www\\s*$\"}) {\n unset beresp.http.Surrogate-Control;\n }\n # Empty Surrogate-Control-Content so remove\n elsif (beresp.http.Surrogate-Control-Content ~ \"^\\s*$\") {\n set beresp.http.Surrogate-Control = regsub(regsub(beresp.http.Surrogate-Control, \n {\"(?i)(^|,)\\s*content\\s*=\\s*\"[^\"]*\"\\s*;\\s*www\\s*(?=,|$)\"}, \"\"), \"^\\s*(,\\s*)?\", \"\");\n }\n # Update changed Surrogate-Control-Content\n elsif (beresp.http.Surrogate-Control-Content != regsub(beresp.http.Surrogate-Control, \n {\"(?i)^(?:.*,)?\\s*content\\s*=\\s*\"([^\"]*)\"\\s*;\\s*www\\s*(?:,.*)?$\"}, \"\\1\")) {\n set beresp.http.Surrogate-Control = regsub(beresp.http.Surrogate-Control, \n {\"(?i)((?:^|,)\\s*content\\s*=\\s*\")[^\"]*(\"\\s*;\\s*www\\s*)(?=,|$)\"}, \n \"\\1\"+beresp.http.Surrogate-Control-Content+\"\\2\");\n }\n }\n \n ###\n # Update ;varnishdrupalol\n #\n elsif (\"varnishdrupalol\" == server.identity && beresp.http.Surrogate-Control ~ {\"(?i)(^|,)\\s*content\\s*=\\s*\"[^\"]*\"\\s*;\\s*varnishdrupalol\\s*(,|$)\"}) {\n # Empty Surrogate-Control so unset\n if (beresp.http.Surrogate-Control-Content ~ \"^\\s*$\" && \n beresp.http.Surrogate-Control ~ {\"(?i)^\\s*content\\s*=\\s*\"[^\"]*\"\\s*;\\s*varnishdrupalol\\s*$\"}) {\n unset beresp.http.Surrogate-Control;\n }\n # Empty Surrogate-Control-Content so remove\n elsif (beresp.http.Surrogate-Control-Content ~ \"^\\s*$\") {\n set beresp.http.Surrogate-Control = regsub(regsub(beresp.http.Surrogate-Control, \n {\"(?i)(^|,)\\s*content\\s*=\\s*\"[^\"]*\"\\s*;\\s*varnishdrupalol\\s*(?=,|$)\"}, \"\"), \"^\\s*(,\\s*)?\", \"\");\n }\n # Update changed Surrogate-Control-Content\n elsif (beresp.http.Surrogate-Control-Content != regsub(beresp.http.Surrogate-Control, \n {\"(?i)^(?:.*,)?\\s*content\\s*=\\s*\"([^\"]*)\"\\s*;\\s*varnishdrupalol\\s*(?:,.*)?$\"}, \"\\1\")) {\n set beresp.http.Surrogate-Control = regsub(beresp.http.Surrogate-Control, \n {\"(?i)((?:^|,)\\s*content\\s*=\\s*\")[^\"]*(\"\\s*;\\s*varnishdrupalol\\s*)(?=,|$)\"}, \n \"\\1\"+beresp.http.Surrogate-Control-Content+\"\\2\");\n }\n }\n \n ###\n # Update Apply to all\n #\n elsif (beresp.http.Surrogate-Control ~ {\"(?i)(^|,)\\s*content\\s*=\\s*\"[^\"]*\"\\s*(,|$)\"}) {\n # Empty Surrogate-Control so unset\n if (beresp.http.Surrogate-Control-Content ~ \"^\\s*$\" && \n beresp.http.Surrogate-Control ~ {\"(?i)^\\s*content\\s*=\\s*\"[^\"]*\"\\s*$\"}) {\n unset beresp.http.Surrogate-Control;\n }\n # Empty Surrogate-Control-Content so remove\n elsif (beresp.http.Surrogate-Control-Content ~ \"^\\s*$\") {\n set beresp.http.Surrogate-Control = regsub(regsub(beresp.http.Surrogate-Control, \n {\"(?i)(^|,)\\s*content\\s*=\\s*\"[^\"]*\"\\s*(?=,|$)\"}, \"\"), \"^\\s*(,\\s*)?\", \"\");\n }\n # Update changed Surrogate-Control-Content\n elsif (beresp.http.Surrogate-Control-Content != regsub(beresp.http.Surrogate-Control, \n {\"(?i)^(?:.*,)?\\s*content\\s*=\\s*\"([^\"]*)\"\\s*(?:,.*)?$\"}, \"\\1\")) {\n set beresp.http.Surrogate-Control = regsub(beresp.http.Surrogate-Control, \n {\"(?i)((?:^|,)\\s*content\\s*=\\s*\")[^\"]*(\"\\s*)(?=,|$)\"}, \n \"\\1\"+beresp.http.Surrogate-Control-Content+\"\\2\");\n }\n }\n\n}\n\n\n#######################################################################\n# Each Surrogate Control Targeted identities\n\nsub edge_arch_set_x_cacheable {\n \n ###\n # Process ;edge_arch_vtc\n #\n if (\"edge_arch_vtc\" == server.identity && beresp.http.Surrogate-Control ~ \n \"(?i)(^|,)\\s*(no-store|no-store-remote|max-age\\s*=\\s*\\d+(\\s*\\+\\s*\\d+)?)\\s*;\\s*edge_arch_vtc\\s*(,|$)\") {\n if (beresp.http.Surrogate-Control ~ \"(?i)(^|,)\\s*no-store\\s*;\\s*edge_arch_vtc\\s*(,|$)\") {\n set beresp.http.X-Cacheable = \"sc:no-store;edge_arch_vtc\";\n }\n elsif (beresp.http.Surrogate-Control ~ \"(?i)(^|,)\\s*max-age\\s*=\\s*\\d*(\\s*\\+\\s*\\d*)?\\s*;\\s*edge_arch_vtc\\s*(,|$)\") {\n set beresp.http.X-Cacheable = \"sc:max-age=\"+regsub(beresp.http.Surrogate-Control, \n \"(?i)^(?:.*,)?\\s*max-age\\s*=\\s*(\\d*)(?:\\s*(\\+)\\s*(\\d*))?\\s*;\\s*edge_arch_vtc\\s*(?:,.*)?$\", \n \"\\1\\2\\3\")+\";edge_arch_vtc\";\n }\n }\n ###\n # Process ;www\n #\n elsif (\"www\" == server.identity && beresp.http.Surrogate-Control ~ \n \"(?i)(^|,)\\s*(no-store|no-store-remote|max-age\\s*=\\s*\\d+(\\s*\\+\\s*\\d+)?)\\s*;\\s*www\\s*(,|$)\") {\n if (beresp.http.Surrogate-Control ~ \"(?i)(^|,)\\s*no-store\\s*;\\s*www\\s*(,|$)\") {\n set beresp.http.X-Cacheable = \"sc:no-store;www\";\n }\n elsif (beresp.http.Surrogate-Control ~ \"(?i)(^|,)\\s*max-age\\s*=\\s*\\d*(\\s*\\+\\s*\\d*)?\\s*;\\s*www\\s*(,|$)\") {\n set beresp.http.X-Cacheable = \"sc:max-age=\"+regsub(beresp.http.Surrogate-Control, \n \"(?i)^(?:.*,)?\\s*max-age\\s*=\\s*(\\d*)(?:\\s*(\\+)\\s*(\\d*))?\\s*;\\s*www\\s*(?:,.*)?$\", \n \"\\1\\2\\3\")+\";www\";\n }\n }\n ###\n # Process ;varnishdrupalol\n #\n elsif (\"varnishdrupalol\" == server.identity && beresp.http.Surrogate-Control ~ \n \"(?i)(^|,)\\s*(no-store|no-store-remote|max-age\\s*=\\s*\\d+(\\s*\\+\\s*\\d+)?)\\s*;\\s*varnishdrupalol\\s*(,|$)\") {\n if (beresp.http.Surrogate-Control ~ \"(?i)(^|,)\\s*no-store\\s*;\\s*varnishdrupalol\\s*(,|$)\") {\n set beresp.http.X-Cacheable = \"sc:no-store;varnishdrupalol\";\n }\n elsif (beresp.http.Surrogate-Control ~ \"(?i)(^|,)\\s*max-age\\s*=\\s*\\d*(\\s*\\+\\s*\\d*)?\\s*;\\s*varnishdrupalol\\s*(,|$)\") {\n set beresp.http.X-Cacheable = \"sc:max-age=\"+regsub(beresp.http.Surrogate-Control, \n \"(?i)^(?:.*,)?\\s*max-age\\s*=\\s*(\\d*)(?:\\s*(\\+)\\s*(\\d*))?\\s*;\\s*varnishdrupalol\\s*(?:,.*)?$\", \n \"\\1\\2\\3\")+\";varnishdrupalol\";\n }\n }\n ###\n # Process apply to all others\n #\n elsif (beresp.http.Surrogate-Control ~ \"(?i)(^|,)\\s*(no-store|no-store-remote|max-age\\s*=\\s*\\d+(\\s*\\+\\s*\\d+)?)\\s*(,|$)\") {\n if (beresp.http.Surrogate-Control ~ \"(?i)(^|,)\\s*no-store\\s*(,|$)\") {\n set beresp.http.X-Cacheable = \"sc:no-store\";\n }\n elsif (beresp.http.Surrogate-Control ~ \"(?i)(^|,)\\s*max-age\\s*=\\s*\\d*(\\s*\\+\\s*\\d*)?\\s*(,|$)\") {\n set beresp.http.X-Cacheable = \"sc:max-age=\"+regsub(beresp.http.Surrogate-Control, \n \"(?i)^(?:.*,)?\\s*max-age\\s*=\\s*(\\d*)(?:\\s*(\\+)\\s*(\\d*))?\\s*(?:,.*)?$\", \n \"\\1\\2\\3\")+\";edge_arch_vtc\";\n }\n }\n}\n","old_contents":"\/\/ \n\/\/ Edge Architecture rules for Varnish 4\n\/\/ http:\/\/www.w3.org\/TR\/2001\/NOTE-edge-arch-20010804\n\/\/ \n\/\/ Author Karto Martin <source@karto.net>\n\/\/ Copyright (c) 2015 Karto Martin. All Right Reserved.\n\/\/ License The MIT License\n\/\/\n\n#######################################################################\n# Client side\n\n#sub edge_arch_recv {\n#}\n#sub edge_arch_pipe {\n#}\n#sub edge_arch_pass {\n#}\n#sub edge_arch_hash {\n#}\n#sub edge_arch_purge {\n#}\n#sub edge_arch_hit {\n#}\n#sub edge_arch_miss {\n#}\n#sub edge_arch_deliver {\n#}\n#sub edge_arch_synth {\n#}\n\n\n#######################################################################\n# Backend Fetch\n\nsub edge_arch_backend_fetch {\n # Send Surrogate-Capability headers to announce ESI support to backend\n if (bereq.http.Surrogate-Capability) {\n set bereq.http.Surrogate-Capability = bereq.http.Surrogate-Capability + \", \" + server.identity + {\"=\"Surrogate\/1.0 ESI\/1.0\"\"};\n }\n else {\n set bereq.http.Surrogate-Capability = server.identity + {\"=\"Surrogate\/1.0 ESI\/1.0\"\"};\n }\n}\nsub edge_arch_backend_response {\n \n ###\n # Parse Surrogate-Control for targeted or apply to all content=\"\"\n #\n call edge_arch_set_surrogate_control_content;\n \n ###\n # There are content to process\n #\n if (beresp.http.Surrogate-Control-Content) {\n \n ###\n # Just remove Surrogate\/1.0\n #\n if (beresp.http.Surrogate-Control-Content ~ \"(?i)(^|\\s)Surrogate\/1\\.0(\\s|$)\") {\n set beresp.http.Surrogate-Control-Content = regsub(regsub(beresp.http.Surrogate-Control-Content, \"(^|\\s)Surrogate\/1\\.0(?=\\s|$)\", \"\"), \"^\\s+\", \"\");\n }\n \n ###\n # Set do_esi and remove ESI\/1.0\n #\n if (beresp.http.Surrogate-Control-Content ~ \"(?i)(^|\\s)ESI\/1\\.0(\\s|$)\") {\n set beresp.http.Surrogate-Control-Content = regsub(regsub(beresp.http.Surrogate-Control-Content, \"(^|\\s)ESI\/1\\.0(?=\\s|$)\", \"\"), \"^\\s+\", \"\");\n set beresp.do_esi = true;\n }\n \n ###\n # Update Surrogate-Control with changes to targeted or apply to all content=\"\"\n #\n call edge_arch_set_surrogate_control;\n \n ###\n # Remove temp variable\n #\n unset beresp.http.Surrogate-Control-Content;\n \n }\n \n}\nsub edge_arch_backend_response_cacheable {\n\n ###\n # Only if caching have not already been determined\n #\n if ( ! beresp.http.X-Cacheable) {\n \n ###\n # Process Surrogate-Control and set X-Cacheable\n #\n call edge_arch_set_x_cacheable;\n \n ###\n # Surrogate-Control has a no-store directive\n #\n if (beresp.http.X-Cacheable ~ \"^sc:no-store\") {\n set beresp.ttl = 121s;\n set beresp.uncacheable = true;\n }\n \n ###\n # Surrogate-Control has a max-age directive\n #\n elsif (beresp.http.X-Cacheable ~ \"^sc:max-age\") {\n set beresp.ttl = std.duration(regsub(beresp.http.X-Cacheable, \"^.*=(\\d*)(\\+\\d*)?(;.*)?$\", \"\\1\")+\"s\", 0s);\n # Grace period\n if (beresp.http.Surrogate-Control ~ \"=\\d*\\+\\d*\") {\n set beresp.grace = std.duration(regsub(beresp.http.X-Cacheable, \"^.*=\\d*\\+(\\d*)(;.*)?$\", \"\\1\")+\"s\", 0s);\n }\n \/\/ https:\/\/tools.ietf.org\/html\/rfc7234#section-4.2\n \/\/ half Last-Modified: Sat, 23 May 2015 22:09:02 +0000\n # Calculating Heuristic Grace\n elsif (beresp.http.Last-Modified && std.time(beresp.http.Last-Modified, now) < now) {\n if ((now - std.time(beresp.http.Last-Modified, now)) * 0.5 > beresp.grace && \n (now - std.time(beresp.http.Last-Modified, now)) * 0.5 < beresp.keep) {\n if (\"edge_arch_vtc\" == server.identity) {\n set beresp.grace = std.duration(regsub(\"\"+((now - std.time(beresp.http.Last-Modified, now)) * 0.5), \"\\.\\d+$\", \"s\"), 0s);\n }\n else {\n set beresp.grace = (now - std.time(beresp.http.Last-Modified, now)) * 0.5;\n }\n }\n elsif ((now - std.time(beresp.http.Last-Modified, now)) * 0.5 >= beresp.keep) {\n set beresp.grace = beresp.keep;\n }\n }\n set beresp.uncacheable = false;\n }\n \n }\n}\n#sub edge_arch_backend_error {\n#}\n\n\n#######################################################################\n# Housekeeping\n\n#sub edge_arch_init {\n#}\n#sub edge_arch_fini {\n#}\n\n\n#######################################################################\n# Each Surrogate Control content\n\nsub edge_arch_set_surrogate_control_content {\n if (\"edge_arch_vtc\" != server.identity && \"www\" != server.identity && \"drupal\" != server.identity) {\n std.log(\"edge_arch_backend_response: Need configuration to do Surrogate-Control Targeting for \"+server.identity+\"\");\n std.syslog(156, \"edge_arch_backend_response: Need configuration to do Surrogate-Control Targeting for \"+server.identity+\"\");\n header.append(beresp.http.Warning, \"699 \"+server.identity+{\" \"Need configuration to do Surrogate-Control Targeting for \"}+server.identity+{\"\" \"\"}+now+{\"\"\"});\n }\n if (\"edge_arch_vtc\" == server.identity && beresp.http.Surrogate-Control ~ {\"(?i)(^|,)\\s*content\\s*=\\s*\"[^\"]*\"\\s*;\\s*edge_arch_vtc\\s*(,|$)\"}) {\n set beresp.http.Surrogate-Control-Content = regsub(beresp.http.Surrogate-Control, {\"(?i)^(?:.*,)?\\s*content\\s*=\\s*\"([^\"]*)\"\\s*;\\s*edge_arch_vtc\\s*(?:,.*)?$\"}, \"\\1\");\n }\n elsif (\"www\" == server.identity && beresp.http.Surrogate-Control ~ {\"(?i)(^|,)\\s*content\\s*=\\s*\"[^\"]*\"\\s*;\\s*www\\s*(,|$)\"}) {\n set beresp.http.Surrogate-Control-Content = regsub(beresp.http.Surrogate-Control, {\"(?i)^(?:.*,)?\\s*content\\s*=\\s*\"([^\"]*)\"\\s*;\\s*www\\s*(?:,.*)?$\"}, \"\\1\");\n }\n elsif (\"drupal\" == server.identity && beresp.http.Surrogate-Control ~ {\"(?i)(^|,)\\s*content\\s*=\\s*\"[^\"]*\"\\s*;\\s*drupal\\s*(,|$)\"}) {\n set beresp.http.Surrogate-Control-Content = regsub(beresp.http.Surrogate-Control, {\"(?i)^(?:.*,)?\\s*content\\s*=\\s*\"([^\"]*)\"\\s*;\\s*drupal\\s*(?:,.*)?$\"}, \"\\1\");\n }\n elsif (beresp.http.Surrogate-Control ~ {\"(?i)(^|,)\\s*content\\s*=\\s*\"[^\"]*\"\\s*(,|$)\"}) {\n set beresp.http.Surrogate-Control-Content = regsub(beresp.http.Surrogate-Control, {\"(?i)^(?:.*,)?\\s*content\\s*=\\s*\"([^\"]*)\"\\s*(?:,.*)?$\"}, \"\\1\");\n }\n}\n\nsub edge_arch_set_surrogate_control {\n \n ###\n # Update ;edge_arch_vtc\n #\n if (\"edge_arch_vtc\" == server.identity && beresp.http.Surrogate-Control ~ {\"(?i)(^|,)\\s*content\\s*=\\s*\"[^\"]*\"\\s*;\\s*edge_arch_vtc\\s*(,|$)\"}) {\n # Empty Surrogate-Control so unset\n if (beresp.http.Surrogate-Control-Content ~ \"^\\s*$\" && \n beresp.http.Surrogate-Control ~ {\"(?i)^\\s*content\\s*=\\s*\"[^\"]*\"\\s*;\\s*edge_arch_vtc\\s*$\"}) {\n unset beresp.http.Surrogate-Control;\n }\n # Empty Surrogate-Control-Content so remove\n elsif (beresp.http.Surrogate-Control-Content ~ \"^\\s*$\") {\n set beresp.http.Surrogate-Control = regsub(regsub(beresp.http.Surrogate-Control, \n {\"(?i)(^|,)\\s*content\\s*=\\s*\"[^\"]*\"\\s*;\\s*edge_arch_vtc\\s*(?=,|$)\"}, \"\"), \"^\\s*(,\\s*)?\", \"\");\n }\n # Update changed Surrogate-Control-Content\n elsif (beresp.http.Surrogate-Control-Content != regsub(beresp.http.Surrogate-Control, \n {\"(?i)^(?:.*,)?\\s*content\\s*=\\s*\"([^\"]*)\"\\s*;\\s*edge_arch_vtc\\s*(?:,.*)?$\"}, \"\\1\")) {\n set beresp.http.Surrogate-Control = regsub(beresp.http.Surrogate-Control, \n {\"(?i)((?:^|,)\\s*content\\s*=\\s*\")[^\"]*(\"\\s*;\\s*edge_arch_vtc\\s*)(?=,|$)\"}, \n \"\\1\"+beresp.http.Surrogate-Control-Content+\"\\2\");\n }\n }\n \n ###\n # Update ;www\n #\n elsif (\"www\" == server.identity && beresp.http.Surrogate-Control ~ {\"(?i)(^|,)\\s*content\\s*=\\s*\"[^\"]*\"\\s*;\\s*www\\s*(,|$)\"}) {\n # Empty Surrogate-Control so unset\n if (beresp.http.Surrogate-Control-Content ~ \"^\\s*$\" && \n beresp.http.Surrogate-Control ~ {\"(?i)^\\s*content\\s*=\\s*\"[^\"]*\"\\s*;\\s*www\\s*$\"}) {\n unset beresp.http.Surrogate-Control;\n }\n # Empty Surrogate-Control-Content so remove\n elsif (beresp.http.Surrogate-Control-Content ~ \"^\\s*$\") {\n set beresp.http.Surrogate-Control = regsub(regsub(beresp.http.Surrogate-Control, \n {\"(?i)(^|,)\\s*content\\s*=\\s*\"[^\"]*\"\\s*;\\s*www\\s*(?=,|$)\"}, \"\"), \"^\\s*(,\\s*)?\", \"\");\n }\n # Update changed Surrogate-Control-Content\n elsif (beresp.http.Surrogate-Control-Content != regsub(beresp.http.Surrogate-Control, \n {\"(?i)^(?:.*,)?\\s*content\\s*=\\s*\"([^\"]*)\"\\s*;\\s*www\\s*(?:,.*)?$\"}, \"\\1\")) {\n set beresp.http.Surrogate-Control = regsub(beresp.http.Surrogate-Control, \n {\"(?i)((?:^|,)\\s*content\\s*=\\s*\")[^\"]*(\"\\s*;\\s*www\\s*)(?=,|$)\"}, \n \"\\1\"+beresp.http.Surrogate-Control-Content+\"\\2\");\n }\n }\n \n ###\n # Update ;drupal\n #\n elsif (\"drupal\" == server.identity && beresp.http.Surrogate-Control ~ {\"(?i)(^|,)\\s*content\\s*=\\s*\"[^\"]*\"\\s*;\\s*drupal\\s*(,|$)\"}) {\n # Empty Surrogate-Control so unset\n if (beresp.http.Surrogate-Control-Content ~ \"^\\s*$\" && \n beresp.http.Surrogate-Control ~ {\"(?i)^\\s*content\\s*=\\s*\"[^\"]*\"\\s*;\\s*drupal\\s*$\"}) {\n unset beresp.http.Surrogate-Control;\n }\n # Empty Surrogate-Control-Content so remove\n elsif (beresp.http.Surrogate-Control-Content ~ \"^\\s*$\") {\n set beresp.http.Surrogate-Control = regsub(regsub(beresp.http.Surrogate-Control, \n {\"(?i)(^|,)\\s*content\\s*=\\s*\"[^\"]*\"\\s*;\\s*drupal\\s*(?=,|$)\"}, \"\"), \"^\\s*(,\\s*)?\", \"\");\n }\n # Update changed Surrogate-Control-Content\n elsif (beresp.http.Surrogate-Control-Content != regsub(beresp.http.Surrogate-Control, \n {\"(?i)^(?:.*,)?\\s*content\\s*=\\s*\"([^\"]*)\"\\s*;\\s*drupal\\s*(?:,.*)?$\"}, \"\\1\")) {\n set beresp.http.Surrogate-Control = regsub(beresp.http.Surrogate-Control, \n {\"(?i)((?:^|,)\\s*content\\s*=\\s*\")[^\"]*(\"\\s*;\\s*drupal\\s*)(?=,|$)\"}, \n \"\\1\"+beresp.http.Surrogate-Control-Content+\"\\2\");\n }\n }\n \n ###\n # Update Apply to all\n #\n elsif (beresp.http.Surrogate-Control ~ {\"(?i)(^|,)\\s*content\\s*=\\s*\"[^\"]*\"\\s*(,|$)\"}) {\n # Empty Surrogate-Control so unset\n if (beresp.http.Surrogate-Control-Content ~ \"^\\s*$\" && \n beresp.http.Surrogate-Control ~ {\"(?i)^\\s*content\\s*=\\s*\"[^\"]*\"\\s*$\"}) {\n unset beresp.http.Surrogate-Control;\n }\n # Empty Surrogate-Control-Content so remove\n elsif (beresp.http.Surrogate-Control-Content ~ \"^\\s*$\") {\n set beresp.http.Surrogate-Control = regsub(regsub(beresp.http.Surrogate-Control, \n {\"(?i)(^|,)\\s*content\\s*=\\s*\"[^\"]*\"\\s*(?=,|$)\"}, \"\"), \"^\\s*(,\\s*)?\", \"\");\n }\n # Update changed Surrogate-Control-Content\n elsif (beresp.http.Surrogate-Control-Content != regsub(beresp.http.Surrogate-Control, \n {\"(?i)^(?:.*,)?\\s*content\\s*=\\s*\"([^\"]*)\"\\s*(?:,.*)?$\"}, \"\\1\")) {\n set beresp.http.Surrogate-Control = regsub(beresp.http.Surrogate-Control, \n {\"(?i)((?:^|,)\\s*content\\s*=\\s*\")[^\"]*(\"\\s*)(?=,|$)\"}, \n \"\\1\"+beresp.http.Surrogate-Control-Content+\"\\2\");\n }\n }\n\n}\n\n\n#######################################################################\n# Each Surrogate Control Targeted identities\n\nsub edge_arch_set_x_cacheable {\n \n ###\n # Process ;edge_arch_vtc\n #\n if (\"edge_arch_vtc\" == server.identity && beresp.http.Surrogate-Control ~ \n \"(?i)(^|,)\\s*(no-store|no-store-remote|max-age\\s*=\\s*\\d+(\\s*\\+\\s*\\d+)?)\\s*;\\s*edge_arch_vtc\\s*(,|$)\") {\n if (beresp.http.Surrogate-Control ~ \"(?i)(^|,)\\s*no-store\\s*;\\s*edge_arch_vtc\\s*(,|$)\") {\n set beresp.http.X-Cacheable = \"sc:no-store;edge_arch_vtc\";\n }\n elsif (beresp.http.Surrogate-Control ~ \"(?i)(^|,)\\s*max-age\\s*=\\s*\\d*(\\s*\\+\\s*\\d*)?\\s*;\\s*edge_arch_vtc\\s*(,|$)\") {\n set beresp.http.X-Cacheable = \"sc:max-age=\"+regsub(beresp.http.Surrogate-Control, \n \"(?i)^(?:.*,)?\\s*max-age\\s*=\\s*(\\d*)(?:\\s*(\\+)\\s*(\\d*))?\\s*;\\s*edge_arch_vtc\\s*(?:,.*)?$\", \n \"\\1\\2\\3\")+\";edge_arch_vtc\";\n }\n }\n ###\n # Process ;www\n #\n elsif (\"www\" == server.identity && beresp.http.Surrogate-Control ~ \n \"(?i)(^|,)\\s*(no-store|no-store-remote|max-age\\s*=\\s*\\d+(\\s*\\+\\s*\\d+)?)\\s*;\\s*www\\s*(,|$)\") {\n if (beresp.http.Surrogate-Control ~ \"(?i)(^|,)\\s*no-store\\s*;\\s*www\\s*(,|$)\") {\n set beresp.http.X-Cacheable = \"sc:no-store;www\";\n }\n elsif (beresp.http.Surrogate-Control ~ \"(?i)(^|,)\\s*max-age\\s*=\\s*\\d*(\\s*\\+\\s*\\d*)?\\s*;\\s*www\\s*(,|$)\") {\n set beresp.http.X-Cacheable = \"sc:max-age=\"+regsub(beresp.http.Surrogate-Control, \n \"(?i)^(?:.*,)?\\s*max-age\\s*=\\s*(\\d*)(?:\\s*(\\+)\\s*(\\d*))?\\s*;\\s*www\\s*(?:,.*)?$\", \n \"\\1\\2\\3\")+\";www\";\n }\n }\n ###\n # Process ;drupal\n #\n elsif (\"drupal\" == server.identity && beresp.http.Surrogate-Control ~ \n \"(?i)(^|,)\\s*(no-store|no-store-remote|max-age\\s*=\\s*\\d+(\\s*\\+\\s*\\d+)?)\\s*;\\s*drupal\\s*(,|$)\") {\n if (beresp.http.Surrogate-Control ~ \"(?i)(^|,)\\s*no-store\\s*;\\s*drupal\\s*(,|$)\") {\n set beresp.http.X-Cacheable = \"sc:no-store;drupal\";\n }\n elsif (beresp.http.Surrogate-Control ~ \"(?i)(^|,)\\s*max-age\\s*=\\s*\\d*(\\s*\\+\\s*\\d*)?\\s*;\\s*drupal\\s*(,|$)\") {\n set beresp.http.X-Cacheable = \"sc:max-age=\"+regsub(beresp.http.Surrogate-Control, \n \"(?i)^(?:.*,)?\\s*max-age\\s*=\\s*(\\d*)(?:\\s*(\\+)\\s*(\\d*))?\\s*;\\s*drupal\\s*(?:,.*)?$\", \n \"\\1\\2\\3\")+\";drupal\";\n }\n }\n ###\n # Process apply to all others\n #\n elsif (beresp.http.Surrogate-Control ~ \"(?i)(^|,)\\s*(no-store|no-store-remote|max-age\\s*=\\s*\\d+(\\s*\\+\\s*\\d+)?)\\s*(,|$)\") {\n if (beresp.http.Surrogate-Control ~ \"(?i)(^|,)\\s*no-store\\s*(,|$)\") {\n set beresp.http.X-Cacheable = \"sc:no-store\";\n }\n elsif (beresp.http.Surrogate-Control ~ \"(?i)(^|,)\\s*max-age\\s*=\\s*\\d*(\\s*\\+\\s*\\d*)?\\s*(,|$)\") {\n set beresp.http.X-Cacheable = \"sc:max-age=\"+regsub(beresp.http.Surrogate-Control, \n \"(?i)^(?:.*,)?\\s*max-age\\s*=\\s*(\\d*)(?:\\s*(\\+)\\s*(\\d*))?\\s*(?:,.*)?$\", \n \"\\1\\2\\3\")+\";edge_arch_vtc\";\n }\n }\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"a97acc7b6c12393077fcf31d116affcb8187f113","subject":"Configuration for Varnish.","message":"Configuration for Varnish.\n","repos":"cebartling\/reverse-proxy-url-rewrite-experiment,cebartling\/reverse-proxy-url-rewrite-experiment","old_file":"proxy-servers\/varnish\/default.vcl","new_file":"proxy-servers\/varnish\/default.vcl","new_contents":"# This is a Varnish 4.x VCL file\nvcl 4.0;\n\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"3000\";\n}\n\nbackend sinatra {\n .host = \"127.0.0.1\";\n .port = \"4567\";\n}\n\nbackend nodejs {\n .host = \"127.0.0.1\";\n .port = \"5678\";\n}\n\n# Handle the HTTP request received by the client\nsub vcl_recv {\n\tif (req.url ~ \"^\/api\/v1\/products\") {\n set req.backend_hint = sinatra;\n } else if (req.url ~ \"^\/api\/v2\/products\") {\n set req.backend_hint = sinatra;\n } else if (req.url ~ \"^\/api\/v3\/products\") {\n set req.backend_hint = nodejs;\n } else {\n set req.backend_hint = default;\n }\n}\n\n","old_contents":"# This is a Varnish 4.x VCL file\nvcl 4.0;\n\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"3000\";\n # .probe = {\n # .url = \"\/ping\";\n # .timeout = 1s;\n # .interval = 10s;\n # .window = 5;\n # .threshold = 2;\n # }\n # .first_byte_timeout = 300s; # How long to wait before we receive a first byte from our backend?\n # .connect_timeout = 5s; # How long to wait for a backend connection?\n # .between_bytes_timeout = 2s; # How long to wait between bytes received from our backend?\n}\n\nbackend sinatra {\n .host = \"127.0.0.1\";\n .port = \"4567\";\n}\n\n# backend nodejs {\n# .host = \"127.0.0.1\";\n# .port = \"5678\";\n# }\n\n# Handle the HTTP request received by the client\nsub vcl_recv {\n\tif (req.url ~ \"^\/api\/v1\/products\") {\n set req.backend_hint = sinatra;\n } else if (req.url ~ \"^\/api\/v2\/products\") {\n set req.backend_hint = sinatra;\n } else {\n set req.backend_hint = default;\n }\n}\n\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"42455c0d1f4e602388aa70e5c29a78d1bf7f3e03","subject":"This needs to be a string","message":"This needs to be a string\n","repos":"HonzaKral\/warehouse,dstufft\/warehouse,alex\/warehouse,alex\/warehouse,karan\/warehouse,pypa\/warehouse,ismail-s\/warehouse,dstufft\/warehouse,wlonk\/warehouse,wlonk\/warehouse,alex\/warehouse,ismail-s\/warehouse,karan\/warehouse,dstufft\/warehouse,pypa\/warehouse,HonzaKral\/warehouse,ismail-s\/warehouse,HonzaKral\/warehouse,ismail-s\/warehouse,alex\/warehouse,dstufft\/warehouse,ismail-s\/warehouse,HonzaKral\/warehouse,alex\/warehouse,karan\/warehouse,pypa\/warehouse,pypa\/warehouse,wlonk\/warehouse,karan\/warehouse,karan\/warehouse","old_file":"vcl\/main.vcl","new_file":"vcl\/main.vcl","new_contents":"\nsub vcl_recv {\n#FASTLY recv\n\n # We want to Force SSL for the WebUI by redirecting to the HTTPS version of\n # the page, however for API calls we want to return an error code directing\n # people to instead use HTTPS.\n if (!req.http.Fastly-SSL) {\n\n # The \/simple\/ and \/packages\/ API.\n if (req.url ~ \"^\/(simple|packages)\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy JSON API.\n if (req.url ~ \"^\/pypi\/.+\/json$\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy ?:action= API.\n if (req.url ~ \"^\/pypi.*(\\?|&)=:action\") {\n error 803 \"SSL is required\";\n }\n\n # If we're on the \/pypi page and we've received something other than a\n # GET or HEAD request, then we have no way to determine if a particular\n # request is an API call or not because it'll be in the request body\n # and that isn't available to us here. So in those cases, we won't\n # do a redirect.\n if (req.url ~ \"^\/pypi\") {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n error 801 \"Force SSL\";\n }\n }\n else {\n # This isn't a \/pypi URL so we'll just unconditionally redirect to\n # HTTPS.\n error 801 \"Force SSL\";\n }\n }\n\n # Tell Varnish to use X-Forwarded-Proto to set the \"real\" protocol http\n # or https.\n if (req.http.Fastly-SSL) {\n set req.http.X-Forwarded-Proto = \"https\";\n }\n else {\n set req.http.X-Forwarded-Proto = \"http\";\n }\n\n # Do not bother to attempt to run the caching mechanisms for methods that\n # are not generally safe to cache.\n if (req.request != \"HEAD\" &&\n req.request != \"GET\" &&\n req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n # Finally, return the default lookup action.\n return(lookup);\n}\n\n\nsub vcl_fetch {\n#FASTLY fetch\n\n # Trigger a \"SSL is required\" error if the backend has indicated to do so.\n if (beresp.http.X-Fastly-Error == \"803\") {\n error 803 \"SSL is required\";\n }\n\n # If we've gotten a 500 or a 503 from the backend, we'll go ahead and retry\n # the request.\n if ((beresp.status == 500 || beresp.status == 503) &&\n req.restarts < 1 &&\n (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n # If we've restarted, then we'll record the number of restarts.\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n # If there is a Set-Cookie header, we'll ensure that we do not cache the\n # response.\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n # If the response has the private Cache-Control directive then we won't\n # cache it.\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # If we've gotten an error after the restarts we'll deliver the response\n # with a very short cache time.\n if (beresp.status == 500 || beresp.status == 503) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n # Apply a default TTL if there isn't a max-age or s-maxage.\n if (beresp.http.Expires ||\n beresp.http.Surrogate-Control ~ \"max-age\" ||\n beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # Keep the ttl here\n }\n else {\n # Apply the default ttl\n set beresp.ttl = 3600s;\n }\n\n # Actually deliver the fetched response.\n return(deliver);\n}\n\n\nsub vcl_error {\n#FASTLY error\n\n if (obj.status == 803) {\n set obj.status = 403;\n set obj.response = \"SSL is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic {\"SSL is required.\"};\n return (deliver);\n }\n}\n","old_contents":"\nsub vcl_recv {\n#FASTLY recv\n\n # We want to Force SSL for the WebUI by redirecting to the HTTPS version of\n # the page, however for API calls we want to return an error code directing\n # people to instead use HTTPS.\n if (!req.http.Fastly-SSL) {\n\n # The \/simple\/ and \/packages\/ API.\n if (req.url ~ \"^\/(simple|packages)\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy JSON API.\n if (req.url ~ \"^\/pypi\/.+\/json$\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy ?:action= API.\n if (req.url ~ \"^\/pypi.*(\\?|&)=:action\") {\n error 803 \"SSL is required\";\n }\n\n # If we're on the \/pypi page and we've received something other than a\n # GET or HEAD request, then we have no way to determine if a particular\n # request is an API call or not because it'll be in the request body\n # and that isn't available to us here. So in those cases, we won't\n # do a redirect.\n if (req.url ~ \"^\/pypi\") {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n error 801 \"Force SSL\";\n }\n }\n else {\n # This isn't a \/pypi URL so we'll just unconditionally redirect to\n # HTTPS.\n error 801 \"Force SSL\";\n }\n }\n\n # Tell Varnish to use X-Forwarded-Proto to set the \"real\" protocol http\n # or https.\n if (req.http.Fastly-SSL) {\n set req.http.X-Forwarded-Proto = \"https\";\n }\n else {\n set req.http.X-Forwarded-Proto = \"http\";\n }\n\n # Do not bother to attempt to run the caching mechanisms for methods that\n # are not generally safe to cache.\n if (req.request != \"HEAD\" &&\n req.request != \"GET\" &&\n req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n # Finally, return the default lookup action.\n return(lookup);\n}\n\n\nsub vcl_fetch {\n#FASTLY fetch\n\n # Trigger a \"SSL is required\" error if the backend has indicated to do so.\n if (beresp.http.X-Fastly-Error == 803) {\n error 803 \"SSL is required\";\n }\n\n # If we've gotten a 500 or a 503 from the backend, we'll go ahead and retry\n # the request.\n if ((beresp.status == 500 || beresp.status == 503) &&\n req.restarts < 1 &&\n (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n # If we've restarted, then we'll record the number of restarts.\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n # If there is a Set-Cookie header, we'll ensure that we do not cache the\n # response.\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n # If the response has the private Cache-Control directive then we won't\n # cache it.\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # If we've gotten an error after the restarts we'll deliver the response\n # with a very short cache time.\n if (beresp.status == 500 || beresp.status == 503) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n # Apply a default TTL if there isn't a max-age or s-maxage.\n if (beresp.http.Expires ||\n beresp.http.Surrogate-Control ~ \"max-age\" ||\n beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # Keep the ttl here\n }\n else {\n # Apply the default ttl\n set beresp.ttl = 3600s;\n }\n\n # Actually deliver the fetched response.\n return(deliver);\n}\n\n\nsub vcl_error {\n#FASTLY error\n\n if (obj.status == 803) {\n set obj.status = 403;\n set obj.response = \"SSL is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic {\"SSL is required.\"};\n return (deliver);\n }\n}\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"62746fa063823f817c5cb0e5ece851cc00f3ffb7","subject":"Tinker with TTLs on Cache-Control requests","message":"Tinker with TTLs on Cache-Control requests\n","repos":"trevorparker\/dockerfiles","old_file":"varnish\/default.vcl","new_file":"varnish\/default.vcl","new_contents":"backend default {\n .host = \"127.0.0.1\";\n .port = \"80\";\n}\n\nsub vcl_fetch {\n if (beresp.ttl < 1h) {\n if (beresp.http.Cache-Control ~ \"(private|no-cache|no-store)\") {\n set beresp.ttl = 5m;\n }\n else {\n set beresp.ttl = 1h;\n }\n }\n}\n\nsub vcl_recv {\n set req.http.Host = \"www.trevorparker.com\";\n if (req.http.X-Forwarded-Proto !~ \"(?i)https\") {\n set req.http.x-Redir-Url = \"https:\/\/www.trevorparker.com\" + req.url;\n error 750 req.http.x-Redir-Url;\n }\n}\n\nsub vcl_error {\n if (obj.status == 750) {\n set obj.http.Location = obj.response;\n set obj.status = 301;\n return(deliver);\n }\n}\n\n","old_contents":"backend default {\n .host = \"127.0.0.1\";\n .port = \"80\";\n}\n\nsub vcl_fetch {\n set beresp.ttl = 1h;\n}\n\nsub vcl_recv {\n set req.http.Host = \"www.trevorparker.com\";\n if (req.http.X-Forwarded-Proto !~ \"(?i)https\") {\n set req.http.x-Redir-Url = \"https:\/\/www.trevorparker.com\" + req.url;\n error 750 req.http.x-Redir-Url;\n }\n}\n\nsub vcl_error {\n if (obj.status == 750) {\n set obj.http.Location = obj.response;\n set obj.status = 301;\n return(deliver);\n }\n}\n\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"3d0c442e1f93868e19f89eb9bd0cb5f0038e9e9a","subject":"Make sure we don't maint mode admin pages in case user accidentally locks themselves out","message":"Make sure we don't maint mode admin pages in case user accidentally locks themselves out\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets\/recv.vcl","new_file":"etc\/vcl_snippets\/recv.vcl","new_contents":" # VCL required to support maintenance mode. Don't maintenance mode admin pages and supporting assets\n if (table.lookup(magentomodule_config, \"allow_super_users_during_maint\", \"0\") == \"1\" &&\n !req.http.Fastly-Client-Ip ~ maint_allowlist &&\n !req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" &&\n !req.url ~ \"^\/pub\/static\/\") {\n error 503 \"Maintenance mode\";\n }\n\n # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n unset req.http.x-long-cache;\n\n # We want to force long cache times on any of the versioned assets\n if (req.url.path ~ \"^\/static\/version\\d*\/\") {\n set req.http.x-long-cache = \"1\";\n }\n \n # User's Cookie may contain some Magento Vary items we should vary on\n if (req.http.cookie:X-Magento-Vary ) {\n set req.http.X-Magento-Vary = req.http.cookie:X-Magento-Vary;\n } else {\n unset req.http.X-Magento-Vary;\n }\n\n ############################################################################################################\n # Following code block controls purge by URL. By default we want to protect all URL purges. In general this\n # is addressed by adding Fastly-Purge-Requires-Auth request header in vcl_recv however this runs the risk of\n # exposing API tokens if user attempts to purge non-https URLs. For this reason inside the Magento module\n # we use X-Purge-Token. Unfortunately this breaks purge from the Fastly UI. Therefore in the next code block\n # we check for presence of X-Purge-Token. If it's not present we force the Fastly-Purge-Requires-Auth\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n if (req.http.X-Purge-Token && req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n } else {\n error 403;\n }\n } else {\n set req.http.Fastly-Purge-Requires-Auth = \"1\";\n }\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (req.http.Fastly-FF) {\n # disable ESI processing on Origin Shield\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Make sure we lookup end user geo not shielding. More at https:\/\/docs.fastly.com\/vcl\/geolocation\/#using-geographic-variables-with-shielding\n set client.geo.ip_override = req.http.Fastly-Client-IP;\n\n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie:X-Magento-Vary || req.http.cookie:form_key) {\n error 980 \"GeoIP already processed\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url.qs !~ \"country_code=\" ) {\n set req.url = req.url \"?country_code=\" if ( req.http.geo_override, req.http.geo_override, client.geo.country_code);\n }\n }\n } else {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking by default\n # and allow custom parameters to be set. List of parameters is configurable in admin\n set req.http.Magento-Original-URL = req.url;\n # Change the list of ignored parameters by configuring them in the Advanced section\n set req.url = querystring.regfilter(req.url, \"^(####QUERY_PARAMETERS####)\");\n }\n\n # Don't allow clients to force a pass\n if (req.restarts == 0) {\n unset req.http.x-pass;\n unset req.http.Rate-Limit;\n }\n \n # Pass on checkout URLs. Because it's a snippet we want to execute this after backend selection so we handle it\n # in the request condition\n if (!req.http.x-long-cache && req.url ~ \"\/(catalogsearch|checkout|customer\/section\/load)\") {\n set req.http.x-pass = \"1\";\n # Pass all admin actions\n # ####ADMIN_PATH#### is replaced with value of frontName from app\/etc\/env.php\n } else if ( req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" ) {\n set req.http.x-pass = \"1\";\n } else {\n # Sort the query arguments to increase cache hit ratio with query arguments that\n # may be out od order. In case you want to restore the unsorted URL add a snippet\n # after this one that sets req.url to req.http.Magento-Original-URL\n if ( !req.http.x-pass ) {\n set req.url = boltsort.sort(req.url);\n }\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.http.x-long-cache || req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n","old_contents":" # VCL required to support maintenance mode\n if (table.lookup(magentomodule_config, \"allow_super_users_during_maint\", \"0\") == \"1\" && !req.http.Fastly-Client-Ip ~ maint_allowlist ) {\n error 503 \"Maintenance mode\";\n }\n\n # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n unset req.http.x-long-cache;\n\n # We want to force long cache times on any of the versioned assets\n if (req.url.path ~ \"^\/static\/version\\d*\/\") {\n set req.http.x-long-cache = \"1\";\n }\n \n # User's Cookie may contain some Magento Vary items we should vary on\n if (req.http.cookie:X-Magento-Vary ) {\n set req.http.X-Magento-Vary = req.http.cookie:X-Magento-Vary;\n } else {\n unset req.http.X-Magento-Vary;\n }\n\n ############################################################################################################\n # Following code block controls purge by URL. By default we want to protect all URL purges. In general this\n # is addressed by adding Fastly-Purge-Requires-Auth request header in vcl_recv however this runs the risk of\n # exposing API tokens if user attempts to purge non-https URLs. For this reason inside the Magento module\n # we use X-Purge-Token. Unfortunately this breaks purge from the Fastly UI. Therefore in the next code block\n # we check for presence of X-Purge-Token. If it's not present we force the Fastly-Purge-Requires-Auth\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n if (req.http.X-Purge-Token && req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n } else {\n error 403;\n }\n } else {\n set req.http.Fastly-Purge-Requires-Auth = \"1\";\n }\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (req.http.Fastly-FF) {\n # disable ESI processing on Origin Shield\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Make sure we lookup end user geo not shielding. More at https:\/\/docs.fastly.com\/vcl\/geolocation\/#using-geographic-variables-with-shielding\n set client.geo.ip_override = req.http.Fastly-Client-IP;\n\n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie:X-Magento-Vary || req.http.cookie:form_key) {\n error 980 \"GeoIP already processed\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url.qs !~ \"country_code=\" ) {\n set req.url = req.url \"?country_code=\" if ( req.http.geo_override, req.http.geo_override, client.geo.country_code);\n }\n }\n } else {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking by default\n # and allow custom parameters to be set. List of parameters is configurable in admin\n set req.http.Magento-Original-URL = req.url;\n # Change the list of ignored parameters by configuring them in the Advanced section\n set req.url = querystring.regfilter(req.url, \"^(####QUERY_PARAMETERS####)\");\n }\n\n # Don't allow clients to force a pass\n if (req.restarts == 0) {\n unset req.http.x-pass;\n unset req.http.Rate-Limit;\n }\n \n # Pass on checkout URLs. Because it's a snippet we want to execute this after backend selection so we handle it\n # in the request condition\n if (!req.http.x-long-cache && req.url ~ \"\/(catalogsearch|checkout|customer\/section\/load)\") {\n set req.http.x-pass = \"1\";\n # Pass all admin actions\n # ####ADMIN_PATH#### is replaced with value of frontName from app\/etc\/env.php\n } else if ( req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" ) {\n set req.http.x-pass = \"1\";\n } else {\n # Sort the query arguments to increase cache hit ratio with query arguments that\n # may be out od order. In case you want to restore the unsorted URL add a snippet\n # after this one that sets req.url to req.http.Magento-Original-URL\n if ( !req.http.x-pass ) {\n set req.url = boltsort.sort(req.url);\n }\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.http.x-long-cache || req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"86de0b89893273436284bc5ad66ed1c9777c4a16","subject":"Strip out query parameters used by Google Adwords etc. since they lower the cache hit ratio","message":"Strip out query parameters used by Google Adwords etc. since they lower the cache hit ratio\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/fastly.vcl","new_file":"etc\/fastly.vcl","new_contents":"###############################################################################\n#\n# Fastly CDN for Magento 2\n#\n# NOTICE OF LICENSE\n#\n# This source file is subject to the Fastly CDN for Magento 2 End User License\n# Agreement that is bundled with this package in the file LICENSE_FASTLY_CDN.txt.\n#\n# @copyright Copyright (c) 2016 Fastly, Inc. (http:\/\/www.fastly.com)\n# @license BSD, see LICENSE_FASTLY_CDN.txt\n#\n###############################################################################\n\n# This is a basic VCL configuration file for Fastly CDN for Magento 2 module.\n\nsub vcl_recv {\n#FASTLY recv\n\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking\n set req.http.Fastly-Original-URL = req.url;\n set req.url = querystring.regfilter(req.url, \"^(utm_.*|gclid|gdftrk|_ga|mc_.*)\");\n\n if (req.url ~ \"^\/static\/version(\\d*\/)?(.*)$\") {\n set req.url = \"\/static\/\" + re.group.2 + \"?\" + re.group.1;\n } \n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n set req.http.X-Sig = regsub(req.http.X-Purge-Token, \"^[^_]+_(.*)\", \"\\1\");\n set req.http.X-Exp = regsub(req.http.X-Purge-Token, \"^([^_]+)_.*\", \"\\1\");\n\n # validate signature\n if (req.http.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path req.http.X-Exp), \"^0x\", \"\")) {\n\n # use vcl time math to check expiration timestamp\n set req.http.X-Original-Grace = req.grace;\n set req.grace = std.atoi(strftime({\"%s\"}, now));\n set req.grace -= std.atoi(req.http.X-Exp);\n\n if (std.atoi(req.grace) > 0) {\n error 410;\n }\n\n # clean up grace since we used it for time math\n set req.grace = std.atoi(req.http.X-Original-Grace);\n unset req.http.X-Original-Grace;\n\n } else {\n error 403;\n }\n\n # cleanup variables\n unset req.http.X-Purge-Token;\n unset req.http.X-Sig;\n unset req.http.X-Exp;\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n # disable ESI processing on Origin Shield\n if (req.http.Fastly-FF) {\n set req.esi = false;\n }\n\n # We only deal with GET and HEAD by default\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n return (pass);\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n return (lookup);\n }\n\n # Bypass shopping cart and checkout requests\n if (req.url ~ \"\/checkout\") {\n return (pass);\n }\n\n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie ~ \"(X-Magento-Vary|form_key)=\") {\n error 200 \"\";\n } else {\n # append parameter with country code\n set req.url = req.url \"?country_code=\" geoip.country_code;\n }\n }\n\n return(lookup);\n}\n\nsub vcl_fetch {\n\n # Remove Set-Cookies from responses for static content\n # to match the cookie removal in recv.\n if (req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n }\n\n }\n\n#FASTLY fetch\n\n if (beresp.status >= 500) {\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n }\n\n if (req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Content-Type ~ \"text\/html\" || beresp.http.Content-Type ~ \"text\/xml\") {\n # enable ESI feature for Magento response by default\n esi;\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content\n if ((beresp.status == 200 || beresp.status == 404) && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url ~ \"\\.(css|js|html|eot|ico|otf|ttf|json)($|\\?)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # cache only successfully responses and 404s\n if (beresp.status != 200 && beresp.status != 301 && beresp.status != 404) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\")) {\n unset beresp.http.set-cookie;\n if (req.url !~ \"^\/(pub\/)?(media|static)\/.*\") {\n set beresp.http.Pragma = \"no-cache\";\n set beresp.http.Expires = \"-1\";\n set beresp.http.Cache-Control = \"no-store, no-cache, must-revalidate, max-age=0\";\n set beresp.grace = 1m;\n }\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type\n if (beresp.http.Content-Type ~ \"image\") {\n set beresp.http.Surrogate-Key = \"image\";\n } elsif (beresp.http.Content-Type ~ \"script\") {\n set beresp.http.Surrogate-Key = \"script\";\n } elsif (beresp.http.Content-Type ~ \"css\") {\n set beresp.http.Surrogate-Key = \"css\";\n }\n\n set beresp.http.X-Surrogate-Key = beresp.http.Surrogate-Key;\n return (deliver);\n }\n\n return (deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\n\nsub vcl_miss {\n # Deactivate gzip on origin\n unset bereq.http.Accept-Encoding;\n\n#FASTLY miss\n\n return(fetch);\n}\n\nsub vcl_deliver {\n\n # Add an easy way to see whether custom Fastly VCL has been uploaded\n if ( req.http.Fastly-Debug ) {\n set resp.http.Fastly-Magento-VCL-Uploaded = \"yes\";\n }\n # debug info\n if (resp.http.X-Magento-Debug) {\n if (obj.hits > 0) {\n set resp.http.X-Magento-Cache-Debug = \"HIT\";\n set resp.http.X-Magento-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Magento-Cache-Debug = \"MISS\";\n }\n } else {\n # remove Varnish\/proxy header\n remove resp.http.Age;\n remove resp.http.X-Magento-Debug;\n remove resp.http.X-Magento-Tags;\n remove resp.http.X-Surrogate-Key;\n remove resp.http.X-Magento-Cache-Control;\n remove resp.http.X-Powered-By;\n remove resp.http.Server;\n remove resp.http.X-Varnish;\n remove resp.http.Via;\n remove resp.http.Link;\n remove resp.http.X-Purge-URL;\n remove resp.http.X-Purge-Host;\n }\n\n#FASTLY deliver\n\n return (deliver);\n}\n\n\nsub vcl_error {\n # workaround for possible security issue\n if (req.url ~ \"^\\s\") {\n set obj.status = 400;\n set obj.response = \"Malformed request\";\n synthetic \"\";\n return (deliver);\n }\n\n # error 200\n if (obj.status == 200) {\n return (deliver);\n }\n\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} obj.status \" \" obj.response {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} obj.status \" \" obj.response {\"<\/h1>\n <p>\"} obj.response {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} req.xid {\"<\/p>\n <hr>\n <p>Fastly CDN server<\/p>\n <\/body>\n<\/html>\n\"};\n\n#FASTLY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n\nsub vcl_hash {\n set req.hash += req.http.Https;\n set req.hash += req.http.host;\n set req.hash += req.url;\n\n if (req.http.cookie:X-Magento-Vary ) {\n set req.hash += req.http.cookie:X-Magento-Vary;\n }\n \n set req.hash += \"#####GENERATION#####\";\n\n ### {{ design_exceptions_code }} ###\n\n return (hash);\n}\n\n","old_contents":"###############################################################################\n#\n# Fastly CDN for Magento 2\n#\n# NOTICE OF LICENSE\n#\n# This source file is subject to the Fastly CDN for Magento 2 End User License\n# Agreement that is bundled with this package in the file LICENSE_FASTLY_CDN.txt.\n#\n# @copyright Copyright (c) 2016 Fastly, Inc. (http:\/\/www.fastly.com)\n# @license BSD, see LICENSE_FASTLY_CDN.txt\n#\n###############################################################################\n\n# This is a basic VCL configuration file for Fastly CDN for Magento 2 module.\n\nsub vcl_recv {\n#FASTLY recv\n\n if (req.url ~ \"^\/static\/version(\\d*\/)?(.*)$\") {\n set req.url = \"\/static\/\" + re.group.2 + \"?\" + re.group.1;\n } \n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n set req.http.X-Sig = regsub(req.http.X-Purge-Token, \"^[^_]+_(.*)\", \"\\1\");\n set req.http.X-Exp = regsub(req.http.X-Purge-Token, \"^([^_]+)_.*\", \"\\1\");\n\n # validate signature\n if (req.http.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path req.http.X-Exp), \"^0x\", \"\")) {\n\n # use vcl time math to check expiration timestamp\n set req.http.X-Original-Grace = req.grace;\n set req.grace = std.atoi(strftime({\"%s\"}, now));\n set req.grace -= std.atoi(req.http.X-Exp);\n\n if (std.atoi(req.grace) > 0) {\n error 410;\n }\n\n # clean up grace since we used it for time math\n set req.grace = std.atoi(req.http.X-Original-Grace);\n unset req.http.X-Original-Grace;\n\n } else {\n error 403;\n }\n\n # cleanup variables\n unset req.http.X-Purge-Token;\n unset req.http.X-Sig;\n unset req.http.X-Exp;\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n # disable ESI processing on Origin Shield\n if (req.http.Fastly-FF) {\n set req.esi = false;\n }\n\n # We only deal with GET and HEAD by default\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n return (pass);\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n return (lookup);\n }\n\n # Bypass shopping cart and checkout requests\n if (req.url ~ \"\/checkout\") {\n return (pass);\n }\n\n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie ~ \"(X-Magento-Vary|form_key)=\") {\n error 200 \"\";\n } else {\n # append parameter with country code\n set req.url = req.url \"?country_code=\" geoip.country_code;\n }\n }\n\n return(lookup);\n}\n\nsub vcl_fetch {\n\n # Remove Set-Cookies from responses for static content\n # to match the cookie removal in recv.\n if (req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n }\n\n }\n\n#FASTLY fetch\n\n if (beresp.status >= 500) {\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n }\n\n if (req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Content-Type ~ \"text\/html\" || beresp.http.Content-Type ~ \"text\/xml\") {\n # enable ESI feature for Magento response by default\n esi;\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content\n if ((beresp.status == 200 || beresp.status == 404) && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url ~ \"\\.(css|js|html|eot|ico|otf|ttf|json)($|\\?)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # cache only successfully responses and 404s\n if (beresp.status != 200 && beresp.status != 301 && beresp.status != 404) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\")) {\n unset beresp.http.set-cookie;\n if (req.url !~ \"^\/(pub\/)?(media|static)\/.*\") {\n set beresp.http.Pragma = \"no-cache\";\n set beresp.http.Expires = \"-1\";\n set beresp.http.Cache-Control = \"no-store, no-cache, must-revalidate, max-age=0\";\n set beresp.grace = 1m;\n }\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type\n if (beresp.http.Content-Type ~ \"image\") {\n set beresp.http.Surrogate-Key = \"image\";\n } elsif (beresp.http.Content-Type ~ \"script\") {\n set beresp.http.Surrogate-Key = \"script\";\n } elsif (beresp.http.Content-Type ~ \"css\") {\n set beresp.http.Surrogate-Key = \"css\";\n }\n\n set beresp.http.X-Surrogate-Key = beresp.http.Surrogate-Key;\n return (deliver);\n }\n\n return (deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\n\nsub vcl_miss {\n # Deactivate gzip on origin\n unset bereq.http.Accept-Encoding;\n\n#FASTLY miss\n\n return(fetch);\n}\n\nsub vcl_deliver {\n\n # Add an easy way to see whether custom Fastly VCL has been uploaded\n if ( req.http.Fastly-Debug ) {\n set resp.http.Fastly-Magento-VCL-Uploaded = \"yes\";\n }\n # debug info\n if (resp.http.X-Magento-Debug) {\n if (obj.hits > 0) {\n set resp.http.X-Magento-Cache-Debug = \"HIT\";\n set resp.http.X-Magento-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Magento-Cache-Debug = \"MISS\";\n }\n } else {\n # remove Varnish\/proxy header\n remove resp.http.Age;\n remove resp.http.X-Magento-Debug;\n remove resp.http.X-Magento-Tags;\n remove resp.http.X-Surrogate-Key;\n remove resp.http.X-Magento-Cache-Control;\n remove resp.http.X-Powered-By;\n remove resp.http.Server;\n remove resp.http.X-Varnish;\n remove resp.http.Via;\n remove resp.http.Link;\n remove resp.http.X-Purge-URL;\n remove resp.http.X-Purge-Host;\n }\n\n#FASTLY deliver\n\n return (deliver);\n}\n\n\nsub vcl_error {\n # workaround for possible security issue\n if (req.url ~ \"^\\s\") {\n set obj.status = 400;\n set obj.response = \"Malformed request\";\n synthetic \"\";\n return (deliver);\n }\n\n # error 200\n if (obj.status == 200) {\n return (deliver);\n }\n\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} obj.status \" \" obj.response {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} obj.status \" \" obj.response {\"<\/h1>\n <p>\"} obj.response {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} req.xid {\"<\/p>\n <hr>\n <p>Fastly CDN server<\/p>\n <\/body>\n<\/html>\n\"};\n\n#FASTLY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n\nsub vcl_hash {\n set req.hash += req.http.Https;\n set req.hash += req.http.host;\n set req.hash += req.url;\n\n if (req.http.cookie:X-Magento-Vary ) {\n set req.hash += req.http.cookie:X-Magento-Vary;\n }\n \n set req.hash += \"#####GENERATION#####\";\n\n ### {{ design_exceptions_code }} ###\n\n return (hash);\n}\n\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"5a7bec3d9bc84123b4216293598225f4760ac31e","subject":"Per @drwilco we need to make sure request collapsing is off","message":"Per @drwilco we need to make sure request collapsing is off\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets_rate_limiting\/recv.vcl","new_file":"etc\/vcl_snippets_rate_limiting\/recv.vcl","new_contents":"if (####RATE_LIMITED_PATHS####) {\n set req.http.Rate-Limit = \"1\";\n set req.hash_ignore_busy = true;\n}\n","old_contents":"if (####RATE_LIMITED_PATHS####) {\n set req.http.Rate-Limit = \"1\";\n}\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"d1de441a6ce6514e82e1b726adcd697489772e8b","subject":"Set Cache-Control just in case it doesn't get set. It may cause default TTL to kick in","message":"Set Cache-Control just in case it doesn't get set. It may cause default TTL to kick in\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets\/fetch.vcl","new_file":"etc\/vcl_snippets\/fetch.vcl","new_contents":" \/* handle 5XX (or any other unwanted status code) *\/\n if (beresp.status >= 500 && beresp.status < 600) {\n\n \/* deliver stale if the object is available *\/\n if (stale.exists) {\n return(deliver_stale);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n \/* else go to vcl_error to deliver a synthetic *\/\n error beresp.status beresp.response;\n }\n\n # Remove Set-Cookies from responses for static content to match the cookie removal in recv.\n if (req.http.x-long-cache || req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's since those can be temporary during the site build\/index\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n set beresp.http.Cache-Control = \"max-age=0\";\n } else if (req.http.x-long-cache) {\n # Force caching for signed cached assets.\n set beresp.ttl = 31536000s;\n # Add immutable as it avoids IMS and INM revalidations\n set beresp.http.Cache-Control = \"max-age=31536000, immutable\";\n }\n }\n\n # All the Magento responses should emit X-Esi headers\n if (beresp.http.x-esi) {\n # enable ESI feature for Magento response by default\n esi;\n if (!beresp.http.Vary ~ \"X-Magento-Vary,Https\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \",X-Magento-Vary,Https\";\n } else {\n set beresp.http.Vary = \"X-Magento-Vary,Https\";\n }\n }\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content except\n if ( http_status_matches(beresp.status, \"200,404\") && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|text\\\/html|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url.ext ~ \"(?i)(css|js|html|eot|ico|otf|ttf|json)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n if (beresp.http.Cache-Control ~ \"private|no-cache|no-store\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # Never cache 302s\n if (beresp.status == 302) {\n return (pass);\n }\n\n # Just in case the Request Setting for x-pass is missing\n if (req.http.x-pass) {\n return (pass);\n }\n\n # Varnish sets default TTL if none of these are present\n if (!beresp.http.Expires && !beresp.http.Surrogate-Control ~ \"max-age\" && !beresp.http.Cache-Control ~ \"(s-maxage|max-age)\") {\n set beresp.ttl = 0s;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\") && !req.http.x-pass ) {\n unset beresp.http.set-cookie;\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type if they are image\/script or CSS\n if (beresp.http.Content-Type ~ \"(image|script|css)\") {\n set beresp.http.Surrogate-Key = re.group.1;\n }\n }\n","old_contents":" \/* handle 5XX (or any other unwanted status code) *\/\n if (beresp.status >= 500 && beresp.status < 600) {\n\n \/* deliver stale if the object is available *\/\n if (stale.exists) {\n return(deliver_stale);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n \/* else go to vcl_error to deliver a synthetic *\/\n error beresp.status beresp.response;\n }\n\n # Remove Set-Cookies from responses for static content to match the cookie removal in recv.\n if (req.http.x-long-cache || req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's since those can be temporary during the site build\/index\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n } else if (req.http.x-long-cache) {\n # Force caching for signed cached assets.\n set beresp.ttl = 31536000s;\n # Add immutable as it avoids IMS and INM revalidations\n set beresp.http.Cache-Control = \"max-age=31536000, immutable\";\n }\n }\n\n # All the Magento responses should emit X-Esi headers\n if (beresp.http.x-esi) {\n # enable ESI feature for Magento response by default\n esi;\n if (!beresp.http.Vary ~ \"X-Magento-Vary,Https\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \",X-Magento-Vary,Https\";\n } else {\n set beresp.http.Vary = \"X-Magento-Vary,Https\";\n }\n }\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content except\n if ( http_status_matches(beresp.status, \"200,404\") && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|text\\\/html|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url.ext ~ \"(?i)(css|js|html|eot|ico|otf|ttf|json)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n if (beresp.http.Cache-Control ~ \"private|no-cache|no-store\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # Never cache 302s\n if (beresp.status == 302) {\n return (pass);\n }\n\n # Just in case the Request Setting for x-pass is missing\n if (req.http.x-pass) {\n return (pass);\n }\n\n # Varnish sets default TTL if none of these are present\n if (!beresp.http.Expires && !beresp.http.Surrogate-Control ~ \"max-age\" && !beresp.http.Cache-Control ~ \"(s-maxage|max-age)\") {\n set beresp.ttl = 0s;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\") && !req.http.x-pass ) {\n unset beresp.http.set-cookie;\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type if they are image\/script or CSS\n if (beresp.http.Content-Type ~ \"(image|script|css)\") {\n set beresp.http.Surrogate-Key = re.group.1;\n }\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"e355f78eec597000e676477e83c351da2dc395b8","subject":"readability counts","message":"readability counts\n","repos":"NITEMAN\/Varnish_VCL_samps-hacks,NITEMAN\/varnish-bites","old_file":"varnish4\/drupal-base.vcl","new_file":"varnish4\/drupal-base.vcl","new_contents":"\/*\n * Varnish 4 example config for Drupal 7 \/ Pressflow 6 & 7\n *\/\n\n# Original source: https:\/\/github.com\/NITEMAN\/varnish-bites\/varnish4\/drupal-base.vcl\n# Copyright (c) 2015 Pedro Gonz\u00e1lez Serrano and individual contributors.\n# MIT License\n\n# Intended to be used both in simple production environments and with\n# learning\/teaching purposes.\n# Some references may not be yet updated to VCL 4.0, we use SeeV3 then.\n\n# WARNING:\n# Note that the built-in logic will be appended to our code if no return is\n# performed before.\n# Built-in logic is included commented out right after our's for reference\n# purposes in that cases.\n# See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleDefault\n\n#######################################################################\n# Initialization: Version & imports;\n\n\/* Version statement *\/\n# Since Varnish 4.0 it's mandatory to declare VCL version on first line.\nvcl 4.0;\n\n\/* Module (VMOD) imports *\/\n# Standard module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_std.generated.html\nimport std;\n\n# Directors module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# Unused in simple configs.\n#import directors;\n\n\n#######################################################################\n# Probe, backend, ACL and subroutine definitions\n\n\/* Backend probes \/ healthchecks *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#probes\nprobe basic {\n \/* Only test that backend's IP serves content for '\/' *\/\n # This might be a too heavy probe\n # .url = \"\/\";\n\n \/* Only test that backend's IP has apache working *\/\n # Nginx would fail this probe with a default config\n .request =\n \"OPTIONS * HTTP\/1.1\"\n \"Host: *\"\n \"Connection: close\";\n\n \/* Common options *\/\n .interval = 10s;\n .timeout = 2s;\n .window = 8;\n .threshold = 6;\n}\n\n\/* Backend definitions.*\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#backend-definition\nbackend default {\n \/* Default backend on the same machine. *\/\n # WARNING: timeouts could be not big enought for certain POST requests.\n .host = \"127.0.0.1\";\n .port = \"8008\";\n .max_connections = 100;\n .connect_timeout = 60s;\n .first_byte_timeout = 60s;\n .between_bytes_timeout = 60s;\n .probe = basic;\n}\n\n\/* Access Control Lists *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#access-control-list-acl\nacl purge_ban {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use '\"localhost\";' instead\n}\nacl allowed_monitors {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n}\n# acl own_proxys {\n# \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n# }\n\n\/* Custom subroutines *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#subroutines\n#TODO# Test in Varnihs 4\n# Empty in simple configs.\n# The only restriction naming subs is that the 'vlc_' prefix is reserverd for\n# Varnish use. As a task can need several chunks of code in diferent states,\n# it's a good idea to identify what main sub will call each with a suffix.\n# \/* Example 301 client redirection removing \"www\" prefix from request *\/\n# sub perm_redirections_recv {\n# if ( req.http.host ~ \"^www.*$\" ) {\n# return(\n# synth(751, \"http:\/\/\" + regsub(req.http.host, \"^www\\.\", \"\") + req.url)\n# );\n# }\n# }\n# sub perm_redirections_synth {\n# if (resp.status == 751) {\n# \/* Get new URL from the response *\/\n# set resp.http.Location = resp.response;\n# \/* Set HTTP 301 for permanent redirect *\/\n# set resp.status = 301;\n# return (deliver);\n# }\n# }\n\n\n#######################################################################\n# Client side\n\n# vcl_recv: Called at the beginning of a request, after the complete request\n# has been received and parsed. Its purpose is to decide whether or not to\n# serve the request, how to do it, and, if applicable, which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-recv\nsub vcl_recv {\n \/* 0th: general bypass, general return & authorization checks *\/\n # Empty in simple configs.\n # Useful for debugging we can pipe or pass the request to default backend\n # here to bypass completely Varnish.\n # return (pipe);\n # return (pass);\n # We can also return here a 200 Ok for network performance benchmarking.\n # return(synth(200, \"Ok\"));\n # Finally we can perform basic HTTP authentification here, by example.\n # SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* 1st: Check for Varnish special requests *\/ \n # Custom response implementation example in order to check that Varnish is\n # working properly.\n # This is usefull for automatic monitoring with monit or when Varnish is\n # behind another proxies like HAProxy.\n if ( ( req.http.host == \"monitor.server.health\"\n || req.http.host == \"health.varnish\" )\n && client.ip ~ allowed_monitors\n && ( req.method == \"OPTIONS\" || req.method == \"GET\" )\n ) {\n return(synth(200, \"Ban added\"));\n }\n # Purge logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#http-purging\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if ( req.method == \"PURGE\" ) {\n if ( ! client.ip ~ purge_ban ) {\n return(synth(405, \"Not allowed.\"));\n }\n return (purge);\n }\n # Ban logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#bans\n if ( req.method == \"BAN\" ) {\n if ( ! client.ip ~ purge_ban ) {\n return(synth(405, \"Not allowed.\"));\n }\n ban( \"req.http.host == \" + req.http.host +\n \"&& req.url == \" + req.url);\n return(synth(200, \"Ban added\"));\n }\n\n \/* 2nd: Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_recv;\n # Here we can also enforce SSL when Varnish run behind some SSL termination\n # point.\n\n \/* 3rd: Time for backend choice *\/\n # Empty in simple configs.\n\n \/* 4th: Prepare request for the backend *\/\n # Empty in simple configs.\n # Example remove own_proxys from X-Forwarded-For\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/whats-new\/upgrading.html#x-forwarded-for-is-now-set-before-vcl-recv\n # if ( req.restarts == 0\n # && client.ip ~ own_proxys\n # && req.http.x-forwarded-for\n # ) {\n # set req.http.X-Forwarded-For\n # = regsub(req.http.X-Forwarded-For, \",( )?\" + client.ip, \"\");\n # }\n # Example normalize the host header, remove the port (in case you're testing\n # this on various TCP ports)\n # set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n \/* 5th: Bypass breakpoint 1 *\/\n # Useful for debugging we can now pipe or pass the request to backend with\n # headers setted.\n # return (pipe);\n # return (pass);\n\n \/* 6th: Decide if we should deal with a request (mostly from built-in logic) *\/\n if (req.method == \"PRI\") {\n \/* We do not support SPDY or HTTP\/2.0 *\/\n return (synth(405));\n }\n if ( req.method != \"GET\"\n && req.method != \"HEAD\"\n && req.method != \"PUT\"\n && req.method != \"POST\"\n && req.method != \"TRACE\"\n && req.method != \"OPTIONS\"\n && req.method != \"DELETE\"\n ) {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n # Websocket support\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n \/* 7th: Access control for some URLs by ACL *\/\n # Empty in simple configs.\n # By example denial some URLs depending on client-ip, we'll need to define\n # corresponding ACL 'internal'.\n # if ( req.url ~ \"^\/(cron|install)\\.php\"\n # && ! client.ip ~ internal\n # ) {\n # # Have Varnish throw the error directly.\n # return(synth(403, \"Forbidden.\"));\n # # Use a custom error page that you've defined in Drupal at the path \"404\".\n # # set req.url = \"\/403\";\n # }\n\n \/* 8th: Custom exceptions *\/\n # Host exception example:\n # if (req.http.host == \"ejemplo.exception.com\") {\n # return (pass);\n # }\n # Drupal exceptions, edit if we want to cache some AJAX\/AHAH request.\n # Add here filters for never cache URLs such as Payment Gateway's callbacks.\n if ( req.url ~ \"^\/status\\.php$\"\n || req.url ~ \"^\/update\\.php$\"\n || req.url ~ \"^\/ooyala\/ping$\"\n || req.url ~ \"^\/admin\/build\/features\"\n || req.url ~ \"^\/info\/.*$\"\n || req.url ~ \"^\/flag\/.*$\"\n || req.url ~ \"^.*\/ajax\/.*$\"\n || req.url ~ \"^.*\/ahah\/.*$\"\n ) {\n \/* Do not cache these paths *\/\n return (pass);\n }\n # Pipe these paths directly to backend for streaming.\n if (req.url ~ \"^\/admin\/content\/backup_migrate\/export\") {\n return (pipe);\n }\n if (req.url ~ \"^\/system\/files\") {\n return (pipe);\n }\n\n \/* 9th: Graced objets & Serve from anonymous cahe if all backends are down *\/\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n # set req.http.grace = \"none\";\n if ( ! std.healthy(req.backend_hint) ) {\n # We must do this here since cookie hashing\n unset req.http.Cookie;\n #TODO# Add sick marker\n } \n\n \/* 10th: Deal with compression and the Accept-Encoding header *\/\n # Althought Varnish 3 handles gziped content itself by default, just to be\n # sure we want to remove Accept-Encoding for some compressed formats.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html#what-does-http-gzip-support-do\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/varnishd.html?highlight=http_gzip_support\n # See (for older configs) https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleNormalizeAcceptEncoding\n if (req.http.Accept-Encoding) {\n if ( req.url\n ~ \"\\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|mp4|flv|zip|rar)$\"\n ) {\n \/* Already compressed formats, no sense trying to compress again *\/\n unset req.http.Accept-Encoding;\n }\n }\n\n \/* 11th: Another request manipulation *\/\n # Empty in simple configs.\n # We could add here a custom header grouping User-agent families.\n\n \/* 12th: Cookie removal *\/\n # Always cache the following static file types for all users. \n # Use with care if we control certain downloads depending on cookies. \n # Be carefull also if appending .htm[l] via Drupal's clean URLs.\n if ( req.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|woff2|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n && ! req.url ~ \"\/system\/storage\/serve\"\n ) {\n unset req.http.Cookie;\n }\n # Remove all cookies that backend doesn't need to know about.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRemovingSomeCookies\n if (req.http.Cookie) {\n \/* Warning: Not a pretty solution *\/\n # Prefix header containing cookies with ';'\n set req.http.Cookie = \";\" + req.http.Cookie;\n # Remove any spaces after ';' in header containing cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n # Prefix cookies we want to preserve with one space:\n # 'S{1,2}ESS[a-z0-9]+' is the regular expression matching a Drupal session\n # cookie ({1,2} added for HTTPS support).\n # 'NO_CACHE' is usually set after a POST request to make sure issuing user\n # see the results of his post.\n # 'OATMEAL' & 'CHOCOLATECHIP' are special cookies used by Drupal's Bakery\n # module to provide Single Sign On.\n # Keep in mind we should add here any cookie that should reach the backend\n # such as splash avoiding cookies.\n set req.http.Cookie\n = regsuball(\n req.http.Cookie,\n \";(S{1,2}ESS[a-z0-9]+|NO_CACHE|OATMEAL|CHOCOLATECHIP)=\",\n \"; \\1=\"\n );\n # Remove from the header any single Cookie not prefixed with a space until\n # next ';' separator.\n set req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n # Remove any '; ' at the start or the end of the header.\n set req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n #If there are no remaining cookies, remove the cookie header.\n if (req.http.Cookie == \"\") {\n unset req.http.Cookie;\n }\n }\n\n \/* 13th: Session cookie & special cookies bypass caching stage *\/\n # As we might want to cache some requests, hashed with its cookies, we don't\n # simply pass when some cookies remain present at this point.\n # Instead we look for request that must be passed due to the cookie header.\n if ( req.http.Cookie ~ \"SESS\"\n || req.http.Cookie ~ \"SSESS\"\n || req.http.Cookie ~ \"NO_CACHE\"\n || req.http.Cookie ~ \"OATMEAL\"\n || req.http.Cookie ~ \"CHOCOLATECHIP\"\n ) {\n return (pass);\n }\n\n \/* 14th: Bypass breakpoint 2 *\/\n # Useful for debugging we can now pipe or pass the request to backend to\n # bypass cache.\n # return (pipe);\n # return (pass);\n\n \/* 15th: Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n return (hash);\n}\n\n# vcl_pipe: Called upon entering pipe mode.\n# In this mode, the request is passed on to the backend, and any further data\n# from either client or backend is passed on unaltered until either end closes\n# the connection.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pipe\nsub vcl_pipe {\n # Websocket support\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n}\n# sub vcl_pipe {\n# # By default Connection: close is set on all piped requests, to stop\n# # connection reuse from sending future requests directly to the\n# # (potentially) wrong backend. If you do want this to happen, you can undo\n# # it here.\n# # unset bereq.http.connection;\n# return (pipe);\n# }\n\n# vcl_pass: Called upon entering pass mode. \n# In this mode, the request is passed on to the backend, and the backend's\n# response is passed on to the client, but is not entered into the cache.\n# Subsequent requests submitted over the same client connection are handled normally.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pass\n# sub vcl_pass {\n# return (fetch);\n# }\n\n# vcl_hash: You may call hash_data() on the data you would like to add to the\n# hash.\n# Hash is used by Varnish to uniquely identify objects.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hash\nsub vcl_hash {\n \/* Hash cookie data *\/\n # As requests with same URL and host can produce diferent results when issued\n # with different cookies, we need to store items hashed with the associated\n # cookies. Note that cookies are already sanitized when we reach this point.\n if (req.http.Cookie) {\n \/* Include cookie in cache hash *\/\n hash_data(req.http.Cookie);\n }\n\n \/* Custom header hashing *\/\n # Empty in simple configs.\n # Example for caching differents object versions by device previously\n # detected (when static content could also vary):\n # if (req.http.X-UA-Device) {\n # hash_data(req.http.X-UA-Device);\n # }\n # Example for caching diferent object versions by X-Forwarded-Proto, trying\n # to be smart about what kind of request could generate diffetent responses.\n if ( req.http.X-Forwarded-Proto\n && req.url !~ \"(?i)\\.(png|gif|jpeg|jpg|ico|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|woff2|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\") {\n hash_data(req.http.X-Forwarded-Proto);\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (lookup);\n# }\n\n# vcl_purge: Called after the purge has been executed and all its variants have\n# been evited.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-purge\n# sub vcl_purge {\n# return (synth(200, \"Purged\"));\n# }\n\n# vcl_hit: Called after a cache lookup if the requested document was found in\n# the cache.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hit\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n \/\/ A pure unadultered hit, deliver it\n return (deliver);\n }\n \/* Allow varnish to serve up stale content if it is responding slowly *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n if (obj.ttl + 60s > 0s) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n set req.http.grace = \"normal\";\n return (deliver);\n }\n \/* Allow varish to serve up stale content if all backends are down *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n if ( ! std.healthy(req.backend_hint)\n && obj.ttl + obj.grace > 0s\n ) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n set req.http.grace = \"extended\";\n return (deliver);\n }\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\n# vcl_miss: Called after a cache lookup if the requested document was not found\n# in the cache.\n# Its purpose is to decide whether or not to attempt to retrieve the document\n# from the backend, and which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-miss\n# sub vcl_miss {\n# return (fetch);\n# }\n\n# vcl_deliver: Called before an object is delivered to the client\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-deliver\nsub vcl_deliver {\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # Add whether the object is a cache hit or miss and the number of hits for\n # the object.\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Addingaheaderindicatinghitmiss\n # In Varnish 4 the obj.hits counter behaviour has changed (see bug 1492), so\n # we use a different method: if X-Varnish contains only 1 id, we have a miss,\n # if it contains more (and therefore a space), we have a hit.\n if (resp.http.x-varnish ~ \" \") {\n set resp.http.X-Cache = \"HIT\";\n # Since in Varnish 4 the behaviour of obj.hits changed, this might not be\n # accurate.\n # See https:\/\/www.varnish-cache.org\/trac\/ticket\/1492\n set resp.http.X-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Cache = \"MISS\";\n \/* Show the results of cookie sanitization *\/\n set resp.http.X-Cookie = req.http.Cookie;\n }\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n set resp.http.grace = req.http.grace;\n\n #TODO# Add sick marker\n\n # Restart count\n if ( req.restarts > 0) {\n set resp.http.X-Restarts = req.restarts;\n }\n\n # Add the Varnish server hostname\n set resp.http.X-Varnish-Server = server.hostname;\n # If we have setted a custom header with device's family detected we can show\n # it:\n # if (req.http.X-UA-Device) {\n # set resp.http.X-UA-Device = req.http.X-UA-Device;\n # }\n # If we have recived a custom header indicating the protocol in the request we\n # can show it:\n # if (req.http.X-Forwarded-Proto) {\n # set resp.http.X-Forwarded-Proto = req.http.X-Forwarded-Proto;\n # }\n\n \/* Vary header manipulation *\/\n # Empty in simple configs.\n # By example, if we are storing & serving diferent objects depending on\n # User-Agent header we must set the correct Vary header:\n # if (resp.http.Vary) {\n # set resp.http.Vary = resp.http.Vary + \",User-Agent\";\n # } else {\n # set resp.http.Vary = \"User-Agent\";\n # }\n\n \/* Fake headers *\/\n # Empty in simple configs\n # We can fake server headers here, by example:\n # set resp.http.Server = \"Deep thought\";\n # set resp.http.X-Powered-By = \"BOFH\";\n # Or have some fun with headers:\n # See http:\/\/www.nextthing.org\/archives\/2005\/08\/07\/fun-with-http-headers\n # See http:\/\/royal.pingdom.com\/2012\/08\/15\/fun-and-unusual-http-response-headers\/\n # set resp.http.X-Thank-You = \"for bothering to look at my HTTP headers\";\n # set resp.http.X-Answer = \"42\";\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_deliver {\n# return (deliver);\n# }\n\n# vcl_synth: Called to deliver a synthetic object. A synthetic object is\n# generated in VCL, not fetched from the backend. It is typically contructed\n# using the synthetic() function.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-synth\n\/*\n * We can come here \"invisibly\" with the following errors: 413, 417 & 503\n *\/\nsub vcl_synth {\n \/* Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_synth;\n\n \/* Try to restart request in case of failure *\/\n # Note that max_restarts defaults to 4\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if (resp.status == 503 && req.restarts < 4) {\n return(restart);\n }\n\n \/* Set common headers for synthetic responses *\/\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n\n \/* HTTP Authentification client request *\/\n # Empty in simple configs.\n # SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* Load synthetic responses from disk *\/\n # Note that files loaded this way are never re-readed (even after a reload).\n # You should consider PROS\/CONS of doing an include instead.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_std.generated.html#func-fileread\n # Example custom 403 error page.\n # if (resp.status == 403) {\n # synthetic(std.fileread(\"\/403.html\"));\n # return(deliver);\n # }\n\n \/* Error page & refresh \/ redirections *\/\n # We have plenty of choices when we have to serve an error to the client, \n # from the default error page to javascript black magic or plain redirections.\n # Adding some external statistic javascript to track failures served to\n # clients is strongly suggested.\n # We can't use external resources on synthetic content, everything must be\n # inlined.\n # If we need to include images we can embed them in base64 encoding.\n # We're using error 200 for monitoring puposes which should not be retried\n # client side.\n if ( resp.status != 200) {\n set resp.http.Retry-After = \"5\";\n }\n\n # Here is the default error page for Varnish 4 (not so pretty)\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n return (deliver);\n}\n\n#######################################################################\n# Backend Fetch\n\n# vcl_backend_fetch: Called before sending the backend request. In this\n# subroutine you typically alter the request before it gets to the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-fetch\n# sub vcl_backend_fetch {\n# return (fetch);\n# }\n\n# vcl_backend_response: Called after the response headers has been successfully\n# retrieved from the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-response\nsub vcl_backend_response {\n \/* Caching exceptions *\/\n # Varnish will cache objects with response codes:\n # 200, 203, 300, 301, 302, 307, 404 & 410.\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/VCL_Basics.html#the-initial-value-of-beresp-ttl\n # Drupal's Imagecache module can return a 307 redirection to the requested\n # url itself and, depending on Drupal's cache settings, this could lead to a\n # redirection loop being cached for a long time but also we want Varnish to\n # shield a little the backend.\n # See http:\/\/drupal.org\/node\/1248010\n # See http:\/\/drupal.org\/node\/310656\n if ( beresp.status == 307\n #TODO# verify that this work better than 'bereq.url ~ \"imagecache\"'\n && beresp.http.Location == bereq.url\n && beresp.ttl > 5s\n ) {\n set beresp.ttl = 5s;\n set beresp.http.cache-control = \"max-age=5\";\n }\n\n \/* Request retrial *\/\n if ( beresp.status == 500\n || beresp.status == 503\n ) {\n #TODO# consider not restarting POST requests as seenV3 on https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleSaintMode\n return (retry);\n }\n\n \/* Enable grace mode. Related with vcl_hit *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n set beresp.grace = 1h;\n\n \/* Strip cookies from the following static file types for all users. *\/\n # Related with our 12th stage on vcl_recv\n if (bereq.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|woff2|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\") {\n unset beresp.http.set-cookie;\n }\n\n \/* Gzip response *\/\n # Empty in simple configs.\n # Use Varnish to Gzip respone, if suitable, before storing it on cache.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html\n if ( ! beresp.http.Content-Encoding\n && ( beresp.http.content-type ~ \"text\"\n || beresp.http.content-type ~ \"application\/x-javascript\"\n || beresp.http.content-type ~ \"application\/javascript\"\n || beresp.http.content-type ~ \"application\/rss+xml\"\n || beresp.http.content-type ~ \"application\/xml\"\n || beresp.http.content-type ~ \"Application\/JSON\")\n ) {\n set beresp.do_gzip = true;\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # We can add the name of the backend that has processed the request:\n # set beresp.http.X-Backend = beresp.backend.name;\n # We can use a header to tell if the object was gziped by Varnish:\n # if (beresp.do_gzip) {\n # set beresp.http.X-Varnish-Gzipped = \"yes\";\n # } else {\n # set beresp.http.X-Varnish-Gizipped = \"no\";\n # }\n # We can also add headers informing whether the object is cacheable or not and why:\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Varnish3.0\n if (beresp.ttl <= 0s) {\n \/* Varnish determined the object was not cacheable *\/\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n } elsif (bereq.http.Cookie ~ \"(SESS|SSESS|NO_CACHE|OATMEAL|CHOCOLATECHIP)\") {\n \/* We don't wish to cache content for logged in users or with certain cookies. *\/\n # Related with our 9th stage on vcl_recv\n set beresp.http.X-Cacheable = \"NO:Cookies\";\n # set beresp.uncacheable = true;\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n \/* We are respecting the Cache-Control=private header from the backend *\/\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n # set beresp.uncacheable = true;\n } else {\n \/* Varnish determined the object was cacheable *\/\n set beresp.http.X-Cacheable = \"YES\";\n }\n\n \/* Further header manipulation *\/\n # Empty in simple configs.\n # We can also unset some headers to prevent information disclosure and save\n # some cache space.\n # unset beresp.http.Server;\n # unset beresp.http.X-Powered-By;\n # Retry count.\n if ( bereq.retries > 0) {\n set beresp.http.X-Retries = bereq.retries;\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_backend_response {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Surrogate-control ~ \"no-store\" ||\n# (!beresp.http.Surrogate-Control &&\n# beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n# beresp.http.Vary == \"*\") {\n# \/*\n# * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# *\/\n# set beresp.ttl = 120s;\n# set beresp.uncacheable = true;\n# }\n# return (deliver);\n# }\n\n# vcl_backend_error: This subroutine is called if we fail the backend fetch.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-error\nsub vcl_backend_error {\n\n \/* Try to restart request in case of failure *\/\n #TODO# Confirm max_retries default value\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if (bereq.retries < 4) {\n return (retry);\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # Retry count\n if ( bereq.retries > 0) {\n set beresp.http.X-Retries = bereq.retries;\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + beresp.status + \" \" + beresp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + beresp.status + \" \" + beresp.reason + {\"<\/h1>\n <p>\"} + beresp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + bereq.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this\n # point.\n return (deliver);\n}\n\n#######################################################################\n# Housekeeping\n\n# vcl_init: Called when VCL is loaded, before any requests pass through it.\n# Typically used to initialize VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-init\n# Here is where you should declare your directors now.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-backends.html#directors\n# Empty in simple configs\n# sub vcl_init {\n# return (ok);\n# }\n\n# vcl_fini: Called when VCL is discarded only after all requests have exited\n# the VCL. Typically used to clean up VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-fini\n# sub vcl_fini {\n# return (ok);\n# }\n\n","old_contents":"\/*\n * Varnish 4 example config for Drupal 7 \/ Pressflow 6 & 7\n *\/\n\n# Original source: https:\/\/github.com\/NITEMAN\/varnish-bites\/varnish4\/drupal-base.vcl\n# Copyright (c) 2015 Pedro Gonz\u00e1lez Serrano and individual contributors.\n# MIT License\n\n# Intended to be used both in simple production environments and with\n# learning\/teaching purposes.\n# Some references may not be yet updated to VCL 4.0, we use SeeV3 then.\n\n# WARNING:\n# Note that the built-in logic will be appended to our code if no return is\n# performed before.\n# Built-in logic is included commented out right after our's for reference\n# purposes in that cases.\n# See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleDefault\n\n#######################################################################\n# Initialization: Version & imports;\n\n\/* Version statement *\/\n# Since Varnish 4.0 it's mandatory to declare VCL version on first line.\nvcl 4.0;\n\n\/* Module (VMOD) imports *\/\n# Standard module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_std.generated.html\nimport std;\n\n# Directors module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# Unused in simple configs.\n#import directors;\n\n\n#######################################################################\n# Probe, backend, ACL and subroutine definitions\n\n\/* Backend probes \/ healthchecks *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#probes\nprobe basic {\n \/* Only test that backend's IP serves content for '\/' *\/\n # This might be a too heavy probe\n # .url = \"\/\";\n\n \/* Only test that backend's IP has apache working *\/\n # Nginx would fail this probe with a default config\n .request =\n \"OPTIONS * HTTP\/1.1\"\n \"Host: *\"\n \"Connection: close\";\n\n \/* Common options *\/\n .interval = 10s;\n .timeout = 2s;\n .window = 8;\n .threshold = 6;\n}\n\n\/* Backend definitions.*\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#backend-definition\nbackend default {\n \/* Default backend on the same machine. *\/\n # WARNING: timeouts could be not big enought for certain POST requests.\n .host = \"127.0.0.1\";\n .port = \"8008\";\n .max_connections = 100;\n .connect_timeout = 60s;\n .first_byte_timeout = 60s;\n .between_bytes_timeout = 60s;\n .probe = basic;\n}\n\n\/* Access Control Lists *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#access-control-list-acl\nacl purge_ban {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use '\"localhost\";' instead\n}\nacl allowed_monitors {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n}\n# acl own_proxys {\n# \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n# }\n\n\/* Custom subroutines *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#subroutines\n#TODO# Test in Varnihs 4\n# Empty in simple configs.\n# The only restriction naming subs is that the 'vlc_' prefix is reserverd for\n# Varnish use. As a task can need several chunks of code in diferent states,\n# it's a good idea to identify what main sub will call each with a suffix.\n# \/* Example 301 client redirection removing \"www\" prefix from request *\/\n# sub perm_redirections_recv {\n# if ( req.http.host ~ \"^www.*$\" ) {\n# return(\n# synth(751, \"http:\/\/\" + regsub(req.http.host, \"^www\\.\", \"\") + req.url)\n# );\n# }\n# }\n# sub perm_redirections_synth {\n# if (resp.status == 751) {\n# \/* Get new URL from the response *\/\n# set resp.http.Location = resp.response;\n# \/* Set HTTP 301 for permanent redirect *\/\n# set resp.status = 301;\n# return (deliver);\n# }\n# }\n\n\n#######################################################################\n# Client side\n\n# vcl_recv: Called at the beginning of a request, after the complete request\n# has been received and parsed. Its purpose is to decide whether or not to\n# serve the request, how to do it, and, if applicable, which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-recv\nsub vcl_recv {\n \/* 0th: general bypass, general return & authorization checks *\/\n # Empty in simple configs.\n # Useful for debugging we can pipe or pass the request to default backend\n # here to bypass completely Varnish.\n # return (pipe);\n # return (pass);\n # We can also return here a 200 Ok for network performance benchmarking.\n # return(synth(200, \"Ok\"));\n # Finally we can perform basic HTTP authentification here, by example.\n # SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* 1st: Check for Varnish special requests *\/ \n # Custom response implementation example in order to check that Varnish is\n # working properly.\n # This is usefull for automatic monitoring with monit or when Varnish is\n # behind another proxies like HAProxy.\n if ( ( req.http.host == \"monitor.server.health\"\n || req.http.host == \"health.varnish\" )\n && client.ip ~ allowed_monitors\n && ( req.method == \"OPTIONS\" || req.method == \"GET\" )\n ) {\n return(synth(200, \"Ban added\"));\n }\n # Purge logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#http-purging\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if ( req.method == \"PURGE\" ) {\n if ( ! client.ip ~ purge_ban ) {\n return(synth(405, \"Not allowed.\"));\n }\n return (purge);\n }\n # Ban logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#bans\n if ( req.method == \"BAN\" ) {\n if ( ! client.ip ~ purge_ban ) {\n return(synth(405, \"Not allowed.\"));\n }\n ban( \"req.http.host == \" + req.http.host +\n \"&& req.url == \" + req.url);\n return(synth(200, \"Ban added\"));\n }\n\n \/* 2nd: Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_recv;\n # Here we can also enforce SSL when Varnish run behind some SSL termination\n # point.\n\n \/* 3rd: Time for backend choice *\/\n # Empty in simple configs.\n\n \/* 4th: Prepare request for the backend *\/\n # Empty in simple configs.\n # Example remove own_proxys from X-Forwarded-For\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/whats-new\/upgrading.html#x-forwarded-for-is-now-set-before-vcl-recv\n # if ( req.restarts == 0\n # && client.ip ~ own_proxys\n # && req.http.x-forwarded-for\n # ) {\n # set req.http.X-Forwarded-For\n # = regsub(req.http.X-Forwarded-For, \",( )?\" + client.ip, \"\");\n # }\n # Example normalize the host header, remove the port (in case you're testing\n # this on various TCP ports)\n # set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n \/* 5th: Bypass breakpoint 1 *\/\n # Useful for debugging we can now pipe or pass the request to backend with\n # headers setted.\n # return (pipe);\n # return (pass);\n\n \/* 6th: Decide if we should deal with a request (mostly from built-in logic) *\/\n if (req.method == \"PRI\") {\n \/* We do not support SPDY or HTTP\/2.0 *\/\n return (synth(405));\n }\n if ( req.method != \"GET\"\n && req.method != \"HEAD\"\n && req.method != \"PUT\"\n && req.method != \"POST\"\n && req.method != \"TRACE\"\n && req.method != \"OPTIONS\"\n && req.method != \"DELETE\"\n ) {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n # Websocket support\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n \/* 7th: Access control for some URLs by ACL *\/\n # Empty in simple configs.\n # By example denial some URLs depending on client-ip, we'll need to define\n # corresponding ACL 'internal'.\n # if ( req.url ~ \"^\/(cron|install)\\.php\"\n # && ! client.ip ~ internal\n # ) {\n # # Have Varnish throw the error directly.\n # return(synth(403, \"Forbidden.\"));\n # # Use a custom error page that you've defined in Drupal at the path \"404\".\n # # set req.url = \"\/403\";\n # }\n\n \/* 8th: Custom exceptions *\/\n # Host exception example:\n # if (req.http.host == \"ejemplo.exception.com\") {\n # return (pass);\n # }\n # Drupal exceptions, edit if we want to cache some AJAX\/AHAH request.\n # Add here filters for never cache URLs such as Payment Gateway's callbacks.\n if ( req.url ~ \"^\/status\\.php$\"\n || req.url ~ \"^\/update\\.php$\"\n || req.url ~ \"^\/ooyala\/ping$\"\n || req.url ~ \"^\/admin\/build\/features\"\n || req.url ~ \"^\/info\/.*$\"\n || req.url ~ \"^\/flag\/.*$\"\n || req.url ~ \"^.*\/ajax\/.*$\"\n || req.url ~ \"^.*\/ahah\/.*$\"\n ) {\n \/* Do not cache these paths *\/\n return (pass);\n }\n # Pipe these paths directly to backend for streaming.\n if (req.url ~ \"^\/admin\/content\/backup_migrate\/export\") {\n return (pipe);\n }\n if (req.url ~ \"^\/system\/files\") {\n return (pipe);\n }\n\n \/* 9th: Graced objets & Serve from anonymous cahe if all backends are down *\/\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n # set req.http.grace = \"none\";\n if ( ! std.healthy(req.backend_hint) ) {\n # We must do this here since cookie hashing\n unset req.http.Cookie;\n #TODO# Add sick marker\n } \n\n \/* 10th: Deal with compression and the Accept-Encoding header *\/\n # Althought Varnish 3 handles gziped content itself by default, just to be\n # sure we want to remove Accept-Encoding for some compressed formats.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html#what-does-http-gzip-support-do\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/varnishd.html?highlight=http_gzip_support\n # See (for older configs) https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleNormalizeAcceptEncoding\n if (req.http.Accept-Encoding) {\n if ( req.url\n ~ \"\\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|mp4|flv|zip|rar)$\"\n ) {\n \/* Already compressed formats, no sense trying to compress again *\/\n unset req.http.Accept-Encoding;\n }\n }\n\n \/* 11th: Another request manipulation *\/\n # Empty in simple configs.\n # We could add here a custom header grouping User-agent families.\n\n \/* 12th: Cookie removal *\/\n # Always cache the following static file types for all users. \n # Use with care if we control certain downloads depending on cookies. \n # Be carefull also if appending .htm[l] via Drupal's clean URLs.\n if ( req.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|woff2|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n && ! req.url ~ \"\/system\/storage\/serve\"\n ) {\n unset req.http.Cookie;\n }\n # Remove all cookies that backend doesn't need to know about.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRemovingSomeCookies\n if (req.http.Cookie) {\n \/* Warning: Not a pretty solution *\/\n # Prefix header containing cookies with ';'\n set req.http.Cookie = \";\" + req.http.Cookie;\n # Remove any spaces after ';' in header containing cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n # Prefix cookies we want to preserve with one space:\n # 'S{1,2}ESS[a-z0-9]+' is the regular expression matching a Drupal session\n # cookie ({1,2} added for HTTPS support).\n # 'NO_CACHE' is usually set after a POST request to make sure issuing user\n # see the results of his post.\n # 'OATMEAL' & 'CHOCOLATECHIP' are special cookies used by Drupal's Bakery\n # module to provide Single Sign On.\n # Keep in mind we should add here any cookie that should reach the backend\n # such as splash avoiding cookies.\n set req.http.Cookie\n = regsuball(\n req.http.Cookie,\n \";(S{1,2}ESS[a-z0-9]+|NO_CACHE|OATMEAL|CHOCOLATECHIP)=\",\n \"; \\1=\"\n );\n # Remove from the header any single Cookie not prefixed with a space until\n # next ';' separator.\n set req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n # Remove any '; ' at the start or the end of the header.\n set req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n #If there are no remaining cookies, remove the cookie header.\n if (req.http.Cookie == \"\") {\n unset req.http.Cookie;\n }\n }\n\n \/* 13th: Session cookie & special cookies bypass caching stage *\/\n # As we might want to cache some requests, hashed with its cookies, we don't\n # simply pass when some cookies remain present at this point.\n # Instead we look for request that must be passed due to the cookie header.\n if ( req.http.Cookie ~ \"SESS\"\n || req.http.Cookie ~ \"SSESS\"\n || req.http.Cookie ~ \"NO_CACHE\"\n || req.http.Cookie ~ \"OATMEAL\"\n || req.http.Cookie ~ \"CHOCOLATECHIP\"\n ) {\n return (pass);\n }\n\n \/* 14th: Bypass breakpoint 2 *\/\n # Useful for debugging we can now pipe or pass the request to backend to\n # bypass cache.\n # return (pipe);\n # return (pass);\n\n \/* 15th: Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n return (hash);\n}\n\n# vcl_pipe: Called upon entering pipe mode.\n# In this mode, the request is passed on to the backend, and any further data\n# from either client or backend is passed on unaltered until either end closes\n# the connection.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pipe\nsub vcl_pipe {\n # Websocket support\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n}\n# sub vcl_pipe {\n# # By default Connection: close is set on all piped requests, to stop\n# # connection reuse from sending future requests directly to the\n# # (potentially) wrong backend. If you do want this to happen, you can undo\n# # it here.\n# # unset bereq.http.connection;\n# return (pipe);\n# }\n\n# vcl_pass: Called upon entering pass mode. \n# In this mode, the request is passed on to the backend, and the backend's\n# response is passed on to the client, but is not entered into the cache.\n# Subsequent requests submitted over the same client connection are handled normally.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pass\n# sub vcl_pass {\n# return (fetch);\n# }\n\n# vcl_hash: You may call hash_data() on the data you would like to add to the\n# hash.\n# Hash is used by Varnish to uniquely identify objects.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hash\nsub vcl_hash {\n \/* Hash cookie data *\/\n # As requests with same URL and host can produce diferent results when issued\n # with different cookies, we need to store items hashed with the associated\n # cookies. Note that cookies are already sanitized when we reach this point.\n if (req.http.Cookie) {\n \/* Include cookie in cache hash *\/\n hash_data(req.http.Cookie);\n }\n\n \/* Custom header hashing *\/\n # Empty in simple configs.\n # Example for caching differents object versions by device previously\n # detected (when static content could also vary):\n # if (req.http.X-UA-Device) {\n # hash_data(req.http.X-UA-Device);\n # }\n # Example for caching diferent object versions by X-Forwarded-Proto, trying\n # to be smart about what kind of request could generate diffetent responses.\n if ( req.http.X-Forwarded-Proto\n && req.url !~ \"(?i)\\.(png|gif|jpeg|jpg|ico|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|woff2|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\") {\n hash_data(req.http.X-Forwarded-Proto);\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (lookup);\n# }\n\n# vcl_purge: Called after the purge has been executed and all its variants have\n# been evited.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-purge\n# sub vcl_purge {\n# return (synth(200, \"Purged\"));\n# }\n\n# vcl_hit: Called after a cache lookup if the requested document was found in\n# the cache.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hit\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n \/\/ A pure unadultered hit, deliver it\n return (deliver);\n }\n \/* Allow varnish to serve up stale content if it is responding slowly *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n if (obj.ttl + 60s > 0s) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n set req.http.grace = \"normal\";\n return (deliver);\n }\n \/* Allow varish to serve up stale content if all backends are down *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n if ( ! std.healthy(req.backend_hint)\n && obj.ttl + obj.grace > 0s\n ) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n set req.http.grace = \"extended\";\n return (deliver);\n }\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\n# vcl_miss: Called after a cache lookup if the requested document was not found\n# in the cache.\n# Its purpose is to decide whether or not to attempt to retrieve the document\n# from the backend, and which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-miss\n# sub vcl_miss {\n# return (fetch);\n# }\n\n# vcl_deliver: Called before an object is delivered to the client\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-deliver\nsub vcl_deliver {\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # Add whether the object is a cache hit or miss and the number of hits for\n # the object.\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Addingaheaderindicatinghitmiss\n # In Varnish 4 the obj.hits counter behaviour has changed (see bug 1492), so\n # we use a different method: if X-Varnish contains only 1 id, we have a miss,\n # if it contains more (and therefore a space), we have a hit.\n if (resp.http.x-varnish ~ \" \") {\n set resp.http.X-Cache = \"HIT\";\n # Since in Varnish 4 the behaviour of obj.hits changed, this might not be\n # accurate.\n # See https:\/\/www.varnish-cache.org\/trac\/ticket\/1492\n set resp.http.X-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Cache = \"MISS\";\n \/* Show the results of cookie sanitization *\/\n set resp.http.X-Cookie = req.http.Cookie;\n }\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n set resp.http.grace = req.http.grace;\n\n #TODO# Add sick marker\n\n # Restart count\n if ( req.restarts > 0) {\n set resp.http.X-Restarts = req.restarts;\n }\n\n # Add the Varnish server hostname\n set resp.http.X-Varnish-Server = server.hostname;\n # If we have setted a custom header with device's family detected we can show\n # it:\n # if (req.http.X-UA-Device) {\n # set resp.http.X-UA-Device = req.http.X-UA-Device;\n # }\n # If we have recived a custom header indicating the protocol in the request we\n # can show it:\n # if (req.http.X-Forwarded-Proto) {\n # set resp.http.X-Forwarded-Proto = req.http.X-Forwarded-Proto;\n # }\n\n \/* Vary header manipulation *\/\n # Empty in simple configs.\n # By example, if we are storing & serving diferent objects depending on\n # User-Agent header we must set the correct Vary header:\n # if (resp.http.Vary) {\n # set resp.http.Vary = resp.http.Vary + \",User-Agent\";\n # } else {\n # set resp.http.Vary = \"User-Agent\";\n # }\n\n \/* Fake headers *\/\n # Empty in simple configs\n # We can fake server headers here, by example:\n # set resp.http.Server = \"Deep thought\";\n # set resp.http.X-Powered-By = \"BOFH\";\n # Or have some fun with headers:\n # See http:\/\/www.nextthing.org\/archives\/2005\/08\/07\/fun-with-http-headers\n # See http:\/\/royal.pingdom.com\/2012\/08\/15\/fun-and-unusual-http-response-headers\/\n # set resp.http.X-Thank-You = \"for bothering to look at my HTTP headers\";\n # set resp.http.X-Answer = \"42\";\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_deliver {\n# return (deliver);\n# }\n\n# vcl_synth: Called to deliver a synthetic object. A synthetic object is\n# generated in VCL, not fetched from the backend. It is typically contructed\n# using the synthetic() function.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-synth\n\/*\n * We can come here \"invisibly\" with the following errors: 413, 417 & 503\n *\/\nsub vcl_synth {\n \/* Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_synth;\n\n \/* Try to restart request in case of failure *\/\n # Note that max_restarts defaults to 4\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if (resp.status == 503 && req.restarts < 4) {\n return(restart);\n }\n\n \/* Set common headers for synthetic responses *\/\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n\n \/* HTTP Authentification client request *\/\n # Empty in simple configs.\n # SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* Load synthetic responses from disk *\/\n # Note that files loaded this way are never re-readed (even after a reload).\n # You should consider PROS\/CONS of doing an include instead.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_std.generated.html#func-fileread\n # Example custom 403 error page.\n # if (resp.status == 403) {\n # synthetic(std.fileread(\"\/403.html\"));\n # return(deliver);\n # }\n\n \/* Error page & refresh \/ redirections *\/\n # We have plenty of choices when we have to serve an error to the client, \n # from the default error page to javascript black magic or plain redirections.\n # Adding some external statistic javascript to track failures served to\n # clients is strongly suggested.\n # We can't use external resources on synthetic content, everything must be\n # inlined.\n # If we need to include images we can embed them in base64 encoding.\n # We're using error 200 for monitoring puposes which should not be retried\n # client side.\n if ( resp.status != 200) {\n set resp.http.Retry-After = \"5\";\n }\n\n # Here is the default error page for Varnish 4 (not so pretty)\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n return (deliver);\n}\n\n#######################################################################\n# Backend Fetch\n\n# vcl_backend_fetch: Called before sending the backend request. In this\n# subroutine you typically alter the request before it gets to the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-fetch\n# sub vcl_backend_fetch {\n# return (fetch);\n# }\n\n# vcl_backend_response: Called after the response headers has been successfully\n# retrieved from the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-response\nsub vcl_backend_response {\n \/* Caching exceptions *\/\n # Varnish will cache objects with response codes:\n # 200, 203, 300, 301, 302, 307, 404 & 410.\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/VCL_Basics.html#the-initial-value-of-beresp-ttl\n # Drupal's Imagecache module can return a 307 redirection to the requested\n # url itself and, depending on Drupal's cache settings, this could lead to a\n # redirection loop being cached for a long time but also we want Varnish to\n # shield a little the backend.\n # See http:\/\/drupal.org\/node\/1248010\n # See http:\/\/drupal.org\/node\/310656\n if (beresp.status == 307 &&\n #TODO# verify that this work better than 'bereq.url ~ \"imagecache\"'\n beresp.http.Location == bereq.url &&\n beresp.ttl > 5s) {\n set beresp.ttl = 5s;\n set beresp.http.cache-control = \"max-age=5\";\n }\n\n \/* Request retrial *\/\n if ( beresp.status == 500\n || beresp.status == 503\n ) {\n #TODO# consider not restarting POST requests as seenV3 on https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleSaintMode\n return (retry);\n }\n\n \/* Enable grace mode. Related with vcl_hit *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n set beresp.grace = 1h;\n\n \/* Strip cookies from the following static file types for all users. *\/\n # Related with our 12th stage on vcl_recv\n if (bereq.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|woff2|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\") {\n unset beresp.http.set-cookie;\n }\n\n \/* Gzip response *\/\n # Empty in simple configs.\n # Use Varnish to Gzip respone, if suitable, before storing it on cache.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html\n if ( ! beresp.http.Content-Encoding\n && ( beresp.http.content-type ~ \"text\"\n || beresp.http.content-type ~ \"application\/x-javascript\"\n || beresp.http.content-type ~ \"application\/javascript\"\n || beresp.http.content-type ~ \"application\/rss+xml\"\n || beresp.http.content-type ~ \"application\/xml\"\n || beresp.http.content-type ~ \"Application\/JSON\")\n ) {\n set beresp.do_gzip = true;\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # We can add the name of the backend that has processed the request:\n # set beresp.http.X-Backend = beresp.backend.name;\n # We can use a header to tell if the object was gziped by Varnish:\n # if (beresp.do_gzip) {\n # set beresp.http.X-Varnish-Gzipped = \"yes\";\n # } else {\n # set beresp.http.X-Varnish-Gizipped = \"no\";\n # }\n # We can also add headers informing whether the object is cacheable or not and why:\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Varnish3.0\n if (beresp.ttl <= 0s) {\n \/* Varnish determined the object was not cacheable *\/\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n } elsif (bereq.http.Cookie ~ \"(SESS|SSESS|NO_CACHE|OATMEAL|CHOCOLATECHIP)\") {\n \/* We don't wish to cache content for logged in users or with certain cookies. *\/\n # Related with our 9th stage on vcl_recv\n set beresp.http.X-Cacheable = \"NO:Cookies\";\n # set beresp.uncacheable = true;\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n \/* We are respecting the Cache-Control=private header from the backend *\/\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n # set beresp.uncacheable = true;\n } else {\n \/* Varnish determined the object was cacheable *\/\n set beresp.http.X-Cacheable = \"YES\";\n }\n\n \/* Further header manipulation *\/\n # Empty in simple configs.\n # We can also unset some headers to prevent information disclosure and save\n # some cache space.\n # unset beresp.http.Server;\n # unset beresp.http.X-Powered-By;\n # Retry count.\n if ( bereq.retries > 0) {\n set beresp.http.X-Retries = bereq.retries;\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_backend_response {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Surrogate-control ~ \"no-store\" ||\n# (!beresp.http.Surrogate-Control &&\n# beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n# beresp.http.Vary == \"*\") {\n# \/*\n# * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# *\/\n# set beresp.ttl = 120s;\n# set beresp.uncacheable = true;\n# }\n# return (deliver);\n# }\n\n# vcl_backend_error: This subroutine is called if we fail the backend fetch.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-error\nsub vcl_backend_error {\n\n \/* Try to restart request in case of failure *\/\n #TODO# Confirm max_retries default value\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if (bereq.retries < 4) {\n return (retry);\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # Retry count\n if ( bereq.retries > 0) {\n set beresp.http.X-Retries = bereq.retries;\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + beresp.status + \" \" + beresp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + beresp.status + \" \" + beresp.reason + {\"<\/h1>\n <p>\"} + beresp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + bereq.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this\n # point.\n return (deliver);\n}\n\n#######################################################################\n# Housekeeping\n\n# vcl_init: Called when VCL is loaded, before any requests pass through it.\n# Typically used to initialize VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-init\n# Here is where you should declare your directors now.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-backends.html#directors\n# Empty in simple configs\n# sub vcl_init {\n# return (ok);\n# }\n\n# vcl_fini: Called when VCL is discarded only after all requests have exited\n# the VCL. Typically used to clean up VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-fini\n# sub vcl_fini {\n# return (ok);\n# }\n\n","returncode":0,"stderr":"","license":"unknown","lang":"VCL"} {"commit":"1469a18891528c3900f59d34ded69d7004322059","subject":"Fix 400 bad request of varnish with nginx and apache 2.4","message":"Fix 400 bad request of varnish with nginx and apache 2.4\n\nUpdate vcl from https:\/\/github.com\/cosimo\/varnish-accept-language\n.\/gen_vcl.pl pt de eo es fr hy it pt ru < accept-language.c > new.vcl\n\n(ActionItem3186)\n","repos":"coletivoEITA\/noosfero-ecosol,blogoosfero\/noosfero,samasti\/noosfero,CIRANDAS\/noosfero-ecosol,samasti\/noosfero,blogoosfero\/noosfero,EcoAlternative\/noosfero-ecosol,CIRANDAS\/noosfero-ecosol,samasti\/noosfero,CIRANDAS\/noosfero-ecosol,samasti\/noosfero,EcoAlternative\/noosfero-ecosol,EcoAlternative\/noosfero-ecosol,EcoAlternative\/noosfero-ecosol,coletivoEITA\/noosfero-ecosol,samasti\/noosfero,EcoAlternative\/noosfero-ecosol,coletivoEITA\/noosfero-ecosol,EcoAlternative\/noosfero-ecosol,EcoAlternative\/noosfero-ecosol,coletivoEITA\/noosfero-ecosol,blogoosfero\/noosfero,blogoosfero\/noosfero,blogoosfero\/noosfero,coletivoEITA\/noosfero-ecosol,coletivoEITA\/noosfero-ecosol,samasti\/noosfero,CIRANDAS\/noosfero-ecosol,blogoosfero\/noosfero,CIRANDAS\/noosfero-ecosol,blogoosfero\/noosfero","old_file":"etc\/noosfero\/varnish-accept-language.vcl","new_file":"etc\/noosfero\/varnish-accept-language.vcl","new_contents":"C{\n\n\/* ------------------------------------------------------------------ *\/\n\/* THIS FILE IS AUTOMATICALLY GENERATED BY .\/gen_vcl.pl. DO NOT EDIT. *\/\n\n\/*\n * Accept-language header normalization\n *\n * - Parses client Accept-Language HTTP header\n * - Tries to find the best match with the supported languages\n * - Writes the best match as req.http.X-Varnish-Accept-Language\n *\n * First version: Cosimo, 21\/Jan\/2010\n * Last update: Cosimo, 03\/Nov\/2011\n *\n * http:\/\/github.com\/cosimo\/varnish-accept-language\n *\n *\/\n\n#include <ctype.h> \/* isupper *\/\n#include <stdio.h>\n#include <stdlib.h> \/* qsort *\/\n#include <string.h>\n\n#define DEFAULT_LANGUAGE \"pt\"\n#define SUPPORTED_LANGUAGES \":de:eo:es:fr:hy:it:pt:ru:\"\n\n#define vcl_string char\n#define LANG_LIST_SIZE 16\n#define HDR_MAXLEN 256\n#define LANG_MAXLEN 8\n#define RETURN_LANG(x) { \\\n strncpy(lang, x, LANG_MAXLEN); \\\n return; \\\n}\n#define RETURN_DEFAULT_LANG RETURN_LANG(DEFAULT_LANGUAGE)\n#define PUSH_LANG(x,y) { \\\n \/* fprintf(stderr, \"Pushing lang [%d] %s %.4f\\n\", curr_lang, x, y); *\/ \\\n \/* We have to copy, otherwise root_lang will be the same every time *\/ \\\n strncpy(pl[curr_lang].lang, x, LANG_MAXLEN); \\\n pl[curr_lang].q = y; \\\n curr_lang++; \\\n}\n\nstruct lang_list {\n vcl_string lang[LANG_MAXLEN];\n float q;\n};\n\n\/* In-place lowercase of a string *\/\nstatic void strtolower(char *s) {\n register char *c;\n for (c=s; *c; c++) {\n if (isupper(*c)) {\n *c = tolower(*c);\n }\n }\n return;\n}\n\n\/* Checks if a given language is in the static list of the ones we support *\/\nint is_supported(vcl_string *lang) {\n vcl_string *supported_languages = SUPPORTED_LANGUAGES;\n vcl_string match_str[LANG_MAXLEN + 3] = \"\"; \/* :, :, \\0 = 3 *\/\n int is_supported = 0;\n\n \/* We want to match 'zh-cn' and 'zh-CN' too *\/\n strtolower(lang);\n\n \/* Search \":<lang>:\" in supported languages string *\/\n strncpy(match_str, \":\", 1);\n strncat(match_str, lang, LANG_MAXLEN);\n strncat(match_str, \":\\0\", 2);\n\n if (strstr(supported_languages, match_str))\n is_supported = 1;\n\n return is_supported;\n}\n\n\/* Used by qsort() below *\/\nint sort_by_q(const void *x, const void *y) {\n struct lang_list *a = (struct lang_list *)x;\n struct lang_list *b = (struct lang_list *)y;\n if (a->q > b->q) return -1;\n if (a->q < b->q) return 1;\n return 0;\n}\n\n\/* Reads Accept-Language, parses it, and finds the first match\n among the supported languages. In case of no match,\n returns the default language.\n*\/\nvoid select_language(const vcl_string *incoming_header, char *lang) {\n\n struct lang_list pl[LANG_LIST_SIZE];\n vcl_string *lang_tok = NULL;\n vcl_string root_lang[3];\n vcl_string *header;\n vcl_string header_copy[HDR_MAXLEN];\n vcl_string *pos = NULL;\n vcl_string *q_spec = NULL;\n unsigned int curr_lang = 0, i = 0;\n float q;\n\n \/* Empty or default string, return default language immediately *\/\n if (\n !incoming_header\n || (0 == strcmp(incoming_header, \"en-US\"))\n || (0 == strcmp(incoming_header, \"en-GB\"))\n || (0 == strcmp(incoming_header, DEFAULT_LANGUAGE))\n || (0 == strcmp(incoming_header, \"\"))\n )\n RETURN_DEFAULT_LANG;\n\n \/* Tokenize Accept-Language *\/\n header = strncpy(header_copy, incoming_header, sizeof(header_copy));\n\n while ((lang_tok = strtok_r(header, \" ,\", &pos))) {\n\n q = 1.0;\n\n if ((q_spec = strstr(lang_tok, \";q=\"))) {\n \/* Truncate language name before ';' *\/\n *q_spec = '\\0';\n \/* Get q value *\/\n sscanf(q_spec + 3, \"%f\", &q);\n }\n\n \/* Wildcard language '*' should be last in list *\/\n if ((*lang_tok) == '*') q = 0.0;\n\n \/* Push in the prioritized list *\/\n PUSH_LANG(lang_tok, q);\n\n \/* For cases like 'en-GB', we also want the root language in the final list *\/\n if ('-' == lang_tok[2]) {\n root_lang[0] = lang_tok[0];\n root_lang[1] = lang_tok[1];\n root_lang[2] = '\\0';\n PUSH_LANG(root_lang, q - 0.001);\n }\n\n \/* For strtok_r() to proceed from where it left off *\/\n header = NULL;\n\n \/* Break out if stored max no. of languages *\/\n if (curr_lang >= LANG_LIST_SIZE)\n break;\n }\n\n \/* Sort by priority *\/\n qsort(pl, curr_lang, sizeof(struct lang_list), &sort_by_q);\n\n \/* Match with supported languages *\/\n for (i = 0; i < curr_lang; i++) {\n if (is_supported(pl[i].lang))\n RETURN_LANG(pl[i].lang);\n }\n\n RETURN_DEFAULT_LANG;\n}\n\n\/* Reads req.http.Accept-Language and writes X-Varnish-Accept-Language *\/\nvoid vcl_rewrite_accept_language(const struct sess *sp) {\n vcl_string *in_hdr;\n vcl_string lang[LANG_MAXLEN];\n\n \/* Get Accept-Language header from client *\/\n in_hdr = VRT_GetHdr(sp, HDR_REQ, \"\\020Accept-Language:\");\n\n \/* Normalize and filter out by list of supported languages *\/\n memset(lang, 0, sizeof(lang));\n select_language(in_hdr, lang);\n\n \/* By default, use a different header name: don't mess with backend logic *\/\n VRT_SetHdr(sp, HDR_REQ, \"\\032X-Varnish-Accept-Language:\", lang, vrt_magic_string_end);\n\n return;\n}\n\n\/* vim: syn=c ts=4 et sts=4 sw=4 tw=0\n*\/\n\n\/* THIS FILE IS AUTOMATICALLY GENERATED BY .\/gen_vcl.pl. DO NOT EDIT. *\/\n\/* ------------------------------------------------------------------ *\/\n}C\n\nsub vcl_recv {\n C{\n vcl_rewrite_accept_language(sp);\n }C\n}\n\nsub vcl_fetch {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary + \", X-Varnish-Accept-Language\";\n } else {\n set beresp.http.Vary = \"X-Varnish-Accept-Language\";\n }\n}\n\n","old_contents":"C{\n\n\/* ------------------------------------------------------------------ *\/\n\/* THIS FILE IS AUTOMATICALLY GENERATED BY .\/gen_vcl.pl. DO NOT EDIT. *\/\n\n\/*\n * Accept-language header normalization\n *\n * Cosimo, 21\/01\/2010\n *\n *\/\n\n#include <ctype.h> \/* isupper *\/\n#include <stdio.h>\n#include <stdlib.h> \/* qsort *\/\n#include <string.h>\n\n#define DEFAULT_LANGUAGE \"en\"\n#define SUPPORTED_LANGUAGES \":de:fr:es:ru:pt:hy:en:\"\n\n#define vcl_string char\n#define LANG_LIST_SIZE 16 \n#define LANG_MAXLEN 16\n#define RETURN_LANG(x) { \\\n strncpy(lang, x, LANG_MAXLEN); \\\n return; \\\n}\n#define RETURN_DEFAULT_LANG RETURN_LANG(DEFAULT_LANGUAGE)\n#define PUSH_LANG(x,y) { \\\n \/* fprintf(stderr, \"Pushing lang [%d] %s %.4f\\n\", curr_lang, x, y); *\/ \\\n \/* We have to copy, otherwise root_lang will be the same every time *\/ \\\n strncpy(pl[curr_lang].lang, x, LANG_MAXLEN); \\\n pl[curr_lang].q = y; \\\n curr_lang++; \\\n}\n\nstruct lang_list {\n vcl_string lang[LANG_MAXLEN];\n float q;\n};\n\n\/* In-place lowercase of a string *\/\nstatic void strtolower(char *s) {\n register char *c;\n for (c=s; *c; c++) {\n if (isupper(*c)) {\n *c = tolower(*c);\n }\n }\n return;\n}\n\n\/* Checks if a given language is in the static list of the ones we support *\/\nint is_supported(vcl_string *lang) {\n vcl_string *supported_languages = SUPPORTED_LANGUAGES;\n vcl_string match_str[LANG_MAXLEN + 3] = \"\"; \/* :, :, \\0 = 3 *\/\n int is_supported = 0;\n\n \/* We want to match 'zh-cn' and 'zh-CN' too *\/\n strtolower(lang);\n\n \/* Search \":<lang>:\" in supported languages string *\/\n strncpy(match_str, \":\", 1);\n strncat(match_str, lang, LANG_MAXLEN);\n strncat(match_str, \":\\0\", 2);\n\n if (strstr(supported_languages, match_str)) {\n is_supported = 1;\n }\n\n return is_supported;\n}\n\n\/* Used by qsort() below *\/\nint sort_by_q(const void *x, const void *y) {\n struct lang_list *a = (struct lang_list *)x;\n struct lang_list *b = (struct lang_list *)y;\n if (a->q > b->q) return -1;\n if (a->q < b->q) return 1;\n return 0;\n}\n\n\/* Reads Accept-Language, parses it, and finds the first match\n among the supported languages. In case of no match,\n returns the default language.\n*\/\nvoid select_language(const vcl_string *incoming_header, char *lang) {\n\n struct lang_list pl[LANG_LIST_SIZE];\n vcl_string *lang_tok = NULL;\n vcl_string root_lang[3];\n vcl_string *header;\n vcl_string *pos = NULL;\n vcl_string *q_spec = NULL;\n unsigned int curr_lang = 0, i = 0;\n float q;\n\n \/* Empty or default string, return default language immediately *\/\n if (\n !incoming_header\n || (0 == strcmp(incoming_header, \"en-US\"))\n || (0 == strcmp(incoming_header, \"en-GB\"))\n || (0 == strcmp(incoming_header, DEFAULT_LANGUAGE))\n || (0 == strcmp(incoming_header, \"\"))\n )\n RETURN_DEFAULT_LANG;\n\n \/* Tokenize Accept-Language *\/\n header = (vcl_string *) incoming_header;\n\n while ((lang_tok = strtok_r(header, \" ,\", &pos))) {\n\n q = 1.0;\n\n if ((q_spec = strstr(lang_tok, \";q=\"))) {\n \/* Truncate language name before ';' *\/\n *q_spec = '\\0';\n \/* Get q value *\/\n sscanf(q_spec + 3, \"%f\", &q);\n }\n\n \/* Wildcard language '*' should be last in list *\/\n if ((*lang_tok) == '*') q = 0.0;\n\n \/* Push in the prioritized list *\/\n PUSH_LANG(lang_tok, q);\n\n \/* For cases like 'en-GB', we also want the root language in the final list *\/\n if ('-' == lang_tok[2]) {\n root_lang[0] = lang_tok[0];\n root_lang[1] = lang_tok[1];\n root_lang[2] = '\\0';\n PUSH_LANG(root_lang, q - 0.001);\n }\n\n \/* For strtok_r() to proceed from where it left off *\/\n header = NULL;\n\n \/* Break out if stored max no. of languages *\/\n if (curr_lang >= LANG_MAXLEN) break;\n }\n\n \/* Sort by priority *\/\n qsort(pl, curr_lang, sizeof(struct lang_list), &sort_by_q);\n\n \/* Match with supported languages *\/\n for (i = 0; i < curr_lang; i++) {\n if (is_supported(pl[i].lang))\n RETURN_LANG(pl[i].lang);\n }\n\n RETURN_DEFAULT_LANG;\n}\n\n\/* Reads req.http.Accept-Language and writes X-Varnish-Accept-Language *\/\nvoid vcl_rewrite_accept_language(const struct sess *sp) {\n vcl_string *in_hdr;\n vcl_string lang[LANG_MAXLEN];\n\n memset(lang, 0, LANG_MAXLEN);\n\n \/* Get Accept-Language header from client *\/\n in_hdr = VRT_GetHdr(sp, HDR_REQ, \"\\020Accept-Language:\");\n\n \/* Normalize and filter out by list of supported languages *\/\n select_language(in_hdr, lang);\n\n \/* By default, use a different header name: don't mess with backend logic *\/\n VRT_SetHdr(sp, HDR_REQ, \"\\032X-Varnish-Accept-Language:\", lang, vrt_magic_string_end);\n\n return;\n}\n\n\/* vim: syn=c ts=4 et sts=4 sw=4 tw=0\n*\/\n\n\/* THIS FILE IS AUTOMATICALLY GENERATED BY .\/gen_vcl.pl. DO NOT EDIT. *\/\n\/* ------------------------------------------------------------------ *\/\n}C\n\nsub vcl_recv {\n C{\n vcl_rewrite_accept_language(sp);\n }C\n}\n\nsub vcl_fetch {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary + \", X-Varnish-Accept-Language\";\n } else {\n set beresp.http.Vary = \"X-Varnish-Accept-Language\";\n }\n}\n","returncode":0,"stderr":"","license":"agpl-3.0","lang":"VCL"} {"commit":"bb8e54986364aa0180ec1b169c315e2cd6339068","subject":"Fix the ?next= parameter to admin login (#1535)","message":"Fix the ?next= parameter to admin login (#1535)\n\n","repos":"dstufft\/warehouse,pypa\/warehouse,alex\/warehouse,dstufft\/warehouse,dstufft\/warehouse,pypa\/warehouse,pypa\/warehouse,alex\/warehouse,pypa\/warehouse,dstufft\/warehouse,alex\/warehouse,alex\/warehouse,alex\/warehouse","old_file":"vcl\/main.vcl","new_file":"vcl\/main.vcl","new_contents":"\nsub vcl_recv {\n\n # I'm not 100% sure on what this is exactly for, it was taken from the\n # Fastly documentation, however, what I *believe* it does is just ensure\n # that we don't serve a stale copy of the page from the shield node when\n # an edge node is requesting content.\n if (req.http.Fastly-FF) {\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Some (Older) clients will send a hash fragment as part of the URL even\n # though that is a local only modification. This breaks this badly for the\n # files in S3, and in general it's just not needed.\n set req.url = regsub(req.url, \"#.*$\", \"\");\n\n # Fastly does some normalization of the Accept-Encoding header so that it\n # reduces the number of cached copies (when served with the common,\n # Vary: Accept-Encoding) that are cached for any one URL. This makes a lot\n # of sense, except for the fact that we want to enable brotli compression\n # for our static files. Thus we need to work around the normalized encoding\n # in a way that still minimizes cached copies, but which will allow our\n # static files to be served using brotli.\n if (req.url ~ \"^\/static\/\" && req.http.Fastly-Orig-Accept-Encoding) {\n if (req.http.User-Agent ~ \"MSIE 6\") {\n # For that 0.3% of stubborn users out there\n unset req.http.Accept-Encoding;\n } elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"br\") {\n set req.http.Accept-Encoding = \"br\";\n } elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n\n # Most of the URLs in Warehouse do not support or require any sort of query\n # parameter. If we strip these at the edge then we'll increase our cache\n # efficiency when they won't otherwise change the output of the pages.\n #\n # This will match any URL except those that start with:\n #\n # * \/admin\/\n # * \/search\/\n # * \/account\/login\/\n # * \/account\/logout\/\n # * \/account\/register\/\n # * \/pypi\n if (req.url.path !~ \"^\/(admin\/|search(\/|$)|account\/(login|logout|register)\/|pypi)\") {\n set req.url = req.url.path;\n }\n\n # Sort all of our query parameters, this will ensure that the same query\n # parameters in a different order will end up being represented as the same\n # thing, reducing cache misses due to ordering differences.\n set req.url = boltsort.sort(req.url);\n\n\n#FASTLY recv\n\n\n # We want to Force SSL for the WebUI by redirecting to the HTTPS version of\n # the page, however for API calls we want to return an error code directing\n # people to instead use HTTPS.\n if (!req.http.Fastly-SSL) {\n\n # The \/simple\/ and \/packages\/ API.\n if (req.url ~ \"^\/(simple|packages)\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy JSON API.\n if (req.url ~ \"^\/pypi\/.+\/json$\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy ?:action= API.\n if (req.url ~ \"^\/pypi.*(\\?|&)=:action\") {\n error 803 \"SSL is required\";\n }\n\n # If we're on the \/pypi page and we've received something other than a\n # GET or HEAD request, then we have no way to determine if a particular\n # request is an API call or not because it'll be in the request body\n # and that isn't available to us here. So in those cases, we won't\n # do a redirect.\n if (req.url ~ \"^\/pypi\") {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n error 801 \"Force SSL\";\n }\n }\n else {\n # This isn't a \/pypi URL so we'll just unconditionally redirect to\n # HTTPS.\n error 801 \"Force SSL\";\n }\n }\n\n # Redirect pypi.io, www.pypi.io, and warehouse.python.org to pypi.org, this\n # is purposely done *after* the HTTPS checks.\n if (std.tolower(req.http.host) ~ \"^(www.pypi.org|(www.)?pypi.io|warehouse.python.org)$\") {\n set req.http.Location = \"https:\/\/pypi.org\" req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n # Redirect warehouse-staging.python.org to test.pypi.io.\n if (std.tolower(req.http.host) ~ \"^(test.pypi.io|warehouse-staging.python.org)$\") {\n set req.http.Location = \"https:\/\/test.pypi.org\" req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n\n # Requests to \/packages\/ get dispatched to Amazon instead of to our typical\n # Origin. This requires a a bit of setup to make it work.\n if (req.http.host ~ \"^(test-)?files.pythonhosted.org$\"\n && req.url ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\") {\n # Setup our environment to better match what S3 expects\/needs\n set req.http.Host = req.http.AWS-Bucket-Name \".s3.amazonaws.com\";\n set req.http.Date = now;\n set req.url = regsuball(req.url, \"\\+\", urlencode(\"+\"));\n\n # Compute the Authorization header that S3 requires to be able to\n # access the files stored there.\n set req.http.Authorization = \"AWS \" req.http.AWS-Access-Key-ID \":\" digest.hmac_sha1_base64(req.http.AWS-Secret-Access-Key, \"GET\" LF LF LF req.http.Date LF \"\/\" req.http.AWS-Bucket-Name req.url.path);\n\n # We don't want to send our Warehouse-Token to S3, so we'll go ahead\n # and remove it.\n unset req.http.Warehouse-Token;\n }\n\n # We no longer need any of these variables, which would exist only to\n # shuffle configuration from the Fastly UI into our VCL.\n unset req.http.AWS-Access-Key-ID;\n unset req.http.AWS-Secret-Access-Key;\n unset req.http.AWS-Bucket-Name;\n\n # We have a number of items that we'll pass back to the origin, but only\n # if we have a Warehouse-Token that will allow them to be accepted.\n if (req.http.Warehouse-Token) {\n # Set a header to tell the backend if we're using https or http.\n if (req.http.Fastly-SSL) {\n set req.http.Warehouse-Proto = \"https\";\n } else {\n set req.http.Warehouse-Proto = \"http\";\n }\n\n # Pass the client IP address back to the backend.\n if (req.http.Fastly-Client-IP) {\n set req.http.Warehouse-IP = req.http.Fastly-Client-IP;\n }\n\n # Pass the real host value back to the backend.\n if (req.http.Host) {\n set req.http.Warehouse-Host = req.http.host;\n }\n }\n\n # On a POST, we want to skip the shielding and hit backends directly.\n if (req.request == \"POST\") {\n set req.backend = F_Heroku;\n }\n\n # Do not bother to attempt to run the caching mechanisms for methods that\n # are not generally safe to cache.\n if (req.request != \"HEAD\" &&\n req.request != \"GET\" &&\n req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n # We don't ever want to cache our health URL. Outside systems should be\n # able to use it to reach past Fastly and get an end to end health check.\n if (req.url == \"\/_health\/\") {\n return(pass);\n }\n\n # We never want to cache our admin URLs, while this should be \"safe\" due to\n # the architecure of Warehouse, it'll just be easier to debug issues if\n # these always are uncached.\n if (req.url ~ \"^\/admin\/\") {\n return(pass);\n }\n\n # Finally, return the default lookup action.\n return(lookup);\n}\n\n\nsub vcl_fetch {\n\n # These are newer kinds of redirects which should be able to be cached by\n # default, even though Fastly doesn't currently have them in their default\n # list of cacheable status codes.\n if (http_status_matches(beresp.status, \"303,307,308\")) {\n set beresp.cacheable = true;\n }\n\n # For any 5xx status code we want to see if a stale object exists for it,\n # if so we'll go ahead and serve it.\n if (beresp.status >= 500 && beresp.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n # When delivering a 304 response, we don't always have access to all the\n # headers in the resp because a 304 response is supposed to remove most of\n # the headers. So we'll instead stash these headers on the request so that\n # we can log this data from there instead of from the response.\n if (beresp.http.x-amz-meta-project\n || beresp.http.x-amz-meta-version\n || beresp.http.x-amz-meta-package-type) {\n set req.http.Fastly-amz-meta-project = beresp.http.x-amz-meta-project;\n set req.http.Fastly-amz-meta-version = beresp.http.x-amz-meta-version;\n set req.http.Fastly-amz-meta-package-type = beresp.http.x-amz-meta-package-type;\n }\n\n\n#FASTLY fetch\n\n\n # Trigger a \"SSL is required\" error if the backend has indicated to do so.\n if (beresp.http.X-Fastly-Error == \"803\") {\n error 803 \"SSL is required\";\n }\n\n # If we've gotten a 502 or a 503 from the backend, we'll go ahead and retry\n # the request.\n if ((beresp.status == 502 || beresp.status == 503) &&\n req.restarts < 1 &&\n (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n # If we've restarted, then we'll record the number of restarts.\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n # If there is a Set-Cookie header, we'll ensure that we do not cache the\n # response.\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n # If the response has the private Cache-Control directive then we won't\n # cache it.\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # If we've gotten an error after the restarts we'll deliver the response\n # with a very short cache time.\n if (http_status_matches(beresp.status, \"500,502,503\")) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n # Apply a default TTL if there isn't a max-age or s-maxage.\n if (beresp.http.Expires ||\n beresp.http.Surrogate-Control ~ \"max-age\" ||\n beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # Keep the ttl here\n }\n else {\n # Apply the default ttl\n set beresp.ttl = 60s;\n }\n\n # Actually deliver the fetched response.\n return(deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n # If the object we have isn't cacheable, then just serve it directly\n # without going through any of the caching mechanisms.\n if (!obj.cacheable) {\n return(pass);\n }\n\n return(deliver);\n}\n\n\nsub vcl_deliver {\n # If this is an error and we have a stale response available, restart so\n # that we can pick it up and serve it.\n if (resp.status >= 500 && resp.status < 600) {\n if (stale.exists) {\n restart;\n }\n }\n\n#FASTLY deliver\n\n # Unset headers that we don't need\/want to send on to the client because\n # they are not generally useful.\n unset resp.http.Server;\n unset resp.http.Via;\n\n # Unset a few headers set by Amazon that we don't really have a need\/desire\n # to send to clients.\n unset resp.http.X-AMZ-Replication-Status;\n unset resp.http.X-AMZ-Meta-Python-Version;\n unset resp.http.X-AMZ-Meta-Version;\n unset resp.http.X-AMZ-Meta-Package-Type;\n unset resp.http.X-AMZ-Meta-Project;\n\n # Set our standard security headers, we do this in VCL rather than in\n # Warehouse itself so that we always get these headers, regardless of the\n # origin server being used.\n set resp.http.Strict-Transport-Security = \"max-age=31536000; includeSubDomains; preload\";\n set resp.http.X-Frame-Options = \"deny\";\n set resp.http.X-XSS-Protection = \"1; mode=block\";\n set resp.http.X-Content-Type-Options = \"nosniff\";\n set resp.http.X-Permitted-Cross-Domain-Policies = \"none\";\n\n # Unstash our information about what project\/version\/package-type a\n # particular file download was for.\n if (req.http.Fastly-amz-meta-project\n || req.http.Fastly-amz-meta-version\n || req.http.Fastly-amz-meta-package-type) {\n set resp.http.x-amz-meta-project = req.http.Fastly-amz-meta-project;\n set resp.http.x-amz-meta-version = req.http.Fastly-amz-meta-version;\n set resp.http.x-amz-meta-package-type = req.http.Fastly-amz-meta-package-type;\n }\n\n # If we're not executing a shielding request, and the URL is one of our file\n # URLs, and it's a GET request, and the response is either a 200 or a 304\n # then we want to log an event stating that a download has taken place.\n if (!req.http.Fastly-FF\n && std.tolower(req.http.host) == \"files.pythonhosted.org\"\n && req.url.path ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\"\n && req.request == \"GET\"\n && http_status_matches(resp.status, \"200,304\")) {\n log {\"syslog \"} req.service_id {\" linehaul :: \"} \"2@\" now \"|\" geoip.country_code \"|\" req.url.path \"|\" tls.client.protocol \"|\" tls.client.cipher \"|\" resp.http.x-amz-meta-project \"|\" resp.http.x-amz-meta-version \"|\" resp.http.x-amz-meta-package-type \"|\" req.http.user-agent;\n log {\"syslog \"} req.service_id {\" downloads :: \"} \"2@\" now \"|\" geoip.country_code \"|\" req.url.path \"|\" tls.client.protocol \"|\" tls.client.cipher \"|\" resp.http.x-amz-meta-project \"|\" resp.http.x-amz-meta-version \"|\" resp.http.x-amz-meta-package-type \"|\" req.http.user-agent;\n }\n\n return(deliver);\n}\n\n\nsub vcl_error {\n#FASTLY error\n\n # If we have a 5xx error and there is a stale object available, then we\n # will deliver that stale object.\n if (obj.status >= 500 && obj.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n if (obj.status == 803) {\n set obj.status = 403;\n set obj.response = \"SSL is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic {\"SSL is required.\"};\n return (deliver);\n } else if (obj.status == 750) {\n set obj.status = 301;\n set obj.http.Location = req.http.Location;\n set obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n synthetic {\"<html><head><title>301 Moved Permanently<\/title><\/head><body><center><h1>301 Moved Permanently<\/h1><\/center><\/body><\/html>\"};\n return(deliver);\n }\n\n}\n","old_contents":"\nsub vcl_recv {\n\n # I'm not 100% sure on what this is exactly for, it was taken from the\n # Fastly documentation, however, what I *believe* it does is just ensure\n # that we don't serve a stale copy of the page from the shield node when\n # an edge node is requesting content.\n if (req.http.Fastly-FF) {\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Some (Older) clients will send a hash fragment as part of the URL even\n # though that is a local only modification. This breaks this badly for the\n # files in S3, and in general it's just not needed.\n set req.url = regsub(req.url, \"#.*$\", \"\");\n\n # Fastly does some normalization of the Accept-Encoding header so that it\n # reduces the number of cached copies (when served with the common,\n # Vary: Accept-Encoding) that are cached for any one URL. This makes a lot\n # of sense, except for the fact that we want to enable brotli compression\n # for our static files. Thus we need to work around the normalized encoding\n # in a way that still minimizes cached copies, but which will allow our\n # static files to be served using brotli.\n if (req.url ~ \"^\/static\/\" && req.http.Fastly-Orig-Accept-Encoding) {\n if (req.http.User-Agent ~ \"MSIE 6\") {\n # For that 0.3% of stubborn users out there\n unset req.http.Accept-Encoding;\n } elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"br\") {\n set req.http.Accept-Encoding = \"br\";\n } elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n\n # Most of the URLs in Warehouse do not support or require any sort of query\n # parameter. If we strip these at the edge then we'll increase our cache\n # efficiency when they won't otherwise change the output of the pages.\n #\n # This will match any URL except those that start with:\n #\n # * \/search\/\n # * \/account\/login\/\n # * \/account\/logout\/\n # * \/account\/register\/\n # * \/pypi\n if (req.url.path !~ \"^\/(search(\/|$)|account\/(login|logout|register)\/|pypi)\") {\n set req.url = req.url.path;\n }\n\n # Sort all of our query parameters, this will ensure that the same query\n # parameters in a different order will end up being represented as the same\n # thing, reducing cache misses due to ordering differences.\n set req.url = boltsort.sort(req.url);\n\n\n#FASTLY recv\n\n\n # We want to Force SSL for the WebUI by redirecting to the HTTPS version of\n # the page, however for API calls we want to return an error code directing\n # people to instead use HTTPS.\n if (!req.http.Fastly-SSL) {\n\n # The \/simple\/ and \/packages\/ API.\n if (req.url ~ \"^\/(simple|packages)\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy JSON API.\n if (req.url ~ \"^\/pypi\/.+\/json$\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy ?:action= API.\n if (req.url ~ \"^\/pypi.*(\\?|&)=:action\") {\n error 803 \"SSL is required\";\n }\n\n # If we're on the \/pypi page and we've received something other than a\n # GET or HEAD request, then we have no way to determine if a particular\n # request is an API call or not because it'll be in the request body\n # and that isn't available to us here. So in those cases, we won't\n # do a redirect.\n if (req.url ~ \"^\/pypi\") {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n error 801 \"Force SSL\";\n }\n }\n else {\n # This isn't a \/pypi URL so we'll just unconditionally redirect to\n # HTTPS.\n error 801 \"Force SSL\";\n }\n }\n\n # Redirect pypi.io, www.pypi.io, and warehouse.python.org to pypi.org, this\n # is purposely done *after* the HTTPS checks.\n if (std.tolower(req.http.host) ~ \"^(www.pypi.org|(www.)?pypi.io|warehouse.python.org)$\") {\n set req.http.Location = \"https:\/\/pypi.org\" req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n # Redirect warehouse-staging.python.org to test.pypi.io.\n if (std.tolower(req.http.host) ~ \"^(test.pypi.io|warehouse-staging.python.org)$\") {\n set req.http.Location = \"https:\/\/test.pypi.org\" req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n\n # Requests to \/packages\/ get dispatched to Amazon instead of to our typical\n # Origin. This requires a a bit of setup to make it work.\n if (req.http.host ~ \"^(test-)?files.pythonhosted.org$\"\n && req.url ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\") {\n # Setup our environment to better match what S3 expects\/needs\n set req.http.Host = req.http.AWS-Bucket-Name \".s3.amazonaws.com\";\n set req.http.Date = now;\n set req.url = regsuball(req.url, \"\\+\", urlencode(\"+\"));\n\n # Compute the Authorization header that S3 requires to be able to\n # access the files stored there.\n set req.http.Authorization = \"AWS \" req.http.AWS-Access-Key-ID \":\" digest.hmac_sha1_base64(req.http.AWS-Secret-Access-Key, \"GET\" LF LF LF req.http.Date LF \"\/\" req.http.AWS-Bucket-Name req.url.path);\n\n # We don't want to send our Warehouse-Token to S3, so we'll go ahead\n # and remove it.\n unset req.http.Warehouse-Token;\n }\n\n # We no longer need any of these variables, which would exist only to\n # shuffle configuration from the Fastly UI into our VCL.\n unset req.http.AWS-Access-Key-ID;\n unset req.http.AWS-Secret-Access-Key;\n unset req.http.AWS-Bucket-Name;\n\n # We have a number of items that we'll pass back to the origin, but only\n # if we have a Warehouse-Token that will allow them to be accepted.\n if (req.http.Warehouse-Token) {\n # Set a header to tell the backend if we're using https or http.\n if (req.http.Fastly-SSL) {\n set req.http.Warehouse-Proto = \"https\";\n } else {\n set req.http.Warehouse-Proto = \"http\";\n }\n\n # Pass the client IP address back to the backend.\n if (req.http.Fastly-Client-IP) {\n set req.http.Warehouse-IP = req.http.Fastly-Client-IP;\n }\n\n # Pass the real host value back to the backend.\n if (req.http.Host) {\n set req.http.Warehouse-Host = req.http.host;\n }\n }\n\n # On a POST, we want to skip the shielding and hit backends directly.\n if (req.request == \"POST\") {\n set req.backend = F_Heroku;\n }\n\n # Do not bother to attempt to run the caching mechanisms for methods that\n # are not generally safe to cache.\n if (req.request != \"HEAD\" &&\n req.request != \"GET\" &&\n req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n # We don't ever want to cache our health URL. Outside systems should be\n # able to use it to reach past Fastly and get an end to end health check.\n if (req.url == \"\/_health\/\") {\n return(pass);\n }\n\n # We never want to cache our admin URLs, while this should be \"safe\" due to\n # the architecure of Warehouse, it'll just be easier to debug issues if\n # these always are uncached.\n if (req.url ~ \"^\/admin\/\") {\n return(pass);\n }\n\n # Finally, return the default lookup action.\n return(lookup);\n}\n\n\nsub vcl_fetch {\n\n # These are newer kinds of redirects which should be able to be cached by\n # default, even though Fastly doesn't currently have them in their default\n # list of cacheable status codes.\n if (http_status_matches(beresp.status, \"303,307,308\")) {\n set beresp.cacheable = true;\n }\n\n # For any 5xx status code we want to see if a stale object exists for it,\n # if so we'll go ahead and serve it.\n if (beresp.status >= 500 && beresp.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n # When delivering a 304 response, we don't always have access to all the\n # headers in the resp because a 304 response is supposed to remove most of\n # the headers. So we'll instead stash these headers on the request so that\n # we can log this data from there instead of from the response.\n if (beresp.http.x-amz-meta-project\n || beresp.http.x-amz-meta-version\n || beresp.http.x-amz-meta-package-type) {\n set req.http.Fastly-amz-meta-project = beresp.http.x-amz-meta-project;\n set req.http.Fastly-amz-meta-version = beresp.http.x-amz-meta-version;\n set req.http.Fastly-amz-meta-package-type = beresp.http.x-amz-meta-package-type;\n }\n\n\n#FASTLY fetch\n\n\n # Trigger a \"SSL is required\" error if the backend has indicated to do so.\n if (beresp.http.X-Fastly-Error == \"803\") {\n error 803 \"SSL is required\";\n }\n\n # If we've gotten a 502 or a 503 from the backend, we'll go ahead and retry\n # the request.\n if ((beresp.status == 502 || beresp.status == 503) &&\n req.restarts < 1 &&\n (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n # If we've restarted, then we'll record the number of restarts.\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n # If there is a Set-Cookie header, we'll ensure that we do not cache the\n # response.\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n # If the response has the private Cache-Control directive then we won't\n # cache it.\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # If we've gotten an error after the restarts we'll deliver the response\n # with a very short cache time.\n if (http_status_matches(beresp.status, \"500,502,503\")) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n # Apply a default TTL if there isn't a max-age or s-maxage.\n if (beresp.http.Expires ||\n beresp.http.Surrogate-Control ~ \"max-age\" ||\n beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # Keep the ttl here\n }\n else {\n # Apply the default ttl\n set beresp.ttl = 60s;\n }\n\n # Actually deliver the fetched response.\n return(deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n # If the object we have isn't cacheable, then just serve it directly\n # without going through any of the caching mechanisms.\n if (!obj.cacheable) {\n return(pass);\n }\n\n return(deliver);\n}\n\n\nsub vcl_deliver {\n # If this is an error and we have a stale response available, restart so\n # that we can pick it up and serve it.\n if (resp.status >= 500 && resp.status < 600) {\n if (stale.exists) {\n restart;\n }\n }\n\n#FASTLY deliver\n\n # Unset headers that we don't need\/want to send on to the client because\n # they are not generally useful.\n unset resp.http.Server;\n unset resp.http.Via;\n\n # Unset a few headers set by Amazon that we don't really have a need\/desire\n # to send to clients.\n unset resp.http.X-AMZ-Replication-Status;\n unset resp.http.X-AMZ-Meta-Python-Version;\n unset resp.http.X-AMZ-Meta-Version;\n unset resp.http.X-AMZ-Meta-Package-Type;\n unset resp.http.X-AMZ-Meta-Project;\n\n # Set our standard security headers, we do this in VCL rather than in\n # Warehouse itself so that we always get these headers, regardless of the\n # origin server being used.\n set resp.http.Strict-Transport-Security = \"max-age=31536000; includeSubDomains; preload\";\n set resp.http.X-Frame-Options = \"deny\";\n set resp.http.X-XSS-Protection = \"1; mode=block\";\n set resp.http.X-Content-Type-Options = \"nosniff\";\n set resp.http.X-Permitted-Cross-Domain-Policies = \"none\";\n\n # Unstash our information about what project\/version\/package-type a\n # particular file download was for.\n if (req.http.Fastly-amz-meta-project\n || req.http.Fastly-amz-meta-version\n || req.http.Fastly-amz-meta-package-type) {\n set resp.http.x-amz-meta-project = req.http.Fastly-amz-meta-project;\n set resp.http.x-amz-meta-version = req.http.Fastly-amz-meta-version;\n set resp.http.x-amz-meta-package-type = req.http.Fastly-amz-meta-package-type;\n }\n\n # If we're not executing a shielding request, and the URL is one of our file\n # URLs, and it's a GET request, and the response is either a 200 or a 304\n # then we want to log an event stating that a download has taken place.\n if (!req.http.Fastly-FF\n && std.tolower(req.http.host) == \"files.pythonhosted.org\"\n && req.url.path ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\"\n && req.request == \"GET\"\n && http_status_matches(resp.status, \"200,304\")) {\n log {\"syslog \"} req.service_id {\" linehaul :: \"} \"2@\" now \"|\" geoip.country_code \"|\" req.url.path \"|\" tls.client.protocol \"|\" tls.client.cipher \"|\" resp.http.x-amz-meta-project \"|\" resp.http.x-amz-meta-version \"|\" resp.http.x-amz-meta-package-type \"|\" req.http.user-agent;\n log {\"syslog \"} req.service_id {\" downloads :: \"} \"2@\" now \"|\" geoip.country_code \"|\" req.url.path \"|\" tls.client.protocol \"|\" tls.client.cipher \"|\" resp.http.x-amz-meta-project \"|\" resp.http.x-amz-meta-version \"|\" resp.http.x-amz-meta-package-type \"|\" req.http.user-agent;\n }\n\n return(deliver);\n}\n\n\nsub vcl_error {\n#FASTLY error\n\n # If we have a 5xx error and there is a stale object available, then we\n # will deliver that stale object.\n if (obj.status >= 500 && obj.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n if (obj.status == 803) {\n set obj.status = 403;\n set obj.response = \"SSL is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic {\"SSL is required.\"};\n return (deliver);\n } else if (obj.status == 750) {\n set obj.status = 301;\n set obj.http.Location = req.http.Location;\n set obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n synthetic {\"<html><head><title>301 Moved Permanently<\/title><\/head><body><center><h1>301 Moved Permanently<\/h1><\/center><\/body><\/html>\"};\n return(deliver);\n }\n\n}\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"cb8159d9a45534a14d8b70b7da61db0c4cc8df33","subject":"Update fastly.vcl","message":"Update fastly.vcl\n\nmagento suggests implementing this in nginx but it makes more sense to have it here and it won't interfere with the nginx rules, if both are used.","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/fastly.vcl","new_file":"etc\/fastly.vcl","new_contents":"###############################################################################\n#\n# Fastly CDN for Magento 2\n#\n# NOTICE OF LICENSE\n#\n# This source file is subject to the Fastly CDN for Magento 2 End User License\n# Agreement that is bundled with this package in the file LICENSE_FASTLY_CDN.txt.\n#\n# @copyright Copyright (c) 2016 Fastly, Inc. (http:\/\/www.fastly.com)\n# @license BSD, see LICENSE_FASTLY_CDN.txt\n#\n###############################################################################\n\n# This is a basic VCL configuration file for Fastly CDN for Magento 2 module.\n\nsub vcl_recv {\n#FASTLY recv\n\n if (req.url ~ \"^\/static\/version(\\d*\/)?(.*)$\") {\n set req.url = \"\/static\/\" + re.group.2 + \"?\" + re.group.1;\n } \n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n set req.http.X-Sig = regsub(req.http.X-Purge-Token, \"^[^_]+_(.*)\", \"\\1\");\n set req.http.X-Exp = regsub(req.http.X-Purge-Token, \"^([^_]+)_.*\", \"\\1\");\n\n # validate signature\n if (req.http.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path req.http.X-Exp), \"^0x\", \"\")) {\n\n # use vcl time math to check expiration timestamp\n set req.http.X-Original-Grace = req.grace;\n set req.grace = std.atoi(strftime({\"%s\"}, now));\n set req.grace -= std.atoi(req.http.X-Exp);\n\n if (std.atoi(req.grace) > 0) {\n error 410;\n }\n\n # clean up grace since we used it for time math\n set req.grace = std.atoi(req.http.X-Original-Grace);\n unset req.http.X-Original-Grace;\n\n } else {\n error 403;\n }\n\n # cleanup variables\n unset req.http.X-Purge-Token;\n unset req.http.X-Sig;\n unset req.http.X-Exp;\n }\n\n # Deactivate gzip\n set req.http.X-Orig-Accept-Encoding = req.http.Accept-Encoding;\n unset req.http.Accept-Encoding;\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n # disable ESI processing on Origin Shield\n if (req.http.Fastly-FF) {\n set req.esi = false;\n }\n\n # We only deal with GET and HEAD by default\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n return (pass);\n }\n\n # Bypass shopping cart and checkout requests\n if (req.url ~ \"\/checkout\") {\n return (pass);\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie ~ \"(X-Magento-Vary|form_key)=\") {\n error 200 \"\";\n } else {\n # append parameter with country code\n set req.url = req.url \"?country_code=\" geoip.country_code;\n }\n }\n\n return(lookup);\n}\n\nsub vcl_fetch {\n\n # Remove Set-Cookies from responses for static content\n # to match the cookie removal in recv.\n if (req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n }\n\n }\n\n#FASTLY fetch\n\n if (beresp.status >= 500) {\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n }\n\n if (req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Content-Type ~ \"text\/html\" || beresp.http.Content-Type ~ \"text\/xml\") {\n # enable ESI feature for Magento response by default\n esi;\n } else {\n # enable gzip for all static content\n if ((beresp.status == 200 || beresp.status == 404) && (beresp.http.content-type ~ \"^(text\\\/html|application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain|text\\\/xml)\\s*($|;)\" || req.url ~ \"\\.(css|js|html|eot|ico|otf|ttf|json)($|\\?)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.X-Orig-Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # cache only successfully responses and 404s\n if (beresp.status != 200 && beresp.status != 301 && beresp.status != 404) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\")) {\n unset beresp.http.set-cookie;\n if (req.url !~ \"^\/(pub\/)?(media|static)\/.*\") {\n set beresp.http.Pragma = \"no-cache\";\n set beresp.http.Expires = \"-1\";\n set beresp.http.Cache-Control = \"no-store, no-cache, must-revalidate, max-age=0\";\n set beresp.grace = 1m;\n }\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type\n if (beresp.http.Content-Type ~ \"image\") {\n set beresp.http.Surrogate-Key = \"image\";\n } elsif (beresp.http.Content-Type ~ \"script\") {\n set beresp.http.Surrogate-Key = \"script\";\n } elsif (beresp.http.Content-Type ~ \"css\") {\n set beresp.http.Surrogate-Key = \"css\";\n }\n\n set beresp.http.X-Surrogate-Key = beresp.http.Surrogate-Key;\n return (deliver);\n }\n\n return (deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\n\nsub vcl_miss {\n#FASTLY miss\n\n return(fetch);\n}\n\nsub vcl_deliver {\n # debug info\n if (resp.http.X-Magento-Debug) {\n if (obj.hits > 0) {\n set resp.http.X-Magento-Cache-Debug = \"HIT\";\n set resp.http.X-Magento-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Magento-Cache-Debug = \"MISS\";\n }\n } else {\n # remove Varnish\/proxy header\n remove resp.http.Age;\n remove resp.http.X-Magento-Debug;\n remove resp.http.X-Magento-Tags;\n remove resp.http.X-Surrogate-Key;\n remove resp.http.X-Magento-Cache-Control;\n remove resp.http.X-Powered-By;\n remove resp.http.Server;\n remove resp.http.X-Varnish;\n remove resp.http.Via;\n remove resp.http.Link;\n remove resp.http.X-Purge-URL;\n remove resp.http.X-Purge-Host;\n }\n\n#FASTLY deliver\n\n return (deliver);\n}\n\n\nsub vcl_error {\n # workaround for possible security issue\n if (req.url ~ \"^\\s\") {\n set obj.status = 400;\n set obj.response = \"Malformed request\";\n synthetic \"\";\n return (deliver);\n }\n\n # error 200\n if (obj.status == 200) {\n return (deliver);\n }\n\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} obj.status \" \" obj.response {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} obj.status \" \" obj.response {\"<\/h1>\n <p>\"} obj.response {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} req.xid {\"<\/p>\n <hr>\n <p>Fastly CDN server<\/p>\n <\/body>\n<\/html>\n\"};\n\n#FASTLY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n\nsub vcl_hash {\n set req.hash += req.http.Https;\n set req.hash += req.http.host;\n set req.hash += req.url;\n\n if (req.http.cookie ~ \"X-Magento-Vary=\") {\n set req.http.X-Magento-Vary = regsub(req.http.cookie, \"^.*?X-Magento-Vary=([^;]+);*.*$\", \"\\1\");\n set req.hash += req.http.X-Magento-Vary;\n unset req.http.X-Magento-Vary;\n }\n \n set req.hash += \"#####GENERATION#####\";\n\n ### {{ design_exceptions_code }} ###\n\n return (hash);\n}\n\n","old_contents":"###############################################################################\n#\n# Fastly CDN for Magento 2\n#\n# NOTICE OF LICENSE\n#\n# This source file is subject to the Fastly CDN for Magento 2 End User License\n# Agreement that is bundled with this package in the file LICENSE_FASTLY_CDN.txt.\n#\n# @copyright Copyright (c) 2016 Fastly, Inc. (http:\/\/www.fastly.com)\n# @license BSD, see LICENSE_FASTLY_CDN.txt\n#\n###############################################################################\n\n# This is a basic VCL configuration file for Fastly CDN for Magento 2 module.\n\nsub vcl_recv {\n#FASTLY recv\n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n set req.http.X-Sig = regsub(req.http.X-Purge-Token, \"^[^_]+_(.*)\", \"\\1\");\n set req.http.X-Exp = regsub(req.http.X-Purge-Token, \"^([^_]+)_.*\", \"\\1\");\n\n # validate signature\n if (req.http.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path req.http.X-Exp), \"^0x\", \"\")) {\n\n # use vcl time math to check expiration timestamp\n set req.http.X-Original-Grace = req.grace;\n set req.grace = std.atoi(strftime({\"%s\"}, now));\n set req.grace -= std.atoi(req.http.X-Exp);\n\n if (std.atoi(req.grace) > 0) {\n error 410;\n }\n\n # clean up grace since we used it for time math\n set req.grace = std.atoi(req.http.X-Original-Grace);\n unset req.http.X-Original-Grace;\n\n } else {\n error 403;\n }\n\n # cleanup variables\n unset req.http.X-Purge-Token;\n unset req.http.X-Sig;\n unset req.http.X-Exp;\n }\n\n # Deactivate gzip\n set req.http.X-Orig-Accept-Encoding = req.http.Accept-Encoding;\n unset req.http.Accept-Encoding;\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n # disable ESI processing on Origin Shield\n if (req.http.Fastly-FF) {\n set req.esi = false;\n }\n\n # We only deal with GET and HEAD by default\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n return (pass);\n }\n\n # Bypass shopping cart and checkout requests\n if (req.url ~ \"\/checkout\") {\n return (pass);\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie ~ \"(X-Magento-Vary|form_key)=\") {\n error 200 \"\";\n } else {\n # append parameter with country code\n set req.url = req.url \"?country_code=\" geoip.country_code;\n }\n }\n\n return(lookup);\n}\n\nsub vcl_fetch {\n\n # Remove Set-Cookies from responses for static content\n # to match the cookie removal in recv.\n if (req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n }\n\n }\n\n#FASTLY fetch\n\n if (beresp.status >= 500) {\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n }\n\n if (req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Content-Type ~ \"text\/html\" || beresp.http.Content-Type ~ \"text\/xml\") {\n # enable ESI feature for Magento response by default\n esi;\n } else {\n # enable gzip for all static content\n if ((beresp.status == 200 || beresp.status == 404) && (beresp.http.content-type ~ \"^(text\\\/html|application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain|text\\\/xml)\\s*($|;)\" || req.url ~ \"\\.(css|js|html|eot|ico|otf|ttf|json)($|\\?)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.X-Orig-Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # cache only successfully responses and 404s\n if (beresp.status != 200 && beresp.status != 301 && beresp.status != 404) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\")) {\n unset beresp.http.set-cookie;\n if (req.url !~ \"^\/(pub\/)?(media|static)\/.*\") {\n set beresp.http.Pragma = \"no-cache\";\n set beresp.http.Expires = \"-1\";\n set beresp.http.Cache-Control = \"no-store, no-cache, must-revalidate, max-age=0\";\n set beresp.grace = 1m;\n }\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type\n if (beresp.http.Content-Type ~ \"image\") {\n set beresp.http.Surrogate-Key = \"image\";\n } elsif (beresp.http.Content-Type ~ \"script\") {\n set beresp.http.Surrogate-Key = \"script\";\n } elsif (beresp.http.Content-Type ~ \"css\") {\n set beresp.http.Surrogate-Key = \"css\";\n }\n\n set beresp.http.X-Surrogate-Key = beresp.http.Surrogate-Key;\n return (deliver);\n }\n\n return (deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\n\nsub vcl_miss {\n#FASTLY miss\n\n return(fetch);\n}\n\nsub vcl_deliver {\n # debug info\n if (resp.http.X-Magento-Debug) {\n if (obj.hits > 0) {\n set resp.http.X-Magento-Cache-Debug = \"HIT\";\n set resp.http.X-Magento-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Magento-Cache-Debug = \"MISS\";\n }\n } else {\n # remove Varnish\/proxy header\n remove resp.http.Age;\n remove resp.http.X-Magento-Debug;\n remove resp.http.X-Magento-Tags;\n remove resp.http.X-Surrogate-Key;\n remove resp.http.X-Magento-Cache-Control;\n remove resp.http.X-Powered-By;\n remove resp.http.Server;\n remove resp.http.X-Varnish;\n remove resp.http.Via;\n remove resp.http.Link;\n remove resp.http.X-Purge-URL;\n remove resp.http.X-Purge-Host;\n }\n\n#FASTLY deliver\n\n return (deliver);\n}\n\n\nsub vcl_error {\n # workaround for possible security issue\n if (req.url ~ \"^\\s\") {\n set obj.status = 400;\n set obj.response = \"Malformed request\";\n synthetic \"\";\n return (deliver);\n }\n\n # error 200\n if (obj.status == 200) {\n return (deliver);\n }\n\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} obj.status \" \" obj.response {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} obj.status \" \" obj.response {\"<\/h1>\n <p>\"} obj.response {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} req.xid {\"<\/p>\n <hr>\n <p>Fastly CDN server<\/p>\n <\/body>\n<\/html>\n\"};\n\n#FASTLY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n\nsub vcl_hash {\n set req.hash += req.http.Https;\n set req.hash += req.http.host;\n set req.hash += req.url;\n\n if (req.http.cookie ~ \"X-Magento-Vary=\") {\n set req.http.X-Magento-Vary = regsub(req.http.cookie, \"^.*?X-Magento-Vary=([^;]+);*.*$\", \"\\1\");\n set req.hash += req.http.X-Magento-Vary;\n unset req.http.X-Magento-Vary;\n }\n \n set req.hash += \"#####GENERATION#####\";\n\n ### {{ design_exceptions_code }} ###\n\n return (hash);\n}\n\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"cabcda82382f70971ee801c24757c4610bf4e118","subject":"add include for default section features","message":"add include for default section features\n","repos":"xini\/silverstripe-section-io","old_file":"default.vcl","new_file":"default.vcl","new_contents":"# See the VCL chapters in the Users Guide at https:\/\/www.varnish-cache.org\/docs\/\n# and http:\/\/varnish-cache.org\/trac\/wiki\/VCLExamples for more examples.\n\n# Marker to tell the VCL compiler that this VCL has been adapted to the\n# new 4.0 format.\nvcl 4.0;\n\nbackend default {\n\t.host = \"next-hop\";\n\t.port = \"80\";\n}\n\ninclude \"section-features.vcl\";\n\n# The following VMODs are available for use if required:\n#import geoip; # see https:\/\/github.com\/varnish\/libvmod-geoip\n#import header; # see https:\/\/github.com\/varnish\/libvmod-header\n\nsub vcl_recv {\n\t# Happens before we check if we have this in cache already.\n\t#\n\t# Typically you clean up the request here, removing cookies you don't need,\n\t# rewriting the request, etc.\n\t\n\t# clean up accept-encoding\n\tif (req.http.Accept-Encoding) {\n\t\tif (req.http.Accept-Encoding ~ \"gzip\") {\n\t\t\tset req.http.Accept-Encoding = \"gzip\";\n\t\t} else if (req.http.Accept-Encoding ~ \"deflate\") {\n\t\t\tset req.http.Accept-Encoding = \"deflate\";\n\t\t} else {\n\t\t\tunset req.http.Accept-Encoding;\n\t\t}\n\t}\t\n\t\n\t# remove cookies for static content based on \/assets\/.htaccess\n\tif (req.url ~ \".*\\.(?:js|css|bmp|png|gif|jpg|jpeg|ico|pcx|tif|tiff|au|mid|midi|mpa|mp3|ogg|m4a|ra|wma|wav|cda|avi|mpg|mpeg|asf|wmv|m4v|mov|mkv|mp4|ogv|webm|swf|flv|ram|rm|doc|docx|txt|rtf|xls|xlsx|pages|ppt|pptx|pps|csv|cab|arj|tar|zip|zipx|sit|sitx|gz|tgz|bz2|ace|arc|pkg|dmg|hqx|jar|pdf|woff|eot|ttf|otf|svg)(?=\\?|&|$)\") {\n\t\tunset req.http.Cookie;\n\t\treturn (hash);\n\t}\n\t\n\t# ss admin\n\tif (req.url ~ \"^\/(Security|admin|dev)\" || req.url ~ \"stage=\") {\n\t\treturn (pass);\n\t}\n\t\n\t# ss multistep form\n\tif( req.url ~ \"MultiFormSessionID=\" ) {\n\t\treturn (pass);\n\t}\n\t\n\t# check for login cookie\n\tif ( req.http.Cookie ~ \"sslogin=\" ) {\n\t\treturn (pass);\n\t}\n\t\n\t# remove tracking cookies\n\tif (req.http.Cookie) {\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|(?<=; )) *__utm.=[^;]+;? *\", \"\\1\"); # standard ga cookies\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|;\\s*)(_dc_gtm_[A-Z0-9\\-]+)=[^;]*\", \"\"); # gtm cookies\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|;\\s*)(_ga)=[^;]*\", \"\"); # gtm ga cookies\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|;\\s*)(_gat)=[^;]*\", \"\"); # legacy ga cookies\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|;\\s*)(AUA[0-9]+)=[^;]*\", \"\"); # avanser phone tracking cookies\n\n\t\tif (req.http.Cookie == \"\") {\n\t\t\tunset req.http.Cookie;\n\t\t}\n\t}\n\t\n\t# remove adwords gclid parameter\n\tset req.url = regsuball(req.url,\"\\?gclid=[^&]+$\",\"\"); # strips when QS = \"?gclid=AAA\"\n\tset req.url = regsuball(req.url,\"\\?gclid=[^&]+&\",\"?\"); # strips when QS = \"?gclid=AAA&foo=bar\"\n\tset req.url = regsuball(req.url,\"&gclid=[^&]+\",\"\"); # strips when QS = \"?foo=bar&gclid=AAA\" or QS = \"?foo=bar&gclid=AAA&bar=baz\"\n\t\n}\n\nsub vcl_backend_fetch {\n\t# Called before sending the backend request.\n\t#\n\t# Typically you alter the request for the backend here. Overriding to the\n\t# required hostname, upstream Proto matching, etc\n\t\n}\n\nsub vcl_backend_response {\n\t# Happens after we have read the response headers from the backend.\n\t#\n\t# Here you clean the response headers, removing silly Set-Cookie headers\n\t# and other mistakes your backend does.\n\t\n\t# cache static content\n\t# css & js\n\tif (bereq.url ~ \".*\\.(?:css|js)(?=\\?|&|$)\") { \n\t\tset beresp.ttl = 604800s; # The number of seconds to cache inside Varnish: 1 week\n\t\tset beresp.http.Cache-Control = \"public, max-age=604800\"; # The number of seconds to cache in browser: 1 week\n\t}\n\t# images, audio, video\n\tif (bereq.url ~ \".*\\.(?:bmp|png|gif|jpg|jpeg|ico|pcx|tif|tiff|au|mid|midi|mpa|mp3|ogg|m4a|ra|wma|wav|cda|avi|mpg|mpeg|asf|wmv|m4v|mov|mkv|mp4|ogv|webm|swf|flv|ram|rm)(?=\\?|&|$)\") {\n\t\tset beresp.ttl = 2592000s; # The number of seconds to cache inside Varnish: 1 month\n\t\tset beresp.http.Cache-Control = \"public, max-age=2592000\"; # The number of seconds to cache in browser: 1 month\n\t}\n\t# docs and archives\n\tif (bereq.url ~ \".*\\.(?:doc|docx|txt|rtf|xls|xlsx|pages|ppt|pptx|pps|csv|cab|arj|tar|zip|zipx|sit|sitx|gz|tgz|bz2|ace|arc|pkg|dmg|hqx|jar|pdf)(?=\\?|&|$)\") {\n\t\tset beresp.ttl = 2592000s; # The number of seconds to cache inside Varnish: 1 month\n\t\tset beresp.http.Cache-Control = \"public, max-age=2592000\"; # The number of seconds to cache in browser: 1 month\n\t}\n\t# fonts\n\tif (bereq.url ~ \".*\\.(?:woff|eot|ttf|otf|svg)(?=\\?|&|$)\") {\n\t\tset beresp.ttl = 2592000s; # The number of seconds to cache inside Varnish: 1 month\n\t\tset beresp.http.Cache-Control = \"public, max-age=2592000\"; # The number of seconds to cache in browser: 1 month\n\t}\n\t\n\t# set cache control header for pages\n if (beresp.http.Content-Type ~ \"^text\/html\" && !(bereq.url ~ \"^\/(Security|admin|dev)\") && !(bereq.http.Cookie ~ \"sslogin=\") && !(beresp.http.Pragma ~ \"no-cache\") ) {\n\t\t set beresp.ttl = 3600s;\n\t\t set beresp.http.Cache-Control = \"public, max-age=600\";\n }\n\t\n\t# set grace period\n\tset beresp.grace = 1d;\n\t\n\t### DO NOT CHANGE ###\n\t# store url in cached object to use in ban()\n\tset beresp.http.x-url = bereq.url;\n\t\n}\n\nsub vcl_deliver {\n\t# Happens when we have all the pieces we need, and are about to send the\n\t# response to the client.\n\t#\n\t# You can do accounting or modifying the final object here.\n\t\n\t# add cache response header\n\tif (obj.hits > 0) {\n\t\tset resp.http.X-Cache = \"HIT\";\n\t} else {\n\t\tset resp.http.X-Cache = \"MISS\";\n\t}\n\t\n\t### DO NOT CHANGE ###\n\t# remove saved url from object before delivery\n\tunset resp.http.x-url;\n\t\n}\n\nsub vcl_hit {\n\t# deliver if ttl > 0, normal hit\n\tif (obj.ttl >= 0s) {\n\t\treturn (deliver);\n\t}\n\t# deliver if ttl = 0 but grace still on\n\tif (obj.ttl + obj.grace > 0s) {\n\t\treturn (deliver);\n\t}\n\t# fetch new content\n\treturn (fetch);\n}","old_contents":"# See the VCL chapters in the Users Guide at https:\/\/www.varnish-cache.org\/docs\/\n# and http:\/\/varnish-cache.org\/trac\/wiki\/VCLExamples for more examples.\n\n# Marker to tell the VCL compiler that this VCL has been adapted to the\n# new 4.0 format.\nvcl 4.0;\n\nbackend default {\n\t.host = \"next-hop\";\n\t.port = \"80\";\n}\n\nsub vcl_recv {\n\t# Happens before we check if we have this in cache already.\n\t#\n\t# Typically you clean up the request here, removing cookies you don't need,\n\t# rewriting the request, etc.\n\t\n\t# clean up accept-encoding\n\tif (req.http.Accept-Encoding) {\n\t\tif (req.http.Accept-Encoding ~ \"gzip\") {\n\t\t\tset req.http.Accept-Encoding = \"gzip\";\n\t\t} else if (req.http.Accept-Encoding ~ \"deflate\") {\n\t\t\tset req.http.Accept-Encoding = \"deflate\";\n\t\t} else {\n\t\t\tunset req.http.Accept-Encoding;\n\t\t}\n\t}\t\n\t\n\t# remove cookies for static content based on \/assets\/.htaccess\n\tif (req.url ~ \".*\\.(?:js|css|bmp|png|gif|jpg|jpeg|ico|pcx|tif|tiff|au|mid|midi|mpa|mp3|ogg|m4a|ra|wma|wav|cda|avi|mpg|mpeg|asf|wmv|m4v|mov|mkv|mp4|ogv|webm|swf|flv|ram|rm|doc|docx|txt|rtf|xls|xlsx|pages|ppt|pptx|pps|csv|cab|arj|tar|zip|zipx|sit|sitx|gz|tgz|bz2|ace|arc|pkg|dmg|hqx|jar|pdf|woff|eot|ttf|otf|svg)(?=\\?|&|$)\") {\n\t\tunset req.http.Cookie;\n\t\treturn (hash);\n\t}\n\t\n\t# ss admin\n\tif (req.url ~ \"^\/(Security|admin|dev)\" || req.url ~ \"stage=\") {\n\t\treturn (pass);\n\t}\n\t\n\t# ss multistep form\n\tif( req.url ~ \"MultiFormSessionID=\" ) {\n\t\treturn (pass);\n\t}\n\t\n\t# check for login cookie\n\tif ( req.http.Cookie ~ \"sslogin=\" ) {\n\t\treturn (pass);\n\t}\n\t\n\t# remove tracking cookies\n\tif (req.http.Cookie) {\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|(?<=; )) *__utm.=[^;]+;? *\", \"\\1\"); # standard ga cookies\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|;\\s*)(_dc_gtm_[A-Z0-9\\-]+)=[^;]*\", \"\"); # gtm cookies\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|;\\s*)(_ga)=[^;]*\", \"\"); # gtm ga cookies\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|;\\s*)(_gat)=[^;]*\", \"\"); # legacy ga cookies\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|;\\s*)(AUA[0-9]+)=[^;]*\", \"\"); # avanser phone tracking cookies\n\n\t\tif (req.http.Cookie == \"\") {\n\t\t\tunset req.http.Cookie;\n\t\t}\n\t}\n\t\n\t# remove adwords gclid parameter\n\tset req.url = regsuball(req.url,\"\\?gclid=[^&]+$\",\"\"); # strips when QS = \"?gclid=AAA\"\n\tset req.url = regsuball(req.url,\"\\?gclid=[^&]+&\",\"?\"); # strips when QS = \"?gclid=AAA&foo=bar\"\n\tset req.url = regsuball(req.url,\"&gclid=[^&]+\",\"\"); # strips when QS = \"?foo=bar&gclid=AAA\" or QS = \"?foo=bar&gclid=AAA&bar=baz\"\n\t\n}\n\nsub vcl_backend_fetch {\n\t# Called before sending the backend request.\n\t#\n\t# Typically you alter the request for the backend here. Overriding to the\n\t# required hostname, upstream Proto matching, etc\n\t\n}\n\nsub vcl_backend_response {\n\t# Happens after we have read the response headers from the backend.\n\t#\n\t# Here you clean the response headers, removing silly Set-Cookie headers\n\t# and other mistakes your backend does.\n\t\n\t# cache static content\n\t# css & js\n\tif (bereq.url ~ \".*\\.(?:css|js)(?=\\?|&|$)\") { \n\t\tset beresp.ttl = 604800s; # The number of seconds to cache inside Varnish: 1 week\n\t\tset beresp.http.Cache-Control = \"public, max-age=604800\"; # The number of seconds to cache in browser: 1 week\n\t}\n\t# images, audio, video\n\tif (bereq.url ~ \".*\\.(?:bmp|png|gif|jpg|jpeg|ico|pcx|tif|tiff|au|mid|midi|mpa|mp3|ogg|m4a|ra|wma|wav|cda|avi|mpg|mpeg|asf|wmv|m4v|mov|mkv|mp4|ogv|webm|swf|flv|ram|rm)(?=\\?|&|$)\") {\n\t\tset beresp.ttl = 2592000s; # The number of seconds to cache inside Varnish: 1 month\n\t\tset beresp.http.Cache-Control = \"public, max-age=2592000\"; # The number of seconds to cache in browser: 1 month\n\t}\n\t# docs and archives\n\tif (bereq.url ~ \".*\\.(?:doc|docx|txt|rtf|xls|xlsx|pages|ppt|pptx|pps|csv|cab|arj|tar|zip|zipx|sit|sitx|gz|tgz|bz2|ace|arc|pkg|dmg|hqx|jar|pdf)(?=\\?|&|$)\") {\n\t\tset beresp.ttl = 2592000s; # The number of seconds to cache inside Varnish: 1 month\n\t\tset beresp.http.Cache-Control = \"public, max-age=2592000\"; # The number of seconds to cache in browser: 1 month\n\t}\n\t# fonts\n\tif (bereq.url ~ \".*\\.(?:woff|eot|ttf|otf|svg)(?=\\?|&|$)\") {\n\t\tset beresp.ttl = 2592000s; # The number of seconds to cache inside Varnish: 1 month\n\t\tset beresp.http.Cache-Control = \"public, max-age=2592000\"; # The number of seconds to cache in browser: 1 month\n\t}\n\t\n\t# set cache control header for pages\n if (beresp.http.Content-Type ~ \"^text\/html\" && !(bereq.url ~ \"^\/(Security|admin|dev)\") && !(bereq.http.Cookie ~ \"sslogin=\") && !(beresp.http.Pragma ~ \"no-cache\") ) {\n\t\t set beresp.ttl = 3600s;\n\t\t set beresp.http.Cache-Control = \"public, max-age=600\";\n }\n\t\n\t# set grace period\n\tset beresp.grace = 1d;\n\t\n\t### DO NOT CHANGE ###\n\t# store url in cached object to use in ban()\n\tset beresp.http.x-url = bereq.url;\n\t\n}\n\nsub vcl_deliver {\n\t# Happens when we have all the pieces we need, and are about to send the\n\t# response to the client.\n\t#\n\t# You can do accounting or modifying the final object here.\n\t\n\t# add cache response header\n\tif (obj.hits > 0) {\n\t\tset resp.http.X-Cache = \"HIT\";\n\t} else {\n\t\tset resp.http.X-Cache = \"MISS\";\n\t}\n\t\n\t### DO NOT CHANGE ###\n\t# remove saved url from object before delivery\n\tunset resp.http.x-url;\n\t\n}\n\nsub vcl_hit {\n\t# deliver if ttl > 0, normal hit\n\tif (obj.ttl >= 0s) {\n\t\treturn (deliver);\n\t}\n\t# deliver if ttl = 0 but grace still on\n\tif (obj.ttl + obj.grace > 0s) {\n\t\treturn (deliver);\n\t}\n\t# fetch new content\n\treturn (fetch);\n}","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"58b6b69c271e76df3dade05a31f7b798301999dd","subject":"Revert \"Add special-case redirects for old URL scheme\"","message":"Revert \"Add special-case redirects for old URL scheme\"\n\nThis reverts commit 9b6eb3ad93ef924f7724df66351a91bcedf49baa.\n","repos":"adzerk-oss\/docker-s3-cache,adzerk-oss\/docker-s3-cache","old_file":"default.vcl","new_file":"default.vcl","new_contents":"# This is a VCL configuration file for varnish. See the vcl(7)\n# man page for details on VCL syntax and semantics.\n#\nbackend default {\n .host = \"${VARNISH_BACKEND_IP}\";\n .port = \"${VARNISH_BACKEND_PORT}\";\n}\n\nsub vcl_recv {\n set req.http.host = \"${VARNISH_BACKEND_HOST}\";\n}\n\nsub vcl_fetch {\n if (beresp.status == 302) {\n set beresp.status = 301;\n set beresp.response = \"Moved Permanently\";\n }\n}\n","old_contents":"# This is a VCL configuration file for varnish. See the vcl(7)\n# man page for details on VCL syntax and semantics.\n#\nbackend default {\n .host = \"${VARNISH_BACKEND_IP}\";\n .port = \"${VARNISH_BACKEND_PORT}\";\n}\n\nsub vcl_recv {\n set req.http.host = \"${VARNISH_BACKEND_HOST}\";\n\n if (req.url ~ \"^\/ad-server-privacy\/*$\") {\n error 750 \"\/privacy\/ad-server\/\";\n }\n if (req.url ~ \"^\/customer-privacy\/*$\") {\n error 750 \"\/privacy\/customers\/\";\n }\n if (req.url ~ \"^\/sales\/*$\") {\n error 750 \"\/contact\/\";\n }\n if (req.url ~ \"^\/ad-server-jobs\/*$\") {\n error 750 \"\/about\/\";\n }\n if (req.url ~ \"^\/features\/*$\") {\n error 750 \"\/solutions\/\";\n }\n if (req.url ~ \"^\/ad-server-resources\/*$\") {\n error 750 \"\/\";\n }\n if (req.url ~ \"^\/support\/*$\") {\n error 750 \"\/help\/\";\n }\n if (req.url ~ \"^\/customers\/ad-server-for-publishers\/*$\") {\n error 750 \"\/solutions\/\";\n }\n if (req.url ~ \"^\/ad-serving-resource-center\/*$\") {\n error 750 \"\/\";\n }\n if (req.url ~ \"^\/customers\/ad-server-developer-api\/*$\") {\n error 750 \"\/solutions\/\";\n }\n if (req.url ~ \"^\/blog\/2014\/10\/using-advertisting-to-monetize-a-social-media-community\/*$\") {\n error 750 \"\/blog\/2014\/10\/using-advertising-to-monetize-a-social-media-community\/\";\n }\n if (req.url ~ \"^\/news-and-announcements\/reddit-is-using-adzerk\/*$\") {\n error 750 \"\/blog\/2013\/03\/reddit-is-using-adzerk\/\";\n }\n if (req.url ~ \"^\/job-openings\/*$\") {\n error 750 \"\/about\/\";\n }\n if (req.url ~ \"^\/for-publishers\/*$\") {\n error 750 \"\/solutions\/\";\n }\n if (req.url ~ \"^\/product-blog\/the-fastest-ad-code-in-the-world\/\/*$\") {\n error 750 \"\/blog\/2012\/06\/the-fastest-ad-code-in-the-world\/\";\n }\n if (req.url ~ \"^\/our-team\/*$\") {\n error 750 \"\/about\/\";\n }\n if (req.url ~ \"^\/product-tour\/*$\") {\n error 750 \"\/learn\/\";\n }\n}\n\nsub vcl_error {\n if (obj.status == 750) {\n set obj.http.Location = obj.response;\n set obj.status = 301;\n return(deliver);\n }\n}\n\nsub vcl_fetch {\n if (beresp.status == 302) {\n set beresp.status = 301;\n set beresp.response = \"Moved Permanently\";\n }\n}\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"47807a664c56b8fd56f11c6c90f94a58592864bd","subject":"use regex for URIBAN and PURGE to have greater flexibility","message":"use regex for URIBAN and PURGE to have greater flexibility\n","repos":"amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon","old_file":"images\/varnish-drupal\/drupal.vcl","new_file":"images\/varnish-drupal\/drupal.vcl","new_contents":"vcl 4.0;\n\nimport std;\n\n# set backend default\nbackend default {\n .host = \"${VARNISH_BACKEND_HOST:-nginx}\";\n .port = \"${VARNISH_BACKEND_PORT:-8080}\";\n .first_byte_timeout = 35m;\n .between_bytes_timeout = 10m;\n}\n\n# Allow purging from localhost\n# @TODO allow from openshift network\nacl purge {\n \"127.0.0.1\";\n \"10.0.0.0\"\/8;\n \"172.16.0.0\"\/12;\n \"192.168.0.0\"\/16;\n}\n\n# This configuration is optimized for Drupal hosting:\n# Respond to incoming requests.\nsub vcl_recv {\n if (req.url ~ \"^\/varnish_status$\") {\n return (synth(200,\"OK\"));\n }\n # set the backend, which should be used:\n set req.backend_hint = default;\n\n # Always set the forward ip.\n if (req.restarts == 0) {\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n\n\n if (req.http.X-LAGOON-VARNISH ) {\n ## Pass all Requests which are handled via an upstream Varnish\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, \" + req.http.X-LAGOON-VARNISH;\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n } else if (req.http.Fastly-FF) {\n ## Pass all Requests which are handled via Fastly\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, fastly\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n set req.http.X-Forwarded-For = req.http.Fastly-Client-IP;\n } else if (req.http.CF-RAY) {\n ## Pass all Requests which are handled via CloudFlare\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, cloudflare\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n set req.http.X-Forwarded-For = req.http.CF-Connecting-IP;\n } else if (req.http.X-Pull) {\n ## Pass all Requests which are handled via KeyCDN\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, keycdn\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n } else {\n ## We set a header to let a Varnish Chain know that it already has been varnishcached\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}\";\n\n ## Allow to bypass based on env variable `VARNISH_BYPASS`\n set req.http.X-LAGOON-VARNISH-BYPASS = \"${VARNISH_BYPASS:-false}\";\n }\n\n # Websockets are piped\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n if (req.http.X-LAGOON-VARNISH-BYPASS == \"true\" || req.http.X-LAGOON-VARNISH-BYPASS == \"TRUE\") {\n return (pass);\n }\n\n # SA-CORE-2014-004 preventing access to \/xmlrpc.php\n if (req.url ~ \"^\/xmlrpc.php$\") {\n return (synth(701, \"Unauthorized\"));\n }\n\n # Strip out Google Analytics campaign variables. They are only needed\n # by the javascript running on the page\n # utm_source, utm_medium, utm_campaign, gclid\n if(req.url ~ \"(\\?|&)(gclid|utm_[a-z]+)=\") {\n set req.url = regsuball(req.url, \"(gclid|utm_[a-z]+)=[^\\&]+&?\", \"\");\n set req.url = regsub(req.url, \"(\\?|&)$\", \"\");\n }\n\n # Bypass a cache hit (the request is still sent to the backend)\n if (req.method == \"REFRESH\") {\n if (!client.ip ~ purge) { return (synth(405, \"Not allowed\")); }\n set req.method = \"GET\";\n set req.hash_always_miss = true;\n }\n\n # Only allow BAN requests from IP addresses in the 'purge' ACL.\n if (req.method == \"BAN\" || req.method == \"URIBAN\" || req.method == \"PURGE\") {\n # Only allow BAN from defined ACL\n if (!client.ip ~ purge) {\n return (synth(403, \"Your IP is not allowed.\"));\n }\n\n # Only allows BAN if the Host Header has the style of with \"${SERVICE_NAME:-varnish}:8080\" or \"${SERVICE_NAME:-varnish}\".\n # Such a request is only possible from within the Docker network, as a request from external goes trough the Kubernetes Router and for that needs a proper Host Header\n if (!req.http.host ~ \"^${SERVICE_NAME:-varnish}(:\\d+)?$\") {\n return (synth(403, \"Only allowed from within own network.\"));\n }\n\n if (req.method == \"BAN\") {\n # Logic for the ban, using the Cache-Tags header.\n if (req.http.Cache-Tags) {\n ban(\"obj.http.Cache-Tags ~ \" + req.http.Cache-Tags);\n # Throw a synthetic page so the request won't go to the backend.\n return (synth(200, \"Ban added.\"));\n }\n else {\n return (synth(403, \"Cache-Tags header missing.\"));\n }\n }\n\n if (req.method == \"URIBAN\" || req.method == \"PURGE\") {\n ban(\"req.url ~ \" + req.url);\n # Throw a synthetic page so the request won't go to the backend.\n return (synth(200, \"Ban added.\"));\n }\n\n }\n\n # Non-RFC2616 or CONNECT which is weird, we pipe that\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n return (pipe);\n }\n\n # We only try to cache GET and HEAD, other things are passed\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n # Any requests with Basic Auth are passed\n if (req.http.Authorization || req.http.Authenticate)\n {\n return (pass);\n }\n\n ## Pass requests which are from blackfire\n if (req.http.X-Blackfire-Query) {\n return (pass);\n }\n\n # Some URLs should never be cached\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/admin([\/?]|$).*$\" ||\n req.url ~ \"^\/info([\/?]|$).*$\" ||\n req.url ~ \"^\/flag([\/?]|$).*$\" ||\n req.url ~ \"^.*\/system\/files([\/?]|$).*$\" ||\n req.url ~ \"^\/cgi\" ||\n req.url ~ \"^\/cgi-bin\"\n ) {\n return (pass);\n }\n\n # Plupload likes to get piped\n if (req.url ~ \"^.*\/plupload-handle-uploads.*$\"\n ) {\n return (pipe);\n }\n\n # Handle compression correctly. Different browsers send different\n # \"Accept-Encoding\" headers, even though they mostly all support the same\n # compression mechanisms. By consolidating these compression headers into\n # a consistent format, we can reduce the size of the cache and get more hits.=\n # @see: http:\/\/ varnish.projects.linpro.no\/wiki\/FAQ\/Compression\n if (req.http.Accept-Encoding) {\n if (req.http.Accept-Encoding ~ \"gzip\") {\n # If the browser supports it, we'll use gzip.\n set req.http.Accept-Encoding = \"gzip\";\n }\n else if (req.http.Accept-Encoding ~ \"deflate\") {\n # Next, try deflate if it is supported.\n set req.http.Accept-Encoding = \"deflate\";\n }\n else {\n # Unknown algorithm. Remove it and send unencoded.\n unset req.http.Accept-Encoding;\n }\n }\n\n # Always cache the following file types for all users.\n if (req.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n unset req.http.Cookie;\n }\n\n # Remove all cookies that Drupal doesn't need to know about. ANY remaining\n # cookie will cause the request to pass-through to a backend. For the most part\n # we always set the NO_CACHE cookie after any POST request, disabling the\n # Varnish cache temporarily. The session cookie allows all authenticated users\n # to pass through as long as they're logged in.\n #\n # 1. Append a semi-colon to the front of the cookie string.\n # 2. Remove all spaces that appear after semi-colons.\n # 3. Match the cookies we want to keep, adding the space we removed\n # previously, back. (\\1) is first matching group in the regsuball.\n # 4. Remove all other cookies, identifying them by the fact that they have\n # no space after the preceding semi-colon.\n # 5. Remove all spaces and semi-colons from the beginning and end of the\n # cookie string.\n if (req.http.Cookie) {\n set req.http.CookieCheck = \";\" + req.http.Cookie;\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"; +\", \";\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";(${VARNISH_COOKIECHECK:-SESS[a-z0-9]+|SSESS[a-z0-9]+|NO_CACHE})=\", \"; \\1=\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";[^ ][^;]*\", \"\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"^[; ]+|[; ]+$\", \"\");\n\n set req.http.Cookie = req.http.Cookie + \";\";\n\n if (req.http.CookieCheck == \"\") {\n # If there are no remaining cookies, remove the cookie header. If there\n # aren't any cookie headers, Varnish's default behavior will be to cache\n # the page.\n\n unset req.http.CookieCheck;\n unset req.http.Cookie;\n }\n else {\n # If there is any cookies left (a session or NO_CACHE cookie), do not\n # cache the page. Pass it on to Apache directly.\n unset req.http.CookieCheck;\n return (pass);\n }\n }\n\n # Cacheable, lookup in cache.\n return (hash);\n}\n\nsub vcl_pipe {\n # Support for Websockets\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n set bereq.http.connection = req.http.connection;\n }\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n # normal hit\n return (deliver);\n }\n # We have no fresh fish. Lets look at the stale ones.\n if (std.healthy(req.backend_hint)) {\n # Backend is healthy. If the object is not older then 30secs, deliver it to the client\n # and automatically create a separate backend request to warm the cache for this request.\n if (obj.ttl + 30s > 0s) {\n set req.http.grace = \"normal(limited)\";\n return (deliver);\n } else {\n # No candidate for grace. Fetch a fresh object.\n return(miss);\n }\n } else {\n # backend is sick - use full grace\n if (obj.ttl + obj.grace > 0s) {\n set req.http.grace = \"full\";\n return (deliver);\n } else {\n # no graced object.\n return (miss);\n }\n }\n}\n\nsub vcl_backend_response {\n # Allow items to be stale if needed.\n set beresp.grace = 6h;\n\n # Set ban-lurker friendly custom headers.\n set beresp.http.X-Url = bereq.url;\n set beresp.http.X-Host = bereq.http.host;\n\n # If the backend sends a X-LAGOON-VARNISH-BACKEND-BYPASS header we directly deliver\n if(beresp.http.X-LAGOON-VARNISH-BACKEND-BYPASS == \"TRUE\") {\n return (deliver);\n }\n\n # Cache 404 and 403 for 10 seconds\n if(beresp.status == 404 || beresp.status == 403) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n # Don't allow static files to set cookies.\n if (bereq.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n # beresp == Back-end response from the web server.\n unset beresp.http.set-cookie;\n unset beresp.http.Cache-Control;\n\n # If an asset would come back with statuscode 500 we only cache it for 10 seconds instead of the usual static file cache\n if (beresp.status == 500) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n set beresp.ttl = ${VARNISH_ASSETS_TTL:-2628001}s;\n set beresp.http.Cache-Control = \"public, max-age=${VARNISH_ASSETS_TTL:-2628001}\";\n set beresp.http.Expires = \"\" + (now + beresp.ttl);\n }\n\n return (deliver);\n}\n\n# Set a header to track a cache HIT\/MISS.\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Varnish-Cache = \"HIT\";\n }\n else {\n set resp.http.X-Varnish-Cache = \"MISS\";\n }\n\n # Remove ban-lurker friendly custom headers when delivering to client.\n unset resp.http.X-Url;\n unset resp.http.X-Host;\n\n # unset Cache-Tags Header by default, can be disabled with VARNISH_UNSET_HEADER_CACHE_TAGS=true\n if (!${VARNISH_UNSET_HEADER_CACHE_TAGS:-false}) {\n unset resp.http.Cache-Tags;\n }\n\n unset resp.http.X-Generator;\n unset resp.http.Server;\n # Inject information about grace\n if (req.http.grace) {\n set resp.http.X-Varnish-Grace = req.http.grace;\n }\n set resp.http.X-LAGOON = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}>\" + resp.http.X-LAGOON;\n return (deliver);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n if (req.http.X-Forwarded-Proto) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n if (req.http.HTTPS) {\n hash_data(req.http.HTTPS);\n }\n return (lookup);\n}\n\nsub vcl_synth {\n if (resp.status == 701) {\n set resp.status = 401;\n set resp.http.Content-Type = \"text\/plain; charset=utf-8\";\n synthetic({\"XMLRPC Interface is blocked due to SA-CORE-2014-004 - mail support@amazee.io if you need it.\"});\n return (deliver);\n }\n if (resp.status == 700) {\n # Set a status the client will understand\n set resp.status = 200;\n # Create our synthetic response\n synthetic(\"\");\n return(deliver);\n}\n return (deliver);\n}\n\nsub vcl_backend_error {\n # Restart the request, when we have a backend server error, to try another backend.\n # Restart max twice.\n if (bereq.retries < 2) {\n return(retry);\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<head>\n <title>Server Error<\/title>\n <style type=\"text\/css\">\n body {\n font-family: helvetica, arial, sans-serif;\n }\n img {\n margin-top: 50px;\n }\n p {\n width: 6 00px;\n margin-top: 10px\n }\n div {\n background: #ccc;\n width: 600px;\n margin: auto;\n padding: 50px;\n }\n span {\n color: #ccc\n }\n <\/style>\n<\/head>\n<body>\n <div>\n <h1>We are sorry...<\/h1>\n <p>We encountered a server-side error. This means that the problem is not with your computer or Internet connection, but rather with the website's server.<\/p>\n <p>We are currently working on solving this problem and apologise for the inconvenience.<\/p>\n <span>\n <strong>Technical Information<\/strong><br \/>\n Error \"} + beresp.status + \" \" + beresp.reason + {\"<br \/>\n XID: \"} + bereq.xid + {\"<br \/>\n <\/span>\n <\/div>\n<\/body>\n<\/html>\n\n\"} );\n return (deliver);\n}\n","old_contents":"vcl 4.0;\n\nimport std;\n\n# set backend default\nbackend default {\n .host = \"${VARNISH_BACKEND_HOST:-nginx}\";\n .port = \"${VARNISH_BACKEND_PORT:-8080}\";\n .first_byte_timeout = 35m;\n .between_bytes_timeout = 10m;\n}\n\n# Allow purging from localhost\n# @TODO allow from openshift network\nacl purge {\n \"127.0.0.1\";\n \"10.0.0.0\"\/8;\n \"172.16.0.0\"\/12;\n \"192.168.0.0\"\/16;\n}\n\n# This configuration is optimized for Drupal hosting:\n# Respond to incoming requests.\nsub vcl_recv {\n if (req.url ~ \"^\/varnish_status$\") {\n return (synth(200,\"OK\"));\n }\n # set the backend, which should be used:\n set req.backend_hint = default;\n\n # Always set the forward ip.\n if (req.restarts == 0) {\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n\n\n if (req.http.X-LAGOON-VARNISH ) {\n ## Pass all Requests which are handled via an upstream Varnish\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, \" + req.http.X-LAGOON-VARNISH;\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n } else if (req.http.Fastly-FF) {\n ## Pass all Requests which are handled via Fastly\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, fastly\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n set req.http.X-Forwarded-For = req.http.Fastly-Client-IP;\n } else if (req.http.CF-RAY) {\n ## Pass all Requests which are handled via CloudFlare\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, cloudflare\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n set req.http.X-Forwarded-For = req.http.CF-Connecting-IP;\n } else if (req.http.X-Pull) {\n ## Pass all Requests which are handled via KeyCDN\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, keycdn\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n } else {\n ## We set a header to let a Varnish Chain know that it already has been varnishcached\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}\";\n\n ## Allow to bypass based on env variable `VARNISH_BYPASS`\n set req.http.X-LAGOON-VARNISH-BYPASS = \"${VARNISH_BYPASS:-false}\";\n }\n\n # Websockets are piped\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n if (req.http.X-LAGOON-VARNISH-BYPASS == \"true\" || req.http.X-LAGOON-VARNISH-BYPASS == \"TRUE\") {\n return (pass);\n }\n\n # SA-CORE-2014-004 preventing access to \/xmlrpc.php\n if (req.url ~ \"^\/xmlrpc.php$\") {\n return (synth(701, \"Unauthorized\"));\n }\n\n # Strip out Google Analytics campaign variables. They are only needed\n # by the javascript running on the page\n # utm_source, utm_medium, utm_campaign, gclid\n if(req.url ~ \"(\\?|&)(gclid|utm_[a-z]+)=\") {\n set req.url = regsuball(req.url, \"(gclid|utm_[a-z]+)=[^\\&]+&?\", \"\");\n set req.url = regsub(req.url, \"(\\?|&)$\", \"\");\n }\n\n # Bypass a cache hit (the request is still sent to the backend)\n if (req.method == \"REFRESH\") {\n if (!client.ip ~ purge) { return (synth(405, \"Not allowed\")); }\n set req.method = \"GET\";\n set req.hash_always_miss = true;\n }\n\n # Only allow BAN requests from IP addresses in the 'purge' ACL.\n if (req.method == \"BAN\" || req.method == \"URIBAN\" || req.method == \"PURGE\") {\n # Only allow BAN from defined ACL\n if (!client.ip ~ purge) {\n return (synth(403, \"Your IP is not allowed.\"));\n }\n\n # Only allows BAN if the Host Header has the style of with \"${SERVICE_NAME:-varnish}:8080\" or \"${SERVICE_NAME:-varnish}\".\n # Such a request is only possible from within the Docker network, as a request from external goes trough the Kubernetes Router and for that needs a proper Host Header\n if (!req.http.host ~ \"^${SERVICE_NAME:-varnish}(:\\d+)?$\") {\n return (synth(403, \"BAN only allowed from within own network.\"));\n }\n\n if (req.method == \"BAN\") {\n # Logic for the ban, using the Cache-Tags header.\n if (req.http.Cache-Tags) {\n ban(\"obj.http.Cache-Tags ~ \" + req.http.Cache-Tags);\n # Throw a synthetic page so the request won't go to the backend.\n return (synth(200, \"Ban added.\"));\n }\n else {\n return (synth(403, \"Cache-Tags header missing.\"));\n }\n }\n\n if (req.method == \"URIBAN\" || req.method == \"PURGE\") {\n ban(\"req.url == \" + req.url);\n # Throw a synthetic page so the request won't go to the backend.\n return (synth(200, \"Ban added.\"));\n }\n\n }\n\n # Non-RFC2616 or CONNECT which is weird, we pipe that\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n return (pipe);\n }\n\n # We only try to cache GET and HEAD, other things are passed\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n # Any requests with Basic Auth are passed\n if (req.http.Authorization || req.http.Authenticate)\n {\n return (pass);\n }\n\n ## Pass requests which are from blackfire\n if (req.http.X-Blackfire-Query) {\n return (pass);\n }\n\n # Some URLs should never be cached\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/admin([\/?]|$).*$\" ||\n req.url ~ \"^\/info([\/?]|$).*$\" ||\n req.url ~ \"^\/flag([\/?]|$).*$\" ||\n req.url ~ \"^.*\/system\/files([\/?]|$).*$\" ||\n req.url ~ \"^\/cgi\" ||\n req.url ~ \"^\/cgi-bin\"\n ) {\n return (pass);\n }\n\n # Plupload likes to get piped\n if (req.url ~ \"^.*\/plupload-handle-uploads.*$\"\n ) {\n return (pipe);\n }\n\n # Handle compression correctly. Different browsers send different\n # \"Accept-Encoding\" headers, even though they mostly all support the same\n # compression mechanisms. By consolidating these compression headers into\n # a consistent format, we can reduce the size of the cache and get more hits.=\n # @see: http:\/\/ varnish.projects.linpro.no\/wiki\/FAQ\/Compression\n if (req.http.Accept-Encoding) {\n if (req.http.Accept-Encoding ~ \"gzip\") {\n # If the browser supports it, we'll use gzip.\n set req.http.Accept-Encoding = \"gzip\";\n }\n else if (req.http.Accept-Encoding ~ \"deflate\") {\n # Next, try deflate if it is supported.\n set req.http.Accept-Encoding = \"deflate\";\n }\n else {\n # Unknown algorithm. Remove it and send unencoded.\n unset req.http.Accept-Encoding;\n }\n }\n\n # Always cache the following file types for all users.\n if (req.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n unset req.http.Cookie;\n }\n\n # Remove all cookies that Drupal doesn't need to know about. ANY remaining\n # cookie will cause the request to pass-through to a backend. For the most part\n # we always set the NO_CACHE cookie after any POST request, disabling the\n # Varnish cache temporarily. The session cookie allows all authenticated users\n # to pass through as long as they're logged in.\n #\n # 1. Append a semi-colon to the front of the cookie string.\n # 2. Remove all spaces that appear after semi-colons.\n # 3. Match the cookies we want to keep, adding the space we removed\n # previously, back. (\\1) is first matching group in the regsuball.\n # 4. Remove all other cookies, identifying them by the fact that they have\n # no space after the preceding semi-colon.\n # 5. Remove all spaces and semi-colons from the beginning and end of the\n # cookie string.\n if (req.http.Cookie) {\n set req.http.CookieCheck = \";\" + req.http.Cookie;\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"; +\", \";\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";(${VARNISH_COOKIECHECK:-SESS[a-z0-9]+|SSESS[a-z0-9]+|NO_CACHE})=\", \"; \\1=\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";[^ ][^;]*\", \"\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"^[; ]+|[; ]+$\", \"\");\n\n set req.http.Cookie = req.http.Cookie + \";\";\n\n if (req.http.CookieCheck == \"\") {\n # If there are no remaining cookies, remove the cookie header. If there\n # aren't any cookie headers, Varnish's default behavior will be to cache\n # the page.\n\n unset req.http.CookieCheck;\n unset req.http.Cookie;\n }\n else {\n # If there is any cookies left (a session or NO_CACHE cookie), do not\n # cache the page. Pass it on to Apache directly.\n unset req.http.CookieCheck;\n return (pass);\n }\n }\n\n # Cacheable, lookup in cache.\n return (hash);\n}\n\nsub vcl_pipe {\n # Support for Websockets\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n set bereq.http.connection = req.http.connection;\n }\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n # normal hit\n return (deliver);\n }\n # We have no fresh fish. Lets look at the stale ones.\n if (std.healthy(req.backend_hint)) {\n # Backend is healthy. If the object is not older then 30secs, deliver it to the client\n # and automatically create a separate backend request to warm the cache for this request.\n if (obj.ttl + 30s > 0s) {\n set req.http.grace = \"normal(limited)\";\n return (deliver);\n } else {\n # No candidate for grace. Fetch a fresh object.\n return(miss);\n }\n } else {\n # backend is sick - use full grace\n if (obj.ttl + obj.grace > 0s) {\n set req.http.grace = \"full\";\n return (deliver);\n } else {\n # no graced object.\n return (miss);\n }\n }\n}\n\nsub vcl_backend_response {\n # Allow items to be stale if needed.\n set beresp.grace = 6h;\n\n # Set ban-lurker friendly custom headers.\n set beresp.http.X-Url = bereq.url;\n set beresp.http.X-Host = bereq.http.host;\n\n # If the backend sends a X-LAGOON-VARNISH-BACKEND-BYPASS header we directly deliver\n if(beresp.http.X-LAGOON-VARNISH-BACKEND-BYPASS == \"TRUE\") {\n return (deliver);\n }\n\n # Cache 404 and 403 for 10 seconds\n if(beresp.status == 404 || beresp.status == 403) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n # Don't allow static files to set cookies.\n if (bereq.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n # beresp == Back-end response from the web server.\n unset beresp.http.set-cookie;\n unset beresp.http.Cache-Control;\n\n # If an asset would come back with statuscode 500 we only cache it for 10 seconds instead of the usual static file cache\n if (beresp.status == 500) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n set beresp.ttl = ${VARNISH_ASSETS_TTL:-2628001}s;\n set beresp.http.Cache-Control = \"public, max-age=${VARNISH_ASSETS_TTL:-2628001}\";\n set beresp.http.Expires = \"\" + (now + beresp.ttl);\n }\n\n return (deliver);\n}\n\n# Set a header to track a cache HIT\/MISS.\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Varnish-Cache = \"HIT\";\n }\n else {\n set resp.http.X-Varnish-Cache = \"MISS\";\n }\n\n # Remove ban-lurker friendly custom headers when delivering to client.\n unset resp.http.X-Url;\n unset resp.http.X-Host;\n\n # unset Cache-Tags Header by default, can be disabled with VARNISH_UNSET_HEADER_CACHE_TAGS=true\n if (!${VARNISH_UNSET_HEADER_CACHE_TAGS:-false}) {\n unset resp.http.Cache-Tags;\n }\n\n unset resp.http.X-Generator;\n unset resp.http.Server;\n # Inject information about grace\n if (req.http.grace) {\n set resp.http.X-Varnish-Grace = req.http.grace;\n }\n set resp.http.X-LAGOON = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}>\" + resp.http.X-LAGOON;\n return (deliver);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n if (req.http.X-Forwarded-Proto) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n if (req.http.HTTPS) {\n hash_data(req.http.HTTPS);\n }\n return (lookup);\n}\n\nsub vcl_synth {\n if (resp.status == 701) {\n set resp.status = 401;\n set resp.http.Content-Type = \"text\/plain; charset=utf-8\";\n synthetic({\"XMLRPC Interface is blocked due to SA-CORE-2014-004 - mail support@amazee.io if you need it.\"});\n return (deliver);\n }\n if (resp.status == 700) {\n # Set a status the client will understand\n set resp.status = 200;\n # Create our synthetic response\n synthetic(\"\");\n return(deliver);\n}\n return (deliver);\n}\n\nsub vcl_backend_error {\n # Restart the request, when we have a backend server error, to try another backend.\n # Restart max twice.\n if (bereq.retries < 2) {\n return(retry);\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<head>\n <title>Server Error<\/title>\n <style type=\"text\/css\">\n body {\n font-family: helvetica, arial, sans-serif;\n }\n img {\n margin-top: 50px;\n }\n p {\n width: 6 00px;\n margin-top: 10px\n }\n div {\n background: #ccc;\n width: 600px;\n margin: auto;\n padding: 50px;\n }\n span {\n color: #ccc\n }\n <\/style>\n<\/head>\n<body>\n <div>\n <h1>We are sorry...<\/h1>\n <p>We encountered a server-side error. This means that the problem is not with your computer or Internet connection, but rather with the website's server.<\/p>\n <p>We are currently working on solving this problem and apologise for the inconvenience.<\/p>\n <span>\n <strong>Technical Information<\/strong><br \/>\n Error \"} + beresp.status + \" \" + beresp.reason + {\"<br \/>\n XID: \"} + bereq.xid + {\"<br \/>\n <\/span>\n <\/div>\n<\/body>\n<\/html>\n\n\"} );\n return (deliver);\n}\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"ad7072001e988fe311c03db458dff24cc74d9263","subject":"Sync with reality","message":"Sync with reality\n","repos":"feld\/Varnish-Cache,gquintard\/Varnish-Cache,varnish\/Varnish-Cache,feld\/Varnish-Cache,varnish\/Varnish-Cache,gquintard\/Varnish-Cache,varnish\/Varnish-Cache,feld\/Varnish-Cache,feld\/Varnish-Cache,gquintard\/Varnish-Cache,varnish\/Varnish-Cache,feld\/Varnish-Cache,gquintard\/Varnish-Cache,varnish\/Varnish-Cache","old_file":"bin\/varnishd\/builtin.vcl","new_file":"bin\/varnishd\/builtin.vcl","new_contents":"\/*-\n * Copyright (c) 2006 Verdens Gang AS\n * Copyright (c) 2006-2015 Varnish Software AS\n * All rights reserved.\n *\n * Author: Poul-Henning Kamp <phk@phk.freebsd.dk>\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in the\n * documentation and\/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n\n *\n * The built-in (previously called default) VCL code.\n *\n * NB! You do NOT need to copy & paste all of these functions into your\n * own vcl code, if you do not provide a definition of one of these\n * functions, the compiler will automatically fall back to the default\n * code from this file.\n *\n * This code will be prefixed with a backend declaration built from the\n * -b argument.\n *\/\n\nvcl 4.0;\n\n#######################################################################\n# Client side\n\nsub vcl_recv {\n if (req.method == \"PRI\") {\n\t\/* We do not support SPDY or HTTP\/2.0 *\/\n\treturn (synth(405));\n }\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization || req.http.Cookie) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n return (hash);\n}\n\nsub vcl_pipe {\n # By default Connection: close is set on all piped requests, to stop\n # connection reuse from sending future requests directly to the\n # (potentially) wrong backend. If you do want this to happen, you can undo\n # it here.\n # unset bereq.http.connection;\n return (pipe);\n}\n\nsub vcl_pass {\n return (fetch);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n return (lookup);\n}\n\nsub vcl_purge {\n return (synth(200, \"Purged\"));\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n \/\/ A pure unadultered hit, deliver it\n return (deliver);\n }\n if (obj.ttl + obj.grace > 0s) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n return (deliver);\n }\n \/\/ fetch & deliver once we get the result\n return (miss);\n}\n\nsub vcl_miss {\n return (fetch);\n}\n\nsub vcl_deliver {\n return (deliver);\n}\n\n\/*\n * We can come here \"invisibly\" with the following errors: 500 & 503\n *\/\nsub vcl_synth {\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n set resp.http.Retry-After = \"5\";\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n return (deliver);\n}\n\n#######################################################################\n# Backend Fetch\n\nsub vcl_backend_fetch {\n return (fetch);\n}\n\nsub vcl_backend_response {\n if (beresp.ttl <= 0s ||\n beresp.http.Set-Cookie ||\n beresp.http.Surrogate-control ~ \"no-store\" ||\n (!beresp.http.Surrogate-Control &&\n beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n beresp.http.Vary == \"*\") {\n \/*\n * Mark as \"Hit-For-Pass\" for the next 2 minutes\n *\/\n set beresp.ttl = 120s;\n set beresp.uncacheable = true;\n }\n return (deliver);\n}\n\nsub vcl_backend_error {\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + beresp.status + \" \" + beresp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + beresp.status + \" \" + beresp.reason + {\"<\/h1>\n <p>\"} + beresp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + bereq.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n return (deliver);\n}\n\n#######################################################################\n# Housekeeping\n\nsub vcl_init {\n}\n\nsub vcl_fini {\n return (ok);\n}\n","old_contents":"\/*-\n * Copyright (c) 2006 Verdens Gang AS\n * Copyright (c) 2006-2015 Varnish Software AS\n * All rights reserved.\n *\n * Author: Poul-Henning Kamp <phk@phk.freebsd.dk>\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in the\n * documentation and\/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n\n *\n * The built-in (previously called default) VCL code.\n *\n * NB! You do NOT need to copy & paste all of these functions into your\n * own vcl code, if you do not provide a definition of one of these\n * functions, the compiler will automatically fall back to the default\n * code from this file.\n *\n * This code will be prefixed with a backend declaration built from the\n * -b argument.\n *\/\n\nvcl 4.0;\n\n#######################################################################\n# Client side\n\nsub vcl_recv {\n if (req.method == \"PRI\") {\n\t\/* We do not support SPDY or HTTP\/2.0 *\/\n\treturn (synth(405));\n }\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization || req.http.Cookie) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n return (hash);\n}\n\nsub vcl_pipe {\n # By default Connection: close is set on all piped requests, to stop\n # connection reuse from sending future requests directly to the\n # (potentially) wrong backend. If you do want this to happen, you can undo\n # it here.\n # unset bereq.http.connection;\n return (pipe);\n}\n\nsub vcl_pass {\n return (fetch);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n return (lookup);\n}\n\nsub vcl_purge {\n return (synth(200, \"Purged\"));\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n \/\/ A pure unadultered hit, deliver it\n return (deliver);\n }\n if (obj.ttl + obj.grace > 0s) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n return (deliver);\n }\n \/\/ fetch & deliver once we get the result\n return (miss);\n}\n\nsub vcl_miss {\n return (fetch);\n}\n\nsub vcl_deliver {\n return (deliver);\n}\n\n\/*\n * We can come here \"invisibly\" with the following errors: 413, 417 & 503\n *\/\nsub vcl_synth {\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n set resp.http.Retry-After = \"5\";\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n return (deliver);\n}\n\n#######################################################################\n# Backend Fetch\n\nsub vcl_backend_fetch {\n return (fetch);\n}\n\nsub vcl_backend_response {\n if (beresp.ttl <= 0s ||\n beresp.http.Set-Cookie ||\n beresp.http.Surrogate-control ~ \"no-store\" ||\n (!beresp.http.Surrogate-Control &&\n beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n beresp.http.Vary == \"*\") {\n \/*\n * Mark as \"Hit-For-Pass\" for the next 2 minutes\n *\/\n set beresp.ttl = 120s;\n set beresp.uncacheable = true;\n }\n return (deliver);\n}\n\nsub vcl_backend_error {\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + beresp.status + \" \" + beresp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + beresp.status + \" \" + beresp.reason + {\"<\/h1>\n <p>\"} + beresp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + bereq.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n return (deliver);\n}\n\n#######################################################################\n# Housekeeping\n\nsub vcl_init {\n}\n\nsub vcl_fini {\n return (ok);\n}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"ca6ad10bf087e7773b7da70c2e7de6a83a459375","subject":"Add div, comment, tags commands","message":"Add div, comment, tags commands\n","repos":"aschneiderman\/atom-voice-vocola","old_file":"atom.vcl","new_file":"atom.vcl","new_contents":"# Voice commands for atom\n\ninclude folders.vch;\ninclude letters.vch;\n\nGo Strawberry = {Ctrl+Alt+F8};\nGo Blueberry ={Ctrl+Alt+o};\nGo Banana = {Ctrl+Alt+F7};\n\n\n# Commands for developing Atom: init.config, packages; also for navigating existing packages\/commands\nReload Atom = {Ctrl+s} Wait(100) {Shift+Ctrl+Alt+F5};\nCommand Palette = {Ctrl+Shift+p};\nKeyboard Shortcuts = {Ctrl+.};\nRun Specs = {Ctrl+Alt+p};\nShow Console = {Ctrl+Alt+i};\n\n# Commands for developing D3: D3 visualizations, D3 Sandwiches\nSave and Reload = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Ctrl+r};\t\nSave and Really Reload = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Ctrl+Shift+r};\n\n# File commands\nFind (File | Document) = {Ctrl+t};\nSave As = {Ctrl+Shift+s};\n\n\n# --- Navigation commands ------------------------------------\n<delimiters> := (Quote = '\"' | 'Single Quote' = \"'\" | Comma = ',' | 'Equal Sign' = '=' | Equals = '=' \n\t| Period = '.' | Colon = ':' | 'Semi-Colon' = ';' | Hyphen = '-' | Underscore = '_' | Slash = '\/'\n\t| Paren = \"(\" | \"Close Paren\" = \")\" | Parentheses = \"(\" | \"Close Parentheses\" = \")\"\n\t| Bracket = '[' | \"Close Bracket\" = ']' | Brace = '{' | 'Close Brace' = '}'\t);\n\nLine 1..200 = {Ctrl+g} $1 {Enter};\n(Left = 'b' | Right = 'f') Word = {Alt+$1};\nTop = {Ctrl+Home};\nBottom = {Ctrl+End};\n(Find = 'Right' | 'Insert After' = 'Right' | 'Insert Before' = 'Left') (Next = 'Enter' | Last = 'Shift+F3') <delimiters> \n\t\t= {Ctrl+f} $3 {$2} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') <delimiters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') 1..20 <delimiters> = {Ctrl+f} $3 {Enter} {Esc} Wait(100) {F3_$2} {Shift+F3} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') Enda <delimiters> = {End} {Ctrl+f} $2 {Enter} {Esc} {Shift+F3} Wait(100) {$1};\n\nFine Alpha <letters> = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Left};\nInsert (Before = 'Left' | After = 'Right') Alpha <letters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nFine Number 0..9 = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Right};\nFind Again = {F3} {Right};\nFind Again 1..20 Times = {F3_$1} {Right};\n\nFind Symbol = {Ctrl+r};\n\n(Set | Add | Clear | Hide | Delete) Bookmark = {Ctrl+Alt+F2};\n(Next = 'F2' | Last = 'Shift+F2') Bookmark = {$1};\n\nNext Window = {Ctrl+Tab};\nLast Window = {Ctrl+Shift+Tab};\n\n\n# --- Editing commands ----------------------------------------\nSelect Line = {Ctrl+l};\nSelect (Next = 'Down' | Last = 'Up') 1..20 Lines = {Home} {Shift+$1_$2};\n(Join = 'j' | Indent = ']' | Dedent = '[') That = {Ctrl+$1};\nMove Line (Up | Down) 1..20 = {Ctrl+$1_$2};\n\n\n\nDelete Word = {Ctrl+Del};\nDelete 1..20 Words = {Ctrl+Del_$1};\nDelete (Back | Last) Word = {Ctrl+Backspace};\nDelete (Back | Last) 1..20 Words = {Ctrl+Backspace_$2};\nDelete Enda Word = {End} {Ctrl+Backspace};\n\n(Delete Line | Dede) = {Ctrl+Shift+k};\nDelete 1..20 Lines = {Ctrl+Shift+k_$1};\n(Cut = 'x' | Paste = 'v' | Copy = 'c') That = {Ctrl+$1};\n\nComment (That | Line) = {Ctrl+\/};\nComment 1..20 Lines = {Home} {Shift+Down_$1} {Ctrl+\/};\n\nSelect between (Delimiters | Brackets | Tags) ={Ctrl+m} {Ctrl+Alt+m};\n\nDelete Tags = {Ctrl+Alt+F4};\n\nReplace = {Ctrl+f};\nReplace All = {Ctrl+Enter};\n\n\n\n\n# --- Code commands -------------------------------------------\nStart (Item = 'li' | List = 'ul' | HTML = 'html' | pre = \"pre\"\n\t| div = 'div' | 'Comment' = 'comment-html'\n\t| 'Bold ID' = 'bold-id' | 'Input' = 'ds-input-text'\n\t| 'Fix Line' = 'fix-current-line' | 'Fix Current Line' = 'fix-current-line'\n\t| Snippet = 'my-snippet' | 'Recipe Row' = 'recipe-row' | 'Recipe Play' = 'recipe-play') = $1 {Tab};\nStop (Comment = 'comment-html-end' ) = $1 {Tab};\nStart (para = '<p>' ) = $1;\nAdd (para = 'p') = '<' $1 '>' {End} '<\/' $1 '>';\nReplace With (para = 'p') = {Ctrl+Alt+F4} '<' $1 '>' {End} '<\/' $1 '>';\n\nStart (Header | Heading) 1..7 = h $2 {Tab};\nAdd (Header | Heading) 1..7 = '<h' $2 '>' {End} '<\/h' $2 '>';\nReplace With (Header | Heading) 1..7 = {Ctrl+Alt+F4} '<h' $2 '>' {End} '<\/h' $2 '>' {Home};\nMid HREF = '\">';\n\nPaste Function = 'function ' {Ctrl+v} ' {' {Enter} {Enter} '};' {Up};\n\nPre-Format Code = {Ctrl+Alt+F5};\n\n# TO ADD:\n# adding HTML comments, using a snippet\n\n\n\n","old_contents":"# Voice commands for atom\n\ninclude folders.vch;\ninclude letters.vch;\n\nGo Strawberry = {Ctrl+Alt+F8};\nGo Blueberry ={Ctrl+Alt+o};\nGo Banana = {Ctrl+Alt+F7};\n\n\n# Commands for developing Atom: init.config, packages; also for navigating existing packages\/commands\nReload Atom = {Ctrl+s} Wait(100) {Shift+Ctrl+Alt+F5};\nCommand Palette = {Ctrl+Shift+p};\nKeyboard Shortcuts = {Ctrl+.};\nRun Specs = {Ctrl+Alt+p};\nShow Console = {Ctrl+Alt+i};\n\n# Commands for developing D3: D3 visualizations, D3 Sandwiches\nSave and Reload = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Ctrl+r};\t\nSave and Really Reload = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Ctrl+Shift+r};\n\n# File commands\nFind (File | Document) = {Ctrl+t};\nSave As = {Ctrl+Shift+s};\n\n\n# --- Navigation commands ------------------------------------\n<delimiters> := (Quote = '\"' | 'Single Quote' = \"'\" | Comma = ',' | 'Equal Sign' = '=' | Equals = '=' \n\t| Period = '.' | Colon = ':' | 'Semi-Colon' = ';' | Hyphen = '-' | Underscore = '_' | Slash = '\/'\n\t| Paren = \"(\" | \"Close Paren\" = \")\" | Parentheses = \"(\" | \"Close Parentheses\" = \")\"\n\t| Bracket = '[' | \"Close Bracket\" = ']' | Brace = '{' | 'Close Brace' = '}'\t);\n\nLine 1..200 = {Ctrl+g} $1 {Enter};\n(Left = 'b' | Right = 'f') Word = {Alt+$1};\nTop = {Ctrl+Home};\nBottom = {Ctrl+End};\n(Find = 'Right' | 'Insert After' = 'Right' | 'Insert Before' = 'Left') (Next = 'Enter' | Last = 'Shift+F3') <delimiters> \n\t\t= {Ctrl+f} $3 {$2} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') <delimiters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') 1..20 <delimiters> = {Ctrl+f} $3 {Enter} {Esc} Wait(100) {F3_$2} {Shift+F3} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') Enda <delimiters> = {End} {Ctrl+f} $2 {Enter} {Esc} {Shift+F3} Wait(100) {$1};\n\nFine Alpha <letters> = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Left};\nInsert (Before = 'Left' | After = 'Right') Alpha <letters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nFine Number 0..9 = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Right};\nFind Again = {F3} {Right};\nFind Again 1..20 Times = {F3_$1} {Right};\n\nFind Symbol = {Ctrl+r};\n\n(Set | Add | Clear | Hide | Delete) Bookmark = {Ctrl+Alt+F2};\n(Next = 'F2' | Last = 'Shift+F2') Bookmark = {$1};\n\nNext Window = {Ctrl+Tab};\nLast Window = {Ctrl+Shift+Tab};\n\n\n# --- Editing commands ----------------------------------------\nSelect Line = {Ctrl+l};\nSelect (Next = 'Down' | Last = 'Up') 1..20 Lines = {Home} {Shift+$1_$2};\n(Join = 'j' | Indent = ']' | Dedent = '[') That = {Ctrl+$1};\nMove Line (Up | Down) 1..20 = {Ctrl+$1_$2};\n\n\n\nDelete Word = {Ctrl+Del};\nDelete 1..20 Words = {Ctrl+Del_$1};\nDelete (Back | Last) Word = {Ctrl+Backspace};\nDelete (Back | Last) 1..20 Words = {Ctrl+Backspace_$2};\nDelete Enda Word = {End} {Ctrl+Backspace};\n\n(Delete Line | Dede) = {Ctrl+Shift+k};\nDelete 1..20 Lines = {Ctrl+Shift+k_$1};\n(Cut = 'x' | Paste = 'v' | Copy = 'c') That = {Ctrl+$1};\n\nComment (That | Line) = {Ctrl+\/};\nComment 1..20 Lines = {Home} {Shift+Down_$1} {Ctrl+\/};\n\nSelect between (Delimiters | Brackets) ={Ctrl+m} {Ctrl+Alt+m};\n\nDelete Tags = {Ctrl+Alt+F4};\n\nReplace = {Ctrl+f};\nReplace All = {Ctrl+Enter};\n\n\n\n\n# --- Code commands -------------------------------------------\nStart (Item = 'li' | List = 'ul' | HTML = 'html' | pre = \"pre\"\n\t| 'Bold ID' = 'bold-id' | 'Input' = 'ds-input-text'\n\t| 'Fix Line' = 'fix-current-line' | 'Fix Current Line' = 'fix-current-line'\n\t| Snippet = 'my-snippet' | 'Recipe Row' = 'recipe-row' | 'Recipe Play' = 'recipe-play') = $1 {Tab};\nStart (para = '<p>' ) = $1;\nAdd (para = 'p') = '<' $1 '>' {End} '<\/' $1 '>';\nReplace With (para = 'p') = {Ctrl+Alt+F4} '<' $1 '>' {End} '<\/' $1 '>';\n\nStart (Header | Heading) 1..7 = h $2 {Tab};\nAdd (Header | Heading) 1..7 = '<h' $2 '>' {End} '<\/h' $2 '>';\nReplace With (Header | Heading) 1..7 = {Ctrl+Alt+F4} '<h' $2 '>' {End} '<\/h' $2 '>' {Home};\nMid HREF = '\">';\n\nPaste Function = 'function ' {Ctrl+v} ' {' {Enter} {Enter} '};' {Up};\n\nPre-Format Code = {Ctrl+Alt+F5};\n\n# TO ADD:\n# adding HTML comments, using a snippet\n\n\n\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"cf1d483edb16edb8196cef310244eb211e01d15e","subject":"We don't want to set X-Pass for Ratelimiting calls. We'll handle those separately","message":"We don't want to set X-Pass for Ratelimiting calls. We'll handle those separately\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets_rate_limiting\/recv.vcl","new_file":"etc\/vcl_snippets_rate_limiting\/recv.vcl","new_contents":"if (####RATE_LIMITED_PATHS####) {\n set req.http.Rate-Limit = \"1\";\n return(lookup);\n}\n","old_contents":"if (####RATE_LIMITED_PATHS####) {\n set req.http.X-Pass = \"1\";\n set req.http.Rate-Limit = \"1\";\n return(lookup);\n}\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"a37322e0564d55311010f6f85b7fed8fcd07fd10","subject":"adding a proper header to process ESI","message":"adding a proper header to process ESI\n","repos":"domix\/poc-varnish-cache-docker,domix\/poc-varnish-cache-docker","old_file":"conf\/varnish.vcl","new_file":"conf\/varnish.vcl","new_contents":"vcl 4.0;\n\nbackend default {\n .host = \"web\";\n .port = \"9191\";\n}\n\nbackend management {\n .host = \"web\";\n .port = \"9192\";\n}\n\nsub vcl_recv {\n # Happens before we check if we have this in cache already.\n #\n # Typically you clean up the request here, removing cookies you don't need,\n # rewriting the request, etc.\n\n if (req.url ~ \"^\/management\/\") {\n set req.backend_hint = management;\n } else {\n set req.backend_hint = default;\n }\n\n if (req.method == \"BAN\" || req.method == \"PURGE\") {\n # Same ACL check as above:\n #if (!client.ip ~ purge) {\n #return(synth(403, \"Not allowed.\"));\n #}\n\n #ban(\"obj.http.x-url ~ \" + req.url); # Assumes req.url is a regex. This might be a bit too simple\n\n ban (\"obj.http.x-article-ids ~ \" + req.url);\n\n # Throw a synthetic page so the\n # request won't go to the backend.\n return(synth(200, \"Ban added\"));\n }\n\n if (!req.url ~ \"\\.(jpg|jpeg|png|gif|ico|tiff|tif|bmp|ppm|pgm|xcf|psd|webp|svg)\") {\n set req.http.X-Esi = \"1\";\n set req.http.Surrogate-Capability = \"ESI\/1.0\";\n }\n}\n\nsub vcl_backend_response {\n # Happens after we have read the response headers from the backend.\n #\n # Here you clean the response headers, removing silly Set-Cookie headers\n # and other mistakes your backend does.\n\n #if (beresp.http.Content-Type ~ \"^image\/\") {\n if (beresp.status == 404) {\n #set beresp.http.Cache-Control = \"public, max-age=60\";\n #set beresp.ttl = 60s;\n set beresp.http.Cache-Control = \"public, max-age=0\";\n set beresp.ttl = 0s;\n }\n\n if (beresp.http.X-Esi) {\n set beresp.do_esi = true;\n unset beresp.http.X-Esi; # remove header\n }\n\n set beresp.http.X-url = bereq.url;\n}\n\nsub vcl_deliver {\n # Happens when we have all the pieces we need, and are about to send the\n # response to the client.\n #\n # You can do accounting or modifying the final object here.\n\n unset resp.http.Server;\n unset resp.http.X-Powered-By;\n}","old_contents":"vcl 4.0;\n\nbackend default {\n .host = \"web\";\n .port = \"9191\";\n}\n\nbackend management {\n .host = \"web\";\n .port = \"9192\";\n}\n\nsub vcl_recv {\n # Happens before we check if we have this in cache already.\n #\n # Typically you clean up the request here, removing cookies you don't need,\n # rewriting the request, etc.\n\n if (req.url ~ \"^\/management\/\") {\n set req.backend_hint = management;\n } else {\n set req.backend_hint = default;\n }\n\n if (req.method == \"BAN\" || req.method == \"PURGE\") {\n # Same ACL check as above:\n #if (!client.ip ~ purge) {\n #return(synth(403, \"Not allowed.\"));\n #}\n\n #ban(\"obj.http.x-url ~ \" + req.url); # Assumes req.url is a regex. This might be a bit too simple\n\n ban (\"obj.http.x-article-ids ~ \" + req.url);\n\n # Throw a synthetic page so the\n # request won't go to the backend.\n return(synth(200, \"Ban added\"));\n }\n\n if (!req.url ~ \"\\.(jpg|jpeg|png|gif|ico|tiff|tif|bmp|ppm|pgm|xcf|psd|webp|svg)\") {\n set req.http.X-Esi = \"1\";\n }\n}\n\nsub vcl_backend_response {\n # Happens after we have read the response headers from the backend.\n #\n # Here you clean the response headers, removing silly Set-Cookie headers\n # and other mistakes your backend does.\n\n #if (beresp.http.Content-Type ~ \"^image\/\") {\n if (beresp.status == 404) {\n #set beresp.http.Cache-Control = \"public, max-age=60\";\n #set beresp.ttl = 60s;\n set beresp.http.Cache-Control = \"public, max-age=0\";\n set beresp.ttl = 0s;\n }\n\n if (beresp.http.X-Esi) {\n set beresp.do_esi = true;\n unset beresp.http.X-Esi; # remove header\n }\n\n set beresp.http.X-url = bereq.url;\n}\n\nsub vcl_deliver {\n # Happens when we have all the pieces we need, and are about to send the\n # response to the client.\n #\n # You can do accounting or modifying the final object here.\n\n unset resp.http.Server;\n unset resp.http.X-Powered-By;\n}","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"c8d46dbe049a402d7616b490b32d3461f52c2936","subject":"Cleanup delete-tags code","message":"Cleanup delete-tags code\n","repos":"aschneiderman\/atom-voice-vocola","old_file":"atom.vcl","new_file":"atom.vcl","new_contents":"# Voice commands for atom\n\ninclude folders.vch;\ninclude letters.vch;\n\n\nReload Atom = {Shift+Ctrl+Alt+F5};\n\nFind (File | Document) = {Ctrl+t};\nSave As = {Ctrl+Shift+s};\nSave and Reload = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Ctrl+r};\n\n<delimiters> := (Quote = '\"' | 'Single Quote' = \"'\" | Comma = ',' | 'Equal Sign' = '=' | Equals = '=' \n\t| Period = '.' | Colon = ':' | 'Semi-Colon' = ';' | Hyphen = '-' | Underscore = '_'\n\t| Paren = \"(\" | \"Close Paren\" = \")\"\n\t| Bracket = '[' | \"Close Bracket\" = ']' | Brace = '{' | 'Close Brace' = '}'\t);\n\n# --- Navigation commands ------------------------------------\nLine 1..200 = {Ctrl+g} $1 {Enter};\n(Left = 'b' | Right = 'f') Word = {Alt+$1};\nTop = {Ctrl+Home};\nBottom = {Ctrl+End};\n(Find = 'Right' | 'Insert After' = 'Right' | 'Insert Before' = 'Left') (Next = 'Enter' | Last = 'Shift+F3') <delimiters> \n\t\t= {Ctrl+f} $3 {$2} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') <delimiters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') 1..20 <delimiters> = {Ctrl+f} $3 {Enter} {Esc} Wait(100) {F3_$2} {Shift+F3} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') Enda <delimiters> = {End} {Ctrl+f} $2 {Enter} {Esc} {Shift+F3} Wait(100) {$1};\n\nFine Alpha <letters> = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Right};\nInsert (Before = 'Left' | After = 'Right') Alpha <letters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nFine Number 0..9 = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Right};\nFind Again = {F3} {Right};\nFind Again 1..20 Times = {F3_$1} {Right};\n\nFind Symbol = {Ctrl+r};\n\n(Set | Add | Clear | Hide | Delete) Bookmark = {Ctrl+Alt+F2};\n(Next = 'F2' | Last = 'Shift+F2') Bookmark = {$1};\n\nNext Window = {Ctrl+Tab};\nLast Window = {Ctrl+Shift+Tab};\n\n\n# --- Editing commands ----------------------------------------\nSelect Line = {Ctrl+l};\nSelect (Next = 'Down' | Last = 'Up') 1..20 Lines = {Home} {Shift+$1_$2};\n(Join = 'j' | Indent = ']' | Dedent = '[') That = {Ctrl+$1};\nMove Line (Up | Down) 1..20 = {Ctrl+$1_$2};\n\n\n\nDelete Word = {Ctrl+Del};\nDelete 1..20 Words = {Ctrl+Del_$1};\nDelete (Back | Last) Word = {Ctrl+Backspace};\nDelete (Back | Last) 1..20 Words = {Ctrl+Backspace_$2};\nDelete Enda Word = {End} {Ctrl+Backspace};\n\n(Delete Line | Dede) = {Ctrl+Shift+k};\nDelete 1..20 Lines = {Ctrl+Shift+k_$1};\n(Cut = 'x' | Paste = 'v' | Copy = 'c') That = {Ctrl+$1};\n\nComment (That | Line) = {Ctrl+\/};\nComment 1..20 Lines = {Home} {Shift+Down_$1} {Ctrl+\/};\n\nSelect between (Delimiters | Brackets) ={Ctrl+m} {Ctrl+Alt+m};\nDelete Tags = {Ctrl+Alt+F4};\n\n\n\n\n# --- Code commands -------------------------------------------\nStart (Item = 'li' | List = 'ul' | HTML = 'html' | pre = \"pre\"\n\t| 'Bold ID' = 'bold-id' | 'Input' = 'ds-input-text'\n\t| Snippet = 'snip' | 'Recipe Row' = 'recipe-row' | 'Recipe Play' = 'recipe-play') = $1 {Tab};\nStart (para = '<p>' ) = $1;\nAdd (para = 'p') = '<' $1 '>' {End} '<\/' $1 '>';\nReplace With (para = 'p') = {Ctrl+Alt+F4} '<' $1 '>' {End} '<\/' $1 '>';\n\nStart (Header | Heading) 1..7 = h $2 {Tab};\nAdd (Header | Heading) 1..7 = '<h' $2 '>' {End} '<\/h' $2 '>';\nReplace With (Header | Heading) 1..7 = {Ctrl+Alt+F4} '<h' $2 '>' {End} '<\/h' $2 '>' {Home};\nMid HREF = '\">';\n\nPaste Function = 'function ' {Ctrl+v} ' {' {Enter} {Enter} '};' {Up};\n\n# TO ADD:\n# adding HTML comments, using a snippet\n\nShortcut Keys = {Ctrl+Shift+p};\n\n","old_contents":"# Voice commands for atom\n\ninclude folders.vch;\ninclude letters.vch;\n\n\nReload Atom = {Shift+Ctrl+Alt+F5};\n\nFind (File | Document) = {Ctrl+t};\nSave As = {Ctrl+Shift+s};\nSave and Reload = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Ctrl+r};\n\n<delimiters> := (Quote = '\"' | 'Single Quote' = \"'\" | Comma = ',' | 'Equal Sign' = '=' | Equals = '=' \n\t| Period = '.' | Colon = ':' | 'Semi-Colon' = ';' | Hyphen = '-' | Underscore = '_'\n\t| Paren = \"(\" | \"Close Paren\" = \")\"\n\t| Bracket = '[' | \"Close Bracket\" = ']' | Brace = '{' | 'Close Brace' = '}'\t);\n\n# --- Navigation commands ------------------------------------\nLine 1..200 = {Ctrl+g} $1 {Enter};\n(Left = 'b' | Right = 'f') Word = {Alt+$1};\nTop = {Ctrl+Home};\nBottom = {Ctrl+End};\n(Find = 'Right' | 'Insert After' = 'Right' | 'Insert Before' = 'Left') (Next = 'Enter' | Last = 'Shift+F3') <delimiters> \n\t\t= {Ctrl+f} $3 {$2} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') <delimiters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') 1..20 <delimiters> = {Ctrl+f} $3 {Enter} {Esc} Wait(100) {F3_$2} {Shift+F3} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') Enda <delimiters> = {End} {Ctrl+f} $2 {Enter} {Esc} {Shift+F3} Wait(100) {$1};\n\nFine Alpha <letters> = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Right};\nInsert (Before = 'Left' | After = 'Right') Alpha <letters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nFine Number 0..9 = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Right};\nFind Again = {F3} {Right};\nFind Again 1..20 Times = {F3_$1} {Right};\n\nFind Symbol = {Ctrl+r};\n\n(Set | Add | Clear | Hide | Delete) Bookmark = {Ctrl+Alt+F2};\n(Next = 'F2' | Last = 'Shift+F2') Bookmark = {$1};\n\nNext Window = {Ctrl+Tab};\nLast Window = {Ctrl+Shift+Tab};\n\n\n# --- Editing commands ----------------------------------------\nSelect Line = {Ctrl+l};\nSelect (Next = 'Down' | Last = 'Up') 1..20 Lines = {Home} {Shift+$1_$2};\n(Join = 'j' | Indent = ']' | Dedent = '[') That = {Ctrl+$1};\nMove Line (Up | Down) 1..20 = {Ctrl+$1_$2};\n\n\n\nDelete Word = {Ctrl+Del};\nDelete 1..20 Words = {Ctrl+Del_$1};\nDelete (Back | Last) Word = {Ctrl+Backspace};\nDelete (Back | Last) 1..20 Words = {Ctrl+Backspace_$2};\nDelete Enda Word = {End} {Ctrl+Backspace};\n\n(Delete Line | Dede) = {Ctrl+Shift+k};\nDelete 1..20 Lines = {Ctrl+Shift+k_$1};\n(Cut = 'x' | Paste = 'v' | Copy = 'c') That = {Ctrl+$1};\n\nComment (That | Line) = {Ctrl+\/};\nComment 1..20 Lines = {Home} {Shift+Down_$1} {Ctrl+\/};\n\nSelect between (Delimiters | Brackets) ={Ctrl+m} {Ctrl+Alt+m};\nDelete Tags = {Ctrl+Alt+F4} {Up};\n\n\n\n\n# --- Code commands -------------------------------------------\nStart (Item = 'li' | List = 'ul' | HTML = 'html' | pre = \"pre\"\n\t| 'Bold ID' = 'bold-id' | 'Input' = 'ds-input-text'\n\t| Snippet = 'snip' | 'Recipe Row' = 'recipe-row' | 'Recipe Play' = 'recipe-play') = $1 {Tab};\nStart (para = '<p>' ) = $1;\nAdd (para = 'p') = {Home} '<' $1 '>' {End} '<\/' $1 '>';\nReplace With (para = 'p') = {Home} {Ctrl+Alt+F4} {Up} {Home} '<' $1 '>' {End} '<\/' $1 '>';\n\nStart (Header | Heading) 1..7 = h $2 {Tab};\nAdd (Header | Heading) 1..7 = {Home} '<h' $2 '>' {End} '<\/h' $2 '>';\nReplace With (Header | Heading) 1..7 = {Home} {Ctrl+Alt+F4} {Up} {Home} '<h' $2 '>' {End} '<\/h' $2 '>' {Home};\nMid HREF = '\">';\n\nPaste Function = 'function ' {Ctrl+v} ' {' {Enter} {Enter} '};' {Up};\n\n# TO ADD:\n# adding HTML comments, using a snippet\n\nShortcut Keys = {Ctrl+Shift+p};\n\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"008a69fa951390b7b7c8b2e3b18292cbd433309a","subject":"like the default backend, use no probe.","message":"like the default backend, use no probe.\n","repos":"amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon","old_file":"images\/varnish-drupal\/drupal.vcl","new_file":"images\/varnish-drupal\/drupal.vcl","new_contents":"vcl 4.0;\n\nimport std;\nimport dynamic;\n\n# set backend default\nbackend default {\n .host = \"${VARNISH_BACKEND_HOST:-nginx}\";\n .port = \"${VARNISH_BACKEND_PORT:-8080}\";\n .first_byte_timeout = 35m;\n .between_bytes_timeout = 10m;\n}\n\n# Allow purging from localhost\n# @TODO allow from openshift network\nacl purge {\n \"127.0.0.1\";\n \"10.0.0.0\"\/8;\n \"172.16.0.0\"\/12;\n \"192.168.0.0\"\/16;\n}\n\nsub vcl_init {\n new www_dir = dynamic.director(\n port = \"${VARNISH_BACKEND_PORT:-8080}\",\n whitelist = purge,\n ttl = 60s);\n }\n\n# This configuration is optimized for Drupal hosting:\n# Respond to incoming requests.\nsub vcl_recv {\n\n if (req.url ~ \"^\/varnish_status$\") {\n return (synth(200,\"OK\"));\n }\n # set the backend, which should be used:\n set req.backend_hint = www_dir.backend(\"${VARNISH_BACKEND_HOST:-nginx}\");\n\n # Always set the forward ip.\n if (req.restarts == 0) {\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n\n\n if (req.http.X-LAGOON-VARNISH ) {\n ## Pass all Requests which are handled via an upstream Varnish\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, \" + req.http.X-LAGOON-VARNISH;\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n } else if (req.http.Fastly-FF) {\n ## Pass all Requests which are handled via Fastly\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, fastly\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n set req.http.X-Forwarded-For = req.http.Fastly-Client-IP;\n } else if (req.http.CF-RAY) {\n ## Pass all Requests which are handled via CloudFlare\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, cloudflare\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n set req.http.X-Forwarded-For = req.http.CF-Connecting-IP;\n } else if (req.http.X-Pull) {\n ## Pass all Requests which are handled via KeyCDN\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, keycdn\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n } else {\n ## We set a header to let a Varnish Chain know that it already has been varnishcached\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}\";\n\n ## Allow to bypass based on env variable `VARNISH_BYPASS`\n set req.http.X-LAGOON-VARNISH-BYPASS = \"${VARNISH_BYPASS:-false}\";\n }\n\n # Websockets are piped\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n if (req.http.X-LAGOON-VARNISH-BYPASS == \"true\" || req.http.X-LAGOON-VARNISH-BYPASS == \"TRUE\") {\n return (pass);\n }\n\n # SA-CORE-2014-004 preventing access to \/xmlrpc.php\n if (req.url ~ \"^\/xmlrpc.php$\") {\n return (synth(701, \"Unauthorized\"));\n }\n\n # Strip out Google Analytics campaign variables. They are only needed\n # by the javascript running on the page\n # utm_source, utm_medium, utm_campaign, gclid\n if(req.url ~ \"(\\?|&)(gclid|utm_[a-z]+)=\") {\n set req.url = regsuball(req.url, \"(gclid|utm_[a-z]+)=[^\\&]+&?\", \"\");\n set req.url = regsub(req.url, \"(\\?|&)$\", \"\");\n }\n\n # Bypass a cache hit (the request is still sent to the backend)\n if (req.method == \"REFRESH\") {\n if (!client.ip ~ purge) { return (synth(405, \"Not allowed\")); }\n set req.method = \"GET\";\n set req.hash_always_miss = true;\n }\n\n # Only allow BAN requests from IP addresses in the 'purge' ACL.\n if (req.method == \"BAN\" || req.method == \"URIBAN\" || req.method == \"PURGE\") {\n # Only allow BAN from defined ACL\n if (!client.ip ~ purge) {\n return (synth(403, \"Your IP is not allowed.\"));\n }\n\n # Only allows BAN if the Host Header has the style of with \"${SERVICE_NAME:-varnish}:8080\" or \"${SERVICE_NAME:-varnish}\".\n # Such a request is only possible from within the Docker network, as a request from external goes trough the Kubernetes Router and for that needs a proper Host Header\n if (!req.http.host ~ \"^${SERVICE_NAME:-varnish}(:\\d+)?$\") {\n return (synth(403, \"Only allowed from within own network.\"));\n }\n\n if (req.method == \"BAN\") {\n # Logic for the ban, using the Cache-Tags header.\n if (req.http.Cache-Tags) {\n ban(\"obj.http.Cache-Tags ~ \" + req.http.Cache-Tags);\n # Throw a synthetic page so the request won't go to the backend.\n return (synth(200, \"Ban added.\"));\n }\n else {\n return (synth(403, \"Cache-Tags header missing.\"));\n }\n }\n\n if (req.method == \"URIBAN\" || req.method == \"PURGE\") {\n ban(\"req.url ~ \" + req.url);\n # Throw a synthetic page so the request won't go to the backend.\n return (synth(200, \"Ban added.\"));\n }\n\n }\n\n # Non-RFC2616 or CONNECT which is weird, we pipe that\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n return (pipe);\n }\n\n # We only try to cache GET and HEAD, other things are passed\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n # Any requests with Basic Auth are passed\n if (req.http.Authorization || req.http.Authenticate)\n {\n return (pass);\n }\n\n ## Pass requests which are from blackfire\n if (req.http.X-Blackfire-Query) {\n return (pass);\n }\n\n # Some URLs should never be cached\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/admin([\/?]|$).*$\" ||\n req.url ~ \"^\/info([\/?]|$).*$\" ||\n req.url ~ \"^\/flag([\/?]|$).*$\" ||\n req.url ~ \"^.*\/system\/files([\/?]|$).*$\" ||\n req.url ~ \"^\/cgi\" ||\n req.url ~ \"^\/cgi-bin\"\n ) {\n return (pass);\n }\n\n # Plupload likes to get piped\n if (req.url ~ \"^.*\/plupload-handle-uploads.*$\"\n ) {\n return (pipe);\n }\n\n # Handle compression correctly. Different browsers send different\n # \"Accept-Encoding\" headers, even though they mostly all support the same\n # compression mechanisms. By consolidating these compression headers into\n # a consistent format, we can reduce the size of the cache and get more hits.=\n # @see: http:\/\/ varnish.projects.linpro.no\/wiki\/FAQ\/Compression\n if (req.http.Accept-Encoding) {\n if (req.http.Accept-Encoding ~ \"gzip\") {\n # If the browser supports it, we'll use gzip.\n set req.http.Accept-Encoding = \"gzip\";\n }\n else if (req.http.Accept-Encoding ~ \"deflate\") {\n # Next, try deflate if it is supported.\n set req.http.Accept-Encoding = \"deflate\";\n }\n else {\n # Unknown algorithm. Remove it and send unencoded.\n unset req.http.Accept-Encoding;\n }\n }\n\n # Always cache the following file types for all users.\n if (req.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n unset req.http.Cookie;\n }\n\n # Remove all cookies that Drupal doesn't need to know about. ANY remaining\n # cookie will cause the request to pass-through to a backend. For the most part\n # we always set the NO_CACHE cookie after any POST request, disabling the\n # Varnish cache temporarily. The session cookie allows all authenticated users\n # to pass through as long as they're logged in.\n #\n # 1. Append a semi-colon to the front of the cookie string.\n # 2. Remove all spaces that appear after semi-colons.\n # 3. Match the cookies we want to keep, adding the space we removed\n # previously, back. (\\1) is first matching group in the regsuball.\n # 4. Remove all other cookies, identifying them by the fact that they have\n # no space after the preceding semi-colon.\n # 5. Remove all spaces and semi-colons from the beginning and end of the\n # cookie string.\n if (req.http.Cookie) {\n set req.http.CookieCheck = \";\" + req.http.Cookie;\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"; +\", \";\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";(${VARNISH_COOKIECHECK:-SESS[a-z0-9]+|SSESS[a-z0-9]+|NO_CACHE})=\", \"; \\1=\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";[^ ][^;]*\", \"\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"^[; ]+|[; ]+$\", \"\");\n\n set req.http.Cookie = req.http.Cookie + \";\";\n\n if (req.http.CookieCheck == \"\") {\n # If there are no remaining cookies, remove the cookie header. If there\n # aren't any cookie headers, Varnish's default behavior will be to cache\n # the page.\n\n unset req.http.CookieCheck;\n unset req.http.Cookie;\n }\n else {\n # If there is any cookies left (a session or NO_CACHE cookie), do not\n # cache the page. Pass it on to Apache directly.\n unset req.http.CookieCheck;\n return (pass);\n }\n }\n\n # Cacheable, lookup in cache.\n return (hash);\n}\n\nsub vcl_pipe {\n # Support for Websockets\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n set bereq.http.connection = req.http.connection;\n }\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n # normal hit\n return (deliver);\n }\n # We have no fresh fish. Lets look at the stale ones.\n if (std.healthy(req.backend_hint)) {\n # Backend is healthy. If the object is not older then 30secs, deliver it to the client\n # and automatically create a separate backend request to warm the cache for this request.\n if (obj.ttl + 30s > 0s) {\n set req.http.grace = \"normal(limited)\";\n return (deliver);\n } else {\n # No candidate for grace. Fetch a fresh object.\n return(miss);\n }\n } else {\n # backend is sick - use full grace\n if (obj.ttl + obj.grace > 0s) {\n set req.http.grace = \"full\";\n return (deliver);\n } else {\n # no graced object.\n return (miss);\n }\n }\n}\n\nsub vcl_backend_response {\n # Allow items to be stale if needed.\n set beresp.grace = 6h;\n\n # Set ban-lurker friendly custom headers.\n set beresp.http.X-Url = bereq.url;\n set beresp.http.X-Host = bereq.http.host;\n\n # If the backend sends a X-LAGOON-VARNISH-BACKEND-BYPASS header we directly deliver\n if(beresp.http.X-LAGOON-VARNISH-BACKEND-BYPASS == \"TRUE\") {\n return (deliver);\n }\n\n # Cache 404 and 403 for 10 seconds\n if(beresp.status == 404 || beresp.status == 403) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n # Don't allow static files to set cookies.\n if (bereq.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n # beresp == Back-end response from the web server.\n unset beresp.http.set-cookie;\n unset beresp.http.Cache-Control;\n\n # If an asset would come back with statuscode 500 we only cache it for 10 seconds instead of the usual static file cache\n if (beresp.status == 500) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n set beresp.ttl = ${VARNISH_ASSETS_TTL:-2628001}s;\n set beresp.http.Cache-Control = \"public, max-age=${VARNISH_ASSETS_TTL:-2628001}\";\n set beresp.http.Expires = \"\" + (now + beresp.ttl);\n }\n\n return (deliver);\n}\n\n# Set a header to track a cache HIT\/MISS.\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Varnish-Cache = \"HIT\";\n }\n else {\n set resp.http.X-Varnish-Cache = \"MISS\";\n }\n\n # Remove ban-lurker friendly custom headers when delivering to client.\n unset resp.http.X-Url;\n unset resp.http.X-Host;\n\n # unset Cache-Tags Header by default, can be disabled with VARNISH_UNSET_HEADER_CACHE_TAGS=true\n if (!${VARNISH_UNSET_HEADER_CACHE_TAGS:-false}) {\n unset resp.http.Cache-Tags;\n }\n\n unset resp.http.X-Generator;\n unset resp.http.Server;\n # Inject information about grace\n if (req.http.grace) {\n set resp.http.X-Varnish-Grace = req.http.grace;\n }\n set resp.http.X-LAGOON = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}>\" + resp.http.X-LAGOON;\n return (deliver);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n if (req.http.X-Forwarded-Proto) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n if (req.http.HTTPS) {\n hash_data(req.http.HTTPS);\n }\n return (lookup);\n}\n\nsub vcl_synth {\n if (resp.status == 701) {\n set resp.status = 401;\n set resp.http.Content-Type = \"text\/plain; charset=utf-8\";\n synthetic({\"XMLRPC Interface is blocked due to SA-CORE-2014-004 - mail support@amazee.io if you need it.\"});\n return (deliver);\n }\n if (resp.status == 700) {\n # Set a status the client will understand\n set resp.status = 200;\n # Create our synthetic response\n synthetic(\"\");\n return(deliver);\n}\n return (deliver);\n}\n\nsub vcl_backend_error {\n # Restart the request, when we have a backend server error, to try another backend.\n # Restart max twice.\n if (bereq.retries < 2) {\n return(retry);\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<head>\n <title>Server Error<\/title>\n <style type=\"text\/css\">\n body {\n font-family: helvetica, arial, sans-serif;\n }\n img {\n margin-top: 50px;\n }\n p {\n width: 6 00px;\n margin-top: 10px\n }\n div {\n background: #ccc;\n width: 600px;\n margin: auto;\n padding: 50px;\n }\n span {\n color: #ccc\n }\n <\/style>\n<\/head>\n<body>\n <div>\n <h1>We are sorry...<\/h1>\n <p>We encountered a server-side error. This means that the problem is not with your computer or Internet connection, but rather with the website's server.<\/p>\n <p>We are currently working on solving this problem and apologise for the inconvenience.<\/p>\n <span>\n <strong>Technical Information<\/strong><br \/>\n Error \"} + beresp.status + \" \" + beresp.reason + {\"<br \/>\n XID: \"} + bereq.xid + {\"<br \/>\n <\/span>\n <\/div>\n<\/body>\n<\/html>\n\n\"} );\n return (deliver);\n}\n","old_contents":"vcl 4.0;\n\nimport std;\nimport dynamic;\n\n# set backend default\nbackend default {\n .host = \"${VARNISH_BACKEND_HOST:-nginx}\";\n .port = \"${VARNISH_BACKEND_PORT:-8080}\";\n .first_byte_timeout = 35m;\n .between_bytes_timeout = 10m;\n}\n\n# Allow purging from localhost\n# @TODO allow from openshift network\nacl purge {\n \"127.0.0.1\";\n \"10.0.0.0\"\/8;\n \"172.16.0.0\"\/12;\n \"192.168.0.0\"\/16;\n}\n\nsub vcl_init {\n new www_dir = dynamic.director(\n port = \"${VARNISH_BACKEND_PORT:-8080}\",\n probe = www_probe,\n whitelist = purge,\n ttl = 60s);\n }\n\n\n# This configuration is optimized for Drupal hosting:\n# Respond to incoming requests.\nsub vcl_recv {\n\n if (req.url ~ \"^\/varnish_status$\") {\n return (synth(200,\"OK\"));\n }\n # set the backend, which should be used:\n set req.backend_hint = www_dir.backend(\"${VARNISH_BACKEND_HOST:-nginx}\");\n\n # Always set the forward ip.\n if (req.restarts == 0) {\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n\n\n if (req.http.X-LAGOON-VARNISH ) {\n ## Pass all Requests which are handled via an upstream Varnish\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, \" + req.http.X-LAGOON-VARNISH;\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n } else if (req.http.Fastly-FF) {\n ## Pass all Requests which are handled via Fastly\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, fastly\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n set req.http.X-Forwarded-For = req.http.Fastly-Client-IP;\n } else if (req.http.CF-RAY) {\n ## Pass all Requests which are handled via CloudFlare\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, cloudflare\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n set req.http.X-Forwarded-For = req.http.CF-Connecting-IP;\n } else if (req.http.X-Pull) {\n ## Pass all Requests which are handled via KeyCDN\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, keycdn\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n } else {\n ## We set a header to let a Varnish Chain know that it already has been varnishcached\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}\";\n\n ## Allow to bypass based on env variable `VARNISH_BYPASS`\n set req.http.X-LAGOON-VARNISH-BYPASS = \"${VARNISH_BYPASS:-false}\";\n }\n\n # Websockets are piped\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n if (req.http.X-LAGOON-VARNISH-BYPASS == \"true\" || req.http.X-LAGOON-VARNISH-BYPASS == \"TRUE\") {\n return (pass);\n }\n\n # SA-CORE-2014-004 preventing access to \/xmlrpc.php\n if (req.url ~ \"^\/xmlrpc.php$\") {\n return (synth(701, \"Unauthorized\"));\n }\n\n # Strip out Google Analytics campaign variables. They are only needed\n # by the javascript running on the page\n # utm_source, utm_medium, utm_campaign, gclid\n if(req.url ~ \"(\\?|&)(gclid|utm_[a-z]+)=\") {\n set req.url = regsuball(req.url, \"(gclid|utm_[a-z]+)=[^\\&]+&?\", \"\");\n set req.url = regsub(req.url, \"(\\?|&)$\", \"\");\n }\n\n # Bypass a cache hit (the request is still sent to the backend)\n if (req.method == \"REFRESH\") {\n if (!client.ip ~ purge) { return (synth(405, \"Not allowed\")); }\n set req.method = \"GET\";\n set req.hash_always_miss = true;\n }\n\n # Only allow BAN requests from IP addresses in the 'purge' ACL.\n if (req.method == \"BAN\" || req.method == \"URIBAN\" || req.method == \"PURGE\") {\n # Only allow BAN from defined ACL\n if (!client.ip ~ purge) {\n return (synth(403, \"Your IP is not allowed.\"));\n }\n\n # Only allows BAN if the Host Header has the style of with \"${SERVICE_NAME:-varnish}:8080\" or \"${SERVICE_NAME:-varnish}\".\n # Such a request is only possible from within the Docker network, as a request from external goes trough the Kubernetes Router and for that needs a proper Host Header\n if (!req.http.host ~ \"^${SERVICE_NAME:-varnish}(:\\d+)?$\") {\n return (synth(403, \"Only allowed from within own network.\"));\n }\n\n if (req.method == \"BAN\") {\n # Logic for the ban, using the Cache-Tags header.\n if (req.http.Cache-Tags) {\n ban(\"obj.http.Cache-Tags ~ \" + req.http.Cache-Tags);\n # Throw a synthetic page so the request won't go to the backend.\n return (synth(200, \"Ban added.\"));\n }\n else {\n return (synth(403, \"Cache-Tags header missing.\"));\n }\n }\n\n if (req.method == \"URIBAN\" || req.method == \"PURGE\") {\n ban(\"req.url ~ \" + req.url);\n # Throw a synthetic page so the request won't go to the backend.\n return (synth(200, \"Ban added.\"));\n }\n\n }\n\n # Non-RFC2616 or CONNECT which is weird, we pipe that\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n return (pipe);\n }\n\n # We only try to cache GET and HEAD, other things are passed\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n # Any requests with Basic Auth are passed\n if (req.http.Authorization || req.http.Authenticate)\n {\n return (pass);\n }\n\n ## Pass requests which are from blackfire\n if (req.http.X-Blackfire-Query) {\n return (pass);\n }\n\n # Some URLs should never be cached\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/admin([\/?]|$).*$\" ||\n req.url ~ \"^\/info([\/?]|$).*$\" ||\n req.url ~ \"^\/flag([\/?]|$).*$\" ||\n req.url ~ \"^.*\/system\/files([\/?]|$).*$\" ||\n req.url ~ \"^\/cgi\" ||\n req.url ~ \"^\/cgi-bin\"\n ) {\n return (pass);\n }\n\n # Plupload likes to get piped\n if (req.url ~ \"^.*\/plupload-handle-uploads.*$\"\n ) {\n return (pipe);\n }\n\n # Handle compression correctly. Different browsers send different\n # \"Accept-Encoding\" headers, even though they mostly all support the same\n # compression mechanisms. By consolidating these compression headers into\n # a consistent format, we can reduce the size of the cache and get more hits.=\n # @see: http:\/\/ varnish.projects.linpro.no\/wiki\/FAQ\/Compression\n if (req.http.Accept-Encoding) {\n if (req.http.Accept-Encoding ~ \"gzip\") {\n # If the browser supports it, we'll use gzip.\n set req.http.Accept-Encoding = \"gzip\";\n }\n else if (req.http.Accept-Encoding ~ \"deflate\") {\n # Next, try deflate if it is supported.\n set req.http.Accept-Encoding = \"deflate\";\n }\n else {\n # Unknown algorithm. Remove it and send unencoded.\n unset req.http.Accept-Encoding;\n }\n }\n\n # Always cache the following file types for all users.\n if (req.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n unset req.http.Cookie;\n }\n\n # Remove all cookies that Drupal doesn't need to know about. ANY remaining\n # cookie will cause the request to pass-through to a backend. For the most part\n # we always set the NO_CACHE cookie after any POST request, disabling the\n # Varnish cache temporarily. The session cookie allows all authenticated users\n # to pass through as long as they're logged in.\n #\n # 1. Append a semi-colon to the front of the cookie string.\n # 2. Remove all spaces that appear after semi-colons.\n # 3. Match the cookies we want to keep, adding the space we removed\n # previously, back. (\\1) is first matching group in the regsuball.\n # 4. Remove all other cookies, identifying them by the fact that they have\n # no space after the preceding semi-colon.\n # 5. Remove all spaces and semi-colons from the beginning and end of the\n # cookie string.\n if (req.http.Cookie) {\n set req.http.CookieCheck = \";\" + req.http.Cookie;\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"; +\", \";\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";(${VARNISH_COOKIECHECK:-SESS[a-z0-9]+|SSESS[a-z0-9]+|NO_CACHE})=\", \"; \\1=\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";[^ ][^;]*\", \"\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"^[; ]+|[; ]+$\", \"\");\n\n set req.http.Cookie = req.http.Cookie + \";\";\n\n if (req.http.CookieCheck == \"\") {\n # If there are no remaining cookies, remove the cookie header. If there\n # aren't any cookie headers, Varnish's default behavior will be to cache\n # the page.\n\n unset req.http.CookieCheck;\n unset req.http.Cookie;\n }\n else {\n # If there is any cookies left (a session or NO_CACHE cookie), do not\n # cache the page. Pass it on to Apache directly.\n unset req.http.CookieCheck;\n return (pass);\n }\n }\n\n # Cacheable, lookup in cache.\n return (hash);\n}\n\nsub vcl_pipe {\n # Support for Websockets\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n set bereq.http.connection = req.http.connection;\n }\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n # normal hit\n return (deliver);\n }\n # We have no fresh fish. Lets look at the stale ones.\n if (std.healthy(req.backend_hint)) {\n # Backend is healthy. If the object is not older then 30secs, deliver it to the client\n # and automatically create a separate backend request to warm the cache for this request.\n if (obj.ttl + 30s > 0s) {\n set req.http.grace = \"normal(limited)\";\n return (deliver);\n } else {\n # No candidate for grace. Fetch a fresh object.\n return(miss);\n }\n } else {\n # backend is sick - use full grace\n if (obj.ttl + obj.grace > 0s) {\n set req.http.grace = \"full\";\n return (deliver);\n } else {\n # no graced object.\n return (miss);\n }\n }\n}\n\nsub vcl_backend_response {\n # Allow items to be stale if needed.\n set beresp.grace = 6h;\n\n # Set ban-lurker friendly custom headers.\n set beresp.http.X-Url = bereq.url;\n set beresp.http.X-Host = bereq.http.host;\n\n # If the backend sends a X-LAGOON-VARNISH-BACKEND-BYPASS header we directly deliver\n if(beresp.http.X-LAGOON-VARNISH-BACKEND-BYPASS == \"TRUE\") {\n return (deliver);\n }\n\n # Cache 404 and 403 for 10 seconds\n if(beresp.status == 404 || beresp.status == 403) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n # Don't allow static files to set cookies.\n if (bereq.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n # beresp == Back-end response from the web server.\n unset beresp.http.set-cookie;\n unset beresp.http.Cache-Control;\n\n # If an asset would come back with statuscode 500 we only cache it for 10 seconds instead of the usual static file cache\n if (beresp.status == 500) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n set beresp.ttl = ${VARNISH_ASSETS_TTL:-2628001}s;\n set beresp.http.Cache-Control = \"public, max-age=${VARNISH_ASSETS_TTL:-2628001}\";\n set beresp.http.Expires = \"\" + (now + beresp.ttl);\n }\n\n return (deliver);\n}\n\n# Set a header to track a cache HIT\/MISS.\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Varnish-Cache = \"HIT\";\n }\n else {\n set resp.http.X-Varnish-Cache = \"MISS\";\n }\n\n # Remove ban-lurker friendly custom headers when delivering to client.\n unset resp.http.X-Url;\n unset resp.http.X-Host;\n\n # unset Cache-Tags Header by default, can be disabled with VARNISH_UNSET_HEADER_CACHE_TAGS=true\n if (!${VARNISH_UNSET_HEADER_CACHE_TAGS:-false}) {\n unset resp.http.Cache-Tags;\n }\n\n unset resp.http.X-Generator;\n unset resp.http.Server;\n # Inject information about grace\n if (req.http.grace) {\n set resp.http.X-Varnish-Grace = req.http.grace;\n }\n set resp.http.X-LAGOON = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}>\" + resp.http.X-LAGOON;\n return (deliver);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n if (req.http.X-Forwarded-Proto) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n if (req.http.HTTPS) {\n hash_data(req.http.HTTPS);\n }\n return (lookup);\n}\n\nsub vcl_synth {\n if (resp.status == 701) {\n set resp.status = 401;\n set resp.http.Content-Type = \"text\/plain; charset=utf-8\";\n synthetic({\"XMLRPC Interface is blocked due to SA-CORE-2014-004 - mail support@amazee.io if you need it.\"});\n return (deliver);\n }\n if (resp.status == 700) {\n # Set a status the client will understand\n set resp.status = 200;\n # Create our synthetic response\n synthetic(\"\");\n return(deliver);\n}\n return (deliver);\n}\n\nsub vcl_backend_error {\n # Restart the request, when we have a backend server error, to try another backend.\n # Restart max twice.\n if (bereq.retries < 2) {\n return(retry);\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<head>\n <title>Server Error<\/title>\n <style type=\"text\/css\">\n body {\n font-family: helvetica, arial, sans-serif;\n }\n img {\n margin-top: 50px;\n }\n p {\n width: 6 00px;\n margin-top: 10px\n }\n div {\n background: #ccc;\n width: 600px;\n margin: auto;\n padding: 50px;\n }\n span {\n color: #ccc\n }\n <\/style>\n<\/head>\n<body>\n <div>\n <h1>We are sorry...<\/h1>\n <p>We encountered a server-side error. This means that the problem is not with your computer or Internet connection, but rather with the website's server.<\/p>\n <p>We are currently working on solving this problem and apologise for the inconvenience.<\/p>\n <span>\n <strong>Technical Information<\/strong><br \/>\n Error \"} + beresp.status + \" \" + beresp.reason + {\"<br \/>\n XID: \"} + bereq.xid + {\"<br \/>\n <\/span>\n <\/div>\n<\/body>\n<\/html>\n\n\"} );\n return (deliver);\n}\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"d8f183e9baadbb938a2a2763d2a95e3dc0a02832","subject":"Copies builtin vcl for vcl_backend_response to deal with no-store\/private\/etc","message":"Copies builtin vcl for vcl_backend_response to deal with no-store\/private\/etc\n","repos":"amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon","old_file":"images\/varnish-drupal\/drupal.vcl","new_file":"images\/varnish-drupal\/drupal.vcl","new_contents":"","old_contents":"","returncode":0,"stderr":"unknown","license":"apache-2.0","lang":"VCL"} {"commit":"2351f7ab6395ed5ad3a0a46ddb834ffdf199c1fb","subject":"Added else keyword to if statements.","message":"Added else keyword to if statements.\n","repos":"iainmckay\/heliumd","old_file":"templates\/default.vcl","new_file":"templates\/default.vcl","new_contents":"include \"directors.vcl\";\n\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"65535\";\n}\n\nsub vcl_recv {\n set req.backend = default;\n\n {{range $index, $host := .}}\n {{if $index}}else{{end}} if (req.http.host == \"{{$host.Name}}\") {\n {{range $index, $value := $host.Paths}}\n {{if $index}}else{{end}} if (req.url ~ \"^{{$value.Path}}\") {\n set req.backend = {{$value.Director}};\n include \"\/etc\/varnish\/vcl\/{{$value.VCL}}\/recv.vcl\";\n }\n {{end}}\n }\n {{end}}\n}\n\nsub vcl_fetch {\n {{range $index, $host := .}}\n {{if $index}}else{{end}} if (req.http.host == \"{{$host.Name}}\") {\n {{range $index, $value := $host.Paths}}\n {{if $index}}else{{end}} if (req.url ~ \"^{{$value.Path}}\") {\n include \"\/etc\/varnish\/vcl\/{{$value.VCL}}\/fetch.vcl\";\n }\n {{end}}\n }\n {{end}}\n}\n\nsub vcl_deliver {\n {{range $index, $host := .}}\n {{if $index}}else{{end}} if (req.http.host == \"{{$host.Name}}\") {\n {{range $index, $value := $host.Paths}}\n {{if $index}}else{{end}} if (req.url ~ \"^{{$value.Path}}\") {\n include \"\/etc\/varnish\/vcl\/{{$value.VCL}}\/deliver.vcl\";\n }\n {{end}}\n }\n {{end}}\n}\n\nsub vcl_hit {\n {{range $index, $host := .}}\n {{if $index}}else{{end}} if (req.http.host == \"{{$host.Name}}\") {\n {{range $index, $value := $host.Paths}}\n {{if $index}}else{{end}} if (req.url ~ \"^{{$value.Path}}\") {\n include \"\/etc\/varnish\/vcl\/{{$value.VCL}}\/hit.vcl\";\n }\n {{end}}\n }\n {{end}}\n}\n\nsub vcl_miss {\n {{range $index, $host := .}}\n {{if $index}}else{{end}} if (req.http.host == \"{{$host.Name}}\") {\n {{range $index, $value := $host.Paths}}\n {{if $index}}else{{end}} if (req.url ~ \"^{{$value.Path}}\") {\n include \"\/etc\/varnish\/vcl\/{{$value.VCL}}\/miss.vcl\";\n }\n {{end}}\n }\n {{end}}\n}\n","old_contents":"include \"directors.vcl\";\n\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"65535\";\n}\n\nsub vcl_recv {\n set req.backend = default;\n\n {{range .}}\n if (req.http.host == \"{{.Name}}\") {\n {{range .Paths}}\n if (req.url ~ \"^{{.Path}}\") {\n set req.backend = {{.Director}};\n include \"\/etc\/varnish\/vcl\/{{.VCL}}\/recv.vcl\";\n }\n {{end}}\n }\n {{end}}\n}\n\nsub vcl_fetch {\n {{range .}}\n if (req.http.host == \"{{.Name}}\") {\n {{range .Paths}}\n if (req.url ~ \"^{{.Path}}\") {\n include \"\/etc\/varnish\/vcl\/{{.VCL}}\/fetch.vcl\";\n }\n {{end}}\n }\n {{end}}\n}\n\nsub vcl_deliver {\n {{range .}}\n if (req.http.host == \"{{.Name}}\") {\n {{range .Paths}}\n if (req.url ~ \"^{{.Path}}\") {\n include \"\/etc\/varnish\/vcl\/{{.VCL}}\/deliver.vcl\";\n }\n {{end}}\n }\n {{end}}\n}\n\nsub vcl_hit {\n {{range .}}\n if (req.http.host == \"^{{.Name}}\") {\n {{range .Paths}}\n if (req.url ~ \"^{{.Path}}\") {\n include \"\/etc\/varnish\/vcl\/{{.VCL}}\/hit.vcl\";\n }\n {{end}}\n }\n {{end}}\n}\n\nsub vcl_miss {\n {{range .}}\n if (req.http.host == \"^{{.Name}}\") {\n {{range .Paths}}\n if (req.url ~ \"^{{.Path}}\") {\n include \"\/etc\/varnish\/vcl\/{{.VCL}}\/miss.vcl\";\n }\n {{end}}\n }\n {{end}}\n}\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"a6a2f1431647da8f59cc2fa17eaa7247d78e41fe","subject":"Update Fastly VCL to what we are actually running on vastly.","message":"Update Fastly VCL to what we are actually running on vastly.\n","repos":"jonathan-fielding\/polyfill-service,kdzwinel\/polyfill-service,kdzwinel\/polyfill-service,jonathan-fielding\/polyfill-service,mcshaz\/polyfill-service,mcshaz\/polyfill-service,JakeChampion\/polyfill-service,mcshaz\/polyfill-service,JakeChampion\/polyfill-service,kdzwinel\/polyfill-service,jonathan-fielding\/polyfill-service","old_file":"fastly-config.vcl","new_file":"fastly-config.vcl","new_contents":"sub vcl_recv {\n#FASTLY recv\n\n\tif (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n\t\treturn(pass);\n\t}\n\n\tif (req.url ~ \"^\/v1\/polyfill\\.\" && req.url !~ \"[\\?\\&]ua=\") {\n\t\tset req.http.X-Orig-URL = req.url;\n\t\tset req.url = \"\/v1\/normalizeUa?ua=\" urlencode(req.http.User-Agent);\n\t}\n\n\treturn(lookup);\n}\n\nsub vcl_deliver {\n#FASTLY deliver\n\tif (req.url ~ \"^\/v1\/normalizeUa\" && resp.status == 200) {\n\t\tset req.http.Fastly-force-Shield = \"1\";\n\t\tif (req.http.X-Orig-URL ~ \"\\?\") {\n\t\t\tset req.url = req.http.X-Orig-URL \"&ua=\" resp.http.Normalized-User-Agent;\n\t\t} else {\n\t\t\tset req.url = req.http.X-Orig-URL \"?ua=\" resp.http.Normalized-User-Agent;\n\t\t}\n\t\trestart;\n\t} else if (req.url ~ \"^\/v1\/polyfill\\..*[\\?\\&]ua=\" && req.http.X-Orig-URL && req.http.X-Orig-URL !~ \"[\\?\\&]ua=\") {\n\t\tset resp.http.Vary = \"Accept-Encoding, User-Agent\";\n\t}\n\treturn(deliver);\n}\n","old_contents":"\nsub vcl_deliver {\n#FASTLY deliver\n\tif (resp.status == 301) {\n\t\tset req.http.Fastly-force-Shield = \"1\";\n\t\tset req.url = resp.http.Location;\n\t\trestart;\n\t}\n\treturn(deliver);\n}\n\nsub vcl_hash {\n\n\tif (req.url ~ \"^\\\/v1\\\/polyfill\\.\" && req.url !~ \"[\\?\\&]ua=\") {\n\t\tset req.hash += req.http.User-Agent;\n\t}\n\tset req.hash += req.url;\n\tset req.hash += req.http.host;\n#FASTLY hash\n\treturn (hash);\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"3725eb968fbe31b582590c19023b8bb113e802db","subject":"Import latest version from github.com\/varnish\/varnish-devicedetect\/","message":"Import latest version from github.com\/varnish\/varnish-devicedetect\/\n","repos":"mrhmouse\/Varnish-Cache,feld\/Varnish-Cache,mrhmouse\/Varnish-Cache,gquintard\/Varnish-Cache,franciscovg\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,gquintard\/Varnish-Cache,chrismoulton\/Varnish-Cache,chrismoulton\/Varnish-Cache,gquintard\/Varnish-Cache,franciscovg\/Varnish-Cache,zhoualbeart\/Varnish-Cache,zhoualbeart\/Varnish-Cache,varnish\/Varnish-Cache,alarky\/varnish-cache-doc-ja,gauthier-delacroix\/Varnish-Cache,franciscovg\/Varnish-Cache,alarky\/varnish-cache-doc-ja,franciscovg\/Varnish-Cache,zhoualbeart\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,zhoualbeart\/Varnish-Cache,zhoualbeart\/Varnish-Cache,chrismoulton\/Varnish-Cache,feld\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,alarky\/varnish-cache-doc-ja,gauthier-delacroix\/Varnish-Cache,varnish\/Varnish-Cache,varnish\/Varnish-Cache,feld\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,feld\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,mrhmouse\/Varnish-Cache,feld\/Varnish-Cache,gquintard\/Varnish-Cache,mrhmouse\/Varnish-Cache,chrismoulton\/Varnish-Cache,chrismoulton\/Varnish-Cache,alarky\/varnish-cache-doc-ja,varnish\/Varnish-Cache,franciscovg\/Varnish-Cache,mrhmouse\/Varnish-Cache,varnish\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,alarky\/varnish-cache-doc-ja,gauthier-delacroix\/Varnish-Cache","old_file":"etc\/devicedetect.vcl","new_file":"etc\/devicedetect.vcl","new_contents":"#\n# detectdevice.vcl - regex based device detection for Varnish\n# http:\/\/github.com\/varnish\/varnish-devicedetect\/\n#\n# Author: Lasse Karstensen <lasse@varnish-software.com>\n\nsub devicedetect {\n\tunset req.http.X-UA-Device;\n\tset req.http.X-UA-Device = \"pc\";\n\n\t# Handle that a cookie may override the detection alltogether.\n\tif (req.http.Cookie ~ \"(?i)X-UA-Device-force\") {\n\t\t\/* ;?? means zero or one ;, non-greedy to match the first. *\/\n\t\tset req.http.X-UA-Device = regsub(req.http.Cookie, \"(?i).*X-UA-Device-force=([^;]+);??.*\", \"\\1\");\n\t\t\/* Clean up our mess in the cookie header *\/\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|; ) *X-UA-Device-force=[^;]+;? *\", \"\\1\");\n\t\t\/* If the cookie header is now empty, or just whitespace, unset it. *\/\n\t\tif (req.http.Cookie ~ \"^ *$\") { unset req.http.Cookie; }\n\t} else {\n\t\tif (req.http.User-Agent ~ \"(?i)(ads|google|bing|msn|yandex|baidu|ro|career|)bot\" ||\n\t\t req.http.User-Agent ~ \"(?i)(baidu|jike|symantec)spider\" ||\n\t\t req.http.User-Agent ~ \"(?i)scanner\" ||\n\t\t req.http.User-Agent ~ \"(?i)(web)crawler\") {\n\t\t\tset req.http.X-UA-Device = \"bot\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ipad\") { set req.http.X-UA-Device = \"tablet-ipad\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ip(hone|od)\") { set req.http.X-UA-Device = \"mobile-iphone\"; }\n\t\t\/* how do we differ between an android phone and an android tablet?\n\t\t http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent *\/\n\t\telsif (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") { set req.http.X-UA-Device = \"mobile-android\"; }\n\t\t\/\/ android 3\/honeycomb was just about tablet-only, and any phones will probably handle a bigger page layout.\n\t\telsif (req.http.User-Agent ~ \"(?i)android 3\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\t\/\/ May very well give false positives towards android tablets. Suggestions welcome.\n\t\telsif (req.http.User-Agent ~ \"(?i)android\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\telsif (req.http.User-Agent ~ \"Mobile.+Firefox\") { set req.http.X-UA-Device = \"mobile-firefoxos\"; }\n\t\telsif (req.http.User-Agent ~ \"^HTC\" ||\n\t\t req.http.User-Agent ~ \"Fennec\" ||\n\t\t req.http.User-Agent ~ \"IEMobile\" ||\n\t\t req.http.User-Agent ~ \"BlackBerry\" ||\n\t\t req.http.User-Agent ~ \"SymbianOS.*AppleWebKit\" ||\n\t\t req.http.User-Agent ~ \"Opera Mobi\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-smartphone\";\n\t\t}\n\t\telsif (req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)^sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)^nokia\" ||\n\t\t req.http.User-Agent ~ \"(?i)^samsung\" ||\n\t\t req.http.User-Agent ~ \"(?i)^lg\" ||\n\t\t req.http.User-Agent ~ \"(?i)bada\" ||\n\t\t req.http.User-Agent ~ \"(?i)blazer\" ||\n\t\t req.http.User-Agent ~ \"(?i)cellphone\" ||\n\t\t req.http.User-Agent ~ \"(?i)iemobile\" ||\n\t\t req.http.User-Agent ~ \"(?i)midp-2.0\" ||\n\t\t req.http.User-Agent ~ \"(?i)u990\" ||\n\t\t req.http.User-Agent ~ \"(?i)netfront\" ||\n\t\t req.http.User-Agent ~ \"(?i)opera mini\" ||\n\t\t req.http.User-Agent ~ \"(?i)palm\" ||\n\t\t req.http.User-Agent ~ \"(?i)nintendo wii\" ||\n\t\t req.http.User-Agent ~ \"(?i)playstation portable\" ||\n\t\t req.http.User-Agent ~ \"(?i)portalmmm\" ||\n\t\t req.http.User-Agent ~ \"(?i)proxinet\" ||\n\t\t req.http.User-Agent ~ \"(?i)sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)windows\\ ?ce\" ||\n\t\t req.http.User-Agent ~ \"(?i)winwap\" ||\n\t\t req.http.User-Agent ~ \"(?i)eudoraweb\" ||\n\t\t req.http.User-Agent ~ \"(?i)htc\" ||\n\t\t req.http.User-Agent ~ \"(?i)240x320\" ||\n\t\t req.http.User-Agent ~ \"(?i)avantgo\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-generic\";\n\t\t}\n\t}\n}\n","old_contents":"#\n# detectdevice.vcl - regex based device detection for Varnish\n# http:\/\/github.com\/varnish\/varnish-devicedetect\/\n#\n# Author: Lasse Karstensen <lasse@varnish-software.com>\n\nsub devicedetect {\n unset req.http.X-UA-Device;\n set req.http.X-UA-Device = \"pc\";\n\n if (req.http.User-Agent ~ \"(?i)(ads|google|bing|msn|yandex|baidu|ro|career|)bot\" ||\n\treq.http.User-Agent ~ \"(?i)(baidu|symantec)spider\" ||\n\treq.http.User-Agent ~ \"(?i)scanner\" ||\n\treq.http.User-Agent ~ \"(?i)(web)crawler\") {\n\tset req.http.X-UA-Device = \"bot\"; }\n elsif (req.http.User-Agent ~ \"(?i)ip(hone|od)\") { set req.http.X-UA-Device = \"mobile-iphone\"; }\n elsif (req.http.User-Agent ~ \"(?i)ipad\") { set req.http.X-UA-Device = \"tablet-ipad\"; }\n # how do we differ between an android phone and an android tablet?\n # http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent\n elsif (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") { set req.http.X-UA-Device = \"mobile-android\"; } \n # android 3\/honeycomb was just about tablet-only, and any phones will probably handle a bigger page layout.\n elsif (req.http.User-Agent ~ \"(?i)android 3\") { set req.http.X-UA-Device = \"tablet-android\"; }\n # may very well give false positives towards android tablets. Suggestions welcome.\n elsif (req.http.User-Agent ~ \"(?i)android\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\n elsif (req.http.User-Agent ~ \"^HTC\" ||\n req.http.User-Agent ~ \"Fennec\" || \n req.http.User-Agent ~ \"IEMobile\" ||\n req.http.User-Agent ~ \"BlackBerry\" ||\n req.http.User-Agent ~ \"SymbianOS.*AppleWebKit\" ||\n req.http.User-Agent ~ \"Opera Mobi\") {\n set req.http.X-UA-Device = \"mobile-smartphone\";\n }\n elsif (req.http.User-Agent ~ \"(?i)symbian\" ||\n req.http.User-Agent ~ \"(?i)^sonyericsson\" ||\n req.http.User-Agent ~ \"(?i)^nokia\" ||\n req.http.User-Agent ~ \"(?i)^samsung\" ||\n req.http.User-Agent ~ \"(?i)^lg\" ||\n\treq.http.User-Agent ~ \"(?i)bada\" ||\n\treq.http.User-Agent ~ \"(?i)blazer\" ||\n\treq.http.User-Agent ~ \"(?i)cellphone\" ||\n\treq.http.User-Agent ~ \"(?i)iemobile\" ||\n\treq.http.User-Agent ~ \"(?i)midp-2.0\" ||\n\treq.http.User-Agent ~ \"(?i)u990\" ||\n\treq.http.User-Agent ~ \"(?i)netfront\" ||\n\treq.http.User-Agent ~ \"(?i)opera mini\" ||\n\treq.http.User-Agent ~ \"(?i)palm\" ||\n\treq.http.User-Agent ~ \"(?i)nintendo wii\" ||\n\treq.http.User-Agent ~ \"(?i)playstation portable\" ||\n\treq.http.User-Agent ~ \"(?i)portalmmm\" ||\n\treq.http.User-Agent ~ \"(?i)proxinet\" ||\n\treq.http.User-Agent ~ \"(?i)sonyericsson\" ||\n\treq.http.User-Agent ~ \"(?i)symbian\" ||\n\treq.http.User-Agent ~ \"(?i)windows\\ ?ce\" ||\n\treq.http.User-Agent ~ \"(?i)winwap\" ||\n\treq.http.User-Agent ~ \"(?i)eudoraweb\" ||\n\treq.http.User-Agent ~ \"(?i)htc\" ||\n\treq.http.User-Agent ~ \"(?i)240x320\" ||\n\treq.http.User-Agent ~ \"(?i)avantgo\") { \n set req.http.X-UA-Device = \"mobile-generic\";\n } \n # handle overrides\n if (req.http.Cookie ~ \"(i?)X-UA-Device-force\") {\n # ;?? means zero or one ;, non-greedy to match the first.\n set req.http.X-UA-Device = regsub(req.http.Cookie, \"(?i).*X-UA-Device-force=([^;]+);??.*\", \"\\1\");\n }\n}\n\n# vim: sw=4:tw=120 # meh\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"3482f043955392264f1bc739244497d984b3c216","subject":"Don't create thread unless authrep call","message":"Don't create thread unless authrep call\n","repos":"3scale\/libvmod-3scale,3scale\/libvmod-3scale","old_file":"vcl\/default_3scale_simple.vcl","new_file":"vcl\/default_3scale_simple.vcl","new_contents":"# This is a the VCL configuration file for 3scale's varnish plugin.\n# \n# Default backend definition. Set this to point to the 3scale's\n# backend. \n# \n# set the beresp.ttl in vcl_fetch to have a default global TTL\n# you can define custom TTL via regular expresions\n#\n \nbackend default {\n\t.host = \"su1.3scale.net\"; \n \t.port = \"80\";\n}\n\nimport std;\nimport threescale;\n\nsub vcl_recv {\n\n\tunset req.http.cookie;\n\tset req.http.host = \"su1.3scale.net\";\n\tset req.grace = 1s;\n\n\tif (req.request != \"GET\" && req.request != \"HEAD\") {\n \t\treturn(pass);\n \t}\n \telse {\n \t\t## GET or HEAD requests\n \t\treturn(lookup);\n \t}\n\t \n}\n\n# the hash of the request needs to be customized to remove all fields that are not \n# associated to the user\n\nsub vcl_hash {\n\n\t## remove no_body\n\tset req.http.X-url-tmp = regsub(req.url,\"[&?]no_body.[^&]*\",\"\");\n\t## remove object_id\n\tset req.http.X-url-tmp = regsub(req.http.X-url-tmp,\"[&?]object.[^&]*\",\"\");\n\t## remove object\n\tset req.http.X-url-tmp = regsub(req.http.X-url-tmp,\"[&?]object_id.[^&]*\",\"\");\n\n\thash_data(req.http.X-url-tmp);\t\n\tunset req.http.X-url-tmp;\n \treturn (hash);\n\n}\n\n#A HIT means that the request to your local cache of 3scale is still fresh and the\n#response will not have to fetch the data from the remote 3scale backend.\n#vmod_3scale plugin will send a replica of the call asynchronously to 3scale's remote\n#backend on its own\n\nsub vcl_hit {\n\n if (req.url ~ \"^\/transactions\/authrep.xml\\?\") {\n\n\t if (threescale.request_no_response(\"su1.3scale.net\",\"80\",req.url)==0) {}\n\n }\n\n}\n\n\nsub vcl_fetch {\n\tset beresp.ttl = 30s;\n}\n\n\n\n","old_contents":"# This is a the VCL configuration file for 3scale's varnish plugin.\n# \n# Default backend definition. Set this to point to the 3scale's\n# backend. \n# \n# set the beresp.ttl in vcl_fetch to have a default global TTL\n# you can define custom TTL via regular expresions\n#\n \nbackend default {\n\t.host = \"su1.3scale.net\"; \n \t.port = \"80\";\n}\n\nimport std;\nimport threescale;\n\nsub vcl_recv {\n\n\tunset req.http.cookie;\n\tset req.http.host = \"su1.3scale.net\";\n\tset req.grace = 1s;\n\n\tif (req.request != \"GET\" && req.request != \"HEAD\") {\n \t\treturn(pass);\n \t}\n \telse {\n \t\t## GET or HEAD requests\n \t\treturn(lookup);\n \t}\n\t \n}\n\n# the hash of the request needs to be customized to remove all fields that are not \n# associated to the user\n\nsub vcl_hash {\n\n\t## remove no_body\n\tset req.http.X-url-tmp = regsub(req.url,\"[&?]no_body.[^&]*\",\"\");\n\t## remove object_id\n\tset req.http.X-url-tmp = regsub(req.http.X-url-tmp,\"[&?]object.[^&]*\",\"\");\n\t## remove object\n\tset req.http.X-url-tmp = regsub(req.http.X-url-tmp,\"[&?]object_id.[^&]*\",\"\");\n\n\thash_data(req.http.X-url-tmp);\t\n\tunset req.http.X-url-tmp;\n \treturn (hash);\n\n}\n\n#A HIT means that the request to your local cache of 3scale is still fresh and the\n#response will not have to fetch the data from the remote 3scale backend.\n#vmod_3scale plugin will send a replica of the call asynchronously to 3scale's remote\n#backend on its own\n\nsub vcl_hit {\n\tif (threescale.request_no_response(\"su1.3scale.net\",\"80\",req.url)==0) {}\n}\n\n\nsub vcl_fetch {\n\tset beresp.ttl = 30s;\n}\n\n\n\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"9da204a5841bcfc08782e887127adb4708eb258e","subject":"Falling back to old strategy when header is not in the request","message":"Falling back to old strategy when header is not in the request\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets\/fetch.vcl","new_file":"etc\/vcl_snippets\/fetch.vcl","new_contents":" # If we are doing a bypass for Magento Tester return early as not to affect any headers\n if ( req.http.bypass-secret ) {\n set beresp.ttl = 0s;\n return(pass);\n }\n\n \/* handle 5XX (or any other unwanted status code) *\/\n if (beresp.status >= 500 && beresp.status < 600) {\n\n \/* deliver stale if the object is available *\/\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n # Remove Set-Cookies from responses for static content to match the cookie removal in recv.\n if (req.http.x-long-cache || req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's since those can be temporary during the site build\/index\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n set beresp.http.Cache-Control = \"max-age=0\";\n } else if (req.http.x-long-cache) {\n # Force caching for signed cached assets.\n set beresp.ttl = 31536000s;\n # Add immutable as it avoids IMS and INM revalidations\n set beresp.http.Cache-Control = \"max-age=31536000, immutable\";\n }\n }\n\n # Fix Vary Header in some cases. In 99.9% of cases Varying on User-Agent is counterproductive\n # https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleFixupVary\n if (beresp.http.Vary ~ \"User-Agent\") {\n unset beresp.http.Vary:User-Agent;\n if (beresp.http.Vary == \"\") {\n unset beresp.http.Vary;\n }\n }\n\n # All the Magento responses should emit X-Esi headers\n if (beresp.http.x-esi) {\n # enable ESI feature for Magento response by default\n esi;\n } else {\n # enable gzip for all static content except\n if ( http_status_matches(beresp.status, \"200,404\") && (beresp.http.content-type ~ \"^(application\/x\\-javascript|text\/css|text\/html|application\/javascript|text\/javascript|application\/json|application\/vnd\\.ms\\-fontobject|application\/x\\-font\\-opentype|application\/x\\-font\\-truetype|application\/x\\-font\\-ttf|application\/xml|font\/eot|font\/opentype|font\/otf|image\/svg\\+xml|image\/vnd\\.microsoft\\.icon|text\/plain)\\s*($|;)\" || req.url.ext ~ \"(?i)(css|js|html|eot|ico|otf|ttf|json)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n set beresp.http.Vary:Accept-Encoding = \"\";\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # Add Varying on Store and Content-Currency for GraphQl, X-Magento-Vary otherwise\n if (req.http.graphql) {\n set beresp.http.Vary:Store = \"\";\n set beresp.http.Vary:Content-Currency = \"\";\n } else if (beresp.http.Content-Type ~ \"text\/(html|xml)\") {\n set beresp.http.Vary:X-Magento-Vary = \"\";\n set beresp.http.Vary:Https = \"\";\n }\n\n # Just in case the Request Setting for x-pass is missing\n if (req.http.x-pass) {\n return (pass);\n }\n\n if (beresp.http.Cache-Control ~ \"private|no-cache|no-store\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # Never cache 302s\n if (beresp.status == 302) {\n return (pass);\n }\n\n if (beresp.http.x-amz-request-id) {\n # If assets are coming from Amazon they may have no Cache-Control headers which may make them uncacheable\n } else if (!beresp.http.Expires && !beresp.http.Surrogate-Control ~ \"max-age\" && !beresp.http.Cache-Control ~ \"(s-maxage|max-age)\") {\n # Varnish sets default TTL if none of the headers above are present. If not set we want to make sure we don't cache it\n set beresp.ttl = 0s;\n set beresp.cacheable = false;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\") && !req.http.x-pass ) {\n unset beresp.http.set-cookie;\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type if they are image\/script or CSS\n if (beresp.http.Content-Type ~ \"(image|script|css)\") {\n set beresp.http.Surrogate-Key = re.group.1;\n }\n }\n\n # If the cache key in the Magento response doesn't match the one that was sent in the request, don't cache under the request's key\n if (req.http.graphql && req.http.X-Magento-Cache-Id && req.http.X-Magento-Cache-Id != beresp.http.X-Magento-Cache-Id) {\n set beresp.ttl = 0s;\n set beresp.cacheable = false;\n return (deliver);\n }\n","old_contents":" # If we are doing a bypass for Magento Tester return early as not to affect any headers\n if ( req.http.bypass-secret ) {\n set beresp.ttl = 0s;\n return(pass);\n }\n\n \/* handle 5XX (or any other unwanted status code) *\/\n if (beresp.status >= 500 && beresp.status < 600) {\n\n \/* deliver stale if the object is available *\/\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n # Remove Set-Cookies from responses for static content to match the cookie removal in recv.\n if (req.http.x-long-cache || req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's since those can be temporary during the site build\/index\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n set beresp.http.Cache-Control = \"max-age=0\";\n } else if (req.http.x-long-cache) {\n # Force caching for signed cached assets.\n set beresp.ttl = 31536000s;\n # Add immutable as it avoids IMS and INM revalidations\n set beresp.http.Cache-Control = \"max-age=31536000, immutable\";\n }\n }\n\n # Fix Vary Header in some cases. In 99.9% of cases Varying on User-Agent is counterproductive\n # https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleFixupVary\n if (beresp.http.Vary ~ \"User-Agent\") {\n unset beresp.http.Vary:User-Agent;\n if (beresp.http.Vary == \"\") {\n unset beresp.http.Vary;\n }\n }\n\n # All the Magento responses should emit X-Esi headers\n if (beresp.http.x-esi) {\n # enable ESI feature for Magento response by default\n esi;\n } else {\n # enable gzip for all static content except\n if ( http_status_matches(beresp.status, \"200,404\") && (beresp.http.content-type ~ \"^(application\/x\\-javascript|text\/css|text\/html|application\/javascript|text\/javascript|application\/json|application\/vnd\\.ms\\-fontobject|application\/x\\-font\\-opentype|application\/x\\-font\\-truetype|application\/x\\-font\\-ttf|application\/xml|font\/eot|font\/opentype|font\/otf|image\/svg\\+xml|image\/vnd\\.microsoft\\.icon|text\/plain)\\s*($|;)\" || req.url.ext ~ \"(?i)(css|js|html|eot|ico|otf|ttf|json)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n set beresp.http.Vary:Accept-Encoding = \"\";\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # Add Varying on Store and Content-Currency for GraphQl, X-Magento-Vary otherwise\n if (req.http.graphql) {\n set beresp.http.Vary:Store = \"\";\n set beresp.http.Vary:Content-Currency = \"\";\n } else if (beresp.http.Content-Type ~ \"text\/(html|xml)\") {\n set beresp.http.Vary:X-Magento-Vary = \"\";\n set beresp.http.Vary:Https = \"\";\n }\n\n # Just in case the Request Setting for x-pass is missing\n if (req.http.x-pass) {\n return (pass);\n }\n\n if (beresp.http.Cache-Control ~ \"private|no-cache|no-store\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # Never cache 302s\n if (beresp.status == 302) {\n return (pass);\n }\n\n if (beresp.http.x-amz-request-id) {\n # If assets are coming from Amazon they may have no Cache-Control headers which may make them uncacheable\n } else if (!beresp.http.Expires && !beresp.http.Surrogate-Control ~ \"max-age\" && !beresp.http.Cache-Control ~ \"(s-maxage|max-age)\") {\n # Varnish sets default TTL if none of the headers above are present. If not set we want to make sure we don't cache it\n set beresp.ttl = 0s;\n set beresp.cacheable = false;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\") && !req.http.x-pass ) {\n unset beresp.http.set-cookie;\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type if they are image\/script or CSS\n if (beresp.http.Content-Type ~ \"(image|script|css)\") {\n set beresp.http.Surrogate-Key = re.group.1;\n }\n }\n\n # If the cache key in the Magento response doesn't match the one that was sent in the request, don't cache under the request's key\n if (req.http.graphql && req.http.X-Magento-Cache-Id != beresp.http.X-Magento-Cache-Id) {\n set beresp.ttl = 0s;\n set beresp.cacheable = false;\n return (deliver);\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"a152239e3b243754ec8bc89d933b814e41437497","subject":"Add immutable tag to Cache-Control on long cached objects as it avoids users having to make If-Modified-Requests. Supported by most current browsers","message":"Add immutable tag to Cache-Control on long cached objects as it avoids users having to make If-Modified-Requests. Supported by most current browsers\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets\/fetch.vcl","new_file":"etc\/vcl_snippets\/fetch.vcl","new_contents":" \/* handle 5XX (or any other unwanted status code) *\/\n if (beresp.status >= 500 && beresp.status < 600) {\n\n \/* deliver stale if the object is available *\/\n if (stale.exists) {\n return(deliver_stale);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n \/* else go to vcl_error to deliver a synthetic *\/\n error beresp.status beresp.response;\n }\n\n # Remove Set-Cookies from responses for static content\n # to match the cookie removal in recv.\n if (req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's since those can be temporary during the site build\/index\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n }\n\n }\n\n # Force caching for signed cached assets.\n if (req.http.x-long-cache) {\n set beresp.ttl = 31536000s;\n set beresp.http.Cache-Control = \"max-age=31536000, immutable\";\n }\n\n if (beresp.http.Content-Type ~ \"text\/(html|xml)\") {\n # enable ESI feature for Magento response by default\n esi;\n if (!beresp.http.Vary ~ \"X-Magento-Vary,Https\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \",X-Magento-Vary,Https\";\n } else {\n set beresp.http.Vary = \"X-Magento-Vary,Https\";\n }\n }\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content\n if (http_status_matches(beresp.status, \"200,404\") && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url.ext ~ \"(?i)(css|js|html|eot|ico|otf|ttf|json)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n if (beresp.http.Cache-Control ~ \"private|no-cache|no-store\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # Never cache 302s\n if (beresp.status == 302) {\n return (pass);\n }\n\n # Just in case the Request Setting for x-pass is missing\n if (req.http.x-pass) {\n return (pass);\n }\n\n # Varnish sets default TTL if none of these are present\n if (!beresp.http.Expires && !beresp.http.Surrogate-Control ~ \"max-age\" && !beresp.http.Cache-Control ~ \"(s-maxage|max-age)\") {\n set beresp.ttl = 0s;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\") && !req.http.x-pass ) {\n unset beresp.http.set-cookie;\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type if they are image\/script or CSS\n if (beresp.http.Content-Type ~ \"(image|script|css)\") {\n set beresp.http.Surrogate-Key = re.group.1;\n }\n return (deliver);\n }\n","old_contents":" \/* handle 5XX (or any other unwanted status code) *\/\n if (beresp.status >= 500 && beresp.status < 600) {\n\n \/* deliver stale if the object is available *\/\n if (stale.exists) {\n return(deliver_stale);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n \/* else go to vcl_error to deliver a synthetic *\/\n error beresp.status beresp.response;\n }\n\n # Remove Set-Cookies from responses for static content\n # to match the cookie removal in recv.\n if (req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's since those can be temporary during the site build\/index\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n }\n\n }\n\n # Force caching for signed cached assets.\n if (req.http.x-long-cache) {\n set beresp.ttl = 31536000s;\n set beresp.http.Cache-Control = \"max-age=31536000\";\n }\n\n if (beresp.http.Content-Type ~ \"text\/(html|xml)\") {\n # enable ESI feature for Magento response by default\n esi;\n if (!beresp.http.Vary ~ \"X-Magento-Vary,Https\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \",X-Magento-Vary,Https\";\n } else {\n set beresp.http.Vary = \"X-Magento-Vary,Https\";\n }\n }\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content\n if (http_status_matches(beresp.status, \"200,404\") && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url.ext ~ \"(?i)(css|js|html|eot|ico|otf|ttf|json)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n if (beresp.http.Cache-Control ~ \"private|no-cache|no-store\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # Never cache 302s\n if (beresp.status == 302) {\n return (pass);\n }\n\n # Just in case the Request Setting for x-pass is missing\n if (req.http.x-pass) {\n return (pass);\n }\n\n # Varnish sets default TTL if none of these are present\n if (!beresp.http.Expires && !beresp.http.Surrogate-Control ~ \"max-age\" && !beresp.http.Cache-Control ~ \"(s-maxage|max-age)\") {\n set beresp.ttl = 0s;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\") && !req.http.x-pass ) {\n unset beresp.http.set-cookie;\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type if they are image\/script or CSS\n if (beresp.http.Content-Type ~ \"(image|script|css)\") {\n set beresp.http.Surrogate-Key = re.group.1;\n }\n return (deliver);\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"6db5e37410463746b2b32183920c50f59a551fe6","subject":"Replace custom VCL logic with new Fastly features (#2148)","message":"Replace custom VCL logic with new Fastly features (#2148)\n\n* Replace custom solution for figuring out whether it is the first time the request has entered the service with the new Fastly provided solution\r\n\r\n* use new fastly.ff.visits_this_service instead of custom solution\r\n\r\nCo-authored-by: Jake Champion <0fc28a72b6b6b7b90a731ec9d7d2cc16a612eed7@googlemail.com>","repos":"JakeChampion\/polyfill-service,JakeChampion\/polyfill-service","old_file":"fastly\/vcl\/polyfill-service.vcl","new_file":"fastly\/vcl\/polyfill-service.vcl","new_contents":"sub set_backend {\n\t# The Fastly macro is inserted before the backend is selected because the\n\t# macro has the code which defines the values avaiable for req.http.Host\n\t# but it also contains a default backend which is always set to the EU. I wish we could disable the default backend setting.\n\t#FASTLY recv\n\t\n\t# Calculate the ideal region to route the request to.\n \tdeclare local var.region STRING; \n\tif (server.region ~ \"(APAC|Asia|North-America|South-America|US-Central|US-East|US-West)\") {\n\t\tset var.region = \"US\";\n \t} else {\n\t\tset var.region = \"EU\";\n \t}\n\n\t# Gather the health of the shields and origins.\n\tdeclare local var.v3_eu_is_healthy BOOL;\n\tset req.backend = F_v3_eu;\n\tset var.v3_eu_is_healthy = req.backend.healthy;\n\n\tdeclare local var.v3_us_is_healthy BOOL;\n \tset req.backend = F_v3_us;\n \tset var.v3_us_is_healthy = req.backend.healthy;\n\n \tdeclare local var.shield_eu_is_healthy BOOL;\n \tset req.backend = ssl_shield_london_city_uk;\n \tset var.shield_eu_is_healthy = req.backend.healthy;\n\n \tdeclare local var.shield_us_is_healthy BOOL;\n \tset req.backend = ssl_shield_dca_dc_us;\n \tset var.shield_us_is_healthy = req.backend.healthy;\n\n \t# Set some sort of default, that shouldn't get used.\n \tset req.backend = F_v3_eu;\n\n\tdeclare local var.EU_shield_server_name STRING;\n\tset var.EU_shield_server_name = \"LCY\";\n\n\tdeclare local var.US_shield_server_name STRING;\n\tset var.US_shield_server_name = \"DCA\";\n\n\t# Route EU requests to the nearest healthy shield or origin.\n \tif (var.region == \"EU\") {\n\t\tif (server.datacenter != var.EU_shield_server_name && fastly.ff.visits_this_service == 0 && req.restarts == 0 && var.shield_eu_is_healthy) {\n\t\t\tset req.backend = ssl_shield_london_city_uk;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} elseif (var.shield_us_is_healthy) {\n\t\t\tset req.backend = ssl_shield_dca_dc_us;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_eu;\n\t\t}\n \t}\n\n\t# Route US requests to the nearest healthy shield or origin.\n \tif (var.region == \"US\") {\n\t\tif (server.datacenter != var.US_shield_server_name && fastly.ff.visits_this_service == 0 && req.restarts == 0 && var.shield_us_is_healthy) {\n\t\t\tset req.backend = ssl_shield_dca_dc_us;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} elseif (var.shield_eu_is_healthy) {\n\t\t\tset req.backend = ssl_shield_london_city_uk;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_us;\n\t\t}\n\t}\n\n\t# Persist the decision so we can debug the result.\n \tset req.http.Debug-Backend = req.backend;\n}\n\nsub vcl_recv {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_recv;\n\t}\n\n\tif (req.method != \"GET\" && req.method != \"HEAD\" && req.method != \"OPTIONS\" && req.method != \"FASTLYPURGE\" && req.method != \"PURGE\") {\n\t\terror 911;\n\t}\n\n\tif (req.method == \"OPTIONS\") {\n\t\terror 912;\n\t}\n\n\t# Because the old service had a router which allowed any words between \/v2\/polyfill. and .js\n\tif (req.url.path ~ \"^\/v2\/polyfill(\\.\\w+)(\\.\\w+)?\" && req.url.ext == \"js\") {\n\t\tif (re.group.2) {\n\t\t\tset req.url = \"\/v2\/polyfill.min.js?\" req.url.qs;\n\t\t} else {\n\t\t\tset req.url = \"\/v2\/polyfill.js?\" req.url.qs;\n\t\t}\n\t}\n\n\t# Override the v3 defaults with the defaults of v2\n\tif (req.url ~ \"^\/v2\/polyfill(\\.min)?\\.js\") {\n\t\tset req.url = regsub(req.url, \"^\/v2\", \"\/v3\");\n\t\tset req.url = querystring.set(req.url, \"version\", \"3.25.1\");\n\t\tdeclare local var.unknown STRING;\n\t\tset var.unknown = subfield(req.url.qs, \"unknown\", \"&\");\n\t\tset req.url = querystring.set(req.url, \"unknown\", if(var.unknown != \"\", var.unknown, \"ignore\"));\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\") {\n\t\tcall normalise_querystring_parameters_for_polyfill_bundle;\n\t\t# Sort the querystring parameters alphabetically to improve chances of hitting a cached copy.\n\t\t# If querystring is empty, remove the ? from the url.\n\t\tset req.url = querystring.clean(querystring.sort(req.url));\n\t\tcall set_backend;\n\t} else {\n\t\t# The request is to an endpoint which doesn't use query parameters, let's remove them to increase our cache-hit-ratio\n\t\tset req.url = querystring.remove(req.url);\n\t\tcall set_backend;\n\t}\n\t\n\tif (req.backend == ssl_shield_dca_dc_us || req.backend == ssl_shield_london_city_uk) {\n\t\t# avoid passing stale content from Shield POP to Edge POP\n\t\tset req.max_stale_while_revalidate = 0s;\n\t} else {\n\t\tset req.http.referer_domain = if(req.http.referer ~ \"^https?\\:\\\/\\\/([^\\\/:?#]+)(?:[\\\/:?#]|$)\", re.group.1, \"\");\n\t}\n}\n\nsub vcl_hash {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_hash;\n\t}\n\n\t# We are not adding req.http.host to the hash because we want https:\/\/cdn.polyfill.io and https:\/\/polyfill.io to be a single object in the cache.\n\t# set req.hash += req.http.host;\n\tset req.hash += req.url;\n\t# We include return(hash) to stop the function falling through to the default VCL built into varnish, which for vcl_hash will add req.url and req.http.Host to the hash.\n\treturn(hash);\n}\n\nsub vcl_miss {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_miss;\n\t}\n}\n\nsub vcl_pass {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_pass;\n\t}\n}\n\nsub vcl_fetch {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_fetch;\n\t}\n\n\t# These header are only required for HTML documents.\n\tif (beresp.http.Content-Type ~ \"text\/html\") {\n\t\t# Enables the cross-site scripting filter built into most modern web browsers.\n\t\tset beresp.http.X-XSS-Protection = \"1; mode=block\";\t\n\t}\n\t# Prevents MIME-sniffing a response away from the declared content type.\n\tset beresp.http.X-Content-Type-Options = \"nosniff\";\n\n\t# Ensure the site is only served over HTTPS and reduce the chances of someone performing a MITM attack.\n\tset beresp.http.Strict-Transport-Security = \"max-age=31536000; includeSubdomains; preload\";\n\n\t# The Referrer-Policy header governs which referrer information, sent in the Referer header, should be included with requests made.\n\t# Send a full URL when performing a same-origin request, but only send the origin of the document for other cases.\n\tset beresp.http.Referrer-Policy = \"origin-when-cross-origin\";\n\n\t# Enable purging of all objects in the Fastly cache by issuing a purge with the key \"polyfill-service\".\n\tif (beresp.http.Surrogate-Key !~ \"\\bpolyfill-service\\b\") {\n\t\tset beresp.http.Surrogate-Key = if(beresp.http.Surrogate-Key, beresp.http.Surrogate-Key \" polyfill-service\", \"polyfill-service\");\n\t}\n\n\tset beresp.http.Timing-Allow-Origin = \"*\";\n\n\tif (req.http.Normalized-User-Agent) {\n\t\tset beresp.http.Normalized-User-Agent = req.http.Normalized-User-Agent;\n\t\tset beresp.http.Detected-User-Agent = req.http.useragent_parser_family \"\/\" req.http.useragent_parser_major \".\" req.http.useragent_parser_minor \".\" req.http.useragent_parser_patch;\n\t}\n}\n\nsub vcl_deliver {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_deliver;\n\t}\n\n\tset req.http.Fastly-Force-Shield = \"yes\";\n\n\t# Allow cross origin GET, HEAD, and OPTIONS requests to be made.\n\tif (req.http.Origin) {\n\t\tset resp.http.Access-Control-Allow-Origin = \"*\";\n\t\tset resp.http.Access-Control-Allow-Methods = \"GET,HEAD,OPTIONS\";\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\" && fastly.ff.visits_this_service == 0 && req.restarts == 0 && req.backend != ssl_shield_dca_dc_us && req.backend != ssl_shield_london_city_uk) {\n\t\t# Need to add \"Vary: User-Agent\" in after vcl_fetch to avoid the \n\t\t# \"Vary: User-Agent\" entering the Varnish cache.\n\t\t# We need \"Vary: User-Agent\" in the browser cache because a browser\n\t\t# may update itself to a version which needs different polyfills\n\t\t# So we need to have it ignore the browser cached bundle when the user-agent changes.\n\t\tset resp.http.Vary = \"User-Agent, Accept-Encoding\";\n\t}\n\n\tif (resp.status == 304) {\n\t\tset resp.http.Age = \"0\";\n\t}\n\n\tadd resp.http.Server-Timing = fastly_info.state {\", fastly;desc=\"Edge time\";dur=\"} time.elapsed.msec;\n\n\tif (req.http.Fastly-Debug) {\n\t\tset resp.http.Debug-Backend = req.http.Debug-Backend;\n\t\tset resp.http.Debug-Host = req.http.Host;\n\t\tset resp.http.Debug-Fastly-Restarts = req.restarts;\n\t\tset resp.http.Debug-Orig-URL = req.http.Orig-URL;\n\t\tset resp.http.Debug-VCL-Route = req.http.X-VCL-Route;\n\t\tset resp.http.useragent_parser_family = req.http.useragent_parser_family;\n\t\tset resp.http.useragent_parser_major = req.http.useragent_parser_major;\n\t\tset resp.http.useragent_parser_minor = req.http.useragent_parser_minor;\n\t\tset resp.http.useragent_parser_patch = req.http.useragent_parser_patch;\n\t} else {\n\t\tunset resp.http.Server;\n\t\tunset resp.http.Via;\n\t\tunset resp.http.X-Cache;\n\t\tunset resp.http.X-Cache-Hits;\n\t\tunset resp.http.X-Served-By;\n\t\tunset resp.http.X-Timer;\n\t\tunset resp.http.Fastly-Restarts;\n\t\tunset resp.http.X-PreFetch-Pass;\n\t\tunset resp.http.X-PreFetch-Miss;\n\t\tunset resp.http.X-PostFetch;\n\t}\n}\n\nsub vcl_error {\n\tif (obj.status == 911) {\n\t\tset obj.status = 405;\n\t\tset obj.response = \"METHOD NOT ALLOWED\";\n\t\tset obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n\t\tset obj.http.Cache-Control = \"private, no-store\";\n\t\tsynthetic req.method \" METHOD NOT ALLOWED\";\n\t\treturn (deliver);\n\t}\n\tif (obj.status == 912) {\n\t\tset obj.status = 200;\n\t\tset obj.response = \"OK\";\n\t\tset obj.http.Allow = \"OPTIONS, GET, HEAD\";\n\t\treturn (deliver);\n\t}\n}\n","old_contents":"sub set_backend {\n\t# The Fastly macro is inserted before the backend is selected because the\n\t# macro has the code which defines the values avaiable for req.http.Host\n\t# but it also contains a default backend which is always set to the EU. I wish we could disable the default backend setting.\n\t#FASTLY recv\n\t\n\t# Calculate the ideal region to route the request to.\n \tdeclare local var.region STRING; \n\tif (server.region ~ \"(APAC|Asia|North-America|South-America|US-Central|US-East|US-West)\") {\n\t\tset var.region = \"US\";\n \t} else {\n\t\tset var.region = \"EU\";\n \t}\n\n\t# Gather the health of the shields and origins.\n\tdeclare local var.v3_eu_is_healthy BOOL;\n\tset req.backend = F_v3_eu;\n\tset var.v3_eu_is_healthy = req.backend.healthy;\n\n\tdeclare local var.v3_us_is_healthy BOOL;\n \tset req.backend = F_v3_us;\n \tset var.v3_us_is_healthy = req.backend.healthy;\n\n \tdeclare local var.shield_eu_is_healthy BOOL;\n \tset req.backend = ssl_shield_london_city_uk;\n \tset var.shield_eu_is_healthy = req.backend.healthy;\n\n \tdeclare local var.shield_us_is_healthy BOOL;\n \tset req.backend = ssl_shield_dca_dc_us;\n \tset var.shield_us_is_healthy = req.backend.healthy;\n\n \t# Set some sort of default, that shouldn't get used.\n \tset req.backend = F_v3_eu;\n\n\tdeclare local var.EU_shield_server_name STRING;\n\tset var.EU_shield_server_name = \"LCY\";\n\n\tdeclare local var.US_shield_server_name STRING;\n\tset var.US_shield_server_name = \"DCA\";\n\n\t# Route EU requests to the nearest healthy shield or origin.\n \tif (var.region == \"EU\") {\n\t\tif (server.datacenter != var.EU_shield_server_name && req.http.Request_Came_From_Shield != var.EU_shield_server_name && var.shield_eu_is_healthy) {\n\t\t\tset req.backend = ssl_shield_london_city_uk;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} elseif (var.shield_us_is_healthy) {\n\t\t\tset req.backend = ssl_shield_dca_dc_us;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_eu;\n\t\t}\n \t}\n\n\t# Route US requests to the nearest healthy shield or origin.\n \tif (var.region == \"US\") {\n\t\tif (server.datacenter != var.US_shield_server_name && req.http.Request_Came_From_Shield != var.US_shield_server_name && var.shield_us_is_healthy) {\n\t\t\tset req.backend = ssl_shield_dca_dc_us;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} elseif (var.shield_eu_is_healthy) {\n\t\t\tset req.backend = ssl_shield_london_city_uk;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_us;\n\t\t}\n\t}\n\n\t# Persist the decision so we can debug the result.\n \tset req.http.Debug-Backend = req.backend;\n}\n\nsub vcl_recv {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_recv;\n\t}\n\n\tif (req.method != \"GET\" && req.method != \"HEAD\" && req.method != \"OPTIONS\" && req.method != \"FASTLYPURGE\" && req.method != \"PURGE\") {\n\t\terror 911;\n\t}\n\n\tif (req.method == \"OPTIONS\") {\n\t\terror 912;\n\t}\n\n\t# Because the old service had a router which allowed any words between \/v2\/polyfill. and .js\n\tif (req.url.path ~ \"^\/v2\/polyfill(\\.\\w+)(\\.\\w+)?\" && req.url.ext == \"js\") {\n\t\tif (re.group.2) {\n\t\t\tset req.url = \"\/v2\/polyfill.min.js?\" req.url.qs;\n\t\t} else {\n\t\t\tset req.url = \"\/v2\/polyfill.js?\" req.url.qs;\n\t\t}\n\t}\n\n\t# Override the v3 defaults with the defaults of v2\n\tif (req.url ~ \"^\/v2\/polyfill(\\.min)?\\.js\") {\n\t\tset req.url = regsub(req.url, \"^\/v2\", \"\/v3\");\n\t\tset req.url = querystring.set(req.url, \"version\", \"3.25.1\");\n\t\tdeclare local var.unknown STRING;\n\t\tset var.unknown = subfield(req.url.qs, \"unknown\", \"&\");\n\t\tset req.url = querystring.set(req.url, \"unknown\", if(var.unknown != \"\", var.unknown, \"ignore\"));\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\") {\n\t\tcall normalise_querystring_parameters_for_polyfill_bundle;\n\t\t# Sort the querystring parameters alphabetically to improve chances of hitting a cached copy.\n\t\t# If querystring is empty, remove the ? from the url.\n\t\tset req.url = querystring.clean(querystring.sort(req.url));\n\t\tcall set_backend;\n\t} else {\n\t\t# The request is to an endpoint which doesn't use query parameters, let's remove them to increase our cache-hit-ratio\n\t\tset req.url = querystring.remove(req.url);\n\t\tcall set_backend;\n\t}\n\t\n\tif (req.backend == ssl_shield_dca_dc_us || req.backend == ssl_shield_london_city_uk) {\n\t\t# avoid passing stale content from Shield POP to Edge POP\n\t\tset req.max_stale_while_revalidate = 0s;\n\t} else {\n\t\tset req.http.referer_domain = if(req.http.referer ~ \"^https?\\:\\\/\\\/([^\\\/:?#]+)(?:[\\\/:?#]|$)\", re.group.1, \"\");\n\t}\n}\n\nsub vcl_hash {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_hash;\n\t}\n\n\t# We are not adding req.http.host to the hash because we want https:\/\/cdn.polyfill.io and https:\/\/polyfill.io to be a single object in the cache.\n\t# set req.hash += req.http.host;\n\tset req.hash += req.url;\n\t# We include return(hash) to stop the function falling through to the default VCL built into varnish, which for vcl_hash will add req.url and req.http.Host to the hash.\n\treturn(hash);\n}\n\n\nsub shielding_header {\n\tif (req.backend == ssl_shield_dca_dc_us) {\n\t\tset req.http.Request_Came_From_Shield = server.datacenter;\n\t} elsif (req.backend == ssl_shield_london_city_uk) {\n\t\tset req.http.Request_Came_From_Shield = server.datacenter;\n\t}\n}\n\nsub vcl_miss {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_miss;\n\t}\n\tcall shielding_header;\n}\n\nsub vcl_pass {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_pass;\n\t}\n\tcall shielding_header;\n}\n\nsub vcl_fetch {\n\tset beresp.http.Request_Came_From_Shield = req.http.Request_Came_From_Shield;\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_fetch;\n\t}\n\n\t# These header are only required for HTML documents.\n\tif (beresp.http.Content-Type ~ \"text\/html\") {\n\t\t# Enables the cross-site scripting filter built into most modern web browsers.\n\t\tset beresp.http.X-XSS-Protection = \"1; mode=block\";\t\n\t}\n\t# Prevents MIME-sniffing a response away from the declared content type.\n\tset beresp.http.X-Content-Type-Options = \"nosniff\";\n\n\t# Ensure the site is only served over HTTPS and reduce the chances of someone performing a MITM attack.\n\tset beresp.http.Strict-Transport-Security = \"max-age=31536000; includeSubdomains; preload\";\n\n\t# The Referrer-Policy header governs which referrer information, sent in the Referer header, should be included with requests made.\n\t# Send a full URL when performing a same-origin request, but only send the origin of the document for other cases.\n\tset beresp.http.Referrer-Policy = \"origin-when-cross-origin\";\n\n\t# Enable purging of all objects in the Fastly cache by issuing a purge with the key \"polyfill-service\".\n\tif (beresp.http.Surrogate-Key !~ \"\\bpolyfill-service\\b\") {\n\t\tset beresp.http.Surrogate-Key = if(beresp.http.Surrogate-Key, beresp.http.Surrogate-Key \" polyfill-service\", \"polyfill-service\");\n\t}\n\n\tset beresp.http.Timing-Allow-Origin = \"*\";\n\n\tif (req.http.Normalized-User-Agent) {\n\t\tset beresp.http.Normalized-User-Agent = req.http.Normalized-User-Agent;\n\t\tset beresp.http.Detected-User-Agent = req.http.useragent_parser_family \"\/\" req.http.useragent_parser_major \".\" req.http.useragent_parser_minor \".\" req.http.useragent_parser_patch;\n\t}\n}\n\nsub vcl_deliver {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_deliver;\n\t}\n\n\tset req.http.Fastly-Force-Shield = \"yes\";\n\n\t# Allow cross origin GET, HEAD, and OPTIONS requests to be made.\n\tif (req.http.Origin) {\n\t\tset resp.http.Access-Control-Allow-Origin = \"*\";\n\t\tset resp.http.Access-Control-Allow-Methods = \"GET,HEAD,OPTIONS\";\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\" && !resp.http.Request_Came_From_Shield && req.backend != ssl_shield_dca_dc_us && req.backend != ssl_shield_london_city_uk) {\n\t\t# Need to add \"Vary: User-Agent\" in after vcl_fetch to avoid the \n\t\t# \"Vary: User-Agent\" entering the Varnish cache.\n\t\t# We need \"Vary: User-Agent\" in the browser cache because a browser\n\t\t# may update itself to a version which needs different polyfills\n\t\t# So we need to have it ignore the browser cached bundle when the user-agent changes.\n\t\tset resp.http.Vary = \"User-Agent, Accept-Encoding\";\n\t}\n\n\tif (resp.status == 304) {\n\t\tset resp.http.Age = \"0\";\n\t}\n\n\tadd resp.http.Server-Timing = fastly_info.state {\", fastly;desc=\"Edge time\";dur=\"} time.elapsed.msec;\n\n\tif (req.http.Fastly-Debug) {\n\t\tset resp.http.Debug-Backend = req.http.Debug-Backend;\n\t\tset resp.http.Debug-Host = req.http.Host;\n\t\tset resp.http.Debug-Fastly-Restarts = req.restarts;\n\t\tset resp.http.Debug-Orig-URL = req.http.Orig-URL;\n\t\tset resp.http.Debug-VCL-Route = req.http.X-VCL-Route;\n\t\tset resp.http.useragent_parser_family = req.http.useragent_parser_family;\n\t\tset resp.http.useragent_parser_major = req.http.useragent_parser_major;\n\t\tset resp.http.useragent_parser_minor = req.http.useragent_parser_minor;\n\t\tset resp.http.useragent_parser_patch = req.http.useragent_parser_patch;\n\t} else {\n\t\tunset resp.http.Server;\n\t\tunset resp.http.Via;\n\t\tunset resp.http.X-Cache;\n\t\tunset resp.http.X-Cache-Hits;\n\t\tunset resp.http.X-Served-By;\n\t\tunset resp.http.X-Timer;\n\t\tunset resp.http.Fastly-Restarts;\n\t\tunset resp.http.X-PreFetch-Pass;\n\t\tunset resp.http.X-PreFetch-Miss;\n\t\tunset resp.http.X-PostFetch;\n\t}\n}\n\nsub vcl_error {\n\tif (obj.status == 911) {\n\t\tset obj.status = 405;\n\t\tset obj.response = \"METHOD NOT ALLOWED\";\n\t\tset obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n\t\tset obj.http.Cache-Control = \"private, no-store\";\n\t\tsynthetic req.method \" METHOD NOT ALLOWED\";\n\t\treturn (deliver);\n\t}\n\tif (obj.status == 912) {\n\t\tset obj.status = 200;\n\t\tset obj.response = \"OK\";\n\t\tset obj.http.Allow = \"OPTIONS, GET, HEAD\";\n\t\treturn (deliver);\n\t}\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"a4396665feb8e00d6ed703dd9c924d6c93c4f9aa","subject":"Compatibility with images served from S3 directly","message":"Compatibility with images served from S3 directly","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets\/fetch.vcl","new_file":"etc\/vcl_snippets\/fetch.vcl","new_contents":" \/* handle 5XX (or any other unwanted status code) *\/\n if (beresp.status >= 500 && beresp.status < 600) {\n\n \/* deliver stale if the object is available *\/\n if (stale.exists) {\n return(deliver_stale);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n }\n\n # Remove Set-Cookies from responses for static content to match the cookie removal in recv.\n if (req.http.x-long-cache || req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's since those can be temporary during the site build\/index\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n set beresp.http.Cache-Control = \"max-age=0\";\n } else if (req.http.x-long-cache) {\n # Force caching for signed cached assets.\n set beresp.ttl = 31536000s;\n # Add immutable as it avoids IMS and INM revalidations\n set beresp.http.Cache-Control = \"max-age=31536000, immutable\";\n }\n }\n\n # Fix Vary Header in some cases. In 99.9% of cases Varying on User-Agent is counterproductive\n # https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleFixupVary\n if (beresp.http.Vary ~ \"User-Agent\") {\n unset beresp.http.Vary:User-Agent;\n if (beresp.http.Vary == \"\") {\n unset beresp.http.Vary;\n }\n }\n\n # All the Magento responses should emit X-Esi headers\n if (beresp.http.x-esi) {\n # enable ESI feature for Magento response by default\n esi;\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content except\n if ( http_status_matches(beresp.status, \"200,404\") && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|text\\\/html|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url.ext ~ \"(?i)(css|js|html|eot|ico|otf|ttf|json)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # Add Varying on X-Magento-Vary\n if (beresp.http.Content-Type ~ \"text\/(html|xml)\" || req.http.graphql) {\n set beresp.http.Vary:X-Magento-Vary = \"\";\n set beresp.http.Vary:Https = \"\";\n }\n\n # Just in case the Request Setting for x-pass is missing\n if (req.http.x-pass) {\n return (pass);\n }\n\n if (beresp.http.Cache-Control ~ \"private|no-cache|no-store\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # Never cache 302s\n if (beresp.status == 302) {\n return (pass);\n }\n\n if (beresp.http.x-amz-request-id) {\n # media retrieved from Amazon S3 should be cacheable even with Shielding enabled\n } else if (!beresp.http.Expires && !beresp.http.Surrogate-Control ~ \"max-age\" && !beresp.http.Cache-Control ~ \"(s-maxage|max-age)\") {\n # Varnish sets default TTL if none of the headers above are present. If not set we want to make sure we don't cache it\n set beresp.ttl = 0s;\n set beresp.cacheable = false;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\") && !req.http.x-pass ) {\n unset beresp.http.set-cookie;\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type if they are image\/script or CSS\n if (beresp.http.Content-Type ~ \"(image|script|css)\") {\n set beresp.http.Surrogate-Key = re.group.1;\n }\n }\n","old_contents":" \/* handle 5XX (or any other unwanted status code) *\/\n if (beresp.status >= 500 && beresp.status < 600) {\n\n \/* deliver stale if the object is available *\/\n if (stale.exists) {\n return(deliver_stale);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n }\n\n # Remove Set-Cookies from responses for static content to match the cookie removal in recv.\n if (req.http.x-long-cache || req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's since those can be temporary during the site build\/index\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n set beresp.http.Cache-Control = \"max-age=0\";\n } else if (req.http.x-long-cache) {\n # Force caching for signed cached assets.\n set beresp.ttl = 31536000s;\n # Add immutable as it avoids IMS and INM revalidations\n set beresp.http.Cache-Control = \"max-age=31536000, immutable\";\n }\n }\n\n # Fix Vary Header in some cases. In 99.9% of cases Varying on User-Agent is counterproductive\n # https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleFixupVary\n if (beresp.http.Vary ~ \"User-Agent\") {\n unset beresp.http.Vary:User-Agent;\n if (beresp.http.Vary == \"\") {\n unset beresp.http.Vary;\n }\n }\n\n # All the Magento responses should emit X-Esi headers\n if (beresp.http.x-esi) {\n # enable ESI feature for Magento response by default\n esi;\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content except\n if ( http_status_matches(beresp.status, \"200,404\") && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|text\\\/html|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url.ext ~ \"(?i)(css|js|html|eot|ico|otf|ttf|json)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # Add Varying on X-Magento-Vary\n if (beresp.http.Content-Type ~ \"text\/(html|xml)\" || req.http.graphql) {\n set beresp.http.Vary:X-Magento-Vary = \"\";\n set beresp.http.Vary:Https = \"\";\n }\n\n # Just in case the Request Setting for x-pass is missing\n if (req.http.x-pass) {\n return (pass);\n }\n\n if (beresp.http.Cache-Control ~ \"private|no-cache|no-store\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # Never cache 302s\n if (beresp.status == 302) {\n return (pass);\n }\n\n # Varnish sets default TTL if none of these are present. If not set we want to make sure we don't cache it\n if (!beresp.http.Expires && !beresp.http.Surrogate-Control ~ \"max-age\" && !beresp.http.Cache-Control ~ \"(s-maxage|max-age)\") {\n set beresp.ttl = 0s;\n set beresp.cacheable = false;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\") && !req.http.x-pass ) {\n unset beresp.http.set-cookie;\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type if they are image\/script or CSS\n if (beresp.http.Content-Type ~ \"(image|script|css)\") {\n set beresp.http.Surrogate-Key = re.group.1;\n }\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"933fc103a6844a1454459e0b58cbcceb3e83b0fa","subject":"IT WORKS! :D","message":"IT WORKS! :D\n","repos":"rhargreaves\/fastly-vcl-experiments,rhargreaves\/fastly-vcl-experiments","old_file":"oauth_sig_check.vcl","new_file":"oauth_sig_check.vcl","new_contents":"\ntable consumer_secrets {\n\t\"foo\": \"super_secret\"\n}\n\nsub vcl_recv {\n#FASTLY recv\n#DEPLOY recv\n\tset req.url = boltsort.sort(req.url);\n\tset req.http.X-Consumer-Key = regsub(req.url, \"(?i).*oauth_consumer_key=([^&]*).*\", \"\\1\");\n\tset req.http.X-Consumer-Secret = table.lookup(consumer_secrets, req.http.X-Consumer-Key);\n\tset req.http.X-Provided-Signature = regsub(req.url, \"(?i).*oauth_signature=([^&]*).*\", \"\\1\");\n\tset req.http.X-Parameters = regsub(req.url, \".*\\?\", \"\");\n\tset req.http.X-Parameters = regsub(req.http.X-Parameters, \"&oauth_signature=[^&]*\", \"\");\n\t\n\tset req.http.X-Base-String-Uri = \n\t\tif(req.http.Fastly-SSL,\"https\",\"http\") \n\t\t\":\/\/\" \n\t\tstd.tolower(req.http.host)\n\t\treq.url.path;\n\n\t# Construct according to https:\/\/tools.ietf.org\/html\/rfc5849#page-18\n\tset req.http.X-Signature-Base-String = \n\t\treq.request\n\t\t\"&\"\n\t\turlencode(req.http.X-Base-String-Uri)\n\t\t\"&\"\n\t\turlencode(req.http.X-Parameters);\n\n\tset req.http.X-Calculated-Signature = urlencode(digest.hmac_sha1_base64(\n\t\treq.http.X-Consumer-Secret \"&\", req.http.X-Signature-Base-String));\n\n\tif(req.http.X-Provided-Signature != req.http.X-Calculated-Signature) {\n\t\terror 401 \"Invalid OAuth signature\";\n\t}\n\n\n\treturn(lookup);\n}\n\nsub vcl_fetch {\n#FASTLY fetch\n\treturn(deliver);\n}\n\nsub vcl_hit {\n#FASTLY hit\n\tif (!obj.cacheable) {\n\t\treturn(pass);\n\t}\n\treturn(deliver);\n}\n\nsub vcl_miss {\n#FASTLY miss\n\treturn(fetch);\n}\n\nsub vcl_deliver{\n#FASTLY deliver\n\tset resp.http.X-Consumer-Key = req.http.X-Consumer-Key;\n\tset resp.http.X-Consumer-Secret = req.http.X-Consumer-Secret;\n\tset resp.http.X-Provided-Signature = req.http.X-Provided-Signature;\n\tset resp.http.X-Calculated-Signature = req.http.X-Calculated-Signature;\n\tset resp.http.X-Parameters = req.http.X-Parameters;\n\tset resp.http.X-Base-String-Uri = req.http.X-Base-String-Uri;\n\tset resp.http.X-Signature-Base-String = req.http.X-Signature-Base-String;\n\treturn(deliver);\n}\n\nsub vcl_error {\n#FASTLY error\n#DEPLOY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n","old_contents":"\ntable consumer_secrets {\n\t\"foo\": \"super_secret\"\n}\n\nsub vcl_recv {\n#FASTLY recv\n#DEPLOY recv\n\tset req.url = boltsort.sort(req.url);\n\tset req.http.X-Consumer-Key = regsub(req.url, \".*\\?.*oauth_consumer_key=(.*?)(&|$)\", \"\\1\");\n\tset req.http.X-Consumer-Secret = table.lookup(consumer_secrets, req.http.X-Consumer-Key);\n\tset req.http.X-Provided-Signature = regsub(req.url, \".*\\?.*oauth_signature=(.*?)(&|$)\", \"\\1\");\n\tset req.http.X-Parameters = regsub(req.url, \".*\\?\", \"\");\n\tset req.http.X-Parameters = regsub(req.http.X-Parameters, \"&oauth_signature=[^&]*\", \"\");\n\t\n\tset req.http.X-Base-String-Uri = \n\t\tif(req.http.Fastly-SSL,\"https\",\"http\") \n\t\t\":\/\/\" \n\t\tstd.tolower(req.http.host)\n\t\treq.url.path;\n\n\t# Construct according to https:\/\/tools.ietf.org\/html\/rfc5849#page-18\n\tset req.http.X-Signature-Base-String = \n\t\treq.request\n\t\t\"&\"\n\t\treq.http.X-Base-String-Uri\n\t\t\"&\"\n\t\treq.http.X-Parameters;\n\n\tset req.http.X-Calculated-Signature = urlencode(digest.hmac_sha1_base64(\n\t\treq.http.X-Consumer-Secret \"&\", req.http.X-Signature-Base-String));\n\n\tif(req.http.X-Provided-Signature != req.http.X-Calculated-Signature) {\n\t\terror 401 \"Invalid OAuth signature\";\n\t}\n\n\n\treturn(lookup);\n}\n\nsub vcl_fetch {\n#FASTLY fetch\n\treturn(deliver);\n}\n\nsub vcl_hit {\n#FASTLY hit\n\tif (!obj.cacheable) {\n\t\treturn(pass);\n\t}\n\treturn(deliver);\n}\n\nsub vcl_miss {\n#FASTLY miss\n\treturn(fetch);\n}\n\nsub vcl_deliver{\n#FASTLY deliver\n\tset resp.http.X-Consumer-Key = req.http.X-Consumer-Key;\n\tset resp.http.X-Consumer-Secret = req.http.X-Consumer-Secret;\n\tset resp.http.X-Provided-Signature = req.http.X-Provided-Signature;\n\tset resp.http.X-Calculated-Signature = req.http.X-Calculated-Signature;\n\tset resp.http.X-Parameters = req.http.X-Parameters;\n\tset resp.http.X-Base-String-Uri = req.http.X-Base-String-Uri;\n\tset resp.http.X-Signature-Base-String = req.http.X-Signature-Base-String;\n\treturn(deliver);\n}\n\nsub vcl_error {\n#FASTLY error\n#DEPLOY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"ca4b05a7fdd5a5667bdd5f6e72380d1ce27adaf0","subject":"Some of the maintenance files may be in \/pub\/error. Excluded them from blocking during maintenance","message":"Some of the maintenance files may be in \/pub\/error. Excluded them from blocking during maintenance\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets\/recv.vcl","new_file":"etc\/vcl_snippets\/recv.vcl","new_contents":" # When using Magento tester to test whether your site is configured properly\n # this uses a bypass secret. By default we will use service ID as the bypass secret\n # however user can override this by defining a bypass_secret key in the\n # magentomodule_config edge dictionary\n if ( req.http.bypass-secret ) {\n declare local var.bypass-secret STRING;\n set var.bypass-secret = table.lookup(magentomodule_config, \"bypass_secret\", \"NONE\");\n if ( var.bypass-secret == req.http.bypass-secret ) {\n set req.http.x-pass = \"1\";\n set var.fastly_req_do_shield = false;\n set req.hash_always_miss = true;\n } else if ( var.bypass-secret == \"NONE\" && req.http.bypass-secret == req.service_id ) {\n set req.http.x-pass = \"1\";\n set var.fastly_req_do_shield = false;\n set req.hash_always_miss = true;\n } else {\n error 403 \"Bypass Secret incorrect\";\n }\n\n if (req.url == \"\/fastly-io-tester\") {\n # IO won't work for PASS requests\n unset req.http.x-pass;\n # IO requires shielding\n set var.fastly_req_do_shield = true;\n set req.hash_always_miss = true;\n set req.http.X-Fastly-Imageopto-Api = \"fastly\";\n }\n }\n\n # VCL required to support maintenance mode. Don't maintenance mode admin pages and supporting assets\n if (table.lookup(magentomodule_config, \"allow_super_users_during_maint\", \"0\") == \"1\" &&\n !req.http.Fastly-Client-Ip ~ maint_allowlist &&\n !req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" &&\n !req.url ~ \"^\/pub\/(static|error)\/\") {\n\n # If we end up here after a restart and there is a ResponseObject it means we got here after error\n # page VCL restart. We shouldn't touch it. Otherwise return a plain 503 error page\n if ( req.restarts > 0 && req.http.ResponseObject ) {\n set req.http.ResponseObject = \"970\";\n } else {\n error 503 \"Maintenance mode\";\n }\n }\n\n unset req.http.x-long-cache;\n\n # We want to force long cache times on any of the versioned assets\n if (req.url.path ~ \"^\/static\/version\\d*\/\") {\n set req.http.x-long-cache = \"1\";\n }\n\n # User's Cookie may contain some Magento Vary items we should vary on\n if (req.http.cookie:X-Magento-Vary) {\n set req.http.X-Magento-Vary = req.http.cookie:X-Magento-Vary;\n } else {\n unset req.http.X-Magento-Vary;\n }\n\n ############################################################################################################\n # Following code block controls purge by URL. By default we want to protect all URL purges. In general this\n # is addressed by adding Fastly-Purge-Requires-Auth request header in vcl_recv however this runs the risk of\n # exposing API tokens if user attempts to purge non-https URLs. For this reason inside the Magento module\n # we use X-Purge-Token. Unfortunately this breaks purge from the Fastly UI. Therefore in the next code block\n # we check for presence of X-Purge-Token. If it's not present we force the Fastly-Purge-Requires-Auth\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n if (req.http.X-Purge-Token && req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n } else {\n error 403;\n }\n } else {\n set req.http.Fastly-Purge-Requires-Auth = \"1\";\n }\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (fastly.ff.visits_this_service > 0) {\n # disable ESI processing on Origin Shield\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Make sure we lookup end user geo not shielding. More at https:\/\/docs.fastly.com\/vcl\/geolocation\/#using-geographic-variables-with-shielding\n set client.geo.ip_override = req.http.Fastly-Client-IP;\n\n if ((req.request == \"GET\" || req.request == \"HEAD\") && req.url.path ~ \"\/graphql\" && req.url.qs ~ \"query=\") {\n set req.http.graphql = \"1\";\n } else {\n unset req.http.graphql;\n }\n\n # geoip lookup\n if (req.url.path ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie:X-Magento-Vary || req.http.cookie:form_key) {\n error 980 \"GeoIP already processed\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url.qs !~ \"country_code=\" ) {\n set req.url = querystring.set(req.url, \"country_code\", if ( req.http.geo_override, req.http.geo_override, client.geo.country_code));\n }\n }\n } else if ( req.url.path !~ \"\/graphql\" ) {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking by default\n # and allow custom parameters to be set. List of parameters is configurable in admin\n set req.http.Magento-Original-URL = req.url;\n # Change the list of ignored parameters by configuring them in the Advanced section\n set req.url = querystring.regfilter(req.url, \"^(####QUERY_PARAMETERS####)$\");\n }\n\n # Don't allow clients to force a pass\n if (req.restarts == 0) {\n unset req.http.x-pass;\n unset req.http.Rate-Limit;\n unset req.http.magento-admin-path;\n }\n\n # Pass on checkout URLs. Because it's a snippet we want to execute this after backend selection so we handle it\n # in the request condition\n if (!req.http.x-long-cache && req.url ~ \"\/(checkout|customer\/section\/load)\") {\n set req.http.x-pass = \"1\";\n # Pass all admin actions\n # ####ADMIN_PATH#### is replaced with value of frontName from app\/etc\/env.php\n } else if ( req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" ) {\n set req.http.x-pass = \"1\";\n set req.http.magento-admin-path = \"1\";\n } else {\n # Sort the query arguments to increase cache hit ratio with query arguments that\n # may be out od order. In case you want to restore the unsorted URL add a snippet\n # after this one that sets req.url to req.http.Magento-Original-URL\n if ( !req.http.x-pass ) {\n set req.url = boltsort.sort(req.url);\n }\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.http.x-long-cache || req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n # GraphQL special headers handling because this area doesn't rely on X-Magento-Vary cookie\n if (req.http.graphql && !req.http.X-Magento-Cache-Id && req.http.Authorization ~ \"^Bearer\" ) {\n unset req.http.graphql;\n set req.http.x-pass = \"1\";\n }\n","old_contents":" # When using Magento tester to test whether your site is configured properly\n # this uses a bypass secret. By default we will use service ID as the bypass secret\n # however user can override this by defining a bypass_secret key in the\n # magentomodule_config edge dictionary\n if ( req.http.bypass-secret ) {\n declare local var.bypass-secret STRING;\n set var.bypass-secret = table.lookup(magentomodule_config, \"bypass_secret\", \"NONE\");\n if ( var.bypass-secret == req.http.bypass-secret ) {\n set req.http.x-pass = \"1\";\n set var.fastly_req_do_shield = false;\n set req.hash_always_miss = true;\n } else if ( var.bypass-secret == \"NONE\" && req.http.bypass-secret == req.service_id ) {\n set req.http.x-pass = \"1\";\n set var.fastly_req_do_shield = false;\n set req.hash_always_miss = true;\n } else {\n error 403 \"Bypass Secret incorrect\";\n }\n\n if (req.url == \"\/fastly-io-tester\") {\n # IO won't work for PASS requests\n unset req.http.x-pass;\n # IO requires shielding\n set var.fastly_req_do_shield = true;\n set req.hash_always_miss = true;\n set req.http.X-Fastly-Imageopto-Api = \"fastly\";\n }\n }\n\n # VCL required to support maintenance mode. Don't maintenance mode admin pages and supporting assets\n if (table.lookup(magentomodule_config, \"allow_super_users_during_maint\", \"0\") == \"1\" &&\n !req.http.Fastly-Client-Ip ~ maint_allowlist &&\n !req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" &&\n !req.url ~ \"^\/pub\/static\/\") {\n\n # If we end up here after a restart and there is a ResponseObject it means we got here after error\n # page VCL restart. We shouldn't touch it. Otherwise return a plain 503 error page\n if ( req.restarts > 0 && req.http.ResponseObject ) {\n set req.http.ResponseObject = \"970\";\n } else {\n error 503 \"Maintenance mode\";\n }\n }\n\n unset req.http.x-long-cache;\n\n # We want to force long cache times on any of the versioned assets\n if (req.url.path ~ \"^\/static\/version\\d*\/\") {\n set req.http.x-long-cache = \"1\";\n }\n\n # User's Cookie may contain some Magento Vary items we should vary on\n if (req.http.cookie:X-Magento-Vary) {\n set req.http.X-Magento-Vary = req.http.cookie:X-Magento-Vary;\n } else {\n unset req.http.X-Magento-Vary;\n }\n\n ############################################################################################################\n # Following code block controls purge by URL. By default we want to protect all URL purges. In general this\n # is addressed by adding Fastly-Purge-Requires-Auth request header in vcl_recv however this runs the risk of\n # exposing API tokens if user attempts to purge non-https URLs. For this reason inside the Magento module\n # we use X-Purge-Token. Unfortunately this breaks purge from the Fastly UI. Therefore in the next code block\n # we check for presence of X-Purge-Token. If it's not present we force the Fastly-Purge-Requires-Auth\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n if (req.http.X-Purge-Token && req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n } else {\n error 403;\n }\n } else {\n set req.http.Fastly-Purge-Requires-Auth = \"1\";\n }\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (fastly.ff.visits_this_service > 0) {\n # disable ESI processing on Origin Shield\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Make sure we lookup end user geo not shielding. More at https:\/\/docs.fastly.com\/vcl\/geolocation\/#using-geographic-variables-with-shielding\n set client.geo.ip_override = req.http.Fastly-Client-IP;\n\n if ((req.request == \"GET\" || req.request == \"HEAD\") && req.url.path ~ \"\/graphql\" && req.url.qs ~ \"query=\") {\n set req.http.graphql = \"1\";\n } else {\n unset req.http.graphql;\n }\n\n # geoip lookup\n if (req.url.path ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie:X-Magento-Vary || req.http.cookie:form_key) {\n error 980 \"GeoIP already processed\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url.qs !~ \"country_code=\" ) {\n set req.url = querystring.set(req.url, \"country_code\", if ( req.http.geo_override, req.http.geo_override, client.geo.country_code));\n }\n }\n } else if ( req.url.path !~ \"\/graphql\" ) {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking by default\n # and allow custom parameters to be set. List of parameters is configurable in admin\n set req.http.Magento-Original-URL = req.url;\n # Change the list of ignored parameters by configuring them in the Advanced section\n set req.url = querystring.regfilter(req.url, \"^(####QUERY_PARAMETERS####)$\");\n }\n\n # Don't allow clients to force a pass\n if (req.restarts == 0) {\n unset req.http.x-pass;\n unset req.http.Rate-Limit;\n unset req.http.magento-admin-path;\n }\n\n # Pass on checkout URLs. Because it's a snippet we want to execute this after backend selection so we handle it\n # in the request condition\n if (!req.http.x-long-cache && req.url ~ \"\/(checkout|customer\/section\/load)\") {\n set req.http.x-pass = \"1\";\n # Pass all admin actions\n # ####ADMIN_PATH#### is replaced with value of frontName from app\/etc\/env.php\n } else if ( req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" ) {\n set req.http.x-pass = \"1\";\n set req.http.magento-admin-path = \"1\";\n } else {\n # Sort the query arguments to increase cache hit ratio with query arguments that\n # may be out od order. In case you want to restore the unsorted URL add a snippet\n # after this one that sets req.url to req.http.Magento-Original-URL\n if ( !req.http.x-pass ) {\n set req.url = boltsort.sort(req.url);\n }\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.http.x-long-cache || req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n # GraphQL special headers handling because this area doesn't rely on X-Magento-Vary cookie\n if (req.http.graphql && !req.http.X-Magento-Cache-Id && req.http.Authorization ~ \"^Bearer\" ) {\n unset req.http.graphql;\n set req.http.x-pass = \"1\";\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"a8d017717625a28eb7a50a7a0bff5f2442b1e5c4","subject":"Simplify regular expression","message":"Simplify regular expression\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets\/recv.vcl","new_file":"etc\/vcl_snippets\/recv.vcl","new_contents":" # When using Magento tester to test whether your site is configured properly\n # this uses a bypass secret. By default we will use service ID as the bypass secret\n # however user can override this by defining a bypass_secret key in the\n # magentomodule_config edge dictionary\n if ( req.http.bypass-secret ) {\n declare local var.bypass-secret STRING;\n set var.bypass-secret = table.lookup(magentomodule_config, \"bypass_secret\", \"NONE\");\n if ( var.bypass-secret == req.http.bypass-secret ) {\n set req.http.x-pass = \"1\";\n set var.fastly_req_do_shield = false;\n set req.hash_always_miss = true;\n } else if ( var.bypass-secret == \"NONE\" && req.http.bypass-secret == req.service_id ) {\n set req.http.x-pass = \"1\";\n set var.fastly_req_do_shield = false;\n set req.hash_always_miss = true;\n } else {\n error 403 \"Bypass Secret incorrect\";\n }\n }\n\n # VCL required to support maintenance mode. Don't maintenance mode admin pages and supporting assets\n if (table.lookup(magentomodule_config, \"allow_super_users_during_maint\", \"0\") == \"1\" &&\n !req.http.Fastly-Client-Ip ~ maint_allowlist &&\n !req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" &&\n !req.url ~ \"^\/pub\/static\/\") {\n\n # If we end up here after a restart and there is a ResponseObject it means we got here after error\n # page VCL restart. We shouldn't touch it. Otherwise return a plain 503 error page\n if ( req.restarts > 0 && req.http.ResponseObject ) {\n set req.http.ResponseObject = \"970\";\n } else {\n error 503 \"Maintenance mode\";\n }\n }\n\n # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n unset req.http.x-long-cache;\n\n # We want to force long cache times on any of the versioned assets\n if (req.url.path ~ \"^\/static\/version\\d*\/\") {\n set req.http.x-long-cache = \"1\";\n }\n\n # User's Cookie may contain some Magento Vary items we should vary on\n if (req.http.cookie:X-Magento-Vary) {\n set req.http.X-Magento-Vary = req.http.cookie:X-Magento-Vary;\n } else {\n unset req.http.X-Magento-Vary;\n }\n\n ############################################################################################################\n # Following code block controls purge by URL. By default we want to protect all URL purges. In general this\n # is addressed by adding Fastly-Purge-Requires-Auth request header in vcl_recv however this runs the risk of\n # exposing API tokens if user attempts to purge non-https URLs. For this reason inside the Magento module\n # we use X-Purge-Token. Unfortunately this breaks purge from the Fastly UI. Therefore in the next code block\n # we check for presence of X-Purge-Token. If it's not present we force the Fastly-Purge-Requires-Auth\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n if (req.http.X-Purge-Token && req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n } else {\n error 403;\n }\n } else {\n set req.http.Fastly-Purge-Requires-Auth = \"1\";\n }\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (fastly.ff.visits_this_service > 0) {\n # disable ESI processing on Origin Shield\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Make sure we lookup end user geo not shielding. More at https:\/\/docs.fastly.com\/vcl\/geolocation\/#using-geographic-variables-with-shielding\n set client.geo.ip_override = req.http.Fastly-Client-IP;\n\n # geoip lookup\n if (req.url.path ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie:X-Magento-Vary || req.http.cookie:form_key) {\n error 980 \"GeoIP already processed\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url.qs !~ \"country_code=\" ) {\n set req.url = querystring.set(req.url, \"country_code\", if ( req.http.geo_override, req.http.geo_override, client.geo.country_code));\n }\n }\n } else if ( req.url.path !~ \"\/graphql\" ) {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking by default\n # and allow custom parameters to be set. List of parameters is configurable in admin\n set req.http.Magento-Original-URL = req.url;\n # Change the list of ignored parameters by configuring them in the Advanced section\n set req.url = querystring.regfilter(req.url, \"^(####QUERY_PARAMETERS####)$\");\n }\n\n # Don't allow clients to force a pass\n if (req.restarts == 0) {\n unset req.http.x-pass;\n unset req.http.Rate-Limit;\n unset req.http.magento-admin-path;\n }\n\n # Pass on checkout URLs. Because it's a snippet we want to execute this after backend selection so we handle it\n # in the request condition\n if (!req.http.x-long-cache && req.url ~ \"\/(checkout|customer\/section\/load)\") {\n set req.http.x-pass = \"1\";\n # Pass all admin actions\n # ####ADMIN_PATH#### is replaced with value of frontName from app\/etc\/env.php\n } else if ( req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" ) {\n set req.http.x-pass = \"1\";\n set req.http.magento-admin-path = \"1\";\n } else {\n # Sort the query arguments to increase cache hit ratio with query arguments that\n # may be out od order. In case you want to restore the unsorted URL add a snippet\n # after this one that sets req.url to req.http.Magento-Original-URL\n if ( !req.http.x-pass ) {\n set req.url = boltsort.sort(req.url);\n }\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.http.x-long-cache || req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n unset req.http.graphql;\n # GraphQL special headers handling because this area doesn't rely on X-Magento-Vary cookie\n if (req.request == \"GET\" && req.url.path ~ \"\/graphql\" && req.url.qs ~ \"query=\") {\n if ( req.http.Authorization ~ \"^Bearer\" ) {\n set req.http.x-pass = \"1\";\n } else {\n set req.http.graphql = \"1\";\n if (req.http.Store) {\n set req.http.X-Magento-Vary = req.http.Store;\n }\n if (req.http.Content-Currency) {\n if (req.http.X-Magento-Vary) {\n set req.http.X-Magento-Vary = req.http.X-Magento-Vary req.http.Content-Currency;\n } else {\n set req.http.X-Magento-Vary = req.http.Content-Currency;\n }\n }\n }\n }\n","old_contents":" # When using Magento tester to test whether your site is configured properly\n # this uses a bypass secret. By default we will use service ID as the bypass secret\n # however user can override this by defining a bypass_secret key in the\n # magentomodule_config edge dictionary\n if ( req.http.bypass-secret ) {\n declare local var.bypass-secret STRING;\n set var.bypass-secret = table.lookup(magentomodule_config, \"bypass_secret\", \"NONE\");\n if ( var.bypass-secret == req.http.bypass-secret ) {\n set req.http.x-pass = \"1\";\n set var.fastly_req_do_shield = false;\n set req.hash_always_miss = true;\n } else if ( var.bypass-secret == \"NONE\" && req.http.bypass-secret == req.service_id ) {\n set req.http.x-pass = \"1\";\n set var.fastly_req_do_shield = false;\n set req.hash_always_miss = true;\n } else {\n error 403 \"Bypass Secret incorrect\";\n }\n }\n\n # VCL required to support maintenance mode. Don't maintenance mode admin pages and supporting assets\n if (table.lookup(magentomodule_config, \"allow_super_users_during_maint\", \"0\") == \"1\" &&\n !req.http.Fastly-Client-Ip ~ maint_allowlist &&\n !req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" &&\n !req.url ~ \"^\/pub\/static\/\") {\n\n # If we end up here after a restart and there is a ResponseObject it means we got here after error\n # page VCL restart. We shouldn't touch it. Otherwise return a plain 503 error page\n if ( req.restarts > 0 && req.http.ResponseObject ) {\n set req.http.ResponseObject = \"970\";\n } else {\n error 503 \"Maintenance mode\";\n }\n }\n\n # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n unset req.http.x-long-cache;\n\n # We want to force long cache times on any of the versioned assets\n if (req.url.path ~ \"^\/static\/version\\d*\/\") {\n set req.http.x-long-cache = \"1\";\n }\n\n # User's Cookie may contain some Magento Vary items we should vary on\n if (req.http.cookie:X-Magento-Vary) {\n set req.http.X-Magento-Vary = req.http.cookie:X-Magento-Vary;\n } else {\n unset req.http.X-Magento-Vary;\n }\n\n ############################################################################################################\n # Following code block controls purge by URL. By default we want to protect all URL purges. In general this\n # is addressed by adding Fastly-Purge-Requires-Auth request header in vcl_recv however this runs the risk of\n # exposing API tokens if user attempts to purge non-https URLs. For this reason inside the Magento module\n # we use X-Purge-Token. Unfortunately this breaks purge from the Fastly UI. Therefore in the next code block\n # we check for presence of X-Purge-Token. If it's not present we force the Fastly-Purge-Requires-Auth\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n if (req.http.X-Purge-Token && req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n } else {\n error 403;\n }\n } else {\n set req.http.Fastly-Purge-Requires-Auth = \"1\";\n }\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (fastly.ff.visits_this_service > 0) {\n # disable ESI processing on Origin Shield\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Make sure we lookup end user geo not shielding. More at https:\/\/docs.fastly.com\/vcl\/geolocation\/#using-geographic-variables-with-shielding\n set client.geo.ip_override = req.http.Fastly-Client-IP;\n\n # geoip lookup\n if (req.url.path ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie:X-Magento-Vary || req.http.cookie:form_key) {\n error 980 \"GeoIP already processed\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url.qs !~ \"country_code=\" ) {\n set req.url = querystring.set(req.url, \"country_code\", if ( req.http.geo_override, req.http.geo_override, client.geo.country_code));\n }\n }\n } else if ( req.url.path !~ \"\/graphql\" ) {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking by default\n # and allow custom parameters to be set. List of parameters is configurable in admin\n set req.http.Magento-Original-URL = req.url;\n # Change the list of ignored parameters by configuring them in the Advanced section\n set req.url = querystring.regfilter(req.url, \"^(####QUERY_PARAMETERS####)(=|&|$)\");\n }\n\n # Don't allow clients to force a pass\n if (req.restarts == 0) {\n unset req.http.x-pass;\n unset req.http.Rate-Limit;\n unset req.http.magento-admin-path;\n }\n\n # Pass on checkout URLs. Because it's a snippet we want to execute this after backend selection so we handle it\n # in the request condition\n if (!req.http.x-long-cache && req.url ~ \"\/(checkout|customer\/section\/load)\") {\n set req.http.x-pass = \"1\";\n # Pass all admin actions\n # ####ADMIN_PATH#### is replaced with value of frontName from app\/etc\/env.php\n } else if ( req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" ) {\n set req.http.x-pass = \"1\";\n set req.http.magento-admin-path = \"1\";\n } else {\n # Sort the query arguments to increase cache hit ratio with query arguments that\n # may be out od order. In case you want to restore the unsorted URL add a snippet\n # after this one that sets req.url to req.http.Magento-Original-URL\n if ( !req.http.x-pass ) {\n set req.url = boltsort.sort(req.url);\n }\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.http.x-long-cache || req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n unset req.http.graphql;\n # GraphQL special headers handling because this area doesn't rely on X-Magento-Vary cookie\n if (req.request == \"GET\" && req.url.path ~ \"\/graphql\" && req.url.qs ~ \"query=\") {\n if ( req.http.Authorization ~ \"^Bearer\" ) {\n set req.http.x-pass = \"1\";\n } else {\n set req.http.graphql = \"1\";\n if (req.http.Store) {\n set req.http.X-Magento-Vary = req.http.Store;\n }\n if (req.http.Content-Currency) {\n if (req.http.X-Magento-Vary) {\n set req.http.X-Magento-Vary = req.http.X-Magento-Vary req.http.Content-Currency;\n } else {\n set req.http.X-Magento-Vary = req.http.Content-Currency;\n }\n }\n }\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"8f38f5696d40676be68dbf790f39de1551a134b4","subject":"change of ports","message":"change of ports\n","repos":"andyfase\/varnishAutoScalingCluster","old_file":"vcl\/backend.vcl","new_file":"vcl\/backend.vcl","new_contents":"#\n# Backend VCL file - this should be auto-generated by consul\n#\n\nbackend http_backend1 {\n .host = \"127.0.0.1\";\n .port = \"81\";\n}\n\nbackend http_backend2 {\n .host = \"127.0.0.1\";\n .port = \"81\";\n}\n\nbackend varnish_backend1 {\n .host = \"127.0.0.1\";\n .port = \"80\";\n}\n\nbackend varnish_backend2 {\n .host = \"127.0.0.1\";\n .port = \"80\";\n}\n\nsub backend_init {\n ## setup varnish backend hash director\n new varnish_backend = directors.hash();\n varnish_backend.add_backend(varnish_backend1, 1.0);\n varnish_backend.add_backend(varnish_backend2, 1.0);\n\n ## setup actual backend director, using round-robin\n new httpd_backend = directors.round_robin();\n httpd_backend.add_backend(http_backend1);\n httpd_backend.add_backend(http_backend2);\n}\n","old_contents":"#\n# Backend VCL file - this should be auto-generated by consul\n#\n\nbackend http_backend1 {\n .host = \"127.0.0.1\";\n .port = \"10000\";\n}\n\nbackend http_backend2 {\n .host = \"127.0.0.1\";\n .port = \"10000\";\n}\n\nbackend varnish_backend1 {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\n\nbackend varnish_backend2 {\n .host = \"127.0.0.1\";\n .port = \"8081\";\n}\n\nsub backend_init {\n ## setup varnish backend hash director\n new varnish_backend = directors.hash();\n varnish_backend.add_backend(varnish_backend1, 1.0);\n varnish_backend.add_backend(varnish_backend2, 1.0);\n\n ## setup actual backend director, using round-robin\n new httpd_backend = directors.round_robin();\n httpd_backend.add_backend(http_backend1);\n httpd_backend.add_backend(http_backend2);\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"14b1d5a823212ec4806ee2b2309ec5ad6b0f5ecc","subject":"Fix vcl for v4","message":"Fix vcl for v4\n","repos":"mskyttner\/nub-docker,mskyttner\/nub-docker,mskyttner\/clb-docker,mskyttner\/clb-docker,mskyttner\/clb-docker,mskyttner\/nub-docker","old_file":"ws\/default.vcl","new_file":"ws\/default.vcl","new_contents":"vcl 4.0;\n\nbackend clbws { \n .host = \"ws\"; \n .port = \"9000\";\n .max_connections = 100;\n .first_byte_timeout = 300s; # How long to wait before we receive a first byte from our backend?\n .connect_timeout = 5s; # How long to wait for a backend connection?\n .between_bytes_timeout = 2s; # How long to wait between bytes received from our backend?\n}\n\n#backend nubws { \n# .host = \"nubws\"; \n# .port = \"9002\";\n# .max_connections = 100;\n# .first_byte_timeout = 300s; # How long to wait before we receive a first byte from our backend?\n# .connect_timeout = 5s; # How long to wait for a backend connection?\n# .between_bytes_timeout = 2s; # How long to wait between bytes received from our backend?\n#}\n\nsub vcl_recv {\n\n # keep original URL in custom header for the ban lurker process later one in vcl_fetch. We modify the request URL here to match the backend apps\n set req.http.x-api-url = req.url;\n\n if (req.method == \"FLUSH\") {\n ban(\"req.http.host == \" + req.http.host + \" && req.url == \/\");\n # Throw a synthetic page so the\n # request won't go to the backend.\n return(synth(200, \"Flush added\"));\n }\n if (req.method == \"BAN\") {\n ban(\"req.http.host == \" + req.http.host + \" && req.url == \" + req.url);\n # Throw a synthetic page so the\n # request won't go to the backend.\n return(synth(200, \"Ban added\"));\n }\n\n if ( req.url ~ \"^\/favicon.ico\") {\n return(synth(404, \"Not found\"));\n }\n\n if (req.url ~ \"^\/species\/(match|lookup)\"){\n# set req.backend_hint = nubws;\n set req.backend_hint = clbws;\n } else {\n set req.backend_hint = clbws;\n }\n \n # apparently varnish tries to cache POST requests by converting them to GETs :(\n # https:\/\/www.varnish-cache.org\/forum\/topic\/235\n # we therefore make sure we only cache GET requests\n if (req.method == \"GET\") {\n return (hash);\n } else {\n return(pass);\n } \n}\n\n\n\nsub vcl_backend_response {\n # keep original request url in cache for varnishs ban lurker thread:\n # https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#smart-bans\n # x-api-url is set in vcl_recv BAN\n set beresp.http.x-api-url = req.http.x-api-url;\n\n # 1 hour for all API calls\n set beresp.ttl = 3600s;\n \n return (deliver);\n}\n","old_contents":"vcl 4.0;\n\nbackend clbws { \n .host = \"ws\"; \n .port = \"9000\";\n .max_connections = 100;\n .first_byte_timeout = 300s; # How long to wait before we receive a first byte from our backend?\n .connect_timeout = 5s; # How long to wait for a backend connection?\n .between_bytes_timeout = 2s; # How long to wait between bytes received from our backend?\n}\n\n#backend nubws { \n# .host = \"nubws\"; \n# .port = \"9002\";\n# .max_connections = 100;\n# .first_byte_timeout = 300s; # How long to wait before we receive a first byte from our backend?\n# .connect_timeout = 5s; # How long to wait for a backend connection?\n# .between_bytes_timeout = 2s; # How long to wait between bytes received from our backend?\n#}\n\nsub vcl_recv {\n\n # keep original URL in custom header for the ban lurker process later one in vcl_fetch. We modify the request URL here to match the backend apps\n set req.http.x-api-url = req.url;\n\n # this bans matching objects via regex from being served if older than the ban\n if (req.method == \"BAN\") {\n ban(\"obj.http.x-api-url ~ \" + req.http.x-ban-url);\n error 200 \"Banned\";\n }\n\n # remove whatever host we got, as varnish adds the backend hostname if none exists in the request\n remove req.http.host;\n\n # remove cookies in weird case they exist\n remove req.http.Cookie;\n\n if ( req.url ~ \"^\/favicon.ico\") {\n error 404 \"Not found\";\n }\n\n if (req.url ~ \"^\/species\/(match|lookup)\"){\n# set req.backend = nubws;\n set req.backend = clbws;\n } else {\n set req.backend = clbws;\n }\n \n # apparently varnish tries to cache POST requests by converting them to GETs :(\n # https:\/\/www.varnish-cache.org\/forum\/topic\/235\n # we therefore make sure we only cache GET requests\n if (req.method == \"GET\") {\n return (lookup);\n } else {\n return(pass);\n } \n}\n\n\n\nsub vcl_fetch {\n # keep original request url in cache for varnishs ban lurker thread:\n # https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#smart-bans\n # x-api-url is set in vcl_recv BAN\n set beresp.http.x-api-url = req.http.x-api-url;\n\n #\n # CACHE CONTROL\n #\n # remove no cache headers.\n # Cache-Control: mag-age takes precendence over Last-Modified or ETags:\n # https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleLongerCaching\n # http:\/\/stackoverflow.com\/questions\/6451137\/etag-attribute-present-but-no-cache-control-present-in-http-header\n # http:\/\/www.w3.org\/Protocols\/rfc2616\/rfc2616-sec13.html\n remove beresp.http.Cache-Control;\n\n # 1 hour for all API calls\n set beresp.ttl = 3600s;\n \n return (deliver);\n}\n\nsub vcl_error {\n if (obj.status == 301) {\n set obj.http.Location = obj.response;\n set obj.status = 301;\n return (deliver);\n }\n}\n","returncode":0,"stderr":"","license":"agpl-3.0","lang":"VCL"} {"commit":"f1ee63b6e71e32bd83266e48ddbbfa74b3c15f06","subject":"Fix inability to purge by URL from the Fastly UI","message":"Fix inability to purge by URL from the Fastly UI\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets\/recv.vcl","new_file":"etc\/vcl_snippets\/recv.vcl","new_contents":" # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n unset req.http.x-long-cache;\n\n # Rewrite \/static\/versionxxxxx URLs. Avoids us having to rewrite on nginx layer\n if (req.url ~ \"^\/static\/version(\\d*\/)?(.*)$\") {\n set req.url = \"\/static\/\" + re.group.2 + \"?\" + re.group.1;\n set req.http.x-long-cache = \"1\";\n }\n \n # User's Cookie may contain some Magento Vary items we should vary on\n if (req.http.cookie:X-Magento-Vary ) {\n set req.http.X-Magento-Vary = req.http.cookie:X-Magento-Vary;\n } else {\n unset req.http.X-Magento-Vary;\n }\n\n ############################################################################################################\n # Following code block controls purge by URL. By default we want to protect all URL purges. In general this\n # is addressed by adding Fastly-Purge-Requires-Auth request header in vcl_recv however this runs the risk of\n # exposing API tokens if user attempts to purge non-https URLs. For this reason inside the Magento module\n # we use X-Purge-Token. Unfortunately this breaks purge from the Fastly UI. Therefore in the next code block\n # we check for presence of X-Purge-Token. If it's not present we force the Fastly-Purge-Requires-Auth\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n if (req.http.X-Purge-Token && req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n }\n\n } else {\n set req.http.Fastly-Purge-Requires-Auth = \"1\";\n }\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (req.http.Fastly-FF) {\n # disable ESI processing on Origin Shield\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie:X-Magento-Vary || req.http.cookie:form_key) {\n error 980 \"GeoIP already processed\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url.qs !~ \"country_code=\" ) {\n set req.url = req.url \"?country_code=\" if ( req.http.geo_override, req.http.geo_override, client.geo.country_code);\n }\n }\n } else {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking by default\n # and allow custom parameters to be set. List of parameters is configurable in admin\n set req.http.Magento-Original-URL = req.url;\n set req.url = querystring.regfilter(req.url, \"^(####QUERY_PARAMETERS####)\");\n }\n\n # Don't allow clients to force a pass\n if (req.restarts == 0) {\n unset req.http.x-pass;\n }\n \n # Pass on checkout URLs. Because it's a snippet we want to execute this after backend selection so we handle it\n # in the request condition\n if (!req.http.x-long-cache && req.url ~ \"\/(catalogsearch|checkout|customer\/section\/load)\") {\n set req.http.x-pass = \"1\";\n # Pass all admin actions\n # ####ADMIN_PATH#### is replaced with value of frontName from app\/etc\/env.php\n } else if ( req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" ) {\n set req.http.x-pass = \"1\";\n } else {\n # Sort the query arguments to increase cache hit ratio with query arguments that\n # may be out od order\n set req.url = boltsort.sort(req.url);\n }\n\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.http.x-long-cache || req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n","old_contents":" # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n unset req.http.x-long-cache;\n\n # Rewrite \/static\/versionxxxxx URLs. Avoids us having to rewrite on nginx layer\n if (req.url ~ \"^\/static\/version(\\d*\/)?(.*)$\") {\n set req.url = \"\/static\/\" + re.group.2 + \"?\" + re.group.1;\n set req.http.x-long-cache = \"1\";\n }\n \n # User's Cookie may contain some Magento Vary items we should vary on\n if (req.http.cookie:X-Magento-Vary ) {\n set req.http.X-Magento-Vary = req.http.cookie:X-Magento-Vary;\n } else {\n unset req.http.X-Magento-Vary;\n }\n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n if (!req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n error 403;\n }\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n\n } else {\n error 403;\n }\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (req.http.Fastly-FF) {\n # disable ESI processing on Origin Shield\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie:X-Magento-Vary || req.http.cookie:form_key) {\n error 980 \"GeoIP already processed\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url.qs !~ \"country_code=\" ) {\n set req.url = req.url \"?country_code=\" if ( req.http.geo_override, req.http.geo_override, client.geo.country_code);\n }\n }\n } else {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking by default\n # and allow custom parameters to be set\n set req.http.Magento-Original-URL = req.url;\n set req.url = querystring.regfilter(req.url, \"^(####QUERY_PARAMETERS####)\");\n }\n\n # Don't allow clients to force a pass\n if (req.restarts == 0) {\n unset req.http.x-pass;\n }\n \n # Pass on checkout URLs. Because it's a snippet we want to execute this after backend selection so we handle it\n # in the request condition\n if (!req.http.x-long-cache && req.url ~ \"\/(catalogsearch|checkout|customer\/section\/load)\") {\n set req.http.x-pass = \"1\";\n # Pass all admin actions\n # ####ADMIN_PATH#### is replaced with value of frontName from app\/etc\/env.php\n } else if ( req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" ) {\n set req.http.x-pass = \"1\";\n } else {\n # Sort the query arguments to increase cache hit ratio with query arguments that\n # may be out od order\n set req.url = boltsort.sort(req.url);\n }\n\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.http.x-long-cache || req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"2a9026b004e148db83e807411adfde4deece4515","subject":"fix redirects","message":"fix redirects\n","repos":"JakeChampion\/polyfill-service,JakeChampion\/polyfill-service","old_file":"fastly\/vcl\/redirects.vcl","new_file":"fastly\/vcl\/redirects.vcl","new_contents":"sub vcl_recv {\n\tif (req.http.Host ~ \"polyfills.io\") {\n\t\t# Fastly recommend using the 900-999 range of status codes for custom errors within an application's VCL.\n\t\t# Do the canonicalise check before the HTTPS check to avoid a double redirect\n\t\terror 901 \"Canonicalise\";\n\t}\n\tif (!req.http.Fastly-SSL) {\n\t\t# 801 is a special error code that Fastly uses to Force HTTPS on the request\n\t\terror 801 \"Redirect to HTTPS\";\n\t}\n\tif (req.http.Orig-URL ~ \"^\/v1\") {\n\t\terror 902 \"Redirect to V2\";\n\t}\n\n\tif (req.url.path == \"\/\" || req.url.path == \"\/v2\" || req.url.path == \"\/v2\/docs\" || req.url.path == \"\/v2\/docs\/\") {\n\t\terror 908;\n\t}\n}\n\nsub vcl_error {\n # Redirect to canonical prod\/qa origins\n\tif (obj.status == 901) {\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\tset obj.http.Location = \"https:\/\/polyfill.io\" req.url;\n\t\tsynthetic {\"\"};\n\t\treturn (deliver);\n\t}\n\t# Redirect to v2\n\tif (obj.status == 902) {\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\t# Remove libVersion and gated query parameters if they exist.\n\t\tset req.url = querystring.regfilter(req.url, \"^\\b(libVersion|gated)\\b.*\");\n\t\tset obj.http.Location = if(req.url.path == \"\/v1\", \"\/v3\/\", regsub(req.url, \"^\/v1\", \"\/v2\"));\n\t\tset obj.http.Deprecation-Notice = \"API version 1 has been decommissioned - see the body of this response for more information.\";\n\t\tsynthetic {\"API version 1 has been decommissioned. Your request is being redirected to v2. The `libVersion` and `gated` query string parameters are no longer supported and if present have been removed from your request.\\n\\nA deprecation period for v1 existed between August and December 2015, during which time v1 requests were honoured but a deprecation warning was added to output.\"};\n\t\treturn (deliver);\n\t}\n\n\t# Redirect to v3\n\tif (obj.status == 908) {\n\t\tset obj.status = 301;\n\t\tset obj.http.Location = \"\/v3\/\";\n\t\treturn (deliver);\n\t}\n}\n","old_contents":"sub vcl_recv {\n\tif (req.http.Host ~ \"polyfills.io\") {\n\t\t# Fastly recommend using the 900-999 range of status codes for custom errors within an application's VCL.\n\t\t# Do the canonicalise check before the HTTPS check to avoid a double redirect\n\t\terror 901 \"Canonicalise\";\n\t}\n\tif (!req.http.Fastly-SSL) {\n\t\t# 801 is a special error code that Fastly uses to Force HTTPS on the request\n\t\terror 801 \"Redirect to HTTPS\";\n\t}\n\tif (req.http.Orig-URL ~ \"^\/v1\") {\n\t\terror 902 \"Redirect to V2\";\n\t}\n\n\tif (req.url.path == \"\/\" || req.url.path == \"\/v2\" || req.url.path == \"\/v2\/docs\/\") {\n\t\terror 908;\n\t}\n}\n\nsub vcl_error {\n # Redirect to canonical prod\/qa origins\n\tif (obj.status == 901) {\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\tset obj.http.Location = \"https:\/\/polyfill.io\" req.url;\n\t\tsynthetic {\"\"};\n\t\treturn (deliver);\n\t}\n\t# Redirect to v2\n\tif (obj.status == 902) {\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\t# Remove libVersion and gated query parameters if they exist.\n\t\tset req.url = querystring.regfilter(req.url, \"^\\b(libVersion|gated)\\b.*\");\n\t\tset obj.http.Location = if(req.url.path == \"\/v1\", \"\/v3\/\", regsub(req.url, \"^\/v1\", \"\/v2\"));\n\t\tset obj.http.Deprecation-Notice = \"API version 1 has been decommissioned - see the body of this response for more information.\";\n\t\tsynthetic {\"API version 1 has been decommissioned. Your request is being redirected to v2. The `libVersion` and `gated` query string parameters are no longer supported and if present have been removed from your request.\\n\\nA deprecation period for v1 existed between August and December 2015, during which time v1 requests were honoured but a deprecation warning was added to output.\"};\n\t\treturn (deliver);\n\t}\n\n\t# Redirect to v3\n\tif (obj.status == 908) {\n\t\tset obj.status = 301;\n\t\tset obj.http.Location = \"\/v3\/\";\n\t\treturn (deliver);\n\t}\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"36f3fb86241e8299d009a92308083ebd525e6c50","subject":"add default backend cache of 60 minutes","message":"add default backend cache of 60 minutes\n","repos":"andyfase\/varnishAutoScalingCluster","old_file":"vcl\/vcl_backend.vcl","new_file":"vcl\/vcl_backend.vcl","new_contents":"sub recv_backend {\n # set backend as httpd round-robin director\n set req.backend_hint = httpd_backend.backend();\n\n # re-set X-Varnish-Cluster-Hash to differentiate hash key for cache\n set req.http.X-Varnish-Cluster-Hash = \"backend\";\n\n return (hash);\n}\n\nsub backend_response_backend {\n set beresp.http.X-BE = bereq.xid;\n\n ## set default cache of 60m\n set beresp.ttl = 60m;\n\n return(deliver);\n}\n\nsub deliver_backend {\n # set responde header X-Varnish-Cluster-Backend (value doesnt really matter)\n set resp.http.X-Varnish-Cluster-Backend = req.xid;\n\n # add backend varnish server IP as response header just for demonstration purposes!\n set resp.http.X-Varnish-Cluster-Backend-Host = server.hostname;\n\n # set Age header to X-Cache, on frontend we will remove Age header completly.\n set resp.http.X-Cache = resp.http.Age;\n\n return(deliver);\n}\n","old_contents":"sub recv_backend {\n # set backend as httpd round-robin director\n set req.backend_hint = httpd_backend.backend();\n\n # re-set X-Varnish-Cluster-Hash to differentiate hash key for cache\n set req.http.X-Varnish-Cluster-Hash = \"backend\";\n\n return (hash);\n}\n\nsub backend_response_backend {\n set beresp.http.X-BE = bereq.xid;\n\n return(deliver);\n}\n\nsub deliver_backend {\n # set responde header X-Varnish-Cluster-Backend (value doesnt really matter)\n set resp.http.X-Varnish-Cluster-Backend = req.xid;\n\n # add backend varnish server IP as response header just for demonstration purposes!\n set resp.http.X-Varnish-Cluster-Backend-Host = server.hostname;\n\n # set Age header to X-Cache, on frontend we will remove Age header completly.\n set resp.http.X-Cache = resp.http.Age;\n\n return(deliver);\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"6b89e1b78361a07384039c750b20b4ad0d183ed8","subject":"Add comment on how to restore original URL","message":"Add comment on how to restore original URL\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets\/recv.vcl","new_file":"etc\/vcl_snippets\/recv.vcl","new_contents":" # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n unset req.http.x-long-cache;\n\n # Rewrite \/static\/versionxxxxx URLs. Avoids us having to rewrite on nginx layer\n if (req.url ~ \"^\/static\/version(\\d*\/)?(.*)$\") {\n set req.url = \"\/static\/\" + re.group.2 + \"?\" + re.group.1;\n set req.http.x-long-cache = \"1\";\n }\n \n # User's Cookie may contain some Magento Vary items we should vary on\n if (req.http.cookie:X-Magento-Vary ) {\n set req.http.X-Magento-Vary = req.http.cookie:X-Magento-Vary;\n } else {\n unset req.http.X-Magento-Vary;\n }\n\n ############################################################################################################\n # Following code block controls purge by URL. By default we want to protect all URL purges. In general this\n # is addressed by adding Fastly-Purge-Requires-Auth request header in vcl_recv however this runs the risk of\n # exposing API tokens if user attempts to purge non-https URLs. For this reason inside the Magento module\n # we use X-Purge-Token. Unfortunately this breaks purge from the Fastly UI. Therefore in the next code block\n # we check for presence of X-Purge-Token. If it's not present we force the Fastly-Purge-Requires-Auth\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n if (req.http.X-Purge-Token && req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n }\n\n } else {\n set req.http.Fastly-Purge-Requires-Auth = \"1\";\n }\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (req.http.Fastly-FF) {\n # disable ESI processing on Origin Shield\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie:X-Magento-Vary || req.http.cookie:form_key) {\n error 980 \"GeoIP already processed\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url.qs !~ \"country_code=\" ) {\n set req.url = req.url \"?country_code=\" if ( req.http.geo_override, req.http.geo_override, client.geo.country_code);\n }\n }\n } else {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking by default\n # and allow custom parameters to be set. List of parameters is configurable in admin\n set req.http.Magento-Original-URL = req.url;\n # Change the list of ignored parameters by configuring them in the Advanced section\n set req.url = querystring.regfilter(req.url, \"^(####QUERY_PARAMETERS####)\");\n }\n\n # Don't allow clients to force a pass\n if (req.restarts == 0) {\n unset req.http.x-pass;\n }\n \n # Pass on checkout URLs. Because it's a snippet we want to execute this after backend selection so we handle it\n # in the request condition\n if (!req.http.x-long-cache && req.url ~ \"\/(catalogsearch|checkout|customer\/section\/load)\") {\n set req.http.x-pass = \"1\";\n # Pass all admin actions\n # ####ADMIN_PATH#### is replaced with value of frontName from app\/etc\/env.php\n } else if ( req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" ) {\n set req.http.x-pass = \"1\";\n } else {\n # Sort the query arguments to increase cache hit ratio with query arguments that\n # may be out od order. In case you want to restore the unsorted URL add a snippet\n # after this one that sets req.url to req.http.Magento-Original-URL\n set req.url = boltsort.sort(req.url);\n }\n\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.http.x-long-cache || req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n","old_contents":" # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n unset req.http.x-long-cache;\n\n # Rewrite \/static\/versionxxxxx URLs. Avoids us having to rewrite on nginx layer\n if (req.url ~ \"^\/static\/version(\\d*\/)?(.*)$\") {\n set req.url = \"\/static\/\" + re.group.2 + \"?\" + re.group.1;\n set req.http.x-long-cache = \"1\";\n }\n \n # User's Cookie may contain some Magento Vary items we should vary on\n if (req.http.cookie:X-Magento-Vary ) {\n set req.http.X-Magento-Vary = req.http.cookie:X-Magento-Vary;\n } else {\n unset req.http.X-Magento-Vary;\n }\n\n ############################################################################################################\n # Following code block controls purge by URL. By default we want to protect all URL purges. In general this\n # is addressed by adding Fastly-Purge-Requires-Auth request header in vcl_recv however this runs the risk of\n # exposing API tokens if user attempts to purge non-https URLs. For this reason inside the Magento module\n # we use X-Purge-Token. Unfortunately this breaks purge from the Fastly UI. Therefore in the next code block\n # we check for presence of X-Purge-Token. If it's not present we force the Fastly-Purge-Requires-Auth\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n if (req.http.X-Purge-Token && req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n }\n\n } else {\n set req.http.Fastly-Purge-Requires-Auth = \"1\";\n }\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (req.http.Fastly-FF) {\n # disable ESI processing on Origin Shield\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie:X-Magento-Vary || req.http.cookie:form_key) {\n error 980 \"GeoIP already processed\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url.qs !~ \"country_code=\" ) {\n set req.url = req.url \"?country_code=\" if ( req.http.geo_override, req.http.geo_override, client.geo.country_code);\n }\n }\n } else {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking by default\n # and allow custom parameters to be set. List of parameters is configurable in admin\n set req.http.Magento-Original-URL = req.url;\n # Change the list of ignored parameters by configuring them in the Advanced section\n set req.url = querystring.regfilter(req.url, \"^(####QUERY_PARAMETERS####)\");\n }\n\n # Don't allow clients to force a pass\n if (req.restarts == 0) {\n unset req.http.x-pass;\n }\n \n # Pass on checkout URLs. Because it's a snippet we want to execute this after backend selection so we handle it\n # in the request condition\n if (!req.http.x-long-cache && req.url ~ \"\/(catalogsearch|checkout|customer\/section\/load)\") {\n set req.http.x-pass = \"1\";\n # Pass all admin actions\n # ####ADMIN_PATH#### is replaced with value of frontName from app\/etc\/env.php\n } else if ( req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" ) {\n set req.http.x-pass = \"1\";\n } else {\n # Sort the query arguments to increase cache hit ratio with query arguments that\n # may be out od order\n set req.url = boltsort.sort(req.url);\n }\n\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.http.x-long-cache || req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"219a06c63780229cde6f92cf82ba6d0c07bc7390","subject":"query string and anchor processing","message":"query string and anchor processing\n","repos":"NITEMAN\/varnish-bites,NITEMAN\/Varnish_VCL_samps-hacks","old_file":"varnish4\/drupal-base.vcl","new_file":"varnish4\/drupal-base.vcl","new_contents":"\/*\n * Varnish 4 example config for Drupal 7 \/ Pressflow 6 & 7\n *\/\n\n# Original source: https:\/\/github.com\/NITEMAN\/varnish-bites\/varnish4\/drupal-base.vcl\n# Copyright (c) 2015 Pedro Gonz\u00e1lez Serrano and individual contributors.\n# MIT License\n\n# Intended to be used both in simple production environments and with\n# learning\/teaching purposes.\n# Some references may not be yet updated to VCL 4.0, we use SeeV3 then.\n\n# WARNING:\n# Note that the built-in logic will be appended to our code if no return is\n# performed before.\n# Built-in logic is included commented out right after our's for reference\n# purposes in that cases.\n# See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleDefault\n\n#######################################################################\n# Initialization: Version & imports;\n\n\/* Version statement *\/\n# Since Varnish 4.0 it's mandatory to declare VCL version on first line.\nvcl 4.0;\n\n\/* Module (VMOD) imports *\/\n# Standard module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_std.generated.html\nimport std;\n\n# Directors module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# Unused in simple configs.\n#import directors;\n\n\n#######################################################################\n# Probe, backend, ACL and subroutine definitions\n\n\/* Backend probes \/ healthchecks *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#probes\nprobe basic {\n \/* Only test that backend's IP serves content for '\/' *\/\n # This might be a too heavy probe\n # .url = \"\/\";\n\n \/* Only test that backend's IP has apache working *\/\n # Nginx would fail this probe with a default config\n .request =\n \"OPTIONS * HTTP\/1.1\"\n \"Host: *\"\n \"Connection: close\";\n\n \/* Common options *\/\n .interval = 10s;\n .timeout = 2s;\n .window = 8;\n .threshold = 6;\n}\n\n\/* Backend definitions.*\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#backend-definition\nbackend default {\n \/* Default backend on the same machine. *\/\n # WARNING: timeouts could be not big enought for certain POST requests.\n .host = \"127.0.0.1\";\n .port = \"8008\";\n .max_connections = 100;\n .connect_timeout = 60s;\n .first_byte_timeout = 60s;\n .between_bytes_timeout = 60s;\n .probe = basic;\n}\n\n\/* Access Control Lists *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#access-control-list-acl\nacl purge_ban {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use '\"localhost\";' instead\n}\nacl allowed_monitors {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n}\n# acl own_proxys {\n# \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n# }\n\n\/* Custom subroutines *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#subroutines\n#TODO# Test in Varnihs 4\n# Empty in simple configs.\n# The only restriction naming subs is that the 'vlc_' prefix is reserverd for\n# Varnish use. As a task can need several chunks of code in diferent states,\n# it's a good idea to identify what main sub will call each with a suffix.\n# \/* Example 301 client redirection removing \"www\" prefix from request *\/\n# sub perm_redirections_recv {\n# if ( req.http.host ~ \"^www.*$\" ) {\n# return (\n# synth(751, \"http:\/\/\" + regsub(req.http.host, \"^www\\.\", \"\") + req.url)\n# );\n# }\n# }\n# sub perm_redirections_synth {\n# if ( resp.status == 751 ) {\n# \/* Get new URL from the response *\/\n# set resp.http.Location = resp.response;\n# \/* Set HTTP 301 for permanent redirect *\/\n# set resp.status = 301;\n# return (deliver);\n# }\n# }\n\n\n#######################################################################\n# Client side\n\n# vcl_recv: Called at the beginning of a request, after the complete request\n# has been received and parsed. Its purpose is to decide whether or not to\n# serve the request, how to do it, and, if applicable, which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-recv\nsub vcl_recv {\n \/* 0th: general bypass, general return & authorization checks *\/\n # Empty in simple configs.\n # Useful for debugging we can pipe or pass the request to default backend\n # here to bypass completely Varnish.\n # return (pipe);\n # return (pass);\n # We can also return here a 200 Ok for network performance benchmarking.\n # return (synth(200, \"Ok\"));\n # Finally we can perform basic HTTP authentification here, by example.\n # SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* 1st: Check for Varnish special requests *\/ \n # Custom response implementation example in order to check that Varnish is\n # working properly.\n # This is usefull for automatic monitoring with monit or when Varnish is\n # behind another proxies like HAProxy.\n if ( ( req.http.host == \"monitor.server.health\"\n || req.http.host == \"health.varnish\" )\n && client.ip ~ allowed_monitors\n && ( req.method == \"OPTIONS\" || req.method == \"GET\" )\n ) {\n return (synth(200, \"Ban added\"));\n }\n # Purge logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#http-purging\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if ( req.method == \"PURGE\" ) {\n if ( client.ip !~ purge_ban ) {\n return (synth(405, \"Not allowed.\"));\n }\n return (purge);\n }\n # Ban logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#bans\n if ( req.method == \"BAN\" ) {\n if ( client.ip !~ purge_ban ) {\n return (synth(405, \"Not allowed.\"));\n }\n ban( \"req.http.host == \" + req.http.host +\n \"&& req.url == \" + req.url);\n return (synth(200, \"Ban added\"));\n }\n\n \/* 2nd: Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_recv;\n # Here we can also enforce SSL when Varnish run behind some SSL termination\n # point.\n\n \/* 3rd: Time for backend choice *\/\n # Empty in simple configs.\n\n \/* 4th: Prepare request for the backend *\/\n # Empty in simple configs.\n # Example remove own_proxys from X-Forwarded-For\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/whats-new\/upgrading.html#x-forwarded-for-is-now-set-before-vcl-recv\n # if ( req.restarts == 0\n # && client.ip ~ own_proxys\n # && req.http.x-forwarded-for\n # ) {\n # set req.http.X-Forwarded-For\n # = regsub(req.http.X-Forwarded-For, \",( )?\" + client.ip, \"\");\n # }\n # Example normalize the host header, remove the port (in case you're testing\n # this on various TCP ports)\n # set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n \/* 5th: Bypass breakpoint 1 *\/\n # Useful for debugging we can now pipe or pass the request to backend with\n # headers setted.\n # return (pipe);\n # return (pass);\n\n \/* 6th: Decide if we should deal with a request (mostly from built-in logic) *\/\n if ( req.method == \"PRI\" ) {\n \/* We do not support SPDY or HTTP\/2.0 *\/\n return (synth(405));\n }\n if ( req.method != \"GET\"\n && req.method != \"HEAD\"\n && req.method != \"PUT\"\n && req.method != \"POST\"\n && req.method != \"TRACE\"\n && req.method != \"OPTIONS\"\n && req.method != \"DELETE\"\n ) {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if ( req.method != \"GET\"\n && req.method != \"HEAD\"\n ) {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if ( req.http.Authorization ) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n # Websocket support\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html\n if ( req.http.Upgrade ~ \"(?i)websocket\" ) {\n return (pipe);\n }\n\n \/* 7th: Access control for some URLs by ACL *\/\n # Empty in simple configs.\n # By example denial some URLs depending on client-ip, we'll need to define\n # corresponding ACL 'internal'.\n # if ( req.url ~ \"^\/(cron|install)\\.php\"\n # && client.ip !~ internal\n # ) {\n # # Have Varnish throw the error directly.\n # return (synth(403, \"Forbidden.\"));\n # # Use a custom error page that you've defined in Drupal at the path \"404\".\n # # set req.url = \"\/403\";\n # }\n\n \/* 8th: Custom exceptions *\/\n # Host exception example:\n # if ( req.http.host == \"ejemplo.exception.com\" ) {\n # return (pass);\n # }\n # Drupal exceptions, edit if we want to cache some AJAX\/AHAH request.\n # Add here filters for never cache URLs such as Payment Gateway's callbacks.\n if ( req.url ~ \"^\/status\\.php$\"\n || req.url ~ \"^\/update\\.php$\"\n || req.url ~ \"^\/ooyala\/ping$\"\n || req.url ~ \"^\/admin\/build\/features\"\n || req.url ~ \"^\/info\/.*$\"\n || req.url ~ \"^\/flag\/.*$\"\n || req.url ~ \"^.*\/ajax\/.*$\"\n || req.url ~ \"^.*\/ahah\/.*$\"\n ) {\n \/* Do not cache these paths *\/\n return (pass);\n }\n # Pipe these paths directly to backend for streaming.\n if ( req.url ~ \"^\/admin\/content\/backup_migrate\/export\" ) {\n return (pipe);\n }\n if ( req.url ~ \"^\/system\/files\" ) {\n return (pipe);\n }\n\n \/* 9th: Graced objets & Serve from anonymous cahe if all backends are down *\/\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n # set req.http.grace = \"none\";\n if ( ! std.healthy(req.backend_hint) ) {\n # We must do this here since cookie hashing\n unset req.http.Cookie;\n #TODO# Add sick marker\n } \n\n \/* 10th: Deal with compression and the Accept-Encoding header *\/\n # Althought Varnish 3 handles gziped content itself by default, just to be\n # sure we want to remove Accept-Encoding for some compressed formats.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html#what-does-http-gzip-support-do\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/varnishd.html?highlight=http_gzip_support\n # See (for older configs) https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleNormalizeAcceptEncoding\n if ( req.http.Accept-Encoding ) {\n if ( req.url ~ \"(?i)\\.(7z|avi|bz2|flv|gif|gz|jpe?g|mpe?g|mk[av]|mov|mp[34]|og[gm]|pdf|png|rar|swf|tar|tbz|tgz|woff2?|zip|xz)(\\?.*)?$\"\n ) {\n \/* Already compressed formats, no sense trying to compress again *\/\n unset req.http.Accept-Encoding;\n }\n }\n\n \/* 11th: Another request manipulation *\/\n # Empty in simple configs.\n # We could add here a custom header grouping User-agent families.\n # Generic URL manipulation.\n # Remove Google Analytics added parameters, useless for our backends.\n if ( req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=\" ) {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n # Strip anchors, server doesn't need it.\n if ( req.url ~ \"\\#\" ) {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n # Strip a trailing ? if it exists\n if ( req.url ~ \"\\?$\" ) {\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n # Normalize the querystring arguments\n set req.url = std.querysort(req.url);\n\n \/* 12th: Cookie removal *\/\n # Always cache the following static file types for all users. \n # Use with care if we control certain downloads depending on cookies. \n # Be carefull also if appending .htm[l] via Drupal's clean URLs.\n if ( req.url ~ \"(?i)\\.(bz2|css|eot|gif|gz|html?|ico|jpe?g|js|mp3|ogg|otf|pdf|png|rar|svg|swf|tbz|tgz|ttf|woff2?|zip)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n && req.url !~ \"\/system\/storage\/serve\"\n ) {\n unset req.http.Cookie;\n }\n # Remove all cookies that backend doesn't need to know about.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRemovingSomeCookies\n if ( req.http.Cookie ) {\n \/* Warning: Not a pretty solution *\/\n # Prefix header containing cookies with ';'\n set req.http.Cookie = \";\" + req.http.Cookie;\n # Remove any spaces after ';' in header containing cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n # Prefix cookies we want to preserve with one space:\n # 'S{1,2}ESS[a-z0-9]+' is the regular expression matching a Drupal session\n # cookie ({1,2} added for HTTPS support).\n # 'NO_CACHE' is usually set after a POST request to make sure issuing user\n # see the results of his post.\n # 'OATMEAL' & 'CHOCOLATECHIP' are special cookies used by Drupal's Bakery\n # module to provide Single Sign On.\n # Keep in mind we should add here any cookie that should reach the backend\n # such as splash avoiding cookies.\n set req.http.Cookie\n = regsuball(\n req.http.Cookie,\n \";(S{1,2}ESS[a-z0-9]+|NO_CACHE|OATMEAL|CHOCOLATECHIP)=\",\n \"; \\1=\"\n );\n # Remove from the header any single Cookie not prefixed with a space until\n # next ';' separator.\n set req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n # Remove any '; ' at the start or the end of the header.\n set req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n #If there are no remaining cookies, remove the cookie header.\n if ( req.http.Cookie == \"\" ) {\n unset req.http.Cookie;\n }\n }\n\n \/* 13th: Session cookie & special cookies bypass caching stage *\/\n # As we might want to cache some requests, hashed with its cookies, we don't\n # simply pass when some cookies remain present at this point.\n # Instead we look for request that must be passed due to the cookie header.\n if ( req.http.Cookie ~ \"SESS\"\n || req.http.Cookie ~ \"SSESS\"\n || req.http.Cookie ~ \"NO_CACHE\"\n || req.http.Cookie ~ \"OATMEAL\"\n || req.http.Cookie ~ \"CHOCOLATECHIP\"\n ) {\n return (pass);\n }\n\n \/* 14th: Announce ESI Support *\/\n # Empty in simple configs.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/esi.html\n # Note that ESI included requests inherits its parent's modified request, so\n # depending on the case you will end playing with req.esi_level to know\n # current depth.\n # Send Surrogate-Capability headers\n # See http:\/\/www.w3.org\/TR\/edge-arch\n # Note that myproxyname is an identifier that should avoid collitions\n # set req.http.Surrogate-Capability = \"myproxyname=ESI\/1.0\";\n\n \/* 15th: Bypass breakpoint 2 *\/\n # Useful for debugging we can now pipe or pass the request to backend to\n # bypass cache.\n # return (pipe);\n # return (pass);\n\n \/* 16th: Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n return (hash);\n}\n\n# vcl_pipe: Called upon entering pipe mode.\n# In this mode, the request is passed on to the backend, and any further data\n# from either client or backend is passed on unaltered until either end closes\n# the connection.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pipe\nsub vcl_pipe {\n # Websocket support\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html\n if ( req.http.upgrade ) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n}\n# sub vcl_pipe {\n# # By default Connection: close is set on all piped requests, to stop\n# # connection reuse from sending future requests directly to the\n# # (potentially) wrong backend. If you do want this to happen, you can undo\n# # it here.\n# # unset bereq.http.connection;\n# return (pipe);\n# }\n\n# vcl_pass: Called upon entering pass mode. \n# In this mode, the request is passed on to the backend, and the backend's\n# response is passed on to the client, but is not entered into the cache.\n# Subsequent requests submitted over the same client connection are handled normally.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pass\n# sub vcl_pass {\n# return (fetch);\n# }\n\n# vcl_hash: You may call hash_data() on the data you would like to add to the\n# hash.\n# Hash is used by Varnish to uniquely identify objects.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hash\nsub vcl_hash {\n \/* Hash cookie data *\/\n # As requests with same URL and host can produce diferent results when issued\n # with different cookies, we need to store items hashed with the associated\n # cookies. Note that cookies are already sanitized when we reach this point.\n if ( req.http.Cookie ) {\n \/* Include cookie in cache hash *\/\n hash_data(req.http.Cookie);\n }\n\n \/* Custom header hashing *\/\n # Empty in simple configs.\n # Example for caching differents object versions by device previously\n # detected (when static content could also vary):\n # if ( req.http.X-UA-Device ) {\n # hash_data(req.http.X-UA-Device);\n # }\n # Example for caching diferent object versions by X-Forwarded-Proto, trying\n # to be smart about what kind of request could generate diffetent responses.\n if ( req.http.X-Forwarded-Proto\n && req.url !~ \"(?i)\\.(bz2|css|eot|gif|gz|html?|ico|jpe?g|js|mp3|ogg|otf|pdf|png|rar|svg|swf|tbz|tgz|ttf|woff2?|zip)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n ) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (lookup);\n# }\n\n# vcl_purge: Called after the purge has been executed and all its variants have\n# been evited.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-purge\n# sub vcl_purge {\n# return (synth(200, \"Purged\"));\n# }\n\n# vcl_hit: Called after a cache lookup if the requested document was found in\n# the cache.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hit\nsub vcl_hit {\n if ( obj.ttl >= 0s ) {\n \/\/ A pure unadultered hit, deliver it\n return (deliver);\n }\n \/* Allow varnish to serve up stale content if it is responding slowly *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n if ( obj.ttl + 60s > 0s ) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n set req.http.grace = \"normal\";\n return (deliver);\n }\n \/* Allow varish to serve up stale content if all backends are down *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n if ( ! std.healthy(req.backend_hint)\n && obj.ttl + obj.grace > 0s\n ) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n set req.http.grace = \"extended\";\n return (deliver);\n }\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\n# vcl_miss: Called after a cache lookup if the requested document was not found\n# in the cache.\n# Its purpose is to decide whether or not to attempt to retrieve the document\n# from the backend, and which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-miss\n# sub vcl_miss {\n# return (fetch);\n# }\n\n# vcl_deliver: Called before an object is delivered to the client\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-deliver\nsub vcl_deliver {\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # Add whether the object is a cache hit or miss and the number of hits for\n # the object.\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Addingaheaderindicatinghitmiss\n # In Varnish 4 the obj.hits counter behaviour has changed (see bug 1492), so\n # we use a different method: if X-Varnish contains only 1 id, we have a miss,\n # if it contains more (and therefore a space), we have a hit.\n if ( resp.http.x-varnish ~ \" \" ) {\n set resp.http.X-Cache = \"HIT\";\n # Since in Varnish 4 the behaviour of obj.hits changed, this might not be\n # accurate.\n # See https:\/\/www.varnish-cache.org\/trac\/ticket\/1492\n set resp.http.X-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Cache = \"MISS\";\n \/* Show the results of cookie sanitization *\/\n set resp.http.X-Cookie = req.http.Cookie;\n }\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n set resp.http.grace = req.http.grace;\n\n #TODO# Add sick marker\n\n # Restart count\n if ( req.restarts > 0 ) {\n set resp.http.X-Restarts = req.restarts;\n }\n\n # Add the Varnish server hostname\n set resp.http.X-Varnish-Server = server.hostname;\n # If we have setted a custom header with device's family detected we can show\n # it:\n # if ( req.http.X-UA-Device ) {\n # set resp.http.X-UA-Device = req.http.X-UA-Device;\n # }\n # If we have recived a custom header indicating the protocol in the request we\n # can show it:\n # if ( req.http.X-Forwarded-Proto ) {\n # set resp.http.X-Forwarded-Proto = req.http.X-Forwarded-Proto;\n # }\n\n \/* Vary header manipulation *\/\n # Empty in simple configs.\n # By example, if we are storing & serving diferent objects depending on\n # User-Agent header we must set the correct Vary header:\n # if ( resp.http.Vary ) {\n # set resp.http.Vary = resp.http.Vary + \",User-Agent\";\n # } else {\n # set resp.http.Vary = \"User-Agent\";\n # }\n\n \/* Fake headers *\/\n # Empty in simple configs\n # We can fake server headers here, by example:\n # set resp.http.Server = \"Deep thought\";\n # set resp.http.X-Powered-By = \"BOFH\";\n # Or have some fun with headers:\n # See http:\/\/www.nextthing.org\/archives\/2005\/08\/07\/fun-with-http-headers\n # See http:\/\/royal.pingdom.com\/2012\/08\/15\/fun-and-unusual-http-response-headers\/\n # set resp.http.X-Thank-You = \"for bothering to look at my HTTP headers\";\n # set resp.http.X-Answer = \"42\";\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_deliver {\n# return (deliver);\n# }\n\n# vcl_synth: Called to deliver a synthetic object. A synthetic object is\n# generated in VCL, not fetched from the backend. It is typically contructed\n# using the synthetic() function.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-synth\n\/*\n * We can come here \"invisibly\" with the following errors: 413, 417 & 503\n *\/\nsub vcl_synth {\n \/* Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_synth;\n\n \/* Try to restart request in case of failure *\/\n # Note that max_restarts defaults to 4\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if ( resp.status == 503\n && req.restarts < 4\n ) {\n return (restart);\n }\n\n \/* Set common headers for synthetic responses *\/\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n\n \/* HTTP Authentification client request *\/\n # Empty in simple configs.\n # SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* Load synthetic responses from disk *\/\n # Note that files loaded this way are never re-readed (even after a reload).\n # You should consider PROS\/CONS of doing an include instead.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_std.generated.html#func-fileread\n # Example custom 403 error page.\n # if ( resp.status == 403 ) {\n # synthetic(std.fileread(\"\/403.html\"));\n # return (deliver);\n # }\n\n \/* Error page & refresh \/ redirections *\/\n # We have plenty of choices when we have to serve an error to the client, \n # from the default error page to javascript black magic or plain redirections.\n # Adding some external statistic javascript to track failures served to\n # clients is strongly suggested.\n # We can't use external resources on synthetic content, everything must be\n # inlined.\n # If we need to include images we can embed them in base64 encoding.\n # We're using error 200 for monitoring puposes which should not be retried\n # client side.\n if ( resp.status != 200 ) {\n set resp.http.Retry-After = \"5\";\n }\n\n # Here is the default error page for Varnish 4 (not so pretty)\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n return (deliver);\n}\n\n#######################################################################\n# Backend Fetch\n\n# vcl_backend_fetch: Called before sending the backend request. In this\n# subroutine you typically alter the request before it gets to the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-fetch\n# sub vcl_backend_fetch {\n# return (fetch);\n# }\n\n# vcl_backend_response: Called after the response headers has been successfully\n# retrieved from the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-response\nsub vcl_backend_response {\n \/* Caching exceptions *\/\n # Varnish will cache objects with response codes:\n # 200, 203, 300, 301, 302, 307, 404 & 410.\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/VCL_Basics.html#the-initial-value-of-beresp-ttl\n # Drupal's Imagecache module can return a 307 redirection to the requested\n # url itself and, depending on Drupal's cache settings, this could lead to a\n # redirection loop being cached for a long time but also we want Varnish to\n # shield a little the backend.\n # See http:\/\/drupal.org\/node\/1248010\n # See http:\/\/drupal.org\/node\/310656\n if ( beresp.status == 307\n #TODO# verify that this work better than 'bereq.url ~ \"imagecache\"'\n && beresp.http.Location == bereq.url\n && beresp.ttl > 5s\n ) {\n set beresp.ttl = 5s;\n set beresp.http.cache-control = \"max-age=5\";\n }\n\n \/* Request retrial *\/\n if ( beresp.status == 500\n || beresp.status == 503\n ) {\n #TODO# consider not restarting POST requests as seenV3 on https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleSaintMode\n return (retry);\n }\n\n \/* Enable grace mode. Related with vcl_hit *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n set beresp.grace = 1h;\n\n \/* Strip cookies from the following static file types for all users. *\/\n # Related with our 12th stage on vcl_recv\n if ( bereq.url ~ \"(?i)\\.(bz2|css|eot|gif|gz|html?|ico|jpe?g|js|mp3|ogg|otf|pdf|png|rar|svg|swf|tbz|tgz|ttf|woff2?|zip)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n ) {\n unset beresp.http.set-cookie;\n }\n\n \/* Process ESI responses *\/\n # Empty in simple configs.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/esi.html\n # Send Surrogate-Capability headers\n # See http:\/\/www.w3.org\/TR\/edge-arch\n # Note that myproxyname is an identifier that should avoid collitions\n # Check for ESI acknowledgement and remove Surrogate-Control header\n #TODO# Add support for Surrogate-Control Targetting\n # if ( beresp.http.Surrogate-Control ~ \"ESI\/1.0\" ) {\n # unset beresp.http.Surrogate-Control;\n # set beresp.do_esi = true;\n # }\n\n \/* Gzip response *\/\n # Empty in simple configs.\n # Use Varnish to Gzip respone, if suitable, before storing it on cache.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html\n if ( ! beresp.http.Content-Encoding\n && ( beresp.http.content-type ~ \"text\"\n || beresp.http.content-type ~ \"application\/x-javascript\"\n || beresp.http.content-type ~ \"application\/javascript\"\n || beresp.http.content-type ~ \"application\/rss+xml\"\n || beresp.http.content-type ~ \"application\/xml\"\n || beresp.http.content-type ~ \"Application\/JSON\")\n ) {\n set beresp.do_gzip = true;\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # We can add the name of the backend that has processed the request:\n # set beresp.http.X-Backend = beresp.backend.name;\n # We can use a header to tell if the object was gziped by Varnish:\n # if ( beresp.do_gzip ) {\n # set beresp.http.X-Varnish-Gzipped = \"yes\";\n # } else {\n # set beresp.http.X-Varnish-Gizipped = \"no\";\n # }\n # We can also add headers informing whether the object is cacheable or not and why:\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Varnish3.0\n if ( beresp.ttl <= 0s ) {\n \/* Varnish determined the object was not cacheable *\/\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n } elsif ( bereq.http.Cookie ~ \"(SESS|SSESS|NO_CACHE|OATMEAL|CHOCOLATECHIP)\" ) {\n \/* We don't wish to cache content for logged in users or with certain cookies. *\/\n # Related with our 9th stage on vcl_recv\n set beresp.http.X-Cacheable = \"NO:Cookies\";\n # set beresp.uncacheable = true;\n } elsif ( beresp.http.Cache-Control ~ \"private\" ) {\n \/* We are respecting the Cache-Control=private header from the backend *\/\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n # set beresp.uncacheable = true;\n } else {\n \/* Varnish determined the object was cacheable *\/\n set beresp.http.X-Cacheable = \"YES\";\n }\n\n \/* Further header manipulation *\/\n # Empty in simple configs.\n # We can also unset some headers to prevent information disclosure and save\n # some cache space.\n # unset beresp.http.Server;\n # unset beresp.http.X-Powered-By;\n # Retry count.\n if ( bereq.retries > 0 ) {\n set beresp.http.X-Retries = bereq.retries;\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_backend_response {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Surrogate-control ~ \"no-store\" ||\n# (!beresp.http.Surrogate-Control &&\n# beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n# beresp.http.Vary == \"*\") {\n# \/*\n# * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# *\/\n# set beresp.ttl = 120s;\n# set beresp.uncacheable = true;\n# }\n# return (deliver);\n# }\n\n# vcl_backend_error: This subroutine is called if we fail the backend fetch.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-error\nsub vcl_backend_error {\n\n \/* Try to restart request in case of failure *\/\n #TODO# Confirm max_retries default value\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if ( bereq.retries < 4 ) {\n return (retry);\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # Retry count\n if ( bereq.retries > 0 ) {\n set beresp.http.X-Retries = bereq.retries;\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + beresp.status + \" \" + beresp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + beresp.status + \" \" + beresp.reason + {\"<\/h1>\n <p>\"} + beresp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + bereq.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this\n # point.\n return (deliver);\n}\n\n#######################################################################\n# Housekeeping\n\n# vcl_init: Called when VCL is loaded, before any requests pass through it.\n# Typically used to initialize VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-init\n# Here is where you should declare your directors now.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-backends.html#directors\n# Empty in simple configs\n# sub vcl_init {\n# return (ok);\n# }\n\n# vcl_fini: Called when VCL is discarded only after all requests have exited\n# the VCL. Typically used to clean up VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-fini\n# sub vcl_fini {\n# return (ok);\n# }\n\n","old_contents":"\/*\n * Varnish 4 example config for Drupal 7 \/ Pressflow 6 & 7\n *\/\n\n# Original source: https:\/\/github.com\/NITEMAN\/varnish-bites\/varnish4\/drupal-base.vcl\n# Copyright (c) 2015 Pedro Gonz\u00e1lez Serrano and individual contributors.\n# MIT License\n\n# Intended to be used both in simple production environments and with\n# learning\/teaching purposes.\n# Some references may not be yet updated to VCL 4.0, we use SeeV3 then.\n\n# WARNING:\n# Note that the built-in logic will be appended to our code if no return is\n# performed before.\n# Built-in logic is included commented out right after our's for reference\n# purposes in that cases.\n# See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleDefault\n\n#######################################################################\n# Initialization: Version & imports;\n\n\/* Version statement *\/\n# Since Varnish 4.0 it's mandatory to declare VCL version on first line.\nvcl 4.0;\n\n\/* Module (VMOD) imports *\/\n# Standard module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_std.generated.html\nimport std;\n\n# Directors module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# Unused in simple configs.\n#import directors;\n\n\n#######################################################################\n# Probe, backend, ACL and subroutine definitions\n\n\/* Backend probes \/ healthchecks *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#probes\nprobe basic {\n \/* Only test that backend's IP serves content for '\/' *\/\n # This might be a too heavy probe\n # .url = \"\/\";\n\n \/* Only test that backend's IP has apache working *\/\n # Nginx would fail this probe with a default config\n .request =\n \"OPTIONS * HTTP\/1.1\"\n \"Host: *\"\n \"Connection: close\";\n\n \/* Common options *\/\n .interval = 10s;\n .timeout = 2s;\n .window = 8;\n .threshold = 6;\n}\n\n\/* Backend definitions.*\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#backend-definition\nbackend default {\n \/* Default backend on the same machine. *\/\n # WARNING: timeouts could be not big enought for certain POST requests.\n .host = \"127.0.0.1\";\n .port = \"8008\";\n .max_connections = 100;\n .connect_timeout = 60s;\n .first_byte_timeout = 60s;\n .between_bytes_timeout = 60s;\n .probe = basic;\n}\n\n\/* Access Control Lists *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#access-control-list-acl\nacl purge_ban {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use '\"localhost\";' instead\n}\nacl allowed_monitors {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n}\n# acl own_proxys {\n# \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n# }\n\n\/* Custom subroutines *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#subroutines\n#TODO# Test in Varnihs 4\n# Empty in simple configs.\n# The only restriction naming subs is that the 'vlc_' prefix is reserverd for\n# Varnish use. As a task can need several chunks of code in diferent states,\n# it's a good idea to identify what main sub will call each with a suffix.\n# \/* Example 301 client redirection removing \"www\" prefix from request *\/\n# sub perm_redirections_recv {\n# if ( req.http.host ~ \"^www.*$\" ) {\n# return (\n# synth(751, \"http:\/\/\" + regsub(req.http.host, \"^www\\.\", \"\") + req.url)\n# );\n# }\n# }\n# sub perm_redirections_synth {\n# if ( resp.status == 751 ) {\n# \/* Get new URL from the response *\/\n# set resp.http.Location = resp.response;\n# \/* Set HTTP 301 for permanent redirect *\/\n# set resp.status = 301;\n# return (deliver);\n# }\n# }\n\n\n#######################################################################\n# Client side\n\n# vcl_recv: Called at the beginning of a request, after the complete request\n# has been received and parsed. Its purpose is to decide whether or not to\n# serve the request, how to do it, and, if applicable, which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-recv\nsub vcl_recv {\n \/* 0th: general bypass, general return & authorization checks *\/\n # Empty in simple configs.\n # Useful for debugging we can pipe or pass the request to default backend\n # here to bypass completely Varnish.\n # return (pipe);\n # return (pass);\n # We can also return here a 200 Ok for network performance benchmarking.\n # return (synth(200, \"Ok\"));\n # Finally we can perform basic HTTP authentification here, by example.\n # SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* 1st: Check for Varnish special requests *\/ \n # Custom response implementation example in order to check that Varnish is\n # working properly.\n # This is usefull for automatic monitoring with monit or when Varnish is\n # behind another proxies like HAProxy.\n if ( ( req.http.host == \"monitor.server.health\"\n || req.http.host == \"health.varnish\" )\n && client.ip ~ allowed_monitors\n && ( req.method == \"OPTIONS\" || req.method == \"GET\" )\n ) {\n return (synth(200, \"Ban added\"));\n }\n # Purge logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#http-purging\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if ( req.method == \"PURGE\" ) {\n if ( client.ip !~ purge_ban ) {\n return (synth(405, \"Not allowed.\"));\n }\n return (purge);\n }\n # Ban logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#bans\n if ( req.method == \"BAN\" ) {\n if ( client.ip !~ purge_ban ) {\n return (synth(405, \"Not allowed.\"));\n }\n ban( \"req.http.host == \" + req.http.host +\n \"&& req.url == \" + req.url);\n return (synth(200, \"Ban added\"));\n }\n\n \/* 2nd: Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_recv;\n # Here we can also enforce SSL when Varnish run behind some SSL termination\n # point.\n\n \/* 3rd: Time for backend choice *\/\n # Empty in simple configs.\n\n \/* 4th: Prepare request for the backend *\/\n # Empty in simple configs.\n # Example remove own_proxys from X-Forwarded-For\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/whats-new\/upgrading.html#x-forwarded-for-is-now-set-before-vcl-recv\n # if ( req.restarts == 0\n # && client.ip ~ own_proxys\n # && req.http.x-forwarded-for\n # ) {\n # set req.http.X-Forwarded-For\n # = regsub(req.http.X-Forwarded-For, \",( )?\" + client.ip, \"\");\n # }\n # Example normalize the host header, remove the port (in case you're testing\n # this on various TCP ports)\n # set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n \/* 5th: Bypass breakpoint 1 *\/\n # Useful for debugging we can now pipe or pass the request to backend with\n # headers setted.\n # return (pipe);\n # return (pass);\n\n \/* 6th: Decide if we should deal with a request (mostly from built-in logic) *\/\n if ( req.method == \"PRI\" ) {\n \/* We do not support SPDY or HTTP\/2.0 *\/\n return (synth(405));\n }\n if ( req.method != \"GET\"\n && req.method != \"HEAD\"\n && req.method != \"PUT\"\n && req.method != \"POST\"\n && req.method != \"TRACE\"\n && req.method != \"OPTIONS\"\n && req.method != \"DELETE\"\n ) {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if ( req.method != \"GET\"\n && req.method != \"HEAD\"\n ) {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if ( req.http.Authorization ) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n # Websocket support\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html\n if ( req.http.Upgrade ~ \"(?i)websocket\" ) {\n return (pipe);\n }\n\n \/* 7th: Access control for some URLs by ACL *\/\n # Empty in simple configs.\n # By example denial some URLs depending on client-ip, we'll need to define\n # corresponding ACL 'internal'.\n # if ( req.url ~ \"^\/(cron|install)\\.php\"\n # && client.ip !~ internal\n # ) {\n # # Have Varnish throw the error directly.\n # return (synth(403, \"Forbidden.\"));\n # # Use a custom error page that you've defined in Drupal at the path \"404\".\n # # set req.url = \"\/403\";\n # }\n\n \/* 8th: Custom exceptions *\/\n # Host exception example:\n # if ( req.http.host == \"ejemplo.exception.com\" ) {\n # return (pass);\n # }\n # Drupal exceptions, edit if we want to cache some AJAX\/AHAH request.\n # Add here filters for never cache URLs such as Payment Gateway's callbacks.\n if ( req.url ~ \"^\/status\\.php$\"\n || req.url ~ \"^\/update\\.php$\"\n || req.url ~ \"^\/ooyala\/ping$\"\n || req.url ~ \"^\/admin\/build\/features\"\n || req.url ~ \"^\/info\/.*$\"\n || req.url ~ \"^\/flag\/.*$\"\n || req.url ~ \"^.*\/ajax\/.*$\"\n || req.url ~ \"^.*\/ahah\/.*$\"\n ) {\n \/* Do not cache these paths *\/\n return (pass);\n }\n # Pipe these paths directly to backend for streaming.\n if ( req.url ~ \"^\/admin\/content\/backup_migrate\/export\" ) {\n return (pipe);\n }\n if ( req.url ~ \"^\/system\/files\" ) {\n return (pipe);\n }\n\n \/* 9th: Graced objets & Serve from anonymous cahe if all backends are down *\/\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n # set req.http.grace = \"none\";\n if ( ! std.healthy(req.backend_hint) ) {\n # We must do this here since cookie hashing\n unset req.http.Cookie;\n #TODO# Add sick marker\n } \n\n \/* 10th: Deal with compression and the Accept-Encoding header *\/\n # Althought Varnish 3 handles gziped content itself by default, just to be\n # sure we want to remove Accept-Encoding for some compressed formats.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html#what-does-http-gzip-support-do\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/varnishd.html?highlight=http_gzip_support\n # See (for older configs) https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleNormalizeAcceptEncoding\n if ( req.http.Accept-Encoding ) {\n if ( req.url ~ \"(?i)\\.(7z|avi|bz2|flv|gif|gz|jpe?g|mpe?g|mk[av]|mov|mp[34]|og[gm]|pdf|png|rar|swf|tar|tbz|tgz|woff2?|zip|xz)(\\?.*)?$\"\n ) {\n \/* Already compressed formats, no sense trying to compress again *\/\n unset req.http.Accept-Encoding;\n }\n }\n\n \/* 11th: Another request manipulation *\/\n # Empty in simple configs.\n # We could add here a custom header grouping User-agent families.\n\n \/* 12th: Cookie removal *\/\n # Always cache the following static file types for all users. \n # Use with care if we control certain downloads depending on cookies. \n # Be carefull also if appending .htm[l] via Drupal's clean URLs.\n if ( req.url ~ \"(?i)\\.(bz2|css|eot|gif|gz|html?|ico|jpe?g|js|mp3|ogg|otf|pdf|png|rar|svg|swf|tbz|tgz|ttf|woff2?|zip)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n && req.url !~ \"\/system\/storage\/serve\"\n ) {\n unset req.http.Cookie;\n }\n # Remove all cookies that backend doesn't need to know about.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRemovingSomeCookies\n if ( req.http.Cookie ) {\n \/* Warning: Not a pretty solution *\/\n # Prefix header containing cookies with ';'\n set req.http.Cookie = \";\" + req.http.Cookie;\n # Remove any spaces after ';' in header containing cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n # Prefix cookies we want to preserve with one space:\n # 'S{1,2}ESS[a-z0-9]+' is the regular expression matching a Drupal session\n # cookie ({1,2} added for HTTPS support).\n # 'NO_CACHE' is usually set after a POST request to make sure issuing user\n # see the results of his post.\n # 'OATMEAL' & 'CHOCOLATECHIP' are special cookies used by Drupal's Bakery\n # module to provide Single Sign On.\n # Keep in mind we should add here any cookie that should reach the backend\n # such as splash avoiding cookies.\n set req.http.Cookie\n = regsuball(\n req.http.Cookie,\n \";(S{1,2}ESS[a-z0-9]+|NO_CACHE|OATMEAL|CHOCOLATECHIP)=\",\n \"; \\1=\"\n );\n # Remove from the header any single Cookie not prefixed with a space until\n # next ';' separator.\n set req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n # Remove any '; ' at the start or the end of the header.\n set req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n #If there are no remaining cookies, remove the cookie header.\n if ( req.http.Cookie == \"\" ) {\n unset req.http.Cookie;\n }\n }\n\n \/* 13th: Session cookie & special cookies bypass caching stage *\/\n # As we might want to cache some requests, hashed with its cookies, we don't\n # simply pass when some cookies remain present at this point.\n # Instead we look for request that must be passed due to the cookie header.\n if ( req.http.Cookie ~ \"SESS\"\n || req.http.Cookie ~ \"SSESS\"\n || req.http.Cookie ~ \"NO_CACHE\"\n || req.http.Cookie ~ \"OATMEAL\"\n || req.http.Cookie ~ \"CHOCOLATECHIP\"\n ) {\n return (pass);\n }\n\n \/* 14th: Announce ESI Support *\/\n # Empty in simple configs.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/esi.html\n # Note that ESI included requests inherits its parent's modified request, so\n # depending on the case you will end playing with req.esi_level to know\n # current depth.\n # Send Surrogate-Capability headers\n # See http:\/\/www.w3.org\/TR\/edge-arch\n # Note that myproxyname is an identifier that should avoid collitions\n # set req.http.Surrogate-Capability = \"myproxyname=ESI\/1.0\";\n\n \/* 15th: Bypass breakpoint 2 *\/\n # Useful for debugging we can now pipe or pass the request to backend to\n # bypass cache.\n # return (pipe);\n # return (pass);\n\n \/* 16th: Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n return (hash);\n}\n\n# vcl_pipe: Called upon entering pipe mode.\n# In this mode, the request is passed on to the backend, and any further data\n# from either client or backend is passed on unaltered until either end closes\n# the connection.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pipe\nsub vcl_pipe {\n # Websocket support\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html\n if ( req.http.upgrade ) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n}\n# sub vcl_pipe {\n# # By default Connection: close is set on all piped requests, to stop\n# # connection reuse from sending future requests directly to the\n# # (potentially) wrong backend. If you do want this to happen, you can undo\n# # it here.\n# # unset bereq.http.connection;\n# return (pipe);\n# }\n\n# vcl_pass: Called upon entering pass mode. \n# In this mode, the request is passed on to the backend, and the backend's\n# response is passed on to the client, but is not entered into the cache.\n# Subsequent requests submitted over the same client connection are handled normally.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pass\n# sub vcl_pass {\n# return (fetch);\n# }\n\n# vcl_hash: You may call hash_data() on the data you would like to add to the\n# hash.\n# Hash is used by Varnish to uniquely identify objects.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hash\nsub vcl_hash {\n \/* Hash cookie data *\/\n # As requests with same URL and host can produce diferent results when issued\n # with different cookies, we need to store items hashed with the associated\n # cookies. Note that cookies are already sanitized when we reach this point.\n if ( req.http.Cookie ) {\n \/* Include cookie in cache hash *\/\n hash_data(req.http.Cookie);\n }\n\n \/* Custom header hashing *\/\n # Empty in simple configs.\n # Example for caching differents object versions by device previously\n # detected (when static content could also vary):\n # if ( req.http.X-UA-Device ) {\n # hash_data(req.http.X-UA-Device);\n # }\n # Example for caching diferent object versions by X-Forwarded-Proto, trying\n # to be smart about what kind of request could generate diffetent responses.\n if ( req.http.X-Forwarded-Proto\n && req.url !~ \"(?i)\\.(bz2|css|eot|gif|gz|html?|ico|jpe?g|js|mp3|ogg|otf|pdf|png|rar|svg|swf|tbz|tgz|ttf|woff2?|zip)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n ) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (lookup);\n# }\n\n# vcl_purge: Called after the purge has been executed and all its variants have\n# been evited.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-purge\n# sub vcl_purge {\n# return (synth(200, \"Purged\"));\n# }\n\n# vcl_hit: Called after a cache lookup if the requested document was found in\n# the cache.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hit\nsub vcl_hit {\n if ( obj.ttl >= 0s ) {\n \/\/ A pure unadultered hit, deliver it\n return (deliver);\n }\n \/* Allow varnish to serve up stale content if it is responding slowly *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n if ( obj.ttl + 60s > 0s ) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n set req.http.grace = \"normal\";\n return (deliver);\n }\n \/* Allow varish to serve up stale content if all backends are down *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n if ( ! std.healthy(req.backend_hint)\n && obj.ttl + obj.grace > 0s\n ) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n set req.http.grace = \"extended\";\n return (deliver);\n }\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\n# vcl_miss: Called after a cache lookup if the requested document was not found\n# in the cache.\n# Its purpose is to decide whether or not to attempt to retrieve the document\n# from the backend, and which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-miss\n# sub vcl_miss {\n# return (fetch);\n# }\n\n# vcl_deliver: Called before an object is delivered to the client\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-deliver\nsub vcl_deliver {\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # Add whether the object is a cache hit or miss and the number of hits for\n # the object.\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Addingaheaderindicatinghitmiss\n # In Varnish 4 the obj.hits counter behaviour has changed (see bug 1492), so\n # we use a different method: if X-Varnish contains only 1 id, we have a miss,\n # if it contains more (and therefore a space), we have a hit.\n if ( resp.http.x-varnish ~ \" \" ) {\n set resp.http.X-Cache = \"HIT\";\n # Since in Varnish 4 the behaviour of obj.hits changed, this might not be\n # accurate.\n # See https:\/\/www.varnish-cache.org\/trac\/ticket\/1492\n set resp.http.X-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Cache = \"MISS\";\n \/* Show the results of cookie sanitization *\/\n set resp.http.X-Cookie = req.http.Cookie;\n }\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n set resp.http.grace = req.http.grace;\n\n #TODO# Add sick marker\n\n # Restart count\n if ( req.restarts > 0 ) {\n set resp.http.X-Restarts = req.restarts;\n }\n\n # Add the Varnish server hostname\n set resp.http.X-Varnish-Server = server.hostname;\n # If we have setted a custom header with device's family detected we can show\n # it:\n # if ( req.http.X-UA-Device ) {\n # set resp.http.X-UA-Device = req.http.X-UA-Device;\n # }\n # If we have recived a custom header indicating the protocol in the request we\n # can show it:\n # if ( req.http.X-Forwarded-Proto ) {\n # set resp.http.X-Forwarded-Proto = req.http.X-Forwarded-Proto;\n # }\n\n \/* Vary header manipulation *\/\n # Empty in simple configs.\n # By example, if we are storing & serving diferent objects depending on\n # User-Agent header we must set the correct Vary header:\n # if ( resp.http.Vary ) {\n # set resp.http.Vary = resp.http.Vary + \",User-Agent\";\n # } else {\n # set resp.http.Vary = \"User-Agent\";\n # }\n\n \/* Fake headers *\/\n # Empty in simple configs\n # We can fake server headers here, by example:\n # set resp.http.Server = \"Deep thought\";\n # set resp.http.X-Powered-By = \"BOFH\";\n # Or have some fun with headers:\n # See http:\/\/www.nextthing.org\/archives\/2005\/08\/07\/fun-with-http-headers\n # See http:\/\/royal.pingdom.com\/2012\/08\/15\/fun-and-unusual-http-response-headers\/\n # set resp.http.X-Thank-You = \"for bothering to look at my HTTP headers\";\n # set resp.http.X-Answer = \"42\";\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_deliver {\n# return (deliver);\n# }\n\n# vcl_synth: Called to deliver a synthetic object. A synthetic object is\n# generated in VCL, not fetched from the backend. It is typically contructed\n# using the synthetic() function.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-synth\n\/*\n * We can come here \"invisibly\" with the following errors: 413, 417 & 503\n *\/\nsub vcl_synth {\n \/* Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_synth;\n\n \/* Try to restart request in case of failure *\/\n # Note that max_restarts defaults to 4\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if ( resp.status == 503\n && req.restarts < 4\n ) {\n return (restart);\n }\n\n \/* Set common headers for synthetic responses *\/\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n\n \/* HTTP Authentification client request *\/\n # Empty in simple configs.\n # SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* Load synthetic responses from disk *\/\n # Note that files loaded this way are never re-readed (even after a reload).\n # You should consider PROS\/CONS of doing an include instead.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_std.generated.html#func-fileread\n # Example custom 403 error page.\n # if ( resp.status == 403 ) {\n # synthetic(std.fileread(\"\/403.html\"));\n # return (deliver);\n # }\n\n \/* Error page & refresh \/ redirections *\/\n # We have plenty of choices when we have to serve an error to the client, \n # from the default error page to javascript black magic or plain redirections.\n # Adding some external statistic javascript to track failures served to\n # clients is strongly suggested.\n # We can't use external resources on synthetic content, everything must be\n # inlined.\n # If we need to include images we can embed them in base64 encoding.\n # We're using error 200 for monitoring puposes which should not be retried\n # client side.\n if ( resp.status != 200 ) {\n set resp.http.Retry-After = \"5\";\n }\n\n # Here is the default error page for Varnish 4 (not so pretty)\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n return (deliver);\n}\n\n#######################################################################\n# Backend Fetch\n\n# vcl_backend_fetch: Called before sending the backend request. In this\n# subroutine you typically alter the request before it gets to the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-fetch\n# sub vcl_backend_fetch {\n# return (fetch);\n# }\n\n# vcl_backend_response: Called after the response headers has been successfully\n# retrieved from the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-response\nsub vcl_backend_response {\n \/* Caching exceptions *\/\n # Varnish will cache objects with response codes:\n # 200, 203, 300, 301, 302, 307, 404 & 410.\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/VCL_Basics.html#the-initial-value-of-beresp-ttl\n # Drupal's Imagecache module can return a 307 redirection to the requested\n # url itself and, depending on Drupal's cache settings, this could lead to a\n # redirection loop being cached for a long time but also we want Varnish to\n # shield a little the backend.\n # See http:\/\/drupal.org\/node\/1248010\n # See http:\/\/drupal.org\/node\/310656\n if ( beresp.status == 307\n #TODO# verify that this work better than 'bereq.url ~ \"imagecache\"'\n && beresp.http.Location == bereq.url\n && beresp.ttl > 5s\n ) {\n set beresp.ttl = 5s;\n set beresp.http.cache-control = \"max-age=5\";\n }\n\n \/* Request retrial *\/\n if ( beresp.status == 500\n || beresp.status == 503\n ) {\n #TODO# consider not restarting POST requests as seenV3 on https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleSaintMode\n return (retry);\n }\n\n \/* Enable grace mode. Related with vcl_hit *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n set beresp.grace = 1h;\n\n \/* Strip cookies from the following static file types for all users. *\/\n # Related with our 12th stage on vcl_recv\n if ( bereq.url ~ \"(?i)\\.(bz2|css|eot|gif|gz|html?|ico|jpe?g|js|mp3|ogg|otf|pdf|png|rar|svg|swf|tbz|tgz|ttf|woff2?|zip)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n ) {\n unset beresp.http.set-cookie;\n }\n\n \/* Process ESI responses *\/\n # Empty in simple configs.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/esi.html\n # Send Surrogate-Capability headers\n # See http:\/\/www.w3.org\/TR\/edge-arch\n # Note that myproxyname is an identifier that should avoid collitions\n # Check for ESI acknowledgement and remove Surrogate-Control header\n #TODO# Add support for Surrogate-Control Targetting\n # if ( beresp.http.Surrogate-Control ~ \"ESI\/1.0\" ) {\n # unset beresp.http.Surrogate-Control;\n # set beresp.do_esi = true;\n # }\n\n \/* Gzip response *\/\n # Empty in simple configs.\n # Use Varnish to Gzip respone, if suitable, before storing it on cache.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html\n if ( ! beresp.http.Content-Encoding\n && ( beresp.http.content-type ~ \"text\"\n || beresp.http.content-type ~ \"application\/x-javascript\"\n || beresp.http.content-type ~ \"application\/javascript\"\n || beresp.http.content-type ~ \"application\/rss+xml\"\n || beresp.http.content-type ~ \"application\/xml\"\n || beresp.http.content-type ~ \"Application\/JSON\")\n ) {\n set beresp.do_gzip = true;\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # We can add the name of the backend that has processed the request:\n # set beresp.http.X-Backend = beresp.backend.name;\n # We can use a header to tell if the object was gziped by Varnish:\n # if ( beresp.do_gzip ) {\n # set beresp.http.X-Varnish-Gzipped = \"yes\";\n # } else {\n # set beresp.http.X-Varnish-Gizipped = \"no\";\n # }\n # We can also add headers informing whether the object is cacheable or not and why:\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Varnish3.0\n if ( beresp.ttl <= 0s ) {\n \/* Varnish determined the object was not cacheable *\/\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n } elsif ( bereq.http.Cookie ~ \"(SESS|SSESS|NO_CACHE|OATMEAL|CHOCOLATECHIP)\" ) {\n \/* We don't wish to cache content for logged in users or with certain cookies. *\/\n # Related with our 9th stage on vcl_recv\n set beresp.http.X-Cacheable = \"NO:Cookies\";\n # set beresp.uncacheable = true;\n } elsif ( beresp.http.Cache-Control ~ \"private\" ) {\n \/* We are respecting the Cache-Control=private header from the backend *\/\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n # set beresp.uncacheable = true;\n } else {\n \/* Varnish determined the object was cacheable *\/\n set beresp.http.X-Cacheable = \"YES\";\n }\n\n \/* Further header manipulation *\/\n # Empty in simple configs.\n # We can also unset some headers to prevent information disclosure and save\n # some cache space.\n # unset beresp.http.Server;\n # unset beresp.http.X-Powered-By;\n # Retry count.\n if ( bereq.retries > 0 ) {\n set beresp.http.X-Retries = bereq.retries;\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_backend_response {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Surrogate-control ~ \"no-store\" ||\n# (!beresp.http.Surrogate-Control &&\n# beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n# beresp.http.Vary == \"*\") {\n# \/*\n# * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# *\/\n# set beresp.ttl = 120s;\n# set beresp.uncacheable = true;\n# }\n# return (deliver);\n# }\n\n# vcl_backend_error: This subroutine is called if we fail the backend fetch.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-error\nsub vcl_backend_error {\n\n \/* Try to restart request in case of failure *\/\n #TODO# Confirm max_retries default value\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if ( bereq.retries < 4 ) {\n return (retry);\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # Retry count\n if ( bereq.retries > 0 ) {\n set beresp.http.X-Retries = bereq.retries;\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + beresp.status + \" \" + beresp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + beresp.status + \" \" + beresp.reason + {\"<\/h1>\n <p>\"} + beresp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + bereq.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this\n # point.\n return (deliver);\n}\n\n#######################################################################\n# Housekeeping\n\n# vcl_init: Called when VCL is loaded, before any requests pass through it.\n# Typically used to initialize VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-init\n# Here is where you should declare your directors now.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-backends.html#directors\n# Empty in simple configs\n# sub vcl_init {\n# return (ok);\n# }\n\n# vcl_fini: Called when VCL is discarded only after all requests have exited\n# the VCL. Typically used to clean up VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-fini\n# sub vcl_fini {\n# return (ok);\n# }\n\n","returncode":0,"stderr":"","license":"unknown","lang":"VCL"} {"commit":"1dcf15f5fccac77ed1ccabdfd3f52e897826aa8f","subject":"Have varnish honor a Surrogate-Control max-age","message":"Have varnish honor a Surrogate-Control max-age\n","repos":"evolution\/wordpress,jalevin\/wordpress,jalevin\/wordpress,jalevin\/wordpress,evolution\/wordpress,evolution\/wordpress,evolution\/wordpress,jalevin\/wordpress,evolution\/wordpress,jalevin\/wordpress","old_file":"lib\/ansible\/roles\/varnish\/files\/etc-varnish\/production.vcl","new_file":"lib\/ansible\/roles\/varnish\/files\/etc-varnish\/production.vcl","new_contents":"# Default backend definition. Set this to point to your content server.\n# all paths relative to varnish option vcl_dir\nimport std;\n\ninclude \"custom.backend.vcl\";\ninclude \"custom.acl.vcl\";\n\n# Handle the HTTP request received by the client\nsub vcl_recv {\n # varnish serves stale (but cacheable) objects while retriving object from backend\n if (req.backend.healthy) {\n set req.grace = 30s;\n } else {\n set req.grace = 1h;\n }\n\n # shortcut for DFind requests\n if (req.url ~ \"^\/w00tw00t\") {\n error 404 \"Not Found\";\n }\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n # Normalize the header, remove the port (in case you're testing this on various TCP ports)\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n # Allow purging\n if (req.request == \"PURGE\") {\n if (!client.ip ~ purge) {\n # Not from an allowed IP? Then die with an error.\n error 405 \"This IP is not allowed to send PURGE requests.\";\n }\n\n # If you got this stage (and didn't error out above), do a cache-lookup\n # That will force entry into vcl_hit() or vcl_miss() below and purge the actual cache\n return (lookup);\n }\n\n # Only deal with \"normal\" types\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"PATCH\" &&\n req.request != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n # We only deal with GET and HEAD by default\n return (pass);\n }\n\n # Some generic URL manipulation, useful for all templates that follow\n # First remove the Google Analytics added parameters, useless for our backend\n if (req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=\") {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # Strip hash, server doesn't need it.\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n # Strip a trailing ? if it exists\n if (req.url ~ \"\\?$\") {\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # This is an example to redirect with a 301\/302 HTTP status code from within Varnish\n # if (req.http.Host ~ \"secure.mysite.tld\") {\n # # We may want to force our users from the secure site to the HTTPs version?\n # error 720 \"https:\/\/secure.mysite.tld\";\n # # If you want to keep the URLs intact, this also works:\n # error 720 \"https:\/\/\" + req.http.Host + req.url;\n # }\n #\n # Or to force a 302 temporary redirect, use error 721\n # if (req.http.Host ~ \"temp.mysite.tld\") {\n # # Temporary redirect\n # error 721 \"http:\/\/mysite.tld\/temp\";\n # }\n #\n\n # Some generic cookie manipulation, useful for all templates that follow\n\n # Remove any '_' prefixed cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"(^|;\\s*)_[^=]+=[^;]*\", \"\");\n\n # Remove a \";\" prefix in the cookie if present\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n\n # Are there cookies left with only spaces or that are empty?\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n\n # Normalize Accept-Encoding header\n # straight from the manual: https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/vary.html\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n # No point in compressing these\n remove req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n # unkown algorithm\n remove req.http.Accept-Encoding;\n }\n }\n\n # Include custom vcl_recv logic\n include \"conf.d\/receive\/wordpress.vcl\";\n\n # Remove all cookies for static files\n # A valid discussion could be held on this line: do you really need to cache static files that don't cause load? Only if you have memory left.\n # Sure, there's disk I\/O, but chances are your OS will already have these files in their buffers (thus memory).\n # Before you blindly enable this, have a read here: http:\/\/mattiasgeniar.be\/2012\/11\/28\/stop-caching-static-files\/\n # if (req.url ~ \"^[^?]*\\.(bmp|bz2|css|doc|eot|flv|gif|gz|ico|jpeg|jpg|js|less|mp[34]|pdf|png|rar|rtf|swf|tar|tgz|txt|wav|woff|xml|zip)(\\?.*)?$\") {\n # unset req.http.Cookie;\n # return (lookup);\n # }\n\n # Send Surrogate-Capability headers to announce ESI support to backend\n set req.http.Surrogate-Capability = \"key=ESI\/1.0\";\n\n if (req.http.Authorization || req.http.Cookie) {\n # Not cacheable by default\n return (pass);\n }\n\n return (lookup);\n}\n\nsub vcl_pipe {\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n # set bereq.http.connection = \"close\";\n # here. It is not set by default as it might break some broken web\n # applications, like IIS with NTLM authentication.\n\n #set bereq.http.Connection = \"Close\";\n return (pipe);\n}\n\nsub vcl_pass {\n return (pass);\n}\n\n# The data on which the hashing will take place\nsub vcl_hash {\n hash_data(req.url);\n\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n\n # hash cookies for object with auth\n if (req.http.Cookie) {\n hash_data(req.http.Cookie);\n }\n if (req.http.Authorization) {\n hash_data(req.http.Authorization);\n }\n\n # hash forwarded protocol, if present\n if (req.http.X-Forwarded-Proto) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n\n return (hash);\n}\n\nsub vcl_hit {\n # Allow purges\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"purged\";\n }\n\n return (deliver);\n}\n\nsub vcl_miss {\n # Allow purges\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"purged\";\n }\n\n return (fetch);\n}\n\n# Handle the HTTP request coming from our backend\nsub vcl_fetch {\n set beresp.grace = 1h;\n\n # Include custom vcl_fetch logic\n include \"conf.d\/fetch\/wordpress.vcl\";\n\n # Parse ESI request and remove Surrogate-Control header\n if (beresp.http.Surrogate-Control ~ \"ESI\/1.0\") {\n # Honor max-age, if provided, from Surrogate-Control\n if (beresp.http.Surrogate-Control ~ \"max-age=\\d+[smhdw]?\") {\n set beresp.ttl = std.duration(regsub(beresp.http.Surrogate-Control, \"^.*?max-age=(\\d+[smhdw]?).*?$\", \"\\1\"), beresp.ttl);\n }\n unset beresp.http.Surrogate-Control;\n set beresp.do_esi = true;\n }\n\n # If the request to the backend returns a code is 5xx, return the error page\n if (beresp.status >= 500 && beresp.status <= 599){\n return(hit_for_pass);\n }\n\n # Enable cache for all static files\n # The same argument as the static caches from above: monitor your cache size, if you get data nuked out of it, consider giving up the static file cache.\n # Before you blindly enable this, have a read here: http:\/\/mattiasgeniar.be\/2012\/11\/28\/stop-caching-static-files\/\n # if (req.url ~ \"^[^?]*\\.(bmp|bz2|css|doc|eot|flv|gif|gz|ico|jpeg|jpg|js|less|mp[34]|pdf|png|rar|rtf|swf|tar|tgz|txt|wav|woff|xml|zip)(\\?.*)?$\") {\n # unset beresp.http.set-cookie;\n # }\n\n # Sometimes, a 301 or 302 redirect formed via Apache's mod_rewrite can mess with the HTTP port that is being passed along.\n # This often happens with simple rewrite rules in a scenario where Varnish runs on :80 and Apache on :8080 on the same box.\n # A redirect can then often redirect the end-user to a URL on :8080, where it should be :80.\n # This may need finetuning on your setup.\n #\n # To prevent accidental replace, we only filter the 301\/302 redirects for now.\n if (beresp.status == 301 || beresp.status == 302) {\n set beresp.http.Location = regsub(beresp.http.Location, \":[0-9]+\", \"\");\n }\n\n # Don't cache user & server errors\n if (beresp.status >= 400) {\n return (hit_for_pass);\n }\n\n # Non private responses without cookies and with a ttl of 0 should be artificially extended to 1 hour\n if (beresp.ttl <= 0s && beresp.http.Cache-Control !~ \"private\" && (!beresp.http.Set-Cookie)) {\n set beresp.ttl = 1h;\n set beresp.http.X-Cache-Extended = \"1\";\n }\n\n # Set 2min cache if unset for static files\n if (beresp.ttl <= 0s || beresp.http.Set-Cookie || beresp.http.Vary == \"*\") {\n set beresp.ttl = 120s;\n return (hit_for_pass);\n }\n\n return (deliver);\n}\n\n# The routine when we deliver the HTTP request to the user\n# Last chance to modify headers that are sent to the client\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"cached\";\n } else {\n set resp.http.x-Cache = \"uncached\";\n }\n\n # Remove some headers: PHP version\n unset resp.http.X-Powered-By;\n\n # Remove some headers: Apache version & OS\n unset resp.http.Server;\n unset resp.http.X-Drupal-Cache;\n unset resp.http.X-Varnish;\n unset resp.http.Via;\n unset resp.http.Link;\n\n return (deliver);\n}\n\nsub vcl_error {\n if (obj.status == 720) {\n # We use this special error status 720 to force redirects with 301 (permanent) redirects\n # To use this, call the following from anywhere in vcl_recv: error 720 \"http:\/\/host\/new.html\"\n set obj.status = 301;\n set obj.http.Location = obj.response;\n return (deliver);\n } elseif (obj.status == 721) {\n # And we use error status 721 to force redirects with a 302 (temporary) redirect\n # To use this, call the following from anywhere in vcl_recv: error 720 \"http:\/\/host\/new.html\"\n set obj.status = 302;\n set obj.http.Location = obj.response;\n return (deliver);\n }\n\n return (deliver);\n}\n\nsub vcl_init {\n return (ok);\n}\n\nsub vcl_fini {\n return (ok);\n}\n","old_contents":"# Default backend definition. Set this to point to your content server.\n# all paths relative to varnish option vcl_dir\n\ninclude \"custom.backend.vcl\";\ninclude \"custom.acl.vcl\";\n\n# Handle the HTTP request received by the client\nsub vcl_recv {\n # varnish serves stale (but cacheable) objects while retriving object from backend\n if (req.backend.healthy) {\n set req.grace = 30s;\n } else {\n set req.grace = 1h;\n }\n\n # shortcut for DFind requests\n if (req.url ~ \"^\/w00tw00t\") {\n error 404 \"Not Found\";\n }\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n # Normalize the header, remove the port (in case you're testing this on various TCP ports)\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n # Allow purging\n if (req.request == \"PURGE\") {\n if (!client.ip ~ purge) {\n # Not from an allowed IP? Then die with an error.\n error 405 \"This IP is not allowed to send PURGE requests.\";\n }\n\n # If you got this stage (and didn't error out above), do a cache-lookup\n # That will force entry into vcl_hit() or vcl_miss() below and purge the actual cache\n return (lookup);\n }\n\n # Only deal with \"normal\" types\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"PATCH\" &&\n req.request != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n # We only deal with GET and HEAD by default\n return (pass);\n }\n\n # Some generic URL manipulation, useful for all templates that follow\n # First remove the Google Analytics added parameters, useless for our backend\n if (req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=\") {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # Strip hash, server doesn't need it.\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n # Strip a trailing ? if it exists\n if (req.url ~ \"\\?$\") {\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # This is an example to redirect with a 301\/302 HTTP status code from within Varnish\n # if (req.http.Host ~ \"secure.mysite.tld\") {\n # # We may want to force our users from the secure site to the HTTPs version?\n # error 720 \"https:\/\/secure.mysite.tld\";\n # # If you want to keep the URLs intact, this also works:\n # error 720 \"https:\/\/\" + req.http.Host + req.url;\n # }\n #\n # Or to force a 302 temporary redirect, use error 721\n # if (req.http.Host ~ \"temp.mysite.tld\") {\n # # Temporary redirect\n # error 721 \"http:\/\/mysite.tld\/temp\";\n # }\n #\n\n # Some generic cookie manipulation, useful for all templates that follow\n\n # Remove any '_' prefixed cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"(^|;\\s*)_[^=]+=[^;]*\", \"\");\n\n # Remove a \";\" prefix in the cookie if present\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n\n # Are there cookies left with only spaces or that are empty?\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n\n # Normalize Accept-Encoding header\n # straight from the manual: https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/vary.html\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n # No point in compressing these\n remove req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n # unkown algorithm\n remove req.http.Accept-Encoding;\n }\n }\n\n # Include custom vcl_recv logic\n include \"conf.d\/receive\/wordpress.vcl\";\n\n # Remove all cookies for static files\n # A valid discussion could be held on this line: do you really need to cache static files that don't cause load? Only if you have memory left.\n # Sure, there's disk I\/O, but chances are your OS will already have these files in their buffers (thus memory).\n # Before you blindly enable this, have a read here: http:\/\/mattiasgeniar.be\/2012\/11\/28\/stop-caching-static-files\/\n # if (req.url ~ \"^[^?]*\\.(bmp|bz2|css|doc|eot|flv|gif|gz|ico|jpeg|jpg|js|less|mp[34]|pdf|png|rar|rtf|swf|tar|tgz|txt|wav|woff|xml|zip)(\\?.*)?$\") {\n # unset req.http.Cookie;\n # return (lookup);\n # }\n\n # Send Surrogate-Capability headers to announce ESI support to backend\n set req.http.Surrogate-Capability = \"key=ESI\/1.0\";\n\n if (req.http.Authorization || req.http.Cookie) {\n # Not cacheable by default\n return (pass);\n }\n\n return (lookup);\n}\n\nsub vcl_pipe {\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n # set bereq.http.connection = \"close\";\n # here. It is not set by default as it might break some broken web\n # applications, like IIS with NTLM authentication.\n\n #set bereq.http.Connection = \"Close\";\n return (pipe);\n}\n\nsub vcl_pass {\n return (pass);\n}\n\n# The data on which the hashing will take place\nsub vcl_hash {\n hash_data(req.url);\n\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n\n # hash cookies for object with auth\n if (req.http.Cookie) {\n hash_data(req.http.Cookie);\n }\n if (req.http.Authorization) {\n hash_data(req.http.Authorization);\n }\n\n # hash forwarded protocol, if present\n if (req.http.X-Forwarded-Proto) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n\n return (hash);\n}\n\nsub vcl_hit {\n # Allow purges\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"purged\";\n }\n\n return (deliver);\n}\n\nsub vcl_miss {\n # Allow purges\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"purged\";\n }\n\n return (fetch);\n}\n\n# Handle the HTTP request coming from our backend\nsub vcl_fetch {\n set beresp.grace = 1h;\n\n # Include custom vcl_fetch logic\n include \"conf.d\/fetch\/wordpress.vcl\";\n\n # Parse ESI request and remove Surrogate-Control header\n if (beresp.http.Surrogate-Control ~ \"ESI\/1.0\") {\n unset beresp.http.Surrogate-Control;\n set beresp.do_esi = true;\n }\n\n # If the request to the backend returns a code is 5xx, return the error page\n if (beresp.status >= 500 && beresp.status <= 599){\n return(hit_for_pass);\n }\n\n # Enable cache for all static files\n # The same argument as the static caches from above: monitor your cache size, if you get data nuked out of it, consider giving up the static file cache.\n # Before you blindly enable this, have a read here: http:\/\/mattiasgeniar.be\/2012\/11\/28\/stop-caching-static-files\/\n # if (req.url ~ \"^[^?]*\\.(bmp|bz2|css|doc|eot|flv|gif|gz|ico|jpeg|jpg|js|less|mp[34]|pdf|png|rar|rtf|swf|tar|tgz|txt|wav|woff|xml|zip)(\\?.*)?$\") {\n # unset beresp.http.set-cookie;\n # }\n\n # Sometimes, a 301 or 302 redirect formed via Apache's mod_rewrite can mess with the HTTP port that is being passed along.\n # This often happens with simple rewrite rules in a scenario where Varnish runs on :80 and Apache on :8080 on the same box.\n # A redirect can then often redirect the end-user to a URL on :8080, where it should be :80.\n # This may need finetuning on your setup.\n #\n # To prevent accidental replace, we only filter the 301\/302 redirects for now.\n if (beresp.status == 301 || beresp.status == 302) {\n set beresp.http.Location = regsub(beresp.http.Location, \":[0-9]+\", \"\");\n }\n\n # Don't cache user & server errors\n if (beresp.status >= 400) {\n return (hit_for_pass);\n }\n\n # Non private responses without cookies and with a ttl of 0 should be artificially extended to 1 hour\n if (beresp.ttl <= 0s && beresp.http.Cache-Control !~ \"private\" && (!beresp.http.Set-Cookie)) {\n set beresp.ttl = 1h;\n set beresp.http.X-Cache-Extended = \"1\";\n }\n\n # Set 2min cache if unset for static files\n if (beresp.ttl <= 0s || beresp.http.Set-Cookie || beresp.http.Vary == \"*\") {\n set beresp.ttl = 120s;\n return (hit_for_pass);\n }\n\n return (deliver);\n}\n\n# The routine when we deliver the HTTP request to the user\n# Last chance to modify headers that are sent to the client\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"cached\";\n } else {\n set resp.http.x-Cache = \"uncached\";\n }\n\n # Remove some headers: PHP version\n unset resp.http.X-Powered-By;\n\n # Remove some headers: Apache version & OS\n unset resp.http.Server;\n unset resp.http.X-Drupal-Cache;\n unset resp.http.X-Varnish;\n unset resp.http.Via;\n unset resp.http.Link;\n\n return (deliver);\n}\n\nsub vcl_error {\n if (obj.status == 720) {\n # We use this special error status 720 to force redirects with 301 (permanent) redirects\n # To use this, call the following from anywhere in vcl_recv: error 720 \"http:\/\/host\/new.html\"\n set obj.status = 301;\n set obj.http.Location = obj.response;\n return (deliver);\n } elseif (obj.status == 721) {\n # And we use error status 721 to force redirects with a 302 (temporary) redirect\n # To use this, call the following from anywhere in vcl_recv: error 720 \"http:\/\/host\/new.html\"\n set obj.status = 302;\n set obj.http.Location = obj.response;\n return (deliver);\n }\n\n return (deliver);\n}\n\nsub vcl_init {\n return (ok);\n}\n\nsub vcl_fini {\n return (ok);\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"be672f0fecc61cd874b07dd6157deca7c5df1a76","subject":"Add comment to sample VCL to show how to make it 2.x compatible","message":"Add comment to sample VCL to show how to make it 2.x compatible\n","repos":"hasadna\/alaveteli,codeforcroatia\/alaveteli,TEDICpy\/QueremoSaber,hasadna\/alaveteli,Br3nda\/alaveteli,4bic\/alaveteli,petterreinholdtsen\/alaveteli,codeforcroatia\/alaveteli,TEDICpy\/QueremoSaber,hasadna\/alaveteli,sarhane\/alaveteli-test,andreicristianpetcu\/alaveteli_old,andreicristianpetcu\/alaveteli_old,obshtestvo\/alaveteli-bulgaria,codeforcroatia\/alaveteli,10layer\/alaveteli,TEDICpy\/QueremoSaber,codeforcroatia\/alaveteli,10layer\/alaveteli,Br3nda\/alaveteli,nzherald\/alaveteli,4bic\/alaveteli,datauy\/alaveteli,petterreinholdtsen\/alaveteli,hasadna\/alaveteli,petterreinholdtsen\/alaveteli,hasadna\/alaveteli,sarhane\/alaveteli-test,hasadna\/alaveteli,4bic\/alaveteli,petterreinholdtsen\/alaveteli,petterreinholdtsen\/alaveteli,andreicristianpetcu\/alaveteli,4bic\/alaveteli,Br3nda\/alaveteli,obshtestvo\/alaveteli-bulgaria,andreicristianpetcu\/alaveteli_old,obshtestvo\/alaveteli-bulgaria,obshtestvo\/alaveteli-bulgaria,datauy\/alaveteli,nzherald\/alaveteli,10layer\/alaveteli,TEDICpy\/QueremoSaber,Br3nda\/alaveteli,Br3nda\/alaveteli,andreicristianpetcu\/alaveteli,obshtestvo\/alaveteli-bulgaria,andreicristianpetcu\/alaveteli,datauy\/alaveteli,nzherald\/alaveteli,sarhane\/alaveteli-test,nzherald\/alaveteli,andreicristianpetcu\/alaveteli_old,nzherald\/alaveteli,4bic\/alaveteli,TEDICpy\/QueremoSaber,sarhane\/alaveteli-test,andreicristianpetcu\/alaveteli_old,andreicristianpetcu\/alaveteli,andreicristianpetcu\/alaveteli","old_file":"config\/varnish-alaveteli.vcl","new_file":"config\/varnish-alaveteli.vcl","new_contents":"# This is a sample VCL configuration file for varnish running in front\n# of Alaveteli. See the vcl(7) man page for details on VCL syntax and\n# semantics.\n\n# \n# Default backend definition. Set this to point to your content\n# server. In this case, apache + Passenger running on port 80\n# \n\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"80\";\n .connect_timeout = 600s;\n .first_byte_timeout = 600s;\n .between_bytes_timeout = 600s;\n}\n\n\/\/ set the servers alaveteli can issue a purge from\nacl purge {\n \"localhost\";\n \"127.0.0.1\";\n}\n\nsub vcl_recv {\n\n # Handle IPv6\n if (req.http.Host ~ \"^ipv6.*\") {\n set req.http.host = regsub(req.http.host, \"^ipv6\\.(.*)\",\"www\\.\\1\");\n }\n\n\n # Sanitise X-Forwarded-For...\n remove req.http.X-Forwarded-For;\n set req.http.X-Forwarded-For = client.ip;\n \n # Remove Google Analytics, has_js, and last-seen cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"(^|;\\s*)(__[a-z]+|has_js|has_seen_country_message|seen_foi2)=[^;]*\", \"\");\n\n # Normalize the Accept-Encoding header\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|flv|pdf|ico)$\") {\n # No point in compressing these\n remove req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n # unknown algorithm\n remove req.http.Accept-Encoding;\n }\n }\n \n # Ignore empty cookies\n if (req.http.Cookie ~ \"^\\s*$\") {\n remove req.http.Cookie;\n }\n \n if (req.request != \"GET\" &&\n req.request != \"HEAD\" && \n req.request != \"POST\" &&\n req.request != \"PUT\" &&\n req.request != \"PURGE\" &&\n req.request != \"DELETE\" ) {\n # We don't allow any other methods.\n error 405 \"Method Not Allowed\";\n }\n\n if (req.request != \"GET\" && req.request != \"HEAD\" && req.request != \"PURGE\") {\n \/* We only deal with GET and HEAD by default, the rest get passed direct to backend *\/\n return (pass);\n }\n \n # Ignore Cookies on images...\n if (req.url ~ \"\\.(png|gif|jpg|jpeg|swf|css|js|rdf|ico|txt)(\\?.*|)$\") {\n remove req.http.Cookie;\n return (lookup);\n }\n\n if (req.http.Authorization || req.http.Cookie) {\n return (pass);\n }\n # Let's have a little grace\n set req.grace = 30s;\n # Handle PURGE requests\n if (req.request == \"PURGE\") {\n if (!client.ip ~ purge) {\n error 405 \"Not allowed.\";\n }\n # XXX in Varnish 2.x, the following would be\n # purge(\"obj.http.x-url ~ \" req.url);\n ban(\"obj.http.x-url ~ \" + req.url);\n error 200 \"Banned\";\n }\n return (lookup);\n}\n\nsub vcl_fetch {\n set beresp.http.x-url = req.url;\n if (req.url ~ \"\\.(png|gif|jpg|jpeg|swf|css|js|rdf|ico|txt)(\\?.*|)$\") {\n # Ignore backend headers..\n remove beresp.http.set-Cookie;\n set beresp.ttl = 3600s;\n return (deliver);\n }\n\n if (beresp.status == 404 || beresp.status == 301 || beresp.status == 500) {\n set beresp.ttl = 1m;\n return (deliver);\n }\n}\n\n","old_contents":"# This is a sample VCL configuration file for varnish running in front\n# of Alaveteli. See the vcl(7) man page for details on VCL syntax and\n# semantics.\n\n# \n# Default backend definition. Set this to point to your content\n# server. In this case, apache + Passenger running on port 80\n# \n\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"80\";\n .connect_timeout = 600s;\n .first_byte_timeout = 600s;\n .between_bytes_timeout = 600s;\n}\n\n\/\/ set the servers alaveteli can issue a purge from\nacl purge {\n \"localhost\";\n \"127.0.0.1\";\n}\n\nsub vcl_recv {\n\n # Handle IPv6\n if (req.http.Host ~ \"^ipv6.*\") {\n set req.http.host = regsub(req.http.host, \"^ipv6\\.(.*)\",\"www\\.\\1\");\n }\n\n\n # Sanitise X-Forwarded-For...\n remove req.http.X-Forwarded-For;\n set req.http.X-Forwarded-For = client.ip;\n \n # Remove Google Analytics, has_js, and last-seen cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"(^|;\\s*)(__[a-z]+|has_js|has_seen_country_message|seen_foi2)=[^;]*\", \"\");\n\n # Normalize the Accept-Encoding header\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|flv|pdf|ico)$\") {\n # No point in compressing these\n remove req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n # unknown algorithm\n remove req.http.Accept-Encoding;\n }\n }\n \n # Ignore empty cookies\n if (req.http.Cookie ~ \"^\\s*$\") {\n remove req.http.Cookie;\n }\n \n if (req.request != \"GET\" &&\n req.request != \"HEAD\" && \n req.request != \"POST\" &&\n req.request != \"PUT\" &&\n req.request != \"PURGE\" &&\n req.request != \"DELETE\" ) {\n # We don't allow any other methods.\n error 405 \"Method Not Allowed\";\n }\n\n if (req.request != \"GET\" && req.request != \"HEAD\" && req.request != \"PURGE\") {\n \/* We only deal with GET and HEAD by default, the rest get passed direct to backend *\/\n return (pass);\n }\n \n # Ignore Cookies on images...\n if (req.url ~ \"\\.(png|gif|jpg|jpeg|swf|css|js|rdf|ico|txt)(\\?.*|)$\") {\n remove req.http.Cookie;\n return (lookup);\n }\n\n if (req.http.Authorization || req.http.Cookie) {\n return (pass);\n }\n # Let's have a little grace\n set req.grace = 30s;\n # Handle PURGE requests\n if (req.request == \"PURGE\") {\n if (!client.ip ~ purge) {\n error 405 \"Not allowed.\";\n }\n ban(\"obj.http.x-url ~ \" + req.url);\n error 200 \"Banned\";\n }\n return (lookup);\n}\n\nsub vcl_fetch {\n set beresp.http.x-url = req.url;\n if (req.url ~ \"\\.(png|gif|jpg|jpeg|swf|css|js|rdf|ico|txt)(\\?.*|)$\") {\n # Ignore backend headers..\n remove beresp.http.set-Cookie;\n set beresp.ttl = 3600s;\n return (deliver);\n }\n\n if (beresp.status == 404 || beresp.status == 301 || beresp.status == 500) {\n set beresp.ttl = 1m;\n return (deliver);\n }\n}\n\n","returncode":0,"stderr":"","license":"agpl-3.0","lang":"VCL"} {"commit":"99eb9ad8c2854a6229418c8cf24f0e9c521b7ab3","subject":"Remove caching for static files","message":"Remove caching for static files\n","repos":"genesis\/wordpress,evolution\/genesis-wordpress,jalevin\/wordpress,genesis\/wordpress,evolution\/wordpress,genesis\/wordpress,jalevin\/wordpress,evolution\/genesis-wordpress,evolution\/wordpress,genesis\/wordpress,evolution\/genesis-wordpress,evolution\/genesis-wordpress,evolution\/genesis-wordpress,evolution\/genesis-wordpress,evolution\/wordpress,jalevin\/wordpress,evolution\/wordpress,jalevin\/wordpress,genesis\/wordpress,genesis\/wordpress,jalevin\/wordpress,evolution\/wordpress","old_file":"provisioning\/roles\/varnish\/files\/etc-varnish\/production.vcl","new_file":"provisioning\/roles\/varnish\/files\/etc-varnish\/production.vcl","new_contents":"# Default backend definition. Set this to point to your content server.\n# all paths relative to varnish option vcl_dir\n\ninclude \"custom.backend.vcl\";\ninclude \"custom.acl.vcl\";\n\n# Handle the HTTP request received by the client\nsub vcl_recv {\n # varnish serves stale (but cacheable) objects while retriving object from backend\n if (req.backend.healthy) {\n set req.grace = 30s;\n } else {\n set req.grace = 1h;\n }\n\n # shortcut for DFind requests\n if (req.url ~ \"^\/w00tw00t\") {\n error 404 \"Not Found\";\n }\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n # Normalize the header, remove the port (in case you're testing this on various TCP ports)\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n # Allow purging\n if (req.request == \"PURGE\") {\n if (!client.ip ~ purge) {\n # Not from an allowed IP? Then die with an error.\n error 405 \"This IP is not allowed to send PURGE requests.\";\n }\n\n # If you got this stage (and didn't error out above), do a cache-lookup\n # That will force entry into vcl_hit() or vcl_miss() below and purge the actual cache\n return (lookup);\n }\n\n # Only deal with \"normal\" types\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"PATCH\" &&\n req.request != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n # We only deal with GET and HEAD by default\n return (pass);\n }\n\n # Some generic URL manipulation, useful for all templates that follow\n # First remove the Google Analytics added parameters, useless for our backend\n if (req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=\") {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # Strip hash, server doesn't need it.\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n # Strip a trailing ? if it exists\n if (req.url ~ \"\\?$\") {\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # This is an example to redirect with a 301\/302 HTTP status code from within Varnish\n # if (req.http.Host ~ \"secure.mysite.tld\") {\n # # We may want to force our users from the secure site to the HTTPs version?\n # error 720 \"https:\/\/secure.mysite.tld\";\n # # If you want to keep the URLs intact, this also works:\n # error 720 \"https:\/\/\" + req.http.Host + req.url;\n # }\n #\n # Or to force a 302 temporary redirect, use error 721\n # if (req.http.Host ~ \"temp.mysite.tld\") {\n # # Temporary redirect\n # error 721 \"http:\/\/mysite.tld\/temp\";\n # }\n #\n\n # Some generic cookie manipulation, useful for all templates that follow\n\n # Remove any '_' prefixed cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"_[^=]+=[^;]+(; )?\", \"\");\n\n # Remove a \";\" prefix in the cookie if present\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n\n # Are there cookies left with only spaces or that are empty?\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n\n # Normalize Accept-Encoding header\n # straight from the manual: https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/vary.html\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n # No point in compressing these\n remove req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n # unkown algorithm\n remove req.http.Accept-Encoding;\n }\n }\n\n # Include custom vcl_recv logic\n include \"conf.d\/receive\/wordpress.vcl\";\n\n # Remove all cookies for static files\n # A valid discussion could be held on this line: do you really need to cache static files that don't cause load? Only if you have memory left.\n # Sure, there's disk I\/O, but chances are your OS will already have these files in their buffers (thus memory).\n # Before you blindly enable this, have a read here: http:\/\/mattiasgeniar.be\/2012\/11\/28\/stop-caching-static-files\/\n # if (req.url ~ \"^[^?]*\\.(bmp|bz2|css|doc|eot|flv|gif|gz|ico|jpeg|jpg|js|less|mp[34]|pdf|png|rar|rtf|swf|tar|tgz|txt|wav|woff|xml|zip)(\\?.*)?$\") {\n # unset req.http.Cookie;\n # return (lookup);\n # }\n\n # Send Surrogate-Capability headers to announce ESI support to backend\n set req.http.Surrogate-Capability = \"key=ESI\/1.0\";\n\n if (req.http.Authorization || req.http.Cookie) {\n # Not cacheable by default\n return (pass);\n }\n\n return (lookup);\n}\n\nsub vcl_pipe {\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n # set bereq.http.connection = \"close\";\n # here. It is not set by default as it might break some broken web\n # applications, like IIS with NTLM authentication.\n\n #set bereq.http.Connection = \"Close\";\n return (pipe);\n}\n\nsub vcl_pass {\n return (pass);\n}\n\n# The data on which the hashing will take place\nsub vcl_hash {\n hash_data(req.url);\n\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n\n # hash cookies for object with auth\n if (req.http.Cookie) {\n hash_data(req.http.Cookie);\n }\n if (req.http.Authorization) {\n hash_data(req.http.Authorization);\n }\n\n return (hash);\n}\n\nsub vcl_hit {\n # Allow purges\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"purged\";\n }\n\n return (deliver);\n}\n\nsub vcl_miss {\n # Allow purges\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"purged\";\n }\n\n return (fetch);\n}\n\n# Handle the HTTP request coming from our backend\nsub vcl_fetch {\n set beresp.grace = 1h;\n\n # Include custom vcl_fetch logic\n include \"conf.d\/fetch\/wordpress.vcl\";\n\n # Parse ESI request and remove Surrogate-Control header\n if (beresp.http.Surrogate-Control ~ \"ESI\/1.0\") {\n unset beresp.http.Surrogate-Control;\n set beresp.do_esi = true;\n }\n\n # If the request to the backend returns a code is 5xx, restart the loop\n # If the number of restarts reaches the value of the parameter max_restarts,\n # the request will be error'ed. max_restarts defaults to 4. This prevents\n # an eternal loop in the event that, e.g., the object does not exist at all.\n if (beresp.status >= 500 && beresp.status <= 599){\n return(restart);\n }\n\n # Enable cache for all static files\n # The same argument as the static caches from above: monitor your cache size, if you get data nuked out of it, consider giving up the static file cache.\n # Before you blindly enable this, have a read here: http:\/\/mattiasgeniar.be\/2012\/11\/28\/stop-caching-static-files\/\n # if (req.url ~ \"^[^?]*\\.(bmp|bz2|css|doc|eot|flv|gif|gz|ico|jpeg|jpg|js|less|mp[34]|pdf|png|rar|rtf|swf|tar|tgz|txt|wav|woff|xml|zip)(\\?.*)?$\") {\n # unset beresp.http.set-cookie;\n # }\n\n # Sometimes, a 301 or 302 redirect formed via Apache's mod_rewrite can mess with the HTTP port that is being passed along.\n # This often happens with simple rewrite rules in a scenario where Varnish runs on :80 and Apache on :8080 on the same box.\n # A redirect can then often redirect the end-user to a URL on :8080, where it should be :80.\n # This may need finetuning on your setup.\n #\n # To prevent accidental replace, we only filter the 301\/302 redirects for now.\n if (beresp.status == 301 || beresp.status == 302) {\n set beresp.http.Location = regsub(beresp.http.Location, \":[0-9]+\", \"\");\n }\n\n # Don't cache user & server errors\n if (beresp.status >= 400) {\n return (hit_for_pass);\n }\n\n # Non private responses without cookies and with a ttl of 0 should be artificially extended to 1 hour\n if (beresp.ttl <= 0s && beresp.http.Cache-Control !~ \"private\" && (!beresp.http.Set-Cookie)) {\n set beresp.ttl = 1h;\n set beresp.http.X-Cache-Extended = \"1\";\n }\n\n # Set 2min cache if unset for static files\n if (beresp.ttl <= 0s || beresp.http.Set-Cookie || beresp.http.Vary == \"*\") {\n set beresp.ttl = 120s;\n return (hit_for_pass);\n }\n\n return (deliver);\n}\n\n# The routine when we deliver the HTTP request to the user\n# Last chance to modify headers that are sent to the client\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"cached\";\n } else {\n set resp.http.x-Cache = \"uncached\";\n }\n\n # Remove some headers: PHP version\n unset resp.http.X-Powered-By;\n\n # Remove some headers: Apache version & OS\n unset resp.http.Server;\n unset resp.http.X-Drupal-Cache;\n unset resp.http.X-Varnish;\n unset resp.http.Via;\n unset resp.http.Link;\n\n return (deliver);\n}\n\nsub vcl_error {\n if (obj.status == 720) {\n # We use this special error status 720 to force redirects with 301 (permanent) redirects\n # To use this, call the following from anywhere in vcl_recv: error 720 \"http:\/\/host\/new.html\"\n set obj.status = 301;\n set obj.http.Location = obj.response;\n return (deliver);\n } elseif (obj.status == 721) {\n # And we use error status 721 to force redirects with a 302 (temporary) redirect\n # To use this, call the following from anywhere in vcl_recv: error 720 \"http:\/\/host\/new.html\"\n set obj.status = 302;\n set obj.http.Location = obj.response;\n return (deliver);\n }\n\n return (deliver);\n}\n\nsub vcl_init {\n return (ok);\n}\n\nsub vcl_fini {\n return (ok);\n}\n","old_contents":"# Default backend definition. Set this to point to your content server.\n# all paths relative to varnish option vcl_dir\n\ninclude \"custom.backend.vcl\";\ninclude \"custom.acl.vcl\";\n\n# Handle the HTTP request received by the client\nsub vcl_recv {\n # varnish serves stale (but cacheable) objects while retriving object from backend\n if (req.backend.healthy) {\n set req.grace = 30s;\n } else {\n set req.grace = 1h;\n }\n\n # shortcut for DFind requests\n if (req.url ~ \"^\/w00tw00t\") {\n error 404 \"Not Found\";\n }\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n # Normalize the header, remove the port (in case you're testing this on various TCP ports)\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n # Allow purging\n if (req.request == \"PURGE\") {\n if (!client.ip ~ purge) {\n # Not from an allowed IP? Then die with an error.\n error 405 \"This IP is not allowed to send PURGE requests.\";\n }\n\n # If you got this stage (and didn't error out above), do a cache-lookup\n # That will force entry into vcl_hit() or vcl_miss() below and purge the actual cache\n return (lookup);\n }\n\n # Only deal with \"normal\" types\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"PATCH\" &&\n req.request != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n # We only deal with GET and HEAD by default\n return (pass);\n }\n\n # Some generic URL manipulation, useful for all templates that follow\n # First remove the Google Analytics added parameters, useless for our backend\n if (req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=\") {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # Strip hash, server doesn't need it.\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n # Strip a trailing ? if it exists\n if (req.url ~ \"\\?$\") {\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # This is an example to redirect with a 301\/302 HTTP status code from within Varnish\n # if (req.http.Host ~ \"secure.mysite.tld\") {\n # # We may want to force our users from the secure site to the HTTPs version?\n # error 720 \"https:\/\/secure.mysite.tld\";\n # # If you want to keep the URLs intact, this also works:\n # error 720 \"https:\/\/\" + req.http.Host + req.url;\n # }\n #\n # Or to force a 302 temporary redirect, use error 721\n # if (req.http.Host ~ \"temp.mysite.tld\") {\n # # Temporary redirect\n # error 721 \"http:\/\/mysite.tld\/temp\";\n # }\n #\n\n # Some generic cookie manipulation, useful for all templates that follow\n\n # Remove any '_' prefixed cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"_[^=]+=[^;]+(; )?\", \"\");\n\n # Remove a \";\" prefix in the cookie if present\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n\n # Are there cookies left with only spaces or that are empty?\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n\n # Normalize Accept-Encoding header\n # straight from the manual: https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/vary.html\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n # No point in compressing these\n remove req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n # unkown algorithm\n remove req.http.Accept-Encoding;\n }\n }\n\n # Include custom vcl_recv logic\n include \"conf.d\/receive\/wordpress.vcl\";\n\n # Remove all cookies for static files\n # A valid discussion could be held on this line: do you really need to cache static files that don't cause load? Only if you have memory left.\n # Sure, there's disk I\/O, but chances are your OS will already have these files in their buffers (thus memory).\n # Before you blindly enable this, have a read here: http:\/\/mattiasgeniar.be\/2012\/11\/28\/stop-caching-static-files\/\n if (req.url ~ \"^[^?]*\\.(bmp|bz2|css|doc|eot|flv|gif|gz|ico|jpeg|jpg|js|less|mp[34]|pdf|png|rar|rtf|swf|tar|tgz|txt|wav|woff|xml|zip)(\\?.*)?$\") {\n unset req.http.Cookie;\n return (lookup);\n }\n\n # Send Surrogate-Capability headers to announce ESI support to backend\n set req.http.Surrogate-Capability = \"key=ESI\/1.0\";\n\n if (req.http.Authorization || req.http.Cookie) {\n # Not cacheable by default\n return (pass);\n }\n\n return (lookup);\n}\n\nsub vcl_pipe {\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n # set bereq.http.connection = \"close\";\n # here. It is not set by default as it might break some broken web\n # applications, like IIS with NTLM authentication.\n\n #set bereq.http.Connection = \"Close\";\n return (pipe);\n}\n\nsub vcl_pass {\n return (pass);\n}\n\n# The data on which the hashing will take place\nsub vcl_hash {\n hash_data(req.url);\n\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n\n # hash cookies for object with auth\n if (req.http.Cookie) {\n hash_data(req.http.Cookie);\n }\n if (req.http.Authorization) {\n hash_data(req.http.Authorization);\n }\n\n return (hash);\n}\n\nsub vcl_hit {\n # Allow purges\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"purged\";\n }\n\n return (deliver);\n}\n\nsub vcl_miss {\n # Allow purges\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"purged\";\n }\n\n return (fetch);\n}\n\n# Handle the HTTP request coming from our backend\nsub vcl_fetch {\n set beresp.grace = 1h;\n\n # Include custom vcl_fetch logic\n include \"conf.d\/fetch\/wordpress.vcl\";\n\n # Parse ESI request and remove Surrogate-Control header\n if (beresp.http.Surrogate-Control ~ \"ESI\/1.0\") {\n unset beresp.http.Surrogate-Control;\n set beresp.do_esi = true;\n }\n\n # If the request to the backend returns a code is 5xx, restart the loop\n # If the number of restarts reaches the value of the parameter max_restarts,\n # the request will be error'ed. max_restarts defaults to 4. This prevents\n # an eternal loop in the event that, e.g., the object does not exist at all.\n if (beresp.status >= 500 && beresp.status <= 599){\n return(restart);\n }\n\n # Enable cache for all static files\n # The same argument as the static caches from above: monitor your cache size, if you get data nuked out of it, consider giving up the static file cache.\n # Before you blindly enable this, have a read here: http:\/\/mattiasgeniar.be\/2012\/11\/28\/stop-caching-static-files\/\n if (req.url ~ \"^[^?]*\\.(bmp|bz2|css|doc|eot|flv|gif|gz|ico|jpeg|jpg|js|less|mp[34]|pdf|png|rar|rtf|swf|tar|tgz|txt|wav|woff|xml|zip)(\\?.*)?$\") {\n unset beresp.http.set-cookie;\n }\n\n # Sometimes, a 301 or 302 redirect formed via Apache's mod_rewrite can mess with the HTTP port that is being passed along.\n # This often happens with simple rewrite rules in a scenario where Varnish runs on :80 and Apache on :8080 on the same box.\n # A redirect can then often redirect the end-user to a URL on :8080, where it should be :80.\n # This may need finetuning on your setup.\n #\n # To prevent accidental replace, we only filter the 301\/302 redirects for now.\n if (beresp.status == 301 || beresp.status == 302) {\n set beresp.http.Location = regsub(beresp.http.Location, \":[0-9]+\", \"\");\n }\n\n # Don't cache user & server errors\n if (beresp.status >= 400) {\n return (hit_for_pass);\n }\n\n # Non private responses without cookies and with a ttl of 0 should be artificially extended to 1 hour\n if (beresp.ttl <= 0s && beresp.http.Cache-Control !~ \"private\" && (!beresp.http.Set-Cookie)) {\n set beresp.ttl = 1h;\n set beresp.http.X-Cache-Extended = \"1\";\n }\n\n # Set 2min cache if unset for static files\n if (beresp.ttl <= 0s || beresp.http.Set-Cookie || beresp.http.Vary == \"*\") {\n set beresp.ttl = 120s;\n return (hit_for_pass);\n }\n\n return (deliver);\n}\n\n# The routine when we deliver the HTTP request to the user\n# Last chance to modify headers that are sent to the client\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"cached\";\n } else {\n set resp.http.x-Cache = \"uncached\";\n }\n\n # Remove some headers: PHP version\n unset resp.http.X-Powered-By;\n\n # Remove some headers: Apache version & OS\n unset resp.http.Server;\n unset resp.http.X-Drupal-Cache;\n unset resp.http.X-Varnish;\n unset resp.http.Via;\n unset resp.http.Link;\n\n return (deliver);\n}\n\nsub vcl_error {\n if (obj.status == 720) {\n # We use this special error status 720 to force redirects with 301 (permanent) redirects\n # To use this, call the following from anywhere in vcl_recv: error 720 \"http:\/\/host\/new.html\"\n set obj.status = 301;\n set obj.http.Location = obj.response;\n return (deliver);\n } elseif (obj.status == 721) {\n # And we use error status 721 to force redirects with a 302 (temporary) redirect\n # To use this, call the following from anywhere in vcl_recv: error 720 \"http:\/\/host\/new.html\"\n set obj.status = 302;\n set obj.http.Location = obj.response;\n return (deliver);\n }\n\n return (deliver);\n}\n\nsub vcl_init {\n return (ok);\n}\n\nsub vcl_fini {\n return (ok);\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"badaa47e651a2910964c40e98bfad74c6e2b5549","subject":"This may be causing unintended effects so removing it","message":"This may be causing unintended effects so removing it\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets\/fetch.vcl","new_file":"etc\/vcl_snippets\/fetch.vcl","new_contents":" \/* handle 5XX (or any other unwanted status code) *\/\n if (beresp.status >= 500 && beresp.status < 600) {\n\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n \/* deliver stale if the object is available *\/\n if (stale.exists) {\n return(deliver_stale);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n \/* else go to vcl_error to deliver a synthetic *\/\n error 503;\n }\n\n # Remove Set-Cookies from responses for static content\n # to match the cookie removal in recv.\n if (req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's since those can be temporary during the site build\/index\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n }\n\n }\n\n if (beresp.http.Content-Type ~ \"text\/(html|xml)\") {\n # enable ESI feature for Magento response by default\n esi;\n if (!beresp.http.Vary ~ \"X-Magento-Vary,Https\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \",X-Magento-Vary,Https\";\n } else {\n set beresp.http.Vary = \"X-Magento-Vary,Https\";\n }\n }\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content\n if (http_status_matches(beresp.status, \"200,404\") && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url.ext ~ \"(?i)(css|js|html|eot|ico|otf|ttf|json)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n if (beresp.http.Cache-Control ~ \"private|no-cache|no-store\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # Never cache 302s\n if (beresp.status == 302) {\n return (pass);\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\") && !req.http.x-pass ) {\n unset beresp.http.set-cookie;\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type if they are image\/script or CSS\n if (beresp.http.Content-Type ~ \"(image|script|css)\") {\n set beresp.http.Surrogate-Key = re.group.1;\n }\n return (deliver);\n }\n","old_contents":" \/* handle 5XX (or any other unwanted status code) *\/\n if (beresp.status >= 500 && beresp.status < 600) {\n\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n \/* deliver stale if the object is available *\/\n if (stale.exists) {\n return(deliver_stale);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n \/* else go to vcl_error to deliver a synthetic *\/\n error 503;\n }\n\n # Remove Set-Cookies from responses for static content\n # to match the cookie removal in recv.\n if (req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's since those can be temporary during the site build\/index\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n }\n\n }\n\n if (beresp.http.Content-Type ~ \"text\/(html|xml)\") {\n # enable ESI feature for Magento response by default\n esi;\n if (!beresp.http.Vary ~ \"X-Magento-Vary,Https\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \",X-Magento-Vary,Https\";\n } else {\n set beresp.http.Vary = \"X-Magento-Vary,Https\";\n }\n }\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content\n if (http_status_matches(beresp.status, \"200,404\") && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url.ext ~ \"(?i)(css|js|html|eot|ico|otf|ttf|json)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n if (beresp.http.Cache-Control ~ \"private|no-cache|no-store\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # Never cache 302s\n if (beresp.status == 302) {\n return (pass);\n }\n\n # Cache non-successful responses for 1 second to avoid onslaught of traffic if backend starts\n # spewing 500s. Also set 5 second grace in case backend is timing out or otherwise messed up\n if ( !http_status_matches(beresp.status, \"200,203,300,301,302,404,410\")) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n # Remove Set-Cookies so we don't inadvertenly cache them\n unset beresp.http.Set-Cookie;\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\") && !req.http.x-pass ) {\n unset beresp.http.set-cookie;\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type if they are image\/script or CSS\n if (beresp.http.Content-Type ~ \"(image|script|css)\") {\n set beresp.http.Surrogate-Key = re.group.1;\n }\n return (deliver);\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"383b54081707b95946a0b9d8990e31a240b8c8ad","subject":"Add JikeSpider to list of bot user agents","message":"Add JikeSpider to list of bot user agents\n\nObserved user-agent was:\r\n\r\nUser-Agent: Mozilla\/5.0 (compatible; JikeSpider; +http:\/\/shoulu.jike.com\/spider.html)\r\n","repos":"wikp\/varnish-devicedetect,varnish\/varnish-devicedetect,varnish\/varnish-devicedetect,kevinquinnyo\/varnish-devicedetect,kevinquinnyo\/varnish-devicedetect,wikp\/varnish-devicedetect","old_file":"devicedetect.vcl","new_file":"devicedetect.vcl","new_contents":"#\n# detectdevice.vcl - regex based device detection for Varnish\n# http:\/\/github.com\/varnish\/varnish-devicedetect\/\n#\n# Author: Lasse Karstensen <lasse@varnish-software.com>\n\nsub devicedetect {\n unset req.http.X-UA-Device;\n set req.http.X-UA-Device = \"pc\";\n\n if (req.http.User-Agent ~ \"(?i)(ads|google|bing|msn|yandex|baidu|ro|career|)bot\" ||\n\treq.http.User-Agent ~ \"(?i)(baidu|jike|symantec)spider\" ||\n\treq.http.User-Agent ~ \"(?i)scanner\" ||\n\treq.http.User-Agent ~ \"(?i)(web)crawler\") {\n\tset req.http.X-UA-Device = \"bot\"; }\n elsif (req.http.User-Agent ~ \"(?i)ip(hone|od)\") { set req.http.X-UA-Device = \"mobile-iphone\"; }\n elsif (req.http.User-Agent ~ \"(?i)ipad\") { set req.http.X-UA-Device = \"tablet-ipad\"; }\n # how do we differ between an android phone and an android tablet?\n # http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent\n elsif (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") { set req.http.X-UA-Device = \"mobile-android\"; }\n # android 3\/honeycomb was just about tablet-only, and any phones will probably handle a bigger page layout.\n elsif (req.http.User-Agent ~ \"(?i)android 3\") { set req.http.X-UA-Device = \"tablet-android\"; }\n # may very well give false positives towards android tablets. Suggestions welcome.\n elsif (req.http.User-Agent ~ \"(?i)android\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\n elsif (req.http.User-Agent ~ \"^HTC\" ||\n req.http.User-Agent ~ \"Fennec\" ||\n req.http.User-Agent ~ \"IEMobile\" ||\n req.http.User-Agent ~ \"BlackBerry\" ||\n req.http.User-Agent ~ \"SymbianOS.*AppleWebKit\" ||\n req.http.User-Agent ~ \"Opera Mobi\") {\n set req.http.X-UA-Device = \"mobile-smartphone\";\n }\n elsif (req.http.User-Agent ~ \"(?i)symbian\" ||\n req.http.User-Agent ~ \"(?i)^sonyericsson\" ||\n req.http.User-Agent ~ \"(?i)^nokia\" ||\n req.http.User-Agent ~ \"(?i)^samsung\" ||\n req.http.User-Agent ~ \"(?i)^lg\" ||\n\treq.http.User-Agent ~ \"(?i)bada\" ||\n\treq.http.User-Agent ~ \"(?i)blazer\" ||\n\treq.http.User-Agent ~ \"(?i)cellphone\" ||\n\treq.http.User-Agent ~ \"(?i)iemobile\" ||\n\treq.http.User-Agent ~ \"(?i)midp-2.0\" ||\n\treq.http.User-Agent ~ \"(?i)u990\" ||\n\treq.http.User-Agent ~ \"(?i)netfront\" ||\n\treq.http.User-Agent ~ \"(?i)opera mini\" ||\n\treq.http.User-Agent ~ \"(?i)palm\" ||\n\treq.http.User-Agent ~ \"(?i)nintendo wii\" ||\n\treq.http.User-Agent ~ \"(?i)playstation portable\" ||\n\treq.http.User-Agent ~ \"(?i)portalmmm\" ||\n\treq.http.User-Agent ~ \"(?i)proxinet\" ||\n\treq.http.User-Agent ~ \"(?i)sonyericsson\" ||\n\treq.http.User-Agent ~ \"(?i)symbian\" ||\n\treq.http.User-Agent ~ \"(?i)windows\\ ?ce\" ||\n\treq.http.User-Agent ~ \"(?i)winwap\" ||\n\treq.http.User-Agent ~ \"(?i)eudoraweb\" ||\n\treq.http.User-Agent ~ \"(?i)htc\" ||\n\treq.http.User-Agent ~ \"(?i)240x320\" ||\n\treq.http.User-Agent ~ \"(?i)avantgo\") {\n set req.http.X-UA-Device = \"mobile-generic\";\n }\n # handle overrides\n if (req.http.Cookie ~ \"(i?)X-UA-Device-force\") {\n # ;?? means zero or one ;, non-greedy to match the first.\n set req.http.X-UA-Device = regsub(req.http.Cookie, \"(?i).*X-UA-Device-force=([^;]+);??.*\", \"\\1\");\n # Clean up the cookie header to allow for caching.\n set req.http.Cookie = regsuball(req.http.Cookie, \"(^|; ) *X-UA-Device-force=[^;]+;? *\", \"\\1\");\n if (req.http.Cookie ~ \"^ *$\") { unset req.http.Cookie; }\n }\n}\n\n# vim: sw=4:tw=120\n","old_contents":"#\n# detectdevice.vcl - regex based device detection for Varnish\n# http:\/\/github.com\/varnish\/varnish-devicedetect\/\n#\n# Author: Lasse Karstensen <lasse@varnish-software.com>\n\nsub devicedetect {\n unset req.http.X-UA-Device;\n set req.http.X-UA-Device = \"pc\";\n\n if (req.http.User-Agent ~ \"(?i)(ads|google|bing|msn|yandex|baidu|ro|career|)bot\" ||\n\treq.http.User-Agent ~ \"(?i)(baidu|symantec)spider\" ||\n\treq.http.User-Agent ~ \"(?i)scanner\" ||\n\treq.http.User-Agent ~ \"(?i)(web)crawler\") {\n\tset req.http.X-UA-Device = \"bot\"; }\n elsif (req.http.User-Agent ~ \"(?i)ip(hone|od)\") { set req.http.X-UA-Device = \"mobile-iphone\"; }\n elsif (req.http.User-Agent ~ \"(?i)ipad\") { set req.http.X-UA-Device = \"tablet-ipad\"; }\n # how do we differ between an android phone and an android tablet?\n # http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent\n elsif (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") { set req.http.X-UA-Device = \"mobile-android\"; }\n # android 3\/honeycomb was just about tablet-only, and any phones will probably handle a bigger page layout.\n elsif (req.http.User-Agent ~ \"(?i)android 3\") { set req.http.X-UA-Device = \"tablet-android\"; }\n # may very well give false positives towards android tablets. Suggestions welcome.\n elsif (req.http.User-Agent ~ \"(?i)android\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\n elsif (req.http.User-Agent ~ \"^HTC\" ||\n req.http.User-Agent ~ \"Fennec\" ||\n req.http.User-Agent ~ \"IEMobile\" ||\n req.http.User-Agent ~ \"BlackBerry\" ||\n req.http.User-Agent ~ \"SymbianOS.*AppleWebKit\" ||\n req.http.User-Agent ~ \"Opera Mobi\") {\n set req.http.X-UA-Device = \"mobile-smartphone\";\n }\n elsif (req.http.User-Agent ~ \"(?i)symbian\" ||\n req.http.User-Agent ~ \"(?i)^sonyericsson\" ||\n req.http.User-Agent ~ \"(?i)^nokia\" ||\n req.http.User-Agent ~ \"(?i)^samsung\" ||\n req.http.User-Agent ~ \"(?i)^lg\" ||\n\treq.http.User-Agent ~ \"(?i)bada\" ||\n\treq.http.User-Agent ~ \"(?i)blazer\" ||\n\treq.http.User-Agent ~ \"(?i)cellphone\" ||\n\treq.http.User-Agent ~ \"(?i)iemobile\" ||\n\treq.http.User-Agent ~ \"(?i)midp-2.0\" ||\n\treq.http.User-Agent ~ \"(?i)u990\" ||\n\treq.http.User-Agent ~ \"(?i)netfront\" ||\n\treq.http.User-Agent ~ \"(?i)opera mini\" ||\n\treq.http.User-Agent ~ \"(?i)palm\" ||\n\treq.http.User-Agent ~ \"(?i)nintendo wii\" ||\n\treq.http.User-Agent ~ \"(?i)playstation portable\" ||\n\treq.http.User-Agent ~ \"(?i)portalmmm\" ||\n\treq.http.User-Agent ~ \"(?i)proxinet\" ||\n\treq.http.User-Agent ~ \"(?i)sonyericsson\" ||\n\treq.http.User-Agent ~ \"(?i)symbian\" ||\n\treq.http.User-Agent ~ \"(?i)windows\\ ?ce\" ||\n\treq.http.User-Agent ~ \"(?i)winwap\" ||\n\treq.http.User-Agent ~ \"(?i)eudoraweb\" ||\n\treq.http.User-Agent ~ \"(?i)htc\" ||\n\treq.http.User-Agent ~ \"(?i)240x320\" ||\n\treq.http.User-Agent ~ \"(?i)avantgo\") {\n set req.http.X-UA-Device = \"mobile-generic\";\n }\n # handle overrides\n if (req.http.Cookie ~ \"(i?)X-UA-Device-force\") {\n # ;?? means zero or one ;, non-greedy to match the first.\n set req.http.X-UA-Device = regsub(req.http.Cookie, \"(?i).*X-UA-Device-force=([^;]+);??.*\", \"\\1\");\n # Clean up the cookie header to allow for caching.\n set req.http.Cookie = regsuball(req.http.Cookie, \"(^|; ) *X-UA-Device-force=[^;]+;? *\", \"\\1\");\n if (req.http.Cookie ~ \"^ *$\") { unset req.http.Cookie; }\n }\n}\n\n# vim: sw=4:tw=120\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"ef9821f5d94e10856f5f025261f36b19a8cdc328","subject":"Switch from pypi.io to pypi.org (#1411)","message":"Switch from pypi.io to pypi.org (#1411)\n\n","repos":"alex\/warehouse,dstufft\/warehouse,dstufft\/warehouse,dstufft\/warehouse,alex\/warehouse,alex\/warehouse,alex\/warehouse,dstufft\/warehouse,pypa\/warehouse,pypa\/warehouse,pypa\/warehouse,alex\/warehouse,pypa\/warehouse","old_file":"vcl\/main.vcl","new_file":"vcl\/main.vcl","new_contents":"\nsub vcl_recv {\n\n # I'm not 100% sure on what this is exactly for, it was taken from the\n # Fastly documentation, however, what I *believe* it does is just ensure\n # that we don't serve a stale copy of the page from the shield node when\n # an edge node is requesting content.\n if (req.http.Fastly-FF) {\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Some (Older) clients will send a hash fragment as part of the URL even\n # though that is a local only modification. This breaks this badly for the\n # files in S3, and in general it's just not needed.\n set req.url = regsub(req.url, \"#.*$\", \"\");\n\n # Fastly does some normalization of the Accept-Encoding header so that it\n # reduces the number of cached copies (when served with the common,\n # Vary: Accept-Encoding) that are cached for any one URL. This makes a lot\n # of sense, except for the fact that we want to enable brotli compression\n # for our static files. Thus we need to work around the normalized encoding\n # in a way that still minimizes cached copies, but which will allow our\n # static files to be served using brotli.\n if (req.url ~ \"^\/static\/\" && req.http.Fastly-Orig-Accept-Encoding) {\n if (req.http.User-Agent ~ \"MSIE 6\") {\n # For that 0.3% of stubborn users out there\n unset req.http.Accept-Encoding;\n } elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"br\") {\n set req.http.Accept-Encoding = \"br\";\n } elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n\n # Most of the URLs in Warehouse do not support or require any sort of query\n # parameter. If we strip these at the edge then we'll increase our cache\n # efficiency when they won't otherwise change the output of the pages.\n #\n # This will match any URL except those that start with:\n #\n # * \/search\/\n # * \/account\/login\/\n # * \/account\/logout\/\n # * \/account\/register\/\n # * \/pypi\n if (req.url !~ \"^\/(search\/|account\/(login|logout|register)\/|pypi)\") {\n set req.url = req.url.path;\n }\n\n # Sort all of our query parameters, this will ensure that the same query\n # parameters in a different order will end up being represented as the same\n # thing, reducing cache misses due to ordering differences.\n set req.url = boltsort.sort(req.url);\n\n\n#FASTLY recv\n\n\n # We want to Force SSL for the WebUI by redirecting to the HTTPS version of\n # the page, however for API calls we want to return an error code directing\n # people to instead use HTTPS.\n if (!req.http.Fastly-SSL) {\n\n # The \/simple\/ and \/packages\/ API.\n if (req.url ~ \"^\/(simple|packages)\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy JSON API.\n if (req.url ~ \"^\/pypi\/.+\/json$\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy ?:action= API.\n if (req.url ~ \"^\/pypi.*(\\?|&)=:action\") {\n error 803 \"SSL is required\";\n }\n\n # If we're on the \/pypi page and we've received something other than a\n # GET or HEAD request, then we have no way to determine if a particular\n # request is an API call or not because it'll be in the request body\n # and that isn't available to us here. So in those cases, we won't\n # do a redirect.\n if (req.url ~ \"^\/pypi\") {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n error 801 \"Force SSL\";\n }\n }\n else {\n # This isn't a \/pypi URL so we'll just unconditionally redirect to\n # HTTPS.\n error 801 \"Force SSL\";\n }\n }\n\n # Redirect pypi.io, www.pypi.io, and warehouse.python.org to pypi.io, this\n # is purposely done *after* the HTTPS checks.\n if (std.tolower(req.http.host) ~ \"^(www.pypi.org|(www.)?pypi.io|warehouse.python.org)$\") {\n set req.http.Location = \"https:\/\/pypi.org\" req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n # Redirect warehouse-staging.python.org to test.pypi.io.\n if (std.tolower(req.http.host) ~ \"^(test.pypi.io|warehouse-staging.python.org)$\") {\n set req.http.Location = \"https:\/\/test.pypi.org\" req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n\n # Requests to \/packages\/ get dispatched to Amazon instead of to our typical\n # Origin. This requires a a bit of setup to make it work.\n if (req.http.host ~ \"^(test-)?files.pythonhosted.org$\"\n && req.url ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\") {\n # Setup our environment to better match what S3 expects\/needs\n set req.http.Host = req.http.AWS-Bucket-Name \".s3.amazonaws.com\";\n set req.http.Date = now;\n set req.url = regsuball(req.url, \"\\+\", urlencode(\"+\"));\n\n # Compute the Authorization header that S3 requires to be able to\n # access the files stored there.\n set req.http.Authorization = \"AWS \" req.http.AWS-Access-Key-ID \":\" digest.hmac_sha1_base64(req.http.AWS-Secret-Access-Key, \"GET\" LF LF LF req.http.Date LF \"\/\" req.http.AWS-Bucket-Name req.url.path);\n\n # We don't want to send our Warehouse-Token to S3, so we'll go ahead\n # and remove it.\n unset req.http.Warehouse-Token;\n }\n\n # We no longer need any of these variables, which would exist only to\n # shuffle configuration from the Fastly UI into our VCL.\n unset req.http.AWS-Access-Key-ID;\n unset req.http.AWS-Secret-Access-Key;\n unset req.http.AWS-Bucket-Name;\n\n # We have a number of items that we'll pass back to the origin, but only\n # if we have a Warehouse-Token that will allow them to be accepted.\n if (req.http.Warehouse-Token) {\n # Set a header to tell the backend if we're using https or http.\n if (req.http.Fastly-SSL) {\n set req.http.Warehouse-Proto = \"https\";\n } else {\n set req.http.Warehouse-Proto = \"http\";\n }\n\n # Pass the client IP address back to the backend.\n if (req.http.Fastly-Client-IP) {\n set req.http.Warehouse-IP = req.http.Fastly-Client-IP;\n }\n\n # Pass the real host value back to the backend.\n if (req.http.Host) {\n set req.http.Warehouse-Host = req.http.host;\n }\n }\n\n # On a POST, we want to skip the shielding and hit backends directly.\n if (req.request == \"POST\") {\n set req.backend = F_Heroku;\n }\n\n # Do not bother to attempt to run the caching mechanisms for methods that\n # are not generally safe to cache.\n if (req.request != \"HEAD\" &&\n req.request != \"GET\" &&\n req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n # We don't ever want to cache our health URL. Outside systems should be\n # able to use it to reach past Fastly and get an end to end health check.\n if (req.url == \"\/_health\/\") {\n return(pass);\n }\n\n # Finally, return the default lookup action.\n return(lookup);\n}\n\n\nsub vcl_fetch {\n\n # These are newer kinds of redirects which should be able to be cached by\n # default, even though Fastly doesn't currently have them in their default\n # list of cacheable status codes.\n if (http_status_matches(beresp.status, \"303,307,308\")) {\n set beresp.cacheable = true;\n }\n\n # For any 5xx status code we want to see if a stale object exists for it,\n # if so we'll go ahead and serve it.\n if (beresp.status >= 500 && beresp.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n # When delivering a 304 response, we don't always have access to all the\n # headers in the resp because a 304 response is supposed to remove most of\n # the headers. So we'll instead stash these headers on the request so that\n # we can log this data from there instead of from the response.\n if (beresp.http.x-amz-meta-project\n || beresp.http.x-amz-meta-version\n || beresp.http.x-amz-meta-package-type) {\n set req.http.Fastly-amz-meta-project = beresp.http.x-amz-meta-project;\n set req.http.Fastly-amz-meta-version = beresp.http.x-amz-meta-version;\n set req.http.Fastly-amz-meta-package-type = beresp.http.x-amz-meta-package-type;\n }\n\n\n#FASTLY fetch\n\n\n # Trigger a \"SSL is required\" error if the backend has indicated to do so.\n if (beresp.http.X-Fastly-Error == \"803\") {\n error 803 \"SSL is required\";\n }\n\n # If we've gotten a 502 or a 503 from the backend, we'll go ahead and retry\n # the request.\n if ((beresp.status == 502 || beresp.status == 503) &&\n req.restarts < 1 &&\n (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n # If we've restarted, then we'll record the number of restarts.\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n # If there is a Set-Cookie header, we'll ensure that we do not cache the\n # response.\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n # If the response has the private Cache-Control directive then we won't\n # cache it.\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # If we've gotten an error after the restarts we'll deliver the response\n # with a very short cache time.\n if (http_status_matches(beresp.status, \"500,502,503\")) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n # Apply a default TTL if there isn't a max-age or s-maxage.\n if (beresp.http.Expires ||\n beresp.http.Surrogate-Control ~ \"max-age\" ||\n beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # Keep the ttl here\n }\n else {\n # Apply the default ttl\n set beresp.ttl = 60s;\n }\n\n # Actually deliver the fetched response.\n return(deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n # If the object we have isn't cacheable, then just serve it directly\n # without going through any of the caching mechanisms.\n if (!obj.cacheable) {\n return(pass);\n }\n\n return(deliver);\n}\n\n\nsub vcl_deliver {\n # If this is an error and we have a stale response available, restart so\n # that we can pick it up and serve it.\n if (resp.status >= 500 && resp.status < 600) {\n if (stale.exists) {\n restart;\n }\n }\n\n#FASTLY deliver\n\n # Unset headers that we don't need\/want to send on to the client because\n # they are not generally useful.\n unset resp.http.Server;\n unset resp.http.Via;\n\n # Unset a few headers set by Amazon that we don't really have a need\/desire\n # to send to clients.\n unset resp.http.X-AMZ-Replication-Status;\n unset resp.http.X-AMZ-Meta-Python-Version;\n unset resp.http.X-AMZ-Meta-Version;\n unset resp.http.X-AMZ-Meta-Package-Type;\n unset resp.http.X-AMZ-Meta-Project;\n\n # Set our standard security headers, we do this in VCL rather than in\n # Warehouse itself so that we always get these headers, regardless of the\n # origin server being used.\n set resp.http.Strict-Transport-Security = \"max-age=31536000; includeSubDomains; preload\";\n set resp.http.X-Frame-Options = \"deny\";\n set resp.http.X-XSS-Protection = \"1; mode=block\";\n set resp.http.X-Content-Type-Options = \"nosniff\";\n set resp.http.X-Permitted-Cross-Domain-Policies = \"none\";\n\n # Unstash our information about what project\/version\/package-type a\n # particular file download was for.\n if (req.http.Fastly-amz-meta-project\n || req.http.Fastly-amz-meta-version\n || req.http.Fastly-amz-meta-package-type) {\n set resp.http.x-amz-meta-project = req.http.Fastly-amz-meta-project;\n set resp.http.x-amz-meta-version = req.http.Fastly-amz-meta-version;\n set resp.http.x-amz-meta-package-type = req.http.Fastly-amz-meta-package-type;\n }\n\n # If we're not executing a shielding request, and the URL is one of our file\n # URLs, and it's a GET request, and the response is either a 200 or a 304\n # then we want to log an event stating that a download has taken place.\n if (!req.http.Fastly-FF\n && std.tolower(req.http.host) == \"files.pythonhosted.org\"\n && req.url.path ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\"\n && req.request == \"GET\"\n && http_status_matches(resp.status, \"200,304\")) {\n log {\"syslog \"} req.service_id {\" linehaul :: \"} \"2@\" now \"|\" geoip.country_code \"|\" req.url.path \"|\" tls.client.protocol \"|\" tls.client.cipher \"|\" resp.http.x-amz-meta-project \"|\" resp.http.x-amz-meta-version \"|\" resp.http.x-amz-meta-package-type \"|\" req.http.user-agent;\n log {\"syslog \"} req.service_id {\" downloads :: \"} \"2@\" now \"|\" geoip.country_code \"|\" req.url.path \"|\" tls.client.protocol \"|\" tls.client.cipher \"|\" resp.http.x-amz-meta-project \"|\" resp.http.x-amz-meta-version \"|\" resp.http.x-amz-meta-package-type \"|\" req.http.user-agent;\n }\n\n return(deliver);\n}\n\n\nsub vcl_error {\n#FASTLY error\n\n # If we have a 5xx error and there is a stale object available, then we\n # will deliver that stale object.\n if (obj.status >= 500 && obj.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n if (obj.status == 803) {\n set obj.status = 403;\n set obj.response = \"SSL is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic {\"SSL is required.\"};\n return (deliver);\n } else if (obj.status == 750) {\n set obj.status = 301;\n set obj.http.Location = req.http.Location;\n set obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n synthetic {\"<html><head><title>301 Moved Permanently<\/title><\/head><body><center><h1>301 Moved Permanently<\/h1><\/center><\/body><\/html>\"};\n return(deliver);\n }\n\n}\n","old_contents":"\nsub vcl_recv {\n\n # I'm not 100% sure on what this is exactly for, it was taken from the\n # Fastly documentation, however, what I *believe* it does is just ensure\n # that we don't serve a stale copy of the page from the shield node when\n # an edge node is requesting content.\n if (req.http.Fastly-FF) {\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Some (Older) clients will send a hash fragment as part of the URL even\n # though that is a local only modification. This breaks this badly for the\n # files in S3, and in general it's just not needed.\n set req.url = regsub(req.url, \"#.*$\", \"\");\n\n # Fastly does some normalization of the Accept-Encoding header so that it\n # reduces the number of cached copies (when served with the common,\n # Vary: Accept-Encoding) that are cached for any one URL. This makes a lot\n # of sense, except for the fact that we want to enable brotli compression\n # for our static files. Thus we need to work around the normalized encoding\n # in a way that still minimizes cached copies, but which will allow our\n # static files to be served using brotli.\n if (req.url ~ \"^\/static\/\" && req.http.Fastly-Orig-Accept-Encoding) {\n if (req.http.User-Agent ~ \"MSIE 6\") {\n # For that 0.3% of stubborn users out there\n unset req.http.Accept-Encoding;\n } elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"br\") {\n set req.http.Accept-Encoding = \"br\";\n } elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n\n # Most of the URLs in Warehouse do not support or require any sort of query\n # parameter. If we strip these at the edge then we'll increase our cache\n # efficiency when they won't otherwise change the output of the pages.\n #\n # This will match any URL except those that start with:\n #\n # * \/search\/\n # * \/account\/login\/\n # * \/account\/logout\/\n # * \/account\/register\/\n # * \/pypi\n if (req.url !~ \"^\/(search\/|account\/(login|logout|register)\/|pypi)\") {\n set req.url = req.url.path;\n }\n\n # Sort all of our query parameters, this will ensure that the same query\n # parameters in a different order will end up being represented as the same\n # thing, reducing cache misses due to ordering differences.\n set req.url = boltsort.sort(req.url);\n\n\n#FASTLY recv\n\n\n # We want to Force SSL for the WebUI by redirecting to the HTTPS version of\n # the page, however for API calls we want to return an error code directing\n # people to instead use HTTPS.\n if (!req.http.Fastly-SSL) {\n\n # The \/simple\/ and \/packages\/ API.\n if (req.url ~ \"^\/(simple|packages)\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy JSON API.\n if (req.url ~ \"^\/pypi\/.+\/json$\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy ?:action= API.\n if (req.url ~ \"^\/pypi.*(\\?|&)=:action\") {\n error 803 \"SSL is required\";\n }\n\n # If we're on the \/pypi page and we've received something other than a\n # GET or HEAD request, then we have no way to determine if a particular\n # request is an API call or not because it'll be in the request body\n # and that isn't available to us here. So in those cases, we won't\n # do a redirect.\n if (req.url ~ \"^\/pypi\") {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n error 801 \"Force SSL\";\n }\n }\n else {\n # This isn't a \/pypi URL so we'll just unconditionally redirect to\n # HTTPS.\n error 801 \"Force SSL\";\n }\n }\n\n # Redirect www.pypi.io and warehouse.python.org to pypi.io, this is\n # purposely done *after* the HTTPS checks.\n if (std.tolower(req.http.host) ~ \"^(www.pypi.io|warehouse.python.org)$\") {\n set req.http.Location = \"https:\/\/pypi.io\" req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n # Redirect warehouse-staging.python.org to test.pypi.io.\n if (std.tolower(req.http.host) ~ \"^(test.pypi.io|warehouse-staging.python.org)$\") {\n set req.http.Location = \"https:\/\/test.pypi.org\" req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n\n # Requests to \/packages\/ get dispatched to Amazon instead of to our typical\n # Origin. This requires a a bit of setup to make it work.\n if (req.http.host ~ \"^(test-)?files.pythonhosted.org$\"\n && req.url ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\") {\n # Setup our environment to better match what S3 expects\/needs\n set req.http.Host = req.http.AWS-Bucket-Name \".s3.amazonaws.com\";\n set req.http.Date = now;\n set req.url = regsuball(req.url, \"\\+\", urlencode(\"+\"));\n\n # Compute the Authorization header that S3 requires to be able to\n # access the files stored there.\n set req.http.Authorization = \"AWS \" req.http.AWS-Access-Key-ID \":\" digest.hmac_sha1_base64(req.http.AWS-Secret-Access-Key, \"GET\" LF LF LF req.http.Date LF \"\/\" req.http.AWS-Bucket-Name req.url.path);\n\n # We don't want to send our Warehouse-Token to S3, so we'll go ahead\n # and remove it.\n unset req.http.Warehouse-Token;\n }\n\n # We no longer need any of these variables, which would exist only to\n # shuffle configuration from the Fastly UI into our VCL.\n unset req.http.AWS-Access-Key-ID;\n unset req.http.AWS-Secret-Access-Key;\n unset req.http.AWS-Bucket-Name;\n\n # We have a number of items that we'll pass back to the origin, but only\n # if we have a Warehouse-Token that will allow them to be accepted.\n if (req.http.Warehouse-Token) {\n # Set a header to tell the backend if we're using https or http.\n if (req.http.Fastly-SSL) {\n set req.http.Warehouse-Proto = \"https\";\n } else {\n set req.http.Warehouse-Proto = \"http\";\n }\n\n # Pass the client IP address back to the backend.\n if (req.http.Fastly-Client-IP) {\n set req.http.Warehouse-IP = req.http.Fastly-Client-IP;\n }\n\n # Pass the real host value back to the backend.\n if (req.http.Host) {\n set req.http.Warehouse-Host = req.http.host;\n }\n }\n\n # On a POST, we want to skip the shielding and hit backends directly.\n if (req.request == \"POST\") {\n set req.backend = F_Heroku;\n }\n\n # Do not bother to attempt to run the caching mechanisms for methods that\n # are not generally safe to cache.\n if (req.request != \"HEAD\" &&\n req.request != \"GET\" &&\n req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n # We don't ever want to cache our health URL. Outside systems should be\n # able to use it to reach past Fastly and get an end to end health check.\n if (req.url == \"\/_health\/\") {\n return(pass);\n }\n\n # Finally, return the default lookup action.\n return(lookup);\n}\n\n\nsub vcl_fetch {\n\n # These are newer kinds of redirects which should be able to be cached by\n # default, even though Fastly doesn't currently have them in their default\n # list of cacheable status codes.\n if (http_status_matches(beresp.status, \"303,307,308\")) {\n set beresp.cacheable = true;\n }\n\n # For any 5xx status code we want to see if a stale object exists for it,\n # if so we'll go ahead and serve it.\n if (beresp.status >= 500 && beresp.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n # When delivering a 304 response, we don't always have access to all the\n # headers in the resp because a 304 response is supposed to remove most of\n # the headers. So we'll instead stash these headers on the request so that\n # we can log this data from there instead of from the response.\n if (beresp.http.x-amz-meta-project\n || beresp.http.x-amz-meta-version\n || beresp.http.x-amz-meta-package-type) {\n set req.http.Fastly-amz-meta-project = beresp.http.x-amz-meta-project;\n set req.http.Fastly-amz-meta-version = beresp.http.x-amz-meta-version;\n set req.http.Fastly-amz-meta-package-type = beresp.http.x-amz-meta-package-type;\n }\n\n\n#FASTLY fetch\n\n\n # Trigger a \"SSL is required\" error if the backend has indicated to do so.\n if (beresp.http.X-Fastly-Error == \"803\") {\n error 803 \"SSL is required\";\n }\n\n # If we've gotten a 502 or a 503 from the backend, we'll go ahead and retry\n # the request.\n if ((beresp.status == 502 || beresp.status == 503) &&\n req.restarts < 1 &&\n (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n # If we've restarted, then we'll record the number of restarts.\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n # If there is a Set-Cookie header, we'll ensure that we do not cache the\n # response.\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n # If the response has the private Cache-Control directive then we won't\n # cache it.\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # If we've gotten an error after the restarts we'll deliver the response\n # with a very short cache time.\n if (http_status_matches(beresp.status, \"500,502,503\")) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n # Apply a default TTL if there isn't a max-age or s-maxage.\n if (beresp.http.Expires ||\n beresp.http.Surrogate-Control ~ \"max-age\" ||\n beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # Keep the ttl here\n }\n else {\n # Apply the default ttl\n set beresp.ttl = 60s;\n }\n\n # Actually deliver the fetched response.\n return(deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n # If the object we have isn't cacheable, then just serve it directly\n # without going through any of the caching mechanisms.\n if (!obj.cacheable) {\n return(pass);\n }\n\n return(deliver);\n}\n\n\nsub vcl_deliver {\n # If this is an error and we have a stale response available, restart so\n # that we can pick it up and serve it.\n if (resp.status >= 500 && resp.status < 600) {\n if (stale.exists) {\n restart;\n }\n }\n\n#FASTLY deliver\n\n # Unset headers that we don't need\/want to send on to the client because\n # they are not generally useful.\n unset resp.http.Server;\n unset resp.http.Via;\n\n # Unset a few headers set by Amazon that we don't really have a need\/desire\n # to send to clients.\n unset resp.http.X-AMZ-Replication-Status;\n unset resp.http.X-AMZ-Meta-Python-Version;\n unset resp.http.X-AMZ-Meta-Version;\n unset resp.http.X-AMZ-Meta-Package-Type;\n unset resp.http.X-AMZ-Meta-Project;\n\n # Set our standard security headers, we do this in VCL rather than in\n # Warehouse itself so that we always get these headers, regardless of the\n # origin server being used.\n set resp.http.Strict-Transport-Security = \"max-age=31536000; includeSubDomains; preload\";\n set resp.http.X-Frame-Options = \"deny\";\n set resp.http.X-XSS-Protection = \"1; mode=block\";\n set resp.http.X-Content-Type-Options = \"nosniff\";\n set resp.http.X-Permitted-Cross-Domain-Policies = \"none\";\n\n # Unstash our information about what project\/version\/package-type a\n # particular file download was for.\n if (req.http.Fastly-amz-meta-project\n || req.http.Fastly-amz-meta-version\n || req.http.Fastly-amz-meta-package-type) {\n set resp.http.x-amz-meta-project = req.http.Fastly-amz-meta-project;\n set resp.http.x-amz-meta-version = req.http.Fastly-amz-meta-version;\n set resp.http.x-amz-meta-package-type = req.http.Fastly-amz-meta-package-type;\n }\n\n # If we're not executing a shielding request, and the URL is one of our file\n # URLs, and it's a GET request, and the response is either a 200 or a 304\n # then we want to log an event stating that a download has taken place.\n if (!req.http.Fastly-FF\n && std.tolower(req.http.host) == \"files.pythonhosted.org\"\n && req.url.path ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\"\n && req.request == \"GET\"\n && http_status_matches(resp.status, \"200,304\")) {\n log {\"syslog \"} req.service_id {\" linehaul :: \"} \"2@\" now \"|\" geoip.country_code \"|\" req.url.path \"|\" tls.client.protocol \"|\" tls.client.cipher \"|\" resp.http.x-amz-meta-project \"|\" resp.http.x-amz-meta-version \"|\" resp.http.x-amz-meta-package-type \"|\" req.http.user-agent;\n log {\"syslog \"} req.service_id {\" downloads :: \"} \"2@\" now \"|\" geoip.country_code \"|\" req.url.path \"|\" tls.client.protocol \"|\" tls.client.cipher \"|\" resp.http.x-amz-meta-project \"|\" resp.http.x-amz-meta-version \"|\" resp.http.x-amz-meta-package-type \"|\" req.http.user-agent;\n }\n\n return(deliver);\n}\n\n\nsub vcl_error {\n#FASTLY error\n\n # If we have a 5xx error and there is a stale object available, then we\n # will deliver that stale object.\n if (obj.status >= 500 && obj.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n if (obj.status == 803) {\n set obj.status = 403;\n set obj.response = \"SSL is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic {\"SSL is required.\"};\n return (deliver);\n } else if (obj.status == 750) {\n set obj.status = 301;\n set obj.http.Location = req.http.Location;\n set obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n synthetic {\"<html><head><title>301 Moved Permanently<\/title><\/head><body><center><h1>301 Moved Permanently<\/h1><\/center><\/body><\/html>\"};\n return(deliver);\n }\n\n}\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"eeb8d58715b023fdd5938790931bafd97c52f662","subject":"Various fixes","message":"Various fixes\n\nSpelling. While here also fix indentation and make sure we are using\nthe right name for the variables and not the backward compat ones.\n","repos":"gquintard\/Varnish-Cache,feld\/Varnish-Cache,zhoualbeart\/Varnish-Cache,chrismoulton\/Varnish-Cache,zhoualbeart\/Varnish-Cache,zhoualbeart\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,feld\/Varnish-Cache,chrismoulton\/Varnish-Cache,franciscovg\/Varnish-Cache,alarky\/varnish-cache-doc-ja,ajasty-cavium\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,franciscovg\/Varnish-Cache,franciscovg\/Varnish-Cache,chrismoulton\/Varnish-Cache,feld\/Varnish-Cache,alarky\/varnish-cache-doc-ja,zhoualbeart\/Varnish-Cache,mrhmouse\/Varnish-Cache,zhoualbeart\/Varnish-Cache,feld\/Varnish-Cache,mrhmouse\/Varnish-Cache,chrismoulton\/Varnish-Cache,varnish\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,mrhmouse\/Varnish-Cache,chrismoulton\/Varnish-Cache,franciscovg\/Varnish-Cache,gquintard\/Varnish-Cache,mrhmouse\/Varnish-Cache,alarky\/varnish-cache-doc-ja,varnish\/Varnish-Cache,mrhmouse\/Varnish-Cache,alarky\/varnish-cache-doc-ja,gquintard\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,feld\/Varnish-Cache,franciscovg\/Varnish-Cache,varnish\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,varnish\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,gquintard\/Varnish-Cache,alarky\/varnish-cache-doc-ja,gauthier-delacroix\/Varnish-Cache,varnish\/Varnish-Cache","old_file":"bin\/varnishd\/builtin.vcl","new_file":"bin\/varnishd\/builtin.vcl","new_contents":"\/*-\n * Copyright (c) 2006 Verdens Gang AS\n * Copyright (c) 2006-2014 Varnish Software AS\n * All rights reserved.\n *\n * Author: Poul-Henning Kamp <phk@phk.freebsd.dk>\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in the\n * documentation and\/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n\n *\n * The built-in (previously called default) VCL code.\n *\n * NB! You do NOT need to copy & paste all of these functions into your\n * own vcl code, if you do not provide a definition of one of these\n * functions, the compiler will automatically fall back to the default\n * code from this file.\n *\n * This code will be prefixed with a backend declaration built from the\n * -b argument.\n *\/\n\nvcl 4.0;\n\nsub vcl_recv {\n if (req.restarts == 0) {\n\tif (req.http.x-forwarded-for) {\n\t set req.http.X-Forwarded-For =\n\t\treq.http.X-Forwarded-For + \", \" + client.ip;\n\t} else {\n\t set req.http.X-Forwarded-For = client.ip;\n\t}\n }\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization || req.http.Cookie) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n return (hash);\n}\n\nsub vcl_pipe {\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n # set bereq.http.connection = \"close\";\n # here. It is not set by default as it might break some broken web\n # applications, like IIS with NTLM authentication.\n return (pipe);\n}\n\nsub vcl_pass {\n return (fetch);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n return (lookup);\n}\n\nsub vcl_purge {\n return (error(200, \"Purged\"));\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n\t\/\/ A pure unadultered hit, deliver it\n\treturn (deliver);\n }\n if (obj.ttl + obj.grace > 0s) {\n\t\/\/ Object is in grace, deliver it\n\t\/\/ Automatically triggers a background fetch\n\treturn (deliver);\n }\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\nsub vcl_miss {\n return (fetch);\n}\n\n\nsub vcl_backend_fetch {\n return (fetch);\n}\n\nsub vcl_backend_response {\n if (beresp.ttl <= 0s ||\n beresp.http.Set-Cookie ||\n beresp.http.Surrogate-control ~ \"no-store\" ||\n (!beresp.http.Surrogate-Control &&\n beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n beresp.http.Vary == \"*\") {\n\t\t\/*\n\t\t * Mark as \"Hit-For-Pass\" for the next 2 minutes\n\t\t *\/\n\t\tset beresp.ttl = 120s;\n\t\tset beresp.uncacheable = true;\n }\n return (deliver);\n}\n\nsub vcl_deliver {\n \/*\n * These two write to the stored object causing extra page faults\n * Enable them only if you need them.\n *\n * set obj.hits = obj.hits + 1;\n * set obj.last_use = now;\n *\/\n return (deliver);\n}\n\n\/*\n * We can come here \"invisibly\" with the following errors: 413, 417 & 503\n *\/\nsub vcl_error {\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} + obj.status + \" \" + obj.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + obj.status + \" \" + obj.reason + {\"<\/h1>\n <p>\"} + obj.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"};\n return (deliver);\n}\n\nsub vcl_init {\n return (ok);\n}\n\nsub vcl_fini {\n return (ok);\n}\n","old_contents":"\/*-\n * Copyright (c) 2006 Verdens Gang AS\n * Copyright (c) 2006-2014 Varnish Software AS\n * All rights reserved.\n *\n * Author: Poul-Henning Kamp <phk@phk.freebsd.dk>\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in the\n * documentation and\/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n\n *\n * The built-in (previously called default) VCL code.\n *\n * NB! You do NOT need to copy & paste all of these functions into your\n * own vcl code, if you do not provide a definition of one of these\n * functions, the compiler will automatically fall back to the default\n * code from this file.\n *\n * This code will be prefixed with a backend declaration built from the\n * -b argument.\n *\/\n\nvcl 4.0;\n\nsub vcl_recv {\n if (req.restarts == 0) {\n\tif (req.http.x-forwarded-for) {\n\t set req.http.X-Forwarded-For =\n\t\treq.http.X-Forwarded-For + \", \" + client.ip;\n\t} else {\n\t set req.http.X-Forwarded-For = client.ip;\n\t}\n }\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization || req.http.Cookie) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n return (hash);\n}\n\nsub vcl_pipe {\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n # set bereq.http.connection = \"close\";\n # here. It is not set by default as it might break some broken web\n # applications, like IIS with NTLM authentication.\n return (pipe);\n}\n\nsub vcl_pass {\n return (fetch);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n return (lookup);\n}\n\nsub vcl_purge {\n return (error(200, \"Purged\"));\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n\t\/\/ A pure unadultered hit, deliver it\n\treturn (deliver);\n }\n if (obj.ttl + obj.grace > 0s) {\n\t\/\/ Object is in grace, delive it\n\t\/\/ Automatically triggers a background fetch\n\treturn (deliver);\n }\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\nsub vcl_miss {\n return (fetch);\n}\n\n\nsub vcl_backend_fetch {\n return (fetch);\n}\n\nsub vcl_backend_response {\n if (beresp.ttl <= 0s ||\n beresp.http.Set-Cookie ||\n beresp.http.Surrogate-control ~ \"no-store\" ||\n (!beresp.http.Surrogate-Control &&\n beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n beresp.http.Vary == \"*\") {\n\t\t\/*\n\t\t * Mark as \"Hit-For-Pass\" for the next 2 minutes\n\t\t *\/\n\t\tset beresp.ttl = 120 s;\n\t\tset beresp.uncacheable = true;\n }\n return (deliver);\n}\n\nsub vcl_deliver {\n \/*\n * These two write to the stored object causing extra page faults\n * Enable them only if you need them.\n *\n * set obj.hits = obj.hits + 1;\n * set obj.last_use = now;\n *\/\n return (deliver);\n}\n\n\/*\n * We can come here \"invisibly\" with the following errors: 413, 417 & 503\n *\/\nsub vcl_error {\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + obj.status + \" \" + obj.response + {\"<\/h1>\n <p>\"} + obj.response + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"};\n return (deliver);\n}\n\nsub vcl_init {\n\treturn (ok);\n}\n\nsub vcl_fini {\n\treturn (ok);\n}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"9df58456cd19ee9edb3c6ba2c6d2baf5703dd351","subject":"Added a test command","message":"Added a test command\n","repos":"aschneiderman\/atom-voice-vocola","old_file":"atom.vcl","new_file":"atom.vcl","new_contents":"# Voice commands for atom\n\nTest Command = \"This Is a Test Command\";\n\ninclude folders.vch;\ninclude letters.vch;\n\n# Commands for developing D3: D3 visualizations, D3 Sandwiches\nSave and Reload = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Ctrl+r};\t\nSave and Really Reload = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Ctrl+Shift+r};\nSave and Run = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Up}{Enter};\n\n# File commands\nFind (File | Document) = {Ctrl+t};\nSave As = {Ctrl+Shift+s};\nNext Window = {Ctrl+Tab};\nLast Window = {Ctrl+Shift+Tab};\nLatest File = {Ctrl+Shift+t};\n(Tree View | List Files) = {Alt+o};\t# NOTE: to make this work, I had to create a new keyboard shortcut in Atom (my personal keymap.cson)\n\n\n# --- Text navigation commands ------------------------------------\n<delimiters> := (Quote = '\"' | 'Double Quote' = '\"' | 'Single Quote' = \"'\" | Comma = ',' | 'Equal Sign' = '=' | Equals = '=' \n\t| Period = '.' | Colon = ':' | 'Semi-Colon' = ';' | Hyphen = '-' | Underscore = '_' | Slash = '\/'\n\t| Paren = \"(\" | \"Close Paren\" = \")\" | Parentheses = \"(\" | \"Open Parenthesis\" = \"(\" | \"Close Parentheses\" = \")\"\n\t| Bracket = '[' | \"Close Bracket\" = ']' | Brace = '{' | 'Close Brace' = '}'\t);\n\nLine 1..200 = {Ctrl+g} $1 {Enter};\n(Left = 'b' | Right = 'f') Word = {Alt+$1};\nTop = {Ctrl+Home};\nBottom = {Ctrl+End};\n(Find = 'Right' | 'Insert After' = 'Right' | 'Insert Before' = 'Left') (Next = 'Enter' | Last = 'Shift+F3') <delimiters> \n\t\t= {Ctrl+f} $3 {$2} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') <delimiters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') 1..20 <delimiters> = {Ctrl+f} $3 {Enter} {Esc} Wait(100) {F3_$2} {Shift+F3} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') Enda <delimiters> = {End} {Ctrl+f} $2 {Enter} {Esc} {Shift+F3} Wait(100) {$1};\n\nFine Alpha <letters> = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Left};\nInsert (Before = 'Left' | After = 'Right') Alpha <letters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nFine Number 0..9 = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Right};\n(Find | Insert) Again = {F3} {Right};\n(Find | Insert) Again 1..20 Times = {F3_$1} {Right};\n\n(Set | Add | Clear | Hide | Delete) Bookmark = {Ctrl+Alt+F2};\n(Next = 'F2' | Last = 'Shift+F2') Bookmark = {$1};\n\n\n# --- Editing commands ----------------------------------------\nSelect Line = {Ctrl+l};\nSelect (Next = 'Down' | Forward = 'Down' | Last = 'Up' | Back = 'Up' | Previous = 'Up') 1..20 Lines = {Home} {Shift+$1_$2};\nMove Line (Up | Down) 1..20 = {Ctrl+$1_$2};\nAdd 1..20 (Lines = 'Down' | Line = 'Down' | Pages = 'PgDn' | Page = 'PgDn') = {Shift+$2_$1};\nStart Adding 1..20 Lines = {Home}{Shift+Down_$1};\n\n\nSelect between (Delimiters | Brackets | Tags) ={Ctrl+m} {Ctrl+Alt+m};\nDelete between Tags = {Ctrl+m} {Ctrl+Alt+m} {Del};\nDelete Tags = {Ctrl+Alt+F4};\nReplace With (Header | Heading) 1..7 = {Ctrl+Alt+F4} '<h' $2 '>' {End} '<\/h' $2 '>' {Home};\nReplace With (para = 'p') = {Ctrl+Alt+F4} '<' $1 '>' {End} '<\/' $1 '>';\n\n\nDelete Word = {Ctrl+Del};\nDelete 1..20 Words = {Ctrl+Del_$1};\nDelete (Back | Last) Word = {Ctrl+Backspace};\nDelete (Back | Last) 1..20 Words = {Ctrl+Backspace_$2};\nDelete Enda Word = {End} {Ctrl+Backspace};\nKill Word = {Ctrl+Backspace}{Ctrl+Del};\n\n(Delete Line | Dede) = {Ctrl+Shift+k};\nDelete 1..20 Lines = {Ctrl+Shift+k_$1};\n(Cut = 'x' | Paste = 'v' | Copy = 'c') That = {Ctrl+$1};\n\nComment (That | Line) = {Ctrl+\/};\nComment 1..20 Lines = {Home} {Shift+Down_$1} {Ctrl+\/};\n\nReplace = {Ctrl+f};\nReplace All = {Ctrl+Enter};\n\n(Join = 'j' | Indent = ']' | Dedent = '[') That = {Ctrl+$1};\n\n\n# --- Commands to create code\/tags -------------------------------------------\n# NOTE: basic HTML commands are stored in my global Vocala commands\n\nStart (\t# HTML commands\n\t'HTML page' = 'html' | pre = \"pre\" | 'Comment' = 'comment-html'\n\t| div = 'div' \n\n\t# D3 Recipe commands\n\t| 'Recipe Page' = 'recipe-page' | 'Recipe Row' = 'recipe-row' \n\t| 'Recipe Toy' = 'recipe-toy' | Toy = 'recipe-toy'\n\t| 'Bold ID'\n\n\t# D3 and JavaScript commands\n\t| Console = 'console' | Log = 'console'\n\t| Var = 'variable' | Variable = 'variable'\n\t# Coffeescript commands\n\t| Snippet = 'my-snippet' \n\t| 'Fix Line' = 'fix-current-line' | 'Fix Current Line' = 'fix-current-line'\n) = $1 {Tab};\n\nStop (\t#HTML commands\n\t'div comment' = 'comment-div-end' | Comment = 'comment-html-end' \n) = $1 {Tab};\n\n# HTML commands\nDot HTML = '.html';\nStart (Header | Heading) 1..7 = h $2 {Tab};\nAdd (Header | Heading) 1..7 = '<h' $2 '>' {End} '<\/h' $2 '>';\nAdd (para = 'p') = '<' $1 '>' {End} '<\/' $1 '>';\n\n# D3 Recipe commands\nPre-Format Code = {Ctrl+Alt+F5};\nReload Atom = {Ctrl+s} Wait(100) {Shift+Ctrl+Alt+F5};\nCommand Palette = {Ctrl+Shift+p};\nKeyboard Shortcuts = {Ctrl+.};\nRun Specs = {Ctrl+Alt+p};\nShow Console = {Ctrl+Alt+i};\n\n\n\n# D3 commands\nPaste Function = 'function ' {Ctrl+v} ' {' {Enter} {Enter} '};' {Up};\n\n# Coffeescript commands\n\n# Python commands\n\n\n# --- D3 commands -------------------------------------------\n\n\n# --- Python commands -------------------------------------------\n\n\n# --- Coffeescript commands -------------------------------------------","old_contents":"# Voice commands for atom\n\ninclude folders.vch;\ninclude letters.vch;\n\n# Commands for developing D3: D3 visualizations, D3 Sandwiches\nSave and Reload = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Ctrl+r};\t\nSave and Really Reload = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Ctrl+Shift+r};\nSave and Run = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Up}{Enter};\n\n# File commands\nFind (File | Document) = {Ctrl+t};\nSave As = {Ctrl+Shift+s};\nNext Window = {Ctrl+Tab};\nLast Window = {Ctrl+Shift+Tab};\nLatest File = {Ctrl+Shift+t};\n(Tree View | List Files) = {Alt+o};\t# NOTE: to make this work, I had to create a new keyboard shortcut in Atom (my personal keymap.cson)\n\n\n# --- Text navigation commands ------------------------------------\n<delimiters> := (Quote = '\"' | 'Double Quote' = '\"' | 'Single Quote' = \"'\" | Comma = ',' | 'Equal Sign' = '=' | Equals = '=' \n\t| Period = '.' | Colon = ':' | 'Semi-Colon' = ';' | Hyphen = '-' | Underscore = '_' | Slash = '\/'\n\t| Paren = \"(\" | \"Close Paren\" = \")\" | Parentheses = \"(\" | \"Open Parenthesis\" = \"(\" | \"Close Parentheses\" = \")\"\n\t| Bracket = '[' | \"Close Bracket\" = ']' | Brace = '{' | 'Close Brace' = '}'\t);\n\nLine 1..200 = {Ctrl+g} $1 {Enter};\n(Left = 'b' | Right = 'f') Word = {Alt+$1};\nTop = {Ctrl+Home};\nBottom = {Ctrl+End};\n(Find = 'Right' | 'Insert After' = 'Right' | 'Insert Before' = 'Left') (Next = 'Enter' | Last = 'Shift+F3') <delimiters> \n\t\t= {Ctrl+f} $3 {$2} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') <delimiters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') 1..20 <delimiters> = {Ctrl+f} $3 {Enter} {Esc} Wait(100) {F3_$2} {Shift+F3} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') Enda <delimiters> = {End} {Ctrl+f} $2 {Enter} {Esc} {Shift+F3} Wait(100) {$1};\n\nFine Alpha <letters> = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Left};\nInsert (Before = 'Left' | After = 'Right') Alpha <letters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nFine Number 0..9 = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Right};\n(Find | Insert) Again = {F3} {Right};\n(Find | Insert) Again 1..20 Times = {F3_$1} {Right};\n\n(Set | Add | Clear | Hide | Delete) Bookmark = {Ctrl+Alt+F2};\n(Next = 'F2' | Last = 'Shift+F2') Bookmark = {$1};\n\n\n# --- Editing commands ----------------------------------------\nSelect Line = {Ctrl+l};\nSelect (Next = 'Down' | Forward = 'Down' | Last = 'Up' | Back = 'Up' | Previous = 'Up') 1..20 Lines = {Home} {Shift+$1_$2};\nMove Line (Up | Down) 1..20 = {Ctrl+$1_$2};\nAdd 1..20 (Lines = 'Down' | Line = 'Down' | Pages = 'PgDn' | Page = 'PgDn') = {Shift+$2_$1};\nStart Adding 1..20 Lines = {Home}{Shift+Down_$1};\n\n\nSelect between (Delimiters | Brackets | Tags) ={Ctrl+m} {Ctrl+Alt+m};\nDelete between Tags = {Ctrl+m} {Ctrl+Alt+m} {Del};\nDelete Tags = {Ctrl+Alt+F4};\nReplace With (Header | Heading) 1..7 = {Ctrl+Alt+F4} '<h' $2 '>' {End} '<\/h' $2 '>' {Home};\nReplace With (para = 'p') = {Ctrl+Alt+F4} '<' $1 '>' {End} '<\/' $1 '>';\n\n\nDelete Word = {Ctrl+Del};\nDelete 1..20 Words = {Ctrl+Del_$1};\nDelete (Back | Last) Word = {Ctrl+Backspace};\nDelete (Back | Last) 1..20 Words = {Ctrl+Backspace_$2};\nDelete Enda Word = {End} {Ctrl+Backspace};\nKill Word = {Ctrl+Backspace}{Ctrl+Del};\n\n(Delete Line | Dede) = {Ctrl+Shift+k};\nDelete 1..20 Lines = {Ctrl+Shift+k_$1};\n(Cut = 'x' | Paste = 'v' | Copy = 'c') That = {Ctrl+$1};\n\nComment (That | Line) = {Ctrl+\/};\nComment 1..20 Lines = {Home} {Shift+Down_$1} {Ctrl+\/};\n\nReplace = {Ctrl+f};\nReplace All = {Ctrl+Enter};\n\n(Join = 'j' | Indent = ']' | Dedent = '[') That = {Ctrl+$1};\n\n\n# --- Commands to create code\/tags -------------------------------------------\n# NOTE: basic HTML commands are stored in my global Vocala commands\n\nStart (\t# HTML commands\n\t'HTML page' = 'html' | pre = \"pre\" | 'Comment' = 'comment-html'\n\t| div = 'div' \n\n\t# D3 Recipe commands\n\t| 'Recipe Page' = 'recipe-page' | 'Recipe Row' = 'recipe-row' \n\t| 'Recipe Toy' = 'recipe-toy' | Toy = 'recipe-toy'\n\t| 'Bold ID'\n\n\t# D3 and JavaScript commands\n\t| Console = 'console' | Log = 'console'\n\t| Var = 'variable' | Variable = 'variable'\n\t# Coffeescript commands\n\t| Snippet = 'my-snippet' \n\t| 'Fix Line' = 'fix-current-line' | 'Fix Current Line' = 'fix-current-line'\n) = $1 {Tab};\n\nStop (\t#HTML commands\n\t'div comment' = 'comment-div-end' | Comment = 'comment-html-end' \n) = $1 {Tab};\n\n# HTML commands\nDot HTML = '.html';\nStart (Header | Heading) 1..7 = h $2 {Tab};\nAdd (Header | Heading) 1..7 = '<h' $2 '>' {End} '<\/h' $2 '>';\nAdd (para = 'p') = '<' $1 '>' {End} '<\/' $1 '>';\n\n# D3 Recipe commands\nPre-Format Code = {Ctrl+Alt+F5};\nReload Atom = {Ctrl+s} Wait(100) {Shift+Ctrl+Alt+F5};\nCommand Palette = {Ctrl+Shift+p};\nKeyboard Shortcuts = {Ctrl+.};\nRun Specs = {Ctrl+Alt+p};\nShow Console = {Ctrl+Alt+i};\n\n\n\n# D3 commands\nPaste Function = 'function ' {Ctrl+v} ' {' {Enter} {Enter} '};' {Up};\n\n# Coffeescript commands\n\n# Python commands\n\n\n# --- D3 commands -------------------------------------------\n\n\n# --- Python commands -------------------------------------------\n\n\n# --- Coffeescript commands -------------------------------------------","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"62f734f077e83b8d6d06859c428ac3e106699b86","subject":"Stop doing UA normalisation on v1 endpoints","message":"Stop doing UA normalisation on v1 endpoints\n","repos":"kdzwinel\/polyfill-service,mcshaz\/polyfill-service,jonathan-fielding\/polyfill-service,jonathan-fielding\/polyfill-service,JakeChampion\/polyfill-service,jonathan-fielding\/polyfill-service,mcshaz\/polyfill-service,mcshaz\/polyfill-service,kdzwinel\/polyfill-service,kdzwinel\/polyfill-service,JakeChampion\/polyfill-service","old_file":"fastly-config.vcl","new_file":"fastly-config.vcl","new_contents":"sub vcl_recv {\n#FASTLY recv\n\n\tif (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n\t\treturn(pass);\n\t}\n\n\tif (req.url ~ \"^\/v2\/polyfill\\.\" && req.url !~ \"[\\?\\&]ua=\") {\n\t\tset req.http.X-Orig-URL = req.url;\n\t\tset req.url = \"\/v2\/normalizeUa?ua=\" urlencode(req.http.User-Agent);\n\t}\n\n\treturn(lookup);\n}\n\nsub vcl_deliver {\n#FASTLY deliver\n\n\t# If the response is to a normalise request and there's a parked \"original request\", use the normalised UA response to modify the original request and restart it\n\tif (req.url ~ \"^\/v\\d\/normalizeUa\" && resp.status == 200 && req.http.X-Orig-URL) {\n\t\tset req.http.Fastly-force-Shield = \"1\";\n\t\tif (req.http.X-Orig-URL ~ \"\\?\") {\n\t\t\tset req.url = req.http.X-Orig-URL \"&ua=\" resp.http.Normalized-User-Agent;\n\t\t} else {\n\t\t\tset req.url = req.http.X-Orig-URL \"?ua=\" resp.http.Normalized-User-Agent;\n\t\t}\n\t\trestart;\n\n\t# If the original request didn't specify a UA override, and we added one when the request was sent to the backend, the backend won't have included a Vary:user-agent header (correctly) but we need to add one\n\t} else if (req.url ~ \"^\/v\\d\/polyfill\\..*[\\?\\&]ua=\" && req.http.X-Orig-URL && req.http.X-Orig-URL !~ \"[\\?\\&]ua=\") {\n\t\tadd resp.http.Vary = \"User-Agent\";\n\t}\n\treturn(deliver);\n}\n","old_contents":"sub vcl_recv {\n#FASTLY recv\n\n\tif (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n\t\treturn(pass);\n\t}\n\n\tif (req.url ~ \"^\/v\\d\/polyfill\\.\" && req.url !~ \"[\\?\\&]ua=\") {\n\t\tset req.http.X-Orig-URL = req.url;\n\t\tset req.url = \"\/v2\/normalizeUa?ua=\" urlencode(req.http.User-Agent);\n\t}\n\n\treturn(lookup);\n}\n\nsub vcl_deliver {\n#FASTLY deliver\n\n\t# If the response is to a normalise request and there's a parked \"original request\", use the normalised UA response to modify the original request and restart it\n\tif (req.url ~ \"^\/v\\d\/normalizeUa\" && resp.status == 200 && req.http.X-Orig-URL) {\n\t\tset req.http.Fastly-force-Shield = \"1\";\n\t\tif (req.http.X-Orig-URL ~ \"\\?\") {\n\t\t\tset req.url = req.http.X-Orig-URL \"&ua=\" resp.http.Normalized-User-Agent;\n\t\t} else {\n\t\t\tset req.url = req.http.X-Orig-URL \"?ua=\" resp.http.Normalized-User-Agent;\n\t\t}\n\t\trestart;\n\n\t# If the original request didn't specify a UA override, and we added one when the request was sent to the backend, the backend won't have included a Vary:user-agent header (correctly) but we need to add one\n\t} else if (req.url ~ \"^\/v\\d\/polyfill\\..*[\\?\\&]ua=\" && req.http.X-Orig-URL && req.http.X-Orig-URL !~ \"[\\?\\&]ua=\") {\n\t\tadd resp.http.Vary = \"User-Agent\";\n\t}\n\treturn(deliver);\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"dbbfb5f9b0edda5677b0c741d899922e1ec20875","subject":"Minor cleanup and add code to avoid caching of store switcher responses being cached","message":"Minor cleanup and add code to avoid caching of store switcher responses\nbeing cached\n","repos":"fastly\/fastly-magento,fastly\/fastly-magento,fastly\/fastly-magento,fastly\/fastly-magento","old_file":"app\/code\/community\/Fastly\/CDN\/etc\/default.vcl","new_file":"app\/code\/community\/Fastly\/CDN\/etc\/default.vcl","new_contents":"###############################################################################\n#\n# Fastly CDN for Magento\n#\n# NOTICE OF LICENSE\n#\n# This source file is subject to the Fastly CDN for Magento End User License\n# Agreement that is bundled with this package in the file LICENSE_FASTLY_CDN.txt.\n#\n# @copyright Copyright (c) 2015 Fastly, Inc. (http:\/\/www.fastly.com)\n# @license BSD, see LICENSE_FASTLY_CDN.txt\n#\n###############################################################################\n\n# This is a basic VCL configuration file for fastly CDN for Magento module.\n\nsub vcl_recv {\n#FASTLY recv\n # we only deal with GET and HEAD by default\n if (req.request != \"GET\" && req.request != \"HEAD\" && req.request != \"FASTLYPURGE\") {\n return (pass);\n }\n\n # Sort the query arguments\n set req.url = boltsort.sort(req.url);\n\n # bypass language switcher\n if (req.url ~ \"(?i)___from_store=.*&___store=.*\") {\n set req.http.X-Pass = \"1\";\n return(pass);\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n set req.http.X-Sig = regsub(req.http.X-Purge-Token, \"^[^_]+_(.*)\", \"\\1\");\n set req.http.X-Exp = regsub(req.http.X-Purge-Token, \"^([^_]+)_.*\", \"\\1\");\n\n # validate signature\n if (req.http.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path req.http.X-Exp), \"^0x\", \"\")) {\n\n # use vcl time math to check expiration timestamp\n set req.http.X-Original-Grace = req.grace;\n set req.grace = std.atoi(strftime({\"%s\"}, now));\n set req.grace -= std.atoi(req.http.X-Exp);\n\n if (std.atoi(req.grace) > 0) {\n error 410;\n }\n\n # clean up grace since we used it for time math\n set req.grace = std.atoi(req.http.X-Original-Grace);\n unset req.http.X-Original-Grace;\n\n } else {\n error 403;\n }\n\n # cleanup variables\n unset req.http.X-Purge-Token;\n unset req.http.X-Sig;\n unset req.http.X-Exp;\n }\n\n # disable ESI processing on Origin Shield\n if (req.http.Fastly-FF) {\n set req.esi = false;\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(media|js|skin)\/.*\\.(png|jpg|jpeg|gif|css|js|swf|ico)$\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n # formkey lookup\n if (req.url ~ \"\/fastlycdn\/getformkey\/\") {\n # check if we have a formkey cookie\n if (req.http.Cookie:FASTLY_CDN_FORMKEY) {\n set req.http.Formkey = req.http.Cookie:FASTLY_CDN_FORMKEY;\n } else {\n # create formkey\n set req.http.seed = req.http.Cookie client.ip remote.port geoip.longitude geoip.latitude geoip.postal_code;\n set req.http.Formkey = regsub(digest.hash_md5(req.http.seed), \"^0x\", \"\");\n }\n error 760 req.http.Formkey;\n }\n\n # geoip lookup\n if (req.url ~ \"fastlycdn\/esi\/getcountry\/\") {\n # check if GeoIP has been already processed by client\n if (req.http.Cookie:FASTLY_CDN_GEOIP_PROCESSED) {\n error 200 \"\";\n } else {\n # modify req.url and restart request processing\n error 750 geoip.country_code;\n }\n }\n\n # geoip get country code\n if (req.url ~ \"fastlycdn\/esi\/getcountrycode\/\") {\n # create and set req.http.X-Country-Code\n error 755 geoip.country_code;\n }\n\n # check for ESI calls\n if (req.url ~ \"esi_data=\") {\n # check for valid cookie data\n if (req.http.Cookie ~ \"FASTLY_CDN-\") {\n # get the cookie name to look for\n set req.http.fastlyCDNEsiCookieName = regsub(\n req.url,\n \"(.*)esi_data=([^&]*)(.*)\",\n \"\\2\"\n );\n\n # get the cookie value for the cookie name\n # tmp string is NAMESPACE-COOKIENAME@@@@@COMPLETE_COOKIE\n # left of @@@@@ is back-referenced in regex to extract value from cookie\n set req.http.fastlyTmp = \"FASTLY_CDN-\" req.http.fastlyCDNEsiCookieName \"@@@@@\" req.http.Cookie;\n set req.http.fastlyCDNRequest = regsub(\n req.http.fastlyTmp,\n \"^([A-Za-z0-9-_]+)@@@@@.*\\1=([^;]*)\",\n \"\\2\"\n );\n\n # do we have a value for the cookie name?\n if (!req.http.fastlyCDNRequest) {\n set req.http.fastlyCDNRequest = \"default\";\n }\n\n # build backend url\n set req.url = regsub(\n req.url,\n \"(.*)esi_data=([^&]*)[&]?(.*)\",\n \"\\1\\3\"\n )\n \"&esi_data=\"\n req.http.fastlyCDNRequest;\n\n # clean up temp variables\n remove req.http.fastlyCDNEsiCookieName;\n remove req.http.fastlyCDNRequest;\n\n return (lookup);\n }\n }\n\n return(lookup);\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n\nsub vcl_hash {\n set req.hash += req.http.Https;\n set req.hash += req.http.host;\n set req.hash += req.url;\n\n if (req.http.cookie:FASTLY_CDN_ENV) {\n set req.hash += req.http.cookie:FASTLY_CDN_ENV;\n }\n\n set req.hash += \"#####GENERATION#####\";\n\n if (!(req.url ~ \"^\/(media|js|skin)\/.*\\.(png|jpg|jpeg|gif|css|js|swf|ico)$\")) {\n call design_exception;\n }\n return (hash);\n}\n\nsub vcl_hit {\n#FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\nsub vcl_miss {\n # Deactivate gzip on origin\n unset bereq.http.Accept-Encoding;\n\n#FASTLY miss\n\n return(fetch);\n}\n\nsub vcl_fetch {\n#FASTLY fetch\n\n if (beresp.status >= 500) {\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n }\n\n if (req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Content-Type ~ \"text\/html\" || beresp.http.Content-Type ~ \"text\/xml\") {\n # enable ESI feature for Magento response by default\n esi;\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content\n if ((beresp.status == 200 || beresp.status == 404) && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url ~ \"\\.(css|js|html|eot|ico|otf|ttf|json)($|\\?)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.status == 500 || beresp.status == 503) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n if (http_status_matches(beresp.status, \"200,301,404\") && !req.http.X-Pass) {\n if (beresp.http.Content-Type ~ \"text\/html\" || beresp.http.Content-Type ~ \"text\/xml\") {\n # marker for vcl_deliver to reset Age:\n set beresp.http.magentomarker = \"1\";\n\n # Don't cache cookies\n unset beresp.http.set-cookie;\n } else {\n if (beresp.http.Expires || beresp.http.Surrogate-Control ~ \"max-age\" || beresp.http.Cache-Control ~ \"(s-maxage|max-age)\") {\n # keep the ttl here\n } else {\n # apply the default ttl\n set beresp.ttl = 3600s;\n }\n }\n\n # init surrogate keys\n if (beresp.http.Surrogate-Key) {\n set beresp.http.Surrogate-Key = beresp.http.Surrogate-Key \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type\n if (beresp.http.Content-Type ~ \"image\") {\n set beresp.http.Surrogate-Key = \"image\";\n } elsif (beresp.http.Content-Type ~ \"script\") {\n set beresp.http.Surrogate-Key = \"script\";\n } elsif (beresp.http.Content-Type ~ \"css\") {\n set beresp.http.Surrogate-Key = \"css\";\n }\n\n set beresp.http.X-Surrogate-Key = beresp.http.Surrogate-Key;\n }\n\n return (deliver);\n}\n\nsub vcl_deliver {\n # debug info\n if (resp.http.X-Cache-Debug) {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n set resp.http.X-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n set resp.http.X-Cache-Expires = resp.http.Expires;\n } else {\n # remove Varnish\/proxy header\n remove resp.http.X-Varnish;\n remove resp.http.Via;\n remove resp.http.Age;\n remove resp.http.X-Purge-URL;\n remove resp.http.X-Purge-Host;\n remove resp.http.X-Surrogate-Key;\n }\n\n if (resp.http.magentomarker) {\n # Remove the magic marker\n unset resp.http.magentomarker;\n\n set resp.http.Cache-Control = \"no-store, no-cache, must-revalidate, post-check=0, pre-check=0\";\n set resp.http.Pragma = \"no-cache\";\n set resp.http.Expires = \"Mon, 31 Mar 2008 10:00:00 GMT\";\n set resp.http.Age = \"0\";\n }\n\n#FASTLY deliver\n\n return (deliver);\n}\n\nsub vcl_error {\n # workaround for possible security issue\n if (req.url ~ \"^\\s\") {\n set obj.status = 400;\n set obj.response = \"Malformed request\";\n synthetic \"\";\n return (deliver);\n }\n\n # geo ip request\n if (obj.status == 750) {\n set req.url = regsub(req.url, \"(\/fastlycdn\/esi\/getcountry\/.*)\", \"\/fastlycdn\/esi\/getcountryaction\/?country_code=\") obj.response;\n return (restart);\n }\n\n # geo ip country code\n if (obj.status == 755) {\n set obj.status = 200;\n\t synthetic obj.response;\n return(deliver);\n }\n\n # formkey request\n if (obj.status == 760) {\n set obj.status = 200;\n\t synthetic obj.response;\n return (deliver);\n }\n\n # error 200\n if (obj.status == 200) {\n return (deliver);\n }\n\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} obj.status \" \" obj.response {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} obj.status \" \" obj.response {\"<\/h1>\n <p>\"} obj.response {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} req.xid {\"<\/p>\n <hr>\n <p>Fastly CDN server<\/p>\n <\/body>\n<\/html>\n\"};\n\n#FASTLY error\n}\n\nsub design_exception {\n}\n","old_contents":"###############################################################################\n#\n# Fastly CDN for Magento\n#\n# NOTICE OF LICENSE\n#\n# This source file is subject to the Fastly CDN for Magento End User License\n# Agreement that is bundled with this package in the file LICENSE_FASTLY_CDN.txt.\n#\n# @copyright Copyright (c) 2015 Fastly, Inc. (http:\/\/www.fastly.com)\n# @license BSD, see LICENSE_FASTLY_CDN.txt\n#\n###############################################################################\n\n# This is a basic VCL configuration file for fastly CDN for Magento module.\n\nsub vcl_recv {\n#FASTLY recv\n # we only deal with GET and HEAD by default\n if (req.request != \"GET\" && req.request != \"HEAD\" && req.request != \"FASTLYPURGE\") {\n return (pass);\n }\n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n set req.http.X-Sig = regsub(req.http.X-Purge-Token, \"^[^_]+_(.*)\", \"\\1\");\n set req.http.X-Exp = regsub(req.http.X-Purge-Token, \"^([^_]+)_.*\", \"\\1\");\n\n # validate signature\n if (req.http.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path req.http.X-Exp), \"^0x\", \"\")) {\n\n # use vcl time math to check expiration timestamp\n set req.http.X-Original-Grace = req.grace;\n set req.grace = std.atoi(strftime({\"%s\"}, now));\n set req.grace -= std.atoi(req.http.X-Exp);\n\n if (std.atoi(req.grace) > 0) {\n error 410;\n }\n\n # clean up grace since we used it for time math\n set req.grace = std.atoi(req.http.X-Original-Grace);\n unset req.http.X-Original-Grace;\n\n } else {\n error 403;\n }\n\n # cleanup variables\n unset req.http.X-Purge-Token;\n unset req.http.X-Sig;\n unset req.http.X-Exp;\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n # disable ESI processing on Origin Shield\n if (req.http.Fastly-FF) {\n set req.esi = false;\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(media|js|skin)\/.*\\.(png|jpg|jpeg|gif|css|js|swf|ico)$\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n # formkey lookup\n if (req.url ~ \"\/fastlycdn\/getformkey\/\") {\n # check if we have a formkey cookie\n if (req.http.Cookie:FASTLY_CDN_FORMKEY) {\n set req.http.Formkey = req.http.Cookie:FASTLY_CDN_FORMKEY;\n } else {\n # create formkey\n set req.http.seed = req.http.Cookie client.ip remote.port geoip.longitude geoip.latitude geoip.postal_code;\n set req.http.Formkey = regsub(digest.hash_md5(req.http.seed), \"^0x\", \"\");\n }\n error 760 req.http.Formkey;\n }\n\n # geoip lookup\n if (req.url ~ \"fastlycdn\/esi\/getcountry\/\") {\n # check if GeoIP has been already processed by client\n if (req.http.Cookie:FASTLY_CDN_GEOIP_PROCESSED) {\n error 200 \"\";\n } else {\n # modify req.url and restart request processing\n error 750 geoip.country_code;\n }\n }\n\n # geoip get country code\n if (req.url ~ \"fastlycdn\/esi\/getcountrycode\/\") {\n # create and set req.http.X-Country-Code\n error 755 geoip.country_code;\n }\n\n # check for ESI calls\n if (req.url ~ \"esi_data=\") {\n # check for valid cookie data\n if (req.http.Cookie ~ \"FASTLY_CDN-\") {\n # get the cookie name to look for\n set req.http.fastlyCDNEsiCookieName = regsub(\n req.url,\n \"(.*)esi_data=([^&]*)(.*)\",\n \"\\2\"\n );\n\n # get the cookie value for the cookie name\n # tmp string is NAMESPACE-COOKIENAME@@@@@COMPLETE_COOKIE\n # left of @@@@@ is back-referenced in regex to extract value from cookie\n set req.http.fastlyTmp = \"FASTLY_CDN-\" req.http.fastlyCDNEsiCookieName \"@@@@@\" req.http.Cookie;\n set req.http.fastlyCDNRequest = regsub(\n req.http.fastlyTmp,\n \"^([A-Za-z0-9-_]+)@@@@@.*\\1=([^;]*)\",\n \"\\2\"\n );\n\n # do we have a value for the cookie name?\n if (!req.http.fastlyCDNRequest) {\n set req.http.fastlyCDNRequest = \"default\";\n }\n\n # build backend url\n set req.url = regsub(\n req.url,\n \"(.*)esi_data=([^&]*)[&]?(.*)\",\n \"\\1\\3\"\n )\n \"&esi_data=\"\n req.http.fastlyCDNRequest;\n\n # clean up temp variables\n remove req.http.fastlyCDNEsiCookieName;\n remove req.http.fastlyCDNRequest;\n\n return (lookup);\n }\n }\n\n return(lookup);\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n\nsub vcl_hash {\n set req.hash += req.http.Https;\n set req.hash += req.http.host;\n set req.hash += req.url;\n\n if (req.http.cookie:FASTLY_CDN_ENV) {\n set req.hash += req.http.cookie:FASTLY_CDN_ENV;\n }\n\n set req.hash += \"#####GENERATION#####\";\n\n if (!(req.url ~ \"^\/(media|js|skin)\/.*\\.(png|jpg|jpeg|gif|css|js|swf|ico)$\")) {\n call design_exception;\n }\n return (hash);\n}\n\nsub vcl_hit {\n#FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\nsub vcl_miss {\n # Deactivate gzip on origin\n unset bereq.http.Accept-Encoding;\n\n#FASTLY miss\n\n return(fetch);\n}\n\nsub vcl_fetch {\n#FASTLY fetch\n\n if (beresp.status >= 500) {\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n }\n\n if (req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Content-Type ~ \"text\/html\" || beresp.http.Content-Type ~ \"text\/xml\") {\n # enable ESI feature for Magento response by default\n esi;\n } else {\n # enable gzip for all static content\n if ((beresp.status == 200 || beresp.status == 404) && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url ~ \"\\.(css|js|html|eot|ico|otf|ttf|json)($|\\?)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.status == 500 || beresp.status == 503) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n if (beresp.status == 200 || beresp.status == 301 || beresp.status == 404) {\n if (beresp.http.Content-Type ~ \"text\/html\" || beresp.http.Content-Type ~ \"text\/xml\") {\n # marker for vcl_deliver to reset Age:\n set beresp.http.magentomarker = \"1\";\n\n # Don't cache cookies\n unset beresp.http.set-cookie;\n } else {\n if (beresp.http.Expires || beresp.http.Surrogate-Control ~ \"max-age\" || beresp.http.Cache-Control ~ \"(s-maxage|max-age)\") {\n # keep the ttl here\n } else {\n # apply the default ttl\n set beresp.ttl = 3600s;\n }\n }\n\n # init surrogate keys\n if (beresp.http.Surrogate-Key) {\n set beresp.http.Surrogate-Key = beresp.http.Surrogate-Key \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type\n if (beresp.http.Content-Type ~ \"image\") {\n set beresp.http.Surrogate-Key = \"image\";\n } elsif (beresp.http.Content-Type ~ \"script\") {\n set beresp.http.Surrogate-Key = \"script\";\n } elsif (beresp.http.Content-Type ~ \"css\") {\n set beresp.http.Surrogate-Key = \"css\";\n }\n\n set beresp.http.X-Surrogate-Key = beresp.http.Surrogate-Key;\n }\n\n return (deliver);\n}\n\nsub vcl_deliver {\n # debug info\n if (resp.http.X-Cache-Debug) {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n set resp.http.X-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n set resp.http.X-Cache-Expires = resp.http.Expires;\n } else {\n # remove Varnish\/proxy header\n remove resp.http.X-Varnish;\n remove resp.http.Via;\n remove resp.http.Age;\n remove resp.http.X-Purge-URL;\n remove resp.http.X-Purge-Host;\n remove resp.http.X-Surrogate-Key;\n }\n\n if (resp.http.magentomarker) {\n # Remove the magic marker\n unset resp.http.magentomarker;\n\n set resp.http.Cache-Control = \"no-store, no-cache, must-revalidate, post-check=0, pre-check=0\";\n set resp.http.Pragma = \"no-cache\";\n set resp.http.Expires = \"Mon, 31 Mar 2008 10:00:00 GMT\";\n set resp.http.Age = \"0\";\n }\n\n#FASTLY deliver\n\n return (deliver);\n}\n\nsub vcl_error {\n # workaround for possible security issue\n if (req.url ~ \"^\\s\") {\n set obj.status = 400;\n set obj.response = \"Malformed request\";\n synthetic \"\";\n return (deliver);\n }\n\n # geo ip request\n if (obj.status == 750) {\n set req.url = regsub(req.url, \"(\/fastlycdn\/esi\/getcountry\/.*)\", \"\/fastlycdn\/esi\/getcountryaction\/?country_code=\") obj.response;\n return (restart);\n }\n\n # geo ip country code\n if (obj.status == 755) {\n set obj.status = 200;\n\t synthetic obj.response;\n return(deliver);\n }\n\n # formkey request\n if (obj.status == 760) {\n set obj.status = 200;\n\t synthetic obj.response;\n return (deliver);\n }\n\n # error 200\n if (obj.status == 200) {\n return (deliver);\n }\n\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} obj.status \" \" obj.response {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} obj.status \" \" obj.response {\"<\/h1>\n <p>\"} obj.response {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} req.xid {\"<\/p>\n <hr>\n <p>Fastly CDN server<\/p>\n <\/body>\n<\/html>\n\"};\n\n#FASTLY error\n}\n\nsub design_exception {\n}\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"54a0a501699dfb21060c3c3f422ecafc0cbaef0e","subject":"Allow purging","message":"Allow purging\n","repos":"JakeChampion\/polyfill-service,JakeChampion\/polyfill-service","old_file":"fastly\/vcl\/polyfill-service.vcl","new_file":"fastly\/vcl\/polyfill-service.vcl","new_contents":"sub set_backend {\n\t# Calculate the ideal region to route the request to.\n\tdeclare local var.region STRING;\n\tif (server.region ~ \"(APAC|Asia|North-America|South-America|US-Central|US-East|US-West)\") {\n\t\tset var.region = \"US\";\n\t} else {\n\t\tset var.region = \"EU\";\n\t}\n\n\t# Gather the health of the shields and origins.\n\tdeclare local var.v3_eu_is_healthy BOOL;\n\tset req.backend = F_v3_eu;\n\tset var.v3_eu_is_healthy = req.backend.healthy;\n\n\tdeclare local var.v3_us_is_healthy BOOL;\n\tset req.backend = F_v3_us;\n\tset var.v3_us_is_healthy = req.backend.healthy;\n\n\t# Set some sort of default, that shouldn't get used.\n\tset req.backend = F_v3_eu;\n\n\t# Route EU requests to the nearest healthy shield or origin.\n\tif (var.region == \"EU\") {\n\t\tif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_eu;\n\t\t}\n\t}\n\n\t# Route US requests to the nearest healthy shield or origin.\n\tif (var.region == \"US\") {\n\t\tif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_us;\n\t\t}\n\t}\n\n\t# Persist the decision so we can debug the result.\n\tset req.http.Debug-Backend = req.backend;\n\n\t# The Fastly macro is inserted after the backend is selected because the\n\t# macro has the code to select the correct req.http.Host value based on the backend.\n\t#FASTLY recv\n}\n\nsub vcl_recv {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_recv;\n\t}\n\n\tif (req.method != \"GET\" && req.method != \"HEAD\" && req.method != \"OPTIONS\" && req.method != \"FASTLYPURGE\" && req.method != \"PURGE\") {\n\t\terror 911;\n\t}\n\n\tif (req.method == \"OPTIONS\") {\n\t\terror 912;\n\t}\n\n\t# Override the v3 defaults with the defaults of v2\n\tif (req.url ~ \"^\/v2\/polyfill(\\.min)?\\.js\") {\n\t\tset req.url = regsub(req.url, \"^\/v2\", \"\/v3\");\n\t\tset req.url = querystring.set(req.url, \"version\", \"3.25.1\");\n\t\tdeclare local var.unknown STRING;\n\t\tset var.unknown = subfield(req.url.qs, \"unknown\", \"&\");\n\t\tset req.url = querystring.set(req.url, \"unknown\", if(var.unknown != \"\", var.unknown, \"ignore\"));\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\") {\n\t\tcall normalise_querystring_parameters_for_polyfill_bundle;\n\t}\n\n\t# Sort the querystring parameters alphabetically to improve chances of hitting a cached copy.\n\t# If querystring is empty, remove the ? from the url.\n\tset req.url = querystring.clean(querystring.sort(req.url));\n\tcall set_backend;\n}\n\nsub vcl_hash {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_hash;\n\t}\n\n\t# We are not adding req.http.host to the hash because we want https:\/\/cdn.polyfill.io and https:\/\/polyfill.io to be a single object in the cache.\n\t# set req.hash += req.http.host;\n\tset req.hash += req.url;\n\t# We include return(hash) to stop the function falling through to the default VCL built into varnish, which for vcl_hash will add req.url and req.http.Host to the hash.\n\treturn(hash);\n}\n\nsub vcl_miss {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_miss;\n\t}\n}\n\nsub vcl_pass {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_pass;\n\t}\n}\n\nsub vcl_fetch {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_fetch;\n\t}\n\n\t# These header are only required for HTML documents.\n\tif (beresp.http.Content-Type ~ \"text\/html\") {\n\t\t# Enables the cross-site scripting filter built into most modern web browsers.\n\t\tset beresp.http.X-XSS-Protection = \"1; mode=block\";\t\n\n\t\t# Allow only content from the site's own origin (this excludes subdomains) and www.ft.com.\n\t\t# Don't allow the website to be used within an iframe\n\t\tif (!beresp.http.Content-Security-Policy) {\n\t\t\tset beresp.http.Content-Security-Policy = \"default-src 'self'; font-src 'self' https:\/\/www.ft.com; img-src 'self' https:\/\/www.ft.com; frame-ancestors 'none'; base-uri 'self'; form-action 'self'\";\n\t\t}\n\t}\n\t# Prevents MIME-sniffing a response away from the declared content type.\n\tset beresp.http.X-Content-Type-Options = \"nosniff\";\n\n\t# Ensure the site is only served over HTTPS and reduce the chances of someone performing a MITM attack.\n\tset beresp.http.Strict-Transport-Security = \"max-age=31536000; includeSubdomains; preload\";\n\n\t# The Referrer-Policy header governs which referrer information, sent in the Referer header, should be included with requests made.\n\t# Send a full URL when performing a same-origin request, but only send the origin of the document for other cases.\n\tset beresp.http.Referrer-Policy = \"origin-when-cross-origin\";\n\n\t# Enable purging of all objects in the Fastly cache by issuing a purge with the key \"polyfill-service\".\n\tif (beresp.http.Surrogate-Key !~ \"\\bpolyfill-service\\b\") {\n\t\tset beresp.http.Surrogate-Key = if(beresp.http.Surrogate-Key, beresp.http.Surrogate-Key \" polyfill-service\", \"polyfill-service\");\n\t}\n\n\tset beresp.http.Timing-Allow-Origin = \"*\";\n\n\tif (req.http.Normalized-User-Agent) {\n\t\tset beresp.http.Normalized-User-Agent = req.http.Normalized-User-Agent;\n\t\tset beresp.http.Detected-User-Agent = req.http.useragent_parser_family \"\/\" req.http.useragent_parser_major \".\" req.http.useragent_parser_minor \".\" req.http.useragent_parser_patch;\n\t}\n}\n\nsub vcl_deliver {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_deliver;\n\t}\n\n\tset req.http.Fastly-Force-Shield = \"yes\";\n\n\t# Allow cross origin GET, HEAD, and OPTIONS requests to be made.\n\tif (req.http.Origin) {\n\t\tset resp.http.Access-Control-Allow-Origin = \"*\";\n\t\tset resp.http.Access-Control-Allow-Methods = \"GET,HEAD,OPTIONS\";\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\") {\n\t\t# Need to add \"Vary: User-Agent\" in after vcl_fetch to avoid the \n\t\t# \"Vary: User-Agent\" entering the Varnish cache.\n\t\t# We need \"Vary: User-Agent\" in the browser cache because a browser\n\t\t# may update itself to a version which needs different polyfills\n\t\t# So we need to have it ignore the browser cached bundle when the user-agent changes.\n\t\tadd resp.http.Vary = \"User-Agent\";\n\t\tadd resp.http.Vary = \"Accept-Encoding\";\n\t}\n\n\tadd resp.http.Server-Timing = fastly_info.state {\", fastly;desc=\"Edge time\";dur=\"} time.elapsed.msec;\n\n\tif (req.http.Fastly-Debug) {\n\t\tset resp.http.Debug-Backend = req.http.Debug-Backend;\n\t\tset resp.http.Debug-Host = req.http.Host;\n\t\tset resp.http.Debug-Fastly-Restarts = req.restarts;\n\t\tset resp.http.Debug-Orig-URL = req.http.Orig-URL;\n\t\tset resp.http.Debug-VCL-Route = req.http.X-VCL-Route;\n\t\tset resp.http.useragent_parser_family = req.http.useragent_parser_family;\n\t\tset resp.http.useragent_parser_major = req.http.useragent_parser_major;\n\t\tset resp.http.useragent_parser_minor = req.http.useragent_parser_minor;\n\t\tset resp.http.useragent_parser_patch = req.http.useragent_parser_patch;\n\t} else {\n\t\tunset resp.http.Server;\n\t\tunset resp.http.Via;\n\t\tunset resp.http.X-Cache;\n\t\tunset resp.http.X-Cache-Hits;\n\t\tunset resp.http.X-Served-By;\n\t\tunset resp.http.X-Timer;\n\t\tunset resp.http.Fastly-Restarts;\n\t}\n}\n\nsub vcl_error {\n\tif (obj.status == 911) {\n\t\tset obj.status = 405;\n\t\tset obj.response = \"METHOD NOT ALLOWED\";\n\t\tset obj.http.Content-Type = \"text\/html; charset=utf-8\";\n\t\tset obj.http.Cache-Control = \"private, no-store\";\n\t\tsynthetic req.method \" METHOD NOT ALLOWED\";\n\t\treturn (deliver);\n\t}\n\tif (obj.status == 912) {\n\t\tset obj.status = 200;\n\t\tset obj.response = \"OK\";\n\t\tset obj.http.Allow = \"OPTIONS, GET, HEAD\";\n\t\treturn (deliver);\n\t}\n}\n","old_contents":"sub set_backend {\n\t# Calculate the ideal region to route the request to.\n\tdeclare local var.region STRING;\n\tif (server.region ~ \"(APAC|Asia|North-America|South-America|US-Central|US-East|US-West)\") {\n\t\tset var.region = \"US\";\n\t} else {\n\t\tset var.region = \"EU\";\n\t}\n\n\t# Gather the health of the shields and origins.\n\tdeclare local var.v3_eu_is_healthy BOOL;\n\tset req.backend = F_v3_eu;\n\tset var.v3_eu_is_healthy = req.backend.healthy;\n\n\tdeclare local var.v3_us_is_healthy BOOL;\n\tset req.backend = F_v3_us;\n\tset var.v3_us_is_healthy = req.backend.healthy;\n\n\t# Set some sort of default, that shouldn't get used.\n\tset req.backend = F_v3_eu;\n\n\t# Route EU requests to the nearest healthy shield or origin.\n\tif (var.region == \"EU\") {\n\t\tif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_eu;\n\t\t}\n\t}\n\n\t# Route US requests to the nearest healthy shield or origin.\n\tif (var.region == \"US\") {\n\t\tif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_us;\n\t\t}\n\t}\n\n\t# Persist the decision so we can debug the result.\n\tset req.http.Debug-Backend = req.backend;\n\n\t# The Fastly macro is inserted after the backend is selected because the\n\t# macro has the code to select the correct req.http.Host value based on the backend.\n\t#FASTLY recv\n}\n\nsub vcl_recv {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_recv;\n\t}\n\n\tif (req.method != \"GET\" && req.method != \"HEAD\" && req.method != \"OPTIONS\") {\n\t\terror 911;\n\t}\n\n\tif (req.method == \"OPTIONS\") {\n\t\terror 912;\n\t}\n\n\t# Override the v3 defaults with the defaults of v2\n\tif (req.url ~ \"^\/v2\/polyfill(\\.min)?\\.js\") {\n\t\tset req.url = regsub(req.url, \"^\/v2\", \"\/v3\");\n\t\tset req.url = querystring.set(req.url, \"version\", \"3.25.1\");\n\t\tdeclare local var.unknown STRING;\n\t\tset var.unknown = subfield(req.url.qs, \"unknown\", \"&\");\n\t\tset req.url = querystring.set(req.url, \"unknown\", if(var.unknown != \"\", var.unknown, \"ignore\"));\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\") {\n\t\tcall normalise_querystring_parameters_for_polyfill_bundle;\n\t}\n\n\t# Sort the querystring parameters alphabetically to improve chances of hitting a cached copy.\n\t# If querystring is empty, remove the ? from the url.\n\tset req.url = querystring.clean(querystring.sort(req.url));\n\tcall set_backend;\n}\n\nsub vcl_hash {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_hash;\n\t}\n\n\t# We are not adding req.http.host to the hash because we want https:\/\/cdn.polyfill.io and https:\/\/polyfill.io to be a single object in the cache.\n\t# set req.hash += req.http.host;\n\tset req.hash += req.url;\n\t# We include return(hash) to stop the function falling through to the default VCL built into varnish, which for vcl_hash will add req.url and req.http.Host to the hash.\n\treturn(hash);\n}\n\nsub vcl_miss {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_miss;\n\t}\n}\n\nsub vcl_pass {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_pass;\n\t}\n}\n\nsub vcl_fetch {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_fetch;\n\t}\n\n\t# These header are only required for HTML documents.\n\tif (beresp.http.Content-Type ~ \"text\/html\") {\n\t\t# Enables the cross-site scripting filter built into most modern web browsers.\n\t\tset beresp.http.X-XSS-Protection = \"1; mode=block\";\t\n\n\t\t# Allow only content from the site's own origin (this excludes subdomains) and www.ft.com.\n\t\t# Don't allow the website to be used within an iframe\n\t\tif (!beresp.http.Content-Security-Policy) {\n\t\t\tset beresp.http.Content-Security-Policy = \"default-src 'self'; font-src 'self' https:\/\/www.ft.com; img-src 'self' https:\/\/www.ft.com; frame-ancestors 'none'; base-uri 'self'; form-action 'self'\";\n\t\t}\n\t}\n\t# Prevents MIME-sniffing a response away from the declared content type.\n\tset beresp.http.X-Content-Type-Options = \"nosniff\";\n\n\t# Ensure the site is only served over HTTPS and reduce the chances of someone performing a MITM attack.\n\tset beresp.http.Strict-Transport-Security = \"max-age=31536000; includeSubdomains; preload\";\n\n\t# The Referrer-Policy header governs which referrer information, sent in the Referer header, should be included with requests made.\n\t# Send a full URL when performing a same-origin request, but only send the origin of the document for other cases.\n\tset beresp.http.Referrer-Policy = \"origin-when-cross-origin\";\n\n\t# Enable purging of all objects in the Fastly cache by issuing a purge with the key \"polyfill-service\".\n\tif (beresp.http.Surrogate-Key !~ \"\\bpolyfill-service\\b\") {\n\t\tset beresp.http.Surrogate-Key = if(beresp.http.Surrogate-Key, beresp.http.Surrogate-Key \" polyfill-service\", \"polyfill-service\");\n\t}\n\n\tset beresp.http.Timing-Allow-Origin = \"*\";\n\n\tif (req.http.Normalized-User-Agent) {\n\t\tset beresp.http.Normalized-User-Agent = req.http.Normalized-User-Agent;\n\t\tset beresp.http.Detected-User-Agent = req.http.useragent_parser_family \"\/\" req.http.useragent_parser_major \".\" req.http.useragent_parser_minor \".\" req.http.useragent_parser_patch;\n\t}\n}\n\nsub vcl_deliver {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_deliver;\n\t}\n\n\tset req.http.Fastly-Force-Shield = \"yes\";\n\n\t# Allow cross origin GET, HEAD, and OPTIONS requests to be made.\n\tif (req.http.Origin) {\n\t\tset resp.http.Access-Control-Allow-Origin = \"*\";\n\t\tset resp.http.Access-Control-Allow-Methods = \"GET,HEAD,OPTIONS\";\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\") {\n\t\t# Need to add \"Vary: User-Agent\" in after vcl_fetch to avoid the \n\t\t# \"Vary: User-Agent\" entering the Varnish cache.\n\t\t# We need \"Vary: User-Agent\" in the browser cache because a browser\n\t\t# may update itself to a version which needs different polyfills\n\t\t# So we need to have it ignore the browser cached bundle when the user-agent changes.\n\t\tadd resp.http.Vary = \"User-Agent\";\n\t\tadd resp.http.Vary = \"Accept-Encoding\";\n\t}\n\n\tadd resp.http.Server-Timing = fastly_info.state {\", fastly;desc=\"Edge time\";dur=\"} time.elapsed.msec;\n\n\tif (req.http.Fastly-Debug) {\n\t\tset resp.http.Debug-Backend = req.http.Debug-Backend;\n\t\tset resp.http.Debug-Host = req.http.Host;\n\t\tset resp.http.Debug-Fastly-Restarts = req.restarts;\n\t\tset resp.http.Debug-Orig-URL = req.http.Orig-URL;\n\t\tset resp.http.Debug-VCL-Route = req.http.X-VCL-Route;\n\t\tset resp.http.useragent_parser_family = req.http.useragent_parser_family;\n\t\tset resp.http.useragent_parser_major = req.http.useragent_parser_major;\n\t\tset resp.http.useragent_parser_minor = req.http.useragent_parser_minor;\n\t\tset resp.http.useragent_parser_patch = req.http.useragent_parser_patch;\n\t} else {\n\t\tunset resp.http.Server;\n\t\tunset resp.http.Via;\n\t\tunset resp.http.X-Cache;\n\t\tunset resp.http.X-Cache-Hits;\n\t\tunset resp.http.X-Served-By;\n\t\tunset resp.http.X-Timer;\n\t\tunset resp.http.Fastly-Restarts;\n\t}\n}\n\nsub vcl_error {\n\tif (obj.status == 911) {\n\t\tset obj.status = 405;\n\t\tset obj.response = \"METHOD NOT ALLOWED\";\n\t\tset obj.http.Content-Type = \"text\/html; charset=utf-8\";\n\t\tset obj.http.Cache-Control = \"private, no-store\";\n\t\tsynthetic req.method \" METHOD NOT ALLOWED\";\n\t\treturn (deliver);\n\t}\n\tif (obj.status == 912) {\n\t\tset obj.status = 200;\n\t\tset obj.response = \"OK\";\n\t\tset obj.http.Allow = \"OPTIONS, GET, HEAD\";\n\t\treturn (deliver);\n\t}\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"bba6b7b58503f795f02cc4046a185645f8a89785","subject":"Changing varnish default backend","message":"Changing varnish default backend\n","repos":"shawnsi\/varnish-ring,shawnsi\/varnish-ring,shawnsi\/varnish-ring","old_file":"roles\/varnish\/files\/default.vcl","new_file":"roles\/varnish\/files\/default.vcl","new_contents":"# This is a basic VCL configuration file for varnish. See the vcl(7)\n# man page for details on VCL syntax and semantics.\n# \n# Default backend definition. Set this to point to your content\n# server.\n# \nbackend default {\n .host = \"127.0.0.1\";\n .port = \"9090\";\n}\n# \n# Below is a commented-out copy of the default VCL logic. If you\n# redefine any of these subroutines, the built-in logic will be\n# appended to your code.\n# sub vcl_recv {\n# if (req.restarts == 0) {\n# \tif (req.http.x-forwarded-for) {\n# \t set req.http.X-Forwarded-For =\n# \t\treq.http.X-Forwarded-For + \", \" + client.ip;\n# \t} else {\n# \t set req.http.X-Forwarded-For = client.ip;\n# \t}\n# }\n# if (req.request != \"GET\" &&\n# req.request != \"HEAD\" &&\n# req.request != \"PUT\" &&\n# req.request != \"POST\" &&\n# req.request != \"TRACE\" &&\n# req.request != \"OPTIONS\" &&\n# req.request != \"DELETE\") {\n# \/* Non-RFC2616 or CONNECT which is weird. *\/\n# return (pipe);\n# }\n# if (req.request != \"GET\" && req.request != \"HEAD\") {\n# \/* We only deal with GET and HEAD by default *\/\n# return (pass);\n# }\n# if (req.http.Authorization || req.http.Cookie) {\n# \/* Not cacheable by default *\/\n# return (pass);\n# }\n# return (lookup);\n# }\n# \n# sub vcl_pipe {\n# # Note that only the first request to the backend will have\n# # X-Forwarded-For set. If you use X-Forwarded-For and want to\n# # have it set for all requests, make sure to have:\n# # set bereq.http.connection = \"close\";\n# # here. It is not set by default as it might break some broken web\n# # applications, like IIS with NTLM authentication.\n# return (pipe);\n# }\n# \n# sub vcl_pass {\n# return (pass);\n# }\n# \n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (hash);\n# }\n# \n# sub vcl_hit {\n# return (deliver);\n# }\n# \n# sub vcl_miss {\n# return (fetch);\n# }\n# \n# sub vcl_fetch {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Vary == \"*\") {\n# \t\t\/*\n# \t\t * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# \t\t *\/\n# \t\tset beresp.ttl = 120 s;\n# \t\treturn (hit_for_pass);\n# }\n# return (deliver);\n# }\n# \n# sub vcl_deliver {\n# return (deliver);\n# }\n# \n# sub vcl_error {\n# set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n# set obj.http.Retry-After = \"5\";\n# synthetic {\"\n# <?xml version=\"1.0\" encoding=\"utf-8\"?>\n# <!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n# \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n# <html>\n# <head>\n# <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n# <\/head>\n# <body>\n# <h1>Error \"} + obj.status + \" \" + obj.response + {\"<\/h1>\n# <p>\"} + obj.response + {\"<\/p>\n# <h3>Guru Meditation:<\/h3>\n# <p>XID: \"} + req.xid + {\"<\/p>\n# <hr>\n# <p>Varnish cache server<\/p>\n# <\/body>\n# <\/html>\n# \"};\n# return (deliver);\n# }\n# \n# sub vcl_init {\n# \treturn (ok);\n# }\n# \n# sub vcl_fini {\n# \treturn (ok);\n# }\n","old_contents":"# This is a basic VCL configuration file for varnish. See the vcl(7)\n# man page for details on VCL syntax and semantics.\n# \n# Default backend definition. Set this to point to your content\n# server.\n# \nbackend default {\n .host = \"127.0.0.1\";\n .port = \"81\";\n}\n# \n# Below is a commented-out copy of the default VCL logic. If you\n# redefine any of these subroutines, the built-in logic will be\n# appended to your code.\n# sub vcl_recv {\n# if (req.restarts == 0) {\n# \tif (req.http.x-forwarded-for) {\n# \t set req.http.X-Forwarded-For =\n# \t\treq.http.X-Forwarded-For + \", \" + client.ip;\n# \t} else {\n# \t set req.http.X-Forwarded-For = client.ip;\n# \t}\n# }\n# if (req.request != \"GET\" &&\n# req.request != \"HEAD\" &&\n# req.request != \"PUT\" &&\n# req.request != \"POST\" &&\n# req.request != \"TRACE\" &&\n# req.request != \"OPTIONS\" &&\n# req.request != \"DELETE\") {\n# \/* Non-RFC2616 or CONNECT which is weird. *\/\n# return (pipe);\n# }\n# if (req.request != \"GET\" && req.request != \"HEAD\") {\n# \/* We only deal with GET and HEAD by default *\/\n# return (pass);\n# }\n# if (req.http.Authorization || req.http.Cookie) {\n# \/* Not cacheable by default *\/\n# return (pass);\n# }\n# return (lookup);\n# }\n# \n# sub vcl_pipe {\n# # Note that only the first request to the backend will have\n# # X-Forwarded-For set. If you use X-Forwarded-For and want to\n# # have it set for all requests, make sure to have:\n# # set bereq.http.connection = \"close\";\n# # here. It is not set by default as it might break some broken web\n# # applications, like IIS with NTLM authentication.\n# return (pipe);\n# }\n# \n# sub vcl_pass {\n# return (pass);\n# }\n# \n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (hash);\n# }\n# \n# sub vcl_hit {\n# return (deliver);\n# }\n# \n# sub vcl_miss {\n# return (fetch);\n# }\n# \n# sub vcl_fetch {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Vary == \"*\") {\n# \t\t\/*\n# \t\t * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# \t\t *\/\n# \t\tset beresp.ttl = 120 s;\n# \t\treturn (hit_for_pass);\n# }\n# return (deliver);\n# }\n# \n# sub vcl_deliver {\n# return (deliver);\n# }\n# \n# sub vcl_error {\n# set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n# set obj.http.Retry-After = \"5\";\n# synthetic {\"\n# <?xml version=\"1.0\" encoding=\"utf-8\"?>\n# <!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n# \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n# <html>\n# <head>\n# <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n# <\/head>\n# <body>\n# <h1>Error \"} + obj.status + \" \" + obj.response + {\"<\/h1>\n# <p>\"} + obj.response + {\"<\/p>\n# <h3>Guru Meditation:<\/h3>\n# <p>XID: \"} + req.xid + {\"<\/p>\n# <hr>\n# <p>Varnish cache server<\/p>\n# <\/body>\n# <\/html>\n# \"};\n# return (deliver);\n# }\n# \n# sub vcl_init {\n# \treturn (ok);\n# }\n# \n# sub vcl_fini {\n# \treturn (ok);\n# }\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"cac0fb2cb6d79f4b01837746bb95a6a18f9a366f","subject":"index.php may be included in admin path","message":"index.php may be included in admin path\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets\/recv.vcl","new_file":"etc\/vcl_snippets\/recv.vcl","new_contents":" # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n # Sort the query arguments\n set req.url = boltsort.sort(req.url);\n\n if (req.url ~ \"^\/static\/version(\\d*\/)?(.*)$\") {\n set req.url = \"\/static\/\" + re.group.2 + \"?\" + re.group.1;\n }\n \n # User's Cookie may contain some Magento Vary items we should vary on\n if (req.http.cookie:X-Magento-Vary ) {\n set req.http.X-Magento-Vary = req.http.cookie:X-Magento-Vary;\n } else {\n unset req.http.X-Magento-Vary;\n }\n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n if (!req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n error 403;\n }\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n\n } else {\n error 403;\n }\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (req.http.Fastly-FF) {\n # disable ESI processing on Origin Shield\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie ~ \"(X-Magento-Vary|form_key)=\") {\n error 200 \"\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url !~ \"country_code=\" ) {\n set req.url = req.url \"?country_code=\" if ( req.http.geo_override, req.http.geo_override, client.geo.country_code);\n }\n }\n } else {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking\n set req.http.Magento-Original-URL = req.url;\n set req.url = querystring.regfilter(req.url, \"^(utm_.*|gclid|gdftrk|_ga|mc_.*)\");\n }\n \n # Pass on checkout URLs. Because it's a snippet we want to execute this after backend selection so we handle it\n # in the request condition\n if (req.url ~ \"\/(catalogsearch|checkout)\") {\n set req.http.x-pass = \"1\";\n # Pass all admin actions\n } else if ( req.url ~ \"^\/(index\\.php\/)?admin(_.*)?\/\" ) {\n set req.http.x-pass = \"1\";\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n","old_contents":" # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n # Sort the query arguments\n set req.url = boltsort.sort(req.url);\n\n if (req.url ~ \"^\/static\/version(\\d*\/)?(.*)$\") {\n set req.url = \"\/static\/\" + re.group.2 + \"?\" + re.group.1;\n }\n \n # User's Cookie may contain some Magento Vary items we should vary on\n if (req.http.cookie:X-Magento-Vary ) {\n set req.http.X-Magento-Vary = req.http.cookie:X-Magento-Vary;\n } else {\n unset req.http.X-Magento-Vary;\n }\n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n if (!req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n error 403;\n }\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n\n } else {\n error 403;\n }\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (req.http.Fastly-FF) {\n # disable ESI processing on Origin Shield\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie ~ \"(X-Magento-Vary|form_key)=\") {\n error 200 \"\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url !~ \"country_code=\" ) {\n set req.url = req.url \"?country_code=\" if ( req.http.geo_override, req.http.geo_override, client.geo.country_code);\n }\n }\n } else {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking\n set req.http.Magento-Original-URL = req.url;\n set req.url = querystring.regfilter(req.url, \"^(utm_.*|gclid|gdftrk|_ga|mc_.*)\");\n }\n \n # Pass on checkout URLs. Because it's a snippet we want to execute this after backend selection so we handle it\n # in the request condition\n if (req.url ~ \"\/(catalogsearch|checkout)\") {\n set req.http.x-pass = \"1\";\n # Pass all admin actions\n } else if ( req.url ~ \"^\/admin(_.*)?\/\" ) {\n set req.http.x-pass = \"1\";\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"18aaf14d30df5e191ddeed2f1b4ff88ecdd795a4","subject":"Remove the if statement because the code contained within it is idempotent","message":"Remove the if statement because the code contained within it is idempotent\n","repos":"JakeChampion\/polyfill-service,JakeChampion\/polyfill-service","old_file":"fastly\/vcl\/polyfill-service.vcl","new_file":"fastly\/vcl\/polyfill-service.vcl","new_contents":"sub set_backend {\n\t# The Fastly macro is inserted before the backend is selected because the\n\t# macro has the code which defines the values avaiable for req.http.Host\n\t# but it also contains a default backend which is always set to the EU. I wish we could disable the default backend setting.\n\t#FASTLY recv\n\t\n\t# Calculate the ideal region to route the request to.\n \tdeclare local var.region STRING; \n\tif (server.region ~ \"(APAC|Asia|North-America|South-America|US-Central|US-East|US-West)\") {\n\t\tset var.region = \"US\";\n \t} else {\n\t\tset var.region = \"EU\";\n \t}\n\n\t# Gather the health of the shields and origins.\n\tdeclare local var.v3_eu_is_healthy BOOL;\n\tset req.backend = F_v3_eu;\n\tset var.v3_eu_is_healthy = req.backend.healthy;\n\n\tdeclare local var.v3_us_is_healthy BOOL;\n \tset req.backend = F_v3_us;\n \tset var.v3_us_is_healthy = req.backend.healthy;\n\n \tdeclare local var.shield_eu_is_healthy BOOL;\n \tset req.backend = ssl_shield_london_city_uk;\n \tset var.shield_eu_is_healthy = req.backend.healthy;\n\n \tdeclare local var.shield_us_is_healthy BOOL;\n \tset req.backend = ssl_shield_iad_va_us;\n \tset var.shield_us_is_healthy = req.backend.healthy;\n\n \t# Set some sort of default, that shouldn't get used.\n \tset req.backend = F_v3_eu;\n\n\t# Route EU requests to the nearest healthy shield or origin.\n \tif (var.region == \"EU\") {\n\t\tif (server.identity !~ \"-LCY$\" && req.http.Fastly-FF !~ \"-LCY\" && var.shield_eu_is_healthy) {\n\t\t\tset req.backend = ssl_shield_london_city_uk;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t\tset req.http.Host = req.http.EU_Host;\n\t\t} elseif (var.shield_us_is_healthy) {\n\t\t\tset req.backend = ssl_shield_iad_va_us;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t\tset req.http.Host = req.http.US_Host;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_eu;\n\t\t}\n \t}\n\n\t# Route US requests to the nearest healthy shield or origin.\n \tif (var.region == \"US\") {\n\t\tif (server.identity !~ \"-IAD$\" && req.http.Fastly-FF !~ \"-IAD\" && var.shield_us_is_healthy) {\n\t\t\tset req.backend = ssl_shield_iad_va_us;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t\tset req.http.Host = req.http.US_Host;\n\t\t} elseif (var.shield_eu_is_healthy) {\n\t\t\tset req.backend = ssl_shield_london_city_uk;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t\tset req.http.Host = req.http.EU_Host;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_us;\n\t\t}\n\t}\n\n\t# Persist the decision so we can debug the result.\n \tset req.http.Debug-Backend = req.backend;\n}\n\nsub vcl_recv {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_recv;\n\t}\n\n\tif (req.method != \"GET\" && req.method != \"HEAD\" && req.method != \"OPTIONS\" && req.method != \"FASTLYPURGE\" && req.method != \"PURGE\") {\n\t\terror 911;\n\t}\n\n\tif (req.method == \"OPTIONS\") {\n\t\terror 912;\n\t}\n\n\t# Because the old service had a router which allowed any words between \/v2\/polyfill. and .js\n\tif (req.url.path ~ \"^\/v2\/polyfill(\\.\\w+)(\\.\\w+)?\" && req.url.ext == \"js\") {\n\t\tif (re.group.2) {\n\t\t\tset req.url = \"\/v2\/polyfill.min.js?\" req.url.qs;\n\t\t} else {\n\t\t\tset req.url = \"\/v2\/polyfill.js?\" req.url.qs;\n\t\t}\n\t}\n\n\t# Override the v3 defaults with the defaults of v2\n\tif (req.url ~ \"^\/v2\/polyfill(\\.min)?\\.js\") {\n\t\tset req.url = regsub(req.url, \"^\/v2\", \"\/v3\");\n\t\tset req.url = querystring.set(req.url, \"version\", \"3.25.1\");\n\t\tdeclare local var.unknown STRING;\n\t\tset var.unknown = subfield(req.url.qs, \"unknown\", \"&\");\n\t\tset req.url = querystring.set(req.url, \"unknown\", if(var.unknown != \"\", var.unknown, \"ignore\"));\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\") {\n\t\tcall normalise_querystring_parameters_for_polyfill_bundle;\n\t\t# Sort the querystring parameters alphabetically to improve chances of hitting a cached copy.\n\t\t# If querystring is empty, remove the ? from the url.\n\t\tset req.url = querystring.clean(querystring.sort(req.url));\n\t\tcall set_backend;\n\t} else {\n\t\t# The request is to an endpoint which doesn't use query parameters, let's remove them to increase our cache-hit-ratio\n\t\tset req.url = querystring.remove(req.url);\n\t\tcall set_backend;\n\t}\n}\n\nsub vcl_hash {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_hash;\n\t}\n\n\t# We are not adding req.http.host to the hash because we want https:\/\/cdn.polyfill.io and https:\/\/polyfill.io to be a single object in the cache.\n\t# set req.hash += req.http.host;\n\tset req.hash += req.url;\n\t# We include return(hash) to stop the function falling through to the default VCL built into varnish, which for vcl_hash will add req.url and req.http.Host to the hash.\n\treturn(hash);\n}\n\nsub vcl_miss {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_miss;\n\t}\n}\n\nsub vcl_pass {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_pass;\n\t}\n}\n\nsub vcl_fetch {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_fetch;\n\t}\n\n\t# These header are only required for HTML documents.\n\tif (beresp.http.Content-Type ~ \"text\/html\") {\n\t\t# Enables the cross-site scripting filter built into most modern web browsers.\n\t\tset beresp.http.X-XSS-Protection = \"1; mode=block\";\t\n\t}\n\t# Prevents MIME-sniffing a response away from the declared content type.\n\tset beresp.http.X-Content-Type-Options = \"nosniff\";\n\n\t# Ensure the site is only served over HTTPS and reduce the chances of someone performing a MITM attack.\n\tset beresp.http.Strict-Transport-Security = \"max-age=31536000; includeSubdomains; preload\";\n\n\t# The Referrer-Policy header governs which referrer information, sent in the Referer header, should be included with requests made.\n\t# Send a full URL when performing a same-origin request, but only send the origin of the document for other cases.\n\tset beresp.http.Referrer-Policy = \"origin-when-cross-origin\";\n\n\t# Enable purging of all objects in the Fastly cache by issuing a purge with the key \"polyfill-service\".\n\tif (beresp.http.Surrogate-Key !~ \"\\bpolyfill-service\\b\") {\n\t\tset beresp.http.Surrogate-Key = if(beresp.http.Surrogate-Key, beresp.http.Surrogate-Key \" polyfill-service\", \"polyfill-service\");\n\t}\n\n\tset beresp.http.Timing-Allow-Origin = \"*\";\n\n\tif (req.http.Normalized-User-Agent) {\n\t\tset beresp.http.Normalized-User-Agent = req.http.Normalized-User-Agent;\n\t\tset beresp.http.Detected-User-Agent = req.http.useragent_parser_family \"\/\" req.http.useragent_parser_major \".\" req.http.useragent_parser_minor \".\" req.http.useragent_parser_patch;\n\t}\n}\n\nsub vcl_deliver {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_deliver;\n\t}\n\n\tset req.http.Fastly-Force-Shield = \"yes\";\n\n\t# Allow cross origin GET, HEAD, and OPTIONS requests to be made.\n\tif (req.http.Origin) {\n\t\tset resp.http.Access-Control-Allow-Origin = \"*\";\n\t\tset resp.http.Access-Control-Allow-Methods = \"GET,HEAD,OPTIONS\";\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\" && !req.http.Fastly-FF) {\n\t\t# Need to add \"Vary: User-Agent\" in after vcl_fetch to avoid the \n\t\t# \"Vary: User-Agent\" entering the Varnish cache.\n\t\t# We need \"Vary: User-Agent\" in the browser cache because a browser\n\t\t# may update itself to a version which needs different polyfills\n\t\t# So we need to have it ignore the browser cached bundle when the user-agent changes.\n\t\tadd resp.http.Vary = \"User-Agent\";\n\t\tadd resp.http.Vary = \"Accept-Encoding\";\n\t}\n\n\tadd resp.http.Server-Timing = fastly_info.state {\", fastly;desc=\"Edge time\";dur=\"} time.elapsed.msec;\n\n\tif (req.http.Fastly-Debug) {\n\t\tset resp.http.Debug-Backend = req.http.Debug-Backend;\n\t\tset resp.http.Debug-Host = req.http.Host;\n\t\tset resp.http.Debug-Fastly-Restarts = req.restarts;\n\t\tset resp.http.Debug-Orig-URL = req.http.Orig-URL;\n\t\tset resp.http.Debug-VCL-Route = req.http.X-VCL-Route;\n\t\tset resp.http.useragent_parser_family = req.http.useragent_parser_family;\n\t\tset resp.http.useragent_parser_major = req.http.useragent_parser_major;\n\t\tset resp.http.useragent_parser_minor = req.http.useragent_parser_minor;\n\t\tset resp.http.useragent_parser_patch = req.http.useragent_parser_patch;\n\t} else {\n\t\tunset resp.http.Server;\n\t\tunset resp.http.Via;\n\t\tunset resp.http.X-Cache;\n\t\tunset resp.http.X-Cache-Hits;\n\t\tunset resp.http.X-Served-By;\n\t\tunset resp.http.X-Timer;\n\t\tunset resp.http.Fastly-Restarts;\n\t}\n}\n\nsub vcl_error {\n\tif (obj.status == 911) {\n\t\tset obj.status = 405;\n\t\tset obj.response = \"METHOD NOT ALLOWED\";\n\t\tset obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n\t\tset obj.http.Cache-Control = \"private, no-store\";\n\t\tsynthetic req.method \" METHOD NOT ALLOWED\";\n\t\treturn (deliver);\n\t}\n\tif (obj.status == 912) {\n\t\tset obj.status = 200;\n\t\tset obj.response = \"OK\";\n\t\tset obj.http.Allow = \"OPTIONS, GET, HEAD\";\n\t\treturn (deliver);\n\t}\n}\n","old_contents":"sub set_backend {\n\t# The Fastly macro is inserted before the backend is selected because the\n\t# macro has the code which defines the values avaiable for req.http.Host\n\t# but it also contains a default backend which is always set to the EU. I wish we could disable the default backend setting.\n\t#FASTLY recv\n\t\n\t# Calculate the ideal region to route the request to.\n \tdeclare local var.region STRING; \n\tif (server.region ~ \"(APAC|Asia|North-America|South-America|US-Central|US-East|US-West)\") {\n\t\tset var.region = \"US\";\n \t} else {\n\t\tset var.region = \"EU\";\n \t}\n\n\t# Gather the health of the shields and origins.\n\tdeclare local var.v3_eu_is_healthy BOOL;\n\tset req.backend = F_v3_eu;\n\tset var.v3_eu_is_healthy = req.backend.healthy;\n\n\tdeclare local var.v3_us_is_healthy BOOL;\n \tset req.backend = F_v3_us;\n \tset var.v3_us_is_healthy = req.backend.healthy;\n\n \tdeclare local var.shield_eu_is_healthy BOOL;\n \tset req.backend = ssl_shield_london_city_uk;\n \tset var.shield_eu_is_healthy = req.backend.healthy;\n\n \tdeclare local var.shield_us_is_healthy BOOL;\n \tset req.backend = ssl_shield_iad_va_us;\n \tset var.shield_us_is_healthy = req.backend.healthy;\n\n \t# Set some sort of default, that shouldn't get used.\n \tset req.backend = F_v3_eu;\n\n\t# Route EU requests to the nearest healthy shield or origin.\n \tif (var.region == \"EU\") {\n\t\tif (server.identity !~ \"-LCY$\" && req.http.Fastly-FF !~ \"-LCY\" && var.shield_eu_is_healthy) {\n\t\t\tset req.backend = ssl_shield_london_city_uk;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t\tset req.http.Host = req.http.EU_Host;\n\t\t} elseif (var.shield_us_is_healthy) {\n\t\t\tset req.backend = ssl_shield_iad_va_us;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t\tset req.http.Host = req.http.US_Host;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_eu;\n\t\t}\n \t}\n\n\t# Route US requests to the nearest healthy shield or origin.\n \tif (var.region == \"US\") {\n\t\tif (server.identity !~ \"-IAD$\" && req.http.Fastly-FF !~ \"-IAD\" && var.shield_us_is_healthy) {\n\t\t\tset req.backend = ssl_shield_iad_va_us;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t\tset req.http.Host = req.http.US_Host;\n\t\t} elseif (var.shield_eu_is_healthy) {\n\t\t\tset req.backend = ssl_shield_london_city_uk;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t\tset req.http.Host = req.http.EU_Host;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_us;\n\t\t}\n\t}\n\n\t# Persist the decision so we can debug the result.\n \tset req.http.Debug-Backend = req.backend;\n}\n\nsub vcl_recv {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_recv;\n\t}\n\n\tif (req.method != \"GET\" && req.method != \"HEAD\" && req.method != \"OPTIONS\" && req.method != \"FASTLYPURGE\" && req.method != \"PURGE\") {\n\t\terror 911;\n\t}\n\n\tif (req.method == \"OPTIONS\") {\n\t\terror 912;\n\t}\n\n\t# Because the old service had a router which allowed any words between \/v2\/polyfill. and .js\n\tif (req.url.path ~ \"^\/v2\/polyfill(\\.\\w+)(\\.\\w+)?\" && req.url.ext == \"js\") {\n\t\tif (re.group.2) {\n\t\t\tset req.url = \"\/v2\/polyfill.min.js?\" req.url.qs;\n\t\t} else {\n\t\t\tset req.url = \"\/v2\/polyfill.js?\" req.url.qs;\n\t\t}\n\t}\n\n\t# Override the v3 defaults with the defaults of v2\n\tif (req.url ~ \"^\/v2\/polyfill(\\.min)?\\.js\") {\n\t\tset req.url = regsub(req.url, \"^\/v2\", \"\/v3\");\n\t\tset req.url = querystring.set(req.url, \"version\", \"3.25.1\");\n\t\tdeclare local var.unknown STRING;\n\t\tset var.unknown = subfield(req.url.qs, \"unknown\", \"&\");\n\t\tset req.url = querystring.set(req.url, \"unknown\", if(var.unknown != \"\", var.unknown, \"ignore\"));\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\") {\n\t\tif (!req.http.Fastly-FF) {\n\t\t\tcall normalise_querystring_parameters_for_polyfill_bundle;\n\t\t\t# Sort the querystring parameters alphabetically to improve chances of hitting a cached copy.\n\t\t\t# If querystring is empty, remove the ? from the url.\n\t\t\tset req.url = querystring.clean(querystring.sort(req.url));\n\t\t}\n\t\tcall set_backend;\n\t} else {\n\t\t# The request is to an endpoint which doesn't use query parameters, let's remove them to increase our cache-hit-ratio\n\t\tset req.url = querystring.remove(req.url);\n\t\tcall set_backend;\n\t}\n}\n\nsub vcl_hash {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_hash;\n\t}\n\n\t# We are not adding req.http.host to the hash because we want https:\/\/cdn.polyfill.io and https:\/\/polyfill.io to be a single object in the cache.\n\t# set req.hash += req.http.host;\n\tset req.hash += req.url;\n\t# We include return(hash) to stop the function falling through to the default VCL built into varnish, which for vcl_hash will add req.url and req.http.Host to the hash.\n\treturn(hash);\n}\n\nsub vcl_miss {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_miss;\n\t}\n}\n\nsub vcl_pass {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_pass;\n\t}\n}\n\nsub vcl_fetch {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_fetch;\n\t}\n\n\t# These header are only required for HTML documents.\n\tif (beresp.http.Content-Type ~ \"text\/html\") {\n\t\t# Enables the cross-site scripting filter built into most modern web browsers.\n\t\tset beresp.http.X-XSS-Protection = \"1; mode=block\";\t\n\t}\n\t# Prevents MIME-sniffing a response away from the declared content type.\n\tset beresp.http.X-Content-Type-Options = \"nosniff\";\n\n\t# Ensure the site is only served over HTTPS and reduce the chances of someone performing a MITM attack.\n\tset beresp.http.Strict-Transport-Security = \"max-age=31536000; includeSubdomains; preload\";\n\n\t# The Referrer-Policy header governs which referrer information, sent in the Referer header, should be included with requests made.\n\t# Send a full URL when performing a same-origin request, but only send the origin of the document for other cases.\n\tset beresp.http.Referrer-Policy = \"origin-when-cross-origin\";\n\n\t# Enable purging of all objects in the Fastly cache by issuing a purge with the key \"polyfill-service\".\n\tif (beresp.http.Surrogate-Key !~ \"\\bpolyfill-service\\b\") {\n\t\tset beresp.http.Surrogate-Key = if(beresp.http.Surrogate-Key, beresp.http.Surrogate-Key \" polyfill-service\", \"polyfill-service\");\n\t}\n\n\tset beresp.http.Timing-Allow-Origin = \"*\";\n\n\tif (req.http.Normalized-User-Agent) {\n\t\tset beresp.http.Normalized-User-Agent = req.http.Normalized-User-Agent;\n\t\tset beresp.http.Detected-User-Agent = req.http.useragent_parser_family \"\/\" req.http.useragent_parser_major \".\" req.http.useragent_parser_minor \".\" req.http.useragent_parser_patch;\n\t}\n}\n\nsub vcl_deliver {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_deliver;\n\t}\n\n\tset req.http.Fastly-Force-Shield = \"yes\";\n\n\t# Allow cross origin GET, HEAD, and OPTIONS requests to be made.\n\tif (req.http.Origin) {\n\t\tset resp.http.Access-Control-Allow-Origin = \"*\";\n\t\tset resp.http.Access-Control-Allow-Methods = \"GET,HEAD,OPTIONS\";\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\" && !req.http.Fastly-FF) {\n\t\t# Need to add \"Vary: User-Agent\" in after vcl_fetch to avoid the \n\t\t# \"Vary: User-Agent\" entering the Varnish cache.\n\t\t# We need \"Vary: User-Agent\" in the browser cache because a browser\n\t\t# may update itself to a version which needs different polyfills\n\t\t# So we need to have it ignore the browser cached bundle when the user-agent changes.\n\t\tadd resp.http.Vary = \"User-Agent\";\n\t\tadd resp.http.Vary = \"Accept-Encoding\";\n\t}\n\n\tadd resp.http.Server-Timing = fastly_info.state {\", fastly;desc=\"Edge time\";dur=\"} time.elapsed.msec;\n\n\tif (req.http.Fastly-Debug) {\n\t\tset resp.http.Debug-Backend = req.http.Debug-Backend;\n\t\tset resp.http.Debug-Host = req.http.Host;\n\t\tset resp.http.Debug-Fastly-Restarts = req.restarts;\n\t\tset resp.http.Debug-Orig-URL = req.http.Orig-URL;\n\t\tset resp.http.Debug-VCL-Route = req.http.X-VCL-Route;\n\t\tset resp.http.useragent_parser_family = req.http.useragent_parser_family;\n\t\tset resp.http.useragent_parser_major = req.http.useragent_parser_major;\n\t\tset resp.http.useragent_parser_minor = req.http.useragent_parser_minor;\n\t\tset resp.http.useragent_parser_patch = req.http.useragent_parser_patch;\n\t} else {\n\t\tunset resp.http.Server;\n\t\tunset resp.http.Via;\n\t\tunset resp.http.X-Cache;\n\t\tunset resp.http.X-Cache-Hits;\n\t\tunset resp.http.X-Served-By;\n\t\tunset resp.http.X-Timer;\n\t\tunset resp.http.Fastly-Restarts;\n\t}\n}\n\nsub vcl_error {\n\tif (obj.status == 911) {\n\t\tset obj.status = 405;\n\t\tset obj.response = \"METHOD NOT ALLOWED\";\n\t\tset obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n\t\tset obj.http.Cache-Control = \"private, no-store\";\n\t\tsynthetic req.method \" METHOD NOT ALLOWED\";\n\t\treturn (deliver);\n\t}\n\tif (obj.status == 912) {\n\t\tset obj.status = 200;\n\t\tset obj.response = \"OK\";\n\t\tset obj.http.Allow = \"OPTIONS, GET, HEAD\";\n\t\treturn (deliver);\n\t}\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"847f468caaebd86045aa214cb7331a06e7aab185","subject":"As susgested","message":"As susgested\n\nAs susgested\n","repos":"kevin25\/fastly","old_file":"custom52.vcl","new_file":"custom52.vcl","new_contents":"sub vcl_recv {\n #FASTLY recv\n if (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n if (req.url ~ \"en\" || req.url ~ \"^\/$\") {\n\n set req.http.MyLang = \"MyLang=en\";\n\n } elseif (req.url ~ \"ja\") {\n\n set req.http.MyLang = \"MyLang=ja\";\n\n } elseif (req.url ~ \"es\") {\n\n set req.http.MyLang = \"MyLang=es\";\n\n } elseif (req.url ~ \"it\") {\n\n set req.http.MyLang = \"MyLang=it\";\n\n } elseif (req.url ~ \"de\") {\n\n set req.http.MyLang = \"MyLang=de\";\n\n } elseif (req.url ~ \"pt\") {\n\n set req.http.MyLang = \"MyLang=pt\";\n\n } elseif (req.url ~ \"fr\") {\n\n set req.http.MyLang = \"MyLang=fr\";\n\n }\n return(lookup);\n\n}\nsub vcl_fetch {\n\t#FASTLY fetch\n\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", MyLang\";\n } else {\n set beresp.http.Vary = \"MyLang\";\n }\n\n if ((beresp.status == 500 || beresp.status == 503) && req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.status == 500 || beresp.status == 503) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n if (beresp.http.Expires || beresp.http.Surrogate-Control ~ \"max-age\" || beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # keep the ttl here\n } else {\n # apply the default ttl\n set beresp.ttl = 3600s;\n }\n return(deliver);\n\n}\nsub vcl_deliver {\n\t#FASTLY deliver\n if (resp.http.Vary) {\n set resp.http.Vary = regsub(resp.http.Vary, \"X-Language\", \"WebSiteLang\");\n } \n if (req.url ~ \"ja\" && req.http.Cookie !~ \"WebSiteLang=ja\") { \n add resp.http.Set-Cookie = \"WebSiteLang=ja; expires=\" now + 180d \"; path=\/;\";\n } \n if (req.url ~ \"es\" && req.http.Cookie !~ \"WebSiteLang=es\") { \n add resp.http.Set-Cookie = \"WebSiteLang=es; expires=\" now + 180d \"; path=\/;\";\n }\n if (req.url ~ \"pt\" && req.http.Cookie !~ \"WebSiteLang=pt\") { \n add resp.http.Set-Cookie = \"WebSiteLang=pt; expires=\" now + 180d \"; path=\/;\";\n } \n if (req.url ~ \"it\" && req.http.Cookie !~ \"WebSiteLang=it\") { \n add resp.http.Set-Cookie = \"WebSiteLang=it; expires=\" now + 180d \"; path=\/;\";\n } \n if (req.url ~ \"fr\" && req.http.Cookie !~ \"WebSiteLang=fr\") { \n add resp.http.Set-Cookie = \"WebSiteLang=fr; expires=\" now + 180d \"; path=\/;\";\n } \n if (req.url ~ \"de\" && req.http.Cookie !~ \"WebSiteLang=de\") { \n add resp.http.Set-Cookie = \"WebSiteLang=de; expires=\" now + 180d \"; path=\/;\";\n }\n if (req.url ~ \"en\" && req.http.Cookie !~ \"WebSiteLang=en\") { \n add resp.http.Set-Cookie = \"WebSiteLang=en; expires=\" now + 180d \"; path=\/;\";\n }\n #if (req.http.X-Language) {\n # set resp.http.Set-Cookie = req.http.Language;\n #}\n}\nsub vcl_hash {\n #FASTLY hash\n set req.hash += req.url;\n if (req.http.host) {\n set req.hash += req.http.host;\n #hash_data(req.http.host);\n } else {\n set req.hash += server.ip;\n #hash_data(server.ip);\n }\n if (req.http.Language) {\n #add cookie in hash\n set req.hash += req.http.Language;\n #hash_data(req.http.Language);\n }\n return(hash);\n}\nsub vcl_hit {\n#FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\nsub vcl_miss {\n#FASTLY miss\n return(fetch);\n}\nsub vcl_error {\n#FASTLY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n","old_contents":"sub vcl_recv {\n #FASTLY recv\n if (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n if (req.http.Cookie ~ \"WebSiteLang=\") {\n set req.http.X-Language = req.http.Cookie;\n unset req.http.Cookie;\n }\n return(lookup);\n\n}\nsub vcl_fetch {\n\t#FASTLY fetch\n\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", MyLang\";\n } else {\n set beresp.http.Vary = \"MyLang\";\n }\n\n if ((beresp.status == 500 || beresp.status == 503) && req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.status == 500 || beresp.status == 503) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n if (beresp.http.Expires || beresp.http.Surrogate-Control ~ \"max-age\" || beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # keep the ttl here\n } else {\n # apply the default ttl\n set beresp.ttl = 3600s;\n }\n return(deliver);\n\n}\nsub vcl_deliver {\n\t#FASTLY deliver\n if (resp.http.Vary) {\n set resp.http.Vary = regsub(resp.http.Vary, \"MyLang\", \"WebSiteLang\");\n } \n if (req.url ~ \"ja\" && req.http.Cookie !~ \"WebSiteLang=ja\") { \n add resp.http.Set-Cookie = \"WebSiteLang=ja; expires=\" now + 180d \"; path=\/;\";\n } \n if (req.url ~ \"es\" && req.http.Cookie !~ \"WebSiteLang=es\") { \n add resp.http.Set-Cookie = \"WebSiteLang=es; expires=\" now + 180d \"; path=\/;\";\n }\n if (req.url ~ \"pt\" && req.http.Cookie !~ \"WebSiteLang=pt\") { \n add resp.http.Set-Cookie = \"WebSiteLang=pt; expires=\" now + 180d \"; path=\/;\";\n } \n if (req.url ~ \"it\" && req.http.Cookie !~ \"WebSiteLang=it\") { \n add resp.http.Set-Cookie = \"WebSiteLang=it; expires=\" now + 180d \"; path=\/;\";\n } \n if (req.url ~ \"fr\" && req.http.Cookie !~ \"WebSiteLang=fr\") { \n add resp.http.Set-Cookie = \"WebSiteLang=fr; expires=\" now + 180d \"; path=\/;\";\n } \n if (req.url ~ \"de\" && req.http.Cookie !~ \"WebSiteLang=de\") { \n add resp.http.Set-Cookie = \"WebSiteLang=de; expires=\" now + 180d \"; path=\/;\";\n }\n if (req.url ~ \"en\" && req.http.Cookie !~ \"WebSiteLang=en\") { \n add resp.http.Set-Cookie = \"WebSiteLang=en; expires=\" now + 180d \"; path=\/;\";\n }\n #if (req.http.MyLang) {\n # set resp.http.Set-Cookie = req.http.MyLang;\n #}\n}\n#sub vcl_hash {\n #FASTLY hash\n# if(req.http.WebSiteLang) {\n# set req.hash += req.http.WebSiteLang;\n# }\n# return(hash);\n#}\nsub vcl_hit {\n#FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\nsub vcl_miss {\n#FASTLY miss\n return(fetch);\n}\nsub vcl_error {\n#FASTLY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"5cf2f42fe68539bc00835848fe67c274711e8798","subject":"Set grace time","message":"Set grace time\n","repos":"mobulum\/docker-varnish,Zenedith\/docker-varnish","old_file":"config\/default.vcl","new_file":"config\/default.vcl","new_contents":"import throttle;\n\nbackend default {\n .host = \"$(eval \"echo \\$BACKEND_PORT_${BACKEND_ENV_PORT}_TCP_ADDR\")\";\n .port = \"${BACKEND_ENV_PORT}\";\n}\n\n# Handling of requests that are received from clients.\n# First decide whether or not to lookup data in the cache.\nsub vcl_recv {\n # Pipe requests that are non-RFC2616 or CONNECT which is weird.\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"PATCH\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"DELETE\") {\n return(pipe);\n }\n\n if (req.backend.healthy) {\n set req.grace = ${GRACE_TTL};\n } else {\n set req.grace = ${GRACE_MAX};\n }\n\n if (req.http.Authorization || req.http.Authenticate) {\n return(pass);\n }\n\n # Pass requests that are not GET or HEAD\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n return(pass);\n }\n\n if (throttle.is_allowed(\"ip:\" + client.ip, \"${THROTTLE_LIMIT}\") > 0s) {\n error 429 \"Too many requests\";\n }\n\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n\n # Handle compression correctly. Varnish treats headers literally, not\n # semantically. So it is very well possible that there are cache misses\n # because the headers sent by different browsers aren't the same.\n # @see: http:\/\/varnish.projects.linpro.no\/wiki\/FAQ\/Compression\n if (req.http.Accept-Encoding) {\n if (req.http.Accept-Encoding ~ \"gzip\") {\n # if the browser supports it, we'll use gzip\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n # next, try deflate if it is supported\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n # unknown algorithm. Probably junk, remove it\n remove req.http.Accept-Encoding;\n }\n }\n\n # Clear cookie and authorization headers, set grace time, lookup in the cache\n unset req.http.Cookie;\n unset req.http.Authorization;\n return(lookup);\n}\n\n# Called when entering pipe mode\nsub vcl_pipe {\n set bereq.http.connection = \"close\";\n\n if (req.http.X-Forwarded-For) {\n set bereq.http.X-Forwarded-For = req.http.X-Forwarded-For;\n } else {\n set bereq.http.X-Forwarded-For = regsub(client.ip, \":.*\", \"\");\n }\n return (pipe);\n}\n\nsub vcl_pass {\n set bereq.http.connection = \"close\";\n\n if (req.http.X-Forwarded-For) {\n set bereq.http.X-Forwarded-For = req.http.X-Forwarded-For;\n } else {\n set bereq.http.X-Forwarded-For = regsub(client.ip, \":.*\", \"\");\n }\n #return (pass);\n}\n\n# Called when the requested object has been retrieved from the\n# backend, or the request to the backend has failed\nsub vcl_fetch {\n # Set the grace time\n set beresp.grace = ${GRACE_MAX};\n\n # Do not cache the object if the status is not in the 200s\n if (beresp.status >= 300) {\n # Remove the Set-Cookie header\n remove beresp.http.Set-Cookie;\n return(hit_for_pass);\n }\n\n # Do not cache the object if the backend application does not want us to.\n if (beresp.http.Cache-Control ~ \"(no-cache|no-store|private|must-revalidate)\") {\n return(hit_for_pass);\n }\n\n if (beresp.ttl <= 0s ||\n beresp.http.Set-Cookie ||\n beresp.http.Vary == \"*\") {\n \/*\n * Mark as \"Hit-For-Pass\"\n *\/\n set beresp.ttl = ${GRACE_TTL};\n return (hit_for_pass);\n }\n\n # Everything below here should be cached\n\n # Remove the Set-Cookie header\n remove beresp.http.Set-Cookie;\n\n # Deliver the object\n return (deliver);\n}\n\n# Called before the response is sent back to the client\nsub vcl_deliver {\n\n # Exclui os assets do revalidate\n if (! (req.url ~ \"^\/(assets|images|uploads)\")) {\n # Force browsers and intermediary caches to always check back with us\n set resp.http.Cache-Control = \"private, max-age=0, must-revalidate\";\n set resp.http.Pragma = \"no-cache\";\n }\n\n # Add a header to indicate a cache HIT\/MISS\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n\n return (deliver);\n}\n\nsub vcl_error {\n set obj.http.Content-Type = \"application\/json; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic {\"{\n \"status\":\"\"} + obj.status + {\"\",\n \"response\":\"\"} + obj.response + {\"\",\n \"xid\":\"\"} + req.xid + {\"\",\n \"message\":\"Varnish cache server error\"\n }\"};\n return (deliver);\n }\n\n sub vcl_init {\n return (ok);\n}\n","old_contents":"import throttle;\n\nbackend default {\n .host = \"$(eval \"echo \\$BACKEND_PORT_${BACKEND_ENV_PORT}_TCP_ADDR\")\";\n .port = \"${BACKEND_ENV_PORT}\";\n}\n\n# Handling of requests that are received from clients.\n# First decide whether or not to lookup data in the cache.\nsub vcl_recv {\n # Pipe requests that are non-RFC2616 or CONNECT which is weird.\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"PATCH\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"DELETE\") {\n return(pipe);\n }\n\n if (req.backend.healthy) {\n set req.grace = ${GRACE_TTL};\n } else {\n set req.grace = ${GRACE_MAX};\n }\n\n if (req.http.Authorization || req.http.Authenticate) {\n return(pass);\n }\n\n # Pass requests that are not GET or HEAD\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n return(pass);\n }\n\n if (throttle.is_allowed(\"ip:\" + client.ip, \"${THROTTLE_LIMIT}\") > 0s) {\n error 429 \"Too many requests\";\n }\n\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n\n # Handle compression correctly. Varnish treats headers literally, not\n # semantically. So it is very well possible that there are cache misses\n # because the headers sent by different browsers aren't the same.\n # @see: http:\/\/varnish.projects.linpro.no\/wiki\/FAQ\/Compression\n if (req.http.Accept-Encoding) {\n if (req.http.Accept-Encoding ~ \"gzip\") {\n # if the browser supports it, we'll use gzip\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n # next, try deflate if it is supported\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n # unknown algorithm. Probably junk, remove it\n remove req.http.Accept-Encoding;\n }\n }\n\n # Clear cookie and authorization headers, set grace time, lookup in the cache\n unset req.http.Cookie;\n unset req.http.Authorization;\n return(lookup);\n}\n\n# Called when entering pipe mode\nsub vcl_pipe {\n set bereq.http.connection = \"close\";\n\n if (req.http.X-Forwarded-For) {\n set bereq.http.X-Forwarded-For = req.http.X-Forwarded-For;\n } else {\n set bereq.http.X-Forwarded-For = regsub(client.ip, \":.*\", \"\");\n }\n return (pipe);\n}\n\nsub vcl_pass {\n set bereq.http.connection = \"close\";\n\n if (req.http.X-Forwarded-For) {\n set bereq.http.X-Forwarded-For = req.http.X-Forwarded-For;\n } else {\n set bereq.http.X-Forwarded-For = regsub(client.ip, \":.*\", \"\");\n }\n #return (pass);\n}\n\n# Called when the requested object has been retrieved from the\n# backend, or the request to the backend has failed\nsub vcl_fetch {\n # Set the grace time\n set beresp.grace = ${GRACE_MAX};\n\n # Do not cache the object if the status is not in the 200s\n if (beresp.status >= 300) {\n # Remove the Set-Cookie header\n remove beresp.http.Set-Cookie;\n return(hit_for_pass);\n }\n\n # Do not cache the object if the backend application does not want us to.\n if (beresp.http.Cache-Control ~ \"(no-cache|no-store|private|must-revalidate)\") {\n return(hit_for_pass);\n }\n\n if (beresp.ttl <= 0s ||\n beresp.http.Set-Cookie ||\n beresp.http.Vary == \"*\") {\n \/*\n * Mark as \"Hit-For-Pass\" for the next 2 minutes\n *\/\n set beresp.ttl = ${GRACE_TTL};\n return (hit_for_pass);\n }\n\n # Everything below here should be cached\n\n # Remove the Set-Cookie header\n remove beresp.http.Set-Cookie;\n\n # Deliver the object\n return (deliver);\n}\n\n# Called before the response is sent back to the client\nsub vcl_deliver {\n\n # Exclui os assets do revalidate\n if (! (req.url ~ \"^\/(assets|images|uploads)\")) {\n # Force browsers and intermediary caches to always check back with us\n set resp.http.Cache-Control = \"private, max-age=0, must-revalidate\";\n set resp.http.Pragma = \"no-cache\";\n }\n\n # Add a header to indicate a cache HIT\/MISS\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n\n return (deliver);\n}\n\nsub vcl_error {\n set obj.http.Content-Type = \"application\/json; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic {\"{\n \"status\":\"\"} + obj.status + {\"\",\n \"response\":\"\"} + obj.response + {\"\",\n \"xid\":\"\"} + req.xid + {\"\",\n \"message\":\"Varnish cache server error\"\n }\"};\n return (deliver);\n }\n\n sub vcl_init {\n return (ok);\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"8d7dd8c8566a8b638437a50a356d2ed958e1a78e","subject":"[varnish] Fix syntax error :-\/","message":"[varnish] Fix syntax error :-\/\n","repos":"coletivoEITA\/noosfero-ecosol,macartur\/noosfero,rafamanzo\/mezuro-travis,evandrojr\/noosferogov,hackathon-oscs\/cartografias,danielafeitosa\/noosfero,coletivoEITA\/noosfero,CIRANDAS\/noosfero-ecosol,uniteddiversity\/noosfero,hackathon-oscs\/rede-osc,CIRANDAS\/noosfero-ecosol,hebertdougl\/noosfero,hackathon-oscs\/rede-osc,hackathon-oscs\/cartografias,pr-snas\/noosfero-sgpr,LuisBelo\/tccnoosfero,alexandreab\/noosfero,AlessandroCaetano\/noosfero,abner\/noosfero,macartur\/noosfero,hebertdougl\/noosfero,CIRANDAS\/noosfero-ecosol,blogoosfero\/noosfero,macartur\/noosfero,tallysmartins\/noosfero,evandrojr\/noosfero,macartur\/noosfero,hackathon-oscs\/cartografias,evandrojr\/noosferogov,marcosronaldo\/noosfero,abner\/noosfero,pr-snas\/noosfero-sgpr,evandrojr\/noosferogov,hackathon-oscs\/cartografias,uniteddiversity\/noosfero,hebertdougl\/noosfero,cesarfex\/noosfero,hackathon-oscs\/rede-osc,hackathon-oscs\/rede-osc,samasti\/noosfero,larissa\/noosfero,samasti\/noosfero,hebertdougl\/noosfero,blogoosfero\/noosfero,arthurmde\/noosfero,tallysmartins\/noosfero,samasti\/noosfero,evandrojr\/noosfero,alexandreab\/noosfero,tallysmartins\/noosfero,vfcosta\/noosfero,blogoosfero\/noosfero,danielafeitosa\/noosfero,macartur\/noosfero,tallysmartins\/noosfero,arthurmde\/noosfero,pr-snas\/noosfero-sgpr,evandrojr\/noosferogov,evandrojr\/noosfero,tallysmartins\/noosfero,evandrojr\/noosfero,marcosronaldo\/noosfero,alexandreab\/noosfero,blogoosfero\/noosfero,alexandreab\/noosfero,uniteddiversity\/noosfero,EcoAlternative\/noosfero-ecosol,AlessandroCaetano\/noosfero,tallysmartins\/noosfero,AlessandroCaetano\/noosfero,larissa\/noosfero,uniteddiversity\/noosfero,cesarfex\/noosfero,cesarfex\/noosfero,hackathon-oscs\/cartografias,CIRANDAS\/noosfero-ecosol,cesarfex\/noosfero,hebertdougl\/noosfero,tallysmartins\/noosfero,hackathon-oscs\/rede-osc,LuisBelo\/tccnoosfero,CIRANDAS\/noosfero-ecosol,alexandreab\/noosfero,EcoAlternative\/noosfero-ecosol,AlessandroCaetano\/noosfero,coletivoEITA\/noosfero-ecosol,cesarfex\/noosfero,larissa\/noosfero,EcoAlternative\/noosfero-ecosol,EcoAlternative\/noosfero-ecosol,evandrojr\/noosfero,hackathon-oscs\/rede-osc,AlessandroCaetano\/noosfero,blogoosfero\/noosfero,abner\/noosfero,coletivoEITA\/noosfero,danielafeitosa\/noosfero,cesarfex\/noosfero,evandrojr\/noosfero,coletivoEITA\/noosfero,uniteddiversity\/noosfero,LuisBelo\/tccnoosfero,abner\/noosfero,AlessandroCaetano\/noosfero,hackathon-oscs\/rede-osc,uniteddiversity\/noosfero,LuisBelo\/tccnoosfero,marcosronaldo\/noosfero,arthurmde\/noosfero,EcoAlternative\/noosfero-ecosol,blogoosfero\/noosfero,cesarfex\/noosfero,danielafeitosa\/noosfero,evandrojr\/noosferogov,alexandreab\/noosfero,rafamanzo\/mezuro-travis,hackathon-oscs\/cartografias,vfcosta\/noosfero,blogoosfero\/noosfero,marcosronaldo\/noosfero,coletivoEITA\/noosfero,larissa\/noosfero,danielafeitosa\/noosfero,larissa\/noosfero,vfcosta\/noosfero,coletivoEITA\/noosfero-ecosol,rafamanzo\/mezuro-travis,abner\/noosfero,macartur\/noosfero,EcoAlternative\/noosfero-ecosol,pr-snas\/noosfero-sgpr,larissa\/noosfero,vfcosta\/noosfero,macartur\/noosfero,arthurmde\/noosfero,abner\/noosfero,coletivoEITA\/noosfero,uniteddiversity\/noosfero,evandrojr\/noosferogov,arthurmde\/noosfero,LuisBelo\/tccnoosfero,evandrojr\/noosferogov,coletivoEITA\/noosfero-ecosol,samasti\/noosfero,alexandreab\/noosfero,marcosronaldo\/noosfero,LuisBelo\/tccnoosfero,marcosronaldo\/noosfero,rafamanzo\/mezuro-travis,samasti\/noosfero,pr-snas\/noosfero-sgpr,hebertdougl\/noosfero,vfcosta\/noosfero,marcosronaldo\/noosfero,evandrojr\/noosfero,abner\/noosfero,coletivoEITA\/noosfero,arthurmde\/noosfero,coletivoEITA\/noosfero-ecosol,larissa\/noosfero,arthurmde\/noosfero,hackathon-oscs\/cartografias,coletivoEITA\/noosfero-ecosol,EcoAlternative\/noosfero-ecosol,coletivoEITA\/noosfero,AlessandroCaetano\/noosfero,samasti\/noosfero,hebertdougl\/noosfero,danielafeitosa\/noosfero,pr-snas\/noosfero-sgpr,vfcosta\/noosfero,rafamanzo\/mezuro-travis","old_file":"etc\/noosfero\/varnish-noosfero.vcl","new_file":"etc\/noosfero\/varnish-noosfero.vcl","new_contents":"sub vcl_recv {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n if (req.http.Cookie) {\n # We only care about the \"_noosfero_session.*\" cookie, used for\n # authentication.\n if (req.http.Cookie !~ \"_noosfero_session.*\" ) {\n # strip all cookies\n unset req.http.Cookie;\n }\n }\n }\n}\n\nsub vcl_error {\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n\n synthetic {\"\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Transitional\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-transitional.dtd\">\n<html xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n <head>\n <meta http-equiv=\"Content-Type\" content=\"text\/html; charset=utf-8\"\/>\n <meta http-equiv=\"refresh\" content=\"60\"\/>\n <title>Technical problems<\/title>\n <link rel=\"stylesheet\" type=\"text\/css\" href=\"\/designs\/themes\/default\/errors.css\"\/>\n <link rel=\"shortcut icon\" href='\/designs\/themes\/default\/favicon.ico' type=\"image\/x-icon\" \/>\n <script type='text\/javascript' src='https:\/\/ajax.googleapis.com\/ajax\/libs\/prototype\/1.7.0.0\/prototype.js'><\/script>\n <script type='text\/javascript'>\n function display_error_message(language) {\n if (!language) {\n var language = ((navigator.language) ? navigator.language : navigator.userLanguage).replace('-', '_');\n }\n element = $(language);\n if (!element) {\n element = $(language.replace(\/_.*$\/, ''));\n }\n if (!element) {\n element = $('en');\n }\n $$('.message').each(function(item) { item.hide() });\n element.getElementsBySelector('h1').each(function(title) { document.title = title.innerHTML; });\n element.show();\n }\n <\/script>\n<\/head>\n<body onload='display_error_message()'>\n <div id='wrap'>\n <div id='header'>\n <div id='logo'> <\/div>\n <div id='details'><b>\"} obj.status \"<\/b> - \" obj.response {\"<\/div>\n <\/div>\n\n <div id='de' style='display: none' class='message'>\n <h1>Kurzzeitiges Systemproblem<\/h1>\n <p>\n Unser technisches Team arbeitet gerade daran, bitte probieren Sie es nachher erneut. Wir entschuldigen uns für die Unannehmlichkeiten.\n <\/p>\n <ul>\n <li><a href='javascript: history.back()'>Zurück<\/a><\/li>\n <li><a href='\/'>Gehe zur Homepage<\/a><\/li>\n <\/ul>\n <\/div>\n\n <div id='en' style='display: none' class='message'>\n <h1>Temporary system problem<\/h1>\n <p>\n Our technical team is working on it, please try again later. Sorry for the inconvenience.\n <\/p>\n <ul>\n <li><a href='javascript: history.back()'>Go back<\/a><\/li>\n <li><a href='\/'>Go to the site home page<\/a><\/li>\n <\/ul>\n <\/div>\n\n <div id='es' style='display: none' class='message'>\n <h1>Temporary system problem<\/h1>\n <p>\n Our technical team is working on it, please try again later. Sorry for the inconvenience.\n <\/p>\n <ul>\n <li><a href='javascript: history.back()'>Go back<\/a><\/li>\n <li><a href='\/'>Go to the site home page<\/a><\/li>\n <\/ul>\n <\/div>\n\n <div id='fr' style='display: none' class='message'>\n <h1>Problème temporaire du système.<\/h1>\n <p>\n Notre équipe technique est en train d'y travailler. Merci de réessayer plus tard. Nous sommes désolés de la gêne occasionnée.\n <\/p>\n <ul>\n <li><a href='javascript: history.back()'>Retour<\/a><\/li>\n <li><a href='\/'>Aller à la page d'accueil du site<\/a><\/li>\n <\/ul>\n <\/div>\n\n <div id='hy' style='display: none' class='message'>\n <h1>Temporary system problem<\/h1>\n <p>\n Our technical team is working on it, please try again later. Sorry for the inconvenience.\n <\/p>\n <ul>\n <li><a href='javascript: history.back()'>Վերադառնալ<\/a><\/li>\n <li><a href='\/'>Go to the site home page<\/a><\/li>\n <\/ul>\n <\/div>\n\n <div id='pt' style='display: none' class='message'>\n <h1>Problema temporário no sistema<\/h1>\n <p>\n Nossa equipe técnica está trabalhando nele, por favor tente mais tarde. Perdoe o incoveniente.\n <\/p>\n <ul>\n <li><a href='javascript: history.back()'>Voltar<\/a><\/li>\n <li><a href='\/'>Ir para a página inicial do site.<\/a><\/li>\n <\/ul>\n <\/div>\n\n <div id='ru' style='display: none' class='message'>\n <h1>Временная ошибка системы<\/h1>\n <p>\n Техники уже работают над проблемой, пожалуйста, попробуйте позже.\n <\/p>\n <ul>\n <li><a href='javascript:history.back()'>Назад<\/a><\/li>\n <li><a href='\/'>Перейти на домашнюю страницу сайта<\/a><\/li>\n <\/ul>\n <\/div>\n\n <div id='languages'>\n <a href=\"javascript: display_error_message('de')\">Deutsch<\/a>\n <a href=\"javascript: display_error_message('en')\">English<\/a>\n <a href=\"javascript: display_error_message('es')\">Español<\/a>\n <a href=\"javascript: display_error_message('fr')\">Français<\/a>\n <a href=\"javascript: display_error_message('hy')\">հայերեն լեզու<\/a>\n <a href=\"javascript: display_error_message('pt')\">Português<\/a>\n <a href=\"javascript: display_error_message('ru')\">русский язык<\/a>\n <\/div>\n\n <\/div>\n<\/body>\n<\/html>\n \"};\n return(deliver);\n}\n","old_contents":"sub vcl_recv {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n if (req.http.Cookie) {\n # We only care about the \"_noosfero_session.*\" cookie, used for\n # authentication.\n if (req.http.Cookie !~ \"_noosfero_session.*\" ) {\n # strip all cookies\n unset req.http.Cookie;\n }\n }\n}\n\nsub vcl_error {\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n\n synthetic {\"\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Transitional\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-transitional.dtd\">\n<html xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n <head>\n <meta http-equiv=\"Content-Type\" content=\"text\/html; charset=utf-8\"\/>\n <meta http-equiv=\"refresh\" content=\"60\"\/>\n <title>Technical problems<\/title>\n <link rel=\"stylesheet\" type=\"text\/css\" href=\"\/designs\/themes\/default\/errors.css\"\/>\n <link rel=\"shortcut icon\" href='\/designs\/themes\/default\/favicon.ico' type=\"image\/x-icon\" \/>\n <script type='text\/javascript' src='https:\/\/ajax.googleapis.com\/ajax\/libs\/prototype\/1.7.0.0\/prototype.js'><\/script>\n <script type='text\/javascript'>\n function display_error_message(language) {\n if (!language) {\n var language = ((navigator.language) ? navigator.language : navigator.userLanguage).replace('-', '_');\n }\n element = $(language);\n if (!element) {\n element = $(language.replace(\/_.*$\/, ''));\n }\n if (!element) {\n element = $('en');\n }\n $$('.message').each(function(item) { item.hide() });\n element.getElementsBySelector('h1').each(function(title) { document.title = title.innerHTML; });\n element.show();\n }\n <\/script>\n<\/head>\n<body onload='display_error_message()'>\n <div id='wrap'>\n <div id='header'>\n <div id='logo'> <\/div>\n <div id='details'><b>\"} obj.status \"<\/b> - \" obj.response {\"<\/div>\n <\/div>\n\n <div id='de' style='display: none' class='message'>\n <h1>Kurzzeitiges Systemproblem<\/h1>\n <p>\n Unser technisches Team arbeitet gerade daran, bitte probieren Sie es nachher erneut. Wir entschuldigen uns für die Unannehmlichkeiten.\n <\/p>\n <ul>\n <li><a href='javascript: history.back()'>Zurück<\/a><\/li>\n <li><a href='\/'>Gehe zur Homepage<\/a><\/li>\n <\/ul>\n <\/div>\n\n <div id='en' style='display: none' class='message'>\n <h1>Temporary system problem<\/h1>\n <p>\n Our technical team is working on it, please try again later. Sorry for the inconvenience.\n <\/p>\n <ul>\n <li><a href='javascript: history.back()'>Go back<\/a><\/li>\n <li><a href='\/'>Go to the site home page<\/a><\/li>\n <\/ul>\n <\/div>\n\n <div id='es' style='display: none' class='message'>\n <h1>Temporary system problem<\/h1>\n <p>\n Our technical team is working on it, please try again later. Sorry for the inconvenience.\n <\/p>\n <ul>\n <li><a href='javascript: history.back()'>Go back<\/a><\/li>\n <li><a href='\/'>Go to the site home page<\/a><\/li>\n <\/ul>\n <\/div>\n\n <div id='fr' style='display: none' class='message'>\n <h1>Problème temporaire du système.<\/h1>\n <p>\n Notre équipe technique est en train d'y travailler. Merci de réessayer plus tard. Nous sommes désolés de la gêne occasionnée.\n <\/p>\n <ul>\n <li><a href='javascript: history.back()'>Retour<\/a><\/li>\n <li><a href='\/'>Aller à la page d'accueil du site<\/a><\/li>\n <\/ul>\n <\/div>\n\n <div id='hy' style='display: none' class='message'>\n <h1>Temporary system problem<\/h1>\n <p>\n Our technical team is working on it, please try again later. Sorry for the inconvenience.\n <\/p>\n <ul>\n <li><a href='javascript: history.back()'>Վերադառնալ<\/a><\/li>\n <li><a href='\/'>Go to the site home page<\/a><\/li>\n <\/ul>\n <\/div>\n\n <div id='pt' style='display: none' class='message'>\n <h1>Problema temporário no sistema<\/h1>\n <p>\n Nossa equipe técnica está trabalhando nele, por favor tente mais tarde. Perdoe o incoveniente.\n <\/p>\n <ul>\n <li><a href='javascript: history.back()'>Voltar<\/a><\/li>\n <li><a href='\/'>Ir para a página inicial do site.<\/a><\/li>\n <\/ul>\n <\/div>\n\n <div id='ru' style='display: none' class='message'>\n <h1>Временная ошибка системы<\/h1>\n <p>\n Техники уже работают над проблемой, пожалуйста, попробуйте позже.\n <\/p>\n <ul>\n <li><a href='javascript:history.back()'>Назад<\/a><\/li>\n <li><a href='\/'>Перейти на домашнюю страницу сайта<\/a><\/li>\n <\/ul>\n <\/div>\n\n <div id='languages'>\n <a href=\"javascript: display_error_message('de')\">Deutsch<\/a>\n <a href=\"javascript: display_error_message('en')\">English<\/a>\n <a href=\"javascript: display_error_message('es')\">Español<\/a>\n <a href=\"javascript: display_error_message('fr')\">Français<\/a>\n <a href=\"javascript: display_error_message('hy')\">հայերեն լեզու<\/a>\n <a href=\"javascript: display_error_message('pt')\">Português<\/a>\n <a href=\"javascript: display_error_message('ru')\">русский язык<\/a>\n <\/div>\n\n <\/div>\n<\/body>\n<\/html>\n \"};\n return(deliver);\n}\n","returncode":0,"stderr":"","license":"agpl-3.0","lang":"VCL"} {"commit":"f9591f061e918d802f9adbe6556777ba28beaff9","subject":"Update devicedetect.vcl to current upstream","message":"Update devicedetect.vcl to current upstream\n","repos":"gquintard\/Varnish-Cache,feld\/Varnish-Cache,gquintard\/Varnish-Cache,feld\/Varnish-Cache,gquintard\/Varnish-Cache,feld\/Varnish-Cache,gquintard\/Varnish-Cache,feld\/Varnish-Cache,feld\/Varnish-Cache","old_file":"etc\/devicedetect.vcl","new_file":"etc\/devicedetect.vcl","new_contents":"# Copyright (c) 2012-2014 Varnish Software AS\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions\n# are met:\n# 1. Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n# 2. Redistributions in binary form must reproduce the above copyright\n# notice, this list of conditions and the following disclaimer in the\n# documentation and\/or other materials provided with the distribution.\n#\n# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n# ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n# SUCH DAMAGE.\n#\n# detectdevice.vcl - regex based device detection for Varnish\n# https:\/\/github.com\/varnishcache\/varnish-devicedetect\/\n#\n# Author: Lasse Karstensen <lkarsten@varnish-software.com>\n\nsub devicedetect {\n\tunset req.http.X-UA-Device;\n\tset req.http.X-UA-Device = \"pc\";\n\n\t# Handle that a cookie may override the detection alltogether.\n\tif (req.http.Cookie ~ \"(?i)X-UA-Device-force\") {\n\t\t\/* ;?? means zero or one ;, non-greedy to match the first. *\/\n\t\tset req.http.X-UA-Device = regsub(req.http.Cookie, \"(?i).*X-UA-Device-force=([^;]+);??.*\", \"\\1\");\n\t\t\/* Clean up our mess in the cookie header *\/\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|; ) *X-UA-Device-force=[^;]+;? *\", \"\\1\");\n\t\t\/* If the cookie header is now empty, or just whitespace, unset it. *\/\n\t\tif (req.http.Cookie ~ \"^ *$\") { unset req.http.Cookie; }\n\t} else {\n if (req.http.User-Agent ~ \"\\(compatible; Googlebot-Mobile\/2.1; \\+http:\/\/www.google.com\/bot.html\\)\" ||\n (req.http.User-Agent ~ \"(Android|iPhone)\" && req.http.User-Agent ~ \"\\(compatible.?; Googlebot\/2.1.?; \\+http:\/\/www.google.com\/bot.html\") ||\n\t\t\t(req.http.User-Agent ~ \"(iPhone|Windows Phone)\" && req.http.User-Agent ~ \"\\(compatible; bingbot\/2.0; \\+http:\/\/www.bing.com\/bingbot.htm\")) {\n set req.http.X-UA-Device = \"mobile-bot\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)(ads|google|bing|msn|yandex|baidu|ro|career|seznam|)bot\" ||\n\t\t req.http.User-Agent ~ \"(?i)(baidu|jike|symantec)spider\" ||\n\t\t req.http.User-Agent ~ \"(?i)scanner\" ||\n\t\t req.http.User-Agent ~ \"(?i)(web)crawler\") {\n\t\t\tset req.http.X-UA-Device = \"bot\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ipad\") { set req.http.X-UA-Device = \"tablet-ipad\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ip(hone|od)\") { set req.http.X-UA-Device = \"mobile-iphone\"; }\n\t\t\/* how do we differ between an android phone and an android tablet?\n\t\t http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent *\/\n\t\telsif (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") { set req.http.X-UA-Device = \"mobile-android\"; }\n\t\t\/\/ android 3\/honeycomb was just about tablet-only, and any phones will probably handle a bigger page layout.\n\t\telsif (req.http.User-Agent ~ \"(?i)android 3\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\t\/* Opera Mobile *\/\n\t\telsif (req.http.User-Agent ~ \"Opera Mobi\") { set req.http.X-UA-Device = \"mobile-smartphone\"; }\n\t\t\/\/ May very well give false positives towards android tablets. Suggestions welcome.\n\t\telsif (req.http.User-Agent ~ \"(?i)android\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\telsif (req.http.User-Agent ~ \"PlayBook; U; RIM Tablet\") { set req.http.X-UA-Device = \"tablet-rim\"; }\n\t\telsif (req.http.User-Agent ~ \"hp-tablet.*TouchPad\") { set req.http.X-UA-Device = \"tablet-hp\"; }\n\t\telsif (req.http.User-Agent ~ \"Kindle\/3\") { set req.http.X-UA-Device = \"tablet-kindle\"; }\n\t\telsif (req.http.User-Agent ~ \"Touch.+Tablet PC\" ||\n\t\t req.http.User-Agent ~ \"Windows NT [0-9.]+; ARM;\" ) {\n\t\t set req.http.X-UA-Device = \"tablet-microsoft\";\n\t\t}\n\t\telsif (req.http.User-Agent ~ \"Mobile.+Firefox\") { set req.http.X-UA-Device = \"mobile-firefoxos\"; }\n\t\telsif (req.http.User-Agent ~ \"^HTC\" ||\n\t\t req.http.User-Agent ~ \"Fennec\" ||\n\t\t req.http.User-Agent ~ \"IEMobile\" ||\n\t\t req.http.User-Agent ~ \"BlackBerry\" ||\n\t\t req.http.User-Agent ~ \"BB10.*Mobile\" ||\n\t\t req.http.User-Agent ~ \"GT-.*Build\/GINGERBREAD\" ||\n\t\t req.http.User-Agent ~ \"SymbianOS.*AppleWebKit\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-smartphone\";\n\t\t}\n\t\telsif (req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)^sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)^nokia\" ||\n\t\t req.http.User-Agent ~ \"(?i)^samsung\" ||\n\t\t req.http.User-Agent ~ \"(?i)^lg\" ||\n\t\t req.http.User-Agent ~ \"(?i)bada\" ||\n\t\t req.http.User-Agent ~ \"(?i)blazer\" ||\n\t\t req.http.User-Agent ~ \"(?i)cellphone\" ||\n\t\t req.http.User-Agent ~ \"(?i)iemobile\" ||\n\t\t req.http.User-Agent ~ \"(?i)midp-2.0\" ||\n\t\t req.http.User-Agent ~ \"(?i)u990\" ||\n\t\t req.http.User-Agent ~ \"(?i)netfront\" ||\n\t\t req.http.User-Agent ~ \"(?i)opera mini\" ||\n\t\t req.http.User-Agent ~ \"(?i)palm\" ||\n\t\t req.http.User-Agent ~ \"(?i)nintendo wii\" ||\n\t\t req.http.User-Agent ~ \"(?i)playstation portable\" ||\n\t\t req.http.User-Agent ~ \"(?i)portalmmm\" ||\n\t\t req.http.User-Agent ~ \"(?i)proxinet\" ||\n\t\t req.http.User-Agent ~ \"(?i)sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)windows\\ ?ce\" ||\n\t\t req.http.User-Agent ~ \"(?i)winwap\" ||\n\t\t req.http.User-Agent ~ \"(?i)eudoraweb\" ||\n\t\t req.http.User-Agent ~ \"(?i)htc\" ||\n\t\t req.http.User-Agent ~ \"(?i)240x320\" ||\n\t\t req.http.User-Agent ~ \"(?i)avantgo\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-generic\";\n\t\t}\n\t}\n}\n","old_contents":"# Copyright (c) 2012-2014 Varnish Software AS\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions\n# are met:\n# 1. Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n# 2. Redistributions in binary form must reproduce the above copyright\n# notice, this list of conditions and the following disclaimer in the\n# documentation and\/or other materials provided with the distribution.\n#\n# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n# ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n# SUCH DAMAGE.\n#\n# detectdevice.vcl - regex based device detection for Varnish\n# https:\/\/github.com\/varnishcache\/varnish-devicedetect\/\n#\n# Author: Lasse Karstensen <lkarsten@varnish-software.com>\n\nsub devicedetect {\n\tunset req.http.X-UA-Device;\n\tset req.http.X-UA-Device = \"pc\";\n\n\t# Handle that a cookie may override the detection alltogether.\n\tif (req.http.Cookie ~ \"(?i)X-UA-Device-force\") {\n\t\t\/* ;?? means zero or one ;, non-greedy to match the first. *\/\n\t\tset req.http.X-UA-Device = regsub(req.http.Cookie, \"(?i).*X-UA-Device-force=([^;]+);??.*\", \"\\1\");\n\t\t\/* Clean up our mess in the cookie header *\/\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|; ) *X-UA-Device-force=[^;]+;? *\", \"\\1\");\n\t\t\/* If the cookie header is now empty, or just whitespace, unset it. *\/\n\t\tif (req.http.Cookie ~ \"^ *$\") { unset req.http.Cookie; }\n\t} else {\n if (req.http.User-Agent ~ \"\\(compatible; Googlebot-Mobile\/2.1; \\+http:\/\/www.google.com\/bot.html\\)\" ||\n (req.http.User-Agent ~ \"iPhone\" && req.http.User-Agent ~ \"\\(compatible; Googlebot\/2.1; \\+http:\/\/www.google.com\/bot.html\")) {\n set req.http.X-UA-Device = \"mobile-bot\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)(ads|google|bing|msn|yandex|baidu|ro|career|seznam|)bot\" ||\n\t\t req.http.User-Agent ~ \"(?i)(baidu|jike|symantec)spider\" ||\n\t\t req.http.User-Agent ~ \"(?i)scanner\" ||\n\t\t req.http.User-Agent ~ \"(?i)(web)crawler\") {\n\t\t\tset req.http.X-UA-Device = \"bot\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ipad\") { set req.http.X-UA-Device = \"tablet-ipad\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ip(hone|od)\") { set req.http.X-UA-Device = \"mobile-iphone\"; }\n\t\t\/* how do we differ between an android phone and an android tablet?\n\t\t http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent *\/\n\t\telsif (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") { set req.http.X-UA-Device = \"mobile-android\"; }\n\t\t\/\/ android 3\/honeycomb was just about tablet-only, and any phones will probably handle a bigger page layout.\n\t\telsif (req.http.User-Agent ~ \"(?i)android 3\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\t\/* Opera Mobile *\/\n\t\telsif (req.http.User-Agent ~ \"Opera Mobi\") { set req.http.X-UA-Device = \"mobile-smartphone\"; }\n\t\t\/\/ May very well give false positives towards android tablets. Suggestions welcome.\n\t\telsif (req.http.User-Agent ~ \"(?i)android\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\telsif (req.http.User-Agent ~ \"PlayBook; U; RIM Tablet\") { set req.http.X-UA-Device = \"tablet-rim\"; }\n\t\telsif (req.http.User-Agent ~ \"hp-tablet.*TouchPad\") { set req.http.X-UA-Device = \"tablet-hp\"; }\n\t\telsif (req.http.User-Agent ~ \"Kindle\/3\") { set req.http.X-UA-Device = \"tablet-kindle\"; }\n\t\telsif (req.http.User-Agent ~ \"Touch.+Tablet PC\" ||\n\t\t req.http.User-Agent ~ \"Windows NT [0-9.]+; ARM;\" ) {\n\t\t set req.http.X-UA-Device = \"tablet-microsoft\";\n\t\t}\n\t\telsif (req.http.User-Agent ~ \"Mobile.+Firefox\") { set req.http.X-UA-Device = \"mobile-firefoxos\"; }\n\t\telsif (req.http.User-Agent ~ \"^HTC\" ||\n\t\t req.http.User-Agent ~ \"Fennec\" ||\n\t\t req.http.User-Agent ~ \"IEMobile\" ||\n\t\t req.http.User-Agent ~ \"BlackBerry\" ||\n\t\t req.http.User-Agent ~ \"BB10.*Mobile\" ||\n\t\t req.http.User-Agent ~ \"GT-.*Build\/GINGERBREAD\" ||\n\t\t req.http.User-Agent ~ \"SymbianOS.*AppleWebKit\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-smartphone\";\n\t\t}\n\t\telsif (req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)^sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)^nokia\" ||\n\t\t req.http.User-Agent ~ \"(?i)^samsung\" ||\n\t\t req.http.User-Agent ~ \"(?i)^lg\" ||\n\t\t req.http.User-Agent ~ \"(?i)bada\" ||\n\t\t req.http.User-Agent ~ \"(?i)blazer\" ||\n\t\t req.http.User-Agent ~ \"(?i)cellphone\" ||\n\t\t req.http.User-Agent ~ \"(?i)iemobile\" ||\n\t\t req.http.User-Agent ~ \"(?i)midp-2.0\" ||\n\t\t req.http.User-Agent ~ \"(?i)u990\" ||\n\t\t req.http.User-Agent ~ \"(?i)netfront\" ||\n\t\t req.http.User-Agent ~ \"(?i)opera mini\" ||\n\t\t req.http.User-Agent ~ \"(?i)palm\" ||\n\t\t req.http.User-Agent ~ \"(?i)nintendo wii\" ||\n\t\t req.http.User-Agent ~ \"(?i)playstation portable\" ||\n\t\t req.http.User-Agent ~ \"(?i)portalmmm\" ||\n\t\t req.http.User-Agent ~ \"(?i)proxinet\" ||\n\t\t req.http.User-Agent ~ \"(?i)sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)windows\\ ?ce\" ||\n\t\t req.http.User-Agent ~ \"(?i)winwap\" ||\n\t\t req.http.User-Agent ~ \"(?i)eudoraweb\" ||\n\t\t req.http.User-Agent ~ \"(?i)htc\" ||\n\t\t req.http.User-Agent ~ \"(?i)240x320\" ||\n\t\t req.http.User-Agent ~ \"(?i)avantgo\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-generic\";\n\t\t}\n\t}\n}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"843e2b7f974c98ee82eadc9a1dc55f9492659155","subject":"include excludes without sorting if above 100","message":"include excludes without sorting if above 100\n","repos":"JakeChampion\/polyfill-service,JakeChampion\/polyfill-service","old_file":"fastly\/vcl\/main.vcl","new_file":"fastly\/vcl\/main.vcl","new_contents":"import querystring;\n\nsub sort_comma_separated_value {\n\t# This function takes a CSV and tranforms it into a url where each\n\t# comma-separated-value is a query-string parameter and then uses \n\t# Fastly's querystring.sort function to sort the values. Once sorted\n\t# it then turn the query-parameters back into a CSV.\n\t# Set the CSV on the header `Sort-Value`.\n\t# Returns the sorted CSV on the header `Sorted-Value`.\n\tdeclare local var.value STRING;\n\tset var.value = req.http.Sort-value;\n\n\t# If query value does not exist or is empty, set it to \"\"\n\tset var.value = if(var.value != \"\", var.value, \"\");\n\n\t# Replace all `&` characters with `^`, this is because `&` would break the value up into pieces.\n\tset var.value = regsuball(var.value, \"&\", \"^\");\n\n\t# Replace all `,` characters with `&` to break them into individual query values\n\t# Append `1-` infront of all the query values to make them simpler to transform later\n\tset var.value = \"1-\" regsuball(var.value, \",\", \"&1-\");\n\t\n\t# Create a querystring-like string in order for querystring.sort to work.\n\tset var.value = querystring.sort(\"?\" var.value);\n\n\t# Grab all the query values from the sorted url\n\tset var.value = regsub(var.value, \"\\?\", \"\");\n\t\n\t# Reverse all the previous transformations to get back the single `features` query value value\n\tset var.value = regsuball(var.value, \"1-\", \"\");\n\tset var.value = regsuball(var.value, \"&\", \",\");\n\tset var.value = regsuball(var.value, \"\\^\", \"&\");\n\n\tset req.http.Sorted-Value = var.value;\n}\n\nsub normalise_querystring_parameters_for_polyfill_bundle {\n\t# Store the url without the querystring into a temporary header.\n\tdeclare local var.url STRING;\n\tset var.url = querystring.remove(req.url);\n\n\tdeclare local var.querystring STRING;\n\tset var.querystring = \"?\";\n\n\t# Remove all querystring parameters which are not part of the public API.\n\t# set req.url = querystring.regfilter_except(req.url, \"^(features|excludes|rum|unknown|flags|version|ua|callback|compression)$\");\n\n\t# (?i) makes the regex case-insensitive\n\t# The regex will match only if their are characters after `features=` which are not an ampersand (&).\n\tif (req.url.qs ~ \"(?i)[^&=]*features=([^&]+)\") {\n\t\t# Parameter has already been set, use the already set value.\n\t\t# re.group.1 is the first regex capture group in the regex above.\n\t\tif (std.strlen(re.group.1) < 100) {\n\t\t\t# We add the value of the features parameter to this header\n\t\t\t# This is to be able to have sort_comma_separated_value sort the value\n\t\t\tset req.http.Sort-Value = urldecode(re.group.1);\n\t\t\tcall sort_comma_separated_value;\n\t\t\t# The header Sorted-Value now contains the sorted version of the features parameter.\n\t\t\tset var.querystring = querystring.set(var.querystring, \"features\", req.http.Sorted-Value);\n\t\t} else {\n\t\t\tset var.querystring = querystring.set(var.querystring, \"features\", re.group.1);\n\t\t}\n\t} else {\n\t\t# Parameter has not been set, use the default value.\n\t\tset var.querystring = querystring.set(var.querystring, \"features\", \"default\");\n\t}\n\t\n\t# (?i) makes the regex case-insensitive\n\t# The regex will match only if their are characters after `excludes=` which are not an ampersand (&).\n\tif (req.url.qs ~ \"(?i)[^&=]*excludes=([^&]+)\") {\n\t\t# Parameter has already been set, use the already set value.\n\t\t# re.group.1 is the first regex capture group in the regex above.\n\t\tif (std.strlen(re.group.1) < 100) {\n\t\t\t# We add the value of the excludes parameter to this header\n\t\t\t# This is to be able to have sort_comma_separated_value sort the value\n\t\t\tset req.http.Sort-Value = urldecode(re.group.1);\n\t\t\tcall sort_comma_separated_value;\n\t\t\t# The header Sorted-Value now contains the sorted version of the excludes parameter.\n\t\t\tset var.querystring = querystring.set(var.querystring, \"excludes\", req.http.Sorted-Value);\n\t\t} else {\n\t\t\tset var.querystring = querystring.set(var.querystring, \"excludes\", re.group.1);\n\t\t}\n\t} else {\n\t\t# If excludes is not set, set to default value \"\"\n\t\tset var.querystring = var.querystring \"&excludes=\";\n\t}\n\t\n\t# If rum is not set, set to default value \"0\"\n\tif (req.url.qs !~ \"(?i)[^&=]*rum=([^&]+)\") {\n\t\tset var.querystring = querystring.set(var.querystring, \"rum\", \"0\");\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"rum\", re.group.1);\n\t}\n\t\n\t# If unknown is not set, set to default value \"polyfill\"\n\tif (req.url.qs !~ \"(?i)[^&=]*unknown=([^&]+)\") {\n\t\tset var.querystring = querystring.set(var.querystring, \"unknown\", \"polyfill\");\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"unknown\", re.group.1);\n\t}\n\n\t# If flags is not set, set to default value \"\"\n\tif (req.url.qs !~ \"(?i)[^&=]*flags=([^&]+)\") {\n\t\tset var.querystring = var.querystring \"&flags=\";\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"flags\", re.group.1);\n\t}\n\n\t# If version is not set, set to default value \"\"\n\tdeclare local var.version STRING;\n\tif (req.url.qs !~ \"(?i)[^&=]*version=([^&]+)\") {\n\t\tset var.querystring = var.querystring \"&version=\";\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"version\", re.group.1);\n\t}\n\t\n\t# If ua is not set, normalise the User-Agent header based upon the version of the polyfill-library that has been requested.\n\tif (req.url.qs !~ \"(?i)[^&=]*ua=([^&]+)\") {\n\t\tif (req.url.qs ~ \"(?i)[^&=]*version=3\\.25\\.1(&|$)\") {\n\t\t\tcall normalise_user_agent_3_25_1;\n\t\t} else {\n\t\t\tcall normalise_user_agent_latest;\n\t\t}\n\t\tset var.querystring = querystring.set(var.querystring, \"ua\", req.http.Normalized-User-Agent);\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"ua\", re.group.1);\n\t}\n\n\t# If callback is not set, set to default value \"\"\n\tif (req.url.qs !~ \"(?i)[^&=]*callback=([^&]+)\") {\n\t\tset var.querystring = var.querystring \"&callback=\";\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"callback\", re.group.1);\n\t}\n\t\n\t# If compression is not set, use the best compression that the user-agent supports.\n\tif (req.url.qs !~ \"(?i)[^&=]*compression=([^&]+)\") {\n\t\t# When Fastly adds Brotli into the Accept-Encoding normalisation we can replace this with: \n\t\t# `set var.querystring = querystring.set(var.querystring, \"compression\", req.http.Accept-Encoding || \"\")`\n\n\t\t# Before SP2, IE\/6 doesn't always read and cache gzipped content correctly.\n\t\tif (req.http.Fastly-Orig-Accept-Encoding && req.http.User-Agent !~ \"MSIE 6\") {\n\t\t\tif (req.http.Fastly-Orig-Accept-Encoding ~ \"br\") {\n\t\t\t\tset var.querystring = querystring.set(var.querystring, \"compression\", \"br\");\n\t\t\t} elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"gzip\") {\n\t\t\t\tset var.querystring = querystring.set(var.querystring, \"compression\", \"gzip\");\n\t\t\t} else {\n\t\t\t\tset var.querystring = var.querystring \"&compression=\";\n\t\t\t}\n\t\t} else {\n\t\t\tset var.querystring = var.querystring \"&compression=\";\n\t\t}\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"compression\", re.group.1);\n\t}\n\tset req.url = var.url var.querystring;\n}\n\ninclude \"ua_parser.vcl\";\ninclude \"normalise-user-agent-3-25-1.vcl\";\ninclude \"normalise-user-agent-latest.vcl\";\n\n# The Fastly VCL boilerplate.\ninclude \"fastly-boilerplate-begin.vcl\";\n\ninclude \"breadcrumbs.vcl\";\ninclude \"redirects.vcl\";\ninclude \"synthetic-responses.vcl\";\ninclude \"polyfill-service.vcl\";\n\n# Finally include the last bit of VCL, this _must_ be last!\ninclude \"fastly-boilerplate-end.vcl\";\n","old_contents":"import querystring;\n\nsub sort_comma_separated_value {\n\t# This function takes a CSV and tranforms it into a url where each\n\t# comma-separated-value is a query-string parameter and then uses \n\t# Fastly's querystring.sort function to sort the values. Once sorted\n\t# it then turn the query-parameters back into a CSV.\n\t# Set the CSV on the header `Sort-Value`.\n\t# Returns the sorted CSV on the header `Sorted-Value`.\n\tdeclare local var.value STRING;\n\tset var.value = req.http.Sort-value;\n\n\t# If query value does not exist or is empty, set it to \"\"\n\tset var.value = if(var.value != \"\", var.value, \"\");\n\n\t# Replace all `&` characters with `^`, this is because `&` would break the value up into pieces.\n\tset var.value = regsuball(var.value, \"&\", \"^\");\n\n\t# Replace all `,` characters with `&` to break them into individual query values\n\t# Append `1-` infront of all the query values to make them simpler to transform later\n\tset var.value = \"1-\" regsuball(var.value, \",\", \"&1-\");\n\t\n\t# Create a querystring-like string in order for querystring.sort to work.\n\tset var.value = querystring.sort(\"?\" var.value);\n\n\t# Grab all the query values from the sorted url\n\tset var.value = regsub(var.value, \"\\?\", \"\");\n\t\n\t# Reverse all the previous transformations to get back the single `features` query value value\n\tset var.value = regsuball(var.value, \"1-\", \"\");\n\tset var.value = regsuball(var.value, \"&\", \",\");\n\tset var.value = regsuball(var.value, \"\\^\", \"&\");\n\n\tset req.http.Sorted-Value = var.value;\n}\n\nsub normalise_querystring_parameters_for_polyfill_bundle {\n\t# Store the url without the querystring into a temporary header.\n\tdeclare local var.url STRING;\n\tset var.url = querystring.remove(req.url);\n\n\tdeclare local var.querystring STRING;\n\tset var.querystring = \"?\";\n\n\t# Remove all querystring parameters which are not part of the public API.\n\t# set req.url = querystring.regfilter_except(req.url, \"^(features|excludes|rum|unknown|flags|version|ua|callback|compression)$\");\n\n\t# (?i) makes the regex case-insensitive\n\t# The regex will match only if their are characters after `features=` which are not an ampersand (&).\n\tif (req.url.qs ~ \"(?i)[^&=]*features=([^&]+)\") {\n\t\t# Parameter has already been set, use the already set value.\n\t\t# re.group.1 is the first regex capture group in the regex above.\n\t\tif (std.strlen(re.group.1) < 100) {\n\t\t\t# We add the value of the features parameter to this header\n\t\t\t# This is to be able to have sort_comma_separated_value sort the value\n\t\t\tset req.http.Sort-Value = urldecode(re.group.1);\n\t\t\tcall sort_comma_separated_value;\n\t\t\t# The header Sorted-Value now contains the sorted version of the features parameter.\n\t\t\tset var.querystring = querystring.set(var.querystring, \"features\", req.http.Sorted-Value);\n\t\t} else {\n\t\t\tset var.querystring = querystring.set(var.querystring, \"features\", re.group.1);\n\t\t}\n\t} else {\n\t\t# Parameter has not been set, use the default value.\n\t\tset var.querystring = querystring.set(var.querystring, \"features\", \"default\");\n\t}\n\t\n\t# (?i) makes the regex case-insensitive\n\t# The regex will match only if their are characters after `excludes=` which are not an ampersand (&).\n\tif (req.url.qs ~ \"(?i)[^&=]*excludes=([^&]+)\") {\n\t\t# Parameter has already been set, use the already set value.\n\t\t# re.group.1 is the first regex capture group in the regex above.\n\t\tif (std.strlen(re.group.1) < 100) {\n\t\t\t# We add the value of the excludes parameter to this header\n\t\t\t# This is to be able to have sort_comma_separated_value sort the value\n\t\t\tset req.http.Sort-Value = urldecode(re.group.1);\n\t\t\tcall sort_comma_separated_value;\n\t\t\t# The header Sorted-Value now contains the sorted version of the excludes parameter.\n\t\t\tset var.querystring = querystring.set(var.querystring, \"excludes\", req.http.Sorted-Value);\n\t\t}\n\t} else {\n\t\t# If excludes is not set, set to default value \"\"\n\t\tset var.querystring = var.querystring \"&excludes=\";\n\t}\n\t\n\t# If rum is not set, set to default value \"0\"\n\tif (req.url.qs !~ \"(?i)[^&=]*rum=([^&]+)\") {\n\t\tset var.querystring = querystring.set(var.querystring, \"rum\", \"0\");\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"rum\", re.group.1);\n\t}\n\t\n\t# If unknown is not set, set to default value \"polyfill\"\n\tif (req.url.qs !~ \"(?i)[^&=]*unknown=([^&]+)\") {\n\t\tset var.querystring = querystring.set(var.querystring, \"unknown\", \"polyfill\");\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"unknown\", re.group.1);\n\t}\n\n\t# If flags is not set, set to default value \"\"\n\tif (req.url.qs !~ \"(?i)[^&=]*flags=([^&]+)\") {\n\t\tset var.querystring = var.querystring \"&flags=\";\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"flags\", re.group.1);\n\t}\n\n\t# If version is not set, set to default value \"\"\n\tdeclare local var.version STRING;\n\tif (req.url.qs !~ \"(?i)[^&=]*version=([^&]+)\") {\n\t\tset var.querystring = var.querystring \"&version=\";\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"version\", re.group.1);\n\t}\n\t\n\t# If ua is not set, normalise the User-Agent header based upon the version of the polyfill-library that has been requested.\n\tif (req.url.qs !~ \"(?i)[^&=]*ua=([^&]+)\") {\n\t\tif (req.url.qs ~ \"(?i)[^&=]*version=3\\.25\\.1(&|$)\") {\n\t\t\tcall normalise_user_agent_3_25_1;\n\t\t} else {\n\t\t\tcall normalise_user_agent_latest;\n\t\t}\n\t\tset var.querystring = querystring.set(var.querystring, \"ua\", req.http.Normalized-User-Agent);\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"ua\", re.group.1);\n\t}\n\n\t# If callback is not set, set to default value \"\"\n\tif (req.url.qs !~ \"(?i)[^&=]*callback=([^&]+)\") {\n\t\tset var.querystring = var.querystring \"&callback=\";\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"callback\", re.group.1);\n\t}\n\t\n\t# If compression is not set, use the best compression that the user-agent supports.\n\tif (req.url.qs !~ \"(?i)[^&=]*compression=([^&]+)\") {\n\t\t# When Fastly adds Brotli into the Accept-Encoding normalisation we can replace this with: \n\t\t# `set var.querystring = querystring.set(var.querystring, \"compression\", req.http.Accept-Encoding || \"\")`\n\n\t\t# Before SP2, IE\/6 doesn't always read and cache gzipped content correctly.\n\t\tif (req.http.Fastly-Orig-Accept-Encoding && req.http.User-Agent !~ \"MSIE 6\") {\n\t\t\tif (req.http.Fastly-Orig-Accept-Encoding ~ \"br\") {\n\t\t\t\tset var.querystring = querystring.set(var.querystring, \"compression\", \"br\");\n\t\t\t} elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"gzip\") {\n\t\t\t\tset var.querystring = querystring.set(var.querystring, \"compression\", \"gzip\");\n\t\t\t} else {\n\t\t\t\tset var.querystring = var.querystring \"&compression=\";\n\t\t\t}\n\t\t} else {\n\t\t\tset var.querystring = var.querystring \"&compression=\";\n\t\t}\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"compression\", re.group.1);\n\t}\n\tset req.url = var.url var.querystring;\n}\n\ninclude \"ua_parser.vcl\";\ninclude \"normalise-user-agent-3-25-1.vcl\";\ninclude \"normalise-user-agent-latest.vcl\";\n\n# The Fastly VCL boilerplate.\ninclude \"fastly-boilerplate-begin.vcl\";\n\ninclude \"breadcrumbs.vcl\";\ninclude \"redirects.vcl\";\ninclude \"synthetic-responses.vcl\";\ninclude \"polyfill-service.vcl\";\n\n# Finally include the last bit of VCL, this _must_ be last!\ninclude \"fastly-boilerplate-end.vcl\";\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"7670a25e80f760add83896db931551afb0a378d2","subject":"update varnish vcl to support multiple hosts","message":"update varnish vcl to support multiple hosts\n","repos":"KhanovaSkola\/khanovaskola-v3,KhanovaSkola\/khanovaskola-v3,KhanovaSkola\/khanovaskola-v3,KhanovaSkola\/khanovaskola-v3,KhanovaSkola\/khanovaskola-v3,KhanovaSkola\/khanovaskola-v3","old_file":"production\/varnish.vcl","new_file":"production\/varnish.vcl","new_contents":"vcl 4.0;\n\n# Disable esi xml check on varnish Startup\n# Example:\n# DAEMON_OPTS=\"-a :6081 \\\n# -T localhost:6082 \\\n# -p feature=+esi_disable_xml_check\n# -p feature=+esi_ignore_https\n#\n\nbackend dev {\n .host = \"127.0.0.1\";\n .port = \"8085\";\n}\nbackend beta {\n .host = \"127.0.0.1\";\n .port = \"8086\";\n}\n\nsub vcl_recv {\n\t\tif (req.http.host == \"dev.khanovaskola.cz\") {\n\t\t\tset req.backend = dev;\n\t\t}\n\t\tif (req.http.host == \"beta.khanovaskola.cz\") {\n set req.backend = beta;\n }\n\n if (req.method != \"GET\") {\n return (pass);\n }\n if (req.http.Cookie ~ \"\\bvarnish-force=pass\") {\n return (pass);\n }\n\n return (hash);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n return(lookup);\n}\n\nsub vcl_backend_response {\n if (beresp.http.Cache-Control != \"public\") {\n set beresp.uncacheable = true;\n set beresp.ttl = 3m;\n return (deliver);\n }\n\n set beresp.do_esi = true;\n set beresp.ttl = 15m;\n\n unset beresp.http.Set-Cookie;\n}\n","old_contents":"vcl 4.0;\n\n# Disable esi xml check on varnish Startup\n# Example:\n# DAEMON_OPTS=\"-a :6081 \\\n# -T localhost:6082 \\\n# -p feature=+esi_disable_xml_check\n# -p feature=+esi_ignore_https\n#\n\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8085\";\n}\n\nsub vcl_recv {\n if (req.method != \"GET\") {\n return (pass);\n }\n if (req.http.Cookie ~ \"\\bvarnish-force=pass\") {\n return (pass);\n }\n\n return (hash);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n return(lookup);\n}\n\nsub vcl_backend_response {\n if (beresp.http.Cache-Control != \"public\") {\n set beresp.uncacheable = true;\n set beresp.ttl = 3m;\n return (deliver);\n }\n\n set beresp.do_esi = true;\n set beresp.ttl = 15m;\n\n unset beresp.http.Set-Cookie;\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"5a33bb0576e1785ef2acdb3b17913d5bd1d942d1","subject":"Revert \"Only bypass for logged in users, not logged out\"","message":"Revert \"Only bypass for logged in users, not logged out\"\n\nThis reverts commit dad7c5232be6929aea02262aa5a784d30cbe6880.\n","repos":"genesis\/wordpress,evolution\/wordpress,jalevin\/wordpress,jalevin\/wordpress,evolution\/wordpress,evolution\/genesis-wordpress,evolution\/genesis-wordpress,evolution\/genesis-wordpress,evolution\/genesis-wordpress,evolution\/wordpress,genesis\/wordpress,genesis\/wordpress,jalevin\/wordpress,evolution\/wordpress,jalevin\/wordpress,genesis\/wordpress,evolution\/genesis-wordpress,genesis\/wordpress,evolution\/genesis-wordpress,evolution\/wordpress,genesis\/wordpress,jalevin\/wordpress","old_file":"provisioning\/roles\/varnish\/files\/etc-varnish\/conf.d\/receive\/wordpress.vcl","new_file":"provisioning\/roles\/varnish\/files\/etc-varnish\/conf.d\/receive\/wordpress.vcl","new_contents":"# Pass all local or login\/admin requests straight through\nif (req.http.Host ~ \"^local\\.\" || (req.url ~ \"wp-(login|admin)\")) {\n return (pass);\n}\n\nif (req.http.Cookie ~ \"^wp-\" || req.http.Cookie ~ \"^wordpress_\") {\n return (pass);\n}\n\n# Drop any cookies sent to Wordpress.\nif (!(req.url ~ \"wp-(login|admin)\")) {\n unset req.http.Cookie;\n}\n\n# Anything else left?\nif (!req.http.Cookie) {\n unset req.http.Cookie;\n}\n\n# Try a cache-lookup\nreturn (lookup);\n","old_contents":"# Pass all local or login\/admin requests straight through\nif (req.http.Host ~ \"^local\\.\" || (req.url ~ \"wp-(login|admin)\")) {\n return (pass);\n}\n\nif (req.http.Cookie ~ \"^wordpress_logged_in_\") {\n return (pass);\n}\n\n# Drop any cookies sent to Wordpress.\nif (!(req.url ~ \"wp-(login|admin)\")) {\n unset req.http.Cookie;\n}\n\n# Anything else left?\nif (!req.http.Cookie) {\n unset req.http.Cookie;\n}\n\n# Try a cache-lookup\nreturn (lookup);\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"0001096be212c4efe40da24ec2ca24231e604466","subject":"Added HTML and bootstrap commands","message":"Added HTML and bootstrap commands\n","repos":"aschneiderman\/vim-voice","old_file":"gvim.vcl","new_file":"gvim.vcl","new_contents":"# Voice commands for gvim\r\n\r\ninclude folders.vch;\r\ninclude numbers.vch;\r\ninclude letters.vch;\r\ninclude pandas.vch;\r\n\r\nEdit [My] Configuration = ':e $' 'MYVIMRC' {Enter};\r\n\r\n<delimiters> := (Quotes = '\"' | 'Single Quotes' = \"'\" | 'Double Quotes' = '\"' | Parentheses = '(' \r\n\t\t| Brackets = '[' | 'Curly Braces' = '{' | Braces = '{' | HTML = '<' | Tags = '<');\r\n\r\n# --- File Management ---------------\r\nOpen Document = {Alt+f} o;\r\nList Files = {Esc} ':bro ol' {Enter};\r\nFile <numbers> = $1 {Enter};\r\nLatest File = {Esc} ':bro ol' {Enter} 1{Enter};\r\n\r\nShow (Projects | Folders) = {Esc}':e C:\\Voice\\folders.vch' {Enter} Wait(100) {Down_9};\r\n[Open] Project <folder> = {Esc} ':e ' $1 {Enter} Wait(100) {Down_9};\r\n[Open] Current Project = {Esc} ':e .' {Enter} Wait(100) {Down_9};\r\nUp Directory = '-';\r\nSearch [Directory] <letters> = '\/^' $1;\r\n# :Sex = directory of current file \r\n# :Vex for vertical split\r\n# :sp. = Split horizontally on current directory (:vsp. For vertical)\r\n# % = new file\r\n\r\n(List Buffers = 'ls' | Buffer List = 'ls' | 'Next Buffer' = 'bn' | 'Last Buffer' = 'bp') = ':' $1 {Enter};\r\n\r\n\r\nSave Document = {Esc} Wait(100) ':w' {Enter};\r\nSave As = {Alt+f} a;\r\nGo (Quit = 'quit' | Close = 'close' | 'Close without saving' = 'close!' | Set = 'set') = ':' $1 {Enter};\r\n[Go] Quit without Saving = {Esc} Wait(100) ':quit!' {Enter};\r\n\r\n\r\n# --- Basic Navigation ---------------\r\n<numbers> (Up = 'k' | Down = 'j' | Right = 'l' | Left = 'h') = $1 $2;\r\nHoma = {Esc} 0;\r\nEnda = {Esc} '$';\r\n(Top | Go to Top) = {Esc} gg;\r\n(Bottom | Go to Bottom) = {Esc} G;\r\n(Move Forward | Move Right | Go Forward) <numbers> (words = 'w' | blocks = '}') = $2 $3;\r\n(Move Forward | Move Right | Go Forward) <numbers> (end | enda) words = $2 'e';\r\n(Move Back | Move Left | Go Back) <numbers> (words = 'b' | blocks = '{') = $2 $3;\r\nFine Text <letters> = {Esc} f $1;\r\nFind Back <letters> = {Esc} F $1;\r\nFine Number 1..9 = {Esc} '\/' $1 {Enter};\r\nNext Fine = n;\r\nLine 1..100 = {Esc} ':' $1 {Enter};\r\n\r\n\r\n# --- Basic Editing ---------------\r\n(Do | Go) (Insert = 'i' | Append = 'A' | \rEscape = '{Esc}') = $2;\r\n(Insert = 'i' | \rEscape = '{Esc}') = $1;\r\nNexta = {Esc} A {Enter};\r\n\r\n(Do Again | Repeat That) = '.';\r\n(Undo | Undo That) = {Esc} u;\r\nRedo = {Esc} {Ctrl+r};\r\n\r\n(Kill = 'x') <numbers> = $2 $1;\r\n(Kill | Delete) Word = 'dw';\r\n(Kill | Delete) <numbers> Words = 'd' $2 'w';\r\nDee Dee = 'dd';\r\nCut to End of Line = 'd$';\r\nCut to End of Word = 'de';\r\n\r\n('Go Visual' | Mark | 'Visual Mode') = V;\r\n('Delete That' = 'd' | 'Yank That' = 'y' | 'Paste That' = 'p' | 'Change That' = 'c') = $1;\r\nCopy That = '\"*y';\r\nCopy Line = {Esc} V Wait(100) '\"*y';\r\nSelect Line = {Esc} V;\r\n\r\ndo test = {Esc} i Wait(100) \"strawberry\";\r\n\r\n\r\n(Delete= 'd' | Change = 'c') between <delimiters> = $1 i $2;\r\n(Delete= 'd' | Change = 'c') (Next = '\/' | Last = '?') <delimiters> = {Esc} $2 $3 {Enter} $1 i $3;\r\n(Delete= 'd' | Change = 'c') (Next = '\/' | Last = '?') \r\n\t(Heading = '<h' | Header = '<h' | Paragraph = '<p') \r\n\t= {Esc} $2 '\\c' $3 {Enter} $1 i t;\r\n\r\n\r\n\r\n\r\nPaste That = {Alt+e} p;\r\nSelect All = {Alt+e} s {Enter};\r\nGrab Everything = {Alt+e} s {Enter} Wait(100) {Alt+e} c {Enter} Wait(100) {Alt+Tab};\r\n\r\n\r\n\r\n\r\n1..20 Spaces = Repeat($1, ' ');\r\n\r\n\r\nDo Ultisnips = {Esc} ':UltiSnipsEdit'{Enter};\r\n\r\n\r\n(Next = 'j' | Last = 'k') Tag = {Ctrl+$1};\r\nStart Snippet= {Esc} i 'snippet {Enter} {Enter}endsnippet' {Esc} {Up_2} A;\r\nStart (\r\n\tD3 = 'd3_template' | Code = 'D3_code_wrapper'\r\n| \tform | 'form text' | 'form button' | 'form select'\r\n|\thref\r\n) = {Esc} i $1 Wait(100) {Tab};\r\n\r\n\r\n\r\nDelete Line = 'dd';\r\nDelete <numbers> Lines = $1 'dd';\r\n\r\n\r\n\r\n\r\n# --- HTML and Bootstrap commands (until I'm sure I can get Ultisnips to work) ------------\r\nNext One = {Esc} A;\r\nStart Div (id | class) = '<div ' $1 '= \"\">' Wait(100) {Left_2};\r\nStop Div = '<\/div>' {Enter};\r\nStart Columns = {Esc} i Wait(100) '<div class=\"container\">{Enter}<div class=\"row\">{Enter}'\r\n\t\t {Enter} '<\/div>' {Enter} '<\/div>' {Esc} {Up_3} Wait(100) A;\r\nStart Column 1..12 = {Esc} a '<div class=\"col-md-' $1 '\">' {Enter} '<\/div>'{Enter} {Esc} {Up_2} Wait(100) A;\r\n\r\n# Paste Image = {Esc} a' <img align=right hspace=\"7\" width=\"200\" src=\"' {Ctrl+v} '\" \/>';\r\nPaste Image = {Esc} a ' <img align=right hspace=\"7\" src=\"' {Esc} p a '\" \/>';\r\n\r\n### NOTE: need to add the join command.\r\n# Try J\r\n\r\n\r\n\r\n# ---Things to do\r\n# change the configuration file\r\n\r\n\r\n# Commands to add:\r\n# g; - last place I was where I made a change\r\n# Ctrl-o - If I jump to a place, copy a line, I can snap back \r\n# :9yank - copy line 9\r\n# :9t16 - copy line 9 to line 16\r\n# :9. - copy line 9 to current position \r\n\r\n\r\n# Commands I'm not sure about\r\n# H,M,L: top, middle, and bottom of screen","old_contents":"# Voice commands for gvim\r\n\r\ninclude folders.vch;\r\ninclude numbers.vch;\r\ninclude letters.vch;\r\ninclude pandas.vch;\r\n\r\nEdit [My] Configuration = ':e $' 'MYVIMRC' {Enter};\r\n\r\n<delimiters> := (Quotes = '\"' | 'Single Quotes' = \"'\" | 'Double Quotes' = '\"' | Parentheses = '(' \r\n\t\t| Brackets = '[' | 'Curly Braces' = '{' | Braces = '{' | HTML = '<' | Tags = '<');\r\n\r\n# --- File Management ---------------\r\nOpen Document = {Alt+f} o;\r\nList Files = {Esc} ':bro ol' {Enter};\r\nFile <numbers> = $1 {Enter};\r\nLatest File = {Esc} ':bro ol' {Enter} 1{Enter};\r\n\r\nShow (Projects | Folders) = {Esc}':e C:\\Voice\\folders.vch' {Enter} Wait(100) {Down_9};\r\n[Open] Project <folder> = {Esc} ':e ' $1 {Enter} Wait(100) {Down_9};\r\n[Open] Current Project = {Esc} ':e .' {Enter} Wait(100) {Down_9};\r\nUp Directory = '-';\r\nSearch [Directory] <letters> = '\/^' $1;\r\n# :Sex = directory of current file \r\n# :Vex for vertical split\r\n# :sp. = Split horizontally on current directory (:vsp. For vertical)\r\n# % = new file\r\n\r\n(List Buffers = 'ls' | Buffer List = 'ls' | 'Next Buffer' = 'bn' | 'Last Buffer' = 'bp') = ':' $1 {Enter};\r\n\r\n\r\nSave Document = {Esc} Wait(100) ':w' {Enter};\r\nSave As = {Alt+f} a;\r\nGo (Quit = 'quit' | Close = 'close' | 'Close without saving' = 'close!' | Set = 'set') = ':' $1 {Enter};\r\n[Go] Quit without Saving = {Esc} Wait(100) ':quit!' {Enter};\r\n\r\n\r\n# --- Basic Navigation ---------------\r\n<numbers> (Up = 'k' | Down = 'j' | Right = 'l' | Left = 'h') = $1 $2;\r\nHoma = {Esc} 0;\r\nEnda = {Esc} '$';\r\n(Top | Go to Top) = {Esc} gg;\r\n(Bottom | Go to Bottom) = {Esc} G;\r\n(Move Forward | Move Right | Go Forward) <numbers> (words = 'w' | blocks = '}') = $2 $3;\r\n(Move Forward | Move Right | Go Forward) <numbers> (end | enda) words = $2 'e';\r\n(Move Back | Move Left | Go Back) <numbers> (words = 'b' | blocks = '{') = $2 $3;\r\nFine Text <letters> = {Esc} f $1;\r\nFind Back <letters> = {Esc} F $1;\r\nFine Number 1..9 = {Esc} '\/' $1 {Enter};\r\nNext Fine = n;\r\nLine 1..100 = {Esc} ':' $1 {Enter};\r\n\r\n\r\n# --- Basic Editing ---------------\r\n(Do | Go) (Insert = 'i' | Append = 'A' | \rEscape = '{Esc}') = $2;\r\n(Insert = 'i' | \rEscape = '{Esc}') = $1;\r\nNexta = {Esc} A {Enter};\r\n\r\n(Do Again | Repeat That) = '.';\r\n(Undo | Undo That) = {Esc} u;\r\nRedo = {Esc} {Ctrl+r};\r\n\r\n(Kill = 'x') <numbers> = $2 $1;\r\n(Kill | Delete) Word = 'dw';\r\n(Kill | Delete) <numbers> Words = 'd' $2 'w';\r\nDee Dee = 'dd';\r\nCut to End of Line = 'd$';\r\nCut to End of Word = 'de';\r\n\r\n('Go Visual' | Mark | 'Visual Mode') = V;\r\n('Delete That' = 'd' | 'Copy That' = 'y' | 'Yank That' = 'y' | 'Paste That' = 'p' | 'Change That' = 'c') = $1;\r\n\r\n(Delete= 'd' | Change = 'c') between <delimiters> = $1 i $2;\r\n(Delete= 'd' | Change = 'c') (Next = '\/' | Last = '?') <delimiters> = {Esc} $2 $3 {Enter} $1 i $3;\r\n(Delete= 'd' | Change = 'c') (Next = '\/' | Last = '?') \r\n\t(Heading = '<h' | Header = '<h' | Paragraph = '<p') \r\n\t= {Esc} $2 '\\c' $3 {Enter} $1 i t;\r\n\r\n\r\n\r\nStrawberry test = 'vi<';\r\n\r\nPaste That = {Alt+e} p;\r\nSelect All = {Alt+e} s {Enter};\r\nGrab Everything = {Alt+e} s {Enter} Wait(100) {Alt+e} c {Enter} Wait(100) {Alt+Tab};\r\n\r\n\r\n\r\n\r\n1..20 Spaces = Repeat($1, ' ');\r\n\r\n\r\nDo Ultisnips = {Esc} ':UltiSnipsEdit'{Enter};\r\n\r\n\r\n(Next = 'j' | Last = 'k') Tag = {Ctrl+$1};\r\nStart Snippet= {Esc} i 'snippet {Enter} {Enter}endsnippet' {Esc} {Up_2} A;\r\nStart (\r\n\tD3 = 'd3_template' | Code = 'D3_code_wrapper'\r\n| \tform | 'form text' | 'form button' | 'form select'\r\n|\thref\r\n) = {Esc} i $1 Wait(100) {Tab};\r\n\r\n\r\n\r\nDelete Line = 'dd';\r\nDelete <numbers> Lines = $1 'dd';\r\n\r\n# Commands for command line mode\r\nYank That = 'y';\r\n\r\n\r\n\r\n\r\n# ---Things to do\r\n# change the configuration file\r\n\r\n\r\n# Commands to add:\r\n# g; - last place I was where I made a change\r\n# Ctrl-o - If I jump to a place, copy a line, I can snap back \r\n# :9yank - copy line 9\r\n# :9t16 - copy line 9 to line 16\r\n# :9. - copy line 9 to current position \r\n\r\n\r\n# Commands I'm not sure about\r\n# H,M,L: top, middle, and bottom of screen","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"9dd71ca07d9907471bfd315f379379e2df6e8a5d","subject":"Remove 7.0 test file","message":"Remove 7.0 test file\n","repos":"emgag\/docker-varnish","old_file":"test\/7.0.vcl","new_file":"test\/7.0.vcl","new_contents":"","old_contents":"vcl 4.0;\n\nimport blob;\nimport bodyaccess;\nimport cookie;\nimport debug;\nimport digest;\nimport directors;\nimport dynamic;\nimport header;\nimport proxy;\nimport purge;\nimport querystring;\nimport saintmode;\nimport std;\nimport tcp;\nimport unix;\nimport var;\nimport vsthrottle;\nimport vtc;\nimport xkey;\n\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\n\nsub vcl_recv {\n std.log(\"you can't stop the signal!\");\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"21ef9ca4073f71150536025a66ebffa190248071","subject":"Raise a 403 error instead of a redirect","message":"Raise a 403 error instead of a redirect\n","repos":"pypa\/warehouse,pypa\/warehouse,karan\/warehouse,alex\/warehouse,alex\/warehouse,HonzaKral\/warehouse,ismail-s\/warehouse,dstufft\/warehouse,alex\/warehouse,dstufft\/warehouse,alex\/warehouse,pypa\/warehouse,karan\/warehouse,karan\/warehouse,ismail-s\/warehouse,pypa\/warehouse,HonzaKral\/warehouse,ismail-s\/warehouse,wlonk\/warehouse,karan\/warehouse,ismail-s\/warehouse,wlonk\/warehouse,dstufft\/warehouse,HonzaKral\/warehouse,alex\/warehouse,karan\/warehouse,dstufft\/warehouse,wlonk\/warehouse,ismail-s\/warehouse,HonzaKral\/warehouse","old_file":"vcl\/main.vcl","new_file":"vcl\/main.vcl","new_contents":"\nsub vcl_recv {\n#FASTLY recv\n\n # We want to Force SSL for the WebUI by redirecting to the HTTPS version of\n # the page, however for API calls we want to return an error code directing\n # people to instead use HTTPS.\n if (!req.http.Fastly-SSL) {\n\n # The \/simple\/ and \/packages\/ API.\n if (req.url ~ \"^\/(simple|packages)\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy JSON API.\n if (req.url ~ \"^\/pypi\/.+\/json$\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy ?:action= API.\n if (req.url ~ \"^\/pypi.*(\\?|&)=:action\") {\n error 803 \"SSL is required\";\n }\n\n error 801 \"Force SSL\";\n }\n\n # Do not bother to attempt to run the caching mechanisms for methods that\n # are not generally safe to cache.\n if (req.request != \"HEAD\" &&\n req.request != \"GET\" &&\n req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n # Finally, return the default lookup action.\n return(lookup);\n}\n\n\nsub vcl_error {\n#FASTLY error\n\n if (obj.status == 803) {\n set obj.status = 403;\n set obj.response = \"SSL is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic {\"SSL is required.\"};\n return (deliver);\n }\n}\n","old_contents":"\nsub vcl_recv {\n#FASTLY recv\n\n # We want to Force SSL for the WebUI by redirecting to the HTTPS version of\n # the page, however for API calls we want to return an error code directing\n # people to instead use HTTPS.\n # TODO: Cause an error instead of a redirect for \"API\" URLs.\n if (!req.http.Fastly-SSL) {\n error 801 \"Force SSL\";\n }\n\n # Do not bother to attempt to run the caching mechanisms for methods that\n # are not generally safe to cache.\n if (req.request != \"HEAD\" &&\n req.request != \"GET\" &&\n req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n # Finally, return the default lookup action.\n return(lookup);\n}\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"624c9051efd8f60ee7deb060629357ab0cbd3c18","subject":"Only strip headers on edge nodes, not on shield nodes.","message":"Only strip headers on edge nodes, not on shield nodes.\n","repos":"pypa\/warehouse,alex\/warehouse,dstufft\/warehouse,alex\/warehouse,pypa\/warehouse,karan\/warehouse,ismail-s\/warehouse,HonzaKral\/warehouse,dstufft\/warehouse,karan\/warehouse,alex\/warehouse,karan\/warehouse,pypa\/warehouse,karan\/warehouse,alex\/warehouse,HonzaKral\/warehouse,wlonk\/warehouse,dstufft\/warehouse,ismail-s\/warehouse,dstufft\/warehouse,HonzaKral\/warehouse,wlonk\/warehouse,pypa\/warehouse,alex\/warehouse,ismail-s\/warehouse,ismail-s\/warehouse,wlonk\/warehouse,HonzaKral\/warehouse,karan\/warehouse,ismail-s\/warehouse","old_file":"vcl\/main.vcl","new_file":"vcl\/main.vcl","new_contents":"\nsub vcl_recv {\n#FASTLY recv\n\n # Disable ESI processing when doing a shield request.\n if (req.http.Fastly-FF) {\n set req.esi = false;\n }\n\n # If we're serving an ESI request, and the request in question has NOT\n # opted into cookies, then we'll go ahead and strip any cookies from the\n # request. In addition, we'll strip out any Authorization or Authentication\n # headers.\n if (req.url ~ \"^\/_esi\/\") {\n unset req.http.Authenticate;\n unset req.http.Authorization;\n\n if (req.url !~ \"esi-cookies=1\") {\n unset req.http.Cookie;\n }\n }\n\n # We want to Force SSL for the WebUI by redirecting to the HTTPS version of\n # the page, however for API calls we want to return an error code directing\n # people to instead use HTTPS.\n if (!req.http.Fastly-SSL) {\n\n # The \/simple\/ and \/packages\/ API.\n if (req.url ~ \"^\/(simple|packages)\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy JSON API.\n if (req.url ~ \"^\/pypi\/.+\/json$\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy ?:action= API.\n if (req.url ~ \"^\/pypi.*(\\?|&)=:action\") {\n error 803 \"SSL is required\";\n }\n\n # If we're on the \/pypi page and we've received something other than a\n # GET or HEAD request, then we have no way to determine if a particular\n # request is an API call or not because it'll be in the request body\n # and that isn't available to us here. So in those cases, we won't\n # do a redirect.\n if (req.url ~ \"^\/pypi\") {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n error 801 \"Force SSL\";\n }\n }\n else {\n # This isn't a \/pypi URL so we'll just unconditionally redirect to\n # HTTPS.\n error 801 \"Force SSL\";\n }\n }\n\n # Set a header to tell the backend if we're using https or http.\n if (req.http.Fastly-SSL) {\n set req.http.Warehouse-Proto = \"https\";\n } else {\n set req.http.Warehouse-Proto = \"http\";\n }\n\n # Pass the client IP address back to the backend.\n if (req.http.Fastly-Client-IP) {\n set req.http.Warehouse-IP = req.http.Fastly-Client-IP;\n }\n\n # Pass the real host value back to the backend.\n if (req.http.Host) {\n set req.http.Warehouse-Host = req.http.Host;\n }\n\n # Do not bother to attempt to run the caching mechanisms for methods that\n # are not generally safe to cache.\n if (req.request != \"HEAD\" &&\n req.request != \"GET\" &&\n req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n # Finally, return the default lookup action.\n return(lookup);\n}\n\n\nsub vcl_fetch {\n#FASTLY fetch\n\n # Only enable ESI on responses that have opted into them.\n if (beresp.http.Warehouse-ESI-Enable) {\n # Conditional HTTP requests are not compatible with Varnish's\n # implementation of ESI, in particularl the ETag and the Last-Modified\n # won't be updated when the included content changes, causing Varnish\n # to return a 304 Not Modified.\n unset beresp.http.ETag;\n unset beresp.http.Last-Modified;\n\n # Enable ESI.\n esi;\n }\n\n # Trigger a \"SSL is required\" error if the backend has indicated to do so.\n if (beresp.http.X-Fastly-Error == \"803\") {\n error 803 \"SSL is required\";\n }\n\n # If we've gotten a 500 or a 503 from the backend, we'll go ahead and retry\n # the request.\n if ((beresp.status == 500 || beresp.status == 503) &&\n req.restarts < 1 &&\n (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n # If we've restarted, then we'll record the number of restarts.\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n # If there is a Set-Cookie header, we'll ensure that we do not cache the\n # response.\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n # If the response has the private Cache-Control directive then we won't\n # cache it.\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # If we've gotten an error after the restarts we'll deliver the response\n # with a very short cache time.\n if (beresp.status == 500 || beresp.status == 503) {\n # If this is a ESI request, then instead of returning the error we're\n # going to return a blank page so that our top level page acts as if it\n # did not have ESI rather than inlining the error page.\n if (req.url ~ \"^\/_esi\/\") {\n error 900 \"ESI Error\";\n }\n\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n # Apply a default TTL if there isn't a max-age or s-maxage.\n if (beresp.http.Expires ||\n beresp.http.Surrogate-Control ~ \"max-age\" ||\n beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # Keep the ttl here\n }\n else {\n # Apply the default ttl\n set beresp.ttl = 60s;\n }\n\n # Actually deliver the fetched response.\n return(deliver);\n}\n\n\nsub vcl_deliver {\n#FASTLY deliver\n\n # If the backend has indicated additional Vary headers to add once the\n # ESI result has been processed, then we'll go ahead and either append them\n # to our existing Vary header or we'll set the Vary header equal to it.\n # However, we only want this logic to happen on the edge nodes, not on the\n # shielding nodes.\n if (resp.http.Warehouse-ESI-Vary && !req.http.Fastly-FF) {\n if (resp.http.Vary) {\n set resp.http.Vary = resp.http.Vary \", \" resp.http.Warehouse-ESI-Vary;\n } else {\n set resp.http.Vary = resp.http.Warehouse-ESI-Vary;\n }\n\n unset resp.http.Warehouse-ESI-Vary;\n }\n\n # We no longer need the header that enables ESI, so we'll remove it from\n # the output if we're not on a shielding node, otherwise we want to pass\n # this header on to the edge nodes so that they can handle the ESI.\n if (!req.http.Fastly-FF) {\n unset resp.http.Warehouse-ESI-Enable;\n }\n\n # Unset headers that we don't need\/want to send on to the client because\n # they are not generally useful.\n unset resp.http.Server;\n unset resp.http.Via;\n\n return(deliver);\n}\n\n\nsub vcl_error {\n#FASTLY error\n\n if (obj.status == 803) {\n set obj.status = 403;\n set obj.response = \"SSL is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic {\"SSL is required.\"};\n return (deliver);\n } else if (obj.status == 900) {\n set obj.status = 500;\n set obj.response = \"500 ESI Error\";\n set obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n synthetic {\"\"};\n return(deliver);\n }\n}\n","old_contents":"\nsub vcl_recv {\n#FASTLY recv\n\n # Disable ESI processing when doing a shield request.\n if (req.http.Fastly-FF) {\n set req.esi = false;\n }\n\n # If we're serving an ESI request, and the request in question has NOT\n # opted into cookies, then we'll go ahead and strip any cookies from the\n # request. In addition, we'll strip out any Authorization or Authentication\n # headers.\n if (req.url ~ \"^\/_esi\/\") {\n unset req.http.Authenticate;\n unset req.http.Authorization;\n\n if (req.url !~ \"esi-cookies=1\") {\n unset req.http.Cookie;\n }\n }\n\n # We want to Force SSL for the WebUI by redirecting to the HTTPS version of\n # the page, however for API calls we want to return an error code directing\n # people to instead use HTTPS.\n if (!req.http.Fastly-SSL) {\n\n # The \/simple\/ and \/packages\/ API.\n if (req.url ~ \"^\/(simple|packages)\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy JSON API.\n if (req.url ~ \"^\/pypi\/.+\/json$\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy ?:action= API.\n if (req.url ~ \"^\/pypi.*(\\?|&)=:action\") {\n error 803 \"SSL is required\";\n }\n\n # If we're on the \/pypi page and we've received something other than a\n # GET or HEAD request, then we have no way to determine if a particular\n # request is an API call or not because it'll be in the request body\n # and that isn't available to us here. So in those cases, we won't\n # do a redirect.\n if (req.url ~ \"^\/pypi\") {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n error 801 \"Force SSL\";\n }\n }\n else {\n # This isn't a \/pypi URL so we'll just unconditionally redirect to\n # HTTPS.\n error 801 \"Force SSL\";\n }\n }\n\n # Set a header to tell the backend if we're using https or http.\n if (req.http.Fastly-SSL) {\n set req.http.Warehouse-Proto = \"https\";\n } else {\n set req.http.Warehouse-Proto = \"http\";\n }\n\n # Pass the client IP address back to the backend.\n if (req.http.Fastly-Client-IP) {\n set req.http.Warehouse-IP = req.http.Fastly-Client-IP;\n }\n\n # Pass the real host value back to the backend.\n if (req.http.Host) {\n set req.http.Warehouse-Host = req.http.Host;\n }\n\n # Do not bother to attempt to run the caching mechanisms for methods that\n # are not generally safe to cache.\n if (req.request != \"HEAD\" &&\n req.request != \"GET\" &&\n req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n # Finally, return the default lookup action.\n return(lookup);\n}\n\n\nsub vcl_fetch {\n#FASTLY fetch\n\n # Only enable ESI on responses that have opted into them.\n if (beresp.http.Warehouse-ESI-Enable) {\n # Conditional HTTP requests are not compatible with Varnish's\n # implementation of ESI, in particularl the ETag and the Last-Modified\n # won't be updated when the included content changes, causing Varnish\n # to return a 304 Not Modified.\n unset beresp.http.ETag;\n unset beresp.http.Last-Modified;\n\n # Enable ESI.\n esi;\n }\n\n # Trigger a \"SSL is required\" error if the backend has indicated to do so.\n if (beresp.http.X-Fastly-Error == \"803\") {\n error 803 \"SSL is required\";\n }\n\n # If we've gotten a 500 or a 503 from the backend, we'll go ahead and retry\n # the request.\n if ((beresp.status == 500 || beresp.status == 503) &&\n req.restarts < 1 &&\n (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n # If we've restarted, then we'll record the number of restarts.\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n # If there is a Set-Cookie header, we'll ensure that we do not cache the\n # response.\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n # If the response has the private Cache-Control directive then we won't\n # cache it.\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # If we've gotten an error after the restarts we'll deliver the response\n # with a very short cache time.\n if (beresp.status == 500 || beresp.status == 503) {\n # If this is a ESI request, then instead of returning the error we're\n # going to return a blank page so that our top level page acts as if it\n # did not have ESI rather than inlining the error page.\n if (req.url ~ \"^\/_esi\/\") {\n error 900 \"ESI Error\";\n }\n\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n # Apply a default TTL if there isn't a max-age or s-maxage.\n if (beresp.http.Expires ||\n beresp.http.Surrogate-Control ~ \"max-age\" ||\n beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # Keep the ttl here\n }\n else {\n # Apply the default ttl\n set beresp.ttl = 60s;\n }\n\n # Actually deliver the fetched response.\n return(deliver);\n}\n\n\nsub vcl_deliver {\n#FASTLY deliver\n\n # If the backend has indicated additional Vary headers to add once the\n # ESI result has been processed, then we'll go ahead and either append them\n # to our existing Vary header or we'll set the Vary header equal to it.\n if (resp.http.Warehouse-ESI-Vary) {\n if (resp.http.Vary) {\n set resp.http.Vary = resp.http.Vary \", \" resp.http.Warehouse-ESI-Vary;\n } else {\n set resp.http.Vary = resp.http.Warehouse-ESI-Vary;\n }\n\n unset resp.http.Warehouse-ESI-Vary;\n }\n\n # We no longer need the header that enables ESI, so we'll remove it from\n # the output.\n unset resp.http.Warehouse-ESI-Enable;\n\n # Unset headers that we don't need\/want to send on to the client because\n # they are not generally useful.\n unset resp.http.Server;\n unset resp.http.Via;\n\n return(deliver);\n}\n\n\nsub vcl_error {\n#FASTLY error\n\n if (obj.status == 803) {\n set obj.status = 403;\n set obj.response = \"SSL is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic {\"SSL is required.\"};\n return (deliver);\n } else if (obj.status == 900) {\n set obj.status = 500;\n set obj.response = \"500 ESI Error\";\n set obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n synthetic {\"\"};\n return(deliver);\n }\n}\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"73584febf8d4ad03c7b5a9890a8c96eaea8db2f7","subject":"Remove set resp.response \/ resp.http.response","message":"Remove set resp.response \/ resp.http.response\n\nNot required","repos":"varnish\/varnish-devicedetect,varnish\/varnish-devicedetect","old_file":"devicedetect-dev.vcl","new_file":"devicedetect-dev.vcl","new_contents":"#\n# devicedetect-dev.vcl\n#\n# Enable test URLs and cookie overrides.\n#\nvcl 4.0;\n\nbackend devicetest {\n\t.host = \"127.0.0.1\";\n\t.port = \"5911\";\n}\n\nsub vcl_recv {\n\t# 701\/702 are arbitrary chosen return codes that is only used internally in varnish.\n\tif (req.url ~ \"^\/set_ua_device\/.+\") {\n\t\treturn(synth(701, regsub(req.url, \"^\/set_ua_device\/\", \"\"));\n\t}\n\t# set expired cookie if nothing is specified\n\tif (req.url ~ \"^\/set_ua_device\/\") {\n\t\treturn(synth(702, \"OK\"));\n\t}\n\tif (req.url ~ \"^\/devicetest\") {\n\t\tset req.backend = devicetest;\n\t}\n}\n\nsub vcl_synth {\n\tif (resp.status == 701 || resp.status == 702) {\n\t\tif (resp.status == 702) {\n\t\t\tset resp.http.Set-Cookie = \"X-UA-Device-force=expiring; Path=\/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;\";\n\t\t\tset resp.status = 200;\n\t\t} else {\n\t\t\tset resp.http.Set-Cookie = \"X-UA-Device-force=\" + resp.reason + \"; Path=\/;\";\n\t\t\tset resp.status = 200;\n\t\t}\n\t\tset resp.http.Content-Type = \"text\/html; charset=utf-8\";\n\t\tsynthetic {\"<html><body><h1>OK, Cookie updated<\/h1><a href='\/devicetest\/'>\/devicetest\/<\/a><\/body><\/html>\"};\n\t\treturn(deliver);\n\t}\n}\n","old_contents":"#\n# devicedetect-dev.vcl\n#\n# Enable test URLs and cookie overrides.\n#\nvcl 4.0;\n\nbackend devicetest {\n\t.host = \"127.0.0.1\";\n\t.port = \"5911\";\n}\n\nsub vcl_recv {\n\t# 701\/702 are arbitrary chosen return codes that is only used internally in varnish.\n\tif (req.url ~ \"^\/set_ua_device\/.+\") {\n\t\treturn(synth(701, regsub(req.url, \"^\/set_ua_device\/\", \"\"));\n\t}\n\t# set expired cookie if nothing is specified\n\tif (req.url ~ \"^\/set_ua_device\/\") {\n\t\treturn(synth(702, \"OK\"));\n\t}\n\tif (req.url ~ \"^\/devicetest\") {\n\t\tset req.backend = devicetest;\n\t}\n}\n\nsub vcl_synth {\n\tif (resp.status == 701 || resp.status == 702) {\n\t\tif (resp.status == 702) {\n\t\t\tset resp.http.Set-Cookie = \"X-UA-Device-force=expiring; Path=\/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;\";\n\t\t\tset resp.status = 200;\n\t\t} else {\n\t\t\tset resp.http.Set-Cookie = \"X-UA-Device-force=\" + resp.reason + \"; Path=\/;\";\n\t\t\tset resp.status = 200;\n\t\t}\n\t\tset resp.http.Content-Type = \"text\/html; charset=utf-8\";\n\t\tsynthetic {\"<html><body><h1>OK, Cookie updated<\/h1><a href='\/devicetest\/'>\/devicetest\/<\/a><\/body><\/html>\"};\n\t\tset resp.http.response = \"OK\";\n\t\treturn(deliver);\n\t}\n}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"a10d24c3641be4d2329c411a54afd3c58539c5e0","subject":"Fixed variable name.","message":"Fixed variable name.\n","repos":"noqcks\/ansible-varnish,killerwails\/ansible-varnish,colstrom\/ansible-varnish,telusdigital\/ansible-varnish,kkwoker\/ansible-varnish,gotofbi\/ansible-varnish,killerwails\/ansible-varnish,gotofbi\/ansible-varnish","old_file":"templates\/etc\/varnish\/default.vcl","new_file":"templates\/etc\/varnish\/default.vcl","new_contents":"vcl 4.0;\n\nimport directors;\nimport std;\n\n###\n# Varnish Documentation\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-built-in-subs.html\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/reference\/vcl.html\n##\n\n{% for backend in varnish_backend_hosts %}\nbackend application_{{ loop.index }} {\n .host = \"{{ backend }}\";\n .port = \"{{ varnish_backend_port }}\";\n{% if varnish_health_checks_enabled %}\n .probe = {\n .url = \"{{ varnish_health_check_url }}\";\n .interval = {{ varnish_health_check_interval }};\n .timeout = {{ varnish_health_check_timeout }};\n .window = {{ varnish_health_check_window }};\n .threshold = {{ varnish_health_check_threshold }};\n }\n{% endif %}\n}\n{% endfor %}\n\n###\n# vcl_init\n# Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n###\n# The vcl_init subroutine may terminate with calling return() with one of the following keywords:\n#\n# ok\n# Normal return, VCL continues loading.\n##\n\nsub vcl_init {\n new application = directors.round_robin();\n{% for backend in varnish_backend_hosts %}\n application.add_backend(application_{{ loop.index }});\n{% endfor %}\n}\n\n###\n# vcl_recv\n# Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use. \n# It is also used to modify the request\n###\n# The vcl_recv subroutine may terminate with calling return() on one of the following keywords:\n#\n# synth(status code, reason)\n# Return a synthetic object with the specified status code to the client and abandon the request.\n# pass\n# Switch to pass mode. Control will eventually pass to vcl_pass.\n# pipe\n# Switch to pipe mode. Control will eventually pass to vcl_pipe.\n# hash\n# Continue processing the object as a potential candidate for caching. Passes the control over to vcl_hash.\n# purge\n# Purge the object and it's variants. Control passes through vcl_hash to vcl_purge.\n#\n\nsub vcl_recv {\n set req.backend_hint = application.backend();\n\n ###\n # Avoid processing uncacheable requests\n ###\n\n if (req.http.Authorization) {\n return (pass);\n }\n\n{% if varnish_uri_blacklist_enabled %}\n if ((req.url ~ \"{{ varnish_uri_blacklist_regexp }}\")) {\n set req.http.X-Passthrough-Reason = \"Path in Blacklist\";\n return(pass);\n }\n{% endif %}\n\n ###\n # Inject X-Forwarded-For headers, but only once.\n ###\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n{% if varnish_header_sanitization_enabled %}\n ###\n # Header Sanitization\n ###\n\n{% if varnish_header_sanitization_discard_host_port %}\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n{% endif %}\n\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_enabled %}\n ###\n # Cookie Sanitization\n ###\n{% for cookie in varnish_cookie_sanitization_blacklist %}\n set req.http.Cookie = regsuball(req.http.Cookie, \"{{ cookie }}=[^;]+(; )?\", \"\");\n{% endfor %}\n\n ### General Cleanup\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n{% endif %}\n\n{% if varnish_uri_sanitization_enabled %}\n ###\n # URI Sanitization\n ###\n \n if (req.url ~ \"(\\?|&){{ varnish_uri_sanitization_regexp }}=\") {\n set req.url = regsuball(req.url, \"&{{ varnish_uri_sanitization_regexp }}=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?{{ varnish_uri_sanitization_regexp }}=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n{% endif %}\n\n{% if varnish_workaround_telusdotcom_browser_profile %}\n ###\n # Workaround for BrowserProfile and Language\/Region Detection on TELUS.com\n ###\n\n if (req.http.Cookie ~ \"BrowserProfile\") {\n set req.http.X-BrowserProfile = regsuball(req.http.Cookie, \"(.*)BrowserProfile=([^;]*)(.*)\", \"\\2\");\n if (req.http.X-BrowserProfile ~ \"language\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.X-BrowserProfile, \"(.*)language\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n set req.http.X-Language-Found = \"YES:BrowserProfile\";\n }\n if (req.http.X-BrowserProfile ~ \"region\") {\n set req.http.X-Region = std.tolower(regsuball(regsuball(req.http.X-BrowserProfile, \"geo\\\\.\\:{(.*)\\}\", \"\"), \"(.*)region\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n set req.http.X-Region-Found = \"YES:BrowserProfile\";\n }\n if (req.http.X-BrowserProfile ~ \"geo\") {\n set req.http.X-BrowserProfile-Geolocation = regsuball(req.http.X-BrowserProfile, \"(.*)geo..:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n set req.http.X-BrowserProfile-Geolocation-Found: \"YES\";\n\n if (req.http.X-BrowserProfile-Geolocation ~ \"country\") {\n set req.http.X-BrowserProfile-Geolocation-Country = regsuball(req.http.X-BrowserProfile-Geolocation, \"(.*)country\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-BrowserProfile-Geolocation ~ \"region\") {\n set req.http.X-BrowserProfile-Geolocation-Region = regsuball(req.http.X-BrowserProfile-Geolocation, \"(.*)region\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-BrowserProfile-Geolocation ~ \"city\") {\n set req.http.X-BrowserProfile-Geolocation-City = regsuball(req.http.X-BrowserProfile-Geolocation, \"(.*)city\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-BrowserProfile-Geolocation ~ \"isp\") {\n set req.http.X-BrowserProfile-Geolocation-ISP = regsuball(req.http.X-BrowserProfile-Geolocation, \"(.*)isp\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n } else {\n set req.http.X-BrowserProfile-Geolocation-Found: \"NO\";\n }\n }\n\n if (!req.http.X-Language) {\n if (req.http.Cookie ~ \"lang=\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.Cookie, \"(.*)lang=([^;]*)(.*)\", \"\\2\"));\n set req.http.X-Language-Found = \"YES:lang\";\n } else {\n set req.http.X-Language = \"en\";\n set req.http.X-Language-Found = \"NO\";\n }\n }\n\n if (!req.http.X-Region) {\n if (req.http.Cookie ~ \"prov=\") {\n set req.http.X-Region = std.tolower(regsuball(req.http.Cookie, \"(.*)prov=([^;]*)(.*)\", \"\\2\"));\n set req.http.X-Region-Found = \"YES:prov\";\n } else {\n set req.http.X-Region = \"bc\";\n set req.http.X-Region-Found = \"NO\";\n }\n }\n\n if (req.url ~ \"\/(en|fr)\/\") {\n if (req.url ~ \"\/en\/\" && req.http.X-Language != \"en\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Language (Path: \/en\/) vs (Cookie: \" + req.http.X-Language + \")\";\n return(pass);\n }\n if (req.url ~ \"\/fr\/\" && req.http.X-Language != \"fr\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Language (Path: \/fr\/) vs (Cookie: \" + req.http.X-Language + \")\";\n return(pass);\n }\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Language)\";\n return(pass);\n }\n\n if (req.url ~ \"\/(ab|bc|mb|nb|nl|ns|nt|nu|on|pe|qc|sk|yt)\/\") {\n {% for province in ['ab', 'bc', 'mb', 'nb', 'nl', 'ns', 'nt', 'nu', 'on', 'pe', 'qc', 'sk', 'yt'] %}\n if (req.url ~ \"\/{{ province }}\/\" && req.http.X-Region != \"{{ province }}\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Region (Path: \/{{ province }}\/) vs (Cookie: \" + req.http.X-Region + \")\";\n return(pass);\n }\n {% endfor %}\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Province)\";\n return(pass);\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_discard_from_client %}\n unset req.http.Cookie;\n{% endif %}\n}\n\n###\n# vcl_hit\n# Called when a cache lookup is successful.\n###\n# The vcl_hit subroutine may terminate with calling return() with one of the following keywords:\n#\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n# deliver\n# Deliver the object. Control passes to vcl_deliver.\n# synth(status code, reason)\n# Return the specified status code to the client and abandon the request.\n###\n\nsub vcl_hit {\n if (obj.ttl > 0s) {\n return (deliver);\n }\n{% if varnish_health_checks_enabled %}\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (fetch);\n }\n{% else %}\n if (obj.ttl + obj.grace > 0s) {\n return (deliver);\n }\n\n return (fetch);\n{% endif %}\n}\n\n###\n# vcl_backend_response\n# Called after the response headers has been successfully retrieved from the backend.\n###\n# The vcl_backend_response subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Possibly insert the object into the cache, then deliver it to the Control will eventually pass to vcl_deliver.\n# abandon\n# Abandon the backend request and generates an error.\n# retry\n# Retry the backend transaction. Increases the retries counter. If the number of retries is higher than max_retries Varnish emits a guru meditation error.\n###\n\nsub vcl_backend_response {\n{% if varnish_workaround_telusdotcom_browser_profile %}\n if (bereq.http.X-Language) {\n set beresp.http.X-Language = bereq.http.X-Language;\n if (bereq.http.X-Language-Found) {\n set beresp.http.X-Language-Found = bereq.http.X-Language-Found;\n }\n }\n if (bereq.http.X-Region) {\n set beresp.http.X-Region = bereq.http.X-Region;\n if (bereq.http.X-Region-Found) {\n set beresp.http.X-Region-Found = bereq.http.X-Region-Found;\n }\n }\n{% endif %}\n\n{% if varnish_uri_blacklist_enabled %}\n if (bereq.url ~ \"{{ varnish_uri_blacklist_regexp }}\") {\n set beresp.http.X-Cacheable = \"NO:Path in Blacklist\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n if (bereq.http.X-Passthrough-Reason) {\n set beresp.http.X-Passthrough-Reason = bereq.http.X-Passthrough-Reason;\n return(deliver);\n }\n }\n{% else %}\n{% if varnish_cookie_sanitization_discard_from_server %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n{% endif %}\n\n{% if varnish_diagnostic_headers_enabled %}\n if (bereq.http.Cookie) {\n set beresp.http.X-Cacheable = \"NO:Cookie in Request\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO:Set-Cookie in Response\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.X-No-Cache) {\n set beresp.http.X-Cacheable = \"NO:X-No-Cache\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.ttl <= 0s) {\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n{% endif %}\n\n set beresp.grace = {{ varnish_grace_period }};\n}\n\n###\n# vcl_deliver\n# Called before a cached object is delivered to the client.\n###\n# The vcl_deliver subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Deliver the object to the client.\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n###\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n","old_contents":"vcl 4.0;\n\nimport directors;\nimport std;\n\n###\n# Varnish Documentation\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-built-in-subs.html\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/reference\/vcl.html\n##\n\n{% for backend in varnish_backend_hosts %}\nbackend application_{{ loop.index }} {\n .host = \"{{ backend }}\";\n .port = \"{{ varnish_backend_port }}\";\n{% if varnish_health_checks_enabled %}\n .probe = {\n .url = \"{{ varnish_health_check_url }}\";\n .interval = {{ varnish_health_check_interval }};\n .timeout = {{ varnish_health_check_timeout }};\n .window = {{ varnish_health_check_window }};\n .threshold = {{ varnish_health_check_threshold }};\n }\n{% endif %}\n}\n{% endfor %}\n\n###\n# vcl_init\n# Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n###\n# The vcl_init subroutine may terminate with calling return() with one of the following keywords:\n#\n# ok\n# Normal return, VCL continues loading.\n##\n\nsub vcl_init {\n new application = directors.round_robin();\n{% for backend in varnish_backend_hosts %}\n application.add_backend(application_{{ loop.index }});\n{% endfor %}\n}\n\n###\n# vcl_recv\n# Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use. \n# It is also used to modify the request\n###\n# The vcl_recv subroutine may terminate with calling return() on one of the following keywords:\n#\n# synth(status code, reason)\n# Return a synthetic object with the specified status code to the client and abandon the request.\n# pass\n# Switch to pass mode. Control will eventually pass to vcl_pass.\n# pipe\n# Switch to pipe mode. Control will eventually pass to vcl_pipe.\n# hash\n# Continue processing the object as a potential candidate for caching. Passes the control over to vcl_hash.\n# purge\n# Purge the object and it's variants. Control passes through vcl_hash to vcl_purge.\n#\n\nsub vcl_recv {\n set req.backend_hint = application.backend();\n\n ###\n # Avoid processing uncacheable requests\n ###\n\n if (req.http.Authorization) {\n return (pass);\n }\n\n{% if varnish_uri_blacklist_enabled %}\n if ((req.url ~ \"{{ varnish_uri_blacklist_regexp }}\")) {\n set req.http.X-Passthrough-Reason = \"Path in Blacklist\";\n return(pass);\n }\n{% endif %}\n\n ###\n # Inject X-Forwarded-For headers, but only once.\n ###\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n{% if varnish_header_sanitization_enabled %}\n ###\n # Header Sanitization\n ###\n\n{% if varnish_header_sanitization_discard_host_port %}\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n{% endif %}\n\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_enabled %}\n ###\n # Cookie Sanitization\n ###\n{% for cookie in varnish_cookie_sanitization_blacklist %}\n set req.http.Cookie = regsuball(req.http.Cookie, \"{{ cookie }}=[^;]+(; )?\", \"\");\n{% endfor %}\n\n ### General Cleanup\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n{% endif %}\n\n{% if varnish_uri_sanitization_enabled %}\n ###\n # URI Sanitization\n ###\n \n if (req.url ~ \"(\\?|&){{ varnish_uri_sanitization_regexp }}=\") {\n set req.url = regsuball(req.url, \"&{{ varnish_uri_sanitization_regexp }}=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?{{ varnish_uri_sanitization_regexp }}=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n{% endif %}\n\n{% if varnish_workaround_telusdotcom_browser_profile %}\n ###\n # Workaround for BrowserProfile and Language\/Region Detection on TELUS.com\n ###\n\n if (req.http.Cookie ~ \"BrowserProfile\") {\n set req.http.X-BrowserProfile = regsuball(req.http.Cookie, \"(.*)BrowserProfile=([^;]*)(.*)\", \"\\2\");\n if (req.http.X-BrowserProfile ~ \"language\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.X-BrowserProfile, \"(.*)language\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n set req.http.X-Language-Found = \"YES:BrowserProfile\";\n }\n if (req.http.X-BrowserProfile ~ \"region\") {\n set req.http.X-Region = std.tolower(regsuball(regsuball(req.http.X-BrowserProfile, \"geo\\\\.\\:{(.*)\\}\", \"\"), \"(.*)region\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n set req.http.X-Region-Found = \"YES:BrowserProfile\";\n }\n if (req.http.X-BrowserProfile ~ \"geo\") {\n set req.http.X-BrowserProfile-Geolocation = regsuball(req.http.X-BrowserProfile, \"(.*)geo..:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n set req.http.X-BrowserProfile-Geolocation-Found: \"YES\";\n\n if (req.http.X-BrowserProfile-Geolocation ~ \"country\") {\n set req.http.X-BrowserProfile-Geolocation-Country = regsuball(req.http.X-BrowserProfile-Geolocation, \"(.*)country\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-BrowserProfile-Geolocation ~ \"region\") {\n set req.http.X-BrowserProfile-Geolocation-Region = regsuball(req.http.X-BrowserProfile-Geolocation, \"(.*)region\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-BrowserProfile-Geolocation ~ \"city\") {\n set req.http.X-BrowserProfile-Geolocation-City = regsuball(req.http.X-BrowserProfile-Geolocation, \"(.*)city\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-BrowserProfile-Geolocation ~ \"isp\") {\n set req.http.X-BrowserProfile-Geolocation-ISP = regsuball(req.http.X-BrowserProfile-Geolocation, \"(.*)isp\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n } else {\n set req.http.X-BrowserProfile-Geolocation-Found: \"NO\";\n }\n }\n\n if (!req.http.X-Language) {\n if (req.http.Cookie ~ \"lang=\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.Cookie, \"(.*)lang=([^;]*)(.*)\", \"\\2\"));\n set req.http.X-Language-Found = \"YES:lang\";\n } else {\n set req.http.X-Language = \"en\";\n set req.http.X-Language-Found = \"NO\";\n }\n }\n\n if (!req.http.X-Region) {\n if (req.http.Cookie ~ \"prov=\") {\n set req.http.X-Region = std.tolower(regsuball(req.http.Cookie, \"(.*)prov=([^;]*)(.*)\", \"\\2\"));\n set req.http.X-Region-Found = \"YES:prov\";\n } else {\n set req.http.X-Region = \"bc\";\n set req.http.X-Region-Found = \"NO\";\n }\n }\n\n if (req.url ~ \"\/(en|fr)\/\") {\n if (req.url ~ \"\/en\/\" && req.http.X-Language != \"en\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Language (Path: \/en\/) vs (Cookie: \" + req.http.X-Language + \")\";\n return(pass);\n }\n if (req.url ~ \"\/fr\/\" && req.http.X-Language != \"fr\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Language (Path: \/fr\/) vs (Cookie: \" + req.http.X-Language + \")\";\n return(pass);\n }\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Language)\";\n return(pass);\n }\n\n if (req.url ~ \"\/(ab|bc|mb|nb|nl|ns|nt|nu|on|pe|qc|sk|yt)\/\") {\n {% for province in ['ab', 'bc', 'mb', 'nb', 'nl', 'ns', 'nt', 'nu', 'on', 'pe', 'qc', 'sk', 'yt'] %}\n if (req.url ~ \"\/{{ province }}\/\" && req.http.X-Region != \"{{ province }}\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Region (Path: \/{{ province }}\/) vs (Cookie: \" + req.http.X-Region + \")\";\n return(pass);\n }\n {% endfor %}\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Province)\";\n return(pass);\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_discard_from_client %}\n unset req.http.Cookie;\n{% endif %}\n}\n\n###\n# vcl_hit\n# Called when a cache lookup is successful.\n###\n# The vcl_hit subroutine may terminate with calling return() with one of the following keywords:\n#\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n# deliver\n# Deliver the object. Control passes to vcl_deliver.\n# synth(status code, reason)\n# Return the specified status code to the client and abandon the request.\n###\n\nsub vcl_hit {\n if (obj.ttl > 0s) {\n return (deliver);\n }\n{% if varnish_health_checks_enabled %}\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (fetch);\n }\n{% else %}\n if (obj.ttl + obj.grace > 0s) {\n return (deliver);\n }\n\n return (fetch);\n{% endif %}\n}\n\n###\n# vcl_backend_response\n# Called after the response headers has been successfully retrieved from the backend.\n###\n# The vcl_backend_response subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Possibly insert the object into the cache, then deliver it to the Control will eventually pass to vcl_deliver.\n# abandon\n# Abandon the backend request and generates an error.\n# retry\n# Retry the backend transaction. Increases the retries counter. If the number of retries is higher than max_retries Varnish emits a guru meditation error.\n###\n\nsub vcl_backend_response {\n{% if varnish_workaround_telusdotcom_browser_profile %}\n if (bereq.http.X-Language) {\n set beresp.http.X-Language = bereq.http.X-Language;\n if (bereq.http.X-Language-Found) {\n set beresp.http.X-Language-Found = bereq.http.X-Language-Found;\n }\n }\n if (bereq.http.X-Region) {\n set beresp.http.X-Region = bereq.http.X-Region;\n if (bereq.http.X-Region-Found) {\n set beresp.http.X-Region-Found = bereq.http.X-Region-Found;\n }\n }\n{% endif %}\n\n{% if varnish_uri_blacklist_enabled %}\n if (bereq.url ~ \"{{ varnish_uri_blacklist_regexp }}\") {\n set beresp.http.X-Cacheable = \"NO:Path in Blacklist\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n if (bereq.http.X-Passthrough-Reason) {\n set beresp.http.X-Passthrough-Reason = bereq.http.X-Passthrough-Reason;\n return(deliver);\n }\n }\n{% else %}\n{% if varnish_cookie_sanitization_discard_from_server %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n{% endif %}\n\n{% if varnish_cache_diagnostics_enabled %}\n if (bereq.http.Cookie) {\n set beresp.http.X-Cacheable = \"NO:Cookie in Request\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO:Set-Cookie in Response\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.X-No-Cache) {\n set beresp.http.X-Cacheable = \"NO:X-No-Cache\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.ttl <= 0s) {\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n{% endif %}\n\n set beresp.grace = {{ varnish_grace_period }};\n}\n\n###\n# vcl_deliver\n# Called before a cached object is delivered to the client.\n###\n# The vcl_deliver subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Deliver the object to the client.\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n###\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"fa9ba7e2d6c3bb2ff195a7b34caf2700639254cd","subject":"Reverted reordering.","message":"Reverted reordering.\n","repos":"telusdigital\/ansible-varnish,killerwails\/ansible-varnish,gotofbi\/ansible-varnish,gotofbi\/ansible-varnish,killerwails\/ansible-varnish,noqcks\/ansible-varnish,kkwoker\/ansible-varnish,colstrom\/ansible-varnish","old_file":"templates\/etc\/varnish\/default.vcl","new_file":"templates\/etc\/varnish\/default.vcl","new_contents":"vcl 4.0;\n\nimport directors;\nimport std;\n\n###\n# Varnish Documentation\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-built-in-subs.html\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/reference\/vcl.html\n##\n\n{% for backend in varnish_backend_hosts %}\nbackend application_{{ loop.index }} {\n .host = \"{{ backend }}\";\n .port = \"{{ varnish_backend_port }}\";\n{% if varnish_health_checks_enabled %}\n .probe = {\n .url = \"{{ varnish_health_check_url }}\";\n .interval = {{ varnish_health_check_interval }};\n .timeout = {{ varnish_health_check_timeout }};\n .window = {{ varnish_health_check_window }};\n .threshold = {{ varnish_health_check_threshold }};\n }\n{% endif %}\n}\n{% endfor %}\n\n###\n# vcl_init\n# Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n###\n# The vcl_init subroutine may terminate with calling return() with one of the following keywords:\n#\n# ok\n# Normal return, VCL continues loading.\n##\n\nsub vcl_init {\n new application = directors.round_robin();\n{% for backend in varnish_backend_hosts %}\n application.add_backend(application_{{ loop.index }});\n{% endfor %}\n}\n\n###\n# vcl_recv\n# Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use. \n# It is also used to modify the request\n###\n# The vcl_recv subroutine may terminate with calling return() on one of the following keywords:\n#\n# synth(status code, reason)\n# Return a synthetic object with the specified status code to the client and abandon the request.\n# pass\n# Switch to pass mode. Control will eventually pass to vcl_pass.\n# pipe\n# Switch to pipe mode. Control will eventually pass to vcl_pipe.\n# hash\n# Continue processing the object as a potential candidate for caching. Passes the control over to vcl_hash.\n# purge\n# Purge the object and it's variants. Control passes through vcl_hash to vcl_purge.\n#\n\nsub vcl_recv {\n set req.backend_hint = application.backend();\n\n ###\n # Avoid processing uncacheable requests\n ###\n\n if (req.http.Authorization) {\n set req.http.X-Passthrough-Reason = \"No Caching Authenticated Content\";\n return (pass);\n }\n\n{% if varnish_uri_blacklist_enabled %}\n if ((req.url ~ \"{{ varnish_uri_blacklist_regexp }}\")) {\n set req.http.X-Passthrough-Reason = \"Path in Blacklist\";\n return(pass);\n }\n{% endif %}\n\n{% if varnish_diagnostic_headers_forwarded_for %}\n ###\n # Inject X-Forwarded-For headers, but only once.\n ###\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_enabled %}\n ###\n # Cookie Sanitization\n ###\n if (req.http.Cookie) {\n set req.http.X-Cookie-Unmodified = req.http.Cookie;\n\n {% for cookie in varnish_cookie_sanitization_blacklist %}\n set req.http.Cookie = regsuball(req.http.Cookie, \"{{ cookie }}=[^;]+(; )?\", \"\");\n {% endfor %}\n\n ### General Cleanup\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n if (req.http.Cookie ~ \"^\\s*$\") {\n unset req.http.Cookie;\n }\n if (req.http.Cookie) {\n set req.http.X-Cookie-Sanitized = req.http.Cookie;\n }\n }\n{% endif %}\n\n{% if varnish_header_sanitization_enabled %}\n ###\n # Header Sanitization\n ###\n\n{% if varnish_header_sanitization_discard_host_port %}\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n{% endif %}\n\n{% if varnish_header_sanitization_normalize_accept_encoding %}\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n{% endif %}\n\n{% endif %}\n\n{% if varnish_uri_sanitization_enabled %}\n ###\n # URI Sanitization\n ###\n \n if (req.url ~ \"(\\?|&){{ varnish_uri_sanitization_regexp }}=\") {\n set req.url = regsuball(req.url, \"&{{ varnish_uri_sanitization_regexp }}=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?{{ varnish_uri_sanitization_regexp }}=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n{% endif %}\n\n{% if varnish_workaround_telusdotcom_browser_profile %}\n ###\n # Workaround and Diagnostics for BrowserProfile and Language\/Region Detection on TELUS.com\n ###\n\n if (req.http.Cookie ~ \"BrowserProfile\") {\n set req.http.X-BrowserProfile = regsuball(req.http.Cookie, \"(.*)BrowserProfile=([^;]*)(.*)\", \"\\2\");\n if (req.http.X-BrowserProfile ~ \"language\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.X-BrowserProfile, \"(.*)language\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n set req.http.X-Language-Found = \"YES:BrowserProfile\";\n }\n if (req.http.X-BrowserProfile ~ \"region\") {\n set req.http.X-Region = std.tolower(regsuball(regsuball(req.http.X-BrowserProfile, \"geo\\\\.\\:{(.*)\\}\", \"\"), \"(.*)region\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n set req.http.X-Region-Found = \"YES:BrowserProfile\";\n }\n if (req.http.X-BrowserProfile ~ \"geo\") {\n set req.http.X-BrowserProfile-Geolocation = regsuball(req.http.X-BrowserProfile, \"(.*)geo..:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n set req.http.X-BrowserProfile-Geolocation-Found = \"YES\";\n\n if (req.http.X-BrowserProfile-Geolocation ~ \"country\") {\n set req.http.X-BrowserProfile-Geolocation-Country = regsuball(req.http.X-BrowserProfile-Geolocation, \"(.*)country\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-BrowserProfile-Geolocation ~ \"region\") {\n set req.http.X-BrowserProfile-Geolocation-Region = regsuball(req.http.X-BrowserProfile-Geolocation, \"(.*)region\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-BrowserProfile-Geolocation ~ \"city\") {\n set req.http.X-BrowserProfile-Geolocation-City = regsuball(req.http.X-BrowserProfile-Geolocation, \"(.*)city\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-BrowserProfile-Geolocation ~ \"isp\") {\n set req.http.X-BrowserProfile-Geolocation-ISP = regsuball(req.http.X-BrowserProfile-Geolocation, \"(.*)isp\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n } else {\n set req.http.X-BrowserProfile-Geolocation-Found = \"NO\";\n }\n }\n\n if (!req.http.X-Language) {\n if (req.http.Cookie ~ \"lang=\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.Cookie, \"(.*)lang=([^;]*)(.*)\", \"\\2\"));\n set req.http.X-Language-Found = \"YES:lang\";\n } else {\n set req.http.X-Language = \"en\";\n set req.http.X-Language-Found = \"NO\";\n }\n }\n\n if (!req.http.X-Region) {\n if (req.http.Cookie ~ \"prov=\") {\n set req.http.X-Region = std.tolower(regsuball(req.http.Cookie, \"(.*)prov=([^;]*)(.*)\", \"\\2\"));\n set req.http.X-Region-Found = \"YES:prov\";\n } else {\n set req.http.X-Region = \"bc\";\n set req.http.X-Region-Found = \"NO\";\n }\n }\n\n\n if (req.url ~ \"\/(en|fr)\/\") {\n if (req.url ~ \"\/en\/\" && req.http.X-Language != \"en\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Language (Path: \/en\/) vs (Cookie: \" + req.http.X-Language + \")\";\n return(pass);\n }\n if (req.url ~ \"\/fr\/\" && req.http.X-Language != \"fr\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Language (Path: \/fr\/) vs (Cookie: \" + req.http.X-Language + \")\";\n return(pass);\n }\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Language)\";\n return(pass);\n }\n\n if (req.url ~ \"\/(ab|bc|mb|nb|nl|ns|nt|nu|on|pe|qc|sk|yt)\/\") {\n {% for province in ['ab', 'bc', 'mb', 'nb', 'nl', 'ns', 'nt', 'nu', 'on', 'pe', 'qc', 'sk', 'yt'] %}\n if (req.url ~ \"\/{{ province }}\/\" && req.http.X-Region != \"{{ province }}\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Region (Path: \/{{ province }}\/) vs (Cookie: \" + req.http.X-Region + \")\";\n return(pass);\n }\n {% endfor %}\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Province)\";\n return(pass);\n }\n\n if (req.http.Cookie) {\n if (req.http.Cookie ~ \"***REMOVED***\") {\n set req.http.X-Screen-Resolution = regsuball(req.http.Cookie, \"(.*)***REMOVED***=([^;]*)(.*)\", \"\\2\");\n }\n\n if (req.http.Cookie ~ \"***REMOVED***\") {\n set req.http.X-Customer-Type = regsuball(req.http.Cookie, \"(.*)***REMOVED***=([^;]*)(.*)\", \"\\2\");\n }\n if (req.http.Cookie ~ \"***REMOVED***\") {\n set req.http.X-Outdated-Browser = regsuball(req.http.Cookie, \"(.*)***REMOVED***=([^;]*)(.*)\", \"\\2\");\n }\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_discard_from_client %}\n unset req.http.Cookie;\n{% endif %}\n}\n\n###\n# vcl_hit\n# Called when a cache lookup is successful.\n###\n# The vcl_hit subroutine may terminate with calling return() with one of the following keywords:\n#\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n# deliver\n# Deliver the object. Control passes to vcl_deliver.\n# synth(status code, reason)\n# Return the specified status code to the client and abandon the request.\n###\n\nsub vcl_hit {\n if (obj.ttl > 0s) {\n return (deliver);\n }\n{% if varnish_health_checks_enabled %}\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (fetch);\n }\n{% else %}\n if (obj.ttl + obj.grace > 0s) {\n return (deliver);\n }\n\n return (fetch);\n{% endif %}\n}\n\n###\n# vcl_backend_response\n# Called after the response headers has been successfully retrieved from the backend.\n###\n# The vcl_backend_response subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Possibly insert the object into the cache, then deliver it to the Control will eventually pass to vcl_deliver.\n# abandon\n# Abandon the backend request and generates an error.\n# retry\n# Retry the backend transaction. Increases the retries counter. If the number of retries is higher than max_retries Varnish emits a guru meditation error.\n###\n\nsub vcl_backend_response {\n{% if varnish_workaround_telusdotcom_browser_profile %}\n if (bereq.http.X-Language) {\n set beresp.http.X-Language = bereq.http.X-Language;\n# if (bereq.http.X-Language-Found) {\n# set beresp.http.X-Language-Found = bereq.http.X-Language-Found;\n# }\n }\n if (bereq.http.X-Region) {\n set beresp.http.X-Region = bereq.http.X-Region;\n# if (bereq.http.X-Region-Found) {\n# set beresp.http.X-Region-Found = bereq.http.X-Region-Found;\n# }\n }\n{% endif %}\n\n{% if varnish_uri_blacklist_enabled %}\n if (bereq.url ~ \"{{ varnish_uri_blacklist_regexp }}\") {\n set beresp.http.X-Cacheable = \"NO:Path in Blacklist\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n if (bereq.http.X-Passthrough-Reason) {\n{% if varnish_diagnostic_headers_passthrough_reason %}\n set beresp.http.X-Passthrough-Reason = bereq.http.X-Passthrough-Reason;\n{% endif %}\n return(deliver);\n } else {\n{% if varnish_cookie_sanitization_discard_from_server %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n }\n }\n{% else %}\n{% if varnish_cookie_sanitization_discard_from_server %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n{% endif %}\n\n{% if varnish_diagnostic_headers_enabled %}\n if (bereq.http.Cookie) {\n set beresp.http.X-Cacheable = \"NO:Cookie in Request\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO:Set-Cookie in Response\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.X-No-Cache) {\n set beresp.http.X-Cacheable = \"NO:X-No-Cache\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.ttl <= 0s) {\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n{% endif %}\n\n set beresp.grace = {{ varnish_grace_period }};\n}\n\n###\n# vcl_deliver\n# Called before a cached object is delivered to the client.\n###\n# The vcl_deliver subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Deliver the object to the client.\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n###\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n","old_contents":"vcl 4.0;\n\nimport directors;\nimport std;\n\n###\n# Varnish Documentation\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-built-in-subs.html\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/reference\/vcl.html\n##\n\n{% for backend in varnish_backend_hosts %}\nbackend application_{{ loop.index }} {\n .host = \"{{ backend }}\";\n .port = \"{{ varnish_backend_port }}\";\n{% if varnish_health_checks_enabled %}\n .probe = {\n .url = \"{{ varnish_health_check_url }}\";\n .interval = {{ varnish_health_check_interval }};\n .timeout = {{ varnish_health_check_timeout }};\n .window = {{ varnish_health_check_window }};\n .threshold = {{ varnish_health_check_threshold }};\n }\n{% endif %}\n}\n{% endfor %}\n\n###\n# vcl_init\n# Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n###\n# The vcl_init subroutine may terminate with calling return() with one of the following keywords:\n#\n# ok\n# Normal return, VCL continues loading.\n##\n\nsub vcl_init {\n new application = directors.round_robin();\n{% for backend in varnish_backend_hosts %}\n application.add_backend(application_{{ loop.index }});\n{% endfor %}\n}\n\n###\n# vcl_recv\n# Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use. \n# It is also used to modify the request\n###\n# The vcl_recv subroutine may terminate with calling return() on one of the following keywords:\n#\n# synth(status code, reason)\n# Return a synthetic object with the specified status code to the client and abandon the request.\n# pass\n# Switch to pass mode. Control will eventually pass to vcl_pass.\n# pipe\n# Switch to pipe mode. Control will eventually pass to vcl_pipe.\n# hash\n# Continue processing the object as a potential candidate for caching. Passes the control over to vcl_hash.\n# purge\n# Purge the object and it's variants. Control passes through vcl_hash to vcl_purge.\n#\n\nsub vcl_recv {\n set req.backend_hint = application.backend();\n\n ###\n # Avoid processing uncacheable requests\n ###\n\n if (req.http.Authorization) {\n set req.http.X-Passthrough-Reason = \"No Caching Authenticated Content\";\n return (pass);\n }\n\n{% if varnish_uri_blacklist_enabled %}\n if ((req.url ~ \"{{ varnish_uri_blacklist_regexp }}\")) {\n set req.http.X-Passthrough-Reason = \"Path in Blacklist\";\n return(pass);\n }\n{% endif %}\n\n{% if varnish_diagnostic_headers_forwarded_for %}\n ###\n # Inject X-Forwarded-For headers, but only once.\n ###\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n{% endif %}\n\n{% if varnish_header_sanitization_enabled %}\n ###\n # Header Sanitization\n ###\n\n{% if varnish_header_sanitization_discard_host_port %}\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n{% endif %}\n\n{% if varnish_header_sanitization_normalize_accept_encoding %}\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n{% endif %}\n\n{% endif %}\n\n{% if varnish_uri_sanitization_enabled %}\n ###\n # URI Sanitization\n ###\n \n if (req.url ~ \"(\\?|&){{ varnish_uri_sanitization_regexp }}=\") {\n set req.url = regsuball(req.url, \"&{{ varnish_uri_sanitization_regexp }}=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?{{ varnish_uri_sanitization_regexp }}=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n{% endif %}\n\n{% if varnish_workaround_telusdotcom_browser_profile %}\n ###\n # Workaround and Diagnostics for BrowserProfile and Language\/Region Detection on TELUS.com\n ###\n\n if (req.http.Cookie ~ \"BrowserProfile\") {\n set req.http.X-BrowserProfile = regsuball(req.http.Cookie, \"(.*)BrowserProfile=([^;]*)(.*)\", \"\\2\");\n if (req.http.X-BrowserProfile ~ \"language\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.X-BrowserProfile, \"(.*)language\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n set req.http.X-Language-Found = \"YES:BrowserProfile\";\n }\n if (req.http.X-BrowserProfile ~ \"region\") {\n set req.http.X-Region = std.tolower(regsuball(regsuball(req.http.X-BrowserProfile, \"geo\\\\.\\:{(.*)\\}\", \"\"), \"(.*)region\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n set req.http.X-Region-Found = \"YES:BrowserProfile\";\n }\n if (req.http.X-BrowserProfile ~ \"geo\") {\n set req.http.X-BrowserProfile-Geolocation = regsuball(req.http.X-BrowserProfile, \"(.*)geo..:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n set req.http.X-BrowserProfile-Geolocation-Found = \"YES\";\n\n if (req.http.X-BrowserProfile-Geolocation ~ \"country\") {\n set req.http.X-BrowserProfile-Geolocation-Country = regsuball(req.http.X-BrowserProfile-Geolocation, \"(.*)country\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-BrowserProfile-Geolocation ~ \"region\") {\n set req.http.X-BrowserProfile-Geolocation-Region = regsuball(req.http.X-BrowserProfile-Geolocation, \"(.*)region\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-BrowserProfile-Geolocation ~ \"city\") {\n set req.http.X-BrowserProfile-Geolocation-City = regsuball(req.http.X-BrowserProfile-Geolocation, \"(.*)city\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-BrowserProfile-Geolocation ~ \"isp\") {\n set req.http.X-BrowserProfile-Geolocation-ISP = regsuball(req.http.X-BrowserProfile-Geolocation, \"(.*)isp\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n } else {\n set req.http.X-BrowserProfile-Geolocation-Found = \"NO\";\n }\n }\n\n if (!req.http.X-Language) {\n if (req.http.Cookie ~ \"lang=\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.Cookie, \"(.*)lang=([^;]*)(.*)\", \"\\2\"));\n set req.http.X-Language-Found = \"YES:lang\";\n } else {\n set req.http.X-Language = \"en\";\n set req.http.X-Language-Found = \"NO\";\n }\n }\n\n if (!req.http.X-Region) {\n if (req.http.Cookie ~ \"prov=\") {\n set req.http.X-Region = std.tolower(regsuball(req.http.Cookie, \"(.*)prov=([^;]*)(.*)\", \"\\2\"));\n set req.http.X-Region-Found = \"YES:prov\";\n } else {\n set req.http.X-Region = \"bc\";\n set req.http.X-Region-Found = \"NO\";\n }\n }\n\n\n if (req.url ~ \"\/(en|fr)\/\") {\n if (req.url ~ \"\/en\/\" && req.http.X-Language != \"en\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Language (Path: \/en\/) vs (Cookie: \" + req.http.X-Language + \")\";\n return(pass);\n }\n if (req.url ~ \"\/fr\/\" && req.http.X-Language != \"fr\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Language (Path: \/fr\/) vs (Cookie: \" + req.http.X-Language + \")\";\n return(pass);\n }\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Language)\";\n return(pass);\n }\n\n if (req.url ~ \"\/(ab|bc|mb|nb|nl|ns|nt|nu|on|pe|qc|sk|yt)\/\") {\n {% for province in ['ab', 'bc', 'mb', 'nb', 'nl', 'ns', 'nt', 'nu', 'on', 'pe', 'qc', 'sk', 'yt'] %}\n if (req.url ~ \"\/{{ province }}\/\" && req.http.X-Region != \"{{ province }}\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Region (Path: \/{{ province }}\/) vs (Cookie: \" + req.http.X-Region + \")\";\n return(pass);\n }\n {% endfor %}\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Province)\";\n return(pass);\n }\n\n if (req.http.Cookie) {\n if (req.http.Cookie ~ \"***REMOVED***\") {\n set req.http.X-Screen-Resolution = regsuball(req.http.Cookie, \"(.*)***REMOVED***=([^;]*)(.*)\", \"\\2\");\n }\n\n if (req.http.Cookie ~ \"***REMOVED***\") {\n set req.http.X-Customer-Type = regsuball(req.http.Cookie, \"(.*)***REMOVED***=([^;]*)(.*)\", \"\\2\");\n }\n if (req.http.Cookie ~ \"***REMOVED***\") {\n set req.http.X-Outdated-Browser = regsuball(req.http.Cookie, \"(.*)***REMOVED***=([^;]*)(.*)\", \"\\2\");\n }\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_enabled %}\n ###\n # Cookie Sanitization\n ###\n if (req.http.Cookie) {\n set req.http.X-Cookie-Unmodified = req.http.Cookie;\n\n {% for cookie in varnish_cookie_sanitization_blacklist %}\n set req.http.Cookie = regsuball(req.http.Cookie, \"{{ cookie }}=[^;]+(; )?\", \"\");\n {% endfor %}\n\n ### General Cleanup\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n if (req.http.Cookie ~ \"^\\s*$\") {\n unset req.http.Cookie;\n }\n if (req.http.Cookie) {\n set req.http.X-Cookie-Sanitized = req.http.Cookie;\n }\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_discard_from_client %}\n unset req.http.Cookie;\n{% endif %}\n}\n\n###\n# vcl_hit\n# Called when a cache lookup is successful.\n###\n# The vcl_hit subroutine may terminate with calling return() with one of the following keywords:\n#\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n# deliver\n# Deliver the object. Control passes to vcl_deliver.\n# synth(status code, reason)\n# Return the specified status code to the client and abandon the request.\n###\n\nsub vcl_hit {\n if (obj.ttl > 0s) {\n return (deliver);\n }\n{% if varnish_health_checks_enabled %}\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (fetch);\n }\n{% else %}\n if (obj.ttl + obj.grace > 0s) {\n return (deliver);\n }\n\n return (fetch);\n{% endif %}\n}\n\n###\n# vcl_backend_response\n# Called after the response headers has been successfully retrieved from the backend.\n###\n# The vcl_backend_response subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Possibly insert the object into the cache, then deliver it to the Control will eventually pass to vcl_deliver.\n# abandon\n# Abandon the backend request and generates an error.\n# retry\n# Retry the backend transaction. Increases the retries counter. If the number of retries is higher than max_retries Varnish emits a guru meditation error.\n###\n\nsub vcl_backend_response {\n{% if varnish_workaround_telusdotcom_browser_profile %}\n if (bereq.http.X-Language) {\n set beresp.http.X-Language = bereq.http.X-Language;\n# if (bereq.http.X-Language-Found) {\n# set beresp.http.X-Language-Found = bereq.http.X-Language-Found;\n# }\n }\n if (bereq.http.X-Region) {\n set beresp.http.X-Region = bereq.http.X-Region;\n# if (bereq.http.X-Region-Found) {\n# set beresp.http.X-Region-Found = bereq.http.X-Region-Found;\n# }\n }\n{% endif %}\n\n{% if varnish_uri_blacklist_enabled %}\n if (bereq.url ~ \"{{ varnish_uri_blacklist_regexp }}\") {\n set beresp.http.X-Cacheable = \"NO:Path in Blacklist\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n if (bereq.http.X-Passthrough-Reason) {\n{% if varnish_diagnostic_headers_passthrough_reason %}\n set beresp.http.X-Passthrough-Reason = bereq.http.X-Passthrough-Reason;\n{% endif %}\n return(deliver);\n } else {\n{% if varnish_cookie_sanitization_discard_from_server %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n }\n }\n{% else %}\n{% if varnish_cookie_sanitization_discard_from_server %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n{% endif %}\n\n{% if varnish_diagnostic_headers_enabled %}\n if (bereq.http.Cookie) {\n set beresp.http.X-Cacheable = \"NO:Cookie in Request\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO:Set-Cookie in Response\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.X-No-Cache) {\n set beresp.http.X-Cacheable = \"NO:X-No-Cache\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.ttl <= 0s) {\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n{% endif %}\n\n set beresp.grace = {{ varnish_grace_period }};\n}\n\n###\n# vcl_deliver\n# Called before a cached object is delivered to the client.\n###\n# The vcl_deliver subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Deliver the object to the client.\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n###\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"d9e8e1b3cd14e2577b8a6a29946e4f6d4ee7f569","subject":"Normalized default province to lowercase.","message":"Normalized default province to lowercase.\n","repos":"kkwoker\/ansible-varnish,killerwails\/ansible-varnish,colstrom\/ansible-varnish,telusdigital\/ansible-varnish,gotofbi\/ansible-varnish,killerwails\/ansible-varnish,gotofbi\/ansible-varnish,noqcks\/ansible-varnish","old_file":"templates\/etc\/varnish\/default.vcl","new_file":"templates\/etc\/varnish\/default.vcl","new_contents":"vcl 4.0;\n\nimport directors;\nimport std;\n\n###\n# Varnish Documentation\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-built-in-subs.html\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/reference\/vcl.html\n##\n\n{% for backend in varnish_backend_hosts %}\nbackend application_{{ loop.index }} {\n .host = \"{{ backend }}\";\n .port = \"{{ varnish_backend_port }}\";\n{% if varnish_health_checks_enabled %}\n .probe = {\n .url = \"{{ varnish_health_check_url }}\";\n .interval = {{ varnish_health_check_interval }};\n .timeout = {{ varnish_health_check_timeout }};\n .window = {{ varnish_health_check_window }};\n .threshold = {{ varnish_health_check_threshold }};\n }\n{% endif %}\n}\n{% endfor %}\n\n###\n# vcl_init\n# Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n###\n# The vcl_init subroutine may terminate with calling return() with one of the following keywords:\n#\n# ok\n# Normal return, VCL continues loading.\n##\n\nsub vcl_init {\n new application = directors.round_robin();\n{% for backend in varnish_backend_hosts %}\n application.add_backend(application_{{ loop.index }});\n{% endfor %}\n}\n\n###\n# vcl_recv\n# Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use. \n# It is also used to modify the request\n###\n# The vcl_recv subroutine may terminate with calling return() on one of the following keywords:\n#\n# synth(status code, reason)\n# Return a synthetic object with the specified status code to the client and abandon the request.\n# pass\n# Switch to pass mode. Control will eventually pass to vcl_pass.\n# pipe\n# Switch to pipe mode. Control will eventually pass to vcl_pipe.\n# hash\n# Continue processing the object as a potential candidate for caching. Passes the control over to vcl_hash.\n# purge\n# Purge the object and it's variants. Control passes through vcl_hash to vcl_purge.\n#\n\nsub vcl_recv {\n set req.backend_hint = application.backend();\n\n ###\n # Avoid processing uncacheable requests\n ###\n\n if (req.http.Authorization) {\n return (pass);\n }\n\n{% if varnish_blacklist_enabled %}\n if ((req.url ~ \"{{ varnish_blacklist_regexp }}\")) {\n set req.http.X-Passthrough-Reason = \"Path in Blacklist\";\n return(pass);\n }\n{% endif %}\n\n ###\n # Inject X-Forwarded-For headers, but only once.\n ###\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n{% if varnish_header_sanitization_enabled %}\n ###\n # Header Sanitization\n ###\n\n{% if varnish_discards_port_from_host_header %}\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n{% endif %}\n\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_enabled %}\n ###\n # Cookie Sanitization\n ###\n\n ### Google Analytics\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n\n ### Quantcast\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n \n ### AddThis\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n\n ### General Cleanup\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n{% endif %}\n\n{% if varnish_uri_sanitization_enabled %}\n ###\n # URI Sanitization\n ###\n \n if (req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=\") {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n{% endif %}\n\n{% if varnish_workaround_telusdotcom_browser_profile %}\n ###\n # Workaround for BrowserProfile and Language\/Region Detection on TELUS.com\n ###\n\n if (req.http.Cookie ~ \"BrowserProfile\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.Cookie, \"(.*)language..:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n set req.http.X-Province = std.tolower(regsuball(regsuball(req.http.Cookie, \"geo\\\\.\\:{(.*)\\}\", \"\"), \"(.*)region..:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n } else {\n if (req.http.Cookie ~ \"lang=\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.Cookie, \"(.*)lang=([^;]*)(.*)\", \"\\2\"));\n } else {\n set req.http.X-Language = \"en\";\n }\n\n if (req.http.Cookie ~ \"prov=\") {\n set req.http.X-Province = std.tolower(regsuball(req.http.Cookie, \"(.*)prov=([^;]*)(.*)\", \"\\2\"));\n } else {\n set req.http.X-Province = \"bc\";\n }\n }\n\n if (req.url ~ \"\/(en|fr)\/\") {\n if (req.url ~ \"\/en\/\" && req.http.X-Language != \"en\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Language)\";\n return(pass);\n }\n if (req.url ~ \"\/fr\/\" && req.http.X-Language != \"fr\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Language)\";\n return(pass);\n }\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Language)\";\n return(pass);\n }\n\n if (req.url ~ \"\/(ab|bc|mb|nb|nl|ns|nt|nu|on|pe|qc|sk|yt)\/\") {\n {% for province in ['ab', 'bc', 'mb', 'nb', 'nl', 'ns', 'nt', 'nu', 'on', 'pe', 'qc', 'sk', 'yt'] %}\n if (req.url ~ \"\/{{ province }}\/\" && req.http.X-Province != \"{{ province }}\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Province)\";\n return(pass);\n }\n {% endfor %}\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Province)\";\n return(pass);\n }\n{% endif %}\n\n{% if varnish_discards_client_cookies %}\n unset req.http.Cookie;\n{% endif %}\n}\n\n###\n# vcl_hit\n# Called when a cache lookup is successful.\n###\n# The vcl_hit subroutine may terminate with calling return() with one of the following keywords:\n#\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n# deliver\n# Deliver the object. Control passes to vcl_deliver.\n# synth(status code, reason)\n# Return the specified status code to the client and abandon the request.\n###\n\nsub vcl_hit {\n if (obj.ttl > 0s) {\n return (deliver);\n }\n{% if varnish_health_checks_enabled %}\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (fetch);\n }\n{% else %}\n if (obj.ttl + obj.grace > 0s) {\n return (deliver);\n }\n\n return (fetch);\n{% endif %}\n}\n\n###\n# vcl_backend_response\n# Called after the response headers has been successfully retrieved from the backend.\n###\n# The vcl_backend_response subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Possibly insert the object into the cache, then deliver it to the Control will eventually pass to vcl_deliver.\n# abandon\n# Abandon the backend request and generates an error.\n# retry\n# Retry the backend transaction. Increases the retries counter. If the number of retries is higher than max_retries Varnish emits a guru meditation error.\n###\n\nsub vcl_backend_response {\n{% if varnish_workaround_telusdotcom_browser_profile %}\n if (bereq.http.X-Language) {\n set beresp.http.X-Language = bereq.http.X-Language;\n }\n if (bereq.http.X-Province) {\n set beresp.http.X-Province = bereq.http.X-Province;\n }\n{% endif %}\n\n{% if varnish_blacklist_enabled %}\n if (bereq.url ~ \"{{ varnish_blacklist_regexp }}\") {\n set beresp.http.X-Cacheable = \"NO:Path in Blacklist\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n if (bereq.http.X-Passthrough-Reason) {\n set beresp.http.X-Passthrough-Reason = bereq.http.X-Passthrough-Reason;\n return(deliver);\n } else {\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n }\n }\n{% else %}\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n{% endif %}\n\n{% if varnish_cache_diagnostics_enabled %}\n if (bereq.http.Cookie) {\n set beresp.http.X-Cacheable = \"NO:Cookie in Request\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO:Set-Cookie in Response\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.X-No-Cache) {\n set beresp.http.X-Cacheable = \"NO:X-No-Cache\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.ttl <= 0s) {\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n{% endif %}\n\n set beresp.grace = {{ varnish_grace_period }};\n}\n\n###\n# vcl_deliver\n# Called before a cached object is delivered to the client.\n###\n# The vcl_deliver subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Deliver the object to the client.\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n###\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n","old_contents":"vcl 4.0;\n\nimport directors;\nimport std;\n\n###\n# Varnish Documentation\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-built-in-subs.html\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/reference\/vcl.html\n##\n\n{% for backend in varnish_backend_hosts %}\nbackend application_{{ loop.index }} {\n .host = \"{{ backend }}\";\n .port = \"{{ varnish_backend_port }}\";\n{% if varnish_health_checks_enabled %}\n .probe = {\n .url = \"{{ varnish_health_check_url }}\";\n .interval = {{ varnish_health_check_interval }};\n .timeout = {{ varnish_health_check_timeout }};\n .window = {{ varnish_health_check_window }};\n .threshold = {{ varnish_health_check_threshold }};\n }\n{% endif %}\n}\n{% endfor %}\n\n###\n# vcl_init\n# Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n###\n# The vcl_init subroutine may terminate with calling return() with one of the following keywords:\n#\n# ok\n# Normal return, VCL continues loading.\n##\n\nsub vcl_init {\n new application = directors.round_robin();\n{% for backend in varnish_backend_hosts %}\n application.add_backend(application_{{ loop.index }});\n{% endfor %}\n}\n\n###\n# vcl_recv\n# Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use. \n# It is also used to modify the request\n###\n# The vcl_recv subroutine may terminate with calling return() on one of the following keywords:\n#\n# synth(status code, reason)\n# Return a synthetic object with the specified status code to the client and abandon the request.\n# pass\n# Switch to pass mode. Control will eventually pass to vcl_pass.\n# pipe\n# Switch to pipe mode. Control will eventually pass to vcl_pipe.\n# hash\n# Continue processing the object as a potential candidate for caching. Passes the control over to vcl_hash.\n# purge\n# Purge the object and it's variants. Control passes through vcl_hash to vcl_purge.\n#\n\nsub vcl_recv {\n set req.backend_hint = application.backend();\n\n ###\n # Avoid processing uncacheable requests\n ###\n\n if (req.http.Authorization) {\n return (pass);\n }\n\n{% if varnish_blacklist_enabled %}\n if ((req.url ~ \"{{ varnish_blacklist_regexp }}\")) {\n set req.http.X-Passthrough-Reason = \"Path in Blacklist\";\n return(pass);\n }\n{% endif %}\n\n ###\n # Inject X-Forwarded-For headers, but only once.\n ###\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n{% if varnish_header_sanitization_enabled %}\n ###\n # Header Sanitization\n ###\n\n{% if varnish_discards_port_from_host_header %}\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n{% endif %}\n\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_enabled %}\n ###\n # Cookie Sanitization\n ###\n\n ### Google Analytics\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n\n ### Quantcast\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n \n ### AddThis\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n\n ### General Cleanup\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n{% endif %}\n\n{% if varnish_uri_sanitization_enabled %}\n ###\n # URI Sanitization\n ###\n \n if (req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=\") {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n{% endif %}\n\n{% if varnish_workaround_telusdotcom_browser_profile %}\n ###\n # Workaround for BrowserProfile and Language\/Region Detection on TELUS.com\n ###\n\n if (req.http.Cookie ~ \"BrowserProfile\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.Cookie, \"(.*)language..:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n set req.http.X-Province = std.tolower(regsuball(regsuball(req.http.Cookie, \"geo\\\\.\\:{(.*)\\}\", \"\"), \"(.*)region..:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n } else {\n if (req.http.Cookie ~ \"lang=\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.Cookie, \"(.*)lang=([^;]*)(.*)\", \"\\2\"));\n } else {\n set req.http.X-Language = \"en\";\n }\n\n if (req.http.Cookie ~ \"prov=\") {\n set req.http.X-Province = std.tolower(regsuball(req.http.Cookie, \"(.*)prov=([^;]*)(.*)\", \"\\2\"));\n } else {\n set req.http.X-Province = \"BC\";\n }\n }\n\n if (req.url ~ \"\/(en|fr)\/\") {\n if (req.url ~ \"\/en\/\" && req.http.X-Language != \"en\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Language)\";\n return(pass);\n }\n if (req.url ~ \"\/fr\/\" && req.http.X-Language != \"fr\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Language)\";\n return(pass);\n }\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Language)\";\n return(pass);\n }\n\n if (req.url ~ \"\/(ab|bc|mb|nb|nl|ns|nt|nu|on|pe|qc|sk|yt)\/\") {\n {% for province in ['ab', 'bc', 'mb', 'nb', 'nl', 'ns', 'nt', 'nu', 'on', 'pe', 'qc', 'sk', 'yt'] %}\n if (req.url ~ \"\/{{ province }}\/\" && req.http.X-Province != \"{{ province }}\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Province)\";\n return(pass);\n }\n {% endfor %}\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Province)\";\n return(pass);\n }\n{% endif %}\n\n{% if varnish_discards_client_cookies %}\n unset req.http.Cookie;\n{% endif %}\n}\n\n###\n# vcl_hit\n# Called when a cache lookup is successful.\n###\n# The vcl_hit subroutine may terminate with calling return() with one of the following keywords:\n#\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n# deliver\n# Deliver the object. Control passes to vcl_deliver.\n# synth(status code, reason)\n# Return the specified status code to the client and abandon the request.\n###\n\nsub vcl_hit {\n if (obj.ttl > 0s) {\n return (deliver);\n }\n{% if varnish_health_checks_enabled %}\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (fetch);\n }\n{% else %}\n if (obj.ttl + obj.grace > 0s) {\n return (deliver);\n }\n\n return (fetch);\n{% endif %}\n}\n\n###\n# vcl_backend_response\n# Called after the response headers has been successfully retrieved from the backend.\n###\n# The vcl_backend_response subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Possibly insert the object into the cache, then deliver it to the Control will eventually pass to vcl_deliver.\n# abandon\n# Abandon the backend request and generates an error.\n# retry\n# Retry the backend transaction. Increases the retries counter. If the number of retries is higher than max_retries Varnish emits a guru meditation error.\n###\n\nsub vcl_backend_response {\n{% if varnish_workaround_telusdotcom_browser_profile %}\n if (bereq.http.X-Language) {\n set beresp.http.X-Language = bereq.http.X-Language;\n }\n if (bereq.http.X-Province) {\n set beresp.http.X-Province = bereq.http.X-Province;\n }\n{% endif %}\n\n{% if varnish_blacklist_enabled %}\n if (bereq.url ~ \"{{ varnish_blacklist_regexp }}\") {\n set beresp.http.X-Cacheable = \"NO:Path in Blacklist\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n if (bereq.http.X-Passthrough-Reason) {\n set beresp.http.X-Passthrough-Reason = bereq.http.X-Passthrough-Reason;\n return(deliver);\n } else {\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n }\n }\n{% else %}\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n{% endif %}\n\n{% if varnish_cache_diagnostics_enabled %}\n if (bereq.http.Cookie) {\n set beresp.http.X-Cacheable = \"NO:Cookie in Request\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO:Set-Cookie in Response\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.X-No-Cache) {\n set beresp.http.X-Cacheable = \"NO:X-No-Cache\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.ttl <= 0s) {\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n{% endif %}\n\n set beresp.grace = {{ varnish_grace_period }};\n}\n\n###\n# vcl_deliver\n# Called before a cached object is delivered to the client.\n###\n# The vcl_deliver subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Deliver the object to the client.\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n###\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"400e4c1847461eaca38273171db81878c3e9795b","subject":"Don't sanitize cookies if they don't exist.","message":"Don't sanitize cookies if they don't exist.\n","repos":"killerwails\/ansible-varnish,kkwoker\/ansible-varnish,noqcks\/ansible-varnish,telusdigital\/ansible-varnish,gotofbi\/ansible-varnish,colstrom\/ansible-varnish,killerwails\/ansible-varnish,gotofbi\/ansible-varnish","old_file":"templates\/etc\/varnish\/default.vcl","new_file":"templates\/etc\/varnish\/default.vcl","new_contents":"vcl 4.0;\n\nimport directors;\nimport std;\n\n###\n# Varnish Documentation\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-built-in-subs.html\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/reference\/vcl.html\n##\n\n{% for backend in varnish_backend_hosts %}\nbackend application_{{ loop.index }} {\n .host = \"{{ backend }}\";\n .port = \"{{ varnish_backend_port }}\";\n{% if varnish_health_checks_enabled %}\n .probe = {\n .url = \"{{ varnish_health_check_url }}\";\n .interval = {{ varnish_health_check_interval }};\n .timeout = {{ varnish_health_check_timeout }};\n .window = {{ varnish_health_check_window }};\n .threshold = {{ varnish_health_check_threshold }};\n }\n{% endif %}\n}\n{% endfor %}\n\n###\n# vcl_init\n# Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n###\n# The vcl_init subroutine may terminate with calling return() with one of the following keywords:\n#\n# ok\n# Normal return, VCL continues loading.\n##\n\nsub vcl_init {\n new application = directors.round_robin();\n{% for backend in varnish_backend_hosts %}\n application.add_backend(application_{{ loop.index }});\n{% endfor %}\n}\n\n###\n# vcl_recv\n# Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use. \n# It is also used to modify the request\n###\n# The vcl_recv subroutine may terminate with calling return() on one of the following keywords:\n#\n# synth(status code, reason)\n# Return a synthetic object with the specified status code to the client and abandon the request.\n# pass\n# Switch to pass mode. Control will eventually pass to vcl_pass.\n# pipe\n# Switch to pipe mode. Control will eventually pass to vcl_pipe.\n# hash\n# Continue processing the object as a potential candidate for caching. Passes the control over to vcl_hash.\n# purge\n# Purge the object and it's variants. Control passes through vcl_hash to vcl_purge.\n#\n\nsub vcl_recv {\n set req.backend_hint = application.backend();\n\n ###\n # Avoid processing uncacheable requests\n ###\n\n if (req.http.Authorization) {\n set req.http.X-Passthrough-Reason = \"No Caching Authenticated Content\";\n return (pass);\n }\n\n{% if varnish_uri_blacklist_enabled %}\n if ((req.url ~ \"{{ varnish_uri_blacklist_regexp }}\")) {\n set req.http.X-Passthrough-Reason = \"Path in Blacklist\";\n return(pass);\n }\n{% endif %}\n\n{% if varnish_diagnostic_headers_forwarded_for %}\n ###\n # Inject X-Forwarded-For headers, but only once.\n ###\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n{% endif %}\n\n{% if varnish_header_sanitization_enabled %}\n ###\n # Header Sanitization\n ###\n\n{% if varnish_header_sanitization_discard_host_port %}\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n{% endif %}\n\n{% if varnish_header_sanitization_normalize_accept_encoding %}\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n{% endif %}\n\n{% endif %}\n\n{% if varnish_cookie_sanitization_enabled %}\n ###\n # Cookie Sanitization\n ###\n if (req.http.Cookie) {\n set req.http.X-Cookie-Unmodified = req.http.Cookie;\n\n {% for cookie in varnish_cookie_sanitization_blacklist %}\n set req.http.Cookie = regsuball(req.http.Cookie, \"{{ cookie }}=[^;]+(; )?\", \"\");\n {% endfor %}\n\n ### General Cleanup\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n if (req.http.Cookie ~ \"^\\s*$\") {\n unset req.http.Cookie;\n }\n if (req.http.Cookie) {\n set req.http.X-Cookie-Sanitized = req.http.Cookie;\n }\n }\n{% endif %}\n\n{% if varnish_uri_sanitization_enabled %}\n ###\n # URI Sanitization\n ###\n \n if (req.url ~ \"(\\?|&){{ varnish_uri_sanitization_regexp }}=\") {\n set req.url = regsuball(req.url, \"&{{ varnish_uri_sanitization_regexp }}=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?{{ varnish_uri_sanitization_regexp }}=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n{% endif %}\n\n{% if varnish_workaround_telusdotcom_browser_profile %}\n ###\n # Workaround and Diagnostics for BrowserProfile and Language\/Region Detection on TELUS.com\n ###\n\n if (req.http.Cookie ~ \"BrowserProfile\") {\n set req.http.X-BrowserProfile = regsuball(req.http.Cookie, \"(.*)BrowserProfile=([^;]*)(.*)\", \"\\2\");\n if (req.http.X-BrowserProfile ~ \"language\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.X-BrowserProfile, \"(.*)language\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n set req.http.X-Language-Found = \"YES:BrowserProfile\";\n }\n if (req.http.X-BrowserProfile ~ \"region\") {\n set req.http.X-Region = std.tolower(regsuball(regsuball(req.http.X-BrowserProfile, \"geo\\\\.\\:{(.*)\\}\", \"\"), \"(.*)region\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n set req.http.X-Region-Found = \"YES:BrowserProfile\";\n }\n if (req.http.X-BrowserProfile ~ \"geo\") {\n set req.http.X-BrowserProfile-Geolocation = regsuball(req.http.X-BrowserProfile, \"(.*)geo..:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n set req.http.X-BrowserProfile-Geolocation-Found = \"YES\";\n\n if (req.http.X-BrowserProfile-Geolocation ~ \"country\") {\n set req.http.X-BrowserProfile-Geolocation-Country = regsuball(req.http.X-BrowserProfile-Geolocation, \"(.*)country\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-BrowserProfile-Geolocation ~ \"region\") {\n set req.http.X-BrowserProfile-Geolocation-Region = regsuball(req.http.X-BrowserProfile-Geolocation, \"(.*)region\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-BrowserProfile-Geolocation ~ \"city\") {\n set req.http.X-BrowserProfile-Geolocation-City = regsuball(req.http.X-BrowserProfile-Geolocation, \"(.*)city\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-BrowserProfile-Geolocation ~ \"isp\") {\n set req.http.X-BrowserProfile-Geolocation-ISP = regsuball(req.http.X-BrowserProfile-Geolocation, \"(.*)isp\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n } else {\n set req.http.X-BrowserProfile-Geolocation-Found = \"NO\";\n }\n }\n\n if (!req.http.X-Language) {\n if (req.http.Cookie ~ \"lang=\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.Cookie, \"(.*)lang=([^;]*)(.*)\", \"\\2\"));\n set req.http.X-Language-Found = \"YES:lang\";\n } else {\n set req.http.X-Language = \"en\";\n set req.http.X-Language-Found = \"NO\";\n }\n }\n\n if (!req.http.X-Region) {\n if (req.http.Cookie ~ \"prov=\") {\n set req.http.X-Region = std.tolower(regsuball(req.http.Cookie, \"(.*)prov=([^;]*)(.*)\", \"\\2\"));\n set req.http.X-Region-Found = \"YES:prov\";\n } else {\n set req.http.X-Region = \"bc\";\n set req.http.X-Region-Found = \"NO\";\n }\n }\n\n if (req.url ~ \"\/(en|fr)\/\") {\n if (req.url ~ \"\/en\/\" && req.http.X-Language != \"en\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Language (Path: \/en\/) vs (Cookie: \" + req.http.X-Language + \")\";\n return(pass);\n }\n if (req.url ~ \"\/fr\/\" && req.http.X-Language != \"fr\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Language (Path: \/fr\/) vs (Cookie: \" + req.http.X-Language + \")\";\n return(pass);\n }\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Language)\";\n return(pass);\n }\n\n if (req.url ~ \"\/(ab|bc|mb|nb|nl|ns|nt|nu|on|pe|qc|sk|yt)\/\") {\n {% for province in ['ab', 'bc', 'mb', 'nb', 'nl', 'ns', 'nt', 'nu', 'on', 'pe', 'qc', 'sk', 'yt'] %}\n if (req.url ~ \"\/{{ province }}\/\" && req.http.X-Region != \"{{ province }}\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Region (Path: \/{{ province }}\/) vs (Cookie: \" + req.http.X-Region + \")\";\n return(pass);\n }\n {% endfor %}\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Province)\";\n return(pass);\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_discard_from_client %}\n unset req.http.Cookie;\n{% endif %}\n}\n\n###\n# vcl_hit\n# Called when a cache lookup is successful.\n###\n# The vcl_hit subroutine may terminate with calling return() with one of the following keywords:\n#\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n# deliver\n# Deliver the object. Control passes to vcl_deliver.\n# synth(status code, reason)\n# Return the specified status code to the client and abandon the request.\n###\n\nsub vcl_hit {\n if (obj.ttl > 0s) {\n return (deliver);\n }\n{% if varnish_health_checks_enabled %}\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (fetch);\n }\n{% else %}\n if (obj.ttl + obj.grace > 0s) {\n return (deliver);\n }\n\n return (fetch);\n{% endif %}\n}\n\n###\n# vcl_backend_response\n# Called after the response headers has been successfully retrieved from the backend.\n###\n# The vcl_backend_response subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Possibly insert the object into the cache, then deliver it to the Control will eventually pass to vcl_deliver.\n# abandon\n# Abandon the backend request and generates an error.\n# retry\n# Retry the backend transaction. Increases the retries counter. If the number of retries is higher than max_retries Varnish emits a guru meditation error.\n###\n\nsub vcl_backend_response {\n{% if varnish_workaround_telusdotcom_browser_profile %}\n if (bereq.http.X-Language) {\n set beresp.http.X-Language = bereq.http.X-Language;\n# if (bereq.http.X-Language-Found) {\n# set beresp.http.X-Language-Found = bereq.http.X-Language-Found;\n# }\n }\n if (bereq.http.X-Region) {\n set beresp.http.X-Region = bereq.http.X-Region;\n# if (bereq.http.X-Region-Found) {\n# set beresp.http.X-Region-Found = bereq.http.X-Region-Found;\n# }\n }\n{% endif %}\n\n{% if varnish_uri_blacklist_enabled %}\n if (bereq.url ~ \"{{ varnish_uri_blacklist_regexp }}\") {\n set beresp.http.X-Cacheable = \"NO:Path in Blacklist\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n if (bereq.http.X-Passthrough-Reason) {\n{% if varnish_diagnostic_headers_passthrough_reason %}\n set beresp.http.X-Passthrough-Reason = bereq.http.X-Passthrough-Reason;\n{% endif %}\n return(deliver);\n } else {\n{% if varnish_cookie_sanitization_discard_from_server %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n }\n }\n{% else %}\n{% if varnish_cookie_sanitization_discard_from_server %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n{% endif %}\n\n{% if varnish_diagnostic_headers_enabled %}\n if (bereq.http.Cookie) {\n set beresp.http.X-Cacheable = \"NO:Cookie in Request\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO:Set-Cookie in Response\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.X-No-Cache) {\n set beresp.http.X-Cacheable = \"NO:X-No-Cache\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.ttl <= 0s) {\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n{% endif %}\n\n set beresp.grace = {{ varnish_grace_period }};\n}\n\n###\n# vcl_deliver\n# Called before a cached object is delivered to the client.\n###\n# The vcl_deliver subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Deliver the object to the client.\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n###\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n","old_contents":"vcl 4.0;\n\nimport directors;\nimport std;\n\n###\n# Varnish Documentation\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-built-in-subs.html\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/reference\/vcl.html\n##\n\n{% for backend in varnish_backend_hosts %}\nbackend application_{{ loop.index }} {\n .host = \"{{ backend }}\";\n .port = \"{{ varnish_backend_port }}\";\n{% if varnish_health_checks_enabled %}\n .probe = {\n .url = \"{{ varnish_health_check_url }}\";\n .interval = {{ varnish_health_check_interval }};\n .timeout = {{ varnish_health_check_timeout }};\n .window = {{ varnish_health_check_window }};\n .threshold = {{ varnish_health_check_threshold }};\n }\n{% endif %}\n}\n{% endfor %}\n\n###\n# vcl_init\n# Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n###\n# The vcl_init subroutine may terminate with calling return() with one of the following keywords:\n#\n# ok\n# Normal return, VCL continues loading.\n##\n\nsub vcl_init {\n new application = directors.round_robin();\n{% for backend in varnish_backend_hosts %}\n application.add_backend(application_{{ loop.index }});\n{% endfor %}\n}\n\n###\n# vcl_recv\n# Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use. \n# It is also used to modify the request\n###\n# The vcl_recv subroutine may terminate with calling return() on one of the following keywords:\n#\n# synth(status code, reason)\n# Return a synthetic object with the specified status code to the client and abandon the request.\n# pass\n# Switch to pass mode. Control will eventually pass to vcl_pass.\n# pipe\n# Switch to pipe mode. Control will eventually pass to vcl_pipe.\n# hash\n# Continue processing the object as a potential candidate for caching. Passes the control over to vcl_hash.\n# purge\n# Purge the object and it's variants. Control passes through vcl_hash to vcl_purge.\n#\n\nsub vcl_recv {\n set req.backend_hint = application.backend();\n\n ###\n # Avoid processing uncacheable requests\n ###\n\n if (req.http.Authorization) {\n set req.http.X-Passthrough-Reason = \"No Caching Authenticated Content\";\n return (pass);\n }\n\n{% if varnish_uri_blacklist_enabled %}\n if ((req.url ~ \"{{ varnish_uri_blacklist_regexp }}\")) {\n set req.http.X-Passthrough-Reason = \"Path in Blacklist\";\n return(pass);\n }\n{% endif %}\n\n{% if varnish_diagnostic_headers_forwarded_for %}\n ###\n # Inject X-Forwarded-For headers, but only once.\n ###\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n{% endif %}\n\n{% if varnish_header_sanitization_enabled %}\n ###\n # Header Sanitization\n ###\n\n{% if varnish_header_sanitization_discard_host_port %}\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n{% endif %}\n\n{% if varnish_header_sanitization_normalize_accept_encoding %}\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n{% endif %}\n\n{% endif %}\n\n{% if varnish_cookie_sanitization_enabled %}\n ###\n # Cookie Sanitization\n ###\n set req.http.X-Cookie-Unmodified = req.http.Cookie;\n\n{% for cookie in varnish_cookie_sanitization_blacklist %}\n set req.http.Cookie = regsuball(req.http.Cookie, \"{{ cookie }}=[^;]+(; )?\", \"\");\n{% endfor %}\n\n ### General Cleanup\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n if (req.http.Cookie ~ \"^\\s*$\") {\n unset req.http.Cookie;\n }\n if (req.http.Cookie) {\n set req.http.X-Cookie-Sanitized = req.http.Cookie;\n }\n{% endif %}\n\n{% if varnish_uri_sanitization_enabled %}\n ###\n # URI Sanitization\n ###\n \n if (req.url ~ \"(\\?|&){{ varnish_uri_sanitization_regexp }}=\") {\n set req.url = regsuball(req.url, \"&{{ varnish_uri_sanitization_regexp }}=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?{{ varnish_uri_sanitization_regexp }}=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n{% endif %}\n\n{% if varnish_workaround_telusdotcom_browser_profile %}\n ###\n # Workaround and Diagnostics for BrowserProfile and Language\/Region Detection on TELUS.com\n ###\n\n if (req.http.Cookie ~ \"BrowserProfile\") {\n set req.http.X-BrowserProfile = regsuball(req.http.Cookie, \"(.*)BrowserProfile=([^;]*)(.*)\", \"\\2\");\n if (req.http.X-BrowserProfile ~ \"language\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.X-BrowserProfile, \"(.*)language\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n set req.http.X-Language-Found = \"YES:BrowserProfile\";\n }\n if (req.http.X-BrowserProfile ~ \"region\") {\n set req.http.X-Region = std.tolower(regsuball(regsuball(req.http.X-BrowserProfile, \"geo\\\\.\\:{(.*)\\}\", \"\"), \"(.*)region\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n set req.http.X-Region-Found = \"YES:BrowserProfile\";\n }\n if (req.http.X-BrowserProfile ~ \"geo\") {\n set req.http.X-BrowserProfile-Geolocation = regsuball(req.http.X-BrowserProfile, \"(.*)geo..:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n set req.http.X-BrowserProfile-Geolocation-Found = \"YES\";\n\n if (req.http.X-BrowserProfile-Geolocation ~ \"country\") {\n set req.http.X-BrowserProfile-Geolocation-Country = regsuball(req.http.X-BrowserProfile-Geolocation, \"(.*)country\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-BrowserProfile-Geolocation ~ \"region\") {\n set req.http.X-BrowserProfile-Geolocation-Region = regsuball(req.http.X-BrowserProfile-Geolocation, \"(.*)region\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-BrowserProfile-Geolocation ~ \"city\") {\n set req.http.X-BrowserProfile-Geolocation-City = regsuball(req.http.X-BrowserProfile-Geolocation, \"(.*)city\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-BrowserProfile-Geolocation ~ \"isp\") {\n set req.http.X-BrowserProfile-Geolocation-ISP = regsuball(req.http.X-BrowserProfile-Geolocation, \"(.*)isp\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n } else {\n set req.http.X-BrowserProfile-Geolocation-Found = \"NO\";\n }\n }\n\n if (!req.http.X-Language) {\n if (req.http.Cookie ~ \"lang=\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.Cookie, \"(.*)lang=([^;]*)(.*)\", \"\\2\"));\n set req.http.X-Language-Found = \"YES:lang\";\n } else {\n set req.http.X-Language = \"en\";\n set req.http.X-Language-Found = \"NO\";\n }\n }\n\n if (!req.http.X-Region) {\n if (req.http.Cookie ~ \"prov=\") {\n set req.http.X-Region = std.tolower(regsuball(req.http.Cookie, \"(.*)prov=([^;]*)(.*)\", \"\\2\"));\n set req.http.X-Region-Found = \"YES:prov\";\n } else {\n set req.http.X-Region = \"bc\";\n set req.http.X-Region-Found = \"NO\";\n }\n }\n\n if (req.url ~ \"\/(en|fr)\/\") {\n if (req.url ~ \"\/en\/\" && req.http.X-Language != \"en\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Language (Path: \/en\/) vs (Cookie: \" + req.http.X-Language + \")\";\n return(pass);\n }\n if (req.url ~ \"\/fr\/\" && req.http.X-Language != \"fr\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Language (Path: \/fr\/) vs (Cookie: \" + req.http.X-Language + \")\";\n return(pass);\n }\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Language)\";\n return(pass);\n }\n\n if (req.url ~ \"\/(ab|bc|mb|nb|nl|ns|nt|nu|on|pe|qc|sk|yt)\/\") {\n {% for province in ['ab', 'bc', 'mb', 'nb', 'nl', 'ns', 'nt', 'nu', 'on', 'pe', 'qc', 'sk', 'yt'] %}\n if (req.url ~ \"\/{{ province }}\/\" && req.http.X-Region != \"{{ province }}\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Region (Path: \/{{ province }}\/) vs (Cookie: \" + req.http.X-Region + \")\";\n return(pass);\n }\n {% endfor %}\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Province)\";\n return(pass);\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_discard_from_client %}\n unset req.http.Cookie;\n{% endif %}\n}\n\n###\n# vcl_hit\n# Called when a cache lookup is successful.\n###\n# The vcl_hit subroutine may terminate with calling return() with one of the following keywords:\n#\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n# deliver\n# Deliver the object. Control passes to vcl_deliver.\n# synth(status code, reason)\n# Return the specified status code to the client and abandon the request.\n###\n\nsub vcl_hit {\n if (obj.ttl > 0s) {\n return (deliver);\n }\n{% if varnish_health_checks_enabled %}\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (fetch);\n }\n{% else %}\n if (obj.ttl + obj.grace > 0s) {\n return (deliver);\n }\n\n return (fetch);\n{% endif %}\n}\n\n###\n# vcl_backend_response\n# Called after the response headers has been successfully retrieved from the backend.\n###\n# The vcl_backend_response subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Possibly insert the object into the cache, then deliver it to the Control will eventually pass to vcl_deliver.\n# abandon\n# Abandon the backend request and generates an error.\n# retry\n# Retry the backend transaction. Increases the retries counter. If the number of retries is higher than max_retries Varnish emits a guru meditation error.\n###\n\nsub vcl_backend_response {\n{% if varnish_workaround_telusdotcom_browser_profile %}\n if (bereq.http.X-Language) {\n set beresp.http.X-Language = bereq.http.X-Language;\n# if (bereq.http.X-Language-Found) {\n# set beresp.http.X-Language-Found = bereq.http.X-Language-Found;\n# }\n }\n if (bereq.http.X-Region) {\n set beresp.http.X-Region = bereq.http.X-Region;\n# if (bereq.http.X-Region-Found) {\n# set beresp.http.X-Region-Found = bereq.http.X-Region-Found;\n# }\n }\n{% endif %}\n\n{% if varnish_uri_blacklist_enabled %}\n if (bereq.url ~ \"{{ varnish_uri_blacklist_regexp }}\") {\n set beresp.http.X-Cacheable = \"NO:Path in Blacklist\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n if (bereq.http.X-Passthrough-Reason) {\n{% if varnish_diagnostic_headers_passthrough_reason %}\n set beresp.http.X-Passthrough-Reason = bereq.http.X-Passthrough-Reason;\n{% endif %}\n return(deliver);\n } else {\n{% if varnish_cookie_sanitization_discard_from_server %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n }\n }\n{% else %}\n{% if varnish_cookie_sanitization_discard_from_server %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n{% endif %}\n\n{% if varnish_diagnostic_headers_enabled %}\n if (bereq.http.Cookie) {\n set beresp.http.X-Cacheable = \"NO:Cookie in Request\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO:Set-Cookie in Response\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.X-No-Cache) {\n set beresp.http.X-Cacheable = \"NO:X-No-Cache\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.ttl <= 0s) {\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n{% endif %}\n\n set beresp.grace = {{ varnish_grace_period }};\n}\n\n###\n# vcl_deliver\n# Called before a cached object is delivered to the client.\n###\n# The vcl_deliver subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Deliver the object to the client.\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n###\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"f1ebf32b6e00b25f3d1f5efc155b73720e776212","subject":"Update main.vcl","message":"Update main.vcl","repos":"JakeChampion\/polyfill-service,JakeChampion\/polyfill-service","old_file":"fastly\/vcl\/main.vcl","new_file":"fastly\/vcl\/main.vcl","new_contents":"import querystring;\n\nsub sort_comma_separated_value {\n\t# This function takes a CSV and tranforms it into a url where each\n\t# comma-separated-value is a query-string parameter and then uses\n\t# Fastly's querystring.sort function to sort the values. Once sorted\n\t# it then turn the query-parameters back into a CSV.\n\t# Set the CSV on the header `Sort-Value`.\n\t# Returns the sorted CSV on the header `Sorted-Value`.\n\tdeclare local var.value STRING;\n\tset var.value = req.http.Sort-value;\n\n\t# If query value does not exist or is empty, set it to \"\"\n\tset var.value = if(var.value != \"\", var.value, \"\");\n\n\t# Replace all `&` characters with `^`, this is because `&` would break the value up into pieces.\n\tset var.value = regsuball(var.value, \"&\", \"^\");\n\n\t# Replace all `,` characters with `&` to break them into individual query values\n\t# Append `1-` infront of all the query values to make them simpler to transform later\n\tset var.value = \"1-\" regsuball(var.value, \",\", \"&1-\");\n\n\t# Create a querystring-like string in order for querystring.sort to work.\n\tset var.value = querystring.sort(\"?\" var.value);\n\n\t# Grab all the query values from the sorted url\n\tset var.value = regsub(var.value, \"\\?\", \"\");\n\n\t# Reverse all the previous transformations to get back the single `features` query value value\n\tset var.value = regsuball(var.value, \"1-\", \"\");\n\tset var.value = regsuball(var.value, \"&\", \",\");\n\tset var.value = regsuball(var.value, \"\\^\", \"&\");\n\n\tset req.http.Sorted-Value = var.value;\n}\n\nsub normalise_querystring_parameters_for_polyfill_bundle {\n\t# Store the url without the querystring into a temporary header.\n\tdeclare local var.url STRING;\n\tset var.url = querystring.remove(req.url);\n\n\tdeclare local var.querystring STRING;\n\tset var.querystring = \"?\";\n\n\t# Remove all querystring parameters which are not part of the public API.\n\t# set req.url = querystring.regfilter_except(req.url, \"^(features|excludes|rum|unknown|flags|version|ua|callback|compression)$\");\n\n\t# (?i) makes the regex case-insensitive\n\t# The regex will match only if their are characters after `features=` which are not an ampersand (&).\n\tif (req.url.qs ~ \"(?i)[^&=]*features=([^&]+)\") {\n\t\t# Parameter has already been set, use the already set value.\n\t\t# re.group.1 is the first regex capture group in the regex above.\n\t\tif (std.strlen(re.group.1) < 100) {\n\t\t\t# We add the value of the features parameter to this header\n\t\t\t# This is to be able to have sort_comma_separated_value sort the value\n\t\t\tset req.http.Sort-Value = urldecode(re.group.1);\n\t\t\tcall sort_comma_separated_value;\n\t\t\t# The header Sorted-Value now contains the sorted version of the features parameter.\n\t\t\tset var.querystring = querystring.set(var.querystring, \"features\", req.http.Sorted-Value);\n\t\t} else {\n\t\t\tset var.querystring = querystring.set(var.querystring, \"features\", urldecode(re.group.1));\n\t\t}\n\t} else {\n\t\t# Parameter has not been set, use the default value.\n\t\tset var.querystring = querystring.set(var.querystring, \"features\", \"default\");\n\t}\n\n\t# (?i) makes the regex case-insensitive\n\t# The regex will match only if their are characters after `excludes=` which are not an ampersand (&).\n\tif (req.url.qs ~ \"(?i)[^&=]*excludes=([^&]+)\") {\n\t\t# Parameter has already been set, use the already set value.\n\t\t# re.group.1 is the first regex capture group in the regex above.\n\t\tif (std.strlen(re.group.1) < 100) {\n\t\t\t# We add the value of the excludes parameter to this header\n\t\t\t# This is to be able to have sort_comma_separated_value sort the value\n\t\t\tset req.http.Sort-Value = urldecode(re.group.1);\n\t\t\tcall sort_comma_separated_value;\n\t\t\t# The header Sorted-Value now contains the sorted version of the excludes parameter.\n\t\t\tset var.querystring = querystring.set(var.querystring, \"excludes\", req.http.Sorted-Value);\n\t\t} else {\n\t\t\tset var.querystring = querystring.set(var.querystring, \"excludes\", urldecode(re.group.1));\n\t\t}\n\t} else {\n\t\t# If excludes is not set, set to default value \"\"\n\t\tset var.querystring = var.querystring \"&excludes=\";\n\t}\n\n\t# If rum is not set, set to default value \"0\"\n\tif (req.url.qs !~ \"(?i)[^&=]*rum=([^&]+)\") {\n\t\tset var.querystring = querystring.set(var.querystring, \"rum\", \"0\");\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"rum\", re.group.1);\n\t}\n\n\t# If unknown is not set, set to default value \"polyfill\"\n\tif (req.url.qs !~ \"(?i)[^&=]*unknown=([^&]+)\") {\n\t\tset var.querystring = querystring.set(var.querystring, \"unknown\", \"polyfill\");\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"unknown\", re.group.1);\n\t}\n\n\t# If flags is not set, set to default value \"\"\n\tif (req.url.qs !~ \"(?i)[^&=]*flags=([^&]+)\") {\n\t\tset var.querystring = var.querystring \"&flags=\";\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"flags\", urldecode(re.group.1));\n\t}\n\n\t# If version is not set, set to default value \"\"\n\tdeclare local var.version STRING;\n\tif (req.url.qs !~ \"(?i)[^&=]*version=([^&]+)\") {\n\t\tset var.querystring = var.querystring \"&version=\";\n\t} else {\n\t\tif (re.group.1 == \"3.89.4\" || re.group.1 == \"3.53.1\" || re.group.1 == \"3.52.3\" || re.group.1 == \"3.52.2\" || re.group.1 == \"3.52.1\" || re.group.1 == \"3.52.0\" || re.group.1 == \"3.51.0\" || re.group.1 == \"3.50.2\" || re.group.1 == \"3.49.0\" || re.group.1 == \"3.48.0\" || re.group.1 == \"3.46.0\" || re.group.1 == \"3.45.0\" || re.group.1 == \"3.44.0\" || re.group.1 == \"3.43.0\" || re.group.1 == \"3.42.0\" || re.group.1 == \"3.41.0\" || re.group.1 == \"3.40.0\" || re.group.1 == \"3.39.0\" || re.group.1 == \"3.38.0\" || re.group.1 == \"3.37.0\" || re.group.1 == \"3.36.0\" || re.group.1 == \"3.35.0\" || re.group.1 == \"3.34.0\" || re.group.1 == \"3.28.1\" || re.group.1 == \"3.27.4\" || re.group.1 == \"3.25.3\" || re.group.1 == \"3.25.2\" || re.group.1 == \"3.25.1\") {\n\t\t\tset var.querystring = querystring.set(var.querystring, \"version\", re.group.1);\n\t\t} else {\n\t\t\tset var.querystring = var.querystring \"&version=\";\n\t\t}\n\t}\n\n\t# If ua is not set, normalise the User-Agent header based upon the version of the polyfill-library that has been requested.\n\tif (req.url.qs !~ \"(?i)[^&=]*ua=([^&]+)\") {\n\t\tif (req.url.qs ~ \"(?i)[^&=]*version=3\\.25\\.1(&|$)\") {\n\t\t\tcall normalise_user_agent_3_25_1;\n\t\t} else {\n\t\t\tcall normalise_user_agent_1_9_0;\n\t\t}\n\t\tset var.querystring = querystring.set(var.querystring, \"ua\", req.http.Normalized-User-Agent);\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"ua\", urldecode(re.group.1));\n\t}\n\n\t# If callback is not set, set to default value \"\"\n\tif (req.url.qs !~ \"(?i)[^&=]*callback=([^&]+)\") {\n\t\tset var.querystring = var.querystring \"&callback=\";\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"callback\", re.group.1);\n\t}\n\n\t# If compression is not set, use the best compression that the user-agent supports.\n\tif (req.url.qs !~ \"(?i)[^&=]*compression=([^&]+)\") {\n\t\t# When Fastly adds Brotli into the Accept-Encoding normalisation we can replace this with:\n\t\t# `set var.querystring = querystring.set(var.querystring, \"compression\", req.http.Accept-Encoding || \"\")`\n\n\t\t# Before SP2, IE\/6 doesn't always read and cache gzipped content correctly.\n\t\tif (req.http.Fastly-Orig-Accept-Encoding && req.http.User-Agent !~ \"MSIE 6\") {\n\t\t\tif (req.http.Fastly-Orig-Accept-Encoding ~ \"br\") {\n\t\t\t\tset var.querystring = querystring.set(var.querystring, \"compression\", \"br\");\n\t\t\t} elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"gzip\") {\n\t\t\t\tset var.querystring = querystring.set(var.querystring, \"compression\", \"gzip\");\n\t\t\t} else {\n\t\t\t\tset var.querystring = var.querystring \"&compression=\";\n\t\t\t}\n\t\t} else {\n\t\t\tset var.querystring = var.querystring \"&compression=\";\n\t\t}\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"compression\", re.group.1);\n\t}\n\tset req.url = var.url var.querystring;\n}\n\ninclude \"top_pops.vcl\";\ninclude \"normalise-user-agent-3-25-1.vcl\";\ninclude \"normalise-user-agent.vcl\";\n\n# The Fastly VCL boilerplate.\ninclude \"fastly-boilerplate-begin.vcl\";\n\ninclude \"breadcrumbs.vcl\";\ninclude \"redirects.vcl\";\ninclude \"synthetic-responses.vcl\";\ninclude \"polyfill-service.vcl\";\n\n# Finally include the last bit of VCL, this _must_ be last!\ninclude \"fastly-boilerplate-end.vcl\";\n","old_contents":"import querystring;\n\nsub sort_comma_separated_value {\n\t# This function takes a CSV and tranforms it into a url where each\n\t# comma-separated-value is a query-string parameter and then uses\n\t# Fastly's querystring.sort function to sort the values. Once sorted\n\t# it then turn the query-parameters back into a CSV.\n\t# Set the CSV on the header `Sort-Value`.\n\t# Returns the sorted CSV on the header `Sorted-Value`.\n\tdeclare local var.value STRING;\n\tset var.value = req.http.Sort-value;\n\n\t# If query value does not exist or is empty, set it to \"\"\n\tset var.value = if(var.value != \"\", var.value, \"\");\n\n\t# Replace all `&` characters with `^`, this is because `&` would break the value up into pieces.\n\tset var.value = regsuball(var.value, \"&\", \"^\");\n\n\t# Replace all `,` characters with `&` to break them into individual query values\n\t# Append `1-` infront of all the query values to make them simpler to transform later\n\tset var.value = \"1-\" regsuball(var.value, \",\", \"&1-\");\n\n\t# Create a querystring-like string in order for querystring.sort to work.\n\tset var.value = querystring.sort(\"?\" var.value);\n\n\t# Grab all the query values from the sorted url\n\tset var.value = regsub(var.value, \"\\?\", \"\");\n\n\t# Reverse all the previous transformations to get back the single `features` query value value\n\tset var.value = regsuball(var.value, \"1-\", \"\");\n\tset var.value = regsuball(var.value, \"&\", \",\");\n\tset var.value = regsuball(var.value, \"\\^\", \"&\");\n\n\tset req.http.Sorted-Value = var.value;\n}\n\nsub normalise_querystring_parameters_for_polyfill_bundle {\n\t# Store the url without the querystring into a temporary header.\n\tdeclare local var.url STRING;\n\tset var.url = querystring.remove(req.url);\n\n\tdeclare local var.querystring STRING;\n\tset var.querystring = \"?\";\n\n\t# Remove all querystring parameters which are not part of the public API.\n\t# set req.url = querystring.regfilter_except(req.url, \"^(features|excludes|rum|unknown|flags|version|ua|callback|compression)$\");\n\n\t# (?i) makes the regex case-insensitive\n\t# The regex will match only if their are characters after `features=` which are not an ampersand (&).\n\tif (req.url.qs ~ \"(?i)[^&=]*features=([^&]+)\") {\n\t\t# Parameter has already been set, use the already set value.\n\t\t# re.group.1 is the first regex capture group in the regex above.\n\t\tif (std.strlen(re.group.1) < 100) {\n\t\t\t# We add the value of the features parameter to this header\n\t\t\t# This is to be able to have sort_comma_separated_value sort the value\n\t\t\tset req.http.Sort-Value = urldecode(re.group.1);\n\t\t\tcall sort_comma_separated_value;\n\t\t\t# The header Sorted-Value now contains the sorted version of the features parameter.\n\t\t\tset var.querystring = querystring.set(var.querystring, \"features\", req.http.Sorted-Value);\n\t\t} else {\n\t\t\tset var.querystring = querystring.set(var.querystring, \"features\", urldecode(re.group.1));\n\t\t}\n\t} else {\n\t\t# Parameter has not been set, use the default value.\n\t\tset var.querystring = querystring.set(var.querystring, \"features\", \"default\");\n\t}\n\n\t# (?i) makes the regex case-insensitive\n\t# The regex will match only if their are characters after `excludes=` which are not an ampersand (&).\n\tif (req.url.qs ~ \"(?i)[^&=]*excludes=([^&]+)\") {\n\t\t# Parameter has already been set, use the already set value.\n\t\t# re.group.1 is the first regex capture group in the regex above.\n\t\tif (std.strlen(re.group.1) < 100) {\n\t\t\t# We add the value of the excludes parameter to this header\n\t\t\t# This is to be able to have sort_comma_separated_value sort the value\n\t\t\tset req.http.Sort-Value = urldecode(re.group.1);\n\t\t\tcall sort_comma_separated_value;\n\t\t\t# The header Sorted-Value now contains the sorted version of the excludes parameter.\n\t\t\tset var.querystring = querystring.set(var.querystring, \"excludes\", req.http.Sorted-Value);\n\t\t} else {\n\t\t\tset var.querystring = querystring.set(var.querystring, \"excludes\", urldecode(re.group.1));\n\t\t}\n\t} else {\n\t\t# If excludes is not set, set to default value \"\"\n\t\tset var.querystring = var.querystring \"&excludes=\";\n\t}\n\n\t# If rum is not set, set to default value \"0\"\n\tif (req.url.qs !~ \"(?i)[^&=]*rum=([^&]+)\") {\n\t\tset var.querystring = querystring.set(var.querystring, \"rum\", \"0\");\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"rum\", re.group.1);\n\t}\n\n\t# If unknown is not set, set to default value \"polyfill\"\n\tif (req.url.qs !~ \"(?i)[^&=]*unknown=([^&]+)\") {\n\t\tset var.querystring = querystring.set(var.querystring, \"unknown\", \"polyfill\");\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"unknown\", re.group.1);\n\t}\n\n\t# If flags is not set, set to default value \"\"\n\tif (req.url.qs !~ \"(?i)[^&=]*flags=([^&]+)\") {\n\t\tset var.querystring = var.querystring \"&flags=\";\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"flags\", urldecode(re.group.1));\n\t}\n\n\t# If version is not set, set to default value \"\"\n\tdeclare local var.version STRING;\n\tif (req.url.qs !~ \"(?i)[^&=]*version=([^&]+)\") {\n\t\tset var.querystring = var.querystring \"&version=\";\n\t} else {\n\t\tif (re.group.1 == \"3.89.4\" || re.group.1 == \"3.53.1\" || re.group.1 == \"3.52.3\" || re.group.1 == \"3.52.2\" || re.group.1 == \"3.52.1\" || re.group.1 == \"3.52.0\" || re.group.1 == \"3.51.0\" || re.group.1 == \"3.50.2\" || re.group.1 == \"3.49.0\" || re.group.1 == \"3.48.0\" || re.group.1 == \"3.46.0\" || re.group.1 == \"3.45.0\" || re.group.1 == \"3.44.0\" || re.group.1 == \"3.43.0\" || re.group.1 == \"3.42.0\" || re.group.1 == \"3.41.0\" || re.group.1 == \"3.40.0\" || re.group.1 == \"3.39.0\" || re.group.1 == \"3.38.0\" || re.group.1 == \"3.37.0\" || re.group.1 == \"3.36.0\" || re.group.1 == \"3.35.0\" || re.group.1 == \"3.34.0\" || re.group.1 == \"3.28.1\" || re.group.1 == \"3.27.4\" || re.group.1 == \"3.25.3\" || re.group.1 == \"3.25.2\" || re.group.1 == \"3.25.1\") {\n\t\t\tset var.querystring = querystring.set(var.querystring, \"version\", re.group.1);\n\t\t} else {\n\t\t\tset var.querystring = var.querystring \"&version=\";\n\t\t}\n\t}\n\n\t# If ua is not set, normalise the User-Agent header based upon the version of the polyfill-library that has been requested.\n\tif (req.url.qs !~ \"(?i)[^&=]*ua=([^&]+)\") {\n\t\tif (req.url.qs ~ \"(?i)[^&=]*version=3\\.25\\.1(&|$)\") {\n\t\t\tcall normalise_user_agent_3_25_1;\n\t\t} else {\n\t\t\tcall normalise_user_agent_1_7_0;\n\t\t}\n\t\tset var.querystring = querystring.set(var.querystring, \"ua\", req.http.Normalized-User-Agent);\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"ua\", urldecode(re.group.1));\n\t}\n\n\t# If callback is not set, set to default value \"\"\n\tif (req.url.qs !~ \"(?i)[^&=]*callback=([^&]+)\") {\n\t\tset var.querystring = var.querystring \"&callback=\";\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"callback\", re.group.1);\n\t}\n\n\t# If compression is not set, use the best compression that the user-agent supports.\n\tif (req.url.qs !~ \"(?i)[^&=]*compression=([^&]+)\") {\n\t\t# When Fastly adds Brotli into the Accept-Encoding normalisation we can replace this with:\n\t\t# `set var.querystring = querystring.set(var.querystring, \"compression\", req.http.Accept-Encoding || \"\")`\n\n\t\t# Before SP2, IE\/6 doesn't always read and cache gzipped content correctly.\n\t\tif (req.http.Fastly-Orig-Accept-Encoding && req.http.User-Agent !~ \"MSIE 6\") {\n\t\t\tif (req.http.Fastly-Orig-Accept-Encoding ~ \"br\") {\n\t\t\t\tset var.querystring = querystring.set(var.querystring, \"compression\", \"br\");\n\t\t\t} elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"gzip\") {\n\t\t\t\tset var.querystring = querystring.set(var.querystring, \"compression\", \"gzip\");\n\t\t\t} else {\n\t\t\t\tset var.querystring = var.querystring \"&compression=\";\n\t\t\t}\n\t\t} else {\n\t\t\tset var.querystring = var.querystring \"&compression=\";\n\t\t}\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"compression\", re.group.1);\n\t}\n\tset req.url = var.url var.querystring;\n}\n\ninclude \"top_pops.vcl\";\ninclude \"normalise-user-agent-3-25-1.vcl\";\ninclude \"normalise-user-agent.vcl\";\n\n# The Fastly VCL boilerplate.\ninclude \"fastly-boilerplate-begin.vcl\";\n\ninclude \"breadcrumbs.vcl\";\ninclude \"redirects.vcl\";\ninclude \"synthetic-responses.vcl\";\ninclude \"polyfill-service.vcl\";\n\n# Finally include the last bit of VCL, this _must_ be last!\ninclude \"fastly-boilerplate-end.vcl\";\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"15581bbe3ba2de7d483b93c31c7a0c2ad4171571","subject":"Added\/fixed HTML commands","message":"Added\/fixed HTML commands\n","repos":"aschneiderman\/vim-voice","old_file":"gvim.vcl","new_file":"gvim.vcl","new_contents":"# Voice commands for gvim\r\n\r\ninclude folders.vch;\r\ninclude numbers.vch;\r\ninclude letters.vch;\r\ninclude pandas.vch;\r\n\r\nEdit [My] Configuration = ':e $' 'MYVIMRC' {Enter};\r\n\r\n<delimiters> := (Quotes = '\"' | 'Single Quotes' = \"'\" | 'Double Quotes' = '\"' | Parentheses = '(' \r\n\t\t| Brackets = '[' | 'Curly Braces' = '{' | Braces = '{'\r\n\t\t| HTML = '<' | 'Close HTML' = '>' | 'Close Tag' = '>'\t# NOTE: only works with commands I created\r\n\t\t| 'Equal Sign' = '='\r\n);\r\n\r\n# --- File Management ---------------\r\nOpen Document = {Alt+f} o;\r\nList Files = {Esc} ':bro ol' {Enter};\r\nFile <numbers> = $1 {Enter};\r\nLatest File = {Esc} ':bro ol' {Enter} 1{Enter};\r\n\r\nShow (Projects | Folders) = {Esc}':e C:\\Voice\\folders.vch' {Enter} Wait(100) {Down_9};\r\n[Open] Project <folder> = {Esc} ':e ' $1 {Enter} Wait(100) {Down_9};\r\n[Open] Current Project = {Esc} ':e .' {Enter} Wait(100) {Down_9};\r\nUp Directory = '-';\r\nSearch [Directory] <letters> = '\/^' $1;\r\n# :Sex = directory of current file \r\n# :Vex for vertical split\r\n# :sp. = Split horizontally on current directory (:vsp. For vertical)\r\n# % = new file\r\n\r\n(List Buffers = 'ls' | Buffer List = 'ls' | 'Next Buffer' = 'bn' | 'Last Buffer' = 'bp' | 'Close Buffer' = 'bd'\r\n\t| 'Next Window' = 'bn' | 'Last Window' = 'bp' | 'Close Window' = 'bd') \r\n\t= {Esc}':' $1 {Enter};\r\n\r\n\r\nSave Document = {Esc} Wait(100) ':w' {Enter};\r\nSave As = {Alt+f} a;\r\nGo (Quit = 'quit' | Close = 'close' | 'Close without saving' = 'close!' | Set = 'set') = ':' $1 {Enter};\r\n[Go] Quit without Saving = {Esc} Wait(100) ':quit!' {Enter};\r\n\r\nSave and Reload = {Esc} Wait(100) ':w' {Enter} Wait(100) SendSystemKeys({Alt+Tab}) Wait(100) {Alt+r};\r\n\r\n\r\n# --- Basic Navigation ---------------\r\n<numbers> (Up = 'k' | Down = 'j' | Right = 'l' | Left = 'h') = $1 $2;\r\nHoma = {Esc} 0;\r\nEnda = {Esc} '$';\r\n(Top | Go to Top) = {Esc} gg;\r\n(Bottom | Go to Bottom) = {Esc} G;\r\n(Move Forward | Move Right | Go Forward) <numbers> (words = 'w' | blocks = '}') = $2 $3;\r\n(Move Forward | Move Right | Go Forward) <numbers> (end | enda) words = $2 'e';\r\n(Move Back | Move Left | Go Back) <numbers> (words = 'b' | blocks = '{') = $2 $3;\r\nFine (Text | Alpha) <letters> = {Esc} f $2;\r\nFind Back <letters> = {Esc} F $1;\r\nFine Number 1..9 = {Esc} '\/' $1 {Enter};\r\nGo (Search | Find) = {Esc} '\/\\c'; # \\c = case insensitive\r\nFine <delimiters> = {Esc} '\/' $1 {Enter};\r\nInsert (Before = 'i' | After = 'a') <delimiters> = {Esc} '\/' $2 {Enter} Wait(100) $1;\r\nFine Tag = {Esc} '\/' '<' {Enter};\r\nInsert (Before = 'i' | After = 'a') tag = {Esc} '\/' '<' {Enter} Wait(100) $1;\r\n\r\n\r\n(Find Again | Next Fine | Next Find) = n;\r\nLine 1..100 = {Esc} ':' $1 {Enter};\r\n\r\n\r\n# --- Basic Editing ---------------\r\n(Do | Go) (Insert = 'i' | Append = 'A' | \rEscape = '{Esc}') = $2;\r\n(Insert = 'i' | \rEscape = '{Esc}') = $1;\r\nNexta = {Esc} A {Enter};\r\nEnda Insert = {Esc} A;\r\n\r\n(Do Again | Repeat That) = '.';\r\n(Undo | Undo That) = {Esc} u;\r\nRedo = {Esc} {Ctrl+r};\r\n\r\n(Kill = 'x') <numbers> = $2 $1;\r\n(Kill | Delete) Word = 'dw';\r\n(Kill | Delete) <numbers> Words = 'd' $2 'w';\r\nDee Dee = 'dd';\r\nCut to End of Line = 'd$';\r\nCut to End of Word = 'de';\r\n\r\n('Go Visual' | Mark | 'Visual Mode') = V;\r\n('Delete That' = 'd' | 'Yank That' = 'y' | 'Paste' = 'p' | 'Change That' = 'c' | 'Join That' = 'J') = $1;\r\nPaste That = {Esc} Wait(100) '\"+gP';\r\nCopy That = '\"*y';\r\nCopy Line = {Esc} V Wait(100) '\"*y';\r\nSelect Line = {Esc} V;\r\n\r\ndo test = {Esc} i Wait(100) \"strawberry\";\r\n\r\n(Delete= 'd' | Change = 'c') Between Tags = $1 i t;\r\n(Delete= 'd' | Change = 'c') (Next = '\/' | Last = '?') Tag = {Esc} $2 '>' {Enter} $1 i t;\r\n(Delete= 'd' | Change = 'c') between <delimiters> = $1 i $2;\r\n(Delete= 'd' | Change = 'c') (Next = '\/' | Last = '?') <delimiters> = {Esc} $2 $3 {Enter} $1 i $3;\r\n(Delete= 'd' | Change = 'c') (Next = '\/' | Last = '?') (Heading = '<h' | Header = '<h' | Paragraph = '<p') \r\n\t\t= {Esc} $2 '\\c' $3 {Enter} $1 i t;\r\n\r\n\r\n\r\n\r\nSelect All = {Alt+e} s {Enter};\r\nGrab Everything = {Alt+e} s {Enter} Wait(100) {Alt+e} c {Enter} Wait(100) {Alt+Tab};\r\n\r\n\r\n\r\n\r\n1..20 Spaces = Repeat($1, ' ');\r\n\r\n\r\n\r\n\r\nDelete Line = 'dd';\r\nDelete <numbers> Lines = $1 'dd';\r\n\r\n\r\n\r\n\r\n# --- HTML and Bootstrap commands (until I'm sure I can get Ultisnips to work) ------------\r\nNext One = {Esc} A;\r\nStart (Heading | Header) 1..5 = '<h' $2 '><\/h' $2 '>' Wait(100) {Left_5};\r\nWrap [In] (Heading | Header) 1..5 = {Esc} I '<h' $2 '>' {Esc} A '<\/h' $2 '>' {Esc};\r\nStart Para = {Esc} I '<p>';\r\nStop Para = {Esc} A '<\/p>' {Esc};\r\n\r\nPaste Image = {Esc} a ' <img align=right hspace=\"7\" src=\"' {Esc} p a '\" \/>';\t\t# Might also add: width=\"200\"\r\n\r\nStart Div (id | class) = '<div ' $1 '= \"\">' Wait(100) {Left_2};\r\nStop Div = '<\/div>' {Enter};\r\nStart Columns = {Esc} i Wait(100) '<div class=\"container\">{Enter}<div class=\"row\">{Enter}'\r\n\t\t {Enter} '<\/div>' {Enter} '<\/div>' {Esc} {Up_3} Wait(100) A;\r\nStart Column 1..12 = {Esc} a '<div class=\"col-md-' $1 '\">' {Enter} '<\/div>'{Enter} {Esc} {Up_2} Wait(100) A;\r\n\r\n\r\n\r\n\r\n\r\n# --- Ultisnips (if I can get it working on all PCs) ------------------------\r\nDo Ultisnips = {Esc} ':UltiSnipsEdit'{Enter};\r\n\r\n(Next = 'j' | Last = 'k') Tag = {Ctrl+$1};\r\nStart Snippet= {Esc} i 'snippet {Enter} {Enter}endsnippet' {Esc} {Up_2} A;\r\nStart (\r\n\tD3 = 'd3_template' | Code = 'D3_code_wrapper'\r\n| \tform | 'form text' | 'form button' | 'form select'\r\n) = {Esc} i $1 Wait(100) {Tab};\r\n\r\n\r\n\r\n\r\n# --- COMMANDS TO ADD ------------------------\r\n\r\n# Using bookmarks or whatever they are called e.g., if I accidentally do the wrong thing and end up on the wrong line,\r\n# g; - last place I was where I made a change\r\n# Ctrl-o - If I jump to a place, copy a line, I can snap back \r\n\r\n# copying sets of lines, moving sets of lines\r\n# :9yank - copy line 9\r\n# :9t16 - copy line 9 to line 16\r\n# :9. - copy line 9 to current position \r\n\r\n\r\n\r\n# For adding quotes, HTML tags, etc. to text that's already there:\r\n# http:\/\/stackoverflow.com\/questions\/10305952\/vim-enclose-word-in-tag\r\n\r\n# Commands I'm not sure about\r\n# H,M,L: top, middle, and bottom of screen\r\n\r\n","old_contents":"# Voice commands for gvim\r\n\r\ninclude folders.vch;\r\ninclude numbers.vch;\r\ninclude letters.vch;\r\ninclude pandas.vch;\r\n\r\nEdit [My] Configuration = ':e $' 'MYVIMRC' {Enter};\r\n\r\n<delimiters> := (Quotes = '\"' | 'Single Quotes' = \"'\" | 'Double Quotes' = '\"' | Parentheses = '(' \r\n\t\t| Brackets = '[' | 'Curly Braces' = '{' | Braces = '{'\r\n\t\t| HTML = '<' | Tags = '<' | 'Close HTML' = '>' | 'Close Tag' = '>'\t# NOTE: only works with commands I created\r\n\t\t| 'Equal Sign' = '='\r\n);\r\n\r\n# --- File Management ---------------\r\nOpen Document = {Alt+f} o;\r\nList Files = {Esc} ':bro ol' {Enter};\r\nFile <numbers> = $1 {Enter};\r\nLatest File = {Esc} ':bro ol' {Enter} 1{Enter};\r\n\r\nShow (Projects | Folders) = {Esc}':e C:\\Voice\\folders.vch' {Enter} Wait(100) {Down_9};\r\n[Open] Project <folder> = {Esc} ':e ' $1 {Enter} Wait(100) {Down_9};\r\n[Open] Current Project = {Esc} ':e .' {Enter} Wait(100) {Down_9};\r\nUp Directory = '-';\r\nSearch [Directory] <letters> = '\/^' $1;\r\n# :Sex = directory of current file \r\n# :Vex for vertical split\r\n# :sp. = Split horizontally on current directory (:vsp. For vertical)\r\n# % = new file\r\n\r\n(List Buffers = 'ls' | Buffer List = 'ls' | 'Next Buffer' = 'bn' | 'Last Buffer' = 'bp' | 'Close Buffer' = 'bd'\r\n\t| 'Next Window' = 'bn' | 'Last Window' = 'bp' | 'Close Window' = 'bd') \r\n\t= {Esc}':' $1 {Enter};\r\n\r\n\r\nSave Document = {Esc} Wait(100) ':w' {Enter};\r\nSave As = {Alt+f} a;\r\nGo (Quit = 'quit' | Close = 'close' | 'Close without saving' = 'close!' | Set = 'set') = ':' $1 {Enter};\r\n[Go] Quit without Saving = {Esc} Wait(100) ':quit!' {Enter};\r\n\r\nSave and Reload = {Esc} Wait(100) ':w' {Enter} Wait(100) SendSystemKeys({Alt+Tab}) Wait(100) {Alt+r};\r\n\r\n\r\n# --- Basic Navigation ---------------\r\n<numbers> (Up = 'k' | Down = 'j' | Right = 'l' | Left = 'h') = $1 $2;\r\nHoma = {Esc} 0;\r\nEnda = {Esc} '$';\r\n(Top | Go to Top) = {Esc} gg;\r\n(Bottom | Go to Bottom) = {Esc} G;\r\n(Move Forward | Move Right | Go Forward) <numbers> (words = 'w' | blocks = '}') = $2 $3;\r\n(Move Forward | Move Right | Go Forward) <numbers> (end | enda) words = $2 'e';\r\n(Move Back | Move Left | Go Back) <numbers> (words = 'b' | blocks = '{') = $2 $3;\r\nFine (Text | Alpha) <letters> = {Esc} f $2;\r\nFind Back <letters> = {Esc} F $1;\r\nFine Number 1..9 = {Esc} '\/' $1 {Enter};\r\nGo (Search | Find) = {Esc} '\/\\c'; # \\c = case insensitive\r\nFine <delimiters> = {Esc} '\/' $1 {Enter};\r\nInsert (Before = 'i' | After = 'a') <delimiters> = {Esc} '\/' $2 {Enter} Wait(100) $1;\r\n\r\n(Find Again | Next Fine | Next Find) = n;\r\nLine 1..100 = {Esc} ':' $1 {Enter};\r\n\r\n\r\n# --- Basic Editing ---------------\r\n(Do | Go) (Insert = 'i' | Append = 'A' | \rEscape = '{Esc}') = $2;\r\n(Insert = 'i' | \rEscape = '{Esc}') = $1;\r\nNexta = {Esc} A {Enter};\r\nEnda Insert = {Esc} A;\r\n\r\n(Do Again | Repeat That) = '.';\r\n(Undo | Undo That) = {Esc} u;\r\nRedo = {Esc} {Ctrl+r};\r\n\r\n(Kill = 'x') <numbers> = $2 $1;\r\n(Kill | Delete) Word = 'dw';\r\n(Kill | Delete) <numbers> Words = 'd' $2 'w';\r\nDee Dee = 'dd';\r\nCut to End of Line = 'd$';\r\nCut to End of Word = 'de';\r\n\r\n('Go Visual' | Mark | 'Visual Mode') = V;\r\n('Delete That' = 'd' | 'Yank That' = 'y' | 'Paste' = 'p' | 'Change That' = 'c' | 'Join That' = 'J') = $1;\r\nPaste That = {Esc} Wait(100) '\"+gP';\r\nCopy That = '\"*y';\r\nCopy Line = {Esc} V Wait(100) '\"*y';\r\nSelect Line = {Esc} V;\r\n\r\ndo test = {Esc} i Wait(100) \"strawberry\";\r\n\r\n\r\n(Delete= 'd' | Change = 'c') between <delimiters> = $1 i $2;\r\n(Delete= 'd' | Change = 'c') (Next = '\/' | Last = '?') <delimiters> = {Esc} $2 $3 {Enter} $1 i $3;\r\n(Delete= 'd' | Change = 'c') (Next = '\/' | Last = '?') \r\n\t(Heading = '<h' | Header = '<h' | Paragraph = '<p') \r\n\t= {Esc} $2 '\\c' $3 {Enter} $1 i t;\r\n\r\n\r\n\r\n\r\nSelect All = {Alt+e} s {Enter};\r\nGrab Everything = {Alt+e} s {Enter} Wait(100) {Alt+e} c {Enter} Wait(100) {Alt+Tab};\r\n\r\n\r\n\r\n\r\n1..20 Spaces = Repeat($1, ' ');\r\n\r\n\r\nDo Ultisnips = {Esc} ':UltiSnipsEdit'{Enter};\r\n\r\n\r\n(Next = 'j' | Last = 'k') Tag = {Ctrl+$1};\r\nStart Snippet= {Esc} i 'snippet {Enter} {Enter}endsnippet' {Esc} {Up_2} A;\r\nStart (\r\n\tD3 = 'd3_template' | Code = 'D3_code_wrapper'\r\n| \tform | 'form text' | 'form button' | 'form select'\r\n) = {Esc} i $1 Wait(100) {Tab};\r\n\r\n\r\n\r\nDelete Line = 'dd';\r\nDelete <numbers> Lines = $1 'dd';\r\n\r\n\r\n\r\n\r\n# --- HTML and Bootstrap commands (until I'm sure I can get Ultisnips to work) ------------\r\nNext One = {Esc} A;\r\nStart (Heading | Header) 1..4 = '<h' $2 '><\/h' $2 '>' Wait(100) {Left_5};\r\nStart Div (id | class) = '<div ' $1 '= \"\">' Wait(100) {Left_2};\r\nStop Div = '<\/div>' {Enter};\r\nStart Columns = {Esc} i Wait(100) '<div class=\"container\">{Enter}<div class=\"row\">{Enter}'\r\n\t\t {Enter} '<\/div>' {Enter} '<\/div>' {Esc} {Up_3} Wait(100) A;\r\nStart Column 1..12 = {Esc} a '<div class=\"col-md-' $1 '\">' {Enter} '<\/div>'{Enter} {Esc} {Up_2} Wait(100) A;\r\n\r\n# Paste Image = {Esc} a' <img align=right hspace=\"7\" width=\"200\" src=\"' {Ctrl+v} '\" \/>';\r\nPaste Image = {Esc} a ' <img align=right hspace=\"7\" src=\"' {Esc} p a '\" \/>';\r\n\r\n\r\n\r\n\r\n\r\n# --- COMMANDS TO ADD ------------------------\r\n\r\n# Using bookmarks or whatever they are called e.g., if I accidentally do the wrong thing and end up on the wrong line,\r\n# g; - last place I was where I made a change\r\n# Ctrl-o - If I jump to a place, copy a line, I can snap back \r\n\r\n# copying sets of lines, moving sets of lines\r\n# :9yank - copy line 9\r\n# :9t16 - copy line 9 to line 16\r\n# :9. - copy line 9 to current position \r\n\r\n\r\n\r\n# For adding quotes, HTML tags, etc. to text that's already there:\r\n# http:\/\/stackoverflow.com\/questions\/10305952\/vim-enclose-word-in-tag\r\n\r\n# Commands I'm not sure about\r\n# H,M,L: top, middle, and bottom of screen","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"9c2f3585144aa0f81d41ee637f028f56457f200b","subject":"Simplified cookie logic in receive\/wordpress.vcl","message":"Simplified cookie logic in receive\/wordpress.vcl\n\n* The existing wp cookie check was *starting with* `wp-` or `wprdpress_`, but would not match a 2nd or higher position wp cookie\n* The second url check for `wp-(login|admin)` was no longer necessary, so removing all cookies past that point is more efficient\n","repos":"evolution\/genesis-wordpress,genesis\/wordpress,evolution\/wordpress,evolution\/wordpress,evolution\/genesis-wordpress,jalevin\/wordpress,genesis\/wordpress,evolution\/genesis-wordpress,evolution\/genesis-wordpress,evolution\/wordpress,evolution\/wordpress,evolution\/genesis-wordpress,genesis\/wordpress,jalevin\/wordpress,evolution\/genesis-wordpress,jalevin\/wordpress,genesis\/wordpress,genesis\/wordpress,jalevin\/wordpress,genesis\/wordpress,evolution\/wordpress,jalevin\/wordpress","old_file":"provisioning\/roles\/varnish\/files\/etc-varnish\/conf.d\/receive\/wordpress.vcl","new_file":"provisioning\/roles\/varnish\/files\/etc-varnish\/conf.d\/receive\/wordpress.vcl","new_contents":"# Pass all local or login\/admin requests straight through\nif (req.http.Host ~ \"^local\\.\" || (req.url ~ \"wp-(login|admin)\")) {\n return (pass);\n}\n\n# Pass all requests containing a wp- or wordpress_ cookie\n# (meaning NO caching for logged in users)\nif (req.http.Cookie ~ \"^([^;]+;\\s*)*?(wp-|wordpress_)\") {\n return (pass);\n}\n\n# Drop *all* cookies sent to Wordpress, if we've gotten this far\nunset req.http.Cookie;\n\n# Try a cache-lookup\nreturn (lookup);\n","old_contents":"# Pass all local or login\/admin requests straight through\nif (req.http.Host ~ \"^local\\.\" || (req.url ~ \"wp-(login|admin)\")) {\n return (pass);\n}\n\nif (req.http.Cookie ~ \"^wp-\" || req.http.Cookie ~ \"^wordpress_\") {\n return (pass);\n}\n\n# Drop any cookies sent to Wordpress.\nif (!(req.url ~ \"wp-(login|admin)\")) {\n unset req.http.Cookie;\n}\n\n# Anything else left?\nif (!req.http.Cookie) {\n unset req.http.Cookie;\n}\n\n# Try a cache-lookup\nreturn (lookup);\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"5d1365ae9f1a81bdaea87d3980f8fd45ac5abcfb","subject":"refactor drupal varnish to support PURGE for Drupal 7","message":"refactor drupal varnish to support PURGE for Drupal 7\n","repos":"amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon","old_file":"images\/varnish-drupal\/drupal.vcl","new_file":"images\/varnish-drupal\/drupal.vcl","new_contents":"vcl 4.0;\n\nimport std;\n\n# set backend default\nbackend default {\n .host = \"${VARNISH_BACKEND_HOST:-nginx}\";\n .port = \"${VARNISH_BACKEND_PORT:-8080}\";\n .first_byte_timeout = 35m;\n .between_bytes_timeout = 10m;\n}\n\n# Allow purging from localhost\n# @TODO allow from openshift network\nacl purge {\n \"127.0.0.1\";\n \"10.0.0.0\"\/8;\n \"172.16.0.0\"\/12;\n \"192.168.0.0\"\/16;\n}\n\n# This configuration is optimized for Drupal hosting:\n# Respond to incoming requests.\nsub vcl_recv {\n if (req.url ~ \"^\/varnish_status$\") {\n return (synth(200,\"OK\"));\n }\n # set the backend, which should be used:\n set req.backend_hint = default;\n\n # Always set the forward ip.\n if (req.restarts == 0) {\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n\n\n if (req.http.X-LAGOON-VARNISH ) {\n ## Pass all Requests which are handled via an upstream Varnish\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, \" + req.http.X-LAGOON-VARNISH;\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n } else if (req.http.Fastly-FF) {\n ## Pass all Requests which are handled via Fastly\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, fastly\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n set req.http.X-Forwarded-For = req.http.Fastly-Client-IP;\n } else if (req.http.CF-RAY) {\n ## Pass all Requests which are handled via CloudFlare\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, cloudflare\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n set req.http.X-Forwarded-For = req.http.CF-Connecting-IP;\n } else if (req.http.X-Pull) {\n ## Pass all Requests which are handled via KeyCDN\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, keycdn\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n } else {\n ## We set a header to let a Varnish Chain know that it already has been varnishcached\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}\";\n\n ## Allow to bypass based on env variable `VARNISH_BYPASS`\n set req.http.X-LAGOON-VARNISH-BYPASS = \"${VARNISH_BYPASS:-false}\";\n }\n\n # Websockets are piped\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n if (req.http.X-LAGOON-VARNISH-BYPASS == \"true\" || req.http.X-LAGOON-VARNISH-BYPASS == \"TRUE\") {\n return (pass);\n }\n\n # SA-CORE-2014-004 preventing access to \/xmlrpc.php\n if (req.url ~ \"^\/xmlrpc.php$\") {\n return (synth(701, \"Unauthorized\"));\n }\n\n # Strip out Google Analytics campaign variables. They are only needed\n # by the javascript running on the page\n # utm_source, utm_medium, utm_campaign, gclid\n if(req.url ~ \"(\\?|&)(gclid|utm_[a-z]+)=\") {\n set req.url = regsuball(req.url, \"(gclid|utm_[a-z]+)=[^\\&]+&?\", \"\");\n set req.url = regsub(req.url, \"(\\?|&)$\", \"\");\n }\n\n # Bypass a cache hit (the request is still sent to the backend)\n if (req.method == \"REFRESH\") {\n if (!client.ip ~ purge) { return (synth(405, \"Not allowed\")); }\n set req.method = \"GET\";\n set req.hash_always_miss = true;\n }\n\n # Only allow BAN requests from IP addresses in the 'purge' ACL.\n if (req.method == \"BAN\" || req.method == \"URIBAN\" || req.method == \"PURGE\") {\n # Only allow BAN from defined ACL\n if (!client.ip ~ purge) {\n return (synth(403, \"Your IP is not allowed.\"));\n }\n\n # Only allows BAN if the Host Header has the style of with \"${SERVICE_NAME:-varnish}:8080\" or \"${SERVICE_NAME:-varnish}\".\n # Such a request is only possible from within the Docker network, as a request from external goes trough the Kubernetes Router and for that needs a proper Host Header\n if (!req.http.host ~ \"^${SERVICE_NAME:-varnish}(:\\d+)?$\") {\n return (synth(403, \"BAN only allowed from within own network.\"));\n }\n\n if (req.method == \"BAN\") {\n # Logic for the ban, using the Cache-Tags header.\n if (req.http.Cache-Tags) {\n ban(\"obj.http.Cache-Tags ~ \" + req.http.Cache-Tags);\n # Throw a synthetic page so the request won't go to the backend.\n return (synth(200, \"Ban added.\"));\n }\n else {\n return (synth(403, \"Cache-Tags header missing.\"));\n }\n }\n\n if (req.method == \"URIBAN\" || req.method == \"PURGE\") {\n ban(\"req.url == \" + req.url);\n # Throw a synthetic page so the request won't go to the backend.\n return (synth(200, \"Ban added.\"));\n }\n\n }\n\n # Non-RFC2616 or CONNECT which is weird, we pipe that\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n return (pipe);\n }\n\n # We only try to cache GET and HEAD, other things are passed\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n # Any requests with Basic Auth are passed\n if (req.http.Authorization || req.http.Authenticate)\n {\n return (pass);\n }\n\n ## Pass requests which are from blackfire\n if (req.http.X-Blackfire-Query) {\n return (pass);\n }\n\n # Some URLs should never be cached\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/admin([\/?]|$).*$\" ||\n req.url ~ \"^\/info([\/?]|$).*$\" ||\n req.url ~ \"^\/flag([\/?]|$).*$\" ||\n req.url ~ \"^.*\/system\/files([\/?]|$).*$\" ||\n req.url ~ \"^\/cgi\" ||\n req.url ~ \"^\/cgi-bin\"\n ) {\n return (pass);\n }\n\n # Plupload likes to get piped\n if (req.url ~ \"^.*\/plupload-handle-uploads.*$\"\n ) {\n return (pipe);\n }\n\n # Handle compression correctly. Different browsers send different\n # \"Accept-Encoding\" headers, even though they mostly all support the same\n # compression mechanisms. By consolidating these compression headers into\n # a consistent format, we can reduce the size of the cache and get more hits.=\n # @see: http:\/\/ varnish.projects.linpro.no\/wiki\/FAQ\/Compression\n if (req.http.Accept-Encoding) {\n if (req.http.Accept-Encoding ~ \"gzip\") {\n # If the browser supports it, we'll use gzip.\n set req.http.Accept-Encoding = \"gzip\";\n }\n else if (req.http.Accept-Encoding ~ \"deflate\") {\n # Next, try deflate if it is supported.\n set req.http.Accept-Encoding = \"deflate\";\n }\n else {\n # Unknown algorithm. Remove it and send unencoded.\n unset req.http.Accept-Encoding;\n }\n }\n\n # Always cache the following file types for all users.\n if (req.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n unset req.http.Cookie;\n }\n\n # Remove all cookies that Drupal doesn't need to know about. ANY remaining\n # cookie will cause the request to pass-through to a backend. For the most part\n # we always set the NO_CACHE cookie after any POST request, disabling the\n # Varnish cache temporarily. The session cookie allows all authenticated users\n # to pass through as long as they're logged in.\n #\n # 1. Append a semi-colon to the front of the cookie string.\n # 2. Remove all spaces that appear after semi-colons.\n # 3. Match the cookies we want to keep, adding the space we removed\n # previously, back. (\\1) is first matching group in the regsuball.\n # 4. Remove all other cookies, identifying them by the fact that they have\n # no space after the preceding semi-colon.\n # 5. Remove all spaces and semi-colons from the beginning and end of the\n # cookie string.\n if (req.http.Cookie) {\n set req.http.CookieCheck = \";\" + req.http.Cookie;\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"; +\", \";\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";(${VARNISH_COOKIECHECK:-SESS[a-z0-9]+|SSESS[a-z0-9]+|NO_CACHE})=\", \"; \\1=\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";[^ ][^;]*\", \"\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"^[; ]+|[; ]+$\", \"\");\n\n set req.http.Cookie = req.http.Cookie + \";\";\n\n if (req.http.CookieCheck == \"\") {\n # If there are no remaining cookies, remove the cookie header. If there\n # aren't any cookie headers, Varnish's default behavior will be to cache\n # the page.\n\n unset req.http.CookieCheck;\n unset req.http.Cookie;\n }\n else {\n # If there is any cookies left (a session or NO_CACHE cookie), do not\n # cache the page. Pass it on to Apache directly.\n unset req.http.CookieCheck;\n return (pass);\n }\n }\n\n # Cacheable, lookup in cache.\n return (hash);\n}\n\nsub vcl_pipe {\n # Support for Websockets\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n set bereq.http.connection = req.http.connection;\n }\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n # normal hit\n return (deliver);\n }\n # We have no fresh fish. Lets look at the stale ones.\n if (std.healthy(req.backend_hint)) {\n # Backend is healthy. If the object is not older then 30secs, deliver it to the client\n # and automatically create a separate backend request to warm the cache for this request.\n if (obj.ttl + 30s > 0s) {\n set req.http.grace = \"normal(limited)\";\n return (deliver);\n } else {\n # No candidate for grace. Fetch a fresh object.\n return(miss);\n }\n } else {\n # backend is sick - use full grace\n if (obj.ttl + obj.grace > 0s) {\n set req.http.grace = \"full\";\n return (deliver);\n } else {\n # no graced object.\n return (miss);\n }\n }\n}\n\nsub vcl_backend_response {\n # Allow items to be stale if needed.\n set beresp.grace = 6h;\n\n # Set ban-lurker friendly custom headers.\n set beresp.http.X-Url = bereq.url;\n set beresp.http.X-Host = bereq.http.host;\n\n # If the backend sends a X-LAGOON-VARNISH-BACKEND-BYPASS header we directly deliver\n if(beresp.http.X-LAGOON-VARNISH-BACKEND-BYPASS == \"TRUE\") {\n return (deliver);\n }\n\n # Cache 404 and 403 for 10 seconds\n if(beresp.status == 404 || beresp.status == 403) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n # Don't allow static files to set cookies.\n if (bereq.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n # beresp == Back-end response from the web server.\n unset beresp.http.set-cookie;\n unset beresp.http.Cache-Control;\n\n # If an asset would come back with statuscode 500 we only cache it for 10 seconds instead of the usual static file cache\n if (beresp.status == 500) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n set beresp.ttl = ${VARNISH_ASSETS_TTL:-2628001}s;\n set beresp.http.Cache-Control = \"public, max-age=${VARNISH_ASSETS_TTL:-2628001}\";\n set beresp.http.Expires = \"\" + (now + beresp.ttl);\n }\n\n return (deliver);\n}\n\n# Set a header to track a cache HIT\/MISS.\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Varnish-Cache = \"HIT\";\n }\n else {\n set resp.http.X-Varnish-Cache = \"MISS\";\n }\n\n # Remove ban-lurker friendly custom headers when delivering to client.\n unset resp.http.X-Url;\n unset resp.http.X-Host;\n\n # unset Cache-Tags Header by default, can be disabled with VARNISH_UNSET_HEADER_CACHE_TAGS=true\n if (!${VARNISH_UNSET_HEADER_CACHE_TAGS:-false}) {\n unset resp.http.Cache-Tags;\n }\n\n unset resp.http.X-Generator;\n unset resp.http.Server;\n # Inject information about grace\n if (req.http.grace) {\n set resp.http.X-Varnish-Grace = req.http.grace;\n }\n set resp.http.X-LAGOON = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}>\" + resp.http.X-LAGOON;\n return (deliver);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n if (req.http.X-Forwarded-Proto) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n if (req.http.HTTPS) {\n hash_data(req.http.HTTPS);\n }\n return (lookup);\n}\n\nsub vcl_synth {\n if (resp.status == 701) {\n set resp.status = 401;\n set resp.http.Content-Type = \"text\/plain; charset=utf-8\";\n synthetic({\"XMLRPC Interface is blocked due to SA-CORE-2014-004 - mail support@amazee.io if you need it.\"});\n return (deliver);\n }\n if (resp.status == 700) {\n # Set a status the client will understand\n set resp.status = 200;\n # Create our synthetic response\n synthetic(\"\");\n return(deliver);\n}\n return (deliver);\n}\n\nsub vcl_backend_error {\n # Restart the request, when we have a backend server error, to try another backend.\n # Restart max twice.\n if (bereq.retries < 2) {\n return(retry);\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<head>\n <title>Server Error<\/title>\n <style type=\"text\/css\">\n body {\n font-family: helvetica, arial, sans-serif;\n }\n img {\n margin-top: 50px;\n }\n p {\n width: 6 00px;\n margin-top: 10px\n }\n div {\n background: #ccc;\n width: 600px;\n margin: auto;\n padding: 50px;\n }\n span {\n color: #ccc\n }\n <\/style>\n<\/head>\n<body>\n <div>\n <h1>We are sorry...<\/h1>\n <p>We encountered a server-side error. This means that the problem is not with your computer or Internet connection, but rather with the website's server.<\/p>\n <p>We are currently working on solving this problem and apologise for the inconvenience.<\/p>\n <span>\n <strong>Technical Information<\/strong><br \/>\n Error \"} + beresp.status + \" \" + beresp.reason + {\"<br \/>\n XID: \"} + bereq.xid + {\"<br \/>\n <\/span>\n <\/div>\n<\/body>\n<\/html>\n\n\"} );\n return (deliver);\n}\n","old_contents":"vcl 4.0;\n\nimport std;\n\n# set backend default\nbackend default {\n .host = \"${VARNISH_BACKEND_HOST:-nginx}\";\n .port = \"${VARNISH_BACKEND_PORT:-8080}\";\n .first_byte_timeout = 35m;\n .between_bytes_timeout = 10m;\n}\n\n# Allow purging from localhost\n# @TODO allow from openshift network\nacl purge {\n \"127.0.0.1\";\n \"10.0.0.0\"\/8;\n \"172.16.0.0\"\/12;\n \"192.168.0.0\"\/16;\n}\n\n# This configuration is optimized for Drupal hosting:\n# Respond to incoming requests.\nsub vcl_recv {\n if (req.url ~ \"^\/varnish_status$\") {\n return (synth(200,\"OK\"));\n }\n # set the backend, which should be used:\n set req.backend_hint = default;\n\n # Always set the forward ip.\n if (req.restarts == 0) {\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n\n\n if (req.http.X-LAGOON-VARNISH ) {\n ## Pass all Requests which are handled via an upstream Varnish\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, \" + req.http.X-LAGOON-VARNISH;\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n } else if (req.http.Fastly-FF) {\n ## Pass all Requests which are handled via Fastly\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, fastly\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n set req.http.X-Forwarded-For = req.http.Fastly-Client-IP;\n } else if (req.http.CF-RAY) {\n ## Pass all Requests which are handled via CloudFlare\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, cloudflare\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n set req.http.X-Forwarded-For = req.http.CF-Connecting-IP;\n } else if (req.http.X-Pull) {\n ## Pass all Requests which are handled via KeyCDN\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, keycdn\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n } else {\n ## We set a header to let a Varnish Chain know that it already has been varnishcached\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}\";\n\n ## Allow to bypass based on env variable `VARNISH_BYPASS`\n set req.http.X-LAGOON-VARNISH-BYPASS = \"${VARNISH_BYPASS:-false}\";\n }\n\n # Websockets are piped\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n if (req.http.X-LAGOON-VARNISH-BYPASS == \"true\" || req.http.X-LAGOON-VARNISH-BYPASS == \"TRUE\") {\n return (pass);\n }\n\n # SA-CORE-2014-004 preventing access to \/xmlrpc.php\n if (req.url ~ \"^\/xmlrpc.php$\") {\n return (synth(701, \"Unauthorized\"));\n }\n\n # Strip out Google Analytics campaign variables. They are only needed\n # by the javascript running on the page\n # utm_source, utm_medium, utm_campaign, gclid\n if(req.url ~ \"(\\?|&)(gclid|utm_[a-z]+)=\") {\n set req.url = regsuball(req.url, \"(gclid|utm_[a-z]+)=[^\\&]+&?\", \"\");\n set req.url = regsub(req.url, \"(\\?|&)$\", \"\");\n }\n\n # Bypass a cache hit (the request is still sent to the backend)\n if (req.method == \"REFRESH\") {\n if (!client.ip ~ purge) { return (synth(405, \"Not allowed\")); }\n set req.method = \"GET\";\n set req.hash_always_miss = true;\n }\n\n # Only allow BAN requests from IP addresses in the 'purge' ACL.\n if (req.method == \"BAN\") {\n # Only allow BAN from defined ACL\n if (!client.ip ~ purge) {\n return (synth(403, \"Your IP is not allowed.\"));\n }\n\n # Only allows BAN if the Host Header has the style of with \"${SERVICE_NAME:-varnish}:8080\" or \"${SERVICE_NAME:-varnish}\".\n # Such a request is only possible from within the Docker network, as a request from external goes trough the Kubernetes Router and for that needs a proper Host Header\n if (!req.http.host ~ \"^${SERVICE_NAME:-varnish}(:\\d+)?$\") {\n return (synth(403, \"BAN only allowed from within own network.\"));\n }\n\n # Logic for the ban, using the Cache-Tags header.\n if (req.http.Cache-Tags) {\n ban(\"obj.http.Cache-Tags ~ \" + req.http.Cache-Tags);\n }\n else {\n return (synth(403, \"Cache-Tags header missing.\"));\n }\n\n # Throw a synthetic page so the request won't go to the backend.\n return (synth(200, \"Ban added.\"));\n }\n\n if (req.method == \"URIBAN\") {\n ban(\"req.http.host == \" + req.http.host + \" && req.url == \" + req.url);\n # Throw a synthetic page so the request won't go to the backend.\n return (synth(200, \"Ban added.\"));\n }\n\n # Non-RFC2616 or CONNECT which is weird, we pipe that\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n return (pipe);\n }\n\n # We only try to cache GET and HEAD, other things are passed\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n # Any requests with Basic Auth are passed\n if (req.http.Authorization || req.http.Authenticate)\n {\n return (pass);\n }\n\n ## Pass requests which are from blackfire\n if (req.http.X-Blackfire-Query) {\n return (pass);\n }\n\n # Some URLs should never be cached\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/admin([\/?]|$).*$\" ||\n req.url ~ \"^\/info([\/?]|$).*$\" ||\n req.url ~ \"^\/flag([\/?]|$).*$\" ||\n req.url ~ \"^.*\/system\/files([\/?]|$).*$\" ||\n req.url ~ \"^\/cgi\" ||\n req.url ~ \"^\/cgi-bin\"\n ) {\n return (pass);\n }\n\n # Plupload likes to get piped\n if (req.url ~ \"^.*\/plupload-handle-uploads.*$\"\n ) {\n return (pipe);\n }\n\n # Handle compression correctly. Different browsers send different\n # \"Accept-Encoding\" headers, even though they mostly all support the same\n # compression mechanisms. By consolidating these compression headers into\n # a consistent format, we can reduce the size of the cache and get more hits.=\n # @see: http:\/\/ varnish.projects.linpro.no\/wiki\/FAQ\/Compression\n if (req.http.Accept-Encoding) {\n if (req.http.Accept-Encoding ~ \"gzip\") {\n # If the browser supports it, we'll use gzip.\n set req.http.Accept-Encoding = \"gzip\";\n }\n else if (req.http.Accept-Encoding ~ \"deflate\") {\n # Next, try deflate if it is supported.\n set req.http.Accept-Encoding = \"deflate\";\n }\n else {\n # Unknown algorithm. Remove it and send unencoded.\n unset req.http.Accept-Encoding;\n }\n }\n\n # Always cache the following file types for all users.\n if (req.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n unset req.http.Cookie;\n }\n\n # Remove all cookies that Drupal doesn't need to know about. ANY remaining\n # cookie will cause the request to pass-through to a backend. For the most part\n # we always set the NO_CACHE cookie after any POST request, disabling the\n # Varnish cache temporarily. The session cookie allows all authenticated users\n # to pass through as long as they're logged in.\n #\n # 1. Append a semi-colon to the front of the cookie string.\n # 2. Remove all spaces that appear after semi-colons.\n # 3. Match the cookies we want to keep, adding the space we removed\n # previously, back. (\\1) is first matching group in the regsuball.\n # 4. Remove all other cookies, identifying them by the fact that they have\n # no space after the preceding semi-colon.\n # 5. Remove all spaces and semi-colons from the beginning and end of the\n # cookie string.\n if (req.http.Cookie) {\n set req.http.CookieCheck = \";\" + req.http.Cookie;\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"; +\", \";\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";(${VARNISH_COOKIECHECK:-SESS[a-z0-9]+|SSESS[a-z0-9]+|NO_CACHE})=\", \"; \\1=\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";[^ ][^;]*\", \"\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"^[; ]+|[; ]+$\", \"\");\n\n set req.http.Cookie = req.http.Cookie + \";\";\n\n if (req.http.CookieCheck == \"\") {\n # If there are no remaining cookies, remove the cookie header. If there\n # aren't any cookie headers, Varnish's default behavior will be to cache\n # the page.\n\n unset req.http.CookieCheck;\n unset req.http.Cookie;\n }\n else {\n # If there is any cookies left (a session or NO_CACHE cookie), do not\n # cache the page. Pass it on to Apache directly.\n unset req.http.CookieCheck;\n return (pass);\n }\n }\n\n # Cacheable, lookup in cache.\n return (hash);\n}\n\nsub vcl_pipe {\n # Support for Websockets\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n set bereq.http.connection = req.http.connection;\n }\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n # normal hit\n return (deliver);\n }\n # We have no fresh fish. Lets look at the stale ones.\n if (std.healthy(req.backend_hint)) {\n # Backend is healthy. If the object is not older then 30secs, deliver it to the client\n # and automatically create a separate backend request to warm the cache for this request.\n if (obj.ttl + 30s > 0s) {\n set req.http.grace = \"normal(limited)\";\n return (deliver);\n } else {\n # No candidate for grace. Fetch a fresh object.\n return(miss);\n }\n } else {\n # backend is sick - use full grace\n if (obj.ttl + obj.grace > 0s) {\n set req.http.grace = \"full\";\n return (deliver);\n } else {\n # no graced object.\n return (miss);\n }\n }\n}\n\nsub vcl_backend_response {\n # Allow items to be stale if needed.\n set beresp.grace = 6h;\n\n # Set ban-lurker friendly custom headers.\n set beresp.http.X-Url = bereq.url;\n set beresp.http.X-Host = bereq.http.host;\n\n # If the backend sends a X-LAGOON-VARNISH-BACKEND-BYPASS header we directly deliver\n if(beresp.http.X-LAGOON-VARNISH-BACKEND-BYPASS == \"TRUE\") {\n return (deliver);\n }\n\n # Cache 404 and 403 for 10 seconds\n if(beresp.status == 404 || beresp.status == 403) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n # Don't allow static files to set cookies.\n if (bereq.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n # beresp == Back-end response from the web server.\n unset beresp.http.set-cookie;\n unset beresp.http.Cache-Control;\n\n # If an asset would come back with statuscode 500 we only cache it for 10 seconds instead of the usual static file cache\n if (beresp.status == 500) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n set beresp.ttl = ${VARNISH_ASSETS_TTL:-2628001}s;\n set beresp.http.Cache-Control = \"public, max-age=${VARNISH_ASSETS_TTL:-2628001}\";\n set beresp.http.Expires = \"\" + (now + beresp.ttl);\n }\n\n return (deliver);\n}\n\n# Set a header to track a cache HIT\/MISS.\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Varnish-Cache = \"HIT\";\n }\n else {\n set resp.http.X-Varnish-Cache = \"MISS\";\n }\n\n # Remove ban-lurker friendly custom headers when delivering to client.\n unset resp.http.X-Url;\n unset resp.http.X-Host;\n\n # unset Cache-Tags Header by default, can be disabled with VARNISH_UNSET_HEADER_CACHE_TAGS=true\n if (!${VARNISH_UNSET_HEADER_CACHE_TAGS:-false}) {\n unset resp.http.Cache-Tags;\n }\n\n unset resp.http.X-Generator;\n unset resp.http.Server;\n # Inject information about grace\n if (req.http.grace) {\n set resp.http.X-Varnish-Grace = req.http.grace;\n }\n set resp.http.X-LAGOON = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}>\" + resp.http.X-LAGOON;\n return (deliver);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n if (req.http.X-Forwarded-Proto) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n if (req.http.HTTPS) {\n hash_data(req.http.HTTPS);\n }\n return (lookup);\n}\n\nsub vcl_synth {\n if (resp.status == 701) {\n set resp.status = 401;\n set resp.http.Content-Type = \"text\/plain; charset=utf-8\";\n synthetic({\"XMLRPC Interface is blocked due to SA-CORE-2014-004 - mail support@amazee.io if you need it.\"});\n return (deliver);\n }\n if (resp.status == 700) {\n # Set a status the client will understand\n set resp.status = 200;\n # Create our synthetic response\n synthetic(\"\");\n return(deliver);\n}\n return (deliver);\n}\n\nsub vcl_backend_error {\n # Restart the request, when we have a backend server error, to try another backend.\n # Restart max twice.\n if (bereq.retries < 2) {\n return(retry);\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<head>\n <title>Server Error<\/title>\n <style type=\"text\/css\">\n body {\n font-family: helvetica, arial, sans-serif;\n }\n img {\n margin-top: 50px;\n }\n p {\n width: 6 00px;\n margin-top: 10px\n }\n div {\n background: #ccc;\n width: 600px;\n margin: auto;\n padding: 50px;\n }\n span {\n color: #ccc\n }\n <\/style>\n<\/head>\n<body>\n <div>\n <h1>We are sorry...<\/h1>\n <p>We encountered a server-side error. This means that the problem is not with your computer or Internet connection, but rather with the website's server.<\/p>\n <p>We are currently working on solving this problem and apologise for the inconvenience.<\/p>\n <span>\n <strong>Technical Information<\/strong><br \/>\n Error \"} + beresp.status + \" \" + beresp.reason + {\"<br \/>\n XID: \"} + bereq.xid + {\"<br \/>\n <\/span>\n <\/div>\n<\/body>\n<\/html>\n\n\"} );\n return (deliver);\n}\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"aaf6682413dc99eee619a82871022dbddd835037","subject":"Fix the TLS message (#3358)","message":"Fix the TLS message (#3358)\n\n","repos":"pypa\/warehouse,dstufft\/warehouse,dstufft\/warehouse,dstufft\/warehouse,dstufft\/warehouse,pypa\/warehouse,pypa\/warehouse,pypa\/warehouse","old_file":"vcl\/main.vcl","new_file":"vcl\/main.vcl","new_contents":"# Note: It is VERY important to ensure that any changes to VCL will work\n# properly with both the current version of ``master`` and the version in\n# the pull request that adds any new changes. This is because the\n# configuration will be applied automatically as part of the deployment\n# process, but while the previous version of the code is still up and\n# running. Thus backwards incompatible changes must be broken up over\n# multiple pull requests in order to phase them in over multiple deploys.\n\nsub vcl_recv {\n\n # Fastly is dropping support for TLSv1.0 and TLSv1.1, in preperation for\n # for that, we're going to block support for it now, using VCL. This will\n # let us present a better error message in the interim before Fastly shuts\n # off TLSv1.0 and TLSv1.1 support completely.\n if (tls.client.protocol ~ \"^TLSv1(\\.(0|1))?$\") {\n error 804 \"Bad SSL Version\";\n }\n\n # I'm not 100% sure on what this is exactly for, it was taken from the\n # Fastly documentation, however, what I *believe* it does is just ensure\n # that we don't serve a stale copy of the page from the shield node when\n # an edge node is requesting content.\n if (req.http.Fastly-FF) {\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Some (Older) clients will send a hash fragment as part of the URL even\n # though that is a local only modification. This breaks this badly for the\n # files in S3, and in general it's just not needed.\n set req.url = regsub(req.url, \"#.*$\", \"\");\n\n # Fastly does some normalization of the Accept-Encoding header so that it\n # reduces the number of cached copies (when served with the common,\n # Vary: Accept-Encoding) that are cached for any one URL. This makes a lot\n # of sense, except for the fact that we want to enable brotli compression\n # for our static files. Thus we need to work around the normalized encoding\n # in a way that still minimizes cached copies, but which will allow our\n # static files to be served using brotli.\n if (req.url ~ \"^\/static\/\" && req.http.Fastly-Orig-Accept-Encoding) {\n if (req.http.User-Agent ~ \"MSIE 6\") {\n # For that 0.3% of stubborn users out there\n unset req.http.Accept-Encoding;\n } elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"br\") {\n set req.http.Accept-Encoding = \"br\";\n } elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n\n # Most of the URLs in Warehouse do not support or require any sort of query\n # parameter. If we strip these at the edge then we'll increase our cache\n # efficiency when they won't otherwise change the output of the pages.\n #\n # This will match any URL except those that start with:\n #\n # * \/admin\/\n # * \/search\/\n # * \/account\/login\/\n # * \/account\/logout\/\n # * \/account\/register\/\n # * \/account\/reset-password\/\n # * \/account\/verify-email\/\n # * \/pypi\n if (req.url.path !~ \"^\/(admin\/|search(\/|$)|account\/(login|logout|register|reset-password|verify-email)\/|pypi)\") {\n set req.url = req.url.path;\n }\n\n # Sort all of our query parameters, this will ensure that the same query\n # parameters in a different order will end up being represented as the same\n # thing, reducing cache misses due to ordering differences.\n set req.url = boltsort.sort(req.url);\n\n # We have a number of items that we'll pass back to the origin.\n # Set a header to tell the backend if we're using https or http.\n if (req.http.Fastly-SSL) {\n set req.http.Warehouse-Proto = \"https\";\n } else {\n set req.http.Warehouse-Proto = \"http\";\n }\n # Pass the client IP address back to the backend.\n if (req.http.Fastly-Client-IP) {\n set req.http.Warehouse-IP = req.http.Fastly-Client-IP;\n }\n # Pass the real host value back to the backend.\n if (req.http.Host) {\n set req.http.Warehouse-Host = req.http.host;\n }\n\n # Currently Fastly does not provide a way to access response headers when\n # the response is a 304 response. This is because the RFC states that only\n # a limit set of headers should be sent with a 304 response, and the rest\n # are SHOULD NOT. Since this stripping happens *prior* to vcl_deliver being\n # ran, that breaks our ability to log on 304 responses. Ideally at some\n # point Fastly offers us a way to access the \"real\" response headers even\n # for a 304 response, but for now, we are going to remove the headers that\n # allow a conditional response to be made. If at some point Fastly does\n # allow this, then we can delete this code.\n if (!req.http.Fastly-FF\n && std.tolower(req.http.Warehouse-Host) == \"files.pythonhosted.org\"\n && req.url.path ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\") {\n unset req.http.If-None-Match;\n unset req.http.If-Modified-Since;\n }\n\n\n#FASTLY recv\n\n\n # We want to Force SSL for the WebUI by redirecting to the HTTPS version of\n # the page, however for API calls we want to return an error code directing\n # people to instead use HTTPS.\n if (!req.http.Fastly-SSL) {\n\n # The \/simple\/ and \/packages\/ API.\n if (req.url ~ \"^\/(simple|packages)\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy JSON API.\n if (req.url ~ \"^\/pypi\/.+\/json$\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy ?:action= API.\n if (req.url ~ \"^\/pypi.*(\\?|&)=:action\") {\n error 803 \"SSL is required\";\n }\n\n # If we're on the \/pypi page and we've received something other than a\n # GET or HEAD request, then we have no way to determine if a particular\n # request is an API call or not because it'll be in the request body\n # and that isn't available to us here. So in those cases, we won't\n # do a redirect.\n if (req.url ~ \"^\/pypi\") {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n error 801 \"Force SSL\";\n }\n }\n else {\n # This isn't a \/pypi URL so we'll just unconditionally redirect to\n # HTTPS.\n error 801 \"Force SSL\";\n }\n }\n\n # Redirect pypi.io, www.pypi.io, and warehouse.python.org to pypi.org, this\n # is purposely done *after* the HTTPS checks.\n if (std.tolower(req.http.host) ~ \"^(www.pypi.org|(www.)?pypi.io|warehouse.python.org)$\") {\n set req.http.Location = \"https:\/\/pypi.org\" req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n # Redirect warehouse-staging.python.org to test.pypi.io.\n if (std.tolower(req.http.host) ~ \"^(test.pypi.io|warehouse-staging.python.org)$\") {\n set req.http.Location = \"https:\/\/test.pypi.org\" req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n\n # Requests to \/packages\/ get dispatched to Amazon instead of to our typical\n # Origin. This requires a a bit of setup to make it work.\n if (req.http.host ~ \"^(test-)?files.pythonhosted.org$\"\n && req.url ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\") {\n # Setup our environment to better match what S3 expects\/needs\n set req.http.Host = req.http.AWS-Bucket-Name \".s3.amazonaws.com\";\n set req.http.Date = now;\n set req.url = regsuball(req.url, \"\\+\", urlencode(\"+\"));\n\n # Compute the Authorization header that S3 requires to be able to\n # access the files stored there.\n set req.http.Authorization = \"AWS \" req.http.AWS-Access-Key-ID \":\" digest.hmac_sha1_base64(req.http.AWS-Secret-Access-Key, \"GET\" LF LF LF req.http.Date LF \"\/\" req.http.AWS-Bucket-Name req.url.path);\n\n # We don't want to send our Warehouse-Token to S3, so we'll go ahead\n # and remove it.\n unset req.http.Warehouse-Token;\n }\n\n # We no longer need any of these variables, which would exist only to\n # shuffle configuration from the Fastly UI into our VCL.\n unset req.http.AWS-Access-Key-ID;\n unset req.http.AWS-Secret-Access-Key;\n unset req.http.AWS-Bucket-Name;\n\n # On a POST, we want to skip the shielding and hit backends directly.\n if (req.request == \"POST\") {\n set req.backend = F_Heroku;\n }\n\n # Do not bother to attempt to run the caching mechanisms for methods that\n # are not generally safe to cache.\n if (req.request != \"HEAD\" &&\n req.request != \"GET\" &&\n req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n # We don't ever want to cache our health URL. Outside systems should be\n # able to use it to reach past Fastly and get an end to end health check.\n if (req.url == \"\/_health\/\") {\n return(pass);\n }\n\n # We never want to cache our admin URLs, while this should be \"safe\" due to\n # the architecure of Warehouse, it'll just be easier to debug issues if\n # these always are uncached.\n if (req.url ~ \"^\/admin\/\") {\n return(pass);\n }\n\n # Finally, return the default lookup action.\n return(lookup);\n}\n\n\nsub vcl_fetch {\n\n # These are newer kinds of redirects which should be able to be cached by\n # default, even though Fastly doesn't currently have them in their default\n # list of cacheable status codes.\n if (http_status_matches(beresp.status, \"303,307,308\")) {\n set beresp.cacheable = true;\n }\n\n # For any 5xx status code we want to see if a stale object exists for it,\n # if so we'll go ahead and serve it.\n if (beresp.status >= 500 && beresp.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n\n#FASTLY fetch\n\n\n # Trigger a \"SSL is required\" error if the backend has indicated to do so.\n if (beresp.http.X-Fastly-Error == \"803\") {\n error 803 \"SSL is required\";\n }\n\n # If we've gotten a 502 or a 503 from the backend, we'll go ahead and retry\n # the request.\n if ((beresp.status == 502 || beresp.status == 503) &&\n req.restarts < 1 &&\n (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n # If we've restarted, then we'll record the number of restarts.\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n # If there is a Set-Cookie header, we'll ensure that we do not cache the\n # response.\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n # If the response has the private Cache-Control directive then we won't\n # cache it.\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # If we've gotten an error after the restarts we'll deliver the response\n # with a very short cache time.\n if (http_status_matches(beresp.status, \"500,502,503\")) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n # Apply a default TTL if there isn't a max-age or s-maxage.\n if (beresp.http.Expires ||\n beresp.http.Surrogate-Control ~ \"max-age\" ||\n beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # Keep the ttl here\n }\n else {\n # Apply the default ttl\n set beresp.ttl = 60s;\n }\n\n # Actually deliver the fetched response.\n return(deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n # If the object we have isn't cacheable, then just serve it directly\n # without going through any of the caching mechanisms.\n if (!obj.cacheable) {\n return(pass);\n }\n\n return(deliver);\n}\n\n\nsub vcl_deliver {\n # If this is an error and we have a stale response available, restart so\n # that we can pick it up and serve it.\n if (resp.status >= 500 && resp.status < 600) {\n if (stale.exists) {\n restart;\n }\n }\n\n#FASTLY deliver\n\n # Unset headers that we don't need\/want to send on to the client because\n # they are not generally useful.\n unset resp.http.Via;\n\n # Set our standard security headers, we do this in VCL rather than in\n # Warehouse itself so that we always get these headers, regardless of the\n # origin server being used.\n set resp.http.Strict-Transport-Security = \"max-age=31536000; includeSubDomains; preload\";\n set resp.http.X-Frame-Options = \"deny\";\n set resp.http.X-XSS-Protection = \"1; mode=block\";\n set resp.http.X-Content-Type-Options = \"nosniff\";\n set resp.http.X-Permitted-Cross-Domain-Policies = \"none\";\n\n # Currently Fastly does not provide a way to access response headers when\n # the response is a 304 response. This is because the RFC states that only\n # a limit set of headers should be sent with a 304 response, and the rest\n # are SHOULD NOT. Since this stripping happens *prior* to vcl_deliver being\n # ran, that breaks our ability to log on 304 responses. Ideally at some\n # point Fastly offers us a way to access the \"real\" response headers even\n # for a 304 response, but for now, we are going to remove the headers that\n # allow a conditional response to be made. If at some point Fastly does\n # allow this, then we can delete this code, and also allow a 304 response\n # in the http_status_matches() check further down.\n if (!req.http.Fastly-FF\n && std.tolower(req.http.Warehouse-Host) == \"files.pythonhosted.org\"\n && req.url.path ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\") {\n unset resp.http.ETag;\n unset resp.http.Last-Modified;\n }\n\n # If we're not executing a shielding request, and the URL is one of our file\n # URLs, and it's a GET request, and the response is either a 200 or a 304\n # then we want to log an event stating that a download has taken place.\n if (!req.http.Fastly-FF\n && std.tolower(req.http.Warehouse-Host) == \"files.pythonhosted.org\"\n && req.url.path ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\"\n && req.request == \"GET\"\n && http_status_matches(resp.status, \"200\")) {\n log {\"syslog \"} req.service_id {\" linehaul :: \"} \"2@\" now \"|\" geoip.country_code \"|\" req.url.path \"|\" tls.client.protocol \"|\" tls.client.cipher \"|\" resp.http.x-amz-meta-project \"|\" resp.http.x-amz-meta-version \"|\" resp.http.x-amz-meta-package-type \"|\" req.http.user-agent;\n log {\"syslog \"} req.service_id {\" downloads :: \"} \"2@\" now \"|\" geoip.country_code \"|\" req.url.path \"|\" tls.client.protocol \"|\" tls.client.cipher \"|\" resp.http.x-amz-meta-project \"|\" resp.http.x-amz-meta-version \"|\" resp.http.x-amz-meta-package-type \"|\" req.http.user-agent;\n }\n\n # Set X-Robots-Header for everything _but_ prod\n if (std.tolower(req.http.host) !~ \"^pypi.org$\") {\n set resp.http.X-Robots-Header = \"noindex\";\n }\n\n # Unset a few headers set by Amazon that we don't really have a need\/desire\n # to send to clients.\n unset resp.http.x-amz-replication-status;\n unset resp.http.x-amz-meta-python-version;\n unset resp.http.x-amz-meta-version;\n unset resp.http.x-amz-meta-package-type;\n unset resp.http.x-amz-meta-project;\n\n\n return(deliver);\n}\n\n\nsub vcl_error {\n#FASTLY error\n\n # If we have a 5xx error and there is a stale object available, then we\n # will deliver that stale object.\n if (obj.status >= 500 && obj.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n if (obj.status == 803) {\n set obj.status = 403;\n set obj.response = \"SSL is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic {\"SSL is required.\"};\n return (deliver);\n } else if(obj.status == 804) {\n set obj.status = 403;\n set obj.response = \"TLSv1.2+ is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic \"Support for \" tls.client.protocol \" has been removed, please upgrade to a TLSv1.2+ client.\";\n return (deliver);\n } else if (obj.status == 750) {\n set obj.status = 301;\n set obj.http.Location = req.http.Location;\n set obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n synthetic {\"<html><head><title>301 Moved Permanently<\/title><\/head><body><center><h1>301 Moved Permanently<\/h1><\/center><\/body><\/html>\"};\n return(deliver);\n }\n\n}\n","old_contents":"# Note: It is VERY important to ensure that any changes to VCL will work\n# properly with both the current version of ``master`` and the version in\n# the pull request that adds any new changes. This is because the\n# configuration will be applied automatically as part of the deployment\n# process, but while the previous version of the code is still up and\n# running. Thus backwards incompatible changes must be broken up over\n# multiple pull requests in order to phase them in over multiple deploys.\n\nsub vcl_recv {\n\n # Fastly is dropping support for TLSv1.0 and TLSv1.1, in preperation for\n # for that, we're going to block support for it now, using VCL. This will\n # let us present a better error message in the interim before Fastly shuts\n # off TLSv1.0 and TLSv1.1 support completely.\n if (tls.client.protocol ~ \"^TLSv1(\\.(0|1))?$\") {\n error 804 \"Bad SSL Version\";\n }\n\n # I'm not 100% sure on what this is exactly for, it was taken from the\n # Fastly documentation, however, what I *believe* it does is just ensure\n # that we don't serve a stale copy of the page from the shield node when\n # an edge node is requesting content.\n if (req.http.Fastly-FF) {\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Some (Older) clients will send a hash fragment as part of the URL even\n # though that is a local only modification. This breaks this badly for the\n # files in S3, and in general it's just not needed.\n set req.url = regsub(req.url, \"#.*$\", \"\");\n\n # Fastly does some normalization of the Accept-Encoding header so that it\n # reduces the number of cached copies (when served with the common,\n # Vary: Accept-Encoding) that are cached for any one URL. This makes a lot\n # of sense, except for the fact that we want to enable brotli compression\n # for our static files. Thus we need to work around the normalized encoding\n # in a way that still minimizes cached copies, but which will allow our\n # static files to be served using brotli.\n if (req.url ~ \"^\/static\/\" && req.http.Fastly-Orig-Accept-Encoding) {\n if (req.http.User-Agent ~ \"MSIE 6\") {\n # For that 0.3% of stubborn users out there\n unset req.http.Accept-Encoding;\n } elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"br\") {\n set req.http.Accept-Encoding = \"br\";\n } elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n\n # Most of the URLs in Warehouse do not support or require any sort of query\n # parameter. If we strip these at the edge then we'll increase our cache\n # efficiency when they won't otherwise change the output of the pages.\n #\n # This will match any URL except those that start with:\n #\n # * \/admin\/\n # * \/search\/\n # * \/account\/login\/\n # * \/account\/logout\/\n # * \/account\/register\/\n # * \/account\/reset-password\/\n # * \/account\/verify-email\/\n # * \/pypi\n if (req.url.path !~ \"^\/(admin\/|search(\/|$)|account\/(login|logout|register|reset-password|verify-email)\/|pypi)\") {\n set req.url = req.url.path;\n }\n\n # Sort all of our query parameters, this will ensure that the same query\n # parameters in a different order will end up being represented as the same\n # thing, reducing cache misses due to ordering differences.\n set req.url = boltsort.sort(req.url);\n\n # We have a number of items that we'll pass back to the origin.\n # Set a header to tell the backend if we're using https or http.\n if (req.http.Fastly-SSL) {\n set req.http.Warehouse-Proto = \"https\";\n } else {\n set req.http.Warehouse-Proto = \"http\";\n }\n # Pass the client IP address back to the backend.\n if (req.http.Fastly-Client-IP) {\n set req.http.Warehouse-IP = req.http.Fastly-Client-IP;\n }\n # Pass the real host value back to the backend.\n if (req.http.Host) {\n set req.http.Warehouse-Host = req.http.host;\n }\n\n # Currently Fastly does not provide a way to access response headers when\n # the response is a 304 response. This is because the RFC states that only\n # a limit set of headers should be sent with a 304 response, and the rest\n # are SHOULD NOT. Since this stripping happens *prior* to vcl_deliver being\n # ran, that breaks our ability to log on 304 responses. Ideally at some\n # point Fastly offers us a way to access the \"real\" response headers even\n # for a 304 response, but for now, we are going to remove the headers that\n # allow a conditional response to be made. If at some point Fastly does\n # allow this, then we can delete this code.\n if (!req.http.Fastly-FF\n && std.tolower(req.http.Warehouse-Host) == \"files.pythonhosted.org\"\n && req.url.path ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\") {\n unset req.http.If-None-Match;\n unset req.http.If-Modified-Since;\n }\n\n\n#FASTLY recv\n\n\n # We want to Force SSL for the WebUI by redirecting to the HTTPS version of\n # the page, however for API calls we want to return an error code directing\n # people to instead use HTTPS.\n if (!req.http.Fastly-SSL) {\n\n # The \/simple\/ and \/packages\/ API.\n if (req.url ~ \"^\/(simple|packages)\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy JSON API.\n if (req.url ~ \"^\/pypi\/.+\/json$\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy ?:action= API.\n if (req.url ~ \"^\/pypi.*(\\?|&)=:action\") {\n error 803 \"SSL is required\";\n }\n\n # If we're on the \/pypi page and we've received something other than a\n # GET or HEAD request, then we have no way to determine if a particular\n # request is an API call or not because it'll be in the request body\n # and that isn't available to us here. So in those cases, we won't\n # do a redirect.\n if (req.url ~ \"^\/pypi\") {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n error 801 \"Force SSL\";\n }\n }\n else {\n # This isn't a \/pypi URL so we'll just unconditionally redirect to\n # HTTPS.\n error 801 \"Force SSL\";\n }\n }\n\n # Redirect pypi.io, www.pypi.io, and warehouse.python.org to pypi.org, this\n # is purposely done *after* the HTTPS checks.\n if (std.tolower(req.http.host) ~ \"^(www.pypi.org|(www.)?pypi.io|warehouse.python.org)$\") {\n set req.http.Location = \"https:\/\/pypi.org\" req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n # Redirect warehouse-staging.python.org to test.pypi.io.\n if (std.tolower(req.http.host) ~ \"^(test.pypi.io|warehouse-staging.python.org)$\") {\n set req.http.Location = \"https:\/\/test.pypi.org\" req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n\n # Requests to \/packages\/ get dispatched to Amazon instead of to our typical\n # Origin. This requires a a bit of setup to make it work.\n if (req.http.host ~ \"^(test-)?files.pythonhosted.org$\"\n && req.url ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\") {\n # Setup our environment to better match what S3 expects\/needs\n set req.http.Host = req.http.AWS-Bucket-Name \".s3.amazonaws.com\";\n set req.http.Date = now;\n set req.url = regsuball(req.url, \"\\+\", urlencode(\"+\"));\n\n # Compute the Authorization header that S3 requires to be able to\n # access the files stored there.\n set req.http.Authorization = \"AWS \" req.http.AWS-Access-Key-ID \":\" digest.hmac_sha1_base64(req.http.AWS-Secret-Access-Key, \"GET\" LF LF LF req.http.Date LF \"\/\" req.http.AWS-Bucket-Name req.url.path);\n\n # We don't want to send our Warehouse-Token to S3, so we'll go ahead\n # and remove it.\n unset req.http.Warehouse-Token;\n }\n\n # We no longer need any of these variables, which would exist only to\n # shuffle configuration from the Fastly UI into our VCL.\n unset req.http.AWS-Access-Key-ID;\n unset req.http.AWS-Secret-Access-Key;\n unset req.http.AWS-Bucket-Name;\n\n # On a POST, we want to skip the shielding and hit backends directly.\n if (req.request == \"POST\") {\n set req.backend = F_Heroku;\n }\n\n # Do not bother to attempt to run the caching mechanisms for methods that\n # are not generally safe to cache.\n if (req.request != \"HEAD\" &&\n req.request != \"GET\" &&\n req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n # We don't ever want to cache our health URL. Outside systems should be\n # able to use it to reach past Fastly and get an end to end health check.\n if (req.url == \"\/_health\/\") {\n return(pass);\n }\n\n # We never want to cache our admin URLs, while this should be \"safe\" due to\n # the architecure of Warehouse, it'll just be easier to debug issues if\n # these always are uncached.\n if (req.url ~ \"^\/admin\/\") {\n return(pass);\n }\n\n # Finally, return the default lookup action.\n return(lookup);\n}\n\n\nsub vcl_fetch {\n\n # These are newer kinds of redirects which should be able to be cached by\n # default, even though Fastly doesn't currently have them in their default\n # list of cacheable status codes.\n if (http_status_matches(beresp.status, \"303,307,308\")) {\n set beresp.cacheable = true;\n }\n\n # For any 5xx status code we want to see if a stale object exists for it,\n # if so we'll go ahead and serve it.\n if (beresp.status >= 500 && beresp.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n\n#FASTLY fetch\n\n\n # Trigger a \"SSL is required\" error if the backend has indicated to do so.\n if (beresp.http.X-Fastly-Error == \"803\") {\n error 803 \"SSL is required\";\n }\n\n # If we've gotten a 502 or a 503 from the backend, we'll go ahead and retry\n # the request.\n if ((beresp.status == 502 || beresp.status == 503) &&\n req.restarts < 1 &&\n (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n # If we've restarted, then we'll record the number of restarts.\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n # If there is a Set-Cookie header, we'll ensure that we do not cache the\n # response.\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n # If the response has the private Cache-Control directive then we won't\n # cache it.\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # If we've gotten an error after the restarts we'll deliver the response\n # with a very short cache time.\n if (http_status_matches(beresp.status, \"500,502,503\")) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n # Apply a default TTL if there isn't a max-age or s-maxage.\n if (beresp.http.Expires ||\n beresp.http.Surrogate-Control ~ \"max-age\" ||\n beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # Keep the ttl here\n }\n else {\n # Apply the default ttl\n set beresp.ttl = 60s;\n }\n\n # Actually deliver the fetched response.\n return(deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n # If the object we have isn't cacheable, then just serve it directly\n # without going through any of the caching mechanisms.\n if (!obj.cacheable) {\n return(pass);\n }\n\n return(deliver);\n}\n\n\nsub vcl_deliver {\n # If this is an error and we have a stale response available, restart so\n # that we can pick it up and serve it.\n if (resp.status >= 500 && resp.status < 600) {\n if (stale.exists) {\n restart;\n }\n }\n\n#FASTLY deliver\n\n # Unset headers that we don't need\/want to send on to the client because\n # they are not generally useful.\n unset resp.http.Via;\n\n # Set our standard security headers, we do this in VCL rather than in\n # Warehouse itself so that we always get these headers, regardless of the\n # origin server being used.\n set resp.http.Strict-Transport-Security = \"max-age=31536000; includeSubDomains; preload\";\n set resp.http.X-Frame-Options = \"deny\";\n set resp.http.X-XSS-Protection = \"1; mode=block\";\n set resp.http.X-Content-Type-Options = \"nosniff\";\n set resp.http.X-Permitted-Cross-Domain-Policies = \"none\";\n\n # Currently Fastly does not provide a way to access response headers when\n # the response is a 304 response. This is because the RFC states that only\n # a limit set of headers should be sent with a 304 response, and the rest\n # are SHOULD NOT. Since this stripping happens *prior* to vcl_deliver being\n # ran, that breaks our ability to log on 304 responses. Ideally at some\n # point Fastly offers us a way to access the \"real\" response headers even\n # for a 304 response, but for now, we are going to remove the headers that\n # allow a conditional response to be made. If at some point Fastly does\n # allow this, then we can delete this code, and also allow a 304 response\n # in the http_status_matches() check further down.\n if (!req.http.Fastly-FF\n && std.tolower(req.http.Warehouse-Host) == \"files.pythonhosted.org\"\n && req.url.path ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\") {\n unset resp.http.ETag;\n unset resp.http.Last-Modified;\n }\n\n # If we're not executing a shielding request, and the URL is one of our file\n # URLs, and it's a GET request, and the response is either a 200 or a 304\n # then we want to log an event stating that a download has taken place.\n if (!req.http.Fastly-FF\n && std.tolower(req.http.Warehouse-Host) == \"files.pythonhosted.org\"\n && req.url.path ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\"\n && req.request == \"GET\"\n && http_status_matches(resp.status, \"200\")) {\n log {\"syslog \"} req.service_id {\" linehaul :: \"} \"2@\" now \"|\" geoip.country_code \"|\" req.url.path \"|\" tls.client.protocol \"|\" tls.client.cipher \"|\" resp.http.x-amz-meta-project \"|\" resp.http.x-amz-meta-version \"|\" resp.http.x-amz-meta-package-type \"|\" req.http.user-agent;\n log {\"syslog \"} req.service_id {\" downloads :: \"} \"2@\" now \"|\" geoip.country_code \"|\" req.url.path \"|\" tls.client.protocol \"|\" tls.client.cipher \"|\" resp.http.x-amz-meta-project \"|\" resp.http.x-amz-meta-version \"|\" resp.http.x-amz-meta-package-type \"|\" req.http.user-agent;\n }\n\n # Set X-Robots-Header for everything _but_ prod\n if (std.tolower(req.http.host) !~ \"^pypi.org$\") {\n set resp.http.X-Robots-Header = \"noindex\";\n }\n\n # Unset a few headers set by Amazon that we don't really have a need\/desire\n # to send to clients.\n unset resp.http.x-amz-replication-status;\n unset resp.http.x-amz-meta-python-version;\n unset resp.http.x-amz-meta-version;\n unset resp.http.x-amz-meta-package-type;\n unset resp.http.x-amz-meta-project;\n\n\n return(deliver);\n}\n\n\nsub vcl_error {\n#FASTLY error\n\n # If we have a 5xx error and there is a stale object available, then we\n # will deliver that stale object.\n if (obj.status >= 500 && obj.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n if (obj.status == 803) {\n set obj.status = 403;\n set obj.response = \"SSL is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic {\"SSL is required.\"};\n return (deliver);\n } else if(obj.status == 804) {\n set obj.status = 403;\n set obj.response = \"TLSv1.2+ is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic {\"Support for \" tls.client.protocol \" has been removed, please upgrade to a TLSv1.2+ client.\"};\n return (deliver);\n } else if (obj.status == 750) {\n set obj.status = 301;\n set obj.http.Location = req.http.Location;\n set obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n synthetic {\"<html><head><title>301 Moved Permanently<\/title><\/head><body><center><h1>301 Moved Permanently<\/h1><\/center><\/body><\/html>\"};\n return(deliver);\n }\n\n}\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"8b17c76e5f1b6b9facbe69133139841a180b9213","subject":"Varnish rule to cache static doc files","message":"Varnish rule to cache static doc files\n\nNormalize req.url part of vcl_hash for static files at project\/doc\/*\nto avoid reading these files more than once from backend.\n","repos":"youprofit\/rust-ci-1,hansjorg\/rust-ci,youprofit\/rust-ci-1,youprofit\/rust-ci-1,hansjorg\/rust-ci,youprofit\/rust-ci-1","old_file":"config\/rust-ci.vcl","new_file":"config\/rust-ci.vcl","new_contents":"# Varnish VCL config for www.rust-ci.org\n\nbackend nginx {\n .host = \"127.0.0.1\";\n .port = \"8000\";\n}\n\nacl purge {\n \"localhost\";\n}\n\nsub vcl_recv {\n set req.backend = nginx;\n\n if ((req.url ~ \"\/p\/\") || (req.url ~ \"\/admin\") || (req.url ~ \"\/artifacts\") || (req.url ~ \"\/callback\")) {\n return(pass);\n }\n\n # Normalize host header (for test env)\n set req.http.Host = \"www.rust-ci.org\";\n\n # Remove cookies from request\n unset req.http.cookie;\n\n if (req.request == \"PURGE\") {\n # Ignore query string (python-varnish adds \"?\" to PURGE URLs)\n set req.url = regsub(req.url, \"\\?.*$\", \"\");\n if (!client.ip ~ purge) {\n error 405 \"Not allowed.\";\n }\n return (lookup);\n }\n}\n\nsub vcl_hash {\n\n\t# All the project\/doc\/.* static files are the same, except for search-index.js\n\t# Normalize the hashed req.url so that these files are only fetched once from S3\n\n\tif (req.url ~ \"doc\\\/[^.]*\\.(woff|css|js)$\" && req.url !~ \"search-index.js$\") {\n\t\thash_data(regsub(req.url, \"(.*)\\\/doc\", \"\/normalized\"));\n\t} else {\n\t\thash_data(req.url);\n\t}\n\n\tif (req.http.host) {\n\t\t\thash_data(req.http.host);\n\t} else {\n\t\t\thash_data(server.ip);\n\t}\n\treturn (hash);\n}\n\nsub vcl_hit {\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged.\";\n }\n}\n\nsub vcl_miss {\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged.\";\n }\n}\n\nsub vcl_fetch {\n # Remove set-cookie from backend response\n if (!(req.url ~ \"\/p\/\") && !(req.url ~ \"\/admin\") && !(req.url ~ \"\/artifacts\") && !(req.url ~ \"\/callback\")) {\n unset beresp.http.set-cookie;\n }\n\n # Remove Expires from backend\n unset beresp.http.expires;\n\n # Set the clients TTL on this object\n if (req.url ~ \"^\/static\") {\n set beresp.http.cache-control = \"max-age=31536000\";\n } else {\n set beresp.http.cache-control = \"max-age=0\";\n }\n\n # Set how long Varnish will keep it\n set beresp.ttl = 10w;\n\n # marker for vcl_deliver to reset Age:\n set beresp.http.magicmarker = \"1\";\n}\n\nsub vcl_deliver {\n if (resp.http.magicmarker) {\n # Remove the magic marker\n unset resp.http.magicmarker;\n\n # By definition we have a fresh object\n set resp.http.age = \"0\";\n }\n\n # Set HIT\/MISS indicator\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n\n","old_contents":"# Varnish VCL config for www.rust-ci.org\n\nbackend nginx {\n .host = \"127.0.0.1\";\n .port = \"8000\";\n}\n\nacl purge {\n \"localhost\";\n}\n\nsub vcl_recv {\n set req.backend = nginx;\n\n if ((req.url ~ \"\/p\/\") || (req.url ~ \"\/admin\") || (req.url ~ \"\/artifacts\") || (req.url ~ \"\/callback\")) {\n return(pass);\n }\n\n # Normalize host header (for test env)\n set req.http.Host = \"www.rust-ci.org\";\n\n # Remove cookies from request\n unset req.http.cookie;\n\n if (req.request == \"PURGE\") {\n # Ignore query string (python-varnish adds \"?\" to PURGE URLs)\n set req.url = regsub(req.url, \"\\?.*$\", \"\");\n if (!client.ip ~ purge) {\n error 405 \"Not allowed.\";\n }\n return (lookup);\n }\n}\n\nsub vcl_hit {\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged.\";\n }\n}\n\nsub vcl_miss {\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged.\";\n }\n}\n\nsub vcl_fetch {\n # Remove set-cookie from backend response\n if (!(req.url ~ \"\/p\/\") && !(req.url ~ \"\/admin\") && !(req.url ~ \"\/artifacts\") && !(req.url ~ \"\/callback\")) {\n unset beresp.http.set-cookie;\n }\n\n # Remove Expires from backend\n unset beresp.http.expires;\n\n # Set the clients TTL on this object\n if (req.url ~ \"^\/static\") {\n set beresp.http.cache-control = \"max-age=31536000\";\n } else {\n set beresp.http.cache-control = \"max-age=0\";\n }\n\n # Set how long Varnish will keep it\n set beresp.ttl = 10w;\n\n # marker for vcl_deliver to reset Age:\n set beresp.http.magicmarker = \"1\";\n}\n\nsub vcl_deliver {\n if (resp.http.magicmarker) {\n # Remove the magic marker\n unset resp.http.magicmarker;\n\n # By definition we have a fresh object\n set resp.http.age = \"0\";\n }\n\n # Set HIT\/MISS indicator\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n } \n}\n\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"a0c9ec2d8121274e7a9c7e9252d4ba84c8547031","subject":"Moved the logic to set a TTL for 404s.","message":"Moved the logic to set a TTL for 404s.\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/fastly.vcl","new_file":"etc\/fastly.vcl","new_contents":"###############################################################################\n#\n# Fastly CDN for Magento 2\n#\n# NOTICE OF LICENSE\n#\n# This source file is subject to the Fastly CDN for Magento 2 End User License\n# Agreement that is bundled with this package in the file LICENSE_FASTLY_CDN.txt.\n#\n# @copyright Copyright (c) 2016 Fastly, Inc. (http:\/\/www.fastly.com)\n# @license BSD, see LICENSE_FASTLY_CDN.txt\n#\n###############################################################################\n\n# This is a basic VCL configuration file for Fastly CDN for Magento 2 module.\n\nsub vcl_recv {\n#FASTLY recv\n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n set req.http.X-Sig = regsub(req.http.X-Purge-Token, \"^[^_]+_(.*)\", \"\\1\");\n set req.http.X-Exp = regsub(req.http.X-Purge-Token, \"^([^_]+)_.*\", \"\\1\");\n\n # validate signature\n if (req.http.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path req.http.X-Exp), \"^0x\", \"\")) {\n\n # use vcl time math to check expiration timestamp\n set req.http.X-Original-Grace = req.grace;\n set req.grace = std.atoi(strftime({\"%s\"}, now));\n set req.grace -= std.atoi(req.http.X-Exp);\n\n if (std.atoi(req.grace) > 0) {\n error 410;\n }\n\n # clean up grace since we used it for time math\n set req.grace = std.atoi(req.http.X-Original-Grace);\n unset req.http.X-Original-Grace;\n\n } else {\n error 403;\n }\n\n # cleanup variables\n unset req.http.X-Purge-Token;\n unset req.http.X-Sig;\n unset req.http.X-Exp;\n }\n\n # Deactivate gzip\n set req.http.X-Orig-Accept-Encoding = req.http.Accept-Encoding;\n unset req.http.Accept-Encoding;\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n # disable ESI processing on Origin Shield\n if (req.http.Fastly-FF) {\n set req.esi = false;\n }\n\n # We only deal with GET and HEAD by default\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n return (pass);\n }\n\n # Bypass shopping cart and checkout requests\n if (req.url ~ \"\/checkout\") {\n return (pass);\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie ~ \"(X-Magento-Vary|form_key)=\") {\n error 200 \"\";\n } else {\n # append parameter with country code\n set req.url = req.url \"?country_code=\" geoip.country_code;\n }\n }\n\n return(lookup);\n}\n\nsub vcl_fetch {\n\n # Remove Set-Cookies from responses for static content\n # to match the cookie removal in recv.\n if (req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n }\n\n }\n\n#FASTLY fetch\n\n if (beresp.status >= 500) {\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n }\n\n if (req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Content-Type ~ \"text\/html\" || beresp.http.Content-Type ~ \"text\/xml\") {\n # enable ESI feature for Magento response by default\n esi;\n } else {\n # enable gzip for all static content\n if ((beresp.status == 200 || beresp.status == 404) && (beresp.http.content-type ~ \"^(text\\\/html|application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain|text\\\/xml)\\s*($|;)\" || req.url ~ \"\\.(css|js|html|eot|ico|otf|ttf|json)($|\\?)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.X-Orig-Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # cache only successfully responses and 404s\n if (beresp.status != 200 && beresp.status != 301 && beresp.status != 404) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\")) {\n unset beresp.http.set-cookie;\n if (req.url !~ \"^\/(pub\/)?(media|static)\/.*\") {\n set beresp.http.Pragma = \"no-cache\";\n set beresp.http.Expires = \"-1\";\n set beresp.http.Cache-Control = \"no-store, no-cache, must-revalidate, max-age=0\";\n set beresp.grace = 1m;\n }\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type\n if (beresp.http.Content-Type ~ \"image\") {\n set beresp.http.Surrogate-Key = \"image\";\n } elsif (beresp.http.Content-Type ~ \"script\") {\n set beresp.http.Surrogate-Key = \"script\";\n } elsif (beresp.http.Content-Type ~ \"css\") {\n set beresp.http.Surrogate-Key = \"css\";\n }\n\n set beresp.http.X-Surrogate-Key = beresp.http.Surrogate-Key;\n return (deliver);\n }\n\n return (deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\n\nsub vcl_miss {\n#FASTLY miss\n\n return(fetch);\n}\n\nsub vcl_deliver {\n # debug info\n if (resp.http.X-Magento-Debug) {\n if (obj.hits > 0) {\n set resp.http.X-Magento-Cache-Debug = \"HIT\";\n set resp.http.X-Magento-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Magento-Cache-Debug = \"MISS\";\n }\n } else {\n # remove Varnish\/proxy header\n remove resp.http.Age;\n remove resp.http.X-Magento-Debug;\n remove resp.http.X-Magento-Tags;\n remove resp.http.X-Surrogate-Key;\n remove resp.http.X-Magento-Cache-Control;\n remove resp.http.X-Powered-By;\n remove resp.http.Server;\n remove resp.http.X-Varnish;\n remove resp.http.Via;\n remove resp.http.Link;\n remove resp.http.X-Purge-URL;\n remove resp.http.X-Purge-Host;\n }\n\n#FASTLY deliver\n\n return (deliver);\n}\n\n\nsub vcl_error {\n # workaround for possible security issue\n if (req.url ~ \"^\\s\") {\n set obj.status = 400;\n set obj.response = \"Malformed request\";\n synthetic \"\";\n return (deliver);\n }\n\n # error 200\n if (obj.status == 200) {\n return (deliver);\n }\n\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} obj.status \" \" obj.response {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} obj.status \" \" obj.response {\"<\/h1>\n <p>\"} obj.response {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} req.xid {\"<\/p>\n <hr>\n <p>Fastly CDN server<\/p>\n <\/body>\n<\/html>\n\"};\n\n#FASTLY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n\nsub vcl_hash {\n set req.hash += req.http.Https;\n set req.hash += req.http.host;\n set req.hash += req.url;\n\n if (req.http.cookie ~ \"X-Magento-Vary=\") {\n set req.http.X-Magento-Vary = regsub(req.http.cookie, \"^.*?X-Magento-Vary=([^;]+);*.*$\", \"\\1\");\n set req.hash += req.http.X-Magento-Vary;\n unset req.http.X-Magento-Vary;\n }\n \n set req.hash += \"#####GENERATION#####\";\n\n ### {{ design_exceptions_code }} ###\n\n return (hash);\n}\n\n","old_contents":"###############################################################################\n#\n# Fastly CDN for Magento 2\n#\n# NOTICE OF LICENSE\n#\n# This source file is subject to the Fastly CDN for Magento 2 End User License\n# Agreement that is bundled with this package in the file LICENSE_FASTLY_CDN.txt.\n#\n# @copyright Copyright (c) 2016 Fastly, Inc. (http:\/\/www.fastly.com)\n# @license BSD, see LICENSE_FASTLY_CDN.txt\n#\n###############################################################################\n\n# This is a basic VCL configuration file for Fastly CDN for Magento 2 module.\n\nsub vcl_recv {\n#FASTLY recv\n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n set req.http.X-Sig = regsub(req.http.X-Purge-Token, \"^[^_]+_(.*)\", \"\\1\");\n set req.http.X-Exp = regsub(req.http.X-Purge-Token, \"^([^_]+)_.*\", \"\\1\");\n\n # validate signature\n if (req.http.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path req.http.X-Exp), \"^0x\", \"\")) {\n\n # use vcl time math to check expiration timestamp\n set req.http.X-Original-Grace = req.grace;\n set req.grace = std.atoi(strftime({\"%s\"}, now));\n set req.grace -= std.atoi(req.http.X-Exp);\n\n if (std.atoi(req.grace) > 0) {\n error 410;\n }\n\n # clean up grace since we used it for time math\n set req.grace = std.atoi(req.http.X-Original-Grace);\n unset req.http.X-Original-Grace;\n\n } else {\n error 403;\n }\n\n # cleanup variables\n unset req.http.X-Purge-Token;\n unset req.http.X-Sig;\n unset req.http.X-Exp;\n }\n\n # Deactivate gzip\n set req.http.X-Orig-Accept-Encoding = req.http.Accept-Encoding;\n unset req.http.Accept-Encoding;\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n # disable ESI processing on Origin Shield\n if (req.http.Fastly-FF) {\n set req.esi = false;\n }\n\n # We only deal with GET and HEAD by default\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n return (pass);\n }\n\n # Bypass shopping cart and checkout requests\n if (req.url ~ \"\/checkout\") {\n return (pass);\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie ~ \"(X-Magento-Vary|form_key)=\") {\n error 200 \"\";\n } else {\n # append parameter with country code\n set req.url = req.url \"?country_code=\" geoip.country_code;\n }\n }\n\n return(lookup);\n}\n\nsub vcl_fetch {\n\n # Remove Set-Cookies from responses for static content\n # to match the cookie removal in recv.\n if (req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n }\n\n }\n\n#FASTLY fetch\n\n if (beresp.status >= 500) {\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n }\n\n if (req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Content-Type ~ \"text\/html\" || beresp.http.Content-Type ~ \"text\/xml\") {\n # enable ESI feature for Magento response by default\n esi;\n } else {\n # enable gzip for all static content\n if ((beresp.status == 200 || beresp.status == 404) && (beresp.http.content-type ~ \"^(text\\\/html|application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain|text\\\/xml)\\s*($|;)\" || req.url ~ \"\\.(css|js|html|eot|ico|otf|ttf|json)($|\\?)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.X-Orig-Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # cache only successfully responses and 404s\n if (beresp.status != 200 && beresp.status != 301 && beresp.status != 404) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\")) {\n unset beresp.http.set-cookie;\n if (req.url !~ \"^\/(pub\/)?(media|static)\/.*\") {\n set beresp.http.Pragma = \"no-cache\";\n set beresp.http.Expires = \"-1\";\n set beresp.http.Cache-Control = \"no-store, no-cache, must-revalidate, max-age=0\";\n set beresp.grace = 1m;\n }\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type\n if (beresp.http.Content-Type ~ \"image\") {\n set beresp.http.Surrogate-Key = \"image\";\n } elsif (beresp.http.Content-Type ~ \"script\") {\n set beresp.http.Surrogate-Key = \"script\";\n } elsif (beresp.http.Content-Type ~ \"css\") {\n set beresp.http.Surrogate-Key = \"css\";\n }\n\n set beresp.http.X-Surrogate-Key = beresp.http.Surrogate-Key;\n return (deliver);\n }\n\n return (deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\n\nsub vcl_miss {\n#FASTLY miss\n\n return(fetch);\n}\n\nsub vcl_deliver {\n # debug info\n if (resp.http.X-Magento-Debug) {\n if (obj.hits > 0) {\n set resp.http.X-Magento-Cache-Debug = \"HIT\";\n set resp.http.X-Magento-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Magento-Cache-Debug = \"MISS\";\n }\n } else {\n # remove Varnish\/proxy header\n remove resp.http.Age;\n remove resp.http.X-Magento-Debug;\n remove resp.http.X-Magento-Tags;\n remove resp.http.X-Surrogate-Key;\n remove resp.http.X-Magento-Cache-Control;\n remove resp.http.X-Powered-By;\n remove resp.http.Server;\n remove resp.http.X-Varnish;\n remove resp.http.Via;\n remove resp.http.Link;\n remove resp.http.X-Purge-URL;\n remove resp.http.X-Purge-Host;\n }\n\n#FASTLY deliver\n\n return (deliver);\n}\n\n\nsub vcl_error {\n # workaround for possible security issue\n if (req.url ~ \"^\\s\") {\n set obj.status = 400;\n set obj.response = \"Malformed request\";\n synthetic \"\";\n return (deliver);\n }\n\n # error 200\n if (obj.status == 200) {\n return (deliver);\n }\n\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} obj.status \" \" obj.response {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} obj.status \" \" obj.response {\"<\/h1>\n <p>\"} obj.response {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} req.xid {\"<\/p>\n <hr>\n <p>Fastly CDN server<\/p>\n <\/body>\n<\/html>\n\"};\n\n#FASTLY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n\nsub vcl_hash {\n set req.hash += req.http.Https;\n set req.hash += req.http.host;\n set req.hash += req.url;\n\n if (req.http.cookie ~ \"X-Magento-Vary=\") {\n set req.http.X-Magento-Vary = regsub(req.http.cookie, \"^.*?X-Magento-Vary=([^;]+);*.*$\", \"\\1\");\n set req.hash += req.http.X-Magento-Vary;\n unset req.http.X-Magento-Vary;\n }\n \n set req.hash += \"#####GENERATION#####\";\n\n ### {{ design_exceptions_code }} ###\n\n return (hash);\n}\n\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"989d5219de2169bbb946d26204f582e357999e00","subject":"Add a test to make sure synchronizing is working on laptop","message":"Add a test to make sure synchronizing is working on laptop\n","repos":"aschneiderman\/atom-voice-vocola","old_file":"atom.vcl","new_file":"atom.vcl","new_contents":"# Voice commands for atom\n\nTest Command = \"This Is a Test Command\"; # see if working on laptop\n\ninclude folders.vch;\ninclude letters.vch;\n\n# Commands for developing D3: D3 visualizations, D3 Sandwiches\nSave and Reload = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Ctrl+r};\t\nSave and Really Reload = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Ctrl+Shift+r};\nSave and Run = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Up}{Enter};\n\n# File commands\nFind (File | Document) = {Ctrl+t};\nSave As = {Ctrl+Shift+s};\nNext Window = {Ctrl+Tab};\nLast Window = {Ctrl+Shift+Tab};\nLatest File = {Ctrl+Shift+t};\n(Tree View | List Files) = {Alt+o};\t# NOTE: to make this work, I had to create a new keyboard shortcut in Atom (my personal keymap.cson)\n\n\n# --- Text navigation commands ------------------------------------\n<delimiters> := (Quote = '\"' | 'Double Quote' = '\"' | 'Single Quote' = \"'\" | Comma = ',' | 'Equal Sign' = '=' | Equals = '=' \n\t| Period = '.' | Colon = ':' | 'Semi-Colon' = ';' | Hyphen = '-' | Underscore = '_' | Slash = '\/'\n\t| Paren = \"(\" | \"Close Paren\" = \")\" | Parentheses = \"(\" | \"Open Parenthesis\" = \"(\" | \"Close Parentheses\" = \")\"\n\t| Bracket = '[' | \"Close Bracket\" = ']' | Brace = '{' | 'Close Brace' = '}'\t);\n\nLine 1..200 = {Ctrl+g} $1 {Enter};\n(Left = 'b' | Right = 'f') Word = {Alt+$1};\nTop = {Ctrl+Home};\nBottom = {Ctrl+End};\n(Find = 'Right' | 'Insert After' = 'Right' | 'Insert Before' = 'Left') (Next = 'Enter' | Last = 'Shift+F3') <delimiters> \n\t\t= {Ctrl+f} $3 {$2} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') <delimiters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') 1..20 <delimiters> = {Ctrl+f} $3 {Enter} {Esc} Wait(100) {F3_$2} {Shift+F3} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') Enda <delimiters> = {End} {Ctrl+f} $2 {Enter} {Esc} {Shift+F3} Wait(100) {$1};\n\nFine Alpha <letters> = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Left};\nInsert (Before = 'Left' | After = 'Right') Alpha <letters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nFine Number 0..9 = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Right};\n(Find | Insert) Again = {F3} {Right};\n(Find | Insert) Again 1..20 Times = {F3_$1} {Right};\n\n(Set | Add | Clear | Hide | Delete) Bookmark = {Ctrl+Alt+F2};\n(Next = 'F2' | Last = 'Shift+F2') Bookmark = {$1};\n\n\n# --- Editing commands ----------------------------------------\nSelect Line = {Ctrl+l};\nSelect (Next = 'Down' | Forward = 'Down' | Last = 'Up' | Back = 'Up' | Previous = 'Up') 1..20 Lines = {Home} {Shift+$1_$2};\nMove Line (Up | Down) 1..20 = {Ctrl+$1_$2};\nAdd 1..20 (Lines = 'Down' | Line = 'Down' | Pages = 'PgDn' | Page = 'PgDn') = {Shift+$2_$1};\nStart Adding 1..20 Lines = {Home}{Shift+Down_$1};\n\n\nSelect between (Delimiters | Brackets | Tags) ={Ctrl+m} {Ctrl+Alt+m};\nDelete between Tags = {Ctrl+m} {Ctrl+Alt+m} {Del};\nDelete Tags = {Ctrl+Alt+F4};\nReplace With (Header | Heading) 1..7 = {Ctrl+Alt+F4} '<h' $2 '>' {End} '<\/h' $2 '>' {Home};\nReplace With (para = 'p') = {Ctrl+Alt+F4} '<' $1 '>' {End} '<\/' $1 '>';\n\n\nDelete Word = {Ctrl+Del};\nDelete 1..20 Words = {Ctrl+Del_$1};\nDelete (Back | Last) Word = {Ctrl+Backspace};\nDelete (Back | Last) 1..20 Words = {Ctrl+Backspace_$2};\nDelete Enda Word = {End} {Ctrl+Backspace};\nKill Word = {Ctrl+Backspace}{Ctrl+Del};\n\n(Delete Line | Dede) = {Ctrl+Shift+k};\nDelete 1..20 Lines = {Ctrl+Shift+k_$1};\n(Cut = 'x' | Paste = 'v' | Copy = 'c') That = {Ctrl+$1};\n\nComment (That | Line) = {Ctrl+\/};\nComment 1..20 Lines = {Home} {Shift+Down_$1} {Ctrl+\/};\n\nReplace = {Ctrl+f};\nReplace All = {Ctrl+Enter};\n\n(Join = 'j' | Indent = ']' | Dedent = '[') That = {Ctrl+$1};\n\n\n# --- Commands to create code\/tags -------------------------------------------\n# NOTE: basic HTML commands are stored in my global Vocala commands\n\nStart (\t# HTML commands\n\t'HTML page' = 'html' | pre = \"pre\" | 'Comment' = 'comment-html'\n\t| div = 'div' \n\n\t# D3 Recipe commands\n\t| 'Recipe Page' = 'recipe-page' | 'Recipe Row' = 'recipe-row' \n\t| 'Recipe Toy' = 'recipe-toy' | Toy = 'recipe-toy'\n\t| 'Bold ID'\n\n\t# D3 and JavaScript commands\n\t| Console = 'console' | Log = 'console'\n\t| Var = 'variable' | Variable = 'variable'\n\t# Coffeescript commands\n\t| Snippet = 'my-snippet' \n\t| 'Fix Line' = 'fix-current-line' | 'Fix Current Line' = 'fix-current-line'\n) = $1 {Tab};\n\nStop (\t#HTML commands\n\t'div comment' = 'comment-div-end' | Comment = 'comment-html-end' \n) = $1 {Tab};\n\n# HTML commands\nDot HTML = '.html';\nStart (Header | Heading) 1..7 = h $2 {Tab};\nAdd (Header | Heading) 1..7 = '<h' $2 '>' {End} '<\/h' $2 '>';\nAdd (para = 'p') = '<' $1 '>' {End} '<\/' $1 '>';\n\n# D3 Recipe commands\nPre-Format Code = {Ctrl+Alt+F5};\nReload Atom = {Ctrl+s} Wait(100) {Shift+Ctrl+Alt+F5};\nCommand Palette = {Ctrl+Shift+p};\nKeyboard Shortcuts = {Ctrl+.};\nRun Specs = {Ctrl+Alt+p};\nShow Console = {Ctrl+Alt+i};\n\n\n\n# D3 commands\nPaste Function = 'function ' {Ctrl+v} ' {' {Enter} {Enter} '};' {Up};\n\n# Coffeescript commands\n\n# Python commands\n\n\n# --- D3 commands -------------------------------------------\n\n\n# --- Python commands -------------------------------------------\n\n\n# --- Coffeescript commands -------------------------------------------","old_contents":"# Voice commands for atom\n\nTest Command = \"This Is a Test Command\";\n\ninclude folders.vch;\ninclude letters.vch;\n\n# Commands for developing D3: D3 visualizations, D3 Sandwiches\nSave and Reload = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Ctrl+r};\t\nSave and Really Reload = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Ctrl+Shift+r};\nSave and Run = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Up}{Enter};\n\n# File commands\nFind (File | Document) = {Ctrl+t};\nSave As = {Ctrl+Shift+s};\nNext Window = {Ctrl+Tab};\nLast Window = {Ctrl+Shift+Tab};\nLatest File = {Ctrl+Shift+t};\n(Tree View | List Files) = {Alt+o};\t# NOTE: to make this work, I had to create a new keyboard shortcut in Atom (my personal keymap.cson)\n\n\n# --- Text navigation commands ------------------------------------\n<delimiters> := (Quote = '\"' | 'Double Quote' = '\"' | 'Single Quote' = \"'\" | Comma = ',' | 'Equal Sign' = '=' | Equals = '=' \n\t| Period = '.' | Colon = ':' | 'Semi-Colon' = ';' | Hyphen = '-' | Underscore = '_' | Slash = '\/'\n\t| Paren = \"(\" | \"Close Paren\" = \")\" | Parentheses = \"(\" | \"Open Parenthesis\" = \"(\" | \"Close Parentheses\" = \")\"\n\t| Bracket = '[' | \"Close Bracket\" = ']' | Brace = '{' | 'Close Brace' = '}'\t);\n\nLine 1..200 = {Ctrl+g} $1 {Enter};\n(Left = 'b' | Right = 'f') Word = {Alt+$1};\nTop = {Ctrl+Home};\nBottom = {Ctrl+End};\n(Find = 'Right' | 'Insert After' = 'Right' | 'Insert Before' = 'Left') (Next = 'Enter' | Last = 'Shift+F3') <delimiters> \n\t\t= {Ctrl+f} $3 {$2} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') <delimiters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') 1..20 <delimiters> = {Ctrl+f} $3 {Enter} {Esc} Wait(100) {F3_$2} {Shift+F3} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') Enda <delimiters> = {End} {Ctrl+f} $2 {Enter} {Esc} {Shift+F3} Wait(100) {$1};\n\nFine Alpha <letters> = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Left};\nInsert (Before = 'Left' | After = 'Right') Alpha <letters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nFine Number 0..9 = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Right};\n(Find | Insert) Again = {F3} {Right};\n(Find | Insert) Again 1..20 Times = {F3_$1} {Right};\n\n(Set | Add | Clear | Hide | Delete) Bookmark = {Ctrl+Alt+F2};\n(Next = 'F2' | Last = 'Shift+F2') Bookmark = {$1};\n\n\n# --- Editing commands ----------------------------------------\nSelect Line = {Ctrl+l};\nSelect (Next = 'Down' | Forward = 'Down' | Last = 'Up' | Back = 'Up' | Previous = 'Up') 1..20 Lines = {Home} {Shift+$1_$2};\nMove Line (Up | Down) 1..20 = {Ctrl+$1_$2};\nAdd 1..20 (Lines = 'Down' | Line = 'Down' | Pages = 'PgDn' | Page = 'PgDn') = {Shift+$2_$1};\nStart Adding 1..20 Lines = {Home}{Shift+Down_$1};\n\n\nSelect between (Delimiters | Brackets | Tags) ={Ctrl+m} {Ctrl+Alt+m};\nDelete between Tags = {Ctrl+m} {Ctrl+Alt+m} {Del};\nDelete Tags = {Ctrl+Alt+F4};\nReplace With (Header | Heading) 1..7 = {Ctrl+Alt+F4} '<h' $2 '>' {End} '<\/h' $2 '>' {Home};\nReplace With (para = 'p') = {Ctrl+Alt+F4} '<' $1 '>' {End} '<\/' $1 '>';\n\n\nDelete Word = {Ctrl+Del};\nDelete 1..20 Words = {Ctrl+Del_$1};\nDelete (Back | Last) Word = {Ctrl+Backspace};\nDelete (Back | Last) 1..20 Words = {Ctrl+Backspace_$2};\nDelete Enda Word = {End} {Ctrl+Backspace};\nKill Word = {Ctrl+Backspace}{Ctrl+Del};\n\n(Delete Line | Dede) = {Ctrl+Shift+k};\nDelete 1..20 Lines = {Ctrl+Shift+k_$1};\n(Cut = 'x' | Paste = 'v' | Copy = 'c') That = {Ctrl+$1};\n\nComment (That | Line) = {Ctrl+\/};\nComment 1..20 Lines = {Home} {Shift+Down_$1} {Ctrl+\/};\n\nReplace = {Ctrl+f};\nReplace All = {Ctrl+Enter};\n\n(Join = 'j' | Indent = ']' | Dedent = '[') That = {Ctrl+$1};\n\n\n# --- Commands to create code\/tags -------------------------------------------\n# NOTE: basic HTML commands are stored in my global Vocala commands\n\nStart (\t# HTML commands\n\t'HTML page' = 'html' | pre = \"pre\" | 'Comment' = 'comment-html'\n\t| div = 'div' \n\n\t# D3 Recipe commands\n\t| 'Recipe Page' = 'recipe-page' | 'Recipe Row' = 'recipe-row' \n\t| 'Recipe Toy' = 'recipe-toy' | Toy = 'recipe-toy'\n\t| 'Bold ID'\n\n\t# D3 and JavaScript commands\n\t| Console = 'console' | Log = 'console'\n\t| Var = 'variable' | Variable = 'variable'\n\t# Coffeescript commands\n\t| Snippet = 'my-snippet' \n\t| 'Fix Line' = 'fix-current-line' | 'Fix Current Line' = 'fix-current-line'\n) = $1 {Tab};\n\nStop (\t#HTML commands\n\t'div comment' = 'comment-div-end' | Comment = 'comment-html-end' \n) = $1 {Tab};\n\n# HTML commands\nDot HTML = '.html';\nStart (Header | Heading) 1..7 = h $2 {Tab};\nAdd (Header | Heading) 1..7 = '<h' $2 '>' {End} '<\/h' $2 '>';\nAdd (para = 'p') = '<' $1 '>' {End} '<\/' $1 '>';\n\n# D3 Recipe commands\nPre-Format Code = {Ctrl+Alt+F5};\nReload Atom = {Ctrl+s} Wait(100) {Shift+Ctrl+Alt+F5};\nCommand Palette = {Ctrl+Shift+p};\nKeyboard Shortcuts = {Ctrl+.};\nRun Specs = {Ctrl+Alt+p};\nShow Console = {Ctrl+Alt+i};\n\n\n\n# D3 commands\nPaste Function = 'function ' {Ctrl+v} ' {' {Enter} {Enter} '};' {Up};\n\n# Coffeescript commands\n\n# Python commands\n\n\n# --- D3 commands -------------------------------------------\n\n\n# --- Python commands -------------------------------------------\n\n\n# --- Coffeescript commands -------------------------------------------","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"22cdd06ba05cfb41bbbfee5adf458bb6d4bb5ca9","subject":"Only cache error 500 on assets for 10 seconds instead of the long-lived ttl","message":"Only cache error 500 on assets for 10 seconds instead of the long-lived ttl\n","repos":"amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon","old_file":"images\/varnish-drupal\/drupal.vcl","new_file":"images\/varnish-drupal\/drupal.vcl","new_contents":"vcl 4.0;\n\nimport std;\n\n# set backend default\nbackend default {\n .host = \"${VARNISH_HOST:-nginx}\";\n .port = \"8080\";\n .first_byte_timeout = 35m;\n .between_bytes_timeout = 10m;\n}\n\n# Allow purging from localhost\n# @TODO allow from openshift network\nacl purge {\n \"127.0.0.1\";\n}\n\n# This configuration is optimized for Drupal hosting:\n# Respond to incoming requests.\nsub vcl_recv {\n if (req.url ~ \"^\/varnish_status$\") {\n return (synth(200,\"OK\"));\n }\n # set the backend, which should be used:\n set req.backend_hint = default;\n\n # Always set the forward ip.\n if (req.restarts == 0) {\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n # SA-CORE-2014-004 preventing access to \/xmlrpc.php\n if (req.url ~ \"^\/xmlrpc.php$\") {\n return (synth(701, \"Unauthorized\"));\n }\n\n # Strip out Google Analytics campaign variables. They are only needed\n # by the javascript running on the page\n # utm_source, utm_medium, utm_campaign, gclid\n if(req.url ~ \"(\\?|&)(gclid|utm_[a-z]+)=\") {\n set req.url = regsuball(req.url, \"(gclid|utm_[a-z]+)=[^\\&]+&?\", \"\");\n set req.url = regsub(req.url, \"(\\?|&)$\", \"\");\n }\n\n # We set a header to let a Varnish Chain know that it already has been varnishcached\n set req.http.X-LAGOON-VARNISH = \"d3659c5e113e.amazee.io\";\n\n # Bypass a cache hit\n if (req.method == \"REFRESH\") {\n if (!client.ip ~ purge) { return (synth(405, \"Not allowed\")); }\n set req.method = \"GET\";\n set req.hash_always_miss = true;\n }\n\n # Non-RFC2616 or CONNECT which is weird, we pipe that\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n return (pipe);\n }\n\n # We only try to cache GET and HEAD, other things are passed\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n # Any requests with Basic Auth are passed\n if (req.http.Authorization || req.http.Authenticate)\n {\n return (pass);\n }\n\n ## Pass requests which are from blackfire\n if (req.http.X-Blackfire-Query) {\n return (pass);\n }\n\n # Some URLs should never be cached\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/admin([\/?]|$).*$\" ||\n req.url ~ \"^\/info([\/?]|$).*$\" ||\n req.url ~ \"^\/flag([\/?]|$).*$\" ||\n req.url ~ \"^.*\/system\/files([\/?]|$).*$\" ||\n req.url ~ \"^\/amazeeadmin\" ||\n req.url ~ \"^\/lithium\" ||\n req.url ~ \"^\/cgi\" ||\n req.url ~ \"^\/cgi-bin\"\n ) {\n return (pass);\n }\n\n # Plupload likes to get piped\n if (req.url ~ \"^.*\/plupload-handle-uploads.*$\"\n ) {\n return (pipe);\n }\n\n # Handle compression correctly. Different browsers send different\n # \"Accept-Encoding\" headers, even though they mostly all support the same\n # compression mechanisms. By consolidating these compression headers into\n # a consistent format, we can reduce the size of the cache and get more hits.=\n # @see: http:\/\/ varnish.projects.linpro.no\/wiki\/FAQ\/Compression\n if (req.http.Accept-Encoding) {\n if (req.http.Accept-Encoding ~ \"gzip\") {\n # If the browser supports it, we'll use gzip.\n set req.http.Accept-Encoding = \"gzip\";\n }\n else if (req.http.Accept-Encoding ~ \"deflate\") {\n # Next, try deflate if it is supported.\n set req.http.Accept-Encoding = \"deflate\";\n }\n else {\n # Unknown algorithm. Remove it and send unencoded.\n unset req.http.Accept-Encoding;\n }\n }\n\n # Always cache the following file types for all users.\n if (req.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n unset req.http.Cookie;\n }\n\n # Remove all cookies that Drupal doesn't need to know about. ANY remaining\n # cookie will cause the request to pass-through to a backend. For the most part\n # we always set the NO_CACHE cookie after any POST request, disabling the\n # Varnish cache temporarily. The session cookie allows all authenticated users\n # to pass through as long as they're logged in.\n #\n # 1. Append a semi-colon to the front of the cookie string.\n # 2. Remove all spaces that appear after semi-colons.\n # 3. Match the cookies we want to keep, adding the space we removed\n # previously, back. (\\1) is first matching group in the regsuball.\n # 4. Remove all other cookies, identifying them by the fact that they have\n # no space after the preceding semi-colon.\n # 5. Remove all spaces and semi-colons from the beginning and end of the\n # cookie string.\n if (req.http.Cookie) {\n set req.http.CookieCheck = \";\" + req.http.Cookie;\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"; +\", \";\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";(SESS[a-z0-9]+|SSESS[a-z0-9]+|NO_CACHE)=\", \"; \\1=\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";[^ ][^;]*\", \"\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"^[; ]+|[; ]+$\", \"\");\n\n set req.http.Cookie = req.http.Cookie + \";\";\n\n if (req.http.CookieCheck == \"\") {\n # If there are no remaining cookies, remove the cookie header. If there\n # aren't any cookie headers, Varnish's default behavior will be to cache\n # the page.\n\n unset req.http.CookieCheck;\n unset req.http.Cookie;\n }\n else {\n # If there is any cookies left (a session or NO_CACHE cookie), do not\n # cache the page. Pass it on to Apache directly.\n unset req.http.CookieCheck;\n return (pass);\n }\n }\n\n # Cacheable, lookup in cache.\n return (hash);\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n # normal hit\n return (deliver);\n }\n # We have no fresh fish. Lets look at the stale ones.\n if (std.healthy(req.backend_hint)) {\n # Backend is healthy. If the object is not older then 30secs, deliver it to the client\n # and automatically create a separate backend request to warm the cache for this request.\n if (obj.ttl + 30s > 0s) {\n set req.http.grace = \"normal(limited)\";\n return (deliver);\n } else {\n # No candidate for grace. Fetch a fresh object.\n return(miss);\n }\n } else {\n # backend is sick - use full grace\n if (obj.ttl + obj.grace > 0s) {\n set req.http.grace = \"full\";\n return (deliver);\n } else {\n # no graced object.\n return (miss);\n }\n }\n}\n\nsub vcl_backend_response {\n # Temporarily disable streaming on files to be tested and removed after Varnish 4.1.x upgrade\n set beresp.do_stream = false;\n\n # Allow items to be stale if needed.\n set beresp.grace = 6h;\n\n ## FIXME: rename X-LAGOON-VARNISH-BYPASS to X-LAGOON-VARNISH-BACKEND-BYPASS to avoid confusion\n # If the backend sends a X-LAGOON-VARNISH-BYPASS header we directly deliver\n if(beresp.http.X-LAGOON-VARNISH-BYPASS == \"TRUE\") {\n return (deliver);\n }\n\n # Cache 404 and 403 for 10 seconds\n if(beresp.status == 404 || beresp.status == 403) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n # Don't allow static files to set cookies.\n if (bereq.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n # beresp == Back-end response from the web server.\n unset beresp.http.set-cookie;\n unset beresp.http.Cache-Control;\n set beresp.ttl = 2628001s;\n set beresp.http.Cache-Control = \"public, max-age=2628001\";\n set beresp.http.Expires = \"\" + (now + beresp.ttl);\n \n # If an asset would come back with statuscode 500 we only cache it for 10 seconds instead of the usual static file cache\n if(beresp.status == 500) {\n set beresp.ttl = 10s;\n }\n }\n\n return (deliver);\n}\n\n# Set a header to track a cache HIT\/MISS.\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Varnish-Cache = \"HIT\";\n }\n else {\n set resp.http.X-Varnish-Cache = \"MISS\";\n }\n unset resp.http.X-Generator;\n unset resp.http.Server;\n # Inject information about grace\n if (req.http.grace) {\n set resp.http.X-Varnish-Grace = req.http.grace;\n }\n set resp.http.X-LAGOON = \"varnish>\" + resp.http.X-LAGOON;\n return (deliver);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n if (req.http.X-Forwarded-Proto) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n if (req.http.HTTPS) {\n hash_data(req.http.HTTPS);\n }\n return (lookup);\n}\n\nsub vcl_synth {\n if (resp.status == 701) {\n set resp.status = 401;\n set resp.http.Content-Type = \"text\/plain; charset=utf-8\";\n synthetic({\"XMLRPC Interface is blocked due to SA-CORE-2014-004 - mail support@amazee.io if you need it.\"});\n return (deliver);\n }\n if (resp.status == 700) {\n # Set a status the client will understand\n set resp.status = 200;\n # Create our synthetic response\n synthetic(\"\");\n return(deliver);\n}\n return (deliver);\n}\n\nsub vcl_backend_error {\n # Restart the request, when we have a backend server error, to try another backend.\n # Restart max twice.\n if (bereq.retries < 2) {\n return(retry);\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<head>\n <title>Server Error<\/title>\n <style type=\"text\/css\">\n body {\n font-family: helvetica, arial, sans-serif;\n }\n img {\n margin-top: 50px;\n }\n p {\n width: 6 00px;\n margin-top: 10px\n }\n div {\n background: #ccc;\n width: 600px;\n margin: auto;\n padding: 50px;\n }\n span {\n color: #ccc\n }\n <\/style>\n<\/head>\n<body>\n <div>\n <h1>We are sorry...<\/h1>\n <p>We encountered a server-side error. This means that the problem is not with your computer or Internet connection, but rather with the website's server.<\/p>\n <p>We are currently working on solving this problem and apologise for the inconvenience.<\/p>\n <span>\n <strong>Technical Information<\/strong><br \/>\n Error \"} + beresp.status + \" \" + beresp.reason + {\"<br \/>\n XID: \"} + bereq.xid + {\"<br \/>\n <\/span>\n <\/div>\n<\/body>\n<\/html>\n\n\"} );\n return (deliver);\n}\n","old_contents":"vcl 4.0;\n\nimport std;\n\n# set backend default\nbackend default {\n .host = \"${VARNISH_HOST:-nginx}\";\n .port = \"8080\";\n .first_byte_timeout = 35m;\n .between_bytes_timeout = 10m;\n}\n\n# Allow purging from localhost\n# @TODO allow from openshift network\nacl purge {\n \"127.0.0.1\";\n}\n\n# This configuration is optimized for Drupal hosting:\n# Respond to incoming requests.\nsub vcl_recv {\n if (req.url ~ \"^\/varnish_status$\") {\n return (synth(200,\"OK\"));\n }\n # set the backend, which should be used:\n set req.backend_hint = default;\n\n # Always set the forward ip.\n if (req.restarts == 0) {\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n # SA-CORE-2014-004 preventing access to \/xmlrpc.php\n if (req.url ~ \"^\/xmlrpc.php$\") {\n return (synth(701, \"Unauthorized\"));\n }\n\n # Strip out Google Analytics campaign variables. They are only needed\n # by the javascript running on the page\n # utm_source, utm_medium, utm_campaign, gclid\n if(req.url ~ \"(\\?|&)(gclid|utm_[a-z]+)=\") {\n set req.url = regsuball(req.url, \"(gclid|utm_[a-z]+)=[^\\&]+&?\", \"\");\n set req.url = regsub(req.url, \"(\\?|&)$\", \"\");\n }\n\n # We set a header to let a Varnish Chain know that it already has been varnishcached\n set req.http.X-LAGOON-VARNISH = \"d3659c5e113e.amazee.io\";\n\n # Bypass a cache hit\n if (req.method == \"REFRESH\") {\n if (!client.ip ~ purge) { return (synth(405, \"Not allowed\")); }\n set req.method = \"GET\";\n set req.hash_always_miss = true;\n }\n\n # Non-RFC2616 or CONNECT which is weird, we pipe that\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n return (pipe);\n }\n\n # We only try to cache GET and HEAD, other things are passed\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n # Any requests with Basic Auth are passed\n if (req.http.Authorization || req.http.Authenticate)\n {\n return (pass);\n }\n\n ## Pass requests which are from blackfire\n if (req.http.X-Blackfire-Query) {\n return (pass);\n }\n\n # Some URLs should never be cached\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/admin([\/?]|$).*$\" ||\n req.url ~ \"^\/info([\/?]|$).*$\" ||\n req.url ~ \"^\/flag([\/?]|$).*$\" ||\n req.url ~ \"^.*\/system\/files([\/?]|$).*$\" ||\n req.url ~ \"^\/amazeeadmin\" ||\n req.url ~ \"^\/lithium\" ||\n req.url ~ \"^\/cgi\" ||\n req.url ~ \"^\/cgi-bin\"\n ) {\n return (pass);\n }\n\n # Plupload likes to get piped\n if (req.url ~ \"^.*\/plupload-handle-uploads.*$\"\n ) {\n return (pipe);\n }\n\n # Handle compression correctly. Different browsers send different\n # \"Accept-Encoding\" headers, even though they mostly all support the same\n # compression mechanisms. By consolidating these compression headers into\n # a consistent format, we can reduce the size of the cache and get more hits.=\n # @see: http:\/\/ varnish.projects.linpro.no\/wiki\/FAQ\/Compression\n if (req.http.Accept-Encoding) {\n if (req.http.Accept-Encoding ~ \"gzip\") {\n # If the browser supports it, we'll use gzip.\n set req.http.Accept-Encoding = \"gzip\";\n }\n else if (req.http.Accept-Encoding ~ \"deflate\") {\n # Next, try deflate if it is supported.\n set req.http.Accept-Encoding = \"deflate\";\n }\n else {\n # Unknown algorithm. Remove it and send unencoded.\n unset req.http.Accept-Encoding;\n }\n }\n\n # Always cache the following file types for all users.\n if (req.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n unset req.http.Cookie;\n }\n\n # Remove all cookies that Drupal doesn't need to know about. ANY remaining\n # cookie will cause the request to pass-through to a backend. For the most part\n # we always set the NO_CACHE cookie after any POST request, disabling the\n # Varnish cache temporarily. The session cookie allows all authenticated users\n # to pass through as long as they're logged in.\n #\n # 1. Append a semi-colon to the front of the cookie string.\n # 2. Remove all spaces that appear after semi-colons.\n # 3. Match the cookies we want to keep, adding the space we removed\n # previously, back. (\\1) is first matching group in the regsuball.\n # 4. Remove all other cookies, identifying them by the fact that they have\n # no space after the preceding semi-colon.\n # 5. Remove all spaces and semi-colons from the beginning and end of the\n # cookie string.\n if (req.http.Cookie) {\n set req.http.CookieCheck = \";\" + req.http.Cookie;\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"; +\", \";\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";(SESS[a-z0-9]+|SSESS[a-z0-9]+|NO_CACHE)=\", \"; \\1=\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";[^ ][^;]*\", \"\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"^[; ]+|[; ]+$\", \"\");\n\n set req.http.Cookie = req.http.Cookie + \";\";\n\n if (req.http.CookieCheck == \"\") {\n # If there are no remaining cookies, remove the cookie header. If there\n # aren't any cookie headers, Varnish's default behavior will be to cache\n # the page.\n\n unset req.http.CookieCheck;\n unset req.http.Cookie;\n }\n else {\n # If there is any cookies left (a session or NO_CACHE cookie), do not\n # cache the page. Pass it on to Apache directly.\n unset req.http.CookieCheck;\n return (pass);\n }\n }\n\n # Cacheable, lookup in cache.\n return (hash);\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n # normal hit\n return (deliver);\n }\n # We have no fresh fish. Lets look at the stale ones.\n if (std.healthy(req.backend_hint)) {\n # Backend is healthy. If the object is not older then 30secs, deliver it to the client\n # and automatically create a separate backend request to warm the cache for this request.\n if (obj.ttl + 30s > 0s) {\n set req.http.grace = \"normal(limited)\";\n return (deliver);\n } else {\n # No candidate for grace. Fetch a fresh object.\n return(miss);\n }\n } else {\n # backend is sick - use full grace\n if (obj.ttl + obj.grace > 0s) {\n set req.http.grace = \"full\";\n return (deliver);\n } else {\n # no graced object.\n return (miss);\n }\n }\n}\n\nsub vcl_backend_response {\n # Temporarily disable streaming on files to be tested and removed after Varnish 4.1.x upgrade\n set beresp.do_stream = false;\n\n # Allow items to be stale if needed.\n set beresp.grace = 6h;\n\n ## FIXME: rename X-LAGOON-VARNISH-BYPASS to X-LAGOON-VARNISH-BACKEND-BYPASS to avoid confusion\n # If the backend sends a X-LAGOON-VARNISH-BYPASS header we directly deliver\n if(beresp.http.X-LAGOON-VARNISH-BYPASS == \"TRUE\") {\n return (deliver);\n }\n\n # Cache 404 and 403 for 10 seconds\n if(beresp.status == 404 || beresp.status == 403) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n # Don't allow static files to set cookies.\n if (bereq.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n # beresp == Back-end response from the web server.\n unset beresp.http.set-cookie;\n unset beresp.http.Cache-Control;\n set beresp.ttl = 2628001s;\n set beresp.http.Cache-Control = \"public, max-age=2628001\";\n set beresp.http.Expires = \"\" + (now + beresp.ttl);\n }\n\n return (deliver);\n}\n\n# Set a header to track a cache HIT\/MISS.\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Varnish-Cache = \"HIT\";\n }\n else {\n set resp.http.X-Varnish-Cache = \"MISS\";\n }\n unset resp.http.X-Generator;\n unset resp.http.Server;\n # Inject information about grace\n if (req.http.grace) {\n set resp.http.X-Varnish-Grace = req.http.grace;\n }\n set resp.http.X-LAGOON = \"varnish>\" + resp.http.X-LAGOON;\n return (deliver);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n if (req.http.X-Forwarded-Proto) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n if (req.http.HTTPS) {\n hash_data(req.http.HTTPS);\n }\n return (lookup);\n}\n\nsub vcl_synth {\n if (resp.status == 701) {\n set resp.status = 401;\n set resp.http.Content-Type = \"text\/plain; charset=utf-8\";\n synthetic({\"XMLRPC Interface is blocked due to SA-CORE-2014-004 - mail support@amazee.io if you need it.\"});\n return (deliver);\n }\n if (resp.status == 700) {\n # Set a status the client will understand\n set resp.status = 200;\n # Create our synthetic response\n synthetic(\"\");\n return(deliver);\n}\n return (deliver);\n}\n\nsub vcl_backend_error {\n # Restart the request, when we have a backend server error, to try another backend.\n # Restart max twice.\n if (bereq.retries < 2) {\n return(retry);\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<head>\n <title>Server Error<\/title>\n <style type=\"text\/css\">\n body {\n font-family: helvetica, arial, sans-serif;\n }\n img {\n margin-top: 50px;\n }\n p {\n width: 6 00px;\n margin-top: 10px\n }\n div {\n background: #ccc;\n width: 600px;\n margin: auto;\n padding: 50px;\n }\n span {\n color: #ccc\n }\n <\/style>\n<\/head>\n<body>\n <div>\n <h1>We are sorry...<\/h1>\n <p>We encountered a server-side error. This means that the problem is not with your computer or Internet connection, but rather with the website's server.<\/p>\n <p>We are currently working on solving this problem and apologise for the inconvenience.<\/p>\n <span>\n <strong>Technical Information<\/strong><br \/>\n Error \"} + beresp.status + \" \" + beresp.reason + {\"<br \/>\n XID: \"} + bereq.xid + {\"<br \/>\n <\/span>\n <\/div>\n<\/body>\n<\/html>\n\n\"} );\n return (deliver);\n}\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"1ece93e7a94b180185a2aa2eed1c33819c75e172","subject":"Fixed syntax error, moved cookie unset outside of blacklist check.","message":"Fixed syntax error, moved cookie unset outside of blacklist check.\n","repos":"killerwails\/ansible-varnish,colstrom\/ansible-varnish,noqcks\/ansible-varnish,gotofbi\/ansible-varnish,kkwoker\/ansible-varnish,telusdigital\/ansible-varnish,killerwails\/ansible-varnish,gotofbi\/ansible-varnish","old_file":"templates\/etc\/varnish\/default.vcl","new_file":"templates\/etc\/varnish\/default.vcl","new_contents":"vcl 4.0;\n\nimport directors;\nimport std;\n\n###\n# Varnish Documentation\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-built-in-subs.html\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/reference\/vcl.html\n##\n\n{% for backend in varnish_backend_hosts %}\nbackend application_{{ loop.index }} {\n .host = \"{{ backend }}\";\n .port = \"{{ varnish_backend_port }}\";\n{% if varnish_health_checks_enabled %}\n .probe = {\n .url = \"{{ varnish_health_check_url }}\";\n .interval = {{ varnish_health_check_interval }};\n .timeout = {{ varnish_health_check_timeout }};\n .window = {{ varnish_health_check_window }};\n .threshold = {{ varnish_health_check_threshold }};\n }\n{% endif %}\n}\n{% endfor %}\n\n###\n# vcl_init\n# Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n###\n# The vcl_init subroutine may terminate with calling return() with one of the following keywords:\n#\n# ok\n# Normal return, VCL continues loading.\n##\n\nsub vcl_init {\n new application = directors.round_robin();\n{% for backend in varnish_backend_hosts %}\n application.add_backend(application_{{ loop.index }});\n{% endfor %}\n}\n\n###\n# vcl_recv\n# Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use. \n# It is also used to modify the request\n###\n# The vcl_recv subroutine may terminate with calling return() on one of the following keywords:\n#\n# synth(status code, reason)\n# Return a synthetic object with the specified status code to the client and abandon the request.\n# pass\n# Switch to pass mode. Control will eventually pass to vcl_pass.\n# pipe\n# Switch to pipe mode. Control will eventually pass to vcl_pipe.\n# hash\n# Continue processing the object as a potential candidate for caching. Passes the control over to vcl_hash.\n# purge\n# Purge the object and it's variants. Control passes through vcl_hash to vcl_purge.\n#\n\nsub vcl_recv {\n{% if varnish_blacklist_enabled %}\n if (!(req.url ~ \"{{ varnish_blacklist_regexp }}\")) {\n return(pass);\n } else {\n{% if varnish_discards_client_cookies %}\n unset req.http.Cookie;\n{% endif %}\n }\n{% endif %}\n\n set req.backend_hint = application.backend();\n}\n\n###\n# vcl_hit\n# Called when a cache lookup is successful.\n###\n# The vcl_hit subroutine may terminate with calling return() with one of the following keywords:\n#\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n# deliver\n# Deliver the object. Control passes to vcl_deliver.\n# synth(status code, reason)\n# Return the specified status code to the client and abandon the request.\n###\n\nsub vcl_hit {\n if (obj.ttl > 0s) {\n return (deliver);\n }\n{% if varnish_health_checks_enabled %}\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (fetch);\n }\n{% else %}\n if (obj.ttl + obj.grace > 0s) {\n return (deliver);\n }\n\n return (fetch);\n{% endif %}\n}\n\n###\n# vcl_backend_response\n# Called after the response headers has been successfully retrieved from the backend.\n###\n# The vcl_backend_response subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Possibly insert the object into the cache, then deliver it to the Control will eventually pass to vcl_deliver.\n# abandon\n# Abandon the backend request and generates an error.\n# retry\n# Retry the backend transaction. Increases the retries counter. If the number of retries is higher than max_retries Varnish emits a guru meditation error.\n###\n\nsub vcl_backend_response {\n{% if varnish_cache_diagnostics_enabled %}\n if (beresp.ttl <= 0s) {\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (bereq.http.Cookie) {\n set beresp.http.X-Cacheable = \"NO:Cookie in Request\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO:Set-Cookie in Response\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.X-No-Cache) {\n set beresp.http.X-Cacheable = \"NO:X-No-Cache\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n{% endif %}\n\n{% if varnish_blacklist_enabled %}\n if (bereq.url ~ \"{{ varnish_blacklist_regexp }}\") {\n set beresp.http.X-Cacheable = \"NO:Blacklisted\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n }\n{% endif %}\n\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n\n set beresp.grace = {{ varnish_grace_period }};\n}\n\n###\n# vcl_deliver\n# Called before a cached object is delivered to the client.\n###\n# The vcl_deliver subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Deliver the object to the client.\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n###\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n","old_contents":"vcl 4.0;\n\nimport directors;\nimport std;\n\n###\n# Varnish Documentation\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-built-in-subs.html\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/reference\/vcl.html\n##\n\n{% for backend in varnish_backend_hosts %}\nbackend application_{{ loop.index }} {\n .host = \"{{ backend }}\";\n .port = \"{{ varnish_backend_port }}\";\n{% if varnish_health_checks_enabled %}\n .probe = {\n .url = \"{{ varnish_health_check_url }}\";\n .interval = {{ varnish_health_check_interval }};\n .timeout = {{ varnish_health_check_timeout }};\n .window = {{ varnish_health_check_window }};\n .threshold = {{ varnish_health_check_threshold }};\n }\n{% endif %}\n}\n{% endfor %}\n\n###\n# vcl_init\n# Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n###\n# The vcl_init subroutine may terminate with calling return() with one of the following keywords:\n#\n# ok\n# Normal return, VCL continues loading.\n##\n\nsub vcl_init {\n new application = directors.round_robin();\n{% for backend in varnish_backend_hosts %}\n application.add_backend(application_{{ loop.index }});\n{% endfor %}\n}\n\n###\n# vcl_recv\n# Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use. \n# It is also used to modify the request\n###\n# The vcl_recv subroutine may terminate with calling return() on one of the following keywords:\n#\n# synth(status code, reason)\n# Return a synthetic object with the specified status code to the client and abandon the request.\n# pass\n# Switch to pass mode. Control will eventually pass to vcl_pass.\n# pipe\n# Switch to pipe mode. Control will eventually pass to vcl_pipe.\n# hash\n# Continue processing the object as a potential candidate for caching. Passes the control over to vcl_hash.\n# purge\n# Purge the object and it's variants. Control passes through vcl_hash to vcl_purge.\n#\n\nsub vcl_recv {\n{% if varnish_blacklist_enabled %}\n if (!(req.url ~ \"{{ varnish_blacklist_regexp }}\")) {\n{% if varnish_discards_client_cookies %}\n unset req.http.Cookie;\n{% endif %}\n return(pass);\n }\n{% endif %}\n\n set req.backend_hint = application.backend();\n}\n}\n\n###\n# vcl_hit\n# Called when a cache lookup is successful.\n###\n# The vcl_hit subroutine may terminate with calling return() with one of the following keywords:\n#\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n# deliver\n# Deliver the object. Control passes to vcl_deliver.\n# synth(status code, reason)\n# Return the specified status code to the client and abandon the request.\n###\n\nsub vcl_hit {\n if (obj.ttl > 0s) {\n return (deliver);\n }\n{% if varnish_health_checks_enabled %}\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (fetch);\n }\n{% else %}\n if (obj.ttl + obj.grace > 0s) {\n return (deliver);\n }\n\n return (fetch);\n{% endif %}\n}\n\n###\n# vcl_backend_response\n# Called after the response headers has been successfully retrieved from the backend.\n###\n# The vcl_backend_response subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Possibly insert the object into the cache, then deliver it to the Control will eventually pass to vcl_deliver.\n# abandon\n# Abandon the backend request and generates an error.\n# retry\n# Retry the backend transaction. Increases the retries counter. If the number of retries is higher than max_retries Varnish emits a guru meditation error.\n###\n\nsub vcl_backend_response {\n{% if varnish_cache_diagnostics_enabled %}\n if (beresp.ttl <= 0s) {\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (bereq.http.Cookie) {\n set beresp.http.X-Cacheable = \"NO:Cookie in Request\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO:Set-Cookie in Response\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.X-No-Cache) {\n set beresp.http.X-Cacheable = \"NO:X-No-Cache\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n{% endif %}\n\n{% if varnish_blacklist_enabled %}\n if (bereq.url ~ \"{{ varnish_blacklist_regexp }}\") {\n set beresp.http.X-Cacheable = \"NO:Blacklisted\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n }\n{% endif %}\n\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n\n set beresp.grace = {{ varnish_grace_period }};\n}\n\n###\n# vcl_deliver\n# Called before a cached object is delivered to the client.\n###\n# The vcl_deliver subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Deliver the object to the client.\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n###\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"f03dcb20890a72957d4dad50c91185ddc58aa689","subject":"Removed extra GA cookie checks (turned out to be components of __utmz, not cookies themselves)","message":"Removed extra GA cookie checks (turned out to be components of __utmz, not cookies themselves)\n","repos":"evolution\/genesis-wordpress,genesis\/wordpress,evolution\/genesis-wordpress,jalevin\/wordpress,genesis\/wordpress,genesis\/wordpress,evolution\/wordpress,evolution\/genesis-wordpress,jalevin\/wordpress,evolution\/wordpress,evolution\/genesis-wordpress,evolution\/wordpress,evolution\/wordpress,evolution\/wordpress,evolution\/genesis-wordpress,evolution\/genesis-wordpress,jalevin\/wordpress,genesis\/wordpress,jalevin\/wordpress,genesis\/wordpress,genesis\/wordpress,jalevin\/wordpress","old_file":"provisioning\/roles\/varnish\/files\/etc-varnish\/production.vcl","new_file":"provisioning\/roles\/varnish\/files\/etc-varnish\/production.vcl","new_contents":"# Default backend definition. Set this to point to your content server.\n# all paths relative to varnish option vcl_dir\n\ninclude \"custom.backend.vcl\";\ninclude \"custom.acl.vcl\";\n\n# Handle the HTTP request received by the client\nsub vcl_recv {\n # varnish serves stale (but cacheable) objects while retriving object from backend\n if (req.backend.healthy) {\n set req.grace = 30s;\n } else {\n set req.grace = 1h;\n }\n\n # shortcut for DFind requests\n if (req.url ~ \"^\/w00tw00t\") {\n error 404 \"Not Found\";\n }\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n # Normalize the header, remove the port (in case you're testing this on various TCP ports)\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n # Allow purging\n if (req.request == \"PURGE\") {\n if (!client.ip ~ purge) {\n # Not from an allowed IP? Then die with an error.\n error 405 \"This IP is not allowed to send PURGE requests.\";\n }\n\n # If you got this stage (and didn't error out above), do a cache-lookup\n # That will force entry into vcl_hit() or vcl_miss() below and purge the actual cache\n return (lookup);\n }\n\n # Only deal with \"normal\" types\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"PATCH\" &&\n req.request != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n # We only deal with GET and HEAD by default\n return (pass);\n }\n\n # Some generic URL manipulation, useful for all templates that follow\n # First remove the Google Analytics added parameters, useless for our backend\n if (req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=\") {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # Strip hash, server doesn't need it.\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n # Strip a trailing ? if it exists\n if (req.url ~ \"\\?$\") {\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # This is an example to redirect with a 301\/302 HTTP status code from within Varnish\n # if (req.http.Host ~ \"secure.mysite.tld\") {\n # # We may want to force our users from the secure site to the HTTPs version?\n # error 720 \"https:\/\/secure.mysite.tld\";\n # # If you want to keep the URLs intact, this also works:\n # error 720 \"https:\/\/\" + req.http.Host + req.url;\n # }\n #\n # Or to force a 302 temporary redirect, use error 721\n # if (req.http.Host ~ \"temp.mysite.tld\") {\n # # Temporary redirect\n # error 721 \"http:\/\/mysite.tld\/temp\";\n # }\n #\n\n # Some generic cookie manipulation, useful for all templates that follow\n\n # Remove any '_' prefixed cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"_[^=]+=[^;]+(; )?\", \"\");\n\n # Remove a \";\" prefix in the cookie if present\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n\n # Are there cookies left with only spaces or that are empty?\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n\n # Normalize Accept-Encoding header\n # straight from the manual: https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/vary.html\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n # No point in compressing these\n remove req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n # unkown algorithm\n remove req.http.Accept-Encoding;\n }\n }\n\n # Include custom vcl_recv logic\n include \"conf.d\/receive\/wordpress.vcl\";\n\n # Remove all cookies for static files\n # A valid discussion could be held on this line: do you really need to cache static files that don't cause load? Only if you have memory left.\n # Sure, there's disk I\/O, but chances are your OS will already have these files in their buffers (thus memory).\n # Before you blindly enable this, have a read here: http:\/\/mattiasgeniar.be\/2012\/11\/28\/stop-caching-static-files\/\n if (req.url ~ \"^[^?]*\\.(bmp|bz2|css|doc|eot|flv|gif|gz|ico|jpeg|jpg|js|less|mp[34]|pdf|png|rar|rtf|swf|tar|tgz|txt|wav|woff|xml|zip)(\\?.*)?$\") {\n unset req.http.Cookie;\n return (lookup);\n }\n\n # Send Surrogate-Capability headers to announce ESI support to backend\n set req.http.Surrogate-Capability = \"key=ESI\/1.0\";\n\n if (req.http.Authorization || req.http.Cookie) {\n # Not cacheable by default\n return (pass);\n }\n\n return (lookup);\n}\n\nsub vcl_pipe {\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n # set bereq.http.connection = \"close\";\n # here. It is not set by default as it might break some broken web\n # applications, like IIS with NTLM authentication.\n\n #set bereq.http.Connection = \"Close\";\n return (pipe);\n}\n\nsub vcl_pass {\n return (pass);\n}\n\n# The data on which the hashing will take place\nsub vcl_hash {\n hash_data(req.url);\n\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n\n # hash cookies for object with auth\n if (req.http.Cookie) {\n hash_data(req.http.Cookie);\n }\n if (req.http.Authorization) {\n hash_data(req.http.Authorization);\n }\n\n return (hash);\n}\n\nsub vcl_hit {\n # Allow purges\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"purged\";\n }\n\n return (deliver);\n}\n\nsub vcl_miss {\n # Allow purges\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"purged\";\n }\n\n return (fetch);\n}\n\n# Handle the HTTP request coming from our backend\nsub vcl_fetch {\n set beresp.grace = 1h;\n\n # Include custom vcl_fetch logic\n include \"conf.d\/fetch\/wordpress.vcl\";\n\n # Parse ESI request and remove Surrogate-Control header\n if (beresp.http.Surrogate-Control ~ \"ESI\/1.0\") {\n unset beresp.http.Surrogate-Control;\n set beresp.do_esi = true;\n }\n\n # If the request to the backend returns a code is 5xx, restart the loop\n # If the number of restarts reaches the value of the parameter max_restarts,\n # the request will be error'ed. max_restarts defaults to 4. This prevents\n # an eternal loop in the event that, e.g., the object does not exist at all.\n if (beresp.status >= 500 && beresp.status <= 599){\n return(restart);\n }\n\n # Enable cache for all static files\n # The same argument as the static caches from above: monitor your cache size, if you get data nuked out of it, consider giving up the static file cache.\n # Before you blindly enable this, have a read here: http:\/\/mattiasgeniar.be\/2012\/11\/28\/stop-caching-static-files\/\n if (req.url ~ \"^[^?]*\\.(bmp|bz2|css|doc|eot|flv|gif|gz|ico|jpeg|jpg|js|less|mp[34]|pdf|png|rar|rtf|swf|tar|tgz|txt|wav|woff|xml|zip)(\\?.*)?$\") {\n unset beresp.http.set-cookie;\n }\n\n # Sometimes, a 301 or 302 redirect formed via Apache's mod_rewrite can mess with the HTTP port that is being passed along.\n # This often happens with simple rewrite rules in a scenario where Varnish runs on :80 and Apache on :8080 on the same box.\n # A redirect can then often redirect the end-user to a URL on :8080, where it should be :80.\n # This may need finetuning on your setup.\n #\n # To prevent accidental replace, we only filter the 301\/302 redirects for now.\n if (beresp.status == 301 || beresp.status == 302) {\n set beresp.http.Location = regsub(beresp.http.Location, \":[0-9]+\", \"\");\n }\n\n # Don't cache user & server errors\n if (beresp.status >= 400) {\n return (hit_for_pass);\n }\n\n # Non private responses without cookies and with a ttl of 0 should be artificially extended to 1 hour\n if (beresp.ttl <= 0s && beresp.http.Cache-Control !~ \"private\" && (!beresp.http.Set-Cookie)) {\n set beresp.ttl = 1h;\n set beresp.http.X-Cache-Extended = \"1\";\n }\n\n # Set 2min cache if unset for static files\n if (beresp.ttl <= 0s || beresp.http.Set-Cookie || beresp.http.Vary == \"*\") {\n set beresp.ttl = 120s;\n return (hit_for_pass);\n }\n\n return (deliver);\n}\n\n# The routine when we deliver the HTTP request to the user\n# Last chance to modify headers that are sent to the client\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"cached\";\n } else {\n set resp.http.x-Cache = \"uncached\";\n }\n\n # Remove some headers: PHP version\n unset resp.http.X-Powered-By;\n\n # Remove some headers: Apache version & OS\n unset resp.http.Server;\n unset resp.http.X-Drupal-Cache;\n unset resp.http.X-Varnish;\n unset resp.http.Via;\n unset resp.http.Link;\n\n return (deliver);\n}\n\nsub vcl_error {\n if (obj.status == 720) {\n # We use this special error status 720 to force redirects with 301 (permanent) redirects\n # To use this, call the following from anywhere in vcl_recv: error 720 \"http:\/\/host\/new.html\"\n set obj.status = 301;\n set obj.http.Location = obj.response;\n return (deliver);\n } elseif (obj.status == 721) {\n # And we use error status 721 to force redirects with a 302 (temporary) redirect\n # To use this, call the following from anywhere in vcl_recv: error 720 \"http:\/\/host\/new.html\"\n set obj.status = 302;\n set obj.http.Location = obj.response;\n return (deliver);\n }\n\n return (deliver);\n}\n\nsub vcl_init {\n return (ok);\n}\n\nsub vcl_fini {\n return (ok);\n}\n","old_contents":"# Default backend definition. Set this to point to your content server.\n# all paths relative to varnish option vcl_dir\n\ninclude \"custom.backend.vcl\";\ninclude \"custom.acl.vcl\";\n\n# Handle the HTTP request received by the client\nsub vcl_recv {\n # varnish serves stale (but cacheable) objects while retriving object from backend\n if (req.backend.healthy) {\n set req.grace = 30s;\n } else {\n set req.grace = 1h;\n }\n\n # shortcut for DFind requests\n if (req.url ~ \"^\/w00tw00t\") {\n error 404 \"Not Found\";\n }\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n # Normalize the header, remove the port (in case you're testing this on various TCP ports)\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n # Allow purging\n if (req.request == \"PURGE\") {\n if (!client.ip ~ purge) {\n # Not from an allowed IP? Then die with an error.\n error 405 \"This IP is not allowed to send PURGE requests.\";\n }\n\n # If you got this stage (and didn't error out above), do a cache-lookup\n # That will force entry into vcl_hit() or vcl_miss() below and purge the actual cache\n return (lookup);\n }\n\n # Only deal with \"normal\" types\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"PATCH\" &&\n req.request != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n # We only deal with GET and HEAD by default\n return (pass);\n }\n\n # Some generic URL manipulation, useful for all templates that follow\n # First remove the Google Analytics added parameters, useless for our backend\n if (req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=\") {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # Strip hash, server doesn't need it.\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n # Strip a trailing ? if it exists\n if (req.url ~ \"\\?$\") {\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # This is an example to redirect with a 301\/302 HTTP status code from within Varnish\n # if (req.http.Host ~ \"secure.mysite.tld\") {\n # # We may want to force our users from the secure site to the HTTPs version?\n # error 720 \"https:\/\/secure.mysite.tld\";\n # # If you want to keep the URLs intact, this also works:\n # error 720 \"https:\/\/\" + req.http.Host + req.url;\n # }\n #\n # Or to force a 302 temporary redirect, use error 721\n # if (req.http.Host ~ \"temp.mysite.tld\") {\n # # Temporary redirect\n # error 721 \"http:\/\/mysite.tld\/temp\";\n # }\n #\n\n # Some generic cookie manipulation, useful for all templates that follow\n\n # Remove any '_' prefixed cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"_[^=]+=[^;]+(; )?\", \"\");\n\n # Remove any Google Analytics based cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmctr=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmcmd.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmccn.=[^;]+(; )?\", \"\");\n\n # Remove a \";\" prefix in the cookie if present\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n\n # Are there cookies left with only spaces or that are empty?\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n\n # Normalize Accept-Encoding header\n # straight from the manual: https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/vary.html\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n # No point in compressing these\n remove req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n # unkown algorithm\n remove req.http.Accept-Encoding;\n }\n }\n\n # Include custom vcl_recv logic\n include \"conf.d\/receive\/wordpress.vcl\";\n\n # Remove all cookies for static files\n # A valid discussion could be held on this line: do you really need to cache static files that don't cause load? Only if you have memory left.\n # Sure, there's disk I\/O, but chances are your OS will already have these files in their buffers (thus memory).\n # Before you blindly enable this, have a read here: http:\/\/mattiasgeniar.be\/2012\/11\/28\/stop-caching-static-files\/\n if (req.url ~ \"^[^?]*\\.(bmp|bz2|css|doc|eot|flv|gif|gz|ico|jpeg|jpg|js|less|mp[34]|pdf|png|rar|rtf|swf|tar|tgz|txt|wav|woff|xml|zip)(\\?.*)?$\") {\n unset req.http.Cookie;\n return (lookup);\n }\n\n # Send Surrogate-Capability headers to announce ESI support to backend\n set req.http.Surrogate-Capability = \"key=ESI\/1.0\";\n\n if (req.http.Authorization || req.http.Cookie) {\n # Not cacheable by default\n return (pass);\n }\n\n return (lookup);\n}\n\nsub vcl_pipe {\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n # set bereq.http.connection = \"close\";\n # here. It is not set by default as it might break some broken web\n # applications, like IIS with NTLM authentication.\n\n #set bereq.http.Connection = \"Close\";\n return (pipe);\n}\n\nsub vcl_pass {\n return (pass);\n}\n\n# The data on which the hashing will take place\nsub vcl_hash {\n hash_data(req.url);\n\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n\n # hash cookies for object with auth\n if (req.http.Cookie) {\n hash_data(req.http.Cookie);\n }\n if (req.http.Authorization) {\n hash_data(req.http.Authorization);\n }\n\n return (hash);\n}\n\nsub vcl_hit {\n # Allow purges\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"purged\";\n }\n\n return (deliver);\n}\n\nsub vcl_miss {\n # Allow purges\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"purged\";\n }\n\n return (fetch);\n}\n\n# Handle the HTTP request coming from our backend\nsub vcl_fetch {\n set beresp.grace = 1h;\n\n # Include custom vcl_fetch logic\n include \"conf.d\/fetch\/wordpress.vcl\";\n\n # Parse ESI request and remove Surrogate-Control header\n if (beresp.http.Surrogate-Control ~ \"ESI\/1.0\") {\n unset beresp.http.Surrogate-Control;\n set beresp.do_esi = true;\n }\n\n # If the request to the backend returns a code is 5xx, restart the loop\n # If the number of restarts reaches the value of the parameter max_restarts,\n # the request will be error'ed. max_restarts defaults to 4. This prevents\n # an eternal loop in the event that, e.g., the object does not exist at all.\n if (beresp.status >= 500 && beresp.status <= 599){\n return(restart);\n }\n\n # Enable cache for all static files\n # The same argument as the static caches from above: monitor your cache size, if you get data nuked out of it, consider giving up the static file cache.\n # Before you blindly enable this, have a read here: http:\/\/mattiasgeniar.be\/2012\/11\/28\/stop-caching-static-files\/\n if (req.url ~ \"^[^?]*\\.(bmp|bz2|css|doc|eot|flv|gif|gz|ico|jpeg|jpg|js|less|mp[34]|pdf|png|rar|rtf|swf|tar|tgz|txt|wav|woff|xml|zip)(\\?.*)?$\") {\n unset beresp.http.set-cookie;\n }\n\n # Sometimes, a 301 or 302 redirect formed via Apache's mod_rewrite can mess with the HTTP port that is being passed along.\n # This often happens with simple rewrite rules in a scenario where Varnish runs on :80 and Apache on :8080 on the same box.\n # A redirect can then often redirect the end-user to a URL on :8080, where it should be :80.\n # This may need finetuning on your setup.\n #\n # To prevent accidental replace, we only filter the 301\/302 redirects for now.\n if (beresp.status == 301 || beresp.status == 302) {\n set beresp.http.Location = regsub(beresp.http.Location, \":[0-9]+\", \"\");\n }\n\n # Don't cache user & server errors\n if (beresp.status >= 400) {\n return (hit_for_pass);\n }\n\n # Non private responses without cookies and with a ttl of 0 should be artificially extended to 1 hour\n if (beresp.ttl <= 0s && beresp.http.Cache-Control !~ \"private\" && (!beresp.http.Set-Cookie)) {\n set beresp.ttl = 1h;\n set beresp.http.X-Cache-Extended = \"1\";\n }\n\n # Set 2min cache if unset for static files\n if (beresp.ttl <= 0s || beresp.http.Set-Cookie || beresp.http.Vary == \"*\") {\n set beresp.ttl = 120s;\n return (hit_for_pass);\n }\n\n return (deliver);\n}\n\n# The routine when we deliver the HTTP request to the user\n# Last chance to modify headers that are sent to the client\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"cached\";\n } else {\n set resp.http.x-Cache = \"uncached\";\n }\n\n # Remove some headers: PHP version\n unset resp.http.X-Powered-By;\n\n # Remove some headers: Apache version & OS\n unset resp.http.Server;\n unset resp.http.X-Drupal-Cache;\n unset resp.http.X-Varnish;\n unset resp.http.Via;\n unset resp.http.Link;\n\n return (deliver);\n}\n\nsub vcl_error {\n if (obj.status == 720) {\n # We use this special error status 720 to force redirects with 301 (permanent) redirects\n # To use this, call the following from anywhere in vcl_recv: error 720 \"http:\/\/host\/new.html\"\n set obj.status = 301;\n set obj.http.Location = obj.response;\n return (deliver);\n } elseif (obj.status == 721) {\n # And we use error status 721 to force redirects with a 302 (temporary) redirect\n # To use this, call the following from anywhere in vcl_recv: error 720 \"http:\/\/host\/new.html\"\n set obj.status = 302;\n set obj.http.Location = obj.response;\n return (deliver);\n }\n\n return (deliver);\n}\n\nsub vcl_init {\n return (ok);\n}\n\nsub vcl_fini {\n return (ok);\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"7654a4c7cc7346d970e07d8e47863aa415b4bac3","subject":"Add: search by slash","message":"Add: search by slash\n","repos":"aschneiderman\/atom-voice-vocola","old_file":"atom.vcl","new_file":"atom.vcl","new_contents":"# Voice commands for atom\n\ninclude folders.vch;\ninclude letters.vch;\n\nGo Strawberry = {Ctrl+Alt+F8};\n\n\n# Reload Atom = {Shift+Ctrl+Alt+F5};\nReload Atom = {Ctrl+s} Wait(100) {Shift+Ctrl+Alt+F5};\n\nFind (File | Document) = {Ctrl+t};\nSave As = {Ctrl+Shift+s};\nSave and Reload = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Ctrl+r};\nSave and Really Reload = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Ctrl+Shift+r};\n\n<delimiters> := (Quote = '\"' | 'Single Quote' = \"'\" | Comma = ',' | 'Equal Sign' = '=' | Equals = '=' \n\t| Period = '.' | Colon = ':' | 'Semi-Colon' = ';' | Hyphen = '-' | Underscore = '_' | Slash = '\/'\n\t| Paren = \"(\" | \"Close Paren\" = \")\"\n\t| Bracket = '[' | \"Close Bracket\" = ']' | Brace = '{' | 'Close Brace' = '}'\t);\n\n# --- Navigation commands ------------------------------------\nLine 1..200 = {Ctrl+g} $1 {Enter};\n(Left = 'b' | Right = 'f') Word = {Alt+$1};\nTop = {Ctrl+Home};\nBottom = {Ctrl+End};\n(Find = 'Right' | 'Insert After' = 'Right' | 'Insert Before' = 'Left') (Next = 'Enter' | Last = 'Shift+F3') <delimiters> \n\t\t= {Ctrl+f} $3 {$2} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') <delimiters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') 1..20 <delimiters> = {Ctrl+f} $3 {Enter} {Esc} Wait(100) {F3_$2} {Shift+F3} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') Enda <delimiters> = {End} {Ctrl+f} $2 {Enter} {Esc} {Shift+F3} Wait(100) {$1};\n\nFine Alpha <letters> = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Left};\nInsert (Before = 'Left' | After = 'Right') Alpha <letters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nFine Number 0..9 = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Right};\nFind Again = {F3} {Right};\nFind Again 1..20 Times = {F3_$1} {Right};\n\nFind Symbol = {Ctrl+r};\n\n(Set | Add | Clear | Hide | Delete) Bookmark = {Ctrl+Alt+F2};\n(Next = 'F2' | Last = 'Shift+F2') Bookmark = {$1};\n\nNext Window = {Ctrl+Tab};\nLast Window = {Ctrl+Shift+Tab};\n\n\n# --- Editing commands ----------------------------------------\nSelect Line = {Ctrl+l};\nSelect (Next = 'Down' | Last = 'Up') 1..20 Lines = {Home} {Shift+$1_$2};\n(Join = 'j' | Indent = ']' | Dedent = '[') That = {Ctrl+$1};\nMove Line (Up | Down) 1..20 = {Ctrl+$1_$2};\n\n\n\nDelete Word = {Ctrl+Del};\nDelete 1..20 Words = {Ctrl+Del_$1};\nDelete (Back | Last) Word = {Ctrl+Backspace};\nDelete (Back | Last) 1..20 Words = {Ctrl+Backspace_$2};\nDelete Enda Word = {End} {Ctrl+Backspace};\n\n(Delete Line | Dede) = {Ctrl+Shift+k};\nDelete 1..20 Lines = {Ctrl+Shift+k_$1};\n(Cut = 'x' | Paste = 'v' | Copy = 'c') That = {Ctrl+$1};\n\nComment (That | Line) = {Ctrl+\/};\nComment 1..20 Lines = {Home} {Shift+Down_$1} {Ctrl+\/};\n\nSelect between (Delimiters | Brackets) ={Ctrl+m} {Ctrl+Alt+m};\n\nDelete Tags = {Ctrl+Alt+F4};\n\n\n\n\n# --- Code commands -------------------------------------------\nStart (Item = 'li' | List = 'ul' | HTML = 'html' | pre = \"pre\"\n\t| 'Bold ID' = 'bold-id' | 'Input' = 'ds-input-text'\n\t| 'Fix Line' = 'fix-current-line' | 'Fix Current Line' = 'fix-current-line'\n\t| Snippet = 'my-snippet' | 'Recipe Row' = 'recipe-row' | 'Recipe Play' = 'recipe-play') = $1 {Tab};\nStart (para = '<p>' ) = $1;\nAdd (para = 'p') = '<' $1 '>' {End} '<\/' $1 '>';\nReplace With (para = 'p') = {Ctrl+Alt+F4} '<' $1 '>' {End} '<\/' $1 '>';\n\nStart (Header | Heading) 1..7 = h $2 {Tab};\nAdd (Header | Heading) 1..7 = '<h' $2 '>' {End} '<\/h' $2 '>';\nReplace With (Header | Heading) 1..7 = {Ctrl+Alt+F4} '<h' $2 '>' {End} '<\/h' $2 '>' {Home};\nMid HREF = '\">';\n\nPaste Function = 'function ' {Ctrl+v} ' {' {Enter} {Enter} '};' {Up};\n\nPre-Format Code = {Ctrl+Alt+F5};\n\n# TO ADD:\n# adding HTML comments, using a snippet\n\nShortcut Keys = {Ctrl+Shift+p};\n\n","old_contents":"# Voice commands for atom\n\ninclude folders.vch;\ninclude letters.vch;\n\n\n# Reload Atom = {Shift+Ctrl+Alt+F5};\nReload Atom = {Ctrl+s} Wait(100) {Shift+Ctrl+Alt+F5};\n\nFind (File | Document) = {Ctrl+t};\nSave As = {Ctrl+Shift+s};\nSave and Reload = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Ctrl+r};\nSave and Really Reload = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Ctrl+Shift+r};\n\n<delimiters> := (Quote = '\"' | 'Single Quote' = \"'\" | Comma = ',' | 'Equal Sign' = '=' | Equals = '=' \n\t| Period = '.' | Colon = ':' | 'Semi-Colon' = ';' | Hyphen = '-' | Underscore = '_'\n\t| Paren = \"(\" | \"Close Paren\" = \")\"\n\t| Bracket = '[' | \"Close Bracket\" = ']' | Brace = '{' | 'Close Brace' = '}'\t);\n\n# --- Navigation commands ------------------------------------\nLine 1..200 = {Ctrl+g} $1 {Enter};\n(Left = 'b' | Right = 'f') Word = {Alt+$1};\nTop = {Ctrl+Home};\nBottom = {Ctrl+End};\n(Find = 'Right' | 'Insert After' = 'Right' | 'Insert Before' = 'Left') (Next = 'Enter' | Last = 'Shift+F3') <delimiters> \n\t\t= {Ctrl+f} $3 {$2} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') <delimiters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') 1..20 <delimiters> = {Ctrl+f} $3 {Enter} {Esc} Wait(100) {F3_$2} {Shift+F3} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') Enda <delimiters> = {End} {Ctrl+f} $2 {Enter} {Esc} {Shift+F3} Wait(100) {$1};\n\nFine Alpha <letters> = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Right};\nInsert (Before = 'Left' | After = 'Right') Alpha <letters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nFine Number 0..9 = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Right};\nFind Again = {F3} {Right};\nFind Again 1..20 Times = {F3_$1} {Right};\n\nFind Symbol = {Ctrl+r};\n\n(Set | Add | Clear | Hide | Delete) Bookmark = {Ctrl+Alt+F2};\n(Next = 'F2' | Last = 'Shift+F2') Bookmark = {$1};\n\nNext Window = {Ctrl+Tab};\nLast Window = {Ctrl+Shift+Tab};\n\n\n# --- Editing commands ----------------------------------------\nSelect Line = {Ctrl+l};\nSelect (Next = 'Down' | Last = 'Up') 1..20 Lines = {Home} {Shift+$1_$2};\n(Join = 'j' | Indent = ']' | Dedent = '[') That = {Ctrl+$1};\nMove Line (Up | Down) 1..20 = {Ctrl+$1_$2};\n\n\n\nDelete Word = {Ctrl+Del};\nDelete 1..20 Words = {Ctrl+Del_$1};\nDelete (Back | Last) Word = {Ctrl+Backspace};\nDelete (Back | Last) 1..20 Words = {Ctrl+Backspace_$2};\nDelete Enda Word = {End} {Ctrl+Backspace};\n\n(Delete Line | Dede) = {Ctrl+Shift+k};\nDelete 1..20 Lines = {Ctrl+Shift+k_$1};\n(Cut = 'x' | Paste = 'v' | Copy = 'c') That = {Ctrl+$1};\n\nComment (That | Line) = {Ctrl+\/};\nComment 1..20 Lines = {Home} {Shift+Down_$1} {Ctrl+\/};\n\nSelect between (Delimiters | Brackets) ={Ctrl+m} {Ctrl+Alt+m};\n\nDelete Tags = {Ctrl+Alt+F4};\n\n\n\n\n# --- Code commands -------------------------------------------\nStart (Item = 'li' | List = 'ul' | HTML = 'html' | pre = \"pre\"\n\t| 'Bold ID' = 'bold-id' | 'Input' = 'ds-input-text'\n\t| 'Fix Line' = 'fix-current-line' | 'Fix Current Line' = 'fix-current-line'\n\t| Snippet = 'my-snippet' | 'Recipe Row' = 'recipe-row' | 'Recipe Play' = 'recipe-play') = $1 {Tab};\nStart (para = '<p>' ) = $1;\nAdd (para = 'p') = '<' $1 '>' {End} '<\/' $1 '>';\nReplace With (para = 'p') = {Ctrl+Alt+F4} '<' $1 '>' {End} '<\/' $1 '>';\n\nStart (Header | Heading) 1..7 = h $2 {Tab};\nAdd (Header | Heading) 1..7 = '<h' $2 '>' {End} '<\/h' $2 '>';\nReplace With (Header | Heading) 1..7 = {Ctrl+Alt+F4} '<h' $2 '>' {End} '<\/h' $2 '>' {Home};\nMid HREF = '\">';\n\nPaste Function = 'function ' {Ctrl+v} ' {' {Enter} {Enter} '};' {Up};\n\nPre-Format Code = {Ctrl+Alt+F5};\n\n# TO ADD:\n# adding HTML comments, using a snippet\n\nShortcut Keys = {Ctrl+Shift+p};\n\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"10978ce2d5595cebb2633295ea5b8892b6cf0d28","subject":"fix bug firefox caching when switching languages","message":"fix bug firefox caching when switching languages","repos":"Arasaac\/dockerizePHPApp,Arasaac\/dockerizePHPApp,Arasaac\/dockerizePHPApp,Arasaac\/dockerizePHPApp,Arasaac\/dockerizePHPApp,Arasaac\/dockerizePHPApp","old_file":"varnish\/default.vcl","new_file":"varnish\/default.vcl","new_contents":"vcl 4.0;\n# Based on: https:\/\/github.com\/mattiasgeniar\/varnish-4.0-configuration-templates\/blob\/master\/\nimport std;\nimport directors;\n\nbackend server1 { # Define one backend\n .host = \"{VARNISH_BACKEND_HOST}\";\n .port = \"{VARNISH_BACKEND_PORT}\";\n .max_connections = 300; # That's it\n\n .probe = {\n #.url = \"\/\"; # short easy way (GET \/)\n # We prefer to only do a HEAD \/\n .request =\n \"HEAD \/ HTTP\/1.1\"\n \"Host: arasaac\"\n \"Connection: close\"\n \"User-Agent: Varnish Health Probe\";\n\n .interval = 5s; # check the health of each backend every 5 seconds\n .timeout = 3s; # timing out after 1 second.\n .window = 5; # If 3 out of the last 5 polls succeeded the backend is considered healthy, otherwise it will be marked as sick\n .threshold = 3;\n }\n\n .first_byte_timeout = 3s; # How long to wait before we receive a first byte from our backend?\n .connect_timeout = 5s; # How long to wait for a backend connection?\n .between_bytes_timeout = 2s; # How long to wait between bytes received from our backend?\n}\n\n#acl purge {\n # ACL we'll use later to allow purges\n# \"localhost\";\n# \"127.0.0.1\";\n# \"::1\";\n#}\n\nsub vcl_init {\n # Called when VCL is loaded, before any requests pass through it.\n # Typically used to initialize VMODs.\n\n new vdir = directors.round_robin();\n vdir.add_backend(server1);\n # vdir.add_backend(server...);\n # vdir.add_backend(servern);\n}\n\nsub vcl_recv {\n set req.backend_hint = vdir.backend(); # send all traffic to the vdir director\n\n # Normalize the header, remove the port (in case you're testing this on various TCP ports)\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n # Remove the proxy header (see https:\/\/httpoxy.org\/#mitigate-varnish)\n unset req.http.proxy;\n\n # when purging from php files, we need to send the request to varnish but process it as it were arasaac web server\n if ( req.http.host ~ \"varnish\" ) {\n set req.http.x-host = req.http.host;\n set req.http.host = \"www.arasaac.org\";\n }\n\n\n if (req.http.host ~ \"^arasaac.org\" || req.http.host ~ \"arasaac.net\" || req.http.host ~ \"arasaac.es\" ) {\n return (synth (750, \"\"));\n }\n if (req.url~ \"^\/index.php\") {\n set req.url = regsub(req.url, \"index.php\", \"\");\n } \n\n # Allow purging\n if (req.method == \"PURGE\") {\n# if (!client.ip ~ purge) { # purge is the ACL defined at the begining\n # Not from an allowed IP? Then die with an error.\n# return (synth(405, \"This IP is not allowed to send PURGE requests.\"));\n# }\n # If you got this stage (and didn't error out above), purge the cached result\n return (purge);\n }\n if (req.method == \"BAN\")\n {\n \/\/ TODO: Add client validation as needed\n ban(\"obj.http.x-url ~ \" + req.url);\n return(synth(901, \"BAN Set for \" + req.url));\n }\n\n # Only deal with \"normal\" types\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"PATCH\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n # Implementing websocket support (https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html)\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n # Only cache GET or HEAD requests. This makes sure the POST requests are always passed.\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n\n set req.http.Cookie = regsuball(req.http.Cookie, \"has_js=[^;]+(; )?\", \"\");\n\n # Remove any Google Analytics based cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__utm.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"_ga=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"_gat=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmctr=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmcmd.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmccn.=[^;]+(; )?\", \"\");\n\n # Remove Arasaac Cookies for caching:\n if (!(req.url ~ \"cesta.php\" || req.url ~ \"pictogramas_color.php\" || req.url ~ \"pictogramas_byn.php\"|| req.url ~ \"imagenes.php\" || req.url ~ \"videos_lse.php\" || req.url ~ \"signos_lse_color.php\" \n || req.url ~ \"buscar.php\" || req.url ~ \"n_elementos_cesto.php\" || req.url ~ \"herramientas\" || req.url ~ \"zip_cesto.php\" || req.url ~ \"carpeta_trabajo.php\" || req.url ~ \"admin.php\")) {\n set req.http.Cookie = regsuball(req.http.Cookie, \"PHPSESSID=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"preImg=x; \", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"; \", \";\");\n\n }\n \n #unset req.http.cookie; \n # Remove DoubleClick offensive cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__gads=[^;]+(; )?\", \"\");\n\n # Remove the Quant Capital cookies (added by some plugin, all __qca)\n set req.http.Cookie = regsuball(req.http.Cookie, \"__qc.=[^;]+(; )?\", \"\");\n\n # Remove the AddThis cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__atuv.=[^;]+(; )?\", \"\");\n\n # Remove a \";\" prefix in the cookie if present\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n\n # Are there cookies left with only spaces or that are empty?\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n\n # Remove all cookies for static files\n # A valid discussion could be held on this line: do you really need to cache static files that don't cause load? Only if you have memory left.\n # Sure, there's disk I\/O, but chances are your OS will already have these files in their buffers (thus memory).\n # Before you blindly enable this, have a read here: https:\/\/ma.ttias.be\/stop-caching-static-files\/\n if (req.url ~ \"^[^?]*\\.(7z|avi|bmp|bz2|css|csv|doc|docx|eot|flac|flv|gif|gz|ico|jpeg|jpg|js|less|mka|mkv|mov|mp3|mp4|mpeg|mpg|odt|otf|ogg|ogm|opus|pdf|png|ppt|pptx|rar|rtf|svg|svgz|swf|tar|tbz|tgz|ttf|txt|txz|wav|webm|webp|woff|woff2|xls|xlsx|xml|xz|zip)(\\?.*)?$\") {\n unset req.http.Cookie;\n return (hash);\n }\n \n #at the end because I need to remove previous cookies \n if (req.url ~ \"purge.php\") {\n return (pass);\n }\n\n return (hash);\n}\n\nsub vcl_pipe {\n # Called upon entering pipe mode.\n # In this mode, the request is passed on to the backend, and any further data from both the client\n # and backend is passed on unaltered until either end closes the connection. Basically, Varnish will\n # degrade into a simple TCP proxy, shuffling bytes back and forth. For a connection in pipe mode,\n # no other VCL subroutine will ever get called after vcl_pipe.\n\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n # set bereq.http.connection = \"close\";\n # here. It is not set by default as it might break some broken web\n # applications, like IIS with NTLM authentication.\n\n # set bereq.http.Connection = \"Close\";\n\n # Implementing websocket support (https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html)\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n\n return (pipe);\n}\n\nsub vcl_pass {\n # Called upon entering pass mode. In this mode, the request is passed on to the backend, and the\n # backend's response is passed on to the client, but is not entered into the cache. Subsequent\n # requests submitted over the same client connection are handled normally.\n\n # return (pass);\n}\n\n# The data on which the hashing will take place\nsub vcl_hash {\n # Called after vcl_recv to create a hash value for the request. This is used as a key\n # to look up the object in Varnish.\n\n hash_data(req.url);\n\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n\n # hash cookies for requests that have them\n# if (req.http.Language) {\n #add cookie in hash\n# hash_data(req.http.Language);\n# }\n if (req.http.Cookie) {\n hash_data(req.http.Cookie);\n }\n #for debugging hash \n #std.log(\"######################################################################################################\");\n #std.log(req.http.Cookie + req.http.host + req.url);\n\n}\n\nsub vcl_hit {\n # Called when a cache lookup is successful.\n\n if (obj.ttl >= 0s) {\n # A pure unadultered hit, deliver it\n return (deliver);\n }\n\n # https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-grace.html\n # When several clients are requesting the same page Varnish will send one request to the backend and place the others on hold while fetching one copy from the backend. In some products this is called request coalescing and Varnish does this automatically.\n # If you are serving thousands of hits per second the queue of waiting requests can get huge. There are two potential problems - one is a thundering herd problem - suddenly releasing a thousand threads to serve content might send the load sky high. Secondly - nobody likes to wait. To deal with this we can instruct Varnish to keep the objects in cache beyond their TTL and to serve the waiting requests somewhat stale content.\n\n# if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n# return (deliver);\n# } else {\n# return (fetch);\n# }\n\n # We have no fresh fish. Lets look at the stale ones.\n if (std.healthy(req.backend_hint)) {\n # Backend is healthy. Limit age to 10s.\n if (obj.ttl + 10s > 0s) {\n #set req.http.grace = \"normal(limited)\";\n return (deliver);\n } else {\n # No candidate for grace. Fetch a fresh object.\n return(fetch);\n }\n } else {\n # backend is sick - use full grace\n if (obj.ttl + obj.grace > 0s) {\n #set req.http.grace = \"full\";\n return (deliver);\n } else {\n # no graced object.\n return (fetch);\n }\n }\n\n # fetch & deliver once we get the result\n return (fetch); # Dead code, keep as a safeguard\n}\n\nsub vcl_miss {\n # Called after a cache lookup if the requested document was not found in the cache. Its purpose\n # is to decide whether or not to attempt to retrieve the document from the backend, and which\n # backend to use.\n\n return (fetch);\n}\n\n# Handle the HTTP request coming from our backend\nsub vcl_backend_response {\n # Called after the response headers has been successfully retrieved from the backend.\n\n # Pause ESI request and remove Surrogate-Control header\n if (beresp.http.Surrogate-Control ~ \"ESI\/1.0\") {\n unset beresp.http.Surrogate-Control;\n set beresp.do_esi = true;\n }\n\n # Enable cache for all static files\n # The same argument as the static caches from above: monitor your cache size, if you get data nuked out of it, consider giving up the static file cache.\n # Before you blindly enable this, have a read here: https:\/\/ma.ttias.be\/stop-caching-static-files\/\n if (bereq.url ~ \"^[^?]*\\.(7z|avi|bmp|bz2|css|csv|doc|docx|eot|flac|flv|gif|gz|ico|jpeg|jpg|js|less|mka|mkv|mov|mp3|mp4|mpeg|mpg|odt|otf|ogg|ogm|opus|pdf|png|ppt|pptx|rar|rtf|svg|svgz|swf|tar|tbz|tgz|ttf|txt|txz|wav|webm|webp|woff|woff2|xls|xlsx|xml|xz|zip)(\\?.*)?$\") {\n unset beresp.http.set-cookie;\n }\n \n if (bereq.url ~ \"^\/$\") {\n # en firfox a veces se cacheaba al cambiar el lenguaje dando datos erroneos\n set beresp.ttl = 86400s;\n set beresp.http.cache-control = \"public, max-age = 0\";\n unset beresp.http.set-cookie;\n return(deliver);\n }\n \n if (!(bereq.url ~ \"language_set.php\" || bereq.url ~ \"cesta.php\" || bereq.url ~ \"pictogramas_color.php\" || bereq.url ~ \"pictogramas_byn.php\"|| bereq.url ~ \"imagenes.php\" || bereq.url ~ \"videos_lse.php\" || bereq.url ~ \"signos_lse_color.php\" || bereq.url ~ \"buscar.php\" || bereq.url ~ \"n_elementos_cesto.php\" || bereq.url ~ \"herramientas\" || bereq.url ~ \"zip_cesto.php\" || bereq.url ~ \"carpeta_trabajo.php\" || bereq.url ~ \"admin.php\")) {\n set beresp.ttl = 86400s;\n set beresp.http.cache-control = \"public, max-age = 300\";\n #set beresp.http.log = \"ha entrado aqu\u00ed\";\n #set beresp.http.X-CacheReason = \"varnishcache\";\n unset beresp.http.set-cookie;\n return(deliver);\n }\n \n\n # Large static files are delivered directly to the end-user without\n # waiting for Varnish to fully read the file first.\n # Varnish 4 fully supports Streaming, so use streaming here to avoid locking.\n if (bereq.url ~ \"^[^?]*\\.(7z|avi|bz2|flac|flv|gz|mka|mkv|mov|mp3|mp4|mpeg|mpg|ogg|ogm|opus|rar|tar|tgz|tbz|txz|wav|webm|xz|zip)(\\?.*)?$\") {\n unset beresp.http.set-cookie;\n set beresp.do_stream = true; # Check memory usage it'll grow in fetch_chunksize blocks (128k by default) if the backend doesn't send a Content-Length header, so only enable it for big objects\n }\n\n # Sometimes, a 301 or 302 redirect formed via Apache's mod_rewrite can mess with the HTTP port that is being passed along.\n # This often happens with simple rewrite rules in a scenario where Varnish runs on :80 and Apache on :8080 on the same box.\n # A redirect can then often redirect the end-user to a URL on :8080, where it should be :80.\n # This may need finetuning on your setup.\n #\n # To prevent accidental replace, we only filter the 301\/302 redirects for now.\n if (beresp.status == 301 || beresp.status == 302) {\n set beresp.http.Location = regsub(beresp.http.Location, \":[0-9]+\", \"\");\n }\n\n # Set 2min cache if unset for static files\n if (beresp.ttl <= 0s || beresp.http.Set-Cookie || beresp.http.Vary == \"*\") {\n set beresp.ttl = 120s; # Important, you shouldn't rely on this, SET YOUR HEADERS in the backend\n set beresp.uncacheable = true;\n return (deliver);\n }\n\n # Don't cache 50x responses\n if (beresp.status == 500 || beresp.status == 502 || beresp.status == 503 || beresp.status == 504) {\n return (abandon);\n }\n\n # Allow stale content, in case the backend goes down.\n # make Varnish keep all objects for 6 hours beyond their TTL\n set beresp.grace = 6h;\n\n return (deliver);\n}\n\n# The routine when we deliver the HTTP request to the user\n# Last chance to modify headers that are sent to the client\nsub vcl_deliver {\n # Called before a cached object is delivered to the client.\n\n if (obj.hits > 0) { # Add debug header to see if it's a HIT\/MISS and the number of hits, disable when not needed\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n\n # Please note that obj.hits behaviour changed in 4.0, now it counts per objecthead, not per object\n # and obj.hits may not be reset in some cases where bans are in use. See bug 1492 for details.\n # So take hits with a grain of salt\n set resp.http.X-Cache-Hits = obj.hits;\n\n # Remove some headers: PHP version\n unset resp.http.X-Powered-By;\n\n # Remove some headers: Apache version & OS\n unset resp.http.Server;\n unset resp.http.X-Drupal-Cache;\n unset resp.http.X-Varnish;\n unset resp.http.Via;\n unset resp.http.Link;\n unset resp.http.X-Generator;\n\n return (deliver);\n}\n\nsub vcl_purge {\n # Only handle actual PURGE HTTP methods, everything else is discarded\n if (req.method != \"PURGE\") {\n # restart request\n set req.http.X-Purge = \"Yes\";\n return(restart);\n }\n}\n\nsub vcl_synth {\n if (resp.status == 720) {\n # We use this special error status 720 to force redirects with 301 (permanent) redirects\n # To use this, call the following from anywhere in vcl_recv: return (synth(720, \"http:\/\/host\/new.html\"));\n set resp.http.Location = resp.reason;\n set resp.status = 301;\n return (deliver);\n } elseif (resp.status == 721) {\n # And we use error status 721 to force redirects with a 302 (temporary) redirect\n # To use this, call the following from anywhere in vcl_recv: return (synth(720, \"http:\/\/host\/new.html\"));\n set resp.http.Location = resp.reason;\n set resp.status = 302;\n return (deliver);\n } elseif (resp.status == 750) {\n set resp.status = 301;\n set resp.http.Location = \"http:\/\/www.arasaac.org\" + req.url;\n return(deliver);\n }\n\n return (deliver);\n}\n\n\nsub vcl_fini {\n # Called when VCL is discarded only after all requests have exited the VCL.\n # Typically used to clean up VMODs.\n\n return (ok);\n}\n","old_contents":"vcl 4.0;\n# Based on: https:\/\/github.com\/mattiasgeniar\/varnish-4.0-configuration-templates\/blob\/master\/\nimport std;\nimport directors;\n\nbackend server1 { # Define one backend\n .host = \"{VARNISH_BACKEND_HOST}\";\n .port = \"{VARNISH_BACKEND_PORT}\";\n .max_connections = 300; # That's it\n\n .probe = {\n #.url = \"\/\"; # short easy way (GET \/)\n # We prefer to only do a HEAD \/\n .request =\n \"HEAD \/ HTTP\/1.1\"\n \"Host: arasaac\"\n \"Connection: close\"\n \"User-Agent: Varnish Health Probe\";\n\n .interval = 5s; # check the health of each backend every 5 seconds\n .timeout = 3s; # timing out after 1 second.\n .window = 5; # If 3 out of the last 5 polls succeeded the backend is considered healthy, otherwise it will be marked as sick\n .threshold = 3;\n }\n\n .first_byte_timeout = 3s; # How long to wait before we receive a first byte from our backend?\n .connect_timeout = 5s; # How long to wait for a backend connection?\n .between_bytes_timeout = 2s; # How long to wait between bytes received from our backend?\n}\n\n#acl purge {\n # ACL we'll use later to allow purges\n# \"localhost\";\n# \"127.0.0.1\";\n# \"::1\";\n#}\n\nsub vcl_init {\n # Called when VCL is loaded, before any requests pass through it.\n # Typically used to initialize VMODs.\n\n new vdir = directors.round_robin();\n vdir.add_backend(server1);\n # vdir.add_backend(server...);\n # vdir.add_backend(servern);\n}\n\nsub vcl_recv {\n set req.backend_hint = vdir.backend(); # send all traffic to the vdir director\n\n # Normalize the header, remove the port (in case you're testing this on various TCP ports)\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n # Remove the proxy header (see https:\/\/httpoxy.org\/#mitigate-varnish)\n unset req.http.proxy;\n\n # when purging from php files, we need to send the request to varnish but process it as it were arasaac web server\n if ( req.http.host ~ \"varnish\" ) {\n set req.http.x-host = req.http.host;\n set req.http.host = \"www.arasaac.org\";\n }\n\n\n if (req.http.host ~ \"^arasaac.org\" || req.http.host ~ \"arasaac.net\" || req.http.host ~ \"arasaac.es\" ) {\n return (synth (750, \"\"));\n }\n if (req.url~ \"^\/index.php\") {\n set req.url = regsub(req.url, \"index.php\", \"\");\n } \n\n # Allow purging\n if (req.method == \"PURGE\") {\n# if (!client.ip ~ purge) { # purge is the ACL defined at the begining\n # Not from an allowed IP? Then die with an error.\n# return (synth(405, \"This IP is not allowed to send PURGE requests.\"));\n# }\n # If you got this stage (and didn't error out above), purge the cached result\n return (purge);\n }\n if (req.method == \"BAN\")\n {\n \/\/ TODO: Add client validation as needed\n ban(\"obj.http.x-url ~ \" + req.url);\n return(synth(901, \"BAN Set for \" + req.url));\n }\n\n # Only deal with \"normal\" types\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"PATCH\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n # Implementing websocket support (https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html)\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n # Only cache GET or HEAD requests. This makes sure the POST requests are always passed.\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n\n set req.http.Cookie = regsuball(req.http.Cookie, \"has_js=[^;]+(; )?\", \"\");\n\n # Remove any Google Analytics based cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__utm.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"_ga=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"_gat=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmctr=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmcmd.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmccn.=[^;]+(; )?\", \"\");\n\n # Remove Arasaac Cookies for caching:\n if (!(req.url ~ \"cesta.php\" || req.url ~ \"pictogramas_color.php\" || req.url ~ \"pictogramas_byn.php\"|| req.url ~ \"imagenes.php\" || req.url ~ \"videos_lse.php\" || req.url ~ \"signos_lse_color.php\" \n || req.url ~ \"buscar.php\" || req.url ~ \"n_elementos_cesto.php\" || req.url ~ \"herramientas\" || req.url ~ \"zip_cesto.php\" || req.url ~ \"carpeta_trabajo.php\" || req.url ~ \"admin.php\")) {\n set req.http.Cookie = regsuball(req.http.Cookie, \"PHPSESSID=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"preImg=x; \", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"; \", \";\");\n\n }\n \n #unset req.http.cookie; \n # Remove DoubleClick offensive cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__gads=[^;]+(; )?\", \"\");\n\n # Remove the Quant Capital cookies (added by some plugin, all __qca)\n set req.http.Cookie = regsuball(req.http.Cookie, \"__qc.=[^;]+(; )?\", \"\");\n\n # Remove the AddThis cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__atuv.=[^;]+(; )?\", \"\");\n\n # Remove a \";\" prefix in the cookie if present\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n\n # Are there cookies left with only spaces or that are empty?\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n\n # Remove all cookies for static files\n # A valid discussion could be held on this line: do you really need to cache static files that don't cause load? Only if you have memory left.\n # Sure, there's disk I\/O, but chances are your OS will already have these files in their buffers (thus memory).\n # Before you blindly enable this, have a read here: https:\/\/ma.ttias.be\/stop-caching-static-files\/\n if (req.url ~ \"^[^?]*\\.(7z|avi|bmp|bz2|css|csv|doc|docx|eot|flac|flv|gif|gz|ico|jpeg|jpg|js|less|mka|mkv|mov|mp3|mp4|mpeg|mpg|odt|otf|ogg|ogm|opus|pdf|png|ppt|pptx|rar|rtf|svg|svgz|swf|tar|tbz|tgz|ttf|txt|txz|wav|webm|webp|woff|woff2|xls|xlsx|xml|xz|zip)(\\?.*)?$\") {\n unset req.http.Cookie;\n return (hash);\n }\n \n #at the end because I need to remove previous cookies \n if (req.url ~ \"purge.php\") {\n return (pass);\n }\n\n return (hash);\n}\n\nsub vcl_pipe {\n # Called upon entering pipe mode.\n # In this mode, the request is passed on to the backend, and any further data from both the client\n # and backend is passed on unaltered until either end closes the connection. Basically, Varnish will\n # degrade into a simple TCP proxy, shuffling bytes back and forth. For a connection in pipe mode,\n # no other VCL subroutine will ever get called after vcl_pipe.\n\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n # set bereq.http.connection = \"close\";\n # here. It is not set by default as it might break some broken web\n # applications, like IIS with NTLM authentication.\n\n # set bereq.http.Connection = \"Close\";\n\n # Implementing websocket support (https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html)\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n\n return (pipe);\n}\n\nsub vcl_pass {\n # Called upon entering pass mode. In this mode, the request is passed on to the backend, and the\n # backend's response is passed on to the client, but is not entered into the cache. Subsequent\n # requests submitted over the same client connection are handled normally.\n\n # return (pass);\n}\n\n# The data on which the hashing will take place\nsub vcl_hash {\n # Called after vcl_recv to create a hash value for the request. This is used as a key\n # to look up the object in Varnish.\n\n hash_data(req.url);\n\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n\n # hash cookies for requests that have them\n# if (req.http.Language) {\n #add cookie in hash\n# hash_data(req.http.Language);\n# }\n if (req.http.Cookie) {\n hash_data(req.http.Cookie);\n }\n #for debugging hash \n #std.log(\"######################################################################################################\");\n #std.log(req.http.Cookie + req.http.host + req.url);\n\n}\n\nsub vcl_hit {\n # Called when a cache lookup is successful.\n\n if (obj.ttl >= 0s) {\n # A pure unadultered hit, deliver it\n return (deliver);\n }\n\n # https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-grace.html\n # When several clients are requesting the same page Varnish will send one request to the backend and place the others on hold while fetching one copy from the backend. In some products this is called request coalescing and Varnish does this automatically.\n # If you are serving thousands of hits per second the queue of waiting requests can get huge. There are two potential problems - one is a thundering herd problem - suddenly releasing a thousand threads to serve content might send the load sky high. Secondly - nobody likes to wait. To deal with this we can instruct Varnish to keep the objects in cache beyond their TTL and to serve the waiting requests somewhat stale content.\n\n# if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n# return (deliver);\n# } else {\n# return (fetch);\n# }\n\n # We have no fresh fish. Lets look at the stale ones.\n if (std.healthy(req.backend_hint)) {\n # Backend is healthy. Limit age to 10s.\n if (obj.ttl + 10s > 0s) {\n #set req.http.grace = \"normal(limited)\";\n return (deliver);\n } else {\n # No candidate for grace. Fetch a fresh object.\n return(fetch);\n }\n } else {\n # backend is sick - use full grace\n if (obj.ttl + obj.grace > 0s) {\n #set req.http.grace = \"full\";\n return (deliver);\n } else {\n # no graced object.\n return (fetch);\n }\n }\n\n # fetch & deliver once we get the result\n return (fetch); # Dead code, keep as a safeguard\n}\n\nsub vcl_miss {\n # Called after a cache lookup if the requested document was not found in the cache. Its purpose\n # is to decide whether or not to attempt to retrieve the document from the backend, and which\n # backend to use.\n\n return (fetch);\n}\n\n# Handle the HTTP request coming from our backend\nsub vcl_backend_response {\n # Called after the response headers has been successfully retrieved from the backend.\n\n # Pause ESI request and remove Surrogate-Control header\n if (beresp.http.Surrogate-Control ~ \"ESI\/1.0\") {\n unset beresp.http.Surrogate-Control;\n set beresp.do_esi = true;\n }\n\n # Enable cache for all static files\n # The same argument as the static caches from above: monitor your cache size, if you get data nuked out of it, consider giving up the static file cache.\n # Before you blindly enable this, have a read here: https:\/\/ma.ttias.be\/stop-caching-static-files\/\n if (bereq.url ~ \"^[^?]*\\.(7z|avi|bmp|bz2|css|csv|doc|docx|eot|flac|flv|gif|gz|ico|jpeg|jpg|js|less|mka|mkv|mov|mp3|mp4|mpeg|mpg|odt|otf|ogg|ogm|opus|pdf|png|ppt|pptx|rar|rtf|svg|svgz|swf|tar|tbz|tgz|ttf|txt|txz|wav|webm|webp|woff|woff2|xls|xlsx|xml|xz|zip)(\\?.*)?$\") {\n unset beresp.http.set-cookie;\n }\n \n if (!(bereq.url ~ \"language_set.php\" || bereq.url ~ \"cesta.php\" || bereq.url ~ \"pictogramas_color.php\" || bereq.url ~ \"pictogramas_byn.php\"|| bereq.url ~ \"imagenes.php\" || bereq.url ~ \"videos_lse.php\" || bereq.url ~ \"signos_lse_color.php\" || bereq.url ~ \"buscar.php\" || bereq.url ~ \"n_elementos_cesto.php\" || bereq.url ~ \"herramientas\" || bereq.url ~ \"zip_cesto.php\" || bereq.url ~ \"carpeta_trabajo.php\" || bereq.url ~ \"admin.php\")) {\n set beresp.ttl = 86400s;\n set beresp.http.cache-control = \"public, max-age = 300\";\n #set beresp.http.log = \"ha entrado aqu\u00ed\";\n #set beresp.http.X-CacheReason = \"varnishcache\";\n unset beresp.http.set-cookie;\n return(deliver);\n }\n \n\n # Large static files are delivered directly to the end-user without\n # waiting for Varnish to fully read the file first.\n # Varnish 4 fully supports Streaming, so use streaming here to avoid locking.\n if (bereq.url ~ \"^[^?]*\\.(7z|avi|bz2|flac|flv|gz|mka|mkv|mov|mp3|mp4|mpeg|mpg|ogg|ogm|opus|rar|tar|tgz|tbz|txz|wav|webm|xz|zip)(\\?.*)?$\") {\n unset beresp.http.set-cookie;\n set beresp.do_stream = true; # Check memory usage it'll grow in fetch_chunksize blocks (128k by default) if the backend doesn't send a Content-Length header, so only enable it for big objects\n }\n\n # Sometimes, a 301 or 302 redirect formed via Apache's mod_rewrite can mess with the HTTP port that is being passed along.\n # This often happens with simple rewrite rules in a scenario where Varnish runs on :80 and Apache on :8080 on the same box.\n # A redirect can then often redirect the end-user to a URL on :8080, where it should be :80.\n # This may need finetuning on your setup.\n #\n # To prevent accidental replace, we only filter the 301\/302 redirects for now.\n if (beresp.status == 301 || beresp.status == 302) {\n set beresp.http.Location = regsub(beresp.http.Location, \":[0-9]+\", \"\");\n }\n\n # Set 2min cache if unset for static files\n if (beresp.ttl <= 0s || beresp.http.Set-Cookie || beresp.http.Vary == \"*\") {\n set beresp.ttl = 120s; # Important, you shouldn't rely on this, SET YOUR HEADERS in the backend\n set beresp.uncacheable = true;\n return (deliver);\n }\n\n # Don't cache 50x responses\n if (beresp.status == 500 || beresp.status == 502 || beresp.status == 503 || beresp.status == 504) {\n return (abandon);\n }\n\n # Allow stale content, in case the backend goes down.\n # make Varnish keep all objects for 6 hours beyond their TTL\n set beresp.grace = 6h;\n\n return (deliver);\n}\n\n# The routine when we deliver the HTTP request to the user\n# Last chance to modify headers that are sent to the client\nsub vcl_deliver {\n # Called before a cached object is delivered to the client.\n\n if (obj.hits > 0) { # Add debug header to see if it's a HIT\/MISS and the number of hits, disable when not needed\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n\n # Please note that obj.hits behaviour changed in 4.0, now it counts per objecthead, not per object\n # and obj.hits may not be reset in some cases where bans are in use. See bug 1492 for details.\n # So take hits with a grain of salt\n set resp.http.X-Cache-Hits = obj.hits;\n\n # Remove some headers: PHP version\n unset resp.http.X-Powered-By;\n\n # Remove some headers: Apache version & OS\n unset resp.http.Server;\n unset resp.http.X-Drupal-Cache;\n unset resp.http.X-Varnish;\n unset resp.http.Via;\n unset resp.http.Link;\n unset resp.http.X-Generator;\n\n return (deliver);\n}\n\nsub vcl_purge {\n # Only handle actual PURGE HTTP methods, everything else is discarded\n if (req.method != \"PURGE\") {\n # restart request\n set req.http.X-Purge = \"Yes\";\n return(restart);\n }\n}\n\nsub vcl_synth {\n if (resp.status == 720) {\n # We use this special error status 720 to force redirects with 301 (permanent) redirects\n # To use this, call the following from anywhere in vcl_recv: return (synth(720, \"http:\/\/host\/new.html\"));\n set resp.http.Location = resp.reason;\n set resp.status = 301;\n return (deliver);\n } elseif (resp.status == 721) {\n # And we use error status 721 to force redirects with a 302 (temporary) redirect\n # To use this, call the following from anywhere in vcl_recv: return (synth(720, \"http:\/\/host\/new.html\"));\n set resp.http.Location = resp.reason;\n set resp.status = 302;\n return (deliver);\n } elseif (resp.status == 750) {\n set resp.status = 301;\n set resp.http.Location = \"http:\/\/www.arasaac.org\" + req.url;\n return(deliver);\n }\n\n return (deliver);\n}\n\n\nsub vcl_fini {\n # Called when VCL is discarded only after all requests have exited the VCL.\n # Typically used to clean up VMODs.\n\n return (ok);\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"ff81e80b8915695ad3fd1aa71ee74f9830d5a231","subject":"Update synthetic-responses.vcl","message":"Update synthetic-responses.vcl","repos":"JakeChampion\/polyfill-service,JakeChampion\/polyfill-service","old_file":"fastly\/vcl\/synthetic-responses.vcl","new_file":"fastly\/vcl\/synthetic-responses.vcl","new_contents":"sub vcl_recv {\n\t# Fastly recommend using the 900-999 range of status codes for custom errors within an application's VCL.\n\tif (req.http.Orig-URL ~ \"^\/v3\/normalizeUa\") {\n\t\terror 903 \"Normalise User Agent\";\n\t}\n\tif (req.http.Orig-URL ~ \"^\/v3\/parseUa\") {\n\t\terror 904 \"Parse User Agent\";\n\t}\n\tif (req.http.Orig-URL ~ \"^\/v3\/normalise_querystring_parameters_for_polyfill_bundle\") {\n\t\terror 905 \"Normalise querystring parameters for polyfill bundle\";\n\t}\n\tif (req.http.Orig-URL ~ \"^\/robots.txt\") {\n\t\terror 906;\n\t}\n\tif (req.url ~ \"^\/https:\/\/cdn.polyfill.io\") {\n\t\terror 907;\n\t}\n\tif (req.url ~ \"^\/https:\/\/polyfill.io\") {\n\t\terror 907;\n\t}\n\tif (req.url ~ \"^\/pages\/fixedData\") {\n\t\terror 907;\n\t}\n}\n\nsub vcl_error {\n\t# Normalise User Agent API\n\tif (obj.status == 903) {\n\t\tcall normalise_user_agent_1_9_0;\n\t\tset obj.status = 200;\n\t\tset obj.response = \"OK\";\n\t\tset obj.http.Content-Type = \"text\/plain; charset=utf-8\";\n\t\tset obj.http.Normalized-User-Agent = req.http.Normalized-User-Agent;\n\t\tsynthetic req.http.Normalized-User-Agent;\n\t\treturn (deliver);\n\t}\n\n\t# Parse User Agent API\n\tif (obj.status == 904) {\n\t\tcall useragent_parser;\n\t\tset obj.status = 200;\n\t\tset obj.response = \"OK\";\n\t\tset obj.http.Content-Type = \"text\/plain; charset=utf-8\";\n\t\tset obj.http.useragent_parser_family = req.http.useragent_parser_family;\n\t\tset obj.http.useragent_parser_major = req.http.useragent_parser_major;\n\t\tset obj.http.useragent_parser_minor = req.http.useragent_parser_minor;\n\t\tset obj.http.useragent_parser_patch = req.http.useragent_parser_patch;\n\t\tsynthetic req.http.useragent_parser_family \"\/\" req.http.useragent_parser_major \".\" req.http.useragent_parser_minor \".\" req.http.useragent_parser_patch;\n\t\treturn (deliver);\n\t}\n\n\t# Normalise querystring parameters\n\tif (obj.status == 905) {\n\t\tcall normalise_querystring_parameters_for_polyfill_bundle;\n\t\tset obj.status = 200;\n\t\tset obj.response = \"OK\";\n\t\tset obj.http.Content-Type = \"application\/json; charset=utf-8\";\n\t\tset obj.http.features = subfield(req.url.qs, \"features\", \"&\");\n\t\tset obj.http.excludes = subfield(req.url.qs, \"excludes\", \"&\");\n\t\tset obj.http.rum = subfield(req.url.qs, \"rum\", \"&\");\n\t\tset obj.http.unknown = subfield(req.url.qs, \"unknown\", \"&\");\n\t\tset obj.http.flags = subfield(req.url.qs, \"flags\", \"&\");\n\t\tset obj.http.ua = subfield(req.url.qs, \"ua\", \"&\");\n\t\tset obj.http.callback = subfield(req.url.qs, \"callback\", \"&\");\n\t\tset obj.http.compression = subfield(req.url.qs, \"compression\", \"&\");\n\t\tset obj.http.version = subfield(req.url.qs, \"version\", \"&\");\n\t\tsynthetic \"{\"\n\t\t\t{\"\"\"} \"features\" {\"\"\"} \":\" {\"\"\"} obj.http.features {\"\"\"}\n\t\t\tif (obj.http.excludes, \",\"{\"\"\"} \"excludes\" {\"\"\"} \":\" {\"\"\"} obj.http.excludes {\"\"\"}, \"\")\n\t\t\t\",\"{\"\"\"} \"rum\" {\"\"\"} \":\" {\"\"\"} obj.http.rum {\"\"\"}\n\t\t\t\",\"{\"\"\"} \"unknown\" {\"\"\"} \":\" {\"\"\"} obj.http.unknown {\"\"\"}\n\t\t\tif (obj.http.flags, \",\"{\"\"\"} \"flags\" {\"\"\"} \":\" {\"\"\"} obj.http.flags {\"\"\"}, \"\")\n\t\t\t\",\"{\"\"\"} \"ua\" {\"\"\"} \":\" {\"\"\"} obj.http.ua {\"\"\"}\n\t\t\tif (obj.http.callback, \",\"{\"\"\"} \"callback\" {\"\"\"} \":\" {\"\"\"} obj.http.callback {\"\"\"}, \"\")\n\t\t\tif (obj.http.compression, \",\"{\"\"\"} \"compression\" {\"\"\"} \":\" {\"\"\"} obj.http.compression {\"\"\"}, \"\")\n\t\t\tif (obj.http.version, \",\"{\"\"\"} \"version\" {\"\"\"} \":\" {\"\"\"} obj.http.version {\"\"\"}, \"\")\n\t\t\"}\";\n\t\treturn (deliver);\n\t}\n\n\t# \/robots.txt endpoint \n\tif (obj.status == 906) {\n\t\tset obj.status = 200;\n\t\tset obj.response = \"OK\";\n\t\tset obj.http.Content-Type = \"text\/plain; charset=utf-8\";\n\t\tsynthetic {\"User-agent: *\nDisallow:\"};\n\t\treturn (deliver);\n\t}\n\n\t# return 404\n\tif (obj.status == 907) {\n\t\tset obj.status = 404;\n\t\tset obj.response = \"Not Found\";\n\t\tset obj.http.Content-Type = \"text\/plain; charset=utf-8\";\n\t\tsynthetic {\"Not Found.\"};\n\t\treturn (deliver);\n\t}\n}\n","old_contents":"sub vcl_recv {\n\t# Fastly recommend using the 900-999 range of status codes for custom errors within an application's VCL.\n\tif (req.http.Orig-URL ~ \"^\/v3\/normalizeUa\") {\n\t\terror 903 \"Normalise User Agent\";\n\t}\n\tif (req.http.Orig-URL ~ \"^\/v3\/parseUa\") {\n\t\terror 904 \"Parse User Agent\";\n\t}\n\tif (req.http.Orig-URL ~ \"^\/v3\/normalise_querystring_parameters_for_polyfill_bundle\") {\n\t\terror 905 \"Normalise querystring parameters for polyfill bundle\";\n\t}\n\tif (req.http.Orig-URL ~ \"^\/robots.txt\") {\n\t\terror 906;\n\t}\n\tif (req.url ~ \"^\/https:\/\/cdn.polyfill.io\") {\n\t\terror 907;\n\t}\n\tif (req.url ~ \"^\/https:\/\/polyfill.io\") {\n\t\terror 907;\n\t}\n\tif (req.url ~ \"^\/pages\/fixedData\") {\n\t\terror 907;\n\t}\n}\n\nsub vcl_error {\n\t# Normalise User Agent API\n\tif (obj.status == 903) {\n\t\tcall normalise_user_agent_1_7_0;\n\t\tset obj.status = 200;\n\t\tset obj.response = \"OK\";\n\t\tset obj.http.Content-Type = \"text\/plain; charset=utf-8\";\n\t\tset obj.http.Normalized-User-Agent = req.http.Normalized-User-Agent;\n\t\tsynthetic req.http.Normalized-User-Agent;\n\t\treturn (deliver);\n\t}\n\n\t# Parse User Agent API\n\tif (obj.status == 904) {\n\t\tcall useragent_parser;\n\t\tset obj.status = 200;\n\t\tset obj.response = \"OK\";\n\t\tset obj.http.Content-Type = \"text\/plain; charset=utf-8\";\n\t\tset obj.http.useragent_parser_family = req.http.useragent_parser_family;\n\t\tset obj.http.useragent_parser_major = req.http.useragent_parser_major;\n\t\tset obj.http.useragent_parser_minor = req.http.useragent_parser_minor;\n\t\tset obj.http.useragent_parser_patch = req.http.useragent_parser_patch;\n\t\tsynthetic req.http.useragent_parser_family \"\/\" req.http.useragent_parser_major \".\" req.http.useragent_parser_minor \".\" req.http.useragent_parser_patch;\n\t\treturn (deliver);\n\t}\n\n\t# Normalise querystring parameters\n\tif (obj.status == 905) {\n\t\tcall normalise_querystring_parameters_for_polyfill_bundle;\n\t\tset obj.status = 200;\n\t\tset obj.response = \"OK\";\n\t\tset obj.http.Content-Type = \"application\/json; charset=utf-8\";\n\t\tset obj.http.features = subfield(req.url.qs, \"features\", \"&\");\n\t\tset obj.http.excludes = subfield(req.url.qs, \"excludes\", \"&\");\n\t\tset obj.http.rum = subfield(req.url.qs, \"rum\", \"&\");\n\t\tset obj.http.unknown = subfield(req.url.qs, \"unknown\", \"&\");\n\t\tset obj.http.flags = subfield(req.url.qs, \"flags\", \"&\");\n\t\tset obj.http.ua = subfield(req.url.qs, \"ua\", \"&\");\n\t\tset obj.http.callback = subfield(req.url.qs, \"callback\", \"&\");\n\t\tset obj.http.compression = subfield(req.url.qs, \"compression\", \"&\");\n\t\tset obj.http.version = subfield(req.url.qs, \"version\", \"&\");\n\t\tsynthetic \"{\"\n\t\t\t{\"\"\"} \"features\" {\"\"\"} \":\" {\"\"\"} obj.http.features {\"\"\"}\n\t\t\tif (obj.http.excludes, \",\"{\"\"\"} \"excludes\" {\"\"\"} \":\" {\"\"\"} obj.http.excludes {\"\"\"}, \"\")\n\t\t\t\",\"{\"\"\"} \"rum\" {\"\"\"} \":\" {\"\"\"} obj.http.rum {\"\"\"}\n\t\t\t\",\"{\"\"\"} \"unknown\" {\"\"\"} \":\" {\"\"\"} obj.http.unknown {\"\"\"}\n\t\t\tif (obj.http.flags, \",\"{\"\"\"} \"flags\" {\"\"\"} \":\" {\"\"\"} obj.http.flags {\"\"\"}, \"\")\n\t\t\t\",\"{\"\"\"} \"ua\" {\"\"\"} \":\" {\"\"\"} obj.http.ua {\"\"\"}\n\t\t\tif (obj.http.callback, \",\"{\"\"\"} \"callback\" {\"\"\"} \":\" {\"\"\"} obj.http.callback {\"\"\"}, \"\")\n\t\t\tif (obj.http.compression, \",\"{\"\"\"} \"compression\" {\"\"\"} \":\" {\"\"\"} obj.http.compression {\"\"\"}, \"\")\n\t\t\tif (obj.http.version, \",\"{\"\"\"} \"version\" {\"\"\"} \":\" {\"\"\"} obj.http.version {\"\"\"}, \"\")\n\t\t\"}\";\n\t\treturn (deliver);\n\t}\n\n\t# \/robots.txt endpoint \n\tif (obj.status == 906) {\n\t\tset obj.status = 200;\n\t\tset obj.response = \"OK\";\n\t\tset obj.http.Content-Type = \"text\/plain; charset=utf-8\";\n\t\tsynthetic {\"User-agent: *\nDisallow:\"};\n\t\treturn (deliver);\n\t}\n\n\t# return 404\n\tif (obj.status == 907) {\n\t\tset obj.status = 404;\n\t\tset obj.response = \"Not Found\";\n\t\tset obj.http.Content-Type = \"text\/plain; charset=utf-8\";\n\t\tsynthetic {\"Not Found.\"};\n\t\treturn (deliver);\n\t}\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"059b41488c5ec03f70ffe342d0d2f34d840a8607","subject":"Serve stale objects on origin errors","message":"Serve stale objects on origin errors\n","repos":"wlonk\/warehouse,karan\/warehouse,alex\/warehouse,pypa\/warehouse,karan\/warehouse,pypa\/warehouse,wlonk\/warehouse,alex\/warehouse,pypa\/warehouse,alex\/warehouse,karan\/warehouse,alex\/warehouse,dstufft\/warehouse,wlonk\/warehouse,dstufft\/warehouse,dstufft\/warehouse,alex\/warehouse,dstufft\/warehouse,karan\/warehouse,karan\/warehouse,pypa\/warehouse","old_file":"vcl\/main.vcl","new_file":"vcl\/main.vcl","new_contents":"\nsub vcl_recv {\n\n # I'm not 100% sure on what this is exactly for, it was taken from the\n # Fastly documentation, however, what I *believe* it does is just ensure\n # that we don't serve a stale copy of the page from the shield node when\n # an edge node is requesting content.\n if (req.http.Fastly-FF) {\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Some (Older) clients will send a hash fragment as part of the URL even\n # though that is a local only modification. This breaks this badly for the\n # files in S3, and in general it's just not needed.\n set req.url = regsub(req.url, \"#.*$\", \"\");\n\n # Most of the URLs in Warehouse do not support or require any sort of query\n # parameter. If we strip these at the edge then we'll increase our cache\n # efficiency when they won't otherwise change the output of the pages.\n #\n # This will match any URL except those that start with:\n #\n # * \/search\/\n # * \/account\/login\/\n # * \/account\/logout\/\n # * \/account\/register\/\n # * \/pypi\n if (req.url !~ \"^\/(search\/|account\/(login|logout|register)\/|pypi)\") {\n set req.url = req.url.path;\n }\n\n # Sort all of our query parameters, this will ensure that the same query\n # parameters in a different order will end up being represented as the same\n # thing, reducing cache misses due to ordering differences.\n set req.url = boltsort.sort(req.url);\n\n\n#FASTLY recv\n\n\n # We want to Force SSL for the WebUI by redirecting to the HTTPS version of\n # the page, however for API calls we want to return an error code directing\n # people to instead use HTTPS.\n if (!req.http.Fastly-SSL) {\n\n # The \/simple\/ and \/packages\/ API.\n if (req.url ~ \"^\/(simple|packages)\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy JSON API.\n if (req.url ~ \"^\/pypi\/.+\/json$\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy ?:action= API.\n if (req.url ~ \"^\/pypi.*(\\?|&)=:action\") {\n error 803 \"SSL is required\";\n }\n\n # If we're on the \/pypi page and we've received something other than a\n # GET or HEAD request, then we have no way to determine if a particular\n # request is an API call or not because it'll be in the request body\n # and that isn't available to us here. So in those cases, we won't\n # do a redirect.\n if (req.url ~ \"^\/pypi\") {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n error 801 \"Force SSL\";\n }\n }\n else {\n # This isn't a \/pypi URL so we'll just unconditionally redirect to\n # HTTPS.\n error 801 \"Force SSL\";\n }\n }\n\n # Canonicalize our domains by redirecting any domain that doesn't match our\n # primary domain to our primary domain. We do this *after* the HTTPS check\n # on purpose.\n if (std.tolower(req.http.host) != std.tolower(req.http.Primary-Domain)) {\n set req.http.Location = \"https:\/\/\" req.http.Primary-Domain req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n\n # Requests to \/packages\/ get dispatched to Amazon instead of to our typical\n # Origin. This requires a a bit of setup to make it work.\n if (req.url ~ \"^\/packages\/\") {\n # Setup our environment to better match what S3 expects\/needs\n set req.http.Host = req.http.AWS-Bucket-Name \".s3.amazonaws.com\";\n set req.http.Date = now;\n set req.url = regsuball(req.url, \"\\+\", urlencode(\"+\"));\n\n # Compute the Authorization header that S3 requires to be able to\n # access the files stored there.\n set req.http.Authorization = \"AWS \" req.http.AWS-Access-Key-ID \":\" digest.hmac_sha1_base64(req.http.AWS-Secret-Access-Key, \"GET\" LF LF LF req.http.Date LF \"\/\" req.http.AWS-Bucket-Name req.url.path);\n\n # We don't want to send our Warehouse-Token to S3, so we'll go ahead\n # and remove it.\n unset req.http.Warehouse-Token;\n }\n\n # We no longer need any of these variables, which would exist only to\n # shuffle configuration from the Fastly UI into our VCL.\n unset req.http.Primary-Domain;\n unset req.http.AWS-Access-Key-ID;\n unset req.http.AWS-Secret-Access-Key;\n unset req.http.AWS-Bucket-Name;\n\n # We have a number of items that we'll pass back to the origin, but only\n # if we have a Warehouse-Token that will allow them to be accepted.\n if (req.http.Warehouse-Token) {\n # Set a header to tell the backend if we're using https or http.\n if (req.http.Fastly-SSL) {\n set req.http.Warehouse-Proto = \"https\";\n } else {\n set req.http.Warehouse-Proto = \"http\";\n }\n\n # Pass the client IP address back to the backend.\n if (req.http.Fastly-Client-IP) {\n set req.http.Warehouse-IP = req.http.Fastly-Client-IP;\n }\n\n # Pass the real host value back to the backend.\n if (req.http.Host) {\n set req.http.Warehouse-Host = req.http.Host;\n }\n }\n\n # Do not bother to attempt to run the caching mechanisms for methods that\n # are not generally safe to cache.\n if (req.request != \"HEAD\" &&\n req.request != \"GET\" &&\n req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n # Finally, return the default lookup action.\n return(lookup);\n}\n\n\nsub vcl_fetch {\n\n # For any 5xx status code we want to see if a stale object exists for it,\n # if so we'll go ahead and serve it.\n if (beresp.status >= 500 && beresp.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n\n#FASTLY fetch\n\n\n # Trigger a \"SSL is required\" error if the backend has indicated to do so.\n if (beresp.http.X-Fastly-Error == \"803\") {\n error 803 \"SSL is required\";\n }\n\n # If we've gotten a 502 or a 503 from the backend, we'll go ahead and retry\n # the request.\n if ((beresp.status == 502 || beresp.status == 503) &&\n req.restarts < 1 &&\n (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n # If we've restarted, then we'll record the number of restarts.\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n # If there is a Set-Cookie header, we'll ensure that we do not cache the\n # response.\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n # If the response has the private Cache-Control directive then we won't\n # cache it.\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # If we've gotten an error after the restarts we'll deliver the response\n # with a very short cache time.\n if (http_status_matches(beresp.status, \"500,502,503\")) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n # Apply a default TTL if there isn't a max-age or s-maxage.\n if (beresp.http.Expires ||\n beresp.http.Surrogate-Control ~ \"max-age\" ||\n beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # Keep the ttl here\n }\n else {\n # Apply the default ttl\n set beresp.ttl = 60s;\n }\n\n # Actually deliver the fetched response.\n return(deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n # If the object we have isn't cacheable, then just serve it directly\n # without going through any of the caching mechanisms.\n if (!obj.cacheable) {\n return(pass);\n }\n\n return(deliver);\n}\n\n\nsub vcl_deliver {\n # If this is an error and we have a stale response available, restart so\n # that we can pick it up and serve it.\n if (resp.status >= 500 && resp.status < 600) {\n if (stale.exists) {\n restart;\n }\n }\n\n#FASTLY deliver\n\n # Unset headers that we don't need\/want to send on to the client because\n # they are not generally useful.\n unset resp.http.Server;\n unset resp.http.Via;\n\n # Unset a few headers set by Amazon that we don't really have a need\/desire\n # to send to clients.\n unset resp.http.X-AMZ-Replication-Status;\n unset resp.http.X-AMZ-Meta-Python-Version;\n unset resp.http.X-AMZ-Meta-Version;\n unset resp.http.X-AMZ-Meta-Package-Type;\n unset resp.http.X-AMZ-Meta-Project;\n\n # Set our standard security headers, we do this in VCL rather than in\n # Warehouse itself so that we always get these headers, regardless of the\n # origin server being used.\n set resp.http.Strict-Transport-Security = \"max-age=31536000; includeSubDomains; preload\";\n set resp.http.X-Frame-Options = \"deny\";\n set resp.http.X-XSS-Protection = \"1; mode=block\";\n set resp.http.X-Content-Type-Options = \"nosniff\";\n set resp.http.X-Permitted-Cross-Domain-Policies = \"none\";\n\n return(deliver);\n}\n\n\nsub vcl_error {\n#FASTLY error\n\n # If we have a 5xx error and there is a stale object available, then we\n # will deliver that stale object.\n if (obj.status >= 500 && obj.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n if (obj.status == 803) {\n set obj.status = 403;\n set obj.response = \"SSL is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic {\"SSL is required.\"};\n return (deliver);\n } else if (obj.status == 750) {\n set obj.status = 301;\n set obj.http.Location = req.http.Location;\n set obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n synthetic {\"<html><head><title>301 Moved Permanently<\/title><\/head><body><center><h1>301 Moved Permanently<\/h1><\/center><\/body><\/html>\"};\n return(deliver);\n }\n\n}\n","old_contents":"\nsub vcl_recv {\n\n # Some (Older) clients will send a hash fragment as part of the URL even\n # though that is a local only modification. This breaks this badly for the\n # files in S3, and in general it's just not needed.\n set req.url = regsub(req.url, \"#.*$\", \"\");\n\n # Most of the URLs in Warehouse do not support or require any sort of query\n # parameter. If we strip these at the edge then we'll increase our cache\n # efficiency when they won't otherwise change the output of the pages.\n #\n # This will match any URL except those that start with:\n #\n # * \/search\/\n # * \/account\/login\/\n # * \/account\/logout\/\n # * \/account\/register\/\n # * \/pypi\n if (req.url !~ \"^\/(search\/|account\/(login|logout|register)\/|pypi)\") {\n set req.url = req.url.path;\n }\n\n # Sort all of our query parameters, this will ensure that the same query\n # parameters in a different order will end up being represented as the same\n # thing, reducing cache misses due to ordering differences.\n set req.url = boltsort.sort(req.url);\n\n\n#FASTLY recv\n\n\n # We want to Force SSL for the WebUI by redirecting to the HTTPS version of\n # the page, however for API calls we want to return an error code directing\n # people to instead use HTTPS.\n if (!req.http.Fastly-SSL) {\n\n # The \/simple\/ and \/packages\/ API.\n if (req.url ~ \"^\/(simple|packages)\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy JSON API.\n if (req.url ~ \"^\/pypi\/.+\/json$\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy ?:action= API.\n if (req.url ~ \"^\/pypi.*(\\?|&)=:action\") {\n error 803 \"SSL is required\";\n }\n\n # If we're on the \/pypi page and we've received something other than a\n # GET or HEAD request, then we have no way to determine if a particular\n # request is an API call or not because it'll be in the request body\n # and that isn't available to us here. So in those cases, we won't\n # do a redirect.\n if (req.url ~ \"^\/pypi\") {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n error 801 \"Force SSL\";\n }\n }\n else {\n # This isn't a \/pypi URL so we'll just unconditionally redirect to\n # HTTPS.\n error 801 \"Force SSL\";\n }\n }\n\n # Canonicalize our domains by redirecting any domain that doesn't match our\n # primary domain to our primary domain. We do this *after* the HTTPS check\n # on purpose.\n if (std.tolower(req.http.host) != std.tolower(req.http.Primary-Domain)) {\n set req.http.Location = \"https:\/\/\" req.http.Primary-Domain req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n\n # Requests to \/packages\/ get dispatched to Amazon instead of to our typical\n # Origin. This requires a a bit of setup to make it work.\n if (req.url ~ \"^\/packages\/\") {\n # Setup our environment to better match what S3 expects\/needs\n set req.http.Host = req.http.AWS-Bucket-Name \".s3.amazonaws.com\";\n set req.http.Date = now;\n set req.url = regsuball(req.url, \"\\+\", urlencode(\"+\"));\n\n # Compute the Authorization header that S3 requires to be able to\n # access the files stored there.\n set req.http.Authorization = \"AWS \" req.http.AWS-Access-Key-ID \":\" digest.hmac_sha1_base64(req.http.AWS-Secret-Access-Key, \"GET\" LF LF LF req.http.Date LF \"\/\" req.http.AWS-Bucket-Name req.url.path);\n\n # We don't want to send our Warehouse-Token to S3, so we'll go ahead\n # and remove it.\n unset req.http.Warehouse-Token;\n }\n\n # We no longer need any of these variables, which would exist only to\n # shuffle configuration from the Fastly UI into our VCL.\n unset req.http.Primary-Domain;\n unset req.http.AWS-Access-Key-ID;\n unset req.http.AWS-Secret-Access-Key;\n unset req.http.AWS-Bucket-Name;\n\n # We have a number of items that we'll pass back to the origin, but only\n # if we have a Warehouse-Token that will allow them to be accepted.\n if (req.http.Warehouse-Token) {\n # Set a header to tell the backend if we're using https or http.\n if (req.http.Fastly-SSL) {\n set req.http.Warehouse-Proto = \"https\";\n } else {\n set req.http.Warehouse-Proto = \"http\";\n }\n\n # Pass the client IP address back to the backend.\n if (req.http.Fastly-Client-IP) {\n set req.http.Warehouse-IP = req.http.Fastly-Client-IP;\n }\n\n # Pass the real host value back to the backend.\n if (req.http.Host) {\n set req.http.Warehouse-Host = req.http.Host;\n }\n }\n\n # Do not bother to attempt to run the caching mechanisms for methods that\n # are not generally safe to cache.\n if (req.request != \"HEAD\" &&\n req.request != \"GET\" &&\n req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n # Finally, return the default lookup action.\n return(lookup);\n}\n\n\nsub vcl_fetch {\n#FASTLY fetch\n\n # Trigger a \"SSL is required\" error if the backend has indicated to do so.\n if (beresp.http.X-Fastly-Error == \"803\") {\n error 803 \"SSL is required\";\n }\n\n # If we've gotten a 502 or a 503 from the backend, we'll go ahead and retry\n # the request.\n if ((beresp.status == 502 || beresp.status == 503) &&\n req.restarts < 1 &&\n (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n # If we've restarted, then we'll record the number of restarts.\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n # If there is a Set-Cookie header, we'll ensure that we do not cache the\n # response.\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n # If the response has the private Cache-Control directive then we won't\n # cache it.\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # If we've gotten an error after the restarts we'll deliver the response\n # with a very short cache time.\n if (beresp.status == 500 || beresp.status == 503) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n # Apply a default TTL if there isn't a max-age or s-maxage.\n if (beresp.http.Expires ||\n beresp.http.Surrogate-Control ~ \"max-age\" ||\n beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # Keep the ttl here\n }\n else {\n # Apply the default ttl\n set beresp.ttl = 60s;\n }\n\n # Actually deliver the fetched response.\n return(deliver);\n}\n\n\nsub vcl_deliver {\n#FASTLY deliver\n\n # Unset headers that we don't need\/want to send on to the client because\n # they are not generally useful.\n unset resp.http.Server;\n unset resp.http.Via;\n\n # Unset a few headers set by Amazon that we don't really have a need\/desire\n # to send to clients.\n unset resp.http.X-AMZ-Replication-Status;\n unset resp.http.X-AMZ-Meta-Python-Version;\n unset resp.http.X-AMZ-Meta-Version;\n unset resp.http.X-AMZ-Meta-Package-Type;\n unset resp.http.X-AMZ-Meta-Project;\n\n # Set our standard security headers, we do this in VCL rather than in\n # Warehouse itself so that we always get these headers, regardless of the\n # origin server being used.\n set resp.http.Strict-Transport-Security = \"max-age=31536000; includeSubDomains; preload\";\n set resp.http.X-Frame-Options = \"deny\";\n set resp.http.X-XSS-Protection = \"1; mode=block\";\n set resp.http.X-Content-Type-Options = \"nosniff\";\n set resp.http.X-Permitted-Cross-Domain-Policies = \"none\";\n\n return(deliver);\n}\n\n\nsub vcl_error {\n#FASTLY error\n\n if (obj.status == 803) {\n set obj.status = 403;\n set obj.response = \"SSL is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic {\"SSL is required.\"};\n return (deliver);\n } else if (obj.status == 750) {\n set obj.status = 301;\n set obj.http.Location = req.http.Location;\n set obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n synthetic {\"<html><head><title>301 Moved Permanently<\/title><\/head><body><center><h1>301 Moved Permanently<\/h1><\/center><\/body><\/html>\"};\n return(deliver);\n }\n\n}\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"372f73bbc57a20f8d5fdf3f3cd455413b6dfcae4","subject":"Add a copyright notice and license information to the VCL file","message":"Add a copyright notice and license information to the VCL file\n","repos":"varnish\/varnish-devicedetect,kevinquinnyo\/varnish-devicedetect,wikp\/varnish-devicedetect,varnish\/varnish-devicedetect,wikp\/varnish-devicedetect,kevinquinnyo\/varnish-devicedetect","old_file":"devicedetect.vcl","new_file":"devicedetect.vcl","new_contents":"# Copyright (c) 2012-2013 Varnish Software AS\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions\n# are met:\n# 1. Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n# 2. Redistributions in binary form must reproduce the above copyright\n# notice, this list of conditions and the following disclaimer in the\n# documentation and\/or other materials provided with the distribution.\n#\n# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n# ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n# SUCH DAMAGE.\n#\n# detectdevice.vcl - regex based device detection for Varnish\n# http:\/\/github.com\/varnish\/varnish-devicedetect\/\n#\n# Author: Lasse Karstensen <lasse@varnish-software.com>\n\nsub devicedetect {\n\tunset req.http.X-UA-Device;\n\tset req.http.X-UA-Device = \"pc\";\n\n\t# Handle that a cookie may override the detection alltogether.\n\tif (req.http.Cookie ~ \"(?i)X-UA-Device-force\") {\n\t\t\/* ;?? means zero or one ;, non-greedy to match the first. *\/\n\t\tset req.http.X-UA-Device = regsub(req.http.Cookie, \"(?i).*X-UA-Device-force=([^;]+);??.*\", \"\\1\");\n\t\t\/* Clean up our mess in the cookie header *\/\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|; ) *X-UA-Device-force=[^;]+;? *\", \"\\1\");\n\t\t\/* If the cookie header is now empty, or just whitespace, unset it. *\/\n\t\tif (req.http.Cookie ~ \"^ *$\") { unset req.http.Cookie; }\n\t} else {\n\t\tif (req.http.User-Agent ~ \"(?i)(ads|google|bing|msn|yandex|baidu|ro|career|)bot\" ||\n\t\t req.http.User-Agent ~ \"(?i)(baidu|jike|symantec)spider\" ||\n\t\t req.http.User-Agent ~ \"(?i)scanner\" ||\n\t\t req.http.User-Agent ~ \"(?i)(web)crawler\") {\n\t\t\tset req.http.X-UA-Device = \"bot\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ipad\") { set req.http.X-UA-Device = \"tablet-ipad\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ip(hone|od)\") { set req.http.X-UA-Device = \"mobile-iphone\"; }\n\t\t\/* how do we differ between an android phone and an android tablet?\n\t\t http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent *\/\n\t\telsif (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") { set req.http.X-UA-Device = \"mobile-android\"; }\n\t\t\/\/ android 3\/honeycomb was just about tablet-only, and any phones will probably handle a bigger page layout.\n\t\telsif (req.http.User-Agent ~ \"(?i)android 3\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\t\/\/ May very well give false positives towards android tablets. Suggestions welcome.\n\t\telsif (req.http.User-Agent ~ \"(?i)android\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\telsif (req.http.User-Agent ~ \"Mobile.+Firefox\") { set req.http.X-UA-Device = \"mobile-firefoxos\"; }\n\t\telsif (req.http.User-Agent ~ \"^HTC\" ||\n\t\t req.http.User-Agent ~ \"Fennec\" ||\n\t\t req.http.User-Agent ~ \"IEMobile\" ||\n\t\t req.http.User-Agent ~ \"BlackBerry\" ||\n\t\t req.http.User-Agent ~ \"SymbianOS.*AppleWebKit\" ||\n\t\t req.http.User-Agent ~ \"Opera Mobi\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-smartphone\";\n\t\t}\n\t\telsif (req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)^sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)^nokia\" ||\n\t\t req.http.User-Agent ~ \"(?i)^samsung\" ||\n\t\t req.http.User-Agent ~ \"(?i)^lg\" ||\n\t\t req.http.User-Agent ~ \"(?i)bada\" ||\n\t\t req.http.User-Agent ~ \"(?i)blazer\" ||\n\t\t req.http.User-Agent ~ \"(?i)cellphone\" ||\n\t\t req.http.User-Agent ~ \"(?i)iemobile\" ||\n\t\t req.http.User-Agent ~ \"(?i)midp-2.0\" ||\n\t\t req.http.User-Agent ~ \"(?i)u990\" ||\n\t\t req.http.User-Agent ~ \"(?i)netfront\" ||\n\t\t req.http.User-Agent ~ \"(?i)opera mini\" ||\n\t\t req.http.User-Agent ~ \"(?i)palm\" ||\n\t\t req.http.User-Agent ~ \"(?i)nintendo wii\" ||\n\t\t req.http.User-Agent ~ \"(?i)playstation portable\" ||\n\t\t req.http.User-Agent ~ \"(?i)portalmmm\" ||\n\t\t req.http.User-Agent ~ \"(?i)proxinet\" ||\n\t\t req.http.User-Agent ~ \"(?i)sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)windows\\ ?ce\" ||\n\t\t req.http.User-Agent ~ \"(?i)winwap\" ||\n\t\t req.http.User-Agent ~ \"(?i)eudoraweb\" ||\n\t\t req.http.User-Agent ~ \"(?i)htc\" ||\n\t\t req.http.User-Agent ~ \"(?i)240x320\" ||\n\t\t req.http.User-Agent ~ \"(?i)avantgo\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-generic\";\n\t\t}\n\t}\n}\n","old_contents":"#\n# detectdevice.vcl - regex based device detection for Varnish\n# http:\/\/github.com\/varnish\/varnish-devicedetect\/\n#\n# Author: Lasse Karstensen <lasse@varnish-software.com>\n\nsub devicedetect {\n\tunset req.http.X-UA-Device;\n\tset req.http.X-UA-Device = \"pc\";\n\n\t# Handle that a cookie may override the detection alltogether.\n\tif (req.http.Cookie ~ \"(?i)X-UA-Device-force\") {\n\t\t\/* ;?? means zero or one ;, non-greedy to match the first. *\/\n\t\tset req.http.X-UA-Device = regsub(req.http.Cookie, \"(?i).*X-UA-Device-force=([^;]+);??.*\", \"\\1\");\n\t\t\/* Clean up our mess in the cookie header *\/\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|; ) *X-UA-Device-force=[^;]+;? *\", \"\\1\");\n\t\t\/* If the cookie header is now empty, or just whitespace, unset it. *\/\n\t\tif (req.http.Cookie ~ \"^ *$\") { unset req.http.Cookie; }\n\t} else {\n\t\tif (req.http.User-Agent ~ \"(?i)(ads|google|bing|msn|yandex|baidu|ro|career|)bot\" ||\n\t\t req.http.User-Agent ~ \"(?i)(baidu|jike|symantec)spider\" ||\n\t\t req.http.User-Agent ~ \"(?i)scanner\" ||\n\t\t req.http.User-Agent ~ \"(?i)(web)crawler\") {\n\t\t\tset req.http.X-UA-Device = \"bot\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ipad\") { set req.http.X-UA-Device = \"tablet-ipad\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ip(hone|od)\") { set req.http.X-UA-Device = \"mobile-iphone\"; }\n\t\t\/* how do we differ between an android phone and an android tablet?\n\t\t http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent *\/\n\t\telsif (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") { set req.http.X-UA-Device = \"mobile-android\"; }\n\t\t\/\/ android 3\/honeycomb was just about tablet-only, and any phones will probably handle a bigger page layout.\n\t\telsif (req.http.User-Agent ~ \"(?i)android 3\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\t\/\/ May very well give false positives towards android tablets. Suggestions welcome.\n\t\telsif (req.http.User-Agent ~ \"(?i)android\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\telsif (req.http.User-Agent ~ \"Mobile.+Firefox\") { set req.http.X-UA-Device = \"mobile-firefoxos\"; }\n\t\telsif (req.http.User-Agent ~ \"^HTC\" ||\n\t\t req.http.User-Agent ~ \"Fennec\" ||\n\t\t req.http.User-Agent ~ \"IEMobile\" ||\n\t\t req.http.User-Agent ~ \"BlackBerry\" ||\n\t\t req.http.User-Agent ~ \"SymbianOS.*AppleWebKit\" ||\n\t\t req.http.User-Agent ~ \"Opera Mobi\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-smartphone\";\n\t\t}\n\t\telsif (req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)^sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)^nokia\" ||\n\t\t req.http.User-Agent ~ \"(?i)^samsung\" ||\n\t\t req.http.User-Agent ~ \"(?i)^lg\" ||\n\t\t req.http.User-Agent ~ \"(?i)bada\" ||\n\t\t req.http.User-Agent ~ \"(?i)blazer\" ||\n\t\t req.http.User-Agent ~ \"(?i)cellphone\" ||\n\t\t req.http.User-Agent ~ \"(?i)iemobile\" ||\n\t\t req.http.User-Agent ~ \"(?i)midp-2.0\" ||\n\t\t req.http.User-Agent ~ \"(?i)u990\" ||\n\t\t req.http.User-Agent ~ \"(?i)netfront\" ||\n\t\t req.http.User-Agent ~ \"(?i)opera mini\" ||\n\t\t req.http.User-Agent ~ \"(?i)palm\" ||\n\t\t req.http.User-Agent ~ \"(?i)nintendo wii\" ||\n\t\t req.http.User-Agent ~ \"(?i)playstation portable\" ||\n\t\t req.http.User-Agent ~ \"(?i)portalmmm\" ||\n\t\t req.http.User-Agent ~ \"(?i)proxinet\" ||\n\t\t req.http.User-Agent ~ \"(?i)sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)windows\\ ?ce\" ||\n\t\t req.http.User-Agent ~ \"(?i)winwap\" ||\n\t\t req.http.User-Agent ~ \"(?i)eudoraweb\" ||\n\t\t req.http.User-Agent ~ \"(?i)htc\" ||\n\t\t req.http.User-Agent ~ \"(?i)240x320\" ||\n\t\t req.http.User-Agent ~ \"(?i)avantgo\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-generic\";\n\t\t}\n\t}\n}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"13367353c41012d101383e396bb57640c06b3c6c","subject":"Don't need X-hash-input any more","message":"Don't need X-hash-input any more\n","repos":"wikp\/varnish-devicedetect,kevinquinnyo\/varnish-devicedetect,varnish\/varnish-devicedetect,wikp\/varnish-devicedetect,varnish\/varnish-devicedetect,kevinquinnyo\/varnish-devicedetect","old_file":"devicedetect.vcl","new_file":"devicedetect.vcl","new_contents":"#\n# detectdevice.vcl - regex based device detection for Varnish\n# http:\/\/github.com\/lkarsten\/varnish-devicedetect\/\n#\n# Author: Lasse Karstensen <lasse@varnish-software.com>\n\nsub devicedetect {\n unset req.http.X-UA-Device;\n set req.http.X-UA-Device = \"pc\";\n\n if (req.http.User-Agent ~ \"(?i)ip(hone|od)\") { set req.http.X-UA-Device = \"mobile-iphone\"; }\n elsif (req.http.User-Agent ~ \"(?i)ipad\") { set req.http.X-UA-Device = \"tablet-ipad\"; }\n # how do we differ between an android phone and an android tablet?\n # http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent\n elsif (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") { set req.http.X-UA-Device = \"mobile-android\"; } \n # android 3\/honeycomb was just about tablet-only, and any phones will probably handle a bigger page layout.\n elsif (req.http.User-Agent ~ \"(?i)android 3\") { set req.http.X-UA-Device = \"tablet-android\"; }\n # may very well give false positives towards android tablets. Suggestions welcome.\n elsif (req.http.User-Agent ~ \"(?i)android\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\n elsif (req.http.User-Agent ~ \"^HTC\" ||\n req.http.User-Agent ~ \"Fennec\" || \n req.http.User-Agent ~ \"IEMobile\" ||\n req.http.User-Agent ~ \"BlackBerry\" ||\n req.http.User-Agent ~ \"SymbianOS.*AppleWebKit\" ||\n req.http.User-Agent ~ \"Opera Mobi\") {\n set req.http.X-UA-Device = \"mobile-smartphone\";\n }\n elsif (req.http.User-Agent ~ \"(?i)symbian\" ||\n req.http.User-Agent ~ \"(?i)^sonyericsson\" ||\n req.http.User-Agent ~ \"(?i)^nokia\" ||\n req.http.User-Agent ~ \"(?i)^samsung\" ||\n req.http.User-Agent ~ \"(?i)^lg\" ||\n\treq.http.User-Agent ~ \"(?i)bada\" ||\n\treq.http.User-Agent ~ \"(?i)blazer\" ||\n\treq.http.User-Agent ~ \"(?i)cellphone\" ||\n\treq.http.User-Agent ~ \"(?i)iemobile\" ||\n\treq.http.User-Agent ~ \"(?i)midp-2.0\" ||\n\treq.http.User-Agent ~ \"(?i)u990\" ||\n\treq.http.User-Agent ~ \"(?i)netfront\" ||\n\treq.http.User-Agent ~ \"(?i)opera mini\" ||\n\treq.http.User-Agent ~ \"(?i)palm\" ||\n\treq.http.User-Agent ~ \"(?i)nintendo wii\" ||\n\treq.http.User-Agent ~ \"(?i)playstation portable\" ||\n\treq.http.User-Agent ~ \"(?i)portalmmm\" ||\n\treq.http.User-Agent ~ \"(?i)proxinet\" ||\n\treq.http.User-Agent ~ \"(?i)sonyericsson\" ||\n\treq.http.User-Agent ~ \"(?i)symbian\" ||\n\treq.http.User-Agent ~ \"(?i)windows\\ ?ce\" ||\n\treq.http.User-Agent ~ \"(?i)winwap\" ||\n\treq.http.User-Agent ~ \"(?i)eudoraweb\" ||\n\treq.http.User-Agent ~ \"(?i)htc\" ||\n\treq.http.User-Agent ~ \"(?i)240x320\" ||\n\treq.http.User-Agent ~ \"(?i)avantgo\") { \n set req.http.X-UA-Device = \"mobile-generic\";\n }\n\n # handle overrides\n if (req.http.Cookie ~ \"(i?)X-UA-Device-force\") {\n # ;?? means zero or one ;, non-greedy to match the first.\n set req.http.X-UA-Device = regsub(req.http.Cookie, \"(?i).*X-UA-Device-force=([^;]+);??.*\", \"\\1\");\n }\n}\n\n# vim: sw=4:tw=120 # meh\n","old_contents":"#\n# detectdevice.vcl - regex based device detection for Varnish\n# http:\/\/github.com\/lkarsten\/varnish-devicedetect\/\n#\n# Author: Lasse Karstensen <lasse@varnish-software.com>\n\nsub devicedetect {\n unset req.http.X-hash-input;\n unset req.http.X-UA-Device;\n set req.http.X-UA-Device = \"pc\";\n\n if (req.http.User-Agent ~ \"(?i)ip(hone|od)\") { set req.http.X-UA-Device = \"mobile-iphone\"; }\n elsif (req.http.User-Agent ~ \"(?i)ipad\") { set req.http.X-UA-Device = \"tablet-ipad\"; }\n # how do we differ between an android phone and an android tablet?\n # http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent\n elsif (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") { set req.http.X-UA-Device = \"mobile-android\"; } \n # android 3\/honeycomb was just about tablet-only, and any phones will probably handle a bigger page layout.\n elsif (req.http.User-Agent ~ \"(?i)android 3\") { set req.http.X-UA-Device = \"tablet-android\"; }\n # may very well give false positives towards android tablets. Suggestions welcome.\n elsif (req.http.User-Agent ~ \"(?i)android\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\n elsif (req.http.User-Agent ~ \"^HTC\" ||\n req.http.User-Agent ~ \"Fennec\" || \n req.http.User-Agent ~ \"IEMobile\" ||\n req.http.User-Agent ~ \"BlackBerry\" ||\n req.http.User-Agent ~ \"SymbianOS.*AppleWebKit\" ||\n req.http.User-Agent ~ \"Opera Mobi\") {\n set req.http.X-UA-Device = \"mobile-smartphone\";\n }\n elsif (req.http.User-Agent ~ \"(?i)symbian\" ||\n req.http.User-Agent ~ \"(?i)^sonyericsson\" ||\n req.http.User-Agent ~ \"(?i)^nokia\" ||\n req.http.User-Agent ~ \"(?i)^samsung\" ||\n req.http.User-Agent ~ \"(?i)^lg\" ||\n\treq.http.User-Agent ~ \"(?i)bada\" ||\n\treq.http.User-Agent ~ \"(?i)blazer\" ||\n\treq.http.User-Agent ~ \"(?i)cellphone\" ||\n\treq.http.User-Agent ~ \"(?i)iemobile\" ||\n\treq.http.User-Agent ~ \"(?i)midp-2.0\" ||\n\treq.http.User-Agent ~ \"(?i)u990\" ||\n\treq.http.User-Agent ~ \"(?i)netfront\" ||\n\treq.http.User-Agent ~ \"(?i)opera mini\" ||\n\treq.http.User-Agent ~ \"(?i)palm\" ||\n\treq.http.User-Agent ~ \"(?i)nintendo wii\" ||\n\treq.http.User-Agent ~ \"(?i)playstation portable\" ||\n\treq.http.User-Agent ~ \"(?i)portalmmm\" ||\n\treq.http.User-Agent ~ \"(?i)proxinet\" ||\n\treq.http.User-Agent ~ \"(?i)sonyericsson\" ||\n\treq.http.User-Agent ~ \"(?i)symbian\" ||\n\treq.http.User-Agent ~ \"(?i)windows\\ ?ce\" ||\n\treq.http.User-Agent ~ \"(?i)winwap\" ||\n\treq.http.User-Agent ~ \"(?i)eudoraweb\" ||\n\treq.http.User-Agent ~ \"(?i)htc\" ||\n\treq.http.User-Agent ~ \"(?i)240x320\" ||\n\treq.http.User-Agent ~ \"(?i)avantgo\") { \n set req.http.X-UA-Device = \"mobile-generic\";\n }\n\n # handle overrides\n if (req.http.Cookie ~ \"(i?)X-UA-Device-force\") {\n # ;?? means zero or one ;, non-greedy to match the first.\n set req.http.X-UA-Device = regsub(req.http.Cookie, \"(?i).*X-UA-Device-force=([^;]+);??.*\", \"\\1\");\n }\n set req.http.X-hash-input = req.http.X-UA-Device;\n}\n\n# vim: sw=4:tw=120 # meh\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"9f490718ad317ef39597ccdcdd2f20bb4a59f442","subject":"Increase cache efficiency by sorting url params","message":"Increase cache efficiency by sorting url params\n","repos":"dstufft\/warehouse,karan\/warehouse,wlonk\/warehouse,pypa\/warehouse,alex\/warehouse,wlonk\/warehouse,dstufft\/warehouse,pypa\/warehouse,alex\/warehouse,alex\/warehouse,dstufft\/warehouse,alex\/warehouse,pypa\/warehouse,dstufft\/warehouse,karan\/warehouse,pypa\/warehouse,karan\/warehouse,alex\/warehouse,wlonk\/warehouse,karan\/warehouse,karan\/warehouse","old_file":"vcl\/main.vcl","new_file":"vcl\/main.vcl","new_contents":"\nsub vcl_recv {\n\n # Some (Older) clients will send a hash fragment as part of the URL even\n # though that is a local only modification. This breaks this badly for the\n # files in S3, and in general it's just not needed.\n set req.url = regsub(req.url, \"#.*$\", \"\");\n\n # Sort all of our query parameters, this will ensure that the same query\n # parameters in a different order will end up being represented as the same\n # thing, reducing cache misses due to ordering differences.\n set req.url = boltsort.sort(req.url);\n\n\n#FASTLY recv\n\n\n # We want to Force SSL for the WebUI by redirecting to the HTTPS version of\n # the page, however for API calls we want to return an error code directing\n # people to instead use HTTPS.\n if (!req.http.Fastly-SSL) {\n\n # The \/simple\/ and \/packages\/ API.\n if (req.url ~ \"^\/(simple|packages)\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy JSON API.\n if (req.url ~ \"^\/pypi\/.+\/json$\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy ?:action= API.\n if (req.url ~ \"^\/pypi.*(\\?|&)=:action\") {\n error 803 \"SSL is required\";\n }\n\n # If we're on the \/pypi page and we've received something other than a\n # GET or HEAD request, then we have no way to determine if a particular\n # request is an API call or not because it'll be in the request body\n # and that isn't available to us here. So in those cases, we won't\n # do a redirect.\n if (req.url ~ \"^\/pypi\") {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n error 801 \"Force SSL\";\n }\n }\n else {\n # This isn't a \/pypi URL so we'll just unconditionally redirect to\n # HTTPS.\n error 801 \"Force SSL\";\n }\n }\n\n # Canonicalize our domains by redirecting any domain that doesn't match our\n # primary domain to our primary domain. We do this *after* the HTTPS check\n # on purpose.\n if (std.tolower(req.http.host) != std.tolower(req.http.Primary-Domain)) {\n set req.http.Location = \"https:\/\/\" req.http.Primary-Domain req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n\n # Requests to \/packages\/ get dispatched to Amazon instead of to our typical\n # Origin. This requires a a bit of setup to make it work.\n if (req.url ~ \"^\/packages\/\") {\n # Setup our environment to better match what S3 expects\/needs\n set req.http.Host = req.http.AWS-Bucket-Name \".s3.amazonaws.com\";\n set req.http.Date = now;\n set req.url = regsuball(req.url, \"\\+\", urlencode(\"+\"));\n\n # Compute the Authorization header that S3 requires to be able to\n # access the files stored there.\n set req.http.Authorization = \"AWS \" req.http.AWS-Access-Key-ID \":\" digest.hmac_sha1_base64(req.http.AWS-Secret-Access-Key, \"GET\" LF LF LF req.http.Date LF \"\/\" req.http.AWS-Bucket-Name req.url.path);\n\n # We don't want to send our Warehouse-Token to S3, so we'll go ahead\n # and remove it.\n unset req.http.Warehouse-Token;\n }\n\n # We no longer need any of these variables, which would exist only to\n # shuffle configuration from the Fastly UI into our VCL.\n unset req.http.Primary-Domain;\n unset req.http.AWS-Access-Key-ID;\n unset req.http.AWS-Secret-Access-Key;\n unset req.http.AWS-Bucket-Name;\n\n # We have a number of items that we'll pass back to the origin, but only\n # if we have a Warehouse-Token that will allow them to be accepted.\n if (req.http.Warehouse-Token) {\n # Set a header to tell the backend if we're using https or http.\n if (req.http.Fastly-SSL) {\n set req.http.Warehouse-Proto = \"https\";\n } else {\n set req.http.Warehouse-Proto = \"http\";\n }\n\n # Pass the client IP address back to the backend.\n if (req.http.Fastly-Client-IP) {\n set req.http.Warehouse-IP = req.http.Fastly-Client-IP;\n }\n\n # Pass the real host value back to the backend.\n if (req.http.Host) {\n set req.http.Warehouse-Host = req.http.Host;\n }\n }\n\n # Do not bother to attempt to run the caching mechanisms for methods that\n # are not generally safe to cache.\n if (req.request != \"HEAD\" &&\n req.request != \"GET\" &&\n req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n # Finally, return the default lookup action.\n return(lookup);\n}\n\n\nsub vcl_fetch {\n#FASTLY fetch\n\n # Trigger a \"SSL is required\" error if the backend has indicated to do so.\n if (beresp.http.X-Fastly-Error == \"803\") {\n error 803 \"SSL is required\";\n }\n\n # If we've gotten a 502 or a 503 from the backend, we'll go ahead and retry\n # the request.\n if ((beresp.status == 502 || beresp.status == 503) &&\n req.restarts < 1 &&\n (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n # If we've restarted, then we'll record the number of restarts.\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n # If there is a Set-Cookie header, we'll ensure that we do not cache the\n # response.\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n # If the response has the private Cache-Control directive then we won't\n # cache it.\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # If we've gotten an error after the restarts we'll deliver the response\n # with a very short cache time.\n if (beresp.status == 500 || beresp.status == 503) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n # Apply a default TTL if there isn't a max-age or s-maxage.\n if (beresp.http.Expires ||\n beresp.http.Surrogate-Control ~ \"max-age\" ||\n beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # Keep the ttl here\n }\n else {\n # Apply the default ttl\n set beresp.ttl = 60s;\n }\n\n # Actually deliver the fetched response.\n return(deliver);\n}\n\n\nsub vcl_deliver {\n#FASTLY deliver\n\n # Unset headers that we don't need\/want to send on to the client because\n # they are not generally useful.\n unset resp.http.Server;\n unset resp.http.Via;\n\n # Unset a few headers set by Amazon that we don't really have a need\/desire\n # to send to clients.\n unset resp.http.X-AMZ-Replication-Status;\n unset resp.http.X-AMZ-Meta-Python-Version;\n unset resp.http.X-AMZ-Meta-Version;\n unset resp.http.X-AMZ-Meta-Package-Type;\n unset resp.http.X-AMZ-Meta-Project;\n\n # Set our standard security headers, we do this in VCL rather than in\n # Warehouse itself so that we always get these headers, regardless of the\n # origin server being used.\n set resp.http.Strict-Transport-Security = \"max-age=31536000; includeSubDomains; preload\";\n set resp.http.X-Frame-Options = \"deny\";\n set resp.http.X-XSS-Protection = \"1; mode=block\";\n set resp.http.X-Content-Type-Options = \"nosniff\";\n set resp.http.X-Permitted-Cross-Domain-Policies = \"none\";\n\n return(deliver);\n}\n\n\nsub vcl_error {\n#FASTLY error\n\n if (obj.status == 803) {\n set obj.status = 403;\n set obj.response = \"SSL is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic {\"SSL is required.\"};\n return (deliver);\n } else if (obj.status == 750) {\n set obj.status = 301;\n set obj.http.Location = req.http.Location;\n set obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n synthetic {\"<html><head><title>301 Moved Permanently<\/title><\/head><body><center><h1>301 Moved Permanently<\/h1><\/center><\/body><\/html>\"};\n return(deliver);\n }\n\n}\n","old_contents":"\nsub vcl_recv {\n\n # Some (Older) clients will send a hash fragment as part of the URL even\n # though that is a local only modification. This breaks this badly for the\n # files in S3, and in general it's just not needed.\n set req.url = regsub(req.url, \"#.*$\", \"\");\n\n\n#FASTLY recv\n\n\n # We want to Force SSL for the WebUI by redirecting to the HTTPS version of\n # the page, however for API calls we want to return an error code directing\n # people to instead use HTTPS.\n if (!req.http.Fastly-SSL) {\n\n # The \/simple\/ and \/packages\/ API.\n if (req.url ~ \"^\/(simple|packages)\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy JSON API.\n if (req.url ~ \"^\/pypi\/.+\/json$\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy ?:action= API.\n if (req.url ~ \"^\/pypi.*(\\?|&)=:action\") {\n error 803 \"SSL is required\";\n }\n\n # If we're on the \/pypi page and we've received something other than a\n # GET or HEAD request, then we have no way to determine if a particular\n # request is an API call or not because it'll be in the request body\n # and that isn't available to us here. So in those cases, we won't\n # do a redirect.\n if (req.url ~ \"^\/pypi\") {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n error 801 \"Force SSL\";\n }\n }\n else {\n # This isn't a \/pypi URL so we'll just unconditionally redirect to\n # HTTPS.\n error 801 \"Force SSL\";\n }\n }\n\n # Canonicalize our domains by redirecting any domain that doesn't match our\n # primary domain to our primary domain. We do this *after* the HTTPS check\n # on purpose.\n if (std.tolower(req.http.host) != std.tolower(req.http.Primary-Domain)) {\n set req.http.Location = \"https:\/\/\" req.http.Primary-Domain req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n\n # Requests to \/packages\/ get dispatched to Amazon instead of to our typical\n # Origin. This requires a a bit of setup to make it work.\n if (req.url ~ \"^\/packages\/\") {\n # Setup our environment to better match what S3 expects\/needs\n set req.http.Host = req.http.AWS-Bucket-Name \".s3.amazonaws.com\";\n set req.http.Date = now;\n set req.url = regsuball(req.url, \"\\+\", urlencode(\"+\"));\n\n # Compute the Authorization header that S3 requires to be able to\n # access the files stored there.\n set req.http.Authorization = \"AWS \" req.http.AWS-Access-Key-ID \":\" digest.hmac_sha1_base64(req.http.AWS-Secret-Access-Key, \"GET\" LF LF LF req.http.Date LF \"\/\" req.http.AWS-Bucket-Name req.url.path);\n\n # We don't want to send our Warehouse-Token to S3, so we'll go ahead\n # and remove it.\n unset req.http.Warehouse-Token;\n }\n\n # We no longer need any of these variables, which would exist only to\n # shuffle configuration from the Fastly UI into our VCL.\n unset req.http.Primary-Domain;\n unset req.http.AWS-Access-Key-ID;\n unset req.http.AWS-Secret-Access-Key;\n unset req.http.AWS-Bucket-Name;\n\n # We have a number of items that we'll pass back to the origin, but only\n # if we have a Warehouse-Token that will allow them to be accepted.\n if (req.http.Warehouse-Token) {\n # Set a header to tell the backend if we're using https or http.\n if (req.http.Fastly-SSL) {\n set req.http.Warehouse-Proto = \"https\";\n } else {\n set req.http.Warehouse-Proto = \"http\";\n }\n\n # Pass the client IP address back to the backend.\n if (req.http.Fastly-Client-IP) {\n set req.http.Warehouse-IP = req.http.Fastly-Client-IP;\n }\n\n # Pass the real host value back to the backend.\n if (req.http.Host) {\n set req.http.Warehouse-Host = req.http.Host;\n }\n }\n\n # Do not bother to attempt to run the caching mechanisms for methods that\n # are not generally safe to cache.\n if (req.request != \"HEAD\" &&\n req.request != \"GET\" &&\n req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n # Finally, return the default lookup action.\n return(lookup);\n}\n\n\nsub vcl_fetch {\n#FASTLY fetch\n\n # Trigger a \"SSL is required\" error if the backend has indicated to do so.\n if (beresp.http.X-Fastly-Error == \"803\") {\n error 803 \"SSL is required\";\n }\n\n # If we've gotten a 502 or a 503 from the backend, we'll go ahead and retry\n # the request.\n if ((beresp.status == 502 || beresp.status == 503) &&\n req.restarts < 1 &&\n (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n # If we've restarted, then we'll record the number of restarts.\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n # If there is a Set-Cookie header, we'll ensure that we do not cache the\n # response.\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n # If the response has the private Cache-Control directive then we won't\n # cache it.\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # If we've gotten an error after the restarts we'll deliver the response\n # with a very short cache time.\n if (beresp.status == 500 || beresp.status == 503) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n # Apply a default TTL if there isn't a max-age or s-maxage.\n if (beresp.http.Expires ||\n beresp.http.Surrogate-Control ~ \"max-age\" ||\n beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # Keep the ttl here\n }\n else {\n # Apply the default ttl\n set beresp.ttl = 60s;\n }\n\n # Actually deliver the fetched response.\n return(deliver);\n}\n\n\nsub vcl_deliver {\n#FASTLY deliver\n\n # Unset headers that we don't need\/want to send on to the client because\n # they are not generally useful.\n unset resp.http.Server;\n unset resp.http.Via;\n\n # Unset a few headers set by Amazon that we don't really have a need\/desire\n # to send to clients.\n unset resp.http.X-AMZ-Replication-Status;\n unset resp.http.X-AMZ-Meta-Python-Version;\n unset resp.http.X-AMZ-Meta-Version;\n unset resp.http.X-AMZ-Meta-Package-Type;\n unset resp.http.X-AMZ-Meta-Project;\n\n # Set our standard security headers, we do this in VCL rather than in\n # Warehouse itself so that we always get these headers, regardless of the\n # origin server being used.\n set resp.http.Strict-Transport-Security = \"max-age=31536000; includeSubDomains; preload\";\n set resp.http.X-Frame-Options = \"deny\";\n set resp.http.X-XSS-Protection = \"1; mode=block\";\n set resp.http.X-Content-Type-Options = \"nosniff\";\n set resp.http.X-Permitted-Cross-Domain-Policies = \"none\";\n\n return(deliver);\n}\n\n\nsub vcl_error {\n#FASTLY error\n\n if (obj.status == 803) {\n set obj.status = 403;\n set obj.response = \"SSL is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic {\"SSL is required.\"};\n return (deliver);\n } else if (obj.status == 750) {\n set obj.status = 301;\n set obj.http.Location = req.http.Location;\n set obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n synthetic {\"<html><head><title>301 Moved Permanently<\/title><\/head><body><center><h1>301 Moved Permanently<\/h1><\/center><\/body><\/html>\"};\n return(deliver);\n }\n\n}\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"2e07b6e18dbdd1fc2186205de0904211f264d241","subject":"Restore the warehouse(-staging).python.org redirects","message":"Restore the warehouse(-staging).python.org redirects\n","repos":"pypa\/warehouse,karan\/warehouse,karan\/warehouse,wlonk\/warehouse,wlonk\/warehouse,pypa\/warehouse,wlonk\/warehouse,dstufft\/warehouse,alex\/warehouse,alex\/warehouse,karan\/warehouse,alex\/warehouse,dstufft\/warehouse,karan\/warehouse,alex\/warehouse,karan\/warehouse,dstufft\/warehouse,pypa\/warehouse,alex\/warehouse,pypa\/warehouse,dstufft\/warehouse","old_file":"vcl\/main.vcl","new_file":"vcl\/main.vcl","new_contents":"\nsub vcl_recv {\n\n # I'm not 100% sure on what this is exactly for, it was taken from the\n # Fastly documentation, however, what I *believe* it does is just ensure\n # that we don't serve a stale copy of the page from the shield node when\n # an edge node is requesting content.\n if (req.http.Fastly-FF) {\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Some (Older) clients will send a hash fragment as part of the URL even\n # though that is a local only modification. This breaks this badly for the\n # files in S3, and in general it's just not needed.\n set req.url = regsub(req.url, \"#.*$\", \"\");\n\n # Most of the URLs in Warehouse do not support or require any sort of query\n # parameter. If we strip these at the edge then we'll increase our cache\n # efficiency when they won't otherwise change the output of the pages.\n #\n # This will match any URL except those that start with:\n #\n # * \/search\/\n # * \/account\/login\/\n # * \/account\/logout\/\n # * \/account\/register\/\n # * \/pypi\n if (req.url !~ \"^\/(search\/|account\/(login|logout|register)\/|pypi)\") {\n set req.url = req.url.path;\n }\n\n # Sort all of our query parameters, this will ensure that the same query\n # parameters in a different order will end up being represented as the same\n # thing, reducing cache misses due to ordering differences.\n set req.url = boltsort.sort(req.url);\n\n\n#FASTLY recv\n\n\n # We want to Force SSL for the WebUI by redirecting to the HTTPS version of\n # the page, however for API calls we want to return an error code directing\n # people to instead use HTTPS.\n if (!req.http.Fastly-SSL) {\n\n # The \/simple\/ and \/packages\/ API.\n if (req.url ~ \"^\/(simple|packages)\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy JSON API.\n if (req.url ~ \"^\/pypi\/.+\/json$\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy ?:action= API.\n if (req.url ~ \"^\/pypi.*(\\?|&)=:action\") {\n error 803 \"SSL is required\";\n }\n\n # If we're on the \/pypi page and we've received something other than a\n # GET or HEAD request, then we have no way to determine if a particular\n # request is an API call or not because it'll be in the request body\n # and that isn't available to us here. So in those cases, we won't\n # do a redirect.\n if (req.url ~ \"^\/pypi\") {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n error 801 \"Force SSL\";\n }\n }\n else {\n # This isn't a \/pypi URL so we'll just unconditionally redirect to\n # HTTPS.\n error 801 \"Force SSL\";\n }\n }\n\n # Redirect www.pypi.io and warehouse.python.org to pypi.io, this is\n # purposely done *after* the HTTPS checks.\n if (std.tolower(req.http.host) ~ \"^(www.pypi.io|warehouse.python.org)$\") {\n set req.http.Location = \"https:\/\/pypi.io\" req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n # Redirect warehouse-staging.python.org to test.pypi.io.\n if (std.tolower(req.http.host) == \"warehouse-staging.python.org\") {\n set req.http.Location = \"https:\/\/test.pypi.io\" req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n\n # Requests to \/packages\/ get dispatched to Amazon instead of to our typical\n # Origin. This requires a a bit of setup to make it work.\n if (req.http.host ~ \"^(test-)?files.pythonhosted.org$\"\n && req.url ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\") {\n # Setup our environment to better match what S3 expects\/needs\n set req.http.Host = req.http.AWS-Bucket-Name \".s3.amazonaws.com\";\n set req.http.Date = now;\n set req.url = regsuball(req.url, \"\\+\", urlencode(\"+\"));\n\n # Compute the Authorization header that S3 requires to be able to\n # access the files stored there.\n set req.http.Authorization = \"AWS \" req.http.AWS-Access-Key-ID \":\" digest.hmac_sha1_base64(req.http.AWS-Secret-Access-Key, \"GET\" LF LF LF req.http.Date LF \"\/\" req.http.AWS-Bucket-Name req.url.path);\n\n # We don't want to send our Warehouse-Token to S3, so we'll go ahead\n # and remove it.\n unset req.http.Warehouse-Token;\n }\n\n # We no longer need any of these variables, which would exist only to\n # shuffle configuration from the Fastly UI into our VCL.\n unset req.http.AWS-Access-Key-ID;\n unset req.http.AWS-Secret-Access-Key;\n unset req.http.AWS-Bucket-Name;\n\n # We have a number of items that we'll pass back to the origin, but only\n # if we have a Warehouse-Token that will allow them to be accepted.\n if (req.http.Warehouse-Token) {\n # Set a header to tell the backend if we're using https or http.\n if (req.http.Fastly-SSL) {\n set req.http.Warehouse-Proto = \"https\";\n } else {\n set req.http.Warehouse-Proto = \"http\";\n }\n\n # Pass the client IP address back to the backend.\n if (req.http.Fastly-Client-IP) {\n set req.http.Warehouse-IP = req.http.Fastly-Client-IP;\n }\n\n # Pass the real host value back to the backend.\n if (req.http.Host) {\n set req.http.Warehouse-Host = req.http.host;\n }\n }\n\n # On a POST, we want to skip the shielding and hit backends directly.\n if (req.request == \"POST\") {\n set req.backend = F_Heroku;\n }\n\n # Do not bother to attempt to run the caching mechanisms for methods that\n # are not generally safe to cache.\n if (req.request != \"HEAD\" &&\n req.request != \"GET\" &&\n req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n # We don't ever want to cache our health URL. Outside systems should be\n # able to use it to reach past Fastly and get an end to end health check.\n if (req.url == \"\/_health\/\") {\n return(pass);\n }\n\n # Finally, return the default lookup action.\n return(lookup);\n}\n\n\nsub vcl_fetch {\n\n # These are newer kinds of redirects which should be able to be cached by\n # default, even though Fastly doesn't currently have them in their default\n # list of cacheable status codes.\n if (http_status_matches(beresp.status, \"303,307,308\")) {\n set beresp.cacheable = true;\n }\n\n # For any 5xx status code we want to see if a stale object exists for it,\n # if so we'll go ahead and serve it.\n if (beresp.status >= 500 && beresp.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n\n#FASTLY fetch\n\n\n # Trigger a \"SSL is required\" error if the backend has indicated to do so.\n if (beresp.http.X-Fastly-Error == \"803\") {\n error 803 \"SSL is required\";\n }\n\n # If we've gotten a 502 or a 503 from the backend, we'll go ahead and retry\n # the request.\n if ((beresp.status == 502 || beresp.status == 503) &&\n req.restarts < 1 &&\n (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n # If we've restarted, then we'll record the number of restarts.\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n # If there is a Set-Cookie header, we'll ensure that we do not cache the\n # response.\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n # If the response has the private Cache-Control directive then we won't\n # cache it.\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # If we've gotten an error after the restarts we'll deliver the response\n # with a very short cache time.\n if (http_status_matches(beresp.status, \"500,502,503\")) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n # Apply a default TTL if there isn't a max-age or s-maxage.\n if (beresp.http.Expires ||\n beresp.http.Surrogate-Control ~ \"max-age\" ||\n beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # Keep the ttl here\n }\n else {\n # Apply the default ttl\n set beresp.ttl = 60s;\n }\n\n # Actually deliver the fetched response.\n return(deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n # If the object we have isn't cacheable, then just serve it directly\n # without going through any of the caching mechanisms.\n if (!obj.cacheable) {\n return(pass);\n }\n\n return(deliver);\n}\n\n\nsub vcl_deliver {\n # If this is an error and we have a stale response available, restart so\n # that we can pick it up and serve it.\n if (resp.status >= 500 && resp.status < 600) {\n if (stale.exists) {\n restart;\n }\n }\n\n#FASTLY deliver\n\n # Unset headers that we don't need\/want to send on to the client because\n # they are not generally useful.\n unset resp.http.Server;\n unset resp.http.Via;\n\n # Unset a few headers set by Amazon that we don't really have a need\/desire\n # to send to clients.\n unset resp.http.X-AMZ-Replication-Status;\n unset resp.http.X-AMZ-Meta-Python-Version;\n unset resp.http.X-AMZ-Meta-Version;\n unset resp.http.X-AMZ-Meta-Package-Type;\n unset resp.http.X-AMZ-Meta-Project;\n\n # Set our standard security headers, we do this in VCL rather than in\n # Warehouse itself so that we always get these headers, regardless of the\n # origin server being used.\n set resp.http.Strict-Transport-Security = \"max-age=31536000; includeSubDomains; preload\";\n set resp.http.X-Frame-Options = \"deny\";\n set resp.http.X-XSS-Protection = \"1; mode=block\";\n set resp.http.X-Content-Type-Options = \"nosniff\";\n set resp.http.X-Permitted-Cross-Domain-Policies = \"none\";\n\n return(deliver);\n}\n\n\nsub vcl_error {\n#FASTLY error\n\n # If we have a 5xx error and there is a stale object available, then we\n # will deliver that stale object.\n if (obj.status >= 500 && obj.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n if (obj.status == 803) {\n set obj.status = 403;\n set obj.response = \"SSL is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic {\"SSL is required.\"};\n return (deliver);\n } else if (obj.status == 750) {\n set obj.status = 301;\n set obj.http.Location = req.http.Location;\n set obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n synthetic {\"<html><head><title>301 Moved Permanently<\/title><\/head><body><center><h1>301 Moved Permanently<\/h1><\/center><\/body><\/html>\"};\n return(deliver);\n }\n\n}\n","old_contents":"\nsub vcl_recv {\n\n # I'm not 100% sure on what this is exactly for, it was taken from the\n # Fastly documentation, however, what I *believe* it does is just ensure\n # that we don't serve a stale copy of the page from the shield node when\n # an edge node is requesting content.\n if (req.http.Fastly-FF) {\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Some (Older) clients will send a hash fragment as part of the URL even\n # though that is a local only modification. This breaks this badly for the\n # files in S3, and in general it's just not needed.\n set req.url = regsub(req.url, \"#.*$\", \"\");\n\n # Most of the URLs in Warehouse do not support or require any sort of query\n # parameter. If we strip these at the edge then we'll increase our cache\n # efficiency when they won't otherwise change the output of the pages.\n #\n # This will match any URL except those that start with:\n #\n # * \/search\/\n # * \/account\/login\/\n # * \/account\/logout\/\n # * \/account\/register\/\n # * \/pypi\n if (req.url !~ \"^\/(search\/|account\/(login|logout|register)\/|pypi)\") {\n set req.url = req.url.path;\n }\n\n # Sort all of our query parameters, this will ensure that the same query\n # parameters in a different order will end up being represented as the same\n # thing, reducing cache misses due to ordering differences.\n set req.url = boltsort.sort(req.url);\n\n\n#FASTLY recv\n\n\n # We want to Force SSL for the WebUI by redirecting to the HTTPS version of\n # the page, however for API calls we want to return an error code directing\n # people to instead use HTTPS.\n if (!req.http.Fastly-SSL) {\n\n # The \/simple\/ and \/packages\/ API.\n if (req.url ~ \"^\/(simple|packages)\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy JSON API.\n if (req.url ~ \"^\/pypi\/.+\/json$\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy ?:action= API.\n if (req.url ~ \"^\/pypi.*(\\?|&)=:action\") {\n error 803 \"SSL is required\";\n }\n\n # If we're on the \/pypi page and we've received something other than a\n # GET or HEAD request, then we have no way to determine if a particular\n # request is an API call or not because it'll be in the request body\n # and that isn't available to us here. So in those cases, we won't\n # do a redirect.\n if (req.url ~ \"^\/pypi\") {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n error 801 \"Force SSL\";\n }\n }\n else {\n # This isn't a \/pypi URL so we'll just unconditionally redirect to\n # HTTPS.\n error 801 \"Force SSL\";\n }\n }\n\n # Redirect www.pypi.io to pypi.io, this is purposely done *after* the HTTPS\n # checks.\n if (std.tolower(req.http.host) == \"www.pypi.io\") {\n set req.http.Location = \"https:\/\/pypi.io\" req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n\n # Requests to \/packages\/ get dispatched to Amazon instead of to our typical\n # Origin. This requires a a bit of setup to make it work.\n if (req.http.host ~ \"^(test-)?files.pythonhosted.org$\"\n && req.url ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\") {\n # Setup our environment to better match what S3 expects\/needs\n set req.http.Host = req.http.AWS-Bucket-Name \".s3.amazonaws.com\";\n set req.http.Date = now;\n set req.url = regsuball(req.url, \"\\+\", urlencode(\"+\"));\n\n # Compute the Authorization header that S3 requires to be able to\n # access the files stored there.\n set req.http.Authorization = \"AWS \" req.http.AWS-Access-Key-ID \":\" digest.hmac_sha1_base64(req.http.AWS-Secret-Access-Key, \"GET\" LF LF LF req.http.Date LF \"\/\" req.http.AWS-Bucket-Name req.url.path);\n\n # We don't want to send our Warehouse-Token to S3, so we'll go ahead\n # and remove it.\n unset req.http.Warehouse-Token;\n }\n\n # We no longer need any of these variables, which would exist only to\n # shuffle configuration from the Fastly UI into our VCL.\n unset req.http.AWS-Access-Key-ID;\n unset req.http.AWS-Secret-Access-Key;\n unset req.http.AWS-Bucket-Name;\n\n # We have a number of items that we'll pass back to the origin, but only\n # if we have a Warehouse-Token that will allow them to be accepted.\n if (req.http.Warehouse-Token) {\n # Set a header to tell the backend if we're using https or http.\n if (req.http.Fastly-SSL) {\n set req.http.Warehouse-Proto = \"https\";\n } else {\n set req.http.Warehouse-Proto = \"http\";\n }\n\n # Pass the client IP address back to the backend.\n if (req.http.Fastly-Client-IP) {\n set req.http.Warehouse-IP = req.http.Fastly-Client-IP;\n }\n\n # Pass the real host value back to the backend.\n if (req.http.Host) {\n set req.http.Warehouse-Host = req.http.host;\n }\n }\n\n # On a POST, we want to skip the shielding and hit backends directly.\n if (req.request == \"POST\") {\n set req.backend = F_Heroku;\n }\n\n # Do not bother to attempt to run the caching mechanisms for methods that\n # are not generally safe to cache.\n if (req.request != \"HEAD\" &&\n req.request != \"GET\" &&\n req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n # We don't ever want to cache our health URL. Outside systems should be\n # able to use it to reach past Fastly and get an end to end health check.\n if (req.url == \"\/_health\/\") {\n return(pass);\n }\n\n # Finally, return the default lookup action.\n return(lookup);\n}\n\n\nsub vcl_fetch {\n\n # These are newer kinds of redirects which should be able to be cached by\n # default, even though Fastly doesn't currently have them in their default\n # list of cacheable status codes.\n if (http_status_matches(beresp.status, \"303,307,308\")) {\n set beresp.cacheable = true;\n }\n\n # For any 5xx status code we want to see if a stale object exists for it,\n # if so we'll go ahead and serve it.\n if (beresp.status >= 500 && beresp.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n\n#FASTLY fetch\n\n\n # Trigger a \"SSL is required\" error if the backend has indicated to do so.\n if (beresp.http.X-Fastly-Error == \"803\") {\n error 803 \"SSL is required\";\n }\n\n # If we've gotten a 502 or a 503 from the backend, we'll go ahead and retry\n # the request.\n if ((beresp.status == 502 || beresp.status == 503) &&\n req.restarts < 1 &&\n (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n # If we've restarted, then we'll record the number of restarts.\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n # If there is a Set-Cookie header, we'll ensure that we do not cache the\n # response.\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n # If the response has the private Cache-Control directive then we won't\n # cache it.\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # If we've gotten an error after the restarts we'll deliver the response\n # with a very short cache time.\n if (http_status_matches(beresp.status, \"500,502,503\")) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n # Apply a default TTL if there isn't a max-age or s-maxage.\n if (beresp.http.Expires ||\n beresp.http.Surrogate-Control ~ \"max-age\" ||\n beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # Keep the ttl here\n }\n else {\n # Apply the default ttl\n set beresp.ttl = 60s;\n }\n\n # Actually deliver the fetched response.\n return(deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n # If the object we have isn't cacheable, then just serve it directly\n # without going through any of the caching mechanisms.\n if (!obj.cacheable) {\n return(pass);\n }\n\n return(deliver);\n}\n\n\nsub vcl_deliver {\n # If this is an error and we have a stale response available, restart so\n # that we can pick it up and serve it.\n if (resp.status >= 500 && resp.status < 600) {\n if (stale.exists) {\n restart;\n }\n }\n\n#FASTLY deliver\n\n # Unset headers that we don't need\/want to send on to the client because\n # they are not generally useful.\n unset resp.http.Server;\n unset resp.http.Via;\n\n # Unset a few headers set by Amazon that we don't really have a need\/desire\n # to send to clients.\n unset resp.http.X-AMZ-Replication-Status;\n unset resp.http.X-AMZ-Meta-Python-Version;\n unset resp.http.X-AMZ-Meta-Version;\n unset resp.http.X-AMZ-Meta-Package-Type;\n unset resp.http.X-AMZ-Meta-Project;\n\n # Set our standard security headers, we do this in VCL rather than in\n # Warehouse itself so that we always get these headers, regardless of the\n # origin server being used.\n set resp.http.Strict-Transport-Security = \"max-age=31536000; includeSubDomains; preload\";\n set resp.http.X-Frame-Options = \"deny\";\n set resp.http.X-XSS-Protection = \"1; mode=block\";\n set resp.http.X-Content-Type-Options = \"nosniff\";\n set resp.http.X-Permitted-Cross-Domain-Policies = \"none\";\n\n return(deliver);\n}\n\n\nsub vcl_error {\n#FASTLY error\n\n # If we have a 5xx error and there is a stale object available, then we\n # will deliver that stale object.\n if (obj.status >= 500 && obj.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n if (obj.status == 803) {\n set obj.status = 403;\n set obj.response = \"SSL is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic {\"SSL is required.\"};\n return (deliver);\n } else if (obj.status == 750) {\n set obj.status = 301;\n set obj.http.Location = req.http.Location;\n set obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n synthetic {\"<html><head><title>301 Moved Permanently<\/title><\/head><body><center><h1>301 Moved Permanently<\/h1><\/center><\/body><\/html>\"};\n return(deliver);\n }\n\n}\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"e37a34e67abfeeffe48f1376e693881cb717f836","subject":"Fix 400 bad request of varnish with nginx and apache 2.4","message":"Fix 400 bad request of varnish with nginx and apache 2.4\n\nUpdate vcl from https:\/\/github.com\/cosimo\/varnish-accept-language\n.\/gen_vcl.pl pt de eo es fr hy it pt ru < accept-language.c > new.vcl\n\n(ActionItem3186)\n","repos":"EcoAlternative\/noosfero-ecosol,CIRANDAS\/noosfero-ecosol,samasti\/noosfero,samasti\/noosfero,blogoosfero\/noosfero,blogoosfero\/noosfero,coletivoEITA\/noosfero-ecosol,CIRANDAS\/noosfero-ecosol,samasti\/noosfero,EcoAlternative\/noosfero-ecosol,samasti\/noosfero,blogoosfero\/noosfero,coletivoEITA\/noosfero-ecosol,EcoAlternative\/noosfero-ecosol,coletivoEITA\/noosfero-ecosol,samasti\/noosfero,EcoAlternative\/noosfero-ecosol,samasti\/noosfero,EcoAlternative\/noosfero-ecosol,EcoAlternative\/noosfero-ecosol,blogoosfero\/noosfero,blogoosfero\/noosfero,coletivoEITA\/noosfero-ecosol,blogoosfero\/noosfero,EcoAlternative\/noosfero-ecosol,coletivoEITA\/noosfero-ecosol,CIRANDAS\/noosfero-ecosol,CIRANDAS\/noosfero-ecosol,CIRANDAS\/noosfero-ecosol,blogoosfero\/noosfero,coletivoEITA\/noosfero-ecosol","old_file":"etc\/noosfero\/varnish-accept-language.vcl","new_file":"etc\/noosfero\/varnish-accept-language.vcl","new_contents":"C{\n\n\/* ------------------------------------------------------------------ *\/\n\/* THIS FILE IS AUTOMATICALLY GENERATED BY .\/gen_vcl.pl. DO NOT EDIT. *\/\n\n\/*\n * Accept-language header normalization\n *\n * - Parses client Accept-Language HTTP header\n * - Tries to find the best match with the supported languages\n * - Writes the best match as req.http.X-Varnish-Accept-Language\n *\n * First version: Cosimo, 21\/Jan\/2010\n * Last update: Cosimo, 03\/Nov\/2011\n *\n * http:\/\/github.com\/cosimo\/varnish-accept-language\n *\n *\/\n\n#include <ctype.h> \/* isupper *\/\n#include <stdio.h>\n#include <stdlib.h> \/* qsort *\/\n#include <string.h>\n\n#define DEFAULT_LANGUAGE \"pt\"\n#define SUPPORTED_LANGUAGES \":de:eo:es:fr:hy:it:pt:ru:\"\n\n#define vcl_string char\n#define LANG_LIST_SIZE 16\n#define HDR_MAXLEN 256\n#define LANG_MAXLEN 8\n#define RETURN_LANG(x) { \\\n strncpy(lang, x, LANG_MAXLEN); \\\n return; \\\n}\n#define RETURN_DEFAULT_LANG RETURN_LANG(DEFAULT_LANGUAGE)\n#define PUSH_LANG(x,y) { \\\n \/* fprintf(stderr, \"Pushing lang [%d] %s %.4f\\n\", curr_lang, x, y); *\/ \\\n \/* We have to copy, otherwise root_lang will be the same every time *\/ \\\n strncpy(pl[curr_lang].lang, x, LANG_MAXLEN); \\\n pl[curr_lang].q = y; \\\n curr_lang++; \\\n}\n\nstruct lang_list {\n vcl_string lang[LANG_MAXLEN];\n float q;\n};\n\n\/* In-place lowercase of a string *\/\nstatic void strtolower(char *s) {\n register char *c;\n for (c=s; *c; c++) {\n if (isupper(*c)) {\n *c = tolower(*c);\n }\n }\n return;\n}\n\n\/* Checks if a given language is in the static list of the ones we support *\/\nint is_supported(vcl_string *lang) {\n vcl_string *supported_languages = SUPPORTED_LANGUAGES;\n vcl_string match_str[LANG_MAXLEN + 3] = \"\"; \/* :, :, \\0 = 3 *\/\n int is_supported = 0;\n\n \/* We want to match 'zh-cn' and 'zh-CN' too *\/\n strtolower(lang);\n\n \/* Search \":<lang>:\" in supported languages string *\/\n strncpy(match_str, \":\", 1);\n strncat(match_str, lang, LANG_MAXLEN);\n strncat(match_str, \":\\0\", 2);\n\n if (strstr(supported_languages, match_str))\n is_supported = 1;\n\n return is_supported;\n}\n\n\/* Used by qsort() below *\/\nint sort_by_q(const void *x, const void *y) {\n struct lang_list *a = (struct lang_list *)x;\n struct lang_list *b = (struct lang_list *)y;\n if (a->q > b->q) return -1;\n if (a->q < b->q) return 1;\n return 0;\n}\n\n\/* Reads Accept-Language, parses it, and finds the first match\n among the supported languages. In case of no match,\n returns the default language.\n*\/\nvoid select_language(const vcl_string *incoming_header, char *lang) {\n\n struct lang_list pl[LANG_LIST_SIZE];\n vcl_string *lang_tok = NULL;\n vcl_string root_lang[3];\n vcl_string *header;\n vcl_string header_copy[HDR_MAXLEN];\n vcl_string *pos = NULL;\n vcl_string *q_spec = NULL;\n unsigned int curr_lang = 0, i = 0;\n float q;\n\n \/* Empty or default string, return default language immediately *\/\n if (\n !incoming_header\n || (0 == strcmp(incoming_header, \"en-US\"))\n || (0 == strcmp(incoming_header, \"en-GB\"))\n || (0 == strcmp(incoming_header, DEFAULT_LANGUAGE))\n || (0 == strcmp(incoming_header, \"\"))\n )\n RETURN_DEFAULT_LANG;\n\n \/* Tokenize Accept-Language *\/\n header = strncpy(header_copy, incoming_header, sizeof(header_copy));\n\n while ((lang_tok = strtok_r(header, \" ,\", &pos))) {\n\n q = 1.0;\n\n if ((q_spec = strstr(lang_tok, \";q=\"))) {\n \/* Truncate language name before ';' *\/\n *q_spec = '\\0';\n \/* Get q value *\/\n sscanf(q_spec + 3, \"%f\", &q);\n }\n\n \/* Wildcard language '*' should be last in list *\/\n if ((*lang_tok) == '*') q = 0.0;\n\n \/* Push in the prioritized list *\/\n PUSH_LANG(lang_tok, q);\n\n \/* For cases like 'en-GB', we also want the root language in the final list *\/\n if ('-' == lang_tok[2]) {\n root_lang[0] = lang_tok[0];\n root_lang[1] = lang_tok[1];\n root_lang[2] = '\\0';\n PUSH_LANG(root_lang, q - 0.001);\n }\n\n \/* For strtok_r() to proceed from where it left off *\/\n header = NULL;\n\n \/* Break out if stored max no. of languages *\/\n if (curr_lang >= LANG_LIST_SIZE)\n break;\n }\n\n \/* Sort by priority *\/\n qsort(pl, curr_lang, sizeof(struct lang_list), &sort_by_q);\n\n \/* Match with supported languages *\/\n for (i = 0; i < curr_lang; i++) {\n if (is_supported(pl[i].lang))\n RETURN_LANG(pl[i].lang);\n }\n\n RETURN_DEFAULT_LANG;\n}\n\n\/* Reads req.http.Accept-Language and writes X-Varnish-Accept-Language *\/\nvoid vcl_rewrite_accept_language(const struct sess *sp) {\n vcl_string *in_hdr;\n vcl_string lang[LANG_MAXLEN];\n\n \/* Get Accept-Language header from client *\/\n in_hdr = VRT_GetHdr(sp, HDR_REQ, \"\\020Accept-Language:\");\n\n \/* Normalize and filter out by list of supported languages *\/\n memset(lang, 0, sizeof(lang));\n select_language(in_hdr, lang);\n\n \/* By default, use a different header name: don't mess with backend logic *\/\n VRT_SetHdr(sp, HDR_REQ, \"\\032X-Varnish-Accept-Language:\", lang, vrt_magic_string_end);\n\n return;\n}\n\n\/* vim: syn=c ts=4 et sts=4 sw=4 tw=0\n*\/\n\n\/* THIS FILE IS AUTOMATICALLY GENERATED BY .\/gen_vcl.pl. DO NOT EDIT. *\/\n\/* ------------------------------------------------------------------ *\/\n}C\n\nsub vcl_recv {\n C{\n vcl_rewrite_accept_language(sp);\n }C\n}\n\nsub vcl_fetch {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary + \", X-Varnish-Accept-Language\";\n } else {\n set beresp.http.Vary = \"X-Varnish-Accept-Language\";\n }\n}\n\n","old_contents":"C{\n\n\/* ------------------------------------------------------------------ *\/\n\/* THIS FILE IS AUTOMATICALLY GENERATED BY .\/gen_vcl.pl. DO NOT EDIT. *\/\n\n\/*\n * Accept-language header normalization\n *\n * Cosimo, 21\/01\/2010\n *\n *\/\n\n#include <ctype.h> \/* isupper *\/\n#include <stdio.h>\n#include <stdlib.h> \/* qsort *\/\n#include <string.h>\n\n#define DEFAULT_LANGUAGE \"en\"\n#define SUPPORTED_LANGUAGES \":de:fr:es:ru:pt:hy:en:\"\n\n#define vcl_string char\n#define LANG_LIST_SIZE 16 \n#define LANG_MAXLEN 16\n#define RETURN_LANG(x) { \\\n strncpy(lang, x, LANG_MAXLEN); \\\n return; \\\n}\n#define RETURN_DEFAULT_LANG RETURN_LANG(DEFAULT_LANGUAGE)\n#define PUSH_LANG(x,y) { \\\n \/* fprintf(stderr, \"Pushing lang [%d] %s %.4f\\n\", curr_lang, x, y); *\/ \\\n \/* We have to copy, otherwise root_lang will be the same every time *\/ \\\n strncpy(pl[curr_lang].lang, x, LANG_MAXLEN); \\\n pl[curr_lang].q = y; \\\n curr_lang++; \\\n}\n\nstruct lang_list {\n vcl_string lang[LANG_MAXLEN];\n float q;\n};\n\n\/* In-place lowercase of a string *\/\nstatic void strtolower(char *s) {\n register char *c;\n for (c=s; *c; c++) {\n if (isupper(*c)) {\n *c = tolower(*c);\n }\n }\n return;\n}\n\n\/* Checks if a given language is in the static list of the ones we support *\/\nint is_supported(vcl_string *lang) {\n vcl_string *supported_languages = SUPPORTED_LANGUAGES;\n vcl_string match_str[LANG_MAXLEN + 3] = \"\"; \/* :, :, \\0 = 3 *\/\n int is_supported = 0;\n\n \/* We want to match 'zh-cn' and 'zh-CN' too *\/\n strtolower(lang);\n\n \/* Search \":<lang>:\" in supported languages string *\/\n strncpy(match_str, \":\", 1);\n strncat(match_str, lang, LANG_MAXLEN);\n strncat(match_str, \":\\0\", 2);\n\n if (strstr(supported_languages, match_str)) {\n is_supported = 1;\n }\n\n return is_supported;\n}\n\n\/* Used by qsort() below *\/\nint sort_by_q(const void *x, const void *y) {\n struct lang_list *a = (struct lang_list *)x;\n struct lang_list *b = (struct lang_list *)y;\n if (a->q > b->q) return -1;\n if (a->q < b->q) return 1;\n return 0;\n}\n\n\/* Reads Accept-Language, parses it, and finds the first match\n among the supported languages. In case of no match,\n returns the default language.\n*\/\nvoid select_language(const vcl_string *incoming_header, char *lang) {\n\n struct lang_list pl[LANG_LIST_SIZE];\n vcl_string *lang_tok = NULL;\n vcl_string root_lang[3];\n vcl_string *header;\n vcl_string *pos = NULL;\n vcl_string *q_spec = NULL;\n unsigned int curr_lang = 0, i = 0;\n float q;\n\n \/* Empty or default string, return default language immediately *\/\n if (\n !incoming_header\n || (0 == strcmp(incoming_header, \"en-US\"))\n || (0 == strcmp(incoming_header, \"en-GB\"))\n || (0 == strcmp(incoming_header, DEFAULT_LANGUAGE))\n || (0 == strcmp(incoming_header, \"\"))\n )\n RETURN_DEFAULT_LANG;\n\n \/* Tokenize Accept-Language *\/\n header = (vcl_string *) incoming_header;\n\n while ((lang_tok = strtok_r(header, \" ,\", &pos))) {\n\n q = 1.0;\n\n if ((q_spec = strstr(lang_tok, \";q=\"))) {\n \/* Truncate language name before ';' *\/\n *q_spec = '\\0';\n \/* Get q value *\/\n sscanf(q_spec + 3, \"%f\", &q);\n }\n\n \/* Wildcard language '*' should be last in list *\/\n if ((*lang_tok) == '*') q = 0.0;\n\n \/* Push in the prioritized list *\/\n PUSH_LANG(lang_tok, q);\n\n \/* For cases like 'en-GB', we also want the root language in the final list *\/\n if ('-' == lang_tok[2]) {\n root_lang[0] = lang_tok[0];\n root_lang[1] = lang_tok[1];\n root_lang[2] = '\\0';\n PUSH_LANG(root_lang, q - 0.001);\n }\n\n \/* For strtok_r() to proceed from where it left off *\/\n header = NULL;\n\n \/* Break out if stored max no. of languages *\/\n if (curr_lang >= LANG_MAXLEN) break;\n }\n\n \/* Sort by priority *\/\n qsort(pl, curr_lang, sizeof(struct lang_list), &sort_by_q);\n\n \/* Match with supported languages *\/\n for (i = 0; i < curr_lang; i++) {\n if (is_supported(pl[i].lang))\n RETURN_LANG(pl[i].lang);\n }\n\n RETURN_DEFAULT_LANG;\n}\n\n\/* Reads req.http.Accept-Language and writes X-Varnish-Accept-Language *\/\nvoid vcl_rewrite_accept_language(const struct sess *sp) {\n vcl_string *in_hdr;\n vcl_string lang[LANG_MAXLEN];\n\n memset(lang, 0, LANG_MAXLEN);\n\n \/* Get Accept-Language header from client *\/\n in_hdr = VRT_GetHdr(sp, HDR_REQ, \"\\020Accept-Language:\");\n\n \/* Normalize and filter out by list of supported languages *\/\n select_language(in_hdr, lang);\n\n \/* By default, use a different header name: don't mess with backend logic *\/\n VRT_SetHdr(sp, HDR_REQ, \"\\032X-Varnish-Accept-Language:\", lang, vrt_magic_string_end);\n\n return;\n}\n\n\/* vim: syn=c ts=4 et sts=4 sw=4 tw=0\n*\/\n\n\/* THIS FILE IS AUTOMATICALLY GENERATED BY .\/gen_vcl.pl. DO NOT EDIT. *\/\n\/* ------------------------------------------------------------------ *\/\n}C\n\nsub vcl_recv {\n C{\n vcl_rewrite_accept_language(sp);\n }C\n}\n\nsub vcl_fetch {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary + \", X-Varnish-Accept-Language\";\n } else {\n set beresp.http.Vary = \"X-Varnish-Accept-Language\";\n }\n}\n","returncode":0,"stderr":"","license":"agpl-3.0","lang":"VCL"} {"commit":"751e0a5adf4a917beb2635e46522346a58a56e3e","subject":"varnish fix uncachable status having no ttl","message":"varnish fix uncachable status having no ttl\n","repos":"KhanovaSkola\/khanovaskola-v3,KhanovaSkola\/khanovaskola-v3,KhanovaSkola\/khanovaskola-v3,KhanovaSkola\/khanovaskola-v3,KhanovaSkola\/khanovaskola-v3,KhanovaSkola\/khanovaskola-v3","old_file":"production\/varnish.vcl","new_file":"production\/varnish.vcl","new_contents":"vcl 4.0;\n\n# Disable esi xml check on varnish Startup\n# Example:\n# DAEMON_OPTS=\"-a :6081 \\\n# -T localhost:6082 \\\n# -p feature=+esi_disable_xml_check\n# -p feature=+esi_ignore_https\n#\n\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8085\";\n}\n\nsub vcl_recv {\n if (req.method != \"GET\") {\n return (pass);\n }\n if (req.http.Cookie ~ \"\\bvarnish-force=pass\") {\n return (pass);\n }\n\n return (hash);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n return(lookup);\n}\n\nsub vcl_backend_response {\n if (beresp.http.Cache-Control != \"public\") {\n set beresp.uncacheable = true;\n set beresp.ttl = 3m;\n return (deliver);\n }\n\n set beresp.do_esi = true;\n set beresp.ttl = 15m;\n\n unset beresp.http.Set-Cookie;\n}\n","old_contents":"vcl 4.0;\n\n# Disable esi xml check on varnish Startup\n# Example:\n# DAEMON_OPTS=\"-a :6081 \\\n# -T localhost:6082 \\\n# -p feature=+esi_disable_xml_check\n# -p feature=+esi_ignore_https\n#\n\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8085\";\n}\n\nsub vcl_recv {\n if (req.method != \"GET\") {\n return (pass);\n }\n if (req.http.Cookie ~ \"\\bvarnish-force=pass\") {\n return (pass);\n }\n\n return (hash);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n return(lookup);\n}\n\nsub vcl_backend_response {\n if (beresp.http.Cache-Control != \"public\") {\n set beresp.uncacheable = true;\n return (deliver);\n }\n\n set beresp.do_esi = true;\n set beresp.ttl = 15m;\n\n unset beresp.http.Set-Cookie;\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"a425c7136d44988d3ed75b190bb3b45c503777e0","subject":"Varies fixes","message":"Varies fixes\n","repos":"karto\/varnish-cacheable,karto\/varnish-cacheable","old_file":"cacheable-backend.vcl","new_file":"cacheable-backend.vcl","new_contents":"#\n# Varnish VCL for backend cacheable\n#\n# Author Karto Martin <source@karto.net>\n# Copyright (c) 2015 Karto Martin. All Right Reserved.\n# License The MIT License\n#\n\n\nsub cacheable_backend_response_cacheable {\n \n ###\n # rfc7231 Hypertext Transfer Protocol (HTTP\/1.1): Semantics and Content\n # rfc7234 Hypertext Transfer Protocol (HTTP\/1.1): Caching\n # rfc7234 3. Storing Responses in Caches https:\/\/tools.ietf.org\/html\/rfc7234#section-3\n #\n # A cache MUST NOT store a response to any request, unless:\n \n # o The request method is understood by the cache and defined as being\n # cacheable, and\n # rfc7231 4.2.3. Cacheable Methods https:\/\/tools.ietf.org\/html\/rfc7231#section-4.2.3\n if (\"GET\" != bereq.method && \"HEAD\" != bereq.method) {\n set beresp.http.X-Cacheable = \"NO;method\";\n set beresp.uncacheable = true;\n set beresp.ttl = 0s; \/\/ No hit for pass\n }\n\n ## varnish - default understood status codes \n ## : 200 203 300 301 302 304 307 404 410\n ## rfc7231 - cacheable by default status codes \n ## : 200 203 204 206 300 301 404 405 410 414 501\n ## consider for default : 204 205\n ## consider for freshness: 302 303 307 401 403 405 406 500 501 502 503 504 505\n ## never be cached: 201 202 305 306 402 408 409 411 412 413 415 417\n #\n ###: custom understood status codes\n ## : 200 203 204 205 300 301 302 303 304 307 308 \n ## : 400 403 404 405 406 410 414 418 \n ## : 500 501 502 503 504 505 \n \n # o the response status code is understood by the cache, and\n # rfc7231 6.1. Overview of Status Codes https:\/\/tools.ietf.org\/html\/rfc7231#section-6.1\n elsif (regsub(beresp.status, \"\", \"\") !~ \"^(20[0345]|30[0123478]|40[03456]|41[048]|50[012345])$\") {\n set beresp.http.X-Cacheable = \"H4P;status\";\n set beresp.uncacheable = true;\n set beresp.ttl = 119s; \/\/ Hit for pass\n }\n \n # o the \"no-store\" cache directive (see Section 5.2) does not appear\n # in request or response header fields, and\n # rfc7234 5.2.1.5. no-store https:\/\/tools.ietf.org\/html\/rfc7234#section-5.2.1.5\n elsif (bereq.http.Cache-Control ~ \"(?i)(^|,)\\s*no-store\\s*(,|$)\") {\n set beresp.http.X-Cacheable = \"NO;req;no-store\";\n set beresp.uncacheable = true;\n set beresp.ttl = 0s; \/\/ No hit for pass\n }\n # rfc7234 5.2.2.3. no-store https:\/\/tools.ietf.org\/html\/rfc7234#section-5.2.2.3\n elsif (beresp.http.Cache-Control ~ \"(?i)(^|,)\\s*no-store\\s*(,|$)\") {\n set beresp.http.X-Cacheable = \"H4P;resp;no-store\";\n set beresp.uncacheable = true;\n set beresp.ttl = 119s; \/\/ Hit for pass\n }\n \n # o the \"private\" response directive (see Section 5.2.2.6) does not\n # appear in the response, if the cache is shared, and\n # rfc7234 5.2.2.6. private https:\/\/tools.ietf.org\/html\/rfc7234#section-5.2.2.6\n elsif (beresp.http.Cache-Control ~ \"(?i)(^|,)\\s*private\\s*(,|$)\") {\n set beresp.http.X-Cacheable = \"H4P;private\";\n set beresp.uncacheable = true;\n set beresp.ttl = 119s; \/\/ Hit for pass\n }\n \n # o the Authorization header field (see Section 4.2 of [RFC7235]) does\n # not appear in the request, if the cache is shared, unless the\n # response explicitly allows it (see Section 3.2), and\n # rfc7234 3.2. Storing Responses to Authenticated Requests https:\/\/tools.ietf.org\/html\/rfc7234#section-3.2\n elsif (bereq.http.Authorization && beresp.http.Cache-Control !~ \"(?i)(^|,)\\s*(must-revalidate|public|s-maxage=\\d+|dr-maxage=\\d+)\\s*(?=,|$)\") {\n set beresp.http.X-Cacheable = \"NO:authorization\";\n set beresp.uncacheable = true;\n set beresp.ttl = 0s; \/\/ No hit for pass\n }\n \n # o the response either:\n # rfc7234 4.2.1. Calculating Freshness Lifetime https:\/\/tools.ietf.org\/html\/rfc7234#section-4.2.1\n # A cache can calculate the freshness lifetime (denoted as\n # freshness_lifetime) of a response by using the first match of the\n # following:\n\n # o If the cache is varnish and the dr-maxage response directive\n # is present, use its value, or\n # * contains a dr-maxage=ttl[+grace] response directive (custom varnish ttl and grace)\n elsif (beresp.http.Cache-Control ~ \"(?i)(^|,)\\s*dr-maxage=\\d+(\\+\\d+)?\\s*(,|$)\") {\n set beresp.http.X-Cacheable = \"YES;\"+regsub(beresp.http.Cache-Control, \"(?i)^(?:.*,)?\\s*(dr-maxage=\\d+(?:\\+\\d+)?)\\s*(?:,.*)?$\", \"\\1\");\n set beresp.ttl = std.duration(regsub(beresp.http.Cache-Control, \"(?i)^(?:.*,)?\\s*dr-maxage=(\\d+)(?:\\+\\d+)?\\s*(?:,.*)?$\", \"\\1\")+\"s\", 0s);\n if (beresp.http.Cache-Control ~ \"(?i)(^|,)\\s*dr-maxage=\\d+\\+\\d+\\s*(,|$)\") {\n set beresp.grace = std.duration(regsub(beresp.http.Cache-Control, \"(?i)^(?:.*,)?\\s*dr-maxage=\\d+\\+(\\d+)\\s*(?:,.*)?$\", \"\\1\")+\"s\", 0s);\n }\n }\n \n # o If the cache is shared and the s-maxage response directive\n # (Section 5.2.2.9) is present, use its value, or\n # * contains a s-maxage response directive (see Section 5.2.2.9)\n # and the cache is shared, or\n # rfc7234 5.2.2.9. s-maxage https:\/\/tools.ietf.org\/html\/rfc7234#section-5.2.2.9\n elsif (beresp.http.Cache-Control ~ \"(?i)(^|,)\\s*s-maxage=\\d+\\s*(,|$)\") {\n set beresp.http.X-Cacheable = \"YES;\"+regsub(beresp.http.Cache-Control, \"(?i)^(?:.*,)?\\s*(s-maxage=\\d+)\\s*(?:,.*)?$\", \"\\1\");\n set beresp.ttl = std.duration(regsub(beresp.http.Cache-Control, \"(?i)^(?:.*,)?\\s*s-maxage=(\\d+)\\s*(?:,.*)?$\", \"\\1\")+\"s\", 0s);\n }\n \n # o If the max-age response directive (Section 5.2.2.8) is present,\n # use its value, or\n # * contains a max-age response directive (see Section 5.2.2.8), or\n # rfc7234 5.2.2.8. max-age https:\/\/tools.ietf.org\/html\/rfc7234#section-5.2.2.8\n elsif (beresp.http.Cache-Control ~ \"(?i)(^|,)\\s*max-age=\\d+\\s*(,|$)\") {\n set beresp.http.X-Cacheable = \"YES;\"+regsub(beresp.http.Cache-Control, \"(?i)^(?:.*,)?\\s*(max-age=\\d+)\\s*(?:,.*)?$\", \"\\1\");\n set beresp.ttl = std.duration(regsub(beresp.http.Cache-Control, \"(?i)^(?:.*,)?\\s*max-age=(\\d+)\\s*(?:,.*)?$\", \"\\1\")+\"s\", 0s);\n }\n \n # o If the Expires response header field (Section 5.3) is present, use\n # its value minus the value of the Date response header field, or\n # * contains an Expires header field (see Section 5.3), or\n # rfc7234 5.3. Expires https:\/\/tools.ietf.org\/html\/rfc7234#section-5.3\n elsif (beresp.http.Expires) {\n if (std.time(beresp.http.Expires, now) > std.time(beresp.http.Date, now)) {\n set beresp.http.X-Cacheable = \"YES;\"+\"expires=\"+(std.time(beresp.http.Expires, now) - std.time(beresp.http.Date, now));\n set beresp.ttl = std.time(beresp.http.Expires, now) - std.time(beresp.http.Date, now);\n }\n else {\n set beresp.http.X-Cacheable = \"H4P;\"+\"expires=past\";\n set beresp.uncacheable = true;\n set beresp.ttl = 119s; \/\/ Hit for pass\n }\n }\n\n # o Otherwise, no explicit expiration time is present in the response.\n # A heuristic freshness lifetime might be applicable; see\n # Section 4.2.2.\n \n # * contains a Cache Control Extension (see Section 5.2.3) that\n # allows it to be cached, or\n #elsif (beresp.http.Cache-Control ~ \"(?i)(^|,)\\s*extension\\s*(,|$)\") { }\n \n \n ## varnish - default understood status codes \n ## : 200 203 300 301 302 304 307 404 410\n ## rfc7231 - cacheable by default status codes \n ## : 200 203 204 206 300 301 404 405 410 414 501\n ## consider for default : 204 205\n ## consider for freshness: 302 303 307 401 403 405 406 500 501 502 503 504 505\n ## never be cached: 201 202 305 306 402 408 409 411 412 413 415 417\n ##\n ###: custom understood status codes\n ## : 200 203 204 205 206 300 301 302 303 304 307 308 \n ## : 400 403 404 405 406 410 414 418 \n ## : 500 501 502 503 504 505 \n ##\n ###: custom cacheable by default\n ## : 200 203 204 300 301 302 303 304 307 308 \n ## : 404 405 410 414 418 500 501 502 503 504\n\n # * has a status code that is defined as cacheable by default (see\n # Section 4.2.2), or\n # rfc7231 6.1. Overview of Status Codes https:\/\/tools.ietf.org\/html\/rfc7231#section-6.1\n # rfc7231 and varnish default status codes : 200 203 204 300 301 302 304 307 404 405 410 414 501\n elsif (regsub(beresp.status, \"\", \"\") ~ \"^(20[034]|30[01247]|40[45]|41[04]|501)$\") {\n if (beresp.http.Last-Modified && std.time(beresp.http.Last-Modified, now) < now) {\n set beresp.http.X-Cacheable = \"YES:default=10s<\"+regsub((now - std.time(beresp.http.Last-Modified, now)) * 0.1, \"\\.\\d\\d\\d$\", \"\")+\"s<1d\";\n if ((now - std.time(beresp.http.Last-Modified, now)) * 0.1 <= 10s) {\n set beresp.ttl = 10s;\n }\n elsif ((now - std.time(beresp.http.Last-Modified, now)) * 0.1 < 1d) {\n set beresp.ttl = (now - std.time(beresp.http.Last-Modified, now)) * 0.1;\n }\n else {\n set beresp.ttl = 1d;\n }\n }\n else {\n set beresp.http.X-Cacheable = \"YES:default=119s\";\n set beresp.ttl = 119s;\n }\n }\n ## Extended default status codes\n ## : 303 308 418 500 502 503 504\n elsif (regsub(beresp.status, \"\", \"\") ~ \"^(30[38]|418|50[0234])$\") {\n if (beresp.http.Last-Modified && std.time(beresp.http.Last-Modified, now) < now) {\n set beresp.http.X-Cacheable = \"YES:extended=10s<\"+regsub((now - std.time(beresp.http.Last-Modified, now)) * 0.01, \"\\.\\d\\d\\d$\", \"\")+\"<1h\";\n if ((now - std.time(beresp.http.Last-Modified, now)) * 0.01 <= 10s) {\n set beresp.ttl = 10s;\n }\n elsif ((now - std.time(beresp.http.Last-Modified, now)) * 0.01 < 1h) {\n set beresp.ttl = (now - std.time(beresp.http.Last-Modified, now)) * 0.01;\n }\n else {\n set beresp.ttl = 1h;\n }\n }\n else {\n set beresp.http.X-Cacheable = \"YES:extended=19s\";\n set beresp.ttl = 19s;\n }\n }\n \n # * contains a public response directive (see Section 5.2.2.5).\n # rfc7234 5.2.2.5. public https:\/\/tools.ietf.org\/html\/rfc7234#section-5.2.2.5\n elsif (beresp.http.Cache-Control ~ \"(?i)(^|,)\\s*public\\s*(,|$)\") {\n if (beresp.http.Last-Modified && std.time(beresp.http.Last-Modified, now) < now) {\n set beresp.http.X-Cacheable = \"YES:public=10s<\"+regsub((now - std.time(beresp.http.Last-Modified, now)) * 0.1, \"\\.\\d\\d\\d$\", \"\")+\"<1d\";\n if ((now - std.time(beresp.http.Last-Modified, now)) * 0.1 <= 10s) {\n set beresp.ttl = 10s;\n }\n elsif ((now - std.time(beresp.http.Last-Modified, now)) * 0.1 < 1d) {\n set beresp.ttl = (now - std.time(beresp.http.Last-Modified, now)) * 0.1;\n }\n else {\n set beresp.ttl = 1d;\n }\n }\n else {\n set beresp.http.X-Cacheable = \"YES:public=119s\";\n set beresp.ttl = 119s;\n }\n }\n \n # The rest - no matching rules\n else {\n set beresp.http.X-Cacheable = \"NO:others\";\n set beresp.uncacheable = true;\n set beresp.ttl = 0s; \/\/ No hit for pass\n }\n #End elseif\n \n ####################################################\n # Set grace\n if (beresp.http.Cache-Control !~ \"(?i)(^|,)\\s*dr-maxage=\\d+\\+\\d+\\s*(,|$)\") {\n\n # 3. The stale-while-revalidate Cache-Control Extension http:\/\/tools.ietf.org\/html\/rfc5861#section-3\n # When present in an HTTP response, the stale-while-revalidate Cache-\n # Control extension indicates that caches MAY serve the response in\n # which it appears after it becomes stale, up to the indicated number\n # of seconds.\n if (beresp.http.Cache-Control ~ \"(?i)(^|,)\\s*stale-while-revalidate=\\d*\\s*(,|$)\") {\n set beresp.http.VAR-stale-while-revalidate = std.duration(regsub(\n beresp.http.Cache-Control, \"(?i)^(?:.*,)?\\s*stale-while-revalidate=(\\d+)\\s*(?:,.*)?$\", \"\\1s\"), 0s)+\"s\";\n }\n\n # 4. The stale-if-error Cache-Control Extension http:\/\/tools.ietf.org\/html\/rfc5861#section-4\n # The stale-if-error Cache-Control extension indicates that when an\n # error is encountered, a cached stale response MAY be used to satisfy\n # the request, regardless of other freshness information.\n if (beresp.http.Cache-Control ~ \"(?i)(^|,)\\s*stale-if-error=\\d+\\s*(,|$)\") {\n set beresp.http.VAR-stale-if-error = std.duration(regsub(\n beresp.http.Cache-Control, \"(?i)^(?:.*,)?\\s*stale-if-error=(\\d+)\\s*(?:,.*)?$\", \"\\1s\"), 0s)+\"s\";\n }\n \n # Default grace\n if (beresp.http.Last-Modified && std.time(beresp.http.Last-Modified, now) < now) {\n if ((now - std.time(beresp.http.Last-Modified, now)) * 0.5 <= 10s) {\n set beresp.http.VAR-stale-default = \"10s\";\n }\n elsif ((now - std.time(beresp.http.Last-Modified, now)) * 0.5 < 1d) {\n set beresp.http.VAR-stale-default = ((now - std.time(beresp.http.Last-Modified, now)) * 0.5)+\"s\";\n }\n else {\n set beresp.http.VAR-stale-default = \"86400s\";\n }\n }\n else {\n set beresp.http.VAR-stale-default = \"59s\";\n }\n \n \n # Pick largest grace\n if (std.duration(beresp.http.VAR-stale-while-revalidate, 0s) >= std.duration(beresp.http.VAR-stale-if-error, 0s) && \n std.duration(beresp.http.VAR-stale-while-revalidate, 0s) > std.duration(beresp.http.VAR-stale-default, 0s)) {\n set beresp.http.X-Cacheable = beresp.http.X-Cacheable+\";swr;grace=\"+std.duration(beresp.http.VAR-stale-while-revalidate, 0s);\n set beresp.grace = std.duration(beresp.http.VAR-stale-while-revalidate, 0s);\n }\n elsif (std.duration(beresp.http.VAR-stale-if-error, 0s) >= std.duration(beresp.http.VAR-stale-while-revalidate, 0s) && \n std.duration(beresp.http.VAR-stale-if-error, 0s) > std.duration(beresp.http.VAR-stale-default, 0s)) {\n set beresp.http.X-Cacheable = beresp.http.X-Cacheable+\";sie;grace=\"+std.duration(beresp.http.VAR-stale-if-error, 0s);\n set beresp.grace = std.duration(beresp.http.VAR-stale-if-error, 0s);\n }\n else {\n set beresp.http.X-Cacheable = beresp.http.X-Cacheable+\";def;grace=\"+std.duration(beresp.http.VAR-stale-default, 0s);\n set beresp.grace = std.duration(beresp.http.VAR-stale-default, 0s);\n }\n \n }\n \n # Set cache info for verbose\n set beresp.http.X-Caching = beresp.ttl + \"\/\" + beresp.grace + \"\/\" + beresp.keep + \"\/\" + beresp.uncacheable;\n\n # cacheable for freshness and stale serving\n if ( ! beresp.uncacheable) {\n set beresp.http.VAR-freshness_lifetime = beresp.ttl+\"s\";\n if (beresp.ttl == 0s) {\n std.log(\"cacheable_backend_response_cacheable: ttl=1ms hack for stale serving\");\n set beresp.ttl = 1ms;\n }\n }\n\n}\n\n","old_contents":"#\n# Varnish VCL for backend cacheable\n#\n# Author Karto Martin <source@karto.net>\n# Copyright (c) 2015 Karto Martin. All Right Reserved.\n# License The MIT License\n#\n\n\nsub cacheable_backend_response_cacheable {\n \n ###\n # rfc7231 Hypertext Transfer Protocol (HTTP\/1.1): Semantics and Content\n # rfc7234 Hypertext Transfer Protocol (HTTP\/1.1): Caching\n # rfc7234 3. Storing Responses in Caches https:\/\/tools.ietf.org\/html\/rfc7234#section-3\n #\n # A cache MUST NOT store a response to any request, unless:\n \n # o The request method is understood by the cache and defined as being\n # cacheable, and\n # rfc7231 4.2.3. Cacheable Methods https:\/\/tools.ietf.org\/html\/rfc7231#section-4.2.3\n if (\"GET\" != bereq.method && \"HEAD\" != bereq.method) {\n set beresp.http.X-Cacheable = \"NO;method\";\n set beresp.uncacheable = true;\n set beresp.ttl = 0s; \/\/ No hit for pass\n }\n\n ## varnish - default understood status codes \n ## : 200 203 300 301 302 304 307 404 410\n ## rfc7231 - cacheable by default status codes \n ## : 200 203 204 206 300 301 404 405 410 414 501\n ## consider for default : 204 205\n ## consider for freshness: 302 303 307 401 403 405 406 500 501 502 503 504 505\n ## never be cached: 201 202 305 306 402 408 409 411 412 413 415 417\n #\n ###: custom understood status codes\n ## : 200 203 204 205 300 301 302 303 304 307 308 \n ## : 400 403 404 405 406 410 414 418 \n ## : 500 501 502 503 504 505 \n \n # o the response status code is understood by the cache, and\n # rfc7231 6.1. Overview of Status Codes https:\/\/tools.ietf.org\/html\/rfc7231#section-6.1\n elsif (regsub(beresp.status, \"\", \"\") !~ \"^(20[0345]|30[0123478]|40[03456]|41[048]|50[012345])$\") {\n set beresp.http.X-Cacheable = \"H4P;status\";\n set beresp.uncacheable = true;\n set beresp.ttl = 119s; \/\/ Hit for pass\n }\n \n # o the \"no-store\" cache directive (see Section 5.2) does not appear\n # in request or response header fields, and\n # rfc7234 5.2.1.5. no-store https:\/\/tools.ietf.org\/html\/rfc7234#section-5.2.1.5\n elsif (bereq.http.Cache-Control ~ \"(?i)(^|,)\\s*no-store\\s*(,|$)\") {\n set beresp.http.X-Cacheable = \"H4P;req;no-store\";\n set beresp.uncacheable = true;\n set beresp.ttl = 119s; \/\/ Hit for pass\n }\n # rfc7234 5.2.2.3. no-store https:\/\/tools.ietf.org\/html\/rfc7234#section-5.2.2.3\n elsif (beresp.http.Cache-Control ~ \"(?i)(^|,)\\s*no-store\\s*(,|$)\") {\n set beresp.http.X-Cacheable = \"H4P;resp;no-store\";\n set beresp.uncacheable = true;\n set beresp.ttl = 119s; \/\/ Hit for pass\n }\n \n # o the \"private\" response directive (see Section 5.2.2.6) does not\n # appear in the response, if the cache is shared, and\n # rfc7234 5.2.2.6. private https:\/\/tools.ietf.org\/html\/rfc7234#section-5.2.2.6\n elsif (beresp.http.Cache-Control ~ \"(?i)(^|,)\\s*private\\s*(,|$)\") {\n set beresp.http.X-Cacheable = \"H4P;private\";\n set beresp.uncacheable = true;\n set beresp.ttl = 119s; \/\/ Hit for pass\n }\n \n # o the Authorization header field (see Section 4.2 of [RFC7235]) does\n # not appear in the request, if the cache is shared, unless the\n # response explicitly allows it (see Section 3.2), and\n # rfc7234 3.2. Storing Responses to Authenticated Requests https:\/\/tools.ietf.org\/html\/rfc7234#section-3.2\n elsif (bereq.http.Authorization && beresp.http.Cache-Control !~ \"(?i)(^|,)\\s*(must-revalidate|public|s-maxage=\\d+|dr-maxage=\\d+)\\s*(?=,|$)\") {\n set beresp.http.X-Cacheable = \"NO:authorization\";\n set beresp.uncacheable = true;\n set beresp.ttl = 0s; \/\/ No hit for pass\n }\n \n # o the response either:\n # rfc7234 4.2.1. Calculating Freshness Lifetime https:\/\/tools.ietf.org\/html\/rfc7234#section-4.2.1\n # A cache can calculate the freshness lifetime (denoted as\n # freshness_lifetime) of a response by using the first match of the\n # following:\n\n # o If the cache is varnish and the v-maxage response directive\n # is present, use its value, or\n # * contains a dr-maxage=ttl[+grace] response directive (custom varnish ttl and grace)\n elsif (beresp.http.Cache-Control ~ \"(?i)(^|,)\\s*dr-maxage=\\d+(\\+\\d+)?\\s*(,|$)\") {\n set beresp.http.X-Cacheable = \"YES;\"+regsub(beresp.http.Cache-Control, \"(?i)^(?:.*,)?\\s*(dr-maxage=\\d+(?:\\+\\d+)?)\\s*(?:,.*)?$\", \"\\1\");\n set beresp.ttl = std.duration(regsub(beresp.http.Cache-Control, \"(?i)^(?:.*,)?\\s*dr-maxage=(\\d+)(?:\\+\\d+)?\\s*(?:,.*)?$\", \"\\1\")+\"s\", 0s);\n if (beresp.http.Cache-Control ~ \"(?i)(^|,)\\s*dr-maxage=\\d+\\+\\d+\\s*(,|$)\") {\n set beresp.http.X-Cacheable = beresp.http.X-Cacheable+\";dr;grace=\"+std.duration(beresp.http.VAR-stale-if-error, 0s);\n set beresp.grace = std.duration(regsub(beresp.http.Cache-Control, \"(?i)^(?:.*,)?\\s*dr-maxage=\\d+\\+(\\d+)\\s*(?:,.*)?$\", \"\\1\")+\"s\", 0s);\n }\n }\n \n # o If the cache is shared and the s-maxage response directive\n # (Section 5.2.2.9) is present, use its value, or\n # * contains a s-maxage response directive (see Section 5.2.2.9)\n # and the cache is shared, or\n # rfc7234 5.2.2.9. s-maxage https:\/\/tools.ietf.org\/html\/rfc7234#section-5.2.2.9\n elsif (beresp.http.Cache-Control ~ \"(?i)(^|,)\\s*s-maxage=\\d+\\s*(,|$)\") {\n set beresp.http.X-Cacheable = \"YES;\"+regsub(beresp.http.Cache-Control, \"(?i)^(?:.*,)?\\s*(s-maxage=\\d+)\\s*(?:,.*)?$\", \"\\1\");\n set beresp.ttl = std.duration(regsub(beresp.http.Cache-Control, \"(?i)^(?:.*,)?\\s*s-maxage=(\\d+)\\s*(?:,.*)?$\", \"\\1\")+\"s\", 0s);\n }\n \n # o If the max-age response directive (Section 5.2.2.8) is present,\n # use its value, or\n # * contains a max-age response directive (see Section 5.2.2.8), or\n # rfc7234 5.2.2.8. max-age https:\/\/tools.ietf.org\/html\/rfc7234#section-5.2.2.8\n elsif (beresp.http.Cache-Control ~ \"(?i)(^|,)\\s*max-age=\\d+\\s*(,|$)\") {\n set beresp.http.X-Cacheable = \"YES;\"+regsub(beresp.http.Cache-Control, \"(?i)^(?:.*,)?\\s*(max-age=\\d+)\\s*(?:,.*)?$\", \"\\1\");\n set beresp.ttl = std.duration(regsub(beresp.http.Cache-Control, \"(?i)^(?:.*,)?\\s*max-age=(\\d+)\\s*(?:,.*)?$\", \"\\1\")+\"s\", 0s);\n }\n \n # o If the Expires response header field (Section 5.3) is present, use\n # its value minus the value of the Date response header field, or\n # * contains an Expires header field (see Section 5.3), or\n # rfc7234 5.3. Expires https:\/\/tools.ietf.org\/html\/rfc7234#section-5.3\n elsif (beresp.http.Expires) {\n if (std.time(beresp.http.Expires, now) > std.time(beresp.http.Date, now)) {\n set beresp.http.X-Cacheable = \"YES;\"+\"expires=\"+(std.time(beresp.http.Expires, now) - std.time(beresp.http.Date, now));\n set beresp.ttl = std.time(beresp.http.Expires, now) - std.time(beresp.http.Date, now);\n }\n else {\n set beresp.http.X-Cacheable = \"H4P;\"+\"expires=past\";\n set beresp.uncacheable = true;\n set beresp.ttl = 119s; \/\/ Hit for pass\n }\n }\n\n # o Otherwise, no explicit expiration time is present in the response.\n # A heuristic freshness lifetime might be applicable; see\n # Section 4.2.2.\n \n # * contains a Cache Control Extension (see Section 5.2.3) that\n # allows it to be cached, or\n #elsif (beresp.http.Cache-Control ~ \"(?i)(^|,)\\s*extension\\s*(,|$)\") { }\n \n \n ## varnish - default understood status codes \n ## : 200 203 300 301 302 304 307 404 410\n ## rfc7231 - cacheable by default status codes \n ## : 200 203 204 206 300 301 404 405 410 414 501\n ## consider for default : 204 205\n ## consider for freshness: 302 303 307 401 403 405 406 500 501 502 503 504 505\n ## never be cached: 201 202 305 306 402 408 409 411 412 413 415 417\n ##\n ###: custom understood status codes\n ## : 200 203 204 205 206 300 301 302 303 304 307 308 \n ## : 400 403 404 405 406 410 414 418 \n ## : 500 501 502 503 504 505 \n ##\n ###: custom cacheable by default\n ## : 200 203 204 300 301 302 303 304 307 308 \n ## : 404 405 410 414 418 500 501 502 503 504\n\n # * has a status code that is defined as cacheable by default (see\n # Section 4.2.2), or\n # rfc7231 6.1. Overview of Status Codes https:\/\/tools.ietf.org\/html\/rfc7231#section-6.1\n # rfc7231 and varnish default status codes : 200 203 204 300 301 302 304 307 404 405 410 414 501\n elsif (regsub(beresp.status, \"\", \"\") ~ \"^(20[034]|30[01247]|40[45]|41[04]|501)$\") {\n if (beresp.http.Last-Modified && std.time(beresp.http.Last-Modified, now) < now) {\n set beresp.http.X-Cacheable = \"YES:default=10s<\"+regsub((now - std.time(beresp.http.Last-Modified, now)) * 0.1, \"\\.\\d\\d\\d$\", \"\")+\"s<1d\";\n if ((now - std.time(beresp.http.Last-Modified, now)) * 0.1 <= 10s) {\n set beresp.ttl = 10s;\n }\n elsif ((now - std.time(beresp.http.Last-Modified, now)) * 0.1 < 1d) {\n set beresp.ttl = (now - std.time(beresp.http.Last-Modified, now)) * 0.1;\n }\n else {\n set beresp.ttl = 1d;\n }\n }\n else {\n set beresp.http.X-Cacheable = \"YES:default=119s\";\n set beresp.ttl = 119s;\n }\n }\n ## Extended default status codes\n ## : 303 308 418 500 502 503 504\n elsif (regsub(beresp.status, \"\", \"\") ~ \"^(30[38]|418|50[0234])$\") {\n if (beresp.http.Last-Modified && std.time(beresp.http.Last-Modified, now) < now) {\n set beresp.http.X-Cacheable = \"YES:extended=10s<\"+regsub((now - std.time(beresp.http.Last-Modified, now)) * 0.01, \"\\.\\d\\d\\d$\", \"\")+\"<1h\";\n if ((now - std.time(beresp.http.Last-Modified, now)) * 0.01 <= 10s) {\n set beresp.ttl = 10s;\n }\n elsif ((now - std.time(beresp.http.Last-Modified, now)) * 0.01 < 1h) {\n set beresp.ttl = (now - std.time(beresp.http.Last-Modified, now)) * 0.01;\n }\n else {\n set beresp.ttl = 1h;\n }\n }\n else {\n set beresp.http.X-Cacheable = \"YES:extended=19s\";\n set beresp.ttl = 19s;\n }\n }\n \n # * contains a public response directive (see Section 5.2.2.5).\n # rfc7234 5.2.2.5. public https:\/\/tools.ietf.org\/html\/rfc7234#section-5.2.2.5\n elsif (beresp.http.Cache-Control ~ \"(?i)(^|,)\\s*public\\s*(,|$)\") {\n if (beresp.http.Last-Modified && std.time(beresp.http.Last-Modified, now) < now) {\n set beresp.http.X-Cacheable = \"YES:public=10s<\"+regsub((now - std.time(beresp.http.Last-Modified, now)) * 0.1, \"\\.\\d\\d\\d$\", \"\")+\"<1d\";\n if ((now - std.time(beresp.http.Last-Modified, now)) * 0.1 <= 10s) {\n set beresp.ttl = 10s;\n }\n elsif ((now - std.time(beresp.http.Last-Modified, now)) * 0.1 < 1d) {\n set beresp.ttl = (now - std.time(beresp.http.Last-Modified, now)) * 0.1;\n }\n else {\n set beresp.ttl = 1d;\n }\n }\n else {\n set beresp.http.X-Cacheable = \"YES:public=119s\";\n set beresp.ttl = 119s;\n }\n }\n \n # The rest - no matching rules\n else {\n set beresp.http.X-Cacheable = \"NO:others\";\n set beresp.uncacheable = true;\n set beresp.ttl = 0s; \/\/ No hit for pass\n }\n \n # Set grace\n if (beresp.http.Cache-Control !~ \"(?i)(^|,)\\s*dr-maxage=\\d+\\+\\d+\\s*(,|$)\") {\n\n # 3. The stale-while-revalidate Cache-Control Extension http:\/\/tools.ietf.org\/html\/rfc5861#section-3\n # When present in an HTTP response, the stale-while-revalidate Cache-\n # Control extension indicates that caches MAY serve the response in\n # which it appears after it becomes stale, up to the indicated number\n # of seconds.\n if (beresp.http.Cache-Control ~ \"(?i)(^|,)\\s*stale-while-revalidate=\\d*\\s*(,|$)\") {\n set beresp.http.VAR-stale-while-revalidate = std.duration(regsub(\n beresp.http.Cache-Control, \"(?i)^(?:.*,)?\\s*stale-while-revalidate=(\\d+)\\s*(?:,.*)?$\", \"\\1s\"), 0s)+\"s\";\n }\n\n # 4. The stale-if-error Cache-Control Extension http:\/\/tools.ietf.org\/html\/rfc5861#section-4\n # The stale-if-error Cache-Control extension indicates that when an\n # error is encountered, a cached stale response MAY be used to satisfy\n # the request, regardless of other freshness information.\n if (beresp.http.Cache-Control ~ \"(?i)(^|,)\\s*stale-if-error=\\d+\\s*(,|$)\") {\n set beresp.http.VAR-stale-if-error = std.duration(regsub(\n beresp.http.Cache-Control, \"(?i)^(?:.*,)?\\s*stale-if-error=(\\d+)\\s*(?:,.*)?$\", \"\\1s\"), 0s)+\"s\";\n }\n \n # Default grace\n if (beresp.http.Last-Modified && std.time(beresp.http.Last-Modified, now) < now) {\n if ((now - std.time(beresp.http.Last-Modified, now)) * 0.5 <= 10s) {\n set beresp.http.VAR-stale-default = \"10s\";\n }\n elsif ((now - std.time(beresp.http.Last-Modified, now)) * 0.5 < 1d) {\n set beresp.http.VAR-stale-default = ((now - std.time(beresp.http.Last-Modified, now)) * 0.5)+\"s\";\n }\n else {\n set beresp.http.VAR-stale-default = \"86400s\";\n }\n }\n else {\n set beresp.http.VAR-stale-default = \"59s\";\n }\n \n \n # Pick largest grace\n if (std.duration(beresp.http.VAR-stale-while-revalidate, 0s) >= std.duration(beresp.http.VAR-stale-if-error, 0s) && \n std.duration(beresp.http.VAR-stale-while-revalidate, 0s) > std.duration(beresp.http.VAR-stale-default, 0s)) {\n set beresp.http.X-Cacheable = beresp.http.X-Cacheable+\";swr;grace=\"+std.duration(beresp.http.VAR-stale-while-revalidate, 0s);\n set beresp.grace = std.duration(beresp.http.VAR-stale-while-revalidate, 0s);\n }\n elsif (std.duration(beresp.http.VAR-stale-if-error, 0s) >= std.duration(beresp.http.VAR-stale-while-revalidate, 0s) && \n std.duration(beresp.http.VAR-stale-if-error, 0s) > std.duration(beresp.http.VAR-stale-default, 0s)) {\n set beresp.http.X-Cacheable = beresp.http.X-Cacheable+\";sie;grace=\"+std.duration(beresp.http.VAR-stale-if-error, 0s);\n set beresp.grace = std.duration(beresp.http.VAR-stale-if-error, 0s);\n }\n else {\n set beresp.http.X-Cacheable = beresp.http.X-Cacheable+\";def;grace=\"+std.duration(beresp.http.VAR-stale-default, 0s);\n set beresp.grace = std.duration(beresp.http.VAR-stale-default, 0s);\n }\n \n }\n \n # Set cache info for verbose\n set beresp.http.X-Caching = beresp.ttl + \"\/\" + beresp.grace + \"\/\" + beresp.keep + \"\/\" + beresp.uncacheable;\n\n # cacheable for freshness and stale serving\n if ( ! beresp.uncacheable) {\n set beresp.http.VAR-freshness_lifetime = beresp.ttl+\"s\";\n if (beresp.ttl == 0s) {\n std.log(\"cacheable_backend_response_cacheable: ttl=1ms hack for stale serving\");\n set beresp.ttl = 1ms;\n }\n }\n\n}\n\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"f9d45b7304c7a2ae39b8b9b27456b362f5fa6ea1","subject":"Add: commands for specs, console, replace, replace all","message":"Add: commands for specs, console, replace, replace all\n","repos":"aschneiderman\/atom-voice-vocola","old_file":"atom.vcl","new_file":"atom.vcl","new_contents":"# Voice commands for atom\n\ninclude folders.vch;\ninclude letters.vch;\n\nGo Strawberry = {Ctrl+Alt+F8};\n\n\n# Commands for developing Atom: init.config, packages; also for navigating existing packages\/commands\nReload Atom = {Ctrl+s} Wait(100) {Shift+Ctrl+Alt+F5};\nCommand Palette = {Ctrl+Shift+p};\nKeyboard Shortcuts = {Ctrl+.};\nRun Atom Specs = {Ctrl+Alt+p};\nShow Console = {Ctrl+Alt+i};\n\n# Commands for developing D3: D3 visualizations, D3 Sandwiches\nSave and Reload = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Ctrl+r};\t\nSave and Really Reload = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Ctrl+Shift+r};\n\n# File commands\nFind (File | Document) = {Ctrl+t};\nSave As = {Ctrl+Shift+s};\n\n\n# --- Navigation commands ------------------------------------\n<delimiters> := (Quote = '\"' | 'Single Quote' = \"'\" | Comma = ',' | 'Equal Sign' = '=' | Equals = '=' \n\t| Period = '.' | Colon = ':' | 'Semi-Colon' = ';' | Hyphen = '-' | Underscore = '_' | Slash = '\/'\n\t| Paren = \"(\" | \"Close Paren\" = \")\"\n\t| Bracket = '[' | \"Close Bracket\" = ']' | Brace = '{' | 'Close Brace' = '}'\t);\n\nLine 1..200 = {Ctrl+g} $1 {Enter};\n(Left = 'b' | Right = 'f') Word = {Alt+$1};\nTop = {Ctrl+Home};\nBottom = {Ctrl+End};\n(Find = 'Right' | 'Insert After' = 'Right' | 'Insert Before' = 'Left') (Next = 'Enter' | Last = 'Shift+F3') <delimiters> \n\t\t= {Ctrl+f} $3 {$2} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') <delimiters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') 1..20 <delimiters> = {Ctrl+f} $3 {Enter} {Esc} Wait(100) {F3_$2} {Shift+F3} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') Enda <delimiters> = {End} {Ctrl+f} $2 {Enter} {Esc} {Shift+F3} Wait(100) {$1};\n\nFine Alpha <letters> = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Left};\nInsert (Before = 'Left' | After = 'Right') Alpha <letters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nFine Number 0..9 = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Right};\nFind Again = {F3} {Right};\nFind Again 1..20 Times = {F3_$1} {Right};\n\nFind Symbol = {Ctrl+r};\n\n(Set | Add | Clear | Hide | Delete) Bookmark = {Ctrl+Alt+F2};\n(Next = 'F2' | Last = 'Shift+F2') Bookmark = {$1};\n\nNext Window = {Ctrl+Tab};\nLast Window = {Ctrl+Shift+Tab};\n\n\n# --- Editing commands ----------------------------------------\nSelect Line = {Ctrl+l};\nSelect (Next = 'Down' | Last = 'Up') 1..20 Lines = {Home} {Shift+$1_$2};\n(Join = 'j' | Indent = ']' | Dedent = '[') That = {Ctrl+$1};\nMove Line (Up | Down) 1..20 = {Ctrl+$1_$2};\n\n\n\nDelete Word = {Ctrl+Del};\nDelete 1..20 Words = {Ctrl+Del_$1};\nDelete (Back | Last) Word = {Ctrl+Backspace};\nDelete (Back | Last) 1..20 Words = {Ctrl+Backspace_$2};\nDelete Enda Word = {End} {Ctrl+Backspace};\n\n(Delete Line | Dede) = {Ctrl+Shift+k};\nDelete 1..20 Lines = {Ctrl+Shift+k_$1};\n(Cut = 'x' | Paste = 'v' | Copy = 'c') That = {Ctrl+$1};\n\nComment (That | Line) = {Ctrl+\/};\nComment 1..20 Lines = {Home} {Shift+Down_$1} {Ctrl+\/};\n\nSelect between (Delimiters | Brackets) ={Ctrl+m} {Ctrl+Alt+m};\n\nDelete Tags = {Ctrl+Alt+F4};\n\nReplace = {Ctrl+f};\nReplace All = {Ctrl+Enter};\n\n\n\n\n# --- Code commands -------------------------------------------\nStart (Item = 'li' | List = 'ul' | HTML = 'html' | pre = \"pre\"\n\t| 'Bold ID' = 'bold-id' | 'Input' = 'ds-input-text'\n\t| 'Fix Line' = 'fix-current-line' | 'Fix Current Line' = 'fix-current-line'\n\t| Snippet = 'my-snippet' | 'Recipe Row' = 'recipe-row' | 'Recipe Play' = 'recipe-play') = $1 {Tab};\nStart (para = '<p>' ) = $1;\nAdd (para = 'p') = '<' $1 '>' {End} '<\/' $1 '>';\nReplace With (para = 'p') = {Ctrl+Alt+F4} '<' $1 '>' {End} '<\/' $1 '>';\n\nStart (Header | Heading) 1..7 = h $2 {Tab};\nAdd (Header | Heading) 1..7 = '<h' $2 '>' {End} '<\/h' $2 '>';\nReplace With (Header | Heading) 1..7 = {Ctrl+Alt+F4} '<h' $2 '>' {End} '<\/h' $2 '>' {Home};\nMid HREF = '\">';\n\nPaste Function = 'function ' {Ctrl+v} ' {' {Enter} {Enter} '};' {Up};\n\nPre-Format Code = {Ctrl+Alt+F5};\n\n# TO ADD:\n# adding HTML comments, using a snippet\n\n\n\n","old_contents":"# Voice commands for atom\n\ninclude folders.vch;\ninclude letters.vch;\n\nGo Strawberry = {Ctrl+Alt+F8};\n\n\n# Commands for developing Atom: init.config, packages; also for navigating existing packages\/commands\nReload Atom = {Ctrl+s} Wait(100) {Shift+Ctrl+Alt+F5};\nCommand Palette = {Ctrl+Shift+p};\nKeyboard Shortcuts = {Ctrl+.};\n\n# Commands for developing D3: D3 visualizations, D3 Sandwiches\nSave and Reload = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Ctrl+r};\t\nSave and Really Reload = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Ctrl+Shift+r};\n\n# File commands\nFind (File | Document) = {Ctrl+t};\nSave As = {Ctrl+Shift+s};\n\n\n# --- Navigation commands ------------------------------------\n<delimiters> := (Quote = '\"' | 'Single Quote' = \"'\" | Comma = ',' | 'Equal Sign' = '=' | Equals = '=' \n\t| Period = '.' | Colon = ':' | 'Semi-Colon' = ';' | Hyphen = '-' | Underscore = '_' | Slash = '\/'\n\t| Paren = \"(\" | \"Close Paren\" = \")\"\n\t| Bracket = '[' | \"Close Bracket\" = ']' | Brace = '{' | 'Close Brace' = '}'\t);\n\nLine 1..200 = {Ctrl+g} $1 {Enter};\n(Left = 'b' | Right = 'f') Word = {Alt+$1};\nTop = {Ctrl+Home};\nBottom = {Ctrl+End};\n(Find = 'Right' | 'Insert After' = 'Right' | 'Insert Before' = 'Left') (Next = 'Enter' | Last = 'Shift+F3') <delimiters> \n\t\t= {Ctrl+f} $3 {$2} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') <delimiters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') 1..20 <delimiters> = {Ctrl+f} $3 {Enter} {Esc} Wait(100) {F3_$2} {Shift+F3} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') Enda <delimiters> = {End} {Ctrl+f} $2 {Enter} {Esc} {Shift+F3} Wait(100) {$1};\n\nFine Alpha <letters> = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Left};\nInsert (Before = 'Left' | After = 'Right') Alpha <letters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nFine Number 0..9 = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Right};\nFind Again = {F3} {Right};\nFind Again 1..20 Times = {F3_$1} {Right};\n\nFind Symbol = {Ctrl+r};\n\n(Set | Add | Clear | Hide | Delete) Bookmark = {Ctrl+Alt+F2};\n(Next = 'F2' | Last = 'Shift+F2') Bookmark = {$1};\n\nNext Window = {Ctrl+Tab};\nLast Window = {Ctrl+Shift+Tab};\n\n\n# --- Editing commands ----------------------------------------\nSelect Line = {Ctrl+l};\nSelect (Next = 'Down' | Last = 'Up') 1..20 Lines = {Home} {Shift+$1_$2};\n(Join = 'j' | Indent = ']' | Dedent = '[') That = {Ctrl+$1};\nMove Line (Up | Down) 1..20 = {Ctrl+$1_$2};\n\n\n\nDelete Word = {Ctrl+Del};\nDelete 1..20 Words = {Ctrl+Del_$1};\nDelete (Back | Last) Word = {Ctrl+Backspace};\nDelete (Back | Last) 1..20 Words = {Ctrl+Backspace_$2};\nDelete Enda Word = {End} {Ctrl+Backspace};\n\n(Delete Line | Dede) = {Ctrl+Shift+k};\nDelete 1..20 Lines = {Ctrl+Shift+k_$1};\n(Cut = 'x' | Paste = 'v' | Copy = 'c') That = {Ctrl+$1};\n\nComment (That | Line) = {Ctrl+\/};\nComment 1..20 Lines = {Home} {Shift+Down_$1} {Ctrl+\/};\n\nSelect between (Delimiters | Brackets) ={Ctrl+m} {Ctrl+Alt+m};\n\nDelete Tags = {Ctrl+Alt+F4};\n\n\n\n\n# --- Code commands -------------------------------------------\nStart (Item = 'li' | List = 'ul' | HTML = 'html' | pre = \"pre\"\n\t| 'Bold ID' = 'bold-id' | 'Input' = 'ds-input-text'\n\t| 'Fix Line' = 'fix-current-line' | 'Fix Current Line' = 'fix-current-line'\n\t| Snippet = 'my-snippet' | 'Recipe Row' = 'recipe-row' | 'Recipe Play' = 'recipe-play') = $1 {Tab};\nStart (para = '<p>' ) = $1;\nAdd (para = 'p') = '<' $1 '>' {End} '<\/' $1 '>';\nReplace With (para = 'p') = {Ctrl+Alt+F4} '<' $1 '>' {End} '<\/' $1 '>';\n\nStart (Header | Heading) 1..7 = h $2 {Tab};\nAdd (Header | Heading) 1..7 = '<h' $2 '>' {End} '<\/h' $2 '>';\nReplace With (Header | Heading) 1..7 = {Ctrl+Alt+F4} '<h' $2 '>' {End} '<\/h' $2 '>' {Home};\nMid HREF = '\">';\n\nPaste Function = 'function ' {Ctrl+v} ' {' {Enter} {Enter} '};' {Up};\n\nPre-Format Code = {Ctrl+Alt+F5};\n\n# TO ADD:\n# adding HTML comments, using a snippet\n\n\n\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"1e07cfe9f71908e22f759d9e1436cd4d00f250c8","subject":"Added newest Atom commands","message":"Added newest Atom commands\n","repos":"aschneiderman\/atom-voice-vocola","old_file":"atom.vcl","new_file":"atom.vcl","new_contents":"# Voice commands for atom\n\ninclude folders.vch;\ninclude letters.vch;\n\nFind (File | Document) = {Ctrl+t};\nSave As = {Ctrl+Shift+s};\nSave and Reload = {Ctrl+s} Wait(100) {Alt+Tab} Wait(300);\n\n<delimiters> := (Quote = '\"' | 'Single Quote' = \"'\" | Comma = ',' | 'Equal Sign' = '=' | Equals = '=' \n\t| Period = '.' | 'Semi-Colon' = ';');\n\n# --- Navigation commands ------------------------------------\nLine 1..200 = {Ctrl+g} $1 {Enter};\n(Left = 'b' | Right = 'f') Word = {Alt+$1};\nTop = {Ctrl+Home};\nBottom = {Ctrl+End};\n(Find = 'Right' | 'Insert After' = 'Right' | 'Insert Before' = 'Left') (Next = 'Enter' | Last = 'Shift+F3') <delimiters> \n\t\t= {Ctrl+f} $3 {$2} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') <delimiters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nFine Alpha <letters> = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Right};\nInsert (Before = 'Left' | After = 'Right') Alpha <letters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nFine Number 0..9 = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Right};\nFind Again = {F3} {Right};\nFind Again 1..20 Times = {F3_$1} {Right};\n\nFind Symbol = {Ctrl+r};\n\n(Set | Add | Clear | Hide | Delete) Bookmark = {Ctrl+Alt+F2};\n(Next = 'F2' | Last = 'Shift+F2') Bookmark = {$1};\n\nNext Window = {Ctrl+Tab};\nLast Window = {Ctrl+Shift+Tab};\n\n\n# --- Editing commands ----------------------------------------\nSelect (Next = 'Down' | Last = 'Up') 1..20 Lines = {Home} {Shift+$1_$2};\n(Join = 'j' | Indent = ']' | Dedent = '[') That = {Ctrl+$1};\nMove Line (Up | Down) 1..20 = {Ctrl+$1_$2};\n\n\n\nDelete Word = {Ctrl+Del};\nDelete 1..20 Words = {Ctrl+Del_$1};\n(Delete Line | Dede) = {Ctrl+Shift+k};\nDelete 1..20 Lines = {Ctrl+Shift+k_$1};\n(Cut = 'x' | Paste = 'v' | Copy = 'c') That = {Ctrl+$1};\n\nSelect between (Delimiters | Brackets) ={Ctrl+m} {Ctrl+Alt+m};\n# TO ADD:\n# Delete back three words\n# delete between next tags\n\n\n\n\n# --- Code commands -------------------------------------------\nStart (para = 'p' | Item = 'li' | List = 'ul' | HTML = 'html' | pre = \"pre\"\n\t| Snippet = 'snip' | 'Recipe Row' = 'recipe-row') = $1 {Tab};\nStart (Header | Heading) 1..7 = h $2 {Tab}; \nMid HREF = '\">';\n\n# TO ADD:\n# adding HTML comments, using a snippet\n\nShortcut Keys = {Ctrl+Shift+p};\n\n","old_contents":"# Voice commands for atom, a fabulous editor\n\ninclude folders.vch;\ninclude letters.vch;\n\nFind (File | Document) = {Ctrl+t};\nSave As = {Ctrl+Shift+s};\nSave and Reload = {Ctrl+s} Wait(100) {Alt+Tab} Wait(300);\n\n<delimiters> := (Quote = '\"' | 'Single Quote' = \"'\" | Comma = ',' | 'Equal Sign' = '=' | Equals = '=');\n\n# --- Navigation commands ------------------------------------\nLine 1..200 = {Ctrl+g} $1 {Enter};\n(Left = 'b' | Right = 'f') Word = {Alt+$1};\nTop = {Ctrl+Home};\nBottom = {Ctrl+End};\n\n\n(Find = 'Right' | 'Insert After' = 'Right' | 'Insert Before' = 'Left') (Next = 'Enter' | Last = 'Shift+F3') <delimiters> \n\t\t= {Ctrl+f} $3 {$2} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') <delimiters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\n\nFine Alpha <letters> = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Right};\nInsert (Before = 'Left' | After = 'Right') Alpha <letters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\n\nFind Again = {F3} {Right};\nFind Again 1..20 Times = {F3_$1} {Right};\n\nFind Symbol = {Ctrl+r};\n\n(Set | Add | Clear | Hide | Delete) Bookmark = {Ctrl+Alt+F2};\n(Next = 'F2' | Last = 'Shift+F2') Bookmark = {$1};\n\nNext Window = {Ctrl+Tab};\nLast Window = {Ctrl+Shift+Tab};\n\n\n# --- Editing commands ----------------------------------------\nSelect (Next = 'Down' | Last = 'Up') 1..20 Lines = {Home} {Shift+$1_$2};\nJoin That = {Ctrl+j};\nMove Line (Up | Down) 1..20 = {Ctrl+$1_$2};\n\nDelete Word = {Ctrl+Del};\nDelete 1..20 Words = {Ctrl+Del_$1};\n(Delete Line | Dede) = {Ctrl+Shift+k};\nDelete 1..20 Lines = {Ctrl+Shift+k_$1};\n\n# TO ADD:\n# DELETE TWO WORDS\n# delete between next tags\n\n\n\n\n# --- Code commands -------------------------------------------\nStart (para = 'p' | Item = 'li' | List = 'ul' | HTML = 'html'\n\t| Snippet = 'snip') = $1 {Tab};\nStart (Header | Heading) 1..7 = h $2 {Tab}; \n\n# TO ADD:\n# adding HTML comments, using a snippet\n\nShortcut Keys = {Ctrl+Shift+p};\n\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"75397a1e9b25638855d6cea4f501fbd33cbc19de","subject":"add svg to cache progress.svg in varnish","message":"add svg to cache progress.svg in varnish\n","repos":"ecreall\/nova-ideo,ecreall\/nova-ideo,ecreall\/nova-ideo,ecreall\/nova-ideo,ecreall\/nova-ideo","old_file":"etc\/varnish.vcl","new_file":"etc\/varnish.vcl","new_contents":"# This a configuration file for varnish.\n# It was generated by plone.recipe.varnish.\n# See the vcl(7) man page for details on VCL syntax and semantics.\n#\nvcl 4.0;\n\nimport std;\n\n# configure all backends\nbackend backend_000 {\n .host = \"127.0.0.1\";\n .port = \"5001\";\n .connect_timeout = 0.4s;\n .first_byte_timeout = 300s;\n .between_bytes_timeout = 60s;\n}\n\n\nsub vcl_init {\n\n}\n\nacl purge {\n \"localhost\";\n \"127.0.0.1\";\n}\n\nsub vcl_recv {\n set req.backend_hint = backend_000;\n set req.http.grace = \"none\";\n\n if (req.method == \"PURGE\") {\n # Not from an allowed IP? Then die with an error.\n if (!client.ip ~ purge) {\n return (synth(405, \"This IP is not allowed to send PURGE requests.\"));\n }\n return(purge);\n }\n\n if (req.method == \"BAN\") {\n # Same ACL check as above:\n if (!client.ip ~ purge) {\n return(synth(403, \"Not allowed.\"));\n }\n #ban(\"req.url ~ \" + req.url);\n ban(\"req.http.host == \" + req.http.host +\n \" && req.url == \" + req.url);\n # Throw a synthetic page so the\n # request won't go to the backend.\n return(synth(200, \"Ban added\"));\n }\n\n if (req.method == \"USERINFO\" ||\n req.method == \"CONNECT\" ||\n req.method == \"QUIT\") {\n return (synth(501, \"Not implemented\"));\n }\n\n # Only deal with \"normal\" types\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return(pipe);\n }\n\n # Only cache GET or HEAD requests. This makes sure the POST requests are always passed.\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return(pass);\n }\n\n if (req.http.Expect) {\n return(pipe);\n }\n\n if (req.http.If-None-Match && !req.http.If-Modified-Since) {\n return(pass);\n }\n\n \/* Do not cache other authorized content by default *\/\n if (req.http.Authenticate || req.http.Authorization) {\n return(pass);\n }\n\n if (req.url ~ \"@@registration|@@login|@@resetpassword\") {\n return(pass);\n }\n\n if (req.url ~ \"^[^?]*\\.(svg|css|js|png|gif|jpeg|jpg|woff|woff2)(\\?.*)?$\") {\n unset req.http.Cookie;\n }\n\n if (req.http.Cookie && req.http.Cookie ~ \"auth_tkt\") {\n return(pass);\n }\n\n unset req.http.Accept-Encoding;\n\n return(hash);\n}\n\nsub vcl_pipe {\n # By default Connection: close is set on all piped requests, to stop\n # connection reuse from sending future requests directly to the\n # (potentially) wrong backend. If you do want this to happen, you can undo\n # it here.\n # unset bereq.http.connection;\n\n return(pipe);\n}\n\nsub vcl_pass {\n return (fetch);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n if (req.http.X-Forwarded-Proto) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n return (lookup);\n}\n\nsub vcl_purge {\n return (synth(200, \"Purged\"));\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n \/\/ A pure unadultered hit, deliver it\n # normal hit\n return (deliver);\n }\n\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n if (obj.ttl + obj.grace > 0s) {\n set req.http.grace = \"normal(limited)\";\n return (deliver);\n }\n\n if (req.method == \"PURGE\") {\n set req.method = \"GET\";\n set req.http.X-purger = \"Purged\";\n return(synth(200, \"Purged. in hit \" + req.url));\n }\n\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\nsub vcl_miss {\n if (req.method == \"PURGE\") {\n set req.method = \"GET\";\n set req.http.X-purger = \"Purged-possibly\";\n return(synth(200, \"Purged. in miss \" + req.url));\n }\n\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\nsub vcl_backend_fetch{\n return (fetch);\n}\n\nsub vcl_backend_response {\n # The object is not cacheable\n if (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO - Set Cookie\";\n set beresp.ttl = 0s;\n set beresp.uncacheable = true;\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO - Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = 120s;\n } elsif (beresp.http.Surrogate-control ~ \"no-store\") {\n set beresp.http.X-Cacheable = \"NO - Surrogate-control=no-store\";\n set beresp.uncacheable = true;\n set beresp.ttl = 120s;\n } elsif (!beresp.http.Surrogate-Control && beresp.http.Cache-Control ~ \"no-cache|no-store\") {\n set beresp.http.X-Cacheable = \"NO - Cache-Control=no-cache|no-store\";\n set beresp.uncacheable = true;\n set beresp.ttl = 120s;\n } elsif (beresp.http.Vary == \"*\") {\n set beresp.http.X-Cacheable = \"NO - Vary=*\";\n set beresp.uncacheable = true;\n set beresp.ttl = 120s;\n\n\n # ttl handling\n } elsif (beresp.ttl < 0s) {\n set beresp.http.X-Cacheable = \"NO - TTL < 0\";\n set beresp.uncacheable = true;\n } elsif (beresp.ttl == 0s) {\n if (bereq.http.Cookie && bereq.http.Cookie ~ \"auth_tkt\") {\n set beresp.http.X-Cacheable = \"NO - TTL = 0\";\n set beresp.uncacheable = true;\n } else {\n set beresp.http.X-Cacheable = \"YES, 3600s\";\n set beresp.ttl = 3600s;\n set beresp.grace = 36000s;\n }\n\n # Varnish determined the object was cacheable\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n\n# https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleLongerCaching\n if (beresp.ttl == 31536000s) { # for deform.js, jquery.form-3.09.js from deformstatic\n \/* Remove Expires from backend, it's too long *\/\n unset beresp.http.expires;\n\n \/* Set the clients TTL on this object *\/\n set beresp.http.cache-control = \"max-age=86400\";\n\n \/* Set how long Varnish will keep it *\/\n set beresp.ttl = 86400s;\n }\n\n # Do not cache 5xx errors\n if (beresp.status >= 500 && beresp.status < 600) {\n unset beresp.http.Cache-Control;\n set beresp.http.X-Cache = \"NOCACHE\";\n set beresp.http.Cache-Control = \"no-cache, max-age=0, must-revalidate\";\n set beresp.ttl = 0s;\n set beresp.http.Pragma = \"no-cache\";\n set beresp.uncacheable = true;\n return(deliver);\n }\n\n return (deliver);\n}\n\nsub vcl_deliver {\n set resp.http.grace = req.http.grace;\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n \/* Rewrite s-maxage to exclude from intermediary proxies\n (to cache *everywhere*, just use 'max-age' token in the response to avoid\n this override) *\/\n if (resp.http.Cache-Control ~ \"s-maxage\") {\n set resp.http.Cache-Control = regsub(resp.http.Cache-Control, \"s-maxage=[0-9]+\", \"s-maxage=0\");\n }\n \/* Remove proxy-revalidate for intermediary proxies *\/\n if (resp.http.Cache-Control ~ \", proxy-revalidate\") {\n set resp.http.Cache-Control = regsub(resp.http.Cache-Control, \", proxy-revalidate\", \"\");\n }\n\n unset resp.http.Server;\n\n}\n\n\/*\n We can come here \"invisibly\" with the following errors: 413, 417 & 503\n*\/\nsub vcl_synth {\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n set resp.http.Retry-After = \"5\";\n\n synthetic( {\"\n <?xml version=\"1.0\" encoding=\"utf-8\"?>\n <!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n <html>\n <head>\n <title>Varnish cache server: \"} + resp.status + \" \" + resp.reason + {\" <\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n <\/html>\n \"} );\n\n return (deliver);\n}\n","old_contents":"# This a configuration file for varnish.\n# It was generated by plone.recipe.varnish.\n# See the vcl(7) man page for details on VCL syntax and semantics.\n#\nvcl 4.0;\n\nimport std;\n\n# configure all backends\nbackend backend_000 {\n .host = \"127.0.0.1\";\n .port = \"5001\";\n .connect_timeout = 0.4s;\n .first_byte_timeout = 300s;\n .between_bytes_timeout = 60s;\n}\n\n\nsub vcl_init {\n\n}\n\nacl purge {\n \"localhost\";\n \"127.0.0.1\";\n}\n\nsub vcl_recv {\n set req.backend_hint = backend_000;\n set req.http.grace = \"none\";\n\n if (req.method == \"PURGE\") {\n # Not from an allowed IP? Then die with an error.\n if (!client.ip ~ purge) {\n return (synth(405, \"This IP is not allowed to send PURGE requests.\"));\n }\n return(purge);\n }\n\n if (req.method == \"BAN\") {\n # Same ACL check as above:\n if (!client.ip ~ purge) {\n return(synth(403, \"Not allowed.\"));\n }\n #ban(\"req.url ~ \" + req.url);\n ban(\"req.http.host == \" + req.http.host +\n \" && req.url == \" + req.url);\n # Throw a synthetic page so the\n # request won't go to the backend.\n return(synth(200, \"Ban added\"));\n }\n\n if (req.method == \"USERINFO\" ||\n req.method == \"CONNECT\" ||\n req.method == \"QUIT\") {\n return (synth(501, \"Not implemented\"));\n }\n\n # Only deal with \"normal\" types\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return(pipe);\n }\n\n # Only cache GET or HEAD requests. This makes sure the POST requests are always passed.\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return(pass);\n }\n\n if (req.http.Expect) {\n return(pipe);\n }\n\n if (req.http.If-None-Match && !req.http.If-Modified-Since) {\n return(pass);\n }\n\n \/* Do not cache other authorized content by default *\/\n if (req.http.Authenticate || req.http.Authorization) {\n return(pass);\n }\n\n if (req.url ~ \"@@registration|@@login|@@resetpassword\") {\n return(pass);\n }\n\n if (req.url ~ \"^[^?]*\\.(css|js|png|gif|jpeg|jpg|woff|woff2)(\\?.*)?$\") {\n unset req.http.Cookie;\n }\n\n if (req.http.Cookie && req.http.Cookie ~ \"auth_tkt\") {\n return(pass);\n }\n\n unset req.http.Accept-Encoding;\n\n return(hash);\n}\n\nsub vcl_pipe {\n # By default Connection: close is set on all piped requests, to stop\n # connection reuse from sending future requests directly to the\n # (potentially) wrong backend. If you do want this to happen, you can undo\n # it here.\n # unset bereq.http.connection;\n\n return(pipe);\n}\n\nsub vcl_pass {\n return (fetch);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n if (req.http.X-Forwarded-Proto) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n return (lookup);\n}\n\nsub vcl_purge {\n return (synth(200, \"Purged\"));\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n \/\/ A pure unadultered hit, deliver it\n # normal hit\n return (deliver);\n }\n\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n if (obj.ttl + obj.grace > 0s) {\n set req.http.grace = \"normal(limited)\";\n return (deliver);\n }\n\n if (req.method == \"PURGE\") {\n set req.method = \"GET\";\n set req.http.X-purger = \"Purged\";\n return(synth(200, \"Purged. in hit \" + req.url));\n }\n\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\nsub vcl_miss {\n if (req.method == \"PURGE\") {\n set req.method = \"GET\";\n set req.http.X-purger = \"Purged-possibly\";\n return(synth(200, \"Purged. in miss \" + req.url));\n }\n\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\nsub vcl_backend_fetch{\n return (fetch);\n}\n\nsub vcl_backend_response {\n # The object is not cacheable\n if (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO - Set Cookie\";\n set beresp.ttl = 0s;\n set beresp.uncacheable = true;\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO - Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = 120s;\n } elsif (beresp.http.Surrogate-control ~ \"no-store\") {\n set beresp.http.X-Cacheable = \"NO - Surrogate-control=no-store\";\n set beresp.uncacheable = true;\n set beresp.ttl = 120s;\n } elsif (!beresp.http.Surrogate-Control && beresp.http.Cache-Control ~ \"no-cache|no-store\") {\n set beresp.http.X-Cacheable = \"NO - Cache-Control=no-cache|no-store\";\n set beresp.uncacheable = true;\n set beresp.ttl = 120s;\n } elsif (beresp.http.Vary == \"*\") {\n set beresp.http.X-Cacheable = \"NO - Vary=*\";\n set beresp.uncacheable = true;\n set beresp.ttl = 120s;\n\n\n # ttl handling\n } elsif (beresp.ttl < 0s) {\n set beresp.http.X-Cacheable = \"NO - TTL < 0\";\n set beresp.uncacheable = true;\n } elsif (beresp.ttl == 0s) {\n if (bereq.http.Cookie && bereq.http.Cookie ~ \"auth_tkt\") {\n set beresp.http.X-Cacheable = \"NO - TTL = 0\";\n set beresp.uncacheable = true;\n } else {\n set beresp.http.X-Cacheable = \"YES, 3600s\";\n set beresp.ttl = 3600s;\n set beresp.grace = 36000s;\n }\n\n # Varnish determined the object was cacheable\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n\n# https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleLongerCaching\n if (beresp.ttl == 31536000s) { # for deform.js, jquery.form-3.09.js from deformstatic\n \/* Remove Expires from backend, it's too long *\/\n unset beresp.http.expires;\n\n \/* Set the clients TTL on this object *\/\n set beresp.http.cache-control = \"max-age=86400\";\n\n \/* Set how long Varnish will keep it *\/\n set beresp.ttl = 86400s;\n }\n\n # Do not cache 5xx errors\n if (beresp.status >= 500 && beresp.status < 600) {\n unset beresp.http.Cache-Control;\n set beresp.http.X-Cache = \"NOCACHE\";\n set beresp.http.Cache-Control = \"no-cache, max-age=0, must-revalidate\";\n set beresp.ttl = 0s;\n set beresp.http.Pragma = \"no-cache\";\n set beresp.uncacheable = true;\n return(deliver);\n }\n\n return (deliver);\n}\n\nsub vcl_deliver {\n set resp.http.grace = req.http.grace;\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n \/* Rewrite s-maxage to exclude from intermediary proxies\n (to cache *everywhere*, just use 'max-age' token in the response to avoid\n this override) *\/\n if (resp.http.Cache-Control ~ \"s-maxage\") {\n set resp.http.Cache-Control = regsub(resp.http.Cache-Control, \"s-maxage=[0-9]+\", \"s-maxage=0\");\n }\n \/* Remove proxy-revalidate for intermediary proxies *\/\n if (resp.http.Cache-Control ~ \", proxy-revalidate\") {\n set resp.http.Cache-Control = regsub(resp.http.Cache-Control, \", proxy-revalidate\", \"\");\n }\n\n unset resp.http.Server;\n\n}\n\n\/*\n We can come here \"invisibly\" with the following errors: 413, 417 & 503\n*\/\nsub vcl_synth {\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n set resp.http.Retry-After = \"5\";\n\n synthetic( {\"\n <?xml version=\"1.0\" encoding=\"utf-8\"?>\n <!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n <html>\n <head>\n <title>Varnish cache server: \"} + resp.status + \" \" + resp.reason + {\" <\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n <\/html>\n \"} );\n\n return (deliver);\n}\n","returncode":0,"stderr":"","license":"agpl-3.0","lang":"VCL"} {"commit":"bdc63fc38748ff6abe5f4652b62dbbd2f5a33145","subject":"Update device detection VCL","message":"Update device detection VCL\n","repos":"gquintard\/Varnish-Cache,gquintard\/Varnish-Cache,gquintard\/Varnish-Cache,feld\/Varnish-Cache,feld\/Varnish-Cache,gquintard\/Varnish-Cache,feld\/Varnish-Cache,feld\/Varnish-Cache,feld\/Varnish-Cache","old_file":"etc\/devicedetect.vcl","new_file":"etc\/devicedetect.vcl","new_contents":"# Copyright (c) 2012-2014 Varnish Software AS\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions\n# are met:\n# 1. Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n# 2. Redistributions in binary form must reproduce the above copyright\n# notice, this list of conditions and the following disclaimer in the\n# documentation and\/or other materials provided with the distribution.\n#\n# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n# ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n# SUCH DAMAGE.\n#\n# detectdevice.vcl - regex based device detection for Varnish\n# https:\/\/github.com\/varnishcache\/varnish-devicedetect\/\n#\n# Author: Lasse Karstensen <lkarsten@varnish-software.com>\n\nsub devicedetect {\n\tunset req.http.X-UA-Device;\n\tset req.http.X-UA-Device = \"pc\";\n\n\t# Handle that a cookie may override the detection alltogether.\n\tif (req.http.Cookie ~ \"(?i)X-UA-Device-force\") {\n\t\t\/* ;?? means zero or one ;, non-greedy to match the first. *\/\n\t\tset req.http.X-UA-Device = regsub(req.http.Cookie, \"(?i).*X-UA-Device-force=([^;]+);??.*\", \"\\1\");\n\t\t\/* Clean up our mess in the cookie header *\/\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|; ) *X-UA-Device-force=[^;]+;? *\", \"\\1\");\n\t\t\/* If the cookie header is now empty, or just whitespace, unset it. *\/\n\t\tif (req.http.Cookie ~ \"^ *$\") { unset req.http.Cookie; }\n\t} else {\n if (req.http.User-Agent ~ \"\\(compatible; Googlebot-Mobile\/2.1; \\+http:\/\/www.google.com\/bot.html\\)\" ||\n (req.http.User-Agent ~ \"iPhone\" && req.http.User-Agent ~ \"\\(compatible; Googlebot\/2.1; \\+http:\/\/www.google.com\/bot.html\")) {\n set req.http.X-UA-Device = \"mobile-bot\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)(ads|google|bing|msn|yandex|baidu|ro|career|seznam|)bot\" ||\n\t\t req.http.User-Agent ~ \"(?i)(baidu|jike|symantec)spider\" ||\n\t\t req.http.User-Agent ~ \"(?i)scanner\" ||\n\t\t req.http.User-Agent ~ \"(?i)(web)crawler\") {\n\t\t\tset req.http.X-UA-Device = \"bot\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ipad\") { set req.http.X-UA-Device = \"tablet-ipad\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ip(hone|od)\") { set req.http.X-UA-Device = \"mobile-iphone\"; }\n\t\t\/* how do we differ between an android phone and an android tablet?\n\t\t http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent *\/\n\t\telsif (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") { set req.http.X-UA-Device = \"mobile-android\"; }\n\t\t\/\/ android 3\/honeycomb was just about tablet-only, and any phones will probably handle a bigger page layout.\n\t\telsif (req.http.User-Agent ~ \"(?i)android 3\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\t\/* Opera Mobile *\/\n\t\telsif (req.http.User-Agent ~ \"Opera Mobi\") { set req.http.X-UA-Device = \"mobile-smartphone\"; }\n\t\t\/\/ May very well give false positives towards android tablets. Suggestions welcome.\n\t\telsif (req.http.User-Agent ~ \"(?i)android\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\telsif (req.http.User-Agent ~ \"PlayBook; U; RIM Tablet\") { set req.http.X-UA-Device = \"tablet-rim\"; }\n\t\telsif (req.http.User-Agent ~ \"hp-tablet.*TouchPad\") { set req.http.X-UA-Device = \"tablet-hp\"; }\n\t\telsif (req.http.User-Agent ~ \"Kindle\/3\") { set req.http.X-UA-Device = \"tablet-kindle\"; }\n\t\telsif (req.http.User-Agent ~ \"Touch.+Tablet PC\" ||\n\t\t req.http.User-Agent ~ \"Windows NT [0-9.]+; ARM;\" ) {\n\t\t set req.http.X-UA-Device = \"tablet-microsoft\";\n\t\t}\n\t\telsif (req.http.User-Agent ~ \"Mobile.+Firefox\") { set req.http.X-UA-Device = \"mobile-firefoxos\"; }\n\t\telsif (req.http.User-Agent ~ \"^HTC\" ||\n\t\t req.http.User-Agent ~ \"Fennec\" ||\n\t\t req.http.User-Agent ~ \"IEMobile\" ||\n\t\t req.http.User-Agent ~ \"BlackBerry\" ||\n\t\t req.http.User-Agent ~ \"BB10.*Mobile\" ||\n\t\t req.http.User-Agent ~ \"GT-.*Build\/GINGERBREAD\" ||\n\t\t req.http.User-Agent ~ \"SymbianOS.*AppleWebKit\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-smartphone\";\n\t\t}\n\t\telsif (req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)^sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)^nokia\" ||\n\t\t req.http.User-Agent ~ \"(?i)^samsung\" ||\n\t\t req.http.User-Agent ~ \"(?i)^lg\" ||\n\t\t req.http.User-Agent ~ \"(?i)bada\" ||\n\t\t req.http.User-Agent ~ \"(?i)blazer\" ||\n\t\t req.http.User-Agent ~ \"(?i)cellphone\" ||\n\t\t req.http.User-Agent ~ \"(?i)iemobile\" ||\n\t\t req.http.User-Agent ~ \"(?i)midp-2.0\" ||\n\t\t req.http.User-Agent ~ \"(?i)u990\" ||\n\t\t req.http.User-Agent ~ \"(?i)netfront\" ||\n\t\t req.http.User-Agent ~ \"(?i)opera mini\" ||\n\t\t req.http.User-Agent ~ \"(?i)palm\" ||\n\t\t req.http.User-Agent ~ \"(?i)nintendo wii\" ||\n\t\t req.http.User-Agent ~ \"(?i)playstation portable\" ||\n\t\t req.http.User-Agent ~ \"(?i)portalmmm\" ||\n\t\t req.http.User-Agent ~ \"(?i)proxinet\" ||\n\t\t req.http.User-Agent ~ \"(?i)sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)windows\\ ?ce\" ||\n\t\t req.http.User-Agent ~ \"(?i)winwap\" ||\n\t\t req.http.User-Agent ~ \"(?i)eudoraweb\" ||\n\t\t req.http.User-Agent ~ \"(?i)htc\" ||\n\t\t req.http.User-Agent ~ \"(?i)240x320\" ||\n\t\t req.http.User-Agent ~ \"(?i)avantgo\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-generic\";\n\t\t}\n\t}\n}\n","old_contents":"# Copyright (c) 2012-2014 Varnish Software AS\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions\n# are met:\n# 1. Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n# 2. Redistributions in binary form must reproduce the above copyright\n# notice, this list of conditions and the following disclaimer in the\n# documentation and\/or other materials provided with the distribution.\n#\n# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n# ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n# SUCH DAMAGE.\n#\n# detectdevice.vcl - regex based device detection for Varnish\n# https:\/\/github.com\/varnishcache\/varnish-devicedetect\/\n#\n# Author: Lasse Karstensen <lkarsten@varnish-software.com>\n\nsub devicedetect {\n\tunset req.http.X-UA-Device;\n\tset req.http.X-UA-Device = \"pc\";\n\n\t# Handle that a cookie may override the detection alltogether.\n\tif (req.http.Cookie ~ \"(?i)X-UA-Device-force\") {\n\t\t\/* ;?? means zero or one ;, non-greedy to match the first. *\/\n\t\tset req.http.X-UA-Device = regsub(req.http.Cookie, \"(?i).*X-UA-Device-force=([^;]+);??.*\", \"\\1\");\n\t\t\/* Clean up our mess in the cookie header *\/\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|; ) *X-UA-Device-force=[^;]+;? *\", \"\\1\");\n\t\t\/* If the cookie header is now empty, or just whitespace, unset it. *\/\n\t\tif (req.http.Cookie ~ \"^ *$\") { unset req.http.Cookie; }\n\t} else {\n if (req.http.User-Agent ~ \"\\(compatible; Googlebot-Mobile\/2.1; \\+http:\/\/www.google.com\/bot.html\\)\" ||\n (req.http.User-Agent ~ \"iPhone\" && req.http.User-Agent ~ \"\\(compatible; Googlebot\/2.1; \\+http:\/\/www.google.com\/bot.html\")) {\n set req.http.X-UA-Device = \"mobile-bot\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)(ads|google|bing|msn|yandex|baidu|ro|career|)bot\" ||\n\t\t req.http.User-Agent ~ \"(?i)(baidu|jike|symantec)spider\" ||\n\t\t req.http.User-Agent ~ \"(?i)scanner\" ||\n\t\t req.http.User-Agent ~ \"(?i)(web)crawler\") {\n\t\t\tset req.http.X-UA-Device = \"bot\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ipad\") { set req.http.X-UA-Device = \"tablet-ipad\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ip(hone|od)\") { set req.http.X-UA-Device = \"mobile-iphone\"; }\n\t\t\/* how do we differ between an android phone and an android tablet?\n\t\t http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent *\/\n\t\telsif (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") { set req.http.X-UA-Device = \"mobile-android\"; }\n\t\t\/\/ android 3\/honeycomb was just about tablet-only, and any phones will probably handle a bigger page layout.\n\t\telsif (req.http.User-Agent ~ \"(?i)android 3\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\t\/* Opera Mobile *\/\n\t\telsif (req.http.User-Agent ~ \"Opera Mobi\") { set req.http.X-UA-Device = \"mobile-smartphone\"; }\n\t\t\/\/ May very well give false positives towards android tablets. Suggestions welcome.\n\t\telsif (req.http.User-Agent ~ \"(?i)android\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\telsif (req.http.User-Agent ~ \"PlayBook; U; RIM Tablet\") { set req.http.X-UA-Device = \"tablet-rim\"; }\n\t\telsif (req.http.User-Agent ~ \"hp-tablet.*TouchPad\") { set req.http.X-UA-Device = \"tablet-hp\"; }\n\t\telsif (req.http.User-Agent ~ \"Kindle\/3\") { set req.http.X-UA-Device = \"tablet-kindle\"; }\n\t\telsif (req.http.User-Agent ~ \"Touch.+Tablet PC\") { set req.http.X-UA-Device = \"tablet-microsoft\"; }\n\t\telsif (req.http.User-Agent ~ \"Mobile.+Firefox\") { set req.http.X-UA-Device = \"mobile-firefoxos\"; }\n\t\telsif (req.http.User-Agent ~ \"^HTC\" ||\n\t\t req.http.User-Agent ~ \"Fennec\" ||\n\t\t req.http.User-Agent ~ \"IEMobile\" ||\n\t\t req.http.User-Agent ~ \"BlackBerry\" ||\n\t\t req.http.User-Agent ~ \"BB10.*Mobile\" ||\n\t\t req.http.User-Agent ~ \"GT-.*Build\/GINGERBREAD\" ||\n\t\t req.http.User-Agent ~ \"SymbianOS.*AppleWebKit\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-smartphone\";\n\t\t}\n\t\telsif (req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)^sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)^nokia\" ||\n\t\t req.http.User-Agent ~ \"(?i)^samsung\" ||\n\t\t req.http.User-Agent ~ \"(?i)^lg\" ||\n\t\t req.http.User-Agent ~ \"(?i)bada\" ||\n\t\t req.http.User-Agent ~ \"(?i)blazer\" ||\n\t\t req.http.User-Agent ~ \"(?i)cellphone\" ||\n\t\t req.http.User-Agent ~ \"(?i)iemobile\" ||\n\t\t req.http.User-Agent ~ \"(?i)midp-2.0\" ||\n\t\t req.http.User-Agent ~ \"(?i)u990\" ||\n\t\t req.http.User-Agent ~ \"(?i)netfront\" ||\n\t\t req.http.User-Agent ~ \"(?i)opera mini\" ||\n\t\t req.http.User-Agent ~ \"(?i)palm\" ||\n\t\t req.http.User-Agent ~ \"(?i)nintendo wii\" ||\n\t\t req.http.User-Agent ~ \"(?i)playstation portable\" ||\n\t\t req.http.User-Agent ~ \"(?i)portalmmm\" ||\n\t\t req.http.User-Agent ~ \"(?i)proxinet\" ||\n\t\t req.http.User-Agent ~ \"(?i)sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)windows\\ ?ce\" ||\n\t\t req.http.User-Agent ~ \"(?i)winwap\" ||\n\t\t req.http.User-Agent ~ \"(?i)eudoraweb\" ||\n\t\t req.http.User-Agent ~ \"(?i)htc\" ||\n\t\t req.http.User-Agent ~ \"(?i)240x320\" ||\n\t\t req.http.User-Agent ~ \"(?i)avantgo\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-generic\";\n\t\t}\n\t}\n}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"3650c08e9e7da9f04b8c0143183cc4243d1f98c6","subject":"add fastly purge auth to vcl file (#729)","message":"add fastly purge auth to vcl file (#729)","repos":"kdzwinel\/polyfill-service,JakeChampion\/polyfill-service,mcshaz\/polyfill-service,mcshaz\/polyfill-service,jonathan-fielding\/polyfill-service,jonathan-fielding\/polyfill-service,mcshaz\/polyfill-service,kdzwinel\/polyfill-service,JakeChampion\/polyfill-service,kdzwinel\/polyfill-service,jonathan-fielding\/polyfill-service","old_file":"fastly-config.vcl","new_file":"fastly-config.vcl","new_contents":"sub vcl_recv {\n#FASTLY recv\n\tif ( req.request == \"FASTLYPURGE\" ) {\n\t\tset req.http.Fastly-Purge-Requires-Auth = \"1\";\n\t}\n\n\tif (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n\t\treturn(pass);\n\t}\n\n\tif (!req.http.Fastly-SSL && req.http.Host == \"cdn.polyfill.io\") {\n\t\terror 751 \"Force TLS\";\n\t}\n\n\tif (req.url ~ \"^\/v2\/polyfill\\.\" && req.url !~ \"[\\?\\&]ua=\") {\n\t\tset req.http.X-Orig-URL = req.url;\n\t\tset req.url = \"\/v2\/normalizeUa?ua=\" urlencode(req.http.User-Agent);\n\t}\n\n\treturn(lookup);\n}\n\nsub vcl_deliver {\n#FASTLY deliver\n\n\t# If the response is to a normalise request and there's a parked \"original request\", use the normalised UA response to modify the original request and restart it\n\tif (req.url ~ \"^\/v\\d\/normalizeUa\" && resp.status == 200 && req.http.X-Orig-URL) {\n\t\tset req.http.Fastly-force-Shield = \"1\";\n\t\tif (req.http.X-Orig-URL ~ \"\\?\") {\n\t\t\tset req.url = req.http.X-Orig-URL \"&ua=\" resp.http.Normalized-User-Agent;\n\t\t} else {\n\t\t\tset req.url = req.http.X-Orig-URL \"?ua=\" resp.http.Normalized-User-Agent;\n\t\t}\n\t\trestart;\n\n\t# If the original request didn't specify a UA override, and we added one when the request was sent to the backend, the backend won't have included a Vary:user-agent header (correctly) but we need to add one\n\t} else if (req.url ~ \"^\/v\\d\/polyfill\\..*[\\?\\&]ua=\" && req.http.X-Orig-URL && req.http.X-Orig-URL !~ \"[\\?\\&]ua=\") {\n\t\tadd resp.http.Vary = \"User-Agent\";\n\t}\n\treturn(deliver);\n}\n\nsub vcl_error {\n\n\t# Redirect to SSL\n\tif (obj.status == 751) {\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\tset obj.http.Location = \"https:\/\/\" req.http.host req.url;\n\t\tsynthetic {\"\"};\n\t\treturn (deliver);\n\t}\n}","old_contents":"sub vcl_recv {\n#FASTLY recv\n\n\tif (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n\t\treturn(pass);\n\t}\n\n\tif (!req.http.Fastly-SSL && req.http.Host == \"cdn.polyfill.io\") {\n\t\terror 751 \"Force TLS\";\n\t}\n\n\tif (req.url ~ \"^\/v2\/polyfill\\.\" && req.url !~ \"[\\?\\&]ua=\") {\n\t\tset req.http.X-Orig-URL = req.url;\n\t\tset req.url = \"\/v2\/normalizeUa?ua=\" urlencode(req.http.User-Agent);\n\t}\n\n\treturn(lookup);\n}\n\nsub vcl_deliver {\n#FASTLY deliver\n\n\t# If the response is to a normalise request and there's a parked \"original request\", use the normalised UA response to modify the original request and restart it\n\tif (req.url ~ \"^\/v\\d\/normalizeUa\" && resp.status == 200 && req.http.X-Orig-URL) {\n\t\tset req.http.Fastly-force-Shield = \"1\";\n\t\tif (req.http.X-Orig-URL ~ \"\\?\") {\n\t\t\tset req.url = req.http.X-Orig-URL \"&ua=\" resp.http.Normalized-User-Agent;\n\t\t} else {\n\t\t\tset req.url = req.http.X-Orig-URL \"?ua=\" resp.http.Normalized-User-Agent;\n\t\t}\n\t\trestart;\n\n\t# If the original request didn't specify a UA override, and we added one when the request was sent to the backend, the backend won't have included a Vary:user-agent header (correctly) but we need to add one\n\t} else if (req.url ~ \"^\/v\\d\/polyfill\\..*[\\?\\&]ua=\" && req.http.X-Orig-URL && req.http.X-Orig-URL !~ \"[\\?\\&]ua=\") {\n\t\tadd resp.http.Vary = \"User-Agent\";\n\t}\n\treturn(deliver);\n}\n\nsub vcl_error {\n\n\t# Redirect to SSL\n\tif (obj.status == 751) {\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\tset obj.http.Location = \"https:\/\/\" req.http.host req.url;\n\t\tsynthetic {\"\"};\n\t\treturn (deliver);\n\t}\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"3a1c1d8e4d678d53863eaf0971673933af05cecb","subject":"trying to get web sockets to work","message":"trying to get web sockets to work\n","repos":"derbyjs\/candygram","old_file":"varnish_default.vcl","new_file":"varnish_default.vcl","new_contents":"","old_contents":"","returncode":0,"stderr":"unknown","license":"mit","lang":"VCL"} {"commit":"bb5fab874a1a12aff9281ecf465ed1b75c837d74","subject":"White space OCD.","message":"White space OCD.\n","repos":"chrismoulton\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,gquintard\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,varnish\/Varnish-Cache,mrhmouse\/Varnish-Cache,franciscovg\/Varnish-Cache,varnish\/Varnish-Cache,chrismoulton\/Varnish-Cache,franciscovg\/Varnish-Cache,franciscovg\/Varnish-Cache,franciscovg\/Varnish-Cache,gquintard\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,varnish\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,gquintard\/Varnish-Cache,mrhmouse\/Varnish-Cache,varnish\/Varnish-Cache,mrhmouse\/Varnish-Cache,feld\/Varnish-Cache,chrismoulton\/Varnish-Cache,feld\/Varnish-Cache,gquintard\/Varnish-Cache,zhoualbeart\/Varnish-Cache,franciscovg\/Varnish-Cache,feld\/Varnish-Cache,chrismoulton\/Varnish-Cache,chrismoulton\/Varnish-Cache,mrhmouse\/Varnish-Cache,zhoualbeart\/Varnish-Cache,varnish\/Varnish-Cache,feld\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,feld\/Varnish-Cache,zhoualbeart\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,zhoualbeart\/Varnish-Cache,mrhmouse\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,zhoualbeart\/Varnish-Cache","old_file":"etc\/example.vcl","new_file":"etc\/example.vcl","new_contents":"#\n# This is an example VCL file for Varnish.\n#\n# It does not do anything by default, delegating control to the\n# builtin VCL. The builtin VCL is called when there is no explicit\n# return statement.\n#\n# See the VCL chapters in the Users Guide at https:\/\/www.varnish-cache.org\/docs\/\n# and http:\/\/varnish-cache.org\/trac\/wiki\/VCLExamples for more examples.\n\n# Marker to tell the VCL compiler that this VCL has been adapted to the\n# new 4.0 format.\nvcl 4.0;\n\n# Default backend definition. Set this to point to your content server.\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\n\nsub vcl_recv {\n # Happens before we check if we have this in cache already.\n #\n # Typically you clean up the request here, removing cookies you don't need,\n # rewriting the request, etc.\n}\n\nsub vcl_backend_response {\n # Happens after we have read the response headers from the backend.\n #\n # Here you clean the response headers, removing silly Set-Cookie headers\n # and other mistakes your backend does.\n}\n\nsub vcl_deliver {\n # Happens when we have all the pieces we need, and are about to send the\n # response to the client.\n #\n # You can do accounting or modifying the final object here.\n}\n","old_contents":"#\n# This is an example VCL file for Varnish.\n#\n# It does not do anything by default, delegating control to the\n# builtin VCL. The builtin VCL is called when there is no explicit\n# return statement.\n#\n# See the VCL chapters in the Users Guide at https:\/\/www.varnish-cache.org\/docs\/\n# and http:\/\/varnish-cache.org\/trac\/wiki\/VCLExamples for more examples.\n\n# Marker to tell the VCL compiler that this VCL has been adapted to the\n# new 4.0 format.\nvcl 4.0;\n\n# Default backend definition. Set this to point to your content server.\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\n\nsub vcl_recv {\n # Happens before we check if we have this in cache already.\n # \n # Typically you clean up the request here, removing cookies you don't need,\n # rewriting the request, etc.\n}\n\nsub vcl_backend_response {\n # Happens after we have read the response headers from the backend.\n # \n # Here you clean the response headers, removing silly Set-Cookie headers\n # and other mistakes your backend does.\n}\n\nsub vcl_deliver {\n # Happens when we have all the pieces we need, and are about to send the\n # response to the client.\n # \n # You can do accounting or modifying the final object here.\n}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"9d6fa3691f14a6cf702b893cca4b9ad5863e06fa","subject":"We weren't creating hit for pass objects","message":"We weren't creating hit for pass objects\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets\/fetch.vcl","new_file":"etc\/vcl_snippets\/fetch.vcl","new_contents":" # If we are doing a bypass for Magento Tester return early as not to affect any headers\n if ( req.http.bypass-secret ) {\n set beresp.ttl = 0s;\n return(pass);\n }\n\n \/* handle 5XX (or any other unwanted status code) *\/\n if (beresp.status >= 500 && beresp.status < 600) {\n\n \/* deliver stale if the object is available *\/\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n # Remove Set-Cookies from responses for static content to match the cookie removal in recv.\n if (req.http.x-long-cache || req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's since those can be temporary during the site build\/index\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n set beresp.http.Cache-Control = \"max-age=0\";\n } else if (req.http.x-long-cache) {\n # Force caching for signed cached assets.\n set beresp.ttl = 31536000s;\n # Add immutable as it avoids IMS and INM revalidations\n set beresp.http.Cache-Control = \"max-age=31536000, immutable\";\n # Remove HTTP\/1.0 caching headers as they may mess with browser memory caches\n unset beresp.http.Pragma;\n unset beresp.http.Expires;\n }\n }\n\n # Fix Vary Header in some cases. In 99.9% of cases Varying on User-Agent is counterproductive\n # https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleFixupVary\n if (beresp.http.Vary ~ \"User-Agent\") {\n unset beresp.http.Vary:User-Agent;\n if (beresp.http.Vary == \"\") {\n unset beresp.http.Vary;\n }\n }\n\n # All the Magento responses should emit X-Esi headers\n if (beresp.http.x-esi) {\n # enable ESI feature for Magento response by default\n esi;\n } else {\n # enable gzip for all static content except\n if ( http_status_matches(beresp.status, \"200,404\") && (beresp.http.content-type ~ \"^(application\/x\\-javascript|text\/css|text\/html|application\/javascript|text\/javascript|application\/json|application\/vnd\\.ms\\-fontobject|application\/x\\-font\\-opentype|application\/x\\-font\\-truetype|application\/x\\-font\\-ttf|application\/xml|font\/eot|font\/opentype|font\/otf|image\/svg\\+xml|image\/vnd\\.microsoft\\.icon|text\/plain)\\s*($|;)\" || req.url.ext ~ \"(?i)(css|js|html|eot|ico|otf|ttf|json)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n set beresp.http.Vary:Accept-Encoding = \"\";\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # Add Varying on Store and Content-Currency for GraphQl, X-Magento-Vary otherwise\n if (req.http.graphql) {\n set beresp.http.Vary:Store = \"\";\n set beresp.http.Vary:Content-Currency = \"\";\n } else if (beresp.http.Content-Type ~ \"text\/(html|xml)\") {\n set beresp.http.Vary:X-Magento-Vary = \"\";\n set beresp.http.Vary:Https = \"\";\n }\n\n # Just in case the Request Setting for x-pass is missing\n if (req.http.x-pass) {\n return (pass);\n }\n\n # We are extending the default Fastly behavior to include no-cache\/no-store in addition to private\n if (beresp.http.Cache-Control ~ \"private|no-cache|no-store\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # Never cache 302s\n if (beresp.status == 302) {\n return (pass);\n }\n\n if (beresp.http.x-amz-request-id) {\n # If assets are coming from Amazon they may have no Cache-Control headers which may make them uncacheable\n\n # If the object is coming with no Expires, Surrogate-Control or Cache-Control headers we assume it's a misconfiguration\n # and we will not cache it. This is to prevent inadventently caching private data\n } else if (!beresp.http.Expires && !beresp.http.Surrogate-Control ~ \"max-age\" && !beresp.http.Cache-Control ~ \"(s-maxage|max-age)\") {\n # Varnish sets default TTL if none of the headers above are present. If not set we want to make sure we don't cache it\n set beresp.ttl = 3600s;\n return(pass);\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\") && !req.http.x-pass ) {\n unset beresp.http.set-cookie;\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type if they are image\/script or CSS\n if (beresp.http.Content-Type ~ \"(image|script|css)\") {\n set beresp.http.Surrogate-Key = re.group.1;\n }\n }\n\n # If the cache key in the Magento response doesn't match the one that was sent in the request, don't cache under the request's key\n if (req.http.graphql && req.http.X-Magento-Cache-Id && req.http.X-Magento-Cache-Id != beresp.http.X-Magento-Cache-Id) {\n set beresp.ttl = 3600s;\n return(pass);\n }\n","old_contents":" # If we are doing a bypass for Magento Tester return early as not to affect any headers\n if ( req.http.bypass-secret ) {\n set beresp.ttl = 0s;\n return(pass);\n }\n\n \/* handle 5XX (or any other unwanted status code) *\/\n if (beresp.status >= 500 && beresp.status < 600) {\n\n \/* deliver stale if the object is available *\/\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n # Remove Set-Cookies from responses for static content to match the cookie removal in recv.\n if (req.http.x-long-cache || req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's since those can be temporary during the site build\/index\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n set beresp.http.Cache-Control = \"max-age=0\";\n } else if (req.http.x-long-cache) {\n # Force caching for signed cached assets.\n set beresp.ttl = 31536000s;\n # Add immutable as it avoids IMS and INM revalidations\n set beresp.http.Cache-Control = \"max-age=31536000, immutable\";\n # Remove HTTP\/1.0 caching headers as they may mess with browser memory caches\n unset beresp.http.Pragma;\n unset beresp.http.Expires;\n }\n }\n\n # Fix Vary Header in some cases. In 99.9% of cases Varying on User-Agent is counterproductive\n # https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleFixupVary\n if (beresp.http.Vary ~ \"User-Agent\") {\n unset beresp.http.Vary:User-Agent;\n if (beresp.http.Vary == \"\") {\n unset beresp.http.Vary;\n }\n }\n\n # All the Magento responses should emit X-Esi headers\n if (beresp.http.x-esi) {\n # enable ESI feature for Magento response by default\n esi;\n } else {\n # enable gzip for all static content except\n if ( http_status_matches(beresp.status, \"200,404\") && (beresp.http.content-type ~ \"^(application\/x\\-javascript|text\/css|text\/html|application\/javascript|text\/javascript|application\/json|application\/vnd\\.ms\\-fontobject|application\/x\\-font\\-opentype|application\/x\\-font\\-truetype|application\/x\\-font\\-ttf|application\/xml|font\/eot|font\/opentype|font\/otf|image\/svg\\+xml|image\/vnd\\.microsoft\\.icon|text\/plain)\\s*($|;)\" || req.url.ext ~ \"(?i)(css|js|html|eot|ico|otf|ttf|json)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n set beresp.http.Vary:Accept-Encoding = \"\";\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # Add Varying on Store and Content-Currency for GraphQl, X-Magento-Vary otherwise\n if (req.http.graphql) {\n set beresp.http.Vary:Store = \"\";\n set beresp.http.Vary:Content-Currency = \"\";\n } else if (beresp.http.Content-Type ~ \"text\/(html|xml)\") {\n set beresp.http.Vary:X-Magento-Vary = \"\";\n set beresp.http.Vary:Https = \"\";\n }\n\n # Just in case the Request Setting for x-pass is missing\n if (req.http.x-pass) {\n return (pass);\n }\n\n # We are extending the default Fastly behavior to include no-cache\/no-store in addition to private\n if (beresp.http.Cache-Control ~ \"private|no-cache|no-store\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # Never cache 302s\n if (beresp.status == 302) {\n return (pass);\n }\n\n if (beresp.http.x-amz-request-id) {\n # If assets are coming from Amazon they may have no Cache-Control headers which may make them uncacheable\n\n # If the object is coming with no Expires, Surrogate-Control or Cache-Control headers we assume it's a misconfiguration\n # and we will not cache it. This is to prevent inadventently caching private data\n } else if (!beresp.http.Expires && !beresp.http.Surrogate-Control ~ \"max-age\" && !beresp.http.Cache-Control ~ \"(s-maxage|max-age)\") {\n # Varnish sets default TTL if none of the headers above are present. If not set we want to make sure we don't cache it\n set beresp.ttl = 0s;\n set beresp.cacheable = false;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\") && !req.http.x-pass ) {\n unset beresp.http.set-cookie;\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type if they are image\/script or CSS\n if (beresp.http.Content-Type ~ \"(image|script|css)\") {\n set beresp.http.Surrogate-Key = re.group.1;\n }\n }\n\n # If the cache key in the Magento response doesn't match the one that was sent in the request, don't cache under the request's key\n if (req.http.graphql && req.http.X-Magento-Cache-Id && req.http.X-Magento-Cache-Id != beresp.http.X-Magento-Cache-Id) {\n set beresp.ttl = 0s;\n set beresp.cacheable = false;\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"0a63ffc7e8b320bf4325e8a9edfc6cdc678e336b","subject":"comment\u90e8\u524a\u9664","message":"comment\u90e8\u524a\u9664\n","repos":"dekokun\/isucon6-qualify,dekokun\/isucon6-qualify,dekokun\/isucon6-qualify,dekokun\/isucon6-qualify,dekokun\/isucon6-qualify,dekokun\/isucon6-qualify,dekokun\/isucon6-qualify,dekokun\/isucon6-qualify","old_file":"webapp\/config\/default.vcl","new_file":"webapp\/config\/default.vcl","new_contents":"#\n# This is an example VCL file for Varnish.\n#\n# It does not do anything by default, delegating control to the\n# builtin VCL. The builtin VCL is called when there is no explicit\n# return statement.\n#\n# See the VCL chapters in the Users Guide at https:\/\/www.varnish-cache.org\/docs\/\n# and https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExamples for more examples.\n\n# Marker to tell the VCL compiler that this VCL has been adapted to the\n# new 4.0 format.\nvcl 4.0;\n\nimport directors;\n\n# Default backend definition. Set this to point to your content server.\nbackend localhost {\n .host = \"127.0.0.1\";\n .port = \"5000\";\n}\n\nsub vcl_init {\n new backend = directors.round_robin();\n\n backend.add_backend(localhost);\n}\n\nsub vcl_recv {\n set req.backend_hint = backend.backend();\n\n if (req.method == \"INVALIDATE\") {\n ban(\"obj.http.Keyword = \" + req.http.X-Invalidated-Keyword);\n return(synth(200, req.http.X-Invalidated-Keyword + \" Purged. Success !!\"));\n }\n\n\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return(pass);\n }\n\n return(hash);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n return (lookup);\n}\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n\n return(deliver);\n}\n\nsub vcl_backend_response {\n\n set beresp.do_esi = true;\n # this is same as builtin vcl_backend_response\n # https:\/\/www.varnish-cache.org\/trac\/browser\/bin\/varnishd\/builtin.vcl?rev=ae548683b8f91d0a92799f6c746b80773a4c9f05\n if (beresp.ttl <= 0s ||\n beresp.http.Set-Cookie ||\n beresp.http.Surrogate-control ~ \"no-store\" ||\n beresp.http.Cache-Control ~ \"no-cache\" ||\n (!beresp.http.Surrogate-Control &&\n beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n beresp.http.Vary == \"*\") {\n \/*\n * Mark as \"Hit-For-Pass\" for the next 2 minutes\n *\/\n set beresp.uncacheable = true;\n }\n\n # this is hatena original config\n if (beresp.ttl > 0s && ! beresp.uncacheable) {\n set beresp.grace = 1m;\n }\n return (deliver);\n}\n\nsub vcl_synth {\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n set resp.http.Retry-After = \"5\";\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>\"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <p>XID: \"} + req.xid + {\"<\/p>\n <\/body>\n<\/html>\n\"} );\n return (deliver);\n}\n\n","old_contents":"#\n# This is an example VCL file for Varnish.\n#\n# It does not do anything by default, delegating control to the\n# builtin VCL. The builtin VCL is called when there is no explicit\n# return statement.\n#\n# See the VCL chapters in the Users Guide at https:\/\/www.varnish-cache.org\/docs\/\n# and https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExamples for more examples.\n\n# Marker to tell the VCL compiler that this VCL has been adapted to the\n# new 4.0 format.\nvcl 4.0;\n\nimport directors;\n\n# Default backend definition. Set this to point to your content server.\nbackend localhost {\n .host = \"127.0.0.1\";\n .port = \"5000\";\n}\n\nsub vcl_init {\n new backend = directors.round_robin();\n\n backend.add_backend(localhost);\n}\n\nsub vcl_recv {\n set req.backend_hint = backend.backend();\n\n if (req.method == \"INVALIDATE\") {\n ban(\"obj.http.Keyword = \" + req.http.X-Invalidated-Keyword);\n return(synth(200, req.http.X-Invalidated-Keyword + \" Purged. Success !!\"));\n }\n\n\n # if (req.http.Cookie) {\n # return(pass);\n # }\n\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return(pass);\n }\n\n return(hash);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n return (lookup);\n}\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n\n return(deliver);\n}\n\nsub vcl_backend_response {\n\n set beresp.do_esi = true;\n # this is same as builtin vcl_backend_response\n # https:\/\/www.varnish-cache.org\/trac\/browser\/bin\/varnishd\/builtin.vcl?rev=ae548683b8f91d0a92799f6c746b80773a4c9f05\n if (beresp.ttl <= 0s ||\n beresp.http.Set-Cookie ||\n beresp.http.Surrogate-control ~ \"no-store\" ||\n beresp.http.Cache-Control ~ \"no-cache\" ||\n (!beresp.http.Surrogate-Control &&\n beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n beresp.http.Vary == \"*\") {\n \/*\n * Mark as \"Hit-For-Pass\" for the next 2 minutes\n *\/\n set beresp.uncacheable = true;\n }\n\n # this is hatena original config\n if (beresp.ttl > 0s && ! beresp.uncacheable) {\n set beresp.grace = 1m;\n }\n return (deliver);\n}\n\nsub vcl_synth {\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n set resp.http.Retry-After = \"5\";\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>\"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <p>XID: \"} + req.xid + {\"<\/p>\n <\/body>\n<\/html>\n\"} );\n return (deliver);\n}\n\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"695872a68d6f0264b3e93a202e98cf4f0367d7a5","subject":"Varnish improvements","message":"Varnish improvements\n","repos":"reinier-vegter\/Simple-Drupal-Docker-Toolset,reinier-vegter\/Simple-Drupal-Docker-Toolset,reinier-vegter\/Simple-Drupal-Docker-Toolset","old_file":"dockerfiles\/d7\/bootstrap\/varnish-default.vcl","new_file":"dockerfiles\/d7\/bootstrap\/varnish-default.vcl","new_contents":"vcl 4.0;\n# Based on: https:\/\/github.com\/mattiasgeniar\/varnish-4.0-configuration-templates\/blob\/master\/default.vcl\n\nimport std;\nimport directors;\n\nbackend server1 { # Define one backend\n .host = \"127.0.0.1\"; # IP or Hostname of backend\n .port = \"90\"; # Port Apache or whatever is listening\n .max_connections = 300; # That's it\n\n .probe = {\n #.url = \"\/\"; # short easy way (GET \/)\n # We prefer to only do a HEAD \/\n .request =\n \"HEAD \/ HTTP\/1.1\"\n \"Host: localhost\"\n \"Connection: close\";\n\n .interval = 5s; # check the health of each backend every 5 seconds\n .timeout = 1s; # timing out after 1 second.\n .window = 5; # If 3 out of the last 5 polls succeeded the backend is considered healthy, otherwise it will be marked as sick\n .threshold = 3;\n }\n\n .first_byte_timeout = 300s; # How long to wait before we receive a first byte from our backend?\n .connect_timeout = 5s; # How long to wait for a backend connection?\n .between_bytes_timeout = 2s; # How long to wait between bytes received from our backend?\n}\n\nacl purge {\n # ACL we'll use later to allow purges\n \"localhost\";\n \"127.0.0.1\";\n \"::1\";\n}\n\n#acl editors {\n # ACL to honor the \"Cache-Control: no-cache\" header to force a refresh but only from selected IPs\n # \"localhost\";\n # \"127.0.0.1\";\n # \"::1\";\n#}\n\nsub vcl_init {\n # Called when VCL is loaded, before any requests pass through it.\n # Typically used to initialize VMODs.\n\n new vdir = directors.round_robin();\n vdir.add_backend(server1);\n # vdir.add_backend(server...);\n # vdir.add_backend(servern);\n}\n\nsub vcl_recv {\n # Called at the beginning of a request, after the complete request has been received and parsed.\n # Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable,\n # which backend to use.\n # also used to modify the request\n\n set req.backend_hint = vdir.backend(); # send all traffic to the vdir director\n\n # Normalize the header, remove the port (in case you're testing this on various TCP ports)\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n # Normalize the query arguments\n set req.url = std.querysort(req.url);\n\n # Allow purging\n if (req.method == \"PURGE\") {\n if (!client.ip ~ purge) { # purge is the ACL defined at the begining\n # Not from an allowed IP? Then die with an error.\n return (synth(405, \"This IP is not allowed to send PURGE requests.\"));\n }\n # If you got this stage (and didn't error out above), purge the cached result\n ban(\"req.url == \" + req.url);\n\n # Throw a synthetic page so the\n # request won't go to the backend.\n return(synth(200, \"Ban added\"));\n }\n\n # Only deal with \"normal\" types\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"PATCH\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n # Implementing websocket support (https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html)\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n # Only cache GET or HEAD requests. This makes sure the POST requests are always passed.\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n # Some generic URL manipulation, useful for all templates that follow\n # First remove the Google Analytics added parameters, useless for our backend\n if (req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=\") {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # Strip hash, server doesn't need it.\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n # Strip a trailing ? if it exists\n if (req.url ~ \"\\?$\") {\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # Some generic cookie manipulation, useful for all templates that follow\n # Remove the \"has_js\" cookie\n set req.http.Cookie = regsuball(req.http.Cookie, \"has_js=[^;]+(; )?\", \"\");\n\n # Remove any Google Analytics based cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__utm.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"_ga=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"_gat[^;]*=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmctr=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmcmd.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmccn.=[^;]+(; )?\", \"\");\n\n # Remove DoubleClick offensive cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__gads=[^;]+(; )?\", \"\");\n\n # Remove the Quant Capital cookies (added by some plugin, all __qca)\n set req.http.Cookie = regsuball(req.http.Cookie, \"__qc.=[^;]+(; )?\", \"\");\n\n # Remove the AddThis cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__atuv.=[^;]+(; )?\", \"\");\n\n set req.http.Cookie = regsuball(req.http.Cookie, \"cookie_accepted=[^;]+(; )?\", \"\");\n\n # Remove SimpleSamlPHP cookie, if no Drupal session cookie is present.\n if (req.http.Cookie !~ \"S{1,2}ESS[a-z0-9]+=\" && req.url !~ \"^\/saml\") {\n set req.http.Cookie = regsuball(req.http.Cookie, \"SimpleSAML[^;]+(; )?\", \"\");\n }\n\n # Remove a \";\" prefix in the cookie if present\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n\n # Are there cookies left with only spaces or that are empty?\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n\n # Remove cookie_accepted cookie.\n # set req.http.Cookie = regsuball(req.http.Cookie, \"cookie_accepted=[^;]+(; )?\", \"\");\n\n #if (req.http.Cache-Control ~ \"(?i)no-cache\") {\n # if (req.http.Cache-Control ~ \"(?i)no-cache\" && client.ip ~ editors) { # create the acl editors if you want to restrict the Ctrl-F5\n # http:\/\/varnish.projects.linpro.no\/wiki\/VCLExampleEnableForceRefresh\n # Ignore requests via proxy caches and badly behaved crawlers\n # like msnbot that send no-cache with every request.\n # if (! (req.http.Via || req.http.User-Agent ~ \"(?i)bot\" || req.http.X-Purge)) {\n # #set req.hash_always_miss = true; # Doesn't seems to refresh the object in the cache\n # # return(purge); # Couple this with restart in vcl_purge and X-Purge header to avoid loops\n # ban(\"req.http.host == \" + req.http.host +\n # \" && req.url == \" + req.url);\n\n # # Throw a synthetic page so the\n # # request won't go to the backend.\n # return(synth(200, \"Ban added\"));\n # }\n #}\n\n # Large static files are delivered directly to the end-user without\n # waiting for Varnish to fully read the file first.\n # Varnish 4 fully supports Streaming, so set do_stream in vcl_backend_response()\n if (req.url ~ \"^[^?]*\\.(mp[34]|rar|tar|tgz|gz|wav|zip|bz2|xz|7z|avi|mov|ogm|mpe?g|mk[av]|webm)(\\?.*)?$\") {\n unset req.http.Cookie;\n return (hash);\n }\n\n # Remove all cookies for static files\n # A valid discussion could be held on this line: do you really need to cache static files that don't cause load? Only if you have memory left.\n # Sure, there's disk I\/O, but chances are your OS will already have these files in their buffers (thus memory).\n # Before you blindly enable this, have a read here: https:\/\/ma.ttias.be\/stop-caching-static-files\/\n if (req.url ~ \"^[^?]*\\.(bmp|bz2|css|doc|eot|flv|gif|gz|ico|jpeg|jpg|js|less|pdf|png|rtf|swf|txt|woff|xml)(\\?.*)?$\") {\n unset req.http.Cookie;\n return (hash);\n }\n\n # Send Surrogate-Capability headers to announce ESI support to backend\n set req.http.Surrogate-Capability = \"key=ESI\/1.0\";\n\n if (req.http.Authorization) {\n # Not cacheable by default\n return (pass);\n }\n\n return (hash);\n}\n\nsub vcl_pipe {\n # Called upon entering pipe mode.\n # In this mode, the request is passed on to the backend, and any further data from both the client\n # and backend is passed on unaltered until either end closes the connection. Basically, Varnish will\n # degrade into a simple TCP proxy, shuffling bytes back and forth. For a connection in pipe mode,\n # no other VCL subroutine will ever get called after vcl_pipe.\n\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n # set bereq.http.connection = \"close\";\n # here. It is not set by default as it might break some broken web\n # applications, like IIS with NTLM authentication.\n\n # set bereq.http.Connection = \"Close\";\n\n # Implementing websocket support (https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html)\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n\n return (pipe);\n}\n\nsub vcl_pass {\n # Called upon entering pass mode. In this mode, the request is passed on to the backend, and the\n # backend's response is passed on to the client, but is not entered into the cache. Subsequent\n # requests submitted over the same client connection are handled normally.\n\n # return (pass);\n}\n\n# The data on which the hashing will take place\nsub vcl_hash {\n # Called after vcl_recv to create a hash value for the request. This is used as a key\n # to look up the object in Varnish.\n\n hash_data(req.url);\n\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n\n # hash cookies for requests that have them\n if (req.http.Cookie) {\n hash_data(req.http.Cookie);\n }\n}\n\nsub vcl_hit {\n # Called when a cache lookup is successful.\n\n if (obj.ttl >= 0s) {\n # A pure unadultered hit, deliver it\n return (deliver);\n }\n\n # https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-grace.html\n # When several clients are requesting the same page Varnish will send one request to the backend and place the others on hold while fetching one copy from the backend. In some products this is called request coalescing and Varnish does this automatically.\n # If you are serving thousands of hits per second the queue of waiting requests can get huge. There are two potential problems - one is a thundering herd problem - suddenly releasing a thousand threads to serve content might send the load sky high. Secondly - nobody likes to wait. To deal with this we can instruct Varnish to keep the objects in cache beyond their TTL and to serve the waiting requests somewhat stale content.\n\n# if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n# return (deliver);\n# } else {\n# return (fetch);\n# }\n\n # We have no fresh fish. Lets look at the stale ones.\n if (std.healthy(req.backend_hint)) {\n # Backend is healthy. Limit age to 10s.\n if (obj.ttl + 10s > 0s) {\n #set req.http.grace = \"normal(limited)\";\n return (deliver);\n } else {\n # No candidate for grace. Fetch a fresh object.\n return(fetch);\n }\n } else {\n # backend is sick - use full grace\n if (obj.ttl + obj.grace > 0s) {\n #set req.http.grace = \"full\";\n return (deliver);\n } else {\n # no graced object.\n return (fetch);\n }\n }\n\n # fetch & deliver once we get the result\n return (fetch); # Dead code, keep as a safeguard\n}\n\nsub vcl_miss {\n # Called after a cache lookup if the requested document was not found in the cache. Its purpose\n # is to decide whether or not to attempt to retrieve the document from the backend, and which\n # backend to use.\n\n return (fetch);\n}\n\n# Handle the HTTP request coming from our backend\nsub vcl_backend_response {\n # Called after the response headers has been successfully retrieved from the backend.\n\n # Pause ESI request and remove Surrogate-Control header\n if (beresp.http.Surrogate-Control ~ \"ESI\/1.0\") {\n unset beresp.http.Surrogate-Control;\n set beresp.do_esi = true;\n }\n\n # Enable cache for all static files\n # The same argument as the static caches from above: monitor your cache size, if you get data nuked out of it, consider giving up the static file cache.\n # Before you blindly enable this, have a read here: https:\/\/ma.ttias.be\/stop-caching-static-files\/\n if (bereq.url ~ \"^[^?]*\\.(bmp|bz2|css|doc|eot|flv|gif|gz|ico|jpeg|jpg|js|less|mp[34]|pdf|png|rar|rtf|swf|tar|tgz|txt|wav|woff|xml|zip|webm)(\\?.*)?$\") {\n unset beresp.http.set-cookie;\n }\n\n # Large static files are delivered directly to the end-user without\n # waiting for Varnish to fully read the file first.\n # Varnish 4 fully supports Streaming, so use streaming here to avoid locking.\n if (bereq.url ~ \"^[^?]*\\.(mp[34]|rar|tar|tgz|gz|wav|zip|bz2|xz|7z|avi|mov|ogm|mpe?g|mk[av]|webm)(\\?.*)?$\") {\n unset beresp.http.set-cookie;\n set beresp.do_stream = true; # Check memory usage it'll grow in fetch_chunksize blocks (128k by default) if the backend doesn't send a Content-Length header, so only enable it for big objects\n set beresp.do_gzip = false; # Don't try to compress it for storage\n }\n\n # Sometimes, a 301 or 302 redirect formed via Apache's mod_rewrite can mess with the HTTP port that is being passed along.\n # This often happens with simple rewrite rules in a scenario where Varnish runs on :80 and Apache on :8080 on the same box.\n # A redirect can then often redirect the end-user to a URL on :8080, where it should be :80.\n # This may need finetuning on your setup.\n #\n # To prevent accidental replace, we only filter the 301\/302 redirects for now.\n if (beresp.status == 301 || beresp.status == 302) {\n set beresp.http.Location = regsub(beresp.http.Location, \":[0-9]+\", \"\");\n }\n\n # Set 2min cache if unset for static files\n if (beresp.ttl > 0s) {\n unset beresp.http.Set-Cookie;\n }\n\n # Allow stale content, in case the backend goes down.\n # make Varnish keep all objects for 6 hours beyond their TTL\n set beresp.grace = 6h;\n\n return (deliver);\n}\n\n# The routine when we deliver the HTTP request to the user\n# Last chance to modify headers that are sent to the client\nsub vcl_deliver {\n # Called before a cached object is delivered to the client.\n\n if (obj.hits > 0) { # Add debug header to see if it's a HIT\/MISS and the number of hits, disable when not needed\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n\n # Please note that obj.hits behaviour changed in 4.0, now it counts per objecthead, not per object\n # and obj.hits may not be reset in some cases where bans are in use. See bug 1492 for details.\n # So take hits with a grain of salt\n set resp.http.X-Cache-Hits = obj.hits;\n\n # Remove some headers: PHP version\n unset resp.http.X-Powered-By;\n\n # Remove some headers: Apache version & OS\n unset resp.http.Server;\n unset resp.http.X-Drupal-Cache;\n unset resp.http.X-Varnish;\n unset resp.http.Via;\n unset resp.http.Link;\n unset resp.http.X-Generator;\n\n return (deliver);\n}\n\nsub vcl_purge {\n # Only handle actual PURGE HTTP methods, everything else is discarded\n if (req.method != \"PURGE\") {\n # restart request\n set req.http.X-Purge = \"Yes\";\n return(restart);\n }\n}\n\nsub vcl_synth {\n if (resp.status == 720) {\n # We use this special error status 720 to force redirects with 301 (permanent) redirects\n # To use this, call the following from anywhere in vcl_recv: return (synth(720, \"http:\/\/host\/new.html\"));\n set resp.http.Location = resp.reason;\n set resp.status = 301;\n return (deliver);\n } elseif (resp.status == 721) {\n # And we use error status 721 to force redirects with a 302 (temporary) redirect\n # To use this, call the following from anywhere in vcl_recv: return (synth(720, \"http:\/\/host\/new.html\"));\n set resp.http.Location = resp.reason;\n set resp.status = 302;\n return (deliver);\n }\n\n return (deliver);\n}\n\n\nsub vcl_fini {\n # Called when VCL is discarded only after all requests have exited the VCL.\n # Typically used to clean up VMODs.\n\n return (ok);\n}\n","old_contents":"vcl 4.0;\n# Based on: https:\/\/github.com\/mattiasgeniar\/varnish-4.0-configuration-templates\/blob\/master\/default.vcl\n\nimport std;\nimport directors;\n\nbackend server1 { # Define one backend\n .host = \"127.0.0.1\"; # IP or Hostname of backend\n .port = \"90\"; # Port Apache or whatever is listening\n .max_connections = 300; # That's it\n\n .probe = {\n #.url = \"\/\"; # short easy way (GET \/)\n # We prefer to only do a HEAD \/\n .request =\n \"HEAD \/ HTTP\/1.1\"\n \"Host: localhost\"\n \"Connection: close\";\n\n .interval = 5s; # check the health of each backend every 5 seconds\n .timeout = 1s; # timing out after 1 second.\n .window = 5; # If 3 out of the last 5 polls succeeded the backend is considered healthy, otherwise it will be marked as sick\n .threshold = 3;\n }\n\n .first_byte_timeout = 300s; # How long to wait before we receive a first byte from our backend?\n .connect_timeout = 5s; # How long to wait for a backend connection?\n .between_bytes_timeout = 2s; # How long to wait between bytes received from our backend?\n}\n\nacl purge {\n # ACL we'll use later to allow purges\n \"localhost\";\n \"127.0.0.1\";\n \"::1\";\n}\n\nacl editors {\n # ACL to honor the \"Cache-Control: no-cache\" header to force a refresh but only from selected IPs\n # \"localhost\";\n # \"127.0.0.1\";\n # \"::1\";\n}\n\nsub vcl_init {\n # Called when VCL is loaded, before any requests pass through it.\n # Typically used to initialize VMODs.\n\n new vdir = directors.round_robin();\n vdir.add_backend(server1);\n # vdir.add_backend(server...);\n # vdir.add_backend(servern);\n}\n\nsub vcl_recv {\n # Called at the beginning of a request, after the complete request has been received and parsed.\n # Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable,\n # which backend to use.\n # also used to modify the request\n\n set req.backend_hint = vdir.backend(); # send all traffic to the vdir director\n\n # Normalize the header, remove the port (in case you're testing this on various TCP ports)\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n # Normalize the query arguments\n set req.url = std.querysort(req.url);\n\n # Allow purging\n if (req.method == \"PURGE\") {\n if (!client.ip ~ purge) { # purge is the ACL defined at the begining\n # Not from an allowed IP? Then die with an error.\n return (synth(405, \"This IP is not allowed to send PURGE requests.\"));\n }\n # If you got this stage (and didn't error out above), purge the cached result\n ban(\"req.http.host == \" + req.http.host +\n \" && req.url == \" + req.url);\n\n # Throw a synthetic page so the\n # request won't go to the backend.\n return(synth(200, \"Ban added\"));\n }\n\n # Only deal with \"normal\" types\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"PATCH\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n # Implementing websocket support (https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html)\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n # Only cache GET or HEAD requests. This makes sure the POST requests are always passed.\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n # Some generic URL manipulation, useful for all templates that follow\n # First remove the Google Analytics added parameters, useless for our backend\n if (req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=\") {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # Strip hash, server doesn't need it.\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n # Strip a trailing ? if it exists\n if (req.url ~ \"\\?$\") {\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # Some generic cookie manipulation, useful for all templates that follow\n # Remove the \"has_js\" cookie\n set req.http.Cookie = regsuball(req.http.Cookie, \"has_js=[^;]+(; )?\", \"\");\n\n # Remove any Google Analytics based cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__utm.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"_ga=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"_gat[^;]*=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmctr=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmcmd.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmccn.=[^;]+(; )?\", \"\");\n\n # Remove DoubleClick offensive cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__gads=[^;]+(; )?\", \"\");\n\n # Remove the Quant Capital cookies (added by some plugin, all __qca)\n set req.http.Cookie = regsuball(req.http.Cookie, \"__qc.=[^;]+(; )?\", \"\");\n\n # Remove the AddThis cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__atuv.=[^;]+(; )?\", \"\");\n\n set req.http.Cookie = regsuball(req.http.Cookie, \"cookie_accepted=[^;]+(; )?\", \"\");\n\n # Remove SimpleSamlPHP cookie, if no Drupal session cookie is present.\n if (req.http.Cookie !~ \"S{1,2}ESS[a-z0-9]+=\") {\n set req.http.Cookie = regsuball(req.http.Cookie, \"SimpleSAML[^;]+(; )?\", \"\");\n }\n\n # Remove a \";\" prefix in the cookie if present\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n\n # Are there cookies left with only spaces or that are empty?\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n\n # Remove cookie_accepted cookie.\n # set req.http.Cookie = regsuball(req.http.Cookie, \"cookie_accepted=[^;]+(; )?\", \"\");\n\n #if (req.http.Cache-Control ~ \"(?i)no-cache\") {\n if (req.http.Cache-Control ~ \"(?i)no-cache\" && client.ip ~ editors) { # create the acl editors if you want to restrict the Ctrl-F5\n # http:\/\/varnish.projects.linpro.no\/wiki\/VCLExampleEnableForceRefresh\n # Ignore requests via proxy caches and badly behaved crawlers\n # like msnbot that send no-cache with every request.\n if (! (req.http.Via || req.http.User-Agent ~ \"(?i)bot\" || req.http.X-Purge)) {\n #set req.hash_always_miss = true; # Doesn't seems to refresh the object in the cache\n # return(purge); # Couple this with restart in vcl_purge and X-Purge header to avoid loops\n ban(\"req.http.host == \" + req.http.host +\n \" && req.url == \" + req.url);\n\n # Throw a synthetic page so the\n # request won't go to the backend.\n return(synth(200, \"Ban added\"));\n }\n }\n\n # Large static files are delivered directly to the end-user without\n # waiting for Varnish to fully read the file first.\n # Varnish 4 fully supports Streaming, so set do_stream in vcl_backend_response()\n if (req.url ~ \"^[^?]*\\.(mp[34]|rar|tar|tgz|gz|wav|zip|bz2|xz|7z|avi|mov|ogm|mpe?g|mk[av]|webm)(\\?.*)?$\") {\n unset req.http.Cookie;\n return (hash);\n }\n\n # Remove all cookies for static files\n # A valid discussion could be held on this line: do you really need to cache static files that don't cause load? Only if you have memory left.\n # Sure, there's disk I\/O, but chances are your OS will already have these files in their buffers (thus memory).\n # Before you blindly enable this, have a read here: https:\/\/ma.ttias.be\/stop-caching-static-files\/\n if (req.url ~ \"^[^?]*\\.(bmp|bz2|css|doc|eot|flv|gif|gz|ico|jpeg|jpg|js|less|pdf|png|rtf|swf|txt|woff|xml)(\\?.*)?$\") {\n unset req.http.Cookie;\n return (hash);\n }\n\n # Send Surrogate-Capability headers to announce ESI support to backend\n set req.http.Surrogate-Capability = \"key=ESI\/1.0\";\n\n if (req.http.Authorization) {\n # Not cacheable by default\n return (pass);\n }\n\n return (hash);\n}\n\nsub vcl_pipe {\n # Called upon entering pipe mode.\n # In this mode, the request is passed on to the backend, and any further data from both the client\n # and backend is passed on unaltered until either end closes the connection. Basically, Varnish will\n # degrade into a simple TCP proxy, shuffling bytes back and forth. For a connection in pipe mode,\n # no other VCL subroutine will ever get called after vcl_pipe.\n\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n # set bereq.http.connection = \"close\";\n # here. It is not set by default as it might break some broken web\n # applications, like IIS with NTLM authentication.\n\n # set bereq.http.Connection = \"Close\";\n\n # Implementing websocket support (https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html)\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n\n return (pipe);\n}\n\nsub vcl_pass {\n # Called upon entering pass mode. In this mode, the request is passed on to the backend, and the\n # backend's response is passed on to the client, but is not entered into the cache. Subsequent\n # requests submitted over the same client connection are handled normally.\n\n # return (pass);\n}\n\n# The data on which the hashing will take place\nsub vcl_hash {\n # Called after vcl_recv to create a hash value for the request. This is used as a key\n # to look up the object in Varnish.\n\n hash_data(req.url);\n\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n\n # hash cookies for requests that have them\n if (req.http.Cookie) {\n hash_data(req.http.Cookie);\n }\n}\n\nsub vcl_hit {\n # Called when a cache lookup is successful.\n\n if (obj.ttl >= 0s) {\n # A pure unadultered hit, deliver it\n return (deliver);\n }\n\n # https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-grace.html\n # When several clients are requesting the same page Varnish will send one request to the backend and place the others on hold while fetching one copy from the backend. In some products this is called request coalescing and Varnish does this automatically.\n # If you are serving thousands of hits per second the queue of waiting requests can get huge. There are two potential problems - one is a thundering herd problem - suddenly releasing a thousand threads to serve content might send the load sky high. Secondly - nobody likes to wait. To deal with this we can instruct Varnish to keep the objects in cache beyond their TTL and to serve the waiting requests somewhat stale content.\n\n# if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n# return (deliver);\n# } else {\n# return (fetch);\n# }\n\n # We have no fresh fish. Lets look at the stale ones.\n if (std.healthy(req.backend_hint)) {\n # Backend is healthy. Limit age to 10s.\n if (obj.ttl + 10s > 0s) {\n #set req.http.grace = \"normal(limited)\";\n return (deliver);\n } else {\n # No candidate for grace. Fetch a fresh object.\n return(fetch);\n }\n } else {\n # backend is sick - use full grace\n if (obj.ttl + obj.grace > 0s) {\n #set req.http.grace = \"full\";\n return (deliver);\n } else {\n # no graced object.\n return (fetch);\n }\n }\n\n # fetch & deliver once we get the result\n return (fetch); # Dead code, keep as a safeguard\n}\n\nsub vcl_miss {\n # Called after a cache lookup if the requested document was not found in the cache. Its purpose\n # is to decide whether or not to attempt to retrieve the document from the backend, and which\n # backend to use.\n\n return (fetch);\n}\n\n# Handle the HTTP request coming from our backend\nsub vcl_backend_response {\n # Called after the response headers has been successfully retrieved from the backend.\n\n # Pause ESI request and remove Surrogate-Control header\n if (beresp.http.Surrogate-Control ~ \"ESI\/1.0\") {\n unset beresp.http.Surrogate-Control;\n set beresp.do_esi = true;\n }\n\n # Enable cache for all static files\n # The same argument as the static caches from above: monitor your cache size, if you get data nuked out of it, consider giving up the static file cache.\n # Before you blindly enable this, have a read here: https:\/\/ma.ttias.be\/stop-caching-static-files\/\n if (bereq.url ~ \"^[^?]*\\.(bmp|bz2|css|doc|eot|flv|gif|gz|ico|jpeg|jpg|js|less|mp[34]|pdf|png|rar|rtf|swf|tar|tgz|txt|wav|woff|xml|zip|webm)(\\?.*)?$\") {\n unset beresp.http.set-cookie;\n }\n\n # Large static files are delivered directly to the end-user without\n # waiting for Varnish to fully read the file first.\n # Varnish 4 fully supports Streaming, so use streaming here to avoid locking.\n if (bereq.url ~ \"^[^?]*\\.(mp[34]|rar|tar|tgz|gz|wav|zip|bz2|xz|7z|avi|mov|ogm|mpe?g|mk[av]|webm)(\\?.*)?$\") {\n unset beresp.http.set-cookie;\n set beresp.do_stream = true; # Check memory usage it'll grow in fetch_chunksize blocks (128k by default) if the backend doesn't send a Content-Length header, so only enable it for big objects\n set beresp.do_gzip = false; # Don't try to compress it for storage\n }\n\n # Sometimes, a 301 or 302 redirect formed via Apache's mod_rewrite can mess with the HTTP port that is being passed along.\n # This often happens with simple rewrite rules in a scenario where Varnish runs on :80 and Apache on :8080 on the same box.\n # A redirect can then often redirect the end-user to a URL on :8080, where it should be :80.\n # This may need finetuning on your setup.\n #\n # To prevent accidental replace, we only filter the 301\/302 redirects for now.\n if (beresp.status == 301 || beresp.status == 302) {\n set beresp.http.Location = regsub(beresp.http.Location, \":[0-9]+\", \"\");\n }\n\n # Set 2min cache if unset for static files\n if (beresp.ttl <= 0s || beresp.http.Set-Cookie || beresp.http.Vary == \"*\") {\n set beresp.ttl = 120s; # Important, you shouldn't rely on this, SET YOUR HEADERS in the backend\n set beresp.uncacheable = true;\n return (deliver);\n }\n\n # Allow stale content, in case the backend goes down.\n # make Varnish keep all objects for 6 hours beyond their TTL\n set beresp.grace = 6h;\n\n return (deliver);\n}\n\n# The routine when we deliver the HTTP request to the user\n# Last chance to modify headers that are sent to the client\nsub vcl_deliver {\n # Called before a cached object is delivered to the client.\n\n if (obj.hits > 0) { # Add debug header to see if it's a HIT\/MISS and the number of hits, disable when not needed\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n\n # Please note that obj.hits behaviour changed in 4.0, now it counts per objecthead, not per object\n # and obj.hits may not be reset in some cases where bans are in use. See bug 1492 for details.\n # So take hits with a grain of salt\n set resp.http.X-Cache-Hits = obj.hits;\n\n # Remove some headers: PHP version\n unset resp.http.X-Powered-By;\n\n # Remove some headers: Apache version & OS\n unset resp.http.Server;\n unset resp.http.X-Drupal-Cache;\n unset resp.http.X-Varnish;\n unset resp.http.Via;\n unset resp.http.Link;\n unset resp.http.X-Generator;\n\n return (deliver);\n}\n\nsub vcl_purge {\n # Only handle actual PURGE HTTP methods, everything else is discarded\n if (req.method != \"PURGE\") {\n # restart request\n set req.http.X-Purge = \"Yes\";\n return(restart);\n }\n}\n\nsub vcl_synth {\n if (resp.status == 720) {\n # We use this special error status 720 to force redirects with 301 (permanent) redirects\n # To use this, call the following from anywhere in vcl_recv: return (synth(720, \"http:\/\/host\/new.html\"));\n set resp.http.Location = resp.reason;\n set resp.status = 301;\n return (deliver);\n } elseif (resp.status == 721) {\n # And we use error status 721 to force redirects with a 302 (temporary) redirect\n # To use this, call the following from anywhere in vcl_recv: return (synth(720, \"http:\/\/host\/new.html\"));\n set resp.http.Location = resp.reason;\n set resp.status = 302;\n return (deliver);\n }\n\n return (deliver);\n}\n\n\nsub vcl_fini {\n # Called when VCL is discarded only after all requests have exited the VCL.\n # Typically used to clean up VMODs.\n\n return (ok);\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"626285f4218ad085de0cac94ba8ba005591dbf3f","subject":"Disable Conditional GETs on file URLs (#2058)","message":"Disable Conditional GETs on file URLs (#2058)\n\nCurrently Fastly does not provide a way to access response headers when\r\nthe response is a 304 response. This is because the RFC states that only\r\na limited set of headers should be sent with a 304 response, and the\r\nrest are SHOULD NOT. Since this stripping happens *prior* to vcl_deliver\r\nbeing ran, that breaks our ability to log on 304 responses. Ideally at\r\nsome point Fastly offers us a way to access the \"real\" response headers\r\neven for a 304 response, but for now, we are going to remove the headers\r\nthat allow a conditional response to be made. If at some point Fastly\r\ndoes allow this, then we can revert this.","repos":"dstufft\/warehouse,pypa\/warehouse,dstufft\/warehouse,pypa\/warehouse,alex\/warehouse,pypa\/warehouse,alex\/warehouse,pypa\/warehouse,dstufft\/warehouse,alex\/warehouse,alex\/warehouse,dstufft\/warehouse,alex\/warehouse","old_file":"vcl\/main.vcl","new_file":"vcl\/main.vcl","new_contents":"# Note: It is VERY important to ensure that any changes to VCL will work\n# properly with both the current version of ``master`` and the version in\n# the pull request that adds any new changes. This is because the\n# configuration will be applied automatically as part of the deployment\n# process, but while the previous version of the code is still up and\n# running. Thus backwards incompatible changes must be broken up over\n# multiple pull requests in order to phase them in over multiple deploys.\n\nsub vcl_recv {\n\n # I'm not 100% sure on what this is exactly for, it was taken from the\n # Fastly documentation, however, what I *believe* it does is just ensure\n # that we don't serve a stale copy of the page from the shield node when\n # an edge node is requesting content.\n if (req.http.Fastly-FF) {\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Some (Older) clients will send a hash fragment as part of the URL even\n # though that is a local only modification. This breaks this badly for the\n # files in S3, and in general it's just not needed.\n set req.url = regsub(req.url, \"#.*$\", \"\");\n\n # Fastly does some normalization of the Accept-Encoding header so that it\n # reduces the number of cached copies (when served with the common,\n # Vary: Accept-Encoding) that are cached for any one URL. This makes a lot\n # of sense, except for the fact that we want to enable brotli compression\n # for our static files. Thus we need to work around the normalized encoding\n # in a way that still minimizes cached copies, but which will allow our\n # static files to be served using brotli.\n if (req.url ~ \"^\/static\/\" && req.http.Fastly-Orig-Accept-Encoding) {\n if (req.http.User-Agent ~ \"MSIE 6\") {\n # For that 0.3% of stubborn users out there\n unset req.http.Accept-Encoding;\n } elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"br\") {\n set req.http.Accept-Encoding = \"br\";\n } elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n\n # Most of the URLs in Warehouse do not support or require any sort of query\n # parameter. If we strip these at the edge then we'll increase our cache\n # efficiency when they won't otherwise change the output of the pages.\n #\n # This will match any URL except those that start with:\n #\n # * \/admin\/\n # * \/search\/\n # * \/account\/login\/\n # * \/account\/logout\/\n # * \/account\/register\/\n # * \/pypi\n if (req.url.path !~ \"^\/(admin\/|search(\/|$)|account\/(login|logout|register)\/|pypi)\") {\n set req.url = req.url.path;\n }\n\n # Sort all of our query parameters, this will ensure that the same query\n # parameters in a different order will end up being represented as the same\n # thing, reducing cache misses due to ordering differences.\n set req.url = boltsort.sort(req.url);\n\n # We have a number of items that we'll pass back to the origin.\n # Set a header to tell the backend if we're using https or http.\n if (req.http.Fastly-SSL) {\n set req.http.Warehouse-Proto = \"https\";\n } else {\n set req.http.Warehouse-Proto = \"http\";\n }\n # Pass the client IP address back to the backend.\n if (req.http.Fastly-Client-IP) {\n set req.http.Warehouse-IP = req.http.Fastly-Client-IP;\n }\n # Pass the real host value back to the backend.\n if (req.http.Host) {\n set req.http.Warehouse-Host = req.http.host;\n }\n\n # Currently Fastly does not provide a way to access response headers when\n # the response is a 304 response. This is because the RFC states that only\n # a limit set of headers should be sent with a 304 response, and the rest\n # are SHOULD NOT. Since this stripping happens *prior* to vcl_deliver being\n # ran, that breaks our ability to log on 304 responses. Ideally at some\n # point Fastly offers us a way to access the \"real\" response headers even\n # for a 304 response, but for now, we are going to remove the headers that\n # allow a conditional response to be made. If at some point Fastly does\n # allow this, then we can delete this code.\n if (!req.http.Fastly-FF\n && std.tolower(req.http.Warehouse-Host) == \"files.pythonhosted.org\"\n && req.url.path ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\") {\n unset req.http.If-None-Match;\n unset req.http.If-Modified-Since;\n }\n\n\n#FASTLY recv\n\n\n # We want to Force SSL for the WebUI by redirecting to the HTTPS version of\n # the page, however for API calls we want to return an error code directing\n # people to instead use HTTPS.\n if (!req.http.Fastly-SSL) {\n\n # The \/simple\/ and \/packages\/ API.\n if (req.url ~ \"^\/(simple|packages)\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy JSON API.\n if (req.url ~ \"^\/pypi\/.+\/json$\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy ?:action= API.\n if (req.url ~ \"^\/pypi.*(\\?|&)=:action\") {\n error 803 \"SSL is required\";\n }\n\n # If we're on the \/pypi page and we've received something other than a\n # GET or HEAD request, then we have no way to determine if a particular\n # request is an API call or not because it'll be in the request body\n # and that isn't available to us here. So in those cases, we won't\n # do a redirect.\n if (req.url ~ \"^\/pypi\") {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n error 801 \"Force SSL\";\n }\n }\n else {\n # This isn't a \/pypi URL so we'll just unconditionally redirect to\n # HTTPS.\n error 801 \"Force SSL\";\n }\n }\n\n # Redirect pypi.io, www.pypi.io, and warehouse.python.org to pypi.org, this\n # is purposely done *after* the HTTPS checks.\n if (std.tolower(req.http.host) ~ \"^(www.pypi.org|(www.)?pypi.io|warehouse.python.org)$\") {\n set req.http.Location = \"https:\/\/pypi.org\" req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n # Redirect warehouse-staging.python.org to test.pypi.io.\n if (std.tolower(req.http.host) ~ \"^(test.pypi.io|warehouse-staging.python.org)$\") {\n set req.http.Location = \"https:\/\/test.pypi.org\" req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n\n # Requests to \/packages\/ get dispatched to Amazon instead of to our typical\n # Origin. This requires a a bit of setup to make it work.\n if (req.http.host ~ \"^(test-)?files.pythonhosted.org$\"\n && req.url ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\") {\n # Setup our environment to better match what S3 expects\/needs\n set req.http.Host = req.http.AWS-Bucket-Name \".s3.amazonaws.com\";\n set req.http.Date = now;\n set req.url = regsuball(req.url, \"\\+\", urlencode(\"+\"));\n\n # Compute the Authorization header that S3 requires to be able to\n # access the files stored there.\n set req.http.Authorization = \"AWS \" req.http.AWS-Access-Key-ID \":\" digest.hmac_sha1_base64(req.http.AWS-Secret-Access-Key, \"GET\" LF LF LF req.http.Date LF \"\/\" req.http.AWS-Bucket-Name req.url.path);\n\n # We don't want to send our Warehouse-Token to S3, so we'll go ahead\n # and remove it.\n unset req.http.Warehouse-Token;\n }\n\n # We no longer need any of these variables, which would exist only to\n # shuffle configuration from the Fastly UI into our VCL.\n unset req.http.AWS-Access-Key-ID;\n unset req.http.AWS-Secret-Access-Key;\n unset req.http.AWS-Bucket-Name;\n\n # On a POST, we want to skip the shielding and hit backends directly.\n if (req.request == \"POST\") {\n set req.backend = F_Heroku;\n }\n\n # Do not bother to attempt to run the caching mechanisms for methods that\n # are not generally safe to cache.\n if (req.request != \"HEAD\" &&\n req.request != \"GET\" &&\n req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n # We don't ever want to cache our health URL. Outside systems should be\n # able to use it to reach past Fastly and get an end to end health check.\n if (req.url == \"\/_health\/\") {\n return(pass);\n }\n\n # We never want to cache our admin URLs, while this should be \"safe\" due to\n # the architecure of Warehouse, it'll just be easier to debug issues if\n # these always are uncached.\n if (req.url ~ \"^\/admin\/\") {\n return(pass);\n }\n\n # Finally, return the default lookup action.\n return(lookup);\n}\n\n\nsub vcl_fetch {\n\n # These are newer kinds of redirects which should be able to be cached by\n # default, even though Fastly doesn't currently have them in their default\n # list of cacheable status codes.\n if (http_status_matches(beresp.status, \"303,307,308\")) {\n set beresp.cacheable = true;\n }\n\n # For any 5xx status code we want to see if a stale object exists for it,\n # if so we'll go ahead and serve it.\n if (beresp.status >= 500 && beresp.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n\n#FASTLY fetch\n\n\n # Trigger a \"SSL is required\" error if the backend has indicated to do so.\n if (beresp.http.X-Fastly-Error == \"803\") {\n error 803 \"SSL is required\";\n }\n\n # If we've gotten a 502 or a 503 from the backend, we'll go ahead and retry\n # the request.\n if ((beresp.status == 502 || beresp.status == 503) &&\n req.restarts < 1 &&\n (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n # If we've restarted, then we'll record the number of restarts.\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n # If there is a Set-Cookie header, we'll ensure that we do not cache the\n # response.\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n # If the response has the private Cache-Control directive then we won't\n # cache it.\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # If we've gotten an error after the restarts we'll deliver the response\n # with a very short cache time.\n if (http_status_matches(beresp.status, \"500,502,503\")) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n # Apply a default TTL if there isn't a max-age or s-maxage.\n if (beresp.http.Expires ||\n beresp.http.Surrogate-Control ~ \"max-age\" ||\n beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # Keep the ttl here\n }\n else {\n # Apply the default ttl\n set beresp.ttl = 60s;\n }\n\n # Actually deliver the fetched response.\n return(deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n # If the object we have isn't cacheable, then just serve it directly\n # without going through any of the caching mechanisms.\n if (!obj.cacheable) {\n return(pass);\n }\n\n return(deliver);\n}\n\n\nsub vcl_deliver {\n # If this is an error and we have a stale response available, restart so\n # that we can pick it up and serve it.\n if (resp.status >= 500 && resp.status < 600) {\n if (stale.exists) {\n restart;\n }\n }\n\n#FASTLY deliver\n\n # Unset headers that we don't need\/want to send on to the client because\n # they are not generally useful.\n unset resp.http.Via;\n\n # Set our standard security headers, we do this in VCL rather than in\n # Warehouse itself so that we always get these headers, regardless of the\n # origin server being used.\n set resp.http.Strict-Transport-Security = \"max-age=31536000; includeSubDomains; preload\";\n set resp.http.X-Frame-Options = \"deny\";\n set resp.http.X-XSS-Protection = \"1; mode=block\";\n set resp.http.X-Content-Type-Options = \"nosniff\";\n set resp.http.X-Permitted-Cross-Domain-Policies = \"none\";\n\n # Currently Fastly does not provide a way to access response headers when\n # the response is a 304 response. This is because the RFC states that only\n # a limit set of headers should be sent with a 304 response, and the rest\n # are SHOULD NOT. Since this stripping happens *prior* to vcl_deliver being\n # ran, that breaks our ability to log on 304 responses. Ideally at some\n # point Fastly offers us a way to access the \"real\" response headers even\n # for a 304 response, but for now, we are going to remove the headers that\n # allow a conditional response to be made. If at some point Fastly does\n # allow this, then we can delete this code, and also allow a 304 response\n # in the http_status_matches() check further down.\n if (!req.http.Fastly-FF\n && std.tolower(req.http.Warehouse-Host) == \"files.pythonhosted.org\"\n && req.url.path ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\") {\n unset resp.http.ETag;\n unset resp.http.Last-Modified;\n }\n\n # If we're not executing a shielding request, and the URL is one of our file\n # URLs, and it's a GET request, and the response is either a 200 or a 304\n # then we want to log an event stating that a download has taken place.\n if (!req.http.Fastly-FF\n && std.tolower(req.http.Warehouse-Host) == \"files.pythonhosted.org\"\n && req.url.path ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\"\n && req.request == \"GET\"\n && http_status_matches(resp.status, \"200\")) {\n log {\"syslog \"} req.service_id {\" linehaul :: \"} \"2@\" now \"|\" geoip.country_code \"|\" req.url.path \"|\" tls.client.protocol \"|\" tls.client.cipher \"|\" resp.http.x-amz-meta-project \"|\" resp.http.x-amz-meta-version \"|\" resp.http.x-amz-meta-package-type \"|\" req.http.user-agent;\n log {\"syslog \"} req.service_id {\" downloads :: \"} \"2@\" now \"|\" geoip.country_code \"|\" req.url.path \"|\" tls.client.protocol \"|\" tls.client.cipher \"|\" resp.http.x-amz-meta-project \"|\" resp.http.x-amz-meta-version \"|\" resp.http.x-amz-meta-package-type \"|\" req.http.user-agent;\n }\n\n # Unset a few headers set by Amazon that we don't really have a need\/desire\n # to send to clients.\n unset resp.http.x-amz-replication-status;\n unset resp.http.x-amz-meta-python-version;\n unset resp.http.x-amz-meta-version;\n unset resp.http.x-amz-meta-package-type;\n unset resp.http.x-amz-meta-project;\n\n\n return(deliver);\n}\n\n\nsub vcl_error {\n#FASTLY error\n\n # If we have a 5xx error and there is a stale object available, then we\n # will deliver that stale object.\n if (obj.status >= 500 && obj.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n if (obj.status == 803) {\n set obj.status = 403;\n set obj.response = \"SSL is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic {\"SSL is required.\"};\n return (deliver);\n } else if (obj.status == 750) {\n set obj.status = 301;\n set obj.http.Location = req.http.Location;\n set obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n synthetic {\"<html><head><title>301 Moved Permanently<\/title><\/head><body><center><h1>301 Moved Permanently<\/h1><\/center><\/body><\/html>\"};\n return(deliver);\n }\n\n}\n","old_contents":"# Note: It is VERY important to ensure that any changes to VCL will work\n# properly with both the current version of ``master`` and the version in\n# the pull request that adds any new changes. This is because the\n# configuration will be applied automatically as part of the deployment\n# process, but while the previous version of the code is still up and\n# running. Thus backwards incompatible changes must be broken up over\n# multiple pull requests in order to phase them in over multiple deploys.\n\nsub vcl_recv {\n\n # I'm not 100% sure on what this is exactly for, it was taken from the\n # Fastly documentation, however, what I *believe* it does is just ensure\n # that we don't serve a stale copy of the page from the shield node when\n # an edge node is requesting content.\n if (req.http.Fastly-FF) {\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Some (Older) clients will send a hash fragment as part of the URL even\n # though that is a local only modification. This breaks this badly for the\n # files in S3, and in general it's just not needed.\n set req.url = regsub(req.url, \"#.*$\", \"\");\n\n # Fastly does some normalization of the Accept-Encoding header so that it\n # reduces the number of cached copies (when served with the common,\n # Vary: Accept-Encoding) that are cached for any one URL. This makes a lot\n # of sense, except for the fact that we want to enable brotli compression\n # for our static files. Thus we need to work around the normalized encoding\n # in a way that still minimizes cached copies, but which will allow our\n # static files to be served using brotli.\n if (req.url ~ \"^\/static\/\" && req.http.Fastly-Orig-Accept-Encoding) {\n if (req.http.User-Agent ~ \"MSIE 6\") {\n # For that 0.3% of stubborn users out there\n unset req.http.Accept-Encoding;\n } elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"br\") {\n set req.http.Accept-Encoding = \"br\";\n } elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n\n # Most of the URLs in Warehouse do not support or require any sort of query\n # parameter. If we strip these at the edge then we'll increase our cache\n # efficiency when they won't otherwise change the output of the pages.\n #\n # This will match any URL except those that start with:\n #\n # * \/admin\/\n # * \/search\/\n # * \/account\/login\/\n # * \/account\/logout\/\n # * \/account\/register\/\n # * \/pypi\n if (req.url.path !~ \"^\/(admin\/|search(\/|$)|account\/(login|logout|register)\/|pypi)\") {\n set req.url = req.url.path;\n }\n\n # Sort all of our query parameters, this will ensure that the same query\n # parameters in a different order will end up being represented as the same\n # thing, reducing cache misses due to ordering differences.\n set req.url = boltsort.sort(req.url);\n\n # We have a number of items that we'll pass back to the origin.\n # Set a header to tell the backend if we're using https or http.\n if (req.http.Fastly-SSL) {\n set req.http.Warehouse-Proto = \"https\";\n } else {\n set req.http.Warehouse-Proto = \"http\";\n }\n\n # Pass the client IP address back to the backend.\n if (req.http.Fastly-Client-IP) {\n set req.http.Warehouse-IP = req.http.Fastly-Client-IP;\n }\n\n # Pass the real host value back to the backend.\n if (req.http.Host) {\n set req.http.Warehouse-Host = req.http.host;\n }\n\n\n#FASTLY recv\n\n\n # We want to Force SSL for the WebUI by redirecting to the HTTPS version of\n # the page, however for API calls we want to return an error code directing\n # people to instead use HTTPS.\n if (!req.http.Fastly-SSL) {\n\n # The \/simple\/ and \/packages\/ API.\n if (req.url ~ \"^\/(simple|packages)\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy JSON API.\n if (req.url ~ \"^\/pypi\/.+\/json$\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy ?:action= API.\n if (req.url ~ \"^\/pypi.*(\\?|&)=:action\") {\n error 803 \"SSL is required\";\n }\n\n # If we're on the \/pypi page and we've received something other than a\n # GET or HEAD request, then we have no way to determine if a particular\n # request is an API call or not because it'll be in the request body\n # and that isn't available to us here. So in those cases, we won't\n # do a redirect.\n if (req.url ~ \"^\/pypi\") {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n error 801 \"Force SSL\";\n }\n }\n else {\n # This isn't a \/pypi URL so we'll just unconditionally redirect to\n # HTTPS.\n error 801 \"Force SSL\";\n }\n }\n\n # Redirect pypi.io, www.pypi.io, and warehouse.python.org to pypi.org, this\n # is purposely done *after* the HTTPS checks.\n if (std.tolower(req.http.host) ~ \"^(www.pypi.org|(www.)?pypi.io|warehouse.python.org)$\") {\n set req.http.Location = \"https:\/\/pypi.org\" req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n # Redirect warehouse-staging.python.org to test.pypi.io.\n if (std.tolower(req.http.host) ~ \"^(test.pypi.io|warehouse-staging.python.org)$\") {\n set req.http.Location = \"https:\/\/test.pypi.org\" req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n\n # Requests to \/packages\/ get dispatched to Amazon instead of to our typical\n # Origin. This requires a a bit of setup to make it work.\n if (req.http.host ~ \"^(test-)?files.pythonhosted.org$\"\n && req.url ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\") {\n # Setup our environment to better match what S3 expects\/needs\n set req.http.Host = req.http.AWS-Bucket-Name \".s3.amazonaws.com\";\n set req.http.Date = now;\n set req.url = regsuball(req.url, \"\\+\", urlencode(\"+\"));\n\n # Compute the Authorization header that S3 requires to be able to\n # access the files stored there.\n set req.http.Authorization = \"AWS \" req.http.AWS-Access-Key-ID \":\" digest.hmac_sha1_base64(req.http.AWS-Secret-Access-Key, \"GET\" LF LF LF req.http.Date LF \"\/\" req.http.AWS-Bucket-Name req.url.path);\n\n # We don't want to send our Warehouse-Token to S3, so we'll go ahead\n # and remove it.\n unset req.http.Warehouse-Token;\n }\n\n # We no longer need any of these variables, which would exist only to\n # shuffle configuration from the Fastly UI into our VCL.\n unset req.http.AWS-Access-Key-ID;\n unset req.http.AWS-Secret-Access-Key;\n unset req.http.AWS-Bucket-Name;\n\n # On a POST, we want to skip the shielding and hit backends directly.\n if (req.request == \"POST\") {\n set req.backend = F_Heroku;\n }\n\n # Do not bother to attempt to run the caching mechanisms for methods that\n # are not generally safe to cache.\n if (req.request != \"HEAD\" &&\n req.request != \"GET\" &&\n req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n # We don't ever want to cache our health URL. Outside systems should be\n # able to use it to reach past Fastly and get an end to end health check.\n if (req.url == \"\/_health\/\") {\n return(pass);\n }\n\n # We never want to cache our admin URLs, while this should be \"safe\" due to\n # the architecure of Warehouse, it'll just be easier to debug issues if\n # these always are uncached.\n if (req.url ~ \"^\/admin\/\") {\n return(pass);\n }\n\n # Finally, return the default lookup action.\n return(lookup);\n}\n\n\nsub vcl_fetch {\n\n # These are newer kinds of redirects which should be able to be cached by\n # default, even though Fastly doesn't currently have them in their default\n # list of cacheable status codes.\n if (http_status_matches(beresp.status, \"303,307,308\")) {\n set beresp.cacheable = true;\n }\n\n # For any 5xx status code we want to see if a stale object exists for it,\n # if so we'll go ahead and serve it.\n if (beresp.status >= 500 && beresp.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n\n#FASTLY fetch\n\n\n # Trigger a \"SSL is required\" error if the backend has indicated to do so.\n if (beresp.http.X-Fastly-Error == \"803\") {\n error 803 \"SSL is required\";\n }\n\n # If we've gotten a 502 or a 503 from the backend, we'll go ahead and retry\n # the request.\n if ((beresp.status == 502 || beresp.status == 503) &&\n req.restarts < 1 &&\n (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n # If we've restarted, then we'll record the number of restarts.\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n # If there is a Set-Cookie header, we'll ensure that we do not cache the\n # response.\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n # If the response has the private Cache-Control directive then we won't\n # cache it.\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # If we've gotten an error after the restarts we'll deliver the response\n # with a very short cache time.\n if (http_status_matches(beresp.status, \"500,502,503\")) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n # Apply a default TTL if there isn't a max-age or s-maxage.\n if (beresp.http.Expires ||\n beresp.http.Surrogate-Control ~ \"max-age\" ||\n beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # Keep the ttl here\n }\n else {\n # Apply the default ttl\n set beresp.ttl = 60s;\n }\n\n # Actually deliver the fetched response.\n return(deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n # If the object we have isn't cacheable, then just serve it directly\n # without going through any of the caching mechanisms.\n if (!obj.cacheable) {\n return(pass);\n }\n\n return(deliver);\n}\n\n\nsub vcl_deliver {\n # If this is an error and we have a stale response available, restart so\n # that we can pick it up and serve it.\n if (resp.status >= 500 && resp.status < 600) {\n if (stale.exists) {\n restart;\n }\n }\n\n#FASTLY deliver\n\n # Unset headers that we don't need\/want to send on to the client because\n # they are not generally useful.\n unset resp.http.Via;\n\n # Set our standard security headers, we do this in VCL rather than in\n # Warehouse itself so that we always get these headers, regardless of the\n # origin server being used.\n set resp.http.Strict-Transport-Security = \"max-age=31536000; includeSubDomains; preload\";\n set resp.http.X-Frame-Options = \"deny\";\n set resp.http.X-XSS-Protection = \"1; mode=block\";\n set resp.http.X-Content-Type-Options = \"nosniff\";\n set resp.http.X-Permitted-Cross-Domain-Policies = \"none\";\n\n # If we're not executing a shielding request, and the URL is one of our file\n # URLs, and it's a GET request, and the response is either a 200 or a 304\n # then we want to log an event stating that a download has taken place.\n if (!req.http.Fastly-FF\n && std.tolower(req.http.Warehouse-Host) == \"files.pythonhosted.org\"\n && req.url.path ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\"\n && req.request == \"GET\"\n && http_status_matches(resp.status, \"200,304\")) {\n log {\"syslog \"} req.service_id {\" linehaul :: \"} \"2@\" now \"|\" geoip.country_code \"|\" req.url.path \"|\" tls.client.protocol \"|\" tls.client.cipher \"|\" resp.http.x-amz-meta-project \"|\" resp.http.x-amz-meta-version \"|\" resp.http.x-amz-meta-package-type \"|\" req.http.user-agent;\n log {\"syslog \"} req.service_id {\" downloads :: \"} \"2@\" now \"|\" geoip.country_code \"|\" req.url.path \"|\" tls.client.protocol \"|\" tls.client.cipher \"|\" resp.http.x-amz-meta-project \"|\" resp.http.x-amz-meta-version \"|\" resp.http.x-amz-meta-package-type \"|\" req.http.user-agent;\n }\n\n # Unset a few headers set by Amazon that we don't really have a need\/desire\n # to send to clients.\n unset resp.http.x-amz-replication-status;\n unset resp.http.x-amz-meta-python-version;\n unset resp.http.x-amz-meta-version;\n unset resp.http.x-amz-meta-package-type;\n unset resp.http.x-amz-meta-project;\n\n\n return(deliver);\n}\n\n\nsub vcl_error {\n#FASTLY error\n\n # If we have a 5xx error and there is a stale object available, then we\n # will deliver that stale object.\n if (obj.status >= 500 && obj.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n if (obj.status == 803) {\n set obj.status = 403;\n set obj.response = \"SSL is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic {\"SSL is required.\"};\n return (deliver);\n } else if (obj.status == 750) {\n set obj.status = 301;\n set obj.http.Location = req.http.Location;\n set obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n synthetic {\"<html><head><title>301 Moved Permanently<\/title><\/head><body><center><h1>301 Moved Permanently<\/h1><\/center><\/body><\/html>\"};\n return(deliver);\n }\n\n}\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"4a81bc626e01e7e329b69184c0a6e95be8afbaa8","subject":"Remove obsolete comment about obj.hits","message":"Remove obsolete comment about obj.hits\n","repos":"gquintard\/Varnish-Cache,franciscovg\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,chrismoulton\/Varnish-Cache,zhoualbeart\/Varnish-Cache,franciscovg\/Varnish-Cache,feld\/Varnish-Cache,mrhmouse\/Varnish-Cache,gquintard\/Varnish-Cache,zhoualbeart\/Varnish-Cache,zhoualbeart\/Varnish-Cache,gquintard\/Varnish-Cache,feld\/Varnish-Cache,feld\/Varnish-Cache,franciscovg\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,franciscovg\/Varnish-Cache,franciscovg\/Varnish-Cache,mrhmouse\/Varnish-Cache,alarky\/varnish-cache-doc-ja,varnish\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,chrismoulton\/Varnish-Cache,feld\/Varnish-Cache,mrhmouse\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,gquintard\/Varnish-Cache,varnish\/Varnish-Cache,mrhmouse\/Varnish-Cache,mrhmouse\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,chrismoulton\/Varnish-Cache,alarky\/varnish-cache-doc-ja,chrismoulton\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,varnish\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,alarky\/varnish-cache-doc-ja,feld\/Varnish-Cache,zhoualbeart\/Varnish-Cache,varnish\/Varnish-Cache,chrismoulton\/Varnish-Cache,varnish\/Varnish-Cache,alarky\/varnish-cache-doc-ja,zhoualbeart\/Varnish-Cache,alarky\/varnish-cache-doc-ja,ajasty-cavium\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache","old_file":"bin\/varnishd\/builtin.vcl","new_file":"bin\/varnishd\/builtin.vcl","new_contents":"\/*-\n * Copyright (c) 2006 Verdens Gang AS\n * Copyright (c) 2006-2014 Varnish Software AS\n * All rights reserved.\n *\n * Author: Poul-Henning Kamp <phk@phk.freebsd.dk>\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in the\n * documentation and\/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n\n *\n * The built-in (previously called default) VCL code.\n *\n * NB! You do NOT need to copy & paste all of these functions into your\n * own vcl code, if you do not provide a definition of one of these\n * functions, the compiler will automatically fall back to the default\n * code from this file.\n *\n * This code will be prefixed with a backend declaration built from the\n * -b argument.\n *\/\n\nvcl 4.0;\n\n#######################################################################\n# Client side\n\nsub vcl_recv {\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization || req.http.Cookie) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n return (hash);\n}\n\nsub vcl_pipe {\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n # set bereq.http.connection = \"close\";\n # here. It is not set by default as it might break some broken web\n # applications, like IIS with NTLM authentication.\n return (pipe);\n}\n\nsub vcl_pass {\n return (fetch);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n return (lookup);\n}\n\nsub vcl_purge {\n return (synth(200, \"Purged\"));\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n \/\/ A pure unadultered hit, deliver it\n return (deliver);\n }\n if (obj.ttl + obj.grace > 0s) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n return (deliver);\n }\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\nsub vcl_miss {\n return (fetch);\n}\n\nsub vcl_deliver {\n return (deliver);\n}\n\n\/*\n * We can come here \"invisibly\" with the following errors: 413, 417 & 503\n *\/\nsub vcl_synth {\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n set resp.http.Retry-After = \"5\";\n synthetic( {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n return (deliver);\n}\n\n#######################################################################\n# Backend Fetch\n\nsub vcl_backend_fetch {\n return (fetch);\n}\n\nsub vcl_backend_response {\n if (beresp.ttl <= 0s ||\n beresp.http.Set-Cookie ||\n beresp.http.Surrogate-control ~ \"no-store\" ||\n (!beresp.http.Surrogate-Control &&\n beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n beresp.http.Vary == \"*\") {\n \/*\n * Mark as \"Hit-For-Pass\" for the next 2 minutes\n *\/\n set beresp.ttl = 120s;\n set beresp.uncacheable = true;\n }\n return (deliver);\n}\n\nsub vcl_backend_error {\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} + beresp.status + \" \" + beresp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + beresp.status + \" \" + beresp.reason + {\"<\/h1>\n <p>\"} + beresp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + bereq.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n return (deliver);\n}\n\n#######################################################################\n# Housekeeping\n\nsub vcl_init {\n return (ok);\n}\n\nsub vcl_fini {\n return (ok);\n}\n","old_contents":"\/*-\n * Copyright (c) 2006 Verdens Gang AS\n * Copyright (c) 2006-2014 Varnish Software AS\n * All rights reserved.\n *\n * Author: Poul-Henning Kamp <phk@phk.freebsd.dk>\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in the\n * documentation and\/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n\n *\n * The built-in (previously called default) VCL code.\n *\n * NB! You do NOT need to copy & paste all of these functions into your\n * own vcl code, if you do not provide a definition of one of these\n * functions, the compiler will automatically fall back to the default\n * code from this file.\n *\n * This code will be prefixed with a backend declaration built from the\n * -b argument.\n *\/\n\nvcl 4.0;\n\n#######################################################################\n# Client side\n\nsub vcl_recv {\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization || req.http.Cookie) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n return (hash);\n}\n\nsub vcl_pipe {\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n # set bereq.http.connection = \"close\";\n # here. It is not set by default as it might break some broken web\n # applications, like IIS with NTLM authentication.\n return (pipe);\n}\n\nsub vcl_pass {\n return (fetch);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n return (lookup);\n}\n\nsub vcl_purge {\n return (synth(200, \"Purged\"));\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n \/\/ A pure unadultered hit, deliver it\n return (deliver);\n }\n if (obj.ttl + obj.grace > 0s) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n return (deliver);\n }\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\nsub vcl_miss {\n return (fetch);\n}\n\nsub vcl_deliver {\n \/*\n * These two write to the stored object causing extra page faults\n * Enable them only if you need them.\n *\n * set obj.hits = obj.hits + 1;\n *\/\n return (deliver);\n}\n\n\/*\n * We can come here \"invisibly\" with the following errors: 413, 417 & 503\n *\/\nsub vcl_synth {\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n set resp.http.Retry-After = \"5\";\n synthetic( {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n return (deliver);\n}\n\n#######################################################################\n# Backend Fetch\n\nsub vcl_backend_fetch {\n return (fetch);\n}\n\nsub vcl_backend_response {\n if (beresp.ttl <= 0s ||\n beresp.http.Set-Cookie ||\n beresp.http.Surrogate-control ~ \"no-store\" ||\n (!beresp.http.Surrogate-Control &&\n beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n beresp.http.Vary == \"*\") {\n \/*\n * Mark as \"Hit-For-Pass\" for the next 2 minutes\n *\/\n set beresp.ttl = 120s;\n set beresp.uncacheable = true;\n }\n return (deliver);\n}\n\nsub vcl_backend_error {\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} + beresp.status + \" \" + beresp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + beresp.status + \" \" + beresp.reason + {\"<\/h1>\n <p>\"} + beresp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + bereq.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n return (deliver);\n}\n\n#######################################################################\n# Housekeeping\n\nsub vcl_init {\n return (ok);\n}\n\nsub vcl_fini {\n return (ok);\n}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"daa2bc1a9e2c05db71e98ce0573718d936930331","subject":"Setting works better when I set them to something. Derp.","message":"Setting works better when I set them to something. Derp.\n","repos":"telusdigital\/ansible-varnish,gotofbi\/ansible-varnish,noqcks\/ansible-varnish,killerwails\/ansible-varnish,gotofbi\/ansible-varnish,killerwails\/ansible-varnish,colstrom\/ansible-varnish,kkwoker\/ansible-varnish","old_file":"templates\/etc\/varnish\/default.vcl","new_file":"templates\/etc\/varnish\/default.vcl","new_contents":"vcl 4.0;\n\nimport directors;\nimport std;\n\n###\n# Varnish Documentation\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-built-in-subs.html\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/reference\/vcl.html\n##\n\n{% for backend in varnish_backend_hosts %}\nbackend application_{{ loop.index }} {\n .host = \"{{ backend }}\";\n .port = \"{{ varnish_backend_port }}\";\n{% if varnish_health_checks_enabled %}\n .probe = {\n .url = \"{{ varnish_health_check_url }}\";\n .interval = {{ varnish_health_check_interval }};\n .timeout = {{ varnish_health_check_timeout }};\n .window = {{ varnish_health_check_window }};\n .threshold = {{ varnish_health_check_threshold }};\n }\n{% endif %}\n}\n{% endfor %}\n\n###\n# vcl_init\n# Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n###\n# The vcl_init subroutine may terminate with calling return() with one of the following keywords:\n#\n# ok\n# Normal return, VCL continues loading.\n##\n\nsub vcl_init {\n new application = directors.round_robin();\n{% for backend in varnish_backend_hosts %}\n application.add_backend(application_{{ loop.index }});\n{% endfor %}\n}\n\n###\n# vcl_recv\n# Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use. \n# It is also used to modify the request\n###\n# The vcl_recv subroutine may terminate with calling return() on one of the following keywords:\n#\n# synth(status code, reason)\n# Return a synthetic object with the specified status code to the client and abandon the request.\n# pass\n# Switch to pass mode. Control will eventually pass to vcl_pass.\n# pipe\n# Switch to pipe mode. Control will eventually pass to vcl_pipe.\n# hash\n# Continue processing the object as a potential candidate for caching. Passes the control over to vcl_hash.\n# purge\n# Purge the object and it's variants. Control passes through vcl_hash to vcl_purge.\n#\n\nsub vcl_recv {\n set req.backend_hint = application.backend();\n\n ###\n # Avoid processing uncacheable requests\n ###\n\n if (req.http.Authorization) {\n return (pass);\n }\n\n ###\n # Inject X-Forwarded-For headers, but only once.\n ###\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n{% if varnish_header_sanitization_enabled %}\n ###\n # Header Sanitization\n ###\n\n{% if varnish_discards_port_from_host_header %}\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n{% endif %}\n\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_enabled %}\n ###\n # Cookie Sanitization\n ###\n\n ### Google Analytics\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n\n ### Quantcast\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n \n ### AddThis\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n\n ### General Cleanup\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n{% endif %}\n\n{% if varnish_uri_sanitization_enabled %}\n ###\n # URI Sanitization\n ###\n \n if (req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=\") {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n{% endif %}\n\n{% if varnish_workaround_telusdotcom_browser_profile %}\n ###\n # Workaround for BrowserProfile and Language\/Region Detection on TELUS.com\n ###\n\n if (req.http.Cookie ~ \"BrowserProfile\") {\n set req.http.X-Language = regsuball(req.http.Cookie, \"language..:\\\\.(.*)\\\\.,\", \"\\1\");\n set req.http.X-Province = regsuball(req.http.Cookie, \"region..:\\\\.(.*)\\\\.,\", \"\\1\");\n } else {\n if (req.http.Cookie ~ \"lang=\") {\n set req.http.X-Language = regsuball(req.http.Cookie, \"lang=(.*);\", \"\\1\");\n } else {\n set req.http.X-Language = \"en\";\n }\n\n if (req.http.Cookie ~ \"prov=\") {\n set req.http.X-Province = regsuball(req.http.Cookie, \"prov=(.*);\", \"\\1\");\n } else {\n set req.http.X-Province = \"BC\";\n }\n }\n\n if (req.url ~ \"\/(en|fr)\/\") {\n if (req.url ~ \"\/en\/\" && req.http.X-Language != \"en\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Language)\";\n return(pass);\n }\n if (req.url ~ \"\/fr\/\" && req.http.X-Language != \"fr\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Language)\";\n return(pass);\n }\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Language)\";\n return(pass);\n }\n\n if (req.url ~ \"\/(ab|bc|mb|nb|nl|ns|nt|nu|on|pe|qc|sk|yt)\/\") {\n {% for province in ['ab', 'bc', 'mb', 'nb', 'nl', 'ns', 'nt', 'nu', 'on', 'pe', 'qc', 'sk', 'yt'] %}\n if (req.url ~ \"{{ province }}\" && req.http.X-Province != \"{{ province }}\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Province)\";\n return(pass);\n }\n {% endfor %}\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Province)\";\n return(pass);\n }\n{% endif %}\n\n{% if varnish_blacklist_enabled %}\n if ((req.url ~ \"{{ varnish_blacklist_regexp }}\")) {\n set req.http.X-Passthrough-Reason = \"Path in Blacklist\";\n return(pass);\n } else {\n{% if varnish_discards_client_cookies %}\n unset req.http.Cookie;\n{% endif %}\n }\n{% endif %}\n\n}\n\n###\n# vcl_hit\n# Called when a cache lookup is successful.\n###\n# The vcl_hit subroutine may terminate with calling return() with one of the following keywords:\n#\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n# deliver\n# Deliver the object. Control passes to vcl_deliver.\n# synth(status code, reason)\n# Return the specified status code to the client and abandon the request.\n###\n\nsub vcl_hit {\n if (obj.ttl > 0s) {\n return (deliver);\n }\n{% if varnish_health_checks_enabled %}\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (fetch);\n }\n{% else %}\n if (obj.ttl + obj.grace > 0s) {\n return (deliver);\n }\n\n return (fetch);\n{% endif %}\n}\n\n###\n# vcl_backend_response\n# Called after the response headers has been successfully retrieved from the backend.\n###\n# The vcl_backend_response subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Possibly insert the object into the cache, then deliver it to the Control will eventually pass to vcl_deliver.\n# abandon\n# Abandon the backend request and generates an error.\n# retry\n# Retry the backend transaction. Increases the retries counter. If the number of retries is higher than max_retries Varnish emits a guru meditation error.\n###\n\nsub vcl_backend_response {\n{% if varnish_workaround_telusdotcom_browser_profile %}\n if (bereq.http.X-Language) {\n set beresp.http.X-Language = bereq.http.X-Language;\n }\n if (bereq.http.X-Province) {\n set beresp.http.X-Province = bereq.http.X-Province;\n }\n{% endif %}\n\n{% if varnish_blacklist_enabled %}\n if (bereq.url ~ \"{{ varnish_blacklist_regexp }}\") {\n set beresp.http.X-Cacheable = \"NO:Path in Blacklist\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n if (bereq.http.X-Passthrough-Reason) {\n set beresp.http.X-Passthrough-Reason = bereq.http.X-Passthrough-Reason;\n return(deliver);\n } else {\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n }\n }\n{% else %}\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n{% endif %}\n\n{% if varnish_cache_diagnostics_enabled %}\n if (bereq.http.Cookie) {\n set beresp.http.X-Cacheable = \"NO:Cookie in Request\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO:Set-Cookie in Response\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.X-No-Cache) {\n set beresp.http.X-Cacheable = \"NO:X-No-Cache\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.ttl <= 0s) {\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n{% endif %}\n\n set beresp.grace = {{ varnish_grace_period }};\n}\n\n###\n# vcl_deliver\n# Called before a cached object is delivered to the client.\n###\n# The vcl_deliver subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Deliver the object to the client.\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n###\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n","old_contents":"vcl 4.0;\n\nimport directors;\nimport std;\n\n###\n# Varnish Documentation\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-built-in-subs.html\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/reference\/vcl.html\n##\n\n{% for backend in varnish_backend_hosts %}\nbackend application_{{ loop.index }} {\n .host = \"{{ backend }}\";\n .port = \"{{ varnish_backend_port }}\";\n{% if varnish_health_checks_enabled %}\n .probe = {\n .url = \"{{ varnish_health_check_url }}\";\n .interval = {{ varnish_health_check_interval }};\n .timeout = {{ varnish_health_check_timeout }};\n .window = {{ varnish_health_check_window }};\n .threshold = {{ varnish_health_check_threshold }};\n }\n{% endif %}\n}\n{% endfor %}\n\n###\n# vcl_init\n# Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n###\n# The vcl_init subroutine may terminate with calling return() with one of the following keywords:\n#\n# ok\n# Normal return, VCL continues loading.\n##\n\nsub vcl_init {\n new application = directors.round_robin();\n{% for backend in varnish_backend_hosts %}\n application.add_backend(application_{{ loop.index }});\n{% endfor %}\n}\n\n###\n# vcl_recv\n# Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use. \n# It is also used to modify the request\n###\n# The vcl_recv subroutine may terminate with calling return() on one of the following keywords:\n#\n# synth(status code, reason)\n# Return a synthetic object with the specified status code to the client and abandon the request.\n# pass\n# Switch to pass mode. Control will eventually pass to vcl_pass.\n# pipe\n# Switch to pipe mode. Control will eventually pass to vcl_pipe.\n# hash\n# Continue processing the object as a potential candidate for caching. Passes the control over to vcl_hash.\n# purge\n# Purge the object and it's variants. Control passes through vcl_hash to vcl_purge.\n#\n\nsub vcl_recv {\n set req.backend_hint = application.backend();\n\n ###\n # Avoid processing uncacheable requests\n ###\n\n if (req.http.Authorization) {\n return (pass);\n }\n\n ###\n # Inject X-Forwarded-For headers, but only once.\n ###\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n{% if varnish_header_sanitization_enabled %}\n ###\n # Header Sanitization\n ###\n\n{% if varnish_discards_port_from_host_header %}\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n{% endif %}\n\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_enabled %}\n ###\n # Cookie Sanitization\n ###\n\n ### Google Analytics\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n\n ### Quantcast\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n \n ### AddThis\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n\n ### General Cleanup\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n{% endif %}\n\n{% if varnish_uri_sanitization_enabled %}\n ###\n # URI Sanitization\n ###\n \n if (req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=\") {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n{% endif %}\n\n{% if varnish_workaround_telusdotcom_browser_profile %}\n ###\n # Workaround for BrowserProfile and Language\/Region Detection on TELUS.com\n ###\n\n if (req.http.Cookie ~ \"BrowserProfile\") {\n set req.http.X-Language = regsuball(req.http.Cookie, \"language..:\\\\.(.*)\\\\.,\", \"\\1\");\n set req.http.X-Province = regsuball(req.http.Cookie, \"region..:\\\\.(.*)\\\\.,\", \"\\1\");\n } else {\n if (req.http.Cookie ~ \"lang=\") {\n set req.http.X-Language = regsuball(req.http.Cookie, \"lang=(.*);\", \"\\1\");\n } else {\n set req.http.X-Language = \"en\";\n }\n\n if (req.http.Cookie ~ \"prov=\") {\n set req.http.X-Province = regsuball(req.http.Cookie, \"prov=(.*);\", \"\\1\");\n } else {\n set req.http.X-Province = \"BC\";\n }\n }\n\n if (req.url ~ \"\/(en|fr)\/\") {\n if (req.url ~ \"\/en\/\" && req.http.X-Language != \"en\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Language)\";\n return(pass);\n }\n if (req.url ~ \"\/fr\/\" && req.http.X-Language != \"fr\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Language)\";\n return(pass);\n }\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Language)\";\n return(pass);\n }\n\n if (req.url ~ \"\/(ab|bc|mb|nb|nl|ns|nt|nu|on|pe|qc|sk|yt)\/\") {\n {% for province in ['ab', 'bc', 'mb', 'nb', 'nl', 'ns', 'nt', 'nu', 'on', 'pe', 'qc', 'sk', 'yt'] %}\n if (req.url ~ \"{{ province }}\" && req.http.X-Province != \"{{ province }}\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Province)\";\n return(pass);\n }\n {% endfor %}\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Province)\";\n return(pass);\n }\n{% endif %}\n\n{% if varnish_blacklist_enabled %}\n if ((req.url ~ \"{{ varnish_blacklist_regexp }}\")) {\n set req.http.X-Passthrough-Reason = \"Path in Blacklist\";\n return(pass);\n } else {\n{% if varnish_discards_client_cookies %}\n unset req.http.Cookie;\n{% endif %}\n }\n{% endif %}\n\n}\n\n###\n# vcl_hit\n# Called when a cache lookup is successful.\n###\n# The vcl_hit subroutine may terminate with calling return() with one of the following keywords:\n#\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n# deliver\n# Deliver the object. Control passes to vcl_deliver.\n# synth(status code, reason)\n# Return the specified status code to the client and abandon the request.\n###\n\nsub vcl_hit {\n if (obj.ttl > 0s) {\n return (deliver);\n }\n{% if varnish_health_checks_enabled %}\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (fetch);\n }\n{% else %}\n if (obj.ttl + obj.grace > 0s) {\n return (deliver);\n }\n\n return (fetch);\n{% endif %}\n}\n\n###\n# vcl_backend_response\n# Called after the response headers has been successfully retrieved from the backend.\n###\n# The vcl_backend_response subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Possibly insert the object into the cache, then deliver it to the Control will eventually pass to vcl_deliver.\n# abandon\n# Abandon the backend request and generates an error.\n# retry\n# Retry the backend transaction. Increases the retries counter. If the number of retries is higher than max_retries Varnish emits a guru meditation error.\n###\n\nsub vcl_backend_response {\n{% if varnish_workaround_telusdotcom_browser_profile %}\n if (bereq.http.X-Language) {\n set bereq.http.X-Language;\n }\n if (bereq.http.X-Province) {\n set bereq.http.X-Province;\n }\n{% endif %}\n\n{% if varnish_blacklist_enabled %}\n if (bereq.url ~ \"{{ varnish_blacklist_regexp }}\") {\n set beresp.http.X-Cacheable = \"NO:Path in Blacklist\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n if (bereq.http.X-Passthrough-Reason) {\n set beresp.http.X-Passthrough-Reason = bereq.http.X-Passthrough-Reason;\n return(deliver);\n } else {\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n }\n }\n{% else %}\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n{% endif %}\n\n{% if varnish_cache_diagnostics_enabled %}\n if (bereq.http.Cookie) {\n set beresp.http.X-Cacheable = \"NO:Cookie in Request\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO:Set-Cookie in Response\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.X-No-Cache) {\n set beresp.http.X-Cacheable = \"NO:X-No-Cache\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.ttl <= 0s) {\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n{% endif %}\n\n set beresp.grace = {{ varnish_grace_period }};\n}\n\n###\n# vcl_deliver\n# Called before a cached object is delivered to the client.\n###\n# The vcl_deliver subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Deliver the object to the client.\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n###\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"fca4ffd8ebc509dd8c71dc2319f5749b5dbf4ef0","subject":"update probe example","message":"update probe example\n","repos":"NITEMAN\/Varnish_VCL_samps-hacks,NITEMAN\/varnish-bites","old_file":"varnish3\/drupal-base.vcl","new_file":"varnish3\/drupal-base.vcl","new_contents":"\/* Varnish 3 example config for Drupal 7 \/ Pressflow 6 & 7 *\/\n# Original source: https:\/\/github.com\/NITEMAN\/varnish-bites\/varnish4\/drupal-base.vcl\n# Copyright (c) 2015 Pedro Gonz\u00e1lez Serrano and individual contributors.\n# MIT License\n\n# Intended to be used both in simple production environments and with learning\/teaching purposes.\n# Loosely based on http:\/\/www.lullabot.com\/sites\/default\/files\/default_varnish3.vcl_.txt\n\n\/* Backend probes \/ healthchecks *\/\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#backend-probes\nprobe basic {\n \/* Only test that backend's IP serves content for '\/' *\/\n # This might be a too heavy probe\n # .url = \"\/\";\n \/* Only test that backend's IP has apache working *\/\n # Nginx would fail this probe with a default config\n .request =\n \"OPTIONS * HTTP\/1.1\"\n \"Host: *\"\n \"Connection: close\";\n .interval = 10s;\n .timeout = 2s;\n .window = 8;\n .threshold = 6;\n}\n\n\n\/* Backend definitions.*\/\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#backend-declarations\nbackend default {\n \/* Default backend on the same machine. WARNING: timeouts could be not big enought for certain POST request *\/\n .host = \"127.0.0.1\";\n .port = \"8080\";\n .connect_timeout = 60s;\n .first_byte_timeout = 60s;\n .between_bytes_timeout = 60s;\n .probe = basic;\n}\n\n\n\/* Directors. *\/\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#directors\n# Empty in simple configs\n\n\n\/* Access Control Lists *\/\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#acls\nacl purge_ban {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use '\"localhost\";' instead\n}\nacl allowed_monitors {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n}\n\n\n\/* Custom routines *\/\n# Empty in simple configs.\n# We can name subs with no restrictions but as a task can need several chunks of code in diferent states,\n# it's a good idea to identify what main sub will call each with a suffix.\n# \/* Example 301 client redirection removing \"www\" prefix from request *\/\n# sub perm_redirections_recv {\n# if ( req.http.host ~ \"^www.*$\" ) {\n# error 751 \"http:\/\/\" + regsub(req.http.host, \"^www\\.\", \"\") + req.url;\n# }\n# }\n# sub perm_redirections_error {\n# if (obj.status == 751) {\n# \/* Get new URL from the response *\/\n# set obj.http.Location = obj.response;\n# \/* Set HTTP 301 for permanent redirect *\/\n# set obj.status = 301;\n# return(deliver);\n# }\n# }\n\n\n\/* VCL logigc overrides *\/\n# Note that the built-in logic will be appended to our code if no return is performed before.\n# Built-in logic is included commented out right after our's for reference purposes in that cases.\n# See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleDefault\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#subroutines\n\n# vcl_recv: Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use.\nsub vcl_recv {\n \/* 0th: general bypass, general return & authorization checks *\/\n # Empty in simple configs.\n # Useful for debugging we can pipe or pass the request to default backend here to bypass completely Varnish.\n # return (pipe);\n # return (pass);\n # We can also return here a 200 Ok for network performance benchmarking.\n # error 200 \"Ok\";\n # Finally we can perform basic HTTP authentification here by example.\n # See http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* 1st: Check for Varnish special requests *\/ \n # Purge logic.\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/purging.html#http-purges\n # See https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if (req.request == \"PURGE\") {\n if (!client.ip ~ purge_ban) {\n error 405 \"Not allowed.\";\n }\n return (lookup);\n }\n # Ban logic. See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/purging.html#bans\n if (req.request == \"BAN\") {\n if (!client.ip ~ purge_ban) {\n error 405 \"Not allowed.\";\n }\n ban(\"req.http.host == \" + req.http.host +\n \"&& req.url == \" + req.url); \n error 200 \"Ban added\";\n }\n # Custom response implementation example in order to check that Varnish is working properly.\n # This is usefull for automatic monitoring with monit or when Varnish is behind another proxies like HAProxy.\n if (req.http.host == \"monitor.server.health\" && \n client.ip ~ allowed_monitors && \n (req.request == \"OPTIONS\" || req.request == \"GET\")) {\n error 200 \"Ok\";\n }\n\n \/* 2nd: Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_recv;\n # Here we can also enforce SSL when Varnish run behind some SSL termination point.\n\n \/* 3rd: Time for backend choice *\/\n # Empty in simple configs.\n\n \/* 4th: Set custom headers for backend like X-Forwarded-For (copied from built-in logic) *\/\n if (req.restarts == 0) {\n \/* See also vcl_pipe section *\/\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n \/* 5th: Bypass breakpoint 1 *\/\n # Useful for debugging we can now pipe or pass the request to backend with headers setted.\n # return (pipe);\n # return (pass);\n\n \/* 6th: Decide if we should deal with a request (mostly copied from built-in logic) *\/\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n\n \/* 7th: Access control for some URLs by ACL *\/\n # Empty in simple configs.\n # By example denial some URLs depending on client-ip, we'll need to define corresponding ACL 'internal'.\n # if (req.url ~ \"^\/(cron|install)\\.php$\" && !client.ip ~ internal) {\n # # Have Varnish throw the error directly.\n # error 403 \"Forbidden.\";\n # # Use a custom error page that you've defined in Drupal at the path \"404\".\n # # set req.url = \"\/403\";\n # }\n\n \/* 8th: Custom exceptions *\/\n # Host exception example:\n # if (req.http.host == \"ejemplo.exception.com\") {\n # return (pass);\n # }\n # Drupal exceptions, edit if we want to cache some AJAX\/AHAH request.\n # Add here filters for never cache URLs such as Payment Gateway's callbacks\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/ooyala\/ping$\" ||\n req.url ~ \"^\/admin\/build\/features\" ||\n req.url ~ \"^\/info\/.*$\" ||\n req.url ~ \"^\/flag\/.*$\" ||\n req.url ~ \"^.*\/ajax\/.*$\" ||\n req.url ~ \"^.*\/ahah\/.*$\") {\n \/* Do not cache these paths *\/\n return (pass);\n }\n # Pipe these paths directly to backend for streaming.\n if (req.url ~ \"^\/admin\/content\/backup_migrate\/export\") {\n return (pipe);\n }\n if (req.url ~ \"^\/system\/files\") {\n return (pipe);\n }\n\n \/* 9th: Enable grace mode *\/\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/handling_misbehaving_servers.html#grace-mode\n if (! req.backend.healthy) {\n \/* Use a longer grace period if all backends are down *\/\n set req.grace = 1h;\n \/* Use anonymous, cached pages if all backends are down. *\/\n unset req.http.Cookie;\n # TO-DO: Add sick marker\n } else {\n \/* Allow the backend to serve up stale content if it is responding slowly. *\/\n set req.grace = 30s;\n }\n\n \/* 10th: Deal with compression and the Accept-Encoding header *\/\n # Althought Varnish 3 handles gziped content itself by default, just to be sure we want to \n # remove Accept-Encoding for some compressed formats.\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/phk\/gzip.html#what-does-http-gzip-support-do\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/varnishd.html?highlight=http_gzip_support\n # See (for older configs) https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleNormalizeAcceptEncoding\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|mp4|flv|zip|rar)$\") {\n \/* Already compressed formats, no sense trying to compress again *\/\n remove req.http.Accept-Encoding;\n }\n }\n\n \/* 11th: Another header manipulation *\/\n # Empty in simple configs.\n # We could add here a custom header grouping User-agent families.\n\n \/* 12th: Cookie removal *\/\n # Always cache the following static file types for all users. \n # Use with care if we control certain downloads depending on cookies. \n # Be carefull also if appending .htm[l] via Drupal's clean URLs.\n if (req.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|svg|pdf)(\\?[a-z0-9]+)?$\") {\n unset req.http.Cookie;\n }\n # Remove all cookies that backend doesn't need to know about.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRemovingSomeCookies\n if (req.http.Cookie) {\n \/* Warning: Not a pretty solution *\/\n \/* Prefix header containing cookies with ';' *\/\n set req.http.Cookie = \";\" + req.http.Cookie;\n \/* Remove any spaces after ';' in header containing cookies *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n \/* Prefix cookies we want to preserve with one space *\/\n \/* 'S{1,2}ESS[a-z0-9]+' is the regular expression matching a Drupal session cookie ({1,2} added for HTTPS support) *\/\n \/* 'NO_CACHE' is usually set after a POST request to make sure issuing user see the results of his post *\/\n \/* 'OATMEAL' & 'CHOCOLATECHIP' are special cookies used by Drupal's Bakery module to provide Single Sign On *\/\n \/* Keep in mind we should add here any cookie that should reach the backend such as splahs avoiding cookies *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \";(S{1,2}ESS[a-z0-9]+|NO_CACHE|OATMEAL|CHOCOLATECHIP)=\", \"; \\1=\");\n \/* Remove from the header any single Cookie not prefixed with a space until next ';' separator *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n \/* Remove any '; ' at the start or the end of the header *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n\n if (req.http.Cookie == \"\") {\n \/* If there are no remaining cookies, remove the cookie header. *\/\n unset req.http.Cookie;\n }\n }\n\n \/* 13th: Session cookie & special cookies bypass caching stage *\/\n # As we might want to cache some requests, hashed with its cookies, \n # we don't simply pass when some cookies remain present at this point.\n # Instead we look for request that must be passed due to the cookie header.\n if (req.http.Cookie ~ \"SESS\" ||\n req.http.Cookie ~ \"SSESS\" ||\n req.http.Cookie ~ \"NO_CACHE\" ||\n req.http.Cookie ~ \"OATMEAL\" ||\n req.http.Cookie ~ \"CHOCOLATECHIP\") {\n return (pass);\n }\n\n \/* 14th: Bypass breakpoint 2 *\/\n # Useful for debugging we can now pipe or pass the request to backend to bypass cache.\n # return (pipe);\n # return (pass);\n\n \/* 15th: Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning a lookup.\n return (lookup);\n}\n\n# vcl_pipe: Called upon entering pipe mode.\n# In this mode, the request is passed on to the backend, \n# and any further data from either client or backend is passed on unaltered until either end closes the connection.\nsub vcl_pipe {\n \/* Prevent connection re-using for piped requests *\/\n # Note that only the first request to the backend will have X-Forwarded-For set.\n # As we use X-Forwarded-For and want to have it set for all requests, \n # we have to make sure connection won't be reused after the request.\n # It is not set by default as it might break some broken web applications, like IIS with NTLM authentication.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExamplePipe\n # TO-DO: make sure this is compatible with websockets piping,\n # reference https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/websockets.html\n set bereq.http.connection = \"close\";\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this point.\n return (pipe);\n}\n\n# vcl_pass: Called upon entering pass mode. \n# In this mode, the request is passed on to the backend, and the backend's response is passed on to the client, \n# but is not entered into the cache.\n# Subsequent requests submitted over the same client connection are handled normally.\n# sub vcl_pass {\n# return (pass);\n# }\n\n# vcl_hash: You may call hash_data() on the data you would like to add to the hash.\n# Hash is used by Varnish to uniquely identify objects.\nsub vcl_hash {\n \/* Hash cookie data *\/\n # As requests with same URL and host can produce diferent results when issued with different cookies,\n # we need to store items hashed with the associated cookies. Note that cookies are already sanitized when we reach this point.\n if (req.http.Cookie) {\n \/* Include cookie in cache hash *\/\n hash_data(req.http.Cookie);\n }\n\n \/* Custom header hashing *\/\n # Empty in simple configs.\n # Example for caching differents object versions by device previously detected (when static content could also vary):\n # if (req.http.X-UA-Device) {\n # hash_data(req.http.X-UA-Device);\n # }\n # Example for caching diferent object versions by X-Forwarded-Proto, trying to be smart about what kind of request\n # could generate diffetent responses.\n # if (req.http.X-Forwarded-Proto &&\n # req.url !~ \"(?i)\\.(png|gif|jpeg|jpg|ico|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|svg|pdf)$\") {\n # hash_data(req.http.X-Forwarded-Proto);\n # }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (hash);\n# }\n\n# vcl_hit: Called after a cache lookup if the requested document was found in the cache.\nsub vcl_hit {\n \/* Check for Varnish special requests *\/ \n # Purge logic.\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/purging.html#http-purges\n # See https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged.\";\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hit {\n# return (deliver);\n# }\n\n# vcl_miss: Called after a cache lookup if the requested document was not found in the cache.\n# Its purpose is to decide whether or not to attempt to retrieve the document from the backend, and which backend to use.\nsub vcl_miss {\n \/* Check for Varnish special requests *\/ \n # Purge logic.\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/purging.html#http-purges\n # See https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged.\";\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_miss {\n# return (fetch);\n# }\n\n# vcl_fetch: Called after a document has been successfully retrieved from the backend.\nsub vcl_fetch {\n \/* Caching exceptions *\/\n # Varnish will cache objects with response codes: 200, 203, 300, 301, 302, 307, 404 & 410.\n # See https:\/\/www.varnish-software.com\/static\/book\/VCL_Basics.html#the-initial-value-of-beresp-ttl\n # Drupal's Imagecache module can return a 307 redirection to the requested url itself and, depending on Drupal's cache settings,\n # this could lead to a redirection loop being cached for a long time but also we want Varnish to shield a little the backend.\n # See http:\/\/drupal.org\/node\/1248010\n # See http:\/\/drupal.org\/node\/310656\n if (beresp.status == 307 &&\n \/* TO-DO: verify that this work better than 'req.url ~ \"imagecache\"' *\/\n beresp.http.Location == req.url &&\n beresp.ttl > 5s) {\n set beresp.ttl = 5s;\n set beresp.http.cache-control = \"max-age=5\";\n }\n\n \/* Enable grace mode. Related with our 9th stage on vcl_recv *\/\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/handling_misbehaving_servers.html#grace-mode\n set beresp.grace = 1h;\n\n \/* Enable saint mode. Related with our 9th stage on vcl_recv *\/\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/handling_misbehaving_servers.html#saint-mode\n if (beresp.status == 500) {\n set beresp.saintmode = 20s;\n # TO-DO: consider not restarting POST requests as seen on https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleSaintMode\n return(restart);\n }\n\n \/* Strip cookies from the following static file types for all users. Related with our 12th stage on vcl_recv *\/\n if (req.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|svg|pdf)(\\?[a-z0-9]+)?$\") {\n unset beresp.http.set-cookie;\n }\n\n \/* Gzip response *\/\n # Empty in simple configs\n # Use Varnish to Gzip respone, if suitable, before storing it on cache\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/phk\/gzip.html\n # if (! beresp.http.Content-Encoding &&\n # (beresp.http.content-type ~ \"text\" ||\n # beresp.http.content-type ~ \"application\/x-javascript\" ||\n # beresp.http.content-type ~ \"application\/javascript\" ||\n # beresp.http.content-type ~ \"application\/rss+xml\" ||\n # beresp.http.content-type ~ \"application\/xml\" ||\n # beresp.http.content-type ~ \"Application\/JSON\")\n # ) {\n # set beresp.do_gzip = true;\n # if ( beresp.http.Vary ) {\n # if ( ! beresp.http.Vary ~ \"Accept-Encoding\" ) {\n # set beresp.http.Vary = beresp.http.Vary + \",Accept-Encoding\";\n # }\n # } else {\n # set beresp.http.Vary = \"Accept-Encoding\";\n # }\n # }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # We can add the name of the backend that has processed the request:\n # set beresp.http.X-Backend = beresp.backend.name;\n # We can use a header to tell if the object was gziped by Varnish\n # if (beresp.do_gzip) {\n # set beresp.http.X-Varnish-Gzipped = \"yes\";\n # } else {\n # set beresp.http.X-Varnish-Gizipped = \"no\";\n # }\n # We can also add headers informing whether the object is cacheable or not and why.\n # https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Varnish3.0\n if (beresp.ttl <= 0s) {\n \/* Varnish determined the object was not cacheable *\/\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n } elsif (req.http.Cookie ~ \"(SESS|SSESS|NO_CACHE|OATMEAL|CHOCOLATECHIP)\") {\n \/* We don't wish to cache content for logged in users or with certain cookies. Related with our 9th stage on vcl_recv *\/\n set beresp.http.X-Cacheable = \"NO:Cookies\";\n # return(hit_for_pass);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n \/* We are respecting the Cache-Control=private header from the backend *\/\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n # return(hit_for_pass);\n } else {\n \/* Varnish determined the object was cacheable *\/\n set beresp.http.X-Cacheable = \"YES\";\n }\n\n \/* Further header manipulation *\/\n # Empty in simple configs.\n # We can also unset some headers to prevent information disclosure and save some cache space\n # unset beresp.http.Server;\n # unset beresp.http.X-Powered-By;\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_fetch {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Vary == \"*\") {\n# \/*\n# * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# *\/\n# set beresp.ttl = 120 s;\n# return (hit_for_pass);\n# }\n# return (deliver);\n# }\n\n# vcl_deliver: Called before an object is delivered to the client\nsub vcl_deliver {\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # Add whether the object is a cache hit or miss and the number of hits for the object.\n # https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Addingaheaderindicatinghitmiss\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n set resp.http.X-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Cache = \"MISS\";\n \/* Show the results of cookie sanitization *\/\n set resp.http.X-Cookie = req.http.Cookie;\n }\n # TO-DO: Add sick marker\n # Restart count\n if ( req.restarts > 0) {\n set resp.http.X-Restarts = req.restarts;\n }\n # Add the Varnish server hostname\n set resp.http.X-Varnish-Server = server.hostname;\n # If we have setted a custom header with device family detected we can show it:\n # if (req.http.X-UA-Device) {\n # set resp.http.X-UA-Device = req.http.X-UA-Device;\n # }\n # If we have recived a custom header with the protocol in the request we can show it:\n # if (req.http.X-Forwarded-Proto) {\n # set resp.http.X-Forwarded-Proto = req.http.X-Forwarded-Proto;\n # }\n\n \/* Vary header manipulation *\/\n # Empty in simple configs.\n # By example, if we are storing & serving diferent objects depending on User-Agent header we must set the correct Vary header:\n # if (resp.http.Vary) {\n # set resp.http.Vary = resp.http.Vary + \",User-Agent\";\n # } else {\n # set resp.http.Vary = \"User-Agent\";\n # }\n\n \/* Fake headers *\/\n # Empty in simple configs\n # We can fake server headers here, by example:\n # set resp.http.Server = \"Deep thought\";\n # set resp.http.X-Powered-By = \"BOFH\";\n # Or have some fun with headers:\n # See http:\/\/www.nextthing.org\/archives\/2005\/08\/07\/fun-with-http-headers\n # See http:\/\/royal.pingdom.com\/2012\/08\/15\/fun-and-unusual-http-response-headers\/\n # set resp.http.X-Thank-You = \"for bothering to look at my HTTP headers\";\n # set resp.http.X-Answer = \"42\";\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_deliver {\n# return (deliver);\n# }\n\n# vcl_error: Called when we hit an error, either explicitly or implicitly due to backend or internal errors.\nsub vcl_error {\n \/* Avoid DOS vulnerability CVE-2013-4484 *\/\n # See https:\/\/www.varnish-cache.org\/lists\/pipermail\/varnish-announce\/2013-October\/000686.html\n if (obj.status == 400 || obj.status == 413) {\n return(deliver);\n }\n\n \/* Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_error;\n\n \/* Try to restart request in case of failure *\/\n # Note that max_restarts defaults to 4\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if (obj.status == 503 && req.restarts < 4) {\n set obj.http.X-Restarts = req.restarts;\n return(restart);\n }\n\n \/* Set common headers for synthetic responses *\/\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n\n \/* HTTP Authentification client request *\/\n # Empty in simple configs. See http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* We're using error 200 for monitoring puposes *\/\n # Consider adding some analytics stuff to trace accesses\n if (obj.status == 200) {\n synthetic {\"\n <?xml version=\"1.0\" encoding=\"utf-8\"?>\n <!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n <html>\n <head>\n <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n <\/head>\n <body><h1>\"} + obj.status + \": \" + obj.response + {\"<\/h1><\/body>\n \"};\n return(deliver);\n }\n\n \/* Error page & refresh \/ redirections *\/\n # We have plenty of choices when we have to serve an error to the client, \n # from the default error page to javascript black magic or plain redirections.\n # Adding some external statistic javascript to track failures served to clients is strongly suggested.\n # We can't use external resources on synthetic content, everything must be inlined.\n # If we need to include images we can embed them in base64 encoding.\n # Here is the default error page for Varnish 3 (not so pretty)\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + obj.status + \" \" + obj.response + {\"<\/h1>\n <p>\"} + obj.response + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"};\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this point.\n return (deliver);\n}\n\n# vcl_init: Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n# sub vcl_init {\n# return (ok);\n# }\n\n# vcl_fini: Called when VCL is discarded only after all requests have exited the VCL. Typically used to clean up VMODs.\n# sub vcl_fini {\n# return (ok);\n# }\n","old_contents":"\/* Varnish 3 example config for Drupal 7 \/ Pressflow 6 & 7 *\/\n# Original source: https:\/\/github.com\/NITEMAN\/varnish-bites\/varnish4\/drupal-base.vcl\n# Copyright (c) 2015 Pedro Gonz\u00e1lez Serrano and individual contributors.\n# MIT License\n\n# Intended to be used both in simple production environments and with learning\/teaching purposes.\n# Loosely based on http:\/\/www.lullabot.com\/sites\/default\/files\/default_varnish3.vcl_.txt\n\n\/* Backend probes \/ healthchecks *\/\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#backend-probes\nprobe basic {\n \/* Only test that backend's IP serves content for '\/' *\/\n .url = \"\/\";\n .interval = 10s;\n .timeout = 2s;\n .window = 8;\n .threshold = 6;\n}\n\n\n\/* Backend definitions.*\/\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#backend-declarations\nbackend default {\n \/* Default backend on the same machine. WARNING: timeouts could be not big enought for certain POST request *\/\n .host = \"127.0.0.1\";\n .port = \"8080\";\n .connect_timeout = 60s;\n .first_byte_timeout = 60s;\n .between_bytes_timeout = 60s;\n .probe = basic;\n}\n\n\n\/* Directors. *\/\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#directors\n# Empty in simple configs\n\n\n\/* Access Control Lists *\/\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#acls\nacl purge_ban {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use '\"localhost\";' instead\n}\nacl allowed_monitors {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n}\n\n\n\/* Custom routines *\/\n# Empty in simple configs.\n# We can name subs with no restrictions but as a task can need several chunks of code in diferent states,\n# it's a good idea to identify what main sub will call each with a suffix.\n# \/* Example 301 client redirection removing \"www\" prefix from request *\/\n# sub perm_redirections_recv {\n# if ( req.http.host ~ \"^www.*$\" ) {\n# error 751 \"http:\/\/\" + regsub(req.http.host, \"^www\\.\", \"\") + req.url;\n# }\n# }\n# sub perm_redirections_error {\n# if (obj.status == 751) {\n# \/* Get new URL from the response *\/\n# set obj.http.Location = obj.response;\n# \/* Set HTTP 301 for permanent redirect *\/\n# set obj.status = 301;\n# return(deliver);\n# }\n# }\n\n\n\/* VCL logigc overrides *\/\n# Note that the built-in logic will be appended to our code if no return is performed before.\n# Built-in logic is included commented out right after our's for reference purposes in that cases.\n# See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleDefault\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#subroutines\n\n# vcl_recv: Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use.\nsub vcl_recv {\n \/* 0th: general bypass, general return & authorization checks *\/\n # Empty in simple configs.\n # Useful for debugging we can pipe or pass the request to default backend here to bypass completely Varnish.\n # return (pipe);\n # return (pass);\n # We can also return here a 200 Ok for network performance benchmarking.\n # error 200 \"Ok\";\n # Finally we can perform basic HTTP authentification here by example.\n # See http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* 1st: Check for Varnish special requests *\/ \n # Purge logic.\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/purging.html#http-purges\n # See https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if (req.request == \"PURGE\") {\n if (!client.ip ~ purge_ban) {\n error 405 \"Not allowed.\";\n }\n return (lookup);\n }\n # Ban logic. See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/purging.html#bans\n if (req.request == \"BAN\") {\n if (!client.ip ~ purge_ban) {\n error 405 \"Not allowed.\";\n }\n ban(\"req.http.host == \" + req.http.host +\n \"&& req.url == \" + req.url); \n error 200 \"Ban added\";\n }\n # Custom response implementation example in order to check that Varnish is working properly.\n # This is usefull for automatic monitoring with monit or when Varnish is behind another proxies like HAProxy.\n if (req.http.host == \"monitor.server.health\" && \n client.ip ~ allowed_monitors && \n (req.request == \"OPTIONS\" || req.request == \"GET\")) {\n error 200 \"Ok\";\n }\n\n \/* 2nd: Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_recv;\n # Here we can also enforce SSL when Varnish run behind some SSL termination point.\n\n \/* 3rd: Time for backend choice *\/\n # Empty in simple configs.\n\n \/* 4th: Set custom headers for backend like X-Forwarded-For (copied from built-in logic) *\/\n if (req.restarts == 0) {\n \/* See also vcl_pipe section *\/\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n \/* 5th: Bypass breakpoint 1 *\/\n # Useful for debugging we can now pipe or pass the request to backend with headers setted.\n # return (pipe);\n # return (pass);\n\n \/* 6th: Decide if we should deal with a request (mostly copied from built-in logic) *\/\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n\n \/* 7th: Access control for some URLs by ACL *\/\n # Empty in simple configs.\n # By example denial some URLs depending on client-ip, we'll need to define corresponding ACL 'internal'.\n # if (req.url ~ \"^\/(cron|install)\\.php$\" && !client.ip ~ internal) {\n # # Have Varnish throw the error directly.\n # error 403 \"Forbidden.\";\n # # Use a custom error page that you've defined in Drupal at the path \"404\".\n # # set req.url = \"\/403\";\n # }\n\n \/* 8th: Custom exceptions *\/\n # Host exception example:\n # if (req.http.host == \"ejemplo.exception.com\") {\n # return (pass);\n # }\n # Drupal exceptions, edit if we want to cache some AJAX\/AHAH request.\n # Add here filters for never cache URLs such as Payment Gateway's callbacks\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/ooyala\/ping$\" ||\n req.url ~ \"^\/admin\/build\/features\" ||\n req.url ~ \"^\/info\/.*$\" ||\n req.url ~ \"^\/flag\/.*$\" ||\n req.url ~ \"^.*\/ajax\/.*$\" ||\n req.url ~ \"^.*\/ahah\/.*$\") {\n \/* Do not cache these paths *\/\n return (pass);\n }\n # Pipe these paths directly to backend for streaming.\n if (req.url ~ \"^\/admin\/content\/backup_migrate\/export\") {\n return (pipe);\n }\n if (req.url ~ \"^\/system\/files\") {\n return (pipe);\n }\n\n \/* 9th: Enable grace mode *\/\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/handling_misbehaving_servers.html#grace-mode\n if (! req.backend.healthy) {\n \/* Use a longer grace period if all backends are down *\/\n set req.grace = 1h;\n \/* Use anonymous, cached pages if all backends are down. *\/\n unset req.http.Cookie;\n # TO-DO: Add sick marker\n } else {\n \/* Allow the backend to serve up stale content if it is responding slowly. *\/\n set req.grace = 30s;\n }\n\n \/* 10th: Deal with compression and the Accept-Encoding header *\/\n # Althought Varnish 3 handles gziped content itself by default, just to be sure we want to \n # remove Accept-Encoding for some compressed formats.\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/phk\/gzip.html#what-does-http-gzip-support-do\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/varnishd.html?highlight=http_gzip_support\n # See (for older configs) https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleNormalizeAcceptEncoding\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|mp4|flv|zip|rar)$\") {\n \/* Already compressed formats, no sense trying to compress again *\/\n remove req.http.Accept-Encoding;\n }\n }\n\n \/* 11th: Another header manipulation *\/\n # Empty in simple configs.\n # We could add here a custom header grouping User-agent families.\n\n \/* 12th: Cookie removal *\/\n # Always cache the following static file types for all users. \n # Use with care if we control certain downloads depending on cookies. \n # Be carefull also if appending .htm[l] via Drupal's clean URLs.\n if (req.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|svg|pdf)(\\?[a-z0-9]+)?$\") {\n unset req.http.Cookie;\n }\n # Remove all cookies that backend doesn't need to know about.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRemovingSomeCookies\n if (req.http.Cookie) {\n \/* Warning: Not a pretty solution *\/\n \/* Prefix header containing cookies with ';' *\/\n set req.http.Cookie = \";\" + req.http.Cookie;\n \/* Remove any spaces after ';' in header containing cookies *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n \/* Prefix cookies we want to preserve with one space *\/\n \/* 'S{1,2}ESS[a-z0-9]+' is the regular expression matching a Drupal session cookie ({1,2} added for HTTPS support) *\/\n \/* 'NO_CACHE' is usually set after a POST request to make sure issuing user see the results of his post *\/\n \/* 'OATMEAL' & 'CHOCOLATECHIP' are special cookies used by Drupal's Bakery module to provide Single Sign On *\/\n \/* Keep in mind we should add here any cookie that should reach the backend such as splahs avoiding cookies *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \";(S{1,2}ESS[a-z0-9]+|NO_CACHE|OATMEAL|CHOCOLATECHIP)=\", \"; \\1=\");\n \/* Remove from the header any single Cookie not prefixed with a space until next ';' separator *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n \/* Remove any '; ' at the start or the end of the header *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n\n if (req.http.Cookie == \"\") {\n \/* If there are no remaining cookies, remove the cookie header. *\/\n unset req.http.Cookie;\n }\n }\n\n \/* 13th: Session cookie & special cookies bypass caching stage *\/\n # As we might want to cache some requests, hashed with its cookies, \n # we don't simply pass when some cookies remain present at this point.\n # Instead we look for request that must be passed due to the cookie header.\n if (req.http.Cookie ~ \"SESS\" ||\n req.http.Cookie ~ \"SSESS\" ||\n req.http.Cookie ~ \"NO_CACHE\" ||\n req.http.Cookie ~ \"OATMEAL\" ||\n req.http.Cookie ~ \"CHOCOLATECHIP\") {\n return (pass);\n }\n\n \/* 14th: Bypass breakpoint 2 *\/\n # Useful for debugging we can now pipe or pass the request to backend to bypass cache.\n # return (pipe);\n # return (pass);\n\n \/* 15th: Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning a lookup.\n return (lookup);\n}\n\n# vcl_pipe: Called upon entering pipe mode.\n# In this mode, the request is passed on to the backend, \n# and any further data from either client or backend is passed on unaltered until either end closes the connection.\nsub vcl_pipe {\n \/* Prevent connection re-using for piped requests *\/\n # Note that only the first request to the backend will have X-Forwarded-For set.\n # As we use X-Forwarded-For and want to have it set for all requests, \n # we have to make sure connection won't be reused after the request.\n # It is not set by default as it might break some broken web applications, like IIS with NTLM authentication.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExamplePipe\n # TO-DO: make sure this is compatible with websockets piping,\n # reference https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/websockets.html\n set bereq.http.connection = \"close\";\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this point.\n return (pipe);\n}\n\n# vcl_pass: Called upon entering pass mode. \n# In this mode, the request is passed on to the backend, and the backend's response is passed on to the client, \n# but is not entered into the cache.\n# Subsequent requests submitted over the same client connection are handled normally.\n# sub vcl_pass {\n# return (pass);\n# }\n\n# vcl_hash: You may call hash_data() on the data you would like to add to the hash.\n# Hash is used by Varnish to uniquely identify objects.\nsub vcl_hash {\n \/* Hash cookie data *\/\n # As requests with same URL and host can produce diferent results when issued with different cookies,\n # we need to store items hashed with the associated cookies. Note that cookies are already sanitized when we reach this point.\n if (req.http.Cookie) {\n \/* Include cookie in cache hash *\/\n hash_data(req.http.Cookie);\n }\n\n \/* Custom header hashing *\/\n # Empty in simple configs.\n # Example for caching differents object versions by device previously detected (when static content could also vary):\n # if (req.http.X-UA-Device) {\n # hash_data(req.http.X-UA-Device);\n # }\n # Example for caching diferent object versions by X-Forwarded-Proto, trying to be smart about what kind of request\n # could generate diffetent responses.\n # if (req.http.X-Forwarded-Proto &&\n # req.url !~ \"(?i)\\.(png|gif|jpeg|jpg|ico|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|svg|pdf)$\") {\n # hash_data(req.http.X-Forwarded-Proto);\n # }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (hash);\n# }\n\n# vcl_hit: Called after a cache lookup if the requested document was found in the cache.\nsub vcl_hit {\n \/* Check for Varnish special requests *\/ \n # Purge logic.\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/purging.html#http-purges\n # See https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged.\";\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hit {\n# return (deliver);\n# }\n\n# vcl_miss: Called after a cache lookup if the requested document was not found in the cache.\n# Its purpose is to decide whether or not to attempt to retrieve the document from the backend, and which backend to use.\nsub vcl_miss {\n \/* Check for Varnish special requests *\/ \n # Purge logic.\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/purging.html#http-purges\n # See https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged.\";\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_miss {\n# return (fetch);\n# }\n\n# vcl_fetch: Called after a document has been successfully retrieved from the backend.\nsub vcl_fetch {\n \/* Caching exceptions *\/\n # Varnish will cache objects with response codes: 200, 203, 300, 301, 302, 307, 404 & 410.\n # See https:\/\/www.varnish-software.com\/static\/book\/VCL_Basics.html#the-initial-value-of-beresp-ttl\n # Drupal's Imagecache module can return a 307 redirection to the requested url itself and, depending on Drupal's cache settings,\n # this could lead to a redirection loop being cached for a long time but also we want Varnish to shield a little the backend.\n # See http:\/\/drupal.org\/node\/1248010\n # See http:\/\/drupal.org\/node\/310656\n if (beresp.status == 307 &&\n \/* TO-DO: verify that this work better than 'req.url ~ \"imagecache\"' *\/\n beresp.http.Location == req.url &&\n beresp.ttl > 5s) {\n set beresp.ttl = 5s;\n set beresp.http.cache-control = \"max-age=5\";\n }\n\n \/* Enable grace mode. Related with our 9th stage on vcl_recv *\/\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/handling_misbehaving_servers.html#grace-mode\n set beresp.grace = 1h;\n\n \/* Enable saint mode. Related with our 9th stage on vcl_recv *\/\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/handling_misbehaving_servers.html#saint-mode\n if (beresp.status == 500) {\n set beresp.saintmode = 20s;\n # TO-DO: consider not restarting POST requests as seen on https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleSaintMode\n return(restart);\n }\n\n \/* Strip cookies from the following static file types for all users. Related with our 12th stage on vcl_recv *\/\n if (req.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|svg|pdf)(\\?[a-z0-9]+)?$\") {\n unset beresp.http.set-cookie;\n }\n\n \/* Gzip response *\/\n # Empty in simple configs\n # Use Varnish to Gzip respone, if suitable, before storing it on cache\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/phk\/gzip.html\n # if (! beresp.http.Content-Encoding &&\n # (beresp.http.content-type ~ \"text\" ||\n # beresp.http.content-type ~ \"application\/x-javascript\" ||\n # beresp.http.content-type ~ \"application\/javascript\" ||\n # beresp.http.content-type ~ \"application\/rss+xml\" ||\n # beresp.http.content-type ~ \"application\/xml\" ||\n # beresp.http.content-type ~ \"Application\/JSON\")\n # ) {\n # set beresp.do_gzip = true;\n # if ( beresp.http.Vary ) {\n # if ( ! beresp.http.Vary ~ \"Accept-Encoding\" ) {\n # set beresp.http.Vary = beresp.http.Vary + \",Accept-Encoding\";\n # }\n # } else {\n # set beresp.http.Vary = \"Accept-Encoding\";\n # }\n # }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # We can add the name of the backend that has processed the request:\n # set beresp.http.X-Backend = beresp.backend.name;\n # We can use a header to tell if the object was gziped by Varnish\n # if (beresp.do_gzip) {\n # set beresp.http.X-Varnish-Gzipped = \"yes\";\n # } else {\n # set beresp.http.X-Varnish-Gizipped = \"no\";\n # }\n # We can also add headers informing whether the object is cacheable or not and why.\n # https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Varnish3.0\n if (beresp.ttl <= 0s) {\n \/* Varnish determined the object was not cacheable *\/\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n } elsif (req.http.Cookie ~ \"(SESS|SSESS|NO_CACHE|OATMEAL|CHOCOLATECHIP)\") {\n \/* We don't wish to cache content for logged in users or with certain cookies. Related with our 9th stage on vcl_recv *\/\n set beresp.http.X-Cacheable = \"NO:Cookies\";\n # return(hit_for_pass);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n \/* We are respecting the Cache-Control=private header from the backend *\/\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n # return(hit_for_pass);\n } else {\n \/* Varnish determined the object was cacheable *\/\n set beresp.http.X-Cacheable = \"YES\";\n }\n\n \/* Further header manipulation *\/\n # Empty in simple configs.\n # We can also unset some headers to prevent information disclosure and save some cache space\n # unset beresp.http.Server;\n # unset beresp.http.X-Powered-By;\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_fetch {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Vary == \"*\") {\n# \/*\n# * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# *\/\n# set beresp.ttl = 120 s;\n# return (hit_for_pass);\n# }\n# return (deliver);\n# }\n\n# vcl_deliver: Called before an object is delivered to the client\nsub vcl_deliver {\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # Add whether the object is a cache hit or miss and the number of hits for the object.\n # https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Addingaheaderindicatinghitmiss\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n set resp.http.X-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Cache = \"MISS\";\n \/* Show the results of cookie sanitization *\/\n set resp.http.X-Cookie = req.http.Cookie;\n }\n # TO-DO: Add sick marker\n # Restart count\n if ( req.restarts > 0) {\n set resp.http.X-Restarts = req.restarts;\n }\n # Add the Varnish server hostname\n set resp.http.X-Varnish-Server = server.hostname;\n # If we have setted a custom header with device family detected we can show it:\n # if (req.http.X-UA-Device) {\n # set resp.http.X-UA-Device = req.http.X-UA-Device;\n # }\n # If we have recived a custom header with the protocol in the request we can show it:\n # if (req.http.X-Forwarded-Proto) {\n # set resp.http.X-Forwarded-Proto = req.http.X-Forwarded-Proto;\n # }\n\n \/* Vary header manipulation *\/\n # Empty in simple configs.\n # By example, if we are storing & serving diferent objects depending on User-Agent header we must set the correct Vary header:\n # if (resp.http.Vary) {\n # set resp.http.Vary = resp.http.Vary + \",User-Agent\";\n # } else {\n # set resp.http.Vary = \"User-Agent\";\n # }\n\n \/* Fake headers *\/\n # Empty in simple configs\n # We can fake server headers here, by example:\n # set resp.http.Server = \"Deep thought\";\n # set resp.http.X-Powered-By = \"BOFH\";\n # Or have some fun with headers:\n # See http:\/\/www.nextthing.org\/archives\/2005\/08\/07\/fun-with-http-headers\n # See http:\/\/royal.pingdom.com\/2012\/08\/15\/fun-and-unusual-http-response-headers\/\n # set resp.http.X-Thank-You = \"for bothering to look at my HTTP headers\";\n # set resp.http.X-Answer = \"42\";\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_deliver {\n# return (deliver);\n# }\n\n# vcl_error: Called when we hit an error, either explicitly or implicitly due to backend or internal errors.\nsub vcl_error {\n \/* Avoid DOS vulnerability CVE-2013-4484 *\/\n # See https:\/\/www.varnish-cache.org\/lists\/pipermail\/varnish-announce\/2013-October\/000686.html\n if (obj.status == 400 || obj.status == 413) {\n return(deliver);\n }\n\n \/* Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_error;\n\n \/* Try to restart request in case of failure *\/\n # Note that max_restarts defaults to 4\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if (obj.status == 503 && req.restarts < 4) {\n set obj.http.X-Restarts = req.restarts;\n return(restart);\n }\n\n \/* Set common headers for synthetic responses *\/\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n\n \/* HTTP Authentification client request *\/\n # Empty in simple configs. See http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* We're using error 200 for monitoring puposes *\/\n # Consider adding some analytics stuff to trace accesses\n if (obj.status == 200) {\n synthetic {\"\n <?xml version=\"1.0\" encoding=\"utf-8\"?>\n <!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n <html>\n <head>\n <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n <\/head>\n <body><h1>\"} + obj.status + \": \" + obj.response + {\"<\/h1><\/body>\n \"};\n return(deliver);\n }\n\n \/* Error page & refresh \/ redirections *\/\n # We have plenty of choices when we have to serve an error to the client, \n # from the default error page to javascript black magic or plain redirections.\n # Adding some external statistic javascript to track failures served to clients is strongly suggested.\n # We can't use external resources on synthetic content, everything must be inlined.\n # If we need to include images we can embed them in base64 encoding.\n # Here is the default error page for Varnish 3 (not so pretty)\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + obj.status + \" \" + obj.response + {\"<\/h1>\n <p>\"} + obj.response + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"};\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this point.\n return (deliver);\n}\n\n# vcl_init: Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n# sub vcl_init {\n# return (ok);\n# }\n\n# vcl_fini: Called when VCL is discarded only after all requests have exited the VCL. Typically used to clean up VMODs.\n# sub vcl_fini {\n# return (ok);\n# }\n","returncode":0,"stderr":"","license":"unknown","lang":"VCL"} {"commit":"e27ccbc388c41626405957facbf62024de6ba01c","subject":"Simplify some of the beresp status matching","message":"Simplify some of the beresp status matching\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets\/fetch.vcl","new_file":"etc\/vcl_snippets\/fetch.vcl","new_contents":" \/* handle 5XX (or any other unwanted status code) *\/\n if (beresp.status >= 500 && beresp.status < 600) {\n\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n \/* deliver stale if the object is available *\/\n if (stale.exists) {\n return(deliver_stale);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n \/* else go to vcl_error to deliver a synthetic *\/\n error 503;\n }\n\n # Remove Set-Cookies from responses for static content\n # to match the cookie removal in recv.\n if (req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's since those can be temporary during the site build\/index\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n }\n\n }\n\n if (req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Content-Type ~ \"text\/(html|xml)\") {\n # enable ESI feature for Magento response by default\n esi;\n if (!beresp.http.Vary ~ \"X-Magento-Vary,Https\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \",X-Magento-Vary,Https\";\n } else {\n set beresp.http.Vary = \"X-Magento-Vary,Https\";\n }\n }\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content\n if (http_status_matches(beresp.status, \"200,404\") && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url.ext ~ \"(?i)(css|js|html|eot|ico|otf|ttf|json)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # cache only successfully responses and 404s\n if ( !http_status_matches(beresp.status, \"200,301,404\")) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\")) {\n unset beresp.http.set-cookie;\n if (req.url !~ \"^\/(pub\/)?(media|static)\/.*\") {\n set beresp.grace = 86400m;\n }\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type\n if (beresp.http.Content-Type ~ \"image\") {\n set beresp.http.Surrogate-Key = \"image\";\n } elsif (beresp.http.Content-Type ~ \"script\") {\n set beresp.http.Surrogate-Key = \"script\";\n } elsif (beresp.http.Content-Type ~ \"css\") {\n set beresp.http.Surrogate-Key = \"css\";\n }\n return (deliver);\n }\n","old_contents":" \/* handle 5XX (or any other unwanted status code) *\/\n if (beresp.status >= 500 && beresp.status < 600) {\n\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n \/* deliver stale if the object is available *\/\n if (stale.exists) {\n return(deliver_stale);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n \/* else go to vcl_error to deliver a synthetic *\/\n error 503;\n }\n\n # Remove Set-Cookies from responses for static content\n # to match the cookie removal in recv.\n if (req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's since those can be temporary during the site build\/index\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n }\n\n }\n\n if (req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Content-Type ~ \"text\/(html|xml)\") {\n # enable ESI feature for Magento response by default\n esi;\n if (!beresp.http.Vary ~ \"X-Magento-Vary,Https\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \",X-Magento-Vary,Https\";\n } else {\n set beresp.http.Vary = \"X-Magento-Vary,Https\";\n }\n }\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content\n if ((beresp.status == 200 || beresp.status == 404) && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url ~ \"\\.(css|js|html|eot|ico|otf|ttf|json)($|\\?)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # cache only successfully responses and 404s\n if (beresp.status != 200 && beresp.status != 301 && beresp.status != 404) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\")) {\n unset beresp.http.set-cookie;\n if (req.url !~ \"^\/(pub\/)?(media|static)\/.*\") {\n set beresp.grace = 86400m;\n }\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type\n if (beresp.http.Content-Type ~ \"image\") {\n set beresp.http.Surrogate-Key = \"image\";\n } elsif (beresp.http.Content-Type ~ \"script\") {\n set beresp.http.Surrogate-Key = \"script\";\n } elsif (beresp.http.Content-Type ~ \"css\") {\n set beresp.http.Surrogate-Key = \"css\";\n }\n return (deliver);\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"9b6eb3ad93ef924f7724df66351a91bcedf49baa","subject":"Add special-case redirects for old URL scheme","message":"Add special-case redirects for old URL scheme\n","repos":"adzerk-oss\/docker-s3-cache,adzerk-oss\/docker-s3-cache","old_file":"default.vcl","new_file":"default.vcl","new_contents":"# This is a VCL configuration file for varnish. See the vcl(7)\n# man page for details on VCL syntax and semantics.\n#\nbackend default {\n .host = \"${VARNISH_BACKEND_IP}\";\n .port = \"${VARNISH_BACKEND_PORT}\";\n}\n\nsub vcl_recv {\n set req.http.host = \"${VARNISH_BACKEND_HOST}\";\n\n if (req.url ~ \"^\/ad-server-privacy\/*$\") {\n error 750 \"\/privacy\/ad-server\/\";\n }\n if (req.url ~ \"^\/customer-privacy\/*$\") {\n error 750 \"\/privacy\/customers\/\";\n }\n if (req.url ~ \"^\/sales\/*$\") {\n error 750 \"\/contact\/\";\n }\n if (req.url ~ \"^\/ad-server-jobs\/*$\") {\n error 750 \"\/about\/\";\n }\n if (req.url ~ \"^\/features\/*$\") {\n error 750 \"\/solutions\/\";\n }\n if (req.url ~ \"^\/ad-server-resources\/*$\") {\n error 750 \"\/\";\n }\n if (req.url ~ \"^\/support\/*$\") {\n error 750 \"\/help\/\";\n }\n if (req.url ~ \"^\/customers\/ad-server-for-publishers\/*$\") {\n error 750 \"\/solutions\/\";\n }\n if (req.url ~ \"^\/ad-serving-resource-center\/*$\") {\n error 750 \"\/\";\n }\n if (req.url ~ \"^\/customers\/ad-server-developer-api\/*$\") {\n error 750 \"\/solutions\/\";\n }\n if (req.url ~ \"^\/blog\/2014\/10\/using-advertisting-to-monetize-a-social-media-community\/*$\") {\n error 750 \"\/blog\/2014\/10\/using-advertising-to-monetize-a-social-media-community\/\";\n }\n if (req.url ~ \"^\/news-and-announcements\/reddit-is-using-adzerk\/*$\") {\n error 750 \"\/blog\/2013\/03\/reddit-is-using-adzerk\/\";\n }\n if (req.url ~ \"^\/job-openings\/*$\") {\n error 750 \"\/about\/\";\n }\n if (req.url ~ \"^\/for-publishers\/*$\") {\n error 750 \"\/solutions\/\";\n }\n if (req.url ~ \"^\/product-blog\/the-fastest-ad-code-in-the-world\/\/*$\") {\n error 750 \"\/blog\/2012\/06\/the-fastest-ad-code-in-the-world\/\";\n }\n if (req.url ~ \"^\/our-team\/*$\") {\n error 750 \"\/about\/\";\n }\n if (req.url ~ \"^\/product-tour\/*$\") {\n error 750 \"\/learn\/\";\n }\n}\n\nsub vcl_error {\n if (obj.status == 750) {\n set obj.http.Location = obj.response;\n set obj.status = 301;\n return(deliver);\n }\n}\n\nsub vcl_fetch {\n if (beresp.status == 302) {\n set beresp.status = 301;\n set beresp.response = \"Moved Permanently\";\n }\n}\n","old_contents":"# This is a VCL configuration file for varnish. See the vcl(7)\n# man page for details on VCL syntax and semantics.\n#\nbackend default {\n .host = \"${VARNISH_BACKEND_IP}\";\n .port = \"${VARNISH_BACKEND_PORT}\";\n}\n\nsub vcl_recv {\n set req.http.host = \"${VARNISH_BACKEND_HOST}\";\n}\n\nsub vcl_fetch {\n if (beresp.status == 302) {\n set beresp.status = 301;\n set beresp.response = \"Moved Permanently\";\n }\n}\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"4c2e0f5334f6d6df96e956280c8b192a59a25518","subject":"Restarting functionality may clash with IO and is typically turned off on IO enabled services. This commit makes the VCL use the built-in restart functionality.","message":"Restarting functionality may clash with IO and is typically turned off\non IO enabled services. This commit makes the VCL use the built-in restart\nfunctionality.\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets\/fetch.vcl","new_file":"etc\/vcl_snippets\/fetch.vcl","new_contents":" \/* handle 5XX (or any other unwanted status code) *\/\n if (beresp.status >= 500 && beresp.status < 600) {\n\n \/* deliver stale if the object is available *\/\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n # Remove Set-Cookies from responses for static content to match the cookie removal in recv.\n if (req.http.x-long-cache || req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's since those can be temporary during the site build\/index\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n set beresp.http.Cache-Control = \"max-age=0\";\n } else if (req.http.x-long-cache) {\n # Force caching for signed cached assets.\n set beresp.ttl = 31536000s;\n # Add immutable as it avoids IMS and INM revalidations\n set beresp.http.Cache-Control = \"max-age=31536000, immutable\";\n }\n }\n\n # Fix Vary Header in some cases. In 99.9% of cases Varying on User-Agent is counterproductive\n # https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleFixupVary\n if (beresp.http.Vary ~ \"User-Agent\") {\n unset beresp.http.Vary:User-Agent;\n if (beresp.http.Vary == \"\") {\n unset beresp.http.Vary;\n }\n }\n\n # All the Magento responses should emit X-Esi headers\n if (beresp.http.x-esi) {\n # enable ESI feature for Magento response by default\n esi;\n } else {\n # enable gzip for all static content except\n if ( http_status_matches(beresp.status, \"200,404\") && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|text\\\/html|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url.ext ~ \"(?i)(css|js|html|eot|ico|otf|ttf|json)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n set beresp.http.Vary:Accept-Encoding = \"\";\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # Add Varying on X-Magento-Vary\n if (beresp.http.Content-Type ~ \"text\/(html|xml)\" || req.http.graphql) {\n set beresp.http.Vary:X-Magento-Vary = \"\";\n set beresp.http.Vary:Https = \"\";\n }\n\n # Just in case the Request Setting for x-pass is missing\n if (req.http.x-pass) {\n return (pass);\n }\n\n if (beresp.http.Cache-Control ~ \"private|no-cache|no-store\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # Never cache 302s\n if (beresp.status == 302) {\n return (pass);\n }\n\n if (beresp.http.x-amz-request-id) {\n # If assets are coming from Amazon they may have no Cache-Control headers which may make them uncacheable\n } else if (!beresp.http.Expires && !beresp.http.Surrogate-Control ~ \"max-age\" && !beresp.http.Cache-Control ~ \"(s-maxage|max-age)\") {\n # Varnish sets default TTL if none of the headers above are present. If not set we want to make sure we don't cache it\n set beresp.ttl = 0s;\n set beresp.cacheable = false;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\") && !req.http.x-pass ) {\n unset beresp.http.set-cookie;\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type if they are image\/script or CSS\n if (beresp.http.Content-Type ~ \"(image|script|css)\") {\n set beresp.http.Surrogate-Key = re.group.1;\n }\n }\n","old_contents":" \/* handle 5XX (or any other unwanted status code) *\/\n if (beresp.status >= 500 && beresp.status < 600) {\n\n \/* deliver stale if the object is available *\/\n if (stale.exists) {\n return(deliver_stale);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n }\n\n # Remove Set-Cookies from responses for static content to match the cookie removal in recv.\n if (req.http.x-long-cache || req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's since those can be temporary during the site build\/index\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n set beresp.http.Cache-Control = \"max-age=0\";\n } else if (req.http.x-long-cache) {\n # Force caching for signed cached assets.\n set beresp.ttl = 31536000s;\n # Add immutable as it avoids IMS and INM revalidations\n set beresp.http.Cache-Control = \"max-age=31536000, immutable\";\n }\n }\n\n # Fix Vary Header in some cases. In 99.9% of cases Varying on User-Agent is counterproductive\n # https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleFixupVary\n if (beresp.http.Vary ~ \"User-Agent\") {\n unset beresp.http.Vary:User-Agent;\n if (beresp.http.Vary == \"\") {\n unset beresp.http.Vary;\n }\n }\n\n # All the Magento responses should emit X-Esi headers\n if (beresp.http.x-esi) {\n # enable ESI feature for Magento response by default\n esi;\n } else {\n # enable gzip for all static content except\n if ( http_status_matches(beresp.status, \"200,404\") && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|text\\\/html|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url.ext ~ \"(?i)(css|js|html|eot|ico|otf|ttf|json)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n set beresp.http.Vary:Accept-Encoding = \"\";\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # Add Varying on X-Magento-Vary\n if (beresp.http.Content-Type ~ \"text\/(html|xml)\" || req.http.graphql) {\n set beresp.http.Vary:X-Magento-Vary = \"\";\n set beresp.http.Vary:Https = \"\";\n }\n\n # Just in case the Request Setting for x-pass is missing\n if (req.http.x-pass) {\n return (pass);\n }\n\n if (beresp.http.Cache-Control ~ \"private|no-cache|no-store\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # Never cache 302s\n if (beresp.status == 302) {\n return (pass);\n }\n\n if (beresp.http.x-amz-request-id) {\n # If assets are coming from Amazon they may have no Cache-Control headers which may make them uncacheable\n } else if (!beresp.http.Expires && !beresp.http.Surrogate-Control ~ \"max-age\" && !beresp.http.Cache-Control ~ \"(s-maxage|max-age)\") {\n # Varnish sets default TTL if none of the headers above are present. If not set we want to make sure we don't cache it\n set beresp.ttl = 0s;\n set beresp.cacheable = false;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\") && !req.http.x-pass ) {\n unset beresp.http.set-cookie;\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type if they are image\/script or CSS\n if (beresp.http.Content-Type ~ \"(image|script|css)\") {\n set beresp.http.Surrogate-Key = re.group.1;\n }\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"54e65b51051e3905644dc571309687770fab02b0","subject":"Fix unset req.http.graphql","message":"Fix unset req.http.graphql\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets\/hash.vcl","new_file":"etc\/vcl_snippets\/hash.vcl","new_contents":" # Fastly should cache on X-Magento-Cache-Id if available, which has a bunch of variations so it should be part of the key and not a Vary factor\n if (req.http.graphql && req.http.X-Magento-Cache-Id) {\n set req.hash += req.http.X-Magento-Cache-Id;\n }\n return(hash);\n","old_contents":" unset req.http.graphql;\n # Fastly should cache on X-Magento-Cache-Id if available, which has a bunch of variations so it should be part of the key and not a Vary factor\n if (req.http.graphql && req.http.X-Magento-Cache-Id) {\n set req.hash += req.http.X-Magento-Cache-Id;\n }\n return(hash);\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"d7ba003bd82c913560cb61f88d9a3b6a7a17adc2","subject":"Minor cleanups to VCL, added import for health checks, fixed quotes.","message":"Minor cleanups to VCL, added import for health checks, fixed quotes.\n","repos":"colstrom\/ansible-varnish,noqcks\/ansible-varnish,kkwoker\/ansible-varnish,gotofbi\/ansible-varnish,killerwails\/ansible-varnish,gotofbi\/ansible-varnish,telusdigital\/ansible-varnish,killerwails\/ansible-varnish","old_file":"templates\/etc\/varnish\/default.vcl","new_file":"templates\/etc\/varnish\/default.vcl","new_contents":"vcl 4.0;\n\nimport directors;\nimport std;\n\n{% for backend in varnish_backend_hosts %}\nbackend application_{{ loop.index }} {\n .host = \"{{ backend }}\";\n .port = \"{{ varnish_backend_port }}\";\n{% if varnish_health_checks_enabled %}\n .probe = {\n .url = \"{{ varnish_health_check_url }}\";\n .interval = {{ varnish_health_check_interval }};\n .timeout = {{ varnish_health_check_timeout }};\n .window = {{ varnish_health_check_window }};\n .threshold = {{ varnish_health_check_threshold }};\n }\n{% endif %}\n}\n{% endfor %}\n\nsub vcl_init {\n new application = directors.round_robin();\n{% for backend in varnish_backend_hosts %}\n application.add_backend(application_{{ loop.index }});\n{% endfor %}\n}\n\nsub vcl_recv {\n set req.backend_hint = application.backend();\n}\n\nsub vcl_hit {\n if (obj.ttl > 0s) {\n return (deliver);\n }\n{% if varnish_health_checks_enabled %}\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (fetch);\n }\n{% else %}\n if (obj.ttl + obj.grace > 0s) {\n return (deliver);\n }\n\n return (fetch);\n{% endif %}\n}\n\n{% if varnish_grace_enabled %}\nsub vcl_backend_response {\n set beresp.grace = {{ varnish_grace_period }};\n}\n{% endif %}","old_contents":"vcl 4.0;\n\nimport directors;\n\n{% for backend in varnish_backend_hosts %}\n backend application_{{ loop.index }} {\n .host = \"{{ backend }}\";\n .port = \"{{ varnish_backend_port }}\";\n{% if varnish_health_checks_enabled %}\n .probe = {\n .url = '{{ varnish_health_check_url }}';\n .interval = {{ varnish_health_check_interval }};\n .timeout = {{ varnish_health_check_timeout }};\n .window = {{ varnish_health_check_window }};\n .threshold = {{ varnish_health_check_threshold }};\n }\n{% endif %}\n }\n{% endfor %}\n\nsub vcl_init {\n new application = directors.round_robin();\n{% for backend in varnish_backend_hosts %}\n application.add_backend(application_{{ loop.index }});\n{% endfor %}\n}\nsub vcl_recv {\n set req.backend_hint = application.backend();\n}\n\nsub vcl_hit {\n if (obj.ttl > 0s) {\n return (deliver);\n }\n{% if varnish_health_checks_enabled %}\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (fetch);\n }\n{% else %}\n if (obj.ttl + obj.grace > 0s) {\n return (deliver);\n }\n\n return (fetch);\n{% endif %}\n}\n\n{% if varnish_grace_enabled %}\nsub vcl_backend_response {\n set beresp.grace = {{ varnish_grace_period }};\n}\n{% endif %}","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"145ddcbc1d5aacc74ff98206f6ebb49aad7f3ba3","subject":"update varnish vcl","message":"update varnish vcl\n","repos":"jclgoodwin\/bustimes.org.uk,jclgoodwin\/bustimes.org.uk,jclgoodwin\/bustimes.org.uk,jclgoodwin\/bustimes.org.uk","old_file":"config\/varnish\/default.vcl","new_file":"config\/varnish\/default.vcl","new_contents":"# Marker to tell the VCL compiler that this VCL has been adapted to the\n# new 4.0 format.\nvcl 4.0;\n\n# Default backend definition. Set this to point to your content server.\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\n\nacl purge {\n \"localhost\";\n \"10.131.0.0\"\/16;\n}\n\nsub vcl_recv {\n # Happens before we check if we have this in cache already.\n #\n # Typically you clean up the request here, removing cookies you don't need,\n # rewriting the request, etc.\n\n if (req.method == \"BAN\") {\n if (!client.ip ~ purge) {\n return(synth(405,\"Not allowed.\"));\n }\n ban(\"obj.http.url ~ ^\" + req.url);\n return (synth(200, \"Ban added\"));\n }\n\n if (req.url ~ \"^\/(admin\/|accounts\/|siri|contact|awin-transaction)\" || req.url ~ \"\/edit\") {\n return (pass);\n }\n\n # special features on fleet lists for logged in users\n if (req.http.Cookie ~ \"sessionid\" && req.url ~ \"operator\" && req.url ~ \"vehicles\") {\n return (pass);\n }\n\n unset req.http.Cookie;\n}\n\nsub vcl_backend_response {\n # Happens after we have read the response headers from the backend.\n #\n # Here you clean the response headers, removing silly Set-Cookie headers\n # and other mistakes your backend does.\n\n if (bereq.url !~ \"^\/(admin\/|accounts\/|contact)\" && bereq.url !~ \"\/edit\") {\n unset beresp.http.set-cookie;\n\n set beresp.http.url = bereq.url;\n\n if (beresp.status >= 200 && beresp.status < 400) {\n if (bereq.url ~ \"^\/stops\/\") {\n set beresp.ttl = 1m;\n } elif (bereq.url ~ \"\/(journeys|locations)\") {\n set beresp.ttl = 10s;\n } elif (bereq.url ~ \"\/vehicles\") {\n set beresp.ttl = 5m;\n } else {\n set beresp.ttl = 30m;\n set beresp.grace = 10m;\n }\n }\n }\n}\n","old_contents":"# Marker to tell the VCL compiler that this VCL has been adapted to the\n# new 4.0 format.\nvcl 4.0;\n\n# Default backend definition. Set this to point to your content server.\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\n\nsub vcl_recv {\n # Happens before we check if we have this in cache already.\n #\n # Typically you clean up the request here, removing cookies you don't need,\n # rewriting the request, etc.\n\n if (req.url ~ \"^\/(admin\/|contact|awin-transaction)\" || req.url ~ \"\/edit\") {\n return (pass);\n }\n\n # special features on fleet lists for logged in users\n if (req.http.Cookie ~ \"sessionid\" && req.url ~ \"operator\" && req.url ~ \"vehicles\") {\n return (pass);\n }\n\n unset req.http.Cookie;\n}\n\nsub vcl_backend_response {\n # Happens after we have read the response headers from the backend.\n #\n # Here you clean the response headers, removing silly Set-Cookie headers\n # and other mistakes your backend does.\n\n if (bereq.url !~ \"^\/(admin\/|contact)\" && bereq.url !~ \"\/edit\") {\n unset beresp.http.set-cookie;\n\n if (beresp.status >= 200 && beresp.status < 400) {\n if (bereq.url ~ \"^\/stops\/\") {\n set beresp.ttl = 50s;\n } elif (bereq.url ~ \"\/(vehicles|journeys\/)\") {\n set beresp.ttl = 6s;\n } else {\n set beresp.ttl = 1h;\n }\n }\n }\n}\n","returncode":0,"stderr":"","license":"mpl-2.0","lang":"VCL"} {"commit":"17b7add9f6b829d4e8dce320c515375069025282","subject":"fix some issues around form detection and submission","message":"fix some issues around form detection and submission\n","repos":"xini\/silverstripe-section-io","old_file":"default.vcl","new_file":"default.vcl","new_contents":"# See the VCL chapters in the Users Guide at https:\/\/www.varnish-cache.org\/docs\/\n# and http:\/\/varnish-cache.org\/trac\/wiki\/VCLExamples for more examples.\n\n# Marker to tell the VCL compiler that this VCL has been adapted to the\n# new 4.0 format.\nvcl 4.0;\n\nbackend default {\n\t.host = \"next-hop\";\n\t.port = \"80\";\n}\n\n# The following VMODs are available for use if required:\n#import geoip; # see https:\/\/github.com\/varnish\/libvmod-geoip\n#import header; # see https:\/\/github.com\/varnish\/libvmod-header\n\nsub vcl_recv {\n\t# Happens before we check if we have this in cache already.\n\t#\n\t# Typically you clean up the request here, removing cookies you don't need,\n\t# rewriting the request, etc.\n\t\n\t# https redirect\n\t# also uncomment vcl_synth at the bottom!\n#\tif (req.http.X-Forwarded-Proto !~ \"(?i)https\") {\n#\t\treturn (synth(750, \"\"));\n#\t}\n\t\n\t# clean up accept-encoding\n\tif (req.http.Accept-Encoding) {\n\t\tif (req.http.Accept-Encoding ~ \"gzip\") {\n\t\t\tset req.http.Accept-Encoding = \"gzip\";\n\t\t} else if (req.http.Accept-Encoding ~ \"deflate\") {\n\t\t\tset req.http.Accept-Encoding = \"deflate\";\n\t\t} else {\n\t\t\tunset req.http.Accept-Encoding;\n\t\t}\n\t}\t\n\t\n\t# remove cookies for static content based on \/assets\/.htaccess\n\tif (req.url ~ \".*\\.(?:js|css|bmp|png|gif|jpg|jpeg|ico|pcx|tif|tiff|au|mid|midi|mpa|mp3|ogg|m4a|ra|wma|wav|cda|avi|mpg|mpeg|asf|wmv|m4v|mov|mkv|mp4|ogv|webm|swf|flv|ram|rm|doc|docx|txt|rtf|xls|xlsx|pages|ppt|pptx|pps|csv|cab|arj|tar|zip|zipx|sit|sitx|gz|tgz|bz2|ace|arc|pkg|dmg|hqx|jar|pdf|woff|woff2|eot|ttf|otf|svg)(?=\\?|&|$)\") {\n\t\tunset req.http.Cookie;\n\t\treturn (hash);\n\t}\n\t\n\t# pass for admin and forms\n\tif (\n\t\t\n\t\t# Admin and dev URLs\n\t\t(req.url ~ \"^\/admin|Security|dev\/\") ||\n\n\t\t# Staging\/Previewing URLs while in \/admin\n\t\t(req.url ~ \"stage=\") ||\n\t\t\n\t\t# ss multistep forms\n\t\t(req.url ~ \"MultiFormSessionID=\") ||\n\t\t\n\t\t# check for login cookie\n\t\t(req.http.Cookie ~ \"sslogin=\")\n\n\t) {\n\t\treturn (pass);\n\t}\t\n\t\n\t# remove common cookies\n\tif (req.http.Cookie) {\n\t\n\t\t# remove silverstripe cookies\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|;\\s*)(cms-panel-collapsed-cms-menu)=[^;]*\", \"\");\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|;\\s*)(cms-menu-sticky)=[^;]*\", \"\");\n\t\t\n\t\t# Remove any Google Analytics based cookies \n\t\t# (removes everything starting with an underscore, which also includes AddThis, DoubleClick and others)\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|;\\s*)(_[_a-zA-Z0-9\\-]+)=[^;]*\", \"\");\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|;\\s*)(utm[a-z]+)=[^;]*\", \"\");\n\t\t\n\t\t# Remove the Avanser phone tracking cookies\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|;\\s*)(AUA[0-9]+)=[^;]*\", \"\");\n\t\t\n\t\t# Remove the StatCounter cookies\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|;\\s*)(sc_is_visitor_unique)=[^;]*\", \"\");\n\n\t\t# Remove a \";\" prefix, if present.\n\t\tset req.http.Cookie = regsub(req.http.Cookie, \"^;\\s*\", \"\");\n\n\t\t# remove empty cookie\n\t\tif (req.http.Cookie == \"\") {\n\t\t\tunset req.http.cookie;\n\t\t}\n\t}\n\t\n\t# remove adwords gclid parameter\n\tset req.url = regsuball(req.url,\"\\?gclid=[^&]+$\",\"\"); # strips when QS = \"?gclid=AAA\"\n\tset req.url = regsuball(req.url,\"\\?gclid=[^&]+&\",\"?\"); # strips when QS = \"?gclid=AAA&foo=bar\"\n\tset req.url = regsuball(req.url,\"&gclid=[^&]+\",\"\"); # strips when QS = \"?foo=bar&gclid=AAA\" or QS = \"?foo=bar&gclid=AAA&bar=baz\"\n\n\t# Strip hash, server doesn't need it.\n\tif (req.url ~ \"\\#\") {\n\t\tset req.url = regsub(req.url, \"\\#.*$\", \"\");\n\t}\n\t\n\t# Strip a trailing ? if it exists\n\tif (req.url ~ \"\\?$\") {\n\t\tset req.url = regsub(req.url, \"\\?$\", \"\");\n\t}\n}\n\nsub vcl_backend_fetch {\n\t# Called before sending the backend request.\n\t#\n\t# Typically you alter the request for the backend here. Overriding to the\n\t# required hostname, upstream Proto matching, etc\n\t\n}\n\nsub vcl_backend_response {\n\t# Happens after we have read the response headers from the backend.\n\t#\n\t# Here you clean the response headers, removing silly Set-Cookie headers\n\t# and other mistakes your backend does.\n\t\n\t# cache static content\n\t# set cache control header for css & js\n\tif (bereq.url ~ \".*\\.(?:css|js)(?=\\?|&|$)\") { \n\t\tunset beresp.http.set-cookie;\n\t\tset beresp.ttl = 604800s; # The number of seconds to cache inside Varnish: 1 week\n\t\tset beresp.http.Cache-Control = \"public, max-age=604800\"; # The number of seconds to cache in browser: 1 week\n\t}\n\t# set cache control header for images, audio, video\n\tif (bereq.url ~ \".*\\.(?:bmp|png|gif|jpg|jpeg|ico|pcx|tif|tiff|au|mid|midi|mpa|mp3|ogg|m4a|ra|wma|wav|cda|avi|mpg|mpeg|asf|wmv|m4v|mov|mkv|mp4|ogv|webm|swf|flv|ram|rm)(?=\\?|&|$)\") {\n\t\tunset beresp.http.set-cookie;\n\t\tset beresp.ttl = 2592000s; # The number of seconds to cache inside Varnish: 1 month\n\t\tset beresp.http.Cache-Control = \"public, max-age=2592000\"; # The number of seconds to cache in browser: 1 month\n\t}\n\t# set cache control header for docs and archives\n\tif (bereq.url ~ \".*\\.(?:doc|docx|txt|rtf|xls|xlsx|pages|ppt|pptx|pps|csv|cab|arj|tar|zip|zipx|sit|sitx|gz|tgz|bz2|ace|arc|pkg|dmg|hqx|jar|pdf)(?=\\?|&|$)\") {\n\t\tunset beresp.http.set-cookie;\n\t\tset beresp.ttl = 2592000s; # The number of seconds to cache inside Varnish: 1 month\n\t\tset beresp.http.Cache-Control = \"public, max-age=2592000\"; # The number of seconds to cache in browser: 1 month\n\t}\n\t# set cache control header for fonts\n\tif (bereq.url ~ \".*\\.(?:woff|woff2|eot|ttf|otf|svg)(?=\\?|&|$)\") {\n\t\tunset beresp.http.set-cookie;\n\t\tset beresp.ttl = 2592000s; # The number of seconds to cache inside Varnish: 1 month\n\t\tset beresp.http.Cache-Control = \"public, max-age=2592000\"; # The number of seconds to cache in browser: 1 month\n\t}\n\t\n\t# normal pages \n if (beresp.http.Content-Type ~ \"^text\/html\"){\n\t\tif (\n\t\t\t(bereq.url ~ \"^\/(Security|admin|dev)\") ||\n\t\t\t(bereq.url ~ \"stage=\") ||\n\t\t\t(bereq.url ~ \"MultiFormSessionID=\") ||\n\t\t\t(bereq.http.Cookie ~ \"sslogin=\") ||\n\t\t\t(beresp.http.X-SS-Form) ||\n\t\t\t(beresp.http.Pragma ~ \"(?i)no-cache\") \n\t\t) {\n\t\t\t# set admin and form pages to uncacheable\n\t\t\tset beresp.uncacheable = true;\n\t\t\tset beresp.ttl = 120s;\n\t\t} else {\n\t\t\t# if just normal page, set cache control headers\n\t\t\tset beresp.ttl = 3600s;\n\t\t\tset beresp.http.Cache-Control = \"public, max-age=600\";\n\t\t\t# remove cookies\n\t\t\tunset beresp.http.set-cookie;\n\t\t}\n\t}\n\t\n\t# make sure svg files are compressed\n\tif (beresp.http.content-type ~ \"image\/svg\\+xml\") {\n set beresp.do_gzip = true;\n }\n\t\n\t# set grace period\n\tset beresp.grace = 6h;\n\t\n\t### DO NOT CHANGE ###\n\t# store url in cached object to use in ban()\n\tset beresp.http.x-url = bereq.url;\n\t\n\t# un-comment this to see in the X-Cookie-Debug header what cookies varnish still sees after cookie stripping in vcl_recv\n\t#set beresp.http.X-Cookie-Debug = \"Request cookie: \" + bereq.http.Cookie;\n\t\n}\n\nsub vcl_deliver {\n\t# Happens when we have all the pieces we need, and are about to send the\n\t# response to the client.\n\t#\n\t# You can do accounting or modifying the final object here.\n\t\n\t# remove session cookie for non-form pages (when someone visits a form page all subsequent pages woulnd't be cached otherwise)\n\tif (\n\t\t(resp.http.Content-Type ~ \"^text\/html\") &&\n\t\t(req.http.Cookie) &&\n\t\t!(req.url ~ \"^\/(Security|admin|dev)\") &&\n\t\t!(req.url ~ \"stage=\") &&\n\t\t!(req.url ~ \"MultiFormSessionID=\") &&\n\t\t!(req.method == \"POST\") &&\n\t\t!(req.http.Cookie ~ \"sslogin=\") &&\n\t\t!(resp.http.X-SS-Form)\n\t) {\n\t\tset resp.http.set-cookie = \"PHPSESSID=deleted; Expires=Thu, 01 Jan 1970 00:00:00 GMT; Path=\/; HttpOnly\";\n\t}\n\t\n\t# add cache response header\n\tif (obj.hits > 0) {\n\t\tset resp.http.X-Cache = \"HIT\";\n\t} else {\n\t\tset resp.http.X-Cache = \"MISS\";\n\t}\n\t\n\t# Remove some headers that give too much information about environment\n\tunset resp.http.X-Powered-By;\n\tunset resp.http.Server;\n\tunset resp.http.X-Varnish;\n\tunset resp.http.Via;\n\t\n\t### DO NOT CHANGE ###\n\t# remove saved url and protocol from object before delivery\n\tunset resp.http.x-url;\n\tunset resp.http.X-Forwarded-Proto;\n\t\n}\n\nsub vcl_hit {\n\t# deliver if ttl > 0, normal hit\n\tif (obj.ttl >= 0s) {\n\t\treturn (deliver);\n\t}\n\t# deliver if ttl = 0 but grace still on\n\tif (obj.ttl + obj.grace > 0s) {\n\t\treturn (deliver);\n\t}\n\t# fetch new content\n\treturn (fetch);\n}\n\n# include protocol in cache key to prevent endless redirects\nsub vcl_hash {\n\tif (req.http.X-Forwarded-Proto) {\n\t\thash_data(req.http.X-Forwarded-Proto);\n\t}\n}\n\n# domain and https redirects\n#sub vcl_synth {\n# if (resp.status == 750) {\n# set resp.status = 301;\n# set resp.http.Location = \"https:\/\/\" + req.http.host + req.url;\n# return(deliver);\n# }\n#}\n","old_contents":"# See the VCL chapters in the Users Guide at https:\/\/www.varnish-cache.org\/docs\/\n# and http:\/\/varnish-cache.org\/trac\/wiki\/VCLExamples for more examples.\n\n# Marker to tell the VCL compiler that this VCL has been adapted to the\n# new 4.0 format.\nvcl 4.0;\n\nbackend default {\n\t.host = \"next-hop\";\n\t.port = \"80\";\n}\n\n# The following VMODs are available for use if required:\n#import geoip; # see https:\/\/github.com\/varnish\/libvmod-geoip\n#import header; # see https:\/\/github.com\/varnish\/libvmod-header\n\nsub vcl_recv {\n\t# Happens before we check if we have this in cache already.\n\t#\n\t# Typically you clean up the request here, removing cookies you don't need,\n\t# rewriting the request, etc.\n\t\n\t# https redirect\n\t# also uncomment vcl_synth at the bottom!\n#\tif (req.http.X-Forwarded-Proto !~ \"(?i)https\") {\n#\t\treturn (synth(750, \"\"));\n#\t}\n\t\n\t# clean up accept-encoding\n\tif (req.http.Accept-Encoding) {\n\t\tif (req.http.Accept-Encoding ~ \"gzip\") {\n\t\t\tset req.http.Accept-Encoding = \"gzip\";\n\t\t} else if (req.http.Accept-Encoding ~ \"deflate\") {\n\t\t\tset req.http.Accept-Encoding = \"deflate\";\n\t\t} else {\n\t\t\tunset req.http.Accept-Encoding;\n\t\t}\n\t}\t\n\t\n\t# remove cookies for static content based on \/assets\/.htaccess\n\tif (req.url ~ \".*\\.(?:js|css|bmp|png|gif|jpg|jpeg|ico|pcx|tif|tiff|au|mid|midi|mpa|mp3|ogg|m4a|ra|wma|wav|cda|avi|mpg|mpeg|asf|wmv|m4v|mov|mkv|mp4|ogv|webm|swf|flv|ram|rm|doc|docx|txt|rtf|xls|xlsx|pages|ppt|pptx|pps|csv|cab|arj|tar|zip|zipx|sit|sitx|gz|tgz|bz2|ace|arc|pkg|dmg|hqx|jar|pdf|woff|woff2|eot|ttf|otf|svg)(?=\\?|&|$)\") {\n\t\tunset req.http.Cookie;\n\t\treturn (hash);\n\t}\n\t\n\t# remove cookies for admin and forms\n\tif (\n\t\t# Any HTTP POST request\n\t\t!(req.method == \"POST\") &&\n\t\t\n\t\t# forms contained on page\n\t\t!(req.http.X-SS-Form) &&\n\n\t\t# Admin and dev URLs\n\t\t!(req.url ~ \"^\/admin|Security|dev\/\") &&\n\n\t\t# Staging\/Previewing URLs while in \/admin\n\t\t!(req.url ~ \"stage=\") &&\n\t\t\n\t\t# ss multistep forms\n\t\t!(req.url ~ \"MultiFormSessionID=\") &&\n\t\t\n\t\t# check for login cookie\n\t\t!(req.http.Cookie ~ \"sslogin=\")\n\n\t) {\n\t\tunset req.http.Cookie;\n\t}\t\n\t\n\t# remove common tracking cookies\n\tif (req.http.Cookie) {\n\t\n\t\t# Remove any Google Analytics based cookies\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|(?<=; )) *__utm.=[^;]+;? *\", \"\\1\");\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|;\\s*)(_dc_gtm_[A-Z0-9\\-]+)=[^;]*\", \"\");\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|;\\s*)(_ga)=[^;]*\", \"\");\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|;\\s*)(_gat)=[^;]*\", \"\");\n\t\t\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|(?<=; )) *utmctr=[^;]+;? *\", \"\\1\");\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|(?<=; )) *utmcmd.=[^;]+;? *\", \"\\1\");\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|(?<=; )) *utmccn.=[^;]+;? *\", \"\\1\");\n\t\t\n\t\t# Remove DoubleClick offensive cookies\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|(?<=; )) *__gads.=[^;]+;? *\", \"\\1\");\n\t\t\n\t\t# Remove the Quant Capital cookies (added by some plugin, all __qca)\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|(?<=; )) *__qc.=[^;]+;? *\", \"\\1\");\n\t\t\n\t\t# Remove the AddThis cookies\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|(?<=; )) *__atuv.=[^;]+;? *\", \"\\1\");\n\n\t\t# Remove the Avanser phone tracking cookies\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|;\\s*)(AUA[0-9]+)=[^;]*\", \"\");\n\t\t\n\t\t# Remove the StatCounter cookies\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|;\\s*)(sc_is_visitor_unique)=[^;]*\", \"\");\n\n\t\t# remove empty cookie\n\t\tif (req.http.Cookie == \"\") {\n\t\t\tunset req.http.cookie;\n\t\t}\n\t}\n\t\n\t# remove adwords gclid parameter\n\tset req.url = regsuball(req.url,\"\\?gclid=[^&]+$\",\"\"); # strips when QS = \"?gclid=AAA\"\n\tset req.url = regsuball(req.url,\"\\?gclid=[^&]+&\",\"?\"); # strips when QS = \"?gclid=AAA&foo=bar\"\n\tset req.url = regsuball(req.url,\"&gclid=[^&]+\",\"\"); # strips when QS = \"?foo=bar&gclid=AAA\" or QS = \"?foo=bar&gclid=AAA&bar=baz\"\n\n\t# Strip hash, server doesn't need it.\n\tif (req.url ~ \"\\#\") {\n\t\tset req.url = regsub(req.url, \"\\#.*$\", \"\");\n\t}\n\t\n\t# Strip a trailing ? if it exists\n\tif (req.url ~ \"\\?$\") {\n\t\tset req.url = regsub(req.url, \"\\?$\", \"\");\n\t}\n}\n\nsub vcl_backend_fetch {\n\t# Called before sending the backend request.\n\t#\n\t# Typically you alter the request for the backend here. Overriding to the\n\t# required hostname, upstream Proto matching, etc\n\t\n}\n\nsub vcl_backend_response {\n\t# Happens after we have read the response headers from the backend.\n\t#\n\t# Here you clean the response headers, removing silly Set-Cookie headers\n\t# and other mistakes your backend does.\n\t\n\t# cache static content\n\t# set cache control header for css & js\n\tif (bereq.url ~ \".*\\.(?:css|js)(?=\\?|&|$)\") { \n\t\tunset beresp.http.set-cookie;\n\t\tset beresp.ttl = 604800s; # The number of seconds to cache inside Varnish: 1 week\n\t\tset beresp.http.Cache-Control = \"public, max-age=604800\"; # The number of seconds to cache in browser: 1 week\n\t}\n\t# set cache control header for images, audio, video\n\tif (bereq.url ~ \".*\\.(?:bmp|png|gif|jpg|jpeg|ico|pcx|tif|tiff|au|mid|midi|mpa|mp3|ogg|m4a|ra|wma|wav|cda|avi|mpg|mpeg|asf|wmv|m4v|mov|mkv|mp4|ogv|webm|swf|flv|ram|rm)(?=\\?|&|$)\") {\n\t\tunset beresp.http.set-cookie;\n\t\tset beresp.ttl = 2592000s; # The number of seconds to cache inside Varnish: 1 month\n\t\tset beresp.http.Cache-Control = \"public, max-age=2592000\"; # The number of seconds to cache in browser: 1 month\n\t}\n\t# set cache control header for docs and archives\n\tif (bereq.url ~ \".*\\.(?:doc|docx|txt|rtf|xls|xlsx|pages|ppt|pptx|pps|csv|cab|arj|tar|zip|zipx|sit|sitx|gz|tgz|bz2|ace|arc|pkg|dmg|hqx|jar|pdf)(?=\\?|&|$)\") {\n\t\tunset beresp.http.set-cookie;\n\t\tset beresp.ttl = 2592000s; # The number of seconds to cache inside Varnish: 1 month\n\t\tset beresp.http.Cache-Control = \"public, max-age=2592000\"; # The number of seconds to cache in browser: 1 month\n\t}\n\t# set cache control header for fonts\n\tif (bereq.url ~ \".*\\.(?:woff|woff2|eot|ttf|otf|svg)(?=\\?|&|$)\") {\n\t\tunset beresp.http.set-cookie;\n\t\tset beresp.ttl = 2592000s; # The number of seconds to cache inside Varnish: 1 month\n\t\tset beresp.http.Cache-Control = \"public, max-age=2592000\"; # The number of seconds to cache in browser: 1 month\n\t}\n\t\n\t# set cache control header for pages\n if (beresp.http.Content-Type ~ \"^text\/html\" && !(bereq.url ~ \"^\/(Security|admin|dev)\") && !(bereq.http.Cookie ~ \"sslogin=\") && !(beresp.http.Pragma ~ \"no-cache\") ) {\n\t\t set beresp.ttl = 3600s;\n\t\t set beresp.http.Cache-Control = \"public, max-age=600\";\n }\n\t\n\t# make sure svg files are compressed\n\tif (beresp.http.content-type ~ \"image\/svg\\+xml\") {\n set beresp.do_gzip = true;\n }\n\t\n\t# set grace period\n\tset beresp.grace = 6h;\n\t\n\t### DO NOT CHANGE ###\n\t# store url in cached object to use in ban()\n\tset beresp.http.x-url = bereq.url;\n\t\n}\n\nsub vcl_deliver {\n\t# Happens when we have all the pieces we need, and are about to send the\n\t# response to the client.\n\t#\n\t# You can do accounting or modifying the final object here.\n\t\n\t# add cache response header\n\tif (obj.hits > 0) {\n\t\tset resp.http.X-Cache = \"HIT\";\n\t} else {\n\t\tset resp.http.X-Cache = \"MISS\";\n\t}\n\t\n\t# Remove some headers that give too much information about environment\n\tunset resp.http.X-Powered-By;\n\tunset resp.http.Server;\n\tunset resp.http.X-Varnish;\n\tunset resp.http.Via;\n\t\n\t### DO NOT CHANGE ###\n\t# remove saved url and protocol from object before delivery\n\tunset resp.http.x-url;\n\tunset resp.http.X-Forwarded-Proto;\n\t\n}\n\nsub vcl_hit {\n\t# deliver if ttl > 0, normal hit\n\tif (obj.ttl >= 0s) {\n\t\treturn (deliver);\n\t}\n\t# deliver if ttl = 0 but grace still on\n\tif (obj.ttl + obj.grace > 0s) {\n\t\treturn (deliver);\n\t}\n\t# fetch new content\n\treturn (fetch);\n}\n\n# include protocol in cache key to prevent endless redirects\nsub vcl_hash {\n\tif (req.http.X-Forwarded-Proto) {\n\t\thash_data(req.http.X-Forwarded-Proto);\n\t}\n}\n\n# domain and https redirects\n#sub vcl_synth {\n# if (resp.status == 750) {\n# set resp.status = 301;\n# set resp.http.Location = \"https:\/\/\" + req.http.host + req.url;\n# return(deliver);\n# }\n#}\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"51fbb594776ee2f7401ee690dfac5ecb3b5cd2d6","subject":"remove trailing whitespace","message":"remove trailing whitespace\n","repos":"wikp\/varnish-devicedetect,varnish\/varnish-devicedetect,varnish\/varnish-devicedetect,kevinquinnyo\/varnish-devicedetect,kevinquinnyo\/varnish-devicedetect,wikp\/varnish-devicedetect","old_file":"devicedetect-dev.vcl","new_file":"devicedetect-dev.vcl","new_contents":"#\n# devicedetect-dev.vcl\n#\n# Enable test URLs and cookie overrides.\n#\n\nbackend devicetest {\n .host = \"127.0.0.1\";\n .port = \"5911\";\n}\n\nsub vcl_recv {\n # 701\/702 are arbitrary chosen return codes that is only used internally in varnish.\n if (req.url ~ \"^\/set_ua_device\/.+\") { error 701 regsub(req.url, \"^\/set_ua_device\/\", \"\"); }\n # set expired cookie if nothing is specified\n if (req.url ~ \"^\/set_ua_device\/\") { error 702 \"OK\"; }\n if (req.url ~ \"^\/devicetest\") { set req.backend = devicetest; }\n}\n\nsub vcl_error {\n if (obj.status == 701 || obj.status == 702) {\n if (obj.status == 702) {\n set obj.status = 200;\n set obj.http.Set-Cookie = \"X-UA-Device-force=expiring; Path=\/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;\";\n\n\t} else {\n\t set obj.status = 200;\n\t set obj.http.Set-Cookie = \"X-UA-Device-force=\" + obj.response + \"; Path=\/;\";\n\t}\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n synthetic {\"<html><body><h1>OK, Cookie updated<\/h1><a href='\/devicetest\/'>\/devicetest\/<\/a><\/body><\/html>\"};\n set obj.response = \"OK\";\n return(deliver);\n }\n}\n","old_contents":"#\n# devicedetect-dev.vcl\n#\n# Enable test URLs and cookie overrides.\n#\n\nbackend devicetest { \n .host = \"127.0.0.1\";\n .port = \"5911\";\n}\n\nsub vcl_recv {\n # 701\/702 are arbitrary chosen return codes that is only used internally in varnish.\n if (req.url ~ \"^\/set_ua_device\/.+\") { error 701 regsub(req.url, \"^\/set_ua_device\/\", \"\"); }\n # set expired cookie if nothing is specified\n if (req.url ~ \"^\/set_ua_device\/\") { error 702 \"OK\"; }\n if (req.url ~ \"^\/devicetest\") { set req.backend = devicetest; }\n}\n\nsub vcl_error { \n if (obj.status == 701 || obj.status == 702) {\n if (obj.status == 702) {\n set obj.status = 200;\n set obj.http.Set-Cookie = \"X-UA-Device-force=expiring; Path=\/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;\";\n\n\t} else {\n\t set obj.status = 200;\n\t set obj.http.Set-Cookie = \"X-UA-Device-force=\" + obj.response + \"; Path=\/;\";\n\t}\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n synthetic {\"<html><body><h1>OK, Cookie updated<\/h1><a href='\/devicetest\/'>\/devicetest\/<\/a><\/body><\/html>\"};\n set obj.response = \"OK\";\n return(deliver);\n }\n}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"a43833014c01b3e56fb87f77451773fc037bd461","subject":"Cosmetics","message":"Cosmetics\n","repos":"3scale\/libvmod-3scale,3scale\/libvmod-3scale","old_file":"vcl\/default_3scale_with_proxy.vcl","new_file":"vcl\/default_3scale_with_proxy.vcl","new_contents":"# This is a the VCL configuration file for 3scale's varnish plugin.\n# \n# Default backend definition. Set this to point to the 3scale's\n# backend. \n# \n# set the beresp.ttl in vcl_fetch to have a default global TTL\n# you can define custom TTL via regular expresions\n#\n\n## the backend of your API\nbackend backend_api {\n .host = \"YOUR_API_ENDPOINT\"; \n .port = \"YOUR_API_ENDPOINT\";\n}\n\n## real 3scale backend\nbackend backend_3scale {\n .host = \"su1.3scale.net\"; \n .port = \"80\";\n}\n\nimport std;\nimport threescale;\n\nsub vcl_recv {\n\n unset req.http.cookie;\n\n if (!req.http.X-3scale-authorization) {\n ## this request was send by the end-user\n set req.backend = backend_api;\n\n ## need to generate the string for the 3sacle authorization,\n set req.http.X-3scale-authrep = \"\/transactions\/authrep.xml?provider_key=\";\n ## set your 3scale provider_key\n ## set req.http.X-3scale-authrep = req.http.X-3scale-authrep + \"YOUR_PROVIDER_KEY\";\n \n ## extract the parameters sent by the user\n set req.http.X-3scale-app_id = regsub(req.url,\".*[&?](app_id.[^&]*).*\",\"\\1\");\n set req.http.X-3scale-app_key = regsub(req.url,\".*[&?](app_key.[^&]*).*\",\"\\1\");\n set req.http.X-3scale-user_key = regsub(req.url,\".*[&?](user_key.[^&]*).*\",\"\\1\");\n set req.http.X-3scale-user_id = regsub(req.url,\".*[&?](user_id.[^&]*).*\",\"\\1\");\n\n if (req.http.X-3scale-app_id != req.url) {\n set req.http.X-3scale-authrep = req.http.X-3scale-authrep + \"&\" + req.http.X-3scale-app_id; \n }\n\n if (req.http.X-3scale-app_key != req.url ) {\n set req.http.X-3scale-authrep = req.http.X-3scale-authrep + \"&\" + req.http.X-3scale-app_key; \n }\n\n if (req.http.X-3scale-user_id != req.url) {\n set req.http.X-3scale-authrep = req.http.X-3scale-authrep + \"&\" + req.http.X-3scale-user_id; \n }\n\n if (req.http.X-3scale-user_key != req.url) {\n set req.http.X-3scale-authrep = req.http.X-3scale-authrep + \"&\" + req.http.X-3scale-user_key; \n }\n \n unset req.http.X-3scale-app_id;\n unset req.http.X-3scale-app_key;\n unset req.http.X-3scale-user_id;\n unset req.http.X-3scale-user_key;\n\n ## set the appropiate usage in a similar why than above, the basic one is...\n set req.http.X-3scale-authrep = req.http.X-3scale-authrep + \"&usage[hits]=1\"; \n\n ## now the additional paramters, for instance if you want to pass the url path \n set req.http.X-3scale-authrep = req.http.X-3scale-authrep + \"&object=\" + req.url;\n\n set req.http.X-3scale-authrep-result = threescale.send_get_request(\"localhost\",\"80\",req.http.X-3scale-authrep,\"X-3scale-authorization: true;\");\n\n if (req.http.X-3scale-authrep-result == \"200\") {\n ## the request from the user has been authorized, proceed as normal\n\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n return(pass);\n } \n else {\n return(lookup);\n }\n \n }\n else {\n ## the request from the users has not been authorized!! Returning an error\n ## FIXME: convert req.http.X-3scale-authrep-result; to int\n error 401;\n } \n\n unset req.http.X-3scale-authrep;\n unset req.http.X-3scale-authrep-result;\n\n\n }\n else {\n ## the request was not send by the end-user but by varnish itself\n set req.backend = backend_3scale;\n set req.http.host = \"su1.3scale.net\";\n\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n std.syslog(0,\"This should never happen!!\");\n } \n else {\n return(lookup);\n }\n\n }\n\n\t \n}\n\n# the hash of the request needs to be customized to remove all fields that are not \n# associated to the user\n\nsub vcl_hash {\n\n if (req.http.X-3scale-authorization) { \n ## remove no_body\n set req.http.X-url-tmp = regsub(req.url,\"[&?]no_body.[^&]*\",\"\");\n ## remove object_id\n set req.http.X-url-tmp = regsub(req.http.X-url-tmp,\"[&?]object.[^&]*\",\"\");\n ## remove object\n set req.http.X-url-tmp = regsub(req.http.X-url-tmp,\"[&?]object_id.[^&]*\",\"\");\n\n hash_data(req.http.X-url-tmp);\t\n unset req.http.X-url-tmp;\n }\n else {\n ## the default has of varnish for the end-user request, however we better remove the \n ## parameters specific to 3scale from the end-user request. If you want to remove other\n ## parameters from the original request so that they are not taken into account for the\n ## cache this is the place.\n\n set req.http.X-url-tmp = regsub(req.url,\"[&?]user_key.[^&]*\",\"\");\n set req.http.X-url-tmp = regsub(req.url,\"[&?]user_id.[^&]*\",\"\");\n set req.http.X-url-tmp = regsub(req.url,\"[&?]app_key.[^&]*\",\"\");\n set req.http.X-url-tmp = regsub(req.url,\"[&?]app_id.[^&]*\",\"\");\n\n hash_data(req.http.X-url-tmp);\n\n if (req.http.host) {\n hash_data(req.http.host);\n } \n else {\n hash_data(server.ip);\n }\n\n\t unset req.http.X-url-tmp;\n\n }\n\n return (hash);\n\n}\n\n#A HIT means that the request to your local cache of 3scale is still fresh and the\n#response will not have to fetch the data from the remote 3scale backend.\n#vmod_3scale plugin will send a replica of the call asynchronously to 3scale's remote\n#backend on its own\n\nsub vcl_hit {\n\n if (req.http.X-3scale-authorization) {\n if (req.url ~ \"^\/transactions\/authrep.xml\\?\") {\n\t if (threescale.send_get_request_threaded(\"su1.3scale.net\",\"80\",req.url,\"\")==0) {}\n }\n }\n \n\n}\n\n\nsub vcl_fetch {\n\n if (req.http.X-3scale-authorization) {\n ## cache the authorization from 3scale\n \tset beresp.ttl = 30s;\n }\n else {\n ## cache of the content of your API\n\t set beresp.ttl = 60s;\n }\n\n}\n\nsub vcl_deliver {\n ## remove control headers\n unset req.http.X-3scale-authrep;\n}\n\n\n\nsub vcl_error {\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n <\/head>\n <body>\n <div style=\"background-color:yellow;\">\n <h2>Authorization error trying to access this API<\/h2>\n <p>Did you forget to send your credentials?<\/p>\n <p>Are you over the limits of your account?<\/p> \n <p><b>Please go to your account at 3scale to find out<\/b><\/p>\n <\/div>\n <\/body>\n<\/html>\n\"};\n return (deliver);\n}\n\n\n\n\n","old_contents":"# This is a the VCL configuration file for 3scale's varnish plugin.\n# \n# Default backend definition. Set this to point to the 3scale's\n# backend. \n# \n# set the beresp.ttl in vcl_fetch to have a default global TTL\n# you can define custom TTL via regular expresions\n#\n\n## the backend of your API\nbackend backend_api {\n .host = \"YOUR_API_ENDPOINT\"; \n .port = \"YOUR_API_ENDPOINT\";\n}\n\n## real 3scale backend\nbackend backend_3scale {\n .host = \"su1.3scale.net\"; \n .port = \"80\";\n}\n\nimport std;\nimport threescale;\n\nsub vcl_recv {\n\n\tunset req.http.cookie;\n\n if (!req.http.X-3scale-authorization) {\n ## this request was send by the end-user\n set req.backend = backend_api;\n\n ## need to generate the string for the 3sacle authorization,\n set req.http.X-3scale-authrep = \"\/transactions\/authrep.xml?provider_key=\";\n ## set your 3scale provider_key\n ## set req.http.X-3scale-authrep = req.http.X-3scale-authrep + \"YOUR_PROVIDER_KEY\";\n \n ## extract the parameters sent by the user\n set req.http.X-3scale-app_id = regsub(req.url,\".*[&?](app_id.[^&]*).*\",\"\\1\");\n set req.http.X-3scale-app_key = regsub(req.url,\".*[&?](app_key.[^&]*).*\",\"\\1\");\n set req.http.X-3scale-user_key = regsub(req.url,\".*[&?](user_key.[^&]*).*\",\"\\1\");\n set req.http.X-3scale-user_id = regsub(req.url,\".*[&?](user_id.[^&]*).*\",\"\\1\");\n\n if (req.http.X-3scale-app_id != req.url) {\n set req.http.X-3scale-authrep = req.http.X-3scale-authrep + \"&\" + req.http.X-3scale-app_id; \n }\n\n if (req.http.X-3scale-app_key != req.url ) {\n set req.http.X-3scale-authrep = req.http.X-3scale-authrep + \"&\" + req.http.X-3scale-app_key; \n }\n\n if (req.http.X-3scale-user_id != req.url) {\n set req.http.X-3scale-authrep = req.http.X-3scale-authrep + \"&\" + req.http.X-3scale-user_id; \n }\n\n if (req.http.X-3scale-user_key != req.url) {\n set req.http.X-3scale-authrep = req.http.X-3scale-authrep + \"&\" + req.http.X-3scale-user_key; \n }\n \n unset req.http.X-3scale-app_id;\n unset req.http.X-3scale-app_key;\n unset req.http.X-3scale-user_id;\n unset req.http.X-3scale-user_key;\n\n ## set the appropiate usage in a similar why than above, the basic one is...\n set req.http.X-3scale-authrep = req.http.X-3scale-authrep + \"&usage[hits]=1\"; \n\n ## now the additional paramters, for instance if you want to pass the url path \n set req.http.X-3scale-authrep = req.http.X-3scale-authrep + \"&object=\" + req.url;\n\n set req.http.X-3scale-authrep-result = threescale.send_get_request(\"localhost\",\"80\",req.http.X-3scale-authrep,\"X-3scale-authorization: true;\");\n\n if (req.http.X-3scale-authrep-result == \"200\") {\n ## the request from the user has been authorized, proceed as normal\n\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n return(pass);\n } \n else {\n return(lookup);\n }\n \n }\n else {\n ## the request from the users has not been authorized!! Returning an error\n ## FIXME: convert req.http.X-3scale-authrep-result; to int\n error 401;\n } \n\n unset req.http.X-3scale-authrep;\n unset req.http.X-3scale-authrep-result;\n\n\n }\n else {\n ## the request was not send by the end-user but by varnish itself\n set req.backend = backend_3scale;\n set req.http.host = \"su1.3scale.net\";\n\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n std.syslog(0,\"This should never happen!!\");\n } \n else {\n return(lookup);\n }\n\n }\n\n\t \n}\n\n# the hash of the request needs to be customized to remove all fields that are not \n# associated to the user\n\nsub vcl_hash {\n\n if (req.http.X-3scale-authorization) { \n\t ## remove no_body\n\t set req.http.X-url-tmp = regsub(req.url,\"[&?]no_body.[^&]*\",\"\");\n\t ## remove object_id\n\t set req.http.X-url-tmp = regsub(req.http.X-url-tmp,\"[&?]object.[^&]*\",\"\");\n\t ## remove object\n\t set req.http.X-url-tmp = regsub(req.http.X-url-tmp,\"[&?]object_id.[^&]*\",\"\");\n\n\t hash_data(req.http.X-url-tmp);\t\n\t unset req.http.X-url-tmp;\n }\n else {\n ## the default has of varnish for the end-user request, however we better remove the \n ## parameters specific to 3scale from the end-user request. If you want to remove other\n ## parameters from the original request so that they are not taken into account for the\n ## cache this is the place.\n\n set req.http.X-url-tmp = regsub(req.url,\"[&?]user_key.[^&]*\",\"\");\n set req.http.X-url-tmp = regsub(req.url,\"[&?]user_id.[^&]*\",\"\");\n set req.http.X-url-tmp = regsub(req.url,\"[&?]app_key.[^&]*\",\"\");\n set req.http.X-url-tmp = regsub(req.url,\"[&?]app_id.[^&]*\",\"\");\n\n hash_data(req.http.X-url-tmp);\n\n if (req.http.host) {\n hash_data(req.http.host);\n } \n else {\n hash_data(server.ip);\n }\n\n\t unset req.http.X-url-tmp;\n\n }\n\n return (hash);\n\n}\n\n#A HIT means that the request to your local cache of 3scale is still fresh and the\n#response will not have to fetch the data from the remote 3scale backend.\n#vmod_3scale plugin will send a replica of the call asynchronously to 3scale's remote\n#backend on its own\n\nsub vcl_hit {\n\n if (req.http.X-3scale-authorization) {\n if (req.url ~ \"^\/transactions\/authrep.xml\\?\") {\n\t if (threescale.send_get_request_threaded(\"su1.3scale.net\",\"80\",req.url,\"\")==0) {}\n }\n }\n \n\n}\n\n\nsub vcl_fetch {\n\n if (req.http.X-3scale-authorization) {\n ## cache the authorization from 3scale\n \tset beresp.ttl = 30s;\n }\n else {\n ## cache of the content of your API\n\t set beresp.ttl = 60s;\n }\n\n}\n\nsub vcl_deliver {\n ## remove control headers\n unset req.http.X-3scale-authrep;\n}\n\n\n\nsub vcl_error {\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n <\/head>\n <body>\n <div style=\"background-color:yellow;\">\n <h2>Authorization error trying to access this API<\/h2>\n <p>Did you forget to send your credentials?<\/p>\n <p>Are you over the limits of your account?<\/p> \n <p><b>Please go to your account at 3scale to find out<\/b><\/p>\n <\/div>\n <\/body>\n<\/html>\n\"};\n return (deliver);\n}\n\n\n\n\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"878074ee95c140e60f7ccb5d7f5f7aeb948e267a","subject":"added delete and get cases","message":"added delete and get cases\n","repos":"Destination\/libvmod-abtest,Destination\/libvmod-abtest","old_file":"vcl\/default.vcl","new_file":"vcl\/default.vcl","new_contents":" import std;\n import abtest;\n\n C{\n #include <syslog.h>\n }C\n\n\n backend default {\n .host = \"127.0.0.1\";\n .port = \"3000\";\n }\n\n\/* Only permit localhost to manipulate abtest configuration *\/\nacl abconfig {\n \"localhost\";\n}\n\nsub vcl_init {\n if (abtest.load_config(\"\/tmp\/abtest.cfg\") != 0) {\n C{ syslog(LOG_ALERT, \"Unable to load AB config from \/tmp\/abtest.cfg\"); }C\n }\n abtest.set_rule(\"special\", \"a:10;b:90;\");\n abtest.rem_rule(\"base\");\n\n return (ok);\n}\n\nsub vcl_fini {\n}\n\nsub vcl_recv {\n std.log(abtest.get_rules());\n\n if (req.http.X-AB-Cfg) {\n if (!client.ip ~ abconfig) {\n std.log(\"AB Config request not allowed from \" + client.ip);\n error 405 \"Not allowed.\";\n } else {\n \/\/ curl localhost:8080 -X PUT -H \"X-AB-Cfg:base\" -H \"X-AB-Cfg-Val:a:25;b:75;\"\n if (req.request == \"PUT\") {\n std.log(\"AB Config PUT request: \" + req.http.X-AB-Cfg + \"|\" + req.http.X-AB-Cfg-Val);\n abtest.set_rule(req.http.X-AB-Cfg, req.http.X-AB-Cfg-Val);\n if (abtest.save_config(\"\/tmp\/abtest.cfg\") != 0) {\n std.log(\"ABTest - Error, could not save the configuration\");\n }\n }\n\n \/\/ curl localhost:8080 -X DELETE -H \"X-AB-Cfg:base\"\n if (req.request == \"DELETE\") {\n std.log(\"AB Config DELETE request: \" + req.http.X-AB-Cfg);\n abtest.rem_rule(req.http.X-AB-Cfg);\n }\n\n \/\/ curl localhost:8080 -X DELETE -H \"X-AB-Cfg;\"\n if (req.request == \"GET\") {\n std.log(\"AB Config GET request: \" + req.http.X-AB-Cfg);\n std.log(\"CFG -> \" + abtest.get_rules());\n }\n }\n }\n\n\/*\n if(req.http.Cookie ~ \"abtesting\") {\n }\n*\/\n}\n\nsub vcl_pipe {\n}\n\nsub vcl_pass {\n}\n\nsub vcl_hash {\n}\n\nsub vcl_hit {\n}\n\nsub vcl_miss {\n}\n\nsub vcl_fetch {\n}\n\nsub vcl_deliver {\n}\n\nsub vcl_error {\n}\n","old_contents":"\/*-\n * Copyright (c) 2006 Verdens Gang AS\n * Copyright (c) 2006-2011 Varnish Software AS\n * All rights reserved.\n *\n * Author: Poul-Henning Kamp <phk@phk.freebsd.dk>\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in the\n * documentation and\/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\n * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n * The default VCL code.\n *\n * NB! You do NOT need to copy & paste all of these functions into your\n * own vcl code, if you do not provide a definition of one of these\n * functions, the compiler will automatically fall back to the default\n * code from this file.\n *\n * This code will be prefixed with a backend declaration built from the\n * -b argument.\n *\/\n\n import std;\n import abtest;\n\n C{\n #include <syslog.h>\n }C\n\n\n backend default {\n .host = \"127.0.0.1\";\n .port = \"3000\";\n }\n\n\/* Only permit localhost to manipulate abtest configuration *\/\nacl abconfig {\n \"localhost\";\n}\n\nsub vcl_init {\n if (abtest.load_config(\"\/tmp\/abtest.cfg\") != 0) {\n C{ syslog(LOG_ALERT, \"Unable to load AB config from \/tmp\/abtest.cfg\"); }C\n }\n return (ok);\n}\n\nsub vcl_fini {\n}\n\nsub vcl_recv {\n if (req.http.AB-Cfg) {\n if (!client.ip ~ abconfig) {\n std.log(\"AB Config request not allowed from \" + client.ip);\n error 405 \"Not allowed.\";\n } else {\n \/\/ curl localhost:8080 -X PUT -H \"AB-Cfg:base\" -H \"AB-Cfg-Val:a:25;b:75;\"\n if (req.request == \"PUT\") {\n std.log(\"AB Config PUT request: \" + req.http.AB-Cfg + \"|\" + req.http.AB-Cfg-Val);\n abtest.set_rule(req.http.AB-Cfg, req.http.AB-Cfg-Val);\n abtest.save_config(\"\/tmp\/abtest.cfg\");\n }\n\n if (req.request == \"DELETE\") {\n std.log(\"AB Config DELETE request: \" + req.http.AB-Cfg);\n }\n\n if (req.request == \"GET\") {\n std.log(\"AB Config GET request: \" + req.http.AB-Cfg);\n }\n }\n }\n\n\/*\n if(req.http.Cookie ~ \"abtesting\") {\n }\n*\/\n}\n\nsub vcl_pipe {\n}\n\nsub vcl_pass {\n}\n\nsub vcl_hash {\n}\n\nsub vcl_hit {\n}\n\nsub vcl_miss {\n}\n\nsub vcl_fetch {\n}\n\nsub vcl_deliver {\n}\n\nsub vcl_error {\n}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"5f41ea8d3f2d839da4f74450ff630126d08a3745","subject":"googlebot for mobile has \"iphone\" in ua-string. move thing a bit to match that first. This is why U-As are no fun","message":"googlebot for mobile has \"iphone\" in ua-string. move thing a bit to match that first. This is why U-As are no fun\n","repos":"varnish\/varnish-devicedetect,wikp\/varnish-devicedetect,varnish\/varnish-devicedetect,wikp\/varnish-devicedetect,kevinquinnyo\/varnish-devicedetect,kevinquinnyo\/varnish-devicedetect","old_file":"devicedetect.vcl","new_file":"devicedetect.vcl","new_contents":"#\n# detectdevice.vcl - regex based device detection for Varnish\n# http:\/\/github.com\/varnish\/varnish-devicedetect\/\n#\n# Author: Lasse Karstensen <lasse@varnish-software.com>\n\nsub devicedetect {\n unset req.http.X-UA-Device;\n set req.http.X-UA-Device = \"pc\";\n\n if (req.http.User-Agent ~ \"(?i)(ads|google|bing|msn|yandex|baidu|ro|career|)bot\" ||\n\treq.http.User-Agent ~ \"(?i)(baidu|symantec)spider\" ||\n\treq.http.User-Agent ~ \"(?i)scanner\" ||\n\treq.http.User-Agent ~ \"(?i)(web)crawler\") {\n\tset req.http.X-UA-Device = \"bot\"; }\n elsif (req.http.User-Agent ~ \"(?i)ip(hone|od)\") { set req.http.X-UA-Device = \"mobile-iphone\"; }\n elsif (req.http.User-Agent ~ \"(?i)ipad\") { set req.http.X-UA-Device = \"tablet-ipad\"; }\n # how do we differ between an android phone and an android tablet?\n # http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent\n elsif (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") { set req.http.X-UA-Device = \"mobile-android\"; } \n # android 3\/honeycomb was just about tablet-only, and any phones will probably handle a bigger page layout.\n elsif (req.http.User-Agent ~ \"(?i)android 3\") { set req.http.X-UA-Device = \"tablet-android\"; }\n # may very well give false positives towards android tablets. Suggestions welcome.\n elsif (req.http.User-Agent ~ \"(?i)android\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\n elsif (req.http.User-Agent ~ \"^HTC\" ||\n req.http.User-Agent ~ \"Fennec\" || \n req.http.User-Agent ~ \"IEMobile\" ||\n req.http.User-Agent ~ \"BlackBerry\" ||\n req.http.User-Agent ~ \"SymbianOS.*AppleWebKit\" ||\n req.http.User-Agent ~ \"Opera Mobi\") {\n set req.http.X-UA-Device = \"mobile-smartphone\";\n }\n elsif (req.http.User-Agent ~ \"(?i)symbian\" ||\n req.http.User-Agent ~ \"(?i)^sonyericsson\" ||\n req.http.User-Agent ~ \"(?i)^nokia\" ||\n req.http.User-Agent ~ \"(?i)^samsung\" ||\n req.http.User-Agent ~ \"(?i)^lg\" ||\n\treq.http.User-Agent ~ \"(?i)bada\" ||\n\treq.http.User-Agent ~ \"(?i)blazer\" ||\n\treq.http.User-Agent ~ \"(?i)cellphone\" ||\n\treq.http.User-Agent ~ \"(?i)iemobile\" ||\n\treq.http.User-Agent ~ \"(?i)midp-2.0\" ||\n\treq.http.User-Agent ~ \"(?i)u990\" ||\n\treq.http.User-Agent ~ \"(?i)netfront\" ||\n\treq.http.User-Agent ~ \"(?i)opera mini\" ||\n\treq.http.User-Agent ~ \"(?i)palm\" ||\n\treq.http.User-Agent ~ \"(?i)nintendo wii\" ||\n\treq.http.User-Agent ~ \"(?i)playstation portable\" ||\n\treq.http.User-Agent ~ \"(?i)portalmmm\" ||\n\treq.http.User-Agent ~ \"(?i)proxinet\" ||\n\treq.http.User-Agent ~ \"(?i)sonyericsson\" ||\n\treq.http.User-Agent ~ \"(?i)symbian\" ||\n\treq.http.User-Agent ~ \"(?i)windows\\ ?ce\" ||\n\treq.http.User-Agent ~ \"(?i)winwap\" ||\n\treq.http.User-Agent ~ \"(?i)eudoraweb\" ||\n\treq.http.User-Agent ~ \"(?i)htc\" ||\n\treq.http.User-Agent ~ \"(?i)240x320\" ||\n\treq.http.User-Agent ~ \"(?i)avantgo\") { \n set req.http.X-UA-Device = \"mobile-generic\";\n } \n # handle overrides\n if (req.http.Cookie ~ \"(i?)X-UA-Device-force\") {\n # ;?? means zero or one ;, non-greedy to match the first.\n set req.http.X-UA-Device = regsub(req.http.Cookie, \"(?i).*X-UA-Device-force=([^;]+);??.*\", \"\\1\");\n }\n}\n\n# vim: sw=4:tw=120 # meh\n","old_contents":"#\n# detectdevice.vcl - regex based device detection for Varnish\n# http:\/\/github.com\/lkarsten\/varnish-devicedetect\/\n#\n# Author: Lasse Karstensen <lasse@varnish-software.com>\n\nsub devicedetect {\n unset req.http.X-UA-Device;\n set req.http.X-UA-Device = \"pc\";\n\n if (req.http.User-Agent ~ \"(?i)ip(hone|od)\") { set req.http.X-UA-Device = \"mobile-iphone\"; }\n elsif (req.http.User-Agent ~ \"(?i)ipad\") { set req.http.X-UA-Device = \"tablet-ipad\"; }\n # how do we differ between an android phone and an android tablet?\n # http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent\n elsif (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") { set req.http.X-UA-Device = \"mobile-android\"; } \n # android 3\/honeycomb was just about tablet-only, and any phones will probably handle a bigger page layout.\n elsif (req.http.User-Agent ~ \"(?i)android 3\") { set req.http.X-UA-Device = \"tablet-android\"; }\n # may very well give false positives towards android tablets. Suggestions welcome.\n elsif (req.http.User-Agent ~ \"(?i)android\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\n elsif (req.http.User-Agent ~ \"^HTC\" ||\n req.http.User-Agent ~ \"Fennec\" || \n req.http.User-Agent ~ \"IEMobile\" ||\n req.http.User-Agent ~ \"BlackBerry\" ||\n req.http.User-Agent ~ \"SymbianOS.*AppleWebKit\" ||\n req.http.User-Agent ~ \"Opera Mobi\") {\n set req.http.X-UA-Device = \"mobile-smartphone\";\n }\n elsif (req.http.User-Agent ~ \"(?i)symbian\" ||\n req.http.User-Agent ~ \"(?i)^sonyericsson\" ||\n req.http.User-Agent ~ \"(?i)^nokia\" ||\n req.http.User-Agent ~ \"(?i)^samsung\" ||\n req.http.User-Agent ~ \"(?i)^lg\" ||\n\treq.http.User-Agent ~ \"(?i)bada\" ||\n\treq.http.User-Agent ~ \"(?i)blazer\" ||\n\treq.http.User-Agent ~ \"(?i)cellphone\" ||\n\treq.http.User-Agent ~ \"(?i)iemobile\" ||\n\treq.http.User-Agent ~ \"(?i)midp-2.0\" ||\n\treq.http.User-Agent ~ \"(?i)u990\" ||\n\treq.http.User-Agent ~ \"(?i)netfront\" ||\n\treq.http.User-Agent ~ \"(?i)opera mini\" ||\n\treq.http.User-Agent ~ \"(?i)palm\" ||\n\treq.http.User-Agent ~ \"(?i)nintendo wii\" ||\n\treq.http.User-Agent ~ \"(?i)playstation portable\" ||\n\treq.http.User-Agent ~ \"(?i)portalmmm\" ||\n\treq.http.User-Agent ~ \"(?i)proxinet\" ||\n\treq.http.User-Agent ~ \"(?i)sonyericsson\" ||\n\treq.http.User-Agent ~ \"(?i)symbian\" ||\n\treq.http.User-Agent ~ \"(?i)windows\\ ?ce\" ||\n\treq.http.User-Agent ~ \"(?i)winwap\" ||\n\treq.http.User-Agent ~ \"(?i)eudoraweb\" ||\n\treq.http.User-Agent ~ \"(?i)htc\" ||\n\treq.http.User-Agent ~ \"(?i)240x320\" ||\n\treq.http.User-Agent ~ \"(?i)avantgo\") { \n set req.http.X-UA-Device = \"mobile-generic\";\n }\n\n # handle overrides\n if (req.http.Cookie ~ \"(i?)X-UA-Device-force\") {\n # ;?? means zero or one ;, non-greedy to match the first.\n set req.http.X-UA-Device = regsub(req.http.Cookie, \"(?i).*X-UA-Device-force=([^;]+);??.*\", \"\\1\");\n }\n}\n\n# vim: sw=4:tw=120 # meh\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"62afbbc6d62bb971680630558804632c8479b8b1","subject":"also add dynamic backend to default varnish config.","message":"also add dynamic backend to default varnish config.\n","repos":"amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon","old_file":"images\/varnish\/default.vcl","new_file":"images\/varnish\/default.vcl","new_contents":"#\n# This is an example VCL file for Varnish.\n#\n# It does not do anything by default, delegating control to the\n# builtin VCL. The builtin VCL is called when there is no explicit\n# return statement.\n#\n# See the VCL chapters in the Users Guide at https:\/\/www.varnish-cache.org\/docs\/\n# and https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExamples for more examples.\n\nvcl 4.0;\n\nimport std;\nimport dynamic;\n\n# set backend default\nbackend default {\n .host = \"${VARNISH_BACKEND_HOST:-nginx}\";\n .port = \"${VARNISH_BACKEND_PORT:-8080}\";\n .first_byte_timeout = 35m;\n .between_bytes_timeout = 10m;\n}\n\nsub vcl_init {\n new www_dir = dynamic.director(\n port = \"${VARNISH_BACKEND_PORT:-8080}\",\n first_byte_timeout = 90s,\n between_bytes_timeout = 90s,\n ttl = 60s);\n }\n\nsub vcl_recv {\n # Happens before we check if we have this in cache already.\n #\n # Typically you clean up the request here, removing cookies you don't need,\n # rewriting the request, etc.\n\n # set the backend, which should be used:\n set req.backend_hint = default;\n\n # Needed for Readyness and Liveness checks - do not remove\n if (req.url ~ \"^\/varnish_status$\") {\n return (synth(200,\"OK\"));\n }\n\n}\n\nsub vcl_backend_response {\n # Happens after we have read the response headers from the backend.\n #\n # Here you clean the response headers, removing silly Set-Cookie headers\n # and other mistakes your backend does.\n}\n\nsub vcl_deliver {\n # Happens when we have all the pieces we need, and are about to send the\n # response to the client.\n #\n # You can do accounting or modifying the final object here.\n}\n","old_contents":"#\n# This is an example VCL file for Varnish.\n#\n# It does not do anything by default, delegating control to the\n# builtin VCL. The builtin VCL is called when there is no explicit\n# return statement.\n#\n# See the VCL chapters in the Users Guide at https:\/\/www.varnish-cache.org\/docs\/\n# and https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExamples for more examples.\n\nvcl 4.0;\n\nimport std;\n\n# set backend default\nbackend default {\n .host = \"${VARNISH_BACKEND_HOST:-nginx}\";\n .port = \"${VARNISH_BACKEND_PORT:-8080}\";\n .first_byte_timeout = 35m;\n .between_bytes_timeout = 10m;\n}\n\nsub vcl_recv {\n # Happens before we check if we have this in cache already.\n #\n # Typically you clean up the request here, removing cookies you don't need,\n # rewriting the request, etc.\n\n # set the backend, which should be used:\n set req.backend_hint = default;\n\n # Needed for Readyness and Liveness checks - do not remove\n if (req.url ~ \"^\/varnish_status$\") {\n return (synth(200,\"OK\"));\n }\n\n}\n\nsub vcl_backend_response {\n # Happens after we have read the response headers from the backend.\n #\n # Here you clean the response headers, removing silly Set-Cookie headers\n # and other mistakes your backend does.\n}\n\nsub vcl_deliver {\n # Happens when we have all the pieces we need, and are about to send the\n # response to the client.\n #\n # You can do accounting or modifying the final object here.\n}\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"81006eafd6d4cd6f9481740a1d172e316a184d05","subject":"Handle Cache-control: (private|no-cache|no-store) by default","message":"Handle Cache-control: (private|no-cache|no-store) by default\n\nAs per discussion at the Varnish dev meeting, seeing Cache-control:\nno-cache (and friends) now disable caching by default. As a twist, we\nrespect Surrogate-control if that is present, in the default VCL.\n\nFixes: 1124\nReferences: 477\n","repos":"chrismoulton\/Varnish-Cache,alarky\/varnish-cache-doc-ja,franciscovg\/Varnish-Cache,feld\/Varnish-Cache,mrhmouse\/Varnish-Cache,feld\/Varnish-Cache,zhoualbeart\/Varnish-Cache,zhoualbeart\/Varnish-Cache,varnish\/Varnish-Cache,1HLtd\/Varnish-Cache,franciscovg\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,franciscovg\/Varnish-Cache,chrismoulton\/Varnish-Cache,alarky\/varnish-cache-doc-ja,varnish\/Varnish-Cache,zhoualbeart\/Varnish-Cache,varnish\/Varnish-Cache,1HLtd\/Varnish-Cache,franciscovg\/Varnish-Cache,alarky\/varnish-cache-doc-ja,franciscovg\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,feld\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,feld\/Varnish-Cache,gquintard\/Varnish-Cache,chrismoulton\/Varnish-Cache,chrismoulton\/Varnish-Cache,zhoualbeart\/Varnish-Cache,mrhmouse\/Varnish-Cache,mrhmouse\/Varnish-Cache,gquintard\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,gquintard\/Varnish-Cache,chrismoulton\/Varnish-Cache,mrhmouse\/Varnish-Cache,1HLtd\/Varnish-Cache,zhoualbeart\/Varnish-Cache,mrhmouse\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,varnish\/Varnish-Cache,feld\/Varnish-Cache,gquintard\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,1HLtd\/Varnish-Cache,varnish\/Varnish-Cache,alarky\/varnish-cache-doc-ja,ajasty-cavium\/Varnish-Cache,alarky\/varnish-cache-doc-ja","old_file":"bin\/varnishd\/default.vcl","new_file":"bin\/varnishd\/default.vcl","new_contents":"\/*-\n * Copyright (c) 2006 Verdens Gang AS\n * Copyright (c) 2006-2011 Varnish Software AS\n * All rights reserved.\n *\n * Author: Poul-Henning Kamp <phk@phk.freebsd.dk>\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in the\n * documentation and\/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n\n *\n * The default VCL code.\n *\n * NB! You do NOT need to copy & paste all of these functions into your\n * own vcl code, if you do not provide a definition of one of these\n * functions, the compiler will automatically fall back to the default\n * code from this file.\n *\n * This code will be prefixed with a backend declaration built from the\n * -b argument.\n *\/\n\nsub vcl_recv {\n if (req.restarts == 0) {\n\tif (req.http.x-forwarded-for) {\n\t set req.http.X-Forwarded-For =\n\t\treq.http.X-Forwarded-For + \", \" + client.ip;\n\t} else {\n\t set req.http.X-Forwarded-For = client.ip;\n\t}\n }\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization || req.http.Cookie) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n return (lookup);\n}\n\nsub vcl_pipe {\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n # set bereq.http.connection = \"close\";\n # here. It is not set by default as it might break some broken web\n # applications, like IIS with NTLM authentication.\n return (pipe);\n}\n\nsub vcl_pass {\n return (pass);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n return (hash);\n}\n\nsub vcl_hit {\n return (deliver);\n}\n\nsub vcl_miss {\n return (fetch);\n}\n\nsub vcl_fetch {\n if (beresp.ttl <= 0s ||\n beresp.http.Set-Cookie ||\n beresp.http.Surrogate-control ~ \"no-store\" ||\n (!beresp.http.Surrogate-Control &&\n beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n beresp.http.Vary == \"*\") {\n\t\t\/*\n\t\t * Mark as \"Hit-For-Pass\" for the next 2 minutes\n\t\t *\/\n\t\tset beresp.ttl = 120 s;\n\t\tset beresp.do_pass = true;\n }\n return (deliver);\n}\n\nsub vcl_deliver {\n return (deliver);\n}\n\n\/*\n * We can come here \"invisibly\" with the following errors: 413, 417 & 503\n *\/\nsub vcl_error {\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + obj.status + \" \" + obj.response + {\"<\/h1>\n <p>\"} + obj.response + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"};\n return (deliver);\n}\n\nsub vcl_init {\n\treturn (ok);\n}\n\nsub vcl_fini {\n\treturn (ok);\n}\n","old_contents":"\/*-\n * Copyright (c) 2006 Verdens Gang AS\n * Copyright (c) 2006-2011 Varnish Software AS\n * All rights reserved.\n *\n * Author: Poul-Henning Kamp <phk@phk.freebsd.dk>\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in the\n * documentation and\/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n\n *\n * The default VCL code.\n *\n * NB! You do NOT need to copy & paste all of these functions into your\n * own vcl code, if you do not provide a definition of one of these\n * functions, the compiler will automatically fall back to the default\n * code from this file.\n *\n * This code will be prefixed with a backend declaration built from the\n * -b argument.\n *\/\n\nsub vcl_recv {\n if (req.restarts == 0) {\n\tif (req.http.x-forwarded-for) {\n\t set req.http.X-Forwarded-For =\n\t\treq.http.X-Forwarded-For + \", \" + client.ip;\n\t} else {\n\t set req.http.X-Forwarded-For = client.ip;\n\t}\n }\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization || req.http.Cookie) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n return (lookup);\n}\n\nsub vcl_pipe {\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n # set bereq.http.connection = \"close\";\n # here. It is not set by default as it might break some broken web\n # applications, like IIS with NTLM authentication.\n return (pipe);\n}\n\nsub vcl_pass {\n return (pass);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n return (hash);\n}\n\nsub vcl_hit {\n return (deliver);\n}\n\nsub vcl_miss {\n return (fetch);\n}\n\nsub vcl_fetch {\n if (beresp.ttl <= 0s ||\n beresp.http.Set-Cookie ||\n beresp.http.Vary == \"*\") {\n\t\t\/*\n\t\t * Mark as \"Hit-For-Pass\" for the next 2 minutes\n\t\t *\/\n\t\tset beresp.ttl = 120 s;\n\t\tset beresp.do_pass = true;\n }\n return (deliver);\n}\n\nsub vcl_deliver {\n return (deliver);\n}\n\n\/*\n * We can come here \"invisibly\" with the following errors: 413, 417 & 503\n *\/\nsub vcl_error {\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + obj.status + \" \" + obj.response + {\"<\/h1>\n <p>\"} + obj.response + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"};\n return (deliver);\n}\n\nsub vcl_init {\n\treturn (ok);\n}\n\nsub vcl_fini {\n\treturn (ok);\n}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"357fe1fbee8a9ca3dbab3d38ea695b18cd8a4904","subject":"Remove stale handling in vcl_deliver to make it consistent with Fastly docs. Remove Pragma header as it's superflous","message":"Remove stale handling in vcl_deliver to make it consistent with Fastly docs. Remove Pragma header as it's superflous\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets\/deliver.vcl","new_file":"etc\/vcl_snippets\/deliver.vcl","new_contents":" # Send no cache headers to end users for non-static content. Also make sure\n # we only set this on the edge nodes and not on shields\n if (req.url !~ \"^\/(pub\/)?(media|static)\/.*\" && !req.http.Fastly-FF ) {\n set resp.http.Cache-Control = \"no-store, no-cache, must-revalidate, max-age=0\";\n }\n\n # Execute only on the edge nodes\n if ( !req.http.Fastly-FF ) {\n # Remove X-Magento-Vary and HTTPs Vary served to the user\n set resp.http.Vary = regsub(resp.http.Vary, \"X-Magento-Vary,Https\", \"Cookie\");\n remove resp.http.X-Magento-Tags;\n }\n\n # Add an easy way to see whether custom Fastly VCL has been uploaded\n if ( req.http.Fastly-Debug ) {\n set resp.http.Fastly-Magento-VCL-Uploaded = \"1.2.74\";\n } else {\n remove resp.http.Fastly-Module-Enabled;\n remove resp.http.fastly-page-cacheable;\n }\n\n # debug info\n if (!resp.http.X-Magento-Debug) {\n # remove Varnish\/proxy header\n remove resp.http.X-Magento-Debug;\n remove resp.http.X-Magento-Cache-Control;\n remove resp.http.X-Powered-By;\n remove resp.http.Server;\n remove resp.http.X-Varnish;\n remove resp.http.Via;\n remove resp.http.X-Purge-URL;\n remove resp.http.X-Purge-Host;\n }\n","old_contents":" if (resp.status >= 500 && resp.status < 600) {\n \/* restart if the stale object is available *\/\n if (stale.exists) {\n restart;\n }\n }\n\n # Send no cache headers to end users for non-static content. Also make sure\n # we only set this on the edge nodes and not on shields\n if (req.url !~ \"^\/(pub\/)?(media|static)\/.*\" && !req.http.Fastly-FF ) {\n set resp.http.Pragma = \"no-cache\";\n set resp.http.Cache-Control = \"no-store, no-cache, must-revalidate, max-age=0\";\n }\n\n # Execute only on the edge nodes\n if ( !req.http.Fastly-FF ) {\n # Remove X-Magento-Vary and HTTPs Vary served to the user\n set resp.http.Vary = regsub(resp.http.Vary, \"X-Magento-Vary,Https\", \"Cookie\");\n remove resp.http.X-Magento-Tags;\n }\n\n # Add an easy way to see whether custom Fastly VCL has been uploaded\n if ( req.http.Fastly-Debug ) {\n set resp.http.Fastly-Magento-VCL-Uploaded = \"1.2.74\";\n } else {\n remove resp.http.Fastly-Module-Enabled;\n remove resp.http.fastly-page-cacheable;\n }\n\n # debug info\n if (!resp.http.X-Magento-Debug) {\n # remove Varnish\/proxy header\n remove resp.http.X-Magento-Debug;\n remove resp.http.X-Magento-Cache-Control;\n remove resp.http.X-Powered-By;\n remove resp.http.Server;\n remove resp.http.X-Varnish;\n remove resp.http.Via;\n remove resp.http.X-Purge-URL;\n remove resp.http.X-Purge-Host;\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"02a77a7774ec988a85c3dbf96fb1758d05652194","subject":"Bump to version 1.2.95","message":"Bump to version 1.2.95\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets\/deliver.vcl","new_file":"etc\/vcl_snippets\/deliver.vcl","new_contents":" # Send no cache headers to end users for non-static content created by Magento\n if (resp.http.X-Magento-Tags && !req.http.Fastly-FF ) {\n set resp.http.Cache-Control = \"no-store, no-cache, must-revalidate, max-age=0\";\n }\n\n # Execute only on the edge nodes\n if ( !req.http.Fastly-FF ) {\n # Remove X-Magento-Vary and HTTPs Vary served to the user\n set resp.http.Vary = regsub(resp.http.Vary, \"X-Magento-Vary,Https\", \"Cookie\");\n remove resp.http.X-Magento-Tags;\n }\n\n # Add an easy way to see whether custom Fastly VCL has been uploaded\n if ( req.http.Fastly-Debug ) {\n set resp.http.Fastly-Magento-VCL-Uploaded = \"1.2.95\";\n } else {\n remove resp.http.Fastly-Module-Enabled;\n remove resp.http.fastly-page-cacheable;\n }\n\n # debug info\n if (!resp.http.X-Magento-Debug) {\n # remove Varnish\/proxy header\n remove resp.http.X-Magento-Debug;\n remove resp.http.X-Magento-Cache-Control;\n remove resp.http.X-Powered-By;\n remove resp.http.Server;\n remove resp.http.X-Varnish;\n remove resp.http.Via;\n remove resp.http.X-Purge-URL;\n remove resp.http.X-Purge-Host;\n }\n","old_contents":" # Send no cache headers to end users for non-static content created by Magento\n if (resp.http.X-Magento-Tags && !req.http.Fastly-FF ) {\n set resp.http.Cache-Control = \"no-store, no-cache, must-revalidate, max-age=0\";\n }\n\n # Execute only on the edge nodes\n if ( !req.http.Fastly-FF ) {\n # Remove X-Magento-Vary and HTTPs Vary served to the user\n set resp.http.Vary = regsub(resp.http.Vary, \"X-Magento-Vary,Https\", \"Cookie\");\n remove resp.http.X-Magento-Tags;\n }\n\n # Add an easy way to see whether custom Fastly VCL has been uploaded\n if ( req.http.Fastly-Debug ) {\n set resp.http.Fastly-Magento-VCL-Uploaded = \"1.2.94\";\n } else {\n remove resp.http.Fastly-Module-Enabled;\n remove resp.http.fastly-page-cacheable;\n }\n\n # debug info\n if (!resp.http.X-Magento-Debug) {\n # remove Varnish\/proxy header\n remove resp.http.X-Magento-Debug;\n remove resp.http.X-Magento-Cache-Control;\n remove resp.http.X-Powered-By;\n remove resp.http.Server;\n remove resp.http.X-Varnish;\n remove resp.http.Via;\n remove resp.http.X-Purge-URL;\n remove resp.http.X-Purge-Host;\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"b43038528fc9383dc89eb75e52ac3c6db918c842","subject":"Adding presence of bearer token to cache key","message":"Adding presence of bearer token to cache key\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets\/hash.vcl","new_file":"etc\/vcl_snippets\/hash.vcl","new_contents":" if (req.http.graphql) {\n # GraphQL should cache on X-Magento-Cache-Id if available, which has a bunch of variations so it should be part of the key and not a Vary factor\n if (req.http.X-Magento-Cache-Id) {\n set req.hash += req.http.X-Magento-Cache-Id;\n }\n # When the frontend stops sending the auth token, make sure users stop getting results cached for logged-in users\n # Unfortunately we don't yet have a way to authenticate before hitting the cache, so this is as close as we can get for now\n if ( req.http.Authorization ~ \"^Bearer\" ) {\n set req.hash += \"Authorized\";\n }\n }\n return(hash);\n","old_contents":" # Fastly should cache on X-Magento-Cache-Id if available, which has a bunch of variations so it should be part of the key and not a Vary factor\n if (req.http.graphql && req.http.X-Magento-Cache-Id) {\n set req.hash += req.http.X-Magento-Cache-Id;\n }\n return(hash);\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"6eb04ad7ce1d44b3e42c2c1340a59d2a7bca9d32","subject":"update static files regex","message":"update static files regex\n","repos":"NITEMAN\/varnish-bites,NITEMAN\/Varnish_VCL_samps-hacks","old_file":"varnish3\/drupal-base.vcl","new_file":"varnish3\/drupal-base.vcl","new_contents":"\/* Varnish 3 example config for Drupal 7 \/ Pressflow 6 & 7 *\/\n# Original source: https:\/\/github.com\/NITEMAN\/varnish-bites\/varnish4\/drupal-base.vcl\n# Copyright (c) 2015 Pedro Gonz\u00e1lez Serrano and individual contributors.\n# MIT License\n\n# Intended to be used both in simple production environments and with learning\/teaching purposes.\n# Loosely based on http:\/\/www.lullabot.com\/sites\/default\/files\/default_varnish3.vcl_.txt\n\n\/* Backend probes \/ healthchecks *\/\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#backend-probes\nprobe basic {\n \/* Only test that backend's IP serves content for '\/' *\/\n # This might be a too heavy probe\n # .url = \"\/\";\n \/* Only test that backend's IP has apache working *\/\n # Nginx would fail this probe with a default config\n .request =\n \"OPTIONS * HTTP\/1.1\"\n \"Host: *\"\n \"Connection: close\";\n .interval = 10s;\n .timeout = 2s;\n .window = 8;\n .threshold = 6;\n}\n\n\n\/* Backend definitions.*\/\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#backend-declarations\nbackend default {\n \/* Default backend on the same machine. WARNING: timeouts could be not big enought for certain POST request *\/\n .host = \"127.0.0.1\";\n .port = \"8008\";\n .connect_timeout = 60s;\n .first_byte_timeout = 60s;\n .between_bytes_timeout = 60s;\n .probe = basic;\n}\n\n\n\/* Directors. *\/\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#directors\n# Empty in simple configs\n\n\n\/* Access Control Lists *\/\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#acls\nacl purge_ban {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use '\"localhost\";' instead\n}\nacl allowed_monitors {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n}\nacl own_proxys {\n \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n}\n\n\n\/* Custom routines *\/\n# Empty in simple configs.\n# We can name subs with no restrictions but as a task can need several chunks of code in diferent states,\n# it's a good idea to identify what main sub will call each with a suffix.\n# \/* Example 301 client redirection removing \"www\" prefix from request *\/\n# sub perm_redirections_recv {\n# if ( req.http.host ~ \"^www.*$\" ) {\n# error 751 \"http:\/\/\" + regsub(req.http.host, \"^www\\.\", \"\") + req.url;\n# }\n# }\n# sub perm_redirections_error {\n# if (obj.status == 751) {\n# \/* Get new URL from the response *\/\n# set obj.http.Location = obj.response;\n# \/* Set HTTP 301 for permanent redirect *\/\n# set obj.status = 301;\n# return(deliver);\n# }\n# }\n\n\n\/* VCL logigc overrides *\/\n# Note that the built-in logic will be appended to our code if no return is performed before.\n# Built-in logic is included commented out right after our's for reference purposes in that cases.\n# See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleDefault\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#subroutines\n\n# vcl_recv: Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use.\nsub vcl_recv {\n \/* 0th: general bypass, general return & authorization checks *\/\n # Empty in simple configs.\n # Useful for debugging we can pipe or pass the request to default backend here to bypass completely Varnish.\n # return (pipe);\n # return (pass);\n # We can also return here a 200 Ok for network performance benchmarking.\n # error 200 \"Ok\";\n # Finally we can perform basic HTTP authentification here by example.\n # See http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* 1st: Check for Varnish special requests *\/ \n # Purge logic.\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/purging.html#http-purges\n # See https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if (req.request == \"PURGE\") {\n if (!client.ip ~ purge_ban) {\n error 405 \"Not allowed.\";\n }\n return (lookup);\n }\n # Ban logic. See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/purging.html#bans\n if (req.request == \"BAN\") {\n if (!client.ip ~ purge_ban) {\n error 405 \"Not allowed.\";\n }\n ban(\"req.http.host == \" + req.http.host +\n \"&& req.url == \" + req.url); \n error 200 \"Ban added\";\n }\n # Custom response implementation example in order to check that Varnish is working properly.\n # This is usefull for automatic monitoring with monit or when Varnish is behind another proxies like HAProxy.\n if ( ( req.http.host == \"monitor.server.health\"\n || req.http.host == \"health.varnish\" )\n && client.ip ~ allowed_monitors\n && ( req.request == \"OPTIONS\" || req.request == \"GET\" )\n ) {\n error 200 \"Ok\";\n }\n\n \/* 2nd: Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_recv;\n # Here we can also enforce SSL when Varnish run behind some SSL termination point.\n\n \/* 3rd: Time for backend choice *\/\n # Empty in simple configs.\n\n \/* 4th: Set custom headers for backend like X-Forwarded-For (copied from built-in logic) *\/\n if ( req.restarts == 0 ) {\n \/* See also vcl_pipe section *\/\n if ( ! client.ip ~ own_proxys ) {\n if ( req.http.x-forwarded-for ) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n }\n\n \/* 5th: Bypass breakpoint 1 *\/\n # Useful for debugging we can now pipe or pass the request to backend with headers setted.\n # return (pipe);\n # return (pass);\n\n \/* 6th: Decide if we should deal with a request (mostly copied from built-in logic) *\/\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n\n \/* 7th: Access control for some URLs by ACL *\/\n # Empty in simple configs.\n # By example denial some URLs depending on client-ip, we'll need to define corresponding ACL 'internal'.\n # if (req.url ~ \"^\/(cron|install)\\.php$\" && !client.ip ~ internal) {\n # # Have Varnish throw the error directly.\n # error 403 \"Forbidden.\";\n # # Use a custom error page that you've defined in Drupal at the path \"404\".\n # # set req.url = \"\/403\";\n # }\n\n \/* 8th: Custom exceptions *\/\n # Host exception example:\n # if (req.http.host == \"ejemplo.exception.com\") {\n # return (pass);\n # }\n # Drupal exceptions, edit if we want to cache some AJAX\/AHAH request.\n # Add here filters for never cache URLs such as Payment Gateway's callbacks\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/ooyala\/ping$\" ||\n req.url ~ \"^\/admin\/build\/features\" ||\n req.url ~ \"^\/info\/.*$\" ||\n req.url ~ \"^\/flag\/.*$\" ||\n req.url ~ \"^.*\/ajax\/.*$\" ||\n req.url ~ \"^.*\/ahah\/.*$\") {\n \/* Do not cache these paths *\/\n return (pass);\n }\n # Pipe these paths directly to backend for streaming.\n if (req.url ~ \"^\/admin\/content\/backup_migrate\/export\") {\n return (pipe);\n }\n if (req.url ~ \"^\/system\/files\") {\n return (pipe);\n }\n\n \/* 9th: Enable grace mode *\/\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/handling_misbehaving_servers.html#grace-mode\n if (! req.backend.healthy) {\n \/* Use a longer grace period if all backends are down *\/\n set req.grace = 1h;\n \/* Use anonymous, cached pages if all backends are down. *\/\n unset req.http.Cookie;\n # TO-DO: Add sick marker\n } else {\n \/* Allow the backend to serve up stale content if it is responding slowly. *\/\n set req.grace = 30s;\n }\n\n \/* 10th: Deal with compression and the Accept-Encoding header *\/\n # Althought Varnish 3 handles gziped content itself by default, just to be sure we want to \n # remove Accept-Encoding for some compressed formats.\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/phk\/gzip.html#what-does-http-gzip-support-do\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/varnishd.html?highlight=http_gzip_support\n # See (for older configs) https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleNormalizeAcceptEncoding\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|mp4|flv|zip|rar)$\") {\n \/* Already compressed formats, no sense trying to compress again *\/\n remove req.http.Accept-Encoding;\n }\n }\n\n \/* 11th: Another header manipulation *\/\n # Empty in simple configs.\n # We could add here a custom header grouping User-agent families.\n\n \/* 12th: Cookie removal *\/\n # Always cache the following static file types for all users. \n # Use with care if we control certain downloads depending on cookies. \n # Be carefull also if appending .htm[l] via Drupal's clean URLs.\n if ( req.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n && req.url !~ \"\/system\/storage\/serve\"\n ) {\n unset req.http.Cookie;\n }\n # Remove all cookies that backend doesn't need to know about.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRemovingSomeCookies\n if (req.http.Cookie) {\n \/* Warning: Not a pretty solution *\/\n \/* Prefix header containing cookies with ';' *\/\n set req.http.Cookie = \";\" + req.http.Cookie;\n \/* Remove any spaces after ';' in header containing cookies *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n \/* Prefix cookies we want to preserve with one space *\/\n \/* 'S{1,2}ESS[a-z0-9]+' is the regular expression matching a Drupal session cookie ({1,2} added for HTTPS support) *\/\n \/* 'NO_CACHE' is usually set after a POST request to make sure issuing user see the results of his post *\/\n \/* 'OATMEAL' & 'CHOCOLATECHIP' are special cookies used by Drupal's Bakery module to provide Single Sign On *\/\n \/* Keep in mind we should add here any cookie that should reach the backend such as splahs avoiding cookies *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \";(S{1,2}ESS[a-z0-9]+|NO_CACHE|OATMEAL|CHOCOLATECHIP)=\", \"; \\1=\");\n \/* Remove from the header any single Cookie not prefixed with a space until next ';' separator *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n \/* Remove any '; ' at the start or the end of the header *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n\n if (req.http.Cookie == \"\") {\n \/* If there are no remaining cookies, remove the cookie header. *\/\n unset req.http.Cookie;\n }\n }\n\n \/* 13th: Session cookie & special cookies bypass caching stage *\/\n # As we might want to cache some requests, hashed with its cookies, \n # we don't simply pass when some cookies remain present at this point.\n # Instead we look for request that must be passed due to the cookie header.\n if (req.http.Cookie ~ \"SESS\" ||\n req.http.Cookie ~ \"SSESS\" ||\n req.http.Cookie ~ \"NO_CACHE\" ||\n req.http.Cookie ~ \"OATMEAL\" ||\n req.http.Cookie ~ \"CHOCOLATECHIP\") {\n return (pass);\n }\n\n \/* 14th: Bypass breakpoint 2 *\/\n # Useful for debugging we can now pipe or pass the request to backend to bypass cache.\n # return (pipe);\n # return (pass);\n\n \/* 15th: Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning a lookup.\n return (lookup);\n}\n\n# vcl_pipe: Called upon entering pipe mode.\n# In this mode, the request is passed on to the backend, \n# and any further data from either client or backend is passed on unaltered until either end closes the connection.\nsub vcl_pipe {\n \/* Prevent connection re-using for piped requests *\/\n # Note that only the first request to the backend will have X-Forwarded-For set.\n # As we use X-Forwarded-For and want to have it set for all requests, \n # we have to make sure connection won't be reused after the request.\n # It is not set by default as it might break some broken web applications, like IIS with NTLM authentication.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExamplePipe\n # TO-DO: make sure this is compatible with websockets piping,\n # reference https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/websockets.html\n set bereq.http.connection = \"close\";\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this point.\n return (pipe);\n}\n\n# vcl_pass: Called upon entering pass mode. \n# In this mode, the request is passed on to the backend, and the backend's response is passed on to the client, \n# but is not entered into the cache.\n# Subsequent requests submitted over the same client connection are handled normally.\n# sub vcl_pass {\n# return (pass);\n# }\n\n# vcl_hash: You may call hash_data() on the data you would like to add to the hash.\n# Hash is used by Varnish to uniquely identify objects.\nsub vcl_hash {\n \/* Hash cookie data *\/\n # As requests with same URL and host can produce diferent results when issued with different cookies,\n # we need to store items hashed with the associated cookies. Note that cookies are already sanitized when we reach this point.\n if (req.http.Cookie) {\n \/* Include cookie in cache hash *\/\n hash_data(req.http.Cookie);\n }\n\n \/* Custom header hashing *\/\n # Empty in simple configs.\n # Example for caching differents object versions by device previously detected (when static content could also vary):\n # if (req.http.X-UA-Device) {\n # hash_data(req.http.X-UA-Device);\n # }\n # Example for caching diferent object versions by X-Forwarded-Proto, trying to be smart about what kind of request\n # could generate diffetent responses.\n # if (req.http.X-Forwarded-Proto &&\n # req.url !~ \"(?i)\\.(png|gif|jpeg|jpg|ico|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|svg|pdf)$\") {\n # hash_data(req.http.X-Forwarded-Proto);\n # }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (hash);\n# }\n\n# vcl_hit: Called after a cache lookup if the requested document was found in the cache.\nsub vcl_hit {\n \/* Check for Varnish special requests *\/ \n # Purge logic.\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/purging.html#http-purges\n # See https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged.\";\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hit {\n# return (deliver);\n# }\n\n# vcl_miss: Called after a cache lookup if the requested document was not found in the cache.\n# Its purpose is to decide whether or not to attempt to retrieve the document from the backend, and which backend to use.\nsub vcl_miss {\n \/* Check for Varnish special requests *\/ \n # Purge logic.\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/purging.html#http-purges\n # See https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged.\";\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_miss {\n# return (fetch);\n# }\n\n# vcl_fetch: Called after a document has been successfully retrieved from the backend.\nsub vcl_fetch {\n \/* Caching exceptions *\/\n # Varnish will cache objects with response codes: 200, 203, 300, 301, 302, 307, 404 & 410.\n # See https:\/\/www.varnish-software.com\/static\/book\/VCL_Basics.html#the-initial-value-of-beresp-ttl\n # Drupal's Imagecache module can return a 307 redirection to the requested url itself and, depending on Drupal's cache settings,\n # this could lead to a redirection loop being cached for a long time but also we want Varnish to shield a little the backend.\n # See http:\/\/drupal.org\/node\/1248010\n # See http:\/\/drupal.org\/node\/310656\n if (beresp.status == 307 &&\n \/* TO-DO: verify that this work better than 'req.url ~ \"imagecache\"' *\/\n beresp.http.Location == req.url &&\n beresp.ttl > 5s) {\n set beresp.ttl = 5s;\n set beresp.http.cache-control = \"max-age=5\";\n }\n\n \/* Enable grace mode. Related with our 9th stage on vcl_recv *\/\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/handling_misbehaving_servers.html#grace-mode\n set beresp.grace = 1h;\n\n \/* Enable saint mode. Related with our 9th stage on vcl_recv *\/\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/handling_misbehaving_servers.html#saint-mode\n if (beresp.status == 500) {\n set beresp.saintmode = 20s;\n # TO-DO: consider not restarting POST requests as seen on https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleSaintMode\n return(restart);\n }\n\n \/* Strip cookies from the following static file types for all users. Related with our 12th stage on vcl_recv *\/\n if (req.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\") {\n unset beresp.http.set-cookie;\n }\n\n \/* Gzip response *\/\n # Empty in simple configs\n # Use Varnish to Gzip respone, if suitable, before storing it on cache\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/phk\/gzip.html\n # if (! beresp.http.Content-Encoding &&\n # (beresp.http.content-type ~ \"text\" ||\n # beresp.http.content-type ~ \"application\/x-javascript\" ||\n # beresp.http.content-type ~ \"application\/javascript\" ||\n # beresp.http.content-type ~ \"application\/rss+xml\" ||\n # beresp.http.content-type ~ \"application\/xml\" ||\n # beresp.http.content-type ~ \"Application\/JSON\")\n # ) {\n # set beresp.do_gzip = true;\n # if ( beresp.http.Vary ) {\n # if ( ! beresp.http.Vary ~ \"Accept-Encoding\" ) {\n # set beresp.http.Vary = beresp.http.Vary + \",Accept-Encoding\";\n # }\n # } else {\n # set beresp.http.Vary = \"Accept-Encoding\";\n # }\n # }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # We can add the name of the backend that has processed the request:\n # set beresp.http.X-Backend = beresp.backend.name;\n # We can use a header to tell if the object was gziped by Varnish\n # if (beresp.do_gzip) {\n # set beresp.http.X-Varnish-Gzipped = \"yes\";\n # } else {\n # set beresp.http.X-Varnish-Gizipped = \"no\";\n # }\n # We can also add headers informing whether the object is cacheable or not and why.\n # https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Varnish3.0\n if (beresp.ttl <= 0s) {\n \/* Varnish determined the object was not cacheable *\/\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n } elsif (req.http.Cookie ~ \"(SESS|SSESS|NO_CACHE|OATMEAL|CHOCOLATECHIP)\") {\n \/* We don't wish to cache content for logged in users or with certain cookies. Related with our 9th stage on vcl_recv *\/\n set beresp.http.X-Cacheable = \"NO:Cookies\";\n # return(hit_for_pass);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n \/* We are respecting the Cache-Control=private header from the backend *\/\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n # return(hit_for_pass);\n } else {\n \/* Varnish determined the object was cacheable *\/\n set beresp.http.X-Cacheable = \"YES\";\n }\n\n \/* Further header manipulation *\/\n # Empty in simple configs.\n # We can also unset some headers to prevent information disclosure and save some cache space\n # unset beresp.http.Server;\n # unset beresp.http.X-Powered-By;\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_fetch {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Vary == \"*\") {\n# \/*\n# * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# *\/\n# set beresp.ttl = 120 s;\n# return (hit_for_pass);\n# }\n# return (deliver);\n# }\n\n# vcl_deliver: Called before an object is delivered to the client\nsub vcl_deliver {\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # Add whether the object is a cache hit or miss and the number of hits for the object.\n # https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Addingaheaderindicatinghitmiss\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n set resp.http.X-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Cache = \"MISS\";\n \/* Show the results of cookie sanitization *\/\n set resp.http.X-Cookie = req.http.Cookie;\n }\n # TO-DO: Add sick marker\n # Restart count\n if ( req.restarts > 0) {\n set resp.http.X-Restarts = req.restarts;\n }\n # Add the Varnish server hostname\n set resp.http.X-Varnish-Server = server.hostname;\n # If we have setted a custom header with device family detected we can show it:\n # if (req.http.X-UA-Device) {\n # set resp.http.X-UA-Device = req.http.X-UA-Device;\n # }\n # If we have recived a custom header with the protocol in the request we can show it:\n # if (req.http.X-Forwarded-Proto) {\n # set resp.http.X-Forwarded-Proto = req.http.X-Forwarded-Proto;\n # }\n\n \/* Vary header manipulation *\/\n # Empty in simple configs.\n # By example, if we are storing & serving diferent objects depending on User-Agent header we must set the correct Vary header:\n # if (resp.http.Vary) {\n # set resp.http.Vary = resp.http.Vary + \",User-Agent\";\n # } else {\n # set resp.http.Vary = \"User-Agent\";\n # }\n\n \/* Fake headers *\/\n # Empty in simple configs\n # We can fake server headers here, by example:\n # set resp.http.Server = \"Deep thought\";\n # set resp.http.X-Powered-By = \"BOFH\";\n # Or have some fun with headers:\n # See http:\/\/www.nextthing.org\/archives\/2005\/08\/07\/fun-with-http-headers\n # See http:\/\/royal.pingdom.com\/2012\/08\/15\/fun-and-unusual-http-response-headers\/\n # set resp.http.X-Thank-You = \"for bothering to look at my HTTP headers\";\n # set resp.http.X-Answer = \"42\";\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_deliver {\n# return (deliver);\n# }\n\n# vcl_error: Called when we hit an error, either explicitly or implicitly due to backend or internal errors.\nsub vcl_error {\n \/* Avoid DOS vulnerability CVE-2013-4484 *\/\n # See https:\/\/www.varnish-cache.org\/lists\/pipermail\/varnish-announce\/2013-October\/000686.html\n if (obj.status == 400 || obj.status == 413) {\n return(deliver);\n }\n\n \/* Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_error;\n\n \/* Try to restart request in case of failure *\/\n # Note that max_restarts defaults to 4\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if (obj.status == 503 && req.restarts < 4) {\n set obj.http.X-Restarts = req.restarts;\n return(restart);\n }\n\n \/* Set common headers for synthetic responses *\/\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n\n \/* HTTP Authentification client request *\/\n # Empty in simple configs. See http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* We're using error 200 for monitoring puposes *\/\n # Consider adding some analytics stuff to trace accesses\n if (obj.status == 200) {\n synthetic {\"\n <?xml version=\"1.0\" encoding=\"utf-8\"?>\n <!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n <html>\n <head>\n <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n <\/head>\n <body><h1>\"} + obj.status + \": \" + obj.response + {\"<\/h1><\/body>\n \"};\n return(deliver);\n }\n\n \/* Error page & refresh \/ redirections *\/\n # We have plenty of choices when we have to serve an error to the client, \n # from the default error page to javascript black magic or plain redirections.\n # Adding some external statistic javascript to track failures served to clients is strongly suggested.\n # We can't use external resources on synthetic content, everything must be inlined.\n # If we need to include images we can embed them in base64 encoding.\n # Here is the default error page for Varnish 3 (not so pretty)\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + obj.status + \" \" + obj.response + {\"<\/h1>\n <p>\"} + obj.response + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"};\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this point.\n return (deliver);\n}\n\n# vcl_init: Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n# sub vcl_init {\n# return (ok);\n# }\n\n# vcl_fini: Called when VCL is discarded only after all requests have exited the VCL. Typically used to clean up VMODs.\n# sub vcl_fini {\n# return (ok);\n# }\n","old_contents":"\/* Varnish 3 example config for Drupal 7 \/ Pressflow 6 & 7 *\/\n# Original source: https:\/\/github.com\/NITEMAN\/varnish-bites\/varnish4\/drupal-base.vcl\n# Copyright (c) 2015 Pedro Gonz\u00e1lez Serrano and individual contributors.\n# MIT License\n\n# Intended to be used both in simple production environments and with learning\/teaching purposes.\n# Loosely based on http:\/\/www.lullabot.com\/sites\/default\/files\/default_varnish3.vcl_.txt\n\n\/* Backend probes \/ healthchecks *\/\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#backend-probes\nprobe basic {\n \/* Only test that backend's IP serves content for '\/' *\/\n # This might be a too heavy probe\n # .url = \"\/\";\n \/* Only test that backend's IP has apache working *\/\n # Nginx would fail this probe with a default config\n .request =\n \"OPTIONS * HTTP\/1.1\"\n \"Host: *\"\n \"Connection: close\";\n .interval = 10s;\n .timeout = 2s;\n .window = 8;\n .threshold = 6;\n}\n\n\n\/* Backend definitions.*\/\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#backend-declarations\nbackend default {\n \/* Default backend on the same machine. WARNING: timeouts could be not big enought for certain POST request *\/\n .host = \"127.0.0.1\";\n .port = \"8008\";\n .connect_timeout = 60s;\n .first_byte_timeout = 60s;\n .between_bytes_timeout = 60s;\n .probe = basic;\n}\n\n\n\/* Directors. *\/\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#directors\n# Empty in simple configs\n\n\n\/* Access Control Lists *\/\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#acls\nacl purge_ban {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use '\"localhost\";' instead\n}\nacl allowed_monitors {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n}\nacl own_proxys {\n \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n}\n\n\n\/* Custom routines *\/\n# Empty in simple configs.\n# We can name subs with no restrictions but as a task can need several chunks of code in diferent states,\n# it's a good idea to identify what main sub will call each with a suffix.\n# \/* Example 301 client redirection removing \"www\" prefix from request *\/\n# sub perm_redirections_recv {\n# if ( req.http.host ~ \"^www.*$\" ) {\n# error 751 \"http:\/\/\" + regsub(req.http.host, \"^www\\.\", \"\") + req.url;\n# }\n# }\n# sub perm_redirections_error {\n# if (obj.status == 751) {\n# \/* Get new URL from the response *\/\n# set obj.http.Location = obj.response;\n# \/* Set HTTP 301 for permanent redirect *\/\n# set obj.status = 301;\n# return(deliver);\n# }\n# }\n\n\n\/* VCL logigc overrides *\/\n# Note that the built-in logic will be appended to our code if no return is performed before.\n# Built-in logic is included commented out right after our's for reference purposes in that cases.\n# See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleDefault\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#subroutines\n\n# vcl_recv: Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use.\nsub vcl_recv {\n \/* 0th: general bypass, general return & authorization checks *\/\n # Empty in simple configs.\n # Useful for debugging we can pipe or pass the request to default backend here to bypass completely Varnish.\n # return (pipe);\n # return (pass);\n # We can also return here a 200 Ok for network performance benchmarking.\n # error 200 \"Ok\";\n # Finally we can perform basic HTTP authentification here by example.\n # See http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* 1st: Check for Varnish special requests *\/ \n # Purge logic.\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/purging.html#http-purges\n # See https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if (req.request == \"PURGE\") {\n if (!client.ip ~ purge_ban) {\n error 405 \"Not allowed.\";\n }\n return (lookup);\n }\n # Ban logic. See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/purging.html#bans\n if (req.request == \"BAN\") {\n if (!client.ip ~ purge_ban) {\n error 405 \"Not allowed.\";\n }\n ban(\"req.http.host == \" + req.http.host +\n \"&& req.url == \" + req.url); \n error 200 \"Ban added\";\n }\n # Custom response implementation example in order to check that Varnish is working properly.\n # This is usefull for automatic monitoring with monit or when Varnish is behind another proxies like HAProxy.\n if ( ( req.http.host == \"monitor.server.health\"\n || req.http.host == \"health.varnish\" )\n && client.ip ~ allowed_monitors\n && ( req.request == \"OPTIONS\" || req.request == \"GET\" )\n ) {\n error 200 \"Ok\";\n }\n\n \/* 2nd: Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_recv;\n # Here we can also enforce SSL when Varnish run behind some SSL termination point.\n\n \/* 3rd: Time for backend choice *\/\n # Empty in simple configs.\n\n \/* 4th: Set custom headers for backend like X-Forwarded-For (copied from built-in logic) *\/\n if ( req.restarts == 0 ) {\n \/* See also vcl_pipe section *\/\n if ( ! client.ip ~ own_proxys ) {\n if ( req.http.x-forwarded-for ) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n }\n\n \/* 5th: Bypass breakpoint 1 *\/\n # Useful for debugging we can now pipe or pass the request to backend with headers setted.\n # return (pipe);\n # return (pass);\n\n \/* 6th: Decide if we should deal with a request (mostly copied from built-in logic) *\/\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n\n \/* 7th: Access control for some URLs by ACL *\/\n # Empty in simple configs.\n # By example denial some URLs depending on client-ip, we'll need to define corresponding ACL 'internal'.\n # if (req.url ~ \"^\/(cron|install)\\.php$\" && !client.ip ~ internal) {\n # # Have Varnish throw the error directly.\n # error 403 \"Forbidden.\";\n # # Use a custom error page that you've defined in Drupal at the path \"404\".\n # # set req.url = \"\/403\";\n # }\n\n \/* 8th: Custom exceptions *\/\n # Host exception example:\n # if (req.http.host == \"ejemplo.exception.com\") {\n # return (pass);\n # }\n # Drupal exceptions, edit if we want to cache some AJAX\/AHAH request.\n # Add here filters for never cache URLs such as Payment Gateway's callbacks\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/ooyala\/ping$\" ||\n req.url ~ \"^\/admin\/build\/features\" ||\n req.url ~ \"^\/info\/.*$\" ||\n req.url ~ \"^\/flag\/.*$\" ||\n req.url ~ \"^.*\/ajax\/.*$\" ||\n req.url ~ \"^.*\/ahah\/.*$\") {\n \/* Do not cache these paths *\/\n return (pass);\n }\n # Pipe these paths directly to backend for streaming.\n if (req.url ~ \"^\/admin\/content\/backup_migrate\/export\") {\n return (pipe);\n }\n if (req.url ~ \"^\/system\/files\") {\n return (pipe);\n }\n\n \/* 9th: Enable grace mode *\/\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/handling_misbehaving_servers.html#grace-mode\n if (! req.backend.healthy) {\n \/* Use a longer grace period if all backends are down *\/\n set req.grace = 1h;\n \/* Use anonymous, cached pages if all backends are down. *\/\n unset req.http.Cookie;\n # TO-DO: Add sick marker\n } else {\n \/* Allow the backend to serve up stale content if it is responding slowly. *\/\n set req.grace = 30s;\n }\n\n \/* 10th: Deal with compression and the Accept-Encoding header *\/\n # Althought Varnish 3 handles gziped content itself by default, just to be sure we want to \n # remove Accept-Encoding for some compressed formats.\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/phk\/gzip.html#what-does-http-gzip-support-do\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/varnishd.html?highlight=http_gzip_support\n # See (for older configs) https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleNormalizeAcceptEncoding\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|mp4|flv|zip|rar)$\") {\n \/* Already compressed formats, no sense trying to compress again *\/\n remove req.http.Accept-Encoding;\n }\n }\n\n \/* 11th: Another header manipulation *\/\n # Empty in simple configs.\n # We could add here a custom header grouping User-agent families.\n\n \/* 12th: Cookie removal *\/\n # Always cache the following static file types for all users. \n # Use with care if we control certain downloads depending on cookies. \n # Be carefull also if appending .htm[l] via Drupal's clean URLs.\n if (req.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|svg|pdf)(\\?[a-z0-9]+)?$\") {\n unset req.http.Cookie;\n }\n # Remove all cookies that backend doesn't need to know about.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRemovingSomeCookies\n if (req.http.Cookie) {\n \/* Warning: Not a pretty solution *\/\n \/* Prefix header containing cookies with ';' *\/\n set req.http.Cookie = \";\" + req.http.Cookie;\n \/* Remove any spaces after ';' in header containing cookies *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n \/* Prefix cookies we want to preserve with one space *\/\n \/* 'S{1,2}ESS[a-z0-9]+' is the regular expression matching a Drupal session cookie ({1,2} added for HTTPS support) *\/\n \/* 'NO_CACHE' is usually set after a POST request to make sure issuing user see the results of his post *\/\n \/* 'OATMEAL' & 'CHOCOLATECHIP' are special cookies used by Drupal's Bakery module to provide Single Sign On *\/\n \/* Keep in mind we should add here any cookie that should reach the backend such as splahs avoiding cookies *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \";(S{1,2}ESS[a-z0-9]+|NO_CACHE|OATMEAL|CHOCOLATECHIP)=\", \"; \\1=\");\n \/* Remove from the header any single Cookie not prefixed with a space until next ';' separator *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n \/* Remove any '; ' at the start or the end of the header *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n\n if (req.http.Cookie == \"\") {\n \/* If there are no remaining cookies, remove the cookie header. *\/\n unset req.http.Cookie;\n }\n }\n\n \/* 13th: Session cookie & special cookies bypass caching stage *\/\n # As we might want to cache some requests, hashed with its cookies, \n # we don't simply pass when some cookies remain present at this point.\n # Instead we look for request that must be passed due to the cookie header.\n if (req.http.Cookie ~ \"SESS\" ||\n req.http.Cookie ~ \"SSESS\" ||\n req.http.Cookie ~ \"NO_CACHE\" ||\n req.http.Cookie ~ \"OATMEAL\" ||\n req.http.Cookie ~ \"CHOCOLATECHIP\") {\n return (pass);\n }\n\n \/* 14th: Bypass breakpoint 2 *\/\n # Useful for debugging we can now pipe or pass the request to backend to bypass cache.\n # return (pipe);\n # return (pass);\n\n \/* 15th: Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning a lookup.\n return (lookup);\n}\n\n# vcl_pipe: Called upon entering pipe mode.\n# In this mode, the request is passed on to the backend, \n# and any further data from either client or backend is passed on unaltered until either end closes the connection.\nsub vcl_pipe {\n \/* Prevent connection re-using for piped requests *\/\n # Note that only the first request to the backend will have X-Forwarded-For set.\n # As we use X-Forwarded-For and want to have it set for all requests, \n # we have to make sure connection won't be reused after the request.\n # It is not set by default as it might break some broken web applications, like IIS with NTLM authentication.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExamplePipe\n # TO-DO: make sure this is compatible with websockets piping,\n # reference https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/websockets.html\n set bereq.http.connection = \"close\";\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this point.\n return (pipe);\n}\n\n# vcl_pass: Called upon entering pass mode. \n# In this mode, the request is passed on to the backend, and the backend's response is passed on to the client, \n# but is not entered into the cache.\n# Subsequent requests submitted over the same client connection are handled normally.\n# sub vcl_pass {\n# return (pass);\n# }\n\n# vcl_hash: You may call hash_data() on the data you would like to add to the hash.\n# Hash is used by Varnish to uniquely identify objects.\nsub vcl_hash {\n \/* Hash cookie data *\/\n # As requests with same URL and host can produce diferent results when issued with different cookies,\n # we need to store items hashed with the associated cookies. Note that cookies are already sanitized when we reach this point.\n if (req.http.Cookie) {\n \/* Include cookie in cache hash *\/\n hash_data(req.http.Cookie);\n }\n\n \/* Custom header hashing *\/\n # Empty in simple configs.\n # Example for caching differents object versions by device previously detected (when static content could also vary):\n # if (req.http.X-UA-Device) {\n # hash_data(req.http.X-UA-Device);\n # }\n # Example for caching diferent object versions by X-Forwarded-Proto, trying to be smart about what kind of request\n # could generate diffetent responses.\n # if (req.http.X-Forwarded-Proto &&\n # req.url !~ \"(?i)\\.(png|gif|jpeg|jpg|ico|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|svg|pdf)$\") {\n # hash_data(req.http.X-Forwarded-Proto);\n # }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (hash);\n# }\n\n# vcl_hit: Called after a cache lookup if the requested document was found in the cache.\nsub vcl_hit {\n \/* Check for Varnish special requests *\/ \n # Purge logic.\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/purging.html#http-purges\n # See https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged.\";\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hit {\n# return (deliver);\n# }\n\n# vcl_miss: Called after a cache lookup if the requested document was not found in the cache.\n# Its purpose is to decide whether or not to attempt to retrieve the document from the backend, and which backend to use.\nsub vcl_miss {\n \/* Check for Varnish special requests *\/ \n # Purge logic.\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/purging.html#http-purges\n # See https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged.\";\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_miss {\n# return (fetch);\n# }\n\n# vcl_fetch: Called after a document has been successfully retrieved from the backend.\nsub vcl_fetch {\n \/* Caching exceptions *\/\n # Varnish will cache objects with response codes: 200, 203, 300, 301, 302, 307, 404 & 410.\n # See https:\/\/www.varnish-software.com\/static\/book\/VCL_Basics.html#the-initial-value-of-beresp-ttl\n # Drupal's Imagecache module can return a 307 redirection to the requested url itself and, depending on Drupal's cache settings,\n # this could lead to a redirection loop being cached for a long time but also we want Varnish to shield a little the backend.\n # See http:\/\/drupal.org\/node\/1248010\n # See http:\/\/drupal.org\/node\/310656\n if (beresp.status == 307 &&\n \/* TO-DO: verify that this work better than 'req.url ~ \"imagecache\"' *\/\n beresp.http.Location == req.url &&\n beresp.ttl > 5s) {\n set beresp.ttl = 5s;\n set beresp.http.cache-control = \"max-age=5\";\n }\n\n \/* Enable grace mode. Related with our 9th stage on vcl_recv *\/\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/handling_misbehaving_servers.html#grace-mode\n set beresp.grace = 1h;\n\n \/* Enable saint mode. Related with our 9th stage on vcl_recv *\/\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/handling_misbehaving_servers.html#saint-mode\n if (beresp.status == 500) {\n set beresp.saintmode = 20s;\n # TO-DO: consider not restarting POST requests as seen on https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleSaintMode\n return(restart);\n }\n\n \/* Strip cookies from the following static file types for all users. Related with our 12th stage on vcl_recv *\/\n if (req.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|svg|pdf)(\\?[a-z0-9]+)?$\") {\n unset beresp.http.set-cookie;\n }\n\n \/* Gzip response *\/\n # Empty in simple configs\n # Use Varnish to Gzip respone, if suitable, before storing it on cache\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/phk\/gzip.html\n # if (! beresp.http.Content-Encoding &&\n # (beresp.http.content-type ~ \"text\" ||\n # beresp.http.content-type ~ \"application\/x-javascript\" ||\n # beresp.http.content-type ~ \"application\/javascript\" ||\n # beresp.http.content-type ~ \"application\/rss+xml\" ||\n # beresp.http.content-type ~ \"application\/xml\" ||\n # beresp.http.content-type ~ \"Application\/JSON\")\n # ) {\n # set beresp.do_gzip = true;\n # if ( beresp.http.Vary ) {\n # if ( ! beresp.http.Vary ~ \"Accept-Encoding\" ) {\n # set beresp.http.Vary = beresp.http.Vary + \",Accept-Encoding\";\n # }\n # } else {\n # set beresp.http.Vary = \"Accept-Encoding\";\n # }\n # }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # We can add the name of the backend that has processed the request:\n # set beresp.http.X-Backend = beresp.backend.name;\n # We can use a header to tell if the object was gziped by Varnish\n # if (beresp.do_gzip) {\n # set beresp.http.X-Varnish-Gzipped = \"yes\";\n # } else {\n # set beresp.http.X-Varnish-Gizipped = \"no\";\n # }\n # We can also add headers informing whether the object is cacheable or not and why.\n # https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Varnish3.0\n if (beresp.ttl <= 0s) {\n \/* Varnish determined the object was not cacheable *\/\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n } elsif (req.http.Cookie ~ \"(SESS|SSESS|NO_CACHE|OATMEAL|CHOCOLATECHIP)\") {\n \/* We don't wish to cache content for logged in users or with certain cookies. Related with our 9th stage on vcl_recv *\/\n set beresp.http.X-Cacheable = \"NO:Cookies\";\n # return(hit_for_pass);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n \/* We are respecting the Cache-Control=private header from the backend *\/\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n # return(hit_for_pass);\n } else {\n \/* Varnish determined the object was cacheable *\/\n set beresp.http.X-Cacheable = \"YES\";\n }\n\n \/* Further header manipulation *\/\n # Empty in simple configs.\n # We can also unset some headers to prevent information disclosure and save some cache space\n # unset beresp.http.Server;\n # unset beresp.http.X-Powered-By;\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_fetch {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Vary == \"*\") {\n# \/*\n# * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# *\/\n# set beresp.ttl = 120 s;\n# return (hit_for_pass);\n# }\n# return (deliver);\n# }\n\n# vcl_deliver: Called before an object is delivered to the client\nsub vcl_deliver {\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # Add whether the object is a cache hit or miss and the number of hits for the object.\n # https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Addingaheaderindicatinghitmiss\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n set resp.http.X-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Cache = \"MISS\";\n \/* Show the results of cookie sanitization *\/\n set resp.http.X-Cookie = req.http.Cookie;\n }\n # TO-DO: Add sick marker\n # Restart count\n if ( req.restarts > 0) {\n set resp.http.X-Restarts = req.restarts;\n }\n # Add the Varnish server hostname\n set resp.http.X-Varnish-Server = server.hostname;\n # If we have setted a custom header with device family detected we can show it:\n # if (req.http.X-UA-Device) {\n # set resp.http.X-UA-Device = req.http.X-UA-Device;\n # }\n # If we have recived a custom header with the protocol in the request we can show it:\n # if (req.http.X-Forwarded-Proto) {\n # set resp.http.X-Forwarded-Proto = req.http.X-Forwarded-Proto;\n # }\n\n \/* Vary header manipulation *\/\n # Empty in simple configs.\n # By example, if we are storing & serving diferent objects depending on User-Agent header we must set the correct Vary header:\n # if (resp.http.Vary) {\n # set resp.http.Vary = resp.http.Vary + \",User-Agent\";\n # } else {\n # set resp.http.Vary = \"User-Agent\";\n # }\n\n \/* Fake headers *\/\n # Empty in simple configs\n # We can fake server headers here, by example:\n # set resp.http.Server = \"Deep thought\";\n # set resp.http.X-Powered-By = \"BOFH\";\n # Or have some fun with headers:\n # See http:\/\/www.nextthing.org\/archives\/2005\/08\/07\/fun-with-http-headers\n # See http:\/\/royal.pingdom.com\/2012\/08\/15\/fun-and-unusual-http-response-headers\/\n # set resp.http.X-Thank-You = \"for bothering to look at my HTTP headers\";\n # set resp.http.X-Answer = \"42\";\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_deliver {\n# return (deliver);\n# }\n\n# vcl_error: Called when we hit an error, either explicitly or implicitly due to backend or internal errors.\nsub vcl_error {\n \/* Avoid DOS vulnerability CVE-2013-4484 *\/\n # See https:\/\/www.varnish-cache.org\/lists\/pipermail\/varnish-announce\/2013-October\/000686.html\n if (obj.status == 400 || obj.status == 413) {\n return(deliver);\n }\n\n \/* Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_error;\n\n \/* Try to restart request in case of failure *\/\n # Note that max_restarts defaults to 4\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if (obj.status == 503 && req.restarts < 4) {\n set obj.http.X-Restarts = req.restarts;\n return(restart);\n }\n\n \/* Set common headers for synthetic responses *\/\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n\n \/* HTTP Authentification client request *\/\n # Empty in simple configs. See http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* We're using error 200 for monitoring puposes *\/\n # Consider adding some analytics stuff to trace accesses\n if (obj.status == 200) {\n synthetic {\"\n <?xml version=\"1.0\" encoding=\"utf-8\"?>\n <!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n <html>\n <head>\n <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n <\/head>\n <body><h1>\"} + obj.status + \": \" + obj.response + {\"<\/h1><\/body>\n \"};\n return(deliver);\n }\n\n \/* Error page & refresh \/ redirections *\/\n # We have plenty of choices when we have to serve an error to the client, \n # from the default error page to javascript black magic or plain redirections.\n # Adding some external statistic javascript to track failures served to clients is strongly suggested.\n # We can't use external resources on synthetic content, everything must be inlined.\n # If we need to include images we can embed them in base64 encoding.\n # Here is the default error page for Varnish 3 (not so pretty)\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + obj.status + \" \" + obj.response + {\"<\/h1>\n <p>\"} + obj.response + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"};\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this point.\n return (deliver);\n}\n\n# vcl_init: Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n# sub vcl_init {\n# return (ok);\n# }\n\n# vcl_fini: Called when VCL is discarded only after all requests have exited the VCL. Typically used to clean up VMODs.\n# sub vcl_fini {\n# return (ok);\n# }\n","returncode":0,"stderr":"","license":"unknown","lang":"VCL"} {"commit":"3e6deae71413dcd6afadf00c9ca4da374fb2f5af","subject":"restore original implementation of normalise_querystring_parameters_for_polyfill_bundle","message":"restore original implementation of normalise_querystring_parameters_for_polyfill_bundle\n","repos":"JakeChampion\/polyfill-service,JakeChampion\/polyfill-service","old_file":"fastly\/vcl\/main.vcl","new_file":"fastly\/vcl\/main.vcl","new_contents":"import querystring;\n\nsub sort_comma_separated_value {\n\t# This function takes a CSV and tranforms it into a url where each\n\t# comma-separated-value is a query-string parameter and then uses\n\t# Fastly's querystring.sort function to sort the values. Once sorted\n\t# it then turn the query-parameters back into a CSV.\n\t# Set the CSV on the header `Sort-Value`.\n\t# Returns the sorted CSV on the header `Sorted-Value`.\n\tdeclare local var.value STRING;\n\tset var.value = req.http.Sort-value;\n\n\t# If query value does not exist or is empty, set it to \"\"\n\tset var.value = if(var.value != \"\", var.value, \"\");\n\n\t# Replace all `&` characters with `^`, this is because `&` would break the value up into pieces.\n\tset var.value = regsuball(var.value, \"&\", \"^\");\n\n\t# Replace all `,` characters with `&` to break them into individual query values\n\t# Append `1-` infront of all the query values to make them simpler to transform later\n\tset var.value = \"1-\" regsuball(var.value, \",\", \"&1-\");\n\n\t# Create a querystring-like string in order for querystring.sort to work.\n\tset var.value = querystring.sort(\"?\" var.value);\n\n\t# Grab all the query values from the sorted url\n\tset var.value = regsub(var.value, \"\\?\", \"\");\n\n\t# Reverse all the previous transformations to get back the single `features` query value value\n\tset var.value = regsuball(var.value, \"1-\", \"\");\n\tset var.value = regsuball(var.value, \"&\", \",\");\n\tset var.value = regsuball(var.value, \"\\^\", \"&\");\n\n\tset req.http.Sorted-Value = var.value;\n}\n\nsub normalise_querystring_parameters_for_polyfill_bundle {\n\t# Store the url without the querystring into a temporary header.\n\tdeclare local var.url STRING;\n\tset var.url = querystring.remove(req.url);\n\n\tdeclare local var.querystring STRING;\n\tset var.querystring = \"?\";\n\n\t# Remove all querystring parameters which are not part of the public API.\n\t# set req.url = querystring.regfilter_except(req.url, \"^(features|excludes|rum|unknown|flags|version|ua|callback|compression)$\");\n\n\t# (?i) makes the regex case-insensitive\n\t# The regex will match only if their are characters after `features=` which are not an ampersand (&).\n\tif (req.url.qs ~ \"(?i)[^&=]*features=([^&]+)\") {\n\t\t# Parameter has already been set, use the already set value.\n\t\t# re.group.1 is the first regex capture group in the regex above.\n\t\tif (std.strlen(re.group.1) < 100) {\n\t\t\t# We add the value of the features parameter to this header\n\t\t\t# This is to be able to have sort_comma_separated_value sort the value\n\t\t\tset req.http.Sort-Value = urldecode(re.group.1);\n\t\t\tcall sort_comma_separated_value;\n\t\t\t# The header Sorted-Value now contains the sorted version of the features parameter.\n\t\t\tset var.querystring = querystring.set(var.querystring, \"features\", req.http.Sorted-Value);\n\t\t} else {\n\t\t\tset var.querystring = querystring.set(var.querystring, \"features\", urldecode(re.group.1));\n\t\t}\n\t} else {\n\t\t# Parameter has not been set, use the default value.\n\t\tset var.querystring = querystring.set(var.querystring, \"features\", \"default\");\n\t}\n\n\t# (?i) makes the regex case-insensitive\n\t# The regex will match only if their are characters after `excludes=` which are not an ampersand (&).\n\tif (req.url.qs ~ \"(?i)[^&=]*excludes=([^&]+)\") {\n\t\t# Parameter has already been set, use the already set value.\n\t\t# re.group.1 is the first regex capture group in the regex above.\n\t\tif (std.strlen(re.group.1) < 100) {\n\t\t\t# We add the value of the excludes parameter to this header\n\t\t\t# This is to be able to have sort_comma_separated_value sort the value\n\t\t\tset req.http.Sort-Value = urldecode(re.group.1);\n\t\t\tcall sort_comma_separated_value;\n\t\t\t# The header Sorted-Value now contains the sorted version of the excludes parameter.\n\t\t\tset var.querystring = querystring.set(var.querystring, \"excludes\", req.http.Sorted-Value);\n\t\t} else {\n\t\t\tset var.querystring = querystring.set(var.querystring, \"excludes\", urldecode(re.group.1));\n\t\t}\n\t} else {\n\t\t# If excludes is not set, set to default value \"\"\n\t\tset var.querystring = var.querystring \"&excludes=\";\n\t}\n\n\t# If rum is not set, set to default value \"0\"\n\tif (req.url.qs !~ \"(?i)[^&=]*rum=([^&]+)\") {\n\t\tset var.querystring = querystring.set(var.querystring, \"rum\", \"0\");\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"rum\", re.group.1);\n\t}\n\n\t# If unknown is not set, set to default value \"polyfill\"\n\tif (req.url.qs !~ \"(?i)[^&=]*unknown=([^&]+)\") {\n\t\tset var.querystring = querystring.set(var.querystring, \"unknown\", \"polyfill\");\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"unknown\", re.group.1);\n\t}\n\n\t# If flags is not set, set to default value \"\"\n\tif (req.url.qs !~ \"(?i)[^&=]*flags=([^&]+)\") {\n\t\tset var.querystring = var.querystring \"&flags=\";\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"flags\", urldecode(re.group.1));\n\t}\n\n\t# If version is not set, set to default value \"\"\n\tdeclare local var.version STRING;\n\tif (req.url.qs !~ \"(?i)[^&=]*version=([^&]+)\") {\n\t\tset var.querystring = var.querystring \"&version=\";\n\t} else {\n\t\tif (re.group.1 == \"3.110.1\" || re.group.1 == \"3.109.0\" || re.group.1 == \"3.108.0\" || re.group.1 == \"3.104.0\" || re.group.1 == \"3.103.0\" || re.group.1 == \"3.101.0\" || re.group.1 == \"3.98.0\" || re.group.1 == \"3.96.0\" || re.group.1 == \"3.89.4\" || re.group.1 == \"3.53.1\" || re.group.1 == \"3.52.3\" || re.group.1 == \"3.52.2\" || re.group.1 == \"3.52.1\" || re.group.1 == \"3.52.0\" || re.group.1 == \"3.51.0\" || re.group.1 == \"3.50.2\" || re.group.1 == \"3.48.0\" || re.group.1 == \"3.46.0\" || re.group.1 == \"3.42.0\" || re.group.1 == \"3.41.0\" || re.group.1 == \"3.40.0\" || re.group.1 == \"3.39.0\" || re.group.1 == \"3.34.0\" || re.group.1 == \"3.27.4\" || re.group.1 == \"3.25.1\") {\n\t\t\tset var.querystring = querystring.set(var.querystring, \"version\", re.group.1);\n\t\t} else {\n\t\t\tset var.querystring = var.querystring \"&version=\";\n\t\t}\n\t}\n\n\t# If ua is not set, normalise the User-Agent header based upon the version of the polyfill-library that has been requested.\n\tif (req.url.qs !~ \"(?i)[^&=]*ua=([^&]+)\") {\n\t\tif (req.url.qs ~ \"(?i)[^&=]*version=3\\.25\\.1(&|$)\") {\n\t\t\tcall normalise_user_agent_3_25_1;\n\t\t} else {\n\t\t\tcall normalise_user_agent_1_10_1;\n\t\t}\n\t\tset var.querystring = querystring.set(var.querystring, \"ua\", req.http.Normalized-User-Agent);\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"ua\", urldecode(re.group.1));\n\t}\n\n\t# If callback is not set, set to default value \"\"\n\tif (req.url.qs !~ \"(?i)[^&=]*callback=([^&]+)\") {\n\t\tset var.querystring = var.querystring \"&callback=\";\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"callback\", re.group.1);\n\t}\n\n\t# If compression is not set, use the best compression that the user-agent supports.\n\tif (req.url.qs !~ \"(?i)[^&=]*compression=([^&]+)\") {\n\t\t# When Fastly adds Brotli into the Accept-Encoding normalisation we can replace this with:\n\t\t# `set var.querystring = querystring.set(var.querystring, \"compression\", req.http.Accept-Encoding || \"\")`\n\n\t\t# Before SP2, IE\/6 doesn't always read and cache gzipped content correctly.\n\t\tif (req.http.Fastly-Orig-Accept-Encoding && req.http.User-Agent !~ \"MSIE 6\") {\n\t\t\tif (req.http.Fastly-Orig-Accept-Encoding ~ \"br\") {\n\t\t\t\tset var.querystring = querystring.set(var.querystring, \"compression\", \"br\");\n\t\t\t} elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"gzip\") {\n\t\t\t\tset var.querystring = querystring.set(var.querystring, \"compression\", \"gzip\");\n\t\t\t} else {\n\t\t\t\tset var.querystring = var.querystring \"&compression=\";\n\t\t\t}\n\t\t} else {\n\t\t\tset var.querystring = var.querystring \"&compression=\";\n\t\t}\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"compression\", re.group.1);\n\t}\n\tset req.url = var.url var.querystring;\n}\n\ninclude \"top_pops.vcl\";\ninclude \"normalise-user-agent-3-25-1.vcl\";\ninclude \"normalise-user-agent.vcl\";\n\n# The Fastly VCL boilerplate.\ninclude \"fastly-boilerplate-begin.vcl\";\n\ninclude \"breadcrumbs.vcl\";\n\nsub vcl_recv {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_recv;\n\t}\n}\n\nsub vcl_recv {\n\t# js-compute-runtime currently can not handle a uri which is bigger than 1024\n\t# this has been fixed in js-compute-runtime but not yet released -- https:\/\/github.com\/fastly\/js-compute-runtime\/commit\/f36dee28789b1187652874fe76d1801c9a8e5974\n\t# when the fix is released and added into @fastly\/js-compute we can remove this if statement\n\tif (std.strlen(req.url) < 900) {\n\t\t# We use this edge dictionary item as a flag for whether to use compute-at-edge for any requests.\n\t\t# If the item is not found, then we default to `\"0\"`, which we interpret to mean the flag is off.\n\t\tdeclare local var.compute-at-edge-active BOOL;\n\t\tif (std.atoi(table.lookup(compute_at_edge_config, \"active\", \"0\")) == 1) {\n\t\t\tset var.compute-at-edge-active = true;\n\t\t} else {\n\t\t\tset var.compute-at-edge-active = false;\n\t\t}\n\t\tif (var.compute-at-edge-active) {\n\t\t\t# if the querystring parameter `use-compute-at-edge-backend` is set to yes`\n\t\t\t# then use the c@e backend.\n\t\t\t# The querystring parameter is used within our tests, so that we can confirm\n\t\t\t# the compute-at-edge backend is working as we expect it to.\n\t\t\tdeclare local var.use-compute-at-edge-backend STRING;\n\t\t\tset var.use-compute-at-edge-backend = querystring.get(req.url, \"use-compute-at-edge-backend\");\n\t\t\tif (var.use-compute-at-edge-backend == \"yes\") {\n\t\t\t\tset req.backend = F_compute_at_edge;\n\t\t\t\tif (req.backend.healthy) {\n\t\t\t\t\t# if using the c@e backend then do not use the cache at all\n\t\t\t\t\treturn(pass);\n\t\t\t\t}\n\t\t\t# requests can set the querystring parameter to `no` to avoid ever user compute-at-edge\n\t\t\t# if the querystring parameter is not set to no, then we run some logic to decide whether\n\t\t\t# to use compute-at-edge for this request or not.\n\t\t\t} else if (var.use-compute-at-edge-backend != \"no\") {\n\t\t\t\tdeclare local var.selected BOOL;\n\t\t\t\tset var.selected = randombool(1, std.atoi(table.lookup(compute_at_edge_config, \"sample\", \"1000\")));\n\t\t\t\t# this logic is saying, only use compute-at-edge for a request which has come from outside this Fastly\n\t\t\t\t# service. I.E. The request has directly from a client.\n\t\t\t\t# We also have logic which decides how many of those direct client requests use compute-at-edge.\n\t\t\t\t# We default to 1 in 1000 requests using compute-at-edge, this can be configured by the edge dictionary\n\t\t\t\t# named `compute_at_edge_config` and the item in the dictionary named `sample`\n\t\t\t\tif (var.selected && fastly_info.edge.is_tls && !req.is_background_fetch && !req.is_purge && req.restarts == 0 && fastly.ff.visits_this_service == 0) {\n\t\t\t\t\tset req.backend = F_compute_at_edge;\n\t\t\t\t\tif (req.backend.healthy) {\n\t\t\t\t\t\t# if using the c@e backend then do not use the cache at all\n\t\t\t\t\t\treturn(pass);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\ninclude \"redirects.vcl\";\ninclude \"synthetic-responses.vcl\";\ninclude \"polyfill-service.vcl\";\n\n# Finally include the last bit of VCL, this _must_ be last!\ninclude \"fastly-boilerplate-end.vcl\";\n","old_contents":"import querystring;\n\nsub sort_comma_separated_value {\n\t# This function takes a CSV and tranforms it into a url where each\n\t# comma-separated-value is a query-string parameter and then uses\n\t# Fastly's querystring.sort function to sort the values. Once sorted\n\t# it then turn the query-parameters back into a CSV.\n\t# Set the CSV on the header `Sort-Value`.\n\t# Returns the sorted CSV on the header `Sorted-Value`.\n\tdeclare local var.value STRING;\n\tset var.value = req.http.Sort-value;\n\n\t# If query value does not exist or is empty, set it to \"\"\n\tset var.value = if(var.value != \"\", var.value, \"\");\n\n\t# Replace all `&` characters with `^`, this is because `&` would break the value up into pieces.\n\tset var.value = regsuball(var.value, \"&\", \"^\");\n\n\t# Replace all `,` characters with `&` to break them into individual query values\n\t# Append `1-` infront of all the query values to make them simpler to transform later\n\tset var.value = \"1-\" regsuball(var.value, \",\", \"&1-\");\n\n\t# Create a querystring-like string in order for querystring.sort to work.\n\tset var.value = querystring.sort(\"?\" var.value);\n\n\t# Grab all the query values from the sorted url\n\tset var.value = regsub(var.value, \"\\?\", \"\");\n\n\t# Reverse all the previous transformations to get back the single `features` query value value\n\tset var.value = regsuball(var.value, \"1-\", \"\");\n\tset var.value = regsuball(var.value, \"&\", \",\");\n\tset var.value = regsuball(var.value, \"\\^\", \"&\");\n\n\tset req.http.Sorted-Value = var.value;\n}\n\nsub normalise_querystring_parameters_for_polyfill_bundle {\n\t# Store the url without the querystring into a temporary header.\n\tdeclare local var.url STRING;\n\tset var.url = querystring.remove(req.url);\n\n\tdeclare local var.querystring STRING;\n\tset var.querystring = \"?\";\n\n\t# Remove all querystring parameters which are not part of the public API.\n\t# set req.url = querystring.regfilter_except(req.url, \"^(features|excludes|rum|unknown|flags|version|ua|callback|compression)$\");\n\n\t# (?i) makes the regex case-insensitive\n\t# The regex will match only if their are characters after `features=` which are not an ampersand (&).\n\tif (req.url.qs ~ \"(?i)[^&=]*features=([^&]+)\") {\n\t\t# Parameter has already been set, use the already set value.\n\t\t# re.group.1 is the first regex capture group in the regex above.\n\t\tif (std.strlen(re.group.1) < 100) {\n\t\t\t# We add the value of the features parameter to this header\n\t\t\t# This is to be able to have sort_comma_separated_value sort the value\n\t\t\tset req.http.Sort-Value = urldecode(re.group.1);\n\t\t\tcall sort_comma_separated_value;\n\t\t\t# The header Sorted-Value now contains the sorted version of the features parameter.\n\t\t\tset var.querystring = var.querystring \"features=\" req.http.Sorted-Value;\n\t\t} else {\n\t\t\tset var.querystring = var.querystring \"features=\" urldecode(re.group.1);\n\t\t}\n\t} else {\n\t\t# Parameter has not been set, use the default value.\n\t\tset var.querystring = var.querystring \"features=\" \"default\";\n\t}\n\n\t# (?i) makes the regex case-insensitive\n\t# The regex will match only if their are characters after `excludes=` which are not an ampersand (&).\n\tif (req.url.qs ~ \"(?i)[^&=]*excludes=([^&]+)\") {\n\t\t# Parameter has already been set, use the already set value.\n\t\t# re.group.1 is the first regex capture group in the regex above.\n\t\tif (std.strlen(re.group.1) < 100) {\n\t\t\t# We add the value of the excludes parameter to this header\n\t\t\t# This is to be able to have sort_comma_separated_value sort the value\n\t\t\tset req.http.Sort-Value = urldecode(re.group.1);\n\t\t\tcall sort_comma_separated_value;\n\t\t\t# The header Sorted-Value now contains the sorted version of the excludes parameter.\n\t\t\tset var.querystring = var.querystring \"&excludes=\" req.http.Sorted-Value;\n\t\t} else {\n\t\t\tset var.querystring = var.querystring \"&excludes=\" urldecode(re.group.1);\n\t\t}\n\t} else {\n\t\t# If excludes is not set, set to default value \"\"\n\t\tset var.querystring = var.querystring \"&excludes=\";\n\t}\n\n\t# If rum is not set, set to default value \"0\"\n\tif (req.url.qs !~ \"(?i)[^&=]*rum=([^&]+)\") {\n\t\tset var.querystring = var.querystring \"&rum=\" \"0\";\n\t} else {\n\t\tset var.querystring = var.querystring \"&rum=\" re.group.1;\n\t}\n\n\t# If unknown is not set, set to default value \"polyfill\"\n\tif (req.url.qs !~ \"(?i)[^&=]*unknown=([^&]+)\") {\n\t\tset var.querystring = var.querystring \"&unknown=\" \"polyfill\";\n\t} else {\n\t\tset var.querystring = var.querystring \"&unknown=\" re.group.1;\n\t}\n\n\t# If flags is not set, set to default value \"\"\n\tif (req.url.qs !~ \"(?i)[^&=]*flags=([^&]+)\") {\n\t\tset var.querystring = var.querystring \"&flags=\";\n\t} else {\n\t\tset var.querystring = var.querystring \"&flags=\" urldecode(re.group.1);\n\t}\n\n\t# If version is not set, set to default value \"\"\n\tdeclare local var.version STRING;\n\tif (req.url.qs !~ \"(?i)[^&=]*version=([^&]+)\") {\n\t\tset var.querystring = var.querystring \"&version=\";\n\t} else {\n\t\tif (re.group.1 == \"3.110.1\" || re.group.1 == \"3.109.0\" || re.group.1 == \"3.108.0\" || re.group.1 == \"3.104.0\" || re.group.1 == \"3.103.0\" || re.group.1 == \"3.101.0\" || re.group.1 == \"3.98.0\" || re.group.1 == \"3.96.0\" || re.group.1 == \"3.89.4\" || re.group.1 == \"3.53.1\" || re.group.1 == \"3.52.3\" || re.group.1 == \"3.52.2\" || re.group.1 == \"3.52.1\" || re.group.1 == \"3.52.0\" || re.group.1 == \"3.51.0\" || re.group.1 == \"3.50.2\" || re.group.1 == \"3.48.0\" || re.group.1 == \"3.46.0\" || re.group.1 == \"3.42.0\" || re.group.1 == \"3.41.0\" || re.group.1 == \"3.40.0\" || re.group.1 == \"3.39.0\" || re.group.1 == \"3.34.0\" || re.group.1 == \"3.27.4\" || re.group.1 == \"3.25.1\") {\n\t\t\tset var.querystring = var.querystring \"&version=\" re.group.1;\n\t\t} else {\n\t\t\tset var.querystring = var.querystring \"&version=\";\n\t\t}\n\t}\n\n\t# If ua is not set, normalise the User-Agent header based upon the version of the polyfill-library that has been requested.\n\tif (req.url.qs !~ \"(?i)[^&=]*ua=([^&]+)\") {\n\t\tif (req.url.qs ~ \"(?i)[^&=]*version=3\\.25\\.1(&|$)\") {\n\t\t\tcall normalise_user_agent_3_25_1;\n\t\t} else {\n\t\t\tcall normalise_user_agent_1_10_1;\n\t\t}\n\t\tset var.querystring = var.querystring \"&ua=\" req.http.Normalized-User-Agent;\n\t} else {\n\t\tset var.querystring = var.querystring \"&ua=\" urldecode(re.group.1);\n\t}\n\n\t# If callback is not set, set to default value \"\"\n\tif (req.url.qs !~ \"(?i)[^&=]*callback=([^&]+)\") {\n\t\tset var.querystring = var.querystring \"&callback=\";\n\t} else {\n\t\tset var.querystring = var.querystring \"&callback=\" re.group.1;\n\t}\n\n\t# If compression is not set, use the best compression that the user-agent supports.\n\tif (req.url.qs !~ \"(?i)[^&=]*compression=([^&]+)\") {\n\t\t# When Fastly adds Brotli into the Accept-Encoding normalisation we can replace this with:\n\t\t# `set var.querystring = var.querystring \"&compression=\" req.http.Accept-Encoding || \"\"`\n\n\t\t# Before SP2, IE\/6 doesn't always read and cache gzipped content correctly.\n\t\tif (req.http.Fastly-Orig-Accept-Encoding && req.http.User-Agent !~ \"MSIE 6\") {\n\t\t\tif (req.http.Fastly-Orig-Accept-Encoding ~ \"br\") {\n\t\t\t\tset var.querystring = var.querystring \"&compression=\" \"br\";\n\t\t\t} elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"gzip\") {\n\t\t\t\tset var.querystring = var.querystring \"&compression=\" \"gzip\";\n\t\t\t} else {\n\t\t\t\tset var.querystring = var.querystring \"&compression=\";\n\t\t\t}\n\t\t} else {\n\t\t\tset var.querystring = var.querystring \"&compression=\";\n\t\t}\n\t} else {\n\t\tset var.querystring = var.querystring \"&compression=\" re.group.1;\n\t}\n\tset req.url = var.url var.querystring;\n}\n\ninclude \"top_pops.vcl\";\ninclude \"normalise-user-agent-3-25-1.vcl\";\ninclude \"normalise-user-agent.vcl\";\n\n# The Fastly VCL boilerplate.\ninclude \"fastly-boilerplate-begin.vcl\";\n\ninclude \"breadcrumbs.vcl\";\n\nsub vcl_recv {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_recv;\n\t}\n}\n\nsub vcl_recv {\n\t# js-compute-runtime currently can not handle a uri which is bigger than 1024\n\t# this has been fixed in js-compute-runtime but not yet released -- https:\/\/github.com\/fastly\/js-compute-runtime\/commit\/f36dee28789b1187652874fe76d1801c9a8e5974\n\t# when the fix is released and added into @fastly\/js-compute we can remove this if statement\n\tif (std.strlen(req.url) < 900) {\n\t\t# We use this edge dictionary item as a flag for whether to use compute-at-edge for any requests.\n\t\t# If the item is not found, then we default to `\"0\"`, which we interpret to mean the flag is off.\n\t\tdeclare local var.compute-at-edge-active BOOL;\n\t\tif (std.atoi(table.lookup(compute_at_edge_config, \"active\", \"0\")) == 1) {\n\t\t\tset var.compute-at-edge-active = true;\n\t\t} else {\n\t\t\tset var.compute-at-edge-active = false;\n\t\t}\n\t\tif (var.compute-at-edge-active) {\n\t\t\t# if the querystring parameter `use-compute-at-edge-backend` is set to yes`\n\t\t\t# then use the c@e backend.\n\t\t\t# The querystring parameter is used within our tests, so that we can confirm\n\t\t\t# the compute-at-edge backend is working as we expect it to.\n\t\t\tdeclare local var.use-compute-at-edge-backend STRING;\n\t\t\tset var.use-compute-at-edge-backend = querystring.get(req.url, \"use-compute-at-edge-backend\");\n\t\t\tif (var.use-compute-at-edge-backend == \"yes\") {\n\t\t\t\tset req.backend = F_compute_at_edge;\n\t\t\t\tif (req.backend.healthy) {\n\t\t\t\t\t# if using the c@e backend then do not use the cache at all\n\t\t\t\t\treturn(pass);\n\t\t\t\t}\n\t\t\t# requests can set the querystring parameter to `no` to avoid ever user compute-at-edge\n\t\t\t# if the querystring parameter is not set to no, then we run some logic to decide whether\n\t\t\t# to use compute-at-edge for this request or not.\n\t\t\t} else if (var.use-compute-at-edge-backend != \"no\") {\n\t\t\t\tdeclare local var.selected BOOL;\n\t\t\t\tset var.selected = randombool(1, std.atoi(table.lookup(compute_at_edge_config, \"sample\", \"1000\")));\n\t\t\t\t# this logic is saying, only use compute-at-edge for a request which has come from outside this Fastly\n\t\t\t\t# service. I.E. The request has directly from a client.\n\t\t\t\t# We also have logic which decides how many of those direct client requests use compute-at-edge.\n\t\t\t\t# We default to 1 in 1000 requests using compute-at-edge, this can be configured by the edge dictionary\n\t\t\t\t# named `compute_at_edge_config` and the item in the dictionary named `sample`\n\t\t\t\tif (var.selected && fastly_info.edge.is_tls && !req.is_background_fetch && !req.is_purge && req.restarts == 0 && fastly.ff.visits_this_service == 0) {\n\t\t\t\t\tset req.backend = F_compute_at_edge;\n\t\t\t\t\tif (req.backend.healthy) {\n\t\t\t\t\t\t# if using the c@e backend then do not use the cache at all\n\t\t\t\t\t\treturn(pass);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\ninclude \"redirects.vcl\";\ninclude \"synthetic-responses.vcl\";\ninclude \"polyfill-service.vcl\";\n\n# Finally include the last bit of VCL, this _must_ be last!\ninclude \"fastly-boilerplate-end.vcl\";\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"d32f061c2d6f6229db02c3659c2d837e7271c37a","subject":"Update sample varnish config","message":"Update sample varnish config\n","repos":"wezm\/pkb,wezm\/pkb","old_file":"config\/varnish.vcl","new_file":"config\/varnish.vcl","new_contents":"vcl 4.0;\n\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"3000\";\n}\n\nsub vcl_recv {\n unset req.http.Cookie;\n}\n\nsub vcl_backend_response {\n # Add asset related cache control headers to fingerprinted assets\n if (bereq.url ~ \"^\/assets\/.*-[a-f0-9]{32,64}\\.[^\\.]+$\") {\n # Cache publicly for 1 year (HTTP spec suggests not specifying more then a year)\n set beresp.ttl = 31557600s;\n set beresp.http.Cache-Control = \"max-age=31557600, public\";\n\n # Some browsers still send conditional-GET requests if there's a\n # Last-Modified header or an ETag header even if they haven't\n # reached the expiry date sent in the Expires header.\n unset beresp.http.Last-Modified;\n unset beresp.http.ETag;\n\n set beresp.http.Access-Control-Allow-Origin = \"https:\/\/linkedlist.org\";\n }\n\n # Strip attempts to set cookies if ttl indicates the response will be cached\n if (beresp.ttl > 0s) {\n unset beresp.http.Set-Cookie;\n\n if (beresp.http.Content-Type ~ \"html\") {\n \/\/ Restore default header\n set beresp.http.Cache-Control = \"max-age=0, private, must-revalidate\";\n return (deliver);\n }\n }\n}\n\n# This is the VCL configuration Varnish will automatically append to your VCL\n# file during compilation\/loading. See the vcl(7) man page for details on syntax\n# and semantics.\n# New users is recommended to use the example.vcl file as a starting point.\n# \n# sub vcl_recv {\n# if (req.method == \"PRI\") {\n# \t\/* We do not support SPDY or HTTP\/2.0 *\/\n# \treturn (synth(405));\n# }\n# if (req.method != \"GET\" &&\n# req.method != \"HEAD\" &&\n# req.method != \"PUT\" &&\n# req.method != \"POST\" &&\n# req.method != \"TRACE\" &&\n# req.method != \"OPTIONS\" &&\n# req.method != \"DELETE\") {\n# \/* Non-RFC2616 or CONNECT which is weird. *\/\n# return (pipe);\n# }\n# \n# if (req.method != \"GET\" && req.method != \"HEAD\") {\n# \/* We only deal with GET and HEAD by default *\/\n# return (pass);\n# }\n# if (req.http.Authorization || req.http.Cookie) {\n# \/* Not cacheable by default *\/\n# return (pass);\n# }\n# return (hash);\n# }\n# \n# sub vcl_pipe {\n# # By default Connection: close is set on all piped requests, to stop\n# # connection reuse from sending future requests directly to the\n# # (potentially) wrong backend. If you do want this to happen, you can undo\n# # it here.\n# # unset bereq.http.connection;\n# return (pipe);\n# }\n# \n# sub vcl_pass {\n# return (fetch);\n# }\n# \n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (lookup);\n# }\n# \n# sub vcl_purge {\n# return (synth(200, \"Purged\"));\n# }\n# \n# sub vcl_hit {\n# if (obj.ttl >= 0s) {\n# \/\/ A pure unadultered hit, deliver it\n# return (deliver);\n# }\n# if (obj.ttl + obj.grace > 0s) {\n# \/\/ Object is in grace, deliver it\n# \/\/ Automatically triggers a background fetch\n# return (deliver);\n# }\n# \/\/ fetch & deliver once we get the result\n# return (fetch);\n# }\n# \n# sub vcl_miss {\n# return (fetch);\n# }\n# \n# sub vcl_deliver {\n# return (deliver);\n# }\n# \n# \/*\n# * We can come here \"invisibly\" with the following errors: 413, 417 & 503\n# *\/\n# sub vcl_synth {\n# set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n# set resp.http.Retry-After = \"5\";\n# synthetic( {\"<!DOCTYPE html>\n# <html>\n# <head>\n# <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n# <\/head>\n# <body>\n# <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n# <p>\"} + resp.reason + {\"<\/p>\n# <h3>Guru Meditation:<\/h3>\n# <p>XID: \"} + req.xid + {\"<\/p>\n# <hr>\n# <p>Varnish cache server<\/p>\n# <\/body>\n# <\/html>\n# \"} );\n# return (deliver);\n# }\n# \n# #######################################################################\n# # Backend Fetch\n# \n# sub vcl_backend_fetch {\n# return (fetch);\n# }\n# \n# sub vcl_backend_response {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Surrogate-control ~ \"no-store\" ||\n# (!beresp.http.Surrogate-Control &&\n# beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n# beresp.http.Vary == \"*\") {\n# \/*\n# * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# *\/\n# set beresp.ttl = 120s;\n# set beresp.uncacheable = true;\n# }\n# return (deliver);\n# }\n# \n# sub vcl_backend_error {\n# set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n# set beresp.http.Retry-After = \"5\";\n# synthetic( {\"<!DOCTYPE html>\n# <html>\n# <head>\n# <title>\"} + beresp.status + \" \" + beresp.reason + {\"<\/title>\n# <\/head>\n# <body>\n# <h1>Error \"} + beresp.status + \" \" + beresp.reason + {\"<\/h1>\n# <p>\"} + beresp.reason + {\"<\/p>\n# <h3>Guru Meditation:<\/h3>\n# <p>XID: \"} + bereq.xid + {\"<\/p>\n# <hr>\n# <p>Varnish cache server<\/p>\n# <\/body>\n# <\/html>\n# \"} );\n# return (deliver);\n# }\n# \n# #######################################################################\n# # Housekeeping\n# \n# sub vcl_init {\n# return (ok);\n# }\n# \n# sub vcl_fini {\n# return (ok);\n# }\n","old_contents":"vcl 4.0;\n\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"3000\";\n}\n\nsub vcl_recv {\n unset req.http.Cookie;\n}\n\nsub vcl_backend_response {\n if (beresp.ttl > 0s) {\n unset beresp.http.Set-Cookie;\n\n if (beresp.http.Content-Type ~ \"html\") {\n \/\/ Restore default header\n set beresp.http.Cache-Control = \"max-age=0, private, must-revalidate\";\n return (deliver);\n }\n }\n}\n\n# This is the VCL configuration Varnish will automatically append to your VCL\n# file during compilation\/loading. See the vcl(7) man page for details on syntax\n# and semantics.\n# New users is recommended to use the example.vcl file as a starting point.\n# \n# sub vcl_recv {\n# if (req.method == \"PRI\") {\n# \t\/* We do not support SPDY or HTTP\/2.0 *\/\n# \treturn (synth(405));\n# }\n# if (req.method != \"GET\" &&\n# req.method != \"HEAD\" &&\n# req.method != \"PUT\" &&\n# req.method != \"POST\" &&\n# req.method != \"TRACE\" &&\n# req.method != \"OPTIONS\" &&\n# req.method != \"DELETE\") {\n# \/* Non-RFC2616 or CONNECT which is weird. *\/\n# return (pipe);\n# }\n# \n# if (req.method != \"GET\" && req.method != \"HEAD\") {\n# \/* We only deal with GET and HEAD by default *\/\n# return (pass);\n# }\n# if (req.http.Authorization || req.http.Cookie) {\n# \/* Not cacheable by default *\/\n# return (pass);\n# }\n# return (hash);\n# }\n# \n# sub vcl_pipe {\n# # By default Connection: close is set on all piped requests, to stop\n# # connection reuse from sending future requests directly to the\n# # (potentially) wrong backend. If you do want this to happen, you can undo\n# # it here.\n# # unset bereq.http.connection;\n# return (pipe);\n# }\n# \n# sub vcl_pass {\n# return (fetch);\n# }\n# \n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (lookup);\n# }\n# \n# sub vcl_purge {\n# return (synth(200, \"Purged\"));\n# }\n# \n# sub vcl_hit {\n# if (obj.ttl >= 0s) {\n# \/\/ A pure unadultered hit, deliver it\n# return (deliver);\n# }\n# if (obj.ttl + obj.grace > 0s) {\n# \/\/ Object is in grace, deliver it\n# \/\/ Automatically triggers a background fetch\n# return (deliver);\n# }\n# \/\/ fetch & deliver once we get the result\n# return (fetch);\n# }\n# \n# sub vcl_miss {\n# return (fetch);\n# }\n# \n# sub vcl_deliver {\n# return (deliver);\n# }\n# \n# \/*\n# * We can come here \"invisibly\" with the following errors: 413, 417 & 503\n# *\/\n# sub vcl_synth {\n# set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n# set resp.http.Retry-After = \"5\";\n# synthetic( {\"<!DOCTYPE html>\n# <html>\n# <head>\n# <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n# <\/head>\n# <body>\n# <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n# <p>\"} + resp.reason + {\"<\/p>\n# <h3>Guru Meditation:<\/h3>\n# <p>XID: \"} + req.xid + {\"<\/p>\n# <hr>\n# <p>Varnish cache server<\/p>\n# <\/body>\n# <\/html>\n# \"} );\n# return (deliver);\n# }\n# \n# #######################################################################\n# # Backend Fetch\n# \n# sub vcl_backend_fetch {\n# return (fetch);\n# }\n# \n# sub vcl_backend_response {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Surrogate-control ~ \"no-store\" ||\n# (!beresp.http.Surrogate-Control &&\n# beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n# beresp.http.Vary == \"*\") {\n# \/*\n# * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# *\/\n# set beresp.ttl = 120s;\n# set beresp.uncacheable = true;\n# }\n# return (deliver);\n# }\n# \n# sub vcl_backend_error {\n# set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n# set beresp.http.Retry-After = \"5\";\n# synthetic( {\"<!DOCTYPE html>\n# <html>\n# <head>\n# <title>\"} + beresp.status + \" \" + beresp.reason + {\"<\/title>\n# <\/head>\n# <body>\n# <h1>Error \"} + beresp.status + \" \" + beresp.reason + {\"<\/h1>\n# <p>\"} + beresp.reason + {\"<\/p>\n# <h3>Guru Meditation:<\/h3>\n# <p>XID: \"} + bereq.xid + {\"<\/p>\n# <hr>\n# <p>Varnish cache server<\/p>\n# <\/body>\n# <\/html>\n# \"} );\n# return (deliver);\n# }\n# \n# #######################################################################\n# # Housekeeping\n# \n# sub vcl_init {\n# return (ok);\n# }\n# \n# sub vcl_fini {\n# return (ok);\n# }\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"a15d64dfd9975ddb62fae7be1bb2dd0842c47ef2","subject":"buff adjust","message":"buff adjust\n","repos":"tempbottle\/VFW,sdgdsffdsfff\/VFW,tempbottle\/VFW,tempbottle\/VFW,sdgdsffdsfff\/VFW,sdgdsffdsfff\/VFW,tempbottle\/VFW,sdgdsffdsfff\/VFW,scarpellini\/VFW,sdgdsffdsfff\/VFW,scarpellini\/VFW,scarpellini\/VFW,scarpellini\/VFW,tempbottle\/VFW","old_file":"varnish\/etc\/varnish\/vfw\/post.vcl","new_file":"varnish\/etc\/varnish\/vfw\/post.vcl","new_contents":"C{\n\t#include <stdio.h>\n\t#include <stdlib.h>\n\t#include <fcntl.h>\n\t#include <unistd.h>\n\t#include <string.h>\n\t#include <strings.h>\n\t#include <sys\/mman.h>\n\t#include <sys\/types.h>\n\t#include <bin\/varnishd\/cache.h>\n}C\n\nsub vcl_recv {\n\tif (req.request == \"POST\") {\n\t\tcall vfw_load_post;\n\t}\n}\n\nsub vcl_deliver {\n\tif (req.request == \"POST\") {\n\t\tcall vfw_cleanup_post;\n\t}\n}\n\nsub vfw_load_post {\n\tC{\n\t\t\/*\n\t\t** Please read:\n ** -- bin\/varnishd\/cache_fetch.c: FetchReqBody()\n ** -- bin\/varnishd\/cache_httpconn.c: HTC_Read()\n\t\t**\n\t\t** -- http:\/\/sourceforge.net\/projects\/libdynamic\/ (Cal Heldenbrand)\n\t\t*\/\n\n\t\tchar buf[4096], body[8192];\n\t\tunsigned long content_length;\n\t\tchar *h_clen_ptr, *h_ctype_ptr, shmem_fname[64];\n\t\tint buf_size, rsize, wsize, shmem_htc_fd;\n\n\t\tbody[0] = 0;\n\n\t\tsyslog(LOG_INFO, \"vfw_load_post - initiating...\");\n\n\t\th_ctype_ptr = VRT_GetHdr(sp, HDR_REQ, \"\\015Content-Type:\");\n\n\t\tif (strcmp(h_ctype_ptr, \"application\/x-www-form-urlencoded\")) {\n\t\t\tsyslog(LOG_INFO, \"vfw_load_post - Not Supported Content-Type: %s\", h_ctype_ptr);\n\t\t\treturn(0);\n\t\t}\n\n\t\th_clen_ptr = VRT_GetHdr(sp, HDR_REQ, \"\\017Content-Length:\");\n\n\t\tif (!h_clen_ptr) {\n\t\t\tsyslog(LOG_INFO, \"vfw_load_post - Empty Content-Length Header\");\n\t\t\treturn(0);\n\t\t}\n\n\t\tcontent_length = strtoul(h_clen_ptr, NULL, 10);\n\n\t\tif (content_length <= 0) {\n\t\t\tsyslog(LOG_INFO, \"vfw_load_post - Empty Content-Length Header\");\n\t\t\treturn(0);\n\t\t}\n\n\t\t\/\/ Open\/Create shared memory file\n\t\tsnprintf(shmem_fname, sizeof(shmem_fname), \"varnish.httpbody.%d.%d\", sp->id, sp->xid);\n\t\tshmem_htc_fd = shm_open(shmem_fname, O_RDWR | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);\n\t\tsyslog(LOG_INFO, \"vfw_load_post - shm_open()\/%s: %s\", shmem_fname, strerror(errno));\n\n\t\tif (shmem_htc_fd == -1) {\n\t\t\treturn(0);\n\t\t}\n\n\t\twhile (content_length) {\n\t\t\tif (content_length > sizeof(buf)) {\n\t\t\t\tbuf_size = sizeof(buf) - 1;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tbuf_size = content_length;\n\t\t\t}\n\n\t\t\t\/\/ read body data into 'buf'\n\t\t\trsize = HTC_Read(sp->htc, buf, buf_size);\n\n\t\t\tif (rsize <= 0) {\n\t\t\t\tsyslog(LOG_INFO, \"vfw_load_post - HTC_Read(): %d - %s\", rsize, strerror(errno));\n\t\t\t\treturn(0);\n\t\t\t}\n\n\t\t\tcontent_length -= rsize;\n\n\t\t\t\/\/ write body data to the shared memory file\n\t\t\twsize = write(shmem_htc_fd, buf, buf_size);\n\n\t\t\tif (wsize <= 0) {\n\t\t\t\tsyslog(LOG_INFO, \"vfw_load_post - write(): %d - %s\", wsize, strerror(errno));\n\t\t\t\treturn(0);\n\t\t\t}\n\n\t\t\t\/\/ copy body data to header buffer\n\t\t\tstrncat(body, buf, buf_size);\n\t\t}\n\n\t\tlseek(shmem_htc_fd, 0, SEEK_SET);\n\t\tsyslog(LOG_INFO, \"vfw_load_post - lseek(): %s\", strerror(errno));\n\t\tsp->htc->fd = shmem_htc_fd;\n\n\t\tsyslog(LOG_INFO, \"vfw_load_post - DATA: Content-Length: %s, Content: %s\", h_clen_ptr, body);\n\n\t\tVRT_SetHdr(sp, HDR_REQ, \"\\013X-VFW-Body:\", body, vrt_magic_string_end);\n\t}C\n}\n\nsub vfw_cleanup_post {\n\tC{\n\t\tif (VRT_GetHdr(sp, HDR_REQ, \"\\013X-VFW-Body:\")) {\n\t\t\tsyslog(LOG_INFO, \"vfw_load_post - cleaning up...\");\n\t\t\tclose(sp->htc->fd);\n\t\t\tsyslog(LOG_INFO, \"vfw_cleanup_post - close(): %s\", strerror(errno));\n\t\t}\n\t}C\n}\n","old_contents":"C{\n\t#include <stdio.h>\n\t#include <stdlib.h>\n\t#include <fcntl.h>\n\t#include <unistd.h>\n\t#include <string.h>\n\t#include <strings.h>\n\t#include <sys\/mman.h>\n\t#include <sys\/types.h>\n\t#include <bin\/varnishd\/cache.h>\n}C\n\nsub vcl_recv {\n\tif (req.request == \"POST\") {\n\t\tcall vfw_load_post;\n\t}\n}\n\nsub vcl_deliver {\n\tif (req.request == \"POST\") {\n\t\tcall vfw_cleanup_post;\n\t}\n}\n\nsub vfw_load_post {\n\tC{\n\t\t\/*\n\t\t** Please read:\n ** -- bin\/varnishd\/cache_fetch.c: FetchReqBody()\n ** -- bin\/varnishd\/cache_httpconn.c: HTC_Read()\n\t\t**\n\t\t** -- http:\/\/sourceforge.net\/projects\/libdynamic\/ (Cal Heldenbrand)\n\t\t*\/\n\n\t\tchar buf[3], body[8192];\n\t\tunsigned long content_length;\n\t\tchar *h_clen_ptr, *h_ctype_ptr, shmem_fname[64];\n\t\tint buf_size, rsize, wsize, shmem_htc_fd;\n\n\t\tbody[0] = 0;\n\n\t\tsyslog(LOG_INFO, \"vfw_load_post - initiating...\");\n\n\t\th_ctype_ptr = VRT_GetHdr(sp, HDR_REQ, \"\\015Content-Type:\");\n\n\t\tif (strcmp(h_ctype_ptr, \"application\/x-www-form-urlencoded\")) {\n\t\t\tsyslog(LOG_INFO, \"vfw_load_post - Not Supported Content-Type: %s\", h_ctype_ptr);\n\t\t\treturn(0);\n\t\t}\n\n\t\th_clen_ptr = VRT_GetHdr(sp, HDR_REQ, \"\\017Content-Length:\");\n\n\t\tif (!h_clen_ptr) {\n\t\t\tsyslog(LOG_INFO, \"vfw_load_post - Empty Content-Length Header\");\n\t\t\treturn(0);\n\t\t}\n\n\t\tcontent_length = strtoul(h_clen_ptr, NULL, 10);\n\n\t\tif (content_length <= 0) {\n\t\t\tsyslog(LOG_INFO, \"vfw_load_post - Empty Content-Length Header\");\n\t\t\treturn(0);\n\t\t}\n\n\t\t\/\/ Open\/Create shared memory file\n\t\tsnprintf(shmem_fname, sizeof(shmem_fname), \"varnish.httpbody.%d.%d\", sp->id, sp->xid);\n\t\tshmem_htc_fd = shm_open(shmem_fname, O_RDWR | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);\n\t\tsyslog(LOG_INFO, \"vfw_load_post - shm_open()\/%s: %s\", shmem_fname, strerror(errno));\n\n\t\tif (shmem_htc_fd == -1) {\n\t\t\treturn(0);\n\t\t}\n\n\t\twhile (content_length) {\n\t\t\tif (content_length > sizeof(buf)) {\n\t\t\t\tbuf_size = sizeof(buf) - 1;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tbuf_size = content_length;\n\t\t\t}\n\n\t\t\t\/\/ read body data into 'buf'\n\t\t\trsize = HTC_Read(sp->htc, buf, buf_size);\n\n\t\t\tif (rsize <= 0) {\n\t\t\t\tsyslog(LOG_INFO, \"vfw_load_post - HTC_Read(): %d - %s\", rsize, strerror(errno));\n\t\t\t\treturn(0);\n\t\t\t}\n\n\t\t\tcontent_length -= rsize;\n\n\t\t\t\/\/ write body data to the shared memory file\n\t\t\twsize = write(shmem_htc_fd, buf, buf_size);\n\n\t\t\tif (wsize <= 0) {\n\t\t\t\tsyslog(LOG_INFO, \"vfw_load_post - write(): %d - %s\", wsize, strerror(errno));\n\t\t\t\treturn(0);\n\t\t\t}\n\n\t\t\t\/\/ copy body data to header buffer\n\t\t\tstrncat(body, buf, buf_size);\n\t\t}\n\n\t\tlseek(shmem_htc_fd, 0, SEEK_SET);\n\t\tsyslog(LOG_INFO, \"vfw_load_post - lseek(): %s\", strerror(errno));\n\t\tsp->htc->fd = shmem_htc_fd;\n\n\t\tsyslog(LOG_INFO, \"vfw_load_post - DATA: Content-Length: %s, Content: %s\", h_clen_ptr, body);\n\n\t\tVRT_SetHdr(sp, HDR_REQ, \"\\013X-VFW-Body:\", body, vrt_magic_string_end);\n\t}C\n}\n\nsub vfw_cleanup_post {\n\tC{\n\t\tif (VRT_GetHdr(sp, HDR_REQ, \"\\013X-VFW-Body:\")) {\n\t\t\tsyslog(LOG_INFO, \"vfw_load_post - cleaning up...\");\n\t\t\tclose(sp->htc->fd);\n\t\t\tsyslog(LOG_INFO, \"vfw_cleanup_post - close(): %s\", strerror(errno));\n\t\t}\n\t}C\n}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"dc12e96fe2643a3bded98d5c877fde3050188b2a","subject":"Accidental paste","message":"Accidental paste\n","repos":"fastly\/fastly-magento,fastly\/fastly-magento,fastly\/fastly-magento,fastly\/fastly-magento","old_file":"app\/code\/community\/Fastly\/CDN\/etc\/default.vcl","new_file":"app\/code\/community\/Fastly\/CDN\/etc\/default.vcl","new_contents":"###############################################################################\n#\n# Fastly CDN for Magento\n#\n# NOTICE OF LICENSE\n#\n# This source file is subject to the Fastly CDN for Magento End User License\n# Agreement that is bundled with this package in the file LICENSE_FASTLY_CDN.txt.\n#\n# @copyright Copyright (c) 2015 Fastly, Inc. (http:\/\/www.fastly.com)\n# @license BSD, see LICENSE_FASTLY_CDN.txt\n#\n###############################################################################\n\n# This is a basic VCL configuration file for fastly CDN for Magento module.\n\nsub vcl_recv {\n#FASTLY recv\n # we only deal with GET and HEAD by default\n if (req.request != \"GET\" && req.request != \"HEAD\" && req.request != \"FASTLYPURGE\") {\n return (pass);\n }\n\n # Sort the query arguments\n set req.url = boltsort.sort(req.url);\n\n # bypass language switcher\n if (req.url ~ \"(?i)___from_store=.*&___store=.*\") {\n set req.http.X-Pass = \"1\";\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (req.http.cookie:FASTLY_CDN_ENV) {\n set req.http.Fastly-Cdn-Env = req.http.cookie:FASTLY_CDN_ENV;\n } else {\n unset req.http.Fastly-Cdn-Env;\n }\n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n\n if (!req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n error 403;\n }\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n\n } else {\n error 403;\n }\n\n }\n\n # disable ESI processing on Origin Shield\n if (req.http.Fastly-FF) {\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(media|js|skin)\/.*\\.(png|jpg|jpeg|gif|css|js|swf|ico)$\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n # formkey lookup\n if (req.url ~ \"\/fastlycdn\/getformkey\/\") {\n # check if we have a formkey cookie\n if (req.http.Cookie:FASTLY_CDN_FORMKEY) {\n set req.http.Formkey = req.http.Cookie:FASTLY_CDN_FORMKEY;\n } else {\n # create formkey\n set req.http.seed = req.http.Cookie client.ip remote.port geoip.longitude geoip.latitude geoip.postal_code;\n set req.http.Formkey = regsub(digest.hash_md5(req.http.seed), \"^0x\", \"\");\n }\n error 760 req.http.Formkey;\n }\n\n # geoip lookup\n if (req.url ~ \"fastlycdn\/esi\/getcountry\/\") {\n # check if GeoIP has been already processed by client\n if (req.http.Cookie:FASTLY_CDN_GEOIP_PROCESSED) {\n error 200 \"\";\n } else {\n # modify req.url and restart request processing\n error 750 geoip.country_code;\n }\n }\n\n # geoip get country code\n if (req.url ~ \"fastlycdn\/esi\/getcountrycode\/\") {\n # create and set req.http.X-Country-Code\n error 755 geoip.country_code;\n }\n\n # check for ESI calls\n if (req.url ~ \"esi_data=\") {\n # check for valid cookie data\n if (req.http.Cookie ~ \"FASTLY_CDN-([A-Za-z0-9-_]+)=([^;]*)\") {\n set req.url = querystring.filter(req.url, \"esi_data\") + \"&esi_data=\" + re.group.2;\n }\n }\n \n # If object has been marked as pass pass it\n if ( req.http.X-Pass ) {\n return(pass);\n }\n\n return(lookup);\n}\n\nsub vcl_fetch {\n#FASTLY fetch\n\n if (beresp.status >= 500) {\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n }\n\n if (req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Content-Type ~ \"text\/(html|xml)\") {\n # enable ESI feature for Magento response by default\n esi;\n if (!beresp.http.Vary ~ \"Fastly-Cdn-Env,Https\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \",Fastly-Cdn-Env,Https\";\n } else {\n set beresp.http.Vary = \"Fastly-Cdn-Env,Https\";\n }\n }\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content\n if (http_status_matches(beresp.status, \"200,404\") && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url.ext ~ \"(?i)(css|js|html|eot|ico|otf|ttf|json)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.status == 500 || beresp.status == 503) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n if (http_status_matches(beresp.status, \"200,301,404\") && !req.http.X-Pass) {\n if (beresp.http.Content-Type ~ \"text\/(html|xml)\") {\n # marker for vcl_deliver to reset Age:\n set beresp.http.magentomarker = \"1\";\n\n # Don't cache cookies\n unset beresp.http.set-cookie;\n } else {\n if (beresp.http.Expires || beresp.http.Surrogate-Control ~ \"max-age\" || beresp.http.Cache-Control ~ \"(s-maxage|max-age)\") {\n # keep the ttl here\n } else {\n # apply the default ttl\n set beresp.ttl = 3600s;\n }\n }\n\n # init surrogate keys\n if (beresp.http.Surrogate-Key) {\n set beresp.http.Surrogate-Key = beresp.http.Surrogate-Key \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type\n if (beresp.http.Content-Type ~ \"image\") {\n set beresp.http.Surrogate-Key = \"image\";\n } elsif (beresp.http.Content-Type ~ \"script\") {\n set beresp.http.Surrogate-Key = \"script\";\n } elsif (beresp.http.Content-Type ~ \"css\") {\n set beresp.http.Surrogate-Key = \"css\";\n }\n\n }\n\n return (deliver);\n}\n\nsub vcl_deliver {\n\n # Add an easy way to see whether custom Fastly VCL has been uploaded\n if ( req.http.Fastly-Debug ) {\n set resp.http.Fastly-Magento-VCL-Uploaded = \"1.0.6\";\n } else {\n remove resp.http.Fastly-Module-Enabled;\n }\n\n # debug info\n if (resp.http.X-Cache-Debug) {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n set resp.http.X-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n set resp.http.X-Cache-Expires = resp.http.Expires;\n } else {\n # remove Varnish\/proxy header\n remove resp.http.X-Varnish;\n remove resp.http.Via;\n remove resp.http.Age;\n remove resp.http.X-Purge-URL;\n remove resp.http.X-Purge-Host;\n }\n\n # Clean up Vary before handing off to the user\n if ( !req.http.Fastly-FF ) {\n set resp.http.Vary = regsub(resp.http.Vary, \"Fastly-Cdn-Env,Https\", \"Cookie\");\n }\n\n if (resp.http.magentomarker) {\n # Remove the magic marker\n unset resp.http.magentomarker;\n\n set resp.http.Cache-Control = \"no-store, no-cache, must-revalidate, post-check=0, pre-check=0\";\n set resp.http.Pragma = \"no-cache\";\n set resp.http.Expires = \"Mon, 31 Mar 2008 10:00:00 GMT\";\n }\n\n#FASTLY deliver\n\n return (deliver);\n}\n\nsub vcl_error {\n # workaround for possible security issue\n if (req.url ~ \"^\\s\") {\n set obj.status = 400;\n set obj.response = \"Malformed request\";\n synthetic \"\";\n return (deliver);\n }\n\n # geo ip request\n if (obj.status == 750) {\n set req.url = regsub(req.url, \"(\/fastlycdn\/esi\/getcountry\/.*)\", \"\/fastlycdn\/esi\/getcountryaction\/?country_code=\") obj.response;\n return (restart);\n }\n\n # geo ip country code\n if (obj.status == 755) {\n set obj.status = 200;\n synthetic obj.response;\n return(deliver);\n }\n\n # formkey request\n if (obj.status == 760) {\n set obj.status = 200;\n synthetic obj.response;\n return (deliver);\n }\n\n # error 200\n if (obj.status == 200) {\n return (deliver);\n }\n\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} obj.status \" \" obj.response {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} obj.status \" \" obj.response {\"<\/h1>\n <p>\"} obj.response {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} req.xid {\"<\/p>\n <hr>\n <p>Fastly CDN server<\/p>\n <\/body>\n<\/html>\n\"};\n\n#FASTLY error\n}\n\nsub vcl_pass {\n # Deactivate gzip on origin\n unset bereq.http.Accept-Encoding;\n\n#FASTLY pass\n}\n\nsub vcl_hit {\n#FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\nsub vcl_miss {\n # Deactivate gzip on origin\n unset bereq.http.Accept-Encoding;\n\n#FASTLY miss\n\n return(fetch);\n}\n\nsub vcl_hash {\n set req.hash += req.http.host;\n set req.hash += req.url;\n\n if (!(req.url ~ \"^\/(media|js|skin)\/.*\\.(png|jpg|jpeg|gif|css|js|swf|ico)$\")) {\n call design_exception;\n }\n\n# Please do not remove below. It's required for purge all functionality\n#FASTLY hash\n\n return (hash);\n}\n\n\nsub design_exception {\n}\n","old_contents":"###############################################################################\n#\n# Fastly CDN for Magento\n#\n# NOTICE OF LICENSE\n#\n# This source file is subject to the Fastly CDN for Magento End User License\n# Agreement that is bundled with this package in the file LICENSE_FASTLY_CDN.txt.\n#\n# @copyright Copyright (c) 2015 Fastly, Inc. (http:\/\/www.fastly.com)\n# @license BSD, see LICENSE_FASTLY_CDN.txt\n#\n###############################################################################\n\n# This is a basic VCL configuration file for fastly CDN for Magento module.\n\nsub vcl_recv {\n#FASTLY recv\n # we only deal with GET and HEAD by default\n if (req.request != \"GET\" && req.request != \"HEAD\" && req.request != \"FASTLYPURGE\") {\n return (pass);\n }\n\n # Sort the query arguments\n set req.url = boltsort.sort(req.url);\n\n # bypass language switcher\n if (req.url ~ \"(?i)___from_store=.*&___store=.*\") {\n set req.http.X-Pass = \"1\";\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (req.http.cookie:FASTLY_CDN_ENV) {\n set req.http.Fastly-Cdn-Env = req.http.cookie:FASTLY_CDN_ENV;\n } else {\n unset req.http.Fastly-Cdn-Env;\n }\n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n\n if (!req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n error 403;\n }\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n\n } else {\n error 403;\n }\n\n }\n\n # disable ESI processing on Origin Shield\n if (req.http.Fastly-FF) {\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(media|js|skin)\/.*\\.(png|jpg|jpeg|gif|css|js|swf|ico)$\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n # formkey lookup\n if (req.url ~ \"\/fastlycdn\/getformkey\/\") {\n # check if we have a formkey cookie\n if (req.http.Cookie:FASTLY_CDN_FORMKEY) {\n set req.http.Formkey = req.http.Cookie:FASTLY_CDN_FORMKEY;\n } else {\n # create formkey\n set req.http.seed = req.http.Cookie client.ip remote.port geoip.longitude geoip.latitude geoip.postal_code;\n set req.http.Formkey = regsub(digest.hash_md5(req.http.seed), \"^0x\", \"\");\n }\n error 760 req.http.Formkey;\n }\n\n # geoip lookup\n if (req.url ~ \"fastlycdn\/esi\/getcountry\/\") {\n # check if GeoIP has been already processed by client\n if (req.http.Cookie:FASTLY_CDN_GEOIP_PROCESSED) {\n error 200 \"\";\n } else {\n # modify req.url and restart request processing\n error 750 geoip.country_code;\n }\n }\n\n # geoip get country code\n if (req.url ~ \"fastlycdn\/esi\/getcountrycode\/\") {\n # create and set req.http.X-Country-Code\n error 755 geoip.country_code;\n }\n\n # check for ESI calls\n if (req.url ~ \"esi_data=\") {\n # check for valid cookie data\n if (req.http.Cookie ~ \"FASTLY_CDN-([A-Za-z0-9-_]+)=([^;]*)\") {\n set req.url = querystring.filter(req.url, \"esi_data\") + \"&esi_data=\" + re.group.2;\n }\n }\n \n # If object has been marked as pass pass it\n if ( req.http.X-Pass ) {\n return(pass);\n }\n\n return(lookup);\n}\n\nsub vcl_fetch {\n#FASTLY fetch\n\n if (beresp.status >= 500) {\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n }\n\n if (req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Content-Type ~ \"text\/(html|xml)\") {\n # enable ESI feature for Magento response by default\n esi;\n if (!beresp.http.Vary ~ \"Fastly-Cdn-Env,Https\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \",Fastly-Cdn-Env,Https\";\n } else {\n set beresp.http.Vary = \"Fastly-Cdn-Env,Https\";\n }\n }\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content\n if (http_status_matches(beresp.status, \"200,404\") && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url.ext ~ \"(?i)(css|js|html|eot|ico|otf|ttf|json)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.status == 500 || beresp.status == 503) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver); set req.hash += req.url;\n\n }\n\n if (http_status_matches(beresp.status, \"200,301,404\") && !req.http.X-Pass) {\n if (beresp.http.Content-Type ~ \"text\/(html|xml)\") {\n # marker for vcl_deliver to reset Age:\n set beresp.http.magentomarker = \"1\";\n\n # Don't cache cookies\n unset beresp.http.set-cookie;\n } else {\n if (beresp.http.Expires || beresp.http.Surrogate-Control ~ \"max-age\" || beresp.http.Cache-Control ~ \"(s-maxage|max-age)\") {\n # keep the ttl here\n } else {\n # apply the default ttl\n set beresp.ttl = 3600s;\n }\n }\n\n # init surrogate keys\n if (beresp.http.Surrogate-Key) {\n set beresp.http.Surrogate-Key = beresp.http.Surrogate-Key \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type\n if (beresp.http.Content-Type ~ \"image\") {\n set beresp.http.Surrogate-Key = \"image\";\n } elsif (beresp.http.Content-Type ~ \"script\") {\n set beresp.http.Surrogate-Key = \"script\";\n } elsif (beresp.http.Content-Type ~ \"css\") {\n set beresp.http.Surrogate-Key = \"css\";\n }\n\n }\n\n return (deliver);\n}\n\nsub vcl_deliver {\n\n # Add an easy way to see whether custom Fastly VCL has been uploaded\n if ( req.http.Fastly-Debug ) {\n set resp.http.Fastly-Magento-VCL-Uploaded = \"1.0.6\";\n } else {\n remove resp.http.Fastly-Module-Enabled;\n }\n\n # debug info\n if (resp.http.X-Cache-Debug) {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n set resp.http.X-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n set resp.http.X-Cache-Expires = resp.http.Expires;\n } else {\n # remove Varnish\/proxy header\n remove resp.http.X-Varnish;\n remove resp.http.Via;\n remove resp.http.Age;\n remove resp.http.X-Purge-URL;\n remove resp.http.X-Purge-Host;\n }\n\n # Clean up Vary before handing off to the user\n if ( !req.http.Fastly-FF ) {\n set resp.http.Vary = regsub(resp.http.Vary, \"Fastly-Cdn-Env,Https\", \"Cookie\");\n }\n\n if (resp.http.magentomarker) {\n # Remove the magic marker\n unset resp.http.magentomarker;\n\n set resp.http.Cache-Control = \"no-store, no-cache, must-revalidate, post-check=0, pre-check=0\";\n set resp.http.Pragma = \"no-cache\";\n set resp.http.Expires = \"Mon, 31 Mar 2008 10:00:00 GMT\";\n }\n\n#FASTLY deliver\n\n return (deliver);\n}\n\nsub vcl_error {\n # workaround for possible security issue\n if (req.url ~ \"^\\s\") {\n set obj.status = 400;\n set obj.response = \"Malformed request\";\n synthetic \"\";\n return (deliver);\n }\n\n # geo ip request\n if (obj.status == 750) {\n set req.url = regsub(req.url, \"(\/fastlycdn\/esi\/getcountry\/.*)\", \"\/fastlycdn\/esi\/getcountryaction\/?country_code=\") obj.response;\n return (restart);\n }\n\n # geo ip country code\n if (obj.status == 755) {\n set obj.status = 200;\n synthetic obj.response;\n return(deliver);\n }\n\n # formkey request\n if (obj.status == 760) {\n set obj.status = 200;\n synthetic obj.response;\n return (deliver);\n }\n\n # error 200\n if (obj.status == 200) {\n return (deliver);\n }\n\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} obj.status \" \" obj.response {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} obj.status \" \" obj.response {\"<\/h1>\n <p>\"} obj.response {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} req.xid {\"<\/p>\n <hr>\n <p>Fastly CDN server<\/p>\n <\/body>\n<\/html>\n\"};\n\n#FASTLY error\n}\n\nsub vcl_pass {\n # Deactivate gzip on origin\n unset bereq.http.Accept-Encoding;\n\n#FASTLY pass\n}\n\nsub vcl_hit {\n#FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\nsub vcl_miss {\n # Deactivate gzip on origin\n unset bereq.http.Accept-Encoding;\n\n#FASTLY miss\n\n return(fetch);\n}\n\nsub vcl_hash {\n set req.hash += req.http.host;\n set req.hash += req.url;\n\n if (!(req.url ~ \"^\/(media|js|skin)\/.*\\.(png|jpg|jpeg|gif|css|js|swf|ico)$\")) {\n call design_exception;\n }\n\n# Please do not remove below. It's required for purge all functionality\n#FASTLY hash\n\n return (hash);\n}\n\n\nsub design_exception {\n}\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"283c1b0863a0c49afc26159c8507b66f08c0f8ed","subject":"Comment about query parameters","message":"Comment about query parameters\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets\/recv.vcl","new_file":"etc\/vcl_snippets\/recv.vcl","new_contents":" # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n unset req.http.x-long-cache;\n\n # Rewrite \/static\/versionxxxxx URLs. Avoids us having to rewrite on nginx layer\n if (req.url ~ \"^\/static\/version(\\d*\/)?(.*)$\") {\n set req.url = \"\/static\/\" + re.group.2 + \"?\" + re.group.1;\n set req.http.x-long-cache = \"1\";\n }\n \n # User's Cookie may contain some Magento Vary items we should vary on\n if (req.http.cookie:X-Magento-Vary ) {\n set req.http.X-Magento-Vary = req.http.cookie:X-Magento-Vary;\n } else {\n unset req.http.X-Magento-Vary;\n }\n\n ############################################################################################################\n # Following code block controls purge by URL. By default we want to protect all URL purges. In general this\n # is addressed by adding Fastly-Purge-Requires-Auth request header in vcl_recv however this runs the risk of\n # exposing API tokens if user attempts to purge non-https URLs. For this reason inside the Magento module\n # we use X-Purge-Token. Unfortunately this breaks purge from the Fastly UI. Therefore in the next code block\n # we check for presence of X-Purge-Token. If it's not present we force the Fastly-Purge-Requires-Auth\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n if (req.http.X-Purge-Token && req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n }\n\n } else {\n set req.http.Fastly-Purge-Requires-Auth = \"1\";\n }\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (req.http.Fastly-FF) {\n # disable ESI processing on Origin Shield\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie:X-Magento-Vary || req.http.cookie:form_key) {\n error 980 \"GeoIP already processed\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url.qs !~ \"country_code=\" ) {\n set req.url = req.url \"?country_code=\" if ( req.http.geo_override, req.http.geo_override, client.geo.country_code);\n }\n }\n } else {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking by default\n # and allow custom parameters to be set. List of parameters is configurable in admin\n set req.http.Magento-Original-URL = req.url;\n # Change the list of ignored parameters by configuring them in the Advanced section\n set req.url = querystring.regfilter(req.url, \"^(####QUERY_PARAMETERS####)\");\n }\n\n # Don't allow clients to force a pass\n if (req.restarts == 0) {\n unset req.http.x-pass;\n }\n \n # Pass on checkout URLs. Because it's a snippet we want to execute this after backend selection so we handle it\n # in the request condition\n if (!req.http.x-long-cache && req.url ~ \"\/(catalogsearch|checkout|customer\/section\/load)\") {\n set req.http.x-pass = \"1\";\n # Pass all admin actions\n # ####ADMIN_PATH#### is replaced with value of frontName from app\/etc\/env.php\n } else if ( req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" ) {\n set req.http.x-pass = \"1\";\n } else {\n # Sort the query arguments to increase cache hit ratio with query arguments that\n # may be out od order\n set req.url = boltsort.sort(req.url);\n }\n\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.http.x-long-cache || req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n","old_contents":" # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n unset req.http.x-long-cache;\n\n # Rewrite \/static\/versionxxxxx URLs. Avoids us having to rewrite on nginx layer\n if (req.url ~ \"^\/static\/version(\\d*\/)?(.*)$\") {\n set req.url = \"\/static\/\" + re.group.2 + \"?\" + re.group.1;\n set req.http.x-long-cache = \"1\";\n }\n \n # User's Cookie may contain some Magento Vary items we should vary on\n if (req.http.cookie:X-Magento-Vary ) {\n set req.http.X-Magento-Vary = req.http.cookie:X-Magento-Vary;\n } else {\n unset req.http.X-Magento-Vary;\n }\n\n ############################################################################################################\n # Following code block controls purge by URL. By default we want to protect all URL purges. In general this\n # is addressed by adding Fastly-Purge-Requires-Auth request header in vcl_recv however this runs the risk of\n # exposing API tokens if user attempts to purge non-https URLs. For this reason inside the Magento module\n # we use X-Purge-Token. Unfortunately this breaks purge from the Fastly UI. Therefore in the next code block\n # we check for presence of X-Purge-Token. If it's not present we force the Fastly-Purge-Requires-Auth\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n if (req.http.X-Purge-Token && req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n }\n\n } else {\n set req.http.Fastly-Purge-Requires-Auth = \"1\";\n }\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (req.http.Fastly-FF) {\n # disable ESI processing on Origin Shield\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie:X-Magento-Vary || req.http.cookie:form_key) {\n error 980 \"GeoIP already processed\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url.qs !~ \"country_code=\" ) {\n set req.url = req.url \"?country_code=\" if ( req.http.geo_override, req.http.geo_override, client.geo.country_code);\n }\n }\n } else {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking by default\n # and allow custom parameters to be set. List of parameters is configurable in admin\n set req.http.Magento-Original-URL = req.url;\n set req.url = querystring.regfilter(req.url, \"^(####QUERY_PARAMETERS####)\");\n }\n\n # Don't allow clients to force a pass\n if (req.restarts == 0) {\n unset req.http.x-pass;\n }\n \n # Pass on checkout URLs. Because it's a snippet we want to execute this after backend selection so we handle it\n # in the request condition\n if (!req.http.x-long-cache && req.url ~ \"\/(catalogsearch|checkout|customer\/section\/load)\") {\n set req.http.x-pass = \"1\";\n # Pass all admin actions\n # ####ADMIN_PATH#### is replaced with value of frontName from app\/etc\/env.php\n } else if ( req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" ) {\n set req.http.x-pass = \"1\";\n } else {\n # Sort the query arguments to increase cache hit ratio with query arguments that\n # may be out od order\n set req.url = boltsort.sort(req.url);\n }\n\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.http.x-long-cache || req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"8d02f58207edf330adeb8e93524ed57283e78b44","subject":"Minor VCL tweaks","message":"Minor VCL tweaks\n","repos":"fastly\/fastly-magento,fastly\/fastly-magento,fastly\/fastly-magento,fastly\/fastly-magento","old_file":"app\/code\/community\/Fastly\/CDN\/etc\/vcl_snippets\/fetch.vcl","new_file":"app\/code\/community\/Fastly\/CDN\/etc\/vcl_snippets\/fetch.vcl","new_contents":" if (beresp.status >= 500 && beresp.status < 600) {\n \/* deliver stale if the object is available *\/\n if (stale.exists) {\n return(deliver_stale);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n \/* else go to vcl_error to deliver a synthetic *\/\n error beresp.status beresp.response;\n\n }\n\n if (beresp.http.X-Esi || beresp.http.Content-Type ~ \"^text\/(html|xml)\") {\n # enable ESI feature for Magento response by default\n esi;\n if (!beresp.http.Vary ~ \"Fastly-Cdn-Env,Https\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \",Fastly-Cdn-Env,Https\";\n } else {\n set beresp.http.Vary = \"Fastly-Cdn-Env,Https\";\n }\n }\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content\n if (http_status_matches(beresp.status, \"200,404\") && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url.ext ~ \"(?i)(css|js|html|eot|ico|otf|ttf|json)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # Just in case the Request Setting for x-pass is missing\n if (req.http.x-pass) {\n return (pass);\n }\n\n # Force any responses with private, no-cache or no-store in Cache-Control to pass\n if (beresp.http.Cache-Control ~ \"private|no-cache|no-store\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # Varnish sets default TTL if none of these are present\n if (!beresp.http.Expires && !beresp.http.Surrogate-Control ~ \"max-age\" && !beresp.http.Cache-Control ~ \"(s-maxage|max-age)\") {\n set beresp.ttl = 0s;\n }\n\n # If origin provides TTL for an object we cache it\n if ( beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\") && !req.http.x-pass ) {\n # Don't cache cookies - this is here because Magento sets cookies even for anonymous users\n # which busts cache\n unset beresp.http.set-cookie;\n\n if (beresp.http.Content-Type ~ \"^text\/(html|xml)\") {\n # marker for vcl_deliver to reset Age:\n set beresp.http.magentomarker = \"1\";\n\n # init surrogate keys\n if (beresp.http.Surrogate-Key) {\n set beresp.http.Surrogate-Key = beresp.http.Surrogate-Key \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n } else if (beresp.http.Content-Type ~ \"(image|script|css)\") {\n # set surrogate keys by content type if they are image\/script or CSS\n if (beresp.http.Surrogate-Key) {\n set beresp.http.Surrogate-Key = beresp.http.Surrogate-Key \" \" re.group.1;\n } else {\n set beresp.http.Surrogate-Key = re.group.1;\n }\n }\n }\n","old_contents":" if (beresp.status >= 500 && beresp.status < 600) {\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n \/* deliver stale if the object is available *\/\n if (stale.exists) {\n return(deliver_stale);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n \/* else go to vcl_error to deliver a synthetic *\/\n error beresp.status beresp.response;\n\n }\n\n if (beresp.http.X-Esi || beresp.http.Content-Type ~ \"^text\/(html|xml)\") {\n # enable ESI feature for Magento response by default\n esi;\n if (!beresp.http.Vary ~ \"Fastly-Cdn-Env,Https\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \",Fastly-Cdn-Env,Https\";\n } else {\n set beresp.http.Vary = \"Fastly-Cdn-Env,Https\";\n }\n }\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content\n if (http_status_matches(beresp.status, \"200,404\") && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url.ext ~ \"(?i)(css|js|html|eot|ico|otf|ttf|json)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # Force any responses with private, no-cache or no-store in Cache-Control to pass\n if (beresp.http.Cache-Control ~ \"private|no-cache|no-store\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # Just in case the Request Setting for x-pass is missing\n if (req.http.x-pass) {\n return (pass);\n }\n\n # Varnish sets default TTL if none of these are present\n if (!beresp.http.Expires && !beresp.http.Surrogate-Control ~ \"max-age\" && !beresp.http.Cache-Control ~ \"(s-maxage|max-age)\") {\n set beresp.ttl = 0s;\n }\n\n # If origin provides TTL for an object we cache it\n if ( beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\") && !req.http.x-pass ) {\n # Don't cache cookies - this is here because Magento sets cookies even for anonymous users\n # which busts cache\n unset beresp.http.set-cookie;\n\n if (beresp.http.Content-Type ~ \"^text\/(html|xml)\") {\n # marker for vcl_deliver to reset Age:\n set beresp.http.magentomarker = \"1\";\n\n # init surrogate keys\n if (beresp.http.Surrogate-Key) {\n set beresp.http.Surrogate-Key = beresp.http.Surrogate-Key \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n } else if (beresp.http.Content-Type ~ \"(image|script|css)\") {\n # set surrogate keys by content type if they are image\/script or CSS\n if (beresp.http.Surrogate-Key) {\n set beresp.http.Surrogate-Key = beresp.http.Surrogate-Key \" \" re.group.1;\n } else {\n set beresp.http.Surrogate-Key = re.group.1;\n }\n }\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"109401aa164bf470634138c11f92ef64f7861a7c","subject":"Minor tweak to regexp for VCL.","message":"Minor tweak to regexp for VCL.\n","repos":"gotofbi\/ansible-varnish,killerwails\/ansible-varnish,noqcks\/ansible-varnish,kkwoker\/ansible-varnish,colstrom\/ansible-varnish,telusdigital\/ansible-varnish,gotofbi\/ansible-varnish,killerwails\/ansible-varnish","old_file":"templates\/etc\/varnish\/default.vcl","new_file":"templates\/etc\/varnish\/default.vcl","new_contents":"vcl 4.0;\n\nimport directors;\nimport std;\n\n###\n# Varnish Documentation\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-built-in-subs.html\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/reference\/vcl.html\n##\n\n{% for backend in varnish_backend_hosts %}\nbackend application_{{ loop.index }} {\n .host = \"{{ backend }}\";\n .port = \"{{ varnish_backend_port }}\";\n{% if varnish_health_checks_enabled %}\n .probe = {\n .url = \"{{ varnish_health_check_url }}\";\n .interval = {{ varnish_health_check_interval }};\n .timeout = {{ varnish_health_check_timeout }};\n .window = {{ varnish_health_check_window }};\n .threshold = {{ varnish_health_check_threshold }};\n }\n{% endif %}\n}\n{% endfor %}\n\n###\n# vcl_init\n# Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n###\n# The vcl_init subroutine may terminate with calling return() with one of the following keywords:\n#\n# ok\n# Normal return, VCL continues loading.\n##\n\nsub vcl_init {\n new application = directors.round_robin();\n{% for backend in varnish_backend_hosts %}\n application.add_backend(application_{{ loop.index }});\n{% endfor %}\n}\n\n###\n# vcl_recv\n# Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use. \n# It is also used to modify the request\n###\n# The vcl_recv subroutine may terminate with calling return() on one of the following keywords:\n#\n# synth(status code, reason)\n# Return a synthetic object with the specified status code to the client and abandon the request.\n# pass\n# Switch to pass mode. Control will eventually pass to vcl_pass.\n# pipe\n# Switch to pipe mode. Control will eventually pass to vcl_pipe.\n# hash\n# Continue processing the object as a potential candidate for caching. Passes the control over to vcl_hash.\n# purge\n# Purge the object and it's variants. Control passes through vcl_hash to vcl_purge.\n#\n\nsub vcl_recv {\n set req.backend_hint = application.backend();\n\n ###\n # Avoid processing uncacheable requests\n ###\n\n if (req.http.Authorization) {\n return (pass);\n }\n\n ###\n # Inject X-Forwarded-For headers, but only once.\n ###\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n{% if varnish_header_sanitization_enabled %}\n ###\n # Header Sanitization\n ###\n\n{% if varnish_discards_port_from_host_header %}\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n{% endif %}\n\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_enabled %}\n ###\n # Cookie Sanitization\n ###\n\n ### Google Analytics\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n\n ### Quantcast\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n \n ### AddThis\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n\n ### General Cleanup\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n{% endif %}\n\n{% if varnish_uri_sanitization_enabled %}\n ###\n # URI Sanitization\n ###\n \n if (req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=\") {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n{% endif %}\n\n{% if varnish_workaround_telusdotcom_browser_profile %}\n ###\n # Workaround for BrowserProfile and Language\/Region Detection on TELUS.com\n ###\n\n if (req.http.Cookie ~ \"BrowserProfile\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.Cookie, \"(.*)language..:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n set req.http.X-Province = std.tolower(regsuball(req.http.Cookie, \"(.*)language..:\\\\.([^\\\\]*)region..:\\\\.([^\\\\]*)(.*)\", \"\\3\"));\n } else {\n if (req.http.Cookie ~ \"lang=\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.Cookie, \"(.*)lang=([^;]*)(.*)\", \"\\2\"));\n } else {\n set req.http.X-Language = \"en\";\n }\n\n if (req.http.Cookie ~ \"prov=\") {\n set req.http.X-Province = std.tolower(regsuball(req.http.Cookie, \"(.*)prov=([^;]*)(.*)\", \"\\2\"));\n } else {\n set req.http.X-Province = \"BC\";\n }\n }\n\n if (req.url ~ \"\/(en|fr)\/\") {\n if (req.url ~ \"\/en\/\" && req.http.X-Language != \"en\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Language)\";\n return(pass);\n }\n if (req.url ~ \"\/fr\/\" && req.http.X-Language != \"fr\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Language)\";\n return(pass);\n }\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Language)\";\n return(pass);\n }\n\n if (req.url ~ \"\/(ab|bc|mb|nb|nl|ns|nt|nu|on|pe|qc|sk|yt)\/\") {\n {% for province in ['ab', 'bc', 'mb', 'nb', 'nl', 'ns', 'nt', 'nu', 'on', 'pe', 'qc', 'sk', 'yt'] %}\n if (req.url ~ \"\/{{ province }}\/\" && req.http.X-Province != \"{{ province }}\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Province)\";\n return(pass);\n }\n {% endfor %}\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Province)\";\n return(pass);\n }\n{% endif %}\n\n{% if varnish_blacklist_enabled %}\n if ((req.url ~ \"{{ varnish_blacklist_regexp }}\")) {\n set req.http.X-Passthrough-Reason = \"Path in Blacklist\";\n return(pass);\n } else {\n{% if varnish_discards_client_cookies %}\n unset req.http.Cookie;\n{% endif %}\n }\n{% endif %}\n\n}\n\n###\n# vcl_hit\n# Called when a cache lookup is successful.\n###\n# The vcl_hit subroutine may terminate with calling return() with one of the following keywords:\n#\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n# deliver\n# Deliver the object. Control passes to vcl_deliver.\n# synth(status code, reason)\n# Return the specified status code to the client and abandon the request.\n###\n\nsub vcl_hit {\n if (obj.ttl > 0s) {\n return (deliver);\n }\n{% if varnish_health_checks_enabled %}\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (fetch);\n }\n{% else %}\n if (obj.ttl + obj.grace > 0s) {\n return (deliver);\n }\n\n return (fetch);\n{% endif %}\n}\n\n###\n# vcl_backend_response\n# Called after the response headers has been successfully retrieved from the backend.\n###\n# The vcl_backend_response subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Possibly insert the object into the cache, then deliver it to the Control will eventually pass to vcl_deliver.\n# abandon\n# Abandon the backend request and generates an error.\n# retry\n# Retry the backend transaction. Increases the retries counter. If the number of retries is higher than max_retries Varnish emits a guru meditation error.\n###\n\nsub vcl_backend_response {\n{% if varnish_workaround_telusdotcom_browser_profile %}\n if (bereq.http.X-Language) {\n set beresp.http.X-Language = bereq.http.X-Language;\n }\n if (bereq.http.X-Province) {\n set beresp.http.X-Province = bereq.http.X-Province;\n }\n{% endif %}\n\n{% if varnish_blacklist_enabled %}\n if (bereq.url ~ \"{{ varnish_blacklist_regexp }}\") {\n set beresp.http.X-Cacheable = \"NO:Path in Blacklist\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n if (bereq.http.X-Passthrough-Reason) {\n set beresp.http.X-Passthrough-Reason = bereq.http.X-Passthrough-Reason;\n return(deliver);\n } else {\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n }\n }\n{% else %}\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n{% endif %}\n\n{% if varnish_cache_diagnostics_enabled %}\n if (bereq.http.Cookie) {\n set beresp.http.X-Cacheable = \"NO:Cookie in Request\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO:Set-Cookie in Response\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.X-No-Cache) {\n set beresp.http.X-Cacheable = \"NO:X-No-Cache\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.ttl <= 0s) {\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n{% endif %}\n\n set beresp.grace = {{ varnish_grace_period }};\n}\n\n###\n# vcl_deliver\n# Called before a cached object is delivered to the client.\n###\n# The vcl_deliver subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Deliver the object to the client.\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n###\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n","old_contents":"vcl 4.0;\n\nimport directors;\nimport std;\n\n###\n# Varnish Documentation\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-built-in-subs.html\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/reference\/vcl.html\n##\n\n{% for backend in varnish_backend_hosts %}\nbackend application_{{ loop.index }} {\n .host = \"{{ backend }}\";\n .port = \"{{ varnish_backend_port }}\";\n{% if varnish_health_checks_enabled %}\n .probe = {\n .url = \"{{ varnish_health_check_url }}\";\n .interval = {{ varnish_health_check_interval }};\n .timeout = {{ varnish_health_check_timeout }};\n .window = {{ varnish_health_check_window }};\n .threshold = {{ varnish_health_check_threshold }};\n }\n{% endif %}\n}\n{% endfor %}\n\n###\n# vcl_init\n# Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n###\n# The vcl_init subroutine may terminate with calling return() with one of the following keywords:\n#\n# ok\n# Normal return, VCL continues loading.\n##\n\nsub vcl_init {\n new application = directors.round_robin();\n{% for backend in varnish_backend_hosts %}\n application.add_backend(application_{{ loop.index }});\n{% endfor %}\n}\n\n###\n# vcl_recv\n# Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use. \n# It is also used to modify the request\n###\n# The vcl_recv subroutine may terminate with calling return() on one of the following keywords:\n#\n# synth(status code, reason)\n# Return a synthetic object with the specified status code to the client and abandon the request.\n# pass\n# Switch to pass mode. Control will eventually pass to vcl_pass.\n# pipe\n# Switch to pipe mode. Control will eventually pass to vcl_pipe.\n# hash\n# Continue processing the object as a potential candidate for caching. Passes the control over to vcl_hash.\n# purge\n# Purge the object and it's variants. Control passes through vcl_hash to vcl_purge.\n#\n\nsub vcl_recv {\n set req.backend_hint = application.backend();\n\n ###\n # Avoid processing uncacheable requests\n ###\n\n if (req.http.Authorization) {\n return (pass);\n }\n\n ###\n # Inject X-Forwarded-For headers, but only once.\n ###\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n{% if varnish_header_sanitization_enabled %}\n ###\n # Header Sanitization\n ###\n\n{% if varnish_discards_port_from_host_header %}\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n{% endif %}\n\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_enabled %}\n ###\n # Cookie Sanitization\n ###\n\n ### Google Analytics\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n\n ### Quantcast\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n \n ### AddThis\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n\n ### General Cleanup\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n{% endif %}\n\n{% if varnish_uri_sanitization_enabled %}\n ###\n # URI Sanitization\n ###\n \n if (req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=\") {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n{% endif %}\n\n{% if varnish_workaround_telusdotcom_browser_profile %}\n ###\n # Workaround for BrowserProfile and Language\/Region Detection on TELUS.com\n ###\n\n if (req.http.Cookie ~ \"BrowserProfile\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.Cookie, \"(.*)language..:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n set req.http.X-Province = std.tolower(regsuball(req.http.Cookie, \"(.*)region..:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n } else {\n if (req.http.Cookie ~ \"lang=\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.Cookie, \"(.*)lang=([^;]*)(.*)\", \"\\2\"));\n } else {\n set req.http.X-Language = \"en\";\n }\n\n if (req.http.Cookie ~ \"prov=\") {\n set req.http.X-Province = std.tolower(regsuball(req.http.Cookie, \"(.*)prov=([^;]*)(.*)\", \"\\2\"));\n } else {\n set req.http.X-Province = \"BC\";\n }\n }\n\n if (req.url ~ \"\/(en|fr)\/\") {\n if (req.url ~ \"\/en\/\" && req.http.X-Language != \"en\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Language)\";\n return(pass);\n }\n if (req.url ~ \"\/fr\/\" && req.http.X-Language != \"fr\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Language)\";\n return(pass);\n }\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Language)\";\n return(pass);\n }\n\n if (req.url ~ \"\/(ab|bc|mb|nb|nl|ns|nt|nu|on|pe|qc|sk|yt)\/\") {\n {% for province in ['ab', 'bc', 'mb', 'nb', 'nl', 'ns', 'nt', 'nu', 'on', 'pe', 'qc', 'sk', 'yt'] %}\n if (req.url ~ \"{{ province }}\" && req.http.X-Province != \"{{ province }}\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Province)\";\n return(pass);\n }\n {% endfor %}\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Province)\";\n return(pass);\n }\n{% endif %}\n\n{% if varnish_blacklist_enabled %}\n if ((req.url ~ \"{{ varnish_blacklist_regexp }}\")) {\n set req.http.X-Passthrough-Reason = \"Path in Blacklist\";\n return(pass);\n } else {\n{% if varnish_discards_client_cookies %}\n unset req.http.Cookie;\n{% endif %}\n }\n{% endif %}\n\n}\n\n###\n# vcl_hit\n# Called when a cache lookup is successful.\n###\n# The vcl_hit subroutine may terminate with calling return() with one of the following keywords:\n#\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n# deliver\n# Deliver the object. Control passes to vcl_deliver.\n# synth(status code, reason)\n# Return the specified status code to the client and abandon the request.\n###\n\nsub vcl_hit {\n if (obj.ttl > 0s) {\n return (deliver);\n }\n{% if varnish_health_checks_enabled %}\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (fetch);\n }\n{% else %}\n if (obj.ttl + obj.grace > 0s) {\n return (deliver);\n }\n\n return (fetch);\n{% endif %}\n}\n\n###\n# vcl_backend_response\n# Called after the response headers has been successfully retrieved from the backend.\n###\n# The vcl_backend_response subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Possibly insert the object into the cache, then deliver it to the Control will eventually pass to vcl_deliver.\n# abandon\n# Abandon the backend request and generates an error.\n# retry\n# Retry the backend transaction. Increases the retries counter. If the number of retries is higher than max_retries Varnish emits a guru meditation error.\n###\n\nsub vcl_backend_response {\n{% if varnish_workaround_telusdotcom_browser_profile %}\n if (bereq.http.X-Language) {\n set beresp.http.X-Language = bereq.http.X-Language;\n }\n if (bereq.http.X-Province) {\n set beresp.http.X-Province = bereq.http.X-Province;\n }\n{% endif %}\n\n{% if varnish_blacklist_enabled %}\n if (bereq.url ~ \"{{ varnish_blacklist_regexp }}\") {\n set beresp.http.X-Cacheable = \"NO:Path in Blacklist\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n if (bereq.http.X-Passthrough-Reason) {\n set beresp.http.X-Passthrough-Reason = bereq.http.X-Passthrough-Reason;\n return(deliver);\n } else {\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n }\n }\n{% else %}\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n{% endif %}\n\n{% if varnish_cache_diagnostics_enabled %}\n if (bereq.http.Cookie) {\n set beresp.http.X-Cacheable = \"NO:Cookie in Request\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO:Set-Cookie in Response\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.X-No-Cache) {\n set beresp.http.X-Cacheable = \"NO:X-No-Cache\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.ttl <= 0s) {\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n{% endif %}\n\n set beresp.grace = {{ varnish_grace_period }};\n}\n\n###\n# vcl_deliver\n# Called before a cached object is delivered to the client.\n###\n# The vcl_deliver subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Deliver the object to the client.\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n###\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"861c508694135f44264b80fa8205007601714109","subject":"When using the old v2 api, ensure we use the old useragent-parser logic and not the new logic we have.","message":"When using the old v2 api, ensure we use the old useragent-parser logic and not the new logic we have.\n\nCurrently we have the old v2 api using the same useragent_parser vcl function as the v3 api, this is due to the fact that both v2 and v3 named the vcl subroutine `useragent_parser` and Varnish doesn't warn\/error when that happens.\n","repos":"JakeChampion\/polyfill-service,JakeChampion\/polyfill-service","old_file":"fastly\/vcl\/normalise-user-agent-3-25-1.vcl","new_file":"fastly\/vcl\/normalise-user-agent-3-25-1.vcl","new_contents":"sub useragent_parser_for_polyfill_service_v2 {\n declare local var.Family STRING;\n set var.Family = \"Other\";\n declare local var.Major STRING;\n set var.Major = \"\";\n declare local var.Minor STRING;\n set var.Minor = \"\";\n declare local var.Patch STRING;\n set var.Patch = \"\";\n if (!req.http.User-Agent) {\n } else if (req.http.User-Agent ~ {\"(iPod|iPod touch|iPhone|iPad);.*CPU.*OS[ +](\\d+)_(\\d+)(?:_(\\d+)|).* like Gecko\\) (?!Version\\\/[\\d.]+)[A-Za-z]+\\\/[\\d.]+\"}) {\n\t\tset var.Family = \"Mobile Safari UI\/WKWebView\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(ESPN)[%20| ]+Radio\/(\\d+)\\.(\\d+)\\.(\\d+) CFNetwork\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(Antenna)\/(\\d+) CFNetwork\"}) {\n\t\tset var.Family = \"AntennaPod\";\n\t\tset var.Major = re.group.2;\n\t} else if (req.http.User-Agent ~ {\"(TopPodcasts)Pro\/(\\d+) CFNetwork\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t} else if (req.http.User-Agent ~ {\"(MusicDownloader)Lite\/(\\d+)\\.(\\d+)\\.(\\d+) CFNetwork\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"^(.*)-iPad\\\/(\\d+)(?:\\.(\\d+)|)(?:\\.(\\d+)|)(?:\\.(\\d+)|) CFNetwork\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"^(.*)-iPhone\/(\\d+)(?:\\.(\\d+)|)(?:\\.(\\d+)|)(?:\\.(\\d+)|) CFNetwork\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"^(.*)\/(\\d+)(?:\\.(\\d+)|)(?:\\.(\\d+)|)(?:\\.(\\d+)|) CFNetwork\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(espn\\.go)\"}) {\n\t\tset var.Family = \"ESPN\";\n\t} else if (req.http.User-Agent ~ {\"(espnradio\\.com)\"}) {\n\t\tset var.Family = \"ESPN\";\n\t} else if (req.http.User-Agent ~ {\"ESPN APP$\"}) {\n\t\tset var.Family = \"ESPN\";\n\t} else if (req.http.User-Agent ~ {\"(audioboom\\.com)\"}) {\n\t\tset var.Family = \"AudioBoom\";\n\t} else if (req.http.User-Agent ~ {\" (Rivo) RHYTHM\"}) {\n\t\tset var.Family = re.group.1;\n\t} else if (req.http.User-Agent ~ {\"(CFNetwork)(?:\/(\\d+)\\.(\\d+)(?:\\.(\\d+)|)|)\"}) {\n\t\tset var.Family = \"CFNetwork\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(Pingdom\\.com_bot_version_)(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = \"PingdomBot\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t} else if (req.http.User-Agent ~ {\"(PingdomTMS)\/(\\d+)\\.(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = \"PingdomBot\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\" (PTST)\/(\\d+)(?:\\.(\\d+)|)$\"}) {\n\t\tset var.Family = \"WebPageTest.org bot\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t} else if (req.http.User-Agent ~ {\"X11; (Datanyze); Linux\"}) {\n\t\tset var.Family = re.group.1;\n\t} else if (req.http.User-Agent ~ {\"(NewRelicPinger)\/(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = \"NewRelicPingerBot\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t} else if (req.http.User-Agent ~ {\"(Tableau)\/(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = \"Tableau\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t} else if (req.http.User-Agent ~ {\"(Salesforce)(?:.)\\\/(\\d+)\\.(\\d?)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t} else if (req.http.User-Agent ~ {\"(\\(StatusCake\\))\"}) {\n\t\tset var.Family = \"StatusCakeBot\";\n\t} else if (req.http.User-Agent ~ {\"(facebookexternalhit)\/(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = \"FacebookBot\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t} else if (req.http.User-Agent ~ {\"Google.*\/\\+\/web\/snippet\"}) {\n\t\tset var.Family = \"GooglePlusBot\";\n\t} else if (req.http.User-Agent ~ {\"via ggpht\\.com GoogleImageProxy\"}) {\n\t\tset var.Family = \"GmailImageProxy\";\n\t} else if (req.http.User-Agent ~ {\"YahooMailProxy; https:\/\/help\\.yahoo\\.com\/kb\/yahoo-mail-proxy-SLN28749\\.html\"}) {\n\t\tset var.Family = \"YahooMailProxy\";\n\t} else if (req.http.User-Agent ~ {\"(Twitterbot)\/(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = \"Twitterbot\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t} else if (req.http.User-Agent ~ {\"\/((?:Ant-|)Nutch|[A-z]+[Bb]ot|[A-z]+[Ss]pider|Axtaris|fetchurl|Isara|ShopSalad|Tailsweep)[ \\-](\\d+)(?:\\.(\\d+)|)(?:\\.(\\d+)|)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"\\b(008|Altresium|Argus|BaiduMobaider|BoardReader|DNSGroup|DataparkSearch|EDI|Goodzer|Grub|INGRID|Infohelfer|LinkedInBot|LOOQ|Nutch|OgScrper|PathDefender|Peew|PostPost|Steeler|Twitterbot|VSE|WebCrunch|WebZIP|Y!J-BR[A-Z]|YahooSeeker|envolk|sproose|wminer)\/(\\d+)(?:\\.(\\d+)|)(?:\\.(\\d+)|)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(MSIE) (\\d+)\\.(\\d+)([a-z]\\d|[a-z]|);.* MSIECrawler\"}) {\n\t\tset var.Family = \"MSIECrawler\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(DAVdroid)\/(\\d+)\\.(\\d+)(?:\\.(\\d+)|)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(Google-HTTP-Java-Client|Apache-HttpClient|Go-http-client|scalaj-http|http%20client|Python-urllib|HttpMonitor|TLSProber|WinHTTP|JNLP|okhttp|aihttp|reqwest|axios|unirest-(?:java|python|ruby|nodejs|php|net))(?:[ \/](\\d+)(?:\\.(\\d+)|)(?:\\.(\\d+)|)|)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(Pinterest(?:bot|))\/(\\d+)(?:\\.(\\d+)|)(?:\\.(\\d+)|)[;\\s(]+\\+https:\/\/www.pinterest.com\/bot.html\"}) {\n\t\tset var.Family = \"Pinterestbot\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(CSimpleSpider|Cityreview Robot|CrawlDaddy|CrawlFire|Finderbots|Index crawler|Job Roboter|KiwiStatus Spider|Lijit Crawler|QuerySeekerSpider|ScollSpider|Trends Crawler|USyd-NLP-Spider|SiteCat Webbot|BotName\\\/\\$BotVersion|123metaspider-Bot|1470\\.net crawler|50\\.nu|8bo Crawler Bot|Aboundex|Accoona-[A-z]{1,30}-Agent|AdsBot-Google(?:-[a-z]{1,30}|)|altavista|AppEngine-Google|archive.{0,30}\\.org_bot|archiver|Ask Jeeves|[Bb]ai[Dd]u[Ss]pider(?:-[A-Za-z]{1,30})(?:-[A-Za-z]{1,30}|)|bingbot|BingPreview|blitzbot|BlogBridge|Bloglovin|BoardReader Blog Indexer|BoardReader Favicon Fetcher|boitho.com-dc|BotSeer|BUbiNG|\\b\\w{0,30}favicon\\w{0,30}\\b|\\bYeti(?:-[a-z]{1,30}|)|Catchpoint(?: bot|)|[Cc]harlotte|Checklinks|clumboot|Comodo HTTP\\(S\\) Crawler|Comodo-Webinspector-Crawler|ConveraCrawler|CRAWL-E|CrawlConvera|Daumoa(?:-feedfetcher|)|Feed Seeker Bot|Feedbin|findlinks|Flamingo_SearchEngine|FollowSite Bot|furlbot|Genieo|gigabot|GomezAgent|gonzo1|(?:[a-zA-Z]{1,30}-|)Googlebot(?:-[a-zA-Z]{1,30}|)|Google SketchUp|grub-client|gsa-crawler|heritrix|HiddenMarket|holmes|HooWWWer|htdig|ia_archiver|ICC-Crawler|Icarus6j|ichiro(?:\/mobile|)|IconSurf|IlTrovatore(?:-Setaccio|)|InfuzApp|Innovazion Crawler|InternetArchive|IP2[a-z]{1,30}Bot|jbot\\b|KaloogaBot|Kraken|Kurzor|larbin|LEIA|LesnikBot|Linguee Bot|LinkAider|LinkedInBot|Lite Bot|Llaut|lycos|Mail\\.RU_Bot|masscan|masidani_bot|Mediapartners-Google|Microsoft .{0,30} Bot|mogimogi|mozDex|MJ12bot|msnbot(?:-media {0,2}|)|msrbot|Mtps Feed Aggregation System|netresearch|Netvibes|NewsGator[^\/]{0,30}|^NING|Nutch[^\/]{0,30}|Nymesis|ObjectsSearch|OgScrper|Orbiter|OOZBOT|PagePeeker|PagesInventory|PaxleFramework|Peeplo Screenshot Bot|PlantyNet_WebRobot|Pompos|Qwantify|Read%20Later|Reaper|RedCarpet|Retreiver|Riddler|Rival IQ|scooter|Scrapy|Scrubby|searchsight|seekbot|semanticdiscovery|SemrushBot|Simpy|SimplePie|SEOstats|SimpleRSS|SiteCon|Slackbot-LinkExpanding|Slack-ImgProxy|Slurp|snappy|Speedy Spider|Squrl Java|Stringer|TheUsefulbot|ThumbShotsBot|Thumbshots\\.ru|Tiny Tiny RSS|Twitterbot|WhatsApp|URL2PNG|Vagabondo|VoilaBot|^vortex|Votay bot|^voyager|WASALive.Bot|Web-sniffer|WebThumb|WeSEE:[A-z]{1,30}|WhatWeb|WIRE|WordPress|Wotbox|www\\.almaden\\.ibm\\.com|Xenu(?:.s|) Link Sleuth|Xerka [A-z]{1,30}Bot|yacy(?:bot|)|YahooSeeker|Yahoo! Slurp|Yandex\\w{1,30}|YodaoBot(?:-[A-z]{1,30}|)|YottaaMonitor|Yowedo|^Zao|^Zao-Crawler|ZeBot_www\\.ze\\.bz|ZooShot|ZyBorg)(?:[ \/]v?(\\d+)(?:\\.(\\d+)(?:\\.(\\d+)|)|)|)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"\\b(Boto3?|JetS3t|aws-(?:cli|sdk-(?:cpp|go|java|nodejs|ruby2?|dotnet-(?:\\d{1,2}|core)))|s3fs)\/(\\d+)\\.(\\d+)(?:\\.(\\d+)|)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"\\[(FBAN\/MessengerForiOS|FB_IAB\/MESSENGER);FBAV\/(\\d+)(?:\\.(\\d+)(?:\\.(\\d+)|)|)\"}) {\n\t\tset var.Family = \"Facebook Messenger\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"\\[FB.*;(FBAV)\/(\\d+)(?:\\.(\\d+)|)(?:\\.(\\d+)|)\"}) {\n\t\tset var.Family = \"Facebook\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"\\[FB.*;\"}) {\n\t\tset var.Family = \"Facebook\";\n\t} else if (req.http.User-Agent ~ {\"(?:\\\/[A-Za-z0-9\\.]+|) {0,5}([A-Za-z0-9 \\-_\\!\\[\\]:]{0,50}(?:[Aa]rchiver|[Ii]ndexer|[Ss]craper|[Bb]ot|[Ss]pider|[Cc]rawl[a-z]{0,50}))[\/ ](\\d+)(?:\\.(\\d+)(?:\\.(\\d+)|)|)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"((?:[A-Za-z][A-Za-z0-9 -]{0,50}|)[^C][^Uu][Bb]ot)\\b(?:(?:[ \/]| v)(\\d+)(?:\\.(\\d+)|)(?:\\.(\\d+)|)|)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"((?:[A-z0-9]{1,50}|[A-z\\-]{1,50} ?|)(?: the |)(?:[Ss][Pp][Ii][Dd][Ee][Rr]|[Ss]crape|[Cc][Rr][Aa][Ww][Ll])[A-z0-9]{0,50})(?:(?:[ \/]| v)(\\d+)(?:\\.(\\d+)|)(?:\\.(\\d+)|)|)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(HbbTV)\/(\\d+)\\.(\\d+)\\.(\\d+) \\(\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(Chimera|SeaMonkey|Camino|Waterfox)\/(\\d+)\\.(\\d+)\\.?([ab]?\\d+[a-z]*|)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(SailfishBrowser)\/(\\d+)\\.(\\d+)(?:\\.(\\d+)|)\"}) {\n\t\tset var.Family = \"Sailfish Browser\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"\\[(Pinterest)\/[^\\]]+\\]\"}) {\n\t\tset var.Family = re.group.1;\n\t} else if (req.http.User-Agent ~ {\"(Pinterest)(?: for Android(?: Tablet|)|)\/(\\d+)(?:\\.(\\d+)|)(?:\\.(\\d+)|)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"Mozilla.*Mobile.*(Instagram).(\\d+)\\.(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"Mozilla.*Mobile.*(Flipboard).(\\d+)\\.(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"Mozilla.*Mobile.*(Flipboard-Briefing).(\\d+)\\.(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"Mozilla.*Mobile.*(Onefootball)\\\/Android.(\\d+)\\.(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(Snapchat)\\\/(\\d+)\\.(\\d+)\\.(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(Firefox)\/(\\d+)\\.(\\d+) Basilisk\/(\\d+)\"}) {\n\t\tset var.Family = \"Basilisk\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(PaleMoon)\/(\\d+)\\.(\\d+)(?:\\.(\\d+)|)\"}) {\n\t\tset var.Family = \"Pale Moon\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(Fennec)\/(\\d+)\\.(\\d+)\\.?([ab]?\\d+[a-z]*)\"}) {\n\t\tset var.Family = \"Firefox Mobile\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(Fennec)\/(\\d+)\\.(\\d+)(pre)\"}) {\n\t\tset var.Family = \"Firefox Mobile\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(Fennec)\/(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = \"Firefox Mobile\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t} else if (req.http.User-Agent ~ {\"(?:Mobile|Tablet);.*(Firefox)\/(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = \"Firefox Mobile\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t} else if (req.http.User-Agent ~ {\"(Namoroka|Shiretoko|Minefield)\/(\\d+)\\.(\\d+)\\.(\\d+(?:pre|))\"}) {\n\t\tset var.Family = \"Firefox (\" re.group.1 \")\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(Firefox)\/(\\d+)\\.(\\d+)(a\\d+[a-z]*)\"}) {\n\t\tset var.Family = \"Firefox Alpha\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(Firefox)\/(\\d+)\\.(\\d+)(b\\d+[a-z]*)\"}) {\n\t\tset var.Family = \"Firefox Beta\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(Firefox)-(?:\\d+\\.\\d+|)\/(\\d+)\\.(\\d+)(a\\d+[a-z]*)\"}) {\n\t\tset var.Family = \"Firefox Alpha\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(Firefox)-(?:\\d+\\.\\d+|)\/(\\d+)\\.(\\d+)(b\\d+[a-z]*)\"}) {\n\t\tset var.Family = \"Firefox Beta\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(Namoroka|Shiretoko|Minefield)\/(\\d+)\\.(\\d+)([ab]\\d+[a-z]*|)\"}) {\n\t\tset var.Family = \"Firefox (\" re.group.1 \")\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(Firefox).*Tablet browser (\\d+)\\.(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = \"MicroB\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(MozillaDeveloperPreview)\/(\\d+)\\.(\\d+)([ab]\\d+[a-z]*|)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(FxiOS)\/(\\d+)\\.(\\d+)(\\.(\\d+)|)(\\.(\\d+)|)\"}) {\n\t\tset var.Family = \"Firefox iOS\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(Flock)\/(\\d+)\\.(\\d+)(b\\d+?)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(RockMelt)\/(\\d+)\\.(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(Navigator)\/(\\d+)\\.(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = \"Netscape\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(Navigator)\/(\\d+)\\.(\\d+)([ab]\\d+)\"}) {\n\t\tset var.Family = \"Netscape\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(Netscape6)\/(\\d+)\\.(\\d+)\\.?([ab]?\\d+|)\"}) {\n\t\tset var.Family = \"Netscape\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(MyIBrow)\/(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = \"My Internet Browser\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t} else if (req.http.User-Agent ~ {\"(UC? ?Browser|UCWEB|U3)[ \/]?(\\d+)\\.(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = \"UC Browser\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(Opera Tablet).*Version\/(\\d+)\\.(\\d+)(?:\\.(\\d+)|)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(Opera Mini)(?:\/att|)\/?(\\d+|)(?:\\.(\\d+)|)(?:\\.(\\d+)|)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(Opera)\/.+Opera Mobi.+Version\/(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = \"Opera Mobile\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t} else if (req.http.User-Agent ~ {\"(Opera)\/(\\d+)\\.(\\d+).+Opera Mobi\"}) {\n\t\tset var.Family = \"Opera Mobile\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t} else if (req.http.User-Agent ~ {\"Opera Mobi.+(Opera)(?:\/|\\s+)(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = \"Opera Mobile\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t} else if (req.http.User-Agent ~ {\"Opera Mobi\"}) {\n\t\tset var.Family = \"Opera Mobile\";\n\t} else if (req.http.User-Agent ~ {\"(Opera)\/9.80.*Version\/(\\d+)\\.(\\d+)(?:\\.(\\d+)|)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(?:Mobile Safari).*(OPR)\/(\\d+)\\.(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = \"Opera Mobile\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(?:Chrome).*(OPR)\/(\\d+)\\.(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = \"Opera\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(Coast)\/(\\d+).(\\d+).(\\d+)\"}) {\n\t\tset var.Family = \"Opera Coast\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(OPiOS)\/(\\d+).(\\d+).(\\d+)\"}) {\n\t\tset var.Family = \"Opera Mini\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"Chrome\/.+( MMS)\/(\\d+).(\\d+).(\\d+)\"}) {\n\t\tset var.Family = \"Opera Neon\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(hpw|web)OS\/(\\d+)\\.(\\d+)(?:\\.(\\d+)|)\"}) {\n\t\tset var.Family = \"webOS Browser\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(luakit)\"}) {\n\t\tset var.Family = \"LuaKit\";\n\t} else if (req.http.User-Agent ~ {\"(Snowshoe)\/(\\d+)\\.(\\d+).(\\d+)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"Gecko\/\\d+ (Lightning)\/(\\d+)\\.(\\d+)\\.?((?:[ab]?\\d+[a-z]*)|(?:\\d*))\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(Firefox)\/(\\d+)\\.(\\d+)\\.(\\d+(?:pre|)) \\(Swiftfox\\)\"}) {\n\t\tset var.Family = \"Swiftfox\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(Firefox)\/(\\d+)\\.(\\d+)([ab]\\d+[a-z]*|) \\(Swiftfox\\)\"}) {\n\t\tset var.Family = \"Swiftfox\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(rekonq)\/(\\d+)\\.(\\d+)(?:\\.(\\d+)|) Safari\"}) {\n\t\tset var.Family = \"Rekonq\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"rekonq\"}) {\n\t\tset var.Family = \"Rekonq\";\n\t} else if (req.http.User-Agent ~ {\"(conkeror|Conkeror)\/(\\d+)\\.(\\d+)(?:\\.(\\d+)|)\"}) {\n\t\tset var.Family = \"Conkeror\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(konqueror)\/(\\d+)\\.(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = \"Konqueror\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(WeTab)-Browser\"}) {\n\t\tset var.Family = re.group.1;\n\t} else if (req.http.User-Agent ~ {\"(Comodo_Dragon)\/(\\d+)\\.(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = \"Comodo Dragon\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(Symphony) (\\d+).(\\d+)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t} else if (req.http.User-Agent ~ {\"PLAYSTATION 3.+WebKit\"}) {\n\t\tset var.Family = \"NetFront NX\";\n\t} else if (req.http.User-Agent ~ {\"PLAYSTATION 3\"}) {\n\t\tset var.Family = \"NetFront\";\n\t} else if (req.http.User-Agent ~ {\"(PlayStation Portable)\"}) {\n\t\tset var.Family = \"NetFront\";\n\t} else if (req.http.User-Agent ~ {\"(PlayStation Vita)\"}) {\n\t\tset var.Family = \"NetFront NX\";\n\t} else if (req.http.User-Agent ~ {\"AppleWebKit.+ (NX)\/(\\d+)\\.(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = \"NetFront NX\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(Nintendo 3DS)\"}) {\n\t\tset var.Family = \"NetFront NX\";\n\t} else if (req.http.User-Agent ~ {\"(Silk)\/(\\d+)\\.(\\d+)(?:\\.([0-9\\-]+)|)\"}) {\n\t\tset var.Family = \"Amazon Silk\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(Puffin)\/(\\d+)\\.(\\d+)(?:\\.(\\d+)|)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"Windows Phone .*(Edge)\/(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = \"Edge Mobile\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t} else if (req.http.User-Agent ~ {\"(SamsungBrowser)\/(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = \"Samsung Internet\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t} else if (req.http.User-Agent ~ {\"(SznProhlizec)\/(\\d+)\\.(\\d+)(?:\\.(\\d+)|)\"}) {\n\t\tset var.Family = \"Seznam prohl%u00ED%u017Ee%u010D\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(coc_coc_browser)\/(\\d+)\\.(\\d+)(?:\\.(\\d+)|)\"}) {\n\t\tset var.Family = \"Coc Coc\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(baidubrowser)[\/\\s](\\d+)(?:\\.(\\d+)|)(?:\\.(\\d+)|)\"}) {\n\t\tset var.Family = \"Baidu Browser\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(FlyFlow)\/(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = \"Baidu Explorer\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t} else if (req.http.User-Agent ~ {\"(MxBrowser)\/(\\d+)\\.(\\d+)(?:\\.(\\d+)|)\"}) {\n\t\tset var.Family = \"Maxthon\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(Crosswalk)\/(\\d+)\\.(\\d+)\\.(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(Line)\/(\\d+)\\.(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = \"LINE\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(MiuiBrowser)\/(\\d+)\\.(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = \"MiuiBrowser\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(Mint Browser)\/(\\d+)\\.(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = \"Mint Browser\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"Mozilla.+Android.+(GSA)\/(\\d+)\\.(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = \"Google\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"Version\/.+(Chrome)\/(\\d+)\\.(\\d+)\\.(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = \"Chrome Mobile WebView\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"; wv\\).+(Chrome)\/(\\d+)\\.(\\d+)\\.(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = \"Chrome Mobile WebView\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(CrMo)\/(\\d+)\\.(\\d+)\\.(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = \"Chrome Mobile\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(CriOS)\/(\\d+)\\.(\\d+)\\.(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = \"Chrome Mobile iOS\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(Chrome)\/(\\d+)\\.(\\d+)\\.(\\d+)\\.(\\d+) Mobile(?:[ \/]|$)\"}) {\n\t\tset var.Family = \"Chrome Mobile\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\" Mobile .*(Chrome)\/(\\d+)\\.(\\d+)\\.(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = \"Chrome Mobile\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(chromeframe)\/(\\d+)\\.(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = \"Chrome Frame\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(SLP Browser)\/(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = \"Tizen Browser\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t} else if (req.http.User-Agent ~ {\"(SE 2\\.X) MetaSr (\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = \"Sogou Explorer\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t} else if (req.http.User-Agent ~ {\"(MQQBrowser\/Mini)(?:(\\d+)(?:\\.(\\d+)|)(?:\\.(\\d+)|)|)\"}) {\n\t\tset var.Family = \"QQ Browser Mini\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(MQQBrowser)(?:\/(\\d+)(?:\\.(\\d+)|)(?:\\.(\\d+)|)|)\"}) {\n\t\tset var.Family = \"QQ Browser Mobile\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(QQBrowser)(?:\/(\\d+)(?:\\.(\\d+)\\.(\\d+)(?:\\.(\\d+)|)|)|)\"}) {\n\t\tset var.Family = \"QQ Browser\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(Rackspace Monitoring)\/(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = \"RackspaceBot\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t} else if (req.http.User-Agent ~ {\"(PyAMF)\/(\\d+)\\.(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(YaBrowser)\/(\\d+)\\.(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = \"Yandex Browser\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(Chrome)\/(\\d+)\\.(\\d+)\\.(\\d+).* MRCHROME\"}) {\n\t\tset var.Family = \"Mail.ru Chromium Browser\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(AOL) (\\d+)\\.(\\d+); AOLBuild (\\d+)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(PodCruncher|Downcast)[ \/]?(\\d+)(?:\\.(\\d+)|)(?:\\.(\\d+)|)(?:\\.(\\d+)|)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\" (BoxNotes)\/(\\d+)\\.(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(Whale)\/(\\d+)\\.(\\d+)\\.(\\d+)\\.(\\d+) Mobile(?:[ \/]|$)\"}) {\n\t\tset var.Family = \"Whale\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(Whale)\/(\\d+)\\.(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = \"Whale\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(Ghost)\/(\\d+)\\.(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(Slack_SSB)\/(\\d+)\\.(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = \"Slack Desktop Client\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(HipChat)\/?(\\d+|)\"}) {\n\t\tset var.Family = \"HipChat Desktop Client\";\n\t\tset var.Major = re.group.2;\n\t} else if (req.http.User-Agent ~ {\"\\b(MobileIron|FireWeb|Jasmine|ANTGalio|Midori|Fresco|Lobo|PaleMoon|Maxthon|Lynx|OmniWeb|Dillo|Camino|Demeter|Fluid|Fennec|Epiphany|Shiira|Sunrise|Spotify|Flock|Netscape|Lunascape|WebPilot|NetFront|Netfront|Konqueror|SeaMonkey|Kazehakase|Vienna|Iceape|Iceweasel|IceWeasel|Iron|K-Meleon|Sleipnir|Galeon|GranParadiso|Opera Mini|iCab|NetNewsWire|ThunderBrowse|Iris|UP\\.Browser|Bunjalloo|Google Earth|Raven for Mac|Openwave|MacOutlook|Electron|OktaMobile)\/(\\d+)\\.(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"Microsoft Office Outlook 12\\.\\d+\\.\\d+|MSOffice 12\"}) {\n\t\tset var.Family = \"Outlook\";\n\t\tset var.Major = \"2007\";\n\t} else if (req.http.User-Agent ~ {\"Microsoft Outlook 14\\.\\d+\\.\\d+|MSOffice 14\"}) {\n\t\tset var.Family = \"Outlook\";\n\t\tset var.Major = \"2010\";\n\t} else if (req.http.User-Agent ~ {\"Microsoft Outlook 15\\.\\d+\\.\\d+\"}) {\n\t\tset var.Family = \"Outlook\";\n\t\tset var.Major = \"2013\";\n\t} else if (req.http.User-Agent ~ {\"Microsoft Outlook (?:Mail )?16\\.\\d+\\.\\d+|MSOffice 16\"}) {\n\t\tset var.Family = \"Outlook\";\n\t\tset var.Major = \"2016\";\n\t} else if (req.http.User-Agent ~ {\"Microsoft Office (Word) 2014\"}) {\n\t\tset var.Family = re.group.1;\n\t} else if (req.http.User-Agent ~ {\"Outlook-Express\\\/7\\.0.*\"}) {\n\t\tset var.Family = \"Windows Live Mail\";\n\t} else if (req.http.User-Agent ~ {\"(Airmail) (\\d+)\\.(\\d+)(?:\\.(\\d+)|)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(Thunderbird)\/(\\d+)\\.(\\d+)(?:\\.(\\d+(?:pre|))|)\"}) {\n\t\tset var.Family = \"Thunderbird\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(Postbox)\/(\\d+)\\.(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = \"Postbox\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(Barca(?:Pro)?)\/(\\d+)\\.(\\d+)(?:\\.(\\d+)|)\"}) {\n\t\tset var.Family = \"Barca\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(Lotus-Notes)\/(\\d+)\\.(\\d+)(?:\\.(\\d+)|)\"}) {\n\t\tset var.Family = \"Lotus Notes\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(Vivaldi)\/(\\d+)\\.(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(Edge?)\/(\\d+)(?:\\.(\\d+)|)(?:\\.(\\d+)|)(?:\\.(\\d+)|)\"}) {\n\t\tset var.Family = \"Edge\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(brave)\/(\\d+)\\.(\\d+)\\.(\\d+) Chrome\"}) {\n\t\tset var.Family = \"Brave\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(Chrome)\/(\\d+)\\.(\\d+)\\.(\\d+)[\\d.]* Iron[^\/]\"}) {\n\t\tset var.Family = \"Iron\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"\\b(Dolphin)(?: |HDCN\/|\/INT\\-)(\\d+)\\.(\\d+)(?:\\.(\\d+)|)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(HeadlessChrome)(?:\/(\\d+)\\.(\\d+)\\.(\\d+)|)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(Evolution)\/(\\d+)\\.(\\d+)\\.(\\d+\\.\\d+)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(RCM CardDAV plugin)\/(\\d+)\\.(\\d+)\\.(\\d+(?:-dev|))\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(bingbot|Bolt|AdobeAIR|Jasmine|IceCat|Skyfire|Midori|Maxthon|Lynx|Arora|IBrowse|Dillo|Camino|Shiira|Fennec|Phoenix|Flock|Netscape|Lunascape|Epiphany|WebPilot|Opera Mini|Opera|NetFront|Netfront|Konqueror|Googlebot|SeaMonkey|Kazehakase|Vienna|Iceape|Iceweasel|IceWeasel|Iron|K-Meleon|Sleipnir|Galeon|GranParadiso|iCab|iTunes|MacAppStore|NetNewsWire|Space Bison|Stainless|Orca|Dolfin|BOLT|Minimo|Tizen Browser|Polaris|Abrowser|Planetweb|ICE Browser|mDolphin|qutebrowser|Otter|QupZilla|MailBar|kmail2|YahooMobileMail|ExchangeWebServices|ExchangeServicesClient|Dragon|Outlook-iOS-Android)\/(\\d+)\\.(\\d+)(?:\\.(\\d+)|)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(Chromium|Chrome)\/(\\d+)\\.(\\d+)(?:\\.(\\d+)|)(?:\\.(\\d+)|)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(IEMobile)[ \/](\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = \"IE Mobile\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t} else if (req.http.User-Agent ~ {\"(BacaBerita App)\\\/(\\d+)\\.(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"^(bPod|Pocket Casts|Player FM)$\"}) {\n\t\tset var.Family = re.group.1;\n\t} else if (req.http.User-Agent ~ {\"^(AlexaMediaPlayer|VLC)\/(\\d+)\\.(\\d+)\\.([^.\\s]+)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"^(AntennaPod|WMPlayer|Zune|Podkicker|Radio|ExoPlayerDemo|Overcast|PocketTunes|NSPlayer|okhttp|DoggCatcher|QuickNews|QuickTime|Peapod|Podcasts|GoldenPod|VLC|Spotify|Miro|MediaGo|Juice|iPodder|gPodder|Banshee)\/(\\d+)\\.(\\d+)(?:\\.(\\d+)|)(?:\\.(\\d+)|)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"^(Peapod|Liferea)\/([^.\\s]+)\\.([^.\\s]+|)\\.?([^.\\s]+|)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"^(bPod|Player FM) BMID\/(\\S+)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t} else if (req.http.User-Agent ~ {\"^(Podcast ?Addict)\/v(\\d+) \"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t} else if (req.http.User-Agent ~ {\"^(Podcast ?Addict) \"}) {\n\t\tset var.Family = \"PodcastAddict\";\n\t} else if (req.http.User-Agent ~ {\"(Replay) AV\"}) {\n\t\tset var.Family = re.group.1;\n\t} else if (req.http.User-Agent ~ {\"(VOX) Music Player\"}) {\n\t\tset var.Family = re.group.1;\n\t} else if (req.http.User-Agent ~ {\"(CITA) RSS Aggregator\/(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t} else if (req.http.User-Agent ~ {\"(Pocket Casts)$\"}) {\n\t\tset var.Family = re.group.1;\n\t} else if (req.http.User-Agent ~ {\"(Player FM)$\"}) {\n\t\tset var.Family = re.group.1;\n\t} else if (req.http.User-Agent ~ {\"(LG Player|Doppler|FancyMusic|MediaMonkey|Clementine) (\\d+)\\.(\\d+)\\.?([^.\\s]+|)\\.?([^.\\s]+|)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(philpodder)\/(\\d+)\\.(\\d+)\\.?([^.\\s]+|)\\.?([^.\\s]+|)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(Player FM|Pocket Casts|DoggCatcher|Spotify|MediaMonkey|MediaGo|BashPodder)\"}) {\n\t\tset var.Family = re.group.1;\n\t} else if (req.http.User-Agent ~ {\"(QuickTime)\\.(\\d+)\\.(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(Kinoma)(\\d+)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t} else if (req.http.User-Agent ~ {\"(Fancy) Cloud Music (\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = \"FancyMusic\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t} else if (req.http.User-Agent ~ {\"EspnDownloadManager\"}) {\n\t\tset var.Family = \"ESPN\";\n\t} else if (req.http.User-Agent ~ {\"(ESPN) Radio (\\d+)\\.(\\d+)(?:\\.(\\d+)|) ?(?:rv:(\\d+)|) \"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(podracer|jPodder) v ?(\\d+)\\.(\\d+)(?:\\.(\\d+)|)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(ZDM)\/(\\d+)\\.(\\d+)[; ]?\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t} else if (req.http.User-Agent ~ {\"(Zune|BeyondPod) (\\d+)(?:\\.(\\d+)|)[\\);]\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t} else if (req.http.User-Agent ~ {\"(WMPlayer)\/(\\d+)\\.(\\d+)\\.(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"^(Lavf)\"}) {\n\t\tset var.Family = \"WMPlayer\";\n\t} else if (req.http.User-Agent ~ {\"^(RSSRadio)[ \/]?(\\d+|)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t} else if (req.http.User-Agent ~ {\"(RSS_Radio) (\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = \"RSSRadio\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t} else if (req.http.User-Agent ~ {\"(Podkicker) \\S+\/(\\d+)\\.(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = \"Podkicker\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"^(HTC) Streaming Player \\S+ \/ \\S+ \/ \\S+ \/ (\\d+)\\.(\\d+)(?:\\.(\\d+)|)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"^(Stitcher)\/iOS\"}) {\n\t\tset var.Family = re.group.1;\n\t} else if (req.http.User-Agent ~ {\"^(Stitcher)\/Android\"}) {\n\t\tset var.Family = re.group.1;\n\t} else if (req.http.User-Agent ~ {\"^(VLC) .*version (\\d+)\\.(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\" (VLC) for\"}) {\n\t\tset var.Family = re.group.1;\n\t} else if (req.http.User-Agent ~ {\"(vlc)\/(\\d+)\\.(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = \"VLC\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"^(foobar)\\S+\/([^.\\s]+)\\.([^.\\s]+|)\\.?([^.\\s]+|)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"^(Clementine)\\S+ ([^.\\s]+)\\.([^.\\s]+|)\\.?([^.\\s]+|)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(amarok)\/([^.\\s]+)\\.([^.\\s]+|)\\.?([^.\\s]+|)\"}) {\n\t\tset var.Family = \"Amarok\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(Custom)-Feed Reader\"}) {\n\t\tset var.Family = re.group.1;\n\t} else if (req.http.User-Agent ~ {\"(iRider|Crazy Browser|SkipStone|iCab|Lunascape|Sleipnir|Maemo Browser) (\\d+)\\.(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(iCab|Lunascape|Opera|Android|Jasmine|Polaris|Microsoft SkyDriveSync|The Bat!) (\\d+)\\.(\\d+)(?:\\.(\\d+)|)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(Kindle)\/(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t} else if (req.http.User-Agent ~ {\"(Android) Donut\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = \"1\";\n\t\tset var.Minor=\"2\";\n\t} else if (req.http.User-Agent ~ {\"(Android) Eclair\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = \"2\";\n\t\tset var.Minor=\"1\";\n\t} else if (req.http.User-Agent ~ {\"(Android) Froyo\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = \"2\";\n\t\tset var.Minor=\"2\";\n\t} else if (req.http.User-Agent ~ {\"(Android) Gingerbread\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = \"2\";\n\t\tset var.Minor=\"3\";\n\t} else if (req.http.User-Agent ~ {\"(Android) Honeycomb\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = \"3\";\n\t} else if (req.http.User-Agent ~ {\"(MSIE) (\\d+)\\.(\\d+).*XBLWP7\"}) {\n\t\tset var.Family = \"IE Large Screen\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t} else if (req.http.User-Agent ~ {\"(Nextcloud)\"}) {\n\t\tset var.Family = re.group.1;\n\t} else if (req.http.User-Agent ~ {\"(mirall)\/(\\d+)\\.(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(ownCloud-android)\/(\\d+)\\.(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = \"Owncloud\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(OC)\/(\\d+)\\.(\\d+)\\.(\\d+)\\.(\\d+) \\(Skype for Business\\)\"}) {\n\t\tset var.Family = \"Skype\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(Obigo)InternetBrowser\"}) {\n\t\tset var.Family = re.group.1;\n\t} else if (req.http.User-Agent ~ {\"(Obigo)\\-Browser\"}) {\n\t\tset var.Family = re.group.1;\n\t} else if (req.http.User-Agent ~ {\"(Obigo|OBIGO)[^\\d]*(\\d+)(?:.(\\d+)|)\"}) {\n\t\tset var.Family = \"Obigo\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t} else if (req.http.User-Agent ~ {\"(MAXTHON|Maxthon) (\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = \"Maxthon\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t} else if (req.http.User-Agent ~ {\"(Maxthon|MyIE2|Uzbl|Shiira)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = \"0\";\n\t} else if (req.http.User-Agent ~ {\"(BrowseX) \\((\\d+)\\.(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(NCSA_Mosaic)\/(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = \"NCSA Mosaic\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t} else if (req.http.User-Agent ~ {\"(POLARIS)\/(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = \"Polaris\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t} else if (req.http.User-Agent ~ {\"(Embider)\/(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = \"Polaris\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t} else if (req.http.User-Agent ~ {\"(BonEcho)\/(\\d+)\\.(\\d+)\\.?([ab]?\\d+|)\"}) {\n\t\tset var.Family = \"Bon Echo\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(iPod|iPhone|iPad).+GSA\/(\\d+)\\.(\\d+)\\.(\\d+) Mobile\"}) {\n\t\tset var.Family = \"Google\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(iPod|iPhone|iPad).+Version\/(\\d+)\\.(\\d+)(?:\\.(\\d+)|).*[ +]Safari\"}) {\n\t\tset var.Family = \"Mobile Safari\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(iPod|iPod touch|iPhone|iPad);.*CPU.*OS[ +](\\d+)_(\\d+)(?:_(\\d+)|).* AppleNews\\\/\\d+\\.\\d+\\.\\d+?\"}) {\n\t\tset var.Family = \"Mobile Safari UI\/WKWebView\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(iPod|iPhone|iPad).+Version\/(\\d+)\\.(\\d+)(?:\\.(\\d+)|)\"}) {\n\t\tset var.Family = \"Mobile Safari UI\/WKWebView\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(iPod|iPod touch|iPhone|iPad);.*CPU.*OS[ +](\\d+)_(\\d+)(?:_(\\d+)|).*Mobile.*[ +]Safari\"}) {\n\t\tset var.Family = \"Mobile Safari\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(iPod|iPod touch|iPhone|iPad);.*CPU.*OS[ +](\\d+)_(\\d+)(?:_(\\d+)|).*Mobile\"}) {\n\t\tset var.Family = \"Mobile Safari UI\/WKWebView\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(iPod|iPhone|iPad).* Safari\"}) {\n\t\tset var.Family = \"Mobile Safari\";\n\t} else if (req.http.User-Agent ~ {\"(iPod|iPhone|iPad)\"}) {\n\t\tset var.Family = \"Mobile Safari UI\/WKWebView\";\n\t} else if (req.http.User-Agent ~ {\"(Watch)(\\d+),(\\d+)\"}) {\n\t\tset var.Family = \"Apple \" re.group.1 \" App\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t} else if (req.http.User-Agent ~ {\"(Outlook-iOS)\/\\d+\\.\\d+\\.prod\\.iphone \\((\\d+)\\.(\\d+)\\.(\\d+)\\)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(AvantGo) (\\d+).(\\d+)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t} else if (req.http.User-Agent ~ {\"(OneBrowser)\/(\\d+).(\\d+)\"}) {\n\t\tset var.Family = \"ONE Browser\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t} else if (req.http.User-Agent ~ {\"(Avant)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = \"1\";\n\t} else if (req.http.User-Agent ~ {\"(QtCarBrowser)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = \"1\";\n\t} else if (req.http.User-Agent ~ {\"^(iBrowser\/Mini)(\\d+).(\\d+)\"}) {\n\t\tset var.Family = \"iBrowser Mini\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t} else if (req.http.User-Agent ~ {\"^(iBrowser|iRAPP)\/(\\d+).(\\d+)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t} else if (req.http.User-Agent ~ {\"^(Nokia)\"}) {\n\t\tset var.Family = \"Nokia Services (WAP) Browser\";\n\t} else if (req.http.User-Agent ~ {\"(NokiaBrowser)\/(\\d+)\\.(\\d+).(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = \"Nokia Browser\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(NokiaBrowser)\/(\\d+)\\.(\\d+).(\\d+)\"}) {\n\t\tset var.Family = \"Nokia Browser\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(NokiaBrowser)\/(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = \"Nokia Browser\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t} else if (req.http.User-Agent ~ {\"(BrowserNG)\/(\\d+)\\.(\\d+).(\\d+)\"}) {\n\t\tset var.Family = \"Nokia Browser\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(Series60)\/5\\.0\"}) {\n\t\tset var.Family = \"Nokia Browser\";\n\t\tset var.Major = \"7\";\n\t\tset var.Minor=\"0\";\n\t} else if (req.http.User-Agent ~ {\"(Series60)\/(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = \"Nokia OSS Browser\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t} else if (req.http.User-Agent ~ {\"(S40OviBrowser)\/(\\d+)\\.(\\d+)\\.(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = \"Ovi Browser\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(Nokia)[EN]?(\\d+)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t} else if (req.http.User-Agent ~ {\"(PlayBook).+RIM Tablet OS (\\d+)\\.(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = \"BlackBerry WebKit\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(Black[bB]erry|BB10).+Version\/(\\d+)\\.(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = \"BlackBerry WebKit\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(Black[bB]erry)\\s?(\\d+)\"}) {\n\t\tset var.Family = \"BlackBerry\";\n\t\tset var.Major = re.group.2;\n\t} else if (req.http.User-Agent ~ {\"(OmniWeb)\/v(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t} else if (req.http.User-Agent ~ {\"(Blazer)\/(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = \"Palm Blazer\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t} else if (req.http.User-Agent ~ {\"(Pre)\/(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = \"Palm Pre\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t} else if (req.http.User-Agent ~ {\"(ELinks)\/(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t} else if (req.http.User-Agent ~ {\"(ELinks) \\((\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t} else if (req.http.User-Agent ~ {\"(Links) \\((\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t} else if (req.http.User-Agent ~ {\"(QtWeb) Internet Browser\/(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t} else if (req.http.User-Agent ~ {\"(PhantomJS)\/(\\d+)\\.(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(AppleWebKit)\/(\\d+)(?:\\.(\\d+)|)\\+ .* Safari\"}) {\n\t\tset var.Family = \"WebKit Nightly\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t} else if (req.http.User-Agent ~ {\"(Version)\/(\\d+)\\.(\\d+)(?:\\.(\\d+)|).*Safari\/\"}) {\n\t\tset var.Family = \"Safari\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(Safari)\/\\d+\"}) {\n\t\tset var.Family = re.group.1;\n\t} else if (req.http.User-Agent ~ {\"(OLPC)\/Update(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t} else if (req.http.User-Agent ~ {\"(OLPC)\/Update()\\.(\\d+)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = \"0\";\n\t\tset var.Minor = re.group.3;\n\t} else if (req.http.User-Agent ~ {\"(SEMC\\-Browser)\/(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t} else if (req.http.User-Agent ~ {\"(Teleca)\"}) {\n\t\tset var.Family = \"Teleca Browser\";\n\t} else if (req.http.User-Agent ~ {\"(Phantom)\/V(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = \"Phantom Browser\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t} else if (req.http.User-Agent ~ {\"(Trident)\/(7|8)\\.(0)\"}) {\n\t\tset var.Family = \"IE\";\n\t\tset var.Major = \"11\";\n\t\tset var.Minor = re.group.3;\n\t} else if (req.http.User-Agent ~ {\"(Trident)\/(6)\\.(0)\"}) {\n\t\tset var.Family = \"IE\";\n\t\tset var.Major = \"10\";\n\t\tset var.Minor = re.group.3;\n\t} else if (req.http.User-Agent ~ {\"(Trident)\/(5)\\.(0)\"}) {\n\t\tset var.Family = \"IE\";\n\t\tset var.Major = \"9\";\n\t\tset var.Minor = re.group.3;\n\t} else if (req.http.User-Agent ~ {\"(Trident)\/(4)\\.(0)\"}) {\n\t\tset var.Family = \"IE\";\n\t\tset var.Major = \"8\";\n\t\tset var.Minor = re.group.3;\n\t} else if (req.http.User-Agent ~ {\"(Espial)\/(\\d+)(?:\\.(\\d+)|)(?:\\.(\\d+)|)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(AppleWebKit)\/(\\d+)\\.(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = \"Apple Mail\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(Firefox)\/(\\d+)\\.(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(Firefox)\/(\\d+)\\.(\\d+)(pre|[ab]\\d+[a-z]*|)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"([MS]?IE) (\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = \"IE\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t} else if (req.http.User-Agent ~ {\"(python-requests)\/(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = \"Python Requests\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t} else if (req.http.User-Agent ~ {\"\\b(Windows-Update-Agent|Microsoft-CryptoAPI|SophosUpdateManager|SophosAgent|Debian APT-HTTP|Ubuntu APT-HTTP|libcurl-agent|libwww-perl|urlgrabber|curl|PycURL|Wget|aria2|Axel|OpenBSD ftp|lftp|jupdate|insomnia|fetch libfetch|akka-http|got)(?:[ \/](\\d+)(?:\\.(\\d+)|)(?:\\.(\\d+)|)|)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(Python\/3\\.\\d{1,3} aiohttp)\/(\\d+)\\.(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(Python\/3\\.\\d{1,3} aiohttp)\/(\\d+)\\.(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(Java)[\/ ]{0,1}\\d+\\.(\\d+)\\.(\\d+)[_-]*([a-zA-Z0-9]+|)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"^(Cyberduck)\/(\\d+)\\.(\\d+)\\.(\\d+)(?:\\.\\d+|)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"^(S3 Browser) (\\d+)-(\\d+)-(\\d+)(?:\\s*http:\/\/s3browser\\.com|)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"(S3Gof3r)\"}) {\n\t\tset var.Family = re.group.1;\n\t} else if (req.http.User-Agent ~ {\"\\b(ibm-cos-sdk-(?:core|java|js|python))\/(\\d+)\\.(\\d+)(?:\\.(\\d+)|)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"^(rusoto)\/(\\d+)\\.(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"^(rclone)\/v(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t} else if (req.http.User-Agent ~ {\"^(Roku)\/DVP-(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t} else if (req.http.User-Agent ~ {\"(Kurio)\\\/(\\d+)\\.(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = \"Kurio App\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"^(Box(?: Sync)?)\/(\\d+)\\.(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = re.group.1;\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t} else if (req.http.User-Agent ~ {\"^(ViaFree|Viafree)-(?:tvOS-)?[A-Z]{2}\/(\\d+)\\.(\\d+)\\.(\\d+)\"}) {\n\t\tset var.Family = \"ViaFree\";\n\t\tset var.Major = re.group.2;\n\t\tset var.Minor = re.group.3;\n\t\tset var.Patch = re.group.4;\n\t}\n set req.http.useragent_parser_family=var.Family;\n set req.http.useragent_parser_major=var.Major;\n set req.http.useragent_parser_minor=var.Minor;\n set req.http.useragent_parser_patch=var.Patch;\n}\n\nsub normalise_user_agent_3_25_1 {\n\tif (req.http.User-Agent) {\n\t\t# Longest genuine UA seen so far: 255 chars (Facebook in-app on iOS):\n\t\tset req.http.User-Agent = if(req.http.User-Agent ~ \"(^[\\s\\S]{0,300})\", re.group.1, \"other\/0.0.0\");\n\n\t\t# Remove UA tokens that unnecessarily complicate UA parsing\n\n\t\t# Chrome and Opera on iOS uses a UIWebView of the underlying platform to render\n\t\t# content. By stripping the CriOS or OPiOS strings, the useragent parser will alias the\n\t\t# user agent to ios_saf for the UIWebView, which is closer to the actual renderer\n\t\tset req.http.User-Agent = regsub(req.http.User-Agent, \"((CriOS|OPiOS)\/(\\d+)\\.(\\d+)\\.(\\d+)\\.(\\d+)|(FxiOS\/(\\d+)\\.(\\d+)))\", \"\");\n\n\t\t# # Vivaldi browser is recognised by UA module but is actually identical to Chrome, so\n\t\t# # the best way to get accurate targeting is to remove the vivaldi token from the UA\n\t\tset req.http.User-Agent = regsub(req.http.User-Agent, \"(?i) vivaldi\/[\\d\\.]+\\d+\", \"\");\n\n\t\t# # Facebook in-app browser `[FBAN\/.....]` or `[FB_IAB\/.....]` (see #990)\n\t\tset req.http.User-Agent = regsub(req.http.User-Agent, \"(?i) \\[(FB_IAB|FBAN|FBIOS|FB4A)\/[^\\]]+\\]\", \"\");\n\n\t\t# # Electron ` Electron\/X.Y.Z` (see #1129)\n\t\tset req.http.User-Agent = regsub(req.http.User-Agent, \"(?i) Electron\/[\\d\\.]+\\d+\", \"\");\n\n\t\tcall useragent_parser_for_polyfill_service_v2;\n\n\t\t# Clone the original values for later modification. This helps when debugging as it let's us see what the useragent_parser function returned.\n\t\tset req.http.normalized_user_agent_family = req.http.useragent_parser_family;\n\t\tset req.http.normalized_user_agent_major_version = req.http.useragent_parser_major;\n\t\tset req.http.normalized_user_agent_minor_version = req.http.useragent_parser_minor;\n\t\tset req.http.normalized_user_agent_patch_version = req.http.useragent_parser_patch;\n\n\t\tset req.http.normalized_user_agent_patch_version = \"0\";\n\t\tset req.http.normalized_user_agent_family = std.tolower(req.http.useragent_parser_family);\n\n\t\t# Aliases\n\t\tif (req.http.normalized_user_agent_family == \"blackberry webkit\") {\n\t\t\tset req.http.normalized_user_agent_family = \"bb\";\n\t\t}\n\t\tif (req.http.normalized_user_agent_family == \"blackberry\") {\n\t\t\tset req.http.normalized_user_agent_family = \"bb\";\n\t\t}\n\t\tif (req.http.normalized_user_agent_family == \"pale moon (firefox variant)\") {\n\t\t\tset req.http.normalized_user_agent_family = \"firefox\";\n\t\t}\n\t\tif (req.http.normalized_user_agent_family == \"pale moon\") {\n\t\t\tset req.http.normalized_user_agent_family = \"firefox\";\n\t\t}\n\t\tif (req.http.normalized_user_agent_family == \"firefox mobile\") {\n\t\t\tset req.http.normalized_user_agent_family = \"firefox_mob\";\n\t\t}\n\t\tif (req.http.normalized_user_agent_family == \"firefox namoroka\") {\n\t\t\tset req.http.normalized_user_agent_family = \"firefox\";\n\t\t}\n\t\tif (req.http.normalized_user_agent_family == \"firefox shiretoko\") {\n\t\t\tset req.http.normalized_user_agent_family = \"firefox\";\n\t\t}\n\t\tif (req.http.normalized_user_agent_family == \"firefox minefield\") {\n\t\t\tset req.http.normalized_user_agent_family = \"firefox\";\n\t\t}\n\t\tif (req.http.normalized_user_agent_family == \"firefox alpha\") {\n\t\t\tset req.http.normalized_user_agent_family = \"firefox\";\n\t\t}\n\t\tif (req.http.normalized_user_agent_family == \"firefox beta\") {\n\t\t\tset req.http.normalized_user_agent_family = \"firefox\";\n\t\t}\n\t\tif (req.http.normalized_user_agent_family == \"microb\") {\n\t\t\tset req.http.normalized_user_agent_family = \"firefox\";\n\t\t}\n\t\tif (req.http.normalized_user_agent_family == \"mozilladeveloperpreview\") {\n\t\t\tset req.http.normalized_user_agent_family = \"firefox\";\n\t\t}\n\t\tif (req.http.normalized_user_agent_family == \"iceweasel\") {\n\t\t\tset req.http.normalized_user_agent_family = \"firefox\";\n\t\t}\n\t\tif (req.http.normalized_user_agent_family == \"opera tablet\") {\n\t\t\tset req.http.normalized_user_agent_family = \"opera\";\n\t\t}\n\t\tif (req.http.normalized_user_agent_family == \"opera mobile\") {\n\t\t\tset req.http.normalized_user_agent_family = \"op_mob\";\n\t\t}\n\t\tif (req.http.normalized_user_agent_family == \"opera mini\") {\n\t\t\tset req.http.normalized_user_agent_family = \"op_mini\";\n\t\t}\n\t\tif (req.http.normalized_user_agent_family == \"chrome mobile\") {\n\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t}\n\t\tif (req.http.normalized_user_agent_family == \"chrome frame\") {\n\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t}\n\t\tif (req.http.normalized_user_agent_family == \"chromium\") {\n\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t}\n\t\tif (req.http.normalized_user_agent_family == \"ie mobile\") {\n\t\t\tset req.http.normalized_user_agent_family = \"ie_mob\";\n\t\t}\n\t\tif (req.http.normalized_user_agent_family == \"ie large screen\") {\n\t\t\tset req.http.normalized_user_agent_family = \"ie\";\n\t\t}\n\t\tif (req.http.normalized_user_agent_family == \"internet explorer\") {\n\t\t\tset req.http.normalized_user_agent_family = \"ie\";\n\t\t}\n\t\tif (req.http.normalized_user_agent_family == \"edge\") {\n\t\t\tset req.http.normalized_user_agent_family = \"ie\";\n\t\t}\n\t\tif (req.http.normalized_user_agent_family == \"edge mobile\") {\n\t\t\tset req.http.normalized_user_agent_family = \"ie\";\n\t\t}\n\t\tif (req.http.normalized_user_agent_family == \"uc browser\") {\n\t\t\tif (req.http.normalized_user_agent_major_version == \"9\" && req.http.normalized_user_agent_minor_version == \"9\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"ie\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"10\";\n\t\t\t}\n\t\t}\n\t\tif (req.http.normalized_user_agent_family == \"chrome mobile ios\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"ios_chr\";\n\t\t\t}\n\n\t\tif (req.http.normalized_user_agent_family == \"mobile safari\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"ios_saf\";\n\t\t\t}\n\t\tif (req.http.normalized_user_agent_family == \"iphone\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"ios_saf\";\n\t\t\t}\n\t\tif (req.http.normalized_user_agent_family == \"iphone simulator\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"ios_saf\";\n\t\t\t}\n\t\tif (req.http.normalized_user_agent_family == \"mobile safari uiwebview\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"ios_saf\";\n\t\t\t}\n\t\tif (req.http.normalized_user_agent_family == \"mobile safari ui\/wkwebview\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"ios_saf\";\n\t\t\t}\n\n\t\tif (req.http.normalized_user_agent_family == \"samsung internet\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"samsung_mob\";\n\t\t\t}\n\n\t\tif (req.http.normalized_user_agent_family == \"phantomjs\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"safari\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"5\";\n\t\t\t}\n\n\t\tif (req.http.normalized_user_agent_family == \"yandex browser\") {\n\t\t\tif (req.http.normalized_user_agent_major_version == \"14\" && req.http.normalized_user_agent_minor_version == \"10\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"37\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"14\" && req.http.normalized_user_agent_minor_version == \"10\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"36\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"14\" && req.http.normalized_user_agent_minor_version == \"10\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"35\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"14\" && req.http.normalized_user_agent_minor_version == \"10\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"34\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"14\" && req.http.normalized_user_agent_minor_version == \"10\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"33\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"14\" && req.http.normalized_user_agent_minor_version == \"10\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"32\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"14\" && req.http.normalized_user_agent_minor_version == \"10\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"30\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"14\" && req.http.normalized_user_agent_minor_version == \"10\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"28\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"14\" && req.http.normalized_user_agent_minor_version == \"10\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"60\";\n\t\t\t}\n\t\t}\n\n\t\tif (req.http.normalized_user_agent_family == \"opera\") {\n\t\t\tif (req.http.normalized_user_agent_major_version == \"20\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"33\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"21\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"34\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"22\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"35\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"23\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"36\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"24\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"37\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"25\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"38\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"26\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"39\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"27\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"40\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"28\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"41\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"29\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"42\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"30\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"43\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"31\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"44\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"32\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"45\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"33\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"46\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"34\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"47\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"35\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"48\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"36\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"49\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"37\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"50\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"38\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"51\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"39\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"52\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"40\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"53\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"41\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"54\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"42\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"55\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"43\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"56\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"44\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"57\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"45\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"58\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"46\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"59\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"47\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"60\";\n\t\t\t}\n\t\t}\n\n\t\tif (req.http.normalized_user_agent_family == \"googlebot\") {\n\t\t\tif (req.http.normalized_user_agent_major_version == \"2\" && req.http.normalized_user_agent_minor_version == \"1\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"41\";\n\t\t\t}\n\t\t}\n\n\t\t# Supported Browsers and minimum supported versions.\n\t\tif (\n\t\t\t# ie: \">=7\",\n\t\t\t(req.http.normalized_user_agent_family == \"ie\" && std.atoi(req.http.normalized_user_agent_major_version) >= 7) ||\n\t\t\t# ie_mob: \">=8\",\n\t\t\t(req.http.normalized_user_agent_family == \"ie_mob\" && std.atoi(req.http.normalized_user_agent_major_version) >= 8) ||\n\t\t\t# chrome: \"*\",\n\t\t\t(req.http.normalized_user_agent_family == \"chrome\") ||\n\t\t\t# safari: \">=4\",\n\t\t\t(req.http.normalized_user_agent_family == \"safari\" && std.atoi(req.http.normalized_user_agent_major_version) >= 4) ||\n\t\t\t# ios_saf: \">=4\",\n\t\t\t(req.http.normalized_user_agent_family == \"ios_saf\" && std.atoi(req.http.normalized_user_agent_major_version) >= 4) ||\n\t\t\t# ios_chr: \">=4\",\n\t\t\t(req.http.normalized_user_agent_family == \"ios_chr\" && std.atoi(req.http.normalized_user_agent_major_version) >= 4) ||\n\t\t\t# firefox: \">=3.6\",\n\t\t\t(req.http.normalized_user_agent_family == \"firefox\" && std.atoi(req.http.normalized_user_agent_major_version) >= 4) ||\n\t\t\t(req.http.normalized_user_agent_family == \"firefox\" && std.atoi(req.http.normalized_user_agent_major_version) == 3 && std.atoi(req.http.normalized_user_agent_minor_version) >= 6) ||\n\t\t\t# firefox_mob: \">=4\",\n\t\t\t(req.http.normalized_user_agent_family == \"firefox_mob\" && std.atoi(req.http.normalized_user_agent_major_version) >= 4) ||\n\t\t\t# android: \">=3\",\n\t\t\t(req.http.normalized_user_agent_family == \"android\" && std.atoi(req.http.normalized_user_agent_major_version) >= 3) ||\n\t\t\t# opera: \">=11\",\n\t\t\t(req.http.normalized_user_agent_family == \"opera\" && std.atoi(req.http.normalized_user_agent_major_version) >= 11) ||\n\t\t\t# op_mob: \">=10\",\n\t\t\t(req.http.normalized_user_agent_family == \"op_mob\" && std.atoi(req.http.normalized_user_agent_major_version) >= 10) ||\n\t\t\t# op_mini: \">=5\",\n\t\t\t(req.http.normalized_user_agent_family == \"op_mini\" && std.atoi(req.http.normalized_user_agent_major_version) >= 5) ||\n\t\t\t# bb: \">=6\",\n\t\t\t(req.http.normalized_user_agent_family == \"bb\" && std.atoi(req.http.normalized_user_agent_major_version) >= 6) ||\n\t\t\t# samsung_mob: \">=4\"\n\t\t\t(req.http.normalized_user_agent_family == \"samsung_mob\" && std.atoi(req.http.normalized_user_agent_major_version) >= 4)\n\t\t) {\n\t\t\tset req.http.Normalized-User-Agent = req.http.normalized_user_agent_family \"\/\" req.http.normalized_user_agent_major_version \".\" req.http.normalized_user_agent_minor_version \".\" req.http.normalized_user_agent_patch_version;\n\t\t} else {\n\t\t\tset req.http.normalized_user_agent_family = \"other\";\n\t\t\tset req.http.normalized_user_agent_major_version = \"0\";\n\t\t\tset req.http.normalized_user_agent_minor_version = \"0\";\n\t\t\tset req.http.Normalized-User-Agent = req.http.normalized_user_agent_family \"\/\" req.http.normalized_user_agent_major_version \".\" req.http.normalized_user_agent_minor_version \".\" req.http.normalized_user_agent_patch_version;\n\t\t}\n\t} else {\n\t\tset req.http.Normalized-User-Agent = \"other\/0.0.0\";\n\t}\n}\n","old_contents":"sub normalise_user_agent_3_25_1 {\n\tif (req.http.User-Agent) {\n\t\t# Longest genuine UA seen so far: 255 chars (Facebook in-app on iOS):\n\t\tset req.http.User-Agent = if(req.http.User-Agent ~ \"(^[\\s\\S]{0,300})\", re.group.1, \"other\/0.0.0\");\n\n\t\t# Remove UA tokens that unnecessarily complicate UA parsing\n\n\t\t# Chrome and Opera on iOS uses a UIWebView of the underlying platform to render\n\t\t# content. By stripping the CriOS or OPiOS strings, the useragent parser will alias the\n\t\t# user agent to ios_saf for the UIWebView, which is closer to the actual renderer\n\t\tset req.http.User-Agent = regsub(req.http.User-Agent, \"((CriOS|OPiOS)\/(\\d+)\\.(\\d+)\\.(\\d+)\\.(\\d+)|(FxiOS\/(\\d+)\\.(\\d+)))\", \"\");\n\n\t\t# # Vivaldi browser is recognised by UA module but is actually identical to Chrome, so\n\t\t# # the best way to get accurate targeting is to remove the vivaldi token from the UA\n\t\tset req.http.User-Agent = regsub(req.http.User-Agent, \"(?i) vivaldi\/[\\d\\.]+\\d+\", \"\");\n\n\t\t# # Facebook in-app browser `[FBAN\/.....]` or `[FB_IAB\/.....]` (see #990)\n\t\tset req.http.User-Agent = regsub(req.http.User-Agent, \"(?i) \\[(FB_IAB|FBAN|FBIOS|FB4A)\/[^\\]]+\\]\", \"\");\n\n\t\t# # Electron ` Electron\/X.Y.Z` (see #1129)\n\t\tset req.http.User-Agent = regsub(req.http.User-Agent, \"(?i) Electron\/[\\d\\.]+\\d+\", \"\");\n\n\t\tcall useragent_parser;\n\n\t\t# Clone the original values for later modification. This helps when debugging as it let's us see what the useragent_parser function returned.\n\t\tset req.http.normalized_user_agent_family = req.http.useragent_parser_family;\n\t\tset req.http.normalized_user_agent_major_version = req.http.useragent_parser_major;\n\t\tset req.http.normalized_user_agent_minor_version = req.http.useragent_parser_minor;\n\t\tset req.http.normalized_user_agent_patch_version = req.http.useragent_parser_patch;\n\n\t\tset req.http.normalized_user_agent_patch_version = \"0\";\n\t\tset req.http.normalized_user_agent_family = std.tolower(req.http.useragent_parser_family);\n\n\t\t# Aliases\n\t\tif (req.http.normalized_user_agent_family == \"blackberry webkit\") {\n\t\t\tset req.http.normalized_user_agent_family = \"bb\";\n\t\t}\n\t\tif (req.http.normalized_user_agent_family == \"blackberry\") {\n\t\t\tset req.http.normalized_user_agent_family = \"bb\";\n\t\t}\n\t\tif (req.http.normalized_user_agent_family == \"pale moon (firefox variant)\") {\n\t\t\tset req.http.normalized_user_agent_family = \"firefox\";\n\t\t}\n\t\tif (req.http.normalized_user_agent_family == \"pale moon\") {\n\t\t\tset req.http.normalized_user_agent_family = \"firefox\";\n\t\t}\n\t\tif (req.http.normalized_user_agent_family == \"firefox mobile\") {\n\t\t\tset req.http.normalized_user_agent_family = \"firefox_mob\";\n\t\t}\n\t\tif (req.http.normalized_user_agent_family == \"firefox namoroka\") {\n\t\t\tset req.http.normalized_user_agent_family = \"firefox\";\n\t\t}\n\t\tif (req.http.normalized_user_agent_family == \"firefox shiretoko\") {\n\t\t\tset req.http.normalized_user_agent_family = \"firefox\";\n\t\t}\n\t\tif (req.http.normalized_user_agent_family == \"firefox minefield\") {\n\t\t\tset req.http.normalized_user_agent_family = \"firefox\";\n\t\t}\n\t\tif (req.http.normalized_user_agent_family == \"firefox alpha\") {\n\t\t\tset req.http.normalized_user_agent_family = \"firefox\";\n\t\t}\n\t\tif (req.http.normalized_user_agent_family == \"firefox beta\") {\n\t\t\tset req.http.normalized_user_agent_family = \"firefox\";\n\t\t}\n\t\tif (req.http.normalized_user_agent_family == \"microb\") {\n\t\t\tset req.http.normalized_user_agent_family = \"firefox\";\n\t\t}\n\t\tif (req.http.normalized_user_agent_family == \"mozilladeveloperpreview\") {\n\t\t\tset req.http.normalized_user_agent_family = \"firefox\";\n\t\t}\n\t\tif (req.http.normalized_user_agent_family == \"iceweasel\") {\n\t\t\tset req.http.normalized_user_agent_family = \"firefox\";\n\t\t}\n\t\tif (req.http.normalized_user_agent_family == \"opera tablet\") {\n\t\t\tset req.http.normalized_user_agent_family = \"opera\";\n\t\t}\n\t\tif (req.http.normalized_user_agent_family == \"opera mobile\") {\n\t\t\tset req.http.normalized_user_agent_family = \"op_mob\";\n\t\t}\n\t\tif (req.http.normalized_user_agent_family == \"opera mini\") {\n\t\t\tset req.http.normalized_user_agent_family = \"op_mini\";\n\t\t}\n\t\tif (req.http.normalized_user_agent_family == \"chrome mobile\") {\n\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t}\n\t\tif (req.http.normalized_user_agent_family == \"chrome frame\") {\n\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t}\n\t\tif (req.http.normalized_user_agent_family == \"chromium\") {\n\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t}\n\t\tif (req.http.normalized_user_agent_family == \"ie mobile\") {\n\t\t\tset req.http.normalized_user_agent_family = \"ie_mob\";\n\t\t}\n\t\tif (req.http.normalized_user_agent_family == \"ie large screen\") {\n\t\t\tset req.http.normalized_user_agent_family = \"ie\";\n\t\t}\n\t\tif (req.http.normalized_user_agent_family == \"internet explorer\") {\n\t\t\tset req.http.normalized_user_agent_family = \"ie\";\n\t\t}\n\t\tif (req.http.normalized_user_agent_family == \"edge\") {\n\t\t\tset req.http.normalized_user_agent_family = \"ie\";\n\t\t}\n\t\tif (req.http.normalized_user_agent_family == \"edge mobile\") {\n\t\t\tset req.http.normalized_user_agent_family = \"ie\";\n\t\t}\n\t\tif (req.http.normalized_user_agent_family == \"uc browser\") {\n\t\t\tif (req.http.normalized_user_agent_major_version == \"9\" && req.http.normalized_user_agent_minor_version == \"9\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"ie\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"10\";\n\t\t\t}\n\t\t}\n\t\tif (req.http.normalized_user_agent_family == \"chrome mobile ios\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"ios_chr\";\n\t\t\t}\n\n\t\tif (req.http.normalized_user_agent_family == \"mobile safari\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"ios_saf\";\n\t\t\t}\n\t\tif (req.http.normalized_user_agent_family == \"iphone\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"ios_saf\";\n\t\t\t}\n\t\tif (req.http.normalized_user_agent_family == \"iphone simulator\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"ios_saf\";\n\t\t\t}\n\t\tif (req.http.normalized_user_agent_family == \"mobile safari uiwebview\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"ios_saf\";\n\t\t\t}\n\t\tif (req.http.normalized_user_agent_family == \"mobile safari ui\/wkwebview\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"ios_saf\";\n\t\t\t}\n\n\t\tif (req.http.normalized_user_agent_family == \"samsung internet\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"samsung_mob\";\n\t\t\t}\n\n\t\tif (req.http.normalized_user_agent_family == \"phantomjs\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"safari\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"5\";\n\t\t\t}\n\n\t\tif (req.http.normalized_user_agent_family == \"yandex browser\") {\n\t\t\tif (req.http.normalized_user_agent_major_version == \"14\" && req.http.normalized_user_agent_minor_version == \"10\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"37\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"14\" && req.http.normalized_user_agent_minor_version == \"10\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"36\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"14\" && req.http.normalized_user_agent_minor_version == \"10\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"35\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"14\" && req.http.normalized_user_agent_minor_version == \"10\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"34\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"14\" && req.http.normalized_user_agent_minor_version == \"10\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"33\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"14\" && req.http.normalized_user_agent_minor_version == \"10\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"32\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"14\" && req.http.normalized_user_agent_minor_version == \"10\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"30\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"14\" && req.http.normalized_user_agent_minor_version == \"10\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"28\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"14\" && req.http.normalized_user_agent_minor_version == \"10\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"60\";\n\t\t\t}\n\t\t}\n\n\t\tif (req.http.normalized_user_agent_family == \"opera\") {\n\t\t\tif (req.http.normalized_user_agent_major_version == \"20\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"33\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"21\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"34\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"22\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"35\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"23\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"36\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"24\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"37\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"25\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"38\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"26\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"39\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"27\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"40\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"28\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"41\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"29\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"42\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"30\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"43\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"31\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"44\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"32\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"45\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"33\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"46\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"34\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"47\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"35\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"48\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"36\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"49\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"37\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"50\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"38\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"51\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"39\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"52\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"40\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"53\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"41\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"54\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"42\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"55\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"43\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"56\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"44\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"57\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"45\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"58\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"46\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"59\";\n\t\t\t}\n\t\t\tif (req.http.normalized_user_agent_major_version == \"47\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"60\";\n\t\t\t}\n\t\t}\n\n\t\tif (req.http.normalized_user_agent_family == \"googlebot\") {\n\t\t\tif (req.http.normalized_user_agent_major_version == \"2\" && req.http.normalized_user_agent_minor_version == \"1\") {\n\t\t\t\tset req.http.normalized_user_agent_family = \"chrome\";\n\t\t\t\tset req.http.normalized_user_agent_major_version = \"41\";\n\t\t\t}\n\t\t}\n\n\t\t# Supported Browsers and minimum supported versions.\n\t\tif (\n\t\t\t# ie: \">=7\",\n\t\t\t(req.http.normalized_user_agent_family == \"ie\" && std.atoi(req.http.normalized_user_agent_major_version) >= 7) ||\n\t\t\t# ie_mob: \">=8\",\n\t\t\t(req.http.normalized_user_agent_family == \"ie_mob\" && std.atoi(req.http.normalized_user_agent_major_version) >= 8) ||\n\t\t\t# chrome: \"*\",\n\t\t\t(req.http.normalized_user_agent_family == \"chrome\") ||\n\t\t\t# safari: \">=4\",\n\t\t\t(req.http.normalized_user_agent_family == \"safari\" && std.atoi(req.http.normalized_user_agent_major_version) >= 4) ||\n\t\t\t# ios_saf: \">=4\",\n\t\t\t(req.http.normalized_user_agent_family == \"ios_saf\" && std.atoi(req.http.normalized_user_agent_major_version) >= 4) ||\n\t\t\t# ios_chr: \">=4\",\n\t\t\t(req.http.normalized_user_agent_family == \"ios_chr\" && std.atoi(req.http.normalized_user_agent_major_version) >= 4) ||\n\t\t\t# firefox: \">=3.6\",\n\t\t\t(req.http.normalized_user_agent_family == \"firefox\" && std.atoi(req.http.normalized_user_agent_major_version) >= 4) ||\n\t\t\t(req.http.normalized_user_agent_family == \"firefox\" && std.atoi(req.http.normalized_user_agent_major_version) == 3 && std.atoi(req.http.normalized_user_agent_minor_version) >= 6) ||\n\t\t\t# firefox_mob: \">=4\",\n\t\t\t(req.http.normalized_user_agent_family == \"firefox_mob\" && std.atoi(req.http.normalized_user_agent_major_version) >= 4) ||\n\t\t\t# android: \">=3\",\n\t\t\t(req.http.normalized_user_agent_family == \"android\" && std.atoi(req.http.normalized_user_agent_major_version) >= 3) ||\n\t\t\t# opera: \">=11\",\n\t\t\t(req.http.normalized_user_agent_family == \"opera\" && std.atoi(req.http.normalized_user_agent_major_version) >= 11) ||\n\t\t\t# op_mob: \">=10\",\n\t\t\t(req.http.normalized_user_agent_family == \"op_mob\" && std.atoi(req.http.normalized_user_agent_major_version) >= 10) ||\n\t\t\t# op_mini: \">=5\",\n\t\t\t(req.http.normalized_user_agent_family == \"op_mini\" && std.atoi(req.http.normalized_user_agent_major_version) >= 5) ||\n\t\t\t# bb: \">=6\",\n\t\t\t(req.http.normalized_user_agent_family == \"bb\" && std.atoi(req.http.normalized_user_agent_major_version) >= 6) ||\n\t\t\t# samsung_mob: \">=4\"\n\t\t\t(req.http.normalized_user_agent_family == \"samsung_mob\" && std.atoi(req.http.normalized_user_agent_major_version) >= 4)\n\t\t) {\n\t\t\tset req.http.Normalized-User-Agent = req.http.normalized_user_agent_family \"\/\" req.http.normalized_user_agent_major_version \".\" req.http.normalized_user_agent_minor_version \".\" req.http.normalized_user_agent_patch_version;\n\t\t} else {\n\t\t\tset req.http.normalized_user_agent_family = \"other\";\n\t\t\tset req.http.normalized_user_agent_major_version = \"0\";\n\t\t\tset req.http.normalized_user_agent_minor_version = \"0\";\n\t\t\tset req.http.Normalized-User-Agent = req.http.normalized_user_agent_family \"\/\" req.http.normalized_user_agent_major_version \".\" req.http.normalized_user_agent_minor_version \".\" req.http.normalized_user_agent_patch_version;\n\t\t}\n\t} else {\n\t\tset req.http.Normalized-User-Agent = \"other\/0.0.0\";\n\t}\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"c15e7b6911d003140c515bf2e5169ebcb87f99d2","subject":"Changes in example settings at default.vcl: maintenance mode","message":"Changes in example settings at default.vcl: maintenance mode\n","repos":"allenta\/vac-templater,allenta\/vac-templater,allenta\/vac-templater,allenta\/vac-templater,allenta\/vac-templater,allenta\/vac-templater","old_file":"extras\/envs\/dev\/default.vcl","new_file":"extras\/envs\/dev\/default.vcl","new_contents":"vcl 4.0;\n\n\/*\n * # VAC Templater meta definitions. Settings here defined may be used through all\n * # the VCL code (even multiple times) and the VAC Templater utility will be able\n * # to provide a graphic interface to easily modify its values and deploy\n * # these changes to production by communicating with the VAC.\n * vac-templater:\n * # Users with special roles.\n * # VAC Templater uses the VAC to identify users so there's no need to list all\n * # of them here. Only users with special roles should be listed so that\n * # write permissions on individual settings can be later restricted to those\n * # roles. All users have the implicit role 'user', that needn't be included\n * # in these lists.\n * users:\n * - vac: ['admin', 'developer']\n * - alice: ['admin']\n * - bob: ['developer']\n *\n * # Settings. All settings have a name, a type, an optional description and\n * # an optional list of validators.\n * #\n * # Type may be one of 'text', 'longtext', 'integer', 'duration', 'boolean'\n * # 'time', 'acl', 'select' or 'group' and each one accepts different kinds\n * # of validators.\n * #\n * # Settings can also be restricted to a particular role (only users with\n * # that particular role will be able to modify that setting). All settings\n * # are restricted to the implicit role 'user' by default.\n * settings:\n * # 'Boolean' settings accept no validator. There are three ways of\n * # representing a boolean: as a true boolean in VCL (bool, default), as a\n * # string (str, '0' | '1') or as an integer (int, 0 | 1). Check how this\n * # setting is used in the VCL below to see how a boolean can be\n * # represented as a string in VCL. The same setting may be used multiple\n * # times in VCL and be represented each time differently, that's why the\n * # representation is not part of the setting definition.\n * - debug:\n * name: Debug\n * description: >\n * Enable debugging to receive handy response headers and collect\n * useful information in varnishlog.\n * type: boolean\n *\n * # 'acl' settings accept no validator.\n * - purge-acl:\n * name: Purge ACL\n * description: ACL to restrict the ability to purge cached contents.\n * type: acl\n * role: admin\n *\n * # 'integer' settings accept the following validators: min and max.\n * # There are also two ways of representing an integer: as a true\n * # integer in VCL (int, default), or as a string (str).\n * - max-retries:\n * name: Max retries\n * description: >\n * Maximum number of times a request is to be retried when the\n * backend is behaving unexpectedly.\n * type: integer\n * role: admin\n * validators:\n * min: 0\n * max: 5\n *\n * # Settings may be grouped together in a group, which is just another\n * # setting with the type 'group'. Concrete settings come under the\n * # 'settings' key.\n * # Groups can also be restricted to a specific role, which will affect\n * # all its child settings unless overridden.\n * - backend:\n * name: Backend\n * type: group\n * role: admin\n * settings:\n * # 'text' settings accept the following validators: min, max (both\n * # refering to the text size) and regexp (a regular expression that\n * # the text has to match).\n * - host:\n * name: Host\n * description: Default backend's IP.\n * type: text\n * validators:\n * regexp: ^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$\n *\n * - port:\n * name: Port\n * type: integer\n * validators:\n * min: 0\n * max: 65535\n *\n * - modes:\n * name: Modes\n * type: group\n * role: admin\n * settings:\n * # 'select' settings only accept a single validator: options, which\n * # lists the available values for the setting.\n * - mode:\n * name: Mode\n * type: select\n * validators:\n * options:\n * - normal\n * - cache-all\n *\n * # 'duration' settings accept the following validators: min and max.\n * - cache-all-ttl:\n * name: Cache-all mode TTL\n * description: >\n * All contents will be cached with the selected TTL while in\n * cache-all mode.\n * type: duration\n * validators:\n * min: 0s\n * max: 5m\n *\n * - maintenance:\n * name: Maintenance\n * description: >\n * If enabled, a static HTML page will be served to all clients\n * and no request will be passed to the backend.\n * type: group\n * role: admin\n * settings:\n * # 'time' settings accept the following validators: min and max,\n * # both expressed as UNIX timestamps. Times always are converted to\n * # a UNIX timestamp when they are included in VCL, but there are\n * # two ways of representing them: as a real (real, default), or as\n * # a string (str).\n * - start:\n * name: Start\n * description: >\n * Schedule maintenance mode to start at a certain time. A\n * date in the past will activate the mode immediately.\n * Leave blank to keep it disabled.\n * type: time\n * validators:\n * max: 1577836800\n *\n * # 'longtext' settings accept the following validators: min, max\n * # (both refering to the text size) and regexp (a regular expression\n * # that the text has to match).\n * - html:\n * name: Maintenance mode HTML\n * description: >\n * Static HTML that will be served to clients while in\n * maintenance mode.\n * type: longtext\n * role: developer\n * validators:\n * min: 1\n *\/\n\nimport std;\nimport var;\n\nacl purge {\n \/* {{ purge-acl *\/\n \"localhost\";\n \/* }} *\/\n}\n\nbackend default {\n .host = \/* {{ backend:host *\/\"127.0.0.1\"\/* }} *\/;\n .port = \/* {{ backend:port|str *\/\"80\"\/* }} *\/;\n}\n\nsub vcl_init {\n # Set mode.\n var.global_set(\"mode\", \/* {{ modes:mode *\/\"normal\"\/* }} *\/);\n\n # Enable\/disable debugging.\n var.global_set(\"debug\", \/* {{ debug|str *\/\"0\"\/* }} *\/);\n\n # Maintenance mode start time (UNIX timestamp, 0 means disabled).\n var.global_set(\"maintenance-start\", \/* {{ maintenance:start|str *\/\"0.00\"\/* }} *\/);\n}\n\nsub vcl_recv {\n # Maintenance mode?\n if ((std.real(var.global_get(\"maintenance-start\"), 0.0) > 0.0) &&\n (std.real2time(std.real(var.global_get(\"maintenance-start\"), 0.0)) < now)) {\n return (synth(700, \"Maintenance mode\"));\n }\n\n # Purge.\n if (req.method == \"PURGE\") {\n if (!client.ip ~ purge) {\n return (synth(405, \"Not allowed\"));\n }\n return (purge);\n }\n}\n\nsub vcl_deliver {\n # Debug enabled?\n if (var.global_get(\"debug\") == \"1\") {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n }\n}\n\nsub vcl_synth {\n if (resp.status == 700) {\n set resp.status = 200;\n set resp.reason = \"OK\";\n\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n set resp.http.Cache-Control = \"no-cache, no-store, must-revalidate\";\n set resp.http.Pragma = \"no-cache\";\n set resp.http.Expires = \"0\";\n\n synthetic(\/* {{ maintenance:html *\/{\"<!DOCTYPE html>\n<html>\n <head>\n <title>Maintenance mode<\/title>\n <\/head>\n <body>\n <h1>Sorry, but we are on maintenance mode<\/h1>\n <p>We'll be back as soon as possible!<\/p>\n <\/body>\n<\/html>\"}\/* }} *\/);\n\n return (deliver);\n }\n}\n\nsub vcl_backend_fetch {\n if (bereq.retries == 0) {\n # Clean up the X-Varnish-Backend-5xx flag that is used internally\n # to mark broken backend responses that should be retried.\n unset bereq.http.X-Varnish-Backend-5xx;\n } else {\n if (bereq.http.X-Varnish-Backend-5xx) {\n if (bereq.method != \"POST\" &&\n std.healthy(bereq.backend) &&\n bereq.retries <= \/* {{ max-retries *\/4\/* }} *\/) {\n # Flush broken backend response flag & try again.\n unset bereq.http.X-Varnish-Backend-5xx;\n if (var.global_get(\"debug\") == \"1\") {\n std.log(\n \"Retrying request. Retries: \" +\n bereq.retries + \"\/\" +\n \/* {{ max-retries|str *\/\"4\"\/* }} *\/);\n }\n } else {\n return (abandon);\n }\n }\n }\n}\n\nsub vcl_backend_response {\n # Retry broken backend responses.\n if (beresp.status >= 500 && beresp.status < 600) {\n set bereq.http.X-Varnish-Backend-5xx = \"1\";\n return (retry);\n }\n\n # Cache-all mode?\n if (var.global_get(\"mode\") == \"cache-all\") {\n # Cache everything ignoring any cache headers.\n set beresp.ttl = \/* {{ modes:cache-all-ttl *\/5m\/* }} *\/;\n }\n}\n\nsub vcl_backend_error {\n # Retry broken backend responses.\n set bereq.http.X-Varnish-Backend-5xx = \"1\";\n return (retry);\n}\n","old_contents":"vcl 4.0;\n\n\/*\n * # VAC Templater meta definitions. Settings here defined may be used through all\n * # the VCL code (even multiple times) and the VAC Templater utility will be able\n * # to provide a graphic interface to easily modify its values and deploy\n * # these changes to production by communicating with the VAC.\n * vac-templater:\n * # Users with special roles.\n * # VAC Templater uses the VAC to identify users so there's no need to list all\n * # of them here. Only users with special roles should be listed so that\n * # write permissions on individual settings can be later restricted to those\n * # roles. All users have the implicit role 'user', that needn't be included\n * # in these lists.\n * users:\n * - vac: ['admin', 'developer']\n * - alice: ['admin']\n * - bob: ['developer']\n *\n * # Settings. All settings have a name, a type, an optional description and\n * # an optional list of validators.\n * #\n * # Type may be one of 'text', 'longtext', 'integer', 'duration', 'boolean'\n * # 'time', 'acl', 'select' or 'group' and each one accepts different kinds\n * # of validators.\n * #\n * # Settings can also be restricted to a particular role (only users with\n * # that particular role will be able to modify that setting). All settings\n * # are restricted to the implicit role 'user' by default.\n * settings:\n * # 'Boolean' settings accept no validator. There are three ways of\n * # representing a boolean: as a true boolean in VCL (bool, default), as a\n * # string (str, '0' | '1') or as an integer (int, 0 | 1). Check how this\n * # setting is used in the VCL below to see how a boolean can be\n * # represented as a string in VCL. The same setting may be used multiple\n * # times in VCL and be represented each time differently, that's why the\n * # representation is not part of the setting definition.\n * - debug:\n * name: Debug\n * description: >\n * Enable debugging to receive handy response headers and collect\n * useful information in varnishlog.\n * type: boolean\n *\n * # 'acl' settings accept no validator.\n * - purge-acl:\n * name: Purge ACL\n * description: ACL to restrict the ability to purge cached contents.\n * type: acl\n * role: admin\n *\n * # 'integer' settings accept the following validators: min and max.\n * # There are also two ways of representing an integer: as a true\n * # integer in VCL (int, default), or as a string (str).\n * - max-retries:\n * name: Max retries\n * description: >\n * Maximum number of times a request is to be retried when the\n * backend is behaving unexpectedly.\n * type: integer\n * role: admin\n * validators:\n * min: 0\n * max: 5\n *\n * # Settings may be grouped together in a group, which is just another\n * # setting with the type 'group'. Concrete settings come under the\n * # 'settings' key.\n * # Groups can also be restricted to a specific role, which will affect\n * # all its child settings unless overridden.\n * - backend:\n * name: Backend\n * description: Default backend definition\n * type: group\n * role: admin\n * settings:\n * # 'text' settings accept the following validators: min, max (both\n * # refering to the text size) and regexp (a regular expression that\n * # the text has to match).\n * - host:\n * name: Host\n * description: Default backend's IP.\n * type: text\n * validators:\n * regexp: ^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$\n *\n * - port:\n * name: Port\n * type: integer\n * validators:\n * min: 0\n * max: 65535\n *\n * - modes:\n * name: Modes\n * type: group\n * role: admin\n * settings:\n * # 'select' settings only accept a single validator: options, which\n * # lists the available values for the setting.\n * - mode:\n * name: Mode\n * type: select\n * validators:\n * options:\n * - normal\n * - cache-all\n * - maintenance\n *\n * # 'time' settings accept the following validators: min and max,\n * # both expressed as UNIX timestamps. Times always are converted to\n * # a UNIX timestamp when they are included in VCL, but there are\n * # two ways of representing them: as a real (real, default), or as\n * # a string (str).\n * - start:\n * name: Start\n * description: >\n * Delay the start of the currently selected mode by\n * selecting a date and time. Normal mode will remain active\n * until that date. Leave blank to apply changes immediately.\n * type: time\n * validators:\n * max: 1577836800\n *\n * # 'duration' settings accept the following validators: min and max.\n * - cache-all-ttl:\n * name: Cache-all mode TTL\n * description: >\n * All contents will be cached with the selected TTL while in\n * cache-all mode.\n * type: duration\n * validators:\n * min: 0s\n * max: 5m\n *\n * # 'longtext' settings accept the following validators: min, max\n * # (both refering to the text size) and regexp (a regular expression\n * # that the text has to match).\n * - maintenance-html:\n * name: Maintenance mode HTML\n * description: >\n * Static HTML that will be served to clients while in\n * maintenance mode.\n * type: longtext\n * role: developer\n * validators:\n * min: 1\n *\/\n\nimport std;\nimport var;\n\nacl purge {\n \/* {{ purge-acl *\/\n \"localhost\";\n \/* }} *\/\n}\n\nbackend default {\n .host = \/* {{ backend:host *\/\"127.0.0.1\"\/* }} *\/;\n .port = \/* {{ backend:port|str *\/\"80\"\/* }} *\/;\n}\n\nsub vcl_init {\n # Set mode.\n var.global_set(\"mode\", \/* {{ modes:mode *\/\"normal\"\/* }} *\/);\n var.global_set(\"mode-start\", \/* {{ modes:start|str *\/\"0.0\"\/* }} *\/);\n\n # Enable\/disable debugging.\n var.global_set(\"debug\", \/* {{ debug|str *\/\"0\"\/* }} *\/);\n}\n\nsub vcl_recv {\n # Maintenance mode?\n if ((var.global_get(\"mode\") == \"maintenance\") &&\n (std.real2time(std.real(var.global_get(\"mode-start\"), 0.0)) < now)) {\n return (synth(700, \"Maintenance mode\"));\n }\n\n # Purge.\n if (req.method == \"PURGE\") {\n if (!client.ip ~ purge) {\n return (synth(405, \"Not allowed\"));\n }\n return (purge);\n }\n}\n\nsub vcl_deliver {\n # Debug enabled?\n if (var.global_get(\"debug\") == \"1\") {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n }\n}\n\nsub vcl_synth {\n if (resp.status == 700) {\n set resp.status = 200;\n set resp.reason = \"OK\";\n\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n set resp.http.Cache-Control = \"no-cache, no-store, must-revalidate\";\n set resp.http.Pragma = \"no-cache\";\n set resp.http.Expires = \"0\";\n\n synthetic(\/* {{ modes:maintenance-html *\/{\"<!DOCTYPE html>\n<html>\n <head>\n <title>Maintenance mode<\/title>\n <\/head>\n <body>\n <h1>Sorry, but we are on maintenance mode<\/h1>\n <p>We'll be back as soon as possible!<\/p>\n <\/body>\n<\/html>\"}\/* }} *\/);\n\n return (deliver);\n }\n}\n\nsub vcl_backend_fetch {\n if (bereq.retries == 0) {\n # Clean up the X-Varnish-Backend-5xx flag that is used internally\n # to mark broken backend responses that should be retried.\n unset bereq.http.X-Varnish-Backend-5xx;\n } else {\n if (bereq.http.X-Varnish-Backend-5xx) {\n if (bereq.method != \"POST\" &&\n std.healthy(bereq.backend) &&\n bereq.retries <= \/* {{ max-retries *\/4\/* }} *\/) {\n # Flush broken backend response flag & try again.\n unset bereq.http.X-Varnish-Backend-5xx;\n if (var.global_get(\"debug\") == \"1\") {\n std.log(\n \"Retrying request. Retries: \" +\n bereq.retries + \"\/\" +\n \/* {{ max-retries|str *\/\"4\"\/* }} *\/);\n }\n } else {\n return (abandon);\n }\n }\n }\n}\n\nsub vcl_backend_response {\n # Retry broken backend responses.\n if (beresp.status >= 500 && beresp.status < 600) {\n set bereq.http.X-Varnish-Backend-5xx = \"1\";\n return (retry);\n }\n\n # Cache-all mode?\n if ((var.global_get(\"mode\") == \"cache-all\") &&\n (std.real2time(std.real(var.global_get(\"mode-start\"), 0.0)) < now)) {\n # Cache everything ignoring any cache headers.\n set beresp.ttl = \/* {{ modes:cache-all-ttl *\/5m\/* }} *\/;\n }\n}\n\nsub vcl_backend_error {\n # Retry broken backend responses.\n set bereq.http.X-Varnish-Backend-5xx = \"1\";\n return (retry);\n}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"e268456cd62053fabd56c79b2075c2e9b62c6363","subject":"Added diagnostic header for discarded cookies.","message":"Added diagnostic header for discarded cookies.\n","repos":"noqcks\/ansible-varnish,telusdigital\/ansible-varnish,killerwails\/ansible-varnish,colstrom\/ansible-varnish,gotofbi\/ansible-varnish,gotofbi\/ansible-varnish,kkwoker\/ansible-varnish,killerwails\/ansible-varnish","old_file":"templates\/etc\/varnish\/default.vcl","new_file":"templates\/etc\/varnish\/default.vcl","new_contents":"vcl 4.0;\n\nimport directors;\nimport std;\n\n###\n# Varnish Documentation\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-built-in-subs.html\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/reference\/vcl.html\n##\n\n{% for backend in varnish_backend_hosts %}\nbackend application_{{ loop.index }} {\n .host = \"{{ backend }}\";\n .port = \"{{ varnish_backend_port }}\";\n{% if varnish_health_checks_enabled %}\n .probe = {\n .url = \"{{ varnish_health_check_url }}\";\n .interval = {{ varnish_health_check_interval }};\n .timeout = {{ varnish_health_check_timeout }};\n .window = {{ varnish_health_check_window }};\n .threshold = {{ varnish_health_check_threshold }};\n }\n{% endif %}\n}\n{% endfor %}\n\n###\n# vcl_init\n# Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n###\n# The vcl_init subroutine may terminate with calling return() with one of the following keywords:\n#\n# ok\n# Normal return, VCL continues loading.\n##\n\nsub vcl_init {\n new application = directors.round_robin();\n{% for backend in varnish_backend_hosts %}\n application.add_backend(application_{{ loop.index }});\n{% endfor %}\n}\n\n###\n# vcl_recv\n# Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use. \n# It is also used to modify the request\n###\n# The vcl_recv subroutine may terminate with calling return() on one of the following keywords:\n#\n# synth(status code, reason)\n# Return a synthetic object with the specified status code to the client and abandon the request.\n# pass\n# Switch to pass mode. Control will eventually pass to vcl_pass.\n# pipe\n# Switch to pipe mode. Control will eventually pass to vcl_pipe.\n# hash\n# Continue processing the object as a potential candidate for caching. Passes the control over to vcl_hash.\n# purge\n# Purge the object and it's variants. Control passes through vcl_hash to vcl_purge.\n#\n\nsub vcl_recv {\n set req.backend_hint = application.backend();\n\n ###\n # Avoid processing uncacheable requests\n ###\n\n if (req.http.Authorization) {\n set req.http.X-Passthrough-Reason = \"No Caching Authenticated Content\";\n return (pass);\n }\n\n{% if varnish_uri_blacklist_enabled %}\n if ((req.url ~ \"{{ varnish_uri_blacklist_regexp }}\")) {\n set req.http.X-Passthrough-Reason = \"Path in Blacklist\";\n return(pass);\n }\n{% endif %}\n\n{% if varnish_diagnostic_headers_forwarded_for %}\n ###\n # Inject X-Forwarded-For headers, but only once.\n ###\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_enabled %}\n ###\n # Cookie Sanitization\n ###\n if (req.http.Cookie) {\n set req.http.X-Cookie-Unmodified = req.http.Cookie;\n\n {% for cookie in varnish_cookie_sanitization_blacklist %}\n set req.http.Cookie = regsuball(req.http.Cookie, \"{{ cookie }}=[^;]+(; )?\", \"\");\n {% endfor %}\n\n ### General Cleanup\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n if (req.http.Cookie ~ \"^\\s*$\") {\n set req.http.X-Cookie-Discarded = \"YES\";\n unset req.http.Cookie;\n }\n if (req.http.Cookie) {\n set req.http.X-Cookie-Sanitized = req.http.Cookie;\n }\n }\n{% endif %}\n\n{% if varnish_header_sanitization_enabled %}\n ###\n # Header Sanitization\n ###\n\n{% if varnish_header_sanitization_discard_host_port %}\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n{% endif %}\n\n{% if varnish_header_sanitization_normalize_accept_encoding %}\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n{% endif %}\n\n{% endif %}\n\n{% if varnish_uri_sanitization_enabled %}\n ###\n # URI Sanitization\n ###\n \n if (req.url ~ \"(\\?|&){{ varnish_uri_sanitization_regexp }}=\") {\n set req.url = regsuball(req.url, \"&{{ varnish_uri_sanitization_regexp }}=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?{{ varnish_uri_sanitization_regexp }}=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n{% endif %}\n\n{% if varnish_workaround_telusdotcom_browser_profile %}\n ###\n # Workaround and Diagnostics for BrowserProfile and Language\/Region Detection on TELUS.com\n ###\n\n if (req.http.Cookie ~ \"BrowserProfile\") {\n set req.http.X-BrowserProfile = regsuball(req.http.Cookie, \"(.*)BrowserProfile=([^;]*)(.*)\", \"\\2\");\n if (req.http.X-BrowserProfile ~ \"language\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.X-BrowserProfile, \"(.*)language\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n set req.http.X-Language-Found = \"YES:BrowserProfile\";\n }\n if (req.http.X-BrowserProfile ~ \"region\") {\n set req.http.X-Region = std.tolower(regsuball(regsuball(req.http.X-BrowserProfile, \"geo\\\\.\\:{(.*)\\}\", \"\"), \"(.*)region\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n set req.http.X-Region-Found = \"YES:BrowserProfile\";\n }\n if (req.http.X-BrowserProfile ~ \"geo\") {\n set req.http.X-BrowserProfile-Geolocation = regsuball(req.http.X-BrowserProfile, \"(.*)geo..:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n set req.http.X-BrowserProfile-Geolocation-Found = \"YES\";\n\n if (req.http.X-BrowserProfile-Geolocation ~ \"country\") {\n set req.http.X-BrowserProfile-Geolocation-Country = regsuball(req.http.X-BrowserProfile-Geolocation, \"(.*)country\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-BrowserProfile-Geolocation ~ \"region\") {\n set req.http.X-BrowserProfile-Geolocation-Region = regsuball(req.http.X-BrowserProfile-Geolocation, \"(.*)region\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-BrowserProfile-Geolocation ~ \"city\") {\n set req.http.X-BrowserProfile-Geolocation-City = regsuball(req.http.X-BrowserProfile-Geolocation, \"(.*)city\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-BrowserProfile-Geolocation ~ \"isp\") {\n set req.http.X-BrowserProfile-Geolocation-ISP = regsuball(req.http.X-BrowserProfile-Geolocation, \"(.*)isp\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n } else {\n set req.http.X-BrowserProfile-Geolocation-Found = \"NO\";\n }\n }\n\n if (!req.http.X-Language) {\n if (req.http.Cookie ~ \"lang=\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.Cookie, \"(.*)lang=([^;]*)(.*)\", \"\\2\"));\n set req.http.X-Language-Found = \"YES:lang\";\n } else {\n set req.http.X-Language = \"en\";\n set req.http.X-Language-Found = \"NO\";\n }\n }\n\n if (!req.http.X-Region) {\n if (req.http.Cookie ~ \"prov=\") {\n set req.http.X-Region = std.tolower(regsuball(req.http.Cookie, \"(.*)prov=([^;]*)(.*)\", \"\\2\"));\n set req.http.X-Region-Found = \"YES:prov\";\n } else {\n set req.http.X-Region = \"bc\";\n set req.http.X-Region-Found = \"NO\";\n }\n }\n\n\n if (req.url ~ \"\/(en|fr)\/\") {\n if (req.url ~ \"\/en\/\" && req.http.X-Language != \"en\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Language (Path: \/en\/) vs (Cookie: \" + req.http.X-Language + \")\";\n return(pass);\n }\n if (req.url ~ \"\/fr\/\" && req.http.X-Language != \"fr\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Language (Path: \/fr\/) vs (Cookie: \" + req.http.X-Language + \")\";\n return(pass);\n }\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Language)\";\n return(pass);\n }\n\n if (req.url ~ \"\/(ab|bc|mb|nb|nl|ns|nt|nu|on|pe|qc|sk|yt)\/\") {\n {% for province in ['ab', 'bc', 'mb', 'nb', 'nl', 'ns', 'nt', 'nu', 'on', 'pe', 'qc', 'sk', 'yt'] %}\n if (req.url ~ \"\/{{ province }}\/\" && req.http.X-Region != \"{{ province }}\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Region (Path: \/{{ province }}\/) vs (Cookie: \" + req.http.X-Region + \")\";\n return(pass);\n }\n {% endfor %}\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Province)\";\n return(pass);\n }\n\n if (req.http.Cookie) {\n if (req.http.Cookie ~ \"***REMOVED***\") {\n set req.http.X-Screen-Resolution = regsuball(req.http.Cookie, \"(.*)***REMOVED***=([^;]*)(.*)\", \"\\2\");\n }\n\n if (req.http.Cookie ~ \"***REMOVED***\") {\n set req.http.X-Customer-Type = regsuball(req.http.Cookie, \"(.*)***REMOVED***=([^;]*)(.*)\", \"\\2\");\n }\n if (req.http.Cookie ~ \"***REMOVED***\") {\n set req.http.X-Outdated-Browser = regsuball(req.http.Cookie, \"(.*)***REMOVED***=([^;]*)(.*)\", \"\\2\");\n }\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_discard_from_client %}\n set req.http.X-Cookie-Discarded = \"YES\";\n unset req.http.Cookie;\n{% endif %}\n}\n\n###\n# vcl_hit\n# Called when a cache lookup is successful.\n###\n# The vcl_hit subroutine may terminate with calling return() with one of the following keywords:\n#\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n# deliver\n# Deliver the object. Control passes to vcl_deliver.\n# synth(status code, reason)\n# Return the specified status code to the client and abandon the request.\n###\n\nsub vcl_hit {\n if (obj.ttl > 0s) {\n return (deliver);\n }\n{% if varnish_health_checks_enabled %}\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (fetch);\n }\n{% else %}\n if (obj.ttl + obj.grace > 0s) {\n return (deliver);\n }\n\n return (fetch);\n{% endif %}\n}\n\n###\n# vcl_backend_response\n# Called after the response headers has been successfully retrieved from the backend.\n###\n# The vcl_backend_response subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Possibly insert the object into the cache, then deliver it to the Control will eventually pass to vcl_deliver.\n# abandon\n# Abandon the backend request and generates an error.\n# retry\n# Retry the backend transaction. Increases the retries counter. If the number of retries is higher than max_retries Varnish emits a guru meditation error.\n###\n\nsub vcl_backend_response {\n{% if varnish_workaround_telusdotcom_browser_profile %}\n if (bereq.http.X-Language) {\n set beresp.http.X-Language = bereq.http.X-Language;\n# if (bereq.http.X-Language-Found) {\n# set beresp.http.X-Language-Found = bereq.http.X-Language-Found;\n# }\n }\n if (bereq.http.X-Region) {\n set beresp.http.X-Region = bereq.http.X-Region;\n# if (bereq.http.X-Region-Found) {\n# set beresp.http.X-Region-Found = bereq.http.X-Region-Found;\n# }\n }\n{% endif %}\n\n{% if varnish_uri_blacklist_enabled %}\n if (bereq.url ~ \"{{ varnish_uri_blacklist_regexp }}\") {\n set beresp.http.X-Cacheable = \"NO:Path in Blacklist\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n if (bereq.http.X-Passthrough-Reason) {\n{% if varnish_diagnostic_headers_passthrough_reason %}\n set beresp.http.X-Passthrough-Reason = bereq.http.X-Passthrough-Reason;\n{% endif %}\n return(deliver);\n } else {\n{% if varnish_cookie_sanitization_discard_from_server %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n }\n }\n{% else %}\n{% if varnish_cookie_sanitization_discard_from_server %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n{% endif %}\n\n{% if varnish_diagnostic_headers_enabled %}\n if (bereq.http.Cookie) {\n set beresp.http.X-Cacheable = \"NO:Cookie in Request\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO:Set-Cookie in Response\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.X-No-Cache) {\n set beresp.http.X-Cacheable = \"NO:X-No-Cache\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.ttl <= 0s) {\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n{% endif %}\n\n set beresp.grace = {{ varnish_grace_period }};\n}\n\n###\n# vcl_deliver\n# Called before a cached object is delivered to the client.\n###\n# The vcl_deliver subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Deliver the object to the client.\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n###\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n","old_contents":"vcl 4.0;\n\nimport directors;\nimport std;\n\n###\n# Varnish Documentation\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-built-in-subs.html\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/reference\/vcl.html\n##\n\n{% for backend in varnish_backend_hosts %}\nbackend application_{{ loop.index }} {\n .host = \"{{ backend }}\";\n .port = \"{{ varnish_backend_port }}\";\n{% if varnish_health_checks_enabled %}\n .probe = {\n .url = \"{{ varnish_health_check_url }}\";\n .interval = {{ varnish_health_check_interval }};\n .timeout = {{ varnish_health_check_timeout }};\n .window = {{ varnish_health_check_window }};\n .threshold = {{ varnish_health_check_threshold }};\n }\n{% endif %}\n}\n{% endfor %}\n\n###\n# vcl_init\n# Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n###\n# The vcl_init subroutine may terminate with calling return() with one of the following keywords:\n#\n# ok\n# Normal return, VCL continues loading.\n##\n\nsub vcl_init {\n new application = directors.round_robin();\n{% for backend in varnish_backend_hosts %}\n application.add_backend(application_{{ loop.index }});\n{% endfor %}\n}\n\n###\n# vcl_recv\n# Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use. \n# It is also used to modify the request\n###\n# The vcl_recv subroutine may terminate with calling return() on one of the following keywords:\n#\n# synth(status code, reason)\n# Return a synthetic object with the specified status code to the client and abandon the request.\n# pass\n# Switch to pass mode. Control will eventually pass to vcl_pass.\n# pipe\n# Switch to pipe mode. Control will eventually pass to vcl_pipe.\n# hash\n# Continue processing the object as a potential candidate for caching. Passes the control over to vcl_hash.\n# purge\n# Purge the object and it's variants. Control passes through vcl_hash to vcl_purge.\n#\n\nsub vcl_recv {\n set req.backend_hint = application.backend();\n\n ###\n # Avoid processing uncacheable requests\n ###\n\n if (req.http.Authorization) {\n set req.http.X-Passthrough-Reason = \"No Caching Authenticated Content\";\n return (pass);\n }\n\n{% if varnish_uri_blacklist_enabled %}\n if ((req.url ~ \"{{ varnish_uri_blacklist_regexp }}\")) {\n set req.http.X-Passthrough-Reason = \"Path in Blacklist\";\n return(pass);\n }\n{% endif %}\n\n{% if varnish_diagnostic_headers_forwarded_for %}\n ###\n # Inject X-Forwarded-For headers, but only once.\n ###\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_enabled %}\n ###\n # Cookie Sanitization\n ###\n if (req.http.Cookie) {\n set req.http.X-Cookie-Unmodified = req.http.Cookie;\n\n {% for cookie in varnish_cookie_sanitization_blacklist %}\n set req.http.Cookie = regsuball(req.http.Cookie, \"{{ cookie }}=[^;]+(; )?\", \"\");\n {% endfor %}\n\n ### General Cleanup\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n if (req.http.Cookie ~ \"^\\s*$\") {\n unset req.http.Cookie;\n }\n if (req.http.Cookie) {\n set req.http.X-Cookie-Sanitized = req.http.Cookie;\n }\n }\n{% endif %}\n\n{% if varnish_header_sanitization_enabled %}\n ###\n # Header Sanitization\n ###\n\n{% if varnish_header_sanitization_discard_host_port %}\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n{% endif %}\n\n{% if varnish_header_sanitization_normalize_accept_encoding %}\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n{% endif %}\n\n{% endif %}\n\n{% if varnish_uri_sanitization_enabled %}\n ###\n # URI Sanitization\n ###\n \n if (req.url ~ \"(\\?|&){{ varnish_uri_sanitization_regexp }}=\") {\n set req.url = regsuball(req.url, \"&{{ varnish_uri_sanitization_regexp }}=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?{{ varnish_uri_sanitization_regexp }}=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n{% endif %}\n\n{% if varnish_workaround_telusdotcom_browser_profile %}\n ###\n # Workaround and Diagnostics for BrowserProfile and Language\/Region Detection on TELUS.com\n ###\n\n if (req.http.Cookie ~ \"BrowserProfile\") {\n set req.http.X-BrowserProfile = regsuball(req.http.Cookie, \"(.*)BrowserProfile=([^;]*)(.*)\", \"\\2\");\n if (req.http.X-BrowserProfile ~ \"language\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.X-BrowserProfile, \"(.*)language\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n set req.http.X-Language-Found = \"YES:BrowserProfile\";\n }\n if (req.http.X-BrowserProfile ~ \"region\") {\n set req.http.X-Region = std.tolower(regsuball(regsuball(req.http.X-BrowserProfile, \"geo\\\\.\\:{(.*)\\}\", \"\"), \"(.*)region\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n set req.http.X-Region-Found = \"YES:BrowserProfile\";\n }\n if (req.http.X-BrowserProfile ~ \"geo\") {\n set req.http.X-BrowserProfile-Geolocation = regsuball(req.http.X-BrowserProfile, \"(.*)geo..:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n set req.http.X-BrowserProfile-Geolocation-Found = \"YES\";\n\n if (req.http.X-BrowserProfile-Geolocation ~ \"country\") {\n set req.http.X-BrowserProfile-Geolocation-Country = regsuball(req.http.X-BrowserProfile-Geolocation, \"(.*)country\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-BrowserProfile-Geolocation ~ \"region\") {\n set req.http.X-BrowserProfile-Geolocation-Region = regsuball(req.http.X-BrowserProfile-Geolocation, \"(.*)region\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-BrowserProfile-Geolocation ~ \"city\") {\n set req.http.X-BrowserProfile-Geolocation-City = regsuball(req.http.X-BrowserProfile-Geolocation, \"(.*)city\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-BrowserProfile-Geolocation ~ \"isp\") {\n set req.http.X-BrowserProfile-Geolocation-ISP = regsuball(req.http.X-BrowserProfile-Geolocation, \"(.*)isp\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n } else {\n set req.http.X-BrowserProfile-Geolocation-Found = \"NO\";\n }\n }\n\n if (!req.http.X-Language) {\n if (req.http.Cookie ~ \"lang=\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.Cookie, \"(.*)lang=([^;]*)(.*)\", \"\\2\"));\n set req.http.X-Language-Found = \"YES:lang\";\n } else {\n set req.http.X-Language = \"en\";\n set req.http.X-Language-Found = \"NO\";\n }\n }\n\n if (!req.http.X-Region) {\n if (req.http.Cookie ~ \"prov=\") {\n set req.http.X-Region = std.tolower(regsuball(req.http.Cookie, \"(.*)prov=([^;]*)(.*)\", \"\\2\"));\n set req.http.X-Region-Found = \"YES:prov\";\n } else {\n set req.http.X-Region = \"bc\";\n set req.http.X-Region-Found = \"NO\";\n }\n }\n\n\n if (req.url ~ \"\/(en|fr)\/\") {\n if (req.url ~ \"\/en\/\" && req.http.X-Language != \"en\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Language (Path: \/en\/) vs (Cookie: \" + req.http.X-Language + \")\";\n return(pass);\n }\n if (req.url ~ \"\/fr\/\" && req.http.X-Language != \"fr\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Language (Path: \/fr\/) vs (Cookie: \" + req.http.X-Language + \")\";\n return(pass);\n }\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Language)\";\n return(pass);\n }\n\n if (req.url ~ \"\/(ab|bc|mb|nb|nl|ns|nt|nu|on|pe|qc|sk|yt)\/\") {\n {% for province in ['ab', 'bc', 'mb', 'nb', 'nl', 'ns', 'nt', 'nu', 'on', 'pe', 'qc', 'sk', 'yt'] %}\n if (req.url ~ \"\/{{ province }}\/\" && req.http.X-Region != \"{{ province }}\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Region (Path: \/{{ province }}\/) vs (Cookie: \" + req.http.X-Region + \")\";\n return(pass);\n }\n {% endfor %}\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Province)\";\n return(pass);\n }\n\n if (req.http.Cookie) {\n if (req.http.Cookie ~ \"***REMOVED***\") {\n set req.http.X-Screen-Resolution = regsuball(req.http.Cookie, \"(.*)***REMOVED***=([^;]*)(.*)\", \"\\2\");\n }\n\n if (req.http.Cookie ~ \"***REMOVED***\") {\n set req.http.X-Customer-Type = regsuball(req.http.Cookie, \"(.*)***REMOVED***=([^;]*)(.*)\", \"\\2\");\n }\n if (req.http.Cookie ~ \"***REMOVED***\") {\n set req.http.X-Outdated-Browser = regsuball(req.http.Cookie, \"(.*)***REMOVED***=([^;]*)(.*)\", \"\\2\");\n }\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_discard_from_client %}\n unset req.http.Cookie;\n{% endif %}\n}\n\n###\n# vcl_hit\n# Called when a cache lookup is successful.\n###\n# The vcl_hit subroutine may terminate with calling return() with one of the following keywords:\n#\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n# deliver\n# Deliver the object. Control passes to vcl_deliver.\n# synth(status code, reason)\n# Return the specified status code to the client and abandon the request.\n###\n\nsub vcl_hit {\n if (obj.ttl > 0s) {\n return (deliver);\n }\n{% if varnish_health_checks_enabled %}\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (fetch);\n }\n{% else %}\n if (obj.ttl + obj.grace > 0s) {\n return (deliver);\n }\n\n return (fetch);\n{% endif %}\n}\n\n###\n# vcl_backend_response\n# Called after the response headers has been successfully retrieved from the backend.\n###\n# The vcl_backend_response subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Possibly insert the object into the cache, then deliver it to the Control will eventually pass to vcl_deliver.\n# abandon\n# Abandon the backend request and generates an error.\n# retry\n# Retry the backend transaction. Increases the retries counter. If the number of retries is higher than max_retries Varnish emits a guru meditation error.\n###\n\nsub vcl_backend_response {\n{% if varnish_workaround_telusdotcom_browser_profile %}\n if (bereq.http.X-Language) {\n set beresp.http.X-Language = bereq.http.X-Language;\n# if (bereq.http.X-Language-Found) {\n# set beresp.http.X-Language-Found = bereq.http.X-Language-Found;\n# }\n }\n if (bereq.http.X-Region) {\n set beresp.http.X-Region = bereq.http.X-Region;\n# if (bereq.http.X-Region-Found) {\n# set beresp.http.X-Region-Found = bereq.http.X-Region-Found;\n# }\n }\n{% endif %}\n\n{% if varnish_uri_blacklist_enabled %}\n if (bereq.url ~ \"{{ varnish_uri_blacklist_regexp }}\") {\n set beresp.http.X-Cacheable = \"NO:Path in Blacklist\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n if (bereq.http.X-Passthrough-Reason) {\n{% if varnish_diagnostic_headers_passthrough_reason %}\n set beresp.http.X-Passthrough-Reason = bereq.http.X-Passthrough-Reason;\n{% endif %}\n return(deliver);\n } else {\n{% if varnish_cookie_sanitization_discard_from_server %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n }\n }\n{% else %}\n{% if varnish_cookie_sanitization_discard_from_server %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n{% endif %}\n\n{% if varnish_diagnostic_headers_enabled %}\n if (bereq.http.Cookie) {\n set beresp.http.X-Cacheable = \"NO:Cookie in Request\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO:Set-Cookie in Response\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.X-No-Cache) {\n set beresp.http.X-Cacheable = \"NO:X-No-Cache\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.ttl <= 0s) {\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n{% endif %}\n\n set beresp.grace = {{ varnish_grace_period }};\n}\n\n###\n# vcl_deliver\n# Called before a cached object is delivered to the client.\n###\n# The vcl_deliver subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Deliver the object to the client.\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n###\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"5daef5adcae30f4d6f2b1ce272618157f251e013","subject":"Remove unused code","message":"Remove unused code\n","repos":"Sanchiz\/cibox,PavelLoparev\/cibox,Sanchiz\/cibox,ygerasimov\/cibox-1,turcan-vasile\/cibox,valthebald\/cibox,propeopleua\/cibox,PavelLoparev\/cibox,turcan-vasile\/cibox,tkyryliuk\/cibox,ey-\/cibox,propeoplemd\/cibox,ey-\/cibox,propeoplemd\/cibox,tkyryliuk\/cibox,propeopleua\/cibox,propeoplemd\/cibox,ygerasimov\/cibox-1,Sanchiz\/cibox,propeoplemd\/cibox,Sanchiz\/cibox,ey-\/cibox,turcan-vasile\/cibox,turcan-vasile\/cibox,tkyryliuk\/cibox,propeopleua\/cibox,dpovshed\/cibox,PavelLoparev\/cibox,dpovshed\/cibox,loganyott\/cibox,ygerasimov\/cibox-1,turcan-vasile\/cibox,loganyott\/cibox,PavelLoparev\/cibox,dpovshed\/cibox,tkyryliuk\/cibox,valthebald\/cibox,valthebald\/cibox,tkyryliuk\/cibox,turcan-vasile\/cibox,valthebald\/cibox,loganyott\/cibox,loganyott\/cibox,propeoplemd\/cibox,ey-\/cibox,tkyryliuk\/cibox,dpovshed\/cibox,loganyott\/cibox,PavelLoparev\/cibox,PavelLoparev\/cibox,ey-\/cibox,propeopleua\/cibox,dpovshed\/cibox,loganyott\/cibox,valthebald\/cibox,propeopleua\/cibox,ygerasimov\/cibox-1,Sanchiz\/cibox,Sanchiz\/cibox,ygerasimov\/cibox-1,dpovshed\/cibox","old_file":"github\/files\/vagrant\/puppet\/puphpet\/files\/varnish\/drupal_vcl.vcl","new_file":"github\/files\/vagrant\/puppet\/puphpet\/files\/varnish\/drupal_vcl.vcl","new_contents":"# This is a basic VCL configuration file for varnish. See the vcl(7) main page for details on VCL syntax and semantics.\n\n# Default backend definition. Set this to point to your content server.\n\n backend default {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n .connect_timeout = 600s;\n .first_byte_timeout = 600s;\n .between_bytes_timeout = 600s;\n }\n\n# Respond to incoming requests.\nsub vcl_recv {\n if (req.request == \"GET\" && req.url ~ \"^\/varnishcheck$\") {\n error 200 \"Varnish is Ready\";\n }\n\n # Allow the backend to serve up stale content if it is responding slowly.\n if (!req.backend.healthy) {\n # Use anonymous, cached pages if all backends are down.\n unset req.http.Cookie;\n if (req.http.X-Forwarded-Proto == \"https\") {\n set req.http.X-Forwarded-Proto = \"http\";\n }\n set req.grace = 30m;\n } else {\n set req.grace = 15s;\n }\n\n # Get ride of progress.js query params\n if (req.url ~ \"^\/misc\/progress\\.js\\?[0-9]+$\") {\n set req.url = \"\/misc\/progress.js\";\n }\n\n # If global redirect is on\n #if (req.url ~ \"node\\?page=[0-9]+$\") {\n # set req.url = regsub(req.url, \"node(\\?page=[0-9]+$)\", \"\\1\");\n # return (lookup);\n #}\n\n # Do not cache these paths.\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/ooyala\/ping$\" ||\n req.url ~ \"^\/admin\" ||\n req.url ~ \"^\/admin\/.*$\" ||\n req.url ~ \"^\/user\" ||\n req.url ~ \"^\/user\/.*$\" ||\n req.url ~ \"^\/users\/.*$\" ||\n req.url ~ \"^\/info\/.*$\" ||\n req.url ~ \"^\/flag\/.*$\" ||\n req.url ~ \"^.*\/ajax\/.*$\" ||\n req.url ~ \"^.*\/ahah\/.*$\") {\n return (pass);\n }\n\n # Pipe these paths directly to Apache for streaming.\n if (req.url ~ \"^\/admin\/content\/backup_migrate\/export\") {\n return (pipe);\n }\n\n # Handle compression correctly. Different browsers send different\n # \"Accept-Encoding\" headers, even though they mostly all support the same\n # compression mechanisms. By consolidating these compression headers into\n # a consistent format, we can reduce the size of the cache and get more hits.=\n # @see: http:\/\/ varnish.projects.linpro.no\/wiki\/FAQ\/Compression\n if (req.http.Accept-Encoding) {\n if (req.http.Accept-Encoding ~ \"gzip\") {\n # If the browser supports it, we'll use gzip.\n set req.http.Accept-Encoding = \"gzip\";\n }\n else if (req.http.Accept-Encoding ~ \"deflate\") {\n # Next, try deflate if it is supported.\n set req.http.Accept-Encoding = \"deflate\";\n }\n else {\n # Unknown algorithm. Remove it and send unencoded.\n unset req.http.Accept-Encoding;\n }\n }\n\n # Always cache the following file types for all users.\n if (req.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js)(\\?[a-z0-9]+)?$\") {\n unset req.http.Cookie;\n }\n\n # Remove all cookies that Drupal doesn't need to know about. ANY remaining\n # cookie will cause the request to pass-through to a backend. For the most part\n # we always set the NO_CACHE cookie after any POST request, disabling the\n # Varnish cache temporarily. The session cookie allows all authenticated users\n # to pass through as long as they're logged in.\n #\n # 1. Append a semi-colon to the front of the cookie string.\n # 2. Remove all spaces that appear after semi-colons.\n # 3. Match the cookies we want to keep, adding the space we removed\n # previously, back. (\\1) is first matching group in the regsuball.\n # 4. Remove all other cookies, identifying them by the fact that they have\n # no space after the preceding semi-colon.\n # 5. Remove all spaces and semi-colons from the beginning and end of the\n # cookie string.\n if (req.http.Cookie) {\n set req.http.Cookie = \";\" + req.http.Cookie;\n set req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n set req.http.Cookie = regsuball(req.http.Cookie, \";(S{1,2}ESS[a-z0-9]+|NO_CACHE)=\", \"; \\1=\");\n set req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n\n if (req.http.Cookie == \"\") {\n # If there are no remaining cookies, remove the cookie header. If there\n # aren't any cookie headers, Varnish's default behavior will be to cache\n # the page.\n unset req.http.Cookie;\n }\n else {\n # If there is any cookies left (a session or NO_CACHE cookie), do not\n # cache the page. Pass it on to Apache directly.\n return (pass);\n }\n }\n\n ## From default below ##\n if (req.restarts == 0) {\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For =\n req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n ## Unset Authorization header if it has the correct details...\n #if (req.http.Authorization == \"Basic \") {\n # unset req.http.Authorization;\n #}\n if (req.http.Authorization || req.http.Cookie) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n return (lookup);\n}\n\n# Code determining what to do when serving items from the Apache servers.\nsub vcl_fetch {\n # Don't allow static files to set cookies.\n if (req.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js)(\\?[a-z0-9]+)?$\") {\n # beresp == Back-end response from the web server.\n unset beresp.http.set-cookie;\n }\n else if (beresp.http.Cache-Control) {\n unset beresp.http.Expires;\n }\n\n if (beresp.status == 301) {\n set beresp.ttl = 1h;\n return(deliver);\n }\n\n ## Doesn't seem to work as expected\n #if (beresp.status == 500) {\n # set beresp.saintmode = 10s;\n # return(restart);\n #}\n\n # Allow items to be stale if needed.\n set beresp.grace = 1h;\n}\n\n# Set a header to track a cache HIT\/MISS.\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Varnish-Cache = \"HIT\";\n }\n else {\n set resp.http.X-Varnish-Cache = \"MISS\";\n }\n}\n\n# In the event of an error, show friendlier messages.\nsub vcl_error {\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + obj.status + \" \" + obj.response + {\"<\/h1>\n <p>\"} + obj.response + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"};\n return (deliver);\n}\n","old_contents":"# This is a basic VCL configuration file for varnish. See the vcl(7) main page for details on VCL syntax and semantics.\n\n# Default backend definition. Set this to point to your content server.\n\n backend default {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n .connect_timeout = 600s;\n .first_byte_timeout = 600s;\n .between_bytes_timeout = 600s;\n }\n\n# Respond to incoming requests.\nsub vcl_recv {\n #return (pass);\n if (req.request == \"GET\" && req.url ~ \"^\/varnishcheck$\") {\n error 200 \"Varnish is Ready\";\n }\n\n # Allow the backend to serve up stale content if it is responding slowly.\n if (!req.backend.healthy) {\n # Use anonymous, cached pages if all backends are down.\n unset req.http.Cookie;\n if (req.http.X-Forwarded-Proto == \"https\") {\n set req.http.X-Forwarded-Proto = \"http\";\n }\n set req.grace = 30m;\n } else {\n set req.grace = 15s;\n }\n\n # Get ride of progress.js query params\n if (req.url ~ \"^\/misc\/progress\\.js\\?[0-9]+$\") {\n set req.url = \"\/misc\/progress.js\";\n }\n\n # If global redirect is on\n #if (req.url ~ \"node\\?page=[0-9]+$\") {\n # set req.url = regsub(req.url, \"node(\\?page=[0-9]+$)\", \"\\1\");\n # return (lookup);\n #}\n\n # Do not cache these paths.\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/ooyala\/ping$\" ||\n req.url ~ \"^\/admin\" ||\n req.url ~ \"^\/admin\/.*$\" ||\n req.url ~ \"^\/user\" ||\n req.url ~ \"^\/user\/.*$\" ||\n req.url ~ \"^\/users\/.*$\" ||\n req.url ~ \"^\/info\/.*$\" ||\n req.url ~ \"^\/flag\/.*$\" ||\n req.url ~ \"^.*\/ajax\/.*$\" ||\n req.url ~ \"^.*\/ahah\/.*$\") {\n return (pass);\n }\n\n # Pipe these paths directly to Apache for streaming.\n if (req.url ~ \"^\/admin\/content\/backup_migrate\/export\") {\n return (pipe);\n }\n\n # Handle compression correctly. Different browsers send different\n # \"Accept-Encoding\" headers, even though they mostly all support the same\n # compression mechanisms. By consolidating these compression headers into\n # a consistent format, we can reduce the size of the cache and get more hits.=\n # @see: http:\/\/ varnish.projects.linpro.no\/wiki\/FAQ\/Compression\n if (req.http.Accept-Encoding) {\n if (req.http.Accept-Encoding ~ \"gzip\") {\n # If the browser supports it, we'll use gzip.\n set req.http.Accept-Encoding = \"gzip\";\n }\n else if (req.http.Accept-Encoding ~ \"deflate\") {\n # Next, try deflate if it is supported.\n set req.http.Accept-Encoding = \"deflate\";\n }\n else {\n # Unknown algorithm. Remove it and send unencoded.\n unset req.http.Accept-Encoding;\n }\n }\n\n # Always cache the following file types for all users.\n if (req.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js)(\\?[a-z0-9]+)?$\") {\n unset req.http.Cookie;\n }\n\n # Remove all cookies that Drupal doesn't need to know about. ANY remaining\n # cookie will cause the request to pass-through to a backend. For the most part\n # we always set the NO_CACHE cookie after any POST request, disabling the\n # Varnish cache temporarily. The session cookie allows all authenticated users\n # to pass through as long as they're logged in.\n #\n # 1. Append a semi-colon to the front of the cookie string.\n # 2. Remove all spaces that appear after semi-colons.\n # 3. Match the cookies we want to keep, adding the space we removed\n # previously, back. (\\1) is first matching group in the regsuball.\n # 4. Remove all other cookies, identifying them by the fact that they have\n # no space after the preceding semi-colon.\n # 5. Remove all spaces and semi-colons from the beginning and end of the\n # cookie string.\n if (req.http.Cookie) {\n set req.http.Cookie = \";\" + req.http.Cookie;\n set req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n set req.http.Cookie = regsuball(req.http.Cookie, \";(S{1,2}ESS[a-z0-9]+|NO_CACHE)=\", \"; \\1=\");\n set req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n\n if (req.http.Cookie == \"\") {\n # If there are no remaining cookies, remove the cookie header. If there\n # aren't any cookie headers, Varnish's default behavior will be to cache\n # the page.\n unset req.http.Cookie;\n }\n else {\n # If there is any cookies left (a session or NO_CACHE cookie), do not\n # cache the page. Pass it on to Apache directly.\n return (pass);\n }\n }\n\n ## From default below ##\n if (req.restarts == 0) {\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For =\n req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n ## Unset Authorization header if it has the correct details...\n #if (req.http.Authorization == \"Basic \") {\n # unset req.http.Authorization;\n #}\n if (req.http.Authorization || req.http.Cookie) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n return (lookup);\n}\n\n# Code determining what to do when serving items from the Apache servers.\nsub vcl_fetch {\n # Don't allow static files to set cookies.\n if (req.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js)(\\?[a-z0-9]+)?$\") {\n # beresp == Back-end response from the web server.\n unset beresp.http.set-cookie;\n }\n else if (beresp.http.Cache-Control) {\n unset beresp.http.Expires;\n }\n\n if (beresp.status == 301) {\n set beresp.ttl = 1h;\n return(deliver);\n }\n\n ## Doesn't seem to work as expected\n #if (beresp.status == 500) {\n # set beresp.saintmode = 10s;\n # return(restart);\n #}\n\n # Allow items to be stale if needed.\n set beresp.grace = 1h;\n}\n\n# Set a header to track a cache HIT\/MISS.\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Varnish-Cache = \"HIT\";\n }\n else {\n set resp.http.X-Varnish-Cache = \"MISS\";\n }\n}\n\n# In the event of an error, show friendlier messages.\nsub vcl_error {\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + obj.status + \" \" + obj.response + {\"<\/h1>\n <p>\"} + obj.response + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"};\n return (deliver);\n}\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"c25c34d5a58b0a002dca18c49afbe46a14ab3f3f","subject":"ensure multiple words can be matched such as `\/v2\/polyfill.production.min.js`","message":"ensure multiple words can be matched such as `\/v2\/polyfill.production.min.js`\n","repos":"JakeChampion\/polyfill-service,JakeChampion\/polyfill-service","old_file":"fastly\/vcl\/polyfill-service.vcl","new_file":"fastly\/vcl\/polyfill-service.vcl","new_contents":"sub set_backend {\n\t# Calculate the ideal region to route the request to.\n\tdeclare local var.region STRING;\n\tif (server.region ~ \"(APAC|Asia|North-America|South-America|US-Central|US-East|US-West)\") {\n\t\tset var.region = \"US\";\n\t} else {\n\t\tset var.region = \"EU\";\n\t}\n\n\t# Gather the health of the shields and origins.\n\tdeclare local var.v3_eu_is_healthy BOOL;\n\tset req.backend = F_v3_eu;\n\tset var.v3_eu_is_healthy = req.backend.healthy;\n\n\tdeclare local var.v3_us_is_healthy BOOL;\n\tset req.backend = F_v3_us;\n\tset var.v3_us_is_healthy = req.backend.healthy;\n\n\t# Set some sort of default, that shouldn't get used.\n\tset req.backend = F_v3_eu;\n\n\t# Route EU requests to the nearest healthy shield or origin.\n\tif (var.region == \"EU\") {\n\t\tif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_eu;\n\t\t}\n\t}\n\n\t# Route US requests to the nearest healthy shield or origin.\n\tif (var.region == \"US\") {\n\t\tif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_us;\n\t\t}\n\t}\n\n\t# Persist the decision so we can debug the result.\n\tset req.http.Debug-Backend = req.backend;\n\n\t# The Fastly macro is inserted after the backend is selected because the\n\t# macro has the code to select the correct req.http.Host value based on the backend.\n\t#FASTLY recv\n}\n\nsub vcl_recv {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_recv;\n\t}\n\n\tif (req.method != \"GET\" && req.method != \"HEAD\" && req.method != \"OPTIONS\" && req.method != \"FASTLYPURGE\" && req.method != \"PURGE\") {\n\t\terror 911;\n\t}\n\n\tif (req.method == \"OPTIONS\") {\n\t\terror 912;\n\t}\n\n\t# Because the old service had a router which allowed any words between \/v2\/polyfill. and .js\n\tif (req.url ~ \"^\/v2\/polyfill(\\.\\w+)+\\.js\") {\n\t\tset req.url = regsub(req.url, \"^\/v2\/polyfill(\\.\\w+)\\.js\", \"\/v2\/polyfill.min.js\");\n\t}\n\n\t# Override the v3 defaults with the defaults of v2\n\tif (req.url ~ \"^\/v2\/polyfill(\\.min)?\\.js\") {\n\t\tset req.url = regsub(req.url, \"^\/v2\", \"\/v3\");\n\t\tset req.url = querystring.set(req.url, \"version\", \"3.25.1\");\n\t\tdeclare local var.unknown STRING;\n\t\tset var.unknown = subfield(req.url.qs, \"unknown\", \"&\");\n\t\tset req.url = querystring.set(req.url, \"unknown\", if(var.unknown != \"\", var.unknown, \"ignore\"));\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\") {\n\t\tcall normalise_querystring_parameters_for_polyfill_bundle;\n\t}\n\n\t# Sort the querystring parameters alphabetically to improve chances of hitting a cached copy.\n\t# If querystring is empty, remove the ? from the url.\n\tset req.url = querystring.clean(querystring.sort(req.url));\n\tcall set_backend;\n}\n\nsub vcl_hash {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_hash;\n\t}\n\n\t# We are not adding req.http.host to the hash because we want https:\/\/cdn.polyfill.io and https:\/\/polyfill.io to be a single object in the cache.\n\t# set req.hash += req.http.host;\n\tset req.hash += req.url;\n\t# We include return(hash) to stop the function falling through to the default VCL built into varnish, which for vcl_hash will add req.url and req.http.Host to the hash.\n\treturn(hash);\n}\n\nsub vcl_miss {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_miss;\n\t}\n}\n\nsub vcl_pass {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_pass;\n\t}\n}\n\nsub vcl_fetch {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_fetch;\n\t}\n\n\t# These header are only required for HTML documents.\n\tif (beresp.http.Content-Type ~ \"text\/html\") {\n\t\t# Enables the cross-site scripting filter built into most modern web browsers.\n\t\tset beresp.http.X-XSS-Protection = \"1; mode=block\";\t\n\t}\n\t# Prevents MIME-sniffing a response away from the declared content type.\n\tset beresp.http.X-Content-Type-Options = \"nosniff\";\n\n\t# Ensure the site is only served over HTTPS and reduce the chances of someone performing a MITM attack.\n\tset beresp.http.Strict-Transport-Security = \"max-age=31536000; includeSubdomains; preload\";\n\n\t# The Referrer-Policy header governs which referrer information, sent in the Referer header, should be included with requests made.\n\t# Send a full URL when performing a same-origin request, but only send the origin of the document for other cases.\n\tset beresp.http.Referrer-Policy = \"origin-when-cross-origin\";\n\n\t# Enable purging of all objects in the Fastly cache by issuing a purge with the key \"polyfill-service\".\n\tif (beresp.http.Surrogate-Key !~ \"\\bpolyfill-service\\b\") {\n\t\tset beresp.http.Surrogate-Key = if(beresp.http.Surrogate-Key, beresp.http.Surrogate-Key \" polyfill-service\", \"polyfill-service\");\n\t}\n\n\tset beresp.http.Timing-Allow-Origin = \"*\";\n\n\tif (req.http.Normalized-User-Agent) {\n\t\tset beresp.http.Normalized-User-Agent = req.http.Normalized-User-Agent;\n\t\tset beresp.http.Detected-User-Agent = req.http.useragent_parser_family \"\/\" req.http.useragent_parser_major \".\" req.http.useragent_parser_minor \".\" req.http.useragent_parser_patch;\n\t}\n}\n\nsub vcl_deliver {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_deliver;\n\t}\n\n\tset req.http.Fastly-Force-Shield = \"yes\";\n\n\t# Allow cross origin GET, HEAD, and OPTIONS requests to be made.\n\tif (req.http.Origin) {\n\t\tset resp.http.Access-Control-Allow-Origin = \"*\";\n\t\tset resp.http.Access-Control-Allow-Methods = \"GET,HEAD,OPTIONS\";\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\") {\n\t\t# Need to add \"Vary: User-Agent\" in after vcl_fetch to avoid the \n\t\t# \"Vary: User-Agent\" entering the Varnish cache.\n\t\t# We need \"Vary: User-Agent\" in the browser cache because a browser\n\t\t# may update itself to a version which needs different polyfills\n\t\t# So we need to have it ignore the browser cached bundle when the user-agent changes.\n\t\tadd resp.http.Vary = \"User-Agent\";\n\t\tadd resp.http.Vary = \"Accept-Encoding\";\n\t}\n\n\tadd resp.http.Server-Timing = fastly_info.state {\", fastly;desc=\"Edge time\";dur=\"} time.elapsed.msec;\n\n\tif (req.http.Fastly-Debug) {\n\t\tset resp.http.Debug-Backend = req.http.Debug-Backend;\n\t\tset resp.http.Debug-Host = req.http.Host;\n\t\tset resp.http.Debug-Fastly-Restarts = req.restarts;\n\t\tset resp.http.Debug-Orig-URL = req.http.Orig-URL;\n\t\tset resp.http.Debug-VCL-Route = req.http.X-VCL-Route;\n\t\tset resp.http.useragent_parser_family = req.http.useragent_parser_family;\n\t\tset resp.http.useragent_parser_major = req.http.useragent_parser_major;\n\t\tset resp.http.useragent_parser_minor = req.http.useragent_parser_minor;\n\t\tset resp.http.useragent_parser_patch = req.http.useragent_parser_patch;\n\t} else {\n\t\tunset resp.http.Server;\n\t\tunset resp.http.Via;\n\t\tunset resp.http.X-Cache;\n\t\tunset resp.http.X-Cache-Hits;\n\t\tunset resp.http.X-Served-By;\n\t\tunset resp.http.X-Timer;\n\t\tunset resp.http.Fastly-Restarts;\n\t}\n}\n\nsub vcl_error {\n\tif (obj.status == 911) {\n\t\tset obj.status = 405;\n\t\tset obj.response = \"METHOD NOT ALLOWED\";\n\t\tset obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n\t\tset obj.http.Cache-Control = \"private, no-store\";\n\t\tsynthetic req.method \" METHOD NOT ALLOWED\";\n\t\treturn (deliver);\n\t}\n\tif (obj.status == 912) {\n\t\tset obj.status = 200;\n\t\tset obj.response = \"OK\";\n\t\tset obj.http.Allow = \"OPTIONS, GET, HEAD\";\n\t\treturn (deliver);\n\t}\n}\n","old_contents":"sub set_backend {\n\t# Calculate the ideal region to route the request to.\n\tdeclare local var.region STRING;\n\tif (server.region ~ \"(APAC|Asia|North-America|South-America|US-Central|US-East|US-West)\") {\n\t\tset var.region = \"US\";\n\t} else {\n\t\tset var.region = \"EU\";\n\t}\n\n\t# Gather the health of the shields and origins.\n\tdeclare local var.v3_eu_is_healthy BOOL;\n\tset req.backend = F_v3_eu;\n\tset var.v3_eu_is_healthy = req.backend.healthy;\n\n\tdeclare local var.v3_us_is_healthy BOOL;\n\tset req.backend = F_v3_us;\n\tset var.v3_us_is_healthy = req.backend.healthy;\n\n\t# Set some sort of default, that shouldn't get used.\n\tset req.backend = F_v3_eu;\n\n\t# Route EU requests to the nearest healthy shield or origin.\n\tif (var.region == \"EU\") {\n\t\tif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_eu;\n\t\t}\n\t}\n\n\t# Route US requests to the nearest healthy shield or origin.\n\tif (var.region == \"US\") {\n\t\tif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_us;\n\t\t}\n\t}\n\n\t# Persist the decision so we can debug the result.\n\tset req.http.Debug-Backend = req.backend;\n\n\t# The Fastly macro is inserted after the backend is selected because the\n\t# macro has the code to select the correct req.http.Host value based on the backend.\n\t#FASTLY recv\n}\n\nsub vcl_recv {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_recv;\n\t}\n\n\tif (req.method != \"GET\" && req.method != \"HEAD\" && req.method != \"OPTIONS\" && req.method != \"FASTLYPURGE\" && req.method != \"PURGE\") {\n\t\terror 911;\n\t}\n\n\tif (req.method == \"OPTIONS\") {\n\t\terror 912;\n\t}\n\n\t# Because the old service had a router which allowed any words between \/v2\/polyfill. and .js\n\tif (req.url ~ \"^\/v2\/polyfill(\\.\\w+)\\.js\") {\n\t\tset req.url = regsub(req.url, \"^\/v2\/polyfill(\\.\\w+)\\.js\", \"\/v2\/polyfill.min.js\");\n\t}\n\n\t# Override the v3 defaults with the defaults of v2\n\tif (req.url ~ \"^\/v2\/polyfill(\\.min)?\\.js\") {\n\t\tset req.url = regsub(req.url, \"^\/v2\", \"\/v3\");\n\t\tset req.url = querystring.set(req.url, \"version\", \"3.25.1\");\n\t\tdeclare local var.unknown STRING;\n\t\tset var.unknown = subfield(req.url.qs, \"unknown\", \"&\");\n\t\tset req.url = querystring.set(req.url, \"unknown\", if(var.unknown != \"\", var.unknown, \"ignore\"));\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\") {\n\t\tcall normalise_querystring_parameters_for_polyfill_bundle;\n\t}\n\n\t# Sort the querystring parameters alphabetically to improve chances of hitting a cached copy.\n\t# If querystring is empty, remove the ? from the url.\n\tset req.url = querystring.clean(querystring.sort(req.url));\n\tcall set_backend;\n}\n\nsub vcl_hash {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_hash;\n\t}\n\n\t# We are not adding req.http.host to the hash because we want https:\/\/cdn.polyfill.io and https:\/\/polyfill.io to be a single object in the cache.\n\t# set req.hash += req.http.host;\n\tset req.hash += req.url;\n\t# We include return(hash) to stop the function falling through to the default VCL built into varnish, which for vcl_hash will add req.url and req.http.Host to the hash.\n\treturn(hash);\n}\n\nsub vcl_miss {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_miss;\n\t}\n}\n\nsub vcl_pass {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_pass;\n\t}\n}\n\nsub vcl_fetch {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_fetch;\n\t}\n\n\t# These header are only required for HTML documents.\n\tif (beresp.http.Content-Type ~ \"text\/html\") {\n\t\t# Enables the cross-site scripting filter built into most modern web browsers.\n\t\tset beresp.http.X-XSS-Protection = \"1; mode=block\";\t\n\t}\n\t# Prevents MIME-sniffing a response away from the declared content type.\n\tset beresp.http.X-Content-Type-Options = \"nosniff\";\n\n\t# Ensure the site is only served over HTTPS and reduce the chances of someone performing a MITM attack.\n\tset beresp.http.Strict-Transport-Security = \"max-age=31536000; includeSubdomains; preload\";\n\n\t# The Referrer-Policy header governs which referrer information, sent in the Referer header, should be included with requests made.\n\t# Send a full URL when performing a same-origin request, but only send the origin of the document for other cases.\n\tset beresp.http.Referrer-Policy = \"origin-when-cross-origin\";\n\n\t# Enable purging of all objects in the Fastly cache by issuing a purge with the key \"polyfill-service\".\n\tif (beresp.http.Surrogate-Key !~ \"\\bpolyfill-service\\b\") {\n\t\tset beresp.http.Surrogate-Key = if(beresp.http.Surrogate-Key, beresp.http.Surrogate-Key \" polyfill-service\", \"polyfill-service\");\n\t}\n\n\tset beresp.http.Timing-Allow-Origin = \"*\";\n\n\tif (req.http.Normalized-User-Agent) {\n\t\tset beresp.http.Normalized-User-Agent = req.http.Normalized-User-Agent;\n\t\tset beresp.http.Detected-User-Agent = req.http.useragent_parser_family \"\/\" req.http.useragent_parser_major \".\" req.http.useragent_parser_minor \".\" req.http.useragent_parser_patch;\n\t}\n}\n\nsub vcl_deliver {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_deliver;\n\t}\n\n\tset req.http.Fastly-Force-Shield = \"yes\";\n\n\t# Allow cross origin GET, HEAD, and OPTIONS requests to be made.\n\tif (req.http.Origin) {\n\t\tset resp.http.Access-Control-Allow-Origin = \"*\";\n\t\tset resp.http.Access-Control-Allow-Methods = \"GET,HEAD,OPTIONS\";\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\") {\n\t\t# Need to add \"Vary: User-Agent\" in after vcl_fetch to avoid the \n\t\t# \"Vary: User-Agent\" entering the Varnish cache.\n\t\t# We need \"Vary: User-Agent\" in the browser cache because a browser\n\t\t# may update itself to a version which needs different polyfills\n\t\t# So we need to have it ignore the browser cached bundle when the user-agent changes.\n\t\tadd resp.http.Vary = \"User-Agent\";\n\t\tadd resp.http.Vary = \"Accept-Encoding\";\n\t}\n\n\tadd resp.http.Server-Timing = fastly_info.state {\", fastly;desc=\"Edge time\";dur=\"} time.elapsed.msec;\n\n\tif (req.http.Fastly-Debug) {\n\t\tset resp.http.Debug-Backend = req.http.Debug-Backend;\n\t\tset resp.http.Debug-Host = req.http.Host;\n\t\tset resp.http.Debug-Fastly-Restarts = req.restarts;\n\t\tset resp.http.Debug-Orig-URL = req.http.Orig-URL;\n\t\tset resp.http.Debug-VCL-Route = req.http.X-VCL-Route;\n\t\tset resp.http.useragent_parser_family = req.http.useragent_parser_family;\n\t\tset resp.http.useragent_parser_major = req.http.useragent_parser_major;\n\t\tset resp.http.useragent_parser_minor = req.http.useragent_parser_minor;\n\t\tset resp.http.useragent_parser_patch = req.http.useragent_parser_patch;\n\t} else {\n\t\tunset resp.http.Server;\n\t\tunset resp.http.Via;\n\t\tunset resp.http.X-Cache;\n\t\tunset resp.http.X-Cache-Hits;\n\t\tunset resp.http.X-Served-By;\n\t\tunset resp.http.X-Timer;\n\t\tunset resp.http.Fastly-Restarts;\n\t}\n}\n\nsub vcl_error {\n\tif (obj.status == 911) {\n\t\tset obj.status = 405;\n\t\tset obj.response = \"METHOD NOT ALLOWED\";\n\t\tset obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n\t\tset obj.http.Cache-Control = \"private, no-store\";\n\t\tsynthetic req.method \" METHOD NOT ALLOWED\";\n\t\treturn (deliver);\n\t}\n\tif (obj.status == 912) {\n\t\tset obj.status = 200;\n\t\tset obj.response = \"OK\";\n\t\tset obj.http.Allow = \"OPTIONS, GET, HEAD\";\n\t\treturn (deliver);\n\t}\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"087cad56cd93e0c13779dcf0158789574f77428c","subject":"Remove everything except the core settings","message":"Remove everything except the core settings\n","repos":"micktwomey\/docker-django-varnish","old_file":"default.vcl","new_file":"default.vcl","new_contents":"vcl 4.0;\nimport std;\n\nbackend default {\n .host = \"::BACKEND_PORT_8000_TCP_ADDR::\";\n .port = \"::BACKEND_PORT_8000_TCP_PORT::\";\n}\n","old_contents":"vcl 4.0;\nimport std;\n\nbackend default {\n .host = \"::BACKEND_PORT_8000_TCP_ADDR::\";\n .port = \"::BACKEND_PORT_8000_TCP_PORT::\";\n # .probe = {\n # .url = \"\/\";\n # .interval = 5s;\n # .timeout = 1 s;\n # .window = 5;\n # .threshold = 3;\n # }\n}\n\nsub vcl_recv {\n # Ignore all cookies except for \/admin\n if (!(req.url ~ \"^\/admin\/\")) {\n unset req.http.Cookie;\n }\n\n # # Give ourself some restart time\n # set req.backend_hint = default;\n # if (! std.healthy(req.backend)) {\n # set req.grace = 5m;\n # } else {\n # set req.grace = 15s;\n # }\n}\n\nsub vcl_backend_response {\n # Unset any cookies for static content and cache for 1 hour\n if (bereq.url ~ \"^\/static\/\") {\n unset beresp.http.set-cookie;\n set beresp.ttl = 1h;\n }\n # # Add some grace for backend restarts\n # set beresp.grace = 30m;\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"78071e1a288fa24fe2547236459ea8c408969040","subject":"Remove redirects from cdn to legacy, since canonical domain now has whitelist embedded. Fixes #214","message":"Remove redirects from cdn to legacy, since canonical domain now has whitelist embedded. Fixes #214\n","repos":"mcshaz\/polyfill-service,JakeChampion\/polyfill-service,jonathan-fielding\/polyfill-service,mcshaz\/polyfill-service,JakeChampion\/polyfill-service,kdzwinel\/polyfill-service,kdzwinel\/polyfill-service,jonathan-fielding\/polyfill-service,mcshaz\/polyfill-service,kdzwinel\/polyfill-service,jonathan-fielding\/polyfill-service","old_file":"fastly-config.vcl","new_file":"fastly-config.vcl","new_contents":"sub vcl_recv {\n#FASTLY recv\n\n\tif (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n\t\treturn(pass);\n\t}\n\n\tif (req.url ~ \"^\/v1\/polyfill\\.\" && req.url !~ \"[\\?\\&]ua=\") {\n\t\tset req.http.X-Orig-URL = req.url;\n\t\tset req.url = \"\/v1\/normalizeUa?ua=\" urlencode(req.http.User-Agent);\n\t}\n\n\treturn(lookup);\n}\n\nsub vcl_deliver {\n#FASTLY deliver\n\tif (req.url ~ \"^\/v1\/normalizeUa\" && resp.status == 200) {\n\t\tset req.http.Fastly-force-Shield = \"1\";\n\t\tif (req.http.X-Orig-URL ~ \"\\?\") {\n\t\t\tset req.url = req.http.X-Orig-URL \"&ua=\" resp.http.Normalized-User-Agent;\n\t\t} else {\n\t\t\tset req.url = req.http.X-Orig-URL \"?ua=\" resp.http.Normalized-User-Agent;\n\t\t}\n\t\trestart;\n\t} else if (req.url ~ \"^\/v1\/polyfill\\..*[\\?\\&]ua=\" && req.http.X-Orig-URL && req.http.X-Orig-URL !~ \"[\\?\\&]ua=\") {\n\t\tset resp.http.Vary = \"Accept-Encoding, User-Agent\";\n\t}\n\treturn(deliver);\n}\n","old_contents":"sub vcl_recv {\n#FASTLY recv\n\n\tif (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n\t return(pass);\n\t}\n\n\t# Redirect legacy service users to legacy service\n\tset req.http.X-Referer-Host = regsub(req.http.Referer, \"^https?\\:\\\/\\\/([^\\\/]+)(\\\/.*)?$\", \"\\1\");\n\tif (req.url == \"\/normalize.js\" ||\n\t\treq.url == \"\/normalize.css\" ||\n\t\treq.url == \"\/normalise.js\" ||\n\t\treq.url == \"\/normalise.css\" ||\n\t\treq.http.X-Referer-Host == \"www.manrepeller.com\" ||\n\t\treq.http.X-Referer-Host == \"www.mulesoft.com\" ||\n\t\treq.http.X-Referer-Host == \"iluoghidelcuore.it\" ||\n\t\treq.http.X-Referer-Host == \"it.donga.com\" ||\n\t\treq.http.X-Referer-Host == \"www.watchguard.com\" ||\n\t\treq.http.X-Referer-Host == \"www.mulesoft.org\" ||\n\t\treq.http.X-Referer-Host == \"asmwall.com\" ||\n\t\treq.http.X-Referer-Host == \"www.jcsu.edu\" ||\n\t\treq.http.X-Referer-Host == \"adscendmedia.com\" ||\n\t\treq.http.X-Referer-Host == \"game.donga.com\" ||\n\t\treq.http.X-Referer-Host == \"framkino.no\" ||\n\t\treq.http.X-Referer-Host == \"www.accesswireless.com\" ||\n\t\treq.http.X-Referer-Host == \"represent.com\" ||\n\t\treq.http.X-Referer-Host == \"www.designergreek.com\" ||\n\t\treq.http.X-Referer-Host == \"www.plumbingoverstock.com\" ||\n\t\treq.http.X-Referer-Host == \"servicos.searh.rn.gov.br\" ||\n\t\treq.http.X-Referer-Host == \"www.jane-usa.com\" ||\n\t\treq.http.X-Referer-Host == \"www.juntaempresa.com.br\" ||\n\t\treq.http.X-Referer-Host == \"watchguard.com\" ||\n\t\treq.http.X-Referer-Host == \"www.logianalytics.com\" ||\n\t\treq.http.X-Referer-Host == \"www.thebathpoint.com\" ||\n\t\treq.http.X-Referer-Host == \"blogs.mulesoft.org\" ||\n\t\treq.http.X-Referer-Host == \"www.purecanadiangaming.com\" ||\n\t\treq.http.X-Referer-Host == \"play.egzaminatorius.lt\" ||\n\t\treq.http.X-Referer-Host == \"internetacademi.com\" ||\n\t\treq.http.X-Referer-Host == \"www.skyhighnetworks.com\" ||\n\t\treq.http.X-Referer-Host == \"interactive.guim.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"www.soloio.com\" ||\n\t\treq.http.X-Referer-Host == \"desenvolvimentoparaweb.com\" ||\n\t\treq.http.X-Referer-Host == \"daily-fantasy.trunk.development.manhattan.gq1.yahoo.com\" ||\n\t\treq.http.X-Referer-Host == \"blog.damyller.com.br\" ||\n\t\treq.http.X-Referer-Host == \"doggiebag.no\" ||\n\t\treq.http.X-Referer-Host == \"www.beverlydiamonds.com\" ||\n\t\treq.http.X-Referer-Host == \"www.rogerscup.com\" ||\n\t\treq.http.X-Referer-Host == \"blog.hudy.cz\" ||\n\t\treq.http.X-Referer-Host == \"techhamlet.com\" ||\n\t\treq.http.X-Referer-Host == \"www.flirtfachmann.de\" ||\n\t\treq.http.X-Referer-Host == \"alpacacomics.com\" ||\n\t\treq.http.X-Referer-Host == \"areariservata.fondoprevidenzafinanze.it\" ||\n\t\treq.http.X-Referer-Host == \"www.framkino.no\" ||\n\t\treq.http.X-Referer-Host == \"www.nationalsecurities.com\" ||\n\t\treq.http.X-Referer-Host == \"www.tenniscanada.com\" ||\n\t\treq.http.X-Referer-Host == \"libek.org.rs\" ||\n\t\treq.http.X-Referer-Host == \"learn.logianalytics.com\" ||\n\t\treq.http.X-Referer-Host == \"www.impartner.lt\" ||\n\t\treq.http.X-Referer-Host == \"chameleon.biworldwide.com\" ||\n\t\treq.http.X-Referer-Host == \"www.pujckapowebu.cz\" ||\n\t\treq.http.X-Referer-Host == \"www.dlcnetwork.com\" ||\n\t\treq.http.X-Referer-Host == \"www.forbes.com\" ||\n\t\treq.http.X-Referer-Host == \"blog.skyhighnetworks.com\" ||\n\t\treq.http.X-Referer-Host == \"rflx.bjornborg.com\" ||\n\t\treq.http.X-Referer-Host == \"www.coach-outlet-store.com\" ||\n\t\treq.http.X-Referer-Host == \"gist.io\" ||\n\t\treq.http.X-Referer-Host == \"www.suicideispreventable.org\" ||\n\t\treq.http.X-Referer-Host == \"www.rangemastertacticalgear.com\" ||\n\t\treq.http.X-Referer-Host == \"www.hcpozicka.sk\" ||\n\t\treq.http.X-Referer-Host == \"www.airsoftmegastore.com\" ||\n\t\treq.http.X-Referer-Host == \"colortile.github.io\" ||\n\t\treq.http.X-Referer-Host == \"brasstacksmadras.com\" ||\n\t\treq.http.X-Referer-Host == \"hotelcasadomingo.com.mx\" ||\n\t\treq.http.X-Referer-Host == \"www.worcesterpromotions.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"www.asmwall.com\" ||\n\t\treq.http.X-Referer-Host == \"training.mulesoft.com\" ||\n\t\treq.http.X-Referer-Host == \"exhilarateme.com\" ||\n\t\treq.http.X-Referer-Host == \"www.kommentatorskampen.viasatsport.se\" ||\n\t\treq.http.X-Referer-Host == \"www.golfgearselect.com\" ||\n\t\treq.http.X-Referer-Host == \"www.hcpujcka.cz\" ||\n\t\treq.http.X-Referer-Host == \"www.industriallawsociety.org.uk\" ||\n\t\treq.http.X-Referer-Host == \"www.locawebcorp.com.br\" ||\n\t\treq.http.X-Referer-Host == \"giffffr.giphy.com\" ||\n\t\treq.http.X-Referer-Host == \"mccall.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"kommentatorskampen.viasatsport.se\" ||\n\t\treq.http.X-Referer-Host == \"miraclebodyandpaint.com\" ||\n\t\treq.http.X-Referer-Host == \"www.tymprozdravi.cz\" ||\n\t\treq.http.X-Referer-Host == \"delicius.it\" ||\n\t\treq.http.X-Referer-Host == \"www.bluehighwaygames.com\" ||\n\t\treq.http.X-Referer-Host == \"tales-of-pikohan.de\" ||\n\t\treq.http.X-Referer-Host == \"demo.restoreadytest.com\" ||\n\t\treq.http.X-Referer-Host == \"mark.stratmann.me\" ||\n\t\treq.http.X-Referer-Host == \"apixtechnology.com\" ||\n\t\treq.http.X-Referer-Host == \"www.telefonickapozicka.sk\" ||\n\t\treq.http.X-Referer-Host == \"www.telefonnipujcka.cz\" ||\n\t\treq.http.X-Referer-Host == \"www.iteo.no\" ||\n\t\treq.http.X-Referer-Host == \"www.diktate.info\" ||\n\t\treq.http.X-Referer-Host == \"bpharm.192.168.56.102.xip.io\" ||\n\t\treq.http.X-Referer-Host == \"www.artisanprecast.com\" ||\n\t\treq.http.X-Referer-Host == \"tcisolutions.com\" ||\n\t\treq.http.X-Referer-Host == \"icelebrate.icehotel.com\" ||\n\t\treq.http.X-Referer-Host == \"www.thirtysevenwest.com\" ||\n\t\treq.http.X-Referer-Host == \"www.asgllc.com\" ||\n\t\treq.http.X-Referer-Host == \"www.mailinbox.net\" ||\n\t\treq.http.X-Referer-Host == \"rustyfelty.com\" ||\n\t\treq.http.X-Referer-Host == \"pulse.p2c.com\" ||\n\t\treq.http.X-Referer-Host == \"www.framkino.com\" ||\n\t\treq.http.X-Referer-Host == \"armourselfstorage.com\" ||\n\t\treq.http.X-Referer-Host == \"www.dezrezblog.com\" ||\n\t\treq.http.X-Referer-Host == \"goodpeople.com\" ||\n\t\treq.http.X-Referer-Host == \"www.eden-houlgate.com\" ||\n\t\treq.http.X-Referer-Host == \"www.patiovirtual.com.br\" ||\n\t\treq.http.X-Referer-Host == \"stats.egzaminatorius.lt\" ||\n\t\treq.http.X-Referer-Host == \"www.movieville.org\" ||\n\t\treq.http.X-Referer-Host == \"secure.watchguard.com\" ||\n\t\treq.http.X-Referer-Host == \"nationalsecurities.com\" ||\n\t\treq.http.X-Referer-Host == \"www.snaponindustrial.eu\" ||\n\t\treq.http.X-Referer-Host == \"www.fangear.com\" ||\n\t\treq.http.X-Referer-Host == \"www.scribbleshop.com\" ||\n\t\treq.http.X-Referer-Host == \"forums.mulesoft.org\" ||\n\t\treq.http.X-Referer-Host == \"dataentries.in\" ||\n\t\treq.http.X-Referer-Host == \"maki.alconost.com\" ||\n\t\treq.http.X-Referer-Host == \"dixso.github.io\" ||\n\t\treq.http.X-Referer-Host == \"citaprevia.volkswagen.es\" ||\n\t\treq.http.X-Referer-Host == \"movieville.org\" ||\n\t\treq.http.X-Referer-Host == \"www.seoestudios.com\" ||\n\t\treq.http.X-Referer-Host == \"tickets.campo.nu\" ||\n\t\treq.http.X-Referer-Host == \"perriehale.toucan\" ||\n\t\treq.http.X-Referer-Host == \"online.printstation.cz\" ||\n\t\treq.http.X-Referer-Host == \"www.le-bistrot-basque.com\" ||\n\t\treq.http.X-Referer-Host == \"www.thaiartofmassage.com\" ||\n\t\treq.http.X-Referer-Host == \"www.seevolution.com\" ||\n\t\treq.http.X-Referer-Host == \"janeusa.david\" ||\n\t\treq.http.X-Referer-Host == \"www.goodpeople.com\" ||\n\t\treq.http.X-Referer-Host == \"feeds.feedburner.com\" ||\n\t\treq.http.X-Referer-Host == \"www.millwardesque.com\" ||\n\t\treq.http.X-Referer-Host == \"cci.smartucs.a\" ||\n\t\treq.http.X-Referer-Host == \"forum.tales-of-pikohan.de\" ||\n\t\treq.http.X-Referer-Host == \"small.mu\" ||\n\t\treq.http.X-Referer-Host == \"crisp.toucan\" ||\n\t\treq.http.X-Referer-Host == \"dev1776.nationalsecurities.com\" ||\n\t\treq.http.X-Referer-Host == \"byose.net\" ||\n\t\treq.http.X-Referer-Host == \"www.eurodiary.ie\" ||\n\t\treq.http.X-Referer-Host == \"lemouvementassociatif.org\" ||\n\t\treq.http.X-Referer-Host == \"www.ey.com\" ||\n\t\treq.http.X-Referer-Host == \"cuterunslive.com\" ||\n\t\treq.http.X-Referer-Host == \"blog.odynia.org\" ||\n\t\treq.http.X-Referer-Host == \"solarenaymar.com.ar\" ||\n\t\treq.http.X-Referer-Host == \"www.aispaitalia.it\" ||\n\t\treq.http.X-Referer-Host == \"www.startupsaturday.it\" ||\n\t\treq.http.X-Referer-Host == \"support.watchguard.com\" ||\n\t\treq.http.X-Referer-Host == \"dax.absolnet.se\" ||\n\t\treq.http.X-Referer-Host == \"www.creativeinnovation.net.au\" ||\n\t\treq.http.X-Referer-Host == \"dev.raird.no\" ||\n\t\treq.http.X-Referer-Host == \"lesjeteursdencre.fr\" ||\n\t\treq.http.X-Referer-Host == \"itnotes.pl\" ||\n\t\treq.http.X-Referer-Host == \"www.thesocietyinternational.com\" ||\n\t\treq.http.X-Referer-Host == \"terminalfx.com\" ||\n\t\treq.http.X-Referer-Host == \"draft.sx\" ||\n\t\treq.http.X-Referer-Host == \"atelier-florent.fr\" ||\n\t\treq.http.X-Referer-Host == \"www.buona-tavola-ristorante.fr\" ||\n\t\treq.http.X-Referer-Host == \"www.terminalfx.com\" ||\n\t\treq.http.X-Referer-Host == \"www.taxattorney.com\" ||\n\t\treq.http.X-Referer-Host == \"proenter.dev\" ||\n\t\treq.http.X-Referer-Host == \"bodelo-advocaten.be\" ||\n\t\treq.http.X-Referer-Host == \"www.football1asia.com\" ||\n\t\treq.http.X-Referer-Host == \"rets.ly\" ||\n\t\treq.http.X-Referer-Host == \"erriol.com\" ||\n\t\treq.http.X-Referer-Host == \"shssandiego.com\" ||\n\t\treq.http.X-Referer-Host == \"notecrow.appspot.com\" ||\n\t\treq.http.X-Referer-Host == \"framkino.com\" ||\n\t\treq.http.X-Referer-Host == \"sexsite.daan\" ||\n\t\treq.http.X-Referer-Host == \"sro.dk\" ||\n\t\treq.http.X-Referer-Host == \"www.coloft.com\" ||\n\t\treq.http.X-Referer-Host == \"taxiplus.vsystem.hu\" ||\n\t\treq.http.X-Referer-Host == \"stage.mulesoft.com\" ||\n\t\treq.http.X-Referer-Host == \"local.dev.ugameplan.com\" ||\n\t\treq.http.X-Referer-Host == \"posh-nosh.com\" ||\n\t\treq.http.X-Referer-Host == \"phongthuyshop.vn\" ||\n\t\treq.http.X-Referer-Host == \"local.mansionhouse.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"www.compareaccounting.com\" ||\n\t\treq.http.X-Referer-Host == \"news.coinometrics.com\" ||\n\t\treq.http.X-Referer-Host == \"prod-yann.mailinbox.net\" ||\n\t\treq.http.X-Referer-Host == \"rachelree.se\" ||\n\t\treq.http.X-Referer-Host == \"dev1.accesswireless.usdigitalpartners.net\" ||\n\t\treq.http.X-Referer-Host == \"www.ewirisk.com\" ||\n\t\treq.http.X-Referer-Host == \"snapchan.com\" ||\n\t\treq.http.X-Referer-Host == \"www.trikatasieraakademija.lv\" ||\n\t\treq.http.X-Referer-Host == \"www.fosteringadoptionswindon.org.uk\" ||\n\t\treq.http.X-Referer-Host == \"patiovirtual.com.br\" ||\n\t\treq.http.X-Referer-Host == \"www.libmanpro.com\" ||\n\t\treq.http.X-Referer-Host == \"www.diktate.dev\" ||\n\t\treq.http.X-Referer-Host == \"idisco.pianetaitalia.intra\" ||\n\t\treq.http.X-Referer-Host == \"strudelfolhadinho.com.br\" ||\n\t\treq.http.X-Referer-Host == \"www.cunesoft.com\" ||\n\t\treq.http.X-Referer-Host == \"www.shropshirefoundation.org\" ||\n\t\treq.http.X-Referer-Host == \"speakingofbeauty.tv\" ||\n\t\treq.http.X-Referer-Host == \"www.sbs.com.au\" ||\n\t\treq.http.X-Referer-Host == \"bosch.pikmahosting.de\" ||\n\t\treq.http.X-Referer-Host == \"janeusa.lol\" ||\n\t\treq.http.X-Referer-Host == \"eso.toucan\" ||\n\t\treq.http.X-Referer-Host == \"www.lamedicis.com\" ||\n\t\treq.http.X-Referer-Host == \"cereseurope.com\" ||\n\t\treq.http.X-Referer-Host == \"www.pizza-moltobene.fr\" ||\n\t\treq.http.X-Referer-Host == \"www.kaptiva.com.br\" ||\n\t\treq.http.X-Referer-Host == \"flixified.com\" ||\n\t\treq.http.X-Referer-Host == \"www.12roundsboxing.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"www.tensionautomation.com\" ||\n\t\treq.http.X-Referer-Host == \"www.copyprint.nl\" ||\n\t\treq.http.X-Referer-Host == \"unisol\" ||\n\t\treq.http.X-Referer-Host == \"timepad.ews.co.rs\" ||\n\t\treq.http.X-Referer-Host == \"dev.rets.ly\" ||\n\t\treq.http.X-Referer-Host == \"www.vrhabilis.com\" ||\n\t\treq.http.X-Referer-Host == \"trondheggelund.no\" ||\n\t\treq.http.X-Referer-Host == \"www.ferienwohnungen-lebenswert.de\" ||\n\t\treq.http.X-Referer-Host == \"blog.mainline.com\" ||\n\t\treq.http.X-Referer-Host == \"arcstonepartners.com\" ||\n\t\treq.http.X-Referer-Host == \"dev-mj\" ||\n\t\treq.http.X-Referer-Host == \"www.crisp-cpd.com\" ||\n\t\treq.http.X-Referer-Host == \"purecanadiangaming.com\" ||\n\t\treq.http.X-Referer-Host == \"mainline.com\" ||\n\t\treq.http.X-Referer-Host == \"idx.dev.rets.ly\" ||\n\t\treq.http.X-Referer-Host == \"eneco.flicker.visualwind.com\" ||\n\t\treq.http.X-Referer-Host == \"mi.etoilemedia.it\" ||\n\t\treq.http.X-Referer-Host == \"www.atmosphericwatergenerator.net\" ||\n\t\treq.http.X-Referer-Host == \"www.gasnaturalenergyclass.com\" ||\n\t\treq.http.X-Referer-Host == \"salesmarketing.championpetfoods.com\" ||\n\t\treq.http.X-Referer-Host == \"www.watchgaurd.com\" ||\n\t\treq.http.X-Referer-Host == \"vm-sqlext-svil\" ||\n\t\treq.http.X-Referer-Host == \"dev.accesswireless.usdigitalpartners.net\" ||\n\t\treq.http.X-Referer-Host == \"kommentatorskampen.ohmytest.se\" ||\n\t\treq.http.X-Referer-Host == \"m.euvivoesporte.com.br\" ||\n\t\treq.http.X-Referer-Host == \"blog.dasroot.net\" ||\n\t\treq.http.X-Referer-Host == \"bugsdashboard.com\" ||\n\t\treq.http.X-Referer-Host == \"www.eurodiary.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"seecanadabetter-app.appspot.com\" ||\n\t\treq.http.X-Referer-Host == \"www.bobbychanblog.com\" ||\n\t\treq.http.X-Referer-Host == \"www.mybenefitsatwork.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"www.fotolotos.lt\" ||\n\t\treq.http.X-Referer-Host == \"robferguson.org\" ||\n\t\treq.http.X-Referer-Host == \"staging.motherapp.com\" ||\n\t\treq.http.X-Referer-Host == \"www.undergroundminingequipmentcompaniescalgaryquotes.com\" ||\n\t\treq.http.X-Referer-Host == \"idisco.pianetaitalia.com\" ||\n\t\treq.http.X-Referer-Host == \"cliocalman.com\" ||\n\t\treq.http.X-Referer-Host == \"sexymirror-app.com\" ||\n\t\treq.http.X-Referer-Host == \"taxes-in-serbia.192.168.56.102.xip.io\" ||\n\t\treq.http.X-Referer-Host == \"wunderbiz.com\" ||\n\t\treq.http.X-Referer-Host == \"thebathpoint.webdemo.es\" ||\n\t\treq.http.X-Referer-Host == \"www.restaurant-lemenhir.com\" ||\n\t\treq.http.X-Referer-Host == \"www.valdeure.fr\" ||\n\t\treq.http.X-Referer-Host == \"bpharm.ews.co.rs\" ||\n\t\treq.http.X-Referer-Host == \"teachersdunet.com\" ||\n\t\treq.http.X-Referer-Host == \"livesmartswmo.com\" ||\n\t\treq.http.X-Referer-Host == \"javiblog.com\" ||\n\t\treq.http.X-Referer-Host == \"mi.etoilemedia.com\" ||\n\t\treq.http.X-Referer-Host == \"www.lens.org\" ||\n\t\treq.http.X-Referer-Host == \"blacknet.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"my-faith-be-like.ghost.io\" ||\n\t\treq.http.X-Referer-Host == \"laravel.dev\" ||\n\t\treq.http.X-Referer-Host == \"fi-hpotts.2014-mansionhouse\" ||\n\t\treq.http.X-Referer-Host == \"mi.mailinbox.net\" ||\n\t\treq.http.X-Referer-Host == \"www.schulkeplusrewards.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"sasha-project.s3.amazonaws.com\" ||\n\t\treq.http.X-Referer-Host == \"www.solarenaymar.com.ar\" ||\n\t\treq.http.X-Referer-Host == \"generate.visualwind.com\" ||\n\t\treq.http.X-Referer-Host == \"drupaltest.wgti.net\" ||\n\t\treq.http.X-Referer-Host == \"minasdev.org\" ||\n\t\treq.http.X-Referer-Host == \"ims-logistic.dev\" ||\n\t\treq.http.X-Referer-Host == \"viaresto.com\" ||\n\t\treq.http.X-Referer-Host == \"learn.logixml.com\" ||\n\t\treq.http.X-Referer-Host == \"ox.espadrill-admin\" ||\n\t\treq.http.X-Referer-Host == \"smallmu-sandbox.s3-ap-southeast-1.amazonaws.com\" ||\n\t\treq.http.X-Referer-Host == \"www.firstinternet.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"m.facebook.com\" ||\n\t\treq.http.X-Referer-Host == \"www.ace.media\" ||\n\t\treq.http.X-Referer-Host == \"www.ewiretx.com\" ||\n\t\treq.http.X-Referer-Host == \"crisp.test.tdev.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"www.mifabricavisual.com\" ||\n\t\treq.http.X-Referer-Host == \"www.targetintervention.no\" ||\n\t\treq.http.X-Referer-Host == \"www.couperogers.com\" ||\n\t\treq.http.X-Referer-Host == \"skyhighstaging.local.com\" ||\n\t\treq.http.X-Referer-Host == \"altorendimientoacademico.queretaro.itesm.mx\" ||\n\t\treq.http.X-Referer-Host == \"www.gall-holl.com\" ||\n\t\treq.http.X-Referer-Host == \"sbs-moad.s3-ap-southeast-2.amazonaws.com\" ||\n\t\treq.http.X-Referer-Host == \"firstint.recruitment-lite\" ||\n\t\treq.http.X-Referer-Host == \"www.sro.dk\" ||\n\t\treq.http.X-Referer-Host == \"www.menbur.com\" ||\n\t\treq.http.X-Referer-Host == \"libmanpro.com\" ||\n\t\treq.http.X-Referer-Host == \"blurayaustralia.com\" ||\n\t\treq.http.X-Referer-Host == \"www.adscendmedia.com\" ||\n\t\treq.http.X-Referer-Host == \"blog.vincentbrouillet.com\" ||\n\t\treq.http.X-Referer-Host == \"www.investiumonline.nl\" ||\n\t\treq.http.X-Referer-Host == \"burakkp.com\" ||\n\t\treq.http.X-Referer-Host == \"audreysystem.seeties.me\" ||\n\t\treq.http.X-Referer-Host == \"everestsalesconsultants.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"accesswireless.usdphosting.com\" ||\n\t\treq.http.X-Referer-Host == \"frota.searh.rn.gov.br\" ||\n\t\treq.http.X-Referer-Host == \"qa.ugameplan.com\" ||\n\t\treq.http.X-Referer-Host == \"secure.yec.co\" ||\n\t\treq.http.X-Referer-Host == \"connect.eu.mulesoft.com\" ||\n\t\treq.http.X-Referer-Host == \"www.lastlongerreview.com\" ||\n\t\treq.http.X-Referer-Host == \"kommentatorskampen.lo\" ||\n\t\treq.http.X-Referer-Host == \"kido.bigroominternet.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"ohmydev.se\" ||\n\t\treq.http.X-Referer-Host == \"www.bentogarcia.es\" ||\n\t\treq.http.X-Referer-Host == \"rearview.herokai.com\" ||\n\t\treq.http.X-Referer-Host == \"lecafelatin.resto-ready.com\" ||\n\t\treq.http.X-Referer-Host == \"html24-dev.dk\" ||\n\t\treq.http.X-Referer-Host == \"seecanadabetter.ddev\" ||\n\t\treq.http.X-Referer-Host == \"portal.ad1.wrvc.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"garthwunsch.com\" ||\n\t\treq.http.X-Referer-Host == \"www.elitecustomsigns.com\" ||\n\t\treq.http.X-Referer-Host == \"kaptiva.com.br\" ||\n\t\treq.http.X-Referer-Host == \"nordicinox.com\" ||\n\t\treq.http.X-Referer-Host == \"www.nataktivisterna.lo\" ||\n\t\treq.http.X-Referer-Host == \"www.fidalgobaycoffee.com\" ||\n\t\treq.http.X-Referer-Host == \"mailinbox.net\" ||\n\t\treq.http.X-Referer-Host == \"www.tension.com\" ||\n\t\treq.http.X-Referer-Host == \"www.mccall.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"petbucks.org\" ||\n\t\treq.http.X-Referer-Host == \"mulesoftcompdev.prod.acquia-sites.com\" ||\n\t\treq.http.X-Referer-Host == \"logidev.devcloud.acquia-sites.com\" ||\n\t\treq.http.X-Referer-Host == \"www.cuterunslive.com\" ||\n\t\treq.http.X-Referer-Host == \"ec2-54-86-27-137.compute-1.amazonaws.com\" ||\n\t\treq.http.X-Referer-Host == \"coloft.com\" ||\n\t\treq.http.X-Referer-Host == \"dev-yann.mailinbox.net\" ||\n\t\treq.http.X-Referer-Host == \"titistore.es\" ||\n\t\treq.http.X-Referer-Host == \"biztro.pl\" ||\n\t\treq.http.X-Referer-Host == \"zd.ews.co.rs\" ||\n\t\treq.http.X-Referer-Host == \"www.cafelatincaen.com\" ||\n\t\treq.http.X-Referer-Host == \"togume.com\" ||\n\t\treq.http.X-Referer-Host == \"connect.mulesoft.com\" ||\n\t\treq.http.X-Referer-Host == \"nataktivisterna.lo\" ||\n\t\treq.http.X-Referer-Host == \"livelean.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"copyprint.nl\" ||\n\t\treq.http.X-Referer-Host == \"jayhathaway.com\" ||\n\t\treq.http.X-Referer-Host == \"rugsejis.epratybos.lt\" ||\n\t\treq.http.X-Referer-Host == \"media-env.elasticbeanstalk.com\" ||\n\t\treq.http.X-Referer-Host == \"id.snowfire.io\" ||\n\t\treq.http.X-Referer-Host == \"employme.at\" ||\n\t\treq.http.X-Referer-Host == \"booleanbrothers.com\" ||\n\t\treq.http.X-Referer-Host == \"www.fusiongroup.ie\" ||\n\t\treq.http.X-Referer-Host == \"skyhighnetworks.gravitatestaging.com\" ||\n\t\treq.http.X-Referer-Host == \"www.teachers.youtalkonline.com\" ||\n\t\treq.http.X-Referer-Host == \"sunshineandfrank.com\" ||\n\t\treq.http.X-Referer-Host == \"proof.acemedia.bigroominternet.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"personaltrainersinlosangeles.com\" ||\n\t\treq.http.X-Referer-Host == \"www.shawn.co\" ||\n\t\treq.http.X-Referer-Host == \"solidproperty.com.my\" ||\n\t\treq.http.X-Referer-Host == \"www.nordicinox.com\" ||\n\t\treq.http.X-Referer-Host == \"tension.com\" ||\n\t\treq.http.X-Referer-Host == \"especiaiss3.gshow.globo.com\" ||\n\t\treq.http.X-Referer-Host == \"seebstore.com\" ||\n\t\treq.http.X-Referer-Host == \"packerz.uk\" ||\n\t\treq.http.X-Referer-Host == \"happyliving.jp\" ||\n\t\treq.http.X-Referer-Host == \"www.vacacionesdebuenrollito.com\" ||\n\t\treq.http.X-Referer-Host == \"plastpack.ind.br\" ||\n\t\treq.http.X-Referer-Host == \"finance.trunk.development.manhattan.gq1.yahoo.com\" ||\n\t\treq.http.X-Referer-Host == \"elearningpprd.biworldwide.com\" ||\n\t\treq.http.X-Referer-Host == \"millwardesque.com\" ||\n\t\treq.http.X-Referer-Host == \"icehotel.lo\" ||\n\t\treq.http.X-Referer-Host == \"ongair.im\" ||\n\t\treq.http.X-Referer-Host == \"mule01a.managed.contegix.com\" ||\n\t\treq.http.X-Referer-Host == \"ipated.org\" ||\n\t\treq.http.X-Referer-Host == \"cientifica-research.com\" ||\n\t\treq.http.X-Referer-Host == \"andreypopp.github.io\" ||\n\t\treq.http.X-Referer-Host == \"schools.medsense.in\" ||\n\t\treq.http.X-Referer-Host == \"d-ycl.cigna.com\" ||\n\t\treq.http.X-Referer-Host == \"romankorver.com\" ||\n\t\treq.http.X-Referer-Host == \"ihaveanidea.me\" ||\n\t\treq.http.X-Referer-Host == \"evoyan.org\" ||\n\t\treq.http.X-Referer-Host == \"cectserver.dyndns.org\" ||\n\t\treq.http.X-Referer-Host == \"test.idx.dev.rets.ly\" ||\n\t\treq.http.X-Referer-Host == \"vastgoedpro.dataquote.nl\" ||\n\t\treq.http.X-Referer-Host == \"sifopweb\" ||\n\t\treq.http.X-Referer-Host == \"instituteofselfmastery.com.au\" ||\n\t\treq.http.X-Referer-Host == \"www.automobrella.com\" ||\n\t\treq.http.X-Referer-Host == \"panel.mibubu.com\" ||\n\t\treq.http.X-Referer-Host == \"whsb.herokuapp.com\" ||\n\t\treq.http.X-Referer-Host == \"heastea.com\" ||\n\t\treq.http.X-Referer-Host == \"meishinkan.pl\" ||\n\t\treq.http.X-Referer-Host == \"manrepeller.staging.wpengine.com\" ||\n\t\treq.http.X-Referer-Host == \"derprecated.com\" ||\n\t\treq.http.X-Referer-Host == \"fobesfamily.com\" ||\n\t\treq.http.X-Referer-Host == \"tensionautomation.com\" ||\n\t\treq.http.X-Referer-Host == \"www.jesuisoriginale.com\" ||\n\t\treq.http.X-Referer-Host == \"www.domgonsa.com.ar\" ||\n\t\treq.http.X-Referer-Host == \"www.digitalpark.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"debray.jerome.free.fr\" ||\n\t\treq.http.X-Referer-Host == \"rainmakerthinking.training\" ||\n\t\treq.http.X-Referer-Host == \"thespineauthority.com.au\" ||\n\t\treq.http.X-Referer-Host == \"pseudocubic.com\" ||\n\t\treq.http.X-Referer-Host == \"mi.sky8.it\" ||\n\t\treq.http.X-Referer-Host == \"iteo.staging.wpengine.com\" ||\n\t\treq.http.X-Referer-Host == \"adscend-q.dev\" ||\n\t\treq.http.X-Referer-Host == \"taxes-in-serbia.ews.co.rs\" ||\n\t\treq.http.X-Referer-Host == \"s.codepen.io\" ||\n\t\treq.http.X-Referer-Host == \"seecanadabetter.ca\" ||\n\t\treq.http.X-Referer-Host == \"www.werkbund.com.br\" ||\n\t\treq.http.X-Referer-Host == \"www.art365.co.za\" ||\n\t\treq.http.X-Referer-Host == \"tensionpackaging.com\" ||\n\t\treq.http.X-Referer-Host == \"ec2-54-164-179-111.compute-1.amazonaws.com\" ||\n\t\treq.http.X-Referer-Host == \"sms.loc\" ||\n\t\treq.http.X-Referer-Host == \"timeclock.neonandmore.com\" ||\n\t\treq.http.X-Referer-Host == \"silverblingblack.com\" ||\n\t\treq.http.X-Referer-Host == \"www.modulolanguage.com\" ||\n\t\treq.http.X-Referer-Host == \"visualise.today\" ||\n\t\treq.http.X-Referer-Host == \"pickinglist.constance.com.br\" ||\n\t\treq.http.X-Referer-Host == \"mobileshoppingapps.net\" ||\n\t\treq.http.X-Referer-Host == \"ashleyandbarry.com\" ||\n\t\treq.http.X-Referer-Host == \"www.planetgreen.cl\" ||\n\t\treq.http.X-Referer-Host == \"portal-intranet.ti.sabesp.com.br\" ||\n\t\treq.http.X-Referer-Host == \"gordonrecords.net\" ||\n\t\treq.http.X-Referer-Host == \"cce.pathlore.net\" ||\n\t\treq.http.X-Referer-Host == \"www.myclaimvalue.com\" ||\n\t\treq.http.X-Referer-Host == \"stage.mulesoft.org\" ||\n\t\treq.http.X-Referer-Host == \"javiblog.javigs.es\"\n\t) {\n\t\tset req.http.X-Redir-URL = \"https:\/\/legacy.polyfill.io\" req.url;\n\t\terror 900 req.http.X-Redir-URL;\n\t}\n\n\tif (req.url ~ \"^\/v1\/polyfill\\.\" && req.url !~ \"[\\?\\&]ua=\") {\n\t\tset req.http.X-Orig-URL = req.url;\n\t\tset req.url = \"\/v1\/normalizeUa?ua=\" regsuball(regsuball(regsuball(req.http.User-Agent, {\"%\"}, {\"%25\"}), {\" \"}, {\"%20\"}), {\"&\"}, {\"%26\"});\n\t}\n\n\treturn(lookup);\n}\n\nsub vcl_deliver {\n#FASTLY deliver\n\tif (req.url ~ \"^\/v1\/normalizeUa\" && resp.status == 200) {\n\t\tset req.http.Fastly-force-Shield = \"1\";\n\t\tif (req.http.X-Orig-URL ~ \"\\?\") {\n\t\t\tset req.url = req.http.X-Orig-URL \"&ua=\" resp.http.Normalized-User-Agent;\n\t\t} else {\n\t\t\tset req.url = req.http.X-Orig-URL \"?ua=\" resp.http.Normalized-User-Agent;\n\t\t}\n\t\trestart;\n\t} else if (req.url ~ \"^\/v1\/polyfill\\..*[\\?\\&]ua=\" && req.http.X-Orig-URL && req.http.X-Orig-URL !~ \"[\\?\\&]ua=\") {\n\t\tset resp.http.Vary = \"Accept-Encoding, User-Agent\";\n\t}\n\treturn(deliver);\n}\n\nsub vcl_error {\n\tif (obj.status == 900) {\n\t\tset obj.http.Location = obj.response;\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\tsynthetic {\"The referer header or request URI supplied in your request is known to be an attempt to use the previous version of polyfill.io, so for backwards compatibility we're redirecting you to legacy.polyfill.io which will handle your request using the old version of the service. The legacy version will be discontinued in the future, so please update to the new version, and then let us know by raising an issue in our repo at https:\/\/github.com\/financial-times\/polyfill-service.\"};\n\t\treturn (deliver);\n\t}\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"0d0b9330511ed40bf34fcea9baa5b58da269903e","subject":"set the correct header","message":"set the correct header\n","repos":"kevinquinnyo\/varnish-devicedetect,wikp\/varnish-devicedetect,varnish\/varnish-devicedetect,kevinquinnyo\/varnish-devicedetect,wikp\/varnish-devicedetect,varnish\/varnish-devicedetect","old_file":"devicedetect.vcl","new_file":"devicedetect.vcl","new_contents":"#\n# detectdevice.vcl - regex based device detection for Varnish\n# http:\/\/github.com\/lkarsten\/varnish-devicedetect\/\n#\n# Author: Lasse Karstensen <lasse@varnish-software.com>\n\nsub devicedetect {\n unset req.http.X-hash-input;\n unset req.http.X-UA-Device;\n set req.http.X-UA-Device = \"pc\";\n\n if (req.http.User-Agent ~ \"(?i)ip(hone|od)\") { set req.http.X-UA-Device = \"mobile-iphone\"; }\n elsif (req.http.User-Agent ~ \"(?i)ipad\") { set req.http.X-UA-Device = \"tablet-ipad\"; }\n # how do we differ between an android phone and an android tablet?\n # http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent\n elsif (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") { set req.http.X-UA-Device = \"mobile-android\"; } \n # may very well give false positives towards android tablets. Suggestions welcome.\n elsif (req.http.User-Agent ~ \"(?i)android\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\n elsif (req.http.User-Agent ~ \"^HTC\" ||\n req.http.User-Agent ~ \"Fennec\" || \n req.http.User-Agent ~ \"IEMobile\" ||\n req.http.User-Agent ~ \"BlackBerry\" ||\n req.http.User-Agent ~ \"SymbianOS.*AppleWebKit\" ||\n req.http.User-Agent ~ \"Opera Mobi\") {\n set req.http.X-UA-Device = \"mobile-smartphone\";\n }\n elsif (req.http.User-Agent ~ \"(?i)symbian\" ||\n req.http.User-Agent ~ \"(?i)^sonyericsson\" ||\n req.http.User-Agent ~ \"(?i)^nokia\" ||\n req.http.User-Agent ~ \"(?i)^samsung\" ||\n req.http.User-Agent ~ \"(?i)^lg\" ||\n\treq.http.User-Agent ~ \"(?i)bada\" ||\n\treq.http.User-Agent ~ \"(?i)blazer\" ||\n\treq.http.User-Agent ~ \"(?i)cellphone\" ||\n\treq.http.User-Agent ~ \"(?i)iemobile\" ||\n\treq.http.User-Agent ~ \"(?i)midp-2.0\" ||\n\treq.http.User-Agent ~ \"(?i)u990\" ||\n\treq.http.User-Agent ~ \"(?i)netfront\" ||\n\treq.http.User-Agent ~ \"(?i)opera mini\" ||\n\treq.http.User-Agent ~ \"(?i)palm\" ||\n\treq.http.User-Agent ~ \"(?i)nintendo wii\" ||\n\treq.http.User-Agent ~ \"(?i)playstation portable\" ||\n\treq.http.User-Agent ~ \"(?i)portalmmm\" ||\n\treq.http.User-Agent ~ \"(?i)proxinet\" ||\n\treq.http.User-Agent ~ \"(?i)sonyericsson\" ||\n\treq.http.User-Agent ~ \"(?i)symbian\" ||\n\treq.http.User-Agent ~ \"(?i)windows\\ ?ce\" ||\n\treq.http.User-Agent ~ \"(?i)winwap\" ||\n\treq.http.User-Agent ~ \"(?i)eudoraweb\" ||\n\treq.http.User-Agent ~ \"(?i)htc\" ||\n\treq.http.User-Agent ~ \"(?i)240x320\" ||\n\treq.http.User-Agent ~ \"(?i)avantgo\") { \n set req.http.X-UA-Device = \"mobile-generic\";\n }\n\n # handle overrides\n if (req.http.Cookie ~ \"(i?)X-UA-Device-force\") {\n # ;?? means zero or one ;, non-greedy to match the first.\n set req.http.X-UA-Device = regsub(req.http.Cookie, \"(?i).*X-UA-Device-force=([^;]+);??.*\", \"\\1\");\n }\n set req.http.X-hash-input = req.http.X-UA-Device;\n}\n\n# vim: sw=4:tw=120 # meh\n","old_contents":"#\n# detectdevice.vcl - regex based device detection for Varnish\n# http:\/\/github.com\/lkarsten\/varnish-devicedetect\/\n#\n# Author: Lasse Karstensen <lasse@varnish-software.com>\n\nsub devicedetect {\n unset req.http.X-hash-input;\n unset req.http.X-UA-Device;\n set req.http.X-UA-Device = \"pc\";\n\n if (req.http.User-Agent ~ \"(?i)ip(hone|od)\") { set req.http.X-UA-Device = \"mobile-iphone\"; }\n elsif (req.http.User-Agent ~ \"(?i)ipad\") { set req.http.X-UA-Device = \"tablet-ipad\"; }\n # how do we differ between an android phone and an android tablet?\n # http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent\n elsif (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") { set req.http.X-UA-Device = \"mobile-android\"; } \n # may very well give false positives towards android tablets. Suggestions welcome.\n elsif (req.http.User-Agent ~ \"(?i)android\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\n elsif (req.http.User-Agent ~ \"^HTC\" ||\n req.http.User-Agent ~ \"Fennec\" || \n req.http.User-Agent ~ \"IEMobile\" ||\n req.http.User-Agent ~ \"BlackBerry\" ||\n req.http.User-Agent ~ \"SymbianOS.*AppleWebKit\" ||\n req.http.User-Agent ~ \"Opera Mobi\") {\n set req.http.X-VG-Device = \"mobile-smartphone\";\n }\n elsif (req.http.User-Agent ~ \"(?i)symbian\" ||\n req.http.User-Agent ~ \"(?i)^sonyericsson\" ||\n req.http.User-Agent ~ \"(?i)^nokia\" ||\n req.http.User-Agent ~ \"(?i)^samsung\" ||\n req.http.User-Agent ~ \"(?i)^lg\" ||\n\treq.http.User-Agent ~ \"(?i)bada\" ||\n\treq.http.User-Agent ~ \"(?i)blazer\" ||\n\treq.http.User-Agent ~ \"(?i)cellphone\" ||\n\treq.http.User-Agent ~ \"(?i)iemobile\" ||\n\treq.http.User-Agent ~ \"(?i)midp-2.0\" ||\n\treq.http.User-Agent ~ \"(?i)u990\" ||\n\treq.http.User-Agent ~ \"(?i)netfront\" ||\n\treq.http.User-Agent ~ \"(?i)opera mini\" ||\n\treq.http.User-Agent ~ \"(?i)palm\" ||\n\treq.http.User-Agent ~ \"(?i)nintendo wii\" ||\n\treq.http.User-Agent ~ \"(?i)playstation portable\" ||\n\treq.http.User-Agent ~ \"(?i)portalmmm\" ||\n\treq.http.User-Agent ~ \"(?i)proxinet\" ||\n\treq.http.User-Agent ~ \"(?i)sonyericsson\" ||\n\treq.http.User-Agent ~ \"(?i)symbian\" ||\n\treq.http.User-Agent ~ \"(?i)windows\\ ?ce\" ||\n\treq.http.User-Agent ~ \"(?i)winwap\" ||\n\treq.http.User-Agent ~ \"(?i)eudoraweb\" ||\n\treq.http.User-Agent ~ \"(?i)htc\" ||\n\treq.http.User-Agent ~ \"(?i)240x320\" ||\n\treq.http.User-Agent ~ \"(?i)avantgo\") { \n set req.http.X-UA-Device = \"mobile-generic\";\n }\n\n # handle overrides\n if (req.http.Cookie ~ \"(i?)X-UA-Device-force\") {\n # ;?? means zero or one ;, non-greedy to match the first.\n set req.http.X-UA-Device = regsub(req.http.Cookie, \"(?i).*X-UA-Device-force=([^;]+);??.*\", \"\\1\");\n }\n set req.http.X-hash-input = req.http.X-UA-Device;\n}\n\n# vim: sw=4:tw=120 # meh\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"d861c18fc97d74068e58337be86b306e0920b075","subject":"This file was named wrong, and the test does not make sense anymore, since the backend health information is in the fetch thread","message":"This file was named wrong, and the test does not make sense anymore, since the backend health information is in the fetch thread\n","repos":"alarky\/varnish-cache-doc-ja,ajasty-cavium\/Varnish-Cache,chrismoulton\/Varnish-Cache,alarky\/varnish-cache-doc-ja,alarky\/varnish-cache-doc-ja,zhoualbeart\/Varnish-Cache,mrhmouse\/Varnish-Cache,mrhmouse\/Varnish-Cache,varnish\/Varnish-Cache,varnish\/Varnish-Cache,feld\/Varnish-Cache,gquintard\/Varnish-Cache,gquintard\/Varnish-Cache,varnish\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,feld\/Varnish-Cache,franciscovg\/Varnish-Cache,chrismoulton\/Varnish-Cache,zhoualbeart\/Varnish-Cache,feld\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,zhoualbeart\/Varnish-Cache,franciscovg\/Varnish-Cache,alarky\/varnish-cache-doc-ja,mrhmouse\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,chrismoulton\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,feld\/Varnish-Cache,chrismoulton\/Varnish-Cache,mrhmouse\/Varnish-Cache,zhoualbeart\/Varnish-Cache,feld\/Varnish-Cache,varnish\/Varnish-Cache,varnish\/Varnish-Cache,gquintard\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,mrhmouse\/Varnish-Cache,franciscovg\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,chrismoulton\/Varnish-Cache,franciscovg\/Varnish-Cache,zhoualbeart\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,franciscovg\/Varnish-Cache,gquintard\/Varnish-Cache,alarky\/varnish-cache-doc-ja","old_file":"bin\/varnishtest\/tests\/r01228.vcl","new_file":"bin\/varnishtest\/tests\/r01228.vcl","new_contents":"","old_contents":"varnishtest \"req.backend.healthy in vcl_deliver\"\n\nserver s1 {\n\trxreq\n\ttxresp\n} -start\n\nvarnish v1 -vcl+backend {\n\n\timport ${vmod_std};\n\n\tsub vcl_deliver {\n\t set resp.http.x-foo = std.healthy(req.backend);\n\t}\n} -start\n\nclient c1 {\n\ttxreq\n\trxresp\n\texpect resp.status == 200\n} -run\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"f7eeb647ce4e558470f0014519855d7e9398bf67","subject":"Switch geo location to the new name space per https:\/\/docs.fastly.com\/guides\/migrations\/migrating-geolocation-variables-to-the-new-dataset","message":"Switch geo location to the new name space per https:\/\/docs.fastly.com\/guides\/migrations\/migrating-geolocation-variables-to-the-new-dataset\n","repos":"fastly\/fastly-magento,fastly\/fastly-magento,fastly\/fastly-magento,fastly\/fastly-magento","old_file":"app\/code\/community\/Fastly\/CDN\/etc\/vcl_snippets\/recv.vcl","new_file":"app\/code\/community\/Fastly\/CDN\/etc\/vcl_snippets\/recv.vcl","new_contents":" # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n # Sort the query arguments\n set req.url = boltsort.sort(req.url);\n\n # bypass language switcher\n if (req.url ~ \"(?i)___from_store=.*&___store=.*\") {\n set req.http.X-Pass = \"1\";\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (req.http.cookie:FASTLY_CDN_ENV) {\n set req.http.Fastly-Cdn-Env = req.http.cookie:FASTLY_CDN_ENV;\n } else {\n unset req.http.Fastly-Cdn-Env;\n }\n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n\n if (!req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n error 403;\n }\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n\n } else {\n error 403;\n }\n\n }\n\n # disable ESI processing on Origin Shield\n if (req.http.Fastly-FF) {\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(media|js|skin)\/.*\\.(png|jpg|jpeg|gif|css|js|swf|ico)$\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n # formkey lookup\n if (req.url ~ \"\/fastlycdn\/getformkey\/\") {\n # check if we have a formkey cookie\n if (req.http.Cookie:FASTLY_CDN_FORMKEY) {\n set req.http.Formkey = req.http.Cookie:FASTLY_CDN_FORMKEY;\n } else {\n # create formkey\n set req.http.seed = req.http.Cookie client.ip remote.port client.geo.longitude client.geo.latitude client.geo.postal_code;\n set req.http.Formkey = regsub(digest.hash_md5(req.http.seed), \"^0x\", \"\");\n }\n error 760 req.http.Formkey;\n }\n\n # client.geo lookup\n if (req.url ~ \"fastlycdn\/esi\/getcountry\/\") {\n # check if GeoIP has been already processed by client\n if (req.http.Cookie:FASTLY_CDN_GEOIP_PROCESSED) {\n error 200 \"\";\n } else {\n # modify req.url and restart request processing\n error 750 client.geo.country_code;\n }\n }\n\n # client.geo get country code\n if (req.url ~ \"fastlycdn\/esi\/getcountrycode\/\") {\n # create and set req.http.X-Country-Code\n error 755 client.geo.country_code;\n }\n\n # check for ESI calls\n if (req.url ~ \"esi_data=\") {\n # check for valid cookie data\n if (req.http.Cookie ~ \"FASTLY_CDN-([A-Za-z0-9-_]+)=([^;]*)\") {\n set req.url = querystring.filter(req.url, \"esi_data\") + \"&esi_data=\" + re.group.2;\n }\n }\n\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking\n set req.http.Magento-Original-URL = req.url;\n set req.url = querystring.regfilter(req.url, \"^(utm_.*|gclid|gdftrk|_ga|mc_.*)\");\n\n # If object has been marked as pass pass it\n if ( req.http.X-Pass ) {\n return(pass);\n }\n","old_contents":" # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n # Sort the query arguments\n set req.url = boltsort.sort(req.url);\n\n # bypass language switcher\n if (req.url ~ \"(?i)___from_store=.*&___store=.*\") {\n set req.http.X-Pass = \"1\";\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (req.http.cookie:FASTLY_CDN_ENV) {\n set req.http.Fastly-Cdn-Env = req.http.cookie:FASTLY_CDN_ENV;\n } else {\n unset req.http.Fastly-Cdn-Env;\n }\n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n\n if (!req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n error 403;\n }\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n\n } else {\n error 403;\n }\n\n }\n\n # disable ESI processing on Origin Shield\n if (req.http.Fastly-FF) {\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(media|js|skin)\/.*\\.(png|jpg|jpeg|gif|css|js|swf|ico)$\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n # formkey lookup\n if (req.url ~ \"\/fastlycdn\/getformkey\/\") {\n # check if we have a formkey cookie\n if (req.http.Cookie:FASTLY_CDN_FORMKEY) {\n set req.http.Formkey = req.http.Cookie:FASTLY_CDN_FORMKEY;\n } else {\n # create formkey\n set req.http.seed = req.http.Cookie client.ip remote.port geoip.longitude geoip.latitude geoip.postal_code;\n set req.http.Formkey = regsub(digest.hash_md5(req.http.seed), \"^0x\", \"\");\n }\n error 760 req.http.Formkey;\n }\n\n # geoip lookup\n if (req.url ~ \"fastlycdn\/esi\/getcountry\/\") {\n # check if GeoIP has been already processed by client\n if (req.http.Cookie:FASTLY_CDN_GEOIP_PROCESSED) {\n error 200 \"\";\n } else {\n # modify req.url and restart request processing\n error 750 geoip.country_code;\n }\n }\n\n # geoip get country code\n if (req.url ~ \"fastlycdn\/esi\/getcountrycode\/\") {\n # create and set req.http.X-Country-Code\n error 755 geoip.country_code;\n }\n\n # check for ESI calls\n if (req.url ~ \"esi_data=\") {\n # check for valid cookie data\n if (req.http.Cookie ~ \"FASTLY_CDN-([A-Za-z0-9-_]+)=([^;]*)\") {\n set req.url = querystring.filter(req.url, \"esi_data\") + \"&esi_data=\" + re.group.2;\n }\n }\n\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking\n set req.http.Magento-Original-URL = req.url;\n set req.url = querystring.regfilter(req.url, \"^(utm_.*|gclid|gdftrk|_ga|mc_.*)\");\n\n # If object has been marked as pass pass it\n if ( req.http.X-Pass ) {\n return(pass);\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"4aaaf9474b33660942fa590bd56ec21e4a7ef8b8","subject":"Remove trailing Python code characters from VCL template","message":"Remove trailing Python code characters from VCL template\n","repos":"elifesciences\/builder,elifesciences\/builder","old_file":"src\/buildercore\/fastly\/vcl\/main.vcl","new_file":"src\/buildercore\/fastly\/vcl\/main.vcl","new_contents":"sub vcl_recv {\n #FASTLY recv\n\n if (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n return(lookup);\n}\n\nsub vcl_fetch {\n #FASTLY fetch\n\n if ((beresp.status == 500 || beresp.status == 503) && req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n if (req.restarts > 0) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return(pass);\n }\n\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return(pass);\n }\n\n if (beresp.status == 500 || beresp.status == 503) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return(deliver);\n }\n\n if (beresp.http.Expires || beresp.http.Surrogate-Control ~ \"max-age\" || beresp.http.Cache-Control ~ \"(s-maxage|max-age)\") {\n # keep the ttl here\n } else {\n # apply the default ttl\n set beresp.ttl = 3600s;\n }\n\n return(deliver);\n}\n\nsub vcl_hit {\n #FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\nsub vcl_miss {\n #FASTLY miss\n return(fetch);\n}\n\nsub vcl_deliver {\n #FASTLY deliver\n return(deliver);\n}\n\nsub vcl_error {\n #FASTLY error\n}\n\nsub vcl_pass {\n #FASTLY pass\n}\n\nsub vcl_log {\n #FASTLY log\n}\n","old_contents":"sub vcl_recv {\n #FASTLY recv\n\n if (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n return(lookup);\n}\n\nsub vcl_fetch {\n #FASTLY fetch\n\n if ((beresp.status == 500 || beresp.status == 503) && req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n if (req.restarts > 0) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return(pass);\n }\n\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return(pass);\n }\n\n if (beresp.status == 500 || beresp.status == 503) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return(deliver);\n }\n\n if (beresp.http.Expires || beresp.http.Surrogate-Control ~ \"max-age\" || beresp.http.Cache-Control ~ \"(s-maxage|max-age)\") {\n # keep the ttl here\n } else {\n # apply the default ttl\n set beresp.ttl = 3600s;\n }\n\n return(deliver);\n}\n\nsub vcl_hit {\n #FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\nsub vcl_miss {\n #FASTLY miss\n return(fetch);\n}\n\nsub vcl_deliver {\n #FASTLY deliver\n return(deliver);\n}\n\nsub vcl_error {\n #FASTLY error\n}\n\nsub vcl_pass {\n #FASTLY pass\n}\n\nsub vcl_log {\n #FASTLY log\n}\"\"\")\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"7a0a1d0757772c035b66ac03fb6ae54c7b2026f0","subject":"Enable shielding on tester requests","message":"Enable shielding on tester requests\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets\/recv.vcl","new_file":"etc\/vcl_snippets\/recv.vcl","new_contents":" # When using Magento tester to test whether your site is configured properly\n # this uses a bypass secret. By default we will use service ID as the bypass secret\n # however user can override this by defining a bypass_secret key in the\n # magentomodule_config edge dictionary\n if ( req.http.bypass-secret ) {\n declare local var.bypass-secret STRING;\n set var.bypass-secret = table.lookup(magentomodule_config, \"bypass_secret\", \"NONE\");\n if ( var.bypass-secret == req.http.bypass-secret ) {\n set req.http.x-pass = \"1\";\n set var.fastly_req_do_shield = false;\n set req.hash_always_miss = true;\n } else if ( var.bypass-secret == \"NONE\" && req.http.bypass-secret == req.service_id ) {\n set req.http.x-pass = \"1\";\n set var.fastly_req_do_shield = false;\n set req.hash_always_miss = true;\n } else {\n error 403 \"Bypass Secret incorrect\";\n }\n\n if (req.url == \"\/fastly-io-tester\") {\n # IO won't work for PASS requests\n unset req.http.x-pass;\n # IO requires shielding\n set var.fastly_req_do_shield = true;\n set req.hash_always_miss = true;\n set req.http.X-Fastly-Imageopto-Api = \"fastly\";\n }\n }\n\n # VCL required to support maintenance mode. Don't maintenance mode admin pages and supporting assets\n if (table.lookup(magentomodule_config, \"allow_super_users_during_maint\", \"0\") == \"1\" &&\n !req.http.Fastly-Client-Ip ~ maint_allowlist &&\n !req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" &&\n !req.url ~ \"^\/pub\/static\/\") {\n\n # If we end up here after a restart and there is a ResponseObject it means we got here after error\n # page VCL restart. We shouldn't touch it. Otherwise return a plain 503 error page\n if ( req.restarts > 0 && req.http.ResponseObject ) {\n set req.http.ResponseObject = \"970\";\n } else {\n error 503 \"Maintenance mode\";\n }\n }\n\n unset req.http.x-long-cache;\n\n # We want to force long cache times on any of the versioned assets\n if (req.url.path ~ \"^\/static\/version\\d*\/\") {\n set req.http.x-long-cache = \"1\";\n }\n\n # User's Cookie may contain some Magento Vary items we should vary on\n if (req.http.cookie:X-Magento-Vary) {\n set req.http.X-Magento-Vary = req.http.cookie:X-Magento-Vary;\n } else {\n unset req.http.X-Magento-Vary;\n }\n\n ############################################################################################################\n # Following code block controls purge by URL. By default we want to protect all URL purges. In general this\n # is addressed by adding Fastly-Purge-Requires-Auth request header in vcl_recv however this runs the risk of\n # exposing API tokens if user attempts to purge non-https URLs. For this reason inside the Magento module\n # we use X-Purge-Token. Unfortunately this breaks purge from the Fastly UI. Therefore in the next code block\n # we check for presence of X-Purge-Token. If it's not present we force the Fastly-Purge-Requires-Auth\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n if (req.http.X-Purge-Token && req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n } else {\n error 403;\n }\n } else {\n set req.http.Fastly-Purge-Requires-Auth = \"1\";\n }\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (fastly.ff.visits_this_service > 0) {\n # disable ESI processing on Origin Shield\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Make sure we lookup end user geo not shielding. More at https:\/\/docs.fastly.com\/vcl\/geolocation\/#using-geographic-variables-with-shielding\n set client.geo.ip_override = req.http.Fastly-Client-IP;\n\n if ((req.request == \"GET\" || req.request == \"HEAD\") && req.url.path ~ \"\/graphql\" && req.url.qs ~ \"query=\") {\n set req.http.graphql = \"1\";\n } else {\n unset req.http.graphql;\n }\n\n # geoip lookup\n if (req.url.path ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie:X-Magento-Vary || req.http.cookie:form_key) {\n error 980 \"GeoIP already processed\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url.qs !~ \"country_code=\" ) {\n set req.url = querystring.set(req.url, \"country_code\", if ( req.http.geo_override, req.http.geo_override, client.geo.country_code));\n }\n }\n } else if ( req.url.path !~ \"\/graphql\" ) {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking by default\n # and allow custom parameters to be set. List of parameters is configurable in admin\n set req.http.Magento-Original-URL = req.url;\n # Change the list of ignored parameters by configuring them in the Advanced section\n set req.url = querystring.regfilter(req.url, \"^(####QUERY_PARAMETERS####)$\");\n }\n\n # Don't allow clients to force a pass\n if (req.restarts == 0) {\n unset req.http.x-pass;\n unset req.http.Rate-Limit;\n unset req.http.magento-admin-path;\n }\n\n # Pass on checkout URLs. Because it's a snippet we want to execute this after backend selection so we handle it\n # in the request condition\n if (!req.http.x-long-cache && req.url ~ \"\/(checkout|customer\/section\/load)\") {\n set req.http.x-pass = \"1\";\n # Pass all admin actions\n # ####ADMIN_PATH#### is replaced with value of frontName from app\/etc\/env.php\n } else if ( req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" ) {\n set req.http.x-pass = \"1\";\n set req.http.magento-admin-path = \"1\";\n } else {\n # Sort the query arguments to increase cache hit ratio with query arguments that\n # may be out od order. In case you want to restore the unsorted URL add a snippet\n # after this one that sets req.url to req.http.Magento-Original-URL\n if ( !req.http.x-pass ) {\n set req.url = boltsort.sort(req.url);\n }\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.http.x-long-cache || req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n # GraphQL special headers handling because this area doesn't rely on X-Magento-Vary cookie\n if (req.http.graphql && !req.http.X-Magento-Cache-Id && req.http.Authorization ~ \"^Bearer\" ) {\n unset req.http.graphql;\n set req.http.x-pass = \"1\";\n }\n","old_contents":" # When using Magento tester to test whether your site is configured properly\n # this uses a bypass secret. By default we will use service ID as the bypass secret\n # however user can override this by defining a bypass_secret key in the\n # magentomodule_config edge dictionary\n if ( req.http.bypass-secret ) {\n declare local var.bypass-secret STRING;\n set var.bypass-secret = table.lookup(magentomodule_config, \"bypass_secret\", \"NONE\");\n if ( var.bypass-secret == req.http.bypass-secret ) {\n set req.http.x-pass = \"1\";\n set var.fastly_req_do_shield = false;\n set req.hash_always_miss = true;\n } else if ( var.bypass-secret == \"NONE\" && req.http.bypass-secret == req.service_id ) {\n set req.http.x-pass = \"1\";\n set var.fastly_req_do_shield = false;\n set req.hash_always_miss = true;\n } else {\n error 403 \"Bypass Secret incorrect\";\n }\n\n if (req.url == \"\/fastly-io-tester\") {\n # IO won't work for PASS requests\n unset req.http.x-pass;\n set req.hash_always_miss = true;\n set req.http.X-Fastly-Imageopto-Api = \"fastly\";\n }\n }\n\n # VCL required to support maintenance mode. Don't maintenance mode admin pages and supporting assets\n if (table.lookup(magentomodule_config, \"allow_super_users_during_maint\", \"0\") == \"1\" &&\n !req.http.Fastly-Client-Ip ~ maint_allowlist &&\n !req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" &&\n !req.url ~ \"^\/pub\/static\/\") {\n\n # If we end up here after a restart and there is a ResponseObject it means we got here after error\n # page VCL restart. We shouldn't touch it. Otherwise return a plain 503 error page\n if ( req.restarts > 0 && req.http.ResponseObject ) {\n set req.http.ResponseObject = \"970\";\n } else {\n error 503 \"Maintenance mode\";\n }\n }\n\n unset req.http.x-long-cache;\n\n # We want to force long cache times on any of the versioned assets\n if (req.url.path ~ \"^\/static\/version\\d*\/\") {\n set req.http.x-long-cache = \"1\";\n }\n\n # User's Cookie may contain some Magento Vary items we should vary on\n if (req.http.cookie:X-Magento-Vary) {\n set req.http.X-Magento-Vary = req.http.cookie:X-Magento-Vary;\n } else {\n unset req.http.X-Magento-Vary;\n }\n\n ############################################################################################################\n # Following code block controls purge by URL. By default we want to protect all URL purges. In general this\n # is addressed by adding Fastly-Purge-Requires-Auth request header in vcl_recv however this runs the risk of\n # exposing API tokens if user attempts to purge non-https URLs. For this reason inside the Magento module\n # we use X-Purge-Token. Unfortunately this breaks purge from the Fastly UI. Therefore in the next code block\n # we check for presence of X-Purge-Token. If it's not present we force the Fastly-Purge-Requires-Auth\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n if (req.http.X-Purge-Token && req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n } else {\n error 403;\n }\n } else {\n set req.http.Fastly-Purge-Requires-Auth = \"1\";\n }\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (fastly.ff.visits_this_service > 0) {\n # disable ESI processing on Origin Shield\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Make sure we lookup end user geo not shielding. More at https:\/\/docs.fastly.com\/vcl\/geolocation\/#using-geographic-variables-with-shielding\n set client.geo.ip_override = req.http.Fastly-Client-IP;\n\n if ((req.request == \"GET\" || req.request == \"HEAD\") && req.url.path ~ \"\/graphql\" && req.url.qs ~ \"query=\") {\n set req.http.graphql = \"1\";\n } else {\n unset req.http.graphql;\n }\n\n # geoip lookup\n if (req.url.path ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie:X-Magento-Vary || req.http.cookie:form_key) {\n error 980 \"GeoIP already processed\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url.qs !~ \"country_code=\" ) {\n set req.url = querystring.set(req.url, \"country_code\", if ( req.http.geo_override, req.http.geo_override, client.geo.country_code));\n }\n }\n } else if ( req.url.path !~ \"\/graphql\" ) {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking by default\n # and allow custom parameters to be set. List of parameters is configurable in admin\n set req.http.Magento-Original-URL = req.url;\n # Change the list of ignored parameters by configuring them in the Advanced section\n set req.url = querystring.regfilter(req.url, \"^(####QUERY_PARAMETERS####)$\");\n }\n\n # Don't allow clients to force a pass\n if (req.restarts == 0) {\n unset req.http.x-pass;\n unset req.http.Rate-Limit;\n unset req.http.magento-admin-path;\n }\n\n # Pass on checkout URLs. Because it's a snippet we want to execute this after backend selection so we handle it\n # in the request condition\n if (!req.http.x-long-cache && req.url ~ \"\/(checkout|customer\/section\/load)\") {\n set req.http.x-pass = \"1\";\n # Pass all admin actions\n # ####ADMIN_PATH#### is replaced with value of frontName from app\/etc\/env.php\n } else if ( req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" ) {\n set req.http.x-pass = \"1\";\n set req.http.magento-admin-path = \"1\";\n } else {\n # Sort the query arguments to increase cache hit ratio with query arguments that\n # may be out od order. In case you want to restore the unsorted URL add a snippet\n # after this one that sets req.url to req.http.Magento-Original-URL\n if ( !req.http.x-pass ) {\n set req.url = boltsort.sort(req.url);\n }\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.http.x-long-cache || req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n # GraphQL special headers handling because this area doesn't rely on X-Magento-Vary cookie\n if (req.http.graphql && !req.http.X-Magento-Cache-Id && req.http.Authorization ~ \"^Bearer\" ) {\n unset req.http.graphql;\n set req.http.x-pass = \"1\";\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"55ddf2c64e41dbe436aa9cee92dd5ad1ad05b516","subject":"Missing X-Wall","message":"Missing X-Wall\n","repos":"rhargreaves\/fastly-vcl-experiments,rhargreaves\/fastly-vcl-experiments","old_file":"99_bottles.vcl","new_file":"99_bottles.vcl","new_contents":"backend F_fake_backend {\n\t.host = \"fake-backend.example.com\";\n\t.port = \"80\";\n\t.dynamic = true;\n\t.connect_timeout = 5s;\n\t.first_byte_timeout = 15s;\n\t.probe = {\n\t\t.dummy = true;\n\t}\n}\n\nsub vcl_recv {\n#FASTLY recv\n\tset req.backend = F_fake_backend;\n\n\tset req.http.X-Bottle = if(req.url ~ \"(?i)bottle=([^&]*)\", urldecode(re.group.1), \"99\");\n\tset req.http.X-Wall = if(req.http.X-Wall, req.http.X-Wall \" \", \"\") req.http.X-Bottle;\n\n\tif(req.http.X-Bottle == \"0\") {\n\t\terror 996;\n\t}\n\treturn(lookup);\n}\n\nsub vcl_fetch {\n#FASTLY fetch\n\n\tif(req.restarts > 0) {\n\t\tset beresp.http.Fastly-Restarts = req.restarts;\n\t}\n\treturn(deliver);\n}\n\nsub vcl_deliver {\n#FASTLY deliver\n\tset resp.http.X-Wall = req.http.X-Wall;\n\n\tif(req.restarts == 2) {\n# For now, limit to 3 bottles as we can only restart 3 times\n\t\tset req.http.X-Next-Bottle = \"0\";\n\t}\n\n\tset req.url = \"\/?bottle=\" req.http.X-Next-Bottle;\n\tif(req.restarts < 2) {\n\t\trestart;\n\t}\n\treturn(deliver);\n}\n\nsub set_next_bottle {\n\tset req.grace = 1d;\n\tset req.http.X-Original-Grace = req.grace;\n\tset req.grace = std.atoi(req.http.X-Bottle);\n\tset req.grace -= 1s;\n\tset req.http.X-Next-Bottle = regsub(req.grace, \"\\..*\", \"\");\n\tset req.grace = std.atoi(req.http.X-Original-Grace);\n}\n\nsub vcl_error {\n#FASTLY error\n\tif(obj.status == 996) {\n\t\tset obj.status = 200;\n\t\tset obj.response = \"Cheers!\";\n\t\tsynthetic req.http.X-Wall;\n\t\treturn (deliver);\n\t}\n}\n","old_contents":"backend F_fake_backend {\n\t.host = \"fake-backend.example.com\";\n\t.port = \"80\";\n\t.dynamic = true;\n\t.connect_timeout = 5s;\n\t.first_byte_timeout = 15s;\n\t.probe = {\n\t\t.dummy = true;\n\t}\n}\n\nsub vcl_recv {\n#FASTLY recv\n\tset req.backend = F_fake_backend;\n\n\tset req.http.X-Bottle = if(req.url ~ \"(?i)bottle=([^&]*)\", urldecode(re.group.1), \"99\");\n\tset req.http.X-Wall = if(req.http.X-Wall, \" \", \"\") req.http.X-Bottle;\n\n\tif(req.http.X-Bottle == \"0\") {\n\t\terror 996;\n\t}\n\treturn(lookup);\n}\n\nsub vcl_fetch {\n#FASTLY fetch\n\n\tif(req.restarts > 0) {\n\t\tset beresp.http.Fastly-Restarts = req.restarts;\n\t}\n\treturn(deliver);\n}\n\nsub vcl_deliver {\n#FASTLY deliver\n\tset resp.http.X-Wall = req.http.X-Wall;\n\n\tif(req.restarts == 2) {\n# For now, limit to 3 bottles as we can only restart 3 times\n\t\tset req.http.X-Next-Bottle = \"0\";\n\t}\n\n\tset req.url = \"\/?bottle=\" req.http.X-Next-Bottle;\n\tif(req.restarts < 2) {\n\t\trestart;\n\t}\n\treturn(deliver);\n}\n\nsub set_next_bottle {\n\tset req.grace = 1d;\n\tset req.http.X-Original-Grace = req.grace;\n\tset req.grace = std.atoi(req.http.X-Bottle);\n\tset req.grace -= 1s;\n\tset req.http.X-Next-Bottle = regsub(req.grace, \"\\..*\", \"\");\n\tset req.grace = std.atoi(req.http.X-Original-Grace);\n}\n\nsub vcl_error {\n#FASTLY error\n\tif(obj.status == 996) {\n\t\tset obj.status = 200;\n\t\tset obj.response = \"Cheers!\";\n\t\tsynthetic req.http.X-Wall;\n\t\treturn (deliver);\n\t}\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"04259387458de57d8d0c9bd8a26c44e87bf774cf","subject":"Don't cache \/status requests.","message":"Don't cache \/status requests.\n","repos":"drsnyder\/poky,drsnyder\/poky,drsnyder\/poky","old_file":"config\/default.vcl","new_file":"config\/default.vcl","new_contents":"# TODO:\n# - add probe for backend health\nbackend poky {\n .host = \"127.0.0.1\";\n .port = \"8081\"; # make sure this syncs up with the deploy config\n .connect_timeout = 1s;\n .first_byte_timeout = 5s;\n .between_bytes_timeout = 2s;\n .probe = {\n .url = \"\/status\";\n .interval = 5s;\n .timeout = 1s;\n .window = 5;\n .threshold = 3;\n }\n}\n\nsub vcl_recv {\n set req.backend = poky;\n set req.grace = 5m;\n\n # on PUT, POST, or DELETE, we want to invalidate the given object\n if (req.request == \"POST\" || req.request == \"PUT\" || req.request == \"DELETE\") {\n ban(\"req.url ~ \" + req.url);\n }\n\n if (req.url ~ \"^\/status$\") {\n return (pass);\n }\n}\n\nsub vcl_fetch {\n set beresp.grace = 5m;\n if (beresp.status == 200) {\n set beresp.ttl = 1h;\n }\n\n if (beresp.status == 404) {\n set beresp.ttl = 0s;\n }\n\n if (beresp.status >= 500) {\n set beresp.ttl = 0s;\n }\n\n}\n\nsub vcl_deliver {\n set resp.http.X-Served-By = server.identity;\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n","old_contents":"# TODO:\n# - add probe for backend health\nbackend poky {\n .host = \"127.0.0.1\";\n .port = \"8081\"; # make sure this syncs up with the deploy config\n .connect_timeout = 1s;\n .first_byte_timeout = 5s;\n .between_bytes_timeout = 2s;\n .probe = {\n .url = \"\/status\";\n .interval = 5s;\n .timeout = 1s;\n .window = 5;\n .threshold = 3;\n }\n}\n\nsub vcl_recv {\n set req.backend = poky;\n set req.grace = 5m;\n\n # on PUT, POST, or DELETE, we want to invalidate the given object\n if (req.request == \"POST\" || req.request == \"PUT\" || req.request == \"DELETE\") {\n ban(\"req.url ~ \" + req.url);\n }\n}\n\nsub vcl_fetch {\n set beresp.grace = 5m;\n if (beresp.status == 200) {\n set beresp.ttl = 1h;\n }\n\n if (beresp.status == 404) {\n set beresp.ttl = 0s;\n }\n\n if (beresp.status >= 500) {\n set beresp.ttl = 0s;\n }\n\n}\n\nsub vcl_deliver {\n set resp.http.X-Served-By = server.identity;\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"0d3a55456fe8758cb025d9c8f52cee976f427c16","subject":"Configuration for Varnish.","message":"Configuration for Varnish.\n","repos":"cebartling\/reverse-proxy-url-rewrite-experiment,cebartling\/reverse-proxy-url-rewrite-experiment","old_file":"proxy-servers\/varnish\/default.vcl","new_file":"proxy-servers\/varnish\/default.vcl","new_contents":"# This is a Varnish 4.x VCL file\nvcl 4.0;\n\n# Rails server\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"3000\";\n}\n\nSinatra server\nbackend sinatra {\n .host = \"127.0.0.1\";\n .port = \"4567\";\n}\n\n# Node.js server\n# backend nodejs {\n# .host = \"127.0.0.1\";\n# .port = \"5678\";\n# }\n\n# Handle the HTTP request received by the client\nsub vcl_recv {\n\t# if (req.url ~ \"^\/api\/v1\") {\n\t# set req.backend_hint = default;\n\t# }\n\n\tif (req.url ~ \"^\/api\/v1\/products\") {\n set req.backend_hint = sinatra;\n } else if (req.url ~ \"^\/api\/v2\/products\") {\n set req.backend_hint = sinatra;\n } else {\n set req.backend_hint = default;\n }\n\n\n\t# if (req.url ~ \"^\/api\/v1\/products\") {\n\t# set req.backend_hint = sinatra;\n\t# } else if (req.url ~ \"^\/api\/v2\/products\") {\n\t# set req.backend_hint = sinatra;\n\t# } else if (req.url ~ \"^\/api\/v3\/products\") {\n\t# set req.backend_hint = nodejs;\n\t# } else {\n\t# set req.backend_hint = default;\n\t# }\n}\n\n","old_contents":"# This is a Varnish 4.x VCL file\nvcl 4.0;\n\n# Rails server\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"3000\";\n}\n\n# Sinatra server\n# backend sinatra {\n# .host = \"127.0.0.1\";\n# .port = \"4567\";\n# }\n\n# Node.js server\n# backend nodejs {\n# .host = \"127.0.0.1\";\n# .port = \"5678\";\n# }\n\n# Handle the HTTP request received by the client\nsub vcl_recv {\n\tif (req.url ~ \"^\/api\/v1\") {\n set req.backend_hint = default;\n }\n\n\t# if (req.url ~ \"^\/api\/v1\/products\") {\n\t# set req.backend_hint = sinatra;\n\t# } else if (req.url ~ \"^\/api\/v2\/products\") {\n\t# set req.backend_hint = sinatra;\n\t# } else {\n\t# set req.backend_hint = default;\n\t# }\n\n\n\t# if (req.url ~ \"^\/api\/v1\/products\") {\n\t# set req.backend_hint = sinatra;\n\t# } else if (req.url ~ \"^\/api\/v2\/products\") {\n\t# set req.backend_hint = sinatra;\n\t# } else if (req.url ~ \"^\/api\/v3\/products\") {\n\t# set req.backend_hint = nodejs;\n\t# } else {\n\t# set req.backend_hint = default;\n\t# }\n}\n\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"580e8dacd1027b81899a6c599659b64545be5868","subject":"Update fixture","message":"Update fixture","repos":"dayvson\/libvmod-api-auth,dayvson\/libvmod-api-auth,dayvson\/libvmod-api-auth,dayvson\/libvmod-api-auth","old_file":"examples\/authentication-mongodb.vcl","new_file":"examples\/authentication-mongodb.vcl","new_contents":"import authorization;\n\nsub vcl_init {\n authorization.database(\"mongodb\");\n authorization.database_connect(\"127.0.0.1\", 27017, \"database.collection\");\n authorization.database_scheme(\"token\", \"secretkey\", \"ratelimit\");\n}\n\nsub vcl_recv {\n if (req.http.Authorization && req.http.X-Custom-Date) {\n if(authorization.is_valid(req.http.Authorization, req.url, req.http.X-Custom-Date)){\n return (pass);\n }else{\n error 401 \"Not Authorized\";\n }\n }\n}\n","old_contents":"import authorization;\n\nsub vcl_init {\n authorization.database(\"mongodb\");\n authorization.database_connect(\"127.0.0.1\", 27017, \"database.collection\");\n authorization.database_scheme(\"token\", \"secretkey\");\n}\n\nsub vcl_recv {\n if (req.http.Authorization && req.http.X-Custom-Date) {\n if(authorization.is_valid(req.http.Authorization, req.url, req.http.X-NYTV-Date)){\n return (pass);\n }else{\n error 401 \"Not Authorized\";\n }\n }\n}","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"8ff8091eb4239f2e257288d02a84b67241cb3ad4","subject":"Update zope-plone.vcl to v3 syntax","message":"Update zope-plone.vcl to v3 syntax\n\nThanks to cleberjsantos for initial patch which this is based on.\n\nFixes: #976\n","repos":"ajasty-cavium\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,1HLtd\/Varnish-Cache,franciscovg\/Varnish-Cache,chrismoulton\/Varnish-Cache,drwilco\/varnish-cache-drwilco,alarky\/varnish-cache-doc-ja,chrismoulton\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,ambernetas\/varnish-cache,mrhmouse\/Varnish-Cache,drwilco\/varnish-cache-drwilco,varnish\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,chrismoulton\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,1HLtd\/Varnish-Cache,mrhmouse\/Varnish-Cache,alarky\/varnish-cache-doc-ja,gquintard\/Varnish-Cache,feld\/Varnish-Cache,alarky\/varnish-cache-doc-ja,gauthier-delacroix\/Varnish-Cache,varnish\/Varnish-Cache,gquintard\/Varnish-Cache,mrhmouse\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,ambernetas\/varnish-cache,ajasty-cavium\/Varnish-Cache,drwilco\/varnish-cache-drwilco,gquintard\/Varnish-Cache,1HLtd\/Varnish-Cache,chrismoulton\/Varnish-Cache,alarky\/varnish-cache-doc-ja,chrismoulton\/Varnish-Cache,feld\/Varnish-Cache,franciscovg\/Varnish-Cache,varnish\/Varnish-Cache,ambernetas\/varnish-cache,varnish\/Varnish-Cache,zhoualbeart\/Varnish-Cache,franciscovg\/Varnish-Cache,zhoualbeart\/Varnish-Cache,zhoualbeart\/Varnish-Cache,varnish\/Varnish-Cache,zhoualbeart\/Varnish-Cache,feld\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,mrhmouse\/Varnish-Cache,gquintard\/Varnish-Cache,feld\/Varnish-Cache,franciscovg\/Varnish-Cache,1HLtd\/Varnish-Cache,zhoualbeart\/Varnish-Cache,franciscovg\/Varnish-Cache,feld\/Varnish-Cache,mrhmouse\/Varnish-Cache,alarky\/varnish-cache-doc-ja","old_file":"etc\/zope-plone.vcl","new_file":"etc\/zope-plone.vcl","new_contents":"#\n# This is an example VCL configuration file for varnish, meant for the\n# Plone CMS running within Zope. It defines a \"default\" backend for\n# serving static content from a normal web server, and a \"zope\"\n# backend for requests to the Zope CMS\n#\n# See the vcl(7) man page for details on VCL syntax and semantics.\n#\n# $Id$\n#\n\n# Default backend definition. Set this to point to your content\n# server.\n\n# Default backend is the Zope CMS\nbackend default {\n\t.host = \"127.0.0.1\";\n\t.port = \"9673\";\n}\n\nacl purge {\n\t\"localhost\";\n\t\"192.0.2.0\"\/24;\n}\n\nsub vcl_recv {\n\n\t# Normalize host headers, and do rewriting for the zope sites. Reject\n\t# requests for unknown hosts\n if (req.http.host ~ \"(www.)?example.com\") {\n set req.http.host = \"example.com\";\n set req.url = \"\/VirtualHostBase\/http\/example.com:80\/example.com\/VirtualHostRoot\" + req.url;\n } elsif (req.http.host ~ \"(www.)?example.org\") {\n set req.http.host = \"example.org\";\n set req.url = \"\/VirtualHostBase\/http\/example.org:80\/example.org\/VirtualHostRoot\" + req.url;\n } else {\n error 404 \"Unknown virtual host.\";\n }\n\n # Handle special requests\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n\n # POST - Logins and edits\n if (req.request == \"POST\") {\n return(pass);\n }\n \n # PURGE - The CacheFu product can invalidate updated URLs\n if (req.request == \"PURGE\") {\n if (!client.ip ~ purge) {\n error 405 \"Not allowed.\";\n }\n return(lookup);\n }\n }\n\n # Don't cache authenticated requests\n if (req.http.Cookie && req.http.Cookie ~ \"__ac(|_(name|password|persistent))=\") {\n\n\t\t# Force lookup of specific urls unlikely to need protection\n\t\tif (req.url ~ \"\\.(js|css)\") {\n remove req.http.cookie;\n return(lookup);\n }\n return(pass);\n }\n\n # The default vcl_recv is used from here.\n }\n\n# Do the PURGE thing\nsub vcl_hit {\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged\";\n }\n}\nsub vcl_miss {\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged\";\n }\n}\n\n# Enforce a minimum TTL, since we can PURGE changed objects actively\n# from Zope by using the CacheFu product\n\nsub vcl_fetch {\n if (beresp.ttl < 3600s) {\n set beresp.ttl = 3600s;\n }\n}\n","old_contents":"#\n# This is an example VCL configuration file for varnish, meant for the\n# Plone CMS running within Zope. It defines a \"default\" backend for\n# serving static content from a normal web server, and a \"zope\"\n# backend for requests to the Zope CMS\n#\n# See the vcl(7) man page for details on VCL syntax and semantics.\n#\n# $Id$\n#\n\n# Default backend definition. Set this to point to your content\n# server.\n\n# Default backend is the Zope CMS\nbackend default {\n\tset backend.host = \"127.0.0.1\";\n\tset backend.port = \"9673\";\n}\n\nacl purge {\n\t\"localhost\";\n\t\"192.0.2.0\"\/24;\n}\n\nsub vcl_recv {\n\n\t# Normalize host headers, and do rewriting for the zope sites. Reject\n\t# requests for unknown hosts\n if (req.http.host ~ \"(www.)?example.com\") {\n set req.http.host = \"example.com\";\n set req.url = \"\/VirtualHostBase\/http\/example.com:80\/example.com\/VirtualHostRoot\" req.url;\n } elsif (req.http.host ~ \"(www.)?example.org\") {\n set req.http.host = \"example.org\";\n set req.url = \"\/VirtualHostBase\/http\/example.org:80\/example.org\/VirtualHostRoot\" req.url;\n } else {\n error 404 \"Unknown virtual host.\";\n }\n\n # Handle special requests\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n\n # POST - Logins and edits\n if (req.request == \"POST\") {\n pass;\n }\n \n # PURGE - The CacheFu product can invalidate updated URLs\n if (req.request == \"PURGE\") {\n if (!client.ip ~ purge) {\n error 405 \"Not allowed.\";\n }\n lookup;\n }\n }\n\n # Don't cache authenticated requests\n if (req.http.Cookie && req.http.Cookie ~ \"__ac(|_(name|password|persistent))=\") {\n\n\t\t# Force lookup of specific urls unlikely to need protection\n\t\tif (req.url ~ \"\\.(js|css)\") {\n remove req.http.cookie;\n lookup;\n }\n pass;\n }\n\n # The default vcl_recv is used from here.\n }\n\n# Do the PURGE thing\nsub vcl_hit {\n if (req.request == \"PURGE\") {\n set obj.ttl = 0s;\n error 200 \"Purged\";\n }\n}\nsub vcl_miss {\n if (req.request == \"PURGE\") {\n error 404 \"Not in cache\";\n }\n}\n\n# Enforce a minimum TTL, since we can PURGE changed objects actively\n# from Zope by using the CacheFu product\n\nsub vcl_fetch {\n if (obj.ttl < 3600s) {\n set obj.ttl = 3600s;\n }\n}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"bde309f9605a6566946412864365213c3f252774","subject":"Another comment","message":"Another comment\n","repos":"elifesciences\/builder,elifesciences\/builder","old_file":"src\/buildercore\/fastly\/vcl\/main.vcl","new_file":"src\/buildercore\/fastly\/vcl\/main.vcl","new_contents":"sub vcl_recv {\n if (req.restarts < 1) {\n # Sanitise header\n unset req.http.X-eLife-Restart;\n }\n\n #FASTLY recv\n\n if (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n return(lookup);\n}\n\nsub vcl_fetch {\n #FASTLY fetch\n\n if (beresp.status >= 500 && beresp.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n set req.http.X-eLife-Restart = \"fetch,\" beresp.status;\n unset req.http.Cookie; # Temporarily log out the user\n\n restart;\n }\n\n if (!beresp.http.Content-Length || beresp.http.Content-Length == \"0\") {\n # Elastic Load Balancer returns empty error responses\n error beresp.status;\n }\n }\n\n if (req.restarts > 0) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return(pass);\n }\n\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return(pass);\n }\n\n if (beresp.status == 500 || beresp.status == 503) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return(deliver);\n }\n\n if (beresp.http.Expires || beresp.http.Surrogate-Control ~ \"max-age\" || beresp.http.Cache-Control ~ \"(s-maxage|max-age)\") {\n # keep the ttl here\n } else {\n # apply the default ttl\n set beresp.ttl = 3600s;\n }\n\n return(deliver);\n}\n\nsub vcl_hit {\n #FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\nsub vcl_miss {\n #FASTLY miss\n return(fetch);\n}\n\nsub vcl_deliver {\n if (resp.status >= 500 && resp.status < 600 && stale.exists) {\n set req.http.X-eLife-Restart = \"deliver,\" resp.status;\n\n restart;\n }\n\n if (req.http.Fastly-Debug && req.http.X-eLife-Restart) {\n set resp.http.X-eLife-Restart = req.http.X-eLife-Restart;\n }\n\n #FASTLY deliver\n return(deliver);\n}\n\nsub vcl_error {\n if (obj.status >= 500 && obj.status < 600 && stale.exists) {\n return(deliver_stale);\n }\n\n #FASTLY error\n}\n\nsub vcl_pass {\n #FASTLY pass\n}\n\nsub vcl_log {\n #FASTLY log\n}\n","old_contents":"sub vcl_recv {\n if (req.restarts < 1) {\n # Sanitise header\n unset req.http.X-eLife-Restart;\n }\n\n #FASTLY recv\n\n if (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n return(lookup);\n}\n\nsub vcl_fetch {\n #FASTLY fetch\n\n if (beresp.status >= 500 && beresp.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n set req.http.X-eLife-Restart = \"fetch,\" beresp.status;\n unset req.http.Cookie; # Temporarily log out the user\n\n restart;\n }\n\n if (!beresp.http.Content-Length || beresp.http.Content-Length == \"0\") {\n error beresp.status;\n }\n }\n\n if (req.restarts > 0) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return(pass);\n }\n\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return(pass);\n }\n\n if (beresp.status == 500 || beresp.status == 503) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return(deliver);\n }\n\n if (beresp.http.Expires || beresp.http.Surrogate-Control ~ \"max-age\" || beresp.http.Cache-Control ~ \"(s-maxage|max-age)\") {\n # keep the ttl here\n } else {\n # apply the default ttl\n set beresp.ttl = 3600s;\n }\n\n return(deliver);\n}\n\nsub vcl_hit {\n #FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\nsub vcl_miss {\n #FASTLY miss\n return(fetch);\n}\n\nsub vcl_deliver {\n if (resp.status >= 500 && resp.status < 600 && stale.exists) {\n set req.http.X-eLife-Restart = \"deliver,\" resp.status;\n\n restart;\n }\n\n if (req.http.Fastly-Debug && req.http.X-eLife-Restart) {\n set resp.http.X-eLife-Restart = req.http.X-eLife-Restart;\n }\n\n #FASTLY deliver\n return(deliver);\n}\n\nsub vcl_error {\n if (obj.status >= 500 && obj.status < 600 && stale.exists) {\n return(deliver_stale);\n }\n\n #FASTLY error\n}\n\nsub vcl_pass {\n #FASTLY pass\n}\n\nsub vcl_log {\n #FASTLY log\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"258d5a3af20a71f7c4cbd8cc3ba45c81a1834135","subject":"Remove unnecessary restart block since it's never gonna get hit","message":"Remove unnecessary restart block since it's never gonna get hit\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets\/fetch.vcl","new_file":"etc\/vcl_snippets\/fetch.vcl","new_contents":" \/* handle 5XX (or any other unwanted status code) *\/\n if (beresp.status >= 500 && beresp.status < 600) {\n\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n \/* deliver stale if the object is available *\/\n if (stale.exists) {\n return(deliver_stale);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n \/* else go to vcl_error to deliver a synthetic *\/\n error 503;\n }\n\n # Remove Set-Cookies from responses for static content\n # to match the cookie removal in recv.\n if (req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's since those can be temporary during the site build\/index\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n }\n\n }\n\n if (req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Content-Type ~ \"text\/html\" || beresp.http.Content-Type ~ \"text\/xml\") {\n # enable ESI feature for Magento response by default\n esi;\n if (!beresp.http.Vary ~ \"X-Magento-Vary,Https\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \",X-Magento-Vary,Https\";\n } else {\n set beresp.http.Vary = \"X-Magento-Vary,Https\";\n }\n }\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content\n if ((beresp.status == 200 || beresp.status == 404) && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url ~ \"\\.(css|js|html|eot|ico|otf|ttf|json)($|\\?)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # cache only successfully responses and 404s\n if (beresp.status != 200 && beresp.status != 301 && beresp.status != 404) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\")) {\n unset beresp.http.set-cookie;\n if (req.url !~ \"^\/(pub\/)?(media|static)\/.*\") {\n set beresp.grace = 86400m;\n }\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type\n if (beresp.http.Content-Type ~ \"image\") {\n set beresp.http.Surrogate-Key = \"image\";\n } elsif (beresp.http.Content-Type ~ \"script\") {\n set beresp.http.Surrogate-Key = \"script\";\n } elsif (beresp.http.Content-Type ~ \"css\") {\n set beresp.http.Surrogate-Key = \"css\";\n }\n\n set beresp.http.X-Surrogate-Key = beresp.http.Surrogate-Key;\n return (deliver);\n }","old_contents":" \/* handle 5XX (or any other unwanted status code) *\/\n if (beresp.status >= 500 && beresp.status < 600) {\n\n \/* deliver stale if the object is available *\/\n if (stale.exists) {\n return(deliver_stale);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n \/* else go to vcl_error to deliver a synthetic *\/\n error 503;\n }\n\n # Remove Set-Cookies from responses for static content\n # to match the cookie removal in recv.\n if (req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n }\n\n }\n\n if (beresp.status >= 500) {\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n }\n\n if (req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Content-Type ~ \"text\/html\" || beresp.http.Content-Type ~ \"text\/xml\") {\n # enable ESI feature for Magento response by default\n esi;\n if (!beresp.http.Vary ~ \"X-Magento-Vary,Https\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \",X-Magento-Vary,Https\";\n } else {\n set beresp.http.Vary = \"X-Magento-Vary,Https\";\n }\n }\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content\n if ((beresp.status == 200 || beresp.status == 404) && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url ~ \"\\.(css|js|html|eot|ico|otf|ttf|json)($|\\?)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # cache only successfully responses and 404s\n if (beresp.status != 200 && beresp.status != 301 && beresp.status != 404) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\")) {\n unset beresp.http.set-cookie;\n if (req.url !~ \"^\/(pub\/)?(media|static)\/.*\") {\n set beresp.grace = 86400m;\n }\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type\n if (beresp.http.Content-Type ~ \"image\") {\n set beresp.http.Surrogate-Key = \"image\";\n } elsif (beresp.http.Content-Type ~ \"script\") {\n set beresp.http.Surrogate-Key = \"script\";\n } elsif (beresp.http.Content-Type ~ \"css\") {\n set beresp.http.Surrogate-Key = \"css\";\n }\n\n set beresp.http.X-Surrogate-Key = beresp.http.Surrogate-Key;\n return (deliver);\n }","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"2a9fb6fd64c73f590aff01792594bba9f6af9b80","subject":"Minor refinement for basic auth","message":"Minor refinement for basic auth\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets_basic_auth\/recv.vcl","new_file":"etc\/vcl_snippets_basic_auth\/recv.vcl","new_contents":" # Check Basic auth against a table\n if ( table.lookup(magentomodule_basic_auth, regsub(req.http.Authorization, \"^Basic \", \"\"), \"NOTFOUND\") == \"NOTFOUND\" ) {\n error 971;\n }\n","old_contents":" if ( table.lookup(magentomodule_basic_auth, req.http.Authorization, \"NOTFOUND\") == \"NOTFOUND\" ) {\n error 971;\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"d6c56075cc338c4e4b26c99d0e024f76a73e5520","subject":"converted tabs to spaces","message":"converted tabs to spaces\n","repos":"timwhitlock\/php-varnish","old_file":"wordpress-plugin\/wordpress.vcl","new_file":"wordpress-plugin\/wordpress.vcl","new_contents":"\r\nbackend origin {\r\n .host = \"localhost\";\r\n .port = \"8080\";\r\n}\r\n\r\n\r\nsub vcl_recv {\r\n # only using one backend\r\n set req.backend = origin;\r\n \r\n # set standard proxied ip header for getting original remote address\r\n set req.http.X-Forwarded-For = client.ip;\r\n \r\n # logged in users must always pass\r\n if( req.url ~ \"^\/wp-(login|admin)\" || req.http.Cookie ~ \"wordpress_logged_in_\" ){\r\n return (pass);\r\n }\r\n \r\n # don't cache search results\r\n if( req.url ~ \"\\?s=\" ){\r\n return (pass);\r\n }\r\n\r\n # always pass through posted requests and those with basic auth\r\n if ( req.request == \"POST\" || req.http.Authorization ) {\r\n return (pass);\r\n }\r\n \r\n # else ok to fetch a cached page\r\n unset req.http.Cookie;\r\n return (lookup);\r\n}\r\n\r\n\r\n\r\nsub vcl_fetch {\r\n\r\n # remove some headers we never want to see\r\n unset beresp.http.Server;\r\n unset beresp.http.X-Powered-By;\r\n \r\n # only allow cookies to be set if we're in admin area - i.e. commenters stay logged out\r\n if( beresp.http.Set-Cookie && req.url !~ \"^\/wp-(login|admin)\" ){\r\n unset beresp.http.Set-Cookie;\r\n }\r\n \r\n # don't cache response to posted requests or those with basic auth\r\n if ( req.request == \"POST\" || req.http.Authorization ) {\r\n return (pass);\r\n }\r\n \r\n # Trust Varnish if it says this is not cacheable\r\n if ( ! beresp.cacheable ) {\r\n return (pass);\r\n }\r\n\r\n # only cache status ok\r\n if ( beresp.status != 200 ) {\r\n return (pass);\r\n }\r\n\r\n # don't cache search results\r\n if( req.url ~ \"\\?s=\" ){\r\n return (pass);\r\n }\r\n \r\n # else ok to cache the response\r\n set beresp.ttl = 24h;\r\n return (deliver);\r\n}\r\n\r\n\r\n\r\nsub vcl_deliver {\r\n # add debugging headers, so we can see what's cached\r\n if (obj.hits > 0) {\r\n set resp.http.X-Cache = \"HIT\";\r\n }\r\n else {\r\n set resp.http.X-Cache = \"MISS\";\r\n }\r\n # remove some headers added by varnish\r\n unset resp.http.Via;\r\n unset resp.http.X-Varnish;\r\n}\r\n\r\n\r\n\r\nsub vcl_hash {\r\n set req.hash += req.url;\r\n # altering hash so subdomains are ignored.\r\n # don't do this if you actually run different sites on different subdomains\r\n if ( req.http.host ) {\r\n set req.hash += regsub( req.http.host, \"^([^\\.]+\\.)+([a-z]+)$\", \"\\1\\2\" );\r\n } else {\r\n set req.hash += server.ip;\r\n }\r\n # ensure separate cache for mobile clients (WPTouch workaround)\r\n if( req.http.User-Agent ~ \"(iPod|iPhone|incognito|webmate|dream|CUPCAKE|WebOS|blackberry9\\d\\d\\d)\" ){\r\n set req.hash += \"touch\";\r\n }\r\n return (hash);\r\n} \r\n","old_contents":"\r\nbackend origin {\r\n .host = \"localhost\";\r\n .port = \"8080\";\r\n}\r\n\r\n\r\nsub vcl_recv {\r\n\t# only using one backend\r\n\tset req.backend = origin;\r\n\t\r\n\t# set standard proxied ip header for getting original remote address\r\n\tset req.http.X-Forwarded-For = client.ip;\r\n\t\r\n\t# logged in users must always pass\r\n\tif( req.url ~ \"^\/wp-(login|admin)\" || req.http.Cookie ~ \"wordpress_logged_in_\" ){\r\n\t return (pass);\r\n\t}\r\n \r\n # don't cache search results\r\n if( req.url ~ \"\\?s=\" ){\r\n return (pass);\r\n }\r\n\r\n\t# always pass through posted requests and those with basic auth\r\n\tif ( req.request == \"POST\" || req.http.Authorization ) {\r\n \t\treturn (pass);\r\n\t}\r\n\t\r\n\t# else ok to fetch a cached page\r\n\tunset req.http.Cookie;\r\n\treturn (lookup);\r\n}\r\n\r\n\r\n\r\nsub vcl_fetch {\r\n\r\n\t# remove some headers we never want to see\r\n\tunset beresp.http.Server;\r\n\tunset beresp.http.X-Powered-By;\r\n\t\r\n\t# only allow cookies to be set if we're in admin area - i.e. commenters stay logged out\r\n\tif( beresp.http.Set-Cookie && req.url !~ \"^\/wp-(login|admin)\" ){\r\n\t\tunset beresp.http.Set-Cookie;\r\n\t}\r\n\t\r\n\t# don't cache response to posted requests or those with basic auth\r\n\tif ( req.request == \"POST\" || req.http.Authorization ) {\r\n \t\treturn (pass);\r\n\t}\r\n\t\r\n\t# Trust Varnish if it says this is not cacheable\r\n\tif ( ! beresp.cacheable ) {\r\n \treturn (pass);\r\n \t}\r\n\r\n\t# only cache status ok\r\n\tif ( beresp.status != 200 ) {\r\n\t\treturn (pass);\r\n\t}\r\n\r\n # don't cache search results\r\n if( req.url ~ \"\\?s=\" ){\r\n return (pass);\r\n }\r\n\t\r\n\t# else ok to cache the response\r\n\tset beresp.ttl = 24h;\r\n\treturn (deliver);\r\n}\r\n\r\n\r\n\r\nsub vcl_deliver {\r\n\t# add debugging headers, so we can see what's cached\r\n\tif (obj.hits > 0) {\r\n\t\tset resp.http.X-Cache = \"HIT\";\r\n \t}\r\n \telse {\r\n\t\tset resp.http.X-Cache = \"MISS\";\r\n\t}\r\n\t# remove some headers added by varnish\r\n\tunset resp.http.Via;\r\n\tunset resp.http.X-Varnish;\r\n}\r\n\r\n\r\n\r\nsub vcl_hash {\r\n set req.hash += req.url;\r\n # altering hash so subdomains are ignored.\r\n # don't do this if you actually run different sites on different subdomains\r\n if ( req.http.host ) {\r\n set req.hash += regsub( req.http.host, \"^([^\\.]+\\.)+([a-z]+)$\", \"\\1\\2\" );\r\n } else {\r\n set req.hash += server.ip;\r\n }\r\n # ensure separate cache for mobile clients (WPTouch workaround)\r\n if( req.http.User-Agent ~ \"(iPod|iPhone|incognito|webmate|dream|CUPCAKE|WebOS|blackberry9\\d\\d\\d)\" ){\r\n \tset req.hash += \"touch\";\r\n }\r\n return (hash);\r\n} \r\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"88195c508ff8e3522dae30dbf6ef7be8b72c6175","subject":"Add commands","message":"Add commands\n","repos":"aschneiderman\/atom-voice-vocola","old_file":"atom.vcl","new_file":"atom.vcl","new_contents":"# Voice commands for atom\n\ninclude folders.vch;\ninclude letters.vch;\n\nGo Strawberry = {Ctrl+Alt+F8};\nGo Blueberry ={Ctrl+Alt+o};\nGo Banana = {Ctrl+Alt+F7};\n\nStart Far = 'var ';\n\n# Commands for developing Atom: init.config, packages; also for navigating existing packages\/commands\nReload Atom = {Ctrl+s} Wait(100) {Shift+Ctrl+Alt+F5};\nCommand Palette = {Ctrl+Shift+p};\nKeyboard Shortcuts = {Ctrl+.};\nRun Specs = {Ctrl+Alt+p};\nShow Console = {Ctrl+Alt+i};\n\n# Commands for developing D3: D3 visualizations, D3 Sandwiches\nSave and Reload = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Ctrl+r};\t\nSave and Really Reload = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Ctrl+Shift+r};\n\n# File commands\nFind (File | Document) = {Ctrl+t};\nSave As = {Ctrl+Shift+s};\n\n\n# --- Navigation commands ------------------------------------\n<delimiters> := (Quote = '\"' | 'Single Quote' = \"'\" | Comma = ',' | 'Equal Sign' = '=' | Equals = '=' \n\t| Period = '.' | Colon = ':' | 'Semi-Colon' = ';' | Hyphen = '-' | Underscore = '_' | Slash = '\/'\n\t| Paren = \"(\" | \"Close Paren\" = \")\" | Parentheses = \"(\" | \"Close Parentheses\" = \")\"\n\t| Bracket = '[' | \"Close Bracket\" = ']' | Brace = '{' | 'Close Brace' = '}'\t);\n\nLine 1..200 = {Ctrl+g} $1 {Enter};\n(Left = 'b' | Right = 'f') Word = {Alt+$1};\nTop = {Ctrl+Home};\nBottom = {Ctrl+End};\n(Find = 'Right' | 'Insert After' = 'Right' | 'Insert Before' = 'Left') (Next = 'Enter' | Last = 'Shift+F3') <delimiters> \n\t\t= {Ctrl+f} $3 {$2} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') <delimiters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') 1..20 <delimiters> = {Ctrl+f} $3 {Enter} {Esc} Wait(100) {F3_$2} {Shift+F3} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') Enda <delimiters> = {End} {Ctrl+f} $2 {Enter} {Esc} {Shift+F3} Wait(100) {$1};\n\nFine Alpha <letters> = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Left};\nInsert (Before = 'Left' | After = 'Right') Alpha <letters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nFine Number 0..9 = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Right};\nFind Again = {F3} {Right};\nFind Again 1..20 Times = {F3_$1} {Right};\n\nFind Symbol = {Ctrl+r};\n\n(Set | Add | Clear | Hide | Delete) Bookmark = {Ctrl+Alt+F2};\n(Next = 'F2' | Last = 'Shift+F2') Bookmark = {$1};\n\nNext Window = {Ctrl+Tab};\nLast Window = {Ctrl+Shift+Tab};\n\n\n# --- Editing commands ----------------------------------------\nSelect Line = {Ctrl+l};\nSelect (Next = 'Down' | Forward = 'Down' | Last = 'Up' | Back = 'Up' | Previous = 'Up') 1..20 Lines = {Home} {Shift+$1_$2};\nGrab 1..20 Lines = {Home} {Shift+Down_$1};\nAdd 1..20 (Lines = 'Down' | Line = 'Down' | Pages = 'PgDn' | Page = 'PgDn') = {Shift+$2_$1};\n\n(Join = 'j' | Indent = ']' | Dedent = '[') That = {Ctrl+$1};\nMove Line (Up | Down) 1..20 = {Ctrl+$1_$2};\n\n\n\nDelete Word = {Ctrl+Del};\nDelete 1..20 Words = {Ctrl+Del_$1};\nDelete (Back | Last) Word = {Ctrl+Backspace};\nDelete (Back | Last) 1..20 Words = {Ctrl+Backspace_$2};\nDelete Enda Word = {End} {Ctrl+Backspace};\n\n(Delete Line | Dede) = {Ctrl+Shift+k};\nDelete 1..20 Lines = {Ctrl+Shift+k_$1};\n(Cut = 'x' | Paste = 'v' | Copy = 'c') That = {Ctrl+$1};\n\nComment (That | Line) = {Ctrl+\/};\nComment 1..20 Lines = {Home} {Shift+Down_$1} {Ctrl+\/};\n\nSelect between (Delimiters | Brackets | Tags) ={Ctrl+m} {Ctrl+Alt+m};\n\nDelete Tags = {Ctrl+Alt+F4};\n\nReplace = {Ctrl+f};\nReplace All = {Ctrl+Enter};\n\n\n\n\n# --- Code commands -------------------------------------------\nStart (Item = 'li' | List = 'ul' | HTML = 'html' | pre = \"pre\"\n\t| div = 'div' | 'Comment' = 'comment-html'\n\t| 'Bold ID' = 'bold-id' | 'Input' = 'ds-input-text'\n\t| 'Fix Line' = 'fix-current-line' | 'Fix Current Line' = 'fix-current-line'\n\t| Snippet = 'my-snippet' | 'Recipe Row' = 'recipe-row' | 'Recipe Play' = 'recipe-play') = $1 {Tab};\nStop (Comment = 'comment-html-end' ) = $1 {Tab};\nStart (para = '<p>' ) = $1;\nAdd (para = 'p') = '<' $1 '>' {End} '<\/' $1 '>';\nReplace With (para = 'p') = {Ctrl+Alt+F4} '<' $1 '>' {End} '<\/' $1 '>';\n\nStart (Header | Heading) 1..7 = h $2 {Tab};\nAdd (Header | Heading) 1..7 = '<h' $2 '>' {End} '<\/h' $2 '>';\nReplace With (Header | Heading) 1..7 = {Ctrl+Alt+F4} '<h' $2 '>' {End} '<\/h' $2 '>' {Home};\nMid HREF = '\">';\n\nPaste Function = 'function ' {Ctrl+v} ' {' {Enter} {Enter} '};' {Up};\n\nPre-Format Code = {Ctrl+Alt+F5};\n\n# TO ADD:\n# adding HTML comments, using a snippet\n\n\n\n","old_contents":"# Voice commands for atom\n\ninclude folders.vch;\ninclude letters.vch;\n\nGo Strawberry = {Ctrl+Alt+F8};\nGo Blueberry ={Ctrl+Alt+o};\nGo Banana = {Ctrl+Alt+F7};\n\n\n# Commands for developing Atom: init.config, packages; also for navigating existing packages\/commands\nReload Atom = {Ctrl+s} Wait(100) {Shift+Ctrl+Alt+F5};\nCommand Palette = {Ctrl+Shift+p};\nKeyboard Shortcuts = {Ctrl+.};\nRun Specs = {Ctrl+Alt+p};\nShow Console = {Ctrl+Alt+i};\n\n# Commands for developing D3: D3 visualizations, D3 Sandwiches\nSave and Reload = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Ctrl+r};\t\nSave and Really Reload = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Ctrl+Shift+r};\n\n# File commands\nFind (File | Document) = {Ctrl+t};\nSave As = {Ctrl+Shift+s};\n\n\n# --- Navigation commands ------------------------------------\n<delimiters> := (Quote = '\"' | 'Single Quote' = \"'\" | Comma = ',' | 'Equal Sign' = '=' | Equals = '=' \n\t| Period = '.' | Colon = ':' | 'Semi-Colon' = ';' | Hyphen = '-' | Underscore = '_' | Slash = '\/'\n\t| Paren = \"(\" | \"Close Paren\" = \")\" | Parentheses = \"(\" | \"Close Parentheses\" = \")\"\n\t| Bracket = '[' | \"Close Bracket\" = ']' | Brace = '{' | 'Close Brace' = '}'\t);\n\nLine 1..200 = {Ctrl+g} $1 {Enter};\n(Left = 'b' | Right = 'f') Word = {Alt+$1};\nTop = {Ctrl+Home};\nBottom = {Ctrl+End};\n(Find = 'Right' | 'Insert After' = 'Right' | 'Insert Before' = 'Left') (Next = 'Enter' | Last = 'Shift+F3') <delimiters> \n\t\t= {Ctrl+f} $3 {$2} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') <delimiters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') 1..20 <delimiters> = {Ctrl+f} $3 {Enter} {Esc} Wait(100) {F3_$2} {Shift+F3} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') Enda <delimiters> = {End} {Ctrl+f} $2 {Enter} {Esc} {Shift+F3} Wait(100) {$1};\n\nFine Alpha <letters> = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Left};\nInsert (Before = 'Left' | After = 'Right') Alpha <letters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nFine Number 0..9 = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Right};\nFind Again = {F3} {Right};\nFind Again 1..20 Times = {F3_$1} {Right};\n\nFind Symbol = {Ctrl+r};\n\n(Set | Add | Clear | Hide | Delete) Bookmark = {Ctrl+Alt+F2};\n(Next = 'F2' | Last = 'Shift+F2') Bookmark = {$1};\n\nNext Window = {Ctrl+Tab};\nLast Window = {Ctrl+Shift+Tab};\n\n\n# --- Editing commands ----------------------------------------\nSelect Line = {Ctrl+l};\nSelect (Next = 'Down' | Forward = 'Down' | Last = 'Up' | Back = 'Up' | Previous = 'Up') 1..20 Lines = {Home} {Shift+$1_$2};\nGrab 1..20 Lines = {Home} {Shift+Down_$1};\nAdd 1..20 (Lines = 'Down' | Line = 'Down' | Pages = 'PgDn' | Page = 'PgDn') = {Shift+$2_$1};\n\n(Join = 'j' | Indent = ']' | Dedent = '[') That = {Ctrl+$1};\nMove Line (Up | Down) 1..20 = {Ctrl+$1_$2};\n\n\n\nDelete Word = {Ctrl+Del};\nDelete 1..20 Words = {Ctrl+Del_$1};\nDelete (Back | Last) Word = {Ctrl+Backspace};\nDelete (Back | Last) 1..20 Words = {Ctrl+Backspace_$2};\nDelete Enda Word = {End} {Ctrl+Backspace};\n\n(Delete Line | Dede) = {Ctrl+Shift+k};\nDelete 1..20 Lines = {Ctrl+Shift+k_$1};\n(Cut = 'x' | Paste = 'v' | Copy = 'c') That = {Ctrl+$1};\n\nComment (That | Line) = {Ctrl+\/};\nComment 1..20 Lines = {Home} {Shift+Down_$1} {Ctrl+\/};\n\nSelect between (Delimiters | Brackets | Tags) ={Ctrl+m} {Ctrl+Alt+m};\n\nDelete Tags = {Ctrl+Alt+F4};\n\nReplace = {Ctrl+f};\nReplace All = {Ctrl+Enter};\n\n\n\n\n# --- Code commands -------------------------------------------\nStart (Item = 'li' | List = 'ul' | HTML = 'html' | pre = \"pre\"\n\t| div = 'div' | 'Comment' = 'comment-html'\n\t| 'Bold ID' = 'bold-id' | 'Input' = 'ds-input-text'\n\t| 'Fix Line' = 'fix-current-line' | 'Fix Current Line' = 'fix-current-line'\n\t| Snippet = 'my-snippet' | 'Recipe Row' = 'recipe-row' | 'Recipe Play' = 'recipe-play') = $1 {Tab};\nStop (Comment = 'comment-html-end' ) = $1 {Tab};\nStart (para = '<p>' ) = $1;\nAdd (para = 'p') = '<' $1 '>' {End} '<\/' $1 '>';\nReplace With (para = 'p') = {Ctrl+Alt+F4} '<' $1 '>' {End} '<\/' $1 '>';\n\nStart (Header | Heading) 1..7 = h $2 {Tab};\nAdd (Header | Heading) 1..7 = '<h' $2 '>' {End} '<\/h' $2 '>';\nReplace With (Header | Heading) 1..7 = {Ctrl+Alt+F4} '<h' $2 '>' {End} '<\/h' $2 '>' {Home};\nMid HREF = '\">';\n\nPaste Function = 'function ' {Ctrl+v} ' {' {Enter} {Enter} '};' {Up};\n\nPre-Format Code = {Ctrl+Alt+F5};\n\n# TO ADD:\n# adding HTML comments, using a snippet\n\n\n\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"49a95fe4df0824341a41c6e34c78679aba052000","subject":"Don't pass static objects that have \/checkout in their URL","message":"Don't pass static objects that have \/checkout in their URL\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/fastly.vcl","new_file":"etc\/fastly.vcl","new_contents":"###############################################################################\n#\n# Fastly CDN for Magento 2\n#\n# NOTICE OF LICENSE\n#\n# This source file is subject to the Fastly CDN for Magento 2 End User License\n# Agreement that is bundled with this package in the file LICENSE_FASTLY_CDN.txt.\n#\n# @copyright Copyright (c) 2016 Fastly, Inc. (http:\/\/www.fastly.com)\n# @license BSD, see LICENSE_FASTLY_CDN.txt\n#\n###############################################################################\n\n# This is a basic VCL configuration file for Fastly CDN for Magento 2 module.\n\nsub vcl_recv {\n#FASTLY recv\n\n if (req.url ~ \"^\/static\/version(\\d*\/)?(.*)$\") {\n set req.url = \"\/static\/\" + re.group.2 + \"?\" + re.group.1;\n } \n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n set req.http.X-Sig = regsub(req.http.X-Purge-Token, \"^[^_]+_(.*)\", \"\\1\");\n set req.http.X-Exp = regsub(req.http.X-Purge-Token, \"^([^_]+)_.*\", \"\\1\");\n\n # validate signature\n if (req.http.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path req.http.X-Exp), \"^0x\", \"\")) {\n\n # use vcl time math to check expiration timestamp\n set req.http.X-Original-Grace = req.grace;\n set req.grace = std.atoi(strftime({\"%s\"}, now));\n set req.grace -= std.atoi(req.http.X-Exp);\n\n if (std.atoi(req.grace) > 0) {\n error 410;\n }\n\n # clean up grace since we used it for time math\n set req.grace = std.atoi(req.http.X-Original-Grace);\n unset req.http.X-Original-Grace;\n\n } else {\n error 403;\n }\n\n # cleanup variables\n unset req.http.X-Purge-Token;\n unset req.http.X-Sig;\n unset req.http.X-Exp;\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n # disable ESI processing on Origin Shield\n if (req.http.Fastly-FF) {\n set req.esi = false;\n }\n\n # We only deal with GET and HEAD by default\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n return (pass);\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n return (lookup);\n }\n\n # Bypass shopping cart and checkout requests\n if (req.url ~ \"\/checkout\") {\n return (pass);\n }\n\n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie ~ \"(X-Magento-Vary|form_key)=\") {\n error 200 \"\";\n } else {\n # append parameter with country code\n set req.url = req.url \"?country_code=\" geoip.country_code;\n }\n }\n\n return(lookup);\n}\n\nsub vcl_fetch {\n\n # Remove Set-Cookies from responses for static content\n # to match the cookie removal in recv.\n if (req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n }\n\n }\n\n#FASTLY fetch\n\n if (beresp.status >= 500) {\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n }\n\n if (req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Content-Type ~ \"text\/html\" || beresp.http.Content-Type ~ \"text\/xml\") {\n # enable ESI feature for Magento response by default\n esi;\n } else {\n # enable gzip for all static content\n if ((beresp.status == 200 || beresp.status == 404) && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url ~ \"\\.(css|js|html|eot|ico|otf|ttf|json)($|\\?)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # cache only successfully responses and 404s\n if (beresp.status != 200 && beresp.status != 301 && beresp.status != 404) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\")) {\n unset beresp.http.set-cookie;\n if (req.url !~ \"^\/(pub\/)?(media|static)\/.*\") {\n set beresp.http.Pragma = \"no-cache\";\n set beresp.http.Expires = \"-1\";\n set beresp.http.Cache-Control = \"no-store, no-cache, must-revalidate, max-age=0\";\n set beresp.grace = 1m;\n }\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type\n if (beresp.http.Content-Type ~ \"image\") {\n set beresp.http.Surrogate-Key = \"image\";\n } elsif (beresp.http.Content-Type ~ \"script\") {\n set beresp.http.Surrogate-Key = \"script\";\n } elsif (beresp.http.Content-Type ~ \"css\") {\n set beresp.http.Surrogate-Key = \"css\";\n }\n\n set beresp.http.X-Surrogate-Key = beresp.http.Surrogate-Key;\n return (deliver);\n }\n\n return (deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\n\nsub vcl_miss {\n # Deactivate gzip on origin\n unset bereq.http.Accept-Encoding;\n\n#FASTLY miss\n\n return(fetch);\n}\n\nsub vcl_deliver {\n # debug info\n if (resp.http.X-Magento-Debug) {\n if (obj.hits > 0) {\n set resp.http.X-Magento-Cache-Debug = \"HIT\";\n set resp.http.X-Magento-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Magento-Cache-Debug = \"MISS\";\n }\n } else {\n # remove Varnish\/proxy header\n remove resp.http.Age;\n remove resp.http.X-Magento-Debug;\n remove resp.http.X-Magento-Tags;\n remove resp.http.X-Surrogate-Key;\n remove resp.http.X-Magento-Cache-Control;\n remove resp.http.X-Powered-By;\n remove resp.http.Server;\n remove resp.http.X-Varnish;\n remove resp.http.Via;\n remove resp.http.Link;\n remove resp.http.X-Purge-URL;\n remove resp.http.X-Purge-Host;\n }\n\n#FASTLY deliver\n\n return (deliver);\n}\n\n\nsub vcl_error {\n # workaround for possible security issue\n if (req.url ~ \"^\\s\") {\n set obj.status = 400;\n set obj.response = \"Malformed request\";\n synthetic \"\";\n return (deliver);\n }\n\n # error 200\n if (obj.status == 200) {\n return (deliver);\n }\n\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} obj.status \" \" obj.response {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} obj.status \" \" obj.response {\"<\/h1>\n <p>\"} obj.response {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} req.xid {\"<\/p>\n <hr>\n <p>Fastly CDN server<\/p>\n <\/body>\n<\/html>\n\"};\n\n#FASTLY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n\nsub vcl_hash {\n set req.hash += req.http.Https;\n set req.hash += req.http.host;\n set req.hash += req.url;\n\n if (req.http.cookie:X-Magento-Vary ) {\n set req.hash += req.http.cookie:X-Magento-Vary;\n }\n \n set req.hash += \"#####GENERATION#####\";\n\n ### {{ design_exceptions_code }} ###\n\n return (hash);\n}\n\n","old_contents":"###############################################################################\n#\n# Fastly CDN for Magento 2\n#\n# NOTICE OF LICENSE\n#\n# This source file is subject to the Fastly CDN for Magento 2 End User License\n# Agreement that is bundled with this package in the file LICENSE_FASTLY_CDN.txt.\n#\n# @copyright Copyright (c) 2016 Fastly, Inc. (http:\/\/www.fastly.com)\n# @license BSD, see LICENSE_FASTLY_CDN.txt\n#\n###############################################################################\n\n# This is a basic VCL configuration file for Fastly CDN for Magento 2 module.\n\nsub vcl_recv {\n#FASTLY recv\n\n if (req.url ~ \"^\/static\/version(\\d*\/)?(.*)$\") {\n set req.url = \"\/static\/\" + re.group.2 + \"?\" + re.group.1;\n } \n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n set req.http.X-Sig = regsub(req.http.X-Purge-Token, \"^[^_]+_(.*)\", \"\\1\");\n set req.http.X-Exp = regsub(req.http.X-Purge-Token, \"^([^_]+)_.*\", \"\\1\");\n\n # validate signature\n if (req.http.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path req.http.X-Exp), \"^0x\", \"\")) {\n\n # use vcl time math to check expiration timestamp\n set req.http.X-Original-Grace = req.grace;\n set req.grace = std.atoi(strftime({\"%s\"}, now));\n set req.grace -= std.atoi(req.http.X-Exp);\n\n if (std.atoi(req.grace) > 0) {\n error 410;\n }\n\n # clean up grace since we used it for time math\n set req.grace = std.atoi(req.http.X-Original-Grace);\n unset req.http.X-Original-Grace;\n\n } else {\n error 403;\n }\n\n # cleanup variables\n unset req.http.X-Purge-Token;\n unset req.http.X-Sig;\n unset req.http.X-Exp;\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n # disable ESI processing on Origin Shield\n if (req.http.Fastly-FF) {\n set req.esi = false;\n }\n\n # We only deal with GET and HEAD by default\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n return (pass);\n }\n\n # Bypass shopping cart and checkout requests\n if (req.url ~ \"\/checkout\") {\n return (pass);\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie ~ \"(X-Magento-Vary|form_key)=\") {\n error 200 \"\";\n } else {\n # append parameter with country code\n set req.url = req.url \"?country_code=\" geoip.country_code;\n }\n }\n\n return(lookup);\n}\n\nsub vcl_fetch {\n\n # Remove Set-Cookies from responses for static content\n # to match the cookie removal in recv.\n if (req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n }\n\n }\n\n#FASTLY fetch\n\n if (beresp.status >= 500) {\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n }\n\n if (req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Content-Type ~ \"text\/html\" || beresp.http.Content-Type ~ \"text\/xml\") {\n # enable ESI feature for Magento response by default\n esi;\n } else {\n # enable gzip for all static content\n if ((beresp.status == 200 || beresp.status == 404) && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url ~ \"\\.(css|js|html|eot|ico|otf|ttf|json)($|\\?)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # cache only successfully responses and 404s\n if (beresp.status != 200 && beresp.status != 301 && beresp.status != 404) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\")) {\n unset beresp.http.set-cookie;\n if (req.url !~ \"^\/(pub\/)?(media|static)\/.*\") {\n set beresp.http.Pragma = \"no-cache\";\n set beresp.http.Expires = \"-1\";\n set beresp.http.Cache-Control = \"no-store, no-cache, must-revalidate, max-age=0\";\n set beresp.grace = 1m;\n }\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type\n if (beresp.http.Content-Type ~ \"image\") {\n set beresp.http.Surrogate-Key = \"image\";\n } elsif (beresp.http.Content-Type ~ \"script\") {\n set beresp.http.Surrogate-Key = \"script\";\n } elsif (beresp.http.Content-Type ~ \"css\") {\n set beresp.http.Surrogate-Key = \"css\";\n }\n\n set beresp.http.X-Surrogate-Key = beresp.http.Surrogate-Key;\n return (deliver);\n }\n\n return (deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\n\nsub vcl_miss {\n # Deactivate gzip on origin\n unset bereq.http.Accept-Encoding;\n\n#FASTLY miss\n\n return(fetch);\n}\n\nsub vcl_deliver {\n # debug info\n if (resp.http.X-Magento-Debug) {\n if (obj.hits > 0) {\n set resp.http.X-Magento-Cache-Debug = \"HIT\";\n set resp.http.X-Magento-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Magento-Cache-Debug = \"MISS\";\n }\n } else {\n # remove Varnish\/proxy header\n remove resp.http.Age;\n remove resp.http.X-Magento-Debug;\n remove resp.http.X-Magento-Tags;\n remove resp.http.X-Surrogate-Key;\n remove resp.http.X-Magento-Cache-Control;\n remove resp.http.X-Powered-By;\n remove resp.http.Server;\n remove resp.http.X-Varnish;\n remove resp.http.Via;\n remove resp.http.Link;\n remove resp.http.X-Purge-URL;\n remove resp.http.X-Purge-Host;\n }\n\n#FASTLY deliver\n\n return (deliver);\n}\n\n\nsub vcl_error {\n # workaround for possible security issue\n if (req.url ~ \"^\\s\") {\n set obj.status = 400;\n set obj.response = \"Malformed request\";\n synthetic \"\";\n return (deliver);\n }\n\n # error 200\n if (obj.status == 200) {\n return (deliver);\n }\n\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} obj.status \" \" obj.response {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} obj.status \" \" obj.response {\"<\/h1>\n <p>\"} obj.response {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} req.xid {\"<\/p>\n <hr>\n <p>Fastly CDN server<\/p>\n <\/body>\n<\/html>\n\"};\n\n#FASTLY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n\nsub vcl_hash {\n set req.hash += req.http.Https;\n set req.hash += req.http.host;\n set req.hash += req.url;\n\n if (req.http.cookie:X-Magento-Vary ) {\n set req.hash += req.http.cookie:X-Magento-Vary;\n }\n \n set req.hash += \"#####GENERATION#####\";\n\n ### {{ design_exceptions_code }} ###\n\n return (hash);\n}\n\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"775e1fde1ab0175f6028c3d86d904c9ce05c7d48","subject":"Added commands for Ultisnips","message":"Added commands for Ultisnips\n","repos":"aschneiderman\/vim-voice","old_file":"gvim.vcl","new_file":"gvim.vcl","new_contents":"# Voice commands for gvim (test)\n\ninclude folders.vch;\ninclude numbers.vch;\ninclude pandas.vch;\n<letters> := (alpha = a | bravo = b | Charlie = c | Delta = d | echo = e | foxtrot = f | golf = g | hotel = h \n\t| India = i | Juliet = j | kilo = k | Lima = l | Mike = m | November = n | Oscar = o | Poppa = p \n\t| Qubec = q | Romeo = r | Sierra = s | tango = t three spaces | uniform = u | Victor = v | whiskey = w \n\t| 'x-ray' = x | Yankee = y | Zulu = z);\n<delimiters> := (Quotes = '\"' | 'Single Quotes' = \"'\" | 'Double Quotes' = '\"' | Parentheses = '(' \n\t\t| Brackets = '[' | 'Curly Braces' = '{' | Braces = '{' );\n\n\n# --- File Management ---------------\nOpen Document = {Alt+f} o;\nList Files = {Esc} ':bro ol' {Enter};\nFile <numbers> = $1 {Enter};\nProject <folder> = {Esc} ':e ' $1 {Enter} Wait(100) {Down_9};\nProject Current = {Esc} ':e .' {Enter} Wait(100) {Down_9};\nGet (\t 'Home Folders' = 'C:\\Users\\Anders\\Documents\\Voice\\folders.vch' \n\t) = {Esc}':e ' $1 {Enter} Wait(100) {Down_9};\nShow (Projects | Folders) = {Esc}':e C:\\Users\\Anders\\Documents\\Voice\\folders.vch' {Enter} Wait(100) {Down_9};\nEdit [My] Configuration = ':e $' 'MYVIMRC' {Enter};\nUp Directory = '-';\nSearch [Directory] <letters> = '\/^' $1;\n\t\t\t# :Sex = directory of current file (:Vex for vertical split)\n\t\t\t# :sp. = Split horizontally on current directory (:vsp. For vertical)\n\t\t\t# % = new file\n\nSave Document = {Esc} Wait(100) ':w' {Enter};\nSave As = {Alt+f} a;\nGo (Quit = 'quit' | Close = 'close' | 'Close without saving' = 'close!' | Set = 'set') = ':' $1 {Enter};\n[Go] Quit without Saving = {Esc} Wait(100) ':quit!' {Enter};\n\n\n# --- Basic Navigation ---------------\n<numbers> (Up = 'k' | Down = 'j' | Right = 'l' | Left = 'h') = $1 $2;\nHoma = {Esc} 0;\nEnda = {Esc} '$';\n(Move Forward | Go | Go Forward) <numbers> words = $2 'w';\n(Move Forward | Go | Go Forward) <numbers> (end | enda) words = $2 'e';\n(Move Back | Go | Go Back) <numbers> words = $2 'b';\n(Move Forward | Go | Go Forward) <numbers> (sections | parentheses) = $2 '%';\nFine Text <letters> = {Esc} f $1;\nFind Back <letters> = {Esc} F $1;\nLine <numbers> = ':' $1 {Enter};\n\t\t\t# Commands to add: bottom, top\n\n\n# --- Basic Editing ---------------\n(Do | Go) Insert = i;\n(Do | Go) Escape = {Esc};\nGo Append = A;\nNexta = {Esc} A {Enter};\n\t\t\t# commands for changing\n\n(Do Again | Repeat That) = '.';\n(Undo | Undo That) = {Esc} u;\nRedo = {Esc} {Ctrl+r};\n\n(Kill = 'x') <numbers> = $2 $1;\n(Kill | Delete) Word = 'dw';\n(Kill | Delete) <numbers> Words = 'd' $2 'w';\nDee Dee = 'dd';\nCut to End of Line = 'd$';\nCut to End of Word = 'de';\nDelete Between <delimiters> = {Esc} Wait(100) '\/' $1 {Enter} Wait(100) ci $1;\n\nPaste That = {Alt+e} p;\nSelect All = {Alt+e} s {Enter};\nGrab Everything = {Alt+e} s {Enter} Wait(100) {Alt+e} c {Enter} Wait(100) {Alt+Tab};\n\n\n\n\n\n(Do | Edit) Ultisnips = {Esc} ':UltiSnipsEdit' {Enter};\nNew Snippet = {Esc} A {Enter}{Enter} 'endsnippet' {Up} 'snippet ';\n(Next='j' | Last='k') Stop = {Ctrl+$1};\n\n(D3 = 'd3_template' | Code = 'D3_code_wrapper') Snippet = {Esc} i $1 {Tab};\n\n\n# ---Things to do\n# delete several lines\n# change the configuration file","old_contents":"# Voice commands for gvim (test)\n\ninclude folders.vch;\ninclude numbers.vch;\ninclude pandas.vch;\n<letters> := (alpha = a | bravo = b | Charlie = c | Delta = d | echo = e | foxtrot = f | golf = g | hotel = h \n\t| India = i | Juliet = j | kilo = k | Lima = l | Mike = m | November = n | Oscar = o | Poppa = p \n\t| Qubec = q | Romeo = r | Sierra = s | tango = t three spaces | uniform = u | Victor = v | whiskey = w \n\t| 'x-ray' = x | Yankee = y | Zulu = z);\n<delimiters> := (Quotes = '\"' | 'Single Quotes' = \"'\" | 'Double Quotes' = '\"' | Parentheses = '(' \n\t\t| Brackets = '[' | 'Curly Braces' = '{' | Braces = '{' );\n\n\n# --- File Management ---------------\nOpen Document = {Alt+f} o;\nList Files = {Esc} ':bro ol' {Enter};\nFile <numbers> = $1 {Enter};\nProject <folder> = {Esc} ':e ' $1 {Enter} Wait(100) {Down_9};\nProject Current = {Esc} ':e .' {Enter} Wait(100) {Down_9};\nGet (\t 'Home Folders' = 'C:\\Users\\Anders\\Documents\\Voice\\folders.vch' \n\t) = {Esc}':e ' $1 {Enter} Wait(100) {Down_9};\nShow (Projects | Folders) = {Esc}':e C:\\Users\\Anders\\Documents\\Voice\\folders.vch' {Enter} Wait(100) {Down_9};\nEdit [My] Configuration = ':e $' 'MYVIMRC' {Enter};\nUp Directory = '-';\nSearch [Directory] <letters> = '\/^' $1;\n\t\t\t# :Sex = directory of current file (:Vex for vertical split)\n\t\t\t# :sp. = Split horizontally on current directory (:vsp. For vertical)\n\t\t\t# % = new file\n\nSave Document = {Esc} Wait(100) ':w' {Enter};\nSave As = {Alt+f} a;\nGo (Quit = 'quit' | Close = 'close' | 'Close without saving' = 'close!' | Set = 'set') = ':' $1 {Enter};\n[Go] Quit without Saving = {Esc} Wait(100) ':quit!' {Enter};\n\n\n# --- Basic Navigation ---------------\n<numbers> (Up = 'k' | Down = 'j' | Right = 'l' | Left = 'h') = $1 $2;\nHoma = {Esc} 0;\nEnda = {Esc} '$';\n(Move Forward | Go | Go Forward) <numbers> words = $2 'w';\n(Move Forward | Go | Go Forward) <numbers> (end | enda) words = $2 'e';\n(Move Back | Go | Go Back) <numbers> words = $2 'b';\n(Move Forward | Go | Go Forward) <numbers> (sections | parentheses) = $2 '%';\nFine Text <letters> = {Esc} f $1;\nFind Back <letters> = {Esc} F $1;\nLine <numbers> = ':' $1 {Enter};\n\t\t\t# Commands to add: bottom, top\n\n\n# --- Basic Editing ---------------\n(Do | Go) Insert = i;\n(Do | Go) Escape = {Esc};\nGo Append = A;\nNexta = {Esc} A {Enter};\n\t\t\t# commands for changing\n\n(Do Again | Repeat That) = '.';\n(Undo | Undo That) = {Esc} u;\nRedo = {Esc} {Ctrl+r};\n\n(Kill = 'x') <numbers> = $2 $1;\n(Kill | Delete) Word = 'dw';\n(Kill | Delete) <numbers> Words = 'd' $2 'w';\nDee Dee = 'dd';\nCut to End of Line = 'd$';\nCut to End of Word = 'de';\nDelete Between <delimiters> = {Esc} Wait(100) '\/' $1 {Enter} Wait(100) ci $1;\n\nPaste That = {Alt+e} p;\nSelect All = {Alt+e} s {Enter};\nGrab Everything = {Alt+e} s {Enter} Wait(100) {Alt+e} c {Enter} Wait(100) {Alt+Tab};\n\n\n\n\n\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"a077da7c9561299a4727387785cbe8f3211d6722","subject":"Use pipe for chunked POST\/PUT requests.","message":"Use pipe for chunked POST\/PUT requests.\n\nWe don't know how to handle incoming chunked bodies currently, but the backend\nmight.\n","repos":"chrismoulton\/Varnish-Cache,feld\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,franciscovg\/Varnish-Cache,feld\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,zhoualbeart\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,mrhmouse\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,gquintard\/Varnish-Cache,zhoualbeart\/Varnish-Cache,gquintard\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,alarky\/varnish-cache-doc-ja,mrhmouse\/Varnish-Cache,varnish\/Varnish-Cache,gquintard\/Varnish-Cache,varnish\/Varnish-Cache,mrhmouse\/Varnish-Cache,zhoualbeart\/Varnish-Cache,chrismoulton\/Varnish-Cache,varnish\/Varnish-Cache,franciscovg\/Varnish-Cache,chrismoulton\/Varnish-Cache,alarky\/varnish-cache-doc-ja,franciscovg\/Varnish-Cache,feld\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,alarky\/varnish-cache-doc-ja,alarky\/varnish-cache-doc-ja,zhoualbeart\/Varnish-Cache,chrismoulton\/Varnish-Cache,mrhmouse\/Varnish-Cache,zhoualbeart\/Varnish-Cache,varnish\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,gquintard\/Varnish-Cache,varnish\/Varnish-Cache,alarky\/varnish-cache-doc-ja,feld\/Varnish-Cache,mrhmouse\/Varnish-Cache,franciscovg\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,franciscovg\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,chrismoulton\/Varnish-Cache,feld\/Varnish-Cache","old_file":"bin\/varnishd\/builtin.vcl","new_file":"bin\/varnishd\/builtin.vcl","new_contents":"\/*-\n * Copyright (c) 2006 Verdens Gang AS\n * Copyright (c) 2006-2014 Varnish Software AS\n * All rights reserved.\n *\n * Author: Poul-Henning Kamp <phk@phk.freebsd.dk>\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in the\n * documentation and\/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n\n *\n * The built-in (previously called default) VCL code.\n *\n * NB! You do NOT need to copy & paste all of these functions into your\n * own vcl code, if you do not provide a definition of one of these\n * functions, the compiler will automatically fall back to the default\n * code from this file.\n *\n * This code will be prefixed with a backend declaration built from the\n * -b argument.\n *\/\n\nvcl 4.0;\n\n#######################################################################\n# Client side\n\nsub vcl_recv {\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n \/* We don't support chunked uploads, except when piping. *\/\n if ((req.request == \"POST\" || req.request == \"PUT\") &&\n req.http.transfer-encoding ~ \"chunked\") {\n return(pipe);\n }\n\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization || req.http.Cookie) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n return (hash);\n}\n\nsub vcl_pipe {\n # By default Connection: close is set on all piped requests, to stop\n # connection reuse from sending future requests directly to the\n # (potentially) wrong backend. If you do want this to happen, you can undo\n # it here.\n # unset bereq.http.connection;\n return (pipe);\n}\n\nsub vcl_pass {\n return (fetch);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n return (lookup);\n}\n\nsub vcl_purge {\n return (synth(200, \"Purged\"));\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n \/\/ A pure unadultered hit, deliver it\n return (deliver);\n }\n if (obj.ttl + obj.grace > 0s) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n return (deliver);\n }\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\nsub vcl_miss {\n return (fetch);\n}\n\nsub vcl_deliver {\n return (deliver);\n}\n\n\/*\n * We can come here \"invisibly\" with the following errors: 413, 417 & 503\n *\/\nsub vcl_synth {\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n set resp.http.Retry-After = \"5\";\n synthetic( {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n return (deliver);\n}\n\n#######################################################################\n# Backend Fetch\n\nsub vcl_backend_fetch {\n return (fetch);\n}\n\nsub vcl_backend_response {\n if (beresp.ttl <= 0s ||\n beresp.http.Set-Cookie ||\n beresp.http.Surrogate-control ~ \"no-store\" ||\n (!beresp.http.Surrogate-Control &&\n beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n beresp.http.Vary == \"*\") {\n \/*\n * Mark as \"Hit-For-Pass\" for the next 2 minutes\n *\/\n set beresp.ttl = 120s;\n set beresp.uncacheable = true;\n }\n return (deliver);\n}\n\nsub vcl_backend_error {\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} + beresp.status + \" \" + beresp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + beresp.status + \" \" + beresp.reason + {\"<\/h1>\n <p>\"} + beresp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + bereq.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n return (deliver);\n}\n\n#######################################################################\n# Housekeeping\n\nsub vcl_init {\n return (ok);\n}\n\nsub vcl_fini {\n return (ok);\n}\n","old_contents":"\/*-\n * Copyright (c) 2006 Verdens Gang AS\n * Copyright (c) 2006-2014 Varnish Software AS\n * All rights reserved.\n *\n * Author: Poul-Henning Kamp <phk@phk.freebsd.dk>\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in the\n * documentation and\/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n\n *\n * The built-in (previously called default) VCL code.\n *\n * NB! You do NOT need to copy & paste all of these functions into your\n * own vcl code, if you do not provide a definition of one of these\n * functions, the compiler will automatically fall back to the default\n * code from this file.\n *\n * This code will be prefixed with a backend declaration built from the\n * -b argument.\n *\/\n\nvcl 4.0;\n\n#######################################################################\n# Client side\n\nsub vcl_recv {\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization || req.http.Cookie) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n return (hash);\n}\n\nsub vcl_pipe {\n # By default Connection: close is set on all piped requests, to stop\n # connection reuse from sending future requests directly to the\n # (potentially) wrong backend. If you do want this to happen, you can undo\n # it here.\n # unset bereq.http.connection;\n return (pipe);\n}\n\nsub vcl_pass {\n return (fetch);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n return (lookup);\n}\n\nsub vcl_purge {\n return (synth(200, \"Purged\"));\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n \/\/ A pure unadultered hit, deliver it\n return (deliver);\n }\n if (obj.ttl + obj.grace > 0s) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n return (deliver);\n }\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\nsub vcl_miss {\n return (fetch);\n}\n\nsub vcl_deliver {\n return (deliver);\n}\n\n\/*\n * We can come here \"invisibly\" with the following errors: 413, 417 & 503\n *\/\nsub vcl_synth {\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n set resp.http.Retry-After = \"5\";\n synthetic( {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n return (deliver);\n}\n\n#######################################################################\n# Backend Fetch\n\nsub vcl_backend_fetch {\n return (fetch);\n}\n\nsub vcl_backend_response {\n if (beresp.ttl <= 0s ||\n beresp.http.Set-Cookie ||\n beresp.http.Surrogate-control ~ \"no-store\" ||\n (!beresp.http.Surrogate-Control &&\n beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n beresp.http.Vary == \"*\") {\n \/*\n * Mark as \"Hit-For-Pass\" for the next 2 minutes\n *\/\n set beresp.ttl = 120s;\n set beresp.uncacheable = true;\n }\n return (deliver);\n}\n\nsub vcl_backend_error {\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} + beresp.status + \" \" + beresp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + beresp.status + \" \" + beresp.reason + {\"<\/h1>\n <p>\"} + beresp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + bereq.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n return (deliver);\n}\n\n#######################################################################\n# Housekeeping\n\nsub vcl_init {\n return (ok);\n}\n\nsub vcl_fini {\n return (ok);\n}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"18e048a2be5c924ed2a46b2fb9beb8d0777e69b5","subject":"Add varnish exception for blackfire","message":"Add varnish exception for blackfire\n","repos":"api-platform\/demo,api-platform\/demo,api-platform\/demo,api-platform\/demo","old_file":"api\/docker\/varnish\/conf\/default.vcl","new_file":"api\/docker\/varnish\/conf\/default.vcl","new_contents":"vcl 4.0;\n\nimport std;\n\nbackend default {\n .host = \"api\";\n .port = \"80\";\n # Health check\n #.probe = {\n # .url = \"\/\";\n # .timeout = 5s;\n # .interval = 10s;\n # .window = 5;\n # .threshold = 3;\n #}\n}\n\n# Hosts allowed to send BAN requests\nacl invalidators {\n \"localhost\";\n \"php\";\n # local Kubernetes network\n \"10.0.0.0\"\/8;\n \"172.16.0.0\"\/12;\n \"192.168.0.0\"\/16;\n}\n\nsub vcl_backend_response {\n # Ban lurker friendly header\n set beresp.http.url = bereq.url;\n\n # Add a grace in case the backend is down\n set beresp.grace = 1h;\n}\n\nsub vcl_recv {\n if (req.http.X-Blackfire-Query) {\n if (req.esi_level > 0) {\n # ESI request should not be included in the profile.\n # Instead you should profile them separately, each one\n # in their dedicated profile.\n # Removing the Blackfire header avoids to trigger the profiling.\n # Not returning let it go trough your usual workflow as a regular\n # ESI request without distinction.\n unset req.http.X-Blackfire-Query;\n } else {\n return (pass);\n }\n }\n}\n\nsub vcl_deliver {\n # Don't send cache tags related headers to the client\n unset resp.http.url;\n # Comment the following line to send the \"Cache-Tags\" header to the client (e.g. to use CloudFlare cache tags)\n unset resp.http.Cache-Tags;\n}\n\nsub vcl_recv {\n # Remove the \"Forwarded\" HTTP header if exists (security)\n unset req.http.forwarded;\n\n # To allow API Platform to ban by cache tags\n if (req.method == \"BAN\") {\n if (client.ip !~ invalidators) {\n return(synth(405, \"Not allowed\"));\n }\n\n if (req.http.ApiPlatform-Ban-Regex) {\n ban(\"obj.http.Cache-Tags ~ \" + req.http.ApiPlatform-Ban-Regex);\n\n return(synth(200, \"Ban added\"));\n }\n\n return(synth(400, \"ApiPlatform-Ban-Regex HTTP header must be set.\"));\n }\n\n # For health checks\n if (req.method == \"GET\" && req.url == \"\/healthz\") {\n return(synth(200, \"OK\"));\n }\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n # A pure unadulterated hit, deliver it\n return (deliver);\n }\n if (std.healthy(req.backend_hint)) {\n # The backend is healthy\n # Fetch the object from the backend\n return (miss);\n }\n # No fresh object and the backend is not healthy\n if (obj.ttl + obj.grace > 0s) {\n # Deliver graced object\n # Automatically triggers a background fetch\n return (deliver);\n }\n # No valid object to deliver\n # No healthy backend to handle request\n # Return error\n return (synth(503, \"API is down\"));\n}\n","old_contents":"vcl 4.0;\n\nimport std;\n\nbackend default {\n .host = \"api\";\n .port = \"80\";\n # Health check\n #.probe = {\n # .url = \"\/\";\n # .timeout = 5s;\n # .interval = 10s;\n # .window = 5;\n # .threshold = 3;\n #}\n}\n\n# Hosts allowed to send BAN requests\nacl invalidators {\n \"localhost\";\n \"php\";\n # local Kubernetes network\n \"10.0.0.0\"\/8;\n \"172.16.0.0\"\/12;\n \"192.168.0.0\"\/16;\n}\n\nsub vcl_backend_response {\n # Ban lurker friendly header\n set beresp.http.url = bereq.url;\n\n # Add a grace in case the backend is down\n set beresp.grace = 1h;\n}\n\nsub vcl_deliver {\n # Don't send cache tags related headers to the client\n unset resp.http.url;\n # Comment the following line to send the \"Cache-Tags\" header to the client (e.g. to use CloudFlare cache tags)\n unset resp.http.Cache-Tags;\n}\n\nsub vcl_recv {\n # Remove the \"Forwarded\" HTTP header if exists (security)\n unset req.http.forwarded;\n\n # To allow API Platform to ban by cache tags\n if (req.method == \"BAN\") {\n if (client.ip !~ invalidators) {\n return(synth(405, \"Not allowed\"));\n }\n\n if (req.http.ApiPlatform-Ban-Regex) {\n ban(\"obj.http.Cache-Tags ~ \" + req.http.ApiPlatform-Ban-Regex);\n\n return(synth(200, \"Ban added\"));\n }\n\n return(synth(400, \"ApiPlatform-Ban-Regex HTTP header must be set.\"));\n }\n\n # For health checks\n if (req.method == \"GET\" && req.url == \"\/healthz\") {\n return(synth(200, \"OK\"));\n }\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n # A pure unadulterated hit, deliver it\n return (deliver);\n }\n if (std.healthy(req.backend_hint)) {\n # The backend is healthy\n # Fetch the object from the backend\n return (miss);\n }\n # No fresh object and the backend is not healthy\n if (obj.ttl + obj.grace > 0s) {\n # Deliver graced object\n # Automatically triggers a background fetch\n return (deliver);\n }\n # No valid object to deliver\n # No healthy backend to handle request\n # Return error\n return (synth(503, \"API is down\"));\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"8eeb6328af4040ebb675c93d6868d3fbb86a1477","subject":"Changed elif to elsif.","message":"Changed elif to elsif.\n\nI am not a VCL expert but it seems like the 'elif' on line 45 should be 'elsif'.","repos":"wikp\/varnish-devicedetect,varnish\/varnish-devicedetect,kevinquinnyo\/varnish-devicedetect,wikp\/varnish-devicedetect,kevinquinnyo\/varnish-devicedetect,varnish\/varnish-devicedetect","old_file":"devicedetect.vcl","new_file":"devicedetect.vcl","new_contents":"# Copyright (c) 2012-2014 Varnish Software AS\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions\n# are met:\n# 1. Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n# 2. Redistributions in binary form must reproduce the above copyright\n# notice, this list of conditions and the following disclaimer in the\n# documentation and\/or other materials provided with the distribution.\n#\n# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n# ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n# SUCH DAMAGE.\n#\n# detectdevice.vcl - regex based device detection for Varnish\n# http:\/\/github.com\/varnish\/varnish-devicedetect\/\n#\n# Author: Lasse Karstensen <lkarsten@varnish-software.com>\n\nsub devicedetect {\n\tunset req.http.X-UA-Device;\n\tset req.http.X-UA-Device = \"pc\";\n\n\t# Handle that a cookie may override the detection alltogether.\n\tif (req.http.Cookie ~ \"(?i)X-UA-Device-force\") {\n\t\t\/* ;?? means zero or one ;, non-greedy to match the first. *\/\n\t\tset req.http.X-UA-Device = regsub(req.http.Cookie, \"(?i).*X-UA-Device-force=([^;]+);??.*\", \"\\1\");\n\t\t\/* Clean up our mess in the cookie header *\/\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|; ) *X-UA-Device-force=[^;]+;? *\", \"\\1\");\n\t\t\/* If the cookie header is now empty, or just whitespace, unset it. *\/\n\t\tif (req.http.Cookie ~ \"^ *$\") { unset req.http.Cookie; }\n\t} else {\n if (req.http.User-Agent ~ \"\\(compatible; Googlebot-Mobile\/2.1; \\+http:\/\/www.google.com\/bot.html\\)\" ||\n (req.http.User-Agent ~ \"iPhone\" && req.http.User-Agent ~ \"\\(compatible; Googlebot\/2.1; \\+http:\/\/www.google.com\/bot.html\")) {\n set req.http.X-UA-Device = \"mobile-bot\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)(ads|google|bing|msn|yandex|baidu|ro|career|)bot\" ||\n\t\t req.http.User-Agent ~ \"(?i)(baidu|jike|symantec)spider\" ||\n\t\t req.http.User-Agent ~ \"(?i)scanner\" ||\n\t\t req.http.User-Agent ~ \"(?i)(web)crawler\") {\n\t\t\tset req.http.X-UA-Device = \"bot\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ipad\") { set req.http.X-UA-Device = \"tablet-ipad\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ip(hone|od)\") { set req.http.X-UA-Device = \"mobile-iphone\"; }\n\t\t\/* how do we differ between an android phone and an android tablet?\n\t\t http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent *\/\n\t\telsif (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") { set req.http.X-UA-Device = \"mobile-android\"; }\n\t\t\/\/ android 3\/honeycomb was just about tablet-only, and any phones will probably handle a bigger page layout.\n\t\telsif (req.http.User-Agent ~ \"(?i)android 3\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\t\/* see http:\/\/my.opera.com\/community\/openweb\/idopera\/ *\/\n\t\telsif (req.http.User-Agent ~ \"Opera Mobi\") { set req.http.X-UA-Device = \"mobile-smartphone\"; }\n\t\t\/\/ May very well give false positives towards android tablets. Suggestions welcome.\n\t\telsif (req.http.User-Agent ~ \"(?i)android\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\telsif (req.http.User-Agent ~ \"PlayBook; U; RIM Tablet\") { set req.http.X-UA-Device = \"tablet-rim\"; }\n\t\telsif (req.http.User-Agent ~ \"hp-tablet.*TouchPad\") { set req.http.X-UA-Device = \"tablet-hp\"; }\n\t\telsif (req.http.User-Agent ~ \"Kindle\/3\") { set req.http.X-UA-Device = \"tablet-kindle\"; }\n\t\telsif (req.http.User-Agent ~ \"Touch.+Tablet PC\") { set req.http.X-UA-Device = \"tablet-microsoft\"; }\n\t\telsif (req.http.User-Agent ~ \"Mobile.+Firefox\") { set req.http.X-UA-Device = \"mobile-firefoxos\"; }\n\t\telsif (req.http.User-Agent ~ \"^HTC\" ||\n\t\t req.http.User-Agent ~ \"Fennec\" ||\n\t\t req.http.User-Agent ~ \"IEMobile\" ||\n\t\t req.http.User-Agent ~ \"BlackBerry\" ||\n\t\t req.http.User-Agent ~ \"BB10.*Mobile\" ||\n\t\t req.http.User-Agent ~ \"GT-.*Build\/GINGERBREAD\" ||\n\t\t req.http.User-Agent ~ \"SymbianOS.*AppleWebKit\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-smartphone\";\n\t\t}\n\t\telsif (req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)^sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)^nokia\" ||\n\t\t req.http.User-Agent ~ \"(?i)^samsung\" ||\n\t\t req.http.User-Agent ~ \"(?i)^lg\" ||\n\t\t req.http.User-Agent ~ \"(?i)bada\" ||\n\t\t req.http.User-Agent ~ \"(?i)blazer\" ||\n\t\t req.http.User-Agent ~ \"(?i)cellphone\" ||\n\t\t req.http.User-Agent ~ \"(?i)iemobile\" ||\n\t\t req.http.User-Agent ~ \"(?i)midp-2.0\" ||\n\t\t req.http.User-Agent ~ \"(?i)u990\" ||\n\t\t req.http.User-Agent ~ \"(?i)netfront\" ||\n\t\t req.http.User-Agent ~ \"(?i)opera mini\" ||\n\t\t req.http.User-Agent ~ \"(?i)palm\" ||\n\t\t req.http.User-Agent ~ \"(?i)nintendo wii\" ||\n\t\t req.http.User-Agent ~ \"(?i)playstation portable\" ||\n\t\t req.http.User-Agent ~ \"(?i)portalmmm\" ||\n\t\t req.http.User-Agent ~ \"(?i)proxinet\" ||\n\t\t req.http.User-Agent ~ \"(?i)sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)windows\\ ?ce\" ||\n\t\t req.http.User-Agent ~ \"(?i)winwap\" ||\n\t\t req.http.User-Agent ~ \"(?i)eudoraweb\" ||\n\t\t req.http.User-Agent ~ \"(?i)htc\" ||\n\t\t req.http.User-Agent ~ \"(?i)240x320\" ||\n\t\t req.http.User-Agent ~ \"(?i)avantgo\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-generic\";\n\t\t}\n\t}\n}\n","old_contents":"# Copyright (c) 2012-2014 Varnish Software AS\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions\n# are met:\n# 1. Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n# 2. Redistributions in binary form must reproduce the above copyright\n# notice, this list of conditions and the following disclaimer in the\n# documentation and\/or other materials provided with the distribution.\n#\n# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n# ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n# SUCH DAMAGE.\n#\n# detectdevice.vcl - regex based device detection for Varnish\n# http:\/\/github.com\/varnish\/varnish-devicedetect\/\n#\n# Author: Lasse Karstensen <lkarsten@varnish-software.com>\n\nsub devicedetect {\n\tunset req.http.X-UA-Device;\n\tset req.http.X-UA-Device = \"pc\";\n\n\t# Handle that a cookie may override the detection alltogether.\n\tif (req.http.Cookie ~ \"(?i)X-UA-Device-force\") {\n\t\t\/* ;?? means zero or one ;, non-greedy to match the first. *\/\n\t\tset req.http.X-UA-Device = regsub(req.http.Cookie, \"(?i).*X-UA-Device-force=([^;]+);??.*\", \"\\1\");\n\t\t\/* Clean up our mess in the cookie header *\/\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|; ) *X-UA-Device-force=[^;]+;? *\", \"\\1\");\n\t\t\/* If the cookie header is now empty, or just whitespace, unset it. *\/\n\t\tif (req.http.Cookie ~ \"^ *$\") { unset req.http.Cookie; }\n\t} else {\n if (req.http.User-Agent ~ \"\\(compatible; Googlebot-Mobile\/2.1; \\+http:\/\/www.google.com\/bot.html\\)\" ||\n (req.http.User-Agent ~ \"iPhone\" && req.http.User-Agent ~ \"\\(compatible; Googlebot\/2.1; \\+http:\/\/www.google.com\/bot.html\")) {\n set req.http.X-UA-Device = \"mobile-bot\"; }\n\t\telif (req.http.User-Agent ~ \"(?i)(ads|google|bing|msn|yandex|baidu|ro|career|)bot\" ||\n\t\t req.http.User-Agent ~ \"(?i)(baidu|jike|symantec)spider\" ||\n\t\t req.http.User-Agent ~ \"(?i)scanner\" ||\n\t\t req.http.User-Agent ~ \"(?i)(web)crawler\") {\n\t\t\tset req.http.X-UA-Device = \"bot\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ipad\") { set req.http.X-UA-Device = \"tablet-ipad\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ip(hone|od)\") { set req.http.X-UA-Device = \"mobile-iphone\"; }\n\t\t\/* how do we differ between an android phone and an android tablet?\n\t\t http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent *\/\n\t\telsif (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") { set req.http.X-UA-Device = \"mobile-android\"; }\n\t\t\/\/ android 3\/honeycomb was just about tablet-only, and any phones will probably handle a bigger page layout.\n\t\telsif (req.http.User-Agent ~ \"(?i)android 3\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\t\/* see http:\/\/my.opera.com\/community\/openweb\/idopera\/ *\/\n\t\telsif (req.http.User-Agent ~ \"Opera Mobi\") { set req.http.X-UA-Device = \"mobile-smartphone\"; }\n\t\t\/\/ May very well give false positives towards android tablets. Suggestions welcome.\n\t\telsif (req.http.User-Agent ~ \"(?i)android\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\telsif (req.http.User-Agent ~ \"PlayBook; U; RIM Tablet\") { set req.http.X-UA-Device = \"tablet-rim\"; }\n\t\telsif (req.http.User-Agent ~ \"hp-tablet.*TouchPad\") { set req.http.X-UA-Device = \"tablet-hp\"; }\n\t\telsif (req.http.User-Agent ~ \"Kindle\/3\") { set req.http.X-UA-Device = \"tablet-kindle\"; }\n\t\telsif (req.http.User-Agent ~ \"Touch.+Tablet PC\") { set req.http.X-UA-Device = \"tablet-microsoft\"; }\n\t\telsif (req.http.User-Agent ~ \"Mobile.+Firefox\") { set req.http.X-UA-Device = \"mobile-firefoxos\"; }\n\t\telsif (req.http.User-Agent ~ \"^HTC\" ||\n\t\t req.http.User-Agent ~ \"Fennec\" ||\n\t\t req.http.User-Agent ~ \"IEMobile\" ||\n\t\t req.http.User-Agent ~ \"BlackBerry\" ||\n\t\t req.http.User-Agent ~ \"BB10.*Mobile\" ||\n\t\t req.http.User-Agent ~ \"GT-.*Build\/GINGERBREAD\" ||\n\t\t req.http.User-Agent ~ \"SymbianOS.*AppleWebKit\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-smartphone\";\n\t\t}\n\t\telsif (req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)^sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)^nokia\" ||\n\t\t req.http.User-Agent ~ \"(?i)^samsung\" ||\n\t\t req.http.User-Agent ~ \"(?i)^lg\" ||\n\t\t req.http.User-Agent ~ \"(?i)bada\" ||\n\t\t req.http.User-Agent ~ \"(?i)blazer\" ||\n\t\t req.http.User-Agent ~ \"(?i)cellphone\" ||\n\t\t req.http.User-Agent ~ \"(?i)iemobile\" ||\n\t\t req.http.User-Agent ~ \"(?i)midp-2.0\" ||\n\t\t req.http.User-Agent ~ \"(?i)u990\" ||\n\t\t req.http.User-Agent ~ \"(?i)netfront\" ||\n\t\t req.http.User-Agent ~ \"(?i)opera mini\" ||\n\t\t req.http.User-Agent ~ \"(?i)palm\" ||\n\t\t req.http.User-Agent ~ \"(?i)nintendo wii\" ||\n\t\t req.http.User-Agent ~ \"(?i)playstation portable\" ||\n\t\t req.http.User-Agent ~ \"(?i)portalmmm\" ||\n\t\t req.http.User-Agent ~ \"(?i)proxinet\" ||\n\t\t req.http.User-Agent ~ \"(?i)sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)windows\\ ?ce\" ||\n\t\t req.http.User-Agent ~ \"(?i)winwap\" ||\n\t\t req.http.User-Agent ~ \"(?i)eudoraweb\" ||\n\t\t req.http.User-Agent ~ \"(?i)htc\" ||\n\t\t req.http.User-Agent ~ \"(?i)240x320\" ||\n\t\t req.http.User-Agent ~ \"(?i)avantgo\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-generic\";\n\t\t}\n\t}\n}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"d257398b09985f5191bf6064fcd9a5f81b2412f9","subject":"Set large minimum TTL for now","message":"Set large minimum TTL for now\n","repos":"trevorparker\/dockerfiles","old_file":"varnish\/default.vcl","new_file":"varnish\/default.vcl","new_contents":"backend default {\n .host = \"127.0.0.1\";\n .port = \"80\";\n}\n\nsub vcl_fetch {\n set obj.ttl = 12h;\n}\n\nsub vcl_recv {\n set req.http.Host = \"www.trevorparker.com\";\n if (req.http.X-Forwarded-Proto !~ \"(?i)https\") {\n set req.http.x-Redir-Url = \"https:\/\/www.trevorparker.com\" + req.url;\n error 750 req.http.x-Redir-Url;\n }\n}\n\nsub vcl_error {\n if (obj.status == 750) {\n set obj.http.Location = obj.response;\n set obj.status = 301;\n return(deliver);\n }\n}\n\n","old_contents":"backend default {\n .host = \"127.0.0.1\";\n .port = \"80\";\n}\n\nsub vcl_recv {\n set req.http.Host = \"www.trevorparker.com\";\n if (req.http.X-Forwarded-Proto !~ \"(?i)https\") {\n set req.http.x-Redir-Url = \"https:\/\/www.trevorparker.com\" + req.url;\n error 750 req.http.x-Redir-Url;\n }\n}\n\nsub vcl_error {\n if (obj.status == 750) {\n set obj.http.Location = obj.response;\n set obj.status = 301;\n return(deliver);\n }\n}\n\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"c642073f2946b547b0ae1d295fdca6ad744c27be","subject":"Remove fastly.vcl since it's deprecated","message":"Remove fastly.vcl since it's deprecated\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/fastly.vcl","new_file":"etc\/fastly.vcl","new_contents":"","old_contents":"###############################################################################\n#\n# Fastly CDN for Magento 2\n#\n# NOTICE OF LICENSE\n#\n# This source file is subject to the Fastly CDN for Magento 2 End User License\n# Agreement that is bundled with this package in the file LICENSE_FASTLY_CDN.txt.\n#\n# @copyright Copyright (c) 2016 Fastly, Inc. (http:\/\/www.fastly.com)\n# @license BSD, see LICENSE_FASTLY_CDN.txt\n#\n###############################################################################\n\n# This is a basic VCL configuration file for Fastly CDN for Magento 2 module.\n\nsub vcl_recv {\n#FASTLY recv\n\n # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n # Sort the query arguments\n set req.url = boltsort.sort(req.url);\n\n if (req.url ~ \"^\/static\/version(\\d*\/)?(.*)$\") {\n set req.url = \"\/static\/\" + re.group.2 + \"?\" + re.group.1;\n }\n \n # User's Cookie may contain some Magento Vary items we should vary on\n if (req.http.cookie:X-Magento-Vary ) {\n set req.http.X-Magento-Vary = req.http.cookie:X-Magento-Vary;\n } else {\n unset req.http.X-Magento-Vary;\n }\n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n set req.http.X-Sig = regsub(req.http.X-Purge-Token, \"^[^_]+_(.*)\", \"\\1\");\n set req.http.X-Exp = regsub(req.http.X-Purge-Token, \"^([^_]+)_.*\", \"\\1\");\n\n # validate signature\n if (req.http.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path req.http.X-Exp), \"^0x\", \"\")) {\n\n # use vcl time math to check expiration timestamp\n set req.http.X-Original-Grace = req.grace;\n set req.grace = std.atoi(strftime({\"%s\"}, now));\n set req.grace -= std.atoi(req.http.X-Exp);\n\n if (std.atoi(req.grace) > 0) {\n error 410;\n }\n\n # clean up grace since we used it for time math\n set req.grace = std.atoi(req.http.X-Original-Grace);\n unset req.http.X-Original-Grace;\n\n } else {\n error 403;\n }\n\n # cleanup variables\n unset req.http.X-Purge-Token;\n unset req.http.X-Sig;\n unset req.http.X-Exp;\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (req.http.Fastly-FF) {\n # disable ESI processing on Origin Shield\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # We only deal with GET and HEAD by default\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n return (pass);\n }\n \n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie ~ \"(X-Magento-Vary|form_key)=\") {\n error 200 \"\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url !~ \"country_code=\" ) {\n set req.url = req.url \"?country_code=\" if ( req.http.geo_override, req.http.geo_override, geoip.country_code);\n }\n }\n } else {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking\n set req.http.Magento-Original-URL = req.url;\n set req.url = querystring.regfilter(req.url, \"^(utm_.*|gclid|gdftrk|_ga|mc_.*)\");\n }\n \n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n return (lookup);\n }\n\n # Bypass shopping cart and checkout requests\n if (req.url ~ \"\/checkout\") {\n return (pass);\n }\n\n return(lookup);\n}\n\nsub vcl_fetch {\n\n \/* handle 5XX (or any other unwanted status code) *\/\n if (beresp.status >= 500 && beresp.status < 600) {\n\n \/* deliver stale if the object is available *\/\n if (stale.exists) {\n return(deliver_stale);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n \/* else go to vcl_error to deliver a synthetic *\/\n error 503;\n }\n\n # Remove Set-Cookies from responses for static content\n # to match the cookie removal in recv.\n if (req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n }\n\n }\n\n#FASTLY fetch\n\n if (beresp.status >= 500) {\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n }\n\n if (req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Content-Type ~ \"text\/(html|xml)\" ) {\n # enable ESI feature for Magento response by default\n esi;\n if (!beresp.http.Vary ~ \"X-Magento-Vary,Https\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \",X-Magento-Vary,Https\";\n } else {\n set beresp.http.Vary = \"X-Magento-Vary,Https\";\n }\n }\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content\n if ((beresp.status == 200 || beresp.status == 404) && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url ~ \"\\.(css|js|html|eot|ico|otf|ttf|json)($|\\?)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # cache only successfully responses and 404s\n if (beresp.status != 200 && beresp.status != 301 && beresp.status != 404) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\")) {\n unset beresp.http.set-cookie;\n if (req.url !~ \"^\/(pub\/)?(media|static)\/.*\") {\n set beresp.grace = 86400m;\n }\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type\n if (beresp.http.Content-Type ~ \"image\") {\n set beresp.http.Surrogate-Key = \"image\";\n } elsif (beresp.http.Content-Type ~ \"script\") {\n set beresp.http.Surrogate-Key = \"script\";\n } elsif (beresp.http.Content-Type ~ \"css\") {\n set beresp.http.Surrogate-Key = \"css\";\n }\n\n set beresp.http.X-Surrogate-Key = beresp.http.Surrogate-Key;\n return (deliver);\n }\n\n return (deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\n\nsub vcl_miss {\n # Deactivate gzip on origin\n unset bereq.http.Accept-Encoding;\n\n#FASTLY miss\n\n return(fetch);\n}\n\nsub vcl_deliver {\n\n if (resp.status >= 500 && resp.status < 600) {\n \/* restart if the stale object is available *\/\n if (stale.exists) {\n restart;\n }\n }\n\n # Send no cache headers to end users for non-static content. Also make sure\n # we only set this on the edge nodes and not on shields\n if (req.url !~ \"^\/(pub\/)?(media|static)\/.*\" && !req.http.Fastly-FF ) {\n set resp.http.Pragma = \"no-cache\";\n set resp.http.Cache-Control = \"no-store, no-cache, must-revalidate, max-age=0\";\n }\n\n # Remove X-Magento-Vary and HTTPs Vary served to the user\n if ( !req.http.Fastly-FF ) {\n set resp.http.Vary = regsub(resp.http.Vary, \"X-Magento-Vary,Https\", \"Cookie\");\n }\n\n # Add an easy way to see whether custom Fastly VCL has been uploaded\n if ( req.http.Fastly-Debug ) {\n set resp.http.Fastly-Magento-VCL-Uploaded = \"1.2.9-CUSTOMVCL-DEPRECATED\";\n } else {\n remove resp.http.Fastly-Module-Enabled;\n }\n # debug info\n if (resp.http.X-Magento-Debug) {\n if (obj.hits > 0) {\n set resp.http.X-Magento-Cache-Debug = \"HIT\";\n set resp.http.X-Magento-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Magento-Cache-Debug = \"MISS\";\n }\n } else {\n # remove Varnish\/proxy header\n remove resp.http.Age;\n remove resp.http.X-Magento-Debug;\n remove resp.http.X-Magento-Tags;\n remove resp.http.X-Surrogate-Key;\n remove resp.http.X-Magento-Cache-Control;\n remove resp.http.X-Powered-By;\n remove resp.http.Server;\n remove resp.http.X-Varnish;\n remove resp.http.Via;\n remove resp.http.Link;\n remove resp.http.X-Purge-URL;\n remove resp.http.X-Purge-Host;\n }\n\n#FASTLY deliver\n\n return (deliver);\n}\n\n\nsub vcl_error {\n # workaround for possible security issue\n if (req.url ~ \"^\\s\") {\n set obj.status = 400;\n set obj.response = \"Malformed request\";\n synthetic \"\";\n return (deliver);\n }\n\n \/* handle 503s *\/\n if (obj.status >= 500 && obj.status < 600) {\n\n \/* deliver stale object if it is available *\/\n if (stale.exists) {\n return(deliver_stale);\n }\n\n \/* otherwise, return a synthetic *\/\n \/* uncomment below and include your HTML response here *\/\n \/* synthetic {\"<!DOCTYPE html><html>Trouble connecting to origin<\/html>\"};\n return(deliver); *\/\n }\n\n # error 200\n if (obj.status == 200) {\n return (deliver);\n }\n\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} obj.status \" \" obj.response {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} obj.status \" \" obj.response {\"<\/h1>\n <p>\"} obj.response {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} req.xid {\"<\/p>\n <hr>\n <p>Fastly CDN server<\/p>\n <\/body>\n<\/html>\n\"};\n\n#FASTLY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n\nsub vcl_hash {\n set req.hash += req.http.host;\n set req.hash += req.url;\n \n ### {{ design_exceptions_code }} ###\n\n# Please do not remove below. It's required for purge all functionality\n#FASTLY hash\n\n return (hash);\n\n}\n\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"c6548d83da23e3105587c66ac1674d00e54e1de1","subject":"Add to whatever Vary header has been set already, rather than overwrite","message":"Add to whatever Vary header has been set already, rather than overwrite","repos":"mcshaz\/polyfill-service,jonathan-fielding\/polyfill-service,JakeChampion\/polyfill-service,kdzwinel\/polyfill-service,mcshaz\/polyfill-service,kdzwinel\/polyfill-service,jonathan-fielding\/polyfill-service,JakeChampion\/polyfill-service,jonathan-fielding\/polyfill-service,mcshaz\/polyfill-service,kdzwinel\/polyfill-service","old_file":"fastly-config.vcl","new_file":"fastly-config.vcl","new_contents":"sub vcl_recv {\n#FASTLY recv\n\n\tif (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n\t\treturn(pass);\n\t}\n\n\tif (req.url ~ \"^\/v\\d\/polyfill\\.\" && req.url !~ \"[\\?\\&]ua=\") {\n\t\tset req.http.X-Orig-URL = req.url;\n\t\tset req.url = \"\/v2\/normalizeUa?ua=\" urlencode(req.http.User-Agent);\n\t}\n\n\treturn(lookup);\n}\n\nsub vcl_deliver {\n#FASTLY deliver\n\n\t# If the response is to a normalise request and there's a parked \"original request\", use the normalised UA response to modify the original request and restart it\n\tif (req.url ~ \"^\/v\\d\/normalizeUa\" && resp.status == 200 && req.http.X-Orig-URL) {\n\t\tset req.http.Fastly-force-Shield = \"1\";\n\t\tif (req.http.X-Orig-URL ~ \"\\?\") {\n\t\t\tset req.url = req.http.X-Orig-URL \"&ua=\" resp.http.Normalized-User-Agent;\n\t\t} else {\n\t\t\tset req.url = req.http.X-Orig-URL \"?ua=\" resp.http.Normalized-User-Agent;\n\t\t}\n\t\trestart;\n\n\t# If the original request didn't specify a UA override, and we added one when the request was sent to the backend, the backend won't have included a Vary:user-agent header (correctly) but we need to add one\n\t} else if (req.url ~ \"^\/v\\d\/polyfill\\..*[\\?\\&]ua=\" && req.http.X-Orig-URL && req.http.X-Orig-URL !~ \"[\\?\\&]ua=\") {\n\t\tadd resp.http.Vary = \"User-Agent\";\n\t}\n\treturn(deliver);\n}\n","old_contents":"sub vcl_recv {\n#FASTLY recv\n\n\tif (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n\t\treturn(pass);\n\t}\n\n\tif (req.url ~ \"^\/v\\d\/polyfill\\.\" && req.url !~ \"[\\?\\&]ua=\") {\n\t\tset req.http.X-Orig-URL = req.url;\n\t\tset req.url = \"\/v2\/normalizeUa?ua=\" urlencode(req.http.User-Agent);\n\t}\n\n\treturn(lookup);\n}\n\nsub vcl_deliver {\n#FASTLY deliver\n\n\t# If the response is to a normalise request and there's a parked \"original request\", use the normalised UA response to modify the original request and restart it\n\tif (req.url ~ \"^\/v\\d\/normalizeUa\" && resp.status == 200 && req.http.X-Orig-URL) {\n\t\tset req.http.Fastly-force-Shield = \"1\";\n\t\tif (req.http.X-Orig-URL ~ \"\\?\") {\n\t\t\tset req.url = req.http.X-Orig-URL \"&ua=\" resp.http.Normalized-User-Agent;\n\t\t} else {\n\t\t\tset req.url = req.http.X-Orig-URL \"?ua=\" resp.http.Normalized-User-Agent;\n\t\t}\n\t\trestart;\n\n\t# If the original request didn't specify a UA override, and we added one when the request was sent to the backend, the backend won't have included a Vary:user-agent header (correctly) but we need to add one\n\t} else if (req.url ~ \"^\/v\\d\/polyfill\\..*[\\?\\&]ua=\" && req.http.X-Orig-URL && req.http.X-Orig-URL !~ \"[\\?\\&]ua=\") {\n\t\tset resp.http.Vary = \"Accept-Encoding, User-Agent\";\n\t}\n\treturn(deliver);\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"0056eaca8dfb508ed94699d6711230033fc6b375","subject":"Small clarification on X-Magento-Debug header","message":"Small clarification on X-Magento-Debug header\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets\/deliver.vcl","new_file":"etc\/vcl_snippets\/deliver.vcl","new_contents":" # Send no cache headers to end users for non-static content created by Magento\n if (resp.http.X-Magento-Tags && fastly.ff.visits_this_service == 0 ) {\n set resp.http.Cache-Control = \"no-store, no-cache, must-revalidate, max-age=0\";\n }\n\n # Execute only on the edge nodes\n if ( fastly.ff.visits_this_service == 0 ) {\n # Remove X-Magento-Vary and HTTPs Vary served to the user\n set resp.http.Vary = regsub(resp.http.Vary, \"(?i)X-Magento-Vary,Https\", \"Cookie\");\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it and we only want to do this on the edge nodes\n if (resp.http.x-esi) {\n set resp.http.x-compress-hint = \"on\";\n }\n remove resp.http.X-Magento-Tags;\n }\n\n # Add an easy way to see whether custom Fastly VCL has been uploaded\n if ( req.http.Fastly-Debug ) {\n set resp.http.Fastly-Magento-VCL-Uploaded = \"1.2.125\";\n } else {\n remove resp.http.Fastly-Module-Enabled;\n remove resp.http.fastly-page-cacheable;\n }\n\n # X-Magento-Debug header is exposed when developer mode is activated in Magento\n if (!resp.http.X-Magento-Debug) {\n # remove Varnish\/proxy header\n remove resp.http.X-Magento-Debug;\n remove resp.http.X-Magento-Cache-Control;\n remove resp.http.X-Powered-By;\n remove resp.http.Server;\n remove resp.http.X-Varnish;\n remove resp.http.Via;\n remove resp.http.X-Purge-URL;\n remove resp.http.X-Purge-Host;\n }\n","old_contents":" # Send no cache headers to end users for non-static content created by Magento\n if (resp.http.X-Magento-Tags && fastly.ff.visits_this_service == 0 ) {\n set resp.http.Cache-Control = \"no-store, no-cache, must-revalidate, max-age=0\";\n }\n\n # Execute only on the edge nodes\n if ( fastly.ff.visits_this_service == 0 ) {\n # Remove X-Magento-Vary and HTTPs Vary served to the user\n set resp.http.Vary = regsub(resp.http.Vary, \"(?i)X-Magento-Vary,Https\", \"Cookie\");\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it and we only want to do this on the edge nodes\n if (resp.http.x-esi) {\n set resp.http.x-compress-hint = \"on\";\n }\n remove resp.http.X-Magento-Tags;\n }\n\n # Add an easy way to see whether custom Fastly VCL has been uploaded\n if ( req.http.Fastly-Debug ) {\n set resp.http.Fastly-Magento-VCL-Uploaded = \"1.2.125\";\n } else {\n remove resp.http.Fastly-Module-Enabled;\n remove resp.http.fastly-page-cacheable;\n }\n\n # debug info\n if (!resp.http.X-Magento-Debug) {\n # remove Varnish\/proxy header\n remove resp.http.X-Magento-Debug;\n remove resp.http.X-Magento-Cache-Control;\n remove resp.http.X-Powered-By;\n remove resp.http.Server;\n remove resp.http.X-Varnish;\n remove resp.http.Via;\n remove resp.http.X-Purge-URL;\n remove resp.http.X-Purge-Host;\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"d2f9903714c5048f7cb601fcb45b949806d2aba5","subject":"Add more detailed comments about the vcl which decides whether to use the compute at edge backend","message":"Add more detailed comments about the vcl which decides whether to use the compute at edge backend","repos":"JakeChampion\/polyfill-service,JakeChampion\/polyfill-service","old_file":"fastly\/vcl\/polyfill-service.vcl","new_file":"fastly\/vcl\/polyfill-service.vcl","new_contents":"sub set_backend {\n\t# The Fastly macro is inserted before the backend is selected because the\n\t# macro has the code which defines the values avaiable for req.http.Host\n\t# but it also contains a default backend which is always set to the EU. I wish we could disable the default backend setting.\n\t#FASTLY recv\n\n\t# Calculate the ideal region to route the request to.\n\tdeclare local var.region STRING;\n\tif (server.region ~ \"(APAC|Asia|North-America|South-America|US-Central|US-East|US-West)\") {\n\t\tset var.region = \"US\";\n\t} else {\n\t\tset var.region = \"EU\";\n\t}\n\n\t# Gather the health of the shields and origins.\n\tdeclare local var.v3_eu_is_healthy BOOL;\n\tset req.backend = F_v3_eu;\n\tset var.v3_eu_is_healthy = req.backend.healthy;\n\n\tdeclare local var.v3_us_is_healthy BOOL;\n\tset req.backend = F_v3_us;\n\tset var.v3_us_is_healthy = req.backend.healthy;\n\n\tdeclare local var.shield_eu_is_healthy BOOL;\n\tset req.backend = ssl_shield_london_city_uk;\n\tset var.shield_eu_is_healthy = req.backend.healthy;\n\n\tdeclare local var.shield_us_is_healthy BOOL;\n\tset req.backend = ssl_shield_iad_va_us;\n\tset var.shield_us_is_healthy = req.backend.healthy;\n\n\t# Set some sort of default, that shouldn't get used.\n\tset req.backend = F_v3_eu;\n\n\tdeclare local var.EU_shield_server_name STRING;\n\tset var.EU_shield_server_name = \"LCY\";\n\n\tdeclare local var.US_shield_server_name STRING;\n\tset var.US_shield_server_name = \"IAD\";\n\n\t# Route EU requests to the nearest healthy shield or origin.\n\tif (var.region == \"EU\") {\n\t\tif (server.datacenter != var.EU_shield_server_name && fastly.ff.visits_this_service == 0 && req.restarts == 0 && var.shield_eu_is_healthy) {\n\t\t\tset req.backend = ssl_shield_london_city_uk;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} elseif (var.shield_us_is_healthy) {\n\t\t\tset req.backend = ssl_shield_iad_va_us;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_eu;\n\t\t}\n\t}\n\n\t# Route US requests to the nearest healthy shield or origin.\n\tif (var.region == \"US\") {\n\t\tif (server.datacenter != var.US_shield_server_name && fastly.ff.visits_this_service == 0 && req.restarts == 0 && var.shield_us_is_healthy) {\n\t\t\tset req.backend = ssl_shield_iad_va_us;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} elseif (var.shield_eu_is_healthy) {\n\t\t\tset req.backend = ssl_shield_london_city_uk;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_us;\n\t\t}\n\t}\n\n\t# Persist the decision so we can debug the result.\n\tset req.http.Debug-Backend = req.backend;\n}\n\nsub vcl_recv {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_recv;\n\t}\n\n\n # We use this edge dictionary item as a flag for whether to use compute-at-edge for any requests.\n # If the item is not found, then we default to `\"0\"`, which we interpret to mean the flag is off.\n\tdeclare local var.compute-at-edge-active BOOL;\n\tif (std.atoi(table.lookup(compute_at_edge_config, \"active\", \"0\")) == 1) {\n\t\tset var.compute-at-edge-active = true;\n\t} else {\n\t\tset var.compute-at-edge-active = false;\n\t}\n\tif (var.compute-at-edge-active) {\n\t\t# if the querystring parameter `use-compute-at-edge-backend` is set to yes`\n\t\t# then use the c@e backend.\n\t\t# The querystring parameter is used within our tests, so that we can confirm \n\t\t# the compute-at-edge backend is working as we expect it to.\n\t\tdeclare local var.use-compute-at-edge-backend STRING;\n\t\tset var.use-compute-at-edge-backend = querystring.get(req.url, \"use-compute-at-edge-backend\");\n\t\tif (var.use-compute-at-edge-backend == \"yes\" && (std.prefixof(req.url.path, \"\/v3\/polyfill.js\") || std.prefixof(req.url.path, \"\/v3\/polyfill.min.js\"))) {\n\t\t\tset req.backend = F_compute_at_edge;\n\t\t\tif (req.backend.healthy) {\n\t\t\t\t# if using the c@e backend then do not use the cache at all\n\t\t\t\treturn(pass);\n\t\t\t}\n # requests can set the querystring parameter to `no` to avoid ever user compute-at-edge\n # if the querystring parameter is not set to no, then we run some logic to decide whether\n # to use compute-at-edge for this request or not.\n\t\t} else if (var.use-compute-at-edge-backend != \"no\") {\n\t\t\tdeclare local var.selected BOOL;\n\t\t\tset var.selected = randombool(1, std.atoi(table.lookup(compute_at_edge_config, \"sample\", \"1000\")));\n\t\t\t# this logic is saying, only use compute-at-edge for a request which has come from outside this Fastly\n\t\t\t# service. I.E. The request has directly from a client.\n\t\t\t# We also have logic which decides how many of those direct client requests use compute-at-edge.\n\t\t\t# We default to 1 in 1000 requests using compute-at-edge, this can be configured by the edge dictionary\n\t\t\t# named `compute_at_edge_config` and the item in the dictionary named `sample`\n\t\t\tif (var.selected && fastly_info.edge.is_tls && !req.is_background_fetch && !req.is_purge && req.restarts == 0 && fastly.ff.visits_this_service == 0 && (std.prefixof(req.url.path, \"\/v3\/polyfill.js\") || std.prefixof(req.url.path, \"\/v3\/polyfill.min.js\"))) {\n\t\t\t\tset req.backend = F_compute_at_edge;\n\t\t\t\tif (req.backend.healthy) {\n\t\t\t\t\t# if using the c@e backend then do not use the cache at all\n\t\t\t\t\treturn(pass);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif (req.method != \"GET\" && req.method != \"HEAD\" && req.method != \"OPTIONS\" && req.method != \"FASTLYPURGE\" && req.method != \"PURGE\") {\n\t\terror 911;\n\t}\n\n\tif (req.method == \"OPTIONS\") {\n\t\terror 912;\n\t}\n\n\t# Because the old service had a router which allowed any words between \/v2\/polyfill. and .js\n\tif (req.url.path ~ \"^\/v2\/polyfill(\\.\\w+)(\\.\\w+)?\" && req.url.ext == \"js\") {\n\t\tif (re.group.2) {\n\t\t\tset req.url = \"\/v2\/polyfill.min.js?\" req.url.qs;\n\t\t} else {\n\t\t\tset req.url = \"\/v2\/polyfill.js?\" req.url.qs;\n\t\t}\n\t}\n\n\t# Override the v3 defaults with the defaults of v2\n\tif (req.url ~ \"^\/v2\/polyfill(\\.min)?\\.js\") {\n\t\tset req.url = regsub(req.url, \"^\/v2\", \"\/v3\");\n\t\tset req.url = querystring.set(req.url, \"version\", \"3.25.1\");\n\t\tdeclare local var.unknown STRING;\n\t\tset var.unknown = subfield(req.url.qs, \"unknown\", \"&\");\n\t\tset req.url = querystring.set(req.url, \"unknown\", if(var.unknown != \"\", var.unknown, \"ignore\"));\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\") {\n\t\tcall normalise_querystring_parameters_for_polyfill_bundle;\n\t\t# Sort the querystring parameters alphabetically to improve chances of hitting a cached copy.\n\t\t# If querystring is empty, remove the ? from the url.\n\t\tset req.url = querystring.clean(querystring.sort(req.url));\n\t\tcall set_backend;\n\t} else {\n\t\t# The request is to an endpoint which doesn't use query parameters, let's remove them to increase our cache-hit-ratio\n\t\tset req.url = querystring.remove(req.url);\n\t\tcall set_backend;\n\t}\n\n\tif (req.backend == ssl_shield_iad_va_us || req.backend == ssl_shield_london_city_uk) {\n\t\t# avoid passing stale content from Shield POP to Edge POP\n\t\tset req.max_stale_while_revalidate = 0s;\n\t} else {\n\t\tset req.http.referer_domain = if(req.http.referer ~ \"^https?\\:\\\/\\\/([^\\\/:?#]+)(?:[\\\/:?#]|$)\", re.group.1, \"\");\n\t}\n}\n\nsub vcl_hash {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_hash;\n\t}\n\n\t# We are not adding req.http.host to the hash because we want https:\/\/cdn.polyfill.io and https:\/\/polyfill.io to be a single object in the cache.\n\t# As well as any other domains we support such as polyfills.io and cdn.polyfills.io\n\t# set req.hash += req.http.host;\n\tset req.hash += req.url;\n\t# We include return(hash) to stop the function falling through to the default VCL built into varnish, which for vcl_hash will add req.url and req.http.Host to the hash.\n\treturn(hash);\n}\n\nsub vcl_miss {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_miss;\n\t}\n}\n\nsub vcl_pass {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_pass;\n\t}\n}\n\nsub vcl_fetch {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_fetch;\n\t}\n\n\t# https:\/\/yann.mandragor.org\/posts\/purge-group-pattern\/\n\tif (beresp.http.Surrogate-Key && !std.strstr(beresp.http.Surrogate-Key, \"PurgeGroup\")) {\n\t\tset beresp.http.Surrogate-Key = beresp.http.Surrogate-Key \" PurgeGroup\" randomint(0, 999);\n\t} else if (!beresp.http.Surrogate-Key) {\n\t\tset beresp.http.Surrogate-Key = \"PurgeGroup\" randomint(0, 999);\n\t}\n\n\t# These header are only required for HTML documents.\n\tif (beresp.http.Content-Type ~ \"text\/html\") {\n\t\t# Enables the cross-site scripting filter built into most modern web browsers.\n\t\tset beresp.http.X-XSS-Protection = \"1; mode=block\";\n\t}\n\t# Prevents MIME-sniffing a response away from the declared content type.\n\tset beresp.http.X-Content-Type-Options = \"nosniff\";\n\n\t# Ensure the site is only served over HTTPS and reduce the chances of someone performing a MITM attack.\n\tset beresp.http.Strict-Transport-Security = \"max-age=31536000; includeSubdomains; preload\";\n\n\t# The Referrer-Policy header governs which referrer information, sent in the Referer header, should be included with requests made.\n\t# Send a full URL when performing a same-origin request, but only send the origin of the document for other cases.\n\tset beresp.http.Referrer-Policy = \"origin-when-cross-origin\";\n\n\t# Enable purging of all objects in the Fastly cache by issuing a purge with the key \"polyfill-service\".\n\tif (beresp.http.Surrogate-Key !~ \"\\bpolyfill-service\\b\") {\n\t\tset beresp.http.Surrogate-Key = if(beresp.http.Surrogate-Key, beresp.http.Surrogate-Key \" polyfill-service\", \"polyfill-service\");\n\t}\n\n\tset beresp.http.Timing-Allow-Origin = \"*\";\n\n\tif (req.http.Normalized-User-Agent) {\n\t\tset beresp.http.Normalized-User-Agent = req.http.Normalized-User-Agent;\n\t\tset beresp.http.Detected-User-Agent = req.http.useragent_parser_family \"\/\" req.http.useragent_parser_major \".\" req.http.useragent_parser_minor \".\" req.http.useragent_parser_patch;\n\t}\n\n\t# We end up here if\n\t# - The origin is HEALTHY; and\n\t# - It returned a valid HTTP response\n\t#\n\t# We may still not want to *use* that response, if it's an HTTP error,\n\t# so that's the case we need to catch here.\n\tif (beresp.status >= 500 && beresp.status < 600) {\n\t\t# There's a stale version available! Serve it.\n\t\tif (stale.exists) {\n\t\t\treturn(deliver_stale);\n\t\t}\n\t\t# Cache the error for 1s to allow it to be used for any collapsed requests\n\t\tset beresp.cacheable = true;\n\t\tset beresp.ttl = 1s;\n\t\treturn(deliver);\n\t}\n\t# If the response is not an error, but it is stale content that's being\n\t# served from a cache upstream, cache it for a very brief period to\n\t# clear the request queue.\n\tif (beresp.status == 200 && beresp.http.x-resp-is-stale) {\n\t\tset beresp.ttl = 1s;\n\t\tset beresp.stale_while_revalidate = 0s;\n\t\tset beresp.stale_if_error = 0s;\n\t\treturn (deliver);\n\t}\n}\n\nsub vcl_deliver {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_deliver;\n\t}\n\tif (fastly_info.state ~ \"STALE\") {\n\t\tset resp.http.x-resp-is-stale = \"true\";\n\t}\n\n\tset req.http.Fastly-Force-Shield = \"yes\";\n\n\t# Allow cross origin GET, HEAD, and OPTIONS requests to be made.\n\tif (req.http.Origin) {\n\t\tset resp.http.Access-Control-Allow-Origin = \"*\";\n\t\tset resp.http.Access-Control-Allow-Methods = \"GET,HEAD,OPTIONS\";\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\" && fastly.ff.visits_this_service == 0) {\n\t\t# Need to add \"Vary: User-Agent\" in after vcl_fetch to avoid the\n\t\t# \"Vary: User-Agent\" entering the Varnish cache.\n\t\t# We need \"Vary: User-Agent\" in the browser cache because a browser\n\t\t# may update itself to a version which needs different polyfills\n\t\t# So we need to have it ignore the browser cached bundle when the user-agent changes.\n\t\tset resp.http.Vary = \"User-Agent, Accept-Encoding\";\n\t}\n\n\tif (resp.status == 304) {\n\t\tset resp.http.Age = \"0\";\n\t}\n\n\tadd resp.http.Server-Timing = fastly_info.state {\", fastly;desc=\"Edge time\";dur=\"} time.elapsed.msec;\n\n\tif (req.http.Fastly-Debug) {\n\t\tset resp.http.Debug-Backend = req.http.Debug-Backend;\n\t\tset resp.http.Debug-Host = req.http.Host;\n\t\tset resp.http.Debug-Fastly-Restarts = req.restarts;\n\t\tset resp.http.Debug-Orig-URL = req.http.Orig-URL;\n\t\tset resp.http.Debug-VCL-Route = req.http.X-VCL-Route;\n\t\tset resp.http.useragent_parser_family = req.http.useragent_parser_family;\n\t\tset resp.http.useragent_parser_major = req.http.useragent_parser_major;\n\t\tset resp.http.useragent_parser_minor = req.http.useragent_parser_minor;\n\t\tset resp.http.useragent_parser_patch = req.http.useragent_parser_patch;\n\t} else {\n\t\tunset resp.http.Server;\n\t\tunset resp.http.Via;\n\t\tunset resp.http.X-Cache;\n\t\tunset resp.http.X-Cache-Hits;\n\t\tunset resp.http.X-Served-By;\n\t\tunset resp.http.X-Timer;\n\t\tunset resp.http.Fastly-Restarts;\n\t\tunset resp.http.X-PreFetch-Pass;\n\t\tunset resp.http.X-PreFetch-Miss;\n\t\tunset resp.http.X-PostFetch;\n\t}\n}\n\nsub vcl_error {\n\tif (obj.status >= 500 && obj.status < 600) {\n\t\tif (stale.exists) {\n\t\t\treturn(deliver_stale);\n\t\t}\n\t\treturn(deliver);\n\t}\n\tif (obj.status == 911) {\n\t\tset obj.status = 405;\n\t\tset obj.response = \"METHOD NOT ALLOWED\";\n\t\tset obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n\t\tset obj.http.Cache-Control = \"private, no-store\";\n\t\tsynthetic req.method \" METHOD NOT ALLOWED\";\n\t\treturn (deliver);\n\t}\n\tif (obj.status == 912) {\n\t\tset obj.status = 200;\n\t\tset obj.response = \"OK\";\n\t\tset obj.http.Allow = \"OPTIONS, GET, HEAD\";\n\t\treturn (deliver);\n\t}\n}\n","old_contents":"sub set_backend {\n\t# The Fastly macro is inserted before the backend is selected because the\n\t# macro has the code which defines the values avaiable for req.http.Host\n\t# but it also contains a default backend which is always set to the EU. I wish we could disable the default backend setting.\n\t#FASTLY recv\n\n\t# Calculate the ideal region to route the request to.\n\tdeclare local var.region STRING;\n\tif (server.region ~ \"(APAC|Asia|North-America|South-America|US-Central|US-East|US-West)\") {\n\t\tset var.region = \"US\";\n\t} else {\n\t\tset var.region = \"EU\";\n\t}\n\n\t# Gather the health of the shields and origins.\n\tdeclare local var.v3_eu_is_healthy BOOL;\n\tset req.backend = F_v3_eu;\n\tset var.v3_eu_is_healthy = req.backend.healthy;\n\n\tdeclare local var.v3_us_is_healthy BOOL;\n\tset req.backend = F_v3_us;\n\tset var.v3_us_is_healthy = req.backend.healthy;\n\n\tdeclare local var.shield_eu_is_healthy BOOL;\n\tset req.backend = ssl_shield_london_city_uk;\n\tset var.shield_eu_is_healthy = req.backend.healthy;\n\n\tdeclare local var.shield_us_is_healthy BOOL;\n\tset req.backend = ssl_shield_iad_va_us;\n\tset var.shield_us_is_healthy = req.backend.healthy;\n\n\t# Set some sort of default, that shouldn't get used.\n\tset req.backend = F_v3_eu;\n\n\tdeclare local var.EU_shield_server_name STRING;\n\tset var.EU_shield_server_name = \"LCY\";\n\n\tdeclare local var.US_shield_server_name STRING;\n\tset var.US_shield_server_name = \"IAD\";\n\n\t# Route EU requests to the nearest healthy shield or origin.\n\tif (var.region == \"EU\") {\n\t\tif (server.datacenter != var.EU_shield_server_name && fastly.ff.visits_this_service == 0 && req.restarts == 0 && var.shield_eu_is_healthy) {\n\t\t\tset req.backend = ssl_shield_london_city_uk;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} elseif (var.shield_us_is_healthy) {\n\t\t\tset req.backend = ssl_shield_iad_va_us;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_eu;\n\t\t}\n\t}\n\n\t# Route US requests to the nearest healthy shield or origin.\n\tif (var.region == \"US\") {\n\t\tif (server.datacenter != var.US_shield_server_name && fastly.ff.visits_this_service == 0 && req.restarts == 0 && var.shield_us_is_healthy) {\n\t\t\tset req.backend = ssl_shield_iad_va_us;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} elseif (var.shield_eu_is_healthy) {\n\t\t\tset req.backend = ssl_shield_london_city_uk;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_us;\n\t\t}\n\t}\n\n\t# Persist the decision so we can debug the result.\n\tset req.http.Debug-Backend = req.backend;\n}\n\nsub vcl_recv {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_recv;\n\t}\n\n\n\tdeclare local var.compute-at-edge-active BOOL;\n\tif (std.atoi(table.lookup(compute_at_edge_config, \"active\", \"0\")) == 1) {\n\t\tset var.compute-at-edge-active = true;\n\t} else {\n\t\tset var.compute-at-edge-active = false;\n\t}\n\tif (var.compute-at-edge-active) {\n\t\t# if the querystring parameter `use-compute-at-edge-backend` is set to yes`\n\t\t# then use the c@e backend.\n\t\t# else if the `use-compute-at-edge-backend` is not set to `no` then make\n\t\t# 1 in 1000 requests which come directly from a client use the c@e backend\n\t\tdeclare local var.use-compute-at-edge-backend STRING;\n\t\tset var.use-compute-at-edge-backend = querystring.get(req.url, \"use-compute-at-edge-backend\");\n\t\tif (var.use-compute-at-edge-backend == \"yes\" && (std.prefixof(req.url.path, \"\/v3\/polyfill.js\") || std.prefixof(req.url.path, \"\/v3\/polyfill.min.js\"))) {\n\t\t\tset req.backend = F_compute_at_edge;\n\t\t\tif (req.backend.healthy) {\n\t\t\t\t# if using the c@e backend then do not use the cache at all\n\t\t\t\treturn(pass);\n\t\t\t}\n\t\t} else if (var.use-compute-at-edge-backend != \"no\") {\n\t\t\tdeclare local var.selected BOOL;\n\t\t\tset var.selected = randombool(1, std.atoi(table.lookup(compute_at_edge_config, \"sample\", \"1000\")));\n\t\t\tif (var.selected && fastly_info.edge.is_tls && !req.is_background_fetch && !req.is_purge && req.restarts == 0 && fastly.ff.visits_this_service == 0 && (std.prefixof(req.url.path, \"\/v3\/polyfill.js\") || std.prefixof(req.url.path, \"\/v3\/polyfill.min.js\"))) {\n\t\t\t\tset req.backend = F_compute_at_edge;\n\t\t\t\tif (req.backend.healthy) {\n\t\t\t\t\t# if using the c@e backend then do not use the cache at all\n\t\t\t\t\treturn(pass);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif (req.method != \"GET\" && req.method != \"HEAD\" && req.method != \"OPTIONS\" && req.method != \"FASTLYPURGE\" && req.method != \"PURGE\") {\n\t\terror 911;\n\t}\n\n\tif (req.method == \"OPTIONS\") {\n\t\terror 912;\n\t}\n\n\t# Because the old service had a router which allowed any words between \/v2\/polyfill. and .js\n\tif (req.url.path ~ \"^\/v2\/polyfill(\\.\\w+)(\\.\\w+)?\" && req.url.ext == \"js\") {\n\t\tif (re.group.2) {\n\t\t\tset req.url = \"\/v2\/polyfill.min.js?\" req.url.qs;\n\t\t} else {\n\t\t\tset req.url = \"\/v2\/polyfill.js?\" req.url.qs;\n\t\t}\n\t}\n\n\t# Override the v3 defaults with the defaults of v2\n\tif (req.url ~ \"^\/v2\/polyfill(\\.min)?\\.js\") {\n\t\tset req.url = regsub(req.url, \"^\/v2\", \"\/v3\");\n\t\tset req.url = querystring.set(req.url, \"version\", \"3.25.1\");\n\t\tdeclare local var.unknown STRING;\n\t\tset var.unknown = subfield(req.url.qs, \"unknown\", \"&\");\n\t\tset req.url = querystring.set(req.url, \"unknown\", if(var.unknown != \"\", var.unknown, \"ignore\"));\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\") {\n\t\tcall normalise_querystring_parameters_for_polyfill_bundle;\n\t\t# Sort the querystring parameters alphabetically to improve chances of hitting a cached copy.\n\t\t# If querystring is empty, remove the ? from the url.\n\t\tset req.url = querystring.clean(querystring.sort(req.url));\n\t\tcall set_backend;\n\t} else {\n\t\t# The request is to an endpoint which doesn't use query parameters, let's remove them to increase our cache-hit-ratio\n\t\tset req.url = querystring.remove(req.url);\n\t\tcall set_backend;\n\t}\n\n\tif (req.backend == ssl_shield_iad_va_us || req.backend == ssl_shield_london_city_uk) {\n\t\t# avoid passing stale content from Shield POP to Edge POP\n\t\tset req.max_stale_while_revalidate = 0s;\n\t} else {\n\t\tset req.http.referer_domain = if(req.http.referer ~ \"^https?\\:\\\/\\\/([^\\\/:?#]+)(?:[\\\/:?#]|$)\", re.group.1, \"\");\n\t}\n}\n\nsub vcl_hash {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_hash;\n\t}\n\n\t# We are not adding req.http.host to the hash because we want https:\/\/cdn.polyfill.io and https:\/\/polyfill.io to be a single object in the cache.\n\t# As well as any other domains we support such as polyfills.io and cdn.polyfills.io\n\t# set req.hash += req.http.host;\n\tset req.hash += req.url;\n\t# We include return(hash) to stop the function falling through to the default VCL built into varnish, which for vcl_hash will add req.url and req.http.Host to the hash.\n\treturn(hash);\n}\n\nsub vcl_miss {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_miss;\n\t}\n}\n\nsub vcl_pass {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_pass;\n\t}\n}\n\nsub vcl_fetch {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_fetch;\n\t}\n\n\t# https:\/\/yann.mandragor.org\/posts\/purge-group-pattern\/\n\tif (beresp.http.Surrogate-Key && !std.strstr(beresp.http.Surrogate-Key, \"PurgeGroup\")) {\n\t\tset beresp.http.Surrogate-Key = beresp.http.Surrogate-Key \" PurgeGroup\" randomint(0, 999);\n\t} else if (!beresp.http.Surrogate-Key) {\n\t\tset beresp.http.Surrogate-Key = \"PurgeGroup\" randomint(0, 999);\n\t}\n\n\t# These header are only required for HTML documents.\n\tif (beresp.http.Content-Type ~ \"text\/html\") {\n\t\t# Enables the cross-site scripting filter built into most modern web browsers.\n\t\tset beresp.http.X-XSS-Protection = \"1; mode=block\";\n\t}\n\t# Prevents MIME-sniffing a response away from the declared content type.\n\tset beresp.http.X-Content-Type-Options = \"nosniff\";\n\n\t# Ensure the site is only served over HTTPS and reduce the chances of someone performing a MITM attack.\n\tset beresp.http.Strict-Transport-Security = \"max-age=31536000; includeSubdomains; preload\";\n\n\t# The Referrer-Policy header governs which referrer information, sent in the Referer header, should be included with requests made.\n\t# Send a full URL when performing a same-origin request, but only send the origin of the document for other cases.\n\tset beresp.http.Referrer-Policy = \"origin-when-cross-origin\";\n\n\t# Enable purging of all objects in the Fastly cache by issuing a purge with the key \"polyfill-service\".\n\tif (beresp.http.Surrogate-Key !~ \"\\bpolyfill-service\\b\") {\n\t\tset beresp.http.Surrogate-Key = if(beresp.http.Surrogate-Key, beresp.http.Surrogate-Key \" polyfill-service\", \"polyfill-service\");\n\t}\n\n\tset beresp.http.Timing-Allow-Origin = \"*\";\n\n\tif (req.http.Normalized-User-Agent) {\n\t\tset beresp.http.Normalized-User-Agent = req.http.Normalized-User-Agent;\n\t\tset beresp.http.Detected-User-Agent = req.http.useragent_parser_family \"\/\" req.http.useragent_parser_major \".\" req.http.useragent_parser_minor \".\" req.http.useragent_parser_patch;\n\t}\n\n\t# We end up here if\n\t# - The origin is HEALTHY; and\n\t# - It returned a valid HTTP response\n\t#\n\t# We may still not want to *use* that response, if it's an HTTP error,\n\t# so that's the case we need to catch here.\n\tif (beresp.status >= 500 && beresp.status < 600) {\n\t\t# There's a stale version available! Serve it.\n\t\tif (stale.exists) {\n\t\t\treturn(deliver_stale);\n\t\t}\n\t\t# Cache the error for 1s to allow it to be used for any collapsed requests\n\t\tset beresp.cacheable = true;\n\t\tset beresp.ttl = 1s;\n\t\treturn(deliver);\n\t}\n\t# If the response is not an error, but it is stale content that's being\n\t# served from a cache upstream, cache it for a very brief period to\n\t# clear the request queue.\n\tif (beresp.status == 200 && beresp.http.x-resp-is-stale) {\n\t\tset beresp.ttl = 1s;\n\t\tset beresp.stale_while_revalidate = 0s;\n\t\tset beresp.stale_if_error = 0s;\n\t\treturn (deliver);\n\t}\n}\n\nsub vcl_deliver {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_deliver;\n\t}\n\tif (fastly_info.state ~ \"STALE\") {\n\t\tset resp.http.x-resp-is-stale = \"true\";\n\t}\n\n\tset req.http.Fastly-Force-Shield = \"yes\";\n\n\t# Allow cross origin GET, HEAD, and OPTIONS requests to be made.\n\tif (req.http.Origin) {\n\t\tset resp.http.Access-Control-Allow-Origin = \"*\";\n\t\tset resp.http.Access-Control-Allow-Methods = \"GET,HEAD,OPTIONS\";\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\" && fastly.ff.visits_this_service == 0) {\n\t\t# Need to add \"Vary: User-Agent\" in after vcl_fetch to avoid the\n\t\t# \"Vary: User-Agent\" entering the Varnish cache.\n\t\t# We need \"Vary: User-Agent\" in the browser cache because a browser\n\t\t# may update itself to a version which needs different polyfills\n\t\t# So we need to have it ignore the browser cached bundle when the user-agent changes.\n\t\tset resp.http.Vary = \"User-Agent, Accept-Encoding\";\n\t}\n\n\tif (resp.status == 304) {\n\t\tset resp.http.Age = \"0\";\n\t}\n\n\tadd resp.http.Server-Timing = fastly_info.state {\", fastly;desc=\"Edge time\";dur=\"} time.elapsed.msec;\n\n\tif (req.http.Fastly-Debug) {\n\t\tset resp.http.Debug-Backend = req.http.Debug-Backend;\n\t\tset resp.http.Debug-Host = req.http.Host;\n\t\tset resp.http.Debug-Fastly-Restarts = req.restarts;\n\t\tset resp.http.Debug-Orig-URL = req.http.Orig-URL;\n\t\tset resp.http.Debug-VCL-Route = req.http.X-VCL-Route;\n\t\tset resp.http.useragent_parser_family = req.http.useragent_parser_family;\n\t\tset resp.http.useragent_parser_major = req.http.useragent_parser_major;\n\t\tset resp.http.useragent_parser_minor = req.http.useragent_parser_minor;\n\t\tset resp.http.useragent_parser_patch = req.http.useragent_parser_patch;\n\t} else {\n\t\tunset resp.http.Server;\n\t\tunset resp.http.Via;\n\t\tunset resp.http.X-Cache;\n\t\tunset resp.http.X-Cache-Hits;\n\t\tunset resp.http.X-Served-By;\n\t\tunset resp.http.X-Timer;\n\t\tunset resp.http.Fastly-Restarts;\n\t\tunset resp.http.X-PreFetch-Pass;\n\t\tunset resp.http.X-PreFetch-Miss;\n\t\tunset resp.http.X-PostFetch;\n\t}\n}\n\nsub vcl_error {\n\tif (obj.status >= 500 && obj.status < 600) {\n\t\tif (stale.exists) {\n\t\t\treturn(deliver_stale);\n\t\t}\n\t\treturn(deliver);\n\t}\n\tif (obj.status == 911) {\n\t\tset obj.status = 405;\n\t\tset obj.response = \"METHOD NOT ALLOWED\";\n\t\tset obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n\t\tset obj.http.Cache-Control = \"private, no-store\";\n\t\tsynthetic req.method \" METHOD NOT ALLOWED\";\n\t\treturn (deliver);\n\t}\n\tif (obj.status == 912) {\n\t\tset obj.status = 200;\n\t\tset obj.response = \"OK\";\n\t\tset obj.http.Allow = \"OPTIONS, GET, HEAD\";\n\t\treturn (deliver);\n\t}\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"48ed602b8dff2f0f9d33179b1c15fe3bf21c6158","subject":"Bypass cache for 4xx & 5xx errors","message":"Bypass cache for 4xx & 5xx errors\n","repos":"genesis\/wordpress,evolution\/wordpress,evolution\/genesis-wordpress,evolution\/wordpress,genesis\/wordpress,genesis\/wordpress,genesis\/wordpress,jalevin\/wordpress,evolution\/genesis-wordpress,evolution\/wordpress,evolution\/wordpress,genesis\/wordpress,jalevin\/wordpress,jalevin\/wordpress,jalevin\/wordpress,evolution\/genesis-wordpress,evolution\/wordpress,genesis\/wordpress,jalevin\/wordpress,evolution\/genesis-wordpress,evolution\/genesis-wordpress,evolution\/genesis-wordpress","old_file":"provisioning\/roles\/varnish\/files\/etc-varnish\/production.vcl","new_file":"provisioning\/roles\/varnish\/files\/etc-varnish\/production.vcl","new_contents":"# Default backend definition. Set this to point to your content server.\n# all paths relative to varnish option vcl_dir\n\ninclude \"custom.backend.vcl\";\ninclude \"custom.acl.vcl\";\n\n# Handle the HTTP request received by the client\nsub vcl_recv {\n # varnish serves stale (but cacheable) objects while retriving object from backend\n if (req.backend.healthy) {\n set req.grace = 30s;\n } else {\n set req.grace = 1h;\n }\n\n # shortcut for DFind requests\n if (req.url ~ \"^\/w00tw00t\") {\n error 404 \"Not Found\";\n }\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n # Normalize the header, remove the port (in case you're testing this on various TCP ports)\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n # Allow purging\n if (req.request == \"PURGE\") {\n if (!client.ip ~ purge) {\n # Not from an allowed IP? Then die with an error.\n error 405 \"This IP is not allowed to send PURGE requests.\";\n }\n\n # If you got this stage (and didn't error out above), do a cache-lookup\n # That will force entry into vcl_hit() or vcl_miss() below and purge the actual cache\n return (lookup);\n }\n\n # Only deal with \"normal\" types\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"PATCH\" &&\n req.request != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n # We only deal with GET and HEAD by default\n return (pass);\n }\n\n # Some generic URL manipulation, useful for all templates that follow\n # First remove the Google Analytics added parameters, useless for our backend\n if (req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=\") {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # Strip hash, server doesn't need it.\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n # Strip a trailing ? if it exists\n if (req.url ~ \"\\?$\") {\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # This is an example to redirect with a 301\/302 HTTP status code from within Varnish\n # if (req.http.Host ~ \"secure.mysite.tld\") {\n # # We may want to force our users from the secure site to the HTTPs version?\n # error 720 \"https:\/\/secure.mysite.tld\";\n # # If you want to keep the URLs intact, this also works:\n # error 720 \"https:\/\/\" + req.http.Host + req.url;\n # }\n #\n # Or to force a 302 temporary redirect, use error 721\n # if (req.http.Host ~ \"temp.mysite.tld\") {\n # # Temporary redirect\n # error 721 \"http:\/\/mysite.tld\/temp\";\n # }\n #\n\n # Some generic cookie manipulation, useful for all templates that follow\n # Remove the \"has_js\" cookie\n set req.http.Cookie = regsuball(req.http.Cookie, \"has_js=[^;]+(; )?\", \"\");\n\n # Remove any Satallite cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__gaid=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"_sdsat_[^=]+=[^;]+(; )?\", \"\");\n\n # Remove any Google Analytics based cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__utm.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"_ga=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmctr=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmcmd.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmccn.=[^;]+(; )?\", \"\");\n\n # Remove any Cloudflare cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__cfduid=[^;]+(; )?\", \"\");\n\n # Remove the Quant Capital cookies (added by some plugin, all __qca)\n set req.http.Cookie = regsuball(req.http.Cookie, \"__qc.=[^;]+(; )?\", \"\");\n\n # Remove the AddThis cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__atuvc=[^;]+(; )?\", \"\");\n\n # Remove a \";\" prefix in the cookie if present\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n\n # Are there cookies left with only spaces or that are empty?\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n\n # Normalize Accept-Encoding header\n # straight from the manual: https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/vary.html\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n # No point in compressing these\n remove req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n # unkown algorithm\n remove req.http.Accept-Encoding;\n }\n }\n\n # Remove all cookies for static files\n # A valid discussion could be held on this line: do you really need to cache static files that don't cause load? Only if you have memory left.\n # Sure, there's disk I\/O, but chances are your OS will already have these files in their buffers (thus memory).\n # Before you blindly enable this, have a read here: http:\/\/mattiasgeniar.be\/2012\/11\/28\/stop-caching-static-files\/\n if (req.url ~ \"^[^?]*\\.(bmp|bz2|css|doc|eot|flv|gif|gz|ico|jpeg|jpg|js|less|mp[34]|pdf|png|rar|rtf|swf|tar|tgz|txt|wav|woff|xml|zip)(\\?.*)?$\") {\n unset req.http.Cookie;\n return (lookup);\n }\n\n # Send Surrogate-Capability headers to announce ESI support to backend\n set req.http.Surrogate-Capability = \"key=ESI\/1.0\";\n\n # Include custom vcl_recv logic\n include \"conf.d\/receive\/wordpress.vcl\";\n\n if (req.http.Authorization || req.http.Cookie) {\n # Not cacheable by default\n return (pass);\n }\n\n return (lookup);\n}\n\nsub vcl_pipe {\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n # set bereq.http.connection = \"close\";\n # here. It is not set by default as it might break some broken web\n # applications, like IIS with NTLM authentication.\n\n #set bereq.http.Connection = \"Close\";\n return (pipe);\n}\n\nsub vcl_pass {\n return (pass);\n}\n\n# The data on which the hashing will take place\nsub vcl_hash {\n hash_data(req.url);\n\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n\n # hash cookies for object with auth\n if (req.http.Cookie) {\n hash_data(req.http.Cookie);\n }\n if (req.http.Authorization) {\n hash_data(req.http.Authorization);\n }\n\n return (hash);\n}\n\nsub vcl_hit {\n # Allow purges\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"purged\";\n }\n\n return (deliver);\n}\n\nsub vcl_miss {\n # Allow purges\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"purged\";\n }\n\n return (fetch);\n}\n\n# Handle the HTTP request coming from our backend \nsub vcl_fetch {\n set beresp.grace = 1h;\n\n # Include custom vcl_fetch logic\n include \"conf.d\/fetch\/wordpress.vcl\";\n\n # Parse ESI request and remove Surrogate-Control header\n if (beresp.http.Surrogate-Control ~ \"ESI\/1.0\") {\n unset beresp.http.Surrogate-Control;\n set beresp.do_esi = true;\n }\n\n # If the request to the backend returns a code is 5xx, restart the loop\n # If the number of restarts reaches the value of the parameter max_restarts,\n # the request will be error'ed. max_restarts defaults to 4. This prevents\n # an eternal loop in the event that, e.g., the object does not exist at all.\n if (beresp.status >= 500 && beresp.status <= 599){\n return(restart);\n }\n\n # Enable cache for all static files\n # The same argument as the static caches from above: monitor your cache size, if you get data nuked out of it, consider giving up the static file cache.\n # Before you blindly enable this, have a read here: http:\/\/mattiasgeniar.be\/2012\/11\/28\/stop-caching-static-files\/\n if (req.url ~ \"^[^?]*\\.(bmp|bz2|css|doc|eot|flv|gif|gz|ico|jpeg|jpg|js|less|mp[34]|pdf|png|rar|rtf|swf|tar|tgz|txt|wav|woff|xml|zip)(\\?.*)?$\") {\n unset beresp.http.set-cookie;\n }\n\n # Sometimes, a 301 or 302 redirect formed via Apache's mod_rewrite can mess with the HTTP port that is being passed along.\n # This often happens with simple rewrite rules in a scenario where Varnish runs on :80 and Apache on :8080 on the same box.\n # A redirect can then often redirect the end-user to a URL on :8080, where it should be :80.\n # This may need finetuning on your setup.\n #\n # To prevent accidental replace, we only filter the 301\/302 redirects for now.\n if (beresp.status == 301 || beresp.status == 302) {\n set beresp.http.Location = regsub(beresp.http.Location, \":[0-9]+\", \"\");\n }\n\n # Don't cache user & server errors\n if (beresp.status >= 400) {\n return (hit_for_pass);\n }\n\n # Non private responses without cookies and with a ttl of 0 should be artificially extended to 5min\n if (beresp.ttl <= 0s && beresp.http.Cache-Control !~ \"private\" && (!beresp.http.Set-Cookie)) {\n set beresp.ttl = 1h;\n set beresp.http.X-Cache-Extended = \"1\";\n }\n\n # Set 2min cache if unset for static files\n if (beresp.ttl <= 0s || beresp.http.Set-Cookie || beresp.http.Vary == \"*\") {\n set beresp.ttl = 120s;\n return (hit_for_pass);\n }\n\n return (deliver);\n}\n\n# The routine when we deliver the HTTP request to the user\n# Last chance to modify headers that are sent to the client\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"cached\";\n } else {\n set resp.http.x-Cache = \"uncached\";\n }\n\n # Remove some headers: PHP version\n unset resp.http.X-Powered-By;\n\n # Remove some headers: Apache version & OS\n unset resp.http.Server;\n unset resp.http.X-Drupal-Cache;\n unset resp.http.X-Varnish;\n unset resp.http.Via;\n unset resp.http.Link;\n\n return (deliver);\n}\n\nsub vcl_error {\n if (obj.status >= 500 && obj.status <= 599 && req.restarts < 4) {\n # 4 retry for 5xx error\n return(restart);\n } elsif (obj.status >= 400 && obj.status <= 499 ) {\n # use 404 error page for 4xx error\n include \"conf.d\/error-404.vcl\";\n } elsif (obj.status <= 200 && obj.status >= 299 ) {\n # for other errors (not 5xx, not 4xx and not 2xx)\n include \"conf.d\/error.vcl\";\n } elseif (obj.status == 720) {\n # We use this special error status 720 to force redirects with 301 (permanent) redirects\n # To use this, call the following from anywhere in vcl_recv: error 720 \"http:\/\/host\/new.html\"\n set obj.status = 301;\n set obj.http.Location = obj.response;\n return (deliver);\n } elseif (obj.status == 721) {\n # And we use error status 721 to force redirects with a 302 (temporary) redirect\n # To use this, call the following from anywhere in vcl_recv: error 720 \"http:\/\/host\/new.html\"\n set obj.status = 302;\n set obj.http.Location = obj.response;\n return (deliver);\n } else {\n include \"conf.d\/error.vcl\";\n }\n\n return (deliver);\n}\n\nsub vcl_init {\n return (ok);\n}\n\nsub vcl_fini {\n return (ok);\n}\n","old_contents":"# Default backend definition. Set this to point to your content server.\n# all paths relative to varnish option vcl_dir\n\ninclude \"custom.backend.vcl\";\ninclude \"custom.acl.vcl\";\n\n# Handle the HTTP request received by the client\nsub vcl_recv {\n # varnish serves stale (but cacheable) objects while retriving object from backend\n if (req.backend.healthy) {\n set req.grace = 30s;\n } else {\n set req.grace = 1h;\n }\n\n # shortcut for DFind requests\n if (req.url ~ \"^\/w00tw00t\") {\n error 404 \"Not Found\";\n }\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n # Normalize the header, remove the port (in case you're testing this on various TCP ports)\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n # Allow purging\n if (req.request == \"PURGE\") {\n if (!client.ip ~ purge) {\n # Not from an allowed IP? Then die with an error.\n error 405 \"This IP is not allowed to send PURGE requests.\";\n }\n\n # If you got this stage (and didn't error out above), do a cache-lookup\n # That will force entry into vcl_hit() or vcl_miss() below and purge the actual cache\n return (lookup);\n }\n\n # Only deal with \"normal\" types\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"PATCH\" &&\n req.request != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n # We only deal with GET and HEAD by default\n return (pass);\n }\n\n # Some generic URL manipulation, useful for all templates that follow\n # First remove the Google Analytics added parameters, useless for our backend\n if (req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=\") {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # Strip hash, server doesn't need it.\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n # Strip a trailing ? if it exists\n if (req.url ~ \"\\?$\") {\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # This is an example to redirect with a 301\/302 HTTP status code from within Varnish\n # if (req.http.Host ~ \"secure.mysite.tld\") {\n # # We may want to force our users from the secure site to the HTTPs version?\n # error 720 \"https:\/\/secure.mysite.tld\";\n # # If you want to keep the URLs intact, this also works:\n # error 720 \"https:\/\/\" + req.http.Host + req.url;\n # }\n #\n # Or to force a 302 temporary redirect, use error 721\n # if (req.http.Host ~ \"temp.mysite.tld\") {\n # # Temporary redirect\n # error 721 \"http:\/\/mysite.tld\/temp\";\n # }\n #\n\n # Some generic cookie manipulation, useful for all templates that follow\n # Remove the \"has_js\" cookie\n set req.http.Cookie = regsuball(req.http.Cookie, \"has_js=[^;]+(; )?\", \"\");\n\n # Remove any Satallite cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__gaid=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"_sdsat_[^=]+=[^;]+(; )?\", \"\");\n\n # Remove any Google Analytics based cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__utm.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"_ga=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmctr=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmcmd.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmccn.=[^;]+(; )?\", \"\");\n\n # Remove any Cloudflare cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__cfduid=[^;]+(; )?\", \"\");\n\n # Remove the Quant Capital cookies (added by some plugin, all __qca)\n set req.http.Cookie = regsuball(req.http.Cookie, \"__qc.=[^;]+(; )?\", \"\");\n\n # Remove the AddThis cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__atuvc=[^;]+(; )?\", \"\");\n\n # Remove a \";\" prefix in the cookie if present\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n\n # Are there cookies left with only spaces or that are empty?\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n\n # Normalize Accept-Encoding header\n # straight from the manual: https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/vary.html\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n # No point in compressing these\n remove req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n # unkown algorithm\n remove req.http.Accept-Encoding;\n }\n }\n\n # Remove all cookies for static files\n # A valid discussion could be held on this line: do you really need to cache static files that don't cause load? Only if you have memory left.\n # Sure, there's disk I\/O, but chances are your OS will already have these files in their buffers (thus memory).\n # Before you blindly enable this, have a read here: http:\/\/mattiasgeniar.be\/2012\/11\/28\/stop-caching-static-files\/\n if (req.url ~ \"^[^?]*\\.(bmp|bz2|css|doc|eot|flv|gif|gz|ico|jpeg|jpg|js|less|mp[34]|pdf|png|rar|rtf|swf|tar|tgz|txt|wav|woff|xml|zip)(\\?.*)?$\") {\n unset req.http.Cookie;\n return (lookup);\n }\n\n # Send Surrogate-Capability headers to announce ESI support to backend\n set req.http.Surrogate-Capability = \"key=ESI\/1.0\";\n\n # Include custom vcl_recv logic\n include \"conf.d\/receive\/wordpress.vcl\";\n\n if (req.http.Authorization || req.http.Cookie) {\n # Not cacheable by default\n return (pass);\n }\n\n return (lookup);\n}\n\nsub vcl_pipe {\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n # set bereq.http.connection = \"close\";\n # here. It is not set by default as it might break some broken web\n # applications, like IIS with NTLM authentication.\n\n #set bereq.http.Connection = \"Close\";\n return (pipe);\n}\n\nsub vcl_pass {\n return (pass);\n}\n\n# The data on which the hashing will take place\nsub vcl_hash {\n hash_data(req.url);\n\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n\n # hash cookies for object with auth\n if (req.http.Cookie) {\n hash_data(req.http.Cookie);\n }\n if (req.http.Authorization) {\n hash_data(req.http.Authorization);\n }\n\n return (hash);\n}\n\nsub vcl_hit {\n # Allow purges\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"purged\";\n }\n\n return (deliver);\n}\n\nsub vcl_miss {\n # Allow purges\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"purged\";\n }\n\n return (fetch);\n}\n\n# Handle the HTTP request coming from our backend \nsub vcl_fetch {\n set beresp.grace = 1h;\n\n # Include custom vcl_fetch logic\n include \"conf.d\/fetch\/wordpress.vcl\";\n\n # Parse ESI request and remove Surrogate-Control header\n if (beresp.http.Surrogate-Control ~ \"ESI\/1.0\") {\n unset beresp.http.Surrogate-Control;\n set beresp.do_esi = true;\n }\n\n # If the request to the backend returns a code is 5xx, restart the loop\n # If the number of restarts reaches the value of the parameter max_restarts,\n # the request will be error'ed. max_restarts defaults to 4. This prevents\n # an eternal loop in the event that, e.g., the object does not exist at all.\n if (beresp.status >= 500 && beresp.status <= 599){\n return(restart);\n }\n\n # Enable cache for all static files\n # The same argument as the static caches from above: monitor your cache size, if you get data nuked out of it, consider giving up the static file cache.\n # Before you blindly enable this, have a read here: http:\/\/mattiasgeniar.be\/2012\/11\/28\/stop-caching-static-files\/\n if (req.url ~ \"^[^?]*\\.(bmp|bz2|css|doc|eot|flv|gif|gz|ico|jpeg|jpg|js|less|mp[34]|pdf|png|rar|rtf|swf|tar|tgz|txt|wav|woff|xml|zip)(\\?.*)?$\") {\n unset beresp.http.set-cookie;\n }\n\n # Sometimes, a 301 or 302 redirect formed via Apache's mod_rewrite can mess with the HTTP port that is being passed along.\n # This often happens with simple rewrite rules in a scenario where Varnish runs on :80 and Apache on :8080 on the same box.\n # A redirect can then often redirect the end-user to a URL on :8080, where it should be :80.\n # This may need finetuning on your setup.\n #\n # To prevent accidental replace, we only filter the 301\/302 redirects for now.\n if (beresp.status == 301 || beresp.status == 302) {\n set beresp.http.Location = regsub(beresp.http.Location, \":[0-9]+\", \"\");\n }\n\n # Non private responses without cookies and with a ttl of 0 should be artificially extended to 5min\n if (beresp.ttl <= 0s && beresp.http.Cache-Control !~ \"private\" && (!beresp.http.Set-Cookie)) {\n set beresp.ttl = 1h;\n set beresp.http.X-Cache-Extended = \"1\";\n }\n\n # Set 2min cache if unset for static files\n if (beresp.ttl <= 0s || beresp.http.Set-Cookie || beresp.http.Vary == \"*\") {\n set beresp.ttl = 120s;\n return (hit_for_pass);\n }\n\n return (deliver);\n}\n\n# The routine when we deliver the HTTP request to the user\n# Last chance to modify headers that are sent to the client\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"cached\";\n } else {\n set resp.http.x-Cache = \"uncached\";\n }\n\n # Remove some headers: PHP version\n unset resp.http.X-Powered-By;\n\n # Remove some headers: Apache version & OS\n unset resp.http.Server;\n unset resp.http.X-Drupal-Cache;\n unset resp.http.X-Varnish;\n unset resp.http.Via;\n unset resp.http.Link;\n\n return (deliver);\n}\n\nsub vcl_error {\n if (obj.status >= 500 && obj.status <= 599 && req.restarts < 4) {\n # 4 retry for 5xx error\n return(restart);\n } elsif (obj.status >= 400 && obj.status <= 499 ) {\n # use 404 error page for 4xx error\n include \"conf.d\/error-404.vcl\";\n } elsif (obj.status <= 200 && obj.status >= 299 ) {\n # for other errors (not 5xx, not 4xx and not 2xx)\n include \"conf.d\/error.vcl\";\n } elseif (obj.status == 720) {\n # We use this special error status 720 to force redirects with 301 (permanent) redirects\n # To use this, call the following from anywhere in vcl_recv: error 720 \"http:\/\/host\/new.html\"\n set obj.status = 301;\n set obj.http.Location = obj.response;\n return (deliver);\n } elseif (obj.status == 721) {\n # And we use error status 721 to force redirects with a 302 (temporary) redirect\n # To use this, call the following from anywhere in vcl_recv: error 720 \"http:\/\/host\/new.html\"\n set obj.status = 302;\n set obj.http.Location = obj.response;\n return (deliver);\n } else {\n include \"conf.d\/error.vcl\";\n }\n\n return (deliver);\n}\n\nsub vcl_init {\n return (ok);\n}\n\nsub vcl_fini {\n return (ok);\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"ae97c3ebcfd3816ea20694d732f4776c76825888","subject":"Strip last-modified headers from wms requests for data overlays and otherwise don't cache (so logged in and logged out user doesn't see the same data)","message":"Strip last-modified headers from wms requests for data overlays and otherwise don't cache (so logged in and logged out user doesn't see the same data)\n","repos":"AstunTechnology\/NRW_FishMapMon,AstunTechnology\/NRW_FishMapMon,AstunTechnology\/NRW_FishMapMon,AstunTechnology\/NRW_FishMapMon","old_file":"config\/varnish\/default.vcl","new_file":"config\/varnish\/default.vcl","new_contents":"# This is a basic VCL configuration file for varnish. See the vcl(7)\n# man page for details on VCL syntax and semantics.\n# \n# Default backend definition. Set this to point to your content\n# server.\n# \nbackend cy {\n .host = \"cy.blah\";\n .port = \"8001\";\n}\n\nbackend en {\n .host = \"en.blah\";\n .port = \"8002\";\n}\n\n\n# \n# Below is a commented-out copy of the default VCL logic. If you\n# redefine any of these subroutines, the built-in logic will be\n# appended to your code.\nsub vcl_recv {\n\tif (req.http.host ~ \"(?i)^(www.)?cy.blah\") {\n\t\tset req.http.host = \"cy.blah\";\n\t\tset req.backend = cy;\n\t}\n\telsif (req.http.host ~ \"(?i)^(www.)?en.blah\") {\n\t\tset req.http.host = \"en.blah\";\n\t\tset req.backend = en;\n\t}\n\n\tif ( req.url ~ \"^\/wms\\?map=fishmap\" ) {\n\t\treturn (pass);\n\t}\n\n\tif ( req.url ~ \"^\/static\/\" ) {\n\t\treturn (lookup);\n\t}\n\tif ( req.url ~ \"^\/wms\" ) {\n\t\treturn (lookup);\n\t}\n# if (req.restarts == 0) {\n# \tif (req.http.x-forwarded-for) {\n# \t set req.http.X-Forwarded-For =\n# \t\treq.http.X-Forwarded-For + \", \" + client.ip;\n# \t} else {\n# \t set req.http.X-Forwarded-For = client.ip;\n# \t}\n# }\n# if (req.request != \"GET\" &&\n# req.request != \"HEAD\" &&\n# req.request != \"PUT\" &&\n# req.request != \"POST\" &&\n# req.request != \"TRACE\" &&\n# req.request != \"OPTIONS\" &&\n# req.request != \"DELETE\") {\n# \/* Non-RFC2616 or CONNECT which is weird. *\/\n# return (pipe);\n# }\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization || req.http.Cookie) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n return (lookup);\n}\n# \n# sub vcl_pipe {\n# # Note that only the first request to the backend will have\n# # X-Forwarded-For set. If you use X-Forwarded-For and want to\n# # have it set for all requests, make sure to have:\n# # set bereq.http.connection = \"close\";\n# # here. It is not set by default as it might break some broken web\n# # applications, like IIS with NTLM authentication.\n# return (pipe);\n# }\n# \n# sub vcl_pass {\n# return (pass);\n# }\n# \n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (hash);\n# }\n# \n# sub vcl_hit {\n# return (deliver);\n# }\n# \n# sub vcl_miss {\n# return (fetch);\n# }\n# \nsub vcl_fetch {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Vary == \"*\") {\n# \t\t\/*\n# \t\t * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# \t\t *\/\n# \t\tset beresp.ttl = 120 s;\n# \t\treturn (hit_for_pass);\n# }\n\tif ( req.url ~ \"^\/wms\\?map=fishmap\" ) {\n\t\tunset beresp.http.last-modified;\n\t\treturn (hit_for_pass);\n\t}\n\tif ( req.url ~ \"^\/wms\" ) {\n \t\tunset beresp.http.set-cookie;\n\t\tunset beresp.http.expires;\n \t\tset beresp.ttl = 1w;\n\t set beresp.http.Cache-Control = \"max-age=1900\";\n\t}\t\t\n return (deliver);\n}\n# \n# sub vcl_deliver {\n# return (deliver);\n# }\n# \n# sub vcl_error {\n# set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n# set obj.http.Retry-After = \"5\";\n# synthetic {\"\n# <?xml version=\"1.0\" encoding=\"utf-8\"?>\n# <!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n# \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n# <html>\n# <head>\n# <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n# <\/head>\n# <body>\n# <h1>Error \"} + obj.status + \" \" + obj.response + {\"<\/h1>\n# <p>\"} + obj.response + {\"<\/p>\n# <h3>Guru Meditation:<\/h3>\n# <p>XID: \"} + req.xid + {\"<\/p>\n# <hr>\n# <p>Varnish cache server<\/p>\n# <\/body>\n# <\/html>\n# \"};\n# return (deliver);\n# }\n# \n# sub vcl_init {\n# \treturn (ok);\n# }\n# \n# sub vcl_fini {\n# \treturn (ok);\n# }\n","old_contents":"# This is a basic VCL configuration file for varnish. See the vcl(7)\n# man page for details on VCL syntax and semantics.\n# \n# Default backend definition. Set this to point to your content\n# server.\n# \nbackend cy {\n .host = \"cy.blah\";\n .port = \"8001\";\n}\n\nbackend en {\n .host = \"en.blah\";\n .port = \"8002\";\n}\n\n\n# \n# Below is a commented-out copy of the default VCL logic. If you\n# redefine any of these subroutines, the built-in logic will be\n# appended to your code.\nsub vcl_recv {\n\tif (req.http.host ~ \"(?i)^(www.)?cy.blah\") {\n\t\tset req.http.host = \"cy.blah\";\n\t\tset req.backend = cy;\n\t}\n\telsif (req.http.host ~ \"(?i)^(www.)?en.blah\") {\n\t\tset req.http.host = \"en.blah\";\n\t\tset req.backend = en;\n\t}\n\n\tif ( req.url ~ \"^\/wms\\?map=fishmap\" ) {\n\t\treturn (pass);\n\t}\n\n\tif ( req.url ~ \"^\/static\/\" ) {\n\t\treturn (lookup);\n\t}\n\tif ( req.url ~ \"^\/wms\" ) {\n\t\treturn (lookup);\n\t}\n# if (req.restarts == 0) {\n# \tif (req.http.x-forwarded-for) {\n# \t set req.http.X-Forwarded-For =\n# \t\treq.http.X-Forwarded-For + \", \" + client.ip;\n# \t} else {\n# \t set req.http.X-Forwarded-For = client.ip;\n# \t}\n# }\n# if (req.request != \"GET\" &&\n# req.request != \"HEAD\" &&\n# req.request != \"PUT\" &&\n# req.request != \"POST\" &&\n# req.request != \"TRACE\" &&\n# req.request != \"OPTIONS\" &&\n# req.request != \"DELETE\") {\n# \/* Non-RFC2616 or CONNECT which is weird. *\/\n# return (pipe);\n# }\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization || req.http.Cookie) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n return (lookup);\n}\n# \n# sub vcl_pipe {\n# # Note that only the first request to the backend will have\n# # X-Forwarded-For set. If you use X-Forwarded-For and want to\n# # have it set for all requests, make sure to have:\n# # set bereq.http.connection = \"close\";\n# # here. It is not set by default as it might break some broken web\n# # applications, like IIS with NTLM authentication.\n# return (pipe);\n# }\n# \n# sub vcl_pass {\n# return (pass);\n# }\n# \n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (hash);\n# }\n# \n# sub vcl_hit {\n# return (deliver);\n# }\n# \n# sub vcl_miss {\n# return (fetch);\n# }\n# \nsub vcl_fetch {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Vary == \"*\") {\n# \t\t\/*\n# \t\t * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# \t\t *\/\n# \t\tset beresp.ttl = 120 s;\n# \t\treturn (hit_for_pass);\n# }\n\tif ( req.url ~ \"^\/wms\" ) {\n \t\tunset beresp.http.set-cookie;\n\t\tunset beresp.http.expires;\n \t\tset beresp.ttl = 1w;\n\t set beresp.http.Cache-Control = \"max-age=1900\";\n\t}\t\t\n return (deliver);\n}\n# \n# sub vcl_deliver {\n# return (deliver);\n# }\n# \n# sub vcl_error {\n# set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n# set obj.http.Retry-After = \"5\";\n# synthetic {\"\n# <?xml version=\"1.0\" encoding=\"utf-8\"?>\n# <!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n# \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n# <html>\n# <head>\n# <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n# <\/head>\n# <body>\n# <h1>Error \"} + obj.status + \" \" + obj.response + {\"<\/h1>\n# <p>\"} + obj.response + {\"<\/p>\n# <h3>Guru Meditation:<\/h3>\n# <p>XID: \"} + req.xid + {\"<\/p>\n# <hr>\n# <p>Varnish cache server<\/p>\n# <\/body>\n# <\/html>\n# \"};\n# return (deliver);\n# }\n# \n# sub vcl_init {\n# \treturn (ok);\n# }\n# \n# sub vcl_fini {\n# \treturn (ok);\n# }\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"c226c0edcdfc18547d2e8382688920339ac511c6","subject":"Update scheme","message":"Update scheme\n","repos":"kevinquinnyo\/varnish-devicedetect,wikp\/varnish-devicedetect,wikp\/varnish-devicedetect,varnish\/varnish-devicedetect,varnish\/varnish-devicedetect,kevinquinnyo\/varnish-devicedetect","old_file":"devicedetect.vcl","new_file":"devicedetect.vcl","new_contents":"# Copyright (c) 2012-2014 Varnish Software AS\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions\n# are met:\n# 1. Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n# 2. Redistributions in binary form must reproduce the above copyright\n# notice, this list of conditions and the following disclaimer in the\n# documentation and\/or other materials provided with the distribution.\n#\n# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n# ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n# SUCH DAMAGE.\n#\n# detectdevice.vcl - regex based device detection for Varnish\n# https:\/\/github.com\/varnish\/varnish-devicedetect\/\n#\n# Author: Lasse Karstensen <lkarsten@varnish-software.com>\n\nsub devicedetect {\n\tunset req.http.X-UA-Device;\n\tset req.http.X-UA-Device = \"pc\";\n\n\t# Handle that a cookie may override the detection alltogether.\n\tif (req.http.Cookie ~ \"(?i)X-UA-Device-force\") {\n\t\t\/* ;?? means zero or one ;, non-greedy to match the first. *\/\n\t\tset req.http.X-UA-Device = regsub(req.http.Cookie, \"(?i).*X-UA-Device-force=([^;]+);??.*\", \"\\1\");\n\t\t\/* Clean up our mess in the cookie header *\/\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|; ) *X-UA-Device-force=[^;]+;? *\", \"\\1\");\n\t\t\/* If the cookie header is now empty, or just whitespace, unset it. *\/\n\t\tif (req.http.Cookie ~ \"^ *$\") { unset req.http.Cookie; }\n\t} else {\n if (req.http.User-Agent ~ \"\\(compatible; Googlebot-Mobile\/2.1; \\+http:\/\/www.google.com\/bot.html\\)\" ||\n (req.http.User-Agent ~ \"iPhone\" && req.http.User-Agent ~ \"\\(compatible; Googlebot\/2.1; \\+http:\/\/www.google.com\/bot.html\")) {\n set req.http.X-UA-Device = \"mobile-bot\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)(ads|google|bing|msn|yandex|baidu|ro|career|)bot\" ||\n\t\t req.http.User-Agent ~ \"(?i)(baidu|jike|symantec)spider\" ||\n\t\t req.http.User-Agent ~ \"(?i)scanner\" ||\n\t\t req.http.User-Agent ~ \"(?i)(web)crawler\") {\n\t\t\tset req.http.X-UA-Device = \"bot\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ipad\") { set req.http.X-UA-Device = \"tablet-ipad\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ip(hone|od)\") { set req.http.X-UA-Device = \"mobile-iphone\"; }\n\t\t\/* how do we differ between an android phone and an android tablet?\n\t\t http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent *\/\n\t\telsif (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") { set req.http.X-UA-Device = \"mobile-android\"; }\n\t\t\/\/ android 3\/honeycomb was just about tablet-only, and any phones will probably handle a bigger page layout.\n\t\telsif (req.http.User-Agent ~ \"(?i)android 3\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\t\/* Opera Mobile *\/\n\t\telsif (req.http.User-Agent ~ \"Opera Mobi\") { set req.http.X-UA-Device = \"mobile-smartphone\"; }\n\t\t\/\/ May very well give false positives towards android tablets. Suggestions welcome.\n\t\telsif (req.http.User-Agent ~ \"(?i)android\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\telsif (req.http.User-Agent ~ \"PlayBook; U; RIM Tablet\") { set req.http.X-UA-Device = \"tablet-rim\"; }\n\t\telsif (req.http.User-Agent ~ \"hp-tablet.*TouchPad\") { set req.http.X-UA-Device = \"tablet-hp\"; }\n\t\telsif (req.http.User-Agent ~ \"Kindle\/3\") { set req.http.X-UA-Device = \"tablet-kindle\"; }\n\t\telsif (req.http.User-Agent ~ \"Touch.+Tablet PC\") { set req.http.X-UA-Device = \"tablet-microsoft\"; }\n\t\telsif (req.http.User-Agent ~ \"Mobile.+Firefox\") { set req.http.X-UA-Device = \"mobile-firefoxos\"; }\n\t\telsif (req.http.User-Agent ~ \"^HTC\" ||\n\t\t req.http.User-Agent ~ \"Fennec\" ||\n\t\t req.http.User-Agent ~ \"IEMobile\" ||\n\t\t req.http.User-Agent ~ \"BlackBerry\" ||\n\t\t req.http.User-Agent ~ \"BB10.*Mobile\" ||\n\t\t req.http.User-Agent ~ \"GT-.*Build\/GINGERBREAD\" ||\n\t\t req.http.User-Agent ~ \"SymbianOS.*AppleWebKit\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-smartphone\";\n\t\t}\n\t\telsif (req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)^sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)^nokia\" ||\n\t\t req.http.User-Agent ~ \"(?i)^samsung\" ||\n\t\t req.http.User-Agent ~ \"(?i)^lg\" ||\n\t\t req.http.User-Agent ~ \"(?i)bada\" ||\n\t\t req.http.User-Agent ~ \"(?i)blazer\" ||\n\t\t req.http.User-Agent ~ \"(?i)cellphone\" ||\n\t\t req.http.User-Agent ~ \"(?i)iemobile\" ||\n\t\t req.http.User-Agent ~ \"(?i)midp-2.0\" ||\n\t\t req.http.User-Agent ~ \"(?i)u990\" ||\n\t\t req.http.User-Agent ~ \"(?i)netfront\" ||\n\t\t req.http.User-Agent ~ \"(?i)opera mini\" ||\n\t\t req.http.User-Agent ~ \"(?i)palm\" ||\n\t\t req.http.User-Agent ~ \"(?i)nintendo wii\" ||\n\t\t req.http.User-Agent ~ \"(?i)playstation portable\" ||\n\t\t req.http.User-Agent ~ \"(?i)portalmmm\" ||\n\t\t req.http.User-Agent ~ \"(?i)proxinet\" ||\n\t\t req.http.User-Agent ~ \"(?i)sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)windows\\ ?ce\" ||\n\t\t req.http.User-Agent ~ \"(?i)winwap\" ||\n\t\t req.http.User-Agent ~ \"(?i)eudoraweb\" ||\n\t\t req.http.User-Agent ~ \"(?i)htc\" ||\n\t\t req.http.User-Agent ~ \"(?i)240x320\" ||\n\t\t req.http.User-Agent ~ \"(?i)avantgo\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-generic\";\n\t\t}\n\t}\n}\n","old_contents":"# Copyright (c) 2012-2014 Varnish Software AS\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions\n# are met:\n# 1. Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n# 2. Redistributions in binary form must reproduce the above copyright\n# notice, this list of conditions and the following disclaimer in the\n# documentation and\/or other materials provided with the distribution.\n#\n# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n# ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n# SUCH DAMAGE.\n#\n# detectdevice.vcl - regex based device detection for Varnish\n# http:\/\/github.com\/varnish\/varnish-devicedetect\/\n#\n# Author: Lasse Karstensen <lkarsten@varnish-software.com>\n\nsub devicedetect {\n\tunset req.http.X-UA-Device;\n\tset req.http.X-UA-Device = \"pc\";\n\n\t# Handle that a cookie may override the detection alltogether.\n\tif (req.http.Cookie ~ \"(?i)X-UA-Device-force\") {\n\t\t\/* ;?? means zero or one ;, non-greedy to match the first. *\/\n\t\tset req.http.X-UA-Device = regsub(req.http.Cookie, \"(?i).*X-UA-Device-force=([^;]+);??.*\", \"\\1\");\n\t\t\/* Clean up our mess in the cookie header *\/\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|; ) *X-UA-Device-force=[^;]+;? *\", \"\\1\");\n\t\t\/* If the cookie header is now empty, or just whitespace, unset it. *\/\n\t\tif (req.http.Cookie ~ \"^ *$\") { unset req.http.Cookie; }\n\t} else {\n if (req.http.User-Agent ~ \"\\(compatible; Googlebot-Mobile\/2.1; \\+http:\/\/www.google.com\/bot.html\\)\" ||\n (req.http.User-Agent ~ \"iPhone\" && req.http.User-Agent ~ \"\\(compatible; Googlebot\/2.1; \\+http:\/\/www.google.com\/bot.html\")) {\n set req.http.X-UA-Device = \"mobile-bot\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)(ads|google|bing|msn|yandex|baidu|ro|career|)bot\" ||\n\t\t req.http.User-Agent ~ \"(?i)(baidu|jike|symantec)spider\" ||\n\t\t req.http.User-Agent ~ \"(?i)scanner\" ||\n\t\t req.http.User-Agent ~ \"(?i)(web)crawler\") {\n\t\t\tset req.http.X-UA-Device = \"bot\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ipad\") { set req.http.X-UA-Device = \"tablet-ipad\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ip(hone|od)\") { set req.http.X-UA-Device = \"mobile-iphone\"; }\n\t\t\/* how do we differ between an android phone and an android tablet?\n\t\t http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent *\/\n\t\telsif (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") { set req.http.X-UA-Device = \"mobile-android\"; }\n\t\t\/\/ android 3\/honeycomb was just about tablet-only, and any phones will probably handle a bigger page layout.\n\t\telsif (req.http.User-Agent ~ \"(?i)android 3\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\t\/* Opera Mobile *\/\n\t\telsif (req.http.User-Agent ~ \"Opera Mobi\") { set req.http.X-UA-Device = \"mobile-smartphone\"; }\n\t\t\/\/ May very well give false positives towards android tablets. Suggestions welcome.\n\t\telsif (req.http.User-Agent ~ \"(?i)android\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\telsif (req.http.User-Agent ~ \"PlayBook; U; RIM Tablet\") { set req.http.X-UA-Device = \"tablet-rim\"; }\n\t\telsif (req.http.User-Agent ~ \"hp-tablet.*TouchPad\") { set req.http.X-UA-Device = \"tablet-hp\"; }\n\t\telsif (req.http.User-Agent ~ \"Kindle\/3\") { set req.http.X-UA-Device = \"tablet-kindle\"; }\n\t\telsif (req.http.User-Agent ~ \"Touch.+Tablet PC\") { set req.http.X-UA-Device = \"tablet-microsoft\"; }\n\t\telsif (req.http.User-Agent ~ \"Mobile.+Firefox\") { set req.http.X-UA-Device = \"mobile-firefoxos\"; }\n\t\telsif (req.http.User-Agent ~ \"^HTC\" ||\n\t\t req.http.User-Agent ~ \"Fennec\" ||\n\t\t req.http.User-Agent ~ \"IEMobile\" ||\n\t\t req.http.User-Agent ~ \"BlackBerry\" ||\n\t\t req.http.User-Agent ~ \"BB10.*Mobile\" ||\n\t\t req.http.User-Agent ~ \"GT-.*Build\/GINGERBREAD\" ||\n\t\t req.http.User-Agent ~ \"SymbianOS.*AppleWebKit\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-smartphone\";\n\t\t}\n\t\telsif (req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)^sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)^nokia\" ||\n\t\t req.http.User-Agent ~ \"(?i)^samsung\" ||\n\t\t req.http.User-Agent ~ \"(?i)^lg\" ||\n\t\t req.http.User-Agent ~ \"(?i)bada\" ||\n\t\t req.http.User-Agent ~ \"(?i)blazer\" ||\n\t\t req.http.User-Agent ~ \"(?i)cellphone\" ||\n\t\t req.http.User-Agent ~ \"(?i)iemobile\" ||\n\t\t req.http.User-Agent ~ \"(?i)midp-2.0\" ||\n\t\t req.http.User-Agent ~ \"(?i)u990\" ||\n\t\t req.http.User-Agent ~ \"(?i)netfront\" ||\n\t\t req.http.User-Agent ~ \"(?i)opera mini\" ||\n\t\t req.http.User-Agent ~ \"(?i)palm\" ||\n\t\t req.http.User-Agent ~ \"(?i)nintendo wii\" ||\n\t\t req.http.User-Agent ~ \"(?i)playstation portable\" ||\n\t\t req.http.User-Agent ~ \"(?i)portalmmm\" ||\n\t\t req.http.User-Agent ~ \"(?i)proxinet\" ||\n\t\t req.http.User-Agent ~ \"(?i)sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)windows\\ ?ce\" ||\n\t\t req.http.User-Agent ~ \"(?i)winwap\" ||\n\t\t req.http.User-Agent ~ \"(?i)eudoraweb\" ||\n\t\t req.http.User-Agent ~ \"(?i)htc\" ||\n\t\t req.http.User-Agent ~ \"(?i)240x320\" ||\n\t\t req.http.User-Agent ~ \"(?i)avantgo\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-generic\";\n\t\t}\n\t}\n}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"8909318e4cb4e80f481c6967eaf6d6fcaacf6434","subject":"Remove cookie _gat for Google analytics","message":"Remove cookie _gat for Google analytics\n","repos":"nooku\/nooku-platform,nooku\/nooku-platform,timble\/kodekit-platform,timble\/kodekit-platform,timble\/kodekit-platform,timble\/kodekit-platform,nooku\/nooku-platform,timble\/kodekit-platform,nooku\/nooku-platform,nooku\/nooku-platform","old_file":"component\/varnish\/resources\/varnish\/nooku.vcl","new_file":"component\/varnish\/resources\/varnish\/nooku.vcl","new_contents":"vcl 4.0;\n# Based on: https:\/\/github.com\/mattiasgeniar\/varnish-4.0-configuration-templates\/blob\/master\/default.vcl\n\nimport std;\nimport directors;\n\nprobe health\n{\n #.url = \"\/varnish-enabled\";\n # We prefer to only do a HEAD \/\n .request =\n \"HEAD \/varnish-enabled HTTP\/1.1\"\n \"Host: localhost\"\n \"Connection: close\";\n .interval = 5s; # check the health of each backend every 5 seconds\n .timeout = 1s; # timing out after 1 second.\n # If 3 out of the last 5 polls succeeded the backend is considered healthy, otherwise it will be marked as sick\n .window = 5;\n .threshold = 3;\n .expected_response = 200;\n}\n\nbackend default\n{\n .host = \"127.0.0.1\"; # IP or Hostname of backend\n .port = \"8080\"; # Port Apache or whatever is listening\n .max_connections = 300; # That's it\n .probe = health;\n .connect_timeout = 600s; # How long to wait before we receive a first byte from our backend?\n .first_byte_timeout = 600s; # How long to wait for a backend connection?\n .between_bytes_timeout = 600s; # How long to wait between bytes received from our backend?\n}\n\nbackend passthrough\n{\n .host = \"127.0.0.1\"; # IP or Hostname of backend\n .port = \"8080\"; # Port Apache or whatever is listening\n}\n\nacl localhost\n{\n \"localhost\";\n \"33.33.33.63\";\n \"::1\";\n}\n\nsub vcl_init\n{\n # Called when VCL is loaded, before any requests pass through it.\n # Typically used to initialize VMODs.\n\n new vdir = directors.round_robin();\n vdir.add_backend(default);\n # vdir.add_backend(server...);\n # vdir.add_backend(servern);\n}\n\nsub vcl_recv\n{\n # Called at the beginning of a request, after the complete request has been received and parsed.\n # Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable,\n # which backend to use and if needed to modify the request.\n\n # Send all traffic to the vdir director\n set req.backend_hint = vdir.backend();\n\n if (req.restarts == 0)\n {\n # Set or append the client.ip to X-Forwarded-For header\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n\n set req.http.X-Forwarded-By = server.ip;\n set req.http.X-Forwarded-Port = std.port(client.ip);\n }\n\n # Normalize the header, remove the port (in case you're testing this on various TCP ports)\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n # Normalize the query arguments\n set req.url = std.querysort(req.url);\n\n # Allow purging\n if (req.method == \"PURGE\")\n {\n # purge is the ACL defined at the begining\n if (!client.ip ~ localhost) {\n return (synth(405, \"This IP is not allowed to send PURGE requests.\"));\n }\n\n # If you got this stage (and didn't error out above), purge the cached result\n return (purge);\n }\n\n # Check if we've still enabled Varnish, if not, passthrough every request\n if (! std.healthy(req.backend_hint))\n {\n set req.backend_hint = passthrough;\n return (pass);\n }\n\n # Only deal with \"normal\" types\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"PATCH\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n # Implementing websocket support (https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html)\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n # Only cache GET or HEAD requests. This makes sure the POST requests are always passed.\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n # Specific Nooku Platform rules\n\n # Do not cache \/administrator\n if(req.url ~ \"^\/administrator\") {\n return (pass);\n }\n\n # Specific Nooku Server rules\n\n # Do not cache webgrind.nooku.dev\n if (req.http.host == \"webgrind.nooku.dev\") {\n return (pass);\n }\n\n # Do not cache phpmyadmin.nooku.dev\n if (req.http.host == \"phpmyadmin.nooku.dev\") {\n return (pass);\n }\n\n # Do not cache \/apc and \/phpinfo\n if (req.url == \"\/apc\" || req.url == \"\/phpinfo\") {\n return (pass);\n }\n\n # Generic URL manipulation, useful for all templates that follow\n\n # Remove the Google Analytics added parameters, useless for our backend\n if (req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=\") {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # Strip hash, server doesn't need it.\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n # Strip a trailing ? if it exists\n if (req.url ~ \"\\?$\") {\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # Cookie manipulation\n\n # Remove the \"has_js\" cookie\n set req.http.Cookie = regsuball(req.http.Cookie, \"has_js=[^;]+(; )?\", \"\");\n\n # Remove any Google Analytics based cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__utm.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"_ga=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"_gat=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmctr=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmcmd.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmccn.=[^;]+(; )?\", \"\");\n\n # Remove DoubleClick offensive cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__gads=[^;]+(; )?\", \"\");\n\n # Remove the Quant Capital cookies (added by some plugin, all __qca)\n set req.http.Cookie = regsuball(req.http.Cookie, \"__qc.=[^;]+(; )?\", \"\");\n\n # Remove the AddThis cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__atuv.=[^;]+(; )?\", \"\");\n\n # Remove a \";\" prefix in the cookie if present\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n\n # Remove the csrf_token cookie\n set req.http.Cookie = regsuball(req.http.Cookie, \"csrf_token=[^;]+(; )?\", \"\");\n\n # Are there cookies left with only spaces or that are empty?\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n\n # Large static files are delivered directly to the end-user without waiting for Varnish to fully read the file first.\n # Varnish 4 supports Streaming, so set do_stream in vcl_backend_response()\n if (req.url ~ \"^[^?]*\\.(mp[34]|rar|tar|tgz|gz|wav|zip|bz2|xz|7z|avi|mov|og[gvaxm]|mpe?g|mk[av])(\\?.*)?$\") {\n unset req.http.Cookie;\n return (hash);\n }\n\n # Remove all cookies for static files\n # Before you blindly enable this read: https:\/\/ma.ttias.be\/stop-caching-static-files\/\n #if (req.method == \"GET\")\n #{\n # # Cache files with these extensions and remove cookie\n # if (req.url ~ \"^[^?]*\\.(bmp|bz2|css|doc|eot|flv|gif|gz|ico|jpeg|jpg|js|less|pdf|png|rtf|swf|txt|woff|xml)(\\?.*)?$\") {\n # unset req.http.Cookie;\n # return (hash);\n # }\n #}\n\n # Normalize Accept-Encoding header\n # straight from the manual: https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/vary.html\n # TODO: Test if it's still needed, Varnish 4 now does this by itself if http_gzip_support = on\n # https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/compression.html\n # https:\/\/www.varnish-cache.org\/docs\/trunk\/phk\/gzip.html\n if (req.http.Accept-Encoding)\n {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n # No point in compressing these\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n # unkown algorithm\n unset req.http.Accept-Encoding;\n }\n }\n\n if (req.http.Cache-Control ~ \"(?i)no-cache\" && client.ip ~ localhost)\n {\n # http:\/\/varnish.projects.linpro.no\/wiki\/VCLExampleEnableForceRefresh\n # Ignore requests via proxy caches and badly behaved crawlers\n # like msnbot that send no-cache with every request.\n if (! (req.http.Via || req.http.User-Agent ~ \"(?i)bot\" || req.http.X-Purge))\n {\n # Doesn't seems to refresh the object in the cache\n set req.hash_always_miss = true;\n\n # Couple this with restart in vcl_purge and X-Purge header to avoid loops\n return(purge);\n }\n }\n\n # Send Surrogate-Capability headers to announce ESI support to backend\n set req.http.Surrogate-Capability = \"varnish=ESI\/1.0\";\n\n # Requests that require authorization are not cacheable by default\n if (req.http.Authorization) {\n return (pass);\n }\n\n # We do not support SPDY or HTTP\/2.0\n if (req.method == \"PRI\") {\n return (synth(405));\n }\n\n return (hash);\n}\n\n# Called upon entering pipe mode. In this mode, the request is passed on to the backend, and any further data from both\n# the client and backend is passed on unaltered until either end closes the connection. Basically, Varnish will degrade\n# into a simple TCP proxy, shuffling bytes back and forth. For a connection in pipe mode, no other VCL subroutine will\n# ever get called after vcl_pipe.\nsub vcl_pipe\n{\n # Note that only the first request to the backend will have X-Forwarded-For set.\n # If you use X-Forwarded-For and want to have it set for all requests, make sure to have:\n # set bereq.http.connection = \"close\";\n # It is not set by default as it might break some broken web applications, like IIS with NTLM authentication.\n # set bereq.http.Connection = \"Close\";\n\n # Implementing websocket support (https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html)\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n\n return (pipe);\n}\n\n# Called upon entering pass mode. In this mode, the request is passed on to the backend, and the backend's response\n# is passed on to the client, but is not entered into the cache. Subsequent requests submitted over the same client\n# connection are handled normally.\nsub vcl_pass\n{\n return (fetch);\n}\n\n# Called after vcl_recv to create a hash value for the request. This is used as a key to look up the object in Varnish.\nsub vcl_hash\n{\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n\n # hash cookies for requests that have them\n if (req.http.Cookie) {\n hash_data(req.http.Cookie);\n }\n}\n\n# Called when a cache lookup is successful.\nsub vcl_hit\n{\n # A pure unadultered hit, deliver it\n if (obj.ttl >= 0s) {\n return (deliver);\n }\n\n # https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-grace.html\n # When several clients are requesting the same page Varnish will send one request to the backend and place the\n # others on hold while fetching one copy from the backend. In some products this is called request coalescing and\n # Varnish does this automatically.\n\n # If you are serving thousands of hits per second the queue of waiting requests can get huge. There are two\n # potential problems - one is a thundering herd problem - suddenly releasing a thousand threads to serve content\n # might send the load sky high. Secondly - nobody likes to wait. To deal with this we can instruct Varnish to keep\n # the objects in cache beyond their TTL and to serve the waiting requests somewhat stale content.\n\n # if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n # return (deliver);\n # } else {\n # return (fetch);\n # }\n\n # We have no fresh fish. Lets look at the stale ones.\n if (std.healthy(req.backend_hint))\n {\n # Backend is healthy. Limit age to 10s.\n if (obj.ttl + 10s > 0s)\n {\n #set req.http.grace = \"normal(limited)\";\n return (deliver);\n }\n else\n {\n # No candidate for grace. Fetch a fresh object.\n return(fetch);\n }\n }\n else\n {\n # backend is sick - use full grace\n if (obj.ttl + obj.grace > 0s)\n {\n #set req.http.grace = \"full\";\n return (deliver);\n }\n else\n {\n # no graced object.\n return (fetch);\n }\n }\n\n # fetch & deliver once we get the result\n return (fetch); # Dead code, keep as a safeguard\n}\n\n# Called after a cache lookup if the requested document was not found in the cache. Its purpose is to decide whether\n# or not to attempt to retrieve the document from the backend, and which backend to use.\nsub vcl_miss\n{\n return (fetch);\n}\n\n # Called after the response headers has been successfully retrieved from the backend.\nsub vcl_backend_response\n{\n # Enable ESI handling\n if (beresp.http.Surrogate-Control ~ \"ESI\/1.0\" ) {\n set beresp.do_esi = true;\n }\n\n # Store the csrf_token cookie temporarily if the response is cacheabale\n if (beresp.http.Set-Cookie && !beresp.uncacheable)\n {\n set beresp.http.X-Varnish-Cookie = beresp.http.Set-Cookie;\n unset beresp.http.Set-Cookie;\n }\n\n # Cache handling all static files\n if (bereq.method == \"GET\")\n {\n # Before you blindly enable this, read: https:\/\/ma.ttias.be\/stop-caching-static-files\/\n #if (bereq.url ~ \"^[^?]*\\.(bmp|bz2|css|doc|eot|flv|gif|gz|ico|jpeg|jpg|js|less|mp[34]|pdf|png|rar|rtf|swf|tar|tgz|txt|wav|woff|xml|zip)(\\?.*)?$\") {\n # unset beresp.http.Set-Cookie;\n #}\n\n # Large static files are delivered directly to the end-user without waiting for Varnish to fully read the\n # file first. Check memory usage it'll grow in fetch_chunksize blocks (128k by default) if the backend\n # doesn't send a Content-Length header. Only enable it for large files\n if (bereq.url ~ \"^[^?]*\\.(mp[34]|rar|tar|tgz|gz|wav|zip|bz2|xz|7z|avi|mov|og[gvaxm]|mpe?g|mk[av])(\\?.*)?$\")\n {\n unset beresp.http.Set-Cookie;\n\n # Use streaming to avoid locking\n set beresp.do_stream = true;\n\n # Don't try to compress it for storage\n set beresp.do_gzip = false;\n\n # Disable Transfer-encoding chunked when serving HTML5 video\n # See : http:\/\/stackoverflow.com\/questions\/23643233\/how-do-i-disable-transfer-encoding-chunked-encoding-in-varnish\n # See : https:\/\/www.varnish-cache.org\/trac\/ticket\/1506\n if(beresp.http.Content-Type ~ \"video\") {\n set beresp.do_stream = true;\n set beresp.do_esi = true;\n }\n }\n\n # Set 2min cache if unset for static files\n if (beresp.ttl <= 0s || beresp.http.Set-Cookie || beresp.http.Vary == \"*\")\n {\n set beresp.ttl = 120s; # Important, you shouldn't rely on this, SET YOUR HEADERS in the backend\n set beresp.uncacheable = true;\n\n return (deliver);\n }\n }\n\n # Sometimes, a 301 or 302 redirect formed via Apache's mod_rewrite can mess with the HTTP port that is being passed along.\n # This often happens with simple rewrite rules in a scenario where Varnish runs on :80 and Apache on :8080 on the same box.\n # A redirect can then often redirect the end-user to a URL on :8080, where it should be :80.\n # This may need finetuning on your setup.\n #\n # To prevent accidental replace, we only filter the 301\/302 redirects for now.\n if (beresp.status == 301 || beresp.status == 302) {\n set beresp.http.Location = regsub(beresp.http.Location, \":[0-9]+\", \"\");\n }\n\n # Do not cache errors from the backend\n if (beresp.status >= 400)\n {\n set beresp.uncacheable = true;\n set beresp.ttl = 0s;\n\n return (deliver);\n }\n\n # Allow stale content, in case the backend goes down. Make Varnish keep all objects for 6 hours beyond their TTL\n set beresp.grace = 6h;\n\n # Set ban-lurker friendly custom headers\n set beresp.http.X-Varnish-Url = bereq.url;\n set beresp.http.X-Varnish-Host = bereq.http.host;\n\n return (deliver);\n}\n\n# Called when the backend returns an error\nsub vcl_backend_error\n{\n if (beresp.status == 503 && bereq.retries < 5)\n {\n set beresp.http.X-Varnish-Retries = bereq.retries;\n return(retry);\n }\n\n return(deliver);\n}\n\n# Called before a cached object is delivered to the client.\nsub vcl_deliver\n{\n # Send the Cookie header again if a temporay header was stored\n if (req.http.X-Varnish-Cookie) {\n set resp.http.Set-Cookie = req.http.X-Varnish-Cookie;\n }\n\n # Add extra headers if debugging is enabled\n if (resp.http.x-varnish-debug && server.ip ~ localhost)\n {\n set resp.http.X-Served-By = server.hostname;\n\n if (resp.http.x-varnish ~ \" \") {\n set resp.http.X-Varnish-Status = \"HIT\";\n } else {\n set resp.http.X-Varnish-Status = \"MISS\";\n }\n\n # Please note that obj.hits behaviour changed in 4.0, now it counts per objecthead, not per object\n # and obj.hits may not be reset in some cases where bans are in use. See bug 1492 for details.\n # So take hits with a grain of salt\n set resp.http.X-Varnish-Hits = obj.hits;\n }\n else\n {\n # Remove ban-lurker friendly custom headers when delivering to client\n unset resp.http.X-Url;\n unset resp.http.X-Host;\n\n # Remove some headers: PHP version\n unset resp.http.X-Powered-By;\n\n # Remove some headers: Apache version & OS\n unset resp.http.Server;\n unset resp.http.Via;\n unset resp.http.Link;\n unset resp.http.X-Varnish;\n unset resp.http.X-Varnish-Tag;\n unset resp.http.X-Varnish-Debug;\n unset resp.http.X-Varnish-Host;\n unset resp.http.X-Varnish-Url;\n unset resp.http.X-Varnish-Retries;\n unset resp.http.X-Varnish-Cookie;\n unset resp.http.Surrogate-Control;\n }\n\n return (deliver);\n}\n\nsub vcl_purge\n{\n # Only handle actual PURGE HTTP methods, everything else is discarded\n if (req.method != \"PURGE\" && server.ip ~ localhost)\n {\n set req.http.X-Varnish-Purge = \"Yes\";\n return (restart);\n }\n}\n\nsub vcl_synth\n{\n if (resp.status == 720)\n {\n # We use this special error status 720 to force redirects with 301 (permanent) redirects\n # To use this, call the following from anywhere in vcl_recv: return (synth(720, \"http:\/\/host\/new.html\"));\n set resp.http.Location = resp.reason;\n set resp.status = 301;\n\n return (deliver);\n }\n elseif (resp.status == 721)\n {\n # And we use error status 721 to force redirects with a 302 (temporary) redirect\n # To use this, call the following from anywhere in vcl_recv: return (synth(720, \"http:\/\/host\/new.html\"));\n\n set resp.http.Location = resp.reason;\n set resp.status = 302;\n\n return (deliver);\n }\n\n return (deliver);\n}\n\n# Called when VCL is discarded only after all requests have exited the VCL. Typically used to clean up VMODs.\nsub vcl_fini\n{\n return (ok);\n}\n","old_contents":"vcl 4.0;\n# Based on: https:\/\/github.com\/mattiasgeniar\/varnish-4.0-configuration-templates\/blob\/master\/default.vcl\n\nimport std;\nimport directors;\n\nprobe health\n{\n #.url = \"\/varnish-enabled\";\n # We prefer to only do a HEAD \/\n .request =\n \"HEAD \/varnish-enabled HTTP\/1.1\"\n \"Host: localhost\"\n \"Connection: close\";\n .interval = 5s; # check the health of each backend every 5 seconds\n .timeout = 1s; # timing out after 1 second.\n # If 3 out of the last 5 polls succeeded the backend is considered healthy, otherwise it will be marked as sick\n .window = 5;\n .threshold = 3;\n .expected_response = 200;\n}\n\nbackend default\n{\n .host = \"127.0.0.1\"; # IP or Hostname of backend\n .port = \"8080\"; # Port Apache or whatever is listening\n .max_connections = 300; # That's it\n .probe = health;\n .connect_timeout = 600s; # How long to wait before we receive a first byte from our backend?\n .first_byte_timeout = 600s; # How long to wait for a backend connection?\n .between_bytes_timeout = 600s; # How long to wait between bytes received from our backend?\n}\n\nbackend passthrough\n{\n .host = \"127.0.0.1\"; # IP or Hostname of backend\n .port = \"8080\"; # Port Apache or whatever is listening\n}\n\nacl localhost\n{\n \"localhost\";\n \"33.33.33.63\";\n \"::1\";\n}\n\nsub vcl_init\n{\n # Called when VCL is loaded, before any requests pass through it.\n # Typically used to initialize VMODs.\n\n new vdir = directors.round_robin();\n vdir.add_backend(default);\n # vdir.add_backend(server...);\n # vdir.add_backend(servern);\n}\n\nsub vcl_recv\n{\n # Called at the beginning of a request, after the complete request has been received and parsed.\n # Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable,\n # which backend to use and if needed to modify the request.\n\n # Send all traffic to the vdir director\n set req.backend_hint = vdir.backend();\n\n if (req.restarts == 0)\n {\n # Set or append the client.ip to X-Forwarded-For header\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n\n set req.http.X-Forwarded-By = server.ip;\n set req.http.X-Forwarded-Port = std.port(client.ip);\n }\n\n # Normalize the header, remove the port (in case you're testing this on various TCP ports)\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n # Normalize the query arguments\n set req.url = std.querysort(req.url);\n\n # Allow purging\n if (req.method == \"PURGE\")\n {\n # purge is the ACL defined at the begining\n if (!client.ip ~ localhost) {\n return (synth(405, \"This IP is not allowed to send PURGE requests.\"));\n }\n\n # If you got this stage (and didn't error out above), purge the cached result\n return (purge);\n }\n\n # Check if we've still enabled Varnish, if not, passthrough every request\n if (! std.healthy(req.backend_hint))\n {\n set req.backend_hint = passthrough;\n return (pass);\n }\n\n # Only deal with \"normal\" types\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"PATCH\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n # Implementing websocket support (https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html)\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n # Only cache GET or HEAD requests. This makes sure the POST requests are always passed.\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n # Specific Nooku Platform rules\n\n # Do not cache \/administrator\n if(req.url ~ \"^\/administrator\") {\n return (pass);\n }\n\n # Specific Nooku Server rules\n\n # Do not cache webgrind.nooku.dev\n if (req.http.host == \"webgrind.nooku.dev\") {\n return (pass);\n }\n\n # Do not cache phpmyadmin.nooku.dev\n if (req.http.host == \"phpmyadmin.nooku.dev\") {\n return (pass);\n }\n\n # Do not cache \/apc and \/phpinfo\n if (req.url == \"\/apc\" || req.url == \"\/phpinfo\") {\n return (pass);\n }\n\n # Generic URL manipulation, useful for all templates that follow\n\n # Remove the Google Analytics added parameters, useless for our backend\n if (req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=\") {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # Strip hash, server doesn't need it.\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n # Strip a trailing ? if it exists\n if (req.url ~ \"\\?$\") {\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # Cookie manipulation\n\n # Remove the \"has_js\" cookie\n set req.http.Cookie = regsuball(req.http.Cookie, \"has_js=[^;]+(; )?\", \"\");\n\n # Remove any Google Analytics based cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__utm.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"_ga=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmctr=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmcmd.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmccn.=[^;]+(; )?\", \"\");\n\n # Remove DoubleClick offensive cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__gads=[^;]+(; )?\", \"\");\n\n # Remove the Quant Capital cookies (added by some plugin, all __qca)\n set req.http.Cookie = regsuball(req.http.Cookie, \"__qc.=[^;]+(; )?\", \"\");\n\n # Remove the AddThis cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__atuv.=[^;]+(; )?\", \"\");\n\n # Remove a \";\" prefix in the cookie if present\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n\n # Remove the csrf_token cookie\n set req.http.Cookie = regsuball(req.http.Cookie, \"csrf_token=[^;]+(; )?\", \"\");\n\n # Are there cookies left with only spaces or that are empty?\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n\n # Large static files are delivered directly to the end-user without waiting for Varnish to fully read the file first.\n # Varnish 4 supports Streaming, so set do_stream in vcl_backend_response()\n if (req.url ~ \"^[^?]*\\.(mp[34]|rar|tar|tgz|gz|wav|zip|bz2|xz|7z|avi|mov|og[gvaxm]|mpe?g|mk[av])(\\?.*)?$\") {\n unset req.http.Cookie;\n return (hash);\n }\n\n # Remove all cookies for static files\n # Before you blindly enable this read: https:\/\/ma.ttias.be\/stop-caching-static-files\/\n #if (req.method == \"GET\")\n #{\n # # Cache files with these extensions and remove cookie\n # if (req.url ~ \"^[^?]*\\.(bmp|bz2|css|doc|eot|flv|gif|gz|ico|jpeg|jpg|js|less|pdf|png|rtf|swf|txt|woff|xml)(\\?.*)?$\") {\n # unset req.http.Cookie;\n # return (hash);\n # }\n #}\n\n # Normalize Accept-Encoding header\n # straight from the manual: https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/vary.html\n # TODO: Test if it's still needed, Varnish 4 now does this by itself if http_gzip_support = on\n # https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/compression.html\n # https:\/\/www.varnish-cache.org\/docs\/trunk\/phk\/gzip.html\n if (req.http.Accept-Encoding)\n {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n # No point in compressing these\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n # unkown algorithm\n unset req.http.Accept-Encoding;\n }\n }\n\n if (req.http.Cache-Control ~ \"(?i)no-cache\" && client.ip ~ localhost)\n {\n # http:\/\/varnish.projects.linpro.no\/wiki\/VCLExampleEnableForceRefresh\n # Ignore requests via proxy caches and badly behaved crawlers\n # like msnbot that send no-cache with every request.\n if (! (req.http.Via || req.http.User-Agent ~ \"(?i)bot\" || req.http.X-Purge))\n {\n # Doesn't seems to refresh the object in the cache\n set req.hash_always_miss = true;\n\n # Couple this with restart in vcl_purge and X-Purge header to avoid loops\n return(purge);\n }\n }\n\n # Send Surrogate-Capability headers to announce ESI support to backend\n set req.http.Surrogate-Capability = \"varnish=ESI\/1.0\";\n\n # Requests that require authorization are not cacheable by default\n if (req.http.Authorization) {\n return (pass);\n }\n\n # We do not support SPDY or HTTP\/2.0\n if (req.method == \"PRI\") {\n return (synth(405));\n }\n\n return (hash);\n}\n\n# Called upon entering pipe mode. In this mode, the request is passed on to the backend, and any further data from both\n# the client and backend is passed on unaltered until either end closes the connection. Basically, Varnish will degrade\n# into a simple TCP proxy, shuffling bytes back and forth. For a connection in pipe mode, no other VCL subroutine will\n# ever get called after vcl_pipe.\nsub vcl_pipe\n{\n # Note that only the first request to the backend will have X-Forwarded-For set.\n # If you use X-Forwarded-For and want to have it set for all requests, make sure to have:\n # set bereq.http.connection = \"close\";\n # It is not set by default as it might break some broken web applications, like IIS with NTLM authentication.\n # set bereq.http.Connection = \"Close\";\n\n # Implementing websocket support (https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html)\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n\n return (pipe);\n}\n\n# Called upon entering pass mode. In this mode, the request is passed on to the backend, and the backend's response\n# is passed on to the client, but is not entered into the cache. Subsequent requests submitted over the same client\n# connection are handled normally.\nsub vcl_pass\n{\n return (fetch);\n}\n\n# Called after vcl_recv to create a hash value for the request. This is used as a key to look up the object in Varnish.\nsub vcl_hash\n{\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n\n # hash cookies for requests that have them\n if (req.http.Cookie) {\n hash_data(req.http.Cookie);\n }\n}\n\n# Called when a cache lookup is successful.\nsub vcl_hit\n{\n # A pure unadultered hit, deliver it\n if (obj.ttl >= 0s) {\n return (deliver);\n }\n\n # https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-grace.html\n # When several clients are requesting the same page Varnish will send one request to the backend and place the\n # others on hold while fetching one copy from the backend. In some products this is called request coalescing and\n # Varnish does this automatically.\n\n # If you are serving thousands of hits per second the queue of waiting requests can get huge. There are two\n # potential problems - one is a thundering herd problem - suddenly releasing a thousand threads to serve content\n # might send the load sky high. Secondly - nobody likes to wait. To deal with this we can instruct Varnish to keep\n # the objects in cache beyond their TTL and to serve the waiting requests somewhat stale content.\n\n # if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n # return (deliver);\n # } else {\n # return (fetch);\n # }\n\n # We have no fresh fish. Lets look at the stale ones.\n if (std.healthy(req.backend_hint))\n {\n # Backend is healthy. Limit age to 10s.\n if (obj.ttl + 10s > 0s)\n {\n #set req.http.grace = \"normal(limited)\";\n return (deliver);\n }\n else\n {\n # No candidate for grace. Fetch a fresh object.\n return(fetch);\n }\n }\n else\n {\n # backend is sick - use full grace\n if (obj.ttl + obj.grace > 0s)\n {\n #set req.http.grace = \"full\";\n return (deliver);\n }\n else\n {\n # no graced object.\n return (fetch);\n }\n }\n\n # fetch & deliver once we get the result\n return (fetch); # Dead code, keep as a safeguard\n}\n\n# Called after a cache lookup if the requested document was not found in the cache. Its purpose is to decide whether\n# or not to attempt to retrieve the document from the backend, and which backend to use.\nsub vcl_miss\n{\n return (fetch);\n}\n\n # Called after the response headers has been successfully retrieved from the backend.\nsub vcl_backend_response\n{\n # Enable ESI handling\n if (beresp.http.Surrogate-Control ~ \"ESI\/1.0\" ) {\n set beresp.do_esi = true;\n }\n\n # Store the csrf_token cookie temporarily if the response is cacheabale\n if (beresp.http.Set-Cookie && !beresp.uncacheable)\n {\n set beresp.http.X-Varnish-Cookie = beresp.http.Set-Cookie;\n unset beresp.http.Set-Cookie;\n }\n\n # Cache handling all static files\n if (bereq.method == \"GET\")\n {\n # Before you blindly enable this, read: https:\/\/ma.ttias.be\/stop-caching-static-files\/\n #if (bereq.url ~ \"^[^?]*\\.(bmp|bz2|css|doc|eot|flv|gif|gz|ico|jpeg|jpg|js|less|mp[34]|pdf|png|rar|rtf|swf|tar|tgz|txt|wav|woff|xml|zip)(\\?.*)?$\") {\n # unset beresp.http.Set-Cookie;\n #}\n\n # Large static files are delivered directly to the end-user without waiting for Varnish to fully read the\n # file first. Check memory usage it'll grow in fetch_chunksize blocks (128k by default) if the backend\n # doesn't send a Content-Length header. Only enable it for large files\n if (bereq.url ~ \"^[^?]*\\.(mp[34]|rar|tar|tgz|gz|wav|zip|bz2|xz|7z|avi|mov|og[gvaxm]|mpe?g|mk[av])(\\?.*)?$\")\n {\n unset beresp.http.Set-Cookie;\n\n # Use streaming to avoid locking\n set beresp.do_stream = true;\n\n # Don't try to compress it for storage\n set beresp.do_gzip = false;\n\n # Disable Transfer-encoding chunked when serving HTML5 video\n # See : http:\/\/stackoverflow.com\/questions\/23643233\/how-do-i-disable-transfer-encoding-chunked-encoding-in-varnish\n # See : https:\/\/www.varnish-cache.org\/trac\/ticket\/1506\n if(beresp.http.Content-Type ~ \"video\") {\n set beresp.do_stream = true;\n set beresp.do_esi = true;\n }\n }\n\n # Set 2min cache if unset for static files\n if (beresp.ttl <= 0s || beresp.http.Set-Cookie || beresp.http.Vary == \"*\")\n {\n set beresp.ttl = 120s; # Important, you shouldn't rely on this, SET YOUR HEADERS in the backend\n set beresp.uncacheable = true;\n\n return (deliver);\n }\n }\n\n # Sometimes, a 301 or 302 redirect formed via Apache's mod_rewrite can mess with the HTTP port that is being passed along.\n # This often happens with simple rewrite rules in a scenario where Varnish runs on :80 and Apache on :8080 on the same box.\n # A redirect can then often redirect the end-user to a URL on :8080, where it should be :80.\n # This may need finetuning on your setup.\n #\n # To prevent accidental replace, we only filter the 301\/302 redirects for now.\n if (beresp.status == 301 || beresp.status == 302) {\n set beresp.http.Location = regsub(beresp.http.Location, \":[0-9]+\", \"\");\n }\n\n # Do not cache errors from the backend\n if (beresp.status >= 400)\n {\n set beresp.uncacheable = true;\n set beresp.ttl = 0s;\n\n return (deliver);\n }\n\n # Allow stale content, in case the backend goes down. Make Varnish keep all objects for 6 hours beyond their TTL\n set beresp.grace = 6h;\n\n # Set ban-lurker friendly custom headers\n set beresp.http.X-Varnish-Url = bereq.url;\n set beresp.http.X-Varnish-Host = bereq.http.host;\n\n return (deliver);\n}\n\n# Called when the backend returns an error\nsub vcl_backend_error\n{\n if (beresp.status == 503 && bereq.retries < 5)\n {\n set beresp.http.X-Varnish-Retries = bereq.retries;\n return(retry);\n }\n\n return(deliver);\n}\n\n# Called before a cached object is delivered to the client.\nsub vcl_deliver\n{\n # Send the Cookie header again if a temporay header was stored\n if (req.http.X-Varnish-Cookie) {\n set resp.http.Set-Cookie = req.http.X-Varnish-Cookie;\n }\n\n # Add extra headers if debugging is enabled\n if (resp.http.x-varnish-debug && server.ip ~ localhost)\n {\n set resp.http.X-Served-By = server.hostname;\n\n if (resp.http.x-varnish ~ \" \") {\n set resp.http.X-Varnish-Status = \"HIT\";\n } else {\n set resp.http.X-Varnish-Status = \"MISS\";\n }\n\n # Please note that obj.hits behaviour changed in 4.0, now it counts per objecthead, not per object\n # and obj.hits may not be reset in some cases where bans are in use. See bug 1492 for details.\n # So take hits with a grain of salt\n set resp.http.X-Varnish-Hits = obj.hits;\n }\n else\n {\n # Remove ban-lurker friendly custom headers when delivering to client\n unset resp.http.X-Url;\n unset resp.http.X-Host;\n\n # Remove some headers: PHP version\n unset resp.http.X-Powered-By;\n\n # Remove some headers: Apache version & OS\n unset resp.http.Server;\n unset resp.http.Via;\n unset resp.http.Link;\n unset resp.http.X-Varnish;\n unset resp.http.X-Varnish-Tag;\n unset resp.http.X-Varnish-Debug;\n unset resp.http.X-Varnish-Host;\n unset resp.http.X-Varnish-Url;\n unset resp.http.X-Varnish-Retries;\n unset resp.http.X-Varnish-Cookie;\n unset resp.http.Surrogate-Control;\n }\n\n return (deliver);\n}\n\nsub vcl_purge\n{\n # Only handle actual PURGE HTTP methods, everything else is discarded\n if (req.method != \"PURGE\" && server.ip ~ localhost)\n {\n set req.http.X-Varnish-Purge = \"Yes\";\n return (restart);\n }\n}\n\nsub vcl_synth\n{\n if (resp.status == 720)\n {\n # We use this special error status 720 to force redirects with 301 (permanent) redirects\n # To use this, call the following from anywhere in vcl_recv: return (synth(720, \"http:\/\/host\/new.html\"));\n set resp.http.Location = resp.reason;\n set resp.status = 301;\n\n return (deliver);\n }\n elseif (resp.status == 721)\n {\n # And we use error status 721 to force redirects with a 302 (temporary) redirect\n # To use this, call the following from anywhere in vcl_recv: return (synth(720, \"http:\/\/host\/new.html\"));\n\n set resp.http.Location = resp.reason;\n set resp.status = 302;\n\n return (deliver);\n }\n\n return (deliver);\n}\n\n# Called when VCL is discarded only after all requests have exited the VCL. Typically used to clean up VMODs.\nsub vcl_fini\n{\n return (ok);\n}\n","returncode":0,"stderr":"","license":"mpl-2.0","lang":"VCL"} {"commit":"9e08a78f060f867ae84a27331e6f92ffac94efe0","subject":"Regex query filter appears to be stripping out trailing slash for geoip calls so we'll make sure that it doesn't run on those URLs","message":"Regex query filter appears to be stripping out trailing slash for geoip calls\nso we'll make sure that it doesn't run on those URLs\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/fastly.vcl","new_file":"etc\/fastly.vcl","new_contents":"###############################################################################\n#\n# Fastly CDN for Magento 2\n#\n# NOTICE OF LICENSE\n#\n# This source file is subject to the Fastly CDN for Magento 2 End User License\n# Agreement that is bundled with this package in the file LICENSE_FASTLY_CDN.txt.\n#\n# @copyright Copyright (c) 2016 Fastly, Inc. (http:\/\/www.fastly.com)\n# @license BSD, see LICENSE_FASTLY_CDN.txt\n#\n###############################################################################\n\n# This is a basic VCL configuration file for Fastly CDN for Magento 2 module.\n\nsub vcl_recv {\n#FASTLY recv\n\n # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n if (req.url ~ \"^\/static\/version(\\d*\/)?(.*)$\") {\n set req.url = \"\/static\/\" + re.group.2 + \"?\" + re.group.1;\n } \n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n set req.http.X-Sig = regsub(req.http.X-Purge-Token, \"^[^_]+_(.*)\", \"\\1\");\n set req.http.X-Exp = regsub(req.http.X-Purge-Token, \"^([^_]+)_.*\", \"\\1\");\n\n # validate signature\n if (req.http.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path req.http.X-Exp), \"^0x\", \"\")) {\n\n # use vcl time math to check expiration timestamp\n set req.http.X-Original-Grace = req.grace;\n set req.grace = std.atoi(strftime({\"%s\"}, now));\n set req.grace -= std.atoi(req.http.X-Exp);\n\n if (std.atoi(req.grace) > 0) {\n error 410;\n }\n\n # clean up grace since we used it for time math\n set req.grace = std.atoi(req.http.X-Original-Grace);\n unset req.http.X-Original-Grace;\n\n } else {\n error 403;\n }\n\n # cleanup variables\n unset req.http.X-Purge-Token;\n unset req.http.X-Sig;\n unset req.http.X-Exp;\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n # disable ESI processing on Origin Shield\n if (req.http.Fastly-FF) {\n set req.esi = false;\n }\n\n # We only deal with GET and HEAD by default\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n return (pass);\n }\n \n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie ~ \"(X-Magento-Vary|form_key)=\") {\n error 200 \"\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url !~ \"country_code=\" ) {\n set req.url = req.url \"?country_code=\" if ( req.http.geo_override, req.http.geo_override, geoip.country_code);\n }\n }\n } else {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking\n set req.http.Fastly-Original-URL = req.url;\n set req.url = querystring.regfilter(req.url, \"^(utm_.*|gclid|gdftrk|_ga|mc_.*)\");\n }\n \n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n return (lookup);\n }\n\n # Bypass shopping cart and checkout requests\n if (req.url ~ \"\/checkout\") {\n return (pass);\n }\n\n return(lookup);\n}\n\nsub vcl_fetch {\n\n # Remove Set-Cookies from responses for static content\n # to match the cookie removal in recv.\n if (req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n }\n\n }\n\n#FASTLY fetch\n\n if (beresp.status >= 500) {\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n }\n\n if (req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Content-Type ~ \"text\/html\" || beresp.http.Content-Type ~ \"text\/xml\") {\n # enable ESI feature for Magento response by default\n esi;\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content\n if ((beresp.status == 200 || beresp.status == 404) && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url ~ \"\\.(css|js|html|eot|ico|otf|ttf|json)($|\\?)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # cache only successfully responses and 404s\n if (beresp.status != 200 && beresp.status != 301 && beresp.status != 404) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\")) {\n unset beresp.http.set-cookie;\n if (req.url !~ \"^\/(pub\/)?(media|static)\/.*\") {\n set beresp.http.Pragma = \"no-cache\";\n set beresp.http.Expires = \"-1\";\n set beresp.http.Cache-Control = \"no-store, no-cache, must-revalidate, max-age=0\";\n set beresp.grace = 1m;\n }\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type\n if (beresp.http.Content-Type ~ \"image\") {\n set beresp.http.Surrogate-Key = \"image\";\n } elsif (beresp.http.Content-Type ~ \"script\") {\n set beresp.http.Surrogate-Key = \"script\";\n } elsif (beresp.http.Content-Type ~ \"css\") {\n set beresp.http.Surrogate-Key = \"css\";\n }\n\n set beresp.http.X-Surrogate-Key = beresp.http.Surrogate-Key;\n return (deliver);\n }\n\n return (deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\n\nsub vcl_miss {\n # Deactivate gzip on origin\n unset bereq.http.Accept-Encoding;\n\n#FASTLY miss\n\n return(fetch);\n}\n\nsub vcl_deliver {\n\n # Add an easy way to see whether custom Fastly VCL has been uploaded\n if ( req.http.Fastly-Debug ) {\n set resp.http.Fastly-Magento-VCL-Uploaded = \"yes\";\n } else {\n remove resp.http.Fastly-Module-Enabled;\n }\n # debug info\n if (resp.http.X-Magento-Debug) {\n if (obj.hits > 0) {\n set resp.http.X-Magento-Cache-Debug = \"HIT\";\n set resp.http.X-Magento-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Magento-Cache-Debug = \"MISS\";\n }\n } else {\n # remove Varnish\/proxy header\n remove resp.http.Age;\n remove resp.http.X-Magento-Debug;\n remove resp.http.X-Magento-Tags;\n remove resp.http.X-Surrogate-Key;\n remove resp.http.X-Magento-Cache-Control;\n remove resp.http.X-Powered-By;\n remove resp.http.Server;\n remove resp.http.X-Varnish;\n remove resp.http.Via;\n remove resp.http.Link;\n remove resp.http.X-Purge-URL;\n remove resp.http.X-Purge-Host;\n }\n\n#FASTLY deliver\n\n return (deliver);\n}\n\n\nsub vcl_error {\n # workaround for possible security issue\n if (req.url ~ \"^\\s\") {\n set obj.status = 400;\n set obj.response = \"Malformed request\";\n synthetic \"\";\n return (deliver);\n }\n\n # error 200\n if (obj.status == 200) {\n return (deliver);\n }\n\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} obj.status \" \" obj.response {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} obj.status \" \" obj.response {\"<\/h1>\n <p>\"} obj.response {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} req.xid {\"<\/p>\n <hr>\n <p>Fastly CDN server<\/p>\n <\/body>\n<\/html>\n\"};\n\n#FASTLY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n\nsub vcl_hash {\n set req.hash += req.http.Https;\n set req.hash += req.http.host;\n set req.hash += req.url;\n\n if (req.http.cookie:X-Magento-Vary ) {\n set req.hash += req.http.cookie:X-Magento-Vary;\n }\n \n set req.hash += \"#####GENERATION#####\";\n\n ### {{ design_exceptions_code }} ###\n\n return (hash);\n}\n\n","old_contents":"###############################################################################\n#\n# Fastly CDN for Magento 2\n#\n# NOTICE OF LICENSE\n#\n# This source file is subject to the Fastly CDN for Magento 2 End User License\n# Agreement that is bundled with this package in the file LICENSE_FASTLY_CDN.txt.\n#\n# @copyright Copyright (c) 2016 Fastly, Inc. (http:\/\/www.fastly.com)\n# @license BSD, see LICENSE_FASTLY_CDN.txt\n#\n###############################################################################\n\n# This is a basic VCL configuration file for Fastly CDN for Magento 2 module.\n\nsub vcl_recv {\n#FASTLY recv\n\n # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking\n set req.http.Fastly-Original-URL = req.url;\n set req.url = querystring.regfilter(req.url, \"^(utm_.*|gclid|gdftrk|_ga|mc_.*)\");\n\n if (req.url ~ \"^\/static\/version(\\d*\/)?(.*)$\") {\n set req.url = \"\/static\/\" + re.group.2 + \"?\" + re.group.1;\n } \n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n set req.http.X-Sig = regsub(req.http.X-Purge-Token, \"^[^_]+_(.*)\", \"\\1\");\n set req.http.X-Exp = regsub(req.http.X-Purge-Token, \"^([^_]+)_.*\", \"\\1\");\n\n # validate signature\n if (req.http.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path req.http.X-Exp), \"^0x\", \"\")) {\n\n # use vcl time math to check expiration timestamp\n set req.http.X-Original-Grace = req.grace;\n set req.grace = std.atoi(strftime({\"%s\"}, now));\n set req.grace -= std.atoi(req.http.X-Exp);\n\n if (std.atoi(req.grace) > 0) {\n error 410;\n }\n\n # clean up grace since we used it for time math\n set req.grace = std.atoi(req.http.X-Original-Grace);\n unset req.http.X-Original-Grace;\n\n } else {\n error 403;\n }\n\n # cleanup variables\n unset req.http.X-Purge-Token;\n unset req.http.X-Sig;\n unset req.http.X-Exp;\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n # disable ESI processing on Origin Shield\n if (req.http.Fastly-FF) {\n set req.esi = false;\n }\n\n # We only deal with GET and HEAD by default\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n return (pass);\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n return (lookup);\n }\n\n # Bypass shopping cart and checkout requests\n if (req.url ~ \"\/checkout\") {\n return (pass);\n }\n\n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie ~ \"(X-Magento-Vary|form_key)=\") {\n error 200 \"\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url !~ \"country_code=\" ) {\n set req.url = req.url \"?country_code=\" if ( req.http.geo_override, req.http.geo_override, geoip.country_code);\n }\n }\n }\n\n return(lookup);\n}\n\nsub vcl_fetch {\n\n # Remove Set-Cookies from responses for static content\n # to match the cookie removal in recv.\n if (req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n }\n\n }\n\n#FASTLY fetch\n\n if (beresp.status >= 500) {\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n }\n\n if (req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Content-Type ~ \"text\/html\" || beresp.http.Content-Type ~ \"text\/xml\") {\n # enable ESI feature for Magento response by default\n esi;\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content\n if ((beresp.status == 200 || beresp.status == 404) && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url ~ \"\\.(css|js|html|eot|ico|otf|ttf|json)($|\\?)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # cache only successfully responses and 404s\n if (beresp.status != 200 && beresp.status != 301 && beresp.status != 404) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\")) {\n unset beresp.http.set-cookie;\n if (req.url !~ \"^\/(pub\/)?(media|static)\/.*\") {\n set beresp.http.Pragma = \"no-cache\";\n set beresp.http.Expires = \"-1\";\n set beresp.http.Cache-Control = \"no-store, no-cache, must-revalidate, max-age=0\";\n set beresp.grace = 1m;\n }\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type\n if (beresp.http.Content-Type ~ \"image\") {\n set beresp.http.Surrogate-Key = \"image\";\n } elsif (beresp.http.Content-Type ~ \"script\") {\n set beresp.http.Surrogate-Key = \"script\";\n } elsif (beresp.http.Content-Type ~ \"css\") {\n set beresp.http.Surrogate-Key = \"css\";\n }\n\n set beresp.http.X-Surrogate-Key = beresp.http.Surrogate-Key;\n return (deliver);\n }\n\n return (deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\n\nsub vcl_miss {\n # Deactivate gzip on origin\n unset bereq.http.Accept-Encoding;\n\n#FASTLY miss\n\n return(fetch);\n}\n\nsub vcl_deliver {\n\n # Add an easy way to see whether custom Fastly VCL has been uploaded\n if ( req.http.Fastly-Debug ) {\n set resp.http.Fastly-Magento-VCL-Uploaded = \"yes\";\n } else {\n remove resp.http.Fastly-Module-Enabled;\n }\n # debug info\n if (resp.http.X-Magento-Debug) {\n if (obj.hits > 0) {\n set resp.http.X-Magento-Cache-Debug = \"HIT\";\n set resp.http.X-Magento-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Magento-Cache-Debug = \"MISS\";\n }\n } else {\n # remove Varnish\/proxy header\n remove resp.http.Age;\n remove resp.http.X-Magento-Debug;\n remove resp.http.X-Magento-Tags;\n remove resp.http.X-Surrogate-Key;\n remove resp.http.X-Magento-Cache-Control;\n remove resp.http.X-Powered-By;\n remove resp.http.Server;\n remove resp.http.X-Varnish;\n remove resp.http.Via;\n remove resp.http.Link;\n remove resp.http.X-Purge-URL;\n remove resp.http.X-Purge-Host;\n }\n\n#FASTLY deliver\n\n return (deliver);\n}\n\n\nsub vcl_error {\n # workaround for possible security issue\n if (req.url ~ \"^\\s\") {\n set obj.status = 400;\n set obj.response = \"Malformed request\";\n synthetic \"\";\n return (deliver);\n }\n\n # error 200\n if (obj.status == 200) {\n return (deliver);\n }\n\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} obj.status \" \" obj.response {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} obj.status \" \" obj.response {\"<\/h1>\n <p>\"} obj.response {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} req.xid {\"<\/p>\n <hr>\n <p>Fastly CDN server<\/p>\n <\/body>\n<\/html>\n\"};\n\n#FASTLY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n\nsub vcl_hash {\n set req.hash += req.http.Https;\n set req.hash += req.http.host;\n set req.hash += req.url;\n\n if (req.http.cookie:X-Magento-Vary ) {\n set req.hash += req.http.cookie:X-Magento-Vary;\n }\n \n set req.hash += \"#####GENERATION#####\";\n\n ### {{ design_exceptions_code }} ###\n\n return (hash);\n}\n\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"32328f1b3f2120e4e4425c6f007b198e64bde74a","subject":"my vcl is a little rusty; import the module before using it.","message":"my vcl is a little rusty; import the module before using it.\n","repos":"amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon","old_file":"images\/varnish-drupal\/drupal.vcl","new_file":"images\/varnish-drupal\/drupal.vcl","new_contents":"vcl 4.0;\n\nimport std;\nimport dynamic;\n\n# set backend default\nbackend default {\n .host = \"${VARNISH_BACKEND_HOST:-nginx}\";\n .port = \"${VARNISH_BACKEND_PORT:-8080}\";\n .first_byte_timeout = 35m;\n .between_bytes_timeout = 10m;\n}\n\n# Allow purging from localhost\n# @TODO allow from openshift network\nacl purge {\n \"127.0.0.1\";\n \"10.0.0.0\"\/8;\n \"172.16.0.0\"\/12;\n \"192.168.0.0\"\/16;\n}\n\nsub vcl_init {\n new www_dir = dynamic.director(\n port = \"${VARNISH_BACKEND_PORT:-8080}\",\n probe = www_probe,\n whitelist = purge,\n ttl = 60s);\n }\n\n\n# This configuration is optimized for Drupal hosting:\n# Respond to incoming requests.\nsub vcl_recv {\n\n if (req.url ~ \"^\/varnish_status$\") {\n return (synth(200,\"OK\"));\n }\n # set the backend, which should be used:\n set req.backend_hint = www_dir.backend(\"${VARNISH_BACKEND_HOST:-nginx}\");\n\n # Always set the forward ip.\n if (req.restarts == 0) {\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n\n\n if (req.http.X-LAGOON-VARNISH ) {\n ## Pass all Requests which are handled via an upstream Varnish\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, \" + req.http.X-LAGOON-VARNISH;\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n } else if (req.http.Fastly-FF) {\n ## Pass all Requests which are handled via Fastly\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, fastly\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n set req.http.X-Forwarded-For = req.http.Fastly-Client-IP;\n } else if (req.http.CF-RAY) {\n ## Pass all Requests which are handled via CloudFlare\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, cloudflare\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n set req.http.X-Forwarded-For = req.http.CF-Connecting-IP;\n } else if (req.http.X-Pull) {\n ## Pass all Requests which are handled via KeyCDN\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, keycdn\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n } else {\n ## We set a header to let a Varnish Chain know that it already has been varnishcached\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}\";\n\n ## Allow to bypass based on env variable `VARNISH_BYPASS`\n set req.http.X-LAGOON-VARNISH-BYPASS = \"${VARNISH_BYPASS:-false}\";\n }\n\n # Websockets are piped\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n if (req.http.X-LAGOON-VARNISH-BYPASS == \"true\" || req.http.X-LAGOON-VARNISH-BYPASS == \"TRUE\") {\n return (pass);\n }\n\n # SA-CORE-2014-004 preventing access to \/xmlrpc.php\n if (req.url ~ \"^\/xmlrpc.php$\") {\n return (synth(701, \"Unauthorized\"));\n }\n\n # Strip out Google Analytics campaign variables. They are only needed\n # by the javascript running on the page\n # utm_source, utm_medium, utm_campaign, gclid\n if(req.url ~ \"(\\?|&)(gclid|utm_[a-z]+)=\") {\n set req.url = regsuball(req.url, \"(gclid|utm_[a-z]+)=[^\\&]+&?\", \"\");\n set req.url = regsub(req.url, \"(\\?|&)$\", \"\");\n }\n\n # Bypass a cache hit (the request is still sent to the backend)\n if (req.method == \"REFRESH\") {\n if (!client.ip ~ purge) { return (synth(405, \"Not allowed\")); }\n set req.method = \"GET\";\n set req.hash_always_miss = true;\n }\n\n # Only allow BAN requests from IP addresses in the 'purge' ACL.\n if (req.method == \"BAN\" || req.method == \"URIBAN\" || req.method == \"PURGE\") {\n # Only allow BAN from defined ACL\n if (!client.ip ~ purge) {\n return (synth(403, \"Your IP is not allowed.\"));\n }\n\n # Only allows BAN if the Host Header has the style of with \"${SERVICE_NAME:-varnish}:8080\" or \"${SERVICE_NAME:-varnish}\".\n # Such a request is only possible from within the Docker network, as a request from external goes trough the Kubernetes Router and for that needs a proper Host Header\n if (!req.http.host ~ \"^${SERVICE_NAME:-varnish}(:\\d+)?$\") {\n return (synth(403, \"Only allowed from within own network.\"));\n }\n\n if (req.method == \"BAN\") {\n # Logic for the ban, using the Cache-Tags header.\n if (req.http.Cache-Tags) {\n ban(\"obj.http.Cache-Tags ~ \" + req.http.Cache-Tags);\n # Throw a synthetic page so the request won't go to the backend.\n return (synth(200, \"Ban added.\"));\n }\n else {\n return (synth(403, \"Cache-Tags header missing.\"));\n }\n }\n\n if (req.method == \"URIBAN\" || req.method == \"PURGE\") {\n ban(\"req.url ~ \" + req.url);\n # Throw a synthetic page so the request won't go to the backend.\n return (synth(200, \"Ban added.\"));\n }\n\n }\n\n # Non-RFC2616 or CONNECT which is weird, we pipe that\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n return (pipe);\n }\n\n # We only try to cache GET and HEAD, other things are passed\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n # Any requests with Basic Auth are passed\n if (req.http.Authorization || req.http.Authenticate)\n {\n return (pass);\n }\n\n ## Pass requests which are from blackfire\n if (req.http.X-Blackfire-Query) {\n return (pass);\n }\n\n # Some URLs should never be cached\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/admin([\/?]|$).*$\" ||\n req.url ~ \"^\/info([\/?]|$).*$\" ||\n req.url ~ \"^\/flag([\/?]|$).*$\" ||\n req.url ~ \"^.*\/system\/files([\/?]|$).*$\" ||\n req.url ~ \"^\/cgi\" ||\n req.url ~ \"^\/cgi-bin\"\n ) {\n return (pass);\n }\n\n # Plupload likes to get piped\n if (req.url ~ \"^.*\/plupload-handle-uploads.*$\"\n ) {\n return (pipe);\n }\n\n # Handle compression correctly. Different browsers send different\n # \"Accept-Encoding\" headers, even though they mostly all support the same\n # compression mechanisms. By consolidating these compression headers into\n # a consistent format, we can reduce the size of the cache and get more hits.=\n # @see: http:\/\/ varnish.projects.linpro.no\/wiki\/FAQ\/Compression\n if (req.http.Accept-Encoding) {\n if (req.http.Accept-Encoding ~ \"gzip\") {\n # If the browser supports it, we'll use gzip.\n set req.http.Accept-Encoding = \"gzip\";\n }\n else if (req.http.Accept-Encoding ~ \"deflate\") {\n # Next, try deflate if it is supported.\n set req.http.Accept-Encoding = \"deflate\";\n }\n else {\n # Unknown algorithm. Remove it and send unencoded.\n unset req.http.Accept-Encoding;\n }\n }\n\n # Always cache the following file types for all users.\n if (req.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n unset req.http.Cookie;\n }\n\n # Remove all cookies that Drupal doesn't need to know about. ANY remaining\n # cookie will cause the request to pass-through to a backend. For the most part\n # we always set the NO_CACHE cookie after any POST request, disabling the\n # Varnish cache temporarily. The session cookie allows all authenticated users\n # to pass through as long as they're logged in.\n #\n # 1. Append a semi-colon to the front of the cookie string.\n # 2. Remove all spaces that appear after semi-colons.\n # 3. Match the cookies we want to keep, adding the space we removed\n # previously, back. (\\1) is first matching group in the regsuball.\n # 4. Remove all other cookies, identifying them by the fact that they have\n # no space after the preceding semi-colon.\n # 5. Remove all spaces and semi-colons from the beginning and end of the\n # cookie string.\n if (req.http.Cookie) {\n set req.http.CookieCheck = \";\" + req.http.Cookie;\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"; +\", \";\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";(${VARNISH_COOKIECHECK:-SESS[a-z0-9]+|SSESS[a-z0-9]+|NO_CACHE})=\", \"; \\1=\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";[^ ][^;]*\", \"\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"^[; ]+|[; ]+$\", \"\");\n\n set req.http.Cookie = req.http.Cookie + \";\";\n\n if (req.http.CookieCheck == \"\") {\n # If there are no remaining cookies, remove the cookie header. If there\n # aren't any cookie headers, Varnish's default behavior will be to cache\n # the page.\n\n unset req.http.CookieCheck;\n unset req.http.Cookie;\n }\n else {\n # If there is any cookies left (a session or NO_CACHE cookie), do not\n # cache the page. Pass it on to Apache directly.\n unset req.http.CookieCheck;\n return (pass);\n }\n }\n\n # Cacheable, lookup in cache.\n return (hash);\n}\n\nsub vcl_pipe {\n # Support for Websockets\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n set bereq.http.connection = req.http.connection;\n }\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n # normal hit\n return (deliver);\n }\n # We have no fresh fish. Lets look at the stale ones.\n if (std.healthy(req.backend_hint)) {\n # Backend is healthy. If the object is not older then 30secs, deliver it to the client\n # and automatically create a separate backend request to warm the cache for this request.\n if (obj.ttl + 30s > 0s) {\n set req.http.grace = \"normal(limited)\";\n return (deliver);\n } else {\n # No candidate for grace. Fetch a fresh object.\n return(miss);\n }\n } else {\n # backend is sick - use full grace\n if (obj.ttl + obj.grace > 0s) {\n set req.http.grace = \"full\";\n return (deliver);\n } else {\n # no graced object.\n return (miss);\n }\n }\n}\n\nsub vcl_backend_response {\n # Allow items to be stale if needed.\n set beresp.grace = 6h;\n\n # Set ban-lurker friendly custom headers.\n set beresp.http.X-Url = bereq.url;\n set beresp.http.X-Host = bereq.http.host;\n\n # If the backend sends a X-LAGOON-VARNISH-BACKEND-BYPASS header we directly deliver\n if(beresp.http.X-LAGOON-VARNISH-BACKEND-BYPASS == \"TRUE\") {\n return (deliver);\n }\n\n # Cache 404 and 403 for 10 seconds\n if(beresp.status == 404 || beresp.status == 403) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n # Don't allow static files to set cookies.\n if (bereq.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n # beresp == Back-end response from the web server.\n unset beresp.http.set-cookie;\n unset beresp.http.Cache-Control;\n\n # If an asset would come back with statuscode 500 we only cache it for 10 seconds instead of the usual static file cache\n if (beresp.status == 500) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n set beresp.ttl = ${VARNISH_ASSETS_TTL:-2628001}s;\n set beresp.http.Cache-Control = \"public, max-age=${VARNISH_ASSETS_TTL:-2628001}\";\n set beresp.http.Expires = \"\" + (now + beresp.ttl);\n }\n\n return (deliver);\n}\n\n# Set a header to track a cache HIT\/MISS.\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Varnish-Cache = \"HIT\";\n }\n else {\n set resp.http.X-Varnish-Cache = \"MISS\";\n }\n\n # Remove ban-lurker friendly custom headers when delivering to client.\n unset resp.http.X-Url;\n unset resp.http.X-Host;\n\n # unset Cache-Tags Header by default, can be disabled with VARNISH_UNSET_HEADER_CACHE_TAGS=true\n if (!${VARNISH_UNSET_HEADER_CACHE_TAGS:-false}) {\n unset resp.http.Cache-Tags;\n }\n\n unset resp.http.X-Generator;\n unset resp.http.Server;\n # Inject information about grace\n if (req.http.grace) {\n set resp.http.X-Varnish-Grace = req.http.grace;\n }\n set resp.http.X-LAGOON = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}>\" + resp.http.X-LAGOON;\n return (deliver);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n if (req.http.X-Forwarded-Proto) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n if (req.http.HTTPS) {\n hash_data(req.http.HTTPS);\n }\n return (lookup);\n}\n\nsub vcl_synth {\n if (resp.status == 701) {\n set resp.status = 401;\n set resp.http.Content-Type = \"text\/plain; charset=utf-8\";\n synthetic({\"XMLRPC Interface is blocked due to SA-CORE-2014-004 - mail support@amazee.io if you need it.\"});\n return (deliver);\n }\n if (resp.status == 700) {\n # Set a status the client will understand\n set resp.status = 200;\n # Create our synthetic response\n synthetic(\"\");\n return(deliver);\n}\n return (deliver);\n}\n\nsub vcl_backend_error {\n # Restart the request, when we have a backend server error, to try another backend.\n # Restart max twice.\n if (bereq.retries < 2) {\n return(retry);\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<head>\n <title>Server Error<\/title>\n <style type=\"text\/css\">\n body {\n font-family: helvetica, arial, sans-serif;\n }\n img {\n margin-top: 50px;\n }\n p {\n width: 6 00px;\n margin-top: 10px\n }\n div {\n background: #ccc;\n width: 600px;\n margin: auto;\n padding: 50px;\n }\n span {\n color: #ccc\n }\n <\/style>\n<\/head>\n<body>\n <div>\n <h1>We are sorry...<\/h1>\n <p>We encountered a server-side error. This means that the problem is not with your computer or Internet connection, but rather with the website's server.<\/p>\n <p>We are currently working on solving this problem and apologise for the inconvenience.<\/p>\n <span>\n <strong>Technical Information<\/strong><br \/>\n Error \"} + beresp.status + \" \" + beresp.reason + {\"<br \/>\n XID: \"} + bereq.xid + {\"<br \/>\n <\/span>\n <\/div>\n<\/body>\n<\/html>\n\n\"} );\n return (deliver);\n}\n","old_contents":"vcl 4.0;\n\nimport std;\n\n# set backend default\nbackend default {\n .host = \"${VARNISH_BACKEND_HOST:-nginx}\";\n .port = \"${VARNISH_BACKEND_PORT:-8080}\";\n .first_byte_timeout = 35m;\n .between_bytes_timeout = 10m;\n}\n\n# Allow purging from localhost\n# @TODO allow from openshift network\nacl purge {\n \"127.0.0.1\";\n \"10.0.0.0\"\/8;\n \"172.16.0.0\"\/12;\n \"192.168.0.0\"\/16;\n}\n\nsub vcl_init {\n new www_dir = dynamic.director(\n port = \"${VARNISH_BACKEND_PORT:-8080}\",\n probe = www_probe,\n whitelist = purge,\n ttl = 60s);\n }\n\n\n# This configuration is optimized for Drupal hosting:\n# Respond to incoming requests.\nsub vcl_recv {\n\n if (req.url ~ \"^\/varnish_status$\") {\n return (synth(200,\"OK\"));\n }\n # set the backend, which should be used:\n set req.backend_hint = www_dir.backend(\"${VARNISH_BACKEND_HOST:-nginx}\");\n\n # Always set the forward ip.\n if (req.restarts == 0) {\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n\n\n if (req.http.X-LAGOON-VARNISH ) {\n ## Pass all Requests which are handled via an upstream Varnish\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, \" + req.http.X-LAGOON-VARNISH;\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n } else if (req.http.Fastly-FF) {\n ## Pass all Requests which are handled via Fastly\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, fastly\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n set req.http.X-Forwarded-For = req.http.Fastly-Client-IP;\n } else if (req.http.CF-RAY) {\n ## Pass all Requests which are handled via CloudFlare\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, cloudflare\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n set req.http.X-Forwarded-For = req.http.CF-Connecting-IP;\n } else if (req.http.X-Pull) {\n ## Pass all Requests which are handled via KeyCDN\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, keycdn\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n } else {\n ## We set a header to let a Varnish Chain know that it already has been varnishcached\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}\";\n\n ## Allow to bypass based on env variable `VARNISH_BYPASS`\n set req.http.X-LAGOON-VARNISH-BYPASS = \"${VARNISH_BYPASS:-false}\";\n }\n\n # Websockets are piped\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n if (req.http.X-LAGOON-VARNISH-BYPASS == \"true\" || req.http.X-LAGOON-VARNISH-BYPASS == \"TRUE\") {\n return (pass);\n }\n\n # SA-CORE-2014-004 preventing access to \/xmlrpc.php\n if (req.url ~ \"^\/xmlrpc.php$\") {\n return (synth(701, \"Unauthorized\"));\n }\n\n # Strip out Google Analytics campaign variables. They are only needed\n # by the javascript running on the page\n # utm_source, utm_medium, utm_campaign, gclid\n if(req.url ~ \"(\\?|&)(gclid|utm_[a-z]+)=\") {\n set req.url = regsuball(req.url, \"(gclid|utm_[a-z]+)=[^\\&]+&?\", \"\");\n set req.url = regsub(req.url, \"(\\?|&)$\", \"\");\n }\n\n # Bypass a cache hit (the request is still sent to the backend)\n if (req.method == \"REFRESH\") {\n if (!client.ip ~ purge) { return (synth(405, \"Not allowed\")); }\n set req.method = \"GET\";\n set req.hash_always_miss = true;\n }\n\n # Only allow BAN requests from IP addresses in the 'purge' ACL.\n if (req.method == \"BAN\" || req.method == \"URIBAN\" || req.method == \"PURGE\") {\n # Only allow BAN from defined ACL\n if (!client.ip ~ purge) {\n return (synth(403, \"Your IP is not allowed.\"));\n }\n\n # Only allows BAN if the Host Header has the style of with \"${SERVICE_NAME:-varnish}:8080\" or \"${SERVICE_NAME:-varnish}\".\n # Such a request is only possible from within the Docker network, as a request from external goes trough the Kubernetes Router and for that needs a proper Host Header\n if (!req.http.host ~ \"^${SERVICE_NAME:-varnish}(:\\d+)?$\") {\n return (synth(403, \"Only allowed from within own network.\"));\n }\n\n if (req.method == \"BAN\") {\n # Logic for the ban, using the Cache-Tags header.\n if (req.http.Cache-Tags) {\n ban(\"obj.http.Cache-Tags ~ \" + req.http.Cache-Tags);\n # Throw a synthetic page so the request won't go to the backend.\n return (synth(200, \"Ban added.\"));\n }\n else {\n return (synth(403, \"Cache-Tags header missing.\"));\n }\n }\n\n if (req.method == \"URIBAN\" || req.method == \"PURGE\") {\n ban(\"req.url ~ \" + req.url);\n # Throw a synthetic page so the request won't go to the backend.\n return (synth(200, \"Ban added.\"));\n }\n\n }\n\n # Non-RFC2616 or CONNECT which is weird, we pipe that\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n return (pipe);\n }\n\n # We only try to cache GET and HEAD, other things are passed\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n # Any requests with Basic Auth are passed\n if (req.http.Authorization || req.http.Authenticate)\n {\n return (pass);\n }\n\n ## Pass requests which are from blackfire\n if (req.http.X-Blackfire-Query) {\n return (pass);\n }\n\n # Some URLs should never be cached\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/admin([\/?]|$).*$\" ||\n req.url ~ \"^\/info([\/?]|$).*$\" ||\n req.url ~ \"^\/flag([\/?]|$).*$\" ||\n req.url ~ \"^.*\/system\/files([\/?]|$).*$\" ||\n req.url ~ \"^\/cgi\" ||\n req.url ~ \"^\/cgi-bin\"\n ) {\n return (pass);\n }\n\n # Plupload likes to get piped\n if (req.url ~ \"^.*\/plupload-handle-uploads.*$\"\n ) {\n return (pipe);\n }\n\n # Handle compression correctly. Different browsers send different\n # \"Accept-Encoding\" headers, even though they mostly all support the same\n # compression mechanisms. By consolidating these compression headers into\n # a consistent format, we can reduce the size of the cache and get more hits.=\n # @see: http:\/\/ varnish.projects.linpro.no\/wiki\/FAQ\/Compression\n if (req.http.Accept-Encoding) {\n if (req.http.Accept-Encoding ~ \"gzip\") {\n # If the browser supports it, we'll use gzip.\n set req.http.Accept-Encoding = \"gzip\";\n }\n else if (req.http.Accept-Encoding ~ \"deflate\") {\n # Next, try deflate if it is supported.\n set req.http.Accept-Encoding = \"deflate\";\n }\n else {\n # Unknown algorithm. Remove it and send unencoded.\n unset req.http.Accept-Encoding;\n }\n }\n\n # Always cache the following file types for all users.\n if (req.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n unset req.http.Cookie;\n }\n\n # Remove all cookies that Drupal doesn't need to know about. ANY remaining\n # cookie will cause the request to pass-through to a backend. For the most part\n # we always set the NO_CACHE cookie after any POST request, disabling the\n # Varnish cache temporarily. The session cookie allows all authenticated users\n # to pass through as long as they're logged in.\n #\n # 1. Append a semi-colon to the front of the cookie string.\n # 2. Remove all spaces that appear after semi-colons.\n # 3. Match the cookies we want to keep, adding the space we removed\n # previously, back. (\\1) is first matching group in the regsuball.\n # 4. Remove all other cookies, identifying them by the fact that they have\n # no space after the preceding semi-colon.\n # 5. Remove all spaces and semi-colons from the beginning and end of the\n # cookie string.\n if (req.http.Cookie) {\n set req.http.CookieCheck = \";\" + req.http.Cookie;\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"; +\", \";\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";(${VARNISH_COOKIECHECK:-SESS[a-z0-9]+|SSESS[a-z0-9]+|NO_CACHE})=\", \"; \\1=\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";[^ ][^;]*\", \"\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"^[; ]+|[; ]+$\", \"\");\n\n set req.http.Cookie = req.http.Cookie + \";\";\n\n if (req.http.CookieCheck == \"\") {\n # If there are no remaining cookies, remove the cookie header. If there\n # aren't any cookie headers, Varnish's default behavior will be to cache\n # the page.\n\n unset req.http.CookieCheck;\n unset req.http.Cookie;\n }\n else {\n # If there is any cookies left (a session or NO_CACHE cookie), do not\n # cache the page. Pass it on to Apache directly.\n unset req.http.CookieCheck;\n return (pass);\n }\n }\n\n # Cacheable, lookup in cache.\n return (hash);\n}\n\nsub vcl_pipe {\n # Support for Websockets\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n set bereq.http.connection = req.http.connection;\n }\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n # normal hit\n return (deliver);\n }\n # We have no fresh fish. Lets look at the stale ones.\n if (std.healthy(req.backend_hint)) {\n # Backend is healthy. If the object is not older then 30secs, deliver it to the client\n # and automatically create a separate backend request to warm the cache for this request.\n if (obj.ttl + 30s > 0s) {\n set req.http.grace = \"normal(limited)\";\n return (deliver);\n } else {\n # No candidate for grace. Fetch a fresh object.\n return(miss);\n }\n } else {\n # backend is sick - use full grace\n if (obj.ttl + obj.grace > 0s) {\n set req.http.grace = \"full\";\n return (deliver);\n } else {\n # no graced object.\n return (miss);\n }\n }\n}\n\nsub vcl_backend_response {\n # Allow items to be stale if needed.\n set beresp.grace = 6h;\n\n # Set ban-lurker friendly custom headers.\n set beresp.http.X-Url = bereq.url;\n set beresp.http.X-Host = bereq.http.host;\n\n # If the backend sends a X-LAGOON-VARNISH-BACKEND-BYPASS header we directly deliver\n if(beresp.http.X-LAGOON-VARNISH-BACKEND-BYPASS == \"TRUE\") {\n return (deliver);\n }\n\n # Cache 404 and 403 for 10 seconds\n if(beresp.status == 404 || beresp.status == 403) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n # Don't allow static files to set cookies.\n if (bereq.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n # beresp == Back-end response from the web server.\n unset beresp.http.set-cookie;\n unset beresp.http.Cache-Control;\n\n # If an asset would come back with statuscode 500 we only cache it for 10 seconds instead of the usual static file cache\n if (beresp.status == 500) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n set beresp.ttl = ${VARNISH_ASSETS_TTL:-2628001}s;\n set beresp.http.Cache-Control = \"public, max-age=${VARNISH_ASSETS_TTL:-2628001}\";\n set beresp.http.Expires = \"\" + (now + beresp.ttl);\n }\n\n return (deliver);\n}\n\n# Set a header to track a cache HIT\/MISS.\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Varnish-Cache = \"HIT\";\n }\n else {\n set resp.http.X-Varnish-Cache = \"MISS\";\n }\n\n # Remove ban-lurker friendly custom headers when delivering to client.\n unset resp.http.X-Url;\n unset resp.http.X-Host;\n\n # unset Cache-Tags Header by default, can be disabled with VARNISH_UNSET_HEADER_CACHE_TAGS=true\n if (!${VARNISH_UNSET_HEADER_CACHE_TAGS:-false}) {\n unset resp.http.Cache-Tags;\n }\n\n unset resp.http.X-Generator;\n unset resp.http.Server;\n # Inject information about grace\n if (req.http.grace) {\n set resp.http.X-Varnish-Grace = req.http.grace;\n }\n set resp.http.X-LAGOON = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}>\" + resp.http.X-LAGOON;\n return (deliver);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n if (req.http.X-Forwarded-Proto) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n if (req.http.HTTPS) {\n hash_data(req.http.HTTPS);\n }\n return (lookup);\n}\n\nsub vcl_synth {\n if (resp.status == 701) {\n set resp.status = 401;\n set resp.http.Content-Type = \"text\/plain; charset=utf-8\";\n synthetic({\"XMLRPC Interface is blocked due to SA-CORE-2014-004 - mail support@amazee.io if you need it.\"});\n return (deliver);\n }\n if (resp.status == 700) {\n # Set a status the client will understand\n set resp.status = 200;\n # Create our synthetic response\n synthetic(\"\");\n return(deliver);\n}\n return (deliver);\n}\n\nsub vcl_backend_error {\n # Restart the request, when we have a backend server error, to try another backend.\n # Restart max twice.\n if (bereq.retries < 2) {\n return(retry);\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<head>\n <title>Server Error<\/title>\n <style type=\"text\/css\">\n body {\n font-family: helvetica, arial, sans-serif;\n }\n img {\n margin-top: 50px;\n }\n p {\n width: 6 00px;\n margin-top: 10px\n }\n div {\n background: #ccc;\n width: 600px;\n margin: auto;\n padding: 50px;\n }\n span {\n color: #ccc\n }\n <\/style>\n<\/head>\n<body>\n <div>\n <h1>We are sorry...<\/h1>\n <p>We encountered a server-side error. This means that the problem is not with your computer or Internet connection, but rather with the website's server.<\/p>\n <p>We are currently working on solving this problem and apologise for the inconvenience.<\/p>\n <span>\n <strong>Technical Information<\/strong><br \/>\n Error \"} + beresp.status + \" \" + beresp.reason + {\"<br \/>\n XID: \"} + bereq.xid + {\"<br \/>\n <\/span>\n <\/div>\n<\/body>\n<\/html>\n\n\"} );\n return (deliver);\n}\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"47bbbb6091bd0fdc1535f9c065600271992c0cd5","subject":"Remove custom VCL as it's deprecated","message":"Remove custom VCL as it's deprecated\n","repos":"fastly\/fastly-magento,fastly\/fastly-magento,fastly\/fastly-magento,fastly\/fastly-magento","old_file":"app\/code\/community\/Fastly\/CDN\/etc\/default.vcl","new_file":"app\/code\/community\/Fastly\/CDN\/etc\/default.vcl","new_contents":"","old_contents":"","returncode":0,"stderr":"unknown","license":"bsd-3-clause","lang":"VCL"} {"commit":"25a15c791b469c066971cb4a73b78996f9ea65ab","subject":"Update default.vcl","message":"Update default.vcl\n\nreproduce the setup on dev and stage","repos":"sylvestre\/treeherder,tojonmz\/treeherder,wlach\/treeherder,moijes12\/treeherder,kapy2010\/treeherder,glenn124f\/treeherder,glenn124f\/treeherder,deathping1994\/treeherder,jgraham\/treeherder,jgraham\/treeherder,deathping1994\/treeherder,gbrmachado\/treeherder,edmorley\/treeherder,glenn124f\/treeherder,gbrmachado\/treeherder,rail\/treeherder,akhileshpillai\/treeherder,edmorley\/treeherder,moijes12\/treeherder,parkouss\/treeherder,wlach\/treeherder,adusca\/treeherder,tojon\/treeherder,gbrmachado\/treeherder,KWierso\/treeherder,parkouss\/treeherder,kapy2010\/treeherder,moijes12\/treeherder,rail\/treeherder,kapy2010\/treeherder,parkouss\/treeherder,wlach\/treeherder,sylvestre\/treeherder,avih\/treeherder,glenn124f\/treeherder,glenn124f\/treeherder,edmorley\/treeherder,parkouss\/treeherder,rail\/treeherder,avih\/treeherder,akhileshpillai\/treeherder,glenn124f\/treeherder,moijes12\/treeherder,tojonmz\/treeherder,moijes12\/treeherder,wlach\/treeherder,adusca\/treeherder,kapy2010\/treeherder,wlach\/treeherder,edmorley\/treeherder,deathping1994\/treeherder,vaishalitekale\/treeherder,avih\/treeherder,jgraham\/treeherder,sylvestre\/treeherder,vaishalitekale\/treeherder,vaishalitekale\/treeherder,sylvestre\/treeherder,jgraham\/treeherder,adusca\/treeherder,wlach\/treeherder,rail\/treeherder,avih\/treeherder,tojonmz\/treeherder,vaishalitekale\/treeherder,parkouss\/treeherder,tojon\/treeherder,deathping1994\/treeherder,kapy2010\/treeherder,rail\/treeherder,deathping1994\/treeherder,avih\/treeherder,deathping1994\/treeherder,gbrmachado\/treeherder,akhileshpillai\/treeherder,avih\/treeherder,moijes12\/treeherder,jgraham\/treeherder,vaishalitekale\/treeherder,adusca\/treeherder,tojon\/treeherder,tojonmz\/treeherder,tojon\/treeherder,parkouss\/treeherder,adusca\/treeherder,akhileshpillai\/treeherder,KWierso\/treeherder,sylvestre\/treeherder,sylvestre\/treeherder,tojonmz\/treeherder,rail\/treeherder,gbrmachado\/treeherder,KWierso\/treeherder,tojonmz\/treeherder,adusca\/treeherder,gbrmachado\/treeherder,KWierso\/treeherder,jgraham\/treeherder,vaishalitekale\/treeherder,akhileshpillai\/treeherder,akhileshpillai\/treeherder","old_file":"puppet\/files\/varnish\/default.vcl","new_file":"puppet\/files\/varnish\/default.vcl","new_contents":"backend apache {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\nbackend socketio {\n .host = \"127.0.0.1\";\n .port = \"8005\";\n}\nsub vcl_pipe {\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n}\nsub vcl_recv {\n if (req.url ~ \"socket.io\/[0-9]\") {\n set req.backend = socketio;\n \n if(req.http.upgrade ~ \"(?i)websocket\"){\n return (pipe);\n }\n }\n else {\n set req.backend = apache;\n }\n return (pass);\n}\n\nsub vcl_fetch {\n if (beresp.http.content-type ~ \"json\" || beresp.http.content-type ~ \"text\" ) {\n set beresp.do_gzip = true;\n }\n}\n","old_contents":"backend apache {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\nbackend socketio {\n .host = \"127.0.0.1\";\n .port = \"8005\";\n}\nsub vcl_pipe {\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n}\nsub vcl_recv {\n if (req.url ~ \"socket.io\/[0-9]\") {\n set req.backend = socketio;\n return (pipe);\n }\n else {\n set req.backend = apache;\n }\n}\n\nsub vcl_fetch {\n if (beresp.http.content-type ~ \"json\" || beresp.http.content-type ~ \"text\" ) {\n set beresp.do_gzip = true;\n }\n}\n","returncode":0,"stderr":"","license":"mpl-2.0","lang":"VCL"} {"commit":"ca80d93cb53cbd91b496f97ccbd81006734ce047","subject":"redirect www.polyfill.io to polyfill.io","message":"redirect www.polyfill.io to polyfill.io\n","repos":"JakeChampion\/polyfill-service,JakeChampion\/polyfill-service","old_file":"fastly\/vcl\/redirects.vcl","new_file":"fastly\/vcl\/redirects.vcl","new_contents":"sub vcl_recv {\n\tif (req.http.Host ~ \"polyfills.io\") {\n\t\t# Fastly recommend using the 900-999 range of status codes for custom errors within an application's VCL.\n\t\t# Do the canonicalise checks before the HTTPS check to avoid a double redirect\n\t\terror 901 \"Canonicalise\";\n\t}\n\tif (req.http.Host ~ \"www.polyfill.io\") {\n\t\t# Do the canonicalise checks before the HTTPS check to avoid a double redirect\n\t\terror 909 \"Canonicalise\";\n\t}\n\tif (!req.http.Fastly-SSL) {\n\t\t# 801 is a special error code that Fastly uses to Force HTTPS on the request\n\t\terror 801 \"Redirect to HTTPS\";\n\t}\n\tif (req.http.Orig-URL ~ \"^\/v1\") {\n\t\terror 902 \"Redirect to V2\";\n\t}\n\t\n\tif (req.url.path ~ \"^\/v2\/?\") {\n\t\tif (!(req.url.path ~ \"^\/v2\/polyfill(\\.\\w+)(\\.\\w+)?\" && req.url.ext == \"js\")) {\n\t\t\terror 908;\n\t\t}\n\t}\n\tif (req.url.path == \"\/\") {\n\t\terror 908;\n\t}\n}\n\nsub vcl_error {\n # Redirect to canonical prod\/qa origins\n\tif (obj.status == 901) {\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\tset obj.http.Location = \"https:\/\/polyfill.io\" req.url;\n\t\tsynthetic {\"\"};\n\t\treturn (deliver);\n\t}\n\t# Redirect to v2\n\tif (obj.status == 902) {\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\t# Remove libVersion and gated query parameters if they exist.\n\t\tset req.url = querystring.regfilter(req.url, \"^\\b(libVersion|gated)\\b.*\");\n\t\tset obj.http.Location = if(req.url.path == \"\/v1\", \"\/v3\/\", regsub(req.url, \"^\/v1\", \"\/v2\"));\n\t\tset obj.http.Deprecation-Notice = \"API version 1 has been decommissioned - see the body of this response for more information.\";\n\t\tsynthetic {\"API version 1 has been decommissioned. Your request is being redirected to v2. The `libVersion` and `gated` query string parameters are no longer supported and if present have been removed from your request.\\n\\nA deprecation period for v1 existed between August and December 2015, during which time v1 requests were honoured but a deprecation warning was added to output.\"};\n\t\treturn (deliver);\n\t}\n\n\t# Redirect to v3\n\tif (obj.status == 908) {\n\t\tset obj.status = 301;\n\t\tset obj.http.Location = \"\/v3\/\";\n\t\treturn (deliver);\n\t}\n\t\n\t# Redirect to home\n\tif (obj.status == 908) {\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\tset obj.http.Location = \"https:\/\/polyfill.io\";\n\t\tsynthetic {\"\"};\n\t\treturn (deliver);\n\t}\n}\n","old_contents":"sub vcl_recv {\n\tif (req.http.Host ~ \"polyfills.io\") {\n\t\t# Fastly recommend using the 900-999 range of status codes for custom errors within an application's VCL.\n\t\t# Do the canonicalise check before the HTTPS check to avoid a double redirect\n\t\terror 901 \"Canonicalise\";\n\t}\n\tif (!req.http.Fastly-SSL) {\n\t\t# 801 is a special error code that Fastly uses to Force HTTPS on the request\n\t\terror 801 \"Redirect to HTTPS\";\n\t}\n\tif (req.http.Orig-URL ~ \"^\/v1\") {\n\t\terror 902 \"Redirect to V2\";\n\t}\n\t\n\tif (req.url.path ~ \"^\/v2\/?\") {\n\t\tif (!(req.url.path ~ \"^\/v2\/polyfill(\\.\\w+)(\\.\\w+)?\" && req.url.ext == \"js\")) {\n\t\t\terror 908;\n\t\t}\n\t}\n\tif (req.url.path == \"\/\") {\n\t\terror 908;\n\t}\n}\n\nsub vcl_error {\n # Redirect to canonical prod\/qa origins\n\tif (obj.status == 901) {\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\tset obj.http.Location = \"https:\/\/polyfill.io\" req.url;\n\t\tsynthetic {\"\"};\n\t\treturn (deliver);\n\t}\n\t# Redirect to v2\n\tif (obj.status == 902) {\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\t# Remove libVersion and gated query parameters if they exist.\n\t\tset req.url = querystring.regfilter(req.url, \"^\\b(libVersion|gated)\\b.*\");\n\t\tset obj.http.Location = if(req.url.path == \"\/v1\", \"\/v3\/\", regsub(req.url, \"^\/v1\", \"\/v2\"));\n\t\tset obj.http.Deprecation-Notice = \"API version 1 has been decommissioned - see the body of this response for more information.\";\n\t\tsynthetic {\"API version 1 has been decommissioned. Your request is being redirected to v2. The `libVersion` and `gated` query string parameters are no longer supported and if present have been removed from your request.\\n\\nA deprecation period for v1 existed between August and December 2015, during which time v1 requests were honoured but a deprecation warning was added to output.\"};\n\t\treturn (deliver);\n\t}\n\n\t# Redirect to v3\n\tif (obj.status == 908) {\n\t\tset obj.status = 301;\n\t\tset obj.http.Location = \"\/v3\/\";\n\t\treturn (deliver);\n\t}\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"e7f88a499fac7a7f3524a108a961ca2f1999dcf7","subject":"do not send cache-control ad expires headers if static files responds an 500","message":"do not send cache-control ad expires headers if static files responds an 500\n","repos":"amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon","old_file":"images\/varnish-drupal\/drupal.vcl","new_file":"images\/varnish-drupal\/drupal.vcl","new_contents":"vcl 4.0;\n\nimport std;\n\n# set backend default\nbackend default {\n .host = \"${VARNISH_HOST:-nginx}\";\n .port = \"8080\";\n .first_byte_timeout = 35m;\n .between_bytes_timeout = 10m;\n}\n\n# Allow purging from localhost\n# @TODO allow from openshift network\nacl purge {\n \"127.0.0.1\";\n}\n\n# This configuration is optimized for Drupal hosting:\n# Respond to incoming requests.\nsub vcl_recv {\n if (req.url ~ \"^\/varnish_status$\") {\n return (synth(200,\"OK\"));\n }\n # set the backend, which should be used:\n set req.backend_hint = default;\n\n # Always set the forward ip.\n if (req.restarts == 0) {\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n # SA-CORE-2014-004 preventing access to \/xmlrpc.php\n if (req.url ~ \"^\/xmlrpc.php$\") {\n return (synth(701, \"Unauthorized\"));\n }\n\n # Strip out Google Analytics campaign variables. They are only needed\n # by the javascript running on the page\n # utm_source, utm_medium, utm_campaign, gclid\n if(req.url ~ \"(\\?|&)(gclid|utm_[a-z]+)=\") {\n set req.url = regsuball(req.url, \"(gclid|utm_[a-z]+)=[^\\&]+&?\", \"\");\n set req.url = regsub(req.url, \"(\\?|&)$\", \"\");\n }\n\n # We set a header to let a Varnish Chain know that it already has been varnishcached\n set req.http.X-LAGOON-VARNISH = \"d3659c5e113e.amazee.io\";\n\n # Bypass a cache hit\n if (req.method == \"REFRESH\") {\n if (!client.ip ~ purge) { return (synth(405, \"Not allowed\")); }\n set req.method = \"GET\";\n set req.hash_always_miss = true;\n }\n\n # Non-RFC2616 or CONNECT which is weird, we pipe that\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n return (pipe);\n }\n\n # We only try to cache GET and HEAD, other things are passed\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n # Any requests with Basic Auth are passed\n if (req.http.Authorization || req.http.Authenticate)\n {\n return (pass);\n }\n\n ## Pass requests which are from blackfire\n if (req.http.X-Blackfire-Query) {\n return (pass);\n }\n\n # Some URLs should never be cached\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/admin([\/?]|$).*$\" ||\n req.url ~ \"^\/info([\/?]|$).*$\" ||\n req.url ~ \"^\/flag([\/?]|$).*$\" ||\n req.url ~ \"^.*\/system\/files([\/?]|$).*$\" ||\n req.url ~ \"^\/amazeeadmin\" ||\n req.url ~ \"^\/lithium\" ||\n req.url ~ \"^\/cgi\" ||\n req.url ~ \"^\/cgi-bin\"\n ) {\n return (pass);\n }\n\n # Plupload likes to get piped\n if (req.url ~ \"^.*\/plupload-handle-uploads.*$\"\n ) {\n return (pipe);\n }\n\n # Handle compression correctly. Different browsers send different\n # \"Accept-Encoding\" headers, even though they mostly all support the same\n # compression mechanisms. By consolidating these compression headers into\n # a consistent format, we can reduce the size of the cache and get more hits.=\n # @see: http:\/\/ varnish.projects.linpro.no\/wiki\/FAQ\/Compression\n if (req.http.Accept-Encoding) {\n if (req.http.Accept-Encoding ~ \"gzip\") {\n # If the browser supports it, we'll use gzip.\n set req.http.Accept-Encoding = \"gzip\";\n }\n else if (req.http.Accept-Encoding ~ \"deflate\") {\n # Next, try deflate if it is supported.\n set req.http.Accept-Encoding = \"deflate\";\n }\n else {\n # Unknown algorithm. Remove it and send unencoded.\n unset req.http.Accept-Encoding;\n }\n }\n\n # Always cache the following file types for all users.\n if (req.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n unset req.http.Cookie;\n }\n\n # Remove all cookies that Drupal doesn't need to know about. ANY remaining\n # cookie will cause the request to pass-through to a backend. For the most part\n # we always set the NO_CACHE cookie after any POST request, disabling the\n # Varnish cache temporarily. The session cookie allows all authenticated users\n # to pass through as long as they're logged in.\n #\n # 1. Append a semi-colon to the front of the cookie string.\n # 2. Remove all spaces that appear after semi-colons.\n # 3. Match the cookies we want to keep, adding the space we removed\n # previously, back. (\\1) is first matching group in the regsuball.\n # 4. Remove all other cookies, identifying them by the fact that they have\n # no space after the preceding semi-colon.\n # 5. Remove all spaces and semi-colons from the beginning and end of the\n # cookie string.\n if (req.http.Cookie) {\n set req.http.CookieCheck = \";\" + req.http.Cookie;\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"; +\", \";\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";(SESS[a-z0-9]+|SSESS[a-z0-9]+|NO_CACHE)=\", \"; \\1=\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";[^ ][^;]*\", \"\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"^[; ]+|[; ]+$\", \"\");\n\n set req.http.Cookie = req.http.Cookie + \";\";\n\n if (req.http.CookieCheck == \"\") {\n # If there are no remaining cookies, remove the cookie header. If there\n # aren't any cookie headers, Varnish's default behavior will be to cache\n # the page.\n\n unset req.http.CookieCheck;\n unset req.http.Cookie;\n }\n else {\n # If there is any cookies left (a session or NO_CACHE cookie), do not\n # cache the page. Pass it on to Apache directly.\n unset req.http.CookieCheck;\n return (pass);\n }\n }\n\n # Cacheable, lookup in cache.\n return (hash);\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n # normal hit\n return (deliver);\n }\n # We have no fresh fish. Lets look at the stale ones.\n if (std.healthy(req.backend_hint)) {\n # Backend is healthy. If the object is not older then 30secs, deliver it to the client\n # and automatically create a separate backend request to warm the cache for this request.\n if (obj.ttl + 30s > 0s) {\n set req.http.grace = \"normal(limited)\";\n return (deliver);\n } else {\n # No candidate for grace. Fetch a fresh object.\n return(miss);\n }\n } else {\n # backend is sick - use full grace\n if (obj.ttl + obj.grace > 0s) {\n set req.http.grace = \"full\";\n return (deliver);\n } else {\n # no graced object.\n return (miss);\n }\n }\n}\n\nsub vcl_backend_response {\n # Temporarily disable streaming on files to be tested and removed after Varnish 4.1.x upgrade\n set beresp.do_stream = false;\n\n # Allow items to be stale if needed.\n set beresp.grace = 6h;\n\n ## FIXME: rename X-LAGOON-VARNISH-BYPASS to X-LAGOON-VARNISH-BACKEND-BYPASS to avoid confusion\n # If the backend sends a X-LAGOON-VARNISH-BYPASS header we directly deliver\n if(beresp.http.X-LAGOON-VARNISH-BYPASS == \"TRUE\") {\n return (deliver);\n }\n\n # Cache 404 and 403 for 10 seconds\n if(beresp.status == 404 || beresp.status == 403) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n # Don't allow static files to set cookies.\n if (bereq.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n # beresp == Back-end response from the web server.\n unset beresp.http.set-cookie;\n unset beresp.http.Cache-Control;\n\n # If an asset would come back with statuscode 500 we only cache it for 10 seconds instead of the usual static file cache\n if (beresp.status == 500) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n set beresp.ttl = 2628001s;\n set beresp.http.Cache-Control = \"public, max-age=2628001\";\n set beresp.http.Expires = \"\" + (now + beresp.ttl);\n }\n\n return (deliver);\n}\n\n# Set a header to track a cache HIT\/MISS.\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Varnish-Cache = \"HIT\";\n }\n else {\n set resp.http.X-Varnish-Cache = \"MISS\";\n }\n unset resp.http.X-Generator;\n unset resp.http.Server;\n # Inject information about grace\n if (req.http.grace) {\n set resp.http.X-Varnish-Grace = req.http.grace;\n }\n set resp.http.X-LAGOON = \"varnish>\" + resp.http.X-LAGOON;\n return (deliver);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n if (req.http.X-Forwarded-Proto) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n if (req.http.HTTPS) {\n hash_data(req.http.HTTPS);\n }\n return (lookup);\n}\n\nsub vcl_synth {\n if (resp.status == 701) {\n set resp.status = 401;\n set resp.http.Content-Type = \"text\/plain; charset=utf-8\";\n synthetic({\"XMLRPC Interface is blocked due to SA-CORE-2014-004 - mail support@amazee.io if you need it.\"});\n return (deliver);\n }\n if (resp.status == 700) {\n # Set a status the client will understand\n set resp.status = 200;\n # Create our synthetic response\n synthetic(\"\");\n return(deliver);\n}\n return (deliver);\n}\n\nsub vcl_backend_error {\n # Restart the request, when we have a backend server error, to try another backend.\n # Restart max twice.\n if (bereq.retries < 2) {\n return(retry);\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<head>\n <title>Server Error<\/title>\n <style type=\"text\/css\">\n body {\n font-family: helvetica, arial, sans-serif;\n }\n img {\n margin-top: 50px;\n }\n p {\n width: 6 00px;\n margin-top: 10px\n }\n div {\n background: #ccc;\n width: 600px;\n margin: auto;\n padding: 50px;\n }\n span {\n color: #ccc\n }\n <\/style>\n<\/head>\n<body>\n <div>\n <h1>We are sorry...<\/h1>\n <p>We encountered a server-side error. This means that the problem is not with your computer or Internet connection, but rather with the website's server.<\/p>\n <p>We are currently working on solving this problem and apologise for the inconvenience.<\/p>\n <span>\n <strong>Technical Information<\/strong><br \/>\n Error \"} + beresp.status + \" \" + beresp.reason + {\"<br \/>\n XID: \"} + bereq.xid + {\"<br \/>\n <\/span>\n <\/div>\n<\/body>\n<\/html>\n\n\"} );\n return (deliver);\n}\n","old_contents":"vcl 4.0;\n\nimport std;\n\n# set backend default\nbackend default {\n .host = \"${VARNISH_HOST:-nginx}\";\n .port = \"8080\";\n .first_byte_timeout = 35m;\n .between_bytes_timeout = 10m;\n}\n\n# Allow purging from localhost\n# @TODO allow from openshift network\nacl purge {\n \"127.0.0.1\";\n}\n\n# This configuration is optimized for Drupal hosting:\n# Respond to incoming requests.\nsub vcl_recv {\n if (req.url ~ \"^\/varnish_status$\") {\n return (synth(200,\"OK\"));\n }\n # set the backend, which should be used:\n set req.backend_hint = default;\n\n # Always set the forward ip.\n if (req.restarts == 0) {\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n # SA-CORE-2014-004 preventing access to \/xmlrpc.php\n if (req.url ~ \"^\/xmlrpc.php$\") {\n return (synth(701, \"Unauthorized\"));\n }\n\n # Strip out Google Analytics campaign variables. They are only needed\n # by the javascript running on the page\n # utm_source, utm_medium, utm_campaign, gclid\n if(req.url ~ \"(\\?|&)(gclid|utm_[a-z]+)=\") {\n set req.url = regsuball(req.url, \"(gclid|utm_[a-z]+)=[^\\&]+&?\", \"\");\n set req.url = regsub(req.url, \"(\\?|&)$\", \"\");\n }\n\n # We set a header to let a Varnish Chain know that it already has been varnishcached\n set req.http.X-LAGOON-VARNISH = \"d3659c5e113e.amazee.io\";\n\n # Bypass a cache hit\n if (req.method == \"REFRESH\") {\n if (!client.ip ~ purge) { return (synth(405, \"Not allowed\")); }\n set req.method = \"GET\";\n set req.hash_always_miss = true;\n }\n\n # Non-RFC2616 or CONNECT which is weird, we pipe that\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n return (pipe);\n }\n\n # We only try to cache GET and HEAD, other things are passed\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n # Any requests with Basic Auth are passed\n if (req.http.Authorization || req.http.Authenticate)\n {\n return (pass);\n }\n\n ## Pass requests which are from blackfire\n if (req.http.X-Blackfire-Query) {\n return (pass);\n }\n\n # Some URLs should never be cached\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/admin([\/?]|$).*$\" ||\n req.url ~ \"^\/info([\/?]|$).*$\" ||\n req.url ~ \"^\/flag([\/?]|$).*$\" ||\n req.url ~ \"^.*\/system\/files([\/?]|$).*$\" ||\n req.url ~ \"^\/amazeeadmin\" ||\n req.url ~ \"^\/lithium\" ||\n req.url ~ \"^\/cgi\" ||\n req.url ~ \"^\/cgi-bin\"\n ) {\n return (pass);\n }\n\n # Plupload likes to get piped\n if (req.url ~ \"^.*\/plupload-handle-uploads.*$\"\n ) {\n return (pipe);\n }\n\n # Handle compression correctly. Different browsers send different\n # \"Accept-Encoding\" headers, even though they mostly all support the same\n # compression mechanisms. By consolidating these compression headers into\n # a consistent format, we can reduce the size of the cache and get more hits.=\n # @see: http:\/\/ varnish.projects.linpro.no\/wiki\/FAQ\/Compression\n if (req.http.Accept-Encoding) {\n if (req.http.Accept-Encoding ~ \"gzip\") {\n # If the browser supports it, we'll use gzip.\n set req.http.Accept-Encoding = \"gzip\";\n }\n else if (req.http.Accept-Encoding ~ \"deflate\") {\n # Next, try deflate if it is supported.\n set req.http.Accept-Encoding = \"deflate\";\n }\n else {\n # Unknown algorithm. Remove it and send unencoded.\n unset req.http.Accept-Encoding;\n }\n }\n\n # Always cache the following file types for all users.\n if (req.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n unset req.http.Cookie;\n }\n\n # Remove all cookies that Drupal doesn't need to know about. ANY remaining\n # cookie will cause the request to pass-through to a backend. For the most part\n # we always set the NO_CACHE cookie after any POST request, disabling the\n # Varnish cache temporarily. The session cookie allows all authenticated users\n # to pass through as long as they're logged in.\n #\n # 1. Append a semi-colon to the front of the cookie string.\n # 2. Remove all spaces that appear after semi-colons.\n # 3. Match the cookies we want to keep, adding the space we removed\n # previously, back. (\\1) is first matching group in the regsuball.\n # 4. Remove all other cookies, identifying them by the fact that they have\n # no space after the preceding semi-colon.\n # 5. Remove all spaces and semi-colons from the beginning and end of the\n # cookie string.\n if (req.http.Cookie) {\n set req.http.CookieCheck = \";\" + req.http.Cookie;\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"; +\", \";\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";(SESS[a-z0-9]+|SSESS[a-z0-9]+|NO_CACHE)=\", \"; \\1=\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";[^ ][^;]*\", \"\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"^[; ]+|[; ]+$\", \"\");\n\n set req.http.Cookie = req.http.Cookie + \";\";\n\n if (req.http.CookieCheck == \"\") {\n # If there are no remaining cookies, remove the cookie header. If there\n # aren't any cookie headers, Varnish's default behavior will be to cache\n # the page.\n\n unset req.http.CookieCheck;\n unset req.http.Cookie;\n }\n else {\n # If there is any cookies left (a session or NO_CACHE cookie), do not\n # cache the page. Pass it on to Apache directly.\n unset req.http.CookieCheck;\n return (pass);\n }\n }\n\n # Cacheable, lookup in cache.\n return (hash);\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n # normal hit\n return (deliver);\n }\n # We have no fresh fish. Lets look at the stale ones.\n if (std.healthy(req.backend_hint)) {\n # Backend is healthy. If the object is not older then 30secs, deliver it to the client\n # and automatically create a separate backend request to warm the cache for this request.\n if (obj.ttl + 30s > 0s) {\n set req.http.grace = \"normal(limited)\";\n return (deliver);\n } else {\n # No candidate for grace. Fetch a fresh object.\n return(miss);\n }\n } else {\n # backend is sick - use full grace\n if (obj.ttl + obj.grace > 0s) {\n set req.http.grace = \"full\";\n return (deliver);\n } else {\n # no graced object.\n return (miss);\n }\n }\n}\n\nsub vcl_backend_response {\n # Temporarily disable streaming on files to be tested and removed after Varnish 4.1.x upgrade\n set beresp.do_stream = false;\n\n # Allow items to be stale if needed.\n set beresp.grace = 6h;\n\n ## FIXME: rename X-LAGOON-VARNISH-BYPASS to X-LAGOON-VARNISH-BACKEND-BYPASS to avoid confusion\n # If the backend sends a X-LAGOON-VARNISH-BYPASS header we directly deliver\n if(beresp.http.X-LAGOON-VARNISH-BYPASS == \"TRUE\") {\n return (deliver);\n }\n\n # Cache 404 and 403 for 10 seconds\n if(beresp.status == 404 || beresp.status == 403) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n # Don't allow static files to set cookies.\n if (bereq.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n # beresp == Back-end response from the web server.\n unset beresp.http.set-cookie;\n unset beresp.http.Cache-Control;\n set beresp.ttl = 2628001s;\n set beresp.http.Cache-Control = \"public, max-age=2628001\";\n set beresp.http.Expires = \"\" + (now + beresp.ttl);\n \n # If an asset would come back with statuscode 500 we only cache it for 10 seconds instead of the usual static file cache\n if(beresp.status == 500) {\n set beresp.ttl = 10s;\n }\n }\n\n return (deliver);\n}\n\n# Set a header to track a cache HIT\/MISS.\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Varnish-Cache = \"HIT\";\n }\n else {\n set resp.http.X-Varnish-Cache = \"MISS\";\n }\n unset resp.http.X-Generator;\n unset resp.http.Server;\n # Inject information about grace\n if (req.http.grace) {\n set resp.http.X-Varnish-Grace = req.http.grace;\n }\n set resp.http.X-LAGOON = \"varnish>\" + resp.http.X-LAGOON;\n return (deliver);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n if (req.http.X-Forwarded-Proto) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n if (req.http.HTTPS) {\n hash_data(req.http.HTTPS);\n }\n return (lookup);\n}\n\nsub vcl_synth {\n if (resp.status == 701) {\n set resp.status = 401;\n set resp.http.Content-Type = \"text\/plain; charset=utf-8\";\n synthetic({\"XMLRPC Interface is blocked due to SA-CORE-2014-004 - mail support@amazee.io if you need it.\"});\n return (deliver);\n }\n if (resp.status == 700) {\n # Set a status the client will understand\n set resp.status = 200;\n # Create our synthetic response\n synthetic(\"\");\n return(deliver);\n}\n return (deliver);\n}\n\nsub vcl_backend_error {\n # Restart the request, when we have a backend server error, to try another backend.\n # Restart max twice.\n if (bereq.retries < 2) {\n return(retry);\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<head>\n <title>Server Error<\/title>\n <style type=\"text\/css\">\n body {\n font-family: helvetica, arial, sans-serif;\n }\n img {\n margin-top: 50px;\n }\n p {\n width: 6 00px;\n margin-top: 10px\n }\n div {\n background: #ccc;\n width: 600px;\n margin: auto;\n padding: 50px;\n }\n span {\n color: #ccc\n }\n <\/style>\n<\/head>\n<body>\n <div>\n <h1>We are sorry...<\/h1>\n <p>We encountered a server-side error. This means that the problem is not with your computer or Internet connection, but rather with the website's server.<\/p>\n <p>We are currently working on solving this problem and apologise for the inconvenience.<\/p>\n <span>\n <strong>Technical Information<\/strong><br \/>\n Error \"} + beresp.status + \" \" + beresp.reason + {\"<br \/>\n XID: \"} + bereq.xid + {\"<br \/>\n <\/span>\n <\/div>\n<\/body>\n<\/html>\n\n\"} );\n return (deliver);\n}\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"9fbe9ef1f7953aa7d54442916bd4ada940eaadd0","subject":"Add save and run command","message":"Add save and run command\n","repos":"aschneiderman\/atom-voice-vocola","old_file":"atom.vcl","new_file":"atom.vcl","new_contents":"# Voice commands for atom\n\ninclude folders.vch;\ninclude letters.vch;\n\n# Commands for developing D3: D3 visualizations, D3 Sandwiches\nSave and Reload = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Ctrl+r};\t\nSave and Really Reload = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Ctrl+Shift+r};\nSave and Run = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Up}{Enter};\n\n# File commands\nFind (File | Document) = {Ctrl+t};\nSave As = {Ctrl+Shift+s};\nNext Window = {Ctrl+Tab};\nLast Window = {Ctrl+Shift+Tab};\nLatest File = {Ctrl+Shift+t};\n(Tree View | List Files) = {Alt+o};\t# NOTE: to make this work, I had to create a new keyboard shortcut in Atom (my personal keymap.cson)\n\n\n# --- Text navigation commands ------------------------------------\n<delimiters> := (Quote = '\"' | 'Double Quote' = '\"' | 'Single Quote' = \"'\" | Comma = ',' | 'Equal Sign' = '=' | Equals = '=' \n\t| Period = '.' | Colon = ':' | 'Semi-Colon' = ';' | Hyphen = '-' | Underscore = '_' | Slash = '\/'\n\t| Paren = \"(\" | \"Close Paren\" = \")\" | Parentheses = \"(\" | \"Open Parenthesis\" = \"(\" | \"Close Parentheses\" = \")\"\n\t| Bracket = '[' | \"Close Bracket\" = ']' | Brace = '{' | 'Close Brace' = '}'\t);\n\nLine 1..200 = {Ctrl+g} $1 {Enter};\n(Left = 'b' | Right = 'f') Word = {Alt+$1};\nTop = {Ctrl+Home};\nBottom = {Ctrl+End};\n(Find = 'Right' | 'Insert After' = 'Right' | 'Insert Before' = 'Left') (Next = 'Enter' | Last = 'Shift+F3') <delimiters> \n\t\t= {Ctrl+f} $3 {$2} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') <delimiters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') 1..20 <delimiters> = {Ctrl+f} $3 {Enter} {Esc} Wait(100) {F3_$2} {Shift+F3} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') Enda <delimiters> = {End} {Ctrl+f} $2 {Enter} {Esc} {Shift+F3} Wait(100) {$1};\n\nFine Alpha <letters> = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Left};\nInsert (Before = 'Left' | After = 'Right') Alpha <letters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nFine Number 0..9 = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Right};\n(Find | Insert) Again = {F3} {Right};\n(Find | Insert) Again 1..20 Times = {F3_$1} {Right};\n\n(Set | Add | Clear | Hide | Delete) Bookmark = {Ctrl+Alt+F2};\n(Next = 'F2' | Last = 'Shift+F2') Bookmark = {$1};\n\n\n# --- Editing commands ----------------------------------------\nSelect Line = {Ctrl+l};\nSelect (Next = 'Down' | Forward = 'Down' | Last = 'Up' | Back = 'Up' | Previous = 'Up') 1..20 Lines = {Home} {Shift+$1_$2};\nMove Line (Up | Down) 1..20 = {Ctrl+$1_$2};\nAdd 1..20 (Lines = 'Down' | Line = 'Down' | Pages = 'PgDn' | Page = 'PgDn') = {Shift+$2_$1};\nStart Adding 1..20 Lines = {Home}{Shift+Down_$1};\n\n\nSelect between (Delimiters | Brackets | Tags) ={Ctrl+m} {Ctrl+Alt+m};\nDelete between Tags = {Ctrl+m} {Ctrl+Alt+m} {Del};\nDelete Tags = {Ctrl+Alt+F4};\nReplace With (Header | Heading) 1..7 = {Ctrl+Alt+F4} '<h' $2 '>' {End} '<\/h' $2 '>' {Home};\nReplace With (para = 'p') = {Ctrl+Alt+F4} '<' $1 '>' {End} '<\/' $1 '>';\n\n\nDelete Word = {Ctrl+Del};\nDelete 1..20 Words = {Ctrl+Del_$1};\nDelete (Back | Last) Word = {Ctrl+Backspace};\nDelete (Back | Last) 1..20 Words = {Ctrl+Backspace_$2};\nDelete Enda Word = {End} {Ctrl+Backspace};\nKill Word = {Ctrl+Backspace}{Ctrl+Del};\n\n(Delete Line | Dede) = {Ctrl+Shift+k};\nDelete 1..20 Lines = {Ctrl+Shift+k_$1};\n(Cut = 'x' | Paste = 'v' | Copy = 'c') That = {Ctrl+$1};\n\nComment (That | Line) = {Ctrl+\/};\nComment 1..20 Lines = {Home} {Shift+Down_$1} {Ctrl+\/};\n\nReplace = {Ctrl+f};\nReplace All = {Ctrl+Enter};\n\n(Join = 'j' | Indent = ']' | Dedent = '[') That = {Ctrl+$1};\n\n\n# --- Commands to create code\/tags -------------------------------------------\n# NOTE: basic HTML commands are stored in my global Vocala commands\n\nStart (\t# HTML commands\n\t'HTML page' = 'html' | pre = \"pre\" | 'Comment' = 'comment-html'\n\t| div = 'div' \n\n\t# D3 Recipe commands\n\t| 'Recipe Page' = 'recipe-page' | 'Recipe Row' = 'recipe-row' \n\t| 'Recipe Toy' = 'recipe-toy' | Toy = 'recipe-toy'\n\t| 'Bold ID'\n\n\t# D3 and JavaScript commands\n\t| Console = 'console' | Log = 'console'\n\t| Var = 'variable' | Variable = 'variable'\n\t# Coffeescript commands\n\t| Snippet = 'my-snippet' \n\t| 'Fix Line' = 'fix-current-line' | 'Fix Current Line' = 'fix-current-line'\n) = $1 {Tab};\n\nStop (\t#HTML commands\n\t'div comment' = 'comment-div-end' | Comment = 'comment-html-end' \n) = $1 {Tab};\n\n# HTML commands\nDot HTML = '.html';\nStart (Header | Heading) 1..7 = h $2 {Tab};\nAdd (Header | Heading) 1..7 = '<h' $2 '>' {End} '<\/h' $2 '>';\nAdd (para = 'p') = '<' $1 '>' {End} '<\/' $1 '>';\n\n# D3 Recipe commands\nPre-Format Code = {Ctrl+Alt+F5};\nReload Atom = {Ctrl+s} Wait(100) {Shift+Ctrl+Alt+F5};\nCommand Palette = {Ctrl+Shift+p};\nKeyboard Shortcuts = {Ctrl+.};\nRun Specs = {Ctrl+Alt+p};\nShow Console = {Ctrl+Alt+i};\n\n\n\n# D3 commands\nPaste Function = 'function ' {Ctrl+v} ' {' {Enter} {Enter} '};' {Up};\n\n# Coffeescript commands\n\n# Python commands\n\n\n# --- D3 commands -------------------------------------------\n\n\n# --- Python commands -------------------------------------------\n\n\n# --- Coffeescript commands -------------------------------------------","old_contents":"# Voice commands for atom\n\ninclude folders.vch;\ninclude letters.vch;\n\n# Commands for developing D3: D3 visualizations, D3 Sandwiches\nSave and Reload = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Ctrl+r};\t\nSave and Really Reload = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Ctrl+Shift+r};\n\n# File commands\nFind (File | Document) = {Ctrl+t};\nSave As = {Ctrl+Shift+s};\nNext Window = {Ctrl+Tab};\nLast Window = {Ctrl+Shift+Tab};\nLatest File = {Ctrl+Shift+t};\n(Tree View | List Files) = {Alt+o};\t# NOTE: to make this work, I had to create a new keyboard shortcut in Atom (my personal keymap.cson)\n\n\n# --- Text navigation commands ------------------------------------\n<delimiters> := (Quote = '\"' | 'Double Quote' = '\"' | 'Single Quote' = \"'\" | Comma = ',' | 'Equal Sign' = '=' | Equals = '=' \n\t| Period = '.' | Colon = ':' | 'Semi-Colon' = ';' | Hyphen = '-' | Underscore = '_' | Slash = '\/'\n\t| Paren = \"(\" | \"Close Paren\" = \")\" | Parentheses = \"(\" | \"Open Parenthesis\" = \"(\" | \"Close Parentheses\" = \")\"\n\t| Bracket = '[' | \"Close Bracket\" = ']' | Brace = '{' | 'Close Brace' = '}'\t);\n\nLine 1..200 = {Ctrl+g} $1 {Enter};\n(Left = 'b' | Right = 'f') Word = {Alt+$1};\nTop = {Ctrl+Home};\nBottom = {Ctrl+End};\n(Find = 'Right' | 'Insert After' = 'Right' | 'Insert Before' = 'Left') (Next = 'Enter' | Last = 'Shift+F3') <delimiters> \n\t\t= {Ctrl+f} $3 {$2} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') <delimiters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') 1..20 <delimiters> = {Ctrl+f} $3 {Enter} {Esc} Wait(100) {F3_$2} {Shift+F3} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') Enda <delimiters> = {End} {Ctrl+f} $2 {Enter} {Esc} {Shift+F3} Wait(100) {$1};\n\nFine Alpha <letters> = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Left};\nInsert (Before = 'Left' | After = 'Right') Alpha <letters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nFine Number 0..9 = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Right};\n(Find | Insert) Again = {F3} {Right};\n(Find | Insert) Again 1..20 Times = {F3_$1} {Right};\n\n(Set | Add | Clear | Hide | Delete) Bookmark = {Ctrl+Alt+F2};\n(Next = 'F2' | Last = 'Shift+F2') Bookmark = {$1};\n\n\n# --- Editing commands ----------------------------------------\nSelect Line = {Ctrl+l};\nSelect (Next = 'Down' | Forward = 'Down' | Last = 'Up' | Back = 'Up' | Previous = 'Up') 1..20 Lines = {Home} {Shift+$1_$2};\nMove Line (Up | Down) 1..20 = {Ctrl+$1_$2};\nAdd 1..20 (Lines = 'Down' | Line = 'Down' | Pages = 'PgDn' | Page = 'PgDn') = {Shift+$2_$1};\nStart Adding 1..20 Lines = {Home}{Shift+Down_$1};\n\n\nSelect between (Delimiters | Brackets | Tags) ={Ctrl+m} {Ctrl+Alt+m};\nDelete between Tags = {Ctrl+m} {Ctrl+Alt+m} {Del};\nDelete Tags = {Ctrl+Alt+F4};\nReplace With (Header | Heading) 1..7 = {Ctrl+Alt+F4} '<h' $2 '>' {End} '<\/h' $2 '>' {Home};\nReplace With (para = 'p') = {Ctrl+Alt+F4} '<' $1 '>' {End} '<\/' $1 '>';\n\n\nDelete Word = {Ctrl+Del};\nDelete 1..20 Words = {Ctrl+Del_$1};\nDelete (Back | Last) Word = {Ctrl+Backspace};\nDelete (Back | Last) 1..20 Words = {Ctrl+Backspace_$2};\nDelete Enda Word = {End} {Ctrl+Backspace};\nKill Word = {Ctrl+Backspace}{Ctrl+Del};\n\n(Delete Line | Dede) = {Ctrl+Shift+k};\nDelete 1..20 Lines = {Ctrl+Shift+k_$1};\n(Cut = 'x' | Paste = 'v' | Copy = 'c') That = {Ctrl+$1};\n\nComment (That | Line) = {Ctrl+\/};\nComment 1..20 Lines = {Home} {Shift+Down_$1} {Ctrl+\/};\n\nReplace = {Ctrl+f};\nReplace All = {Ctrl+Enter};\n\n(Join = 'j' | Indent = ']' | Dedent = '[') That = {Ctrl+$1};\n\n\n# --- Commands to create code\/tags -------------------------------------------\n# NOTE: basic HTML commands are stored in my global Vocala commands\n\nStart (\t# HTML commands\n\t'HTML page' = 'html' | pre = \"pre\" | 'Comment' = 'comment-html'\n\t| div = 'div' \n\n\t# D3 Recipe commands\n\t| 'Recipe Page' = 'recipe-page' | 'Recipe Row' = 'recipe-row' \n\t| 'Recipe Toy' = 'recipe-toy' | Toy = 'recipe-toy'\n\t| 'Bold ID'\n\n\t# D3 and JavaScript commands\n\t| Console = 'console' | Log = 'console'\n\t| Var = 'variable' | Variable = 'variable'\n\t# Coffeescript commands\n\t| Snippet = 'my-snippet' \n\t| 'Fix Line' = 'fix-current-line' | 'Fix Current Line' = 'fix-current-line'\n) = $1 {Tab};\n\nStop (\t#HTML commands\n\t'div comment' = 'comment-div-end' | Comment = 'comment-html-end' \n) = $1 {Tab};\n\n# HTML commands\nDot HTML = '.html';\nStart (Header | Heading) 1..7 = h $2 {Tab};\nAdd (Header | Heading) 1..7 = '<h' $2 '>' {End} '<\/h' $2 '>';\nAdd (para = 'p') = '<' $1 '>' {End} '<\/' $1 '>';\n\n# D3 Recipe commands\nPre-Format Code = {Ctrl+Alt+F5};\nReload Atom = {Ctrl+s} Wait(100) {Shift+Ctrl+Alt+F5};\nCommand Palette = {Ctrl+Shift+p};\nKeyboard Shortcuts = {Ctrl+.};\nRun Specs = {Ctrl+Alt+p};\nShow Console = {Ctrl+Alt+i};\n\n\n\n# D3 commands\nPaste Function = 'function ' {Ctrl+v} ' {' {Enter} {Enter} '};' {Up};\n\n# Coffeescript commands\n\n# Python commands\n\n\n# --- D3 commands -------------------------------------------\n\n\n# --- Python commands -------------------------------------------\n\n\n# --- Coffeescript commands -------------------------------------------","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"3359fb964c782309b5df531b7274336bd8825311","subject":"Tweaked regexp for BrowserProfile.","message":"Tweaked regexp for BrowserProfile.\n","repos":"noqcks\/ansible-varnish,killerwails\/ansible-varnish,gotofbi\/ansible-varnish,colstrom\/ansible-varnish,gotofbi\/ansible-varnish,telusdigital\/ansible-varnish,kkwoker\/ansible-varnish,killerwails\/ansible-varnish","old_file":"templates\/etc\/varnish\/default.vcl","new_file":"templates\/etc\/varnish\/default.vcl","new_contents":"vcl 4.0;\n\nimport directors;\nimport std;\n\n###\n# Varnish Documentation\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-built-in-subs.html\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/reference\/vcl.html\n##\n\n{% for backend in varnish_backend_hosts %}\nbackend application_{{ loop.index }} {\n .host = \"{{ backend }}\";\n .port = \"{{ varnish_backend_port }}\";\n{% if varnish_health_checks_enabled %}\n .probe = {\n .url = \"{{ varnish_health_check_url }}\";\n .interval = {{ varnish_health_check_interval }};\n .timeout = {{ varnish_health_check_timeout }};\n .window = {{ varnish_health_check_window }};\n .threshold = {{ varnish_health_check_threshold }};\n }\n{% endif %}\n}\n{% endfor %}\n\n###\n# vcl_init\n# Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n###\n# The vcl_init subroutine may terminate with calling return() with one of the following keywords:\n#\n# ok\n# Normal return, VCL continues loading.\n##\n\nsub vcl_init {\n new application = directors.round_robin();\n{% for backend in varnish_backend_hosts %}\n application.add_backend(application_{{ loop.index }});\n{% endfor %}\n}\n\n###\n# vcl_recv\n# Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use. \n# It is also used to modify the request\n###\n# The vcl_recv subroutine may terminate with calling return() on one of the following keywords:\n#\n# synth(status code, reason)\n# Return a synthetic object with the specified status code to the client and abandon the request.\n# pass\n# Switch to pass mode. Control will eventually pass to vcl_pass.\n# pipe\n# Switch to pipe mode. Control will eventually pass to vcl_pipe.\n# hash\n# Continue processing the object as a potential candidate for caching. Passes the control over to vcl_hash.\n# purge\n# Purge the object and it's variants. Control passes through vcl_hash to vcl_purge.\n#\n\nsub vcl_recv {\n set req.backend_hint = application.backend();\n\n ###\n # Avoid processing uncacheable requests\n ###\n\n if (req.http.Authorization) {\n return (pass);\n }\n\n ###\n # Inject X-Forwarded-For headers, but only once.\n ###\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n{% if varnish_header_sanitization_enabled %}\n ###\n # Header Sanitization\n ###\n\n{% if varnish_discards_port_from_host_header %}\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n{% endif %}\n\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_enabled %}\n ###\n # Cookie Sanitization\n ###\n\n ### Google Analytics\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n\n ### Quantcast\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n \n ### AddThis\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n\n ### General Cleanup\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n{% endif %}\n\n{% if varnish_uri_sanitization_enabled %}\n ###\n # URI Sanitization\n ###\n \n if (req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=\") {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n{% endif %}\n\n{% if varnish_workaround_telusdotcom_browser_profile %}\n ###\n # Workaround for BrowserProfile and Language\/Region Detection on TELUS.com\n ###\n\n if (req.http.Cookie ~ \"BrowserProfile\") {\n set req.http.X-Language = regsuball(req.http.Cookie, \"(language..:\\\\.)(.*)\\\\.,\", \"\\2\");\n set req.http.X-Province = regsuball(req.http.Cookie, \"(region..:\\\\.)(.*)\\\\.,\", \"\\2\");\n } else {\n if (req.http.Cookie ~ \"lang=\") {\n set req.http.X-Language = regsuball(req.http.Cookie, \"lang=(.*);\", \"\\1\");\n } else {\n set req.http.X-Language = \"en\";\n }\n\n if (req.http.Cookie ~ \"prov=\") {\n set req.http.X-Province = regsuball(req.http.Cookie, \"prov=(.*);\", \"\\1\");\n } else {\n set req.http.X-Province = \"BC\";\n }\n }\n\n if (req.url ~ \"\/(en|fr)\/\") {\n if (req.url ~ \"\/en\/\" && req.http.X-Language != \"en\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Language)\";\n return(pass);\n }\n if (req.url ~ \"\/fr\/\" && req.http.X-Language != \"fr\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Language)\";\n return(pass);\n }\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Language)\";\n return(pass);\n }\n\n if (req.url ~ \"\/(ab|bc|mb|nb|nl|ns|nt|nu|on|pe|qc|sk|yt)\/\") {\n {% for province in ['ab', 'bc', 'mb', 'nb', 'nl', 'ns', 'nt', 'nu', 'on', 'pe', 'qc', 'sk', 'yt'] %}\n if (req.url ~ \"{{ province }}\" && req.http.X-Province != \"{{ province }}\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Province)\";\n return(pass);\n }\n {% endfor %}\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Province)\";\n return(pass);\n }\n{% endif %}\n\n{% if varnish_blacklist_enabled %}\n if ((req.url ~ \"{{ varnish_blacklist_regexp }}\")) {\n set req.http.X-Passthrough-Reason = \"Path in Blacklist\";\n return(pass);\n } else {\n{% if varnish_discards_client_cookies %}\n unset req.http.Cookie;\n{% endif %}\n }\n{% endif %}\n\n}\n\n###\n# vcl_hit\n# Called when a cache lookup is successful.\n###\n# The vcl_hit subroutine may terminate with calling return() with one of the following keywords:\n#\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n# deliver\n# Deliver the object. Control passes to vcl_deliver.\n# synth(status code, reason)\n# Return the specified status code to the client and abandon the request.\n###\n\nsub vcl_hit {\n if (obj.ttl > 0s) {\n return (deliver);\n }\n{% if varnish_health_checks_enabled %}\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (fetch);\n }\n{% else %}\n if (obj.ttl + obj.grace > 0s) {\n return (deliver);\n }\n\n return (fetch);\n{% endif %}\n}\n\n###\n# vcl_backend_response\n# Called after the response headers has been successfully retrieved from the backend.\n###\n# The vcl_backend_response subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Possibly insert the object into the cache, then deliver it to the Control will eventually pass to vcl_deliver.\n# abandon\n# Abandon the backend request and generates an error.\n# retry\n# Retry the backend transaction. Increases the retries counter. If the number of retries is higher than max_retries Varnish emits a guru meditation error.\n###\n\nsub vcl_backend_response {\n{% if varnish_workaround_telusdotcom_browser_profile %}\n if (bereq.http.X-Language) {\n set beresp.http.X-Language = bereq.http.X-Language;\n }\n if (bereq.http.X-Province) {\n set beresp.http.X-Province = bereq.http.X-Province;\n }\n{% endif %}\n\n{% if varnish_blacklist_enabled %}\n if (bereq.url ~ \"{{ varnish_blacklist_regexp }}\") {\n set beresp.http.X-Cacheable = \"NO:Path in Blacklist\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n if (bereq.http.X-Passthrough-Reason) {\n set beresp.http.X-Passthrough-Reason = bereq.http.X-Passthrough-Reason;\n return(deliver);\n } else {\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n }\n }\n{% else %}\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n{% endif %}\n\n{% if varnish_cache_diagnostics_enabled %}\n if (bereq.http.Cookie) {\n set beresp.http.X-Cacheable = \"NO:Cookie in Request\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO:Set-Cookie in Response\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.X-No-Cache) {\n set beresp.http.X-Cacheable = \"NO:X-No-Cache\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.ttl <= 0s) {\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n{% endif %}\n\n set beresp.grace = {{ varnish_grace_period }};\n}\n\n###\n# vcl_deliver\n# Called before a cached object is delivered to the client.\n###\n# The vcl_deliver subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Deliver the object to the client.\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n###\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n","old_contents":"vcl 4.0;\n\nimport directors;\nimport std;\n\n###\n# Varnish Documentation\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-built-in-subs.html\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/reference\/vcl.html\n##\n\n{% for backend in varnish_backend_hosts %}\nbackend application_{{ loop.index }} {\n .host = \"{{ backend }}\";\n .port = \"{{ varnish_backend_port }}\";\n{% if varnish_health_checks_enabled %}\n .probe = {\n .url = \"{{ varnish_health_check_url }}\";\n .interval = {{ varnish_health_check_interval }};\n .timeout = {{ varnish_health_check_timeout }};\n .window = {{ varnish_health_check_window }};\n .threshold = {{ varnish_health_check_threshold }};\n }\n{% endif %}\n}\n{% endfor %}\n\n###\n# vcl_init\n# Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n###\n# The vcl_init subroutine may terminate with calling return() with one of the following keywords:\n#\n# ok\n# Normal return, VCL continues loading.\n##\n\nsub vcl_init {\n new application = directors.round_robin();\n{% for backend in varnish_backend_hosts %}\n application.add_backend(application_{{ loop.index }});\n{% endfor %}\n}\n\n###\n# vcl_recv\n# Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use. \n# It is also used to modify the request\n###\n# The vcl_recv subroutine may terminate with calling return() on one of the following keywords:\n#\n# synth(status code, reason)\n# Return a synthetic object with the specified status code to the client and abandon the request.\n# pass\n# Switch to pass mode. Control will eventually pass to vcl_pass.\n# pipe\n# Switch to pipe mode. Control will eventually pass to vcl_pipe.\n# hash\n# Continue processing the object as a potential candidate for caching. Passes the control over to vcl_hash.\n# purge\n# Purge the object and it's variants. Control passes through vcl_hash to vcl_purge.\n#\n\nsub vcl_recv {\n set req.backend_hint = application.backend();\n\n ###\n # Avoid processing uncacheable requests\n ###\n\n if (req.http.Authorization) {\n return (pass);\n }\n\n ###\n # Inject X-Forwarded-For headers, but only once.\n ###\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n{% if varnish_header_sanitization_enabled %}\n ###\n # Header Sanitization\n ###\n\n{% if varnish_discards_port_from_host_header %}\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n{% endif %}\n\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_enabled %}\n ###\n # Cookie Sanitization\n ###\n\n ### Google Analytics\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n\n ### Quantcast\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n \n ### AddThis\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n\n ### General Cleanup\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n{% endif %}\n\n{% if varnish_uri_sanitization_enabled %}\n ###\n # URI Sanitization\n ###\n \n if (req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=\") {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n{% endif %}\n\n{% if varnish_workaround_telusdotcom_browser_profile %}\n ###\n # Workaround for BrowserProfile and Language\/Region Detection on TELUS.com\n ###\n\n if (req.http.Cookie ~ \"BrowserProfile\") {\n set req.http.X-Language = regsuball(req.http.Cookie, \"language..:\\\\.(.*)\\\\.,\", \"\\1\");\n set req.http.X-Province = regsuball(req.http.Cookie, \"region..:\\\\.(.*)\\\\.,\", \"\\1\");\n } else {\n if (req.http.Cookie ~ \"lang=\") {\n set req.http.X-Language = regsuball(req.http.Cookie, \"lang=(.*);\", \"\\1\");\n } else {\n set req.http.X-Language = \"en\";\n }\n\n if (req.http.Cookie ~ \"prov=\") {\n set req.http.X-Province = regsuball(req.http.Cookie, \"prov=(.*);\", \"\\1\");\n } else {\n set req.http.X-Province = \"BC\";\n }\n }\n\n if (req.url ~ \"\/(en|fr)\/\") {\n if (req.url ~ \"\/en\/\" && req.http.X-Language != \"en\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Language)\";\n return(pass);\n }\n if (req.url ~ \"\/fr\/\" && req.http.X-Language != \"fr\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Language)\";\n return(pass);\n }\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Language)\";\n return(pass);\n }\n\n if (req.url ~ \"\/(ab|bc|mb|nb|nl|ns|nt|nu|on|pe|qc|sk|yt)\/\") {\n {% for province in ['ab', 'bc', 'mb', 'nb', 'nl', 'ns', 'nt', 'nu', 'on', 'pe', 'qc', 'sk', 'yt'] %}\n if (req.url ~ \"{{ province }}\" && req.http.X-Province != \"{{ province }}\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Province)\";\n return(pass);\n }\n {% endfor %}\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Province)\";\n return(pass);\n }\n{% endif %}\n\n{% if varnish_blacklist_enabled %}\n if ((req.url ~ \"{{ varnish_blacklist_regexp }}\")) {\n set req.http.X-Passthrough-Reason = \"Path in Blacklist\";\n return(pass);\n } else {\n{% if varnish_discards_client_cookies %}\n unset req.http.Cookie;\n{% endif %}\n }\n{% endif %}\n\n}\n\n###\n# vcl_hit\n# Called when a cache lookup is successful.\n###\n# The vcl_hit subroutine may terminate with calling return() with one of the following keywords:\n#\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n# deliver\n# Deliver the object. Control passes to vcl_deliver.\n# synth(status code, reason)\n# Return the specified status code to the client and abandon the request.\n###\n\nsub vcl_hit {\n if (obj.ttl > 0s) {\n return (deliver);\n }\n{% if varnish_health_checks_enabled %}\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (fetch);\n }\n{% else %}\n if (obj.ttl + obj.grace > 0s) {\n return (deliver);\n }\n\n return (fetch);\n{% endif %}\n}\n\n###\n# vcl_backend_response\n# Called after the response headers has been successfully retrieved from the backend.\n###\n# The vcl_backend_response subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Possibly insert the object into the cache, then deliver it to the Control will eventually pass to vcl_deliver.\n# abandon\n# Abandon the backend request and generates an error.\n# retry\n# Retry the backend transaction. Increases the retries counter. If the number of retries is higher than max_retries Varnish emits a guru meditation error.\n###\n\nsub vcl_backend_response {\n{% if varnish_workaround_telusdotcom_browser_profile %}\n if (bereq.http.X-Language) {\n set beresp.http.X-Language = bereq.http.X-Language;\n }\n if (bereq.http.X-Province) {\n set beresp.http.X-Province = bereq.http.X-Province;\n }\n{% endif %}\n\n{% if varnish_blacklist_enabled %}\n if (bereq.url ~ \"{{ varnish_blacklist_regexp }}\") {\n set beresp.http.X-Cacheable = \"NO:Path in Blacklist\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n if (bereq.http.X-Passthrough-Reason) {\n set beresp.http.X-Passthrough-Reason = bereq.http.X-Passthrough-Reason;\n return(deliver);\n } else {\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n }\n }\n{% else %}\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n{% endif %}\n\n{% if varnish_cache_diagnostics_enabled %}\n if (bereq.http.Cookie) {\n set beresp.http.X-Cacheable = \"NO:Cookie in Request\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO:Set-Cookie in Response\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.X-No-Cache) {\n set beresp.http.X-Cacheable = \"NO:X-No-Cache\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.ttl <= 0s) {\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n{% endif %}\n\n set beresp.grace = {{ varnish_grace_period }};\n}\n\n###\n# vcl_deliver\n# Called before a cached object is delivered to the client.\n###\n# The vcl_deliver subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Deliver the object to the client.\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n###\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"b4c0c6a71ec2f9ab2c786e8ad353fa01d4a966f9","subject":"Enabling processing ESIs inside CDATA","message":"Enabling processing ESIs inside CDATA\n","repos":"fastly\/fastly-magento,fastly\/fastly-magento,fastly\/fastly-magento,fastly\/fastly-magento","old_file":"app\/code\/community\/Fastly\/CDN\/etc\/vcl_snippets\/recv.vcl","new_file":"app\/code\/community\/Fastly\/CDN\/etc\/vcl_snippets\/recv.vcl","new_contents":" # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n # Pass any checkout, cart or customer\/myaccount urls\n if (req.url.path ~ \"\/(cart|checkout|customer)\") {\n set req.http.x-pass = \"1\";\n # Pass all admin actions\n } else if (req.url.path ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\") {\n set req.http.x-pass = \"1\";\n # bypass language switcher\n } else if (req.url.qs ~ \"(?i)___from_store=.*&___store=.*\") {\n set req.http.x-pass = \"1\";\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (req.http.cookie:FASTLY_CDN_ENV) {\n set req.http.Fastly-Cdn-Env = req.http.cookie:FASTLY_CDN_ENV;\n } else {\n unset req.http.Fastly-Cdn-Env;\n }\n\n ############################################################################################################\n # Following code block controls purge by URL. By default we want to protect all URL purges. In general this\n # is addressed by adding Fastly-Purge-Requires-Auth request header in vcl_recv however this runs the risk of\n # exposing API tokens if user attempts to purge non-https URLs. For this reason inside the Magento module\n # we use X-Purge-Token. Unfortunately this breaks purge from the Fastly UI. Therefore in the next code block\n # we check for presence of X-Purge-Token. If it's not present we force the Fastly-Purge-Requires-Auth\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n if (req.http.X-Purge-Token && req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n } else {\n error 403;\n }\n } else {\n set req.http.Fastly-Purge-Requires-Auth = \"1\";\n }\n }\n\n # disable ESI processing on Origin Shield\n if (req.http.Fastly-FF) {\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n } else {\n set esi.allow_inside_cdata = true;\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url.path ~ \"^\/(media|js|skin)\/.*\\.(png|jpg|jpeg|gif|css|js|swf|ico|webp|svg)$\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n # formkey lookup\n if (req.url.path ~ \"\/fastlycdn\/getformkey\/\") {\n # check if we have a formkey cookie and that it's validly formed\n if (req.http.Cookie:FASTLY_CDN_FORMKEY &&\nstd.strlen(req.http.Cookie:FASTLY_CDN_FORMKEY) < 40 && req.http.Cookie:FASTLY_CDN_FORMKEY ~ \"^[a-zA-Z0-9-_]*$\" ) {\n set req.http.Formkey = req.http.Cookie:FASTLY_CDN_FORMKEY;\n } else {\n # create formkey\n set req.http.seed = req.http.Cookie client.ip remote.port client.geo.longitude client.geo.latitude client.geo.postal_code;\n set req.http.Formkey = regsub(digest.hash_md5(req.http.seed), \"^0x\", \"\");\n }\n error 760 req.http.Formkey;\n }\n\n # client.geo lookup\n if (req.url.path ~ \"fastlycdn\/esi\/getcountry\/\") {\n # check if GeoIP has been already processed by client\n if (req.http.Cookie:FASTLY_CDN_GEOIP_PROCESSED) {\n error 200 \"\";\n } else {\n # modify req.url and restart request processing\n error 750 client.geo.country_code;\n }\n }\n\n # client.geo get country code\n if (req.url.path ~ \"fastlycdn\/esi\/getcountrycode\/\") {\n # create and set req.http.X-Country-Code\n error 755 client.geo.country_code;\n }\n\n # check for ESI calls\n if (req.url.qs ~ \"esi_data=\") {\n # check for valid cookie data\n declare local var.esi_data_field STRING;\n declare local var.cookie_data STRING;\n # Based on esi_data value requested we will need to search for cookie FASTLY_CDN-<type> e.g. FASTLY_CDN-customer_quote\n set var.esi_data_field = \"FASTLY_CDN-\" subfield(req.url.qs, \"esi_data\", \"&\");\n # We can't use variables in either subfield or regex so we need to use this workaround\n # to extract value of cookie that we compiled in esi_data_field\n set var.cookie_data = std.strstr(req.http.Cookie,var.esi_data_field);\n set var.cookie_data = regsub(var.cookie_data,\"^[^=]*=([^;]*).*\",\"\\1\");\n # If found a value we replace the query string with the contents of that cookie\n if ( var.cookie_data != \"\" ) {\n set req.url = querystring.set(req.url, \"esi_data\", var.cookie_data);\n }\n }\n\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking\n set req.http.Magento-Original-URL = req.url;\n set req.url = querystring.regfilter(req.url, \"^(####QUERY_PARAMETERS####)\");\n # Sort the query arguments to increase cache hit ratio with query arguments that\n # may be out of order however only on URLs that are not being passed. \n if ( !req.http.x-pass ) {\n set req.url = boltsort.sort(req.url);\n }\n","old_contents":" # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n # Pass any checkout, cart or customer\/myaccount urls\n if (req.url.path ~ \"\/(cart|checkout|customer)\") {\n set req.http.x-pass = \"1\";\n # Pass all admin actions\n } else if (req.url.path ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\") {\n set req.http.x-pass = \"1\";\n # bypass language switcher\n } else if (req.url.qs ~ \"(?i)___from_store=.*&___store=.*\") {\n set req.http.x-pass = \"1\";\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (req.http.cookie:FASTLY_CDN_ENV) {\n set req.http.Fastly-Cdn-Env = req.http.cookie:FASTLY_CDN_ENV;\n } else {\n unset req.http.Fastly-Cdn-Env;\n }\n\n ############################################################################################################\n # Following code block controls purge by URL. By default we want to protect all URL purges. In general this\n # is addressed by adding Fastly-Purge-Requires-Auth request header in vcl_recv however this runs the risk of\n # exposing API tokens if user attempts to purge non-https URLs. For this reason inside the Magento module\n # we use X-Purge-Token. Unfortunately this breaks purge from the Fastly UI. Therefore in the next code block\n # we check for presence of X-Purge-Token. If it's not present we force the Fastly-Purge-Requires-Auth\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n if (req.http.X-Purge-Token && req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n } else {\n error 403;\n }\n } else {\n set req.http.Fastly-Purge-Requires-Auth = \"1\";\n }\n }\n\n # disable ESI processing on Origin Shield\n if (req.http.Fastly-FF) {\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url.path ~ \"^\/(media|js|skin)\/.*\\.(png|jpg|jpeg|gif|css|js|swf|ico|webp|svg)$\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n # formkey lookup\n if (req.url.path ~ \"\/fastlycdn\/getformkey\/\") {\n # check if we have a formkey cookie and that it's validly formed\n if (req.http.Cookie:FASTLY_CDN_FORMKEY &&\nstd.strlen(req.http.Cookie:FASTLY_CDN_FORMKEY) < 40 && req.http.Cookie:FASTLY_CDN_FORMKEY ~ \"^[a-zA-Z0-9-_]*$\" ) {\n set req.http.Formkey = req.http.Cookie:FASTLY_CDN_FORMKEY;\n } else {\n # create formkey\n set req.http.seed = req.http.Cookie client.ip remote.port client.geo.longitude client.geo.latitude client.geo.postal_code;\n set req.http.Formkey = regsub(digest.hash_md5(req.http.seed), \"^0x\", \"\");\n }\n error 760 req.http.Formkey;\n }\n\n # client.geo lookup\n if (req.url.path ~ \"fastlycdn\/esi\/getcountry\/\") {\n # check if GeoIP has been already processed by client\n if (req.http.Cookie:FASTLY_CDN_GEOIP_PROCESSED) {\n error 200 \"\";\n } else {\n # modify req.url and restart request processing\n error 750 client.geo.country_code;\n }\n }\n\n # client.geo get country code\n if (req.url.path ~ \"fastlycdn\/esi\/getcountrycode\/\") {\n # create and set req.http.X-Country-Code\n error 755 client.geo.country_code;\n }\n\n # check for ESI calls\n if (req.url.qs ~ \"esi_data=\") {\n # check for valid cookie data\n declare local var.esi_data_field STRING;\n declare local var.cookie_data STRING;\n # Based on esi_data value requested we will need to search for cookie FASTLY_CDN-<type> e.g. FASTLY_CDN-customer_quote\n set var.esi_data_field = \"FASTLY_CDN-\" subfield(req.url.qs, \"esi_data\", \"&\");\n # We can't use variables in either subfield or regex so we need to use this workaround\n # to extract value of cookie that we compiled in esi_data_field\n set var.cookie_data = std.strstr(req.http.Cookie,var.esi_data_field);\n set var.cookie_data = regsub(var.cookie_data,\"^[^=]*=([^;]*).*\",\"\\1\");\n # If found a value we replace the query string with the contents of that cookie\n if ( var.cookie_data != \"\" ) {\n set req.url = querystring.set(req.url, \"esi_data\", var.cookie_data);\n }\n }\n\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking\n set req.http.Magento-Original-URL = req.url;\n set req.url = querystring.regfilter(req.url, \"^(####QUERY_PARAMETERS####)\");\n # Sort the query arguments to increase cache hit ratio with query arguments that\n # may be out of order however only on URLs that are not being passed. \n if ( !req.http.x-pass ) {\n set req.url = boltsort.sort(req.url);\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"015dbcb9ae575a2b1d429783716ef58c285af969","subject":"Syntax tweaks","message":"Syntax tweaks","repos":"whyneus\/magneto-ponies,whyneus\/magneto-ponies,whyneus\/magneto-ponies","old_file":"m2-default.vcl","new_file":"m2-default.vcl","new_contents":"# Source: https:\/\/raw.githubusercontent.com\/magento\/magento2\/2.1\/app\/code\/Magento\/PageCache\/etc\/varnish4.vcl\n# This VCL is part of the Magento2 application code should be maintained by the website developer or Service Integrator. \n# Modifications from source: .host, .port, acl purge ranges, and use of X-Forwarded-Proto header.\n\nvcl 4.0;\n\nimport std;\n# The minimal Varnish version is 4.0\n# For SSL offloading, pass the following header in your proxy server or load balancer: 'X-Forwarded-Proto: https'\n\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\n\nacl purge {\n \"127.0.0.1\";\n \"192.168.0.0\"\/16;\n \"172.24.0.0\"\/16;\n \"10.0.0.0\"\/8;\n}\n\nsub vcl_recv {\n if (req.method == \"PURGE\") {\n if (client.ip !~ purge) {\n return (synth(405, \"Method not allowed\"));\n }\n if (!req.http.X-Magento-Tags-Pattern) {\n return (synth(400, \"X-Magento-Tags-Pattern header required\"));\n }\n ban(\"obj.http.X-Magento-Tags ~ \" + req.http.X-Magento-Tags-Pattern);\n return (synth(200, \"Purged\"));\n }\n\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n # We only deal with GET and HEAD by default\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n # Bypass shopping cart, checkout and search requests\n if (req.url ~ \"\/checkout\" || req.url ~ \"\/catalogsearch\") {\n return (pass);\n }\n\n # normalize url in case of leading HTTP scheme and domain\n set req.url = regsub(req.url, \"^http[s]?:\/\/\", \"\");\n\n # collect all cookies\n std.collect(req.http.Cookie);\n\n # Compression filter. See https:\/\/www.varnish-cache.org\/trac\/wiki\/FAQ\/Compression\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|flv)$\") {\n # No point in compressing these\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\" && req.http.user-agent !~ \"MSIE\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n # unkown algorithm\n unset req.http.Accept-Encoding;\n }\n }\n\n # Remove Google gclid parameters to minimize the cache objects\n set req.url = regsuball(req.url,\"\\?gclid=[^&]+$\",\"\"); # strips when QS = \"?gclid=AAA\"\n set req.url = regsuball(req.url,\"\\?gclid=[^&]+&\",\"?\"); # strips when QS = \"?gclid=AAA&foo=bar\"\n set req.url = regsuball(req.url,\"&gclid=[^&]+\",\"\"); # strips when QS = \"?foo=bar&gclid=AAA\" or QS = \"?foo=bar&gclid=AAA&bar=baz\"\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(pub\/)?(media|static)\/.*\\.(ico|css|js|jpg|jpeg|png|gif|tiff|bmp|mp3|ogg|svg|swf|woff|woff2|eot|ttf|otf)$\") {\n unset req.http.Https;\n unset req.http.X-Forwarded-Proto;\n unset req.http.Cookie;\n }\n\n return (hash);\n}\n\nsub vcl_hash {\n if (req.http.cookie ~ \"X-Magento-Vary=\") {\n hash_data(regsub(req.http.cookie, \"^.*?X-Magento-Vary=([^;]+);*.*$\", \"\\1\"));\n }\n\n # For multi site configurations to not cache each other's content\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n\n # To make sure http users don't see ssl warning\n if (req.http.X-Forwarded-Proto) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n #\/* {{ design_exceptions_code }} *\/\n}\n\nsub vcl_backend_response {\n if (beresp.http.content-type ~ \"text\") {\n set beresp.do_esi = true;\n }\n\n if (bereq.url ~ \"\\.js$\" || beresp.http.content-type ~ \"text\") {\n set beresp.do_gzip = true;\n }\n\n # cache only successfully responses and 404s\n if (beresp.status != 200 && beresp.status != 404) {\n set beresp.ttl = 0s;\n set beresp.uncacheable = true;\n return (deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.uncacheable = true;\n set beresp.ttl = 86400s;\n return (deliver);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (bereq.method == \"GET\" || bereq.method == \"HEAD\")) {\n unset beresp.http.set-cookie;\n if (bereq.url !~ \"\\.(ico|css|js|jpg|jpeg|png|gif|tiff|bmp|gz|tgz|bz2|tbz|mp3|ogg|svg|swf|woff|woff2|eot|ttf|otf)(\\?|$)\") {\n set beresp.http.Pragma = \"no-cache\";\n set beresp.http.Expires = \"-1\";\n set beresp.http.Cache-Control = \"no-store, no-cache, must-revalidate, max-age=0\";\n set beresp.grace = 1m;\n }\n }\n\n # If page is not cacheable then bypass varnish for 2 minutes as Hit-For-Pass\n if (beresp.ttl <= 0s ||\n beresp.http.Surrogate-control ~ \"no-store\" ||\n (!beresp.http.Surrogate-Control && beresp.http.Vary == \"*\")) {\n # Mark as Hit-For-Pass for the next 2 minutes\n set beresp.ttl = 120s;\n set beresp.uncacheable = true;\n }\n return (deliver);\n}\n\nsub vcl_deliver {\n if (resp.http.X-Magento-Debug) {\n if (resp.http.x-varnish ~ \" \") {\n set resp.http.X-Magento-Cache-Debug = \"HIT\";\n } else {\n set resp.http.X-Magento-Cache-Debug = \"MISS\";\n }\n } else {\n unset resp.http.Age;\n }\n\n unset resp.http.X-Magento-Debug;\n unset resp.http.X-Magento-Tags;\n unset resp.http.X-Powered-By;\n unset resp.http.Server;\n unset resp.http.X-Varnish;\n unset resp.http.Via;\n unset resp.http.Link;\n}\n","old_contents":"# Source: https:\/\/raw.githubusercontent.com\/magento\/magento2\/2.1\/app\/code\/Magento\/PageCache\/etc\/varnish4.vcl\n# This VCL is part of the Magento2 application code should be maintained by the website developer or Service Integrator. \n# Modifications from source: .host, .port, acl purge ranges, and use of X-Forwarded-Proto header.\n\nvcl 4.0;\n\nimport std;\n# The minimal Varnish version is 4.0\n# For SSL offloading, pass the following header in your proxy server or load balancer: 'X-Forwarded-Proto: https'\n\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\n\nacl purge {\n \"127.0.0.1\"\n \"192.168.0.0\"\/16\n \"172.24.0.0\"\/16\n \"10.0.0.0\"\/8\n}\n\nsub vcl_recv {\n if (req.method == \"PURGE\") {\n if (client.ip !~ purge) {\n return (synth(405, \"Method not allowed\"));\n }\n if (!req.http.X-Magento-Tags-Pattern) {\n return (synth(400, \"X-Magento-Tags-Pattern header required\"));\n }\n ban(\"obj.http.X-Magento-Tags ~ \" + req.http.X-Magento-Tags-Pattern);\n return (synth(200, \"Purged\"));\n }\n\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n # We only deal with GET and HEAD by default\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n # Bypass shopping cart, checkout and search requests\n if (req.url ~ \"\/checkout\" || req.url ~ \"\/catalogsearch\") {\n return (pass);\n }\n\n # normalize url in case of leading HTTP scheme and domain\n set req.url = regsub(req.url, \"^http[s]?:\/\/\", \"\");\n\n # collect all cookies\n std.collect(req.http.Cookie);\n\n # Compression filter. See https:\/\/www.varnish-cache.org\/trac\/wiki\/FAQ\/Compression\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|flv)$\") {\n # No point in compressing these\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\" && req.http.user-agent !~ \"MSIE\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n # unkown algorithm\n unset req.http.Accept-Encoding;\n }\n }\n\n # Remove Google gclid parameters to minimize the cache objects\n set req.url = regsuball(req.url,\"\\?gclid=[^&]+$\",\"\"); # strips when QS = \"?gclid=AAA\"\n set req.url = regsuball(req.url,\"\\?gclid=[^&]+&\",\"?\"); # strips when QS = \"?gclid=AAA&foo=bar\"\n set req.url = regsuball(req.url,\"&gclid=[^&]+\",\"\"); # strips when QS = \"?foo=bar&gclid=AAA\" or QS = \"?foo=bar&gclid=AAA&bar=baz\"\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(pub\/)?(media|static)\/.*\\.(ico|css|js|jpg|jpeg|png|gif|tiff|bmp|mp3|ogg|svg|swf|woff|woff2|eot|ttf|otf)$\") {\n unset req.http.Https;\n unset req.http.X-Forwarded-Proto;\n unset req.http.Cookie;\n }\n\n return (hash);\n}\n\nsub vcl_hash {\n if (req.http.cookie ~ \"X-Magento-Vary=\") {\n hash_data(regsub(req.http.cookie, \"^.*?X-Magento-Vary=([^;]+);*.*$\", \"\\1\"));\n }\n\n # For multi site configurations to not cache each other's content\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n\n # To make sure http users don't see ssl warning\n if (req.http.X-Forwarded-Proto {\n hash_data(req.http.X-Forwarded-Proto);\n }\n #\/* {{ design_exceptions_code }} *\/\n}\n\nsub vcl_backend_response {\n if (beresp.http.content-type ~ \"text\") {\n set beresp.do_esi = true;\n }\n\n if (bereq.url ~ \"\\.js$\" || beresp.http.content-type ~ \"text\") {\n set beresp.do_gzip = true;\n }\n\n # cache only successfully responses and 404s\n if (beresp.status != 200 && beresp.status != 404) {\n set beresp.ttl = 0s;\n set beresp.uncacheable = true;\n return (deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.uncacheable = true;\n set beresp.ttl = 86400s;\n return (deliver);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (bereq.method == \"GET\" || bereq.method == \"HEAD\")) {\n unset beresp.http.set-cookie;\n if (bereq.url !~ \"\\.(ico|css|js|jpg|jpeg|png|gif|tiff|bmp|gz|tgz|bz2|tbz|mp3|ogg|svg|swf|woff|woff2|eot|ttf|otf)(\\?|$)\") {\n set beresp.http.Pragma = \"no-cache\";\n set beresp.http.Expires = \"-1\";\n set beresp.http.Cache-Control = \"no-store, no-cache, must-revalidate, max-age=0\";\n set beresp.grace = 1m;\n }\n }\n\n # If page is not cacheable then bypass varnish for 2 minutes as Hit-For-Pass\n if (beresp.ttl <= 0s ||\n beresp.http.Surrogate-control ~ \"no-store\" ||\n (!beresp.http.Surrogate-Control && beresp.http.Vary == \"*\")) {\n # Mark as Hit-For-Pass for the next 2 minutes\n set beresp.ttl = 120s;\n set beresp.uncacheable = true;\n }\n return (deliver);\n}\n\nsub vcl_deliver {\n if (resp.http.X-Magento-Debug) {\n if (resp.http.x-varnish ~ \" \") {\n set resp.http.X-Magento-Cache-Debug = \"HIT\";\n } else {\n set resp.http.X-Magento-Cache-Debug = \"MISS\";\n }\n } else {\n unset resp.http.Age;\n }\n\n unset resp.http.X-Magento-Debug;\n unset resp.http.X-Magento-Tags;\n unset resp.http.X-Powered-By;\n unset resp.http.Server;\n unset resp.http.X-Varnish;\n unset resp.http.Via;\n unset resp.http.Link;\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"5a89ed9490a518ac9afad76f65ac36bd0c27c83d","subject":"change from req.http.url to req.url","message":"change from req.http.url to req.url\n","repos":"JakeChampion\/polyfill-service,JakeChampion\/polyfill-service","old_file":"fastly\/vcl\/synthetic-responses.vcl","new_file":"fastly\/vcl\/synthetic-responses.vcl","new_contents":"sub vcl_recv {\n\t# Fastly recommend using the 900-999 range of status codes for custom errors within an application's VCL.\n\tif (req.http.Orig-URL ~ \"^\/v3\/normalizeUa\") {\n\t\terror 903 \"Normalise User Agent\";\n\t}\n\tif (req.http.Orig-URL ~ \"^\/v3\/parseUa\") {\n\t\terror 904 \"Parse User Agent\";\n\t}\n\tif (req.http.Orig-URL ~ \"^\/v3\/normalise_querystring_parameters_for_polyfill_bundle\") {\n\t\terror 905 \"Normalise querystring parameters for polyfill bundle\";\n\t}\n\tif (req.http.Orig-URL ~ \"^\/robots.txt\") {\n\t\terror 906;\n\t}\n\tif (req.url ~ \"^\/https:\/\/cdn.polyfill.io\") {\n\t\terror 907;\n\t}\n\tif (req.url ~ \"^\/https:\/\/polyfill.io\") {\n\t\terror 907;\n\t}\n\tif (req.url ~ \"^\/pages\/fixedData\") {\n\t\terror 907;\n\t}\n}\n\nsub vcl_error {\n\t# Normalise User Agent API\n\tif (obj.status == 903) {\n\t\tcall normalise_user_agent_1_5_0;\n\t\tset obj.status = 200;\n\t\tset obj.response = \"OK\";\n\t\tset obj.http.Content-Type = \"text\/plain; charset=utf-8\";\n\t\tset obj.http.Normalized-User-Agent = req.http.Normalized-User-Agent;\n\t\tsynthetic req.http.Normalized-User-Agent;\n\t\treturn (deliver);\n\t}\n\n\t# Parse User Agent API\n\tif (obj.status == 904) {\n\t\tcall useragent_parser;\n\t\tset obj.status = 200;\n\t\tset obj.response = \"OK\";\n\t\tset obj.http.Content-Type = \"text\/plain; charset=utf-8\";\n\t\tset obj.http.useragent_parser_family = req.http.useragent_parser_family;\n\t\tset obj.http.useragent_parser_major = req.http.useragent_parser_major;\n\t\tset obj.http.useragent_parser_minor = req.http.useragent_parser_minor;\n\t\tset obj.http.useragent_parser_patch = req.http.useragent_parser_patch;\n\t\tsynthetic req.http.useragent_parser_family \"\/\" req.http.useragent_parser_major \".\" req.http.useragent_parser_minor \".\" req.http.useragent_parser_patch;\n\t\treturn (deliver);\n\t}\n\n\t# Normalise querystring parameters\n\tif (obj.status == 905) {\n\t\tcall normalise_querystring_parameters_for_polyfill_bundle;\n\t\tset obj.status = 200;\n\t\tset obj.response = \"OK\";\n\t\tset obj.http.Content-Type = \"application\/json; charset=utf-8\";\n\t\tset obj.http.features = subfield(req.url.qs, \"features\", \"&\");\n\t\tset obj.http.excludes = subfield(req.url.qs, \"excludes\", \"&\");\n\t\tset obj.http.rum = subfield(req.url.qs, \"rum\", \"&\");\n\t\tset obj.http.unknown = subfield(req.url.qs, \"unknown\", \"&\");\n\t\tset obj.http.flags = subfield(req.url.qs, \"flags\", \"&\");\n\t\tset obj.http.ua = subfield(req.url.qs, \"ua\", \"&\");\n\t\tset obj.http.callback = subfield(req.url.qs, \"callback\", \"&\");\n\t\tset obj.http.compression = subfield(req.url.qs, \"compression\", \"&\");\n\t\tset obj.http.version = subfield(req.url.qs, \"version\", \"&\");\n\t\tsynthetic \"{\"\n\t\t\t{\"\"\"} \"features\" {\"\"\"} \":\" {\"\"\"} obj.http.features {\"\"\"}\n\t\t\tif (obj.http.excludes, \",\"{\"\"\"} \"excludes\" {\"\"\"} \":\" {\"\"\"} obj.http.excludes {\"\"\"}, \"\")\n\t\t\t\",\"{\"\"\"} \"rum\" {\"\"\"} \":\" {\"\"\"} obj.http.rum {\"\"\"}\n\t\t\t\",\"{\"\"\"} \"unknown\" {\"\"\"} \":\" {\"\"\"} obj.http.unknown {\"\"\"}\n\t\t\tif (obj.http.flags, \",\"{\"\"\"} \"flags\" {\"\"\"} \":\" {\"\"\"} obj.http.flags {\"\"\"}, \"\")\n\t\t\t\",\"{\"\"\"} \"ua\" {\"\"\"} \":\" {\"\"\"} obj.http.ua {\"\"\"}\n\t\t\tif (obj.http.callback, \",\"{\"\"\"} \"callback\" {\"\"\"} \":\" {\"\"\"} obj.http.callback {\"\"\"}, \"\")\n\t\t\tif (obj.http.compression, \",\"{\"\"\"} \"compression\" {\"\"\"} \":\" {\"\"\"} obj.http.compression {\"\"\"}, \"\")\n\t\t\tif (obj.http.version, \",\"{\"\"\"} \"version\" {\"\"\"} \":\" {\"\"\"} obj.http.version {\"\"\"}, \"\")\n\t\t\"}\";\n\t\treturn (deliver);\n\t}\n\n\t# \/robots.txt endpoint \n\tif (obj.status == 906) {\n\t\tset obj.status = 200;\n\t\tset obj.response = \"OK\";\n\t\tset obj.http.Content-Type = \"text\/plain; charset=utf-8\";\n\t\tsynthetic {\"User-agent: *\nDisallow:\"};\n\t\treturn (deliver);\n\t}\n\n\t# return 404\n\tif (obj.status == 907) {\n\t\tset obj.status = 404;\n\t\tset obj.response = \"Not Found\";\n\t\tset obj.http.Content-Type = \"text\/plain; charset=utf-8\";\n\t\tsynthetic {\"Not Found.\"};\n\t\treturn (deliver);\n\t}\n}\n","old_contents":"sub vcl_recv {\n\t# Fastly recommend using the 900-999 range of status codes for custom errors within an application's VCL.\n\tif (req.http.Orig-URL ~ \"^\/v3\/normalizeUa\") {\n\t\terror 903 \"Normalise User Agent\";\n\t}\n\tif (req.http.Orig-URL ~ \"^\/v3\/parseUa\") {\n\t\terror 904 \"Parse User Agent\";\n\t}\n\tif (req.http.Orig-URL ~ \"^\/v3\/normalise_querystring_parameters_for_polyfill_bundle\") {\n\t\terror 905 \"Normalise querystring parameters for polyfill bundle\";\n\t}\n\tif (req.http.Orig-URL ~ \"^\/robots.txt\") {\n\t\terror 906;\n\t}\n\tif (req.http.url ~ \"^\/https:\/\/cdn.polyfill.io\") {\n\t\terror 907;\n\t}\n\tif (req.http.url ~ \"^\/https:\/\/polyfill.io\") {\n\t\terror 907;\n\t}\n\tif (req.http.url ~ \"^\/pages\/fixedData\") {\n\t\terror 907;\n\t}\n}\n\nsub vcl_error {\n\t# Normalise User Agent API\n\tif (obj.status == 903) {\n\t\tcall normalise_user_agent_1_5_0;\n\t\tset obj.status = 200;\n\t\tset obj.response = \"OK\";\n\t\tset obj.http.Content-Type = \"text\/plain; charset=utf-8\";\n\t\tset obj.http.Normalized-User-Agent = req.http.Normalized-User-Agent;\n\t\tsynthetic req.http.Normalized-User-Agent;\n\t\treturn (deliver);\n\t}\n\n\t# Parse User Agent API\n\tif (obj.status == 904) {\n\t\tcall useragent_parser;\n\t\tset obj.status = 200;\n\t\tset obj.response = \"OK\";\n\t\tset obj.http.Content-Type = \"text\/plain; charset=utf-8\";\n\t\tset obj.http.useragent_parser_family = req.http.useragent_parser_family;\n\t\tset obj.http.useragent_parser_major = req.http.useragent_parser_major;\n\t\tset obj.http.useragent_parser_minor = req.http.useragent_parser_minor;\n\t\tset obj.http.useragent_parser_patch = req.http.useragent_parser_patch;\n\t\tsynthetic req.http.useragent_parser_family \"\/\" req.http.useragent_parser_major \".\" req.http.useragent_parser_minor \".\" req.http.useragent_parser_patch;\n\t\treturn (deliver);\n\t}\n\n\t# Normalise querystring parameters\n\tif (obj.status == 905) {\n\t\tcall normalise_querystring_parameters_for_polyfill_bundle;\n\t\tset obj.status = 200;\n\t\tset obj.response = \"OK\";\n\t\tset obj.http.Content-Type = \"application\/json; charset=utf-8\";\n\t\tset obj.http.features = subfield(req.url.qs, \"features\", \"&\");\n\t\tset obj.http.excludes = subfield(req.url.qs, \"excludes\", \"&\");\n\t\tset obj.http.rum = subfield(req.url.qs, \"rum\", \"&\");\n\t\tset obj.http.unknown = subfield(req.url.qs, \"unknown\", \"&\");\n\t\tset obj.http.flags = subfield(req.url.qs, \"flags\", \"&\");\n\t\tset obj.http.ua = subfield(req.url.qs, \"ua\", \"&\");\n\t\tset obj.http.callback = subfield(req.url.qs, \"callback\", \"&\");\n\t\tset obj.http.compression = subfield(req.url.qs, \"compression\", \"&\");\n\t\tset obj.http.version = subfield(req.url.qs, \"version\", \"&\");\n\t\tsynthetic \"{\"\n\t\t\t{\"\"\"} \"features\" {\"\"\"} \":\" {\"\"\"} obj.http.features {\"\"\"}\n\t\t\tif (obj.http.excludes, \",\"{\"\"\"} \"excludes\" {\"\"\"} \":\" {\"\"\"} obj.http.excludes {\"\"\"}, \"\")\n\t\t\t\",\"{\"\"\"} \"rum\" {\"\"\"} \":\" {\"\"\"} obj.http.rum {\"\"\"}\n\t\t\t\",\"{\"\"\"} \"unknown\" {\"\"\"} \":\" {\"\"\"} obj.http.unknown {\"\"\"}\n\t\t\tif (obj.http.flags, \",\"{\"\"\"} \"flags\" {\"\"\"} \":\" {\"\"\"} obj.http.flags {\"\"\"}, \"\")\n\t\t\t\",\"{\"\"\"} \"ua\" {\"\"\"} \":\" {\"\"\"} obj.http.ua {\"\"\"}\n\t\t\tif (obj.http.callback, \",\"{\"\"\"} \"callback\" {\"\"\"} \":\" {\"\"\"} obj.http.callback {\"\"\"}, \"\")\n\t\t\tif (obj.http.compression, \",\"{\"\"\"} \"compression\" {\"\"\"} \":\" {\"\"\"} obj.http.compression {\"\"\"}, \"\")\n\t\t\tif (obj.http.version, \",\"{\"\"\"} \"version\" {\"\"\"} \":\" {\"\"\"} obj.http.version {\"\"\"}, \"\")\n\t\t\"}\";\n\t\treturn (deliver);\n\t}\n\n\t# \/robots.txt endpoint \n\tif (obj.status == 906) {\n\t\tset obj.status = 200;\n\t\tset obj.response = \"OK\";\n\t\tset obj.http.Content-Type = \"text\/plain; charset=utf-8\";\n\t\tsynthetic {\"User-agent: *\nDisallow:\"};\n\t\treturn (deliver);\n\t}\n\n\t# return 404\n\tif (obj.status == 907) {\n\t\tset obj.status = 404;\n\t\tset obj.response = \"Not Found\";\n\t\tset obj.http.Content-Type = \"text\/plain; charset=utf-8\";\n\t\tsynthetic {\"Not Found.\"};\n\t\treturn (deliver);\n\t}\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"801cf1d5e79d5db2f600e7327f5354fc0b2f9618","subject":"Correct condition for HTML caching","message":"Correct condition for HTML caching\n","repos":"fastly\/fastly-magento,fastly\/fastly-magento,fastly\/fastly-magento,fastly\/fastly-magento","old_file":"app\/code\/community\/Fastly\/CDN\/etc\/vcl_snippets\/fetch.vcl","new_file":"app\/code\/community\/Fastly\/CDN\/etc\/vcl_snippets\/fetch.vcl","new_contents":" if (beresp.status >= 500 && beresp.status < 600) {\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n \/* deliver stale if the object is available *\/\n if (stale.exists) {\n return(deliver_stale);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n \/* else go to vcl_error to deliver a synthetic *\/\n error 503;\n\n }\n\n if (req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Content-Type ~ \"text\/(html|xml)\") {\n # enable ESI feature for Magento response by default\n esi;\n if (!beresp.http.Vary ~ \"Fastly-Cdn-Env,Https\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \",Fastly-Cdn-Env,Https\";\n } else {\n set beresp.http.Vary = \"Fastly-Cdn-Env,Https\";\n }\n }\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content\n if (http_status_matches(beresp.status, \"200,404\") && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url.ext ~ \"(?i)(css|js|html|eot|ico|otf|ttf|json)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n if ( beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\") && !req.http.x-pass ) {\n if (beresp.http.Content-Type ~ \"text\/(html|xml)\") {\n # marker for vcl_deliver to reset Age:\n set beresp.http.magentomarker = \"1\";\n\n # Don't cache cookies\n unset beresp.http.set-cookie;\n } else {\n if (beresp.http.Expires || beresp.http.Surrogate-Control ~ \"max-age\" || beresp.http.Cache-Control ~ \"(s-maxage|max-age)\") {\n # keep the ttl here\n } else {\n # apply the default ttl\n set beresp.ttl = 3600s;\n }\n }\n\n # init surrogate keys\n if (beresp.http.Surrogate-Key) {\n set beresp.http.Surrogate-Key = beresp.http.Surrogate-Key \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type\n if (beresp.http.Content-Type ~ \"image\") {\n set beresp.http.Surrogate-Key = \"image\";\n } elsif (beresp.http.Content-Type ~ \"script\") {\n set beresp.http.Surrogate-Key = \"script\";\n } elsif (beresp.http.Content-Type ~ \"css\") {\n set beresp.http.Surrogate-Key = \"css\";\n }\n\n }\n","old_contents":" if (beresp.status >= 500 && beresp.status < 600) {\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n \/* deliver stale if the object is available *\/\n if (stale.exists) {\n return(deliver_stale);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n \/* else go to vcl_error to deliver a synthetic *\/\n error 503;\n\n }\n\n if (req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Content-Type ~ \"text\/(html|xml)\") {\n # enable ESI feature for Magento response by default\n esi;\n if (!beresp.http.Vary ~ \"Fastly-Cdn-Env,Https\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \",Fastly-Cdn-Env,Https\";\n } else {\n set beresp.http.Vary = \"Fastly-Cdn-Env,Https\";\n }\n }\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content\n if (http_status_matches(beresp.status, \"200,404\") && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url.ext ~ \"(?i)(css|js|html|eot|ico|otf|ttf|json)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n if (http_status_matches(beresp.status, \"200,301,404\") && !req.http.X-Pass) {\n if (beresp.http.Content-Type ~ \"text\/(html|xml)\") {\n # marker for vcl_deliver to reset Age:\n set beresp.http.magentomarker = \"1\";\n\n # Don't cache cookies\n unset beresp.http.set-cookie;\n } else {\n if (beresp.http.Expires || beresp.http.Surrogate-Control ~ \"max-age\" || beresp.http.Cache-Control ~ \"(s-maxage|max-age)\") {\n # keep the ttl here\n } else {\n # apply the default ttl\n set beresp.ttl = 3600s;\n }\n }\n\n # init surrogate keys\n if (beresp.http.Surrogate-Key) {\n set beresp.http.Surrogate-Key = beresp.http.Surrogate-Key \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type\n if (beresp.http.Content-Type ~ \"image\") {\n set beresp.http.Surrogate-Key = \"image\";\n } elsif (beresp.http.Content-Type ~ \"script\") {\n set beresp.http.Surrogate-Key = \"script\";\n } elsif (beresp.http.Content-Type ~ \"css\") {\n set beresp.http.Surrogate-Key = \"css\";\n }\n\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"e6da0e9a8878f1116147cf8a055d40aa8e2c33b3","subject":"In cases where image is not found Magento may end up processing the request which will set cookies which may overwrite any existing cookies","message":"In cases where image is not found Magento may end up processing the request which will set cookies which may overwrite any existing cookies\n","repos":"fastly\/fastly-magento,fastly\/fastly-magento,fastly\/fastly-magento,fastly\/fastly-magento","old_file":"app\/code\/community\/Fastly\/CDN\/etc\/vcl_snippets\/fetch.vcl","new_file":"app\/code\/community\/Fastly\/CDN\/etc\/vcl_snippets\/fetch.vcl","new_contents":" if (beresp.status >= 500 && beresp.status < 600) {\n \/* deliver stale if the object is available *\/\n if (stale.exists) {\n return(deliver_stale);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n \/* else go to vcl_error to deliver a synthetic *\/\n error beresp.status beresp.response;\n\n }\n\n if (beresp.http.X-Esi || beresp.http.Content-Type ~ \"^text\/(html|xml)\") {\n # enable ESI feature for Magento response by default\n esi;\n if (!beresp.http.Vary ~ \"Fastly-Cdn-Env,Https\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \",Fastly-Cdn-Env,Https\";\n } else {\n set beresp.http.Vary = \"Fastly-Cdn-Env,Https\";\n }\n }\n # marker for vcl_deliver to reset Age:\n set beresp.http.magentomarker = \"1\";\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content\n if (http_status_matches(beresp.status, \"200,404\") && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url.ext ~ \"(?i)(css|js|html|eot|ico|otf|ttf|json)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # Just in case the Request Setting for x-pass is missing\n if (req.http.x-pass) {\n return (pass);\n }\n\n # Force any responses with private, no-cache or no-store in Cache-Control to pass\n if (beresp.http.Cache-Control ~ \"private|no-cache|no-store\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # Varnish sets default TTL if none of these are present. Assume if they are not present that we don't want to cache\n if (!beresp.http.Expires && !beresp.http.Surrogate-Control ~ \"max-age\" && !beresp.http.Cache-Control ~ \"(s-maxage|max-age)\") {\n set beresp.ttl = 0s;\n }\n\n # If origin provides TTL for an object we cache it\n if ( beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\") && !req.http.x-pass ) {\n # Don't cache cookies - this is here because Magento sets cookies even for anonymous users\n # which busts cache\n unset beresp.http.set-cookie;\n\n # If surrogate keys have been set do not set them again\n if ( !beresp.http.surrogate-keys-set ) {\n if (beresp.http.magentomarker) {\n # init surrogate keys\n if (beresp.http.Surrogate-Key) {\n set beresp.http.Surrogate-Key = beresp.http.Surrogate-Key \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n } else if (beresp.http.Content-Type ~ \"(image|script|css)\") {\n # set surrogate keys by content type if they are image\/script or CSS\n if (beresp.http.Surrogate-Key) {\n set beresp.http.Surrogate-Key = beresp.http.Surrogate-Key \" \" re.group.1;\n } else {\n set beresp.http.Surrogate-Key = re.group.1;\n }\n }\n\n set beresp.http.surrogate-keys-set = \"1\";\n }\n\n }\n\n if (beresp.status == 404 && req.url.path ~ \"^\/(media|js|skin)\/.*\\.(png|jpg|jpeg|gif|css|js|swf|ico|webp|svg)$\") {\n unset beresp.http.set-cookie;\n }","old_contents":" if (beresp.status >= 500 && beresp.status < 600) {\n \/* deliver stale if the object is available *\/\n if (stale.exists) {\n return(deliver_stale);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n \/* else go to vcl_error to deliver a synthetic *\/\n error beresp.status beresp.response;\n\n }\n\n if (beresp.http.X-Esi || beresp.http.Content-Type ~ \"^text\/(html|xml)\") {\n # enable ESI feature for Magento response by default\n esi;\n if (!beresp.http.Vary ~ \"Fastly-Cdn-Env,Https\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \",Fastly-Cdn-Env,Https\";\n } else {\n set beresp.http.Vary = \"Fastly-Cdn-Env,Https\";\n }\n }\n # marker for vcl_deliver to reset Age:\n set beresp.http.magentomarker = \"1\";\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content\n if (http_status_matches(beresp.status, \"200,404\") && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url.ext ~ \"(?i)(css|js|html|eot|ico|otf|ttf|json)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # Just in case the Request Setting for x-pass is missing\n if (req.http.x-pass) {\n return (pass);\n }\n\n # Force any responses with private, no-cache or no-store in Cache-Control to pass\n if (beresp.http.Cache-Control ~ \"private|no-cache|no-store\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # Varnish sets default TTL if none of these are present. Assume if they are not present that we don't want to cache\n if (!beresp.http.Expires && !beresp.http.Surrogate-Control ~ \"max-age\" && !beresp.http.Cache-Control ~ \"(s-maxage|max-age)\") {\n set beresp.ttl = 0s;\n }\n\n # If origin provides TTL for an object we cache it\n if ( beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\") && !req.http.x-pass ) {\n # Don't cache cookies - this is here because Magento sets cookies even for anonymous users\n # which busts cache\n unset beresp.http.set-cookie;\n\n # If surrogate keys have been set do not set them again\n if ( !beresp.http.surrogate-keys-set ) {\n if (beresp.http.magentomarker) {\n # init surrogate keys\n if (beresp.http.Surrogate-Key) {\n set beresp.http.Surrogate-Key = beresp.http.Surrogate-Key \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n } else if (beresp.http.Content-Type ~ \"(image|script|css)\") {\n # set surrogate keys by content type if they are image\/script or CSS\n if (beresp.http.Surrogate-Key) {\n set beresp.http.Surrogate-Key = beresp.http.Surrogate-Key \" \" re.group.1;\n } else {\n set beresp.http.Surrogate-Key = re.group.1;\n }\n }\n\n set beresp.http.surrogate-keys-set = \"1\";\n }\n\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"4f211a8cb1687c11cae65f7014d60621fd4b0a3a","subject":"Triggering build?","message":"Triggering build?\n","repos":"nippe\/alpine-varnish-docker,nippe\/alpine-varnish-docker","old_file":"default.vcl","new_file":"default.vcl","new_contents":"vcl 4.0;\n# This is a basic VCL configuration file for varnish. See the vcl(7)\n# man page for details on VCL syntax and semantics.\n#\n# Default backend definition. Set this to point to your content\n# server.\n#\nbackend default {\n .host = \"${VARNISH_BACKEND_IP}\";\n .port = \"${VARNISH_BACKEND_PORT}\";\n}\n#\n#\n# Below is a commented-out copy of the default VCL logic. If you\n# redefine any of these subroutines, the built-in logic will be\n# appended to your code.\n# sub vcl_recv {\n# if (req.restarts == 0) {\n# \tif (req.http.x-forwarded-for) {\n# \t set req.http.X-Forwarded-For =\n# \t\treq.http.X-Forwarded-For + \", \" + client.ip;\n# \t} else {\n# \t set req.http.X-Forwarded-For = client.ip;\n# \t}\n# }\n# if (req.request != \"GET\" &&\n# req.request != \"HEAD\" &&\n# req.request != \"PUT\" &&\n# req.request != \"POST\" &&\n# req.request != \"TRACE\" &&\n# req.request != \"OPTIONS\" &&\n# req.request != \"DELETE\") {\n# \/* Non-RFC2616 or CONNECT which is weird. *\/\n# return (pipe);\n# }\n# if (req.request != \"GET\" && req.request != \"HEAD\") {\n# \/* We only deal with GET and HEAD by default *\/\n# return (pass);\n# }\n# if (req.http.Authorization || req.http.Cookie) {\n# \/* Not cacheable by default *\/\n# return (pass);\n# }\n# return (lookup);\n# }\n#\n# sub vcl_pipe {\n# # Note that only the first request to the backend will have\n# # X-Forwarded-For set. If you use X-Forwarded-For and want to\n# # have it set for all requests, make sure to have:\n# # set bereq.http.connection = \"close\";\n# # here. It is not set by default as it might break some broken web\n# # applications, like IIS with NTLM authentication.\n# return (pipe);\n# }\n#\n# sub vcl_pass {\n# return (pass);\n# }\n#\n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (hash);\n# }\n#\n# sub vcl_hit {\n# return (deliver);\n# }\n#\n# sub vcl_miss {\n# return (fetch);\n# }\n#\n# sub vcl_fetch {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Vary == \"*\") {\n# \t\t\/*\n# \t\t * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# \t\t *\/\n# \t\tset beresp.ttl = 120 s;\n# \t\treturn (hit_for_pass);\n# }\n# return (deliver);\n# }\n#\n# sub vcl_deliver {\n# return (deliver);\n# }\n#\n# sub vcl_error {\n# set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n# set obj.http.Retry-After = \"5\";\n# synthetic {\"\n# <?xml version=\"1.0\" encoding=\"utf-8\"?>\n# <!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n# \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n# <html>\n# <head>\n# <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n# <\/head>\n# <body>\n# <h1>Error \"} + obj.status + \" \" + obj.response + {\"<\/h1>\n# <p>\"} + obj.response + {\"<\/p>\n# <h3>Guru Meditation:<\/h3>\n# <p>XID: \"} + req.xid + {\"<\/p>\n# <hr>\n# <p>Varnish cache server<\/p>\n# <\/body>\n# <\/html>\n# \"};\n# return (deliver);\n# }\n#\n# sub vcl_init {\n# \treturn (ok);\n# }\n#\n# sub vcl_fini {\n# \treturn (ok);\n# }\n","old_contents":"vcl 4.0;\n# This is a basic VCL configuration file for varnish. See the vcl(7)\n# man page for details on VCL syntax and semantics.\n#\n# Default backend definition. Set this to point to your content\n# server.\n#\nbackend default {\n .host = \"${VARNISH_BACKEND_IP}\";\n .port = \"${VARNISH_BACKEND_PORT}\";\n}\n#\n# Below is a commented-out copy of the default VCL logic. If you\n# redefine any of these subroutines, the built-in logic will be\n# appended to your code.\n# sub vcl_recv {\n# if (req.restarts == 0) {\n# \tif (req.http.x-forwarded-for) {\n# \t set req.http.X-Forwarded-For =\n# \t\treq.http.X-Forwarded-For + \", \" + client.ip;\n# \t} else {\n# \t set req.http.X-Forwarded-For = client.ip;\n# \t}\n# }\n# if (req.request != \"GET\" &&\n# req.request != \"HEAD\" &&\n# req.request != \"PUT\" &&\n# req.request != \"POST\" &&\n# req.request != \"TRACE\" &&\n# req.request != \"OPTIONS\" &&\n# req.request != \"DELETE\") {\n# \/* Non-RFC2616 or CONNECT which is weird. *\/\n# return (pipe);\n# }\n# if (req.request != \"GET\" && req.request != \"HEAD\") {\n# \/* We only deal with GET and HEAD by default *\/\n# return (pass);\n# }\n# if (req.http.Authorization || req.http.Cookie) {\n# \/* Not cacheable by default *\/\n# return (pass);\n# }\n# return (lookup);\n# }\n#\n# sub vcl_pipe {\n# # Note that only the first request to the backend will have\n# # X-Forwarded-For set. If you use X-Forwarded-For and want to\n# # have it set for all requests, make sure to have:\n# # set bereq.http.connection = \"close\";\n# # here. It is not set by default as it might break some broken web\n# # applications, like IIS with NTLM authentication.\n# return (pipe);\n# }\n#\n# sub vcl_pass {\n# return (pass);\n# }\n#\n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (hash);\n# }\n#\n# sub vcl_hit {\n# return (deliver);\n# }\n#\n# sub vcl_miss {\n# return (fetch);\n# }\n#\n# sub vcl_fetch {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Vary == \"*\") {\n# \t\t\/*\n# \t\t * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# \t\t *\/\n# \t\tset beresp.ttl = 120 s;\n# \t\treturn (hit_for_pass);\n# }\n# return (deliver);\n# }\n#\n# sub vcl_deliver {\n# return (deliver);\n# }\n#\n# sub vcl_error {\n# set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n# set obj.http.Retry-After = \"5\";\n# synthetic {\"\n# <?xml version=\"1.0\" encoding=\"utf-8\"?>\n# <!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n# \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n# <html>\n# <head>\n# <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n# <\/head>\n# <body>\n# <h1>Error \"} + obj.status + \" \" + obj.response + {\"<\/h1>\n# <p>\"} + obj.response + {\"<\/p>\n# <h3>Guru Meditation:<\/h3>\n# <p>XID: \"} + req.xid + {\"<\/p>\n# <hr>\n# <p>Varnish cache server<\/p>\n# <\/body>\n# <\/html>\n# \"};\n# return (deliver);\n# }\n#\n# sub vcl_init {\n# \treturn (ok);\n# }\n#\n# sub vcl_fini {\n# \treturn (ok);\n# }\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"c99d56bf96c627cfec5205b258a102b6e549fa97","subject":"Reset cache control headers only on content that contains X-Magento-Tags. Otherwise we run the risk of unsetting Cache-Control headers of objects we didn't intend.","message":"Reset cache control headers only on content that contains X-Magento-Tags.\nOtherwise we run the risk of unsetting Cache-Control headers of objects\nwe didn't intend.\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets\/deliver.vcl","new_file":"etc\/vcl_snippets\/deliver.vcl","new_contents":" # Send no cache headers to end users for non-static content created by Magento\n if (resp.http.X-Magento-Tags && !req.http.Fastly-FF ) {\n set resp.http.Cache-Control = \"no-store, no-cache, must-revalidate, max-age=0\";\n }\n\n # Execute only on the edge nodes\n if ( !req.http.Fastly-FF ) {\n # Remove X-Magento-Vary and HTTPs Vary served to the user\n set resp.http.Vary = regsub(resp.http.Vary, \"X-Magento-Vary,Https\", \"Cookie\");\n remove resp.http.X-Magento-Tags;\n }\n\n # Add an easy way to see whether custom Fastly VCL has been uploaded\n if ( req.http.Fastly-Debug ) {\n set resp.http.Fastly-Magento-VCL-Uploaded = \"1.2.74\";\n } else {\n remove resp.http.Fastly-Module-Enabled;\n remove resp.http.fastly-page-cacheable;\n }\n\n # debug info\n if (!resp.http.X-Magento-Debug) {\n # remove Varnish\/proxy header\n remove resp.http.X-Magento-Debug;\n remove resp.http.X-Magento-Cache-Control;\n remove resp.http.X-Powered-By;\n remove resp.http.Server;\n remove resp.http.X-Varnish;\n remove resp.http.Via;\n remove resp.http.X-Purge-URL;\n remove resp.http.X-Purge-Host;\n }\n","old_contents":" # Send no cache headers to end users for non-static content. Also make sure\n # we only set this on the edge nodes and not on shields\n if (req.url !~ \"^\/(pub\/)?(media|static)\/.*\" && !req.http.Fastly-FF ) {\n set resp.http.Cache-Control = \"no-store, no-cache, must-revalidate, max-age=0\";\n }\n\n # Execute only on the edge nodes\n if ( !req.http.Fastly-FF ) {\n # Remove X-Magento-Vary and HTTPs Vary served to the user\n set resp.http.Vary = regsub(resp.http.Vary, \"X-Magento-Vary,Https\", \"Cookie\");\n remove resp.http.X-Magento-Tags;\n }\n\n # Add an easy way to see whether custom Fastly VCL has been uploaded\n if ( req.http.Fastly-Debug ) {\n set resp.http.Fastly-Magento-VCL-Uploaded = \"1.2.74\";\n } else {\n remove resp.http.Fastly-Module-Enabled;\n remove resp.http.fastly-page-cacheable;\n }\n\n # debug info\n if (!resp.http.X-Magento-Debug) {\n # remove Varnish\/proxy header\n remove resp.http.X-Magento-Debug;\n remove resp.http.X-Magento-Cache-Control;\n remove resp.http.X-Powered-By;\n remove resp.http.Server;\n remove resp.http.X-Varnish;\n remove resp.http.Via;\n remove resp.http.X-Purge-URL;\n remove resp.http.X-Purge-Host;\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"95661589e32e24dc24581b22cf4efe419afa40fb","subject":"cache ttf fonts in varnish","message":"cache ttf fonts in varnish\n","repos":"ecreall\/nova-ideo,ecreall\/nova-ideo,ecreall\/nova-ideo,ecreall\/nova-ideo,ecreall\/nova-ideo","old_file":"etc\/varnish.vcl","new_file":"etc\/varnish.vcl","new_contents":"# This a configuration file for varnish.\n# It was generated by plone.recipe.varnish.\n# See the vcl(7) man page for details on VCL syntax and semantics.\n#\nvcl 4.0;\n\nimport std;\n\n# configure all backends\nbackend backend_000 {\n .host = \"127.0.0.1\";\n .port = \"5001\";\n .connect_timeout = 0.4s;\n .first_byte_timeout = 300s;\n .between_bytes_timeout = 60s;\n}\n\n\nsub vcl_init {\n\n}\n\nacl purge {\n \"localhost\";\n \"127.0.0.1\";\n}\n\nsub vcl_recv {\n set req.backend_hint = backend_000;\n set req.http.grace = \"none\";\n\n if (req.method == \"PURGE\") {\n # Not from an allowed IP? Then die with an error.\n if (!client.ip ~ purge) {\n return (synth(405, \"This IP is not allowed to send PURGE requests.\"));\n }\n return(purge);\n }\n\n if (req.method == \"BAN\") {\n # Same ACL check as above:\n if (!client.ip ~ purge) {\n return(synth(403, \"Not allowed.\"));\n }\n #ban(\"req.url ~ \" + req.url);\n ban(\"req.http.host == \" + req.http.host +\n \" && req.url == \" + req.url);\n # Throw a synthetic page so the\n # request won't go to the backend.\n return(synth(200, \"Ban added\"));\n }\n\n if (req.method == \"USERINFO\" ||\n req.method == \"CONNECT\" ||\n req.method == \"QUIT\") {\n return (synth(501, \"Not implemented\"));\n }\n\n # Only deal with \"normal\" types\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return(pipe);\n }\n\n # Only cache GET or HEAD requests. This makes sure the POST requests are always passed.\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return(pass);\n }\n\n if (req.http.Expect) {\n return(pipe);\n }\n\n if (req.http.If-None-Match && !req.http.If-Modified-Since) {\n return(pass);\n }\n\n \/* Do not cache other authorized content by default *\/\n if (req.http.Authenticate || req.http.Authorization) {\n return(pass);\n }\n\n if (req.url ~ \"@@registration|@@login|@@resetpassword\") {\n return(pass);\n }\n\n if (req.url ~ \"^[^?]*\\.(svg|css|js|png|gif|jpeg|jpg|ttf|woff|woff2)(\\?.*)?$\") {\n unset req.http.Cookie;\n }\n\n if (req.http.Cookie && req.http.Cookie ~ \"auth_tkt\") {\n return(pass);\n }\n\n unset req.http.Accept-Encoding;\n\n return(hash);\n}\n\nsub vcl_pipe {\n # By default Connection: close is set on all piped requests, to stop\n # connection reuse from sending future requests directly to the\n # (potentially) wrong backend. If you do want this to happen, you can undo\n # it here.\n # unset bereq.http.connection;\n\n return(pipe);\n}\n\nsub vcl_pass {\n return (fetch);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n if (req.http.X-Forwarded-Proto) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n return (lookup);\n}\n\nsub vcl_purge {\n return (synth(200, \"Purged\"));\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n \/\/ A pure unadultered hit, deliver it\n # normal hit\n return (deliver);\n }\n\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n if (obj.ttl + obj.grace > 0s) {\n set req.http.grace = \"normal(limited)\";\n return (deliver);\n }\n\n if (req.method == \"PURGE\") {\n set req.method = \"GET\";\n set req.http.X-purger = \"Purged\";\n return(synth(200, \"Purged. in hit \" + req.url));\n }\n\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\nsub vcl_miss {\n if (req.method == \"PURGE\") {\n set req.method = \"GET\";\n set req.http.X-purger = \"Purged-possibly\";\n return(synth(200, \"Purged. in miss \" + req.url));\n }\n\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\nsub vcl_backend_fetch{\n return (fetch);\n}\n\nsub vcl_backend_response {\n # The object is not cacheable\n if (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO - Set Cookie\";\n set beresp.ttl = 0s;\n set beresp.uncacheable = true;\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO - Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = 120s;\n } elsif (beresp.http.Surrogate-control ~ \"no-store\") {\n set beresp.http.X-Cacheable = \"NO - Surrogate-control=no-store\";\n set beresp.uncacheable = true;\n set beresp.ttl = 120s;\n } elsif (!beresp.http.Surrogate-Control && beresp.http.Cache-Control ~ \"no-cache|no-store\") {\n set beresp.http.X-Cacheable = \"NO - Cache-Control=no-cache|no-store\";\n set beresp.uncacheable = true;\n set beresp.ttl = 120s;\n } elsif (beresp.http.Vary == \"*\") {\n set beresp.http.X-Cacheable = \"NO - Vary=*\";\n set beresp.uncacheable = true;\n set beresp.ttl = 120s;\n\n\n # ttl handling\n } elsif (beresp.ttl < 0s) {\n set beresp.http.X-Cacheable = \"NO - TTL < 0\";\n set beresp.uncacheable = true;\n } elsif (beresp.ttl == 0s) {\n if (bereq.http.Cookie && bereq.http.Cookie ~ \"auth_tkt\") {\n set beresp.http.X-Cacheable = \"NO - TTL = 0\";\n set beresp.uncacheable = true;\n } else {\n set beresp.http.X-Cacheable = \"YES, 3600s\";\n set beresp.ttl = 3600s;\n set beresp.grace = 36000s;\n }\n\n # Varnish determined the object was cacheable\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n\n# https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleLongerCaching\n if (beresp.ttl == 31536000s) { # for deform.js, jquery.form-3.09.js from deformstatic\n \/* Remove Expires from backend, it's too long *\/\n unset beresp.http.expires;\n\n \/* Set the clients TTL on this object *\/\n set beresp.http.cache-control = \"max-age=86400\";\n\n \/* Set how long Varnish will keep it *\/\n set beresp.ttl = 86400s;\n }\n\n # Do not cache 5xx errors\n if (beresp.status >= 500 && beresp.status < 600) {\n unset beresp.http.Cache-Control;\n set beresp.http.X-Cache = \"NOCACHE\";\n set beresp.http.Cache-Control = \"no-cache, max-age=0, must-revalidate\";\n set beresp.ttl = 0s;\n set beresp.http.Pragma = \"no-cache\";\n set beresp.uncacheable = true;\n return(deliver);\n }\n\n return (deliver);\n}\n\nsub vcl_deliver {\n set resp.http.grace = req.http.grace;\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n \/* Rewrite s-maxage to exclude from intermediary proxies\n (to cache *everywhere*, just use 'max-age' token in the response to avoid\n this override) *\/\n if (resp.http.Cache-Control ~ \"s-maxage\") {\n set resp.http.Cache-Control = regsub(resp.http.Cache-Control, \"s-maxage=[0-9]+\", \"s-maxage=0\");\n }\n \/* Remove proxy-revalidate for intermediary proxies *\/\n if (resp.http.Cache-Control ~ \", proxy-revalidate\") {\n set resp.http.Cache-Control = regsub(resp.http.Cache-Control, \", proxy-revalidate\", \"\");\n }\n\n unset resp.http.Server;\n\n}\n\n\/*\n We can come here \"invisibly\" with the following errors: 413, 417 & 503\n*\/\nsub vcl_synth {\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n set resp.http.Retry-After = \"5\";\n\n synthetic( {\"\n <?xml version=\"1.0\" encoding=\"utf-8\"?>\n <!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n <html>\n <head>\n <title>Varnish cache server: \"} + resp.status + \" \" + resp.reason + {\" <\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n <\/html>\n \"} );\n\n return (deliver);\n}\n","old_contents":"# This a configuration file for varnish.\n# It was generated by plone.recipe.varnish.\n# See the vcl(7) man page for details on VCL syntax and semantics.\n#\nvcl 4.0;\n\nimport std;\n\n# configure all backends\nbackend backend_000 {\n .host = \"127.0.0.1\";\n .port = \"5001\";\n .connect_timeout = 0.4s;\n .first_byte_timeout = 300s;\n .between_bytes_timeout = 60s;\n}\n\n\nsub vcl_init {\n\n}\n\nacl purge {\n \"localhost\";\n \"127.0.0.1\";\n}\n\nsub vcl_recv {\n set req.backend_hint = backend_000;\n set req.http.grace = \"none\";\n\n if (req.method == \"PURGE\") {\n # Not from an allowed IP? Then die with an error.\n if (!client.ip ~ purge) {\n return (synth(405, \"This IP is not allowed to send PURGE requests.\"));\n }\n return(purge);\n }\n\n if (req.method == \"BAN\") {\n # Same ACL check as above:\n if (!client.ip ~ purge) {\n return(synth(403, \"Not allowed.\"));\n }\n #ban(\"req.url ~ \" + req.url);\n ban(\"req.http.host == \" + req.http.host +\n \" && req.url == \" + req.url);\n # Throw a synthetic page so the\n # request won't go to the backend.\n return(synth(200, \"Ban added\"));\n }\n\n if (req.method == \"USERINFO\" ||\n req.method == \"CONNECT\" ||\n req.method == \"QUIT\") {\n return (synth(501, \"Not implemented\"));\n }\n\n # Only deal with \"normal\" types\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return(pipe);\n }\n\n # Only cache GET or HEAD requests. This makes sure the POST requests are always passed.\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return(pass);\n }\n\n if (req.http.Expect) {\n return(pipe);\n }\n\n if (req.http.If-None-Match && !req.http.If-Modified-Since) {\n return(pass);\n }\n\n \/* Do not cache other authorized content by default *\/\n if (req.http.Authenticate || req.http.Authorization) {\n return(pass);\n }\n\n if (req.url ~ \"@@registration|@@login|@@resetpassword\") {\n return(pass);\n }\n\n if (req.url ~ \"^[^?]*\\.(svg|css|js|png|gif|jpeg|jpg|woff|woff2)(\\?.*)?$\") {\n unset req.http.Cookie;\n }\n\n if (req.http.Cookie && req.http.Cookie ~ \"auth_tkt\") {\n return(pass);\n }\n\n unset req.http.Accept-Encoding;\n\n return(hash);\n}\n\nsub vcl_pipe {\n # By default Connection: close is set on all piped requests, to stop\n # connection reuse from sending future requests directly to the\n # (potentially) wrong backend. If you do want this to happen, you can undo\n # it here.\n # unset bereq.http.connection;\n\n return(pipe);\n}\n\nsub vcl_pass {\n return (fetch);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n if (req.http.X-Forwarded-Proto) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n return (lookup);\n}\n\nsub vcl_purge {\n return (synth(200, \"Purged\"));\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n \/\/ A pure unadultered hit, deliver it\n # normal hit\n return (deliver);\n }\n\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n if (obj.ttl + obj.grace > 0s) {\n set req.http.grace = \"normal(limited)\";\n return (deliver);\n }\n\n if (req.method == \"PURGE\") {\n set req.method = \"GET\";\n set req.http.X-purger = \"Purged\";\n return(synth(200, \"Purged. in hit \" + req.url));\n }\n\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\nsub vcl_miss {\n if (req.method == \"PURGE\") {\n set req.method = \"GET\";\n set req.http.X-purger = \"Purged-possibly\";\n return(synth(200, \"Purged. in miss \" + req.url));\n }\n\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\nsub vcl_backend_fetch{\n return (fetch);\n}\n\nsub vcl_backend_response {\n # The object is not cacheable\n if (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO - Set Cookie\";\n set beresp.ttl = 0s;\n set beresp.uncacheable = true;\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO - Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = 120s;\n } elsif (beresp.http.Surrogate-control ~ \"no-store\") {\n set beresp.http.X-Cacheable = \"NO - Surrogate-control=no-store\";\n set beresp.uncacheable = true;\n set beresp.ttl = 120s;\n } elsif (!beresp.http.Surrogate-Control && beresp.http.Cache-Control ~ \"no-cache|no-store\") {\n set beresp.http.X-Cacheable = \"NO - Cache-Control=no-cache|no-store\";\n set beresp.uncacheable = true;\n set beresp.ttl = 120s;\n } elsif (beresp.http.Vary == \"*\") {\n set beresp.http.X-Cacheable = \"NO - Vary=*\";\n set beresp.uncacheable = true;\n set beresp.ttl = 120s;\n\n\n # ttl handling\n } elsif (beresp.ttl < 0s) {\n set beresp.http.X-Cacheable = \"NO - TTL < 0\";\n set beresp.uncacheable = true;\n } elsif (beresp.ttl == 0s) {\n if (bereq.http.Cookie && bereq.http.Cookie ~ \"auth_tkt\") {\n set beresp.http.X-Cacheable = \"NO - TTL = 0\";\n set beresp.uncacheable = true;\n } else {\n set beresp.http.X-Cacheable = \"YES, 3600s\";\n set beresp.ttl = 3600s;\n set beresp.grace = 36000s;\n }\n\n # Varnish determined the object was cacheable\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n\n# https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleLongerCaching\n if (beresp.ttl == 31536000s) { # for deform.js, jquery.form-3.09.js from deformstatic\n \/* Remove Expires from backend, it's too long *\/\n unset beresp.http.expires;\n\n \/* Set the clients TTL on this object *\/\n set beresp.http.cache-control = \"max-age=86400\";\n\n \/* Set how long Varnish will keep it *\/\n set beresp.ttl = 86400s;\n }\n\n # Do not cache 5xx errors\n if (beresp.status >= 500 && beresp.status < 600) {\n unset beresp.http.Cache-Control;\n set beresp.http.X-Cache = \"NOCACHE\";\n set beresp.http.Cache-Control = \"no-cache, max-age=0, must-revalidate\";\n set beresp.ttl = 0s;\n set beresp.http.Pragma = \"no-cache\";\n set beresp.uncacheable = true;\n return(deliver);\n }\n\n return (deliver);\n}\n\nsub vcl_deliver {\n set resp.http.grace = req.http.grace;\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n \/* Rewrite s-maxage to exclude from intermediary proxies\n (to cache *everywhere*, just use 'max-age' token in the response to avoid\n this override) *\/\n if (resp.http.Cache-Control ~ \"s-maxage\") {\n set resp.http.Cache-Control = regsub(resp.http.Cache-Control, \"s-maxage=[0-9]+\", \"s-maxage=0\");\n }\n \/* Remove proxy-revalidate for intermediary proxies *\/\n if (resp.http.Cache-Control ~ \", proxy-revalidate\") {\n set resp.http.Cache-Control = regsub(resp.http.Cache-Control, \", proxy-revalidate\", \"\");\n }\n\n unset resp.http.Server;\n\n}\n\n\/*\n We can come here \"invisibly\" with the following errors: 413, 417 & 503\n*\/\nsub vcl_synth {\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n set resp.http.Retry-After = \"5\";\n\n synthetic( {\"\n <?xml version=\"1.0\" encoding=\"utf-8\"?>\n <!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n <html>\n <head>\n <title>Varnish cache server: \"} + resp.status + \" \" + resp.reason + {\" <\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n <\/html>\n \"} );\n\n return (deliver);\n}\n","returncode":0,"stderr":"","license":"agpl-3.0","lang":"VCL"} {"commit":"db7f5d8c458cf31396b8feb1dbf2adeac7b3d28c","subject":"Add bot detection for Yahoo! Slurp","message":"Add bot detection for Yahoo! Slurp\n\nThe Yahoo spider user agent is `Mozilla\/5.0 (compatible; Yahoo! Slurp; http:\/\/help.yahoo.com\/help\/us\/ysearch\/slurp)` and is not currently being detected as a bot by `devicedetect`.\r\n\r\nSee https:\/\/help.yahoo.com\/kb\/SLN22600.html for details.","repos":"varnish\/varnish-devicedetect,varnish\/varnish-devicedetect","old_file":"devicedetect.vcl","new_file":"devicedetect.vcl","new_contents":"# Copyright (c) 2012-2014 Varnish Software AS\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions\n# are met:\n# 1. Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n# 2. Redistributions in binary form must reproduce the above copyright\n# notice, this list of conditions and the following disclaimer in the\n# documentation and\/or other materials provided with the distribution.\n#\n# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n# ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n# SUCH DAMAGE.\n#\n# detectdevice.vcl - regex based device detection for Varnish\n# https:\/\/github.com\/varnishcache\/varnish-devicedetect\/\n#\n# Author: Lasse Karstensen <lkarsten@varnish-software.com>\n\nsub devicedetect {\n\tunset req.http.X-UA-Device;\n\tset req.http.X-UA-Device = \"pc\";\n\n\t# Handle that a cookie may override the detection alltogether.\n\tif (req.http.Cookie ~ \"(?i)X-UA-Device-force\") {\n\t\t\/* ;?? means zero or one ;, non-greedy to match the first. *\/\n\t\tset req.http.X-UA-Device = regsub(req.http.Cookie, \"(?i).*X-UA-Device-force=([^;]+);??.*\", \"\\1\");\n\t\t\/* Clean up our mess in the cookie header *\/\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|; ) *X-UA-Device-force=[^;]+;? *\", \"\\1\");\n\t\t\/* If the cookie header is now empty, or just whitespace, unset it. *\/\n\t\tif (req.http.Cookie ~ \"^ *$\") { unset req.http.Cookie; }\n\t} else {\n if (req.http.User-Agent ~ \"\\(compatible; Googlebot-Mobile\/2.1; \\+http:\/\/www.google.com\/bot.html\\)\" ||\n (req.http.User-Agent ~ \"(Android|iPhone)\" && req.http.User-Agent ~ \"\\(compatible.?; Googlebot\/2.1.?; \\+http:\/\/www.google.com\/bot.html\") ||\n\t\t\t(req.http.User-Agent ~ \"(iPhone|Windows Phone)\" && req.http.User-Agent ~ \"\\(compatible; bingbot\/2.0; \\+http:\/\/www.bing.com\/bingbot.htm\")) {\n set req.http.X-UA-Device = \"mobile-bot\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)(ads|google|bing|msn|yandex|baidu|ro|career|seznam|)bot\" ||\n\t\t req.http.User-Agent ~ \"(?i)(baidu|jike|symantec)spider\" ||\n\t\t req.http.User-Agent ~ \"(?i)scanner\" ||\n\t\t req.http.User-Agent ~ \"(?i)slurp\" ||\n\t\t req.http.User-Agent ~ \"(?i)(web)crawler\") {\n\t\t\tset req.http.X-UA-Device = \"bot\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ipad\") { set req.http.X-UA-Device = \"tablet-ipad\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ip(hone|od)\") { set req.http.X-UA-Device = \"mobile-iphone\"; }\n\t\t\/* how do we differ between an android phone and an android tablet?\n\t\t http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent *\/\n\t\telsif (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") { set req.http.X-UA-Device = \"mobile-android\"; }\n\t\t\/\/ android 3\/honeycomb was just about tablet-only, and any phones will probably handle a bigger page layout.\n\t\telsif (req.http.User-Agent ~ \"(?i)android 3\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\t\/* Opera Mobile *\/\n\t\telsif (req.http.User-Agent ~ \"Opera Mobi\") { set req.http.X-UA-Device = \"mobile-smartphone\"; }\n\t\t\/\/ May very well give false positives towards android tablets. Suggestions welcome.\n\t\telsif (req.http.User-Agent ~ \"(?i)android\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\telsif (req.http.User-Agent ~ \"PlayBook; U; RIM Tablet\") { set req.http.X-UA-Device = \"tablet-rim\"; }\n\t\telsif (req.http.User-Agent ~ \"hp-tablet.*TouchPad\") { set req.http.X-UA-Device = \"tablet-hp\"; }\n\t\telsif (req.http.User-Agent ~ \"Kindle\/3\") { set req.http.X-UA-Device = \"tablet-kindle\"; }\n\t\telsif (req.http.User-Agent ~ \"Touch.+Tablet PC\" ||\n\t\t req.http.User-Agent ~ \"Windows NT [0-9.]+; ARM;\" ) {\n\t\t set req.http.X-UA-Device = \"tablet-microsoft\";\n\t\t}\n\t\telsif (req.http.User-Agent ~ \"Mobile.+Firefox\") { set req.http.X-UA-Device = \"mobile-firefoxos\"; }\n\t\telsif (req.http.User-Agent ~ \"^HTC\" ||\n\t\t req.http.User-Agent ~ \"Fennec\" ||\n\t\t req.http.User-Agent ~ \"IEMobile\" ||\n\t\t req.http.User-Agent ~ \"BlackBerry\" ||\n\t\t req.http.User-Agent ~ \"BB10.*Mobile\" ||\n\t\t req.http.User-Agent ~ \"GT-.*Build\/GINGERBREAD\" ||\n\t\t req.http.User-Agent ~ \"SymbianOS.*AppleWebKit\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-smartphone\";\n\t\t}\n\t\telsif (req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)^sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)^nokia\" ||\n\t\t req.http.User-Agent ~ \"(?i)^samsung\" ||\n\t\t req.http.User-Agent ~ \"(?i)^lg\" ||\n\t\t req.http.User-Agent ~ \"(?i)bada\" ||\n\t\t req.http.User-Agent ~ \"(?i)blazer\" ||\n\t\t req.http.User-Agent ~ \"(?i)cellphone\" ||\n\t\t req.http.User-Agent ~ \"(?i)iemobile\" ||\n\t\t req.http.User-Agent ~ \"(?i)midp-2.0\" ||\n\t\t req.http.User-Agent ~ \"(?i)u990\" ||\n\t\t req.http.User-Agent ~ \"(?i)netfront\" ||\n\t\t req.http.User-Agent ~ \"(?i)opera mini\" ||\n\t\t req.http.User-Agent ~ \"(?i)palm\" ||\n\t\t req.http.User-Agent ~ \"(?i)nintendo wii\" ||\n\t\t req.http.User-Agent ~ \"(?i)playstation portable\" ||\n\t\t req.http.User-Agent ~ \"(?i)portalmmm\" ||\n\t\t req.http.User-Agent ~ \"(?i)proxinet\" ||\n\t\t req.http.User-Agent ~ \"(?i)sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)windows\\ ?ce\" ||\n\t\t req.http.User-Agent ~ \"(?i)winwap\" ||\n\t\t req.http.User-Agent ~ \"(?i)eudoraweb\" ||\n\t\t req.http.User-Agent ~ \"(?i)htc\" ||\n\t\t req.http.User-Agent ~ \"(?i)240x320\" ||\n\t\t req.http.User-Agent ~ \"(?i)avantgo\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-generic\";\n\t\t}\n\t}\n}\n","old_contents":"# Copyright (c) 2012-2014 Varnish Software AS\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions\n# are met:\n# 1. Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n# 2. Redistributions in binary form must reproduce the above copyright\n# notice, this list of conditions and the following disclaimer in the\n# documentation and\/or other materials provided with the distribution.\n#\n# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n# ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n# SUCH DAMAGE.\n#\n# detectdevice.vcl - regex based device detection for Varnish\n# https:\/\/github.com\/varnishcache\/varnish-devicedetect\/\n#\n# Author: Lasse Karstensen <lkarsten@varnish-software.com>\n\nsub devicedetect {\n\tunset req.http.X-UA-Device;\n\tset req.http.X-UA-Device = \"pc\";\n\n\t# Handle that a cookie may override the detection alltogether.\n\tif (req.http.Cookie ~ \"(?i)X-UA-Device-force\") {\n\t\t\/* ;?? means zero or one ;, non-greedy to match the first. *\/\n\t\tset req.http.X-UA-Device = regsub(req.http.Cookie, \"(?i).*X-UA-Device-force=([^;]+);??.*\", \"\\1\");\n\t\t\/* Clean up our mess in the cookie header *\/\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|; ) *X-UA-Device-force=[^;]+;? *\", \"\\1\");\n\t\t\/* If the cookie header is now empty, or just whitespace, unset it. *\/\n\t\tif (req.http.Cookie ~ \"^ *$\") { unset req.http.Cookie; }\n\t} else {\n if (req.http.User-Agent ~ \"\\(compatible; Googlebot-Mobile\/2.1; \\+http:\/\/www.google.com\/bot.html\\)\" ||\n (req.http.User-Agent ~ \"(Android|iPhone)\" && req.http.User-Agent ~ \"\\(compatible.?; Googlebot\/2.1.?; \\+http:\/\/www.google.com\/bot.html\") ||\n\t\t\t(req.http.User-Agent ~ \"(iPhone|Windows Phone)\" && req.http.User-Agent ~ \"\\(compatible; bingbot\/2.0; \\+http:\/\/www.bing.com\/bingbot.htm\")) {\n set req.http.X-UA-Device = \"mobile-bot\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)(ads|google|bing|msn|yandex|baidu|ro|career|seznam|)bot\" ||\n\t\t req.http.User-Agent ~ \"(?i)(baidu|jike|symantec)spider\" ||\n\t\t req.http.User-Agent ~ \"(?i)scanner\" ||\n\t\t req.http.User-Agent ~ \"(?i)(web)crawler\") {\n\t\t\tset req.http.X-UA-Device = \"bot\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ipad\") { set req.http.X-UA-Device = \"tablet-ipad\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ip(hone|od)\") { set req.http.X-UA-Device = \"mobile-iphone\"; }\n\t\t\/* how do we differ between an android phone and an android tablet?\n\t\t http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent *\/\n\t\telsif (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") { set req.http.X-UA-Device = \"mobile-android\"; }\n\t\t\/\/ android 3\/honeycomb was just about tablet-only, and any phones will probably handle a bigger page layout.\n\t\telsif (req.http.User-Agent ~ \"(?i)android 3\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\t\/* Opera Mobile *\/\n\t\telsif (req.http.User-Agent ~ \"Opera Mobi\") { set req.http.X-UA-Device = \"mobile-smartphone\"; }\n\t\t\/\/ May very well give false positives towards android tablets. Suggestions welcome.\n\t\telsif (req.http.User-Agent ~ \"(?i)android\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\telsif (req.http.User-Agent ~ \"PlayBook; U; RIM Tablet\") { set req.http.X-UA-Device = \"tablet-rim\"; }\n\t\telsif (req.http.User-Agent ~ \"hp-tablet.*TouchPad\") { set req.http.X-UA-Device = \"tablet-hp\"; }\n\t\telsif (req.http.User-Agent ~ \"Kindle\/3\") { set req.http.X-UA-Device = \"tablet-kindle\"; }\n\t\telsif (req.http.User-Agent ~ \"Touch.+Tablet PC\" ||\n\t\t req.http.User-Agent ~ \"Windows NT [0-9.]+; ARM;\" ) {\n\t\t set req.http.X-UA-Device = \"tablet-microsoft\";\n\t\t}\n\t\telsif (req.http.User-Agent ~ \"Mobile.+Firefox\") { set req.http.X-UA-Device = \"mobile-firefoxos\"; }\n\t\telsif (req.http.User-Agent ~ \"^HTC\" ||\n\t\t req.http.User-Agent ~ \"Fennec\" ||\n\t\t req.http.User-Agent ~ \"IEMobile\" ||\n\t\t req.http.User-Agent ~ \"BlackBerry\" ||\n\t\t req.http.User-Agent ~ \"BB10.*Mobile\" ||\n\t\t req.http.User-Agent ~ \"GT-.*Build\/GINGERBREAD\" ||\n\t\t req.http.User-Agent ~ \"SymbianOS.*AppleWebKit\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-smartphone\";\n\t\t}\n\t\telsif (req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)^sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)^nokia\" ||\n\t\t req.http.User-Agent ~ \"(?i)^samsung\" ||\n\t\t req.http.User-Agent ~ \"(?i)^lg\" ||\n\t\t req.http.User-Agent ~ \"(?i)bada\" ||\n\t\t req.http.User-Agent ~ \"(?i)blazer\" ||\n\t\t req.http.User-Agent ~ \"(?i)cellphone\" ||\n\t\t req.http.User-Agent ~ \"(?i)iemobile\" ||\n\t\t req.http.User-Agent ~ \"(?i)midp-2.0\" ||\n\t\t req.http.User-Agent ~ \"(?i)u990\" ||\n\t\t req.http.User-Agent ~ \"(?i)netfront\" ||\n\t\t req.http.User-Agent ~ \"(?i)opera mini\" ||\n\t\t req.http.User-Agent ~ \"(?i)palm\" ||\n\t\t req.http.User-Agent ~ \"(?i)nintendo wii\" ||\n\t\t req.http.User-Agent ~ \"(?i)playstation portable\" ||\n\t\t req.http.User-Agent ~ \"(?i)portalmmm\" ||\n\t\t req.http.User-Agent ~ \"(?i)proxinet\" ||\n\t\t req.http.User-Agent ~ \"(?i)sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)windows\\ ?ce\" ||\n\t\t req.http.User-Agent ~ \"(?i)winwap\" ||\n\t\t req.http.User-Agent ~ \"(?i)eudoraweb\" ||\n\t\t req.http.User-Agent ~ \"(?i)htc\" ||\n\t\t req.http.User-Agent ~ \"(?i)240x320\" ||\n\t\t req.http.User-Agent ~ \"(?i)avantgo\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-generic\";\n\t\t}\n\t}\n}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"d6b596b80ae43c4dca03d7acc91bccc22dc6b667","subject":"Added version number","message":"Added version number\n","repos":"theikkila\/scuttle,theikkila\/scuttle","old_file":"default.vcl","new_file":"default.vcl","new_contents":"vcl 4.0;\n# This is a basic VCL configuration file for varnish. See the vcl(7)\n# man page for details on VCL syntax and semantics.\n# \n# Default backend definition. Set this to point to your content\n# server.\n# \nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\n\n\nacl purge {\n \"localhost\";\n \"10.0.0.0\"\/8;\n \"192.168.0.0\"\/16;\n \"172.16.0.0\"\/12;\n}\n\nsub vcl_backend_response { \n # TTL 1 min\n set beresp.ttl = 1m;\n if (bereq.url ~ \"\\.(avi|mp4|ogv|deb|tar|gz|rar||zip)$\") {\n set beresp.do_stream = true;\n set beresp.ttl = 3m;\n }\n}\n\nsub vcl_recv {\n unset req.http.Cookie;\n if (req.method != \"GET\" && req.method != \"HEAD\"){ \n return (pass);\n }\n if (req.url ~ \"^[^?]*\\.(mp[34]|rar|tar|tgz|gz|wav|iso|img|dmg|mkv|ogv|avi|zip)(\\?.*)?$\") {\n unset req.http.Cookie;\n return (pipe);\n }\n if (req.http.Authorization) {\n # Not cacheable by default\n return (pass);\n }\n # Allow purging\n if (req.method == \"PURGE\") {\n if (!client.ip ~ purge) {\n # Not from an allowed IP? Then die with an error.\n return (synth(405, \"This IP is not allowed to send PURGE requests.\"));\n }\n\n # If you got this stage (and didn't error out above), do a cache-lookup\n # That will force entry into vcl_hit() or vcl_miss() below and purge the actual cache\n return (hash);\n }\n}\n\n\nsub vcl_hit {\n # Allow purges\n if (req.method == \"PURGE\") {\n #\n # This is now handled in vcl_recv.\n #\n # purge;\n return (synth(200, \"purged\"));\n }\n\n return (deliver);\n}\n\nsub vcl_miss {\n # Allow purges\n if (req.method == \"PURGE\") {\n #\n # This is now handled in vcl_recv.\n #\n # purge;\n return (synth(200, \"purged\"));\n }\n\n return (fetch);\n}\n\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"cached\";\n } else {\n set resp.http.X-Cache = \"uncached\";\n }\n\n unset resp.http.Server;\n unset resp.http.X-Varnish;\n unset resp.http.Via;\n unset resp.http.Link;\n\n return (deliver);\n}","old_contents":"# This is a basic VCL configuration file for varnish. See the vcl(7)\n# man page for details on VCL syntax and semantics.\n# \n# Default backend definition. Set this to point to your content\n# server.\n# \nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\n\n\nacl purge {\n \"localhost\";\n \"10.0.0.0\"\/8;\n \"192.168.0.0\"\/16;\n \"172.16.0.0\"\/12;\n}\n\nsub vcl_backend_response { \n # TTL 1 min\n set beresp.ttl = 1m;\n if (bereq.url ~ \"\\.(avi|mp4|ogv|deb|tar|gz|rar||zip)$\") {\n set beresp.do_stream = true;\n set beresp.ttl = 3m;\n }\n}\n\nsub vcl_recv {\n unset req.http.Cookie;\n if (req.method != \"GET\" && req.method != \"HEAD\"){ \n return (pass);\n }\n if (req.url ~ \"^[^?]*\\.(mp[34]|rar|tar|tgz|gz|wav|iso|img|dmg|mkv|ogv|avi|zip)(\\?.*)?$\") {\n unset req.http.Cookie;\n return (pipe);\n }\n if (req.http.Authorization) {\n # Not cacheable by default\n return (pass);\n }\n # Allow purging\n if (req.method == \"PURGE\") {\n if (!client.ip ~ purge) {\n # Not from an allowed IP? Then die with an error.\n return (synth(405, \"This IP is not allowed to send PURGE requests.\"));\n }\n\n # If you got this stage (and didn't error out above), do a cache-lookup\n # That will force entry into vcl_hit() or vcl_miss() below and purge the actual cache\n return (hash);\n }\n}\n\n\nsub vcl_hit {\n # Allow purges\n if (req.method == \"PURGE\") {\n #\n # This is now handled in vcl_recv.\n #\n # purge;\n return (synth(200, \"purged\"));\n }\n\n return (deliver);\n}\n\nsub vcl_miss {\n # Allow purges\n if (req.method == \"PURGE\") {\n #\n # This is now handled in vcl_recv.\n #\n # purge;\n return (synth(200, \"purged\"));\n }\n\n return (fetch);\n}\n\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"cached\";\n } else {\n set resp.http.X-Cache = \"uncached\";\n }\n\n unset resp.http.Server;\n unset resp.http.X-Varnish;\n unset resp.http.Via;\n unset resp.http.Link;\n\n return (deliver);\n}","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"876d4c5d5d05b2dd5b837e5b2f826cf14574ae9d","subject":"add statcounter cookies to exclusion list","message":"add statcounter cookies to exclusion list\n","repos":"xini\/silverstripe-section-io","old_file":"default.vcl","new_file":"default.vcl","new_contents":"# See the VCL chapters in the Users Guide at https:\/\/www.varnish-cache.org\/docs\/\n# and http:\/\/varnish-cache.org\/trac\/wiki\/VCLExamples for more examples.\n\n# Marker to tell the VCL compiler that this VCL has been adapted to the\n# new 4.0 format.\nvcl 4.0;\n\nbackend default {\n\t.host = \"next-hop\";\n\t.port = \"80\";\n}\n\ninclude \"section-features.vcl\";\n\n# The following VMODs are available for use if required:\n#import geoip; # see https:\/\/github.com\/varnish\/libvmod-geoip\n#import header; # see https:\/\/github.com\/varnish\/libvmod-header\n\nsub vcl_recv {\n\t# Happens before we check if we have this in cache already.\n\t#\n\t# Typically you clean up the request here, removing cookies you don't need,\n\t# rewriting the request, etc.\n\t\n\t# clean up accept-encoding\n\tif (req.http.Accept-Encoding) {\n\t\tif (req.http.Accept-Encoding ~ \"gzip\") {\n\t\t\tset req.http.Accept-Encoding = \"gzip\";\n\t\t} else if (req.http.Accept-Encoding ~ \"deflate\") {\n\t\t\tset req.http.Accept-Encoding = \"deflate\";\n\t\t} else {\n\t\t\tunset req.http.Accept-Encoding;\n\t\t}\n\t}\t\n\t\n\t# remove cookies for static content based on \/assets\/.htaccess\n\tif (req.url ~ \".*\\.(?:js|css|bmp|png|gif|jpg|jpeg|ico|pcx|tif|tiff|au|mid|midi|mpa|mp3|ogg|m4a|ra|wma|wav|cda|avi|mpg|mpeg|asf|wmv|m4v|mov|mkv|mp4|ogv|webm|swf|flv|ram|rm|doc|docx|txt|rtf|xls|xlsx|pages|ppt|pptx|pps|csv|cab|arj|tar|zip|zipx|sit|sitx|gz|tgz|bz2|ace|arc|pkg|dmg|hqx|jar|pdf|woff|eot|ttf|otf|svg)(?=\\?|&|$)\") {\n\t\tunset req.http.Cookie;\n\t\treturn (hash);\n\t}\n\t\n\t# ss admin\n\tif (req.url ~ \"^\/(Security|admin|dev)\" || req.url ~ \"stage=\") {\n\t\treturn (pass);\n\t}\n\t\n\t# ss multistep form\n\tif( req.url ~ \"MultiFormSessionID=\" ) {\n\t\treturn (pass);\n\t}\n\t\n\t# check for login cookie\n\tif ( req.http.Cookie ~ \"sslogin=\" ) {\n\t\treturn (pass);\n\t}\n\t\n\t# remove tracking cookies\n\tif (req.http.Cookie) {\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|(?<=; )) *__utm.=[^;]+;? *\", \"\\1\"); # standard ga cookies\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|;\\s*)(_dc_gtm_[A-Z0-9\\-]+)=[^;]*\", \"\"); # gtm cookies\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|;\\s*)(_ga)=[^;]*\", \"\"); # gtm ga cookies\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|;\\s*)(_gat)=[^;]*\", \"\"); # legacy ga cookies\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|;\\s*)(AUA[0-9]+)=[^;]*\", \"\"); # avanser phone tracking cookies\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|;\\s*)(sc_is_visitor_unique)=[^;]*\", \"\"); # StatCounter web analytics\n\n\t\tif (req.http.Cookie == \"\") {\n\t\t\tunset req.http.Cookie;\n\t\t}\n\t}\n\t\n\t# remove adwords gclid parameter\n\tset req.url = regsuball(req.url,\"\\?gclid=[^&]+$\",\"\"); # strips when QS = \"?gclid=AAA\"\n\tset req.url = regsuball(req.url,\"\\?gclid=[^&]+&\",\"?\"); # strips when QS = \"?gclid=AAA&foo=bar\"\n\tset req.url = regsuball(req.url,\"&gclid=[^&]+\",\"\"); # strips when QS = \"?foo=bar&gclid=AAA\" or QS = \"?foo=bar&gclid=AAA&bar=baz\"\n\t\n}\n\nsub vcl_backend_fetch {\n\t# Called before sending the backend request.\n\t#\n\t# Typically you alter the request for the backend here. Overriding to the\n\t# required hostname, upstream Proto matching, etc\n\t\n}\n\nsub vcl_backend_response {\n\t# Happens after we have read the response headers from the backend.\n\t#\n\t# Here you clean the response headers, removing silly Set-Cookie headers\n\t# and other mistakes your backend does.\n\t\n\t# cache static content\n\t# css & js\n\tif (bereq.url ~ \".*\\.(?:css|js)(?=\\?|&|$)\") { \n\t\tset beresp.ttl = 604800s; # The number of seconds to cache inside Varnish: 1 week\n\t\tset beresp.http.Cache-Control = \"public, max-age=604800\"; # The number of seconds to cache in browser: 1 week\n\t}\n\t# images, audio, video\n\tif (bereq.url ~ \".*\\.(?:bmp|png|gif|jpg|jpeg|ico|pcx|tif|tiff|au|mid|midi|mpa|mp3|ogg|m4a|ra|wma|wav|cda|avi|mpg|mpeg|asf|wmv|m4v|mov|mkv|mp4|ogv|webm|swf|flv|ram|rm)(?=\\?|&|$)\") {\n\t\tset beresp.ttl = 2592000s; # The number of seconds to cache inside Varnish: 1 month\n\t\tset beresp.http.Cache-Control = \"public, max-age=2592000\"; # The number of seconds to cache in browser: 1 month\n\t}\n\t# docs and archives\n\tif (bereq.url ~ \".*\\.(?:doc|docx|txt|rtf|xls|xlsx|pages|ppt|pptx|pps|csv|cab|arj|tar|zip|zipx|sit|sitx|gz|tgz|bz2|ace|arc|pkg|dmg|hqx|jar|pdf)(?=\\?|&|$)\") {\n\t\tset beresp.ttl = 2592000s; # The number of seconds to cache inside Varnish: 1 month\n\t\tset beresp.http.Cache-Control = \"public, max-age=2592000\"; # The number of seconds to cache in browser: 1 month\n\t}\n\t# fonts\n\tif (bereq.url ~ \".*\\.(?:woff|eot|ttf|otf|svg)(?=\\?|&|$)\") {\n\t\tset beresp.ttl = 2592000s; # The number of seconds to cache inside Varnish: 1 month\n\t\tset beresp.http.Cache-Control = \"public, max-age=2592000\"; # The number of seconds to cache in browser: 1 month\n\t}\n\t\n\t# set cache control header for pages\n if (beresp.http.Content-Type ~ \"^text\/html\" && !(bereq.url ~ \"^\/(Security|admin|dev)\") && !(bereq.http.Cookie ~ \"sslogin=\") && !(beresp.http.Pragma ~ \"no-cache\") ) {\n\t\t set beresp.ttl = 3600s;\n\t\t set beresp.http.Cache-Control = \"public, max-age=600\";\n }\n\t\n\t# set grace period\n\tset beresp.grace = 1d;\n\t\n\t### DO NOT CHANGE ###\n\t# store url in cached object to use in ban()\n\tset beresp.http.x-url = bereq.url;\n\t\n}\n\nsub vcl_deliver {\n\t# Happens when we have all the pieces we need, and are about to send the\n\t# response to the client.\n\t#\n\t# You can do accounting or modifying the final object here.\n\t\n\t# add cache response header\n\tif (obj.hits > 0) {\n\t\tset resp.http.X-Cache = \"HIT\";\n\t} else {\n\t\tset resp.http.X-Cache = \"MISS\";\n\t}\n\t\n\t### DO NOT CHANGE ###\n\t# remove saved url from object before delivery\n\tunset resp.http.x-url;\n\t\n}\n\nsub vcl_hit {\n\t# deliver if ttl > 0, normal hit\n\tif (obj.ttl >= 0s) {\n\t\treturn (deliver);\n\t}\n\t# deliver if ttl = 0 but grace still on\n\tif (obj.ttl + obj.grace > 0s) {\n\t\treturn (deliver);\n\t}\n\t# fetch new content\n\treturn (fetch);\n}","old_contents":"# See the VCL chapters in the Users Guide at https:\/\/www.varnish-cache.org\/docs\/\n# and http:\/\/varnish-cache.org\/trac\/wiki\/VCLExamples for more examples.\n\n# Marker to tell the VCL compiler that this VCL has been adapted to the\n# new 4.0 format.\nvcl 4.0;\n\nbackend default {\n\t.host = \"next-hop\";\n\t.port = \"80\";\n}\n\ninclude \"section-features.vcl\";\n\n# The following VMODs are available for use if required:\n#import geoip; # see https:\/\/github.com\/varnish\/libvmod-geoip\n#import header; # see https:\/\/github.com\/varnish\/libvmod-header\n\nsub vcl_recv {\n\t# Happens before we check if we have this in cache already.\n\t#\n\t# Typically you clean up the request here, removing cookies you don't need,\n\t# rewriting the request, etc.\n\t\n\t# clean up accept-encoding\n\tif (req.http.Accept-Encoding) {\n\t\tif (req.http.Accept-Encoding ~ \"gzip\") {\n\t\t\tset req.http.Accept-Encoding = \"gzip\";\n\t\t} else if (req.http.Accept-Encoding ~ \"deflate\") {\n\t\t\tset req.http.Accept-Encoding = \"deflate\";\n\t\t} else {\n\t\t\tunset req.http.Accept-Encoding;\n\t\t}\n\t}\t\n\t\n\t# remove cookies for static content based on \/assets\/.htaccess\n\tif (req.url ~ \".*\\.(?:js|css|bmp|png|gif|jpg|jpeg|ico|pcx|tif|tiff|au|mid|midi|mpa|mp3|ogg|m4a|ra|wma|wav|cda|avi|mpg|mpeg|asf|wmv|m4v|mov|mkv|mp4|ogv|webm|swf|flv|ram|rm|doc|docx|txt|rtf|xls|xlsx|pages|ppt|pptx|pps|csv|cab|arj|tar|zip|zipx|sit|sitx|gz|tgz|bz2|ace|arc|pkg|dmg|hqx|jar|pdf|woff|eot|ttf|otf|svg)(?=\\?|&|$)\") {\n\t\tunset req.http.Cookie;\n\t\treturn (hash);\n\t}\n\t\n\t# ss admin\n\tif (req.url ~ \"^\/(Security|admin|dev)\" || req.url ~ \"stage=\") {\n\t\treturn (pass);\n\t}\n\t\n\t# ss multistep form\n\tif( req.url ~ \"MultiFormSessionID=\" ) {\n\t\treturn (pass);\n\t}\n\t\n\t# check for login cookie\n\tif ( req.http.Cookie ~ \"sslogin=\" ) {\n\t\treturn (pass);\n\t}\n\t\n\t# remove tracking cookies\n\tif (req.http.Cookie) {\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|(?<=; )) *__utm.=[^;]+;? *\", \"\\1\"); # standard ga cookies\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|;\\s*)(_dc_gtm_[A-Z0-9\\-]+)=[^;]*\", \"\"); # gtm cookies\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|;\\s*)(_ga)=[^;]*\", \"\"); # gtm ga cookies\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|;\\s*)(_gat)=[^;]*\", \"\"); # legacy ga cookies\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|;\\s*)(AUA[0-9]+)=[^;]*\", \"\"); # avanser phone tracking cookies\n\n\t\tif (req.http.Cookie == \"\") {\n\t\t\tunset req.http.Cookie;\n\t\t}\n\t}\n\t\n\t# remove adwords gclid parameter\n\tset req.url = regsuball(req.url,\"\\?gclid=[^&]+$\",\"\"); # strips when QS = \"?gclid=AAA\"\n\tset req.url = regsuball(req.url,\"\\?gclid=[^&]+&\",\"?\"); # strips when QS = \"?gclid=AAA&foo=bar\"\n\tset req.url = regsuball(req.url,\"&gclid=[^&]+\",\"\"); # strips when QS = \"?foo=bar&gclid=AAA\" or QS = \"?foo=bar&gclid=AAA&bar=baz\"\n\t\n}\n\nsub vcl_backend_fetch {\n\t# Called before sending the backend request.\n\t#\n\t# Typically you alter the request for the backend here. Overriding to the\n\t# required hostname, upstream Proto matching, etc\n\t\n}\n\nsub vcl_backend_response {\n\t# Happens after we have read the response headers from the backend.\n\t#\n\t# Here you clean the response headers, removing silly Set-Cookie headers\n\t# and other mistakes your backend does.\n\t\n\t# cache static content\n\t# css & js\n\tif (bereq.url ~ \".*\\.(?:css|js)(?=\\?|&|$)\") { \n\t\tset beresp.ttl = 604800s; # The number of seconds to cache inside Varnish: 1 week\n\t\tset beresp.http.Cache-Control = \"public, max-age=604800\"; # The number of seconds to cache in browser: 1 week\n\t}\n\t# images, audio, video\n\tif (bereq.url ~ \".*\\.(?:bmp|png|gif|jpg|jpeg|ico|pcx|tif|tiff|au|mid|midi|mpa|mp3|ogg|m4a|ra|wma|wav|cda|avi|mpg|mpeg|asf|wmv|m4v|mov|mkv|mp4|ogv|webm|swf|flv|ram|rm)(?=\\?|&|$)\") {\n\t\tset beresp.ttl = 2592000s; # The number of seconds to cache inside Varnish: 1 month\n\t\tset beresp.http.Cache-Control = \"public, max-age=2592000\"; # The number of seconds to cache in browser: 1 month\n\t}\n\t# docs and archives\n\tif (bereq.url ~ \".*\\.(?:doc|docx|txt|rtf|xls|xlsx|pages|ppt|pptx|pps|csv|cab|arj|tar|zip|zipx|sit|sitx|gz|tgz|bz2|ace|arc|pkg|dmg|hqx|jar|pdf)(?=\\?|&|$)\") {\n\t\tset beresp.ttl = 2592000s; # The number of seconds to cache inside Varnish: 1 month\n\t\tset beresp.http.Cache-Control = \"public, max-age=2592000\"; # The number of seconds to cache in browser: 1 month\n\t}\n\t# fonts\n\tif (bereq.url ~ \".*\\.(?:woff|eot|ttf|otf|svg)(?=\\?|&|$)\") {\n\t\tset beresp.ttl = 2592000s; # The number of seconds to cache inside Varnish: 1 month\n\t\tset beresp.http.Cache-Control = \"public, max-age=2592000\"; # The number of seconds to cache in browser: 1 month\n\t}\n\t\n\t# set cache control header for pages\n if (beresp.http.Content-Type ~ \"^text\/html\" && !(bereq.url ~ \"^\/(Security|admin|dev)\") && !(bereq.http.Cookie ~ \"sslogin=\") && !(beresp.http.Pragma ~ \"no-cache\") ) {\n\t\t set beresp.ttl = 3600s;\n\t\t set beresp.http.Cache-Control = \"public, max-age=600\";\n }\n\t\n\t# set grace period\n\tset beresp.grace = 1d;\n\t\n\t### DO NOT CHANGE ###\n\t# store url in cached object to use in ban()\n\tset beresp.http.x-url = bereq.url;\n\t\n}\n\nsub vcl_deliver {\n\t# Happens when we have all the pieces we need, and are about to send the\n\t# response to the client.\n\t#\n\t# You can do accounting or modifying the final object here.\n\t\n\t# add cache response header\n\tif (obj.hits > 0) {\n\t\tset resp.http.X-Cache = \"HIT\";\n\t} else {\n\t\tset resp.http.X-Cache = \"MISS\";\n\t}\n\t\n\t### DO NOT CHANGE ###\n\t# remove saved url from object before delivery\n\tunset resp.http.x-url;\n\t\n}\n\nsub vcl_hit {\n\t# deliver if ttl > 0, normal hit\n\tif (obj.ttl >= 0s) {\n\t\treturn (deliver);\n\t}\n\t# deliver if ttl = 0 but grace still on\n\tif (obj.ttl + obj.grace > 0s) {\n\t\treturn (deliver);\n\t}\n\t# fetch new content\n\treturn (fetch);\n}","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"e73b3b4aa83bbd95bb29146f5c6233f8469915a9","subject":"fileread clarification","message":"fileread clarification\n","repos":"NITEMAN\/Varnish_VCL_samps-hacks,NITEMAN\/varnish-bites","old_file":"varnish4\/drupal-base.vcl","new_file":"varnish4\/drupal-base.vcl","new_contents":"\/* Varnish 4 example config for Drupal 7 \/ Pressflow 6 & 7 *\/\n# Original source: https:\/\/github.com\/NITEMAN\/varnish-bites\/varnish4\/drupal-base.vcl\n# Copyright (c) 2015 Pedro Gonz\u00e1lez Serrano and individual contributors.\n# MIT License\n\n# Intended to be used both in simple production environments and with\n# learning\/teaching purposes.\n# Some references may not be yet updated to VCL 4.0, we use SeeV3 then.\n\n# WARNING:\n# Note that the built-in logic will be appended to our code if no return is performed before.\n# Built-in logic is included commented out right after our's for reference purposes in that cases.\n# See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleDefault\n\n#######################################################################\n# Initialization: Version & imports;\n\n\/* Version statement *\/\n# Since Varnish 4.0 it's mandatory to declare VCL version on first line.\nvcl 4.0;\n\n\/* Module (VMOD) imports *\/\n# Standard module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_std.generated.html\nimport std;\n\n# Directors module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# Unused in simple configs.\n#import directors;\n\n\n#######################################################################\n# Probe, backend, ACL and subroutine definitions\n\n\/* Backend probes \/ healthchecks *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#probes\nprobe basic {\n \/* Only test that backend's IP serves content for '\/' *\/\n # This might be a too heavy probe\n # .url = \"\/\";\n \/* Only test that backend's IP has apache working *\/\n # Nginx would fail this probe with a default config\n .request =\n \"OPTIONS * HTTP\/1.1\"\n \"Host: *\"\n \"Connection: close\";\n .interval = 10s;\n .timeout = 2s;\n .window = 8;\n .threshold = 6;\n}\n\n\/* Backend definitions.*\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#backend-definition\nbackend default {\n \/* Default backend on the same machine. WARNING: timeouts could be not big enought for certain POST request *\/\n .host = \"127.0.0.1\";\n .port = \"8008\";\n .connect_timeout = 60s;\n .first_byte_timeout = 60s;\n .between_bytes_timeout = 60s;\n .probe = basic;\n}\n\n\/* Access Control Lists *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#access-control-list-acl\nacl purge_ban {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use '\"localhost\";' instead\n}\nacl allowed_monitors {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n}\n#acl own_proxys {\n# \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n#}\n\n\/* Custom subroutines *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#subroutines\n#TODO# Test in Varnihs 4\n# Empty in simple configs.\n# We can name subs with no restrictions but as a task can need several chunks of code in diferent states,\n# it's a good idea to identify what main sub will call each with a suffix.\n# \/* Example 301 client redirection removing \"www\" prefix from request *\/\n# sub perm_redirections_recv {\n# if ( req.http.host ~ \"^www.*$\" ) {\n# return(synth(751, \"http:\/\/\" + regsub(req.http.host, \"^www\\.\", \"\") + req.url));\n# }\n# }\n# sub perm_redirections_synth {\n# if (resp.status == 751) {\n# \/* Get new URL from the response *\/\n# set resp.http.Location = resp.response;\n# \/* Set HTTP 301 for permanent redirect *\/\n# set resp.status = 301;\n# return (deliver);\n# }\n# }\n\n\n#######################################################################\n# Client side\n\n# vcl_recv: Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-recv\nsub vcl_recv {\n \/* 0th: general bypass, general return & authorization checks *\/\n # Empty in simple configs.\n # Useful for debugging we can pipe or pass the request to default backend here to bypass completely Varnish.\n # return (pipe);\n # return (pass);\n # We can also return here a 200 Ok for network performance benchmarking.\n # return(synth(200, \"Ok\"));\n # Finally we can perform basic HTTP authentification here, by example.\n # SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* 1st: Check for Varnish special requests *\/ \n # Custom response implementation example in order to check that Varnish is working properly.\n # This is usefull for automatic monitoring with monit or when Varnish is behind another proxies like HAProxy.\n if ( ( req.http.host == \"monitor.server.health\"\n || req.http.host == \"health.varnish\" )\n && client.ip ~ allowed_monitors\n && ( req.method == \"OPTIONS\" || req.method == \"GET\" )\n ) {\n return(synth(200, \"Ban added\"));\n }\n # Purge logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#http-purging\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if (req.method == \"PURGE\") {\n if (!client.ip ~ purge_ban) {\n return(synth(405, \"Not allowed.\"));\n }\n return (purge);\n }\n # Ban logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#bans\n if (req.method == \"BAN\") {\n if (!client.ip ~ purge_ban) {\n return(synth(405, \"Not allowed.\"));\n }\n ban(\"req.http.host == \" + req.http.host +\n \"&& req.url == \" + req.url); \n return(synth(200, \"Ban added\"));\n }\n\n \/* 2nd: Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_recv;\n # Here we can also enforce SSL when Varnish run behind some SSL termination point.\n\n \/* 3rd: Time for backend choice *\/\n # Empty in simple configs.\n\n \/* 4th: Prepare headers for the backend *\/\n # Empty in simple configs.\n # Example remove own_proxys from X-Forwarded-For\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/whats-new\/upgrading.html#x-forwarded-for-is-now-set-before-vcl-recv\n # if ( req.restarts == 0\n # && client.ip ~ own_proxys\n # && req.http.x-forwarded-for\n # ) {\n # set req.http.X-Forwarded-For = regsub(req.http.X-Forwarded-For, \",( )?\" + client.ip, \"\");\n # }\n\n \/* 5th: Bypass breakpoint 1 *\/\n # Useful for debugging we can now pipe or pass the request to backend with headers setted.\n # return (pipe);\n # return (pass);\n\n \/* 6th: Decide if we should deal with a request (mostly copied from built-in logic) *\/\n if (req.method == \"PRI\") {\n \/* We do not support SPDY or HTTP\/2.0 *\/\n return (synth(405));\n }\n if ( req.method != \"GET\"\n && req.method != \"HEAD\"\n && req.method != \"PUT\"\n && req.method != \"POST\"\n && req.method != \"TRACE\"\n && req.method != \"OPTIONS\"\n && req.method != \"DELETE\"\n ) {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n\n \/* 7th: Access control for some URLs by ACL *\/\n # Empty in simple configs.\n # By example denial some URLs depending on client-ip, we'll need to define corresponding ACL 'internal'.\n # if ( req.url ~ \"^\/(cron|install)\\.php\"\n # && ! client.ip ~ internal\n # ) {\n # # Have Varnish throw the error directly.\n # return(synth(403, \"Forbidden.\"));\n # # Use a custom error page that you've defined in Drupal at the path \"404\".\n # # set req.url = \"\/403\";\n # }\n\n \/* 8th: Custom exceptions *\/\n # Host exception example:\n # if (req.http.host == \"ejemplo.exception.com\") {\n # return (pass);\n # }\n # Drupal exceptions, edit if we want to cache some AJAX\/AHAH request.\n # Add here filters for never cache URLs such as Payment Gateway's callbacks\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/ooyala\/ping$\" ||\n req.url ~ \"^\/admin\/build\/features\" ||\n req.url ~ \"^\/info\/.*$\" ||\n req.url ~ \"^\/flag\/.*$\" ||\n req.url ~ \"^.*\/ajax\/.*$\" ||\n req.url ~ \"^.*\/ahah\/.*$\") {\n \/* Do not cache these paths *\/\n return (pass);\n }\n # Pipe these paths directly to backend for streaming.\n if (req.url ~ \"^\/admin\/content\/backup_migrate\/export\") {\n return (pipe);\n }\n if (req.url ~ \"^\/system\/files\") {\n return (pipe);\n }\n\n \/* 9th: Serve from anonymous cahe if all backends are down *\/\n if (! std.healthy(req.backend_hint) ) {\n #TODO# Consider moving this to vcl_backend_fetch\n unset req.http.Cookie;\n #TODO# Add sick marker\n } \n\n \/* 10th: Deal with compression and the Accept-Encoding header *\/\n # Althought Varnish 3 handles gziped content itself by default, just to be sure we want to \n # remove Accept-Encoding for some compressed formats.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html#what-does-http-gzip-support-do\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/varnishd.html?highlight=http_gzip_support\n # See (for older configs) https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleNormalizeAcceptEncoding\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|mp4|flv|zip|rar)$\") {\n \/* Already compressed formats, no sense trying to compress again *\/\n unset req.http.Accept-Encoding;\n }\n }\n\n \/* 11th: Another header manipulation *\/\n # Empty in simple configs.\n # We could add here a custom header grouping User-agent families.\n\n \/* 12th: Cookie removal *\/\n # Always cache the following static file types for all users. \n # Use with care if we control certain downloads depending on cookies. \n # Be carefull also if appending .htm[l] via Drupal's clean URLs.\n if ( req.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|woff2|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n && req.url !~ \"\/system\/storage\/serve\"\n ) {\n unset req.http.Cookie;\n }\n # Remove all cookies that backend doesn't need to know about.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRemovingSomeCookies\n if (req.http.Cookie) {\n \/* Warning: Not a pretty solution *\/\n \/* Prefix header containing cookies with ';' *\/\n set req.http.Cookie = \";\" + req.http.Cookie;\n \/* Remove any spaces after ';' in header containing cookies *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n \/* Prefix cookies we want to preserve with one space *\/\n \/* 'S{1,2}ESS[a-z0-9]+' is the regular expression matching a Drupal session cookie ({1,2} added for HTTPS support) *\/\n \/* 'NO_CACHE' is usually set after a POST request to make sure issuing user see the results of his post *\/\n \/* 'OATMEAL' & 'CHOCOLATECHIP' are special cookies used by Drupal's Bakery module to provide Single Sign On *\/\n \/* Keep in mind we should add here any cookie that should reach the backend such as splahs avoiding cookies *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \";(S{1,2}ESS[a-z0-9]+|NO_CACHE|OATMEAL|CHOCOLATECHIP)=\", \"; \\1=\");\n \/* Remove from the header any single Cookie not prefixed with a space until next ';' separator *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n \/* Remove any '; ' at the start or the end of the header *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n\n if (req.http.Cookie == \"\") {\n \/* If there are no remaining cookies, remove the cookie header. *\/\n unset req.http.Cookie;\n }\n }\n\n \/* 13th: Session cookie & special cookies bypass caching stage *\/\n # As we might want to cache some requests, hashed with its cookies, \n # we don't simply pass when some cookies remain present at this point.\n # Instead we look for request that must be passed due to the cookie header.\n if ( req.http.Cookie ~ \"SESS\"\n || req.http.Cookie ~ \"SSESS\"\n || req.http.Cookie ~ \"NO_CACHE\"\n || req.http.Cookie ~ \"OATMEAL\"\n || req.http.Cookie ~ \"CHOCOLATECHIP\"\n ) {\n return (pass);\n }\n\n \/* 14th: Bypass breakpoint 2 *\/\n # Useful for debugging we can now pipe or pass the request to backend to bypass cache.\n # return (pipe);\n # return (pass);\n\n \/* 15th: Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning inconditionally.\n return (hash);\n}\n\n# vcl_pipe: Called upon entering pipe mode.\n# In this mode, the request is passed on to the backend, \n# and any further data from either client or backend is passed on unaltered until either end closes the connection.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pipe\n# sub vcl_pipe {\n# # By default Connection: close is set on all piped requests, to stop\n# # connection reuse from sending future requests directly to the\n# # (potentially) wrong backend. If you do want this to happen, you can undo\n# # it here.\n# # unset bereq.http.connection;\n# return (pipe);\n# }\n\n# vcl_pass: Called upon entering pass mode. \n# In this mode, the request is passed on to the backend, and the backend's response is passed on to the client, \n# but is not entered into the cache.\n# Subsequent requests submitted over the same client connection are handled normally.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pass\n# sub vcl_pass {\n# return (fetch);\n# }\n\n# vcl_hash: You may call hash_data() on the data you would like to add to the hash.\n# Hash is used by Varnish to uniquely identify objects.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hash\nsub vcl_hash {\n \/* Hash cookie data *\/\n # As requests with same URL and host can produce diferent results when issued with different cookies,\n # we need to store items hashed with the associated cookies. Note that cookies are already sanitized when we reach this point.\n if (req.http.Cookie) {\n \/* Include cookie in cache hash *\/\n hash_data(req.http.Cookie);\n }\n\n \/* Custom header hashing *\/\n # Empty in simple configs.\n # Example for caching differents object versions by device previously detected (when static content could also vary):\n # if (req.http.X-UA-Device) {\n # hash_data(req.http.X-UA-Device);\n # }\n # Example for caching diferent object versions by X-Forwarded-Proto, trying to be smart about what kind of request\n # could generate diffetent responses.\n if ( req.http.X-Forwarded-Proto\n && req.url !~ \"(?i)\\.(png|gif|jpeg|jpg|ico|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|woff2|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\") {\n hash_data(req.http.X-Forwarded-Proto);\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (lookup);\n# }\n\n# vcl_purge: Called after the purge has been executed and all its variants have been evited.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-purge\n# sub vcl_purge {\n# return (synth(200, \"Purged\"));\n# }\n\n# vcl_hit: Called after a cache lookup if the requested document was found in the cache.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hit\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n \/\/ A pure unadultered hit, deliver it\n return (deliver);\n }\n \/* Allow varnish to serve up stale content if it is responding slowly *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n if (obj.ttl + 60s > 0s) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n return (deliver);\n }\n \/* Allow varish to serve up stale content if all backends are down *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n if ( ! std.healthy(req.backend_hint)\n && obj.ttl + obj.grace > 0s\n ) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n return (deliver);\n }\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning inconditionally.\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\n# vcl_miss: Called after a cache lookup if the requested document was not found in the cache.\n# Its purpose is to decide whether or not to attempt to retrieve the document from the backend, and which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-miss\n# sub vcl_miss {\n# return (fetch);\n# }\n\n# vcl_deliver: Called before an object is delivered to the client\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-deliver\nsub vcl_deliver {\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # Add whether the object is a cache hit or miss and the number of hits for the object.\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Addingaheaderindicatinghitmiss\n # In Varnish 4 the obj.hits counter behaviour has changed (see bug 1492), so\n # we use a different method: if X-Varnish contains only 1 id, we have a miss,\n # if it contains more (and therefore a space), we have a hit.\n if (resp.http.x-varnish ~ \" \") {\n set resp.http.X-Cache = \"HIT\";\n # Since in Varnish 4 the behaviour of obj.hits changed, this might not be accurate\n # See https:\/\/www.varnish-cache.org\/trac\/ticket\/1492\n set resp.http.X-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Cache = \"MISS\";\n \/* Show the results of cookie sanitization *\/\n set resp.http.X-Cookie = req.http.Cookie;\n }\n\n #TODO# Add sick marker\n\n # Restart count\n if ( req.restarts > 0) {\n set resp.http.X-Restarts = req.restarts;\n }\n\n # Add the Varnish server hostname\n set resp.http.X-Varnish-Server = server.hostname;\n # If we have setted a custom header with device family detected we can show it:\n # if (req.http.X-UA-Device) {\n # set resp.http.X-UA-Device = req.http.X-UA-Device;\n # }\n # If we have recived a custom header with the protocol in the request we can show it:\n # if (req.http.X-Forwarded-Proto) {\n # set resp.http.X-Forwarded-Proto = req.http.X-Forwarded-Proto;\n # }\n\n \/* Vary header manipulation *\/\n # Empty in simple configs.\n # By example, if we are storing & serving diferent objects depending on User-Agent header we must set the correct Vary header:\n # if (resp.http.Vary) {\n # set resp.http.Vary = resp.http.Vary + \",User-Agent\";\n # } else {\n # set resp.http.Vary = \"User-Agent\";\n # }\n\n \/* Fake headers *\/\n # Empty in simple configs\n # We can fake server headers here, by example:\n # set resp.http.Server = \"Deep thought\";\n # set resp.http.X-Powered-By = \"BOFH\";\n # Or have some fun with headers:\n # See http:\/\/www.nextthing.org\/archives\/2005\/08\/07\/fun-with-http-headers\n # See http:\/\/royal.pingdom.com\/2012\/08\/15\/fun-and-unusual-http-response-headers\/\n # set resp.http.X-Thank-You = \"for bothering to look at my HTTP headers\";\n # set resp.http.X-Answer = \"42\";\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_deliver {\n# return (deliver);\n# }\n\n# vcl_synth: Called to deliver a synthetic object. A synthetic object is generated in VCL,\n# not fetched from the backend. It is typically contructed using the synthetic() function.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-synth\n\/*\n * We can come here \"invisibly\" with the following errors: 413, 417 & 503\n *\/\nsub vcl_synth {\n \/* Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_synth;\n\n \/* Try to restart request in case of failure *\/\n # Note that max_restarts defaults to 4\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if (resp.status == 503 && req.restarts < 4) {\n return(restart);\n }\n\n \/* Set common headers for synthetic responses *\/\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n\n \/* HTTP Authentification client request *\/\n # Empty in simple configs. SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* Load synthetic responses from disk *\/\n # Note that files loaded this way are never re-readed (even after a reload).\n # You should consider PROS\/CONS of doing an include instead.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_std.generated.html#func-fileread\n # Example custom 403 error page.\n # if (resp.status == 403) {\n # synthetic(std.fileread(\"\/403.html\"));\n # return(deliver);\n # }\n\n \/* Error page & refresh \/ redirections *\/\n # We have plenty of choices when we have to serve an error to the client, \n # from the default error page to javascript black magic or plain redirections.\n # Adding some external statistic javascript to track failures served to clients is strongly suggested.\n # We can't use external resources on synthetic content, everything must be inlined.\n # If we need to include images we can embed them in base64 encoding.\n # Here is the default error page for Varnish 4 (not so pretty)\n # We're using error 200 for monitoring puposes which should not be retried client side *\/\n if ( resp.status != 200) {\n set resp.http.Retry-After = \"5\";\n }\n\n # Consider add some analytics stuff to trace accesses\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning inconditionally.\n return (deliver);\n}\n\n#######################################################################\n# Backend Fetch\n\n# vcl_backend_fetch: Called before sending the backend request. In this subroutine you typically alter the request before it gets to the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-fetch\n# sub vcl_backend_fetch {\n# return (fetch);\n# }\n\n# vcl_backend_response: Called after the response headers has been successfully retrieved from the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-response\nsub vcl_backend_response {\n \/* Caching exceptions *\/\n # Varnish will cache objects with response codes: 200, 203, 300, 301, 302, 307, 404 & 410.\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/VCL_Basics.html#the-initial-value-of-beresp-ttl\n # Drupal's Imagecache module can return a 307 redirection to the requested url itself and, depending on Drupal's cache settings,\n # this could lead to a redirection loop being cached for a long time but also we want Varnish to shield a little the backend.\n # See http:\/\/drupal.org\/node\/1248010\n # See http:\/\/drupal.org\/node\/310656\n if (beresp.status == 307 &&\n #TODO# verify that this work better than 'bereq.url ~ \"imagecache\"' *\/\n beresp.http.Location == bereq.url &&\n beresp.ttl > 5s) {\n set beresp.ttl = 5s;\n set beresp.http.cache-control = \"max-age=5\";\n }\n\n \/* Request retrial *\/\n if ( beresp.status == 500\n || beresp.status == 503\n ) {\n #TODO# consider not restarting POST requests as seenV3 on https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleSaintMode\n return (retry);\n }\n\n \/* Enable grace mode. Related with vcl_hit *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n set beresp.grace = 1h;\n\n \/* Strip cookies from the following static file types for all users. Related with our 12th stage on vcl_recv *\/\n if (bereq.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|woff2|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\") {\n unset beresp.http.set-cookie;\n }\n\n \/* Gzip response *\/\n # Empty in simple configs\n # Use Varnish to Gzip respone, if suitable, before storing it on cache\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html\n if ( ! beresp.http.Content-Encoding\n && ( beresp.http.content-type ~ \"text\"\n || beresp.http.content-type ~ \"application\/x-javascript\"\n || beresp.http.content-type ~ \"application\/javascript\"\n || beresp.http.content-type ~ \"application\/rss+xml\"\n || beresp.http.content-type ~ \"application\/xml\"\n || beresp.http.content-type ~ \"Application\/JSON\")\n ) {\n set beresp.do_gzip = true;\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # We can add the name of the backend that has processed the request:\n # set beresp.http.X-Backend = beresp.backend.name;\n # We can use a header to tell if the object was gziped by Varnish\n # if (beresp.do_gzip) {\n # set beresp.http.X-Varnish-Gzipped = \"yes\";\n # } else {\n # set beresp.http.X-Varnish-Gizipped = \"no\";\n # }\n # We can also add headers informing whether the object is cacheable or not and why.\n # https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Varnish3.0\n if (beresp.ttl <= 0s) {\n \/* Varnish determined the object was not cacheable *\/\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n } elsif (bereq.http.Cookie ~ \"(SESS|SSESS|NO_CACHE|OATMEAL|CHOCOLATECHIP)\") {\n \/* We don't wish to cache content for logged in users or with certain cookies. Related with our 9th stage on vcl_recv *\/\n set beresp.http.X-Cacheable = \"NO:Cookies\";\n # return(hit_for_pass);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n \/* We are respecting the Cache-Control=private header from the backend *\/\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n # return(hit_for_pass);\n } else {\n \/* Varnish determined the object was cacheable *\/\n set beresp.http.X-Cacheable = \"YES\";\n }\n\n \/* Further header manipulation *\/\n # Empty in simple configs.\n # We can also unset some headers to prevent information disclosure and save some cache space\n # unset beresp.http.Server;\n # unset beresp.http.X-Powered-By;\n # Retry count\n if ( bereq.retries > 0) {\n set beresp.http.X-Retries = bereq.retries;\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_backend_response {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Surrogate-control ~ \"no-store\" ||\n# (!beresp.http.Surrogate-Control &&\n# beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n# beresp.http.Vary == \"*\") {\n# \/*\n# * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# *\/\n# set beresp.ttl = 120s;\n# set beresp.uncacheable = true;\n# }\n# return (deliver);\n# }\n\n# vcl_backend_error: This subroutine is called if we fail the backend fetch.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-error\nsub vcl_backend_error {\n\n \/* Try to restart request in case of failure *\/\n #TODO# Confirm max_retries default value\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if (bereq.retries < 4) {\n return (retry);\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # Retry count\n if ( bereq.retries > 0) {\n set beresp.http.X-Retries = bereq.retries;\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + beresp.status + \" \" + beresp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + beresp.status + \" \" + beresp.reason + {\"<\/h1>\n <p>\"} + beresp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + bereq.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this point.\n return (deliver);\n}\n\n#######################################################################\n# Housekeeping\n\n# vcl_init: Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-init\n# Here is where you should declare your directors now.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-backends.html#directors\n# Empty in simple configs\n# sub vcl_init {\n# return (ok);\n# }\n\n# vcl_fini: Called when VCL is discarded only after all requests have exited the VCL. Typically used to clean up VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-fini\n# sub vcl_fini {\n# return (ok);\n# }\n\n","old_contents":"\/* Varnish 4 example config for Drupal 7 \/ Pressflow 6 & 7 *\/\n# Original source: https:\/\/github.com\/NITEMAN\/varnish-bites\/varnish4\/drupal-base.vcl\n# Copyright (c) 2015 Pedro Gonz\u00e1lez Serrano and individual contributors.\n# MIT License\n\n# Intended to be used both in simple production environments and with\n# learning\/teaching purposes.\n# Some references may not be yet updated to VCL 4.0, we use SeeV3 then.\n\n# WARNING:\n# Note that the built-in logic will be appended to our code if no return is performed before.\n# Built-in logic is included commented out right after our's for reference purposes in that cases.\n# See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleDefault\n\n#######################################################################\n# Initialization: Version & imports;\n\n\/* Version statement *\/\n# Since Varnish 4.0 it's mandatory to declare VCL version on first line.\nvcl 4.0;\n\n\/* Module (VMOD) imports *\/\n# Standard module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_std.generated.html\nimport std;\n\n# Directors module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# Unused in simple configs.\n#import directors;\n\n\n#######################################################################\n# Probe, backend, ACL and subroutine definitions\n\n\/* Backend probes \/ healthchecks *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#probes\nprobe basic {\n \/* Only test that backend's IP serves content for '\/' *\/\n # This might be a too heavy probe\n # .url = \"\/\";\n \/* Only test that backend's IP has apache working *\/\n # Nginx would fail this probe with a default config\n .request =\n \"OPTIONS * HTTP\/1.1\"\n \"Host: *\"\n \"Connection: close\";\n .interval = 10s;\n .timeout = 2s;\n .window = 8;\n .threshold = 6;\n}\n\n\/* Backend definitions.*\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#backend-definition\nbackend default {\n \/* Default backend on the same machine. WARNING: timeouts could be not big enought for certain POST request *\/\n .host = \"127.0.0.1\";\n .port = \"8008\";\n .connect_timeout = 60s;\n .first_byte_timeout = 60s;\n .between_bytes_timeout = 60s;\n .probe = basic;\n}\n\n\/* Access Control Lists *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#access-control-list-acl\nacl purge_ban {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use '\"localhost\";' instead\n}\nacl allowed_monitors {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n}\n#acl own_proxys {\n# \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n#}\n\n\/* Custom subroutines *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#subroutines\n#TODO# Test in Varnihs 4\n# Empty in simple configs.\n# We can name subs with no restrictions but as a task can need several chunks of code in diferent states,\n# it's a good idea to identify what main sub will call each with a suffix.\n# \/* Example 301 client redirection removing \"www\" prefix from request *\/\n# sub perm_redirections_recv {\n# if ( req.http.host ~ \"^www.*$\" ) {\n# return(synth(751, \"http:\/\/\" + regsub(req.http.host, \"^www\\.\", \"\") + req.url));\n# }\n# }\n# sub perm_redirections_synth {\n# if (resp.status == 751) {\n# \/* Get new URL from the response *\/\n# set resp.http.Location = resp.response;\n# \/* Set HTTP 301 for permanent redirect *\/\n# set resp.status = 301;\n# return (deliver);\n# }\n# }\n\n\n#######################################################################\n# Client side\n\n# vcl_recv: Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-recv\nsub vcl_recv {\n \/* 0th: general bypass, general return & authorization checks *\/\n # Empty in simple configs.\n # Useful for debugging we can pipe or pass the request to default backend here to bypass completely Varnish.\n # return (pipe);\n # return (pass);\n # We can also return here a 200 Ok for network performance benchmarking.\n # return(synth(200, \"Ok\"));\n # Finally we can perform basic HTTP authentification here, by example.\n # SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* 1st: Check for Varnish special requests *\/ \n # Custom response implementation example in order to check that Varnish is working properly.\n # This is usefull for automatic monitoring with monit or when Varnish is behind another proxies like HAProxy.\n if ( ( req.http.host == \"monitor.server.health\"\n || req.http.host == \"health.varnish\" )\n && client.ip ~ allowed_monitors\n && ( req.method == \"OPTIONS\" || req.method == \"GET\" )\n ) {\n return(synth(200, \"Ban added\"));\n }\n # Purge logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#http-purging\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if (req.method == \"PURGE\") {\n if (!client.ip ~ purge_ban) {\n return(synth(405, \"Not allowed.\"));\n }\n return (purge);\n }\n # Ban logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#bans\n if (req.method == \"BAN\") {\n if (!client.ip ~ purge_ban) {\n return(synth(405, \"Not allowed.\"));\n }\n ban(\"req.http.host == \" + req.http.host +\n \"&& req.url == \" + req.url); \n return(synth(200, \"Ban added\"));\n }\n\n \/* 2nd: Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_recv;\n # Here we can also enforce SSL when Varnish run behind some SSL termination point.\n\n \/* 3rd: Time for backend choice *\/\n # Empty in simple configs.\n\n \/* 4th: Prepare headers for the backend *\/\n # Empty in simple configs.\n # Example remove own_proxys from X-Forwarded-For\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/whats-new\/upgrading.html#x-forwarded-for-is-now-set-before-vcl-recv\n # if ( req.restarts == 0\n # && client.ip ~ own_proxys\n # && req.http.x-forwarded-for\n # ) {\n # set req.http.X-Forwarded-For = regsub(req.http.X-Forwarded-For, \",( )?\" + client.ip, \"\");\n # }\n\n \/* 5th: Bypass breakpoint 1 *\/\n # Useful for debugging we can now pipe or pass the request to backend with headers setted.\n # return (pipe);\n # return (pass);\n\n \/* 6th: Decide if we should deal with a request (mostly copied from built-in logic) *\/\n if (req.method == \"PRI\") {\n \/* We do not support SPDY or HTTP\/2.0 *\/\n return (synth(405));\n }\n if ( req.method != \"GET\"\n && req.method != \"HEAD\"\n && req.method != \"PUT\"\n && req.method != \"POST\"\n && req.method != \"TRACE\"\n && req.method != \"OPTIONS\"\n && req.method != \"DELETE\"\n ) {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n\n \/* 7th: Access control for some URLs by ACL *\/\n # Empty in simple configs.\n # By example denial some URLs depending on client-ip, we'll need to define corresponding ACL 'internal'.\n # if ( req.url ~ \"^\/(cron|install)\\.php\"\n # && ! client.ip ~ internal\n # ) {\n # # Have Varnish throw the error directly.\n # return(synth(403, \"Forbidden.\"));\n # # Use a custom error page that you've defined in Drupal at the path \"404\".\n # # set req.url = \"\/403\";\n # }\n\n \/* 8th: Custom exceptions *\/\n # Host exception example:\n # if (req.http.host == \"ejemplo.exception.com\") {\n # return (pass);\n # }\n # Drupal exceptions, edit if we want to cache some AJAX\/AHAH request.\n # Add here filters for never cache URLs such as Payment Gateway's callbacks\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/ooyala\/ping$\" ||\n req.url ~ \"^\/admin\/build\/features\" ||\n req.url ~ \"^\/info\/.*$\" ||\n req.url ~ \"^\/flag\/.*$\" ||\n req.url ~ \"^.*\/ajax\/.*$\" ||\n req.url ~ \"^.*\/ahah\/.*$\") {\n \/* Do not cache these paths *\/\n return (pass);\n }\n # Pipe these paths directly to backend for streaming.\n if (req.url ~ \"^\/admin\/content\/backup_migrate\/export\") {\n return (pipe);\n }\n if (req.url ~ \"^\/system\/files\") {\n return (pipe);\n }\n\n \/* 9th: Serve from anonymous cahe if all backends are down *\/\n if (! std.healthy(req.backend_hint) ) {\n #TODO# Consider moving this to vcl_backend_fetch\n unset req.http.Cookie;\n #TODO# Add sick marker\n } \n\n \/* 10th: Deal with compression and the Accept-Encoding header *\/\n # Althought Varnish 3 handles gziped content itself by default, just to be sure we want to \n # remove Accept-Encoding for some compressed formats.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html#what-does-http-gzip-support-do\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/varnishd.html?highlight=http_gzip_support\n # See (for older configs) https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleNormalizeAcceptEncoding\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|mp4|flv|zip|rar)$\") {\n \/* Already compressed formats, no sense trying to compress again *\/\n unset req.http.Accept-Encoding;\n }\n }\n\n \/* 11th: Another header manipulation *\/\n # Empty in simple configs.\n # We could add here a custom header grouping User-agent families.\n\n \/* 12th: Cookie removal *\/\n # Always cache the following static file types for all users. \n # Use with care if we control certain downloads depending on cookies. \n # Be carefull also if appending .htm[l] via Drupal's clean URLs.\n if ( req.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|woff2|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n && req.url !~ \"\/system\/storage\/serve\"\n ) {\n unset req.http.Cookie;\n }\n # Remove all cookies that backend doesn't need to know about.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRemovingSomeCookies\n if (req.http.Cookie) {\n \/* Warning: Not a pretty solution *\/\n \/* Prefix header containing cookies with ';' *\/\n set req.http.Cookie = \";\" + req.http.Cookie;\n \/* Remove any spaces after ';' in header containing cookies *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n \/* Prefix cookies we want to preserve with one space *\/\n \/* 'S{1,2}ESS[a-z0-9]+' is the regular expression matching a Drupal session cookie ({1,2} added for HTTPS support) *\/\n \/* 'NO_CACHE' is usually set after a POST request to make sure issuing user see the results of his post *\/\n \/* 'OATMEAL' & 'CHOCOLATECHIP' are special cookies used by Drupal's Bakery module to provide Single Sign On *\/\n \/* Keep in mind we should add here any cookie that should reach the backend such as splahs avoiding cookies *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \";(S{1,2}ESS[a-z0-9]+|NO_CACHE|OATMEAL|CHOCOLATECHIP)=\", \"; \\1=\");\n \/* Remove from the header any single Cookie not prefixed with a space until next ';' separator *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n \/* Remove any '; ' at the start or the end of the header *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n\n if (req.http.Cookie == \"\") {\n \/* If there are no remaining cookies, remove the cookie header. *\/\n unset req.http.Cookie;\n }\n }\n\n \/* 13th: Session cookie & special cookies bypass caching stage *\/\n # As we might want to cache some requests, hashed with its cookies, \n # we don't simply pass when some cookies remain present at this point.\n # Instead we look for request that must be passed due to the cookie header.\n if ( req.http.Cookie ~ \"SESS\"\n || req.http.Cookie ~ \"SSESS\"\n || req.http.Cookie ~ \"NO_CACHE\"\n || req.http.Cookie ~ \"OATMEAL\"\n || req.http.Cookie ~ \"CHOCOLATECHIP\"\n ) {\n return (pass);\n }\n\n \/* 14th: Bypass breakpoint 2 *\/\n # Useful for debugging we can now pipe or pass the request to backend to bypass cache.\n # return (pipe);\n # return (pass);\n\n \/* 15th: Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning inconditionally.\n return (hash);\n}\n\n# vcl_pipe: Called upon entering pipe mode.\n# In this mode, the request is passed on to the backend, \n# and any further data from either client or backend is passed on unaltered until either end closes the connection.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pipe\n# sub vcl_pipe {\n# # By default Connection: close is set on all piped requests, to stop\n# # connection reuse from sending future requests directly to the\n# # (potentially) wrong backend. If you do want this to happen, you can undo\n# # it here.\n# # unset bereq.http.connection;\n# return (pipe);\n# }\n\n# vcl_pass: Called upon entering pass mode. \n# In this mode, the request is passed on to the backend, and the backend's response is passed on to the client, \n# but is not entered into the cache.\n# Subsequent requests submitted over the same client connection are handled normally.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pass\n# sub vcl_pass {\n# return (fetch);\n# }\n\n# vcl_hash: You may call hash_data() on the data you would like to add to the hash.\n# Hash is used by Varnish to uniquely identify objects.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hash\nsub vcl_hash {\n \/* Hash cookie data *\/\n # As requests with same URL and host can produce diferent results when issued with different cookies,\n # we need to store items hashed with the associated cookies. Note that cookies are already sanitized when we reach this point.\n if (req.http.Cookie) {\n \/* Include cookie in cache hash *\/\n hash_data(req.http.Cookie);\n }\n\n \/* Custom header hashing *\/\n # Empty in simple configs.\n # Example for caching differents object versions by device previously detected (when static content could also vary):\n # if (req.http.X-UA-Device) {\n # hash_data(req.http.X-UA-Device);\n # }\n # Example for caching diferent object versions by X-Forwarded-Proto, trying to be smart about what kind of request\n # could generate diffetent responses.\n if ( req.http.X-Forwarded-Proto\n && req.url !~ \"(?i)\\.(png|gif|jpeg|jpg|ico|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|woff2|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\") {\n hash_data(req.http.X-Forwarded-Proto);\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (lookup);\n# }\n\n# vcl_purge: Called after the purge has been executed and all its variants have been evited.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-purge\n# sub vcl_purge {\n# return (synth(200, \"Purged\"));\n# }\n\n# vcl_hit: Called after a cache lookup if the requested document was found in the cache.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hit\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n \/\/ A pure unadultered hit, deliver it\n return (deliver);\n }\n \/* Allow varnish to serve up stale content if it is responding slowly *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n if (obj.ttl + 60s > 0s) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n return (deliver);\n }\n \/* Allow varish to serve up stale content if all backends are down *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n if ( ! std.healthy(req.backend_hint)\n && obj.ttl + obj.grace > 0s\n ) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n return (deliver);\n }\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning inconditionally.\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\n# vcl_miss: Called after a cache lookup if the requested document was not found in the cache.\n# Its purpose is to decide whether or not to attempt to retrieve the document from the backend, and which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-miss\n# sub vcl_miss {\n# return (fetch);\n# }\n\n# vcl_deliver: Called before an object is delivered to the client\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-deliver\nsub vcl_deliver {\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # Add whether the object is a cache hit or miss and the number of hits for the object.\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Addingaheaderindicatinghitmiss\n # In Varnish 4 the obj.hits counter behaviour has changed (see bug 1492), so\n # we use a different method: if X-Varnish contains only 1 id, we have a miss,\n # if it contains more (and therefore a space), we have a hit.\n if (resp.http.x-varnish ~ \" \") {\n set resp.http.X-Cache = \"HIT\";\n # Since in Varnish 4 the behaviour of obj.hits changed, this might not be accurate\n # See https:\/\/www.varnish-cache.org\/trac\/ticket\/1492\n set resp.http.X-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Cache = \"MISS\";\n \/* Show the results of cookie sanitization *\/\n set resp.http.X-Cookie = req.http.Cookie;\n }\n\n #TODO# Add sick marker\n\n # Restart count\n if ( req.restarts > 0) {\n set resp.http.X-Restarts = req.restarts;\n }\n\n # Add the Varnish server hostname\n set resp.http.X-Varnish-Server = server.hostname;\n # If we have setted a custom header with device family detected we can show it:\n # if (req.http.X-UA-Device) {\n # set resp.http.X-UA-Device = req.http.X-UA-Device;\n # }\n # If we have recived a custom header with the protocol in the request we can show it:\n # if (req.http.X-Forwarded-Proto) {\n # set resp.http.X-Forwarded-Proto = req.http.X-Forwarded-Proto;\n # }\n\n \/* Vary header manipulation *\/\n # Empty in simple configs.\n # By example, if we are storing & serving diferent objects depending on User-Agent header we must set the correct Vary header:\n # if (resp.http.Vary) {\n # set resp.http.Vary = resp.http.Vary + \",User-Agent\";\n # } else {\n # set resp.http.Vary = \"User-Agent\";\n # }\n\n \/* Fake headers *\/\n # Empty in simple configs\n # We can fake server headers here, by example:\n # set resp.http.Server = \"Deep thought\";\n # set resp.http.X-Powered-By = \"BOFH\";\n # Or have some fun with headers:\n # See http:\/\/www.nextthing.org\/archives\/2005\/08\/07\/fun-with-http-headers\n # See http:\/\/royal.pingdom.com\/2012\/08\/15\/fun-and-unusual-http-response-headers\/\n # set resp.http.X-Thank-You = \"for bothering to look at my HTTP headers\";\n # set resp.http.X-Answer = \"42\";\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_deliver {\n# return (deliver);\n# }\n\n# vcl_synth: Called to deliver a synthetic object. A synthetic object is generated in VCL,\n# not fetched from the backend. It is typically contructed using the synthetic() function.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-synth\n\/*\n * We can come here \"invisibly\" with the following errors: 413, 417 & 503\n *\/\nsub vcl_synth {\n \/* Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_synth;\n\n \/* Try to restart request in case of failure *\/\n # Note that max_restarts defaults to 4\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if (resp.status == 503 && req.restarts < 4) {\n return(restart);\n }\n\n \/* Set common headers for synthetic responses *\/\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n\n \/* HTTP Authentification client request *\/\n # Empty in simple configs. SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* Load synthetic responses from disk *\/\n #TODO# Ensure that this is only done at boot time and we don't hit disk in-flight\n # Example custom 403 error page.\n # if (resp.status == 403) {\n # synthetic(std.fileread(\"\/403.html\"));\n # return(deliver);\n # }\n\n \/* Error page & refresh \/ redirections *\/\n # We have plenty of choices when we have to serve an error to the client, \n # from the default error page to javascript black magic or plain redirections.\n # Adding some external statistic javascript to track failures served to clients is strongly suggested.\n # We can't use external resources on synthetic content, everything must be inlined.\n # If we need to include images we can embed them in base64 encoding.\n # Here is the default error page for Varnish 4 (not so pretty)\n # We're using error 200 for monitoring puposes which should not be retried client side *\/\n if ( resp.status != 200) {\n set resp.http.Retry-After = \"5\";\n }\n\n # Consider add some analytics stuff to trace accesses\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning inconditionally.\n return (deliver);\n}\n\n#######################################################################\n# Backend Fetch\n\n# vcl_backend_fetch: Called before sending the backend request. In this subroutine you typically alter the request before it gets to the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-fetch\n# sub vcl_backend_fetch {\n# return (fetch);\n# }\n\n# vcl_backend_response: Called after the response headers has been successfully retrieved from the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-response\nsub vcl_backend_response {\n \/* Caching exceptions *\/\n # Varnish will cache objects with response codes: 200, 203, 300, 301, 302, 307, 404 & 410.\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/VCL_Basics.html#the-initial-value-of-beresp-ttl\n # Drupal's Imagecache module can return a 307 redirection to the requested url itself and, depending on Drupal's cache settings,\n # this could lead to a redirection loop being cached for a long time but also we want Varnish to shield a little the backend.\n # See http:\/\/drupal.org\/node\/1248010\n # See http:\/\/drupal.org\/node\/310656\n if (beresp.status == 307 &&\n #TODO# verify that this work better than 'bereq.url ~ \"imagecache\"' *\/\n beresp.http.Location == bereq.url &&\n beresp.ttl > 5s) {\n set beresp.ttl = 5s;\n set beresp.http.cache-control = \"max-age=5\";\n }\n\n \/* Request retrial *\/\n if ( beresp.status == 500\n || beresp.status == 503\n ) {\n #TODO# consider not restarting POST requests as seenV3 on https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleSaintMode\n return (retry);\n }\n\n \/* Enable grace mode. Related with vcl_hit *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n set beresp.grace = 1h;\n\n \/* Strip cookies from the following static file types for all users. Related with our 12th stage on vcl_recv *\/\n if (bereq.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|woff2|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\") {\n unset beresp.http.set-cookie;\n }\n\n \/* Gzip response *\/\n # Empty in simple configs\n # Use Varnish to Gzip respone, if suitable, before storing it on cache\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html\n if ( ! beresp.http.Content-Encoding\n && ( beresp.http.content-type ~ \"text\"\n || beresp.http.content-type ~ \"application\/x-javascript\"\n || beresp.http.content-type ~ \"application\/javascript\"\n || beresp.http.content-type ~ \"application\/rss+xml\"\n || beresp.http.content-type ~ \"application\/xml\"\n || beresp.http.content-type ~ \"Application\/JSON\")\n ) {\n set beresp.do_gzip = true;\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # We can add the name of the backend that has processed the request:\n # set beresp.http.X-Backend = beresp.backend.name;\n # We can use a header to tell if the object was gziped by Varnish\n # if (beresp.do_gzip) {\n # set beresp.http.X-Varnish-Gzipped = \"yes\";\n # } else {\n # set beresp.http.X-Varnish-Gizipped = \"no\";\n # }\n # We can also add headers informing whether the object is cacheable or not and why.\n # https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Varnish3.0\n if (beresp.ttl <= 0s) {\n \/* Varnish determined the object was not cacheable *\/\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n } elsif (bereq.http.Cookie ~ \"(SESS|SSESS|NO_CACHE|OATMEAL|CHOCOLATECHIP)\") {\n \/* We don't wish to cache content for logged in users or with certain cookies. Related with our 9th stage on vcl_recv *\/\n set beresp.http.X-Cacheable = \"NO:Cookies\";\n # return(hit_for_pass);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n \/* We are respecting the Cache-Control=private header from the backend *\/\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n # return(hit_for_pass);\n } else {\n \/* Varnish determined the object was cacheable *\/\n set beresp.http.X-Cacheable = \"YES\";\n }\n\n \/* Further header manipulation *\/\n # Empty in simple configs.\n # We can also unset some headers to prevent information disclosure and save some cache space\n # unset beresp.http.Server;\n # unset beresp.http.X-Powered-By;\n # Retry count\n if ( bereq.retries > 0) {\n set beresp.http.X-Retries = bereq.retries;\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_backend_response {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Surrogate-control ~ \"no-store\" ||\n# (!beresp.http.Surrogate-Control &&\n# beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n# beresp.http.Vary == \"*\") {\n# \/*\n# * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# *\/\n# set beresp.ttl = 120s;\n# set beresp.uncacheable = true;\n# }\n# return (deliver);\n# }\n\n# vcl_backend_error: This subroutine is called if we fail the backend fetch.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-error\nsub vcl_backend_error {\n\n \/* Try to restart request in case of failure *\/\n #TODO# Confirm max_retries default value\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if (bereq.retries < 4) {\n return (retry);\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # Retry count\n if ( bereq.retries > 0) {\n set beresp.http.X-Retries = bereq.retries;\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + beresp.status + \" \" + beresp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + beresp.status + \" \" + beresp.reason + {\"<\/h1>\n <p>\"} + beresp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + bereq.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this point.\n return (deliver);\n}\n\n#######################################################################\n# Housekeeping\n\n# vcl_init: Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-init\n# Here is where you should declare your directors now.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-backends.html#directors\n# Empty in simple configs\n# sub vcl_init {\n# return (ok);\n# }\n\n# vcl_fini: Called when VCL is discarded only after all requests have exited the VCL. Typically used to clean up VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-fini\n# sub vcl_fini {\n# return (ok);\n# }\n\n","returncode":0,"stderr":"","license":"unknown","lang":"VCL"} {"commit":"360317502f90b9713c3d4972666cde27dc140496","subject":"varnish grace debug header naming consistency","message":"varnish grace debug header naming consistency\n","repos":"NITEMAN\/varnish-bites,NITEMAN\/Varnish_VCL_samps-hacks","old_file":"varnish4\/drupal-base.vcl","new_file":"varnish4\/drupal-base.vcl","new_contents":"\/*\n * Varnish 4 example config for Drupal 7 & 8 \/ Pressflow 6 & 7\n *\/\n\n# Original source: https:\/\/github.com\/NITEMAN\/varnish-bites\/varnish4\/drupal-base.vcl\n# Copyright (c) 2015 Pedro Gonz\u00e1lez Serrano and individual contributors.\n# MIT License\n\n# Intended to be used both in simple production environments and with\n# learning\/teaching purposes.\n# Some references may not be yet updated to VCL 4.0, we use SeeV3 then.\n\n# WARNING:\n# Note that the built-in logic will be appended to our code if no return is\n# performed before.\n# Built-in logic is included commented out right after our's for reference\n# purposes in that cases.\n# See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleDefault\n\n#######################################################################\n# Initialization: Version & imports;\n\n\/* Version statement *\/\n# Since Varnish 4.0 it's mandatory to declare VCL version on first line.\nvcl 4.0;\n\n\/* Module (VMOD) imports *\/\n# Standard module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_std.generated.html\nimport std;\n\n# Directors module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# Unused in simple configs.\n#import directors;\n\n\n#######################################################################\n# Probe, backend, ACL and subroutine definitions\n\n\/* Backend probes \/ healthchecks *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#probes\nprobe basic {\n \/* Only test that backend's IP serves content for '\/' *\/\n # This might be a too heavy probe\n # .url = \"\/\";\n\n \/* Only test that backend's IP has apache working *\/\n # Nginx would fail this probe with a default config\n .request =\n \"OPTIONS * HTTP\/1.1\"\n \"Host: *\"\n \"Connection: close\";\n\n \/* Common options *\/\n .interval = 10s;\n .timeout = 2s;\n .window = 8;\n .threshold = 6;\n}\n\n\/* Backend definitions.*\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#backend-definition\nbackend default {\n \/* Default backend on the same machine. *\/\n # WARNING: timeouts could be not big enought for certain POST requests.\n .host = \"127.0.0.1\";\n .port = \"8008\";\n .max_connections = 100;\n .connect_timeout = 60s;\n .first_byte_timeout = 60s;\n .between_bytes_timeout = 60s;\n .probe = basic;\n}\n\n\/* Access Control Lists *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#access-control-list-acl\nacl purge_ban {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use '\"localhost\";' instead\n}\nacl allowed_monitors {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n}\n# acl own_proxys {\n# \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n# }\n\n\/* Custom subroutines *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#subroutines\n#TODO# Test in Varnihs 4\n# Empty in simple configs.\n# The only restriction naming subs is that the 'vlc_' prefix is reserverd for\n# Varnish use. As a task can need several chunks of code in diferent states,\n# it's a good idea to identify what main sub will call each with a suffix.\n# \/* Example 301 client redirection removing \"www\" prefix from request *\/\n# sub perm_redirections_recv {\n# if ( req.http.host ~ \"^www.*$\" ) {\n# return (\n# synth(751, \"http:\/\/\" + regsub(req.http.host, \"^www\\.\", \"\") + req.url)\n# );\n# }\n# }\n# sub perm_redirections_synth {\n# if ( resp.status == 751 ) {\n# \/* Get new URL from the response *\/\n# set resp.http.Location = resp.reason;\n# \/* Set HTTP 301 for permanent redirect *\/\n# set resp.status = 301;\n# set resp.reason = \"Moved Permanently\";\n# return (deliver);\n# }\n# }\n\n\n#######################################################################\n# Client side\n\n# vcl_recv: Called at the beginning of a request, after the complete request\n# has been received and parsed. Its purpose is to decide whether or not to\n# serve the request, how to do it, and, if applicable, which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-recv\nsub vcl_recv {\n \/* 0th: general bypass, general return & authorization checks *\/\n # Empty in simple configs.\n # Useful for debugging we can pipe or pass the request to default backend\n # here to bypass completely Varnish.\n # return (pipe);\n # return (pass);\n # We can also return here a 200 Ok for network performance benchmarking.\n # return (synth(200, \"Ok\"));\n # Finally we can perform basic HTTP authentification here, by example.\n # SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* 1st: Check for Varnish special requests *\/\n # Custom response implementation example in order to check that Varnish is\n # working properly.\n # This is usefull for automatic monitoring with monit or when Varnish is\n # behind another proxies like HAProxy.\n if ( ( req.http.host == \"monitor.server.health\"\n || req.http.host == \"health.varnish\" )\n && client.ip ~ allowed_monitors\n && ( req.method == \"OPTIONS\" || req.method == \"GET\" )\n ) {\n return (synth(200, \"OK\"));\n }\n # Purge logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#http-purging\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if ( req.method == \"PURGE\" ) {\n if ( client.ip !~ purge_ban ) {\n return (synth(405, \"Not allowed.\"));\n }\n return (purge);\n }\n # Ban logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#bans\n if ( req.method == \"BAN\" ) {\n if ( client.ip !~ purge_ban ) {\n return (synth(405, \"Not allowed.\"));\n }\n if (req.http.Purge-Cache-Tags) {\n ban( \"obj.http.X-Host == \" + req.http.host +\n \" && obj.http.Purge-Cache-Tags ~ \" + req.http.Purge-Cache-Tags\n );\n }\n else {\n # Assumes req.url is a regex. This might be a bit too simple\n ban( \"obj.http.X-Host == \" + req.http.host +\n \" && obj.http.X-Url ~ \" + req.url\n );\n }\n return (synth(200, \"Ban added\"));\n }\n\n \/* 2nd: Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_recv;\n # Here we can also enforce SSL when Varnish run behind some SSL termination\n # point.\n\n \/* 3rd: Time for backend choice *\/\n # Empty in simple configs.\n\n \/* 4th: Prepare request for the backend *\/\n # Empty in simple configs.\n # Example remove own_proxys from X-Forwarded-For\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/whats-new\/upgrading.html#x-forwarded-for-is-now-set-before-vcl-recv\n # Varnish 4 regsub doesn't accept anything but plain regexp, so we can't use\n # client.ip to exclude the proxy ips from the request:\n # set req.http.X-Forwarded-For\n # = regsub(req.http.X-Forwarded-For, \",( )?\" + client.ip, \"\");\n # Instead, we need to add the proxy ips manually in the exclude list:\n # if ( req.restarts == 0\n # && client.ip ~ own_proxys\n # && req.http.X-Forwarded-For\n # ) {\n # set req.http.X-Forwarded-For\n # = regsub(req.http.X-Forwarded-For,\n # \"(, )?(10\\.10\\.10\\.10|10\\.11\\.11\\.11)\", \"\");\n # }\n # An alternative could be to skip all this and try to modify the header\n # manually so Varnish doesn't touch it.\n # set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \"\";\n #\n # Example normalize the host header, remove the port (in case you're testing\n # this on various TCP ports)\n # set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n \/* 5th: Bypass breakpoint 1 *\/\n # Useful for debugging we can now pipe or pass the request to backend with\n # headers setted.\n # return (pipe);\n # return (pass);\n\n \/* 6th: Decide if we should deal with a request (mostly from built-in logic) *\/\n if ( req.method == \"PRI\" ) {\n \/* We do not support SPDY or HTTP\/2.0 *\/\n return (synth(405));\n }\n if ( req.method != \"GET\"\n && req.method != \"HEAD\"\n && req.method != \"PUT\"\n && req.method != \"POST\"\n && req.method != \"TRACE\"\n && req.method != \"OPTIONS\"\n && req.method != \"DELETE\"\n ) {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if ( req.method != \"GET\"\n && req.method != \"HEAD\"\n ) {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if ( req.http.Authorization ) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n # Websocket support\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html\n if ( req.http.Upgrade ~ \"(?i)websocket\" ) {\n return (pipe);\n }\n\n \/* 7th: Access control for some URLs by ACL *\/\n # Empty in simple configs.\n # By example denial some URLs depending on client-ip, we'll need to define\n # corresponding ACL 'internal'.\n # if ( req.url ~ \"^\/(cron|install)\\.php\"\n # && client.ip !~ internal\n # ) {\n # # Have Varnish throw the error directly.\n # return (synth(403, \"Forbidden.\"));\n # # Use a custom error page that you've defined in Drupal at the path \"404\".\n # # set req.url = \"\/403\";\n # }\n\n \/* 8th: Custom exceptions *\/\n # Host exception example:\n # if ( req.http.host == \"ejemplo.exception.com\" ) {\n # return (pass);\n # }\n # Drupal exceptions, edit if we want to cache some AJAX\/AHAH request.\n # Add here filters for never cache URLs such as Payment Gateway's callbacks.\n if ( req.url ~ \"^\/status\\.php$\"\n || req.url ~ \"^\/update\\.php$\"\n || req.url ~ \"^\/ooyala\/ping$\"\n || req.url ~ \"^\/admin\/build\/features\"\n || req.url ~ \"^\/info\/.*$\"\n || req.url ~ \"^\/flag\/.*$\"\n || req.url ~ \"^.*\/ajax\/.*$\"\n || req.url ~ \"^.*\/ahah\/.*$\"\n ) {\n \/* Do not cache these paths *\/\n return (pass);\n }\n # Pipe these paths directly to backend for streaming.\n if ( req.url ~ \"^\/admin\/content\/backup_migrate\/export\"\n || req.url ~ \"^\/admin\/config\/system\/backup_migrate\"\n ) {\n return (pipe);\n }\n if ( req.url ~ \"^\/system\/files\" ) {\n return (pipe);\n }\n\n \/* 9th: Graced objets & Serve from anonymous cahe if all backends are down *\/\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n # set req.http.X-Varnish-Grace = \"none\";\n if ( ! std.healthy(req.backend_hint) ) {\n # We must do this here since cookie hashing\n unset req.http.Cookie;\n #TODO# Add sick marker\n }\n\n \/* 10th: Deal with compression and the Accept-Encoding header *\/\n # Althought Varnish 4 handles gziped content itself by default, just to be\n # sure we want to remove Accept-Encoding for some compressed formats.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html#what-does-http-gzip-support-do\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/varnishd.html?highlight=http_gzip_support\n # See (for older configs) https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleNormalizeAcceptEncoding\n if ( req.http.Accept-Encoding ) {\n if ( req.url ~ \"(?i)\\.(7z|avi|bz2|flv|gif|gz|jpe?g|mpe?g|mk[av]|mov|mp[34]|og[gm]|pdf|png|rar|swf|tar|tbz|tgz|woff2?|zip|xz)(\\?.*)?$\"\n ) {\n \/* Already compressed formats, no sense trying to compress again *\/\n unset req.http.Accept-Encoding;\n }\n }\n\n \/* 11th: Further request manipulation *\/\n # Empty in simple configs.\n # We could add here a custom header grouping User-agent families.\n # Generic URL manipulation.\n # Remove Google Analytics added parameters, useless for our backends.\n if ( req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=\" ) {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n # Strip anchors, server doesn't need it.\n if ( req.url ~ \"\\#\" ) {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n # Strip a trailing ? if it exists\n if ( req.url ~ \"\\?$\" ) {\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n # Normalize the querystring arguments\n set req.url = std.querysort(req.url);\n\n \/* 12th: Cookie removal *\/\n # Always cache the following static file types for all users.\n # Use with care if we control certain downloads depending on cookies.\n # Be carefull also if appending .htm[l] via Drupal's clean URLs.\n if ( req.url ~ \"(?i)\\.(bz2|css|eot|gif|gz|html?|ico|jpe?g|js|mp3|ogg|otf|pdf|png|rar|svg|swf|tbz|tgz|ttf|woff2?|zip)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n && req.url !~ \"\/system\/storage\/serve\"\n ) {\n unset req.http.Cookie;\n }\n # Remove all cookies that backend doesn't need to know about.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRemovingSomeCookies\n if ( req.http.Cookie ) {\n \/* Warning: Not a pretty solution *\/\n # Prefix header containing cookies with ';'\n set req.http.Cookie = \";\" + req.http.Cookie;\n # Remove any spaces after ';' in header containing cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n # Prefix cookies we want to preserve with one space:\n # 'S{1,2}ESS[a-z0-9]+' is the regular expression matching a Drupal session\n # cookie ({1,2} added for HTTPS support).\n # 'NO_CACHE' is usually set after a POST request to make sure issuing user\n # see the results of his post.\n # 'OATMEAL' & 'CHOCOLATECHIP' are special cookies used by Drupal's Bakery\n # module to provide Single Sign On.\n # Keep in mind we should add here any cookie that should reach the backend\n # such as splash avoiding cookies.\n set req.http.Cookie\n = regsuball(\n req.http.Cookie,\n \";(S{1,2}ESS[a-z0-9]+|NO_CACHE|OATMEAL|CHOCOLATECHIP)=\",\n \"; \\1=\"\n );\n # Remove from the header any single Cookie not prefixed with a space until\n # next ';' separator.\n set req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n # Remove any '; ' at the start or the end of the header.\n set req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n #If there are no remaining cookies, remove the cookie header.\n if ( req.http.Cookie == \"\" ) {\n unset req.http.Cookie;\n }\n }\n\n \/* 13th: Session cookie & special cookies bypass caching stage *\/\n # As we might want to cache some requests, hashed with its cookies, we don't\n # simply pass when some cookies remain present at this point.\n # Instead we look for request that must be passed due to the cookie header.\n if ( req.http.Cookie ~ \"SESS\"\n || req.http.Cookie ~ \"SSESS\"\n || req.http.Cookie ~ \"NO_CACHE\"\n || req.http.Cookie ~ \"OATMEAL\"\n || req.http.Cookie ~ \"CHOCOLATECHIP\"\n ) {\n return (pass);\n }\n\n \/* 14th: Announce ESI Support *\/\n # Empty in simple configs.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/esi.html\n # Note that ESI included requests inherits its parent's modified request, so\n # depending on the case you will end playing with req.esi_level to know\n # current depth.\n # Send Surrogate-Capability headers\n # See http:\/\/www.w3.org\/TR\/edge-arch\n # Note that myproxyname is an identifier that should avoid collitions\n # set req.http.Surrogate-Capability = \"myproxyname=ESI\/1.0\";\n\n \/* 15th: Bypass breakpoint 2 *\/\n # Useful for debugging we can now pipe or pass the request to backend to\n # bypass cache.\n # return (pipe);\n # return (pass);\n\n \/* 16th: Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n return (hash);\n}\n\n# vcl_pipe: Called upon entering pipe mode.\n# In this mode, the request is passed on to the backend, and any further data\n# from either client or backend is passed on unaltered until either end closes\n# the connection.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pipe\nsub vcl_pipe {\n # Websocket support\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html\n if ( req.http.upgrade ) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n}\n# sub vcl_pipe {\n# # By default Connection: close is set on all piped requests, to stop\n# # connection reuse from sending future requests directly to the\n# # (potentially) wrong backend. If you do want this to happen, you can undo\n# # it here.\n# # unset bereq.http.connection;\n# return (pipe);\n# }\n\n# vcl_pass: Called upon entering pass mode.\n# In this mode, the request is passed on to the backend, and the backend's\n# response is passed on to the client, but is not entered into the cache.\n# Subsequent requests submitted over the same client connection are handled normally.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pass\n# sub vcl_pass {\n# return (fetch);\n# }\n\n# vcl_hash: You may call hash_data() on the data you would like to add to the\n# hash.\n# Hash is used by Varnish to uniquely identify objects.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hash\nsub vcl_hash {\n \/* Hash cookie data *\/\n # As requests with same URL and host can produce diferent results when issued\n # with different cookies, we need to store items hashed with the associated\n # cookies. Note that cookies are already sanitized when we reach this point.\n if ( req.http.Cookie ) {\n \/* Include cookie in cache hash *\/\n hash_data(req.http.Cookie);\n }\n\n \/* Custom header hashing *\/\n # Empty in simple configs.\n # Example for caching differents object versions by device previously\n # detected (when static content could also vary):\n # if ( req.http.X-UA-Device ) {\n # hash_data(req.http.X-UA-Device);\n # }\n # Example for caching diferent object versions by X-Forwarded-Proto, trying\n # to be smart about what kind of request could generate diffetent responses.\n if ( req.http.X-Forwarded-Proto\n && req.url !~ \"(?i)\\.(bz2|css|eot|gif|gz|html?|ico|jpe?g|js|mp3|ogg|otf|pdf|png|rar|svg|swf|tbz|tgz|ttf|woff2?|zip)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n ) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (lookup);\n# }\n\n# vcl_purge: Called after the purge has been executed and all its variants have\n# been evited.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-purge\n# sub vcl_purge {\n# return (synth(200, \"Purged\"));\n# }\n\n# vcl_hit: Called after a cache lookup if the requested document was found in\n# the cache.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hit\nsub vcl_hit {\n if ( obj.ttl >= 0s ) {\n \/\/ A pure unadultered hit, deliver it\n return (deliver);\n }\n \/* Allow varnish to serve up stale content if it is responding slowly *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n if ( obj.ttl + 60s > 0s ) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n set req.http.X-Varnish-Grace = \"normal\";\n return (deliver);\n }\n \/* Allow varish to serve up stale content if all backends are down *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n if ( ! std.healthy(req.backend_hint)\n && obj.ttl + obj.grace > 0s\n ) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n set req.http.X-Varnish-Grace = \"extended\";\n return (deliver);\n }\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\n# vcl_miss: Called after a cache lookup if the requested document was not found\n# in the cache.\n# Its purpose is to decide whether or not to attempt to retrieve the document\n# from the backend, and which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-miss\n# sub vcl_miss {\n# return (fetch);\n# }\n\n# vcl_deliver: Called before an object is delivered to the client\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-deliver\nsub vcl_deliver {\n \/* Ban lurker friendly bans support *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#bans\n unset resp.http.X-Host;\n unset resp.http.X-Url;\n\n \/* Drupal 8 Purge's module header cleanup *\/\n # Purge's headers can become quite big, causing issues in upstream proxies, so we clean it here\n unset resp.http.Purge-Cache-Tags;\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # Add whether the object is a cache hit or miss and the number of hits for\n # the object.\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Addingaheaderindicatinghitmiss\n # In Varnish 4 the obj.hits counter behaviour has changed (see bug 1492), so\n # we use a different method: if X-Varnish contains only 1 id, we have a miss,\n # if it contains more (and therefore a space), we have a hit.\n if ( resp.http.X-Varnish ~ \" \" ) {\n set resp.http.X-Varnish-Cache = \"HIT\";\n # Since in Varnish 4 the behaviour of obj.hits changed, this might not be\n # accurate.\n # See https:\/\/www.varnish-cache.org\/trac\/ticket\/1492\n set resp.http.X-Varnish-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Varnish-Cache = \"MISS\";\n \/* Show the results of cookie sanitization *\/\n if ( req.http.Cookie ) {\n set resp.http.X-Varnish-Cookie = req.http.Cookie;\n }\n }\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n if ( req.http.X-Varnish-Grace ) {\n set resp.http.X-Varnish-Grace = req.http.X-Varnish-Grace;\n }\n\n #TODO# Add sick marker\n\n # Restart count\n if ( req.restarts > 0 ) {\n set resp.http.X-Varnish-Restarts = req.restarts;\n }\n\n # Add the Varnish server hostname\n set resp.http.X-Varnish-Server = server.hostname;\n # If we have setted a custom header with device's family detected we can show\n # it:\n # if ( req.http.X-UA-Device ) {\n # set resp.http.X-UA-Device = req.http.X-UA-Device;\n # }\n # If we have recived a custom header indicating the protocol in the request we\n # can show it:\n # if ( req.http.X-Forwarded-Proto ) {\n # set resp.http.X-Forwarded-Proto = req.http.X-Forwarded-Proto;\n # }\n\n \/* Vary header manipulation *\/\n # Empty in simple configs.\n # By example, if we are storing & serving diferent objects depending on\n # User-Agent header we must set the correct Vary header:\n # if ( resp.http.Vary ) {\n # set resp.http.Vary = resp.http.Vary + \",User-Agent\";\n # } else {\n # set resp.http.Vary = \"User-Agent\";\n # }\n\n \/* Fake headers *\/\n # Empty in simple configs\n # We can fake server headers here, by example:\n # set resp.http.Server = \"Deep thought\";\n # set resp.http.X-Powered-By = \"BOFH\";\n # Or have some fun with headers:\n # See http:\/\/www.nextthing.org\/archives\/2005\/08\/07\/fun-with-http-headers\n # See http:\/\/royal.pingdom.com\/2012\/08\/15\/fun-and-unusual-http-response-headers\/\n # set resp.http.X-Thank-You = \"for bothering to look at my HTTP headers\";\n # set resp.http.X-Answer = \"42\";\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_deliver {\n# return (deliver);\n# }\n\n# vcl_synth: Called to deliver a synthetic object. A synthetic object is\n# generated in VCL, not fetched from the backend. It is typically contructed\n# using the synthetic() function.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-synth\n\/*\n * We can come here \"invisibly\" with the following errors: 413, 417 & 503\n *\/\nsub vcl_synth {\n \/* Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_synth;\n\n \/* Try to restart request in case of failure *\/\n # Note that max_restarts defaults to 4\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if ( resp.status == 503\n && req.restarts < 4\n ) {\n return (restart);\n }\n\n \/* Set common headers for synthetic responses *\/\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n\n \/* HTTP Authentification client request *\/\n # Empty in simple configs.\n # SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* Load synthetic responses from disk *\/\n # Note that files loaded this way are never re-readed (even after a reload).\n # You should consider PROS\/CONS of doing an include instead.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_std.generated.html#func-fileread\n # Example custom 403 error page.\n # if ( resp.status == 403 ) {\n # synthetic(std.fileread(\"\/403.html\"));\n # return (deliver);\n # }\n\n \/* Error page & refresh \/ redirections *\/\n # We have plenty of choices when we have to serve an error to the client,\n # from the default error page to javascript black magic or plain redirections.\n # Adding some external statistic javascript to track failures served to\n # clients is strongly suggested.\n # We can't use external resources on synthetic content, everything must be\n # inlined.\n # If we need to include images we can embed them in base64 encoding.\n # We're using error 200 for monitoring puposes which should not be retried\n # client side.\n if ( resp.status != 200 ) {\n set resp.http.Retry-After = \"5\";\n }\n\n # Here is the default error page for Varnish 4 (not so pretty)\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n return (deliver);\n}\n\n#######################################################################\n# Backend Fetch\n\n# vcl_backend_fetch: Called before sending the backend request. In this\n# subroutine you typically alter the request before it gets to the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-fetch\n# sub vcl_backend_fetch {\n# return (fetch);\n# }\n\n# vcl_backend_response: Called after the response headers has been successfully\n# retrieved from the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-response\nsub vcl_backend_response {\n \/* Ban lurker friendly bans support *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#bans\n set beresp.http.X-Host = bereq.http.host;\n set beresp.http.X-Url = bereq.url;\n\n \/* Caching exceptions *\/\n # Varnish will cache objects with response codes:\n # 200, 203, 300, 301, 302, 307, 404 & 410.\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/VCL_Basics.html#the-initial-value-of-beresp-ttl\n # Drupal's Imagecache module can return a 307 redirection to the requested\n # url itself and, depending on Drupal's cache settings, this could lead to a\n # redirection loop being cached for a long time but also we want Varnish to\n # shield a little the backend.\n # See http:\/\/drupal.org\/node\/1248010\n # See http:\/\/drupal.org\/node\/310656\n if ( beresp.status == 307\n #TODO# verify that this work better than 'bereq.url ~ \"imagecache\"'\n && beresp.http.Location == bereq.url\n && beresp.ttl > 5s\n ) {\n set beresp.ttl = 5s;\n set beresp.http.cache-control = \"max-age=5\";\n }\n\n \/* Request retrial *\/\n if ( beresp.status == 500\n || beresp.status == 503\n ) {\n #TODO# consider not restarting POST requests as seenV3 on https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleSaintMode\n return (retry);\n }\n\n \/* Enable grace mode. Related with vcl_hit *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n set beresp.grace = 1h;\n\n \/* Strip cookies from the following static file types for all users. *\/\n # Related with our 12th stage on vcl_recv\n if ( bereq.url ~ \"(?i)\\.(bz2|css|eot|gif|gz|html?|ico|jpe?g|js|mp3|ogg|otf|pdf|png|rar|svg|swf|tbz|tgz|ttf|woff2?|zip)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n ) {\n unset beresp.http.set-cookie;\n }\n\n \/* Process ESI responses *\/\n # Empty in simple configs.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/esi.html\n # Send Surrogate-Capability headers\n # See http:\/\/www.w3.org\/TR\/edge-arch\n # Note that myproxyname is an identifier that should avoid collitions\n # Check for ESI acknowledgement and remove Surrogate-Control header\n #TODO# Add support for Surrogate-Control Targetting\n # if ( beresp.http.Surrogate-Control ~ \"ESI\/1.0\" ) {\n # unset beresp.http.Surrogate-Control;\n # set beresp.do_esi = true;\n # }\n\n \/* Drupal 8's Big Pipe support *\/\n # Tentative support, maybe 'set beresp.ttl = 0s;' is also needed\n if ( beresp.http.Surrogate-Control ~ \"BigPipe\/1.0\" ) {\n set beresp.do_stream = true;\n }\n\n \/* Gzip response *\/\n # Empty in simple configs.\n # Use Varnish to Gzip respone, if suitable, before storing it on cache.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html\n if ( ! beresp.http.Content-Encoding\n && ( beresp.http.content-type ~ \"(?i)text\"\n || beresp.http.content-type ~ \"(?i)application\/x-javascript\"\n || beresp.http.content-type ~ \"(?i)application\/javascript\"\n || beresp.http.content-type ~ \"(?i)application\/rss+xml\"\n || beresp.http.content-type ~ \"(?i)application\/xml\"\n || beresp.http.content-type ~ \"(?i)Application\/JSON\")\n ) {\n set beresp.do_gzip = true;\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # We can add the name of the backend that has processed the request:\n # set beresp.http.X-Varnish-Backend = beresp.backend.name;\n # We can use a header to tell if the object was gziped by Varnish:\n # if ( beresp.do_gzip ) {\n # set beresp.http.X-Varnish-Gzipped = \"yes\";\n # } else {\n # set beresp.http.X-Varnish-Gzipped = \"no\";\n # }\n # We can do the same to tell if Varnish is streaming it:\n # if ( beresp.do_stream ) {\n # set beresp.http.X-Varnish-Streaming = \"yes\";\n # } else {\n # set beresp.http.X-Varnish-Streaming = \"no\";\n # }\n # We can also add headers informing whether the object is cacheable or not and why:\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Varnish3.0\n if ( beresp.ttl <= 0s ) {\n \/* Varnish determined the object was not cacheable *\/\n set beresp.http.X-Varnish-Cacheable = \"NO:Not Cacheable\";\n } elsif ( bereq.http.Cookie ~ \"(SESS|SSESS|NO_CACHE|OATMEAL|CHOCOLATECHIP)\" ) {\n \/* We don't wish to cache content for logged in users or with certain cookies. *\/\n # Related with our 9th stage on vcl_recv\n set beresp.http.X-Varnish-Cacheable = \"NO:Cookies\";\n # set beresp.uncacheable = true;\n } elsif ( beresp.http.Cache-Control ~ \"private\" ) {\n \/* We are respecting the Cache-Control=private header from the backend *\/\n set beresp.http.X-Varnish-Cacheable = \"NO:Cache-Control=private\";\n # set beresp.uncacheable = true;\n } else {\n \/* Varnish determined the object was cacheable *\/\n set beresp.http.X-Varnish-Cacheable = \"YES\";\n }\n\n \/* Further header manipulation *\/\n # Empty in simple configs.\n # We can also unset some headers to prevent information disclosure and save\n # some cache space.\n # unset beresp.http.Server;\n # unset beresp.http.X-Powered-By;\n # Retry count.\n if ( bereq.retries > 0 ) {\n set beresp.http.X-Varnish-Retries = bereq.retries;\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_backend_response {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Surrogate-control ~ \"no-store\" ||\n# (!beresp.http.Surrogate-Control &&\n# beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n# beresp.http.Vary == \"*\") {\n# \/*\n# * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# *\/\n# set beresp.ttl = 120s;\n# set beresp.uncacheable = true;\n# }\n# return (deliver);\n# }\n\n# vcl_backend_error: This subroutine is called if we fail the backend fetch.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-error\nsub vcl_backend_error {\n\n \/* Try to restart request in case of failure *\/\n #TODO# Confirm max_retries default value\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if ( bereq.retries < 4 ) {\n return (retry);\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # Retry count\n if ( bereq.retries > 0 ) {\n set beresp.http.X-Varnish-Retries = bereq.retries;\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + beresp.status + \" \" + beresp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + beresp.status + \" \" + beresp.reason + {\"<\/h1>\n <p>\"} + beresp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + bereq.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this\n # point.\n return (deliver);\n}\n\n#######################################################################\n# Housekeeping\n\n# vcl_init: Called when VCL is loaded, before any requests pass through it.\n# Typically used to initialize VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-init\n# Here is where you should declare your directors now.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-backends.html#directors\n# Empty in simple configs\n# sub vcl_init {\n# return (ok);\n# }\n\n# vcl_fini: Called when VCL is discarded only after all requests have exited\n# the VCL. Typically used to clean up VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-fini\n# sub vcl_fini {\n# return (ok);\n# }\n","old_contents":"\/*\n * Varnish 4 example config for Drupal 7 & 8 \/ Pressflow 6 & 7\n *\/\n\n# Original source: https:\/\/github.com\/NITEMAN\/varnish-bites\/varnish4\/drupal-base.vcl\n# Copyright (c) 2015 Pedro Gonz\u00e1lez Serrano and individual contributors.\n# MIT License\n\n# Intended to be used both in simple production environments and with\n# learning\/teaching purposes.\n# Some references may not be yet updated to VCL 4.0, we use SeeV3 then.\n\n# WARNING:\n# Note that the built-in logic will be appended to our code if no return is\n# performed before.\n# Built-in logic is included commented out right after our's for reference\n# purposes in that cases.\n# See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleDefault\n\n#######################################################################\n# Initialization: Version & imports;\n\n\/* Version statement *\/\n# Since Varnish 4.0 it's mandatory to declare VCL version on first line.\nvcl 4.0;\n\n\/* Module (VMOD) imports *\/\n# Standard module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_std.generated.html\nimport std;\n\n# Directors module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# Unused in simple configs.\n#import directors;\n\n\n#######################################################################\n# Probe, backend, ACL and subroutine definitions\n\n\/* Backend probes \/ healthchecks *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#probes\nprobe basic {\n \/* Only test that backend's IP serves content for '\/' *\/\n # This might be a too heavy probe\n # .url = \"\/\";\n\n \/* Only test that backend's IP has apache working *\/\n # Nginx would fail this probe with a default config\n .request =\n \"OPTIONS * HTTP\/1.1\"\n \"Host: *\"\n \"Connection: close\";\n\n \/* Common options *\/\n .interval = 10s;\n .timeout = 2s;\n .window = 8;\n .threshold = 6;\n}\n\n\/* Backend definitions.*\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#backend-definition\nbackend default {\n \/* Default backend on the same machine. *\/\n # WARNING: timeouts could be not big enought for certain POST requests.\n .host = \"127.0.0.1\";\n .port = \"8008\";\n .max_connections = 100;\n .connect_timeout = 60s;\n .first_byte_timeout = 60s;\n .between_bytes_timeout = 60s;\n .probe = basic;\n}\n\n\/* Access Control Lists *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#access-control-list-acl\nacl purge_ban {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use '\"localhost\";' instead\n}\nacl allowed_monitors {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n}\n# acl own_proxys {\n# \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n# }\n\n\/* Custom subroutines *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#subroutines\n#TODO# Test in Varnihs 4\n# Empty in simple configs.\n# The only restriction naming subs is that the 'vlc_' prefix is reserverd for\n# Varnish use. As a task can need several chunks of code in diferent states,\n# it's a good idea to identify what main sub will call each with a suffix.\n# \/* Example 301 client redirection removing \"www\" prefix from request *\/\n# sub perm_redirections_recv {\n# if ( req.http.host ~ \"^www.*$\" ) {\n# return (\n# synth(751, \"http:\/\/\" + regsub(req.http.host, \"^www\\.\", \"\") + req.url)\n# );\n# }\n# }\n# sub perm_redirections_synth {\n# if ( resp.status == 751 ) {\n# \/* Get new URL from the response *\/\n# set resp.http.Location = resp.reason;\n# \/* Set HTTP 301 for permanent redirect *\/\n# set resp.status = 301;\n# set resp.reason = \"Moved Permanently\";\n# return (deliver);\n# }\n# }\n\n\n#######################################################################\n# Client side\n\n# vcl_recv: Called at the beginning of a request, after the complete request\n# has been received and parsed. Its purpose is to decide whether or not to\n# serve the request, how to do it, and, if applicable, which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-recv\nsub vcl_recv {\n \/* 0th: general bypass, general return & authorization checks *\/\n # Empty in simple configs.\n # Useful for debugging we can pipe or pass the request to default backend\n # here to bypass completely Varnish.\n # return (pipe);\n # return (pass);\n # We can also return here a 200 Ok for network performance benchmarking.\n # return (synth(200, \"Ok\"));\n # Finally we can perform basic HTTP authentification here, by example.\n # SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* 1st: Check for Varnish special requests *\/\n # Custom response implementation example in order to check that Varnish is\n # working properly.\n # This is usefull for automatic monitoring with monit or when Varnish is\n # behind another proxies like HAProxy.\n if ( ( req.http.host == \"monitor.server.health\"\n || req.http.host == \"health.varnish\" )\n && client.ip ~ allowed_monitors\n && ( req.method == \"OPTIONS\" || req.method == \"GET\" )\n ) {\n return (synth(200, \"OK\"));\n }\n # Purge logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#http-purging\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if ( req.method == \"PURGE\" ) {\n if ( client.ip !~ purge_ban ) {\n return (synth(405, \"Not allowed.\"));\n }\n return (purge);\n }\n # Ban logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#bans\n if ( req.method == \"BAN\" ) {\n if ( client.ip !~ purge_ban ) {\n return (synth(405, \"Not allowed.\"));\n }\n if (req.http.Purge-Cache-Tags) {\n ban( \"obj.http.X-Host == \" + req.http.host +\n \" && obj.http.Purge-Cache-Tags ~ \" + req.http.Purge-Cache-Tags\n );\n }\n else {\n # Assumes req.url is a regex. This might be a bit too simple\n ban( \"obj.http.X-Host == \" + req.http.host +\n \" && obj.http.X-Url ~ \" + req.url\n );\n }\n return (synth(200, \"Ban added\"));\n }\n\n \/* 2nd: Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_recv;\n # Here we can also enforce SSL when Varnish run behind some SSL termination\n # point.\n\n \/* 3rd: Time for backend choice *\/\n # Empty in simple configs.\n\n \/* 4th: Prepare request for the backend *\/\n # Empty in simple configs.\n # Example remove own_proxys from X-Forwarded-For\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/whats-new\/upgrading.html#x-forwarded-for-is-now-set-before-vcl-recv\n # Varnish 4 regsub doesn't accept anything but plain regexp, so we can't use\n # client.ip to exclude the proxy ips from the request:\n # set req.http.X-Forwarded-For\n # = regsub(req.http.X-Forwarded-For, \",( )?\" + client.ip, \"\");\n # Instead, we need to add the proxy ips manually in the exclude list:\n # if ( req.restarts == 0\n # && client.ip ~ own_proxys\n # && req.http.X-Forwarded-For\n # ) {\n # set req.http.X-Forwarded-For\n # = regsub(req.http.X-Forwarded-For,\n # \"(, )?(10\\.10\\.10\\.10|10\\.11\\.11\\.11)\", \"\");\n # }\n # An alternative could be to skip all this and try to modify the header\n # manually so Varnish doesn't touch it.\n # set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \"\";\n #\n # Example normalize the host header, remove the port (in case you're testing\n # this on various TCP ports)\n # set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n \/* 5th: Bypass breakpoint 1 *\/\n # Useful for debugging we can now pipe or pass the request to backend with\n # headers setted.\n # return (pipe);\n # return (pass);\n\n \/* 6th: Decide if we should deal with a request (mostly from built-in logic) *\/\n if ( req.method == \"PRI\" ) {\n \/* We do not support SPDY or HTTP\/2.0 *\/\n return (synth(405));\n }\n if ( req.method != \"GET\"\n && req.method != \"HEAD\"\n && req.method != \"PUT\"\n && req.method != \"POST\"\n && req.method != \"TRACE\"\n && req.method != \"OPTIONS\"\n && req.method != \"DELETE\"\n ) {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if ( req.method != \"GET\"\n && req.method != \"HEAD\"\n ) {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if ( req.http.Authorization ) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n # Websocket support\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html\n if ( req.http.Upgrade ~ \"(?i)websocket\" ) {\n return (pipe);\n }\n\n \/* 7th: Access control for some URLs by ACL *\/\n # Empty in simple configs.\n # By example denial some URLs depending on client-ip, we'll need to define\n # corresponding ACL 'internal'.\n # if ( req.url ~ \"^\/(cron|install)\\.php\"\n # && client.ip !~ internal\n # ) {\n # # Have Varnish throw the error directly.\n # return (synth(403, \"Forbidden.\"));\n # # Use a custom error page that you've defined in Drupal at the path \"404\".\n # # set req.url = \"\/403\";\n # }\n\n \/* 8th: Custom exceptions *\/\n # Host exception example:\n # if ( req.http.host == \"ejemplo.exception.com\" ) {\n # return (pass);\n # }\n # Drupal exceptions, edit if we want to cache some AJAX\/AHAH request.\n # Add here filters for never cache URLs such as Payment Gateway's callbacks.\n if ( req.url ~ \"^\/status\\.php$\"\n || req.url ~ \"^\/update\\.php$\"\n || req.url ~ \"^\/ooyala\/ping$\"\n || req.url ~ \"^\/admin\/build\/features\"\n || req.url ~ \"^\/info\/.*$\"\n || req.url ~ \"^\/flag\/.*$\"\n || req.url ~ \"^.*\/ajax\/.*$\"\n || req.url ~ \"^.*\/ahah\/.*$\"\n ) {\n \/* Do not cache these paths *\/\n return (pass);\n }\n # Pipe these paths directly to backend for streaming.\n if ( req.url ~ \"^\/admin\/content\/backup_migrate\/export\"\n || req.url ~ \"^\/admin\/config\/system\/backup_migrate\"\n ) {\n return (pipe);\n }\n if ( req.url ~ \"^\/system\/files\" ) {\n return (pipe);\n }\n\n \/* 9th: Graced objets & Serve from anonymous cahe if all backends are down *\/\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n # set req.http.grace = \"none\";\n if ( ! std.healthy(req.backend_hint) ) {\n # We must do this here since cookie hashing\n unset req.http.Cookie;\n #TODO# Add sick marker\n }\n\n \/* 10th: Deal with compression and the Accept-Encoding header *\/\n # Althought Varnish 4 handles gziped content itself by default, just to be\n # sure we want to remove Accept-Encoding for some compressed formats.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html#what-does-http-gzip-support-do\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/varnishd.html?highlight=http_gzip_support\n # See (for older configs) https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleNormalizeAcceptEncoding\n if ( req.http.Accept-Encoding ) {\n if ( req.url ~ \"(?i)\\.(7z|avi|bz2|flv|gif|gz|jpe?g|mpe?g|mk[av]|mov|mp[34]|og[gm]|pdf|png|rar|swf|tar|tbz|tgz|woff2?|zip|xz)(\\?.*)?$\"\n ) {\n \/* Already compressed formats, no sense trying to compress again *\/\n unset req.http.Accept-Encoding;\n }\n }\n\n \/* 11th: Further request manipulation *\/\n # Empty in simple configs.\n # We could add here a custom header grouping User-agent families.\n # Generic URL manipulation.\n # Remove Google Analytics added parameters, useless for our backends.\n if ( req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=\" ) {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n # Strip anchors, server doesn't need it.\n if ( req.url ~ \"\\#\" ) {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n # Strip a trailing ? if it exists\n if ( req.url ~ \"\\?$\" ) {\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n # Normalize the querystring arguments\n set req.url = std.querysort(req.url);\n\n \/* 12th: Cookie removal *\/\n # Always cache the following static file types for all users.\n # Use with care if we control certain downloads depending on cookies.\n # Be carefull also if appending .htm[l] via Drupal's clean URLs.\n if ( req.url ~ \"(?i)\\.(bz2|css|eot|gif|gz|html?|ico|jpe?g|js|mp3|ogg|otf|pdf|png|rar|svg|swf|tbz|tgz|ttf|woff2?|zip)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n && req.url !~ \"\/system\/storage\/serve\"\n ) {\n unset req.http.Cookie;\n }\n # Remove all cookies that backend doesn't need to know about.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRemovingSomeCookies\n if ( req.http.Cookie ) {\n \/* Warning: Not a pretty solution *\/\n # Prefix header containing cookies with ';'\n set req.http.Cookie = \";\" + req.http.Cookie;\n # Remove any spaces after ';' in header containing cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n # Prefix cookies we want to preserve with one space:\n # 'S{1,2}ESS[a-z0-9]+' is the regular expression matching a Drupal session\n # cookie ({1,2} added for HTTPS support).\n # 'NO_CACHE' is usually set after a POST request to make sure issuing user\n # see the results of his post.\n # 'OATMEAL' & 'CHOCOLATECHIP' are special cookies used by Drupal's Bakery\n # module to provide Single Sign On.\n # Keep in mind we should add here any cookie that should reach the backend\n # such as splash avoiding cookies.\n set req.http.Cookie\n = regsuball(\n req.http.Cookie,\n \";(S{1,2}ESS[a-z0-9]+|NO_CACHE|OATMEAL|CHOCOLATECHIP)=\",\n \"; \\1=\"\n );\n # Remove from the header any single Cookie not prefixed with a space until\n # next ';' separator.\n set req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n # Remove any '; ' at the start or the end of the header.\n set req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n #If there are no remaining cookies, remove the cookie header.\n if ( req.http.Cookie == \"\" ) {\n unset req.http.Cookie;\n }\n }\n\n \/* 13th: Session cookie & special cookies bypass caching stage *\/\n # As we might want to cache some requests, hashed with its cookies, we don't\n # simply pass when some cookies remain present at this point.\n # Instead we look for request that must be passed due to the cookie header.\n if ( req.http.Cookie ~ \"SESS\"\n || req.http.Cookie ~ \"SSESS\"\n || req.http.Cookie ~ \"NO_CACHE\"\n || req.http.Cookie ~ \"OATMEAL\"\n || req.http.Cookie ~ \"CHOCOLATECHIP\"\n ) {\n return (pass);\n }\n\n \/* 14th: Announce ESI Support *\/\n # Empty in simple configs.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/esi.html\n # Note that ESI included requests inherits its parent's modified request, so\n # depending on the case you will end playing with req.esi_level to know\n # current depth.\n # Send Surrogate-Capability headers\n # See http:\/\/www.w3.org\/TR\/edge-arch\n # Note that myproxyname is an identifier that should avoid collitions\n # set req.http.Surrogate-Capability = \"myproxyname=ESI\/1.0\";\n\n \/* 15th: Bypass breakpoint 2 *\/\n # Useful for debugging we can now pipe or pass the request to backend to\n # bypass cache.\n # return (pipe);\n # return (pass);\n\n \/* 16th: Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n return (hash);\n}\n\n# vcl_pipe: Called upon entering pipe mode.\n# In this mode, the request is passed on to the backend, and any further data\n# from either client or backend is passed on unaltered until either end closes\n# the connection.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pipe\nsub vcl_pipe {\n # Websocket support\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html\n if ( req.http.upgrade ) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n}\n# sub vcl_pipe {\n# # By default Connection: close is set on all piped requests, to stop\n# # connection reuse from sending future requests directly to the\n# # (potentially) wrong backend. If you do want this to happen, you can undo\n# # it here.\n# # unset bereq.http.connection;\n# return (pipe);\n# }\n\n# vcl_pass: Called upon entering pass mode.\n# In this mode, the request is passed on to the backend, and the backend's\n# response is passed on to the client, but is not entered into the cache.\n# Subsequent requests submitted over the same client connection are handled normally.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pass\n# sub vcl_pass {\n# return (fetch);\n# }\n\n# vcl_hash: You may call hash_data() on the data you would like to add to the\n# hash.\n# Hash is used by Varnish to uniquely identify objects.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hash\nsub vcl_hash {\n \/* Hash cookie data *\/\n # As requests with same URL and host can produce diferent results when issued\n # with different cookies, we need to store items hashed with the associated\n # cookies. Note that cookies are already sanitized when we reach this point.\n if ( req.http.Cookie ) {\n \/* Include cookie in cache hash *\/\n hash_data(req.http.Cookie);\n }\n\n \/* Custom header hashing *\/\n # Empty in simple configs.\n # Example for caching differents object versions by device previously\n # detected (when static content could also vary):\n # if ( req.http.X-UA-Device ) {\n # hash_data(req.http.X-UA-Device);\n # }\n # Example for caching diferent object versions by X-Forwarded-Proto, trying\n # to be smart about what kind of request could generate diffetent responses.\n if ( req.http.X-Forwarded-Proto\n && req.url !~ \"(?i)\\.(bz2|css|eot|gif|gz|html?|ico|jpe?g|js|mp3|ogg|otf|pdf|png|rar|svg|swf|tbz|tgz|ttf|woff2?|zip)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n ) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (lookup);\n# }\n\n# vcl_purge: Called after the purge has been executed and all its variants have\n# been evited.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-purge\n# sub vcl_purge {\n# return (synth(200, \"Purged\"));\n# }\n\n# vcl_hit: Called after a cache lookup if the requested document was found in\n# the cache.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hit\nsub vcl_hit {\n if ( obj.ttl >= 0s ) {\n \/\/ A pure unadultered hit, deliver it\n return (deliver);\n }\n \/* Allow varnish to serve up stale content if it is responding slowly *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n if ( obj.ttl + 60s > 0s ) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n set req.http.grace = \"normal\";\n return (deliver);\n }\n \/* Allow varish to serve up stale content if all backends are down *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n if ( ! std.healthy(req.backend_hint)\n && obj.ttl + obj.grace > 0s\n ) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n set req.http.grace = \"extended\";\n return (deliver);\n }\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\n# vcl_miss: Called after a cache lookup if the requested document was not found\n# in the cache.\n# Its purpose is to decide whether or not to attempt to retrieve the document\n# from the backend, and which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-miss\n# sub vcl_miss {\n# return (fetch);\n# }\n\n# vcl_deliver: Called before an object is delivered to the client\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-deliver\nsub vcl_deliver {\n \/* Ban lurker friendly bans support *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#bans\n unset resp.http.X-Host;\n unset resp.http.X-Url;\n\n \/* Drupal 8 Purge's module header cleanup *\/\n # Purge's headers can become quite big, causing issues in upstream proxies, so we clean it here\n unset resp.http.Purge-Cache-Tags;\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # Add whether the object is a cache hit or miss and the number of hits for\n # the object.\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Addingaheaderindicatinghitmiss\n # In Varnish 4 the obj.hits counter behaviour has changed (see bug 1492), so\n # we use a different method: if X-Varnish contains only 1 id, we have a miss,\n # if it contains more (and therefore a space), we have a hit.\n if ( resp.http.X-Varnish ~ \" \" ) {\n set resp.http.X-Varnish-Cache = \"HIT\";\n # Since in Varnish 4 the behaviour of obj.hits changed, this might not be\n # accurate.\n # See https:\/\/www.varnish-cache.org\/trac\/ticket\/1492\n set resp.http.X-Varnish-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Varnish-Cache = \"MISS\";\n \/* Show the results of cookie sanitization *\/\n if ( req.http.Cookie ) {\n set resp.http.X-Varnish-Cookie = req.http.Cookie;\n }\n }\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n set resp.http.grace = req.http.grace;\n\n #TODO# Add sick marker\n\n # Restart count\n if ( req.restarts > 0 ) {\n set resp.http.X-Varnish-Restarts = req.restarts;\n }\n\n # Add the Varnish server hostname\n set resp.http.X-Varnish-Server = server.hostname;\n # If we have setted a custom header with device's family detected we can show\n # it:\n # if ( req.http.X-UA-Device ) {\n # set resp.http.X-UA-Device = req.http.X-UA-Device;\n # }\n # If we have recived a custom header indicating the protocol in the request we\n # can show it:\n # if ( req.http.X-Forwarded-Proto ) {\n # set resp.http.X-Forwarded-Proto = req.http.X-Forwarded-Proto;\n # }\n\n \/* Vary header manipulation *\/\n # Empty in simple configs.\n # By example, if we are storing & serving diferent objects depending on\n # User-Agent header we must set the correct Vary header:\n # if ( resp.http.Vary ) {\n # set resp.http.Vary = resp.http.Vary + \",User-Agent\";\n # } else {\n # set resp.http.Vary = \"User-Agent\";\n # }\n\n \/* Fake headers *\/\n # Empty in simple configs\n # We can fake server headers here, by example:\n # set resp.http.Server = \"Deep thought\";\n # set resp.http.X-Powered-By = \"BOFH\";\n # Or have some fun with headers:\n # See http:\/\/www.nextthing.org\/archives\/2005\/08\/07\/fun-with-http-headers\n # See http:\/\/royal.pingdom.com\/2012\/08\/15\/fun-and-unusual-http-response-headers\/\n # set resp.http.X-Thank-You = \"for bothering to look at my HTTP headers\";\n # set resp.http.X-Answer = \"42\";\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_deliver {\n# return (deliver);\n# }\n\n# vcl_synth: Called to deliver a synthetic object. A synthetic object is\n# generated in VCL, not fetched from the backend. It is typically contructed\n# using the synthetic() function.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-synth\n\/*\n * We can come here \"invisibly\" with the following errors: 413, 417 & 503\n *\/\nsub vcl_synth {\n \/* Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_synth;\n\n \/* Try to restart request in case of failure *\/\n # Note that max_restarts defaults to 4\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if ( resp.status == 503\n && req.restarts < 4\n ) {\n return (restart);\n }\n\n \/* Set common headers for synthetic responses *\/\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n\n \/* HTTP Authentification client request *\/\n # Empty in simple configs.\n # SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* Load synthetic responses from disk *\/\n # Note that files loaded this way are never re-readed (even after a reload).\n # You should consider PROS\/CONS of doing an include instead.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_std.generated.html#func-fileread\n # Example custom 403 error page.\n # if ( resp.status == 403 ) {\n # synthetic(std.fileread(\"\/403.html\"));\n # return (deliver);\n # }\n\n \/* Error page & refresh \/ redirections *\/\n # We have plenty of choices when we have to serve an error to the client,\n # from the default error page to javascript black magic or plain redirections.\n # Adding some external statistic javascript to track failures served to\n # clients is strongly suggested.\n # We can't use external resources on synthetic content, everything must be\n # inlined.\n # If we need to include images we can embed them in base64 encoding.\n # We're using error 200 for monitoring puposes which should not be retried\n # client side.\n if ( resp.status != 200 ) {\n set resp.http.Retry-After = \"5\";\n }\n\n # Here is the default error page for Varnish 4 (not so pretty)\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n return (deliver);\n}\n\n#######################################################################\n# Backend Fetch\n\n# vcl_backend_fetch: Called before sending the backend request. In this\n# subroutine you typically alter the request before it gets to the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-fetch\n# sub vcl_backend_fetch {\n# return (fetch);\n# }\n\n# vcl_backend_response: Called after the response headers has been successfully\n# retrieved from the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-response\nsub vcl_backend_response {\n \/* Ban lurker friendly bans support *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#bans\n set beresp.http.X-Host = bereq.http.host;\n set beresp.http.X-Url = bereq.url;\n\n \/* Caching exceptions *\/\n # Varnish will cache objects with response codes:\n # 200, 203, 300, 301, 302, 307, 404 & 410.\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/VCL_Basics.html#the-initial-value-of-beresp-ttl\n # Drupal's Imagecache module can return a 307 redirection to the requested\n # url itself and, depending on Drupal's cache settings, this could lead to a\n # redirection loop being cached for a long time but also we want Varnish to\n # shield a little the backend.\n # See http:\/\/drupal.org\/node\/1248010\n # See http:\/\/drupal.org\/node\/310656\n if ( beresp.status == 307\n #TODO# verify that this work better than 'bereq.url ~ \"imagecache\"'\n && beresp.http.Location == bereq.url\n && beresp.ttl > 5s\n ) {\n set beresp.ttl = 5s;\n set beresp.http.cache-control = \"max-age=5\";\n }\n\n \/* Request retrial *\/\n if ( beresp.status == 500\n || beresp.status == 503\n ) {\n #TODO# consider not restarting POST requests as seenV3 on https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleSaintMode\n return (retry);\n }\n\n \/* Enable grace mode. Related with vcl_hit *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n set beresp.grace = 1h;\n\n \/* Strip cookies from the following static file types for all users. *\/\n # Related with our 12th stage on vcl_recv\n if ( bereq.url ~ \"(?i)\\.(bz2|css|eot|gif|gz|html?|ico|jpe?g|js|mp3|ogg|otf|pdf|png|rar|svg|swf|tbz|tgz|ttf|woff2?|zip)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n ) {\n unset beresp.http.set-cookie;\n }\n\n \/* Process ESI responses *\/\n # Empty in simple configs.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/esi.html\n # Send Surrogate-Capability headers\n # See http:\/\/www.w3.org\/TR\/edge-arch\n # Note that myproxyname is an identifier that should avoid collitions\n # Check for ESI acknowledgement and remove Surrogate-Control header\n #TODO# Add support for Surrogate-Control Targetting\n # if ( beresp.http.Surrogate-Control ~ \"ESI\/1.0\" ) {\n # unset beresp.http.Surrogate-Control;\n # set beresp.do_esi = true;\n # }\n\n \/* Drupal 8's Big Pipe support *\/\n # Tentative support, maybe 'set beresp.ttl = 0s;' is also needed\n if ( beresp.http.Surrogate-Control ~ \"BigPipe\/1.0\" ) {\n set beresp.do_stream = true;\n }\n\n \/* Gzip response *\/\n # Empty in simple configs.\n # Use Varnish to Gzip respone, if suitable, before storing it on cache.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html\n if ( ! beresp.http.Content-Encoding\n && ( beresp.http.content-type ~ \"(?i)text\"\n || beresp.http.content-type ~ \"(?i)application\/x-javascript\"\n || beresp.http.content-type ~ \"(?i)application\/javascript\"\n || beresp.http.content-type ~ \"(?i)application\/rss+xml\"\n || beresp.http.content-type ~ \"(?i)application\/xml\"\n || beresp.http.content-type ~ \"(?i)Application\/JSON\")\n ) {\n set beresp.do_gzip = true;\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # We can add the name of the backend that has processed the request:\n # set beresp.http.X-Varnish-Backend = beresp.backend.name;\n # We can use a header to tell if the object was gziped by Varnish:\n # if ( beresp.do_gzip ) {\n # set beresp.http.X-Varnish-Gzipped = \"yes\";\n # } else {\n # set beresp.http.X-Varnish-Gzipped = \"no\";\n # }\n # We can do the same to tell if Varnish is streaming it:\n # if ( beresp.do_stream ) {\n # set beresp.http.X-Varnish-Streaming = \"yes\";\n # } else {\n # set beresp.http.X-Varnish-Streaming = \"no\";\n # }\n # We can also add headers informing whether the object is cacheable or not and why:\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Varnish3.0\n if ( beresp.ttl <= 0s ) {\n \/* Varnish determined the object was not cacheable *\/\n set beresp.http.X-Varnish-Cacheable = \"NO:Not Cacheable\";\n } elsif ( bereq.http.Cookie ~ \"(SESS|SSESS|NO_CACHE|OATMEAL|CHOCOLATECHIP)\" ) {\n \/* We don't wish to cache content for logged in users or with certain cookies. *\/\n # Related with our 9th stage on vcl_recv\n set beresp.http.X-Varnish-Cacheable = \"NO:Cookies\";\n # set beresp.uncacheable = true;\n } elsif ( beresp.http.Cache-Control ~ \"private\" ) {\n \/* We are respecting the Cache-Control=private header from the backend *\/\n set beresp.http.X-Varnish-Cacheable = \"NO:Cache-Control=private\";\n # set beresp.uncacheable = true;\n } else {\n \/* Varnish determined the object was cacheable *\/\n set beresp.http.X-Varnish-Cacheable = \"YES\";\n }\n\n \/* Further header manipulation *\/\n # Empty in simple configs.\n # We can also unset some headers to prevent information disclosure and save\n # some cache space.\n # unset beresp.http.Server;\n # unset beresp.http.X-Powered-By;\n # Retry count.\n if ( bereq.retries > 0 ) {\n set beresp.http.X-Varnish-Retries = bereq.retries;\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_backend_response {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Surrogate-control ~ \"no-store\" ||\n# (!beresp.http.Surrogate-Control &&\n# beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n# beresp.http.Vary == \"*\") {\n# \/*\n# * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# *\/\n# set beresp.ttl = 120s;\n# set beresp.uncacheable = true;\n# }\n# return (deliver);\n# }\n\n# vcl_backend_error: This subroutine is called if we fail the backend fetch.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-error\nsub vcl_backend_error {\n\n \/* Try to restart request in case of failure *\/\n #TODO# Confirm max_retries default value\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if ( bereq.retries < 4 ) {\n return (retry);\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # Retry count\n if ( bereq.retries > 0 ) {\n set beresp.http.X-Varnish-Retries = bereq.retries;\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + beresp.status + \" \" + beresp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + beresp.status + \" \" + beresp.reason + {\"<\/h1>\n <p>\"} + beresp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + bereq.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this\n # point.\n return (deliver);\n}\n\n#######################################################################\n# Housekeeping\n\n# vcl_init: Called when VCL is loaded, before any requests pass through it.\n# Typically used to initialize VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-init\n# Here is where you should declare your directors now.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-backends.html#directors\n# Empty in simple configs\n# sub vcl_init {\n# return (ok);\n# }\n\n# vcl_fini: Called when VCL is discarded only after all requests have exited\n# the VCL. Typically used to clean up VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-fini\n# sub vcl_fini {\n# return (ok);\n# }\n","returncode":0,"stderr":"","license":"unknown","lang":"VCL"} {"commit":"7d66ab94e27a8290b9e5d245b75d06f9b6743756","subject":"Update varnish\/default.vcl","message":"Update varnish\/default.vcl\n","repos":"jclgoodwin\/bustimes.org.uk,jclgoodwin\/bustimes.org.uk,jclgoodwin\/bustimes.org.uk,jclgoodwin\/bustimes.org.uk","old_file":"config\/varnish\/default.vcl","new_file":"config\/varnish\/default.vcl","new_contents":"vcl 4.0;\n\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8081\";\n}\n\nbackend bustimesio {\n .host = \"127.0.0.1\";\n .port = \"8082\";\n}\n\nbackend supermarket {\n .host = \"127.0.0.1\";\n .port = \"8000\";\n}\n\nbackend basiltherat {\n .host = \"127.0.0.1\";\n .port = \"8083\";\n}\n\nbackend tileserver {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\n\nsub vcl_recv {\n if (req.http.host == \"bustimes.io\") {\n set req.backend_hint = bustimesio;\n } elif (req.http.host == \"www.supermarketmarket.co.uk\") {\n set req.backend_hint = supermarket;\n } elif (req.http.host == \"hygieneratings.co.uk\") {\n set req.backend_hint = basiltherat;\n } elif (req.url ~ \"^\/styles\/\") {\n set req.backend_hint = tileserver;\n }\n\n if (req.url ~ \"^\/(admin\/|contact|awin-transaction)\") {\n return (pass);\n }\n\n if (req.url ~ \"^\/services\/\" && req.http.Cookie ~ \"sessionid\") {\n return (pass);\n }\n\n unset req.http.Cookie;\n}\n\nsub vcl_backend_response {\n if (bereq.url !~ \"^\/(admin\/|contact)\") {\n unset beresp.http.set-cookie;\n\n if (beresp.status >= 200 && beresp.status < 400) {\n if (bereq.url ~ \"^\/stops\/\") {\n set beresp.ttl = 30s;\n } elif (bereq.url ~ \"^\/styles\/\") {\n set beresp.ttl = 30d;\n } else {\n set beresp.ttl = 1h;\n }\n }\n\n }\n}\n","old_contents":"vcl 4.0;\n\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8081\";\n}\n\nbackend bustimesio {\n .host = \"127.0.0.1\";\n .port = \"8082\";\n}\n\nbackend tileserver {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\n\nsub vcl_recv {\n if (req.http.host == \"bustimes.io\") {\n set req.backend_hint = bustimesio;\n } elif (req.url ~ \"^\/styles\/\") {\n set req.backend_hint = tileserver;\n }\n\n if (req.url ~ \"^\/(admin\/|contact|awin-transaction)\") {\n return (pass);\n }\n\n if (req.url ~ \"^\/services\/\" && req.http.Cookie ~ \"sessionid\") {\n return (pass);\n }\n\n unset req.http.Cookie;\n}\n\nsub vcl_backend_response {\n if (bereq.url !~ \"^\/(admin\/|contact)\") {\n unset beresp.http.set-cookie;\n\n if (beresp.status >= 200 && beresp.status < 400) {\n if (bereq.url ~ \"^\/stops\/\") {\n set beresp.ttl = 30s;\n } elif (bereq.url ~ \"^\/styles\/\") {\n set beresp.ttl = 30d;\n } else {\n set beresp.ttl = 1h;\n }\n }\n\n }\n}\n","returncode":0,"stderr":"","license":"mpl-2.0","lang":"VCL"} {"commit":"c7333b8aff24159f1d33ca8d862619cfd9beddee","subject":"spacing nit.","message":"spacing nit.\n","repos":"amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon","old_file":"images\/varnish-drupal\/drupal.vcl","new_file":"images\/varnish-drupal\/drupal.vcl","new_contents":"vcl 4.0;\n\nimport std;\nimport dynamic;\n\n# set backend default\nbackend default {\n .host = \"${VARNISH_BACKEND_HOST:-nginx}\";\n .port = \"${VARNISH_BACKEND_PORT:-8080}\";\n .first_byte_timeout = 35m;\n .between_bytes_timeout = 10m;\n}\n\n# Allow purging from localhost\n# @TODO allow from openshift network\nacl purge {\n \"127.0.0.1\";\n \"10.0.0.0\"\/8;\n \"172.16.0.0\"\/12;\n \"192.168.0.0\"\/16;\n}\n\nsub vcl_init {\n new www_dir = dynamic.director(\n port = \"${VARNISH_BACKEND_PORT:-8080}\",\n first_byte_timeout = 90s,\n between_bytes_timeout = 90s,\n ttl = 60s);\n}\n\n# This configuration is optimized for Drupal hosting:\n# Respond to incoming requests.\nsub vcl_recv {\n\n if (req.url ~ \"^\/varnish_status$\") {\n return (synth(200,\"OK\"));\n }\n # set the backend, which should be used:\n set req.backend_hint = www_dir.backend(\"${VARNISH_BACKEND_HOST:-nginx}\");\n\n # Always set the forward ip.\n if (req.restarts == 0) {\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n\n\n if (req.http.X-LAGOON-VARNISH ) {\n ## Pass all Requests which are handled via an upstream Varnish\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, \" + req.http.X-LAGOON-VARNISH;\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n } else if (req.http.Fastly-FF) {\n ## Pass all Requests which are handled via Fastly\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, fastly\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n set req.http.X-Forwarded-For = req.http.Fastly-Client-IP;\n } else if (req.http.CF-RAY) {\n ## Pass all Requests which are handled via CloudFlare\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, cloudflare\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n set req.http.X-Forwarded-For = req.http.CF-Connecting-IP;\n } else if (req.http.X-Pull) {\n ## Pass all Requests which are handled via KeyCDN\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, keycdn\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n } else {\n ## We set a header to let a Varnish Chain know that it already has been varnishcached\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}\";\n\n ## Allow to bypass based on env variable `VARNISH_BYPASS`\n set req.http.X-LAGOON-VARNISH-BYPASS = \"${VARNISH_BYPASS:-false}\";\n }\n\n # Websockets are piped\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n if (req.http.X-LAGOON-VARNISH-BYPASS == \"true\" || req.http.X-LAGOON-VARNISH-BYPASS == \"TRUE\") {\n return (pass);\n }\n\n # SA-CORE-2014-004 preventing access to \/xmlrpc.php\n if (req.url ~ \"^\/xmlrpc.php$\") {\n return (synth(701, \"Unauthorized\"));\n }\n\n # Strip out Google Analytics campaign variables. They are only needed\n # by the javascript running on the page\n # utm_source, utm_medium, utm_campaign, gclid\n if(req.url ~ \"(\\?|&)(gclid|utm_[a-z]+)=\") {\n set req.url = regsuball(req.url, \"(gclid|utm_[a-z]+)=[^\\&]+&?\", \"\");\n set req.url = regsub(req.url, \"(\\?|&)$\", \"\");\n }\n\n # Bypass a cache hit (the request is still sent to the backend)\n if (req.method == \"REFRESH\") {\n if (!client.ip ~ purge) { return (synth(405, \"Not allowed\")); }\n set req.method = \"GET\";\n set req.hash_always_miss = true;\n }\n\n # Only allow BAN requests from IP addresses in the 'purge' ACL.\n if (req.method == \"BAN\" || req.method == \"URIBAN\" || req.method == \"PURGE\") {\n # Only allow BAN from defined ACL\n if (!client.ip ~ purge) {\n return (synth(403, \"Your IP is not allowed.\"));\n }\n\n # Only allows BAN if the Host Header has the style of with \"${SERVICE_NAME:-varnish}:8080\" or \"${SERVICE_NAME:-varnish}\".\n # Such a request is only possible from within the Docker network, as a request from external goes trough the Kubernetes Router and for that needs a proper Host Header\n if (!req.http.host ~ \"^${SERVICE_NAME:-varnish}(:\\d+)?$\") {\n return (synth(403, \"Only allowed from within own network.\"));\n }\n\n if (req.method == \"BAN\") {\n # Logic for the ban, using the Cache-Tags header.\n if (req.http.Cache-Tags) {\n ban(\"obj.http.Cache-Tags ~ \" + req.http.Cache-Tags);\n # Throw a synthetic page so the request won't go to the backend.\n return (synth(200, \"Ban added.\"));\n }\n else {\n return (synth(403, \"Cache-Tags header missing.\"));\n }\n }\n\n if (req.method == \"URIBAN\" || req.method == \"PURGE\") {\n ban(\"req.url ~ \" + req.url);\n # Throw a synthetic page so the request won't go to the backend.\n return (synth(200, \"Ban added.\"));\n }\n\n }\n\n # Non-RFC2616 or CONNECT which is weird, we pipe that\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n return (pipe);\n }\n\n # We only try to cache GET and HEAD, other things are passed\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n # Any requests with Basic Auth are passed\n if (req.http.Authorization || req.http.Authenticate)\n {\n return (pass);\n }\n\n ## Pass requests which are from blackfire\n if (req.http.X-Blackfire-Query) {\n return (pass);\n }\n\n # Some URLs should never be cached\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/admin([\/?]|$).*$\" ||\n req.url ~ \"^\/info([\/?]|$).*$\" ||\n req.url ~ \"^\/flag([\/?]|$).*$\" ||\n req.url ~ \"^.*\/system\/files([\/?]|$).*$\" ||\n req.url ~ \"^\/cgi\" ||\n req.url ~ \"^\/cgi-bin\"\n ) {\n return (pass);\n }\n\n # Plupload likes to get piped\n if (req.url ~ \"^.*\/plupload-handle-uploads.*$\"\n ) {\n return (pipe);\n }\n\n # Handle compression correctly. Different browsers send different\n # \"Accept-Encoding\" headers, even though they mostly all support the same\n # compression mechanisms. By consolidating these compression headers into\n # a consistent format, we can reduce the size of the cache and get more hits.=\n # @see: http:\/\/ varnish.projects.linpro.no\/wiki\/FAQ\/Compression\n if (req.http.Accept-Encoding) {\n if (req.http.Accept-Encoding ~ \"gzip\") {\n # If the browser supports it, we'll use gzip.\n set req.http.Accept-Encoding = \"gzip\";\n }\n else if (req.http.Accept-Encoding ~ \"deflate\") {\n # Next, try deflate if it is supported.\n set req.http.Accept-Encoding = \"deflate\";\n }\n else {\n # Unknown algorithm. Remove it and send unencoded.\n unset req.http.Accept-Encoding;\n }\n }\n\n # Always cache the following file types for all users.\n if (req.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n unset req.http.Cookie;\n }\n\n # Remove all cookies that Drupal doesn't need to know about. ANY remaining\n # cookie will cause the request to pass-through to a backend. For the most part\n # we always set the NO_CACHE cookie after any POST request, disabling the\n # Varnish cache temporarily. The session cookie allows all authenticated users\n # to pass through as long as they're logged in.\n #\n # 1. Append a semi-colon to the front of the cookie string.\n # 2. Remove all spaces that appear after semi-colons.\n # 3. Match the cookies we want to keep, adding the space we removed\n # previously, back. (\\1) is first matching group in the regsuball.\n # 4. Remove all other cookies, identifying them by the fact that they have\n # no space after the preceding semi-colon.\n # 5. Remove all spaces and semi-colons from the beginning and end of the\n # cookie string.\n if (req.http.Cookie) {\n set req.http.CookieCheck = \";\" + req.http.Cookie;\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"; +\", \";\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";(${VARNISH_COOKIECHECK:-SESS[a-z0-9]+|SSESS[a-z0-9]+|NO_CACHE})=\", \"; \\1=\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";[^ ][^;]*\", \"\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"^[; ]+|[; ]+$\", \"\");\n\n set req.http.Cookie = req.http.Cookie + \";\";\n\n if (req.http.CookieCheck == \"\") {\n # If there are no remaining cookies, remove the cookie header. If there\n # aren't any cookie headers, Varnish's default behavior will be to cache\n # the page.\n\n unset req.http.CookieCheck;\n unset req.http.Cookie;\n }\n else {\n # If there is any cookies left (a session or NO_CACHE cookie), do not\n # cache the page. Pass it on to Apache directly.\n unset req.http.CookieCheck;\n return (pass);\n }\n }\n\n # Cacheable, lookup in cache.\n return (hash);\n}\n\nsub vcl_pipe {\n # Support for Websockets\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n set bereq.http.connection = req.http.connection;\n }\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n # normal hit\n return (deliver);\n }\n # We have no fresh fish. Lets look at the stale ones.\n if (std.healthy(req.backend_hint)) {\n # Backend is healthy. If the object is not older then 30secs, deliver it to the client\n # and automatically create a separate backend request to warm the cache for this request.\n if (obj.ttl + 30s > 0s) {\n set req.http.grace = \"normal(limited)\";\n return (deliver);\n } else {\n # No candidate for grace. Fetch a fresh object.\n return(miss);\n }\n } else {\n # backend is sick - use full grace\n if (obj.ttl + obj.grace > 0s) {\n set req.http.grace = \"full\";\n return (deliver);\n } else {\n # no graced object.\n return (miss);\n }\n }\n}\n\nsub vcl_backend_response {\n # Allow items to be stale if needed.\n set beresp.grace = 6h;\n\n # Set ban-lurker friendly custom headers.\n set beresp.http.X-Url = bereq.url;\n set beresp.http.X-Host = bereq.http.host;\n\n # If the backend sends a X-LAGOON-VARNISH-BACKEND-BYPASS header we directly deliver\n if(beresp.http.X-LAGOON-VARNISH-BACKEND-BYPASS == \"TRUE\") {\n return (deliver);\n }\n\n # Cache 404 and 403 for 10 seconds\n if(beresp.status == 404 || beresp.status == 403) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n # Don't allow static files to set cookies.\n if (bereq.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n # beresp == Back-end response from the web server.\n unset beresp.http.set-cookie;\n unset beresp.http.Cache-Control;\n\n # If an asset would come back with statuscode 500 we only cache it for 10 seconds instead of the usual static file cache\n if (beresp.status == 500) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n set beresp.ttl = ${VARNISH_ASSETS_TTL:-2628001}s;\n set beresp.http.Cache-Control = \"public, max-age=${VARNISH_ASSETS_TTL:-2628001}\";\n set beresp.http.Expires = \"\" + (now + beresp.ttl);\n }\n\n return (deliver);\n}\n\n# Set a header to track a cache HIT\/MISS.\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Varnish-Cache = \"HIT\";\n }\n else {\n set resp.http.X-Varnish-Cache = \"MISS\";\n }\n\n # Remove ban-lurker friendly custom headers when delivering to client.\n unset resp.http.X-Url;\n unset resp.http.X-Host;\n\n # unset Cache-Tags Header by default, can be disabled with VARNISH_UNSET_HEADER_CACHE_TAGS=true\n if (!${VARNISH_UNSET_HEADER_CACHE_TAGS:-false}) {\n unset resp.http.Cache-Tags;\n }\n\n unset resp.http.X-Generator;\n unset resp.http.Server;\n # Inject information about grace\n if (req.http.grace) {\n set resp.http.X-Varnish-Grace = req.http.grace;\n }\n set resp.http.X-LAGOON = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}>\" + resp.http.X-LAGOON;\n return (deliver);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n if (req.http.X-Forwarded-Proto) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n if (req.http.HTTPS) {\n hash_data(req.http.HTTPS);\n }\n return (lookup);\n}\n\nsub vcl_synth {\n if (resp.status == 701) {\n set resp.status = 401;\n set resp.http.Content-Type = \"text\/plain; charset=utf-8\";\n synthetic({\"XMLRPC Interface is blocked due to SA-CORE-2014-004 - mail support@amazee.io if you need it.\"});\n return (deliver);\n }\n if (resp.status == 700) {\n # Set a status the client will understand\n set resp.status = 200;\n # Create our synthetic response\n synthetic(\"\");\n return(deliver);\n}\n return (deliver);\n}\n\nsub vcl_backend_error {\n # Restart the request, when we have a backend server error, to try another backend.\n # Restart max twice.\n if (bereq.retries < 2) {\n return(retry);\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<head>\n <title>Server Error<\/title>\n <style type=\"text\/css\">\n body {\n font-family: helvetica, arial, sans-serif;\n }\n img {\n margin-top: 50px;\n }\n p {\n width: 6 00px;\n margin-top: 10px\n }\n div {\n background: #ccc;\n width: 600px;\n margin: auto;\n padding: 50px;\n }\n span {\n color: #ccc\n }\n <\/style>\n<\/head>\n<body>\n <div>\n <h1>We are sorry...<\/h1>\n <p>We encountered a server-side error. This means that the problem is not with your computer or Internet connection, but rather with the website's server.<\/p>\n <p>We are currently working on solving this problem and apologise for the inconvenience.<\/p>\n <span>\n <strong>Technical Information<\/strong><br \/>\n Error \"} + beresp.status + \" \" + beresp.reason + {\"<br \/>\n XID: \"} + bereq.xid + {\"<br \/>\n <\/span>\n <\/div>\n<\/body>\n<\/html>\n\n\"} );\n return (deliver);\n}\n","old_contents":"vcl 4.0;\n\nimport std;\nimport dynamic;\n\n# set backend default\nbackend default {\n .host = \"${VARNISH_BACKEND_HOST:-nginx}\";\n .port = \"${VARNISH_BACKEND_PORT:-8080}\";\n .first_byte_timeout = 35m;\n .between_bytes_timeout = 10m;\n}\n\n# Allow purging from localhost\n# @TODO allow from openshift network\nacl purge {\n \"127.0.0.1\";\n \"10.0.0.0\"\/8;\n \"172.16.0.0\"\/12;\n \"192.168.0.0\"\/16;\n}\n\nsub vcl_init {\n new www_dir = dynamic.director(\n port = \"${VARNISH_BACKEND_PORT:-8080}\",\n first_byte_timeout = 90s,\n between_bytes_timeout = 90s,\n ttl = 60s);\n }\n\n# This configuration is optimized for Drupal hosting:\n# Respond to incoming requests.\nsub vcl_recv {\n\n if (req.url ~ \"^\/varnish_status$\") {\n return (synth(200,\"OK\"));\n }\n # set the backend, which should be used:\n set req.backend_hint = www_dir.backend(\"${VARNISH_BACKEND_HOST:-nginx}\");\n\n # Always set the forward ip.\n if (req.restarts == 0) {\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n\n\n if (req.http.X-LAGOON-VARNISH ) {\n ## Pass all Requests which are handled via an upstream Varnish\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, \" + req.http.X-LAGOON-VARNISH;\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n } else if (req.http.Fastly-FF) {\n ## Pass all Requests which are handled via Fastly\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, fastly\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n set req.http.X-Forwarded-For = req.http.Fastly-Client-IP;\n } else if (req.http.CF-RAY) {\n ## Pass all Requests which are handled via CloudFlare\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, cloudflare\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n set req.http.X-Forwarded-For = req.http.CF-Connecting-IP;\n } else if (req.http.X-Pull) {\n ## Pass all Requests which are handled via KeyCDN\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, keycdn\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n } else {\n ## We set a header to let a Varnish Chain know that it already has been varnishcached\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}\";\n\n ## Allow to bypass based on env variable `VARNISH_BYPASS`\n set req.http.X-LAGOON-VARNISH-BYPASS = \"${VARNISH_BYPASS:-false}\";\n }\n\n # Websockets are piped\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n if (req.http.X-LAGOON-VARNISH-BYPASS == \"true\" || req.http.X-LAGOON-VARNISH-BYPASS == \"TRUE\") {\n return (pass);\n }\n\n # SA-CORE-2014-004 preventing access to \/xmlrpc.php\n if (req.url ~ \"^\/xmlrpc.php$\") {\n return (synth(701, \"Unauthorized\"));\n }\n\n # Strip out Google Analytics campaign variables. They are only needed\n # by the javascript running on the page\n # utm_source, utm_medium, utm_campaign, gclid\n if(req.url ~ \"(\\?|&)(gclid|utm_[a-z]+)=\") {\n set req.url = regsuball(req.url, \"(gclid|utm_[a-z]+)=[^\\&]+&?\", \"\");\n set req.url = regsub(req.url, \"(\\?|&)$\", \"\");\n }\n\n # Bypass a cache hit (the request is still sent to the backend)\n if (req.method == \"REFRESH\") {\n if (!client.ip ~ purge) { return (synth(405, \"Not allowed\")); }\n set req.method = \"GET\";\n set req.hash_always_miss = true;\n }\n\n # Only allow BAN requests from IP addresses in the 'purge' ACL.\n if (req.method == \"BAN\" || req.method == \"URIBAN\" || req.method == \"PURGE\") {\n # Only allow BAN from defined ACL\n if (!client.ip ~ purge) {\n return (synth(403, \"Your IP is not allowed.\"));\n }\n\n # Only allows BAN if the Host Header has the style of with \"${SERVICE_NAME:-varnish}:8080\" or \"${SERVICE_NAME:-varnish}\".\n # Such a request is only possible from within the Docker network, as a request from external goes trough the Kubernetes Router and for that needs a proper Host Header\n if (!req.http.host ~ \"^${SERVICE_NAME:-varnish}(:\\d+)?$\") {\n return (synth(403, \"Only allowed from within own network.\"));\n }\n\n if (req.method == \"BAN\") {\n # Logic for the ban, using the Cache-Tags header.\n if (req.http.Cache-Tags) {\n ban(\"obj.http.Cache-Tags ~ \" + req.http.Cache-Tags);\n # Throw a synthetic page so the request won't go to the backend.\n return (synth(200, \"Ban added.\"));\n }\n else {\n return (synth(403, \"Cache-Tags header missing.\"));\n }\n }\n\n if (req.method == \"URIBAN\" || req.method == \"PURGE\") {\n ban(\"req.url ~ \" + req.url);\n # Throw a synthetic page so the request won't go to the backend.\n return (synth(200, \"Ban added.\"));\n }\n\n }\n\n # Non-RFC2616 or CONNECT which is weird, we pipe that\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n return (pipe);\n }\n\n # We only try to cache GET and HEAD, other things are passed\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n # Any requests with Basic Auth are passed\n if (req.http.Authorization || req.http.Authenticate)\n {\n return (pass);\n }\n\n ## Pass requests which are from blackfire\n if (req.http.X-Blackfire-Query) {\n return (pass);\n }\n\n # Some URLs should never be cached\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/admin([\/?]|$).*$\" ||\n req.url ~ \"^\/info([\/?]|$).*$\" ||\n req.url ~ \"^\/flag([\/?]|$).*$\" ||\n req.url ~ \"^.*\/system\/files([\/?]|$).*$\" ||\n req.url ~ \"^\/cgi\" ||\n req.url ~ \"^\/cgi-bin\"\n ) {\n return (pass);\n }\n\n # Plupload likes to get piped\n if (req.url ~ \"^.*\/plupload-handle-uploads.*$\"\n ) {\n return (pipe);\n }\n\n # Handle compression correctly. Different browsers send different\n # \"Accept-Encoding\" headers, even though they mostly all support the same\n # compression mechanisms. By consolidating these compression headers into\n # a consistent format, we can reduce the size of the cache and get more hits.=\n # @see: http:\/\/ varnish.projects.linpro.no\/wiki\/FAQ\/Compression\n if (req.http.Accept-Encoding) {\n if (req.http.Accept-Encoding ~ \"gzip\") {\n # If the browser supports it, we'll use gzip.\n set req.http.Accept-Encoding = \"gzip\";\n }\n else if (req.http.Accept-Encoding ~ \"deflate\") {\n # Next, try deflate if it is supported.\n set req.http.Accept-Encoding = \"deflate\";\n }\n else {\n # Unknown algorithm. Remove it and send unencoded.\n unset req.http.Accept-Encoding;\n }\n }\n\n # Always cache the following file types for all users.\n if (req.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n unset req.http.Cookie;\n }\n\n # Remove all cookies that Drupal doesn't need to know about. ANY remaining\n # cookie will cause the request to pass-through to a backend. For the most part\n # we always set the NO_CACHE cookie after any POST request, disabling the\n # Varnish cache temporarily. The session cookie allows all authenticated users\n # to pass through as long as they're logged in.\n #\n # 1. Append a semi-colon to the front of the cookie string.\n # 2. Remove all spaces that appear after semi-colons.\n # 3. Match the cookies we want to keep, adding the space we removed\n # previously, back. (\\1) is first matching group in the regsuball.\n # 4. Remove all other cookies, identifying them by the fact that they have\n # no space after the preceding semi-colon.\n # 5. Remove all spaces and semi-colons from the beginning and end of the\n # cookie string.\n if (req.http.Cookie) {\n set req.http.CookieCheck = \";\" + req.http.Cookie;\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"; +\", \";\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";(${VARNISH_COOKIECHECK:-SESS[a-z0-9]+|SSESS[a-z0-9]+|NO_CACHE})=\", \"; \\1=\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";[^ ][^;]*\", \"\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"^[; ]+|[; ]+$\", \"\");\n\n set req.http.Cookie = req.http.Cookie + \";\";\n\n if (req.http.CookieCheck == \"\") {\n # If there are no remaining cookies, remove the cookie header. If there\n # aren't any cookie headers, Varnish's default behavior will be to cache\n # the page.\n\n unset req.http.CookieCheck;\n unset req.http.Cookie;\n }\n else {\n # If there is any cookies left (a session or NO_CACHE cookie), do not\n # cache the page. Pass it on to Apache directly.\n unset req.http.CookieCheck;\n return (pass);\n }\n }\n\n # Cacheable, lookup in cache.\n return (hash);\n}\n\nsub vcl_pipe {\n # Support for Websockets\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n set bereq.http.connection = req.http.connection;\n }\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n # normal hit\n return (deliver);\n }\n # We have no fresh fish. Lets look at the stale ones.\n if (std.healthy(req.backend_hint)) {\n # Backend is healthy. If the object is not older then 30secs, deliver it to the client\n # and automatically create a separate backend request to warm the cache for this request.\n if (obj.ttl + 30s > 0s) {\n set req.http.grace = \"normal(limited)\";\n return (deliver);\n } else {\n # No candidate for grace. Fetch a fresh object.\n return(miss);\n }\n } else {\n # backend is sick - use full grace\n if (obj.ttl + obj.grace > 0s) {\n set req.http.grace = \"full\";\n return (deliver);\n } else {\n # no graced object.\n return (miss);\n }\n }\n}\n\nsub vcl_backend_response {\n # Allow items to be stale if needed.\n set beresp.grace = 6h;\n\n # Set ban-lurker friendly custom headers.\n set beresp.http.X-Url = bereq.url;\n set beresp.http.X-Host = bereq.http.host;\n\n # If the backend sends a X-LAGOON-VARNISH-BACKEND-BYPASS header we directly deliver\n if(beresp.http.X-LAGOON-VARNISH-BACKEND-BYPASS == \"TRUE\") {\n return (deliver);\n }\n\n # Cache 404 and 403 for 10 seconds\n if(beresp.status == 404 || beresp.status == 403) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n # Don't allow static files to set cookies.\n if (bereq.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n # beresp == Back-end response from the web server.\n unset beresp.http.set-cookie;\n unset beresp.http.Cache-Control;\n\n # If an asset would come back with statuscode 500 we only cache it for 10 seconds instead of the usual static file cache\n if (beresp.status == 500) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n set beresp.ttl = ${VARNISH_ASSETS_TTL:-2628001}s;\n set beresp.http.Cache-Control = \"public, max-age=${VARNISH_ASSETS_TTL:-2628001}\";\n set beresp.http.Expires = \"\" + (now + beresp.ttl);\n }\n\n return (deliver);\n}\n\n# Set a header to track a cache HIT\/MISS.\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Varnish-Cache = \"HIT\";\n }\n else {\n set resp.http.X-Varnish-Cache = \"MISS\";\n }\n\n # Remove ban-lurker friendly custom headers when delivering to client.\n unset resp.http.X-Url;\n unset resp.http.X-Host;\n\n # unset Cache-Tags Header by default, can be disabled with VARNISH_UNSET_HEADER_CACHE_TAGS=true\n if (!${VARNISH_UNSET_HEADER_CACHE_TAGS:-false}) {\n unset resp.http.Cache-Tags;\n }\n\n unset resp.http.X-Generator;\n unset resp.http.Server;\n # Inject information about grace\n if (req.http.grace) {\n set resp.http.X-Varnish-Grace = req.http.grace;\n }\n set resp.http.X-LAGOON = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}>\" + resp.http.X-LAGOON;\n return (deliver);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n if (req.http.X-Forwarded-Proto) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n if (req.http.HTTPS) {\n hash_data(req.http.HTTPS);\n }\n return (lookup);\n}\n\nsub vcl_synth {\n if (resp.status == 701) {\n set resp.status = 401;\n set resp.http.Content-Type = \"text\/plain; charset=utf-8\";\n synthetic({\"XMLRPC Interface is blocked due to SA-CORE-2014-004 - mail support@amazee.io if you need it.\"});\n return (deliver);\n }\n if (resp.status == 700) {\n # Set a status the client will understand\n set resp.status = 200;\n # Create our synthetic response\n synthetic(\"\");\n return(deliver);\n}\n return (deliver);\n}\n\nsub vcl_backend_error {\n # Restart the request, when we have a backend server error, to try another backend.\n # Restart max twice.\n if (bereq.retries < 2) {\n return(retry);\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<head>\n <title>Server Error<\/title>\n <style type=\"text\/css\">\n body {\n font-family: helvetica, arial, sans-serif;\n }\n img {\n margin-top: 50px;\n }\n p {\n width: 6 00px;\n margin-top: 10px\n }\n div {\n background: #ccc;\n width: 600px;\n margin: auto;\n padding: 50px;\n }\n span {\n color: #ccc\n }\n <\/style>\n<\/head>\n<body>\n <div>\n <h1>We are sorry...<\/h1>\n <p>We encountered a server-side error. This means that the problem is not with your computer or Internet connection, but rather with the website's server.<\/p>\n <p>We are currently working on solving this problem and apologise for the inconvenience.<\/p>\n <span>\n <strong>Technical Information<\/strong><br \/>\n Error \"} + beresp.status + \" \" + beresp.reason + {\"<br \/>\n XID: \"} + bereq.xid + {\"<br \/>\n <\/span>\n <\/div>\n<\/body>\n<\/html>\n\n\"} );\n return (deliver);\n}\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"2381b24f78f0a08bfbf772c6c5a822c841922029","subject":"Bypass cache for users that have or are logged in","message":"Bypass cache for users that have or are logged in\n","repos":"evolution\/genesis-wordpress,evolution\/wordpress,genesis\/wordpress,evolution\/genesis-wordpress,jalevin\/wordpress,jalevin\/wordpress,evolution\/wordpress,genesis\/wordpress,jalevin\/wordpress,evolution\/wordpress,genesis\/wordpress,evolution\/genesis-wordpress,evolution\/genesis-wordpress,evolution\/genesis-wordpress,jalevin\/wordpress,genesis\/wordpress,evolution\/wordpress,genesis\/wordpress,evolution\/genesis-wordpress,jalevin\/wordpress,genesis\/wordpress,evolution\/wordpress","old_file":"provisioning\/roles\/varnish\/files\/etc-varnish\/conf.d\/receive\/wordpress.vcl","new_file":"provisioning\/roles\/varnish\/files\/etc-varnish\/conf.d\/receive\/wordpress.vcl","new_contents":"# Pass all local or login\/admin requests straight through\nif (req.http.Host ~ \"^local\\.\" || (req.url ~ \"wp-(login|admin)\")) {\n return (pass);\n}\n\nif (req.http.Cookie ~ \"^wp-\" || req.http.Cookie ~ \"^wordpress_\") {\n return (pass);\n}\n\n# Drop any cookies sent to Wordpress.\nif (!(req.url ~ \"wp-(login|admin)\")) {\n unset req.http.Cookie;\n}\n\n# Anything else left?\nif (!req.http.Cookie) {\n unset req.http.Cookie;\n}\n\n# Try a cache-lookup\nreturn (lookup);\n","old_contents":"# Pass all local or login\/admin requests straight through\nif (req.http.Host ~ \"^local\\.\" || (req.url ~ \"wp-(login|admin)\")) {\n return (pass);\n}\n\n# Drop any cookies sent to Wordpress.\nif (!(req.url ~ \"wp-(login|admin)\")) {\n unset req.http.Cookie;\n}\n\n# Anything else left?\nif (!req.http.Cookie) {\n unset req.http.Cookie;\n}\n\n# Try a cache-lookup\nreturn (lookup);\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"8eecc22816db57e8e90cd2b8075bcf92b1a0a610","subject":"Reordered diagnostic responses for clarity.","message":"Reordered diagnostic responses for clarity.\n","repos":"gotofbi\/ansible-varnish,gotofbi\/ansible-varnish,colstrom\/ansible-varnish,telusdigital\/ansible-varnish,kkwoker\/ansible-varnish,noqcks\/ansible-varnish,killerwails\/ansible-varnish,killerwails\/ansible-varnish","old_file":"templates\/etc\/varnish\/default.vcl","new_file":"templates\/etc\/varnish\/default.vcl","new_contents":"vcl 4.0;\n\nimport directors;\nimport std;\n\n###\n# Varnish Documentation\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-built-in-subs.html\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/reference\/vcl.html\n##\n\n{% for backend in varnish_backend_hosts %}\nbackend application_{{ loop.index }} {\n .host = \"{{ backend }}\";\n .port = \"{{ varnish_backend_port }}\";\n{% if varnish_health_checks_enabled %}\n .probe = {\n .url = \"{{ varnish_health_check_url }}\";\n .interval = {{ varnish_health_check_interval }};\n .timeout = {{ varnish_health_check_timeout }};\n .window = {{ varnish_health_check_window }};\n .threshold = {{ varnish_health_check_threshold }};\n }\n{% endif %}\n}\n{% endfor %}\n\n###\n# vcl_init\n# Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n###\n# The vcl_init subroutine may terminate with calling return() with one of the following keywords:\n#\n# ok\n# Normal return, VCL continues loading.\n##\n\nsub vcl_init {\n new application = directors.round_robin();\n{% for backend in varnish_backend_hosts %}\n application.add_backend(application_{{ loop.index }});\n{% endfor %}\n}\n\n###\n# vcl_recv\n# Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use. \n# It is also used to modify the request\n###\n# The vcl_recv subroutine may terminate with calling return() on one of the following keywords:\n#\n# synth(status code, reason)\n# Return a synthetic object with the specified status code to the client and abandon the request.\n# pass\n# Switch to pass mode. Control will eventually pass to vcl_pass.\n# pipe\n# Switch to pipe mode. Control will eventually pass to vcl_pipe.\n# hash\n# Continue processing the object as a potential candidate for caching. Passes the control over to vcl_hash.\n# purge\n# Purge the object and it's variants. Control passes through vcl_hash to vcl_purge.\n#\n\nsub vcl_recv {\n{% if varnish_blacklist_enabled %}\n if ((req.url ~ \"{{ varnish_blacklist_regexp }}\")) {\n return(pass);\n } else {\n{% if varnish_discards_client_cookies %}\n unset req.http.Cookie;\n{% endif %}\n }\n{% endif %}\n\n set req.backend_hint = application.backend();\n}\n\n###\n# vcl_hit\n# Called when a cache lookup is successful.\n###\n# The vcl_hit subroutine may terminate with calling return() with one of the following keywords:\n#\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n# deliver\n# Deliver the object. Control passes to vcl_deliver.\n# synth(status code, reason)\n# Return the specified status code to the client and abandon the request.\n###\n\nsub vcl_hit {\n if (obj.ttl > 0s) {\n return (deliver);\n }\n{% if varnish_health_checks_enabled %}\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (fetch);\n }\n{% else %}\n if (obj.ttl + obj.grace > 0s) {\n return (deliver);\n }\n\n return (fetch);\n{% endif %}\n}\n\n###\n# vcl_backend_response\n# Called after the response headers has been successfully retrieved from the backend.\n###\n# The vcl_backend_response subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Possibly insert the object into the cache, then deliver it to the Control will eventually pass to vcl_deliver.\n# abandon\n# Abandon the backend request and generates an error.\n# retry\n# Retry the backend transaction. Increases the retries counter. If the number of retries is higher than max_retries Varnish emits a guru meditation error.\n###\n\nsub vcl_backend_response {\n{% if varnish_blacklist_enabled %}\n if (bereq.url ~ \"{{ varnish_blacklist_regexp }}\") {\n set beresp.http.X-Cacheable = \"NO:Path in Blacklist\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n }\n{% endif %}\n\n{% if varnish_cache_diagnostics_enabled %}\n if (bereq.http.Cookie) {\n set beresp.http.X-Cacheable = \"NO:Cookie in Request\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO:Set-Cookie in Response\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.X-No-Cache) {\n set beresp.http.X-Cacheable = \"NO:X-No-Cache\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.ttl <= 0s) {\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n{% endif %}\n\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n\n set beresp.grace = {{ varnish_grace_period }};\n}\n\n###\n# vcl_deliver\n# Called before a cached object is delivered to the client.\n###\n# The vcl_deliver subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Deliver the object to the client.\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n###\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n","old_contents":"vcl 4.0;\n\nimport directors;\nimport std;\n\n###\n# Varnish Documentation\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-built-in-subs.html\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/reference\/vcl.html\n##\n\n{% for backend in varnish_backend_hosts %}\nbackend application_{{ loop.index }} {\n .host = \"{{ backend }}\";\n .port = \"{{ varnish_backend_port }}\";\n{% if varnish_health_checks_enabled %}\n .probe = {\n .url = \"{{ varnish_health_check_url }}\";\n .interval = {{ varnish_health_check_interval }};\n .timeout = {{ varnish_health_check_timeout }};\n .window = {{ varnish_health_check_window }};\n .threshold = {{ varnish_health_check_threshold }};\n }\n{% endif %}\n}\n{% endfor %}\n\n###\n# vcl_init\n# Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n###\n# The vcl_init subroutine may terminate with calling return() with one of the following keywords:\n#\n# ok\n# Normal return, VCL continues loading.\n##\n\nsub vcl_init {\n new application = directors.round_robin();\n{% for backend in varnish_backend_hosts %}\n application.add_backend(application_{{ loop.index }});\n{% endfor %}\n}\n\n###\n# vcl_recv\n# Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use. \n# It is also used to modify the request\n###\n# The vcl_recv subroutine may terminate with calling return() on one of the following keywords:\n#\n# synth(status code, reason)\n# Return a synthetic object with the specified status code to the client and abandon the request.\n# pass\n# Switch to pass mode. Control will eventually pass to vcl_pass.\n# pipe\n# Switch to pipe mode. Control will eventually pass to vcl_pipe.\n# hash\n# Continue processing the object as a potential candidate for caching. Passes the control over to vcl_hash.\n# purge\n# Purge the object and it's variants. Control passes through vcl_hash to vcl_purge.\n#\n\nsub vcl_recv {\n{% if varnish_blacklist_enabled %}\n if ((req.url ~ \"{{ varnish_blacklist_regexp }}\")) {\n return(pass);\n } else {\n{% if varnish_discards_client_cookies %}\n unset req.http.Cookie;\n{% endif %}\n }\n{% endif %}\n\n set req.backend_hint = application.backend();\n}\n\n###\n# vcl_hit\n# Called when a cache lookup is successful.\n###\n# The vcl_hit subroutine may terminate with calling return() with one of the following keywords:\n#\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n# deliver\n# Deliver the object. Control passes to vcl_deliver.\n# synth(status code, reason)\n# Return the specified status code to the client and abandon the request.\n###\n\nsub vcl_hit {\n if (obj.ttl > 0s) {\n return (deliver);\n }\n{% if varnish_health_checks_enabled %}\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (fetch);\n }\n{% else %}\n if (obj.ttl + obj.grace > 0s) {\n return (deliver);\n }\n\n return (fetch);\n{% endif %}\n}\n\n###\n# vcl_backend_response\n# Called after the response headers has been successfully retrieved from the backend.\n###\n# The vcl_backend_response subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Possibly insert the object into the cache, then deliver it to the Control will eventually pass to vcl_deliver.\n# abandon\n# Abandon the backend request and generates an error.\n# retry\n# Retry the backend transaction. Increases the retries counter. If the number of retries is higher than max_retries Varnish emits a guru meditation error.\n###\n\nsub vcl_backend_response {\n{% if varnish_blacklist_enabled %}\n if (bereq.url ~ \"{{ varnish_blacklist_regexp }}\") {\n set beresp.http.X-Cacheable = \"NO:URL in Blacklist\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n }\n{% endif %}\n\n{% if varnish_cache_diagnostics_enabled %}\n if (beresp.ttl <= 0s) {\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (bereq.http.Cookie) {\n set beresp.http.X-Cacheable = \"NO:Cookie in Request\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO:Set-Cookie in Response\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.X-No-Cache) {\n set beresp.http.X-Cacheable = \"NO:X-No-Cache\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n{% endif %}\n\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n\n set beresp.grace = {{ varnish_grace_period }};\n}\n\n###\n# vcl_deliver\n# Called before a cached object is delivered to the client.\n###\n# The vcl_deliver subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Deliver the object to the client.\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n###\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"7c0ce5339ed19f0016e8ec376a3267df03410f19","subject":"Don't strip query string on \/search?foo=bar (#1507)","message":"Don't strip query string on \/search?foo=bar (#1507)\n\n","repos":"alex\/warehouse,alex\/warehouse,alex\/warehouse,pypa\/warehouse,dstufft\/warehouse,dstufft\/warehouse,pypa\/warehouse,dstufft\/warehouse,dstufft\/warehouse,pypa\/warehouse,alex\/warehouse,alex\/warehouse,pypa\/warehouse","old_file":"vcl\/main.vcl","new_file":"vcl\/main.vcl","new_contents":"\nsub vcl_recv {\n\n # I'm not 100% sure on what this is exactly for, it was taken from the\n # Fastly documentation, however, what I *believe* it does is just ensure\n # that we don't serve a stale copy of the page from the shield node when\n # an edge node is requesting content.\n if (req.http.Fastly-FF) {\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Some (Older) clients will send a hash fragment as part of the URL even\n # though that is a local only modification. This breaks this badly for the\n # files in S3, and in general it's just not needed.\n set req.url = regsub(req.url, \"#.*$\", \"\");\n\n # Fastly does some normalization of the Accept-Encoding header so that it\n # reduces the number of cached copies (when served with the common,\n # Vary: Accept-Encoding) that are cached for any one URL. This makes a lot\n # of sense, except for the fact that we want to enable brotli compression\n # for our static files. Thus we need to work around the normalized encoding\n # in a way that still minimizes cached copies, but which will allow our\n # static files to be served using brotli.\n if (req.url ~ \"^\/static\/\" && req.http.Fastly-Orig-Accept-Encoding) {\n if (req.http.User-Agent ~ \"MSIE 6\") {\n # For that 0.3% of stubborn users out there\n unset req.http.Accept-Encoding;\n } elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"br\") {\n set req.http.Accept-Encoding = \"br\";\n } elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n\n # Most of the URLs in Warehouse do not support or require any sort of query\n # parameter. If we strip these at the edge then we'll increase our cache\n # efficiency when they won't otherwise change the output of the pages.\n #\n # This will match any URL except those that start with:\n #\n # * \/search\/\n # * \/account\/login\/\n # * \/account\/logout\/\n # * \/account\/register\/\n # * \/pypi\n if (req.url.path !~ \"^\/(search(\/|$)|account\/(login|logout|register)\/|pypi)\") {\n set req.url = req.url.path;\n }\n\n # Sort all of our query parameters, this will ensure that the same query\n # parameters in a different order will end up being represented as the same\n # thing, reducing cache misses due to ordering differences.\n set req.url = boltsort.sort(req.url);\n\n\n#FASTLY recv\n\n\n # We want to Force SSL for the WebUI by redirecting to the HTTPS version of\n # the page, however for API calls we want to return an error code directing\n # people to instead use HTTPS.\n if (!req.http.Fastly-SSL) {\n\n # The \/simple\/ and \/packages\/ API.\n if (req.url ~ \"^\/(simple|packages)\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy JSON API.\n if (req.url ~ \"^\/pypi\/.+\/json$\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy ?:action= API.\n if (req.url ~ \"^\/pypi.*(\\?|&)=:action\") {\n error 803 \"SSL is required\";\n }\n\n # If we're on the \/pypi page and we've received something other than a\n # GET or HEAD request, then we have no way to determine if a particular\n # request is an API call or not because it'll be in the request body\n # and that isn't available to us here. So in those cases, we won't\n # do a redirect.\n if (req.url ~ \"^\/pypi\") {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n error 801 \"Force SSL\";\n }\n }\n else {\n # This isn't a \/pypi URL so we'll just unconditionally redirect to\n # HTTPS.\n error 801 \"Force SSL\";\n }\n }\n\n # Redirect pypi.io, www.pypi.io, and warehouse.python.org to pypi.org, this\n # is purposely done *after* the HTTPS checks.\n if (std.tolower(req.http.host) ~ \"^(www.pypi.org|(www.)?pypi.io|warehouse.python.org)$\") {\n set req.http.Location = \"https:\/\/pypi.org\" req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n # Redirect warehouse-staging.python.org to test.pypi.io.\n if (std.tolower(req.http.host) ~ \"^(test.pypi.io|warehouse-staging.python.org)$\") {\n set req.http.Location = \"https:\/\/test.pypi.org\" req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n\n # Requests to \/packages\/ get dispatched to Amazon instead of to our typical\n # Origin. This requires a a bit of setup to make it work.\n if (req.http.host ~ \"^(test-)?files.pythonhosted.org$\"\n && req.url ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\") {\n # Setup our environment to better match what S3 expects\/needs\n set req.http.Host = req.http.AWS-Bucket-Name \".s3.amazonaws.com\";\n set req.http.Date = now;\n set req.url = regsuball(req.url, \"\\+\", urlencode(\"+\"));\n\n # Compute the Authorization header that S3 requires to be able to\n # access the files stored there.\n set req.http.Authorization = \"AWS \" req.http.AWS-Access-Key-ID \":\" digest.hmac_sha1_base64(req.http.AWS-Secret-Access-Key, \"GET\" LF LF LF req.http.Date LF \"\/\" req.http.AWS-Bucket-Name req.url.path);\n\n # We don't want to send our Warehouse-Token to S3, so we'll go ahead\n # and remove it.\n unset req.http.Warehouse-Token;\n }\n\n # We no longer need any of these variables, which would exist only to\n # shuffle configuration from the Fastly UI into our VCL.\n unset req.http.AWS-Access-Key-ID;\n unset req.http.AWS-Secret-Access-Key;\n unset req.http.AWS-Bucket-Name;\n\n # We have a number of items that we'll pass back to the origin, but only\n # if we have a Warehouse-Token that will allow them to be accepted.\n if (req.http.Warehouse-Token) {\n # Set a header to tell the backend if we're using https or http.\n if (req.http.Fastly-SSL) {\n set req.http.Warehouse-Proto = \"https\";\n } else {\n set req.http.Warehouse-Proto = \"http\";\n }\n\n # Pass the client IP address back to the backend.\n if (req.http.Fastly-Client-IP) {\n set req.http.Warehouse-IP = req.http.Fastly-Client-IP;\n }\n\n # Pass the real host value back to the backend.\n if (req.http.Host) {\n set req.http.Warehouse-Host = req.http.host;\n }\n }\n\n # On a POST, we want to skip the shielding and hit backends directly.\n if (req.request == \"POST\") {\n set req.backend = F_Heroku;\n }\n\n # Do not bother to attempt to run the caching mechanisms for methods that\n # are not generally safe to cache.\n if (req.request != \"HEAD\" &&\n req.request != \"GET\" &&\n req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n # We don't ever want to cache our health URL. Outside systems should be\n # able to use it to reach past Fastly and get an end to end health check.\n if (req.url == \"\/_health\/\") {\n return(pass);\n }\n\n # Finally, return the default lookup action.\n return(lookup);\n}\n\n\nsub vcl_fetch {\n\n # These are newer kinds of redirects which should be able to be cached by\n # default, even though Fastly doesn't currently have them in their default\n # list of cacheable status codes.\n if (http_status_matches(beresp.status, \"303,307,308\")) {\n set beresp.cacheable = true;\n }\n\n # For any 5xx status code we want to see if a stale object exists for it,\n # if so we'll go ahead and serve it.\n if (beresp.status >= 500 && beresp.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n # When delivering a 304 response, we don't always have access to all the\n # headers in the resp because a 304 response is supposed to remove most of\n # the headers. So we'll instead stash these headers on the request so that\n # we can log this data from there instead of from the response.\n if (beresp.http.x-amz-meta-project\n || beresp.http.x-amz-meta-version\n || beresp.http.x-amz-meta-package-type) {\n set req.http.Fastly-amz-meta-project = beresp.http.x-amz-meta-project;\n set req.http.Fastly-amz-meta-version = beresp.http.x-amz-meta-version;\n set req.http.Fastly-amz-meta-package-type = beresp.http.x-amz-meta-package-type;\n }\n\n\n#FASTLY fetch\n\n\n # Trigger a \"SSL is required\" error if the backend has indicated to do so.\n if (beresp.http.X-Fastly-Error == \"803\") {\n error 803 \"SSL is required\";\n }\n\n # If we've gotten a 502 or a 503 from the backend, we'll go ahead and retry\n # the request.\n if ((beresp.status == 502 || beresp.status == 503) &&\n req.restarts < 1 &&\n (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n # If we've restarted, then we'll record the number of restarts.\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n # If there is a Set-Cookie header, we'll ensure that we do not cache the\n # response.\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n # If the response has the private Cache-Control directive then we won't\n # cache it.\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # If we've gotten an error after the restarts we'll deliver the response\n # with a very short cache time.\n if (http_status_matches(beresp.status, \"500,502,503\")) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n # Apply a default TTL if there isn't a max-age or s-maxage.\n if (beresp.http.Expires ||\n beresp.http.Surrogate-Control ~ \"max-age\" ||\n beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # Keep the ttl here\n }\n else {\n # Apply the default ttl\n set beresp.ttl = 60s;\n }\n\n # Actually deliver the fetched response.\n return(deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n # If the object we have isn't cacheable, then just serve it directly\n # without going through any of the caching mechanisms.\n if (!obj.cacheable) {\n return(pass);\n }\n\n return(deliver);\n}\n\n\nsub vcl_deliver {\n # If this is an error and we have a stale response available, restart so\n # that we can pick it up and serve it.\n if (resp.status >= 500 && resp.status < 600) {\n if (stale.exists) {\n restart;\n }\n }\n\n#FASTLY deliver\n\n # Unset headers that we don't need\/want to send on to the client because\n # they are not generally useful.\n unset resp.http.Server;\n unset resp.http.Via;\n\n # Unset a few headers set by Amazon that we don't really have a need\/desire\n # to send to clients.\n unset resp.http.X-AMZ-Replication-Status;\n unset resp.http.X-AMZ-Meta-Python-Version;\n unset resp.http.X-AMZ-Meta-Version;\n unset resp.http.X-AMZ-Meta-Package-Type;\n unset resp.http.X-AMZ-Meta-Project;\n\n # Set our standard security headers, we do this in VCL rather than in\n # Warehouse itself so that we always get these headers, regardless of the\n # origin server being used.\n set resp.http.Strict-Transport-Security = \"max-age=31536000; includeSubDomains; preload\";\n set resp.http.X-Frame-Options = \"deny\";\n set resp.http.X-XSS-Protection = \"1; mode=block\";\n set resp.http.X-Content-Type-Options = \"nosniff\";\n set resp.http.X-Permitted-Cross-Domain-Policies = \"none\";\n\n # Unstash our information about what project\/version\/package-type a\n # particular file download was for.\n if (req.http.Fastly-amz-meta-project\n || req.http.Fastly-amz-meta-version\n || req.http.Fastly-amz-meta-package-type) {\n set resp.http.x-amz-meta-project = req.http.Fastly-amz-meta-project;\n set resp.http.x-amz-meta-version = req.http.Fastly-amz-meta-version;\n set resp.http.x-amz-meta-package-type = req.http.Fastly-amz-meta-package-type;\n }\n\n # If we're not executing a shielding request, and the URL is one of our file\n # URLs, and it's a GET request, and the response is either a 200 or a 304\n # then we want to log an event stating that a download has taken place.\n if (!req.http.Fastly-FF\n && std.tolower(req.http.host) == \"files.pythonhosted.org\"\n && req.url.path ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\"\n && req.request == \"GET\"\n && http_status_matches(resp.status, \"200,304\")) {\n log {\"syslog \"} req.service_id {\" linehaul :: \"} \"2@\" now \"|\" geoip.country_code \"|\" req.url.path \"|\" tls.client.protocol \"|\" tls.client.cipher \"|\" resp.http.x-amz-meta-project \"|\" resp.http.x-amz-meta-version \"|\" resp.http.x-amz-meta-package-type \"|\" req.http.user-agent;\n log {\"syslog \"} req.service_id {\" downloads :: \"} \"2@\" now \"|\" geoip.country_code \"|\" req.url.path \"|\" tls.client.protocol \"|\" tls.client.cipher \"|\" resp.http.x-amz-meta-project \"|\" resp.http.x-amz-meta-version \"|\" resp.http.x-amz-meta-package-type \"|\" req.http.user-agent;\n }\n\n return(deliver);\n}\n\n\nsub vcl_error {\n#FASTLY error\n\n # If we have a 5xx error and there is a stale object available, then we\n # will deliver that stale object.\n if (obj.status >= 500 && obj.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n if (obj.status == 803) {\n set obj.status = 403;\n set obj.response = \"SSL is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic {\"SSL is required.\"};\n return (deliver);\n } else if (obj.status == 750) {\n set obj.status = 301;\n set obj.http.Location = req.http.Location;\n set obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n synthetic {\"<html><head><title>301 Moved Permanently<\/title><\/head><body><center><h1>301 Moved Permanently<\/h1><\/center><\/body><\/html>\"};\n return(deliver);\n }\n\n}\n","old_contents":"\nsub vcl_recv {\n\n # I'm not 100% sure on what this is exactly for, it was taken from the\n # Fastly documentation, however, what I *believe* it does is just ensure\n # that we don't serve a stale copy of the page from the shield node when\n # an edge node is requesting content.\n if (req.http.Fastly-FF) {\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Some (Older) clients will send a hash fragment as part of the URL even\n # though that is a local only modification. This breaks this badly for the\n # files in S3, and in general it's just not needed.\n set req.url = regsub(req.url, \"#.*$\", \"\");\n\n # Fastly does some normalization of the Accept-Encoding header so that it\n # reduces the number of cached copies (when served with the common,\n # Vary: Accept-Encoding) that are cached for any one URL. This makes a lot\n # of sense, except for the fact that we want to enable brotli compression\n # for our static files. Thus we need to work around the normalized encoding\n # in a way that still minimizes cached copies, but which will allow our\n # static files to be served using brotli.\n if (req.url ~ \"^\/static\/\" && req.http.Fastly-Orig-Accept-Encoding) {\n if (req.http.User-Agent ~ \"MSIE 6\") {\n # For that 0.3% of stubborn users out there\n unset req.http.Accept-Encoding;\n } elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"br\") {\n set req.http.Accept-Encoding = \"br\";\n } elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n\n # Most of the URLs in Warehouse do not support or require any sort of query\n # parameter. If we strip these at the edge then we'll increase our cache\n # efficiency when they won't otherwise change the output of the pages.\n #\n # This will match any URL except those that start with:\n #\n # * \/search\/\n # * \/account\/login\/\n # * \/account\/logout\/\n # * \/account\/register\/\n # * \/pypi\n if (req.url !~ \"^\/(search\/|account\/(login|logout|register)\/|pypi)\") {\n set req.url = req.url.path;\n }\n\n # Sort all of our query parameters, this will ensure that the same query\n # parameters in a different order will end up being represented as the same\n # thing, reducing cache misses due to ordering differences.\n set req.url = boltsort.sort(req.url);\n\n\n#FASTLY recv\n\n\n # We want to Force SSL for the WebUI by redirecting to the HTTPS version of\n # the page, however for API calls we want to return an error code directing\n # people to instead use HTTPS.\n if (!req.http.Fastly-SSL) {\n\n # The \/simple\/ and \/packages\/ API.\n if (req.url ~ \"^\/(simple|packages)\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy JSON API.\n if (req.url ~ \"^\/pypi\/.+\/json$\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy ?:action= API.\n if (req.url ~ \"^\/pypi.*(\\?|&)=:action\") {\n error 803 \"SSL is required\";\n }\n\n # If we're on the \/pypi page and we've received something other than a\n # GET or HEAD request, then we have no way to determine if a particular\n # request is an API call or not because it'll be in the request body\n # and that isn't available to us here. So in those cases, we won't\n # do a redirect.\n if (req.url ~ \"^\/pypi\") {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n error 801 \"Force SSL\";\n }\n }\n else {\n # This isn't a \/pypi URL so we'll just unconditionally redirect to\n # HTTPS.\n error 801 \"Force SSL\";\n }\n }\n\n # Redirect pypi.io, www.pypi.io, and warehouse.python.org to pypi.org, this\n # is purposely done *after* the HTTPS checks.\n if (std.tolower(req.http.host) ~ \"^(www.pypi.org|(www.)?pypi.io|warehouse.python.org)$\") {\n set req.http.Location = \"https:\/\/pypi.org\" req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n # Redirect warehouse-staging.python.org to test.pypi.io.\n if (std.tolower(req.http.host) ~ \"^(test.pypi.io|warehouse-staging.python.org)$\") {\n set req.http.Location = \"https:\/\/test.pypi.org\" req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n\n # Requests to \/packages\/ get dispatched to Amazon instead of to our typical\n # Origin. This requires a a bit of setup to make it work.\n if (req.http.host ~ \"^(test-)?files.pythonhosted.org$\"\n && req.url ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\") {\n # Setup our environment to better match what S3 expects\/needs\n set req.http.Host = req.http.AWS-Bucket-Name \".s3.amazonaws.com\";\n set req.http.Date = now;\n set req.url = regsuball(req.url, \"\\+\", urlencode(\"+\"));\n\n # Compute the Authorization header that S3 requires to be able to\n # access the files stored there.\n set req.http.Authorization = \"AWS \" req.http.AWS-Access-Key-ID \":\" digest.hmac_sha1_base64(req.http.AWS-Secret-Access-Key, \"GET\" LF LF LF req.http.Date LF \"\/\" req.http.AWS-Bucket-Name req.url.path);\n\n # We don't want to send our Warehouse-Token to S3, so we'll go ahead\n # and remove it.\n unset req.http.Warehouse-Token;\n }\n\n # We no longer need any of these variables, which would exist only to\n # shuffle configuration from the Fastly UI into our VCL.\n unset req.http.AWS-Access-Key-ID;\n unset req.http.AWS-Secret-Access-Key;\n unset req.http.AWS-Bucket-Name;\n\n # We have a number of items that we'll pass back to the origin, but only\n # if we have a Warehouse-Token that will allow them to be accepted.\n if (req.http.Warehouse-Token) {\n # Set a header to tell the backend if we're using https or http.\n if (req.http.Fastly-SSL) {\n set req.http.Warehouse-Proto = \"https\";\n } else {\n set req.http.Warehouse-Proto = \"http\";\n }\n\n # Pass the client IP address back to the backend.\n if (req.http.Fastly-Client-IP) {\n set req.http.Warehouse-IP = req.http.Fastly-Client-IP;\n }\n\n # Pass the real host value back to the backend.\n if (req.http.Host) {\n set req.http.Warehouse-Host = req.http.host;\n }\n }\n\n # On a POST, we want to skip the shielding and hit backends directly.\n if (req.request == \"POST\") {\n set req.backend = F_Heroku;\n }\n\n # Do not bother to attempt to run the caching mechanisms for methods that\n # are not generally safe to cache.\n if (req.request != \"HEAD\" &&\n req.request != \"GET\" &&\n req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n # We don't ever want to cache our health URL. Outside systems should be\n # able to use it to reach past Fastly and get an end to end health check.\n if (req.url == \"\/_health\/\") {\n return(pass);\n }\n\n # Finally, return the default lookup action.\n return(lookup);\n}\n\n\nsub vcl_fetch {\n\n # These are newer kinds of redirects which should be able to be cached by\n # default, even though Fastly doesn't currently have them in their default\n # list of cacheable status codes.\n if (http_status_matches(beresp.status, \"303,307,308\")) {\n set beresp.cacheable = true;\n }\n\n # For any 5xx status code we want to see if a stale object exists for it,\n # if so we'll go ahead and serve it.\n if (beresp.status >= 500 && beresp.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n # When delivering a 304 response, we don't always have access to all the\n # headers in the resp because a 304 response is supposed to remove most of\n # the headers. So we'll instead stash these headers on the request so that\n # we can log this data from there instead of from the response.\n if (beresp.http.x-amz-meta-project\n || beresp.http.x-amz-meta-version\n || beresp.http.x-amz-meta-package-type) {\n set req.http.Fastly-amz-meta-project = beresp.http.x-amz-meta-project;\n set req.http.Fastly-amz-meta-version = beresp.http.x-amz-meta-version;\n set req.http.Fastly-amz-meta-package-type = beresp.http.x-amz-meta-package-type;\n }\n\n\n#FASTLY fetch\n\n\n # Trigger a \"SSL is required\" error if the backend has indicated to do so.\n if (beresp.http.X-Fastly-Error == \"803\") {\n error 803 \"SSL is required\";\n }\n\n # If we've gotten a 502 or a 503 from the backend, we'll go ahead and retry\n # the request.\n if ((beresp.status == 502 || beresp.status == 503) &&\n req.restarts < 1 &&\n (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n # If we've restarted, then we'll record the number of restarts.\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n # If there is a Set-Cookie header, we'll ensure that we do not cache the\n # response.\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n # If the response has the private Cache-Control directive then we won't\n # cache it.\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # If we've gotten an error after the restarts we'll deliver the response\n # with a very short cache time.\n if (http_status_matches(beresp.status, \"500,502,503\")) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n # Apply a default TTL if there isn't a max-age or s-maxage.\n if (beresp.http.Expires ||\n beresp.http.Surrogate-Control ~ \"max-age\" ||\n beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # Keep the ttl here\n }\n else {\n # Apply the default ttl\n set beresp.ttl = 60s;\n }\n\n # Actually deliver the fetched response.\n return(deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n # If the object we have isn't cacheable, then just serve it directly\n # without going through any of the caching mechanisms.\n if (!obj.cacheable) {\n return(pass);\n }\n\n return(deliver);\n}\n\n\nsub vcl_deliver {\n # If this is an error and we have a stale response available, restart so\n # that we can pick it up and serve it.\n if (resp.status >= 500 && resp.status < 600) {\n if (stale.exists) {\n restart;\n }\n }\n\n#FASTLY deliver\n\n # Unset headers that we don't need\/want to send on to the client because\n # they are not generally useful.\n unset resp.http.Server;\n unset resp.http.Via;\n\n # Unset a few headers set by Amazon that we don't really have a need\/desire\n # to send to clients.\n unset resp.http.X-AMZ-Replication-Status;\n unset resp.http.X-AMZ-Meta-Python-Version;\n unset resp.http.X-AMZ-Meta-Version;\n unset resp.http.X-AMZ-Meta-Package-Type;\n unset resp.http.X-AMZ-Meta-Project;\n\n # Set our standard security headers, we do this in VCL rather than in\n # Warehouse itself so that we always get these headers, regardless of the\n # origin server being used.\n set resp.http.Strict-Transport-Security = \"max-age=31536000; includeSubDomains; preload\";\n set resp.http.X-Frame-Options = \"deny\";\n set resp.http.X-XSS-Protection = \"1; mode=block\";\n set resp.http.X-Content-Type-Options = \"nosniff\";\n set resp.http.X-Permitted-Cross-Domain-Policies = \"none\";\n\n # Unstash our information about what project\/version\/package-type a\n # particular file download was for.\n if (req.http.Fastly-amz-meta-project\n || req.http.Fastly-amz-meta-version\n || req.http.Fastly-amz-meta-package-type) {\n set resp.http.x-amz-meta-project = req.http.Fastly-amz-meta-project;\n set resp.http.x-amz-meta-version = req.http.Fastly-amz-meta-version;\n set resp.http.x-amz-meta-package-type = req.http.Fastly-amz-meta-package-type;\n }\n\n # If we're not executing a shielding request, and the URL is one of our file\n # URLs, and it's a GET request, and the response is either a 200 or a 304\n # then we want to log an event stating that a download has taken place.\n if (!req.http.Fastly-FF\n && std.tolower(req.http.host) == \"files.pythonhosted.org\"\n && req.url.path ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\"\n && req.request == \"GET\"\n && http_status_matches(resp.status, \"200,304\")) {\n log {\"syslog \"} req.service_id {\" linehaul :: \"} \"2@\" now \"|\" geoip.country_code \"|\" req.url.path \"|\" tls.client.protocol \"|\" tls.client.cipher \"|\" resp.http.x-amz-meta-project \"|\" resp.http.x-amz-meta-version \"|\" resp.http.x-amz-meta-package-type \"|\" req.http.user-agent;\n log {\"syslog \"} req.service_id {\" downloads :: \"} \"2@\" now \"|\" geoip.country_code \"|\" req.url.path \"|\" tls.client.protocol \"|\" tls.client.cipher \"|\" resp.http.x-amz-meta-project \"|\" resp.http.x-amz-meta-version \"|\" resp.http.x-amz-meta-package-type \"|\" req.http.user-agent;\n }\n\n return(deliver);\n}\n\n\nsub vcl_error {\n#FASTLY error\n\n # If we have a 5xx error and there is a stale object available, then we\n # will deliver that stale object.\n if (obj.status >= 500 && obj.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n if (obj.status == 803) {\n set obj.status = 403;\n set obj.response = \"SSL is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic {\"SSL is required.\"};\n return (deliver);\n } else if (obj.status == 750) {\n set obj.status = 301;\n set obj.http.Location = req.http.Location;\n set obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n synthetic {\"<html><head><title>301 Moved Permanently<\/title><\/head><body><center><h1>301 Moved Permanently<\/h1><\/center><\/body><\/html>\"};\n return(deliver);\n }\n\n}\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"c468a9101be44050582bfba22d1edc2012d931d8","subject":"Indent according to Varnish coding standards","message":"Indent according to Varnish coding standards\n\nThanks to Sergey Syrota for pointing this out.\n","repos":"varnish\/varnish-devicedetect,varnish\/varnish-devicedetect,kevinquinnyo\/varnish-devicedetect,wikp\/varnish-devicedetect,kevinquinnyo\/varnish-devicedetect,wikp\/varnish-devicedetect","old_file":"devicedetect.vcl","new_file":"devicedetect.vcl","new_contents":"#\n# detectdevice.vcl - regex based device detection for Varnish\n# http:\/\/github.com\/varnish\/varnish-devicedetect\/\n#\n# Author: Lasse Karstensen <lasse@varnish-software.com>\n\nsub devicedetect {\n\tunset req.http.X-UA-Device;\n\tset req.http.X-UA-Device = \"pc\";\n\n \tif (req.http.User-Agent ~ \"(?i)(ads|google|bing|msn|yandex|baidu|ro|career|)bot\" ||\n\t req.http.User-Agent ~ \"(?i)(baidu|jike|symantec)spider\" ||\n\t req.http.User-Agent ~ \"(?i)scanner\" ||\n\t req.http.User-Agent ~ \"(?i)(web)crawler\") {\n\t\tset req.http.X-UA-Device = \"bot\"; }\n\telsif (req.http.User-Agent ~ \"(?i)ip(hone|od)\") { set req.http.X-UA-Device = \"mobile-iphone\"; }\n\telsif (req.http.User-Agent ~ \"(?i)ipad\") { set req.http.X-UA-Device = \"tablet-ipad\"; }\n\t# how do we differ between an android phone and an android tablet?\n\t# http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent\n\telsif (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") { set req.http.X-UA-Device = \"mobile-android\"; }\n\t# android 3\/honeycomb was just about tablet-only, and any phones will probably handle a bigger page layout.\n\telsif (req.http.User-Agent ~ \"(?i)android 3\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t# may very well give false positives towards android tablets. Suggestions welcome.\n\telsif (req.http.User-Agent ~ \"(?i)android\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\telsif (req.http.User-Agent ~ \"^HTC\" ||\n\t req.http.User-Agent ~ \"Fennec\" ||\n\t req.http.User-Agent ~ \"IEMobile\" ||\n\t req.http.User-Agent ~ \"BlackBerry\" ||\n\t req.http.User-Agent ~ \"SymbianOS.*AppleWebKit\" ||\n\t req.http.User-Agent ~ \"Opera Mobi\") {\n\t\tset req.http.X-UA-Device = \"mobile-smartphone\";\n\t}\n\telsif (req.http.User-Agent ~ \"(?i)symbian\" ||\n\t req.http.User-Agent ~ \"(?i)^sonyericsson\" ||\n\t req.http.User-Agent ~ \"(?i)^nokia\" ||\n\t req.http.User-Agent ~ \"(?i)^samsung\" ||\n\t req.http.User-Agent ~ \"(?i)^lg\" ||\n\t req.http.User-Agent ~ \"(?i)bada\" ||\n\t req.http.User-Agent ~ \"(?i)blazer\" ||\n\t req.http.User-Agent ~ \"(?i)cellphone\" ||\n\t req.http.User-Agent ~ \"(?i)iemobile\" ||\n\t req.http.User-Agent ~ \"(?i)midp-2.0\" ||\n\t req.http.User-Agent ~ \"(?i)u990\" ||\n\t req.http.User-Agent ~ \"(?i)netfront\" ||\n\t req.http.User-Agent ~ \"(?i)opera mini\" ||\n\t req.http.User-Agent ~ \"(?i)palm\" ||\n\t req.http.User-Agent ~ \"(?i)nintendo wii\" ||\n\t req.http.User-Agent ~ \"(?i)playstation portable\" ||\n\t req.http.User-Agent ~ \"(?i)portalmmm\" ||\n\t req.http.User-Agent ~ \"(?i)proxinet\" ||\n\t req.http.User-Agent ~ \"(?i)sonyericsson\" ||\n\t req.http.User-Agent ~ \"(?i)symbian\" ||\n\t req.http.User-Agent ~ \"(?i)windows\\ ?ce\" ||\n\t req.http.User-Agent ~ \"(?i)winwap\" ||\n\t req.http.User-Agent ~ \"(?i)eudoraweb\" ||\n\t req.http.User-Agent ~ \"(?i)htc\" ||\n\t req.http.User-Agent ~ \"(?i)240x320\" ||\n\t req.http.User-Agent ~ \"(?i)avantgo\") {\n \tset req.http.X-UA-Device = \"mobile-generic\";\n\t}\n\t# handle overrides\n\tif (req.http.Cookie ~ \"(i?)X-UA-Device-force\") {\n\t\t# ;?? means zero or one ;, non-greedy to match the first.\n\t\tset req.http.X-UA-Device = regsub(req.http.Cookie, \"(?i).*X-UA-Device-force=([^;]+);??.*\", \"\\1\");\n\t\t# Clean up the cookie header to allow for caching.\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|; ) *X-UA-Device-force=[^;]+;? *\", \"\\1\");\n\t\tif (req.http.Cookie ~ \"^ *$\") { unset req.http.Cookie; }\n\t}\n}\n\n","old_contents":"#\n# detectdevice.vcl - regex based device detection for Varnish\n# http:\/\/github.com\/varnish\/varnish-devicedetect\/\n#\n# Author: Lasse Karstensen <lasse@varnish-software.com>\n\nsub devicedetect {\n unset req.http.X-UA-Device;\n set req.http.X-UA-Device = \"pc\";\n\n if (req.http.User-Agent ~ \"(?i)(ads|google|bing|msn|yandex|baidu|ro|career|)bot\" ||\n\treq.http.User-Agent ~ \"(?i)(baidu|jike|symantec)spider\" ||\n\treq.http.User-Agent ~ \"(?i)scanner\" ||\n\treq.http.User-Agent ~ \"(?i)(web)crawler\") {\n\tset req.http.X-UA-Device = \"bot\"; }\n elsif (req.http.User-Agent ~ \"(?i)ip(hone|od)\") { set req.http.X-UA-Device = \"mobile-iphone\"; }\n elsif (req.http.User-Agent ~ \"(?i)ipad\") { set req.http.X-UA-Device = \"tablet-ipad\"; }\n # how do we differ between an android phone and an android tablet?\n # http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent\n elsif (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") { set req.http.X-UA-Device = \"mobile-android\"; }\n # android 3\/honeycomb was just about tablet-only, and any phones will probably handle a bigger page layout.\n elsif (req.http.User-Agent ~ \"(?i)android 3\") { set req.http.X-UA-Device = \"tablet-android\"; }\n # may very well give false positives towards android tablets. Suggestions welcome.\n elsif (req.http.User-Agent ~ \"(?i)android\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\n elsif (req.http.User-Agent ~ \"^HTC\" ||\n req.http.User-Agent ~ \"Fennec\" ||\n req.http.User-Agent ~ \"IEMobile\" ||\n req.http.User-Agent ~ \"BlackBerry\" ||\n req.http.User-Agent ~ \"SymbianOS.*AppleWebKit\" ||\n req.http.User-Agent ~ \"Opera Mobi\") {\n set req.http.X-UA-Device = \"mobile-smartphone\";\n }\n elsif (req.http.User-Agent ~ \"(?i)symbian\" ||\n req.http.User-Agent ~ \"(?i)^sonyericsson\" ||\n req.http.User-Agent ~ \"(?i)^nokia\" ||\n req.http.User-Agent ~ \"(?i)^samsung\" ||\n req.http.User-Agent ~ \"(?i)^lg\" ||\n\treq.http.User-Agent ~ \"(?i)bada\" ||\n\treq.http.User-Agent ~ \"(?i)blazer\" ||\n\treq.http.User-Agent ~ \"(?i)cellphone\" ||\n\treq.http.User-Agent ~ \"(?i)iemobile\" ||\n\treq.http.User-Agent ~ \"(?i)midp-2.0\" ||\n\treq.http.User-Agent ~ \"(?i)u990\" ||\n\treq.http.User-Agent ~ \"(?i)netfront\" ||\n\treq.http.User-Agent ~ \"(?i)opera mini\" ||\n\treq.http.User-Agent ~ \"(?i)palm\" ||\n\treq.http.User-Agent ~ \"(?i)nintendo wii\" ||\n\treq.http.User-Agent ~ \"(?i)playstation portable\" ||\n\treq.http.User-Agent ~ \"(?i)portalmmm\" ||\n\treq.http.User-Agent ~ \"(?i)proxinet\" ||\n\treq.http.User-Agent ~ \"(?i)sonyericsson\" ||\n\treq.http.User-Agent ~ \"(?i)symbian\" ||\n\treq.http.User-Agent ~ \"(?i)windows\\ ?ce\" ||\n\treq.http.User-Agent ~ \"(?i)winwap\" ||\n\treq.http.User-Agent ~ \"(?i)eudoraweb\" ||\n\treq.http.User-Agent ~ \"(?i)htc\" ||\n\treq.http.User-Agent ~ \"(?i)240x320\" ||\n\treq.http.User-Agent ~ \"(?i)avantgo\") {\n set req.http.X-UA-Device = \"mobile-generic\";\n }\n # handle overrides\n if (req.http.Cookie ~ \"(i?)X-UA-Device-force\") {\n # ;?? means zero or one ;, non-greedy to match the first.\n set req.http.X-UA-Device = regsub(req.http.Cookie, \"(?i).*X-UA-Device-force=([^;]+);??.*\", \"\\1\");\n # Clean up the cookie header to allow for caching.\n set req.http.Cookie = regsuball(req.http.Cookie, \"(^|; ) *X-UA-Device-force=[^;]+;? *\", \"\\1\");\n if (req.http.Cookie ~ \"^ *$\") { unset req.http.Cookie; }\n }\n}\n\n# vim: sw=4:tw=120\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"434a8209d79be9e828b435f3a84e43fe74fd1934","subject":"give the hash to all requests","message":"give the hash to all requests\n","repos":"JakeChampion\/polyfill-service,JakeChampion\/polyfill-service","old_file":"packages\/polyfill-service\/fastly\/vcl\/polyfill-service-v3.vcl","new_file":"packages\/polyfill-service\/fastly\/vcl\/polyfill-service-v3.vcl","new_contents":"sub set_backend {\n\t# Calculate the ideal region to route the request to.\n\tdeclare local var.region STRING;\n\tif (server.region ~ \"(APAC|Asia|North-America|South-America|US-Central|US-East|US-West)\") {\n\t\tset var.region = \"US\";\n\t} else {\n\t\tset var.region = \"EU\";\n\t}\n\n\t# Gather the health of the shields and origins.\n\tdeclare local var.v3_eu_is_healthy BOOL;\n\tset req.backend = F_v3_eu;\n\tset var.v3_eu_is_healthy = req.backend.healthy;\n\n\tdeclare local var.v3_us_is_healthy BOOL;\n\tset req.backend = F_v3_us;\n\tset var.v3_us_is_healthy = req.backend.healthy;\n\n\t# Set some sort of default, that shouldn't get used.\n\tset req.backend = F_v3_eu;\n\n\t# Route EU requests to the nearest healthy shield or origin.\n\tif (var.region == \"EU\") {\n\t\tif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_eu;\n\t\t}\n\t}\n\n\t# Route US requests to the nearest healthy shield or origin.\n\tif (var.region == \"US\") {\n\t\tif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_us;\n\t\t}\n\t}\n\n\t# Persist the decision so we can debug the result.\n\tset req.http.Debug-Backend = req.backend;\n\n\t# The Fastly macro is inserted after the backend is selected because the\n\t# macro has the code to select the correct req.http.Host value based on the backend.\n\t#FASTLY recv\n}\n\nsub vcl_recv {\n\t# Run this VCL only if the path is not to the polyfill-service v2 server\n\tif ((req.http.Orig-URL ~ \"^\/v3\/\") || req.http.Orig-URL ~ \"^(?!\/v2).+\" && req.http.Orig-URL ~ \"^(?!\/__health).+\" && req.http.Orig-URL ~ \"^(?!\/test\/libs\/proclaim\/proclaim.js).+\" && req.http.Orig-URL ~ \"^(?!\/test\/libs\/mocha\/mocha.js).+\" && req.http.Orig-URL ~ \"^(?!\/test\/libs\/mocha\/mocha.css).+\" && req.http.Orig-URL ~ \"^(?!\/__gtg).+\") {\n\t\tif (req.http.Fastly-Debug) {\n\t\t\tcall breadcrumb_recv;\n\t\t}\n\n\t\tif (req.method != \"GET\" && req.method != \"HEAD\" && req.method != \"OPTIONS\") {\n\t\t\terror 911;\n\t\t}\n\n\t\tif (req.method == \"OPTIONS\") {\n \t\t\terror 912;\n\t\t}\n\n\t\tif (req.http.Orig-URL ~ \"^\/v3\/polyfill(\\.min)?\\.js\") {\n\t\t\tcall normalise_querystring_parameters_for_polyfill_bundle;\n\t\t}\n\n\t\tif (req.http.Orig-URL ~ \"^\/test\/(director|tests?)\/?\") {\n\t\t\tdeclare local var.ua STRING;\n\t\t\tset var.ua = urlencode(urldecode(subfield(req.url.qs, \"ua\", \"&\")));\n\t\t\tif (var.ua == \"\") {\n\t\t\t\tcall normalise_user_agent;\n\t\t\t\tset req.url = querystring.set(req.url, \"ua\", req.http.Normalized-User-Agent);\n\t\t\t}\n\t\t}\n\n\t\t# Sort the querystring parameters alphabetically to improve chances of hitting a cached copy.\n\t\t# If querystring is empty, remove the ? from the url.\n\t\tset req.url = querystring.clean(querystring.sort(req.url));\n\t\tcall set_backend;\n\t}\n}\n\nsub vcl_hash {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_hash;\n\t}\n\n\t# We are not adding req.http.host to the hash because we want https:\/\/cdn.polyfill.io and https:\/\/polyfill.io to be a single object in the cache.\n\t# set req.hash += req.http.host;\n\tset req.hash += req.url;\n\t# We include return(hash) to stop the function falling through to the default VCL built into varnish, which for vcl_hash will add req.url and req.http.Host to the hash.\n\treturn(hash);\n}\n\nsub vcl_miss {\n\t# Run this VCL only if the path is not to the polyfill-service v2 server\n\tif ((req.http.Orig-URL ~ \"^\/v3\/\") || req.http.Orig-URL ~ \"^(?!\/v2).+\" && req.http.Orig-URL ~ \"^(?!\/__health).+\" && req.http.Orig-URL ~ \"^(?!\/test\/libs\/proclaim\/proclaim.js).+\" && req.http.Orig-URL ~ \"^(?!\/test\/libs\/mocha\/mocha.js).+\" && req.http.Orig-URL ~ \"^(?!\/test\/libs\/mocha\/mocha.css).+\" && req.http.Orig-URL ~ \"^(?!\/__gtg).+\") {\n\t\tif (req.http.Fastly-Debug) {\n\t\t\tcall breadcrumb_miss;\n\t\t}\n\t}\n}\n\nsub vcl_pass {\n\t# Run this VCL only if the path is not to the polyfill-service v2 server\n\tif ((req.http.Orig-URL ~ \"^\/v3\/\") || req.http.Orig-URL ~ \"^(?!\/v2).+\" && req.http.Orig-URL ~ \"^(?!\/__health).+\" && req.http.Orig-URL ~ \"^(?!\/test\/libs\/proclaim\/proclaim.js).+\" && req.http.Orig-URL ~ \"^(?!\/test\/libs\/mocha\/mocha.js).+\" && req.http.Orig-URL ~ \"^(?!\/test\/libs\/mocha\/mocha.css).+\" && req.http.Orig-URL ~ \"^(?!\/__gtg).+\") {\n\t\tif (req.http.Fastly-Debug) {\n\t\t\tcall breadcrumb_pass;\n\t\t}\n\t}\n}\n\nsub vcl_fetch {\n\t# Run this VCL only if the path is not to the polyfill-service v2 server\n\tif ((req.http.Orig-URL ~ \"^\/v3\/\") || req.http.Orig-URL ~ \"^(?!\/v2).+\" && req.http.Orig-URL ~ \"^(?!\/__health).+\" && req.http.Orig-URL ~ \"^(?!\/test\/libs\/proclaim\/proclaim.js).+\" && req.http.Orig-URL ~ \"^(?!\/test\/libs\/mocha\/mocha.js).+\" && req.http.Orig-URL ~ \"^(?!\/test\/libs\/mocha\/mocha.css).+\" && req.http.Orig-URL ~ \"^(?!\/__gtg).+\") {\n\t\tif (req.http.Fastly-Debug) {\n\t\t\tcall breadcrumb_fetch;\n\t\t}\n\n\t\t# Ensure the site is only served over HTTPS and reduce the chances of someone performing a MITM attack.\n\t\tset beresp.http.Strict-Transport-Security = \"max-age=31536000; includeSubdomains; preload\";\n\t\t# Enables the cross-site scripting filter built into most modern web browsers.\n\t\tset beresp.http.X-XSS-Protection = \"1; mode=block\";\n\t\t# Prevents MIME-sniffing a response away from the declared content type.\n\t\tset beresp.http.X-Content-Type-Options = \"nosniff\";\n\n\t\t# Allow only content from the site's own origin (this excludes subdomains.)\n\t\t# Don't allow the website to be used within an iframe\n\t\tif (!beresp.http.Content-Security-Policy) {\n\t\t\tset beresp.http.Content-Security-Policy = \"default-src 'self'; font-src 'self' https:\/\/www.ft.com; img-src 'self' https:\/\/www.ft.com; frame-ancestors 'none'; base-uri 'self'; form-action 'self'\";\n\t\t}\n\n\t\t# The Referrer-Policy header governs which referrer information, sent in the Referer header, should be included with requests made.\n\t\t# Send a full URL when performing a same-origin request, but only send the origin of the document for other cases.\n\t\tset beresp.http.Referrer-Policy = \"origin-when-cross-origin\";\n\n\t\t# Enable purging of all objects in the Fastly cache by issuing a purge with the key \"polyfill-service\".\n\t\tif (beresp.http.Surrogate-Key !~ \"\\bpolyfill-service\\b\") {\n set beresp.http.Surrogate-Key = if(beresp.http.Surrogate-Key, beresp.http.Surrogate-Key \" polyfill-service\", \"polyfill-service\");\n }\n\n\t\tset beresp.http.Timing-Allow-Origin = \"*\";\n\n\t\tset beresp.http.Normalized-User-Agent = req.http.Normalized-User-Agent;\n\t\tset beresp.http.Detected-User-Agent = req.http.useragent_parser_family \"\/\" req.http.useragent_parser_major \".\" req.http.useragent_parser_minor \".\" req.http.useragent_parser_patch;\n\t}\n}\n\nsub vcl_deliver {\n\t# Run this VCL only if the path is not to the polyfill-service v2 server\n\tif ((req.http.Orig-URL ~ \"^\/v3\/\") || req.http.Orig-URL ~ \"^(?!\/v2).+\" && req.http.Orig-URL ~ \"^(?!\/__health).+\" && req.http.Orig-URL ~ \"^(?!\/test\/libs\/proclaim\/proclaim.js).+\" && req.http.Orig-URL ~ \"^(?!\/test\/libs\/mocha\/mocha.js).+\" && req.http.Orig-URL ~ \"^(?!\/test\/libs\/mocha\/mocha.css).+\" && req.http.Orig-URL ~ \"^(?!\/__gtg).+\") {\n\t\tif (req.http.Fastly-Debug) {\n\t\t\tcall breadcrumb_deliver;\n\t\t}\n\n\t\tset req.http.Fastly-Force-Shield = \"yes\";\n\n\t\t# Allow cross origin GET, HEAD, and OPTIONS requests to be made.\n\t\tif (req.http.Origin) {\n\t\t\tset resp.http.Access-Control-Allow-Origin = \"*\";\n\t\t\tset resp.http.Access-Control-Allow-Methods = \"GET,HEAD,OPTIONS\";\n\t\t}\n\n\t\tadd resp.http.Server-Timing = fastly_info.state {\", fastly;desc=\"Edge time\";dur=\"} time.elapsed.msec;\n\n\t\tif (req.http.Fastly-Debug) {\n\t\t\tset resp.http.Debug-Backend = req.http.Debug-Backend;\n\t\t\tset resp.http.Debug-Host = req.http.Host;\n\t\t\tset resp.http.Debug-Fastly-Restarts = req.restarts;\n\t\t\tset resp.http.Debug-URL = req.url;\n\t\t\tset resp.http.Debug-Orig-URL = req.http.Orig-URL;\n\t\t\tset resp.http.Debug-VCL-Route = req.http.X-VCL-Route;\n\t\t\tset resp.http.useragent_parser_family = req.http.useragent_parser_family;\n\t\t\tset resp.http.useragent_parser_major = req.http.useragent_parser_major;\n\t\t\tset resp.http.useragent_parser_minor = req.http.useragent_parser_minor;\n\t\t\tset resp.http.useragent_parser_patch = req.http.useragent_parser_patch;\n\t\t} else {\n\t\t\tunset resp.http.Server;\n\t\t\tunset resp.http.Via;\n\t\t\tunset resp.http.X-Cache;\n\t\t\tunset resp.http.X-Cache-Hits;\n\t\t\tunset resp.http.X-Served-By;\n\t\t\tunset resp.http.X-Timer;\n\t\t\tunset resp.http.Fastly-Restarts;\n\t\t}\n\t}\n}\n\nsub vcl_error {\n\tif (obj.status == 911) {\n\t\tset obj.status = 405;\n\t\tset obj.response = \"METHOD NOT ALLOWED\";\n\t\tset obj.http.Content-Type = \"text\/html; charset=utf-8\";\n\t\tset obj.http.Cache-Control = \"private, no-store\";\n\t\tsynthetic req.method \" METHOD NOT ALLOWED\";\n\t\treturn (deliver);\n\t}\n\tif (obj.status == 912) {\n\t\tset obj.status = 200;\n\t\tset obj.response = \"OK\";\n\t\tset obj.http.Allow = \"OPTIONS, GET, HEAD\";\n\t\treturn (deliver);\n\t}\n}\n","old_contents":"sub set_backend {\n\t# Calculate the ideal region to route the request to.\n\tdeclare local var.region STRING;\n\tif (server.region ~ \"(APAC|Asia|North-America|South-America|US-Central|US-East|US-West)\") {\n\t\tset var.region = \"US\";\n\t} else {\n\t\tset var.region = \"EU\";\n\t}\n\n\t# Gather the health of the shields and origins.\n\tdeclare local var.v3_eu_is_healthy BOOL;\n\tset req.backend = F_v3_eu;\n\tset var.v3_eu_is_healthy = req.backend.healthy;\n\n\tdeclare local var.v3_us_is_healthy BOOL;\n\tset req.backend = F_v3_us;\n\tset var.v3_us_is_healthy = req.backend.healthy;\n\n\t# Set some sort of default, that shouldn't get used.\n\tset req.backend = F_v3_eu;\n\n\t# Route EU requests to the nearest healthy shield or origin.\n\tif (var.region == \"EU\") {\n\t\tif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_eu;\n\t\t}\n\t}\n\n\t# Route US requests to the nearest healthy shield or origin.\n\tif (var.region == \"US\") {\n\t\tif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_us;\n\t\t}\n\t}\n\n\t# Persist the decision so we can debug the result.\n\tset req.http.Debug-Backend = req.backend;\n\n\t# The Fastly macro is inserted after the backend is selected because the\n\t# macro has the code to select the correct req.http.Host value based on the backend.\n\t#FASTLY recv\n}\n\nsub vcl_recv {\n\t# Run this VCL only if the path is not to the polyfill-service v2 server\n\tif ((req.http.Orig-URL ~ \"^\/v3\/\") || req.http.Orig-URL ~ \"^(?!\/v2).+\" && req.http.Orig-URL ~ \"^(?!\/__health).+\" && req.http.Orig-URL ~ \"^(?!\/test\/libs\/proclaim\/proclaim.js).+\" && req.http.Orig-URL ~ \"^(?!\/test\/libs\/mocha\/mocha.js).+\" && req.http.Orig-URL ~ \"^(?!\/test\/libs\/mocha\/mocha.css).+\" && req.http.Orig-URL ~ \"^(?!\/__gtg).+\") {\n\t\tif (req.http.Fastly-Debug) {\n\t\t\tcall breadcrumb_recv;\n\t\t}\n\n\t\tif (req.method != \"GET\" && req.method != \"HEAD\" && req.method != \"OPTIONS\") {\n\t\t\terror 911;\n\t\t}\n\n\t\tif (req.method == \"OPTIONS\") {\n \t\t\terror 912;\n\t\t}\n\n\t\tif (req.http.Orig-URL ~ \"^\/v3\/polyfill(\\.min)?\\.js\") {\n\t\t\tcall normalise_querystring_parameters_for_polyfill_bundle;\n\t\t}\n\n\t\tif (req.http.Orig-URL ~ \"^\/test\/(director|tests?)\/?\") {\n\t\t\tdeclare local var.ua STRING;\n\t\t\tset var.ua = urlencode(urldecode(subfield(req.url.qs, \"ua\", \"&\")));\n\t\t\tif (var.ua == \"\") {\n\t\t\t\tcall normalise_user_agent;\n\t\t\t\tset req.url = querystring.set(req.url, \"ua\", req.http.Normalized-User-Agent);\n\t\t\t}\n\t\t}\n\n\t\t# Sort the querystring parameters alphabetically to improve chances of hitting a cached copy.\n\t\t# If querystring is empty, remove the ? from the url.\n\t\tset req.url = querystring.clean(querystring.sort(req.url));\n\t\tcall set_backend;\n\t}\n}\n\nsub vcl_hash {\n\t# Run this VCL only if the path is not to the polyfill-service v2 server\n\tif ((req.http.Orig-URL ~ \"^\/v3\/\") || req.http.Orig-URL ~ \"^(?!\/v2).+\" && req.http.Orig-URL ~ \"^(?!\/__health).+\" && req.http.Orig-URL ~ \"^(?!\/test\/libs\/proclaim\/proclaim.js).+\" && req.http.Orig-URL ~ \"^(?!\/test\/libs\/mocha\/mocha.js).+\" && req.http.Orig-URL ~ \"^(?!\/test\/libs\/mocha\/mocha.css).+\" && req.http.Orig-URL ~ \"^(?!\/__gtg).+\") {\n\t\tif (req.http.Fastly-Debug) {\n\t\t\tcall breadcrumb_hash;\n\t\t}\n\n\t\t# We are not adding req.http.host to the hash because we want https:\/\/cdn.polyfill.io and https:\/\/polyfill.io to be a single object in the cache.\n\t\t# set req.hash += req.http.host;\n\t\tset req.hash += req.url;\n\t\t# We include return(hash) to stop the function falling through to the default VCL built into varnish, which for vcl_hash will add req.url and req.http.Host to the hash.\n\t\treturn(hash);\n\t}\n}\n\nsub vcl_miss {\n\t# Run this VCL only if the path is not to the polyfill-service v2 server\n\tif ((req.http.Orig-URL ~ \"^\/v3\/\") || req.http.Orig-URL ~ \"^(?!\/v2).+\" && req.http.Orig-URL ~ \"^(?!\/__health).+\" && req.http.Orig-URL ~ \"^(?!\/test\/libs\/proclaim\/proclaim.js).+\" && req.http.Orig-URL ~ \"^(?!\/test\/libs\/mocha\/mocha.js).+\" && req.http.Orig-URL ~ \"^(?!\/test\/libs\/mocha\/mocha.css).+\" && req.http.Orig-URL ~ \"^(?!\/__gtg).+\") {\n\t\tif (req.http.Fastly-Debug) {\n\t\t\tcall breadcrumb_miss;\n\t\t}\n\t}\n}\n\nsub vcl_pass {\n\t# Run this VCL only if the path is not to the polyfill-service v2 server\n\tif ((req.http.Orig-URL ~ \"^\/v3\/\") || req.http.Orig-URL ~ \"^(?!\/v2).+\" && req.http.Orig-URL ~ \"^(?!\/__health).+\" && req.http.Orig-URL ~ \"^(?!\/test\/libs\/proclaim\/proclaim.js).+\" && req.http.Orig-URL ~ \"^(?!\/test\/libs\/mocha\/mocha.js).+\" && req.http.Orig-URL ~ \"^(?!\/test\/libs\/mocha\/mocha.css).+\" && req.http.Orig-URL ~ \"^(?!\/__gtg).+\") {\n\t\tif (req.http.Fastly-Debug) {\n\t\t\tcall breadcrumb_pass;\n\t\t}\n\t}\n}\n\nsub vcl_fetch {\n\t# Run this VCL only if the path is not to the polyfill-service v2 server\n\tif ((req.http.Orig-URL ~ \"^\/v3\/\") || req.http.Orig-URL ~ \"^(?!\/v2).+\" && req.http.Orig-URL ~ \"^(?!\/__health).+\" && req.http.Orig-URL ~ \"^(?!\/test\/libs\/proclaim\/proclaim.js).+\" && req.http.Orig-URL ~ \"^(?!\/test\/libs\/mocha\/mocha.js).+\" && req.http.Orig-URL ~ \"^(?!\/test\/libs\/mocha\/mocha.css).+\" && req.http.Orig-URL ~ \"^(?!\/__gtg).+\") {\n\t\tif (req.http.Fastly-Debug) {\n\t\t\tcall breadcrumb_fetch;\n\t\t}\n\n\t\t# Ensure the site is only served over HTTPS and reduce the chances of someone performing a MITM attack.\n\t\tset beresp.http.Strict-Transport-Security = \"max-age=31536000; includeSubdomains; preload\";\n\t\t# Enables the cross-site scripting filter built into most modern web browsers.\n\t\tset beresp.http.X-XSS-Protection = \"1; mode=block\";\n\t\t# Prevents MIME-sniffing a response away from the declared content type.\n\t\tset beresp.http.X-Content-Type-Options = \"nosniff\";\n\n\t\t# Allow only content from the site's own origin (this excludes subdomains.)\n\t\t# Don't allow the website to be used within an iframe\n\t\tif (!beresp.http.Content-Security-Policy) {\n\t\t\tset beresp.http.Content-Security-Policy = \"default-src 'self'; font-src 'self' https:\/\/www.ft.com; img-src 'self' https:\/\/www.ft.com; frame-ancestors 'none'; base-uri 'self'; form-action 'self'\";\n\t\t}\n\n\t\t# The Referrer-Policy header governs which referrer information, sent in the Referer header, should be included with requests made.\n\t\t# Send a full URL when performing a same-origin request, but only send the origin of the document for other cases.\n\t\tset beresp.http.Referrer-Policy = \"origin-when-cross-origin\";\n\n\t\t# Enable purging of all objects in the Fastly cache by issuing a purge with the key \"polyfill-service\".\n\t\tif (beresp.http.Surrogate-Key !~ \"\\bpolyfill-service\\b\") {\n set beresp.http.Surrogate-Key = if(beresp.http.Surrogate-Key, beresp.http.Surrogate-Key \" polyfill-service\", \"polyfill-service\");\n }\n\n\t\tset beresp.http.Timing-Allow-Origin = \"*\";\n\n\t\tset beresp.http.Normalized-User-Agent = req.http.Normalized-User-Agent;\n\t\tset beresp.http.Detected-User-Agent = req.http.useragent_parser_family \"\/\" req.http.useragent_parser_major \".\" req.http.useragent_parser_minor \".\" req.http.useragent_parser_patch;\n\t}\n}\n\nsub vcl_deliver {\n\t# Run this VCL only if the path is not to the polyfill-service v2 server\n\tif ((req.http.Orig-URL ~ \"^\/v3\/\") || req.http.Orig-URL ~ \"^(?!\/v2).+\" && req.http.Orig-URL ~ \"^(?!\/__health).+\" && req.http.Orig-URL ~ \"^(?!\/test\/libs\/proclaim\/proclaim.js).+\" && req.http.Orig-URL ~ \"^(?!\/test\/libs\/mocha\/mocha.js).+\" && req.http.Orig-URL ~ \"^(?!\/test\/libs\/mocha\/mocha.css).+\" && req.http.Orig-URL ~ \"^(?!\/__gtg).+\") {\n\t\tif (req.http.Fastly-Debug) {\n\t\t\tcall breadcrumb_deliver;\n\t\t}\n\n\t\tset req.http.Fastly-Force-Shield = \"yes\";\n\n\t\t# Allow cross origin GET, HEAD, and OPTIONS requests to be made.\n\t\tif (req.http.Origin) {\n\t\t\tset resp.http.Access-Control-Allow-Origin = \"*\";\n\t\t\tset resp.http.Access-Control-Allow-Methods = \"GET,HEAD,OPTIONS\";\n\t\t}\n\n\t\tadd resp.http.Server-Timing = fastly_info.state {\", fastly;desc=\"Edge time\";dur=\"} time.elapsed.msec;\n\n\t\tif (req.http.Fastly-Debug) {\n\t\t\tset resp.http.Debug-Backend = req.http.Debug-Backend;\n\t\t\tset resp.http.Debug-Host = req.http.Host;\n\t\t\tset resp.http.Debug-Fastly-Restarts = req.restarts;\n\t\t\tset resp.http.Debug-URL = req.url;\n\t\t\tset resp.http.Debug-Orig-URL = req.http.Orig-URL;\n\t\t\tset resp.http.Debug-VCL-Route = req.http.X-VCL-Route;\n\t\t\tset resp.http.useragent_parser_family = req.http.useragent_parser_family;\n\t\t\tset resp.http.useragent_parser_major = req.http.useragent_parser_major;\n\t\t\tset resp.http.useragent_parser_minor = req.http.useragent_parser_minor;\n\t\t\tset resp.http.useragent_parser_patch = req.http.useragent_parser_patch;\n\t\t} else {\n\t\t\tunset resp.http.Server;\n\t\t\tunset resp.http.Via;\n\t\t\tunset resp.http.X-Cache;\n\t\t\tunset resp.http.X-Cache-Hits;\n\t\t\tunset resp.http.X-Served-By;\n\t\t\tunset resp.http.X-Timer;\n\t\t\tunset resp.http.Fastly-Restarts;\n\t\t}\n\t}\n}\n\nsub vcl_error {\n\tif (obj.status == 911) {\n\t\tset obj.status = 405;\n\t\tset obj.response = \"METHOD NOT ALLOWED\";\n\t\tset obj.http.Content-Type = \"text\/html; charset=utf-8\";\n\t\tset obj.http.Cache-Control = \"private, no-store\";\n\t\tsynthetic req.method \" METHOD NOT ALLOWED\";\n\t\treturn (deliver);\n\t}\n\tif (obj.status == 912) {\n\t\tset obj.status = 200;\n\t\tset obj.response = \"OK\";\n\t\tset obj.http.Allow = \"OPTIONS, GET, HEAD\";\n\t\treturn (deliver);\n\t}\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"e9a155a094904dbc5f11e577cdd3229372fcb3a4","subject":"Example VCL: Cleanup and update for varnish version >= 1.2","message":"Example VCL: Cleanup and update for varnish version >= 1.2\n\n\ngit-svn-id: 7d4b18ab7d176792635d6a7a77dd8cbbea8e8daa@2634 d4fa192b-c00b-0410-8231-f00ffab90ce4\n","repos":"ssm\/pkg-varnish,wikimedia\/operations-debs-varnish,CartoDB\/Varnish-Cache,CartoDB\/Varnish-Cache,ssm\/pkg-varnish,wikimedia\/operations-debs-varnish,wikimedia\/operations-debs-varnish,wikimedia\/operations-debs-varnish,ssm\/pkg-varnish,ssm\/pkg-varnish,ssm\/pkg-varnish,wikimedia\/operations-debs-varnish,CartoDB\/Varnish-Cache","old_file":"etc\/zope-plone.vcl","new_file":"etc\/zope-plone.vcl","new_contents":"#\n# This is an example VCL configuration file for varnish, meant for the\n# Plone CMS running within Zope. It defines a \"default\" backend for\n# serving static content from a normal web server, and a \"zope\"\n# backend for requests to the Zope CMS\n#\n# See the vcl(7) man page for details on VCL syntax and semantics.\n#\n# $Id$\n#\n\n# Default backend definition. Set this to point to your content\n# server.\n\n# Default backend is the Zope CMS\nbackend default {\n\tset backend.host = \"127.0.0.1\";\n\tset backend.port = \"9673\";\n}\n\nacl purge {\n\t\"localhost\";\n\t\"192.0.2.0\"\/24;\n}\n\nsub vcl_recv {\n\n\t# Normalize host headers, and do rewriting for the zope sites. Reject\n\t# requests for unknown hosts\n if (req.http.host ~ \"(www.)?example.com\") {\n set req.http.host = \"example.com\";\n set req.url = \"\/VirtualHostBase\/http\/example.com:80\/example.com\/VirtualHostRoot\" req.url;\n } elsif (req.http.host ~ \"(www.)?example.org\") {\n set req.http.host = \"example.org\";\n set req.url = \"\/VirtualHostBase\/http\/example.org:80\/example.org\/VirtualHostRoot\" req.url;\n } else {\n error 404 \"Unknown virtual host.\";\n }\n\n # Handle special requests\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n\n # POST - Logins and edits\n if (req.request == \"POST\") {\n pass;\n }\n \n # PURGE - The CacheFu product can invalidate updated URLs\n if (req.request == \"PURGE\") {\n if (!client.ip ~ purge) {\n error 405 \"Not allowed.\";\n }\n lookup;\n }\n }\n\n # Don't cache authenticated requests\n if (req.http.Cookie && req.http.Cookie ~ \"__ac(|_(name|password|persistent))=\") {\n\n\t\t# Force lookup of specific urls unlikely to need protection\n\t\tif (req.url ~ \"\\.(js|css)\") {\n remove req.http.cookie;\n lookup;\n }\n pass;\n }\n\n # The default vcl_recv is used from here.\n }\n\n# Do the PURGE thing\nsub vcl_hit {\n if (req.request == \"PURGE\") {\n set obj.ttl = 0s;\n error 200 \"Purged\";\n }\n}\nsub vcl_miss {\n if (req.request == \"PURGE\") {\n error 404 \"Not in cache\";\n }\n}\n\n# Enforce a minimum TTL, since we can PURGE changed objects actively\n# from Zope by using the CacheFu product\n\nsub vcl_fetch {\n if (obj.ttl < 3600s) {\n set obj.ttl = 3600s;\n }\n}\n","old_contents":"#\n# This is a basic VCL configuration file for varnish. See the vcl(7)\n# man page for details on VCL syntax and semantics.\n#\n# $Id: default.vcl 1424 2007-05-15 19:38:56Z des $\n#\n\n# Default backend definition. Set this to point to your content\n# server.\n\nbackend default {\n\tset backend.host = \"127.0.0.1\";\n\tset backend.port = \"9673\";\n}\n\nacl purge {\n\t\"localhost\";\n\t\"192.0.2.0\"\/24;\n}\n\nsub vcl_recv {\n\tif (req.request != \"GET\" && req.request != \"HEAD\") {\n \t# PURGE request if zope asks nicely\n \tif (req.request == \"PURGE\") {\n \t if (!client.ip ~ purge) {\n \t error 405 \"Not allowed.\";\n \t }\n \t lookup;\n \t}\n\t\tpipe;\n\t}\n\tif (req.http.Expect) {\n\t\tpipe;\n\t}\n\tif (req.http.Authenticate || req.http.Authorization) {\n\t\tpass;\n\t}\n\t# We only care about the \"__ac.*\" cookies, used for authentication\n\tif (req.http.Cookie && req.http.Cookie ~ \"__ac(|_(name|password|persistent))=\") {\n\t\tpass;\n\t}\n\tlookup;\n}\n\n# Do the PURGE thing\nsub vcl_hit {\n if (req.request == \"PURGE\") {\n set obj.ttl = 0s;\n error 200 \"Purged\";\n }\n}\nsub vcl_miss {\n if (req.request == \"PURGE\") {\n error 404 \"Not in cache\";\n }\n}\n\n# Enforce a minimum TTL, since we PURGE changed objects actively from Zope.\nsub vcl_fetch {\n if (obj.ttl < 3600s) {\n set obj.ttl = 3600s;\n }\n}\n\n# Below is a commented-out copy of the default VCL logic. If you\n# redefine any of these subroutines, the built-in logic will be\n# appended to your code.\n\n## Called when a client request is received\n#\n#sub vcl_recv {\n#\tif (req.request != \"GET\" && req.request != \"HEAD\") {\n#\t\tpipe;\n#\t}\n#\tif (req.http.Expect) {\n#\t\tpipe;\n#\t}\n#\tif (req.http.Authenticate || req.http.Cookie) {\n#\t\tpass;\n#\t}\n#\tlookup;\n#}\n#\n## Called when entering pipe mode\n#\n#sub vcl_pipe {\n#\tpipe;\n#}\n#\n## Called when entering pass mode\n#\n#sub vcl_pass {\n#\tpass;\n#}\n#\n## Called when entering an object into the cache\n#\n#sub vcl_hash {\n#\thash;\n#}\n#\n## Called when the requested object was found in the cache\n#\n#sub vcl_hit {\n#\tif (!obj.cacheable) {\n#\t\tpass;\n#\t}\n#\tdeliver;\n#}\n#\n## Called when the requested object was not found in the cache\n#\n#sub vcl_miss {\n#\tfetch;\n#}\n#\n## Called when the requested object has been retrieved from the\n## backend, or the request to the backend has failed\n#\n#sub vcl_fetch {\n#\tif (!obj.valid) {\n#\t\terror;\n#\t}\n#\tif (!obj.cacheable) {\n#\t\tpass;\n#\t}\n#\tif (resp.http.Set-Cookie) {\n#\t\tpass;\n#\t}\n#\tinsert;\n#}\n#\n## Called when an object nears its expiry time\n#\n#sub vcl_timeout {\n#\tdiscard;\n#}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"88252faf3ebcedccc0be172367a87460587d3603","subject":"Added more vim commands","message":"Added more vim commands\n","repos":"aschneiderman\/vim-voice","old_file":"gvim.vcl","new_file":"gvim.vcl","new_contents":"# Voice commands for gvim\r\n\r\ninclude folders.vch;\r\ninclude numbers.vch;\r\ninclude letters.vch;\r\ninclude pandas.vch;\r\n\r\nEdit [My] Configuration = ':e $' 'MYVIMRC' {Enter};\r\n\r\n<delimiters> := (Quotes = '\"' | 'Single Quotes' = \"'\" | 'Double Quotes' = '\"' | Parentheses = '(' \r\n\t\t| Brackets = '[' | 'Curly Braces' = '{' | Braces = '{'\r\n\t\t| HTML = '<' | Tags = '<' | 'Close HTML' = '>' | 'Close Tag' = '>'\t# NOTE: only works with commands I created\r\n\t\t| 'Equal Sign' = '='\r\n);\r\n\r\n# --- File Management ---------------\r\nOpen Document = {Alt+f} o;\r\nList Files = {Esc} ':bro ol' {Enter};\r\nFile <numbers> = $1 {Enter};\r\nLatest File = {Esc} ':bro ol' {Enter} 1{Enter};\r\n\r\nShow (Projects | Folders) = {Esc}':e C:\\Voice\\folders.vch' {Enter} Wait(100) {Down_9};\r\n[Open] Project <folder> = {Esc} ':e ' $1 {Enter} Wait(100) {Down_9};\r\n[Open] Current Project = {Esc} ':e .' {Enter} Wait(100) {Down_9};\r\nUp Directory = '-';\r\nSearch [Directory] <letters> = '\/^' $1;\r\n# :Sex = directory of current file \r\n# :Vex for vertical split\r\n# :sp. = Split horizontally on current directory (:vsp. For vertical)\r\n# % = new file\r\n\r\n(List Buffers = 'ls' | Buffer List = 'ls' | 'Next Buffer' = 'bn' | 'Last Buffer' = 'bp' | 'Close Buffer' = 'bd'\r\n\t| 'Next Window' = 'bn' | 'Last Window' = 'bp' | 'Close Window' = 'bd') \r\n\t= {Esc}':' $1 {Enter};\r\n\r\n\r\nSave Document = {Esc} Wait(100) ':w' {Enter};\r\nSave As = {Alt+f} a;\r\nGo (Quit = 'quit' | Close = 'close' | 'Close without saving' = 'close!' | Set = 'set') = ':' $1 {Enter};\r\n[Go] Quit without Saving = {Esc} Wait(100) ':quit!' {Enter};\r\n\r\nSave and Reload = {Esc} Wait(100) ':w' {Enter} Wait(100) SendSystemKeys({Alt+Tab}) Wait(100) {Alt+r};\r\n\r\n\r\n# --- Basic Navigation ---------------\r\n<numbers> (Up = 'k' | Down = 'j' | Right = 'l' | Left = 'h') = $1 $2;\r\nHoma = {Esc} 0;\r\nEnda = {Esc} '$';\r\n(Top | Go to Top) = {Esc} gg;\r\n(Bottom | Go to Bottom) = {Esc} G;\r\n(Move Forward | Move Right | Go Forward) <numbers> (words = 'w' | blocks = '}') = $2 $3;\r\n(Move Forward | Move Right | Go Forward) <numbers> (end | enda) words = $2 'e';\r\n(Move Back | Move Left | Go Back) <numbers> (words = 'b' | blocks = '{') = $2 $3;\r\nFine (Text | Alpha) <letters> = {Esc} f $2;\r\nFind Back <letters> = {Esc} F $1;\r\nFine Number 1..9 = {Esc} '\/' $1 {Enter};\r\nGo (Search | Find) = {Esc} '\/\\c'; # \\c = case insensitive\r\nFine <delimiters> = {Esc} '\/' $1 {Enter};\r\nInsert (Before = 'i' | After = 'a') <delimiters> = {Esc} '\/' $2 {Enter} Wait(100) $1;\r\n\r\n(Find Again | Next Fine | Next Find) = n;\r\nLine 1..100 = {Esc} ':' $1 {Enter};\r\n\r\n\r\n# --- Basic Editing ---------------\r\n(Do | Go) (Insert = 'i' | Append = 'A' | \rEscape = '{Esc}') = $2;\r\n(Insert = 'i' | \rEscape = '{Esc}') = $1;\r\nNexta = {Esc} A {Enter};\r\nEnda Insert = {Esc} A;\r\n\r\n(Do Again | Repeat That) = '.';\r\n(Undo | Undo That) = {Esc} u;\r\nRedo = {Esc} {Ctrl+r};\r\n\r\n(Kill = 'x') <numbers> = $2 $1;\r\n(Kill | Delete) Word = 'dw';\r\n(Kill | Delete) <numbers> Words = 'd' $2 'w';\r\nDee Dee = 'dd';\r\nCut to End of Line = 'd$';\r\nCut to End of Word = 'de';\r\n\r\n('Go Visual' | Mark | 'Visual Mode') = V;\r\n('Delete That' = 'd' | 'Yank That' = 'y' | 'Paste' = 'p' | 'Change That' = 'c' | 'Join That' = 'J') = $1;\r\nPaste That = {Esc} Wait(100) '\"+gP';\r\nCopy That = '\"*y';\r\nCopy Line = {Esc} V Wait(100) '\"*y';\r\nSelect Line = {Esc} V;\r\n\r\ndo test = {Esc} i Wait(100) \"strawberry\";\r\n\r\n\r\n(Delete= 'd' | Change = 'c') between <delimiters> = $1 i $2;\r\n(Delete= 'd' | Change = 'c') (Next = '\/' | Last = '?') <delimiters> = {Esc} $2 $3 {Enter} $1 i $3;\r\n(Delete= 'd' | Change = 'c') (Next = '\/' | Last = '?') \r\n\t(Heading = '<h' | Header = '<h' | Paragraph = '<p') \r\n\t= {Esc} $2 '\\c' $3 {Enter} $1 i t;\r\n\r\n\r\n\r\n\r\nSelect All = {Alt+e} s {Enter};\r\nGrab Everything = {Alt+e} s {Enter} Wait(100) {Alt+e} c {Enter} Wait(100) {Alt+Tab};\r\n\r\n\r\n\r\n\r\n1..20 Spaces = Repeat($1, ' ');\r\n\r\n\r\nDo Ultisnips = {Esc} ':UltiSnipsEdit'{Enter};\r\n\r\n\r\n(Next = 'j' | Last = 'k') Tag = {Ctrl+$1};\r\nStart Snippet= {Esc} i 'snippet {Enter} {Enter}endsnippet' {Esc} {Up_2} A;\r\nStart (\r\n\tD3 = 'd3_template' | Code = 'D3_code_wrapper'\r\n| \tform | 'form text' | 'form button' | 'form select'\r\n) = {Esc} i $1 Wait(100) {Tab};\r\n\r\n\r\n\r\nDelete Line = 'dd';\r\nDelete <numbers> Lines = $1 'dd';\r\n\r\n\r\n\r\n\r\n# --- HTML and Bootstrap commands (until I'm sure I can get Ultisnips to work) ------------\r\nNext One = {Esc} A;\r\nStart (Heading | Header) 1..4 = '<h' $2 '><\/h' $2 '>' Wait(100) {Left_5};\r\nStart Div (id | class) = '<div ' $1 '= \"\">' Wait(100) {Left_2};\r\nStop Div = '<\/div>' {Enter};\r\nStart Columns = {Esc} i Wait(100) '<div class=\"container\">{Enter}<div class=\"row\">{Enter}'\r\n\t\t {Enter} '<\/div>' {Enter} '<\/div>' {Esc} {Up_3} Wait(100) A;\r\nStart Column 1..12 = {Esc} a '<div class=\"col-md-' $1 '\">' {Enter} '<\/div>'{Enter} {Esc} {Up_2} Wait(100) A;\r\n\r\n# Paste Image = {Esc} a' <img align=right hspace=\"7\" width=\"200\" src=\"' {Ctrl+v} '\" \/>';\r\nPaste Image = {Esc} a ' <img align=right hspace=\"7\" src=\"' {Esc} p a '\" \/>';\r\n\r\n\r\n\r\n\r\n\r\n# --- COMMANDS TO ADD ------------------------\r\n\r\n# Using bookmarks or whatever they are called e.g., if I accidentally do the wrong thing and end up on the wrong line,\r\n# g; - last place I was where I made a change\r\n# Ctrl-o - If I jump to a place, copy a line, I can snap back \r\n\r\n# copying sets of lines, moving sets of lines\r\n# :9yank - copy line 9\r\n# :9t16 - copy line 9 to line 16\r\n# :9. - copy line 9 to current position \r\n\r\n\r\n\r\n# For adding quotes, HTML tags, etc. to text that's already there:\r\n# http:\/\/stackoverflow.com\/questions\/10305952\/vim-enclose-word-in-tag\r\n\r\n# Commands I'm not sure about\r\n# H,M,L: top, middle, and bottom of screen","old_contents":"# Voice commands for gvim\r\n\r\ninclude folders.vch;\r\ninclude numbers.vch;\r\ninclude letters.vch;\r\ninclude pandas.vch;\r\n\r\nEdit [My] Configuration = ':e $' 'MYVIMRC' {Enter};\r\n\r\n<delimiters> := (Quotes = '\"' | 'Single Quotes' = \"'\" | 'Double Quotes' = '\"' | Parentheses = '(' \r\n\t\t| Brackets = '[' | 'Curly Braces' = '{' | Braces = '{'\r\n\t\t| HTML = '<' | Tags = '<' | 'Close HTML' = '>' | 'Close Tag' = '>'\t# NOTE: only works with commands I created\r\n\t\t| 'Equal Sign' = '='\r\n);\r\n\r\n# --- File Management ---------------\r\nOpen Document = {Alt+f} o;\r\nList Files = {Esc} ':bro ol' {Enter};\r\nFile <numbers> = $1 {Enter};\r\nLatest File = {Esc} ':bro ol' {Enter} 1{Enter};\r\n\r\nShow (Projects | Folders) = {Esc}':e C:\\Voice\\folders.vch' {Enter} Wait(100) {Down_9};\r\n[Open] Project <folder> = {Esc} ':e ' $1 {Enter} Wait(100) {Down_9};\r\n[Open] Current Project = {Esc} ':e .' {Enter} Wait(100) {Down_9};\r\nUp Directory = '-';\r\nSearch [Directory] <letters> = '\/^' $1;\r\n# :Sex = directory of current file \r\n# :Vex for vertical split\r\n# :sp. = Split horizontally on current directory (:vsp. For vertical)\r\n# % = new file\r\n\r\n(List Buffers = 'ls' | Buffer List = 'ls' | 'Next Buffer' = 'bn' | 'Last Buffer' = 'bp' | 'Close Buffer' = 'bd'\r\n\t| 'Next Window' = 'bn' | 'Last Window' = 'bp' | 'Close Window' = 'bd') \r\n\t= {Esc}':' $1 {Enter};\r\n\r\n\r\nSave Document = {Esc} Wait(100) ':w' {Enter};\r\nSave As = {Alt+f} a;\r\nGo (Quit = 'quit' | Close = 'close' | 'Close without saving' = 'close!' | Set = 'set') = ':' $1 {Enter};\r\n[Go] Quit without Saving = {Esc} Wait(100) ':quit!' {Enter};\r\n\r\n\r\n# --- Basic Navigation ---------------\r\n<numbers> (Up = 'k' | Down = 'j' | Right = 'l' | Left = 'h') = $1 $2;\r\nHoma = {Esc} 0;\r\nEnda = {Esc} '$';\r\n(Top | Go to Top) = {Esc} gg;\r\n(Bottom | Go to Bottom) = {Esc} G;\r\n(Move Forward | Move Right | Go Forward) <numbers> (words = 'w' | blocks = '}') = $2 $3;\r\n(Move Forward | Move Right | Go Forward) <numbers> (end | enda) words = $2 'e';\r\n(Move Back | Move Left | Go Back) <numbers> (words = 'b' | blocks = '{') = $2 $3;\r\nFine Text <letters> = {Esc} f $1;\r\nFind Back <letters> = {Esc} F $1;\r\nFine Number 1..9 = {Esc} '\/' $1 {Enter};\r\nFine <delimiters> = {Esc} '\/' $1 {Enter};\r\nInsert (Before = 'i' | After = 'a') <delimiters> = {Esc} '\/' $2 {Enter} Wait(100) $1;\r\n\r\nNext Fine = n;\r\nLine 1..100 = {Esc} ':' $1 {Enter};\r\n\r\n\r\n# --- Basic Editing ---------------\r\n(Do | Go) (Insert = 'i' | Append = 'A' | \rEscape = '{Esc}') = $2;\r\n(Insert = 'i' | \rEscape = '{Esc}') = $1;\r\nNexta = {Esc} A {Enter};\r\n\r\n(Do Again | Repeat That) = '.';\r\n(Undo | Undo That) = {Esc} u;\r\nRedo = {Esc} {Ctrl+r};\r\n\r\n(Kill = 'x') <numbers> = $2 $1;\r\n(Kill | Delete) Word = 'dw';\r\n(Kill | Delete) <numbers> Words = 'd' $2 'w';\r\nDee Dee = 'dd';\r\nCut to End of Line = 'd$';\r\nCut to End of Word = 'de';\r\n\r\n('Go Visual' | Mark | 'Visual Mode') = V;\r\n('Delete That' = 'd' | 'Yank That' = 'y' | 'Paste That' = 'p' | 'Change That' = 'c') = $1;\r\nCopy That = '\"*y';\r\nCopy Line = {Esc} V Wait(100) '\"*y';\r\nSelect Line = {Esc} V;\r\n\r\ndo test = {Esc} i Wait(100) \"strawberry\";\r\n\r\n\r\n(Delete= 'd' | Change = 'c') between <delimiters> = $1 i $2;\r\n(Delete= 'd' | Change = 'c') (Next = '\/' | Last = '?') <delimiters> = {Esc} $2 $3 {Enter} $1 i $3;\r\n(Delete= 'd' | Change = 'c') (Next = '\/' | Last = '?') \r\n\t(Heading = '<h' | Header = '<h' | Paragraph = '<p') \r\n\t= {Esc} $2 '\\c' $3 {Enter} $1 i t;\r\n\r\n\r\n\r\n\r\nPaste That = {Alt+e} p;\r\nSelect All = {Alt+e} s {Enter};\r\nGrab Everything = {Alt+e} s {Enter} Wait(100) {Alt+e} c {Enter} Wait(100) {Alt+Tab};\r\n\r\n\r\n\r\n\r\n1..20 Spaces = Repeat($1, ' ');\r\n\r\n\r\nDo Ultisnips = {Esc} ':UltiSnipsEdit'{Enter};\r\n\r\n\r\n(Next = 'j' | Last = 'k') Tag = {Ctrl+$1};\r\nStart Snippet= {Esc} i 'snippet {Enter} {Enter}endsnippet' {Esc} {Up_2} A;\r\nStart (\r\n\tD3 = 'd3_template' | Code = 'D3_code_wrapper'\r\n| \tform | 'form text' | 'form button' | 'form select'\r\n|\thref\r\n) = {Esc} i $1 Wait(100) {Tab};\r\n\r\n\r\n\r\nDelete Line = 'dd';\r\nDelete <numbers> Lines = $1 'dd';\r\n\r\n\r\n\r\n\r\n# --- HTML and Bootstrap commands (until I'm sure I can get Ultisnips to work) ------------\r\nNext One = {Esc} A;\r\nStart Div (id | class) = '<div ' $1 '= \"\">' Wait(100) {Left_2};\r\nStop Div = '<\/div>' {Enter};\r\nStart Columns = {Esc} i Wait(100) '<div class=\"container\">{Enter}<div class=\"row\">{Enter}'\r\n\t\t {Enter} '<\/div>' {Enter} '<\/div>' {Esc} {Up_3} Wait(100) A;\r\nStart Column 1..12 = {Esc} a '<div class=\"col-md-' $1 '\">' {Enter} '<\/div>'{Enter} {Esc} {Up_2} Wait(100) A;\r\n\r\n# Paste Image = {Esc} a' <img align=right hspace=\"7\" width=\"200\" src=\"' {Ctrl+v} '\" \/>';\r\nPaste Image = {Esc} a ' <img align=right hspace=\"7\" src=\"' {Esc} p a '\" \/>';\r\n\r\n### NOTE: need to add the join command.\r\n# Try J\r\n\r\n\r\n\r\n# ---Things to do\r\n# change the configuration file\r\n\r\n\r\n# Commands to add:\r\n# g; - last place I was where I made a change\r\n# Ctrl-o - If I jump to a place, copy a line, I can snap back \r\n# :9yank - copy line 9\r\n# :9t16 - copy line 9 to line 16\r\n# :9. - copy line 9 to current position \r\n\r\n\r\n# Commands I'm not sure about\r\n# H,M,L: top, middle, and bottom of screen","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"35d35566484527904f0a4e1a96d0edb2fadbd371","subject":"Unset cookie for images so varnish will cache them.","message":"Unset cookie for images so varnish will cache them.\n\nWhen extensions were added to the image urls this was not updated.\n","repos":"mmb\/meme_captain_web,mmb\/meme_captain_web,mmb\/meme_captain_web,mmb\/meme_captain_web","old_file":"docker\/default.vcl","new_file":"docker\/default.vcl","new_contents":"vcl 4.0;\n\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"9292\";\n}\n\nsub vcl_recv {\n if (req.method == \"GET\" &&\n req.url ~ \"^\/((gend|src)_thumbs\/\\d+|(gend|src)_images\/[\\w-]{6,}\\.(bmp|gif|jpg|png))$\") {\n unset req.http.Cookie;\n }\n}\n","old_contents":"vcl 4.0;\n\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"9292\";\n}\n\nsub vcl_recv {\n if (req.method == \"GET\" &&\n req.url ~ \"^\/((gend|src)_thumbs\/\\d+|(gend|src)_images\/[\\w-]{6,})$\") {\n unset req.http.Cookie;\n }\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"2ccd64a618cbe5bb231384a391b58e6240682dbd","subject":"localhost might resolve to ipv4 and ipv6. using 127.0.0.1 instead.","message":"localhost might resolve to ipv4 and ipv6. using 127.0.0.1 instead.","repos":"KristianLyng\/vagent2,KristianLyng\/vagent2,KristianLyng\/vagent2,KristianLyng\/vagent2,KristianLyng\/vagent2,KristianLyng\/vagent2,KristianLyng\/vagent2","old_file":"tests\/data\/boot.vcl","new_file":"tests\/data\/boot.vcl","new_contents":"backend default { .host = \"127.0.0.1\"; }\n","old_contents":"backend default { .host = \"localhost\"; }\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"116a34a8547cd053a24a3ad9eb2d0ec684f896cd","subject":"vcl 4.0 marker","message":"vcl 4.0 marker\n","repos":"KristianLyng\/vagent2,KristianLyng\/vagent2,KristianLyng\/vagent2,KristianLyng\/vagent2,KristianLyng\/vagent2,KristianLyng\/vagent2,KristianLyng\/vagent2","old_file":"tests\/data\/boot.vcl","new_file":"tests\/data\/boot.vcl","new_contents":"vcl 4.0; backend default { .host = \"localhost\"; }\n","old_contents":"backend default { .host = \"localhost\"; }\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"48be1d6bd8d9901a326037c9bf49f7435a55a949","subject":"Do not stop vcl_recv logic","message":"Do not stop vcl_recv logic\n\nThat return statement has nasty consequences: the rest of the caching\nlogic is skipped, so no cache lookup is done!\n","repos":"EcoAlternative\/noosfero-ecosol,pr-snas\/noosfero-sgpr,hackathon-oscs\/rede-osc,arthurmde\/noosfero,evandrojr\/noosferogov,hebertdougl\/noosfero,samasti\/noosfero,AlessandroCaetano\/noosfero,hebertdougl\/noosfero,hackathon-oscs\/cartografias,cesarfex\/noosfero,uniteddiversity\/noosfero,hackathon-oscs\/rede-osc,evandrojr\/noosferogov,uniteddiversity\/noosfero,danielafeitosa\/noosfero,coletivoEITA\/noosfero-ecosol,blogoosfero\/noosfero,larissa\/noosfero,EcoAlternative\/noosfero-ecosol,macartur\/noosfero,danielafeitosa\/noosfero,alexandreab\/noosfero,AlessandroCaetano\/noosfero,rafamanzo\/mezuro-travis,hebertdougl\/noosfero,CIRANDAS\/noosfero-ecosol,hackathon-oscs\/rede-osc,AlessandroCaetano\/noosfero,blogoosfero\/noosfero,coletivoEITA\/noosfero,ludaac\/noosfero-mx,pr-snas\/noosfero-sgpr,macartur\/noosfero,LuisBelo\/tccnoosfero,hackathon-oscs\/cartografias,coletivoEITA\/noosfero-ecosol,blogoosfero\/noosfero,abner\/noosfero,vfcosta\/noosfero,pr-snas\/noosfero-sgpr,coletivoEITA\/noosfero-ecosol,hebertdougl\/noosfero,vfcosta\/noosfero,uniteddiversity\/noosfero,tallysmartins\/noosfero,arthurmde\/noosfero,arthurmde\/noosfero,pr-snas\/noosfero-sgpr,CIRANDAS\/noosfero-ecosol,evandrojr\/noosfero,tallysmartins\/noosfero,marcosronaldo\/noosfero,arthurmde\/noosfero,coletivoEITA\/noosfero-ecosol,EcoAlternative\/noosfero-ecosol,blogoosfero\/noosfero,arthurmde\/noosfero,larissa\/noosfero,AlessandroCaetano\/noosfero,arthurmde\/noosfero,samasti\/noosfero,larissa\/noosfero,cesarfex\/noosfero,ludaac\/noosfero-mx,macartur\/noosfero,arthurmde\/noosfero,samasti\/noosfero,EcoAlternative\/noosfero-ecosol,hackathon-oscs\/rede-osc,marcosronaldo\/noosfero,coletivoEITA\/noosfero,abner\/noosfero,alexandreab\/noosfero,CIRANDAS\/noosfero-ecosol,marcosronaldo\/noosfero,macartur\/noosfero,vfcosta\/noosfero,EcoAlternative\/noosfero-ecosol,uniteddiversity\/noosfero,evandrojr\/noosferogov,tallysmartins\/noosfero,cesarfex\/noosfero,vfcosta\/noosfero,macartur\/noosfero,hebertdougl\/noosfero,rafamanzo\/mezuro-travis,LuisBelo\/tccnoosfero,uniteddiversity\/noosfero,coletivoEITA\/noosfero,danielafeitosa\/noosfero,alexandreab\/noosfero,pr-snas\/noosfero-sgpr,hackathon-oscs\/cartografias,samasti\/noosfero,hackathon-oscs\/cartografias,EcoAlternative\/noosfero-ecosol,larissa\/noosfero,cesarfex\/noosfero,evandrojr\/noosfero,coletivoEITA\/noosfero,macartur\/noosfero,evandrojr\/noosferogov,tallysmartins\/noosfero,hebertdougl\/noosfero,tallysmartins\/noosfero,evandrojr\/noosferogov,rafamanzo\/mezuro-travis,hackathon-oscs\/rede-osc,tallysmartins\/noosfero,cesarfex\/noosfero,marcosronaldo\/noosfero,coletivoEITA\/noosfero-ecosol,CIRANDAS\/noosfero-ecosol,alexandreab\/noosfero,ludaac\/noosfero-mx,alexandreab\/noosfero,coletivoEITA\/noosfero,cesarfex\/noosfero,AlessandroCaetano\/noosfero,evandrojr\/noosfero,evandrojr\/noosferogov,abner\/noosfero,rafamanzo\/mezuro-travis,evandrojr\/noosfero,hackathon-oscs\/cartografias,hackathon-oscs\/cartografias,LuisBelo\/tccnoosfero,marcosronaldo\/noosfero,samasti\/noosfero,coletivoEITA\/noosfero,LuisBelo\/tccnoosfero,abner\/noosfero,ludaac\/noosfero-mx,alexandreab\/noosfero,coletivoEITA\/noosfero-ecosol,blogoosfero\/noosfero,abner\/noosfero,tallysmartins\/noosfero,hackathon-oscs\/rede-osc,LuisBelo\/tccnoosfero,ludaac\/noosfero-mx,macartur\/noosfero,evandrojr\/noosferogov,samasti\/noosfero,pr-snas\/noosfero-sgpr,evandrojr\/noosfero,cesarfex\/noosfero,evandrojr\/noosfero,larissa\/noosfero,marcosronaldo\/noosfero,danielafeitosa\/noosfero,danielafeitosa\/noosfero,hackathon-oscs\/cartografias,vfcosta\/noosfero,uniteddiversity\/noosfero,hackathon-oscs\/rede-osc,uniteddiversity\/noosfero,marcosronaldo\/noosfero,coletivoEITA\/noosfero,larissa\/noosfero,abner\/noosfero,blogoosfero\/noosfero,LuisBelo\/tccnoosfero,alexandreab\/noosfero,CIRANDAS\/noosfero-ecosol,evandrojr\/noosfero,rafamanzo\/mezuro-travis,danielafeitosa\/noosfero,abner\/noosfero,EcoAlternative\/noosfero-ecosol,vfcosta\/noosfero,AlessandroCaetano\/noosfero,blogoosfero\/noosfero,AlessandroCaetano\/noosfero,hebertdougl\/noosfero,larissa\/noosfero","old_file":"etc\/noosfero\/varnish-accept-language.vcl","new_file":"etc\/noosfero\/varnish-accept-language.vcl","new_contents":"C{\n\n\/* ------------------------------------------------------------------ *\/\n\/* THIS FILE IS AUTOMATICALLY GENERATED BY .\/gen_vcl.pl. DO NOT EDIT. *\/\n\n\/*\n * Accept-language header normalization\n *\n * Cosimo, 21\/01\/2010\n *\n *\/\n\n#include <ctype.h> \/* isupper *\/\n#include <stdio.h>\n#include <stdlib.h> \/* qsort *\/\n#include <string.h>\n\n#define DEFAULT_LANGUAGE \"en\"\n#define SUPPORTED_LANGUAGES \":de:fr:es:ru:pt:hy:en:\"\n\n#define vcl_string char\n#define LANG_LIST_SIZE 16 \n#define LANG_MAXLEN 16\n#define RETURN_LANG(x) { \\\n strncpy(lang, x, LANG_MAXLEN); \\\n return; \\\n}\n#define RETURN_DEFAULT_LANG RETURN_LANG(DEFAULT_LANGUAGE)\n#define PUSH_LANG(x,y) { \\\n \/* fprintf(stderr, \"Pushing lang [%d] %s %.4f\\n\", curr_lang, x, y); *\/ \\\n \/* We have to copy, otherwise root_lang will be the same every time *\/ \\\n strncpy(pl[curr_lang].lang, x, LANG_MAXLEN); \\\n pl[curr_lang].q = y; \\\n curr_lang++; \\\n}\n\nstruct lang_list {\n vcl_string lang[LANG_MAXLEN];\n float q;\n};\n\n\/* In-place lowercase of a string *\/\nstatic void strtolower(char *s) {\n register char *c;\n for (c=s; *c; c++) {\n if (isupper(*c)) {\n *c = tolower(*c);\n }\n }\n return;\n}\n\n\/* Checks if a given language is in the static list of the ones we support *\/\nint is_supported(vcl_string *lang) {\n vcl_string *supported_languages = SUPPORTED_LANGUAGES;\n vcl_string match_str[LANG_MAXLEN + 3] = \"\"; \/* :, :, \\0 = 3 *\/\n int is_supported = 0;\n\n \/* We want to match 'zh-cn' and 'zh-CN' too *\/\n strtolower(lang);\n\n \/* Search \":<lang>:\" in supported languages string *\/\n strncpy(match_str, \":\", 1);\n strncat(match_str, lang, LANG_MAXLEN);\n strncat(match_str, \":\\0\", 2);\n\n if (strstr(supported_languages, match_str)) {\n is_supported = 1;\n }\n\n return is_supported;\n}\n\n\/* Used by qsort() below *\/\nint sort_by_q(const void *x, const void *y) {\n struct lang_list *a = (struct lang_list *)x;\n struct lang_list *b = (struct lang_list *)y;\n if (a->q > b->q) return -1;\n if (a->q < b->q) return 1;\n return 0;\n}\n\n\/* Reads Accept-Language, parses it, and finds the first match\n among the supported languages. In case of no match,\n returns the default language.\n*\/\nvoid select_language(const vcl_string *incoming_header, char *lang) {\n\n struct lang_list pl[LANG_LIST_SIZE];\n vcl_string *lang_tok = NULL;\n vcl_string root_lang[3];\n vcl_string *header;\n vcl_string *pos = NULL;\n vcl_string *q_spec = NULL;\n unsigned int curr_lang = 0, i = 0;\n float q;\n\n \/* Empty or default string, return default language immediately *\/\n if (\n !incoming_header\n || (0 == strcmp(incoming_header, \"en-US\"))\n || (0 == strcmp(incoming_header, \"en-GB\"))\n || (0 == strcmp(incoming_header, DEFAULT_LANGUAGE))\n || (0 == strcmp(incoming_header, \"\"))\n )\n RETURN_DEFAULT_LANG;\n\n \/* Tokenize Accept-Language *\/\n header = (vcl_string *) incoming_header;\n\n while ((lang_tok = strtok_r(header, \" ,\", &pos))) {\n\n q = 1.0;\n\n if ((q_spec = strstr(lang_tok, \";q=\"))) {\n \/* Truncate language name before ';' *\/\n *q_spec = '\\0';\n \/* Get q value *\/\n sscanf(q_spec + 3, \"%f\", &q);\n }\n\n \/* Wildcard language '*' should be last in list *\/\n if ((*lang_tok) == '*') q = 0.0;\n\n \/* Push in the prioritized list *\/\n PUSH_LANG(lang_tok, q);\n\n \/* For cases like 'en-GB', we also want the root language in the final list *\/\n if ('-' == lang_tok[2]) {\n root_lang[0] = lang_tok[0];\n root_lang[1] = lang_tok[1];\n root_lang[2] = '\\0';\n PUSH_LANG(root_lang, q - 0.001);\n }\n\n \/* For strtok_r() to proceed from where it left off *\/\n header = NULL;\n\n \/* Break out if stored max no. of languages *\/\n if (curr_lang >= LANG_MAXLEN) break;\n }\n\n \/* Sort by priority *\/\n qsort(pl, curr_lang, sizeof(struct lang_list), &sort_by_q);\n\n \/* Match with supported languages *\/\n for (i = 0; i < curr_lang; i++) {\n if (is_supported(pl[i].lang))\n RETURN_LANG(pl[i].lang);\n }\n\n RETURN_DEFAULT_LANG;\n}\n\n\/* Reads req.http.Accept-Language and writes X-Varnish-Accept-Language *\/\nvoid vcl_rewrite_accept_language(const struct sess *sp) {\n vcl_string *in_hdr;\n vcl_string lang[LANG_MAXLEN];\n\n memset(lang, 0, LANG_MAXLEN);\n\n \/* Get Accept-Language header from client *\/\n in_hdr = VRT_GetHdr(sp, HDR_REQ, \"\\020Accept-Language:\");\n\n \/* Normalize and filter out by list of supported languages *\/\n select_language(in_hdr, lang);\n\n \/* By default, use a different header name: don't mess with backend logic *\/\n VRT_SetHdr(sp, HDR_REQ, \"\\032X-Varnish-Accept-Language:\", lang, vrt_magic_string_end);\n\n return;\n}\n\n\/* vim: syn=c ts=4 et sts=4 sw=4 tw=0\n*\/\n\n\/* THIS FILE IS AUTOMATICALLY GENERATED BY .\/gen_vcl.pl. DO NOT EDIT. *\/\n\/* ------------------------------------------------------------------ *\/\n}C\n\nsub vcl_recv {\n C{\n vcl_rewrite_accept_language(sp);\n }C\n}\n","old_contents":"C{\n\n\/* ------------------------------------------------------------------ *\/\n\/* THIS FILE IS AUTOMATICALLY GENERATED BY .\/gen_vcl.pl. DO NOT EDIT. *\/\n\n\/*\n * Accept-language header normalization\n *\n * Cosimo, 21\/01\/2010\n *\n *\/\n\n#include <ctype.h> \/* isupper *\/\n#include <stdio.h>\n#include <stdlib.h> \/* qsort *\/\n#include <string.h>\n\n#define DEFAULT_LANGUAGE \"en\"\n#define SUPPORTED_LANGUAGES \":de:fr:es:ru:pt:hy:en:\"\n\n#define vcl_string char\n#define LANG_LIST_SIZE 16 \n#define LANG_MAXLEN 16\n#define RETURN_LANG(x) { \\\n strncpy(lang, x, LANG_MAXLEN); \\\n return; \\\n}\n#define RETURN_DEFAULT_LANG RETURN_LANG(DEFAULT_LANGUAGE)\n#define PUSH_LANG(x,y) { \\\n \/* fprintf(stderr, \"Pushing lang [%d] %s %.4f\\n\", curr_lang, x, y); *\/ \\\n \/* We have to copy, otherwise root_lang will be the same every time *\/ \\\n strncpy(pl[curr_lang].lang, x, LANG_MAXLEN); \\\n pl[curr_lang].q = y; \\\n curr_lang++; \\\n}\n\nstruct lang_list {\n vcl_string lang[LANG_MAXLEN];\n float q;\n};\n\n\/* In-place lowercase of a string *\/\nstatic void strtolower(char *s) {\n register char *c;\n for (c=s; *c; c++) {\n if (isupper(*c)) {\n *c = tolower(*c);\n }\n }\n return;\n}\n\n\/* Checks if a given language is in the static list of the ones we support *\/\nint is_supported(vcl_string *lang) {\n vcl_string *supported_languages = SUPPORTED_LANGUAGES;\n vcl_string match_str[LANG_MAXLEN + 3] = \"\"; \/* :, :, \\0 = 3 *\/\n int is_supported = 0;\n\n \/* We want to match 'zh-cn' and 'zh-CN' too *\/\n strtolower(lang);\n\n \/* Search \":<lang>:\" in supported languages string *\/\n strncpy(match_str, \":\", 1);\n strncat(match_str, lang, LANG_MAXLEN);\n strncat(match_str, \":\\0\", 2);\n\n if (strstr(supported_languages, match_str)) {\n is_supported = 1;\n }\n\n return is_supported;\n}\n\n\/* Used by qsort() below *\/\nint sort_by_q(const void *x, const void *y) {\n struct lang_list *a = (struct lang_list *)x;\n struct lang_list *b = (struct lang_list *)y;\n if (a->q > b->q) return -1;\n if (a->q < b->q) return 1;\n return 0;\n}\n\n\/* Reads Accept-Language, parses it, and finds the first match\n among the supported languages. In case of no match,\n returns the default language.\n*\/\nvoid select_language(const vcl_string *incoming_header, char *lang) {\n\n struct lang_list pl[LANG_LIST_SIZE];\n vcl_string *lang_tok = NULL;\n vcl_string root_lang[3];\n vcl_string *header;\n vcl_string *pos = NULL;\n vcl_string *q_spec = NULL;\n unsigned int curr_lang = 0, i = 0;\n float q;\n\n \/* Empty or default string, return default language immediately *\/\n if (\n !incoming_header\n || (0 == strcmp(incoming_header, \"en-US\"))\n || (0 == strcmp(incoming_header, \"en-GB\"))\n || (0 == strcmp(incoming_header, DEFAULT_LANGUAGE))\n || (0 == strcmp(incoming_header, \"\"))\n )\n RETURN_DEFAULT_LANG;\n\n \/* Tokenize Accept-Language *\/\n header = (vcl_string *) incoming_header;\n\n while ((lang_tok = strtok_r(header, \" ,\", &pos))) {\n\n q = 1.0;\n\n if ((q_spec = strstr(lang_tok, \";q=\"))) {\n \/* Truncate language name before ';' *\/\n *q_spec = '\\0';\n \/* Get q value *\/\n sscanf(q_spec + 3, \"%f\", &q);\n }\n\n \/* Wildcard language '*' should be last in list *\/\n if ((*lang_tok) == '*') q = 0.0;\n\n \/* Push in the prioritized list *\/\n PUSH_LANG(lang_tok, q);\n\n \/* For cases like 'en-GB', we also want the root language in the final list *\/\n if ('-' == lang_tok[2]) {\n root_lang[0] = lang_tok[0];\n root_lang[1] = lang_tok[1];\n root_lang[2] = '\\0';\n PUSH_LANG(root_lang, q - 0.001);\n }\n\n \/* For strtok_r() to proceed from where it left off *\/\n header = NULL;\n\n \/* Break out if stored max no. of languages *\/\n if (curr_lang >= LANG_MAXLEN) break;\n }\n\n \/* Sort by priority *\/\n qsort(pl, curr_lang, sizeof(struct lang_list), &sort_by_q);\n\n \/* Match with supported languages *\/\n for (i = 0; i < curr_lang; i++) {\n if (is_supported(pl[i].lang))\n RETURN_LANG(pl[i].lang);\n }\n\n RETURN_DEFAULT_LANG;\n}\n\n\/* Reads req.http.Accept-Language and writes X-Varnish-Accept-Language *\/\nvoid vcl_rewrite_accept_language(const struct sess *sp) {\n vcl_string *in_hdr;\n vcl_string lang[LANG_MAXLEN];\n\n memset(lang, 0, LANG_MAXLEN);\n\n \/* Get Accept-Language header from client *\/\n in_hdr = VRT_GetHdr(sp, HDR_REQ, \"\\020Accept-Language:\");\n\n \/* Normalize and filter out by list of supported languages *\/\n select_language(in_hdr, lang);\n\n \/* By default, use a different header name: don't mess with backend logic *\/\n VRT_SetHdr(sp, HDR_REQ, \"\\032X-Varnish-Accept-Language:\", lang, vrt_magic_string_end);\n\n return;\n}\n\n\/* vim: syn=c ts=4 et sts=4 sw=4 tw=0\n*\/\n\n\/* THIS FILE IS AUTOMATICALLY GENERATED BY .\/gen_vcl.pl. DO NOT EDIT. *\/\n\/* ------------------------------------------------------------------ *\/\n}C\n\nsub vcl_recv {\n C{\n vcl_rewrite_accept_language(sp);\n }C\n return(pass);\n}\n","returncode":0,"stderr":"","license":"agpl-3.0","lang":"VCL"} {"commit":"6b7eb208e3a5cd3c3feeb82483fdf188a0f974b1","subject":"Update main.vcl","message":"Update main.vcl","repos":"JakeChampion\/polyfill-service,mcshaz\/polyfill-service,JakeChampion\/polyfill-service,mcshaz\/polyfill-service,mcshaz\/polyfill-service","old_file":"vcl\/main.vcl","new_file":"vcl\/main.vcl","new_contents":"import boltsort;\n\nsub vcl_recv {\n#FASTLY recv\n\n\t# Enable API key authentication for URL purge requests\n\tif ( req.request == \"FASTLYPURGE\" ) {\n\t\tset req.http.Fastly-Purge-Requires-Auth = \"1\";\n\t}\n\n\tif (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n\t\treturn(pass);\n\t}\n\n\tif (req.http.Host ~ \"polyfills.io\") {\n\t\t# Do the canonicalise check before the SSL check to avoid a double redirect\n\t\terror 751 \"Canonicalise\";\n\t}\n\n\tif (!req.http.Fastly-SSL) {\n\t\t# 801 is a special error code that Fastly uses to Force SSL on the request\n\t\terror 801 \"Redirect to prod HTTPS\";\n\t}\n\n\tif (req.url ~ \"^\/v2\/(polyfill\\.|recordRumData)\" && req.url !~ \"[\\?\\&]ua=\") {\n\t\tset req.http.X-Orig-URL = req.url;\n\t\tset req.url = \"\/v2\/normalizeUa?ua=\" urlencode(req.http.User-Agent);\n\t}\n\n\tif (req.url ~ \"^\/v2\/recordRumData\" && req.http.Normalized-User-Agent) {\n\t\tset req.http.Log = regsub(req.url, \"^.*?\\?(.*)$\", \"\\1\") \"&ip=\" client.ip \"&refer_domain=\" regsub(req.http.Referer, \"^(https?\\:\\\/\\\/)?(www\\.)?(.+?)(\\:\\d+)?([\\\/\\?].*)?$\", \"\\3\") \"&country=\" geoip.country_code \"&data_center=\" if(req.http.Cookie:FastlyDC, req.http.Cookie:FastlyDC, server.datacenter);\n\t\terror 204 \"No Content\";\n\t}\n\n\tset req.url = boltsort.sort(req.url);\n\n\tif (req.restarts == 0) {\n\t\tset req.http.X-Original-Host = req.http.Host;\n\n\t\tif (req.http.Host == \"qa.polyfill.io\") {\n\t\t\tif (req.http.X-Geoip-Continent ~ \"(NA|SA|OC|AS)\") {\n\t\t\t\tset req.backend = origami_polyfill_service_us;\n\t\t\t\tset req.http.Host = \"ft-polyfill-service-us-qa.herokuapp.com\";\n\n\t\t\t\tif (!req.backend.healthy) {\n\t\t\t\t\tset req.backend = origami_polyfill_service_eu;\n\t\t\t\t\tset req.http.Host = \"ft-polyfill-service-qa.herokuapp.com\";\n\t\t\t\t}\n\n\t\t\t} else {\n\t\t\t\tset req.backend = origami_polyfill_service_eu;\n\t\t\t\tset req.http.Host = \"ft-polyfill-service-qa.herokuapp.com\";\n\n\t\t\t\tif (!req.backend.healthy) {\n\t\t\t\t\tset req.backend = origami_polyfill_service_us;\n\t\t\t\t\tset req.http.Host = \"ft-polyfill-service-us-qa.herokuapp.com\";\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tif (req.http.X-Geoip-Continent ~ \"(NA|SA|OC|AS)\") {\n\t\t\t\tset req.backend = origami_polyfill_service_us;\n\t\t\t\tset req.http.Host = \"ft-polyfill-service-us.herokuapp.com\";\n\n\t\t\t\tif (!req.backend.healthy) {\n\t\t\t\t\tset req.backend = origami_polyfill_service_eu;\n\t\t\t\t\tset req.http.Host = \"ft-polyfill-service.herokuapp.com\";\n\t\t\t\t}\n\n\t\t\t} else {\n\t\t\t\tset req.backend = origami_polyfill_service_eu;\n\t\t\t\tset req.http.Host = \"ft-polyfill-service.herokuapp.com\";\n\n\t\t\t\tif (!req.backend.healthy) {\n\t\t\t\t\tset req.backend = origami_polyfill_service_us;\n\t\t\t\t\tset req.http.Host = \"ft-polyfill-service-us.herokuapp.com\";\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t# https:\/\/community.fastly.com\/t\/brotli-compression-support\/578\/6\n\tif (req.http.Fastly-Orig-Accept-Encoding) {\n\t\tif (req.http.User-Agent ~ \"MSIE 6\") {\n\t\t\t# For that 0.3% of stubborn users out there\n\t\t\tunset req.http.Accept-Encoding;\n\t\t} elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"br\") {\n\t\t\tset req.http.Accept-Encoding = \"br\";\n\t\t} elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"gzip\") {\n\t\t\tset req.http.Accept-Encoding = \"gzip\";\n\t\t} else {\n\t\t\tunset req.http.Accept-Encoding;\n\t\t}\n\t}\n\n\treturn(lookup);\n}\n\nsub vcl_deliver {\n#FASTLY deliver\n\n\t# If the response is to a normalise request and there's a parked \"original request\", use the normalised UA response to modify the original request and restart it\n\tif (req.url ~ \"^\/v\\d\/normalizeUa\" && resp.status == 200 && req.http.X-Orig-URL ~ \"^\/v2\/(polyfill\\.|recordRumData)\") {\n\t\tset req.http.Fastly-force-Shield = \"1\";\n\t\tset req.http.Normalized-User-Agent = resp.http.Normalized-User-Agent;\n\t\tif (req.http.X-Orig-URL ~ \"\\?\") {\n\t\t\tset req.url = req.http.X-Orig-URL \"&ua=\" resp.http.Normalized-User-Agent;\n\t\t} else {\n\t\t\tset req.url = req.http.X-Orig-URL \"?ua=\" resp.http.Normalized-User-Agent;\n\t\t}\n\t\trestart;\n\n\t# If the original request didn't specify a UA override, and we added one when the request was sent to the backend, the backend won't have included a Vary:user-agent header (correctly) but we need to add one\n\t} else if (req.url ~ \"^\/v\\d\/polyfill\\..*[\\?\\&]ua=\" && req.http.X-Orig-URL && req.http.X-Orig-URL !~ \"[\\?\\&]ua=\") {\n\t\tadd resp.http.Vary = \"User-Agent\";\n\t}\n\n\tif (req.url ~ \"[\\&\\?]rum=1\") {\n\t\tadd resp.http.Set-Cookie = \"FastlyDC=\" server.datacenter \"; Path=\/; HttpOnly; max-age=60\";\n\t}\n\n\tif (req.http.Fastly-Debug) {\n\t\tset resp.http.Debug-Host = req.http.Host;\n\t\tset resp.http.Debug-X-Original-Host = req.http.X-Original-Host;\n\t}\n\t\n\tset resp.http.Age = \"0\";\n\n\treturn(deliver);\n}\n\nsub vcl_error {\n#FASTLY error\n\n\t# Redirect to canonical prod\/qa origins\n\tif (obj.status == 751) {\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\tset obj.http.Location = \"https:\/\/polyfill.io\" req.url;\n\t\tsynthetic {\"\"};\n\t\treturn (deliver);\n\t}\n}\n","old_contents":"import boltsort;\n\nsub vcl_recv {\n#FASTLY recv\n\n\t# Enable API key authentication for URL purge requests\n\tif ( req.request == \"FASTLYPURGE\" ) {\n\t\tset req.http.Fastly-Purge-Requires-Auth = \"1\";\n\t}\n\n\tif (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n\t\treturn(pass);\n\t}\n\n\tif (req.http.Host ~ \"polyfills.io\") {\n\t\t# Do the canonicalise check before the SSL check to avoid a double redirect\n\t\terror 751 \"Canonicalise\";\n\t}\n\n\tif (!req.http.Fastly-SSL) {\n\t\t# 801 is a special error code that Fastly uses to Force SSL on the request\n\t\terror 801 \"Redirect to prod HTTPS\";\n\t}\n\n\tif (req.url ~ \"^\/v2\/(polyfill\\.|recordRumData)\" && req.url !~ \"[\\?\\&]ua=\") {\n\t\tset req.http.X-Orig-URL = req.url;\n\t\tset req.url = \"\/v2\/normalizeUa?ua=\" urlencode(req.http.User-Agent);\n\t}\n\n\tif (req.url ~ \"^\/v2\/recordRumData\" && req.http.Normalized-User-Agent) {\n\t\tset req.http.Log = regsub(req.url, \"^.*?\\?(.*)$\", \"\\1\") \"&ip=\" client.ip \"&refer_domain=\" regsub(req.http.Referer, \"^(https?\\:\\\/\\\/)?(www\\.)?(.+?)(\\:\\d+)?([\\\/\\?].*)?$\", \"\\3\") \"&country=\" geoip.country_code \"&data_center=\" if(req.http.Cookie:FastlyDC, req.http.Cookie:FastlyDC, server.datacenter);\n\t\terror 204 \"No Content\";\n\t}\n\n\tset req.url = boltsort.sort(req.url);\n\n\tif (req.restarts == 0) {\n\t\tset req.http.X-Original-Host = req.http.Host;\n\n\t\tif (req.http.Host == \"qa.polyfill.io\") {\n\t\t\tif (req.http.X-Geoip-Continent ~ \"(NA|SA|OC|AS)\") {\n\t\t\t\tset req.backend = origami_polyfill_service_us;\n\t\t\t\tset req.http.Host = \"ft-polyfill-service-us-qa.herokuapp.com\";\n\n\t\t\t\tif (!req.backend.healthy) {\n\t\t\t\t\tset req.backend = origami_polyfill_service_eu;\n\t\t\t\t\tset req.http.Host = \"ft-polyfill-service-qa.herokuapp.com\";\n\t\t\t\t}\n\n\t\t\t} else {\n\t\t\t\tset req.backend = origami_polyfill_service_eu;\n\t\t\t\tset req.http.Host = \"ft-polyfill-service-qa.herokuapp.com\";\n\n\t\t\t\tif (!req.backend.healthy) {\n\t\t\t\t\tset req.backend = origami_polyfill_service_us;\n\t\t\t\t\tset req.http.Host = \"ft-polyfill-service-us-qa.herokuapp.com\";\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tif (req.http.X-Geoip-Continent ~ \"(NA|SA|OC|AS)\") {\n\t\t\t\tset req.backend = origami_polyfill_service_us;\n\t\t\t\tset req.http.Host = \"ft-polyfill-service-us.herokuapp.com\";\n\n\t\t\t\tif (!req.backend.healthy) {\n\t\t\t\t\tset req.backend = origami_polyfill_service_eu;\n\t\t\t\t\tset req.http.Host = \"ft-polyfill-service.herokuapp.com\";\n\t\t\t\t}\n\n\t\t\t} else {\n\t\t\t\tset req.backend = origami_polyfill_service_eu;\n\t\t\t\tset req.http.Host = \"ft-polyfill-service.herokuapp.com\";\n\n\t\t\t\tif (!req.backend.healthy) {\n\t\t\t\t\tset req.backend = origami_polyfill_service_us;\n\t\t\t\t\tset req.http.Host = \"ft-polyfill-service-us.herokuapp.com\";\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t# https:\/\/community.fastly.com\/t\/brotli-compression-support\/578\/6\n\tif (req.http.Fastly-Orig-Accept-Encoding) {\n\t\tif (req.http.User-Agent ~ \"MSIE 6\") {\n\t\t\t# For that 0.3% of stubborn users out there\n\t\t\tunset req.http.Accept-Encoding;\n\t\t} elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"br\") {\n\t\t\tset req.http.Accept-Encoding = \"br\";\n\t\t} elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"gzip\") {\n\t\t\tset req.http.Accept-Encoding = \"gzip\";\n\t\t} else {\n\t\t\tunset req.http.Accept-Encoding;\n\t\t}\n\t}\n\n\treturn(lookup);\n}\n\nsub vcl_deliver {\n#FASTLY deliver\n\n\t# If the response is to a normalise request and there's a parked \"original request\", use the normalised UA response to modify the original request and restart it\n\tif (req.url ~ \"^\/v\\d\/normalizeUa\" && resp.status == 200 && req.http.X-Orig-URL ~ \"^\/v2\/(polyfill\\.|recordRumData)\") {\n\t\tset req.http.Fastly-force-Shield = \"1\";\n\t\tset req.http.Normalized-User-Agent = resp.http.Normalized-User-Agent;\n\t\tif (req.http.X-Orig-URL ~ \"\\?\") {\n\t\t\tset req.url = req.http.X-Orig-URL \"&ua=\" resp.http.Normalized-User-Agent;\n\t\t} else {\n\t\t\tset req.url = req.http.X-Orig-URL \"?ua=\" resp.http.Normalized-User-Agent;\n\t\t}\n\t\trestart;\n\n\t# If the original request didn't specify a UA override, and we added one when the request was sent to the backend, the backend won't have included a Vary:user-agent header (correctly) but we need to add one\n\t} else if (req.url ~ \"^\/v\\d\/polyfill\\..*[\\?\\&]ua=\" && req.http.X-Orig-URL && req.http.X-Orig-URL !~ \"[\\?\\&]ua=\") {\n\t\tadd resp.http.Vary = \"User-Agent\";\n\t}\n\n\tif (req.url ~ \"[\\&\\?]rum=1\") {\n\t\tadd resp.http.Set-Cookie = \"FastlyDC=\" server.datacenter \"; Path=\/; HttpOnly; max-age=60\";\n\t}\n\n\tif (req.http.Fastly-Debug) {\n\t\tset resp.http.Debug-Host = req.http.Host;\n\t\tset resp.http.Debug-X-Original-Host = req.http.X-Original-Host;\n\t}\n\t\n\tset resp.http.Age = 0;\n\n\treturn(deliver);\n}\n\nsub vcl_error {\n#FASTLY error\n\n\t# Redirect to canonical prod\/qa origins\n\tif (obj.status == 751) {\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\tset obj.http.Location = \"https:\/\/polyfill.io\" req.url;\n\t\tsynthetic {\"\"};\n\t\treturn (deliver);\n\t}\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"7e71842ff130cc3fe925d1a412013e2ca16d65b6","subject":"Adds CORS headers to varnish responses","message":"Adds CORS headers to varnish responses\n","repos":"jakefeasel\/sqlfiddle3,jakefeasel\/sqlfiddle3,jakefeasel\/sqlfiddle3","old_file":"varnish\/default.vcl","new_file":"varnish\/default.vcl","new_contents":"vcl 4.0;\n\nbackend default {\n .host = \"${VARNISH_BACKEND_HOST}\";\n .port = \"${VARNISH_BACKEND_PORT}\";\n}\n\nsub vcl_recv {\n\n if (req.method == \"POST\" && !req.http.Content-Length) {\n return (synth(411, \"Content-Length required\"));\n }\n\n # Require that the content be less than 8000 characters\n if (req.method == \"POST\" && !req.http.Content-Length ~ \"^[1-7]?[0-9]{1,3}$\") {\n return (synth(413, \"Request content too large (>8000)\"));\n }\n\n}\n\nsub vcl_backend_response {\n if (bereq.method == \"GET\") {\n set beresp.ttl = 60m;\n }\n\n if (beresp.status != 200) {\n set beresp.ttl = 0s;\n }\n\n if (bereq.method == \"OPTIONS\") {\n set beresp.http.Access-Control-Allow-Origin = \"*\";\n set beresp.http.Access-Control-Allow-Methods = \"GET, POST, OPTIONS\";\n set beresp.http.Access-Control-Allow-Headers = \"Origin, Accept, Content-Type, X-Requested-With\";\n }\n\n set beresp.do_gzip = true;\n}\n","old_contents":"vcl 4.0;\n\nbackend default {\n .host = \"${VARNISH_BACKEND_HOST}\";\n .port = \"${VARNISH_BACKEND_PORT}\";\n}\n\nsub vcl_recv {\n\n if (req.method == \"POST\" && !req.http.Content-Length) {\n return (synth(411, \"Content-Length required\"));\n }\n\n # Require that the content be less than 8000 characters\n if (req.method == \"POST\" && !req.http.Content-Length ~ \"^[1-7]?[0-9]{1,3}$\") {\n return (synth(413, \"Request content too large (>8000)\"));\n }\n\n}\n\nsub vcl_backend_response {\n if (bereq.method == \"GET\") {\n set beresp.ttl = 60m;\n }\n\n if (beresp.status != 200) {\n set beresp.ttl = 0s;\n }\n\n set beresp.do_gzip = true;\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"4bb4be53b0a555ca263cc917cb8f17a0520f888e","subject":"removing server header from default.vcl","message":"removing server header from default.vcl\n","repos":"tsuru\/varnishapi,tsuru\/varnishapi","old_file":"feaas\/misc\/default.vcl","new_file":"feaas\/misc\/default.vcl","new_contents":"director app dns {\n\t{\n\t\t.backend = {\n\t\t\t.host = \"%(app_host)s\";\n\t\t\t.port = \"80\";\n\t\t}\n\t}\n\t.ttl = 5m;\n\n}\n\nsub vcl_recv {\n\tset req.http.X-Host = req.http.host;\n\tset req.http.Host = \"%(app_host)s\";\n\n\tif(req.url ~ \"\/_varnish_healthcheck\") {\n\t\terror 200 \"WORKING\";\n\t\tset req.http.Connection = \"close\";\n\t}\n}\n\nsub vcl_fetch {\n \tunset beresp.http.Server;\n\tif(beresp.http.X-Esi) {\n\t\tset beresp.do_esi = true;\n\t\tunset beresp.http.X-Esi;\n\t}\n}\n","old_contents":"director app dns {\n\t{\n\t\t.backend = {\n\t\t\t.host = \"%(app_host)s\";\n\t\t\t.port = \"80\";\n\t\t}\n\t}\n\t.ttl = 5m;\n\n}\n\nsub vcl_recv {\n\tset req.http.X-Host = req.http.host;\n\tset req.http.Host = \"%(app_host)s\";\n\n\tif(req.url ~ \"\/_varnish_healthcheck\") {\n\t\terror 200 \"WORKING\";\n\t\tset req.http.Connection = \"close\";\n\t}\n}\n\nsub vcl_fetch {\n\tif(beresp.http.X-Esi) {\n\t\tset beresp.do_esi = true;\n\t\tunset beresp.http.X-Esi;\n\t}\n}\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"7bfd275a35f0094b5ccc6f58c43a5ad4b18695db","subject":"keyword id\u3067\u3072\u3063\u304b\u3051\u308b\u306e\u3067\u5168\u4f53\u4e00\u81f4\u304c\u6b63\u3057\u3044","message":"keyword id\u3067\u3072\u3063\u304b\u3051\u308b\u306e\u3067\u5168\u4f53\u4e00\u81f4\u304c\u6b63\u3057\u3044\n","repos":"dekokun\/isucon6-qualify,dekokun\/isucon6-qualify,dekokun\/isucon6-qualify,dekokun\/isucon6-qualify,dekokun\/isucon6-qualify,dekokun\/isucon6-qualify,dekokun\/isucon6-qualify,dekokun\/isucon6-qualify","old_file":"webapp\/config\/default.vcl","new_file":"webapp\/config\/default.vcl","new_contents":"#\n# This is an example VCL file for Varnish.\n#\n# It does not do anything by default, delegating control to the\n# builtin VCL. The builtin VCL is called when there is no explicit\n# return statement.\n#\n# See the VCL chapters in the Users Guide at https:\/\/www.varnish-cache.org\/docs\/\n# and https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExamples for more examples.\n\n# Marker to tell the VCL compiler that this VCL has been adapted to the\n# new 4.0 format.\nvcl 4.0;\n\nimport directors;\n\n# Default backend definition. Set this to point to your content server.\nbackend localhost {\n .host = \"127.0.0.1\";\n .port = \"5000\";\n}\n\nsub vcl_init {\n new backend = directors.round_robin();\n\n backend.add_backend(localhost);\n}\n\nsub vcl_recv {\n set req.backend_hint = backend.backend();\n\n if (req.method == \"INVALIDATE\") {\n ban(\"obj.http.Keyword = ^.*\" + req.http.X-Invalidated-Keyword + \".*$\");\n return(synth(200, req.http.X-Invalidated-Keyword + \" Purged. Success !!\"));\n }\n\n\n # if (req.http.Cookie) {\n # return(pass);\n # }\n\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return(pass);\n }\n\n return(hash);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n return (lookup);\n}\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n\n return(deliver);\n}\n\nsub vcl_backend_response {\n\n set beresp.do_esi = true;\n # this is same as builtin vcl_backend_response\n # https:\/\/www.varnish-cache.org\/trac\/browser\/bin\/varnishd\/builtin.vcl?rev=ae548683b8f91d0a92799f6c746b80773a4c9f05\n if (beresp.ttl <= 0s ||\n beresp.http.Set-Cookie ||\n beresp.http.Surrogate-control ~ \"no-store\" ||\n beresp.http.Cache-Control ~ \"no-cache\" ||\n (!beresp.http.Surrogate-Control &&\n beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n beresp.http.Vary == \"*\") {\n \/*\n * Mark as \"Hit-For-Pass\" for the next 2 minutes\n *\/\n set beresp.uncacheable = true;\n }\n\n # this is hatena original config\n if (beresp.ttl > 0s && ! beresp.uncacheable) {\n set beresp.grace = 1m;\n }\n return (deliver);\n}\n\nsub vcl_synth {\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n set resp.http.Retry-After = \"5\";\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>\"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <p>XID: \"} + req.xid + {\"<\/p>\n <\/body>\n<\/html>\n\"} );\n return (deliver);\n}\n\n","old_contents":"#\n# This is an example VCL file for Varnish.\n#\n# It does not do anything by default, delegating control to the\n# builtin VCL. The builtin VCL is called when there is no explicit\n# return statement.\n#\n# See the VCL chapters in the Users Guide at https:\/\/www.varnish-cache.org\/docs\/\n# and https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExamples for more examples.\n\n# Marker to tell the VCL compiler that this VCL has been adapted to the\n# new 4.0 format.\nvcl 4.0;\n\nimport directors;\n\n# Default backend definition. Set this to point to your content server.\nbackend localhost {\n .host = \"127.0.0.1\";\n .port = \"5000\";\n}\n\nsub vcl_init {\n new backend = directors.round_robin();\n\n backend.add_backend(localhost);\n}\n\nsub vcl_recv {\n set req.backend_hint = backend.backend();\n\n if (req.method == \"INVALIDATE\") {\n ban(\"obj.http.Keyword ~ ^.*\" + req.http.X-Invalidated-Keyword + \".*$\");\n return(synth(200, req.http.X-Invalidated-Keyword + \" Purged. Success !!\"));\n }\n\n\n # if (req.http.Cookie) {\n # return(pass);\n # }\n\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return(pass);\n }\n\n return(hash);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n return (lookup);\n}\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n\n return(deliver);\n}\n\nsub vcl_backend_response {\n\n set beresp.do_esi = true;\n # this is same as builtin vcl_backend_response\n # https:\/\/www.varnish-cache.org\/trac\/browser\/bin\/varnishd\/builtin.vcl?rev=ae548683b8f91d0a92799f6c746b80773a4c9f05\n if (beresp.ttl <= 0s ||\n beresp.http.Set-Cookie ||\n beresp.http.Surrogate-control ~ \"no-store\" ||\n beresp.http.Cache-Control ~ \"no-cache\" ||\n (!beresp.http.Surrogate-Control &&\n beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n beresp.http.Vary == \"*\") {\n \/*\n * Mark as \"Hit-For-Pass\" for the next 2 minutes\n *\/\n set beresp.uncacheable = true;\n }\n\n # this is hatena original config\n if (beresp.ttl > 0s && ! beresp.uncacheable) {\n set beresp.grace = 1m;\n }\n return (deliver);\n}\n\nsub vcl_synth {\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n set resp.http.Retry-After = \"5\";\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>\"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <p>XID: \"} + req.xid + {\"<\/p>\n <\/body>\n<\/html>\n\"} );\n return (deliver);\n}\n\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"72e7c3206ba33280ae665ba0f0863d65619b4dee","subject":"Added set cookie in example VCL","message":"Added set cookie in example VCL","repos":"Destination\/libvmod-abtest,Destination\/libvmod-abtest","old_file":"vcl\/default.vcl","new_file":"vcl\/default.vcl","new_contents":"import std;\nimport abtest;\n\n backend default {\n .host = \"127.0.0.1\";\n .port = \"3000\";\n }\n\n\/* Only permit localhost to manipulate abtest configuration *\/\nacl abconfig {\n \"localhost\";\n}\n\nsub vcl_init {\n if (abtest.load_config(\"\/tmp\/abtest.cfg\") != 0) {\n C{ syslog(LOG_ALERT, \"Unable to load AB config from \/tmp\/abtest.cfg\"); }C\n }\n abtest.set_rule(\".*\", \"a:1;b:1;86400;\"); \/\/ Set default rule with a duration of 24H\n\n return (ok);\n}\n\nsub vcl_fini {\n}\n\nsub vcl_recv {\n if (req.http.X-AB-Cfg) {\n if (!client.ip ~ abconfig) {\n error 405 \"Not allowed.\";\n } else {\n \/\/ curl localhost:8080 -X PUT -H \"X-AB-Cfg:base\" -H \"X-AB-Cfg-Val:a:25;b:75;\"\n if (req.request == \"PUT\") {\n std.log(\"AB Config PUT request: \" + req.http.X-AB-Cfg + \"|\" + req.http.X-AB-Cfg-Val);\n abtest.set_rule(req.http.X-AB-Cfg, req.http.X-AB-Cfg-Val);\n if (abtest.save_config(\"\/tmp\/abtest.cfg\") != 0) {\n std.log(\"ABTest - Error, could not save the configuration\");\n }\n }\n\n \/\/ curl localhost:8080 -X DELETE -H \"X-AB-Cfg:base\"\n if (req.request == \"DELETE\") {\n std.log(\"AB Config DELETE request: \" + req.http.X-AB-Cfg);\n abtest.rem_rule(req.http.X-AB-Cfg);\n }\n }\n }\n\n if(!req.http.Cookie ~ \"abtesting\") {\n std.log(\"No AB cookie, setting it.\");\n set req.http.Cookie = \"abtesting=\" + abtest.get_rand(req.url) + \"; path=\/; expires=\" + abtest.get_expire(req.url);\n set req.http.X-Set-AB-Cookie = req.http.Cookie;\n } else {\n std.log(\"AB cookie found.\");\n }\n\n return (lookup);\n}\n\nsub vcl_pipe {\n}\n\nsub vcl_pass {\n}\n\nsub vcl_hash {\n}\n\nsub vcl_hit {\n}\n\nsub vcl_miss {\n}\n\nsub vcl_fetch {\n}\n\nsub vcl_deliver {\n if (req.http.X-Set-AB-Cookie) {\n std.log(\"Setting cookie to \" + req.http.X-Set-AB-Cookie);\n set resp.http.Set-Cookie = req.http.X-Set-AB-Cookie;\n }\n\n if (req.http.X-AB-Cfg && client.ip ~ abconfig) {\n if (req.request == \"GET\") {\n \/\/ curl localhost:8080 -X GET -H \"X-AB-Cfg:;\"\n set resp.http.X-AB-Cfg = abtest.get_rules();\n }\n }\n}\n\nsub vcl_error {\n}\n","old_contents":" import std;\n import abtest;\n\n C{\n #include <syslog.h>\n }C\n\n\n backend default {\n .host = \"127.0.0.1\";\n .port = \"3000\";\n }\n\n\/* Only permit localhost to manipulate abtest configuration *\/\nacl abconfig {\n \"localhost\";\n}\n\nsub vcl_init {\n if (abtest.load_config(\"\/tmp\/abtest.cfg\") != 0) {\n C{ syslog(LOG_ALERT, \"Unable to load AB config from \/tmp\/abtest.cfg\"); }C\n }\n\n return (ok);\n}\n\nsub vcl_fini {\n}\n\nsub vcl_recv {\n std.log(abtest.get_rules());\n\n if (req.http.X-AB-Cfg) {\n if (!client.ip ~ abconfig) {\n std.log(\"AB Config request not allowed from \" + client.ip);\n error 405 \"Not allowed.\";\n } else {\n \/\/ curl localhost:8080 -X PUT -H \"X-AB-Cfg:base\" -H \"X-AB-Cfg-Val:a:25;b:75;\"\n if (req.request == \"PUT\") {\n std.log(\"AB Config PUT request: \" + req.http.X-AB-Cfg + \"|\" + req.http.X-AB-Cfg-Val);\n abtest.set_rule(req.http.X-AB-Cfg, req.http.X-AB-Cfg-Val);\n if (abtest.save_config(\"\/tmp\/abtest.cfg\") != 0) {\n std.log(\"ABTest - Error, could not save the configuration\");\n }\n }\n\n \/\/ curl localhost:8080 -X DELETE -H \"X-AB-Cfg:base\"\n if (req.request == \"DELETE\") {\n std.log(\"AB Config DELETE request: \" + req.http.X-AB-Cfg);\n abtest.rem_rule(req.http.X-AB-Cfg);\n }\n\n \/\/ curl localhost:8080 -X GET -H \"X-AB-Cfg;\"\n if (req.request == \"GET\") {\n std.log(\"AB Config GET request: \" + req.http.X-AB-Cfg);\n std.log(\"CFG -> \" + abtest.get_rules());\n }\n }\n }\n\n std.log(\"AB Cookie for '\" + req.url + \"': \" + abtest.get_rand(req.url) + \", cookie should last for \" + abtest.get_duration(req.url));\n\n\/*\n if(req.http.Cookie ~ \"abtesting\") {\n }\n*\/\n}\n\nsub vcl_pipe {\n}\n\nsub vcl_pass {\n}\n\nsub vcl_hash {\n}\n\nsub vcl_hit {\n}\n\nsub vcl_miss {\n}\n\nsub vcl_fetch {\n}\n\nsub vcl_deliver {\n}\n\nsub vcl_error {\n}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"5da5fd5139349acbf8f2cb6a128dae53a8d4a430","subject":"Add timestamp validation","message":"Add timestamp validation\n","repos":"rhargreaves\/fastly-vcl-experiments,rhargreaves\/fastly-vcl-experiments","old_file":"oauth_sig_check.vcl","new_file":"oauth_sig_check.vcl","new_contents":"\ntable consumer_secrets {\n\t\"foo\": \"super_secret\"\n}\n\ntable access_tokens {\n\t\"bar\": \"token_secret\"\n}\n\nsub vcl_recv {\n#FASTLY recv\n#DEPLOY recv\n\tset req.http.X-OAuth-Consumer-Key = if(req.url ~ \"(?i)oauth_consumer_key=([^&]*)\", urldecode(re.group.1), \"\");\n\tif(req.http.X-OAuth-Consumer-Key == \"\") {\n\t\terror 401 \"Missing Consumer Key\";\n\t}\n\tset req.http.X-OAuth-Consumer-Secret = table.lookup(consumer_secrets, req.http.X-OAuth-Consumer-Key);\n\tif(!req.http.X-OAuth-Consumer-Secret) {\n\t\terror 401 \"Invalid Consumer Key\";\n\t}\n\tset req.http.X-OAuth-Access-Token = if(req.url ~ \"(?i)oauth_token=([^&]*)\", urldecode(re.group.1), \"\");\n\tif(req.http.X-OAuth-Access-Token != \"\") {\n\t\tset req.http.X-OAuth-Access-Token-Secret = table.lookup(access_tokens, req.http.X-OAuth-Access-Token);\n\t\tif(!req.http.X-OAuth-Access-Token-Secret) {\n\t\t\terror 401 \"Invalid Access Token\";\n\t\t}\n\t} else {\n\t\tset req.http.X-OAuth-Access-Token-Secret = \"\";\n\t}\n\tset req.http.X-OAuth-Provided-Signature = if(req.url ~ \"(?i)oauth_signature=([^&]*)\", urldecode(re.group.1), \"\");\n\tif(req.http.X-OAuth-Provided-Signature == \"\") {\n\t\terror 401 \"Missing Signature\";\n\t}\n\tset req.http.X-OAuth-Ordered-Url = boltsort.sort(req.url);\n\tset req.http.X-OAuth-Parameters = regsub(regsub(req.http.X-OAuth-Ordered-Url, \".*\\?\", \"\"), \"&oauth_signature=[^&]*\", \"\");\n\tset req.http.X-OAuth-Base-String-Uri = \n\t\tif(req.http.Fastly-SSL, \"https\", \"http\") \n\t\t\":\/\/\"\n\t\tstd.tolower(req.http.host)\n\t\treq.url.path;\n\tset req.http.X-OAuth-Signature-Base-String = \n\t\treq.request\n\t\t\"&\"\n\t\turlencode(req.http.X-OAuth-Base-String-Uri)\n\t\t\"&\"\n\t\turlencode(req.http.X-OAuth-Parameters);\n\n\tset req.http.X-OAuth-Calculated-Signature = digest.hmac_sha1_base64(\n\t\t\treq.http.X-OAuth-Consumer-Secret \"&\" req.http.X-OAuth-Access-Token-Secret, \n\t\t\treq.http.X-OAuth-Signature-Base-String);\n\n\tunset req.http.X-OAuth-Consumer-Secret;\n\tunset req.http.X-OAuth-Access-Token-Secret;\n\tunset req.http.X-OAuth-Base-String-Uri;\n\n\tif(req.http.X-OAuth-Provided-Signature != req.http.X-OAuth-Calculated-Signature) {\n\t\terror 401 \"Invalid OAuth Signature\";\n\t}\n\n\tset req.http.X-OAuth-Timestamp = if(req.url ~ \"(?i)oauth_timestamp=([0-9]*)\", urldecode(re.group.1), \"\");\n\tif(req.http.X-OAuth-Timestamp == \"\") {\n\t\terror 401 \"Missing\/Invalid Timestamp\";\n\t}\n\n\tif(time.is_after(\n\t\tnow,\n\t\ttime.add(std.integer2time(std.atoi(req.http.X-OAuth-Timestamp)), 30m))) {\n\t\terror 401 \"Timestamp expired\";\n\t}\n\n\tif(time.is_after(\n\t\tstd.integer2time(std.atoi(req.http.X-OAuth-Timestamp)),\n\t\ttime.add(now, 1m))) {\n\t\terror 401 \"Timestamp too far in future\";\n\t}\n\n\terror 200 \"Authenticated!\";\n\n\treturn(lookup);\n}\n\nsub vcl_fetch {\n#FASTLY fetch\n\treturn(deliver);\n}\n\nsub vcl_hit {\n#FASTLY hit\n\tif (!obj.cacheable) {\n\t\treturn(pass);\n\t}\n\treturn(deliver);\n}\n\nsub vcl_miss {\n#FASTLY miss\n\treturn(fetch);\n}\n\nsub vcl_deliver{\n#FASTLY deliver\n\t# Expose variables for debugging\n\tset resp.http.X-OAuth-Consumer-Key = req.http.X-OAuth-Consumer-Key;\n\tset resp.http.X-OAuth-Access-Token = req.http.X-OAuth-Access-Token;\n\tset resp.http.X-OAuth-Provided-Signature = req.http.X-OAuth-Provided-Signature;\n\tset resp.http.X-OAuth-Calculated-Signature = req.http.X-OAuth-Calculated-Signature;\n\tset resp.http.X-OAuth-Parameters = req.http.X-OAuth-Parameters;\n\tset resp.http.X-OAuth-Signature-Base-String = req.http.X-OAuth-Signature-Base-String;\n\treturn(deliver);\n}\n\nsub vcl_error {\n#FASTLY error\n#DEPLOY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n","old_contents":"\ntable consumer_secrets {\n\t\"foo\": \"super_secret\"\n}\n\ntable access_tokens {\n\t\"bar\": \"token_secret\"\n}\n\nsub vcl_recv {\n#FASTLY recv\n#DEPLOY recv\n\tset req.http.X-OAuth-Consumer-Key = if(req.url ~ \"(?i)oauth_consumer_key=([^&]*)\", urldecode(re.group.1), \"\");\n\tif(req.http.X-OAuth-Consumer-Key == \"\") {\n\t\terror 401 \"Missing Consumer Key\";\n\t}\n\tset req.http.X-OAuth-Consumer-Secret = table.lookup(consumer_secrets, req.http.X-OAuth-Consumer-Key);\n\tif(!req.http.X-OAuth-Consumer-Secret) {\n\t\terror 401 \"Invalid Consumer Key\";\n\t}\n\tset req.http.X-OAuth-Access-Token = if(req.url ~ \"(?i)oauth_token=([^&]*)\", urldecode(re.group.1), \"\");\n\tif(req.http.X-OAuth-Access-Token != \"\") {\n\t\tset req.http.X-OAuth-Access-Token-Secret = table.lookup(access_tokens, req.http.X-OAuth-Access-Token);\n\t\tif(!req.http.X-OAuth-Access-Token-Secret) {\n\t\t\terror 401 \"Invalid Access Token\";\n\t\t}\n\t} else {\n\t\tset req.http.X-OAuth-Access-Token-Secret = \"\";\n\t}\n\tset req.http.X-OAuth-Provided-Signature = if(req.url ~ \"(?i)oauth_signature=([^&]*)\", urldecode(re.group.1), \"\");\n\tif(req.http.X-OAuth-Provided-Signature == \"\") {\n\t\terror 401 \"Missing Signature\";\n\t}\n\tset req.http.X-OAuth-Ordered-Url = boltsort.sort(req.url);\n\tset req.http.X-OAuth-Parameters = regsub(regsub(req.http.X-OAuth-Ordered-Url, \".*\\?\", \"\"), \"&oauth_signature=[^&]*\", \"\");\n\tset req.http.X-OAuth-Base-String-Uri = \n\t\tif(req.http.Fastly-SSL, \"https\", \"http\") \n\t\t\":\/\/\"\n\t\tstd.tolower(req.http.host)\n\t\treq.url.path;\n\tset req.http.X-OAuth-Signature-Base-String = \n\t\treq.request\n\t\t\"&\"\n\t\turlencode(req.http.X-OAuth-Base-String-Uri)\n\t\t\"&\"\n\t\turlencode(req.http.X-OAuth-Parameters);\n\n\tset req.http.X-OAuth-Calculated-Signature = digest.hmac_sha1_base64(\n\t\t\treq.http.X-OAuth-Consumer-Secret \"&\" req.http.X-OAuth-Access-Token-Secret, \n\t\t\treq.http.X-OAuth-Signature-Base-String);\n\n\tunset req.http.X-OAuth-Consumer-Secret;\n\tunset req.http.X-OAuth-Access-Token-Secret;\n\tunset req.http.X-OAuth-Base-String-Uri;\n\n\tif(req.http.X-OAuth-Provided-Signature != req.http.X-OAuth-Calculated-Signature) {\n\t\terror 401 \"Invalid OAuth Signature\";\n\t}\n\n\terror 200 \"Authenticated!\";\n\n\treturn(lookup);\n}\n\nsub vcl_fetch {\n#FASTLY fetch\n\treturn(deliver);\n}\n\nsub vcl_hit {\n#FASTLY hit\n\tif (!obj.cacheable) {\n\t\treturn(pass);\n\t}\n\treturn(deliver);\n}\n\nsub vcl_miss {\n#FASTLY miss\n\treturn(fetch);\n}\n\nsub vcl_deliver{\n#FASTLY deliver\n\t# Expose variables for debugging\n\tset resp.http.X-OAuth-Consumer-Key = req.http.X-OAuth-Consumer-Key;\n\tset resp.http.X-OAuth-Access-Token = req.http.X-OAuth-Access-Token;\n\tset resp.http.X-OAuth-Provided-Signature = req.http.X-OAuth-Provided-Signature;\n\tset resp.http.X-OAuth-Calculated-Signature = req.http.X-OAuth-Calculated-Signature;\n\tset resp.http.X-OAuth-Parameters = req.http.X-OAuth-Parameters;\n\tset resp.http.X-OAuth-Signature-Base-String = req.http.X-OAuth-Signature-Base-String;\n\treturn(deliver);\n}\n\nsub vcl_error {\n#FASTLY error\n#DEPLOY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"2a7a164e33979578927c036d2e81142e15c22c4a","subject":"vcl, etc.","message":"vcl, etc.\n","repos":"teohhanhui\/docker-varnish,tripviss\/docker-varnish","old_file":"default.vcl","new_file":"default.vcl","new_contents":"# This is an example VCL file for Varnish.\n#\n# It does not do anything by default, delegating control to the\n# builtin VCL. The builtin VCL is called when there is no explicit\n# return statement.\n#\n# See the VCL chapters in the Users Guide at https:\/\/www.varnish-cache.org\/docs\/\n# and http:\/\/varnish-cache.org\/trac\/wiki\/VCLExamples for more examples.\n\n# Marker to tell the VCL compiler that this VCL has been adapted to the\n# new 4.0 format.\nvcl 4.0;\n\n# https:\/\/github.com\/Dridi\/libvmod-querystring\nimport querystring;\n\n# Default backend definition. Set this to point to your content server.\nbackend www {\n\t.host = \"127.0.0.1\";\n\t.port = \"8080\";\n}\n\n# Define an access control list to restrict cache purging.\nacl purge {\n\t\"127.0.0.1\";\n\t\"192.168.0.0\"\/16;\n}\n\nsub vcl_recv {\n\n\t# https:\/\/github.com\/mattiasgeniar\/varnish-4.0-configuration-templates\/blob\/master\/default.vcl\n\tif (req.method == \"PURGE\") {\n\t\tif (!client.ip ~ purge) {\n\t\t\treturn(synth(405, \"Not allowed.\"));\n\t\t}\n\t\treturn (purge);\n\t}\n\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"PATCH\" &&\n req.method != \"DELETE\") {\n return (pipe);\n }\n\n # Implementing websocket support (https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html)\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n if (req.http.Authorization) {\n return (pass);\n }\n\n\tif (req.url~ \"^\/wp-admin\/\") {\n\t\treturn (pass);\n\t}\n\n\n\t####\n\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n if (req.url ~ \"^[^?]*\\.(bmp|bz2|css|doc|eot|flv|gif|gz|ico|jpeg|jpg|js|less|pdf|png|rtf|swf|txt|woff|xml)(\\?.*)?$\") {\n unset req.http.Cookie;\n set req.url = querystring.remove(req.url);\n return (hash);\n }\n\n\tset req.url = querystring.clean(req.url);\n\n if (req.url ~ \"\\?\") {\n set req.url = querystring.sort(req.url);\n }\n\n return (hash);\n}\n\nsub vcl_hash {\n\n hash_data(req.url);\n \n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n \n if (req.http.origin) {\n \thash_data(req.http.origin);\n }\n \n return (lookup);\n}\n\nsub vcl_backend_response {\n\t# Happens after we have read the response headers from the backend.\n\t#\n\t# Here you clean the response headers, removing silly Set-Cookie headers\n\t# and other mistakes your backend does.\n}\n\nsub vcl_deliver {\n\t# Fall-through for dev that doesn't work right now. Prob need to do something with beresp too.\n\t# Happens when we have all the pieces we need, and are about to send the\n\t# response to the client.\n\t#\n\t# You can do accounting or modifying the final object here.\n}","old_contents":"# This is an example VCL file for Varnish.\n#\n# It does not do anything by default, delegating control to the\n# builtin VCL. The builtin VCL is called when there is no explicit\n# return statement.\n#\n# See the VCL chapters in the Users Guide at https:\/\/www.varnish-cache.org\/docs\/\n# and http:\/\/varnish-cache.org\/trac\/wiki\/VCLExamples for more examples.\n\n# Marker to tell the VCL compiler that this VCL has been adapted to the\n# new 4.0 format.\nvcl 4.0;\n\n# https:\/\/github.com\/Dridi\/libvmod-querystring\nimport querystring;\n\n# Default backend definition. Set this to point to your content server.\nbackend nytco {\n\t.host = \"127.0.0.1\";\n\t.port = \"8080\";\n}\n\n# Define an access control list to restrict cache purging.\nacl purge {\n\t\"192.168.33.1\"\/8;\n\n}\n\nsub vcl_recv {\n\n\t# Fall-through for admin interface requests\n\tif (req.url~ \"^\/wp-admin\/\") {\n\t\treturn (pass);\n\t}\n\n\t# Purge the cache if the client is allowed to.\n\tif (req.method == \"PURGE\") {\n\t\tif (!client.ip ~ purge) {\n\t\t\treturn(synth(405, \"Not allowed.\"));\n\t\t}\n\t\treturn (purge);\n\t}\n\n\n\tif (req.url ~ \".nytco.com$\") {\n\t\t\tset req.url = querystring.remove(req.url);\n\n\t# Ignore all cookies.\n\tunset req.http.cookie;\n\t}\n}\n\nsub vcl_backend_response {\n\t# Happens after we have read the response headers from the backend.\n\t#\n\t# Here you clean the response headers, removing silly Set-Cookie headers\n\t# and other mistakes your backend does.\n}\n\nsub vcl_deliver {\n\t# Fall-through for dev that doesn't work right now. Prob need to do something with beresp too.\n\tset resp.http.age = \"0\";\n\n\t# Happens when we have all the pieces we need, and are about to send the\n\t# response to the client.\n\t#\n\t# You can do accounting or modifying the final object here.\n}","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"1c389fc8355b23325b30c93b2110639438da06e9","subject":"Use req.url.qs for query string extraction; boltsort url by default","message":"Use req.url.qs for query string extraction; boltsort url by default\n","repos":"rhargreaves\/fastly-vcl-experiments,rhargreaves\/fastly-vcl-experiments","old_file":"oauth_sig_check.vcl","new_file":"oauth_sig_check.vcl","new_contents":"\ntable consumer_secrets {\n\t\"foo\": \"foo_secret\"\n}\n\ntable access_tokens {\n\t\"bar\": \"bar_secret\"\n}\n\nsub vcl_recv {\n#FASTLY recv\n#DEPLOY recv\n\tdeclare local var.consumer_key STRING;\n\tdeclare local var.consumer_secret STRING;\n\tdeclare local var.access_token STRING;\n\tdeclare local var.access_token_secret STRING;\n\tdeclare local var.provided_signature STRING;\n\tdeclare local var.parameters STRING;\n\tdeclare local var.base_string_uri STRING;\n\tdeclare local var.base_string STRING;\n\tdeclare local var.calculated_signature STRING;\n\tdeclare local var.timestamp STRING;\n\n\tset req.url = boltsort.sort(req.url);\n\n\tset var.consumer_key = if(req.url ~ \"(?i)oauth_consumer_key=([^&]*)\",\n\t\t\turldecode(re.group.1), \"\");\n\tif(var.consumer_key == \"\") {\n\t\terror 401 \"Missing Consumer Key\";\n\t}\n\tset var.consumer_secret = table.lookup(consumer_secrets, var.consumer_key, \"\");\n\tif(var.consumer_secret == \"\") {\n\t\terror 401 \"Invalid Consumer Key\";\n\t}\n\tset var.access_token = if(req.url ~ \"(?i)oauth_token=([^&]*)\",\n\t\t\turldecode(re.group.1), \"\");\n\tif(var.access_token != \"\") {\n\t\tset var.access_token_secret = table.lookup(access_tokens, var.access_token, \"\");\n\t\tif(var.access_token_secret == \"\") {\n\t\t\terror 401 \"Invalid Access Token\";\n\t\t}\n\t} else {\n\t\tset var.access_token_secret = \"\";\n\t}\n\tset var.provided_signature = if(req.url ~ \"(?i)oauth_signature=([^&]*)\",\n\t\t\turldecode(re.group.1), \"\");\n\tif(var.provided_signature == \"\") {\n\t\terror 401 \"Missing Signature\";\n\t}\n\tset var.parameters = regsub(\n\t\t\treq.url.qs,\n\t\t\t\"&oauth_signature=[^&]*\", \"\");\n\tset var.base_string_uri =\n\t\tif(req.http.Fastly-SSL, \"https\", \"http\")\n\t\t\t\":\/\/\"\n\t\t\t\tstd.tolower(req.http.host)\n\t\t\t\treq.url.path;\n\tset var.base_string =\n\t\treq.request\n\t\t\"&\"\n\t\turlencode(var.base_string_uri)\n\t\t\"&\"\n\t\turlencode(var.parameters);\n\n\tset var.calculated_signature = digest.hmac_sha1_base64(\n\t\t\tvar.consumer_secret \"&\" var.access_token_secret,\n\t\t\tvar.base_string);\n\n\tif(!digest.secure_is_equal(var.provided_signature,\n\t\t\tvar.calculated_signature)) {\n\t\terror 401 \"Invalid OAuth Signature\";\n\t}\n\n\tset var.timestamp = if(req.url ~ \"(?i)oauth_timestamp=([0-9]*)\",\n\t\t\turldecode(re.group.1), \"\");\n\tif(var.timestamp == \"\") {\n\t\terror 401 \"Missing\/Invalid Timestamp\";\n\t}\n\n\tif(time.is_after(\n\t\t\t\tnow,\n\t\t\t\ttime.add(std.integer2time(std.atoi(var.timestamp)), 30m))) {\n\t\terror 401 \"Timestamp expired\";\n\t}\n\n\tif(time.is_after(\n\t\t\t\tstd.integer2time(std.atoi(var.timestamp)),\n\t\t\t\ttime.add(now, 1m))) {\n\t\terror 401 \"Timestamp too far in future\";\n\t}\n\n\terror 200 \"Authenticated!\";\n\n\treturn(lookup);\n}\n\nsub vcl_fetch {\n#FASTLY fetch\n\treturn(deliver);\n}\n\nsub vcl_hit {\n#FASTLY hit\n\tif (!obj.cacheable) {\n\t\treturn(pass);\n\t}\n\treturn(deliver);\n}\n\nsub vcl_miss {\n#FASTLY miss\n\treturn(fetch);\n}\n\nsub vcl_deliver{\n#FASTLY deliver\n\treturn(deliver);\n}\n\nsub vcl_error {\n#FASTLY error\n#DEPLOY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n","old_contents":"\ntable consumer_secrets {\n\t\"foo\": \"foo_secret\"\n}\n\ntable access_tokens {\n\t\"bar\": \"bar_secret\"\n}\n\nsub vcl_recv {\n#FASTLY recv\n#DEPLOY recv\n\tdeclare local var.consumer_key STRING;\n\tdeclare local var.consumer_secret STRING;\n\tdeclare local var.access_token STRING;\n\tdeclare local var.access_token_secret STRING;\n\tdeclare local var.provided_signature STRING;\n\tdeclare local var.parameters STRING;\n\tdeclare local var.base_string_uri STRING;\n\tdeclare local var.base_string STRING;\n\tdeclare local var.calculated_signature STRING;\n\tdeclare local var.timestamp STRING;\n\n\tset var.consumer_key = if(req.url ~ \"(?i)oauth_consumer_key=([^&]*)\", \n\t\t\turldecode(re.group.1), \"\");\n\tif(var.consumer_key == \"\") {\n\t\terror 401 \"Missing Consumer Key\";\n\t}\n\tset var.consumer_secret = table.lookup(consumer_secrets, var.consumer_key, \"\");\n\tif(var.consumer_secret == \"\") {\n\t\terror 401 \"Invalid Consumer Key\";\n\t}\n\tset var.access_token = if(req.url ~ \"(?i)oauth_token=([^&]*)\", \n\t\t\turldecode(re.group.1), \"\");\n\tif(var.access_token != \"\") {\n\t\tset var.access_token_secret = table.lookup(access_tokens, var.access_token, \"\");\n\t\tif(var.access_token_secret == \"\") {\n\t\t\terror 401 \"Invalid Access Token\";\n\t\t}\n\t} else {\n\t\tset var.access_token_secret = \"\";\n\t}\n\tset var.provided_signature = if(req.url ~ \"(?i)oauth_signature=([^&]*)\", \n\t\t\turldecode(re.group.1), \"\");\n\tif(var.provided_signature == \"\") {\n\t\terror 401 \"Missing Signature\";\n\t}\n\tset var.parameters = regsub(\n\t\t\tregsub(boltsort.sort(req.url), \".*\\?\", \"\"), \n\t\t\t\"&oauth_signature=[^&]*\", \"\");\n\tset var.base_string_uri = \n\t\tif(req.http.Fastly-SSL, \"https\", \"http\") \n\t\t\t\":\/\/\"\n\t\t\t\tstd.tolower(req.http.host)\n\t\t\t\treq.url.path;\n\tset var.base_string = \n\t\treq.request\n\t\t\"&\"\n\t\turlencode(var.base_string_uri)\n\t\t\"&\"\n\t\turlencode(var.parameters);\n\n\tset var.calculated_signature = digest.hmac_sha1_base64(\n\t\t\tvar.consumer_secret \"&\" var.access_token_secret, \n\t\t\tvar.base_string);\n\n\tif(!digest.secure_is_equal(var.provided_signature, \n\t\t\tvar.calculated_signature)) {\n\t\terror 401 \"Invalid OAuth Signature\";\n\t}\n\n\tset var.timestamp = if(req.url ~ \"(?i)oauth_timestamp=([0-9]*)\", \n\t\t\turldecode(re.group.1), \"\");\n\tif(var.timestamp == \"\") {\n\t\terror 401 \"Missing\/Invalid Timestamp\";\n\t}\n\n\tif(time.is_after(\n\t\t\t\tnow,\n\t\t\t\ttime.add(std.integer2time(std.atoi(var.timestamp)), 30m))) {\n\t\terror 401 \"Timestamp expired\";\n\t}\n\n\tif(time.is_after(\n\t\t\t\tstd.integer2time(std.atoi(var.timestamp)),\n\t\t\t\ttime.add(now, 1m))) {\n\t\terror 401 \"Timestamp too far in future\";\n\t}\n\n\terror 200 \"Authenticated!\";\n\n\treturn(lookup);\n}\n\nsub vcl_fetch {\n#FASTLY fetch\n\treturn(deliver);\n}\n\nsub vcl_hit {\n#FASTLY hit\n\tif (!obj.cacheable) {\n\t\treturn(pass);\n\t}\n\treturn(deliver);\n}\n\nsub vcl_miss {\n#FASTLY miss\n\treturn(fetch);\n}\n\nsub vcl_deliver{\n#FASTLY deliver\n\treturn(deliver);\n}\n\nsub vcl_error {\n#FASTLY error\n#DEPLOY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"c79f16ac55170b1cc95a7e62259406f4f1aa6424","subject":"add web socket upgrade piping","message":"add web socket upgrade piping\n","repos":"derbyjs\/candygram","old_file":"varnish_default.vcl","new_file":"varnish_default.vcl","new_contents":"# This is a basic VCL configuration file for varnish. See the vcl(7)\n# man page for details on VCL syntax and semantics.\n\nimport std;\n\n# static\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"4000\";\n}\nbackend examples {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\nbackend components {\n .host = \"127.0.0.1\";\n .port = \"3330\";\n}\n\nsub vcl_recv {\n if (!req.http.Host) {\n error 404 \"Need a host header\";\n }\n\n set req.http.Host = regsub(req.http.Host, \"^www\\.\", \"\");\n set req.http.Host = regsub(req.http.Host, \":80$\", \"\");\n\n if (req.restarts == 0) {\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For =\n req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n if (\n req.http.Host ~ \"^chat\\.\" ||\n req.http.Host ~ \"^charts\\.\" ||\n req.http.Host ~ \"^directory\\.\" ||\n req.http.Host ~ \"^codemirror\\.\" ||\n req.http.Host ~ \"^hello\\.\" ||\n req.http.Host ~ \"^sink\\.\" ||\n req.http.Host ~ \"^todos\\.\" ||\n req.http.Host ~ \"^widgets\\.\"\n ) {\n set req.backend = examples;\n } else if (req.http.Host ~ \"^components\\.\") {\n set req.backend = components;\n }\n\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization || req.http.Cookie) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n return (lookup);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n if (req.http.Origin) {\n hash_data(req.http.Origin);\n }\n return (hash);\n}\n\nsub vcl_pipe {\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n set bereq.http.connection = \"close\";\n # here. It is not set by default as it might break some broken web\n # applications, like IIS with NTLM authentication.\n\n # Websockets\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n\n return (pipe);\n}\n\nsub vcl_fetch {\n # Compress responses\n if (beresp.http.content-type ~ \"text\"\n || beresp.http.content-type ~ \"json\"\n || beresp.http.content-type ~ \"javascript\") {\n set beresp.do_gzip = true;\n }\n}\n\nsub vcl_error {\n if (obj.status == 750) {\n # moved permanently\n set obj.http.Location = req.http.Location;\n set obj.status = 301;\n } else if (obj.status == 752) {\n # moved temporarily\n set obj.http.Location = req.http.Location;\n set obj.status = 302;\n } else {\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic std.fileread(\"\/etc\/varnish\/503.html\");\n }\n return (deliver);\n}\n","old_contents":"# This is a basic VCL configuration file for varnish. See the vcl(7)\n# man page for details on VCL syntax and semantics.\n\nimport std;\n\n# static\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"4000\";\n}\nbackend examples {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\nbackend components {\n .host = \"127.0.0.1\";\n .port = \"3330\";\n}\n\nsub vcl_recv {\n if (!req.http.Host) {\n error 404 \"Need a host header\";\n }\n\n set req.http.Host = regsub(req.http.Host, \"^www\\.\", \"\");\n set req.http.Host = regsub(req.http.Host, \":80$\", \"\");\n\n if (req.restarts == 0) {\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For =\n req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n if (\n req.http.Host ~ \"^chat\\.\" ||\n req.http.Host ~ \"^charts\\.\" ||\n req.http.Host ~ \"^directory\\.\" ||\n req.http.Host ~ \"^codemirror\\.\" ||\n req.http.Host ~ \"^hello\\.\" ||\n req.http.Host ~ \"^sink\\.\" ||\n req.http.Host ~ \"^todos\\.\" ||\n req.http.Host ~ \"^widgets\\.\"\n ) {\n set req.backend = examples;\n } else if (req.http.Host ~ \"^components\\.\") {\n set req.backend = components;\n }\n\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization || req.http.Cookie) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n return (lookup);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n if (req.http.Origin) {\n hash_data(req.http.Origin);\n }\n return (hash);\n}\n\nsub vcl_pipe {\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n set bereq.http.connection = \"close\";\n # here. It is not set by default as it might break some broken web\n # applications, like IIS with NTLM authentication.\n\n # Websockets\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n\n return (pipe);\n}\n\nsub vcl_fetch {\n # Compress responses\n if (beresp.http.content-type ~ \"text\"\n || beresp.http.content-type ~ \"json\"\n || beresp.http.content-type ~ \"javascript\") {\n set beresp.do_gzip = true;\n }\n}\n\nsub vcl_error {\n if (obj.status == 750) {\n # moved permanently\n set obj.http.Location = req.http.Location;\n set obj.status = 301;\n } else if (obj.status == 752) {\n # moved temporarily\n set obj.http.Location = req.http.Location;\n set obj.status = 302;\n } else {\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic std.fileread(\"\/etc\/varnish\/503.html\");\n }\n return (deliver);\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"bb02eb72c36694ce1dfda1f545e4174c49ec5e8e","subject":"Only append country_code if it doesn't exist and also allow geo override for testing","message":"Only append country_code if it doesn't exist and also allow geo override for testing\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/fastly.vcl","new_file":"etc\/fastly.vcl","new_contents":"###############################################################################\n#\n# Fastly CDN for Magento 2\n#\n# NOTICE OF LICENSE\n#\n# This source file is subject to the Fastly CDN for Magento 2 End User License\n# Agreement that is bundled with this package in the file LICENSE_FASTLY_CDN.txt.\n#\n# @copyright Copyright (c) 2016 Fastly, Inc. (http:\/\/www.fastly.com)\n# @license BSD, see LICENSE_FASTLY_CDN.txt\n#\n###############################################################################\n\n# This is a basic VCL configuration file for Fastly CDN for Magento 2 module.\n\nsub vcl_recv {\n#FASTLY recv\n\n # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking\n set req.http.Fastly-Original-URL = req.url;\n set req.url = querystring.regfilter(req.url, \"^(utm_.*|gclid|gdftrk|_ga|mc_.*)\");\n\n if (req.url ~ \"^\/static\/version(\\d*\/)?(.*)$\") {\n set req.url = \"\/static\/\" + re.group.2 + \"?\" + re.group.1;\n } \n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n set req.http.X-Sig = regsub(req.http.X-Purge-Token, \"^[^_]+_(.*)\", \"\\1\");\n set req.http.X-Exp = regsub(req.http.X-Purge-Token, \"^([^_]+)_.*\", \"\\1\");\n\n # validate signature\n if (req.http.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path req.http.X-Exp), \"^0x\", \"\")) {\n\n # use vcl time math to check expiration timestamp\n set req.http.X-Original-Grace = req.grace;\n set req.grace = std.atoi(strftime({\"%s\"}, now));\n set req.grace -= std.atoi(req.http.X-Exp);\n\n if (std.atoi(req.grace) > 0) {\n error 410;\n }\n\n # clean up grace since we used it for time math\n set req.grace = std.atoi(req.http.X-Original-Grace);\n unset req.http.X-Original-Grace;\n\n } else {\n error 403;\n }\n\n # cleanup variables\n unset req.http.X-Purge-Token;\n unset req.http.X-Sig;\n unset req.http.X-Exp;\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n # disable ESI processing on Origin Shield\n if (req.http.Fastly-FF) {\n set req.esi = false;\n }\n\n # We only deal with GET and HEAD by default\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n return (pass);\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n return (lookup);\n }\n\n # Bypass shopping cart and checkout requests\n if (req.url ~ \"\/checkout\") {\n return (pass);\n }\n\n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie ~ \"(X-Magento-Vary|form_key)=\") {\n error 200 \"\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url !~ \"country_code=\" ) {\n set req.url = req.url \"?country_code=\" if ( req.http.geo_override, req.http.geo_override, geoip.country_code);\n }\n }\n }\n\n return(lookup);\n}\n\nsub vcl_fetch {\n\n # Remove Set-Cookies from responses for static content\n # to match the cookie removal in recv.\n if (req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n }\n\n }\n\n#FASTLY fetch\n\n if (beresp.status >= 500) {\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n }\n\n if (req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Content-Type ~ \"text\/html\" || beresp.http.Content-Type ~ \"text\/xml\") {\n # enable ESI feature for Magento response by default\n esi;\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content\n if ((beresp.status == 200 || beresp.status == 404) && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url ~ \"\\.(css|js|html|eot|ico|otf|ttf|json)($|\\?)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # cache only successfully responses and 404s\n if (beresp.status != 200 && beresp.status != 301 && beresp.status != 404) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\")) {\n unset beresp.http.set-cookie;\n if (req.url !~ \"^\/(pub\/)?(media|static)\/.*\") {\n set beresp.http.Pragma = \"no-cache\";\n set beresp.http.Expires = \"-1\";\n set beresp.http.Cache-Control = \"no-store, no-cache, must-revalidate, max-age=0\";\n set beresp.grace = 1m;\n }\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type\n if (beresp.http.Content-Type ~ \"image\") {\n set beresp.http.Surrogate-Key = \"image\";\n } elsif (beresp.http.Content-Type ~ \"script\") {\n set beresp.http.Surrogate-Key = \"script\";\n } elsif (beresp.http.Content-Type ~ \"css\") {\n set beresp.http.Surrogate-Key = \"css\";\n }\n\n set beresp.http.X-Surrogate-Key = beresp.http.Surrogate-Key;\n return (deliver);\n }\n\n return (deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\n\nsub vcl_miss {\n # Deactivate gzip on origin\n unset bereq.http.Accept-Encoding;\n\n#FASTLY miss\n\n return(fetch);\n}\n\nsub vcl_deliver {\n\n # Add an easy way to see whether custom Fastly VCL has been uploaded\n if ( req.http.Fastly-Debug ) {\n set resp.http.Fastly-Magento-VCL-Uploaded = \"yes\";\n } else {\n remove resp.http.Fastly-Module-Enabled;\n }\n # debug info\n if (resp.http.X-Magento-Debug) {\n if (obj.hits > 0) {\n set resp.http.X-Magento-Cache-Debug = \"HIT\";\n set resp.http.X-Magento-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Magento-Cache-Debug = \"MISS\";\n }\n } else {\n # remove Varnish\/proxy header\n remove resp.http.Age;\n remove resp.http.X-Magento-Debug;\n remove resp.http.X-Magento-Tags;\n remove resp.http.X-Surrogate-Key;\n remove resp.http.X-Magento-Cache-Control;\n remove resp.http.X-Powered-By;\n remove resp.http.Server;\n remove resp.http.X-Varnish;\n remove resp.http.Via;\n remove resp.http.Link;\n remove resp.http.X-Purge-URL;\n remove resp.http.X-Purge-Host;\n }\n\n#FASTLY deliver\n\n return (deliver);\n}\n\n\nsub vcl_error {\n # workaround for possible security issue\n if (req.url ~ \"^\\s\") {\n set obj.status = 400;\n set obj.response = \"Malformed request\";\n synthetic \"\";\n return (deliver);\n }\n\n # error 200\n if (obj.status == 200) {\n return (deliver);\n }\n\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} obj.status \" \" obj.response {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} obj.status \" \" obj.response {\"<\/h1>\n <p>\"} obj.response {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} req.xid {\"<\/p>\n <hr>\n <p>Fastly CDN server<\/p>\n <\/body>\n<\/html>\n\"};\n\n#FASTLY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n\nsub vcl_hash {\n set req.hash += req.http.Https;\n set req.hash += req.http.host;\n set req.hash += req.url;\n\n if (req.http.cookie:X-Magento-Vary ) {\n set req.hash += req.http.cookie:X-Magento-Vary;\n }\n \n set req.hash += \"#####GENERATION#####\";\n\n ### {{ design_exceptions_code }} ###\n\n return (hash);\n}\n\n","old_contents":"###############################################################################\n#\n# Fastly CDN for Magento 2\n#\n# NOTICE OF LICENSE\n#\n# This source file is subject to the Fastly CDN for Magento 2 End User License\n# Agreement that is bundled with this package in the file LICENSE_FASTLY_CDN.txt.\n#\n# @copyright Copyright (c) 2016 Fastly, Inc. (http:\/\/www.fastly.com)\n# @license BSD, see LICENSE_FASTLY_CDN.txt\n#\n###############################################################################\n\n# This is a basic VCL configuration file for Fastly CDN for Magento 2 module.\n\nsub vcl_recv {\n#FASTLY recv\n\n # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking\n set req.http.Fastly-Original-URL = req.url;\n set req.url = querystring.regfilter(req.url, \"^(utm_.*|gclid|gdftrk|_ga|mc_.*)\");\n\n if (req.url ~ \"^\/static\/version(\\d*\/)?(.*)$\") {\n set req.url = \"\/static\/\" + re.group.2 + \"?\" + re.group.1;\n } \n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n set req.http.X-Sig = regsub(req.http.X-Purge-Token, \"^[^_]+_(.*)\", \"\\1\");\n set req.http.X-Exp = regsub(req.http.X-Purge-Token, \"^([^_]+)_.*\", \"\\1\");\n\n # validate signature\n if (req.http.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path req.http.X-Exp), \"^0x\", \"\")) {\n\n # use vcl time math to check expiration timestamp\n set req.http.X-Original-Grace = req.grace;\n set req.grace = std.atoi(strftime({\"%s\"}, now));\n set req.grace -= std.atoi(req.http.X-Exp);\n\n if (std.atoi(req.grace) > 0) {\n error 410;\n }\n\n # clean up grace since we used it for time math\n set req.grace = std.atoi(req.http.X-Original-Grace);\n unset req.http.X-Original-Grace;\n\n } else {\n error 403;\n }\n\n # cleanup variables\n unset req.http.X-Purge-Token;\n unset req.http.X-Sig;\n unset req.http.X-Exp;\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n # disable ESI processing on Origin Shield\n if (req.http.Fastly-FF) {\n set req.esi = false;\n }\n\n # We only deal with GET and HEAD by default\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n return (pass);\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n return (lookup);\n }\n\n # Bypass shopping cart and checkout requests\n if (req.url ~ \"\/checkout\") {\n return (pass);\n }\n\n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie ~ \"(X-Magento-Vary|form_key)=\") {\n error 200 \"\";\n } else {\n # append parameter with country code\n set req.url = req.url \"?country_code=\" geoip.country_code;\n }\n }\n\n return(lookup);\n}\n\nsub vcl_fetch {\n\n # Remove Set-Cookies from responses for static content\n # to match the cookie removal in recv.\n if (req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n }\n\n }\n\n#FASTLY fetch\n\n if (beresp.status >= 500) {\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n }\n\n if (req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Content-Type ~ \"text\/html\" || beresp.http.Content-Type ~ \"text\/xml\") {\n # enable ESI feature for Magento response by default\n esi;\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content\n if ((beresp.status == 200 || beresp.status == 404) && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url ~ \"\\.(css|js|html|eot|ico|otf|ttf|json)($|\\?)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # cache only successfully responses and 404s\n if (beresp.status != 200 && beresp.status != 301 && beresp.status != 404) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\")) {\n unset beresp.http.set-cookie;\n if (req.url !~ \"^\/(pub\/)?(media|static)\/.*\") {\n set beresp.http.Pragma = \"no-cache\";\n set beresp.http.Expires = \"-1\";\n set beresp.http.Cache-Control = \"no-store, no-cache, must-revalidate, max-age=0\";\n set beresp.grace = 1m;\n }\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type\n if (beresp.http.Content-Type ~ \"image\") {\n set beresp.http.Surrogate-Key = \"image\";\n } elsif (beresp.http.Content-Type ~ \"script\") {\n set beresp.http.Surrogate-Key = \"script\";\n } elsif (beresp.http.Content-Type ~ \"css\") {\n set beresp.http.Surrogate-Key = \"css\";\n }\n\n set beresp.http.X-Surrogate-Key = beresp.http.Surrogate-Key;\n return (deliver);\n }\n\n return (deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\n\nsub vcl_miss {\n # Deactivate gzip on origin\n unset bereq.http.Accept-Encoding;\n\n#FASTLY miss\n\n return(fetch);\n}\n\nsub vcl_deliver {\n\n # Add an easy way to see whether custom Fastly VCL has been uploaded\n if ( req.http.Fastly-Debug ) {\n set resp.http.Fastly-Magento-VCL-Uploaded = \"yes\";\n } else {\n remove resp.http.Fastly-Module-Enabled;\n }\n # debug info\n if (resp.http.X-Magento-Debug) {\n if (obj.hits > 0) {\n set resp.http.X-Magento-Cache-Debug = \"HIT\";\n set resp.http.X-Magento-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Magento-Cache-Debug = \"MISS\";\n }\n } else {\n # remove Varnish\/proxy header\n remove resp.http.Age;\n remove resp.http.X-Magento-Debug;\n remove resp.http.X-Magento-Tags;\n remove resp.http.X-Surrogate-Key;\n remove resp.http.X-Magento-Cache-Control;\n remove resp.http.X-Powered-By;\n remove resp.http.Server;\n remove resp.http.X-Varnish;\n remove resp.http.Via;\n remove resp.http.Link;\n remove resp.http.X-Purge-URL;\n remove resp.http.X-Purge-Host;\n }\n\n#FASTLY deliver\n\n return (deliver);\n}\n\n\nsub vcl_error {\n # workaround for possible security issue\n if (req.url ~ \"^\\s\") {\n set obj.status = 400;\n set obj.response = \"Malformed request\";\n synthetic \"\";\n return (deliver);\n }\n\n # error 200\n if (obj.status == 200) {\n return (deliver);\n }\n\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} obj.status \" \" obj.response {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} obj.status \" \" obj.response {\"<\/h1>\n <p>\"} obj.response {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} req.xid {\"<\/p>\n <hr>\n <p>Fastly CDN server<\/p>\n <\/body>\n<\/html>\n\"};\n\n#FASTLY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n\nsub vcl_hash {\n set req.hash += req.http.Https;\n set req.hash += req.http.host;\n set req.hash += req.url;\n\n if (req.http.cookie:X-Magento-Vary ) {\n set req.hash += req.http.cookie:X-Magento-Vary;\n }\n \n set req.hash += \"#####GENERATION#####\";\n\n ### {{ design_exceptions_code }} ###\n\n return (hash);\n}\n\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"022097f22fe279e4997a972cc8ed23b3487937d3","subject":"Set the age header to 0 before sending the request back to the browser (#1282)","message":"Set the age header to 0 before sending the request back to the browser (#1282)\n\n* Remove the age header before sending the request back to the browser\r\n\r\n* Set Age header to 0 when delivering response\r\n","repos":"JakeChampion\/polyfill-service,mcshaz\/polyfill-service,mcshaz\/polyfill-service,mcshaz\/polyfill-service,JakeChampion\/polyfill-service","old_file":"vcl\/main.vcl","new_file":"vcl\/main.vcl","new_contents":"import boltsort;\n\nsub vcl_recv {\n#FASTLY recv\n\n\t# Enable API key authentication for URL purge requests\n\tif ( req.request == \"FASTLYPURGE\" ) {\n\t\tset req.http.Fastly-Purge-Requires-Auth = \"1\";\n\t}\n\n\tif (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n\t\treturn(pass);\n\t}\n\n\tif (req.http.Host ~ \"polyfills.io\") {\n\t\t# Do the canonicalise check before the SSL check to avoid a double redirect\n\t\terror 751 \"Canonicalise\";\n\t}\n\n\tif (!req.http.Fastly-SSL) {\n\t\t# 801 is a special error code that Fastly uses to Force SSL on the request\n\t\terror 801 \"Redirect to prod HTTPS\";\n\t}\n\n\tif (req.url ~ \"^\/v2\/(polyfill\\.|recordRumData)\" && req.url !~ \"[\\?\\&]ua=\") {\n\t\tset req.http.X-Orig-URL = req.url;\n\t\tset req.url = \"\/v2\/normalizeUa?ua=\" urlencode(req.http.User-Agent);\n\t}\n\n\tif (req.url ~ \"^\/v2\/recordRumData\" && req.http.Normalized-User-Agent) {\n\t\tset req.http.Log = regsub(req.url, \"^.*?\\?(.*)$\", \"\\1\") \"&ip=\" client.ip \"&refer_domain=\" regsub(req.http.Referer, \"^(https?\\:\\\/\\\/)?(www\\.)?(.+?)(\\:\\d+)?([\\\/\\?].*)?$\", \"\\3\") \"&country=\" geoip.country_code \"&data_center=\" if(req.http.Cookie:FastlyDC, req.http.Cookie:FastlyDC, server.datacenter);\n\t\terror 204 \"No Content\";\n\t}\n\n\tset req.url = boltsort.sort(req.url);\n\n\tif (req.restarts == 0) {\n\t\tset req.http.X-Original-Host = req.http.Host;\n\n\t\tif (req.http.Host == \"qa.polyfill.io\") {\n\t\t\tif (req.http.X-Geoip-Continent ~ \"(NA|SA|OC|AS)\") {\n\t\t\t\tset req.backend = origami_polyfill_service_us;\n\t\t\t\tset req.http.Host = \"ft-polyfill-service-us-qa.herokuapp.com\";\n\n\t\t\t\tif (!req.backend.healthy) {\n\t\t\t\t\tset req.backend = origami_polyfill_service_eu;\n\t\t\t\t\tset req.http.Host = \"ft-polyfill-service-qa.herokuapp.com\";\n\t\t\t\t}\n\n\t\t\t} else {\n\t\t\t\tset req.backend = origami_polyfill_service_eu;\n\t\t\t\tset req.http.Host = \"ft-polyfill-service-qa.herokuapp.com\";\n\n\t\t\t\tif (!req.backend.healthy) {\n\t\t\t\t\tset req.backend = origami_polyfill_service_us;\n\t\t\t\t\tset req.http.Host = \"ft-polyfill-service-us-qa.herokuapp.com\";\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tif (req.http.X-Geoip-Continent ~ \"(NA|SA|OC|AS)\") {\n\t\t\t\tset req.backend = origami_polyfill_service_us;\n\t\t\t\tset req.http.Host = \"ft-polyfill-service-us.herokuapp.com\";\n\n\t\t\t\tif (!req.backend.healthy) {\n\t\t\t\t\tset req.backend = origami_polyfill_service_eu;\n\t\t\t\t\tset req.http.Host = \"ft-polyfill-service.herokuapp.com\";\n\t\t\t\t}\n\n\t\t\t} else {\n\t\t\t\tset req.backend = origami_polyfill_service_eu;\n\t\t\t\tset req.http.Host = \"ft-polyfill-service.herokuapp.com\";\n\n\t\t\t\tif (!req.backend.healthy) {\n\t\t\t\t\tset req.backend = origami_polyfill_service_us;\n\t\t\t\t\tset req.http.Host = \"ft-polyfill-service-us.herokuapp.com\";\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t# https:\/\/community.fastly.com\/t\/brotli-compression-support\/578\/6\n\tif (req.http.Fastly-Orig-Accept-Encoding) {\n\t\tif (req.http.User-Agent ~ \"MSIE 6\") {\n\t\t\t# For that 0.3% of stubborn users out there\n\t\t\tunset req.http.Accept-Encoding;\n\t\t} elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"br\") {\n\t\t\tset req.http.Accept-Encoding = \"br\";\n\t\t} elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"gzip\") {\n\t\t\tset req.http.Accept-Encoding = \"gzip\";\n\t\t} else {\n\t\t\tunset req.http.Accept-Encoding;\n\t\t}\n\t}\n\n\treturn(lookup);\n}\n\nsub vcl_deliver {\n#FASTLY deliver\n\n\t# If the response is to a normalise request and there's a parked \"original request\", use the normalised UA response to modify the original request and restart it\n\tif (req.url ~ \"^\/v\\d\/normalizeUa\" && resp.status == 200 && req.http.X-Orig-URL ~ \"^\/v2\/(polyfill\\.|recordRumData)\") {\n\t\tset req.http.Fastly-force-Shield = \"1\";\n\t\tset req.http.Normalized-User-Agent = resp.http.Normalized-User-Agent;\n\t\tif (req.http.X-Orig-URL ~ \"\\?\") {\n\t\t\tset req.url = req.http.X-Orig-URL \"&ua=\" resp.http.Normalized-User-Agent;\n\t\t} else {\n\t\t\tset req.url = req.http.X-Orig-URL \"?ua=\" resp.http.Normalized-User-Agent;\n\t\t}\n\t\trestart;\n\n\t# If the original request didn't specify a UA override, and we added one when the request was sent to the backend, the backend won't have included a Vary:user-agent header (correctly) but we need to add one\n\t} else if (req.url ~ \"^\/v\\d\/polyfill\\..*[\\?\\&]ua=\" && req.http.X-Orig-URL && req.http.X-Orig-URL !~ \"[\\?\\&]ua=\") {\n\t\tadd resp.http.Vary = \"User-Agent\";\n\t}\n\n\tif (req.url ~ \"[\\&\\?]rum=1\") {\n\t\tadd resp.http.Set-Cookie = \"FastlyDC=\" server.datacenter \"; Path=\/; HttpOnly; max-age=60\";\n\t}\n\n\tif (req.http.Fastly-Debug) {\n\t\tset resp.http.Debug-Host = req.http.Host;\n\t\tset resp.http.Debug-X-Original-Host = req.http.X-Original-Host;\n\t}\n\t\n\tset resp.http.Age = 0;\n\n\treturn(deliver);\n}\n\nsub vcl_error {\n#FASTLY error\n\n\t# Redirect to canonical prod\/qa origins\n\tif (obj.status == 751) {\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\tset obj.http.Location = \"https:\/\/polyfill.io\" req.url;\n\t\tsynthetic {\"\"};\n\t\treturn (deliver);\n\t}\n}\n","old_contents":"import boltsort;\n\nsub vcl_recv {\n#FASTLY recv\n\n\t# Enable API key authentication for URL purge requests\n\tif ( req.request == \"FASTLYPURGE\" ) {\n\t\tset req.http.Fastly-Purge-Requires-Auth = \"1\";\n\t}\n\n\tif (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n\t\treturn(pass);\n\t}\n\n\tif (req.http.Host ~ \"polyfills.io\") {\n\t\t# Do the canonicalise check before the SSL check to avoid a double redirect\n\t\terror 751 \"Canonicalise\";\n\t}\n\n\tif (!req.http.Fastly-SSL) {\n\t\t# 801 is a special error code that Fastly uses to Force SSL on the request\n\t\terror 801 \"Redirect to prod HTTPS\";\n\t}\n\n\tif (req.url ~ \"^\/v2\/(polyfill\\.|recordRumData)\" && req.url !~ \"[\\?\\&]ua=\") {\n\t\tset req.http.X-Orig-URL = req.url;\n\t\tset req.url = \"\/v2\/normalizeUa?ua=\" urlencode(req.http.User-Agent);\n\t}\n\n\tif (req.url ~ \"^\/v2\/recordRumData\" && req.http.Normalized-User-Agent) {\n\t\tset req.http.Log = regsub(req.url, \"^.*?\\?(.*)$\", \"\\1\") \"&ip=\" client.ip \"&refer_domain=\" regsub(req.http.Referer, \"^(https?\\:\\\/\\\/)?(www\\.)?(.+?)(\\:\\d+)?([\\\/\\?].*)?$\", \"\\3\") \"&country=\" geoip.country_code \"&data_center=\" if(req.http.Cookie:FastlyDC, req.http.Cookie:FastlyDC, server.datacenter);\n\t\terror 204 \"No Content\";\n\t}\n\n\tset req.url = boltsort.sort(req.url);\n\n\tif (req.restarts == 0) {\n\t\tset req.http.X-Original-Host = req.http.Host;\n\n\t\tif (req.http.Host == \"qa.polyfill.io\") {\n\t\t\tif (req.http.X-Geoip-Continent ~ \"(NA|SA|OC|AS)\") {\n\t\t\t\tset req.backend = origami_polyfill_service_us;\n\t\t\t\tset req.http.Host = \"ft-polyfill-service-us-qa.herokuapp.com\";\n\n\t\t\t\tif (!req.backend.healthy) {\n\t\t\t\t\tset req.backend = origami_polyfill_service_eu;\n\t\t\t\t\tset req.http.Host = \"ft-polyfill-service-qa.herokuapp.com\";\n\t\t\t\t}\n\n\t\t\t} else {\n\t\t\t\tset req.backend = origami_polyfill_service_eu;\n\t\t\t\tset req.http.Host = \"ft-polyfill-service-qa.herokuapp.com\";\n\n\t\t\t\tif (!req.backend.healthy) {\n\t\t\t\t\tset req.backend = origami_polyfill_service_us;\n\t\t\t\t\tset req.http.Host = \"ft-polyfill-service-us-qa.herokuapp.com\";\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tif (req.http.X-Geoip-Continent ~ \"(NA|SA|OC|AS)\") {\n\t\t\t\tset req.backend = origami_polyfill_service_us;\n\t\t\t\tset req.http.Host = \"ft-polyfill-service-us.herokuapp.com\";\n\n\t\t\t\tif (!req.backend.healthy) {\n\t\t\t\t\tset req.backend = origami_polyfill_service_eu;\n\t\t\t\t\tset req.http.Host = \"ft-polyfill-service.herokuapp.com\";\n\t\t\t\t}\n\n\t\t\t} else {\n\t\t\t\tset req.backend = origami_polyfill_service_eu;\n\t\t\t\tset req.http.Host = \"ft-polyfill-service.herokuapp.com\";\n\n\t\t\t\tif (!req.backend.healthy) {\n\t\t\t\t\tset req.backend = origami_polyfill_service_us;\n\t\t\t\t\tset req.http.Host = \"ft-polyfill-service-us.herokuapp.com\";\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t# https:\/\/community.fastly.com\/t\/brotli-compression-support\/578\/6\n\tif (req.http.Fastly-Orig-Accept-Encoding) {\n\t\tif (req.http.User-Agent ~ \"MSIE 6\") {\n\t\t\t# For that 0.3% of stubborn users out there\n\t\t\tunset req.http.Accept-Encoding;\n\t\t} elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"br\") {\n\t\t\tset req.http.Accept-Encoding = \"br\";\n\t\t} elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"gzip\") {\n\t\t\tset req.http.Accept-Encoding = \"gzip\";\n\t\t} else {\n\t\t\tunset req.http.Accept-Encoding;\n\t\t}\n\t}\n\n\treturn(lookup);\n}\n\nsub vcl_deliver {\n#FASTLY deliver\n\n\t# If the response is to a normalise request and there's a parked \"original request\", use the normalised UA response to modify the original request and restart it\n\tif (req.url ~ \"^\/v\\d\/normalizeUa\" && resp.status == 200 && req.http.X-Orig-URL ~ \"^\/v2\/(polyfill\\.|recordRumData)\") {\n\t\tset req.http.Fastly-force-Shield = \"1\";\n\t\tset req.http.Normalized-User-Agent = resp.http.Normalized-User-Agent;\n\t\tif (req.http.X-Orig-URL ~ \"\\?\") {\n\t\t\tset req.url = req.http.X-Orig-URL \"&ua=\" resp.http.Normalized-User-Agent;\n\t\t} else {\n\t\t\tset req.url = req.http.X-Orig-URL \"?ua=\" resp.http.Normalized-User-Agent;\n\t\t}\n\t\trestart;\n\n\t# If the original request didn't specify a UA override, and we added one when the request was sent to the backend, the backend won't have included a Vary:user-agent header (correctly) but we need to add one\n\t} else if (req.url ~ \"^\/v\\d\/polyfill\\..*[\\?\\&]ua=\" && req.http.X-Orig-URL && req.http.X-Orig-URL !~ \"[\\?\\&]ua=\") {\n\t\tadd resp.http.Vary = \"User-Agent\";\n\t}\n\n\tif (req.url ~ \"[\\&\\?]rum=1\") {\n\t\tadd resp.http.Set-Cookie = \"FastlyDC=\" server.datacenter \"; Path=\/; HttpOnly; max-age=60\";\n\t}\n\n\tif (req.http.Fastly-Debug) {\n\t\tset resp.http.Debug-Host = req.http.Host;\n\t\tset resp.http.Debug-X-Original-Host = req.http.X-Original-Host;\n\t}\n\n\treturn(deliver);\n}\n\nsub vcl_error {\n#FASTLY error\n\n\t# Redirect to canonical prod\/qa origins\n\tif (obj.status == 751) {\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\tset obj.http.Location = \"https:\/\/polyfill.io\" req.url;\n\t\tsynthetic {\"\"};\n\t\treturn (deliver);\n\t}\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"c43f1ec1a8380b9324c1c7d1a6f78be955f162d7","subject":"Integration mode description","message":"Integration mode description","repos":"3scale\/libvmod-3scale,3scale\/libvmod-3scale","old_file":"vcl\/default_3scale_simple.vcl","new_file":"vcl\/default_3scale_simple.vcl","new_contents":"# This is a the VCL configuration file for 3scale's varnish plugin.\n# \n# Default backend definition. Set this to point to the 3scale's\n# backend. \n# \n# set the beresp.ttl in vcl_fetch to have a default global TTL\n# you can define custom TTL via regular expressions\n#\n# Integration mode: stand-alone out of band system.\n# Traffic from API consumers will not go through Varnish\n# (see https:\/\/support.3scale.net\/howtos\/api-configuration\/varnish)\n\nbackend default {\n .host = \"su1.3scale.net\"; \n .port = \"80\";\n}\n\nimport std;\nimport threescale;\n\nsub vcl_recv {\n\n\tunset req.http.cookie;\n\tset req.http.host = \"su1.3scale.net\";\n\tset req.grace = 1s;\n\n\tif (req.request != \"GET\" && req.request != \"HEAD\") {\n \t\treturn(pass);\n \t}\n \telse {\n \t\t## GET or HEAD requests\n \t\treturn(lookup);\n \t}\n\t \n}\n\n# the hash of the request needs to be customized to remove all fields that are not \n# associated to the user\n\nsub vcl_hash {\n\n\t## remove no_body\n\tset req.http.X-url-tmp = regsub(req.url,\"[&?]no_body.[^&]*\",\"\");\n\t## remove object_id\n\tset req.http.X-url-tmp = regsub(req.http.X-url-tmp,\"[&?]object.[^&]*\",\"\");\n\t## remove object\n\tset req.http.X-url-tmp = regsub(req.http.X-url-tmp,\"[&?]object_id.[^&]*\",\"\");\n\n\thash_data(req.http.X-url-tmp);\t\n\tunset req.http.X-url-tmp;\n \treturn (hash);\n\n}\n\n#A HIT means that the request to your local cache of 3scale is still fresh and the\n#response will not have to fetch the data from the remote 3scale backend.\n#vmod_3scale plugin will send a replica of the call asynchronously to 3scale's remote\n#backend on its own\n\nsub vcl_hit {\n\n if (req.url ~ \"^\/transactions\/authrep.xml\\?\") {\n\t if (req.url ~ \"^\/transactions\/authrep.xml\\?\") {\n\t if (threescale.send_get_request_threaded(\"su1.3scale.net\",\"80\",req.url,\"\")==0) {}\n }\n }\n\n}\n\n\nsub vcl_fetch {\n\tset beresp.ttl = 30s;\n}\n\n\n\n","old_contents":"# This is a the VCL configuration file for 3scale's varnish plugin.\n# \n# Default backend definition. Set this to point to the 3scale's\n# backend. \n# \n# set the beresp.ttl in vcl_fetch to have a default global TTL\n# you can define custom TTL via regular expressions\n#\n \n\nbackend default {\n .host = \"su1.3scale.net\"; \n .port = \"80\";\n}\n\nimport std;\nimport threescale;\n\nsub vcl_recv {\n\n\tunset req.http.cookie;\n\tset req.http.host = \"su1.3scale.net\";\n\tset req.grace = 1s;\n\n\tif (req.request != \"GET\" && req.request != \"HEAD\") {\n \t\treturn(pass);\n \t}\n \telse {\n \t\t## GET or HEAD requests\n \t\treturn(lookup);\n \t}\n\t \n}\n\n# the hash of the request needs to be customized to remove all fields that are not \n# associated to the user\n\nsub vcl_hash {\n\n\t## remove no_body\n\tset req.http.X-url-tmp = regsub(req.url,\"[&?]no_body.[^&]*\",\"\");\n\t## remove object_id\n\tset req.http.X-url-tmp = regsub(req.http.X-url-tmp,\"[&?]object.[^&]*\",\"\");\n\t## remove object\n\tset req.http.X-url-tmp = regsub(req.http.X-url-tmp,\"[&?]object_id.[^&]*\",\"\");\n\n\thash_data(req.http.X-url-tmp);\t\n\tunset req.http.X-url-tmp;\n \treturn (hash);\n\n}\n\n#A HIT means that the request to your local cache of 3scale is still fresh and the\n#response will not have to fetch the data from the remote 3scale backend.\n#vmod_3scale plugin will send a replica of the call asynchronously to 3scale's remote\n#backend on its own\n\nsub vcl_hit {\n\n if (req.url ~ \"^\/transactions\/authrep.xml\\?\") {\n\t if (req.url ~ \"^\/transactions\/authrep.xml\\?\") {\n\t if (threescale.send_get_request_threaded(\"su1.3scale.net\",\"80\",req.url,\"\")==0) {}\n }\n }\n\n}\n\n\nsub vcl_fetch {\n\tset beresp.ttl = 30s;\n}\n\n\n\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"01d14b8ddef4b53180da2d3a14b865be4cc36f01","subject":"Fix typo in examples\/example.vcl (redis.call -> redis.send)","message":"Fix typo in examples\/example.vcl (redis.call -> redis.send)\n\nSigned-off-by: Noah Williamsson <01479f9bf7817090e07c55bace445c48178b77b4@gmail.com>\n","repos":"brandonwamboldt\/libvmod-redis,brandonwamboldt\/libvmod-redis,zephirworks\/libvmod-redis,SBRDevelopment\/libvmod-redis,zephirworks\/libvmod-redis,SBRDevelopment\/libvmod-redis","old_file":"examples\/example.vcl","new_file":"examples\/example.vcl","new_contents":"#\n# A trivial example to demonstrate how to use this vmod\n#\n\nimport redis;\n\nbackend be1 {\n .host = \"192.168.0.1\";\n .port = \"80\";\n}\n\n#sub vcl_init {\n #\n # By default, the redis module will attempt to connect to a Redis server\n # at 127.0.0.1:6379 with a connect timeout of 200 milliseconds.\n #\n # The function redis.init_redis(host, port, timeout_ms) may be used to\n # connect to an alternate Redis server or use a different connect timeout.\n #\n # redis.init_redis(\"localhost\", 6379, 200); \/* default values *\/\n#}\n\nsub vcl_recv {\n #\n # redis.send is a procedure, it will send the command to redis and ignore\n # the response. If the command errors out, it will be logged but the VCL\n # will not know.\n #\n redis.send(\"LPUSH client \" + client.ip);\n\n #\n # redis.call is a function that sends the command to redis and return the\n # return value as a string.\n #\n set req.http.x-redis = redis.call(\"LTRIM client 0 99\");\n}\n","old_contents":"#\n# A trivial example to demonstrate how to use this vmod\n#\n\nimport redis;\n\nbackend be1 {\n .host = \"192.168.0.1\";\n .port = \"80\";\n}\n\n#sub vcl_init {\n #\n # By default, the redis module will attempt to connect to a Redis server\n # at 127.0.0.1:6379 with a connect timeout of 200 milliseconds.\n #\n # The function redis.init_redis(host, port, timeout_ms) may be used to\n # connect to an alternate Redis server or use a different connect timeout.\n #\n # redis.init_redis(\"localhost\", 6379, 200); \/* default values *\/\n#}\n\nsub vcl_recv {\n #\n # redis.call is a procedure, it will send the command to redis and ignore\n # the response. If the command errors out, it will be logged but the VCL\n # will not know.\n #\n redis.send(\"LPUSH client \" + client.ip);\n\n #\n # redis.call is a function that sends the command to redis and return the\n # return value as a string.\n #\n set req.http.x-redis = redis.call(\"LTRIM client 0 99\");\n}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"eecc0f45232fde71485c6395a14e02eced1bb784","subject":"Add detection for windows mobile","message":"Add detection for windows mobile\n","repos":"borisguery\/varnish-device-detect","old_file":"devicedetect.vcl","new_file":"devicedetect.vcl","new_contents":"sub devicedetect {\n unset req.http.X-UA-Device-Type;\n\n \/\/ sensible defaults\n set req.http.X-UA-Device-Type = \"generic\";\n set req.http.X-UA-Device-OS = \"unknown\";\n\n if (req.http.Cookie ~ \"(?i)X-UA-Device-Force\") {\n } else {\n if (req.http.User-Agent ~ \"(?i)ipad\") {\n set req.http.X-UA-Device-Type = \"tablet\";\n set req.http.X-UA-Device-OS = \"ios\";\n } elsif (req.http.User-Agent ~ \"(?i)ip(hone|od)\") {\n set req.http.X-UA-Device-Type = \"mobile\";\n set req.http.X-UA-Device-OS = \"ios\";\n } elsif (req.http.User-Agent ~ \"(?i)android\") {\n \/\/ http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent\n set req.http.X-UA-Device-OS = \"android\";\n if (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") {\n set req.http.X-UA-Device-Type = \"mobile\";\n } elseif (req.http.User-Agent ~ \"(?i)android 3\") { \/\/ looks like android 3\/honeycomb are mostly tablet-only\n set req.http.X-UA-Device-Type = \"tablet\";\n } elseif (req.http.User-Agent ~ \"(?i)android 2\") { \/\/ it should not exist any tablet prior to android 3\n set req.http.X-UA-Device-Type = \"mobile\";\n } else {\n \/\/ fallback on tablet\n set req.http.X-UA-Device-Type = \"tablet\";\n }\n } elseif (req.http.User-Agent ~ \"(?i)windows phone\" || req.http.User-Agent ~ \"(?i)windowsphone\") { \/\/ Should we match IEMobile too or instead?\n set req.http.X-UA-Device-Type = \"mobile\";\n set req.http.X-UA-Device-OS = \"windowsphone\";\n } elseif (req.http.User-Agent ~ \"(?i)windows mobile\" || req.http.User-Agent ~ \"(?i)windowsmobile\") { \/\/ Not sure if it makes sense\n set req.http.X-UA-Device-Type = \"mobile\";\n set req.http.X-UA-Device-OS = \"windowsmobile\";\n } elseif (req.http.User-Agent ~ \"(?i)blackberry[0-9]?\" || req.http.User-Agent ~ \"(?i)BB10\") {\n set req.http.X-UA-Device-OS = \"blackberry\";\n \/\/ For now, let's assume all blackberry devices are mobile\n \/\/ Afaik, it does not exist blackberry tablets\n set req.http.X-UA-Device-Type = \"mobile\";\n }\n }\n}\n","old_contents":"sub devicedetect {\n unset req.http.X-UA-Device-Type;\n\n \/\/ sensible defaults\n set req.http.X-UA-Device-Type = \"generic\";\n set req.http.X-UA-Device-OS = \"unknown\";\n\n if (req.http.Cookie ~ \"(?i)X-UA-Device-Force\") {\n } else {\n if (req.http.User-Agent ~ \"(?i)ipad\") {\n set req.http.X-UA-Device-Type = \"tablet\";\n set req.http.X-UA-Device-OS = \"ios\";\n } elsif (req.http.User-Agent ~ \"(?i)ip(hone|od)\") {\n set req.http.X-UA-Device-Type = \"mobile\";\n set req.http.X-UA-Device-OS = \"ios\";\n } elsif (req.http.User-Agent ~ \"(?i)android\") {\n \/\/ http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent\n set req.http.X-UA-Device-OS = \"android\";\n if (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") {\n set req.http.X-UA-Device-Type = \"mobile\";\n } elseif (req.http.User-Agent ~ \"(?i)android 3\") { \/\/ looks like android 3\/honeycomb are mostly tablet-only\n set req.http.X-UA-Device-Type = \"tablet\";\n } elseif (req.http.User-Agent ~ \"(?i)android 2\") { \/\/ it should not exist any tablet prior to android 3\n set req.http.X-UA-Device-Type = \"mobile\";\n } else {\n \/\/ fallback on tablet\n set req.http.X-UA-Device-Type = \"tablet\";\n }\n } elseif (req.http.User-Agent ~ \"(?i)windows phone\" || req.http.User-Agent ~ \"(?i)windowsphone\") { \/\/ Should we match IEMobile too or instead?\n set req.http.X-UA-Device-Type = \"mobile\";\n set req.http.X-UA-Device-OS = \"windowsphone\";\n } elseif (req.http.User-Agent ~ \"(?i)blackberry[0-9]?\" || req.http.User-Agent ~ \"(?i)BB10\") {\n set req.http.X-UA-Device-OS = \"blackberry\";\n \/\/ For now, let's assume all blackberry devices are mobile\n \/\/ Afaik, it does not exist blackberry tablets\n set req.http.X-UA-Device-Type = \"mobile\";\n }\n }\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"5d50e8b5007729bb13f2680e262470b8ed14a2be","subject":"Add copyright and license information to devicedetect.vcl","message":"Add copyright and license information to devicedetect.vcl\n","repos":"varnish\/Varnish-Cache,alarky\/varnish-cache-doc-ja,chrismoulton\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,alarky\/varnish-cache-doc-ja,gquintard\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,mrhmouse\/Varnish-Cache,zhoualbeart\/Varnish-Cache,mrhmouse\/Varnish-Cache,varnish\/Varnish-Cache,zhoualbeart\/Varnish-Cache,gquintard\/Varnish-Cache,feld\/Varnish-Cache,feld\/Varnish-Cache,gquintard\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,zhoualbeart\/Varnish-Cache,gquintard\/Varnish-Cache,chrismoulton\/Varnish-Cache,alarky\/varnish-cache-doc-ja,feld\/Varnish-Cache,zhoualbeart\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,franciscovg\/Varnish-Cache,zhoualbeart\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,varnish\/Varnish-Cache,chrismoulton\/Varnish-Cache,mrhmouse\/Varnish-Cache,varnish\/Varnish-Cache,feld\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,alarky\/varnish-cache-doc-ja,mrhmouse\/Varnish-Cache,feld\/Varnish-Cache,franciscovg\/Varnish-Cache,franciscovg\/Varnish-Cache,franciscovg\/Varnish-Cache,franciscovg\/Varnish-Cache,varnish\/Varnish-Cache,chrismoulton\/Varnish-Cache,chrismoulton\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,alarky\/varnish-cache-doc-ja,mrhmouse\/Varnish-Cache,ajasty-cavium\/Varnish-Cache","old_file":"etc\/devicedetect.vcl","new_file":"etc\/devicedetect.vcl","new_contents":"# Copyright (c) 2012-2013 Varnish Software AS\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions\n# are met:\n# 1. Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n# 2. Redistributions in binary form must reproduce the above copyright\n# notice, this list of conditions and the following disclaimer in the\n# documentation and\/or other materials provided with the distribution.\n#\n# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n# ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n# SUCH DAMAGE.\n#\n# detectdevice.vcl - regex based device detection for Varnish\n# http:\/\/github.com\/varnish\/varnish-devicedetect\/\n#\n# Author: Lasse Karstensen <lasse@varnish-software.com>\n\nsub devicedetect {\n\tunset req.http.X-UA-Device;\n\tset req.http.X-UA-Device = \"pc\";\n\n\t# Handle that a cookie may override the detection alltogether.\n\tif (req.http.Cookie ~ \"(?i)X-UA-Device-force\") {\n\t\t\/* ;?? means zero or one ;, non-greedy to match the first. *\/\n\t\tset req.http.X-UA-Device = regsub(req.http.Cookie, \"(?i).*X-UA-Device-force=([^;]+);??.*\", \"\\1\");\n\t\t\/* Clean up our mess in the cookie header *\/\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|; ) *X-UA-Device-force=[^;]+;? *\", \"\\1\");\n\t\t\/* If the cookie header is now empty, or just whitespace, unset it. *\/\n\t\tif (req.http.Cookie ~ \"^ *$\") { unset req.http.Cookie; }\n\t} else {\n\t\tif (req.http.User-Agent ~ \"(?i)(ads|google|bing|msn|yandex|baidu|ro|career|)bot\" ||\n\t\t req.http.User-Agent ~ \"(?i)(baidu|jike|symantec)spider\" ||\n\t\t req.http.User-Agent ~ \"(?i)scanner\" ||\n\t\t req.http.User-Agent ~ \"(?i)(web)crawler\") {\n\t\t\tset req.http.X-UA-Device = \"bot\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ipad\") { set req.http.X-UA-Device = \"tablet-ipad\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ip(hone|od)\") { set req.http.X-UA-Device = \"mobile-iphone\"; }\n\t\t\/* how do we differ between an android phone and an android tablet?\n\t\t http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent *\/\n\t\telsif (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") { set req.http.X-UA-Device = \"mobile-android\"; }\n\t\t\/\/ android 3\/honeycomb was just about tablet-only, and any phones will probably handle a bigger page layout.\n\t\telsif (req.http.User-Agent ~ \"(?i)android 3\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\t\/\/ May very well give false positives towards android tablets. Suggestions welcome.\n\t\telsif (req.http.User-Agent ~ \"(?i)android\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\telsif (req.http.User-Agent ~ \"Mobile.+Firefox\") { set req.http.X-UA-Device = \"mobile-firefoxos\"; }\n\t\telsif (req.http.User-Agent ~ \"^HTC\" ||\n\t\t req.http.User-Agent ~ \"Fennec\" ||\n\t\t req.http.User-Agent ~ \"IEMobile\" ||\n\t\t req.http.User-Agent ~ \"BlackBerry\" ||\n\t\t req.http.User-Agent ~ \"SymbianOS.*AppleWebKit\" ||\n\t\t req.http.User-Agent ~ \"Opera Mobi\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-smartphone\";\n\t\t}\n\t\telsif (req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)^sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)^nokia\" ||\n\t\t req.http.User-Agent ~ \"(?i)^samsung\" ||\n\t\t req.http.User-Agent ~ \"(?i)^lg\" ||\n\t\t req.http.User-Agent ~ \"(?i)bada\" ||\n\t\t req.http.User-Agent ~ \"(?i)blazer\" ||\n\t\t req.http.User-Agent ~ \"(?i)cellphone\" ||\n\t\t req.http.User-Agent ~ \"(?i)iemobile\" ||\n\t\t req.http.User-Agent ~ \"(?i)midp-2.0\" ||\n\t\t req.http.User-Agent ~ \"(?i)u990\" ||\n\t\t req.http.User-Agent ~ \"(?i)netfront\" ||\n\t\t req.http.User-Agent ~ \"(?i)opera mini\" ||\n\t\t req.http.User-Agent ~ \"(?i)palm\" ||\n\t\t req.http.User-Agent ~ \"(?i)nintendo wii\" ||\n\t\t req.http.User-Agent ~ \"(?i)playstation portable\" ||\n\t\t req.http.User-Agent ~ \"(?i)portalmmm\" ||\n\t\t req.http.User-Agent ~ \"(?i)proxinet\" ||\n\t\t req.http.User-Agent ~ \"(?i)sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)windows\\ ?ce\" ||\n\t\t req.http.User-Agent ~ \"(?i)winwap\" ||\n\t\t req.http.User-Agent ~ \"(?i)eudoraweb\" ||\n\t\t req.http.User-Agent ~ \"(?i)htc\" ||\n\t\t req.http.User-Agent ~ \"(?i)240x320\" ||\n\t\t req.http.User-Agent ~ \"(?i)avantgo\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-generic\";\n\t\t}\n\t}\n}\n","old_contents":"#\n# detectdevice.vcl - regex based device detection for Varnish\n# http:\/\/github.com\/varnish\/varnish-devicedetect\/\n#\n# Author: Lasse Karstensen <lasse@varnish-software.com>\n\nsub devicedetect {\n\tunset req.http.X-UA-Device;\n\tset req.http.X-UA-Device = \"pc\";\n\n\t# Handle that a cookie may override the detection alltogether.\n\tif (req.http.Cookie ~ \"(?i)X-UA-Device-force\") {\n\t\t\/* ;?? means zero or one ;, non-greedy to match the first. *\/\n\t\tset req.http.X-UA-Device = regsub(req.http.Cookie, \"(?i).*X-UA-Device-force=([^;]+);??.*\", \"\\1\");\n\t\t\/* Clean up our mess in the cookie header *\/\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|; ) *X-UA-Device-force=[^;]+;? *\", \"\\1\");\n\t\t\/* If the cookie header is now empty, or just whitespace, unset it. *\/\n\t\tif (req.http.Cookie ~ \"^ *$\") { unset req.http.Cookie; }\n\t} else {\n\t\tif (req.http.User-Agent ~ \"(?i)(ads|google|bing|msn|yandex|baidu|ro|career|)bot\" ||\n\t\t req.http.User-Agent ~ \"(?i)(baidu|jike|symantec)spider\" ||\n\t\t req.http.User-Agent ~ \"(?i)scanner\" ||\n\t\t req.http.User-Agent ~ \"(?i)(web)crawler\") {\n\t\t\tset req.http.X-UA-Device = \"bot\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ipad\") { set req.http.X-UA-Device = \"tablet-ipad\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ip(hone|od)\") { set req.http.X-UA-Device = \"mobile-iphone\"; }\n\t\t\/* how do we differ between an android phone and an android tablet?\n\t\t http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent *\/\n\t\telsif (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") { set req.http.X-UA-Device = \"mobile-android\"; }\n\t\t\/\/ android 3\/honeycomb was just about tablet-only, and any phones will probably handle a bigger page layout.\n\t\telsif (req.http.User-Agent ~ \"(?i)android 3\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\t\/\/ May very well give false positives towards android tablets. Suggestions welcome.\n\t\telsif (req.http.User-Agent ~ \"(?i)android\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\telsif (req.http.User-Agent ~ \"Mobile.+Firefox\") { set req.http.X-UA-Device = \"mobile-firefoxos\"; }\n\t\telsif (req.http.User-Agent ~ \"^HTC\" ||\n\t\t req.http.User-Agent ~ \"Fennec\" ||\n\t\t req.http.User-Agent ~ \"IEMobile\" ||\n\t\t req.http.User-Agent ~ \"BlackBerry\" ||\n\t\t req.http.User-Agent ~ \"SymbianOS.*AppleWebKit\" ||\n\t\t req.http.User-Agent ~ \"Opera Mobi\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-smartphone\";\n\t\t}\n\t\telsif (req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)^sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)^nokia\" ||\n\t\t req.http.User-Agent ~ \"(?i)^samsung\" ||\n\t\t req.http.User-Agent ~ \"(?i)^lg\" ||\n\t\t req.http.User-Agent ~ \"(?i)bada\" ||\n\t\t req.http.User-Agent ~ \"(?i)blazer\" ||\n\t\t req.http.User-Agent ~ \"(?i)cellphone\" ||\n\t\t req.http.User-Agent ~ \"(?i)iemobile\" ||\n\t\t req.http.User-Agent ~ \"(?i)midp-2.0\" ||\n\t\t req.http.User-Agent ~ \"(?i)u990\" ||\n\t\t req.http.User-Agent ~ \"(?i)netfront\" ||\n\t\t req.http.User-Agent ~ \"(?i)opera mini\" ||\n\t\t req.http.User-Agent ~ \"(?i)palm\" ||\n\t\t req.http.User-Agent ~ \"(?i)nintendo wii\" ||\n\t\t req.http.User-Agent ~ \"(?i)playstation portable\" ||\n\t\t req.http.User-Agent ~ \"(?i)portalmmm\" ||\n\t\t req.http.User-Agent ~ \"(?i)proxinet\" ||\n\t\t req.http.User-Agent ~ \"(?i)sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)windows\\ ?ce\" ||\n\t\t req.http.User-Agent ~ \"(?i)winwap\" ||\n\t\t req.http.User-Agent ~ \"(?i)eudoraweb\" ||\n\t\t req.http.User-Agent ~ \"(?i)htc\" ||\n\t\t req.http.User-Agent ~ \"(?i)240x320\" ||\n\t\t req.http.User-Agent ~ \"(?i)avantgo\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-generic\";\n\t\t}\n\t}\n}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"d8f74bc538393bb8c67de3660c7126dc144487f2","subject":"Reindent with 4 spaces, 2 for continuations","message":"Reindent with 4 spaces, 2 for continuations\n","repos":"gauthier-delacroix\/Varnish-Cache,mrhmouse\/Varnish-Cache,franciscovg\/Varnish-Cache,gquintard\/Varnish-Cache,alarky\/varnish-cache-doc-ja,ajasty-cavium\/Varnish-Cache,chrismoulton\/Varnish-Cache,feld\/Varnish-Cache,chrismoulton\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,feld\/Varnish-Cache,mrhmouse\/Varnish-Cache,varnish\/Varnish-Cache,franciscovg\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,alarky\/varnish-cache-doc-ja,zhoualbeart\/Varnish-Cache,mrhmouse\/Varnish-Cache,varnish\/Varnish-Cache,zhoualbeart\/Varnish-Cache,gquintard\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,feld\/Varnish-Cache,alarky\/varnish-cache-doc-ja,gquintard\/Varnish-Cache,franciscovg\/Varnish-Cache,varnish\/Varnish-Cache,alarky\/varnish-cache-doc-ja,gquintard\/Varnish-Cache,zhoualbeart\/Varnish-Cache,franciscovg\/Varnish-Cache,feld\/Varnish-Cache,alarky\/varnish-cache-doc-ja,chrismoulton\/Varnish-Cache,feld\/Varnish-Cache,zhoualbeart\/Varnish-Cache,chrismoulton\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,chrismoulton\/Varnish-Cache,zhoualbeart\/Varnish-Cache,mrhmouse\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,varnish\/Varnish-Cache,mrhmouse\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,varnish\/Varnish-Cache,franciscovg\/Varnish-Cache","old_file":"bin\/varnishd\/builtin.vcl","new_file":"bin\/varnishd\/builtin.vcl","new_contents":"\/*-\n * Copyright (c) 2006 Verdens Gang AS\n * Copyright (c) 2006-2014 Varnish Software AS\n * All rights reserved.\n *\n * Author: Poul-Henning Kamp <phk@phk.freebsd.dk>\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in the\n * documentation and\/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n\n *\n * The built-in (previously called default) VCL code.\n *\n * NB! You do NOT need to copy & paste all of these functions into your\n * own vcl code, if you do not provide a definition of one of these\n * functions, the compiler will automatically fall back to the default\n * code from this file.\n *\n * This code will be prefixed with a backend declaration built from the\n * -b argument.\n *\/\n\nvcl 4.0;\n\n#######################################################################\n# Client side\n\nsub vcl_recv {\n if (req.restarts == 0) {\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For =\n req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization || req.http.Cookie) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n return (hash);\n}\n\nsub vcl_pipe {\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n # set bereq.http.connection = \"close\";\n # here. It is not set by default as it might break some broken web\n # applications, like IIS with NTLM authentication.\n return (pipe);\n}\n\nsub vcl_pass {\n return (fetch);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n return (lookup);\n}\n\nsub vcl_purge {\n return (error(200, \"Purged\"));\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n \/\/ A pure unadultered hit, deliver it\n return (deliver);\n }\n if (obj.ttl + obj.grace > 0s) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n return (deliver);\n }\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\nsub vcl_miss {\n return (fetch);\n}\n\nsub vcl_deliver {\n \/*\n * These two write to the stored object causing extra page faults\n * Enable them only if you need them.\n *\n * set obj.hits = obj.hits + 1;\n * set obj.last_use = now;\n *\/\n return (deliver);\n}\n\n\/*\n * We can come here \"invisibly\" with the following errors: 413, 417 & 503\n *\/\nsub vcl_error {\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} + obj.status + \" \" + obj.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + obj.status + \" \" + obj.reason + {\"<\/h1>\n <p>\"} + obj.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"};\n return (deliver);\n}\n\n#######################################################################\n# Backend Fetch\n\nsub vcl_backend_fetch {\n return (fetch);\n}\n\nsub vcl_backend_response {\n if (beresp.ttl <= 0s ||\n beresp.http.Set-Cookie ||\n beresp.http.Surrogate-control ~ \"no-store\" ||\n (!beresp.http.Surrogate-Control &&\n beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n beresp.http.Vary == \"*\") {\n \/*\n * Mark as \"Hit-For-Pass\" for the next 2 minutes\n *\/\n set beresp.ttl = 120s;\n set beresp.uncacheable = true;\n }\n return (deliver);\n}\n\nsub vcl_backend_error {\n return (deliver);\n}\n\n#######################################################################\n# Housekeeping\n\nsub vcl_init {\n return (ok);\n}\n\nsub vcl_fini {\n return (ok);\n}\n","old_contents":"\/*-\n * Copyright (c) 2006 Verdens Gang AS\n * Copyright (c) 2006-2014 Varnish Software AS\n * All rights reserved.\n *\n * Author: Poul-Henning Kamp <phk@phk.freebsd.dk>\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in the\n * documentation and\/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n\n *\n * The built-in (previously called default) VCL code.\n *\n * NB! You do NOT need to copy & paste all of these functions into your\n * own vcl code, if you do not provide a definition of one of these\n * functions, the compiler will automatically fall back to the default\n * code from this file.\n *\n * This code will be prefixed with a backend declaration built from the\n * -b argument.\n *\/\n\nvcl 4.0;\n\n#######################################################################\n# Client side\n\nsub vcl_recv {\n if (req.restarts == 0) {\n\tif (req.http.x-forwarded-for) {\n\t set req.http.X-Forwarded-For =\n\t\treq.http.X-Forwarded-For + \", \" + client.ip;\n\t} else {\n\t set req.http.X-Forwarded-For = client.ip;\n\t}\n }\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization || req.http.Cookie) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n return (hash);\n}\n\nsub vcl_pipe {\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n # set bereq.http.connection = \"close\";\n # here. It is not set by default as it might break some broken web\n # applications, like IIS with NTLM authentication.\n return (pipe);\n}\n\nsub vcl_pass {\n return (fetch);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n return (lookup);\n}\n\nsub vcl_purge {\n return (error(200, \"Purged\"));\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n\t\/\/ A pure unadultered hit, deliver it\n\treturn (deliver);\n }\n if (obj.ttl + obj.grace > 0s) {\n\t\/\/ Object is in grace, deliver it\n\t\/\/ Automatically triggers a background fetch\n\treturn (deliver);\n }\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\nsub vcl_miss {\n return (fetch);\n}\n\nsub vcl_deliver {\n \/*\n * These two write to the stored object causing extra page faults\n * Enable them only if you need them.\n *\n * set obj.hits = obj.hits + 1;\n * set obj.last_use = now;\n *\/\n return (deliver);\n}\n\n\/*\n * We can come here \"invisibly\" with the following errors: 413, 417 & 503\n *\/\nsub vcl_error {\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} + obj.status + \" \" + obj.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + obj.status + \" \" + obj.reason + {\"<\/h1>\n <p>\"} + obj.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"};\n return (deliver);\n}\n\n#######################################################################\n# Backend Fetch\n\nsub vcl_backend_fetch {\n return (fetch);\n}\n\nsub vcl_backend_response {\n if (beresp.ttl <= 0s ||\n beresp.http.Set-Cookie ||\n beresp.http.Surrogate-control ~ \"no-store\" ||\n (!beresp.http.Surrogate-Control &&\n beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n beresp.http.Vary == \"*\") {\n\t\t\/*\n\t\t * Mark as \"Hit-For-Pass\" for the next 2 minutes\n\t\t *\/\n\t\tset beresp.ttl = 120s;\n\t\tset beresp.uncacheable = true;\n }\n return (deliver);\n}\n\nsub vcl_backend_error {\n\treturn (deliver);\n}\n\n#######################################################################\n# Housekeeping\n\nsub vcl_init {\n return (ok);\n}\n\nsub vcl_fini {\n return (ok);\n}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"39173fd88b0697884dbe718e0c598ad770c0e5f1","subject":"Apply IO header on both shield and edge","message":"Apply IO header on both shield and edge\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets_image_optimizations\/recv.vcl","new_file":"etc\/vcl_snippets_image_optimizations\/recv.vcl","new_contents":"if ( req.url.ext ~ \"(?i)^(gif|png|jpg|jpeg|webp)$\" ) {\n\n set req.http.X-Fastly-Imageopto-Api = \"fastly\";\n\n if (req.url.qs != \"\") {\n set req.url = req.url.path \"?\" req.url.qs \"&auto=webp\";\n } else {\n set req.url = req.url.path \"?auto=webp\";\n }\n}\n","old_contents":"if (!req.http.Fastly-FF && req.url.ext ~ \"(?i)^(gif|png|jpg|jpeg|webp)$\") {\n\n set req.http.X-Fastly-Imageopto-Api = \"fastly\";\n\n if (req.url.qs != \"\") {\n set req.url = req.url.path \"?\" req.url.qs \"&auto=webp\";\n } else {\n set req.url = req.url.path \"?auto=webp\";\n }\n}\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"769fb997bbfb42cedea860d93f71765fc30b0e48","subject":"Remove escaped slashes as they are not necessary in regexes. Avoids the new VCL linter from complaining","message":"Remove escaped slashes as they are not necessary in regexes. Avoids the new VCL linter from complaining\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets\/fetch.vcl","new_file":"etc\/vcl_snippets\/fetch.vcl","new_contents":" \/* handle 5XX (or any other unwanted status code) *\/\n if (beresp.status >= 500 && beresp.status < 600) {\n\n \/* deliver stale if the object is available *\/\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n # Remove Set-Cookies from responses for static content to match the cookie removal in recv.\n if (req.http.x-long-cache || req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's since those can be temporary during the site build\/index\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n set beresp.http.Cache-Control = \"max-age=0\";\n } else if (req.http.x-long-cache) {\n # Force caching for signed cached assets.\n set beresp.ttl = 31536000s;\n # Add immutable as it avoids IMS and INM revalidations\n set beresp.http.Cache-Control = \"max-age=31536000, immutable\";\n }\n }\n\n # Fix Vary Header in some cases. In 99.9% of cases Varying on User-Agent is counterproductive\n # https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleFixupVary\n if (beresp.http.Vary ~ \"User-Agent\") {\n unset beresp.http.Vary:User-Agent;\n if (beresp.http.Vary == \"\") {\n unset beresp.http.Vary;\n }\n }\n\n # All the Magento responses should emit X-Esi headers\n if (beresp.http.x-esi) {\n # enable ESI feature for Magento response by default\n esi;\n } else {\n # enable gzip for all static content except\n if ( http_status_matches(beresp.status, \"200,404\") && (beresp.http.content-type ~ \"^(application\/x\\-javascript|text\/css|text\/html|application\/javascript|text\/javascript|application\/json|application\/vnd\\.ms\\-fontobject|application\/x\\-font\\-opentype|application\/x\\-font\\-truetype|application\/x\\-font\\-ttf|application\/xml|font\/eot|font\/opentype|font\/otf|image\/svg\\+xml|image\/vnd\\.microsoft\\.icon|text\/plain)\\s*($|;)\" || req.url.ext ~ \"(?i)(css|js|html|eot|ico|otf|ttf|json)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n set beresp.http.Vary:Accept-Encoding = \"\";\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # Add Varying on X-Magento-Vary\n if (beresp.http.Content-Type ~ \"text\/(html|xml)\" || req.http.graphql) {\n set beresp.http.Vary:X-Magento-Vary = \"\";\n set beresp.http.Vary:Https = \"\";\n }\n\n # Just in case the Request Setting for x-pass is missing\n if (req.http.x-pass) {\n return (pass);\n }\n\n if (beresp.http.Cache-Control ~ \"private|no-cache|no-store\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # Never cache 302s\n if (beresp.status == 302) {\n return (pass);\n }\n\n if (beresp.http.x-amz-request-id) {\n # If assets are coming from Amazon they may have no Cache-Control headers which may make them uncacheable\n } else if (!beresp.http.Expires && !beresp.http.Surrogate-Control ~ \"max-age\" && !beresp.http.Cache-Control ~ \"(s-maxage|max-age)\") {\n # Varnish sets default TTL if none of the headers above are present. If not set we want to make sure we don't cache it\n set beresp.ttl = 0s;\n set beresp.cacheable = false;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\") && !req.http.x-pass ) {\n unset beresp.http.set-cookie;\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type if they are image\/script or CSS\n if (beresp.http.Content-Type ~ \"(image|script|css)\") {\n set beresp.http.Surrogate-Key = re.group.1;\n }\n }\n","old_contents":" \/* handle 5XX (or any other unwanted status code) *\/\n if (beresp.status >= 500 && beresp.status < 600) {\n\n \/* deliver stale if the object is available *\/\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n # Remove Set-Cookies from responses for static content to match the cookie removal in recv.\n if (req.http.x-long-cache || req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's since those can be temporary during the site build\/index\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n set beresp.http.Cache-Control = \"max-age=0\";\n } else if (req.http.x-long-cache) {\n # Force caching for signed cached assets.\n set beresp.ttl = 31536000s;\n # Add immutable as it avoids IMS and INM revalidations\n set beresp.http.Cache-Control = \"max-age=31536000, immutable\";\n }\n }\n\n # Fix Vary Header in some cases. In 99.9% of cases Varying on User-Agent is counterproductive\n # https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleFixupVary\n if (beresp.http.Vary ~ \"User-Agent\") {\n unset beresp.http.Vary:User-Agent;\n if (beresp.http.Vary == \"\") {\n unset beresp.http.Vary;\n }\n }\n\n # All the Magento responses should emit X-Esi headers\n if (beresp.http.x-esi) {\n # enable ESI feature for Magento response by default\n esi;\n } else {\n # enable gzip for all static content except\n if ( http_status_matches(beresp.status, \"200,404\") && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|text\\\/html|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url.ext ~ \"(?i)(css|js|html|eot|ico|otf|ttf|json)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n set beresp.http.Vary:Accept-Encoding = \"\";\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # Add Varying on X-Magento-Vary\n if (beresp.http.Content-Type ~ \"text\/(html|xml)\" || req.http.graphql) {\n set beresp.http.Vary:X-Magento-Vary = \"\";\n set beresp.http.Vary:Https = \"\";\n }\n\n # Just in case the Request Setting for x-pass is missing\n if (req.http.x-pass) {\n return (pass);\n }\n\n if (beresp.http.Cache-Control ~ \"private|no-cache|no-store\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # Never cache 302s\n if (beresp.status == 302) {\n return (pass);\n }\n\n if (beresp.http.x-amz-request-id) {\n # If assets are coming from Amazon they may have no Cache-Control headers which may make them uncacheable\n } else if (!beresp.http.Expires && !beresp.http.Surrogate-Control ~ \"max-age\" && !beresp.http.Cache-Control ~ \"(s-maxage|max-age)\") {\n # Varnish sets default TTL if none of the headers above are present. If not set we want to make sure we don't cache it\n set beresp.ttl = 0s;\n set beresp.cacheable = false;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\") && !req.http.x-pass ) {\n unset beresp.http.set-cookie;\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type if they are image\/script or CSS\n if (beresp.http.Content-Type ~ \"(image|script|css)\") {\n set beresp.http.Surrogate-Key = re.group.1;\n }\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"0d31cd7a877503efae3837e054e99514a19c8f04","subject":"re #120 - Exclude \/installation folder from Varnish caching","message":"re #120 - Exclude \/installation folder from Varnish caching\n","repos":"joomlatools\/joomlatools-vagrant,joomlatools\/joomlatools-vagrant,joomlatools\/joomlatools-vagrant,gokuale\/joomla-vagrant,joomlatools\/joomlatools-vagrant,Fabrik\/joomla-vagrant,gokuale\/joomla-vagrant,Fabrik\/joomla-vagrant,joomlatools\/joomla-vagrant,Fabrik\/joomla-vagrant,Fabrik\/joomla-vagrant,joomlatools\/joomla-vagrant,gokuale\/joomla-vagrant,joomlatools\/joomlatools-vagrant,gokuale\/joomla-vagrant,joomlatools\/joomla-vagrant,gokuale\/joomla-vagrant,joomlatools\/joomla-vagrant,joomlatools\/joomla-vagrant,Fabrik\/joomla-vagrant,gokuale\/joomla-vagrant,Fabrik\/joomla-vagrant,joomlatools\/joomla-vagrant","old_file":"puppet\/modules\/varnish\/files\/joomla.box.vcl","new_file":"puppet\/modules\/varnish\/files\/joomla.box.vcl","new_contents":"vcl 4.0;\n\n# This Varnish configuration is a very basic template to get started with caching Joomla sites.\n# In no way is this configuration complete: every site is unique and needs customisation!\n#\n# Joomla creates a session cookie by default, even if you not logged in. To deal with this,\n# we need to let Varnish know when a user is logged in or not. If the user is not logged in,\n# we will prevent the Joomla response from setting any cookies so Varnish can cache the page.\n#\n# To set the X-Logged-In header, append the following line in to the onAfterInitialise() method\n# in \/plugins\/system\/cache\/cache.php, right after \"$user = JFactory::getUser();\" (line #60):\n#\n# JFactory::getApplication()->setHeader('X-Logged-In', $user->guest ? 'false' : 'true', true);\n#\n# Now enable the Cache plugin and Varnish cache. Clear your existing cookies.\n# Your front-end pages will be cached as long as you browse the site as a guest.\n#\n# This VCL is based on https:\/\/snipt.net\/fevangelou\/the-perfect-varnish-configuration-for-joomla-websites\/\n\nimport std;\n\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n .probe = {\n .url = \"\/varnish-enabled\";\n .interval = 1s;\n .timeout = 1s;\n }\n}\n\nbackend alternative {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\n\nsub vcl_recv {\n # Forward client's IP to backend\n unset req.http.X-Forwarded-For;\n set req.http.X-Forwarded-For = client.ip;\n\n set req.http.X-Forwarded-By = server.ip;\n set req.http.X-Forwarded-Port = 80;\n\n # Check if we've still enabled Varnish, if not, passthrough every request\n if (! std.healthy(req.backend_hint))\n {\n set req.backend_hint = alternative;\n return (pass);\n }\n\n # Do not cache phpmyadmin\n if (req.http.host == \"phpmyadmin.joomla.box\") {\n return (pass);\n }\n\n # Do not cache system tools on joomla.box:\n if (req.http.host == \"joomla.box\")\n {\n if (req.url == \"\/apc\" || req.url == \"\/phpinfo\" || req.url == \"\/pimpmylog\") {\n return (pass);\n }\n }\n\n # Do not cache POST requests\n if (req.method == \"POST\") {\n return (pass);\n }\n\n # Proxy (pass) any request that goes to the backend admin, the banner component links, ..\n if(req.url ~ \"\/administrator\" || req.url ~ \"\/component\/banners\" || req.url ~ \"\/component\/users\" || req.url ~ \"\/installation\") {\n return (pass);\n }\n\n # Do not cache if user is logged in\n if (req.http.Authorization || req.http.Authenticate || req.http.Cookie) {\n return (pass);\n }\n\n # Don't cache ajax requests\n if(req.http.X-Requested-With == \"XMLHttpRequest\" || req.url ~ \"nocache\") {\n return (pass);\n }\n\n # Properly handle different encoding types\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf)$\") {\n # No point in compressing these\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n # unknown algorithm (aka crappy browser)\n unset req.http.Accept-Encoding;\n }\n }\n\n return (hash);\n}\n\nsub vcl_backend_response {\n # Unset the \"etag\" header (suggested)\n unset beresp.http.etag;\n\n # This is Joomla! specific: fix stupid \"no-cache\" header sent by Joomla! even\n # when caching is on - make sure to replace 300 with the number of seconds that\n # you want the browser to cache content\n if(beresp.http.Cache-Control ~ \"no-cache\" || beresp.http.Cache-Control == \"\"){\n set beresp.http.Cache-Control = \"max-age=300, public, must-revalidate\";\n }\n\n # Check for the custom \"x-Logged-In\" header to identify if the visitor is a guest,\n # then unset any cookie (including session cookies) provided it's not a POST request.\n if(bereq.method != \"POST\" && beresp.http.X-Logged-In == \"false\") {\n unset beresp.http.Set-Cookie;\n }\n\n # This is how long Varnish will cache content\n set beresp.ttl = 1w;\n\n return (deliver);\n}\n\nsub vcl_deliver {\n if (resp.http.x-varnish ~ \" \") {\n set resp.http.X-Varnish-Status = \"HIT\";\n } else {\n set resp.http.X-Varnish-Status = \"MISS\";\n }\n\n # Please note that obj.hits behaviour changed in 4.0, now it counts per objecthead, not per object\n # and obj.hits may not be reset in some cases where bans are in use. See bug 1492 for details.\n # So take hits with a grain of salt\n set resp.http.X-Varnish-Hits = obj.hits;\n}","old_contents":"vcl 4.0;\n\n# This Varnish configuration is a very basic template to get started with caching Joomla sites.\n# In no way is this configuration complete: every site is unique and needs customisation!\n#\n# Joomla creates a session cookie by default, even if you not logged in. To deal with this,\n# we need to let Varnish know when a user is logged in or not. If the user is not logged in,\n# we will prevent the Joomla response from setting any cookies so Varnish can cache the page.\n#\n# To set the X-Logged-In header, append the following line in to the onAfterInitialise() method\n# in \/plugins\/system\/cache\/cache.php, right after \"$user = JFactory::getUser();\" (line #60):\n#\n# JFactory::getApplication()->setHeader('X-Logged-In', $user->guest ? 'false' : 'true', true);\n#\n# Now enable the Cache plugin and Varnish cache. Clear your existing cookies.\n# Your front-end pages will be cached as long as you browse the site as a guest.\n#\n# This VCL is based on https:\/\/snipt.net\/fevangelou\/the-perfect-varnish-configuration-for-joomla-websites\/\n\nimport std;\n\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n .probe = {\n .url = \"\/varnish-enabled\";\n .interval = 1s;\n .timeout = 1s;\n }\n}\n\nbackend alternative {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\n\nsub vcl_recv {\n # Forward client's IP to backend\n unset req.http.X-Forwarded-For;\n set req.http.X-Forwarded-For = client.ip;\n\n set req.http.X-Forwarded-By = server.ip;\n set req.http.X-Forwarded-Port = 80;\n\n # Check if we've still enabled Varnish, if not, passthrough every request\n if (! std.healthy(req.backend_hint))\n {\n set req.backend_hint = alternative;\n return (pass);\n }\n\n # Do not cache phpmyadmin\n if (req.http.host == \"phpmyadmin.joomla.box\") {\n return (pass);\n }\n\n # Do not cache system tools on joomla.box:\n if (req.http.host == \"joomla.box\")\n {\n if (req.url == \"\/apc\" || req.url == \"\/phpinfo\" || req.url == \"\/pimpmylog\") {\n return (pass);\n }\n }\n\n # Proxy (pass) any request that goes to the backend admin,\n # the banner component links or any post requests\n if(req.url ~ \"\/administrator\" || req.url ~ \"\/component\/banners\" || req.url ~ \"\/component\/users\" || req.method == \"POST\") {\n return (pass);\n }\n\n # Do not cache if user is logged in\n if (req.http.Authorization || req.http.Authenticate || req.http.Cookie) {\n return (pass);\n }\n\n # Don't cache ajax requests\n if(req.http.X-Requested-With == \"XMLHttpRequest\" || req.url ~ \"nocache\") {\n return (pass);\n }\n\n # Properly handle different encoding types\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf)$\") {\n # No point in compressing these\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n # unknown algorithm (aka crappy browser)\n unset req.http.Accept-Encoding;\n }\n }\n\n return (hash);\n}\n\nsub vcl_backend_response {\n # Unset the \"etag\" header (suggested)\n unset beresp.http.etag;\n\n # This is Joomla! specific: fix stupid \"no-cache\" header sent by Joomla! even\n # when caching is on - make sure to replace 300 with the number of seconds that\n # you want the browser to cache content\n if(beresp.http.Cache-Control ~ \"no-cache\" || beresp.http.Cache-Control == \"\"){\n set beresp.http.Cache-Control = \"max-age=300, public, must-revalidate\";\n }\n\n # Check for the custom \"x-Logged-In\" header to identify if the visitor is a guest,\n # then unset any cookie (including session cookies) provided it's not a POST request.\n if(bereq.method != \"POST\" && beresp.http.X-Logged-In == \"false\") {\n unset beresp.http.Set-Cookie;\n }\n\n # This is how long Varnish will cache content\n set beresp.ttl = 1w;\n\n return (deliver);\n}\n\nsub vcl_deliver {\n if (resp.http.x-varnish ~ \" \") {\n set resp.http.X-Varnish-Status = \"HIT\";\n } else {\n set resp.http.X-Varnish-Status = \"MISS\";\n }\n\n # Please note that obj.hits behaviour changed in 4.0, now it counts per objecthead, not per object\n # and obj.hits may not be reset in some cases where bans are in use. See bug 1492 for details.\n # So take hits with a grain of salt\n set resp.http.X-Varnish-Hits = obj.hits;\n}","returncode":0,"stderr":"","license":"mpl-2.0","lang":"VCL"} {"commit":"fdc9b17c04953f09090b35f5afaaef3fedff7560","subject":"Delete excel.vcl","message":"Delete excel.vcl","repos":"aschneiderman\/atom-voice-vocola","old_file":"excel.vcl","new_file":"excel.vcl","new_contents":"","old_contents":"# Voice commands for excel\n\ninclude numbers.vch;\n\n#data warehouse commands\nThe Data Warehouse = \"SQL5SV\";\nConnect to (Data Warehouse | It) = {Alt}a x Wait(100) d {Enter} Wait(100) {Enter};\nGo There = {F6} Wait(100) {Tab};\n\n#Timesheet commands\nFind Anders = {Ctrl+f} Wait(100) \"Anders\" {Enter} {Esc};\nNormal Timesheet = \"X\" {Tab} Wait(100) \"X\" {Tab} Wait(100) \"X\" {Tab} Wait(100) \"X\" {Tab} Wait(100) \"X\" {Tab};\n\nGrab Down <numbers> = {Shift+Down_$1};\nFill Down <numbers> = {Shift+Down_$1} {Alt}h fi d;\n\n\nBottom = {Ctrl+Down};\nTop = {Ctrl+Up} {Down};\n(Poo-Owm | Homa) = {Tab} {Home};\n\n\nPrint Preview = {Alt+f}w v;\n\nLatest File = {Alt}f r 1;\n(List Files | File List) = {Alt}f r;\n\n[Set] Landscape = {Alt} p o Wait(100) {Down} {Enter};\n\n\nVisible Cells = {Alt+e}g Wait(100) {Alt+s}{Alt+y} Wait(100) {Enter};\nPaste Special ={Alt+e} st {Enter};\nHide Column = {Ctrl+0};\nHide 1..15 Columns = {Ctrl+space} {Shift+Right_$1}{Shift+left}{Ctrl+0};\nShow Columns = {Alt+o}cu;\n\nLine = {Alt+e}dr {Enter};\n\n\nClean Paste = {Alt+e} st {Enter};\n\n<numbers> (Left | Right | Up | Down) = {$2_$1};\n\nFill (Down='d' | Right = 'r') = {Ctrl+$1};\n\nGrab <numbers> Columns = {Ctrl+space} {Shift+Right_$1} {Shift+left};\nDelete <numbers> Columns = {Ctrl+space} {Shift+Right_$1} {Shift+left} {Alt}h dc;\nRow Height = {Alt+o} re;\nColumn Width = {Alt}h o w;\n\n\n\nSort = {Alt+d} s;\nAuto Filter = {Alt+d} f f;\nSubtotals = {Alt+d} b;\nInsert (Row = 'r' | Column = 'c' | Sheet = 'w') = {Alt+i} $1;\n\n(Autoformat | Autoformat Column ) = {Alt+o}ca;\nFormat (Column = 'w' | Row = 'h') Width = {Alt} h o $1;\nFormat (Cells | Cell) = {Alt+o}e;\nCell Borders = {Alt} h b;\nFormat Number = {Alt+o}e Wait(100) {Alt+c}n {Alt+d}0 Wait(100) {Alt+u}{Enter};\nFormat (General = '~' | Date = '#' | Percent = '%') = {Ctrl+Shift+$1};\n\nInsert Page Break = {Alt+i}b;\n\nSet (Page | Print) Area = {Alt} p r s;\n\nNexSheet = {Ctrl+PgDn};\nLassSheet = {Ctrl+PgUp};\n\nRename (sheet | worksheet) = {Alt+o}hr;\nInsert (Sheet | Worksheet) = {SHIFT+F11};\n\n\n# Macro development commands\n[Start] (Visual Basic | VBA) = {Alt+F11};\nRun It = {Ctrl+Shift+l};\n\n\nMicrosoft Visual Basic for Applications:\n\tReload = {Alt+q} Wait(100) {Ctrl+Shift+l};\n\t(Exit Code | Close Editor) = {Alt+q};\n\tCode Window = {F7};\n\tObject Browser = {F2};\n\tProject Window = {Ctrl+r};\n\tImmediate Window = {Ctrl+g};\n\tNext Window = {Ctrl+tab};\n\tLast Window = {Ctrl+Shift+Tab};\n\n\tFind <_anything> = {Ctrl+f} $1 {Enter} Wait(100) {Esc};\n\tFind Again = {F3};\n\tNext Procedure = {Ctrl+Down};\n\tLast Procedure = {Ctrl+Up};\n\n\tRun = {F5};\t\n\tRun Step = {F8};\n\tStop Running = {Ctrl+break};\n\t(Set | Clear) Breakpoint = {F9};\n\tClear All Breakpoints = {Shift+F9};\n\n\t(shortcut | Shortcuts) Menu = {Shift+F10};\n\n\t#VBA commands\n\tNew Variable = \"Dim As Variant\" Wait(100) {Home} {Right_4};\t\t# NOTE: Variant = any data type\n\t(Dim | Define) as (Variant | Object | Boolean | Integer | Long | Currency | Date | String) = \"Dim As \" $2 Wait(100) {Home} {Right_4};\n\tMessageBox = 'MsgBox ';\n\tRange Value = 'Range(\"\").Value' {Left_8};\n\n\n\n#{Alt+F5} runs the error handling code or returns the error to the calling procedure\n#{Alt+F8} steps into the error handler returns error to the calling procedure\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"68ce9971e39d12d037d901bd871c0226ffb966ef","subject":"Provide a commented out example of redis.init_redis() in examples\/example.vcl","message":"Provide a commented out example of redis.init_redis() in examples\/example.vcl\n\nSigned-off-by: Noah Williamsson <01479f9bf7817090e07c55bace445c48178b77b4@gmail.com>\n","repos":"brandonwamboldt\/libvmod-redis,zephirworks\/libvmod-redis,brandonwamboldt\/libvmod-redis,SBRDevelopment\/libvmod-redis,zephirworks\/libvmod-redis,SBRDevelopment\/libvmod-redis","old_file":"examples\/example.vcl","new_file":"examples\/example.vcl","new_contents":"#\n# A trivial example to demonstrate how to use this vmod\n#\n\nimport redis;\n\nbackend be1 {\n .host = \"192.168.0.1\";\n .port = \"80\";\n}\n\n#sub vcl_init {\n #\n # By default, the redis module will attempt to connect to a Redis server\n # at 127.0.0.1:6379 with a connect timeout of 200 milliseconds.\n #\n # The function redis.init_redis(host, port, timeout_ms) may be used to\n # connect to an alternate Redis server or use a different connect timeout.\n #\n # redis.init_redis(\"localhost\", 6379, 200); \/* default values *\/\n#}\n\nsub vcl_recv {\n #\n # redis.call is a procedure, it will send the command to redis and ignore\n # the response. If the command errors out, it will be logged but the VCL\n # will not know.\n #\n redis.send(\"LPUSH client \" + client.ip);\n\n #\n # redis.call is a function that sends the command to redis and return the\n # return value as a string.\n #\n set req.http.x-redis = redis.call(\"LTRIM client 0 99\");\n}\n","old_contents":"#\n# A trivial example to demonstrate how to use this vmod\n#\n\nimport redis;\n\nbackend be1 {\n .host = \"192.168.0.1\";\n .port = \"80\";\n}\n\nsub vcl_recv {\n #\n # redis.call is a procedure, it will send the command to redis and ignore\n # the response. If the command errors out, it will be logged but the VCL\n # will not know.\n #\n redis.send(\"LPUSH client \" + client.ip);\n\n #\n # redis.call is a function that sends the command to redis and return the\n # return value as a string.\n #\n set req.http.x-redis = redis.call(\"LTRIM client 0 99\");\n}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"0cca284ee9c64c4db2f4be1408efc9409e680d10","subject":"This was always true no matter what token was supplied","message":"This was always true no matter what token was supplied\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets\/recv.vcl","new_file":"etc\/vcl_snippets\/recv.vcl","new_contents":" # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n # Sort the query arguments\n set req.url = boltsort.sort(req.url);\n\n if (req.url ~ \"^\/static\/version(\\d*\/)?(.*)$\") {\n set req.url = \"\/static\/\" + re.group.2 + \"?\" + re.group.1;\n }\n \n # User's Cookie may contain some Magento Vary items we should vary on\n if (req.http.cookie:X-Magento-Vary ) {\n set req.http.X-Magento-Vary = req.http.cookie:X-Magento-Vary;\n } else {\n unset req.http.X-Magento-Vary;\n }\n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n if (!req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n error 403;\n }\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n\n } else {\n error 403;\n }\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (req.http.Fastly-FF) {\n # disable ESI processing on Origin Shield\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie ~ \"(X-Magento-Vary|form_key)=\") {\n error 200 \"\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url !~ \"country_code=\" ) {\n set req.url = req.url \"?country_code=\" if ( req.http.geo_override, req.http.geo_override, geoip.country_code);\n }\n }\n } else {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking\n set req.http.Magento-Original-URL = req.url;\n set req.url = querystring.regfilter(req.url, \"^(utm_.*|gclid|gdftrk|_ga|mc_.*)\");\n }\n \n # Pass on checkout URLs. Because it's a snippet we want to execute this after backend selection so we handle it\n # in the request condition\n if (req.url ~ \"\/(catalogsearch|checkout)\") {\n set req.http.x-pass = \"1\";\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n","old_contents":" # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n # Sort the query arguments\n set req.url = boltsort.sort(req.url);\n\n if (req.url ~ \"^\/static\/version(\\d*\/)?(.*)$\") {\n set req.url = \"\/static\/\" + re.group.2 + \"?\" + re.group.1;\n }\n \n # User's Cookie may contain some Magento Vary items we should vary on\n if (req.http.cookie:X-Magento-Vary ) {\n set req.http.X-Magento-Vary = req.http.cookie:X-Magento-Vary;\n } else {\n unset req.http.X-Magento-Vary;\n }\n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n if (req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n error 403;\n }\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n\n } else {\n error 403;\n }\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (req.http.Fastly-FF) {\n # disable ESI processing on Origin Shield\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie ~ \"(X-Magento-Vary|form_key)=\") {\n error 200 \"\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url !~ \"country_code=\" ) {\n set req.url = req.url \"?country_code=\" if ( req.http.geo_override, req.http.geo_override, geoip.country_code);\n }\n }\n } else {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking\n set req.http.Magento-Original-URL = req.url;\n set req.url = querystring.regfilter(req.url, \"^(utm_.*|gclid|gdftrk|_ga|mc_.*)\");\n }\n \n # Pass on checkout URLs. Because it's a snippet we want to execute this after backend selection so we handle it\n # in the request condition\n if (req.url ~ \"\/(catalogsearch|checkout)\") {\n set req.http.x-pass = \"1\";\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"8cbbdacc3566b627f94e49c635eb1c376dee16d1","subject":"Validate Formkey","message":"Validate Formkey\n","repos":"fastly\/fastly-magento,fastly\/fastly-magento,fastly\/fastly-magento,fastly\/fastly-magento","old_file":"app\/code\/community\/Fastly\/CDN\/etc\/vcl_snippets\/recv.vcl","new_file":"app\/code\/community\/Fastly\/CDN\/etc\/vcl_snippets\/recv.vcl","new_contents":" # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n # Pass any checkout, cart or customer\/myaccount urls\n if (req.url.path ~ \"\/(cart|checkout|customer)\") {\n set req.http.x-pass = \"1\";\n # Pass all admin actions\n } else if (req.url.path ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\") {\n set req.http.x-pass = \"1\";\n # bypass language switcher\n } else if (req.url.qs ~ \"(?i)___from_store=.*&___store=.*\") {\n set req.http.x-pass = \"1\";\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (req.http.cookie:FASTLY_CDN_ENV) {\n set req.http.Fastly-Cdn-Env = req.http.cookie:FASTLY_CDN_ENV;\n } else {\n unset req.http.Fastly-Cdn-Env;\n }\n\n ############################################################################################################\n # Following code block controls purge by URL. By default we want to protect all URL purges. In general this\n # is addressed by adding Fastly-Purge-Requires-Auth request header in vcl_recv however this runs the risk of\n # exposing API tokens if user attempts to purge non-https URLs. For this reason inside the Magento module\n # we use X-Purge-Token. Unfortunately this breaks purge from the Fastly UI. Therefore in the next code block\n # we check for presence of X-Purge-Token. If it's not present we force the Fastly-Purge-Requires-Auth\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n if (req.http.X-Purge-Token && req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n } else {\n error 403;\n }\n } else {\n set req.http.Fastly-Purge-Requires-Auth = \"1\";\n }\n }\n\n # disable ESI processing on Origin Shield\n if (req.http.Fastly-FF) {\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url.path ~ \"^\/(media|js|skin)\/.*\\.(png|jpg|jpeg|gif|css|js|swf|ico|webp|svg)$\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n # formkey lookup\n if (req.url.path ~ \"\/fastlycdn\/getformkey\/\") {\n # check if we have a formkey cookie and that it's validly formed\n if (req.http.Cookie:FASTLY_CDN_FORMKEY &&\nstd.strlen(req.http.Cookie:FASTLY_CDN_FORMKEY) < 40 && req.http.Cookie:FASTLY_CDN_FORMKEY ~ \"^[a-zA-Z0-9-_]*$\" ) {\n set req.http.Formkey = req.http.Cookie:FASTLY_CDN_FORMKEY;\n } else {\n # create formkey\n set req.http.seed = req.http.Cookie client.ip remote.port client.geo.longitude client.geo.latitude client.geo.postal_code;\n set req.http.Formkey = regsub(digest.hash_md5(req.http.seed), \"^0x\", \"\");\n }\n error 760 req.http.Formkey;\n }\n\n # client.geo lookup\n if (req.url.path ~ \"fastlycdn\/esi\/getcountry\/\") {\n # check if GeoIP has been already processed by client\n if (req.http.Cookie:FASTLY_CDN_GEOIP_PROCESSED) {\n error 200 \"\";\n } else {\n # modify req.url and restart request processing\n error 750 client.geo.country_code;\n }\n }\n\n # client.geo get country code\n if (req.url.path ~ \"fastlycdn\/esi\/getcountrycode\/\") {\n # create and set req.http.X-Country-Code\n error 755 client.geo.country_code;\n }\n\n # check for ESI calls\n if (req.url.qs ~ \"esi_data=\") {\n # check for valid cookie data\n declare local var.esi_data_field STRING;\n declare local var.cookie_data STRING;\n # Based on esi_data value requested we will need to search for cookie FASTLY_CDN-<type> e.g. FASTLY_CDN-customer_quote\n set var.esi_data_field = \"FASTLY_CDN-\" subfield(req.url.qs, \"esi_data\", \"&\");\n # We can't use variables in either subfield or regex so we need to use this workaround\n # to extract value of cookie that we compiled in esi_data_field\n set var.cookie_data = std.strstr(req.http.Cookie,var.esi_data_field);\n set var.cookie_data = regsub(var.cookie_data,\"^[^=]*=([^;]*).*\",\"\\1\");\n # If found a value we replace the query string with the contents of that cookie\n if ( var.cookie_data != \"\" ) {\n set req.url = querystring.set(req.url, \"esi_data\", var.cookie_data);\n }\n }\n\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking\n set req.http.Magento-Original-URL = req.url;\n set req.url = querystring.regfilter(req.url, \"^(####QUERY_PARAMETERS####)\");\n # Sort the query arguments to increase cache hit ratio with query arguments that\n # may be out of order however only on URLs that are not being passed. \n if ( !req.http.x-pass ) {\n set req.url = boltsort.sort(req.url);\n }\n","old_contents":" # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n # Pass any checkout, cart or customer\/myaccount urls\n if (req.url.path ~ \"\/(cart|checkout|customer)\") {\n set req.http.x-pass = \"1\";\n # Pass all admin actions\n } else if (req.url.path ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\") {\n set req.http.x-pass = \"1\";\n # bypass language switcher\n } else if (req.url.qs ~ \"(?i)___from_store=.*&___store=.*\") {\n set req.http.x-pass = \"1\";\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (req.http.cookie:FASTLY_CDN_ENV) {\n set req.http.Fastly-Cdn-Env = req.http.cookie:FASTLY_CDN_ENV;\n } else {\n unset req.http.Fastly-Cdn-Env;\n }\n\n ############################################################################################################\n # Following code block controls purge by URL. By default we want to protect all URL purges. In general this\n # is addressed by adding Fastly-Purge-Requires-Auth request header in vcl_recv however this runs the risk of\n # exposing API tokens if user attempts to purge non-https URLs. For this reason inside the Magento module\n # we use X-Purge-Token. Unfortunately this breaks purge from the Fastly UI. Therefore in the next code block\n # we check for presence of X-Purge-Token. If it's not present we force the Fastly-Purge-Requires-Auth\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n if (req.http.X-Purge-Token && req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n } else {\n error 403;\n }\n } else {\n set req.http.Fastly-Purge-Requires-Auth = \"1\";\n }\n }\n\n # disable ESI processing on Origin Shield\n if (req.http.Fastly-FF) {\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url.path ~ \"^\/(media|js|skin)\/.*\\.(png|jpg|jpeg|gif|css|js|swf|ico|webp|svg)$\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n # formkey lookup\n if (req.url.path ~ \"\/fastlycdn\/getformkey\/\") {\n # check if we have a formkey cookie\n if (req.http.Cookie:FASTLY_CDN_FORMKEY) {\n set req.http.Formkey = req.http.Cookie:FASTLY_CDN_FORMKEY;\n } else {\n # create formkey\n set req.http.seed = req.http.Cookie client.ip remote.port client.geo.longitude client.geo.latitude client.geo.postal_code;\n set req.http.Formkey = regsub(digest.hash_md5(req.http.seed), \"^0x\", \"\");\n }\n error 760 req.http.Formkey;\n }\n\n # client.geo lookup\n if (req.url.path ~ \"fastlycdn\/esi\/getcountry\/\") {\n # check if GeoIP has been already processed by client\n if (req.http.Cookie:FASTLY_CDN_GEOIP_PROCESSED) {\n error 200 \"\";\n } else {\n # modify req.url and restart request processing\n error 750 client.geo.country_code;\n }\n }\n\n # client.geo get country code\n if (req.url.path ~ \"fastlycdn\/esi\/getcountrycode\/\") {\n # create and set req.http.X-Country-Code\n error 755 client.geo.country_code;\n }\n\n # check for ESI calls\n if (req.url.qs ~ \"esi_data=\") {\n # check for valid cookie data\n declare local var.esi_data_field STRING;\n declare local var.cookie_data STRING;\n # Based on esi_data value requested we will need to search for cookie FASTLY_CDN-<type> e.g. FASTLY_CDN-customer_quote\n set var.esi_data_field = \"FASTLY_CDN-\" subfield(req.url.qs, \"esi_data\", \"&\");\n # We can't use variables in either subfield or regex so we need to use this workaround\n # to extract value of cookie that we compiled in esi_data_field\n set var.cookie_data = std.strstr(req.http.Cookie,var.esi_data_field);\n set var.cookie_data = regsub(var.cookie_data,\"^[^=]*=([^;]*).*\",\"\\1\");\n # If found a value we replace the query string with the contents of that cookie\n if ( var.cookie_data != \"\" ) {\n set req.url = querystring.set(req.url, \"esi_data\", var.cookie_data);\n }\n }\n\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking\n set req.http.Magento-Original-URL = req.url;\n set req.url = querystring.regfilter(req.url, \"^(####QUERY_PARAMETERS####)\");\n # Sort the query arguments to increase cache hit ratio with query arguments that\n # may be out of order however only on URLs that are not being passed. \n if ( !req.http.x-pass ) {\n set req.url = boltsort.sort(req.url);\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"4dfc9cd3cbed91845b809d897fe7967e43d5e1da","subject":"we use 8008 port by default in our apache configs to avoid colliding with other daemons like Tomcat","message":"we use 8008 port by default in our apache configs to avoid colliding with other daemons like Tomcat\n","repos":"NITEMAN\/varnish-bites,NITEMAN\/Varnish_VCL_samps-hacks","old_file":"varnish3\/drupal-base.vcl","new_file":"varnish3\/drupal-base.vcl","new_contents":"\/* Varnish 3 example config for Drupal 7 \/ Pressflow 6 & 7 *\/\n# Original source: https:\/\/github.com\/NITEMAN\/varnish-bites\/varnish4\/drupal-base.vcl\n# Copyright (c) 2015 Pedro Gonz\u00e1lez Serrano and individual contributors.\n# MIT License\n\n# Intended to be used both in simple production environments and with learning\/teaching purposes.\n# Loosely based on http:\/\/www.lullabot.com\/sites\/default\/files\/default_varnish3.vcl_.txt\n\n\/* Backend probes \/ healthchecks *\/\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#backend-probes\nprobe basic {\n \/* Only test that backend's IP serves content for '\/' *\/\n # This might be a too heavy probe\n # .url = \"\/\";\n \/* Only test that backend's IP has apache working *\/\n # Nginx would fail this probe with a default config\n .request =\n \"OPTIONS * HTTP\/1.1\"\n \"Host: *\"\n \"Connection: close\";\n .interval = 10s;\n .timeout = 2s;\n .window = 8;\n .threshold = 6;\n}\n\n\n\/* Backend definitions.*\/\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#backend-declarations\nbackend default {\n \/* Default backend on the same machine. WARNING: timeouts could be not big enought for certain POST request *\/\n .host = \"127.0.0.1\";\n .port = \"8008\";\n .connect_timeout = 60s;\n .first_byte_timeout = 60s;\n .between_bytes_timeout = 60s;\n .probe = basic;\n}\n\n\n\/* Directors. *\/\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#directors\n# Empty in simple configs\n\n\n\/* Access Control Lists *\/\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#acls\nacl purge_ban {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use '\"localhost\";' instead\n}\nacl allowed_monitors {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n}\n\n\n\/* Custom routines *\/\n# Empty in simple configs.\n# We can name subs with no restrictions but as a task can need several chunks of code in diferent states,\n# it's a good idea to identify what main sub will call each with a suffix.\n# \/* Example 301 client redirection removing \"www\" prefix from request *\/\n# sub perm_redirections_recv {\n# if ( req.http.host ~ \"^www.*$\" ) {\n# error 751 \"http:\/\/\" + regsub(req.http.host, \"^www\\.\", \"\") + req.url;\n# }\n# }\n# sub perm_redirections_error {\n# if (obj.status == 751) {\n# \/* Get new URL from the response *\/\n# set obj.http.Location = obj.response;\n# \/* Set HTTP 301 for permanent redirect *\/\n# set obj.status = 301;\n# return(deliver);\n# }\n# }\n\n\n\/* VCL logigc overrides *\/\n# Note that the built-in logic will be appended to our code if no return is performed before.\n# Built-in logic is included commented out right after our's for reference purposes in that cases.\n# See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleDefault\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#subroutines\n\n# vcl_recv: Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use.\nsub vcl_recv {\n \/* 0th: general bypass, general return & authorization checks *\/\n # Empty in simple configs.\n # Useful for debugging we can pipe or pass the request to default backend here to bypass completely Varnish.\n # return (pipe);\n # return (pass);\n # We can also return here a 200 Ok for network performance benchmarking.\n # error 200 \"Ok\";\n # Finally we can perform basic HTTP authentification here by example.\n # See http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* 1st: Check for Varnish special requests *\/ \n # Purge logic.\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/purging.html#http-purges\n # See https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if (req.request == \"PURGE\") {\n if (!client.ip ~ purge_ban) {\n error 405 \"Not allowed.\";\n }\n return (lookup);\n }\n # Ban logic. See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/purging.html#bans\n if (req.request == \"BAN\") {\n if (!client.ip ~ purge_ban) {\n error 405 \"Not allowed.\";\n }\n ban(\"req.http.host == \" + req.http.host +\n \"&& req.url == \" + req.url); \n error 200 \"Ban added\";\n }\n # Custom response implementation example in order to check that Varnish is working properly.\n # This is usefull for automatic monitoring with monit or when Varnish is behind another proxies like HAProxy.\n if (req.http.host == \"monitor.server.health\" && \n client.ip ~ allowed_monitors && \n (req.request == \"OPTIONS\" || req.request == \"GET\")) {\n error 200 \"Ok\";\n }\n\n \/* 2nd: Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_recv;\n # Here we can also enforce SSL when Varnish run behind some SSL termination point.\n\n \/* 3rd: Time for backend choice *\/\n # Empty in simple configs.\n\n \/* 4th: Set custom headers for backend like X-Forwarded-For (copied from built-in logic) *\/\n if (req.restarts == 0) {\n \/* See also vcl_pipe section *\/\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n \/* 5th: Bypass breakpoint 1 *\/\n # Useful for debugging we can now pipe or pass the request to backend with headers setted.\n # return (pipe);\n # return (pass);\n\n \/* 6th: Decide if we should deal with a request (mostly copied from built-in logic) *\/\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n\n \/* 7th: Access control for some URLs by ACL *\/\n # Empty in simple configs.\n # By example denial some URLs depending on client-ip, we'll need to define corresponding ACL 'internal'.\n # if (req.url ~ \"^\/(cron|install)\\.php$\" && !client.ip ~ internal) {\n # # Have Varnish throw the error directly.\n # error 403 \"Forbidden.\";\n # # Use a custom error page that you've defined in Drupal at the path \"404\".\n # # set req.url = \"\/403\";\n # }\n\n \/* 8th: Custom exceptions *\/\n # Host exception example:\n # if (req.http.host == \"ejemplo.exception.com\") {\n # return (pass);\n # }\n # Drupal exceptions, edit if we want to cache some AJAX\/AHAH request.\n # Add here filters for never cache URLs such as Payment Gateway's callbacks\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/ooyala\/ping$\" ||\n req.url ~ \"^\/admin\/build\/features\" ||\n req.url ~ \"^\/info\/.*$\" ||\n req.url ~ \"^\/flag\/.*$\" ||\n req.url ~ \"^.*\/ajax\/.*$\" ||\n req.url ~ \"^.*\/ahah\/.*$\") {\n \/* Do not cache these paths *\/\n return (pass);\n }\n # Pipe these paths directly to backend for streaming.\n if (req.url ~ \"^\/admin\/content\/backup_migrate\/export\") {\n return (pipe);\n }\n if (req.url ~ \"^\/system\/files\") {\n return (pipe);\n }\n\n \/* 9th: Enable grace mode *\/\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/handling_misbehaving_servers.html#grace-mode\n if (! req.backend.healthy) {\n \/* Use a longer grace period if all backends are down *\/\n set req.grace = 1h;\n \/* Use anonymous, cached pages if all backends are down. *\/\n unset req.http.Cookie;\n # TO-DO: Add sick marker\n } else {\n \/* Allow the backend to serve up stale content if it is responding slowly. *\/\n set req.grace = 30s;\n }\n\n \/* 10th: Deal with compression and the Accept-Encoding header *\/\n # Althought Varnish 3 handles gziped content itself by default, just to be sure we want to \n # remove Accept-Encoding for some compressed formats.\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/phk\/gzip.html#what-does-http-gzip-support-do\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/varnishd.html?highlight=http_gzip_support\n # See (for older configs) https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleNormalizeAcceptEncoding\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|mp4|flv|zip|rar)$\") {\n \/* Already compressed formats, no sense trying to compress again *\/\n remove req.http.Accept-Encoding;\n }\n }\n\n \/* 11th: Another header manipulation *\/\n # Empty in simple configs.\n # We could add here a custom header grouping User-agent families.\n\n \/* 12th: Cookie removal *\/\n # Always cache the following static file types for all users. \n # Use with care if we control certain downloads depending on cookies. \n # Be carefull also if appending .htm[l] via Drupal's clean URLs.\n if (req.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|svg|pdf)(\\?[a-z0-9]+)?$\") {\n unset req.http.Cookie;\n }\n # Remove all cookies that backend doesn't need to know about.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRemovingSomeCookies\n if (req.http.Cookie) {\n \/* Warning: Not a pretty solution *\/\n \/* Prefix header containing cookies with ';' *\/\n set req.http.Cookie = \";\" + req.http.Cookie;\n \/* Remove any spaces after ';' in header containing cookies *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n \/* Prefix cookies we want to preserve with one space *\/\n \/* 'S{1,2}ESS[a-z0-9]+' is the regular expression matching a Drupal session cookie ({1,2} added for HTTPS support) *\/\n \/* 'NO_CACHE' is usually set after a POST request to make sure issuing user see the results of his post *\/\n \/* 'OATMEAL' & 'CHOCOLATECHIP' are special cookies used by Drupal's Bakery module to provide Single Sign On *\/\n \/* Keep in mind we should add here any cookie that should reach the backend such as splahs avoiding cookies *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \";(S{1,2}ESS[a-z0-9]+|NO_CACHE|OATMEAL|CHOCOLATECHIP)=\", \"; \\1=\");\n \/* Remove from the header any single Cookie not prefixed with a space until next ';' separator *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n \/* Remove any '; ' at the start or the end of the header *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n\n if (req.http.Cookie == \"\") {\n \/* If there are no remaining cookies, remove the cookie header. *\/\n unset req.http.Cookie;\n }\n }\n\n \/* 13th: Session cookie & special cookies bypass caching stage *\/\n # As we might want to cache some requests, hashed with its cookies, \n # we don't simply pass when some cookies remain present at this point.\n # Instead we look for request that must be passed due to the cookie header.\n if (req.http.Cookie ~ \"SESS\" ||\n req.http.Cookie ~ \"SSESS\" ||\n req.http.Cookie ~ \"NO_CACHE\" ||\n req.http.Cookie ~ \"OATMEAL\" ||\n req.http.Cookie ~ \"CHOCOLATECHIP\") {\n return (pass);\n }\n\n \/* 14th: Bypass breakpoint 2 *\/\n # Useful for debugging we can now pipe or pass the request to backend to bypass cache.\n # return (pipe);\n # return (pass);\n\n \/* 15th: Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning a lookup.\n return (lookup);\n}\n\n# vcl_pipe: Called upon entering pipe mode.\n# In this mode, the request is passed on to the backend, \n# and any further data from either client or backend is passed on unaltered until either end closes the connection.\nsub vcl_pipe {\n \/* Prevent connection re-using for piped requests *\/\n # Note that only the first request to the backend will have X-Forwarded-For set.\n # As we use X-Forwarded-For and want to have it set for all requests, \n # we have to make sure connection won't be reused after the request.\n # It is not set by default as it might break some broken web applications, like IIS with NTLM authentication.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExamplePipe\n # TO-DO: make sure this is compatible with websockets piping,\n # reference https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/websockets.html\n set bereq.http.connection = \"close\";\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this point.\n return (pipe);\n}\n\n# vcl_pass: Called upon entering pass mode. \n# In this mode, the request is passed on to the backend, and the backend's response is passed on to the client, \n# but is not entered into the cache.\n# Subsequent requests submitted over the same client connection are handled normally.\n# sub vcl_pass {\n# return (pass);\n# }\n\n# vcl_hash: You may call hash_data() on the data you would like to add to the hash.\n# Hash is used by Varnish to uniquely identify objects.\nsub vcl_hash {\n \/* Hash cookie data *\/\n # As requests with same URL and host can produce diferent results when issued with different cookies,\n # we need to store items hashed with the associated cookies. Note that cookies are already sanitized when we reach this point.\n if (req.http.Cookie) {\n \/* Include cookie in cache hash *\/\n hash_data(req.http.Cookie);\n }\n\n \/* Custom header hashing *\/\n # Empty in simple configs.\n # Example for caching differents object versions by device previously detected (when static content could also vary):\n # if (req.http.X-UA-Device) {\n # hash_data(req.http.X-UA-Device);\n # }\n # Example for caching diferent object versions by X-Forwarded-Proto, trying to be smart about what kind of request\n # could generate diffetent responses.\n # if (req.http.X-Forwarded-Proto &&\n # req.url !~ \"(?i)\\.(png|gif|jpeg|jpg|ico|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|svg|pdf)$\") {\n # hash_data(req.http.X-Forwarded-Proto);\n # }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (hash);\n# }\n\n# vcl_hit: Called after a cache lookup if the requested document was found in the cache.\nsub vcl_hit {\n \/* Check for Varnish special requests *\/ \n # Purge logic.\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/purging.html#http-purges\n # See https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged.\";\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hit {\n# return (deliver);\n# }\n\n# vcl_miss: Called after a cache lookup if the requested document was not found in the cache.\n# Its purpose is to decide whether or not to attempt to retrieve the document from the backend, and which backend to use.\nsub vcl_miss {\n \/* Check for Varnish special requests *\/ \n # Purge logic.\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/purging.html#http-purges\n # See https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged.\";\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_miss {\n# return (fetch);\n# }\n\n# vcl_fetch: Called after a document has been successfully retrieved from the backend.\nsub vcl_fetch {\n \/* Caching exceptions *\/\n # Varnish will cache objects with response codes: 200, 203, 300, 301, 302, 307, 404 & 410.\n # See https:\/\/www.varnish-software.com\/static\/book\/VCL_Basics.html#the-initial-value-of-beresp-ttl\n # Drupal's Imagecache module can return a 307 redirection to the requested url itself and, depending on Drupal's cache settings,\n # this could lead to a redirection loop being cached for a long time but also we want Varnish to shield a little the backend.\n # See http:\/\/drupal.org\/node\/1248010\n # See http:\/\/drupal.org\/node\/310656\n if (beresp.status == 307 &&\n \/* TO-DO: verify that this work better than 'req.url ~ \"imagecache\"' *\/\n beresp.http.Location == req.url &&\n beresp.ttl > 5s) {\n set beresp.ttl = 5s;\n set beresp.http.cache-control = \"max-age=5\";\n }\n\n \/* Enable grace mode. Related with our 9th stage on vcl_recv *\/\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/handling_misbehaving_servers.html#grace-mode\n set beresp.grace = 1h;\n\n \/* Enable saint mode. Related with our 9th stage on vcl_recv *\/\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/handling_misbehaving_servers.html#saint-mode\n if (beresp.status == 500) {\n set beresp.saintmode = 20s;\n # TO-DO: consider not restarting POST requests as seen on https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleSaintMode\n return(restart);\n }\n\n \/* Strip cookies from the following static file types for all users. Related with our 12th stage on vcl_recv *\/\n if (req.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|svg|pdf)(\\?[a-z0-9]+)?$\") {\n unset beresp.http.set-cookie;\n }\n\n \/* Gzip response *\/\n # Empty in simple configs\n # Use Varnish to Gzip respone, if suitable, before storing it on cache\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/phk\/gzip.html\n # if (! beresp.http.Content-Encoding &&\n # (beresp.http.content-type ~ \"text\" ||\n # beresp.http.content-type ~ \"application\/x-javascript\" ||\n # beresp.http.content-type ~ \"application\/javascript\" ||\n # beresp.http.content-type ~ \"application\/rss+xml\" ||\n # beresp.http.content-type ~ \"application\/xml\" ||\n # beresp.http.content-type ~ \"Application\/JSON\")\n # ) {\n # set beresp.do_gzip = true;\n # if ( beresp.http.Vary ) {\n # if ( ! beresp.http.Vary ~ \"Accept-Encoding\" ) {\n # set beresp.http.Vary = beresp.http.Vary + \",Accept-Encoding\";\n # }\n # } else {\n # set beresp.http.Vary = \"Accept-Encoding\";\n # }\n # }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # We can add the name of the backend that has processed the request:\n # set beresp.http.X-Backend = beresp.backend.name;\n # We can use a header to tell if the object was gziped by Varnish\n # if (beresp.do_gzip) {\n # set beresp.http.X-Varnish-Gzipped = \"yes\";\n # } else {\n # set beresp.http.X-Varnish-Gizipped = \"no\";\n # }\n # We can also add headers informing whether the object is cacheable or not and why.\n # https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Varnish3.0\n if (beresp.ttl <= 0s) {\n \/* Varnish determined the object was not cacheable *\/\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n } elsif (req.http.Cookie ~ \"(SESS|SSESS|NO_CACHE|OATMEAL|CHOCOLATECHIP)\") {\n \/* We don't wish to cache content for logged in users or with certain cookies. Related with our 9th stage on vcl_recv *\/\n set beresp.http.X-Cacheable = \"NO:Cookies\";\n # return(hit_for_pass);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n \/* We are respecting the Cache-Control=private header from the backend *\/\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n # return(hit_for_pass);\n } else {\n \/* Varnish determined the object was cacheable *\/\n set beresp.http.X-Cacheable = \"YES\";\n }\n\n \/* Further header manipulation *\/\n # Empty in simple configs.\n # We can also unset some headers to prevent information disclosure and save some cache space\n # unset beresp.http.Server;\n # unset beresp.http.X-Powered-By;\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_fetch {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Vary == \"*\") {\n# \/*\n# * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# *\/\n# set beresp.ttl = 120 s;\n# return (hit_for_pass);\n# }\n# return (deliver);\n# }\n\n# vcl_deliver: Called before an object is delivered to the client\nsub vcl_deliver {\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # Add whether the object is a cache hit or miss and the number of hits for the object.\n # https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Addingaheaderindicatinghitmiss\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n set resp.http.X-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Cache = \"MISS\";\n \/* Show the results of cookie sanitization *\/\n set resp.http.X-Cookie = req.http.Cookie;\n }\n # TO-DO: Add sick marker\n # Restart count\n if ( req.restarts > 0) {\n set resp.http.X-Restarts = req.restarts;\n }\n # Add the Varnish server hostname\n set resp.http.X-Varnish-Server = server.hostname;\n # If we have setted a custom header with device family detected we can show it:\n # if (req.http.X-UA-Device) {\n # set resp.http.X-UA-Device = req.http.X-UA-Device;\n # }\n # If we have recived a custom header with the protocol in the request we can show it:\n # if (req.http.X-Forwarded-Proto) {\n # set resp.http.X-Forwarded-Proto = req.http.X-Forwarded-Proto;\n # }\n\n \/* Vary header manipulation *\/\n # Empty in simple configs.\n # By example, if we are storing & serving diferent objects depending on User-Agent header we must set the correct Vary header:\n # if (resp.http.Vary) {\n # set resp.http.Vary = resp.http.Vary + \",User-Agent\";\n # } else {\n # set resp.http.Vary = \"User-Agent\";\n # }\n\n \/* Fake headers *\/\n # Empty in simple configs\n # We can fake server headers here, by example:\n # set resp.http.Server = \"Deep thought\";\n # set resp.http.X-Powered-By = \"BOFH\";\n # Or have some fun with headers:\n # See http:\/\/www.nextthing.org\/archives\/2005\/08\/07\/fun-with-http-headers\n # See http:\/\/royal.pingdom.com\/2012\/08\/15\/fun-and-unusual-http-response-headers\/\n # set resp.http.X-Thank-You = \"for bothering to look at my HTTP headers\";\n # set resp.http.X-Answer = \"42\";\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_deliver {\n# return (deliver);\n# }\n\n# vcl_error: Called when we hit an error, either explicitly or implicitly due to backend or internal errors.\nsub vcl_error {\n \/* Avoid DOS vulnerability CVE-2013-4484 *\/\n # See https:\/\/www.varnish-cache.org\/lists\/pipermail\/varnish-announce\/2013-October\/000686.html\n if (obj.status == 400 || obj.status == 413) {\n return(deliver);\n }\n\n \/* Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_error;\n\n \/* Try to restart request in case of failure *\/\n # Note that max_restarts defaults to 4\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if (obj.status == 503 && req.restarts < 4) {\n set obj.http.X-Restarts = req.restarts;\n return(restart);\n }\n\n \/* Set common headers for synthetic responses *\/\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n\n \/* HTTP Authentification client request *\/\n # Empty in simple configs. See http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* We're using error 200 for monitoring puposes *\/\n # Consider adding some analytics stuff to trace accesses\n if (obj.status == 200) {\n synthetic {\"\n <?xml version=\"1.0\" encoding=\"utf-8\"?>\n <!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n <html>\n <head>\n <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n <\/head>\n <body><h1>\"} + obj.status + \": \" + obj.response + {\"<\/h1><\/body>\n \"};\n return(deliver);\n }\n\n \/* Error page & refresh \/ redirections *\/\n # We have plenty of choices when we have to serve an error to the client, \n # from the default error page to javascript black magic or plain redirections.\n # Adding some external statistic javascript to track failures served to clients is strongly suggested.\n # We can't use external resources on synthetic content, everything must be inlined.\n # If we need to include images we can embed them in base64 encoding.\n # Here is the default error page for Varnish 3 (not so pretty)\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + obj.status + \" \" + obj.response + {\"<\/h1>\n <p>\"} + obj.response + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"};\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this point.\n return (deliver);\n}\n\n# vcl_init: Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n# sub vcl_init {\n# return (ok);\n# }\n\n# vcl_fini: Called when VCL is discarded only after all requests have exited the VCL. Typically used to clean up VMODs.\n# sub vcl_fini {\n# return (ok);\n# }\n","old_contents":"\/* Varnish 3 example config for Drupal 7 \/ Pressflow 6 & 7 *\/\n# Original source: https:\/\/github.com\/NITEMAN\/varnish-bites\/varnish4\/drupal-base.vcl\n# Copyright (c) 2015 Pedro Gonz\u00e1lez Serrano and individual contributors.\n# MIT License\n\n# Intended to be used both in simple production environments and with learning\/teaching purposes.\n# Loosely based on http:\/\/www.lullabot.com\/sites\/default\/files\/default_varnish3.vcl_.txt\n\n\/* Backend probes \/ healthchecks *\/\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#backend-probes\nprobe basic {\n \/* Only test that backend's IP serves content for '\/' *\/\n # This might be a too heavy probe\n # .url = \"\/\";\n \/* Only test that backend's IP has apache working *\/\n # Nginx would fail this probe with a default config\n .request =\n \"OPTIONS * HTTP\/1.1\"\n \"Host: *\"\n \"Connection: close\";\n .interval = 10s;\n .timeout = 2s;\n .window = 8;\n .threshold = 6;\n}\n\n\n\/* Backend definitions.*\/\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#backend-declarations\nbackend default {\n \/* Default backend on the same machine. WARNING: timeouts could be not big enought for certain POST request *\/\n .host = \"127.0.0.1\";\n .port = \"8080\";\n .connect_timeout = 60s;\n .first_byte_timeout = 60s;\n .between_bytes_timeout = 60s;\n .probe = basic;\n}\n\n\n\/* Directors. *\/\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#directors\n# Empty in simple configs\n\n\n\/* Access Control Lists *\/\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#acls\nacl purge_ban {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use '\"localhost\";' instead\n}\nacl allowed_monitors {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n}\n\n\n\/* Custom routines *\/\n# Empty in simple configs.\n# We can name subs with no restrictions but as a task can need several chunks of code in diferent states,\n# it's a good idea to identify what main sub will call each with a suffix.\n# \/* Example 301 client redirection removing \"www\" prefix from request *\/\n# sub perm_redirections_recv {\n# if ( req.http.host ~ \"^www.*$\" ) {\n# error 751 \"http:\/\/\" + regsub(req.http.host, \"^www\\.\", \"\") + req.url;\n# }\n# }\n# sub perm_redirections_error {\n# if (obj.status == 751) {\n# \/* Get new URL from the response *\/\n# set obj.http.Location = obj.response;\n# \/* Set HTTP 301 for permanent redirect *\/\n# set obj.status = 301;\n# return(deliver);\n# }\n# }\n\n\n\/* VCL logigc overrides *\/\n# Note that the built-in logic will be appended to our code if no return is performed before.\n# Built-in logic is included commented out right after our's for reference purposes in that cases.\n# See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleDefault\n# See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/vcl.html#subroutines\n\n# vcl_recv: Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use.\nsub vcl_recv {\n \/* 0th: general bypass, general return & authorization checks *\/\n # Empty in simple configs.\n # Useful for debugging we can pipe or pass the request to default backend here to bypass completely Varnish.\n # return (pipe);\n # return (pass);\n # We can also return here a 200 Ok for network performance benchmarking.\n # error 200 \"Ok\";\n # Finally we can perform basic HTTP authentification here by example.\n # See http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* 1st: Check for Varnish special requests *\/ \n # Purge logic.\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/purging.html#http-purges\n # See https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if (req.request == \"PURGE\") {\n if (!client.ip ~ purge_ban) {\n error 405 \"Not allowed.\";\n }\n return (lookup);\n }\n # Ban logic. See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/purging.html#bans\n if (req.request == \"BAN\") {\n if (!client.ip ~ purge_ban) {\n error 405 \"Not allowed.\";\n }\n ban(\"req.http.host == \" + req.http.host +\n \"&& req.url == \" + req.url); \n error 200 \"Ban added\";\n }\n # Custom response implementation example in order to check that Varnish is working properly.\n # This is usefull for automatic monitoring with monit or when Varnish is behind another proxies like HAProxy.\n if (req.http.host == \"monitor.server.health\" && \n client.ip ~ allowed_monitors && \n (req.request == \"OPTIONS\" || req.request == \"GET\")) {\n error 200 \"Ok\";\n }\n\n \/* 2nd: Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_recv;\n # Here we can also enforce SSL when Varnish run behind some SSL termination point.\n\n \/* 3rd: Time for backend choice *\/\n # Empty in simple configs.\n\n \/* 4th: Set custom headers for backend like X-Forwarded-For (copied from built-in logic) *\/\n if (req.restarts == 0) {\n \/* See also vcl_pipe section *\/\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n \/* 5th: Bypass breakpoint 1 *\/\n # Useful for debugging we can now pipe or pass the request to backend with headers setted.\n # return (pipe);\n # return (pass);\n\n \/* 6th: Decide if we should deal with a request (mostly copied from built-in logic) *\/\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n\n \/* 7th: Access control for some URLs by ACL *\/\n # Empty in simple configs.\n # By example denial some URLs depending on client-ip, we'll need to define corresponding ACL 'internal'.\n # if (req.url ~ \"^\/(cron|install)\\.php$\" && !client.ip ~ internal) {\n # # Have Varnish throw the error directly.\n # error 403 \"Forbidden.\";\n # # Use a custom error page that you've defined in Drupal at the path \"404\".\n # # set req.url = \"\/403\";\n # }\n\n \/* 8th: Custom exceptions *\/\n # Host exception example:\n # if (req.http.host == \"ejemplo.exception.com\") {\n # return (pass);\n # }\n # Drupal exceptions, edit if we want to cache some AJAX\/AHAH request.\n # Add here filters for never cache URLs such as Payment Gateway's callbacks\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/ooyala\/ping$\" ||\n req.url ~ \"^\/admin\/build\/features\" ||\n req.url ~ \"^\/info\/.*$\" ||\n req.url ~ \"^\/flag\/.*$\" ||\n req.url ~ \"^.*\/ajax\/.*$\" ||\n req.url ~ \"^.*\/ahah\/.*$\") {\n \/* Do not cache these paths *\/\n return (pass);\n }\n # Pipe these paths directly to backend for streaming.\n if (req.url ~ \"^\/admin\/content\/backup_migrate\/export\") {\n return (pipe);\n }\n if (req.url ~ \"^\/system\/files\") {\n return (pipe);\n }\n\n \/* 9th: Enable grace mode *\/\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/handling_misbehaving_servers.html#grace-mode\n if (! req.backend.healthy) {\n \/* Use a longer grace period if all backends are down *\/\n set req.grace = 1h;\n \/* Use anonymous, cached pages if all backends are down. *\/\n unset req.http.Cookie;\n # TO-DO: Add sick marker\n } else {\n \/* Allow the backend to serve up stale content if it is responding slowly. *\/\n set req.grace = 30s;\n }\n\n \/* 10th: Deal with compression and the Accept-Encoding header *\/\n # Althought Varnish 3 handles gziped content itself by default, just to be sure we want to \n # remove Accept-Encoding for some compressed formats.\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/phk\/gzip.html#what-does-http-gzip-support-do\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/reference\/varnishd.html?highlight=http_gzip_support\n # See (for older configs) https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleNormalizeAcceptEncoding\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|mp4|flv|zip|rar)$\") {\n \/* Already compressed formats, no sense trying to compress again *\/\n remove req.http.Accept-Encoding;\n }\n }\n\n \/* 11th: Another header manipulation *\/\n # Empty in simple configs.\n # We could add here a custom header grouping User-agent families.\n\n \/* 12th: Cookie removal *\/\n # Always cache the following static file types for all users. \n # Use with care if we control certain downloads depending on cookies. \n # Be carefull also if appending .htm[l] via Drupal's clean URLs.\n if (req.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|svg|pdf)(\\?[a-z0-9]+)?$\") {\n unset req.http.Cookie;\n }\n # Remove all cookies that backend doesn't need to know about.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRemovingSomeCookies\n if (req.http.Cookie) {\n \/* Warning: Not a pretty solution *\/\n \/* Prefix header containing cookies with ';' *\/\n set req.http.Cookie = \";\" + req.http.Cookie;\n \/* Remove any spaces after ';' in header containing cookies *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n \/* Prefix cookies we want to preserve with one space *\/\n \/* 'S{1,2}ESS[a-z0-9]+' is the regular expression matching a Drupal session cookie ({1,2} added for HTTPS support) *\/\n \/* 'NO_CACHE' is usually set after a POST request to make sure issuing user see the results of his post *\/\n \/* 'OATMEAL' & 'CHOCOLATECHIP' are special cookies used by Drupal's Bakery module to provide Single Sign On *\/\n \/* Keep in mind we should add here any cookie that should reach the backend such as splahs avoiding cookies *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \";(S{1,2}ESS[a-z0-9]+|NO_CACHE|OATMEAL|CHOCOLATECHIP)=\", \"; \\1=\");\n \/* Remove from the header any single Cookie not prefixed with a space until next ';' separator *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n \/* Remove any '; ' at the start or the end of the header *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n\n if (req.http.Cookie == \"\") {\n \/* If there are no remaining cookies, remove the cookie header. *\/\n unset req.http.Cookie;\n }\n }\n\n \/* 13th: Session cookie & special cookies bypass caching stage *\/\n # As we might want to cache some requests, hashed with its cookies, \n # we don't simply pass when some cookies remain present at this point.\n # Instead we look for request that must be passed due to the cookie header.\n if (req.http.Cookie ~ \"SESS\" ||\n req.http.Cookie ~ \"SSESS\" ||\n req.http.Cookie ~ \"NO_CACHE\" ||\n req.http.Cookie ~ \"OATMEAL\" ||\n req.http.Cookie ~ \"CHOCOLATECHIP\") {\n return (pass);\n }\n\n \/* 14th: Bypass breakpoint 2 *\/\n # Useful for debugging we can now pipe or pass the request to backend to bypass cache.\n # return (pipe);\n # return (pass);\n\n \/* 15th: Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning a lookup.\n return (lookup);\n}\n\n# vcl_pipe: Called upon entering pipe mode.\n# In this mode, the request is passed on to the backend, \n# and any further data from either client or backend is passed on unaltered until either end closes the connection.\nsub vcl_pipe {\n \/* Prevent connection re-using for piped requests *\/\n # Note that only the first request to the backend will have X-Forwarded-For set.\n # As we use X-Forwarded-For and want to have it set for all requests, \n # we have to make sure connection won't be reused after the request.\n # It is not set by default as it might break some broken web applications, like IIS with NTLM authentication.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExamplePipe\n # TO-DO: make sure this is compatible with websockets piping,\n # reference https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/websockets.html\n set bereq.http.connection = \"close\";\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this point.\n return (pipe);\n}\n\n# vcl_pass: Called upon entering pass mode. \n# In this mode, the request is passed on to the backend, and the backend's response is passed on to the client, \n# but is not entered into the cache.\n# Subsequent requests submitted over the same client connection are handled normally.\n# sub vcl_pass {\n# return (pass);\n# }\n\n# vcl_hash: You may call hash_data() on the data you would like to add to the hash.\n# Hash is used by Varnish to uniquely identify objects.\nsub vcl_hash {\n \/* Hash cookie data *\/\n # As requests with same URL and host can produce diferent results when issued with different cookies,\n # we need to store items hashed with the associated cookies. Note that cookies are already sanitized when we reach this point.\n if (req.http.Cookie) {\n \/* Include cookie in cache hash *\/\n hash_data(req.http.Cookie);\n }\n\n \/* Custom header hashing *\/\n # Empty in simple configs.\n # Example for caching differents object versions by device previously detected (when static content could also vary):\n # if (req.http.X-UA-Device) {\n # hash_data(req.http.X-UA-Device);\n # }\n # Example for caching diferent object versions by X-Forwarded-Proto, trying to be smart about what kind of request\n # could generate diffetent responses.\n # if (req.http.X-Forwarded-Proto &&\n # req.url !~ \"(?i)\\.(png|gif|jpeg|jpg|ico|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|svg|pdf)$\") {\n # hash_data(req.http.X-Forwarded-Proto);\n # }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (hash);\n# }\n\n# vcl_hit: Called after a cache lookup if the requested document was found in the cache.\nsub vcl_hit {\n \/* Check for Varnish special requests *\/ \n # Purge logic.\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/purging.html#http-purges\n # See https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged.\";\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hit {\n# return (deliver);\n# }\n\n# vcl_miss: Called after a cache lookup if the requested document was not found in the cache.\n# Its purpose is to decide whether or not to attempt to retrieve the document from the backend, and which backend to use.\nsub vcl_miss {\n \/* Check for Varnish special requests *\/ \n # Purge logic.\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/purging.html#http-purges\n # See https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged.\";\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_miss {\n# return (fetch);\n# }\n\n# vcl_fetch: Called after a document has been successfully retrieved from the backend.\nsub vcl_fetch {\n \/* Caching exceptions *\/\n # Varnish will cache objects with response codes: 200, 203, 300, 301, 302, 307, 404 & 410.\n # See https:\/\/www.varnish-software.com\/static\/book\/VCL_Basics.html#the-initial-value-of-beresp-ttl\n # Drupal's Imagecache module can return a 307 redirection to the requested url itself and, depending on Drupal's cache settings,\n # this could lead to a redirection loop being cached for a long time but also we want Varnish to shield a little the backend.\n # See http:\/\/drupal.org\/node\/1248010\n # See http:\/\/drupal.org\/node\/310656\n if (beresp.status == 307 &&\n \/* TO-DO: verify that this work better than 'req.url ~ \"imagecache\"' *\/\n beresp.http.Location == req.url &&\n beresp.ttl > 5s) {\n set beresp.ttl = 5s;\n set beresp.http.cache-control = \"max-age=5\";\n }\n\n \/* Enable grace mode. Related with our 9th stage on vcl_recv *\/\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/handling_misbehaving_servers.html#grace-mode\n set beresp.grace = 1h;\n\n \/* Enable saint mode. Related with our 9th stage on vcl_recv *\/\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/handling_misbehaving_servers.html#saint-mode\n if (beresp.status == 500) {\n set beresp.saintmode = 20s;\n # TO-DO: consider not restarting POST requests as seen on https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleSaintMode\n return(restart);\n }\n\n \/* Strip cookies from the following static file types for all users. Related with our 12th stage on vcl_recv *\/\n if (req.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|svg|pdf)(\\?[a-z0-9]+)?$\") {\n unset beresp.http.set-cookie;\n }\n\n \/* Gzip response *\/\n # Empty in simple configs\n # Use Varnish to Gzip respone, if suitable, before storing it on cache\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/3.0\/phk\/gzip.html\n # if (! beresp.http.Content-Encoding &&\n # (beresp.http.content-type ~ \"text\" ||\n # beresp.http.content-type ~ \"application\/x-javascript\" ||\n # beresp.http.content-type ~ \"application\/javascript\" ||\n # beresp.http.content-type ~ \"application\/rss+xml\" ||\n # beresp.http.content-type ~ \"application\/xml\" ||\n # beresp.http.content-type ~ \"Application\/JSON\")\n # ) {\n # set beresp.do_gzip = true;\n # if ( beresp.http.Vary ) {\n # if ( ! beresp.http.Vary ~ \"Accept-Encoding\" ) {\n # set beresp.http.Vary = beresp.http.Vary + \",Accept-Encoding\";\n # }\n # } else {\n # set beresp.http.Vary = \"Accept-Encoding\";\n # }\n # }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # We can add the name of the backend that has processed the request:\n # set beresp.http.X-Backend = beresp.backend.name;\n # We can use a header to tell if the object was gziped by Varnish\n # if (beresp.do_gzip) {\n # set beresp.http.X-Varnish-Gzipped = \"yes\";\n # } else {\n # set beresp.http.X-Varnish-Gizipped = \"no\";\n # }\n # We can also add headers informing whether the object is cacheable or not and why.\n # https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Varnish3.0\n if (beresp.ttl <= 0s) {\n \/* Varnish determined the object was not cacheable *\/\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n } elsif (req.http.Cookie ~ \"(SESS|SSESS|NO_CACHE|OATMEAL|CHOCOLATECHIP)\") {\n \/* We don't wish to cache content for logged in users or with certain cookies. Related with our 9th stage on vcl_recv *\/\n set beresp.http.X-Cacheable = \"NO:Cookies\";\n # return(hit_for_pass);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n \/* We are respecting the Cache-Control=private header from the backend *\/\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n # return(hit_for_pass);\n } else {\n \/* Varnish determined the object was cacheable *\/\n set beresp.http.X-Cacheable = \"YES\";\n }\n\n \/* Further header manipulation *\/\n # Empty in simple configs.\n # We can also unset some headers to prevent information disclosure and save some cache space\n # unset beresp.http.Server;\n # unset beresp.http.X-Powered-By;\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_fetch {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Vary == \"*\") {\n# \/*\n# * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# *\/\n# set beresp.ttl = 120 s;\n# return (hit_for_pass);\n# }\n# return (deliver);\n# }\n\n# vcl_deliver: Called before an object is delivered to the client\nsub vcl_deliver {\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # Add whether the object is a cache hit or miss and the number of hits for the object.\n # https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Addingaheaderindicatinghitmiss\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n set resp.http.X-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Cache = \"MISS\";\n \/* Show the results of cookie sanitization *\/\n set resp.http.X-Cookie = req.http.Cookie;\n }\n # TO-DO: Add sick marker\n # Restart count\n if ( req.restarts > 0) {\n set resp.http.X-Restarts = req.restarts;\n }\n # Add the Varnish server hostname\n set resp.http.X-Varnish-Server = server.hostname;\n # If we have setted a custom header with device family detected we can show it:\n # if (req.http.X-UA-Device) {\n # set resp.http.X-UA-Device = req.http.X-UA-Device;\n # }\n # If we have recived a custom header with the protocol in the request we can show it:\n # if (req.http.X-Forwarded-Proto) {\n # set resp.http.X-Forwarded-Proto = req.http.X-Forwarded-Proto;\n # }\n\n \/* Vary header manipulation *\/\n # Empty in simple configs.\n # By example, if we are storing & serving diferent objects depending on User-Agent header we must set the correct Vary header:\n # if (resp.http.Vary) {\n # set resp.http.Vary = resp.http.Vary + \",User-Agent\";\n # } else {\n # set resp.http.Vary = \"User-Agent\";\n # }\n\n \/* Fake headers *\/\n # Empty in simple configs\n # We can fake server headers here, by example:\n # set resp.http.Server = \"Deep thought\";\n # set resp.http.X-Powered-By = \"BOFH\";\n # Or have some fun with headers:\n # See http:\/\/www.nextthing.org\/archives\/2005\/08\/07\/fun-with-http-headers\n # See http:\/\/royal.pingdom.com\/2012\/08\/15\/fun-and-unusual-http-response-headers\/\n # set resp.http.X-Thank-You = \"for bothering to look at my HTTP headers\";\n # set resp.http.X-Answer = \"42\";\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_deliver {\n# return (deliver);\n# }\n\n# vcl_error: Called when we hit an error, either explicitly or implicitly due to backend or internal errors.\nsub vcl_error {\n \/* Avoid DOS vulnerability CVE-2013-4484 *\/\n # See https:\/\/www.varnish-cache.org\/lists\/pipermail\/varnish-announce\/2013-October\/000686.html\n if (obj.status == 400 || obj.status == 413) {\n return(deliver);\n }\n\n \/* Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_error;\n\n \/* Try to restart request in case of failure *\/\n # Note that max_restarts defaults to 4\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if (obj.status == 503 && req.restarts < 4) {\n set obj.http.X-Restarts = req.restarts;\n return(restart);\n }\n\n \/* Set common headers for synthetic responses *\/\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n\n \/* HTTP Authentification client request *\/\n # Empty in simple configs. See http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* We're using error 200 for monitoring puposes *\/\n # Consider adding some analytics stuff to trace accesses\n if (obj.status == 200) {\n synthetic {\"\n <?xml version=\"1.0\" encoding=\"utf-8\"?>\n <!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n <html>\n <head>\n <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n <\/head>\n <body><h1>\"} + obj.status + \": \" + obj.response + {\"<\/h1><\/body>\n \"};\n return(deliver);\n }\n\n \/* Error page & refresh \/ redirections *\/\n # We have plenty of choices when we have to serve an error to the client, \n # from the default error page to javascript black magic or plain redirections.\n # Adding some external statistic javascript to track failures served to clients is strongly suggested.\n # We can't use external resources on synthetic content, everything must be inlined.\n # If we need to include images we can embed them in base64 encoding.\n # Here is the default error page for Varnish 3 (not so pretty)\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + obj.status + \" \" + obj.response + {\"<\/h1>\n <p>\"} + obj.response + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"};\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this point.\n return (deliver);\n}\n\n# vcl_init: Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n# sub vcl_init {\n# return (ok);\n# }\n\n# vcl_fini: Called when VCL is discarded only after all requests have exited the VCL. Typically used to clean up VMODs.\n# sub vcl_fini {\n# return (ok);\n# }\n","returncode":0,"stderr":"","license":"unknown","lang":"VCL"} {"commit":"0b013a31dad59338232c89ffc1973f1e8ccdc413","subject":"Unset Via and Server headers","message":"Unset Via and Server headers\n","repos":"karan\/warehouse,HonzaKral\/warehouse,wlonk\/warehouse,alex\/warehouse,HonzaKral\/warehouse,alex\/warehouse,dstufft\/warehouse,dstufft\/warehouse,pypa\/warehouse,HonzaKral\/warehouse,dstufft\/warehouse,ismail-s\/warehouse,alex\/warehouse,pypa\/warehouse,karan\/warehouse,karan\/warehouse,wlonk\/warehouse,pypa\/warehouse,karan\/warehouse,alex\/warehouse,ismail-s\/warehouse,HonzaKral\/warehouse,pypa\/warehouse,ismail-s\/warehouse,ismail-s\/warehouse,karan\/warehouse,ismail-s\/warehouse,dstufft\/warehouse,alex\/warehouse,wlonk\/warehouse","old_file":"vcl\/main.vcl","new_file":"vcl\/main.vcl","new_contents":"\nsub vcl_recv {\n#FASTLY recv\n\n # Disable ESI processing when doing a shield request.\n if (req.http.Fastly-FF) {\n set req.esi = false;\n }\n\n # If we're serving an ESI request, and the request in question has NOT\n # opted into cookies, then we'll go ahead and strip any cookies from the\n # request. In addition, we'll strip out any Authorization or Authentication\n # headers.\n if (req.url ~ \"^\/_esi\/\") {\n unset req.http.Authenticate;\n unset req.http.Authorization;\n\n if (req.url !~ \"esi-cookies=1\") {\n unset req.http.Cookie;\n }\n }\n\n # We want to Force SSL for the WebUI by redirecting to the HTTPS version of\n # the page, however for API calls we want to return an error code directing\n # people to instead use HTTPS.\n if (!req.http.Fastly-SSL) {\n\n # The \/simple\/ and \/packages\/ API.\n if (req.url ~ \"^\/(simple|packages)\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy JSON API.\n if (req.url ~ \"^\/pypi\/.+\/json$\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy ?:action= API.\n if (req.url ~ \"^\/pypi.*(\\?|&)=:action\") {\n error 803 \"SSL is required\";\n }\n\n # If we're on the \/pypi page and we've received something other than a\n # GET or HEAD request, then we have no way to determine if a particular\n # request is an API call or not because it'll be in the request body\n # and that isn't available to us here. So in those cases, we won't\n # do a redirect.\n if (req.url ~ \"^\/pypi\") {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n error 801 \"Force SSL\";\n }\n }\n else {\n # This isn't a \/pypi URL so we'll just unconditionally redirect to\n # HTTPS.\n error 801 \"Force SSL\";\n }\n }\n\n # Set a header to tell the backend if we're using https or http.\n if (req.http.Fastly-SSL) {\n set req.http.Warehouse-Proto = \"https\";\n } else {\n set req.http.Warehouse-Proto = \"http\";\n }\n\n # Pass the client IP address back to the backend.\n if (req.http.Fastly-Client-IP) {\n set req.http.Warehouse-IP = req.http.Fastly-Client-IP;\n }\n\n # Pass the real host value back to the backend.\n if (req.http.Host) {\n set req.http.Warehouse-Host = req.http.Host;\n }\n\n # Do not bother to attempt to run the caching mechanisms for methods that\n # are not generally safe to cache.\n if (req.request != \"HEAD\" &&\n req.request != \"GET\" &&\n req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n # Finally, return the default lookup action.\n return(lookup);\n}\n\n\nsub vcl_fetch {\n#FASTLY fetch\n\n # Only enable ESI on responses that have opted into them.\n if (beresp.http.Warehouse-ESI-Enable) {\n # Conditional HTTP requests are not compatible with Varnish's\n # implementation of ESI, in particularl the ETag and the Last-Modified\n # won't be updated when the included content changes, causing Varnish\n # to return a 304 Not Modified.\n unset beresp.http.ETag;\n unset beresp.http.Last-Modified;\n\n # Enable ESI.\n esi;\n }\n\n # Trigger a \"SSL is required\" error if the backend has indicated to do so.\n if (beresp.http.X-Fastly-Error == \"803\") {\n error 803 \"SSL is required\";\n }\n\n # If we've gotten a 500 or a 503 from the backend, we'll go ahead and retry\n # the request.\n if ((beresp.status == 500 || beresp.status == 503) &&\n req.restarts < 1 &&\n (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n # If we've restarted, then we'll record the number of restarts.\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n # If there is a Set-Cookie header, we'll ensure that we do not cache the\n # response.\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n # If the response has the private Cache-Control directive then we won't\n # cache it.\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # If we've gotten an error after the restarts we'll deliver the response\n # with a very short cache time.\n if (beresp.status == 500 || beresp.status == 503) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n # Apply a default TTL if there isn't a max-age or s-maxage.\n if (beresp.http.Expires ||\n beresp.http.Surrogate-Control ~ \"max-age\" ||\n beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # Keep the ttl here\n }\n else {\n # Apply the default ttl\n set beresp.ttl = 60s;\n }\n\n # Actually deliver the fetched response.\n return(deliver);\n}\n\n\nsub vcl_deliver {\n#FASTLY deliver\n\n # If the backend has indicated additional Vary headers to add once the\n # ESI result has been processed, then we'll go ahead and either append them\n # to our existing Vary header or we'll set the Vary header equal to it.\n if (resp.http.Warehouse-ESI-Vary) {\n if (resp.http.Vary) {\n set resp.http.Vary = resp.http.Vary \", \" resp.http.Warehouse-ESI-Vary;\n } else {\n set resp.http.Vary = resp.http.Warehouse-ESI-Vary;\n }\n\n unset resp.http.Warehouse-ESI-Vary;\n }\n\n # We no longer need the header that enables ESI, so we'll remove it from\n # the output.\n unset resp.http.Warehouse-ESI-Enable;\n\n # Unset headers that we don't need\/want to send on to the client because\n # they are not generally useful.\n unset resp.http.Server;\n unset resp.http.Via;\n\n return(deliver);\n}\n\n\nsub vcl_error {\n#FASTLY error\n\n if (obj.status == 803) {\n set obj.status = 403;\n set obj.response = \"SSL is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic {\"SSL is required.\"};\n return (deliver);\n }\n}\n","old_contents":"\nsub vcl_recv {\n#FASTLY recv\n\n # Disable ESI processing when doing a shield request.\n if (req.http.Fastly-FF) {\n set req.esi = false;\n }\n\n # If we're serving an ESI request, and the request in question has NOT\n # opted into cookies, then we'll go ahead and strip any cookies from the\n # request. In addition, we'll strip out any Authorization or Authentication\n # headers.\n if (req.url ~ \"^\/_esi\/\") {\n unset req.http.Authenticate;\n unset req.http.Authorization;\n\n if (req.url !~ \"esi-cookies=1\") {\n unset req.http.Cookie;\n }\n }\n\n # We want to Force SSL for the WebUI by redirecting to the HTTPS version of\n # the page, however for API calls we want to return an error code directing\n # people to instead use HTTPS.\n if (!req.http.Fastly-SSL) {\n\n # The \/simple\/ and \/packages\/ API.\n if (req.url ~ \"^\/(simple|packages)\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy JSON API.\n if (req.url ~ \"^\/pypi\/.+\/json$\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy ?:action= API.\n if (req.url ~ \"^\/pypi.*(\\?|&)=:action\") {\n error 803 \"SSL is required\";\n }\n\n # If we're on the \/pypi page and we've received something other than a\n # GET or HEAD request, then we have no way to determine if a particular\n # request is an API call or not because it'll be in the request body\n # and that isn't available to us here. So in those cases, we won't\n # do a redirect.\n if (req.url ~ \"^\/pypi\") {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n error 801 \"Force SSL\";\n }\n }\n else {\n # This isn't a \/pypi URL so we'll just unconditionally redirect to\n # HTTPS.\n error 801 \"Force SSL\";\n }\n }\n\n # Set a header to tell the backend if we're using https or http.\n if (req.http.Fastly-SSL) {\n set req.http.Warehouse-Proto = \"https\";\n } else {\n set req.http.Warehouse-Proto = \"http\";\n }\n\n # Pass the client IP address back to the backend.\n if (req.http.Fastly-Client-IP) {\n set req.http.Warehouse-IP = req.http.Fastly-Client-IP;\n }\n\n # Pass the real host value back to the backend.\n if (req.http.Host) {\n set req.http.Warehouse-Host = req.http.Host;\n }\n\n # Do not bother to attempt to run the caching mechanisms for methods that\n # are not generally safe to cache.\n if (req.request != \"HEAD\" &&\n req.request != \"GET\" &&\n req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n # Finally, return the default lookup action.\n return(lookup);\n}\n\n\nsub vcl_fetch {\n#FASTLY fetch\n\n # Only enable ESI on responses that have opted into them.\n if (beresp.http.Warehouse-ESI-Enable) {\n # Conditional HTTP requests are not compatible with Varnish's\n # implementation of ESI, in particularl the ETag and the Last-Modified\n # won't be updated when the included content changes, causing Varnish\n # to return a 304 Not Modified.\n unset beresp.http.ETag;\n unset beresp.http.Last-Modified;\n\n # Enable ESI.\n esi;\n }\n\n # Trigger a \"SSL is required\" error if the backend has indicated to do so.\n if (beresp.http.X-Fastly-Error == \"803\") {\n error 803 \"SSL is required\";\n }\n\n # If we've gotten a 500 or a 503 from the backend, we'll go ahead and retry\n # the request.\n if ((beresp.status == 500 || beresp.status == 503) &&\n req.restarts < 1 &&\n (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n # If we've restarted, then we'll record the number of restarts.\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n # If there is a Set-Cookie header, we'll ensure that we do not cache the\n # response.\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n # If the response has the private Cache-Control directive then we won't\n # cache it.\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # If we've gotten an error after the restarts we'll deliver the response\n # with a very short cache time.\n if (beresp.status == 500 || beresp.status == 503) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n # Apply a default TTL if there isn't a max-age or s-maxage.\n if (beresp.http.Expires ||\n beresp.http.Surrogate-Control ~ \"max-age\" ||\n beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # Keep the ttl here\n }\n else {\n # Apply the default ttl\n set beresp.ttl = 60s;\n }\n\n # Actually deliver the fetched response.\n return(deliver);\n}\n\n\nsub vcl_deliver {\n#FASTLY deliver\n\n # If the backend has indicated additional Vary headers to add once the\n # ESI result has been processed, then we'll go ahead and either append them\n # to our existing Vary header or we'll set the Vary header equal to it.\n if (resp.http.Warehouse-ESI-Vary) {\n if (resp.http.Vary) {\n set resp.http.Vary = resp.http.Vary \", \" resp.http.Warehouse-ESI-Vary;\n } else {\n set resp.http.Vary = resp.http.Warehouse-ESI-Vary;\n }\n\n unset resp.http.Warehouse-ESI-Vary;\n }\n\n # We no longer need the header that enables ESI, so we'll remove it from\n # the output.\n unset resp.http.Warehouse-ESI-Enable;\n\n return(deliver);\n}\n\n\nsub vcl_error {\n#FASTLY error\n\n if (obj.status == 803) {\n set obj.status = 403;\n set obj.response = \"SSL is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic {\"SSL is required.\"};\n return (deliver);\n }\n}\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"15d03edeb0fe5d0eb363e32b75905301e5c7b246","subject":"purge pages implemented","message":"purge pages implemented","repos":"Arasaac\/dockerizePHPApp,Arasaac\/dockerizePHPApp,Arasaac\/dockerizePHPApp,Arasaac\/dockerizePHPApp,Arasaac\/dockerizePHPApp,Arasaac\/dockerizePHPApp","old_file":"varnish\/default.vcl","new_file":"varnish\/default.vcl","new_contents":"vcl 4.0;\n# Based on: https:\/\/github.com\/mattiasgeniar\/varnish-4.0-configuration-templates\/blob\/master\/\nimport std;\nimport directors;\n\nbackend server1 { # Define one backend\n .host = \"{VARNISH_BACKEND_HOST}\";\n .port = \"{VARNISH_BACKEND_PORT}\";\n .max_connections = 300; # That's it\n\n .probe = {\n #.url = \"\/\"; # short easy way (GET \/)\n # We prefer to only do a HEAD \/\n .request =\n \"HEAD \/ HTTP\/1.1\"\n \"Host: arasaac\"\n \"Connection: close\"\n \"User-Agent: Varnish Health Probe\";\n\n .interval = 5s; # check the health of each backend every 5 seconds\n .timeout = 3s; # timing out after 1 second.\n .window = 5; # If 3 out of the last 5 polls succeeded the backend is considered healthy, otherwise it will be marked as sick\n .threshold = 3;\n }\n\n .first_byte_timeout = 3s; # How long to wait before we receive a first byte from our backend?\n .connect_timeout = 5s; # How long to wait for a backend connection?\n .between_bytes_timeout = 2s; # How long to wait between bytes received from our backend?\n}\n\n#acl purge {\n # ACL we'll use later to allow purges\n# \"localhost\";\n# \"127.0.0.1\";\n# \"::1\";\n#}\n\nsub vcl_init {\n # Called when VCL is loaded, before any requests pass through it.\n # Typically used to initialize VMODs.\n\n new vdir = directors.round_robin();\n vdir.add_backend(server1);\n # vdir.add_backend(server...);\n # vdir.add_backend(servern);\n}\n\nsub vcl_recv {\n set req.backend_hint = vdir.backend(); # send all traffic to the vdir director\n\n # Normalize the header, remove the port (in case you're testing this on various TCP ports)\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n # Remove the proxy header (see https:\/\/httpoxy.org\/#mitigate-varnish)\n unset req.http.proxy;\n\n # when purging from php files, we need to send the request to varnish but process it as it were arasaac web server\n if ( req.http.host ~ \"varnish\" ) {\n set req.http.x-host = req.http.host;\n set req.http.host = \"www.arasaac.org\";\n }\n\n\n if (req.http.host ~ \"^arasaac.org\" || req.http.host ~ \"arasaac.net\" || req.http.host ~ \"arasaac.es\" ) {\n return (synth (750, \"\"));\n }\n if (req.url~ \"^\/index.php\") {\n set req.url = regsub(req.url, \"index.php\", \"\");\n } \n\n # Allow purging\n if (req.method == \"PURGE\") {\n# if (!client.ip ~ purge) { # purge is the ACL defined at the begining\n # Not from an allowed IP? Then die with an error.\n# return (synth(405, \"This IP is not allowed to send PURGE requests.\"));\n# }\n # If you got this stage (and didn't error out above), purge the cached result\n return (purge);\n }\n if (req.method == \"BAN\")\n {\n \/\/ TODO: Add client validation as needed\n ban(\"obj.http.x-url ~ \" + req.url);\n return(synth(901, \"BAN Set for \" + req.url));\n }\n\n # Only deal with \"normal\" types\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"PATCH\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n # Implementing websocket support (https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html)\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n # Only cache GET or HEAD requests. This makes sure the POST requests are always passed.\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n\n set req.http.Cookie = regsuball(req.http.Cookie, \"has_js=[^;]+(; )?\", \"\");\n\n # Remove any Google Analytics based cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__utm.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"_ga=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"_gat=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmctr=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmcmd.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmccn.=[^;]+(; )?\", \"\");\n\n # Remove Arasaac Cookies for caching:\n if (!(req.url ~ \"cesta.php\" || req.url ~ \"pictogramas_color.php\" || req.url ~ \"pictogramas_byn.php\"|| req.url ~ \"imagenes.php\" || req.url ~ \"videos_lse.php\" || req.url ~ \"signos_lse_color.php\" \n || req.url ~ \"buscar.php\" || req.url ~ \"n_elementos_cesto.php\" || req.url ~ \"herramientas\" || req.url ~ \"zip_cesto.php\" || req.url ~ \"carpeta_trabajo.php\" || req.url ~ \"admin.php\")) {\n set req.http.Cookie = regsuball(req.http.Cookie, \"PHPSESSID=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"preImg=x; \", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"; \", \";\");\n\n }\n \n #unset req.http.cookie; \n # Remove DoubleClick offensive cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__gads=[^;]+(; )?\", \"\");\n\n # Remove the Quant Capital cookies (added by some plugin, all __qca)\n set req.http.Cookie = regsuball(req.http.Cookie, \"__qc.=[^;]+(; )?\", \"\");\n\n # Remove the AddThis cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__atuv.=[^;]+(; )?\", \"\");\n\n # Remove a \";\" prefix in the cookie if present\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n\n # Are there cookies left with only spaces or that are empty?\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n\n # Remove all cookies for static files\n # A valid discussion could be held on this line: do you really need to cache static files that don't cause load? Only if you have memory left.\n # Sure, there's disk I\/O, but chances are your OS will already have these files in their buffers (thus memory).\n # Before you blindly enable this, have a read here: https:\/\/ma.ttias.be\/stop-caching-static-files\/\n if (req.url ~ \"^[^?]*\\.(7z|avi|bmp|bz2|css|csv|doc|docx|eot|flac|flv|gif|gz|ico|jpeg|jpg|js|less|mka|mkv|mov|mp3|mp4|mpeg|mpg|odt|otf|ogg|ogm|opus|pdf|png|ppt|pptx|rar|rtf|svg|svgz|swf|tar|tbz|tgz|ttf|txt|txz|wav|webm|webp|woff|woff2|xls|xlsx|xml|xz|zip)(\\?.*)?$\") {\n unset req.http.Cookie;\n return (hash);\n }\n \n #at the end because I need to remove previous cookies \n if (req.url ~ \"purge.php\") {\n return (pass);\n }\n\n return (hash);\n}\n\nsub vcl_pipe {\n # Called upon entering pipe mode.\n # In this mode, the request is passed on to the backend, and any further data from both the client\n # and backend is passed on unaltered until either end closes the connection. Basically, Varnish will\n # degrade into a simple TCP proxy, shuffling bytes back and forth. For a connection in pipe mode,\n # no other VCL subroutine will ever get called after vcl_pipe.\n\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n # set bereq.http.connection = \"close\";\n # here. It is not set by default as it might break some broken web\n # applications, like IIS with NTLM authentication.\n\n # set bereq.http.Connection = \"Close\";\n\n # Implementing websocket support (https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html)\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n\n return (pipe);\n}\n\nsub vcl_pass {\n # Called upon entering pass mode. In this mode, the request is passed on to the backend, and the\n # backend's response is passed on to the client, but is not entered into the cache. Subsequent\n # requests submitted over the same client connection are handled normally.\n\n # return (pass);\n}\n\n# The data on which the hashing will take place\nsub vcl_hash {\n # Called after vcl_recv to create a hash value for the request. This is used as a key\n # to look up the object in Varnish.\n\n hash_data(req.url);\n\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n\n # hash cookies for requests that have them\n# if (req.http.Language) {\n #add cookie in hash\n# hash_data(req.http.Language);\n# }\n if (req.http.Cookie) {\n hash_data(req.http.Cookie);\n }\n #for debugging hash \n #std.log(\"######################################################################################################\");\n #std.log(req.http.Cookie + req.http.host + req.url);\n\n}\n\nsub vcl_hit {\n # Called when a cache lookup is successful.\n\n if (obj.ttl >= 0s) {\n # A pure unadultered hit, deliver it\n return (deliver);\n }\n\n # https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-grace.html\n # When several clients are requesting the same page Varnish will send one request to the backend and place the others on hold while fetching one copy from the backend. In some products this is called request coalescing and Varnish does this automatically.\n # If you are serving thousands of hits per second the queue of waiting requests can get huge. There are two potential problems - one is a thundering herd problem - suddenly releasing a thousand threads to serve content might send the load sky high. Secondly - nobody likes to wait. To deal with this we can instruct Varnish to keep the objects in cache beyond their TTL and to serve the waiting requests somewhat stale content.\n\n# if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n# return (deliver);\n# } else {\n# return (fetch);\n# }\n\n # We have no fresh fish. Lets look at the stale ones.\n if (std.healthy(req.backend_hint)) {\n # Backend is healthy. Limit age to 10s.\n if (obj.ttl + 10s > 0s) {\n #set req.http.grace = \"normal(limited)\";\n return (deliver);\n } else {\n # No candidate for grace. Fetch a fresh object.\n return(fetch);\n }\n } else {\n # backend is sick - use full grace\n if (obj.ttl + obj.grace > 0s) {\n #set req.http.grace = \"full\";\n return (deliver);\n } else {\n # no graced object.\n return (fetch);\n }\n }\n\n # fetch & deliver once we get the result\n return (fetch); # Dead code, keep as a safeguard\n}\n\nsub vcl_miss {\n # Called after a cache lookup if the requested document was not found in the cache. Its purpose\n # is to decide whether or not to attempt to retrieve the document from the backend, and which\n # backend to use.\n\n return (fetch);\n}\n\n# Handle the HTTP request coming from our backend\nsub vcl_backend_response {\n # Called after the response headers has been successfully retrieved from the backend.\n\n # Pause ESI request and remove Surrogate-Control header\n if (beresp.http.Surrogate-Control ~ \"ESI\/1.0\") {\n unset beresp.http.Surrogate-Control;\n set beresp.do_esi = true;\n }\n\n # Enable cache for all static files\n # The same argument as the static caches from above: monitor your cache size, if you get data nuked out of it, consider giving up the static file cache.\n # Before you blindly enable this, have a read here: https:\/\/ma.ttias.be\/stop-caching-static-files\/\n if (bereq.url ~ \"^[^?]*\\.(7z|avi|bmp|bz2|css|csv|doc|docx|eot|flac|flv|gif|gz|ico|jpeg|jpg|js|less|mka|mkv|mov|mp3|mp4|mpeg|mpg|odt|otf|ogg|ogm|opus|pdf|png|ppt|pptx|rar|rtf|svg|svgz|swf|tar|tbz|tgz|ttf|txt|txz|wav|webm|webp|woff|woff2|xls|xlsx|xml|xz|zip)(\\?.*)?$\") {\n unset beresp.http.set-cookie;\n }\n \n if (!(bereq.url ~ \"language_set.php\" || bereq.url ~ \"cesta.php\" || bereq.url ~ \"pictogramas_color.php\" || bereq.url ~ \"pictogramas_byn.php\"|| bereq.url ~ \"imagenes.php\" || bereq.url ~ \"videos_lse.php\" || bereq.url ~ \"signos_lse_color.php\" || bereq.url ~ \"buscar.php\" || bereq.url ~ \"n_elementos_cesto.php\" || bereq.url ~ \"herramientas\" || bereq.url ~ \"zip_cesto.php\" || bereq.url ~ \"carpeta_trabajo.php\" || bereq.url ~ \"admin.php\")) {\n set beresp.ttl = 86400s;\n set beresp.http.cache-control = \"public, max-age = 300\";\n #set beresp.http.log = \"ha entrado aqu\u00ed\";\n #set beresp.http.X-CacheReason = \"varnishcache\";\n unset beresp.http.set-cookie;\n return(deliver);\n }\n \n\n # Large static files are delivered directly to the end-user without\n # waiting for Varnish to fully read the file first.\n # Varnish 4 fully supports Streaming, so use streaming here to avoid locking.\n if (bereq.url ~ \"^[^?]*\\.(7z|avi|bz2|flac|flv|gz|mka|mkv|mov|mp3|mp4|mpeg|mpg|ogg|ogm|opus|rar|tar|tgz|tbz|txz|wav|webm|xz|zip)(\\?.*)?$\") {\n unset beresp.http.set-cookie;\n set beresp.do_stream = true; # Check memory usage it'll grow in fetch_chunksize blocks (128k by default) if the backend doesn't send a Content-Length header, so only enable it for big objects\n }\n\n # Sometimes, a 301 or 302 redirect formed via Apache's mod_rewrite can mess with the HTTP port that is being passed along.\n # This often happens with simple rewrite rules in a scenario where Varnish runs on :80 and Apache on :8080 on the same box.\n # A redirect can then often redirect the end-user to a URL on :8080, where it should be :80.\n # This may need finetuning on your setup.\n #\n # To prevent accidental replace, we only filter the 301\/302 redirects for now.\n if (beresp.status == 301 || beresp.status == 302) {\n set beresp.http.Location = regsub(beresp.http.Location, \":[0-9]+\", \"\");\n }\n\n # Set 2min cache if unset for static files\n if (beresp.ttl <= 0s || beresp.http.Set-Cookie || beresp.http.Vary == \"*\") {\n set beresp.ttl = 120s; # Important, you shouldn't rely on this, SET YOUR HEADERS in the backend\n set beresp.uncacheable = true;\n return (deliver);\n }\n\n # Don't cache 50x responses\n if (beresp.status == 500 || beresp.status == 502 || beresp.status == 503 || beresp.status == 504) {\n return (abandon);\n }\n\n # Allow stale content, in case the backend goes down.\n # make Varnish keep all objects for 6 hours beyond their TTL\n set beresp.grace = 6h;\n\n return (deliver);\n}\n\n# The routine when we deliver the HTTP request to the user\n# Last chance to modify headers that are sent to the client\nsub vcl_deliver {\n # Called before a cached object is delivered to the client.\n\n if (obj.hits > 0) { # Add debug header to see if it's a HIT\/MISS and the number of hits, disable when not needed\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n\n # Please note that obj.hits behaviour changed in 4.0, now it counts per objecthead, not per object\n # and obj.hits may not be reset in some cases where bans are in use. See bug 1492 for details.\n # So take hits with a grain of salt\n set resp.http.X-Cache-Hits = obj.hits;\n\n # Remove some headers: PHP version\n unset resp.http.X-Powered-By;\n\n # Remove some headers: Apache version & OS\n unset resp.http.Server;\n unset resp.http.X-Drupal-Cache;\n unset resp.http.X-Varnish;\n unset resp.http.Via;\n unset resp.http.Link;\n unset resp.http.X-Generator;\n\n return (deliver);\n}\n\nsub vcl_purge {\n # Only handle actual PURGE HTTP methods, everything else is discarded\n if (req.method != \"PURGE\") {\n # restart request\n set req.http.X-Purge = \"Yes\";\n return(restart);\n }\n}\n\nsub vcl_synth {\n if (resp.status == 720) {\n # We use this special error status 720 to force redirects with 301 (permanent) redirects\n # To use this, call the following from anywhere in vcl_recv: return (synth(720, \"http:\/\/host\/new.html\"));\n set resp.http.Location = resp.reason;\n set resp.status = 301;\n return (deliver);\n } elseif (resp.status == 721) {\n # And we use error status 721 to force redirects with a 302 (temporary) redirect\n # To use this, call the following from anywhere in vcl_recv: return (synth(720, \"http:\/\/host\/new.html\"));\n set resp.http.Location = resp.reason;\n set resp.status = 302;\n return (deliver);\n } elseif (resp.status == 750) {\n set resp.status = 301;\n set resp.http.Location = \"http:\/\/www.arasaac.org\" + req.url;\n return(deliver);\n }\n\n return (deliver);\n}\n\n\nsub vcl_fini {\n # Called when VCL is discarded only after all requests have exited the VCL.\n # Typically used to clean up VMODs.\n\n return (ok);\n}\n","old_contents":"vcl 4.0;\n# Based on: https:\/\/github.com\/mattiasgeniar\/varnish-4.0-configuration-templates\/blob\/master\/\nimport std;\nimport directors;\n\nbackend server1 { # Define one backend\n .host = \"{VARNISH_BACKEND_HOST}\";\n .port = \"{VARNISH_BACKEND_PORT}\";\n .max_connections = 300; # That's it\n\n .probe = {\n #.url = \"\/\"; # short easy way (GET \/)\n # We prefer to only do a HEAD \/\n .request =\n \"HEAD \/ HTTP\/1.1\"\n \"Host: arasaac\"\n \"Connection: close\"\n \"User-Agent: Varnish Health Probe\";\n\n .interval = 5s; # check the health of each backend every 5 seconds\n .timeout = 3s; # timing out after 1 second.\n .window = 5; # If 3 out of the last 5 polls succeeded the backend is considered healthy, otherwise it will be marked as sick\n .threshold = 3;\n }\n\n .first_byte_timeout = 3s; # How long to wait before we receive a first byte from our backend?\n .connect_timeout = 5s; # How long to wait for a backend connection?\n .between_bytes_timeout = 2s; # How long to wait between bytes received from our backend?\n}\n\n#acl purge {\n # ACL we'll use later to allow purges\n# \"localhost\";\n# \"127.0.0.1\";\n# \"::1\";\n#}\n\nsub vcl_init {\n # Called when VCL is loaded, before any requests pass through it.\n # Typically used to initialize VMODs.\n\n new vdir = directors.round_robin();\n vdir.add_backend(server1);\n # vdir.add_backend(server...);\n # vdir.add_backend(servern);\n}\n\nsub vcl_recv {\n set req.backend_hint = vdir.backend(); # send all traffic to the vdir director\n\n # Normalize the header, remove the port (in case you're testing this on various TCP ports)\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n # Remove the proxy header (see https:\/\/httpoxy.org\/#mitigate-varnish)\n unset req.http.proxy;\n\n\n if (req.http.host ~ \"^arasaac.org\" || req.http.host ~ \"arasaac.net\" || req.http.host ~ \"arasaac.es\" ) {\n return (synth (750, \"\"));\n }\n if (req.url~ \"^\/index.php\") {\n set req.url = regsub(req.url, \"index.php\", \"\");\n } \n\n # Allow purging\n if (req.method == \"PURGE\") {\n# if (!client.ip ~ purge) { # purge is the ACL defined at the begining\n # Not from an allowed IP? Then die with an error.\n# return (synth(405, \"This IP is not allowed to send PURGE requests.\"));\n# }\n # If you got this stage (and didn't error out above), purge the cached result\n return (purge);\n }\n if (req.method == \"BAN\")\n {\n \/\/ TODO: Add client validation as needed\n ban(\"obj.http.x-url ~ \" + req.url);\n return(synth(901, \"BAN Set for \" + req.url));\n }\n\n # Only deal with \"normal\" types\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"PATCH\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n # Implementing websocket support (https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html)\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n # Only cache GET or HEAD requests. This makes sure the POST requests are always passed.\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n\n set req.http.Cookie = regsuball(req.http.Cookie, \"has_js=[^;]+(; )?\", \"\");\n\n # Remove any Google Analytics based cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__utm.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"_ga=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"_gat=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmctr=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmcmd.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmccn.=[^;]+(; )?\", \"\");\n\n # Remove Arasaac Cookies for caching:\n if (!(req.url ~ \"cesta.php\" || req.url ~ \"pictogramas_color.php\" || req.url ~ \"pictogramas_byn.php\"|| req.url ~ \"imagenes.php\" || req.url ~ \"videos_lse.php\" || req.url ~ \"signos_lse_color.php\" \n || req.url ~ \"buscar.php\" || req.url ~ \"n_elementos_cesto.php\" || req.url ~ \"herramientas\" || req.url ~ \"zip_cesto.php\" || req.url ~ \"carpeta_trabajo.php\" || req.url ~ \"admin.php\")) {\n set req.http.Cookie = regsuball(req.http.Cookie, \"PHPSESSID=[^;]+(; )?\", \"\");\n }\n \n #unset req.http.cookie; \n # Remove DoubleClick offensive cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__gads=[^;]+(; )?\", \"\");\n\n # Remove the Quant Capital cookies (added by some plugin, all __qca)\n set req.http.Cookie = regsuball(req.http.Cookie, \"__qc.=[^;]+(; )?\", \"\");\n\n # Remove the AddThis cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__atuv.=[^;]+(; )?\", \"\");\n\n # Remove a \";\" prefix in the cookie if present\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n\n # Are there cookies left with only spaces or that are empty?\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n\n # Remove all cookies for static files\n # A valid discussion could be held on this line: do you really need to cache static files that don't cause load? Only if you have memory left.\n # Sure, there's disk I\/O, but chances are your OS will already have these files in their buffers (thus memory).\n # Before you blindly enable this, have a read here: https:\/\/ma.ttias.be\/stop-caching-static-files\/\n if (req.url ~ \"^[^?]*\\.(7z|avi|bmp|bz2|css|csv|doc|docx|eot|flac|flv|gif|gz|ico|jpeg|jpg|js|less|mka|mkv|mov|mp3|mp4|mpeg|mpg|odt|otf|ogg|ogm|opus|pdf|png|ppt|pptx|rar|rtf|svg|svgz|swf|tar|tbz|tgz|ttf|txt|txz|wav|webm|webp|woff|woff2|xls|xlsx|xml|xz|zip)(\\?.*)?$\") {\n unset req.http.Cookie;\n return (hash);\n }\n\n return (hash);\n}\n\nsub vcl_pipe {\n # Called upon entering pipe mode.\n # In this mode, the request is passed on to the backend, and any further data from both the client\n # and backend is passed on unaltered until either end closes the connection. Basically, Varnish will\n # degrade into a simple TCP proxy, shuffling bytes back and forth. For a connection in pipe mode,\n # no other VCL subroutine will ever get called after vcl_pipe.\n\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n # set bereq.http.connection = \"close\";\n # here. It is not set by default as it might break some broken web\n # applications, like IIS with NTLM authentication.\n\n # set bereq.http.Connection = \"Close\";\n\n # Implementing websocket support (https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html)\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n\n return (pipe);\n}\n\nsub vcl_pass {\n # Called upon entering pass mode. In this mode, the request is passed on to the backend, and the\n # backend's response is passed on to the client, but is not entered into the cache. Subsequent\n # requests submitted over the same client connection are handled normally.\n\n # return (pass);\n}\n\n# The data on which the hashing will take place\nsub vcl_hash {\n # Called after vcl_recv to create a hash value for the request. This is used as a key\n # to look up the object in Varnish.\n\n hash_data(req.url);\n\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n\n # hash cookies for requests that have them\n# if (req.http.Language) {\n #add cookie in hash\n# hash_data(req.http.Language);\n# }\n if (req.http.Cookie) {\n hash_data(req.http.Cookie);\n }\n}\n\nsub vcl_hit {\n # Called when a cache lookup is successful.\n\n if (obj.ttl >= 0s) {\n # A pure unadultered hit, deliver it\n return (deliver);\n }\n\n # https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-grace.html\n # When several clients are requesting the same page Varnish will send one request to the backend and place the others on hold while fetching one copy from the backend. In some products this is called request coalescing and Varnish does this automatically.\n # If you are serving thousands of hits per second the queue of waiting requests can get huge. There are two potential problems - one is a thundering herd problem - suddenly releasing a thousand threads to serve content might send the load sky high. Secondly - nobody likes to wait. To deal with this we can instruct Varnish to keep the objects in cache beyond their TTL and to serve the waiting requests somewhat stale content.\n\n# if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n# return (deliver);\n# } else {\n# return (fetch);\n# }\n\n # We have no fresh fish. Lets look at the stale ones.\n if (std.healthy(req.backend_hint)) {\n # Backend is healthy. Limit age to 10s.\n if (obj.ttl + 10s > 0s) {\n #set req.http.grace = \"normal(limited)\";\n return (deliver);\n } else {\n # No candidate for grace. Fetch a fresh object.\n return(fetch);\n }\n } else {\n # backend is sick - use full grace\n if (obj.ttl + obj.grace > 0s) {\n #set req.http.grace = \"full\";\n return (deliver);\n } else {\n # no graced object.\n return (fetch);\n }\n }\n\n # fetch & deliver once we get the result\n return (fetch); # Dead code, keep as a safeguard\n}\n\nsub vcl_miss {\n # Called after a cache lookup if the requested document was not found in the cache. Its purpose\n # is to decide whether or not to attempt to retrieve the document from the backend, and which\n # backend to use.\n\n return (fetch);\n}\n\n# Handle the HTTP request coming from our backend\nsub vcl_backend_response {\n # Called after the response headers has been successfully retrieved from the backend.\n\n # Pause ESI request and remove Surrogate-Control header\n if (beresp.http.Surrogate-Control ~ \"ESI\/1.0\") {\n unset beresp.http.Surrogate-Control;\n set beresp.do_esi = true;\n }\n\n # Enable cache for all static files\n # The same argument as the static caches from above: monitor your cache size, if you get data nuked out of it, consider giving up the static file cache.\n # Before you blindly enable this, have a read here: https:\/\/ma.ttias.be\/stop-caching-static-files\/\n if (bereq.url ~ \"^[^?]*\\.(7z|avi|bmp|bz2|css|csv|doc|docx|eot|flac|flv|gif|gz|ico|jpeg|jpg|js|less|mka|mkv|mov|mp3|mp4|mpeg|mpg|odt|otf|ogg|ogm|opus|pdf|png|ppt|pptx|rar|rtf|svg|svgz|swf|tar|tbz|tgz|ttf|txt|txz|wav|webm|webp|woff|woff2|xls|xlsx|xml|xz|zip)(\\?.*)?$\") {\n unset beresp.http.set-cookie;\n }\n \n if (!(bereq.url ~ \"language_set.php\" || bereq.url ~ \"cesta.php\" || bereq.url ~ \"pictogramas_color.php\" || bereq.url ~ \"pictogramas_byn.php\"|| bereq.url ~ \"imagenes.php\" || bereq.url ~ \"videos_lse.php\" || bereq.url ~ \"signos_lse_color.php\" || bereq.url ~ \"buscar.php\" || bereq.url ~ \"n_elementos_cesto.php\" || bereq.url ~ \"herramientas\" || bereq.url ~ \"zip_cesto.php\" || bereq.url ~ \"carpeta_trabajo.php\" || bereq.url ~ \"admin.php\")) {\n set beresp.ttl = 86400s;\n set beresp.http.cache-control = \"public, max-age = 300\";\n #set beresp.http.log = \"ha entrado aqu\u00ed\";\n #set beresp.http.X-CacheReason = \"varnishcache\";\n unset beresp.http.set-cookie;\n return(deliver);\n }\n \n\n # Large static files are delivered directly to the end-user without\n # waiting for Varnish to fully read the file first.\n # Varnish 4 fully supports Streaming, so use streaming here to avoid locking.\n if (bereq.url ~ \"^[^?]*\\.(7z|avi|bz2|flac|flv|gz|mka|mkv|mov|mp3|mp4|mpeg|mpg|ogg|ogm|opus|rar|tar|tgz|tbz|txz|wav|webm|xz|zip)(\\?.*)?$\") {\n unset beresp.http.set-cookie;\n set beresp.do_stream = true; # Check memory usage it'll grow in fetch_chunksize blocks (128k by default) if the backend doesn't send a Content-Length header, so only enable it for big objects\n }\n\n # Sometimes, a 301 or 302 redirect formed via Apache's mod_rewrite can mess with the HTTP port that is being passed along.\n # This often happens with simple rewrite rules in a scenario where Varnish runs on :80 and Apache on :8080 on the same box.\n # A redirect can then often redirect the end-user to a URL on :8080, where it should be :80.\n # This may need finetuning on your setup.\n #\n # To prevent accidental replace, we only filter the 301\/302 redirects for now.\n if (beresp.status == 301 || beresp.status == 302) {\n set beresp.http.Location = regsub(beresp.http.Location, \":[0-9]+\", \"\");\n }\n\n # Set 2min cache if unset for static files\n if (beresp.ttl <= 0s || beresp.http.Set-Cookie || beresp.http.Vary == \"*\") {\n set beresp.ttl = 120s; # Important, you shouldn't rely on this, SET YOUR HEADERS in the backend\n set beresp.uncacheable = true;\n return (deliver);\n }\n\n # Don't cache 50x responses\n if (beresp.status == 500 || beresp.status == 502 || beresp.status == 503 || beresp.status == 504) {\n return (abandon);\n }\n\n # Allow stale content, in case the backend goes down.\n # make Varnish keep all objects for 6 hours beyond their TTL\n set beresp.grace = 6h;\n\n return (deliver);\n}\n\n# The routine when we deliver the HTTP request to the user\n# Last chance to modify headers that are sent to the client\nsub vcl_deliver {\n # Called before a cached object is delivered to the client.\n\n if (obj.hits > 0) { # Add debug header to see if it's a HIT\/MISS and the number of hits, disable when not needed\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n\n # Please note that obj.hits behaviour changed in 4.0, now it counts per objecthead, not per object\n # and obj.hits may not be reset in some cases where bans are in use. See bug 1492 for details.\n # So take hits with a grain of salt\n set resp.http.X-Cache-Hits = obj.hits;\n\n # Remove some headers: PHP version\n unset resp.http.X-Powered-By;\n\n # Remove some headers: Apache version & OS\n unset resp.http.Server;\n unset resp.http.X-Drupal-Cache;\n unset resp.http.X-Varnish;\n unset resp.http.Via;\n unset resp.http.Link;\n unset resp.http.X-Generator;\n\n return (deliver);\n}\n\nsub vcl_purge {\n # Only handle actual PURGE HTTP methods, everything else is discarded\n if (req.method != \"PURGE\") {\n # restart request\n set req.http.X-Purge = \"Yes\";\n return(restart);\n }\n}\n\nsub vcl_synth {\n if (resp.status == 720) {\n # We use this special error status 720 to force redirects with 301 (permanent) redirects\n # To use this, call the following from anywhere in vcl_recv: return (synth(720, \"http:\/\/host\/new.html\"));\n set resp.http.Location = resp.reason;\n set resp.status = 301;\n return (deliver);\n } elseif (resp.status == 721) {\n # And we use error status 721 to force redirects with a 302 (temporary) redirect\n # To use this, call the following from anywhere in vcl_recv: return (synth(720, \"http:\/\/host\/new.html\"));\n set resp.http.Location = resp.reason;\n set resp.status = 302;\n return (deliver);\n } elseif (resp.status == 750) {\n set resp.status = 301;\n set resp.http.Location = \"http:\/\/www.arasaac.org\" + req.url;\n return(deliver);\n }\n\n return (deliver);\n}\n\n\nsub vcl_fini {\n # Called when VCL is discarded only after all requests have exited the VCL.\n # Typically used to clean up VMODs.\n\n return (ok);\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"41ba309de6c4bd6ac4b4a54a6435b035bda30f1f","subject":"fix varnish esi on https","message":"fix varnish esi on https\n","repos":"KhanovaSkola\/khanovaskola-v3,KhanovaSkola\/khanovaskola-v3,KhanovaSkola\/khanovaskola-v3,KhanovaSkola\/khanovaskola-v3,KhanovaSkola\/khanovaskola-v3,KhanovaSkola\/khanovaskola-v3","old_file":"production\/varnish.vcl","new_file":"production\/varnish.vcl","new_contents":"vcl 4.0;\n\n# Disable esi xml check on varnish Startup\n# Example:\n# DAEMON_OPTS=\"-a :6081 \\\n# -T localhost:6082 \\\n# -p feature=+esi_disable_xml_check\n# -p feature=+esi_ignore_https\n#\n\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8085\";\n}\n\nsub vcl_recv {\n if (req.method != \"GET\") {\n return (pass);\n }\n\n unset req.http.cookie;\n return (hash);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.url ~ \"\/esi\/header\/user($|\\?)\")\n {\n hash_data(regsub(req.http.cookie, \".*PHPSESSID=([^;]+);.*\", \"\\1\"));\n }\n return(lookup);\n}\n\nsub vcl_backend_response {\n set beresp.do_esi = true;\n set beresp.ttl = 15m;\n\n unset beresp.http.Set-Cookie;\n unset beresp.http.Cache-Control;\n\n set beresp.http.Cache-Control = \"public\";\n}\n","old_contents":"vcl 4.0;\n\n# Disable esi xml check on varnish Startup\n# Example:\n# DAEMON_OPTS=\"-a :6081 \\\n# -T localhost:6082 \\\n# -p feature=+esi_disable_xml_check\n#\n\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8085\";\n}\n\nsub vcl_recv {\n if (req.method != \"GET\") {\n return (pass);\n }\n\n unset req.http.cookie;\n return (hash);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.url ~ \"\/esi\/header\/user($|\\?)\")\n {\n hash_data(regsub(req.http.cookie, \".*PHPSESSID=([^;]+);.*\", \"\\1\"));\n }\n return(lookup);\n}\n\nsub vcl_backend_response {\n set beresp.do_esi = true;\n set beresp.ttl = 15m;\n\n unset beresp.http.Set-Cookie;\n unset beresp.http.Cache-Control;\n\n set beresp.http.Cache-Control = \"public\";\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"2b9065d2f4b03cb779e1dbbe57d901a5165a3ff2","subject":"If the origin is offline, serve stale responses if they exist","message":"If the origin is offline, serve stale responses if they exist","repos":"JakeChampion\/polyfill-service,JakeChampion\/polyfill-service","old_file":"fastly\/vcl\/polyfill-service.vcl","new_file":"fastly\/vcl\/polyfill-service.vcl","new_contents":"sub set_backend {\n\t# The Fastly macro is inserted before the backend is selected because the\n\t# macro has the code which defines the values avaiable for req.http.Host\n\t# but it also contains a default backend which is always set to the EU. I wish we could disable the default backend setting.\n\t#FASTLY recv\n\t\n\t# Calculate the ideal region to route the request to.\n \tdeclare local var.region STRING; \n\tif (server.region ~ \"(APAC|Asia|North-America|South-America|US-Central|US-East|US-West)\") {\n\t\tset var.region = \"US\";\n \t} else {\n\t\tset var.region = \"EU\";\n \t}\n\n\t# Gather the health of the shields and origins.\n\tdeclare local var.v3_eu_is_healthy BOOL;\n\tset req.backend = F_v3_eu;\n\tset var.v3_eu_is_healthy = req.backend.healthy;\n\n\tdeclare local var.v3_us_is_healthy BOOL;\n \tset req.backend = F_v3_us;\n \tset var.v3_us_is_healthy = req.backend.healthy;\n\n \tdeclare local var.shield_eu_is_healthy BOOL;\n \tset req.backend = ssl_shield_london_city_uk;\n \tset var.shield_eu_is_healthy = req.backend.healthy;\n\n \tdeclare local var.shield_us_is_healthy BOOL;\n \tset req.backend = ssl_shield_dca_dc_us;\n \tset var.shield_us_is_healthy = req.backend.healthy;\n\n \t# Set some sort of default, that shouldn't get used.\n \tset req.backend = F_v3_eu;\n\n\tdeclare local var.EU_shield_server_name STRING;\n\tset var.EU_shield_server_name = \"LCY\";\n\n\tdeclare local var.US_shield_server_name STRING;\n\tset var.US_shield_server_name = \"DCA\";\n\n\t# Route EU requests to the nearest healthy shield or origin.\n \tif (var.region == \"EU\") {\n\t\tif (server.datacenter != var.EU_shield_server_name && fastly.ff.visits_this_service == 0 && req.restarts == 0 && var.shield_eu_is_healthy) {\n\t\t\tset req.backend = ssl_shield_london_city_uk;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} elseif (var.shield_us_is_healthy) {\n\t\t\tset req.backend = ssl_shield_dca_dc_us;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_eu;\n\t\t}\n \t}\n\n\t# Route US requests to the nearest healthy shield or origin.\n \tif (var.region == \"US\") {\n\t\tif (server.datacenter != var.US_shield_server_name && fastly.ff.visits_this_service == 0 && req.restarts == 0 && var.shield_us_is_healthy) {\n\t\t\tset req.backend = ssl_shield_dca_dc_us;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} elseif (var.shield_eu_is_healthy) {\n\t\t\tset req.backend = ssl_shield_london_city_uk;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_us;\n\t\t}\n\t}\n\n\t# Persist the decision so we can debug the result.\n \tset req.http.Debug-Backend = req.backend;\n}\n\nsub vcl_recv {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_recv;\n\t}\n\n\tif (req.method != \"GET\" && req.method != \"HEAD\" && req.method != \"OPTIONS\" && req.method != \"FASTLYPURGE\" && req.method != \"PURGE\") {\n\t\terror 911;\n\t}\n\n\tif (req.method == \"OPTIONS\") {\n\t\terror 912;\n\t}\n\n\t# Because the old service had a router which allowed any words between \/v2\/polyfill. and .js\n\tif (req.url.path ~ \"^\/v2\/polyfill(\\.\\w+)(\\.\\w+)?\" && req.url.ext == \"js\") {\n\t\tif (re.group.2) {\n\t\t\tset req.url = \"\/v2\/polyfill.min.js?\" req.url.qs;\n\t\t} else {\n\t\t\tset req.url = \"\/v2\/polyfill.js?\" req.url.qs;\n\t\t}\n\t}\n\n\t# Override the v3 defaults with the defaults of v2\n\tif (req.url ~ \"^\/v2\/polyfill(\\.min)?\\.js\") {\n\t\tset req.url = regsub(req.url, \"^\/v2\", \"\/v3\");\n\t\tset req.url = querystring.set(req.url, \"version\", \"3.25.1\");\n\t\tdeclare local var.unknown STRING;\n\t\tset var.unknown = subfield(req.url.qs, \"unknown\", \"&\");\n\t\tset req.url = querystring.set(req.url, \"unknown\", if(var.unknown != \"\", var.unknown, \"ignore\"));\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\") {\n\t\tcall normalise_querystring_parameters_for_polyfill_bundle;\n\t\t# Sort the querystring parameters alphabetically to improve chances of hitting a cached copy.\n\t\t# If querystring is empty, remove the ? from the url.\n\t\tset req.url = querystring.clean(querystring.sort(req.url));\n\t\tcall set_backend;\n\t} else {\n\t\t# The request is to an endpoint which doesn't use query parameters, let's remove them to increase our cache-hit-ratio\n\t\tset req.url = querystring.remove(req.url);\n\t\tcall set_backend;\n\t}\n\t\n\tif (req.backend == ssl_shield_dca_dc_us || req.backend == ssl_shield_london_city_uk) {\n\t\t# avoid passing stale content from Shield POP to Edge POP\n\t\tset req.max_stale_while_revalidate = 0s;\n\t} else {\n\t\tset req.http.referer_domain = if(req.http.referer ~ \"^https?\\:\\\/\\\/([^\\\/:?#]+)(?:[\\\/:?#]|$)\", re.group.1, \"\");\n\t}\n}\n\nsub vcl_hash {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_hash;\n\t}\n\n\t# We are not adding req.http.host to the hash because we want https:\/\/cdn.polyfill.io and https:\/\/polyfill.io to be a single object in the cache.\n\t# set req.hash += req.http.host;\n\tset req.hash += req.url;\n\t# We include return(hash) to stop the function falling through to the default VCL built into varnish, which for vcl_hash will add req.url and req.http.Host to the hash.\n\treturn(hash);\n}\n\nsub vcl_miss {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_miss;\n\t}\n}\n\nsub vcl_pass {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_pass;\n\t}\n}\n\nsub vcl_fetch {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_fetch;\n\t}\n\n\t# These header are only required for HTML documents.\n\tif (beresp.http.Content-Type ~ \"text\/html\") {\n\t\t# Enables the cross-site scripting filter built into most modern web browsers.\n\t\tset beresp.http.X-XSS-Protection = \"1; mode=block\";\t\n\t}\n\t# Prevents MIME-sniffing a response away from the declared content type.\n\tset beresp.http.X-Content-Type-Options = \"nosniff\";\n\n\t# Ensure the site is only served over HTTPS and reduce the chances of someone performing a MITM attack.\n\tset beresp.http.Strict-Transport-Security = \"max-age=31536000; includeSubdomains; preload\";\n\n\t# The Referrer-Policy header governs which referrer information, sent in the Referer header, should be included with requests made.\n\t# Send a full URL when performing a same-origin request, but only send the origin of the document for other cases.\n\tset beresp.http.Referrer-Policy = \"origin-when-cross-origin\";\n\n\t# Enable purging of all objects in the Fastly cache by issuing a purge with the key \"polyfill-service\".\n\tif (beresp.http.Surrogate-Key !~ \"\\bpolyfill-service\\b\") {\n\t\tset beresp.http.Surrogate-Key = if(beresp.http.Surrogate-Key, beresp.http.Surrogate-Key \" polyfill-service\", \"polyfill-service\");\n\t}\n\n\tset beresp.http.Timing-Allow-Origin = \"*\";\n\n\tif (req.http.Normalized-User-Agent) {\n\t\tset beresp.http.Normalized-User-Agent = req.http.Normalized-User-Agent;\n\t\tset beresp.http.Detected-User-Agent = req.http.useragent_parser_family \"\/\" req.http.useragent_parser_major \".\" req.http.useragent_parser_minor \".\" req.http.useragent_parser_patch;\n\t}\n\t\n\t# We end up here if\n\t# - The origin is HEALTHY; and\n\t# - It returned a valid HTTP response\n\t#\n\t# We may still not want to *use* that response, if it's an HTTP error,\n\t# so that's the case we need to catch here.\n\tif (beresp.status >= 500 && beresp.status < 600) {\n\t\t# There's a stale version available! Serve it.\n\t\tif (stale.exists) {\n\t\t\treturn(deliver_stale);\n\t\t}\n\t\t# Cache the error for 1s to allow it to be used for any collapsed requests\n\t\tset beresp.cacheable = true;\n\t\tset beresp.ttl = 1s;\n\t\treturn(deliver);\n\t}\n\t# If the response is not an error, but it is stale content that's being\n\t# served from a cache upstream, cache it for a very brief period to\n\t# clear the request queue.\n\tif (beresp.status == 200 && beresp.http.x-resp-is-stale) {\n\t\tset beresp.ttl = 1s;\n\t\tset beresp.stale_while_revalidate = 0s;\n\t\tset beresp.stale_if_error = 0s;\n\t\treturn (deliver);\n\t}\n}\n\nsub vcl_deliver {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_deliver;\n\t}\n\tif (fastly_info.state ~ \"STALE\") {\n\t\tset resp.http.x-resp-is-stale = \"true\";\n\t}\n\n\tset req.http.Fastly-Force-Shield = \"yes\";\n\n\t# Allow cross origin GET, HEAD, and OPTIONS requests to be made.\n\tif (req.http.Origin) {\n\t\tset resp.http.Access-Control-Allow-Origin = \"*\";\n\t\tset resp.http.Access-Control-Allow-Methods = \"GET,HEAD,OPTIONS\";\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\" && fastly.ff.visits_this_service == 0) {\n\t\t# Need to add \"Vary: User-Agent\" in after vcl_fetch to avoid the\n\t\t# \"Vary: User-Agent\" entering the Varnish cache.\n\t\t# We need \"Vary: User-Agent\" in the browser cache because a browser\n\t\t# may update itself to a version which needs different polyfills\n\t\t# So we need to have it ignore the browser cached bundle when the user-agent changes.\n\t\tset resp.http.Vary = \"User-Agent, Accept-Encoding\";\n\t}\n\n\tif (resp.status == 304) {\n\t\tset resp.http.Age = \"0\";\n\t}\n\n\tadd resp.http.Server-Timing = fastly_info.state {\", fastly;desc=\"Edge time\";dur=\"} time.elapsed.msec;\n\n\tif (req.http.Fastly-Debug) {\n\t\tset resp.http.Debug-Backend = req.http.Debug-Backend;\n\t\tset resp.http.Debug-Host = req.http.Host;\n\t\tset resp.http.Debug-Fastly-Restarts = req.restarts;\n\t\tset resp.http.Debug-Orig-URL = req.http.Orig-URL;\n\t\tset resp.http.Debug-VCL-Route = req.http.X-VCL-Route;\n\t\tset resp.http.useragent_parser_family = req.http.useragent_parser_family;\n\t\tset resp.http.useragent_parser_major = req.http.useragent_parser_major;\n\t\tset resp.http.useragent_parser_minor = req.http.useragent_parser_minor;\n\t\tset resp.http.useragent_parser_patch = req.http.useragent_parser_patch;\n\t} else {\n\t\tunset resp.http.Server;\n\t\tunset resp.http.Via;\n\t\tunset resp.http.X-Cache;\n\t\tunset resp.http.X-Cache-Hits;\n\t\tunset resp.http.X-Served-By;\n\t\tunset resp.http.X-Timer;\n\t\tunset resp.http.Fastly-Restarts;\n\t\tunset resp.http.X-PreFetch-Pass;\n\t\tunset resp.http.X-PreFetch-Miss;\n\t\tunset resp.http.X-PostFetch;\n\t}\n}\n\nsub vcl_error {\n\tif (obj.status >= 500 && obj.status < 600) {\n\t\tif (stale.exists) {\n\t\t\treturn(deliver_stale);\n\t\t}\n\t\treturn(deliver);\n\t}\n\tif (obj.status == 911) {\n\t\tset obj.status = 405;\n\t\tset obj.response = \"METHOD NOT ALLOWED\";\n\t\tset obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n\t\tset obj.http.Cache-Control = \"private, no-store\";\n\t\tsynthetic req.method \" METHOD NOT ALLOWED\";\n\t\treturn (deliver);\n\t}\n\tif (obj.status == 912) {\n\t\tset obj.status = 200;\n\t\tset obj.response = \"OK\";\n\t\tset obj.http.Allow = \"OPTIONS, GET, HEAD\";\n\t\treturn (deliver);\n\t}\n}\n","old_contents":"sub set_backend {\n\t# The Fastly macro is inserted before the backend is selected because the\n\t# macro has the code which defines the values avaiable for req.http.Host\n\t# but it also contains a default backend which is always set to the EU. I wish we could disable the default backend setting.\n\t#FASTLY recv\n\t\n\t# Calculate the ideal region to route the request to.\n \tdeclare local var.region STRING; \n\tif (server.region ~ \"(APAC|Asia|North-America|South-America|US-Central|US-East|US-West)\") {\n\t\tset var.region = \"US\";\n \t} else {\n\t\tset var.region = \"EU\";\n \t}\n\n\t# Gather the health of the shields and origins.\n\tdeclare local var.v3_eu_is_healthy BOOL;\n\tset req.backend = F_v3_eu;\n\tset var.v3_eu_is_healthy = req.backend.healthy;\n\n\tdeclare local var.v3_us_is_healthy BOOL;\n \tset req.backend = F_v3_us;\n \tset var.v3_us_is_healthy = req.backend.healthy;\n\n \tdeclare local var.shield_eu_is_healthy BOOL;\n \tset req.backend = ssl_shield_london_city_uk;\n \tset var.shield_eu_is_healthy = req.backend.healthy;\n\n \tdeclare local var.shield_us_is_healthy BOOL;\n \tset req.backend = ssl_shield_dca_dc_us;\n \tset var.shield_us_is_healthy = req.backend.healthy;\n\n \t# Set some sort of default, that shouldn't get used.\n \tset req.backend = F_v3_eu;\n\n\tdeclare local var.EU_shield_server_name STRING;\n\tset var.EU_shield_server_name = \"LCY\";\n\n\tdeclare local var.US_shield_server_name STRING;\n\tset var.US_shield_server_name = \"DCA\";\n\n\t# Route EU requests to the nearest healthy shield or origin.\n \tif (var.region == \"EU\") {\n\t\tif (server.datacenter != var.EU_shield_server_name && fastly.ff.visits_this_service == 0 && req.restarts == 0 && var.shield_eu_is_healthy) {\n\t\t\tset req.backend = ssl_shield_london_city_uk;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} elseif (var.shield_us_is_healthy) {\n\t\t\tset req.backend = ssl_shield_dca_dc_us;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_eu;\n\t\t}\n \t}\n\n\t# Route US requests to the nearest healthy shield or origin.\n \tif (var.region == \"US\") {\n\t\tif (server.datacenter != var.US_shield_server_name && fastly.ff.visits_this_service == 0 && req.restarts == 0 && var.shield_us_is_healthy) {\n\t\t\tset req.backend = ssl_shield_dca_dc_us;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} elseif (var.shield_eu_is_healthy) {\n\t\t\tset req.backend = ssl_shield_london_city_uk;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_us;\n\t\t}\n\t}\n\n\t# Persist the decision so we can debug the result.\n \tset req.http.Debug-Backend = req.backend;\n}\n\nsub vcl_recv {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_recv;\n\t}\n\n\tif (req.method != \"GET\" && req.method != \"HEAD\" && req.method != \"OPTIONS\" && req.method != \"FASTLYPURGE\" && req.method != \"PURGE\") {\n\t\terror 911;\n\t}\n\n\tif (req.method == \"OPTIONS\") {\n\t\terror 912;\n\t}\n\n\t# Because the old service had a router which allowed any words between \/v2\/polyfill. and .js\n\tif (req.url.path ~ \"^\/v2\/polyfill(\\.\\w+)(\\.\\w+)?\" && req.url.ext == \"js\") {\n\t\tif (re.group.2) {\n\t\t\tset req.url = \"\/v2\/polyfill.min.js?\" req.url.qs;\n\t\t} else {\n\t\t\tset req.url = \"\/v2\/polyfill.js?\" req.url.qs;\n\t\t}\n\t}\n\n\t# Override the v3 defaults with the defaults of v2\n\tif (req.url ~ \"^\/v2\/polyfill(\\.min)?\\.js\") {\n\t\tset req.url = regsub(req.url, \"^\/v2\", \"\/v3\");\n\t\tset req.url = querystring.set(req.url, \"version\", \"3.25.1\");\n\t\tdeclare local var.unknown STRING;\n\t\tset var.unknown = subfield(req.url.qs, \"unknown\", \"&\");\n\t\tset req.url = querystring.set(req.url, \"unknown\", if(var.unknown != \"\", var.unknown, \"ignore\"));\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\") {\n\t\tcall normalise_querystring_parameters_for_polyfill_bundle;\n\t\t# Sort the querystring parameters alphabetically to improve chances of hitting a cached copy.\n\t\t# If querystring is empty, remove the ? from the url.\n\t\tset req.url = querystring.clean(querystring.sort(req.url));\n\t\tcall set_backend;\n\t} else {\n\t\t# The request is to an endpoint which doesn't use query parameters, let's remove them to increase our cache-hit-ratio\n\t\tset req.url = querystring.remove(req.url);\n\t\tcall set_backend;\n\t}\n\t\n\tif (req.backend == ssl_shield_dca_dc_us || req.backend == ssl_shield_london_city_uk) {\n\t\t# avoid passing stale content from Shield POP to Edge POP\n\t\tset req.max_stale_while_revalidate = 0s;\n\t} else {\n\t\tset req.http.referer_domain = if(req.http.referer ~ \"^https?\\:\\\/\\\/([^\\\/:?#]+)(?:[\\\/:?#]|$)\", re.group.1, \"\");\n\t}\n}\n\nsub vcl_hash {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_hash;\n\t}\n\n\t# We are not adding req.http.host to the hash because we want https:\/\/cdn.polyfill.io and https:\/\/polyfill.io to be a single object in the cache.\n\t# set req.hash += req.http.host;\n\tset req.hash += req.url;\n\t# We include return(hash) to stop the function falling through to the default VCL built into varnish, which for vcl_hash will add req.url and req.http.Host to the hash.\n\treturn(hash);\n}\n\nsub vcl_miss {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_miss;\n\t}\n}\n\nsub vcl_pass {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_pass;\n\t}\n}\n\nsub vcl_fetch {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_fetch;\n\t}\n\n\t# These header are only required for HTML documents.\n\tif (beresp.http.Content-Type ~ \"text\/html\") {\n\t\t# Enables the cross-site scripting filter built into most modern web browsers.\n\t\tset beresp.http.X-XSS-Protection = \"1; mode=block\";\t\n\t}\n\t# Prevents MIME-sniffing a response away from the declared content type.\n\tset beresp.http.X-Content-Type-Options = \"nosniff\";\n\n\t# Ensure the site is only served over HTTPS and reduce the chances of someone performing a MITM attack.\n\tset beresp.http.Strict-Transport-Security = \"max-age=31536000; includeSubdomains; preload\";\n\n\t# The Referrer-Policy header governs which referrer information, sent in the Referer header, should be included with requests made.\n\t# Send a full URL when performing a same-origin request, but only send the origin of the document for other cases.\n\tset beresp.http.Referrer-Policy = \"origin-when-cross-origin\";\n\n\t# Enable purging of all objects in the Fastly cache by issuing a purge with the key \"polyfill-service\".\n\tif (beresp.http.Surrogate-Key !~ \"\\bpolyfill-service\\b\") {\n\t\tset beresp.http.Surrogate-Key = if(beresp.http.Surrogate-Key, beresp.http.Surrogate-Key \" polyfill-service\", \"polyfill-service\");\n\t}\n\n\tset beresp.http.Timing-Allow-Origin = \"*\";\n\n\tif (req.http.Normalized-User-Agent) {\n\t\tset beresp.http.Normalized-User-Agent = req.http.Normalized-User-Agent;\n\t\tset beresp.http.Detected-User-Agent = req.http.useragent_parser_family \"\/\" req.http.useragent_parser_major \".\" req.http.useragent_parser_minor \".\" req.http.useragent_parser_patch;\n\t}\n}\n\nsub vcl_deliver {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_deliver;\n\t}\n\n\tset req.http.Fastly-Force-Shield = \"yes\";\n\n\t# Allow cross origin GET, HEAD, and OPTIONS requests to be made.\n\tif (req.http.Origin) {\n\t\tset resp.http.Access-Control-Allow-Origin = \"*\";\n\t\tset resp.http.Access-Control-Allow-Methods = \"GET,HEAD,OPTIONS\";\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\" && fastly.ff.visits_this_service == 0) {\n\t\t# Need to add \"Vary: User-Agent\" in after vcl_fetch to avoid the\n\t\t# \"Vary: User-Agent\" entering the Varnish cache.\n\t\t# We need \"Vary: User-Agent\" in the browser cache because a browser\n\t\t# may update itself to a version which needs different polyfills\n\t\t# So we need to have it ignore the browser cached bundle when the user-agent changes.\n\t\tset resp.http.Vary = \"User-Agent, Accept-Encoding\";\n\t}\n\n\tif (resp.status == 304) {\n\t\tset resp.http.Age = \"0\";\n\t}\n\n\tadd resp.http.Server-Timing = fastly_info.state {\", fastly;desc=\"Edge time\";dur=\"} time.elapsed.msec;\n\n\tif (req.http.Fastly-Debug) {\n\t\tset resp.http.Debug-Backend = req.http.Debug-Backend;\n\t\tset resp.http.Debug-Host = req.http.Host;\n\t\tset resp.http.Debug-Fastly-Restarts = req.restarts;\n\t\tset resp.http.Debug-Orig-URL = req.http.Orig-URL;\n\t\tset resp.http.Debug-VCL-Route = req.http.X-VCL-Route;\n\t\tset resp.http.useragent_parser_family = req.http.useragent_parser_family;\n\t\tset resp.http.useragent_parser_major = req.http.useragent_parser_major;\n\t\tset resp.http.useragent_parser_minor = req.http.useragent_parser_minor;\n\t\tset resp.http.useragent_parser_patch = req.http.useragent_parser_patch;\n\t} else {\n\t\tunset resp.http.Server;\n\t\tunset resp.http.Via;\n\t\tunset resp.http.X-Cache;\n\t\tunset resp.http.X-Cache-Hits;\n\t\tunset resp.http.X-Served-By;\n\t\tunset resp.http.X-Timer;\n\t\tunset resp.http.Fastly-Restarts;\n\t\tunset resp.http.X-PreFetch-Pass;\n\t\tunset resp.http.X-PreFetch-Miss;\n\t\tunset resp.http.X-PostFetch;\n\t}\n}\n\nsub vcl_error {\n\tif (obj.status == 911) {\n\t\tset obj.status = 405;\n\t\tset obj.response = \"METHOD NOT ALLOWED\";\n\t\tset obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n\t\tset obj.http.Cache-Control = \"private, no-store\";\n\t\tsynthetic req.method \" METHOD NOT ALLOWED\";\n\t\treturn (deliver);\n\t}\n\tif (obj.status == 912) {\n\t\tset obj.status = 200;\n\t\tset obj.response = \"OK\";\n\t\tset obj.http.Allow = \"OPTIONS, GET, HEAD\";\n\t\treturn (deliver);\n\t}\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"53b59718eb694aa6c6048ead4791bcbe05a05d66","subject":"fix backend name","message":"fix backend name","repos":"JakeChampion\/polyfill-service,JakeChampion\/polyfill-service","old_file":"fastly\/vcl\/polyfill-service.vcl","new_file":"fastly\/vcl\/polyfill-service.vcl","new_contents":"sub set_backend {\n\t# The Fastly macro is inserted before the backend is selected because the\n\t# macro has the code which defines the values avaiable for req.http.Host\n\t# but it also contains a default backend which is always set to the EU. I wish we could disable the default backend setting.\n\t#FASTLY recv\n\t\n\t# Calculate the ideal region to route the request to.\n \tdeclare local var.region STRING; \n\tif (server.region ~ \"(APAC|Asia|North-America|South-America|US-Central|US-East|US-West)\") {\n\t\tset var.region = \"US\";\n \t} else {\n\t\tset var.region = \"EU\";\n \t}\n\n\t# Gather the health of the shields and origins.\n\tdeclare local var.v3_eu_is_healthy BOOL;\n\tset req.backend = F_v3_eu;\n\tset var.v3_eu_is_healthy = req.backend.healthy;\n\n\tdeclare local var.v3_us_is_healthy BOOL;\n \tset req.backend = F_v3_us;\n \tset var.v3_us_is_healthy = req.backend.healthy;\n\n \tdeclare local var.shield_eu_is_healthy BOOL;\n \tset req.backend = ssl_shield_london_city_uk;\n \tset var.shield_eu_is_healthy = req.backend.healthy;\n\n \tdeclare local var.shield_us_is_healthy BOOL;\n \tset req.backend = ssl_shield_dca_dc_us;\n \tset var.shield_us_is_healthy = req.backend.healthy;\n\n \t# Set some sort of default, that shouldn't get used.\n \tset req.backend = F_v3_eu;\n\n\tdeclare local var.EU_shield_server_name STRING;\n\tset var.EU_shield_server_name = \"LCY\";\n\n\tdeclare local var.US_shield_server_name STRING;\n\tset var.US_shield_server_name = \"DCA\";\n\n\t# Route EU requests to the nearest healthy shield or origin.\n \tif (var.region == \"EU\") {\n\t\tif (server.datacenter != var.EU_shield_server_name && req.http.Request_Came_From_Shield != var.EU_shield_server_name && var.shield_eu_is_healthy) {\n\t\t\tset req.backend = ssl_shield_london_city_uk;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} elseif (var.shield_us_is_healthy) {\n\t\t\tset req.backend = ssl_shield_dca_dc_us;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_eu;\n\t\t}\n \t}\n\n\t# Route US requests to the nearest healthy shield or origin.\n \tif (var.region == \"US\") {\n\t\tif (server.datacenter != var.US_shield_server_name && req.http.Request_Came_From_Shield != var.US_shield_server_name && var.shield_us_is_healthy) {\n\t\t\tset req.backend = ssl_shield_dca_dc_us;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} elseif (var.shield_eu_is_healthy) {\n\t\t\tset req.backend = ssl_shield_london_city_uk;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_us;\n\t\t}\n\t}\n\n\t# Persist the decision so we can debug the result.\n \tset req.http.Debug-Backend = req.backend;\n}\n\nsub vcl_recv {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_recv;\n\t}\n\n\tif (req.method != \"GET\" && req.method != \"HEAD\" && req.method != \"OPTIONS\" && req.method != \"FASTLYPURGE\" && req.method != \"PURGE\") {\n\t\terror 911;\n\t}\n\n\tif (req.method == \"OPTIONS\") {\n\t\terror 912;\n\t}\n\n\t# Because the old service had a router which allowed any words between \/v2\/polyfill. and .js\n\tif (req.url.path ~ \"^\/v2\/polyfill(\\.\\w+)(\\.\\w+)?\" && req.url.ext == \"js\") {\n\t\tif (re.group.2) {\n\t\t\tset req.url = \"\/v2\/polyfill.min.js?\" req.url.qs;\n\t\t} else {\n\t\t\tset req.url = \"\/v2\/polyfill.js?\" req.url.qs;\n\t\t}\n\t}\n\n\t# Override the v3 defaults with the defaults of v2\n\tif (req.url ~ \"^\/v2\/polyfill(\\.min)?\\.js\") {\n\t\tset req.url = regsub(req.url, \"^\/v2\", \"\/v3\");\n\t\tset req.url = querystring.set(req.url, \"version\", \"3.25.1\");\n\t\tdeclare local var.unknown STRING;\n\t\tset var.unknown = subfield(req.url.qs, \"unknown\", \"&\");\n\t\tset req.url = querystring.set(req.url, \"unknown\", if(var.unknown != \"\", var.unknown, \"ignore\"));\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\") {\n\t\tcall normalise_querystring_parameters_for_polyfill_bundle;\n\t\t# Sort the querystring parameters alphabetically to improve chances of hitting a cached copy.\n\t\t# If querystring is empty, remove the ? from the url.\n\t\tset req.url = querystring.clean(querystring.sort(req.url));\n\t\tcall set_backend;\n\t} else {\n\t\t# The request is to an endpoint which doesn't use query parameters, let's remove them to increase our cache-hit-ratio\n\t\tset req.url = querystring.remove(req.url);\n\t\tcall set_backend;\n\t}\n\t\n\tif (req.backend == ssl_shield_dca_dc_us || req.backend == ssl_shield_london_city_uk) {\n\t\t# avoid passing stale content from Shield POP to Edge POP\n\t\tset req.max_stale_while_revalidate = 0s;\n\t} else {\n\t\tset req.http.referer_domain = if(req.http.referer ~ \"^https?\\:\\\/\\\/([^\\\/:?#]+)(?:[\\\/:?#]|$)\", re.group.1, \"\");\n\t}\n}\n\nsub vcl_hash {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_hash;\n\t}\n\n\t# We are not adding req.http.host to the hash because we want https:\/\/cdn.polyfill.io and https:\/\/polyfill.io to be a single object in the cache.\n\t# set req.hash += req.http.host;\n\tset req.hash += req.url;\n\t# We include return(hash) to stop the function falling through to the default VCL built into varnish, which for vcl_hash will add req.url and req.http.Host to the hash.\n\treturn(hash);\n}\n\n\nsub shielding_header {\n\tif (req.backend == ssl_shield_dca_dc_us) {\n\t\tset req.http.Request_Came_From_Shield = server.datacenter;\n\t} elsif (req.backend == ssl_shield_london_city_uk) {\n\t\tset req.http.Request_Came_From_Shield = server.datacenter;\n\t}\n}\n\nsub vcl_miss {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_miss;\n\t}\n\tcall shielding_header;\n}\n\nsub vcl_pass {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_pass;\n\t}\n\tcall shielding_header;\n}\n\nsub vcl_fetch {\n\tset beresp.http.Request_Came_From_Shield = req.http.Request_Came_From_Shield;\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_fetch;\n\t}\n\n\t# These header are only required for HTML documents.\n\tif (beresp.http.Content-Type ~ \"text\/html\") {\n\t\t# Enables the cross-site scripting filter built into most modern web browsers.\n\t\tset beresp.http.X-XSS-Protection = \"1; mode=block\";\t\n\t}\n\t# Prevents MIME-sniffing a response away from the declared content type.\n\tset beresp.http.X-Content-Type-Options = \"nosniff\";\n\n\t# Ensure the site is only served over HTTPS and reduce the chances of someone performing a MITM attack.\n\tset beresp.http.Strict-Transport-Security = \"max-age=31536000; includeSubdomains; preload\";\n\n\t# The Referrer-Policy header governs which referrer information, sent in the Referer header, should be included with requests made.\n\t# Send a full URL when performing a same-origin request, but only send the origin of the document for other cases.\n\tset beresp.http.Referrer-Policy = \"origin-when-cross-origin\";\n\n\t# Enable purging of all objects in the Fastly cache by issuing a purge with the key \"polyfill-service\".\n\tif (beresp.http.Surrogate-Key !~ \"\\bpolyfill-service\\b\") {\n\t\tset beresp.http.Surrogate-Key = if(beresp.http.Surrogate-Key, beresp.http.Surrogate-Key \" polyfill-service\", \"polyfill-service\");\n\t}\n\n\tset beresp.http.Timing-Allow-Origin = \"*\";\n\n\tif (req.http.Normalized-User-Agent) {\n\t\tset beresp.http.Normalized-User-Agent = req.http.Normalized-User-Agent;\n\t\tset beresp.http.Detected-User-Agent = req.http.useragent_parser_family \"\/\" req.http.useragent_parser_major \".\" req.http.useragent_parser_minor \".\" req.http.useragent_parser_patch;\n\t}\n}\n\nsub vcl_deliver {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_deliver;\n\t}\n\n\tset req.http.Fastly-Force-Shield = \"yes\";\n\n\t# Allow cross origin GET, HEAD, and OPTIONS requests to be made.\n\tif (req.http.Origin) {\n\t\tset resp.http.Access-Control-Allow-Origin = \"*\";\n\t\tset resp.http.Access-Control-Allow-Methods = \"GET,HEAD,OPTIONS\";\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\" && !resp.http.Request_Came_From_Shield && req.backend != ssl_shield_dca-dc-us && req.backend != ssl_shield_london_city_uk) {\n\t\t# Need to add \"Vary: User-Agent\" in after vcl_fetch to avoid the \n\t\t# \"Vary: User-Agent\" entering the Varnish cache.\n\t\t# We need \"Vary: User-Agent\" in the browser cache because a browser\n\t\t# may update itself to a version which needs different polyfills\n\t\t# So we need to have it ignore the browser cached bundle when the user-agent changes.\n\t\tset resp.http.Vary = \"User-Agent, Accept-Encoding\";\n\t}\n\n\tif (resp.status == 304) {\n\t\tset resp.http.Age = \"0\";\n\t}\n\n\tadd resp.http.Server-Timing = fastly_info.state {\", fastly;desc=\"Edge time\";dur=\"} time.elapsed.msec;\n\n\tif (req.http.Fastly-Debug) {\n\t\tset resp.http.Debug-Backend = req.http.Debug-Backend;\n\t\tset resp.http.Debug-Host = req.http.Host;\n\t\tset resp.http.Debug-Fastly-Restarts = req.restarts;\n\t\tset resp.http.Debug-Orig-URL = req.http.Orig-URL;\n\t\tset resp.http.Debug-VCL-Route = req.http.X-VCL-Route;\n\t\tset resp.http.useragent_parser_family = req.http.useragent_parser_family;\n\t\tset resp.http.useragent_parser_major = req.http.useragent_parser_major;\n\t\tset resp.http.useragent_parser_minor = req.http.useragent_parser_minor;\n\t\tset resp.http.useragent_parser_patch = req.http.useragent_parser_patch;\n\t} else {\n\t\tunset resp.http.Server;\n\t\tunset resp.http.Via;\n\t\tunset resp.http.X-Cache;\n\t\tunset resp.http.X-Cache-Hits;\n\t\tunset resp.http.X-Served-By;\n\t\tunset resp.http.X-Timer;\n\t\tunset resp.http.Fastly-Restarts;\n\t\tunset resp.http.X-PreFetch-Pass;\n\t\tunset resp.http.X-PreFetch-Miss;\n\t\tunset resp.http.X-PostFetch;\n\t}\n}\n\nsub vcl_error {\n\tif (obj.status == 911) {\n\t\tset obj.status = 405;\n\t\tset obj.response = \"METHOD NOT ALLOWED\";\n\t\tset obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n\t\tset obj.http.Cache-Control = \"private, no-store\";\n\t\tsynthetic req.method \" METHOD NOT ALLOWED\";\n\t\treturn (deliver);\n\t}\n\tif (obj.status == 912) {\n\t\tset obj.status = 200;\n\t\tset obj.response = \"OK\";\n\t\tset obj.http.Allow = \"OPTIONS, GET, HEAD\";\n\t\treturn (deliver);\n\t}\n}\n","old_contents":"sub set_backend {\n\t# The Fastly macro is inserted before the backend is selected because the\n\t# macro has the code which defines the values avaiable for req.http.Host\n\t# but it also contains a default backend which is always set to the EU. I wish we could disable the default backend setting.\n\t#FASTLY recv\n\t\n\t# Calculate the ideal region to route the request to.\n \tdeclare local var.region STRING; \n\tif (server.region ~ \"(APAC|Asia|North-America|South-America|US-Central|US-East|US-West)\") {\n\t\tset var.region = \"US\";\n \t} else {\n\t\tset var.region = \"EU\";\n \t}\n\n\t# Gather the health of the shields and origins.\n\tdeclare local var.v3_eu_is_healthy BOOL;\n\tset req.backend = F_v3_eu;\n\tset var.v3_eu_is_healthy = req.backend.healthy;\n\n\tdeclare local var.v3_us_is_healthy BOOL;\n \tset req.backend = F_v3_us;\n \tset var.v3_us_is_healthy = req.backend.healthy;\n\n \tdeclare local var.shield_eu_is_healthy BOOL;\n \tset req.backend = ssl_shield_london_city_uk;\n \tset var.shield_eu_is_healthy = req.backend.healthy;\n\n \tdeclare local var.shield_us_is_healthy BOOL;\n \tset req.backend = ssl_shield_dca-dc-us;\n \tset var.shield_us_is_healthy = req.backend.healthy;\n\n \t# Set some sort of default, that shouldn't get used.\n \tset req.backend = F_v3_eu;\n\n\tdeclare local var.EU_shield_server_name STRING;\n\tset var.EU_shield_server_name = \"LCY\";\n\n\tdeclare local var.US_shield_server_name STRING;\n\tset var.US_shield_server_name = \"DCA\";\n\n\t# Route EU requests to the nearest healthy shield or origin.\n \tif (var.region == \"EU\") {\n\t\tif (server.datacenter != var.EU_shield_server_name && req.http.Request_Came_From_Shield != var.EU_shield_server_name && var.shield_eu_is_healthy) {\n\t\t\tset req.backend = ssl_shield_london_city_uk;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} elseif (var.shield_us_is_healthy) {\n\t\t\tset req.backend = ssl_shield_dca-dc-us;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_eu;\n\t\t}\n \t}\n\n\t# Route US requests to the nearest healthy shield or origin.\n \tif (var.region == \"US\") {\n\t\tif (server.datacenter != var.US_shield_server_name && req.http.Request_Came_From_Shield != var.US_shield_server_name && var.shield_us_is_healthy) {\n\t\t\tset req.backend = ssl_shield_dca-dc-us;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} elseif (var.shield_eu_is_healthy) {\n\t\t\tset req.backend = ssl_shield_london_city_uk;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_us;\n\t\t}\n\t}\n\n\t# Persist the decision so we can debug the result.\n \tset req.http.Debug-Backend = req.backend;\n}\n\nsub vcl_recv {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_recv;\n\t}\n\n\tif (req.method != \"GET\" && req.method != \"HEAD\" && req.method != \"OPTIONS\" && req.method != \"FASTLYPURGE\" && req.method != \"PURGE\") {\n\t\terror 911;\n\t}\n\n\tif (req.method == \"OPTIONS\") {\n\t\terror 912;\n\t}\n\n\t# Because the old service had a router which allowed any words between \/v2\/polyfill. and .js\n\tif (req.url.path ~ \"^\/v2\/polyfill(\\.\\w+)(\\.\\w+)?\" && req.url.ext == \"js\") {\n\t\tif (re.group.2) {\n\t\t\tset req.url = \"\/v2\/polyfill.min.js?\" req.url.qs;\n\t\t} else {\n\t\t\tset req.url = \"\/v2\/polyfill.js?\" req.url.qs;\n\t\t}\n\t}\n\n\t# Override the v3 defaults with the defaults of v2\n\tif (req.url ~ \"^\/v2\/polyfill(\\.min)?\\.js\") {\n\t\tset req.url = regsub(req.url, \"^\/v2\", \"\/v3\");\n\t\tset req.url = querystring.set(req.url, \"version\", \"3.25.1\");\n\t\tdeclare local var.unknown STRING;\n\t\tset var.unknown = subfield(req.url.qs, \"unknown\", \"&\");\n\t\tset req.url = querystring.set(req.url, \"unknown\", if(var.unknown != \"\", var.unknown, \"ignore\"));\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\") {\n\t\tcall normalise_querystring_parameters_for_polyfill_bundle;\n\t\t# Sort the querystring parameters alphabetically to improve chances of hitting a cached copy.\n\t\t# If querystring is empty, remove the ? from the url.\n\t\tset req.url = querystring.clean(querystring.sort(req.url));\n\t\tcall set_backend;\n\t} else {\n\t\t# The request is to an endpoint which doesn't use query parameters, let's remove them to increase our cache-hit-ratio\n\t\tset req.url = querystring.remove(req.url);\n\t\tcall set_backend;\n\t}\n\t\n\tif (req.backend == ssl_shield_dca-dc-us || req.backend == ssl_shield_london_city_uk) {\n\t\t# avoid passing stale content from Shield POP to Edge POP\n\t\tset req.max_stale_while_revalidate = 0s;\n\t} else {\n\t\tset req.http.referer_domain = if(req.http.referer ~ \"^https?\\:\\\/\\\/([^\\\/:?#]+)(?:[\\\/:?#]|$)\", re.group.1, \"\");\n\t}\n}\n\nsub vcl_hash {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_hash;\n\t}\n\n\t# We are not adding req.http.host to the hash because we want https:\/\/cdn.polyfill.io and https:\/\/polyfill.io to be a single object in the cache.\n\t# set req.hash += req.http.host;\n\tset req.hash += req.url;\n\t# We include return(hash) to stop the function falling through to the default VCL built into varnish, which for vcl_hash will add req.url and req.http.Host to the hash.\n\treturn(hash);\n}\n\n\nsub shielding_header {\n\tif (req.backend == ssl_shield_dca-dc-us) {\n\t\tset req.http.Request_Came_From_Shield = server.datacenter;\n\t} elsif (req.backend == ssl_shield_london_city_uk) {\n\t\tset req.http.Request_Came_From_Shield = server.datacenter;\n\t}\n}\n\nsub vcl_miss {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_miss;\n\t}\n\tcall shielding_header;\n}\n\nsub vcl_pass {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_pass;\n\t}\n\tcall shielding_header;\n}\n\nsub vcl_fetch {\n\tset beresp.http.Request_Came_From_Shield = req.http.Request_Came_From_Shield;\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_fetch;\n\t}\n\n\t# These header are only required for HTML documents.\n\tif (beresp.http.Content-Type ~ \"text\/html\") {\n\t\t# Enables the cross-site scripting filter built into most modern web browsers.\n\t\tset beresp.http.X-XSS-Protection = \"1; mode=block\";\t\n\t}\n\t# Prevents MIME-sniffing a response away from the declared content type.\n\tset beresp.http.X-Content-Type-Options = \"nosniff\";\n\n\t# Ensure the site is only served over HTTPS and reduce the chances of someone performing a MITM attack.\n\tset beresp.http.Strict-Transport-Security = \"max-age=31536000; includeSubdomains; preload\";\n\n\t# The Referrer-Policy header governs which referrer information, sent in the Referer header, should be included with requests made.\n\t# Send a full URL when performing a same-origin request, but only send the origin of the document for other cases.\n\tset beresp.http.Referrer-Policy = \"origin-when-cross-origin\";\n\n\t# Enable purging of all objects in the Fastly cache by issuing a purge with the key \"polyfill-service\".\n\tif (beresp.http.Surrogate-Key !~ \"\\bpolyfill-service\\b\") {\n\t\tset beresp.http.Surrogate-Key = if(beresp.http.Surrogate-Key, beresp.http.Surrogate-Key \" polyfill-service\", \"polyfill-service\");\n\t}\n\n\tset beresp.http.Timing-Allow-Origin = \"*\";\n\n\tif (req.http.Normalized-User-Agent) {\n\t\tset beresp.http.Normalized-User-Agent = req.http.Normalized-User-Agent;\n\t\tset beresp.http.Detected-User-Agent = req.http.useragent_parser_family \"\/\" req.http.useragent_parser_major \".\" req.http.useragent_parser_minor \".\" req.http.useragent_parser_patch;\n\t}\n}\n\nsub vcl_deliver {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_deliver;\n\t}\n\n\tset req.http.Fastly-Force-Shield = \"yes\";\n\n\t# Allow cross origin GET, HEAD, and OPTIONS requests to be made.\n\tif (req.http.Origin) {\n\t\tset resp.http.Access-Control-Allow-Origin = \"*\";\n\t\tset resp.http.Access-Control-Allow-Methods = \"GET,HEAD,OPTIONS\";\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\" && !resp.http.Request_Came_From_Shield && req.backend != ssl_shield_dca-dc-us && req.backend != ssl_shield_london_city_uk) {\n\t\t# Need to add \"Vary: User-Agent\" in after vcl_fetch to avoid the \n\t\t# \"Vary: User-Agent\" entering the Varnish cache.\n\t\t# We need \"Vary: User-Agent\" in the browser cache because a browser\n\t\t# may update itself to a version which needs different polyfills\n\t\t# So we need to have it ignore the browser cached bundle when the user-agent changes.\n\t\tset resp.http.Vary = \"User-Agent, Accept-Encoding\";\n\t}\n\n\tif (resp.status == 304) {\n\t\tset resp.http.Age = \"0\";\n\t}\n\n\tadd resp.http.Server-Timing = fastly_info.state {\", fastly;desc=\"Edge time\";dur=\"} time.elapsed.msec;\n\n\tif (req.http.Fastly-Debug) {\n\t\tset resp.http.Debug-Backend = req.http.Debug-Backend;\n\t\tset resp.http.Debug-Host = req.http.Host;\n\t\tset resp.http.Debug-Fastly-Restarts = req.restarts;\n\t\tset resp.http.Debug-Orig-URL = req.http.Orig-URL;\n\t\tset resp.http.Debug-VCL-Route = req.http.X-VCL-Route;\n\t\tset resp.http.useragent_parser_family = req.http.useragent_parser_family;\n\t\tset resp.http.useragent_parser_major = req.http.useragent_parser_major;\n\t\tset resp.http.useragent_parser_minor = req.http.useragent_parser_minor;\n\t\tset resp.http.useragent_parser_patch = req.http.useragent_parser_patch;\n\t} else {\n\t\tunset resp.http.Server;\n\t\tunset resp.http.Via;\n\t\tunset resp.http.X-Cache;\n\t\tunset resp.http.X-Cache-Hits;\n\t\tunset resp.http.X-Served-By;\n\t\tunset resp.http.X-Timer;\n\t\tunset resp.http.Fastly-Restarts;\n\t\tunset resp.http.X-PreFetch-Pass;\n\t\tunset resp.http.X-PreFetch-Miss;\n\t\tunset resp.http.X-PostFetch;\n\t}\n}\n\nsub vcl_error {\n\tif (obj.status == 911) {\n\t\tset obj.status = 405;\n\t\tset obj.response = \"METHOD NOT ALLOWED\";\n\t\tset obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n\t\tset obj.http.Cache-Control = \"private, no-store\";\n\t\tsynthetic req.method \" METHOD NOT ALLOWED\";\n\t\treturn (deliver);\n\t}\n\tif (obj.status == 912) {\n\t\tset obj.status = 200;\n\t\tset obj.response = \"OK\";\n\t\tset obj.http.Allow = \"OPTIONS, GET, HEAD\";\n\t\treturn (deliver);\n\t}\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"60cf836470133f8608ddcf9e924a61f74f6cc42c","subject":"Updated VCL for the new html() function.","message":"Updated VCL for the new html() function.\n","repos":"normabuttz\/libvmod-rtstatus,normabuttz\/libvmod-rtstatus,normabuttz\/libvmod-rtstatus","old_file":"example.vcl","new_file":"example.vcl","new_contents":"vcl 4.0;\nimport std;\nimport directors;\nimport rtstatus;\n\nbackend default {\n\t.host = \"127.0.0.1\";\n\t.port = \"8080\";\n}\nbackend server1 {\n\t.host = \"192.168.0.10\";\n\t.port =\"8081\";\n}\nbackend server2 {\n\t.host = \"192.168.0.10\";\n\t.port = \"8082\";\n}\n\nsub vcl_init {\n\tnew bar = directors.round_robin();\n\tbar.add_backend(server1);\n\tbar.add_backend(server2);\n\tbar.add_backend(default);\n}\n\nsub vcl_recv {\n\tif (req.url ~ \"\/rtstatus.json\") {\n\t\treturn(synth(700, \"OK\"));\n\t}\n\tif (req.url ~ \"\/rtstatus\") {\n\t\treturn(synth(800, \"OK\"));\n\t}\n}\n\nsub vcl_synth {\n\tif (resp.status == 700) {\n\t\tset resp.status = 200;\n\t\tsynthetic(rtstatus.rtstatus());\n\t\treturn (deliver);\n\t}\n\tif (resp.status == 800) {\n\t\tset resp.status = 200;\n\t\tset resp.http.Content-Type = \"text\/html; charset=utf-8\";\n\t\tsynthetic(rtstatus.html());\n\t\treturn (deliver);\n\t}\n}\n\n\n\n\n","old_contents":"vcl 4.0;\nimport std;\nimport directors;\nimport rtstatus;\n\nbackend default {\n\t.host = \"127.0.0.1\";\n\t.port = \"8080\";\n}\nbackend server1 {\n\t.host = \"192.168.0.10\";\n\t.port =\"8081\";\n}\nbackend server2 {\n\t.host = \"192.168.0.10\";\n\t.port = \"8082\";\n}\n\nsub vcl_init {\n\tnew bar = directors.round_robin();\n\tbar.add_backend(server1);\n\tbar.add_backend(server2);\n\tbar.add_backend(default);\n}\n\nsub vcl_recv {\n\tif (req.url ~ \"\/rtstatus.json\") {\n\t\treturn(synth(700, \"OK\"));\n\t}\n\tif (req.url ~ \"\/rtstatus\") {\n\t\treturn(synth(800, \"OK\"));\n\t}\n}\n\nsub vcl_synth {\n\tif (resp.status == 700) {\n\t\tset resp.status = 200;\n\t\tsynthetic(rtstatus.rtstatus());\n\t\treturn (deliver);\n\t}\n\tif (resp.status == 800) {\n\t\tset resp.http.Content-Type = \"text\/html; charset=utf-8\";\n\t\tsynthetic(std.fileread(\"\/home\/arianna\/libvmod-rtstatus\/src\/rtstatus.html\"));\n\t\treturn (deliver);\n\t}\n}\n\n\n\n\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"21a4c4e96cb2af7c2962c1a8a6306c557a4278f0","subject":"Set cookie on password\/edit to avoid csrf error","message":"Set cookie on password\/edit to avoid csrf error\n","repos":"EFForg\/action-center-platform,EFForg\/action-center-platform,EFForg\/action-center-platform,EFForg\/action-center-platform","old_file":"varnish.vcl","new_file":"varnish.vcl","new_contents":"# See https:\/\/github.com\/EFForg\/action-center-platform\/wiki\/Deployment-Notes#cache-configuration\n\nsub vcl_recv {\n#FASTLY recv\n\n if (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n if (req.http.cookie ~ \"logged_in\" && req.url !~ \"^\/assets\/\") {\n set req.hash_always_miss = true;\n return(pass);\n }\n\n if (req.url !~ \"^\/(ahoy)\/\") {\n unset req.http.Cookie;\n }\n\n return(lookup);\n}\n\nsub vcl_fetch {\n if (req.http.cookie !~ \"logged_in\" && req.url !~ \"^\/(login)|(register)|(confirmation\/new)|(unlock\/new)|(password\/new)|(password\/edit)|(ahoy\/)\") {\n unset beresp.http.Set-Cookie;\n }\n\n#FASTLY fetch\n\n if ((beresp.status == 500 || beresp.status == 503) && req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n if (req.restarts > 0) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return(pass);\n }\n\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return(pass);\n }\n\n if (beresp.status == 500 || beresp.status == 503) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return(deliver);\n }\n\n if (beresp.http.Expires || beresp.http.Surrogate-Control ~ \"max-age\" || beresp.http.Cache-Control ~ \"(s-maxage|max-age)\") {\n # keep the ttl here\n } else {\n # apply the default ttl\n set beresp.ttl = 3600s;\n }\n\n return(deliver);\n}\n\nsub vcl_hit {\n#FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\nsub vcl_miss {\n#FASTLY miss\n return(fetch);\n}\n\nsub vcl_deliver {\n#FASTLY deliver\n return(deliver);\n}\n\nsub vcl_error {\n#FASTLY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n\nsub vcl_log {\n#FASTLY log\n}\n","old_contents":"# See https:\/\/github.com\/EFForg\/action-center-platform\/wiki\/Deployment-Notes#cache-configuration\n\nsub vcl_recv {\n#FASTLY recv\n\n if (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n if (req.http.cookie ~ \"logged_in\" && req.url !~ \"^\/assets\/\") {\n set req.hash_always_miss = true;\n return(pass);\n }\n\n if (req.url !~ \"^\/(ahoy)\/\") {\n unset req.http.Cookie;\n }\n\n return(lookup);\n}\n\nsub vcl_fetch {\n if (req.http.cookie !~ \"logged_in\" && req.url !~ \"^\/(login)|(register)|(confirmation\/new)|(unlock\/new)|(password\/new)|(ahoy\/)\") {\n unset beresp.http.Set-Cookie;\n }\n\n#FASTLY fetch\n\n if ((beresp.status == 500 || beresp.status == 503) && req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n if (req.restarts > 0) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return(pass);\n }\n\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return(pass);\n }\n\n if (beresp.status == 500 || beresp.status == 503) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return(deliver);\n }\n\n if (beresp.http.Expires || beresp.http.Surrogate-Control ~ \"max-age\" || beresp.http.Cache-Control ~ \"(s-maxage|max-age)\") {\n # keep the ttl here\n } else {\n # apply the default ttl\n set beresp.ttl = 3600s;\n }\n\n return(deliver);\n}\n\nsub vcl_hit {\n#FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\nsub vcl_miss {\n#FASTLY miss\n return(fetch);\n}\n\nsub vcl_deliver {\n#FASTLY deliver\n return(deliver);\n}\n\nsub vcl_error {\n#FASTLY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n\nsub vcl_log {\n#FASTLY log\n}\n","returncode":0,"stderr":"","license":"agpl-3.0","lang":"VCL"} {"commit":"a558c5abca6c94e4d1621462991fd6371403b7bd","subject":"Stop rewriting version assets URLs in Varnish","message":"Stop rewriting version assets URLs in Varnish\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets\/recv.vcl","new_file":"etc\/vcl_snippets\/recv.vcl","new_contents":" # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n unset req.http.x-long-cache;\n\n # We want to force long cache times on any of the versioned assets\n if (req.url.path ~ \"^\/static\/version(\\d*\/)\") {\n set req.http.x-long-cache = \"1\";\n }\n \n # User's Cookie may contain some Magento Vary items we should vary on\n if (req.http.cookie:X-Magento-Vary ) {\n set req.http.X-Magento-Vary = req.http.cookie:X-Magento-Vary;\n } else {\n unset req.http.X-Magento-Vary;\n }\n\n ############################################################################################################\n # Following code block controls purge by URL. By default we want to protect all URL purges. In general this\n # is addressed by adding Fastly-Purge-Requires-Auth request header in vcl_recv however this runs the risk of\n # exposing API tokens if user attempts to purge non-https URLs. For this reason inside the Magento module\n # we use X-Purge-Token. Unfortunately this breaks purge from the Fastly UI. Therefore in the next code block\n # we check for presence of X-Purge-Token. If it's not present we force the Fastly-Purge-Requires-Auth\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n if (req.http.X-Purge-Token && req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n } else {\n error 403;\n }\n } else {\n set req.http.Fastly-Purge-Requires-Auth = \"1\";\n }\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (req.http.Fastly-FF) {\n # disable ESI processing on Origin Shield\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Make sure we lookup end user geo not shielding. More at https:\/\/docs.fastly.com\/vcl\/geolocation\/#using-geographic-variables-with-shielding\n set client.geo.ip_override = req.http.Fastly-Client-IP;\n\n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie:X-Magento-Vary || req.http.cookie:form_key) {\n error 980 \"GeoIP already processed\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url.qs !~ \"country_code=\" ) {\n set req.url = req.url \"?country_code=\" if ( req.http.geo_override, req.http.geo_override, client.geo.country_code);\n }\n }\n } else {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking by default\n # and allow custom parameters to be set. List of parameters is configurable in admin\n set req.http.Magento-Original-URL = req.url;\n # Change the list of ignored parameters by configuring them in the Advanced section\n set req.url = querystring.regfilter(req.url, \"^(####QUERY_PARAMETERS####)\");\n }\n\n # Don't allow clients to force a pass\n if (req.restarts == 0) {\n unset req.http.x-pass;\n }\n \n # Pass on checkout URLs. Because it's a snippet we want to execute this after backend selection so we handle it\n # in the request condition\n if (!req.http.x-long-cache && req.url ~ \"\/(catalogsearch|checkout|customer\/section\/load)\") {\n set req.http.x-pass = \"1\";\n # Pass all admin actions\n # ####ADMIN_PATH#### is replaced with value of frontName from app\/etc\/env.php\n } else if ( req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" ) {\n set req.http.x-pass = \"1\";\n } else {\n # Sort the query arguments to increase cache hit ratio with query arguments that\n # may be out od order. In case you want to restore the unsorted URL add a snippet\n # after this one that sets req.url to req.http.Magento-Original-URL\n set req.url = boltsort.sort(req.url);\n }\n\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.http.x-long-cache || req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n","old_contents":" # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n unset req.http.x-long-cache;\n\n # Rewrite \/static\/versionxxxxx URLs. Avoids us having to rewrite on nginx layer\n if (req.url ~ \"^\/static\/version(\\d*\/)?(.*)$\") {\n set req.url = \"\/static\/\" + re.group.2 + \"?\" + re.group.1;\n set req.http.x-long-cache = \"1\";\n }\n \n # User's Cookie may contain some Magento Vary items we should vary on\n if (req.http.cookie:X-Magento-Vary ) {\n set req.http.X-Magento-Vary = req.http.cookie:X-Magento-Vary;\n } else {\n unset req.http.X-Magento-Vary;\n }\n\n ############################################################################################################\n # Following code block controls purge by URL. By default we want to protect all URL purges. In general this\n # is addressed by adding Fastly-Purge-Requires-Auth request header in vcl_recv however this runs the risk of\n # exposing API tokens if user attempts to purge non-https URLs. For this reason inside the Magento module\n # we use X-Purge-Token. Unfortunately this breaks purge from the Fastly UI. Therefore in the next code block\n # we check for presence of X-Purge-Token. If it's not present we force the Fastly-Purge-Requires-Auth\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n if (req.http.X-Purge-Token && req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n } else {\n error 403;\n }\n } else {\n set req.http.Fastly-Purge-Requires-Auth = \"1\";\n }\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (req.http.Fastly-FF) {\n # disable ESI processing on Origin Shield\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Make sure we lookup end user geo not shielding. More at https:\/\/docs.fastly.com\/vcl\/geolocation\/#using-geographic-variables-with-shielding\n set client.geo.ip_override = req.http.Fastly-Client-IP;\n\n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie:X-Magento-Vary || req.http.cookie:form_key) {\n error 980 \"GeoIP already processed\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url.qs !~ \"country_code=\" ) {\n set req.url = req.url \"?country_code=\" if ( req.http.geo_override, req.http.geo_override, client.geo.country_code);\n }\n }\n } else {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking by default\n # and allow custom parameters to be set. List of parameters is configurable in admin\n set req.http.Magento-Original-URL = req.url;\n # Change the list of ignored parameters by configuring them in the Advanced section\n set req.url = querystring.regfilter(req.url, \"^(####QUERY_PARAMETERS####)\");\n }\n\n # Don't allow clients to force a pass\n if (req.restarts == 0) {\n unset req.http.x-pass;\n }\n \n # Pass on checkout URLs. Because it's a snippet we want to execute this after backend selection so we handle it\n # in the request condition\n if (!req.http.x-long-cache && req.url ~ \"\/(catalogsearch|checkout|customer\/section\/load)\") {\n set req.http.x-pass = \"1\";\n # Pass all admin actions\n # ####ADMIN_PATH#### is replaced with value of frontName from app\/etc\/env.php\n } else if ( req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" ) {\n set req.http.x-pass = \"1\";\n } else {\n # Sort the query arguments to increase cache hit ratio with query arguments that\n # may be out od order. In case you want to restore the unsorted URL add a snippet\n # after this one that sets req.url to req.http.Magento-Original-URL\n set req.url = boltsort.sort(req.url);\n }\n\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.http.x-long-cache || req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"d5e15237982fb3133d634af59eed4bd3786819ab","subject":"enable varnish","message":"enable varnish\n","repos":"20steps\/alexa,20steps\/alexa,20steps\/alexa,20steps\/alexa,20steps\/alexa,20steps\/alexa,20steps\/alexa","old_file":"etc\/system\/varnish\/default.generic_live.vcl","new_file":"etc\/system\/varnish\/default.generic_live.vcl","new_contents":"vcl 4.0;\n## Based on: https:\/\/github.com\/mattiasgeniar\/varnish-4.0-configuration-templates\/blob\/master\/default.vcl\n# Corrected & improved for 4.0.2 by jnerin@gmail.com\nimport std;\nimport directors;\n\ninclude \"badbot.vcl\";\n\nbackend alexa1 {\n .host = \"192.168.16.3\";\n .port = \"8080\";\n\n .max_connections = 300; # That's it\n .first_byte_timeout = 300s; # How long to wait before we receive a first byte from our backend?\n .connect_timeout = 5s; # How long to wait for a backend connection?\n .between_bytes_timeout = 2s; # How long to wait between bytes received from our backend?\n\n# .probe = {\n#\t .request =\n# \"GET \/robots.txt HTTP\/1.1\"\n# \"Host: admin.platform.bricks.20steps.de\"\n# \"Connection: close\";\n# .interval = 5s;\n# .timeout = 1s;\n# .window = 5;\n# .threshold = 3;\n# }\n}\n\n#backend alexa2 {\n# .host = \"192.168.13.20\";\n# .port = \"8080\";\n#\n# .max_connections = 300; # That's it\n# .first_byte_timeout = 300s; # How long to wait before we receive a first byte from our backend?\n# .connect_timeout = 5s; # How long to wait for a backend connection?\n# .between_bytes_timeout = 2s; # How long to wait between bytes received from our backend?\n#\n# .probe = {\n# .request =\n# \"GET \/robots.txt HTTP\/1.1\"\n# \"Host: admin.platform.bricks.20steps.de\"\n# \"Connection: close\";\n# .interval = 5s;\n# .timeout = 1s;\n# .window = 5;\n# .threshold = 3;\n# }\n#}\n\n\n#backend alexaj1 {\n# .host = \"192.168.14.17\";\n# .port = \"8080\";\n#\n# .max_connections = 300; # That's it\n# .first_byte_timeout = 300s; # How long to wait before we receive a first byte from our backend?\n# .connect_timeout = 5s; # How long to wait for a backend connection?\n# .between_bytes_timeout = 2s; # How long to wait between bytes received from our backend?\n#\n# .probe = {\n# .request =\n# \"GET \/robots.txt HTTP\/1.1\"\n# \"Host: admin.platform.bricks.20steps.de\"\n# \"Connection: close\";\n# .interval = 5s;\n# .timeout = 1s;\n# .window = 5;\n# .threshold = 3;\n# }\n#}\n\nacl invalidators {\n # ACL we'll use later to allow purges\n \"localhost\";\n \"127.0.0.1\";\n \"::1\";\n \"192.168.0.0\"\/16;\n}\n\nsub vcl_init {\n# Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n\n include \"director.vcl\";\n\n}\n\nsub vcl_recv {\n# Called at the beginning of a request, after the complete request has been received and parsed. Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use.\n# also used to modify the request\n\n call badbot;\n\n ## REQUEST NORMALIZATION\n # Normalize the header, remove the port (in case you're testing this on various TCP ports)\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n # Normalize the query arguments except for phpmyadmin\n if (req.http.Host ~ \"phpmyadmin\") {\n # no sorting here\n } else if (req.url !~ \"wp-admin\") {\n set req.url = std.querysort(req.url);\n }\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) { # set or append the client.ip to X-Forwarded-For header\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n # For mod_pagespeed (cp. https:\/\/developers.google.com\/speed\/pagespeed\/module\/downstream-caching)\n # Tell PageSpeed not to use optimizations specific to this request.\n set req.http.PS-CapabilityList = \"fully general optimizations only\";\n\n # Don't allow external entities to force beaconing.\n unset req.http.PS-ShouldBeacon;\n\n ## letsencrypt\n if (req.url ~ \"acme-challenge\") {\n return (pipe);\n }\n\n ## http to https\n\n if (\n (req.http.Host ~ \"alexa.20steps.de\")\n && req.http.X_FORWARDED_PROTO !~ \"(?i)https\") {\n if (\n # req.url !~ \"wp-admin\"\n # && req.url !~ \"wp-login\"\n # && req.url !~ \"secure\"\n # && req.url !~ \"well-known\"\n req.url !~ \"well-known\"\n ) {\n return (synth(750, \"\"));\n }\n }\n\n ## HOST MODIFICATION AND BACKEND SELECTION\n\n # default backend director\n set req.backend_hint = zone.backend(); # send all traffic to the apache_director\n\n # direct access to backend depending on Header\n if (req.http.X-Server-Select == \"alexa1\") {\n set req.backend_hint = alexa1;\n } else if (req.http.X-Server-Select == \"alexa2\") {\n # set req.backend_hint = alexa2;\n } else if (req.http.X-Server-Select == \"alexaj1\") {\n #set req.backend_hint = alexaj1;\n }\n\n if (req.http.Host ~ \"^job\\.\") {\n #set req.backend_hint = alexaj1;\n }\n\n\n # modify host and\/or backend depending on url for further processing\n\n # Normalize Accept-Encoding header\n # straight from the manual: https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/vary.html\n # TODO: Test if it's still needed, Varnish 4 now does this by itself if http_gzip_support = on\n # https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/compression.html\n # https:\/\/www.varnish-cache.org\/docs\/trunk\/phk\/gzip.html\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(avi|bmp|bz2|cssgz|doc|divx|eot|flv|gif|gz|ico|jpeg|jpg|jsgz|mp3|mp4|mpg|mpeg|mk[av]|mov|ogg|ogv|pdf|png|qt|rar|swf|tbz|woff|xz|zip|webp)$\") {\n # No point in compressing these\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n # unkown algorithm\n unset req.http.Accept-Encoding;\n }\n }\n\n\n ## HANDLING DEPENDING ON HTTP METHOD\n\n # Provide PURGE HTTP method\n if (req.method == \"PURGE\") {\n if (!client.ip ~ invalidators) { # purge is the ACL defined at the begining\n # Not from an allowed IP? Then die with an error.\n return (synth(405, \"Not allowed\"));\n }\n # If you got this stage (and didn't error out above), purge the cached result\n return (purge);\n }\n\n if (req.method == \"BAN\") {\n if (!client.ip ~ invalidators) {\n return (synth(405, \"Not allowed\"));\n }\n\n if (req.http.X-Cache-Tags) {\n ban(\"obj.http.X-Host ~ \" + req.http.X-Host\n + \" && obj.http.X-Url ~ \" + req.http.X-Url\n + \" && obj.http.content-type ~ \" + req.http.X-Content-Type\n + \" && obj.http.X-Cache-Tags ~ \" + req.http.X-Cache-Tags\n );\n } else {\n\t ban(\"obj.http.X-Host ~ \" + req.http.X-Host\n + \" && obj.http.X-Url ~ \" + req.http.X-Url\n \t+ \" && obj.http.content-type ~ \" + req.http.X-Content-Type\n \t );\n }\n\n return (synth(200, \"Banned\"));\n }\n\n \n\n # Only deal with \"normal\" types\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"PATCH\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n # Implementing websocket support (https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html)\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n # Only cache GET or HEAD requests. This makes sure the POST requests are always passed.\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n ## COOKIE HANDLING\n\n # Some generic URL manipulation, useful for all templates that follow\n # First remove the Google Analytics added parameters, useless for our backend\n if (req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=\") {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # Strip hash, server doesn't need it.\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n # Strip a trailing ? if it exists\n if (req.url ~ \"\\?$\") {\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # Some generic cookie manipulation, useful for all templates that follow\n # Remove the \"has_js\" cookie\n set req.http.Cookie = regsuball(req.http.Cookie, \"has_js=[^;]+(; )?\", \"\");\n\n # Remove any Google Analytics based cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__utm.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"_ga=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmctr=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmcmd.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmccn.=[^;]+(; )?\", \"\");\n\n # Remove DoubleClick offensive cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__gads=[^;]+(; )?\", \"\");\n\n # Remove the Quant Capital cookies (added by some plugin, all __qca)\n set req.http.Cookie = regsuball(req.http.Cookie, \"__qc.=[^;]+(; )?\", \"\");\n\n # Remove the AddThis cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__atuv.=[^;]+(; )?\", \"\");\n\n # Remove a \";\" prefix in the cookie if present\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n\n # Are there cookies left with only spaces or that are empty?\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n\n ## Allow for refreshing using <shift>+<reload> in browser\n if (req.http.Cache-Control ~ \"(?i)no-cache\" && client.ip ~ invalidators) { \n if (! (req.http.Via || req.http.User-Agent ~ \"(?i)bot\" || req.http.X-Purge)) {\n #set req.hash_always_miss = true; # Doesn't seems to refresh the object in the cache\n #return(purge); # Couple this with restart in vcl_purge and X-Purge header to avoid loops\n }\n }\n\n ## DO NOT CACHE APPLE APP SITE ASSOCIATIONS\n if (req.url ~ \"apple-app-site-association\") {\n return (pass);\n }\n\n ## DO NOT CACHE DEPENDING ON HOST\/URL\n\n # do not cache depending on host\/url\n if (\n req.url ~ \"^\/(wp-admin|admin)\"\n || req.url ~ \"(secure)\"\n || req.url ~ \"(raten|rechner|eAntrag)\"\n ) {\n return (pass);\n }\n\n ## REMOVE COOKIES AS PREREQUESTITE FOR CACHING DEPENDING ON TYPE\/URL\/HOST\n\n # Remove all cookies for static files\n # A valid discussion could be held on this line: do you really need to cache static files that don't cause load? Only if you have memory left.\n # Sure, there's disk I\/O, but chances are your OS will already have these files in their buffers (thus memory).\n # Before you blindly enable this, have a read here: http:\/\/mattiasgeniar.be\/2012\/11\/28\/stop-caching-static-files\/\n if (req.url ~ \"^[^?]*\\.(avi|bmp|bz2|css|cssgz|doc|divx|eot|flv|gif|gz|ico|jpeg|jpg|js|jsgz|less|mp3|mp4|mpg|mpeg|mk[av]|mov|ogg|ogv|pdf|png|qt|rar|rtf|swf|txt|tbz|woff|xml|xz|zip|webp)$\") {\n unset req.http.Cookie;\n return (hash);\n } else if (req.url ~ \"timthumb.php\") {\n unset req.http.Cookie;\n return (hash);\n }\n\n # Send Surrogate-Capability headers to announce ESI support to backend\n set req.http.Surrogate-Capability = \"key=ESI\/1.0\";\n\n # allow caching even when using Authorization\n #if (req.http.Authorization) {\n # # Not cacheable by default\n # return (pass);\n #}\n\n return (hash);\n}\n\nsub vcl_pipe {\n# Called upon entering pipe mode. In this mode, the request is passed on to the backend, and any further data from both the client and backend is passed on unaltered until either end closes the connection. Basically, Varnish will degrade into a simple TCP proxy, shuffling bytes back and forth. For a connection in pipe mode, no other VCL subroutine will ever get called after vcl_pipe.\n\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n # set bereq.http.connection = \"close\";\n # here. It is not set by default as it might break some broken web\n # applications, like IIS with NTLM authentication.\n\n #set bereq.http.Connection = \"Close\";\n\n # Implementing websocket support (https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html)\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n\n return (pipe);\n}\n\nsub vcl_pass {\n# Called upon entering pass mode. In this mode, the request is passed on to the backend, and the backend's response is passed on to the client, but is not entered into the cache. Subsequent requests submitted over the same client connection are handled normally.\n\n # return (pass);\n}\n\n# The data on which the hashing will take place\nsub vcl_hash {\n# Called after vcl_recv to create a hash value for the request. This is used as a key to look up the object in Varnish.\n\n hash_data(req.url);\n\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n\n # hash cookies for requests that have them\n if (req.http.Cookie) {\n hash_data(req.http.Cookie);\n }\n\n}\n\nsub vcl_hit {\n # Called when a cache lookup is successful.\n\n # mod_pagespeed\n # 5% of the time ignore that we got a cache hit and send the request to the\n # backend anyway for instrumentation.\n if (std.random(0, 100) < 5) {\n set req.http.PS-ShouldBeacon = \"futuresteps25\";\n return (pass);\n }\n\n if (obj.ttl >= 0s) {\n # A pure unadultered hit, deliver it\n return (deliver);\n }\n\n # https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-grace.html\n # When several clients are requesting the same page Varnish will send one request to the backend and place the others on hold while fetching one copy from the backend. In some products this is called request coalescing and Varnish does this automatically.\n # If you are serving thousands of hits per second the queue of waiting requests can get huge. There are two potential problems - one is a thundering herd problem - suddenly releasing a thousand threads to serve content might send the load sky high. Secondly - nobody likes to wait. To deal with this we can instruct Varnish to keep the objects in cache beyond their TTL and to serve the waiting requests somewhat stale content.\n\n# if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n# return (deliver);\n# } else {\n# return (fetch);\n# }\n\n # We have no fresh fish. Lets look at the stale ones.\n if (std.healthy(req.backend_hint)) {\n # Backend is healthy. Limit age to 10s.\n if (obj.ttl + 10s > 0s) {\n #set req.http.grace = \"normal(limited)\";\n return (deliver);\n } else {\n # No candidate for grace. Fetch a fresh object.\n\t return(fetch);\n }\n } else {\n # backend is sick - use full grace\n if (obj.ttl + obj.grace > 0s) {\n #set req.http.grace = \"full\";\n return (deliver);\n } else {\n # no graced object.\n return (fetch);\n }\n }\n\n\n # fetch & deliver once we get the result\n return (fetch); # Dead code, keep as a safeguard\n}\n\nsub vcl_miss {\n# Called after a cache lookup if the requested document was not found in the cache. Its purpose is to decide whether or not to attempt to retrieve the document from the backend, and which backend to use.\n\n # mod_pagespeed\n # Instrument 25% of cache misses.\n if (std.random(0, 100) < 25) {\n set req.http.PS-ShouldBeacon = \"futuresteps25\";\n return (pass);\n }\n\n return (fetch);\n}\n\n# Handle the HTTP request coming from our backend\nsub vcl_backend_response {\n# Called after the response headers has been successfully retrieved from the backend.\n\n # Set ban-lurker friendly custom headers\n set beresp.http.X-Url = bereq.url;\n set beresp.http.X-Host = bereq.http.host;\n\n if (beresp.status >= 400 || beresp.status >= 500) {\n set beresp.uncacheable = true;\n return (deliver);\n }\n\n # Pause ESI request and remove Surrogate-Control header\n if (beresp.http.Surrogate-Control ~ \"ESI\/1.0\") {\n unset beresp.http.Surrogate-Control;\n set beresp.do_esi = true;\n }\n\n # send json as text\/html instead of application\/json as MSIE wants to save the \"file\" otherwise\n if (bereq.url ~ \"bricks\/api\") {\n # set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n }\n \n # Enable cache for all static files\n # The same argument as the static caches from above: monitor your cache size, if you get data nuked out of it, consider giving up the static file cache.\n # Before you blindly enable this, have a read here: http:\/\/mattiasgeniar.be\/2012\/11\/28\/stop-caching-static-files\/\n if (bereq.url ~ \"^[^?]*\\.(avi|bmp|bz2|css|cssgz|doc|divx|eot|flv|gif|gz|ico|jpeg|jpg|js|jsgz|less|mp3|mp4|mpg|mpeg|mk[av]|mov|ogg|ogv|pdf|png|qt|rar|rtf|swf|txt|tbz|woff|xml|xz|zip|webp)$\") {\n set beresp.http.cache-control = \"max-age=604800\";\n unset beresp.http.set-cookie;\n unset beresp.http.expires;\n set beresp.http.cachable = \"1\";\n }\n\n # Large static files are delivered directly to the end-user without\n # waiting for Varnish to fully read the file first.\n # Varnish 4 fully supports Streaming, so use streaming here to avoid locking.\n if (bereq.url ~ \"^[^?]*\\.(mp[34]|rar|tar|tgz|gz|wav|zip|bz2|xz|7z|avi|mov|ogm|mpe?g|mk[av])(\\?.*)?$\") {\n unset beresp.http.set-cookie;\n set beresp.ttl = 3600s;\n unset beresp.http.expires;\n set beresp.http.cache-control = \"max-age=3600\";\n set beresp.http.cachable = \"1\";\n set beresp.do_stream = true; # Check memory usage it'll grow in fetch_chunksize blocks (128k by default) if\n # the backend doesn't send a Content-Length header, so only enable it for big objects\n set beresp.do_gzip = false; # Don't try to compress it for storage\n }\n\n # Sometimes, a 301 or 302 redirect formed via Apache's mod_rewrite can mess with the HTTP port that is being passed along.\n # This often happens with simple rewrite rules in a scenario where Varnish runs on :80 and Apache on :8080 on the same box.\n # A redirect can then often redirect the end-user to a URL on :8080, where it should be :80.\n # This may need finetuning on your setup.\n #\n # To prevent accidental replace, we only filter the 301\/302 redirects for now.\n if (beresp.status == 301 || beresp.status == 302) {\n set beresp.http.Location = regsub(beresp.http.Location, \":[0-9]+\", \"\");\n }\n\n # Set 2min cache if unset for static files\n if (beresp.ttl <= 0s || beresp.http.Set-Cookie || beresp.http.Vary == \"*\") {\n set beresp.ttl = 120s; # Important, you shouldn't rely on this, SET YOUR HEADERS in the backend\n set beresp.uncacheable = true;\n return (deliver);\n }\n\n # Allow stale content, in case the backend goes down.\n # make Varnish keep all objects for 6 hours beyond their TTL\n set beresp.grace = 0s;\n\n return (deliver);\n}\n\n# The routine when we deliver the HTTP request to the user\n# Last chance to modify headers that are sent to the client\nsub vcl_deliver {\n# Called before a cached object is delivered to the client.\n\n # Keep ban-lurker headers only if debugging is enabled\n if (!resp.http.X-Cache-Debug) {\n # Remove ban-lurker friendly custom headers when delivering to client\n unset resp.http.X-Url;\n unset resp.http.X-Host;\n unset resp.http.X-Cache-Tags;\n }\n # In Varnish 4 the obj.hits counter behaviour has changed, so we use a\n # different method: if X-Varnish contains only 1 id, we have a miss, if it\n # contains more (and therefore a space), we have a hit.\n if (resp.http.X-Cache-Debug) {\n if (resp.http.X-Varnish ~ \" \") {\n \tset resp.http.X-Cache = \"HIT\";\n } else {\n \tset resp.http.X-Cache = \"MISS\";\n }\n #if (obj.hits > 0) { # Add debug header to see if it's a HIT\/MISS and the number of hits, disable when not needed\n # set resp.http.X-Cache = \"HIT\";\n #} else {\n # set resp.http.X-Cache = \"MISS\";\n #}\n }\n\n # Please note that obj.hits behaviour changed in 4.0, now it counts per objecthead, not per object\n # and obj.hits may not be reset in some cases where bans are in use. See bug 1492 for details.\n # So take hits with a grain of salt\n set resp.http.X-Cache-Hits = obj.hits;\n\n # Remove some headers: PHP version\n unset resp.http.X-Powered-By;\n\n # Remove some headers: Apache version & OS\n unset resp.http.Server;\n unset resp.http.X-Drupal-Cache;\n unset resp.http.X-Varnish;\n unset resp.http.Via;\n unset resp.http.Link;\n\n set resp.http.Access-Control-Allow-Credentials = \"true\";\n set resp.http.Access-Control-Allow-Origin = \"*\";\n set resp.http.Access-Control-Expose-Headers = \"*\";\n set resp.http.Access-Control-Allow-Methods = \"GET, POST, OPTIONS, PUT, DELETE\";\n set resp.http.Access-Control-Allow-Headers = \"accept, content-type, authorization, pragma, cache-control, AuthorizationFF\";\n set resp.http.Access-Control-Max-Age = \"1728000\";\n\n return (deliver);\n}\n\nsub vcl_purge {\n # restart request\n #set req.http.X-Purge = \"Yes\";\n #return(restart);\n}\n\nsub vcl_synth {\n if (resp.status == 720) {\n # We use this special error status 720 to force redirects with 301 (permanent) redirects\n # To use this, call the following from anywhere in vcl_recv: error 720 \"http:\/\/host\/new.html\"\n set resp.status = 301;\n set resp.http.Location = resp.reason;\n return (deliver);\n } elseif (resp.status == 721) {\n # And we use error status 721 to force redirects with a 302 (temporary) redirect\n # To use this, call the following from anywhere in vcl_recv: error 720 \"http:\/\/host\/new.html\"\n set resp.status = 302;\n set resp.http.Location = resp.reason;\n return (deliver);\n } elseif (resp.status == 750) {\n set resp.status = 301;\n set resp.http.Location = \"https:\/\/\" + req.http.Host + req.url;\n return (deliver);\n }\n\n return (deliver);\n}\n\n\nsub vcl_fini {\n# Called when VCL is discarded only after all requests have exited the VCL. Typically used to clean up VMODs.\n\n return (ok);\n}","old_contents":"vcl 4.0;\n## Based on: https:\/\/github.com\/mattiasgeniar\/varnish-4.0-configuration-templates\/blob\/master\/default.vcl\n# Corrected & improved for 4.0.2 by jnerin@gmail.com\nimport std;\nimport directors;\n\ninclude \"badbot.vcl\";\n\nbackend alexa1 {\n .host = \"192.168.16.3\";\n .port = \"8080\";\n\n .max_connections = 300; # That's it\n .first_byte_timeout = 300s; # How long to wait before we receive a first byte from our backend?\n .connect_timeout = 5s; # How long to wait for a backend connection?\n .between_bytes_timeout = 2s; # How long to wait between bytes received from our backend?\n\n# .probe = {\n#\t .request =\n# \"GET \/robots.txt HTTP\/1.1\"\n# \"Host: admin.platform.bricks.20steps.de\"\n# \"Connection: close\";\n# .interval = 5s;\n# .timeout = 1s;\n# .window = 5;\n# .threshold = 3;\n# }\n}\n\n#backend alexa2 {\n# .host = \"192.168.13.20\";\n# .port = \"8080\";\n#\n# .max_connections = 300; # That's it\n# .first_byte_timeout = 300s; # How long to wait before we receive a first byte from our backend?\n# .connect_timeout = 5s; # How long to wait for a backend connection?\n# .between_bytes_timeout = 2s; # How long to wait between bytes received from our backend?\n#\n# .probe = {\n# .request =\n# \"GET \/robots.txt HTTP\/1.1\"\n# \"Host: admin.platform.bricks.20steps.de\"\n# \"Connection: close\";\n# .interval = 5s;\n# .timeout = 1s;\n# .window = 5;\n# .threshold = 3;\n# }\n#}\n\n\n#backend alexaj1 {\n# .host = \"192.168.14.17\";\n# .port = \"8080\";\n#\n# .max_connections = 300; # That's it\n# .first_byte_timeout = 300s; # How long to wait before we receive a first byte from our backend?\n# .connect_timeout = 5s; # How long to wait for a backend connection?\n# .between_bytes_timeout = 2s; # How long to wait between bytes received from our backend?\n#\n# .probe = {\n# .request =\n# \"GET \/robots.txt HTTP\/1.1\"\n# \"Host: admin.platform.bricks.20steps.de\"\n# \"Connection: close\";\n# .interval = 5s;\n# .timeout = 1s;\n# .window = 5;\n# .threshold = 3;\n# }\n#}\n\nacl invalidators {\n # ACL we'll use later to allow purges\n \"localhost\";\n \"127.0.0.1\";\n \"::1\";\n \"192.168.0.0\"\/16;\n}\n\nsub vcl_init {\n# Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n\n include \"director.vcl\";\n\n}\n\nsub vcl_recv {\n# Called at the beginning of a request, after the complete request has been received and parsed. Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use.\n# also used to modify the request\n\n call badbot;\n\n ## REQUEST NORMALIZATION\n # Normalize the header, remove the port (in case you're testing this on various TCP ports)\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n # Normalize the query arguments except for phpmyadmin\n if (req.http.Host ~ \"phpmyadmin\") {\n # no sorting here\n } else if (req.url !~ \"wp-admin\") {\n set req.url = std.querysort(req.url);\n }\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) { # set or append the client.ip to X-Forwarded-For header\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n # For mod_pagespeed (cp. https:\/\/developers.google.com\/speed\/pagespeed\/module\/downstream-caching)\n # Tell PageSpeed not to use optimizations specific to this request.\n set req.http.PS-CapabilityList = \"fully general optimizations only\";\n\n # Don't allow external entities to force beaconing.\n unset req.http.PS-ShouldBeacon;\n\n ## letsencrypt\n if (req.url ~ \"acme-challenge\") {\n return (pipe);\n }\n\n ## http to https\n\n if (\n (req.http.Host ~ \"alexa.20steps.de\")\n && req.http.X_FORWARDED_PROTO !~ \"(?i)https\") {\n if (\n # req.url !~ \"wp-admin\"\n # && req.url !~ \"wp-login\"\n # && req.url !~ \"secure\"\n # && req.url !~ \"well-known\"\n req.url !~ \"well-known\"\n ) {\n return (synth(750, \"\"));\n }\n }\n\n ## HOST MODIFICATION AND BACKEND SELECTION\n\n # default backend director\n set req.backend_hint = zone.backend(); # send all traffic to the apache_director\n\n # direct access to backend depending on Header\n if (req.http.X-Server-Select == \"alexa1\") {\n set req.backend_hint = alexa1;\n } else if (req.http.X-Server-Select == \"alexa2\") {\n # set req.backend_hint = alexa2;\n } else if (req.http.X-Server-Select == \"alexaj1\") {\n #set req.backend_hint = alexaj1;\n }\n\n if (req.http.Host ~ \"^job\\.\") {\n #set req.backend_hint = alexaj1;\n }\n\n\n # modify host and\/or backend depending on url for further processing\n\n # Normalize Accept-Encoding header\n # straight from the manual: https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/vary.html\n # TODO: Test if it's still needed, Varnish 4 now does this by itself if http_gzip_support = on\n # https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/compression.html\n # https:\/\/www.varnish-cache.org\/docs\/trunk\/phk\/gzip.html\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(avi|bmp|bz2|cssgz|doc|divx|eot|flv|gif|gz|ico|jpeg|jpg|jsgz|mp3|mp4|mpg|mpeg|mk[av]|mov|ogg|ogv|pdf|png|qt|rar|swf|tbz|woff|xz|zip|webp)$\") {\n # No point in compressing these\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n # unkown algorithm\n unset req.http.Accept-Encoding;\n }\n }\n\n\n ## HANDLING DEPENDING ON HTTP METHOD\n\n # Provide PURGE HTTP method\n if (req.method == \"PURGE\") {\n if (!client.ip ~ invalidators) { # purge is the ACL defined at the begining\n # Not from an allowed IP? Then die with an error.\n return (synth(405, \"Not allowed\"));\n }\n # If you got this stage (and didn't error out above), purge the cached result\n return (purge);\n }\n\n if (req.method == \"BAN\") {\n if (!client.ip ~ invalidators) {\n return (synth(405, \"Not allowed\"));\n }\n\n if (req.http.X-Cache-Tags) {\n ban(\"obj.http.X-Host ~ \" + req.http.X-Host\n + \" && obj.http.X-Url ~ \" + req.http.X-Url\n + \" && obj.http.content-type ~ \" + req.http.X-Content-Type\n + \" && obj.http.X-Cache-Tags ~ \" + req.http.X-Cache-Tags\n );\n } else {\n\t ban(\"obj.http.X-Host ~ \" + req.http.X-Host\n + \" && obj.http.X-Url ~ \" + req.http.X-Url\n \t+ \" && obj.http.content-type ~ \" + req.http.X-Content-Type\n \t );\n }\n\n return (synth(200, \"Banned\"));\n }\n\n \n\n # Only deal with \"normal\" types\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"PATCH\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n # Implementing websocket support (https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html)\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n # Only cache GET or HEAD requests. This makes sure the POST requests are always passed.\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n ## COOKIE HANDLING\n\n # Some generic URL manipulation, useful for all templates that follow\n # First remove the Google Analytics added parameters, useless for our backend\n if (req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=\") {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # Strip hash, server doesn't need it.\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n # Strip a trailing ? if it exists\n if (req.url ~ \"\\?$\") {\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # Some generic cookie manipulation, useful for all templates that follow\n # Remove the \"has_js\" cookie\n set req.http.Cookie = regsuball(req.http.Cookie, \"has_js=[^;]+(; )?\", \"\");\n\n # Remove any Google Analytics based cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__utm.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"_ga=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmctr=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmcmd.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmccn.=[^;]+(; )?\", \"\");\n\n # Remove DoubleClick offensive cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__gads=[^;]+(; )?\", \"\");\n\n # Remove the Quant Capital cookies (added by some plugin, all __qca)\n set req.http.Cookie = regsuball(req.http.Cookie, \"__qc.=[^;]+(; )?\", \"\");\n\n # Remove the AddThis cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__atuv.=[^;]+(; )?\", \"\");\n\n # Remove a \";\" prefix in the cookie if present\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n\n # Are there cookies left with only spaces or that are empty?\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n\n ## Allow for refreshing using <shift>+<reload> in browser\n if (req.http.Cache-Control ~ \"(?i)no-cache\" && client.ip ~ invalidators) { \n if (! (req.http.Via || req.http.User-Agent ~ \"(?i)bot\" || req.http.X-Purge)) {\n #set req.hash_always_miss = true; # Doesn't seems to refresh the object in the cache\n #return(purge); # Couple this with restart in vcl_purge and X-Purge header to avoid loops\n }\n }\n\n ## DO NOT CACHE APPLE APP SITE ASSOCIATIONS\n if (req.url ~ \"apple-app-site-association\") {\n return (pass);\n }\n\n ## DO NOT CACHE DEPENDING ON HOST\/URL\n\n # do not cache depending on host\/url\n if (\n req.url ~ \"^\/(wp-admin|admin)\"\n || req.url ~ \"(secure)\"\n || req.url ~ \"(raten|rechner|eAntrag)\"\n ) {\n return (pass);\n }\n\n ## REMOVE COOKIES AS PREREQUESTITE FOR CACHING DEPENDING ON TYPE\/URL\/HOST\n\n # Remove all cookies for static files\n # A valid discussion could be held on this line: do you really need to cache static files that don't cause load? Only if you have memory left.\n # Sure, there's disk I\/O, but chances are your OS will already have these files in their buffers (thus memory).\n # Before you blindly enable this, have a read here: http:\/\/mattiasgeniar.be\/2012\/11\/28\/stop-caching-static-files\/\n if (req.url ~ \"^[^?]*\\.(avi|bmp|bz2|css|cssgz|doc|divx|eot|flv|gif|gz|ico|jpeg|jpg|js|jsgz|less|mp3|mp4|mpg|mpeg|mk[av]|mov|ogg|ogv|pdf|png|qt|rar|rtf|swf|txt|tbz|woff|xml|xz|zip|webp)$\") {\n unset req.http.Cookie;\n return (hash);\n } else if (req.url ~ \"timthumb.php\") {\n unset req.http.Cookie;\n return (hash);\n }\n\n # Send Surrogate-Capability headers to announce ESI support to backend\n set req.http.Surrogate-Capability = \"key=ESI\/1.0\";\n\n # allow caching even when using Authorization\n #if (req.http.Authorization) {\n # # Not cacheable by default\n # return (pass);\n #}\n\n #return (hash);\n}\n\nsub vcl_pipe {\n# Called upon entering pipe mode. In this mode, the request is passed on to the backend, and any further data from both the client and backend is passed on unaltered until either end closes the connection. Basically, Varnish will degrade into a simple TCP proxy, shuffling bytes back and forth. For a connection in pipe mode, no other VCL subroutine will ever get called after vcl_pipe.\n\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n # set bereq.http.connection = \"close\";\n # here. It is not set by default as it might break some broken web\n # applications, like IIS with NTLM authentication.\n\n #set bereq.http.Connection = \"Close\";\n\n # Implementing websocket support (https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html)\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n\n return (pipe);\n}\n\nsub vcl_pass {\n# Called upon entering pass mode. In this mode, the request is passed on to the backend, and the backend's response is passed on to the client, but is not entered into the cache. Subsequent requests submitted over the same client connection are handled normally.\n\n # return (pass);\n}\n\n# The data on which the hashing will take place\nsub vcl_hash {\n# Called after vcl_recv to create a hash value for the request. This is used as a key to look up the object in Varnish.\n\n hash_data(req.url);\n\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n\n # hash cookies for requests that have them\n if (req.http.Cookie) {\n hash_data(req.http.Cookie);\n }\n\n}\n\nsub vcl_hit {\n # Called when a cache lookup is successful.\n\n # mod_pagespeed\n # 5% of the time ignore that we got a cache hit and send the request to the\n # backend anyway for instrumentation.\n if (std.random(0, 100) < 5) {\n set req.http.PS-ShouldBeacon = \"futuresteps25\";\n return (pass);\n }\n\n if (obj.ttl >= 0s) {\n # A pure unadultered hit, deliver it\n return (deliver);\n }\n\n # https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-grace.html\n # When several clients are requesting the same page Varnish will send one request to the backend and place the others on hold while fetching one copy from the backend. In some products this is called request coalescing and Varnish does this automatically.\n # If you are serving thousands of hits per second the queue of waiting requests can get huge. There are two potential problems - one is a thundering herd problem - suddenly releasing a thousand threads to serve content might send the load sky high. Secondly - nobody likes to wait. To deal with this we can instruct Varnish to keep the objects in cache beyond their TTL and to serve the waiting requests somewhat stale content.\n\n# if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n# return (deliver);\n# } else {\n# return (fetch);\n# }\n\n # We have no fresh fish. Lets look at the stale ones.\n if (std.healthy(req.backend_hint)) {\n # Backend is healthy. Limit age to 10s.\n if (obj.ttl + 10s > 0s) {\n #set req.http.grace = \"normal(limited)\";\n return (deliver);\n } else {\n # No candidate for grace. Fetch a fresh object.\n\t return(fetch);\n }\n } else {\n # backend is sick - use full grace\n if (obj.ttl + obj.grace > 0s) {\n #set req.http.grace = \"full\";\n return (deliver);\n } else {\n # no graced object.\n return (fetch);\n }\n }\n\n\n # fetch & deliver once we get the result\n return (fetch); # Dead code, keep as a safeguard\n}\n\nsub vcl_miss {\n# Called after a cache lookup if the requested document was not found in the cache. Its purpose is to decide whether or not to attempt to retrieve the document from the backend, and which backend to use.\n\n # mod_pagespeed\n # Instrument 25% of cache misses.\n if (std.random(0, 100) < 25) {\n set req.http.PS-ShouldBeacon = \"futuresteps25\";\n return (pass);\n }\n\n return (fetch);\n}\n\n# Handle the HTTP request coming from our backend\nsub vcl_backend_response {\n# Called after the response headers has been successfully retrieved from the backend.\n\n # Set ban-lurker friendly custom headers\n set beresp.http.X-Url = bereq.url;\n set beresp.http.X-Host = bereq.http.host;\n\n if (beresp.status >= 400 || beresp.status >= 500) {\n set beresp.uncacheable = true;\n return (deliver);\n }\n\n # Pause ESI request and remove Surrogate-Control header\n if (beresp.http.Surrogate-Control ~ \"ESI\/1.0\") {\n unset beresp.http.Surrogate-Control;\n set beresp.do_esi = true;\n }\n\n # send json as text\/html instead of application\/json as MSIE wants to save the \"file\" otherwise\n if (bereq.url ~ \"bricks\/api\") {\n # set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n }\n \n # Enable cache for all static files\n # The same argument as the static caches from above: monitor your cache size, if you get data nuked out of it, consider giving up the static file cache.\n # Before you blindly enable this, have a read here: http:\/\/mattiasgeniar.be\/2012\/11\/28\/stop-caching-static-files\/\n if (bereq.url ~ \"^[^?]*\\.(avi|bmp|bz2|css|cssgz|doc|divx|eot|flv|gif|gz|ico|jpeg|jpg|js|jsgz|less|mp3|mp4|mpg|mpeg|mk[av]|mov|ogg|ogv|pdf|png|qt|rar|rtf|swf|txt|tbz|woff|xml|xz|zip|webp)$\") {\n set beresp.http.cache-control = \"max-age=604800\";\n unset beresp.http.set-cookie;\n unset beresp.http.expires;\n set beresp.http.cachable = \"1\";\n }\n\n # Large static files are delivered directly to the end-user without\n # waiting for Varnish to fully read the file first.\n # Varnish 4 fully supports Streaming, so use streaming here to avoid locking.\n if (bereq.url ~ \"^[^?]*\\.(mp[34]|rar|tar|tgz|gz|wav|zip|bz2|xz|7z|avi|mov|ogm|mpe?g|mk[av])(\\?.*)?$\") {\n unset beresp.http.set-cookie;\n set beresp.ttl = 3600s;\n unset beresp.http.expires;\n set beresp.http.cache-control = \"max-age=3600\";\n set beresp.http.cachable = \"1\";\n set beresp.do_stream = true; # Check memory usage it'll grow in fetch_chunksize blocks (128k by default) if\n # the backend doesn't send a Content-Length header, so only enable it for big objects\n set beresp.do_gzip = false; # Don't try to compress it for storage\n }\n\n # Sometimes, a 301 or 302 redirect formed via Apache's mod_rewrite can mess with the HTTP port that is being passed along.\n # This often happens with simple rewrite rules in a scenario where Varnish runs on :80 and Apache on :8080 on the same box.\n # A redirect can then often redirect the end-user to a URL on :8080, where it should be :80.\n # This may need finetuning on your setup.\n #\n # To prevent accidental replace, we only filter the 301\/302 redirects for now.\n if (beresp.status == 301 || beresp.status == 302) {\n set beresp.http.Location = regsub(beresp.http.Location, \":[0-9]+\", \"\");\n }\n\n # Set 2min cache if unset for static files\n if (beresp.ttl <= 0s || beresp.http.Set-Cookie || beresp.http.Vary == \"*\") {\n set beresp.ttl = 120s; # Important, you shouldn't rely on this, SET YOUR HEADERS in the backend\n set beresp.uncacheable = true;\n return (deliver);\n }\n\n # Allow stale content, in case the backend goes down.\n # make Varnish keep all objects for 6 hours beyond their TTL\n set beresp.grace = 0s;\n\n return (deliver);\n}\n\n# The routine when we deliver the HTTP request to the user\n# Last chance to modify headers that are sent to the client\nsub vcl_deliver {\n# Called before a cached object is delivered to the client.\n\n # Keep ban-lurker headers only if debugging is enabled\n if (!resp.http.X-Cache-Debug) {\n # Remove ban-lurker friendly custom headers when delivering to client\n unset resp.http.X-Url;\n unset resp.http.X-Host;\n unset resp.http.X-Cache-Tags;\n }\n # In Varnish 4 the obj.hits counter behaviour has changed, so we use a\n # different method: if X-Varnish contains only 1 id, we have a miss, if it\n # contains more (and therefore a space), we have a hit.\n if (resp.http.X-Cache-Debug) {\n if (resp.http.X-Varnish ~ \" \") {\n \tset resp.http.X-Cache = \"HIT\";\n } else {\n \tset resp.http.X-Cache = \"MISS\";\n }\n #if (obj.hits > 0) { # Add debug header to see if it's a HIT\/MISS and the number of hits, disable when not needed\n # set resp.http.X-Cache = \"HIT\";\n #} else {\n # set resp.http.X-Cache = \"MISS\";\n #}\n }\n\n # Please note that obj.hits behaviour changed in 4.0, now it counts per objecthead, not per object\n # and obj.hits may not be reset in some cases where bans are in use. See bug 1492 for details.\n # So take hits with a grain of salt\n set resp.http.X-Cache-Hits = obj.hits;\n\n # Remove some headers: PHP version\n unset resp.http.X-Powered-By;\n\n # Remove some headers: Apache version & OS\n unset resp.http.Server;\n unset resp.http.X-Drupal-Cache;\n unset resp.http.X-Varnish;\n unset resp.http.Via;\n unset resp.http.Link;\n\n set resp.http.Access-Control-Allow-Credentials = \"true\";\n set resp.http.Access-Control-Allow-Origin = \"*\";\n set resp.http.Access-Control-Expose-Headers = \"*\";\n set resp.http.Access-Control-Allow-Methods = \"GET, POST, OPTIONS, PUT, DELETE\";\n set resp.http.Access-Control-Allow-Headers = \"accept, content-type, authorization, pragma, cache-control, AuthorizationFF\";\n set resp.http.Access-Control-Max-Age = \"1728000\";\n\n return (deliver);\n}\n\nsub vcl_purge {\n # restart request\n #set req.http.X-Purge = \"Yes\";\n #return(restart);\n}\n\nsub vcl_synth {\n if (resp.status == 720) {\n # We use this special error status 720 to force redirects with 301 (permanent) redirects\n # To use this, call the following from anywhere in vcl_recv: error 720 \"http:\/\/host\/new.html\"\n set resp.status = 301;\n set resp.http.Location = resp.reason;\n return (deliver);\n } elseif (resp.status == 721) {\n # And we use error status 721 to force redirects with a 302 (temporary) redirect\n # To use this, call the following from anywhere in vcl_recv: error 720 \"http:\/\/host\/new.html\"\n set resp.status = 302;\n set resp.http.Location = resp.reason;\n return (deliver);\n } elseif (resp.status == 750) {\n set resp.status = 301;\n set resp.http.Location = \"https:\/\/\" + req.http.Host + req.url;\n return (deliver);\n }\n\n return (deliver);\n}\n\n\nsub vcl_fini {\n# Called when VCL is discarded only after all requests have exited the VCL. Typically used to clean up VMODs.\n\n return (ok);\n}","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"b6de1ab7c2cc806575c80472382caa23494262b7","subject":"84 - un-amazeeio-ify some more","message":"84 - un-amazeeio-ify some more\n","repos":"amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon","old_file":"images\/varnish\/default.vcl","new_file":"images\/varnish\/default.vcl","new_contents":"","old_contents":"","returncode":0,"stderr":"unknown","license":"apache-2.0","lang":"VCL"} {"commit":"63728f8839d47b308fd269cfc5bac2d2ff8a7f16","subject":"Update the XHTML in the default guru page.","message":"Update the XHTML in the default guru page.\n\nSubmitted by:\tmattrobenolt\nApproved by:\tmithradir\n","repos":"feld\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,gquintard\/Varnish-Cache,alarky\/varnish-cache-doc-ja,mrhmouse\/Varnish-Cache,gquintard\/Varnish-Cache,varnish\/Varnish-Cache,mrhmouse\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,zhoualbeart\/Varnish-Cache,franciscovg\/Varnish-Cache,mrhmouse\/Varnish-Cache,varnish\/Varnish-Cache,franciscovg\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,gquintard\/Varnish-Cache,franciscovg\/Varnish-Cache,varnish\/Varnish-Cache,alarky\/varnish-cache-doc-ja,zhoualbeart\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,alarky\/varnish-cache-doc-ja,varnish\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,zhoualbeart\/Varnish-Cache,feld\/Varnish-Cache,mrhmouse\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,franciscovg\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,alarky\/varnish-cache-doc-ja,zhoualbeart\/Varnish-Cache,alarky\/varnish-cache-doc-ja,feld\/Varnish-Cache,varnish\/Varnish-Cache,chrismoulton\/Varnish-Cache,gquintard\/Varnish-Cache,feld\/Varnish-Cache,chrismoulton\/Varnish-Cache,chrismoulton\/Varnish-Cache,chrismoulton\/Varnish-Cache,chrismoulton\/Varnish-Cache,feld\/Varnish-Cache,zhoualbeart\/Varnish-Cache,franciscovg\/Varnish-Cache,mrhmouse\/Varnish-Cache","old_file":"bin\/varnishd\/builtin.vcl","new_file":"bin\/varnishd\/builtin.vcl","new_contents":"\/*-\n * Copyright (c) 2006 Verdens Gang AS\n * Copyright (c) 2006-2014 Varnish Software AS\n * All rights reserved.\n *\n * Author: Poul-Henning Kamp <phk@phk.freebsd.dk>\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in the\n * documentation and\/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n\n *\n * The built-in (previously called default) VCL code.\n *\n * NB! You do NOT need to copy & paste all of these functions into your\n * own vcl code, if you do not provide a definition of one of these\n * functions, the compiler will automatically fall back to the default\n * code from this file.\n *\n * This code will be prefixed with a backend declaration built from the\n * -b argument.\n *\/\n\nvcl 4.0;\n\n#######################################################################\n# Client side\n\nsub vcl_recv {\n if (req.method == \"PRI\") {\n\t\/* We do not support SPDY or HTTP\/2.0 *\/\n\treturn (synth(405));\n }\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization || req.http.Cookie) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n return (hash);\n}\n\nsub vcl_pipe {\n # By default Connection: close is set on all piped requests, to stop\n # connection reuse from sending future requests directly to the\n # (potentially) wrong backend. If you do want this to happen, you can undo\n # it here.\n # unset bereq.http.connection;\n return (pipe);\n}\n\nsub vcl_pass {\n return (fetch);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n return (lookup);\n}\n\nsub vcl_purge {\n return (synth(200, \"Purged\"));\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n \/\/ A pure unadultered hit, deliver it\n return (deliver);\n }\n if (obj.ttl + obj.grace > 0s) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n return (deliver);\n }\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\nsub vcl_miss {\n return (fetch);\n}\n\nsub vcl_deliver {\n return (deliver);\n}\n\n\/*\n * We can come here \"invisibly\" with the following errors: 413, 417 & 503\n *\/\nsub vcl_synth {\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n set resp.http.Retry-After = \"5\";\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n return (deliver);\n}\n\n#######################################################################\n# Backend Fetch\n\nsub vcl_backend_fetch {\n return (fetch);\n}\n\nsub vcl_backend_response {\n if (beresp.ttl <= 0s ||\n beresp.http.Set-Cookie ||\n beresp.http.Surrogate-control ~ \"no-store\" ||\n (!beresp.http.Surrogate-Control &&\n beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n beresp.http.Vary == \"*\") {\n \/*\n * Mark as \"Hit-For-Pass\" for the next 2 minutes\n *\/\n set beresp.ttl = 120s;\n set beresp.uncacheable = true;\n }\n return (deliver);\n}\n\nsub vcl_backend_error {\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + beresp.status + \" \" + beresp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + beresp.status + \" \" + beresp.reason + {\"<\/h1>\n <p>\"} + beresp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + bereq.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n return (deliver);\n}\n\n#######################################################################\n# Housekeeping\n\nsub vcl_init {\n return (ok);\n}\n\nsub vcl_fini {\n return (ok);\n}\n","old_contents":"\/*-\n * Copyright (c) 2006 Verdens Gang AS\n * Copyright (c) 2006-2014 Varnish Software AS\n * All rights reserved.\n *\n * Author: Poul-Henning Kamp <phk@phk.freebsd.dk>\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in the\n * documentation and\/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n\n *\n * The built-in (previously called default) VCL code.\n *\n * NB! You do NOT need to copy & paste all of these functions into your\n * own vcl code, if you do not provide a definition of one of these\n * functions, the compiler will automatically fall back to the default\n * code from this file.\n *\n * This code will be prefixed with a backend declaration built from the\n * -b argument.\n *\/\n\nvcl 4.0;\n\n#######################################################################\n# Client side\n\nsub vcl_recv {\n if (req.method == \"PRI\") {\n\t\/* We do not support SPDY or HTTP\/2.0 *\/\n\treturn (synth(405));\n }\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization || req.http.Cookie) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n return (hash);\n}\n\nsub vcl_pipe {\n # By default Connection: close is set on all piped requests, to stop\n # connection reuse from sending future requests directly to the\n # (potentially) wrong backend. If you do want this to happen, you can undo\n # it here.\n # unset bereq.http.connection;\n return (pipe);\n}\n\nsub vcl_pass {\n return (fetch);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n return (lookup);\n}\n\nsub vcl_purge {\n return (synth(200, \"Purged\"));\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n \/\/ A pure unadultered hit, deliver it\n return (deliver);\n }\n if (obj.ttl + obj.grace > 0s) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n return (deliver);\n }\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\nsub vcl_miss {\n return (fetch);\n}\n\nsub vcl_deliver {\n return (deliver);\n}\n\n\/*\n * We can come here \"invisibly\" with the following errors: 413, 417 & 503\n *\/\nsub vcl_synth {\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n set resp.http.Retry-After = \"5\";\n synthetic( {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n return (deliver);\n}\n\n#######################################################################\n# Backend Fetch\n\nsub vcl_backend_fetch {\n return (fetch);\n}\n\nsub vcl_backend_response {\n if (beresp.ttl <= 0s ||\n beresp.http.Set-Cookie ||\n beresp.http.Surrogate-control ~ \"no-store\" ||\n (!beresp.http.Surrogate-Control &&\n beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n beresp.http.Vary == \"*\") {\n \/*\n * Mark as \"Hit-For-Pass\" for the next 2 minutes\n *\/\n set beresp.ttl = 120s;\n set beresp.uncacheable = true;\n }\n return (deliver);\n}\n\nsub vcl_backend_error {\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} + beresp.status + \" \" + beresp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + beresp.status + \" \" + beresp.reason + {\"<\/h1>\n <p>\"} + beresp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + bereq.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n return (deliver);\n}\n\n#######################################################################\n# Housekeeping\n\nsub vcl_init {\n return (ok);\n}\n\nsub vcl_fini {\n return (ok);\n}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"2fe9e60a82ec1a3864f47d0d36974bffa99891a9","subject":"Update main.vcl","message":"Update main.vcl","repos":"JakeChampion\/polyfill-service,JakeChampion\/polyfill-service","old_file":"fastly\/vcl\/main.vcl","new_file":"fastly\/vcl\/main.vcl","new_contents":"import querystring;\n\nsub sort_comma_separated_value {\n\t# This function takes a CSV and tranforms it into a url where each\n\t# comma-separated-value is a query-string parameter and then uses\n\t# Fastly's querystring.sort function to sort the values. Once sorted\n\t# it then turn the query-parameters back into a CSV.\n\t# Set the CSV on the header `Sort-Value`.\n\t# Returns the sorted CSV on the header `Sorted-Value`.\n\tdeclare local var.value STRING;\n\tset var.value = req.http.Sort-value;\n\n\t# If query value does not exist or is empty, set it to \"\"\n\tset var.value = if(var.value != \"\", var.value, \"\");\n\n\t# Replace all `&` characters with `^`, this is because `&` would break the value up into pieces.\n\tset var.value = regsuball(var.value, \"&\", \"^\");\n\n\t# Replace all `,` characters with `&` to break them into individual query values\n\t# Append `1-` infront of all the query values to make them simpler to transform later\n\tset var.value = \"1-\" regsuball(var.value, \",\", \"&1-\");\n\n\t# Create a querystring-like string in order for querystring.sort to work.\n\tset var.value = querystring.sort(\"?\" var.value);\n\n\t# Grab all the query values from the sorted url\n\tset var.value = regsub(var.value, \"\\?\", \"\");\n\n\t# Reverse all the previous transformations to get back the single `features` query value value\n\tset var.value = regsuball(var.value, \"1-\", \"\");\n\tset var.value = regsuball(var.value, \"&\", \",\");\n\tset var.value = regsuball(var.value, \"\\^\", \"&\");\n\n\tset req.http.Sorted-Value = var.value;\n}\n\nsub normalise_querystring_parameters_for_polyfill_bundle {\n\t# Store the url without the querystring into a temporary header.\n\tdeclare local var.url STRING;\n\tset var.url = querystring.remove(req.url);\n\n\tdeclare local var.querystring STRING;\n\tset var.querystring = \"?\";\n\n\t# Remove all querystring parameters which are not part of the public API.\n\t# set req.url = querystring.regfilter_except(req.url, \"^(features|excludes|rum|unknown|flags|version|ua|callback|compression)$\");\n\n\t# (?i) makes the regex case-insensitive\n\t# The regex will match only if their are characters after `features=` which are not an ampersand (&).\n\tif (req.url.qs ~ \"(?i)[^&=]*features=([^&]+)\") {\n\t\t# Parameter has already been set, use the already set value.\n\t\t# re.group.1 is the first regex capture group in the regex above.\n\t\tif (std.strlen(re.group.1) < 100) {\n\t\t\t# We add the value of the features parameter to this header\n\t\t\t# This is to be able to have sort_comma_separated_value sort the value\n\t\t\tset req.http.Sort-Value = urldecode(re.group.1);\n\t\t\tcall sort_comma_separated_value;\n\t\t\t# The header Sorted-Value now contains the sorted version of the features parameter.\n\t\t\tset var.querystring = querystring.set(var.querystring, \"features\", req.http.Sorted-Value);\n\t\t} else {\n\t\t\tset var.querystring = querystring.set(var.querystring, \"features\", urldecode(re.group.1));\n\t\t}\n\t} else {\n\t\t# Parameter has not been set, use the default value.\n\t\tset var.querystring = querystring.set(var.querystring, \"features\", \"default\");\n\t}\n\n\t# (?i) makes the regex case-insensitive\n\t# The regex will match only if their are characters after `excludes=` which are not an ampersand (&).\n\tif (req.url.qs ~ \"(?i)[^&=]*excludes=([^&]+)\") {\n\t\t# Parameter has already been set, use the already set value.\n\t\t# re.group.1 is the first regex capture group in the regex above.\n\t\tif (std.strlen(re.group.1) < 100) {\n\t\t\t# We add the value of the excludes parameter to this header\n\t\t\t# This is to be able to have sort_comma_separated_value sort the value\n\t\t\tset req.http.Sort-Value = urldecode(re.group.1);\n\t\t\tcall sort_comma_separated_value;\n\t\t\t# The header Sorted-Value now contains the sorted version of the excludes parameter.\n\t\t\tset var.querystring = querystring.set(var.querystring, \"excludes\", req.http.Sorted-Value);\n\t\t} else {\n\t\t\tset var.querystring = querystring.set(var.querystring, \"excludes\", urldecode(re.group.1));\n\t\t}\n\t} else {\n\t\t# If excludes is not set, set to default value \"\"\n\t\tset var.querystring = var.querystring \"&excludes=\";\n\t}\n\n\t# If rum is not set, set to default value \"0\"\n\tif (req.url.qs !~ \"(?i)[^&=]*rum=([^&]+)\") {\n\t\tset var.querystring = querystring.set(var.querystring, \"rum\", \"0\");\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"rum\", re.group.1);\n\t}\n\n\t# If unknown is not set, set to default value \"polyfill\"\n\tif (req.url.qs !~ \"(?i)[^&=]*unknown=([^&]+)\") {\n\t\tset var.querystring = querystring.set(var.querystring, \"unknown\", \"polyfill\");\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"unknown\", re.group.1);\n\t}\n\n\t# If flags is not set, set to default value \"\"\n\tif (req.url.qs !~ \"(?i)[^&=]*flags=([^&]+)\") {\n\t\tset var.querystring = var.querystring \"&flags=\";\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"flags\", urldecode(re.group.1));\n\t}\n\n\t# If version is not set, set to default value \"\"\n\tdeclare local var.version STRING;\n\tif (req.url.qs !~ \"(?i)[^&=]*version=([^&]+)\") {\n\t\tset var.querystring = var.querystring \"&version=\";\n\t} else {\n\t\tif (re.group.1 == \"3.111.0\" || re.group.1 == \"3.110.1\" || re.group.1 == \"3.109.0\" || re.group.1 == \"3.108.0\" || re.group.1 == \"3.104.0\" || re.group.1 == \"3.103.0\" || re.group.1 == \"3.101.0\" || re.group.1 == \"3.98.0\" || re.group.1 == \"3.96.0\" || re.group.1 == \"3.89.4\" || re.group.1 == \"3.53.1\" || re.group.1 == \"3.52.3\" || re.group.1 == \"3.52.2\" || re.group.1 == \"3.52.1\" || re.group.1 == \"3.52.0\" || re.group.1 == \"3.51.0\" || re.group.1 == \"3.50.2\" || re.group.1 == \"3.48.0\" || re.group.1 == \"3.46.0\" || re.group.1 == \"3.42.0\" || re.group.1 == \"3.41.0\" || re.group.1 == \"3.40.0\" || re.group.1 == \"3.39.0\" || re.group.1 == \"3.34.0\" || re.group.1 == \"3.27.4\" || re.group.1 == \"3.25.1\") {\n\t\t\tset var.querystring = querystring.set(var.querystring, \"version\", re.group.1);\n\t\t} else {\n\t\t\tset var.querystring = var.querystring \"&version=\";\n\t\t}\n\t}\n\n\t# If ua is not set, normalise the User-Agent header based upon the version of the polyfill-library that has been requested.\n\tif (req.url.qs !~ \"(?i)[^&=]*ua=([^&]+)\") {\n\t\tif (req.url.qs ~ \"(?i)[^&=]*version=3\\.25\\.1(&|$)\") {\n\t\t\tcall normalise_user_agent_3_25_1;\n\t\t} else {\n\t\t\tcall normalise_user_agent_1_10_2;\n\t\t}\n\t\tset var.querystring = querystring.set(var.querystring, \"ua\", req.http.Normalized-User-Agent);\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"ua\", urldecode(re.group.1));\n\t}\n\n\t# If callback is not set, set to default value \"\"\n\tif (req.url.qs !~ \"(?i)[^&=]*callback=([^&]+)\") {\n\t\tset var.querystring = var.querystring \"&callback=\";\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"callback\", re.group.1);\n\t}\n\n\t# If compression is not set, use the best compression that the user-agent supports.\n\tif (req.url.qs !~ \"(?i)[^&=]*compression=([^&]+)\") {\n\t\t# When Fastly adds Brotli into the Accept-Encoding normalisation we can replace this with:\n\t\t# `set var.querystring = querystring.set(var.querystring, \"compression\", req.http.Accept-Encoding || \"\")`\n\n\t\t# Before SP2, IE\/6 doesn't always read and cache gzipped content correctly.\n\t\tif (req.http.Fastly-Orig-Accept-Encoding && req.http.User-Agent !~ \"MSIE 6\") {\n\t\t\tif (req.http.Fastly-Orig-Accept-Encoding ~ \"br\") {\n\t\t\t\tset var.querystring = querystring.set(var.querystring, \"compression\", \"br\");\n\t\t\t} elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"gzip\") {\n\t\t\t\tset var.querystring = querystring.set(var.querystring, \"compression\", \"gzip\");\n\t\t\t} else {\n\t\t\t\tset var.querystring = var.querystring \"&compression=\";\n\t\t\t}\n\t\t} else {\n\t\t\tset var.querystring = var.querystring \"&compression=\";\n\t\t}\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"compression\", re.group.1);\n\t}\n\tset req.url = var.url var.querystring;\n}\n\ninclude \"top_pops.vcl\";\ninclude \"normalise-user-agent-3-25-1.vcl\";\ninclude \"normalise-user-agent.vcl\";\n\n# The Fastly VCL boilerplate.\ninclude \"fastly-boilerplate-begin.vcl\";\n\ninclude \"breadcrumbs.vcl\";\n\nsub vcl_recv {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_recv;\n\t}\n}\n\nsub vcl_recv {\n\t# js-compute-runtime currently can not handle a uri which is bigger than 1024\n\t# this has been fixed in js-compute-runtime but not yet released -- https:\/\/github.com\/fastly\/js-compute-runtime\/commit\/f36dee28789b1187652874fe76d1801c9a8e5974\n\t# when the fix is released and added into @fastly\/js-compute we can remove this if statement\n\tif (std.strlen(req.url) < 900) {\n\t\t# We use this edge dictionary item as a flag for whether to use compute-at-edge for any requests.\n\t\t# If the item is not found, then we default to `\"0\"`, which we interpret to mean the flag is off.\n\t\tdeclare local var.compute-at-edge-active BOOL;\n\t\tif (std.atoi(table.lookup(compute_at_edge_config, \"active\", \"0\")) == 1) {\n\t\t\tset var.compute-at-edge-active = true;\n\t\t} else {\n\t\t\tset var.compute-at-edge-active = false;\n\t\t}\n\t\tif (var.compute-at-edge-active) {\n\t\t\t# if the querystring parameter `use-compute-at-edge-backend` is set to yes`\n\t\t\t# then use the c@e backend.\n\t\t\t# The querystring parameter is used within our tests, so that we can confirm\n\t\t\t# the compute-at-edge backend is working as we expect it to.\n\t\t\tdeclare local var.use-compute-at-edge-backend STRING;\n\t\t\tset var.use-compute-at-edge-backend = querystring.get(req.url, \"use-compute-at-edge-backend\");\n\t\t\tif (var.use-compute-at-edge-backend == \"yes\") {\n\t\t\t\tset req.backend = F_compute_at_edge;\n\t\t\t\tif (req.backend.healthy) {\n\t\t\t\t\t# if using the c@e backend then do not use the cache at all\n\t\t\t\t\treturn(pass);\n\t\t\t\t}\n\t\t\t# requests can set the querystring parameter to `no` to avoid ever user compute-at-edge\n\t\t\t# if the querystring parameter is not set to no, then we run some logic to decide whether\n\t\t\t# to use compute-at-edge for this request or not.\n\t\t\t} else if (var.use-compute-at-edge-backend != \"no\") {\n\t\t\t\tdeclare local var.selected BOOL;\n\t\t\t\tset var.selected = randombool(1, std.atoi(table.lookup(compute_at_edge_config, \"sample\", \"1000\")));\n\t\t\t\t# this logic is saying, only use compute-at-edge for a request which has come from outside this Fastly\n\t\t\t\t# service. I.E. The request has directly from a client.\n\t\t\t\t# We also have logic which decides how many of those direct client requests use compute-at-edge.\n\t\t\t\t# We default to 1 in 1000 requests using compute-at-edge, this can be configured by the edge dictionary\n\t\t\t\t# named `compute_at_edge_config` and the item in the dictionary named `sample`\n\t\t\t\tif (var.selected && fastly_info.edge.is_tls && !req.is_background_fetch && !req.is_purge && req.restarts == 0 && fastly.ff.visits_this_service == 0) {\n\t\t\t\t\tset req.backend = F_compute_at_edge;\n\t\t\t\t\tif (req.backend.healthy) {\n\t\t\t\t\t\t# if using the c@e backend then do not use the cache at all\n\t\t\t\t\t\treturn(pass);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\nsub vcl_fetch {\n\t# if using the compute-at-edge backend, we want to ensure request collapsing is not enabled\n\t# we don't want request collapsing because request collapsing would cause multiple requests \n\t# for the same path to be served the same response, which would end up meaning one browser \n\t# would get a polyfill bundle meant for a different browser\n\tif (req.backend == F_compute_at_edge) {\n\t\treturn(pass);\n\t}\n}\n\ninclude \"redirects.vcl\";\ninclude \"synthetic-responses.vcl\";\ninclude \"polyfill-service.vcl\";\n\n# Finally include the last bit of VCL, this _must_ be last!\ninclude \"fastly-boilerplate-end.vcl\";\n","old_contents":"import querystring;\n\nsub sort_comma_separated_value {\n\t# This function takes a CSV and tranforms it into a url where each\n\t# comma-separated-value is a query-string parameter and then uses\n\t# Fastly's querystring.sort function to sort the values. Once sorted\n\t# it then turn the query-parameters back into a CSV.\n\t# Set the CSV on the header `Sort-Value`.\n\t# Returns the sorted CSV on the header `Sorted-Value`.\n\tdeclare local var.value STRING;\n\tset var.value = req.http.Sort-value;\n\n\t# If query value does not exist or is empty, set it to \"\"\n\tset var.value = if(var.value != \"\", var.value, \"\");\n\n\t# Replace all `&` characters with `^`, this is because `&` would break the value up into pieces.\n\tset var.value = regsuball(var.value, \"&\", \"^\");\n\n\t# Replace all `,` characters with `&` to break them into individual query values\n\t# Append `1-` infront of all the query values to make them simpler to transform later\n\tset var.value = \"1-\" regsuball(var.value, \",\", \"&1-\");\n\n\t# Create a querystring-like string in order for querystring.sort to work.\n\tset var.value = querystring.sort(\"?\" var.value);\n\n\t# Grab all the query values from the sorted url\n\tset var.value = regsub(var.value, \"\\?\", \"\");\n\n\t# Reverse all the previous transformations to get back the single `features` query value value\n\tset var.value = regsuball(var.value, \"1-\", \"\");\n\tset var.value = regsuball(var.value, \"&\", \",\");\n\tset var.value = regsuball(var.value, \"\\^\", \"&\");\n\n\tset req.http.Sorted-Value = var.value;\n}\n\nsub normalise_querystring_parameters_for_polyfill_bundle {\n\t# Store the url without the querystring into a temporary header.\n\tdeclare local var.url STRING;\n\tset var.url = querystring.remove(req.url);\n\n\tdeclare local var.querystring STRING;\n\tset var.querystring = \"?\";\n\n\t# Remove all querystring parameters which are not part of the public API.\n\t# set req.url = querystring.regfilter_except(req.url, \"^(features|excludes|rum|unknown|flags|version|ua|callback|compression)$\");\n\n\t# (?i) makes the regex case-insensitive\n\t# The regex will match only if their are characters after `features=` which are not an ampersand (&).\n\tif (req.url.qs ~ \"(?i)[^&=]*features=([^&]+)\") {\n\t\t# Parameter has already been set, use the already set value.\n\t\t# re.group.1 is the first regex capture group in the regex above.\n\t\tif (std.strlen(re.group.1) < 100) {\n\t\t\t# We add the value of the features parameter to this header\n\t\t\t# This is to be able to have sort_comma_separated_value sort the value\n\t\t\tset req.http.Sort-Value = urldecode(re.group.1);\n\t\t\tcall sort_comma_separated_value;\n\t\t\t# The header Sorted-Value now contains the sorted version of the features parameter.\n\t\t\tset var.querystring = querystring.set(var.querystring, \"features\", req.http.Sorted-Value);\n\t\t} else {\n\t\t\tset var.querystring = querystring.set(var.querystring, \"features\", urldecode(re.group.1));\n\t\t}\n\t} else {\n\t\t# Parameter has not been set, use the default value.\n\t\tset var.querystring = querystring.set(var.querystring, \"features\", \"default\");\n\t}\n\n\t# (?i) makes the regex case-insensitive\n\t# The regex will match only if their are characters after `excludes=` which are not an ampersand (&).\n\tif (req.url.qs ~ \"(?i)[^&=]*excludes=([^&]+)\") {\n\t\t# Parameter has already been set, use the already set value.\n\t\t# re.group.1 is the first regex capture group in the regex above.\n\t\tif (std.strlen(re.group.1) < 100) {\n\t\t\t# We add the value of the excludes parameter to this header\n\t\t\t# This is to be able to have sort_comma_separated_value sort the value\n\t\t\tset req.http.Sort-Value = urldecode(re.group.1);\n\t\t\tcall sort_comma_separated_value;\n\t\t\t# The header Sorted-Value now contains the sorted version of the excludes parameter.\n\t\t\tset var.querystring = querystring.set(var.querystring, \"excludes\", req.http.Sorted-Value);\n\t\t} else {\n\t\t\tset var.querystring = querystring.set(var.querystring, \"excludes\", urldecode(re.group.1));\n\t\t}\n\t} else {\n\t\t# If excludes is not set, set to default value \"\"\n\t\tset var.querystring = var.querystring \"&excludes=\";\n\t}\n\n\t# If rum is not set, set to default value \"0\"\n\tif (req.url.qs !~ \"(?i)[^&=]*rum=([^&]+)\") {\n\t\tset var.querystring = querystring.set(var.querystring, \"rum\", \"0\");\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"rum\", re.group.1);\n\t}\n\n\t# If unknown is not set, set to default value \"polyfill\"\n\tif (req.url.qs !~ \"(?i)[^&=]*unknown=([^&]+)\") {\n\t\tset var.querystring = querystring.set(var.querystring, \"unknown\", \"polyfill\");\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"unknown\", re.group.1);\n\t}\n\n\t# If flags is not set, set to default value \"\"\n\tif (req.url.qs !~ \"(?i)[^&=]*flags=([^&]+)\") {\n\t\tset var.querystring = var.querystring \"&flags=\";\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"flags\", urldecode(re.group.1));\n\t}\n\n\t# If version is not set, set to default value \"\"\n\tdeclare local var.version STRING;\n\tif (req.url.qs !~ \"(?i)[^&=]*version=([^&]+)\") {\n\t\tset var.querystring = var.querystring \"&version=\";\n\t} else {\n\t\tif (re.group.1 == \"3.111.0\" || re.group.1 == \"3.110.1\" || re.group.1 == \"3.109.0\" || re.group.1 == \"3.108.0\" || re.group.1 == \"3.104.0\" || re.group.1 == \"3.103.0\" || re.group.1 == \"3.101.0\" || re.group.1 == \"3.98.0\" || re.group.1 == \"3.96.0\" || re.group.1 == \"3.89.4\" || re.group.1 == \"3.53.1\" || re.group.1 == \"3.52.3\" || re.group.1 == \"3.52.2\" || re.group.1 == \"3.52.1\" || re.group.1 == \"3.52.0\" || re.group.1 == \"3.51.0\" || re.group.1 == \"3.50.2\" || re.group.1 == \"3.48.0\" || re.group.1 == \"3.46.0\" || re.group.1 == \"3.42.0\" || re.group.1 == \"3.41.0\" || re.group.1 == \"3.40.0\" || re.group.1 == \"3.39.0\" || re.group.1 == \"3.34.0\" || re.group.1 == \"3.27.4\" || re.group.1 == \"3.25.1\") {\n\t\t\tset var.querystring = querystring.set(var.querystring, \"version\", re.group.1);\n\t\t} else {\n\t\t\tset var.querystring = var.querystring \"&version=\";\n\t\t}\n\t}\n\n\t# If ua is not set, normalise the User-Agent header based upon the version of the polyfill-library that has been requested.\n\tif (req.url.qs !~ \"(?i)[^&=]*ua=([^&]+)\") {\n\t\tif (req.url.qs ~ \"(?i)[^&=]*version=3\\.25\\.1(&|$)\") {\n\t\t\tcall normalise_user_agent_3_25_1;\n\t\t} else {\n\t\t\tcall normalise_user_agent_1_10_1;\n\t\t}\n\t\tset var.querystring = querystring.set(var.querystring, \"ua\", req.http.Normalized-User-Agent);\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"ua\", urldecode(re.group.1));\n\t}\n\n\t# If callback is not set, set to default value \"\"\n\tif (req.url.qs !~ \"(?i)[^&=]*callback=([^&]+)\") {\n\t\tset var.querystring = var.querystring \"&callback=\";\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"callback\", re.group.1);\n\t}\n\n\t# If compression is not set, use the best compression that the user-agent supports.\n\tif (req.url.qs !~ \"(?i)[^&=]*compression=([^&]+)\") {\n\t\t# When Fastly adds Brotli into the Accept-Encoding normalisation we can replace this with:\n\t\t# `set var.querystring = querystring.set(var.querystring, \"compression\", req.http.Accept-Encoding || \"\")`\n\n\t\t# Before SP2, IE\/6 doesn't always read and cache gzipped content correctly.\n\t\tif (req.http.Fastly-Orig-Accept-Encoding && req.http.User-Agent !~ \"MSIE 6\") {\n\t\t\tif (req.http.Fastly-Orig-Accept-Encoding ~ \"br\") {\n\t\t\t\tset var.querystring = querystring.set(var.querystring, \"compression\", \"br\");\n\t\t\t} elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"gzip\") {\n\t\t\t\tset var.querystring = querystring.set(var.querystring, \"compression\", \"gzip\");\n\t\t\t} else {\n\t\t\t\tset var.querystring = var.querystring \"&compression=\";\n\t\t\t}\n\t\t} else {\n\t\t\tset var.querystring = var.querystring \"&compression=\";\n\t\t}\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"compression\", re.group.1);\n\t}\n\tset req.url = var.url var.querystring;\n}\n\ninclude \"top_pops.vcl\";\ninclude \"normalise-user-agent-3-25-1.vcl\";\ninclude \"normalise-user-agent.vcl\";\n\n# The Fastly VCL boilerplate.\ninclude \"fastly-boilerplate-begin.vcl\";\n\ninclude \"breadcrumbs.vcl\";\n\nsub vcl_recv {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_recv;\n\t}\n}\n\nsub vcl_recv {\n\t# js-compute-runtime currently can not handle a uri which is bigger than 1024\n\t# this has been fixed in js-compute-runtime but not yet released -- https:\/\/github.com\/fastly\/js-compute-runtime\/commit\/f36dee28789b1187652874fe76d1801c9a8e5974\n\t# when the fix is released and added into @fastly\/js-compute we can remove this if statement\n\tif (std.strlen(req.url) < 900) {\n\t\t# We use this edge dictionary item as a flag for whether to use compute-at-edge for any requests.\n\t\t# If the item is not found, then we default to `\"0\"`, which we interpret to mean the flag is off.\n\t\tdeclare local var.compute-at-edge-active BOOL;\n\t\tif (std.atoi(table.lookup(compute_at_edge_config, \"active\", \"0\")) == 1) {\n\t\t\tset var.compute-at-edge-active = true;\n\t\t} else {\n\t\t\tset var.compute-at-edge-active = false;\n\t\t}\n\t\tif (var.compute-at-edge-active) {\n\t\t\t# if the querystring parameter `use-compute-at-edge-backend` is set to yes`\n\t\t\t# then use the c@e backend.\n\t\t\t# The querystring parameter is used within our tests, so that we can confirm\n\t\t\t# the compute-at-edge backend is working as we expect it to.\n\t\t\tdeclare local var.use-compute-at-edge-backend STRING;\n\t\t\tset var.use-compute-at-edge-backend = querystring.get(req.url, \"use-compute-at-edge-backend\");\n\t\t\tif (var.use-compute-at-edge-backend == \"yes\") {\n\t\t\t\tset req.backend = F_compute_at_edge;\n\t\t\t\tif (req.backend.healthy) {\n\t\t\t\t\t# if using the c@e backend then do not use the cache at all\n\t\t\t\t\treturn(pass);\n\t\t\t\t}\n\t\t\t# requests can set the querystring parameter to `no` to avoid ever user compute-at-edge\n\t\t\t# if the querystring parameter is not set to no, then we run some logic to decide whether\n\t\t\t# to use compute-at-edge for this request or not.\n\t\t\t} else if (var.use-compute-at-edge-backend != \"no\") {\n\t\t\t\tdeclare local var.selected BOOL;\n\t\t\t\tset var.selected = randombool(1, std.atoi(table.lookup(compute_at_edge_config, \"sample\", \"1000\")));\n\t\t\t\t# this logic is saying, only use compute-at-edge for a request which has come from outside this Fastly\n\t\t\t\t# service. I.E. The request has directly from a client.\n\t\t\t\t# We also have logic which decides how many of those direct client requests use compute-at-edge.\n\t\t\t\t# We default to 1 in 1000 requests using compute-at-edge, this can be configured by the edge dictionary\n\t\t\t\t# named `compute_at_edge_config` and the item in the dictionary named `sample`\n\t\t\t\tif (var.selected && fastly_info.edge.is_tls && !req.is_background_fetch && !req.is_purge && req.restarts == 0 && fastly.ff.visits_this_service == 0) {\n\t\t\t\t\tset req.backend = F_compute_at_edge;\n\t\t\t\t\tif (req.backend.healthy) {\n\t\t\t\t\t\t# if using the c@e backend then do not use the cache at all\n\t\t\t\t\t\treturn(pass);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\nsub vcl_fetch {\n\t# if using the compute-at-edge backend, we want to ensure request collapsing is not enabled\n\t# we don't want request collapsing because request collapsing would cause multiple requests \n\t# for the same path to be served the same response, which would end up meaning one browser \n\t# would get a polyfill bundle meant for a different browser\n\tif (req.backend == F_compute_at_edge) {\n\t\treturn(pass);\n\t}\n}\n\ninclude \"redirects.vcl\";\ninclude \"synthetic-responses.vcl\";\ninclude \"polyfill-service.vcl\";\n\n# Finally include the last bit of VCL, this _must_ be last!\ninclude \"fastly-boilerplate-end.vcl\";\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"0b7071b4cee495f291af5983e692b9aa9dde0e81","subject":"Missing set_next_bottle call","message":"Missing set_next_bottle call\n","repos":"rhargreaves\/fastly-vcl-experiments,rhargreaves\/fastly-vcl-experiments","old_file":"99_bottles.vcl","new_file":"99_bottles.vcl","new_contents":"backend F_fake_backend {\n\t.host = \"example.com\";\n\t.port = \"80\";\n\t.dynamic = true;\n\t.connect_timeout = 5s;\n\t.first_byte_timeout = 15s;\n\t.probe = {\n\t\t.dummy = true;\n\t}\n}\n\nsub vcl_recv {\n#FASTLY recv\n\tset req.backend = F_fake_backend;\n\n\tset req.http.X-Bottle = if(req.url ~ \"(?i)bottle=([^&]*)\", urldecode(re.group.1), \"99\");\n\tset req.http.X-Wall = if(req.http.X-Wall, req.http.X-Wall \" \", \"\") req.http.X-Bottle;\n\n\tcall set_next_bottle;\n\n\tif(req.http.X-Bottle == \"0\") {\n\t\terror 996;\n\t}\n\treturn(lookup);\n}\n\nsub vcl_fetch {\n#FASTLY fetch\n\n\tif(req.restarts > 0) {\n\t\tset beresp.http.Fastly-Restarts = req.restarts;\n\t}\n\treturn(deliver);\n}\n\nsub vcl_deliver {\n#FASTLY deliver\n\tset resp.http.X-Wall = req.http.X-Wall;\n\n\tif(req.restarts == 2) {\n# For now, limit to 3 bottles as we can only restart 3 times\n\t\tset req.http.X-Next-Bottle = \"0\";\n\t}\n\n\tset req.url = \"\/?bottle=\" req.http.X-Next-Bottle;\n\tif(req.restarts < 2) {\n\t\trestart;\n\t}\n\treturn(deliver);\n}\n\nsub set_next_bottle {\n\tset req.grace = 1d;\n\tset req.http.X-Original-Grace = req.grace;\n\tset req.grace = std.atoi(req.http.X-Bottle);\n\tset req.grace -= 1s;\n\tset req.http.X-Next-Bottle = regsub(req.grace, \"\\..*\", \"\");\n\tset req.grace = std.atoi(req.http.X-Original-Grace);\n}\n\nsub vcl_error {\n#FASTLY error\n\tif(obj.status == 996) {\n\t\tset obj.status = 200;\n\t\tset obj.response = \"Cheers!\";\n\t\tsynthetic req.http.X-Wall;\n\t\treturn (deliver);\n\t}\n}\n","old_contents":"backend F_fake_backend {\n\t.host = \"fake-backend.example.com\";\n\t.port = \"80\";\n\t.dynamic = true;\n\t.connect_timeout = 5s;\n\t.first_byte_timeout = 15s;\n\t.probe = {\n\t\t.dummy = true;\n\t}\n}\n\nsub vcl_recv {\n#FASTLY recv\n\tset req.backend = F_fake_backend;\n\n\tset req.http.X-Bottle = if(req.url ~ \"(?i)bottle=([^&]*)\", urldecode(re.group.1), \"99\");\n\tset req.http.X-Wall = if(req.http.X-Wall, req.http.X-Wall \" \", \"\") req.http.X-Bottle;\n\n\tif(req.http.X-Bottle == \"0\") {\n\t\terror 996;\n\t}\n\treturn(lookup);\n}\n\nsub vcl_fetch {\n#FASTLY fetch\n\n\tif(req.restarts > 0) {\n\t\tset beresp.http.Fastly-Restarts = req.restarts;\n\t}\n\treturn(deliver);\n}\n\nsub vcl_deliver {\n#FASTLY deliver\n\tset resp.http.X-Wall = req.http.X-Wall;\n\n\tif(req.restarts == 2) {\n# For now, limit to 3 bottles as we can only restart 3 times\n\t\tset req.http.X-Next-Bottle = \"0\";\n\t}\n\n\tset req.url = \"\/?bottle=\" req.http.X-Next-Bottle;\n\tif(req.restarts < 2) {\n\t\trestart;\n\t}\n\treturn(deliver);\n}\n\nsub set_next_bottle {\n\tset req.grace = 1d;\n\tset req.http.X-Original-Grace = req.grace;\n\tset req.grace = std.atoi(req.http.X-Bottle);\n\tset req.grace -= 1s;\n\tset req.http.X-Next-Bottle = regsub(req.grace, \"\\..*\", \"\");\n\tset req.grace = std.atoi(req.http.X-Original-Grace);\n}\n\nsub vcl_error {\n#FASTLY error\n\tif(obj.status == 996) {\n\t\tset obj.status = 200;\n\t\tset obj.response = \"Cheers!\";\n\t\tsynthetic req.http.X-Wall;\n\t\treturn (deliver);\n\t}\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"c7946f1ce9764679d49279e6c07526b3645c76f1","subject":"fix varnish force cookie","message":"fix varnish force cookie\n","repos":"KhanovaSkola\/khanovaskola-v3,KhanovaSkola\/khanovaskola-v3,KhanovaSkola\/khanovaskola-v3,KhanovaSkola\/khanovaskola-v3,KhanovaSkola\/khanovaskola-v3,KhanovaSkola\/khanovaskola-v3","old_file":"production\/varnish.vcl","new_file":"production\/varnish.vcl","new_contents":"vcl 4.0;\n\n# Disable esi xml check on varnish Startup\n# Example:\n# DAEMON_OPTS=\"-a :6081 \\\n# -T localhost:6082 \\\n# -p feature=+esi_disable_xml_check\n# -p feature=+esi_ignore_https\n#\n\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8085\";\n}\n\nsub vcl_recv {\n if (req.method != \"GET\") {\n return (pass);\n }\n if (req.http.Cookie ~ \"\\bvarnish-force=pass\") {\n return (pass);\n }\n\n return (hash);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n return(lookup);\n}\n\nsub vcl_backend_response {\n if (beresp.http.Cache-Control != \"public\") {\n set beresp.uncacheable = true;\n return (deliver);\n }\n\n set beresp.do_esi = true;\n set beresp.ttl = 15m;\n\n unset beresp.http.Set-Cookie;\n}\n","old_contents":"vcl 4.0;\n\n# Disable esi xml check on varnish Startup\n# Example:\n# DAEMON_OPTS=\"-a :6081 \\\n# -T localhost:6082 \\\n# -p feature=+esi_disable_xml_check\n# -p feature=+esi_ignore_https\n#\n\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8085\";\n}\n\nsub vcl_recv {\n if (req.method != \"GET\") {\n return (pass);\n }\n if (req.http.Cookie ~ \"\\bvarnish-cookie=pass\") {\n return (pass);\n }\n\n return (hash);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n return(lookup);\n}\n\nsub vcl_backend_response {\n if (beresp.http.Cache-Control != \"public\") {\n set beresp.uncacheable = true;\n return (deliver);\n }\n\n set beresp.do_esi = true;\n set beresp.ttl = 15m;\n\n unset beresp.http.Set-Cookie;\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"5e1968141e05ddd7046dd6fdbba2d75d4e59721f","subject":"No reason to remove Age and no need to record X-cache since we already do that","message":"No reason to remove Age and no need to record X-cache since we already do that\n","repos":"fastly\/fastly-magento,fastly\/fastly-magento,fastly\/fastly-magento,fastly\/fastly-magento","old_file":"app\/code\/community\/Fastly\/CDN\/etc\/vcl_snippets\/deliver.vcl","new_file":"app\/code\/community\/Fastly\/CDN\/etc\/vcl_snippets\/deliver.vcl","new_contents":" # Add an easy way to see whether custom Fastly VCL has been uploaded\n if ( req.http.Fastly-Debug ) {\n set resp.http.Fastly-Magento-VCL-Uploaded = \"1.0.15\";\n } else {\n remove resp.http.Fastly-Module-Enabled;\n # remove Varnish\/proxy header\n remove resp.http.X-Varnish;\n remove resp.http.Via;\n remove resp.http.X-Purge-URL;\n remove resp.http.X-Purge-Host;\n }\n\n # Clean up Vary before handing off to the user\n if ( !req.http.Fastly-FF ) {\n set resp.http.Vary = regsub(resp.http.Vary, \"Fastly-Cdn-Env,Https\", \"Cookie\");\n }\n\n if (resp.http.magentomarker && !req.http.Fastly-FF) {\n # Remove the magic marker\n unset resp.http.magentomarker;\n\n set resp.http.Cache-Control = \"no-store, no-cache, must-revalidate, post-check=0, pre-check=0\";\n set resp.http.Pragma = \"no-cache\";\n set resp.http.Expires = \"Mon, 31 Mar 2008 10:00:00 GMT\";\n }\n","old_contents":" # Add an easy way to see whether custom Fastly VCL has been uploaded\n if ( req.http.Fastly-Debug ) {\n set resp.http.Fastly-Magento-VCL-Uploaded = \"1.0.15\";\n } else {\n remove resp.http.Fastly-Module-Enabled;\n # remove Varnish\/proxy header\n remove resp.http.X-Varnish;\n remove resp.http.Via;\n remove resp.http.Age;\n remove resp.http.X-Purge-URL;\n remove resp.http.X-Purge-Host;\n }\n\n # debug info\n if (resp.http.X-Cache-Debug) {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n set resp.http.X-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n set resp.http.X-Cache-Expires = resp.http.Expires;\n } else {\n }\n\n # Clean up Vary before handing off to the user\n if ( !req.http.Fastly-FF ) {\n set resp.http.Vary = regsub(resp.http.Vary, \"Fastly-Cdn-Env,Https\", \"Cookie\");\n }\n\n if (resp.http.magentomarker && !req.http.Fastly-FF) {\n # Remove the magic marker\n unset resp.http.magentomarker;\n\n set resp.http.Cache-Control = \"no-store, no-cache, must-revalidate, post-check=0, pre-check=0\";\n set resp.http.Pragma = \"no-cache\";\n set resp.http.Expires = \"Mon, 31 Mar 2008 10:00:00 GMT\";\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"b15c4edda04cec7391361fb81b8436cfa255ad3d","subject":"Rest of the logic required for per-language cache","message":"Rest of the logic required for per-language cache\n","repos":"CIRANDAS\/noosfero-ecosol,evandrojr\/noosfero,alexandreab\/noosfero,EcoAlternative\/noosfero-ecosol,blogoosfero\/noosfero,abner\/noosfero,LuisBelo\/tccnoosfero,hackathon-oscs\/rede-osc,cesarfex\/noosfero,abner\/noosfero,cesarfex\/noosfero,cesarfex\/noosfero,vfcosta\/noosfero,CIRANDAS\/noosfero-ecosol,AlessandroCaetano\/noosfero,evandrojr\/noosferogov,alexandreab\/noosfero,pr-snas\/noosfero-sgpr,LuisBelo\/tccnoosfero,CIRANDAS\/noosfero-ecosol,arthurmde\/noosfero,LuisBelo\/tccnoosfero,tallysmartins\/noosfero,larissa\/noosfero,hackathon-oscs\/cartografias,ludaac\/noosfero-mx,macartur\/noosfero,LuisBelo\/tccnoosfero,vfcosta\/noosfero,LuisBelo\/tccnoosfero,coletivoEITA\/noosfero,hackathon-oscs\/rede-osc,alexandreab\/noosfero,hackathon-oscs\/cartografias,CIRANDAS\/noosfero-ecosol,EcoAlternative\/noosfero-ecosol,danielafeitosa\/noosfero,pr-snas\/noosfero-sgpr,marcosronaldo\/noosfero,AlessandroCaetano\/noosfero,hackathon-oscs\/cartografias,EcoAlternative\/noosfero-ecosol,vfcosta\/noosfero,evandrojr\/noosfero,evandrojr\/noosferogov,coletivoEITA\/noosfero,marcosronaldo\/noosfero,hackathon-oscs\/rede-osc,marcosronaldo\/noosfero,abner\/noosfero,danielafeitosa\/noosfero,pr-snas\/noosfero-sgpr,rafamanzo\/mezuro-travis,coletivoEITA\/noosfero,uniteddiversity\/noosfero,samasti\/noosfero,marcosronaldo\/noosfero,blogoosfero\/noosfero,abner\/noosfero,abner\/noosfero,arthurmde\/noosfero,tallysmartins\/noosfero,evandrojr\/noosfero,uniteddiversity\/noosfero,hackathon-oscs\/rede-osc,marcosronaldo\/noosfero,rafamanzo\/mezuro-travis,AlessandroCaetano\/noosfero,coletivoEITA\/noosfero-ecosol,evandrojr\/noosferogov,danielafeitosa\/noosfero,macartur\/noosfero,pr-snas\/noosfero-sgpr,AlessandroCaetano\/noosfero,LuisBelo\/tccnoosfero,alexandreab\/noosfero,samasti\/noosfero,samasti\/noosfero,tallysmartins\/noosfero,hebertdougl\/noosfero,AlessandroCaetano\/noosfero,macartur\/noosfero,rafamanzo\/mezuro-travis,blogoosfero\/noosfero,arthurmde\/noosfero,larissa\/noosfero,abner\/noosfero,samasti\/noosfero,uniteddiversity\/noosfero,rafamanzo\/mezuro-travis,ludaac\/noosfero-mx,danielafeitosa\/noosfero,AlessandroCaetano\/noosfero,evandrojr\/noosfero,uniteddiversity\/noosfero,EcoAlternative\/noosfero-ecosol,blogoosfero\/noosfero,uniteddiversity\/noosfero,hackathon-oscs\/cartografias,blogoosfero\/noosfero,AlessandroCaetano\/noosfero,vfcosta\/noosfero,arthurmde\/noosfero,larissa\/noosfero,samasti\/noosfero,evandrojr\/noosferogov,hackathon-oscs\/cartografias,alexandreab\/noosfero,ludaac\/noosfero-mx,cesarfex\/noosfero,coletivoEITA\/noosfero,EcoAlternative\/noosfero-ecosol,cesarfex\/noosfero,evandrojr\/noosferogov,evandrojr\/noosfero,hackathon-oscs\/rede-osc,cesarfex\/noosfero,coletivoEITA\/noosfero-ecosol,macartur\/noosfero,larissa\/noosfero,rafamanzo\/mezuro-travis,hebertdougl\/noosfero,marcosronaldo\/noosfero,ludaac\/noosfero-mx,macartur\/noosfero,EcoAlternative\/noosfero-ecosol,hackathon-oscs\/cartografias,macartur\/noosfero,hebertdougl\/noosfero,cesarfex\/noosfero,marcosronaldo\/noosfero,tallysmartins\/noosfero,hebertdougl\/noosfero,pr-snas\/noosfero-sgpr,CIRANDAS\/noosfero-ecosol,arthurmde\/noosfero,macartur\/noosfero,vfcosta\/noosfero,alexandreab\/noosfero,blogoosfero\/noosfero,evandrojr\/noosferogov,coletivoEITA\/noosfero-ecosol,larissa\/noosfero,samasti\/noosfero,hebertdougl\/noosfero,coletivoEITA\/noosfero,hackathon-oscs\/rede-osc,hackathon-oscs\/rede-osc,tallysmartins\/noosfero,tallysmartins\/noosfero,EcoAlternative\/noosfero-ecosol,hebertdougl\/noosfero,arthurmde\/noosfero,blogoosfero\/noosfero,coletivoEITA\/noosfero-ecosol,hackathon-oscs\/cartografias,danielafeitosa\/noosfero,evandrojr\/noosfero,vfcosta\/noosfero,larissa\/noosfero,coletivoEITA\/noosfero,tallysmartins\/noosfero,uniteddiversity\/noosfero,arthurmde\/noosfero,uniteddiversity\/noosfero,alexandreab\/noosfero,abner\/noosfero,hebertdougl\/noosfero,pr-snas\/noosfero-sgpr,ludaac\/noosfero-mx,coletivoEITA\/noosfero-ecosol,evandrojr\/noosfero,larissa\/noosfero,danielafeitosa\/noosfero,evandrojr\/noosferogov,coletivoEITA\/noosfero,coletivoEITA\/noosfero-ecosol","old_file":"etc\/noosfero\/varnish-accept-language.vcl","new_file":"etc\/noosfero\/varnish-accept-language.vcl","new_contents":"C{\n\n\/* ------------------------------------------------------------------ *\/\n\/* THIS FILE IS AUTOMATICALLY GENERATED BY .\/gen_vcl.pl. DO NOT EDIT. *\/\n\n\/*\n * Accept-language header normalization\n *\n * Cosimo, 21\/01\/2010\n *\n *\/\n\n#include <ctype.h> \/* isupper *\/\n#include <stdio.h>\n#include <stdlib.h> \/* qsort *\/\n#include <string.h>\n\n#define DEFAULT_LANGUAGE \"en\"\n#define SUPPORTED_LANGUAGES \":de:fr:es:ru:pt:hy:en:\"\n\n#define vcl_string char\n#define LANG_LIST_SIZE 16 \n#define LANG_MAXLEN 16\n#define RETURN_LANG(x) { \\\n strncpy(lang, x, LANG_MAXLEN); \\\n return; \\\n}\n#define RETURN_DEFAULT_LANG RETURN_LANG(DEFAULT_LANGUAGE)\n#define PUSH_LANG(x,y) { \\\n \/* fprintf(stderr, \"Pushing lang [%d] %s %.4f\\n\", curr_lang, x, y); *\/ \\\n \/* We have to copy, otherwise root_lang will be the same every time *\/ \\\n strncpy(pl[curr_lang].lang, x, LANG_MAXLEN); \\\n pl[curr_lang].q = y; \\\n curr_lang++; \\\n}\n\nstruct lang_list {\n vcl_string lang[LANG_MAXLEN];\n float q;\n};\n\n\/* In-place lowercase of a string *\/\nstatic void strtolower(char *s) {\n register char *c;\n for (c=s; *c; c++) {\n if (isupper(*c)) {\n *c = tolower(*c);\n }\n }\n return;\n}\n\n\/* Checks if a given language is in the static list of the ones we support *\/\nint is_supported(vcl_string *lang) {\n vcl_string *supported_languages = SUPPORTED_LANGUAGES;\n vcl_string match_str[LANG_MAXLEN + 3] = \"\"; \/* :, :, \\0 = 3 *\/\n int is_supported = 0;\n\n \/* We want to match 'zh-cn' and 'zh-CN' too *\/\n strtolower(lang);\n\n \/* Search \":<lang>:\" in supported languages string *\/\n strncpy(match_str, \":\", 1);\n strncat(match_str, lang, LANG_MAXLEN);\n strncat(match_str, \":\\0\", 2);\n\n if (strstr(supported_languages, match_str)) {\n is_supported = 1;\n }\n\n return is_supported;\n}\n\n\/* Used by qsort() below *\/\nint sort_by_q(const void *x, const void *y) {\n struct lang_list *a = (struct lang_list *)x;\n struct lang_list *b = (struct lang_list *)y;\n if (a->q > b->q) return -1;\n if (a->q < b->q) return 1;\n return 0;\n}\n\n\/* Reads Accept-Language, parses it, and finds the first match\n among the supported languages. In case of no match,\n returns the default language.\n*\/\nvoid select_language(const vcl_string *incoming_header, char *lang) {\n\n struct lang_list pl[LANG_LIST_SIZE];\n vcl_string *lang_tok = NULL;\n vcl_string root_lang[3];\n vcl_string *header;\n vcl_string *pos = NULL;\n vcl_string *q_spec = NULL;\n unsigned int curr_lang = 0, i = 0;\n float q;\n\n \/* Empty or default string, return default language immediately *\/\n if (\n !incoming_header\n || (0 == strcmp(incoming_header, \"en-US\"))\n || (0 == strcmp(incoming_header, \"en-GB\"))\n || (0 == strcmp(incoming_header, DEFAULT_LANGUAGE))\n || (0 == strcmp(incoming_header, \"\"))\n )\n RETURN_DEFAULT_LANG;\n\n \/* Tokenize Accept-Language *\/\n header = (vcl_string *) incoming_header;\n\n while ((lang_tok = strtok_r(header, \" ,\", &pos))) {\n\n q = 1.0;\n\n if ((q_spec = strstr(lang_tok, \";q=\"))) {\n \/* Truncate language name before ';' *\/\n *q_spec = '\\0';\n \/* Get q value *\/\n sscanf(q_spec + 3, \"%f\", &q);\n }\n\n \/* Wildcard language '*' should be last in list *\/\n if ((*lang_tok) == '*') q = 0.0;\n\n \/* Push in the prioritized list *\/\n PUSH_LANG(lang_tok, q);\n\n \/* For cases like 'en-GB', we also want the root language in the final list *\/\n if ('-' == lang_tok[2]) {\n root_lang[0] = lang_tok[0];\n root_lang[1] = lang_tok[1];\n root_lang[2] = '\\0';\n PUSH_LANG(root_lang, q - 0.001);\n }\n\n \/* For strtok_r() to proceed from where it left off *\/\n header = NULL;\n\n \/* Break out if stored max no. of languages *\/\n if (curr_lang >= LANG_MAXLEN) break;\n }\n\n \/* Sort by priority *\/\n qsort(pl, curr_lang, sizeof(struct lang_list), &sort_by_q);\n\n \/* Match with supported languages *\/\n for (i = 0; i < curr_lang; i++) {\n if (is_supported(pl[i].lang))\n RETURN_LANG(pl[i].lang);\n }\n\n RETURN_DEFAULT_LANG;\n}\n\n\/* Reads req.http.Accept-Language and writes X-Varnish-Accept-Language *\/\nvoid vcl_rewrite_accept_language(const struct sess *sp) {\n vcl_string *in_hdr;\n vcl_string lang[LANG_MAXLEN];\n\n memset(lang, 0, LANG_MAXLEN);\n\n \/* Get Accept-Language header from client *\/\n in_hdr = VRT_GetHdr(sp, HDR_REQ, \"\\020Accept-Language:\");\n\n \/* Normalize and filter out by list of supported languages *\/\n select_language(in_hdr, lang);\n\n \/* By default, use a different header name: don't mess with backend logic *\/\n VRT_SetHdr(sp, HDR_REQ, \"\\032X-Varnish-Accept-Language:\", lang, vrt_magic_string_end);\n\n return;\n}\n\n\/* vim: syn=c ts=4 et sts=4 sw=4 tw=0\n*\/\n\n\/* THIS FILE IS AUTOMATICALLY GENERATED BY .\/gen_vcl.pl. DO NOT EDIT. *\/\n\/* ------------------------------------------------------------------ *\/\n}C\n\nsub vcl_recv {\n C{\n vcl_rewrite_accept_language(sp);\n }C\n}\n\nsub vcl_fetch {\n set beresp.http.Vary = \"X-Varnish-Accept-Language\";\n}\n","old_contents":"C{\n\n\/* ------------------------------------------------------------------ *\/\n\/* THIS FILE IS AUTOMATICALLY GENERATED BY .\/gen_vcl.pl. DO NOT EDIT. *\/\n\n\/*\n * Accept-language header normalization\n *\n * Cosimo, 21\/01\/2010\n *\n *\/\n\n#include <ctype.h> \/* isupper *\/\n#include <stdio.h>\n#include <stdlib.h> \/* qsort *\/\n#include <string.h>\n\n#define DEFAULT_LANGUAGE \"en\"\n#define SUPPORTED_LANGUAGES \":de:fr:es:ru:pt:hy:en:\"\n\n#define vcl_string char\n#define LANG_LIST_SIZE 16 \n#define LANG_MAXLEN 16\n#define RETURN_LANG(x) { \\\n strncpy(lang, x, LANG_MAXLEN); \\\n return; \\\n}\n#define RETURN_DEFAULT_LANG RETURN_LANG(DEFAULT_LANGUAGE)\n#define PUSH_LANG(x,y) { \\\n \/* fprintf(stderr, \"Pushing lang [%d] %s %.4f\\n\", curr_lang, x, y); *\/ \\\n \/* We have to copy, otherwise root_lang will be the same every time *\/ \\\n strncpy(pl[curr_lang].lang, x, LANG_MAXLEN); \\\n pl[curr_lang].q = y; \\\n curr_lang++; \\\n}\n\nstruct lang_list {\n vcl_string lang[LANG_MAXLEN];\n float q;\n};\n\n\/* In-place lowercase of a string *\/\nstatic void strtolower(char *s) {\n register char *c;\n for (c=s; *c; c++) {\n if (isupper(*c)) {\n *c = tolower(*c);\n }\n }\n return;\n}\n\n\/* Checks if a given language is in the static list of the ones we support *\/\nint is_supported(vcl_string *lang) {\n vcl_string *supported_languages = SUPPORTED_LANGUAGES;\n vcl_string match_str[LANG_MAXLEN + 3] = \"\"; \/* :, :, \\0 = 3 *\/\n int is_supported = 0;\n\n \/* We want to match 'zh-cn' and 'zh-CN' too *\/\n strtolower(lang);\n\n \/* Search \":<lang>:\" in supported languages string *\/\n strncpy(match_str, \":\", 1);\n strncat(match_str, lang, LANG_MAXLEN);\n strncat(match_str, \":\\0\", 2);\n\n if (strstr(supported_languages, match_str)) {\n is_supported = 1;\n }\n\n return is_supported;\n}\n\n\/* Used by qsort() below *\/\nint sort_by_q(const void *x, const void *y) {\n struct lang_list *a = (struct lang_list *)x;\n struct lang_list *b = (struct lang_list *)y;\n if (a->q > b->q) return -1;\n if (a->q < b->q) return 1;\n return 0;\n}\n\n\/* Reads Accept-Language, parses it, and finds the first match\n among the supported languages. In case of no match,\n returns the default language.\n*\/\nvoid select_language(const vcl_string *incoming_header, char *lang) {\n\n struct lang_list pl[LANG_LIST_SIZE];\n vcl_string *lang_tok = NULL;\n vcl_string root_lang[3];\n vcl_string *header;\n vcl_string *pos = NULL;\n vcl_string *q_spec = NULL;\n unsigned int curr_lang = 0, i = 0;\n float q;\n\n \/* Empty or default string, return default language immediately *\/\n if (\n !incoming_header\n || (0 == strcmp(incoming_header, \"en-US\"))\n || (0 == strcmp(incoming_header, \"en-GB\"))\n || (0 == strcmp(incoming_header, DEFAULT_LANGUAGE))\n || (0 == strcmp(incoming_header, \"\"))\n )\n RETURN_DEFAULT_LANG;\n\n \/* Tokenize Accept-Language *\/\n header = (vcl_string *) incoming_header;\n\n while ((lang_tok = strtok_r(header, \" ,\", &pos))) {\n\n q = 1.0;\n\n if ((q_spec = strstr(lang_tok, \";q=\"))) {\n \/* Truncate language name before ';' *\/\n *q_spec = '\\0';\n \/* Get q value *\/\n sscanf(q_spec + 3, \"%f\", &q);\n }\n\n \/* Wildcard language '*' should be last in list *\/\n if ((*lang_tok) == '*') q = 0.0;\n\n \/* Push in the prioritized list *\/\n PUSH_LANG(lang_tok, q);\n\n \/* For cases like 'en-GB', we also want the root language in the final list *\/\n if ('-' == lang_tok[2]) {\n root_lang[0] = lang_tok[0];\n root_lang[1] = lang_tok[1];\n root_lang[2] = '\\0';\n PUSH_LANG(root_lang, q - 0.001);\n }\n\n \/* For strtok_r() to proceed from where it left off *\/\n header = NULL;\n\n \/* Break out if stored max no. of languages *\/\n if (curr_lang >= LANG_MAXLEN) break;\n }\n\n \/* Sort by priority *\/\n qsort(pl, curr_lang, sizeof(struct lang_list), &sort_by_q);\n\n \/* Match with supported languages *\/\n for (i = 0; i < curr_lang; i++) {\n if (is_supported(pl[i].lang))\n RETURN_LANG(pl[i].lang);\n }\n\n RETURN_DEFAULT_LANG;\n}\n\n\/* Reads req.http.Accept-Language and writes X-Varnish-Accept-Language *\/\nvoid vcl_rewrite_accept_language(const struct sess *sp) {\n vcl_string *in_hdr;\n vcl_string lang[LANG_MAXLEN];\n\n memset(lang, 0, LANG_MAXLEN);\n\n \/* Get Accept-Language header from client *\/\n in_hdr = VRT_GetHdr(sp, HDR_REQ, \"\\020Accept-Language:\");\n\n \/* Normalize and filter out by list of supported languages *\/\n select_language(in_hdr, lang);\n\n \/* By default, use a different header name: don't mess with backend logic *\/\n VRT_SetHdr(sp, HDR_REQ, \"\\032X-Varnish-Accept-Language:\", lang, vrt_magic_string_end);\n\n return;\n}\n\n\/* vim: syn=c ts=4 et sts=4 sw=4 tw=0\n*\/\n\n\/* THIS FILE IS AUTOMATICALLY GENERATED BY .\/gen_vcl.pl. DO NOT EDIT. *\/\n\/* ------------------------------------------------------------------ *\/\n}C\n\nsub vcl_recv {\n C{\n vcl_rewrite_accept_language(sp);\n }C\n}\n","returncode":0,"stderr":"","license":"agpl-3.0","lang":"VCL"} {"commit":"1ed5eff3305992ce184269e3ea9ffeea283b1e57","subject":"Make sure we also allow \/pub\/static","message":"Make sure we also allow \/pub\/static\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets_basic_auth\/recv.vcl","new_file":"etc\/vcl_snippets_basic_auth\/recv.vcl","new_contents":" # Check Basic auth against a table. \/admin URLs are not basic auth protected to avoid the possibility of people\n # locking themselves out\n if ( table.lookup(magentomodule_basic_auth, regsub(req.http.Authorization, \"^Basic \", \"\"), \"NOTFOUND\") == \"NOTFOUND\" &&\n !req.url ~ \"^\/(index\\.php\/)?admin(_.*)?\/\" &&\n !req.url ~ \"^\/pub\/static\/\" ) {\n error 971;\n }\n","old_contents":" # Check Basic auth against a table. \/admin URLs are no basic auth protected to avoid the possibility of people\n # locking themselves out\n if ( table.lookup(magentomodule_basic_auth, regsub(req.http.Authorization, \"^Basic \", \"\"), \"NOTFOUND\") == \"NOTFOUND\" &&\n req.url !~ \"^\/(index\\.php\/)?admin(_.*)?\/\" ) {\n error 971;\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"8516e7d372c09618ddb5cf1b8b53de1c991573c5","subject":"#65: Make backend port configurable in kodekit.vcl","message":"#65: Make backend port configurable in kodekit.vcl\n","repos":"nooku\/nooku-platform,nooku\/nooku-platform,nooku\/nooku-platform,nooku\/nooku-platform,nooku\/nooku-platform","old_file":"component\/varnish\/resources\/varnish\/kodekit.vcl","new_file":"component\/varnish\/resources\/varnish\/kodekit.vcl","new_contents":"vcl 4.0;\n# Based on: https:\/\/github.com\/mattiasgeniar\/varnish-4.0-configuration-templates\/blob\/master\/default.vcl\n\nimport std;\nimport directors;\n\nprobe health\n{\n #.url = \"\/varnish-enabled\";\n # We prefer to only do a HEAD \/\n .request =\n \"HEAD \/varnish-enabled HTTP\/1.1\"\n \"Host: localhost\"\n \"Connection: close\";\n \"User-Agent: Varnish Health Probe\";\n .interval = 5s; # check the health of each backend every 5 seconds\n .timeout = 1s; # timing out after 1 second.\n # If 3 out of the last 5 polls succeeded the backend is considered healthy, otherwise it will be marked as sick\n .window = 5;\n .threshold = 3;\n .expected_response = 200;\n}\n\nbackend default\n{\n .host = \"127.0.0.1\"; # IP or Hostname of backend\n .port = \"%1$s\"; # Port Apache or whatever is listening\n .max_connections = 300; # That's it\n .probe = health;\n .connect_timeout = 600s; # How long to wait before we receive a first byte from our backend?\n .first_byte_timeout = 600s; # How long to wait for a backend connection?\n .between_bytes_timeout = 600s; # How long to wait between bytes received from our backend?\n}\n\nbackend passthrough\n{\n .host = \"127.0.0.1\"; # IP or Hostname of backend\n .port = \"%1$s\"; # Port Apache or whatever is listening\n}\n\nacl localhost\n{\n \"localhost\";\n \"33.33.33.63\";\n \"::1\";\n}\n\nsub vcl_init\n{\n # Called when VCL is loaded, before any requests pass through it.\n # Typically used to initialize VMODs.\n\n new vdir = directors.round_robin();\n vdir.add_backend(default);\n # vdir.add_backend(server...);\n # vdir.add_backend(servern);\n}\n\nsub vcl_recv\n{\n # Called at the beginning of a request, after the complete request has been received and parsed.\n # Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable,\n # which backend to use and if needed to modify the request.\n\n # Send all traffic to the vdir director\n set req.backend_hint = vdir.backend();\n\n # Normalize the header, remove the port (in case you're testing this on various TCP ports)\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n # Normalize the query arguments\n set req.url = std.querysort(req.url);\n\n # Allow purging\n if (req.method == \"PURGE\")\n {\n # purge is the ACL defined at the begining\n if (!client.ip ~ localhost) {\n return (synth(405, \"This IP is not allowed to send PURGE requests.\"));\n }\n\n # If you got this stage (and didn't error out above), purge the cached result\n return (purge);\n }\n\n # Check if we've still enabled Varnish, if not, passthrough every request\n if (! std.healthy(req.backend_hint))\n {\n set req.backend_hint = passthrough;\n return (pass);\n }\n\n # Only deal with \"normal\" types\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"PATCH\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n # Implementing websocket support (https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html)\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n # Only cache GET or HEAD requests. This makes sure the POST requests are always passed.\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n # Specific Nooku Platform rules\n\n # Do not cache \/administrator\n if(req.url ~ \"^\/administrator\") {\n return (pass);\n }\n\n # Specific Nooku Server rules\n\n # Do not cache webgrind.nooku.dev\n if (req.http.host == \"webgrind.nooku.dev\") {\n return (pass);\n }\n\n # Do not cache phpmyadmin.nooku.dev\n if (req.http.host == \"phpmyadmin.nooku.dev\") {\n return (pass);\n }\n\n # Do not cache \/apc and \/phpinfo\n if (req.url == \"\/apc\" || req.url == \"\/phpinfo\") {\n return (pass);\n }\n\n # Generic URL manipulation, useful for all templates that follow\n\n # Remove the Google Analytics added parameters, useless for our backend\n if (req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=\") {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # Strip hash, server doesn't need it.\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n # Strip a trailing ? if it exists\n if (req.url ~ \"\\?$\") {\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # Cookie manipulation\n\n # Remove the \"has_js\" cookie\n set req.http.Cookie = regsuball(req.http.Cookie, \"has_js=[^;]+(; )?\", \"\");\n\n # Remove any Google Analytics based cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__utm.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"_ga=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"_gat=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmctr=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmcmd.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmccn.=[^;]+(; )?\", \"\");\n\n # Remove DoubleClick offensive cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__gads=[^;]+(; )?\", \"\");\n\n # Remove the Quant Capital cookies (added by some plugin, all __qca)\n set req.http.Cookie = regsuball(req.http.Cookie, \"__qc.=[^;]+(; )?\", \"\");\n\n # Remove the AddThis cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__atuv.=[^;]+(; )?\", \"\");\n\n # Remove a \";\" prefix in the cookie if present\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n\n # Remove the csrf_token cookie\n set req.http.Cookie = regsuball(req.http.Cookie, \"csrf_token=[^;]+(; )?\", \"\");\n\n # Are there cookies left with only spaces or that are empty?\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n\n # Large static files are delivered directly to the end-user without waiting for Varnish to fully read the file first.\n # Varnish 4 supports Streaming, so set do_stream in vcl_backend_response()\n if (req.url ~ \"^[^?]*\\.(7z|avi|bz2|flac|flv|gz|mka|mkv|mov|mp3|mp4|mpeg|mpg|ogg|ogm|opus|rar|tar|tgz|tbz|txz|wav|webm|xz|zip)(\\?.*)?$\") {\n unset req.http.Cookie;\n return (hash);\n }\n\n # Remove all cookies for static files\n # Before you blindly enable this read: https:\/\/ma.ttias.be\/stop-caching-static-files\/\n #if (req.method == \"GET\")\n #{\n # # Cache files with these extensions and remove cookie\n # if (req.url ~ \"^[^?]*\\.(7z|avi|bmp|bz2|css|csv|doc|docx|eot|flac|flv|gif|gz|ico|jpeg|jpg|js|less|mka|mkv|mov|mp3|mp4|mpeg|mpg|odt|otf|ogg|ogm|opus|pdf|png|ppt|pptx|rar|rtf|svg|svgz|swf|tar|tbz|tgz|ttf|txt|txz|wav|webm|webp|woff|woff2|xls|xlsx|xml|xz|zip)(\\?.*)?$\") {\n # unset req.http.Cookie;\n # return (hash);\n # }\n #}\n\n if (req.http.Cache-Control ~ \"(?i)no-cache\" && client.ip ~ localhost)\n {\n # http:\/\/varnish.projects.linpro.no\/wiki\/VCLExampleEnableForceRefresh\n # Ignore requests via proxy caches and badly behaved crawlers\n # like msnbot that send no-cache with every request.\n if (! (req.http.Via || req.http.User-Agent ~ \"(?i)bot\" || req.http.X-Purge))\n {\n # Doesn't seems to refresh the object in the cache\n set req.hash_always_miss = true;\n\n # Couple this with restart in vcl_purge and X-Purge header to avoid loops\n return(purge);\n }\n }\n\n # Send Surrogate-Capability headers to announce ESI support to backend\n set req.http.Surrogate-Capability = \"varnish=ESI\/1.0\";\n\n # Requests that require authorization are not cacheable by default\n if (req.http.Authorization) {\n return (pass);\n }\n\n # We do not support SPDY or HTTP\/2.0\n if (req.method == \"PRI\") {\n return (synth(405));\n }\n\n return (hash);\n}\n\n# Called upon entering pipe mode. In this mode, the request is passed on to the backend, and any further data from both\n# the client and backend is passed on unaltered until either end closes the connection. Basically, Varnish will degrade\n# into a simple TCP proxy, shuffling bytes back and forth. For a connection in pipe mode, no other VCL subroutine will\n# ever get called after vcl_pipe.\nsub vcl_pipe\n{\n # Note that only the first request to the backend will have X-Forwarded-For set.\n # If you use X-Forwarded-For and want to have it set for all requests, make sure to have:\n # set bereq.http.connection = \"close\";\n # It is not set by default as it might break some broken web applications, like IIS with NTLM authentication.\n # set bereq.http.Connection = \"Close\";\n\n # Implementing websocket support (https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html)\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n\n return (pipe);\n}\n\n# Called upon entering pass mode. In this mode, the request is passed on to the backend, and the backend's response\n# is passed on to the client, but is not entered into the cache. Subsequent requests submitted over the same client\n# connection are handled normally.\nsub vcl_pass\n{\n return (fetch);\n}\n\n# Called after vcl_recv to create a hash value for the request. This is used as a key to look up the object in Varnish.\nsub vcl_hash\n{\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n\n # hash cookies for requests that have them\n if (req.http.Cookie) {\n hash_data(req.http.Cookie);\n }\n}\n\n# Called when a cache lookup is successful.\nsub vcl_hit\n{\n # A pure unadultered hit, deliver it\n if (obj.ttl >= 0s) {\n return (deliver);\n }\n\n # https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-grace.html\n # When several clients are requesting the same page Varnish will send one request to the backend and place the\n # others on hold while fetching one copy from the backend. In some products this is called request coalescing and\n # Varnish does this automatically.\n\n # If you are serving thousands of hits per second the queue of waiting requests can get huge. There are two\n # potential problems - one is a thundering herd problem - suddenly releasing a thousand threads to serve content\n # might send the load sky high. Secondly - nobody likes to wait. To deal with this we can instruct Varnish to keep\n # the objects in cache beyond their TTL and to serve the waiting requests somewhat stale content.\n\n # if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n # return (deliver);\n # } else {\n # return (fetch);\n # }\n\n # We have no fresh fish. Lets look at the stale ones.\n if (std.healthy(req.backend_hint))\n {\n # Backend is healthy. Limit age to 10s.\n if (obj.ttl + 10s > 0s)\n {\n #set req.http.grace = \"normal(limited)\";\n return (deliver);\n }\n else\n {\n # No candidate for grace. Fetch a fresh object.\n return(fetch);\n }\n }\n else\n {\n # backend is sick - use full grace\n if (obj.ttl + obj.grace > 0s)\n {\n #set req.http.grace = \"full\";\n return (deliver);\n }\n else\n {\n # no graced object.\n return (fetch);\n }\n }\n\n # fetch & deliver once we get the result\n return (fetch); # Dead code, keep as a safeguard\n}\n\n# Called after a cache lookup if the requested document was not found in the cache. Its purpose is to decide whether\n# or not to attempt to retrieve the document from the backend, and which backend to use.\nsub vcl_miss\n{\n return (fetch);\n}\n\n # Called after the response headers has been successfully retrieved from the backend.\nsub vcl_backend_response\n{\n # Enable ESI handling\n if (beresp.http.Surrogate-Control ~ \"ESI\/1.0\" ) {\n set beresp.do_esi = true;\n }\n\n # Store the csrf_token cookie temporarily if the response is cacheabale\n if (beresp.http.Set-Cookie && !beresp.uncacheable)\n {\n set beresp.http.X-Varnish-Cookie = beresp.http.Set-Cookie;\n unset beresp.http.Set-Cookie;\n }\n\n # Cache handling all static files\n if (bereq.method == \"GET\")\n {\n # Before you blindly enable this, read: https:\/\/ma.ttias.be\/stop-caching-static-files\/\n #if (bereq.url ~ \"^[^?]*\\.(7z|avi|bmp|bz2|css|csv|doc|docx|eot|flac|flv|gif|gz|ico|jpeg|jpg|js|less|mka|mkv|mov|mp3|mp4|mpeg|mpg|odt|otf|ogg|ogm|opus|pdf|png|ppt|pptx|rar|rtf|svg|svgz|swf|tar|tbz|tgz|ttf|txt|txz|wav|webm|webp|woff|woff2|xls|xlsx|xml|xz|zip)(\\?.*)?$\") {\n # unset beresp.http.Set-Cookie;\n #}\n\n # Large static files are delivered directly to the end-user without waiting for Varnish to fully read the\n # file first. Check memory usage it'll grow in fetch_chunksize blocks (128k by default) if the backend\n # doesn't send a Content-Length header. Only enable it for large files\n if (bereq.url ~ \"^[^?]*\\.(7z|avi|bz2|flac|flv|gz|mka|mkv|mov|mp3|mp4|mpeg|mpg|ogg|ogm|opus|rar|tar|tgz|tbz|txz|wav|webm|xz|zip)(\\?.*)?$\") {\n {\n unset beresp.http.Set-Cookie;\n\n # Use streaming to avoid locking\n set beresp.do_stream = true;\n\n # Don't try to compress it for storage\n set beresp.do_gzip = false;\n\n # Disable Transfer-encoding chunked when serving HTML5 video\n # See : http:\/\/stackoverflow.com\/questions\/23643233\/how-do-i-disable-transfer-encoding-chunked-encoding-in-varnish\n # See : https:\/\/www.varnish-cache.org\/trac\/ticket\/1506\n if(beresp.http.Content-Type ~ \"video\") {\n set beresp.do_stream = true;\n set beresp.do_esi = true;\n }\n }\n\n # Set 2min cache if unset for static files\n if (beresp.ttl <= 0s || beresp.http.Set-Cookie || beresp.http.Vary == \"*\")\n {\n set beresp.ttl = 120s; # Important, you shouldn't rely on this, SET YOUR HEADERS in the backend\n set beresp.uncacheable = true;\n\n return (deliver);\n }\n }\n\n # Sometimes, a 301 or 302 redirect formed via Apache's mod_rewrite can mess with the HTTP port that is being passed along.\n # This often happens with simple rewrite rules in a scenario where Varnish runs on :80 and Apache on :8080 on the same box.\n # A redirect can then often redirect the end-user to a URL on :8080, where it should be :80.\n # This may need finetuning on your setup.\n #\n # To prevent accidental replace, we only filter the 301\/302 redirects for now.\n if (beresp.status == 301 || beresp.status == 302) {\n set beresp.http.Location = regsub(beresp.http.Location, \":[0-9]+\", \"\");\n }\n\n # Never cache 50x responses\n if (beresp.status >= 500) {\n return (abandon);\n }\n\n # Do not cache errors from the backend\n if (beresp.status >= 400)\n {\n set beresp.uncacheable = true;\n set beresp.ttl = 0s;\n\n return (deliver);\n }\n\n # Allow stale content, in case the backend goes down. Make Varnish keep all objects for 6 hours beyond their TTL\n set beresp.grace = 6h;\n\n # Set ban-lurker friendly custom headers\n set beresp.http.X-Varnish-Url = bereq.url;\n set beresp.http.X-Varnish-Host = bereq.http.host;\n\n return (deliver);\n}\n\n# Called when the backend returns an error\nsub vcl_backend_error\n{\n if (beresp.status == 503 && bereq.retries < 5)\n {\n set beresp.http.X-Varnish-Retries = bereq.retries;\n return(retry);\n }\n\n return(deliver);\n}\n\n# Called before a cached object is delivered to the client.\nsub vcl_deliver\n{\n # Send the Cookie header again if a temporay header was stored\n if (req.http.X-Varnish-Cookie) {\n set resp.http.Set-Cookie = req.http.X-Varnish-Cookie;\n }\n\n # Add extra headers if debugging is enabled\n if (resp.http.x-varnish-debug && server.ip ~ localhost)\n {\n set resp.http.X-Served-By = server.hostname;\n\n if (resp.http.x-varnish ~ \" \") {\n set resp.http.X-Varnish-Status = \"HIT\";\n } else {\n set resp.http.X-Varnish-Status = \"MISS\";\n }\n\n # Please note that obj.hits behaviour changed in 4.0, now it counts per objecthead, not per object\n # and obj.hits may not be reset in some cases where bans are in use. See bug 1492 for details.\n # So take hits with a grain of salt\n set resp.http.X-Varnish-Hits = obj.hits;\n }\n else\n {\n # Remove ban-lurker friendly custom headers when delivering to client\n unset resp.http.X-Url;\n unset resp.http.X-Host;\n\n # Remove some headers: PHP version\n unset resp.http.X-Powered-By;\n\n # Remove some headers: Apache version & OS\n unset resp.http.Server;\n unset resp.http.Via;\n unset resp.http.Link;\n unset resp.http.X-Varnish;\n unset resp.http.X-Varnish-Tag;\n unset resp.http.X-Varnish-Debug;\n unset resp.http.X-Varnish-Host;\n unset resp.http.X-Varnish-Url;\n unset resp.http.X-Varnish-Retries;\n unset resp.http.X-Varnish-Cookie;\n unset resp.http.Surrogate-Control;\n }\n\n return (deliver);\n}\n\nsub vcl_purge\n{\n # Only handle actual PURGE HTTP methods, everything else is discarded\n if (req.method != \"PURGE\" && server.ip ~ localhost)\n {\n set req.http.X-Varnish-Purge = \"Yes\";\n return (restart);\n }\n}\n\nsub vcl_synth\n{\n if (resp.status == 720)\n {\n # We use this special error status 720 to force redirects with 301 (permanent) redirects\n # To use this, call the following from anywhere in vcl_recv: return (synth(720, \"http:\/\/host\/new.html\"));\n set resp.http.Location = resp.reason;\n set resp.status = 301;\n\n return (deliver);\n }\n elseif (resp.status == 721)\n {\n # And we use error status 721 to force redirects with a 302 (temporary) redirect\n # To use this, call the following from anywhere in vcl_recv: return (synth(720, \"http:\/\/host\/new.html\"));\n\n set resp.http.Location = resp.reason;\n set resp.status = 302;\n\n return (deliver);\n }\n\n return (deliver);\n}\n\n# Called when VCL is discarded only after all requests have exited the VCL. Typically used to clean up VMODs.\nsub vcl_fini\n{\n return (ok);\n}\n","old_contents":"vcl 4.0;\n# Based on: https:\/\/github.com\/mattiasgeniar\/varnish-4.0-configuration-templates\/blob\/master\/default.vcl\n\nimport std;\nimport directors;\n\nprobe health\n{\n #.url = \"\/varnish-enabled\";\n # We prefer to only do a HEAD \/\n .request =\n \"HEAD \/varnish-enabled HTTP\/1.1\"\n \"Host: localhost\"\n \"Connection: close\";\n \"User-Agent: Varnish Health Probe\";\n .interval = 5s; # check the health of each backend every 5 seconds\n .timeout = 1s; # timing out after 1 second.\n # If 3 out of the last 5 polls succeeded the backend is considered healthy, otherwise it will be marked as sick\n .window = 5;\n .threshold = 3;\n .expected_response = 200;\n}\n\nbackend default\n{\n .host = \"127.0.0.1\"; # IP or Hostname of backend\n .port = \"8080\"; # Port Apache or whatever is listening\n .max_connections = 300; # That's it\n .probe = health;\n .connect_timeout = 600s; # How long to wait before we receive a first byte from our backend?\n .first_byte_timeout = 600s; # How long to wait for a backend connection?\n .between_bytes_timeout = 600s; # How long to wait between bytes received from our backend?\n}\n\nbackend passthrough\n{\n .host = \"127.0.0.1\"; # IP or Hostname of backend\n .port = \"8080\"; # Port Apache or whatever is listening\n}\n\nacl localhost\n{\n \"localhost\";\n \"33.33.33.63\";\n \"::1\";\n}\n\nsub vcl_init\n{\n # Called when VCL is loaded, before any requests pass through it.\n # Typically used to initialize VMODs.\n\n new vdir = directors.round_robin();\n vdir.add_backend(default);\n # vdir.add_backend(server...);\n # vdir.add_backend(servern);\n}\n\nsub vcl_recv\n{\n # Called at the beginning of a request, after the complete request has been received and parsed.\n # Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable,\n # which backend to use and if needed to modify the request.\n\n # Send all traffic to the vdir director\n set req.backend_hint = vdir.backend();\n\n # Normalize the header, remove the port (in case you're testing this on various TCP ports)\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n # Normalize the query arguments\n set req.url = std.querysort(req.url);\n\n # Allow purging\n if (req.method == \"PURGE\")\n {\n # purge is the ACL defined at the begining\n if (!client.ip ~ localhost) {\n return (synth(405, \"This IP is not allowed to send PURGE requests.\"));\n }\n\n # If you got this stage (and didn't error out above), purge the cached result\n return (purge);\n }\n\n # Check if we've still enabled Varnish, if not, passthrough every request\n if (! std.healthy(req.backend_hint))\n {\n set req.backend_hint = passthrough;\n return (pass);\n }\n\n # Only deal with \"normal\" types\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"PATCH\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n # Implementing websocket support (https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html)\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n # Only cache GET or HEAD requests. This makes sure the POST requests are always passed.\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n # Specific Nooku Platform rules\n\n # Do not cache \/administrator\n if(req.url ~ \"^\/administrator\") {\n return (pass);\n }\n\n # Specific Nooku Server rules\n\n # Do not cache webgrind.nooku.dev\n if (req.http.host == \"webgrind.nooku.dev\") {\n return (pass);\n }\n\n # Do not cache phpmyadmin.nooku.dev\n if (req.http.host == \"phpmyadmin.nooku.dev\") {\n return (pass);\n }\n\n # Do not cache \/apc and \/phpinfo\n if (req.url == \"\/apc\" || req.url == \"\/phpinfo\") {\n return (pass);\n }\n\n # Generic URL manipulation, useful for all templates that follow\n\n # Remove the Google Analytics added parameters, useless for our backend\n if (req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=\") {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # Strip hash, server doesn't need it.\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n # Strip a trailing ? if it exists\n if (req.url ~ \"\\?$\") {\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # Cookie manipulation\n\n # Remove the \"has_js\" cookie\n set req.http.Cookie = regsuball(req.http.Cookie, \"has_js=[^;]+(; )?\", \"\");\n\n # Remove any Google Analytics based cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__utm.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"_ga=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"_gat=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmctr=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmcmd.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmccn.=[^;]+(; )?\", \"\");\n\n # Remove DoubleClick offensive cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__gads=[^;]+(; )?\", \"\");\n\n # Remove the Quant Capital cookies (added by some plugin, all __qca)\n set req.http.Cookie = regsuball(req.http.Cookie, \"__qc.=[^;]+(; )?\", \"\");\n\n # Remove the AddThis cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__atuv.=[^;]+(; )?\", \"\");\n\n # Remove a \";\" prefix in the cookie if present\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n\n # Remove the csrf_token cookie\n set req.http.Cookie = regsuball(req.http.Cookie, \"csrf_token=[^;]+(; )?\", \"\");\n\n # Are there cookies left with only spaces or that are empty?\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n\n # Large static files are delivered directly to the end-user without waiting for Varnish to fully read the file first.\n # Varnish 4 supports Streaming, so set do_stream in vcl_backend_response()\n if (req.url ~ \"^[^?]*\\.(7z|avi|bz2|flac|flv|gz|mka|mkv|mov|mp3|mp4|mpeg|mpg|ogg|ogm|opus|rar|tar|tgz|tbz|txz|wav|webm|xz|zip)(\\?.*)?$\") {\n unset req.http.Cookie;\n return (hash);\n }\n\n # Remove all cookies for static files\n # Before you blindly enable this read: https:\/\/ma.ttias.be\/stop-caching-static-files\/\n #if (req.method == \"GET\")\n #{\n # # Cache files with these extensions and remove cookie\n # if (req.url ~ \"^[^?]*\\.(7z|avi|bmp|bz2|css|csv|doc|docx|eot|flac|flv|gif|gz|ico|jpeg|jpg|js|less|mka|mkv|mov|mp3|mp4|mpeg|mpg|odt|otf|ogg|ogm|opus|pdf|png|ppt|pptx|rar|rtf|svg|svgz|swf|tar|tbz|tgz|ttf|txt|txz|wav|webm|webp|woff|woff2|xls|xlsx|xml|xz|zip)(\\?.*)?$\") {\n # unset req.http.Cookie;\n # return (hash);\n # }\n #}\n\n if (req.http.Cache-Control ~ \"(?i)no-cache\" && client.ip ~ localhost)\n {\n # http:\/\/varnish.projects.linpro.no\/wiki\/VCLExampleEnableForceRefresh\n # Ignore requests via proxy caches and badly behaved crawlers\n # like msnbot that send no-cache with every request.\n if (! (req.http.Via || req.http.User-Agent ~ \"(?i)bot\" || req.http.X-Purge))\n {\n # Doesn't seems to refresh the object in the cache\n set req.hash_always_miss = true;\n\n # Couple this with restart in vcl_purge and X-Purge header to avoid loops\n return(purge);\n }\n }\n\n # Send Surrogate-Capability headers to announce ESI support to backend\n set req.http.Surrogate-Capability = \"varnish=ESI\/1.0\";\n\n # Requests that require authorization are not cacheable by default\n if (req.http.Authorization) {\n return (pass);\n }\n\n # We do not support SPDY or HTTP\/2.0\n if (req.method == \"PRI\") {\n return (synth(405));\n }\n\n return (hash);\n}\n\n# Called upon entering pipe mode. In this mode, the request is passed on to the backend, and any further data from both\n# the client and backend is passed on unaltered until either end closes the connection. Basically, Varnish will degrade\n# into a simple TCP proxy, shuffling bytes back and forth. For a connection in pipe mode, no other VCL subroutine will\n# ever get called after vcl_pipe.\nsub vcl_pipe\n{\n # Note that only the first request to the backend will have X-Forwarded-For set.\n # If you use X-Forwarded-For and want to have it set for all requests, make sure to have:\n # set bereq.http.connection = \"close\";\n # It is not set by default as it might break some broken web applications, like IIS with NTLM authentication.\n # set bereq.http.Connection = \"Close\";\n\n # Implementing websocket support (https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html)\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n\n return (pipe);\n}\n\n# Called upon entering pass mode. In this mode, the request is passed on to the backend, and the backend's response\n# is passed on to the client, but is not entered into the cache. Subsequent requests submitted over the same client\n# connection are handled normally.\nsub vcl_pass\n{\n return (fetch);\n}\n\n# Called after vcl_recv to create a hash value for the request. This is used as a key to look up the object in Varnish.\nsub vcl_hash\n{\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n\n # hash cookies for requests that have them\n if (req.http.Cookie) {\n hash_data(req.http.Cookie);\n }\n}\n\n# Called when a cache lookup is successful.\nsub vcl_hit\n{\n # A pure unadultered hit, deliver it\n if (obj.ttl >= 0s) {\n return (deliver);\n }\n\n # https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-grace.html\n # When several clients are requesting the same page Varnish will send one request to the backend and place the\n # others on hold while fetching one copy from the backend. In some products this is called request coalescing and\n # Varnish does this automatically.\n\n # If you are serving thousands of hits per second the queue of waiting requests can get huge. There are two\n # potential problems - one is a thundering herd problem - suddenly releasing a thousand threads to serve content\n # might send the load sky high. Secondly - nobody likes to wait. To deal with this we can instruct Varnish to keep\n # the objects in cache beyond their TTL and to serve the waiting requests somewhat stale content.\n\n # if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n # return (deliver);\n # } else {\n # return (fetch);\n # }\n\n # We have no fresh fish. Lets look at the stale ones.\n if (std.healthy(req.backend_hint))\n {\n # Backend is healthy. Limit age to 10s.\n if (obj.ttl + 10s > 0s)\n {\n #set req.http.grace = \"normal(limited)\";\n return (deliver);\n }\n else\n {\n # No candidate for grace. Fetch a fresh object.\n return(fetch);\n }\n }\n else\n {\n # backend is sick - use full grace\n if (obj.ttl + obj.grace > 0s)\n {\n #set req.http.grace = \"full\";\n return (deliver);\n }\n else\n {\n # no graced object.\n return (fetch);\n }\n }\n\n # fetch & deliver once we get the result\n return (fetch); # Dead code, keep as a safeguard\n}\n\n# Called after a cache lookup if the requested document was not found in the cache. Its purpose is to decide whether\n# or not to attempt to retrieve the document from the backend, and which backend to use.\nsub vcl_miss\n{\n return (fetch);\n}\n\n # Called after the response headers has been successfully retrieved from the backend.\nsub vcl_backend_response\n{\n # Enable ESI handling\n if (beresp.http.Surrogate-Control ~ \"ESI\/1.0\" ) {\n set beresp.do_esi = true;\n }\n\n # Store the csrf_token cookie temporarily if the response is cacheabale\n if (beresp.http.Set-Cookie && !beresp.uncacheable)\n {\n set beresp.http.X-Varnish-Cookie = beresp.http.Set-Cookie;\n unset beresp.http.Set-Cookie;\n }\n\n # Cache handling all static files\n if (bereq.method == \"GET\")\n {\n # Before you blindly enable this, read: https:\/\/ma.ttias.be\/stop-caching-static-files\/\n #if (bereq.url ~ \"^[^?]*\\.(7z|avi|bmp|bz2|css|csv|doc|docx|eot|flac|flv|gif|gz|ico|jpeg|jpg|js|less|mka|mkv|mov|mp3|mp4|mpeg|mpg|odt|otf|ogg|ogm|opus|pdf|png|ppt|pptx|rar|rtf|svg|svgz|swf|tar|tbz|tgz|ttf|txt|txz|wav|webm|webp|woff|woff2|xls|xlsx|xml|xz|zip)(\\?.*)?$\") {\n # unset beresp.http.Set-Cookie;\n #}\n\n # Large static files are delivered directly to the end-user without waiting for Varnish to fully read the\n # file first. Check memory usage it'll grow in fetch_chunksize blocks (128k by default) if the backend\n # doesn't send a Content-Length header. Only enable it for large files\n if (bereq.url ~ \"^[^?]*\\.(7z|avi|bz2|flac|flv|gz|mka|mkv|mov|mp3|mp4|mpeg|mpg|ogg|ogm|opus|rar|tar|tgz|tbz|txz|wav|webm|xz|zip)(\\?.*)?$\") {\n {\n unset beresp.http.Set-Cookie;\n\n # Use streaming to avoid locking\n set beresp.do_stream = true;\n\n # Don't try to compress it for storage\n set beresp.do_gzip = false;\n\n # Disable Transfer-encoding chunked when serving HTML5 video\n # See : http:\/\/stackoverflow.com\/questions\/23643233\/how-do-i-disable-transfer-encoding-chunked-encoding-in-varnish\n # See : https:\/\/www.varnish-cache.org\/trac\/ticket\/1506\n if(beresp.http.Content-Type ~ \"video\") {\n set beresp.do_stream = true;\n set beresp.do_esi = true;\n }\n }\n\n # Set 2min cache if unset for static files\n if (beresp.ttl <= 0s || beresp.http.Set-Cookie || beresp.http.Vary == \"*\")\n {\n set beresp.ttl = 120s; # Important, you shouldn't rely on this, SET YOUR HEADERS in the backend\n set beresp.uncacheable = true;\n\n return (deliver);\n }\n }\n\n # Sometimes, a 301 or 302 redirect formed via Apache's mod_rewrite can mess with the HTTP port that is being passed along.\n # This often happens with simple rewrite rules in a scenario where Varnish runs on :80 and Apache on :8080 on the same box.\n # A redirect can then often redirect the end-user to a URL on :8080, where it should be :80.\n # This may need finetuning on your setup.\n #\n # To prevent accidental replace, we only filter the 301\/302 redirects for now.\n if (beresp.status == 301 || beresp.status == 302) {\n set beresp.http.Location = regsub(beresp.http.Location, \":[0-9]+\", \"\");\n }\n\n # Never cache 50x responses\n if (beresp.status >= 500) {\n return (abandon);\n }\n\n # Do not cache errors from the backend\n if (beresp.status >= 400)\n {\n set beresp.uncacheable = true;\n set beresp.ttl = 0s;\n\n return (deliver);\n }\n\n # Allow stale content, in case the backend goes down. Make Varnish keep all objects for 6 hours beyond their TTL\n set beresp.grace = 6h;\n\n # Set ban-lurker friendly custom headers\n set beresp.http.X-Varnish-Url = bereq.url;\n set beresp.http.X-Varnish-Host = bereq.http.host;\n\n return (deliver);\n}\n\n# Called when the backend returns an error\nsub vcl_backend_error\n{\n if (beresp.status == 503 && bereq.retries < 5)\n {\n set beresp.http.X-Varnish-Retries = bereq.retries;\n return(retry);\n }\n\n return(deliver);\n}\n\n# Called before a cached object is delivered to the client.\nsub vcl_deliver\n{\n # Send the Cookie header again if a temporay header was stored\n if (req.http.X-Varnish-Cookie) {\n set resp.http.Set-Cookie = req.http.X-Varnish-Cookie;\n }\n\n # Add extra headers if debugging is enabled\n if (resp.http.x-varnish-debug && server.ip ~ localhost)\n {\n set resp.http.X-Served-By = server.hostname;\n\n if (resp.http.x-varnish ~ \" \") {\n set resp.http.X-Varnish-Status = \"HIT\";\n } else {\n set resp.http.X-Varnish-Status = \"MISS\";\n }\n\n # Please note that obj.hits behaviour changed in 4.0, now it counts per objecthead, not per object\n # and obj.hits may not be reset in some cases where bans are in use. See bug 1492 for details.\n # So take hits with a grain of salt\n set resp.http.X-Varnish-Hits = obj.hits;\n }\n else\n {\n # Remove ban-lurker friendly custom headers when delivering to client\n unset resp.http.X-Url;\n unset resp.http.X-Host;\n\n # Remove some headers: PHP version\n unset resp.http.X-Powered-By;\n\n # Remove some headers: Apache version & OS\n unset resp.http.Server;\n unset resp.http.Via;\n unset resp.http.Link;\n unset resp.http.X-Varnish;\n unset resp.http.X-Varnish-Tag;\n unset resp.http.X-Varnish-Debug;\n unset resp.http.X-Varnish-Host;\n unset resp.http.X-Varnish-Url;\n unset resp.http.X-Varnish-Retries;\n unset resp.http.X-Varnish-Cookie;\n unset resp.http.Surrogate-Control;\n }\n\n return (deliver);\n}\n\nsub vcl_purge\n{\n # Only handle actual PURGE HTTP methods, everything else is discarded\n if (req.method != \"PURGE\" && server.ip ~ localhost)\n {\n set req.http.X-Varnish-Purge = \"Yes\";\n return (restart);\n }\n}\n\nsub vcl_synth\n{\n if (resp.status == 720)\n {\n # We use this special error status 720 to force redirects with 301 (permanent) redirects\n # To use this, call the following from anywhere in vcl_recv: return (synth(720, \"http:\/\/host\/new.html\"));\n set resp.http.Location = resp.reason;\n set resp.status = 301;\n\n return (deliver);\n }\n elseif (resp.status == 721)\n {\n # And we use error status 721 to force redirects with a 302 (temporary) redirect\n # To use this, call the following from anywhere in vcl_recv: return (synth(720, \"http:\/\/host\/new.html\"));\n\n set resp.http.Location = resp.reason;\n set resp.status = 302;\n\n return (deliver);\n }\n\n return (deliver);\n}\n\n# Called when VCL is discarded only after all requests have exited the VCL. Typically used to clean up VMODs.\nsub vcl_fini\n{\n return (ok);\n}\n","returncode":0,"stderr":"","license":"mpl-2.0","lang":"VCL"} {"commit":"c3195848ade38243239b86faa54587d746a43c91","subject":"#674: Pantheon adapted varnish VCL file","message":"#674: Pantheon adapted varnish VCL file\n","repos":"kalabox\/kalabox-app-pantheon,ManatiCR\/kalabox-app-pantheon,kalabox\/kalabox-app-pantheon,ManatiCR\/kalabox-app-pantheon,ManatiCR\/kalabox-app-pantheon,kalabox\/kalabox-app-pantheon,ManatiCR\/kalabox-app-pantheon","old_file":"app\/config\/varnish\/default.vcl","new_file":"app\/config\/varnish\/default.vcl","new_contents":"vcl 4.0;\n# For debugging, use the following and inspect the output of `varnishlog`:\n#\n# import std;\n# std.log(\"this is my debug log message\");\nimport std;\n\nbackend styxgo {\n .host = \"127.0.0.1\";\n .port = \"8888\";\n .connect_timeout = 600s;\n .first_byte_timeout = 600s;\n .between_bytes_timeout = 600s;\n}\n\nsub vcl_recv {\n set req.backend_hint = styxgo;\n\n # Always have a `has_js=1` cookie. This is set by Drupal to indicate that the\n # client browser supports JavaScript.\n # TODO (Mark): It isn't clear *why* we want to force has_js=1, update this\n # comment if you know, please.\n #\n # NOTE(jesse): WAT\n # https:\/\/www.drupal.org\/node\/229825 seems to be there reason why here?\n if (req.http.Cookie) {\n if (req.http.Cookie !~ \"has_js=1\") {\n set req.http.Cookie = \"has_js=1; \" + req.http.Cookie;\n }\n } else {\n set req.http.Cookie = \"has_js=1\";\n }\n\n if (req.restarts == 0) {\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For =\n req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n # Do not cache these paths, note that sometimes query strings are appended.\n if (req.url ~ \"^\/install\\.php\" ||\n req.url ~ \"^\/update\\.php\" ||\n req.url ~ \"^\/cron\\.php\") {\n return (pass);\n }\n\n # Pipe backup_migrate directly\n if (req.url ~ \"^\/admin\/content\/backup_migrate\/export\" || req.url ~ \"^\/system\/files\") {\n return (pipe);\n }\n\n # Do not cache potentially large files.\n if (req.url ~ \"(?i)\\.(mp3|flv|mov|mp4|mpg|mpeg|avi|mkv|ogg|oggv|wmv|rm|m4v|3gp|dmg|pdf)($|\\?)\") {\n return (pipe);\n }\n\n # Specify the ESI capability (http:\/\/www.w3.org\/TR\/edge-arch)\n # Note: This clobbers upstream capabilities, should nicely append styx's capabilities.\n set req.http.Surrogate-Capability = {\"styx=\"ESI\/1.0\"\"};\n\n # Normalize the Accept-Encoding header. See http:\/\/varnish-cache.org\/wiki\/FAQ\/Compression\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\" || req.url ~ \"^\/robots\\.txt$\") {\n # No point in compressing these\n unset req.http.Accept-Encoding;\n }\n elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n }\n else {\n # unkown algorithm\n unset req.http.Accept-Encoding;\n }\n }\n\n # Strip all cookies on requests for asset files. This ensures cache-busting\n # session cookies do not cause cache misses for these.\n #\n # Query strings may have a random series of letters\/numbers (Drupal doing its\n # cache-busting), or it may have \"itok=xyz\" which is for image derivatives, or\n # in the case of Wordpress, it may have \"ver=x.y.z\" for css \/ js files. We can\n # safely remove cookies on all of these, as static files don't vary according\n # to a user's session cookie.\n #\n # In our nginx configuration, we explicitly set assets returned in dev and\n # multidev environments to expire in the past, which essentially overrides\n # any Varnish configuration that might attempt to cache those assets. This\n # is so that developers always have fresh content while editing files.\n #\n # This list of file extensions is also in vcl_backend_response(), keep them in sync.\n if (req.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|bmp|tif|tiff|webp|swf|css|js)($|\\?)\") {\n unset req.http.Cookie;\n }\n\n # WARNING: Note that any code below the following will not be processed for\n # POST and other non-GET and non-HEAD requests!\n\n # Any unknown (Non-RFC2616 or CONNECT) request methods will be piped to the backend,\n # as we can't make any caching decisions about those. We need to allow PURGE to\n # pass as cookie munging is important for purging the correct object.\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\" &&\n req.method != \"PURGE\") {\n return (pipe);\n }\n\n # We only cache GET and HEAD requests, so allow requests for other HTTP verbs\n # to pass through without stripping cookies, etc.\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PURGE\") {\n return (pass);\n }\n\n # Strip away Google analytics cruft from GET queries.\n # https:\/\/pantheon-systems.desk.com\/agent\/case\/976\n # Based on original GA cookie cleaner\n # A previous version of the match was for (__[a-z|_]) and utm_[a-z|_].\n # Is the pipe (|) intended to match a literal pipe, or is it an error\n # signifying 'or' as in a-z or _, and doesn't belong? Leaving it for now.\n if (req.url ~ \"(\\?|\\&)(__[a-z|_A-Z-]+|utm_[a-z|_A-Z-]+)\") {\n # Side-save magic: capture the portion of the url that starts the utm block.\n # We will reverse this below in vcl_deliver() if there's a redirect, so\n # customers don't end up with PANTHEON_STRIPPED all up in their GA reports\n # just because they put out a link to a redirect.\n #\n # This process isn't perfect. The capture will take everything from the beginning\n # of the first occurrance of utm_, and restore it the same way. If a redirect\n # is triggered, and the redirect appends query parameters after the first utm_,\n # they will be lost. This could be fixed robustly by not using regular\n # expressions here in this fashion, and instead using a Varnish module (vmod)\n # to handle it. Or better targeting of the utm_ var names.\n set req.http.X-Pre-Strip = regsub(req.url, \".*?.*?(utm_.*)\", \"\\1\");\n\n # Notice that even though the Pre-Strip is captured in a basic fashion for redirects,\n # in general stripping is quite precise. Here the __xyz and utm_ params are\n # correctly carved out leaving any preceding and following params intact.\n set req.url = regsuball(req.url, \"(\\?|\\&)(__[a-z|_A-Z-]+|utm_[a-z|_A-Z-]+)=([^\\&]*)\", \"\\1\\2=PANTHEON_STRIPPED\");\n }\n\n # Cookie munging!\n if (req.http.Cookie) {\n # Prefix the existing cookie header with \";\" to make all cookies\n # have the form \";$name=$value\" for better regexing.\n set req.http.Cookie = \";\" + req.http.Cookie;\n\n # Remove any spaces between semicolons and the beginnings of cookie names.\n set req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n\n # Nuke the annoyingly patterned wordpress_test_cookie\n set req.http.Cookie = regsuball(req.http.Cookie, \";wordpress_test[^;]*\", \"\");\n\n # We bypass the cache if there is a NO_CACHE or login-related cookie set.\n # Also check for SimpleSAML or Facebook cookies to support external auth.\n\n if (req.http.Cookie ~ \";NO_CACHE=\" ||\n req.http.Cookie ~ \";S+ESS[a-z0-9]+=\" ||\n req.http.Cookie ~ \";fbs[a-z0-9_]+=\" ||\n req.http.Cookie ~ \";SimpleSAML[A-Za-z]+=\" ||\n req.http.Cookie ~ \";SimpleSAML[A-Za-z]+=\" ||\n req.http.Cookie ~ \";PHPSESSID=\" ||\n req.http.Cookie ~ \";wordpress[A-Za-z0-9_]*=\" ||\n req.http.Cookie ~ \";wp-[A-Za-z0-9_]+=\" ||\n req.http.Cookie ~ \";comment_author_[a-z0-9_]+=\" ||\n req.http.Cookie ~ \";duo_wordpress_auth_cookie=\" ||\n req.http.Cookie ~ \";duo_secure_wordpress_auth_cookie=\" ||\n req.http.Cookie ~ \";bp_completed_create_steps=\" ||\n req.http.Cookie ~ \";bp_new_group_id=\" ||\n req.http.Cookie ~ \";wp-resetpass-[A-Za-z0-9_]+=\" ||\n req.http.Cookie ~ \";(wp_)?woocommerce[A-Za-z0-9_-]+=\") {\n\n # This flag will be picked up further down vcl_recv() and will trigger a pass.\n set req.http.X-Bypass-Cache = \"1\";\n }\n\n # Add back a space between the semicolon and cookie name for each cookie we\n # intend to pass to the back-end. Starting with login-related cookies.\n set req.http.Cookie = regsuball(req.http.Cookie, \";(NO_CACHE=)\", \"; \\1\");\n set req.http.Cookie = regsuball(req.http.Cookie, \";(S+ESS[a-z0-9]+=)\", \"; \\1\");\n set req.http.Cookie = regsuball(req.http.Cookie, \";(fbs[a-z0-9_]+=)\", \"; \\1\");\n set req.http.Cookie = regsuball(req.http.Cookie, \";(SimpleSAML[A-Za-z]+=)\", \"; \\1\");\n set req.http.Cookie = regsuball(req.http.Cookie, \";(SimpleSAML[A-Za-z]+=)\", \"; \\1\");\n set req.http.Cookie = regsuball(req.http.Cookie, \";(PHPSESSID=)\", \"; \\1\");\n set req.http.Cookie = regsuball(req.http.Cookie, \";(wordpress[A-Za-z0-9_]*=)\", \"; \\1\");\n set req.http.Cookie = regsuball(req.http.Cookie, \";(wp-[A-Za-z0-9_]+=)\", \"; \\1\");\n set req.http.Cookie = regsuball(req.http.Cookie, \";(comment_author_[a-z0-9_]+=)\", \"; \\1\");\n set req.http.Cookie = regsuball(req.http.Cookie, \";(duo_wordpress_auth_cookie=)\", \"; \\1\");\n set req.http.Cookie = regsuball(req.http.Cookie, \";(duo_secure_wordpress_auth_cookie=)\", \"; \\1\");\n set req.http.Cookie = regsuball(req.http.Cookie, \";(bp_completed_create_steps=)\", \"; \\1\");\n set req.http.Cookie = regsuball(req.http.Cookie, \";(bp_new_group_id=)\", \"; \\1\");\n set req.http.Cookie = regsuball(req.http.Cookie, \";(wp-resetpass-[A-Za-z0-9_]+=)\", \"; \\1\");\n set req.http.Cookie = regsuball(req.http.Cookie, \";((wp_)?woocommerce[A-Za-z0-9_-]+=)\", \"; \\1\");\n\n # Same thing for cache-varying cookies: add back a space between the semicolon\n # and cookie name. These are different to the login-related cookies above, as we\n # allow caching for these; we will keep a separate copy of the content per cookie value.\n set req.http.Cookie = regsuball(req.http.Cookie, \";(STYXKEY[a-zA-Z0-9_-]+=)\", \"; \\1\");\n set req.http.Cookie = regsuball(req.http.Cookie, \";(has_js=)\", \"; \\1\");\n set req.http.Cookie = regsuball(req.http.Cookie, \";(Drupal[a-zA-Z0-9_\\.-]+=)\", \"; \\1\");\n\n # This is a BuddyPress pattern used in filtering\/sorting content.\n set req.http.Cookie = regsuball(req.http.Cookie, \";(bp-[a-z]+-(scope|filter))\", \"; \\1\");\n set req.http.Cookie = regsuball(req.http.Cookie, \";(bp-message-[A-Za-z1-9_-]+)\", \"; \\1\");\n\n # WARNING: When adding more cache-varying cookies here, update the `purge_varnish`\n # task in Yggdrasil, which also maintains a list of these cookies.\n\n\n # Strip all cookies lacking the telltale space between the semicolon and cookie name.\n set req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n\n # Replace any leading or trailing spaces and semicolons. This leaves\n # a completely empty cookie header if there are no cookies left.\n set req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n\n # If the cookie header is empty, drop it entirely.\n if (req.http.Cookie == \"\") {\n unset req.http.Cookie;\n }\n }\n\n # Not cacheable.\n if (req.http.Authorization) {\n return (pass);\n }\n\n # We perform a lookup even if there are cookies, as any cookies present on a\n # request that has made it this far in vcl_recv(), will be used as a Cache-Varying\n # cookie in vcl_hash().\n return (hash);\n}\n\nsub vcl_pipe {\n # Called upon entering pipe mode.\n # In this mode, the request is passed on to the backend, and any further data from both the client\n # and backend is passed on unaltered until either end closes the connection. Basically, Varnish will\n # degrade into a simple TCP proxy, shuffling bytes back and forth. For a connection in pipe mode,\n # no other VCL subroutine will ever get called after vcl_pipe.\n\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n # set bereq.http.connection = \"close\";\n # here. It is not set by default as it might break some broken web\n # applications, like IIS with NTLM authentication.\n set bereq.http.connection = \"close\";\n\n # Implementing websocket support (https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html)\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n}\n\nsub vcl_backend_response {\n # Don't allow static files to set cookies. This list of file extensions is also\n # in vcl_recv(), keep them in sync.\n if (bereq.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|bmp|tif|tiff|webp|swf|css|js)($|\\?)\") {\n unset beresp.http.set-cookie;\n }\n\n # Only cache 404s in the filesystem for 30s.\n if (bereq.url ~ \"^\/sites\/default\/files\/\" && beresp.status == 404) {\n set beresp.ttl = 30s;\n set beresp.http.Cache-Control = \"public, max-age=30\";\n }\n\n # Caching for permanent redirects (301s).\n if (beresp.status == 301) {\n if (beresp.http.Location == bereq.http.X-Proto + bereq.http.Host + bereq.url) {\n # Do not cache requests that 301 to themselves for very long.\n set beresp.http.Cache-Control = \"public, max-age=3\";\n set beresp.ttl = 3s;\n set beresp.http.X-Pantheon-Debug = \"Circular redirect detected.\";\n }\n else if (beresp.http.Location ~ \"\/\\?q=\") {\n # Do not cache 301s that redirect to ?q=\n # Misfiring clean urls\n # https:\/\/pantheon-systems.desk.com\/agent\/case\/15792\n set beresp.http.Cache-Control = \"public, max-age=3\";\n set beresp.ttl = 3s;\n set beresp.http.X-Pantheon-Debug = \"Wow. Such redirect.\";\n }\n else if (beresp.http.x-pantheon-endpoint ~ \",\") {\n # Comma in your endpoint header? Go jump in a lake. This is a bug.\n set beresp.http.Cache-Control = \"no-cache, must-revalidate, post-check=0, pre-check=0\";\n set beresp.ttl = 0s;\n }\n else if (!beresp.http.Cache-Control) {\n # Otherwise if no headers, a day is good.\n set beresp.ttl = 1d;\n set beresp.http.Cache-Control = \"public, max-age=86400\";\n }\n }\n\n # Enable ESI processing if requested\n if (beresp.http.Surrogate-Control ~ \"ESI\/1.0\" && !bereq.http.X-Bypass-Pantheon-Esi) {\n unset beresp.http.Surrogate-Control;\n set beresp.do_esi = true;\n set beresp.http.X-Styx-Attempted-ESI = \"1\";\n }\n\n # Don't cache a redirect to install.php\n if (beresp.http.Location ~ \"\/install.php$\") {\n # set beresp.ttl = 120s;\n set beresp.uncacheable = true;\n return (deliver);\n }\n\n # Strip content encoding for 301 and 302 responses.\n # The content is useless to browsers, and an incorrect\n # encoding causes Varnish 3 to return a 503 because\n # Varnish 3 is encoding-aware.\n if (beresp.status == 301 || beresp.status == 302) {\n unset beresp.http.content-encoding;\n }\n\n # beresp.grace is the length of time Varnish will keep cache objects beyond their TTL.\n # So if we have a header `Cache-Control: public, max-age=900`, we'll keep that for 900\n # seconds + the grace period here. This doesn't actually cause the stale objects to be\n # served; for that, see `bereq.grace` in `vcl_recv()`. This value must be at minimum the\n # value of bereq.grace, otherwise we would be essentially telling Varnish to serve stale\n # content for a longer period of time than we're actually storing it.\n set beresp.grace = 120m;\n\n # Smart bans. Varnish has a ban lurker thread, which will test old objects against\n # bans periodically, without a client. For it to work, your bans can not refer to anything\n # starting with `req`, as the ban lurker doesn\u2019t have any request data structure.\n #\n # @see: https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html\n set beresp.http.x-url = bereq.url;\n set beresp.http.x-host = bereq.http.host;\n\n # Varnish ignores 'no-cache' by itself and only looks at 'max-age' in the\n # Cache-Control headers.\n #\n # So, if the response's Cache-Control has only half the required pieces,\n # add the rest in here so we don't cache the page. This is mostly to\n # support customers who are executing PHP outside of Drupal\/Wordpress.\n if (beresp.http.Cache-Control == \"no-cache\") {\n set beresp.ttl = 0s;\n set beresp.http.Cache-Control = \"no-cache, must-revalidate, post-check=0, pre-check=0\";\n # set beresp.ttl = 120s;\n set beresp.uncacheable = true;\n return (deliver);\n }\n}\n\nsub vcl_hash {\n # Called after vcl_recv to create a hash value for the request. This is used as a key\n # to look up the object in Varnish.\n\n if (req.http.X-Forwarded-Proto) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n if (req.http.X-SSL) {\n hash_data(req.http.X-SSL);\n }\n if (req.http.Cookie) {\n hash_data(req.http.Cookie);\n }\n}\nsub vcl_miss {\n # go fetch!\n return (fetch);\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n # A pure unadultered hit, deliver it\n return (deliver);\n }\n\n # https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-grace.html\n\n# if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n# return (deliver);\n# } else {\n# return (fetch);\n# }\n\n # We have no fresh fish. Lets look at the stale ones.\n if (std.healthy(req.backend_hint)) {\n # Backend is healthy. Limit age to 10s.\n if (obj.ttl + 10s > 0s) {\n #set req.http.grace = \"normal(limited)\";\n return (deliver);\n } else {\n # No candidate for grace. Fetch a fresh object.\n return(fetch);\n }\n } else {\n # backend is sick - use full grace\n if (obj.ttl + obj.grace > 0s) {\n #set req.http.grace = \"full\";\n return (deliver);\n } else {\n # no graced object.\n return (fetch);\n }\n }\n\n # fetch & deliver once we get the result\n return (fetch); # Dead code, keep as a safeguard\n}\n\nsub vcl_deliver {\n\n # the following is commented out for security reasons. Do not expose the public IP's of styx boxes because\n # it can give attackers the ability to attack styx nodes directly and bypass any masking that someone may be doing\n # by pointing their DNS through a filtering service like Cloudflare.\n # set resp.http.X-Pantheon-Edge-Server = server.ip;\n if (resp.http.Content-Type ~ \"(text\/html)\") {\n set resp.http.Vary = resp.http.Vary + \", Cookie\";\n # We are busting browser caching on any html pages for Safari since it\n # does not RESPECT the Vary on Cookie header.\n if (req.http.user-agent ~ \"Safari\" && !req.http.user-agent ~ \"Chrom\") {\n set resp.http.Cache-Control = \"no-cache\";\n }\n }\n\n # Reverse the side-save magic for PANTHEON_STRIPPED, see `vcl_recv()` function.\n if ((resp.status == 301 || resp.status == 302) && req.http.X-Pre-Strip && req.http.X-Pre-Strip != \"\") {\n set resp.http.X-Pre-Strip-Debug = req.http.X-Pre-Strip;\n\n # If the backend responds with a redirect, but the Location header doesn't contain\n # any utm_ query string parameters, but we know we replaced them with PANTHEON_STRIPPED,\n # then we do the customer a favor and put them back again. We shouldn't really do this\n # but core Drupal does lose params when `drupal_goto('abcdef')` is called.\n if (resp.http.Location !~ \"(\\?|\\&)utm_.*\") {\n\n if (resp.http.Location !~ \".*\\?\") {\n # If there are no query parameters on the Location response, append a `?`. We\n # will be the only parameter in this case.\n set req.http.X-Pre-Strip = \"?\" + req.http.X-Pre-Strip;\n }\n else {\n set req.http.X-Pre-Strip = \"&\" + req.http.X-Pre-Strip;\n }\n set resp.http.Location = resp.http.Location + req.http.X-Pre-Strip;\n }\n else {\n # Strip out utm_* from the Location header, then add the values we stripped back on.\n # This results in the utm_ parameters always being added to the end of the Location\n # header.\n set resp.http.Location = regsub(resp.http.Location, \"(.*\\?.*?)utm_.*\", \"\\1\") + req.http.X-Pre-Strip;\n }\n }\n}\n","old_contents":"vcl 4.0;\n\nbackend default {\n .host =\n .port = \"8888\";\n}\n\nsub vcl_recv {\n\n # Return (pass) instructs Varnish not to cache the request\n # when the condition is met.\n\n ## GOOGLE ANALYTICS\n\n # Strip out Google Analytics variables\n if (req.url ~ \"(\\?|&)(__+|gclid|cx|ie|cof|siteurl|zanpid|origin|utm_[a-z]+|mr:[A-z]+)=\") {\n set req.url = regsuball(req.url, \"(__+gclid|cx|ie|cof|siteurl|zanpid|origin|utm_[a-z]+|mr:[A-z]+)=[%\\._A-z0-9-]+&?\", \"\");\n }\n\n ## ADMIN PAGES ##\n\n # Here we filter out all URLs containing Drupal administrative sections\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/admin$\" ||\n req.url ~ \"^\/admin\/.*$\" ||\n req.url ~ \"^\/user$\" ||\n req.url ~ \"^\/user\/.*$\" ||\n req.url ~ \"^\/flag\/.*$\" ||\n req.url ~ \"^.*\/ajax\/.*$\" ||\n req.url ~ \"^.*\/ahah\/.*$\" ||\n req.url ~ \".*fbconnect.*\" ||\n req.url ~ \".*facebook.*\" ||\n req.url ~ \".*fblink.*\") {\n return (pass);\n }\n\n ## BACKUP AND MIGRATE MODULE ##\n\n # Backup and Migrate is a very popular Drupal module that needs to be excluded\n # It won't work with Varnish\n if (req.url ~ \"^\/admin\/content\/backup_migrate\/export\") {\n return (pipe);\n }\n\n ## COOKIES ##\n\n # Remove cookies for stylesheets, scripts, and images used throughout the site.\n # Removing cookies will allow Varnish to cache those files.\n if (req.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|png|ico)(\\?.*)?$\") {\n unset req.http.Cookie;\n }\n\n # Remove all cookies that are not necessary for Drupal to work properly.\n # Since it would be cumbersome to REMOVE certain cookies, we specify\n # which ones are of interest to us, and remove all others. In this particular\n # case we leave SESS, SSESS and NO_CACHE cookies used by Drupal's administrative\n # interface. Cookies in cookie header are delimited with \";\", so when there are\n # many cookies, the header looks like \"Cookie1=value1; Cookie2=value2; Cookie3...\"\n # and so on. That allows us to work with \";\" to split cookies into individual\n # ones.\n #\n # The method for filtering unnecessary cookies has been adopted from:\n # https:\/\/fourkitchens.atlassian.net\/wiki\/display\/TECH\/Configure+Varnish+3+for+Drupal+7\n if (req.http.Cookie) {\n\n # 1. We add ; to the beginning of cookie header\n set req.http.Cookie = \";\" + req.http.Cookie;\n\n # 2. We remove spaces following each occurence of \";\". After this operation\n # all cookies are delimited with no spaces.\n set req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n\n # 3. We replace \";\" INTO \"; \" (adding the space we have previously removed) in cookies\n # named SESS..., SSESS... and NO_CACHE. After this operation those cookies will be\n # easy to differentiate from the others, because those will be the only one with space\n # after \";\"\n set req.http.Cookie = regsuball(req.http.Cookie, \";(SESS[a-z0-9]+|SSESS[a-z0-9]+|NO_CACHE)=\", \"; \\1=\");\n\n # 4. We remove all cookies with no space after \";\", so basically we remove all cookies other\n # than those above.\n set req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n\n # 5. We strip leading and trailing whitespace and semicolons.\n set req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n\n # 6. We whitelist some other useful cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \";(fbs[a-z0-9_]+)=\", \"; \\1=\");\n set req.http.Cookie = regsuball(req.http.Cookie, \";(SimpleSAML[A-Za-z]+)=\", \"; \\1=\");\n set req.http.Cookie = regsuball(req.http.Cookie, \";(PHPSESSID)=\", \"; \\1=\");\n set req.http.Cookie = regsuball(req.http.Cookie, \";(wordpress[A-Za-z0-9_]*)=\", \"; \\1=\");\n set req.http.Cookie = regsuball(req.http.Cookie, \";(wp-[A-Za-z0-9_]+)=\", \"; \\1=\");\n set req.http.Cookie = regsuball(req.http.Cookie, \";(comment_author_[a-z0-9_]+)=\", \"; \\1=\");\n set req.http.Cookie = regsuball(req.http.Cookie, \";(duo_wordpress_auth_cookie)=\", \"; \\1=\");\n set req.http.Cookie = regsuball(req.http.Cookie, \";(duo_secure_wordpress_auth_cookie)=\", \"; \\1=\");\n set req.http.Cookie = regsuball(req.http.Cookie, \";(bp_completed_create_steps)=\", \"; \\1=\");\n set req.http.Cookie = regsuball(req.http.Cookie, \";(bp_new_group_id)=\", \"; \\1=\");\n set req.http.Cookie = regsuball(req.http.Cookie, \";(wp-resetpass-[A-Za-z0-9_]+)=\", \"; \\1=\");\n set req.http.Cookie = regsuball(req.http.Cookie, \";((wp_)?woocommerce[A-Za-z0-9_-]+)=\", \"; \\1=\");\n\n # If there are no cookies after our striping procedure, we remove the header altogether,\n # thus allowing Varnish to cache this page\n if (req.http.Cookie == \"\") {\n unset req.http.Cookie;\n }\n # if any of our cookies of interest are still there, we disable caching and pass the request\n # straight to Apache and Drupal\n else {\n return (pass);\n }\n }\n}\n\nsub vcl_backend_response {\n # Remove cookies for stylesheets, scripts and images used throughout the site.\n # Removing cookies will allow Varnish to cache those files. It is uncommon for\n # static files to contain cookies, but it is possible for files generated\n # dynamically by Drupal. Those cookies are unnecessary, but could prevent files\n # from being cached.\n if (bereq.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|png|ico)(\\?.*)?$\") {\n unset beresp.http.set-cookie;\n }\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"00a475b3f7f844027ce5faadcd6ecf6044aac2d5","subject":"Avoid Stale-While-Revalidate problems","message":"Avoid Stale-While-Revalidate problems\n","repos":"elifesciences\/builder,elifesciences\/builder","old_file":"src\/buildercore\/fastly\/vcl\/main.vcl","new_file":"src\/buildercore\/fastly\/vcl\/main.vcl","new_contents":"sub vcl_recv {\n # Disable Stale-While-Revalidate if a shield request to avoid double SWR\n if (req.http.Fastly-FF) {\n set req.max_stale_while_revalidate = 0s;\n }\n\n #FASTLY recv\n\n if (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n return(lookup);\n}\n\nsub vcl_fetch {\n #FASTLY fetch\n\n if ((beresp.status == 500 || beresp.status == 503) && req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n if (req.restarts > 0) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return(pass);\n }\n\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return(pass);\n }\n\n if (beresp.status == 500 || beresp.status == 503) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return(deliver);\n }\n\n if (beresp.http.Expires || beresp.http.Surrogate-Control ~ \"max-age\" || beresp.http.Cache-Control ~ \"(s-maxage|max-age)\") {\n # keep the ttl here\n } else {\n # apply the default ttl\n set beresp.ttl = 3600s;\n }\n\n return(deliver);\n}\n\nsub vcl_hit {\n #FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\nsub vcl_miss {\n #FASTLY miss\n return(fetch);\n}\n\nsub vcl_deliver {\n #FASTLY deliver\n return(deliver);\n}\n\nsub vcl_error {\n #FASTLY error\n}\n\nsub vcl_pass {\n #FASTLY pass\n}\n\nsub vcl_log {\n #FASTLY log\n}\n","old_contents":"sub vcl_recv {\n #FASTLY recv\n\n if (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n return(lookup);\n}\n\nsub vcl_fetch {\n #FASTLY fetch\n\n if ((beresp.status == 500 || beresp.status == 503) && req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n if (req.restarts > 0) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return(pass);\n }\n\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return(pass);\n }\n\n if (beresp.status == 500 || beresp.status == 503) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return(deliver);\n }\n\n if (beresp.http.Expires || beresp.http.Surrogate-Control ~ \"max-age\" || beresp.http.Cache-Control ~ \"(s-maxage|max-age)\") {\n # keep the ttl here\n } else {\n # apply the default ttl\n set beresp.ttl = 3600s;\n }\n\n return(deliver);\n}\n\nsub vcl_hit {\n #FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\nsub vcl_miss {\n #FASTLY miss\n return(fetch);\n}\n\nsub vcl_deliver {\n #FASTLY deliver\n return(deliver);\n}\n\nsub vcl_error {\n #FASTLY error\n}\n\nsub vcl_pass {\n #FASTLY pass\n}\n\nsub vcl_log {\n #FASTLY log\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"05c5c0e14b356ba086d7b0530b0e02e5acf6d5af","subject":"Update openstreetmap3.vcl","message":"Update openstreetmap3.vcl","repos":"klausdk\/varnish","old_file":"openstreetmap\/openstreetmap3.vcl","new_file":"openstreetmap\/openstreetmap3.vcl","new_contents":"# VCL script for Varnish 3\n\n\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"80\";\n}\n\n\nbackend a_tile {\n .host = \"a.tile.openstreetmap.org\";\n .port = \"80\";\n}\n\nbackend b_tile {\n .host = \"b.tile.openstreetmap.org\";\n .port = \"80\";\n}\n\nbackend c_tile {\n .host = \"c.tile.openstreetmap.org\";\n .port = \"80\";\n}\n\nsub vcl_recv {\n\n if (req.http.host ~ \"^a.tile\") {\n set req.backend = a_tile;\n } else if (req.http.host ~ \"^b.tile\") {\n set req.backend = b_tile;\n } else if (req.http.host ~ \"^c.tile\") {\n set req.backend = c_tile;\n } else if (req.http.host ~ \"^a.map\") {\n set req.backend = a_tile;\n } else if (req.http.host ~ \"^b.map\") {\n set req.backend = b_tile;\n } else if (req.http.host ~ \"^c.map\") {\n set req.backend = c_tile;\n }\n\n remove req.http.cookie;\n\n \/\/ Cache everything\n if (req.request == \"GET\") {\n return (lookup);\n }\n\n\n}\n\nsub vcl_fetch {\n\n \/\/ Cache tiles for 3 weeks\n set beresp.ttl = 3w;\n\n \/\/ Remove all cookies\n remove beresp.http.set-cookie;\n remove beresp.http.cookie;\n\n}\n\nsub vcl_deliver {\n\n \n if (obj.hits > 0) {\n set resp.http.X-Cache_v = \"HIT\";\n } else {\n set resp.http.X-Cache_v = \"MISS\";\n }\n}\n\nsub vcl_hash {\n\n \/\/ Cache using only url as a hash. \n \/\/ This means if a.tile\/1\/1\/1\/tile.png is accessed, b.tile\/1\/1\/1\/tile.png will also be fetch from cache\n hash_data(req.url);\n return (hash);\n}\n\n\n","old_contents":"# VCL script for Varnish 3\n\n\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"80\";\n}\n\n\nbackend a_tile {\n .host = \"a.tile.openstreetmap.org\";\n .port = \"80\";\n}\n\nbackend b_tile {\n .host = \"b.tile.openstreetmap.org\";\n .port = \"80\";\n}\n\nbackend c_tile {\n .host = \"c.tile.openstreetmap.org\";\n .port = \"80\";\n}\n\nsub vcl_recv {\n\n if (req.http.host ~ \"^a.tile\") {\n set req.backend = a_tile;\n } else if (req.http.host ~ \"^b.tile\") {\n set req.backend = b_tile;\n } else if (req.http.host ~ \"^c.tile\") {\n set req.backend = c_tile;\n } else if (req.http.host ~ \"^a.map\") {\n set req.backend = a_tile;\n } else if (req.http.host ~ \"^b.map\") {\n set req.backend = b_tile;\n } else if (req.http.host ~ \"^c.map\") {\n set req.backend = c_tile;\n }\n\n remove req.http.cookie;\n\n \/\/ Cache everything\n if (req.request == \"GET\") {\n return (lookup);\n }\n\n\n}\n\nsub vcl_fetch {\n\n \/\/ Cache tiles for 3 weeks\n set beresp.ttl = 3w;\n\n \/\/ Remove all cookies\n remove beresp.http.set-cookie;\n remove beresp.http.cookie;\n\n}\n\nsub vcl_deliver {\n\n \n if (obj.hits > 0) {\n set resp.http.X-Cache_v = \"HIT\";\n } else {\n set resp.http.X-Cache_v = \"MISS\";\n }\n}\n\nsub vcl_hash {\n\n \/\/ Cache using only url as a hash. \n \/\/ This means if a.tile\/1\/1\/1\/tile.png is access, b.tile\/1\/1\/1\/tile.png will also be fetch from cache\n hash_data(req.url);\n return (hash);\n}\n\n\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"0d314640c075e0ff5a644def18cfe5792d22e107","subject":"Handle \"Vary: *\" headers by sending the object to pass, there really isn't anything else we can do sensibly.","message":"Handle \"Vary: *\" headers by sending the object to pass, there really\nisn't anything else we can do sensibly.\n\nFixes: #787\n\n\n\ngit-svn-id: 2c9807fa3ff65b17195bd55dc8a6c4261e10127b@5399 d4fa192b-c00b-0410-8231-f00ffab90ce4\n","repos":"drwilco\/varnish-cache-old,gauthier-delacroix\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,wikimedia\/operations-debs-varnish,varnish\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,ambernetas\/varnish-cache,gauthier-delacroix\/Varnish-Cache,chrismoulton\/Varnish-Cache,mrhmouse\/Varnish-Cache,zhoualbeart\/Varnish-Cache,mrhmouse\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,wikimedia\/operations-debs-varnish,1HLtd\/Varnish-Cache,ssm\/pkg-varnish,zhoualbeart\/Varnish-Cache,wikimedia\/operations-debs-varnish,ajasty-cavium\/Varnish-Cache,1HLtd\/Varnish-Cache,alarky\/varnish-cache-doc-ja,wikimedia\/operations-debs-varnish,zhoualbeart\/Varnish-Cache,ssm\/pkg-varnish,chrismoulton\/Varnish-Cache,alarky\/varnish-cache-doc-ja,zhoualbeart\/Varnish-Cache,feld\/Varnish-Cache,drwilco\/varnish-cache-old,alarky\/varnish-cache-doc-ja,ssm\/pkg-varnish,feld\/Varnish-Cache,ambernetas\/varnish-cache,franciscovg\/Varnish-Cache,varnish\/Varnish-Cache,mrhmouse\/Varnish-Cache,drwilco\/varnish-cache-old,1HLtd\/Varnish-Cache,feld\/Varnish-Cache,chrismoulton\/Varnish-Cache,drwilco\/varnish-cache-drwilco,zhoualbeart\/Varnish-Cache,mrhmouse\/Varnish-Cache,varnish\/Varnish-Cache,franciscovg\/Varnish-Cache,ambernetas\/varnish-cache,feld\/Varnish-Cache,chrismoulton\/Varnish-Cache,wikimedia\/operations-debs-varnish,drwilco\/varnish-cache-drwilco,varnish\/Varnish-Cache,1HLtd\/Varnish-Cache,gquintard\/Varnish-Cache,gquintard\/Varnish-Cache,franciscovg\/Varnish-Cache,alarky\/varnish-cache-doc-ja,mrhmouse\/Varnish-Cache,franciscovg\/Varnish-Cache,feld\/Varnish-Cache,drwilco\/varnish-cache-drwilco,ajasty-cavium\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,ssm\/pkg-varnish,franciscovg\/Varnish-Cache,varnish\/Varnish-Cache,gquintard\/Varnish-Cache,gquintard\/Varnish-Cache,chrismoulton\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,alarky\/varnish-cache-doc-ja,gauthier-delacroix\/Varnish-Cache,ssm\/pkg-varnish","old_file":"bin\/varnishd\/default.vcl","new_file":"bin\/varnishd\/default.vcl","new_contents":"\/*-\n * Copyright (c) 2006 Verdens Gang AS\n * Copyright (c) 2006-2009 Linpro AS\n * All rights reserved.\n *\n * Author: Poul-Henning Kamp <phk@phk.freebsd.dk>\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in the\n * documentation and\/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR \n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\n * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n * $Id$\n *\n * The default VCL code.\n *\n * NB! You do NOT need to copy & paste all of these functions into your\n * own vcl code, if you do not provide a definition of one of these\n * functions, the compiler will automatically fall back to the default\n * code from this file.\n *\n * This code will be prefixed with a backend declaration built from the\n * -b argument.\n *\/\n\nsub vcl_recv {\n if (req.restarts == 0) {\n\tif (req.http.x-forwarded-for) {\n\t set req.http.X-Forwarded-For =\n\t\treq.http.X-Forwarded-For + \", \" + client.ip;\n\t} else {\n\t set req.http.X-Forwarded-For = client.ip;\n\t}\n }\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization || req.http.Cookie) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n return (lookup);\n}\n\nsub vcl_pipe {\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n # set bereq.http.connection = \"close\";\n # here. It is not set by default as it might break some broken web\n # applications, like IIS with NTLM authentication.\n return (pipe);\n}\n\nsub vcl_pass {\n return (pass);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n return (hash);\n}\n\nsub vcl_hit {\n if (!obj.cacheable) {\n return (pass);\n }\n return (deliver);\n}\n\nsub vcl_miss {\n return (fetch);\n}\n\nsub vcl_fetch {\n if (!beresp.cacheable) {\n return (pass);\n }\n if (beresp.http.Set-Cookie) {\n return (pass);\n }\n if (beresp.http.Vary == \"*\") {\n return (pass);\n }\n return (deliver);\n}\n\nsub vcl_deliver {\n return (deliver);\n}\n\nsub vcl_error {\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + obj.status + \" \" + obj.response + {\"<\/h1>\n <p>\"} + obj.response + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"};\n return (deliver);\n}\n","old_contents":"\/*-\n * Copyright (c) 2006 Verdens Gang AS\n * Copyright (c) 2006-2009 Linpro AS\n * All rights reserved.\n *\n * Author: Poul-Henning Kamp <phk@phk.freebsd.dk>\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in the\n * documentation and\/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR \n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\n * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n * $Id$\n *\n * The default VCL code.\n *\n * NB! You do NOT need to copy & paste all of these functions into your\n * own vcl code, if you do not provide a definition of one of these\n * functions, the compiler will automatically fall back to the default\n * code from this file.\n *\n * This code will be prefixed with a backend declaration built from the\n * -b argument.\n *\/\n\nsub vcl_recv {\n if (req.restarts == 0) {\n\tif (req.http.x-forwarded-for) {\n\t set req.http.X-Forwarded-For =\n\t\treq.http.X-Forwarded-For + \", \" + client.ip;\n\t} else {\n\t set req.http.X-Forwarded-For = client.ip;\n\t}\n }\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization || req.http.Cookie) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n return (lookup);\n}\n\nsub vcl_pipe {\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n # set bereq.http.connection = \"close\";\n # here. It is not set by default as it might break some broken web\n # applications, like IIS with NTLM authentication.\n return (pipe);\n}\n\nsub vcl_pass {\n return (pass);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n return (hash);\n}\n\nsub vcl_hit {\n if (!obj.cacheable) {\n return (pass);\n }\n return (deliver);\n}\n\nsub vcl_miss {\n return (fetch);\n}\n\nsub vcl_fetch {\n if (!beresp.cacheable) {\n return (pass);\n }\n if (beresp.http.Set-Cookie) {\n return (pass);\n }\n return (deliver);\n}\n\nsub vcl_deliver {\n return (deliver);\n}\n\nsub vcl_error {\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + obj.status + \" \" + obj.response + {\"<\/h1>\n <p>\"} + obj.response + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"};\n return (deliver);\n}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"e2742cff3726994f6d3d9b6ae0aeb544f4a984b2","subject":"2.2.1","message":"2.2.1\n","repos":"TheWeatherChannel\/dClass,wikimedia\/analytics-dclass,ottomata\/dclass,ottomata\/dclass,ottomata\/dclass,TheWeatherChannel\/dClass,wikimedia\/analytics-dclass,wikimedia\/analytics-dclass,TheWeatherChannel\/dClass,TheWeatherChannel\/dClass,wikimedia\/analytics-dclass","old_file":"servers\/varnish\/dclass.vcl","new_file":"servers\/varnish\/dclass.vcl","new_contents":"import dclass;\n#import urlcode;\n\nbackend default {\n\t.host = \"localhost\";\n\t.port = \"80\";\n}\n\nsub vcl_init {\n\t# load openddr \n\tdclass.init_dclass(\"\/some\/path\/dClass\/dtrees\/openddr.dtree\");\n\t#dclass.init_dclass_p(\"\/some\/path\/OpenDDR\/1.0.0.0\/resources\",0);\n\n\t# load browser dtree\n\tdclass.init_dclass_p(\"\/some\/path\/dClass\/dtrees\/browser.dtree\",1);\n}\n\nsub vcl_recv {\n\t# ua override\n\tif(req.url ~ \"[^\\w]ua=\"){\n\t\tset req.http.user-agent = regsub(req.url,\"^.*[^\\w]ua=([^&]*).*\",\"\\1\");\n\t\t#set req.http.user-agent = urlcode.decode(regsub(req.url,\"^.*[^\\w]ua=([^&]*).*\",\"\\1\"));\n\t}\n\n\t# do the lookup\n\tset req.http.dclass_openddr = dclass.classify(req.http.user-agent);\n\t#set req.http.dclass_openddr = dclass.classify_p(req.http.user-agent,0);\n\tset req.http.dclass_browser = dclass.classify_p(req.http.user-agent,1);\n\n\t# set dclass_type\n\tset req.http.dclass_type = \"unknown\";\n\tif(dclass.get_field(\"is_tablet\") == \"true\"){\n\t\tset req.http.dclass_type = \"tablet\";\n\t} else if(dclass.get_field(\"is_wireless_device\") == \"true\" && dclass.get_field(\"inputDevices\") == \"touchscreen\"){\n\t\tset req.http.dclass_type = \"smartphone\";\n\t} else if(dclass.get_field(\"is_wireless_device\") == \"true\"){\n\t\tset req.http.dclass_type = \"phone\";\n\t} else if(dclass.get_field(\"is_crawler\") == \"true\"){\n\t\tset req.http.dclass_type = \"crawler\";\n\t} else if(dclass.get_field(\"is_desktop\") == \"true\"){\n\t\tset req.http.dclass_type = \"desktop\";\n\t}\n\n\t# \/uadiag commands\n\tif(req.url ~ \"^\/uadiag.js\"){\n\t\terror 849 \"uadiag.js\";\n\t} else if(req.url ~ \"^\/uadiag\"){\n\t\terror 848 \"uadiag\";\n\t}\n}\n\n# add dclass_type to the hash\nsub vcl_hash {\n\thash_data(req.url);\n\n\tif (req.http.host) {\n\t\thash_data(req.http.host);\n\t} else {\n\t\thash_data(server.ip);\n\t}\n\n #use this if you are serving different device content on the same URL\n\thash_data(req.http.dclass_type);\n\n\treturn (hash);\n}\n\nsub vcl_error {\n\t# plain text ua diag\n\tif(obj.status == 848){\n\t\tset obj.status = 200;\n\t\tset obj.http.Content-Type = \"text\/html; charset=utf-8\";\n\t\tsynthetic\n{\"<html><title>UADIAG<\/title>\n<body>\n<h1>UADIAG<\/h1>\n<pre>\nUser-Agent: \"} + req.http.User-Agent + {\"\n\ndClass version: \"} + dclass.get_version() + {\"\n\ndClass type: \"} + req.http.dclass_type + {\"\n\nOpenDDR id: \"} + req.http.dclass_openddr + {\"\nOpenDDR device: \"} + dclass.get_field(\"vendor\") + {\" \"} + dclass.get_field(\"model\") + {\"\nOpenDDR display: \"} + dclass.get_ifield(\"displayWidth\") + {\"x\"} + dclass.get_ifield(\"displayHeight\") + {\"\nOpenDDR input: \"} + dclass.get_field(\"inputDevices\") + {\"\nOpenDDR js: \"} + dclass.get_field(\"ajax_support_javascript\") + {\"\nOpenDDR wireless: \"} + dclass.get_field(\"is_wireless_device\") + {\"\nOpenDDR tablet: \"} + dclass.get_field(\"is_tablet\") + {\"\nOpenDDR crawler: \"} + dclass.get_field(\"is_crawler\") + {\"\nOpenDDR desktop: \"} + dclass.get_field(\"is_desktop\") + {\"\n\nbrowser id: \"} + req.http.dclass_browser + {\"\nbrowser name: \"} + dclass.get_field_p(\"browser\",1) + {\"\nbrowser ver: \"} + dclass.get_ifield_p(\"version\",1) + {\"\nbrowser os: \"} + dclass.get_field_p(\"os\",1) + {\"\n<\/pre>\n<\/body>\n<\/html>\"};\n\t\treturn(deliver);\n\t}\n\t# json ua diag with optional jsonp callback parameter\n\telse if(obj.status == 849){\n\t\tset obj.status = 200;\n\t\tset req.http.dclass_cb = \"\";\n\t\tset req.http.dclass_cbe = \"\";\n\t\tif(req.url ~ \"[^\\w]callback=\\w+\"){\n\t\t\tset obj.http.Content-Type = \"application\/javascript; charset=utf-8\";\n\t\t\tset req.http.dclass_cb = regsub(req.url,\"^.*[^\\w]callback=(\\w+).*\",\"\\1(\");\n\t\t\tset req.http.dclass_cbe = \");\";\n\t\t} else {\n\t\t\tset obj.http.Content-Type = \"application\/json; charset=utf-8\";\n\t\t}\n\t\tsynthetic\nreq.http.dclass_cb + {\"{\n\"user_agent\":\"\"} + req.http.User-Agent + {\"\",\n\"dclass_version\":\"\"} + dclass.get_version() + {\"\",\n\"openddr_id\":\"\"} + req.http.dclass_openddr + {\"\",\n\"openddr_type\":\"\"} + req.http.dclass_type + {\"\",\n\"openddr_device\":\"\"} + dclass.get_field(\"vendor\") + {\" \"} + dclass.get_field(\"model\") + {\"\",\n\"openddr_display\":\"\"} + dclass.get_ifield(\"displayWidth\") + {\"x\"} + dclass.get_ifield(\"displayHeight\") + {\"\",\n\"openddr_input\":\"\"} + dclass.get_field(\"inputDevices\") + {\"\",\n\"openddr_js\":\"\"} + dclass.get_field(\"ajax_support_javascript\") + {\"\",\n\"openddr_wireless\":\"\"} + dclass.get_field(\"is_wireless_device\") + {\"\",\n\"openddr_tablet\":\"\"} + dclass.get_field(\"is_tablet\") + {\"\",\n\"openddr_crawler\":\"\"} + dclass.get_field(\"is_crawler\") + {\"\",\n\"openddr_desktop\":\"\"} + dclass.get_field(\"is_desktop\") + {\"\",\n\"browser_id\":\"\"} + req.http.dclass_browser + {\"\",\n\"browser_name\":\"\"} + dclass.get_field_p(\"browser\",1) + {\"\",\n\"browser_ver\":\"\"} + dclass.get_ifield_p(\"version\",1) + {\"\",\n\"browser_os\":\"\"} + dclass.get_field_p(\"os\",1) + {\"\"\n}\"} + req.http.dclass_cbe;\n\t\treturn(deliver);\n\t}\n}\n\n","old_contents":"import dclass;\n#import urlcode;\n\nbackend default {\n\t.host = \"localhost\";\n\t.port = \"80\";\n}\n\nsub vcl_init {\n\t# load openddr \n\tdclass.init_dclass(\"\/some\/path\/dClass\/dtrees\/openddr.dtree\");\n\t#dclass.init_dclass_p(\"\/some\/path\/OpenDDR\/1.0.0.0\/resources\",0);\n\n\t# load browser dtree\n\tdclass.init_dclass_p(\"\/some\/path\/dClass\/dtrees\/browser.dtree\",1);\n}\n\nsub vcl_recv {\n\t# ua override\n\tif(req.url ~ \"[^\\w]ua=\"){\n\t\tset req.http.user-agent = regsub(req.url,\"^.*[^\\w]ua=([^&]*).*\",\"\\1\");\n\t\t#set req.http.user-agent = urlcode.decode(regsub(req.url,\"^.*[^\\w]ua=([^&]*).*\",\"\\1\"));\n\t}\n\n\t# do the lookup\n\tset req.http.dclass_openddr = dclass.classify(req.http.user-agent);\n\t#set req.http.dclass_openddr = dclass.classify_p(req.http.user-agent,0);\n\tset req.http.dclass_browser = dclass.classify_p(req.http.user-agent,1);\n\n\t# set dclass_type\n\tset req.http.dclass_type = \"unknown\";\n\tif(dclass.get_field(\"is_tablet\") == \"true\"){\n\t\tset req.http.dclass_type = \"tablet\";\n\t} else if(dclass.get_field(\"is_wireless_device\") == \"true\" && dclass.get_field(\"inputDevices\") == \"touchscreen\"){\n\t\tset req.http.dclass_type = \"smartphone\";\n\t} else if(dclass.get_field(\"is_wireless_device\") == \"true\"){\n\t\tset req.http.dclass_type = \"phone\";\n\t} else if(dclass.get_field(\"is_crawler\") == \"true\"){\n\t\tset req.http.dclass_type = \"crawler\";\n\t} else if(dclass.get_field(\"is_desktop\") == \"true\"){\n\t\tset req.http.dclass_type = \"desktop\";\n\t}\n\n\t# \/uadiag commands\n\tif(req.url ~ \"^\/uadiag.js\"){\n\t\terror 849 \"uadiag.js\";\n\t} else if(req.url ~ \"^\/uadiag\"){\n\t\terror 848 \"uadiag\";\n\t}\n}\n\n# add dclass_type to the hash\nsub vcl_hash {\n\thash_data(req.url);\n\n\tif (req.http.host) {\n\t\thash_data(req.http.host);\n\t} else {\n\t\thash_data(server.ip);\n\t}\n\n\thash_data(req.http.dclass_type);\n\n\treturn (hash);\n}\n\nsub vcl_error {\n\t# plain text ua diag\n\tif(obj.status == 848){\n\t\tset obj.status = 200;\n\t\tset obj.http.Content-Type = \"text\/html; charset=utf-8\";\n\t\tsynthetic\n{\"<html><title>UADIAG<\/title>\n<body>\n<h1>UADIAG<\/h1>\n<pre>\nUser-Agent: \"} + req.http.User-Agent + {\"\n\ndClass version: \"} + dclass.get_version() + {\"\n\ndClass type: \"} + req.http.dclass_type + {\"\n\nOpenDDR id: \"} + req.http.dclass_openddr + {\"\nOpenDDR device: \"} + dclass.get_field(\"vendor\") + {\" \"} + dclass.get_field(\"model\") + {\"\nOpenDDR display: \"} + dclass.get_ifield(\"displayWidth\") + {\"x\"} + dclass.get_ifield(\"displayHeight\") + {\"\nOpenDDR input: \"} + dclass.get_field(\"inputDevices\") + {\"\nOpenDDR js: \"} + dclass.get_field(\"ajax_support_javascript\") + {\"\nOpenDDR wireless: \"} + dclass.get_field(\"is_wireless_device\") + {\"\nOpenDDR tablet: \"} + dclass.get_field(\"is_tablet\") + {\"\nOpenDDR crawler: \"} + dclass.get_field(\"is_crawler\") + {\"\nOpenDDR desktop: \"} + dclass.get_field(\"is_desktop\") + {\"\n\nbrowser id: \"} + req.http.dclass_browser + {\"\nbrowser name: \"} + dclass.get_field_p(\"browser\",1) + {\"\nbrowser ver: \"} + dclass.get_ifield_p(\"version\",1) + {\"\nbrowser os: \"} + dclass.get_field_p(\"os\",1) + {\"\n<\/pre>\n<\/body>\n<\/html>\"};\n\t\treturn(deliver);\n\t}\n\t# json ua diag with optional jsonp callback parameter\n\telse if(obj.status == 849){\n\t\tset obj.status = 200;\n\t\tset req.http.dclass_cb = \"\";\n\t\tset req.http.dclass_cbe = \"\";\n\t\tif(req.url ~ \"[^\\w]callback=\\w+\"){\n\t\t\tset obj.http.Content-Type = \"application\/javascript; charset=utf-8\";\n\t\t\tset req.http.dclass_cb = regsub(req.url,\"^.*[^\\w]callback=(\\w+).*\",\"\\1(\");\n\t\t\tset req.http.dclass_cbe = \");\";\n\t\t} else {\n\t\t\tset obj.http.Content-Type = \"application\/json; charset=utf-8\";\n\t\t}\n\t\tsynthetic\nreq.http.dclass_cb + {\"{\n\"user_agent\":\"\"} + req.http.User-Agent + {\"\",\n\"dclass_version\":\"\"} + dclass.get_version() + {\"\",\n\"openddr_id\":\"\"} + req.http.dclass_openddr + {\"\",\n\"openddr_type\":\"\"} + req.http.dclass_type + {\"\",\n\"openddr_device\":\"\"} + dclass.get_field(\"vendor\") + {\" \"} + dclass.get_field(\"model\") + {\"\",\n\"openddr_display\":\"\"} + dclass.get_ifield(\"displayWidth\") + {\"x\"} + dclass.get_ifield(\"displayHeight\") + {\"\",\n\"openddr_input\":\"\"} + dclass.get_field(\"inputDevices\") + {\"\",\n\"openddr_js\":\"\"} + dclass.get_field(\"ajax_support_javascript\") + {\"\",\n\"openddr_wireless\":\"\"} + dclass.get_field(\"is_wireless_device\") + {\"\",\n\"openddr_tablet\":\"\"} + dclass.get_field(\"is_tablet\") + {\"\",\n\"openddr_crawler\":\"\"} + dclass.get_field(\"is_crawler\") + {\"\",\n\"openddr_desktop\":\"\"} + dclass.get_field(\"is_desktop\") + {\"\",\n\"browser_id\":\"\"} + req.http.dclass_browser + {\"\",\n\"browser_name\":\"\"} + dclass.get_field_p(\"browser\",1) + {\"\",\n\"browser_ver\":\"\"} + dclass.get_ifield_p(\"version\",1) + {\"\",\n\"browser_os\":\"\"} + dclass.get_field_p(\"os\",1) + {\"\"\n}\"} + req.http.dclass_cbe;\n\t\treturn(deliver);\n\t}\n}\n\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"1fac03d9e685e204355f28430ab485f3509bb070","subject":"varnish: use std.lower for compatibility with buster","message":"varnish: use std.lower for compatibility with buster\n","repos":"SoftwareHeritage\/puppet-swh-site,SoftwareHeritage\/puppet-swh-site,SoftwareHeritage\/puppet-swh-site,SoftwareHeritage\/puppet-swh-site,SoftwareHeritage\/puppet-swh-site","old_file":"site-modules\/profile\/files\/varnish\/early_vcl_recv.vcl","new_file":"site-modules\/profile\/files\/varnish\/early_vcl_recv.vcl","new_contents":"# 00_early_vcl_recv.vcl\n#\n# Do early manglement of the host header to simplify its future handling\n#\n# File managed by puppet. All modifications will be lost.\n\nimport std;\n\nsub vcl_recv {\n # Keep original Host header in X-Swh-Original-Host.\n set req.http.x-swh-original-host = req.http.host;\n\n # Set Host header to lower case and trim trailing port number.\n set req.http.host = regsub(std.tolower(req.http.host), \":[0-9]+$\", \"\");\n}\n","old_contents":"# 00_early_vcl_recv.vcl\n#\n# Do early manglement of the host header to simplify its future handling\n#\n# File managed by puppet. All modifications will be lost.\n\nsub vcl_recv {\n # Keep original Host header in X-Swh-Original-Host.\n set req.http.x-swh-original-host = req.http.host;\n\n # Set Host header to lower case and trim trailing port number.\n set req.http.host = regsub(req.http.host.lower(), \":[0-9]+$\", \"\");\n}\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"6e8a5687a38b837ab606e84a8177ea74edfaad12","subject":"Make X-Forwarded-Host compatible with Fastly shielding","message":"Make X-Forwarded-Host compatible with Fastly shielding\n","repos":"elifesciences\/builder,elifesciences\/builder","old_file":"src\/buildercore\/fastly\/vcl\/original-host.vcl","new_file":"src\/buildercore\/fastly\/vcl\/original-host.vcl","new_contents":"if (!req.http.Fastly-FF) {\n set req.http.X-Forwarded-Host = req.http.host;\n}\n","old_contents":"set req.http.X-Forwarded-Host = req.http.host;\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"36aab55e613dfe32cc6862713e95be753d39425a","subject":"Fix 400 bad request of varnish with nginx and apache 2.4","message":"Fix 400 bad request of varnish with nginx and apache 2.4\n\nUpdate vcl from https:\/\/github.com\/cosimo\/varnish-accept-language\n.\/gen_vcl.pl pt de eo es fr hy it pt ru < accept-language.c > new.vcl\n\n(ActionItem3186)\n","repos":"blogoosfero\/noosfero,blogoosfero\/noosfero,blogoosfero\/noosfero,blogoosfero\/noosfero,blogoosfero\/noosfero,blogoosfero\/noosfero,blogoosfero\/noosfero","old_file":"etc\/noosfero\/varnish-accept-language.vcl","new_file":"etc\/noosfero\/varnish-accept-language.vcl","new_contents":"C{\n\n\/* ------------------------------------------------------------------ *\/\n\/* THIS FILE IS AUTOMATICALLY GENERATED BY .\/gen_vcl.pl. DO NOT EDIT. *\/\n\n\/*\n * Accept-language header normalization\n *\n * - Parses client Accept-Language HTTP header\n * - Tries to find the best match with the supported languages\n * - Writes the best match as req.http.X-Varnish-Accept-Language\n *\n * First version: Cosimo, 21\/Jan\/2010\n * Last update: Cosimo, 03\/Nov\/2011\n *\n * http:\/\/github.com\/cosimo\/varnish-accept-language\n *\n *\/\n\n#include <ctype.h> \/* isupper *\/\n#include <stdio.h>\n#include <stdlib.h> \/* qsort *\/\n#include <string.h>\n\n#define DEFAULT_LANGUAGE \"pt\"\n#define SUPPORTED_LANGUAGES \":de:eo:es:fr:hy:it:pt:ru:\"\n\n#define vcl_string char\n#define LANG_LIST_SIZE 16\n#define HDR_MAXLEN 256\n#define LANG_MAXLEN 8\n#define RETURN_LANG(x) { \\\n strncpy(lang, x, LANG_MAXLEN); \\\n return; \\\n}\n#define RETURN_DEFAULT_LANG RETURN_LANG(DEFAULT_LANGUAGE)\n#define PUSH_LANG(x,y) { \\\n \/* fprintf(stderr, \"Pushing lang [%d] %s %.4f\\n\", curr_lang, x, y); *\/ \\\n \/* We have to copy, otherwise root_lang will be the same every time *\/ \\\n strncpy(pl[curr_lang].lang, x, LANG_MAXLEN); \\\n pl[curr_lang].q = y; \\\n curr_lang++; \\\n}\n\nstruct lang_list {\n vcl_string lang[LANG_MAXLEN];\n float q;\n};\n\n\/* In-place lowercase of a string *\/\nstatic void strtolower(char *s) {\n register char *c;\n for (c=s; *c; c++) {\n if (isupper(*c)) {\n *c = tolower(*c);\n }\n }\n return;\n}\n\n\/* Checks if a given language is in the static list of the ones we support *\/\nint is_supported(vcl_string *lang) {\n vcl_string *supported_languages = SUPPORTED_LANGUAGES;\n vcl_string match_str[LANG_MAXLEN + 3] = \"\"; \/* :, :, \\0 = 3 *\/\n int is_supported = 0;\n\n \/* We want to match 'zh-cn' and 'zh-CN' too *\/\n strtolower(lang);\n\n \/* Search \":<lang>:\" in supported languages string *\/\n strncpy(match_str, \":\", 1);\n strncat(match_str, lang, LANG_MAXLEN);\n strncat(match_str, \":\\0\", 2);\n\n if (strstr(supported_languages, match_str))\n is_supported = 1;\n\n return is_supported;\n}\n\n\/* Used by qsort() below *\/\nint sort_by_q(const void *x, const void *y) {\n struct lang_list *a = (struct lang_list *)x;\n struct lang_list *b = (struct lang_list *)y;\n if (a->q > b->q) return -1;\n if (a->q < b->q) return 1;\n return 0;\n}\n\n\/* Reads Accept-Language, parses it, and finds the first match\n among the supported languages. In case of no match,\n returns the default language.\n*\/\nvoid select_language(const vcl_string *incoming_header, char *lang) {\n\n struct lang_list pl[LANG_LIST_SIZE];\n vcl_string *lang_tok = NULL;\n vcl_string root_lang[3];\n vcl_string *header;\n vcl_string header_copy[HDR_MAXLEN];\n vcl_string *pos = NULL;\n vcl_string *q_spec = NULL;\n unsigned int curr_lang = 0, i = 0;\n float q;\n\n \/* Empty or default string, return default language immediately *\/\n if (\n !incoming_header\n || (0 == strcmp(incoming_header, \"en-US\"))\n || (0 == strcmp(incoming_header, \"en-GB\"))\n || (0 == strcmp(incoming_header, DEFAULT_LANGUAGE))\n || (0 == strcmp(incoming_header, \"\"))\n )\n RETURN_DEFAULT_LANG;\n\n \/* Tokenize Accept-Language *\/\n header = strncpy(header_copy, incoming_header, sizeof(header_copy));\n\n while ((lang_tok = strtok_r(header, \" ,\", &pos))) {\n\n q = 1.0;\n\n if ((q_spec = strstr(lang_tok, \";q=\"))) {\n \/* Truncate language name before ';' *\/\n *q_spec = '\\0';\n \/* Get q value *\/\n sscanf(q_spec + 3, \"%f\", &q);\n }\n\n \/* Wildcard language '*' should be last in list *\/\n if ((*lang_tok) == '*') q = 0.0;\n\n \/* Push in the prioritized list *\/\n PUSH_LANG(lang_tok, q);\n\n \/* For cases like 'en-GB', we also want the root language in the final list *\/\n if ('-' == lang_tok[2]) {\n root_lang[0] = lang_tok[0];\n root_lang[1] = lang_tok[1];\n root_lang[2] = '\\0';\n PUSH_LANG(root_lang, q - 0.001);\n }\n\n \/* For strtok_r() to proceed from where it left off *\/\n header = NULL;\n\n \/* Break out if stored max no. of languages *\/\n if (curr_lang >= LANG_LIST_SIZE)\n break;\n }\n\n \/* Sort by priority *\/\n qsort(pl, curr_lang, sizeof(struct lang_list), &sort_by_q);\n\n \/* Match with supported languages *\/\n for (i = 0; i < curr_lang; i++) {\n if (is_supported(pl[i].lang))\n RETURN_LANG(pl[i].lang);\n }\n\n RETURN_DEFAULT_LANG;\n}\n\n\/* Reads req.http.Accept-Language and writes X-Varnish-Accept-Language *\/\nvoid vcl_rewrite_accept_language(const struct sess *sp) {\n vcl_string *in_hdr;\n vcl_string lang[LANG_MAXLEN];\n\n \/* Get Accept-Language header from client *\/\n in_hdr = VRT_GetHdr(sp, HDR_REQ, \"\\020Accept-Language:\");\n\n \/* Normalize and filter out by list of supported languages *\/\n memset(lang, 0, sizeof(lang));\n select_language(in_hdr, lang);\n\n \/* By default, use a different header name: don't mess with backend logic *\/\n VRT_SetHdr(sp, HDR_REQ, \"\\032X-Varnish-Accept-Language:\", lang, vrt_magic_string_end);\n\n return;\n}\n\n\/* vim: syn=c ts=4 et sts=4 sw=4 tw=0\n*\/\n\n\/* THIS FILE IS AUTOMATICALLY GENERATED BY .\/gen_vcl.pl. DO NOT EDIT. *\/\n\/* ------------------------------------------------------------------ *\/\n}C\n\nsub vcl_recv {\n C{\n vcl_rewrite_accept_language(sp);\n }C\n}\n\nsub vcl_fetch {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary + \", X-Varnish-Accept-Language\";\n } else {\n set beresp.http.Vary = \"X-Varnish-Accept-Language\";\n }\n}\n\n","old_contents":"C{\n\n\/* ------------------------------------------------------------------ *\/\n\/* THIS FILE IS AUTOMATICALLY GENERATED BY .\/gen_vcl.pl. DO NOT EDIT. *\/\n\n\/*\n * Accept-language header normalization\n *\n * Cosimo, 21\/01\/2010\n *\n *\/\n\n#include <ctype.h> \/* isupper *\/\n#include <stdio.h>\n#include <stdlib.h> \/* qsort *\/\n#include <string.h>\n\n#define DEFAULT_LANGUAGE \"en\"\n#define SUPPORTED_LANGUAGES \":de:fr:es:ru:pt:hy:en:\"\n\n#define vcl_string char\n#define LANG_LIST_SIZE 16 \n#define LANG_MAXLEN 16\n#define RETURN_LANG(x) { \\\n strncpy(lang, x, LANG_MAXLEN); \\\n return; \\\n}\n#define RETURN_DEFAULT_LANG RETURN_LANG(DEFAULT_LANGUAGE)\n#define PUSH_LANG(x,y) { \\\n \/* fprintf(stderr, \"Pushing lang [%d] %s %.4f\\n\", curr_lang, x, y); *\/ \\\n \/* We have to copy, otherwise root_lang will be the same every time *\/ \\\n strncpy(pl[curr_lang].lang, x, LANG_MAXLEN); \\\n pl[curr_lang].q = y; \\\n curr_lang++; \\\n}\n\nstruct lang_list {\n vcl_string lang[LANG_MAXLEN];\n float q;\n};\n\n\/* In-place lowercase of a string *\/\nstatic void strtolower(char *s) {\n register char *c;\n for (c=s; *c; c++) {\n if (isupper(*c)) {\n *c = tolower(*c);\n }\n }\n return;\n}\n\n\/* Checks if a given language is in the static list of the ones we support *\/\nint is_supported(vcl_string *lang) {\n vcl_string *supported_languages = SUPPORTED_LANGUAGES;\n vcl_string match_str[LANG_MAXLEN + 3] = \"\"; \/* :, :, \\0 = 3 *\/\n int is_supported = 0;\n\n \/* We want to match 'zh-cn' and 'zh-CN' too *\/\n strtolower(lang);\n\n \/* Search \":<lang>:\" in supported languages string *\/\n strncpy(match_str, \":\", 1);\n strncat(match_str, lang, LANG_MAXLEN);\n strncat(match_str, \":\\0\", 2);\n\n if (strstr(supported_languages, match_str)) {\n is_supported = 1;\n }\n\n return is_supported;\n}\n\n\/* Used by qsort() below *\/\nint sort_by_q(const void *x, const void *y) {\n struct lang_list *a = (struct lang_list *)x;\n struct lang_list *b = (struct lang_list *)y;\n if (a->q > b->q) return -1;\n if (a->q < b->q) return 1;\n return 0;\n}\n\n\/* Reads Accept-Language, parses it, and finds the first match\n among the supported languages. In case of no match,\n returns the default language.\n*\/\nvoid select_language(const vcl_string *incoming_header, char *lang) {\n\n struct lang_list pl[LANG_LIST_SIZE];\n vcl_string *lang_tok = NULL;\n vcl_string root_lang[3];\n vcl_string *header;\n vcl_string *pos = NULL;\n vcl_string *q_spec = NULL;\n unsigned int curr_lang = 0, i = 0;\n float q;\n\n \/* Empty or default string, return default language immediately *\/\n if (\n !incoming_header\n || (0 == strcmp(incoming_header, \"en-US\"))\n || (0 == strcmp(incoming_header, \"en-GB\"))\n || (0 == strcmp(incoming_header, DEFAULT_LANGUAGE))\n || (0 == strcmp(incoming_header, \"\"))\n )\n RETURN_DEFAULT_LANG;\n\n \/* Tokenize Accept-Language *\/\n header = (vcl_string *) incoming_header;\n\n while ((lang_tok = strtok_r(header, \" ,\", &pos))) {\n\n q = 1.0;\n\n if ((q_spec = strstr(lang_tok, \";q=\"))) {\n \/* Truncate language name before ';' *\/\n *q_spec = '\\0';\n \/* Get q value *\/\n sscanf(q_spec + 3, \"%f\", &q);\n }\n\n \/* Wildcard language '*' should be last in list *\/\n if ((*lang_tok) == '*') q = 0.0;\n\n \/* Push in the prioritized list *\/\n PUSH_LANG(lang_tok, q);\n\n \/* For cases like 'en-GB', we also want the root language in the final list *\/\n if ('-' == lang_tok[2]) {\n root_lang[0] = lang_tok[0];\n root_lang[1] = lang_tok[1];\n root_lang[2] = '\\0';\n PUSH_LANG(root_lang, q - 0.001);\n }\n\n \/* For strtok_r() to proceed from where it left off *\/\n header = NULL;\n\n \/* Break out if stored max no. of languages *\/\n if (curr_lang >= LANG_MAXLEN) break;\n }\n\n \/* Sort by priority *\/\n qsort(pl, curr_lang, sizeof(struct lang_list), &sort_by_q);\n\n \/* Match with supported languages *\/\n for (i = 0; i < curr_lang; i++) {\n if (is_supported(pl[i].lang))\n RETURN_LANG(pl[i].lang);\n }\n\n RETURN_DEFAULT_LANG;\n}\n\n\/* Reads req.http.Accept-Language and writes X-Varnish-Accept-Language *\/\nvoid vcl_rewrite_accept_language(const struct sess *sp) {\n vcl_string *in_hdr;\n vcl_string lang[LANG_MAXLEN];\n\n memset(lang, 0, LANG_MAXLEN);\n\n \/* Get Accept-Language header from client *\/\n in_hdr = VRT_GetHdr(sp, HDR_REQ, \"\\020Accept-Language:\");\n\n \/* Normalize and filter out by list of supported languages *\/\n select_language(in_hdr, lang);\n\n \/* By default, use a different header name: don't mess with backend logic *\/\n VRT_SetHdr(sp, HDR_REQ, \"\\032X-Varnish-Accept-Language:\", lang, vrt_magic_string_end);\n\n return;\n}\n\n\/* vim: syn=c ts=4 et sts=4 sw=4 tw=0\n*\/\n\n\/* THIS FILE IS AUTOMATICALLY GENERATED BY .\/gen_vcl.pl. DO NOT EDIT. *\/\n\/* ------------------------------------------------------------------ *\/\n}C\n\nsub vcl_recv {\n C{\n vcl_rewrite_accept_language(sp);\n }C\n}\n\nsub vcl_fetch {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary + \", X-Varnish-Accept-Language\";\n } else {\n set beresp.http.Vary = \"X-Varnish-Accept-Language\";\n }\n}\n","returncode":0,"stderr":"","license":"agpl-3.0","lang":"VCL"} {"commit":"d9141b5696bb3965873aeee391695a6ac1d1eaeb","subject":"Updated with nginx backend, vhost example and vcl_error routine","message":"Updated with nginx backend, vhost example and vcl_error routine\n","repos":"erlanger-ru\/erlanger-ru.meta,erlanger-ru\/erlanger-ru.meta,erlanger-ru\/erlanger-ru.meta,erlanger-ru\/erlanger-ru.meta,erlanger-ru\/erlanger-ru.meta","old_file":"doc\/varnish.zotonic.vcl","new_file":"doc\/varnish.zotonic.vcl","new_contents":"# Varnish configuration for a Zotonic site\n#\n# It is a very simple configuration in which static content and the home page is cached\n# and all page requests are handled by the Zotonic server (which does its own caching).\n#\n# All non recognized host names are send to Nginx (or Apache) on port 8080.\n#\n# On *nix:\n# sudo varnishd -a :80 -T localhost:6082 -f varnish.zotonic.vcl -s malloc -u nobody\n#\n# On Mac OS X you need to use the varnish.launchd.plist.\n# sudo cp varnish.zotonic.vcl \/usr\/local\/etc\/varnish\/.\n# sudo cp varnish.launchd.plist \/usr\/local\/etc\/varnish\/.\n# sudo chown root:wheel \/usr\/local\/etc\/varnish\/*\n# sudo launchctl load \/usr\/local\/etc\/varnish\/varnish.launchd.plist\n# sudo start launchd\n#\n# Or run varnishd in the foreground:\n# sudo varnishd -F -a :80 -T localhost:6082 -f varnish.zotonic.vcl -s malloc -u nobody\n#\n# You might want to change the req.http.host and the backend names.\n\nbackend zotonic_com {\n .host = \"127.0.0.1\";\n .port = \"8000\";\n .first_byte_timeout = 300s;\n .connect_timeout = 300s;\n .between_bytes_timeout = 300s;\n}\n\nbackend nginx {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n .first_byte_timeout = 300s;\n .connect_timeout = 300s;\n .between_bytes_timeout = 300s;\n}\n\n\nsub vcl_recv {\n set req.http.X-Forwarded-Host = req.http.host;\n\n ######################################################################\n ########################### VIRTUAL HOSTS ############################\n\n if (req.http.host ~ \"^(www.|)(zotonic|zophrenic).(com|net)$\") {\n set req.backend = zotonic_com;\n }\n # Nginx hosted sites\n #\n else {\n set req.backend = nginx;\n }\n\n ######################################################################\n\n # Add a unique header containing the client address\n unset req.http.X-Forwarded-For;\n set req.http.X-Forwarded-For = client.ip;\n\n # We only deal with GET and HEAD by default\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n return (pass);\n }\n\n # Cache the home page for a short period (ttl = 1 second, see vcl_fetch)\n if (req.url ~ \"^\/$\") {\n unset req.http.Cookie;\n unset req.http.Authenticate;\n set req.grace = 10s;\n return (lookup);\n }\n\n # Cache served css and media files\n if (req.url ~ \"^\/(lib|image|media|favicon.ico)\/\") {\n unset req.http.Cookie;\n unset req.http.Authenticate;\n set req.grace = 30m;\n return (lookup);\n }\n\n return (pass);\n}\n\n\nsub vcl_pipe {\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n set req.http.connection = \"close\";\n return (pipe);\n}\n\n\nsub vcl_pass {\n if (req.url ~ \"^\/comet\") {\n #bereq.connect_timeout = 70;\n #bereq.first_byte_timeout = 70;\n }\n return (pass);\n}\n\n\nsub vcl_fetch {\n if (req.url ~ \"^\/$\") {\n unset obj.http.Set-Cookie;\n\tset obj.grace = 10s;\n\tset obj.ttl = 1s;\n\treturn (deliver);\n }\n if (req.url ~ \"^\/(lib|image|media|favicon.ico)\/\") {\n unset obj.http.Set-Cookie;\n set obj.grace = 30m;\n set obj.ttl = 10m;\n return (deliver);\n }\n return (pass);\n}\n\nsub vcl_error {\n if (obj.status == 503 && req.restarts < 4) {\n restart;\n }\n}\n\n\n","old_contents":"# Varnish configuration for a Zotonic site\n#\n# It is a very simple configuration in which static content and the home page is cached\n# and all page requests are handled by the Zotonic server (which does its own caching).\n#\n# On *nix:\n# sudo varnishd -a :80 -T localhost:6082 -f varnish.zotonic.vcl -s malloc -u nobody\n#\n# On Mac OS X you need to use the varnish.launchd.plist.\n# sudo cp varnish.zotonic.vcl \/usr\/local\/etc\/varnish\/.\n# sudo cp varnish.launchd.plist \/usr\/local\/etc\/varnish\/.\n# sudo chown root:wheel \/usr\/local\/etc\/varnish\/*\n# sudo launchctl load \/usr\/local\/etc\/varnish\/varnish.launchd.plist\n# sudo start launchd\n#\n# Or run varnishd in the foreground:\n# sudo varnishd -F -a :80 -T localhost:6082 -f varnish.zotonic.vcl -s malloc -u nobody\n#\n# You might want to change the req.http.host and the backend names.\n\nbackend zotonic {\n .host = \"127.0.0.1\";\n .port = \"8000\";\n}\n\n\nsub vcl_recv {\n set req.http.host = \"zotonicsite.com\";\n set req.backend = zotonic;\n\n # Add a unique header containing the client address\n unset req.http.X-Forwarded-For;\n set req.http.X-Forwarded-For = client.ip;\n\n # We only deal with GET and HEAD by default\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n return (pass);\n }\n\n # Cache the home page for a short period (ttl = 1 second, see vcl_fetch)\n if (req.url ~ \"^\/$\") {\n unset req.http.Cookie;\n unset req.http.Authenticate;\n set req.grace = 10s;\n return (lookup);\n }\n\n # Cache served css and media files\n if (req.url ~ \"^\/(lib|image|media|favicon.ico)\/\") {\n unset req.http.Cookie;\n unset req.http.Authenticate;\n set req.grace = 30m;\n return (lookup);\n }\n\n return (pass);\n}\n\n\nsub vcl_pipe {\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n set req.http.connection = \"close\";\n return (pipe);\n}\n\n\nsub vcl_pass {\n if (req.url ~ \"^\/comet\") {\n #bereq.connect_timeout = 70;\n #bereq.first_byte_timeout = 70;\n }\n return (pass);\n}\n\n\nsub vcl_fetch {\n if (req.url ~ \"^\/$\") {\n unset obj.http.Set-Cookie;\n\tset obj.grace = 10s;\n\tset obj.ttl = 1s;\n\treturn (deliver);\n }\n if (req.url ~ \"^\/(lib|image|media|favicon.ico)\/\") {\n unset obj.http.Set-Cookie;\n set obj.grace = 20m;\n set obj.ttl = 30m;\n return (deliver);\n }\n return (pass);\n}\n\n\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"033c75b7bb7a0692982c1c06dc2026c0382ca30b","subject":"Update example.vcl","message":"Update example.vcl\n","repos":"gauthier-delacroix\/Varnish-Cache,zhoualbeart\/Varnish-Cache,zhoualbeart\/Varnish-Cache,alarky\/varnish-cache-doc-ja,gauthier-delacroix\/Varnish-Cache,gquintard\/Varnish-Cache,feld\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,zhoualbeart\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,varnish\/Varnish-Cache,alarky\/varnish-cache-doc-ja,ajasty-cavium\/Varnish-Cache,varnish\/Varnish-Cache,zhoualbeart\/Varnish-Cache,alarky\/varnish-cache-doc-ja,varnish\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,alarky\/varnish-cache-doc-ja,chrismoulton\/Varnish-Cache,feld\/Varnish-Cache,chrismoulton\/Varnish-Cache,franciscovg\/Varnish-Cache,feld\/Varnish-Cache,varnish\/Varnish-Cache,franciscovg\/Varnish-Cache,varnish\/Varnish-Cache,alarky\/varnish-cache-doc-ja,ajasty-cavium\/Varnish-Cache,chrismoulton\/Varnish-Cache,franciscovg\/Varnish-Cache,mrhmouse\/Varnish-Cache,chrismoulton\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,zhoualbeart\/Varnish-Cache,franciscovg\/Varnish-Cache,gquintard\/Varnish-Cache,gquintard\/Varnish-Cache,feld\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,mrhmouse\/Varnish-Cache,franciscovg\/Varnish-Cache,mrhmouse\/Varnish-Cache,gquintard\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,feld\/Varnish-Cache,mrhmouse\/Varnish-Cache,mrhmouse\/Varnish-Cache,chrismoulton\/Varnish-Cache","old_file":"etc\/example.vcl","new_file":"etc\/example.vcl","new_contents":"#\n# This is an example VCL file for Varnish.\n#\n# It does not do anything by default, delegating control to the builtin vcl.\n# The builtin VCL is called when there is no explicit explicit return\n# statement.\n#\n# See the VCL chapters in the Users Guide at https:\/\/www.varnish-cache.org\/docs\/\n# and http:\/\/varnish-cache.org\/trac\/wiki\/VCLExamples for more examples.\n\n# Marker to tell the VCL compiler that this VCL has been adapted to the\n# new 4.0 format.\nvcl 4.0;\n\n# Default backend definition. Set this to point to your content server.\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\n\nsub vcl_recv {\n # Happens before we check if we have this in cache already.\n # \n # Typically you clean up the request here, removing cookies you don't need,\n # rewriting the request, etc.\n}\n\nsub vcl_backend_response {\n # Happens after we have read the response headers from the backend.\n # \n # Here you clean the response headers, removing silly Set-Cookie headers\n # and other mistakes your backend does.\n}\n\nsub vcl_deliver {\n # Happens when we have all the pieces we need, and are about to send the\n # response to the client.\n # \n # You can do accounting or modifying the final object here.\n}\n","old_contents":"#\n# This is an example VCL file for Varnish.\n#\n# It does not do anything by default, delegating control to the builtin vcl.\n# The builtin VCL is called when there is no explicit explicit return\n# statement.\n#\n# See the VCL tutorial at https:\/\/www.varnish-cache.org\/docs\/trunk\/tutorial\/\n# and http:\/\/varnish-cache.org\/trac\/wiki\/VCLExamples for more examples.\n\n# Marker to tell the VCL compiler that this VCL has been adapted to the\n# new 4.0 format.\nvcl 4.0;\n\n# Default backend definition. Set this to point to your content server.\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\n\nsub vcl_recv {\n # Happens before we check if we have this in cache already.\n # See http:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/vcl.html#vcl_recv\n}\n\nsub vcl_backend_response {\n # Happens after we have read the response headers from the backend.\n # See http:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/vcl.html#vcl_fetch\n}\n\nsub vcl_deliver {\n # Happens when we have all the pieces we need, and are about to send the\n # response to the client.\n # See http:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/vcl.html#vcl_fetch\n}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"42f3ee8c8d1e7b646f60051f5b0282a6c59820b8","subject":"Field values are case insensitive","message":"Field values are case insensitive\n\nShould address \"HTTP cache must not use a cached response with\nCache-Control: No-CaChE, even with max-age and Expires\" from\nhttps:\/\/cache-tests.fyi.\n","repos":"gquintard\/Varnish-Cache,gquintard\/Varnish-Cache,gquintard\/Varnish-Cache,gquintard\/Varnish-Cache","old_file":"bin\/varnishd\/builtin.vcl","new_file":"bin\/varnishd\/builtin.vcl","new_contents":"\/*-\n * Copyright (c) 2006 Verdens Gang AS\n * Copyright (c) 2006-2015 Varnish Software AS\n * All rights reserved.\n *\n * Author: Poul-Henning Kamp <phk@phk.freebsd.dk>\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in the\n * documentation and\/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * This is the builtin VCL code\n *\/\n\nvcl 4.0;\n\n#######################################################################\n# Client side\n\nsub vcl_recv {\n if (req.method == \"PRI\") {\n \/* This will never happen in properly formed traffic (see: RFC7540) *\/\n return (synth(405));\n }\n if (!req.http.host &&\n req.esi_level == 0 &&\n req.proto ~ \"^(?i)HTTP\/1.1\") {\n \/* In HTTP\/1.1, Host is required. *\/\n return (synth(400));\n }\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\" &&\n req.method != \"PATCH\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization || req.http.Cookie) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n return (hash);\n}\n\nsub vcl_pipe {\n # By default Connection: close is set on all piped requests, to stop\n # connection reuse from sending future requests directly to the\n # (potentially) wrong backend. If you do want this to happen, you can undo\n # it here.\n # unset bereq.http.connection;\n return (pipe);\n}\n\nsub vcl_pass {\n return (fetch);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n return (lookup);\n}\n\nsub vcl_purge {\n return (synth(200, \"Purged\"));\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n \/\/ A pure unadulterated hit, deliver it\n return (deliver);\n }\n if (obj.ttl + obj.grace > 0s) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n return (deliver);\n }\n \/\/ fetch & deliver once we get the result\n return (miss);\n}\n\nsub vcl_miss {\n return (fetch);\n}\n\nsub vcl_deliver {\n return (deliver);\n}\n\n\/*\n * We can come here \"invisibly\" with the following errors: 500 & 503\n *\/\nsub vcl_synth {\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n set resp.http.Retry-After = \"5\";\n set resp.body = {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"};\n return (deliver);\n}\n\n#######################################################################\n# Backend Fetch\n\nsub vcl_backend_fetch {\n if (bereq.method == \"GET\") {\n unset bereq.body;\n }\n return (fetch);\n}\n\nsub vcl_backend_response {\n if (bereq.uncacheable) {\n return (deliver);\n } else if (beresp.ttl <= 0s ||\n beresp.http.Set-Cookie ||\n beresp.http.Surrogate-control ~ \"(?i)no-store\" ||\n (!beresp.http.Surrogate-Control &&\n beresp.http.Cache-Control ~ \"(?i:no-cache|no-store|private)\") ||\n beresp.http.Vary == \"*\") {\n # Mark as \"Hit-For-Miss\" for the next 2 minutes\n set beresp.ttl = 120s;\n set beresp.uncacheable = true;\n }\n return (deliver);\n}\n\nsub vcl_backend_error {\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n set beresp.body = {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + beresp.status + \" \" + beresp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + beresp.status + \" \" + beresp.reason + {\"<\/h1>\n <p>\"} + beresp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + bereq.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"};\n return (deliver);\n}\n\n#######################################################################\n# Housekeeping\n\nsub vcl_init {\n return (ok);\n}\n\nsub vcl_fini {\n return (ok);\n}\n","old_contents":"\/*-\n * Copyright (c) 2006 Verdens Gang AS\n * Copyright (c) 2006-2015 Varnish Software AS\n * All rights reserved.\n *\n * Author: Poul-Henning Kamp <phk@phk.freebsd.dk>\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in the\n * documentation and\/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n * This is the builtin VCL code\n *\/\n\nvcl 4.0;\n\n#######################################################################\n# Client side\n\nsub vcl_recv {\n if (req.method == \"PRI\") {\n \/* This will never happen in properly formed traffic (see: RFC7540) *\/\n return (synth(405));\n }\n if (!req.http.host &&\n req.esi_level == 0 &&\n req.proto ~ \"^(?i)HTTP\/1.1\") {\n \/* In HTTP\/1.1, Host is required. *\/\n return (synth(400));\n }\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\" &&\n req.method != \"PATCH\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization || req.http.Cookie) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n return (hash);\n}\n\nsub vcl_pipe {\n # By default Connection: close is set on all piped requests, to stop\n # connection reuse from sending future requests directly to the\n # (potentially) wrong backend. If you do want this to happen, you can undo\n # it here.\n # unset bereq.http.connection;\n return (pipe);\n}\n\nsub vcl_pass {\n return (fetch);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n return (lookup);\n}\n\nsub vcl_purge {\n return (synth(200, \"Purged\"));\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n \/\/ A pure unadulterated hit, deliver it\n return (deliver);\n }\n if (obj.ttl + obj.grace > 0s) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n return (deliver);\n }\n \/\/ fetch & deliver once we get the result\n return (miss);\n}\n\nsub vcl_miss {\n return (fetch);\n}\n\nsub vcl_deliver {\n return (deliver);\n}\n\n\/*\n * We can come here \"invisibly\" with the following errors: 500 & 503\n *\/\nsub vcl_synth {\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n set resp.http.Retry-After = \"5\";\n set resp.body = {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"};\n return (deliver);\n}\n\n#######################################################################\n# Backend Fetch\n\nsub vcl_backend_fetch {\n if (bereq.method == \"GET\") {\n unset bereq.body;\n }\n return (fetch);\n}\n\nsub vcl_backend_response {\n if (bereq.uncacheable) {\n return (deliver);\n } else if (beresp.ttl <= 0s ||\n beresp.http.Set-Cookie ||\n beresp.http.Surrogate-control ~ \"no-store\" ||\n (!beresp.http.Surrogate-Control &&\n beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n beresp.http.Vary == \"*\") {\n # Mark as \"Hit-For-Miss\" for the next 2 minutes\n set beresp.ttl = 120s;\n set beresp.uncacheable = true;\n }\n return (deliver);\n}\n\nsub vcl_backend_error {\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n set beresp.body = {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + beresp.status + \" \" + beresp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + beresp.status + \" \" + beresp.reason + {\"<\/h1>\n <p>\"} + beresp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + bereq.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"};\n return (deliver);\n}\n\n#######################################################################\n# Housekeeping\n\nsub vcl_init {\n return (ok);\n}\n\nsub vcl_fini {\n return (ok);\n}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"5528b281c02065f73b940dae3dcc08f439efb8ea","subject":"First crack","message":"First crack\n","repos":"rhargreaves\/fastly-vcl-experiments,rhargreaves\/fastly-vcl-experiments","old_file":"oauth_sig_check.vcl","new_file":"oauth_sig_check.vcl","new_contents":"\ntable consumer_secrets {\n\t\"foo\": \"super_secret\"\n}\n\nsub vcl_recv {\n#FASTLY recv\n#DEPLOY recv\n\tset req.url = boltsort.sort(req.url);\n\tset req.http.X-Consumer-Key = regsub(req.url, \".*\\?.*oauth_consumer_key=(.*?)(&|$)\", \"\\1\");\n\tset req.http.X-Consumer-Secret = table.lookup(consumer_secrets, req.http.X-Consumer-Key);\n\tset req.http.X-Provided-Signature = regsub(req.url, \".*\\?.*oauth_signature=(.*?)(&|$)\", \"\\1\");\n\tset req.http.X-Parameters = regsub(req.url, \".*\\?\", \"\");\n\tset req.http.X-Parameters = regsub(req.http.X-Parameters, \"&oauth_signature=[^&]*\", \"\");\n\t\n\tset req.http.X-Base-String-Uri = \n\t\tif(req.http.Fastly-SSL,\"https\",\"http\") \n\t\t\":\/\/\" \n\t\tstd.tolower(req.http.host)\n\t\treq.url.path;\n\n\t# Construct according to https:\/\/tools.ietf.org\/html\/rfc5849#page-18\n\tset req.http.X-Signature-Base-String = \n\t\treq.request\n\t\t\"&\"\n\t\treq.http.X-Base-String-Uri\n\t\t\"&\"\n\t\treq.http.X-Parameters;\n\n\tset req.http.X-Calculated-Signature = urlencode(digest.hmac_sha1_base64(\n\t\treq.http.X-Consumer-Secret \"&\", req.http.X-Signature-Base-String));\n\n\tif(req.http.X-Provided-Signature != req.http.X-Calculated-Signature) {\n\t\terror 401 \"Invalid OAuth signature\";\n\t}\n\n\n\treturn(lookup);\n}\n\nsub vcl_fetch {\n#FASTLY fetch\n\treturn(deliver);\n}\n\nsub vcl_hit {\n#FASTLY hit\n\tif (!obj.cacheable) {\n\t\treturn(pass);\n\t}\n\treturn(deliver);\n}\n\nsub vcl_miss {\n#FASTLY miss\n\treturn(fetch);\n}\n\nsub vcl_deliver{\n#FASTLY deliver\n\tset resp.http.X-Consumer-Key = req.http.X-Consumer-Key;\n\tset resp.http.X-Consumer-Secret = req.http.X-Consumer-Secret;\n\tset resp.http.X-Provided-Signature = req.http.X-Provided-Signature;\n\tset resp.http.X-Calculated-Signature = req.http.X-Calculated-Signature;\n\tset resp.http.X-Parameters = req.http.X-Parameters;\n\tset resp.http.X-Base-String-Uri = req.http.X-Base-String-Uri;\n\tset resp.http.X-Signature-Base-String = req.http.X-Signature-Base-String;\n\treturn(deliver);\n}\n\nsub vcl_error {\n#FASTLY error\n#DEPLOY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n","old_contents":"sub vcl_recv {\n#FASTLY recv\n\treturn(lookup);\n}\n\nsub vcl_fetch {\n#FASTLY fetch\n\treturn(deliver);\n}\n\nsub vcl_hit {\n#FASTLY hit\n\tif (!obj.cacheable) {\n\t\treturn(pass);\n\t}\n\treturn(deliver);\n}\n\nsub vcl_miss {\n#FASTLY miss\n\treturn(fetch);\n}\n\nsub vcl_deliver {\n#FASTLY deliver\n\treturn(deliver);\n}\n\nsub vcl_error {\n#FASTLY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"6fc24ad46d2e85b4569e584e02c43a511348b015","subject":"ensure we do not use request collapsing when using the c-at-e backend","message":"ensure we do not use request collapsing when using the c-at-e backend\n\nrequest collapsing would cause multiple requests for the same path to be served the same response, which would end up meaning one browser would get a polyfill bundle meant for a different browser","repos":"JakeChampion\/polyfill-service,JakeChampion\/polyfill-service","old_file":"fastly\/vcl\/main.vcl","new_file":"fastly\/vcl\/main.vcl","new_contents":"import querystring;\n\nsub sort_comma_separated_value {\n\t# This function takes a CSV and tranforms it into a url where each\n\t# comma-separated-value is a query-string parameter and then uses\n\t# Fastly's querystring.sort function to sort the values. Once sorted\n\t# it then turn the query-parameters back into a CSV.\n\t# Set the CSV on the header `Sort-Value`.\n\t# Returns the sorted CSV on the header `Sorted-Value`.\n\tdeclare local var.value STRING;\n\tset var.value = req.http.Sort-value;\n\n\t# If query value does not exist or is empty, set it to \"\"\n\tset var.value = if(var.value != \"\", var.value, \"\");\n\n\t# Replace all `&` characters with `^`, this is because `&` would break the value up into pieces.\n\tset var.value = regsuball(var.value, \"&\", \"^\");\n\n\t# Replace all `,` characters with `&` to break them into individual query values\n\t# Append `1-` infront of all the query values to make them simpler to transform later\n\tset var.value = \"1-\" regsuball(var.value, \",\", \"&1-\");\n\n\t# Create a querystring-like string in order for querystring.sort to work.\n\tset var.value = querystring.sort(\"?\" var.value);\n\n\t# Grab all the query values from the sorted url\n\tset var.value = regsub(var.value, \"\\?\", \"\");\n\n\t# Reverse all the previous transformations to get back the single `features` query value value\n\tset var.value = regsuball(var.value, \"1-\", \"\");\n\tset var.value = regsuball(var.value, \"&\", \",\");\n\tset var.value = regsuball(var.value, \"\\^\", \"&\");\n\n\tset req.http.Sorted-Value = var.value;\n}\n\nsub normalise_querystring_parameters_for_polyfill_bundle {\n\t# Store the url without the querystring into a temporary header.\n\tdeclare local var.url STRING;\n\tset var.url = querystring.remove(req.url);\n\n\tdeclare local var.querystring STRING;\n\tset var.querystring = \"?\";\n\n\t# Remove all querystring parameters which are not part of the public API.\n\t# set req.url = querystring.regfilter_except(req.url, \"^(features|excludes|rum|unknown|flags|version|ua|callback|compression)$\");\n\n\t# (?i) makes the regex case-insensitive\n\t# The regex will match only if their are characters after `features=` which are not an ampersand (&).\n\tif (req.url.qs ~ \"(?i)[^&=]*features=([^&]+)\") {\n\t\t# Parameter has already been set, use the already set value.\n\t\t# re.group.1 is the first regex capture group in the regex above.\n\t\tif (std.strlen(re.group.1) < 100) {\n\t\t\t# We add the value of the features parameter to this header\n\t\t\t# This is to be able to have sort_comma_separated_value sort the value\n\t\t\tset req.http.Sort-Value = urldecode(re.group.1);\n\t\t\tcall sort_comma_separated_value;\n\t\t\t# The header Sorted-Value now contains the sorted version of the features parameter.\n\t\t\tset var.querystring = querystring.set(var.querystring, \"features\", req.http.Sorted-Value);\n\t\t} else {\n\t\t\tset var.querystring = querystring.set(var.querystring, \"features\", urldecode(re.group.1));\n\t\t}\n\t} else {\n\t\t# Parameter has not been set, use the default value.\n\t\tset var.querystring = querystring.set(var.querystring, \"features\", \"default\");\n\t}\n\n\t# (?i) makes the regex case-insensitive\n\t# The regex will match only if their are characters after `excludes=` which are not an ampersand (&).\n\tif (req.url.qs ~ \"(?i)[^&=]*excludes=([^&]+)\") {\n\t\t# Parameter has already been set, use the already set value.\n\t\t# re.group.1 is the first regex capture group in the regex above.\n\t\tif (std.strlen(re.group.1) < 100) {\n\t\t\t# We add the value of the excludes parameter to this header\n\t\t\t# This is to be able to have sort_comma_separated_value sort the value\n\t\t\tset req.http.Sort-Value = urldecode(re.group.1);\n\t\t\tcall sort_comma_separated_value;\n\t\t\t# The header Sorted-Value now contains the sorted version of the excludes parameter.\n\t\t\tset var.querystring = querystring.set(var.querystring, \"excludes\", req.http.Sorted-Value);\n\t\t} else {\n\t\t\tset var.querystring = querystring.set(var.querystring, \"excludes\", urldecode(re.group.1));\n\t\t}\n\t} else {\n\t\t# If excludes is not set, set to default value \"\"\n\t\tset var.querystring = var.querystring \"&excludes=\";\n\t}\n\n\t# If rum is not set, set to default value \"0\"\n\tif (req.url.qs !~ \"(?i)[^&=]*rum=([^&]+)\") {\n\t\tset var.querystring = querystring.set(var.querystring, \"rum\", \"0\");\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"rum\", re.group.1);\n\t}\n\n\t# If unknown is not set, set to default value \"polyfill\"\n\tif (req.url.qs !~ \"(?i)[^&=]*unknown=([^&]+)\") {\n\t\tset var.querystring = querystring.set(var.querystring, \"unknown\", \"polyfill\");\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"unknown\", re.group.1);\n\t}\n\n\t# If flags is not set, set to default value \"\"\n\tif (req.url.qs !~ \"(?i)[^&=]*flags=([^&]+)\") {\n\t\tset var.querystring = var.querystring \"&flags=\";\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"flags\", urldecode(re.group.1));\n\t}\n\n\t# If version is not set, set to default value \"\"\n\tdeclare local var.version STRING;\n\tif (req.url.qs !~ \"(?i)[^&=]*version=([^&]+)\") {\n\t\tset var.querystring = var.querystring \"&version=\";\n\t} else {\n\t\tif (re.group.1 == \"3.111.0\" || re.group.1 == \"3.110.1\" || re.group.1 == \"3.109.0\" || re.group.1 == \"3.108.0\" || re.group.1 == \"3.104.0\" || re.group.1 == \"3.103.0\" || re.group.1 == \"3.101.0\" || re.group.1 == \"3.98.0\" || re.group.1 == \"3.96.0\" || re.group.1 == \"3.89.4\" || re.group.1 == \"3.53.1\" || re.group.1 == \"3.52.3\" || re.group.1 == \"3.52.2\" || re.group.1 == \"3.52.1\" || re.group.1 == \"3.52.0\" || re.group.1 == \"3.51.0\" || re.group.1 == \"3.50.2\" || re.group.1 == \"3.48.0\" || re.group.1 == \"3.46.0\" || re.group.1 == \"3.42.0\" || re.group.1 == \"3.41.0\" || re.group.1 == \"3.40.0\" || re.group.1 == \"3.39.0\" || re.group.1 == \"3.34.0\" || re.group.1 == \"3.27.4\" || re.group.1 == \"3.25.1\") {\n\t\t\tset var.querystring = querystring.set(var.querystring, \"version\", re.group.1);\n\t\t} else {\n\t\t\tset var.querystring = var.querystring \"&version=\";\n\t\t}\n\t}\n\n\t# If ua is not set, normalise the User-Agent header based upon the version of the polyfill-library that has been requested.\n\tif (req.url.qs !~ \"(?i)[^&=]*ua=([^&]+)\") {\n\t\tif (req.url.qs ~ \"(?i)[^&=]*version=3\\.25\\.1(&|$)\") {\n\t\t\tcall normalise_user_agent_3_25_1;\n\t\t} else {\n\t\t\tcall normalise_user_agent_1_10_1;\n\t\t}\n\t\tset var.querystring = querystring.set(var.querystring, \"ua\", req.http.Normalized-User-Agent);\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"ua\", urldecode(re.group.1));\n\t}\n\n\t# If callback is not set, set to default value \"\"\n\tif (req.url.qs !~ \"(?i)[^&=]*callback=([^&]+)\") {\n\t\tset var.querystring = var.querystring \"&callback=\";\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"callback\", re.group.1);\n\t}\n\n\t# If compression is not set, use the best compression that the user-agent supports.\n\tif (req.url.qs !~ \"(?i)[^&=]*compression=([^&]+)\") {\n\t\t# When Fastly adds Brotli into the Accept-Encoding normalisation we can replace this with:\n\t\t# `set var.querystring = querystring.set(var.querystring, \"compression\", req.http.Accept-Encoding || \"\")`\n\n\t\t# Before SP2, IE\/6 doesn't always read and cache gzipped content correctly.\n\t\tif (req.http.Fastly-Orig-Accept-Encoding && req.http.User-Agent !~ \"MSIE 6\") {\n\t\t\tif (req.http.Fastly-Orig-Accept-Encoding ~ \"br\") {\n\t\t\t\tset var.querystring = querystring.set(var.querystring, \"compression\", \"br\");\n\t\t\t} elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"gzip\") {\n\t\t\t\tset var.querystring = querystring.set(var.querystring, \"compression\", \"gzip\");\n\t\t\t} else {\n\t\t\t\tset var.querystring = var.querystring \"&compression=\";\n\t\t\t}\n\t\t} else {\n\t\t\tset var.querystring = var.querystring \"&compression=\";\n\t\t}\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"compression\", re.group.1);\n\t}\n\tset req.url = var.url var.querystring;\n}\n\ninclude \"top_pops.vcl\";\ninclude \"normalise-user-agent-3-25-1.vcl\";\ninclude \"normalise-user-agent.vcl\";\n\n# The Fastly VCL boilerplate.\ninclude \"fastly-boilerplate-begin.vcl\";\n\ninclude \"breadcrumbs.vcl\";\n\nsub vcl_recv {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_recv;\n\t}\n}\n\nsub vcl_recv {\n\t# js-compute-runtime currently can not handle a uri which is bigger than 1024\n\t# this has been fixed in js-compute-runtime but not yet released -- https:\/\/github.com\/fastly\/js-compute-runtime\/commit\/f36dee28789b1187652874fe76d1801c9a8e5974\n\t# when the fix is released and added into @fastly\/js-compute we can remove this if statement\n\tif (std.strlen(req.url) < 900) {\n\t\t# We use this edge dictionary item as a flag for whether to use compute-at-edge for any requests.\n\t\t# If the item is not found, then we default to `\"0\"`, which we interpret to mean the flag is off.\n\t\tdeclare local var.compute-at-edge-active BOOL;\n\t\tif (std.atoi(table.lookup(compute_at_edge_config, \"active\", \"0\")) == 1) {\n\t\t\tset var.compute-at-edge-active = true;\n\t\t} else {\n\t\t\tset var.compute-at-edge-active = false;\n\t\t}\n\t\tif (var.compute-at-edge-active) {\n\t\t\t# if the querystring parameter `use-compute-at-edge-backend` is set to yes`\n\t\t\t# then use the c@e backend.\n\t\t\t# The querystring parameter is used within our tests, so that we can confirm\n\t\t\t# the compute-at-edge backend is working as we expect it to.\n\t\t\tdeclare local var.use-compute-at-edge-backend STRING;\n\t\t\tset var.use-compute-at-edge-backend = querystring.get(req.url, \"use-compute-at-edge-backend\");\n\t\t\tif (var.use-compute-at-edge-backend == \"yes\") {\n\t\t\t\tset req.backend = F_compute_at_edge;\n\t\t\t\tif (req.backend.healthy) {\n\t\t\t\t\t# if using the c@e backend then do not use the cache at all\n\t\t\t\t\treturn(pass);\n\t\t\t\t}\n\t\t\t# requests can set the querystring parameter to `no` to avoid ever user compute-at-edge\n\t\t\t# if the querystring parameter is not set to no, then we run some logic to decide whether\n\t\t\t# to use compute-at-edge for this request or not.\n\t\t\t} else if (var.use-compute-at-edge-backend != \"no\") {\n\t\t\t\tdeclare local var.selected BOOL;\n\t\t\t\tset var.selected = randombool(1, std.atoi(table.lookup(compute_at_edge_config, \"sample\", \"1000\")));\n\t\t\t\t# this logic is saying, only use compute-at-edge for a request which has come from outside this Fastly\n\t\t\t\t# service. I.E. The request has directly from a client.\n\t\t\t\t# We also have logic which decides how many of those direct client requests use compute-at-edge.\n\t\t\t\t# We default to 1 in 1000 requests using compute-at-edge, this can be configured by the edge dictionary\n\t\t\t\t# named `compute_at_edge_config` and the item in the dictionary named `sample`\n\t\t\t\tif (var.selected && fastly_info.edge.is_tls && !req.is_background_fetch && !req.is_purge && req.restarts == 0 && fastly.ff.visits_this_service == 0) {\n\t\t\t\t\tset req.backend = F_compute_at_edge;\n\t\t\t\t\tif (req.backend.healthy) {\n\t\t\t\t\t\t# if using the c@e backend then do not use the cache at all\n\t\t\t\t\t\treturn(pass);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\nsub vcl_fetch {\n\t# if using the compute-at-edge backend, we want to ensure request collapsing is not enabled\n\t# we don't want request collapsing because request collapsing would cause multiple requests \n\t# for the same path to be served the same response, which would end up meaning one browser \n\t# would get a polyfill bundle meant for a different browser\n\tif (req.backend == F_compute_at_edge) {\n\t\treturn(pass);\n\t}\n}\n\ninclude \"redirects.vcl\";\ninclude \"synthetic-responses.vcl\";\ninclude \"polyfill-service.vcl\";\n\n# Finally include the last bit of VCL, this _must_ be last!\ninclude \"fastly-boilerplate-end.vcl\";\n","old_contents":"import querystring;\n\nsub sort_comma_separated_value {\n\t# This function takes a CSV and tranforms it into a url where each\n\t# comma-separated-value is a query-string parameter and then uses\n\t# Fastly's querystring.sort function to sort the values. Once sorted\n\t# it then turn the query-parameters back into a CSV.\n\t# Set the CSV on the header `Sort-Value`.\n\t# Returns the sorted CSV on the header `Sorted-Value`.\n\tdeclare local var.value STRING;\n\tset var.value = req.http.Sort-value;\n\n\t# If query value does not exist or is empty, set it to \"\"\n\tset var.value = if(var.value != \"\", var.value, \"\");\n\n\t# Replace all `&` characters with `^`, this is because `&` would break the value up into pieces.\n\tset var.value = regsuball(var.value, \"&\", \"^\");\n\n\t# Replace all `,` characters with `&` to break them into individual query values\n\t# Append `1-` infront of all the query values to make them simpler to transform later\n\tset var.value = \"1-\" regsuball(var.value, \",\", \"&1-\");\n\n\t# Create a querystring-like string in order for querystring.sort to work.\n\tset var.value = querystring.sort(\"?\" var.value);\n\n\t# Grab all the query values from the sorted url\n\tset var.value = regsub(var.value, \"\\?\", \"\");\n\n\t# Reverse all the previous transformations to get back the single `features` query value value\n\tset var.value = regsuball(var.value, \"1-\", \"\");\n\tset var.value = regsuball(var.value, \"&\", \",\");\n\tset var.value = regsuball(var.value, \"\\^\", \"&\");\n\n\tset req.http.Sorted-Value = var.value;\n}\n\nsub normalise_querystring_parameters_for_polyfill_bundle {\n\t# Store the url without the querystring into a temporary header.\n\tdeclare local var.url STRING;\n\tset var.url = querystring.remove(req.url);\n\n\tdeclare local var.querystring STRING;\n\tset var.querystring = \"?\";\n\n\t# Remove all querystring parameters which are not part of the public API.\n\t# set req.url = querystring.regfilter_except(req.url, \"^(features|excludes|rum|unknown|flags|version|ua|callback|compression)$\");\n\n\t# (?i) makes the regex case-insensitive\n\t# The regex will match only if their are characters after `features=` which are not an ampersand (&).\n\tif (req.url.qs ~ \"(?i)[^&=]*features=([^&]+)\") {\n\t\t# Parameter has already been set, use the already set value.\n\t\t# re.group.1 is the first regex capture group in the regex above.\n\t\tif (std.strlen(re.group.1) < 100) {\n\t\t\t# We add the value of the features parameter to this header\n\t\t\t# This is to be able to have sort_comma_separated_value sort the value\n\t\t\tset req.http.Sort-Value = urldecode(re.group.1);\n\t\t\tcall sort_comma_separated_value;\n\t\t\t# The header Sorted-Value now contains the sorted version of the features parameter.\n\t\t\tset var.querystring = querystring.set(var.querystring, \"features\", req.http.Sorted-Value);\n\t\t} else {\n\t\t\tset var.querystring = querystring.set(var.querystring, \"features\", urldecode(re.group.1));\n\t\t}\n\t} else {\n\t\t# Parameter has not been set, use the default value.\n\t\tset var.querystring = querystring.set(var.querystring, \"features\", \"default\");\n\t}\n\n\t# (?i) makes the regex case-insensitive\n\t# The regex will match only if their are characters after `excludes=` which are not an ampersand (&).\n\tif (req.url.qs ~ \"(?i)[^&=]*excludes=([^&]+)\") {\n\t\t# Parameter has already been set, use the already set value.\n\t\t# re.group.1 is the first regex capture group in the regex above.\n\t\tif (std.strlen(re.group.1) < 100) {\n\t\t\t# We add the value of the excludes parameter to this header\n\t\t\t# This is to be able to have sort_comma_separated_value sort the value\n\t\t\tset req.http.Sort-Value = urldecode(re.group.1);\n\t\t\tcall sort_comma_separated_value;\n\t\t\t# The header Sorted-Value now contains the sorted version of the excludes parameter.\n\t\t\tset var.querystring = querystring.set(var.querystring, \"excludes\", req.http.Sorted-Value);\n\t\t} else {\n\t\t\tset var.querystring = querystring.set(var.querystring, \"excludes\", urldecode(re.group.1));\n\t\t}\n\t} else {\n\t\t# If excludes is not set, set to default value \"\"\n\t\tset var.querystring = var.querystring \"&excludes=\";\n\t}\n\n\t# If rum is not set, set to default value \"0\"\n\tif (req.url.qs !~ \"(?i)[^&=]*rum=([^&]+)\") {\n\t\tset var.querystring = querystring.set(var.querystring, \"rum\", \"0\");\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"rum\", re.group.1);\n\t}\n\n\t# If unknown is not set, set to default value \"polyfill\"\n\tif (req.url.qs !~ \"(?i)[^&=]*unknown=([^&]+)\") {\n\t\tset var.querystring = querystring.set(var.querystring, \"unknown\", \"polyfill\");\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"unknown\", re.group.1);\n\t}\n\n\t# If flags is not set, set to default value \"\"\n\tif (req.url.qs !~ \"(?i)[^&=]*flags=([^&]+)\") {\n\t\tset var.querystring = var.querystring \"&flags=\";\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"flags\", urldecode(re.group.1));\n\t}\n\n\t# If version is not set, set to default value \"\"\n\tdeclare local var.version STRING;\n\tif (req.url.qs !~ \"(?i)[^&=]*version=([^&]+)\") {\n\t\tset var.querystring = var.querystring \"&version=\";\n\t} else {\n\t\tif (re.group.1 == \"3.111.0\" || re.group.1 == \"3.110.1\" || re.group.1 == \"3.109.0\" || re.group.1 == \"3.108.0\" || re.group.1 == \"3.104.0\" || re.group.1 == \"3.103.0\" || re.group.1 == \"3.101.0\" || re.group.1 == \"3.98.0\" || re.group.1 == \"3.96.0\" || re.group.1 == \"3.89.4\" || re.group.1 == \"3.53.1\" || re.group.1 == \"3.52.3\" || re.group.1 == \"3.52.2\" || re.group.1 == \"3.52.1\" || re.group.1 == \"3.52.0\" || re.group.1 == \"3.51.0\" || re.group.1 == \"3.50.2\" || re.group.1 == \"3.48.0\" || re.group.1 == \"3.46.0\" || re.group.1 == \"3.42.0\" || re.group.1 == \"3.41.0\" || re.group.1 == \"3.40.0\" || re.group.1 == \"3.39.0\" || re.group.1 == \"3.34.0\" || re.group.1 == \"3.27.4\" || re.group.1 == \"3.25.1\") {\n\t\t\tset var.querystring = querystring.set(var.querystring, \"version\", re.group.1);\n\t\t} else {\n\t\t\tset var.querystring = var.querystring \"&version=\";\n\t\t}\n\t}\n\n\t# If ua is not set, normalise the User-Agent header based upon the version of the polyfill-library that has been requested.\n\tif (req.url.qs !~ \"(?i)[^&=]*ua=([^&]+)\") {\n\t\tif (req.url.qs ~ \"(?i)[^&=]*version=3\\.25\\.1(&|$)\") {\n\t\t\tcall normalise_user_agent_3_25_1;\n\t\t} else {\n\t\t\tcall normalise_user_agent_1_10_1;\n\t\t}\n\t\tset var.querystring = querystring.set(var.querystring, \"ua\", req.http.Normalized-User-Agent);\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"ua\", urldecode(re.group.1));\n\t}\n\n\t# If callback is not set, set to default value \"\"\n\tif (req.url.qs !~ \"(?i)[^&=]*callback=([^&]+)\") {\n\t\tset var.querystring = var.querystring \"&callback=\";\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"callback\", re.group.1);\n\t}\n\n\t# If compression is not set, use the best compression that the user-agent supports.\n\tif (req.url.qs !~ \"(?i)[^&=]*compression=([^&]+)\") {\n\t\t# When Fastly adds Brotli into the Accept-Encoding normalisation we can replace this with:\n\t\t# `set var.querystring = querystring.set(var.querystring, \"compression\", req.http.Accept-Encoding || \"\")`\n\n\t\t# Before SP2, IE\/6 doesn't always read and cache gzipped content correctly.\n\t\tif (req.http.Fastly-Orig-Accept-Encoding && req.http.User-Agent !~ \"MSIE 6\") {\n\t\t\tif (req.http.Fastly-Orig-Accept-Encoding ~ \"br\") {\n\t\t\t\tset var.querystring = querystring.set(var.querystring, \"compression\", \"br\");\n\t\t\t} elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"gzip\") {\n\t\t\t\tset var.querystring = querystring.set(var.querystring, \"compression\", \"gzip\");\n\t\t\t} else {\n\t\t\t\tset var.querystring = var.querystring \"&compression=\";\n\t\t\t}\n\t\t} else {\n\t\t\tset var.querystring = var.querystring \"&compression=\";\n\t\t}\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"compression\", re.group.1);\n\t}\n\tset req.url = var.url var.querystring;\n}\n\ninclude \"top_pops.vcl\";\ninclude \"normalise-user-agent-3-25-1.vcl\";\ninclude \"normalise-user-agent.vcl\";\n\n# The Fastly VCL boilerplate.\ninclude \"fastly-boilerplate-begin.vcl\";\n\ninclude \"breadcrumbs.vcl\";\n\nsub vcl_recv {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_recv;\n\t}\n}\n\nsub vcl_recv {\n\t# js-compute-runtime currently can not handle a uri which is bigger than 1024\n\t# this has been fixed in js-compute-runtime but not yet released -- https:\/\/github.com\/fastly\/js-compute-runtime\/commit\/f36dee28789b1187652874fe76d1801c9a8e5974\n\t# when the fix is released and added into @fastly\/js-compute we can remove this if statement\n\tif (std.strlen(req.url) < 900) {\n\t\t# We use this edge dictionary item as a flag for whether to use compute-at-edge for any requests.\n\t\t# If the item is not found, then we default to `\"0\"`, which we interpret to mean the flag is off.\n\t\tdeclare local var.compute-at-edge-active BOOL;\n\t\tif (std.atoi(table.lookup(compute_at_edge_config, \"active\", \"0\")) == 1) {\n\t\t\tset var.compute-at-edge-active = true;\n\t\t} else {\n\t\t\tset var.compute-at-edge-active = false;\n\t\t}\n\t\tif (var.compute-at-edge-active) {\n\t\t\t# if the querystring parameter `use-compute-at-edge-backend` is set to yes`\n\t\t\t# then use the c@e backend.\n\t\t\t# The querystring parameter is used within our tests, so that we can confirm\n\t\t\t# the compute-at-edge backend is working as we expect it to.\n\t\t\tdeclare local var.use-compute-at-edge-backend STRING;\n\t\t\tset var.use-compute-at-edge-backend = querystring.get(req.url, \"use-compute-at-edge-backend\");\n\t\t\tif (var.use-compute-at-edge-backend == \"yes\") {\n\t\t\t\tset req.backend = F_compute_at_edge;\n\t\t\t\tif (req.backend.healthy) {\n\t\t\t\t\t# if using the c@e backend then do not use the cache at all\n\t\t\t\t\treturn(pass);\n\t\t\t\t}\n\t\t\t# requests can set the querystring parameter to `no` to avoid ever user compute-at-edge\n\t\t\t# if the querystring parameter is not set to no, then we run some logic to decide whether\n\t\t\t# to use compute-at-edge for this request or not.\n\t\t\t} else if (var.use-compute-at-edge-backend != \"no\") {\n\t\t\t\tdeclare local var.selected BOOL;\n\t\t\t\tset var.selected = randombool(1, std.atoi(table.lookup(compute_at_edge_config, \"sample\", \"1000\")));\n\t\t\t\t# this logic is saying, only use compute-at-edge for a request which has come from outside this Fastly\n\t\t\t\t# service. I.E. The request has directly from a client.\n\t\t\t\t# We also have logic which decides how many of those direct client requests use compute-at-edge.\n\t\t\t\t# We default to 1 in 1000 requests using compute-at-edge, this can be configured by the edge dictionary\n\t\t\t\t# named `compute_at_edge_config` and the item in the dictionary named `sample`\n\t\t\t\tif (var.selected && fastly_info.edge.is_tls && !req.is_background_fetch && !req.is_purge && req.restarts == 0 && fastly.ff.visits_this_service == 0) {\n\t\t\t\t\tset req.backend = F_compute_at_edge;\n\t\t\t\t\tif (req.backend.healthy) {\n\t\t\t\t\t\t# if using the c@e backend then do not use the cache at all\n\t\t\t\t\t\treturn(pass);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\ninclude \"redirects.vcl\";\ninclude \"synthetic-responses.vcl\";\ninclude \"polyfill-service.vcl\";\n\n# Finally include the last bit of VCL, this _must_ be last!\ninclude \"fastly-boilerplate-end.vcl\";\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"d8690a614012000f349cf096ee6328689b1676b2","subject":"need to check for csrftoken","message":"need to check for csrftoken\n","repos":"alexisbellido\/salt-django-stack,alexisbellido\/salt-django-stack,alexisbellido\/salt-django-stack,alexisbellido\/salt-django-stack","old_file":"zinibu\/varnish\/files\/etc\/varnish\/default-4.vcl","new_file":"zinibu\/varnish\/files\/etc\/varnish\/default-4.vcl","new_contents":"# Managed by saltstack.\n# host id: {{ salt['grains.get']('id', '') }}\n{% set settings = salt['pillar.get']('varnish', {}) -%}\n{% set zinibu_basic = salt['pillar.get']('zinibu_basic', {}) -%}\n#\n# This is an example VCL file for Varnish.\n#\n# It does not do anything by default, delegating control to the\n# builtin VCL. The builtin VCL is called when there is no explicit\n# return statement.\n#\n# See the VCL chapters in the Users Guide at https:\/\/www.varnish-cache.org\/docs\/\n# and https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExamples for more examples.\n\n# Marker to tell the VCL compiler that this VCL has been adapted to the\n# new 4.0 format.\nvcl 4.0;\n\nimport std;\nimport directors;\n\n{%- for id, haproxy_server in zinibu_basic.project.haproxy_servers.iteritems() %}\nbackend bk_appsrv_static_{{ id }} {\n .host = \"{{ haproxy_server.private_ip }}\";\n .port = \"{{ haproxy_server.port }}\";\n .probe = {\n .url = \"{{ zinibu_basic.project.haproxy_check }}\";\n .expected_response = 200;\n .timeout = 1s;\n .interval = 3s;\n .window = 2;\n .threshold = 2;\n .initial = 2;\n }\n}\n{%- endfor %}\n\nsub vcl_init {\n new bar = directors.round_robin();\n{%- for id, haproxy_server in zinibu_basic.project.haproxy_servers.iteritems() %}\n bar.add_backend(bk_appsrv_static_{{ id }});\n{%- endfor %}\n}\n\nacl purge {\n \"localhost\";\n \"127.0.0.1\";\n}\n\nsub vcl_recv {\n # Happens before we check if we have this in cache already.\n #\n # Typically you clean up the request here, removing cookies you don't need,\n # rewriting the request, etc.\n\n # debug bypass\n #return (pass);\n\n #std.log(\"vcl recv: \"+req.request);\n\n # Health Checking\n if (req.url == \"{{ zinibu_basic.project.varnish_check }}\") {\n return (synth(751, \"health check OK!\"));\n }\n\n # send all traffic to the bar director:\n set req.backend_hint = bar.backend();\n\n # Normalize the header, remove the port (in case you're testing this on various TCP ports)\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n # Normalize the query arguments\n set req.url = std.querysort(req.url);\n\n # Allow purging\n if (req.method == \"PURGE\") {\n if (!client.ip ~ purge) { # purge is the ACL defined at the begining\n\t # Not from an allowed IP? Then die with an error.\n return (synth(405, \"This IP is not allowed to send PURGE requests.\"));\n }\n # If you got this stage (and didn't error out above), purge the cached result\n return (purge);\n }\n\n # Only deal with \"normal\" types\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"PATCH\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n # Implementing websocket support (https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html)\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n # Only cache GET or HEAD requests. This makes sure the POST requests are always passed.\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n # Don't think is needed anymore, just check for sessionid cookie\n # Django is setting this cookie so we only check here\n #if (req.http.Cookie ~ \"LOGGED_IN\") {\n # return (pass);\n #}\n\n if (req.http.Authorization) {\n # Not cacheable by default\n return (pass);\n }\n\n set req.http.X-Varnish-Use-Cache = \"TRUE\";\n # unless Django's sessionid or message cookies are in the request, don't pass ANY cookies (referral_source, utm, etc)\n # also, anything inside \/media or \/static should be cached\n if (req.method == \"GET\" && (req.url ~ \"^\/media\" || req.url ~ \"^\/static\" || (req.http.Cookie !~ \"sessionid\" && req.http.Cookie !~ \"csrftoken\" && req.http.Cookie !~ \"messages\"))) {\n unset req.http.Cookie;\n return (hash);\n }\n\n # Large static files are delivered directly to the end-user without\n # waiting for Varnish to fully read the file first.\n # Varnish 4 fully supports Streaming, so set do_stream in vcl_backend_response()\n if (req.url ~ \"^[^?]*\\.(7z|avi|bz2|flac|flv|gz|mka|mkv|mov|mp3|mp4|mpeg|mpg|ogg|ogm|opus|rar|tar|tgz|tbz|txz|wav|webm|xz|zip)(\\?.*)?$\") {\n unset req.http.Cookie;\n return (hash);\n }\n\n # Remove all cookies for static files\n # A valid discussion could be held on this line: do you really need to cache static files that don't cause load? Only if you have memory left.\n # Sure, there's disk I\/O, but chances are your OS will already have these files in their buffers (thus memory).\n # Before you blindly enable this, have a read here: https:\/\/ma.ttias.be\/stop-caching-static-files\/\n if (req.url ~ \"^[^?]*\\.(7z|avi|bmp|bz2|css|csv|doc|docx|eot|flac|flv|gif|gz|ico|jpeg|jpg|js|less|mka|mkv|mov|mp3|mp4|mpeg|mpg|odt|otf|ogg|ogm|opus|pdf|png|ppt|pptx|rar|rtf|svg|svgz|swf|tar|tbz|tgz|ttf|txt|txz|wav|webm|webp|woff|woff2|xls|xlsx|xml|xz|zip)(\\?.*)?$\") {\n unset req.http.Cookie;\n return (hash);\n }\n \n # Are there cookies left with only spaces or that are empty?\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.Cookie;\n }\n\n # Some generic cookie manipulation, useful for all templates that follow\n # Remove the \"has_js\" cookie\n set req.http.Cookie = regsuball(req.http.Cookie, \"has_js=[^;]+(; )?\", \"\");\n\n # Remove any Google Analytics based cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__utm.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"_ga=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"_gat=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmctr=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmcmd.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmccn.=[^;]+(; )?\", \"\");\n\n # Remove DoubleClick offensive cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__gads=[^;]+(; )?\", \"\");\n\n # Remove the Quant Capital cookies (added by some plugin, all __qca)\n #set req.http.Cookie = regsuball(req.http.Cookie, \"__qc.=[^;]+(; )?\", \"\");\n\n # Remove the AddThis cookies\n #set req.http.Cookie = regsuball(req.http.Cookie, \"__atuv.=[^;]+(; )?\", \"\");\n\n # Remove a \";\" prefix in the cookie if present\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n\n if (req.http.Cache-Control ~ \"(?i)no-cache\") {\n #if (req.http.Cache-Control ~ \"(?i)no-cache\" && client.ip ~ editors) { # create the acl editors if you want to restrict the Ctrl-F5\n # http:\/\/varnish.projects.linpro.no\/wiki\/VCLExampleEnableForceRefresh\n # Ignore requests via proxy caches and badly behaved crawlers\n # like msnbot that send no-cache with every request.\n if (! (req.http.Via || req.http.User-Agent ~ \"(?i)bot\" || req.http.X-Purge)) {\n #set req.hash_always_miss = true; # Doesn't seems to refresh the object in the cache\n return(purge); # Couple this with restart in vcl_purge and X-Purge header to avoid loops\n }\n }\n\n # Strip hash, server doesn't need it.\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n # Strip a trailing ? if it exists\n if (req.url ~ \"\\?$\") {\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n return (hash);\n}\n\nsub vcl_pipe {\n # Called upon entering pipe mode.\n # In this mode, the request is passed on to the backend, and any further data from both the client\n # and backend is passed on unaltered until either end closes the connection. Basically, Varnish will\n # degrade into a simple TCP proxy, shuffling bytes back and forth. For a connection in pipe mode,\n # no other VCL subroutine will ever get called after vcl_pipe.\n\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n # set bereq.http.connection = \"close\";\n # here. It is not set by default as it might break some broken web\n # applications, like IIS with NTLM authentication.\n\n # set bereq.http.Connection = \"Close\";\n\n # Implementing websocket support (https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html)\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n\n return (pipe);\n}\n\nsub vcl_pass {\n # Called upon entering pass mode. In this mode, the request is passed on to the backend, and the\n # backend's response is passed on to the client, but is not entered into the cache. Subsequent\n # requests submitted over the same client connection are handled normally.\n\n # return (pass);\n}\n\nsub vcl_hash {\n # Called after vcl_recv to create a hash value for the request. This is used as a key\n # to look up the object in Varnish.\n \n hash_data(req.url);\n \n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n \n # hash cookies for requests that have them\n if (req.http.Cookie) {\n hash_data(req.http.Cookie);\n }\n\n return (lookup);\n}\n\nsub vcl_backend_response {\n # Happens after we have read the response headers from the backend.\n #\n # Here you clean the response headers, removing silly Set-Cookie headers\n # and other mistakes your backend does.\n\n # Called after the response headers has been successfully retrieved from the backend.\n # Enable ESI\n set beresp.do_esi = true;\n # and make sure everything under \/no-cache is, well, not cached\n if (bereq.url ~ \"^\/no-cache\/\") {\n set beresp.uncacheable = true;\n return(deliver); \n }\n\n # Pause ESI request and remove Surrogate-Control header\n if (beresp.http.Surrogate-Control ~ \"ESI\/1.0\") {\n unset beresp.http.Surrogate-Control;\n set beresp.do_esi = true;\n }\n\n # Enable cache for all static files\n # The same argument as the static caches from above: monitor your cache size, if you get data nuked out of it, consider giving up the static file cache.\n # Before you blindly enable this, have a read here: https:\/\/ma.ttias.be\/stop-caching-static-files\/\n if (bereq.url ~ \"^[^?]*\\.(7z|avi|bmp|bz2|css|csv|doc|docx|eot|flac|flv|gif|gz|ico|jpeg|jpg|js|less|mka|mkv|mov|mp3|mp4|mpeg|mpg|odt|otf|ogg|ogm|opus|pdf|png|ppt|pptx|rar|rtf|svg|svgz|swf|tar|tbz|tgz|ttf|txt|txz|wav|webm|webp|woff|woff2|xls|xlsx|xml|xz|zip)(\\?.*)?$\") {\n unset beresp.http.set-cookie;\n }\n\n # Large static files are delivered directly to the end-user without\n # waiting for Varnish to fully read the file first.\n # Varnish 4 fully supports Streaming, so use streaming here to avoid locking.\n if (bereq.url ~ \"^[^?]*\\.(7z|avi|bz2|flac|flv|gz|mka|mkv|mov|mp3|mp4|mpeg|mpg|ogg|ogm|opus|rar|tar|tgz|tbz|txz|wav|webm|xz|zip)(\\?.*)?$\") {\n unset beresp.http.set-cookie;\n set beresp.do_stream = true; # Check memory usage it'll grow in fetch_chunksize blocks (128k by default) if the backend doesn't send a Content-Length header, so only enable it for big objects\n set beresp.do_gzip = false; # Don't try to compress it for storage\n }\n\n # Sometimes, a 301 or 302 redirect formed via Apache's mod_rewrite can mess with the HTTP port that is being passed along.\n # This often happens with simple rewrite rules in a scenario where Varnish runs on :80 and Apache on :8080 on the same box.\n # A redirect can then often redirect the end-user to a URL on :8080, where it should be :80.\n # This may need finetuning on your setup.\n #\n # To prevent accidental replace, we only filter the 301\/302 redirects for now.\n if (beresp.status == 301 || beresp.status == 302) {\n set beresp.http.Location = regsub(beresp.http.Location, \":[0-9]+\", \"\");\n }\n\n # Set 2min cache if unset for static files\n if (beresp.ttl <= 0s || beresp.http.Set-Cookie || beresp.http.Vary == \"*\") {\n set beresp.ttl = 120s; # Important, you shouldn't rely on this, SET YOUR HEADERS in the backend\n set beresp.uncacheable = true;\n\n # Study and test this\n # Mark as \"Hit-For-Pass\" for the next 60 minutes - 24 hours\n #if (bereq.url ~ \"\\.(jpe?g|png|gif|pdf|gz|tgz|bz2|tbz|tar|zip|tiff|tif)$\" || bereq.url ~ \"\/(image|(image_(?:[^\/]|(?!view.*).+)))$\") {\n # set beresp.ttl = std.duration(beresp.http.age+\"s\",0s) + 6h;\n #} elseif (bereq.url ~ \"\\.(svg|swf|ico|mp3|mp4|m4a|ogg|mov|avi|wmv|flv)$\") {\n # set beresp.ttl = std.duration(beresp.http.age+\"s\",0s) + 6h;\n #} elseif (bereq.url ~ \"\\.(xls|vsd|doc|ppt|pps|vsd|doc|ppt|pps|xls|pdf|sxw|rar|odc|odb|odf|odg|odi|odp|ods|odt|sxc|sxd|sxi|sxw|dmg|torrent|deb|msi|iso|rpm)$\") {\n # set beresp.ttl = std.duration(beresp.http.age+\"s\",0s) + 6h;\n #} elseif (bereq.url ~ \"\\.(css|js)$\") {\n # set beresp.ttl = std.duration(beresp.http.age+\"s\",0s) + 24h;\n #} else {\n # set beresp.ttl = std.duration(beresp.http.age+\"s\",0s) + 1h;\n #}\n\n return (deliver);\n }\n\n # Don't cache 50x responses\n if (beresp.status == 500 || beresp.status == 502 || beresp.status == 503 || beresp.status == 504) {\n return (abandon);\n }\n\n # Allow stale content, in case the backend goes down.\n # make Varnish keep all objects for 6 hours beyond their TTL\n set beresp.grace = 6h;\n\n return (deliver);\n}\n\nsub vcl_deliver {\n # Happens when we have all the pieces we need, and are about to send the\n # response to the client.\n #\n # You can do accounting or modifying the final object here.\n\n # Called before a cached object is delivered to the client.\n\n if (obj.hits > 0) { # Add debug header to see if it's a HIT\/MISS and the number of hits, disable when not needed\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n\n # Please note that obj.hits behaviour changed in 4.0, now it counts per objecthead, not per object\n # and obj.hits may not be reset in some cases where bans are in use. See bug 1492 for details.\n # So take hits with a grain of salt\n set resp.http.X-Cache-Hits = obj.hits;\n\n # Remove some headers: PHP version\n unset resp.http.X-Powered-By;\n\n # Remove some headers: Apache version & OS\n unset resp.http.Server;\n unset resp.http.X-Drupal-Cache;\n unset resp.http.X-Varnish;\n unset resp.http.Via;\n unset resp.http.Link;\n unset resp.http.X-Generator;\n\n return (deliver);\n}\n\nsub vcl_purge {\n # Only handle actual PURGE HTTP methods, everything else is discarded\n if (req.method != \"PURGE\") {\n # restart request\n set req.http.X-Purge = \"Yes\";\n return(restart);\n }\n}\n\nsub vcl_synth {\n # Health check\n if (resp.status == 751) {\n set resp.status = 200;\n return (deliver);\n }\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n set resp.http.Retry-After = \"5\";\n synthetic (\"Error\");\n return (deliver);\n}\n","old_contents":"# Managed by saltstack.\n# host id: {{ salt['grains.get']('id', '') }}\n{% set settings = salt['pillar.get']('varnish', {}) -%}\n{% set zinibu_basic = salt['pillar.get']('zinibu_basic', {}) -%}\n#\n# This is an example VCL file for Varnish.\n#\n# It does not do anything by default, delegating control to the\n# builtin VCL. The builtin VCL is called when there is no explicit\n# return statement.\n#\n# See the VCL chapters in the Users Guide at https:\/\/www.varnish-cache.org\/docs\/\n# and https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExamples for more examples.\n\n# Marker to tell the VCL compiler that this VCL has been adapted to the\n# new 4.0 format.\nvcl 4.0;\n\nimport std;\nimport directors;\n\n{%- for id, haproxy_server in zinibu_basic.project.haproxy_servers.iteritems() %}\nbackend bk_appsrv_static_{{ id }} {\n .host = \"{{ haproxy_server.private_ip }}\";\n .port = \"{{ haproxy_server.port }}\";\n .probe = {\n .url = \"{{ zinibu_basic.project.haproxy_check }}\";\n .expected_response = 200;\n .timeout = 1s;\n .interval = 3s;\n .window = 2;\n .threshold = 2;\n .initial = 2;\n }\n}\n{%- endfor %}\n\nsub vcl_init {\n new bar = directors.round_robin();\n{%- for id, haproxy_server in zinibu_basic.project.haproxy_servers.iteritems() %}\n bar.add_backend(bk_appsrv_static_{{ id }});\n{%- endfor %}\n}\n\nacl purge {\n \"localhost\";\n \"127.0.0.1\";\n}\n\nsub vcl_recv {\n # Happens before we check if we have this in cache already.\n #\n # Typically you clean up the request here, removing cookies you don't need,\n # rewriting the request, etc.\n\n # debug bypass\n #return (pass);\n\n #std.log(\"vcl recv: \"+req.request);\n\n # Health Checking\n if (req.url == \"{{ zinibu_basic.project.varnish_check }}\") {\n return (synth(751, \"health check OK!\"));\n }\n\n # send all traffic to the bar director:\n set req.backend_hint = bar.backend();\n\n # Normalize the header, remove the port (in case you're testing this on various TCP ports)\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n # Normalize the query arguments\n set req.url = std.querysort(req.url);\n\n # Allow purging\n if (req.method == \"PURGE\") {\n if (!client.ip ~ purge) { # purge is the ACL defined at the begining\n\t # Not from an allowed IP? Then die with an error.\n return (synth(405, \"This IP is not allowed to send PURGE requests.\"));\n }\n # If you got this stage (and didn't error out above), purge the cached result\n return (purge);\n }\n\n # Only deal with \"normal\" types\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"PATCH\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n # Implementing websocket support (https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html)\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n # Only cache GET or HEAD requests. This makes sure the POST requests are always passed.\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n # Don't think is needed anymore, just check for sessionid cookie\n # Django is setting this cookie so we only check here\n #if (req.http.Cookie ~ \"LOGGED_IN\") {\n # return (pass);\n #}\n\n if (req.http.Authorization) {\n # Not cacheable by default\n return (pass);\n }\n\n set req.http.X-Varnish-Use-Cache = \"TRUE\";\n # unless Django's sessionid or message cookies are in the request, don't pass ANY cookies (referral_source, utm, etc)\n # also, anything inside \/media or \/static should be cached\n if (req.method == \"GET\" && (req.url ~ \"^\/media\" || req.url ~ \"^\/static\" || (req.http.Cookie !~ \"sessionid\" && req.http.Cookie !~ \"messages\"))) {\n unset req.http.Cookie;\n return (hash);\n }\n\n # Large static files are delivered directly to the end-user without\n # waiting for Varnish to fully read the file first.\n # Varnish 4 fully supports Streaming, so set do_stream in vcl_backend_response()\n if (req.url ~ \"^[^?]*\\.(7z|avi|bz2|flac|flv|gz|mka|mkv|mov|mp3|mp4|mpeg|mpg|ogg|ogm|opus|rar|tar|tgz|tbz|txz|wav|webm|xz|zip)(\\?.*)?$\") {\n unset req.http.Cookie;\n return (hash);\n }\n\n # Remove all cookies for static files\n # A valid discussion could be held on this line: do you really need to cache static files that don't cause load? Only if you have memory left.\n # Sure, there's disk I\/O, but chances are your OS will already have these files in their buffers (thus memory).\n # Before you blindly enable this, have a read here: https:\/\/ma.ttias.be\/stop-caching-static-files\/\n if (req.url ~ \"^[^?]*\\.(7z|avi|bmp|bz2|css|csv|doc|docx|eot|flac|flv|gif|gz|ico|jpeg|jpg|js|less|mka|mkv|mov|mp3|mp4|mpeg|mpg|odt|otf|ogg|ogm|opus|pdf|png|ppt|pptx|rar|rtf|svg|svgz|swf|tar|tbz|tgz|ttf|txt|txz|wav|webm|webp|woff|woff2|xls|xlsx|xml|xz|zip)(\\?.*)?$\") {\n unset req.http.Cookie;\n return (hash);\n }\n \n # Are there cookies left with only spaces or that are empty?\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.Cookie;\n }\n\n # Some generic cookie manipulation, useful for all templates that follow\n # Remove the \"has_js\" cookie\n set req.http.Cookie = regsuball(req.http.Cookie, \"has_js=[^;]+(; )?\", \"\");\n\n # Remove any Google Analytics based cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__utm.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"_ga=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"_gat=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmctr=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmcmd.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmccn.=[^;]+(; )?\", \"\");\n\n # Remove DoubleClick offensive cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__gads=[^;]+(; )?\", \"\");\n\n # Remove the Quant Capital cookies (added by some plugin, all __qca)\n #set req.http.Cookie = regsuball(req.http.Cookie, \"__qc.=[^;]+(; )?\", \"\");\n\n # Remove the AddThis cookies\n #set req.http.Cookie = regsuball(req.http.Cookie, \"__atuv.=[^;]+(; )?\", \"\");\n\n # Remove a \";\" prefix in the cookie if present\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n\n if (req.http.Cache-Control ~ \"(?i)no-cache\") {\n #if (req.http.Cache-Control ~ \"(?i)no-cache\" && client.ip ~ editors) { # create the acl editors if you want to restrict the Ctrl-F5\n # http:\/\/varnish.projects.linpro.no\/wiki\/VCLExampleEnableForceRefresh\n # Ignore requests via proxy caches and badly behaved crawlers\n # like msnbot that send no-cache with every request.\n if (! (req.http.Via || req.http.User-Agent ~ \"(?i)bot\" || req.http.X-Purge)) {\n #set req.hash_always_miss = true; # Doesn't seems to refresh the object in the cache\n return(purge); # Couple this with restart in vcl_purge and X-Purge header to avoid loops\n }\n }\n\n # Strip hash, server doesn't need it.\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n # Strip a trailing ? if it exists\n if (req.url ~ \"\\?$\") {\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n return (hash);\n}\n\nsub vcl_pipe {\n # Called upon entering pipe mode.\n # In this mode, the request is passed on to the backend, and any further data from both the client\n # and backend is passed on unaltered until either end closes the connection. Basically, Varnish will\n # degrade into a simple TCP proxy, shuffling bytes back and forth. For a connection in pipe mode,\n # no other VCL subroutine will ever get called after vcl_pipe.\n\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n # set bereq.http.connection = \"close\";\n # here. It is not set by default as it might break some broken web\n # applications, like IIS with NTLM authentication.\n\n # set bereq.http.Connection = \"Close\";\n\n # Implementing websocket support (https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html)\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n\n return (pipe);\n}\n\nsub vcl_pass {\n # Called upon entering pass mode. In this mode, the request is passed on to the backend, and the\n # backend's response is passed on to the client, but is not entered into the cache. Subsequent\n # requests submitted over the same client connection are handled normally.\n\n # return (pass);\n}\n\nsub vcl_hash {\n # Called after vcl_recv to create a hash value for the request. This is used as a key\n # to look up the object in Varnish.\n \n hash_data(req.url);\n \n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n \n # hash cookies for requests that have them\n if (req.http.Cookie) {\n hash_data(req.http.Cookie);\n }\n\n return (lookup);\n}\n\nsub vcl_backend_response {\n # Happens after we have read the response headers from the backend.\n #\n # Here you clean the response headers, removing silly Set-Cookie headers\n # and other mistakes your backend does.\n\n # Called after the response headers has been successfully retrieved from the backend.\n # Enable ESI\n set beresp.do_esi = true;\n # and make sure everything under \/no-cache is, well, not cached\n if (bereq.url ~ \"^\/no-cache\/\") {\n set beresp.uncacheable = true;\n return(deliver); \n }\n\n # Pause ESI request and remove Surrogate-Control header\n if (beresp.http.Surrogate-Control ~ \"ESI\/1.0\") {\n unset beresp.http.Surrogate-Control;\n set beresp.do_esi = true;\n }\n\n # Enable cache for all static files\n # The same argument as the static caches from above: monitor your cache size, if you get data nuked out of it, consider giving up the static file cache.\n # Before you blindly enable this, have a read here: https:\/\/ma.ttias.be\/stop-caching-static-files\/\n if (bereq.url ~ \"^[^?]*\\.(7z|avi|bmp|bz2|css|csv|doc|docx|eot|flac|flv|gif|gz|ico|jpeg|jpg|js|less|mka|mkv|mov|mp3|mp4|mpeg|mpg|odt|otf|ogg|ogm|opus|pdf|png|ppt|pptx|rar|rtf|svg|svgz|swf|tar|tbz|tgz|ttf|txt|txz|wav|webm|webp|woff|woff2|xls|xlsx|xml|xz|zip)(\\?.*)?$\") {\n unset beresp.http.set-cookie;\n }\n\n # Large static files are delivered directly to the end-user without\n # waiting for Varnish to fully read the file first.\n # Varnish 4 fully supports Streaming, so use streaming here to avoid locking.\n if (bereq.url ~ \"^[^?]*\\.(7z|avi|bz2|flac|flv|gz|mka|mkv|mov|mp3|mp4|mpeg|mpg|ogg|ogm|opus|rar|tar|tgz|tbz|txz|wav|webm|xz|zip)(\\?.*)?$\") {\n unset beresp.http.set-cookie;\n set beresp.do_stream = true; # Check memory usage it'll grow in fetch_chunksize blocks (128k by default) if the backend doesn't send a Content-Length header, so only enable it for big objects\n set beresp.do_gzip = false; # Don't try to compress it for storage\n }\n\n # Sometimes, a 301 or 302 redirect formed via Apache's mod_rewrite can mess with the HTTP port that is being passed along.\n # This often happens with simple rewrite rules in a scenario where Varnish runs on :80 and Apache on :8080 on the same box.\n # A redirect can then often redirect the end-user to a URL on :8080, where it should be :80.\n # This may need finetuning on your setup.\n #\n # To prevent accidental replace, we only filter the 301\/302 redirects for now.\n if (beresp.status == 301 || beresp.status == 302) {\n set beresp.http.Location = regsub(beresp.http.Location, \":[0-9]+\", \"\");\n }\n\n # Set 2min cache if unset for static files\n if (beresp.ttl <= 0s || beresp.http.Set-Cookie || beresp.http.Vary == \"*\") {\n set beresp.ttl = 120s; # Important, you shouldn't rely on this, SET YOUR HEADERS in the backend\n set beresp.uncacheable = true;\n\n # Study and test this\n # Mark as \"Hit-For-Pass\" for the next 60 minutes - 24 hours\n #if (bereq.url ~ \"\\.(jpe?g|png|gif|pdf|gz|tgz|bz2|tbz|tar|zip|tiff|tif)$\" || bereq.url ~ \"\/(image|(image_(?:[^\/]|(?!view.*).+)))$\") {\n # set beresp.ttl = std.duration(beresp.http.age+\"s\",0s) + 6h;\n #} elseif (bereq.url ~ \"\\.(svg|swf|ico|mp3|mp4|m4a|ogg|mov|avi|wmv|flv)$\") {\n # set beresp.ttl = std.duration(beresp.http.age+\"s\",0s) + 6h;\n #} elseif (bereq.url ~ \"\\.(xls|vsd|doc|ppt|pps|vsd|doc|ppt|pps|xls|pdf|sxw|rar|odc|odb|odf|odg|odi|odp|ods|odt|sxc|sxd|sxi|sxw|dmg|torrent|deb|msi|iso|rpm)$\") {\n # set beresp.ttl = std.duration(beresp.http.age+\"s\",0s) + 6h;\n #} elseif (bereq.url ~ \"\\.(css|js)$\") {\n # set beresp.ttl = std.duration(beresp.http.age+\"s\",0s) + 24h;\n #} else {\n # set beresp.ttl = std.duration(beresp.http.age+\"s\",0s) + 1h;\n #}\n\n return (deliver);\n }\n\n # Don't cache 50x responses\n if (beresp.status == 500 || beresp.status == 502 || beresp.status == 503 || beresp.status == 504) {\n return (abandon);\n }\n\n # Allow stale content, in case the backend goes down.\n # make Varnish keep all objects for 6 hours beyond their TTL\n set beresp.grace = 6h;\n\n return (deliver);\n}\n\nsub vcl_deliver {\n # Happens when we have all the pieces we need, and are about to send the\n # response to the client.\n #\n # You can do accounting or modifying the final object here.\n\n # Called before a cached object is delivered to the client.\n\n if (obj.hits > 0) { # Add debug header to see if it's a HIT\/MISS and the number of hits, disable when not needed\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n\n # Please note that obj.hits behaviour changed in 4.0, now it counts per objecthead, not per object\n # and obj.hits may not be reset in some cases where bans are in use. See bug 1492 for details.\n # So take hits with a grain of salt\n set resp.http.X-Cache-Hits = obj.hits;\n\n # Remove some headers: PHP version\n unset resp.http.X-Powered-By;\n\n # Remove some headers: Apache version & OS\n unset resp.http.Server;\n unset resp.http.X-Drupal-Cache;\n unset resp.http.X-Varnish;\n unset resp.http.Via;\n unset resp.http.Link;\n unset resp.http.X-Generator;\n\n return (deliver);\n}\n\nsub vcl_purge {\n # Only handle actual PURGE HTTP methods, everything else is discarded\n if (req.method != \"PURGE\") {\n # restart request\n set req.http.X-Purge = \"Yes\";\n return(restart);\n }\n}\n\nsub vcl_synth {\n # Health check\n if (resp.status == 751) {\n set resp.status = 200;\n return (deliver);\n }\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n set resp.http.Retry-After = \"5\";\n synthetic (\"Error\");\n return (deliver);\n}\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"62c938912eeb33f89291d0111c33002f65d62a95","subject":"Skip vulcain headers from varnish request","message":"Skip vulcain headers from varnish request\n","repos":"teohhanhui\/api-platform,api-platform\/api-platform,api-platform\/api-platform,api-platform\/api-platform,api-platform\/api-platform,teohhanhui\/api-platform,teohhanhui\/api-platform,teohhanhui\/api-platform","old_file":"api\/docker\/varnish\/conf\/default.vcl","new_file":"api\/docker\/varnish\/conf\/default.vcl","new_contents":"vcl 4.0;\n\nimport std;\n\nbackend default {\n .host = \"api\";\n .port = \"80\";\n # Health check\n #.probe = {\n # .url = \"\/\";\n # .timeout = 5s;\n # .interval = 10s;\n # .window = 5;\n # .threshold = 3;\n #}\n}\n\n# Hosts allowed to send BAN requests\nacl invalidators {\n \"localhost\";\n \"php\";\n # local Kubernetes network\n \"10.0.0.0\"\/8;\n \"172.16.0.0\"\/12;\n \"192.168.0.0\"\/16;\n}\n\nsub vcl_recv {\n if (req.restarts > 0) {\n set req.hash_always_miss = true;\n }\n\n # Remove the \"Forwarded\" HTTP header if exists (security)\n unset req.http.forwarded;\n # Remove \"Preload\" and \"Fields\" HTTP header to improve Vulcain's performance\n unset req.http.preload;\n unset req.http.fields;\n\n # To allow API Platform to ban by cache tags\n if (req.method == \"BAN\") {\n if (client.ip !~ invalidators) {\n return (synth(405, \"Not allowed\"));\n }\n\n if (req.http.ApiPlatform-Ban-Regex) {\n ban(\"obj.http.Cache-Tags ~ \" + req.http.ApiPlatform-Ban-Regex);\n\n return (synth(200, \"Ban added\"));\n }\n\n return (synth(400, \"ApiPlatform-Ban-Regex HTTP header must be set.\"));\n }\n\n # For health checks\n if (req.method == \"GET\" && req.url == \"\/healthz\") {\n return (synth(200, \"OK\"));\n }\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n # A pure unadulterated hit, deliver it\n return (deliver);\n }\n\n if (std.healthy(req.backend_hint)) {\n # The backend is healthy\n # Fetch the object from the backend\n return (restart);\n }\n\n # No fresh object and the backend is not healthy\n if (obj.ttl + obj.grace > 0s) {\n # Deliver graced object\n # Automatically triggers a background fetch\n return (deliver);\n }\n\n # No valid object to deliver\n # No healthy backend to handle request\n # Return error\n return (synth(503, \"API is down\"));\n}\n\nsub vcl_deliver {\n # Don't send cache tags related headers to the client\n unset resp.http.url;\n # Comment the following line to send the \"Cache-Tags\" header to the client (e.g. to use CloudFlare cache tags)\n unset resp.http.Cache-Tags;\n}\n\nsub vcl_backend_response {\n # Ban lurker friendly header\n set beresp.http.url = bereq.url;\n\n # Add a grace in case the backend is down\n set beresp.grace = 1h;\n}\n","old_contents":"vcl 4.0;\n\nimport std;\n\nbackend default {\n .host = \"api\";\n .port = \"80\";\n # Health check\n #.probe = {\n # .url = \"\/\";\n # .timeout = 5s;\n # .interval = 10s;\n # .window = 5;\n # .threshold = 3;\n #}\n}\n\n# Hosts allowed to send BAN requests\nacl invalidators {\n \"localhost\";\n \"php\";\n # local Kubernetes network\n \"10.0.0.0\"\/8;\n \"172.16.0.0\"\/12;\n \"192.168.0.0\"\/16;\n}\n\nsub vcl_recv {\n if (req.restarts > 0) {\n set req.hash_always_miss = true;\n }\n\n # Remove the \"Forwarded\" HTTP header if exists (security)\n unset req.http.forwarded;\n\n # To allow API Platform to ban by cache tags\n if (req.method == \"BAN\") {\n if (client.ip !~ invalidators) {\n return (synth(405, \"Not allowed\"));\n }\n\n if (req.http.ApiPlatform-Ban-Regex) {\n ban(\"obj.http.Cache-Tags ~ \" + req.http.ApiPlatform-Ban-Regex);\n\n return (synth(200, \"Ban added\"));\n }\n\n return (synth(400, \"ApiPlatform-Ban-Regex HTTP header must be set.\"));\n }\n\n # For health checks\n if (req.method == \"GET\" && req.url == \"\/healthz\") {\n return (synth(200, \"OK\"));\n }\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n # A pure unadulterated hit, deliver it\n return (deliver);\n }\n\n if (std.healthy(req.backend_hint)) {\n # The backend is healthy\n # Fetch the object from the backend\n return (restart);\n }\n\n # No fresh object and the backend is not healthy\n if (obj.ttl + obj.grace > 0s) {\n # Deliver graced object\n # Automatically triggers a background fetch\n return (deliver);\n }\n\n # No valid object to deliver\n # No healthy backend to handle request\n # Return error\n return (synth(503, \"API is down\"));\n}\n\nsub vcl_deliver {\n # Don't send cache tags related headers to the client\n unset resp.http.url;\n # Comment the following line to send the \"Cache-Tags\" header to the client (e.g. to use CloudFlare cache tags)\n unset resp.http.Cache-Tags;\n}\n\nsub vcl_backend_response {\n # Ban lurker friendly header\n set beresp.http.url = bereq.url;\n\n # Add a grace in case the backend is down\n set beresp.grace = 1h;\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"08b8149ed9468b0b8f1f64a5a5daee3421031c59","subject":"put synth read from disk in it's place","message":"put synth read from disk in it's place\n","repos":"NITEMAN\/varnish-bites,NITEMAN\/Varnish_VCL_samps-hacks","old_file":"varnish4\/drupal-base.vcl","new_file":"varnish4\/drupal-base.vcl","new_contents":"\/* Varnish 4 example config for Drupal 7 \/ Pressflow 6 & 7 *\/\n# Original source: https:\/\/github.com\/NITEMAN\/varnish-bites\/varnish4\/drupal-base.vcl\n# Copyright (c) 2015 Pedro Gonz\u00e1lez Serrano and individual contributors.\n# MIT License\n\n# Intended to be used both in simple production environments and with\n# learning\/teaching purposes.\n# Some references may not be yet updated to VCL 4.0, we use SeeV3 then.\n\n# WARNING:\n# Note that the built-in logic will be appended to our code if no return is performed before.\n# Built-in logic is included commented out right after our's for reference purposes in that cases.\n# See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleDefault\n\n#######################################################################\n# Initialization: Version & imports;\n\n\/* Version statement *\/\n# Since Varnish 4.0 it's mandatory to declare VCL version on first line.\nvcl 4.0;\n\n\/* Module (VMOD) imports *\/\n# Standard module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_std.generated.html\nimport std;\n\n# Directors module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# Unused in simple configs.\n#import directors;\n\n\n#######################################################################\n# Probe, backend, ACL and subroutine definitions\n\n\/* Backend probes \/ healthchecks *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#probes\nprobe basic {\n \/* Only test that backend's IP serves content for '\/' *\/\n # This might be a too heavy probe\n # .url = \"\/\";\n \/* Only test that backend's IP has apache working *\/\n # Nginx would fail this probe with a default config\n .request =\n \"OPTIONS * HTTP\/1.1\"\n \"Host: *\"\n \"Connection: close\";\n .interval = 10s;\n .timeout = 2s;\n .window = 8;\n .threshold = 6;\n}\n\n\/* Backend definitions.*\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#backend-definition\nbackend default {\n \/* Default backend on the same machine. WARNING: timeouts could be not big enought for certain POST request *\/\n .host = \"127.0.0.1\";\n .port = \"8008\";\n .connect_timeout = 60s;\n .first_byte_timeout = 60s;\n .between_bytes_timeout = 60s;\n .probe = basic;\n}\n\n\/* Access Control Lists *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#access-control-list-acl\nacl purge_ban {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use '\"localhost\";' instead\n}\nacl allowed_monitors {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n}\n#acl own_proxys {\n# \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n#}\n\n\/* Custom subroutines *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#subroutines\n#TODO# Test in Varnihs 4\n# Empty in simple configs.\n# We can name subs with no restrictions but as a task can need several chunks of code in diferent states,\n# it's a good idea to identify what main sub will call each with a suffix.\n# \/* Example 301 client redirection removing \"www\" prefix from request *\/\n# sub perm_redirections_recv {\n# if ( req.http.host ~ \"^www.*$\" ) {\n# return(synth(751, \"http:\/\/\" + regsub(req.http.host, \"^www\\.\", \"\") + req.url));\n# }\n# }\n# sub perm_redirections_synth {\n# if (resp.status == 751) {\n# \/* Get new URL from the response *\/\n# set resp.http.Location = resp.response;\n# \/* Set HTTP 301 for permanent redirect *\/\n# set resp.status = 301;\n# return (deliver);\n# }\n# }\n\n\n#######################################################################\n# Client side\n\n# vcl_recv: Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-recv\nsub vcl_recv {\n \/* 0th: general bypass, general return & authorization checks *\/\n # Empty in simple configs.\n # Useful for debugging we can pipe or pass the request to default backend here to bypass completely Varnish.\n # return (pipe);\n # return (pass);\n # We can also return here a 200 Ok for network performance benchmarking.\n # return(synth(200, \"Ok\"));\n # Finally we can perform basic HTTP authentification here, by example.\n # SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* 1st: Check for Varnish special requests *\/ \n # Custom response implementation example in order to check that Varnish is working properly.\n # This is usefull for automatic monitoring with monit or when Varnish is behind another proxies like HAProxy.\n if ( ( req.http.host == \"monitor.server.health\"\n || req.http.host == \"health.varnish\" )\n && client.ip ~ allowed_monitors\n && ( req.method == \"OPTIONS\" || req.method == \"GET\" )\n ) {\n return(synth(200, \"Ban added\"));\n }\n # Purge logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#http-purging\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if (req.method == \"PURGE\") {\n if (!client.ip ~ purge_ban) {\n return(synth(405, \"Not allowed.\"));\n }\n return (purge);\n }\n # Ban logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#bans\n if (req.method == \"BAN\") {\n if (!client.ip ~ purge_ban) {\n return(synth(405, \"Not allowed.\"));\n }\n ban(\"req.http.host == \" + req.http.host +\n \"&& req.url == \" + req.url); \n return(synth(200, \"Ban added\"));\n }\n\n \/* 2nd: Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_recv;\n # Here we can also enforce SSL when Varnish run behind some SSL termination point.\n\n \/* 3rd: Time for backend choice *\/\n # Empty in simple configs.\n\n \/* 4th: Prepare headers for the backend *\/\n # Empty in simple configs.\n # Example remove own_proxys from X-Forwarded-For\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/whats-new\/upgrading.html#x-forwarded-for-is-now-set-before-vcl-recv\n # if ( req.restarts == 0\n # && client.ip ~ own_proxys\n # && req.http.x-forwarded-for\n # ) {\n # set req.http.X-Forwarded-For = regsub(req.http.X-Forwarded-For, \",( )?\" + client.ip, \"\");\n # }\n\n \/* 5th: Bypass breakpoint 1 *\/\n # Useful for debugging we can now pipe or pass the request to backend with headers setted.\n # return (pipe);\n # return (pass);\n\n \/* 6th: Decide if we should deal with a request (mostly copied from built-in logic) *\/\n if (req.method == \"PRI\") {\n \/* We do not support SPDY or HTTP\/2.0 *\/\n return (synth(405));\n }\n if ( req.method != \"GET\"\n && req.method != \"HEAD\"\n && req.method != \"PUT\"\n && req.method != \"POST\"\n && req.method != \"TRACE\"\n && req.method != \"OPTIONS\"\n && req.method != \"DELETE\"\n ) {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n\n \/* 7th: Access control for some URLs by ACL *\/\n # Empty in simple configs.\n # By example denial some URLs depending on client-ip, we'll need to define corresponding ACL 'internal'.\n # if ( req.url ~ \"^\/(cron|install)\\.php\"\n # && ! client.ip ~ internal\n # ) {\n # # Have Varnish throw the error directly.\n # return(synth(403, \"Forbidden.\"));\n # # Use a custom error page that you've defined in Drupal at the path \"404\".\n # # set req.url = \"\/403\";\n # }\n\n \/* 8th: Custom exceptions *\/\n # Host exception example:\n # if (req.http.host == \"ejemplo.exception.com\") {\n # return (pass);\n # }\n # Drupal exceptions, edit if we want to cache some AJAX\/AHAH request.\n # Add here filters for never cache URLs such as Payment Gateway's callbacks\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/ooyala\/ping$\" ||\n req.url ~ \"^\/admin\/build\/features\" ||\n req.url ~ \"^\/info\/.*$\" ||\n req.url ~ \"^\/flag\/.*$\" ||\n req.url ~ \"^.*\/ajax\/.*$\" ||\n req.url ~ \"^.*\/ahah\/.*$\") {\n \/* Do not cache these paths *\/\n return (pass);\n }\n # Pipe these paths directly to backend for streaming.\n if (req.url ~ \"^\/admin\/content\/backup_migrate\/export\") {\n return (pipe);\n }\n if (req.url ~ \"^\/system\/files\") {\n return (pipe);\n }\n\n \/* 9th: Serve from anonymous cahe if all backends are down *\/\n if (! std.healthy(req.backend_hint) ) {\n #TODO# Consider moving this to vcl_backend_fetch\n unset req.http.Cookie;\n #TODO# Add sick marker\n } \n\n \/* 10th: Deal with compression and the Accept-Encoding header *\/\n # Althought Varnish 3 handles gziped content itself by default, just to be sure we want to \n # remove Accept-Encoding for some compressed formats.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html#what-does-http-gzip-support-do\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/varnishd.html?highlight=http_gzip_support\n # See (for older configs) https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleNormalizeAcceptEncoding\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|mp4|flv|zip|rar)$\") {\n \/* Already compressed formats, no sense trying to compress again *\/\n unset req.http.Accept-Encoding;\n }\n }\n\n \/* 11th: Another header manipulation *\/\n # Empty in simple configs.\n # We could add here a custom header grouping User-agent families.\n\n \/* 12th: Cookie removal *\/\n # Always cache the following static file types for all users. \n # Use with care if we control certain downloads depending on cookies. \n # Be carefull also if appending .htm[l] via Drupal's clean URLs.\n if ( req.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|woff2|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n && req.url !~ \"\/system\/storage\/serve\"\n ) {\n unset req.http.Cookie;\n }\n # Remove all cookies that backend doesn't need to know about.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRemovingSomeCookies\n if (req.http.Cookie) {\n \/* Warning: Not a pretty solution *\/\n \/* Prefix header containing cookies with ';' *\/\n set req.http.Cookie = \";\" + req.http.Cookie;\n \/* Remove any spaces after ';' in header containing cookies *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n \/* Prefix cookies we want to preserve with one space *\/\n \/* 'S{1,2}ESS[a-z0-9]+' is the regular expression matching a Drupal session cookie ({1,2} added for HTTPS support) *\/\n \/* 'NO_CACHE' is usually set after a POST request to make sure issuing user see the results of his post *\/\n \/* 'OATMEAL' & 'CHOCOLATECHIP' are special cookies used by Drupal's Bakery module to provide Single Sign On *\/\n \/* Keep in mind we should add here any cookie that should reach the backend such as splahs avoiding cookies *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \";(S{1,2}ESS[a-z0-9]+|NO_CACHE|OATMEAL|CHOCOLATECHIP)=\", \"; \\1=\");\n \/* Remove from the header any single Cookie not prefixed with a space until next ';' separator *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n \/* Remove any '; ' at the start or the end of the header *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n\n if (req.http.Cookie == \"\") {\n \/* If there are no remaining cookies, remove the cookie header. *\/\n unset req.http.Cookie;\n }\n }\n\n \/* 13th: Session cookie & special cookies bypass caching stage *\/\n # As we might want to cache some requests, hashed with its cookies, \n # we don't simply pass when some cookies remain present at this point.\n # Instead we look for request that must be passed due to the cookie header.\n if ( req.http.Cookie ~ \"SESS\"\n || req.http.Cookie ~ \"SSESS\"\n || req.http.Cookie ~ \"NO_CACHE\"\n || req.http.Cookie ~ \"OATMEAL\"\n || req.http.Cookie ~ \"CHOCOLATECHIP\"\n ) {\n return (pass);\n }\n\n \/* 14th: Bypass breakpoint 2 *\/\n # Useful for debugging we can now pipe or pass the request to backend to bypass cache.\n # return (pipe);\n # return (pass);\n\n \/* 15th: Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning inconditionally.\n return (hash);\n}\n\n# vcl_pipe: Called upon entering pipe mode.\n# In this mode, the request is passed on to the backend, \n# and any further data from either client or backend is passed on unaltered until either end closes the connection.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pipe\n# sub vcl_pipe {\n# # By default Connection: close is set on all piped requests, to stop\n# # connection reuse from sending future requests directly to the\n# # (potentially) wrong backend. If you do want this to happen, you can undo\n# # it here.\n# # unset bereq.http.connection;\n# return (pipe);\n# }\n\n# vcl_pass: Called upon entering pass mode. \n# In this mode, the request is passed on to the backend, and the backend's response is passed on to the client, \n# but is not entered into the cache.\n# Subsequent requests submitted over the same client connection are handled normally.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pass\n# sub vcl_pass {\n# return (fetch);\n# }\n\n# vcl_hash: You may call hash_data() on the data you would like to add to the hash.\n# Hash is used by Varnish to uniquely identify objects.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hash\nsub vcl_hash {\n \/* Hash cookie data *\/\n # As requests with same URL and host can produce diferent results when issued with different cookies,\n # we need to store items hashed with the associated cookies. Note that cookies are already sanitized when we reach this point.\n if (req.http.Cookie) {\n \/* Include cookie in cache hash *\/\n hash_data(req.http.Cookie);\n }\n\n \/* Custom header hashing *\/\n # Empty in simple configs.\n # Example for caching differents object versions by device previously detected (when static content could also vary):\n # if (req.http.X-UA-Device) {\n # hash_data(req.http.X-UA-Device);\n # }\n # Example for caching diferent object versions by X-Forwarded-Proto, trying to be smart about what kind of request\n # could generate diffetent responses.\n if ( req.http.X-Forwarded-Proto\n && req.url !~ \"(?i)\\.(png|gif|jpeg|jpg|ico|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|woff2|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\") {\n hash_data(req.http.X-Forwarded-Proto);\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (lookup);\n# }\n\n# vcl_purge: Called after the purge has been executed and all its variants have been evited.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-purge\n# sub vcl_purge {\n# return (synth(200, \"Purged\"));\n# }\n\n# vcl_hit: Called after a cache lookup if the requested document was found in the cache.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hit\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n \/\/ A pure unadultered hit, deliver it\n return (deliver);\n }\n \/* Allow varnish to serve up stale content if it is responding slowly *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n if (obj.ttl + 60s > 0s) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n return (deliver);\n }\n \/* Allow varish to serve up stale content if all backends are down *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n if ( ! std.healthy(req.backend_hint)\n && obj.ttl + obj.grace > 0s\n ) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n return (deliver);\n }\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning inconditionally.\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\n# vcl_miss: Called after a cache lookup if the requested document was not found in the cache.\n# Its purpose is to decide whether or not to attempt to retrieve the document from the backend, and which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-miss\n# sub vcl_miss {\n# return (fetch);\n# }\n\n# vcl_deliver: Called before an object is delivered to the client\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-deliver\nsub vcl_deliver {\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # Add whether the object is a cache hit or miss and the number of hits for the object.\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Addingaheaderindicatinghitmiss\n # In Varnish 4 the obj.hits counter behaviour has changed (see bug 1492), so\n # we use a different method: if X-Varnish contains only 1 id, we have a miss,\n # if it contains more (and therefore a space), we have a hit.\n if (resp.http.x-varnish ~ \" \") {\n set resp.http.X-Cache = \"HIT\";\n # Since in Varnish 4 the behaviour of obj.hits changed, this might not be accurate\n # See https:\/\/www.varnish-cache.org\/trac\/ticket\/1492\n set resp.http.X-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Cache = \"MISS\";\n \/* Show the results of cookie sanitization *\/\n set resp.http.X-Cookie = req.http.Cookie;\n }\n\n #TODO# Add sick marker\n\n # Restart count\n if ( req.restarts > 0) {\n set resp.http.X-Restarts = req.restarts;\n }\n\n # Add the Varnish server hostname\n set resp.http.X-Varnish-Server = server.hostname;\n # If we have setted a custom header with device family detected we can show it:\n # if (req.http.X-UA-Device) {\n # set resp.http.X-UA-Device = req.http.X-UA-Device;\n # }\n # If we have recived a custom header with the protocol in the request we can show it:\n # if (req.http.X-Forwarded-Proto) {\n # set resp.http.X-Forwarded-Proto = req.http.X-Forwarded-Proto;\n # }\n\n \/* Vary header manipulation *\/\n # Empty in simple configs.\n # By example, if we are storing & serving diferent objects depending on User-Agent header we must set the correct Vary header:\n # if (resp.http.Vary) {\n # set resp.http.Vary = resp.http.Vary + \",User-Agent\";\n # } else {\n # set resp.http.Vary = \"User-Agent\";\n # }\n\n \/* Fake headers *\/\n # Empty in simple configs\n # We can fake server headers here, by example:\n # set resp.http.Server = \"Deep thought\";\n # set resp.http.X-Powered-By = \"BOFH\";\n # Or have some fun with headers:\n # See http:\/\/www.nextthing.org\/archives\/2005\/08\/07\/fun-with-http-headers\n # See http:\/\/royal.pingdom.com\/2012\/08\/15\/fun-and-unusual-http-response-headers\/\n # set resp.http.X-Thank-You = \"for bothering to look at my HTTP headers\";\n # set resp.http.X-Answer = \"42\";\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_deliver {\n# return (deliver);\n# }\n\n# vcl_synth: Called to deliver a synthetic object. A synthetic object is generated in VCL,\n# not fetched from the backend. It is typically contructed using the synthetic() function.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-synth\n\/*\n * We can come here \"invisibly\" with the following errors: 413, 417 & 503\n *\/\nsub vcl_synth {\n \/* Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_synth;\n\n \/* Try to restart request in case of failure *\/\n # Note that max_restarts defaults to 4\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if (resp.status == 503 && req.restarts < 4) {\n return(restart);\n }\n\n \/* Set common headers for synthetic responses *\/\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n\n \/* HTTP Authentification client request *\/\n # Empty in simple configs. SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* Load synthetic responses from disk *\/\n #TODO# Ensure that this is only done at boot time and we don't hit disk in-flight\n # Example custom 403 error page.\n # if (resp.status == 403) {\n # synthetic(std.fileread(\"\/403.html\"));\n # return(deliver);\n # }\n\n \/* Error page & refresh \/ redirections *\/\n # We have plenty of choices when we have to serve an error to the client, \n # from the default error page to javascript black magic or plain redirections.\n # Adding some external statistic javascript to track failures served to clients is strongly suggested.\n # We can't use external resources on synthetic content, everything must be inlined.\n # If we need to include images we can embed them in base64 encoding.\n # Here is the default error page for Varnish 4 (not so pretty)\n # We're using error 200 for monitoring puposes which should not be retried client side *\/\n if ( resp.status != 200) {\n set resp.http.Retry-After = \"5\";\n }\n\n # Consider add some analytics stuff to trace accesses\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning inconditionally.\n return (deliver);\n}\n\n#######################################################################\n# Backend Fetch\n\n# vcl_backend_fetch: Called before sending the backend request. In this subroutine you typically alter the request before it gets to the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-fetch\n# sub vcl_backend_fetch {\n# return (fetch);\n# }\n\n# vcl_backend_response: Called after the response headers has been successfully retrieved from the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-response\nsub vcl_backend_response {\n \/* Caching exceptions *\/\n # Varnish will cache objects with response codes: 200, 203, 300, 301, 302, 307, 404 & 410.\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/VCL_Basics.html#the-initial-value-of-beresp-ttl\n # Drupal's Imagecache module can return a 307 redirection to the requested url itself and, depending on Drupal's cache settings,\n # this could lead to a redirection loop being cached for a long time but also we want Varnish to shield a little the backend.\n # See http:\/\/drupal.org\/node\/1248010\n # See http:\/\/drupal.org\/node\/310656\n if (beresp.status == 307 &&\n #TODO# verify that this work better than 'bereq.url ~ \"imagecache\"' *\/\n beresp.http.Location == bereq.url &&\n beresp.ttl > 5s) {\n set beresp.ttl = 5s;\n set beresp.http.cache-control = \"max-age=5\";\n }\n\n \/* Request retrial *\/\n if ( beresp.status == 500\n || beresp.status == 503\n ) {\n #TODO# consider not restarting POST requests as seenV3 on https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleSaintMode\n return (retry);\n }\n\n \/* Enable grace mode. Related with vcl_hit *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n set beresp.grace = 1h;\n\n \/* Strip cookies from the following static file types for all users. Related with our 12th stage on vcl_recv *\/\n if (bereq.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|woff2|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\") {\n unset beresp.http.set-cookie;\n }\n\n \/* Gzip response *\/\n # Empty in simple configs\n # Use Varnish to Gzip respone, if suitable, before storing it on cache\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html\n if ( ! beresp.http.Content-Encoding\n && ( beresp.http.content-type ~ \"text\"\n || beresp.http.content-type ~ \"application\/x-javascript\"\n || beresp.http.content-type ~ \"application\/javascript\"\n || beresp.http.content-type ~ \"application\/rss+xml\"\n || beresp.http.content-type ~ \"application\/xml\"\n || beresp.http.content-type ~ \"Application\/JSON\")\n ) {\n set beresp.do_gzip = true;\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # We can add the name of the backend that has processed the request:\n # set beresp.http.X-Backend = beresp.backend.name;\n # We can use a header to tell if the object was gziped by Varnish\n # if (beresp.do_gzip) {\n # set beresp.http.X-Varnish-Gzipped = \"yes\";\n # } else {\n # set beresp.http.X-Varnish-Gizipped = \"no\";\n # }\n # We can also add headers informing whether the object is cacheable or not and why.\n # https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Varnish3.0\n if (beresp.ttl <= 0s) {\n \/* Varnish determined the object was not cacheable *\/\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n } elsif (bereq.http.Cookie ~ \"(SESS|SSESS|NO_CACHE|OATMEAL|CHOCOLATECHIP)\") {\n \/* We don't wish to cache content for logged in users or with certain cookies. Related with our 9th stage on vcl_recv *\/\n set beresp.http.X-Cacheable = \"NO:Cookies\";\n # return(hit_for_pass);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n \/* We are respecting the Cache-Control=private header from the backend *\/\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n # return(hit_for_pass);\n } else {\n \/* Varnish determined the object was cacheable *\/\n set beresp.http.X-Cacheable = \"YES\";\n }\n\n \/* Further header manipulation *\/\n # Empty in simple configs.\n # We can also unset some headers to prevent information disclosure and save some cache space\n # unset beresp.http.Server;\n # unset beresp.http.X-Powered-By;\n # Retry count\n if ( bereq.retries > 0) {\n set beresp.http.X-Retries = bereq.retries;\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_backend_response {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Surrogate-control ~ \"no-store\" ||\n# (!beresp.http.Surrogate-Control &&\n# beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n# beresp.http.Vary == \"*\") {\n# \/*\n# * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# *\/\n# set beresp.ttl = 120s;\n# set beresp.uncacheable = true;\n# }\n# return (deliver);\n# }\n\n# vcl_backend_error: This subroutine is called if we fail the backend fetch.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-error\nsub vcl_backend_error {\n\n \/* Try to restart request in case of failure *\/\n #TODO# Confirm max_retries default value\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if (bereq.retries < 4) {\n return (retry);\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # Retry count\n if ( bereq.retries > 0) {\n set beresp.http.X-Retries = bereq.retries;\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + beresp.status + \" \" + beresp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + beresp.status + \" \" + beresp.reason + {\"<\/h1>\n <p>\"} + beresp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + bereq.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this point.\n return (deliver);\n}\n\n#######################################################################\n# Housekeeping\n\n# vcl_init: Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-init\n# Here is where you should declare your directors now.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-backends.html#directors\n# Empty in simple configs\n# sub vcl_init {\n# return (ok);\n# }\n\n# vcl_fini: Called when VCL is discarded only after all requests have exited the VCL. Typically used to clean up VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-fini\n# sub vcl_fini {\n# return (ok);\n# }\n\n","old_contents":"\/* Varnish 4 example config for Drupal 7 \/ Pressflow 6 & 7 *\/\n# Original source: https:\/\/github.com\/NITEMAN\/varnish-bites\/varnish4\/drupal-base.vcl\n# Copyright (c) 2015 Pedro Gonz\u00e1lez Serrano and individual contributors.\n# MIT License\n\n# Intended to be used both in simple production environments and with\n# learning\/teaching purposes.\n# Some references may not be yet updated to VCL 4.0, we use SeeV3 then.\n\n# WARNING:\n# Note that the built-in logic will be appended to our code if no return is performed before.\n# Built-in logic is included commented out right after our's for reference purposes in that cases.\n# See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleDefault\n\n#######################################################################\n# Initialization: Version & imports;\n\n\/* Version statement *\/\n# Since Varnish 4.0 it's mandatory to declare VCL version on first line.\nvcl 4.0;\n\n\/* Module (VMOD) imports *\/\n# Standard module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_std.generated.html\nimport std;\n\n# Directors module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# Unused in simple configs.\n#import directors;\n\n\n#######################################################################\n# Probe, backend, ACL and subroutine definitions\n\n\/* Backend probes \/ healthchecks *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#probes\nprobe basic {\n \/* Only test that backend's IP serves content for '\/' *\/\n # This might be a too heavy probe\n # .url = \"\/\";\n \/* Only test that backend's IP has apache working *\/\n # Nginx would fail this probe with a default config\n .request =\n \"OPTIONS * HTTP\/1.1\"\n \"Host: *\"\n \"Connection: close\";\n .interval = 10s;\n .timeout = 2s;\n .window = 8;\n .threshold = 6;\n}\n\n\/* Backend definitions.*\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#backend-definition\nbackend default {\n \/* Default backend on the same machine. WARNING: timeouts could be not big enought for certain POST request *\/\n .host = \"127.0.0.1\";\n .port = \"8008\";\n .connect_timeout = 60s;\n .first_byte_timeout = 60s;\n .between_bytes_timeout = 60s;\n .probe = basic;\n}\n\n\/* Access Control Lists *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#access-control-list-acl\nacl purge_ban {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use '\"localhost\";' instead\n}\nacl allowed_monitors {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n}\n#acl own_proxys {\n# \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n#}\n\n\/* Custom subroutines *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#subroutines\n#TODO# Test in Varnihs 4\n# Empty in simple configs.\n# We can name subs with no restrictions but as a task can need several chunks of code in diferent states,\n# it's a good idea to identify what main sub will call each with a suffix.\n# \/* Example 301 client redirection removing \"www\" prefix from request *\/\n# sub perm_redirections_recv {\n# if ( req.http.host ~ \"^www.*$\" ) {\n# return(synth(751, \"http:\/\/\" + regsub(req.http.host, \"^www\\.\", \"\") + req.url));\n# }\n# }\n# sub perm_redirections_synth {\n# if (resp.status == 751) {\n# \/* Get new URL from the response *\/\n# set resp.http.Location = resp.response;\n# \/* Set HTTP 301 for permanent redirect *\/\n# set resp.status = 301;\n# return (deliver);\n# }\n# }\n\n\n#######################################################################\n# Client side\n\n# vcl_recv: Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-recv\nsub vcl_recv {\n \/* 0th: general bypass, general return & authorization checks *\/\n # Empty in simple configs.\n # Useful for debugging we can pipe or pass the request to default backend here to bypass completely Varnish.\n # return (pipe);\n # return (pass);\n # We can also return here a 200 Ok for network performance benchmarking.\n # return(synth(200, \"Ok\"));\n # Finally we can perform basic HTTP authentification here, by example.\n # SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* 1st: Check for Varnish special requests *\/ \n # Custom response implementation example in order to check that Varnish is working properly.\n # This is usefull for automatic monitoring with monit or when Varnish is behind another proxies like HAProxy.\n if ( ( req.http.host == \"monitor.server.health\"\n || req.http.host == \"health.varnish\" )\n && client.ip ~ allowed_monitors\n && ( req.method == \"OPTIONS\" || req.method == \"GET\" )\n ) {\n return(synth(200, \"Ban added\"));\n }\n # Purge logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#http-purging\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if (req.method == \"PURGE\") {\n if (!client.ip ~ purge_ban) {\n return(synth(405, \"Not allowed.\"));\n }\n return (purge);\n }\n # Ban logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#bans\n if (req.method == \"BAN\") {\n if (!client.ip ~ purge_ban) {\n return(synth(405, \"Not allowed.\"));\n }\n ban(\"req.http.host == \" + req.http.host +\n \"&& req.url == \" + req.url); \n return(synth(200, \"Ban added\"));\n }\n\n \/* 2nd: Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_recv;\n # Here we can also enforce SSL when Varnish run behind some SSL termination point.\n\n \/* 3rd: Time for backend choice *\/\n # Empty in simple configs.\n\n \/* 4th: Prepare headers for the backend *\/\n # Empty in simple configs.\n # Example remove own_proxys from X-Forwarded-For\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/whats-new\/upgrading.html#x-forwarded-for-is-now-set-before-vcl-recv\n # if ( req.restarts == 0\n # && client.ip ~ own_proxys\n # && req.http.x-forwarded-for\n # ) {\n # set req.http.X-Forwarded-For = regsub(req.http.X-Forwarded-For, \",( )?\" + client.ip, \"\");\n # }\n\n \/* 5th: Bypass breakpoint 1 *\/\n # Useful for debugging we can now pipe or pass the request to backend with headers setted.\n # return (pipe);\n # return (pass);\n\n \/* 6th: Decide if we should deal with a request (mostly copied from built-in logic) *\/\n if (req.method == \"PRI\") {\n \/* We do not support SPDY or HTTP\/2.0 *\/\n return (synth(405));\n }\n if ( req.method != \"GET\"\n && req.method != \"HEAD\"\n && req.method != \"PUT\"\n && req.method != \"POST\"\n && req.method != \"TRACE\"\n && req.method != \"OPTIONS\"\n && req.method != \"DELETE\"\n ) {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n\n \/* 7th: Access control for some URLs by ACL *\/\n # Empty in simple configs.\n # By example denial some URLs depending on client-ip, we'll need to define corresponding ACL 'internal'.\n # if ( req.url ~ \"^\/(cron|install)\\.php\"\n # && ! client.ip ~ internal\n # ) {\n # # Have Varnish throw the error directly.\n # return(synth(403, \"Forbidden.\"));\n # # Use a custom error page that you've defined in Drupal at the path \"404\".\n # # set req.url = \"\/403\";\n # }\n\n \/* 8th: Custom exceptions *\/\n # Host exception example:\n # if (req.http.host == \"ejemplo.exception.com\") {\n # return (pass);\n # }\n # Drupal exceptions, edit if we want to cache some AJAX\/AHAH request.\n # Add here filters for never cache URLs such as Payment Gateway's callbacks\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/ooyala\/ping$\" ||\n req.url ~ \"^\/admin\/build\/features\" ||\n req.url ~ \"^\/info\/.*$\" ||\n req.url ~ \"^\/flag\/.*$\" ||\n req.url ~ \"^.*\/ajax\/.*$\" ||\n req.url ~ \"^.*\/ahah\/.*$\") {\n \/* Do not cache these paths *\/\n return (pass);\n }\n # Pipe these paths directly to backend for streaming.\n if (req.url ~ \"^\/admin\/content\/backup_migrate\/export\") {\n return (pipe);\n }\n if (req.url ~ \"^\/system\/files\") {\n return (pipe);\n }\n\n \/* 9th: Serve from anonymous cahe if all backends are down *\/\n if (! std.healthy(req.backend_hint) ) {\n #TODO# Consider moving this to vcl_backend_fetch\n unset req.http.Cookie;\n #TODO# Add sick marker\n } \n\n \/* 10th: Deal with compression and the Accept-Encoding header *\/\n # Althought Varnish 3 handles gziped content itself by default, just to be sure we want to \n # remove Accept-Encoding for some compressed formats.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html#what-does-http-gzip-support-do\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/varnishd.html?highlight=http_gzip_support\n # See (for older configs) https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleNormalizeAcceptEncoding\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|mp4|flv|zip|rar)$\") {\n \/* Already compressed formats, no sense trying to compress again *\/\n unset req.http.Accept-Encoding;\n }\n }\n\n \/* 11th: Another header manipulation *\/\n # Empty in simple configs.\n # We could add here a custom header grouping User-agent families.\n\n \/* 12th: Cookie removal *\/\n # Always cache the following static file types for all users. \n # Use with care if we control certain downloads depending on cookies. \n # Be carefull also if appending .htm[l] via Drupal's clean URLs.\n if ( req.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|woff2|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n && req.url !~ \"\/system\/storage\/serve\"\n ) {\n unset req.http.Cookie;\n }\n # Remove all cookies that backend doesn't need to know about.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRemovingSomeCookies\n if (req.http.Cookie) {\n \/* Warning: Not a pretty solution *\/\n \/* Prefix header containing cookies with ';' *\/\n set req.http.Cookie = \";\" + req.http.Cookie;\n \/* Remove any spaces after ';' in header containing cookies *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n \/* Prefix cookies we want to preserve with one space *\/\n \/* 'S{1,2}ESS[a-z0-9]+' is the regular expression matching a Drupal session cookie ({1,2} added for HTTPS support) *\/\n \/* 'NO_CACHE' is usually set after a POST request to make sure issuing user see the results of his post *\/\n \/* 'OATMEAL' & 'CHOCOLATECHIP' are special cookies used by Drupal's Bakery module to provide Single Sign On *\/\n \/* Keep in mind we should add here any cookie that should reach the backend such as splahs avoiding cookies *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \";(S{1,2}ESS[a-z0-9]+|NO_CACHE|OATMEAL|CHOCOLATECHIP)=\", \"; \\1=\");\n \/* Remove from the header any single Cookie not prefixed with a space until next ';' separator *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n \/* Remove any '; ' at the start or the end of the header *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n\n if (req.http.Cookie == \"\") {\n \/* If there are no remaining cookies, remove the cookie header. *\/\n unset req.http.Cookie;\n }\n }\n\n \/* 13th: Session cookie & special cookies bypass caching stage *\/\n # As we might want to cache some requests, hashed with its cookies, \n # we don't simply pass when some cookies remain present at this point.\n # Instead we look for request that must be passed due to the cookie header.\n if ( req.http.Cookie ~ \"SESS\"\n || req.http.Cookie ~ \"SSESS\"\n || req.http.Cookie ~ \"NO_CACHE\"\n || req.http.Cookie ~ \"OATMEAL\"\n || req.http.Cookie ~ \"CHOCOLATECHIP\"\n ) {\n return (pass);\n }\n\n \/* 14th: Bypass breakpoint 2 *\/\n # Useful for debugging we can now pipe or pass the request to backend to bypass cache.\n # return (pipe);\n # return (pass);\n\n \/* 15th: Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning inconditionally.\n return (hash);\n}\n\n# vcl_pipe: Called upon entering pipe mode.\n# In this mode, the request is passed on to the backend, \n# and any further data from either client or backend is passed on unaltered until either end closes the connection.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pipe\n# sub vcl_pipe {\n# # By default Connection: close is set on all piped requests, to stop\n# # connection reuse from sending future requests directly to the\n# # (potentially) wrong backend. If you do want this to happen, you can undo\n# # it here.\n# # unset bereq.http.connection;\n# return (pipe);\n# }\n\n# vcl_pass: Called upon entering pass mode. \n# In this mode, the request is passed on to the backend, and the backend's response is passed on to the client, \n# but is not entered into the cache.\n# Subsequent requests submitted over the same client connection are handled normally.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pass\n# sub vcl_pass {\n# return (fetch);\n# }\n\n# vcl_hash: You may call hash_data() on the data you would like to add to the hash.\n# Hash is used by Varnish to uniquely identify objects.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hash\nsub vcl_hash {\n \/* Hash cookie data *\/\n # As requests with same URL and host can produce diferent results when issued with different cookies,\n # we need to store items hashed with the associated cookies. Note that cookies are already sanitized when we reach this point.\n if (req.http.Cookie) {\n \/* Include cookie in cache hash *\/\n hash_data(req.http.Cookie);\n }\n\n \/* Custom header hashing *\/\n # Empty in simple configs.\n # Example for caching differents object versions by device previously detected (when static content could also vary):\n # if (req.http.X-UA-Device) {\n # hash_data(req.http.X-UA-Device);\n # }\n # Example for caching diferent object versions by X-Forwarded-Proto, trying to be smart about what kind of request\n # could generate diffetent responses.\n if ( req.http.X-Forwarded-Proto\n && req.url !~ \"(?i)\\.(png|gif|jpeg|jpg|ico|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|woff2|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\") {\n hash_data(req.http.X-Forwarded-Proto);\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (lookup);\n# }\n\n# vcl_purge: Called after the purge has been executed and all its variants have been evited.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-purge\n# sub vcl_purge {\n# return (synth(200, \"Purged\"));\n# }\n\n# vcl_hit: Called after a cache lookup if the requested document was found in the cache.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hit\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n \/\/ A pure unadultered hit, deliver it\n return (deliver);\n }\n \/* Allow varnish to serve up stale content if it is responding slowly *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n if (obj.ttl + 60s > 0s) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n return (deliver);\n }\n \/* Allow varish to serve up stale content if all backends are down *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n if ( ! std.healthy(req.backend_hint)\n && obj.ttl + obj.grace > 0s\n ) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n return (deliver);\n }\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning inconditionally.\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\n# vcl_miss: Called after a cache lookup if the requested document was not found in the cache.\n# Its purpose is to decide whether or not to attempt to retrieve the document from the backend, and which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-miss\n# sub vcl_miss {\n# return (fetch);\n# }\n\n# vcl_deliver: Called before an object is delivered to the client\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-deliver\nsub vcl_deliver {\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # Add whether the object is a cache hit or miss and the number of hits for the object.\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Addingaheaderindicatinghitmiss\n # In Varnish 4 the obj.hits counter behaviour has changed (see bug 1492), so\n # we use a different method: if X-Varnish contains only 1 id, we have a miss,\n # if it contains more (and therefore a space), we have a hit.\n if (resp.http.x-varnish ~ \" \") {\n set resp.http.X-Cache = \"HIT\";\n # Since in Varnish 4 the behaviour of obj.hits changed, this might not be accurate\n # See https:\/\/www.varnish-cache.org\/trac\/ticket\/1492\n set resp.http.X-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Cache = \"MISS\";\n \/* Show the results of cookie sanitization *\/\n set resp.http.X-Cookie = req.http.Cookie;\n }\n\n #TODO# Add sick marker\n\n # Restart count\n if ( req.restarts > 0) {\n set resp.http.X-Restarts = req.restarts;\n }\n\n # Add the Varnish server hostname\n set resp.http.X-Varnish-Server = server.hostname;\n # If we have setted a custom header with device family detected we can show it:\n # if (req.http.X-UA-Device) {\n # set resp.http.X-UA-Device = req.http.X-UA-Device;\n # }\n # If we have recived a custom header with the protocol in the request we can show it:\n # if (req.http.X-Forwarded-Proto) {\n # set resp.http.X-Forwarded-Proto = req.http.X-Forwarded-Proto;\n # }\n\n \/* Vary header manipulation *\/\n # Empty in simple configs.\n # By example, if we are storing & serving diferent objects depending on User-Agent header we must set the correct Vary header:\n # if (resp.http.Vary) {\n # set resp.http.Vary = resp.http.Vary + \",User-Agent\";\n # } else {\n # set resp.http.Vary = \"User-Agent\";\n # }\n\n \/* Fake headers *\/\n # Empty in simple configs\n # We can fake server headers here, by example:\n # set resp.http.Server = \"Deep thought\";\n # set resp.http.X-Powered-By = \"BOFH\";\n # Or have some fun with headers:\n # See http:\/\/www.nextthing.org\/archives\/2005\/08\/07\/fun-with-http-headers\n # See http:\/\/royal.pingdom.com\/2012\/08\/15\/fun-and-unusual-http-response-headers\/\n # set resp.http.X-Thank-You = \"for bothering to look at my HTTP headers\";\n # set resp.http.X-Answer = \"42\";\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_deliver {\n# return (deliver);\n# }\n\n# vcl_synth: Called to deliver a synthetic object. A synthetic object is generated in VCL,\n# not fetched from the backend. It is typically contructed using the synthetic() function.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-synth\n\/*\n * We can come here \"invisibly\" with the following errors: 413, 417 & 503\n *\/\nsub vcl_synth {\n \/* Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_synth;\n\n \/* Try to restart request in case of failure *\/\n # Note that max_restarts defaults to 4\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if (resp.status == 503 && req.restarts < 4) {\n return(restart);\n }\n\n \/* Set common headers for synthetic responses *\/\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n\n \/* HTTP Authentification client request *\/\n # Empty in simple configs. SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* Error page & refresh \/ redirections *\/\n # We have plenty of choices when we have to serve an error to the client, \n # from the default error page to javascript black magic or plain redirections.\n # Adding some external statistic javascript to track failures served to clients is strongly suggested.\n # We can't use external resources on synthetic content, everything must be inlined.\n # If we need to include images we can embed them in base64 encoding.\n # Here is the default error page for Varnish 4 (not so pretty)\n # We're using error 200 for monitoring puposes which should not be retried client side *\/\n if ( resp.status != 200) {\n set resp.http.Retry-After = \"5\";\n }\n\n ## Example custom 403 error page.\n #if (resp.status == 403) {\n # synthetic(std.fileread(\"\/403.html\"));\n # return(deliver);\n #}\n \n # Consider add some analytics stuff to trace accesses\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning inconditionally.\n return (deliver);\n}\n\n#######################################################################\n# Backend Fetch\n\n# vcl_backend_fetch: Called before sending the backend request. In this subroutine you typically alter the request before it gets to the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-fetch\n# sub vcl_backend_fetch {\n# return (fetch);\n# }\n\n# vcl_backend_response: Called after the response headers has been successfully retrieved from the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-response\nsub vcl_backend_response {\n \/* Caching exceptions *\/\n # Varnish will cache objects with response codes: 200, 203, 300, 301, 302, 307, 404 & 410.\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/VCL_Basics.html#the-initial-value-of-beresp-ttl\n # Drupal's Imagecache module can return a 307 redirection to the requested url itself and, depending on Drupal's cache settings,\n # this could lead to a redirection loop being cached for a long time but also we want Varnish to shield a little the backend.\n # See http:\/\/drupal.org\/node\/1248010\n # See http:\/\/drupal.org\/node\/310656\n if (beresp.status == 307 &&\n #TODO# verify that this work better than 'bereq.url ~ \"imagecache\"' *\/\n beresp.http.Location == bereq.url &&\n beresp.ttl > 5s) {\n set beresp.ttl = 5s;\n set beresp.http.cache-control = \"max-age=5\";\n }\n\n \/* Request retrial *\/\n if ( beresp.status == 500\n || beresp.status == 503\n ) {\n #TODO# consider not restarting POST requests as seenV3 on https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleSaintMode\n return (retry);\n }\n\n \/* Enable grace mode. Related with vcl_hit *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n set beresp.grace = 1h;\n\n \/* Strip cookies from the following static file types for all users. Related with our 12th stage on vcl_recv *\/\n if (bereq.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|gz|tgz|bz2|tbz|mp3|ogg|zip|rar|otf|ttf|eot|woff|woff2|svg|pdf)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\") {\n unset beresp.http.set-cookie;\n }\n\n \/* Gzip response *\/\n # Empty in simple configs\n # Use Varnish to Gzip respone, if suitable, before storing it on cache\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html\n if ( ! beresp.http.Content-Encoding\n && ( beresp.http.content-type ~ \"text\"\n || beresp.http.content-type ~ \"application\/x-javascript\"\n || beresp.http.content-type ~ \"application\/javascript\"\n || beresp.http.content-type ~ \"application\/rss+xml\"\n || beresp.http.content-type ~ \"application\/xml\"\n || beresp.http.content-type ~ \"Application\/JSON\")\n ) {\n set beresp.do_gzip = true;\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # We can add the name of the backend that has processed the request:\n # set beresp.http.X-Backend = beresp.backend.name;\n # We can use a header to tell if the object was gziped by Varnish\n # if (beresp.do_gzip) {\n # set beresp.http.X-Varnish-Gzipped = \"yes\";\n # } else {\n # set beresp.http.X-Varnish-Gizipped = \"no\";\n # }\n # We can also add headers informing whether the object is cacheable or not and why.\n # https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Varnish3.0\n if (beresp.ttl <= 0s) {\n \/* Varnish determined the object was not cacheable *\/\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n } elsif (bereq.http.Cookie ~ \"(SESS|SSESS|NO_CACHE|OATMEAL|CHOCOLATECHIP)\") {\n \/* We don't wish to cache content for logged in users or with certain cookies. Related with our 9th stage on vcl_recv *\/\n set beresp.http.X-Cacheable = \"NO:Cookies\";\n # return(hit_for_pass);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n \/* We are respecting the Cache-Control=private header from the backend *\/\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n # return(hit_for_pass);\n } else {\n \/* Varnish determined the object was cacheable *\/\n set beresp.http.X-Cacheable = \"YES\";\n }\n\n \/* Further header manipulation *\/\n # Empty in simple configs.\n # We can also unset some headers to prevent information disclosure and save some cache space\n # unset beresp.http.Server;\n # unset beresp.http.X-Powered-By;\n # Retry count\n if ( bereq.retries > 0) {\n set beresp.http.X-Retries = bereq.retries;\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_backend_response {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Surrogate-control ~ \"no-store\" ||\n# (!beresp.http.Surrogate-Control &&\n# beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n# beresp.http.Vary == \"*\") {\n# \/*\n# * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# *\/\n# set beresp.ttl = 120s;\n# set beresp.uncacheable = true;\n# }\n# return (deliver);\n# }\n\n# vcl_backend_error: This subroutine is called if we fail the backend fetch.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-error\nsub vcl_backend_error {\n\n \/* Try to restart request in case of failure *\/\n #TODO# Confirm max_retries default value\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if (bereq.retries < 4) {\n return (retry);\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap this with an ACL\n # Retry count\n if ( bereq.retries > 0) {\n set beresp.http.X-Retries = bereq.retries;\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + beresp.status + \" \" + beresp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + beresp.status + \" \" + beresp.reason + {\"<\/h1>\n <p>\"} + beresp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + bereq.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this point.\n return (deliver);\n}\n\n#######################################################################\n# Housekeeping\n\n# vcl_init: Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-init\n# Here is where you should declare your directors now.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-backends.html#directors\n# Empty in simple configs\n# sub vcl_init {\n# return (ok);\n# }\n\n# vcl_fini: Called when VCL is discarded only after all requests have exited the VCL. Typically used to clean up VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-fini\n# sub vcl_fini {\n# return (ok);\n# }\n\n","returncode":0,"stderr":"","license":"unknown","lang":"VCL"} {"commit":"f561b308996a10541e150db60baf233e7882f98d","subject":"Remove unused piece of VCL","message":"Remove unused piece of VCL\n","repos":"dantleech\/FOSHttpCache,dantleech\/FOSHttpCache,dantleech\/FOSHttpCache,stof\/FOSHttpCache,stof\/FOSHttpCache,stof\/FOSHttpCache","old_file":"Tests\/Functional\/Fixtures\/varnish\/fos.vcl","new_file":"Tests\/Functional\/Fixtures\/varnish\/fos.vcl","new_contents":"backend default {\n .host = \"localhost\";\n .port = \"8000\";\n}\n\nacl invalidators {\n \"localhost\";\n}\n\nsub vcl_recv {\n if (req.request == \"PURGE\") {\n if (!client.ip ~ invalidators) {\n error 405 \"Not allowed\";\n }\n return (lookup);\n }\n\n if (req.request == \"BAN\") {\n if (!client.ip ~ invalidators) {\n error 405 \"Not allowed.\";\n }\n\n if (req.http.x-cache-tags) {\n ban(\"obj.http.host ~ \" + req.http.x-host\n + \" && obj.http.x-url ~ \" + req.http.x-url\n + \" && obj.http.content-type ~ \" + req.http.x-content-type\n + \" && obj.http.x-cache-tags ~ \" + req.http.x-cache-tags\n );\n } else {\n ban(\"obj.http.host ~ \" + req.http.x-host\n + \" && obj.http.x-url ~ \" + req.http.x-url\n + \" && obj.http.content-type ~ \" + req.http.x-content-type\n );\n }\n\n error 200 \"Banned\";\n }\n}\n\nsub vcl_fetch {\n\n # Set ban-lurker friendly custom headers\n set beresp.http.x-url = req.url;\n set beresp.http.x-host = req.http.host;\n}\n\nsub vcl_hit {\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged\";\n }\n}\n\nsub vcl_miss {\n if (req.request == \"PURGE\") {\n purge;\n error 404 \"Not in cache\";\n }\n}\n\nsub vcl_deliver {\n # Add extra headers if debugging is enabled\n if (resp.http.x-cache-debug) {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n } else {\n # Remove ban-lurker friendly custom headers when delivering to client\n unset resp.http.x-url;\n unset resp.http.x-host;\n }\n}","old_contents":"backend default {\n .host = \"localhost\";\n .port = \"8000\";\n}\n\nacl invalidators {\n \"localhost\";\n}\n\nsub vcl_recv {\n if (req.request == \"PURGE\") {\n if (!client.ip ~ invalidators) {\n error 405 \"Not allowed\";\n }\n return (lookup);\n }\n\n if (req.request == \"BAN\") {\n if (!client.ip ~ invalidators) {\n error 405 \"Not allowed.\";\n }\n\n if (req.http.x-cache-tags) {\n ban(\"obj.http.host ~ \" + req.http.x-host\n + \" && obj.http.x-url ~ \" + req.http.x-url\n + \" && obj.http.content-type ~ \" + req.http.x-content-type\n + \" && obj.http.x-cache-tags ~ \" + req.http.x-cache-tags\n );\n } else {\n ban(\"obj.http.host ~ \" + req.http.x-host\n + \" && obj.http.x-url ~ \" + req.http.x-url\n + \" && obj.http.content-type ~ \" + req.http.x-content-type\n );\n }\n\n error 200 \"Banned\";\n }\n}\n\nsub vcl_fetch {\n\n # Set ban-lurker friendly custom headers\n set beresp.http.x-url = req.url;\n set beresp.http.x-host = req.http.host;\n\n # Ban cache tags\n if (beresp.status >= 200 && beresp.status < 400\n && (req.request == \"PUT\" || req.request == \"POST\" || req.request == \"PATCH\" || req.request == \"DELETE\")\n ) {\n ban(\"obj.http.x-cache-tags ~ \" + beresp.http.x-cache-tags);\n }\n}\n\nsub vcl_hit {\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged\";\n }\n}\n\nsub vcl_miss {\n if (req.request == \"PURGE\") {\n purge;\n error 404 \"Not in cache\";\n }\n}\n\nsub vcl_deliver {\n # Add extra headers if debugging is enabled\n if (resp.http.x-cache-debug) {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n } else {\n # Remove ban-lurker friendly custom headers when delivering to client\n unset resp.http.x-url;\n unset resp.http.x-host;\n }\n}","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"7c8a68322434f5d95f1250b8c68bba53986ba32e","subject":"Probably best to still pass wp-login requests, and only pipe wp-admin reqs","message":"Probably best to still pass wp-login requests, and only pipe wp-admin reqs\n","repos":"jalevin\/wordpress,evolution\/wordpress,jalevin\/wordpress,evolution\/wordpress,genesis\/wordpress,evolution\/wordpress,evolution\/genesis-wordpress,genesis\/wordpress,jalevin\/wordpress,evolution\/genesis-wordpress,genesis\/wordpress,jalevin\/wordpress,evolution\/genesis-wordpress,jalevin\/wordpress,evolution\/wordpress,evolution\/genesis-wordpress,genesis\/wordpress,evolution\/genesis-wordpress,evolution\/genesis-wordpress,evolution\/wordpress,genesis\/wordpress,genesis\/wordpress","old_file":"provisioning\/roles\/varnish\/files\/etc-varnish\/conf.d\/receive\/wordpress.vcl","new_file":"provisioning\/roles\/varnish\/files\/etc-varnish\/conf.d\/receive\/wordpress.vcl","new_contents":"# Pass all login requests straight through\nif (req.url ~ \"wp-login\") {\n return (pass);\n}\n# Pipe all admin requests directly\nif (req.url ~ \"wp-admin\") {\n return (pipe);\n}\n\n# Pass all requests containing a wp- or wordpress_ cookie\n# (meaning NO caching for logged in users)\nif (req.http.Cookie ~ \"^([^;]+;\\s*)*?(wp-|wordpress_)\") {\n return (pass);\n}\n\n# Drop *all* cookies sent to Wordpress, if we've gotten this far\nunset req.http.Cookie;\n\n# Try a cache-lookup\nreturn (lookup);\n","old_contents":"# Pass all login\/admin requests straight through\nif (req.url ~ \"wp-(login|admin)\") {\n return (pipe);\n}\n\n# Pass all requests containing a wp- or wordpress_ cookie\n# (meaning NO caching for logged in users)\nif (req.http.Cookie ~ \"^([^;]+;\\s*)*?(wp-|wordpress_)\") {\n return (pass);\n}\n\n# Drop *all* cookies sent to Wordpress, if we've gotten this far\nunset req.http.Cookie;\n\n# Try a cache-lookup\nreturn (lookup);\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"89cb1372245ac6a0e5c437fbf563a01f16548fe6","subject":"Pipe all requests for wp-login or wp-admin","message":"Pipe all requests for wp-login or wp-admin\n\nThis appears necessary for the web ui installs\/updates to work. Should fix #30, and may fix #34 as well!\n","repos":"genesis\/wordpress,genesis\/wordpress,evolution\/genesis-wordpress,jalevin\/wordpress,evolution\/wordpress,evolution\/wordpress,evolution\/genesis-wordpress,evolution\/wordpress,evolution\/wordpress,jalevin\/wordpress,jalevin\/wordpress,evolution\/genesis-wordpress,genesis\/wordpress,evolution\/genesis-wordpress,genesis\/wordpress,genesis\/wordpress,jalevin\/wordpress,evolution\/genesis-wordpress,genesis\/wordpress,evolution\/genesis-wordpress,evolution\/wordpress,jalevin\/wordpress","old_file":"provisioning\/roles\/varnish\/files\/etc-varnish\/conf.d\/receive\/wordpress.vcl","new_file":"provisioning\/roles\/varnish\/files\/etc-varnish\/conf.d\/receive\/wordpress.vcl","new_contents":"# Pass all login\/admin requests straight through\nif (req.url ~ \"wp-(login|admin)\") {\n return (pipe);\n}\n\n# Pass all requests containing a wp- or wordpress_ cookie\n# (meaning NO caching for logged in users)\nif (req.http.Cookie ~ \"^([^;]+;\\s*)*?(wp-|wordpress_)\") {\n return (pass);\n}\n\n# Drop *all* cookies sent to Wordpress, if we've gotten this far\nunset req.http.Cookie;\n\n# Try a cache-lookup\nreturn (lookup);\n","old_contents":"# Pass all login\/admin requests straight through\nif (req.url ~ \"wp-(login|admin)\") {\n return (pass);\n}\n\n# Pass all requests containing a wp- or wordpress_ cookie\n# (meaning NO caching for logged in users)\nif (req.http.Cookie ~ \"^([^;]+;\\s*)*?(wp-|wordpress_)\") {\n return (pass);\n}\n\n# Drop *all* cookies sent to Wordpress, if we've gotten this far\nunset req.http.Cookie;\n\n# Try a cache-lookup\nreturn (lookup);\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"723da932036b8e0046b408ffc6c8c0c0fd531e9c","subject":"Fix duplicate wording in example.vcl","message":"Fix duplicate wording in example.vcl\n","repos":"zhoualbeart\/Varnish-Cache,varnish\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,feld\/Varnish-Cache,gquintard\/Varnish-Cache,mrhmouse\/Varnish-Cache,varnish\/Varnish-Cache,gquintard\/Varnish-Cache,feld\/Varnish-Cache,mrhmouse\/Varnish-Cache,alarky\/varnish-cache-doc-ja,zhoualbeart\/Varnish-Cache,feld\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,alarky\/varnish-cache-doc-ja,gquintard\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,alarky\/varnish-cache-doc-ja,mrhmouse\/Varnish-Cache,alarky\/varnish-cache-doc-ja,chrismoulton\/Varnish-Cache,varnish\/Varnish-Cache,franciscovg\/Varnish-Cache,franciscovg\/Varnish-Cache,chrismoulton\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,chrismoulton\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,alarky\/varnish-cache-doc-ja,feld\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,mrhmouse\/Varnish-Cache,franciscovg\/Varnish-Cache,mrhmouse\/Varnish-Cache,zhoualbeart\/Varnish-Cache,chrismoulton\/Varnish-Cache,feld\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,chrismoulton\/Varnish-Cache,varnish\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,franciscovg\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,zhoualbeart\/Varnish-Cache,zhoualbeart\/Varnish-Cache,varnish\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,gquintard\/Varnish-Cache,franciscovg\/Varnish-Cache","old_file":"etc\/example.vcl","new_file":"etc\/example.vcl","new_contents":"#\n# This is an example VCL file for Varnish.\n#\n# It does not do anything by default, delegating control to the\n# builtin VCL. The builtin VCL is called when there is no explicit\n# return statement.\n#\n# See the VCL chapters in the Users Guide at https:\/\/www.varnish-cache.org\/docs\/\n# and http:\/\/varnish-cache.org\/trac\/wiki\/VCLExamples for more examples.\n\n# Marker to tell the VCL compiler that this VCL has been adapted to the\n# new 4.0 format.\nvcl 4.0;\n\n# Default backend definition. Set this to point to your content server.\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\n\nsub vcl_recv {\n # Happens before we check if we have this in cache already.\n # \n # Typically you clean up the request here, removing cookies you don't need,\n # rewriting the request, etc.\n}\n\nsub vcl_backend_response {\n # Happens after we have read the response headers from the backend.\n # \n # Here you clean the response headers, removing silly Set-Cookie headers\n # and other mistakes your backend does.\n}\n\nsub vcl_deliver {\n # Happens when we have all the pieces we need, and are about to send the\n # response to the client.\n # \n # You can do accounting or modifying the final object here.\n}\n","old_contents":"#\n# This is an example VCL file for Varnish.\n#\n# It does not do anything by default, delegating control to the builtin vcl.\n# The builtin VCL is called when there is no explicit explicit return\n# statement.\n#\n# See the VCL chapters in the Users Guide at https:\/\/www.varnish-cache.org\/docs\/\n# and http:\/\/varnish-cache.org\/trac\/wiki\/VCLExamples for more examples.\n\n# Marker to tell the VCL compiler that this VCL has been adapted to the\n# new 4.0 format.\nvcl 4.0;\n\n# Default backend definition. Set this to point to your content server.\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\n\nsub vcl_recv {\n # Happens before we check if we have this in cache already.\n # \n # Typically you clean up the request here, removing cookies you don't need,\n # rewriting the request, etc.\n}\n\nsub vcl_backend_response {\n # Happens after we have read the response headers from the backend.\n # \n # Here you clean the response headers, removing silly Set-Cookie headers\n # and other mistakes your backend does.\n}\n\nsub vcl_deliver {\n # Happens when we have all the pieces we need, and are about to send the\n # response to the client.\n # \n # You can do accounting or modifying the final object here.\n}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"56ea2fc5b126f2c8393fd26624499769863693f7","subject":"flip the check over","message":"flip the check over\n","repos":"mcshaz\/polyfill-service,mcshaz\/polyfill-service,kdzwinel\/polyfill-service,JakeChampion\/polyfill-service,kdzwinel\/polyfill-service,kdzwinel\/polyfill-service,mcshaz\/polyfill-service,JakeChampion\/polyfill-service,jonathan-fielding\/polyfill-service,jonathan-fielding\/polyfill-service,jonathan-fielding\/polyfill-service","old_file":"fastly-config.vcl","new_file":"fastly-config.vcl","new_contents":"import boltsort;\n\nsub vcl_recv {\n#FASTLY recv\n\tif ( req.request == \"FASTLYPURGE\" ) {\n\t\tset req.http.Fastly-Purge-Requires-Auth = \"1\";\n\t}\n\n\tif (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n\t\treturn(pass);\n\t}\n\n\tif (!req.http.Fastly-SSL) {\n\t\tif (req.http.Host == \"cdn.polyfill.io\" || req.http.Host == \"polyfill.io\") {\n\t\t\terror 751 \"Redirect to prod HTTPS\";\n\t\t}\n\t\tif (req.http.Host == \"qa.polyfill.io\") {\n\t\t\terror 752 \"Redirect to QA HTTPS\";\n\t\t}\n\t}\n\n\tif (req.http.Host ~ \"polyfills.io\") {\n\t\terror 751 \"Canonicalise\";\n\t}\n\n\tif (req.url ~ \"^\/v2\/(polyfill\\.|recordRumData)\" && req.url !~ \"[\\?\\&]ua=\") {\n\t\tset req.http.X-Orig-URL = req.url;\n\t\tset req.url = \"\/v2\/normalizeUa?ua=\" urlencode(req.http.User-Agent);\n\t}\n\n\tif (req.url ~ \"^\/v2\/recordRumData\" && req.http.Normalized-User-Agent) {\n\t\tset req.http.Log = regsub(req.url, \"^.*?\\?(.*)$\", \"\\1\") \"&ip=\" client.ip \"&refer_domain=\" regsub(req.http.Referer, \"^(https?\\:\\\/\\\/)?(www\\.)?(.+?)(\\:\\d+)?([\\\/\\?].*)?$\", \"\\3\") \"&country=\" geoip.country_code \"&data_center=\" if(req.http.Cookie:FastlyDC, req.http.Cookie:FastlyDC, server.datacenter);\n\t\terror 204 \"No Content\";\n\t}\n\n\tset req.url = boltsort.sort(req.url);\n\n\treturn(lookup);\n}\n\nsub vcl_deliver {\n#FASTLY deliver\n\n\t# If the response is to a normalise request and there's a parked \"original request\", use the normalised UA response to modify the original request and restart it\n\tif (req.url ~ \"^\/v\\d\/normalizeUa\" && resp.status == 200 && req.http.X-Orig-URL ~ \"^\/v2\/(polyfill\\.|recordRumData)\") {\n\t\tset req.http.Fastly-force-Shield = \"1\";\n\t\tset req.http.Normalized-User-Agent = resp.http.Normalized-User-Agent;\n\t\tif (req.http.X-Orig-URL ~ \"\\?\") {\n\t\t\tset req.url = req.http.X-Orig-URL \"&ua=\" resp.http.Normalized-User-Agent;\n\t\t} else {\n\t\t\tset req.url = req.http.X-Orig-URL \"?ua=\" resp.http.Normalized-User-Agent;\n\t\t}\n\t\trestart;\n\n\t# If the original request didn't specify a UA override, and we added one when the request was sent to the backend, the backend won't have included a Vary:user-agent header (correctly) but we need to add one\n\t} else if (req.url ~ \"^\/v\\d\/polyfill\\..*[\\?\\&]ua=\" && req.http.X-Orig-URL && req.http.X-Orig-URL !~ \"[\\?\\&]ua=\") {\n\t\tadd resp.http.Vary = \"User-Agent\";\n\t}\n\n\tif (req.url ~ \"[\\&\\?]rum=1\") {\n\t\tadd resp.http.Set-Cookie = \"FastlyDC=\" server.datacenter \"; Path=\/; HttpOnly; max-age=60\";\n\t}\n\n\treturn(deliver);\n}\n\nsub vcl_error {\n\n\t# Redirect to canonical prod\/qa origins\n\tif (obj.status == 751 || obj.status == 752) {\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\tset obj.http.Location = \"https:\/\/\" if(obj.status == 751, \"\", \"qa.\") \"polyfill.io\" req.url;\n\t\tsynthetic {\"\"};\n\t\treturn (deliver);\n\t}\n}\n","old_contents":"import boltsort;\n\nsub vcl_recv {\n#FASTLY recv\n\tif ( req.request == \"FASTLYPURGE\" ) {\n\t\tset req.http.Fastly-Purge-Requires-Auth = \"1\";\n\t}\n\n\tif (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n\t\treturn(pass);\n\t}\n\n\tif (!req.http.Fastly-SSL) {\n\t\tif (req.http.Host == \"cdn.polyfill.io\" || req.http.Host == \"polyfill.io\") {\n\t\t\terror 751 \"Redirect to prod HTTPS\";\n\t\t}\n\t\tif (req.http.Host == \"qa.polyfill.io\") {\n\t\t\terror 752 \"Redirect to QA HTTPS\";\n\t\t}\n\t}\n\n\tif (req.http.Host ~ \"polyfills.io\") {\n\t\terror 751 \"Canonicalise\";\n\t}\n\n\tif (req.url ~ \"^\/v2\/(polyfill\\.|recordRumData)\" && req.url !~ \"[\\?\\&]ua=\") {\n\t\tset req.http.X-Orig-URL = req.url;\n\t\tset req.url = \"\/v2\/normalizeUa?ua=\" urlencode(req.http.User-Agent);\n\t}\n\n\tif (req.url ~ \"^\/v2\/recordRumData\" && req.http.Normalized-User-Agent) {\n\t\tset req.http.Log = regsub(req.url, \"^.*?\\?(.*)$\", \"\\1\") \"&ip=\" client.ip \"&refer_domain=\" regsub(req.http.Referer, \"^(https?\\:\\\/\\\/)?(www\\.)?(.+?)(\\:\\d+)?([\\\/\\?].*)?$\", \"\\3\") \"&country=\" geoip.country_code \"&data_center=\" if(req.http.Cookie:FastlyDC, req.http.Cookie:FastlyDC, server.datacenter);\n\t\terror 204 \"No Content\";\n\t}\n\n\tset req.url = boltsort.sort(req.url);\n\n\treturn(lookup);\n}\n\nsub vcl_deliver {\n#FASTLY deliver\n\n\t# If the response is to a normalise request and there's a parked \"original request\", use the normalised UA response to modify the original request and restart it\n\tif (req.url ~ \"^\/v\\d\/normalizeUa\" && resp.status == 200 && req.http.X-Orig-URL ~ \"^\/v2\/(polyfill\\.|recordRumData)\") {\n\t\tset req.http.Fastly-force-Shield = \"1\";\n\t\tset req.http.Normalized-User-Agent = resp.http.Normalized-User-Agent;\n\t\tif (req.http.X-Orig-URL ~ \"\\?\") {\n\t\t\tset req.url = req.http.X-Orig-URL \"&ua=\" resp.http.Normalized-User-Agent;\n\t\t} else {\n\t\t\tset req.url = req.http.X-Orig-URL \"?ua=\" resp.http.Normalized-User-Agent;\n\t\t}\n\t\trestart;\n\n\t# If the original request didn't specify a UA override, and we added one when the request was sent to the backend, the backend won't have included a Vary:user-agent header (correctly) but we need to add one\n\t} else if (req.url ~ \"^\/v\\d\/polyfill\\..*[\\?\\&]ua=\" && req.http.X-Orig-URL && req.http.X-Orig-URL !~ \"[\\?\\&]ua=\") {\n\t\tadd resp.http.Vary = \"User-Agent\";\n\t}\n\n\tif (req.url ~ \"[\\&\\?]rum=1\") {\n\t\tadd resp.http.Set-Cookie = \"FastlyDC=\" server.datacenter \"; Path=\/; HttpOnly; max-age=60\";\n\t}\n\n\treturn(deliver);\n}\n\nsub vcl_error {\n\n\t# Redirect to canonical prod\/qa origins\n\tif (obj.status == 751 || obj.status == 752) {\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\tset obj.http.Location = \"https:\/\/\" if(obj.status == 752, \"qa.\", \"\") \"polyfill.io\" req.url;\n\t\tsynthetic {\"\"};\n\t\treturn (deliver);\n\t}\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"7f6737d60b2e28650fb2481a1563b7558af5df34","subject":"Add webp and svg to list of static assets","message":"Add webp and svg to list of static assets\n","repos":"fastly\/fastly-magento,fastly\/fastly-magento,fastly\/fastly-magento,fastly\/fastly-magento","old_file":"app\/code\/community\/Fastly\/CDN\/etc\/vcl_snippets\/recv.vcl","new_file":"app\/code\/community\/Fastly\/CDN\/etc\/vcl_snippets\/recv.vcl","new_contents":" # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n # Sort the query arguments\n set req.url = boltsort.sort(req.url);\n\n # bypass language switcher\n if (req.url ~ \"(?i)___from_store=.*&___store=.*\") {\n set req.http.X-Pass = \"1\";\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (req.http.cookie:FASTLY_CDN_ENV) {\n set req.http.Fastly-Cdn-Env = req.http.cookie:FASTLY_CDN_ENV;\n } else {\n unset req.http.Fastly-Cdn-Env;\n }\n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n\n if (!req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n error 403;\n }\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n\n } else {\n error 403;\n }\n\n }\n\n # disable ESI processing on Origin Shield\n if (req.http.Fastly-FF) {\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(media|js|skin)\/.*\\.(png|jpg|jpeg|gif|css|js|swf|ico|webp|svg)$\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n # formkey lookup\n if (req.url ~ \"\/fastlycdn\/getformkey\/\") {\n # check if we have a formkey cookie\n if (req.http.Cookie:FASTLY_CDN_FORMKEY) {\n set req.http.Formkey = req.http.Cookie:FASTLY_CDN_FORMKEY;\n } else {\n # create formkey\n set req.http.seed = req.http.Cookie client.ip remote.port client.geo.longitude client.geo.latitude client.geo.postal_code;\n set req.http.Formkey = regsub(digest.hash_md5(req.http.seed), \"^0x\", \"\");\n }\n error 760 req.http.Formkey;\n }\n\n # client.geo lookup\n if (req.url ~ \"fastlycdn\/esi\/getcountry\/\") {\n # check if GeoIP has been already processed by client\n if (req.http.Cookie:FASTLY_CDN_GEOIP_PROCESSED) {\n error 200 \"\";\n } else {\n # modify req.url and restart request processing\n error 750 client.geo.country_code;\n }\n }\n\n # client.geo get country code\n if (req.url ~ \"fastlycdn\/esi\/getcountrycode\/\") {\n # create and set req.http.X-Country-Code\n error 755 client.geo.country_code;\n }\n\n # check for ESI calls\n if (req.url ~ \"esi_data=\") {\n # check for valid cookie data\n if (req.http.Cookie ~ \"FASTLY_CDN-([A-Za-z0-9-_]+)=([^;]*)\") {\n set req.url = querystring.filter(req.url, \"esi_data\") + \"&esi_data=\" + re.group.2;\n }\n }\n\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking\n set req.http.Magento-Original-URL = req.url;\n set req.url = querystring.regfilter(req.url, \"^(utm_.*|gclid|gdftrk|_ga|mc_.*)\");\n","old_contents":" # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n # Sort the query arguments\n set req.url = boltsort.sort(req.url);\n\n # bypass language switcher\n if (req.url ~ \"(?i)___from_store=.*&___store=.*\") {\n set req.http.X-Pass = \"1\";\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (req.http.cookie:FASTLY_CDN_ENV) {\n set req.http.Fastly-Cdn-Env = req.http.cookie:FASTLY_CDN_ENV;\n } else {\n unset req.http.Fastly-Cdn-Env;\n }\n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n\n if (!req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n error 403;\n }\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n\n } else {\n error 403;\n }\n\n }\n\n # disable ESI processing on Origin Shield\n if (req.http.Fastly-FF) {\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(media|js|skin)\/.*\\.(png|jpg|jpeg|gif|css|js|swf|ico)$\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n # formkey lookup\n if (req.url ~ \"\/fastlycdn\/getformkey\/\") {\n # check if we have a formkey cookie\n if (req.http.Cookie:FASTLY_CDN_FORMKEY) {\n set req.http.Formkey = req.http.Cookie:FASTLY_CDN_FORMKEY;\n } else {\n # create formkey\n set req.http.seed = req.http.Cookie client.ip remote.port client.geo.longitude client.geo.latitude client.geo.postal_code;\n set req.http.Formkey = regsub(digest.hash_md5(req.http.seed), \"^0x\", \"\");\n }\n error 760 req.http.Formkey;\n }\n\n # client.geo lookup\n if (req.url ~ \"fastlycdn\/esi\/getcountry\/\") {\n # check if GeoIP has been already processed by client\n if (req.http.Cookie:FASTLY_CDN_GEOIP_PROCESSED) {\n error 200 \"\";\n } else {\n # modify req.url and restart request processing\n error 750 client.geo.country_code;\n }\n }\n\n # client.geo get country code\n if (req.url ~ \"fastlycdn\/esi\/getcountrycode\/\") {\n # create and set req.http.X-Country-Code\n error 755 client.geo.country_code;\n }\n\n # check for ESI calls\n if (req.url ~ \"esi_data=\") {\n # check for valid cookie data\n if (req.http.Cookie ~ \"FASTLY_CDN-([A-Za-z0-9-_]+)=([^;]*)\") {\n set req.url = querystring.filter(req.url, \"esi_data\") + \"&esi_data=\" + re.group.2;\n }\n }\n\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking\n set req.http.Magento-Original-URL = req.url;\n set req.url = querystring.regfilter(req.url, \"^(utm_.*|gclid|gdftrk|_ga|mc_.*)\");\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"b0e8d43716672ff296e21706821e24c6c80fa1ad","subject":"Use secure string comparison to protect against timing attack","message":"Use secure string comparison to protect against timing attack\n","repos":"rhargreaves\/fastly-vcl-experiments,rhargreaves\/fastly-vcl-experiments","old_file":"oauth_sig_check.vcl","new_file":"oauth_sig_check.vcl","new_contents":"\ntable consumer_secrets {\n\t\"foo\": \"foo_secret\"\n}\n\ntable access_tokens {\n\t\"bar\": \"bar_secret\"\n}\n\nsub vcl_recv {\n#FASTLY recv\n#DEPLOY recv\n\tdeclare local var.consumer_key STRING;\n\tdeclare local var.consumer_secret STRING;\n\tdeclare local var.access_token STRING;\n\tdeclare local var.access_token_secret STRING;\n\tdeclare local var.provided_signature STRING;\n\tdeclare local var.parameters STRING;\n\tdeclare local var.base_string_uri STRING;\n\tdeclare local var.base_string STRING;\n\tdeclare local var.calculated_signature STRING;\n\tdeclare local var.timestamp STRING;\n\n\tset var.consumer_key = if(req.url ~ \"(?i)oauth_consumer_key=([^&]*)\", \n\t\t\turldecode(re.group.1), \"\");\n\tif(var.consumer_key == \"\") {\n\t\terror 401 \"Missing Consumer Key\";\n\t}\n\tset var.consumer_secret = table.lookup(consumer_secrets, var.consumer_key, \"\");\n\tif(var.consumer_secret == \"\") {\n\t\terror 401 \"Invalid Consumer Key\";\n\t}\n\tset var.access_token = if(req.url ~ \"(?i)oauth_token=([^&]*)\", \n\t\t\turldecode(re.group.1), \"\");\n\tif(var.access_token != \"\") {\n\t\tset var.access_token_secret = table.lookup(access_tokens, var.access_token, \"\");\n\t\tif(var.access_token_secret == \"\") {\n\t\t\terror 401 \"Invalid Access Token\";\n\t\t}\n\t} else {\n\t\tset var.access_token_secret = \"\";\n\t}\n\tset var.provided_signature = if(req.url ~ \"(?i)oauth_signature=([^&]*)\", \n\t\t\turldecode(re.group.1), \"\");\n\tif(var.provided_signature == \"\") {\n\t\terror 401 \"Missing Signature\";\n\t}\n\tset var.parameters = regsub(\n\t\t\tregsub(boltsort.sort(req.url), \".*\\?\", \"\"), \n\t\t\t\"&oauth_signature=[^&]*\", \"\");\n\tset var.base_string_uri = \n\t\tif(req.http.Fastly-SSL, \"https\", \"http\") \n\t\t\t\":\/\/\"\n\t\t\t\tstd.tolower(req.http.host)\n\t\t\t\treq.url.path;\n\tset var.base_string = \n\t\treq.request\n\t\t\"&\"\n\t\turlencode(var.base_string_uri)\n\t\t\"&\"\n\t\turlencode(var.parameters);\n\n\tset var.calculated_signature = digest.hmac_sha1_base64(\n\t\t\tvar.consumer_secret \"&\" var.access_token_secret, \n\t\t\tvar.base_string);\n\n\tif(!digest.secure_is_equal(var.provided_signature, \n\t\t\tvar.calculated_signature)) {\n\t\terror 401 \"Invalid OAuth Signature\";\n\t}\n\n\tset var.timestamp = if(req.url ~ \"(?i)oauth_timestamp=([0-9]*)\", \n\t\t\turldecode(re.group.1), \"\");\n\tif(var.timestamp == \"\") {\n\t\terror 401 \"Missing\/Invalid Timestamp\";\n\t}\n\n\tif(time.is_after(\n\t\t\t\tnow,\n\t\t\t\ttime.add(std.integer2time(std.atoi(var.timestamp)), 30m))) {\n\t\terror 401 \"Timestamp expired\";\n\t}\n\n\tif(time.is_after(\n\t\t\t\tstd.integer2time(std.atoi(var.timestamp)),\n\t\t\t\ttime.add(now, 1m))) {\n\t\terror 401 \"Timestamp too far in future\";\n\t}\n\n\terror 200 \"Authenticated!\";\n\n\treturn(lookup);\n}\n\nsub vcl_fetch {\n#FASTLY fetch\n\treturn(deliver);\n}\n\nsub vcl_hit {\n#FASTLY hit\n\tif (!obj.cacheable) {\n\t\treturn(pass);\n\t}\n\treturn(deliver);\n}\n\nsub vcl_miss {\n#FASTLY miss\n\treturn(fetch);\n}\n\nsub vcl_deliver{\n#FASTLY deliver\n\treturn(deliver);\n}\n\nsub vcl_error {\n#FASTLY error\n#DEPLOY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n","old_contents":"\ntable consumer_secrets {\n\t\"foo\": \"foo_secret\"\n}\n\ntable access_tokens {\n\t\"bar\": \"bar_secret\"\n}\n\nsub vcl_recv {\n#FASTLY recv\n#DEPLOY recv\n\tdeclare local var.consumer_key STRING;\n\tdeclare local var.consumer_secret STRING;\n\tdeclare local var.access_token STRING;\n\tdeclare local var.access_token_secret STRING;\n\tdeclare local var.provided_signature STRING;\n\tdeclare local var.parameters STRING;\n\tdeclare local var.base_string_uri STRING;\n\tdeclare local var.base_string STRING;\n\tdeclare local var.calculated_signature STRING;\n\tdeclare local var.timestamp STRING;\n\n\tset var.consumer_key = if(req.url ~ \"(?i)oauth_consumer_key=([^&]*)\", \n\t\t\turldecode(re.group.1), \"\");\n\tif(var.consumer_key == \"\") {\n\t\terror 401 \"Missing Consumer Key\";\n\t}\n\tset var.consumer_secret = table.lookup(consumer_secrets, var.consumer_key, \"\");\n\tif(var.consumer_secret == \"\") {\n\t\terror 401 \"Invalid Consumer Key\";\n\t}\n\tset var.access_token = if(req.url ~ \"(?i)oauth_token=([^&]*)\", \n\t\t\turldecode(re.group.1), \"\");\n\tif(var.access_token != \"\") {\n\t\tset var.access_token_secret = table.lookup(access_tokens, var.access_token, \"\");\n\t\tif(var.access_token_secret == \"\") {\n\t\t\terror 401 \"Invalid Access Token\";\n\t\t}\n\t} else {\n\t\tset var.access_token_secret = \"\";\n\t}\n\tset var.provided_signature = if(req.url ~ \"(?i)oauth_signature=([^&]*)\", \n\t\t\turldecode(re.group.1), \"\");\n\tif(var.provided_signature == \"\") {\n\t\terror 401 \"Missing Signature\";\n\t}\n\tset var.parameters = regsub(\n\t\t\tregsub(boltsort.sort(req.url), \".*\\?\", \"\"), \n\t\t\t\"&oauth_signature=[^&]*\", \"\");\n\tset var.base_string_uri = \n\t\tif(req.http.Fastly-SSL, \"https\", \"http\") \n\t\t\t\":\/\/\"\n\t\t\t\tstd.tolower(req.http.host)\n\t\t\t\treq.url.path;\n\tset var.base_string = \n\t\treq.request\n\t\t\"&\"\n\t\turlencode(var.base_string_uri)\n\t\t\"&\"\n\t\turlencode(var.parameters);\n\n\tset var.calculated_signature = digest.hmac_sha1_base64(\n\t\t\tvar.consumer_secret \"&\" var.access_token_secret, \n\t\t\tvar.base_string);\n\n\tif(var.provided_signature != var.calculated_signature) {\n\t\terror 401 \"Invalid OAuth Signature\";\n\t}\n\n\tset var.timestamp = if(req.url ~ \"(?i)oauth_timestamp=([0-9]*)\", \n\t\t\turldecode(re.group.1), \"\");\n\tif(var.timestamp == \"\") {\n\t\terror 401 \"Missing\/Invalid Timestamp\";\n\t}\n\n\tif(time.is_after(\n\t\t\t\tnow,\n\t\t\t\ttime.add(std.integer2time(std.atoi(var.timestamp)), 30m))) {\n\t\terror 401 \"Timestamp expired\";\n\t}\n\n\tif(time.is_after(\n\t\t\t\tstd.integer2time(std.atoi(var.timestamp)),\n\t\t\t\ttime.add(now, 1m))) {\n\t\terror 401 \"Timestamp too far in future\";\n\t}\n\n\terror 200 \"Authenticated!\";\n\n\treturn(lookup);\n}\n\nsub vcl_fetch {\n#FASTLY fetch\n\treturn(deliver);\n}\n\nsub vcl_hit {\n#FASTLY hit\n\tif (!obj.cacheable) {\n\t\treturn(pass);\n\t}\n\treturn(deliver);\n}\n\nsub vcl_miss {\n#FASTLY miss\n\treturn(fetch);\n}\n\nsub vcl_deliver{\n#FASTLY deliver\n\treturn(deliver);\n}\n\nsub vcl_error {\n#FASTLY error\n#DEPLOY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"b4faab9e68d762eedad12907e763c723486bc930","subject":"new line at end of file","message":"new line at end of file\n","repos":"pariahsoft\/libvmod-authentication,pariahsoft\/libvmod-authentication","old_file":"examples\/default.vcl","new_file":"examples\/default.vcl","new_contents":"# This is a basic VCL configuration file for varnish. See the vcl(7)\n# man page for details on VCL syntax and semantics.\n# \n# Default backend definition. Set this to point to your content\n# server.\n# \nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\n\nimport authentication;\n\nsub vcl_recv {\n\tif(!authentication.match(\"admin\", \"test\")) {\n\t\terror 401 \"Authentication Required\";\n\t}\n\t\n\treturn (lookup);\n}\n\nsub vcl_error {\n\tif(obj.status == 401) {\n\t\tset obj.http.WWW-Authenticate = \"Basic realm=Secure Area\";\n\t}\n}\n\n","old_contents":"# This is a basic VCL configuration file for varnish. See the vcl(7)\n# man page for details on VCL syntax and semantics.\n# \n# Default backend definition. Set this to point to your content\n# server.\n# \nbackend default {\n .host = \"127.0.0.1\";\n .port = \"80\";\n}\n\nimport authentication;\n\nsub vcl_recv {\n\tif(!authentication.match(\"admin\", \"test\")) {\n\t\terror 401 \"Authentication Required\";\n\t}\n\t\n\treturn (lookup);\n}\n\nsub vcl_error {\n\tif(obj.status == 401) {\n\t\tset obj.http.WWW-Authenticate = \"Basic realm=Secure Area\";\n\t}\n}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"4b7fcf4529c42e2e5aeacf333ffbcc709601a53b","subject":"Adding X-Cache header in varnish VCL","message":"Adding X-Cache header in varnish VCL\n","repos":"shawnsi\/varnish-ring,shawnsi\/varnish-ring,shawnsi\/varnish-ring","old_file":"roles\/varnish\/files\/default.vcl","new_file":"roles\/varnish\/files\/default.vcl","new_contents":"backend default {\n .host = \"127.0.0.1\";\n .port = \"9090\";\n}\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n }\n else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n","old_contents":"# This is a basic VCL configuration file for varnish. See the vcl(7)\n# man page for details on VCL syntax and semantics.\n# \n# Default backend definition. Set this to point to your content\n# server.\n# \nbackend default {\n .host = \"127.0.0.1\";\n .port = \"9090\";\n}\n# \n# Below is a commented-out copy of the default VCL logic. If you\n# redefine any of these subroutines, the built-in logic will be\n# appended to your code.\n# sub vcl_recv {\n# if (req.restarts == 0) {\n# \tif (req.http.x-forwarded-for) {\n# \t set req.http.X-Forwarded-For =\n# \t\treq.http.X-Forwarded-For + \", \" + client.ip;\n# \t} else {\n# \t set req.http.X-Forwarded-For = client.ip;\n# \t}\n# }\n# if (req.request != \"GET\" &&\n# req.request != \"HEAD\" &&\n# req.request != \"PUT\" &&\n# req.request != \"POST\" &&\n# req.request != \"TRACE\" &&\n# req.request != \"OPTIONS\" &&\n# req.request != \"DELETE\") {\n# \/* Non-RFC2616 or CONNECT which is weird. *\/\n# return (pipe);\n# }\n# if (req.request != \"GET\" && req.request != \"HEAD\") {\n# \/* We only deal with GET and HEAD by default *\/\n# return (pass);\n# }\n# if (req.http.Authorization || req.http.Cookie) {\n# \/* Not cacheable by default *\/\n# return (pass);\n# }\n# return (lookup);\n# }\n# \n# sub vcl_pipe {\n# # Note that only the first request to the backend will have\n# # X-Forwarded-For set. If you use X-Forwarded-For and want to\n# # have it set for all requests, make sure to have:\n# # set bereq.http.connection = \"close\";\n# # here. It is not set by default as it might break some broken web\n# # applications, like IIS with NTLM authentication.\n# return (pipe);\n# }\n# \n# sub vcl_pass {\n# return (pass);\n# }\n# \n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (hash);\n# }\n# \n# sub vcl_hit {\n# return (deliver);\n# }\n# \n# sub vcl_miss {\n# return (fetch);\n# }\n# \n# sub vcl_fetch {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Vary == \"*\") {\n# \t\t\/*\n# \t\t * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# \t\t *\/\n# \t\tset beresp.ttl = 120 s;\n# \t\treturn (hit_for_pass);\n# }\n# return (deliver);\n# }\n# \n# sub vcl_deliver {\n# return (deliver);\n# }\n# \n# sub vcl_error {\n# set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n# set obj.http.Retry-After = \"5\";\n# synthetic {\"\n# <?xml version=\"1.0\" encoding=\"utf-8\"?>\n# <!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n# \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n# <html>\n# <head>\n# <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n# <\/head>\n# <body>\n# <h1>Error \"} + obj.status + \" \" + obj.response + {\"<\/h1>\n# <p>\"} + obj.response + {\"<\/p>\n# <h3>Guru Meditation:<\/h3>\n# <p>XID: \"} + req.xid + {\"<\/p>\n# <hr>\n# <p>Varnish cache server<\/p>\n# <\/body>\n# <\/html>\n# \"};\n# return (deliver);\n# }\n# \n# sub vcl_init {\n# \treturn (ok);\n# }\n# \n# sub vcl_fini {\n# \treturn (ok);\n# }\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"dad7c5232be6929aea02262aa5a784d30cbe6880","subject":"Only bypass for logged in users, not logged out","message":"Only bypass for logged in users, not logged out\n","repos":"evolution\/genesis-wordpress,jalevin\/wordpress,evolution\/genesis-wordpress,genesis\/wordpress,evolution\/genesis-wordpress,jalevin\/wordpress,evolution\/genesis-wordpress,evolution\/wordpress,evolution\/genesis-wordpress,genesis\/wordpress,jalevin\/wordpress,genesis\/wordpress,jalevin\/wordpress,evolution\/wordpress,evolution\/wordpress,evolution\/wordpress,genesis\/wordpress,genesis\/wordpress,evolution\/genesis-wordpress,evolution\/wordpress,jalevin\/wordpress,genesis\/wordpress","old_file":"provisioning\/roles\/varnish\/files\/etc-varnish\/conf.d\/receive\/wordpress.vcl","new_file":"provisioning\/roles\/varnish\/files\/etc-varnish\/conf.d\/receive\/wordpress.vcl","new_contents":"# Pass all local or login\/admin requests straight through\nif (req.http.Host ~ \"^local\\.\" || (req.url ~ \"wp-(login|admin)\")) {\n return (pass);\n}\n\nif (req.http.Cookie ~ \"^wordpress_logged_in_\") {\n return (pass);\n}\n\n# Drop any cookies sent to Wordpress.\nif (!(req.url ~ \"wp-(login|admin)\")) {\n unset req.http.Cookie;\n}\n\n# Anything else left?\nif (!req.http.Cookie) {\n unset req.http.Cookie;\n}\n\n# Try a cache-lookup\nreturn (lookup);\n","old_contents":"# Pass all local or login\/admin requests straight through\nif (req.http.Host ~ \"^local\\.\" || (req.url ~ \"wp-(login|admin)\")) {\n return (pass);\n}\n\nif (req.http.Cookie ~ \"^wp-\" || req.http.Cookie ~ \"^wordpress_\") {\n return (pass);\n}\n\n# Drop any cookies sent to Wordpress.\nif (!(req.url ~ \"wp-(login|admin)\")) {\n unset req.http.Cookie;\n}\n\n# Anything else left?\nif (!req.http.Cookie) {\n unset req.http.Cookie;\n}\n\n# Try a cache-lookup\nreturn (lookup);\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"0f3ab22ec5713d3ff23bb771eeab4694e73feb1f","subject":"Add comments","message":"Add comments\n","repos":"elifesciences\/builder,elifesciences\/builder","old_file":"src\/buildercore\/fastly\/vcl\/main.vcl","new_file":"src\/buildercore\/fastly\/vcl\/main.vcl","new_contents":"sub vcl_recv {\n if (req.restarts < 1) {\n # Sanitise header\n unset req.http.X-eLife-Restart;\n }\n\n #FASTLY recv\n\n if (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n return(lookup);\n}\n\nsub vcl_fetch {\n #FASTLY fetch\n\n if (beresp.status >= 500 && beresp.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n set req.http.X-eLife-Restart = \"fetch,\" beresp.status;\n unset req.http.Cookie; # Temporarily log out the user\n\n restart;\n }\n\n if (!beresp.http.Content-Length || beresp.http.Content-Length == \"0\") {\n error beresp.status;\n }\n }\n\n if (req.restarts > 0) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return(pass);\n }\n\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return(pass);\n }\n\n if (beresp.status == 500 || beresp.status == 503) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return(deliver);\n }\n\n if (beresp.http.Expires || beresp.http.Surrogate-Control ~ \"max-age\" || beresp.http.Cache-Control ~ \"(s-maxage|max-age)\") {\n # keep the ttl here\n } else {\n # apply the default ttl\n set beresp.ttl = 3600s;\n }\n\n return(deliver);\n}\n\nsub vcl_hit {\n #FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\nsub vcl_miss {\n #FASTLY miss\n return(fetch);\n}\n\nsub vcl_deliver {\n if (resp.status >= 500 && resp.status < 600 && stale.exists) {\n set req.http.X-eLife-Restart = \"deliver,\" resp.status;\n\n restart;\n }\n\n if (req.http.Fastly-Debug && req.http.X-eLife-Restart) {\n set resp.http.X-eLife-Restart = req.http.X-eLife-Restart;\n }\n\n #FASTLY deliver\n return(deliver);\n}\n\nsub vcl_error {\n if (obj.status >= 500 && obj.status < 600 && stale.exists) {\n return(deliver_stale);\n }\n\n #FASTLY error\n}\n\nsub vcl_pass {\n #FASTLY pass\n}\n\nsub vcl_log {\n #FASTLY log\n}\n","old_contents":"sub vcl_recv {\n if (req.restarts < 1) {\n unset req.http.X-eLife-Restart;\n }\n\n #FASTLY recv\n\n if (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n return(lookup);\n}\n\nsub vcl_fetch {\n #FASTLY fetch\n\n if (beresp.status >= 500 && beresp.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n set req.http.X-eLife-Restart = \"fetch,\" beresp.status;\n unset req.http.Cookie;\n\n restart;\n }\n\n if (!beresp.http.Content-Length || beresp.http.Content-Length == \"0\") {\n error beresp.status;\n }\n }\n\n if (req.restarts > 0) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return(pass);\n }\n\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return(pass);\n }\n\n if (beresp.status == 500 || beresp.status == 503) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return(deliver);\n }\n\n if (beresp.http.Expires || beresp.http.Surrogate-Control ~ \"max-age\" || beresp.http.Cache-Control ~ \"(s-maxage|max-age)\") {\n # keep the ttl here\n } else {\n # apply the default ttl\n set beresp.ttl = 3600s;\n }\n\n return(deliver);\n}\n\nsub vcl_hit {\n #FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\nsub vcl_miss {\n #FASTLY miss\n return(fetch);\n}\n\nsub vcl_deliver {\n if (resp.status >= 500 && resp.status < 600 && stale.exists) {\n set req.http.X-eLife-Restart = \"deliver,\" resp.status;\n\n restart;\n }\n\n if (req.http.Fastly-Debug && req.http.X-eLife-Restart) {\n set resp.http.X-eLife-Restart = req.http.X-eLife-Restart;\n }\n\n #FASTLY deliver\n return(deliver);\n}\n\nsub vcl_error {\n if (obj.status >= 500 && obj.status < 600 && stale.exists) {\n return(deliver_stale);\n }\n\n #FASTLY error\n}\n\nsub vcl_pass {\n #FASTLY pass\n}\n\nsub vcl_log {\n #FASTLY log\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"ec4775aced3caab7554661879341d0dabd990a57","subject":"remove vsl which set content-security-policy as it is now set in the backend server","message":"remove vsl which set content-security-policy as it is now set in the backend server\n","repos":"JakeChampion\/polyfill-service,JakeChampion\/polyfill-service","old_file":"fastly\/vcl\/polyfill-service.vcl","new_file":"fastly\/vcl\/polyfill-service.vcl","new_contents":"sub set_backend {\n\t# Calculate the ideal region to route the request to.\n\tdeclare local var.region STRING;\n\tif (server.region ~ \"(APAC|Asia|North-America|South-America|US-Central|US-East|US-West)\") {\n\t\tset var.region = \"US\";\n\t} else {\n\t\tset var.region = \"EU\";\n\t}\n\n\t# Gather the health of the shields and origins.\n\tdeclare local var.v3_eu_is_healthy BOOL;\n\tset req.backend = F_v3_eu;\n\tset var.v3_eu_is_healthy = req.backend.healthy;\n\n\tdeclare local var.v3_us_is_healthy BOOL;\n\tset req.backend = F_v3_us;\n\tset var.v3_us_is_healthy = req.backend.healthy;\n\n\t# Set some sort of default, that shouldn't get used.\n\tset req.backend = F_v3_eu;\n\n\t# Route EU requests to the nearest healthy shield or origin.\n\tif (var.region == \"EU\") {\n\t\tif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_eu;\n\t\t}\n\t}\n\n\t# Route US requests to the nearest healthy shield or origin.\n\tif (var.region == \"US\") {\n\t\tif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_us;\n\t\t}\n\t}\n\n\t# Persist the decision so we can debug the result.\n\tset req.http.Debug-Backend = req.backend;\n\n\t# The Fastly macro is inserted after the backend is selected because the\n\t# macro has the code to select the correct req.http.Host value based on the backend.\n\t#FASTLY recv\n}\n\nsub vcl_recv {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_recv;\n\t}\n\n\tif (req.method != \"GET\" && req.method != \"HEAD\" && req.method != \"OPTIONS\" && req.method != \"FASTLYPURGE\" && req.method != \"PURGE\") {\n\t\terror 911;\n\t}\n\n\tif (req.method == \"OPTIONS\") {\n\t\terror 912;\n\t}\n\n\t# Because the old service had a router which allowed any words between \/v2\/polyfill. and .js\n\tif (req.url ~ \"^\/v2\/polyfill(\\.\\w+)\\.js\") {\n\t\tset req.url = regsub(req.url, \"^\/v2\/polyfill(\\.\\w+)\\.js\", \"\/v2\/polyfill.min.js\");\n\t}\n\n\t# Override the v3 defaults with the defaults of v2\n\tif (req.url ~ \"^\/v2\/polyfill(\\.min)?\\.js\") {\n\t\tset req.url = regsub(req.url, \"^\/v2\", \"\/v3\");\n\t\tset req.url = querystring.set(req.url, \"version\", \"3.25.1\");\n\t\tdeclare local var.unknown STRING;\n\t\tset var.unknown = subfield(req.url.qs, \"unknown\", \"&\");\n\t\tset req.url = querystring.set(req.url, \"unknown\", if(var.unknown != \"\", var.unknown, \"ignore\"));\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\") {\n\t\tcall normalise_querystring_parameters_for_polyfill_bundle;\n\t}\n\n\t# Sort the querystring parameters alphabetically to improve chances of hitting a cached copy.\n\t# If querystring is empty, remove the ? from the url.\n\tset req.url = querystring.clean(querystring.sort(req.url));\n\tcall set_backend;\n}\n\nsub vcl_hash {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_hash;\n\t}\n\n\t# We are not adding req.http.host to the hash because we want https:\/\/cdn.polyfill.io and https:\/\/polyfill.io to be a single object in the cache.\n\t# set req.hash += req.http.host;\n\tset req.hash += req.url;\n\t# We include return(hash) to stop the function falling through to the default VCL built into varnish, which for vcl_hash will add req.url and req.http.Host to the hash.\n\treturn(hash);\n}\n\nsub vcl_miss {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_miss;\n\t}\n}\n\nsub vcl_pass {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_pass;\n\t}\n}\n\nsub vcl_fetch {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_fetch;\n\t}\n\n\t# These header are only required for HTML documents.\n\tif (beresp.http.Content-Type ~ \"text\/html\") {\n\t\t# Enables the cross-site scripting filter built into most modern web browsers.\n\t\tset beresp.http.X-XSS-Protection = \"1; mode=block\";\t\n\t}\n\t# Prevents MIME-sniffing a response away from the declared content type.\n\tset beresp.http.X-Content-Type-Options = \"nosniff\";\n\n\t# Ensure the site is only served over HTTPS and reduce the chances of someone performing a MITM attack.\n\tset beresp.http.Strict-Transport-Security = \"max-age=31536000; includeSubdomains; preload\";\n\n\t# The Referrer-Policy header governs which referrer information, sent in the Referer header, should be included with requests made.\n\t# Send a full URL when performing a same-origin request, but only send the origin of the document for other cases.\n\tset beresp.http.Referrer-Policy = \"origin-when-cross-origin\";\n\n\t# Enable purging of all objects in the Fastly cache by issuing a purge with the key \"polyfill-service\".\n\tif (beresp.http.Surrogate-Key !~ \"\\bpolyfill-service\\b\") {\n\t\tset beresp.http.Surrogate-Key = if(beresp.http.Surrogate-Key, beresp.http.Surrogate-Key \" polyfill-service\", \"polyfill-service\");\n\t}\n\n\tset beresp.http.Timing-Allow-Origin = \"*\";\n\n\tif (req.http.Normalized-User-Agent) {\n\t\tset beresp.http.Normalized-User-Agent = req.http.Normalized-User-Agent;\n\t\tset beresp.http.Detected-User-Agent = req.http.useragent_parser_family \"\/\" req.http.useragent_parser_major \".\" req.http.useragent_parser_minor \".\" req.http.useragent_parser_patch;\n\t}\n}\n\nsub vcl_deliver {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_deliver;\n\t}\n\n\tset req.http.Fastly-Force-Shield = \"yes\";\n\n\t# Allow cross origin GET, HEAD, and OPTIONS requests to be made.\n\tif (req.http.Origin) {\n\t\tset resp.http.Access-Control-Allow-Origin = \"*\";\n\t\tset resp.http.Access-Control-Allow-Methods = \"GET,HEAD,OPTIONS\";\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\") {\n\t\t# Need to add \"Vary: User-Agent\" in after vcl_fetch to avoid the \n\t\t# \"Vary: User-Agent\" entering the Varnish cache.\n\t\t# We need \"Vary: User-Agent\" in the browser cache because a browser\n\t\t# may update itself to a version which needs different polyfills\n\t\t# So we need to have it ignore the browser cached bundle when the user-agent changes.\n\t\tadd resp.http.Vary = \"User-Agent\";\n\t\tadd resp.http.Vary = \"Accept-Encoding\";\n\t}\n\n\tadd resp.http.Server-Timing = fastly_info.state {\", fastly;desc=\"Edge time\";dur=\"} time.elapsed.msec;\n\n\tif (req.http.Fastly-Debug) {\n\t\tset resp.http.Debug-Backend = req.http.Debug-Backend;\n\t\tset resp.http.Debug-Host = req.http.Host;\n\t\tset resp.http.Debug-Fastly-Restarts = req.restarts;\n\t\tset resp.http.Debug-Orig-URL = req.http.Orig-URL;\n\t\tset resp.http.Debug-VCL-Route = req.http.X-VCL-Route;\n\t\tset resp.http.useragent_parser_family = req.http.useragent_parser_family;\n\t\tset resp.http.useragent_parser_major = req.http.useragent_parser_major;\n\t\tset resp.http.useragent_parser_minor = req.http.useragent_parser_minor;\n\t\tset resp.http.useragent_parser_patch = req.http.useragent_parser_patch;\n\t} else {\n\t\tunset resp.http.Server;\n\t\tunset resp.http.Via;\n\t\tunset resp.http.X-Cache;\n\t\tunset resp.http.X-Cache-Hits;\n\t\tunset resp.http.X-Served-By;\n\t\tunset resp.http.X-Timer;\n\t\tunset resp.http.Fastly-Restarts;\n\t}\n}\n\nsub vcl_error {\n\tif (obj.status == 911) {\n\t\tset obj.status = 405;\n\t\tset obj.response = \"METHOD NOT ALLOWED\";\n\t\tset obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n\t\tset obj.http.Cache-Control = \"private, no-store\";\n\t\tsynthetic req.method \" METHOD NOT ALLOWED\";\n\t\treturn (deliver);\n\t}\n\tif (obj.status == 912) {\n\t\tset obj.status = 200;\n\t\tset obj.response = \"OK\";\n\t\tset obj.http.Allow = \"OPTIONS, GET, HEAD\";\n\t\treturn (deliver);\n\t}\n}\n","old_contents":"sub set_backend {\n\t# Calculate the ideal region to route the request to.\n\tdeclare local var.region STRING;\n\tif (server.region ~ \"(APAC|Asia|North-America|South-America|US-Central|US-East|US-West)\") {\n\t\tset var.region = \"US\";\n\t} else {\n\t\tset var.region = \"EU\";\n\t}\n\n\t# Gather the health of the shields and origins.\n\tdeclare local var.v3_eu_is_healthy BOOL;\n\tset req.backend = F_v3_eu;\n\tset var.v3_eu_is_healthy = req.backend.healthy;\n\n\tdeclare local var.v3_us_is_healthy BOOL;\n\tset req.backend = F_v3_us;\n\tset var.v3_us_is_healthy = req.backend.healthy;\n\n\t# Set some sort of default, that shouldn't get used.\n\tset req.backend = F_v3_eu;\n\n\t# Route EU requests to the nearest healthy shield or origin.\n\tif (var.region == \"EU\") {\n\t\tif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_eu;\n\t\t}\n\t}\n\n\t# Route US requests to the nearest healthy shield or origin.\n\tif (var.region == \"US\") {\n\t\tif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_us;\n\t\t}\n\t}\n\n\t# Persist the decision so we can debug the result.\n\tset req.http.Debug-Backend = req.backend;\n\n\t# The Fastly macro is inserted after the backend is selected because the\n\t# macro has the code to select the correct req.http.Host value based on the backend.\n\t#FASTLY recv\n}\n\nsub vcl_recv {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_recv;\n\t}\n\n\tif (req.method != \"GET\" && req.method != \"HEAD\" && req.method != \"OPTIONS\" && req.method != \"FASTLYPURGE\" && req.method != \"PURGE\") {\n\t\terror 911;\n\t}\n\n\tif (req.method == \"OPTIONS\") {\n\t\terror 912;\n\t}\n\n\t# Because the old service had a router which allowed any words between \/v2\/polyfill. and .js\n\tif (req.url ~ \"^\/v2\/polyfill(\\.\\w+)\\.js\") {\n\t\tset req.url = regsub(req.url, \"^\/v2\/polyfill(\\.\\w+)\\.js\", \"\/v2\/polyfill.min.js\");\n\t}\n\n\t# Override the v3 defaults with the defaults of v2\n\tif (req.url ~ \"^\/v2\/polyfill(\\.min)?\\.js\") {\n\t\tset req.url = regsub(req.url, \"^\/v2\", \"\/v3\");\n\t\tset req.url = querystring.set(req.url, \"version\", \"3.25.1\");\n\t\tdeclare local var.unknown STRING;\n\t\tset var.unknown = subfield(req.url.qs, \"unknown\", \"&\");\n\t\tset req.url = querystring.set(req.url, \"unknown\", if(var.unknown != \"\", var.unknown, \"ignore\"));\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\") {\n\t\tcall normalise_querystring_parameters_for_polyfill_bundle;\n\t}\n\n\t# Sort the querystring parameters alphabetically to improve chances of hitting a cached copy.\n\t# If querystring is empty, remove the ? from the url.\n\tset req.url = querystring.clean(querystring.sort(req.url));\n\tcall set_backend;\n}\n\nsub vcl_hash {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_hash;\n\t}\n\n\t# We are not adding req.http.host to the hash because we want https:\/\/cdn.polyfill.io and https:\/\/polyfill.io to be a single object in the cache.\n\t# set req.hash += req.http.host;\n\tset req.hash += req.url;\n\t# We include return(hash) to stop the function falling through to the default VCL built into varnish, which for vcl_hash will add req.url and req.http.Host to the hash.\n\treturn(hash);\n}\n\nsub vcl_miss {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_miss;\n\t}\n}\n\nsub vcl_pass {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_pass;\n\t}\n}\n\nsub vcl_fetch {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_fetch;\n\t}\n\n\t# These header are only required for HTML documents.\n\tif (beresp.http.Content-Type ~ \"text\/html\") {\n\t\t# Enables the cross-site scripting filter built into most modern web browsers.\n\t\tset beresp.http.X-XSS-Protection = \"1; mode=block\";\t\n\n\t\t# Allow only content from the site's own origin (this excludes subdomains) and www.ft.com.\n\t\t# Don't allow the website to be used within an iframe\n\t\tif (!beresp.http.Content-Security-Policy) {\n\t\t\tset beresp.http.Content-Security-Policy = \"default-src 'self'; font-src 'self' https:\/\/www.ft.com; img-src 'self' https:\/\/www.ft.com; frame-ancestors 'none'; base-uri 'self'; form-action 'self'\";\n\t\t}\n\t}\n\t# Prevents MIME-sniffing a response away from the declared content type.\n\tset beresp.http.X-Content-Type-Options = \"nosniff\";\n\n\t# Ensure the site is only served over HTTPS and reduce the chances of someone performing a MITM attack.\n\tset beresp.http.Strict-Transport-Security = \"max-age=31536000; includeSubdomains; preload\";\n\n\t# The Referrer-Policy header governs which referrer information, sent in the Referer header, should be included with requests made.\n\t# Send a full URL when performing a same-origin request, but only send the origin of the document for other cases.\n\tset beresp.http.Referrer-Policy = \"origin-when-cross-origin\";\n\n\t# Enable purging of all objects in the Fastly cache by issuing a purge with the key \"polyfill-service\".\n\tif (beresp.http.Surrogate-Key !~ \"\\bpolyfill-service\\b\") {\n\t\tset beresp.http.Surrogate-Key = if(beresp.http.Surrogate-Key, beresp.http.Surrogate-Key \" polyfill-service\", \"polyfill-service\");\n\t}\n\n\tset beresp.http.Timing-Allow-Origin = \"*\";\n\n\tif (req.http.Normalized-User-Agent) {\n\t\tset beresp.http.Normalized-User-Agent = req.http.Normalized-User-Agent;\n\t\tset beresp.http.Detected-User-Agent = req.http.useragent_parser_family \"\/\" req.http.useragent_parser_major \".\" req.http.useragent_parser_minor \".\" req.http.useragent_parser_patch;\n\t}\n}\n\nsub vcl_deliver {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_deliver;\n\t}\n\n\tset req.http.Fastly-Force-Shield = \"yes\";\n\n\t# Allow cross origin GET, HEAD, and OPTIONS requests to be made.\n\tif (req.http.Origin) {\n\t\tset resp.http.Access-Control-Allow-Origin = \"*\";\n\t\tset resp.http.Access-Control-Allow-Methods = \"GET,HEAD,OPTIONS\";\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\") {\n\t\t# Need to add \"Vary: User-Agent\" in after vcl_fetch to avoid the \n\t\t# \"Vary: User-Agent\" entering the Varnish cache.\n\t\t# We need \"Vary: User-Agent\" in the browser cache because a browser\n\t\t# may update itself to a version which needs different polyfills\n\t\t# So we need to have it ignore the browser cached bundle when the user-agent changes.\n\t\tadd resp.http.Vary = \"User-Agent\";\n\t\tadd resp.http.Vary = \"Accept-Encoding\";\n\t}\n\n\tadd resp.http.Server-Timing = fastly_info.state {\", fastly;desc=\"Edge time\";dur=\"} time.elapsed.msec;\n\n\tif (req.http.Fastly-Debug) {\n\t\tset resp.http.Debug-Backend = req.http.Debug-Backend;\n\t\tset resp.http.Debug-Host = req.http.Host;\n\t\tset resp.http.Debug-Fastly-Restarts = req.restarts;\n\t\tset resp.http.Debug-Orig-URL = req.http.Orig-URL;\n\t\tset resp.http.Debug-VCL-Route = req.http.X-VCL-Route;\n\t\tset resp.http.useragent_parser_family = req.http.useragent_parser_family;\n\t\tset resp.http.useragent_parser_major = req.http.useragent_parser_major;\n\t\tset resp.http.useragent_parser_minor = req.http.useragent_parser_minor;\n\t\tset resp.http.useragent_parser_patch = req.http.useragent_parser_patch;\n\t} else {\n\t\tunset resp.http.Server;\n\t\tunset resp.http.Via;\n\t\tunset resp.http.X-Cache;\n\t\tunset resp.http.X-Cache-Hits;\n\t\tunset resp.http.X-Served-By;\n\t\tunset resp.http.X-Timer;\n\t\tunset resp.http.Fastly-Restarts;\n\t}\n}\n\nsub vcl_error {\n\tif (obj.status == 911) {\n\t\tset obj.status = 405;\n\t\tset obj.response = \"METHOD NOT ALLOWED\";\n\t\tset obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n\t\tset obj.http.Cache-Control = \"private, no-store\";\n\t\tsynthetic req.method \" METHOD NOT ALLOWED\";\n\t\treturn (deliver);\n\t}\n\tif (obj.status == 912) {\n\t\tset obj.status = 200;\n\t\tset obj.response = \"OK\";\n\t\tset obj.http.Allow = \"OPTIONS, GET, HEAD\";\n\t\treturn (deliver);\n\t}\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"cf4a9a8c2638633c11185c4b74b56c48921f1b55","subject":"Fixed unmatched parentheses.","message":"Fixed unmatched parentheses.\n","repos":"killerwails\/ansible-varnish,noqcks\/ansible-varnish,telusdigital\/ansible-varnish,killerwails\/ansible-varnish,gotofbi\/ansible-varnish,kkwoker\/ansible-varnish,gotofbi\/ansible-varnish,colstrom\/ansible-varnish","old_file":"templates\/etc\/varnish\/default.vcl","new_file":"templates\/etc\/varnish\/default.vcl","new_contents":"vcl 4.0;\n\nimport directors;\nimport std;\n\n###\n# Varnish Documentation\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-built-in-subs.html\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/reference\/vcl.html\n##\n\n{% for backend in varnish_backend_hosts %}\nbackend application_{{ loop.index }} {\n .host = \"{{ backend }}\";\n .port = \"{{ varnish_backend_port }}\";\n{% if varnish_health_checks_enabled %}\n .probe = {\n .url = \"{{ varnish_health_check_url }}\";\n .interval = {{ varnish_health_check_interval }};\n .timeout = {{ varnish_health_check_timeout }};\n .window = {{ varnish_health_check_window }};\n .threshold = {{ varnish_health_check_threshold }};\n }\n{% endif %}\n}\n{% endfor %}\n\n###\n# vcl_init\n# Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n###\n# The vcl_init subroutine may terminate with calling return() with one of the following keywords:\n#\n# ok\n# Normal return, VCL continues loading.\n##\n\nsub vcl_init {\n new application = directors.round_robin();\n{% for backend in varnish_backend_hosts %}\n application.add_backend(application_{{ loop.index }});\n{% endfor %}\n}\n\n###\n# vcl_recv\n# Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use. \n# It is also used to modify the request\n###\n# The vcl_recv subroutine may terminate with calling return() on one of the following keywords:\n#\n# synth(status code, reason)\n# Return a synthetic object with the specified status code to the client and abandon the request.\n# pass\n# Switch to pass mode. Control will eventually pass to vcl_pass.\n# pipe\n# Switch to pipe mode. Control will eventually pass to vcl_pipe.\n# hash\n# Continue processing the object as a potential candidate for caching. Passes the control over to vcl_hash.\n# purge\n# Purge the object and it's variants. Control passes through vcl_hash to vcl_purge.\n#\n\nsub vcl_recv {\n set req.backend_hint = application.backend();\n\n ###\n # Avoid processing uncacheable requests\n ###\n\n if (req.http.Authorization) {\n return (pass);\n }\n\n ###\n # Inject X-Forwarded-For headers, but only once.\n ###\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n{% if varnish_header_sanitization_enabled %}\n ###\n # Header Sanitization\n ###\n\n{% if varnish_discards_port_from_host_header %}\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n{% endif %}\n\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_enabled %}\n ###\n # Cookie Sanitization\n ###\n\n ### Google Analytics\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n\n ### Quantcast\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n \n ### AddThis\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n\n ### General Cleanup\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n{% endif %}\n\n{% if varnish_uri_sanitization_enabled %}\n ###\n # URI Sanitization\n ###\n \n if (req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=\") {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n{% endif %}\n\n{% if varnish_workaround_telusdotcom_browser_profile %}\n ###\n # Workaround for BrowserProfile and Language\/Region Detection on TELUS.com\n ###\n\n if (req.http.Cookie ~ \"BrowserProfile\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.Cookie, \"(.*)language..:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n set req.http.X-Province = std.tolower(regsuball(req.http.Cookie, \"(.*)language..:(.*)region..:\\\\.([^\\\\]*)(.*)\", \"\\3\"));\n } else {\n if (req.http.Cookie ~ \"lang=\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.Cookie, \"(.*)lang=([^;]*)(.*)\", \"\\2\"));\n } else {\n set req.http.X-Language = \"en\";\n }\n\n if (req.http.Cookie ~ \"prov=\") {\n set req.http.X-Province = std.tolower(regsuball(req.http.Cookie, \"(.*)prov=([^;]*)(.*)\", \"\\2\"));\n } else {\n set req.http.X-Province = \"BC\";\n }\n }\n\n if (req.url ~ \"\/(en|fr)\/\") {\n if (req.url ~ \"\/en\/\" && req.http.X-Language != \"en\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Language)\";\n return(pass);\n }\n if (req.url ~ \"\/fr\/\" && req.http.X-Language != \"fr\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Language)\";\n return(pass);\n }\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Language)\";\n return(pass);\n }\n\n if (req.url ~ \"\/(ab|bc|mb|nb|nl|ns|nt|nu|on|pe|qc|sk|yt)\/\") {\n {% for province in ['ab', 'bc', 'mb', 'nb', 'nl', 'ns', 'nt', 'nu', 'on', 'pe', 'qc', 'sk', 'yt'] %}\n if (req.url ~ \"\/{{ province }}\/\" && req.http.X-Province != \"{{ province }}\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Province)\";\n return(pass);\n }\n {% endfor %}\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Province)\";\n return(pass);\n }\n{% endif %}\n\n{% if varnish_blacklist_enabled %}\n if ((req.url ~ \"{{ varnish_blacklist_regexp }}\")) {\n set req.http.X-Passthrough-Reason = \"Path in Blacklist\";\n return(pass);\n } else {\n{% if varnish_discards_client_cookies %}\n unset req.http.Cookie;\n{% endif %}\n }\n{% endif %}\n\n}\n\n###\n# vcl_hit\n# Called when a cache lookup is successful.\n###\n# The vcl_hit subroutine may terminate with calling return() with one of the following keywords:\n#\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n# deliver\n# Deliver the object. Control passes to vcl_deliver.\n# synth(status code, reason)\n# Return the specified status code to the client and abandon the request.\n###\n\nsub vcl_hit {\n if (obj.ttl > 0s) {\n return (deliver);\n }\n{% if varnish_health_checks_enabled %}\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (fetch);\n }\n{% else %}\n if (obj.ttl + obj.grace > 0s) {\n return (deliver);\n }\n\n return (fetch);\n{% endif %}\n}\n\n###\n# vcl_backend_response\n# Called after the response headers has been successfully retrieved from the backend.\n###\n# The vcl_backend_response subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Possibly insert the object into the cache, then deliver it to the Control will eventually pass to vcl_deliver.\n# abandon\n# Abandon the backend request and generates an error.\n# retry\n# Retry the backend transaction. Increases the retries counter. If the number of retries is higher than max_retries Varnish emits a guru meditation error.\n###\n\nsub vcl_backend_response {\n{% if varnish_workaround_telusdotcom_browser_profile %}\n if (bereq.http.X-Language) {\n set beresp.http.X-Language = bereq.http.X-Language;\n }\n if (bereq.http.X-Province) {\n set beresp.http.X-Province = bereq.http.X-Province;\n }\n{% endif %}\n\n{% if varnish_blacklist_enabled %}\n if (bereq.url ~ \"{{ varnish_blacklist_regexp }}\") {\n set beresp.http.X-Cacheable = \"NO:Path in Blacklist\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n if (bereq.http.X-Passthrough-Reason) {\n set beresp.http.X-Passthrough-Reason = bereq.http.X-Passthrough-Reason;\n return(deliver);\n } else {\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n }\n }\n{% else %}\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n{% endif %}\n\n{% if varnish_cache_diagnostics_enabled %}\n if (bereq.http.Cookie) {\n set beresp.http.X-Cacheable = \"NO:Cookie in Request\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO:Set-Cookie in Response\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.X-No-Cache) {\n set beresp.http.X-Cacheable = \"NO:X-No-Cache\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.ttl <= 0s) {\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n{% endif %}\n\n set beresp.grace = {{ varnish_grace_period }};\n}\n\n###\n# vcl_deliver\n# Called before a cached object is delivered to the client.\n###\n# The vcl_deliver subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Deliver the object to the client.\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n###\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n","old_contents":"vcl 4.0;\n\nimport directors;\nimport std;\n\n###\n# Varnish Documentation\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-built-in-subs.html\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/reference\/vcl.html\n##\n\n{% for backend in varnish_backend_hosts %}\nbackend application_{{ loop.index }} {\n .host = \"{{ backend }}\";\n .port = \"{{ varnish_backend_port }}\";\n{% if varnish_health_checks_enabled %}\n .probe = {\n .url = \"{{ varnish_health_check_url }}\";\n .interval = {{ varnish_health_check_interval }};\n .timeout = {{ varnish_health_check_timeout }};\n .window = {{ varnish_health_check_window }};\n .threshold = {{ varnish_health_check_threshold }};\n }\n{% endif %}\n}\n{% endfor %}\n\n###\n# vcl_init\n# Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n###\n# The vcl_init subroutine may terminate with calling return() with one of the following keywords:\n#\n# ok\n# Normal return, VCL continues loading.\n##\n\nsub vcl_init {\n new application = directors.round_robin();\n{% for backend in varnish_backend_hosts %}\n application.add_backend(application_{{ loop.index }});\n{% endfor %}\n}\n\n###\n# vcl_recv\n# Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use. \n# It is also used to modify the request\n###\n# The vcl_recv subroutine may terminate with calling return() on one of the following keywords:\n#\n# synth(status code, reason)\n# Return a synthetic object with the specified status code to the client and abandon the request.\n# pass\n# Switch to pass mode. Control will eventually pass to vcl_pass.\n# pipe\n# Switch to pipe mode. Control will eventually pass to vcl_pipe.\n# hash\n# Continue processing the object as a potential candidate for caching. Passes the control over to vcl_hash.\n# purge\n# Purge the object and it's variants. Control passes through vcl_hash to vcl_purge.\n#\n\nsub vcl_recv {\n set req.backend_hint = application.backend();\n\n ###\n # Avoid processing uncacheable requests\n ###\n\n if (req.http.Authorization) {\n return (pass);\n }\n\n ###\n # Inject X-Forwarded-For headers, but only once.\n ###\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n{% if varnish_header_sanitization_enabled %}\n ###\n # Header Sanitization\n ###\n\n{% if varnish_discards_port_from_host_header %}\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n{% endif %}\n\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_enabled %}\n ###\n # Cookie Sanitization\n ###\n\n ### Google Analytics\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n\n ### Quantcast\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n \n ### AddThis\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n\n ### General Cleanup\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n{% endif %}\n\n{% if varnish_uri_sanitization_enabled %}\n ###\n # URI Sanitization\n ###\n \n if (req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=\") {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n{% endif %}\n\n{% if varnish_workaround_telusdotcom_browser_profile %}\n ###\n # Workaround for BrowserProfile and Language\/Region Detection on TELUS.com\n ###\n\n if (req.http.Cookie ~ \"BrowserProfile\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.Cookie, \"(.*)language..:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n set req.http.X-Province = std.tolower(regsuball(req.http.Cookie, \"(.*)language..:(.)*)region..:\\\\.([^\\\\]*)(.*)\", \"\\3\"));\n } else {\n if (req.http.Cookie ~ \"lang=\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.Cookie, \"(.*)lang=([^;]*)(.*)\", \"\\2\"));\n } else {\n set req.http.X-Language = \"en\";\n }\n\n if (req.http.Cookie ~ \"prov=\") {\n set req.http.X-Province = std.tolower(regsuball(req.http.Cookie, \"(.*)prov=([^;]*)(.*)\", \"\\2\"));\n } else {\n set req.http.X-Province = \"BC\";\n }\n }\n\n if (req.url ~ \"\/(en|fr)\/\") {\n if (req.url ~ \"\/en\/\" && req.http.X-Language != \"en\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Language)\";\n return(pass);\n }\n if (req.url ~ \"\/fr\/\" && req.http.X-Language != \"fr\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Language)\";\n return(pass);\n }\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Language)\";\n return(pass);\n }\n\n if (req.url ~ \"\/(ab|bc|mb|nb|nl|ns|nt|nu|on|pe|qc|sk|yt)\/\") {\n {% for province in ['ab', 'bc', 'mb', 'nb', 'nl', 'ns', 'nt', 'nu', 'on', 'pe', 'qc', 'sk', 'yt'] %}\n if (req.url ~ \"\/{{ province }}\/\" && req.http.X-Province != \"{{ province }}\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Province)\";\n return(pass);\n }\n {% endfor %}\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Province)\";\n return(pass);\n }\n{% endif %}\n\n{% if varnish_blacklist_enabled %}\n if ((req.url ~ \"{{ varnish_blacklist_regexp }}\")) {\n set req.http.X-Passthrough-Reason = \"Path in Blacklist\";\n return(pass);\n } else {\n{% if varnish_discards_client_cookies %}\n unset req.http.Cookie;\n{% endif %}\n }\n{% endif %}\n\n}\n\n###\n# vcl_hit\n# Called when a cache lookup is successful.\n###\n# The vcl_hit subroutine may terminate with calling return() with one of the following keywords:\n#\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n# deliver\n# Deliver the object. Control passes to vcl_deliver.\n# synth(status code, reason)\n# Return the specified status code to the client and abandon the request.\n###\n\nsub vcl_hit {\n if (obj.ttl > 0s) {\n return (deliver);\n }\n{% if varnish_health_checks_enabled %}\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (fetch);\n }\n{% else %}\n if (obj.ttl + obj.grace > 0s) {\n return (deliver);\n }\n\n return (fetch);\n{% endif %}\n}\n\n###\n# vcl_backend_response\n# Called after the response headers has been successfully retrieved from the backend.\n###\n# The vcl_backend_response subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Possibly insert the object into the cache, then deliver it to the Control will eventually pass to vcl_deliver.\n# abandon\n# Abandon the backend request and generates an error.\n# retry\n# Retry the backend transaction. Increases the retries counter. If the number of retries is higher than max_retries Varnish emits a guru meditation error.\n###\n\nsub vcl_backend_response {\n{% if varnish_workaround_telusdotcom_browser_profile %}\n if (bereq.http.X-Language) {\n set beresp.http.X-Language = bereq.http.X-Language;\n }\n if (bereq.http.X-Province) {\n set beresp.http.X-Province = bereq.http.X-Province;\n }\n{% endif %}\n\n{% if varnish_blacklist_enabled %}\n if (bereq.url ~ \"{{ varnish_blacklist_regexp }}\") {\n set beresp.http.X-Cacheable = \"NO:Path in Blacklist\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n if (bereq.http.X-Passthrough-Reason) {\n set beresp.http.X-Passthrough-Reason = bereq.http.X-Passthrough-Reason;\n return(deliver);\n } else {\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n }\n }\n{% else %}\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n{% endif %}\n\n{% if varnish_cache_diagnostics_enabled %}\n if (bereq.http.Cookie) {\n set beresp.http.X-Cacheable = \"NO:Cookie in Request\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO:Set-Cookie in Response\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.X-No-Cache) {\n set beresp.http.X-Cacheable = \"NO:X-No-Cache\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.ttl <= 0s) {\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n{% endif %}\n\n set beresp.grace = {{ varnish_grace_period }};\n}\n\n###\n# vcl_deliver\n# Called before a cached object is delivered to the client.\n###\n# The vcl_deliver subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Deliver the object to the client.\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n###\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"de4d6bda22eda35d0074fe735477b3cab74b8f4f","subject":"use correct host value for backends","message":"use correct host value for backends\n","repos":"JakeChampion\/polyfill-service,JakeChampion\/polyfill-service","old_file":"fastly\/vcl\/polyfill-service.vcl","new_file":"fastly\/vcl\/polyfill-service.vcl","new_contents":"sub set_backend {\n\t# The Fastly macro is inserted before the backend is selected because the\n\t# macro has the code which defines the values avaiable for req.http.Host\n\t# but it also contains a default backend which is always set to the EU. I wish we could disable the default backend setting.\n\t#FASTLY recv\n\t\n\t# Calculate the ideal region to route the request to.\n \tdeclare local var.region STRING; \n\tif (server.region ~ \"(APAC|Asia|North-America|South-America|US-Central|US-East|US-West)\") {\n\t\tset var.region = \"US\";\n \t} else {\n\t\tset var.region = \"EU\";\n \t}\n\n\t# Gather the health of the shields and origins.\n\tdeclare local var.v3_eu_is_healthy BOOL;\n\tset req.backend = F_v3_eu;\n\tset var.v3_eu_is_healthy = req.backend.healthy;\n\n\tdeclare local var.v3_us_is_healthy BOOL;\n \tset req.backend = F_v3_us;\n \tset var.v3_us_is_healthy = req.backend.healthy;\n\n \tdeclare local var.shield_eu_is_healthy BOOL;\n \tset req.backend = ssl_shield_london_city_uk;\n \tset var.shield_eu_is_healthy = req.backend.healthy;\n\n \tdeclare local var.shield_us_is_healthy BOOL;\n \tset req.backend = ssl_shield_iad_va_us;\n \tset var.shield_us_is_healthy = req.backend.healthy;\n\n \t# Set some sort of default, that shouldn't get used.\n \tset req.backend = F_v3_eu;\n\n\t# Route EU requests to the nearest healthy shield or origin.\n \tif (var.region == \"EU\") {\n\t\tif (server.identity !~ \"-LCY$\" && req.http.Fastly-FF !~ \"-LCY\" && var.shield_eu_is_healthy) {\n\t\t\tset req.backend = ssl_shield_london_city_uk;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t\tset req.http.Host = req.http.EU_Host;\n\t\t} elseif (var.shield_us_is_healthy) {\n\t\t\tset req.backend = ssl_shield_iad_va_us;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t\tset req.http.Host = req.http.US_Host;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_eu;\n\t\t}\n \t}\n\n\t# Route US requests to the nearest healthy shield or origin.\n \tif (var.region == \"US\") {\n\t\tif (server.identity !~ \"-IAD$\" && req.http.Fastly-FF !~ \"-IAD\" && var.shield_us_is_healthy) {\n\t\t\tset req.backend = ssl_shield_iad_va_us;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t\tset req.http.Host = req.http.US_Host;\n\t\t} elseif (var.shield_eu_is_healthy) {\n\t\t\tset req.backend = ssl_shield_london_city_uk;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t\tset req.http.Host = req.http.EU_Host;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_us;\n\t\t}\n\t}\n\n\t# Persist the decision so we can debug the result.\n \tset req.http.Debug-Backend = req.backend;\n}\n\nsub vcl_recv {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_recv;\n\t}\n\n\tif (req.method != \"GET\" && req.method != \"HEAD\" && req.method != \"OPTIONS\" && req.method != \"FASTLYPURGE\" && req.method != \"PURGE\") {\n\t\terror 911;\n\t}\n\n\tif (req.method == \"OPTIONS\") {\n\t\terror 912;\n\t}\n\n\t# Because the old service had a router which allowed any words between \/v2\/polyfill. and .js\n\tif (req.url.path ~ \"^\/v2\/polyfill(\\.\\w+)(\\.\\w+)?\" && req.url.ext == \"js\") {\n\t\tif (re.group.2) {\n\t\t\tset req.url = \"\/v2\/polyfill.min.js?\" req.url.qs;\n\t\t} else {\n\t\t\tset req.url = \"\/v2\/polyfill.js?\" req.url.qs;\n\t\t}\n\t}\n\n\t# Override the v3 defaults with the defaults of v2\n\tif (req.url ~ \"^\/v2\/polyfill(\\.min)?\\.js\") {\n\t\tset req.url = regsub(req.url, \"^\/v2\", \"\/v3\");\n\t\tset req.url = querystring.set(req.url, \"version\", \"3.25.1\");\n\t\tdeclare local var.unknown STRING;\n\t\tset var.unknown = subfield(req.url.qs, \"unknown\", \"&\");\n\t\tset req.url = querystring.set(req.url, \"unknown\", if(var.unknown != \"\", var.unknown, \"ignore\"));\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\") {\n\t\tif (!req.http.Fastly-FF) {\n\t\t\tcall normalise_querystring_parameters_for_polyfill_bundle;\n\t\t\t# Sort the querystring parameters alphabetically to improve chances of hitting a cached copy.\n\t\t\t# If querystring is empty, remove the ? from the url.\n\t\t\tset req.url = querystring.clean(querystring.sort(req.url));\n\t\t}\n\t\tcall set_backend;\n\t} else {\n\t\t# The request is to an endpoint which doesn't use query parameters, let's remove them to increase our cache-hit-ratio\n\t\tset req.url = querystring.remove(req.url);\n\t\tcall set_backend;\n\t}\n}\n\nsub vcl_hash {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_hash;\n\t}\n\n\t# We are not adding req.http.host to the hash because we want https:\/\/cdn.polyfill.io and https:\/\/polyfill.io to be a single object in the cache.\n\t# set req.hash += req.http.host;\n\tset req.hash += req.url;\n\t# We include return(hash) to stop the function falling through to the default VCL built into varnish, which for vcl_hash will add req.url and req.http.Host to the hash.\n\treturn(hash);\n}\n\nsub vcl_miss {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_miss;\n\t}\n}\n\nsub vcl_pass {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_pass;\n\t}\n}\n\nsub vcl_fetch {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_fetch;\n\t}\n\n\t# These header are only required for HTML documents.\n\tif (beresp.http.Content-Type ~ \"text\/html\") {\n\t\t# Enables the cross-site scripting filter built into most modern web browsers.\n\t\tset beresp.http.X-XSS-Protection = \"1; mode=block\";\t\n\t}\n\t# Prevents MIME-sniffing a response away from the declared content type.\n\tset beresp.http.X-Content-Type-Options = \"nosniff\";\n\n\t# Ensure the site is only served over HTTPS and reduce the chances of someone performing a MITM attack.\n\tset beresp.http.Strict-Transport-Security = \"max-age=31536000; includeSubdomains; preload\";\n\n\t# The Referrer-Policy header governs which referrer information, sent in the Referer header, should be included with requests made.\n\t# Send a full URL when performing a same-origin request, but only send the origin of the document for other cases.\n\tset beresp.http.Referrer-Policy = \"origin-when-cross-origin\";\n\n\t# Enable purging of all objects in the Fastly cache by issuing a purge with the key \"polyfill-service\".\n\tif (beresp.http.Surrogate-Key !~ \"\\bpolyfill-service\\b\") {\n\t\tset beresp.http.Surrogate-Key = if(beresp.http.Surrogate-Key, beresp.http.Surrogate-Key \" polyfill-service\", \"polyfill-service\");\n\t}\n\n\tset beresp.http.Timing-Allow-Origin = \"*\";\n\n\tif (req.http.Normalized-User-Agent) {\n\t\tset beresp.http.Normalized-User-Agent = req.http.Normalized-User-Agent;\n\t\tset beresp.http.Detected-User-Agent = req.http.useragent_parser_family \"\/\" req.http.useragent_parser_major \".\" req.http.useragent_parser_minor \".\" req.http.useragent_parser_patch;\n\t}\n}\n\nsub vcl_deliver {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_deliver;\n\t}\n\n\tset req.http.Fastly-Force-Shield = \"yes\";\n\n\t# Allow cross origin GET, HEAD, and OPTIONS requests to be made.\n\tif (req.http.Origin) {\n\t\tset resp.http.Access-Control-Allow-Origin = \"*\";\n\t\tset resp.http.Access-Control-Allow-Methods = \"GET,HEAD,OPTIONS\";\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\" && !req.http.Fastly-FF) {\n\t\t# Need to add \"Vary: User-Agent\" in after vcl_fetch to avoid the \n\t\t# \"Vary: User-Agent\" entering the Varnish cache.\n\t\t# We need \"Vary: User-Agent\" in the browser cache because a browser\n\t\t# may update itself to a version which needs different polyfills\n\t\t# So we need to have it ignore the browser cached bundle when the user-agent changes.\n\t\tadd resp.http.Vary = \"User-Agent\";\n\t\tadd resp.http.Vary = \"Accept-Encoding\";\n\t}\n\n\tadd resp.http.Server-Timing = fastly_info.state {\", fastly;desc=\"Edge time\";dur=\"} time.elapsed.msec;\n\n\tif (req.http.Fastly-Debug) {\n\t\tset resp.http.Debug-Backend = req.http.Debug-Backend;\n\t\tset resp.http.Debug-Host = req.http.Host;\n\t\tset resp.http.Debug-Fastly-Restarts = req.restarts;\n\t\tset resp.http.Debug-Orig-URL = req.http.Orig-URL;\n\t\tset resp.http.Debug-VCL-Route = req.http.X-VCL-Route;\n\t\tset resp.http.useragent_parser_family = req.http.useragent_parser_family;\n\t\tset resp.http.useragent_parser_major = req.http.useragent_parser_major;\n\t\tset resp.http.useragent_parser_minor = req.http.useragent_parser_minor;\n\t\tset resp.http.useragent_parser_patch = req.http.useragent_parser_patch;\n\t} else {\n\t\tunset resp.http.Server;\n\t\tunset resp.http.Via;\n\t\tunset resp.http.X-Cache;\n\t\tunset resp.http.X-Cache-Hits;\n\t\tunset resp.http.X-Served-By;\n\t\tunset resp.http.X-Timer;\n\t\tunset resp.http.Fastly-Restarts;\n\t}\n}\n\nsub vcl_error {\n\tif (obj.status == 911) {\n\t\tset obj.status = 405;\n\t\tset obj.response = \"METHOD NOT ALLOWED\";\n\t\tset obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n\t\tset obj.http.Cache-Control = \"private, no-store\";\n\t\tsynthetic req.method \" METHOD NOT ALLOWED\";\n\t\treturn (deliver);\n\t}\n\tif (obj.status == 912) {\n\t\tset obj.status = 200;\n\t\tset obj.response = \"OK\";\n\t\tset obj.http.Allow = \"OPTIONS, GET, HEAD\";\n\t\treturn (deliver);\n\t}\n}\n","old_contents":"sub set_backend {\n\t# The Fastly macro is inserted before the backend is selected because the\n\t# macro has the code which defines the values avaiable for req.http.Host\n\t# but it also contains a default backend which is always set to the EU. I wish we could disable the default backend setting.\n\t#FASTLY recv\n\t\n\t# Calculate the ideal region to route the request to.\n \tdeclare local var.region STRING; \n\tif (server.region ~ \"(APAC|Asia|North-America|South-America|US-Central|US-East|US-West)\") {\n\t\tset var.region = \"US\";\n \t} else {\n\t\tset var.region = \"EU\";\n \t}\n\n\t# Gather the health of the shields and origins.\n\tdeclare local var.v3_eu_is_healthy BOOL;\n\tset req.backend = F_v3_eu;\n\tset var.v3_eu_is_healthy = req.backend.healthy;\n\n\tdeclare local var.v3_us_is_healthy BOOL;\n \tset req.backend = F_v3_us;\n \tset var.v3_us_is_healthy = req.backend.healthy;\n\n \tdeclare local var.shield_eu_is_healthy BOOL;\n \tset req.backend = ssl_shield_london_city_uk;\n \tset var.shield_eu_is_healthy = req.backend.healthy;\n\n \tdeclare local var.shield_us_is_healthy BOOL;\n \tset req.backend = ssl_shield_iad_va_us;\n \tset var.shield_us_is_healthy = req.backend.healthy;\n\n \t# Set some sort of default, that shouldn't get used.\n \tset req.backend = F_v3_eu;\n\n\t# Route EU requests to the nearest healthy shield or origin.\n \tif (var.region == \"EU\") {\n\t\tif (server.identity !~ \"-LCY$\" && req.http.Fastly-FF !~ \"-LCY\" && var.shield_eu_is_healthy) {\n\t\t\tset req.backend = ssl_shield_london_city_uk;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} elseif (var.shield_us_is_healthy) {\n\t\t\tset req.backend = ssl_shield_iad_va_us;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_eu;\n\t\t}\n \t}\n\n\t# Route US requests to the nearest healthy shield or origin.\n \tif (var.region == \"US\") {\n\t\tif (server.identity !~ \"-IAD$\" && req.http.Fastly-FF !~ \"-IAD\" && var.shield_us_is_healthy) {\n\t\t\tset req.backend = ssl_shield_iad_va_us;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} elseif (var.shield_eu_is_healthy) {\n\t\t\tset req.backend = ssl_shield_london_city_uk;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_us;\n\t\t}\n\t}\n\n\t# Persist the decision so we can debug the result.\n \tset req.http.Debug-Backend = req.backend;\n}\n\nsub vcl_recv {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_recv;\n\t}\n\n\tif (req.method != \"GET\" && req.method != \"HEAD\" && req.method != \"OPTIONS\" && req.method != \"FASTLYPURGE\" && req.method != \"PURGE\") {\n\t\terror 911;\n\t}\n\n\tif (req.method == \"OPTIONS\") {\n\t\terror 912;\n\t}\n\n\t# Because the old service had a router which allowed any words between \/v2\/polyfill. and .js\n\tif (req.url.path ~ \"^\/v2\/polyfill(\\.\\w+)(\\.\\w+)?\" && req.url.ext == \"js\") {\n\t\tif (re.group.2) {\n\t\t\tset req.url = \"\/v2\/polyfill.min.js?\" req.url.qs;\n\t\t} else {\n\t\t\tset req.url = \"\/v2\/polyfill.js?\" req.url.qs;\n\t\t}\n\t}\n\n\t# Override the v3 defaults with the defaults of v2\n\tif (req.url ~ \"^\/v2\/polyfill(\\.min)?\\.js\") {\n\t\tset req.url = regsub(req.url, \"^\/v2\", \"\/v3\");\n\t\tset req.url = querystring.set(req.url, \"version\", \"3.25.1\");\n\t\tdeclare local var.unknown STRING;\n\t\tset var.unknown = subfield(req.url.qs, \"unknown\", \"&\");\n\t\tset req.url = querystring.set(req.url, \"unknown\", if(var.unknown != \"\", var.unknown, \"ignore\"));\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\") {\n\t\tif (!req.http.Fastly-FF) {\n\t\t\tcall normalise_querystring_parameters_for_polyfill_bundle;\n\t\t\t# Sort the querystring parameters alphabetically to improve chances of hitting a cached copy.\n\t\t\t# If querystring is empty, remove the ? from the url.\n\t\t\tset req.url = querystring.clean(querystring.sort(req.url));\n\t\t}\n\t\tcall set_backend;\n\t} else {\n\t\t# The request is to an endpoint which doesn't use query parameters, let's remove them to increase our cache-hit-ratio\n\t\tset req.url = querystring.remove(req.url);\n\t\tcall set_backend;\n\t}\n}\n\nsub vcl_hash {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_hash;\n\t}\n\n\t# We are not adding req.http.host to the hash because we want https:\/\/cdn.polyfill.io and https:\/\/polyfill.io to be a single object in the cache.\n\t# set req.hash += req.http.host;\n\tset req.hash += req.url;\n\t# We include return(hash) to stop the function falling through to the default VCL built into varnish, which for vcl_hash will add req.url and req.http.Host to the hash.\n\treturn(hash);\n}\n\nsub vcl_miss {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_miss;\n\t}\n}\n\nsub vcl_pass {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_pass;\n\t}\n}\n\nsub vcl_fetch {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_fetch;\n\t}\n\n\t# These header are only required for HTML documents.\n\tif (beresp.http.Content-Type ~ \"text\/html\") {\n\t\t# Enables the cross-site scripting filter built into most modern web browsers.\n\t\tset beresp.http.X-XSS-Protection = \"1; mode=block\";\t\n\t}\n\t# Prevents MIME-sniffing a response away from the declared content type.\n\tset beresp.http.X-Content-Type-Options = \"nosniff\";\n\n\t# Ensure the site is only served over HTTPS and reduce the chances of someone performing a MITM attack.\n\tset beresp.http.Strict-Transport-Security = \"max-age=31536000; includeSubdomains; preload\";\n\n\t# The Referrer-Policy header governs which referrer information, sent in the Referer header, should be included with requests made.\n\t# Send a full URL when performing a same-origin request, but only send the origin of the document for other cases.\n\tset beresp.http.Referrer-Policy = \"origin-when-cross-origin\";\n\n\t# Enable purging of all objects in the Fastly cache by issuing a purge with the key \"polyfill-service\".\n\tif (beresp.http.Surrogate-Key !~ \"\\bpolyfill-service\\b\") {\n\t\tset beresp.http.Surrogate-Key = if(beresp.http.Surrogate-Key, beresp.http.Surrogate-Key \" polyfill-service\", \"polyfill-service\");\n\t}\n\n\tset beresp.http.Timing-Allow-Origin = \"*\";\n\n\tif (req.http.Normalized-User-Agent) {\n\t\tset beresp.http.Normalized-User-Agent = req.http.Normalized-User-Agent;\n\t\tset beresp.http.Detected-User-Agent = req.http.useragent_parser_family \"\/\" req.http.useragent_parser_major \".\" req.http.useragent_parser_minor \".\" req.http.useragent_parser_patch;\n\t}\n}\n\nsub vcl_deliver {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_deliver;\n\t}\n\n\tset req.http.Fastly-Force-Shield = \"yes\";\n\n\t# Allow cross origin GET, HEAD, and OPTIONS requests to be made.\n\tif (req.http.Origin) {\n\t\tset resp.http.Access-Control-Allow-Origin = \"*\";\n\t\tset resp.http.Access-Control-Allow-Methods = \"GET,HEAD,OPTIONS\";\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\" && !req.http.Fastly-FF) {\n\t\t# Need to add \"Vary: User-Agent\" in after vcl_fetch to avoid the \n\t\t# \"Vary: User-Agent\" entering the Varnish cache.\n\t\t# We need \"Vary: User-Agent\" in the browser cache because a browser\n\t\t# may update itself to a version which needs different polyfills\n\t\t# So we need to have it ignore the browser cached bundle when the user-agent changes.\n\t\tadd resp.http.Vary = \"User-Agent\";\n\t\tadd resp.http.Vary = \"Accept-Encoding\";\n\t}\n\n\tadd resp.http.Server-Timing = fastly_info.state {\", fastly;desc=\"Edge time\";dur=\"} time.elapsed.msec;\n\n\tif (req.http.Fastly-Debug) {\n\t\tset resp.http.Debug-Backend = req.http.Debug-Backend;\n\t\tset resp.http.Debug-Host = req.http.Host;\n\t\tset resp.http.Debug-Fastly-Restarts = req.restarts;\n\t\tset resp.http.Debug-Orig-URL = req.http.Orig-URL;\n\t\tset resp.http.Debug-VCL-Route = req.http.X-VCL-Route;\n\t\tset resp.http.useragent_parser_family = req.http.useragent_parser_family;\n\t\tset resp.http.useragent_parser_major = req.http.useragent_parser_major;\n\t\tset resp.http.useragent_parser_minor = req.http.useragent_parser_minor;\n\t\tset resp.http.useragent_parser_patch = req.http.useragent_parser_patch;\n\t} else {\n\t\tunset resp.http.Server;\n\t\tunset resp.http.Via;\n\t\tunset resp.http.X-Cache;\n\t\tunset resp.http.X-Cache-Hits;\n\t\tunset resp.http.X-Served-By;\n\t\tunset resp.http.X-Timer;\n\t\tunset resp.http.Fastly-Restarts;\n\t}\n}\n\nsub vcl_error {\n\tif (obj.status == 911) {\n\t\tset obj.status = 405;\n\t\tset obj.response = \"METHOD NOT ALLOWED\";\n\t\tset obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n\t\tset obj.http.Cache-Control = \"private, no-store\";\n\t\tsynthetic req.method \" METHOD NOT ALLOWED\";\n\t\treturn (deliver);\n\t}\n\tif (obj.status == 912) {\n\t\tset obj.status = 200;\n\t\tset obj.response = \"OK\";\n\t\tset obj.http.Allow = \"OPTIONS, GET, HEAD\";\n\t\treturn (deliver);\n\t}\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"15868789a2e344996a2ea4d7deb7c33a0f83a580","subject":"messing with web sockets","message":"messing with web sockets\n","repos":"derbyjs\/candygram","old_file":"varnish_default.vcl","new_file":"varnish_default.vcl","new_contents":"# This is a basic VCL configuration file for varnish. See the vcl(7)\n# man page for details on VCL syntax and semantics.\n\nimport std;\n\n# static\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"4000\";\n}\nbackend examples {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\nbackend components {\n .host = \"127.0.0.1\";\n .port = \"3330\";\n}\n\nsub vcl_recv {\n if (!req.http.Host) {\n error 404 \"Need a host header\";\n }\n\n set req.http.Host = regsub(req.http.Host, \"^www\\.\", \"\");\n set req.http.Host = regsub(req.http.Host, \":80$\", \"\");\n\n if (req.restarts == 0) {\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For =\n req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n if (\n req.http.Host ~ \"^chat\\.\" ||\n req.http.Host ~ \"^charts\\.\" ||\n req.http.Host ~ \"^directory\\.\" ||\n req.http.Host ~ \"^codemirror\\.\" ||\n req.http.Host ~ \"^hello\\.\" ||\n req.http.Host ~ \"^sink\\.\" ||\n req.http.Host ~ \"^todos\\.\" ||\n req.http.Host ~ \"^widgets\\.\"\n ) {\n set req.backend = examples;\n } else if (req.http.Host ~ \"^components\\.\") {\n set req.backend = components;\n }\n\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization || req.http.Cookie) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n return (lookup);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n if (req.http.Origin) {\n hash_data(req.http.Origin);\n }\n return (hash);\n}\n\nsub vcl_pipe {\n # Websockets\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n}\n\nsub vcl_fetch {\n # Compress responses\n if (beresp.http.content-type ~ \"text\"\n || beresp.http.content-type ~ \"json\"\n || beresp.http.content-type ~ \"javascript\") {\n set beresp.do_gzip = true;\n }\n}\n\nsub vcl_error {\n if (obj.status == 750) {\n # moved permanently\n set obj.http.Location = req.http.Location;\n set obj.status = 301;\n } else if (obj.status == 752) {\n # moved temporarily\n set obj.http.Location = req.http.Location;\n set obj.status = 302;\n } else {\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic std.fileread(\"\/etc\/varnish\/503.html\");\n }\n return (deliver);\n}\n","old_contents":"# This is a basic VCL configuration file for varnish. See the vcl(7)\n# man page for details on VCL syntax and semantics.\n\nimport std;\n\n# static\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"4000\";\n}\nbackend examples {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\nbackend components {\n .host = \"127.0.0.1\";\n .port = \"3330\";\n}\n\nsub vcl_recv {\n if (!req.http.Host) {\n error 404 \"Need a host header\";\n }\n\n set req.http.Host = regsub(req.http.Host, \"^www\\.\", \"\");\n set req.http.Host = regsub(req.http.Host, \":80$\", \"\");\n\n if (req.restarts == 0) {\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For =\n req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n if (\n req.http.Host ~ \"^chat\\.\" ||\n req.http.Host ~ \"^charts\\.\" ||\n req.http.Host ~ \"^directory\\.\" ||\n req.http.Host ~ \"^codemirror\\.\" ||\n req.http.Host ~ \"^hello\\.\" ||\n req.http.Host ~ \"^sink\\.\" ||\n req.http.Host ~ \"^todos\\.\" ||\n req.http.Host ~ \"^widgets\\.\"\n ) {\n set req.backend = examples;\n } else if (req.http.Host ~ \"^components\\.\") {\n set req.backend = components;\n }\n\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization || req.http.Cookie) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n return (lookup);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n if (req.http.Origin) {\n hash_data(req.http.Origin);\n }\n return (hash);\n}\n\nsub vcl_pipe {\n # Websockets\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n } else {\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n set bereq.http.connection = \"close\";\n # here. It is not set by default as it might break some broken web\n # applications, like IIS with NTLM authentication.\n }\n\n return (pipe);\n}\n\nsub vcl_fetch {\n # Compress responses\n if (beresp.http.content-type ~ \"text\"\n || beresp.http.content-type ~ \"json\"\n || beresp.http.content-type ~ \"javascript\") {\n set beresp.do_gzip = true;\n }\n}\n\nsub vcl_error {\n if (obj.status == 750) {\n # moved permanently\n set obj.http.Location = req.http.Location;\n set obj.status = 301;\n } else if (obj.status == 752) {\n # moved temporarily\n set obj.http.Location = req.http.Location;\n set obj.status = 302;\n } else {\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic std.fileread(\"\/etc\/varnish\/503.html\");\n }\n return (deliver);\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"966d0b6f378de0c9acbcb473db831f1c9faa5705","subject":"Move the override handling to the top.","message":"Move the override handling to the top.\n\nIn cases where the override function is used for actual users, not just\ntesting\/overriding, it makes sense to not run the regular expressions.\n\nReported by: Sergey Syrota\n","repos":"wikp\/varnish-devicedetect,varnish\/varnish-devicedetect,varnish\/varnish-devicedetect,wikp\/varnish-devicedetect,kevinquinnyo\/varnish-devicedetect,kevinquinnyo\/varnish-devicedetect","old_file":"devicedetect.vcl","new_file":"devicedetect.vcl","new_contents":"#\n# detectdevice.vcl - regex based device detection for Varnish\n# http:\/\/github.com\/varnish\/varnish-devicedetect\/\n#\n# Author: Lasse Karstensen <lasse@varnish-software.com>\n\nsub devicedetect {\n\tunset req.http.X-UA-Device;\n\tset req.http.X-UA-Device = \"pc\";\n\n\t# Handle that a cookie may override the detection alltogether.\n\tif (req.http.Cookie ~ \"(?i)X-UA-Device-force\") {\n\t\t\/* ;?? means zero or one ;, non-greedy to match the first. *\/\n\t\tset req.http.X-UA-Device = regsub(req.http.Cookie, \"(?i).*X-UA-Device-force=([^;]+);??.*\", \"\\1\");\n\t\t\/* Clean up our mess in the cookie header *\/\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|; ) *X-UA-Device-force=[^;]+;? *\", \"\\1\");\n\t\t\/* If the cookie header is now empty, or just whitespace, unset it. *\/\n\t\tif (req.http.Cookie ~ \"^ *$\") { unset req.http.Cookie; }\n\t} else {\n\t\tif (req.http.User-Agent ~ \"(?i)(ads|google|bing|msn|yandex|baidu|ro|career|)bot\" ||\n\t\t req.http.User-Agent ~ \"(?i)(baidu|jike|symantec)spider\" ||\n\t\t req.http.User-Agent ~ \"(?i)scanner\" ||\n\t\t req.http.User-Agent ~ \"(?i)(web)crawler\") {\n\t\t\tset req.http.X-UA-Device = \"bot\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ip(hone|od)\") { set req.http.X-UA-Device = \"mobile-iphone\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ipad\") { set req.http.X-UA-Device = \"tablet-ipad\"; }\n\t\t\/* how do we differ between an android phone and an android tablet?\n\t\t http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent *\/\n\t\telsif (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") { set req.http.X-UA-Device = \"mobile-android\"; }\n\t\t\/\/ android 3\/honeycomb was just about tablet-only, and any phones will probably handle a bigger page layout.\n\t\telsif (req.http.User-Agent ~ \"(?i)android 3\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\t\/\/ May very well give false positives towards android tablets. Suggestions welcome.\n\t\telsif (req.http.User-Agent ~ \"(?i)android\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\telsif (req.http.User-Agent ~ \"^HTC\" ||\n\t\t req.http.User-Agent ~ \"Fennec\" ||\n\t\t req.http.User-Agent ~ \"IEMobile\" ||\n\t\t req.http.User-Agent ~ \"BlackBerry\" ||\n\t\t req.http.User-Agent ~ \"SymbianOS.*AppleWebKit\" ||\n\t\t req.http.User-Agent ~ \"Opera Mobi\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-smartphone\";\n\t\t}\n\t\telsif (req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)^sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)^nokia\" ||\n\t\t req.http.User-Agent ~ \"(?i)^samsung\" ||\n\t\t req.http.User-Agent ~ \"(?i)^lg\" ||\n\t\t req.http.User-Agent ~ \"(?i)bada\" ||\n\t\t req.http.User-Agent ~ \"(?i)blazer\" ||\n\t\t req.http.User-Agent ~ \"(?i)cellphone\" ||\n\t\t req.http.User-Agent ~ \"(?i)iemobile\" ||\n\t\t req.http.User-Agent ~ \"(?i)midp-2.0\" ||\n\t\t req.http.User-Agent ~ \"(?i)u990\" ||\n\t\t req.http.User-Agent ~ \"(?i)netfront\" ||\n\t\t req.http.User-Agent ~ \"(?i)opera mini\" ||\n\t\t req.http.User-Agent ~ \"(?i)palm\" ||\n\t\t req.http.User-Agent ~ \"(?i)nintendo wii\" ||\n\t\t req.http.User-Agent ~ \"(?i)playstation portable\" ||\n\t\t req.http.User-Agent ~ \"(?i)portalmmm\" ||\n\t\t req.http.User-Agent ~ \"(?i)proxinet\" ||\n\t\t req.http.User-Agent ~ \"(?i)sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)windows\\ ?ce\" ||\n\t\t req.http.User-Agent ~ \"(?i)winwap\" ||\n\t\t req.http.User-Agent ~ \"(?i)eudoraweb\" ||\n\t\t req.http.User-Agent ~ \"(?i)htc\" ||\n\t\t req.http.User-Agent ~ \"(?i)240x320\" ||\n\t\t req.http.User-Agent ~ \"(?i)avantgo\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-generic\";\n\t\t}\n\t}\n}\n\n","old_contents":"#\n# detectdevice.vcl - regex based device detection for Varnish\n# http:\/\/github.com\/varnish\/varnish-devicedetect\/\n#\n# Author: Lasse Karstensen <lasse@varnish-software.com>\n\nsub devicedetect {\n\tunset req.http.X-UA-Device;\n\tset req.http.X-UA-Device = \"pc\";\n\n \tif (req.http.User-Agent ~ \"(?i)(ads|google|bing|msn|yandex|baidu|ro|career|)bot\" ||\n\t req.http.User-Agent ~ \"(?i)(baidu|jike|symantec)spider\" ||\n\t req.http.User-Agent ~ \"(?i)scanner\" ||\n\t req.http.User-Agent ~ \"(?i)(web)crawler\") {\n\t\tset req.http.X-UA-Device = \"bot\"; }\n\telsif (req.http.User-Agent ~ \"(?i)ip(hone|od)\") { set req.http.X-UA-Device = \"mobile-iphone\"; }\n\telsif (req.http.User-Agent ~ \"(?i)ipad\") { set req.http.X-UA-Device = \"tablet-ipad\"; }\n\t# how do we differ between an android phone and an android tablet?\n\t# http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent\n\telsif (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") { set req.http.X-UA-Device = \"mobile-android\"; }\n\t# android 3\/honeycomb was just about tablet-only, and any phones will probably handle a bigger page layout.\n\telsif (req.http.User-Agent ~ \"(?i)android 3\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t# may very well give false positives towards android tablets. Suggestions welcome.\n\telsif (req.http.User-Agent ~ \"(?i)android\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\telsif (req.http.User-Agent ~ \"^HTC\" ||\n\t req.http.User-Agent ~ \"Fennec\" ||\n\t req.http.User-Agent ~ \"IEMobile\" ||\n\t req.http.User-Agent ~ \"BlackBerry\" ||\n\t req.http.User-Agent ~ \"SymbianOS.*AppleWebKit\" ||\n\t req.http.User-Agent ~ \"Opera Mobi\") {\n\t\tset req.http.X-UA-Device = \"mobile-smartphone\";\n\t}\n\telsif (req.http.User-Agent ~ \"(?i)symbian\" ||\n\t req.http.User-Agent ~ \"(?i)^sonyericsson\" ||\n\t req.http.User-Agent ~ \"(?i)^nokia\" ||\n\t req.http.User-Agent ~ \"(?i)^samsung\" ||\n\t req.http.User-Agent ~ \"(?i)^lg\" ||\n\t req.http.User-Agent ~ \"(?i)bada\" ||\n\t req.http.User-Agent ~ \"(?i)blazer\" ||\n\t req.http.User-Agent ~ \"(?i)cellphone\" ||\n\t req.http.User-Agent ~ \"(?i)iemobile\" ||\n\t req.http.User-Agent ~ \"(?i)midp-2.0\" ||\n\t req.http.User-Agent ~ \"(?i)u990\" ||\n\t req.http.User-Agent ~ \"(?i)netfront\" ||\n\t req.http.User-Agent ~ \"(?i)opera mini\" ||\n\t req.http.User-Agent ~ \"(?i)palm\" ||\n\t req.http.User-Agent ~ \"(?i)nintendo wii\" ||\n\t req.http.User-Agent ~ \"(?i)playstation portable\" ||\n\t req.http.User-Agent ~ \"(?i)portalmmm\" ||\n\t req.http.User-Agent ~ \"(?i)proxinet\" ||\n\t req.http.User-Agent ~ \"(?i)sonyericsson\" ||\n\t req.http.User-Agent ~ \"(?i)symbian\" ||\n\t req.http.User-Agent ~ \"(?i)windows\\ ?ce\" ||\n\t req.http.User-Agent ~ \"(?i)winwap\" ||\n\t req.http.User-Agent ~ \"(?i)eudoraweb\" ||\n\t req.http.User-Agent ~ \"(?i)htc\" ||\n\t req.http.User-Agent ~ \"(?i)240x320\" ||\n\t req.http.User-Agent ~ \"(?i)avantgo\") {\n \tset req.http.X-UA-Device = \"mobile-generic\";\n\t}\n\t# handle overrides\n\tif (req.http.Cookie ~ \"(i?)X-UA-Device-force\") {\n\t\t# ;?? means zero or one ;, non-greedy to match the first.\n\t\tset req.http.X-UA-Device = regsub(req.http.Cookie, \"(?i).*X-UA-Device-force=([^;]+);??.*\", \"\\1\");\n\t\t# Clean up the cookie header to allow for caching.\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|; ) *X-UA-Device-force=[^;]+;? *\", \"\\1\");\n\t\tif (req.http.Cookie ~ \"^ *$\") { unset req.http.Cookie; }\n\t}\n}\n\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"5fe8262022be2027e7ec9489e8fb204af6df4013","subject":"added, fixed commands","message":"added, fixed commands\n","repos":"aschneiderman\/vim-voice","old_file":"gvim.vcl","new_file":"gvim.vcl","new_contents":"# Voice commands for gvim\r\n\r\ninclude folders.vch;\r\ninclude numbers.vch;\r\ninclude letters.vch;\r\ninclude pandas.vch;\r\n\r\nEdit [My] Configuration = ':e $' 'MYVIMRC' {Enter};\r\n\r\n<delimiters> := (Quotes = '\"' | 'Single Quotes' = \"'\" | 'Double Quotes' = '\"' | Parentheses = '(' \r\n\t\t| Brackets = '[' | 'Curly Braces' = '{' | Braces = '{'\r\n\t\t| HTML = '<' | 'Close HTML' = '>' | 'Close Tag' = '>'\t# NOTE: only works with commands I created\r\n\t\t| 'Equal Sign' = '='\r\n);\r\n\r\n# --- File Management ---------------\r\nOpen Document = {Alt+f} o;\r\nList Files = {Esc} ':bro ol' {Enter};\r\nFile <numbers> = $1 {Enter};\r\nLatest File = {Esc} ':bro ol' {Enter} 1{Enter};\r\n\r\nShow (Projects | Folders) = {Esc}':e C:\\Voice\\folders.vch' {Enter} Wait(100) {Down_9};\r\n[Open] Project <folder> = {Esc} ':e ' $1 {Enter} Wait(100) {Down_9};\r\n[Open] Current Project = {Esc} ':e .' {Enter} Wait(100) {Down_9};\r\nUp Directory = '-';\r\nSearch [Directory] <letters> = '\/^' $1;\r\n# :Sex = directory of current file \r\n# :Vex for vertical split\r\n# :sp. = Split horizontally on current directory (:vsp. For vertical)\r\n# % = new file\r\n\r\n(List Buffers = 'ls' | Buffer List = 'ls' | 'Next Buffer' = 'bn' | 'Last Buffer' = 'bp' | 'Close Buffer' = 'bd'\r\n\t| 'Next Window' = 'bn' | 'Last Window' = 'bp' | 'Close Window' = 'bd') \r\n\t= {Esc}':' $1 {Enter};\r\n\r\n\r\nSave Document = {Esc} Wait(100) ':w' {Enter};\r\nSave As = {Alt+f} a;\r\nGo (Quit = 'quit' | Close = 'close' | 'Close without saving' = 'close!' | Set = 'set') = ':' $1 {Enter};\r\n[Go] Quit without Saving = {Esc} Wait(100) ':quit!' {Enter};\r\n\r\nSave and Reload = {Esc} Wait(100) ':w' {Enter} Wait(100) SendSystemKeys({Alt+Tab}) Wait(100) {Ctrl+r};\r\n\r\n\r\n# --- Basic Navigation ---------------\r\n<numbers> (Up = 'k' | Down = 'j' | Right = 'l' | Left = 'h') = $1 $2;\r\nHoma = {Esc} 0;\r\nEnda = {Esc} '$';\r\n(Top | Go to Top) = {Esc} gg;\r\n(Bottom | Go to Bottom) = {Esc} G;\r\n(Move Forward | Move Right | Go Forward) <numbers> (words = 'w' | blocks = '}') = $2 $3;\r\n(Move Forward | Move Right | Go Forward) <numbers> (end | enda) words = $2 'e';\r\n(Move Back | Move Left | Go Back) <numbers> (words = 'b' | blocks = '{') = $2 $3;\r\nFine (Text | Alpha) <letters> = {Esc} f $2;\r\nFind Back <letters> = {Esc} F $1;\r\nFine Number 1..9 = {Esc} '\/' $1 {Enter};\r\nGo (Search | Find) = {Esc} '\/\\c'; # \\c = case insensitive\r\nFine <delimiters> = {Esc} '\/' $1 {Enter};\r\nInsert (Before = 'i' | After = 'a') <delimiters> = {Esc} '\/' $2 {Enter} Wait(100) $1;\r\nFine Tag = {Esc} '\/' '<' {Enter};\r\nInsert (Before = 'i' | After = 'a') tag = {Esc} '\/' '<' {Enter} Wait(100) $1;\r\n\r\n\r\n(Find Again | Next Fine | Next Find) = n;\r\nLine 1..100 = {Esc} ':' $1 {Enter};\r\n\r\n\r\n# --- Basic Editing ---------------\r\n(Do | Go) (Insert = 'i' | Append = 'A' | \rEscape = '{Esc}') = $2;\r\n(Insert = 'i' | \rEscape = '{Esc}') = $1;\r\nNexta = {Esc} A {Enter};\r\nEnda Insert = {Esc} A;\r\n\r\n(Do Again | Repeat That) = '.';\r\n(Undo | Undo That) = {Esc} u;\r\nRedo = {Esc} {Ctrl+r};\r\n\r\n(Kill = 'x') <numbers> = $2 $1;\r\n(Kill | Delete) Word = 'dw';\r\n(Kill | Delete) <numbers> Words = 'd' $2 'w';\r\nDee Dee = 'dd';\r\nCut to End of Line = 'd$';\r\nCut to End of Word = 'de';\r\n\r\n('Go Visual' | Mark | 'Visual Mode') = V;\r\n('Delete That' = 'd' | 'Yank That' = 'y' | 'Paste' = 'p' | 'Change That' = 'c' | 'Join That' = 'J') = $1;\r\nPaste That = {Esc} Wait(100) '\"+gP';\r\nCopy That = '\"*y';\r\nCopy Line = {Esc} V Wait(100) '\"*y';\r\nSelect Line = {Esc} V;\r\n\r\ndo test = {Esc} i Wait(100) \"strawberry\";\r\n\r\n(Delete= 'd' | Change = 'c') Between Tags = $1 i t;\r\n(Delete= 'd' | Change = 'c') (Next = '\/' | Last = '?') Tag = {Esc} $2 '>' {Enter} $1 i t;\r\n(Delete= 'd' | Change = 'c') between <delimiters> = $1 i $2;\r\n(Delete= 'd' | Change = 'c') (Next = '\/' | Last = '?') <delimiters> = {Esc} $2 $3 {Enter} $1 i $3;\r\n(Delete= 'd' | Change = 'c') (Next = '\/' | Last = '?') (Heading = '<h' | Header = '<h' | Paragraph = '<p') \r\n\t\t= {Esc} $2 '\\c' $3 {Enter} $1 i t;\r\n\r\n\r\n\r\n\r\nSelect All = {Alt+e} s {Enter};\r\nGrab Everything = {Alt+e} s {Enter} Wait(100) {Alt+e} c {Enter} Wait(100) {Alt+Tab};\r\n\r\n\r\n\r\n\r\n1..20 Spaces = Repeat($1, ' ');\r\n\r\n\r\n\r\n\r\nDelete Line = 'dd';\r\nDelete <numbers> Lines = $1 'dd';\r\n\r\n\r\n\r\n\r\n# --- HTML and Bootstrap commands (until I'm sure I can get Ultisnips to work) ------------\r\nNext One = {Esc} A;\r\nStart (Heading | Header) 1..5 = '<h' $2 '><\/h' $2 '>' Wait(100) {Left_5};\r\nWrap [In] (Heading | Header) 1..5 = {Esc} I '<h' $2 '>' {Esc} A '<\/h' $2 '>' {Esc} Wait(100) {Enter};\r\nWrap [in] (para = 'p' | item = 'li') = {Esc} I '<' $1 '>' {Esc} A '<\/' $1 '>' {Esc} Wait(100) {Enter};\r\nStart Para = {Esc} I '<p>';\r\nStop Para = {Esc} A '<\/p>' {Esc};\r\nStart List = {Esc} i '<ul>' {Enter} {Esc};\r\nStop List = {Esc} i '<\/ul>' {Esc};\r\n\r\nPaste Image = {Esc} a ' <img align=right hspace=\"7\" src=\"' {Esc} p a '\" \/>';\t\t# Might also add: width=\"200\"\r\n\r\nStart Div (id | class) = {Esc} a '<div ' $1 '= \"\">' Wait(100) {Left_2};\r\nStop Div = {Esc} A '<\/div>' ;\r\nStart Columns = {Esc} i Wait(100) '<div class=\"container\">{Enter}<div class=\"row\">{Enter}'\r\n\t\t {Enter} '<\/div>' {Enter} '<\/div>' {Esc} {Up_3} Wait(100) A;\r\nStart Column 1..12 = {Esc} a '<div class=\"col-md-' $1 '\">' {Enter} '<\/div>'{Enter} {Esc} {Up_2} Wait(100) A;\r\n\r\n\r\n\r\n\r\n\r\n# --- Ultisnips (if I can get it working on all PCs) ------------------------\r\nDo Ultisnips = {Esc} ':UltiSnipsEdit'{Enter};\r\n\r\n(Next = 'j' | Last = 'k') Tag = {Ctrl+$1};\r\nStart Snippet= {Esc} i 'snippet {Enter} {Enter}endsnippet' {Esc} {Up_2} A;\r\nStart (\r\n\tD3 = 'd3_template' | Code = 'D3_code_wrapper'\r\n| \tform | 'form text' | 'form button' | 'form select'\r\n) = {Esc} i $1 Wait(100) {Tab};\r\n\r\n\r\n\r\n\r\n# --- COMMANDS TO ADD ------------------------\r\n\r\n# Using bookmarks or whatever they are called e.g., if I accidentally do the wrong thing and end up on the wrong line,\r\n# g; - last place I was where I made a change\r\n# Ctrl-o - If I jump to a place, copy a line, I can snap back \r\n\r\n# copying sets of lines, moving sets of lines\r\n# :9yank - copy line 9\r\n# :9t16 - copy line 9 to line 16\r\n# :9. - copy line 9 to current position \r\n\r\n\r\n\r\n# For adding quotes, HTML tags, etc. to text that's already there:\r\n# http:\/\/stackoverflow.com\/questions\/10305952\/vim-enclose-word-in-tag\r\n\r\n# Commands I'm not sure about\r\n# H,M,L: top, middle, and bottom of screen\r\n\r\n","old_contents":"# Voice commands for gvim\r\n\r\ninclude folders.vch;\r\ninclude numbers.vch;\r\ninclude letters.vch;\r\ninclude pandas.vch;\r\n\r\nEdit [My] Configuration = ':e $' 'MYVIMRC' {Enter};\r\n\r\n<delimiters> := (Quotes = '\"' | 'Single Quotes' = \"'\" | 'Double Quotes' = '\"' | Parentheses = '(' \r\n\t\t| Brackets = '[' | 'Curly Braces' = '{' | Braces = '{'\r\n\t\t| HTML = '<' | 'Close HTML' = '>' | 'Close Tag' = '>'\t# NOTE: only works with commands I created\r\n\t\t| 'Equal Sign' = '='\r\n);\r\n\r\n# --- File Management ---------------\r\nOpen Document = {Alt+f} o;\r\nList Files = {Esc} ':bro ol' {Enter};\r\nFile <numbers> = $1 {Enter};\r\nLatest File = {Esc} ':bro ol' {Enter} 1{Enter};\r\n\r\nShow (Projects | Folders) = {Esc}':e C:\\Voice\\folders.vch' {Enter} Wait(100) {Down_9};\r\n[Open] Project <folder> = {Esc} ':e ' $1 {Enter} Wait(100) {Down_9};\r\n[Open] Current Project = {Esc} ':e .' {Enter} Wait(100) {Down_9};\r\nUp Directory = '-';\r\nSearch [Directory] <letters> = '\/^' $1;\r\n# :Sex = directory of current file \r\n# :Vex for vertical split\r\n# :sp. = Split horizontally on current directory (:vsp. For vertical)\r\n# % = new file\r\n\r\n(List Buffers = 'ls' | Buffer List = 'ls' | 'Next Buffer' = 'bn' | 'Last Buffer' = 'bp' | 'Close Buffer' = 'bd'\r\n\t| 'Next Window' = 'bn' | 'Last Window' = 'bp' | 'Close Window' = 'bd') \r\n\t= {Esc}':' $1 {Enter};\r\n\r\n\r\nSave Document = {Esc} Wait(100) ':w' {Enter};\r\nSave As = {Alt+f} a;\r\nGo (Quit = 'quit' | Close = 'close' | 'Close without saving' = 'close!' | Set = 'set') = ':' $1 {Enter};\r\n[Go] Quit without Saving = {Esc} Wait(100) ':quit!' {Enter};\r\n\r\nSave and Reload = {Esc} Wait(100) ':w' {Enter} Wait(100) SendSystemKeys({Alt+Tab}) Wait(100) {Alt+r};\r\n\r\n\r\n# --- Basic Navigation ---------------\r\n<numbers> (Up = 'k' | Down = 'j' | Right = 'l' | Left = 'h') = $1 $2;\r\nHoma = {Esc} 0;\r\nEnda = {Esc} '$';\r\n(Top | Go to Top) = {Esc} gg;\r\n(Bottom | Go to Bottom) = {Esc} G;\r\n(Move Forward | Move Right | Go Forward) <numbers> (words = 'w' | blocks = '}') = $2 $3;\r\n(Move Forward | Move Right | Go Forward) <numbers> (end | enda) words = $2 'e';\r\n(Move Back | Move Left | Go Back) <numbers> (words = 'b' | blocks = '{') = $2 $3;\r\nFine (Text | Alpha) <letters> = {Esc} f $2;\r\nFind Back <letters> = {Esc} F $1;\r\nFine Number 1..9 = {Esc} '\/' $1 {Enter};\r\nGo (Search | Find) = {Esc} '\/\\c'; # \\c = case insensitive\r\nFine <delimiters> = {Esc} '\/' $1 {Enter};\r\nInsert (Before = 'i' | After = 'a') <delimiters> = {Esc} '\/' $2 {Enter} Wait(100) $1;\r\nFine Tag = {Esc} '\/' '<' {Enter};\r\nInsert (Before = 'i' | After = 'a') tag = {Esc} '\/' '<' {Enter} Wait(100) $1;\r\n\r\n\r\n(Find Again | Next Fine | Next Find) = n;\r\nLine 1..100 = {Esc} ':' $1 {Enter};\r\n\r\n\r\n# --- Basic Editing ---------------\r\n(Do | Go) (Insert = 'i' | Append = 'A' | \rEscape = '{Esc}') = $2;\r\n(Insert = 'i' | \rEscape = '{Esc}') = $1;\r\nNexta = {Esc} A {Enter};\r\nEnda Insert = {Esc} A;\r\n\r\n(Do Again | Repeat That) = '.';\r\n(Undo | Undo That) = {Esc} u;\r\nRedo = {Esc} {Ctrl+r};\r\n\r\n(Kill = 'x') <numbers> = $2 $1;\r\n(Kill | Delete) Word = 'dw';\r\n(Kill | Delete) <numbers> Words = 'd' $2 'w';\r\nDee Dee = 'dd';\r\nCut to End of Line = 'd$';\r\nCut to End of Word = 'de';\r\n\r\n('Go Visual' | Mark | 'Visual Mode') = V;\r\n('Delete That' = 'd' | 'Yank That' = 'y' | 'Paste' = 'p' | 'Change That' = 'c' | 'Join That' = 'J') = $1;\r\nPaste That = {Esc} Wait(100) '\"+gP';\r\nCopy That = '\"*y';\r\nCopy Line = {Esc} V Wait(100) '\"*y';\r\nSelect Line = {Esc} V;\r\n\r\ndo test = {Esc} i Wait(100) \"strawberry\";\r\n\r\n(Delete= 'd' | Change = 'c') Between Tags = $1 i t;\r\n(Delete= 'd' | Change = 'c') (Next = '\/' | Last = '?') Tag = {Esc} $2 '>' {Enter} $1 i t;\r\n(Delete= 'd' | Change = 'c') between <delimiters> = $1 i $2;\r\n(Delete= 'd' | Change = 'c') (Next = '\/' | Last = '?') <delimiters> = {Esc} $2 $3 {Enter} $1 i $3;\r\n(Delete= 'd' | Change = 'c') (Next = '\/' | Last = '?') (Heading = '<h' | Header = '<h' | Paragraph = '<p') \r\n\t\t= {Esc} $2 '\\c' $3 {Enter} $1 i t;\r\n\r\n\r\n\r\n\r\nSelect All = {Alt+e} s {Enter};\r\nGrab Everything = {Alt+e} s {Enter} Wait(100) {Alt+e} c {Enter} Wait(100) {Alt+Tab};\r\n\r\n\r\n\r\n\r\n1..20 Spaces = Repeat($1, ' ');\r\n\r\n\r\n\r\n\r\nDelete Line = 'dd';\r\nDelete <numbers> Lines = $1 'dd';\r\n\r\n\r\n\r\n\r\n# --- HTML and Bootstrap commands (until I'm sure I can get Ultisnips to work) ------------\r\nNext One = {Esc} A;\r\nStart (Heading | Header) 1..5 = '<h' $2 '><\/h' $2 '>' Wait(100) {Left_5};\r\nWrap [In] (Heading | Header) 1..5 = {Esc} I '<h' $2 '>' {Esc} A '<\/h' $2 '>' {Esc};\r\nStart Para = {Esc} I '<p>';\r\nStop Para = {Esc} A '<\/p>' {Esc};\r\n\r\nPaste Image = {Esc} a ' <img align=right hspace=\"7\" src=\"' {Esc} p a '\" \/>';\t\t# Might also add: width=\"200\"\r\n\r\nStart Div (id | class) = '<div ' $1 '= \"\">' Wait(100) {Left_2};\r\nStop Div = '<\/div>' {Enter};\r\nStart Columns = {Esc} i Wait(100) '<div class=\"container\">{Enter}<div class=\"row\">{Enter}'\r\n\t\t {Enter} '<\/div>' {Enter} '<\/div>' {Esc} {Up_3} Wait(100) A;\r\nStart Column 1..12 = {Esc} a '<div class=\"col-md-' $1 '\">' {Enter} '<\/div>'{Enter} {Esc} {Up_2} Wait(100) A;\r\n\r\n\r\n\r\n\r\n\r\n# --- Ultisnips (if I can get it working on all PCs) ------------------------\r\nDo Ultisnips = {Esc} ':UltiSnipsEdit'{Enter};\r\n\r\n(Next = 'j' | Last = 'k') Tag = {Ctrl+$1};\r\nStart Snippet= {Esc} i 'snippet {Enter} {Enter}endsnippet' {Esc} {Up_2} A;\r\nStart (\r\n\tD3 = 'd3_template' | Code = 'D3_code_wrapper'\r\n| \tform | 'form text' | 'form button' | 'form select'\r\n) = {Esc} i $1 Wait(100) {Tab};\r\n\r\n\r\n\r\n\r\n# --- COMMANDS TO ADD ------------------------\r\n\r\n# Using bookmarks or whatever they are called e.g., if I accidentally do the wrong thing and end up on the wrong line,\r\n# g; - last place I was where I made a change\r\n# Ctrl-o - If I jump to a place, copy a line, I can snap back \r\n\r\n# copying sets of lines, moving sets of lines\r\n# :9yank - copy line 9\r\n# :9t16 - copy line 9 to line 16\r\n# :9. - copy line 9 to current position \r\n\r\n\r\n\r\n# For adding quotes, HTML tags, etc. to text that's already there:\r\n# http:\/\/stackoverflow.com\/questions\/10305952\/vim-enclose-word-in-tag\r\n\r\n# Commands I'm not sure about\r\n# H,M,L: top, middle, and bottom of screen\r\n\r\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"071d2d4a8399d0104bb6b90e441d7558ff22441f","subject":"Better varnish config documentation.","message":"Better varnish config documentation.\n","repos":"exratione\/thywill","old_file":"serverConfig\/varnish\/thywill-default.vcl","new_file":"serverConfig\/varnish\/thywill-default.vcl","new_contents":"#\n# An example Varnish configuration.\n#\n# This is not suitable for production use - it is a quick-start example\n# intended to help set up Thywill for development and show how Varnish\n# can be set up for use with Thywill.\n#\n# Important note: this configuration disables all Varnish caching! It\n# only illustrates how to use Varnish to divide websocket and non-websocket\n# traffic arriving at a single port, and sent to off to different backends.\n#\n# For more comprehensive Varnish configurations that handle additional\n# functionality unrelated to Node.js and websockets, but which is\n# nonetheless absolutely vital for any serious use of Varnish in a \n# production environment, you might look at:\n#\n# https:\/\/github.com\/mattiasgeniar\/varnish-3.0-configuration-templates\/\n#\n\n# -----------------------------------\n# Backend definitions.\n# -----------------------------------\n\n# Nginx.\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n .connect_timeout = 5s;\n .first_byte_timeout = 15s;\n .between_bytes_timeout = 15s;\n .max_connections = 400;\n}\n# Node.js: Thywill Echo application.\nbackend thywill_echo {\n .host = \"127.0.0.1\";\n .port = \"10080\";\n .connect_timeout = 1s;\n .first_byte_timeout = 2s;\n .between_bytes_timeout = 15s;\n .max_connections = 400;\n}\n\n# -----------------------------------\n# Varnish Functions\n# -----------------------------------\n\n# Set a local ACL.\nacl localhost {\n \"localhost\";\n}\n\nsub vcl_recv {\n # Before anything else, redirect all HTTP traffic arriving from the outside\n # world to port 80 to port 443.\n #\n # This works because we are using Stunnel to terminate HTTPS connections and\n # pass them as HTTP to Varnish. These will arrive with client.ip = localhost\n # and with an X-Forward-For header - you will only see both of those \n # conditions for traffic passed through Stunnel. \n #\n # We want to allow local traffic to access port 80 directly, however - so \n # check client.ip against the local ACL and the existence of \n # req.http.X-Forward-For.\n #\n # See vcl_error() for the actual redirecting.\n if (!req.http.X-Forward-For && client.ip !~ localhost) {\n set req.http.x-Redir-Url = \"https:\/\/\" + req.http.host + req.url;\n error 750 req.http.x-Redir-Url;\n }\n \n set req.backend = default;\n set req.grace = 30s;\n \n # Pass the correct originating IP address for the backends\n if (req.restarts == 0) {\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n \n # Remove any port that might be stuck in the hostname.\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n \n # Only deal with \"normal\" request types.\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n # And only deal with GET and HEAD by default.\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n return (pass);\n }\n \n # Pipe websocket connections directly to the relevant Node.js backend.\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n if (req.url ~ \"^\/echo\/\") {\n set req.backend = thywill_echo;\n }\n return (pipe);\n }\n # Requests made to these paths relate to websockets - pass does not seem to\n # work (even for XHR polling).\n if (req.url ~ \"^\/echo\/socket.io\/\") {\n set req.backend = thywill_echo;\n return (pipe);\n }\n \n # Send everything else known to be served by Thywill to the relevant Node.js\n # backend.\n if (req.url ~ \"^\/echo\/\") {\n set req.backend = thywill_echo;\n }\n\n # Normalize Accept-Encoding header. This is straight from the manual: \n # https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/vary.html\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n # No point in compressing these.\n remove req.http.Accept-Encoding;\n } elseif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elseif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n # Unkown algorithm.\n remove req.http.Accept-Encoding;\n }\n }\n \n if (req.http.Authorization || req.http.Cookie) {\n # Not cacheable by default.\n return (pass);\n }\n \n # If we were caching at all, then this next line would return lookup rather\n # than pass. Return pass disables all caching for all backends.\n # return (lookup);\n return (pass);\n}\n\nsub vcl_error {\n # For redirecting traffic from HTTP to HTTPS - see where error 750 is set in\n # vcl_recv().\n if (obj.status == 750) {\n set obj.http.Location = obj.response;\n set obj.status = 302;\n return (deliver);\n }\n}\n\nsub vcl_pipe {\n # We need to copy the upgrade header.\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n return (pipe);\n}\n","old_contents":"#\n# An example Varnish configuration.\n#\n# This is not suitable for production use - it is a quick-start example\n# intended to help set up Thywill for development and show how Varnish\n# can be set up for use with Thywill.\n#\n# Important note: this configuration disables all Varnish caching! It\n# only illustrates how to use Varnish to divide websocket and non-websocket\n# traffic arriving at a single port, and sent to off to different backends.\n#\n# For more comprehensive Varnish configurations that handle additional\n# functionality unrelated to Node.js and websockets, but which is\n# nonetheless absolutely vital for any serious use of Varnish in a \n# production environment, you might look at:\n#\n# https:\/\/github.com\/mattiasgeniar\/varnish-3.0-configuration-templates\/\n#\n\n# -----------------------------------\n# Backend definitions.\n# -----------------------------------\n\n# Nginx.\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n .connect_timeout = 5s;\n .first_byte_timeout = 15s;\n .between_bytes_timeout = 15s;\n .max_connections = 400;\n}\n# Node.js: Thywill Echo application.\nbackend thywill_echo {\n .host = \"127.0.0.1\";\n .port = \"10080\";\n .connect_timeout = 1s;\n .first_byte_timeout = 2s;\n .between_bytes_timeout = 15s;\n .max_connections = 400;\n}\n\n# -----------------------------------\n# Varnish Functions\n# -----------------------------------\n\n# Set a local ACL.\nacl localhost {\n \"localhost\";\n}\n\nsub vcl_recv {\n # Before anything else, redirect all HTTP traffic arriving from the outside\n # world to port 80 to port 443.\n #\n # This works because we are using Stunnel to terminate HTTPS connections and\n # pass them as HTTP to Varnish. These will arrive with client.ip = localhost\n # and with an X-Forward-For header - you will only see both of those \n # conditions for traffic passed through Stunnel. Therefore if we don't see\n # both of these conditions, redirect.\n #\n # See vcl_error() for the actual redirecting.\n if (!req.http.X-Forward-For && client.ip !~ localhost) {\n set req.http.x-Redir-Url = \"https:\/\/\" + req.http.host + req.url;\n error 750 req.http.x-Redir-Url;\n }\n \n set req.backend = default;\n set req.grace = 30s;\n \n # Pass the correct originating IP address for the backends\n if (req.restarts == 0) {\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n \n # Remove any port that might be stuck in the hostname.\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n \n # Only deal with \"normal\" request types.\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n # And only deal with GET and HEAD by default.\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n return (pass);\n }\n \n # Pipe websocket connections directly to the relevant Node.js backend.\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n if (req.url ~ \"^\/echo\/\") {\n set req.backend = thywill_echo;\n }\n return (pipe);\n }\n # Requests made to these paths relate to websockets - pass does not seem to\n # work (even for XHR polling).\n if (req.url ~ \"^\/echo\/socket.io\/\") {\n set req.backend = thywill_echo;\n return (pipe);\n }\n \n # Send everything else known to be served by Thywill to the relevant Node.js\n # backend.\n if (req.url ~ \"^\/echo\/\") {\n set req.backend = thywill_echo;\n }\n\n # Normalize Accept-Encoding header. This is straight from the manual: \n # https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/vary.html\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n # No point in compressing these.\n remove req.http.Accept-Encoding;\n } elseif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elseif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n # Unkown algorithm.\n remove req.http.Accept-Encoding;\n }\n }\n \n if (req.http.Authorization || req.http.Cookie) {\n # Not cacheable by default.\n return (pass);\n }\n \n # If we were caching at all, then this next line would return lookup rather\n # than pass. Return pass disables all caching for all backends.\n # return (lookup);\n return (pass);\n}\n\nsub vcl_error {\n # For redirecting traffic from HTTP to HTTPS - see where error 750 is set in\n # vcl_recv().\n if (obj.status == 750) {\n set obj.http.Location = obj.response;\n set obj.status = 302;\n return (deliver);\n }\n}\n\nsub vcl_pipe {\n # We need to copy the upgrade header.\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n return (pipe);\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"49b7a6fce046747e140f9ee61e97022d456e99dc","subject":"Bypass varnish for local, login, or admin pages","message":"Bypass varnish for local, login, or admin pages\n","repos":"evolution\/genesis-wordpress,genesis\/wordpress,genesis\/wordpress,jalevin\/wordpress,genesis\/wordpress,genesis\/wordpress,evolution\/wordpress,evolution\/genesis-wordpress,evolution\/wordpress,evolution\/genesis-wordpress,jalevin\/wordpress,genesis\/wordpress,jalevin\/wordpress,evolution\/wordpress,genesis\/wordpress,evolution\/genesis-wordpress,evolution\/wordpress,jalevin\/wordpress,evolution\/genesis-wordpress,evolution\/genesis-wordpress,jalevin\/wordpress,evolution\/wordpress","old_file":"provisioning\/roles\/varnish\/files\/etc-varnish\/conf.d\/receive\/wordpress.vcl","new_file":"provisioning\/roles\/varnish\/files\/etc-varnish\/conf.d\/receive\/wordpress.vcl","new_contents":"# Pass all local or login\/admin requests straight through\nif (req.http.Host ~ \"^local\\.\" || (req.url ~ \"wp-(login|admin)\")) {\n return (pass);\n}\n\n# Drop any cookies sent to Wordpress.\nif (!(req.url ~ \"wp-(login|admin)\")) {\n unset req.http.Cookie;\n}\n\n# Anything else left?\nif (!req.http.Cookie) {\n unset req.http.Cookie;\n}\n\n# Try a cache-lookup\nreturn (lookup);\n","old_contents":"# Drop any cookies sent to Wordpress.\nif (!(req.url ~ \"wp-(login|admin)\")) {\n unset req.http.cookie;\n}\n\n# Anything else left?\nif (!req.http.cookie) {\n unset req.http.cookie;\n}\n\n# Try a cache-lookup\nreturn (lookup);\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"6c535561c8d9b048129655382a5e6ef4d5b2ca63","subject":"Fix 400 bad request of varnish with nginx and apache 2.4","message":"Fix 400 bad request of varnish with nginx and apache 2.4\n\nUpdate vcl from https:\/\/github.com\/cosimo\/varnish-accept-language\n.\/gen_vcl.pl pt de eo es fr hy it pt ru < accept-language.c > new.vcl\n\n(ActionItem3186)\n","repos":"macartur\/noosfero,macartur\/noosfero,uniteddiversity\/noosfero,hebertdougl\/noosfero,samasti\/noosfero,uniteddiversity\/noosfero,evandrojr\/noosfero,marcosronaldo\/noosfero,coletivoEITA\/noosfero,evandrojr\/noosferogov,abner\/noosfero,alexandreab\/noosfero,macartur\/noosfero,coletivoEITA\/noosfero,arthurmde\/noosfero,larissa\/noosfero,larissa\/noosfero,coletivoEITA\/noosfero-ecosol,uniteddiversity\/noosfero,coletivoEITA\/noosfero-ecosol,abner\/noosfero,arthurmde\/noosfero,coletivoEITA\/noosfero,LuisBelo\/tccnoosfero,evandrojr\/noosferogov,tallysmartins\/noosfero,uniteddiversity\/noosfero,vfcosta\/noosfero,alexandreab\/noosfero,vfcosta\/noosfero,AlessandroCaetano\/noosfero,hebertdougl\/noosfero,evandrojr\/noosferogov,alexandreab\/noosfero,LuisBelo\/tccnoosfero,evandrojr\/noosfero,tallysmartins\/noosfero,evandrojr\/noosferogov,blogoosfero\/noosfero,alexandreab\/noosfero,arthurmde\/noosfero,larissa\/noosfero,vfcosta\/noosfero,marcosronaldo\/noosfero,tallysmartins\/noosfero,abner\/noosfero,blogoosfero\/noosfero,marcosronaldo\/noosfero,evandrojr\/noosfero,macartur\/noosfero,coletivoEITA\/noosfero,hebertdougl\/noosfero,blogoosfero\/noosfero,blogoosfero\/noosfero,CIRANDAS\/noosfero-ecosol,hebertdougl\/noosfero,marcosronaldo\/noosfero,samasti\/noosfero,CIRANDAS\/noosfero-ecosol,LuisBelo\/tccnoosfero,hebertdougl\/noosfero,larissa\/noosfero,macartur\/noosfero,vfcosta\/noosfero,CIRANDAS\/noosfero-ecosol,uniteddiversity\/noosfero,evandrojr\/noosfero,coletivoEITA\/noosfero-ecosol,arthurmde\/noosfero,arthurmde\/noosfero,coletivoEITA\/noosfero-ecosol,EcoAlternative\/noosfero-ecosol,blogoosfero\/noosfero,tallysmartins\/noosfero,larissa\/noosfero,coletivoEITA\/noosfero,EcoAlternative\/noosfero-ecosol,marcosronaldo\/noosfero,larissa\/noosfero,EcoAlternative\/noosfero-ecosol,arthurmde\/noosfero,macartur\/noosfero,samasti\/noosfero,samasti\/noosfero,AlessandroCaetano\/noosfero,evandrojr\/noosfero,AlessandroCaetano\/noosfero,vfcosta\/noosfero,hebertdougl\/noosfero,coletivoEITA\/noosfero,marcosronaldo\/noosfero,blogoosfero\/noosfero,EcoAlternative\/noosfero-ecosol,evandrojr\/noosferogov,evandrojr\/noosferogov,AlessandroCaetano\/noosfero,blogoosfero\/noosfero,alexandreab\/noosfero,samasti\/noosfero,vfcosta\/noosfero,LuisBelo\/tccnoosfero,abner\/noosfero,tallysmartins\/noosfero,EcoAlternative\/noosfero-ecosol,AlessandroCaetano\/noosfero,CIRANDAS\/noosfero-ecosol,arthurmde\/noosfero,EcoAlternative\/noosfero-ecosol,abner\/noosfero,samasti\/noosfero,tallysmartins\/noosfero,evandrojr\/noosferogov,EcoAlternative\/noosfero-ecosol,hebertdougl\/noosfero,evandrojr\/noosfero,evandrojr\/noosfero,coletivoEITA\/noosfero-ecosol,abner\/noosfero,uniteddiversity\/noosfero,alexandreab\/noosfero,macartur\/noosfero,AlessandroCaetano\/noosfero,coletivoEITA\/noosfero,tallysmartins\/noosfero,LuisBelo\/tccnoosfero,larissa\/noosfero,AlessandroCaetano\/noosfero,CIRANDAS\/noosfero-ecosol,uniteddiversity\/noosfero,marcosronaldo\/noosfero,coletivoEITA\/noosfero-ecosol,LuisBelo\/tccnoosfero,alexandreab\/noosfero,abner\/noosfero","old_file":"etc\/noosfero\/varnish-accept-language.vcl","new_file":"etc\/noosfero\/varnish-accept-language.vcl","new_contents":"C{\n\n\/* ------------------------------------------------------------------ *\/\n\/* THIS FILE IS AUTOMATICALLY GENERATED BY .\/gen_vcl.pl. DO NOT EDIT. *\/\n\n\/*\n * Accept-language header normalization\n *\n * - Parses client Accept-Language HTTP header\n * - Tries to find the best match with the supported languages\n * - Writes the best match as req.http.X-Varnish-Accept-Language\n *\n * First version: Cosimo, 21\/Jan\/2010\n * Last update: Cosimo, 03\/Nov\/2011\n *\n * http:\/\/github.com\/cosimo\/varnish-accept-language\n *\n *\/\n\n#include <ctype.h> \/* isupper *\/\n#include <stdio.h>\n#include <stdlib.h> \/* qsort *\/\n#include <string.h>\n\n#define DEFAULT_LANGUAGE \"en\"\n#define SUPPORTED_LANGUAGES \":de:eo:es:fr:hy:it:pt:ru:\"\n\n#define vcl_string char\n#define LANG_LIST_SIZE 16\n#define HDR_MAXLEN 256\n#define LANG_MAXLEN 8\n#define RETURN_LANG(x) { \\\n strncpy(lang, x, LANG_MAXLEN); \\\n return; \\\n}\n#define RETURN_DEFAULT_LANG RETURN_LANG(DEFAULT_LANGUAGE)\n#define PUSH_LANG(x,y) { \\\n \/* fprintf(stderr, \"Pushing lang [%d] %s %.4f\\n\", curr_lang, x, y); *\/ \\\n \/* We have to copy, otherwise root_lang will be the same every time *\/ \\\n strncpy(pl[curr_lang].lang, x, LANG_MAXLEN); \\\n pl[curr_lang].q = y; \\\n curr_lang++; \\\n}\n\nstruct lang_list {\n vcl_string lang[LANG_MAXLEN];\n float q;\n};\n\n\/* In-place lowercase of a string *\/\nstatic void strtolower(char *s) {\n register char *c;\n for (c=s; *c; c++) {\n if (isupper(*c)) {\n *c = tolower(*c);\n }\n }\n return;\n}\n\n\/* Checks if a given language is in the static list of the ones we support *\/\nint is_supported(vcl_string *lang) {\n vcl_string *supported_languages = SUPPORTED_LANGUAGES;\n vcl_string match_str[LANG_MAXLEN + 3] = \"\"; \/* :, :, \\0 = 3 *\/\n int is_supported = 0;\n\n \/* We want to match 'zh-cn' and 'zh-CN' too *\/\n strtolower(lang);\n\n \/* Search \":<lang>:\" in supported languages string *\/\n strncpy(match_str, \":\", 1);\n strncat(match_str, lang, LANG_MAXLEN);\n strncat(match_str, \":\\0\", 2);\n\n if (strstr(supported_languages, match_str))\n is_supported = 1;\n\n return is_supported;\n}\n\n\/* Used by qsort() below *\/\nint sort_by_q(const void *x, const void *y) {\n struct lang_list *a = (struct lang_list *)x;\n struct lang_list *b = (struct lang_list *)y;\n if (a->q > b->q) return -1;\n if (a->q < b->q) return 1;\n return 0;\n}\n\n\/* Reads Accept-Language, parses it, and finds the first match\n among the supported languages. In case of no match,\n returns the default language.\n*\/\nvoid select_language(const vcl_string *incoming_header, char *lang) {\n\n struct lang_list pl[LANG_LIST_SIZE];\n vcl_string *lang_tok = NULL;\n vcl_string root_lang[3];\n vcl_string *header;\n vcl_string header_copy[HDR_MAXLEN];\n vcl_string *pos = NULL;\n vcl_string *q_spec = NULL;\n unsigned int curr_lang = 0, i = 0;\n float q;\n\n \/* Empty or default string, return default language immediately *\/\n if (\n !incoming_header\n || (0 == strcmp(incoming_header, \"en-US\"))\n || (0 == strcmp(incoming_header, \"en-GB\"))\n || (0 == strcmp(incoming_header, DEFAULT_LANGUAGE))\n || (0 == strcmp(incoming_header, \"\"))\n )\n RETURN_DEFAULT_LANG;\n\n \/* Tokenize Accept-Language *\/\n header = strncpy(header_copy, incoming_header, sizeof(header_copy));\n\n while ((lang_tok = strtok_r(header, \" ,\", &pos))) {\n\n q = 1.0;\n\n if ((q_spec = strstr(lang_tok, \";q=\"))) {\n \/* Truncate language name before ';' *\/\n *q_spec = '\\0';\n \/* Get q value *\/\n sscanf(q_spec + 3, \"%f\", &q);\n }\n\n \/* Wildcard language '*' should be last in list *\/\n if ((*lang_tok) == '*') q = 0.0;\n\n \/* Push in the prioritized list *\/\n PUSH_LANG(lang_tok, q);\n\n \/* For cases like 'en-GB', we also want the root language in the final list *\/\n if ('-' == lang_tok[2]) {\n root_lang[0] = lang_tok[0];\n root_lang[1] = lang_tok[1];\n root_lang[2] = '\\0';\n PUSH_LANG(root_lang, q - 0.001);\n }\n\n \/* For strtok_r() to proceed from where it left off *\/\n header = NULL;\n\n \/* Break out if stored max no. of languages *\/\n if (curr_lang >= LANG_LIST_SIZE)\n break;\n }\n\n \/* Sort by priority *\/\n qsort(pl, curr_lang, sizeof(struct lang_list), &sort_by_q);\n\n \/* Match with supported languages *\/\n for (i = 0; i < curr_lang; i++) {\n if (is_supported(pl[i].lang))\n RETURN_LANG(pl[i].lang);\n }\n\n RETURN_DEFAULT_LANG;\n}\n\n\/* Reads req.http.Accept-Language and writes X-Varnish-Accept-Language *\/\nvoid vcl_rewrite_accept_language(const struct sess *sp) {\n vcl_string *in_hdr;\n vcl_string lang[LANG_MAXLEN];\n\n \/* Get Accept-Language header from client *\/\n in_hdr = VRT_GetHdr(sp, HDR_REQ, \"\\020Accept-Language:\");\n\n \/* Normalize and filter out by list of supported languages *\/\n memset(lang, 0, sizeof(lang));\n select_language(in_hdr, lang);\n\n \/* By default, use a different header name: don't mess with backend logic *\/\n VRT_SetHdr(sp, HDR_REQ, \"\\032X-Varnish-Accept-Language:\", lang, vrt_magic_string_end);\n\n return;\n}\n\n\/* vim: syn=c ts=4 et sts=4 sw=4 tw=0\n*\/\n\n\/* THIS FILE IS AUTOMATICALLY GENERATED BY .\/gen_vcl.pl. DO NOT EDIT. *\/\n\/* ------------------------------------------------------------------ *\/\n}C\n\nsub vcl_recv {\n C{\n vcl_rewrite_accept_language(sp);\n }C\n}\n\nsub vcl_fetch {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary + \", X-Varnish-Accept-Language\";\n } else {\n set beresp.http.Vary = \"X-Varnish-Accept-Language\";\n }\n}\n\n","old_contents":"C{\n\n\/* ------------------------------------------------------------------ *\/\n\/* THIS FILE IS AUTOMATICALLY GENERATED BY .\/gen_vcl.pl. DO NOT EDIT. *\/\n\n\/*\n * Accept-language header normalization\n *\n * Cosimo, 21\/01\/2010\n *\n *\/\n\n#include <ctype.h> \/* isupper *\/\n#include <stdio.h>\n#include <stdlib.h> \/* qsort *\/\n#include <string.h>\n\n#define DEFAULT_LANGUAGE \"en\"\n#define SUPPORTED_LANGUAGES \":de:fr:es:ru:pt:hy:en:\"\n\n#define vcl_string char\n#define LANG_LIST_SIZE 16 \n#define LANG_MAXLEN 16\n#define RETURN_LANG(x) { \\\n strncpy(lang, x, LANG_MAXLEN); \\\n return; \\\n}\n#define RETURN_DEFAULT_LANG RETURN_LANG(DEFAULT_LANGUAGE)\n#define PUSH_LANG(x,y) { \\\n \/* fprintf(stderr, \"Pushing lang [%d] %s %.4f\\n\", curr_lang, x, y); *\/ \\\n \/* We have to copy, otherwise root_lang will be the same every time *\/ \\\n strncpy(pl[curr_lang].lang, x, LANG_MAXLEN); \\\n pl[curr_lang].q = y; \\\n curr_lang++; \\\n}\n\nstruct lang_list {\n vcl_string lang[LANG_MAXLEN];\n float q;\n};\n\n\/* In-place lowercase of a string *\/\nstatic void strtolower(char *s) {\n register char *c;\n for (c=s; *c; c++) {\n if (isupper(*c)) {\n *c = tolower(*c);\n }\n }\n return;\n}\n\n\/* Checks if a given language is in the static list of the ones we support *\/\nint is_supported(vcl_string *lang) {\n vcl_string *supported_languages = SUPPORTED_LANGUAGES;\n vcl_string match_str[LANG_MAXLEN + 3] = \"\"; \/* :, :, \\0 = 3 *\/\n int is_supported = 0;\n\n \/* We want to match 'zh-cn' and 'zh-CN' too *\/\n strtolower(lang);\n\n \/* Search \":<lang>:\" in supported languages string *\/\n strncpy(match_str, \":\", 1);\n strncat(match_str, lang, LANG_MAXLEN);\n strncat(match_str, \":\\0\", 2);\n\n if (strstr(supported_languages, match_str)) {\n is_supported = 1;\n }\n\n return is_supported;\n}\n\n\/* Used by qsort() below *\/\nint sort_by_q(const void *x, const void *y) {\n struct lang_list *a = (struct lang_list *)x;\n struct lang_list *b = (struct lang_list *)y;\n if (a->q > b->q) return -1;\n if (a->q < b->q) return 1;\n return 0;\n}\n\n\/* Reads Accept-Language, parses it, and finds the first match\n among the supported languages. In case of no match,\n returns the default language.\n*\/\nvoid select_language(const vcl_string *incoming_header, char *lang) {\n\n struct lang_list pl[LANG_LIST_SIZE];\n vcl_string *lang_tok = NULL;\n vcl_string root_lang[3];\n vcl_string *header;\n vcl_string *pos = NULL;\n vcl_string *q_spec = NULL;\n unsigned int curr_lang = 0, i = 0;\n float q;\n\n \/* Empty or default string, return default language immediately *\/\n if (\n !incoming_header\n || (0 == strcmp(incoming_header, \"en-US\"))\n || (0 == strcmp(incoming_header, \"en-GB\"))\n || (0 == strcmp(incoming_header, DEFAULT_LANGUAGE))\n || (0 == strcmp(incoming_header, \"\"))\n )\n RETURN_DEFAULT_LANG;\n\n \/* Tokenize Accept-Language *\/\n header = (vcl_string *) incoming_header;\n\n while ((lang_tok = strtok_r(header, \" ,\", &pos))) {\n\n q = 1.0;\n\n if ((q_spec = strstr(lang_tok, \";q=\"))) {\n \/* Truncate language name before ';' *\/\n *q_spec = '\\0';\n \/* Get q value *\/\n sscanf(q_spec + 3, \"%f\", &q);\n }\n\n \/* Wildcard language '*' should be last in list *\/\n if ((*lang_tok) == '*') q = 0.0;\n\n \/* Push in the prioritized list *\/\n PUSH_LANG(lang_tok, q);\n\n \/* For cases like 'en-GB', we also want the root language in the final list *\/\n if ('-' == lang_tok[2]) {\n root_lang[0] = lang_tok[0];\n root_lang[1] = lang_tok[1];\n root_lang[2] = '\\0';\n PUSH_LANG(root_lang, q - 0.001);\n }\n\n \/* For strtok_r() to proceed from where it left off *\/\n header = NULL;\n\n \/* Break out if stored max no. of languages *\/\n if (curr_lang >= LANG_MAXLEN) break;\n }\n\n \/* Sort by priority *\/\n qsort(pl, curr_lang, sizeof(struct lang_list), &sort_by_q);\n\n \/* Match with supported languages *\/\n for (i = 0; i < curr_lang; i++) {\n if (is_supported(pl[i].lang))\n RETURN_LANG(pl[i].lang);\n }\n\n RETURN_DEFAULT_LANG;\n}\n\n\/* Reads req.http.Accept-Language and writes X-Varnish-Accept-Language *\/\nvoid vcl_rewrite_accept_language(const struct sess *sp) {\n vcl_string *in_hdr;\n vcl_string lang[LANG_MAXLEN];\n\n memset(lang, 0, LANG_MAXLEN);\n\n \/* Get Accept-Language header from client *\/\n in_hdr = VRT_GetHdr(sp, HDR_REQ, \"\\020Accept-Language:\");\n\n \/* Normalize and filter out by list of supported languages *\/\n select_language(in_hdr, lang);\n\n \/* By default, use a different header name: don't mess with backend logic *\/\n VRT_SetHdr(sp, HDR_REQ, \"\\032X-Varnish-Accept-Language:\", lang, vrt_magic_string_end);\n\n return;\n}\n\n\/* vim: syn=c ts=4 et sts=4 sw=4 tw=0\n*\/\n\n\/* THIS FILE IS AUTOMATICALLY GENERATED BY .\/gen_vcl.pl. DO NOT EDIT. *\/\n\/* ------------------------------------------------------------------ *\/\n}C\n\nsub vcl_recv {\n C{\n vcl_rewrite_accept_language(sp);\n }C\n}\n\nsub vcl_fetch {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary + \", X-Varnish-Accept-Language\";\n } else {\n set beresp.http.Vary = \"X-Varnish-Accept-Language\";\n }\n}\n","returncode":0,"stderr":"","license":"agpl-3.0","lang":"VCL"} {"commit":"083c4c47dbabbc180863bac274286869a4bc4690","subject":"Fixed syslog include in example VCL","message":"Fixed syslog include in example VCL","repos":"Destination\/libvmod-abtest,Destination\/libvmod-abtest","old_file":"vcl\/default.vcl","new_file":"vcl\/default.vcl","new_contents":"import std;\nimport abtest;\n\nC{\n #include <syslog.h>\n}C\n\n backend default {\n .host = \"127.0.0.1\";\n .port = \"3000\";\n }\n\n\/* Only permit localhost to manipulate abtest configuration *\/\nacl abconfig {\n \"localhost\";\n}\n\nsub vcl_init {\n if (abtest.load_config(\"\/tmp\/abtest.cfg\") != 0) {\n C{ syslog(LOG_ALERT, \"Unable to load AB config from \/tmp\/abtest.cfg\"); }C\n }\n abtest.set_rule(\".*\", \"a:1;b:1;86400;\"); \/\/ Set default rule with a duration of 24H\n\n return (ok);\n}\n\nsub vcl_fini {\n}\n\nsub vcl_recv {\n if (req.http.X-AB-Cfg) {\n if (!client.ip ~ abconfig) {\n error 405 \"Not allowed.\";\n } else {\n \/\/ curl localhost:8080 -X PUT -H \"X-AB-Cfg:base\" -H \"X-AB-Cfg-Val:a:25;b:75;\"\n if (req.request == \"PUT\") {\n std.log(\"AB Config PUT request: \" + req.http.X-AB-Cfg + \"|\" + req.http.X-AB-Cfg-Val);\n abtest.set_rule(req.http.X-AB-Cfg, req.http.X-AB-Cfg-Val);\n if (abtest.save_config(\"\/tmp\/abtest.cfg\") != 0) {\n std.log(\"ABTest - Error, could not save the configuration\");\n }\n }\n\n \/\/ curl localhost:8080 -X DELETE -H \"X-AB-Cfg:base\"\n if (req.request == \"DELETE\") {\n std.log(\"AB Config DELETE request: \" + req.http.X-AB-Cfg);\n abtest.rem_rule(req.http.X-AB-Cfg);\n }\n }\n }\n\n if(!req.http.Cookie ~ \"abtesting\") {\n std.log(\"No AB cookie, setting it.\");\n set req.http.Cookie = \"abtesting=\" + abtest.get_rand(req.url) + \"; path=\/; expires=\" + abtest.get_expire(req.url);\n set req.http.X-Set-AB-Cookie = req.http.Cookie;\n } else {\n std.log(\"AB cookie found.\");\n }\n\n return (lookup);\n}\n\nsub vcl_pipe {\n}\n\nsub vcl_pass {\n}\n\nsub vcl_hash {\n}\n\nsub vcl_hit {\n}\n\nsub vcl_miss {\n}\n\nsub vcl_fetch {\n}\n\nsub vcl_deliver {\n if (req.http.X-Set-AB-Cookie) {\n std.log(\"Setting cookie to \" + req.http.X-Set-AB-Cookie);\n set resp.http.Set-Cookie = req.http.X-Set-AB-Cookie;\n }\n\n if (req.http.X-AB-Cfg && client.ip ~ abconfig) {\n if (req.request == \"GET\") {\n \/\/ curl localhost:8080 -X GET -H \"X-AB-Cfg:;\"\n set resp.http.X-AB-Cfg = abtest.get_rules();\n }\n }\n}\n\nsub vcl_error {\n}\n","old_contents":"import std;\nimport abtest;\n\n backend default {\n .host = \"127.0.0.1\";\n .port = \"3000\";\n }\n\n\/* Only permit localhost to manipulate abtest configuration *\/\nacl abconfig {\n \"localhost\";\n}\n\nsub vcl_init {\n if (abtest.load_config(\"\/tmp\/abtest.cfg\") != 0) {\n C{ syslog(LOG_ALERT, \"Unable to load AB config from \/tmp\/abtest.cfg\"); }C\n }\n abtest.set_rule(\".*\", \"a:1;b:1;86400;\"); \/\/ Set default rule with a duration of 24H\n\n return (ok);\n}\n\nsub vcl_fini {\n}\n\nsub vcl_recv {\n if (req.http.X-AB-Cfg) {\n if (!client.ip ~ abconfig) {\n error 405 \"Not allowed.\";\n } else {\n \/\/ curl localhost:8080 -X PUT -H \"X-AB-Cfg:base\" -H \"X-AB-Cfg-Val:a:25;b:75;\"\n if (req.request == \"PUT\") {\n std.log(\"AB Config PUT request: \" + req.http.X-AB-Cfg + \"|\" + req.http.X-AB-Cfg-Val);\n abtest.set_rule(req.http.X-AB-Cfg, req.http.X-AB-Cfg-Val);\n if (abtest.save_config(\"\/tmp\/abtest.cfg\") != 0) {\n std.log(\"ABTest - Error, could not save the configuration\");\n }\n }\n\n \/\/ curl localhost:8080 -X DELETE -H \"X-AB-Cfg:base\"\n if (req.request == \"DELETE\") {\n std.log(\"AB Config DELETE request: \" + req.http.X-AB-Cfg);\n abtest.rem_rule(req.http.X-AB-Cfg);\n }\n }\n }\n\n if(!req.http.Cookie ~ \"abtesting\") {\n std.log(\"No AB cookie, setting it.\");\n set req.http.Cookie = \"abtesting=\" + abtest.get_rand(req.url) + \"; path=\/; expires=\" + abtest.get_expire(req.url);\n set req.http.X-Set-AB-Cookie = req.http.Cookie;\n } else {\n std.log(\"AB cookie found.\");\n }\n\n return (lookup);\n}\n\nsub vcl_pipe {\n}\n\nsub vcl_pass {\n}\n\nsub vcl_hash {\n}\n\nsub vcl_hit {\n}\n\nsub vcl_miss {\n}\n\nsub vcl_fetch {\n}\n\nsub vcl_deliver {\n if (req.http.X-Set-AB-Cookie) {\n std.log(\"Setting cookie to \" + req.http.X-Set-AB-Cookie);\n set resp.http.Set-Cookie = req.http.X-Set-AB-Cookie;\n }\n\n if (req.http.X-AB-Cfg && client.ip ~ abconfig) {\n if (req.request == \"GET\") {\n \/\/ curl localhost:8080 -X GET -H \"X-AB-Cfg:;\"\n set resp.http.X-AB-Cfg = abtest.get_rules();\n }\n }\n}\n\nsub vcl_error {\n}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"c93b3eebf9a05d9afdb5aa86c56627ee6a84d7c3","subject":"Fix incorrect VCL in example.vcl.","message":"Fix incorrect VCL in example.vcl.\n\nOld habits die hard.\n\nThanks to Federico Schwindt for pointing this out.\n","repos":"mrhmouse\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,alarky\/varnish-cache-doc-ja,alarky\/varnish-cache-doc-ja,franciscovg\/Varnish-Cache,gquintard\/Varnish-Cache,chrismoulton\/Varnish-Cache,chrismoulton\/Varnish-Cache,chrismoulton\/Varnish-Cache,feld\/Varnish-Cache,franciscovg\/Varnish-Cache,zhoualbeart\/Varnish-Cache,varnish\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,zhoualbeart\/Varnish-Cache,alarky\/varnish-cache-doc-ja,alarky\/varnish-cache-doc-ja,zhoualbeart\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,varnish\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,mrhmouse\/Varnish-Cache,gquintard\/Varnish-Cache,feld\/Varnish-Cache,zhoualbeart\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,gquintard\/Varnish-Cache,varnish\/Varnish-Cache,zhoualbeart\/Varnish-Cache,alarky\/varnish-cache-doc-ja,ajasty-cavium\/Varnish-Cache,feld\/Varnish-Cache,franciscovg\/Varnish-Cache,mrhmouse\/Varnish-Cache,varnish\/Varnish-Cache,varnish\/Varnish-Cache,mrhmouse\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,feld\/Varnish-Cache,franciscovg\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,chrismoulton\/Varnish-Cache,mrhmouse\/Varnish-Cache,feld\/Varnish-Cache,gquintard\/Varnish-Cache,chrismoulton\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,franciscovg\/Varnish-Cache","old_file":"etc\/example.vcl","new_file":"etc\/example.vcl","new_contents":"#\n# This is an example VCL file for Varnish.\n# It does not do anything by default, delegating control to the builtin vcl.\n# The builtin VCL is called when there is no explicit explicit return\n# statement.\n\n# See the VCL tutorial at https:\/\/www.varnish-cache.org\/docs\/trunk\/tutorial\/\n# See http:\/\/varnish-cache.org\/trac\/wiki\/VCLExamples for more examples.\n\n# Marker to tell the VCL compiler that this VCL has been adapted to the new 4.0\n# format.\nvcl 4.0;\n\n# Default backend definition. Set this to point to your content server.\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\n\nsub vcl_recv {\n # Happens before we check if we have this in cache already.\n # See http:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/vcl.html#vcl_recv\n}\n\nsub vcl_backend_response {\n # Happens after we have read the response headers from the backend.\n # See http:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/vcl.html#vcl_fetch\n#\n}\n\nsub vcl_deliver {\n # Happens when we have all the pieces we need, and are about to send the\n # response to the client.\n # See http:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/vcl.html#vcl_fetch\n}\n\n","old_contents":"#\n# This is an example VCL file for Varnish.\n# It does not do anything by default, delegating control to the builtin vcl.\n# The builtin VCL is called when there is no explicit explicit return\n# statement.\n\n# See the VCL tutorial at https:\/\/www.varnish-cache.org\/docs\/trunk\/tutorial\/\n# See http:\/\/varnish-cache.org\/trac\/wiki\/VCLExamples for more examples.\n\n# Marker to tell the VCL compiler that this VCL has been adapted to the new 4.0\n# format.\nvcl 4.0;\n\n# Default backend definition. Set this to point to your content server.\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\n\nsub vcl_recv {\n # Happens before we check if we have this in cache already.\n # See http:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/vcl.html#vcl_recv\n}\n\nsub vcl_fetch {\n # Happens after we have read the response headers from the backend.\n # See http:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/vcl.html#vcl_fetch\n#\n}\n\nsub vcl_deliver {\n # Happens when we have all the pieces we need, and are about to send the\n # response to the client.\n # See http:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/vcl.html#vcl_fetch\n}\n\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"69e25e1d3e82ec512e85172ec0456dde9508578b","subject":"Lowercase the req.http.host variable","message":"Lowercase the req.http.host variable\n","repos":"pypa\/warehouse,alex\/warehouse,karan\/warehouse,wlonk\/warehouse,pypa\/warehouse,karan\/warehouse,karan\/warehouse,alex\/warehouse,dstufft\/warehouse,dstufft\/warehouse,dstufft\/warehouse,wlonk\/warehouse,alex\/warehouse,dstufft\/warehouse,karan\/warehouse,alex\/warehouse,wlonk\/warehouse,alex\/warehouse,karan\/warehouse,pypa\/warehouse,pypa\/warehouse","old_file":"vcl\/main.vcl","new_file":"vcl\/main.vcl","new_contents":"\nsub vcl_recv {\n\n # I'm not 100% sure on what this is exactly for, it was taken from the\n # Fastly documentation, however, what I *believe* it does is just ensure\n # that we don't serve a stale copy of the page from the shield node when\n # an edge node is requesting content.\n if (req.http.Fastly-FF) {\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Some (Older) clients will send a hash fragment as part of the URL even\n # though that is a local only modification. This breaks this badly for the\n # files in S3, and in general it's just not needed.\n set req.url = regsub(req.url, \"#.*$\", \"\");\n\n # Most of the URLs in Warehouse do not support or require any sort of query\n # parameter. If we strip these at the edge then we'll increase our cache\n # efficiency when they won't otherwise change the output of the pages.\n #\n # This will match any URL except those that start with:\n #\n # * \/search\/\n # * \/account\/login\/\n # * \/account\/logout\/\n # * \/account\/register\/\n # * \/pypi\n if (req.url !~ \"^\/(search\/|account\/(login|logout|register)\/|pypi)\") {\n set req.url = req.url.path;\n }\n\n # Sort all of our query parameters, this will ensure that the same query\n # parameters in a different order will end up being represented as the same\n # thing, reducing cache misses due to ordering differences.\n set req.url = boltsort.sort(req.url);\n\n\n#FASTLY recv\n\n\n # We want to Force SSL for the WebUI by redirecting to the HTTPS version of\n # the page, however for API calls we want to return an error code directing\n # people to instead use HTTPS.\n if (!req.http.Fastly-SSL) {\n\n # The \/simple\/ and \/packages\/ API.\n if (req.url ~ \"^\/(simple|packages)\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy JSON API.\n if (req.url ~ \"^\/pypi\/.+\/json$\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy ?:action= API.\n if (req.url ~ \"^\/pypi.*(\\?|&)=:action\") {\n error 803 \"SSL is required\";\n }\n\n # If we're on the \/pypi page and we've received something other than a\n # GET or HEAD request, then we have no way to determine if a particular\n # request is an API call or not because it'll be in the request body\n # and that isn't available to us here. So in those cases, we won't\n # do a redirect.\n if (req.url ~ \"^\/pypi\") {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n error 801 \"Force SSL\";\n }\n }\n else {\n # This isn't a \/pypi URL so we'll just unconditionally redirect to\n # HTTPS.\n error 801 \"Force SSL\";\n }\n }\n\n # Canonicalize our domains by redirecting any domain that doesn't match our\n # primary domain to our primary domain. We do this *after* the HTTPS check\n # on purpose.\n if (std.tolower(req.http.host) != std.tolower(req.http.Primary-Domain)) {\n set req.http.Location = \"https:\/\/\" req.http.Primary-Domain req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n\n # Requests to \/packages\/ get dispatched to Amazon instead of to our typical\n # Origin. This requires a a bit of setup to make it work.\n if (req.url ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\") {\n # Setup our environment to better match what S3 expects\/needs\n set req.http.Host = req.http.AWS-Bucket-Name \".s3.amazonaws.com\";\n set req.http.Date = now;\n set req.url = regsuball(req.url, \"\\+\", urlencode(\"+\"));\n\n # Compute the Authorization header that S3 requires to be able to\n # access the files stored there.\n set req.http.Authorization = \"AWS \" req.http.AWS-Access-Key-ID \":\" digest.hmac_sha1_base64(req.http.AWS-Secret-Access-Key, \"GET\" LF LF LF req.http.Date LF \"\/\" req.http.AWS-Bucket-Name req.url.path);\n\n # We don't want to send our Warehouse-Token to S3, so we'll go ahead\n # and remove it.\n unset req.http.Warehouse-Token;\n }\n\n # We no longer need any of these variables, which would exist only to\n # shuffle configuration from the Fastly UI into our VCL.\n unset req.http.Primary-Domain;\n unset req.http.AWS-Access-Key-ID;\n unset req.http.AWS-Secret-Access-Key;\n unset req.http.AWS-Bucket-Name;\n\n # We have a number of items that we'll pass back to the origin, but only\n # if we have a Warehouse-Token that will allow them to be accepted.\n if (req.http.Warehouse-Token) {\n # Set a header to tell the backend if we're using https or http.\n if (req.http.Fastly-SSL) {\n set req.http.Warehouse-Proto = \"https\";\n } else {\n set req.http.Warehouse-Proto = \"http\";\n }\n\n # Pass the client IP address back to the backend.\n if (req.http.Fastly-Client-IP) {\n set req.http.Warehouse-IP = req.http.Fastly-Client-IP;\n }\n\n # Pass the real host value back to the backend.\n if (req.http.Host) {\n set req.http.Warehouse-Host = req.http.host;\n }\n }\n\n # On a POST, we want to skip the shielding and hit backends directly.\n if (req.request == \"POST\") {\n set req.backend = F_Heroku;\n }\n\n # Do not bother to attempt to run the caching mechanisms for methods that\n # are not generally safe to cache.\n if (req.request != \"HEAD\" &&\n req.request != \"GET\" &&\n req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n # We don't ever want to cache our health URL. Outside systems should be\n # able to use it to reach past Fastly and get an end to end health check.\n if (req.url == \"\/_health\/\") {\n return(pass);\n }\n\n # Finally, return the default lookup action.\n return(lookup);\n}\n\n\nsub vcl_fetch {\n\n # These are newer kinds of redirects which should be able to be cached by\n # default, even though Fastly doesn't currently have them in their default\n # list of cacheable status codes.\n if (http_status_matches(beresp.status, \"303,307,308\")) {\n set beresp.cacheable = true;\n }\n\n # For any 5xx status code we want to see if a stale object exists for it,\n # if so we'll go ahead and serve it.\n if (beresp.status >= 500 && beresp.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n\n#FASTLY fetch\n\n\n # Trigger a \"SSL is required\" error if the backend has indicated to do so.\n if (beresp.http.X-Fastly-Error == \"803\") {\n error 803 \"SSL is required\";\n }\n\n # If we've gotten a 502 or a 503 from the backend, we'll go ahead and retry\n # the request.\n if ((beresp.status == 502 || beresp.status == 503) &&\n req.restarts < 1 &&\n (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n # If we've restarted, then we'll record the number of restarts.\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n # If there is a Set-Cookie header, we'll ensure that we do not cache the\n # response.\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n # If the response has the private Cache-Control directive then we won't\n # cache it.\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # If we've gotten an error after the restarts we'll deliver the response\n # with a very short cache time.\n if (http_status_matches(beresp.status, \"500,502,503\")) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n # Apply a default TTL if there isn't a max-age or s-maxage.\n if (beresp.http.Expires ||\n beresp.http.Surrogate-Control ~ \"max-age\" ||\n beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # Keep the ttl here\n }\n else {\n # Apply the default ttl\n set beresp.ttl = 60s;\n }\n\n # Actually deliver the fetched response.\n return(deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n # If the object we have isn't cacheable, then just serve it directly\n # without going through any of the caching mechanisms.\n if (!obj.cacheable) {\n return(pass);\n }\n\n return(deliver);\n}\n\n\nsub vcl_deliver {\n # If this is an error and we have a stale response available, restart so\n # that we can pick it up and serve it.\n if (resp.status >= 500 && resp.status < 600) {\n if (stale.exists) {\n restart;\n }\n }\n\n#FASTLY deliver\n\n # Unset headers that we don't need\/want to send on to the client because\n # they are not generally useful.\n unset resp.http.Server;\n unset resp.http.Via;\n\n # Unset a few headers set by Amazon that we don't really have a need\/desire\n # to send to clients.\n unset resp.http.X-AMZ-Replication-Status;\n unset resp.http.X-AMZ-Meta-Python-Version;\n unset resp.http.X-AMZ-Meta-Version;\n unset resp.http.X-AMZ-Meta-Package-Type;\n unset resp.http.X-AMZ-Meta-Project;\n\n # Set our standard security headers, we do this in VCL rather than in\n # Warehouse itself so that we always get these headers, regardless of the\n # origin server being used.\n set resp.http.Strict-Transport-Security = \"max-age=31536000; includeSubDomains; preload\";\n set resp.http.X-Frame-Options = \"deny\";\n set resp.http.X-XSS-Protection = \"1; mode=block\";\n set resp.http.X-Content-Type-Options = \"nosniff\";\n set resp.http.X-Permitted-Cross-Domain-Policies = \"none\";\n\n return(deliver);\n}\n\n\nsub vcl_error {\n#FASTLY error\n\n # If we have a 5xx error and there is a stale object available, then we\n # will deliver that stale object.\n if (obj.status >= 500 && obj.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n if (obj.status == 803) {\n set obj.status = 403;\n set obj.response = \"SSL is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic {\"SSL is required.\"};\n return (deliver);\n } else if (obj.status == 750) {\n set obj.status = 301;\n set obj.http.Location = req.http.Location;\n set obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n synthetic {\"<html><head><title>301 Moved Permanently<\/title><\/head><body><center><h1>301 Moved Permanently<\/h1><\/center><\/body><\/html>\"};\n return(deliver);\n }\n\n}\n","old_contents":"\nsub vcl_recv {\n\n # I'm not 100% sure on what this is exactly for, it was taken from the\n # Fastly documentation, however, what I *believe* it does is just ensure\n # that we don't serve a stale copy of the page from the shield node when\n # an edge node is requesting content.\n if (req.http.Fastly-FF) {\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Some (Older) clients will send a hash fragment as part of the URL even\n # though that is a local only modification. This breaks this badly for the\n # files in S3, and in general it's just not needed.\n set req.url = regsub(req.url, \"#.*$\", \"\");\n\n # Most of the URLs in Warehouse do not support or require any sort of query\n # parameter. If we strip these at the edge then we'll increase our cache\n # efficiency when they won't otherwise change the output of the pages.\n #\n # This will match any URL except those that start with:\n #\n # * \/search\/\n # * \/account\/login\/\n # * \/account\/logout\/\n # * \/account\/register\/\n # * \/pypi\n if (req.url !~ \"^\/(search\/|account\/(login|logout|register)\/|pypi)\") {\n set req.url = req.url.path;\n }\n\n # Sort all of our query parameters, this will ensure that the same query\n # parameters in a different order will end up being represented as the same\n # thing, reducing cache misses due to ordering differences.\n set req.url = boltsort.sort(req.url);\n\n\n#FASTLY recv\n\n\n # We want to Force SSL for the WebUI by redirecting to the HTTPS version of\n # the page, however for API calls we want to return an error code directing\n # people to instead use HTTPS.\n if (!req.http.Fastly-SSL) {\n\n # The \/simple\/ and \/packages\/ API.\n if (req.url ~ \"^\/(simple|packages)\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy JSON API.\n if (req.url ~ \"^\/pypi\/.+\/json$\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy ?:action= API.\n if (req.url ~ \"^\/pypi.*(\\?|&)=:action\") {\n error 803 \"SSL is required\";\n }\n\n # If we're on the \/pypi page and we've received something other than a\n # GET or HEAD request, then we have no way to determine if a particular\n # request is an API call or not because it'll be in the request body\n # and that isn't available to us here. So in those cases, we won't\n # do a redirect.\n if (req.url ~ \"^\/pypi\") {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n error 801 \"Force SSL\";\n }\n }\n else {\n # This isn't a \/pypi URL so we'll just unconditionally redirect to\n # HTTPS.\n error 801 \"Force SSL\";\n }\n }\n\n # Canonicalize our domains by redirecting any domain that doesn't match our\n # primary domain to our primary domain. We do this *after* the HTTPS check\n # on purpose.\n if (std.tolower(req.http.host) != std.tolower(req.http.Primary-Domain)) {\n set req.http.Location = \"https:\/\/\" req.http.Primary-Domain req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n\n # Requests to \/packages\/ get dispatched to Amazon instead of to our typical\n # Origin. This requires a a bit of setup to make it work.\n if (req.url ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\") {\n # Setup our environment to better match what S3 expects\/needs\n set req.http.Host = req.http.AWS-Bucket-Name \".s3.amazonaws.com\";\n set req.http.Date = now;\n set req.url = regsuball(req.url, \"\\+\", urlencode(\"+\"));\n\n # Compute the Authorization header that S3 requires to be able to\n # access the files stored there.\n set req.http.Authorization = \"AWS \" req.http.AWS-Access-Key-ID \":\" digest.hmac_sha1_base64(req.http.AWS-Secret-Access-Key, \"GET\" LF LF LF req.http.Date LF \"\/\" req.http.AWS-Bucket-Name req.url.path);\n\n # We don't want to send our Warehouse-Token to S3, so we'll go ahead\n # and remove it.\n unset req.http.Warehouse-Token;\n }\n\n # We no longer need any of these variables, which would exist only to\n # shuffle configuration from the Fastly UI into our VCL.\n unset req.http.Primary-Domain;\n unset req.http.AWS-Access-Key-ID;\n unset req.http.AWS-Secret-Access-Key;\n unset req.http.AWS-Bucket-Name;\n\n # We have a number of items that we'll pass back to the origin, but only\n # if we have a Warehouse-Token that will allow them to be accepted.\n if (req.http.Warehouse-Token) {\n # Set a header to tell the backend if we're using https or http.\n if (req.http.Fastly-SSL) {\n set req.http.Warehouse-Proto = \"https\";\n } else {\n set req.http.Warehouse-Proto = \"http\";\n }\n\n # Pass the client IP address back to the backend.\n if (req.http.Fastly-Client-IP) {\n set req.http.Warehouse-IP = req.http.Fastly-Client-IP;\n }\n\n # Pass the real host value back to the backend.\n if (req.http.Host) {\n set req.http.Warehouse-Host = req.http.Host;\n }\n }\n\n # On a POST, we want to skip the shielding and hit backends directly.\n if (req.request == \"POST\") {\n set req.backend = F_Heroku;\n }\n\n # Do not bother to attempt to run the caching mechanisms for methods that\n # are not generally safe to cache.\n if (req.request != \"HEAD\" &&\n req.request != \"GET\" &&\n req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n # We don't ever want to cache our health URL. Outside systems should be\n # able to use it to reach past Fastly and get an end to end health check.\n if (req.url == \"\/_health\/\") {\n return(pass);\n }\n\n # Finally, return the default lookup action.\n return(lookup);\n}\n\n\nsub vcl_fetch {\n\n # These are newer kinds of redirects which should be able to be cached by\n # default, even though Fastly doesn't currently have them in their default\n # list of cacheable status codes.\n if (http_status_matches(beresp.status, \"303,307,308\")) {\n set beresp.cacheable = true;\n }\n\n # For any 5xx status code we want to see if a stale object exists for it,\n # if so we'll go ahead and serve it.\n if (beresp.status >= 500 && beresp.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n\n#FASTLY fetch\n\n\n # Trigger a \"SSL is required\" error if the backend has indicated to do so.\n if (beresp.http.X-Fastly-Error == \"803\") {\n error 803 \"SSL is required\";\n }\n\n # If we've gotten a 502 or a 503 from the backend, we'll go ahead and retry\n # the request.\n if ((beresp.status == 502 || beresp.status == 503) &&\n req.restarts < 1 &&\n (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n # If we've restarted, then we'll record the number of restarts.\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n # If there is a Set-Cookie header, we'll ensure that we do not cache the\n # response.\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n # If the response has the private Cache-Control directive then we won't\n # cache it.\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # If we've gotten an error after the restarts we'll deliver the response\n # with a very short cache time.\n if (http_status_matches(beresp.status, \"500,502,503\")) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n # Apply a default TTL if there isn't a max-age or s-maxage.\n if (beresp.http.Expires ||\n beresp.http.Surrogate-Control ~ \"max-age\" ||\n beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # Keep the ttl here\n }\n else {\n # Apply the default ttl\n set beresp.ttl = 60s;\n }\n\n # Actually deliver the fetched response.\n return(deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n # If the object we have isn't cacheable, then just serve it directly\n # without going through any of the caching mechanisms.\n if (!obj.cacheable) {\n return(pass);\n }\n\n return(deliver);\n}\n\n\nsub vcl_deliver {\n # If this is an error and we have a stale response available, restart so\n # that we can pick it up and serve it.\n if (resp.status >= 500 && resp.status < 600) {\n if (stale.exists) {\n restart;\n }\n }\n\n#FASTLY deliver\n\n # Unset headers that we don't need\/want to send on to the client because\n # they are not generally useful.\n unset resp.http.Server;\n unset resp.http.Via;\n\n # Unset a few headers set by Amazon that we don't really have a need\/desire\n # to send to clients.\n unset resp.http.X-AMZ-Replication-Status;\n unset resp.http.X-AMZ-Meta-Python-Version;\n unset resp.http.X-AMZ-Meta-Version;\n unset resp.http.X-AMZ-Meta-Package-Type;\n unset resp.http.X-AMZ-Meta-Project;\n\n # Set our standard security headers, we do this in VCL rather than in\n # Warehouse itself so that we always get these headers, regardless of the\n # origin server being used.\n set resp.http.Strict-Transport-Security = \"max-age=31536000; includeSubDomains; preload\";\n set resp.http.X-Frame-Options = \"deny\";\n set resp.http.X-XSS-Protection = \"1; mode=block\";\n set resp.http.X-Content-Type-Options = \"nosniff\";\n set resp.http.X-Permitted-Cross-Domain-Policies = \"none\";\n\n return(deliver);\n}\n\n\nsub vcl_error {\n#FASTLY error\n\n # If we have a 5xx error and there is a stale object available, then we\n # will deliver that stale object.\n if (obj.status >= 500 && obj.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n if (obj.status == 803) {\n set obj.status = 403;\n set obj.response = \"SSL is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic {\"SSL is required.\"};\n return (deliver);\n } else if (obj.status == 750) {\n set obj.status = 301;\n set obj.http.Location = req.http.Location;\n set obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n synthetic {\"<html><head><title>301 Moved Permanently<\/title><\/head><body><center><h1>301 Moved Permanently<\/h1><\/center><\/body><\/html>\"};\n return(deliver);\n }\n\n}\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"2859c105372a39772bcbc17a7bf7148fd6fd35b5","subject":"Decode consumer key; unset secret after signature generation; minor refactors","message":"Decode consumer key; unset secret after signature generation; minor refactors\n","repos":"rhargreaves\/fastly-vcl-experiments,rhargreaves\/fastly-vcl-experiments","old_file":"oauth_sig_check.vcl","new_file":"oauth_sig_check.vcl","new_contents":"\ntable consumer_secrets {\n\t\"foo\": \"super_secret\"\n}\n\nsub vcl_recv {\n#FASTLY recv\n#DEPLOY recv\n\tset req.url = boltsort.sort(req.url);\n\tset req.http.X-Consumer-Key = urldecode(regsub(req.url, \"(?i).*oauth_consumer_key=([^&]*).*\", \"\\1\"));\n\tset req.http.X-Consumer-Secret = table.lookup(consumer_secrets, req.http.X-Consumer-Key);\n\tset req.http.X-Provided-Signature = urldecode(regsub(req.url, \"(?i).*oauth_signature=([^&]*).*\", \"\\1\"));\n\tset req.http.X-Parameters = regsub(regsub(req.url, \".*\\?\", \"\"), \"&oauth_signature=[^&]*\", \"\");\n\tset req.http.X-Base-String-Uri = \n\t\tif(req.http.Fastly-SSL, \"https\", \"http\") \n\t\t\":\/\/\"\n\t\tstd.tolower(req.http.host)\n\t\treq.url.path;\n\n\t# Construct according to https:\/\/tools.ietf.org\/html\/rfc5849#page-18\n\tset req.http.X-Signature-Base-String = \n\t\treq.request\n\t\t\"&\"\n\t\turlencode(req.http.X-Base-String-Uri)\n\t\t\"&\"\n\t\turlencode(req.http.X-Parameters);\n\n\tset req.http.X-Calculated-Signature = digest.hmac_sha1_base64(\n\t\treq.http.X-Consumer-Secret \"&\", req.http.X-Signature-Base-String);\n\n\tunset req.http.X-Consumer-Secret;\n\tunset req.http.X-Base-String-Uri;\n\n\tif(req.http.X-Provided-Signature != req.http.X-Calculated-Signature) {\n\t\terror 401 \"Invalid OAuth signature\";\n\t}\n\n\n\treturn(lookup);\n}\n\nsub vcl_fetch {\n#FASTLY fetch\n\treturn(deliver);\n}\n\nsub vcl_hit {\n#FASTLY hit\n\tif (!obj.cacheable) {\n\t\treturn(pass);\n\t}\n\treturn(deliver);\n}\n\nsub vcl_miss {\n#FASTLY miss\n\treturn(fetch);\n}\n\nsub vcl_deliver{\n#FASTLY deliver\n\tset resp.http.X-Consumer-Key = req.http.X-Consumer-Key;\n\tset resp.http.X-Provided-Signature = req.http.X-Provided-Signature;\n\tset resp.http.X-Calculated-Signature = req.http.X-Calculated-Signature;\n\tset resp.http.X-Parameters = req.http.X-Parameters;\n\tset resp.http.X-Signature-Base-String = req.http.X-Signature-Base-String;\n\treturn(deliver);\n}\n\nsub vcl_error {\n#FASTLY error\n#DEPLOY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n","old_contents":"\ntable consumer_secrets {\n\t\"foo\": \"super_secret\"\n}\n\nsub vcl_recv {\n#FASTLY recv\n#DEPLOY recv\n\tset req.url = boltsort.sort(req.url);\n\tset req.http.X-Consumer-Key = regsub(req.url, \"(?i).*oauth_consumer_key=([^&]*).*\", \"\\1\");\n\tset req.http.X-Consumer-Secret = table.lookup(consumer_secrets, req.http.X-Consumer-Key);\n\tset req.http.X-Provided-Signature = regsub(req.url, \"(?i).*oauth_signature=([^&]*).*\", \"\\1\");\n\tset req.http.X-Parameters = regsub(req.url, \".*\\?\", \"\");\n\tset req.http.X-Parameters = regsub(req.http.X-Parameters, \"&oauth_signature=[^&]*\", \"\");\n\t\n\tset req.http.X-Base-String-Uri = \n\t\tif(req.http.Fastly-SSL,\"https\",\"http\") \n\t\t\":\/\/\" \n\t\tstd.tolower(req.http.host)\n\t\treq.url.path;\n\n\t# Construct according to https:\/\/tools.ietf.org\/html\/rfc5849#page-18\n\tset req.http.X-Signature-Base-String = \n\t\treq.request\n\t\t\"&\"\n\t\turlencode(req.http.X-Base-String-Uri)\n\t\t\"&\"\n\t\turlencode(req.http.X-Parameters);\n\n\tset req.http.X-Calculated-Signature = urlencode(digest.hmac_sha1_base64(\n\t\treq.http.X-Consumer-Secret \"&\", req.http.X-Signature-Base-String));\n\n\tif(req.http.X-Provided-Signature != req.http.X-Calculated-Signature) {\n\t\terror 401 \"Invalid OAuth signature\";\n\t}\n\n\n\treturn(lookup);\n}\n\nsub vcl_fetch {\n#FASTLY fetch\n\treturn(deliver);\n}\n\nsub vcl_hit {\n#FASTLY hit\n\tif (!obj.cacheable) {\n\t\treturn(pass);\n\t}\n\treturn(deliver);\n}\n\nsub vcl_miss {\n#FASTLY miss\n\treturn(fetch);\n}\n\nsub vcl_deliver{\n#FASTLY deliver\n\tset resp.http.X-Consumer-Key = req.http.X-Consumer-Key;\n\tset resp.http.X-Consumer-Secret = req.http.X-Consumer-Secret;\n\tset resp.http.X-Provided-Signature = req.http.X-Provided-Signature;\n\tset resp.http.X-Calculated-Signature = req.http.X-Calculated-Signature;\n\tset resp.http.X-Parameters = req.http.X-Parameters;\n\tset resp.http.X-Base-String-Uri = req.http.X-Base-String-Uri;\n\tset resp.http.X-Signature-Base-String = req.http.X-Signature-Base-String;\n\treturn(deliver);\n}\n\nsub vcl_error {\n#FASTLY error\n#DEPLOY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"fe774ddc91410112deb023f103d688133547fc2b","subject":"Enable load-balancing logic for qa service (#1191)","message":"Enable load-balancing logic for qa service (#1191)\n\n","repos":"kdzwinel\/polyfill-service,kdzwinel\/polyfill-service,mcshaz\/polyfill-service,mcshaz\/polyfill-service,JakeChampion\/polyfill-service,kdzwinel\/polyfill-service,mcshaz\/polyfill-service,JakeChampion\/polyfill-service","old_file":"vcl\/main.vcl","new_file":"vcl\/main.vcl","new_contents":"import boltsort;\n\nsub vcl_recv {\n#FASTLY recv\n\n\t# Enable API key authentication for URL purge requests\n\tif ( req.request == \"FASTLYPURGE\" ) {\n\t\tset req.http.Fastly-Purge-Requires-Auth = \"1\";\n\t}\n\n\tif (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n\t\treturn(pass);\n\t}\n\n\tif (req.http.Host ~ \"polyfills.io\") {\n\t\t# Do the canonicalise check before the SSL check to avoid a double redirect\n\t\terror 751 \"Canonicalise\";\n\t}\n\n\tif (!req.http.Fastly-SSL) {\n\t\t# 801 is a special error code that Fastly uses to Force SSL on the request\n\t\terror 801 \"Redirect to prod HTTPS\";\n\t}\n\n\tif (req.url ~ \"^\/v2\/(polyfill\\.|recordRumData)\" && req.url !~ \"[\\?\\&]ua=\") {\n\t\tset req.http.X-Orig-URL = req.url;\n\t\tset req.url = \"\/v2\/normalizeUa?ua=\" urlencode(req.http.User-Agent);\n\t}\n\n\tif (req.url ~ \"^\/v2\/recordRumData\" && req.http.Normalized-User-Agent) {\n\t\tset req.http.Log = regsub(req.url, \"^.*?\\?(.*)$\", \"\\1\") \"&ip=\" client.ip \"&refer_domain=\" regsub(req.http.Referer, \"^(https?\\:\\\/\\\/)?(www\\.)?(.+?)(\\:\\d+)?([\\\/\\?].*)?$\", \"\\3\") \"&country=\" geoip.country_code \"&data_center=\" if(req.http.Cookie:FastlyDC, req.http.Cookie:FastlyDC, server.datacenter);\n\t\terror 204 \"No Content\";\n\t}\n\n\tset req.url = boltsort.sort(req.url);\n\n\tif (req.restarts == 0) {\n\t\tset req.http.X-Original-Host = req.http.Host;\n\n\t\tif (req.http.Host == \"qa.polyfill.io\") {\n\t\t\tif (req.http.X-Geoip-Continent ~ \"(NA|SA|OC|AS)\") {\n\t\t\t\tset req.backend = origami_polyfill_service_us;\n\t\t\t\tset req.http.Host = \"ft-polyfill-service-us-qa.herokuapp.com\";\n\n\t\t\t\tif (!req.backend.healthy) {\n\t\t\t\t\tset req.backend = origami_polyfill_service_eu;\n\t\t\t\t\tset req.http.Host = \"ft-polyfill-service-qa.herokuapp.com\";\n\t\t\t\t}\n\n\t\t\t} else {\n\t\t\t\tset req.backend = origami_polyfill_service_eu;\n\t\t\t\tset req.http.Host = \"ft-polyfill-service-qa.herokuapp.com\";\n\n\t\t\t\tif (!req.backend.healthy) {\n\t\t\t\t\tset req.backend = origami_polyfill_service_us;\n\t\t\t\t\tset req.http.Host = \"ft-polyfill-service-us-qa.herokuapp.com\";\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tif (req.http.X-Geoip-Continent ~ \"(NA|SA|OC|AS)\") {\n\t\t\t\tset req.backend = origami_polyfill_service_us;\n\t\t\t\tset req.http.Host = \"ft-polyfill-service-us.herokuapp.com\";\n\n\t\t\t\tif (!req.backend.healthy) {\n\t\t\t\t\tset req.backend = origami_polyfill_service_eu;\n\t\t\t\t\tset req.http.Host = \"ft-polyfill-service.herokuapp.com\";\n\t\t\t\t}\n\n\t\t\t} else {\n\t\t\t\tset req.backend = origami_polyfill_service_eu;\n\t\t\t\tset req.http.Host = \"ft-polyfill-service.herokuapp.com\";\n\n\t\t\t\tif (!req.backend.healthy) {\n\t\t\t\t\tset req.backend = origami_polyfill_service_us;\n\t\t\t\t\tset req.http.Host = \"ft-polyfill-service-us.herokuapp.com\";\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t# https:\/\/community.fastly.com\/t\/brotli-compression-support\/578\/6\n\tif (req.http.Fastly-Orig-Accept-Encoding) {\n\t\tif (req.http.User-Agent ~ \"MSIE 6\") {\n\t\t\t# For that 0.3% of stubborn users out there\n\t\t\tunset req.http.Accept-Encoding;\n\t\t} elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"br\") {\n\t\t\tset req.http.Accept-Encoding = \"br\";\n\t\t} elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"gzip\") {\n\t\t\tset req.http.Accept-Encoding = \"gzip\";\n\t\t} else {\n\t\t\tunset req.http.Accept-Encoding;\n\t\t}\n\t}\n\n\treturn(lookup);\n}\n\nsub vcl_deliver {\n#FASTLY deliver\n\n\t# If the response is to a normalise request and there's a parked \"original request\", use the normalised UA response to modify the original request and restart it\n\tif (req.url ~ \"^\/v\\d\/normalizeUa\" && resp.status == 200 && req.http.X-Orig-URL ~ \"^\/v2\/(polyfill\\.|recordRumData)\") {\n\t\tset req.http.Fastly-force-Shield = \"1\";\n\t\tset req.http.Normalized-User-Agent = resp.http.Normalized-User-Agent;\n\t\tif (req.http.X-Orig-URL ~ \"\\?\") {\n\t\t\tset req.url = req.http.X-Orig-URL \"&ua=\" resp.http.Normalized-User-Agent;\n\t\t} else {\n\t\t\tset req.url = req.http.X-Orig-URL \"?ua=\" resp.http.Normalized-User-Agent;\n\t\t}\n\t\trestart;\n\n\t# If the original request didn't specify a UA override, and we added one when the request was sent to the backend, the backend won't have included a Vary:user-agent header (correctly) but we need to add one\n\t} else if (req.url ~ \"^\/v\\d\/polyfill\\..*[\\?\\&]ua=\" && req.http.X-Orig-URL && req.http.X-Orig-URL !~ \"[\\?\\&]ua=\") {\n\t\tadd resp.http.Vary = \"User-Agent\";\n\t}\n\n\tif (req.url ~ \"[\\&\\?]rum=1\") {\n\t\tadd resp.http.Set-Cookie = \"FastlyDC=\" server.datacenter \"; Path=\/; HttpOnly; max-age=60\";\n\t}\n\n\tif (req.http.Fastly-Debug) {\n\t\tset resp.http.Debug-Host = req.http.Host;\n\t\tset resp.http.Debug-X-Original-Host = req.http.X-Original-Host;\n\t}\n\n\treturn(deliver);\n}\n\nsub vcl_error {\n#FASTLY error\n\n\t# Redirect to canonical prod\/qa origins\n\tif (obj.status == 751) {\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\tset obj.http.Location = \"https:\/\/polyfill.io\" req.url;\n\t\tsynthetic {\"\"};\n\t\treturn (deliver);\n\t}\n}\n","old_contents":"import boltsort;\n\nsub vcl_recv {\n#FASTLY recv\n\n\t# Enable API key authentication for URL purge requests\n\tif ( req.request == \"FASTLYPURGE\" ) {\n\t\tset req.http.Fastly-Purge-Requires-Auth = \"1\";\n\t}\n\n\tif (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n\t\treturn(pass);\n\t}\n\n\tif (req.http.Host ~ \"polyfills.io\") {\n\t\t# Do the canonicalise check before the SSL check to avoid a double redirect\n\t\terror 751 \"Canonicalise\";\n\t}\n\n\tif (!req.http.Fastly-SSL) {\n\t\t# 801 is a special error code that Fastly uses to Force SSL on the request\n\t\terror 801 \"Redirect to prod HTTPS\";\n\t}\n\n\n\tif (req.url ~ \"^\/v2\/(polyfill\\.|recordRumData)\" && req.url !~ \"[\\?\\&]ua=\") {\n\t\tset req.http.X-Orig-URL = req.url;\n\t\tset req.url = \"\/v2\/normalizeUa?ua=\" urlencode(req.http.User-Agent);\n\t}\n\n\tif (req.url ~ \"^\/v2\/recordRumData\" && req.http.Normalized-User-Agent) {\n\t\tset req.http.Log = regsub(req.url, \"^.*?\\?(.*)$\", \"\\1\") \"&ip=\" client.ip \"&refer_domain=\" regsub(req.http.Referer, \"^(https?\\:\\\/\\\/)?(www\\.)?(.+?)(\\:\\d+)?([\\\/\\?].*)?$\", \"\\3\") \"&country=\" geoip.country_code \"&data_center=\" if(req.http.Cookie:FastlyDC, req.http.Cookie:FastlyDC, server.datacenter);\n\t\terror 204 \"No Content\";\n\t}\n\n\tset req.url = boltsort.sort(req.url);\n\n\tdeclare local var.isQA BOOL;\n\n\tset var.isQA = (req.http.host == \"qa.polyfill.io\");\n\n\tif (req.http.X-Geoip-Continent ~ \"(NA|SA|OC|AS)\") {\n\t\tset req.backend = origami_polyfill_service_us;\n\t\tset req.http.Host = \"ft-polyfill-service-us.herokuapp.com\";\n\n\t\tif (!req.backend.healthy) {\n\t\t\tset req.backend = origami_polyfill_service_eu;\n\t\t\tset req.http.Host = \"ft-polyfill-service.herokuapp.com\";\n\t\t}\n\n\t} else {\n\t\tset req.backend = origami_polyfill_service_eu;\n\t\tset req.http.Host = \"ft-polyfill-service.herokuapp.com\";\n\n\t\tif (!req.backend.healthy) {\n\t\t\tset req.backend = origami_polyfill_service_us;\n\t\t\tset req.http.Host = \"ft-polyfill-service-us.herokuapp.com\";\n\t\t}\n\t}\n\n\tif (var.isQA) {\n\t\tif (req.backend == origami_polyfill_service_us) {\n\t\t\tset req.http.Host = \"ft-polyfill-service-us-qa.herokuapp.com\";\n\t\t} else {\n\t\t\tset req.http.Host = \"ft-polyfill-service-qa.herokuapp.com\";\n\t\t}\n\t}\n\n\t# https:\/\/community.fastly.com\/t\/brotli-compression-support\/578\/6\n\tif (req.http.Fastly-Orig-Accept-Encoding) {\n\t\tif (req.http.User-Agent ~ \"MSIE 6\") {\n\t\t\t# For that 0.3% of stubborn users out there\n\t\t\tunset req.http.Accept-Encoding;\n\t\t} elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"br\") {\n\t\t\tset req.http.Accept-Encoding = \"br\";\n\t\t} elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"gzip\") {\n\t\t\tset req.http.Accept-Encoding = \"gzip\";\n\t\t} else {\n\t\t\tunset req.http.Accept-Encoding;\n\t\t}\n\t}\n\n\treturn(lookup);\n}\n\nsub vcl_deliver {\n#FASTLY deliver\n\n\t# If the response is to a normalise request and there's a parked \"original request\", use the normalised UA response to modify the original request and restart it\n\tif (req.url ~ \"^\/v\\d\/normalizeUa\" && resp.status == 200 && req.http.X-Orig-URL ~ \"^\/v2\/(polyfill\\.|recordRumData)\") {\n\t\tset req.http.Fastly-force-Shield = \"1\";\n\t\tset req.http.Normalized-User-Agent = resp.http.Normalized-User-Agent;\n\t\tif (req.http.X-Orig-URL ~ \"\\?\") {\n\t\t\tset req.url = req.http.X-Orig-URL \"&ua=\" resp.http.Normalized-User-Agent;\n\t\t} else {\n\t\t\tset req.url = req.http.X-Orig-URL \"?ua=\" resp.http.Normalized-User-Agent;\n\t\t}\n\t\trestart;\n\n\t# If the original request didn't specify a UA override, and we added one when the request was sent to the backend, the backend won't have included a Vary:user-agent header (correctly) but we need to add one\n\t} else if (req.url ~ \"^\/v\\d\/polyfill\\..*[\\?\\&]ua=\" && req.http.X-Orig-URL && req.http.X-Orig-URL !~ \"[\\?\\&]ua=\") {\n\t\tadd resp.http.Vary = \"User-Agent\";\n\t}\n\n\tif (req.url ~ \"[\\&\\?]rum=1\") {\n\t\tadd resp.http.Set-Cookie = \"FastlyDC=\" server.datacenter \"; Path=\/; HttpOnly; max-age=60\";\n\t}\n\n\tif (req.http.Fastly-Debug) {\n\t\tset resp.http.Debug-Host = req.http.Host;\n\t}\n\n\treturn(deliver);\n}\n\nsub vcl_error {\n#FASTLY error\n\n\t# Redirect to canonical prod\/qa origins\n\tif (obj.status == 751) {\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\tset obj.http.Location = \"https:\/\/polyfill.io\" req.url;\n\t\tsynthetic {\"\"};\n\t\treturn (deliver);\n\t}\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"5b3593d0f048b5f8b8d9e0b57a5612d8c742099b","subject":"Set TTL to 0 if there are no TTL headers from origin","message":"Set TTL to 0 if there are no TTL headers from origin\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets\/fetch.vcl","new_file":"etc\/vcl_snippets\/fetch.vcl","new_contents":" \/* handle 5XX (or any other unwanted status code) *\/\n if (beresp.status >= 500 && beresp.status < 600) {\n\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n \/* deliver stale if the object is available *\/\n if (stale.exists) {\n return(deliver_stale);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n \/* else go to vcl_error to deliver a synthetic *\/\n error beresp.status beresp.response;\n }\n\n # Remove Set-Cookies from responses for static content\n # to match the cookie removal in recv.\n if (req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's since those can be temporary during the site build\/index\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n }\n\n }\n\n if (beresp.http.Content-Type ~ \"text\/(html|xml)\") {\n # enable ESI feature for Magento response by default\n esi;\n if (!beresp.http.Vary ~ \"X-Magento-Vary,Https\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \",X-Magento-Vary,Https\";\n } else {\n set beresp.http.Vary = \"X-Magento-Vary,Https\";\n }\n }\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content\n if (http_status_matches(beresp.status, \"200,404\") && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url.ext ~ \"(?i)(css|js|html|eot|ico|otf|ttf|json)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n if (beresp.http.Cache-Control ~ \"private|no-cache|no-store\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # Never cache 302s\n if (beresp.status == 302) {\n return (pass);\n }\n\n # Just in case the Request Setting for x-pass is missing\n if (req.http.x-pass) {\n return (pass);\n }\n\n # Varnish sets default TTL if none of these are present\n if (!beresp.http.Expires && !beresp.http.Surrogate-Control ~ \"max-age\" && !beresp.http.Cache-Control ~ \"(s-maxage|max-age)\") {\n set beresp.ttl = 0s;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\") && !req.http.x-pass ) {\n unset beresp.http.set-cookie;\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type if they are image\/script or CSS\n if (beresp.http.Content-Type ~ \"(image|script|css)\") {\n set beresp.http.Surrogate-Key = re.group.1;\n }\n return (deliver);\n }\n","old_contents":" \/* handle 5XX (or any other unwanted status code) *\/\n if (beresp.status >= 500 && beresp.status < 600) {\n\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n \/* deliver stale if the object is available *\/\n if (stale.exists) {\n return(deliver_stale);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n \/* else go to vcl_error to deliver a synthetic *\/\n error beresp.status beresp.response;\n }\n\n # Remove Set-Cookies from responses for static content\n # to match the cookie removal in recv.\n if (req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's since those can be temporary during the site build\/index\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n }\n\n }\n\n if (beresp.http.Content-Type ~ \"text\/(html|xml)\") {\n # enable ESI feature for Magento response by default\n esi;\n if (!beresp.http.Vary ~ \"X-Magento-Vary,Https\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \",X-Magento-Vary,Https\";\n } else {\n set beresp.http.Vary = \"X-Magento-Vary,Https\";\n }\n }\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content\n if (http_status_matches(beresp.status, \"200,404\") && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url.ext ~ \"(?i)(css|js|html|eot|ico|otf|ttf|json)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n if (beresp.http.Cache-Control ~ \"private|no-cache|no-store\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # Never cache 302s\n if (beresp.status == 302) {\n return (pass);\n }\n\n # Just in case the Request Setting for x-pass is missing\n if (req.http.x-pass) {\n return (pass);\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\") && !req.http.x-pass ) {\n unset beresp.http.set-cookie;\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type if they are image\/script or CSS\n if (beresp.http.Content-Type ~ \"(image|script|css)\") {\n set beresp.http.Surrogate-Key = re.group.1;\n }\n return (deliver);\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"8cdfbbf6415695c26f7b6ce2c68276b955d1015e","subject":"correct health return message","message":"correct health return message\n","repos":"NITEMAN\/Varnish_VCL_samps-hacks,NITEMAN\/varnish-bites","old_file":"varnish4\/drupal-base.vcl","new_file":"varnish4\/drupal-base.vcl","new_contents":"\/*\n * Varnish 4 example config for Drupal 7 \/ Pressflow 6 & 7\n *\/\n\n# Original source: https:\/\/github.com\/NITEMAN\/varnish-bites\/varnish4\/drupal-base.vcl\n# Copyright (c) 2015 Pedro Gonz\u00e1lez Serrano and individual contributors.\n# MIT License\n\n# Intended to be used both in simple production environments and with\n# learning\/teaching purposes.\n# Some references may not be yet updated to VCL 4.0, we use SeeV3 then.\n\n# WARNING:\n# Note that the built-in logic will be appended to our code if no return is\n# performed before.\n# Built-in logic is included commented out right after our's for reference\n# purposes in that cases.\n# See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleDefault\n\n#######################################################################\n# Initialization: Version & imports;\n\n\/* Version statement *\/\n# Since Varnish 4.0 it's mandatory to declare VCL version on first line.\nvcl 4.0;\n\n\/* Module (VMOD) imports *\/\n# Standard module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_std.generated.html\nimport std;\n\n# Directors module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# Unused in simple configs.\n#import directors;\n\n\n#######################################################################\n# Probe, backend, ACL and subroutine definitions\n\n\/* Backend probes \/ healthchecks *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#probes\nprobe basic {\n \/* Only test that backend's IP serves content for '\/' *\/\n # This might be a too heavy probe\n # .url = \"\/\";\n\n \/* Only test that backend's IP has apache working *\/\n # Nginx would fail this probe with a default config\n .request =\n \"OPTIONS * HTTP\/1.1\"\n \"Host: *\"\n \"Connection: close\";\n\n \/* Common options *\/\n .interval = 10s;\n .timeout = 2s;\n .window = 8;\n .threshold = 6;\n}\n\n\/* Backend definitions.*\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#backend-definition\nbackend default {\n \/* Default backend on the same machine. *\/\n # WARNING: timeouts could be not big enought for certain POST requests.\n .host = \"127.0.0.1\";\n .port = \"8008\";\n .max_connections = 100;\n .connect_timeout = 60s;\n .first_byte_timeout = 60s;\n .between_bytes_timeout = 60s;\n .probe = basic;\n}\n\n\/* Access Control Lists *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#access-control-list-acl\nacl purge_ban {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use '\"localhost\";' instead\n}\nacl allowed_monitors {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n}\n# acl own_proxys {\n# \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n# }\n\n\/* Custom subroutines *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#subroutines\n#TODO# Test in Varnihs 4\n# Empty in simple configs.\n# The only restriction naming subs is that the 'vlc_' prefix is reserverd for\n# Varnish use. As a task can need several chunks of code in diferent states,\n# it's a good idea to identify what main sub will call each with a suffix.\n# \/* Example 301 client redirection removing \"www\" prefix from request *\/\n# sub perm_redirections_recv {\n# if ( req.http.host ~ \"^www.*$\" ) {\n# return (\n# synth(751, \"http:\/\/\" + regsub(req.http.host, \"^www\\.\", \"\") + req.url)\n# );\n# }\n# }\n# sub perm_redirections_synth {\n# if ( resp.status == 751 ) {\n# \/* Get new URL from the response *\/\n# set resp.http.Location = resp.response;\n# \/* Set HTTP 301 for permanent redirect *\/\n# set resp.status = 301;\n# return (deliver);\n# }\n# }\n\n\n#######################################################################\n# Client side\n\n# vcl_recv: Called at the beginning of a request, after the complete request\n# has been received and parsed. Its purpose is to decide whether or not to\n# serve the request, how to do it, and, if applicable, which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-recv\nsub vcl_recv {\n \/* 0th: general bypass, general return & authorization checks *\/\n # Empty in simple configs.\n # Useful for debugging we can pipe or pass the request to default backend\n # here to bypass completely Varnish.\n # return (pipe);\n # return (pass);\n # We can also return here a 200 Ok for network performance benchmarking.\n # return (synth(200, \"Ok\"));\n # Finally we can perform basic HTTP authentification here, by example.\n # SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* 1st: Check for Varnish special requests *\/ \n # Custom response implementation example in order to check that Varnish is\n # working properly.\n # This is usefull for automatic monitoring with monit or when Varnish is\n # behind another proxies like HAProxy.\n if ( ( req.http.host == \"monitor.server.health\"\n || req.http.host == \"health.varnish\" )\n && client.ip ~ allowed_monitors\n && ( req.method == \"OPTIONS\" || req.method == \"GET\" )\n ) {\n return (synth(200, \"OK\"));\n }\n # Purge logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#http-purging\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if ( req.method == \"PURGE\" ) {\n if ( client.ip !~ purge_ban ) {\n return (synth(405, \"Not allowed.\"));\n }\n return (purge);\n }\n # Ban logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#bans\n if ( req.method == \"BAN\" ) {\n if ( client.ip !~ purge_ban ) {\n return (synth(405, \"Not allowed.\"));\n }\n ban( \"req.http.host == \" + req.http.host +\n \"&& req.url == \" + req.url);\n return (synth(200, \"Ban added\"));\n }\n\n \/* 2nd: Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_recv;\n # Here we can also enforce SSL when Varnish run behind some SSL termination\n # point.\n\n \/* 3rd: Time for backend choice *\/\n # Empty in simple configs.\n\n \/* 4th: Prepare request for the backend *\/\n # Empty in simple configs.\n # Example remove own_proxys from X-Forwarded-For\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/whats-new\/upgrading.html#x-forwarded-for-is-now-set-before-vcl-recv\n # if ( req.restarts == 0\n # && client.ip ~ own_proxys\n # && req.http.x-forwarded-for\n # ) {\n # set req.http.X-Forwarded-For\n # = regsub(req.http.X-Forwarded-For, \",( )?\" + client.ip, \"\");\n # }\n # Example normalize the host header, remove the port (in case you're testing\n # this on various TCP ports)\n # set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n \/* 5th: Bypass breakpoint 1 *\/\n # Useful for debugging we can now pipe or pass the request to backend with\n # headers setted.\n # return (pipe);\n # return (pass);\n\n \/* 6th: Decide if we should deal with a request (mostly from built-in logic) *\/\n if ( req.method == \"PRI\" ) {\n \/* We do not support SPDY or HTTP\/2.0 *\/\n return (synth(405));\n }\n if ( req.method != \"GET\"\n && req.method != \"HEAD\"\n && req.method != \"PUT\"\n && req.method != \"POST\"\n && req.method != \"TRACE\"\n && req.method != \"OPTIONS\"\n && req.method != \"DELETE\"\n ) {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if ( req.method != \"GET\"\n && req.method != \"HEAD\"\n ) {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if ( req.http.Authorization ) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n # Websocket support\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html\n if ( req.http.Upgrade ~ \"(?i)websocket\" ) {\n return (pipe);\n }\n\n \/* 7th: Access control for some URLs by ACL *\/\n # Empty in simple configs.\n # By example denial some URLs depending on client-ip, we'll need to define\n # corresponding ACL 'internal'.\n # if ( req.url ~ \"^\/(cron|install)\\.php\"\n # && client.ip !~ internal\n # ) {\n # # Have Varnish throw the error directly.\n # return (synth(403, \"Forbidden.\"));\n # # Use a custom error page that you've defined in Drupal at the path \"404\".\n # # set req.url = \"\/403\";\n # }\n\n \/* 8th: Custom exceptions *\/\n # Host exception example:\n # if ( req.http.host == \"ejemplo.exception.com\" ) {\n # return (pass);\n # }\n # Drupal exceptions, edit if we want to cache some AJAX\/AHAH request.\n # Add here filters for never cache URLs such as Payment Gateway's callbacks.\n if ( req.url ~ \"^\/status\\.php$\"\n || req.url ~ \"^\/update\\.php$\"\n || req.url ~ \"^\/ooyala\/ping$\"\n || req.url ~ \"^\/admin\/build\/features\"\n || req.url ~ \"^\/info\/.*$\"\n || req.url ~ \"^\/flag\/.*$\"\n || req.url ~ \"^.*\/ajax\/.*$\"\n || req.url ~ \"^.*\/ahah\/.*$\"\n ) {\n \/* Do not cache these paths *\/\n return (pass);\n }\n # Pipe these paths directly to backend for streaming.\n if ( req.url ~ \"^\/admin\/content\/backup_migrate\/export\" ) {\n return (pipe);\n }\n if ( req.url ~ \"^\/system\/files\" ) {\n return (pipe);\n }\n\n \/* 9th: Graced objets & Serve from anonymous cahe if all backends are down *\/\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n # set req.http.grace = \"none\";\n if ( ! std.healthy(req.backend_hint) ) {\n # We must do this here since cookie hashing\n unset req.http.Cookie;\n #TODO# Add sick marker\n } \n\n \/* 10th: Deal with compression and the Accept-Encoding header *\/\n # Althought Varnish 3 handles gziped content itself by default, just to be\n # sure we want to remove Accept-Encoding for some compressed formats.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html#what-does-http-gzip-support-do\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/varnishd.html?highlight=http_gzip_support\n # See (for older configs) https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleNormalizeAcceptEncoding\n if ( req.http.Accept-Encoding ) {\n if ( req.url ~ \"(?i)\\.(7z|avi|bz2|flv|gif|gz|jpe?g|mpe?g|mk[av]|mov|mp[34]|og[gm]|pdf|png|rar|swf|tar|tbz|tgz|woff2?|zip|xz)(\\?.*)?$\"\n ) {\n \/* Already compressed formats, no sense trying to compress again *\/\n unset req.http.Accept-Encoding;\n }\n }\n\n \/* 11th: Further request manipulation *\/\n # Empty in simple configs.\n # We could add here a custom header grouping User-agent families.\n # Generic URL manipulation.\n # Remove Google Analytics added parameters, useless for our backends.\n if ( req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=\" ) {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n # Strip anchors, server doesn't need it.\n if ( req.url ~ \"\\#\" ) {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n # Strip a trailing ? if it exists\n if ( req.url ~ \"\\?$\" ) {\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n # Normalize the querystring arguments\n set req.url = std.querysort(req.url);\n\n \/* 12th: Cookie removal *\/\n # Always cache the following static file types for all users. \n # Use with care if we control certain downloads depending on cookies. \n # Be carefull also if appending .htm[l] via Drupal's clean URLs.\n if ( req.url ~ \"(?i)\\.(bz2|css|eot|gif|gz|html?|ico|jpe?g|js|mp3|ogg|otf|pdf|png|rar|svg|swf|tbz|tgz|ttf|woff2?|zip)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n && req.url !~ \"\/system\/storage\/serve\"\n ) {\n unset req.http.Cookie;\n }\n # Remove all cookies that backend doesn't need to know about.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRemovingSomeCookies\n if ( req.http.Cookie ) {\n \/* Warning: Not a pretty solution *\/\n # Prefix header containing cookies with ';'\n set req.http.Cookie = \";\" + req.http.Cookie;\n # Remove any spaces after ';' in header containing cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n # Prefix cookies we want to preserve with one space:\n # 'S{1,2}ESS[a-z0-9]+' is the regular expression matching a Drupal session\n # cookie ({1,2} added for HTTPS support).\n # 'NO_CACHE' is usually set after a POST request to make sure issuing user\n # see the results of his post.\n # 'OATMEAL' & 'CHOCOLATECHIP' are special cookies used by Drupal's Bakery\n # module to provide Single Sign On.\n # Keep in mind we should add here any cookie that should reach the backend\n # such as splash avoiding cookies.\n set req.http.Cookie\n = regsuball(\n req.http.Cookie,\n \";(S{1,2}ESS[a-z0-9]+|NO_CACHE|OATMEAL|CHOCOLATECHIP)=\",\n \"; \\1=\"\n );\n # Remove from the header any single Cookie not prefixed with a space until\n # next ';' separator.\n set req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n # Remove any '; ' at the start or the end of the header.\n set req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n #If there are no remaining cookies, remove the cookie header.\n if ( req.http.Cookie == \"\" ) {\n unset req.http.Cookie;\n }\n }\n\n \/* 13th: Session cookie & special cookies bypass caching stage *\/\n # As we might want to cache some requests, hashed with its cookies, we don't\n # simply pass when some cookies remain present at this point.\n # Instead we look for request that must be passed due to the cookie header.\n if ( req.http.Cookie ~ \"SESS\"\n || req.http.Cookie ~ \"SSESS\"\n || req.http.Cookie ~ \"NO_CACHE\"\n || req.http.Cookie ~ \"OATMEAL\"\n || req.http.Cookie ~ \"CHOCOLATECHIP\"\n ) {\n return (pass);\n }\n\n \/* 14th: Announce ESI Support *\/\n # Empty in simple configs.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/esi.html\n # Note that ESI included requests inherits its parent's modified request, so\n # depending on the case you will end playing with req.esi_level to know\n # current depth.\n # Send Surrogate-Capability headers\n # See http:\/\/www.w3.org\/TR\/edge-arch\n # Note that myproxyname is an identifier that should avoid collitions\n # set req.http.Surrogate-Capability = \"myproxyname=ESI\/1.0\";\n\n \/* 15th: Bypass breakpoint 2 *\/\n # Useful for debugging we can now pipe or pass the request to backend to\n # bypass cache.\n # return (pipe);\n # return (pass);\n\n \/* 16th: Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n return (hash);\n}\n\n# vcl_pipe: Called upon entering pipe mode.\n# In this mode, the request is passed on to the backend, and any further data\n# from either client or backend is passed on unaltered until either end closes\n# the connection.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pipe\nsub vcl_pipe {\n # Websocket support\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html\n if ( req.http.upgrade ) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n}\n# sub vcl_pipe {\n# # By default Connection: close is set on all piped requests, to stop\n# # connection reuse from sending future requests directly to the\n# # (potentially) wrong backend. If you do want this to happen, you can undo\n# # it here.\n# # unset bereq.http.connection;\n# return (pipe);\n# }\n\n# vcl_pass: Called upon entering pass mode. \n# In this mode, the request is passed on to the backend, and the backend's\n# response is passed on to the client, but is not entered into the cache.\n# Subsequent requests submitted over the same client connection are handled normally.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pass\n# sub vcl_pass {\n# return (fetch);\n# }\n\n# vcl_hash: You may call hash_data() on the data you would like to add to the\n# hash.\n# Hash is used by Varnish to uniquely identify objects.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hash\nsub vcl_hash {\n \/* Hash cookie data *\/\n # As requests with same URL and host can produce diferent results when issued\n # with different cookies, we need to store items hashed with the associated\n # cookies. Note that cookies are already sanitized when we reach this point.\n if ( req.http.Cookie ) {\n \/* Include cookie in cache hash *\/\n hash_data(req.http.Cookie);\n }\n\n \/* Custom header hashing *\/\n # Empty in simple configs.\n # Example for caching differents object versions by device previously\n # detected (when static content could also vary):\n # if ( req.http.X-UA-Device ) {\n # hash_data(req.http.X-UA-Device);\n # }\n # Example for caching diferent object versions by X-Forwarded-Proto, trying\n # to be smart about what kind of request could generate diffetent responses.\n if ( req.http.X-Forwarded-Proto\n && req.url !~ \"(?i)\\.(bz2|css|eot|gif|gz|html?|ico|jpe?g|js|mp3|ogg|otf|pdf|png|rar|svg|swf|tbz|tgz|ttf|woff2?|zip)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n ) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (lookup);\n# }\n\n# vcl_purge: Called after the purge has been executed and all its variants have\n# been evited.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-purge\n# sub vcl_purge {\n# return (synth(200, \"Purged\"));\n# }\n\n# vcl_hit: Called after a cache lookup if the requested document was found in\n# the cache.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hit\nsub vcl_hit {\n if ( obj.ttl >= 0s ) {\n \/\/ A pure unadultered hit, deliver it\n return (deliver);\n }\n \/* Allow varnish to serve up stale content if it is responding slowly *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n if ( obj.ttl + 60s > 0s ) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n set req.http.grace = \"normal\";\n return (deliver);\n }\n \/* Allow varish to serve up stale content if all backends are down *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n if ( ! std.healthy(req.backend_hint)\n && obj.ttl + obj.grace > 0s\n ) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n set req.http.grace = \"extended\";\n return (deliver);\n }\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\n# vcl_miss: Called after a cache lookup if the requested document was not found\n# in the cache.\n# Its purpose is to decide whether or not to attempt to retrieve the document\n# from the backend, and which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-miss\n# sub vcl_miss {\n# return (fetch);\n# }\n\n# vcl_deliver: Called before an object is delivered to the client\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-deliver\nsub vcl_deliver {\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # Add whether the object is a cache hit or miss and the number of hits for\n # the object.\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Addingaheaderindicatinghitmiss\n # In Varnish 4 the obj.hits counter behaviour has changed (see bug 1492), so\n # we use a different method: if X-Varnish contains only 1 id, we have a miss,\n # if it contains more (and therefore a space), we have a hit.\n if ( resp.http.x-varnish ~ \" \" ) {\n set resp.http.X-Cache = \"HIT\";\n # Since in Varnish 4 the behaviour of obj.hits changed, this might not be\n # accurate.\n # See https:\/\/www.varnish-cache.org\/trac\/ticket\/1492\n set resp.http.X-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Cache = \"MISS\";\n \/* Show the results of cookie sanitization *\/\n set resp.http.X-Cookie = req.http.Cookie;\n }\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n set resp.http.grace = req.http.grace;\n\n #TODO# Add sick marker\n\n # Restart count\n if ( req.restarts > 0 ) {\n set resp.http.X-Restarts = req.restarts;\n }\n\n # Add the Varnish server hostname\n set resp.http.X-Varnish-Server = server.hostname;\n # If we have setted a custom header with device's family detected we can show\n # it:\n # if ( req.http.X-UA-Device ) {\n # set resp.http.X-UA-Device = req.http.X-UA-Device;\n # }\n # If we have recived a custom header indicating the protocol in the request we\n # can show it:\n # if ( req.http.X-Forwarded-Proto ) {\n # set resp.http.X-Forwarded-Proto = req.http.X-Forwarded-Proto;\n # }\n\n \/* Vary header manipulation *\/\n # Empty in simple configs.\n # By example, if we are storing & serving diferent objects depending on\n # User-Agent header we must set the correct Vary header:\n # if ( resp.http.Vary ) {\n # set resp.http.Vary = resp.http.Vary + \",User-Agent\";\n # } else {\n # set resp.http.Vary = \"User-Agent\";\n # }\n\n \/* Fake headers *\/\n # Empty in simple configs\n # We can fake server headers here, by example:\n # set resp.http.Server = \"Deep thought\";\n # set resp.http.X-Powered-By = \"BOFH\";\n # Or have some fun with headers:\n # See http:\/\/www.nextthing.org\/archives\/2005\/08\/07\/fun-with-http-headers\n # See http:\/\/royal.pingdom.com\/2012\/08\/15\/fun-and-unusual-http-response-headers\/\n # set resp.http.X-Thank-You = \"for bothering to look at my HTTP headers\";\n # set resp.http.X-Answer = \"42\";\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_deliver {\n# return (deliver);\n# }\n\n# vcl_synth: Called to deliver a synthetic object. A synthetic object is\n# generated in VCL, not fetched from the backend. It is typically contructed\n# using the synthetic() function.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-synth\n\/*\n * We can come here \"invisibly\" with the following errors: 413, 417 & 503\n *\/\nsub vcl_synth {\n \/* Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_synth;\n\n \/* Try to restart request in case of failure *\/\n # Note that max_restarts defaults to 4\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if ( resp.status == 503\n && req.restarts < 4\n ) {\n return (restart);\n }\n\n \/* Set common headers for synthetic responses *\/\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n\n \/* HTTP Authentification client request *\/\n # Empty in simple configs.\n # SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* Load synthetic responses from disk *\/\n # Note that files loaded this way are never re-readed (even after a reload).\n # You should consider PROS\/CONS of doing an include instead.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_std.generated.html#func-fileread\n # Example custom 403 error page.\n # if ( resp.status == 403 ) {\n # synthetic(std.fileread(\"\/403.html\"));\n # return (deliver);\n # }\n\n \/* Error page & refresh \/ redirections *\/\n # We have plenty of choices when we have to serve an error to the client, \n # from the default error page to javascript black magic or plain redirections.\n # Adding some external statistic javascript to track failures served to\n # clients is strongly suggested.\n # We can't use external resources on synthetic content, everything must be\n # inlined.\n # If we need to include images we can embed them in base64 encoding.\n # We're using error 200 for monitoring puposes which should not be retried\n # client side.\n if ( resp.status != 200 ) {\n set resp.http.Retry-After = \"5\";\n }\n\n # Here is the default error page for Varnish 4 (not so pretty)\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n return (deliver);\n}\n\n#######################################################################\n# Backend Fetch\n\n# vcl_backend_fetch: Called before sending the backend request. In this\n# subroutine you typically alter the request before it gets to the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-fetch\n# sub vcl_backend_fetch {\n# return (fetch);\n# }\n\n# vcl_backend_response: Called after the response headers has been successfully\n# retrieved from the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-response\nsub vcl_backend_response {\n \/* Caching exceptions *\/\n # Varnish will cache objects with response codes:\n # 200, 203, 300, 301, 302, 307, 404 & 410.\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/VCL_Basics.html#the-initial-value-of-beresp-ttl\n # Drupal's Imagecache module can return a 307 redirection to the requested\n # url itself and, depending on Drupal's cache settings, this could lead to a\n # redirection loop being cached for a long time but also we want Varnish to\n # shield a little the backend.\n # See http:\/\/drupal.org\/node\/1248010\n # See http:\/\/drupal.org\/node\/310656\n if ( beresp.status == 307\n #TODO# verify that this work better than 'bereq.url ~ \"imagecache\"'\n && beresp.http.Location == bereq.url\n && beresp.ttl > 5s\n ) {\n set beresp.ttl = 5s;\n set beresp.http.cache-control = \"max-age=5\";\n }\n\n \/* Request retrial *\/\n if ( beresp.status == 500\n || beresp.status == 503\n ) {\n #TODO# consider not restarting POST requests as seenV3 on https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleSaintMode\n return (retry);\n }\n\n \/* Enable grace mode. Related with vcl_hit *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n set beresp.grace = 1h;\n\n \/* Strip cookies from the following static file types for all users. *\/\n # Related with our 12th stage on vcl_recv\n if ( bereq.url ~ \"(?i)\\.(bz2|css|eot|gif|gz|html?|ico|jpe?g|js|mp3|ogg|otf|pdf|png|rar|svg|swf|tbz|tgz|ttf|woff2?|zip)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n ) {\n unset beresp.http.set-cookie;\n }\n\n \/* Process ESI responses *\/\n # Empty in simple configs.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/esi.html\n # Send Surrogate-Capability headers\n # See http:\/\/www.w3.org\/TR\/edge-arch\n # Note that myproxyname is an identifier that should avoid collitions\n # Check for ESI acknowledgement and remove Surrogate-Control header\n #TODO# Add support for Surrogate-Control Targetting\n # if ( beresp.http.Surrogate-Control ~ \"ESI\/1.0\" ) {\n # unset beresp.http.Surrogate-Control;\n # set beresp.do_esi = true;\n # }\n\n \/* Gzip response *\/\n # Empty in simple configs.\n # Use Varnish to Gzip respone, if suitable, before storing it on cache.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html\n if ( ! beresp.http.Content-Encoding\n && ( beresp.http.content-type ~ \"text\"\n || beresp.http.content-type ~ \"application\/x-javascript\"\n || beresp.http.content-type ~ \"application\/javascript\"\n || beresp.http.content-type ~ \"application\/rss+xml\"\n || beresp.http.content-type ~ \"application\/xml\"\n || beresp.http.content-type ~ \"Application\/JSON\")\n ) {\n set beresp.do_gzip = true;\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # We can add the name of the backend that has processed the request:\n # set beresp.http.X-Backend = beresp.backend.name;\n # We can use a header to tell if the object was gziped by Varnish:\n # if ( beresp.do_gzip ) {\n # set beresp.http.X-Varnish-Gzipped = \"yes\";\n # } else {\n # set beresp.http.X-Varnish-Gizipped = \"no\";\n # }\n # We can do the same to tell if Varnish is streaming it:\n # if ( beresp.do_stream ) {\n # set beresp.http.X-Varnish-Streaming = \"yes\";\n # } else {\n # set beresp.http.X-Varnish-Streaming = \"no\";\n # }\n # We can also add headers informing whether the object is cacheable or not and why:\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Varnish3.0\n if ( beresp.ttl <= 0s ) {\n \/* Varnish determined the object was not cacheable *\/\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n } elsif ( bereq.http.Cookie ~ \"(SESS|SSESS|NO_CACHE|OATMEAL|CHOCOLATECHIP)\" ) {\n \/* We don't wish to cache content for logged in users or with certain cookies. *\/\n # Related with our 9th stage on vcl_recv\n set beresp.http.X-Cacheable = \"NO:Cookies\";\n # set beresp.uncacheable = true;\n } elsif ( beresp.http.Cache-Control ~ \"private\" ) {\n \/* We are respecting the Cache-Control=private header from the backend *\/\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n # set beresp.uncacheable = true;\n } else {\n \/* Varnish determined the object was cacheable *\/\n set beresp.http.X-Cacheable = \"YES\";\n }\n\n \/* Further header manipulation *\/\n # Empty in simple configs.\n # We can also unset some headers to prevent information disclosure and save\n # some cache space.\n # unset beresp.http.Server;\n # unset beresp.http.X-Powered-By;\n # Retry count.\n if ( bereq.retries > 0 ) {\n set beresp.http.X-Retries = bereq.retries;\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_backend_response {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Surrogate-control ~ \"no-store\" ||\n# (!beresp.http.Surrogate-Control &&\n# beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n# beresp.http.Vary == \"*\") {\n# \/*\n# * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# *\/\n# set beresp.ttl = 120s;\n# set beresp.uncacheable = true;\n# }\n# return (deliver);\n# }\n\n# vcl_backend_error: This subroutine is called if we fail the backend fetch.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-error\nsub vcl_backend_error {\n\n \/* Try to restart request in case of failure *\/\n #TODO# Confirm max_retries default value\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if ( bereq.retries < 4 ) {\n return (retry);\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # Retry count\n if ( bereq.retries > 0 ) {\n set beresp.http.X-Retries = bereq.retries;\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + beresp.status + \" \" + beresp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + beresp.status + \" \" + beresp.reason + {\"<\/h1>\n <p>\"} + beresp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + bereq.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this\n # point.\n return (deliver);\n}\n\n#######################################################################\n# Housekeeping\n\n# vcl_init: Called when VCL is loaded, before any requests pass through it.\n# Typically used to initialize VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-init\n# Here is where you should declare your directors now.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-backends.html#directors\n# Empty in simple configs\n# sub vcl_init {\n# return (ok);\n# }\n\n# vcl_fini: Called when VCL is discarded only after all requests have exited\n# the VCL. Typically used to clean up VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-fini\n# sub vcl_fini {\n# return (ok);\n# }\n\n","old_contents":"\/*\n * Varnish 4 example config for Drupal 7 \/ Pressflow 6 & 7\n *\/\n\n# Original source: https:\/\/github.com\/NITEMAN\/varnish-bites\/varnish4\/drupal-base.vcl\n# Copyright (c) 2015 Pedro Gonz\u00e1lez Serrano and individual contributors.\n# MIT License\n\n# Intended to be used both in simple production environments and with\n# learning\/teaching purposes.\n# Some references may not be yet updated to VCL 4.0, we use SeeV3 then.\n\n# WARNING:\n# Note that the built-in logic will be appended to our code if no return is\n# performed before.\n# Built-in logic is included commented out right after our's for reference\n# purposes in that cases.\n# See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleDefault\n\n#######################################################################\n# Initialization: Version & imports;\n\n\/* Version statement *\/\n# Since Varnish 4.0 it's mandatory to declare VCL version on first line.\nvcl 4.0;\n\n\/* Module (VMOD) imports *\/\n# Standard module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_std.generated.html\nimport std;\n\n# Directors module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# Unused in simple configs.\n#import directors;\n\n\n#######################################################################\n# Probe, backend, ACL and subroutine definitions\n\n\/* Backend probes \/ healthchecks *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#probes\nprobe basic {\n \/* Only test that backend's IP serves content for '\/' *\/\n # This might be a too heavy probe\n # .url = \"\/\";\n\n \/* Only test that backend's IP has apache working *\/\n # Nginx would fail this probe with a default config\n .request =\n \"OPTIONS * HTTP\/1.1\"\n \"Host: *\"\n \"Connection: close\";\n\n \/* Common options *\/\n .interval = 10s;\n .timeout = 2s;\n .window = 8;\n .threshold = 6;\n}\n\n\/* Backend definitions.*\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#backend-definition\nbackend default {\n \/* Default backend on the same machine. *\/\n # WARNING: timeouts could be not big enought for certain POST requests.\n .host = \"127.0.0.1\";\n .port = \"8008\";\n .max_connections = 100;\n .connect_timeout = 60s;\n .first_byte_timeout = 60s;\n .between_bytes_timeout = 60s;\n .probe = basic;\n}\n\n\/* Access Control Lists *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#access-control-list-acl\nacl purge_ban {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use '\"localhost\";' instead\n}\nacl allowed_monitors {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n}\n# acl own_proxys {\n# \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n# }\n\n\/* Custom subroutines *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#subroutines\n#TODO# Test in Varnihs 4\n# Empty in simple configs.\n# The only restriction naming subs is that the 'vlc_' prefix is reserverd for\n# Varnish use. As a task can need several chunks of code in diferent states,\n# it's a good idea to identify what main sub will call each with a suffix.\n# \/* Example 301 client redirection removing \"www\" prefix from request *\/\n# sub perm_redirections_recv {\n# if ( req.http.host ~ \"^www.*$\" ) {\n# return (\n# synth(751, \"http:\/\/\" + regsub(req.http.host, \"^www\\.\", \"\") + req.url)\n# );\n# }\n# }\n# sub perm_redirections_synth {\n# if ( resp.status == 751 ) {\n# \/* Get new URL from the response *\/\n# set resp.http.Location = resp.response;\n# \/* Set HTTP 301 for permanent redirect *\/\n# set resp.status = 301;\n# return (deliver);\n# }\n# }\n\n\n#######################################################################\n# Client side\n\n# vcl_recv: Called at the beginning of a request, after the complete request\n# has been received and parsed. Its purpose is to decide whether or not to\n# serve the request, how to do it, and, if applicable, which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-recv\nsub vcl_recv {\n \/* 0th: general bypass, general return & authorization checks *\/\n # Empty in simple configs.\n # Useful for debugging we can pipe or pass the request to default backend\n # here to bypass completely Varnish.\n # return (pipe);\n # return (pass);\n # We can also return here a 200 Ok for network performance benchmarking.\n # return (synth(200, \"Ok\"));\n # Finally we can perform basic HTTP authentification here, by example.\n # SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* 1st: Check for Varnish special requests *\/ \n # Custom response implementation example in order to check that Varnish is\n # working properly.\n # This is usefull for automatic monitoring with monit or when Varnish is\n # behind another proxies like HAProxy.\n if ( ( req.http.host == \"monitor.server.health\"\n || req.http.host == \"health.varnish\" )\n && client.ip ~ allowed_monitors\n && ( req.method == \"OPTIONS\" || req.method == \"GET\" )\n ) {\n return (synth(200, \"Ban added\"));\n }\n # Purge logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#http-purging\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if ( req.method == \"PURGE\" ) {\n if ( client.ip !~ purge_ban ) {\n return (synth(405, \"Not allowed.\"));\n }\n return (purge);\n }\n # Ban logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#bans\n if ( req.method == \"BAN\" ) {\n if ( client.ip !~ purge_ban ) {\n return (synth(405, \"Not allowed.\"));\n }\n ban( \"req.http.host == \" + req.http.host +\n \"&& req.url == \" + req.url);\n return (synth(200, \"Ban added\"));\n }\n\n \/* 2nd: Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_recv;\n # Here we can also enforce SSL when Varnish run behind some SSL termination\n # point.\n\n \/* 3rd: Time for backend choice *\/\n # Empty in simple configs.\n\n \/* 4th: Prepare request for the backend *\/\n # Empty in simple configs.\n # Example remove own_proxys from X-Forwarded-For\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/whats-new\/upgrading.html#x-forwarded-for-is-now-set-before-vcl-recv\n # if ( req.restarts == 0\n # && client.ip ~ own_proxys\n # && req.http.x-forwarded-for\n # ) {\n # set req.http.X-Forwarded-For\n # = regsub(req.http.X-Forwarded-For, \",( )?\" + client.ip, \"\");\n # }\n # Example normalize the host header, remove the port (in case you're testing\n # this on various TCP ports)\n # set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n \/* 5th: Bypass breakpoint 1 *\/\n # Useful for debugging we can now pipe or pass the request to backend with\n # headers setted.\n # return (pipe);\n # return (pass);\n\n \/* 6th: Decide if we should deal with a request (mostly from built-in logic) *\/\n if ( req.method == \"PRI\" ) {\n \/* We do not support SPDY or HTTP\/2.0 *\/\n return (synth(405));\n }\n if ( req.method != \"GET\"\n && req.method != \"HEAD\"\n && req.method != \"PUT\"\n && req.method != \"POST\"\n && req.method != \"TRACE\"\n && req.method != \"OPTIONS\"\n && req.method != \"DELETE\"\n ) {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if ( req.method != \"GET\"\n && req.method != \"HEAD\"\n ) {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if ( req.http.Authorization ) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n # Websocket support\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html\n if ( req.http.Upgrade ~ \"(?i)websocket\" ) {\n return (pipe);\n }\n\n \/* 7th: Access control for some URLs by ACL *\/\n # Empty in simple configs.\n # By example denial some URLs depending on client-ip, we'll need to define\n # corresponding ACL 'internal'.\n # if ( req.url ~ \"^\/(cron|install)\\.php\"\n # && client.ip !~ internal\n # ) {\n # # Have Varnish throw the error directly.\n # return (synth(403, \"Forbidden.\"));\n # # Use a custom error page that you've defined in Drupal at the path \"404\".\n # # set req.url = \"\/403\";\n # }\n\n \/* 8th: Custom exceptions *\/\n # Host exception example:\n # if ( req.http.host == \"ejemplo.exception.com\" ) {\n # return (pass);\n # }\n # Drupal exceptions, edit if we want to cache some AJAX\/AHAH request.\n # Add here filters for never cache URLs such as Payment Gateway's callbacks.\n if ( req.url ~ \"^\/status\\.php$\"\n || req.url ~ \"^\/update\\.php$\"\n || req.url ~ \"^\/ooyala\/ping$\"\n || req.url ~ \"^\/admin\/build\/features\"\n || req.url ~ \"^\/info\/.*$\"\n || req.url ~ \"^\/flag\/.*$\"\n || req.url ~ \"^.*\/ajax\/.*$\"\n || req.url ~ \"^.*\/ahah\/.*$\"\n ) {\n \/* Do not cache these paths *\/\n return (pass);\n }\n # Pipe these paths directly to backend for streaming.\n if ( req.url ~ \"^\/admin\/content\/backup_migrate\/export\" ) {\n return (pipe);\n }\n if ( req.url ~ \"^\/system\/files\" ) {\n return (pipe);\n }\n\n \/* 9th: Graced objets & Serve from anonymous cahe if all backends are down *\/\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n # set req.http.grace = \"none\";\n if ( ! std.healthy(req.backend_hint) ) {\n # We must do this here since cookie hashing\n unset req.http.Cookie;\n #TODO# Add sick marker\n } \n\n \/* 10th: Deal with compression and the Accept-Encoding header *\/\n # Althought Varnish 3 handles gziped content itself by default, just to be\n # sure we want to remove Accept-Encoding for some compressed formats.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html#what-does-http-gzip-support-do\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/varnishd.html?highlight=http_gzip_support\n # See (for older configs) https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleNormalizeAcceptEncoding\n if ( req.http.Accept-Encoding ) {\n if ( req.url ~ \"(?i)\\.(7z|avi|bz2|flv|gif|gz|jpe?g|mpe?g|mk[av]|mov|mp[34]|og[gm]|pdf|png|rar|swf|tar|tbz|tgz|woff2?|zip|xz)(\\?.*)?$\"\n ) {\n \/* Already compressed formats, no sense trying to compress again *\/\n unset req.http.Accept-Encoding;\n }\n }\n\n \/* 11th: Further request manipulation *\/\n # Empty in simple configs.\n # We could add here a custom header grouping User-agent families.\n # Generic URL manipulation.\n # Remove Google Analytics added parameters, useless for our backends.\n if ( req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=\" ) {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n # Strip anchors, server doesn't need it.\n if ( req.url ~ \"\\#\" ) {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n # Strip a trailing ? if it exists\n if ( req.url ~ \"\\?$\" ) {\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n # Normalize the querystring arguments\n set req.url = std.querysort(req.url);\n\n \/* 12th: Cookie removal *\/\n # Always cache the following static file types for all users. \n # Use with care if we control certain downloads depending on cookies. \n # Be carefull also if appending .htm[l] via Drupal's clean URLs.\n if ( req.url ~ \"(?i)\\.(bz2|css|eot|gif|gz|html?|ico|jpe?g|js|mp3|ogg|otf|pdf|png|rar|svg|swf|tbz|tgz|ttf|woff2?|zip)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n && req.url !~ \"\/system\/storage\/serve\"\n ) {\n unset req.http.Cookie;\n }\n # Remove all cookies that backend doesn't need to know about.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRemovingSomeCookies\n if ( req.http.Cookie ) {\n \/* Warning: Not a pretty solution *\/\n # Prefix header containing cookies with ';'\n set req.http.Cookie = \";\" + req.http.Cookie;\n # Remove any spaces after ';' in header containing cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n # Prefix cookies we want to preserve with one space:\n # 'S{1,2}ESS[a-z0-9]+' is the regular expression matching a Drupal session\n # cookie ({1,2} added for HTTPS support).\n # 'NO_CACHE' is usually set after a POST request to make sure issuing user\n # see the results of his post.\n # 'OATMEAL' & 'CHOCOLATECHIP' are special cookies used by Drupal's Bakery\n # module to provide Single Sign On.\n # Keep in mind we should add here any cookie that should reach the backend\n # such as splash avoiding cookies.\n set req.http.Cookie\n = regsuball(\n req.http.Cookie,\n \";(S{1,2}ESS[a-z0-9]+|NO_CACHE|OATMEAL|CHOCOLATECHIP)=\",\n \"; \\1=\"\n );\n # Remove from the header any single Cookie not prefixed with a space until\n # next ';' separator.\n set req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n # Remove any '; ' at the start or the end of the header.\n set req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n #If there are no remaining cookies, remove the cookie header.\n if ( req.http.Cookie == \"\" ) {\n unset req.http.Cookie;\n }\n }\n\n \/* 13th: Session cookie & special cookies bypass caching stage *\/\n # As we might want to cache some requests, hashed with its cookies, we don't\n # simply pass when some cookies remain present at this point.\n # Instead we look for request that must be passed due to the cookie header.\n if ( req.http.Cookie ~ \"SESS\"\n || req.http.Cookie ~ \"SSESS\"\n || req.http.Cookie ~ \"NO_CACHE\"\n || req.http.Cookie ~ \"OATMEAL\"\n || req.http.Cookie ~ \"CHOCOLATECHIP\"\n ) {\n return (pass);\n }\n\n \/* 14th: Announce ESI Support *\/\n # Empty in simple configs.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/esi.html\n # Note that ESI included requests inherits its parent's modified request, so\n # depending on the case you will end playing with req.esi_level to know\n # current depth.\n # Send Surrogate-Capability headers\n # See http:\/\/www.w3.org\/TR\/edge-arch\n # Note that myproxyname is an identifier that should avoid collitions\n # set req.http.Surrogate-Capability = \"myproxyname=ESI\/1.0\";\n\n \/* 15th: Bypass breakpoint 2 *\/\n # Useful for debugging we can now pipe or pass the request to backend to\n # bypass cache.\n # return (pipe);\n # return (pass);\n\n \/* 16th: Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n return (hash);\n}\n\n# vcl_pipe: Called upon entering pipe mode.\n# In this mode, the request is passed on to the backend, and any further data\n# from either client or backend is passed on unaltered until either end closes\n# the connection.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pipe\nsub vcl_pipe {\n # Websocket support\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html\n if ( req.http.upgrade ) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n}\n# sub vcl_pipe {\n# # By default Connection: close is set on all piped requests, to stop\n# # connection reuse from sending future requests directly to the\n# # (potentially) wrong backend. If you do want this to happen, you can undo\n# # it here.\n# # unset bereq.http.connection;\n# return (pipe);\n# }\n\n# vcl_pass: Called upon entering pass mode. \n# In this mode, the request is passed on to the backend, and the backend's\n# response is passed on to the client, but is not entered into the cache.\n# Subsequent requests submitted over the same client connection are handled normally.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pass\n# sub vcl_pass {\n# return (fetch);\n# }\n\n# vcl_hash: You may call hash_data() on the data you would like to add to the\n# hash.\n# Hash is used by Varnish to uniquely identify objects.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hash\nsub vcl_hash {\n \/* Hash cookie data *\/\n # As requests with same URL and host can produce diferent results when issued\n # with different cookies, we need to store items hashed with the associated\n # cookies. Note that cookies are already sanitized when we reach this point.\n if ( req.http.Cookie ) {\n \/* Include cookie in cache hash *\/\n hash_data(req.http.Cookie);\n }\n\n \/* Custom header hashing *\/\n # Empty in simple configs.\n # Example for caching differents object versions by device previously\n # detected (when static content could also vary):\n # if ( req.http.X-UA-Device ) {\n # hash_data(req.http.X-UA-Device);\n # }\n # Example for caching diferent object versions by X-Forwarded-Proto, trying\n # to be smart about what kind of request could generate diffetent responses.\n if ( req.http.X-Forwarded-Proto\n && req.url !~ \"(?i)\\.(bz2|css|eot|gif|gz|html?|ico|jpe?g|js|mp3|ogg|otf|pdf|png|rar|svg|swf|tbz|tgz|ttf|woff2?|zip)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n ) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (lookup);\n# }\n\n# vcl_purge: Called after the purge has been executed and all its variants have\n# been evited.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-purge\n# sub vcl_purge {\n# return (synth(200, \"Purged\"));\n# }\n\n# vcl_hit: Called after a cache lookup if the requested document was found in\n# the cache.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hit\nsub vcl_hit {\n if ( obj.ttl >= 0s ) {\n \/\/ A pure unadultered hit, deliver it\n return (deliver);\n }\n \/* Allow varnish to serve up stale content if it is responding slowly *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n if ( obj.ttl + 60s > 0s ) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n set req.http.grace = \"normal\";\n return (deliver);\n }\n \/* Allow varish to serve up stale content if all backends are down *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n if ( ! std.healthy(req.backend_hint)\n && obj.ttl + obj.grace > 0s\n ) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n set req.http.grace = \"extended\";\n return (deliver);\n }\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\n# vcl_miss: Called after a cache lookup if the requested document was not found\n# in the cache.\n# Its purpose is to decide whether or not to attempt to retrieve the document\n# from the backend, and which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-miss\n# sub vcl_miss {\n# return (fetch);\n# }\n\n# vcl_deliver: Called before an object is delivered to the client\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-deliver\nsub vcl_deliver {\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # Add whether the object is a cache hit or miss and the number of hits for\n # the object.\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Addingaheaderindicatinghitmiss\n # In Varnish 4 the obj.hits counter behaviour has changed (see bug 1492), so\n # we use a different method: if X-Varnish contains only 1 id, we have a miss,\n # if it contains more (and therefore a space), we have a hit.\n if ( resp.http.x-varnish ~ \" \" ) {\n set resp.http.X-Cache = \"HIT\";\n # Since in Varnish 4 the behaviour of obj.hits changed, this might not be\n # accurate.\n # See https:\/\/www.varnish-cache.org\/trac\/ticket\/1492\n set resp.http.X-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Cache = \"MISS\";\n \/* Show the results of cookie sanitization *\/\n set resp.http.X-Cookie = req.http.Cookie;\n }\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n set resp.http.grace = req.http.grace;\n\n #TODO# Add sick marker\n\n # Restart count\n if ( req.restarts > 0 ) {\n set resp.http.X-Restarts = req.restarts;\n }\n\n # Add the Varnish server hostname\n set resp.http.X-Varnish-Server = server.hostname;\n # If we have setted a custom header with device's family detected we can show\n # it:\n # if ( req.http.X-UA-Device ) {\n # set resp.http.X-UA-Device = req.http.X-UA-Device;\n # }\n # If we have recived a custom header indicating the protocol in the request we\n # can show it:\n # if ( req.http.X-Forwarded-Proto ) {\n # set resp.http.X-Forwarded-Proto = req.http.X-Forwarded-Proto;\n # }\n\n \/* Vary header manipulation *\/\n # Empty in simple configs.\n # By example, if we are storing & serving diferent objects depending on\n # User-Agent header we must set the correct Vary header:\n # if ( resp.http.Vary ) {\n # set resp.http.Vary = resp.http.Vary + \",User-Agent\";\n # } else {\n # set resp.http.Vary = \"User-Agent\";\n # }\n\n \/* Fake headers *\/\n # Empty in simple configs\n # We can fake server headers here, by example:\n # set resp.http.Server = \"Deep thought\";\n # set resp.http.X-Powered-By = \"BOFH\";\n # Or have some fun with headers:\n # See http:\/\/www.nextthing.org\/archives\/2005\/08\/07\/fun-with-http-headers\n # See http:\/\/royal.pingdom.com\/2012\/08\/15\/fun-and-unusual-http-response-headers\/\n # set resp.http.X-Thank-You = \"for bothering to look at my HTTP headers\";\n # set resp.http.X-Answer = \"42\";\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_deliver {\n# return (deliver);\n# }\n\n# vcl_synth: Called to deliver a synthetic object. A synthetic object is\n# generated in VCL, not fetched from the backend. It is typically contructed\n# using the synthetic() function.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-synth\n\/*\n * We can come here \"invisibly\" with the following errors: 413, 417 & 503\n *\/\nsub vcl_synth {\n \/* Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_synth;\n\n \/* Try to restart request in case of failure *\/\n # Note that max_restarts defaults to 4\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if ( resp.status == 503\n && req.restarts < 4\n ) {\n return (restart);\n }\n\n \/* Set common headers for synthetic responses *\/\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n\n \/* HTTP Authentification client request *\/\n # Empty in simple configs.\n # SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* Load synthetic responses from disk *\/\n # Note that files loaded this way are never re-readed (even after a reload).\n # You should consider PROS\/CONS of doing an include instead.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_std.generated.html#func-fileread\n # Example custom 403 error page.\n # if ( resp.status == 403 ) {\n # synthetic(std.fileread(\"\/403.html\"));\n # return (deliver);\n # }\n\n \/* Error page & refresh \/ redirections *\/\n # We have plenty of choices when we have to serve an error to the client, \n # from the default error page to javascript black magic or plain redirections.\n # Adding some external statistic javascript to track failures served to\n # clients is strongly suggested.\n # We can't use external resources on synthetic content, everything must be\n # inlined.\n # If we need to include images we can embed them in base64 encoding.\n # We're using error 200 for monitoring puposes which should not be retried\n # client side.\n if ( resp.status != 200 ) {\n set resp.http.Retry-After = \"5\";\n }\n\n # Here is the default error page for Varnish 4 (not so pretty)\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n return (deliver);\n}\n\n#######################################################################\n# Backend Fetch\n\n# vcl_backend_fetch: Called before sending the backend request. In this\n# subroutine you typically alter the request before it gets to the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-fetch\n# sub vcl_backend_fetch {\n# return (fetch);\n# }\n\n# vcl_backend_response: Called after the response headers has been successfully\n# retrieved from the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-response\nsub vcl_backend_response {\n \/* Caching exceptions *\/\n # Varnish will cache objects with response codes:\n # 200, 203, 300, 301, 302, 307, 404 & 410.\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/VCL_Basics.html#the-initial-value-of-beresp-ttl\n # Drupal's Imagecache module can return a 307 redirection to the requested\n # url itself and, depending on Drupal's cache settings, this could lead to a\n # redirection loop being cached for a long time but also we want Varnish to\n # shield a little the backend.\n # See http:\/\/drupal.org\/node\/1248010\n # See http:\/\/drupal.org\/node\/310656\n if ( beresp.status == 307\n #TODO# verify that this work better than 'bereq.url ~ \"imagecache\"'\n && beresp.http.Location == bereq.url\n && beresp.ttl > 5s\n ) {\n set beresp.ttl = 5s;\n set beresp.http.cache-control = \"max-age=5\";\n }\n\n \/* Request retrial *\/\n if ( beresp.status == 500\n || beresp.status == 503\n ) {\n #TODO# consider not restarting POST requests as seenV3 on https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleSaintMode\n return (retry);\n }\n\n \/* Enable grace mode. Related with vcl_hit *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n set beresp.grace = 1h;\n\n \/* Strip cookies from the following static file types for all users. *\/\n # Related with our 12th stage on vcl_recv\n if ( bereq.url ~ \"(?i)\\.(bz2|css|eot|gif|gz|html?|ico|jpe?g|js|mp3|ogg|otf|pdf|png|rar|svg|swf|tbz|tgz|ttf|woff2?|zip)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n ) {\n unset beresp.http.set-cookie;\n }\n\n \/* Process ESI responses *\/\n # Empty in simple configs.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/esi.html\n # Send Surrogate-Capability headers\n # See http:\/\/www.w3.org\/TR\/edge-arch\n # Note that myproxyname is an identifier that should avoid collitions\n # Check for ESI acknowledgement and remove Surrogate-Control header\n #TODO# Add support for Surrogate-Control Targetting\n # if ( beresp.http.Surrogate-Control ~ \"ESI\/1.0\" ) {\n # unset beresp.http.Surrogate-Control;\n # set beresp.do_esi = true;\n # }\n\n \/* Gzip response *\/\n # Empty in simple configs.\n # Use Varnish to Gzip respone, if suitable, before storing it on cache.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html\n if ( ! beresp.http.Content-Encoding\n && ( beresp.http.content-type ~ \"text\"\n || beresp.http.content-type ~ \"application\/x-javascript\"\n || beresp.http.content-type ~ \"application\/javascript\"\n || beresp.http.content-type ~ \"application\/rss+xml\"\n || beresp.http.content-type ~ \"application\/xml\"\n || beresp.http.content-type ~ \"Application\/JSON\")\n ) {\n set beresp.do_gzip = true;\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # We can add the name of the backend that has processed the request:\n # set beresp.http.X-Backend = beresp.backend.name;\n # We can use a header to tell if the object was gziped by Varnish:\n # if ( beresp.do_gzip ) {\n # set beresp.http.X-Varnish-Gzipped = \"yes\";\n # } else {\n # set beresp.http.X-Varnish-Gizipped = \"no\";\n # }\n # We can do the same to tell if Varnish is streaming it:\n # if ( beresp.do_stream ) {\n # set beresp.http.X-Varnish-Streaming = \"yes\";\n # } else {\n # set beresp.http.X-Varnish-Streaming = \"no\";\n # }\n # We can also add headers informing whether the object is cacheable or not and why:\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Varnish3.0\n if ( beresp.ttl <= 0s ) {\n \/* Varnish determined the object was not cacheable *\/\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n } elsif ( bereq.http.Cookie ~ \"(SESS|SSESS|NO_CACHE|OATMEAL|CHOCOLATECHIP)\" ) {\n \/* We don't wish to cache content for logged in users or with certain cookies. *\/\n # Related with our 9th stage on vcl_recv\n set beresp.http.X-Cacheable = \"NO:Cookies\";\n # set beresp.uncacheable = true;\n } elsif ( beresp.http.Cache-Control ~ \"private\" ) {\n \/* We are respecting the Cache-Control=private header from the backend *\/\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n # set beresp.uncacheable = true;\n } else {\n \/* Varnish determined the object was cacheable *\/\n set beresp.http.X-Cacheable = \"YES\";\n }\n\n \/* Further header manipulation *\/\n # Empty in simple configs.\n # We can also unset some headers to prevent information disclosure and save\n # some cache space.\n # unset beresp.http.Server;\n # unset beresp.http.X-Powered-By;\n # Retry count.\n if ( bereq.retries > 0 ) {\n set beresp.http.X-Retries = bereq.retries;\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_backend_response {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Surrogate-control ~ \"no-store\" ||\n# (!beresp.http.Surrogate-Control &&\n# beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n# beresp.http.Vary == \"*\") {\n# \/*\n# * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# *\/\n# set beresp.ttl = 120s;\n# set beresp.uncacheable = true;\n# }\n# return (deliver);\n# }\n\n# vcl_backend_error: This subroutine is called if we fail the backend fetch.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-error\nsub vcl_backend_error {\n\n \/* Try to restart request in case of failure *\/\n #TODO# Confirm max_retries default value\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if ( bereq.retries < 4 ) {\n return (retry);\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # Retry count\n if ( bereq.retries > 0 ) {\n set beresp.http.X-Retries = bereq.retries;\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + beresp.status + \" \" + beresp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + beresp.status + \" \" + beresp.reason + {\"<\/h1>\n <p>\"} + beresp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + bereq.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this\n # point.\n return (deliver);\n}\n\n#######################################################################\n# Housekeeping\n\n# vcl_init: Called when VCL is loaded, before any requests pass through it.\n# Typically used to initialize VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-init\n# Here is where you should declare your directors now.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-backends.html#directors\n# Empty in simple configs\n# sub vcl_init {\n# return (ok);\n# }\n\n# vcl_fini: Called when VCL is discarded only after all requests have exited\n# the VCL. Typically used to clean up VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-fini\n# sub vcl_fini {\n# return (ok);\n# }\n\n","returncode":0,"stderr":"","license":"unknown","lang":"VCL"} {"commit":"eb94ee97f81c38f4c78485869bdbd16bd285758a","subject":"improve BigPipe support, take 2","message":"improve BigPipe support, take 2\n","repos":"NITEMAN\/varnish-bites,NITEMAN\/Varnish_VCL_samps-hacks","old_file":"varnish4\/drupal-base.vcl","new_file":"varnish4\/drupal-base.vcl","new_contents":"\/*\n * Varnish 4 example config for Drupal 7 & 8 \/ Pressflow 6 & 7\n *\/\n\n# Original source: https:\/\/github.com\/NITEMAN\/varnish-bites\/varnish4\/drupal-base.vcl\n# Copyright (c) 2015 Pedro Gonz\u00e1lez Serrano and individual contributors.\n# MIT License\n\n# Intended to be used both in simple production environments and with\n# learning\/teaching purposes.\n# Some references may not be yet updated to VCL 4.0, we use SeeV3 then.\n\n# WARNING:\n# Note that the built-in logic will be appended to our code if no return is\n# performed before.\n# Built-in logic is included commented out right after our's for reference\n# purposes in that cases.\n# See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleDefault\n\n#######################################################################\n# Initialization: Version & imports;\n\n\/* Version statement *\/\n# Since Varnish 4.0 it's mandatory to declare VCL version on first line.\nvcl 4.0;\n\n\/* Module (VMOD) imports *\/\n# Standard module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_std.generated.html\nimport std;\n\n# Directors module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# Unused in simple configs.\n#import directors;\n\n\n#######################################################################\n# Probe, backend, ACL and subroutine definitions\n\n\/* Backend probes \/ healthchecks *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#probes\nprobe basic {\n \/* Only test that backend's IP serves content for '\/' *\/\n # This might be a too heavy probe\n # .url = \"\/\";\n\n \/* Only test that backend's IP has apache working *\/\n # Nginx would fail this probe with a default config\n .request =\n \"OPTIONS * HTTP\/1.1\"\n \"Host: *\"\n \"Connection: close\";\n\n \/* Common options *\/\n .interval = 10s;\n .timeout = 2s;\n .window = 8;\n .threshold = 6;\n}\n\n\/* Backend definitions.*\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#backend-definition\nbackend default {\n \/* Default backend on the same machine. *\/\n # WARNING: timeouts could be not big enought for certain POST requests.\n .host = \"127.0.0.1\";\n .port = \"8008\";\n .max_connections = 100;\n .connect_timeout = 60s;\n .first_byte_timeout = 60s;\n .between_bytes_timeout = 60s;\n .probe = basic;\n}\n\n\/* Access Control Lists *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#access-control-list-acl\nacl purge_ban {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use '\"localhost\";' instead\n}\nacl allowed_monitors {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n}\n# acl own_proxys {\n# \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n# }\n\n\/* Custom subroutines *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#subroutines\n#TODO# Test in Varnihs 4\n# Empty in simple configs.\n# The only restriction naming subs is that the 'vlc_' prefix is reserverd for\n# Varnish use. As a task can need several chunks of code in diferent states,\n# it's a good idea to identify what main sub will call each with a suffix.\n# \/* Example 301 client redirection removing \"www\" prefix from request *\/\n# sub perm_redirections_recv {\n# if ( req.http.host ~ \"^www.*$\" ) {\n# return (\n# synth(751, \"http:\/\/\" + regsub(req.http.host, \"^www\\.\", \"\") + req.url)\n# );\n# }\n# }\n# sub perm_redirections_synth {\n# if ( resp.status == 751 ) {\n# \/* Get new URL from the response *\/\n# set resp.http.Location = resp.reason;\n# \/* Set HTTP 301 for permanent redirect *\/\n# set resp.status = 301;\n# set resp.reason = \"Moved Permanently\";\n# return (deliver);\n# }\n# }\n\n\n#######################################################################\n# Client side\n\n# vcl_recv: Called at the beginning of a request, after the complete request\n# has been received and parsed. Its purpose is to decide whether or not to\n# serve the request, how to do it, and, if applicable, which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-recv\nsub vcl_recv {\n \/* 0th: general bypass, general return & authorization checks *\/\n # Empty in simple configs.\n # Useful for debugging we can pipe or pass the request to default backend\n # here to bypass completely Varnish.\n # return (pipe);\n # return (pass);\n # We can also return here a 200 Ok for network performance benchmarking.\n # return (synth(200, \"Ok\"));\n # Finally we can perform basic HTTP authentification here, by example.\n # SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* 1st: Check for Varnish special requests *\/\n # Custom response implementation example in order to check that Varnish is\n # working properly.\n # This is usefull for automatic monitoring with monit or when Varnish is\n # behind another proxies like HAProxy.\n if ( ( req.http.host == \"monitor.server.health\"\n || req.http.host == \"health.varnish\" )\n && client.ip ~ allowed_monitors\n && ( req.method == \"OPTIONS\" || req.method == \"GET\" )\n ) {\n return (synth(200, \"OK\"));\n }\n # Purge logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#http-purging\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if ( req.method == \"PURGE\" ) {\n if ( client.ip !~ purge_ban ) {\n return (synth(405, \"Not allowed.\"));\n }\n return (purge);\n }\n # Ban logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#bans\n if ( req.method == \"BAN\" ) {\n if ( client.ip !~ purge_ban ) {\n return (synth(405, \"Not allowed.\"));\n }\n if (req.http.Purge-Cache-Tags) {\n ban( \"obj.http.X-Host == \" + req.http.host +\n \" && obj.http.Purge-Cache-Tags ~ \" + req.http.Purge-Cache-Tags\n );\n }\n else {\n # Assumes req.url is a regex. This might be a bit too simple\n ban( \"obj.http.X-Host == \" + req.http.host +\n \" && obj.http.X-Url ~ \" + req.url\n );\n }\n return (synth(200, \"Ban added\"));\n }\n\n \/* 2nd: Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_recv;\n # Here we can also enforce SSL when Varnish run behind some SSL termination\n # point.\n\n \/* 3rd: Time for backend choice *\/\n # Empty in simple configs.\n\n \/* 4th: Prepare request for the backend *\/\n # Empty in simple configs.\n # Example remove own_proxys from X-Forwarded-For\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/whats-new\/upgrading.html#x-forwarded-for-is-now-set-before-vcl-recv\n # Varnish 4 regsub doesn't accept anything but plain regexp, so we can't use\n # client.ip to exclude the proxy ips from the request:\n # set req.http.X-Forwarded-For\n # = regsub(req.http.X-Forwarded-For, \",( )?\" + client.ip, \"\");\n # Instead, we need to add the proxy ips manually in the exclude list:\n # if ( req.restarts == 0\n # && client.ip ~ own_proxys\n # && req.http.X-Forwarded-For\n # ) {\n # set req.http.X-Forwarded-For\n # = regsub(req.http.X-Forwarded-For,\n # \"(, )?(10\\.10\\.10\\.10|10\\.11\\.11\\.11)\", \"\");\n # }\n # An alternative could be to skip all this and try to modify the header\n # manually so Varnish doesn't touch it.\n # set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \"\";\n #\n # Example normalize the host header, remove the port (in case you're testing\n # this on various TCP ports)\n # set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n \/* 5th: Bypass breakpoint 1 *\/\n # Useful for debugging we can now pipe or pass the request to backend with\n # headers setted.\n # return (pipe);\n # return (pass);\n\n \/* 6th: Decide if we should deal with a request (mostly from built-in logic) *\/\n if ( req.method == \"PRI\" ) {\n \/* We do not support SPDY or HTTP\/2.0 *\/\n return (synth(405));\n }\n if ( req.method != \"GET\"\n && req.method != \"HEAD\"\n && req.method != \"PUT\"\n && req.method != \"POST\"\n && req.method != \"TRACE\"\n && req.method != \"OPTIONS\"\n && req.method != \"DELETE\"\n ) {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if ( req.method != \"GET\"\n && req.method != \"HEAD\"\n ) {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if ( req.http.Authorization ) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n # Websocket support\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html\n if ( req.http.Upgrade ~ \"(?i)websocket\" ) {\n return (pipe);\n }\n\n \/* 7th: Access control for some URLs by ACL *\/\n # Empty in simple configs.\n # By example denial some URLs depending on client-ip, we'll need to define\n # corresponding ACL 'internal'.\n # if ( req.url ~ \"^\/(cron|install)\\.php\"\n # && client.ip !~ internal\n # ) {\n # # Have Varnish throw the error directly.\n # return (synth(403, \"Forbidden.\"));\n # # Use a custom error page that you've defined in Drupal at the path \"404\".\n # # set req.url = \"\/403\";\n # }\n\n \/* 8th: Custom exceptions *\/\n # Host exception example:\n # if ( req.http.host == \"ejemplo.exception.com\" ) {\n # return (pass);\n # }\n # Drupal exceptions, edit if we want to cache some AJAX\/AHAH request.\n # Add here filters for never cache URLs such as Payment Gateway's callbacks.\n if ( req.url ~ \"^\/status\\.php$\"\n || req.url ~ \"^\/update\\.php$\"\n || req.url ~ \"^\/ooyala\/ping$\"\n || req.url ~ \"^\/admin\/build\/features\"\n || req.url ~ \"^\/info\/.*$\"\n || req.url ~ \"^\/flag\/.*$\"\n || req.url ~ \"^.*\/ajax\/.*$\"\n || req.url ~ \"^.*\/ahah\/.*$\"\n ) {\n \/* Do not cache these paths *\/\n return (pass);\n }\n # Pipe these paths directly to backend for streaming.\n if ( req.url ~ \"^\/admin\/content\/backup_migrate\/export\"\n || req.url ~ \"^\/admin\/config\/system\/backup_migrate\"\n ) {\n return (pipe);\n }\n if ( req.url ~ \"^\/system\/files\" ) {\n return (pipe);\n }\n\n \/* 9th: Graced objets & Serve from anonymous cahe if all backends are down *\/\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n # set req.http.X-Varnish-Grace = \"none\";\n if ( ! std.healthy(req.backend_hint) ) {\n # We must do this here since cookie hashing\n unset req.http.Cookie;\n #TODO# Add sick marker\n }\n\n \/* 10th: Deal with compression and the Accept-Encoding header *\/\n # Althought Varnish 4 handles gziped content itself by default, just to be\n # sure we want to remove Accept-Encoding for some compressed formats.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html#what-does-http-gzip-support-do\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/varnishd.html?highlight=http_gzip_support\n # See (for older configs) https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleNormalizeAcceptEncoding\n if ( req.http.Accept-Encoding ) {\n if ( req.url ~ \"(?i)\\.(7z|avi|bz2|flv|gif|gz|jpe?g|mpe?g|mk[av]|mov|mp[34]|og[gm]|pdf|png|rar|swf|tar|tbz|tgz|woff2?|zip|xz)(\\?.*)?$\"\n ) {\n \/* Already compressed formats, no sense trying to compress again *\/\n unset req.http.Accept-Encoding;\n }\n }\n\n \/* 11th: Further request manipulation *\/\n # Empty in simple configs.\n # We could add here a custom header grouping User-agent families.\n # Generic URL manipulation.\n # Remove Google Analytics added parameters, useless for our backends.\n if ( req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=\" ) {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n # Strip anchors, server doesn't need it.\n if ( req.url ~ \"\\#\" ) {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n # Strip a trailing ? if it exists\n if ( req.url ~ \"\\?$\" ) {\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n # Normalize the querystring arguments\n set req.url = std.querysort(req.url);\n\n \/* 12th: Cookie removal *\/\n # Always cache the following static file types for all users.\n # Use with care if we control certain downloads depending on cookies.\n # Be carefull also if appending .htm[l] via Drupal's clean URLs.\n if ( req.url ~ \"(?i)\\.(bz2|css|eot|gif|gz|html?|ico|jpe?g|js|mp3|ogg|otf|pdf|png|rar|svg|swf|tbz|tgz|ttf|woff2?|zip)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n && req.url !~ \"\/system\/storage\/serve\"\n ) {\n unset req.http.Cookie;\n }\n # Remove all cookies that backend doesn't need to know about.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRemovingSomeCookies\n if ( req.http.Cookie ) {\n \/* Warning: Not a pretty solution *\/\n # Prefix header containing cookies with ';'\n set req.http.Cookie = \";\" + req.http.Cookie;\n # Remove any spaces after ';' in header containing cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n # Prefix cookies we want to preserve with one space:\n # 'S{1,2}ESS[a-z0-9]+' is the regular expression matching a Drupal session\n # cookie ({1,2} added for HTTPS support).\n # 'NO_CACHE' is usually set after a POST request to make sure issuing user\n # see the results of his post.\n # 'OATMEAL' & 'CHOCOLATECHIP' are special cookies used by Drupal's Bakery\n # module to provide Single Sign On.\n # Keep in mind we should add here any cookie that should reach the backend\n # such as splash avoiding cookies.\n set req.http.Cookie\n = regsuball(\n req.http.Cookie,\n \";(S{1,2}ESS[a-z0-9]+|NO_CACHE|OATMEAL|CHOCOLATECHIP|big_pipe_nojs)=\",\n \"; \\1=\"\n );\n # Remove from the header any single Cookie not prefixed with a space until\n # next ';' separator.\n set req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n # Remove any '; ' at the start or the end of the header.\n set req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n #If there are no remaining cookies, remove the cookie header.\n if ( req.http.Cookie == \"\" ) {\n unset req.http.Cookie;\n }\n }\n\n \/* 13th: Session cookie & special cookies bypass caching stage *\/\n # As we might want to cache some requests, hashed with its cookies, we don't\n # simply pass when some cookies remain present at this point.\n # Instead we look for request that must be passed due to the cookie header.\n if ( req.http.Cookie ~ \"SESS\"\n || req.http.Cookie ~ \"SSESS\"\n || req.http.Cookie ~ \"NO_CACHE\"\n || req.http.Cookie ~ \"OATMEAL\"\n || req.http.Cookie ~ \"CHOCOLATECHIP\"\n ) {\n return (pass);\n }\n\n \/* 14th: Announce ESI Support *\/\n # Empty in simple configs.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/esi.html\n # Note that ESI included requests inherits its parent's modified request, so\n # depending on the case you will end playing with req.esi_level to know\n # current depth.\n # Send Surrogate-Capability headers\n # See http:\/\/www.w3.org\/TR\/edge-arch\n # Note that myproxyname is an identifier that should avoid collitions\n # set req.http.Surrogate-Capability = \"myproxyname=ESI\/1.0\";\n\n \/* 15th: Bypass breakpoint 2 *\/\n # Useful for debugging we can now pipe or pass the request to backend to\n # bypass cache.\n # return (pipe);\n # return (pass);\n\n \/* 16th: Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n return (hash);\n}\n\n# vcl_pipe: Called upon entering pipe mode.\n# In this mode, the request is passed on to the backend, and any further data\n# from either client or backend is passed on unaltered until either end closes\n# the connection.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pipe\nsub vcl_pipe {\n # Websocket support\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html\n if ( req.http.upgrade ) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n}\n# sub vcl_pipe {\n# # By default Connection: close is set on all piped requests, to stop\n# # connection reuse from sending future requests directly to the\n# # (potentially) wrong backend. If you do want this to happen, you can undo\n# # it here.\n# # unset bereq.http.connection;\n# return (pipe);\n# }\n\n# vcl_pass: Called upon entering pass mode.\n# In this mode, the request is passed on to the backend, and the backend's\n# response is passed on to the client, but is not entered into the cache.\n# Subsequent requests submitted over the same client connection are handled normally.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pass\n# sub vcl_pass {\n# return (fetch);\n# }\n\n# vcl_hash: You may call hash_data() on the data you would like to add to the\n# hash.\n# Hash is used by Varnish to uniquely identify objects.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hash\nsub vcl_hash {\n \/* Hash cookie data *\/\n # As requests with same URL and host can produce diferent results when issued\n # with different cookies, we need to store items hashed with the associated\n # cookies. Note that cookies are already sanitized when we reach this point.\n if ( req.http.Cookie ) {\n \/* Include cookie in cache hash *\/\n hash_data(req.http.Cookie);\n }\n\n \/* Custom header hashing *\/\n # Empty in simple configs.\n # Example for caching differents object versions by device previously\n # detected (when static content could also vary):\n # if ( req.http.X-UA-Device ) {\n # hash_data(req.http.X-UA-Device);\n # }\n # Example for caching diferent object versions by X-Forwarded-Proto, trying\n # to be smart about what kind of request could generate diffetent responses.\n if ( req.http.X-Forwarded-Proto\n && req.url !~ \"(?i)\\.(bz2|css|eot|gif|gz|html?|ico|jpe?g|js|mp3|ogg|otf|pdf|png|rar|svg|swf|tbz|tgz|ttf|woff2?|zip)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n ) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (lookup);\n# }\n\n# vcl_purge: Called after the purge has been executed and all its variants have\n# been evited.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-purge\n# sub vcl_purge {\n# return (synth(200, \"Purged\"));\n# }\n\n# vcl_hit: Called after a cache lookup if the requested document was found in\n# the cache.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hit\nsub vcl_hit {\n if ( obj.ttl >= 0s ) {\n \/\/ A pure unadultered hit, deliver it\n return (deliver);\n }\n \/* Allow varnish to serve up stale content if it is responding slowly *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n if ( obj.ttl + 60s > 0s ) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n set req.http.X-Varnish-Grace = \"normal\";\n return (deliver);\n }\n \/* Allow varish to serve up stale content if all backends are down *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n if ( ! std.healthy(req.backend_hint)\n && obj.ttl + obj.grace > 0s\n ) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n set req.http.X-Varnish-Grace = \"extended\";\n return (deliver);\n }\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\n# vcl_miss: Called after a cache lookup if the requested document was not found\n# in the cache.\n# Its purpose is to decide whether or not to attempt to retrieve the document\n# from the backend, and which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-miss\n# sub vcl_miss {\n# return (fetch);\n# }\n\n# vcl_deliver: Called before an object is delivered to the client\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-deliver\nsub vcl_deliver {\n \/* Ban lurker friendly bans support *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#bans\n unset resp.http.X-Host;\n unset resp.http.X-Url;\n\n \/* Drupal 8 Purge's module header cleanup *\/\n # Purge's headers can become quite big, causing issues in upstream proxies, so we clean it here\n unset resp.http.Purge-Cache-Tags;\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # Add whether the object is a cache hit or miss and the number of hits for\n # the object.\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Addingaheaderindicatinghitmiss\n # In Varnish 4 the obj.hits counter behaviour has changed (see bug 1492), so\n # we use a different method: if X-Varnish contains only 1 id, we have a miss,\n # if it contains more (and therefore a space), we have a hit.\n if ( resp.http.X-Varnish ~ \" \" ) {\n set resp.http.X-Varnish-Cache = \"HIT\";\n # Since in Varnish 4 the behaviour of obj.hits changed, this might not be\n # accurate.\n # See https:\/\/www.varnish-cache.org\/trac\/ticket\/1492\n set resp.http.X-Varnish-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Varnish-Cache = \"MISS\";\n \/* Show the results of cookie sanitization *\/\n if ( req.http.Cookie ) {\n set resp.http.X-Varnish-Cookie = req.http.Cookie;\n }\n }\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n if ( req.http.X-Varnish-Grace ) {\n set resp.http.X-Varnish-Grace = req.http.X-Varnish-Grace;\n }\n\n #TODO# Add sick marker\n\n # Restart count\n if ( req.restarts > 0 ) {\n set resp.http.X-Varnish-Restarts = req.restarts;\n }\n\n # Add the Varnish server hostname\n set resp.http.X-Varnish-Server = server.hostname;\n # If we have setted a custom header with device's family detected we can show\n # it:\n # if ( req.http.X-UA-Device ) {\n # set resp.http.X-UA-Device = req.http.X-UA-Device;\n # }\n # If we have recived a custom header indicating the protocol in the request we\n # can show it:\n # if ( req.http.X-Forwarded-Proto ) {\n # set resp.http.X-Forwarded-Proto = req.http.X-Forwarded-Proto;\n # }\n\n \/* Vary header manipulation *\/\n # Empty in simple configs.\n # By example, if we are storing & serving diferent objects depending on\n # User-Agent header we must set the correct Vary header:\n # if ( resp.http.Vary ) {\n # set resp.http.Vary = resp.http.Vary + \",User-Agent\";\n # } else {\n # set resp.http.Vary = \"User-Agent\";\n # }\n\n \/* Fake headers *\/\n # Empty in simple configs\n # We can fake server headers here, by example:\n # set resp.http.Server = \"Deep thought\";\n # set resp.http.X-Powered-By = \"BOFH\";\n # Or have some fun with headers:\n # See http:\/\/www.nextthing.org\/archives\/2005\/08\/07\/fun-with-http-headers\n # See http:\/\/royal.pingdom.com\/2012\/08\/15\/fun-and-unusual-http-response-headers\/\n # set resp.http.X-Thank-You = \"for bothering to look at my HTTP headers\";\n # set resp.http.X-Answer = \"42\";\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_deliver {\n# return (deliver);\n# }\n\n# vcl_synth: Called to deliver a synthetic object. A synthetic object is\n# generated in VCL, not fetched from the backend. It is typically contructed\n# using the synthetic() function.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-synth\n\/*\n * We can come here \"invisibly\" with the following errors: 413, 417 & 503\n *\/\nsub vcl_synth {\n \/* Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_synth;\n\n \/* Try to restart request in case of failure *\/\n # Note that max_restarts defaults to 4\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if ( resp.status == 503\n && req.restarts < 4\n ) {\n return (restart);\n }\n\n \/* Set common headers for synthetic responses *\/\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n\n \/* HTTP Authentification client request *\/\n # Empty in simple configs.\n # SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* Load synthetic responses from disk *\/\n # Note that files loaded this way are never re-readed (even after a reload).\n # You should consider PROS\/CONS of doing an include instead.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_std.generated.html#func-fileread\n # Example custom 403 error page.\n # if ( resp.status == 403 ) {\n # synthetic(std.fileread(\"\/403.html\"));\n # return (deliver);\n # }\n\n \/* Error page & refresh \/ redirections *\/\n # We have plenty of choices when we have to serve an error to the client,\n # from the default error page to javascript black magic or plain redirections.\n # Adding some external statistic javascript to track failures served to\n # clients is strongly suggested.\n # We can't use external resources on synthetic content, everything must be\n # inlined.\n # If we need to include images we can embed them in base64 encoding.\n # We're using error 200 for monitoring puposes which should not be retried\n # client side.\n if ( resp.status != 200 ) {\n set resp.http.Retry-After = \"5\";\n }\n\n # Here is the default error page for Varnish 4 (not so pretty)\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n return (deliver);\n}\n\n#######################################################################\n# Backend Fetch\n\n# vcl_backend_fetch: Called before sending the backend request. In this\n# subroutine you typically alter the request before it gets to the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-fetch\n# sub vcl_backend_fetch {\n# return (fetch);\n# }\n\n# vcl_backend_response: Called after the response headers has been successfully\n# retrieved from the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-response\nsub vcl_backend_response {\n \/* Ban lurker friendly bans support *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#bans\n set beresp.http.X-Host = bereq.http.host;\n set beresp.http.X-Url = bereq.url;\n\n \/* Caching exceptions *\/\n # Varnish will cache objects with response codes:\n # 200, 203, 300, 301, 302, 307, 404 & 410.\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/VCL_Basics.html#the-initial-value-of-beresp-ttl\n # Drupal's Imagecache module can return a 307 redirection to the requested\n # url itself and, depending on Drupal's cache settings, this could lead to a\n # redirection loop being cached for a long time but also we want Varnish to\n # shield a little the backend.\n # See http:\/\/drupal.org\/node\/1248010\n # See http:\/\/drupal.org\/node\/310656\n if ( beresp.status == 307\n #TODO# verify that this work better than 'bereq.url ~ \"imagecache\"'\n && beresp.http.Location == bereq.url\n && beresp.ttl > 5s\n ) {\n set beresp.ttl = 5s;\n set beresp.http.cache-control = \"max-age=5\";\n }\n\n \/* Request retrial *\/\n if ( beresp.status == 500\n || beresp.status == 503\n ) {\n #TODO# consider not restarting POST requests as seenV3 on https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleSaintMode\n return (retry);\n }\n\n \/* Enable grace mode. Related with vcl_hit *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n set beresp.grace = 1h;\n\n \/* Strip cookies from the following static file types for all users. *\/\n # Related with our 12th stage on vcl_recv\n if ( bereq.url ~ \"(?i)\\.(bz2|css|eot|gif|gz|html?|ico|jpe?g|js|mp3|ogg|otf|pdf|png|rar|svg|swf|tbz|tgz|ttf|woff2?|zip)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n ) {\n unset beresp.http.set-cookie;\n }\n\n \/* Process ESI responses *\/\n # Empty in simple configs.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/esi.html\n # Send Surrogate-Capability headers\n # See http:\/\/www.w3.org\/TR\/edge-arch\n # Note that myproxyname is an identifier that should avoid collitions\n # Check for ESI acknowledgement and remove Surrogate-Control header\n #TODO# Add support for Surrogate-Control Targetting\n # if ( beresp.http.Surrogate-Control ~ \"ESI\/1.0\" ) {\n # unset beresp.http.Surrogate-Control;\n # set beresp.do_esi = true;\n # }\n\n \/* Gzip response *\/\n # Empty in simple configs.\n # Use Varnish to Gzip respone, if suitable, before storing it on cache.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html\n if ( ! beresp.http.Content-Encoding\n && ( beresp.http.content-type ~ \"(?i)text\"\n || beresp.http.content-type ~ \"(?i)application\/x-javascript\"\n || beresp.http.content-type ~ \"(?i)application\/javascript\"\n || beresp.http.content-type ~ \"(?i)application\/rss+xml\"\n || beresp.http.content-type ~ \"(?i)application\/xml\"\n || beresp.http.content-type ~ \"(?i)Application\/JSON\")\n ) {\n set beresp.do_gzip = true;\n }\n\n \/* Drupal 8's Big Pipe support *\/\n # Tentative support, maybe 'set beresp.ttl = 0s;' is also needed\n if ( beresp.http.Surrogate-Control ~ \"BigPipe\/1.0\" ) {\n set beresp.do_stream = true;\n # Varnish gzipping breaks streaming of the first response\n set beresp.do_gzip = false;\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # We can add the name of the backend that has processed the request:\n # set beresp.http.X-Varnish-Backend = beresp.backend.name;\n # We can use a header to tell if the object was gziped by Varnish:\n # if ( beresp.do_gzip ) {\n # set beresp.http.X-Varnish-Gzipped = \"yes\";\n # } else {\n # set beresp.http.X-Varnish-Gzipped = \"no\";\n # }\n # We can do the same to tell if Varnish is streaming it:\n # if ( beresp.do_stream ) {\n # set beresp.http.X-Varnish-Streaming = \"yes\";\n # } else {\n # set beresp.http.X-Varnish-Streaming = \"no\";\n # }\n # We can also add headers informing whether the object is cacheable or not and why:\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Varnish3.0\n if ( beresp.ttl <= 0s ) {\n \/* Varnish determined the object was not cacheable *\/\n set beresp.http.X-Varnish-Cacheable = \"NO:Not Cacheable\";\n } elsif ( bereq.http.Cookie ~ \"(SESS|SSESS|NO_CACHE|OATMEAL|CHOCOLATECHIP)\" ) {\n \/* We don't wish to cache content for logged in users or with certain cookies. *\/\n # Related with our 9th stage on vcl_recv\n set beresp.http.X-Varnish-Cacheable = \"NO:Cookies\";\n # set beresp.uncacheable = true;\n } elsif ( beresp.http.Cache-Control ~ \"private\" ) {\n \/* We are respecting the Cache-Control=private header from the backend *\/\n set beresp.http.X-Varnish-Cacheable = \"NO:Cache-Control=private\";\n # set beresp.uncacheable = true;\n } else {\n \/* Varnish determined the object was cacheable *\/\n set beresp.http.X-Varnish-Cacheable = \"YES\";\n }\n\n \/* Further header manipulation *\/\n # Empty in simple configs.\n # We can also unset some headers to prevent information disclosure and save\n # some cache space.\n # unset beresp.http.Server;\n # unset beresp.http.X-Powered-By;\n # Retry count.\n if ( bereq.retries > 0 ) {\n set beresp.http.X-Varnish-Retries = bereq.retries;\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_backend_response {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Surrogate-control ~ \"no-store\" ||\n# (!beresp.http.Surrogate-Control &&\n# beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n# beresp.http.Vary == \"*\") {\n# \/*\n# * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# *\/\n# set beresp.ttl = 120s;\n# set beresp.uncacheable = true;\n# }\n# return (deliver);\n# }\n\n# vcl_backend_error: This subroutine is called if we fail the backend fetch.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-error\nsub vcl_backend_error {\n\n \/* Try to restart request in case of failure *\/\n #TODO# Confirm max_retries default value\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if ( bereq.retries < 4 ) {\n return (retry);\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # Retry count\n if ( bereq.retries > 0 ) {\n set beresp.http.X-Varnish-Retries = bereq.retries;\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + beresp.status + \" \" + beresp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + beresp.status + \" \" + beresp.reason + {\"<\/h1>\n <p>\"} + beresp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + bereq.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this\n # point.\n return (deliver);\n}\n\n#######################################################################\n# Housekeeping\n\n# vcl_init: Called when VCL is loaded, before any requests pass through it.\n# Typically used to initialize VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-init\n# Here is where you should declare your directors now.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-backends.html#directors\n# Empty in simple configs\n# sub vcl_init {\n# return (ok);\n# }\n\n# vcl_fini: Called when VCL is discarded only after all requests have exited\n# the VCL. Typically used to clean up VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-fini\n# sub vcl_fini {\n# return (ok);\n# }\n","old_contents":"\/*\n * Varnish 4 example config for Drupal 7 & 8 \/ Pressflow 6 & 7\n *\/\n\n# Original source: https:\/\/github.com\/NITEMAN\/varnish-bites\/varnish4\/drupal-base.vcl\n# Copyright (c) 2015 Pedro Gonz\u00e1lez Serrano and individual contributors.\n# MIT License\n\n# Intended to be used both in simple production environments and with\n# learning\/teaching purposes.\n# Some references may not be yet updated to VCL 4.0, we use SeeV3 then.\n\n# WARNING:\n# Note that the built-in logic will be appended to our code if no return is\n# performed before.\n# Built-in logic is included commented out right after our's for reference\n# purposes in that cases.\n# See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleDefault\n\n#######################################################################\n# Initialization: Version & imports;\n\n\/* Version statement *\/\n# Since Varnish 4.0 it's mandatory to declare VCL version on first line.\nvcl 4.0;\n\n\/* Module (VMOD) imports *\/\n# Standard module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_std.generated.html\nimport std;\n\n# Directors module\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# Unused in simple configs.\n#import directors;\n\n\n#######################################################################\n# Probe, backend, ACL and subroutine definitions\n\n\/* Backend probes \/ healthchecks *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#probes\nprobe basic {\n \/* Only test that backend's IP serves content for '\/' *\/\n # This might be a too heavy probe\n # .url = \"\/\";\n\n \/* Only test that backend's IP has apache working *\/\n # Nginx would fail this probe with a default config\n .request =\n \"OPTIONS * HTTP\/1.1\"\n \"Host: *\"\n \"Connection: close\";\n\n \/* Common options *\/\n .interval = 10s;\n .timeout = 2s;\n .window = 8;\n .threshold = 6;\n}\n\n\/* Backend definitions.*\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#backend-definition\nbackend default {\n \/* Default backend on the same machine. *\/\n # WARNING: timeouts could be not big enought for certain POST requests.\n .host = \"127.0.0.1\";\n .port = \"8008\";\n .max_connections = 100;\n .connect_timeout = 60s;\n .first_byte_timeout = 60s;\n .between_bytes_timeout = 60s;\n .probe = basic;\n}\n\n\/* Access Control Lists *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#access-control-list-acl\nacl purge_ban {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use '\"localhost\";' instead\n}\nacl allowed_monitors {\n \/* Simple access control list for allowing item purge for the self machine *\/\n \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n}\n# acl own_proxys {\n# \"127.0.0.1\"\/32; \/\/ We can use'\"localhost\";' instead\n# }\n\n\/* Custom subroutines *\/\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vcl.html#subroutines\n#TODO# Test in Varnihs 4\n# Empty in simple configs.\n# The only restriction naming subs is that the 'vlc_' prefix is reserverd for\n# Varnish use. As a task can need several chunks of code in diferent states,\n# it's a good idea to identify what main sub will call each with a suffix.\n# \/* Example 301 client redirection removing \"www\" prefix from request *\/\n# sub perm_redirections_recv {\n# if ( req.http.host ~ \"^www.*$\" ) {\n# return (\n# synth(751, \"http:\/\/\" + regsub(req.http.host, \"^www\\.\", \"\") + req.url)\n# );\n# }\n# }\n# sub perm_redirections_synth {\n# if ( resp.status == 751 ) {\n# \/* Get new URL from the response *\/\n# set resp.http.Location = resp.reason;\n# \/* Set HTTP 301 for permanent redirect *\/\n# set resp.status = 301;\n# set resp.reason = \"Moved Permanently\";\n# return (deliver);\n# }\n# }\n\n\n#######################################################################\n# Client side\n\n# vcl_recv: Called at the beginning of a request, after the complete request\n# has been received and parsed. Its purpose is to decide whether or not to\n# serve the request, how to do it, and, if applicable, which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-recv\nsub vcl_recv {\n \/* 0th: general bypass, general return & authorization checks *\/\n # Empty in simple configs.\n # Useful for debugging we can pipe or pass the request to default backend\n # here to bypass completely Varnish.\n # return (pipe);\n # return (pass);\n # We can also return here a 200 Ok for network performance benchmarking.\n # return (synth(200, \"Ok\"));\n # Finally we can perform basic HTTP authentification here, by example.\n # SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* 1st: Check for Varnish special requests *\/\n # Custom response implementation example in order to check that Varnish is\n # working properly.\n # This is usefull for automatic monitoring with monit or when Varnish is\n # behind another proxies like HAProxy.\n if ( ( req.http.host == \"monitor.server.health\"\n || req.http.host == \"health.varnish\" )\n && client.ip ~ allowed_monitors\n && ( req.method == \"OPTIONS\" || req.method == \"GET\" )\n ) {\n return (synth(200, \"OK\"));\n }\n # Purge logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#http-purging\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/Cache_invalidation.html#removing-a-single-object\n if ( req.method == \"PURGE\" ) {\n if ( client.ip !~ purge_ban ) {\n return (synth(405, \"Not allowed.\"));\n }\n return (purge);\n }\n # Ban logic\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#bans\n if ( req.method == \"BAN\" ) {\n if ( client.ip !~ purge_ban ) {\n return (synth(405, \"Not allowed.\"));\n }\n if (req.http.Purge-Cache-Tags) {\n ban( \"obj.http.X-Host == \" + req.http.host +\n \" && obj.http.Purge-Cache-Tags ~ \" + req.http.Purge-Cache-Tags\n );\n }\n else {\n # Assumes req.url is a regex. This might be a bit too simple\n ban( \"obj.http.X-Host == \" + req.http.host +\n \" && obj.http.X-Url ~ \" + req.url\n );\n }\n return (synth(200, \"Ban added\"));\n }\n\n \/* 2nd: Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_recv;\n # Here we can also enforce SSL when Varnish run behind some SSL termination\n # point.\n\n \/* 3rd: Time for backend choice *\/\n # Empty in simple configs.\n\n \/* 4th: Prepare request for the backend *\/\n # Empty in simple configs.\n # Example remove own_proxys from X-Forwarded-For\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/whats-new\/upgrading.html#x-forwarded-for-is-now-set-before-vcl-recv\n # Varnish 4 regsub doesn't accept anything but plain regexp, so we can't use\n # client.ip to exclude the proxy ips from the request:\n # set req.http.X-Forwarded-For\n # = regsub(req.http.X-Forwarded-For, \",( )?\" + client.ip, \"\");\n # Instead, we need to add the proxy ips manually in the exclude list:\n # if ( req.restarts == 0\n # && client.ip ~ own_proxys\n # && req.http.X-Forwarded-For\n # ) {\n # set req.http.X-Forwarded-For\n # = regsub(req.http.X-Forwarded-For,\n # \"(, )?(10\\.10\\.10\\.10|10\\.11\\.11\\.11)\", \"\");\n # }\n # An alternative could be to skip all this and try to modify the header\n # manually so Varnish doesn't touch it.\n # set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \"\";\n #\n # Example normalize the host header, remove the port (in case you're testing\n # this on various TCP ports)\n # set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n \/* 5th: Bypass breakpoint 1 *\/\n # Useful for debugging we can now pipe or pass the request to backend with\n # headers setted.\n # return (pipe);\n # return (pass);\n\n \/* 6th: Decide if we should deal with a request (mostly from built-in logic) *\/\n if ( req.method == \"PRI\" ) {\n \/* We do not support SPDY or HTTP\/2.0 *\/\n return (synth(405));\n }\n if ( req.method != \"GET\"\n && req.method != \"HEAD\"\n && req.method != \"PUT\"\n && req.method != \"POST\"\n && req.method != \"TRACE\"\n && req.method != \"OPTIONS\"\n && req.method != \"DELETE\"\n ) {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if ( req.method != \"GET\"\n && req.method != \"HEAD\"\n ) {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if ( req.http.Authorization ) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n # Websocket support\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html\n if ( req.http.Upgrade ~ \"(?i)websocket\" ) {\n return (pipe);\n }\n\n \/* 7th: Access control for some URLs by ACL *\/\n # Empty in simple configs.\n # By example denial some URLs depending on client-ip, we'll need to define\n # corresponding ACL 'internal'.\n # if ( req.url ~ \"^\/(cron|install)\\.php\"\n # && client.ip !~ internal\n # ) {\n # # Have Varnish throw the error directly.\n # return (synth(403, \"Forbidden.\"));\n # # Use a custom error page that you've defined in Drupal at the path \"404\".\n # # set req.url = \"\/403\";\n # }\n\n \/* 8th: Custom exceptions *\/\n # Host exception example:\n # if ( req.http.host == \"ejemplo.exception.com\" ) {\n # return (pass);\n # }\n # Drupal exceptions, edit if we want to cache some AJAX\/AHAH request.\n # Add here filters for never cache URLs such as Payment Gateway's callbacks.\n if ( req.url ~ \"^\/status\\.php$\"\n || req.url ~ \"^\/update\\.php$\"\n || req.url ~ \"^\/ooyala\/ping$\"\n || req.url ~ \"^\/admin\/build\/features\"\n || req.url ~ \"^\/info\/.*$\"\n || req.url ~ \"^\/flag\/.*$\"\n || req.url ~ \"^.*\/ajax\/.*$\"\n || req.url ~ \"^.*\/ahah\/.*$\"\n ) {\n \/* Do not cache these paths *\/\n return (pass);\n }\n # Pipe these paths directly to backend for streaming.\n if ( req.url ~ \"^\/admin\/content\/backup_migrate\/export\"\n || req.url ~ \"^\/admin\/config\/system\/backup_migrate\"\n ) {\n return (pipe);\n }\n if ( req.url ~ \"^\/system\/files\" ) {\n return (pipe);\n }\n\n \/* 9th: Graced objets & Serve from anonymous cahe if all backends are down *\/\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n # set req.http.X-Varnish-Grace = \"none\";\n if ( ! std.healthy(req.backend_hint) ) {\n # We must do this here since cookie hashing\n unset req.http.Cookie;\n #TODO# Add sick marker\n }\n\n \/* 10th: Deal with compression and the Accept-Encoding header *\/\n # Althought Varnish 4 handles gziped content itself by default, just to be\n # sure we want to remove Accept-Encoding for some compressed formats.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html#what-does-http-gzip-support-do\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/varnishd.html?highlight=http_gzip_support\n # See (for older configs) https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleNormalizeAcceptEncoding\n if ( req.http.Accept-Encoding ) {\n if ( req.url ~ \"(?i)\\.(7z|avi|bz2|flv|gif|gz|jpe?g|mpe?g|mk[av]|mov|mp[34]|og[gm]|pdf|png|rar|swf|tar|tbz|tgz|woff2?|zip|xz)(\\?.*)?$\"\n ) {\n \/* Already compressed formats, no sense trying to compress again *\/\n unset req.http.Accept-Encoding;\n }\n }\n\n \/* 11th: Further request manipulation *\/\n # Empty in simple configs.\n # We could add here a custom header grouping User-agent families.\n # Generic URL manipulation.\n # Remove Google Analytics added parameters, useless for our backends.\n if ( req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=\" ) {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n # Strip anchors, server doesn't need it.\n if ( req.url ~ \"\\#\" ) {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n # Strip a trailing ? if it exists\n if ( req.url ~ \"\\?$\" ) {\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n # Normalize the querystring arguments\n set req.url = std.querysort(req.url);\n\n \/* 12th: Cookie removal *\/\n # Always cache the following static file types for all users.\n # Use with care if we control certain downloads depending on cookies.\n # Be carefull also if appending .htm[l] via Drupal's clean URLs.\n if ( req.url ~ \"(?i)\\.(bz2|css|eot|gif|gz|html?|ico|jpe?g|js|mp3|ogg|otf|pdf|png|rar|svg|swf|tbz|tgz|ttf|woff2?|zip)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n && req.url !~ \"\/system\/storage\/serve\"\n ) {\n unset req.http.Cookie;\n }\n # Remove all cookies that backend doesn't need to know about.\n # See https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRemovingSomeCookies\n if ( req.http.Cookie ) {\n \/* Warning: Not a pretty solution *\/\n # Prefix header containing cookies with ';'\n set req.http.Cookie = \";\" + req.http.Cookie;\n # Remove any spaces after ';' in header containing cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n # Prefix cookies we want to preserve with one space:\n # 'S{1,2}ESS[a-z0-9]+' is the regular expression matching a Drupal session\n # cookie ({1,2} added for HTTPS support).\n # 'NO_CACHE' is usually set after a POST request to make sure issuing user\n # see the results of his post.\n # 'OATMEAL' & 'CHOCOLATECHIP' are special cookies used by Drupal's Bakery\n # module to provide Single Sign On.\n # Keep in mind we should add here any cookie that should reach the backend\n # such as splash avoiding cookies.\n set req.http.Cookie\n = regsuball(\n req.http.Cookie,\n \";(S{1,2}ESS[a-z0-9]+|NO_CACHE|OATMEAL|CHOCOLATECHIP)=\",\n \"; \\1=\"\n );\n # Remove from the header any single Cookie not prefixed with a space until\n # next ';' separator.\n set req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n # Remove any '; ' at the start or the end of the header.\n set req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n #If there are no remaining cookies, remove the cookie header.\n if ( req.http.Cookie == \"\" ) {\n unset req.http.Cookie;\n }\n }\n\n \/* 13th: Session cookie & special cookies bypass caching stage *\/\n # As we might want to cache some requests, hashed with its cookies, we don't\n # simply pass when some cookies remain present at this point.\n # Instead we look for request that must be passed due to the cookie header.\n if ( req.http.Cookie ~ \"SESS\"\n || req.http.Cookie ~ \"SSESS\"\n || req.http.Cookie ~ \"NO_CACHE\"\n || req.http.Cookie ~ \"OATMEAL\"\n || req.http.Cookie ~ \"CHOCOLATECHIP\"\n ) {\n return (pass);\n }\n\n \/* 14th: Announce ESI Support *\/\n # Empty in simple configs.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/esi.html\n # Note that ESI included requests inherits its parent's modified request, so\n # depending on the case you will end playing with req.esi_level to know\n # current depth.\n # Send Surrogate-Capability headers\n # See http:\/\/www.w3.org\/TR\/edge-arch\n # Note that myproxyname is an identifier that should avoid collitions\n # set req.http.Surrogate-Capability = \"myproxyname=ESI\/1.0\";\n\n \/* 15th: Bypass breakpoint 2 *\/\n # Useful for debugging we can now pipe or pass the request to backend to\n # bypass cache.\n # return (pipe);\n # return (pass);\n\n \/* 16th: Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n return (hash);\n}\n\n# vcl_pipe: Called upon entering pipe mode.\n# In this mode, the request is passed on to the backend, and any further data\n# from either client or backend is passed on unaltered until either end closes\n# the connection.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pipe\nsub vcl_pipe {\n # Websocket support\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html\n if ( req.http.upgrade ) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n}\n# sub vcl_pipe {\n# # By default Connection: close is set on all piped requests, to stop\n# # connection reuse from sending future requests directly to the\n# # (potentially) wrong backend. If you do want this to happen, you can undo\n# # it here.\n# # unset bereq.http.connection;\n# return (pipe);\n# }\n\n# vcl_pass: Called upon entering pass mode.\n# In this mode, the request is passed on to the backend, and the backend's\n# response is passed on to the client, but is not entered into the cache.\n# Subsequent requests submitted over the same client connection are handled normally.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-pass\n# sub vcl_pass {\n# return (fetch);\n# }\n\n# vcl_hash: You may call hash_data() on the data you would like to add to the\n# hash.\n# Hash is used by Varnish to uniquely identify objects.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hash\nsub vcl_hash {\n \/* Hash cookie data *\/\n # As requests with same URL and host can produce diferent results when issued\n # with different cookies, we need to store items hashed with the associated\n # cookies. Note that cookies are already sanitized when we reach this point.\n if ( req.http.Cookie ) {\n \/* Include cookie in cache hash *\/\n hash_data(req.http.Cookie);\n }\n\n \/* Custom header hashing *\/\n # Empty in simple configs.\n # Example for caching differents object versions by device previously\n # detected (when static content could also vary):\n # if ( req.http.X-UA-Device ) {\n # hash_data(req.http.X-UA-Device);\n # }\n # Example for caching diferent object versions by X-Forwarded-Proto, trying\n # to be smart about what kind of request could generate diffetent responses.\n if ( req.http.X-Forwarded-Proto\n && req.url !~ \"(?i)\\.(bz2|css|eot|gif|gz|html?|ico|jpe?g|js|mp3|ogg|otf|pdf|png|rar|svg|swf|tbz|tgz|ttf|woff2?|zip)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n ) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (lookup);\n# }\n\n# vcl_purge: Called after the purge has been executed and all its variants have\n# been evited.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-purge\n# sub vcl_purge {\n# return (synth(200, \"Purged\"));\n# }\n\n# vcl_hit: Called after a cache lookup if the requested document was found in\n# the cache.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-hit\nsub vcl_hit {\n if ( obj.ttl >= 0s ) {\n \/\/ A pure unadultered hit, deliver it\n return (deliver);\n }\n \/* Allow varnish to serve up stale content if it is responding slowly *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n if ( obj.ttl + 60s > 0s ) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n set req.http.X-Varnish-Grace = \"normal\";\n return (deliver);\n }\n \/* Allow varish to serve up stale content if all backends are down *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n if ( ! std.healthy(req.backend_hint)\n && obj.ttl + obj.grace > 0s\n ) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n set req.http.X-Varnish-Grace = \"extended\";\n return (deliver);\n }\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\n# vcl_miss: Called after a cache lookup if the requested document was not found\n# in the cache.\n# Its purpose is to decide whether or not to attempt to retrieve the document\n# from the backend, and which backend to use.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-miss\n# sub vcl_miss {\n# return (fetch);\n# }\n\n# vcl_deliver: Called before an object is delivered to the client\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-deliver\nsub vcl_deliver {\n \/* Ban lurker friendly bans support *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#bans\n unset resp.http.X-Host;\n unset resp.http.X-Url;\n\n \/* Drupal 8 Purge's module header cleanup *\/\n # Purge's headers can become quite big, causing issues in upstream proxies, so we clean it here\n unset resp.http.Purge-Cache-Tags;\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # Add whether the object is a cache hit or miss and the number of hits for\n # the object.\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Addingaheaderindicatinghitmiss\n # In Varnish 4 the obj.hits counter behaviour has changed (see bug 1492), so\n # we use a different method: if X-Varnish contains only 1 id, we have a miss,\n # if it contains more (and therefore a space), we have a hit.\n if ( resp.http.X-Varnish ~ \" \" ) {\n set resp.http.X-Varnish-Cache = \"HIT\";\n # Since in Varnish 4 the behaviour of obj.hits changed, this might not be\n # accurate.\n # See https:\/\/www.varnish-cache.org\/trac\/ticket\/1492\n set resp.http.X-Varnish-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Varnish-Cache = \"MISS\";\n \/* Show the results of cookie sanitization *\/\n if ( req.http.Cookie ) {\n set resp.http.X-Varnish-Cookie = req.http.Cookie;\n }\n }\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n if ( req.http.X-Varnish-Grace ) {\n set resp.http.X-Varnish-Grace = req.http.X-Varnish-Grace;\n }\n\n #TODO# Add sick marker\n\n # Restart count\n if ( req.restarts > 0 ) {\n set resp.http.X-Varnish-Restarts = req.restarts;\n }\n\n # Add the Varnish server hostname\n set resp.http.X-Varnish-Server = server.hostname;\n # If we have setted a custom header with device's family detected we can show\n # it:\n # if ( req.http.X-UA-Device ) {\n # set resp.http.X-UA-Device = req.http.X-UA-Device;\n # }\n # If we have recived a custom header indicating the protocol in the request we\n # can show it:\n # if ( req.http.X-Forwarded-Proto ) {\n # set resp.http.X-Forwarded-Proto = req.http.X-Forwarded-Proto;\n # }\n\n \/* Vary header manipulation *\/\n # Empty in simple configs.\n # By example, if we are storing & serving diferent objects depending on\n # User-Agent header we must set the correct Vary header:\n # if ( resp.http.Vary ) {\n # set resp.http.Vary = resp.http.Vary + \",User-Agent\";\n # } else {\n # set resp.http.Vary = \"User-Agent\";\n # }\n\n \/* Fake headers *\/\n # Empty in simple configs\n # We can fake server headers here, by example:\n # set resp.http.Server = \"Deep thought\";\n # set resp.http.X-Powered-By = \"BOFH\";\n # Or have some fun with headers:\n # See http:\/\/www.nextthing.org\/archives\/2005\/08\/07\/fun-with-http-headers\n # See http:\/\/royal.pingdom.com\/2012\/08\/15\/fun-and-unusual-http-response-headers\/\n # set resp.http.X-Thank-You = \"for bothering to look at my HTTP headers\";\n # set resp.http.X-Answer = \"42\";\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_deliver {\n# return (deliver);\n# }\n\n# vcl_synth: Called to deliver a synthetic object. A synthetic object is\n# generated in VCL, not fetched from the backend. It is typically contructed\n# using the synthetic() function.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-synth\n\/*\n * We can come here \"invisibly\" with the following errors: 413, 417 & 503\n *\/\nsub vcl_synth {\n \/* Do some Varnish black magic such as custom client redirections *\/\n # Empty in simple configs.\n # call perm_redirections_synth;\n\n \/* Try to restart request in case of failure *\/\n # Note that max_restarts defaults to 4\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if ( resp.status == 503\n && req.restarts < 4\n ) {\n return (restart);\n }\n\n \/* Set common headers for synthetic responses *\/\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n\n \/* HTTP Authentification client request *\/\n # Empty in simple configs.\n # SeeV3 http:\/\/blog.tenya.me\/blog\/2011\/12\/14\/varnish-http-authentication\/\n\n \/* Load synthetic responses from disk *\/\n # Note that files loaded this way are never re-readed (even after a reload).\n # You should consider PROS\/CONS of doing an include instead.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_std.generated.html#func-fileread\n # Example custom 403 error page.\n # if ( resp.status == 403 ) {\n # synthetic(std.fileread(\"\/403.html\"));\n # return (deliver);\n # }\n\n \/* Error page & refresh \/ redirections *\/\n # We have plenty of choices when we have to serve an error to the client,\n # from the default error page to javascript black magic or plain redirections.\n # Adding some external statistic javascript to track failures served to\n # clients is strongly suggested.\n # We can't use external resources on synthetic content, everything must be\n # inlined.\n # If we need to include images we can embed them in base64 encoding.\n # We're using error 200 for monitoring puposes which should not be retried\n # client side.\n if ( resp.status != 200 ) {\n set resp.http.Retry-After = \"5\";\n }\n\n # Here is the default error page for Varnish 4 (not so pretty)\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning\n # inconditionally.\n return (deliver);\n}\n\n#######################################################################\n# Backend Fetch\n\n# vcl_backend_fetch: Called before sending the backend request. In this\n# subroutine you typically alter the request before it gets to the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-fetch\n# sub vcl_backend_fetch {\n# return (fetch);\n# }\n\n# vcl_backend_response: Called after the response headers has been successfully\n# retrieved from the backend.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-response\nsub vcl_backend_response {\n \/* Ban lurker friendly bans support *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/purging.html#bans\n set beresp.http.X-Host = bereq.http.host;\n set beresp.http.X-Url = bereq.url;\n\n \/* Caching exceptions *\/\n # Varnish will cache objects with response codes:\n # 200, 203, 300, 301, 302, 307, 404 & 410.\n # SeeV3 https:\/\/www.varnish-software.com\/static\/book\/VCL_Basics.html#the-initial-value-of-beresp-ttl\n # Drupal's Imagecache module can return a 307 redirection to the requested\n # url itself and, depending on Drupal's cache settings, this could lead to a\n # redirection loop being cached for a long time but also we want Varnish to\n # shield a little the backend.\n # See http:\/\/drupal.org\/node\/1248010\n # See http:\/\/drupal.org\/node\/310656\n if ( beresp.status == 307\n #TODO# verify that this work better than 'bereq.url ~ \"imagecache\"'\n && beresp.http.Location == bereq.url\n && beresp.ttl > 5s\n ) {\n set beresp.ttl = 5s;\n set beresp.http.cache-control = \"max-age=5\";\n }\n\n \/* Request retrial *\/\n if ( beresp.status == 500\n || beresp.status == 503\n ) {\n #TODO# consider not restarting POST requests as seenV3 on https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleSaintMode\n return (retry);\n }\n\n \/* Enable grace mode. Related with vcl_hit *\/\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-grace.html\n # See https:\/\/www.varnish-software.com\/blog\/grace-varnish-4-stale-while-revalidate-semantics-varnish\n set beresp.grace = 1h;\n\n \/* Strip cookies from the following static file types for all users. *\/\n # Related with our 12th stage on vcl_recv\n if ( bereq.url ~ \"(?i)\\.(bz2|css|eot|gif|gz|html?|ico|jpe?g|js|mp3|ogg|otf|pdf|png|rar|svg|swf|tbz|tgz|ttf|woff2?|zip)(\\?(itok=)?[a-z0-9_=\\.\\-]+)?$\"\n ) {\n unset beresp.http.set-cookie;\n }\n\n \/* Process ESI responses *\/\n # Empty in simple configs.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/esi.html\n # Send Surrogate-Capability headers\n # See http:\/\/www.w3.org\/TR\/edge-arch\n # Note that myproxyname is an identifier that should avoid collitions\n # Check for ESI acknowledgement and remove Surrogate-Control header\n #TODO# Add support for Surrogate-Control Targetting\n # if ( beresp.http.Surrogate-Control ~ \"ESI\/1.0\" ) {\n # unset beresp.http.Surrogate-Control;\n # set beresp.do_esi = true;\n # }\n\n \/* Gzip response *\/\n # Empty in simple configs.\n # Use Varnish to Gzip respone, if suitable, before storing it on cache.\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/compression.html\n # See https:\/\/www.varnish-cache.org\/docs\/4.0\/phk\/gzip.html\n if ( ! beresp.http.Content-Encoding\n && ( beresp.http.content-type ~ \"(?i)text\"\n || beresp.http.content-type ~ \"(?i)application\/x-javascript\"\n || beresp.http.content-type ~ \"(?i)application\/javascript\"\n || beresp.http.content-type ~ \"(?i)application\/rss+xml\"\n || beresp.http.content-type ~ \"(?i)application\/xml\"\n || beresp.http.content-type ~ \"(?i)Application\/JSON\")\n ) {\n set beresp.do_gzip = true;\n }\n\n \/* Drupal 8's Big Pipe support *\/\n # Tentative support, maybe 'set beresp.ttl = 0s;' is also needed\n if ( beresp.http.Surrogate-Control ~ \"BigPipe\/1.0\" ) {\n set beresp.do_stream = true;\n # Varnish gzipping breaks streaming of the first response\n set beresp.do_gzip = false;\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # We can add the name of the backend that has processed the request:\n # set beresp.http.X-Varnish-Backend = beresp.backend.name;\n # We can use a header to tell if the object was gziped by Varnish:\n # if ( beresp.do_gzip ) {\n # set beresp.http.X-Varnish-Gzipped = \"yes\";\n # } else {\n # set beresp.http.X-Varnish-Gzipped = \"no\";\n # }\n # We can do the same to tell if Varnish is streaming it:\n # if ( beresp.do_stream ) {\n # set beresp.http.X-Varnish-Streaming = \"yes\";\n # } else {\n # set beresp.http.X-Varnish-Streaming = \"no\";\n # }\n # We can also add headers informing whether the object is cacheable or not and why:\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleHitMissHeader#Varnish3.0\n if ( beresp.ttl <= 0s ) {\n \/* Varnish determined the object was not cacheable *\/\n set beresp.http.X-Varnish-Cacheable = \"NO:Not Cacheable\";\n } elsif ( bereq.http.Cookie ~ \"(SESS|SSESS|NO_CACHE|OATMEAL|CHOCOLATECHIP)\" ) {\n \/* We don't wish to cache content for logged in users or with certain cookies. *\/\n # Related with our 9th stage on vcl_recv\n set beresp.http.X-Varnish-Cacheable = \"NO:Cookies\";\n # set beresp.uncacheable = true;\n } elsif ( beresp.http.Cache-Control ~ \"private\" ) {\n \/* We are respecting the Cache-Control=private header from the backend *\/\n set beresp.http.X-Varnish-Cacheable = \"NO:Cache-Control=private\";\n # set beresp.uncacheable = true;\n } else {\n \/* Varnish determined the object was cacheable *\/\n set beresp.http.X-Varnish-Cacheable = \"YES\";\n }\n\n \/* Further header manipulation *\/\n # Empty in simple configs.\n # We can also unset some headers to prevent information disclosure and save\n # some cache space.\n # unset beresp.http.Server;\n # unset beresp.http.X-Powered-By;\n # Retry count.\n if ( bereq.retries > 0 ) {\n set beresp.http.X-Varnish-Retries = bereq.retries;\n }\n\n \/* Continue with built-in logic *\/\n # We want built-in logic to be processed after ours so we don't call return.\n}\n# sub vcl_backend_response {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Surrogate-control ~ \"no-store\" ||\n# (!beresp.http.Surrogate-Control &&\n# beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n# beresp.http.Vary == \"*\") {\n# \/*\n# * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# *\/\n# set beresp.ttl = 120s;\n# set beresp.uncacheable = true;\n# }\n# return (deliver);\n# }\n\n# vcl_backend_error: This subroutine is called if we fail the backend fetch.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-backend-error\nsub vcl_backend_error {\n\n \/* Try to restart request in case of failure *\/\n #TODO# Confirm max_retries default value\n # SeeV3 https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleRestarts\n if ( bereq.retries < 4 ) {\n return (retry);\n }\n\n \/* Debugging headers *\/\n # Please consider the risks of showing publicly this information, we can wrap\n # this with an ACL.\n # Retry count\n if ( bereq.retries > 0 ) {\n set beresp.http.X-Varnish-Retries = bereq.retries;\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + beresp.status + \" \" + beresp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + beresp.status + \" \" + beresp.reason + {\"<\/h1>\n <p>\"} + beresp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + bereq.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n\n \/* Bypass built-in logic *\/\n # We make sure no built-in logic is processed after ours returning at this\n # point.\n return (deliver);\n}\n\n#######################################################################\n# Housekeeping\n\n# vcl_init: Called when VCL is loaded, before any requests pass through it.\n# Typically used to initialize VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-init\n# Here is where you should declare your directors now.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/reference\/vmod_directors.generated.html\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-backends.html#directors\n# Empty in simple configs\n# sub vcl_init {\n# return (ok);\n# }\n\n# vcl_fini: Called when VCL is discarded only after all requests have exited\n# the VCL. Typically used to clean up VMODs.\n# See https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-built-in-subs.html#vcl-fini\n# sub vcl_fini {\n# return (ok);\n# }\n","returncode":0,"stderr":"","license":"unknown","lang":"VCL"} {"commit":"e5a3a887ed9d1a123a8ee23442d5d2b4e80791c2","subject":"Typo fix","message":"Typo fix\n","repos":"kevinquinnyo\/varnish-devicedetect,wikp\/varnish-devicedetect,varnish\/varnish-devicedetect,varnish\/varnish-devicedetect,kevinquinnyo\/varnish-devicedetect,wikp\/varnish-devicedetect","old_file":"devicedetect.vcl","new_file":"devicedetect.vcl","new_contents":"#\n# detectdevice.vcl - regex based device detection for Varnish\n# http:\/\/github.com\/varnish\/varnish-devicedetect\/\n#\n# Author: Lasse Karstensen <lasse@varnish-software.com>\n\nsub devicedetect {\n\tunset req.http.X-UA-Device;\n\tset req.http.X-UA-Device = \"pc\";\n\n\t# Handle that a cookie may override the detection alltogether.\n\tif (req.http.Cookie ~ \"(?i)X-UA-Device-force\") {\n\t\t\/* ;?? means zero or one ;, non-greedy to match the first. *\/\n\t\tset req.http.X-UA-Device = regsub(req.http.Cookie, \"(?i).*X-UA-Device-force=([^;]+);??.*\", \"\\1\");\n\t\t\/* Clean up our mess in the cookie header *\/\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|; ) *X-UA-Device-force=[^;]+;? *\", \"\\1\");\n\t\t\/* If the cookie header is now empty, or just whitespace, unset it. *\/\n\t\tif (req.http.Cookie ~ \"^ *$\") { unset req.http.Cookie; }\n\t} else {\n\t\tif (req.http.User-Agent ~ \"(?i)(ads|google|bing|msn|yandex|baidu|ro|career|)bot\" ||\n\t\t req.http.User-Agent ~ \"(?i)(baidu|jike|symantec)spider\" ||\n\t\t req.http.User-Agent ~ \"(?i)scanner\" ||\n\t\t req.http.User-Agent ~ \"(?i)(web)crawler\") {\n\t\t\tset req.http.X-UA-Device = \"bot\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ip(hone|od)\") { set req.http.X-UA-Device = \"mobile-iphone\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ipad\") { set req.http.X-UA-Device = \"tablet-ipad\"; }\n\t\t\/* how do we differ between an android phone and an android tablet?\n\t\t http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent *\/\n\t\telsif (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") { set req.http.X-UA-Device = \"mobile-android\"; }\n\t\t\/\/ android 3\/honeycomb was just about tablet-only, and any phones will probably handle a bigger page layout.\n\t\telsif (req.http.User-Agent ~ \"(?i)android 3\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\t\/\/ May very well give false positives towards android tablets. Suggestions welcome.\n\t\telsif (req.http.User-Agent ~ \"(?i)android\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\telsif (req.http.User-Agent ~ \"Mobile.+Firefox\") { set req.http.X-UA-Device = \"mobile-firefoxos\"; }\n\t\telsif (req.http.User-Agent ~ \"^HTC\" ||\n\t\t req.http.User-Agent ~ \"Fennec\" ||\n\t\t req.http.User-Agent ~ \"IEMobile\" ||\n\t\t req.http.User-Agent ~ \"BlackBerry\" ||\n\t\t req.http.User-Agent ~ \"SymbianOS.*AppleWebKit\" ||\n\t\t req.http.User-Agent ~ \"Opera Mobi\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-smartphone\";\n\t\t}\n\t\telsif (req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)^sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)^nokia\" ||\n\t\t req.http.User-Agent ~ \"(?i)^samsung\" ||\n\t\t req.http.User-Agent ~ \"(?i)^lg\" ||\n\t\t req.http.User-Agent ~ \"(?i)bada\" ||\n\t\t req.http.User-Agent ~ \"(?i)blazer\" ||\n\t\t req.http.User-Agent ~ \"(?i)cellphone\" ||\n\t\t req.http.User-Agent ~ \"(?i)iemobile\" ||\n\t\t req.http.User-Agent ~ \"(?i)midp-2.0\" ||\n\t\t req.http.User-Agent ~ \"(?i)u990\" ||\n\t\t req.http.User-Agent ~ \"(?i)netfront\" ||\n\t\t req.http.User-Agent ~ \"(?i)opera mini\" ||\n\t\t req.http.User-Agent ~ \"(?i)palm\" ||\n\t\t req.http.User-Agent ~ \"(?i)nintendo wii\" ||\n\t\t req.http.User-Agent ~ \"(?i)playstation portable\" ||\n\t\t req.http.User-Agent ~ \"(?i)portalmmm\" ||\n\t\t req.http.User-Agent ~ \"(?i)proxinet\" ||\n\t\t req.http.User-Agent ~ \"(?i)sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)windows\\ ?ce\" ||\n\t\t req.http.User-Agent ~ \"(?i)winwap\" ||\n\t\t req.http.User-Agent ~ \"(?i)eudoraweb\" ||\n\t\t req.http.User-Agent ~ \"(?i)htc\" ||\n\t\t req.http.User-Agent ~ \"(?i)240x320\" ||\n\t\t req.http.User-Agent ~ \"(?i)avantgo\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-generic\";\n\t\t}\n\t}\n}\n","old_contents":"#\n# detectdevice.vcl - regex based device detection for Varnish\n# http:\/\/github.com\/varnish\/varnish-devicedetect\/\n#\n# Author: Lasse Karstensen <lasse@varnish-software.com>\n\nsub devicedetect {\n\tunset req.http.X-UA-Device;\n\tset req.http.X-UA-Device = \"pc\";\n\n\t# Handle that a cookie may override the detection alltogether.\n\tif (req.http.Cookie ~ \"(?i)X-UA-Device-force\") {\n\t\t\/* ;?? means zero or one ;, non-greedy to match the first. *\/\n\t\tset req.http.X-UA-Device = regsub(req.http.Cookie, \"(?i).*X-UA-Device-force=([^;]+);??.*\", \"\\1\");\n\t\t\/* Clean up our mess in the cookie header *\/\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|; ) *X-UA-Device-force=[^;]+;? *\", \"\\1\");\n\t\t\/* If the cookie header is now empty, or just whitespace, unset it. *\/\n\t\tif (req.http.Cookie ~ \"^ *$\") { unset req.http.Cookie; }\n\t} else {\n\t\tif (req.http.User-Agent ~ \"(?i)(ads|google|bing|msn|yandex|baidu|ro|career|)bot\" ||\n\t\t req.http.User-Agent ~ \"(?i)(baidu|jike|symantec)spider\" ||\n\t\t req.http.User-Agent ~ \"(?i)scanner\" ||\n\t\t req.http.User-Agent ~ \"(?i)(web)crawler\") {\n\t\t\tset req.http.X-UA-Device = \"bot\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ip(hone|od)\") { set req.http.X-UA-Device = \"mobile-iphone\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ipad\") { set req.http.X-UA-Device = \"tablet-ipad\"; }\n\t\t\/* how do we differ between an android phone and an android tablet?\n\t\t http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent *\/\n\t\telsif (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") { set req.http.X-UA-Device = \"mobile-android\"; }\n\t\t\/\/ android 3\/honeycomb was just about tablet-only, and any phones will probably handle a bigger page layout.\n\t\telsif (req.http.User-Agent ~ \"(?i)android 3\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\t\/\/ May very well give false positives towards android tablets. Suggestions welcome.\n\t\telsif (req.http.User-Agent ~ \"(?i)android\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\telsif (req.http.User-Agent ~ \"Mobile.+Firefox\") { set req.http.X-UA-Device = \"mobile-firefoxos\"; }\n\t\telsif (req.http.User-Agent ~ \"^HTC\" ||\n\t\t req.http.User-Agent ~ \"Fennec\" ||\n\t\t req.http.User-Agent ~ \"IEMobile\" ||\n\t\t req.http.User-Agent ~ \"BlackBerry\" ||\n\t\t req.http.User-Agent ~ \"SymbianOS.*AppleWebKit\" ||\n\t\t req.http.User-Agent ~ \"Opera Mobi\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-smartphone\";\n\t\t}\n\t\telsif (req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)^sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)^nokia\" ||\n\t\t req.http.User-Agent ~ \"(?i)^samsung\" ||\n\t\t req.http.User-Agent ~ \"(?i)^lg\" ||\n\t\t req.http.User-Agent ~ \"(?i)bada\" ||\n\t\t req.http.User-Agent ~ \"(?i)blazer\" ||\n\t\t req.http.User-Agent ~ \"(?i)cellphone\" ||\n\t\t req.http.User-Agent ~ \"(?i)iemobile\" ||\n\t\t req.http.User-Agent ~ \"(?i)midp-2.0\" ||\n\t\t req.http.User-Agent ~ \"(?i)u990\" ||\n\t\t req.http.User-Agent ~ \"(?i)netfront\" ||\n\t\t req.http.User-Agent ~ \"(?i)opera mini\" ||\n\t\t req.http.User-Agent ~ \"(?i)palm\" ||\n\t\t req.http.User-Agent ~ \"(?i)nintendo wii\" ||\n\t\t req.http.User-Agent ~ \"(?i)playstation portable\" ||\n\t\t req.http.User-Agent ~ \"(?i)portalmmm\" ||\n\t\t req.http.User-Agent ~ \"(?i)proxinet\" ||\n\t\t req.http.User-Agent ~ \"(?i)sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)windows\\ ?ce\" ||\n\t\t req.http.User-Agent ~ \"(?i)winwap\" ||\n\t\t req.http.User-Agent ~ \"(?i)eudoraweb\" ||\n\t\t req.http.User-Agent ~ \"(?i)htc\" ||\n\t\t req.http.User-Agent ~ \"(?i)240x320\" ||\n\t\t req.http.User-Agent ~ \"(?i)avantgo\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-generic\";\n\t\t}\n\t}\n}\n(\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"d1cb0cbc8a92cc3ef598e2b94c37f5dd89443a2b","subject":"Clean up cookie header when overriding. Remove trailing whitespace.","message":"Clean up cookie header when overriding. Remove trailing whitespace.\n","repos":"varnish\/varnish-devicedetect,kevinquinnyo\/varnish-devicedetect,varnish\/varnish-devicedetect,kevinquinnyo\/varnish-devicedetect,wikp\/varnish-devicedetect,wikp\/varnish-devicedetect","old_file":"devicedetect.vcl","new_file":"devicedetect.vcl","new_contents":"#\n# detectdevice.vcl - regex based device detection for Varnish\n# http:\/\/github.com\/varnish\/varnish-devicedetect\/\n#\n# Author: Lasse Karstensen <lasse@varnish-software.com>\n\nsub devicedetect {\n unset req.http.X-UA-Device;\n set req.http.X-UA-Device = \"pc\";\n\n if (req.http.User-Agent ~ \"(?i)(ads|google|bing|msn|yandex|baidu|ro|career|)bot\" ||\n\treq.http.User-Agent ~ \"(?i)(baidu|symantec)spider\" ||\n\treq.http.User-Agent ~ \"(?i)scanner\" ||\n\treq.http.User-Agent ~ \"(?i)(web)crawler\") {\n\tset req.http.X-UA-Device = \"bot\"; }\n elsif (req.http.User-Agent ~ \"(?i)ip(hone|od)\") { set req.http.X-UA-Device = \"mobile-iphone\"; }\n elsif (req.http.User-Agent ~ \"(?i)ipad\") { set req.http.X-UA-Device = \"tablet-ipad\"; }\n # how do we differ between an android phone and an android tablet?\n # http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent\n elsif (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") { set req.http.X-UA-Device = \"mobile-android\"; }\n # android 3\/honeycomb was just about tablet-only, and any phones will probably handle a bigger page layout.\n elsif (req.http.User-Agent ~ \"(?i)android 3\") { set req.http.X-UA-Device = \"tablet-android\"; }\n # may very well give false positives towards android tablets. Suggestions welcome.\n elsif (req.http.User-Agent ~ \"(?i)android\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\n elsif (req.http.User-Agent ~ \"^HTC\" ||\n req.http.User-Agent ~ \"Fennec\" ||\n req.http.User-Agent ~ \"IEMobile\" ||\n req.http.User-Agent ~ \"BlackBerry\" ||\n req.http.User-Agent ~ \"SymbianOS.*AppleWebKit\" ||\n req.http.User-Agent ~ \"Opera Mobi\") {\n set req.http.X-UA-Device = \"mobile-smartphone\";\n }\n elsif (req.http.User-Agent ~ \"(?i)symbian\" ||\n req.http.User-Agent ~ \"(?i)^sonyericsson\" ||\n req.http.User-Agent ~ \"(?i)^nokia\" ||\n req.http.User-Agent ~ \"(?i)^samsung\" ||\n req.http.User-Agent ~ \"(?i)^lg\" ||\n\treq.http.User-Agent ~ \"(?i)bada\" ||\n\treq.http.User-Agent ~ \"(?i)blazer\" ||\n\treq.http.User-Agent ~ \"(?i)cellphone\" ||\n\treq.http.User-Agent ~ \"(?i)iemobile\" ||\n\treq.http.User-Agent ~ \"(?i)midp-2.0\" ||\n\treq.http.User-Agent ~ \"(?i)u990\" ||\n\treq.http.User-Agent ~ \"(?i)netfront\" ||\n\treq.http.User-Agent ~ \"(?i)opera mini\" ||\n\treq.http.User-Agent ~ \"(?i)palm\" ||\n\treq.http.User-Agent ~ \"(?i)nintendo wii\" ||\n\treq.http.User-Agent ~ \"(?i)playstation portable\" ||\n\treq.http.User-Agent ~ \"(?i)portalmmm\" ||\n\treq.http.User-Agent ~ \"(?i)proxinet\" ||\n\treq.http.User-Agent ~ \"(?i)sonyericsson\" ||\n\treq.http.User-Agent ~ \"(?i)symbian\" ||\n\treq.http.User-Agent ~ \"(?i)windows\\ ?ce\" ||\n\treq.http.User-Agent ~ \"(?i)winwap\" ||\n\treq.http.User-Agent ~ \"(?i)eudoraweb\" ||\n\treq.http.User-Agent ~ \"(?i)htc\" ||\n\treq.http.User-Agent ~ \"(?i)240x320\" ||\n\treq.http.User-Agent ~ \"(?i)avantgo\") {\n set req.http.X-UA-Device = \"mobile-generic\";\n }\n # handle overrides\n if (req.http.Cookie ~ \"(i?)X-UA-Device-force\") {\n # ;?? means zero or one ;, non-greedy to match the first.\n set req.http.X-UA-Device = regsub(req.http.Cookie, \"(?i).*X-UA-Device-force=([^;]+);??.*\", \"\\1\");\n # Clean up the cookie header to allow for caching.\n set req.http.Cookie = regsuball(req.http.Cookie, \"(^|; ) *X-UA-Device-force=[^;]+;? *\", \"\\1\");\n if (req.http.Cookie ~ \"^ *$\") { unset req.http.Cookie; }\n }\n}\n\n# vim: sw=4:tw=120\n","old_contents":"#\n# detectdevice.vcl - regex based device detection for Varnish\n# http:\/\/github.com\/varnish\/varnish-devicedetect\/\n#\n# Author: Lasse Karstensen <lasse@varnish-software.com>\n\nsub devicedetect {\n unset req.http.X-UA-Device;\n set req.http.X-UA-Device = \"pc\";\n\n if (req.http.User-Agent ~ \"(?i)(ads|google|bing|msn|yandex|baidu|ro|career|)bot\" ||\n\treq.http.User-Agent ~ \"(?i)(baidu|symantec)spider\" ||\n\treq.http.User-Agent ~ \"(?i)scanner\" ||\n\treq.http.User-Agent ~ \"(?i)(web)crawler\") {\n\tset req.http.X-UA-Device = \"bot\"; }\n elsif (req.http.User-Agent ~ \"(?i)ip(hone|od)\") { set req.http.X-UA-Device = \"mobile-iphone\"; }\n elsif (req.http.User-Agent ~ \"(?i)ipad\") { set req.http.X-UA-Device = \"tablet-ipad\"; }\n # how do we differ between an android phone and an android tablet?\n # http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent\n elsif (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") { set req.http.X-UA-Device = \"mobile-android\"; } \n # android 3\/honeycomb was just about tablet-only, and any phones will probably handle a bigger page layout.\n elsif (req.http.User-Agent ~ \"(?i)android 3\") { set req.http.X-UA-Device = \"tablet-android\"; }\n # may very well give false positives towards android tablets. Suggestions welcome.\n elsif (req.http.User-Agent ~ \"(?i)android\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\n elsif (req.http.User-Agent ~ \"^HTC\" ||\n req.http.User-Agent ~ \"Fennec\" || \n req.http.User-Agent ~ \"IEMobile\" ||\n req.http.User-Agent ~ \"BlackBerry\" ||\n req.http.User-Agent ~ \"SymbianOS.*AppleWebKit\" ||\n req.http.User-Agent ~ \"Opera Mobi\") {\n set req.http.X-UA-Device = \"mobile-smartphone\";\n }\n elsif (req.http.User-Agent ~ \"(?i)symbian\" ||\n req.http.User-Agent ~ \"(?i)^sonyericsson\" ||\n req.http.User-Agent ~ \"(?i)^nokia\" ||\n req.http.User-Agent ~ \"(?i)^samsung\" ||\n req.http.User-Agent ~ \"(?i)^lg\" ||\n\treq.http.User-Agent ~ \"(?i)bada\" ||\n\treq.http.User-Agent ~ \"(?i)blazer\" ||\n\treq.http.User-Agent ~ \"(?i)cellphone\" ||\n\treq.http.User-Agent ~ \"(?i)iemobile\" ||\n\treq.http.User-Agent ~ \"(?i)midp-2.0\" ||\n\treq.http.User-Agent ~ \"(?i)u990\" ||\n\treq.http.User-Agent ~ \"(?i)netfront\" ||\n\treq.http.User-Agent ~ \"(?i)opera mini\" ||\n\treq.http.User-Agent ~ \"(?i)palm\" ||\n\treq.http.User-Agent ~ \"(?i)nintendo wii\" ||\n\treq.http.User-Agent ~ \"(?i)playstation portable\" ||\n\treq.http.User-Agent ~ \"(?i)portalmmm\" ||\n\treq.http.User-Agent ~ \"(?i)proxinet\" ||\n\treq.http.User-Agent ~ \"(?i)sonyericsson\" ||\n\treq.http.User-Agent ~ \"(?i)symbian\" ||\n\treq.http.User-Agent ~ \"(?i)windows\\ ?ce\" ||\n\treq.http.User-Agent ~ \"(?i)winwap\" ||\n\treq.http.User-Agent ~ \"(?i)eudoraweb\" ||\n\treq.http.User-Agent ~ \"(?i)htc\" ||\n\treq.http.User-Agent ~ \"(?i)240x320\" ||\n\treq.http.User-Agent ~ \"(?i)avantgo\") { \n set req.http.X-UA-Device = \"mobile-generic\";\n } \n # handle overrides\n if (req.http.Cookie ~ \"(i?)X-UA-Device-force\") {\n # ;?? means zero or one ;, non-greedy to match the first.\n set req.http.X-UA-Device = regsub(req.http.Cookie, \"(?i).*X-UA-Device-force=([^;]+);??.*\", \"\\1\");\n }\n}\n\n# vim: sw=4:tw=120 # meh\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"d330c39d49f07f047e7eadcfb38e0583fb1e6e7e","subject":"Fix X-UA-Device-force ","message":"Fix X-UA-Device-force \n\nChange resp.response to resp.reason as this is passed to vcl_synth\r\nChange set of resp.response to resp.http.response (varnish 4)\r\nSetting resp.status before using resp.reason resets resp.reason to \"OK\" and results in A-UA-Device-force cooking being set to \"OK\". Swap ordering to avoid this.","repos":"varnish\/varnish-devicedetect,varnish\/varnish-devicedetect","old_file":"devicedetect-dev.vcl","new_file":"devicedetect-dev.vcl","new_contents":"#\n# devicedetect-dev.vcl\n#\n# Enable test URLs and cookie overrides.\n#\nvcl 4.0;\n\nbackend devicetest {\n\t.host = \"127.0.0.1\";\n\t.port = \"5911\";\n}\n\nsub vcl_recv {\n\t# 701\/702 are arbitrary chosen return codes that is only used internally in varnish.\n\tif (req.url ~ \"^\/set_ua_device\/.+\") {\n\t\treturn(synth(701, regsub(req.url, \"^\/set_ua_device\/\", \"\"));\n\t}\n\t# set expired cookie if nothing is specified\n\tif (req.url ~ \"^\/set_ua_device\/\") {\n\t\treturn(synth(702, \"OK\"));\n\t}\n\tif (req.url ~ \"^\/devicetest\") {\n\t\tset req.backend = devicetest;\n\t}\n}\n\nsub vcl_synth {\n\tif (resp.status == 701 || resp.status == 702) {\n\t\tif (resp.status == 702) {\n\t\t\tset resp.http.Set-Cookie = \"X-UA-Device-force=expiring; Path=\/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;\";\n\t\t\tset resp.status = 200;\n\t\t} else {\n\t\t\tset resp.http.Set-Cookie = \"X-UA-Device-force=\" + resp.reason + \"; Path=\/;\";\n\t\t\tset resp.status = 200;\n\t\t}\n\t\tset resp.http.Content-Type = \"text\/html; charset=utf-8\";\n\t\tsynthetic {\"<html><body><h1>OK, Cookie updated<\/h1><a href='\/devicetest\/'>\/devicetest\/<\/a><\/body><\/html>\"};\n\t\tset resp.http.response = \"OK\";\n\t\treturn(deliver);\n\t}\n}\n","old_contents":"#\n# devicedetect-dev.vcl\n#\n# Enable test URLs and cookie overrides.\n#\nvcl 4.0;\n\nbackend devicetest {\n\t.host = \"127.0.0.1\";\n\t.port = \"5911\";\n}\n\nsub vcl_recv {\n\t# 701\/702 are arbitrary chosen return codes that is only used internally in varnish.\n\tif (req.url ~ \"^\/set_ua_device\/.+\") {\n\t\treturn(synth(701, regsub(req.url, \"^\/set_ua_device\/\", \"\"));\n\t}\n\t# set expired cookie if nothing is specified\n\tif (req.url ~ \"^\/set_ua_device\/\") {\n\t\treturn(synth(702, \"OK\"));\n\t}\n\tif (req.url ~ \"^\/devicetest\") {\n\t\tset req.backend = devicetest;\n\t}\n}\n\nsub vcl_synth {\n\tif (resp.status == 701 || resp.status == 702) {\n\t\tif (resp.status == 702) {\n\t\t\tset resp.status = 200;\n\t\t\tset resp.http.Set-Cookie = \"X-UA-Device-force=expiring; Path=\/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;\";\n\t\t} else {\n\t\t\tset resp.status = 200;\n\t\t\tset resp.http.Set-Cookie = \"X-UA-Device-force=\" + resp.response + \"; Path=\/;\";\n\t\t}\n\t\tset resp.http.Content-Type = \"text\/html; charset=utf-8\";\n\t\tsynthetic {\"<html><body><h1>OK, Cookie updated<\/h1><a href='\/devicetest\/'>\/devicetest\/<\/a><\/body><\/html>\"};\n\t\tset resp.response = \"OK\";\n\t\treturn(deliver);\n\t}\n}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"aace2ebd91f8e0184b004c040a0a94d71c585dca","subject":"Moved the logic to set a TTL for 404s.","message":"Moved the logic to set a TTL for 404s.\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/fastly.vcl","new_file":"etc\/fastly.vcl","new_contents":"###############################################################################\n#\n# Fastly CDN for Magento 2\n#\n# NOTICE OF LICENSE\n#\n# This source file is subject to the Fastly CDN for Magento 2 End User License\n# Agreement that is bundled with this package in the file LICENSE_FASTLY_CDN.txt.\n#\n# @copyright Copyright (c) 2016 Fastly, Inc. (http:\/\/www.fastly.com)\n# @license BSD, see LICENSE_FASTLY_CDN.txt\n#\n###############################################################################\n\n# This is a basic VCL configuration file for Fastly CDN for Magento 2 module.\n\nsub vcl_recv {\n#FASTLY recv\n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n set req.http.X-Sig = regsub(req.http.X-Purge-Token, \"^[^_]+_(.*)\", \"\\1\");\n set req.http.X-Exp = regsub(req.http.X-Purge-Token, \"^([^_]+)_.*\", \"\\1\");\n\n # validate signature\n if (req.http.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path req.http.X-Exp), \"^0x\", \"\")) {\n\n # use vcl time math to check expiration timestamp\n set req.http.X-Original-Grace = req.grace;\n set req.grace = std.atoi(strftime({\"%s\"}, now));\n set req.grace -= std.atoi(req.http.X-Exp);\n\n if (std.atoi(req.grace) > 0) {\n error 410;\n }\n\n # clean up grace since we used it for time math\n set req.grace = std.atoi(req.http.X-Original-Grace);\n unset req.http.X-Original-Grace;\n\n } else {\n error 403;\n }\n\n # cleanup variables\n unset req.http.X-Purge-Token;\n unset req.http.X-Sig;\n unset req.http.X-Exp;\n }\n\n # Deactivate gzip\n set req.http.X-Orig-Accept-Encoding = req.http.Accept-Encoding;\n unset req.http.Accept-Encoding;\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n # disable ESI processing on Origin Shield\n if (req.http.Fastly-FF) {\n set req.esi = false;\n }\n\n # We only deal with GET and HEAD by default\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n return (pass);\n }\n\n # Bypass shopping cart and checkout requests\n if (req.url ~ \"\/checkout\") {\n return (pass);\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie ~ \"(X-Magento-Vary|form_key)=\") {\n error 200 \"\";\n } else {\n # append parameter with country code\n set req.url = req.url \"?country_code=\" geoip.country_code;\n }\n }\n\n return(lookup);\n}\n\nsub vcl_fetch {\n\n # Remove Set-Cookies from responses for static content\n # to match the cookie removal in recv.\n if (req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n }\n\n }\n\n#FASTLY fetch\n\n if (beresp.status >= 500) {\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n }\n\n if (req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Content-Type ~ \"text\/html\" || beresp.http.Content-Type ~ \"text\/xml\") {\n # enable ESI feature for Magento response by default\n esi;\n } else {\n # enable gzip for all static content\n if ((beresp.status == 200 || beresp.status == 404) && (beresp.http.content-type ~ \"^(text\\\/html|application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain|text\\\/xml)\\s*($|;)\" || req.url ~ \"\\.(css|js|html|eot|ico|otf|ttf|json)($|\\?)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.X-Orig-Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # cache only successfully responses and 404s\n if (beresp.status != 200 && beresp.status != 301 && beresp.status != 404) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\")) {\n unset beresp.http.set-cookie;\n if (req.url !~ \"^\/(pub\/)?(media|static)\/.*\") {\n set beresp.http.Pragma = \"no-cache\";\n set beresp.http.Expires = \"-1\";\n set beresp.http.Cache-Control = \"no-store, no-cache, must-revalidate, max-age=0\";\n set beresp.grace = 1m;\n }\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type\n if (beresp.http.Content-Type ~ \"image\") {\n set beresp.http.Surrogate-Key = \"image\";\n } elsif (beresp.http.Content-Type ~ \"script\") {\n set beresp.http.Surrogate-Key = \"script\";\n } elsif (beresp.http.Content-Type ~ \"css\") {\n set beresp.http.Surrogate-Key = \"css\";\n }\n\n set beresp.http.X-Surrogate-Key = beresp.http.Surrogate-Key;\n return (deliver);\n }\n\n return (deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\n\nsub vcl_miss {\n#FASTLY miss\n\n return(fetch);\n}\n\nsub vcl_deliver {\n # debug info\n if (resp.http.X-Magento-Debug) {\n if (obj.hits > 0) {\n set resp.http.X-Magento-Cache-Debug = \"HIT\";\n set resp.http.X-Magento-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Magento-Cache-Debug = \"MISS\";\n }\n } else {\n # remove Varnish\/proxy header\n remove resp.http.Age;\n remove resp.http.X-Magento-Debug;\n remove resp.http.X-Magento-Tags;\n remove resp.http.X-Surrogate-Key;\n remove resp.http.X-Magento-Cache-Control;\n remove resp.http.X-Powered-By;\n remove resp.http.Server;\n remove resp.http.X-Varnish;\n remove resp.http.Via;\n remove resp.http.Link;\n remove resp.http.X-Purge-URL;\n remove resp.http.X-Purge-Host;\n }\n\n#FASTLY deliver\n\n return (deliver);\n}\n\n\nsub vcl_error {\n # workaround for possible security issue\n if (req.url ~ \"^\\s\") {\n set obj.status = 400;\n set obj.response = \"Malformed request\";\n synthetic \"\";\n return (deliver);\n }\n\n # error 200\n if (obj.status == 200) {\n return (deliver);\n }\n\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} obj.status \" \" obj.response {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} obj.status \" \" obj.response {\"<\/h1>\n <p>\"} obj.response {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} req.xid {\"<\/p>\n <hr>\n <p>Fastly CDN server<\/p>\n <\/body>\n<\/html>\n\"};\n\n#FASTLY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n\nsub vcl_hash {\n set req.hash += req.http.Https;\n set req.hash += req.http.host;\n set req.hash += req.url;\n\n if (req.http.cookie ~ \"X-Magento-Vary=\") {\n set req.http.X-Magento-Vary = regsub(req.http.cookie, \"^.*?X-Magento-Vary=([^;]+);*.*$\", \"\\1\");\n set req.hash += req.http.X-Magento-Vary;\n unset req.http.X-Magento-Vary;\n }\n \n set req.hash += \"#####GENERATION#####\";\n\n ### {{ design_exceptions_code }} ###\n\n return (hash);\n}\n\n","old_contents":"###############################################################################\n#\n# Fastly CDN for Magento 2\n#\n# NOTICE OF LICENSE\n#\n# This source file is subject to the Fastly CDN for Magento 2 End User License\n# Agreement that is bundled with this package in the file LICENSE_FASTLY_CDN.txt.\n#\n# @copyright Copyright (c) 2016 Fastly, Inc. (http:\/\/www.fastly.com)\n# @license BSD, see LICENSE_FASTLY_CDN.txt\n#\n###############################################################################\n\n# This is a basic VCL configuration file for Fastly CDN for Magento 2 module.\n\nsub vcl_recv {\n#FASTLY recv\n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n set req.http.X-Sig = regsub(req.http.X-Purge-Token, \"^[^_]+_(.*)\", \"\\1\");\n set req.http.X-Exp = regsub(req.http.X-Purge-Token, \"^([^_]+)_.*\", \"\\1\");\n\n # validate signature\n if (req.http.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path req.http.X-Exp), \"^0x\", \"\")) {\n\n # use vcl time math to check expiration timestamp\n set req.http.X-Original-Grace = req.grace;\n set req.grace = std.atoi(strftime({\"%s\"}, now));\n set req.grace -= std.atoi(req.http.X-Exp);\n\n if (std.atoi(req.grace) > 0) {\n error 410;\n }\n\n # clean up grace since we used it for time math\n set req.grace = std.atoi(req.http.X-Original-Grace);\n unset req.http.X-Original-Grace;\n\n } else {\n error 403;\n }\n\n # cleanup variables\n unset req.http.X-Purge-Token;\n unset req.http.X-Sig;\n unset req.http.X-Exp;\n }\n\n # Deactivate gzip\n set req.http.X-Orig-Accept-Encoding = req.http.Accept-Encoding;\n unset req.http.Accept-Encoding;\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n # disable ESI processing on Origin Shield\n if (req.http.Fastly-FF) {\n set req.esi = false;\n }\n\n # We only deal with GET and HEAD by default\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n return (pass);\n }\n\n # Bypass shopping cart and checkout requests\n if (req.url ~ \"\/checkout\") {\n return (pass);\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie ~ \"(X-Magento-Vary|form_key)=\") {\n error 200 \"\";\n } else {\n # append parameter with country code\n set req.url = req.url \"?country_code=\" geoip.country_code;\n }\n }\n\n return(lookup);\n}\n\nsub vcl_fetch {\n\n # Remove Set-Cookies from responses for static content\n # to match the cookie removal in recv.\n if (req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n }\n\n }\n\n#FASTLY fetch\n\n if (beresp.status >= 500) {\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n }\n\n if (req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Content-Type ~ \"text\/html\" || beresp.http.Content-Type ~ \"text\/xml\") {\n # enable ESI feature for Magento response by default\n esi;\n } else {\n # enable gzip for all static content\n if ((beresp.status == 200 || beresp.status == 404) && (beresp.http.content-type ~ \"^(text\\\/html|application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain|text\\\/xml)\\s*($|;)\" || req.url ~ \"\\.(css|js|html|eot|ico|otf|ttf|json)($|\\?)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.X-Orig-Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # cache only successfully responses and 404s\n if (beresp.status != 200 && beresp.status != 301 && beresp.status != 404) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\")) {\n unset beresp.http.set-cookie;\n if (req.url !~ \"^\/(pub\/)?(media|static)\/.*\") {\n set beresp.http.Pragma = \"no-cache\";\n set beresp.http.Expires = \"-1\";\n set beresp.http.Cache-Control = \"no-store, no-cache, must-revalidate, max-age=0\";\n set beresp.grace = 1m;\n }\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type\n if (beresp.http.Content-Type ~ \"image\") {\n set beresp.http.Surrogate-Key = \"image\";\n } elsif (beresp.http.Content-Type ~ \"script\") {\n set beresp.http.Surrogate-Key = \"script\";\n } elsif (beresp.http.Content-Type ~ \"css\") {\n set beresp.http.Surrogate-Key = \"css\";\n }\n\n set beresp.http.X-Surrogate-Key = beresp.http.Surrogate-Key;\n return (deliver);\n }\n\n # Cache 404's for 1 minute.\n if (beresp.status == 404 && req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n set beresp.ttl = 60s;\n }\n\n return (deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\n\nsub vcl_miss {\n#FASTLY miss\n\n return(fetch);\n}\n\nsub vcl_deliver {\n # debug info\n if (resp.http.X-Magento-Debug) {\n if (obj.hits > 0) {\n set resp.http.X-Magento-Cache-Debug = \"HIT\";\n set resp.http.X-Magento-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Magento-Cache-Debug = \"MISS\";\n }\n } else {\n # remove Varnish\/proxy header\n remove resp.http.Age;\n remove resp.http.X-Magento-Debug;\n remove resp.http.X-Magento-Tags;\n remove resp.http.X-Surrogate-Key;\n remove resp.http.X-Magento-Cache-Control;\n remove resp.http.X-Powered-By;\n remove resp.http.Server;\n remove resp.http.X-Varnish;\n remove resp.http.Via;\n remove resp.http.Link;\n remove resp.http.X-Purge-URL;\n remove resp.http.X-Purge-Host;\n }\n\n#FASTLY deliver\n\n return (deliver);\n}\n\n\nsub vcl_error {\n # workaround for possible security issue\n if (req.url ~ \"^\\s\") {\n set obj.status = 400;\n set obj.response = \"Malformed request\";\n synthetic \"\";\n return (deliver);\n }\n\n # error 200\n if (obj.status == 200) {\n return (deliver);\n }\n\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} obj.status \" \" obj.response {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} obj.status \" \" obj.response {\"<\/h1>\n <p>\"} obj.response {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} req.xid {\"<\/p>\n <hr>\n <p>Fastly CDN server<\/p>\n <\/body>\n<\/html>\n\"};\n\n#FASTLY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n\nsub vcl_hash {\n set req.hash += req.http.Https;\n set req.hash += req.http.host;\n set req.hash += req.url;\n\n if (req.http.cookie ~ \"X-Magento-Vary=\") {\n set req.http.X-Magento-Vary = regsub(req.http.cookie, \"^.*?X-Magento-Vary=([^;]+);*.*$\", \"\\1\");\n set req.hash += req.http.X-Magento-Vary;\n unset req.http.X-Magento-Vary;\n }\n \n set req.hash += \"#####GENERATION#####\";\n\n ### {{ design_exceptions_code }} ###\n\n return (hash);\n}\n\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"d7443399b5af136de04e677de75291419b6e4eaa","subject":"Fixes #1857 (#1858)","message":"Fixes #1857 (#1858)\n\n","repos":"JakeChampion\/polyfill-service,JakeChampion\/polyfill-service","old_file":"fastly\/vcl\/main.vcl","new_file":"fastly\/vcl\/main.vcl","new_contents":"import querystring;\n\nsub sort_comma_separated_value {\n\t# This function takes a CSV and tranforms it into a url where each\n\t# comma-separated-value is a query-string parameter and then uses \n\t# Fastly's querystring.sort function to sort the values. Once sorted\n\t# it then turn the query-parameters back into a CSV.\n\t# Set the CSV on the header `Sort-Value`.\n\t# Returns the sorted CSV on the header `Sorted-Value`.\n\tdeclare local var.value STRING;\n\tset var.value = req.http.Sort-value;\n\n\t# If query value does not exist or is empty, set it to \"\"\n\tset var.value = if(var.value != \"\", var.value, \"\");\n\n\t# Replace all `&` characters with `^`, this is because `&` would break the value up into pieces.\n\tset var.value = regsuball(var.value, \"&\", \"^\");\n\n\t# Replace all `,` characters with `&` to break them into individual query values\n\t# Append `1-` infront of all the query values to make them simpler to transform later\n\tset var.value = \"1-\" regsuball(var.value, \",\", \"&1-\");\n\t\n\t# Create a querystring-like string in order for querystring.sort to work.\n\tset var.value = querystring.sort(\"?\" var.value);\n\n\t# Grab all the query values from the sorted url\n\tset var.value = regsub(var.value, \"\\?\", \"\");\n\t\n\t# Reverse all the previous transformations to get back the single `features` query value value\n\tset var.value = regsuball(var.value, \"1-\", \"\");\n\tset var.value = regsuball(var.value, \"&\", \",\");\n\tset var.value = regsuball(var.value, \"\\^\", \"&\");\n\n\tset req.http.Sorted-Value = var.value;\n}\n\nsub normalise_querystring_parameters_for_polyfill_bundle {\n\t# Store the url without the querystring into a temporary header.\n\tdeclare local var.url STRING;\n\tset var.url = querystring.remove(req.url);\n\n\tdeclare local var.querystring STRING;\n\tset var.querystring = \"?\";\n\n\t# Remove all querystring parameters which are not part of the public API.\n\t# set req.url = querystring.regfilter_except(req.url, \"^(features|excludes|rum|unknown|flags|version|ua|callback|compression)$\");\n\n\t# (?i) makes the regex case-insensitive\n\t# The regex will match only if their are characters after `features=` which are not an ampersand (&).\n\tif (req.url.qs ~ \"(?i)[^&=]*features=([^&]+)\") {\n\t\t# Parameter has already been set, use the already set value.\n\t\t# re.group.1 is the first regex capture group in the regex above.\n\t\tif (std.strlen(re.group.1) < 100) {\n\t\t\t# We add the value of the features parameter to this header\n\t\t\t# This is to be able to have sort_comma_separated_value sort the value\n\t\t\tset req.http.Sort-Value = urldecode(re.group.1);\n\t\t\tcall sort_comma_separated_value;\n\t\t\t# The header Sorted-Value now contains the sorted version of the features parameter.\n\t\t\tset var.querystring = querystring.set(var.querystring, \"features\", req.http.Sorted-Value);\n\t\t} else {\n\t\t\tset var.querystring = querystring.set(var.querystring, \"features\", urldecode(re.group.1));\n\t\t}\n\t} else {\n\t\t# Parameter has not been set, use the default value.\n\t\tset var.querystring = querystring.set(var.querystring, \"features\", \"default\");\n\t}\n\t\n\t# (?i) makes the regex case-insensitive\n\t# The regex will match only if their are characters after `excludes=` which are not an ampersand (&).\n\tif (req.url.qs ~ \"(?i)[^&=]*excludes=([^&]+)\") {\n\t\t# Parameter has already been set, use the already set value.\n\t\t# re.group.1 is the first regex capture group in the regex above.\n\t\tif (std.strlen(re.group.1) < 100) {\n\t\t\t# We add the value of the excludes parameter to this header\n\t\t\t# This is to be able to have sort_comma_separated_value sort the value\n\t\t\tset req.http.Sort-Value = urldecode(re.group.1);\n\t\t\tcall sort_comma_separated_value;\n\t\t\t# The header Sorted-Value now contains the sorted version of the excludes parameter.\n\t\t\tset var.querystring = querystring.set(var.querystring, \"excludes\", req.http.Sorted-Value);\n\t\t} else {\n\t\t\tset var.querystring = querystring.set(var.querystring, \"excludes\", urldecode(re.group.1));\n\t\t}\n\t} else {\n\t\t# If excludes is not set, set to default value \"\"\n\t\tset var.querystring = var.querystring \"&excludes=\";\n\t}\n\t\n\t# If rum is not set, set to default value \"0\"\n\tif (req.url.qs !~ \"(?i)[^&=]*rum=([^&]+)\") {\n\t\tset var.querystring = querystring.set(var.querystring, \"rum\", \"0\");\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"rum\", re.group.1);\n\t}\n\t\n\t# If unknown is not set, set to default value \"polyfill\"\n\tif (req.url.qs !~ \"(?i)[^&=]*unknown=([^&]+)\") {\n\t\tset var.querystring = querystring.set(var.querystring, \"unknown\", \"polyfill\");\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"unknown\", re.group.1);\n\t}\n\n\t# If flags is not set, set to default value \"\"\n\tif (req.url.qs !~ \"(?i)[^&=]*flags=([^&]+)\") {\n\t\tset var.querystring = var.querystring \"&flags=\";\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"flags\", re.group.1);\n\t}\n\n\t# If version is not set, set to default value \"\"\n\tdeclare local var.version STRING;\n\tif (req.url.qs !~ \"(?i)[^&=]*version=([^&]+)\") {\n\t\tset var.querystring = var.querystring \"&version=\";\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"version\", re.group.1);\n\t}\n\t\n\t# If ua is not set, normalise the User-Agent header based upon the version of the polyfill-library that has been requested.\n\tif (req.url.qs !~ \"(?i)[^&=]*ua=([^&]+)\") {\n\t\tif (req.url.qs ~ \"(?i)[^&=]*version=3\\.25\\.1(&|$)\") {\n\t\t\tcall normalise_user_agent_3_25_1;\n\t\t} else {\n\t\t\tcall normalise_user_agent_latest;\n\t\t}\n\t\tset var.querystring = querystring.set(var.querystring, \"ua\", req.http.Normalized-User-Agent);\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"ua\", re.group.1);\n\t}\n\n\t# If callback is not set, set to default value \"\"\n\tif (req.url.qs !~ \"(?i)[^&=]*callback=([^&]+)\") {\n\t\tset var.querystring = var.querystring \"&callback=\";\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"callback\", re.group.1);\n\t}\n\t\n\t# If compression is not set, use the best compression that the user-agent supports.\n\tif (req.url.qs !~ \"(?i)[^&=]*compression=([^&]+)\") {\n\t\t# When Fastly adds Brotli into the Accept-Encoding normalisation we can replace this with: \n\t\t# `set var.querystring = querystring.set(var.querystring, \"compression\", req.http.Accept-Encoding || \"\")`\n\n\t\t# Before SP2, IE\/6 doesn't always read and cache gzipped content correctly.\n\t\tif (req.http.Fastly-Orig-Accept-Encoding && req.http.User-Agent !~ \"MSIE 6\") {\n\t\t\tif (req.http.Fastly-Orig-Accept-Encoding ~ \"br\") {\n\t\t\t\tset var.querystring = querystring.set(var.querystring, \"compression\", \"br\");\n\t\t\t} elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"gzip\") {\n\t\t\t\tset var.querystring = querystring.set(var.querystring, \"compression\", \"gzip\");\n\t\t\t} else {\n\t\t\t\tset var.querystring = var.querystring \"&compression=\";\n\t\t\t}\n\t\t} else {\n\t\t\tset var.querystring = var.querystring \"&compression=\";\n\t\t}\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"compression\", re.group.1);\n\t}\n\tset req.url = var.url var.querystring;\n}\n\ninclude \"ua_parser.vcl\";\ninclude \"normalise-user-agent-3-25-1.vcl\";\ninclude \"normalise-user-agent-latest.vcl\";\n\n# The Fastly VCL boilerplate.\ninclude \"fastly-boilerplate-begin.vcl\";\n\ninclude \"breadcrumbs.vcl\";\ninclude \"redirects.vcl\";\ninclude \"synthetic-responses.vcl\";\ninclude \"polyfill-service.vcl\";\n\n# Finally include the last bit of VCL, this _must_ be last!\ninclude \"fastly-boilerplate-end.vcl\";\n","old_contents":"import querystring;\n\nsub sort_comma_separated_value {\n\t# This function takes a CSV and tranforms it into a url where each\n\t# comma-separated-value is a query-string parameter and then uses \n\t# Fastly's querystring.sort function to sort the values. Once sorted\n\t# it then turn the query-parameters back into a CSV.\n\t# Set the CSV on the header `Sort-Value`.\n\t# Returns the sorted CSV on the header `Sorted-Value`.\n\tdeclare local var.value STRING;\n\tset var.value = req.http.Sort-value;\n\n\t# If query value does not exist or is empty, set it to \"\"\n\tset var.value = if(var.value != \"\", var.value, \"\");\n\n\t# Replace all `&` characters with `^`, this is because `&` would break the value up into pieces.\n\tset var.value = regsuball(var.value, \"&\", \"^\");\n\n\t# Replace all `,` characters with `&` to break them into individual query values\n\t# Append `1-` infront of all the query values to make them simpler to transform later\n\tset var.value = \"1-\" regsuball(var.value, \",\", \"&1-\");\n\t\n\t# Create a querystring-like string in order for querystring.sort to work.\n\tset var.value = querystring.sort(\"?\" var.value);\n\n\t# Grab all the query values from the sorted url\n\tset var.value = regsub(var.value, \"\\?\", \"\");\n\t\n\t# Reverse all the previous transformations to get back the single `features` query value value\n\tset var.value = regsuball(var.value, \"1-\", \"\");\n\tset var.value = regsuball(var.value, \"&\", \",\");\n\tset var.value = regsuball(var.value, \"\\^\", \"&\");\n\n\tset req.http.Sorted-Value = var.value;\n}\n\nsub normalise_querystring_parameters_for_polyfill_bundle {\n\t# Store the url without the querystring into a temporary header.\n\tdeclare local var.url STRING;\n\tset var.url = querystring.remove(req.url);\n\n\tdeclare local var.querystring STRING;\n\tset var.querystring = \"?\";\n\n\t# Remove all querystring parameters which are not part of the public API.\n\t# set req.url = querystring.regfilter_except(req.url, \"^(features|excludes|rum|unknown|flags|version|ua|callback|compression)$\");\n\n\t# (?i) makes the regex case-insensitive\n\t# The regex will match only if their are characters after `features=` which are not an ampersand (&).\n\tif (req.url.qs ~ \"(?i)[^&=]*features=([^&]+)\") {\n\t\t# Parameter has already been set, use the already set value.\n\t\t# re.group.1 is the first regex capture group in the regex above.\n\t\tif (std.strlen(re.group.1) < 100) {\n\t\t\t# We add the value of the features parameter to this header\n\t\t\t# This is to be able to have sort_comma_separated_value sort the value\n\t\t\tset req.http.Sort-Value = urldecode(re.group.1);\n\t\t\tcall sort_comma_separated_value;\n\t\t\t# The header Sorted-Value now contains the sorted version of the features parameter.\n\t\t\tset var.querystring = querystring.set(var.querystring, \"features\", req.http.Sorted-Value);\n\t\t} else {\n\t\t\tset var.querystring = querystring.set(var.querystring, \"features\", re.group.1);\n\t\t}\n\t} else {\n\t\t# Parameter has not been set, use the default value.\n\t\tset var.querystring = querystring.set(var.querystring, \"features\", \"default\");\n\t}\n\t\n\t# (?i) makes the regex case-insensitive\n\t# The regex will match only if their are characters after `excludes=` which are not an ampersand (&).\n\tif (req.url.qs ~ \"(?i)[^&=]*excludes=([^&]+)\") {\n\t\t# Parameter has already been set, use the already set value.\n\t\t# re.group.1 is the first regex capture group in the regex above.\n\t\tif (std.strlen(re.group.1) < 100) {\n\t\t\t# We add the value of the excludes parameter to this header\n\t\t\t# This is to be able to have sort_comma_separated_value sort the value\n\t\t\tset req.http.Sort-Value = urldecode(re.group.1);\n\t\t\tcall sort_comma_separated_value;\n\t\t\t# The header Sorted-Value now contains the sorted version of the excludes parameter.\n\t\t\tset var.querystring = querystring.set(var.querystring, \"excludes\", req.http.Sorted-Value);\n\t\t} else {\n\t\t\tset var.querystring = querystring.set(var.querystring, \"excludes\", re.group.1);\n\t\t}\n\t} else {\n\t\t# If excludes is not set, set to default value \"\"\n\t\tset var.querystring = var.querystring \"&excludes=\";\n\t}\n\t\n\t# If rum is not set, set to default value \"0\"\n\tif (req.url.qs !~ \"(?i)[^&=]*rum=([^&]+)\") {\n\t\tset var.querystring = querystring.set(var.querystring, \"rum\", \"0\");\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"rum\", re.group.1);\n\t}\n\t\n\t# If unknown is not set, set to default value \"polyfill\"\n\tif (req.url.qs !~ \"(?i)[^&=]*unknown=([^&]+)\") {\n\t\tset var.querystring = querystring.set(var.querystring, \"unknown\", \"polyfill\");\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"unknown\", re.group.1);\n\t}\n\n\t# If flags is not set, set to default value \"\"\n\tif (req.url.qs !~ \"(?i)[^&=]*flags=([^&]+)\") {\n\t\tset var.querystring = var.querystring \"&flags=\";\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"flags\", re.group.1);\n\t}\n\n\t# If version is not set, set to default value \"\"\n\tdeclare local var.version STRING;\n\tif (req.url.qs !~ \"(?i)[^&=]*version=([^&]+)\") {\n\t\tset var.querystring = var.querystring \"&version=\";\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"version\", re.group.1);\n\t}\n\t\n\t# If ua is not set, normalise the User-Agent header based upon the version of the polyfill-library that has been requested.\n\tif (req.url.qs !~ \"(?i)[^&=]*ua=([^&]+)\") {\n\t\tif (req.url.qs ~ \"(?i)[^&=]*version=3\\.25\\.1(&|$)\") {\n\t\t\tcall normalise_user_agent_3_25_1;\n\t\t} else {\n\t\t\tcall normalise_user_agent_latest;\n\t\t}\n\t\tset var.querystring = querystring.set(var.querystring, \"ua\", req.http.Normalized-User-Agent);\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"ua\", re.group.1);\n\t}\n\n\t# If callback is not set, set to default value \"\"\n\tif (req.url.qs !~ \"(?i)[^&=]*callback=([^&]+)\") {\n\t\tset var.querystring = var.querystring \"&callback=\";\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"callback\", re.group.1);\n\t}\n\t\n\t# If compression is not set, use the best compression that the user-agent supports.\n\tif (req.url.qs !~ \"(?i)[^&=]*compression=([^&]+)\") {\n\t\t# When Fastly adds Brotli into the Accept-Encoding normalisation we can replace this with: \n\t\t# `set var.querystring = querystring.set(var.querystring, \"compression\", req.http.Accept-Encoding || \"\")`\n\n\t\t# Before SP2, IE\/6 doesn't always read and cache gzipped content correctly.\n\t\tif (req.http.Fastly-Orig-Accept-Encoding && req.http.User-Agent !~ \"MSIE 6\") {\n\t\t\tif (req.http.Fastly-Orig-Accept-Encoding ~ \"br\") {\n\t\t\t\tset var.querystring = querystring.set(var.querystring, \"compression\", \"br\");\n\t\t\t} elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"gzip\") {\n\t\t\t\tset var.querystring = querystring.set(var.querystring, \"compression\", \"gzip\");\n\t\t\t} else {\n\t\t\t\tset var.querystring = var.querystring \"&compression=\";\n\t\t\t}\n\t\t} else {\n\t\t\tset var.querystring = var.querystring \"&compression=\";\n\t\t}\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"compression\", re.group.1);\n\t}\n\tset req.url = var.url var.querystring;\n}\n\ninclude \"ua_parser.vcl\";\ninclude \"normalise-user-agent-3-25-1.vcl\";\ninclude \"normalise-user-agent-latest.vcl\";\n\n# The Fastly VCL boilerplate.\ninclude \"fastly-boilerplate-begin.vcl\";\n\ninclude \"breadcrumbs.vcl\";\ninclude \"redirects.vcl\";\ninclude \"synthetic-responses.vcl\";\ninclude \"polyfill-service.vcl\";\n\n# Finally include the last bit of VCL, this _must_ be last!\ninclude \"fastly-boilerplate-end.vcl\";\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"4d858af0ce97bcc27afad782eeda08b5ddab0602","subject":"esi: true","message":"esi: true\n","repos":"dekokun\/isucon6-qualify,dekokun\/isucon6-qualify,dekokun\/isucon6-qualify,dekokun\/isucon6-qualify,dekokun\/isucon6-qualify,dekokun\/isucon6-qualify,dekokun\/isucon6-qualify,dekokun\/isucon6-qualify","old_file":"webapp\/config\/default.vcl","new_file":"webapp\/config\/default.vcl","new_contents":"#\n# This is an example VCL file for Varnish.\n#\n# It does not do anything by default, delegating control to the\n# builtin VCL. The builtin VCL is called when there is no explicit\n# return statement.\n#\n# See the VCL chapters in the Users Guide at https:\/\/www.varnish-cache.org\/docs\/\n# and https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExamples for more examples.\n\n# Marker to tell the VCL compiler that this VCL has been adapted to the\n# new 4.0 format.\nvcl 4.0;\n\nimport directors;\n\n# Default backend definition. Set this to point to your content server.\nbackend localhost {\n .host = \"127.0.0.1\";\n .port = \"5000\";\n}\n\nsub vcl_init {\n new backend = directors.round_robin();\n\n backend.add_backend(localhost);\n}\n\nsub vcl_recv {\n set req.backend_hint = backend.backend();\n\n if (req.method == \"INVALIDATE\") {\n # ban(\"obj.http.Hoge ~ ^.*\" + req.http.X-Invalidated-Hoge + \".*$\");\n ban(\"obj.response ~ ^.*\" + req.http.X-Invalidated-Hoge + \".*$\");\n return(synth(200, req.http.X-Invalidated-Hoge + \" Purged. Success !!\"));\n }\n\n\n # if (req.http.Cookie) {\n # return(pass);\n # }\n\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return(pass);\n }\n\n return(hash);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n return (lookup);\n}\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n\n return(deliver);\n}\n\nsub vcl_backend_response {\n\n set beresp.do_esi = true;\n # this is same as builtin vcl_backend_response\n # https:\/\/www.varnish-cache.org\/trac\/browser\/bin\/varnishd\/builtin.vcl?rev=ae548683b8f91d0a92799f6c746b80773a4c9f05\n if (beresp.ttl <= 0s ||\n beresp.http.Set-Cookie ||\n beresp.http.Surrogate-control ~ \"no-store\" ||\n beresp.http.Cache-Control ~ \"no-cache\" ||\n (!beresp.http.Surrogate-Control &&\n beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n beresp.http.Vary == \"*\") {\n \/*\n * Mark as \"Hit-For-Pass\" for the next 2 minutes\n *\/\n set beresp.uncacheable = true;\n }\n\n # this is hatena original config\n if (beresp.ttl > 0s && ! beresp.uncacheable) {\n set beresp.grace = 1m;\n }\n return (deliver);\n}\n\nsub vcl_synth {\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n set resp.http.Retry-After = \"5\";\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>\"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <p>XID: \"} + req.xid + {\"<\/p>\n <\/body>\n<\/html>\n\"} );\n return (deliver);\n}\n\n","old_contents":"#\n# This is an example VCL file for Varnish.\n#\n# It does not do anything by default, delegating control to the\n# builtin VCL. The builtin VCL is called when there is no explicit\n# return statement.\n#\n# See the VCL chapters in the Users Guide at https:\/\/www.varnish-cache.org\/docs\/\n# and https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExamples for more examples.\n\n# Marker to tell the VCL compiler that this VCL has been adapted to the\n# new 4.0 format.\nvcl 4.0;\n\nimport directors;\n\n# Default backend definition. Set this to point to your content server.\nbackend localhost {\n .host = \"127.0.0.1\";\n .port = \"5000\";\n}\n\nsub vcl_init {\n new backend = directors.round_robin();\n\n backend.add_backend(localhost);\n}\n\nsub vcl_recv {\n set req.backend_hint = backend.backend();\n\n if (req.method == \"INVALIDATE\") {\n # ban(\"obj.http.Hoge ~ ^.*\" + req.http.X-Invalidated-Hoge + \".*$\");\n ban(\"obj.response ~ ^.*\" + req.http.X-Invalidated-Hoge + \".*$\");\n return(synth(200, req.http.X-Invalidated-Hoge + \" Purged. Success !!\"));\n }\n\n\n # if (req.http.Cookie) {\n # return(pass);\n # }\n\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return(pass);\n }\n\n return(hash);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n return (lookup);\n}\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n\n return(deliver);\n}\n\nsub vcl_backend_response {\n\n # this is same as builtin vcl_backend_response\n # https:\/\/www.varnish-cache.org\/trac\/browser\/bin\/varnishd\/builtin.vcl?rev=ae548683b8f91d0a92799f6c746b80773a4c9f05\n if (beresp.ttl <= 0s ||\n beresp.http.Set-Cookie ||\n beresp.http.Surrogate-control ~ \"no-store\" ||\n beresp.http.Cache-Control ~ \"no-cache\" ||\n (!beresp.http.Surrogate-Control &&\n beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n beresp.http.Vary == \"*\") {\n \/*\n * Mark as \"Hit-For-Pass\" for the next 2 minutes\n *\/\n set beresp.uncacheable = true;\n }\n\n # this is hatena original config\n if (beresp.ttl > 0s && ! beresp.uncacheable) {\n set beresp.grace = 1m;\n }\n return (deliver);\n}\n\nsub vcl_synth {\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n set resp.http.Retry-After = \"5\";\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>\"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <p>XID: \"} + req.xid + {\"<\/p>\n <\/body>\n<\/html>\n\"} );\n return (deliver);\n}\n\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"7b9b89b128cd41790042575bb5978567c24702d6","subject":"Update copyright and author.","message":"Update copyright and author.\n","repos":"varnish\/varnish-devicedetect,varnish\/varnish-devicedetect","old_file":"devicedetect.vcl","new_file":"devicedetect.vcl","new_contents":"#\n# Copyright (c) 2016-2018 Varnish Cache project\n# Copyright (c) 2012-2016 Varnish Software AS\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions\n# are met:\n# 1. Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n# 2. Redistributions in binary form must reproduce the above copyright\n# notice, this list of conditions and the following disclaimer in the\n# documentation and\/or other materials provided with the distribution.\n#\n# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n# ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n# SUCH DAMAGE.\n#\n# detectdevice.vcl - regex based device detection for Varnish\n# https:\/\/github.com\/varnishcache\/varnish-devicedetect\/\n#\n# Original author: Lasse Karstensen <lkarsten@varnish-software.com>\n\nsub devicedetect {\n\tunset req.http.X-UA-Device;\n\tset req.http.X-UA-Device = \"pc\";\n\n\t# Handle that a cookie may override the detection alltogether.\n\tif (req.http.Cookie ~ \"(?i)X-UA-Device-force\") {\n\t\t\/* ;?? means zero or one ;, non-greedy to match the first. *\/\n\t\tset req.http.X-UA-Device = regsub(req.http.Cookie, \"(?i).*X-UA-Device-force=([^;]+);??.*\", \"\\1\");\n\t\t\/* Clean up our mess in the cookie header *\/\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|; ) *X-UA-Device-force=[^;]+;? *\", \"\\1\");\n\t\t\/* If the cookie header is now empty, or just whitespace, unset it. *\/\n\t\tif (req.http.Cookie ~ \"^ *$\") { unset req.http.Cookie; }\n\t} else {\n if (req.http.User-Agent ~ \"\\(compatible; Googlebot-Mobile\/2.1; \\+http:\/\/www.google.com\/bot.html\\)\" ||\n (req.http.User-Agent ~ \"(Android|iPhone)\" && req.http.User-Agent ~ \"\\(compatible.?; Googlebot\/2.1.?; \\+http:\/\/www.google.com\/bot.html\") ||\n\t\t\t(req.http.User-Agent ~ \"(iPhone|Windows Phone)\" && req.http.User-Agent ~ \"\\(compatible; bingbot\/2.0; \\+http:\/\/www.bing.com\/bingbot.htm\")) {\n set req.http.X-UA-Device = \"mobile-bot\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)(ads|google|bing|msn|yandex|baidu|ro|career|seznam|)bot\" ||\n\t\t req.http.User-Agent ~ \"(?i)(baidu|jike|symantec)spider\" ||\n\t\t req.http.User-Agent ~ \"(?i)pingdom\" ||\n\t\t req.http.User-Agent ~ \"(?i)facebookexternalhit\" ||\n\t\t req.http.User-Agent ~ \"(?i)scanner\" ||\n\t\t req.http.User-Agent ~ \"(?i)slurp\" ||\n\t\t req.http.User-Agent ~ \"(?i)(web)crawler\") {\n\t\t\tset req.http.X-UA-Device = \"bot\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ipad\") { set req.http.X-UA-Device = \"tablet-ipad\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ip(hone|od)\") { set req.http.X-UA-Device = \"mobile-iphone\"; }\n\t\t\/* how do we differ between an android phone and an android tablet?\n\t\t http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent *\/\n\t\telsif (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") { set req.http.X-UA-Device = \"mobile-android\"; }\n\t\t\/\/ android 3\/honeycomb was just about tablet-only, and any phones will probably handle a bigger page layout.\n\t\telsif (req.http.User-Agent ~ \"(?i)android 3\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\t\/* Opera Mobile *\/\n\t\telsif (req.http.User-Agent ~ \"Opera Mobi\") { set req.http.X-UA-Device = \"mobile-smartphone\"; }\n\t\t\/\/ May very well give false positives towards android tablets. Suggestions welcome.\n\t\telsif (req.http.User-Agent ~ \"(?i)android\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\telsif (req.http.User-Agent ~ \"PlayBook; U; RIM Tablet\") { set req.http.X-UA-Device = \"tablet-rim\"; }\n\t\telsif (req.http.User-Agent ~ \"hp-tablet.*TouchPad\") { set req.http.X-UA-Device = \"tablet-hp\"; }\n\t\telsif (req.http.User-Agent ~ \"Kindle\/3\") { set req.http.X-UA-Device = \"tablet-kindle\"; }\n\t\telsif (req.http.User-Agent ~ \"Touch.+Tablet PC\" ||\n\t\t req.http.User-Agent ~ \"Windows NT [0-9.]+; ARM;\" ) {\n\t\t set req.http.X-UA-Device = \"tablet-microsoft\";\n\t\t}\n\t\telsif (req.http.User-Agent ~ \"Mobile.+Firefox\") { set req.http.X-UA-Device = \"mobile-firefoxos\"; }\n\t\telsif (req.http.User-Agent ~ \"^HTC\" ||\n\t\t req.http.User-Agent ~ \"Fennec\" ||\n\t\t req.http.User-Agent ~ \"IEMobile\" ||\n\t\t req.http.User-Agent ~ \"BlackBerry\" ||\n\t\t req.http.User-Agent ~ \"BB10.*Mobile\" ||\n\t\t req.http.User-Agent ~ \"GT-.*Build\/GINGERBREAD\" ||\n\t\t req.http.User-Agent ~ \"SymbianOS.*AppleWebKit\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-smartphone\";\n\t\t}\n\t\telsif (req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)^sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)^nokia\" ||\n\t\t req.http.User-Agent ~ \"(?i)^samsung\" ||\n\t\t req.http.User-Agent ~ \"(?i)^lg\" ||\n\t\t req.http.User-Agent ~ \"(?i)bada\" ||\n\t\t req.http.User-Agent ~ \"(?i)blazer\" ||\n\t\t req.http.User-Agent ~ \"(?i)cellphone\" ||\n\t\t req.http.User-Agent ~ \"(?i)iemobile\" ||\n\t\t req.http.User-Agent ~ \"(?i)midp-2.0\" ||\n\t\t req.http.User-Agent ~ \"(?i)u990\" ||\n\t\t req.http.User-Agent ~ \"(?i)netfront\" ||\n\t\t req.http.User-Agent ~ \"(?i)opera mini\" ||\n\t\t req.http.User-Agent ~ \"(?i)palm\" ||\n\t\t req.http.User-Agent ~ \"(?i)nintendo wii\" ||\n\t\t req.http.User-Agent ~ \"(?i)playstation portable\" ||\n\t\t req.http.User-Agent ~ \"(?i)portalmmm\" ||\n\t\t req.http.User-Agent ~ \"(?i)proxinet\" ||\n\t\t req.http.User-Agent ~ \"(?i)windows\\ ?ce\" ||\n\t\t req.http.User-Agent ~ \"(?i)winwap\" ||\n\t\t req.http.User-Agent ~ \"(?i)eudoraweb\" ||\n\t\t req.http.User-Agent ~ \"(?i)htc\" ||\n\t\t req.http.User-Agent ~ \"(?i)240x320\" ||\n\t\t req.http.User-Agent ~ \"(?i)avantgo\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-generic\";\n\t\t}\n\t}\n}\n","old_contents":"# Copyright (c) 2012-2014 Varnish Software AS\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions\n# are met:\n# 1. Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n# 2. Redistributions in binary form must reproduce the above copyright\n# notice, this list of conditions and the following disclaimer in the\n# documentation and\/or other materials provided with the distribution.\n#\n# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n# ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n# SUCH DAMAGE.\n#\n# detectdevice.vcl - regex based device detection for Varnish\n# https:\/\/github.com\/varnishcache\/varnish-devicedetect\/\n#\n# Author: Lasse Karstensen <lkarsten@varnish-software.com>\n\nsub devicedetect {\n\tunset req.http.X-UA-Device;\n\tset req.http.X-UA-Device = \"pc\";\n\n\t# Handle that a cookie may override the detection alltogether.\n\tif (req.http.Cookie ~ \"(?i)X-UA-Device-force\") {\n\t\t\/* ;?? means zero or one ;, non-greedy to match the first. *\/\n\t\tset req.http.X-UA-Device = regsub(req.http.Cookie, \"(?i).*X-UA-Device-force=([^;]+);??.*\", \"\\1\");\n\t\t\/* Clean up our mess in the cookie header *\/\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|; ) *X-UA-Device-force=[^;]+;? *\", \"\\1\");\n\t\t\/* If the cookie header is now empty, or just whitespace, unset it. *\/\n\t\tif (req.http.Cookie ~ \"^ *$\") { unset req.http.Cookie; }\n\t} else {\n if (req.http.User-Agent ~ \"\\(compatible; Googlebot-Mobile\/2.1; \\+http:\/\/www.google.com\/bot.html\\)\" ||\n (req.http.User-Agent ~ \"(Android|iPhone)\" && req.http.User-Agent ~ \"\\(compatible.?; Googlebot\/2.1.?; \\+http:\/\/www.google.com\/bot.html\") ||\n\t\t\t(req.http.User-Agent ~ \"(iPhone|Windows Phone)\" && req.http.User-Agent ~ \"\\(compatible; bingbot\/2.0; \\+http:\/\/www.bing.com\/bingbot.htm\")) {\n set req.http.X-UA-Device = \"mobile-bot\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)(ads|google|bing|msn|yandex|baidu|ro|career|seznam|)bot\" ||\n\t\t req.http.User-Agent ~ \"(?i)(baidu|jike|symantec)spider\" ||\n\t\t req.http.User-Agent ~ \"(?i)pingdom\" ||\n\t\t req.http.User-Agent ~ \"(?i)facebookexternalhit\" ||\n\t\t req.http.User-Agent ~ \"(?i)scanner\" ||\n\t\t req.http.User-Agent ~ \"(?i)slurp\" ||\n\t\t req.http.User-Agent ~ \"(?i)(web)crawler\") {\n\t\t\tset req.http.X-UA-Device = \"bot\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ipad\") { set req.http.X-UA-Device = \"tablet-ipad\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ip(hone|od)\") { set req.http.X-UA-Device = \"mobile-iphone\"; }\n\t\t\/* how do we differ between an android phone and an android tablet?\n\t\t http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent *\/\n\t\telsif (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") { set req.http.X-UA-Device = \"mobile-android\"; }\n\t\t\/\/ android 3\/honeycomb was just about tablet-only, and any phones will probably handle a bigger page layout.\n\t\telsif (req.http.User-Agent ~ \"(?i)android 3\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\t\/* Opera Mobile *\/\n\t\telsif (req.http.User-Agent ~ \"Opera Mobi\") { set req.http.X-UA-Device = \"mobile-smartphone\"; }\n\t\t\/\/ May very well give false positives towards android tablets. Suggestions welcome.\n\t\telsif (req.http.User-Agent ~ \"(?i)android\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\telsif (req.http.User-Agent ~ \"PlayBook; U; RIM Tablet\") { set req.http.X-UA-Device = \"tablet-rim\"; }\n\t\telsif (req.http.User-Agent ~ \"hp-tablet.*TouchPad\") { set req.http.X-UA-Device = \"tablet-hp\"; }\n\t\telsif (req.http.User-Agent ~ \"Kindle\/3\") { set req.http.X-UA-Device = \"tablet-kindle\"; }\n\t\telsif (req.http.User-Agent ~ \"Touch.+Tablet PC\" ||\n\t\t req.http.User-Agent ~ \"Windows NT [0-9.]+; ARM;\" ) {\n\t\t set req.http.X-UA-Device = \"tablet-microsoft\";\n\t\t}\n\t\telsif (req.http.User-Agent ~ \"Mobile.+Firefox\") { set req.http.X-UA-Device = \"mobile-firefoxos\"; }\n\t\telsif (req.http.User-Agent ~ \"^HTC\" ||\n\t\t req.http.User-Agent ~ \"Fennec\" ||\n\t\t req.http.User-Agent ~ \"IEMobile\" ||\n\t\t req.http.User-Agent ~ \"BlackBerry\" ||\n\t\t req.http.User-Agent ~ \"BB10.*Mobile\" ||\n\t\t req.http.User-Agent ~ \"GT-.*Build\/GINGERBREAD\" ||\n\t\t req.http.User-Agent ~ \"SymbianOS.*AppleWebKit\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-smartphone\";\n\t\t}\n\t\telsif (req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)^sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)^nokia\" ||\n\t\t req.http.User-Agent ~ \"(?i)^samsung\" ||\n\t\t req.http.User-Agent ~ \"(?i)^lg\" ||\n\t\t req.http.User-Agent ~ \"(?i)bada\" ||\n\t\t req.http.User-Agent ~ \"(?i)blazer\" ||\n\t\t req.http.User-Agent ~ \"(?i)cellphone\" ||\n\t\t req.http.User-Agent ~ \"(?i)iemobile\" ||\n\t\t req.http.User-Agent ~ \"(?i)midp-2.0\" ||\n\t\t req.http.User-Agent ~ \"(?i)u990\" ||\n\t\t req.http.User-Agent ~ \"(?i)netfront\" ||\n\t\t req.http.User-Agent ~ \"(?i)opera mini\" ||\n\t\t req.http.User-Agent ~ \"(?i)palm\" ||\n\t\t req.http.User-Agent ~ \"(?i)nintendo wii\" ||\n\t\t req.http.User-Agent ~ \"(?i)playstation portable\" ||\n\t\t req.http.User-Agent ~ \"(?i)portalmmm\" ||\n\t\t req.http.User-Agent ~ \"(?i)proxinet\" ||\n\t\t req.http.User-Agent ~ \"(?i)windows\\ ?ce\" ||\n\t\t req.http.User-Agent ~ \"(?i)winwap\" ||\n\t\t req.http.User-Agent ~ \"(?i)eudoraweb\" ||\n\t\t req.http.User-Agent ~ \"(?i)htc\" ||\n\t\t req.http.User-Agent ~ \"(?i)240x320\" ||\n\t\t req.http.User-Agent ~ \"(?i)avantgo\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-generic\";\n\t\t}\n\t}\n}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"6000374cde483e2f9e3f399db7bd369824001909","subject":"update varnish port","message":"update varnish port","repos":"KhanovaSkola\/khanovaskola-v3,KhanovaSkola\/khanovaskola-v3,KhanovaSkola\/khanovaskola-v3,KhanovaSkola\/khanovaskola-v3,KhanovaSkola\/khanovaskola-v3,KhanovaSkola\/khanovaskola-v3","old_file":"production\/varnish.vcl","new_file":"production\/varnish.vcl","new_contents":"vcl 4.0;\n\n# Disable esi xml check on varnish Startup\n# Example:\n# DAEMON_OPTS=\"-a :6081 \\\n# -T localhost:6082 \\\n# -p feature=+esi_disable_xml_check\n# -p feature=+esi_ignore_https\n#\n\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8086\";\n}\n\nimport std;\n\nsub vcl_recv {\n if (req.method != \"GET\")\n {\n return (pass);\n }\n if (req.http.Cookie ~ \"\\bvarnish-force=pass\")\n {\n return (pass);\n }\n\n if (req.url ~ \"\/esi\/header\")\n {\n set req.http.Cookie = \";\" + req.http.Cookie;\n set req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n set req.http.Cookie = regsuball(req.http.Cookie, \";(PHPSESSID)=\", \"; \\1=\");\n set req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n if (req.http.Cookie == \"\")\n {\n unset req.http.Cookie;\n }\n }\n\n return (hash);\n}\n\nsub vcl_hash {\n hash_data(req.http.host);\n hash_data(req.url);\n if (req.url ~ \"\/esi\/header\/\")\n {\n hash_data(req.http.Cookie);\n }\n return(lookup);\n}\n\nsub vcl_backend_response {\n if (bereq.url ~ \"\/esi\/header\/\")\n {\n unset beresp.http.Pragma;\n unset beresp.http.Cache-control;\n set beresp.ttl = 30m;\n }\n else if (beresp.http.Cache-Control != \"public\")\n {\n set beresp.uncacheable = true;\n set beresp.ttl = 3m;\n return (deliver);\n }\n\n set beresp.do_esi = true;\n set beresp.ttl = std.duration(beresp.http.Varnish-TTL, 15m);\n\n unset beresp.http.Set-Cookie;\n}\n","old_contents":"vcl 4.0;\n\n# Disable esi xml check on varnish Startup\n# Example:\n# DAEMON_OPTS=\"-a :6081 \\\n# -T localhost:6082 \\\n# -p feature=+esi_disable_xml_check\n# -p feature=+esi_ignore_https\n#\n\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8085\";\n}\n\nimport std;\n\nsub vcl_recv {\n if (req.method != \"GET\")\n {\n return (pass);\n }\n if (req.http.Cookie ~ \"\\bvarnish-force=pass\")\n {\n return (pass);\n }\n\n if (req.url ~ \"\/esi\/header\")\n {\n set req.http.Cookie = \";\" + req.http.Cookie;\n set req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n set req.http.Cookie = regsuball(req.http.Cookie, \";(PHPSESSID)=\", \"; \\1=\");\n set req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n if (req.http.Cookie == \"\")\n {\n unset req.http.Cookie;\n }\n }\n\n return (hash);\n}\n\nsub vcl_hash {\n hash_data(req.http.host);\n hash_data(req.url);\n if (req.url ~ \"\/esi\/header\/\")\n {\n hash_data(req.http.Cookie);\n }\n return(lookup);\n}\n\nsub vcl_backend_response {\n if (bereq.url ~ \"\/esi\/header\/\")\n {\n unset beresp.http.Pragma;\n unset beresp.http.Cache-control;\n set beresp.ttl = 30m;\n }\n else if (beresp.http.Cache-Control != \"public\")\n {\n set beresp.uncacheable = true;\n set beresp.ttl = 3m;\n return (deliver);\n }\n\n set beresp.do_esi = true;\n set beresp.ttl = std.duration(beresp.http.Varnish-TTL, 15m);\n\n unset beresp.http.Set-Cookie;\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"66e24118f759459b523ebdcac98f6de3dc044f3f","subject":"Wrong obj.status for force TLS","message":"Wrong obj.status for force TLS\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets_force_tls\/recv.vcl","new_file":"etc\/vcl_snippets_force_tls\/recv.vcl","new_contents":"# Force SSL immediately to avoid magento module VCL stripping off\n# google campaign ids like gclid\n if (!req.http.Fastly-SSL) { \n error 801 \"Force SSL\";\n }\n","old_contents":"# Force SSL immediately to avoid magento module VCL stripping off\n# google campaign ids like gclid\n if (!req.http.Fastly-SSL) { \n error 972 \"Force SSL\"; \n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"4c8dce229f9af346782002ddf1c66eed95e5b350","subject":"Allow to cache search results ","message":"Allow to cache search results \n\nSee https:\/\/github.com\/magento\/magento2\/pull\/30340","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets\/recv.vcl","new_file":"etc\/vcl_snippets\/recv.vcl","new_contents":" # When using Magento tester to test whether your site is configured properly\n # this uses a bypass secret. By default we will use service ID as the bypass secret\n # however user can override this by defining a bypass_secret key in the \n # magentomodule_config edge dictionary\n if ( req.http.bypass-secret ) {\n declare local var.bypass-secret STRING;\n set var.bypass-secret = table.lookup(magentomodule_config, \"bypass_secret\", \"NONE\");\n if ( var.bypass-secret == req.http.bypass-secret ) {\n set req.http.x-pass = \"1\";\n set var.fastly_req_do_shield = false;\n set req.hash_always_miss = true;\n } else if ( var.bypass-secret == \"NONE\" && req.http.bypass-secret == req.service_id ) {\n set req.http.x-pass = \"1\";\n set var.fastly_req_do_shield = false;\n set req.hash_always_miss = true;\n } else {\n error 403 \"Bypass Secret incorrect\";\n }\n }\n\n # VCL required to support maintenance mode. Don't maintenance mode admin pages and supporting assets\n if (table.lookup(magentomodule_config, \"allow_super_users_during_maint\", \"0\") == \"1\" &&\n !req.http.Fastly-Client-Ip ~ maint_allowlist &&\n !req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" &&\n !req.url ~ \"^\/pub\/static\/\") {\n\n # If we end up here after a restart and there is a ResponseObject it means we got here after error\n # page VCL restart. We shouldn't touch it. Otherwise return a plain 503 error page\n if ( req.restarts > 0 && req.http.ResponseObject ) {\n set req.http.ResponseObject = \"970\";\n } else {\n error 503 \"Maintenance mode\";\n }\n }\n\n # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n unset req.http.x-long-cache;\n\n # We want to force long cache times on any of the versioned assets\n if (req.url.path ~ \"^\/static\/version\\d*\/\") {\n set req.http.x-long-cache = \"1\";\n }\n \n # User's Cookie may contain some Magento Vary items we should vary on\n if (req.http.cookie:X-Magento-Vary) {\n set req.http.X-Magento-Vary = req.http.cookie:X-Magento-Vary;\n } else {\n unset req.http.X-Magento-Vary;\n }\n\n ############################################################################################################\n # Following code block controls purge by URL. By default we want to protect all URL purges. In general this\n # is addressed by adding Fastly-Purge-Requires-Auth request header in vcl_recv however this runs the risk of\n # exposing API tokens if user attempts to purge non-https URLs. For this reason inside the Magento module\n # we use X-Purge-Token. Unfortunately this breaks purge from the Fastly UI. Therefore in the next code block\n # we check for presence of X-Purge-Token. If it's not present we force the Fastly-Purge-Requires-Auth\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n if (req.http.X-Purge-Token && req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n } else {\n error 403;\n }\n } else {\n set req.http.Fastly-Purge-Requires-Auth = \"1\";\n }\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (fastly.ff.visits_this_service > 0) {\n # disable ESI processing on Origin Shield\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Make sure we lookup end user geo not shielding. More at https:\/\/docs.fastly.com\/vcl\/geolocation\/#using-geographic-variables-with-shielding\n set client.geo.ip_override = req.http.Fastly-Client-IP;\n\n # geoip lookup\n if (req.url.path ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie:X-Magento-Vary || req.http.cookie:form_key) {\n error 980 \"GeoIP already processed\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url.qs !~ \"country_code=\" ) {\n set req.url = querystring.set(req.url, \"country_code\", if ( req.http.geo_override, req.http.geo_override, client.geo.country_code));\n }\n }\n } else if ( req.url.path !~ \"\/graphql\" ) {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking by default\n # and allow custom parameters to be set. List of parameters is configurable in admin\n set req.http.Magento-Original-URL = req.url;\n # Change the list of ignored parameters by configuring them in the Advanced section\n set req.url = querystring.regfilter(req.url, \"^(####QUERY_PARAMETERS####)\");\n }\n\n # Don't allow clients to force a pass\n if (req.restarts == 0) {\n unset req.http.x-pass;\n unset req.http.Rate-Limit;\n unset req.http.magento-admin-path;\n }\n \n # Pass on checkout URLs. Because it's a snippet we want to execute this after backend selection so we handle it\n # in the request condition\n if (!req.http.x-long-cache && req.url ~ \"\/(checkout|customer\/section\/load)\") {\n set req.http.x-pass = \"1\";\n # Pass all admin actions\n # ####ADMIN_PATH#### is replaced with value of frontName from app\/etc\/env.php\n } else if ( req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" ) {\n set req.http.x-pass = \"1\";\n set req.http.magento-admin-path = \"1\";\n } else {\n # Sort the query arguments to increase cache hit ratio with query arguments that\n # may be out od order. In case you want to restore the unsorted URL add a snippet\n # after this one that sets req.url to req.http.Magento-Original-URL\n if ( !req.http.x-pass ) {\n set req.url = boltsort.sort(req.url);\n }\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.http.x-long-cache || req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n unset req.http.graphql;\n # GraphQL special headers handling because this area doesn't rely on X-Magento-Vary cookie\n if (req.request == \"GET\" && req.url.path ~ \"\/graphql\" && req.url.qs ~ \"query=\") {\n if ( req.http.Authorization ~ \"^Bearer\" ) {\n set req.http.x-pass = \"1\";\n } else {\n set req.http.graphql = \"1\";\n if (req.http.Store) {\n set req.http.X-Magento-Vary = req.http.Store;\n }\n if (req.http.Content-Currency) {\n if (req.http.X-Magento-Vary) {\n set req.http.X-Magento-Vary = req.http.X-Magento-Vary req.http.Content-Currency;\n } else {\n set req.http.X-Magento-Vary = req.http.Content-Currency;\n }\n }\n }\n }\n","old_contents":" # When using Magento tester to test whether your site is configured properly\n # this uses a bypass secret. By default we will use service ID as the bypass secret\n # however user can override this by defining a bypass_secret key in the \n # magentomodule_config edge dictionary\n if ( req.http.bypass-secret ) {\n declare local var.bypass-secret STRING;\n set var.bypass-secret = table.lookup(magentomodule_config, \"bypass_secret\", \"NONE\");\n if ( var.bypass-secret == req.http.bypass-secret ) {\n set req.http.x-pass = \"1\";\n set var.fastly_req_do_shield = false;\n set req.hash_always_miss = true;\n } else if ( var.bypass-secret == \"NONE\" && req.http.bypass-secret == req.service_id ) {\n set req.http.x-pass = \"1\";\n set var.fastly_req_do_shield = false;\n set req.hash_always_miss = true;\n } else {\n error 403 \"Bypass Secret incorrect\";\n }\n }\n\n # VCL required to support maintenance mode. Don't maintenance mode admin pages and supporting assets\n if (table.lookup(magentomodule_config, \"allow_super_users_during_maint\", \"0\") == \"1\" &&\n !req.http.Fastly-Client-Ip ~ maint_allowlist &&\n !req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" &&\n !req.url ~ \"^\/pub\/static\/\") {\n\n # If we end up here after a restart and there is a ResponseObject it means we got here after error\n # page VCL restart. We shouldn't touch it. Otherwise return a plain 503 error page\n if ( req.restarts > 0 && req.http.ResponseObject ) {\n set req.http.ResponseObject = \"970\";\n } else {\n error 503 \"Maintenance mode\";\n }\n }\n\n # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n unset req.http.x-long-cache;\n\n # We want to force long cache times on any of the versioned assets\n if (req.url.path ~ \"^\/static\/version\\d*\/\") {\n set req.http.x-long-cache = \"1\";\n }\n \n # User's Cookie may contain some Magento Vary items we should vary on\n if (req.http.cookie:X-Magento-Vary) {\n set req.http.X-Magento-Vary = req.http.cookie:X-Magento-Vary;\n } else {\n unset req.http.X-Magento-Vary;\n }\n\n ############################################################################################################\n # Following code block controls purge by URL. By default we want to protect all URL purges. In general this\n # is addressed by adding Fastly-Purge-Requires-Auth request header in vcl_recv however this runs the risk of\n # exposing API tokens if user attempts to purge non-https URLs. For this reason inside the Magento module\n # we use X-Purge-Token. Unfortunately this breaks purge from the Fastly UI. Therefore in the next code block\n # we check for presence of X-Purge-Token. If it's not present we force the Fastly-Purge-Requires-Auth\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n if (req.http.X-Purge-Token && req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n } else {\n error 403;\n }\n } else {\n set req.http.Fastly-Purge-Requires-Auth = \"1\";\n }\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (fastly.ff.visits_this_service > 0) {\n # disable ESI processing on Origin Shield\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Make sure we lookup end user geo not shielding. More at https:\/\/docs.fastly.com\/vcl\/geolocation\/#using-geographic-variables-with-shielding\n set client.geo.ip_override = req.http.Fastly-Client-IP;\n\n # geoip lookup\n if (req.url.path ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie:X-Magento-Vary || req.http.cookie:form_key) {\n error 980 \"GeoIP already processed\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url.qs !~ \"country_code=\" ) {\n set req.url = querystring.set(req.url, \"country_code\", if ( req.http.geo_override, req.http.geo_override, client.geo.country_code));\n }\n }\n } else if ( req.url.path !~ \"\/graphql\" ) {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking by default\n # and allow custom parameters to be set. List of parameters is configurable in admin\n set req.http.Magento-Original-URL = req.url;\n # Change the list of ignored parameters by configuring them in the Advanced section\n set req.url = querystring.regfilter(req.url, \"^(####QUERY_PARAMETERS####)\");\n }\n\n # Don't allow clients to force a pass\n if (req.restarts == 0) {\n unset req.http.x-pass;\n unset req.http.Rate-Limit;\n unset req.http.magento-admin-path;\n }\n \n # Pass on checkout URLs. Because it's a snippet we want to execute this after backend selection so we handle it\n # in the request condition\n if (!req.http.x-long-cache && req.url ~ \"\/(catalogsearch|checkout|customer\/section\/load)\") {\n set req.http.x-pass = \"1\";\n # Pass all admin actions\n # ####ADMIN_PATH#### is replaced with value of frontName from app\/etc\/env.php\n } else if ( req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" ) {\n set req.http.x-pass = \"1\";\n set req.http.magento-admin-path = \"1\";\n } else {\n # Sort the query arguments to increase cache hit ratio with query arguments that\n # may be out od order. In case you want to restore the unsorted URL add a snippet\n # after this one that sets req.url to req.http.Magento-Original-URL\n if ( !req.http.x-pass ) {\n set req.url = boltsort.sort(req.url);\n }\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.http.x-long-cache || req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n unset req.http.graphql;\n # GraphQL special headers handling because this area doesn't rely on X-Magento-Vary cookie\n if (req.request == \"GET\" && req.url.path ~ \"\/graphql\" && req.url.qs ~ \"query=\") {\n if ( req.http.Authorization ~ \"^Bearer\" ) {\n set req.http.x-pass = \"1\";\n } else {\n set req.http.graphql = \"1\";\n if (req.http.Store) {\n set req.http.X-Magento-Vary = req.http.Store;\n }\n if (req.http.Content-Currency) {\n if (req.http.X-Magento-Vary) {\n set req.http.X-Magento-Vary = req.http.X-Magento-Vary req.http.Content-Currency;\n } else {\n set req.http.X-Magento-Vary = req.http.Content-Currency;\n }\n }\n }\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"63d40dd76febb474aaece30a069da372db5b390a","subject":"Removing health checks for the moment","message":"Removing health checks for the moment\n","repos":"micktwomey\/docker-django-varnish","old_file":"default.vcl","new_file":"default.vcl","new_contents":"vcl 4.0;\nimport std;\n\nbackend default {\n .host = \"::BACKEND_PORT_8000_TCP_ADDR::\";\n .port = \"::BACKEND_PORT_8000_TCP_PORT::\";\n # .probe = {\n # .url = \"\/\";\n # .interval = 5s;\n # .timeout = 1 s;\n # .window = 5;\n # .threshold = 3;\n # }\n}\n\nsub vcl_recv {\n # Ignore all cookies except for \/admin\n if (!(req.url ~ \"^\/admin\/\")) {\n unset req.http.Cookie;\n }\n\n # # Give ourself some restart time\n # set req.backend_hint = default;\n # if (! std.healthy(req.backend)) {\n # set req.grace = 5m;\n # } else {\n # set req.grace = 15s;\n # }\n}\n\nsub vcl_backend_response {\n # Unset any cookies for static content and cache for 1 hour\n if (bereq.url ~ \"^\/static\/\") {\n unset beresp.http.set-cookie;\n set beresp.ttl = 1h;\n }\n # # Add some grace for backend restarts\n # set beresp.grace = 30m;\n}\n","old_contents":"vcl 4.0;\nimport std;\n\nbackend default {\n .host = \"::BACKEND_PORT_8000_TCP_ADDR::\";\n .port = \"::BACKEND_PORT_8000_TCP_PORT::\";\n .probe = {\n .url = \"\/\";\n .interval = 5s;\n .timeout = 1 s;\n .window = 5;\n .threshold = 3;\n }\n}\n\nsub vcl_recv {\n # Ignore all cookies except for \/admin\n if (!(req.url ~ \"^\/admin\/\")) {\n unset req.http.Cookie;\n }\n\n # # Give ourself some restart time\n # set req.backend_hint = default;\n # if (! std.healthy(req.backend)) {\n # set req.grace = 5m;\n # } else {\n # set req.grace = 15s;\n # }\n}\n\nsub vcl_backend_response {\n # Unset any cookies for static content and cache for 1 hour\n if (bereq.url ~ \"^\/static\/\") {\n unset beresp.http.set-cookie;\n set beresp.ttl = 1h;\n }\n # # Add some grace for backend restarts\n # set beresp.grace = 30m;\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"e137abd88799ae499d3b91bd2e1d37cef656ce33","subject":"Use r2 for all JSON, RSS, and XML related endpoints.","message":"Use r2 for all JSON, RSS, and XML related endpoints.\n","repos":"ajacksified\/reddit-mobile,ajacksified\/reddit-mobile,ajacksified\/reddit-mobile,ajacksified\/reddit-mobile","old_file":"default.vcl","new_file":"default.vcl","new_contents":"backend mweb {\n .host = \"mweb\";\n .port = \"4444\";\n}\n\/* backend www {\n .host = \"www.reddit.com\";\n .port = \"80\";\n} *\/\n\n\nsub vcl_recv {\n call device_detect;\n\n # Check mweb override cookie.\n if (req.http.Cookie ~ \"(^|;\\s*)(mweb-no-redirect=1)(;|$)\") {\n call set_www_backend;\n } elsif (\n (req.http.X-UA-Device ~ \"^mobile-\" || req.http.X-UA-Device ~ \"^tablet-\")\n # We don't host endpoints with extensions in mweb.\n # The Fastly equivalent is: && !req.url.ext\n && !reg.url ~ \"\\\/.+\\.[a-z]{3,4}(\\?.*|$)\"\n && (\n # Blacklisted endpoints\n # This endpoint 200's for mweb, but the current implementation has issues\n req.url !~ \"^\/message\/compose\/?$\"\n )\n && (\n # Whitelisted 2X endpoints from router\/index.js\n req.url == \"\/\"\n || req.url ~ \"^\/actions\/\"\n || req.url ~ \"^\/comments\/?\"\n || req.url ~ \"^\/login\/?$\"\n || req.url ~ \"^\/message\/\"\n || req.url ~ \"^\/r\/\"\n || req.url ~ \"^\/register\/?$\"\n || req.url ~ \"^\/report\/?$\"\n || req.url ~ \"^\/search\/?$\"\n || req.url ~ \"^\/submit\/?$\"\n || req.url ~ \"^\/submit_to_community\/?$\"\n || req.url ~ \"^\/u\/\"\n || req.url ~ \"^\/user\/\"\n || req.url ~ \"^\/vote\/\"\n || req.url ~ \"^\/(help|w|wiki)\/?\"\n # Whitelisted 2X Ajax endpoints\n || req.url ~ \"^\/csp-report$\"\n || req.url == \"\/error\"\n || req.url ~ \"^\/(login|refresh|register)proxy$\"\n || req.url ~ \"^\/logout\"\n || req.url == \"\/routes\"\n || req.url ~ \"^\/timings$\"\n || req.url ~ \"^\/(u\/)?XXX\\?.*\"\n # Whitelisted dev endpoints (these will be hosted on www in production)\n || req.url == \"\/apple-app-site-association\"\n || req.url ~ \"^\/favicon\/\"\n || req.url ~ \"^\/favicon\\.ico\"\n || req.url ~ \"^\/fonts\/\"\n || req.url == \"\/health\"\n || req.url ~ \"^\/img\/\"\n || req.url ~ \"^\/ProductionClient\\..*\\.(css|js)$\"\n || req.url == \"\/robots.txt\"\n )) {\n # If it's a mobile device and a whitelisted endpoint, use mweb.\n set req.backend = mweb;\n } else {\n call set_www_backend;\n }\n}\n\n\nsub set_www_backend {\n # NOTE(wting|2016-09-26): Normally we would redirect the user to a different\n # backend, but instead we're using a 400 status code for easy programmatic testing.\n error 400;\n # set req.backend = www;\n}\n\n\n# Vendorized from https:\/\/github.com\/varnish\/varnish-devicedetect\/blob\/master\/devicedetect.vcl\n# BSD-2 License\nsub device_detect {\n unset req.http.X-UA-Device;\n set req.http.X-UA-Device = \"pc\";\n\n # Handle that a cookie may override the detection alltogether.\n if (req.http.Cookie ~ \"(?i)X-UA-Device-force\") {\n \/* ;?? means zero or one ;, non-greedy to match the first. *\/\n set req.http.X-UA-Device = regsub(req.http.Cookie, \"(?i).*X-UA-Device-force=([^;]+);??.*\", \"\\1\");\n \/* Clean up our mess in the cookie header *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \"(^|; ) *X-UA-Device-force=[^;]+;? *\", \"\\1\");\n \/* If the cookie header is now empty, or just whitespace, unset it. *\/\n if (req.http.Cookie ~ \"^ *$\") {\n unset req.http.Cookie;\n }\n } else {\n if (req.http.User-Agent ~ \"\\(compatible; Googlebot-Mobile\/2.1; \\+http:\/\/www.google.com\/bot.html\\)\"\n || (req.http.User-Agent ~ \"(Android|iPhone)\"\n && req.http.User-Agent ~ \"\\(compatible.?; Googlebot\/2.1.?; \\+http:\/\/www.google.com\/bot.html\")\n || (req.http.User-Agent ~ \"(iPhone|Windows Phone)\"\n && req.http.User-Agent ~ \"\\(compatible; bingbot\/2.0; \\+http:\/\/www.bing.com\/bingbot.htm\")\n ) {\n set req.http.X-UA-Device = \"mobile-bot\";\n } elsif (req.http.User-Agent ~ \"(?i)(ads|google|bing|msn|yandex|baidu|ro|career|seznam|)bot\"\n || req.http.User-Agent ~ \"(?i)(baidu|jike|symantec)spider\"\n || req.http.User-Agent ~ \"(?i)scanner\"\n || req.http.User-Agent ~ \"(?i)(web)crawler\"\n ) {\n set req.http.X-UA-Device = \"bot\";\n } elsif (req.http.User-Agent ~ \"(?i)ipad\") {\n set req.http.X-UA-Device = \"tablet-ipad\";\n } elsif (req.http.User-Agent ~ \"(?i)ip(hone|od)\") {\n set req.http.X-UA-Device = \"mobile-iphone\";\n } elsif (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") {\n \/* how do we differ between an android phone and an android tablet? *\/\n \/* http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent *\/\n set req.http.X-UA-Device = \"mobile-android\";\n }\n elsif (req.http.User-Agent ~ \"(?i)android 3\") {\n \/* https:\/\/github.com\/varnish\/varnish-devicedetect\/blob\/master\/devicedetect.vcl *\/\n set req.http.X-UA-Device = \"tablet-android\";\n } elsif (req.http.User-Agent ~ \"Opera Mobi\") {\n \/* Opera Mobile *\/\n set req.http.X-UA-Device = \"mobile-smartphone\";\n }\n elsif (req.http.User-Agent ~ \"(?i)android\") {\n \/* May very well give false positives towards android tablets. Suggestions welcome. *\/\n set req.http.X-UA-Device = \"tablet-android\";\n } elsif (req.http.User-Agent ~ \"PlayBook; U; RIM Tablet\") {\n set req.http.X-UA-Device = \"tablet-rim\";\n } elsif (req.http.User-Agent ~ \"hp-tablet.*TouchPad\") {\n set req.http.X-UA-Device = \"tablet-hp\";\n } elsif (req.http.User-Agent ~ \"Kindle\/3\") {\n set req.http.X-UA-Device = \"tablet-kindle\";\n } elsif (req.http.User-Agent ~ \"Touch.+Tablet PC\" || req.http.User-Agent ~ \"Windows NT [0-9.]+; ARM;\" ) {\n set req.http.X-UA-Device = \"tablet-microsoft\";\n } elsif (req.http.User-Agent ~ \"Mobile.+Firefox\") {\n set req.http.X-UA-Device = \"mobile-firefoxos\";\n } elsif (req.http.User-Agent ~ \"^HTC\"\n || req.http.User-Agent ~ \"Fennec\"\n || req.http.User-Agent ~ \"IEMobile\"\n || req.http.User-Agent ~ \"BlackBerry\"\n || req.http.User-Agent ~ \"BB10.*Mobile\"\n || req.http.User-Agent ~ \"GT-.*Build\/GINGERBREAD\"\n || req.http.User-Agent ~ \"SymbianOS.*AppleWebKit\") {\n set req.http.X-UA-Device = \"mobile-smartphone\";\n }\n elsif (req.http.User-Agent ~ \"(?i)symbian\"\n || req.http.User-Agent ~ \"(?i)^sonyericsson\"\n || req.http.User-Agent ~ \"(?i)^nokia\"\n || req.http.User-Agent ~ \"(?i)^samsung\"\n || req.http.User-Agent ~ \"(?i)^lg\"\n || req.http.User-Agent ~ \"(?i)bada\"\n || req.http.User-Agent ~ \"(?i)blazer\"\n || req.http.User-Agent ~ \"(?i)cellphone\"\n || req.http.User-Agent ~ \"(?i)iemobile\"\n || req.http.User-Agent ~ \"(?i)midp-2.0\"\n || req.http.User-Agent ~ \"(?i)u990\"\n || req.http.User-Agent ~ \"(?i)netfront\"\n || req.http.User-Agent ~ \"(?i)opera mini\"\n || req.http.User-Agent ~ \"(?i)palm\"\n || req.http.User-Agent ~ \"(?i)nintendo wii\"\n || req.http.User-Agent ~ \"(?i)playstation portable\"\n || req.http.User-Agent ~ \"(?i)portalmmm\"\n || req.http.User-Agent ~ \"(?i)proxinet\"\n || req.http.User-Agent ~ \"(?i)sonyericsson\"\n || req.http.User-Agent ~ \"(?i)symbian\"\n || req.http.User-Agent ~ \"(?i)windows\\ ?ce\"\n || req.http.User-Agent ~ \"(?i)winwap\"\n || req.http.User-Agent ~ \"(?i)eudoraweb\"\n || req.http.User-Agent ~ \"(?i)htc\"\n || req.http.User-Agent ~ \"(?i)240x320\"\n || req.http.User-Agent ~ \"(?i)avantgo\") {\n set req.http.X-UA-Device = \"mobile-generic\";\n }\n }\n}\n","old_contents":"backend mweb {\n .host = \"mweb\";\n .port = \"4444\";\n}\n\/* backend www {\n .host = \"www.reddit.com\";\n .port = \"80\";\n} *\/\n\n\nsub vcl_recv {\n call device_detect;\n\n # Check mweb override cookie.\n if (req.http.Cookie ~ \"(^|;\\s*)(mweb-no-redirect=1)(;|$)\") {\n call set_www_backend;\n } elsif (\n (req.http.X-UA-Device ~ \"^mobile-\" || req.http.X-UA-Device ~ \"^tablet-\")\n && (\n # Blacklisted endpoints\n # This endpoint 200's for mweb, but the current implementation has issues\n req.url !~ \"^\/message\/compose\/?$\"\n )\n && (\n # Whitelisted 2X endpoints from router\/index.js\n req.url == \"\/\"\n || req.url ~ \"^\/actions\/\"\n || req.url ~ \"^\/comments\/?\"\n || req.url ~ \"^\/login\/?$\"\n || req.url ~ \"^\/message\/\"\n || req.url ~ \"^\/r\/\"\n || req.url ~ \"^\/register\/?$\"\n || req.url ~ \"^\/report\/?$\"\n || req.url ~ \"^\/search\/?$\"\n || req.url ~ \"^\/submit\/?$\"\n || req.url ~ \"^\/submit_to_community\/?$\"\n || req.url ~ \"^\/u\/\"\n || req.url ~ \"^\/user\/\"\n || req.url ~ \"^\/vote\/\"\n || req.url ~ \"^\/(help|w|wiki)\/?\"\n # Whitelisted 2X Ajax endpoints\n || req.url ~ \"^\/csp-report$\"\n || req.url == \"\/error\"\n || req.url ~ \"^\/(login|refresh|register)proxy$\"\n || req.url ~ \"^\/logout\"\n || req.url == \"\/routes\"\n || req.url ~ \"^\/timings$\"\n || req.url ~ \"^\/(u\/)?XXX\\?.*\"\n # Whitelisted dev endpoints (these will be hosted on www in production)\n || req.url == \"\/apple-app-site-association\"\n || req.url ~ \"^\/favicon\/\"\n || req.url ~ \"^\/favicon\\.ico\"\n || req.url ~ \"^\/fonts\/\"\n || req.url == \"\/health\"\n || req.url ~ \"^\/img\/\"\n || req.url ~ \"^\/ProductionClient\\..*\\.(css|js)$\"\n || req.url == \"\/robots.txt\"\n )) {\n # If it's a mobile device and a whitelisted endpoint, use mweb.\n set req.backend = mweb;\n } else {\n call set_www_backend;\n }\n}\n\n\nsub set_www_backend {\n # NOTE(wting|2016-09-26): Normally we would redirect the user to a different\n # backend, but instead we're using a 400 status code for easy programmatic testing.\n error 400;\n # set req.backend = www;\n}\n\n\n# Vendorized from https:\/\/github.com\/varnish\/varnish-devicedetect\/blob\/master\/devicedetect.vcl\n# BSD-2 License\nsub device_detect {\n unset req.http.X-UA-Device;\n set req.http.X-UA-Device = \"pc\";\n\n # Handle that a cookie may override the detection alltogether.\n if (req.http.Cookie ~ \"(?i)X-UA-Device-force\") {\n \/* ;?? means zero or one ;, non-greedy to match the first. *\/\n set req.http.X-UA-Device = regsub(req.http.Cookie, \"(?i).*X-UA-Device-force=([^;]+);??.*\", \"\\1\");\n \/* Clean up our mess in the cookie header *\/\n set req.http.Cookie = regsuball(req.http.Cookie, \"(^|; ) *X-UA-Device-force=[^;]+;? *\", \"\\1\");\n \/* If the cookie header is now empty, or just whitespace, unset it. *\/\n if (req.http.Cookie ~ \"^ *$\") {\n unset req.http.Cookie;\n }\n } else {\n if (req.http.User-Agent ~ \"\\(compatible; Googlebot-Mobile\/2.1; \\+http:\/\/www.google.com\/bot.html\\)\"\n || (req.http.User-Agent ~ \"(Android|iPhone)\"\n && req.http.User-Agent ~ \"\\(compatible.?; Googlebot\/2.1.?; \\+http:\/\/www.google.com\/bot.html\")\n || (req.http.User-Agent ~ \"(iPhone|Windows Phone)\"\n && req.http.User-Agent ~ \"\\(compatible; bingbot\/2.0; \\+http:\/\/www.bing.com\/bingbot.htm\")\n ) {\n set req.http.X-UA-Device = \"mobile-bot\";\n } elsif (req.http.User-Agent ~ \"(?i)(ads|google|bing|msn|yandex|baidu|ro|career|seznam|)bot\"\n || req.http.User-Agent ~ \"(?i)(baidu|jike|symantec)spider\"\n || req.http.User-Agent ~ \"(?i)scanner\"\n || req.http.User-Agent ~ \"(?i)(web)crawler\"\n ) {\n set req.http.X-UA-Device = \"bot\";\n } elsif (req.http.User-Agent ~ \"(?i)ipad\") {\n set req.http.X-UA-Device = \"tablet-ipad\";\n } elsif (req.http.User-Agent ~ \"(?i)ip(hone|od)\") {\n set req.http.X-UA-Device = \"mobile-iphone\";\n } elsif (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") {\n \/* how do we differ between an android phone and an android tablet? *\/\n \/* http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent *\/\n set req.http.X-UA-Device = \"mobile-android\";\n }\n elsif (req.http.User-Agent ~ \"(?i)android 3\") {\n \/* https:\/\/github.com\/varnish\/varnish-devicedetect\/blob\/master\/devicedetect.vcl *\/\n set req.http.X-UA-Device = \"tablet-android\";\n } elsif (req.http.User-Agent ~ \"Opera Mobi\") {\n \/* Opera Mobile *\/\n set req.http.X-UA-Device = \"mobile-smartphone\";\n }\n elsif (req.http.User-Agent ~ \"(?i)android\") {\n \/* May very well give false positives towards android tablets. Suggestions welcome. *\/\n set req.http.X-UA-Device = \"tablet-android\";\n } elsif (req.http.User-Agent ~ \"PlayBook; U; RIM Tablet\") {\n set req.http.X-UA-Device = \"tablet-rim\";\n } elsif (req.http.User-Agent ~ \"hp-tablet.*TouchPad\") {\n set req.http.X-UA-Device = \"tablet-hp\";\n } elsif (req.http.User-Agent ~ \"Kindle\/3\") {\n set req.http.X-UA-Device = \"tablet-kindle\";\n } elsif (req.http.User-Agent ~ \"Touch.+Tablet PC\" || req.http.User-Agent ~ \"Windows NT [0-9.]+; ARM;\" ) {\n set req.http.X-UA-Device = \"tablet-microsoft\";\n } elsif (req.http.User-Agent ~ \"Mobile.+Firefox\") {\n set req.http.X-UA-Device = \"mobile-firefoxos\";\n } elsif (req.http.User-Agent ~ \"^HTC\"\n || req.http.User-Agent ~ \"Fennec\"\n || req.http.User-Agent ~ \"IEMobile\"\n || req.http.User-Agent ~ \"BlackBerry\"\n || req.http.User-Agent ~ \"BB10.*Mobile\"\n || req.http.User-Agent ~ \"GT-.*Build\/GINGERBREAD\"\n || req.http.User-Agent ~ \"SymbianOS.*AppleWebKit\") {\n set req.http.X-UA-Device = \"mobile-smartphone\";\n }\n elsif (req.http.User-Agent ~ \"(?i)symbian\"\n || req.http.User-Agent ~ \"(?i)^sonyericsson\"\n || req.http.User-Agent ~ \"(?i)^nokia\"\n || req.http.User-Agent ~ \"(?i)^samsung\"\n || req.http.User-Agent ~ \"(?i)^lg\"\n || req.http.User-Agent ~ \"(?i)bada\"\n || req.http.User-Agent ~ \"(?i)blazer\"\n || req.http.User-Agent ~ \"(?i)cellphone\"\n || req.http.User-Agent ~ \"(?i)iemobile\"\n || req.http.User-Agent ~ \"(?i)midp-2.0\"\n || req.http.User-Agent ~ \"(?i)u990\"\n || req.http.User-Agent ~ \"(?i)netfront\"\n || req.http.User-Agent ~ \"(?i)opera mini\"\n || req.http.User-Agent ~ \"(?i)palm\"\n || req.http.User-Agent ~ \"(?i)nintendo wii\"\n || req.http.User-Agent ~ \"(?i)playstation portable\"\n || req.http.User-Agent ~ \"(?i)portalmmm\"\n || req.http.User-Agent ~ \"(?i)proxinet\"\n || req.http.User-Agent ~ \"(?i)sonyericsson\"\n || req.http.User-Agent ~ \"(?i)symbian\"\n || req.http.User-Agent ~ \"(?i)windows\\ ?ce\"\n || req.http.User-Agent ~ \"(?i)winwap\"\n || req.http.User-Agent ~ \"(?i)eudoraweb\"\n || req.http.User-Agent ~ \"(?i)htc\"\n || req.http.User-Agent ~ \"(?i)240x320\"\n || req.http.User-Agent ~ \"(?i)avantgo\") {\n set req.http.X-UA-Device = \"mobile-generic\";\n }\n }\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"837a4342d778e61234a143178acb6f8efc64400c","subject":"We were jumping to vcl_error in maintenance mode ignoring the custom error\/maint page","message":"We were jumping to vcl_error in maintenance mode ignoring the custom error\/maint page\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets\/recv.vcl","new_file":"etc\/vcl_snippets\/recv.vcl","new_contents":" # VCL required to support maintenance mode. Don't maintenance mode admin pages and supporting assets\n if (table.lookup(magentomodule_config, \"allow_super_users_during_maint\", \"0\") == \"1\" &&\n !req.http.Fastly-Client-Ip ~ maint_allowlist &&\n !req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" &&\n !req.url ~ \"^\/pub\/static\/\") {\n\n # If we end up here after a restart and there is a ResponseObject it means we got here after error\n # page VCL restart. We shouldn't touch it. Otherwise return a plain 503 error page\n if ( req.restarts > 0 && req.http.ResponseObject ) {\n set req.http.ResponseObject = \"970\";\n } else {\n error 503 \"Maintenance mode\";\n }\n }\n\n # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n unset req.http.x-long-cache;\n\n # We want to force long cache times on any of the versioned assets\n if (req.url.path ~ \"^\/static\/version\\d*\/\") {\n set req.http.x-long-cache = \"1\";\n }\n \n # User's Cookie may contain some Magento Vary items we should vary on\n if (req.http.cookie:X-Magento-Vary ) {\n set req.http.X-Magento-Vary = req.http.cookie:X-Magento-Vary;\n } else {\n unset req.http.X-Magento-Vary;\n }\n\n ############################################################################################################\n # Following code block controls purge by URL. By default we want to protect all URL purges. In general this\n # is addressed by adding Fastly-Purge-Requires-Auth request header in vcl_recv however this runs the risk of\n # exposing API tokens if user attempts to purge non-https URLs. For this reason inside the Magento module\n # we use X-Purge-Token. Unfortunately this breaks purge from the Fastly UI. Therefore in the next code block\n # we check for presence of X-Purge-Token. If it's not present we force the Fastly-Purge-Requires-Auth\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n if (req.http.X-Purge-Token && req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n } else {\n error 403;\n }\n } else {\n set req.http.Fastly-Purge-Requires-Auth = \"1\";\n }\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (req.http.Fastly-FF) {\n # disable ESI processing on Origin Shield\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Make sure we lookup end user geo not shielding. More at https:\/\/docs.fastly.com\/vcl\/geolocation\/#using-geographic-variables-with-shielding\n set client.geo.ip_override = req.http.Fastly-Client-IP;\n\n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie:X-Magento-Vary || req.http.cookie:form_key) {\n error 980 \"GeoIP already processed\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url.qs !~ \"country_code=\" ) {\n set req.url = req.url \"?country_code=\" if ( req.http.geo_override, req.http.geo_override, client.geo.country_code);\n }\n }\n } else {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking by default\n # and allow custom parameters to be set. List of parameters is configurable in admin\n set req.http.Magento-Original-URL = req.url;\n # Change the list of ignored parameters by configuring them in the Advanced section\n set req.url = querystring.regfilter(req.url, \"^(####QUERY_PARAMETERS####)\");\n }\n\n # Don't allow clients to force a pass\n if (req.restarts == 0) {\n unset req.http.x-pass;\n unset req.http.Rate-Limit;\n }\n \n # Pass on checkout URLs. Because it's a snippet we want to execute this after backend selection so we handle it\n # in the request condition\n if (!req.http.x-long-cache && req.url ~ \"\/(catalogsearch|checkout|customer\/section\/load)\") {\n set req.http.x-pass = \"1\";\n # Pass all admin actions\n # ####ADMIN_PATH#### is replaced with value of frontName from app\/etc\/env.php\n } else if ( req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" ) {\n set req.http.x-pass = \"1\";\n } else {\n # Sort the query arguments to increase cache hit ratio with query arguments that\n # may be out od order. In case you want to restore the unsorted URL add a snippet\n # after this one that sets req.url to req.http.Magento-Original-URL\n if ( !req.http.x-pass ) {\n set req.url = boltsort.sort(req.url);\n }\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.http.x-long-cache || req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n","old_contents":" # VCL required to support maintenance mode. Don't maintenance mode admin pages and supporting assets\n if (table.lookup(magentomodule_config, \"allow_super_users_during_maint\", \"0\") == \"1\" &&\n !req.http.Fastly-Client-Ip ~ maint_allowlist &&\n !req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" &&\n !req.url ~ \"^\/pub\/static\/\") {\n error 503 \"Maintenance mode\";\n }\n\n # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n unset req.http.x-long-cache;\n\n # We want to force long cache times on any of the versioned assets\n if (req.url.path ~ \"^\/static\/version\\d*\/\") {\n set req.http.x-long-cache = \"1\";\n }\n \n # User's Cookie may contain some Magento Vary items we should vary on\n if (req.http.cookie:X-Magento-Vary ) {\n set req.http.X-Magento-Vary = req.http.cookie:X-Magento-Vary;\n } else {\n unset req.http.X-Magento-Vary;\n }\n\n ############################################################################################################\n # Following code block controls purge by URL. By default we want to protect all URL purges. In general this\n # is addressed by adding Fastly-Purge-Requires-Auth request header in vcl_recv however this runs the risk of\n # exposing API tokens if user attempts to purge non-https URLs. For this reason inside the Magento module\n # we use X-Purge-Token. Unfortunately this breaks purge from the Fastly UI. Therefore in the next code block\n # we check for presence of X-Purge-Token. If it's not present we force the Fastly-Purge-Requires-Auth\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n if (req.http.X-Purge-Token && req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n } else {\n error 403;\n }\n } else {\n set req.http.Fastly-Purge-Requires-Auth = \"1\";\n }\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (req.http.Fastly-FF) {\n # disable ESI processing on Origin Shield\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Make sure we lookup end user geo not shielding. More at https:\/\/docs.fastly.com\/vcl\/geolocation\/#using-geographic-variables-with-shielding\n set client.geo.ip_override = req.http.Fastly-Client-IP;\n\n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie:X-Magento-Vary || req.http.cookie:form_key) {\n error 980 \"GeoIP already processed\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url.qs !~ \"country_code=\" ) {\n set req.url = req.url \"?country_code=\" if ( req.http.geo_override, req.http.geo_override, client.geo.country_code);\n }\n }\n } else {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking by default\n # and allow custom parameters to be set. List of parameters is configurable in admin\n set req.http.Magento-Original-URL = req.url;\n # Change the list of ignored parameters by configuring them in the Advanced section\n set req.url = querystring.regfilter(req.url, \"^(####QUERY_PARAMETERS####)\");\n }\n\n # Don't allow clients to force a pass\n if (req.restarts == 0) {\n unset req.http.x-pass;\n unset req.http.Rate-Limit;\n }\n \n # Pass on checkout URLs. Because it's a snippet we want to execute this after backend selection so we handle it\n # in the request condition\n if (!req.http.x-long-cache && req.url ~ \"\/(catalogsearch|checkout|customer\/section\/load)\") {\n set req.http.x-pass = \"1\";\n # Pass all admin actions\n # ####ADMIN_PATH#### is replaced with value of frontName from app\/etc\/env.php\n } else if ( req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" ) {\n set req.http.x-pass = \"1\";\n } else {\n # Sort the query arguments to increase cache hit ratio with query arguments that\n # may be out od order. In case you want to restore the unsorted URL add a snippet\n # after this one that sets req.url to req.http.Magento-Original-URL\n if ( !req.http.x-pass ) {\n set req.url = boltsort.sort(req.url);\n }\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.http.x-long-cache || req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"a3118ae566af5b96adc1aa8a84ab82a58a8decd5","subject":"Attempt to fix varnish cache.","message":"Attempt to fix varnish cache.\n","repos":"hummingbird-me\/ansible-deploy","old_file":"roles\/varnish\/templates\/default.vcl","new_file":"roles\/varnish\/templates\/default.vcl","new_contents":"backend s3 {\n .host = \"s3.amazonaws.com\";\n .port = \"80\";\n}\n\nbackend s3forum {\n .host = \"s3.amazonaws.com\";\n .port = \"80\";\n}\n\nsub vcl_recv {\n unset req.http.cookie;\n unset req.http.cache-control;\n unset req.http.pragma;\n unset req.http.expires;\n unset req.http.etag;\n unset req.http.X-Forwarded-For;\n\n if (req.http.host == \"{{varnish_host}}\") {\n set req.backend = s3;\n set req.http.host = \"{{aws_bucket}}.s3.amazonaws.com\";\n return (lookup);\n }\n if (req.http.host == \"{{forum_varnish_host}}\") {\n set req.backend = s3forum;\n set req.http.host = \"{{forum_aws_bucket}}.s3.amazonaws.com\";\n return (lookup);\n }\n}\n\nsub vcl_fetch {\n unset beresp.http.X-Amz-Id-2;\n unset beresp.http.X-Amz-Meta-Group;\n unset beresp.http.X-Amz-Meta-Owner;\n unset beresp.http.X-Amz-Meta-Permissions;\n unset beresp.http.X-Amz-Request-Id;\n unset beresp.http.expires;\n\n set beresp.ttl = 1w;\n set beresp.grace = 30s;\n set beresp.http.cache-control = \"max-age=2592000\";\n}\n\n#\n# Below is a commented-out copy of the default VCL logic. If you\n# redefine any of these subroutines, the built-in logic will be\n# appended to your code.\n# sub vcl_recv {\n# if (req.restarts == 0) {\n# \tif (req.http.x-forwarded-for) {\n# \t set req.http.X-Forwarded-For =\n# \t\treq.http.X-Forwarded-For + \", \" + client.ip;\n# \t} else {\n# \t set req.http.X-Forwarded-For = client.ip;\n# \t}\n# }\n# if (req.request != \"GET\" &&\n# req.request != \"HEAD\" &&\n# req.request != \"PUT\" &&\n# req.request != \"POST\" &&\n# req.request != \"TRACE\" &&\n# req.request != \"OPTIONS\" &&\n# req.request != \"DELETE\") {\n# \/* Non-RFC2616 or CONNECT which is weird. *\/\n# return (pipe);\n# }\n# if (req.request != \"GET\" && req.request != \"HEAD\") {\n# \/* We only deal with GET and HEAD by default *\/\n# return (pass);\n# }\n# if (req.http.Authorization || req.http.Cookie) {\n# \/* Not cacheable by default *\/\n# return (pass);\n# }\n# return (lookup);\n# }\n#\n# sub vcl_pipe {\n# # Note that only the first request to the backend will have\n# # X-Forwarded-For set. If you use X-Forwarded-For and want to\n# # have it set for all requests, make sure to have:\n# # set bereq.http.connection = \"close\";\n# # here. It is not set by default as it might break some broken web\n# # applications, like IIS with NTLM authentication.\n# return (pipe);\n# }\n#\n# sub vcl_pass {\n# return (pass);\n# }\n#\n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (hash);\n# }\n#\n# sub vcl_hit {\n# return (deliver);\n# }\n#\n# sub vcl_miss {\n# return (fetch);\n# }\n#\n# sub vcl_fetch {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Vary == \"*\") {\n# \t\t\/*\n# \t\t * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# \t\t *\/\n# \t\tset beresp.ttl = 120 s;\n# \t\treturn (hit_for_pass);\n# }\n# return (deliver);\n# }\n#\n# sub vcl_deliver {\n# return (deliver);\n# }\n#\n# sub vcl_error {\n# set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n# set obj.http.Retry-After = \"5\";\n# synthetic {\"\n# <?xml version=\"1.0\" encoding=\"utf-8\"?>\n# <!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n# \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n# <html>\n# <head>\n# <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n# <\/head>\n# <body>\n# <h1>Error \"} + obj.status + \" \" + obj.response + {\"<\/h1>\n# <p>\"} + obj.response + {\"<\/p>\n# <h3>Guru Meditation:<\/h3>\n# <p>XID: \"} + req.xid + {\"<\/p>\n# <hr>\n# <p>Varnish cache server<\/p>\n# <\/body>\n# <\/html>\n# \"};\n# return (deliver);\n# }\n#\n# sub vcl_init {\n# \treturn (ok);\n# }\n#\n# sub vcl_fini {\n# \treturn (ok);\n# }\n","old_contents":"backend s3 {\n .host = \"{{aws_bucket}}.s3.amazonaws.com\";\n .port = \"80\";\n}\n\nbackend s3forum {\n .host = \"{{forum_aws_bucket}}.s3.amazonaws.com\";\n .port = \"80\";\n}\n\nsub vcl_recv {\n unset req.http.cookie;\n unset req.http.cache-control;\n unset req.http.pragma;\n unset req.http.expires;\n unset req.http.etag;\n unset req.http.X-Forwarded-For;\n\n if (req.http.host == \"{{varnish_host}}\") {\n set req.backend = s3;\n set req.http.host = \"{{aws_bucket}}.s3.amazonaws.com\";\n return (lookup);\n }\n if (req.http.host == \"{{forum_varnish_host}}\") {\n set req.backend = s3forum;\n set req.http.host = \"{{forum_aws_bucket}}.s3.amazonaws.com\";\n return (lookup);\n }\n}\n\nsub vcl_fetch {\n unset beresp.http.X-Amz-Id-2;\n unset beresp.http.X-Amz-Meta-Group;\n unset beresp.http.X-Amz-Meta-Owner;\n unset beresp.http.X-Amz-Meta-Permissions;\n unset beresp.http.X-Amz-Request-Id;\n unset beresp.http.expires;\n\n set beresp.ttl = 1w;\n set beresp.grace = 30s;\n set beresp.http.cache-control = \"max-age=2592000\";\n}\n\n#\n# Below is a commented-out copy of the default VCL logic. If you\n# redefine any of these subroutines, the built-in logic will be\n# appended to your code.\n# sub vcl_recv {\n# if (req.restarts == 0) {\n# \tif (req.http.x-forwarded-for) {\n# \t set req.http.X-Forwarded-For =\n# \t\treq.http.X-Forwarded-For + \", \" + client.ip;\n# \t} else {\n# \t set req.http.X-Forwarded-For = client.ip;\n# \t}\n# }\n# if (req.request != \"GET\" &&\n# req.request != \"HEAD\" &&\n# req.request != \"PUT\" &&\n# req.request != \"POST\" &&\n# req.request != \"TRACE\" &&\n# req.request != \"OPTIONS\" &&\n# req.request != \"DELETE\") {\n# \/* Non-RFC2616 or CONNECT which is weird. *\/\n# return (pipe);\n# }\n# if (req.request != \"GET\" && req.request != \"HEAD\") {\n# \/* We only deal with GET and HEAD by default *\/\n# return (pass);\n# }\n# if (req.http.Authorization || req.http.Cookie) {\n# \/* Not cacheable by default *\/\n# return (pass);\n# }\n# return (lookup);\n# }\n#\n# sub vcl_pipe {\n# # Note that only the first request to the backend will have\n# # X-Forwarded-For set. If you use X-Forwarded-For and want to\n# # have it set for all requests, make sure to have:\n# # set bereq.http.connection = \"close\";\n# # here. It is not set by default as it might break some broken web\n# # applications, like IIS with NTLM authentication.\n# return (pipe);\n# }\n#\n# sub vcl_pass {\n# return (pass);\n# }\n#\n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (hash);\n# }\n#\n# sub vcl_hit {\n# return (deliver);\n# }\n#\n# sub vcl_miss {\n# return (fetch);\n# }\n#\n# sub vcl_fetch {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Vary == \"*\") {\n# \t\t\/*\n# \t\t * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# \t\t *\/\n# \t\tset beresp.ttl = 120 s;\n# \t\treturn (hit_for_pass);\n# }\n# return (deliver);\n# }\n#\n# sub vcl_deliver {\n# return (deliver);\n# }\n#\n# sub vcl_error {\n# set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n# set obj.http.Retry-After = \"5\";\n# synthetic {\"\n# <?xml version=\"1.0\" encoding=\"utf-8\"?>\n# <!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n# \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n# <html>\n# <head>\n# <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n# <\/head>\n# <body>\n# <h1>Error \"} + obj.status + \" \" + obj.response + {\"<\/h1>\n# <p>\"} + obj.response + {\"<\/p>\n# <h3>Guru Meditation:<\/h3>\n# <p>XID: \"} + req.xid + {\"<\/p>\n# <hr>\n# <p>Varnish cache server<\/p>\n# <\/body>\n# <\/html>\n# \"};\n# return (deliver);\n# }\n#\n# sub vcl_init {\n# \treturn (ok);\n# }\n#\n# sub vcl_fini {\n# \treturn (ok);\n# }\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"2ecfa8eedeb647ab9750e27cd15860219ebd5e0d","subject":"303, 307, and 308 should be cached by Fastly","message":"303, 307, and 308 should be cached by Fastly\n","repos":"dstufft\/warehouse,karan\/warehouse,dstufft\/warehouse,pypa\/warehouse,alex\/warehouse,dstufft\/warehouse,wlonk\/warehouse,wlonk\/warehouse,pypa\/warehouse,alex\/warehouse,alex\/warehouse,alex\/warehouse,pypa\/warehouse,karan\/warehouse,karan\/warehouse,dstufft\/warehouse,wlonk\/warehouse,karan\/warehouse,alex\/warehouse,pypa\/warehouse,karan\/warehouse","old_file":"vcl\/main.vcl","new_file":"vcl\/main.vcl","new_contents":"\nsub vcl_recv {\n\n # I'm not 100% sure on what this is exactly for, it was taken from the\n # Fastly documentation, however, what I *believe* it does is just ensure\n # that we don't serve a stale copy of the page from the shield node when\n # an edge node is requesting content.\n if (req.http.Fastly-FF) {\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Some (Older) clients will send a hash fragment as part of the URL even\n # though that is a local only modification. This breaks this badly for the\n # files in S3, and in general it's just not needed.\n set req.url = regsub(req.url, \"#.*$\", \"\");\n\n # Most of the URLs in Warehouse do not support or require any sort of query\n # parameter. If we strip these at the edge then we'll increase our cache\n # efficiency when they won't otherwise change the output of the pages.\n #\n # This will match any URL except those that start with:\n #\n # * \/search\/\n # * \/account\/login\/\n # * \/account\/logout\/\n # * \/account\/register\/\n # * \/pypi\n if (req.url !~ \"^\/(search\/|account\/(login|logout|register)\/|pypi)\") {\n set req.url = req.url.path;\n }\n\n # Sort all of our query parameters, this will ensure that the same query\n # parameters in a different order will end up being represented as the same\n # thing, reducing cache misses due to ordering differences.\n set req.url = boltsort.sort(req.url);\n\n\n#FASTLY recv\n\n\n # We want to Force SSL for the WebUI by redirecting to the HTTPS version of\n # the page, however for API calls we want to return an error code directing\n # people to instead use HTTPS.\n if (!req.http.Fastly-SSL) {\n\n # The \/simple\/ and \/packages\/ API.\n if (req.url ~ \"^\/(simple|packages)\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy JSON API.\n if (req.url ~ \"^\/pypi\/.+\/json$\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy ?:action= API.\n if (req.url ~ \"^\/pypi.*(\\?|&)=:action\") {\n error 803 \"SSL is required\";\n }\n\n # If we're on the \/pypi page and we've received something other than a\n # GET or HEAD request, then we have no way to determine if a particular\n # request is an API call or not because it'll be in the request body\n # and that isn't available to us here. So in those cases, we won't\n # do a redirect.\n if (req.url ~ \"^\/pypi\") {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n error 801 \"Force SSL\";\n }\n }\n else {\n # This isn't a \/pypi URL so we'll just unconditionally redirect to\n # HTTPS.\n error 801 \"Force SSL\";\n }\n }\n\n # Canonicalize our domains by redirecting any domain that doesn't match our\n # primary domain to our primary domain. We do this *after* the HTTPS check\n # on purpose.\n if (std.tolower(req.http.host) != std.tolower(req.http.Primary-Domain)) {\n set req.http.Location = \"https:\/\/\" req.http.Primary-Domain req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n\n # Requests to \/packages\/ get dispatched to Amazon instead of to our typical\n # Origin. This requires a a bit of setup to make it work.\n if (req.url ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\") {\n # Setup our environment to better match what S3 expects\/needs\n set req.http.Host = req.http.AWS-Bucket-Name \".s3.amazonaws.com\";\n set req.http.Date = now;\n set req.url = regsuball(req.url, \"\\+\", urlencode(\"+\"));\n\n # Compute the Authorization header that S3 requires to be able to\n # access the files stored there.\n set req.http.Authorization = \"AWS \" req.http.AWS-Access-Key-ID \":\" digest.hmac_sha1_base64(req.http.AWS-Secret-Access-Key, \"GET\" LF LF LF req.http.Date LF \"\/\" req.http.AWS-Bucket-Name req.url.path);\n\n # We don't want to send our Warehouse-Token to S3, so we'll go ahead\n # and remove it.\n unset req.http.Warehouse-Token;\n }\n\n # We no longer need any of these variables, which would exist only to\n # shuffle configuration from the Fastly UI into our VCL.\n unset req.http.Primary-Domain;\n unset req.http.AWS-Access-Key-ID;\n unset req.http.AWS-Secret-Access-Key;\n unset req.http.AWS-Bucket-Name;\n\n # We have a number of items that we'll pass back to the origin, but only\n # if we have a Warehouse-Token that will allow them to be accepted.\n if (req.http.Warehouse-Token) {\n # Set a header to tell the backend if we're using https or http.\n if (req.http.Fastly-SSL) {\n set req.http.Warehouse-Proto = \"https\";\n } else {\n set req.http.Warehouse-Proto = \"http\";\n }\n\n # Pass the client IP address back to the backend.\n if (req.http.Fastly-Client-IP) {\n set req.http.Warehouse-IP = req.http.Fastly-Client-IP;\n }\n\n # Pass the real host value back to the backend.\n if (req.http.Host) {\n set req.http.Warehouse-Host = req.http.Host;\n }\n }\n\n # On a POST, we want to skip the shielding and hit backends directly.\n if (req.request == \"POST\") {\n set req.backend = F_Heroku;\n }\n\n # Do not bother to attempt to run the caching mechanisms for methods that\n # are not generally safe to cache.\n if (req.request != \"HEAD\" &&\n req.request != \"GET\" &&\n req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n # We don't ever want to cache our health URL. Outside systems should be\n # able to use it to reach past Fastly and get an end to end health check.\n if (req.url == \"\/_health\/\") {\n return(pass);\n }\n\n # Finally, return the default lookup action.\n return(lookup);\n}\n\n\nsub vcl_fetch {\n\n # These are newer kinds of redirects which should be able to be cached by\n # default, even though Fastly doesn't currently have them in their default\n # list of cacheable status codes.\n if (http_status_matches(beresp.status, \"303,307,308\")) {\n set beresp.cacheable = true;\n }\n\n # For any 5xx status code we want to see if a stale object exists for it,\n # if so we'll go ahead and serve it.\n if (beresp.status >= 500 && beresp.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n\n#FASTLY fetch\n\n\n # Trigger a \"SSL is required\" error if the backend has indicated to do so.\n if (beresp.http.X-Fastly-Error == \"803\") {\n error 803 \"SSL is required\";\n }\n\n # If we've gotten a 502 or a 503 from the backend, we'll go ahead and retry\n # the request.\n if ((beresp.status == 502 || beresp.status == 503) &&\n req.restarts < 1 &&\n (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n # If we've restarted, then we'll record the number of restarts.\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n # If there is a Set-Cookie header, we'll ensure that we do not cache the\n # response.\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n # If the response has the private Cache-Control directive then we won't\n # cache it.\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # If we've gotten an error after the restarts we'll deliver the response\n # with a very short cache time.\n if (http_status_matches(beresp.status, \"500,502,503\")) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n # Apply a default TTL if there isn't a max-age or s-maxage.\n if (beresp.http.Expires ||\n beresp.http.Surrogate-Control ~ \"max-age\" ||\n beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # Keep the ttl here\n }\n else {\n # Apply the default ttl\n set beresp.ttl = 60s;\n }\n\n # Actually deliver the fetched response.\n return(deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n # If the object we have isn't cacheable, then just serve it directly\n # without going through any of the caching mechanisms.\n if (!obj.cacheable) {\n return(pass);\n }\n\n return(deliver);\n}\n\n\nsub vcl_deliver {\n # If this is an error and we have a stale response available, restart so\n # that we can pick it up and serve it.\n if (resp.status >= 500 && resp.status < 600) {\n if (stale.exists) {\n restart;\n }\n }\n\n#FASTLY deliver\n\n # Unset headers that we don't need\/want to send on to the client because\n # they are not generally useful.\n unset resp.http.Server;\n unset resp.http.Via;\n\n # Unset a few headers set by Amazon that we don't really have a need\/desire\n # to send to clients.\n unset resp.http.X-AMZ-Replication-Status;\n unset resp.http.X-AMZ-Meta-Python-Version;\n unset resp.http.X-AMZ-Meta-Version;\n unset resp.http.X-AMZ-Meta-Package-Type;\n unset resp.http.X-AMZ-Meta-Project;\n\n # Set our standard security headers, we do this in VCL rather than in\n # Warehouse itself so that we always get these headers, regardless of the\n # origin server being used.\n set resp.http.Strict-Transport-Security = \"max-age=31536000; includeSubDomains; preload\";\n set resp.http.X-Frame-Options = \"deny\";\n set resp.http.X-XSS-Protection = \"1; mode=block\";\n set resp.http.X-Content-Type-Options = \"nosniff\";\n set resp.http.X-Permitted-Cross-Domain-Policies = \"none\";\n\n return(deliver);\n}\n\n\nsub vcl_error {\n#FASTLY error\n\n # If we have a 5xx error and there is a stale object available, then we\n # will deliver that stale object.\n if (obj.status >= 500 && obj.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n if (obj.status == 803) {\n set obj.status = 403;\n set obj.response = \"SSL is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic {\"SSL is required.\"};\n return (deliver);\n } else if (obj.status == 750) {\n set obj.status = 301;\n set obj.http.Location = req.http.Location;\n set obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n synthetic {\"<html><head><title>301 Moved Permanently<\/title><\/head><body><center><h1>301 Moved Permanently<\/h1><\/center><\/body><\/html>\"};\n return(deliver);\n }\n\n}\n","old_contents":"\nsub vcl_recv {\n\n # I'm not 100% sure on what this is exactly for, it was taken from the\n # Fastly documentation, however, what I *believe* it does is just ensure\n # that we don't serve a stale copy of the page from the shield node when\n # an edge node is requesting content.\n if (req.http.Fastly-FF) {\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Some (Older) clients will send a hash fragment as part of the URL even\n # though that is a local only modification. This breaks this badly for the\n # files in S3, and in general it's just not needed.\n set req.url = regsub(req.url, \"#.*$\", \"\");\n\n # Most of the URLs in Warehouse do not support or require any sort of query\n # parameter. If we strip these at the edge then we'll increase our cache\n # efficiency when they won't otherwise change the output of the pages.\n #\n # This will match any URL except those that start with:\n #\n # * \/search\/\n # * \/account\/login\/\n # * \/account\/logout\/\n # * \/account\/register\/\n # * \/pypi\n if (req.url !~ \"^\/(search\/|account\/(login|logout|register)\/|pypi)\") {\n set req.url = req.url.path;\n }\n\n # Sort all of our query parameters, this will ensure that the same query\n # parameters in a different order will end up being represented as the same\n # thing, reducing cache misses due to ordering differences.\n set req.url = boltsort.sort(req.url);\n\n\n#FASTLY recv\n\n\n # We want to Force SSL for the WebUI by redirecting to the HTTPS version of\n # the page, however for API calls we want to return an error code directing\n # people to instead use HTTPS.\n if (!req.http.Fastly-SSL) {\n\n # The \/simple\/ and \/packages\/ API.\n if (req.url ~ \"^\/(simple|packages)\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy JSON API.\n if (req.url ~ \"^\/pypi\/.+\/json$\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy ?:action= API.\n if (req.url ~ \"^\/pypi.*(\\?|&)=:action\") {\n error 803 \"SSL is required\";\n }\n\n # If we're on the \/pypi page and we've received something other than a\n # GET or HEAD request, then we have no way to determine if a particular\n # request is an API call or not because it'll be in the request body\n # and that isn't available to us here. So in those cases, we won't\n # do a redirect.\n if (req.url ~ \"^\/pypi\") {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n error 801 \"Force SSL\";\n }\n }\n else {\n # This isn't a \/pypi URL so we'll just unconditionally redirect to\n # HTTPS.\n error 801 \"Force SSL\";\n }\n }\n\n # Canonicalize our domains by redirecting any domain that doesn't match our\n # primary domain to our primary domain. We do this *after* the HTTPS check\n # on purpose.\n if (std.tolower(req.http.host) != std.tolower(req.http.Primary-Domain)) {\n set req.http.Location = \"https:\/\/\" req.http.Primary-Domain req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n\n # Requests to \/packages\/ get dispatched to Amazon instead of to our typical\n # Origin. This requires a a bit of setup to make it work.\n if (req.url ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\") {\n # Setup our environment to better match what S3 expects\/needs\n set req.http.Host = req.http.AWS-Bucket-Name \".s3.amazonaws.com\";\n set req.http.Date = now;\n set req.url = regsuball(req.url, \"\\+\", urlencode(\"+\"));\n\n # Compute the Authorization header that S3 requires to be able to\n # access the files stored there.\n set req.http.Authorization = \"AWS \" req.http.AWS-Access-Key-ID \":\" digest.hmac_sha1_base64(req.http.AWS-Secret-Access-Key, \"GET\" LF LF LF req.http.Date LF \"\/\" req.http.AWS-Bucket-Name req.url.path);\n\n # We don't want to send our Warehouse-Token to S3, so we'll go ahead\n # and remove it.\n unset req.http.Warehouse-Token;\n }\n\n # We no longer need any of these variables, which would exist only to\n # shuffle configuration from the Fastly UI into our VCL.\n unset req.http.Primary-Domain;\n unset req.http.AWS-Access-Key-ID;\n unset req.http.AWS-Secret-Access-Key;\n unset req.http.AWS-Bucket-Name;\n\n # We have a number of items that we'll pass back to the origin, but only\n # if we have a Warehouse-Token that will allow them to be accepted.\n if (req.http.Warehouse-Token) {\n # Set a header to tell the backend if we're using https or http.\n if (req.http.Fastly-SSL) {\n set req.http.Warehouse-Proto = \"https\";\n } else {\n set req.http.Warehouse-Proto = \"http\";\n }\n\n # Pass the client IP address back to the backend.\n if (req.http.Fastly-Client-IP) {\n set req.http.Warehouse-IP = req.http.Fastly-Client-IP;\n }\n\n # Pass the real host value back to the backend.\n if (req.http.Host) {\n set req.http.Warehouse-Host = req.http.Host;\n }\n }\n\n # On a POST, we want to skip the shielding and hit backends directly.\n if (req.request == \"POST\") {\n set req.backend = F_Heroku;\n }\n\n # Do not bother to attempt to run the caching mechanisms for methods that\n # are not generally safe to cache.\n if (req.request != \"HEAD\" &&\n req.request != \"GET\" &&\n req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n # We don't ever want to cache our health URL. Outside systems should be\n # able to use it to reach past Fastly and get an end to end health check.\n if (req.url == \"\/_health\/\") {\n return(pass);\n }\n\n # Finally, return the default lookup action.\n return(lookup);\n}\n\n\nsub vcl_fetch {\n\n # For any 5xx status code we want to see if a stale object exists for it,\n # if so we'll go ahead and serve it.\n if (beresp.status >= 500 && beresp.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n\n#FASTLY fetch\n\n\n # Trigger a \"SSL is required\" error if the backend has indicated to do so.\n if (beresp.http.X-Fastly-Error == \"803\") {\n error 803 \"SSL is required\";\n }\n\n # If we've gotten a 502 or a 503 from the backend, we'll go ahead and retry\n # the request.\n if ((beresp.status == 502 || beresp.status == 503) &&\n req.restarts < 1 &&\n (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n # If we've restarted, then we'll record the number of restarts.\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n # If there is a Set-Cookie header, we'll ensure that we do not cache the\n # response.\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n # If the response has the private Cache-Control directive then we won't\n # cache it.\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # If we've gotten an error after the restarts we'll deliver the response\n # with a very short cache time.\n if (http_status_matches(beresp.status, \"500,502,503\")) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n # Apply a default TTL if there isn't a max-age or s-maxage.\n if (beresp.http.Expires ||\n beresp.http.Surrogate-Control ~ \"max-age\" ||\n beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # Keep the ttl here\n }\n else {\n # Apply the default ttl\n set beresp.ttl = 60s;\n }\n\n # Actually deliver the fetched response.\n return(deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n # If the object we have isn't cacheable, then just serve it directly\n # without going through any of the caching mechanisms.\n if (!obj.cacheable) {\n return(pass);\n }\n\n return(deliver);\n}\n\n\nsub vcl_deliver {\n # If this is an error and we have a stale response available, restart so\n # that we can pick it up and serve it.\n if (resp.status >= 500 && resp.status < 600) {\n if (stale.exists) {\n restart;\n }\n }\n\n#FASTLY deliver\n\n # Unset headers that we don't need\/want to send on to the client because\n # they are not generally useful.\n unset resp.http.Server;\n unset resp.http.Via;\n\n # Unset a few headers set by Amazon that we don't really have a need\/desire\n # to send to clients.\n unset resp.http.X-AMZ-Replication-Status;\n unset resp.http.X-AMZ-Meta-Python-Version;\n unset resp.http.X-AMZ-Meta-Version;\n unset resp.http.X-AMZ-Meta-Package-Type;\n unset resp.http.X-AMZ-Meta-Project;\n\n # Set our standard security headers, we do this in VCL rather than in\n # Warehouse itself so that we always get these headers, regardless of the\n # origin server being used.\n set resp.http.Strict-Transport-Security = \"max-age=31536000; includeSubDomains; preload\";\n set resp.http.X-Frame-Options = \"deny\";\n set resp.http.X-XSS-Protection = \"1; mode=block\";\n set resp.http.X-Content-Type-Options = \"nosniff\";\n set resp.http.X-Permitted-Cross-Domain-Policies = \"none\";\n\n return(deliver);\n}\n\n\nsub vcl_error {\n#FASTLY error\n\n # If we have a 5xx error and there is a stale object available, then we\n # will deliver that stale object.\n if (obj.status >= 500 && obj.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n if (obj.status == 803) {\n set obj.status = 403;\n set obj.response = \"SSL is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic {\"SSL is required.\"};\n return (deliver);\n } else if (obj.status == 750) {\n set obj.status = 301;\n set obj.http.Location = req.http.Location;\n set obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n synthetic {\"<html><head><title>301 Moved Permanently<\/title><\/head><body><center><h1>301 Moved Permanently<\/h1><\/center><\/body><\/html>\"};\n return(deliver);\n }\n\n}\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"33784c6481882972e292194c882115968400f2fa","subject":"Formatting","message":"Formatting\n","repos":"rhargreaves\/fastly-vcl-experiments,rhargreaves\/fastly-vcl-experiments","old_file":"99_bottles.vcl","new_file":"99_bottles.vcl","new_contents":"backend F_fake_backend {\n\t.host = \"example.com\";\n\t.port = \"80\";\n\t.dynamic = true;\n\t.connect_timeout = 5s;\n\t.first_byte_timeout = 15s;\n\t.probe = {\n\t\t.dummy = true;\n\t}\n}\n\nsub vcl_recv {\n#FASTLY recv\n\tset req.backend = F_fake_backend;\n\n\tset req.http.X-Bottle = if(req.url ~ \"(?i)bottle=([^&]*)\", urldecode(re.group.1), \"99\");\n\n\tcall set_next_bottle;\n\n\tset req.http.X-Verse = if(req.http.X-Verse,req.http.X-Verse,\"\") req.http.X-Bottle {\" bottles of beer on the wall, \"} req.http.X-Bottle {\" bottles of beer.\nTake one down and pass it around, \"} req.http.X-Next-Bottle {\" bottles of beer on the wall.\n\"};\n\n\tif(req.http.X-Bottle == \"0\") {\n\t\terror 996;\n\t}\n\treturn(lookup);\n}\n\nsub vcl_fetch {\n#FASTLY fetch\n\n\tif(req.restarts > 0) {\n\t\tset beresp.http.Fastly-Restarts = req.restarts;\n\t}\n\treturn(deliver);\n}\n\nsub vcl_deliver {\n#FASTLY deliver\n\tset resp.http.X-Verse = req.http.X-Verse;\n\tset resp.http.X-Bottle = req.http.X-Bottle;\n\tset resp.http.X-Next-Bottle = req.http.X-Next-Bottle;\n\n\tif(req.restarts == 2) {\n\t\t# For now, limit to 3 bottles as we can only restart 3 times\n\t\tset req.http.X-Next-Bottle = \"0\";\n\t}\n\n\tset req.url = \"\/?bottle=\" req.http.X-Next-Bottle;\n\n\tif(req.restarts < 3) {\n\t\trestart;\n\t}\n\treturn(deliver);\n}\n\nsub set_next_bottle {\n\tset req.grace = 1d;\n\tset req.http.X-Original-Grace = req.grace;\n\tset req.grace = std.atoi(req.http.X-Bottle);\n\tset req.grace -= 1s;\n\tset req.http.X-Next-Bottle = regsub(req.grace, \"\\..*\", \"\");\n\tset req.grace = std.atoi(req.http.X-Original-Grace);\n}\n\nsub vcl_error {\n#FASTLY error\n\tif(obj.status == 996) {\n\t\tset obj.status = 200;\n\t\tset obj.response = \"Cheers!\";\n\t\tsynthetic req.http.X-Verse;\n\t\treturn (deliver);\n\t}\n}\n","old_contents":"backend F_fake_backend {\n\t.host = \"example.com\";\n\t.port = \"80\";\n\t.dynamic = true;\n\t.connect_timeout = 5s;\n\t.first_byte_timeout = 15s;\n\t.probe = {\n\t\t.dummy = true;\n\t}\n}\n\nsub vcl_recv {\n#FASTLY recv\n\tset req.backend = F_fake_backend;\n\n\tset req.http.X-Bottle = if(req.url ~ \"(?i)bottle=([^&]*)\", urldecode(re.group.1), \"99\");\n\tset req.http.X-Wall = if(req.http.X-Wall, req.http.X-Wall \" \", \"\") req.http.X-Bottle;\n\n\tcall set_next_bottle;\n\n\tif(req.http.X-Bottle == \"0\") {\n\t\terror 996;\n\t}\n\treturn(lookup);\n}\n\nsub vcl_fetch {\n#FASTLY fetch\n\n\tif(req.restarts > 0) {\n\t\tset beresp.http.Fastly-Restarts = req.restarts;\n\t}\n\treturn(deliver);\n}\n\nsub vcl_deliver {\n#FASTLY deliver\n\tset resp.http.X-Wall = req.http.X-Wall;\n\n\tif(req.restarts == 2) {\n# For now, limit to 3 bottles as we can only restart 3 times\n\t\tset req.http.X-Next-Bottle = \"0\";\n\t}\n\n\tset req.url = \"\/?bottle=\" req.http.X-Next-Bottle;\n\tif(req.restarts < 2) {\n\t\trestart;\n\t}\n\treturn(deliver);\n}\n\nsub set_next_bottle {\n\tset req.grace = 1d;\n\tset req.http.X-Original-Grace = req.grace;\n\tset req.grace = std.atoi(req.http.X-Bottle);\n\tset req.grace -= 1s;\n\tset req.http.X-Next-Bottle = regsub(req.grace, \"\\..*\", \"\");\n\tset req.grace = std.atoi(req.http.X-Original-Grace);\n}\n\nsub vcl_error {\n#FASTLY error\n\tif(obj.status == 996) {\n\t\tset obj.status = 200;\n\t\tset obj.response = \"Cheers!\";\n\t\tsynthetic req.http.X-Wall;\n\t\treturn (deliver);\n\t}\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"5769de8427b763cb693af942b37455dcbf31a798","subject":"always call the toppops_collect log","message":"always call the toppops_collect log\n","repos":"JakeChampion\/polyfill-service,JakeChampion\/polyfill-service","old_file":"fastly\/vcl\/top_pops.vcl","new_file":"fastly\/vcl\/top_pops.vcl","new_contents":"sub toppops_collect {\n declare local var.dcpattern STRING;\n declare local var.thisdc STRING;\n set var.dcpattern = \",\" regsuball(table.lookup(toppops_config, \"datacenters\"), \"\\s\", \"\") \",\";\n set var.thisdc = \",\" server.datacenter \",\";\n if (std.strstr(var.dcpattern, var.thisdc) && randombool(std.atoi(table.lookup(toppops_config, \"sample_percent\", \"0\")), 100)) {\n log \"syslog \" req.service_id \" toppops-collector :: \"\n server.datacenter \" \"\n time.start.usec \" \"\n time.elapsed.usec \" \"\n if (fastly_info.is_h2, \"1\", \"0\")\n if (req.is_ipv6, \"1\", \"0\")\n if (req.is_ssl, \"1\", \"0\")\n if (fastly_info.state ~ \"^HIT\", \"1\", \"0\") \" \"\n accept.language_lookup(\"aa:ab:ae:af:ak:am:an:ar:as:av:ay:az:ba:be:bg:bh:bi:bm:bn:bo:br:ca:ce:ch:co:cr:cs:cu:cv:cy:da:de:dv:dz:ee:el:en:eo:es:et:eu:fa:ff:fi:fj:fo:fr:fy:ga:gd:gl:gn:gu:gv:ha:he:hi:ho:ht:hu:hy:hz:ia:ie:ig:ii:ik:io:is:it:iu:iw:ja:ji:jv:jw:ka:kg:ki:kj:kk:kl:km:kn:ko:kr:ks:ku:kv:kw:ky:la:lb:lg:li:ln:lo:lt:lu:lv:mg:mh:mi:mk:ml:mn:mo:mr:ms:mt:my:na:nd:ne:ng:nl:no:nr:nv:ny:oc:oj:om:or:os:pa:pi:pl:ps:pt:qu:rm:rn:ro:ru:rw:sa:sc:sd:se:sg:sh:si:sk:sl:sm:sn:so:sq:ss:st:su:sv:sw:ta:te:tg:th:ti:tk:tl:tn:to:tr:ts:tt:ty:ug:uk:ur:uz:ve:vi:vo:wa:wo:xh:yi:yo:za:zh:zu\", \"en\", req.http.Accept-Language) \" \"\n client.socket.cwnd \" \"\n client.socket.tcpi_pacing_rate \" \"\n client.socket.tcpi_min_rtt\n ;\n }\n}\n\nsub vcl_log {\n # This log endpoint only exists in production but there's actually no harm \n # in logging to log endpoints that don't exist. It's a no-op.\n call toppops_collect;\n}\n","old_contents":"sub toppops_collect {\n declare local var.dcpattern STRING;\n declare local var.thisdc STRING;\n set var.dcpattern = \",\" regsuball(table.lookup(toppops_config, \"datacenters\"), \"\\s\", \"\") \",\";\n set var.thisdc = \",\" server.datacenter \",\";\n if (std.strstr(var.dcpattern, var.thisdc) && randombool(std.atoi(table.lookup(toppops_config, \"sample_percent\", \"0\")), 100)) {\n log \"syslog \" req.service_id \" toppops-collector :: \"\n server.datacenter \" \"\n time.start.usec \" \"\n time.elapsed.usec \" \"\n if (fastly_info.is_h2, \"1\", \"0\")\n if (req.is_ipv6, \"1\", \"0\")\n if (req.is_ssl, \"1\", \"0\")\n if (fastly_info.state ~ \"^HIT\", \"1\", \"0\") \" \"\n accept.language_lookup(\"aa:ab:ae:af:ak:am:an:ar:as:av:ay:az:ba:be:bg:bh:bi:bm:bn:bo:br:ca:ce:ch:co:cr:cs:cu:cv:cy:da:de:dv:dz:ee:el:en:eo:es:et:eu:fa:ff:fi:fj:fo:fr:fy:ga:gd:gl:gn:gu:gv:ha:he:hi:ho:ht:hu:hy:hz:ia:ie:ig:ii:ik:io:is:it:iu:iw:ja:ji:jv:jw:ka:kg:ki:kj:kk:kl:km:kn:ko:kr:ks:ku:kv:kw:ky:la:lb:lg:li:ln:lo:lt:lu:lv:mg:mh:mi:mk:ml:mn:mo:mr:ms:mt:my:na:nd:ne:ng:nl:no:nr:nv:ny:oc:oj:om:or:os:pa:pi:pl:ps:pt:qu:rm:rn:ro:ru:rw:sa:sc:sd:se:sg:sh:si:sk:sl:sm:sn:so:sq:ss:st:su:sv:sw:ta:te:tg:th:ti:tk:tl:tn:to:tr:ts:tt:ty:ug:uk:ur:uz:ve:vi:vo:wa:wo:xh:yi:yo:za:zh:zu\", \"en\", req.http.Accept-Language) \" \"\n client.socket.cwnd \" \"\n client.socket.tcpi_pacing_rate \" \"\n client.socket.tcpi_min_rtt\n ;\n }\n}\n\nsub vcl_log {\n # Only call the toppops when we are on a production domain because only the\n # production Fastly Service has the \"toppops-collector\" log endpoint\n\tif (\n req.http.url ~ \"^\/https?:\/\/(cdn.)?polyfill.io\" || \n req.http.url ~ \"^\/https?:\/\/(cdn.)?polyfills.io\" || \n req.http.url ~ \"^\/https?:\/\/polyfill.webservices.ft.com\"\n ) {\n call toppops_collect;\n }\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"f357168a19e9696655911df41fe2537fea0b2d7b","subject":"Fix for geo location when shielding is in play","message":"Fix for geo location when shielding is in play\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets\/recv.vcl","new_file":"etc\/vcl_snippets\/recv.vcl","new_contents":" # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n unset req.http.x-long-cache;\n\n # Rewrite \/static\/versionxxxxx URLs. Avoids us having to rewrite on nginx layer\n if (req.url ~ \"^\/static\/version(\\d*\/)?(.*)$\") {\n set req.url = \"\/static\/\" + re.group.2 + \"?\" + re.group.1;\n set req.http.x-long-cache = \"1\";\n }\n \n # User's Cookie may contain some Magento Vary items we should vary on\n if (req.http.cookie:X-Magento-Vary ) {\n set req.http.X-Magento-Vary = req.http.cookie:X-Magento-Vary;\n } else {\n unset req.http.X-Magento-Vary;\n }\n\n ############################################################################################################\n # Following code block controls purge by URL. By default we want to protect all URL purges. In general this\n # is addressed by adding Fastly-Purge-Requires-Auth request header in vcl_recv however this runs the risk of\n # exposing API tokens if user attempts to purge non-https URLs. For this reason inside the Magento module\n # we use X-Purge-Token. Unfortunately this breaks purge from the Fastly UI. Therefore in the next code block\n # we check for presence of X-Purge-Token. If it's not present we force the Fastly-Purge-Requires-Auth\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n if (req.http.X-Purge-Token && req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n } else {\n error 403;\n }\n } else {\n set req.http.Fastly-Purge-Requires-Auth = \"1\";\n }\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (req.http.Fastly-FF) {\n # disable ESI processing on Origin Shield\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Make sure we lookup end user geo not shielding. More at https:\/\/docs.fastly.com\/vcl\/geolocation\/#using-geographic-variables-with-shielding\n set client.geo.ip_override = req.http.Fastly-Client-IP;\n\n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie:X-Magento-Vary || req.http.cookie:form_key) {\n error 980 \"GeoIP already processed\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url.qs !~ \"country_code=\" ) {\n set req.url = req.url \"?country_code=\" if ( req.http.geo_override, req.http.geo_override, client.geo.country_code);\n }\n }\n } else {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking by default\n # and allow custom parameters to be set. List of parameters is configurable in admin\n set req.http.Magento-Original-URL = req.url;\n # Change the list of ignored parameters by configuring them in the Advanced section\n set req.url = querystring.regfilter(req.url, \"^(####QUERY_PARAMETERS####)\");\n }\n\n # Don't allow clients to force a pass\n if (req.restarts == 0) {\n unset req.http.x-pass;\n }\n \n # Pass on checkout URLs. Because it's a snippet we want to execute this after backend selection so we handle it\n # in the request condition\n if (!req.http.x-long-cache && req.url ~ \"\/(catalogsearch|checkout|customer\/section\/load)\") {\n set req.http.x-pass = \"1\";\n # Pass all admin actions\n # ####ADMIN_PATH#### is replaced with value of frontName from app\/etc\/env.php\n } else if ( req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" ) {\n set req.http.x-pass = \"1\";\n } else {\n # Sort the query arguments to increase cache hit ratio with query arguments that\n # may be out od order. In case you want to restore the unsorted URL add a snippet\n # after this one that sets req.url to req.http.Magento-Original-URL\n set req.url = boltsort.sort(req.url);\n }\n\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.http.x-long-cache || req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n","old_contents":" # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n unset req.http.x-long-cache;\n\n # Rewrite \/static\/versionxxxxx URLs. Avoids us having to rewrite on nginx layer\n if (req.url ~ \"^\/static\/version(\\d*\/)?(.*)$\") {\n set req.url = \"\/static\/\" + re.group.2 + \"?\" + re.group.1;\n set req.http.x-long-cache = \"1\";\n }\n \n # User's Cookie may contain some Magento Vary items we should vary on\n if (req.http.cookie:X-Magento-Vary ) {\n set req.http.X-Magento-Vary = req.http.cookie:X-Magento-Vary;\n } else {\n unset req.http.X-Magento-Vary;\n }\n\n ############################################################################################################\n # Following code block controls purge by URL. By default we want to protect all URL purges. In general this\n # is addressed by adding Fastly-Purge-Requires-Auth request header in vcl_recv however this runs the risk of\n # exposing API tokens if user attempts to purge non-https URLs. For this reason inside the Magento module\n # we use X-Purge-Token. Unfortunately this breaks purge from the Fastly UI. Therefore in the next code block\n # we check for presence of X-Purge-Token. If it's not present we force the Fastly-Purge-Requires-Auth\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n if (req.http.X-Purge-Token && req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n } else {\n error 403;\n }\n } else {\n set req.http.Fastly-Purge-Requires-Auth = \"1\";\n }\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (req.http.Fastly-FF) {\n # disable ESI processing on Origin Shield\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie:X-Magento-Vary || req.http.cookie:form_key) {\n error 980 \"GeoIP already processed\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url.qs !~ \"country_code=\" ) {\n set req.url = req.url \"?country_code=\" if ( req.http.geo_override, req.http.geo_override, client.geo.country_code);\n }\n }\n } else {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking by default\n # and allow custom parameters to be set. List of parameters is configurable in admin\n set req.http.Magento-Original-URL = req.url;\n # Change the list of ignored parameters by configuring them in the Advanced section\n set req.url = querystring.regfilter(req.url, \"^(####QUERY_PARAMETERS####)\");\n }\n\n # Don't allow clients to force a pass\n if (req.restarts == 0) {\n unset req.http.x-pass;\n }\n \n # Pass on checkout URLs. Because it's a snippet we want to execute this after backend selection so we handle it\n # in the request condition\n if (!req.http.x-long-cache && req.url ~ \"\/(catalogsearch|checkout|customer\/section\/load)\") {\n set req.http.x-pass = \"1\";\n # Pass all admin actions\n # ####ADMIN_PATH#### is replaced with value of frontName from app\/etc\/env.php\n } else if ( req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" ) {\n set req.http.x-pass = \"1\";\n } else {\n # Sort the query arguments to increase cache hit ratio with query arguments that\n # may be out od order. In case you want to restore the unsorted URL add a snippet\n # after this one that sets req.url to req.http.Magento-Original-URL\n set req.url = boltsort.sort(req.url);\n }\n\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.http.x-long-cache || req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"0165ded6d30a77f2a7c63b3893a20ce0bd768758","subject":"More aggressive filtration of BrowserProfile cookie.","message":"More aggressive filtration of BrowserProfile cookie.\n","repos":"killerwails\/ansible-varnish,gotofbi\/ansible-varnish,telusdigital\/ansible-varnish,noqcks\/ansible-varnish,killerwails\/ansible-varnish,gotofbi\/ansible-varnish,colstrom\/ansible-varnish,kkwoker\/ansible-varnish","old_file":"templates\/etc\/varnish\/default.vcl","new_file":"templates\/etc\/varnish\/default.vcl","new_contents":"vcl 4.0;\n\nimport directors;\nimport std;\n\n###\n# Varnish Documentation\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-built-in-subs.html\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/reference\/vcl.html\n##\n\n{% for backend in varnish_backend_hosts %}\nbackend application_{{ loop.index }} {\n .host = \"{{ backend }}\";\n .port = \"{{ varnish_backend_port }}\";\n{% if varnish_health_checks_enabled %}\n .probe = {\n .url = \"{{ varnish_health_check_url }}\";\n .interval = {{ varnish_health_check_interval }};\n .timeout = {{ varnish_health_check_timeout }};\n .window = {{ varnish_health_check_window }};\n .threshold = {{ varnish_health_check_threshold }};\n }\n{% endif %}\n}\n{% endfor %}\n\n###\n# vcl_init\n# Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n###\n# The vcl_init subroutine may terminate with calling return() with one of the following keywords:\n#\n# ok\n# Normal return, VCL continues loading.\n##\n\nsub vcl_init {\n new application = directors.round_robin();\n{% for backend in varnish_backend_hosts %}\n application.add_backend(application_{{ loop.index }});\n{% endfor %}\n}\n\n###\n# vcl_recv\n# Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use. \n# It is also used to modify the request\n###\n# The vcl_recv subroutine may terminate with calling return() on one of the following keywords:\n#\n# synth(status code, reason)\n# Return a synthetic object with the specified status code to the client and abandon the request.\n# pass\n# Switch to pass mode. Control will eventually pass to vcl_pass.\n# pipe\n# Switch to pipe mode. Control will eventually pass to vcl_pipe.\n# hash\n# Continue processing the object as a potential candidate for caching. Passes the control over to vcl_hash.\n# purge\n# Purge the object and it's variants. Control passes through vcl_hash to vcl_purge.\n#\n\nsub vcl_recv {\n set req.backend_hint = application.backend();\n\n ###\n # Avoid processing uncacheable requests\n ###\n\n if (req.http.Authorization) {\n return (pass);\n }\n\n ###\n # Inject X-Forwarded-For headers, but only once.\n ###\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n{% if varnish_header_sanitization_enabled %}\n ###\n # Header Sanitization\n ###\n\n{% if varnish_discards_port_from_host_header %}\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n{% endif %}\n\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_enabled %}\n ###\n # Cookie Sanitization\n ###\n\n ### Google Analytics\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n\n ### Quantcast\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n \n ### AddThis\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n\n ### General Cleanup\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n{% endif %}\n\n{% if varnish_uri_sanitization_enabled %}\n ###\n # URI Sanitization\n ###\n \n if (req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=\") {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n{% endif %}\n\n{% if varnish_workaround_telusdotcom_browser_profile %}\n ###\n # Workaround for BrowserProfile and Language\/Region Detection on TELUS.com\n ###\n\n if (req.http.Cookie ~ \"BrowserProfile\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.Cookie, \"(.*)language..:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n set req.http.X-Province = std.tolower(regsuball(regsuball(req.http.Cookie, \"geo\\\\.\\:{(.*)\\}\", \"\"), \"(.*)language..:(.*)region..:\\\\.([^\\\\]*)(.*)\", \"\\3\"));\n } else {\n if (req.http.Cookie ~ \"lang=\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.Cookie, \"(.*)lang=([^;]*)(.*)\", \"\\2\"));\n } else {\n set req.http.X-Language = \"en\";\n }\n\n if (req.http.Cookie ~ \"prov=\") {\n set req.http.X-Province = std.tolower(regsuball(req.http.Cookie, \"(.*)prov=([^;]*)(.*)\", \"\\2\"));\n } else {\n set req.http.X-Province = \"BC\";\n }\n }\n\n if (req.url ~ \"\/(en|fr)\/\") {\n if (req.url ~ \"\/en\/\" && req.http.X-Language != \"en\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Language)\";\n return(pass);\n }\n if (req.url ~ \"\/fr\/\" && req.http.X-Language != \"fr\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Language)\";\n return(pass);\n }\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Language)\";\n return(pass);\n }\n\n if (req.url ~ \"\/(ab|bc|mb|nb|nl|ns|nt|nu|on|pe|qc|sk|yt)\/\") {\n {% for province in ['ab', 'bc', 'mb', 'nb', 'nl', 'ns', 'nt', 'nu', 'on', 'pe', 'qc', 'sk', 'yt'] %}\n if (req.url ~ \"\/{{ province }}\/\" && req.http.X-Province != \"{{ province }}\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Province)\";\n return(pass);\n }\n {% endfor %}\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Province)\";\n return(pass);\n }\n{% endif %}\n\n{% if varnish_blacklist_enabled %}\n if ((req.url ~ \"{{ varnish_blacklist_regexp }}\")) {\n set req.http.X-Passthrough-Reason = \"Path in Blacklist\";\n return(pass);\n } else {\n{% if varnish_discards_client_cookies %}\n unset req.http.Cookie;\n{% endif %}\n }\n{% endif %}\n\n}\n\n###\n# vcl_hit\n# Called when a cache lookup is successful.\n###\n# The vcl_hit subroutine may terminate with calling return() with one of the following keywords:\n#\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n# deliver\n# Deliver the object. Control passes to vcl_deliver.\n# synth(status code, reason)\n# Return the specified status code to the client and abandon the request.\n###\n\nsub vcl_hit {\n if (obj.ttl > 0s) {\n return (deliver);\n }\n{% if varnish_health_checks_enabled %}\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (fetch);\n }\n{% else %}\n if (obj.ttl + obj.grace > 0s) {\n return (deliver);\n }\n\n return (fetch);\n{% endif %}\n}\n\n###\n# vcl_backend_response\n# Called after the response headers has been successfully retrieved from the backend.\n###\n# The vcl_backend_response subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Possibly insert the object into the cache, then deliver it to the Control will eventually pass to vcl_deliver.\n# abandon\n# Abandon the backend request and generates an error.\n# retry\n# Retry the backend transaction. Increases the retries counter. If the number of retries is higher than max_retries Varnish emits a guru meditation error.\n###\n\nsub vcl_backend_response {\n{% if varnish_workaround_telusdotcom_browser_profile %}\n if (bereq.http.X-Language) {\n set beresp.http.X-Language = bereq.http.X-Language;\n }\n if (bereq.http.X-Province) {\n set beresp.http.X-Province = bereq.http.X-Province;\n }\n{% endif %}\n\n{% if varnish_blacklist_enabled %}\n if (bereq.url ~ \"{{ varnish_blacklist_regexp }}\") {\n set beresp.http.X-Cacheable = \"NO:Path in Blacklist\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n if (bereq.http.X-Passthrough-Reason) {\n set beresp.http.X-Passthrough-Reason = bereq.http.X-Passthrough-Reason;\n return(deliver);\n } else {\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n }\n }\n{% else %}\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n{% endif %}\n\n{% if varnish_cache_diagnostics_enabled %}\n if (bereq.http.Cookie) {\n set beresp.http.X-Cacheable = \"NO:Cookie in Request\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO:Set-Cookie in Response\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.X-No-Cache) {\n set beresp.http.X-Cacheable = \"NO:X-No-Cache\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.ttl <= 0s) {\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n{% endif %}\n\n set beresp.grace = {{ varnish_grace_period }};\n}\n\n###\n# vcl_deliver\n# Called before a cached object is delivered to the client.\n###\n# The vcl_deliver subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Deliver the object to the client.\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n###\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n","old_contents":"vcl 4.0;\n\nimport directors;\nimport std;\n\n###\n# Varnish Documentation\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-built-in-subs.html\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/reference\/vcl.html\n##\n\n{% for backend in varnish_backend_hosts %}\nbackend application_{{ loop.index }} {\n .host = \"{{ backend }}\";\n .port = \"{{ varnish_backend_port }}\";\n{% if varnish_health_checks_enabled %}\n .probe = {\n .url = \"{{ varnish_health_check_url }}\";\n .interval = {{ varnish_health_check_interval }};\n .timeout = {{ varnish_health_check_timeout }};\n .window = {{ varnish_health_check_window }};\n .threshold = {{ varnish_health_check_threshold }};\n }\n{% endif %}\n}\n{% endfor %}\n\n###\n# vcl_init\n# Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n###\n# The vcl_init subroutine may terminate with calling return() with one of the following keywords:\n#\n# ok\n# Normal return, VCL continues loading.\n##\n\nsub vcl_init {\n new application = directors.round_robin();\n{% for backend in varnish_backend_hosts %}\n application.add_backend(application_{{ loop.index }});\n{% endfor %}\n}\n\n###\n# vcl_recv\n# Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use. \n# It is also used to modify the request\n###\n# The vcl_recv subroutine may terminate with calling return() on one of the following keywords:\n#\n# synth(status code, reason)\n# Return a synthetic object with the specified status code to the client and abandon the request.\n# pass\n# Switch to pass mode. Control will eventually pass to vcl_pass.\n# pipe\n# Switch to pipe mode. Control will eventually pass to vcl_pipe.\n# hash\n# Continue processing the object as a potential candidate for caching. Passes the control over to vcl_hash.\n# purge\n# Purge the object and it's variants. Control passes through vcl_hash to vcl_purge.\n#\n\nsub vcl_recv {\n set req.backend_hint = application.backend();\n\n ###\n # Avoid processing uncacheable requests\n ###\n\n if (req.http.Authorization) {\n return (pass);\n }\n\n ###\n # Inject X-Forwarded-For headers, but only once.\n ###\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n{% if varnish_header_sanitization_enabled %}\n ###\n # Header Sanitization\n ###\n\n{% if varnish_discards_port_from_host_header %}\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n{% endif %}\n\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_enabled %}\n ###\n # Cookie Sanitization\n ###\n\n ### Google Analytics\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n\n ### Quantcast\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n \n ### AddThis\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n\n ### General Cleanup\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n{% endif %}\n\n{% if varnish_uri_sanitization_enabled %}\n ###\n # URI Sanitization\n ###\n \n if (req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=\") {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n{% endif %}\n\n{% if varnish_workaround_telusdotcom_browser_profile %}\n ###\n # Workaround for BrowserProfile and Language\/Region Detection on TELUS.com\n ###\n\n if (req.http.Cookie ~ \"BrowserProfile\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.Cookie, \"(.*)language..:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n set req.http.X-Province = std.tolower(regsuball(req.http.Cookie, \"(.*)language..:(.*)region..:\\\\.([^\\\\]*)(.*)\", \"\\3\"));\n } else {\n if (req.http.Cookie ~ \"lang=\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.Cookie, \"(.*)lang=([^;]*)(.*)\", \"\\2\"));\n } else {\n set req.http.X-Language = \"en\";\n }\n\n if (req.http.Cookie ~ \"prov=\") {\n set req.http.X-Province = std.tolower(regsuball(req.http.Cookie, \"(.*)prov=([^;]*)(.*)\", \"\\2\"));\n } else {\n set req.http.X-Province = \"BC\";\n }\n }\n\n if (req.url ~ \"\/(en|fr)\/\") {\n if (req.url ~ \"\/en\/\" && req.http.X-Language != \"en\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Language)\";\n return(pass);\n }\n if (req.url ~ \"\/fr\/\" && req.http.X-Language != \"fr\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Language)\";\n return(pass);\n }\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Language)\";\n return(pass);\n }\n\n if (req.url ~ \"\/(ab|bc|mb|nb|nl|ns|nt|nu|on|pe|qc|sk|yt)\/\") {\n {% for province in ['ab', 'bc', 'mb', 'nb', 'nl', 'ns', 'nt', 'nu', 'on', 'pe', 'qc', 'sk', 'yt'] %}\n if (req.url ~ \"\/{{ province }}\/\" && req.http.X-Province != \"{{ province }}\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Province)\";\n return(pass);\n }\n {% endfor %}\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Province)\";\n return(pass);\n }\n{% endif %}\n\n{% if varnish_blacklist_enabled %}\n if ((req.url ~ \"{{ varnish_blacklist_regexp }}\")) {\n set req.http.X-Passthrough-Reason = \"Path in Blacklist\";\n return(pass);\n } else {\n{% if varnish_discards_client_cookies %}\n unset req.http.Cookie;\n{% endif %}\n }\n{% endif %}\n\n}\n\n###\n# vcl_hit\n# Called when a cache lookup is successful.\n###\n# The vcl_hit subroutine may terminate with calling return() with one of the following keywords:\n#\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n# deliver\n# Deliver the object. Control passes to vcl_deliver.\n# synth(status code, reason)\n# Return the specified status code to the client and abandon the request.\n###\n\nsub vcl_hit {\n if (obj.ttl > 0s) {\n return (deliver);\n }\n{% if varnish_health_checks_enabled %}\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (fetch);\n }\n{% else %}\n if (obj.ttl + obj.grace > 0s) {\n return (deliver);\n }\n\n return (fetch);\n{% endif %}\n}\n\n###\n# vcl_backend_response\n# Called after the response headers has been successfully retrieved from the backend.\n###\n# The vcl_backend_response subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Possibly insert the object into the cache, then deliver it to the Control will eventually pass to vcl_deliver.\n# abandon\n# Abandon the backend request and generates an error.\n# retry\n# Retry the backend transaction. Increases the retries counter. If the number of retries is higher than max_retries Varnish emits a guru meditation error.\n###\n\nsub vcl_backend_response {\n{% if varnish_workaround_telusdotcom_browser_profile %}\n if (bereq.http.X-Language) {\n set beresp.http.X-Language = bereq.http.X-Language;\n }\n if (bereq.http.X-Province) {\n set beresp.http.X-Province = bereq.http.X-Province;\n }\n{% endif %}\n\n{% if varnish_blacklist_enabled %}\n if (bereq.url ~ \"{{ varnish_blacklist_regexp }}\") {\n set beresp.http.X-Cacheable = \"NO:Path in Blacklist\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n if (bereq.http.X-Passthrough-Reason) {\n set beresp.http.X-Passthrough-Reason = bereq.http.X-Passthrough-Reason;\n return(deliver);\n } else {\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n }\n }\n{% else %}\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n{% endif %}\n\n{% if varnish_cache_diagnostics_enabled %}\n if (bereq.http.Cookie) {\n set beresp.http.X-Cacheable = \"NO:Cookie in Request\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO:Set-Cookie in Response\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.X-No-Cache) {\n set beresp.http.X-Cacheable = \"NO:X-No-Cache\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.ttl <= 0s) {\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n{% endif %}\n\n set beresp.grace = {{ varnish_grace_period }};\n}\n\n###\n# vcl_deliver\n# Called before a cached object is delivered to the client.\n###\n# The vcl_deliver subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Deliver the object to the client.\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n###\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"36bd0825cddfe07bd2e97c60752c0fc3d8f770e6","subject":"Added commands for comments, delete back words","message":"Added commands for comments, delete back words\n","repos":"aschneiderman\/atom-voice-vocola","old_file":"atom.vcl","new_file":"atom.vcl","new_contents":"# Voice commands for atom\n\ninclude folders.vch;\ninclude letters.vch;\n\nGo Strawberry = {Ctrl+Alt+F4};\nReload Atom = {Shift+Ctrl+Alt+F5};\n\nFind (File | Document) = {Ctrl+t};\nSave As = {Ctrl+Shift+s};\nSave and Reload = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Ctrl+r};\n\n<delimiters> := (Quote = '\"' | 'Single Quote' = \"'\" | Comma = ',' | 'Equal Sign' = '=' | Equals = '=' \n\t| Period = '.' | 'Semi-Colon' = ';');\n\n# --- Navigation commands ------------------------------------\nLine 1..200 = {Ctrl+g} $1 {Enter};\n(Left = 'b' | Right = 'f') Word = {Alt+$1};\nTop = {Ctrl+Home};\nBottom = {Ctrl+End};\n(Find = 'Right' | 'Insert After' = 'Right' | 'Insert Before' = 'Left') (Next = 'Enter' | Last = 'Shift+F3') <delimiters> \n\t\t= {Ctrl+f} $3 {$2} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') <delimiters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nFine Alpha <letters> = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Right};\nInsert (Before = 'Left' | After = 'Right') Alpha <letters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nFine Number 0..9 = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Right};\nFind Again = {F3} {Right};\nFind Again 1..20 Times = {F3_$1} {Right};\n\nFind Symbol = {Ctrl+r};\n\n(Set | Add | Clear | Hide | Delete) Bookmark = {Ctrl+Alt+F2};\n(Next = 'F2' | Last = 'Shift+F2') Bookmark = {$1};\n\nNext Window = {Ctrl+Tab};\nLast Window = {Ctrl+Shift+Tab};\n\n\n# --- Editing commands ----------------------------------------\nSelect Line = {Ctrl+l};\nSelect (Next = 'Down' | Last = 'Up') 1..20 Lines = {Home} {Shift+$1_$2};\n(Join = 'j' | Indent = ']' | Dedent = '[') That = {Ctrl+$1};\nMove Line (Up | Down) 1..20 = {Ctrl+$1_$2};\n\n\n\nDelete Word = {Ctrl+Del};\nDelete 1..20 Words = {Ctrl+Del_$1};\nDelete (Back | Last) Word = {Ctrl+Backspace};\nDelete (Back | Last) 1..20 Words = {Ctrl+Backspace_$2};\n(Delete Line | Dede) = {Ctrl+Shift+k};\nDelete 1..20 Lines = {Ctrl+Shift+k_$1};\n(Cut = 'x' | Paste = 'v' | Copy = 'c') That = {Ctrl+$1};\n\nComment (That | Line) = {Ctrl+\/};\nComment 1..20 Lines = {Home} {Shift+Down_$1} {Ctrl+\/};\n\n\nSelect between (Delimiters | Brackets) ={Ctrl+m} {Ctrl+Alt+m};\n# TO ADD:\n# delete between next tags\n\n\n\n\n# --- Code commands -------------------------------------------\nStart (Item = 'li' | List = 'ul' | HTML = 'html' | pre = \"pre\"\n\t| 'Bold ID' = 'bold-id' | 'Input' = 'ds-input-text'\n\t| Snippet = 'snip' | 'Recipe Row' = 'recipe-row' | 'Recipe Play' = 'recipe-play') = $1 {Tab};\nStart (para = '<p>' ) = $1;\nStart (Header | Heading) 1..7 = h $2 {Tab}; \nMid HREF = '\">';\n\nPaste Function = 'function ' {Ctrl+v} ' {' {Enter} {Enter} '};' {Up};\n\n# TO ADD:\n# adding HTML comments, using a snippet\n\nShortcut Keys = {Ctrl+Shift+p};\n\n","old_contents":"# Voice commands for atom\n\ninclude folders.vch;\ninclude letters.vch;\n\nFind (File | Document) = {Ctrl+t};\nSave As = {Ctrl+Shift+s};\nSave and Reload = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Ctrl+r};\n\n<delimiters> := (Quote = '\"' | 'Single Quote' = \"'\" | Comma = ',' | 'Equal Sign' = '=' | Equals = '=' \n\t| Period = '.' | 'Semi-Colon' = ';');\n\n# --- Navigation commands ------------------------------------\nLine 1..200 = {Ctrl+g} $1 {Enter};\n(Left = 'b' | Right = 'f') Word = {Alt+$1};\nTop = {Ctrl+Home};\nBottom = {Ctrl+End};\n(Find = 'Right' | 'Insert After' = 'Right' | 'Insert Before' = 'Left') (Next = 'Enter' | Last = 'Shift+F3') <delimiters> \n\t\t= {Ctrl+f} $3 {$2} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') <delimiters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nFine Alpha <letters> = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Right};\nInsert (Before = 'Left' | After = 'Right') Alpha <letters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nFine Number 0..9 = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Right};\nFind Again = {F3} {Right};\nFind Again 1..20 Times = {F3_$1} {Right};\n\nFind Symbol = {Ctrl+r};\n\n(Set | Add | Clear | Hide | Delete) Bookmark = {Ctrl+Alt+F2};\n(Next = 'F2' | Last = 'Shift+F2') Bookmark = {$1};\n\nNext Window = {Ctrl+Tab};\nLast Window = {Ctrl+Shift+Tab};\n\n\n# --- Editing commands ----------------------------------------\nSelect (Next = 'Down' | Last = 'Up') 1..20 Lines = {Home} {Shift+$1_$2};\n(Join = 'j' | Indent = ']' | Dedent = '[') That = {Ctrl+$1};\nMove Line (Up | Down) 1..20 = {Ctrl+$1_$2};\n\n\n\nDelete Word = {Ctrl+Del};\nDelete 1..20 Words = {Ctrl+Del_$1};\n(Delete Line | Dede) = {Ctrl+Shift+k};\nDelete 1..20 Lines = {Ctrl+Shift+k_$1};\n(Cut = 'x' | Paste = 'v' | Copy = 'c') That = {Ctrl+$1};\n\nSelect between (Delimiters | Brackets) ={Ctrl+m} {Ctrl+Alt+m};\n# TO ADD:\n# Delete back three words\n# delete between next tags\n\n\n\n\n# --- Code commands -------------------------------------------\nStart (Item = 'li' | List = 'ul' | HTML = 'html' | pre = \"pre\"\n\t| 'Bold ID' = 'bold-id' | 'Input' = 'ds-input-text'\n\t| Snippet = 'snip' | 'Recipe Row' = 'recipe-row' | 'Recipe Play' = 'recipe-play') = $1 {Tab};\nStart (para = '<p>' ) = $1;\nStart (Header | Heading) 1..7 = h $2 {Tab}; \nMid HREF = '\">';\n\nPaste Function = 'function ' {Ctrl+v} ' {' {Enter} {Enter} '};' {Up};\n\n# TO ADD:\n# adding HTML comments, using a snippet\n\nShortcut Keys = {Ctrl+Shift+p};\n\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"529506838c5407237c18f3d3fca6671a266e2a73","subject":"Strip cookies from gend and src images in varnish.","message":"Strip cookies from gend and src images in varnish.\n","repos":"mmb\/meme_captain_web,mmb\/meme_captain_web,mmb\/meme_captain_web,mmb\/meme_captain_web,patrickmcguire\/meme,patrickmcguire\/meme","old_file":"varnish\/default.vcl","new_file":"varnish\/default.vcl","new_contents":"sub vcl_recv {\n if (req.request == \"GET\" &&\n req.url ~ \"^\/((gend|src)_thumbs\/\\d+|(gend|src)_images\/[\\w-]{6,})$\") {\n unset req.http.Cookie;\n }\n}\n","old_contents":"sub vcl_recv {\n if (req.url ~ \"^\/(gend|src)_thumbs\/[0-9]+$\") {\n unset req.http.Cookie;\n }\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"c86207293e913a0c8590e90a0cd2eacb928c77ad","subject":"Fix TTL and set to 1 hour","message":"Fix TTL and set to 1 hour\n","repos":"trevorparker\/dockerfiles","old_file":"varnish\/default.vcl","new_file":"varnish\/default.vcl","new_contents":"backend default {\n .host = \"127.0.0.1\";\n .port = \"80\";\n}\n\nsub vcl_fetch {\n set beresp.ttl = 1h;\n}\n\nsub vcl_recv {\n set req.http.Host = \"www.trevorparker.com\";\n if (req.http.X-Forwarded-Proto !~ \"(?i)https\") {\n set req.http.x-Redir-Url = \"https:\/\/www.trevorparker.com\" + req.url;\n error 750 req.http.x-Redir-Url;\n }\n}\n\nsub vcl_error {\n if (obj.status == 750) {\n set obj.http.Location = obj.response;\n set obj.status = 301;\n return(deliver);\n }\n}\n\n","old_contents":"backend default {\n .host = \"127.0.0.1\";\n .port = \"80\";\n}\n\nsub vcl_fetch {\n set obj.ttl = 12h;\n}\n\nsub vcl_recv {\n set req.http.Host = \"www.trevorparker.com\";\n if (req.http.X-Forwarded-Proto !~ \"(?i)https\") {\n set req.http.x-Redir-Url = \"https:\/\/www.trevorparker.com\" + req.url;\n error 750 req.http.x-Redir-Url;\n }\n}\n\nsub vcl_error {\n if (obj.status == 750) {\n set obj.http.Location = obj.response;\n set obj.status = 301;\n return(deliver);\n }\n}\n\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"5cafed47deb466a9f4ce78dc8c4c54b816c74282","subject":"Added commands for changing\/deleting between tags","message":"Added commands for changing\/deleting between tags\n","repos":"aschneiderman\/vim-voice","old_file":"gvim.vcl","new_file":"gvim.vcl","new_contents":"# Voice commands for gvim\n\ninclude folders.vch;\ninclude numbers.vch;\ninclude pandas.vch;\n<letters> := (alpha = a | bravo = b | Charlie = c | Delta = d | echo = e | foxtrot = f | golf = g | hotel = h \n\t| India = i | Juliet = j | kilo = k | Lima = l | Mike = m | November = n | Oscar = o | Poppa = p \n\t| Qubec = q | Romeo = r | Sierra = s | tango = t three spaces | uniform = u | Victor = v | whiskey = w \n\t| 'x-ray' = x | Yankee = y | Zulu = z);\n<delimiters> := (Quotes = '\"' | 'Single Quotes' = \"'\" | 'Double Quotes' = '\"' | Parentheses = '(' \n\t\t| Brackets = '[' | 'Curly Braces' = '{' | Braces = '{' | HTML = '<' | Tags = '<');\n\nProject Sandwich = {Esc} ':e C:\\GitHub\\d3_sandwich\\sandwiches\\Dendrogram' {Enter} Wait(100) {Down_9};\n# --- File Management ---------------\nOpen Document = {Alt+f} o;\nList Files = {Esc} ':bro ol' {Enter};\nLatest File = {Esc} ':bro ol' {Enter} Wait(100) 1 {Enter};\n\nFile <numbers> = $1 {Enter};\nProject <folder> = {Esc} ':e ' $1 {Enter} Wait(100) {Down_9};\nProject Current = {Esc} ':e .' {Enter} Wait(100) {Down_9};\nGet (\t 'Home Folders' = 'C:\\Users\\Anders\\Documents\\Voice\\folders.vch' \n\t) = {Esc}':e ' $1 {Enter} Wait(100) {Down_9};\nShow (Projects | Folders) = {Esc}':e C:\\Users\\Anders\\Documents\\Voice\\folders.vch' {Enter} Wait(100) {Down_9};\nEdit [My] Configuration = ':e $' 'MYVIMRC' {Enter};\nUp Directory = '-';\nSearch [Directory] <letters> = '\/^' $1;\n# :Sex = directory of current file \n# :Vex for vertical split\n# :sp. = Split horizontally on current directory (:vsp. For vertical)\n# % = new file\n\n\n\nSave Document = {Esc} Wait(100) ':w' {Enter};\nSave As = {Alt+f} a;\nGo (Quit = 'quit' | Close = 'close' | 'Close without saving' = 'close!' | Set = 'set') = ':' $1 {Enter};\n[Go] Quit without Saving = {Esc} Wait(100) ':quit!' {Enter};\n\n\n# --- Basic Navigation ---------------\n<numbers> (Up = 'k' | Down = 'j' | Right = 'l' | Left = 'h') = $1 $2;\nHoma = {Esc} 0;\nEnda = {Esc} '$';\n(Top | Go to Top) = {Esc} gg;\n(Bottom | Go to Bottom) = {Esc} G;\n(Move Forward | Move Right | Go Forward) <numbers> (words = 'w' | blocks = '}') = $2 $3;\n(Move Forward | Move Right | Go Forward) <numbers> (end | enda) words = $2 'e';\n(Move Back | Move Left | Go Back) <numbers> (words = 'b' | blocks = '{') = $2 $3;\nFine Text <letters> = {Esc} f $1;\nFind Back <letters> = {Esc} F $1;\nFine Number 1..9 = {Esc} '\/' $1 {Enter};\nNext Fine = n;\nLine 1..100 = {Esc} ':' $1 {Enter};\n\n\n# --- Basic Editing ---------------\n(Do | Go) Insert = i;\n(Do | Go) Escape = {Esc};\nGo Append = A;\nNexta = {Esc} A {Enter};\n\t\t\t# commands for changing\n\n(Do Again | Repeat That) = '.';\n(Undo | Undo That) = {Esc} u;\nRedo = {Esc} {Ctrl+r};\n\n(Kill = 'x') <numbers> = $2 $1;\n(Kill | Delete) Word = 'dw';\n(Kill | Delete) <numbers> Words = 'd' $2 'w';\nDee Dee = 'dd';\nCut to End of Line = 'd$';\nCut to End of Word = 'de';\n\n(Delete= 'd' | Change = 'c') between <delimiters> = $1 i $2;\n(Delete= 'd' | Change = 'c') (Next = '\/' | Last = '?') <delimiters> = {Esc} $2 $3 {Enter} $1 i $3;\n(Delete= 'd' | Change = 'c') (Next = '\/' | Last = '?') \n\t(Heading = '<h' | Header = '<h' | Paragraph = '<p') \n\t= {Esc} $2 '\\c' $3 {Enter} $1 i t;\n\n\n\nStrawberry test = 'vi<';\n\nPaste That = {Alt+e} p;\nSelect All = {Alt+e} s {Enter};\nGrab Everything = {Alt+e} s {Enter} Wait(100) {Alt+e} c {Enter} Wait(100) {Alt+Tab};\n\n\n\n\n1..20 Spaces = Repeat($1, ' ');\n\n\nDo Ultisnips = {Esc} ':UltiSnipsEdit'{Enter};\n\n\n(Next = 'j' | Last = 'k') Tag = {Ctrl+$1};\nStart Snippet= {Esc} i 'snippet {Enter} {Enter}endsnippet' {Esc} {Up_2} A;\nStart (\n\tD3 = 'd3_template' | Code = 'D3_code_wrapper'\n| \tform | 'form text' | 'form button' | 'form select'\n|\thref\n) = {Esc} i $1 {Tab};\n\n\n\nDelete Line = 'dd';\nDelete <numbers> Lines = $1 'dd';\n\n# Commands for command line mode\nYank That = 'y';\n\n\n\n\n# ---Things to do\n# change the configuration file\n\n\n# Commands to add:\n# g; - last place I was where I made a change\n# Ctrl-o - If I jump to a place, copy a line, I can snap back \n# :9yank - copy line 9\n# :9t16 - copy line 9 to line 16\n# :9. - copy line 9 to current position \n\n\n# Commands I'm not sure about\n# H,M,L: top, middle, and bottom of screen","old_contents":"# Voice commands for gvim\n\ninclude folders.vch;\ninclude numbers.vch;\ninclude pandas.vch;\n<letters> := (alpha = a | bravo = b | Charlie = c | Delta = d | echo = e | foxtrot = f | golf = g | hotel = h \n\t| India = i | Juliet = j | kilo = k | Lima = l | Mike = m | November = n | Oscar = o | Poppa = p \n\t| Qubec = q | Romeo = r | Sierra = s | tango = t three spaces | uniform = u | Victor = v | whiskey = w \n\t| 'x-ray' = x | Yankee = y | Zulu = z);\n<delimiters> := (Quotes = '\"' | 'Single Quotes' = \"'\" | 'Double Quotes' = '\"' | Parentheses = '(' \n\t\t| Brackets = '[' | 'Curly Braces' = '{' | Braces = '{' | HTML = '<' | Tags = '<');\n\nProject Sandwich = {Esc} ':e C:\\GitHub\\d3_sandwich\\sandwiches\\Abstract_Map' {Enter} Wait(100) {Down_9};\n# --- File Management ---------------\nOpen Document = {Alt+f} o;\nList Files = {Esc} ':bro ol' {Enter};\nFile <numbers> = $1 {Enter};\nProject <folder> = {Esc} ':e ' $1 {Enter} Wait(100) {Down_9};\nProject Current = {Esc} ':e .' {Enter} Wait(100) {Down_9};\nGet (\t 'Home Folders' = 'C:\\Users\\Anders\\Documents\\Voice\\folders.vch' \n\t) = {Esc}':e ' $1 {Enter} Wait(100) {Down_9};\nShow (Projects | Folders) = {Esc}':e C:\\Users\\Anders\\Documents\\Voice\\folders.vch' {Enter} Wait(100) {Down_9};\nEdit [My] Configuration = ':e $' 'MYVIMRC' {Enter};\nUp Directory = '-';\nSearch [Directory] <letters> = '\/^' $1;\n\t\t\t# :Sex = directory of current file (:Vex for vertical split)\n\t\t\t# :sp. = Split horizontally on current directory (:vsp. For vertical)\n\t\t\t# % = new file\n\n# Command for most recent files\/files?\n# Do some research online\n\n\nSave Document = {Esc} Wait(100) ':w' {Enter};\nSave As = {Alt+f} a;\nGo (Quit = 'quit' | Close = 'close' | 'Close without saving' = 'close!' | Set = 'set') = ':' $1 {Enter};\n[Go] Quit without Saving = {Esc} Wait(100) ':quit!' {Enter};\n\n\n# --- Basic Navigation ---------------\n<numbers> (Up = 'k' | Down = 'j' | Right = 'l' | Left = 'h') = $1 $2;\nHoma = {Esc} 0;\nEnda = {Esc} '$';\n(Move Forward | Go | Go Forward) <numbers> words = $2 'w';\n(Move Forward | Go | Go Forward) <numbers> (end | enda) words = $2 'e';\n(Move Back | Go | Go Back) <numbers> words = $2 'b';\n(Move Forward | Go | Go Forward) <numbers> (sections | parentheses) = $2 '%';\nFine Text <letters> = {Esc} f $1;\nFind Back <letters> = {Esc} F $1;\nLine <numbers> = ':' $1 {Enter};\n\t\t\t# Commands to add: bottom, top\n\n\n# --- Basic Editing ---------------\n(Do | Go) Insert = i;\n(Do | Go) Escape = {Esc};\nGo Append = A;\nNexta = {Esc} A {Enter};\n\t\t\t# commands for changing\n\n(Do Again | Repeat That) = '.';\n(Undo | Undo That) = {Esc} u;\nRedo = {Esc} {Ctrl+r};\n\n(Kill = 'x') <numbers> = $2 $1;\n(Kill | Delete) Word = 'dw';\n(Kill | Delete) <numbers> Words = 'd' $2 'w';\nDee Dee = 'dd';\nCut to End of Line = 'd$';\nCut to End of Word = 'de';\nDelete Between <delimiters> = {Esc} Wait(100) '\/' $1 {Enter} Wait(100) ci $1;\n\nPaste That = {Alt+e} p;\nSelect All = {Alt+e} s {Enter};\nGrab Everything = {Alt+e} s {Enter} Wait(100) {Alt+e} c {Enter} Wait(100) {Alt+Tab};\n\n\n\n\n1..20 Spaces = Repeat($1, ' ');\n\n\nDo Ultisnips = {Esc} ':UltiSnipsEdit'{Enter};\n\n\n(Next = 'j' | Last = 'k') Tag = {Ctrl+$1};\nStart Snippet= {Esc} i 'snippet {Enter} {Enter}endsnippet' {Esc} {Up_2} A;\nStart (\n\tD3 = 'd3_template' | Code = 'D3_code_wrapper'\n| \tform | 'form text' | 'form button' | 'form select'\n|\thref\n) = {Esc} i $1 {Tab};\n\n\n\nDelete Line = 'dd';\nDelete <numbers> Lines = $1 'dd';\n\n# Commands for command line mode\nYank That = 'y';\n\n\n\n\n# ---Things to do\n# change the configuration file","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"606ef23a33efa849dedf8044f688e5dd5f0224e5","subject":"Removed unused vmod","message":"Removed unused vmod\n","repos":"SteveEasley\/libvmod-headerproxy,SteveEasley\/libvmod-headerproxy,SteveEasley\/libvmod-headerproxy,SteveEasley\/libvmod-headerproxy","old_file":"example\/default.vcl","new_file":"example\/default.vcl","new_contents":"vcl 4.0;\n\nimport headerproxy;\n\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8000\";\n}\n\nsub vcl_recv {\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n\n # Call our headerproxy script. Notice we choose not to send requests for\n # asset files to the headerproxy.\n if (req.url !~ \"\\.(gif|jpg|png|css|js)(\\?|$)\") {\n # Make proxy call and add the desired request headers from your\n # vcl_recv json key.\n headerproxy.call(req.backend_hint, \"\/headerproxy.php\");\n\n if (headerproxy.error()) {\n set req.http.X-HeaderProxy-Error = headerproxy.error();\n }\n }\n\n return (hash);\n}\n\nsub vcl_deliver {\n # This call adds the desired response headers from your vcl_deliver\n # json key.\n headerproxy.process();\n}\n","old_contents":"vcl 4.0;\n\nimport std;\nimport headerproxy;\n\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8000\";\n}\n\nsub vcl_recv {\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n\n # Call our headerproxy script. Notice we choose not to send requests for\n # asset files to the headerproxy.\n if (req.url !~ \"\\.(gif|jpg|png|css|js)(\\?|$)\") {\n # Make proxy call and add the desired request headers from your\n # vcl_recv json key.\n headerproxy.call(req.backend_hint, \"\/headerproxy.php\");\n\n if (headerproxy.error()) {\n set req.http.X-HeaderProxy-Error = headerproxy.error();\n }\n }\n\n return (hash);\n}\n\nsub vcl_deliver {\n # This call adds the desired response headers from your vcl_deliver\n # json key.\n headerproxy.process();\n}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"9cac58ae16a1e12a97ce54f220a84a61c90ebcd7","subject":"fix cache of images","message":"fix cache of images\n","repos":"ecreall\/nova-ideo,ecreall\/nova-ideo,ecreall\/nova-ideo,ecreall\/nova-ideo,ecreall\/nova-ideo","old_file":"etc\/varnish.vcl","new_file":"etc\/varnish.vcl","new_contents":"# This a configuration file for varnish.\n# It was generated by plone.recipe.varnish.\n# See the vcl(7) man page for details on VCL syntax and semantics.\n#\nvcl 4.0;\n\nimport std;\n\n# configure all backends\nbackend backend_000 {\n .host = \"127.0.0.1\";\n .port = \"5001\";\n .connect_timeout = 0.4s;\n .first_byte_timeout = 300s;\n .between_bytes_timeout = 60s;\n}\n\n\nsub vcl_init {\n\n}\n\nacl purge {\n \"localhost\";\n \"127.0.0.1\";\n}\n\nsub vcl_recv {\n set req.backend_hint = backend_000;\n set req.http.grace = \"none\";\n\n if (req.method == \"PURGE\") {\n # Not from an allowed IP? Then die with an error.\n if (!client.ip ~ purge) {\n return (synth(405, \"This IP is not allowed to send PURGE requests.\"));\n }\n return(purge);\n }\n\n if (req.method == \"BAN\") {\n # Same ACL check as above:\n if (!client.ip ~ purge) {\n return(synth(403, \"Not allowed.\"));\n }\n #ban(\"req.url ~ \" + req.url);\n ban(\"req.http.host == \" + req.http.host +\n \" && req.url == \" + req.url);\n # Throw a synthetic page so the\n # request won't go to the backend.\n return(synth(200, \"Ban added\"));\n }\n\n if (req.method == \"USERINFO\" ||\n req.method == \"CONNECT\" ||\n req.method == \"QUIT\") {\n return (synth(501, \"Not implemented\"));\n }\n\n # Only deal with \"normal\" types\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return(pipe);\n }\n\n # Only cache GET or HEAD requests. This makes sure the POST requests are always passed.\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return(pass);\n }\n\n if (req.http.Expect) {\n return(pipe);\n }\n\n if (req.http.If-None-Match && !req.http.If-Modified-Since) {\n return(pass);\n }\n\n \/* Do not cache other authorized content by default *\/\n if (req.http.Authenticate || req.http.Authorization) {\n return(pass);\n }\n\n if (req.url ~ \"@@registration|@@login|@@resetpassword\") {\n return(pass);\n }\n\n if (req.url ~ \"^[^?]*\\.(css|js|png|png\/|gif|gif\/|jpeg|jpeg\/|jpg|jpg\/|small\/|medium\/|large\/|xlarge\/|woff|woff2)(\\?.*)?$\") {\n unset req.http.Cookie;\n }\n\n if (req.http.Cookie && req.http.Cookie ~ \"auth_tkt\") {\n return(pass);\n }\n\n unset req.http.Accept-Encoding;\n\n return(hash);\n}\n\nsub vcl_pipe {\n # By default Connection: close is set on all piped requests, to stop\n # connection reuse from sending future requests directly to the\n # (potentially) wrong backend. If you do want this to happen, you can undo\n # it here.\n # unset bereq.http.connection;\n\n return(pipe);\n}\n\nsub vcl_pass {\n return (fetch);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n if (req.http.X-Forwarded-Proto) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n return (lookup);\n}\n\nsub vcl_purge {\n return (synth(200, \"Purged\"));\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n \/\/ A pure unadultered hit, deliver it\n # normal hit\n return (deliver);\n }\n\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n if (obj.ttl + obj.grace > 0s) {\n set req.http.grace = \"normal(limited)\";\n return (deliver);\n }\n\n if (req.method == \"PURGE\") {\n set req.method = \"GET\";\n set req.http.X-purger = \"Purged\";\n return(synth(200, \"Purged. in hit \" + req.url));\n }\n\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\nsub vcl_miss {\n if (req.method == \"PURGE\") {\n set req.method = \"GET\";\n set req.http.X-purger = \"Purged-possibly\";\n return(synth(200, \"Purged. in miss \" + req.url));\n }\n\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\nsub vcl_backend_fetch{\n return (fetch);\n}\n\nsub vcl_backend_response {\n # The object is not cacheable\n if (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO - Set Cookie\";\n set beresp.ttl = 0s;\n set beresp.uncacheable = true;\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO - Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = 120s;\n } elsif (beresp.http.Surrogate-control ~ \"no-store\") {\n set beresp.http.X-Cacheable = \"NO - Surrogate-control=no-store\";\n set beresp.uncacheable = true;\n set beresp.ttl = 120s;\n } elsif (!beresp.http.Surrogate-Control && beresp.http.Cache-Control ~ \"no-cache|no-store\") {\n set beresp.http.X-Cacheable = \"NO - Cache-Control=no-cache|no-store\";\n set beresp.uncacheable = true;\n set beresp.ttl = 120s;\n } elsif (beresp.http.Vary == \"*\") {\n set beresp.http.X-Cacheable = \"NO - Vary=*\";\n set beresp.uncacheable = true;\n set beresp.ttl = 120s;\n\n\n # ttl handling\n } elsif (beresp.ttl < 0s) {\n set beresp.http.X-Cacheable = \"NO - TTL < 0\";\n set beresp.uncacheable = true;\n } elsif (beresp.ttl == 0s) {\n if (bereq.http.Cookie && bereq.http.Cookie ~ \"auth_tkt\") {\n set beresp.http.X-Cacheable = \"NO - TTL = 0\";\n set beresp.uncacheable = true;\n } else {\n set beresp.http.X-Cacheable = \"YES, 3600s\";\n set beresp.ttl = 3600s;\n set beresp.grace = 36000s;\n }\n\n # Varnish determined the object was cacheable\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n\n# https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleLongerCaching\n if (beresp.ttl == 31536000s) { # for deform.js, jquery.form-3.09.js from deformstatic\n \/* Remove Expires from backend, it's too long *\/\n unset beresp.http.expires;\n\n \/* Set the clients TTL on this object *\/\n set beresp.http.cache-control = \"max-age=86400\";\n\n \/* Set how long Varnish will keep it *\/\n set beresp.ttl = 86400s;\n }\n\n # Do not cache 5xx errors\n if (beresp.status >= 500 && beresp.status < 600) {\n unset beresp.http.Cache-Control;\n set beresp.http.X-Cache = \"NOCACHE\";\n set beresp.http.Cache-Control = \"no-cache, max-age=0, must-revalidate\";\n set beresp.ttl = 0s;\n set beresp.http.Pragma = \"no-cache\";\n set beresp.uncacheable = true;\n return(deliver);\n }\n\n return (deliver);\n}\n\nsub vcl_deliver {\n set resp.http.grace = req.http.grace;\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n \/* Rewrite s-maxage to exclude from intermediary proxies\n (to cache *everywhere*, just use 'max-age' token in the response to avoid\n this override) *\/\n if (resp.http.Cache-Control ~ \"s-maxage\") {\n set resp.http.Cache-Control = regsub(resp.http.Cache-Control, \"s-maxage=[0-9]+\", \"s-maxage=0\");\n }\n \/* Remove proxy-revalidate for intermediary proxies *\/\n if (resp.http.Cache-Control ~ \", proxy-revalidate\") {\n set resp.http.Cache-Control = regsub(resp.http.Cache-Control, \", proxy-revalidate\", \"\");\n }\n\n unset resp.http.Server;\n\n}\n\n\/*\n We can come here \"invisibly\" with the following errors: 413, 417 & 503\n*\/\nsub vcl_synth {\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n set resp.http.Retry-After = \"5\";\n\n synthetic( {\"\n <?xml version=\"1.0\" encoding=\"utf-8\"?>\n <!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n <html>\n <head>\n <title>Varnish cache server: \"} + resp.status + \" \" + resp.reason + {\" <\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n <\/html>\n \"} );\n\n return (deliver);\n}\n","old_contents":"# This a configuration file for varnish.\n# It was generated by plone.recipe.varnish.\n# See the vcl(7) man page for details on VCL syntax and semantics.\n#\nvcl 4.0;\n\nimport std;\n\n# configure all backends\nbackend backend_000 {\n .host = \"127.0.0.1\";\n .port = \"5001\";\n .connect_timeout = 0.4s;\n .first_byte_timeout = 300s;\n .between_bytes_timeout = 60s;\n}\n\n\nsub vcl_init {\n\n}\n\nacl purge {\n \"localhost\";\n \"127.0.0.1\";\n}\n\nsub vcl_recv {\n set req.backend_hint = backend_000;\n set req.http.grace = \"none\";\n\n if (req.method == \"PURGE\") {\n # Not from an allowed IP? Then die with an error.\n if (!client.ip ~ purge) {\n return (synth(405, \"This IP is not allowed to send PURGE requests.\"));\n }\n return(purge);\n }\n\n if (req.method == \"BAN\") {\n # Same ACL check as above:\n if (!client.ip ~ purge) {\n return(synth(403, \"Not allowed.\"));\n }\n #ban(\"req.url ~ \" + req.url);\n ban(\"req.http.host == \" + req.http.host +\n \" && req.url == \" + req.url);\n # Throw a synthetic page so the\n # request won't go to the backend.\n return(synth(200, \"Ban added\"));\n }\n\n if (req.method == \"USERINFO\" ||\n req.method == \"CONNECT\" ||\n req.method == \"QUIT\") {\n return (synth(501, \"Not implemented\"));\n }\n\n # Only deal with \"normal\" types\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return(pipe);\n }\n\n # Only cache GET or HEAD requests. This makes sure the POST requests are always passed.\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return(pass);\n }\n\n if (req.http.Expect) {\n return(pipe);\n }\n\n if (req.http.If-None-Match && !req.http.If-Modified-Since) {\n return(pass);\n }\n\n \/* Do not cache other authorized content by default *\/\n if (req.http.Authenticate || req.http.Authorization) {\n return(pass);\n }\n\n if (req.url ~ \"@@registration|@@login|@@resetpassword\") {\n return(pass);\n }\n\n if (req.url ~ \"^[^?]*\\.(css|js|png|gif|jpeg|jpg|woff|woff2)(\\?.*)?$\") {\n unset req.http.Cookie;\n }\n\n if (req.http.Cookie && req.http.Cookie ~ \"auth_tkt\") {\n return(pass);\n }\n\n unset req.http.Accept-Encoding;\n\n return(hash);\n}\n\nsub vcl_pipe {\n # By default Connection: close is set on all piped requests, to stop\n # connection reuse from sending future requests directly to the\n # (potentially) wrong backend. If you do want this to happen, you can undo\n # it here.\n # unset bereq.http.connection;\n\n return(pipe);\n}\n\nsub vcl_pass {\n return (fetch);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n if (req.http.X-Forwarded-Proto) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n return (lookup);\n}\n\nsub vcl_purge {\n return (synth(200, \"Purged\"));\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n \/\/ A pure unadultered hit, deliver it\n # normal hit\n return (deliver);\n }\n\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n if (obj.ttl + obj.grace > 0s) {\n set req.http.grace = \"normal(limited)\";\n return (deliver);\n }\n\n if (req.method == \"PURGE\") {\n set req.method = \"GET\";\n set req.http.X-purger = \"Purged\";\n return(synth(200, \"Purged. in hit \" + req.url));\n }\n\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\nsub vcl_miss {\n if (req.method == \"PURGE\") {\n set req.method = \"GET\";\n set req.http.X-purger = \"Purged-possibly\";\n return(synth(200, \"Purged. in miss \" + req.url));\n }\n\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\nsub vcl_backend_fetch{\n return (fetch);\n}\n\nsub vcl_backend_response {\n # The object is not cacheable\n if (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO - Set Cookie\";\n set beresp.ttl = 0s;\n set beresp.uncacheable = true;\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO - Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = 120s;\n } elsif (beresp.http.Surrogate-control ~ \"no-store\") {\n set beresp.http.X-Cacheable = \"NO - Surrogate-control=no-store\";\n set beresp.uncacheable = true;\n set beresp.ttl = 120s;\n } elsif (!beresp.http.Surrogate-Control && beresp.http.Cache-Control ~ \"no-cache|no-store\") {\n set beresp.http.X-Cacheable = \"NO - Cache-Control=no-cache|no-store\";\n set beresp.uncacheable = true;\n set beresp.ttl = 120s;\n } elsif (beresp.http.Vary == \"*\") {\n set beresp.http.X-Cacheable = \"NO - Vary=*\";\n set beresp.uncacheable = true;\n set beresp.ttl = 120s;\n\n\n # ttl handling\n } elsif (beresp.ttl < 0s) {\n set beresp.http.X-Cacheable = \"NO - TTL < 0\";\n set beresp.uncacheable = true;\n } elsif (beresp.ttl == 0s) {\n if (bereq.http.Cookie && bereq.http.Cookie ~ \"auth_tkt\") {\n set beresp.http.X-Cacheable = \"NO - TTL = 0\";\n set beresp.uncacheable = true;\n } else {\n set beresp.http.X-Cacheable = \"YES, 3600s\";\n set beresp.ttl = 3600s;\n set beresp.grace = 36000s;\n }\n\n # Varnish determined the object was cacheable\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n\n# https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleLongerCaching\n if (beresp.ttl == 31536000s) { # for deform.js, jquery.form-3.09.js from deformstatic\n \/* Remove Expires from backend, it's too long *\/\n unset beresp.http.expires;\n\n \/* Set the clients TTL on this object *\/\n set beresp.http.cache-control = \"max-age=86400\";\n\n \/* Set how long Varnish will keep it *\/\n set beresp.ttl = 86400s;\n }\n\n # Do not cache 5xx errors\n if (beresp.status >= 500 && beresp.status < 600) {\n unset beresp.http.Cache-Control;\n set beresp.http.X-Cache = \"NOCACHE\";\n set beresp.http.Cache-Control = \"no-cache, max-age=0, must-revalidate\";\n set beresp.ttl = 0s;\n set beresp.http.Pragma = \"no-cache\";\n set beresp.uncacheable = true;\n return(deliver);\n }\n\n return (deliver);\n}\n\nsub vcl_deliver {\n set resp.http.grace = req.http.grace;\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n \/* Rewrite s-maxage to exclude from intermediary proxies\n (to cache *everywhere*, just use 'max-age' token in the response to avoid\n this override) *\/\n if (resp.http.Cache-Control ~ \"s-maxage\") {\n set resp.http.Cache-Control = regsub(resp.http.Cache-Control, \"s-maxage=[0-9]+\", \"s-maxage=0\");\n }\n \/* Remove proxy-revalidate for intermediary proxies *\/\n if (resp.http.Cache-Control ~ \", proxy-revalidate\") {\n set resp.http.Cache-Control = regsub(resp.http.Cache-Control, \", proxy-revalidate\", \"\");\n }\n\n unset resp.http.Server;\n\n}\n\n\/*\n We can come here \"invisibly\" with the following errors: 413, 417 & 503\n*\/\nsub vcl_synth {\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n set resp.http.Retry-After = \"5\";\n\n synthetic( {\"\n <?xml version=\"1.0\" encoding=\"utf-8\"?>\n <!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n <html>\n <head>\n <title>Varnish cache server: \"} + resp.status + \" \" + resp.reason + {\" <\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n <\/html>\n \"} );\n\n return (deliver);\n}\n","returncode":0,"stderr":"","license":"agpl-3.0","lang":"VCL"} {"commit":"d3d6ca2b0eb0257e6d1b00354c87c26a4041f4cd","subject":"Added ansible_managed tags to template files.","message":"Added ansible_managed tags to template files.\n","repos":"gotofbi\/ansible-varnish,kkwoker\/ansible-varnish,noqcks\/ansible-varnish,killerwails\/ansible-varnish,killerwails\/ansible-varnish,telusdigital\/ansible-varnish,gotofbi\/ansible-varnish,colstrom\/ansible-varnish","old_file":"templates\/etc\/varnish\/default.vcl","new_file":"templates\/etc\/varnish\/default.vcl","new_contents":"vcl 4.0;\n\n# {{ ansible_managed }}\n\nimport directors;\nimport std;\n\n###\n# Varnish Documentation\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-built-in-subs.html\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/reference\/vcl.html\n##\n\n{% for backend in varnish_backend_hosts %}\nbackend application_{{ loop.index }} {\n .host = \"{{ backend }}\";\n .port = \"{{ varnish_backend_port }}\";\n{% if varnish_health_checks_enabled %}\n .probe = {\n .url = \"{{ varnish_health_check_url }}\";\n .interval = {{ varnish_health_check_interval }};\n .timeout = {{ varnish_health_check_timeout }};\n .window = {{ varnish_health_check_window }};\n .threshold = {{ varnish_health_check_threshold }};\n }\n{% endif %}\n}\n{% endfor %}\n\n###\n# vcl_init\n# Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n###\n# The vcl_init subroutine may terminate with calling return() with one of the following keywords:\n#\n# ok\n# Normal return, VCL continues loading.\n##\n\nsub vcl_init {\n new application = directors.round_robin();\n{% for backend in varnish_backend_hosts %}\n application.add_backend(application_{{ loop.index }});\n{% endfor %}\n}\n\n###\n# vcl_recv\n# Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use. \n# It is also used to modify the request\n###\n# The vcl_recv subroutine may terminate with calling return() on one of the following keywords:\n#\n# synth(status code, reason)\n# Return a synthetic object with the specified status code to the client and abandon the request.\n# pass\n# Switch to pass mode. Control will eventually pass to vcl_pass.\n# pipe\n# Switch to pipe mode. Control will eventually pass to vcl_pipe.\n# hash\n# Continue processing the object as a potential candidate for caching. Passes the control over to vcl_hash.\n# purge\n# Purge the object and it's variants. Control passes through vcl_hash to vcl_purge.\n#\n\nsub vcl_recv {\n set req.backend_hint = application.backend();\n\n ###\n # Avoid processing uncacheable requests\n ###\n\n if (req.http.Authorization) {\n set req.http.X-Passthrough-Reason = \"No Caching Authenticated Content\";\n return (pass);\n }\n\n{% if varnish_uri_blacklist_enabled %}\n if ((req.url ~ \"{{ varnish_uri_blacklist_regexp }}\")) {\n set req.http.X-Passthrough-Reason = \"Path in Blacklist\";\n return(pass);\n }\n{% endif %}\n\n{% if varnish_diagnostic_headers_forwarded_for %}\n ###\n # Inject X-Forwarded-For headers, but only once.\n ###\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_enabled %}\n ###\n # Cookie Sanitization\n ###\n if (req.http.Cookie) {\n set req.http.X-Cookie-Unmodified = req.http.Cookie;\n\n {% for cookie in varnish_cookie_sanitization_blacklist %}\n# set req.http.Cookie = regsuball(req.http.Cookie, \"{{ cookie }}=[^;]+(; )?\", \"\");\n {% endfor %}\n\n ### General Cleanup\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n if (req.http.Cookie ~ \"^\\s*$\") {\n set req.http.X-Cookie-Discarded = \"YES:Empty\";\n unset req.http.Cookie;\n }\n if (req.http.Cookie) {\n set req.http.X-Cookie-Sanitized = req.http.Cookie;\n }\n }\n{% endif %}\n\n{% if varnish_header_sanitization_enabled %}\n ###\n # Header Sanitization\n ###\n\n{% if varnish_header_sanitization_discard_host_port %}\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n{% endif %}\n\n{% if varnish_header_sanitization_normalize_accept_encoding %}\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n{% endif %}\n\n{% endif %}\n\n{% if varnish_uri_sanitization_enabled %}\n ###\n # URI Sanitization\n ###\n \n if (req.url ~ \"(\\?|&){{ varnish_uri_sanitization_regexp }}=\") {\n set req.url = regsuball(req.url, \"&{{ varnish_uri_sanitization_regexp }}=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?{{ varnish_uri_sanitization_regexp }}=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n{% endif %}\n\n{% if varnish_workaround_telusdotcom_browser_profile %}\n ###\n # Workaround and Diagnostics for BrowserProfile and Language\/Region Detection on TELUS.com\n ###\n\n if (req.http.Cookie ~ \"BrowserProfile\") {\n set req.http.X-BrowserProfile = regsuball(req.http.Cookie, \"(.*)BrowserProfile=([^;]*)(.*)\", \"\\2\");\n if (req.http.X-BrowserProfile ~ \"language\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.X-BrowserProfile, \"(.*)language\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n set req.http.X-Language-Found = \"YES:BrowserProfile\";\n }\n if (req.http.X-BrowserProfile ~ \"region\") {\n set req.http.X-Region = std.tolower(regsuball(regsuball(req.http.X-BrowserProfile, \"geo\\\\.\\:{(.*)\\}\", \"\"), \"(.*)region\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n set req.http.X-Region-Found = \"YES:BrowserProfile\";\n }\n if (req.http.X-BrowserProfile ~ \"geo\") {\n set req.http.X-Geolocation = regsuball(req.http.X-BrowserProfile, \"(.*)geo..:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n set req.http.X-Geolocation-Found = \"YES:BrowserProfile\";\n\n if (req.http.X-Geolocation ~ \"country\") {\n set req.http.X-Geolocation-Country = regsuball(req.http.X-Geolocation, \"(.*)country\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-Geolocation ~ \"region\") {\n set req.http.X-Geolocation-Region = regsuball(req.http.X-Geolocation, \"(.*)region\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-Geolocation ~ \"city\") {\n set req.http.X-Geolocation-City = regsuball(req.http.X-Geolocation, \"(.*)city\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-Geolocation ~ \"isp\") {\n set req.http.X-Geolocation-ISP = regsuball(req.http.X-Geolocation, \"(.*)isp\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n } else {\n set req.http.X-Geolocation-Found = \"NO\";\n }\n }\n\n if (!req.http.X-Language) {\n if (req.http.Cookie ~ \"lang=\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.Cookie, \"(.*)lang=([^;]*)(.*)\", \"\\2\"));\n set req.http.X-Language-Found = \"YES:lang\";\n } else {\n set req.http.X-Language = \"en\";\n set req.http.X-Language-Found = \"NO\";\n }\n }\n\n if (!req.http.X-Region) {\n if (req.http.Cookie ~ \"prov=\") {\n set req.http.X-Region = std.tolower(regsuball(req.http.Cookie, \"(.*)prov=([^;]*)(.*)\", \"\\2\"));\n set req.http.X-Region-Found = \"YES:prov\";\n } else {\n set req.http.X-Region = \"bc\";\n set req.http.X-Region-Found = \"NO\";\n }\n }\n\n\n if (req.url ~ \"\/(en|fr)\/\") {\n if (req.url ~ \"\/en\/\" && req.http.X-Language != \"en\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Language (Path: \/en\/) vs (Cookie: \" + req.http.X-Language + \")\";\n return(pass);\n }\n if (req.url ~ \"\/fr\/\" && req.http.X-Language != \"fr\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Language (Path: \/fr\/) vs (Cookie: \" + req.http.X-Language + \")\";\n return(pass);\n }\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Language)\";\n return(pass);\n }\n\n if (req.url ~ \"\/(ab|bc|mb|nb|nl|ns|nt|nu|on|pe|qc|sk|yt)\/\") {\n {% for province in ['ab', 'bc', 'mb', 'nb', 'nl', 'ns', 'nt', 'nu', 'on', 'pe', 'qc', 'sk', 'yt'] %}\n if (req.url ~ \"\/{{ province }}\/\" && req.http.X-Region != \"{{ province }}\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Region (Path: \/{{ province }}\/) vs (Cookie: \" + req.http.X-Region + \")\";\n return(pass);\n }\n {% endfor %}\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Province)\";\n return(pass);\n }\n\n if (req.http.Cookie) {\n if (req.http.Cookie ~ \"***REMOVED***\") {\n set req.http.X-Screen-Resolution = regsuball(req.http.Cookie, \"(.*)***REMOVED***=([^;]*)(.*)\", \"\\2\");\n }\n\n if (req.http.Cookie ~ \"***REMOVED***\") {\n set req.http.X-Customer-Type = regsuball(req.http.Cookie, \"(.*)***REMOVED***=([^;]*)(.*)\", \"\\2\");\n }\n if (req.http.Cookie ~ \"***REMOVED***\") {\n set req.http.X-Outdated-Browser = regsuball(req.http.Cookie, \"(.*)***REMOVED***=([^;]*)(.*)\", \"\\2\");\n }\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_discard_from_client %}\n set req.http.X-Cookie-Discarded = \"YES:No Reason Not To\";\n unset req.http.Cookie;\n{% endif %}\n}\n\n###\n# vcl_hit\n# Called when a cache lookup is successful.\n###\n# The vcl_hit subroutine may terminate with calling return() with one of the following keywords:\n#\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n# deliver\n# Deliver the object. Control passes to vcl_deliver.\n# synth(status code, reason)\n# Return the specified status code to the client and abandon the request.\n###\n\nsub vcl_hit {\n if (obj.ttl > 0s) {\n return (deliver);\n }\n{% if varnish_health_checks_enabled %}\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (fetch);\n }\n{% else %}\n if (obj.ttl + obj.grace > 0s) {\n return (deliver);\n }\n\n return (fetch);\n{% endif %}\n}\n\n###\n# vcl_backend_response\n# Called after the response headers has been successfully retrieved from the backend.\n###\n# The vcl_backend_response subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Possibly insert the object into the cache, then deliver it to the Control will eventually pass to vcl_deliver.\n# abandon\n# Abandon the backend request and generates an error.\n# retry\n# Retry the backend transaction. Increases the retries counter. If the number of retries is higher than max_retries Varnish emits a guru meditation error.\n###\n\nsub vcl_backend_response {\n{% if varnish_workaround_telusdotcom_browser_profile %}\n if (bereq.http.X-Language) {\n set beresp.http.X-Language = bereq.http.X-Language;\n# if (bereq.http.X-Language-Found) {\n# set beresp.http.X-Language-Found = bereq.http.X-Language-Found;\n# }\n }\n if (bereq.http.X-Region) {\n set beresp.http.X-Region = bereq.http.X-Region;\n# if (bereq.http.X-Region-Found) {\n# set beresp.http.X-Region-Found = bereq.http.X-Region-Found;\n# }\n }\n{% endif %}\n\n{% if varnish_uri_blacklist_enabled %}\n if (bereq.url ~ \"{{ varnish_uri_blacklist_regexp }}\") {\n set beresp.http.X-Cacheable = \"NO:Path in Blacklist\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n if (bereq.http.X-Passthrough-Reason) {\n{% if varnish_diagnostic_headers_passthrough_reason %}\n set beresp.http.X-Passthrough-Reason = bereq.http.X-Passthrough-Reason;\n{% endif %}\n return(deliver);\n } else {\n{% if varnish_cookie_sanitization_discard_from_server %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n }\n }\n{% else %}\n{% if varnish_cookie_sanitization_discard_from_server %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n{% endif %}\n\n{% if varnish_diagnostic_headers_enabled %}\n if (bereq.http.Cookie) {\n set beresp.http.X-Cacheable = \"NO:Cookie in Request\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO:Set-Cookie in Response\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.X-No-Cache) {\n set beresp.http.X-Cacheable = \"NO:X-No-Cache\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.ttl <= 0s) {\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n{% endif %}\n\n set beresp.grace = {{ varnish_grace_period }};\n}\n\n###\n# vcl_deliver\n# Called before a cached object is delivered to the client.\n###\n# The vcl_deliver subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Deliver the object to the client.\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n###\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n","old_contents":"vcl 4.0;\n\nimport directors;\nimport std;\n\n###\n# Varnish Documentation\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-built-in-subs.html\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/reference\/vcl.html\n##\n\n{% for backend in varnish_backend_hosts %}\nbackend application_{{ loop.index }} {\n .host = \"{{ backend }}\";\n .port = \"{{ varnish_backend_port }}\";\n{% if varnish_health_checks_enabled %}\n .probe = {\n .url = \"{{ varnish_health_check_url }}\";\n .interval = {{ varnish_health_check_interval }};\n .timeout = {{ varnish_health_check_timeout }};\n .window = {{ varnish_health_check_window }};\n .threshold = {{ varnish_health_check_threshold }};\n }\n{% endif %}\n}\n{% endfor %}\n\n###\n# vcl_init\n# Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n###\n# The vcl_init subroutine may terminate with calling return() with one of the following keywords:\n#\n# ok\n# Normal return, VCL continues loading.\n##\n\nsub vcl_init {\n new application = directors.round_robin();\n{% for backend in varnish_backend_hosts %}\n application.add_backend(application_{{ loop.index }});\n{% endfor %}\n}\n\n###\n# vcl_recv\n# Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use. \n# It is also used to modify the request\n###\n# The vcl_recv subroutine may terminate with calling return() on one of the following keywords:\n#\n# synth(status code, reason)\n# Return a synthetic object with the specified status code to the client and abandon the request.\n# pass\n# Switch to pass mode. Control will eventually pass to vcl_pass.\n# pipe\n# Switch to pipe mode. Control will eventually pass to vcl_pipe.\n# hash\n# Continue processing the object as a potential candidate for caching. Passes the control over to vcl_hash.\n# purge\n# Purge the object and it's variants. Control passes through vcl_hash to vcl_purge.\n#\n\nsub vcl_recv {\n set req.backend_hint = application.backend();\n\n ###\n # Avoid processing uncacheable requests\n ###\n\n if (req.http.Authorization) {\n set req.http.X-Passthrough-Reason = \"No Caching Authenticated Content\";\n return (pass);\n }\n\n{% if varnish_uri_blacklist_enabled %}\n if ((req.url ~ \"{{ varnish_uri_blacklist_regexp }}\")) {\n set req.http.X-Passthrough-Reason = \"Path in Blacklist\";\n return(pass);\n }\n{% endif %}\n\n{% if varnish_diagnostic_headers_forwarded_for %}\n ###\n # Inject X-Forwarded-For headers, but only once.\n ###\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_enabled %}\n ###\n # Cookie Sanitization\n ###\n if (req.http.Cookie) {\n set req.http.X-Cookie-Unmodified = req.http.Cookie;\n\n {% for cookie in varnish_cookie_sanitization_blacklist %}\n# set req.http.Cookie = regsuball(req.http.Cookie, \"{{ cookie }}=[^;]+(; )?\", \"\");\n {% endfor %}\n\n ### General Cleanup\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n if (req.http.Cookie ~ \"^\\s*$\") {\n set req.http.X-Cookie-Discarded = \"YES:Empty\";\n unset req.http.Cookie;\n }\n if (req.http.Cookie) {\n set req.http.X-Cookie-Sanitized = req.http.Cookie;\n }\n }\n{% endif %}\n\n{% if varnish_header_sanitization_enabled %}\n ###\n # Header Sanitization\n ###\n\n{% if varnish_header_sanitization_discard_host_port %}\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n{% endif %}\n\n{% if varnish_header_sanitization_normalize_accept_encoding %}\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n{% endif %}\n\n{% endif %}\n\n{% if varnish_uri_sanitization_enabled %}\n ###\n # URI Sanitization\n ###\n \n if (req.url ~ \"(\\?|&){{ varnish_uri_sanitization_regexp }}=\") {\n set req.url = regsuball(req.url, \"&{{ varnish_uri_sanitization_regexp }}=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?{{ varnish_uri_sanitization_regexp }}=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n{% endif %}\n\n{% if varnish_workaround_telusdotcom_browser_profile %}\n ###\n # Workaround and Diagnostics for BrowserProfile and Language\/Region Detection on TELUS.com\n ###\n\n if (req.http.Cookie ~ \"BrowserProfile\") {\n set req.http.X-BrowserProfile = regsuball(req.http.Cookie, \"(.*)BrowserProfile=([^;]*)(.*)\", \"\\2\");\n if (req.http.X-BrowserProfile ~ \"language\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.X-BrowserProfile, \"(.*)language\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n set req.http.X-Language-Found = \"YES:BrowserProfile\";\n }\n if (req.http.X-BrowserProfile ~ \"region\") {\n set req.http.X-Region = std.tolower(regsuball(regsuball(req.http.X-BrowserProfile, \"geo\\\\.\\:{(.*)\\}\", \"\"), \"(.*)region\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n set req.http.X-Region-Found = \"YES:BrowserProfile\";\n }\n if (req.http.X-BrowserProfile ~ \"geo\") {\n set req.http.X-Geolocation = regsuball(req.http.X-BrowserProfile, \"(.*)geo..:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n set req.http.X-Geolocation-Found = \"YES:BrowserProfile\";\n\n if (req.http.X-Geolocation ~ \"country\") {\n set req.http.X-Geolocation-Country = regsuball(req.http.X-Geolocation, \"(.*)country\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-Geolocation ~ \"region\") {\n set req.http.X-Geolocation-Region = regsuball(req.http.X-Geolocation, \"(.*)region\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-Geolocation ~ \"city\") {\n set req.http.X-Geolocation-City = regsuball(req.http.X-Geolocation, \"(.*)city\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-Geolocation ~ \"isp\") {\n set req.http.X-Geolocation-ISP = regsuball(req.http.X-Geolocation, \"(.*)isp\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n } else {\n set req.http.X-Geolocation-Found = \"NO\";\n }\n }\n\n if (!req.http.X-Language) {\n if (req.http.Cookie ~ \"lang=\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.Cookie, \"(.*)lang=([^;]*)(.*)\", \"\\2\"));\n set req.http.X-Language-Found = \"YES:lang\";\n } else {\n set req.http.X-Language = \"en\";\n set req.http.X-Language-Found = \"NO\";\n }\n }\n\n if (!req.http.X-Region) {\n if (req.http.Cookie ~ \"prov=\") {\n set req.http.X-Region = std.tolower(regsuball(req.http.Cookie, \"(.*)prov=([^;]*)(.*)\", \"\\2\"));\n set req.http.X-Region-Found = \"YES:prov\";\n } else {\n set req.http.X-Region = \"bc\";\n set req.http.X-Region-Found = \"NO\";\n }\n }\n\n\n if (req.url ~ \"\/(en|fr)\/\") {\n if (req.url ~ \"\/en\/\" && req.http.X-Language != \"en\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Language (Path: \/en\/) vs (Cookie: \" + req.http.X-Language + \")\";\n return(pass);\n }\n if (req.url ~ \"\/fr\/\" && req.http.X-Language != \"fr\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Language (Path: \/fr\/) vs (Cookie: \" + req.http.X-Language + \")\";\n return(pass);\n }\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Language)\";\n return(pass);\n }\n\n if (req.url ~ \"\/(ab|bc|mb|nb|nl|ns|nt|nu|on|pe|qc|sk|yt)\/\") {\n {% for province in ['ab', 'bc', 'mb', 'nb', 'nl', 'ns', 'nt', 'nu', 'on', 'pe', 'qc', 'sk', 'yt'] %}\n if (req.url ~ \"\/{{ province }}\/\" && req.http.X-Region != \"{{ province }}\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Region (Path: \/{{ province }}\/) vs (Cookie: \" + req.http.X-Region + \")\";\n return(pass);\n }\n {% endfor %}\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Province)\";\n return(pass);\n }\n\n if (req.http.Cookie) {\n if (req.http.Cookie ~ \"***REMOVED***\") {\n set req.http.X-Screen-Resolution = regsuball(req.http.Cookie, \"(.*)***REMOVED***=([^;]*)(.*)\", \"\\2\");\n }\n\n if (req.http.Cookie ~ \"***REMOVED***\") {\n set req.http.X-Customer-Type = regsuball(req.http.Cookie, \"(.*)***REMOVED***=([^;]*)(.*)\", \"\\2\");\n }\n if (req.http.Cookie ~ \"***REMOVED***\") {\n set req.http.X-Outdated-Browser = regsuball(req.http.Cookie, \"(.*)***REMOVED***=([^;]*)(.*)\", \"\\2\");\n }\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_discard_from_client %}\n set req.http.X-Cookie-Discarded = \"YES:No Reason Not To\";\n unset req.http.Cookie;\n{% endif %}\n}\n\n###\n# vcl_hit\n# Called when a cache lookup is successful.\n###\n# The vcl_hit subroutine may terminate with calling return() with one of the following keywords:\n#\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n# deliver\n# Deliver the object. Control passes to vcl_deliver.\n# synth(status code, reason)\n# Return the specified status code to the client and abandon the request.\n###\n\nsub vcl_hit {\n if (obj.ttl > 0s) {\n return (deliver);\n }\n{% if varnish_health_checks_enabled %}\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (fetch);\n }\n{% else %}\n if (obj.ttl + obj.grace > 0s) {\n return (deliver);\n }\n\n return (fetch);\n{% endif %}\n}\n\n###\n# vcl_backend_response\n# Called after the response headers has been successfully retrieved from the backend.\n###\n# The vcl_backend_response subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Possibly insert the object into the cache, then deliver it to the Control will eventually pass to vcl_deliver.\n# abandon\n# Abandon the backend request and generates an error.\n# retry\n# Retry the backend transaction. Increases the retries counter. If the number of retries is higher than max_retries Varnish emits a guru meditation error.\n###\n\nsub vcl_backend_response {\n{% if varnish_workaround_telusdotcom_browser_profile %}\n if (bereq.http.X-Language) {\n set beresp.http.X-Language = bereq.http.X-Language;\n# if (bereq.http.X-Language-Found) {\n# set beresp.http.X-Language-Found = bereq.http.X-Language-Found;\n# }\n }\n if (bereq.http.X-Region) {\n set beresp.http.X-Region = bereq.http.X-Region;\n# if (bereq.http.X-Region-Found) {\n# set beresp.http.X-Region-Found = bereq.http.X-Region-Found;\n# }\n }\n{% endif %}\n\n{% if varnish_uri_blacklist_enabled %}\n if (bereq.url ~ \"{{ varnish_uri_blacklist_regexp }}\") {\n set beresp.http.X-Cacheable = \"NO:Path in Blacklist\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n if (bereq.http.X-Passthrough-Reason) {\n{% if varnish_diagnostic_headers_passthrough_reason %}\n set beresp.http.X-Passthrough-Reason = bereq.http.X-Passthrough-Reason;\n{% endif %}\n return(deliver);\n } else {\n{% if varnish_cookie_sanitization_discard_from_server %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n }\n }\n{% else %}\n{% if varnish_cookie_sanitization_discard_from_server %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n{% endif %}\n\n{% if varnish_diagnostic_headers_enabled %}\n if (bereq.http.Cookie) {\n set beresp.http.X-Cacheable = \"NO:Cookie in Request\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO:Set-Cookie in Response\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.X-No-Cache) {\n set beresp.http.X-Cacheable = \"NO:X-No-Cache\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.ttl <= 0s) {\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n{% endif %}\n\n set beresp.grace = {{ varnish_grace_period }};\n}\n\n###\n# vcl_deliver\n# Called before a cached object is delivered to the client.\n###\n# The vcl_deliver subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Deliver the object to the client.\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n###\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"f314e813d1c6a6e4eb84a9f627c6d351d7f87a11","subject":"Fixed underscore cookie match in varnish vcl","message":"Fixed underscore cookie match in varnish vcl\n\nFixes #84\n","repos":"evolution\/genesis-wordpress,genesis\/wordpress,evolution\/genesis-wordpress,jalevin\/wordpress,jalevin\/wordpress,evolution\/wordpress,jalevin\/wordpress,evolution\/genesis-wordpress,evolution\/genesis-wordpress,jalevin\/wordpress,evolution\/wordpress,genesis\/wordpress,genesis\/wordpress,evolution\/wordpress,genesis\/wordpress,evolution\/wordpress,genesis\/wordpress,evolution\/genesis-wordpress,evolution\/wordpress,jalevin\/wordpress,genesis\/wordpress,evolution\/genesis-wordpress","old_file":"provisioning\/roles\/varnish\/files\/etc-varnish\/production.vcl","new_file":"provisioning\/roles\/varnish\/files\/etc-varnish\/production.vcl","new_contents":"# Default backend definition. Set this to point to your content server.\n# all paths relative to varnish option vcl_dir\n\ninclude \"custom.backend.vcl\";\ninclude \"custom.acl.vcl\";\n\n# Handle the HTTP request received by the client\nsub vcl_recv {\n # varnish serves stale (but cacheable) objects while retriving object from backend\n if (req.backend.healthy) {\n set req.grace = 30s;\n } else {\n set req.grace = 1h;\n }\n\n # shortcut for DFind requests\n if (req.url ~ \"^\/w00tw00t\") {\n error 404 \"Not Found\";\n }\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n # Normalize the header, remove the port (in case you're testing this on various TCP ports)\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n # Allow purging\n if (req.request == \"PURGE\") {\n if (!client.ip ~ purge) {\n # Not from an allowed IP? Then die with an error.\n error 405 \"This IP is not allowed to send PURGE requests.\";\n }\n\n # If you got this stage (and didn't error out above), do a cache-lookup\n # That will force entry into vcl_hit() or vcl_miss() below and purge the actual cache\n return (lookup);\n }\n\n # Only deal with \"normal\" types\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"PATCH\" &&\n req.request != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n # We only deal with GET and HEAD by default\n return (pass);\n }\n\n # Some generic URL manipulation, useful for all templates that follow\n # First remove the Google Analytics added parameters, useless for our backend\n if (req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=\") {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # Strip hash, server doesn't need it.\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n # Strip a trailing ? if it exists\n if (req.url ~ \"\\?$\") {\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # This is an example to redirect with a 301\/302 HTTP status code from within Varnish\n # if (req.http.Host ~ \"secure.mysite.tld\") {\n # # We may want to force our users from the secure site to the HTTPs version?\n # error 720 \"https:\/\/secure.mysite.tld\";\n # # If you want to keep the URLs intact, this also works:\n # error 720 \"https:\/\/\" + req.http.Host + req.url;\n # }\n #\n # Or to force a 302 temporary redirect, use error 721\n # if (req.http.Host ~ \"temp.mysite.tld\") {\n # # Temporary redirect\n # error 721 \"http:\/\/mysite.tld\/temp\";\n # }\n #\n\n # Some generic cookie manipulation, useful for all templates that follow\n\n # Remove any '_' prefixed cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"(^|;\\s*)_[^=]+=[^;]*\", \"\");\n\n # Remove a \";\" prefix in the cookie if present\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n\n # Are there cookies left with only spaces or that are empty?\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n\n # Normalize Accept-Encoding header\n # straight from the manual: https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/vary.html\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n # No point in compressing these\n remove req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n # unkown algorithm\n remove req.http.Accept-Encoding;\n }\n }\n\n # Include custom vcl_recv logic\n include \"conf.d\/receive\/wordpress.vcl\";\n\n # Remove all cookies for static files\n # A valid discussion could be held on this line: do you really need to cache static files that don't cause load? Only if you have memory left.\n # Sure, there's disk I\/O, but chances are your OS will already have these files in their buffers (thus memory).\n # Before you blindly enable this, have a read here: http:\/\/mattiasgeniar.be\/2012\/11\/28\/stop-caching-static-files\/\n # if (req.url ~ \"^[^?]*\\.(bmp|bz2|css|doc|eot|flv|gif|gz|ico|jpeg|jpg|js|less|mp[34]|pdf|png|rar|rtf|swf|tar|tgz|txt|wav|woff|xml|zip)(\\?.*)?$\") {\n # unset req.http.Cookie;\n # return (lookup);\n # }\n\n # Send Surrogate-Capability headers to announce ESI support to backend\n set req.http.Surrogate-Capability = \"key=ESI\/1.0\";\n\n if (req.http.Authorization || req.http.Cookie) {\n # Not cacheable by default\n return (pass);\n }\n\n return (lookup);\n}\n\nsub vcl_pipe {\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n # set bereq.http.connection = \"close\";\n # here. It is not set by default as it might break some broken web\n # applications, like IIS with NTLM authentication.\n\n #set bereq.http.Connection = \"Close\";\n return (pipe);\n}\n\nsub vcl_pass {\n return (pass);\n}\n\n# The data on which the hashing will take place\nsub vcl_hash {\n hash_data(req.url);\n\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n\n # hash cookies for object with auth\n if (req.http.Cookie) {\n hash_data(req.http.Cookie);\n }\n if (req.http.Authorization) {\n hash_data(req.http.Authorization);\n }\n\n return (hash);\n}\n\nsub vcl_hit {\n # Allow purges\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"purged\";\n }\n\n return (deliver);\n}\n\nsub vcl_miss {\n # Allow purges\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"purged\";\n }\n\n return (fetch);\n}\n\n# Handle the HTTP request coming from our backend\nsub vcl_fetch {\n set beresp.grace = 1h;\n\n # Include custom vcl_fetch logic\n include \"conf.d\/fetch\/wordpress.vcl\";\n\n # Parse ESI request and remove Surrogate-Control header\n if (beresp.http.Surrogate-Control ~ \"ESI\/1.0\") {\n unset beresp.http.Surrogate-Control;\n set beresp.do_esi = true;\n }\n\n # If the request to the backend returns a code is 5xx, restart the loop\n # If the number of restarts reaches the value of the parameter max_restarts,\n # the request will be error'ed. max_restarts defaults to 4. This prevents\n # an eternal loop in the event that, e.g., the object does not exist at all.\n if (beresp.status >= 500 && beresp.status <= 599){\n return(restart);\n }\n\n # Enable cache for all static files\n # The same argument as the static caches from above: monitor your cache size, if you get data nuked out of it, consider giving up the static file cache.\n # Before you blindly enable this, have a read here: http:\/\/mattiasgeniar.be\/2012\/11\/28\/stop-caching-static-files\/\n # if (req.url ~ \"^[^?]*\\.(bmp|bz2|css|doc|eot|flv|gif|gz|ico|jpeg|jpg|js|less|mp[34]|pdf|png|rar|rtf|swf|tar|tgz|txt|wav|woff|xml|zip)(\\?.*)?$\") {\n # unset beresp.http.set-cookie;\n # }\n\n # Sometimes, a 301 or 302 redirect formed via Apache's mod_rewrite can mess with the HTTP port that is being passed along.\n # This often happens with simple rewrite rules in a scenario where Varnish runs on :80 and Apache on :8080 on the same box.\n # A redirect can then often redirect the end-user to a URL on :8080, where it should be :80.\n # This may need finetuning on your setup.\n #\n # To prevent accidental replace, we only filter the 301\/302 redirects for now.\n if (beresp.status == 301 || beresp.status == 302) {\n set beresp.http.Location = regsub(beresp.http.Location, \":[0-9]+\", \"\");\n }\n\n # Don't cache user & server errors\n if (beresp.status >= 400) {\n return (hit_for_pass);\n }\n\n # Non private responses without cookies and with a ttl of 0 should be artificially extended to 1 hour\n if (beresp.ttl <= 0s && beresp.http.Cache-Control !~ \"private\" && (!beresp.http.Set-Cookie)) {\n set beresp.ttl = 1h;\n set beresp.http.X-Cache-Extended = \"1\";\n }\n\n # Set 2min cache if unset for static files\n if (beresp.ttl <= 0s || beresp.http.Set-Cookie || beresp.http.Vary == \"*\") {\n set beresp.ttl = 120s;\n return (hit_for_pass);\n }\n\n return (deliver);\n}\n\n# The routine when we deliver the HTTP request to the user\n# Last chance to modify headers that are sent to the client\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"cached\";\n } else {\n set resp.http.x-Cache = \"uncached\";\n }\n\n # Remove some headers: PHP version\n unset resp.http.X-Powered-By;\n\n # Remove some headers: Apache version & OS\n unset resp.http.Server;\n unset resp.http.X-Drupal-Cache;\n unset resp.http.X-Varnish;\n unset resp.http.Via;\n unset resp.http.Link;\n\n return (deliver);\n}\n\nsub vcl_error {\n if (obj.status == 720) {\n # We use this special error status 720 to force redirects with 301 (permanent) redirects\n # To use this, call the following from anywhere in vcl_recv: error 720 \"http:\/\/host\/new.html\"\n set obj.status = 301;\n set obj.http.Location = obj.response;\n return (deliver);\n } elseif (obj.status == 721) {\n # And we use error status 721 to force redirects with a 302 (temporary) redirect\n # To use this, call the following from anywhere in vcl_recv: error 720 \"http:\/\/host\/new.html\"\n set obj.status = 302;\n set obj.http.Location = obj.response;\n return (deliver);\n }\n\n return (deliver);\n}\n\nsub vcl_init {\n return (ok);\n}\n\nsub vcl_fini {\n return (ok);\n}\n","old_contents":"# Default backend definition. Set this to point to your content server.\n# all paths relative to varnish option vcl_dir\n\ninclude \"custom.backend.vcl\";\ninclude \"custom.acl.vcl\";\n\n# Handle the HTTP request received by the client\nsub vcl_recv {\n # varnish serves stale (but cacheable) objects while retriving object from backend\n if (req.backend.healthy) {\n set req.grace = 30s;\n } else {\n set req.grace = 1h;\n }\n\n # shortcut for DFind requests\n if (req.url ~ \"^\/w00tw00t\") {\n error 404 \"Not Found\";\n }\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n # Normalize the header, remove the port (in case you're testing this on various TCP ports)\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n # Allow purging\n if (req.request == \"PURGE\") {\n if (!client.ip ~ purge) {\n # Not from an allowed IP? Then die with an error.\n error 405 \"This IP is not allowed to send PURGE requests.\";\n }\n\n # If you got this stage (and didn't error out above), do a cache-lookup\n # That will force entry into vcl_hit() or vcl_miss() below and purge the actual cache\n return (lookup);\n }\n\n # Only deal with \"normal\" types\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"PATCH\" &&\n req.request != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n # We only deal with GET and HEAD by default\n return (pass);\n }\n\n # Some generic URL manipulation, useful for all templates that follow\n # First remove the Google Analytics added parameters, useless for our backend\n if (req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=\") {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # Strip hash, server doesn't need it.\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n # Strip a trailing ? if it exists\n if (req.url ~ \"\\?$\") {\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # This is an example to redirect with a 301\/302 HTTP status code from within Varnish\n # if (req.http.Host ~ \"secure.mysite.tld\") {\n # # We may want to force our users from the secure site to the HTTPs version?\n # error 720 \"https:\/\/secure.mysite.tld\";\n # # If you want to keep the URLs intact, this also works:\n # error 720 \"https:\/\/\" + req.http.Host + req.url;\n # }\n #\n # Or to force a 302 temporary redirect, use error 721\n # if (req.http.Host ~ \"temp.mysite.tld\") {\n # # Temporary redirect\n # error 721 \"http:\/\/mysite.tld\/temp\";\n # }\n #\n\n # Some generic cookie manipulation, useful for all templates that follow\n\n # Remove any '_' prefixed cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"_[^=]+=[^;]+(; )?\", \"\");\n\n # Remove a \";\" prefix in the cookie if present\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n\n # Are there cookies left with only spaces or that are empty?\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n\n # Normalize Accept-Encoding header\n # straight from the manual: https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/vary.html\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n # No point in compressing these\n remove req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n # unkown algorithm\n remove req.http.Accept-Encoding;\n }\n }\n\n # Include custom vcl_recv logic\n include \"conf.d\/receive\/wordpress.vcl\";\n\n # Remove all cookies for static files\n # A valid discussion could be held on this line: do you really need to cache static files that don't cause load? Only if you have memory left.\n # Sure, there's disk I\/O, but chances are your OS will already have these files in their buffers (thus memory).\n # Before you blindly enable this, have a read here: http:\/\/mattiasgeniar.be\/2012\/11\/28\/stop-caching-static-files\/\n # if (req.url ~ \"^[^?]*\\.(bmp|bz2|css|doc|eot|flv|gif|gz|ico|jpeg|jpg|js|less|mp[34]|pdf|png|rar|rtf|swf|tar|tgz|txt|wav|woff|xml|zip)(\\?.*)?$\") {\n # unset req.http.Cookie;\n # return (lookup);\n # }\n\n # Send Surrogate-Capability headers to announce ESI support to backend\n set req.http.Surrogate-Capability = \"key=ESI\/1.0\";\n\n if (req.http.Authorization || req.http.Cookie) {\n # Not cacheable by default\n return (pass);\n }\n\n return (lookup);\n}\n\nsub vcl_pipe {\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n # set bereq.http.connection = \"close\";\n # here. It is not set by default as it might break some broken web\n # applications, like IIS with NTLM authentication.\n\n #set bereq.http.Connection = \"Close\";\n return (pipe);\n}\n\nsub vcl_pass {\n return (pass);\n}\n\n# The data on which the hashing will take place\nsub vcl_hash {\n hash_data(req.url);\n\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n\n # hash cookies for object with auth\n if (req.http.Cookie) {\n hash_data(req.http.Cookie);\n }\n if (req.http.Authorization) {\n hash_data(req.http.Authorization);\n }\n\n return (hash);\n}\n\nsub vcl_hit {\n # Allow purges\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"purged\";\n }\n\n return (deliver);\n}\n\nsub vcl_miss {\n # Allow purges\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"purged\";\n }\n\n return (fetch);\n}\n\n# Handle the HTTP request coming from our backend\nsub vcl_fetch {\n set beresp.grace = 1h;\n\n # Include custom vcl_fetch logic\n include \"conf.d\/fetch\/wordpress.vcl\";\n\n # Parse ESI request and remove Surrogate-Control header\n if (beresp.http.Surrogate-Control ~ \"ESI\/1.0\") {\n unset beresp.http.Surrogate-Control;\n set beresp.do_esi = true;\n }\n\n # If the request to the backend returns a code is 5xx, restart the loop\n # If the number of restarts reaches the value of the parameter max_restarts,\n # the request will be error'ed. max_restarts defaults to 4. This prevents\n # an eternal loop in the event that, e.g., the object does not exist at all.\n if (beresp.status >= 500 && beresp.status <= 599){\n return(restart);\n }\n\n # Enable cache for all static files\n # The same argument as the static caches from above: monitor your cache size, if you get data nuked out of it, consider giving up the static file cache.\n # Before you blindly enable this, have a read here: http:\/\/mattiasgeniar.be\/2012\/11\/28\/stop-caching-static-files\/\n # if (req.url ~ \"^[^?]*\\.(bmp|bz2|css|doc|eot|flv|gif|gz|ico|jpeg|jpg|js|less|mp[34]|pdf|png|rar|rtf|swf|tar|tgz|txt|wav|woff|xml|zip)(\\?.*)?$\") {\n # unset beresp.http.set-cookie;\n # }\n\n # Sometimes, a 301 or 302 redirect formed via Apache's mod_rewrite can mess with the HTTP port that is being passed along.\n # This often happens with simple rewrite rules in a scenario where Varnish runs on :80 and Apache on :8080 on the same box.\n # A redirect can then often redirect the end-user to a URL on :8080, where it should be :80.\n # This may need finetuning on your setup.\n #\n # To prevent accidental replace, we only filter the 301\/302 redirects for now.\n if (beresp.status == 301 || beresp.status == 302) {\n set beresp.http.Location = regsub(beresp.http.Location, \":[0-9]+\", \"\");\n }\n\n # Don't cache user & server errors\n if (beresp.status >= 400) {\n return (hit_for_pass);\n }\n\n # Non private responses without cookies and with a ttl of 0 should be artificially extended to 1 hour\n if (beresp.ttl <= 0s && beresp.http.Cache-Control !~ \"private\" && (!beresp.http.Set-Cookie)) {\n set beresp.ttl = 1h;\n set beresp.http.X-Cache-Extended = \"1\";\n }\n\n # Set 2min cache if unset for static files\n if (beresp.ttl <= 0s || beresp.http.Set-Cookie || beresp.http.Vary == \"*\") {\n set beresp.ttl = 120s;\n return (hit_for_pass);\n }\n\n return (deliver);\n}\n\n# The routine when we deliver the HTTP request to the user\n# Last chance to modify headers that are sent to the client\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"cached\";\n } else {\n set resp.http.x-Cache = \"uncached\";\n }\n\n # Remove some headers: PHP version\n unset resp.http.X-Powered-By;\n\n # Remove some headers: Apache version & OS\n unset resp.http.Server;\n unset resp.http.X-Drupal-Cache;\n unset resp.http.X-Varnish;\n unset resp.http.Via;\n unset resp.http.Link;\n\n return (deliver);\n}\n\nsub vcl_error {\n if (obj.status == 720) {\n # We use this special error status 720 to force redirects with 301 (permanent) redirects\n # To use this, call the following from anywhere in vcl_recv: error 720 \"http:\/\/host\/new.html\"\n set obj.status = 301;\n set obj.http.Location = obj.response;\n return (deliver);\n } elseif (obj.status == 721) {\n # And we use error status 721 to force redirects with a 302 (temporary) redirect\n # To use this, call the following from anywhere in vcl_recv: error 720 \"http:\/\/host\/new.html\"\n set obj.status = 302;\n set obj.http.Location = obj.response;\n return (deliver);\n }\n\n return (deliver);\n}\n\nsub vcl_init {\n return (ok);\n}\n\nsub vcl_fini {\n return (ok);\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"5add4db0d5e36619f8ee619197beb6a2647a0302","subject":"Remove the match field","message":"Remove the match field\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets\/recv.vcl","new_file":"etc\/vcl_snippets\/recv.vcl","new_contents":" # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n unset req.http.x-long-cache;\n\n # We want to force long cache times on any of the versioned assets\n if (req.url.path ~ \"^\/static\/version\\d*\/\") {\n set req.http.x-long-cache = \"1\";\n }\n \n # User's Cookie may contain some Magento Vary items we should vary on\n if (req.http.cookie:X-Magento-Vary ) {\n set req.http.X-Magento-Vary = req.http.cookie:X-Magento-Vary;\n } else {\n unset req.http.X-Magento-Vary;\n }\n\n ############################################################################################################\n # Following code block controls purge by URL. By default we want to protect all URL purges. In general this\n # is addressed by adding Fastly-Purge-Requires-Auth request header in vcl_recv however this runs the risk of\n # exposing API tokens if user attempts to purge non-https URLs. For this reason inside the Magento module\n # we use X-Purge-Token. Unfortunately this breaks purge from the Fastly UI. Therefore in the next code block\n # we check for presence of X-Purge-Token. If it's not present we force the Fastly-Purge-Requires-Auth\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n if (req.http.X-Purge-Token && req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n } else {\n error 403;\n }\n } else {\n set req.http.Fastly-Purge-Requires-Auth = \"1\";\n }\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (req.http.Fastly-FF) {\n # disable ESI processing on Origin Shield\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Make sure we lookup end user geo not shielding. More at https:\/\/docs.fastly.com\/vcl\/geolocation\/#using-geographic-variables-with-shielding\n set client.geo.ip_override = req.http.Fastly-Client-IP;\n\n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie:X-Magento-Vary || req.http.cookie:form_key) {\n error 980 \"GeoIP already processed\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url.qs !~ \"country_code=\" ) {\n set req.url = req.url \"?country_code=\" if ( req.http.geo_override, req.http.geo_override, client.geo.country_code);\n }\n }\n } else {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking by default\n # and allow custom parameters to be set. List of parameters is configurable in admin\n set req.http.Magento-Original-URL = req.url;\n # Change the list of ignored parameters by configuring them in the Advanced section\n set req.url = querystring.regfilter(req.url, \"^(####QUERY_PARAMETERS####)\");\n }\n\n # Don't allow clients to force a pass\n if (req.restarts == 0) {\n unset req.http.x-pass;\n }\n \n # Pass on checkout URLs. Because it's a snippet we want to execute this after backend selection so we handle it\n # in the request condition\n if (!req.http.x-long-cache && req.url ~ \"\/(catalogsearch|checkout|customer\/section\/load)\") {\n set req.http.x-pass = \"1\";\n # Pass all admin actions\n # ####ADMIN_PATH#### is replaced with value of frontName from app\/etc\/env.php\n } else if ( req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" ) {\n set req.http.x-pass = \"1\";\n } else {\n # Sort the query arguments to increase cache hit ratio with query arguments that\n # may be out od order. In case you want to restore the unsorted URL add a snippet\n # after this one that sets req.url to req.http.Magento-Original-URL\n set req.url = boltsort.sort(req.url);\n }\n\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.http.x-long-cache || req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n","old_contents":" # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n unset req.http.x-long-cache;\n\n # We want to force long cache times on any of the versioned assets\n if (req.url.path ~ \"^\/static\/version(\\d*\/)\") {\n set req.http.x-long-cache = \"1\";\n }\n \n # User's Cookie may contain some Magento Vary items we should vary on\n if (req.http.cookie:X-Magento-Vary ) {\n set req.http.X-Magento-Vary = req.http.cookie:X-Magento-Vary;\n } else {\n unset req.http.X-Magento-Vary;\n }\n\n ############################################################################################################\n # Following code block controls purge by URL. By default we want to protect all URL purges. In general this\n # is addressed by adding Fastly-Purge-Requires-Auth request header in vcl_recv however this runs the risk of\n # exposing API tokens if user attempts to purge non-https URLs. For this reason inside the Magento module\n # we use X-Purge-Token. Unfortunately this breaks purge from the Fastly UI. Therefore in the next code block\n # we check for presence of X-Purge-Token. If it's not present we force the Fastly-Purge-Requires-Auth\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n if (req.http.X-Purge-Token && req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n } else {\n error 403;\n }\n } else {\n set req.http.Fastly-Purge-Requires-Auth = \"1\";\n }\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (req.http.Fastly-FF) {\n # disable ESI processing on Origin Shield\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Make sure we lookup end user geo not shielding. More at https:\/\/docs.fastly.com\/vcl\/geolocation\/#using-geographic-variables-with-shielding\n set client.geo.ip_override = req.http.Fastly-Client-IP;\n\n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie:X-Magento-Vary || req.http.cookie:form_key) {\n error 980 \"GeoIP already processed\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url.qs !~ \"country_code=\" ) {\n set req.url = req.url \"?country_code=\" if ( req.http.geo_override, req.http.geo_override, client.geo.country_code);\n }\n }\n } else {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking by default\n # and allow custom parameters to be set. List of parameters is configurable in admin\n set req.http.Magento-Original-URL = req.url;\n # Change the list of ignored parameters by configuring them in the Advanced section\n set req.url = querystring.regfilter(req.url, \"^(####QUERY_PARAMETERS####)\");\n }\n\n # Don't allow clients to force a pass\n if (req.restarts == 0) {\n unset req.http.x-pass;\n }\n \n # Pass on checkout URLs. Because it's a snippet we want to execute this after backend selection so we handle it\n # in the request condition\n if (!req.http.x-long-cache && req.url ~ \"\/(catalogsearch|checkout|customer\/section\/load)\") {\n set req.http.x-pass = \"1\";\n # Pass all admin actions\n # ####ADMIN_PATH#### is replaced with value of frontName from app\/etc\/env.php\n } else if ( req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" ) {\n set req.http.x-pass = \"1\";\n } else {\n # Sort the query arguments to increase cache hit ratio with query arguments that\n # may be out od order. In case you want to restore the unsorted URL add a snippet\n # after this one that sets req.url to req.http.Magento-Original-URL\n set req.url = boltsort.sort(req.url);\n }\n\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.http.x-long-cache || req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"b0d9950b4151871877542ba28460f43bd243fd86","subject":"Remove Zope\/Plone example VCL","message":"Remove Zope\/Plone example VCL\n\nWe don't have a maintainer for this, and it hasn't been updated for a while.\n\nIn general we use the Wiki for linking to or referencing backend-specific\nconfiguration.\n","repos":"gquintard\/Varnish-Cache,chrismoulton\/Varnish-Cache,feld\/Varnish-Cache,zhoualbeart\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,gquintard\/Varnish-Cache,feld\/Varnish-Cache,gquintard\/Varnish-Cache,alarky\/varnish-cache-doc-ja,zhoualbeart\/Varnish-Cache,feld\/Varnish-Cache,mrhmouse\/Varnish-Cache,franciscovg\/Varnish-Cache,zhoualbeart\/Varnish-Cache,franciscovg\/Varnish-Cache,chrismoulton\/Varnish-Cache,chrismoulton\/Varnish-Cache,franciscovg\/Varnish-Cache,alarky\/varnish-cache-doc-ja,zhoualbeart\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,franciscovg\/Varnish-Cache,mrhmouse\/Varnish-Cache,gquintard\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,mrhmouse\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,feld\/Varnish-Cache,varnish\/Varnish-Cache,mrhmouse\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,alarky\/varnish-cache-doc-ja,chrismoulton\/Varnish-Cache,varnish\/Varnish-Cache,alarky\/varnish-cache-doc-ja,zhoualbeart\/Varnish-Cache,varnish\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,varnish\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,varnish\/Varnish-Cache,feld\/Varnish-Cache,franciscovg\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,chrismoulton\/Varnish-Cache,alarky\/varnish-cache-doc-ja,mrhmouse\/Varnish-Cache","old_file":"etc\/zope-plone.vcl","new_file":"etc\/zope-plone.vcl","new_contents":"","old_contents":"#\n# This is an example VCL configuration file for varnish, meant for the\n# Plone CMS running within Zope. It defines a \"default\" backend for\n# serving static content from a normal web server, and a \"zope\"\n# backend for requests to the Zope CMS\n#\n# See the vcl(7) man page for details on VCL syntax and semantics.\n#\n# $Id$\n#\n\n# Default backend definition. Set this to point to your content\n# server.\n\n# Default backend is the Zope CMS\nbackend default {\n\t.host = \"127.0.0.1\";\n\t.port = \"9673\";\n}\n\nacl purge {\n\t\"localhost\";\n\t\"192.0.2.0\"\/24;\n}\n\nsub vcl_recv {\n\n\t# Normalize host headers, and do rewriting for the zope sites. Reject\n\t# requests for unknown hosts\n if (req.http.host ~ \"(www.)?example.com\") {\n set req.http.host = \"example.com\";\n set req.url = \"\/VirtualHostBase\/http\/example.com:80\/example.com\/VirtualHostRoot\" + req.url;\n } elsif (req.http.host ~ \"(www.)?example.org\") {\n set req.http.host = \"example.org\";\n set req.url = \"\/VirtualHostBase\/http\/example.org:80\/example.org\/VirtualHostRoot\" + req.url;\n } else {\n error 404 \"Unknown virtual host.\";\n }\n\n # Handle special requests\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n\n # POST - Logins and edits\n if (req.method == \"POST\") {\n return(pass);\n }\n \n # PURGE - The CacheFu product can invalidate updated URLs\n if (req.method == \"PURGE\") {\n if (!client.ip ~ purge) {\n error 405 \"Not allowed.\";\n }\n return(lookup);\n }\n\n # Do not cache the creation of objects in Plone\n if (req.url ~ \"createObject\"){\n return(pass);\n }\n }\n\n # Don't cache authenticated requests\n if (req.http.Cookie && req.http.Cookie ~ \"__ac(|_(name|password|persistent))=\") {\n\n\t\t# Force lookup of specific urls unlikely to need protection\n\t\tif (req.url ~ \"\\.(js|css|kss)\") {\n remove req.http.cookie;\n return(lookup);\n }\n return(pass);\n }\n\n # The default vcl_recv is used from here.\n }\n\n# Do the PURGE thing\nsub vcl_hit {\n if (req.method == \"PURGE\") {\n purge;\n error 200 \"Purged\";\n }\n}\nsub vcl_miss {\n if (req.method == \"PURGE\") {\n purge;\n error 200 \"Purged\";\n }\n}\n\n# Enforce a minimum TTL, since we can PURGE changed objects actively\n# from Zope by using the CacheFu product\n\nsub vcl_response {\n if (beresp.ttl < 3600s) {\n set beresp.ttl = 3600s;\n }\n}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"30a610e6d9ab3c61ee40c20a59e503fc9f62deb6","subject":"Need to migrate Geo location variables to the new library. More detials can be found here","message":"Need to migrate Geo location variables to the new library. More detials can be found here\n\nhttps:\/\/docs.fastly.com\/guides\/migrations\/migrating-geolocation-variables-to-the-new-dataset\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets\/recv.vcl","new_file":"etc\/vcl_snippets\/recv.vcl","new_contents":" # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n # Sort the query arguments\n set req.url = boltsort.sort(req.url);\n\n if (req.url ~ \"^\/static\/version(\\d*\/)?(.*)$\") {\n set req.url = \"\/static\/\" + re.group.2 + \"?\" + re.group.1;\n }\n \n # User's Cookie may contain some Magento Vary items we should vary on\n if (req.http.cookie:X-Magento-Vary ) {\n set req.http.X-Magento-Vary = req.http.cookie:X-Magento-Vary;\n } else {\n unset req.http.X-Magento-Vary;\n }\n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n if (!req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n error 403;\n }\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n\n } else {\n error 403;\n }\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (req.http.Fastly-FF) {\n # disable ESI processing on Origin Shield\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie ~ \"(X-Magento-Vary|form_key)=\") {\n error 200 \"\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url !~ \"country_code=\" ) {\n set req.url = req.url \"?country_code=\" if ( req.http.geo_override, req.http.geo_override, client.geo.country_code);\n }\n }\n } else {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking\n set req.http.Magento-Original-URL = req.url;\n set req.url = querystring.regfilter(req.url, \"^(utm_.*|gclid|gdftrk|_ga|mc_.*)\");\n }\n \n # Pass on checkout URLs. Because it's a snippet we want to execute this after backend selection so we handle it\n # in the request condition\n if (req.url ~ \"\/(catalogsearch|checkout)\") {\n set req.http.x-pass = \"1\";\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n","old_contents":" # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n # Sort the query arguments\n set req.url = boltsort.sort(req.url);\n\n if (req.url ~ \"^\/static\/version(\\d*\/)?(.*)$\") {\n set req.url = \"\/static\/\" + re.group.2 + \"?\" + re.group.1;\n }\n \n # User's Cookie may contain some Magento Vary items we should vary on\n if (req.http.cookie:X-Magento-Vary ) {\n set req.http.X-Magento-Vary = req.http.cookie:X-Magento-Vary;\n } else {\n unset req.http.X-Magento-Vary;\n }\n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n if (!req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n error 403;\n }\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n\n } else {\n error 403;\n }\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (req.http.Fastly-FF) {\n # disable ESI processing on Origin Shield\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie ~ \"(X-Magento-Vary|form_key)=\") {\n error 200 \"\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url !~ \"country_code=\" ) {\n set req.url = req.url \"?country_code=\" if ( req.http.geo_override, req.http.geo_override, geoip.country_code);\n }\n }\n } else {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking\n set req.http.Magento-Original-URL = req.url;\n set req.url = querystring.regfilter(req.url, \"^(utm_.*|gclid|gdftrk|_ga|mc_.*)\");\n }\n \n # Pass on checkout URLs. Because it's a snippet we want to execute this after backend selection so we handle it\n # in the request condition\n if (req.url ~ \"\/(catalogsearch|checkout)\") {\n set req.http.x-pass = \"1\";\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"ede707e69c4e6ae5c8867bc7be511d4701e66aad","subject":"keep v2\/polyfill.js unminified","message":"keep v2\/polyfill.js unminified\n","repos":"JakeChampion\/polyfill-service,JakeChampion\/polyfill-service","old_file":"fastly\/vcl\/polyfill-service.vcl","new_file":"fastly\/vcl\/polyfill-service.vcl","new_contents":"sub set_backend {\n\t# Calculate the ideal region to route the request to.\n\tdeclare local var.region STRING;\n\tif (server.region ~ \"(APAC|Asia|North-America|South-America|US-Central|US-East|US-West)\") {\n\t\tset var.region = \"US\";\n\t} else {\n\t\tset var.region = \"EU\";\n\t}\n\n\t# Gather the health of the shields and origins.\n\tdeclare local var.v3_eu_is_healthy BOOL;\n\tset req.backend = F_v3_eu;\n\tset var.v3_eu_is_healthy = req.backend.healthy;\n\n\tdeclare local var.v3_us_is_healthy BOOL;\n\tset req.backend = F_v3_us;\n\tset var.v3_us_is_healthy = req.backend.healthy;\n\n\t# Set some sort of default, that shouldn't get used.\n\tset req.backend = F_v3_eu;\n\n\t# Route EU requests to the nearest healthy shield or origin.\n\tif (var.region == \"EU\") {\n\t\tif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_eu;\n\t\t}\n\t}\n\n\t# Route US requests to the nearest healthy shield or origin.\n\tif (var.region == \"US\") {\n\t\tif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_us;\n\t\t}\n\t}\n\n\t# Persist the decision so we can debug the result.\n\tset req.http.Debug-Backend = req.backend;\n\n\t# The Fastly macro is inserted after the backend is selected because the\n\t# macro has the code to select the correct req.http.Host value based on the backend.\n\t#FASTLY recv\n}\n\nsub vcl_recv {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_recv;\n\t}\n\n\tif (req.method != \"GET\" && req.method != \"HEAD\" && req.method != \"OPTIONS\" && req.method != \"FASTLYPURGE\" && req.method != \"PURGE\") {\n\t\terror 911;\n\t}\n\n\tif (req.method == \"OPTIONS\") {\n\t\terror 912;\n\t}\n\n\t# Because the old service had a router which allowed any words between \/v2\/polyfill. and .js\n\tif (req.url ~ \"^\/v2\/polyfill(\\.\\w+)\\.js\") {\n\t\tset req.url = regsub(req.url, \"^\/v2\/polyfill(\\.\\w+)\\.js\", \"\/v2\/polyfill.min.js\");\n\t}\n\n\t# Override the v3 defaults with the defaults of v2\n\tif (req.url ~ \"^\/v2\/polyfill(\\.min)?\\.js\") {\n\t\tset req.url = regsub(req.url, \"^\/v2\", \"\/v3\");\n\t\tset req.url = querystring.set(req.url, \"version\", \"3.25.1\");\n\t\tdeclare local var.unknown STRING;\n\t\tset var.unknown = subfield(req.url.qs, \"unknown\", \"&\");\n\t\tset req.url = querystring.set(req.url, \"unknown\", if(var.unknown != \"\", var.unknown, \"ignore\"));\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\") {\n\t\tcall normalise_querystring_parameters_for_polyfill_bundle;\n\t}\n\n\t# Sort the querystring parameters alphabetically to improve chances of hitting a cached copy.\n\t# If querystring is empty, remove the ? from the url.\n\tset req.url = querystring.clean(querystring.sort(req.url));\n\tcall set_backend;\n}\n\nsub vcl_hash {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_hash;\n\t}\n\n\t# We are not adding req.http.host to the hash because we want https:\/\/cdn.polyfill.io and https:\/\/polyfill.io to be a single object in the cache.\n\t# set req.hash += req.http.host;\n\tset req.hash += req.url;\n\t# We include return(hash) to stop the function falling through to the default VCL built into varnish, which for vcl_hash will add req.url and req.http.Host to the hash.\n\treturn(hash);\n}\n\nsub vcl_miss {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_miss;\n\t}\n}\n\nsub vcl_pass {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_pass;\n\t}\n}\n\nsub vcl_fetch {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_fetch;\n\t}\n\n\t# These header are only required for HTML documents.\n\tif (beresp.http.Content-Type ~ \"text\/html\") {\n\t\t# Enables the cross-site scripting filter built into most modern web browsers.\n\t\tset beresp.http.X-XSS-Protection = \"1; mode=block\";\t\n\n\t\t# Allow only content from the site's own origin (this excludes subdomains) and www.ft.com.\n\t\t# Don't allow the website to be used within an iframe\n\t\tif (!beresp.http.Content-Security-Policy) {\n\t\t\tset beresp.http.Content-Security-Policy = \"default-src 'self'; font-src 'self' https:\/\/www.ft.com; img-src 'self' https:\/\/www.ft.com; frame-ancestors 'none'; base-uri 'self'; form-action 'self'\";\n\t\t}\n\t}\n\t# Prevents MIME-sniffing a response away from the declared content type.\n\tset beresp.http.X-Content-Type-Options = \"nosniff\";\n\n\t# Ensure the site is only served over HTTPS and reduce the chances of someone performing a MITM attack.\n\tset beresp.http.Strict-Transport-Security = \"max-age=31536000; includeSubdomains; preload\";\n\n\t# The Referrer-Policy header governs which referrer information, sent in the Referer header, should be included with requests made.\n\t# Send a full URL when performing a same-origin request, but only send the origin of the document for other cases.\n\tset beresp.http.Referrer-Policy = \"origin-when-cross-origin\";\n\n\t# Enable purging of all objects in the Fastly cache by issuing a purge with the key \"polyfill-service\".\n\tif (beresp.http.Surrogate-Key !~ \"\\bpolyfill-service\\b\") {\n\t\tset beresp.http.Surrogate-Key = if(beresp.http.Surrogate-Key, beresp.http.Surrogate-Key \" polyfill-service\", \"polyfill-service\");\n\t}\n\n\tset beresp.http.Timing-Allow-Origin = \"*\";\n\n\tif (req.http.Normalized-User-Agent) {\n\t\tset beresp.http.Normalized-User-Agent = req.http.Normalized-User-Agent;\n\t\tset beresp.http.Detected-User-Agent = req.http.useragent_parser_family \"\/\" req.http.useragent_parser_major \".\" req.http.useragent_parser_minor \".\" req.http.useragent_parser_patch;\n\t}\n}\n\nsub vcl_deliver {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_deliver;\n\t}\n\n\tset req.http.Fastly-Force-Shield = \"yes\";\n\n\t# Allow cross origin GET, HEAD, and OPTIONS requests to be made.\n\tif (req.http.Origin) {\n\t\tset resp.http.Access-Control-Allow-Origin = \"*\";\n\t\tset resp.http.Access-Control-Allow-Methods = \"GET,HEAD,OPTIONS\";\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\") {\n\t\t# Need to add \"Vary: User-Agent\" in after vcl_fetch to avoid the \n\t\t# \"Vary: User-Agent\" entering the Varnish cache.\n\t\t# We need \"Vary: User-Agent\" in the browser cache because a browser\n\t\t# may update itself to a version which needs different polyfills\n\t\t# So we need to have it ignore the browser cached bundle when the user-agent changes.\n\t\tadd resp.http.Vary = \"User-Agent\";\n\t\tadd resp.http.Vary = \"Accept-Encoding\";\n\t}\n\n\tadd resp.http.Server-Timing = fastly_info.state {\", fastly;desc=\"Edge time\";dur=\"} time.elapsed.msec;\n\n\tif (req.http.Fastly-Debug) {\n\t\tset resp.http.Debug-Backend = req.http.Debug-Backend;\n\t\tset resp.http.Debug-Host = req.http.Host;\n\t\tset resp.http.Debug-Fastly-Restarts = req.restarts;\n\t\tset resp.http.Debug-Orig-URL = req.http.Orig-URL;\n\t\tset resp.http.Debug-VCL-Route = req.http.X-VCL-Route;\n\t\tset resp.http.useragent_parser_family = req.http.useragent_parser_family;\n\t\tset resp.http.useragent_parser_major = req.http.useragent_parser_major;\n\t\tset resp.http.useragent_parser_minor = req.http.useragent_parser_minor;\n\t\tset resp.http.useragent_parser_patch = req.http.useragent_parser_patch;\n\t} else {\n\t\tunset resp.http.Server;\n\t\tunset resp.http.Via;\n\t\tunset resp.http.X-Cache;\n\t\tunset resp.http.X-Cache-Hits;\n\t\tunset resp.http.X-Served-By;\n\t\tunset resp.http.X-Timer;\n\t\tunset resp.http.Fastly-Restarts;\n\t}\n}\n\nsub vcl_error {\n\tif (obj.status == 911) {\n\t\tset obj.status = 405;\n\t\tset obj.response = \"METHOD NOT ALLOWED\";\n\t\tset obj.http.Content-Type = \"text\/html; charset=utf-8\";\n\t\tset obj.http.Cache-Control = \"private, no-store\";\n\t\tsynthetic req.method \" METHOD NOT ALLOWED\";\n\t\treturn (deliver);\n\t}\n\tif (obj.status == 912) {\n\t\tset obj.status = 200;\n\t\tset obj.response = \"OK\";\n\t\tset obj.http.Allow = \"OPTIONS, GET, HEAD\";\n\t\treturn (deliver);\n\t}\n}\n","old_contents":"sub set_backend {\n\t# Calculate the ideal region to route the request to.\n\tdeclare local var.region STRING;\n\tif (server.region ~ \"(APAC|Asia|North-America|South-America|US-Central|US-East|US-West)\") {\n\t\tset var.region = \"US\";\n\t} else {\n\t\tset var.region = \"EU\";\n\t}\n\n\t# Gather the health of the shields and origins.\n\tdeclare local var.v3_eu_is_healthy BOOL;\n\tset req.backend = F_v3_eu;\n\tset var.v3_eu_is_healthy = req.backend.healthy;\n\n\tdeclare local var.v3_us_is_healthy BOOL;\n\tset req.backend = F_v3_us;\n\tset var.v3_us_is_healthy = req.backend.healthy;\n\n\t# Set some sort of default, that shouldn't get used.\n\tset req.backend = F_v3_eu;\n\n\t# Route EU requests to the nearest healthy shield or origin.\n\tif (var.region == \"EU\") {\n\t\tif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_eu;\n\t\t}\n\t}\n\n\t# Route US requests to the nearest healthy shield or origin.\n\tif (var.region == \"US\") {\n\t\tif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_us;\n\t\t}\n\t}\n\n\t# Persist the decision so we can debug the result.\n\tset req.http.Debug-Backend = req.backend;\n\n\t# The Fastly macro is inserted after the backend is selected because the\n\t# macro has the code to select the correct req.http.Host value based on the backend.\n\t#FASTLY recv\n}\n\nsub vcl_recv {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_recv;\n\t}\n\n\tif (req.method != \"GET\" && req.method != \"HEAD\" && req.method != \"OPTIONS\" && req.method != \"FASTLYPURGE\" && req.method != \"PURGE\") {\n\t\terror 911;\n\t}\n\n\tif (req.method == \"OPTIONS\") {\n\t\terror 912;\n\t}\n\n\t# Because the old service had a router which allowed any words between \/v2\/polyfill. and .js\n\tif (req.url ~ \"^\/v2\/polyfill(\\.\\w+)?\\.js\") {\n\t\tset req.url = regsub(req.url, \"^\/v2\/polyfill(\\.\\w+)?\\.js\", \"\/v2\/polyfill.min.js\");\n\t}\n\n\t# Override the v3 defaults with the defaults of v2\n\tif (req.url ~ \"^\/v2\/polyfill(\\.min)?\\.js\") {\n\t\tset req.url = regsub(req.url, \"^\/v2\", \"\/v3\");\n\t\tset req.url = querystring.set(req.url, \"version\", \"3.25.1\");\n\t\tdeclare local var.unknown STRING;\n\t\tset var.unknown = subfield(req.url.qs, \"unknown\", \"&\");\n\t\tset req.url = querystring.set(req.url, \"unknown\", if(var.unknown != \"\", var.unknown, \"ignore\"));\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\") {\n\t\tcall normalise_querystring_parameters_for_polyfill_bundle;\n\t}\n\n\t# Sort the querystring parameters alphabetically to improve chances of hitting a cached copy.\n\t# If querystring is empty, remove the ? from the url.\n\tset req.url = querystring.clean(querystring.sort(req.url));\n\tcall set_backend;\n}\n\nsub vcl_hash {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_hash;\n\t}\n\n\t# We are not adding req.http.host to the hash because we want https:\/\/cdn.polyfill.io and https:\/\/polyfill.io to be a single object in the cache.\n\t# set req.hash += req.http.host;\n\tset req.hash += req.url;\n\t# We include return(hash) to stop the function falling through to the default VCL built into varnish, which for vcl_hash will add req.url and req.http.Host to the hash.\n\treturn(hash);\n}\n\nsub vcl_miss {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_miss;\n\t}\n}\n\nsub vcl_pass {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_pass;\n\t}\n}\n\nsub vcl_fetch {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_fetch;\n\t}\n\n\t# These header are only required for HTML documents.\n\tif (beresp.http.Content-Type ~ \"text\/html\") {\n\t\t# Enables the cross-site scripting filter built into most modern web browsers.\n\t\tset beresp.http.X-XSS-Protection = \"1; mode=block\";\t\n\n\t\t# Allow only content from the site's own origin (this excludes subdomains) and www.ft.com.\n\t\t# Don't allow the website to be used within an iframe\n\t\tif (!beresp.http.Content-Security-Policy) {\n\t\t\tset beresp.http.Content-Security-Policy = \"default-src 'self'; font-src 'self' https:\/\/www.ft.com; img-src 'self' https:\/\/www.ft.com; frame-ancestors 'none'; base-uri 'self'; form-action 'self'\";\n\t\t}\n\t}\n\t# Prevents MIME-sniffing a response away from the declared content type.\n\tset beresp.http.X-Content-Type-Options = \"nosniff\";\n\n\t# Ensure the site is only served over HTTPS and reduce the chances of someone performing a MITM attack.\n\tset beresp.http.Strict-Transport-Security = \"max-age=31536000; includeSubdomains; preload\";\n\n\t# The Referrer-Policy header governs which referrer information, sent in the Referer header, should be included with requests made.\n\t# Send a full URL when performing a same-origin request, but only send the origin of the document for other cases.\n\tset beresp.http.Referrer-Policy = \"origin-when-cross-origin\";\n\n\t# Enable purging of all objects in the Fastly cache by issuing a purge with the key \"polyfill-service\".\n\tif (beresp.http.Surrogate-Key !~ \"\\bpolyfill-service\\b\") {\n\t\tset beresp.http.Surrogate-Key = if(beresp.http.Surrogate-Key, beresp.http.Surrogate-Key \" polyfill-service\", \"polyfill-service\");\n\t}\n\n\tset beresp.http.Timing-Allow-Origin = \"*\";\n\n\tif (req.http.Normalized-User-Agent) {\n\t\tset beresp.http.Normalized-User-Agent = req.http.Normalized-User-Agent;\n\t\tset beresp.http.Detected-User-Agent = req.http.useragent_parser_family \"\/\" req.http.useragent_parser_major \".\" req.http.useragent_parser_minor \".\" req.http.useragent_parser_patch;\n\t}\n}\n\nsub vcl_deliver {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_deliver;\n\t}\n\n\tset req.http.Fastly-Force-Shield = \"yes\";\n\n\t# Allow cross origin GET, HEAD, and OPTIONS requests to be made.\n\tif (req.http.Origin) {\n\t\tset resp.http.Access-Control-Allow-Origin = \"*\";\n\t\tset resp.http.Access-Control-Allow-Methods = \"GET,HEAD,OPTIONS\";\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\") {\n\t\t# Need to add \"Vary: User-Agent\" in after vcl_fetch to avoid the \n\t\t# \"Vary: User-Agent\" entering the Varnish cache.\n\t\t# We need \"Vary: User-Agent\" in the browser cache because a browser\n\t\t# may update itself to a version which needs different polyfills\n\t\t# So we need to have it ignore the browser cached bundle when the user-agent changes.\n\t\tadd resp.http.Vary = \"User-Agent\";\n\t\tadd resp.http.Vary = \"Accept-Encoding\";\n\t}\n\n\tadd resp.http.Server-Timing = fastly_info.state {\", fastly;desc=\"Edge time\";dur=\"} time.elapsed.msec;\n\n\tif (req.http.Fastly-Debug) {\n\t\tset resp.http.Debug-Backend = req.http.Debug-Backend;\n\t\tset resp.http.Debug-Host = req.http.Host;\n\t\tset resp.http.Debug-Fastly-Restarts = req.restarts;\n\t\tset resp.http.Debug-Orig-URL = req.http.Orig-URL;\n\t\tset resp.http.Debug-VCL-Route = req.http.X-VCL-Route;\n\t\tset resp.http.useragent_parser_family = req.http.useragent_parser_family;\n\t\tset resp.http.useragent_parser_major = req.http.useragent_parser_major;\n\t\tset resp.http.useragent_parser_minor = req.http.useragent_parser_minor;\n\t\tset resp.http.useragent_parser_patch = req.http.useragent_parser_patch;\n\t} else {\n\t\tunset resp.http.Server;\n\t\tunset resp.http.Via;\n\t\tunset resp.http.X-Cache;\n\t\tunset resp.http.X-Cache-Hits;\n\t\tunset resp.http.X-Served-By;\n\t\tunset resp.http.X-Timer;\n\t\tunset resp.http.Fastly-Restarts;\n\t}\n}\n\nsub vcl_error {\n\tif (obj.status == 911) {\n\t\tset obj.status = 405;\n\t\tset obj.response = \"METHOD NOT ALLOWED\";\n\t\tset obj.http.Content-Type = \"text\/html; charset=utf-8\";\n\t\tset obj.http.Cache-Control = \"private, no-store\";\n\t\tsynthetic req.method \" METHOD NOT ALLOWED\";\n\t\treturn (deliver);\n\t}\n\tif (obj.status == 912) {\n\t\tset obj.status = 200;\n\t\tset obj.response = \"OK\";\n\t\tset obj.http.Allow = \"OPTIONS, GET, HEAD\";\n\t\treturn (deliver);\n\t}\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"c1f5692d4d6f17e2f19e899f0b79974dc48c0a4f","subject":"Display duration for current URL when getting cookie value in example VCL","message":"Display duration for current URL when getting cookie value in example VCL","repos":"Destination\/libvmod-abtest,Destination\/libvmod-abtest","old_file":"vcl\/default.vcl","new_file":"vcl\/default.vcl","new_contents":" import std;\n import abtest;\n\n C{\n #include <syslog.h>\n }C\n\n\n backend default {\n .host = \"127.0.0.1\";\n .port = \"3000\";\n }\n\n\/* Only permit localhost to manipulate abtest configuration *\/\nacl abconfig {\n \"localhost\";\n}\n\nsub vcl_init {\n if (abtest.load_config(\"\/tmp\/abtest.cfg\") != 0) {\n C{ syslog(LOG_ALERT, \"Unable to load AB config from \/tmp\/abtest.cfg\"); }C\n }\n\n return (ok);\n}\n\nsub vcl_fini {\n}\n\nsub vcl_recv {\n std.log(abtest.get_rules());\n\n if (req.http.X-AB-Cfg) {\n if (!client.ip ~ abconfig) {\n std.log(\"AB Config request not allowed from \" + client.ip);\n error 405 \"Not allowed.\";\n } else {\n \/\/ curl localhost:8080 -X PUT -H \"X-AB-Cfg:base\" -H \"X-AB-Cfg-Val:a:25;b:75;\"\n if (req.request == \"PUT\") {\n std.log(\"AB Config PUT request: \" + req.http.X-AB-Cfg + \"|\" + req.http.X-AB-Cfg-Val);\n abtest.set_rule(req.http.X-AB-Cfg, req.http.X-AB-Cfg-Val);\n if (abtest.save_config(\"\/tmp\/abtest.cfg\") != 0) {\n std.log(\"ABTest - Error, could not save the configuration\");\n }\n }\n\n \/\/ curl localhost:8080 -X DELETE -H \"X-AB-Cfg:base\"\n if (req.request == \"DELETE\") {\n std.log(\"AB Config DELETE request: \" + req.http.X-AB-Cfg);\n abtest.rem_rule(req.http.X-AB-Cfg);\n }\n\n \/\/ curl localhost:8080 -X GET -H \"X-AB-Cfg;\"\n if (req.request == \"GET\") {\n std.log(\"AB Config GET request: \" + req.http.X-AB-Cfg);\n std.log(\"CFG -> \" + abtest.get_rules());\n }\n }\n }\n\n std.log(\"AB Cookie for '\" + req.url + \"': \" + abtest.get_rand(req.url) + \", cookie should last for \" + abtest.get_duration(req.url));\n\n\/*\n if(req.http.Cookie ~ \"abtesting\") {\n }\n*\/\n}\n\nsub vcl_pipe {\n}\n\nsub vcl_pass {\n}\n\nsub vcl_hash {\n}\n\nsub vcl_hit {\n}\n\nsub vcl_miss {\n}\n\nsub vcl_fetch {\n}\n\nsub vcl_deliver {\n}\n\nsub vcl_error {\n}\n","old_contents":" import std;\n import abtest;\n\n C{\n #include <syslog.h>\n }C\n\n\n backend default {\n .host = \"127.0.0.1\";\n .port = \"3000\";\n }\n\n\/* Only permit localhost to manipulate abtest configuration *\/\nacl abconfig {\n \"localhost\";\n}\n\nsub vcl_init {\n if (abtest.load_config(\"\/tmp\/abtest.cfg\") != 0) {\n C{ syslog(LOG_ALERT, \"Unable to load AB config from \/tmp\/abtest.cfg\"); }C\n }\n\n return (ok);\n}\n\nsub vcl_fini {\n}\n\nsub vcl_recv {\n std.log(abtest.get_rules());\n\n if (req.http.X-AB-Cfg) {\n if (!client.ip ~ abconfig) {\n std.log(\"AB Config request not allowed from \" + client.ip);\n error 405 \"Not allowed.\";\n } else {\n \/\/ curl localhost:8080 -X PUT -H \"X-AB-Cfg:base\" -H \"X-AB-Cfg-Val:a:25;b:75;\"\n if (req.request == \"PUT\") {\n std.log(\"AB Config PUT request: \" + req.http.X-AB-Cfg + \"|\" + req.http.X-AB-Cfg-Val);\n abtest.set_rule(req.http.X-AB-Cfg, req.http.X-AB-Cfg-Val);\n if (abtest.save_config(\"\/tmp\/abtest.cfg\") != 0) {\n std.log(\"ABTest - Error, could not save the configuration\");\n }\n }\n\n \/\/ curl localhost:8080 -X DELETE -H \"X-AB-Cfg:base\"\n if (req.request == \"DELETE\") {\n std.log(\"AB Config DELETE request: \" + req.http.X-AB-Cfg);\n abtest.rem_rule(req.http.X-AB-Cfg);\n }\n\n \/\/ curl localhost:8080 -X GET -H \"X-AB-Cfg;\"\n if (req.request == \"GET\") {\n std.log(\"AB Config GET request: \" + req.http.X-AB-Cfg);\n std.log(\"CFG -> \" + abtest.get_rules());\n if (req.http.X-AB-Cfg != \"\") {\n std.log(\"duration for '\" + req.http.X-AB-Cfg + \"': \" + abtest.get_duration(req.http.X-AB-Cfg));\n }\n }\n }\n }\n\n std.log(\"AB Cookie for '\" + req.url + \"': \" + abtest.get_rand(req.url));\n\n\/*\n if(req.http.Cookie ~ \"abtesting\") {\n }\n*\/\n}\n\nsub vcl_pipe {\n}\n\nsub vcl_pass {\n}\n\nsub vcl_hash {\n}\n\nsub vcl_hit {\n}\n\nsub vcl_miss {\n}\n\nsub vcl_fetch {\n}\n\nsub vcl_deliver {\n}\n\nsub vcl_error {\n}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"ec70f276dd30613618bd16614045e9ac59941ce2","subject":"Allows fallthrough to builtin.vcl for vcl_backend_response","message":"Allows fallthrough to builtin.vcl for vcl_backend_response\n","repos":"amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon","old_file":"images\/varnish-drupal\/drupal.vcl","new_file":"images\/varnish-drupal\/drupal.vcl","new_contents":"vcl 4.0;\n\nimport std;\nimport dynamic;\n\n# set backend default\nbackend default {\n .host = \"${VARNISH_BACKEND_HOST:-nginx}\";\n .port = \"${VARNISH_BACKEND_PORT:-8080}\";\n .first_byte_timeout = 35m;\n .between_bytes_timeout = 10m;\n}\n\n# Allow purging from localhost\n# @TODO allow from openshift network\nacl purge {\n \"127.0.0.1\";\n \"10.0.0.0\"\/8;\n \"172.16.0.0\"\/12;\n \"192.168.0.0\"\/16;\n}\n\nsub vcl_init {\n new www_dir = dynamic.director(\n port = \"${VARNISH_BACKEND_PORT:-8080}\",\n first_byte_timeout = 90s,\n between_bytes_timeout = 90s,\n ttl = 60s);\n}\n\n# This configuration is optimized for Drupal hosting:\n# Respond to incoming requests.\nsub vcl_recv {\n if (req.url ~ \"^\/varnish_status$\") {\n return (synth(200,\"OK\"));\n }\n # set the backend, which should be used:\n set req.backend_hint = www_dir.backend(\"${VARNISH_BACKEND_HOST:-nginx}\");\n\n # Always set the forward ip.\n if (req.restarts == 0) {\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n }\n else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n if (req.http.X-LAGOON-VARNISH ) {\n # Pass all Requests which are handled via an upstream Varnish\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, \" + req.http.X-LAGOON-VARNISH;\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n }\n else if (req.http.Fastly-FF) {\n # Pass all Requests which are handled via Fastly\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, fastly\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n set req.http.X-Forwarded-For = req.http.Fastly-Client-IP;\n }\n else if (req.http.CF-RAY) {\n # Pass all Requests which are handled via CloudFlare\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, cloudflare\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n set req.http.X-Forwarded-For = req.http.CF-Connecting-IP;\n }\n else if (req.http.X-Pull) {\n # Pass all Requests which are handled via KeyCDN\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, keycdn\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n }\n else {\n # We set a header to let a Varnish chain know that it already has been varnishcached\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}\";\n\n # Allow to bypass based on env variable `VARNISH_BYPASS`\n set req.http.X-LAGOON-VARNISH-BYPASS = \"${VARNISH_BYPASS:-false}\";\n }\n\n # Websockets are piped\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n if (req.http.X-LAGOON-VARNISH-BYPASS == \"true\" || req.http.X-LAGOON-VARNISH-BYPASS == \"TRUE\") {\n return (pass);\n }\n\n # SA-CORE-2014-004 preventing access to \/xmlrpc.php\n if (req.url ~ \"^\/xmlrpc.php$\") {\n return (synth(701, \"Unauthorized\"));\n }\n\n # Strip out Google Analytics campaign variables. They are only needed\n # by the javascript running on the page\n # utm_source, utm_medium, utm_campaign, gclid\n if(req.url ~ \"(\\?|&)(gclid|utm_[a-z]+)=\") {\n set req.url = regsuball(req.url, \"(gclid|utm_[a-z]+)=[^\\&]+&?\", \"\");\n set req.url = regsub(req.url, \"(\\?|&)$\", \"\");\n }\n\n # Bypass a cache hit (the request is still sent to the backend)\n if (req.method == \"REFRESH\") {\n if (!client.ip ~ purge) {\n return (synth(405, \"Not allowed\"));\n }\n set req.method = \"GET\";\n set req.hash_always_miss = true;\n }\n\n # Only allow BAN requests from IP addresses in the 'purge' ACL.\n if (req.method == \"BAN\" || req.method == \"URIBAN\" || req.method == \"PURGE\") {\n # Only allow BAN from defined ACL\n if (!client.ip ~ purge) {\n return (synth(403, \"Your IP is not allowed.\"));\n }\n\n # Only allows BAN if the Host Header has the style of with \"${SERVICE_NAME:-varnish}:8080\" or \"${SERVICE_NAME:-varnish}\".\n # Such a request is only possible from within the Docker network, as a request from external goes trough the Kubernetes Router and for that needs a proper Host Header\n if (!req.http.host ~ \"^${SERVICE_NAME:-varnish}(:\\d+)?$\") {\n return (synth(403, \"Only allowed from within own network.\"));\n }\n\n if (req.method == \"BAN\") {\n # Logic for the ban, using the Cache-Tags header.\n if (req.http.Cache-Tags) {\n ban(\"obj.http.Cache-Tags ~ \" + req.http.Cache-Tags);\n # Throw a synthetic page so the request won't go to the backend.\n return (synth(200, \"Ban added.\"));\n }\n else {\n return (synth(403, \"Cache-Tags header missing.\"));\n }\n }\n\n if (req.method == \"URIBAN\" || req.method == \"PURGE\") {\n ban(\"req.url ~ \" + req.url);\n # Throw a synthetic page so the request won't go to the backend.\n return (synth(200, \"Ban added.\"));\n }\n }\n\n # Non-RFC2616 or CONNECT which is weird, we pipe that\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n return (pipe);\n }\n\n # Large binary files are passed.\n if (req.url ~ \"\\.(msi|exe|dmg|zip|tgz|gz|pkg)$\") {\n return(pass);\n }\n\n # We only try to cache GET and HEAD, other things are passed.\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n # Any requests with Basic Authentication are passed.\n if (req.http.Authorization || req.http.Authenticate) {\n return (pass);\n }\n\n # Blackfire requests are passed.\n if (req.http.X-Blackfire-Query) {\n return (pass);\n }\n\n # Some URLs should never be cached.\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/admin([\/?]|$).*$\" ||\n req.url ~ \"^\/info([\/?]|$).*$\" ||\n req.url ~ \"^\/flag([\/?]|$).*$\" ||\n req.url ~ \"^.*\/system\/files([\/?]|$).*$\" ||\n req.url ~ \"^\/cgi\" ||\n req.url ~ \"^\/cgi-bin\"\n ) {\n return (pass);\n }\n\n # Plupload likes to get piped.\n if (req.url ~ \"^.*\/plupload-handle-uploads.*$\") {\n return (pipe);\n }\n\n # Handle compression correctly. Different browsers send different\n # \"Accept-Encoding\" headers, even though they mostly all support the same\n # compression mechanisms. By consolidating these compression headers into\n # a consistent format, we can reduce the size of the cache and get more hits.=\n # @see: http:\/\/ varnish.projects.linpro.no\/wiki\/FAQ\/Compression\n if (req.http.Accept-Encoding) {\n if (req.http.Accept-Encoding ~ \"gzip\") {\n # If the browser supports it, we'll use gzip.\n set req.http.Accept-Encoding = \"gzip\";\n }\n else if (req.http.Accept-Encoding ~ \"deflate\") {\n # Next, try deflate if it is supported.\n set req.http.Accept-Encoding = \"deflate\";\n }\n else {\n # Unknown algorithm. Remove it and send unencoded.\n unset req.http.Accept-Encoding;\n }\n }\n\n # Always cache the following file types for all users.\n if (req.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n unset req.http.Cookie;\n }\n\n # Remove all cookies that Drupal doesn't need to know about. ANY remaining\n # cookie will cause the request to pass-through to a backend. For the most part\n # we always set the NO_CACHE cookie after any POST request, disabling the\n # Varnish cache temporarily. The session cookie allows all authenticated users\n # to pass through as long as they're logged in.\n #\n # 1. Append a semi-colon to the front of the cookie string.\n # 2. Remove all spaces that appear after semi-colons.\n # 3. Match the cookies we want to keep, adding the space we removed\n # previously, back. (\\1) is first matching group in the regsuball.\n # 4. Remove all other cookies, identifying them by the fact that they have\n # no space after the preceding semi-colon.\n # 5. Remove all spaces and semi-colons from the beginning and end of the\n # cookie string.\n if (req.http.Cookie) {\n set req.http.CookieCheck = \";\" + req.http.Cookie;\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"; +\", \";\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";(${VARNISH_COOKIECHECK:-SESS[a-z0-9]+|SSESS[a-z0-9]+|NO_CACHE})=\", \"; \\1=\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";[^ ][^;]*\", \"\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"^[; ]+|[; ]+$\", \"\");\n\n set req.http.Cookie = req.http.Cookie + \";\";\n\n if (req.http.CookieCheck == \"\") {\n # If there are no remaining cookies, remove the cookie header. If there\n # aren't any cookie headers, Varnish's default behavior will be to cache\n # the page.\n\n unset req.http.CookieCheck;\n unset req.http.Cookie;\n }\n else {\n # If there is any cookies left (a session or NO_CACHE cookie), do not\n # cache the page. Pass it on to Apache directly.\n unset req.http.CookieCheck;\n return (pass);\n }\n }\n\n # Cacheable, lookup in cache.\n return (hash);\n}\n\nsub vcl_pipe {\n # Support for Websockets\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n set bereq.http.connection = req.http.connection;\n }\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n # normal hit\n return (deliver);\n }\n # We have no fresh fish. Lets look at the stale ones.\n if (std.healthy(req.backend_hint)) {\n # Backend is healthy. If the object is not older then 30secs, deliver it to the client\n # and automatically create a separate backend request to warm the cache for this request.\n if (obj.ttl + 30s > 0s) {\n set req.http.grace = \"normal(limited)\";\n return (deliver);\n } else {\n # No candidate for grace. Fetch a fresh object.\n return (miss);\n }\n }\n else {\n # backend is sick - use full grace\n if (obj.ttl + obj.grace > 0s) {\n set req.http.grace = \"full\";\n return (deliver);\n } else {\n # no graced object.\n return (miss);\n }\n }\n}\n\nsub vcl_backend_response {\n # Allow items to be stale if needed.\n set beresp.grace = 6h;\n\n # Set ban-lurker friendly custom headers.\n set beresp.http.X-Url = bereq.url;\n set beresp.http.X-Host = bereq.http.host;\n\n # If the backend sends a X-LAGOON-VARNISH-BACKEND-BYPASS header we directly deliver\n if (beresp.http.X-LAGOON-VARNISH-BACKEND-BYPASS == \"TRUE\") {\n return (deliver);\n }\n\n # Cache 404 and 403 for 10 seconds\n if (beresp.status == 404 || beresp.status == 403) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n # Don't allow static files to set cookies.\n if (bereq.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n unset beresp.http.set-cookie;\n unset beresp.http.Cache-Control;\n\n # If an asset would come back with statuscode 500 we only cache it for 10 seconds instead of the usual static file cache\n if (beresp.status == 500) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n set beresp.ttl = ${VARNISH_ASSETS_TTL:-2628001}s;\n set beresp.http.Cache-Control = \"public, max-age=${VARNISH_ASSETS_TTL:-2628001}\";\n set beresp.http.Expires = \"\" + (now + beresp.ttl);\n }\n\n # Files larger than 10 MB get streamed.\n if (beresp.http.Content-Length ~ \"[0-9]{8,}\") {\n set beresp.do_stream = true;\n set beresp.uncacheable = true;\n set beresp.ttl = 120s;\n }\n\n # Disable buffering only for BigPipe responses\n if (beresp.http.Surrogate-Control ~ \"BigPipe\/1.0\") {\n set beresp.do_stream = true;\n set beresp.ttl = 0s;\n }\n}\n\n# Set a header to track a cache HIT\/MISS.\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Varnish-Cache = \"HIT\";\n }\n else {\n set resp.http.X-Varnish-Cache = \"MISS\";\n }\n\n # Remove ban-lurker friendly custom headers when delivering to client.\n unset resp.http.X-Url;\n unset resp.http.X-Host;\n\n # unset Cache-Tags Header by default, can be disabled with VARNISH_SET_HEADER_CACHE_TAGS=true\n if (!${VARNISH_SET_HEADER_CACHE_TAGS:-false}) {\n unset resp.http.Cache-Tags;\n }\n\n unset resp.http.X-Generator;\n unset resp.http.Server;\n # Inject information about grace\n if (req.http.grace) {\n set resp.http.X-Varnish-Grace = req.http.grace;\n }\n set resp.http.X-LAGOON = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}>\" + resp.http.X-LAGOON;\n return (deliver);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n }\n else {\n hash_data(server.ip);\n }\n if (req.http.X-Forwarded-Proto) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n if (req.http.HTTPS) {\n hash_data(req.http.HTTPS);\n }\n return (lookup);\n}\n\nsub vcl_synth {\n if (resp.status == 701) {\n set resp.status = 401;\n set resp.http.Content-Type = \"text\/plain; charset=utf-8\";\n synthetic({\"XMLRPC Interface is blocked due to SA-CORE-2014-004 - mail support@amazee.io if you need it.\"});\n return (deliver);\n }\n if (resp.status == 700) {\n # Set a status the client will understand\n set resp.status = 200;\n # Create our synthetic response\n synthetic(\"\");\n return(deliver);\n }\n return (deliver);\n}\n\nsub vcl_backend_error {\n # Restart the request, when we have a backend server error, to try another backend.\n # Restart max twice.\n if (bereq.retries < 2) {\n return(retry);\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic({\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<head>\n <title>Server Error<\/title>\n <style type=\"text\/css\">\n body {\n font-family: helvetica, arial, sans-serif;\n }\n img {\n margin-top: 50px;\n }\n p {\n width: 6 00px;\n margin-top: 10px\n }\n div {\n background: #ccc;\n width: 600px;\n margin: auto;\n padding: 50px;\n }\n span {\n color: #ccc\n }\n <\/style>\n<\/head>\n<body>\n <div>\n <h1>We are sorry...<\/h1>\n <p>We encountered a server-side error. This means that the problem is not with your computer or Internet connection, but rather with the website's server.<\/p>\n <p>We are currently working on solving this problem and apologise for the inconvenience.<\/p>\n <span>\n <strong>Technical Information<\/strong><br \/>\n Error \"} + beresp.status + \" \" + beresp.reason + {\"<br \/>\n XID: \"} + bereq.xid + {\"<br \/>\n <\/span>\n <\/div>\n<\/body>\n<\/html>\n\n\"});\n return (deliver);\n}\n","old_contents":"vcl 4.0;\n\nimport std;\nimport dynamic;\n\n# set backend default\nbackend default {\n .host = \"${VARNISH_BACKEND_HOST:-nginx}\";\n .port = \"${VARNISH_BACKEND_PORT:-8080}\";\n .first_byte_timeout = 35m;\n .between_bytes_timeout = 10m;\n}\n\n# Allow purging from localhost\n# @TODO allow from openshift network\nacl purge {\n \"127.0.0.1\";\n \"10.0.0.0\"\/8;\n \"172.16.0.0\"\/12;\n \"192.168.0.0\"\/16;\n}\n\nsub vcl_init {\n new www_dir = dynamic.director(\n port = \"${VARNISH_BACKEND_PORT:-8080}\",\n first_byte_timeout = 90s,\n between_bytes_timeout = 90s,\n ttl = 60s);\n}\n\n# This configuration is optimized for Drupal hosting:\n# Respond to incoming requests.\nsub vcl_recv {\n if (req.url ~ \"^\/varnish_status$\") {\n return (synth(200,\"OK\"));\n }\n # set the backend, which should be used:\n set req.backend_hint = www_dir.backend(\"${VARNISH_BACKEND_HOST:-nginx}\");\n\n # Always set the forward ip.\n if (req.restarts == 0) {\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n }\n else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n if (req.http.X-LAGOON-VARNISH ) {\n # Pass all Requests which are handled via an upstream Varnish\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, \" + req.http.X-LAGOON-VARNISH;\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n }\n else if (req.http.Fastly-FF) {\n # Pass all Requests which are handled via Fastly\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, fastly\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n set req.http.X-Forwarded-For = req.http.Fastly-Client-IP;\n }\n else if (req.http.CF-RAY) {\n # Pass all Requests which are handled via CloudFlare\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, cloudflare\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n set req.http.X-Forwarded-For = req.http.CF-Connecting-IP;\n }\n else if (req.http.X-Pull) {\n # Pass all Requests which are handled via KeyCDN\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, keycdn\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n }\n else {\n # We set a header to let a Varnish chain know that it already has been varnishcached\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}\";\n\n # Allow to bypass based on env variable `VARNISH_BYPASS`\n set req.http.X-LAGOON-VARNISH-BYPASS = \"${VARNISH_BYPASS:-false}\";\n }\n\n # Websockets are piped\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n if (req.http.X-LAGOON-VARNISH-BYPASS == \"true\" || req.http.X-LAGOON-VARNISH-BYPASS == \"TRUE\") {\n return (pass);\n }\n\n # SA-CORE-2014-004 preventing access to \/xmlrpc.php\n if (req.url ~ \"^\/xmlrpc.php$\") {\n return (synth(701, \"Unauthorized\"));\n }\n\n # Strip out Google Analytics campaign variables. They are only needed\n # by the javascript running on the page\n # utm_source, utm_medium, utm_campaign, gclid\n if(req.url ~ \"(\\?|&)(gclid|utm_[a-z]+)=\") {\n set req.url = regsuball(req.url, \"(gclid|utm_[a-z]+)=[^\\&]+&?\", \"\");\n set req.url = regsub(req.url, \"(\\?|&)$\", \"\");\n }\n\n # Bypass a cache hit (the request is still sent to the backend)\n if (req.method == \"REFRESH\") {\n if (!client.ip ~ purge) {\n return (synth(405, \"Not allowed\"));\n }\n set req.method = \"GET\";\n set req.hash_always_miss = true;\n }\n\n # Only allow BAN requests from IP addresses in the 'purge' ACL.\n if (req.method == \"BAN\" || req.method == \"URIBAN\" || req.method == \"PURGE\") {\n # Only allow BAN from defined ACL\n if (!client.ip ~ purge) {\n return (synth(403, \"Your IP is not allowed.\"));\n }\n\n # Only allows BAN if the Host Header has the style of with \"${SERVICE_NAME:-varnish}:8080\" or \"${SERVICE_NAME:-varnish}\".\n # Such a request is only possible from within the Docker network, as a request from external goes trough the Kubernetes Router and for that needs a proper Host Header\n if (!req.http.host ~ \"^${SERVICE_NAME:-varnish}(:\\d+)?$\") {\n return (synth(403, \"Only allowed from within own network.\"));\n }\n\n if (req.method == \"BAN\") {\n # Logic for the ban, using the Cache-Tags header.\n if (req.http.Cache-Tags) {\n ban(\"obj.http.Cache-Tags ~ \" + req.http.Cache-Tags);\n # Throw a synthetic page so the request won't go to the backend.\n return (synth(200, \"Ban added.\"));\n }\n else {\n return (synth(403, \"Cache-Tags header missing.\"));\n }\n }\n\n if (req.method == \"URIBAN\" || req.method == \"PURGE\") {\n ban(\"req.url ~ \" + req.url);\n # Throw a synthetic page so the request won't go to the backend.\n return (synth(200, \"Ban added.\"));\n }\n }\n\n # Non-RFC2616 or CONNECT which is weird, we pipe that\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n return (pipe);\n }\n\n # Large binary files are passed.\n if (req.url ~ \"\\.(msi|exe|dmg|zip|tgz|gz|pkg)$\") {\n return(pass);\n }\n\n # We only try to cache GET and HEAD, other things are passed.\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n # Any requests with Basic Authentication are passed.\n if (req.http.Authorization || req.http.Authenticate) {\n return (pass);\n }\n\n # Blackfire requests are passed.\n if (req.http.X-Blackfire-Query) {\n return (pass);\n }\n\n # Some URLs should never be cached.\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/admin([\/?]|$).*$\" ||\n req.url ~ \"^\/info([\/?]|$).*$\" ||\n req.url ~ \"^\/flag([\/?]|$).*$\" ||\n req.url ~ \"^.*\/system\/files([\/?]|$).*$\" ||\n req.url ~ \"^\/cgi\" ||\n req.url ~ \"^\/cgi-bin\"\n ) {\n return (pass);\n }\n\n # Plupload likes to get piped.\n if (req.url ~ \"^.*\/plupload-handle-uploads.*$\") {\n return (pipe);\n }\n\n # Handle compression correctly. Different browsers send different\n # \"Accept-Encoding\" headers, even though they mostly all support the same\n # compression mechanisms. By consolidating these compression headers into\n # a consistent format, we can reduce the size of the cache and get more hits.=\n # @see: http:\/\/ varnish.projects.linpro.no\/wiki\/FAQ\/Compression\n if (req.http.Accept-Encoding) {\n if (req.http.Accept-Encoding ~ \"gzip\") {\n # If the browser supports it, we'll use gzip.\n set req.http.Accept-Encoding = \"gzip\";\n }\n else if (req.http.Accept-Encoding ~ \"deflate\") {\n # Next, try deflate if it is supported.\n set req.http.Accept-Encoding = \"deflate\";\n }\n else {\n # Unknown algorithm. Remove it and send unencoded.\n unset req.http.Accept-Encoding;\n }\n }\n\n # Always cache the following file types for all users.\n if (req.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n unset req.http.Cookie;\n }\n\n # Remove all cookies that Drupal doesn't need to know about. ANY remaining\n # cookie will cause the request to pass-through to a backend. For the most part\n # we always set the NO_CACHE cookie after any POST request, disabling the\n # Varnish cache temporarily. The session cookie allows all authenticated users\n # to pass through as long as they're logged in.\n #\n # 1. Append a semi-colon to the front of the cookie string.\n # 2. Remove all spaces that appear after semi-colons.\n # 3. Match the cookies we want to keep, adding the space we removed\n # previously, back. (\\1) is first matching group in the regsuball.\n # 4. Remove all other cookies, identifying them by the fact that they have\n # no space after the preceding semi-colon.\n # 5. Remove all spaces and semi-colons from the beginning and end of the\n # cookie string.\n if (req.http.Cookie) {\n set req.http.CookieCheck = \";\" + req.http.Cookie;\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"; +\", \";\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";(${VARNISH_COOKIECHECK:-SESS[a-z0-9]+|SSESS[a-z0-9]+|NO_CACHE})=\", \"; \\1=\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";[^ ][^;]*\", \"\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"^[; ]+|[; ]+$\", \"\");\n\n set req.http.Cookie = req.http.Cookie + \";\";\n\n if (req.http.CookieCheck == \"\") {\n # If there are no remaining cookies, remove the cookie header. If there\n # aren't any cookie headers, Varnish's default behavior will be to cache\n # the page.\n\n unset req.http.CookieCheck;\n unset req.http.Cookie;\n }\n else {\n # If there is any cookies left (a session or NO_CACHE cookie), do not\n # cache the page. Pass it on to Apache directly.\n unset req.http.CookieCheck;\n return (pass);\n }\n }\n\n # Cacheable, lookup in cache.\n return (hash);\n}\n\nsub vcl_pipe {\n # Support for Websockets\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n set bereq.http.connection = req.http.connection;\n }\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n # normal hit\n return (deliver);\n }\n # We have no fresh fish. Lets look at the stale ones.\n if (std.healthy(req.backend_hint)) {\n # Backend is healthy. If the object is not older then 30secs, deliver it to the client\n # and automatically create a separate backend request to warm the cache for this request.\n if (obj.ttl + 30s > 0s) {\n set req.http.grace = \"normal(limited)\";\n return (deliver);\n } else {\n # No candidate for grace. Fetch a fresh object.\n return (miss);\n }\n }\n else {\n # backend is sick - use full grace\n if (obj.ttl + obj.grace > 0s) {\n set req.http.grace = \"full\";\n return (deliver);\n } else {\n # no graced object.\n return (miss);\n }\n }\n}\n\nsub vcl_backend_response {\n # Allow items to be stale if needed.\n set beresp.grace = 6h;\n\n # Set ban-lurker friendly custom headers.\n set beresp.http.X-Url = bereq.url;\n set beresp.http.X-Host = bereq.http.host;\n\n # If the backend sends a X-LAGOON-VARNISH-BACKEND-BYPASS header we directly deliver\n if (beresp.http.X-LAGOON-VARNISH-BACKEND-BYPASS == \"TRUE\") {\n return (deliver);\n }\n\n # Cache 404 and 403 for 10 seconds\n if (beresp.status == 404 || beresp.status == 403) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n # Don't allow static files to set cookies.\n if (bereq.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n unset beresp.http.set-cookie;\n unset beresp.http.Cache-Control;\n\n # If an asset would come back with statuscode 500 we only cache it for 10 seconds instead of the usual static file cache\n if (beresp.status == 500) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n set beresp.ttl = ${VARNISH_ASSETS_TTL:-2628001}s;\n set beresp.http.Cache-Control = \"public, max-age=${VARNISH_ASSETS_TTL:-2628001}\";\n set beresp.http.Expires = \"\" + (now + beresp.ttl);\n }\n\n if (!beresp.http.Surrogate-Control && beresp.http.Cache-Control ~ \"(?i:no-cache|no-store|private)\") {\n # Mark as \"Hit-For-Miss\" for the next 120 seconds\n set beresp.ttl = 120s;\n set beresp.uncacheable = true;\n }\n\n # Files larger than 10 MB get streamed.\n if (beresp.http.Content-Length ~ \"[0-9]{8,}\") {\n set beresp.do_stream = true;\n set beresp.uncacheable = true;\n set beresp.ttl = 120s;\n }\n\n # Disable buffering only for BigPipe responses\n if (beresp.http.Surrogate-Control ~ \"BigPipe\/1.0\") {\n set beresp.do_stream = true;\n set beresp.ttl = 0s;\n }\n\n return (deliver);\n}\n\n# Set a header to track a cache HIT\/MISS.\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Varnish-Cache = \"HIT\";\n }\n else {\n set resp.http.X-Varnish-Cache = \"MISS\";\n }\n\n # Remove ban-lurker friendly custom headers when delivering to client.\n unset resp.http.X-Url;\n unset resp.http.X-Host;\n\n # unset Cache-Tags Header by default, can be disabled with VARNISH_SET_HEADER_CACHE_TAGS=true\n if (!${VARNISH_SET_HEADER_CACHE_TAGS:-false}) {\n unset resp.http.Cache-Tags;\n }\n\n unset resp.http.X-Generator;\n unset resp.http.Server;\n # Inject information about grace\n if (req.http.grace) {\n set resp.http.X-Varnish-Grace = req.http.grace;\n }\n set resp.http.X-LAGOON = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}>\" + resp.http.X-LAGOON;\n return (deliver);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n }\n else {\n hash_data(server.ip);\n }\n if (req.http.X-Forwarded-Proto) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n if (req.http.HTTPS) {\n hash_data(req.http.HTTPS);\n }\n return (lookup);\n}\n\nsub vcl_synth {\n if (resp.status == 701) {\n set resp.status = 401;\n set resp.http.Content-Type = \"text\/plain; charset=utf-8\";\n synthetic({\"XMLRPC Interface is blocked due to SA-CORE-2014-004 - mail support@amazee.io if you need it.\"});\n return (deliver);\n }\n if (resp.status == 700) {\n # Set a status the client will understand\n set resp.status = 200;\n # Create our synthetic response\n synthetic(\"\");\n return(deliver);\n }\n return (deliver);\n}\n\nsub vcl_backend_error {\n # Restart the request, when we have a backend server error, to try another backend.\n # Restart max twice.\n if (bereq.retries < 2) {\n return(retry);\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic({\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<head>\n <title>Server Error<\/title>\n <style type=\"text\/css\">\n body {\n font-family: helvetica, arial, sans-serif;\n }\n img {\n margin-top: 50px;\n }\n p {\n width: 6 00px;\n margin-top: 10px\n }\n div {\n background: #ccc;\n width: 600px;\n margin: auto;\n padding: 50px;\n }\n span {\n color: #ccc\n }\n <\/style>\n<\/head>\n<body>\n <div>\n <h1>We are sorry...<\/h1>\n <p>We encountered a server-side error. This means that the problem is not with your computer or Internet connection, but rather with the website's server.<\/p>\n <p>We are currently working on solving this problem and apologise for the inconvenience.<\/p>\n <span>\n <strong>Technical Information<\/strong><br \/>\n Error \"} + beresp.status + \" \" + beresp.reason + {\"<br \/>\n XID: \"} + bereq.xid + {\"<br \/>\n <\/span>\n <\/div>\n<\/body>\n<\/html>\n\n\"});\n return (deliver);\n}\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"05d4114a44f294ce7d993848a4eed026026bf149","subject":"VCL no longer caches search results","message":"VCL no longer caches search results\n","repos":"timwhitlock\/php-varnish","old_file":"wordpress-plugin\/wordpress.vcl","new_file":"wordpress-plugin\/wordpress.vcl","new_contents":"\r\nbackend origin {\r\n .host = \"localhost\";\r\n .port = \"8080\";\r\n}\r\n\r\n\r\nsub vcl_recv {\r\n\t# only using one backend\r\n\tset req.backend = origin;\r\n\t\r\n\t# set standard proxied ip header for getting original remote address\r\n\tset req.http.X-Forwarded-For = client.ip;\r\n\t\r\n\t# logged in users must always pass\r\n\tif( req.url ~ \"^\/wp-(login|admin)\" || req.http.Cookie ~ \"wordpress_logged_in_\" ){\r\n\t return (pass);\r\n\t}\r\n \r\n # don't cache search results\r\n if( req.url ~ \"\\?s=\" ){\r\n return (pass);\r\n }\r\n\r\n\t# always pass through posted requests and those with basic auth\r\n\tif ( req.request == \"POST\" || req.http.Authorization ) {\r\n \t\treturn (pass);\r\n\t}\r\n\t\r\n\t# else ok to fetch a cached page\r\n\tunset req.http.Cookie;\r\n\treturn (lookup);\r\n}\r\n\r\n\r\n\r\nsub vcl_fetch {\r\n\r\n\t# remove some headers we never want to see\r\n\tunset beresp.http.Server;\r\n\tunset beresp.http.X-Powered-By;\r\n\t\r\n\t# only allow cookies to be set if we're in admin area - i.e. commenters stay logged out\r\n\tif( beresp.http.Set-Cookie && req.url !~ \"^\/wp-(login|admin)\" ){\r\n\t\tunset beresp.http.Set-Cookie;\r\n\t}\r\n\t\r\n\t# don't cache response to posted requests or those with basic auth\r\n\tif ( req.request == \"POST\" || req.http.Authorization ) {\r\n \t\treturn (pass);\r\n\t}\r\n\t\r\n\t# Trust Varnish if it says this is not cacheable\r\n\tif ( ! beresp.cacheable ) {\r\n \treturn (pass);\r\n \t}\r\n\r\n\t# only cache status ok\r\n\tif ( beresp.status != 200 ) {\r\n\t\treturn (pass);\r\n\t}\r\n\r\n # don't cache search results\r\n if( req.url ~ \"\\?s=\" ){\r\n return (pass);\r\n }\r\n\t\r\n\t# else ok to cache the response\r\n\tset beresp.ttl = 24h;\r\n\treturn (deliver);\r\n}\r\n\r\n\r\n\r\nsub vcl_deliver {\r\n\t# add debugging headers, so we can see what's cached\r\n\tif (obj.hits > 0) {\r\n\t\tset resp.http.X-Cache = \"HIT\";\r\n \t}\r\n \telse {\r\n\t\tset resp.http.X-Cache = \"MISS\";\r\n\t}\r\n\t# remove some headers added by varnish\r\n\tunset resp.http.Via;\r\n\tunset resp.http.X-Varnish;\r\n}\r\n\r\n\r\n\r\nsub vcl_hash {\r\n set req.hash += req.url;\r\n # altering hash so subdomains are ignored.\r\n # don't do this if you actually run different sites on different subdomains\r\n if ( req.http.host ) {\r\n set req.hash += regsub( req.http.host, \"^([^\\.]+\\.)+([a-z]+)$\", \"\\1\\2\" );\r\n } else {\r\n set req.hash += server.ip;\r\n }\r\n # ensure separate cache for mobile clients (WPTouch workaround)\r\n if( req.http.User-Agent ~ \"(iPod|iPhone|incognito|webmate|dream|CUPCAKE|WebOS|blackberry9\\d\\d\\d)\" ){\r\n \tset req.hash += \"touch\";\r\n }\r\n return (hash);\r\n} \r\n","old_contents":"\r\nbackend origin {\r\n\t.host = \"localhost\";\r\n\t.port = \"8080\";\r\n}\r\n\r\n\r\nsub vcl_recv {\r\n\t# only using one backend\r\n\tset req.backend = origin;\r\n\t\t\r\n\t# set standard proxied ip header for getting original remote address\r\n\tset req.http.X-Forwarded-For = client.ip;\r\n\t\r\n\t# logged in users must always pass\r\n\tif( req.url ~ \"^\/wp-(login|admin)\" || req.http.Cookie ~ \"wordpress_logged_in_\" ){\r\n\t\treturn (pass);\r\n\t}\r\n\r\n\t# always pass through posted requests and those with basic auth\r\n\tif ( req.request == \"POST\" || req.http.Authorization ) {\r\n \t\treturn (pass);\r\n\t}\r\n\t\r\n\t# else ok to fetch a cached page\r\n\tunset req.http.Cookie;\r\n\treturn (lookup);\r\n}\r\n\r\n\r\n\r\nsub vcl_fetch {\r\n\r\n\t# remove some headers we never want to see\r\n\tunset beresp.http.Server;\r\n\tunset beresp.http.X-Powered-By;\r\n\t\r\n\t# only allow cookies to be set if we're in admin area - i.e. commenters stay logged out\r\n\tif( beresp.http.Set-Cookie && req.url !~ \"^\/wp-(login|admin)\" ){\r\n\t\tunset beresp.http.Set-Cookie;\r\n\t}\r\n\t\r\n\t# don't cache response to posted requests or those with basic auth\r\n\tif ( req.request == \"POST\" || req.http.Authorization ) {\r\n \t\treturn (pass);\r\n\t}\r\n\t\r\n\t# Trust Varnish if it says this is not cacheable\r\n\tif ( ! beresp.cacheable ) {\r\n \treturn (pass);\r\n \t}\r\n\r\n\t# only cache status ok\r\n\tif ( beresp.status != 200 ) {\r\n\t\treturn (pass);\r\n\t}\r\n\t\r\n\t# else ok to cache the response\r\n\tset beresp.ttl = 24h;\r\n\treturn (deliver);\r\n}\r\n\r\n\r\n\r\nsub vcl_deliver {\r\n\t# add debugging headers, so we can see what's cached\r\n\tif (obj.hits > 0) {\r\n\t\tset resp.http.X-Cache = \"HIT\";\r\n \t}\r\n \telse {\r\n\t\tset resp.http.X-Cache = \"MISS\";\r\n\t}\r\n\t# remove some headers added by varnish\r\n\tunset resp.http.Via;\r\n\tunset resp.http.X-Varnish;\r\n}\r\n\r\n\r\n\r\nsub vcl_hash {\r\n set req.hash += req.url;\r\n # altering hash so subdomains are ignored.\r\n # don't do this if you actually run different sites on different subdomains\r\n if ( req.http.host ) {\r\n set req.hash += regsub( req.http.host, \"^([^\\.]+\\.)+([a-z]+)$\", \"\\1\\2\" );\r\n } else {\r\n set req.hash += server.ip;\r\n }\r\n # ensure separate cache for mobile clients (WPTouch workaround)\r\n if( req.http.User-Agent ~ \"(iPod|iPhone|incognito|webmate|dream|CUPCAKE|WebOS|blackberry9\\d\\d\\d)\" ){\r\n \tset req.hash += \"touch\";\r\n }\r\n return (hash);\r\n} \r\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"aad325cff524b5242693faca2048cf1b0db9b6e2","subject":"Avoid passing stale content from Shield POP to Edge POP (#1983)","message":"Avoid passing stale content from Shield POP to Edge POP (#1983)\n\nWe set stale-while-revalidate cache-control directives on our responses from origin and those responses get forwarded from our shield POPs to the other POPs. When we issue a soft-purge in Fastly, Fastly marks the content as stale and serves the content in respect of the stale-while-revalidate directive. For requests which go direct from a browser to a shield POP, they get a stale response and eventually will get the newly updated response when the stale-while-revalidate time has expired. For requests which go to another POP, the request gets served a stale response and then the POP requests the same content from our shield POP, which may end up serving the stale content as well (including the cache-control directives), which the original POP will then cache for a very long time. \r\n\r\nThe solution to this is to detect when a request has come from a Fastly POP to our shield POP and to make the request not honour the stale-while-revalidate directive and instead get served a fresh response immediately, thereby ensuring that a soft-purge of a resource works correctly across the entire Fastly network.\r\n\r\nThis can be achieved by adding to our vcl_recv subroutine:\r\n\r\n```vcl\r\nif (req.http.Fastly-FF) {\r\n # avoid passing stale content from Shield POP to Edge POP\r\n set req.max_stale_while_revalidate = 0s;\r\n}\r\n```\r\n\r\nFixes https:\/\/github.com\/Financial-Times\/polyfill-service\/issues\/1963","repos":"JakeChampion\/polyfill-service,JakeChampion\/polyfill-service","old_file":"fastly\/vcl\/polyfill-service.vcl","new_file":"fastly\/vcl\/polyfill-service.vcl","new_contents":"sub set_backend {\n\t# The Fastly macro is inserted before the backend is selected because the\n\t# macro has the code which defines the values avaiable for req.http.Host\n\t# but it also contains a default backend which is always set to the EU. I wish we could disable the default backend setting.\n\t#FASTLY recv\n\t\n\t# Calculate the ideal region to route the request to.\n \tdeclare local var.region STRING; \n\tif (server.region ~ \"(APAC|Asia|North-America|South-America|US-Central|US-East|US-West)\") {\n\t\tset var.region = \"US\";\n \t} else {\n\t\tset var.region = \"EU\";\n \t}\n\n\t# Gather the health of the shields and origins.\n\tdeclare local var.v3_eu_is_healthy BOOL;\n\tset req.backend = F_v3_eu;\n\tset var.v3_eu_is_healthy = req.backend.healthy;\n\n\tdeclare local var.v3_us_is_healthy BOOL;\n \tset req.backend = F_v3_us;\n \tset var.v3_us_is_healthy = req.backend.healthy;\n\n \tdeclare local var.shield_eu_is_healthy BOOL;\n \tset req.backend = ssl_shield_london_city_uk;\n \tset var.shield_eu_is_healthy = req.backend.healthy;\n\n \tdeclare local var.shield_us_is_healthy BOOL;\n \tset req.backend = ssl_shield_iad_va_us;\n \tset var.shield_us_is_healthy = req.backend.healthy;\n\n \t# Set some sort of default, that shouldn't get used.\n \tset req.backend = F_v3_eu;\n\n\tdeclare local var.EU_shield_server_name STRING;\n\tset var.EU_shield_server_name = \"LCY\";\n\n\tdeclare local var.US_shield_server_name STRING;\n\tset var.US_shield_server_name = \"IAD\";\n\n\t# Route EU requests to the nearest healthy shield or origin.\n \tif (var.region == \"EU\") {\n\t\tif (server.datacenter != var.EU_shield_server_name && req.http.Request_Came_From_Shield != var.EU_shield_server_name && var.shield_eu_is_healthy) {\n\t\t\tset req.backend = ssl_shield_london_city_uk;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t\tset req.http.Host = req.http.EU_Host;\n\t\t} elseif (var.shield_us_is_healthy) {\n\t\t\tset req.backend = ssl_shield_iad_va_us;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t\tset req.http.Host = req.http.US_Host;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_eu;\n\t\t}\n \t}\n\n\t# Route US requests to the nearest healthy shield or origin.\n \tif (var.region == \"US\") {\n\t\tif (server.datacenter != var.US_shield_server_name && req.http.Request_Came_From_Shield != var.US_shield_server_name && var.shield_us_is_healthy) {\n\t\t\tset req.backend = ssl_shield_iad_va_us;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t\tset req.http.Host = req.http.US_Host;\n\t\t} elseif (var.shield_eu_is_healthy) {\n\t\t\tset req.backend = ssl_shield_london_city_uk;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t\tset req.http.Host = req.http.EU_Host;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_us;\n\t\t}\n\t}\n\n\t# Persist the decision so we can debug the result.\n \tset req.http.Debug-Backend = req.backend;\n}\n\nsub vcl_recv {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_recv;\n\t}\n\n\tif (req.method != \"GET\" && req.method != \"HEAD\" && req.method != \"OPTIONS\" && req.method != \"FASTLYPURGE\" && req.method != \"PURGE\") {\n\t\terror 911;\n\t}\n\n\tif (req.method == \"OPTIONS\") {\n\t\terror 912;\n\t}\n\n\t# Because the old service had a router which allowed any words between \/v2\/polyfill. and .js\n\tif (req.url.path ~ \"^\/v2\/polyfill(\\.\\w+)(\\.\\w+)?\" && req.url.ext == \"js\") {\n\t\tif (re.group.2) {\n\t\t\tset req.url = \"\/v2\/polyfill.min.js?\" req.url.qs;\n\t\t} else {\n\t\t\tset req.url = \"\/v2\/polyfill.js?\" req.url.qs;\n\t\t}\n\t}\n\n\t# Override the v3 defaults with the defaults of v2\n\tif (req.url ~ \"^\/v2\/polyfill(\\.min)?\\.js\") {\n\t\tset req.url = regsub(req.url, \"^\/v2\", \"\/v3\");\n\t\tset req.url = querystring.set(req.url, \"version\", \"3.25.1\");\n\t\tdeclare local var.unknown STRING;\n\t\tset var.unknown = subfield(req.url.qs, \"unknown\", \"&\");\n\t\tset req.url = querystring.set(req.url, \"unknown\", if(var.unknown != \"\", var.unknown, \"ignore\"));\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\") {\n\t\tcall normalise_querystring_parameters_for_polyfill_bundle;\n\t\t# Sort the querystring parameters alphabetically to improve chances of hitting a cached copy.\n\t\t# If querystring is empty, remove the ? from the url.\n\t\tset req.url = querystring.clean(querystring.sort(req.url));\n\t\tcall set_backend;\n\t} else {\n\t\t# The request is to an endpoint which doesn't use query parameters, let's remove them to increase our cache-hit-ratio\n\t\tset req.url = querystring.remove(req.url);\n\t\tcall set_backend;\n\t}\n\t\n\tif (req.backend == ssl_shield_iad_va_us || req.backend == ssl_shield_london_city_uk) {\n\t\t# avoid passing stale content from Shield POP to Edge POP\n\t\tset req.max_stale_while_revalidate = 0s;\n\t}\n}\n\nsub vcl_hash {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_hash;\n\t}\n\n\t# We are not adding req.http.host to the hash because we want https:\/\/cdn.polyfill.io and https:\/\/polyfill.io to be a single object in the cache.\n\t# set req.hash += req.http.host;\n\tset req.hash += req.url;\n\t# We include return(hash) to stop the function falling through to the default VCL built into varnish, which for vcl_hash will add req.url and req.http.Host to the hash.\n\treturn(hash);\n}\n\n\nsub shielding_header {\n\tif (req.backend == ssl_shield_iad_va_us) {\n\t\tset req.http.Request_Came_From_Shield = server.datacenter;\n\t} elsif (req.backend == ssl_shield_london_city_uk) {\n\t\tset req.http.Request_Came_From_Shield = server.datacenter;\n\t}\n}\n\nsub vcl_miss {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_miss;\n\t}\n\tcall shielding_header;\n}\n\nsub vcl_pass {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_pass;\n\t}\n\tcall shielding_header;\n}\n\nsub vcl_fetch {\n\tset beresp.http.Request_Came_From_Shield = req.http.Request_Came_From_Shield;\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_fetch;\n\t}\n\n\t# These header are only required for HTML documents.\n\tif (beresp.http.Content-Type ~ \"text\/html\") {\n\t\t# Enables the cross-site scripting filter built into most modern web browsers.\n\t\tset beresp.http.X-XSS-Protection = \"1; mode=block\";\t\n\t}\n\t# Prevents MIME-sniffing a response away from the declared content type.\n\tset beresp.http.X-Content-Type-Options = \"nosniff\";\n\n\t# Ensure the site is only served over HTTPS and reduce the chances of someone performing a MITM attack.\n\tset beresp.http.Strict-Transport-Security = \"max-age=31536000; includeSubdomains; preload\";\n\n\t# The Referrer-Policy header governs which referrer information, sent in the Referer header, should be included with requests made.\n\t# Send a full URL when performing a same-origin request, but only send the origin of the document for other cases.\n\tset beresp.http.Referrer-Policy = \"origin-when-cross-origin\";\n\n\t# Enable purging of all objects in the Fastly cache by issuing a purge with the key \"polyfill-service\".\n\tif (beresp.http.Surrogate-Key !~ \"\\bpolyfill-service\\b\") {\n\t\tset beresp.http.Surrogate-Key = if(beresp.http.Surrogate-Key, beresp.http.Surrogate-Key \" polyfill-service\", \"polyfill-service\");\n\t}\n\n\tset beresp.http.Timing-Allow-Origin = \"*\";\n\n\tif (req.http.Normalized-User-Agent) {\n\t\tset beresp.http.Normalized-User-Agent = req.http.Normalized-User-Agent;\n\t\tset beresp.http.Detected-User-Agent = req.http.useragent_parser_family \"\/\" req.http.useragent_parser_major \".\" req.http.useragent_parser_minor \".\" req.http.useragent_parser_patch;\n\t}\n}\n\nsub vcl_deliver {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_deliver;\n\t}\n\n\tset req.http.Fastly-Force-Shield = \"yes\";\n\n\t# Allow cross origin GET, HEAD, and OPTIONS requests to be made.\n\tif (req.http.Origin) {\n\t\tset resp.http.Access-Control-Allow-Origin = \"*\";\n\t\tset resp.http.Access-Control-Allow-Methods = \"GET,HEAD,OPTIONS\";\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\" && !resp.http.Request_Came_From_Shield && req.backend != ssl_shield_iad_va_us && req.backend != ssl_shield_london_city_uk) {\n\t\t# Need to add \"Vary: User-Agent\" in after vcl_fetch to avoid the \n\t\t# \"Vary: User-Agent\" entering the Varnish cache.\n\t\t# We need \"Vary: User-Agent\" in the browser cache because a browser\n\t\t# may update itself to a version which needs different polyfills\n\t\t# So we need to have it ignore the browser cached bundle when the user-agent changes.\n\t\tset resp.http.Vary = \"User-Agent, Accept-Encoding\";\n\t}\n\n\tadd resp.http.Server-Timing = fastly_info.state {\", fastly;desc=\"Edge time\";dur=\"} time.elapsed.msec;\n\n\tif (req.http.Fastly-Debug) {\n\t\tset resp.http.Debug-Backend = req.http.Debug-Backend;\n\t\tset resp.http.Debug-Host = req.http.Host;\n\t\tset resp.http.Debug-Fastly-Restarts = req.restarts;\n\t\tset resp.http.Debug-Orig-URL = req.http.Orig-URL;\n\t\tset resp.http.Debug-VCL-Route = req.http.X-VCL-Route;\n\t\tset resp.http.useragent_parser_family = req.http.useragent_parser_family;\n\t\tset resp.http.useragent_parser_major = req.http.useragent_parser_major;\n\t\tset resp.http.useragent_parser_minor = req.http.useragent_parser_minor;\n\t\tset resp.http.useragent_parser_patch = req.http.useragent_parser_patch;\n\t} else {\n\t\tunset resp.http.Server;\n\t\tunset resp.http.Via;\n\t\tunset resp.http.X-Cache;\n\t\tunset resp.http.X-Cache-Hits;\n\t\tunset resp.http.X-Served-By;\n\t\tunset resp.http.X-Timer;\n\t\tunset resp.http.Fastly-Restarts;\n\t\tunset resp.http.X-PreFetch-Pass;\n\t\tunset resp.http.X-PreFetch-Miss;\n\t\tunset resp.http.X-PostFetch;\n\t}\n}\n\nsub vcl_error {\n\tif (obj.status == 911) {\n\t\tset obj.status = 405;\n\t\tset obj.response = \"METHOD NOT ALLOWED\";\n\t\tset obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n\t\tset obj.http.Cache-Control = \"private, no-store\";\n\t\tsynthetic req.method \" METHOD NOT ALLOWED\";\n\t\treturn (deliver);\n\t}\n\tif (obj.status == 912) {\n\t\tset obj.status = 200;\n\t\tset obj.response = \"OK\";\n\t\tset obj.http.Allow = \"OPTIONS, GET, HEAD\";\n\t\treturn (deliver);\n\t}\n}\n","old_contents":"sub set_backend {\n\t# The Fastly macro is inserted before the backend is selected because the\n\t# macro has the code which defines the values avaiable for req.http.Host\n\t# but it also contains a default backend which is always set to the EU. I wish we could disable the default backend setting.\n\t#FASTLY recv\n\t\n\t# Calculate the ideal region to route the request to.\n \tdeclare local var.region STRING; \n\tif (server.region ~ \"(APAC|Asia|North-America|South-America|US-Central|US-East|US-West)\") {\n\t\tset var.region = \"US\";\n \t} else {\n\t\tset var.region = \"EU\";\n \t}\n\n\t# Gather the health of the shields and origins.\n\tdeclare local var.v3_eu_is_healthy BOOL;\n\tset req.backend = F_v3_eu;\n\tset var.v3_eu_is_healthy = req.backend.healthy;\n\n\tdeclare local var.v3_us_is_healthy BOOL;\n \tset req.backend = F_v3_us;\n \tset var.v3_us_is_healthy = req.backend.healthy;\n\n \tdeclare local var.shield_eu_is_healthy BOOL;\n \tset req.backend = ssl_shield_london_city_uk;\n \tset var.shield_eu_is_healthy = req.backend.healthy;\n\n \tdeclare local var.shield_us_is_healthy BOOL;\n \tset req.backend = ssl_shield_iad_va_us;\n \tset var.shield_us_is_healthy = req.backend.healthy;\n\n \t# Set some sort of default, that shouldn't get used.\n \tset req.backend = F_v3_eu;\n\n\tdeclare local var.EU_shield_server_name STRING;\n\tset var.EU_shield_server_name = \"LCY\";\n\n\tdeclare local var.US_shield_server_name STRING;\n\tset var.US_shield_server_name = \"IAD\";\n\n\t# Route EU requests to the nearest healthy shield or origin.\n \tif (var.region == \"EU\") {\n\t\tif (server.datacenter != var.EU_shield_server_name && req.http.Request_Came_From_Shield != var.EU_shield_server_name && var.shield_eu_is_healthy) {\n\t\t\tset req.backend = ssl_shield_london_city_uk;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t\tset req.http.Host = req.http.EU_Host;\n\t\t} elseif (var.shield_us_is_healthy) {\n\t\t\tset req.backend = ssl_shield_iad_va_us;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t\tset req.http.Host = req.http.US_Host;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_eu;\n\t\t}\n \t}\n\n\t# Route US requests to the nearest healthy shield or origin.\n \tif (var.region == \"US\") {\n\t\tif (server.datacenter != var.US_shield_server_name && req.http.Request_Came_From_Shield != var.US_shield_server_name && var.shield_us_is_healthy) {\n\t\t\tset req.backend = ssl_shield_iad_va_us;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t\tset req.http.Host = req.http.US_Host;\n\t\t} elseif (var.shield_eu_is_healthy) {\n\t\t\tset req.backend = ssl_shield_london_city_uk;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t\tset req.http.Host = req.http.EU_Host;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_us;\n\t\t}\n\t}\n\n\t# Persist the decision so we can debug the result.\n \tset req.http.Debug-Backend = req.backend;\n}\n\nsub vcl_recv {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_recv;\n\t}\n\n\tif (req.method != \"GET\" && req.method != \"HEAD\" && req.method != \"OPTIONS\" && req.method != \"FASTLYPURGE\" && req.method != \"PURGE\") {\n\t\terror 911;\n\t}\n\n\tif (req.method == \"OPTIONS\") {\n\t\terror 912;\n\t}\n\n\t# Because the old service had a router which allowed any words between \/v2\/polyfill. and .js\n\tif (req.url.path ~ \"^\/v2\/polyfill(\\.\\w+)(\\.\\w+)?\" && req.url.ext == \"js\") {\n\t\tif (re.group.2) {\n\t\t\tset req.url = \"\/v2\/polyfill.min.js?\" req.url.qs;\n\t\t} else {\n\t\t\tset req.url = \"\/v2\/polyfill.js?\" req.url.qs;\n\t\t}\n\t}\n\n\t# Override the v3 defaults with the defaults of v2\n\tif (req.url ~ \"^\/v2\/polyfill(\\.min)?\\.js\") {\n\t\tset req.url = regsub(req.url, \"^\/v2\", \"\/v3\");\n\t\tset req.url = querystring.set(req.url, \"version\", \"3.25.1\");\n\t\tdeclare local var.unknown STRING;\n\t\tset var.unknown = subfield(req.url.qs, \"unknown\", \"&\");\n\t\tset req.url = querystring.set(req.url, \"unknown\", if(var.unknown != \"\", var.unknown, \"ignore\"));\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\") {\n\t\tcall normalise_querystring_parameters_for_polyfill_bundle;\n\t\t# Sort the querystring parameters alphabetically to improve chances of hitting a cached copy.\n\t\t# If querystring is empty, remove the ? from the url.\n\t\tset req.url = querystring.clean(querystring.sort(req.url));\n\t\tcall set_backend;\n\t} else {\n\t\t# The request is to an endpoint which doesn't use query parameters, let's remove them to increase our cache-hit-ratio\n\t\tset req.url = querystring.remove(req.url);\n\t\tcall set_backend;\n\t}\n}\n\nsub vcl_hash {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_hash;\n\t}\n\n\t# We are not adding req.http.host to the hash because we want https:\/\/cdn.polyfill.io and https:\/\/polyfill.io to be a single object in the cache.\n\t# set req.hash += req.http.host;\n\tset req.hash += req.url;\n\t# We include return(hash) to stop the function falling through to the default VCL built into varnish, which for vcl_hash will add req.url and req.http.Host to the hash.\n\treturn(hash);\n}\n\n\nsub shielding_header {\n\tif (req.backend == ssl_shield_iad_va_us) {\n\t\tset req.http.Request_Came_From_Shield = server.datacenter;\n\t} elsif (req.backend == ssl_shield_london_city_uk) {\n\t\tset req.http.Request_Came_From_Shield = server.datacenter;\n\t}\n}\n\nsub vcl_miss {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_miss;\n\t}\n\tcall shielding_header;\n}\n\nsub vcl_pass {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_pass;\n\t}\n\tcall shielding_header;\n}\n\nsub vcl_fetch {\n\tset beresp.http.Request_Came_From_Shield = req.http.Request_Came_From_Shield;\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_fetch;\n\t}\n\n\t# These header are only required for HTML documents.\n\tif (beresp.http.Content-Type ~ \"text\/html\") {\n\t\t# Enables the cross-site scripting filter built into most modern web browsers.\n\t\tset beresp.http.X-XSS-Protection = \"1; mode=block\";\t\n\t}\n\t# Prevents MIME-sniffing a response away from the declared content type.\n\tset beresp.http.X-Content-Type-Options = \"nosniff\";\n\n\t# Ensure the site is only served over HTTPS and reduce the chances of someone performing a MITM attack.\n\tset beresp.http.Strict-Transport-Security = \"max-age=31536000; includeSubdomains; preload\";\n\n\t# The Referrer-Policy header governs which referrer information, sent in the Referer header, should be included with requests made.\n\t# Send a full URL when performing a same-origin request, but only send the origin of the document for other cases.\n\tset beresp.http.Referrer-Policy = \"origin-when-cross-origin\";\n\n\t# Enable purging of all objects in the Fastly cache by issuing a purge with the key \"polyfill-service\".\n\tif (beresp.http.Surrogate-Key !~ \"\\bpolyfill-service\\b\") {\n\t\tset beresp.http.Surrogate-Key = if(beresp.http.Surrogate-Key, beresp.http.Surrogate-Key \" polyfill-service\", \"polyfill-service\");\n\t}\n\n\tset beresp.http.Timing-Allow-Origin = \"*\";\n\n\tif (req.http.Normalized-User-Agent) {\n\t\tset beresp.http.Normalized-User-Agent = req.http.Normalized-User-Agent;\n\t\tset beresp.http.Detected-User-Agent = req.http.useragent_parser_family \"\/\" req.http.useragent_parser_major \".\" req.http.useragent_parser_minor \".\" req.http.useragent_parser_patch;\n\t}\n}\n\nsub vcl_deliver {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_deliver;\n\t}\n\n\tset req.http.Fastly-Force-Shield = \"yes\";\n\n\t# Allow cross origin GET, HEAD, and OPTIONS requests to be made.\n\tif (req.http.Origin) {\n\t\tset resp.http.Access-Control-Allow-Origin = \"*\";\n\t\tset resp.http.Access-Control-Allow-Methods = \"GET,HEAD,OPTIONS\";\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\" && !resp.http.Request_Came_From_Shield && req.backend != ssl_shield_iad_va_us && req.backend != ssl_shield_london_city_uk) {\n\t\t# Need to add \"Vary: User-Agent\" in after vcl_fetch to avoid the \n\t\t# \"Vary: User-Agent\" entering the Varnish cache.\n\t\t# We need \"Vary: User-Agent\" in the browser cache because a browser\n\t\t# may update itself to a version which needs different polyfills\n\t\t# So we need to have it ignore the browser cached bundle when the user-agent changes.\n\t\tset resp.http.Vary = \"User-Agent, Accept-Encoding\";\n\t}\n\n\tadd resp.http.Server-Timing = fastly_info.state {\", fastly;desc=\"Edge time\";dur=\"} time.elapsed.msec;\n\n\tif (req.http.Fastly-Debug) {\n\t\tset resp.http.Debug-Backend = req.http.Debug-Backend;\n\t\tset resp.http.Debug-Host = req.http.Host;\n\t\tset resp.http.Debug-Fastly-Restarts = req.restarts;\n\t\tset resp.http.Debug-Orig-URL = req.http.Orig-URL;\n\t\tset resp.http.Debug-VCL-Route = req.http.X-VCL-Route;\n\t\tset resp.http.useragent_parser_family = req.http.useragent_parser_family;\n\t\tset resp.http.useragent_parser_major = req.http.useragent_parser_major;\n\t\tset resp.http.useragent_parser_minor = req.http.useragent_parser_minor;\n\t\tset resp.http.useragent_parser_patch = req.http.useragent_parser_patch;\n\t} else {\n\t\tunset resp.http.Server;\n\t\tunset resp.http.Via;\n\t\tunset resp.http.X-Cache;\n\t\tunset resp.http.X-Cache-Hits;\n\t\tunset resp.http.X-Served-By;\n\t\tunset resp.http.X-Timer;\n\t\tunset resp.http.Fastly-Restarts;\n\t\tunset resp.http.X-PreFetch-Pass;\n\t\tunset resp.http.X-PreFetch-Miss;\n\t\tunset resp.http.X-PostFetch;\n\t}\n}\n\nsub vcl_error {\n\tif (obj.status == 911) {\n\t\tset obj.status = 405;\n\t\tset obj.response = \"METHOD NOT ALLOWED\";\n\t\tset obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n\t\tset obj.http.Cache-Control = \"private, no-store\";\n\t\tsynthetic req.method \" METHOD NOT ALLOWED\";\n\t\treturn (deliver);\n\t}\n\tif (obj.status == 912) {\n\t\tset obj.status = 200;\n\t\tset obj.response = \"OK\";\n\t\tset obj.http.Allow = \"OPTIONS, GET, HEAD\";\n\t\treturn (deliver);\n\t}\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"9d45b4b237af533a86b0db716fbb594b6dd6e96b","subject":"Updated varnish config example to a more recent Varnish version","message":"Updated varnish config example to a more recent Varnish version\n","repos":"erlanger-ru\/erlanger-ru.meta,erlanger-ru\/erlanger-ru.meta,erlanger-ru\/erlanger-ru.meta,erlanger-ru\/erlanger-ru.meta,erlanger-ru\/erlanger-ru.meta","old_file":"doc\/varnish.zotonic.vcl","new_file":"doc\/varnish.zotonic.vcl","new_contents":"#\n# Varnish configuration for a Zotonic site\n#\n\nbackend zotonic_com {\n .host = \"127.0.0.1\";\n .port = \"8000\";\n .first_byte_timeout = 300s;\n .connect_timeout = 300s;\n .between_bytes_timeout = 300s;\n}\n\nbackend nginx {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n .first_byte_timeout = 300s;\n .connect_timeout = 300s;\n .between_bytes_timeout = 300s;\n}\n\n\nsub vcl_recv {\n set req.http.X-Forwarded-Host = req.http.host;\n\n ######################################################################\n ########################### VIRTUAL HOSTS ############################\n\n if (req.http.host ~ \"^(www.|)(zotonic|example).(com|net)$\") {\n set req.backend = zotonic_com;\n }\n # Nginx hosted sites\n #\n else {\n set req.backend = nginx;\n }\n\n ######################################################################\n\n # Add a unique header containing the client address\n unset req.http.X-Forwarded-For;\n set req.http.X-Forwarded-For = client.ip;\n\n # We only deal with GET and HEAD by default\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n return (pass);\n }\n\n # Cache the home page for a short period (ttl = 1 second, see vcl_fetch)\n if (req.url ~ \"^\/$\") {\n unset req.http.Cookie;\n unset req.http.Authenticate;\n set req.grace = 10s;\n return (lookup);\n }\n\n # Cache served css and media files\n if (req.url ~ \"^\/(lib|image|media|favicon.ico)\/\") {\n unset req.http.Cookie;\n unset req.http.Authenticate;\n set req.grace = 30m;\n return (lookup);\n }\n\n return (pass);\n}\n\n\nsub vcl_pipe {\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n set req.http.connection = \"close\";\n return (pipe);\n}\n\n\nsub vcl_pass {\n if (req.url ~ \"^\/comet\") {\n #bereq.connect_timeout = 70;\n #bereq.first_byte_timeout = 70;\n }\n return (pass);\n}\n\n\nsub vcl_fetch {\n if (req.url ~ \"^\/(lib|image|media|favicon.ico)\/\") {\n unset beresp.http.Set-Cookie;\n set beresp.grace = 30m;\n set beresp.ttl = 10m;\n return (deliver);\n }\n return (pass);\n}\n\nsub vcl_error {\n if (obj.status == 503 && req.restarts < 4) {\n restart;\n }\n}\n\n\n","old_contents":"#\n# Varnish configuration for a Zotonic site\n#\n\nbackend zotonic_com {\n .host = \"127.0.0.1\";\n .port = \"8000\";\n .first_byte_timeout = 300s;\n .connect_timeout = 300s;\n .between_bytes_timeout = 300s;\n}\n\nbackend nginx {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n .first_byte_timeout = 300s;\n .connect_timeout = 300s;\n .between_bytes_timeout = 300s;\n}\n\n\nsub vcl_recv {\n set req.http.X-Forwarded-Host = req.http.host;\n\n ######################################################################\n ########################### VIRTUAL HOSTS ############################\n\n if (req.http.host ~ \"^(www.|)(zotonic|example).(com|net)$\") {\n set req.backend = zotonic_com;\n }\n # Nginx hosted sites\n #\n else {\n set req.backend = nginx;\n }\n\n ######################################################################\n\n # Add a unique header containing the client address\n unset req.http.X-Forwarded-For;\n set req.http.X-Forwarded-For = client.ip;\n\n # We only deal with GET and HEAD by default\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n return (pass);\n }\n\n # Cache the home page for a short period (ttl = 1 second, see vcl_fetch)\n if (req.url ~ \"^\/$\") {\n unset req.http.Cookie;\n unset req.http.Authenticate;\n set req.grace = 10s;\n return (lookup);\n }\n\n # Cache served css and media files\n if (req.url ~ \"^\/(lib|image|media|favicon.ico)\/\") {\n unset req.http.Cookie;\n unset req.http.Authenticate;\n set req.grace = 30m;\n return (lookup);\n }\n\n return (pass);\n}\n\n\nsub vcl_pipe {\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n set req.http.connection = \"close\";\n return (pipe);\n}\n\n\nsub vcl_pass {\n if (req.url ~ \"^\/comet\") {\n #bereq.connect_timeout = 70;\n #bereq.first_byte_timeout = 70;\n }\n return (pass);\n}\n\n\nsub vcl_fetch {\n if (req.url ~ \"^\/$\") {\n unset obj.http.Set-Cookie;\n\tset obj.grace = 10s;\n\tset obj.ttl = 1s;\n\treturn (deliver);\n }\n if (req.url ~ \"^\/(lib|image|media|favicon.ico)\/\") {\n unset obj.http.Set-Cookie;\n set obj.grace = 30m;\n set obj.ttl = 10m;\n return (deliver);\n }\n return (pass);\n}\n\nsub vcl_error {\n if (obj.status == 503 && req.restarts < 4) {\n restart;\n }\n}\n\n\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"bb62379565d5b53130d5ed1018492d0093b9f8b9","subject":"fix allowing set-cookie on some pages","message":"fix allowing set-cookie on some pages\n","repos":"jclgoodwin\/bustimes.org.uk,jclgoodwin\/bustimes.org.uk,jclgoodwin\/bustimes.org.uk,jclgoodwin\/bustimes.org.uk","old_file":"config\/varnish\/default.vcl","new_file":"config\/varnish\/default.vcl","new_contents":"# Marker to tell the VCL compiler that this VCL has been adapted to the\n# new 4.0 format.\nvcl 4.0;\n\n# Default backend definition. Set this to point to your content server.\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\n\nsub vcl_recv {\n # Happens before we check if we have this in cache already.\n #\n # Typically you clean up the request here, removing cookies you don't need,\n # rewriting the request, etc.\n\n if (req.url ~ \"^\/(admin\/|contact|awin-transaction)\" || req.url ~ \"\/edit\") {\n return (pass);\n }\n\n # special features on fleet lists for logged in users\n if (req.http.Cookie ~ \"sessionid\" && req.url ~ \"operator\" && req.url ~ \"vehicles\") {\n return (pass);\n }\n\n unset req.http.Cookie;\n}\n\nsub vcl_backend_response {\n # Happens after we have read the response headers from the backend.\n #\n # Here you clean the response headers, removing silly Set-Cookie headers\n # and other mistakes your backend does.\n\n if (bereq.url !~ \"^\/(admin\/|contact)\" && bereq.url !~ \"\/edit\") {\n unset beresp.http.set-cookie;\n\n if (beresp.status >= 200 && beresp.status < 400) {\n if (bereq.url ~ \"^\/stops\/\") {\n set beresp.ttl = 50s;\n } elif (bereq.url ~ \"\/(vehicles|journeys\/)\") {\n set beresp.ttl = 6s;\n } else {\n set beresp.ttl = 1h;\n }\n }\n }\n}\n","old_contents":"# Marker to tell the VCL compiler that this VCL has been adapted to the\n# new 4.0 format.\nvcl 4.0;\n\n# Default backend definition. Set this to point to your content server.\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\n\nsub vcl_recv {\n # Happens before we check if we have this in cache already.\n #\n # Typically you clean up the request here, removing cookies you don't need,\n # rewriting the request, etc.\n\n if (req.url ~ \"^\/(admin\/|contact|awin-transaction)\" || req.url ~ \"\/edit\") {\n return (pass);\n }\n\n # special features on fleet lists for logged in users\n if (req.http.Cookie ~ \"sessionid\" && req.url ~ \"operator\" && req.url ~ \"vehicles\") {\n return (pass);\n }\n\n unset req.http.Cookie;\n}\n\nsub vcl_backend_response {\n # Happens after we have read the response headers from the backend.\n #\n # Here you clean the response headers, removing silly Set-Cookie headers\n # and other mistakes your backend does.\n\n if (bereq.url !~ \"^\/(admin\/|contact)\" || bereq.url !~ \"\/edit\") {\n unset beresp.http.set-cookie;\n\n if (beresp.status >= 200 && beresp.status < 400) {\n if (bereq.url ~ \"^\/stops\/\") {\n set beresp.ttl = 50s;\n } elif (bereq.url ~ \"\/(vehicles|journeys\/)\") {\n set beresp.ttl = 6s;\n } else {\n set beresp.ttl = 1h;\n }\n }\n }\n}\n","returncode":0,"stderr":"","license":"mpl-2.0","lang":"VCL"} {"commit":"2fbcf7db35857186a9afc99fe9018e45b79200bd","subject":"Redirect qa to https (#942)","message":"Redirect qa to https (#942)\n\n* Redirect qa to https\r\n\r\n* Update fastly-config.vcl\r\n\r\n* Update fastly-config.vcl\r\n","repos":"jonathan-fielding\/polyfill-service,jonathan-fielding\/polyfill-service,JakeChampion\/polyfill-service,jonathan-fielding\/polyfill-service,kdzwinel\/polyfill-service,mcshaz\/polyfill-service,kdzwinel\/polyfill-service,mcshaz\/polyfill-service,kdzwinel\/polyfill-service,mcshaz\/polyfill-service,JakeChampion\/polyfill-service","old_file":"fastly-config.vcl","new_file":"fastly-config.vcl","new_contents":"import boltsort;\n\nsub vcl_recv {\n#FASTLY recv\n\tif ( req.request == \"FASTLYPURGE\" ) {\n\t\tset req.http.Fastly-Purge-Requires-Auth = \"1\";\n\t}\n\n\tif (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n\t\treturn(pass);\n\t}\n\n\tif (!req.http.Fastly-SSL) {\n\t\tif (req.http.Host == \"cdn.polyfill.io\" || req.http.Host == \"polyfill.io\") {\n\t\t\terror 751 \"Redirect to prod HTTPS\";\n\t\t}\n\t\tif (req.http.Host == \"qa.polyfill.io\") {\n\t\t\terror 752 \"Redirect to QA HTTPS\";\n\t\t}\n\t}\n\n\tif (req.http.Host ~ \"polyfills.io\") {\n\t\terror 751 \"Canonicalise\";\n\t}\n\n\tif (req.url ~ \"^\/v2\/(polyfill\\.|recordRumData)\" && req.url !~ \"[\\?\\&]ua=\") {\n\t\tset req.http.X-Orig-URL = req.url;\n\t\tset req.url = \"\/v2\/normalizeUa?ua=\" urlencode(req.http.User-Agent);\n\t}\n\n\tif (req.url ~ \"^\/v2\/recordRumData\" && req.http.Normalized-User-Agent) {\n\t\tset req.http.Log = regsub(req.url, \"^.*?\\?(.*)$\", \"\\1\") \"&ip=\" client.ip \"&refer_domain=\" regsub(req.http.Referer, \"^(https?\\:\\\/\\\/)?(www\\.)?(.+?)(\\:\\d+)?([\\\/\\?].*)?$\", \"\\3\") \"&country=\" geoip.country_code \"&data_center=\" if(req.http.Cookie:FastlyDC, req.http.Cookie:FastlyDC, server.datacenter);\n\t\terror 204 \"No Content\";\n\t}\n\n\tset req.url = boltsort.sort(req.url);\n\n\treturn(lookup);\n}\n\nsub vcl_deliver {\n#FASTLY deliver\n\n\t# If the response is to a normalise request and there's a parked \"original request\", use the normalised UA response to modify the original request and restart it\n\tif (req.url ~ \"^\/v\\d\/normalizeUa\" && resp.status == 200 && req.http.X-Orig-URL ~ \"^\/v2\/(polyfill\\.|recordRumData)\") {\n\t\tset req.http.Fastly-force-Shield = \"1\";\n\t\tset req.http.Normalized-User-Agent = resp.http.Normalized-User-Agent;\n\t\tif (req.http.X-Orig-URL ~ \"\\?\") {\n\t\t\tset req.url = req.http.X-Orig-URL \"&ua=\" resp.http.Normalized-User-Agent;\n\t\t} else {\n\t\t\tset req.url = req.http.X-Orig-URL \"?ua=\" resp.http.Normalized-User-Agent;\n\t\t}\n\t\trestart;\n\n\t# If the original request didn't specify a UA override, and we added one when the request was sent to the backend, the backend won't have included a Vary:user-agent header (correctly) but we need to add one\n\t} else if (req.url ~ \"^\/v\\d\/polyfill\\..*[\\?\\&]ua=\" && req.http.X-Orig-URL && req.http.X-Orig-URL !~ \"[\\?\\&]ua=\") {\n\t\tadd resp.http.Vary = \"User-Agent\";\n\t}\n\n\tif (req.url ~ \"[\\&\\?]rum=1\") {\n\t\tadd resp.http.Set-Cookie = \"FastlyDC=\" server.datacenter \"; Path=\/; HttpOnly; max-age=60\";\n\t}\n\n\treturn(deliver);\n}\n\nsub vcl_error {\n\n\t# Redirect to canonical prod\/qa origins\n\tif (obj.status == 751 || obj.status == 752) {\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\tset obj.http.Location = \"https:\/\/\" if(obj.status == 752, \"qa.\", \"\") \"polyfill.io\" req.url;\n\t\tsynthetic {\"\"};\n\t\treturn (deliver);\n\t}\n}\n","old_contents":"import boltsort;\n\nsub vcl_recv {\n#FASTLY recv\n\tif ( req.request == \"FASTLYPURGE\" ) {\n\t\tset req.http.Fastly-Purge-Requires-Auth = \"1\";\n\t}\n\n\tif (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n\t\treturn(pass);\n\t}\n\n\tif (!req.http.Fastly-SSL && (req.http.Host == \"cdn.polyfill.io\" || req.http.Host == \"polyfill.io\")) {\n\t\terror 751 \"Canonicalise\";\n\t}\n\n\tif (req.http.Host ~ \"polyfills.io\") {\n\t\terror 751 \"Canonicalise\";\n\t}\n\n\tif (req.url ~ \"^\/v2\/(polyfill\\.|recordRumData)\" && req.url !~ \"[\\?\\&]ua=\") {\n\t\tset req.http.X-Orig-URL = req.url;\n\t\tset req.url = \"\/v2\/normalizeUa?ua=\" urlencode(req.http.User-Agent);\n\t}\n\n\tif (req.url ~ \"^\/v2\/recordRumData\" && req.http.Normalized-User-Agent) {\n\t\tset req.http.Log = regsub(req.url, \"^.*?\\?(.*)$\", \"\\1\") \"&ip=\" client.ip \"&refer_domain=\" regsub(req.http.Referer, \"^(https?\\:\\\/\\\/)?(www\\.)?(.+?)(\\:\\d+)?([\\\/\\?].*)?$\", \"\\3\") \"&country=\" geoip.country_code \"&data_center=\" if(req.http.Cookie:FastlyDC, req.http.Cookie:FastlyDC, server.datacenter);\n\t\terror 204 \"No Content\";\n\t}\n\n\tset req.url = boltsort.sort(req.url);\n\n\treturn(lookup);\n}\n\nsub vcl_deliver {\n#FASTLY deliver\n\n\t# If the response is to a normalise request and there's a parked \"original request\", use the normalised UA response to modify the original request and restart it\n\tif (req.url ~ \"^\/v\\d\/normalizeUa\" && resp.status == 200 && req.http.X-Orig-URL ~ \"^\/v2\/(polyfill\\.|recordRumData)\") {\n\t\tset req.http.Fastly-force-Shield = \"1\";\n\t\tset req.http.Normalized-User-Agent = resp.http.Normalized-User-Agent;\n\t\tif (req.http.X-Orig-URL ~ \"\\?\") {\n\t\t\tset req.url = req.http.X-Orig-URL \"&ua=\" resp.http.Normalized-User-Agent;\n\t\t} else {\n\t\t\tset req.url = req.http.X-Orig-URL \"?ua=\" resp.http.Normalized-User-Agent;\n\t\t}\n\t\trestart;\n\n\t# If the original request didn't specify a UA override, and we added one when the request was sent to the backend, the backend won't have included a Vary:user-agent header (correctly) but we need to add one\n\t} else if (req.url ~ \"^\/v\\d\/polyfill\\..*[\\?\\&]ua=\" && req.http.X-Orig-URL && req.http.X-Orig-URL !~ \"[\\?\\&]ua=\") {\n\t\tadd resp.http.Vary = \"User-Agent\";\n\t}\n\n\tif (req.url ~ \"[\\&\\?]rum=1\") {\n\t\tadd resp.http.Set-Cookie = \"FastlyDC=\" server.datacenter \"; Path=\/; HttpOnly; max-age=60\";\n\t}\n\n\treturn(deliver);\n}\n\nsub vcl_error {\n\n\t# Redirect to SSL\n\tif (obj.status == 751) {\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\tset obj.http.Location = \"https:\/\/polyfill.io\" req.url;\n\t\tsynthetic {\"\"};\n\t\treturn (deliver);\n\t}\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"3f71e768599639dcb232d762e6a1e76155196010","subject":"Let the error response from origin go to the user","message":"Let the error response from origin go to the user\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets\/fetch.vcl","new_file":"etc\/vcl_snippets\/fetch.vcl","new_contents":" \/* handle 5XX (or any other unwanted status code) *\/\n if (beresp.status >= 500 && beresp.status < 600) {\n\n \/* deliver stale if the object is available *\/\n if (stale.exists) {\n return(deliver_stale);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n }\n\n # Remove Set-Cookies from responses for static content to match the cookie removal in recv.\n if (req.http.x-long-cache || req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's since those can be temporary during the site build\/index\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n set beresp.http.Cache-Control = \"max-age=0\";\n } else if (req.http.x-long-cache) {\n # Force caching for signed cached assets.\n set beresp.ttl = 31536000s;\n # Add immutable as it avoids IMS and INM revalidations\n set beresp.http.Cache-Control = \"max-age=31536000, immutable\";\n }\n }\n\n # Fix Vary Header in some cases. In 99.9% of cases Varying on User-Agent is counterproductive\n # https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleFixupVary\n if (beresp.http.Vary ~ \"User-Agent\") {\n set beresp.http.Vary = regsub(beresp.http.Vary, \",? *User-Agent *\", \"\");\n set beresp.http.Vary = regsub(beresp.http.Vary, \"^, *\", \"\");\n if (beresp.http.Vary == \"\") {\n unset beresp.http.Vary;\n }\n }\n\n # All the Magento responses should emit X-Esi headers\n if (beresp.http.x-esi) {\n # enable ESI feature for Magento response by default\n esi;\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content except\n if ( http_status_matches(beresp.status, \"200,404\") && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|text\\\/html|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url.ext ~ \"(?i)(css|js|html|eot|ico|otf|ttf|json)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # Add Varying on X-Magento-Vary\n if (beresp.http.Content-Type ~ \"text\/(html|xml)\") {\n if (!beresp.http.Vary ~ \"X-Magento-Vary,Https\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \",X-Magento-Vary,Https\";\n } else {\n set beresp.http.Vary = \"X-Magento-Vary,Https\";\n }\n }\n }\n\n if (beresp.http.Cache-Control ~ \"private|no-cache|no-store\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # Never cache 302s\n if (beresp.status == 302) {\n return (pass);\n }\n\n # Just in case the Request Setting for x-pass is missing\n if (req.http.x-pass) {\n return (pass);\n }\n\n # Varnish sets default TTL if none of these are present. If not set we want to make sure we don't cache it\n if (!beresp.http.Expires && !beresp.http.Surrogate-Control ~ \"max-age\" && !beresp.http.Cache-Control ~ \"(s-maxage|max-age)\") {\n set beresp.ttl = 0s;\n\tset beresp.cacheable = false;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\") && !req.http.x-pass ) {\n unset beresp.http.set-cookie;\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type if they are image\/script or CSS\n if (beresp.http.Content-Type ~ \"(image|script|css)\") {\n set beresp.http.Surrogate-Key = re.group.1;\n }\n }\n","old_contents":" \/* handle 5XX (or any other unwanted status code) *\/\n if (beresp.status >= 500 && beresp.status < 600) {\n\n \/* deliver stale if the object is available *\/\n if (stale.exists) {\n return(deliver_stale);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n \/* else go to vcl_error to deliver a synthetic *\/\n error beresp.status beresp.response;\n }\n\n # Remove Set-Cookies from responses for static content to match the cookie removal in recv.\n if (req.http.x-long-cache || req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's since those can be temporary during the site build\/index\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n set beresp.http.Cache-Control = \"max-age=0\";\n } else if (req.http.x-long-cache) {\n # Force caching for signed cached assets.\n set beresp.ttl = 31536000s;\n # Add immutable as it avoids IMS and INM revalidations\n set beresp.http.Cache-Control = \"max-age=31536000, immutable\";\n }\n }\n\n # Fix Vary Header in some cases. In 99.9% of cases Varying on User-Agent is counterproductive\n # https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleFixupVary\n if (beresp.http.Vary ~ \"User-Agent\") {\n set beresp.http.Vary = regsub(beresp.http.Vary, \",? *User-Agent *\", \"\");\n set beresp.http.Vary = regsub(beresp.http.Vary, \"^, *\", \"\");\n if (beresp.http.Vary == \"\") {\n unset beresp.http.Vary;\n }\n }\n\n # All the Magento responses should emit X-Esi headers\n if (beresp.http.x-esi) {\n # enable ESI feature for Magento response by default\n esi;\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content except\n if ( http_status_matches(beresp.status, \"200,404\") && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|text\\\/html|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url.ext ~ \"(?i)(css|js|html|eot|ico|otf|ttf|json)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # Add Varying on X-Magento-Vary\n if (beresp.http.Content-Type ~ \"text\/(html|xml)\") {\n if (!beresp.http.Vary ~ \"X-Magento-Vary,Https\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \",X-Magento-Vary,Https\";\n } else {\n set beresp.http.Vary = \"X-Magento-Vary,Https\";\n }\n }\n }\n\n if (beresp.http.Cache-Control ~ \"private|no-cache|no-store\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # Never cache 302s\n if (beresp.status == 302) {\n return (pass);\n }\n\n # Just in case the Request Setting for x-pass is missing\n if (req.http.x-pass) {\n return (pass);\n }\n\n # Varnish sets default TTL if none of these are present. If not set we want to make sure we don't cache it\n if (!beresp.http.Expires && !beresp.http.Surrogate-Control ~ \"max-age\" && !beresp.http.Cache-Control ~ \"(s-maxage|max-age)\") {\n set beresp.ttl = 0s;\n\tset beresp.cacheable = false;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\") && !req.http.x-pass ) {\n unset beresp.http.set-cookie;\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type if they are image\/script or CSS\n if (beresp.http.Content-Type ~ \"(image|script|css)\") {\n set beresp.http.Surrogate-Key = re.group.1;\n }\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"c325b9a20625199c074226a160a284d009aa24d1","subject":"use req.url and not orig-url","message":"use req.url and not orig-url\n","repos":"JakeChampion\/polyfill-service,JakeChampion\/polyfill-service","old_file":"fastly\/vcl\/polyfill-service.vcl","new_file":"fastly\/vcl\/polyfill-service.vcl","new_contents":"sub set_backend {\n\t# Calculate the ideal region to route the request to.\n\tdeclare local var.region STRING;\n\tif (server.region ~ \"(APAC|Asia|North-America|South-America|US-Central|US-East|US-West)\") {\n\t\tset var.region = \"US\";\n\t} else {\n\t\tset var.region = \"EU\";\n\t}\n\n\t# Gather the health of the shields and origins.\n\tdeclare local var.v3_eu_is_healthy BOOL;\n\tset req.backend = F_v3_eu;\n\tset var.v3_eu_is_healthy = req.backend.healthy;\n\n\tdeclare local var.v3_us_is_healthy BOOL;\n\tset req.backend = F_v3_us;\n\tset var.v3_us_is_healthy = req.backend.healthy;\n\n\t# Set some sort of default, that shouldn't get used.\n\tset req.backend = F_v3_eu;\n\n\t# Route EU requests to the nearest healthy shield or origin.\n\tif (var.region == \"EU\") {\n\t\tif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_eu;\n\t\t}\n\t}\n\n\t# Route US requests to the nearest healthy shield or origin.\n\tif (var.region == \"US\") {\n\t\tif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_us;\n\t\t}\n\t}\n\n\t# Persist the decision so we can debug the result.\n\tset req.http.Debug-Backend = req.backend;\n\n\t# The Fastly macro is inserted after the backend is selected because the\n\t# macro has the code to select the correct req.http.Host value based on the backend.\n\t#FASTLY recv\n}\n\nsub vcl_recv {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_recv;\n\t}\n\n\tif (req.method != \"GET\" && req.method != \"HEAD\" && req.method != \"OPTIONS\") {\n\t\terror 911;\n\t}\n\n\tif (req.method == \"OPTIONS\") {\n\t\terror 912;\n\t}\n\n\t# Override the v3 defaults with the defaults of v2\n\tif (req.url ~ \"^\/v2\/polyfill(\\.min)?\\.js\") {\n\t\tset req.url = regsub(req.url, \"^\/v2\", \"\/v3\");\n\t\tset req.url = querystring.set(req.url, \"version\", \"3.25.1\");\n\t\tdeclare local var.unknown STRING;\n\t\tset var.unknown = subfield(req.url.qs, \"unknown\", \"&\");\n\t\tset req.url = querystring.set(req.url, \"unknown\", if(var.unknown != \"\", var.unknown, \"ignore\"));\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\") {\n\t\tcall normalise_querystring_parameters_for_polyfill_bundle;\n\t}\n\n\t# Sort the querystring parameters alphabetically to improve chances of hitting a cached copy.\n\t# If querystring is empty, remove the ? from the url.\n\tset req.url = querystring.clean(querystring.sort(req.url));\n\tcall set_backend;\n}\n\nsub vcl_hash {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_hash;\n\t}\n\n\t# We are not adding req.http.host to the hash because we want https:\/\/cdn.polyfill.io and https:\/\/polyfill.io to be a single object in the cache.\n\t# set req.hash += req.http.host;\n\tset req.hash += req.url;\n\t# We include return(hash) to stop the function falling through to the default VCL built into varnish, which for vcl_hash will add req.url and req.http.Host to the hash.\n\treturn(hash);\n}\n\nsub vcl_miss {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_miss;\n\t}\n}\n\nsub vcl_pass {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_pass;\n\t}\n}\n\nsub vcl_fetch {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_fetch;\n\t}\n\n\t# These header are only required for HTML documents.\n\tif (beresp.http.Content-Type ~ \"text\/html\") {\n\t\t# Enables the cross-site scripting filter built into most modern web browsers.\n\t\tset beresp.http.X-XSS-Protection = \"1; mode=block\";\n\t\t\n\t\t# Prevents MIME-sniffing a response away from the declared content type.\n\t\tset beresp.http.X-Content-Type-Options = \"nosniff\";\n\n\t\t# Allow only content from the site's own origin (this excludes subdomains) and www.ft.com.\n\t\t# Don't allow the website to be used within an iframe\n\t\tif (!beresp.http.Content-Security-Policy) {\n\t\t\tset beresp.http.Content-Security-Policy = \"default-src 'self'; font-src 'self' https:\/\/www.ft.com; img-src 'self' https:\/\/www.ft.com; frame-ancestors 'none'; base-uri 'self'; form-action 'self'\";\n\t\t}\n\t}\n\n\t# Ensure the site is only served over HTTPS and reduce the chances of someone performing a MITM attack.\n\tset beresp.http.Strict-Transport-Security = \"max-age=31536000; includeSubdomains; preload\";\n\n\t# The Referrer-Policy header governs which referrer information, sent in the Referer header, should be included with requests made.\n\t# Send a full URL when performing a same-origin request, but only send the origin of the document for other cases.\n\tset beresp.http.Referrer-Policy = \"origin-when-cross-origin\";\n\n\t# Enable purging of all objects in the Fastly cache by issuing a purge with the key \"polyfill-service\".\n\tif (beresp.http.Surrogate-Key !~ \"\\bpolyfill-service\\b\") {\n\t\tset beresp.http.Surrogate-Key = if(beresp.http.Surrogate-Key, beresp.http.Surrogate-Key \" polyfill-service\", \"polyfill-service\");\n\t}\n\n\tset beresp.http.Timing-Allow-Origin = \"*\";\n\n\tif (req.http.Normalized-User-Agent) {\n\t\tset beresp.http.Normalized-User-Agent = req.http.Normalized-User-Agent;\n\t\tset beresp.http.Detected-User-Agent = req.http.useragent_parser_family \"\/\" req.http.useragent_parser_major \".\" req.http.useragent_parser_minor \".\" req.http.useragent_parser_patch;\n\t}\n}\n\nsub vcl_deliver {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_deliver;\n\t}\n\n\tset req.http.Fastly-Force-Shield = \"yes\";\n\n\t# Allow cross origin GET, HEAD, and OPTIONS requests to be made.\n\tif (req.http.Origin) {\n\t\tset resp.http.Access-Control-Allow-Origin = \"*\";\n\t\tset resp.http.Access-Control-Allow-Methods = \"GET,HEAD,OPTIONS\";\n\t}\n\n\tadd resp.http.Server-Timing = fastly_info.state {\", fastly;desc=\"Edge time\";dur=\"} time.elapsed.msec;\n\n\tif (req.http.Fastly-Debug) {\n\t\tset resp.http.Debug-Backend = req.http.Debug-Backend;\n\t\tset resp.http.Debug-Host = req.http.Host;\n\t\tset resp.http.Debug-Fastly-Restarts = req.restarts;\n\t\tset resp.http.Debug-Orig-URL = req.http.Orig-URL;\n\t\tset resp.http.Debug-VCL-Route = req.http.X-VCL-Route;\n\t\tset resp.http.useragent_parser_family = req.http.useragent_parser_family;\n\t\tset resp.http.useragent_parser_major = req.http.useragent_parser_major;\n\t\tset resp.http.useragent_parser_minor = req.http.useragent_parser_minor;\n\t\tset resp.http.useragent_parser_patch = req.http.useragent_parser_patch;\n\t} else {\n\t\tunset resp.http.Server;\n\t\tunset resp.http.Via;\n\t\tunset resp.http.X-Cache;\n\t\tunset resp.http.X-Cache-Hits;\n\t\tunset resp.http.X-Served-By;\n\t\tunset resp.http.X-Timer;\n\t\tunset resp.http.Fastly-Restarts;\n\t}\n}\n\nsub vcl_error {\n\tif (obj.status == 911) {\n\t\tset obj.status = 405;\n\t\tset obj.response = \"METHOD NOT ALLOWED\";\n\t\tset obj.http.Content-Type = \"text\/html; charset=utf-8\";\n\t\tset obj.http.Cache-Control = \"private, no-store\";\n\t\tsynthetic req.method \" METHOD NOT ALLOWED\";\n\t\treturn (deliver);\n\t}\n\tif (obj.status == 912) {\n\t\tset obj.status = 200;\n\t\tset obj.response = \"OK\";\n\t\tset obj.http.Allow = \"OPTIONS, GET, HEAD\";\n\t\treturn (deliver);\n\t}\n}\n","old_contents":"sub set_backend {\n\t# Calculate the ideal region to route the request to.\n\tdeclare local var.region STRING;\n\tif (server.region ~ \"(APAC|Asia|North-America|South-America|US-Central|US-East|US-West)\") {\n\t\tset var.region = \"US\";\n\t} else {\n\t\tset var.region = \"EU\";\n\t}\n\n\t# Gather the health of the shields and origins.\n\tdeclare local var.v3_eu_is_healthy BOOL;\n\tset req.backend = F_v3_eu;\n\tset var.v3_eu_is_healthy = req.backend.healthy;\n\n\tdeclare local var.v3_us_is_healthy BOOL;\n\tset req.backend = F_v3_us;\n\tset var.v3_us_is_healthy = req.backend.healthy;\n\n\t# Set some sort of default, that shouldn't get used.\n\tset req.backend = F_v3_eu;\n\n\t# Route EU requests to the nearest healthy shield or origin.\n\tif (var.region == \"EU\") {\n\t\tif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_eu;\n\t\t}\n\t}\n\n\t# Route US requests to the nearest healthy shield or origin.\n\tif (var.region == \"US\") {\n\t\tif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_us;\n\t\t}\n\t}\n\n\t# Persist the decision so we can debug the result.\n\tset req.http.Debug-Backend = req.backend;\n\n\t# The Fastly macro is inserted after the backend is selected because the\n\t# macro has the code to select the correct req.http.Host value based on the backend.\n\t#FASTLY recv\n}\n\nsub vcl_recv {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_recv;\n\t}\n\n\tif (req.method != \"GET\" && req.method != \"HEAD\" && req.method != \"OPTIONS\") {\n\t\terror 911;\n\t}\n\n\tif (req.method == \"OPTIONS\") {\n\t\terror 912;\n\t}\n\n\t# Override the v3 defaults with the defaults of v2\n\tif (req.http.Orig-URL ~ \"^\/v2\/polyfill(\\.min)?\\.js\") {\n\t\tset req.url = regsub(req.url, \"^\/v2\", \"\/v3\");\n\t\tset req.url = querystring.set(req.url, \"version\", \"3.25.1\");\n\t\tdeclare local var.unknown STRING;\n\t\tset var.unknown = subfield(req.url.qs, \"unknown\", \"&\");\n\t\tset req.url = querystring.set(req.url, \"unknown\", if(var.unknown != \"\", var.unknown, \"ignore\"));\n\t}\n\n\tif (req.http.Orig-URL ~ \"^\/v3\/polyfill(\\.min)?\\.js\") {\n\t\tcall normalise_querystring_parameters_for_polyfill_bundle;\n\t}\n\n\t# Sort the querystring parameters alphabetically to improve chances of hitting a cached copy.\n\t# If querystring is empty, remove the ? from the url.\n\tset req.url = querystring.clean(querystring.sort(req.url));\n\tcall set_backend;\n}\n\nsub vcl_hash {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_hash;\n\t}\n\n\t# We are not adding req.http.host to the hash because we want https:\/\/cdn.polyfill.io and https:\/\/polyfill.io to be a single object in the cache.\n\t# set req.hash += req.http.host;\n\tset req.hash += req.url;\n\t# We include return(hash) to stop the function falling through to the default VCL built into varnish, which for vcl_hash will add req.url and req.http.Host to the hash.\n\treturn(hash);\n}\n\nsub vcl_miss {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_miss;\n\t}\n}\n\nsub vcl_pass {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_pass;\n\t}\n}\n\nsub vcl_fetch {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_fetch;\n\t}\n\n\t# These header are only required for HTML documents.\n\tif (beresp.http.Content-Type ~ \"text\/html\") {\n\t\t# Enables the cross-site scripting filter built into most modern web browsers.\n\t\tset beresp.http.X-XSS-Protection = \"1; mode=block\";\n\t\t\n\t\t# Prevents MIME-sniffing a response away from the declared content type.\n\t\tset beresp.http.X-Content-Type-Options = \"nosniff\";\n\n\t\t# Allow only content from the site's own origin (this excludes subdomains) and www.ft.com.\n\t\t# Don't allow the website to be used within an iframe\n\t\tif (!beresp.http.Content-Security-Policy) {\n\t\t\tset beresp.http.Content-Security-Policy = \"default-src 'self'; font-src 'self' https:\/\/www.ft.com; img-src 'self' https:\/\/www.ft.com; frame-ancestors 'none'; base-uri 'self'; form-action 'self'\";\n\t\t}\n\t}\n\n\t# Ensure the site is only served over HTTPS and reduce the chances of someone performing a MITM attack.\n\tset beresp.http.Strict-Transport-Security = \"max-age=31536000; includeSubdomains; preload\";\n\n\t# The Referrer-Policy header governs which referrer information, sent in the Referer header, should be included with requests made.\n\t# Send a full URL when performing a same-origin request, but only send the origin of the document for other cases.\n\tset beresp.http.Referrer-Policy = \"origin-when-cross-origin\";\n\n\t# Enable purging of all objects in the Fastly cache by issuing a purge with the key \"polyfill-service\".\n\tif (beresp.http.Surrogate-Key !~ \"\\bpolyfill-service\\b\") {\n\t\tset beresp.http.Surrogate-Key = if(beresp.http.Surrogate-Key, beresp.http.Surrogate-Key \" polyfill-service\", \"polyfill-service\");\n\t}\n\n\tset beresp.http.Timing-Allow-Origin = \"*\";\n\n\tif (req.http.Normalized-User-Agent) {\n\t\tset beresp.http.Normalized-User-Agent = req.http.Normalized-User-Agent;\n\t\tset beresp.http.Detected-User-Agent = req.http.useragent_parser_family \"\/\" req.http.useragent_parser_major \".\" req.http.useragent_parser_minor \".\" req.http.useragent_parser_patch;\n\t}\n}\n\nsub vcl_deliver {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_deliver;\n\t}\n\n\tset req.http.Fastly-Force-Shield = \"yes\";\n\n\t# Allow cross origin GET, HEAD, and OPTIONS requests to be made.\n\tif (req.http.Origin) {\n\t\tset resp.http.Access-Control-Allow-Origin = \"*\";\n\t\tset resp.http.Access-Control-Allow-Methods = \"GET,HEAD,OPTIONS\";\n\t}\n\n\tadd resp.http.Server-Timing = fastly_info.state {\", fastly;desc=\"Edge time\";dur=\"} time.elapsed.msec;\n\n\tif (req.http.Fastly-Debug) {\n\t\tset resp.http.Debug-Backend = req.http.Debug-Backend;\n\t\tset resp.http.Debug-Host = req.http.Host;\n\t\tset resp.http.Debug-Fastly-Restarts = req.restarts;\n\t\tset resp.http.Debug-Orig-URL = req.http.Orig-URL;\n\t\tset resp.http.Debug-VCL-Route = req.http.X-VCL-Route;\n\t\tset resp.http.useragent_parser_family = req.http.useragent_parser_family;\n\t\tset resp.http.useragent_parser_major = req.http.useragent_parser_major;\n\t\tset resp.http.useragent_parser_minor = req.http.useragent_parser_minor;\n\t\tset resp.http.useragent_parser_patch = req.http.useragent_parser_patch;\n\t} else {\n\t\tunset resp.http.Server;\n\t\tunset resp.http.Via;\n\t\tunset resp.http.X-Cache;\n\t\tunset resp.http.X-Cache-Hits;\n\t\tunset resp.http.X-Served-By;\n\t\tunset resp.http.X-Timer;\n\t\tunset resp.http.Fastly-Restarts;\n\t}\n}\n\nsub vcl_error {\n\tif (obj.status == 911) {\n\t\tset obj.status = 405;\n\t\tset obj.response = \"METHOD NOT ALLOWED\";\n\t\tset obj.http.Content-Type = \"text\/html; charset=utf-8\";\n\t\tset obj.http.Cache-Control = \"private, no-store\";\n\t\tsynthetic req.method \" METHOD NOT ALLOWED\";\n\t\treturn (deliver);\n\t}\n\tif (obj.status == 912) {\n\t\tset obj.status = 200;\n\t\tset obj.response = \"OK\";\n\t\tset obj.http.Allow = \"OPTIONS, GET, HEAD\";\n\t\treturn (deliver);\n\t}\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"5ff1cccce8037ba2a37f4acd46a3aa47100e9a27","subject":"messing with web sockets","message":"messing with web sockets\n","repos":"derbyjs\/candygram","old_file":"varnish_default.vcl","new_file":"varnish_default.vcl","new_contents":"# This is a basic VCL configuration file for varnish. See the vcl(7)\n# man page for details on VCL syntax and semantics.\n\nimport std;\n\n# static\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"4000\";\n}\nbackend examples {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\nbackend components {\n .host = \"127.0.0.1\";\n .port = \"3330\";\n}\n\nsub vcl_recv {\n if (!req.http.Host) {\n error 404 \"Need a host header\";\n }\n\n set req.http.Host = regsub(req.http.Host, \"^www\\.\", \"\");\n set req.http.Host = regsub(req.http.Host, \":80$\", \"\");\n\n if (\n req.http.Host ~ \"^chat\\.\" ||\n req.http.Host ~ \"^charts\\.\" ||\n req.http.Host ~ \"^directory\\.\" ||\n req.http.Host ~ \"^codemirror\\.\" ||\n req.http.Host ~ \"^hello\\.\" ||\n req.http.Host ~ \"^sink\\.\" ||\n req.http.Host ~ \"^todos\\.\" ||\n req.http.Host ~ \"^widgets\\.\"\n ) {\n set req.backend = examples;\n } else if (req.http.Host ~ \"^components\\.\") {\n set req.backend = components;\n }\n\n if (req.http.upgrade ~ \"(?i)websocket\" || req.url ~ \"^\/channel\") {\n return (pipe);\n }\n\n if (req.restarts == 0) {\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For =\n req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization || req.http.Cookie) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n return (lookup);\n}\n\nsub vcl_pipe {\n # Websockets\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n return (pipe);\n}\n","old_contents":"# This is a basic VCL configuration file for varnish. See the vcl(7)\n# man page for details on VCL syntax and semantics.\n\nimport std;\n\n# static\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"4000\";\n}\nbackend examples {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\nbackend components {\n .host = \"127.0.0.1\";\n .port = \"3330\";\n}\n\nsub vcl_recv {\n if (!req.http.Host) {\n error 404 \"Need a host header\";\n }\n\n set req.http.Host = regsub(req.http.Host, \"^www\\.\", \"\");\n set req.http.Host = regsub(req.http.Host, \":80$\", \"\");\n\n if (\n req.http.Host ~ \"^chat\\.\" ||\n req.http.Host ~ \"^charts\\.\" ||\n req.http.Host ~ \"^directory\\.\" ||\n req.http.Host ~ \"^codemirror\\.\" ||\n req.http.Host ~ \"^hello\\.\" ||\n req.http.Host ~ \"^sink\\.\" ||\n req.http.Host ~ \"^todos\\.\" ||\n req.http.Host ~ \"^widgets\\.\"\n ) {\n set req.backend = examples;\n } else if (req.http.Host ~ \"^components\\.\") {\n set req.backend = components;\n }\n\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n if (req.restarts == 0) {\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For =\n req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization || req.http.Cookie) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n return (lookup);\n}\n\nsub vcl_pipe {\n # Websockets\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"53e73a82671e67d644c80cc438a779ae517d39b4","subject":"D'oh, fix VCL syntax in an example.","message":"D'oh, fix VCL syntax in an example.\n","repos":"brandonwamboldt\/libvmod-redis,SBRDevelopment\/libvmod-redis,zephirworks\/libvmod-redis,zephirworks\/libvmod-redis,SBRDevelopment\/libvmod-redis,brandonwamboldt\/libvmod-redis","old_file":"examples\/session_affinity.vcl","new_file":"examples\/session_affinity.vcl","new_contents":"#\n# Cookie-based session-affinity: non-cached replies will go to a backend per\n# the normal rules, but we'll keep track of the backend that served the\n# request and make sure any future request from the same client will go to\n# the same backend.\n#\n\nimport redis;\nimport std;\n\nbackend be1 {\n .host = \"192.168.0.1\";\n .port = \"80\";\n}\n\nbackend be2 {\n .host = \"192.168.0.2\";\n .port = \"80\";\n}\n\ndirector default random {\n .retries = 5;\n {\n .backend = be1;\n .weight = 7;\n }\n {\n .backend = be2;\n .weight = 3;\n }\n}\n\n#\n# Compute the redis key from a request.\n#\n# In this example a cookie is used, but it could be anything distinctive enough;\n# IP address + User Agent + Accept* headers should work nicely for most purposes.\n#\nsub redis_key_from_req {\n if (req.http.Cookie) {\n set req.http.redis_key = req.http.Cookie;\n }\n}\n\n#\n# Compute the redis key from a response.\n#\n# We use the reposnse cookie if present, as it might be different. We still\n# have the request headers in case we want to use a different schema (see the\n# comment for redis_key_from_req).\n#\n# Another option is to have the backend send us an explicit header.\n#\nsub redis_key_from_beresp {\n if (beresp.http.Set_Cookie) {\n set req.http.redis_key = beresp.http.Set_Cookie;\n } else if (req.http.Cookie) {\n set req.http.redis_key = req.http.Cookie;\n }\n}\n\n#\n# Compute the backend that will serve further requests for this user.\n#\n# We just use the backend name, but we may as well use an explicit header\n# from the backend. This would enable other scenarios, e.g. a \"master\" app\n# server that creates sessions and then hands them off to other servers.\n#\nsub backend_from_beresp {\n set beresp.http.x_backend = beresp.backend.name;\n}\n\n#\n# Set a backend given the name.\n#\n# This would be a very useful addition to the language, or it could be\n# implemented as a vmod.\n#\nsub set_backend_by_name {\n if (req.http.x_backend) {\n std.log(\"backend will be: \" + req.http.x_backend);\n\n if (req.http.x_backend == \"be1\") {\n set req.backend = be1;\n } else if (req.http.x_backend == \"be2\") {\n set req.backend = be2;\n } else {\n error 503 \"No such backend \" + req.http.x_backend;\n }\n }\n}\n\n#\n# This is the main subroutine; it takes care of finding whether we have an\n# entry in redis, and sets the corresponding backed.\n#\nsub select_backend {\n call redis_key_from_req;\n\n if (req.http.redis_key) {\n set req.http.x_backend = redis.call(\"HGET sessions \" + req.http.redis_key);\n if (req.http.x_backend) {\n std.log(\"Found in redis\");\n call set_backend_by_name;\n } else {\n # we will let the director choose\n }\n } else {\n std.log(\"Cookie not found\");\n }\n}\n\nsub vcl_miss {\n call select_backend;\n}\n\nsub vcl_pass {\n call select_backend;\n}\n\nsub vcl_pipe {\n call select_backend;\n}\n\n#\n# IF we don't have an entry in redis, we just let the director (or other\n# mechanism) choose. When we get the response we need to figure key and\n# value and store them.\n#\nsub vcl_fetch {\n if (!req.http.x_backend) {\n call redis_key_from_beresp;\n call backend_from_beresp;\n\n if (req.http.redis_key) {\n std.log(\"Fetched from: \" + beresp.http.x_backend + \", key=\" + req.http.redis_key);\n redis.send(\"HSET sessions \" + req.http.redis_key + \" \" + beresp.http.x_backend);\n }\n }\n}\n","old_contents":"#\n# Cookie-based session-affinity: non-cached replies will go to a backend per\n# the normal rules, but we'll keep track of the backend that served the\n# request and make sure any future request from the same client will go to\n# the same backend.\n#\n\nimport redis;\nimport std;\n\nbackend be1 {\n .host = \"192.168.0.1\";\n .port = \"80\";\n}\n\nbackend be2 {\n .host = \"192.168.0.2\";\n .port = \"80\";\n}\n\ndirector default random {\n .retries = 5;\n {\n .backend = be1;\n .weight = 7;\n }\n {\n .backend = be2;\n .weight = 3;\n }\n}\n\n#\n# Compute the redis key from a request.\n#\n# In this example a cookie is used, but it could be anything distinctive enough;\n# IP address + User Agent + Accept* headers should work nicely for most purposes.\n#\nsub redis_key_from_req {\n if (req.http.Cookie) {\n set req.http.redis_key = req.http.Cookie;\n }\n}\n\n#\n# Compute the redis key from a response.\n#\n# We use the reposnse cookie if present, as it might be different. We still\n# have the request headers in case we want to use a different schema (see the\n# comment for redis_key_from_req).\n#\n# Another option is to have the backend send us an explicit header.\n#\nsub redis_key_from_beresp {\n if (beresp.http.Set_Cookie) {\n set req.http.redis_key = beresp.http.Set_Cookie;\n } else if (req.http.Cookie) {\n set req.http.redis_key = req.http.Cookie;\n }\n}\n\n#\n# Compute the backend that will serve further requests for this user.\n#\n# We just use the backend name, but we may as well use an explicit header\n# from the backend. This would enable other scenarios, e.g. a \"master\" app\n# server that creates sessions and then hands them off to other servers.\n#\nsub backend_from_beresp {\n set beresp.http.x_backend = beresp.backend.name;\n}\n\n#\n# Set a backend given the name.\n#\n# This would be a very useful addition to the language, or it could be\n# implemented as a vmod.\n#\nsub set_backend_by_name {\n if (req.http.x_backend) {\n std.log(\"backend will be: \" + req.http.x_backend);\n\n if (req.http.x_backend == \"be1\") {\n set req.backend = be1;\n } else if (req.http.x_backend == \"be2\") {\n set req.backend = be2;\n } else {\n return(error 503 \"No such backend \" + req.http.x_backend);\n }\n }\n}\n\n#\n# This is the main subroutine; it takes care of finding whether we have an\n# entry in redis, and sets the corresponding backed.\n#\nsub select_backend {\n call redis_key_from_req;\n\n if (req.http.redis_key) {\n set req.http.x_backend = redis.call(\"HGET sessions \" + req.http.redis_key);\n if (req.http.x_backend) {\n std.log(\"Found in redis\");\n call set_backend_by_name;\n } else {\n # we will let the director choose\n }\n } else {\n std.log(\"Cookie not found\");\n }\n}\n\nsub vcl_miss {\n call select_backend;\n}\n\nsub vcl_pass {\n call select_backend;\n}\n\nsub vcl_pipe {\n call select_backend;\n}\n\n#\n# IF we don't have an entry in redis, we just let the director (or other\n# mechanism) choose. When we get the response we need to figure key and\n# value and store them.\n#\nsub vcl_fetch {\n if (!req.http.x_backend) {\n call redis_key_from_beresp;\n call backend_from_beresp;\n\n if (req.http.redis_key) {\n std.log(\"Fetched from: \" + beresp.http.x_backend + \", key=\" + req.http.redis_key);\n redis.send(\"HSET sessions \" + req.http.redis_key + \" \" + beresp.http.x_backend);\n }\n }\n}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"081ea15a94ec7448f8643d1a3c4b320ee8997b65","subject":"doc + support unsetting the override cookie","message":"doc + support unsetting the override cookie\n","repos":"wikp\/varnish-devicedetect,varnish\/varnish-devicedetect,kevinquinnyo\/varnish-devicedetect,varnish\/varnish-devicedetect,kevinquinnyo\/varnish-devicedetect,wikp\/varnish-devicedetect","old_file":"devicedetect-dev.vcl","new_file":"devicedetect-dev.vcl","new_contents":"#\n# devicedetect-dev.vcl\n#\n# Enable test URLs and cookie overrides.\n#\n\nbackend devicetest { \n .host = \"127.0.0.1\";\n .port = \"8000\";\n}\n\nsub vcl_recv {\n # 701\/702 are arbitrary chosen return codes that is only used internally in varnish.\n if (req.url ~ \"^\/set_ua_device\/.+\") { error 701 regsub(req.url, \"^\/set_ua_device\/\", \"\"); }\n # set expired cookie if nothing is specified\n if (req.url ~ \"^\/set_ua_device\/\") { error 702 \"OK\"; }\n if (req.url ~ \"^\/devicetest\") { set req.backend = devicetest; }\n}\n\nsub vcl_error { \n if (obj.status == 701 || obj.status == 702) {\n if (obj.status == 702) {\n set obj.status = 200;\n set obj.http.Set-Cookie = \"X-UA-Device-force=expiring; Path=\/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;\";\n\n\t} else {\n\t set obj.status = 200;\n\t set obj.http.Set-Cookie = \"X-UA-Device-force=\" + obj.response + \"; Path=\/;\";\n\t}\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n synthetic {\"<html><body><h1>OK, Cookie updated<\/h1><a href='\/devicetest\/'>\/devicetest\/<\/a><\/body><\/html>\"};\n set obj.response = \"OK\";\n return(deliver);\n }\n}\n","old_contents":"#\n# devicedetect-dev.vcl\n#\n# Enable test URLs and cookie overrides\n\nbackend devicetest { \n .host = \"127.0.0.1\";\n .port = \"8000\";\n}\n\nsub vcl_recv {\n if (req.url ~ \"^\/set_devicetype\/\") { error 701 regsub(req.url, \"^\/set_devicetype\/\", \"\"); }\n if (req.url ~ \"^\/devicetest\") { set backend = devicetest; }\n}\n\nsub vcl_error { \n if (obj.status == 701 ) {\n # obj.response == mobile-generic\n set obj.http.Set-Cookie = \"X-UA-device=\" + obj.response;\n set obj.http.Content-Type = \"text\/plain; charset=utf-8\";\n synthetic {\" 200 OK, Cookie set \"};\n\treturn(deliver)\n }\n}\n\"\"\"\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"5fe80b7c087ab457da3baf4e015ce6ba9379c58a","subject":"Use a different test for if ESI is being done","message":"Use a different test for if ESI is being done\n","repos":"dstufft\/warehouse,pypa\/warehouse,dstufft\/warehouse,karan\/warehouse,wlonk\/warehouse,ismail-s\/warehouse,ismail-s\/warehouse,alex\/warehouse,wlonk\/warehouse,pypa\/warehouse,HonzaKral\/warehouse,ismail-s\/warehouse,dstufft\/warehouse,ismail-s\/warehouse,pypa\/warehouse,alex\/warehouse,HonzaKral\/warehouse,HonzaKral\/warehouse,wlonk\/warehouse,alex\/warehouse,alex\/warehouse,alex\/warehouse,HonzaKral\/warehouse,dstufft\/warehouse,ismail-s\/warehouse,karan\/warehouse,karan\/warehouse,karan\/warehouse,pypa\/warehouse,karan\/warehouse","old_file":"vcl\/main.vcl","new_file":"vcl\/main.vcl","new_contents":"\nsub vcl_recv {\n#FASTLY recv\n\n # Disable ESI processing when doing a shield request.\n if (req.http.Fastly-FF) {\n set req.esi = false;\n }\n\n # If we're serving an ESI request, and the request in question has NOT\n # opted into cookies, then we'll go ahead and strip any cookies from the\n # request. In addition, we'll strip out any Authorization or Authentication\n # headers.\n if (req.url ~ \"^\/_esi\/\") {\n unset req.http.Authenticate;\n unset req.http.Authorization;\n\n if (req.url !~ \"esi-cookies=1\") {\n unset req.http.Cookie;\n }\n }\n\n # We want to Force SSL for the WebUI by redirecting to the HTTPS version of\n # the page, however for API calls we want to return an error code directing\n # people to instead use HTTPS.\n if (!req.http.Fastly-SSL) {\n\n # The \/simple\/ and \/packages\/ API.\n if (req.url ~ \"^\/(simple|packages)\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy JSON API.\n if (req.url ~ \"^\/pypi\/.+\/json$\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy ?:action= API.\n if (req.url ~ \"^\/pypi.*(\\?|&)=:action\") {\n error 803 \"SSL is required\";\n }\n\n # If we're on the \/pypi page and we've received something other than a\n # GET or HEAD request, then we have no way to determine if a particular\n # request is an API call or not because it'll be in the request body\n # and that isn't available to us here. So in those cases, we won't\n # do a redirect.\n if (req.url ~ \"^\/pypi\") {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n error 801 \"Force SSL\";\n }\n }\n else {\n # This isn't a \/pypi URL so we'll just unconditionally redirect to\n # HTTPS.\n error 801 \"Force SSL\";\n }\n }\n\n # Set a header to tell the backend if we're using https or http.\n if (req.http.Fastly-SSL) {\n set req.http.Warehouse-Proto = \"https\";\n } else {\n set req.http.Warehouse-Proto = \"http\";\n }\n\n # Pass the client IP address back to the backend.\n if (req.http.Fastly-Client-IP) {\n set req.http.Warehouse-IP = req.http.Fastly-Client-IP;\n }\n\n # Pass the real host value back to the backend.\n if (req.http.Host) {\n set req.http.Warehouse-Host = req.http.Host;\n }\n\n # Do not bother to attempt to run the caching mechanisms for methods that\n # are not generally safe to cache.\n if (req.request != \"HEAD\" &&\n req.request != \"GET\" &&\n req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n # Finally, return the default lookup action.\n return(lookup);\n}\n\n\nsub vcl_fetch {\n#FASTLY fetch\n\n # Only enable ESI on requests that could possibly support it, for now just\n # ones that return HTML, but not the \/simple\/ API.\n if (beresp.http.Content-type ~ \"html\" && !(req.url ~ \"^\/simple\/\")) {\n # Conditional HTTP requests are not compatible with Varnish's\n # implementation of ESI, in particularl the ETag and the Last-Modified\n # won't be updated when the included content changes, causing Varnish\n # to return a 304 Not Modified.\n unset beresp.http.ETag;\n unset beresp.http.Last-Modified;\n\n # Enable ESI.\n esi;\n }\n\n # Trigger a \"SSL is required\" error if the backend has indicated to do so.\n if (beresp.http.X-Fastly-Error == \"803\") {\n error 803 \"SSL is required\";\n }\n\n # If we've gotten a 500 or a 503 from the backend, we'll go ahead and retry\n # the request.\n if ((beresp.status == 500 || beresp.status == 503) &&\n req.restarts < 1 &&\n (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n # If we've restarted, then we'll record the number of restarts.\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n # If there is a Set-Cookie header, we'll ensure that we do not cache the\n # response.\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n # If the response has the private Cache-Control directive then we won't\n # cache it.\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # If we've gotten an error after the restarts we'll deliver the response\n # with a very short cache time.\n if (beresp.status == 500 || beresp.status == 503) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n # Apply a default TTL if there isn't a max-age or s-maxage.\n if (beresp.http.Expires ||\n beresp.http.Surrogate-Control ~ \"max-age\" ||\n beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # Keep the ttl here\n }\n else {\n # Apply the default ttl\n set beresp.ttl = 60s;\n }\n\n # Actually deliver the fetched response.\n return(deliver);\n}\n\n\nsub vcl_deliver {\n#FASTLY deliver\n\n # If the backend has indicated additional Vary headers to add once the\n # ESI result has been processed, then we'll go ahead and either append them\n # to our existing Vary header or we'll set the Vary header equal to it.\n if (resp.http.Warehouse-ESI-Vary) {\n if (resp.http.Vary) {\n set resp.http.Vary = resp.http.Vary \", \" resp.http.Warehouse-ESI-Vary;\n } else {\n set resp.http.Vary = resp.http.Warehouse-ESI-Vary;\n }\n\n unset resp.http.Warehouse-ESI-Vary;\n }\n\n return(deliver);\n}\n\n\nsub vcl_error {\n#FASTLY error\n\n if (obj.status == 803) {\n set obj.status = 403;\n set obj.response = \"SSL is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic {\"SSL is required.\"};\n return (deliver);\n }\n}\n","old_contents":"\nsub vcl_recv {\n#FASTLY recv\n\n # Disable ESI processing when doing a shield request.\n if (req.http.Fastly-FF) {\n set req.esi = false;\n }\n\n # If we're serving an ESI request, and the request in question has NOT\n # opted into cookies, then we'll go ahead and strip any cookies from the\n # request. In addition, we'll strip out any Authorization or Authentication\n # headers.\n if (req.esis > 0) {\n unset req.http.Authenticate;\n unset req.http.Authorization;\n\n if (req.url !~ \"esi-cookies=1\") {\n unset req.http.Cookie;\n }\n }\n\n # We want to Force SSL for the WebUI by redirecting to the HTTPS version of\n # the page, however for API calls we want to return an error code directing\n # people to instead use HTTPS.\n if (!req.http.Fastly-SSL) {\n\n # The \/simple\/ and \/packages\/ API.\n if (req.url ~ \"^\/(simple|packages)\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy JSON API.\n if (req.url ~ \"^\/pypi\/.+\/json$\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy ?:action= API.\n if (req.url ~ \"^\/pypi.*(\\?|&)=:action\") {\n error 803 \"SSL is required\";\n }\n\n # If we're on the \/pypi page and we've received something other than a\n # GET or HEAD request, then we have no way to determine if a particular\n # request is an API call or not because it'll be in the request body\n # and that isn't available to us here. So in those cases, we won't\n # do a redirect.\n if (req.url ~ \"^\/pypi\") {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n error 801 \"Force SSL\";\n }\n }\n else {\n # This isn't a \/pypi URL so we'll just unconditionally redirect to\n # HTTPS.\n error 801 \"Force SSL\";\n }\n }\n\n # Set a header to tell the backend if we're using https or http.\n if (req.http.Fastly-SSL) {\n set req.http.Warehouse-Proto = \"https\";\n } else {\n set req.http.Warehouse-Proto = \"http\";\n }\n\n # Pass the client IP address back to the backend.\n if (req.http.Fastly-Client-IP) {\n set req.http.Warehouse-IP = req.http.Fastly-Client-IP;\n }\n\n # Pass the real host value back to the backend.\n if (req.http.Host) {\n set req.http.Warehouse-Host = req.http.Host;\n }\n\n # Do not bother to attempt to run the caching mechanisms for methods that\n # are not generally safe to cache.\n if (req.request != \"HEAD\" &&\n req.request != \"GET\" &&\n req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n # Finally, return the default lookup action.\n return(lookup);\n}\n\n\nsub vcl_fetch {\n#FASTLY fetch\n\n # Only enable ESI on requests that could possibly support it, for now just\n # ones that return HTML, but not the \/simple\/ API.\n if (beresp.http.Content-type ~ \"html\" && !(req.url ~ \"^\/simple\/\")) {\n # Conditional HTTP requests are not compatible with Varnish's\n # implementation of ESI, in particularl the ETag and the Last-Modified\n # won't be updated when the included content changes, causing Varnish\n # to return a 304 Not Modified.\n unset beresp.http.ETag;\n unset beresp.http.Last-Modified;\n\n # Enable ESI.\n esi;\n }\n\n # Trigger a \"SSL is required\" error if the backend has indicated to do so.\n if (beresp.http.X-Fastly-Error == \"803\") {\n error 803 \"SSL is required\";\n }\n\n # If we've gotten a 500 or a 503 from the backend, we'll go ahead and retry\n # the request.\n if ((beresp.status == 500 || beresp.status == 503) &&\n req.restarts < 1 &&\n (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n # If we've restarted, then we'll record the number of restarts.\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n # If there is a Set-Cookie header, we'll ensure that we do not cache the\n # response.\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n # If the response has the private Cache-Control directive then we won't\n # cache it.\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # If we've gotten an error after the restarts we'll deliver the response\n # with a very short cache time.\n if (beresp.status == 500 || beresp.status == 503) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n # Apply a default TTL if there isn't a max-age or s-maxage.\n if (beresp.http.Expires ||\n beresp.http.Surrogate-Control ~ \"max-age\" ||\n beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # Keep the ttl here\n }\n else {\n # Apply the default ttl\n set beresp.ttl = 60s;\n }\n\n # Actually deliver the fetched response.\n return(deliver);\n}\n\n\nsub vcl_deliver {\n#FASTLY deliver\n\n # If the backend has indicated additional Vary headers to add once the\n # ESI result has been processed, then we'll go ahead and either append them\n # to our existing Vary header or we'll set the Vary header equal to it.\n if (resp.http.Warehouse-ESI-Vary) {\n if (resp.http.Vary) {\n set resp.http.Vary = resp.http.Vary \", \" resp.http.Warehouse-ESI-Vary;\n } else {\n set resp.http.Vary = resp.http.Warehouse-ESI-Vary;\n }\n\n unset resp.http.Warehouse-ESI-Vary;\n }\n\n return(deliver);\n}\n\n\nsub vcl_error {\n#FASTLY error\n\n if (obj.status == 803) {\n set obj.status = 403;\n set obj.response = \"SSL is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic {\"SSL is required.\"};\n return (deliver);\n }\n}\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"fae9b2b82720f57b4f51ca6babecc2fb5a91b5c7","subject":"VCL requires \" instead of ' for strings","message":"VCL requires \" instead of ' for strings\n","repos":"alex\/warehouse,karan\/warehouse,dstufft\/warehouse,dstufft\/warehouse,wlonk\/warehouse,pypa\/warehouse,pypa\/warehouse,karan\/warehouse,pypa\/warehouse,alex\/warehouse,alex\/warehouse,pypa\/warehouse,karan\/warehouse,wlonk\/warehouse,dstufft\/warehouse,alex\/warehouse,alex\/warehouse,dstufft\/warehouse,wlonk\/warehouse,karan\/warehouse,karan\/warehouse","old_file":"vcl\/main.vcl","new_file":"vcl\/main.vcl","new_contents":"\nsub vcl_recv {\n\n # Some (Older) clients will send a hash fragment as part of the URL even\n # though that is a local only modification. This breaks this badly for the\n # files in S3, and in general it's just not needed.\n set req.url = regsub(req.url, \"#.*$\", \"\");\n\n # Most of the URLs in Warehouse do not support or require any sort of query\n # parameter. If we strip these at the edge then we'll increase our cache\n # efficiency when they won't otherwise change the output of the pages.\n #\n # This will match any URL except those that start with:\n #\n # * \/search\/\n # * \/account\/login\/\n # * \/account\/logout\/\n # * \/account\/register\/\n # * \/pypi\n if (req.url !~ \"^\/(search\/|account\/(login|logout|register)\/|pypi)\") {\n set req.url = req.url.path;\n }\n\n # Sort all of our query parameters, this will ensure that the same query\n # parameters in a different order will end up being represented as the same\n # thing, reducing cache misses due to ordering differences.\n set req.url = boltsort.sort(req.url);\n\n\n#FASTLY recv\n\n\n # We want to Force SSL for the WebUI by redirecting to the HTTPS version of\n # the page, however for API calls we want to return an error code directing\n # people to instead use HTTPS.\n if (!req.http.Fastly-SSL) {\n\n # The \/simple\/ and \/packages\/ API.\n if (req.url ~ \"^\/(simple|packages)\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy JSON API.\n if (req.url ~ \"^\/pypi\/.+\/json$\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy ?:action= API.\n if (req.url ~ \"^\/pypi.*(\\?|&)=:action\") {\n error 803 \"SSL is required\";\n }\n\n # If we're on the \/pypi page and we've received something other than a\n # GET or HEAD request, then we have no way to determine if a particular\n # request is an API call or not because it'll be in the request body\n # and that isn't available to us here. So in those cases, we won't\n # do a redirect.\n if (req.url ~ \"^\/pypi\") {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n error 801 \"Force SSL\";\n }\n }\n else {\n # This isn't a \/pypi URL so we'll just unconditionally redirect to\n # HTTPS.\n error 801 \"Force SSL\";\n }\n }\n\n # Canonicalize our domains by redirecting any domain that doesn't match our\n # primary domain to our primary domain. We do this *after* the HTTPS check\n # on purpose.\n if (std.tolower(req.http.host) != std.tolower(req.http.Primary-Domain)) {\n set req.http.Location = \"https:\/\/\" req.http.Primary-Domain req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n\n # Requests to \/packages\/ get dispatched to Amazon instead of to our typical\n # Origin. This requires a a bit of setup to make it work.\n if (req.url ~ \"^\/packages\/\") {\n # Setup our environment to better match what S3 expects\/needs\n set req.http.Host = req.http.AWS-Bucket-Name \".s3.amazonaws.com\";\n set req.http.Date = now;\n set req.url = regsuball(req.url, \"\\+\", urlencode(\"+\"));\n\n # Compute the Authorization header that S3 requires to be able to\n # access the files stored there.\n set req.http.Authorization = \"AWS \" req.http.AWS-Access-Key-ID \":\" digest.hmac_sha1_base64(req.http.AWS-Secret-Access-Key, \"GET\" LF LF LF req.http.Date LF \"\/\" req.http.AWS-Bucket-Name req.url.path);\n\n # We don't want to send our Warehouse-Token to S3, so we'll go ahead\n # and remove it.\n unset req.http.Warehouse-Token;\n }\n\n # We no longer need any of these variables, which would exist only to\n # shuffle configuration from the Fastly UI into our VCL.\n unset req.http.Primary-Domain;\n unset req.http.AWS-Access-Key-ID;\n unset req.http.AWS-Secret-Access-Key;\n unset req.http.AWS-Bucket-Name;\n\n # We have a number of items that we'll pass back to the origin, but only\n # if we have a Warehouse-Token that will allow them to be accepted.\n if (req.http.Warehouse-Token) {\n # Set a header to tell the backend if we're using https or http.\n if (req.http.Fastly-SSL) {\n set req.http.Warehouse-Proto = \"https\";\n } else {\n set req.http.Warehouse-Proto = \"http\";\n }\n\n # Pass the client IP address back to the backend.\n if (req.http.Fastly-Client-IP) {\n set req.http.Warehouse-IP = req.http.Fastly-Client-IP;\n }\n\n # Pass the real host value back to the backend.\n if (req.http.Host) {\n set req.http.Warehouse-Host = req.http.Host;\n }\n }\n\n # Do not bother to attempt to run the caching mechanisms for methods that\n # are not generally safe to cache.\n if (req.request != \"HEAD\" &&\n req.request != \"GET\" &&\n req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n # Finally, return the default lookup action.\n return(lookup);\n}\n\n\nsub vcl_fetch {\n#FASTLY fetch\n\n # Trigger a \"SSL is required\" error if the backend has indicated to do so.\n if (beresp.http.X-Fastly-Error == \"803\") {\n error 803 \"SSL is required\";\n }\n\n # If we've gotten a 502 or a 503 from the backend, we'll go ahead and retry\n # the request.\n if ((beresp.status == 502 || beresp.status == 503) &&\n req.restarts < 1 &&\n (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n # If we've restarted, then we'll record the number of restarts.\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n # If there is a Set-Cookie header, we'll ensure that we do not cache the\n # response.\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n # If the response has the private Cache-Control directive then we won't\n # cache it.\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # If we've gotten an error after the restarts we'll deliver the response\n # with a very short cache time.\n if (beresp.status == 500 || beresp.status == 503) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n # Apply a default TTL if there isn't a max-age or s-maxage.\n if (beresp.http.Expires ||\n beresp.http.Surrogate-Control ~ \"max-age\" ||\n beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # Keep the ttl here\n }\n else {\n # Apply the default ttl\n set beresp.ttl = 60s;\n }\n\n # Actually deliver the fetched response.\n return(deliver);\n}\n\n\nsub vcl_deliver {\n#FASTLY deliver\n\n # Unset headers that we don't need\/want to send on to the client because\n # they are not generally useful.\n unset resp.http.Server;\n unset resp.http.Via;\n\n # Unset a few headers set by Amazon that we don't really have a need\/desire\n # to send to clients.\n unset resp.http.X-AMZ-Replication-Status;\n unset resp.http.X-AMZ-Meta-Python-Version;\n unset resp.http.X-AMZ-Meta-Version;\n unset resp.http.X-AMZ-Meta-Package-Type;\n unset resp.http.X-AMZ-Meta-Project;\n\n # Set our standard security headers, we do this in VCL rather than in\n # Warehouse itself so that we always get these headers, regardless of the\n # origin server being used.\n set resp.http.Strict-Transport-Security = \"max-age=31536000; includeSubDomains; preload\";\n set resp.http.X-Frame-Options = \"deny\";\n set resp.http.X-XSS-Protection = \"1; mode=block\";\n set resp.http.X-Content-Type-Options = \"nosniff\";\n set resp.http.X-Permitted-Cross-Domain-Policies = \"none\";\n\n return(deliver);\n}\n\n\nsub vcl_error {\n#FASTLY error\n\n if (obj.status == 803) {\n set obj.status = 403;\n set obj.response = \"SSL is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic {\"SSL is required.\"};\n return (deliver);\n } else if (obj.status == 750) {\n set obj.status = 301;\n set obj.http.Location = req.http.Location;\n set obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n synthetic {\"<html><head><title>301 Moved Permanently<\/title><\/head><body><center><h1>301 Moved Permanently<\/h1><\/center><\/body><\/html>\"};\n return(deliver);\n }\n\n}\n","old_contents":"\nsub vcl_recv {\n\n # Some (Older) clients will send a hash fragment as part of the URL even\n # though that is a local only modification. This breaks this badly for the\n # files in S3, and in general it's just not needed.\n set req.url = regsub(req.url, \"#.*$\", \"\");\n\n # Most of the URLs in Warehouse do not support or require any sort of query\n # parameter. If we strip these at the edge then we'll increase our cache\n # efficiency when they won't otherwise change the output of the pages.\n #\n # This will match any URL except those that start with:\n #\n # * \/search\/\n # * \/account\/login\/\n # * \/account\/logout\/\n # * \/account\/register\/\n # * \/pypi\n if (req.url !~ '^\/(search\/|account\/(login|logout|register)\/|pypi)') {\n set req.url = req.url.path;\n }\n\n # Sort all of our query parameters, this will ensure that the same query\n # parameters in a different order will end up being represented as the same\n # thing, reducing cache misses due to ordering differences.\n set req.url = boltsort.sort(req.url);\n\n\n#FASTLY recv\n\n\n # We want to Force SSL for the WebUI by redirecting to the HTTPS version of\n # the page, however for API calls we want to return an error code directing\n # people to instead use HTTPS.\n if (!req.http.Fastly-SSL) {\n\n # The \/simple\/ and \/packages\/ API.\n if (req.url ~ \"^\/(simple|packages)\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy JSON API.\n if (req.url ~ \"^\/pypi\/.+\/json$\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy ?:action= API.\n if (req.url ~ \"^\/pypi.*(\\?|&)=:action\") {\n error 803 \"SSL is required\";\n }\n\n # If we're on the \/pypi page and we've received something other than a\n # GET or HEAD request, then we have no way to determine if a particular\n # request is an API call or not because it'll be in the request body\n # and that isn't available to us here. So in those cases, we won't\n # do a redirect.\n if (req.url ~ \"^\/pypi\") {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n error 801 \"Force SSL\";\n }\n }\n else {\n # This isn't a \/pypi URL so we'll just unconditionally redirect to\n # HTTPS.\n error 801 \"Force SSL\";\n }\n }\n\n # Canonicalize our domains by redirecting any domain that doesn't match our\n # primary domain to our primary domain. We do this *after* the HTTPS check\n # on purpose.\n if (std.tolower(req.http.host) != std.tolower(req.http.Primary-Domain)) {\n set req.http.Location = \"https:\/\/\" req.http.Primary-Domain req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n\n # Requests to \/packages\/ get dispatched to Amazon instead of to our typical\n # Origin. This requires a a bit of setup to make it work.\n if (req.url ~ \"^\/packages\/\") {\n # Setup our environment to better match what S3 expects\/needs\n set req.http.Host = req.http.AWS-Bucket-Name \".s3.amazonaws.com\";\n set req.http.Date = now;\n set req.url = regsuball(req.url, \"\\+\", urlencode(\"+\"));\n\n # Compute the Authorization header that S3 requires to be able to\n # access the files stored there.\n set req.http.Authorization = \"AWS \" req.http.AWS-Access-Key-ID \":\" digest.hmac_sha1_base64(req.http.AWS-Secret-Access-Key, \"GET\" LF LF LF req.http.Date LF \"\/\" req.http.AWS-Bucket-Name req.url.path);\n\n # We don't want to send our Warehouse-Token to S3, so we'll go ahead\n # and remove it.\n unset req.http.Warehouse-Token;\n }\n\n # We no longer need any of these variables, which would exist only to\n # shuffle configuration from the Fastly UI into our VCL.\n unset req.http.Primary-Domain;\n unset req.http.AWS-Access-Key-ID;\n unset req.http.AWS-Secret-Access-Key;\n unset req.http.AWS-Bucket-Name;\n\n # We have a number of items that we'll pass back to the origin, but only\n # if we have a Warehouse-Token that will allow them to be accepted.\n if (req.http.Warehouse-Token) {\n # Set a header to tell the backend if we're using https or http.\n if (req.http.Fastly-SSL) {\n set req.http.Warehouse-Proto = \"https\";\n } else {\n set req.http.Warehouse-Proto = \"http\";\n }\n\n # Pass the client IP address back to the backend.\n if (req.http.Fastly-Client-IP) {\n set req.http.Warehouse-IP = req.http.Fastly-Client-IP;\n }\n\n # Pass the real host value back to the backend.\n if (req.http.Host) {\n set req.http.Warehouse-Host = req.http.Host;\n }\n }\n\n # Do not bother to attempt to run the caching mechanisms for methods that\n # are not generally safe to cache.\n if (req.request != \"HEAD\" &&\n req.request != \"GET\" &&\n req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n # Finally, return the default lookup action.\n return(lookup);\n}\n\n\nsub vcl_fetch {\n#FASTLY fetch\n\n # Trigger a \"SSL is required\" error if the backend has indicated to do so.\n if (beresp.http.X-Fastly-Error == \"803\") {\n error 803 \"SSL is required\";\n }\n\n # If we've gotten a 502 or a 503 from the backend, we'll go ahead and retry\n # the request.\n if ((beresp.status == 502 || beresp.status == 503) &&\n req.restarts < 1 &&\n (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n # If we've restarted, then we'll record the number of restarts.\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n # If there is a Set-Cookie header, we'll ensure that we do not cache the\n # response.\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n # If the response has the private Cache-Control directive then we won't\n # cache it.\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # If we've gotten an error after the restarts we'll deliver the response\n # with a very short cache time.\n if (beresp.status == 500 || beresp.status == 503) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n # Apply a default TTL if there isn't a max-age or s-maxage.\n if (beresp.http.Expires ||\n beresp.http.Surrogate-Control ~ \"max-age\" ||\n beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # Keep the ttl here\n }\n else {\n # Apply the default ttl\n set beresp.ttl = 60s;\n }\n\n # Actually deliver the fetched response.\n return(deliver);\n}\n\n\nsub vcl_deliver {\n#FASTLY deliver\n\n # Unset headers that we don't need\/want to send on to the client because\n # they are not generally useful.\n unset resp.http.Server;\n unset resp.http.Via;\n\n # Unset a few headers set by Amazon that we don't really have a need\/desire\n # to send to clients.\n unset resp.http.X-AMZ-Replication-Status;\n unset resp.http.X-AMZ-Meta-Python-Version;\n unset resp.http.X-AMZ-Meta-Version;\n unset resp.http.X-AMZ-Meta-Package-Type;\n unset resp.http.X-AMZ-Meta-Project;\n\n # Set our standard security headers, we do this in VCL rather than in\n # Warehouse itself so that we always get these headers, regardless of the\n # origin server being used.\n set resp.http.Strict-Transport-Security = \"max-age=31536000; includeSubDomains; preload\";\n set resp.http.X-Frame-Options = \"deny\";\n set resp.http.X-XSS-Protection = \"1; mode=block\";\n set resp.http.X-Content-Type-Options = \"nosniff\";\n set resp.http.X-Permitted-Cross-Domain-Policies = \"none\";\n\n return(deliver);\n}\n\n\nsub vcl_error {\n#FASTLY error\n\n if (obj.status == 803) {\n set obj.status = 403;\n set obj.response = \"SSL is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic {\"SSL is required.\"};\n return (deliver);\n } else if (obj.status == 750) {\n set obj.status = 301;\n set obj.http.Location = req.http.Location;\n set obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n synthetic {\"<html><head><title>301 Moved Permanently<\/title><\/head><body><center><h1>301 Moved Permanently<\/h1><\/center><\/body><\/html>\"};\n return(deliver);\n }\n\n}\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"1d2ba1d25476153d2006869f1b55f9b8c265a646","subject":"Redirect all domains to the primary domain in Fastly","message":"Redirect all domains to the primary domain in Fastly\n","repos":"dstufft\/warehouse,pypa\/warehouse,karan\/warehouse,alex\/warehouse,alex\/warehouse,wlonk\/warehouse,karan\/warehouse,dstufft\/warehouse,alex\/warehouse,karan\/warehouse,dstufft\/warehouse,pypa\/warehouse,wlonk\/warehouse,pypa\/warehouse,karan\/warehouse,karan\/warehouse,alex\/warehouse,pypa\/warehouse,wlonk\/warehouse,dstufft\/warehouse,alex\/warehouse","old_file":"vcl\/main.vcl","new_file":"vcl\/main.vcl","new_contents":"\nsub vcl_recv {\n#FASTLY recv\n\n # We want to Force SSL for the WebUI by redirecting to the HTTPS version of\n # the page, however for API calls we want to return an error code directing\n # people to instead use HTTPS.\n if (!req.http.Fastly-SSL) {\n\n # The \/simple\/ and \/packages\/ API.\n if (req.url ~ \"^\/(simple|packages)\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy JSON API.\n if (req.url ~ \"^\/pypi\/.+\/json$\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy ?:action= API.\n if (req.url ~ \"^\/pypi.*(\\?|&)=:action\") {\n error 803 \"SSL is required\";\n }\n\n # If we're on the \/pypi page and we've received something other than a\n # GET or HEAD request, then we have no way to determine if a particular\n # request is an API call or not because it'll be in the request body\n # and that isn't available to us here. So in those cases, we won't\n # do a redirect.\n if (req.url ~ \"^\/pypi\") {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n error 801 \"Force SSL\";\n }\n }\n else {\n # This isn't a \/pypi URL so we'll just unconditionally redirect to\n # HTTPS.\n error 801 \"Force SSL\";\n }\n }\n\n # Canonicalize our domains by redirecting any domain that doesn't match our\n # primary domain to our primary domain. We do this *after* the HTTPS check\n # on purpose.\n if (std.tolower(req.http.host) != std.tolower(req.http.Primary-Domain)) {\n error 750 \"https:\/\/\" req.http.Primary-Domain req.url;\n }\n\n # Set a header to tell the backend if we're using https or http.\n if (req.http.Fastly-SSL) {\n set req.http.Warehouse-Proto = \"https\";\n } else {\n set req.http.Warehouse-Proto = \"http\";\n }\n\n # Pass the client IP address back to the backend.\n if (req.http.Fastly-Client-IP) {\n set req.http.Warehouse-IP = req.http.Fastly-Client-IP;\n }\n\n # Pass the real host value back to the backend.\n if (req.http.Host) {\n set req.http.Warehouse-Host = req.http.Host;\n }\n\n # Do not bother to attempt to run the caching mechanisms for methods that\n # are not generally safe to cache.\n if (req.request != \"HEAD\" &&\n req.request != \"GET\" &&\n req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n # Finally, return the default lookup action.\n return(lookup);\n}\n\n\nsub vcl_fetch {\n#FASTLY fetch\n\n # Trigger a \"SSL is required\" error if the backend has indicated to do so.\n if (beresp.http.X-Fastly-Error == \"803\") {\n error 803 \"SSL is required\";\n }\n\n # If we've gotten a 502 or a 503 from the backend, we'll go ahead and retry\n # the request.\n if ((beresp.status == 502 || beresp.status == 503) &&\n req.restarts < 1 &&\n (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n # If we've restarted, then we'll record the number of restarts.\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n # If there is a Set-Cookie header, we'll ensure that we do not cache the\n # response.\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n # If the response has the private Cache-Control directive then we won't\n # cache it.\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # If we've gotten an error after the restarts we'll deliver the response\n # with a very short cache time.\n if (beresp.status == 500 || beresp.status == 503) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n # Apply a default TTL if there isn't a max-age or s-maxage.\n if (beresp.http.Expires ||\n beresp.http.Surrogate-Control ~ \"max-age\" ||\n beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # Keep the ttl here\n }\n else {\n # Apply the default ttl\n set beresp.ttl = 60s;\n }\n\n # Actually deliver the fetched response.\n return(deliver);\n}\n\n\nsub vcl_deliver {\n#FASTLY deliver\n\n # Unset headers that we don't need\/want to send on to the client because\n # they are not generally useful.\n unset resp.http.Server;\n unset resp.http.Via;\n\n # Set our standard security headers, we do this in VCL rather than in\n # Warehouse itself so that we always get these headers, regardless of the\n # origin server being used.\n set resp.http.Strict-Transport-Security = \"max-age=31536000; includeSubDomains; preload\";\n set resp.http.X-Frame-Options = \"deny\";\n set resp.http.X-XSS-Protection = \"1; mode=block\";\n set resp.http.X-Content-Type-Options = \"nosniff\";\n set resp.http.X-Permitted-Cross-Domain-Policies = \"none\";\n\n return(deliver);\n}\n\n\nsub vcl_error {\n#FASTLY error\n\n if (obj.status == 803) {\n set obj.status = 403;\n set obj.response = \"SSL is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic {\"SSL is required.\"};\n return (deliver);\n } else if (obj.status == 750) {\n set obj.status = 301;\n set obj.http.Location = obj.response;\n set obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n synthetic {\"<html><head><title>301 Moved Permanently<\/title><\/head><body><center><h1>301 Moved Permanently<\/h1><\/center><\/body><\/html>\"};\n return(deliver);\n }\n\n}\n","old_contents":"\nsub vcl_recv {\n#FASTLY recv\n\n # We want to Force SSL for the WebUI by redirecting to the HTTPS version of\n # the page, however for API calls we want to return an error code directing\n # people to instead use HTTPS.\n if (!req.http.Fastly-SSL) {\n\n # The \/simple\/ and \/packages\/ API.\n if (req.url ~ \"^\/(simple|packages)\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy JSON API.\n if (req.url ~ \"^\/pypi\/.+\/json$\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy ?:action= API.\n if (req.url ~ \"^\/pypi.*(\\?|&)=:action\") {\n error 803 \"SSL is required\";\n }\n\n # If we're on the \/pypi page and we've received something other than a\n # GET or HEAD request, then we have no way to determine if a particular\n # request is an API call or not because it'll be in the request body\n # and that isn't available to us here. So in those cases, we won't\n # do a redirect.\n if (req.url ~ \"^\/pypi\") {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n error 801 \"Force SSL\";\n }\n }\n else {\n # This isn't a \/pypi URL so we'll just unconditionally redirect to\n # HTTPS.\n error 801 \"Force SSL\";\n }\n }\n\n # Set a header to tell the backend if we're using https or http.\n if (req.http.Fastly-SSL) {\n set req.http.Warehouse-Proto = \"https\";\n } else {\n set req.http.Warehouse-Proto = \"http\";\n }\n\n # Pass the client IP address back to the backend.\n if (req.http.Fastly-Client-IP) {\n set req.http.Warehouse-IP = req.http.Fastly-Client-IP;\n }\n\n # Pass the real host value back to the backend.\n if (req.http.Host) {\n set req.http.Warehouse-Host = req.http.Host;\n }\n\n # Do not bother to attempt to run the caching mechanisms for methods that\n # are not generally safe to cache.\n if (req.request != \"HEAD\" &&\n req.request != \"GET\" &&\n req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n # Finally, return the default lookup action.\n return(lookup);\n}\n\n\nsub vcl_fetch {\n#FASTLY fetch\n\n # Trigger a \"SSL is required\" error if the backend has indicated to do so.\n if (beresp.http.X-Fastly-Error == \"803\") {\n error 803 \"SSL is required\";\n }\n\n # If we've gotten a 502 or a 503 from the backend, we'll go ahead and retry\n # the request.\n if ((beresp.status == 502 || beresp.status == 503) &&\n req.restarts < 1 &&\n (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n # If we've restarted, then we'll record the number of restarts.\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n # If there is a Set-Cookie header, we'll ensure that we do not cache the\n # response.\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n # If the response has the private Cache-Control directive then we won't\n # cache it.\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # If we've gotten an error after the restarts we'll deliver the response\n # with a very short cache time.\n if (beresp.status == 500 || beresp.status == 503) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n # Apply a default TTL if there isn't a max-age or s-maxage.\n if (beresp.http.Expires ||\n beresp.http.Surrogate-Control ~ \"max-age\" ||\n beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # Keep the ttl here\n }\n else {\n # Apply the default ttl\n set beresp.ttl = 60s;\n }\n\n # Actually deliver the fetched response.\n return(deliver);\n}\n\n\nsub vcl_deliver {\n#FASTLY deliver\n\n # Unset headers that we don't need\/want to send on to the client because\n # they are not generally useful.\n unset resp.http.Server;\n unset resp.http.Via;\n\n # Set our standard security headers, we do this in VCL rather than in\n # Warehouse itself so that we always get these headers, regardless of the\n # origin server being used.\n set resp.http.Strict-Transport-Security = \"max-age=31536000; includeSubDomains; preload\";\n set resp.http.X-Frame-Options = \"deny\";\n set resp.http.X-XSS-Protection = \"1; mode=block\";\n set resp.http.X-Content-Type-Options = \"nosniff\";\n set resp.http.X-Permitted-Cross-Domain-Policies = \"none\";\n\n return(deliver);\n}\n\n\nsub vcl_error {\n#FASTLY error\n\n if (obj.status == 803) {\n set obj.status = 403;\n set obj.response = \"SSL is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic {\"SSL is required.\"};\n return (deliver);\n }\n\n}\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"213f1609e99ad8b64ac217fe3816711b7d644a0c","subject":"Added prerender token to prerender.vcl for crawl tracking","message":"Added prerender token to prerender.vcl for crawl tracking\n","repos":"MWers\/prerender-varnish","old_file":"prerender.vcl","new_file":"prerender.vcl","new_contents":"#\n# NOTE: Heroku\/ELB domains resolve to multiple IP addresses and Varnish\n# doesn't like this. The backend host must be a single IP address, a\n# hostname that resolves to a single IP address, or a dynamically-\n# generated director similar to the one described here:\n#\n# http:\/\/blog.cloudreach.co.uk\/2013\/01\/varnish-and-autoscaling-love-story.html\n#\n\ninclude \"prerender_backend.vcl\";\n\nsub vcl_recv {\n if (req.url ~ \"_escaped_fragment_|prerender=1\" ||\n req.http.user-agent ~ \"googlebot|yahoo|bingbot|baiduspider|yandex|yeti|yodaobot|gigabot|ia_archiver|facebookexternalhit|twitterbot|developers\\.google\\.com\") {\n\n if (req.http.user-agent ~ \"Prerender\") {\n return(pass);\n }\n\n # FIXME: Add a whitelist of files or filetypes to never prerender\n\n set req.backend = prerender;\n\n # When doing SSL offloading in front of Varnish, set X-Scheme header\n # to \"https\" before passing the request to Varnish\n if (req.http.X-Scheme !~ \"^http(s?)\") {\n set req.http.X-Scheme = \"http\";\n }\n set req.url = \"\/\" + req.http.X-Scheme + \":\/\/\" + req.http.Host + req.url;\n\n return(lookup);\n }\n}\n\nsub vcl_miss {\n if (req.backend == prerender) {\n set bereq.http.Host = \"prerender.herokuapp.com\";\n set bereq.http.X-Real-IP = client.ip;\n set bereq.http.X-Forwarded-For = client.ip;\n\n # If you're using hosted prerender.io, set your token here to enable\n # stat collection.\n #\n # IMPORTANT: This information is cached for the lifespan of\n # the Varnish daemon. If you change your token, you must restart Varnish.\n #\n # FIXME: This would ideally be handled via environment variables.\n # I don't think that environment variables are available in Varnish.\n # I'm looking into it.\n set bereq.http.X-Prerender-Token = std.fileread(\"\/etc\/varnish\/prerender_token.txt\");\n }\n}\n\nsub vcl_fetch {\n if (req.backend == prerender) {\n # Set the Varnish cache timeout for rendered content\n set beresp.ttl = 60m;\n }\n}\n","old_contents":"#\n# NOTE: Heroku\/ELB domains resolve to multiple IP addresses and Varnish\n# doesn't like this. The backend host must be a single IP address, a\n# hostname that resolves to a single IP address, or a dynamically-\n# generated director similar to the one described here:\n#\n# http:\/\/blog.cloudreach.co.uk\/2013\/01\/varnish-and-autoscaling-love-story.html\n#\n\ninclude \"prerender_backend.vcl\";\n\nsub vcl_recv {\n if (req.url ~ \"_escaped_fragment_|prerender=1\" ||\n req.http.user-agent ~ \"googlebot|yahoo|bingbot|baiduspider|yandex|yeti|yodaobot|gigabot|ia_archiver|facebookexternalhit|twitterbot|developers\\.google\\.com\") {\n\n if (req.http.user-agent ~ \"Prerender\") {\n return(pass);\n }\n\n set req.backend = prerender;\n\n # When doing SSL offloading in front of Varnish, set X-Scheme header\n # to \"https\" before passing the request to Varnish\n if (req.http.X-Scheme !~ \"^http(s?)\") {\n set req.http.X-Scheme = \"http\";\n }\n set req.url = \"\/\" + req.http.X-Scheme + \":\/\/\" + req.http.Host + req.url;\n\n return(lookup);\n }\n}\n\nsub vcl_miss {\n if (req.backend == prerender) {\n set bereq.http.Host = \"prerender.herokuapp.com\";\n set bereq.http.X-Real-IP = client.ip;\n set bereq.http.X-Forwarded-For = client.ip;\n }\n}\n\nsub vcl_fetch {\n if (req.backend == prerender) {\n # Set the Varnish cache timeout for rendered content\n set beresp.ttl = 60m;\n }\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"de41c3858dda42e24a64b52463fe81bc30e19cb3","subject":"Purge Varnish by filename","message":"Purge Varnish by filename\n\nPurging the original or any thumbnail purges everything (original + thumbs)\n\nBug: T112532\nChange-Id: I8d152a23c9080a6baf16c671f352dbb5f09257e3\n","repos":"HarriAlasi\/wiki3dviewer,stuartbman\/mediawiki-vagrant,HarriAlasi\/wiki3dviewer,wikimedia\/mediawiki-vagrant,HarriAlasi\/wiki3dviewer,HarriAlasi\/wiki3dviewer,stuartbman\/mediawiki-vagrant,wikimedia\/mediawiki-vagrant,HarriAlasi\/wiki3dviewer,wikimedia\/mediawiki-vagrant,HarriAlasi\/wiki3dviewer,HarriAlasi\/wiki3dviewer,stuartbman\/mediawiki-vagrant,stuartbman\/mediawiki-vagrant,wikimedia\/mediawiki-vagrant,wikimedia\/mediawiki-vagrant,stuartbman\/mediawiki-vagrant,stuartbman\/mediawiki-vagrant,stuartbman\/mediawiki-vagrant,wikimedia\/mediawiki-vagrant","old_file":"puppet\/modules\/thumbor\/files\/varnish.vcl","new_file":"puppet\/modules\/thumbor\/files\/varnish.vcl","new_contents":"# vcl_recv is called whenever a request is received\nsub vcl_recv {\n # Copy the thumbnail URLs so that they create variants of the same object\n # By later adding X-Url to the Vary header\n if (req.url ~ \"^\/images\/\") {\n set req.http.X-Url = req.url;\n }\n\n # Pass any requests with the \"If-None-Match\" header directly.\n if (req.http.If-None-Match && !req.url ~ \"^\/images\/thumb\/.*\\.(jpeg|jpg|png)\") {\n return(pass);\n }\n}\n\n# Called if the cache does not have a copy of the page.\nsub vcl_miss {\n # qlow jpg thumbs\n if (req.url ~ \"^\/images\/thumb\/(.*)\/qlow-(\\d+)px-.*\\.(jpg|jpeg)\") {\n set bereq.url = \"\/unsafe\/\" + regsub(req.url, \"^\/images\/thumb\/(.*)\/qlow-(\\d+)px-.*\\.(jpg|jpeg)\", \"\\2\") + \"x\/filters:quality(40):sharpen(0.6,0.01,false)\/http:\/\/127.0.0.1:8080\/images\/\" + regsub(req.url, \"^\/images\/thumb\/(.*)\/qlow-(\\d+)px-.*\\.(jpg|jpeg)\", \"\\1\");\n # regular jpg thumbs\n } else if (req.url ~ \"^\/images\/thumb\/(.*)\/(\\d+)px-.*\\.(jpg|jpeg)\") {\n set bereq.url = \"\/unsafe\/\" + regsub(req.url, \"^\/images\/thumb\/(.*)\/(\\d+)px-.*\\.(jpg|jpeg)\", \"\\2\") + \"x\/filters:quality(87):sharpen(0.6,0.01,false)\/http:\/\/127.0.0.1:8080\/images\/\" + regsub(req.url, \"^\/images\/thumb\/(.*)\/(\\d+)px-.*\\.(jpg|jpeg)\", \"\\1\");\n # png thumbs\n } else if (req.url ~ \"^\/images\/thumb\/(.*)\/(\\d+)px-.*\\.png\") {\n set bereq.url = \"\/unsafe\/\" + regsub(req.url, \"^\/images\/thumb\/(.*)\/(\\d+)px-.*\\.png\", \"\\2\") + \"x\/http:\/\/127.0.0.1:8080\/images\/\" + regsub(req.url, \"^\/images\/thumb\/(.*)\/(\\d+)px-.*\\.png\", \"\\1\");\n }\n}\n\nsub vcl_deliver {\n # Thumbor doesn't do fine-grained config for the headers it returns\n if (req.url ~ \"^\/images\/thumb\/.*\\.(jpeg|jpg|png)\") {\n unset resp.http.Cache-Control;\n unset resp.http.Expires;\n }\n}\n\nsub vcl_fetch {\n if (req.http.X-Url) {\n set beresp.http.X-Url = req.http.X-Url;\n if (!beresp.http.Vary) {\n set beresp.http.Vary = \"X-Url\";\n } elsif (beresp.http.Vary !~ \"(?i)X-Url\") {\n set beresp.http.Vary = beresp.http.Vary + \", X-Url\";\n }\n }\n}\n\nsub vcl_hash {\n # For thumbnails and originals we hash on the filename, to store them all under the same object. This will make purging any of them purge all of them.\n if (req.url ~ \"^\/images\/thumb\/\") {\n hash_data(\"Image-\" + regsub(req.url, \"^\/images\/thumb\/[^\/]+\/[^\/]+\/([^\/]+)\/[^\/]+$\", \"\\1\"));\n } elsif (req.url ~ \"^\/images\/\") {\n hash_data(\"Image-\" + regsub(req.url, \"^\/images\/[^\/]+\/[^\/]+\/(.*)\", \"\\1\"));\n } else {\n hash_data(req.url);\n }\n\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n return (hash);\n}\n","old_contents":"# vcl_recv is called whenever a request is received\nsub vcl_recv {\n # Pass any requests with the \"If-None-Match\" header directly.\n if (req.http.If-None-Match && !req.url ~ \"^\/images\/thumb\/.*\\.(jpeg|jpg|png)\") {\n return(pass);\n }\n}\n\n# Called if the cache does not have a copy of the page.\nsub vcl_miss {\n # qlow jpg thumbs\n if (req.url ~ \"^\/images\/thumb\/(.*)\/qlow-(\\d+)px-.*\\.(jpg|jpeg)\") {\n set bereq.url = \"\/unsafe\/\" + regsub(req.url, \"^\/images\/thumb\/(.*)\/qlow-(\\d+)px-.*\\.(jpg|jpeg)\", \"\\2\") + \"x\/filters:quality(40):sharpen(0.6,0.01,false)\/http:\/\/127.0.0.1:8080\/images\/\" + regsub(req.url, \"^\/images\/thumb\/(.*)\/qlow-(\\d+)px-.*\\.(jpg|jpeg)\", \"\\1\");\n # regular jpg thumbs\n } else if (req.url ~ \"^\/images\/thumb\/(.*)\/(\\d+)px-.*\\.(jpg|jpeg)\") {\n set bereq.url = \"\/unsafe\/\" + regsub(req.url, \"^\/images\/thumb\/(.*)\/(\\d+)px-.*\\.(jpg|jpeg)\", \"\\2\") + \"x\/filters:quality(87):sharpen(0.6,0.01,false)\/http:\/\/127.0.0.1:8080\/images\/\" + regsub(req.url, \"^\/images\/thumb\/(.*)\/(\\d+)px-.*\\.(jpg|jpeg)\", \"\\1\");\n # png thumbs\n } else if (req.url ~ \"^\/images\/thumb\/(.*)\/(\\d+)px-.*\\.png\") {\n set bereq.url = \"\/unsafe\/\" + regsub(req.url, \"^\/images\/thumb\/(.*)\/(\\d+)px-.*\\.png\", \"\\2\") + \"x\/http:\/\/127.0.0.1:8080\/images\/\" + regsub(req.url, \"^\/images\/thumb\/(.*)\/(\\d+)px-.*\\.png\", \"\\1\");\n }\n}\n\nsub vcl_deliver {\n # Thumbor doesn't even fine-grained config for the headers it returns\n if (req.url ~ \"^\/images\/thumb\/.*\\.(jpeg|jpg|png)\") {\n unset resp.http.Cache-Control;\n unset resp.http.Expires;\n }\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"782f4c2b25fa648e816617f18c8fa78e7fc55aca","subject":"Remove Pragma and Expires headers for immutable objects as they cause unnecessary revalidations on Chrome browsers slowing pages down","message":"Remove Pragma and Expires headers for immutable objects as they cause unnecessary revalidations on Chrome browsers slowing pages down\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets\/fetch.vcl","new_file":"etc\/vcl_snippets\/fetch.vcl","new_contents":" # If we are doing a bypass for Magento Tester return early as not to affect any headers\n if ( req.http.bypass-secret ) {\n set beresp.ttl = 0s;\n return(pass);\n }\n\n \/* handle 5XX (or any other unwanted status code) *\/\n if (beresp.status >= 500 && beresp.status < 600) {\n\n \/* deliver stale if the object is available *\/\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n # Remove Set-Cookies from responses for static content to match the cookie removal in recv.\n if (req.http.x-long-cache || req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's since those can be temporary during the site build\/index\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n set beresp.http.Cache-Control = \"max-age=0\";\n } else if (req.http.x-long-cache) {\n # Force caching for signed cached assets.\n set beresp.ttl = 31536000s;\n # Add immutable as it avoids IMS and INM revalidations\n set beresp.http.Cache-Control = \"max-age=31536000, immutable\";\n # Remove HTTP\/1.0 caching headers as they may mess with browser memory caches\n unset beresp.http.Pragma;\n unset beresp.http.Expires;\n }\n }\n\n # Fix Vary Header in some cases. In 99.9% of cases Varying on User-Agent is counterproductive\n # https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleFixupVary\n if (beresp.http.Vary ~ \"User-Agent\") {\n unset beresp.http.Vary:User-Agent;\n if (beresp.http.Vary == \"\") {\n unset beresp.http.Vary;\n }\n }\n\n # All the Magento responses should emit X-Esi headers\n if (beresp.http.x-esi) {\n # enable ESI feature for Magento response by default\n esi;\n } else {\n # enable gzip for all static content except\n if ( http_status_matches(beresp.status, \"200,404\") && (beresp.http.content-type ~ \"^(application\/x\\-javascript|text\/css|text\/html|application\/javascript|text\/javascript|application\/json|application\/vnd\\.ms\\-fontobject|application\/x\\-font\\-opentype|application\/x\\-font\\-truetype|application\/x\\-font\\-ttf|application\/xml|font\/eot|font\/opentype|font\/otf|image\/svg\\+xml|image\/vnd\\.microsoft\\.icon|text\/plain)\\s*($|;)\" || req.url.ext ~ \"(?i)(css|js|html|eot|ico|otf|ttf|json)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n set beresp.http.Vary:Accept-Encoding = \"\";\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # Add Varying on Store and Content-Currency for GraphQl, X-Magento-Vary otherwise\n if (req.http.graphql) {\n set beresp.http.Vary:Store = \"\";\n set beresp.http.Vary:Content-Currency = \"\";\n } else if (beresp.http.Content-Type ~ \"text\/(html|xml)\") {\n set beresp.http.Vary:X-Magento-Vary = \"\";\n set beresp.http.Vary:Https = \"\";\n }\n\n # Just in case the Request Setting for x-pass is missing\n if (req.http.x-pass) {\n return (pass);\n }\n\n if (beresp.http.Cache-Control ~ \"private|no-cache|no-store\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # Never cache 302s\n if (beresp.status == 302) {\n return (pass);\n }\n\n if (beresp.http.x-amz-request-id) {\n # If assets are coming from Amazon they may have no Cache-Control headers which may make them uncacheable\n } else if (!beresp.http.Expires && !beresp.http.Surrogate-Control ~ \"max-age\" && !beresp.http.Cache-Control ~ \"(s-maxage|max-age)\") {\n # Varnish sets default TTL if none of the headers above are present. If not set we want to make sure we don't cache it\n set beresp.ttl = 0s;\n set beresp.cacheable = false;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\") && !req.http.x-pass ) {\n unset beresp.http.set-cookie;\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type if they are image\/script or CSS\n if (beresp.http.Content-Type ~ \"(image|script|css)\") {\n set beresp.http.Surrogate-Key = re.group.1;\n }\n }\n\n # If the cache key in the Magento response doesn't match the one that was sent in the request, don't cache under the request's key\n if (req.http.graphql && req.http.X-Magento-Cache-Id && req.http.X-Magento-Cache-Id != beresp.http.X-Magento-Cache-Id) {\n set beresp.ttl = 0s;\n set beresp.cacheable = false;\n }\n","old_contents":" # If we are doing a bypass for Magento Tester return early as not to affect any headers\n if ( req.http.bypass-secret ) {\n set beresp.ttl = 0s;\n return(pass);\n }\n\n \/* handle 5XX (or any other unwanted status code) *\/\n if (beresp.status >= 500 && beresp.status < 600) {\n\n \/* deliver stale if the object is available *\/\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n # Remove Set-Cookies from responses for static content to match the cookie removal in recv.\n if (req.http.x-long-cache || req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's since those can be temporary during the site build\/index\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n set beresp.http.Cache-Control = \"max-age=0\";\n } else if (req.http.x-long-cache) {\n # Force caching for signed cached assets.\n set beresp.ttl = 31536000s;\n # Add immutable as it avoids IMS and INM revalidations\n set beresp.http.Cache-Control = \"max-age=31536000, immutable\";\n }\n }\n\n # Fix Vary Header in some cases. In 99.9% of cases Varying on User-Agent is counterproductive\n # https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExampleFixupVary\n if (beresp.http.Vary ~ \"User-Agent\") {\n unset beresp.http.Vary:User-Agent;\n if (beresp.http.Vary == \"\") {\n unset beresp.http.Vary;\n }\n }\n\n # All the Magento responses should emit X-Esi headers\n if (beresp.http.x-esi) {\n # enable ESI feature for Magento response by default\n esi;\n } else {\n # enable gzip for all static content except\n if ( http_status_matches(beresp.status, \"200,404\") && (beresp.http.content-type ~ \"^(application\/x\\-javascript|text\/css|text\/html|application\/javascript|text\/javascript|application\/json|application\/vnd\\.ms\\-fontobject|application\/x\\-font\\-opentype|application\/x\\-font\\-truetype|application\/x\\-font\\-ttf|application\/xml|font\/eot|font\/opentype|font\/otf|image\/svg\\+xml|image\/vnd\\.microsoft\\.icon|text\/plain)\\s*($|;)\" || req.url.ext ~ \"(?i)(css|js|html|eot|ico|otf|ttf|json)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n set beresp.http.Vary:Accept-Encoding = \"\";\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # Add Varying on Store and Content-Currency for GraphQl, X-Magento-Vary otherwise\n if (req.http.graphql) {\n set beresp.http.Vary:Store = \"\";\n set beresp.http.Vary:Content-Currency = \"\";\n } else if (beresp.http.Content-Type ~ \"text\/(html|xml)\") {\n set beresp.http.Vary:X-Magento-Vary = \"\";\n set beresp.http.Vary:Https = \"\";\n }\n\n # Just in case the Request Setting for x-pass is missing\n if (req.http.x-pass) {\n return (pass);\n }\n\n if (beresp.http.Cache-Control ~ \"private|no-cache|no-store\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # Never cache 302s\n if (beresp.status == 302) {\n return (pass);\n }\n\n if (beresp.http.x-amz-request-id) {\n # If assets are coming from Amazon they may have no Cache-Control headers which may make them uncacheable\n } else if (!beresp.http.Expires && !beresp.http.Surrogate-Control ~ \"max-age\" && !beresp.http.Cache-Control ~ \"(s-maxage|max-age)\") {\n # Varnish sets default TTL if none of the headers above are present. If not set we want to make sure we don't cache it\n set beresp.ttl = 0s;\n set beresp.cacheable = false;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\") && !req.http.x-pass ) {\n unset beresp.http.set-cookie;\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type if they are image\/script or CSS\n if (beresp.http.Content-Type ~ \"(image|script|css)\") {\n set beresp.http.Surrogate-Key = re.group.1;\n }\n }\n\n # If the cache key in the Magento response doesn't match the one that was sent in the request, don't cache under the request's key\n if (req.http.graphql && req.http.X-Magento-Cache-Id && req.http.X-Magento-Cache-Id != beresp.http.X-Magento-Cache-Id) {\n set beresp.ttl = 0s;\n set beresp.cacheable = false;\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"5040f4379d71ffea5bc1eb6cc7eb87d1336c11be","subject":"remove headers from response which users don't need","message":"remove headers from response which users don't need\n","repos":"JakeChampion\/polyfill-service,JakeChampion\/polyfill-service","old_file":"fastly\/vcl\/polyfill-service.vcl","new_file":"fastly\/vcl\/polyfill-service.vcl","new_contents":"sub set_backend {\n\t# The Fastly macro is inserted before the backend is selected because the\n\t# macro has the code which defines the values avaiable for req.http.Host\n\t# but it also contains a default backend which is always set to the EU. I wish we could disable the default backend setting.\n\t#FASTLY recv\n\t\n\t# Calculate the ideal region to route the request to.\n \tdeclare local var.region STRING; \n\tif (server.region ~ \"(APAC|Asia|North-America|South-America|US-Central|US-East|US-West)\") {\n\t\tset var.region = \"US\";\n \t} else {\n\t\tset var.region = \"EU\";\n \t}\n\n\t# Gather the health of the shields and origins.\n\tdeclare local var.v3_eu_is_healthy BOOL;\n\tset req.backend = F_v3_eu;\n\tset var.v3_eu_is_healthy = req.backend.healthy;\n\n\tdeclare local var.v3_us_is_healthy BOOL;\n \tset req.backend = F_v3_us;\n \tset var.v3_us_is_healthy = req.backend.healthy;\n\n \tdeclare local var.shield_eu_is_healthy BOOL;\n \tset req.backend = ssl_shield_london_city_uk;\n \tset var.shield_eu_is_healthy = req.backend.healthy;\n\n \tdeclare local var.shield_us_is_healthy BOOL;\n \tset req.backend = ssl_shield_iad_va_us;\n \tset var.shield_us_is_healthy = req.backend.healthy;\n\n \t# Set some sort of default, that shouldn't get used.\n \tset req.backend = F_v3_eu;\n\n\tdeclare local var.EU_shield_server_name STRING;\n\tset var.EU_shield_server_name = \"LCY\";\n\n\tdeclare local var.US_shield_server_name STRING;\n\tset var.US_shield_server_name = \"IAD\";\n\n\t# Route EU requests to the nearest healthy shield or origin.\n \tif (var.region == \"EU\") {\n\t\tif (server.datacenter != var.EU_shield_server_name && req.http.Request_Came_From_Shield != var.EU_shield_server_name && var.shield_eu_is_healthy) {\n\t\t\tset req.backend = ssl_shield_london_city_uk;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t\tset req.http.Host = req.http.EU_Host;\n\t\t} elseif (var.shield_us_is_healthy) {\n\t\t\tset req.backend = ssl_shield_iad_va_us;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t\tset req.http.Host = req.http.US_Host;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_eu;\n\t\t}\n \t}\n\n\t# Route US requests to the nearest healthy shield or origin.\n \tif (var.region == \"US\") {\n\t\tif (server.datacenter != var.US_shield_server_name && req.http.Request_Came_From_Shield != var.US_shield_server_name && var.shield_us_is_healthy) {\n\t\t\tset req.backend = ssl_shield_iad_va_us;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t\tset req.http.Host = req.http.US_Host;\n\t\t} elseif (var.shield_eu_is_healthy) {\n\t\t\tset req.backend = ssl_shield_london_city_uk;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t\tset req.http.Host = req.http.EU_Host;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_us;\n\t\t}\n\t}\n\n\t# Persist the decision so we can debug the result.\n \tset req.http.Debug-Backend = req.backend;\n}\n\nsub vcl_recv {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_recv;\n\t}\n\n\tif (req.method != \"GET\" && req.method != \"HEAD\" && req.method != \"OPTIONS\" && req.method != \"FASTLYPURGE\" && req.method != \"PURGE\") {\n\t\terror 911;\n\t}\n\n\tif (req.method == \"OPTIONS\") {\n\t\terror 912;\n\t}\n\n\t# Because the old service had a router which allowed any words between \/v2\/polyfill. and .js\n\tif (req.url.path ~ \"^\/v2\/polyfill(\\.\\w+)(\\.\\w+)?\" && req.url.ext == \"js\") {\n\t\tif (re.group.2) {\n\t\t\tset req.url = \"\/v2\/polyfill.min.js?\" req.url.qs;\n\t\t} else {\n\t\t\tset req.url = \"\/v2\/polyfill.js?\" req.url.qs;\n\t\t}\n\t}\n\n\t# Override the v3 defaults with the defaults of v2\n\tif (req.url ~ \"^\/v2\/polyfill(\\.min)?\\.js\") {\n\t\tset req.url = regsub(req.url, \"^\/v2\", \"\/v3\");\n\t\tset req.url = querystring.set(req.url, \"version\", \"3.25.1\");\n\t\tdeclare local var.unknown STRING;\n\t\tset var.unknown = subfield(req.url.qs, \"unknown\", \"&\");\n\t\tset req.url = querystring.set(req.url, \"unknown\", if(var.unknown != \"\", var.unknown, \"ignore\"));\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\") {\n\t\tcall normalise_querystring_parameters_for_polyfill_bundle;\n\t\t# Sort the querystring parameters alphabetically to improve chances of hitting a cached copy.\n\t\t# If querystring is empty, remove the ? from the url.\n\t\tset req.url = querystring.clean(querystring.sort(req.url));\n\t\tcall set_backend;\n\t} else {\n\t\t# The request is to an endpoint which doesn't use query parameters, let's remove them to increase our cache-hit-ratio\n\t\tset req.url = querystring.remove(req.url);\n\t\tcall set_backend;\n\t}\n}\n\nsub vcl_hash {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_hash;\n\t}\n\n\t# We are not adding req.http.host to the hash because we want https:\/\/cdn.polyfill.io and https:\/\/polyfill.io to be a single object in the cache.\n\t# set req.hash += req.http.host;\n\tset req.hash += req.url;\n\t# We include return(hash) to stop the function falling through to the default VCL built into varnish, which for vcl_hash will add req.url and req.http.Host to the hash.\n\treturn(hash);\n}\n\n\nsub shielding_header {\n\tif (req.backend == ssl_shield_iad_va_us) {\n\t\tset req.http.Request_Came_From_Shield = server.datacenter;\n\t} elsif (req.backend == ssl_shield_london_city_uk) {\n\t\tset req.http.Request_Came_From_Shield = server.datacenter;\n\t}\n}\n\nsub vcl_miss {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_miss;\n\t}\n\tcall shielding_header;\n}\n\nsub vcl_pass {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_pass;\n\t}\n\tcall shielding_header;\n}\n\nsub vcl_fetch {\n\tset beresp.http.Request_Came_From_Shield = req.http.Request_Came_From_Shield;\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_fetch;\n\t}\n\n\t# These header are only required for HTML documents.\n\tif (beresp.http.Content-Type ~ \"text\/html\") {\n\t\t# Enables the cross-site scripting filter built into most modern web browsers.\n\t\tset beresp.http.X-XSS-Protection = \"1; mode=block\";\t\n\t}\n\t# Prevents MIME-sniffing a response away from the declared content type.\n\tset beresp.http.X-Content-Type-Options = \"nosniff\";\n\n\t# Ensure the site is only served over HTTPS and reduce the chances of someone performing a MITM attack.\n\tset beresp.http.Strict-Transport-Security = \"max-age=31536000; includeSubdomains; preload\";\n\n\t# The Referrer-Policy header governs which referrer information, sent in the Referer header, should be included with requests made.\n\t# Send a full URL when performing a same-origin request, but only send the origin of the document for other cases.\n\tset beresp.http.Referrer-Policy = \"origin-when-cross-origin\";\n\n\t# Enable purging of all objects in the Fastly cache by issuing a purge with the key \"polyfill-service\".\n\tif (beresp.http.Surrogate-Key !~ \"\\bpolyfill-service\\b\") {\n\t\tset beresp.http.Surrogate-Key = if(beresp.http.Surrogate-Key, beresp.http.Surrogate-Key \" polyfill-service\", \"polyfill-service\");\n\t}\n\n\tset beresp.http.Timing-Allow-Origin = \"*\";\n\n\tif (req.http.Normalized-User-Agent) {\n\t\tset beresp.http.Normalized-User-Agent = req.http.Normalized-User-Agent;\n\t\tset beresp.http.Detected-User-Agent = req.http.useragent_parser_family \"\/\" req.http.useragent_parser_major \".\" req.http.useragent_parser_minor \".\" req.http.useragent_parser_patch;\n\t}\n}\n\nsub vcl_deliver {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_deliver;\n\t}\n\n\tset req.http.Fastly-Force-Shield = \"yes\";\n\n\t# Allow cross origin GET, HEAD, and OPTIONS requests to be made.\n\tif (req.http.Origin) {\n\t\tset resp.http.Access-Control-Allow-Origin = \"*\";\n\t\tset resp.http.Access-Control-Allow-Methods = \"GET,HEAD,OPTIONS\";\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\" && !resp.http.Request_Came_From_Shield && req.backend != ssl_shield_iad_va_us && req.backend != ssl_shield_london_city_uk) {\n\t\t# Need to add \"Vary: User-Agent\" in after vcl_fetch to avoid the \n\t\t# \"Vary: User-Agent\" entering the Varnish cache.\n\t\t# We need \"Vary: User-Agent\" in the browser cache because a browser\n\t\t# may update itself to a version which needs different polyfills\n\t\t# So we need to have it ignore the browser cached bundle when the user-agent changes.\n\t\tadd resp.http.Vary = \"User-Agent\";\n\t\tadd resp.http.Vary = \"Accept-Encoding\";\n\t}\n\n\tadd resp.http.Server-Timing = fastly_info.state {\", fastly;desc=\"Edge time\";dur=\"} time.elapsed.msec;\n\n\tif (req.http.Fastly-Debug) {\n\t\tset resp.http.Debug-Backend = req.http.Debug-Backend;\n\t\tset resp.http.Debug-Host = req.http.Host;\n\t\tset resp.http.Debug-Fastly-Restarts = req.restarts;\n\t\tset resp.http.Debug-Orig-URL = req.http.Orig-URL;\n\t\tset resp.http.Debug-VCL-Route = req.http.X-VCL-Route;\n\t\tset resp.http.useragent_parser_family = req.http.useragent_parser_family;\n\t\tset resp.http.useragent_parser_major = req.http.useragent_parser_major;\n\t\tset resp.http.useragent_parser_minor = req.http.useragent_parser_minor;\n\t\tset resp.http.useragent_parser_patch = req.http.useragent_parser_patch;\n\t} else {\n\t\tunset resp.http.Server;\n\t\tunset resp.http.Via;\n\t\tunset resp.http.X-Cache;\n\t\tunset resp.http.X-Cache-Hits;\n\t\tunset resp.http.X-Served-By;\n\t\tunset resp.http.X-Timer;\n\t\tunset resp.http.Fastly-Restarts;\n\t\tunset resp.http.X-PreFetch-Pass;\n\t\tunset resp.http.X-PreFetch-Miss;\n\t\tunset resp.http.X-PostFetch;\n\t}\n}\n\nsub vcl_error {\n\tif (obj.status == 911) {\n\t\tset obj.status = 405;\n\t\tset obj.response = \"METHOD NOT ALLOWED\";\n\t\tset obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n\t\tset obj.http.Cache-Control = \"private, no-store\";\n\t\tsynthetic req.method \" METHOD NOT ALLOWED\";\n\t\treturn (deliver);\n\t}\n\tif (obj.status == 912) {\n\t\tset obj.status = 200;\n\t\tset obj.response = \"OK\";\n\t\tset obj.http.Allow = \"OPTIONS, GET, HEAD\";\n\t\treturn (deliver);\n\t}\n}\n","old_contents":"sub set_backend {\n\t# The Fastly macro is inserted before the backend is selected because the\n\t# macro has the code which defines the values avaiable for req.http.Host\n\t# but it also contains a default backend which is always set to the EU. I wish we could disable the default backend setting.\n\t#FASTLY recv\n\t\n\t# Calculate the ideal region to route the request to.\n \tdeclare local var.region STRING; \n\tif (server.region ~ \"(APAC|Asia|North-America|South-America|US-Central|US-East|US-West)\") {\n\t\tset var.region = \"US\";\n \t} else {\n\t\tset var.region = \"EU\";\n \t}\n\n\t# Gather the health of the shields and origins.\n\tdeclare local var.v3_eu_is_healthy BOOL;\n\tset req.backend = F_v3_eu;\n\tset var.v3_eu_is_healthy = req.backend.healthy;\n\n\tdeclare local var.v3_us_is_healthy BOOL;\n \tset req.backend = F_v3_us;\n \tset var.v3_us_is_healthy = req.backend.healthy;\n\n \tdeclare local var.shield_eu_is_healthy BOOL;\n \tset req.backend = ssl_shield_london_city_uk;\n \tset var.shield_eu_is_healthy = req.backend.healthy;\n\n \tdeclare local var.shield_us_is_healthy BOOL;\n \tset req.backend = ssl_shield_iad_va_us;\n \tset var.shield_us_is_healthy = req.backend.healthy;\n\n \t# Set some sort of default, that shouldn't get used.\n \tset req.backend = F_v3_eu;\n\n\tdeclare local var.EU_shield_server_name STRING;\n\tset var.EU_shield_server_name = \"LCY\";\n\n\tdeclare local var.US_shield_server_name STRING;\n\tset var.US_shield_server_name = \"IAD\";\n\n\t# Route EU requests to the nearest healthy shield or origin.\n \tif (var.region == \"EU\") {\n\t\tif (server.datacenter != var.EU_shield_server_name && req.http.Request_Came_From_Shield != var.EU_shield_server_name && var.shield_eu_is_healthy) {\n\t\t\tset req.backend = ssl_shield_london_city_uk;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t\tset req.http.Host = req.http.EU_Host;\n\t\t} elseif (var.shield_us_is_healthy) {\n\t\t\tset req.backend = ssl_shield_iad_va_us;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t\tset req.http.Host = req.http.US_Host;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_eu;\n\t\t}\n \t}\n\n\t# Route US requests to the nearest healthy shield or origin.\n \tif (var.region == \"US\") {\n\t\tif (server.datacenter != var.US_shield_server_name && req.http.Request_Came_From_Shield != var.US_shield_server_name && var.shield_us_is_healthy) {\n\t\t\tset req.backend = ssl_shield_iad_va_us;\n\t\t} elseif (var.v3_us_is_healthy) {\n\t\t\tset req.backend = F_v3_us;\n\t\t\tset req.http.Host = req.http.US_Host;\n\t\t} elseif (var.shield_eu_is_healthy) {\n\t\t\tset req.backend = ssl_shield_london_city_uk;\n\t\t} elseif (var.v3_eu_is_healthy) {\n\t\t\tset req.backend = F_v3_eu;\n\t\t\tset req.http.Host = req.http.EU_Host;\n\t\t} else {\n\t\t\t# Everything is on fire... but lets try the origin anyway just in case\n\t\t\t# it's the probes that are wrong\n\t\t\t# set req.backend = F_origin_last_ditch_us;\n\t\t}\n\t}\n\n\t# Persist the decision so we can debug the result.\n \tset req.http.Debug-Backend = req.backend;\n}\n\nsub vcl_recv {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_recv;\n\t}\n\n\tif (req.method != \"GET\" && req.method != \"HEAD\" && req.method != \"OPTIONS\" && req.method != \"FASTLYPURGE\" && req.method != \"PURGE\") {\n\t\terror 911;\n\t}\n\n\tif (req.method == \"OPTIONS\") {\n\t\terror 912;\n\t}\n\n\t# Because the old service had a router which allowed any words between \/v2\/polyfill. and .js\n\tif (req.url.path ~ \"^\/v2\/polyfill(\\.\\w+)(\\.\\w+)?\" && req.url.ext == \"js\") {\n\t\tif (re.group.2) {\n\t\t\tset req.url = \"\/v2\/polyfill.min.js?\" req.url.qs;\n\t\t} else {\n\t\t\tset req.url = \"\/v2\/polyfill.js?\" req.url.qs;\n\t\t}\n\t}\n\n\t# Override the v3 defaults with the defaults of v2\n\tif (req.url ~ \"^\/v2\/polyfill(\\.min)?\\.js\") {\n\t\tset req.url = regsub(req.url, \"^\/v2\", \"\/v3\");\n\t\tset req.url = querystring.set(req.url, \"version\", \"3.25.1\");\n\t\tdeclare local var.unknown STRING;\n\t\tset var.unknown = subfield(req.url.qs, \"unknown\", \"&\");\n\t\tset req.url = querystring.set(req.url, \"unknown\", if(var.unknown != \"\", var.unknown, \"ignore\"));\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\") {\n\t\tcall normalise_querystring_parameters_for_polyfill_bundle;\n\t\t# Sort the querystring parameters alphabetically to improve chances of hitting a cached copy.\n\t\t# If querystring is empty, remove the ? from the url.\n\t\tset req.url = querystring.clean(querystring.sort(req.url));\n\t\tcall set_backend;\n\t} else {\n\t\t# The request is to an endpoint which doesn't use query parameters, let's remove them to increase our cache-hit-ratio\n\t\tset req.url = querystring.remove(req.url);\n\t\tcall set_backend;\n\t}\n}\n\nsub vcl_hash {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_hash;\n\t}\n\n\t# We are not adding req.http.host to the hash because we want https:\/\/cdn.polyfill.io and https:\/\/polyfill.io to be a single object in the cache.\n\t# set req.hash += req.http.host;\n\tset req.hash += req.url;\n\t# We include return(hash) to stop the function falling through to the default VCL built into varnish, which for vcl_hash will add req.url and req.http.Host to the hash.\n\treturn(hash);\n}\n\n\nsub shielding_header {\n\tif (req.backend == ssl_shield_iad_va_us) {\n\t\tset req.http.Request_Came_From_Shield = server.datacenter;\n\t} elsif (req.backend == ssl_shield_london_city_uk) {\n\t\tset req.http.Request_Came_From_Shield = server.datacenter;\n\t}\n}\n\nsub vcl_miss {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_miss;\n\t}\n\tcall shielding_header;\n}\n\nsub vcl_pass {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_pass;\n\t}\n\tcall shielding_header;\n}\n\nsub vcl_fetch {\n\tset beresp.http.Request_Came_From_Shield = req.http.Request_Came_From_Shield;\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_fetch;\n\t}\n\n\t# These header are only required for HTML documents.\n\tif (beresp.http.Content-Type ~ \"text\/html\") {\n\t\t# Enables the cross-site scripting filter built into most modern web browsers.\n\t\tset beresp.http.X-XSS-Protection = \"1; mode=block\";\t\n\t}\n\t# Prevents MIME-sniffing a response away from the declared content type.\n\tset beresp.http.X-Content-Type-Options = \"nosniff\";\n\n\t# Ensure the site is only served over HTTPS and reduce the chances of someone performing a MITM attack.\n\tset beresp.http.Strict-Transport-Security = \"max-age=31536000; includeSubdomains; preload\";\n\n\t# The Referrer-Policy header governs which referrer information, sent in the Referer header, should be included with requests made.\n\t# Send a full URL when performing a same-origin request, but only send the origin of the document for other cases.\n\tset beresp.http.Referrer-Policy = \"origin-when-cross-origin\";\n\n\t# Enable purging of all objects in the Fastly cache by issuing a purge with the key \"polyfill-service\".\n\tif (beresp.http.Surrogate-Key !~ \"\\bpolyfill-service\\b\") {\n\t\tset beresp.http.Surrogate-Key = if(beresp.http.Surrogate-Key, beresp.http.Surrogate-Key \" polyfill-service\", \"polyfill-service\");\n\t}\n\n\tset beresp.http.Timing-Allow-Origin = \"*\";\n\n\tif (req.http.Normalized-User-Agent) {\n\t\tset beresp.http.Normalized-User-Agent = req.http.Normalized-User-Agent;\n\t\tset beresp.http.Detected-User-Agent = req.http.useragent_parser_family \"\/\" req.http.useragent_parser_major \".\" req.http.useragent_parser_minor \".\" req.http.useragent_parser_patch;\n\t}\n}\n\nsub vcl_deliver {\n\tif (req.http.Fastly-Debug) {\n\t\tcall breadcrumb_deliver;\n\t}\n\n\tset req.http.Fastly-Force-Shield = \"yes\";\n\n\t# Allow cross origin GET, HEAD, and OPTIONS requests to be made.\n\tif (req.http.Origin) {\n\t\tset resp.http.Access-Control-Allow-Origin = \"*\";\n\t\tset resp.http.Access-Control-Allow-Methods = \"GET,HEAD,OPTIONS\";\n\t}\n\n\tif (req.url ~ \"^\/v3\/polyfill(\\.min)?\\.js\" && !resp.http.Request_Came_From_Shield && req.backend != ssl_shield_iad_va_us && req.backend != ssl_shield_london_city_uk) {\n\t\t# Need to add \"Vary: User-Agent\" in after vcl_fetch to avoid the \n\t\t# \"Vary: User-Agent\" entering the Varnish cache.\n\t\t# We need \"Vary: User-Agent\" in the browser cache because a browser\n\t\t# may update itself to a version which needs different polyfills\n\t\t# So we need to have it ignore the browser cached bundle when the user-agent changes.\n\t\tadd resp.http.Vary = \"User-Agent\";\n\t\tadd resp.http.Vary = \"Accept-Encoding\";\n\t}\n\n\tadd resp.http.Server-Timing = fastly_info.state {\", fastly;desc=\"Edge time\";dur=\"} time.elapsed.msec;\n\n\tif (req.http.Fastly-Debug) {\n\t\tset resp.http.Debug-Backend = req.http.Debug-Backend;\n\t\tset resp.http.Debug-Host = req.http.Host;\n\t\tset resp.http.Debug-Fastly-Restarts = req.restarts;\n\t\tset resp.http.Debug-Orig-URL = req.http.Orig-URL;\n\t\tset resp.http.Debug-VCL-Route = req.http.X-VCL-Route;\n\t\tset resp.http.useragent_parser_family = req.http.useragent_parser_family;\n\t\tset resp.http.useragent_parser_major = req.http.useragent_parser_major;\n\t\tset resp.http.useragent_parser_minor = req.http.useragent_parser_minor;\n\t\tset resp.http.useragent_parser_patch = req.http.useragent_parser_patch;\n\t} else {\n\t\tunset resp.http.Server;\n\t\tunset resp.http.Via;\n\t\tunset resp.http.X-Cache;\n\t\tunset resp.http.X-Cache-Hits;\n\t\tunset resp.http.X-Served-By;\n\t\tunset resp.http.X-Timer;\n\t\tunset resp.http.Fastly-Restarts;\n\t}\n}\n\nsub vcl_error {\n\tif (obj.status == 911) {\n\t\tset obj.status = 405;\n\t\tset obj.response = \"METHOD NOT ALLOWED\";\n\t\tset obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n\t\tset obj.http.Cache-Control = \"private, no-store\";\n\t\tsynthetic req.method \" METHOD NOT ALLOWED\";\n\t\treturn (deliver);\n\t}\n\tif (obj.status == 912) {\n\t\tset obj.status = 200;\n\t\tset obj.response = \"OK\";\n\t\tset obj.http.Allow = \"OPTIONS, GET, HEAD\";\n\t\treturn (deliver);\n\t}\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"c249724a2b56b9382361cb6f29e63f6f1c13995f","subject":"Disable http auth for GraphQL endpoint","message":"Disable http auth for GraphQL endpoint","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets_basic_auth\/recv.vcl","new_file":"etc\/vcl_snippets_basic_auth\/recv.vcl","new_contents":" # Check Basic auth against a table. \/admin URLs are not basic auth protected to avoid the possibility of people\n # locking themselves out. \/oauth and \/rest have their own auth so we can skip Basic Auth on them as well\n if ( table.lookup(magentomodule_basic_auth, regsub(req.http.Authorization, \"^Basic \", \"\"), \"NOTFOUND\") == \"NOTFOUND\" &&\n !req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" &&\n !req.url ~ \"^\/(index\\.php\/)?(rest|oauth|graphql)\/\" &&\n !req.url ~ \"^\/pub\/static\/\" ) {\n error 771;\n }\n","old_contents":" # Check Basic auth against a table. \/admin URLs are not basic auth protected to avoid the possibility of people\n # locking themselves out. \/oauth and \/rest have their own auth so we can skip Basic Auth on them as well\n if ( table.lookup(magentomodule_basic_auth, regsub(req.http.Authorization, \"^Basic \", \"\"), \"NOTFOUND\") == \"NOTFOUND\" &&\n !req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" &&\n !req.url ~ \"^\/(index\\.php\/)?(rest|oauth)\/\" &&\n !req.url ~ \"^\/pub\/static\/\" ) {\n error 771;\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"dfea49b0194dadf24480c83a7e6e5275684769fa","subject":"Add polyfill-library 3.48","message":"Add polyfill-library 3.48","repos":"JakeChampion\/polyfill-service,JakeChampion\/polyfill-service","old_file":"fastly\/vcl\/main.vcl","new_file":"fastly\/vcl\/main.vcl","new_contents":"import querystring;\n\nsub sort_comma_separated_value {\n\t# This function takes a CSV and tranforms it into a url where each\n\t# comma-separated-value is a query-string parameter and then uses\n\t# Fastly's querystring.sort function to sort the values. Once sorted\n\t# it then turn the query-parameters back into a CSV.\n\t# Set the CSV on the header `Sort-Value`.\n\t# Returns the sorted CSV on the header `Sorted-Value`.\n\tdeclare local var.value STRING;\n\tset var.value = req.http.Sort-value;\n\n\t# If query value does not exist or is empty, set it to \"\"\n\tset var.value = if(var.value != \"\", var.value, \"\");\n\n\t# Replace all `&` characters with `^`, this is because `&` would break the value up into pieces.\n\tset var.value = regsuball(var.value, \"&\", \"^\");\n\n\t# Replace all `,` characters with `&` to break them into individual query values\n\t# Append `1-` infront of all the query values to make them simpler to transform later\n\tset var.value = \"1-\" regsuball(var.value, \",\", \"&1-\");\n\n\t# Create a querystring-like string in order for querystring.sort to work.\n\tset var.value = querystring.sort(\"?\" var.value);\n\n\t# Grab all the query values from the sorted url\n\tset var.value = regsub(var.value, \"\\?\", \"\");\n\n\t# Reverse all the previous transformations to get back the single `features` query value value\n\tset var.value = regsuball(var.value, \"1-\", \"\");\n\tset var.value = regsuball(var.value, \"&\", \",\");\n\tset var.value = regsuball(var.value, \"\\^\", \"&\");\n\n\tset req.http.Sorted-Value = var.value;\n}\n\nsub normalise_querystring_parameters_for_polyfill_bundle {\n\t# Store the url without the querystring into a temporary header.\n\tdeclare local var.url STRING;\n\tset var.url = querystring.remove(req.url);\n\n\tdeclare local var.querystring STRING;\n\tset var.querystring = \"?\";\n\n\t# Remove all querystring parameters which are not part of the public API.\n\t# set req.url = querystring.regfilter_except(req.url, \"^(features|excludes|rum|unknown|flags|version|ua|callback|compression)$\");\n\n\t# (?i) makes the regex case-insensitive\n\t# The regex will match only if their are characters after `features=` which are not an ampersand (&).\n\tif (req.url.qs ~ \"(?i)[^&=]*features=([^&]+)\") {\n\t\t# Parameter has already been set, use the already set value.\n\t\t# re.group.1 is the first regex capture group in the regex above.\n\t\tif (std.strlen(re.group.1) < 100) {\n\t\t\t# We add the value of the features parameter to this header\n\t\t\t# This is to be able to have sort_comma_separated_value sort the value\n\t\t\tset req.http.Sort-Value = urldecode(re.group.1);\n\t\t\tcall sort_comma_separated_value;\n\t\t\t# The header Sorted-Value now contains the sorted version of the features parameter.\n\t\t\tset var.querystring = querystring.set(var.querystring, \"features\", req.http.Sorted-Value);\n\t\t} else {\n\t\t\tset var.querystring = querystring.set(var.querystring, \"features\", urldecode(re.group.1));\n\t\t}\n\t} else {\n\t\t# Parameter has not been set, use the default value.\n\t\tset var.querystring = querystring.set(var.querystring, \"features\", \"default\");\n\t}\n\n\t# (?i) makes the regex case-insensitive\n\t# The regex will match only if their are characters after `excludes=` which are not an ampersand (&).\n\tif (req.url.qs ~ \"(?i)[^&=]*excludes=([^&]+)\") {\n\t\t# Parameter has already been set, use the already set value.\n\t\t# re.group.1 is the first regex capture group in the regex above.\n\t\tif (std.strlen(re.group.1) < 100) {\n\t\t\t# We add the value of the excludes parameter to this header\n\t\t\t# This is to be able to have sort_comma_separated_value sort the value\n\t\t\tset req.http.Sort-Value = urldecode(re.group.1);\n\t\t\tcall sort_comma_separated_value;\n\t\t\t# The header Sorted-Value now contains the sorted version of the excludes parameter.\n\t\t\tset var.querystring = querystring.set(var.querystring, \"excludes\", req.http.Sorted-Value);\n\t\t} else {\n\t\t\tset var.querystring = querystring.set(var.querystring, \"excludes\", urldecode(re.group.1));\n\t\t}\n\t} else {\n\t\t# If excludes is not set, set to default value \"\"\n\t\tset var.querystring = var.querystring \"&excludes=\";\n\t}\n\n\t# If rum is not set, set to default value \"0\"\n\tif (req.url.qs !~ \"(?i)[^&=]*rum=([^&]+)\") {\n\t\tset var.querystring = querystring.set(var.querystring, \"rum\", \"0\");\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"rum\", re.group.1);\n\t}\n\n\t# If unknown is not set, set to default value \"polyfill\"\n\tif (req.url.qs !~ \"(?i)[^&=]*unknown=([^&]+)\") {\n\t\tset var.querystring = querystring.set(var.querystring, \"unknown\", \"polyfill\");\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"unknown\", re.group.1);\n\t}\n\n\t# If flags is not set, set to default value \"\"\n\tif (req.url.qs !~ \"(?i)[^&=]*flags=([^&]+)\") {\n\t\tset var.querystring = var.querystring \"&flags=\";\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"flags\", urldecode(re.group.1));\n\t}\n\n\t# If version is not set, set to default value \"\"\n\tdeclare local var.version STRING;\n\tif (req.url.qs !~ \"(?i)[^&=]*version=([^&]+)\") {\n\t\tset var.querystring = var.querystring \"&version=\";\n\t} else {\n\t\tif (re.group.1 == \"3.48.0\" || re.group.1 == \"3.46.0\" || re.group.1 == \"3.45.0\" || re.group.1 == \"3.44.0\" || re.group.1 == \"3.43.0\" || re.group.1 == \"3.42.0\" || re.group.1 == \"3.41.0\" || re.group.1 == \"3.40.0\" || re.group.1 == \"3.39.0\" || re.group.1 == \"3.38.0\" || re.group.1 == \"3.37.0\" || re.group.1 == \"3.36.0\" || re.group.1 == \"3.35.0\" || re.group.1 == \"3.34.0\" || re.group.1 == \"3.28.1\" || re.group.1 == \"3.27.4\" || re.group.1 == \"3.25.3\" || re.group.1 == \"3.25.2\" || re.group.1 == \"3.25.1\") {\n\t\t\tset var.querystring = querystring.set(var.querystring, \"version\", re.group.1);\n\t\t} else {\n\t\t\tset var.querystring = var.querystring \"&version=\";\n\t\t}\n\t}\n\n\t# If ua is not set, normalise the User-Agent header based upon the version of the polyfill-library that has been requested.\n\tif (req.url.qs !~ \"(?i)[^&=]*ua=([^&]+)\") {\n\t\tif (req.url.qs ~ \"(?i)[^&=]*version=3\\.25\\.1(&|$)\") {\n\t\t\tcall normalise_user_agent_3_25_1;\n\t\t} else {\n\t\t\tcall normalise_user_agent_1_5_0;\n\t\t}\n\t\tset var.querystring = querystring.set(var.querystring, \"ua\", req.http.Normalized-User-Agent);\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"ua\", urldecode(re.group.1));\n\t}\n\n\t# If callback is not set, set to default value \"\"\n\tif (req.url.qs !~ \"(?i)[^&=]*callback=([^&]+)\") {\n\t\tset var.querystring = var.querystring \"&callback=\";\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"callback\", re.group.1);\n\t}\n\n\t# If compression is not set, use the best compression that the user-agent supports.\n\tif (req.url.qs !~ \"(?i)[^&=]*compression=([^&]+)\") {\n\t\t# When Fastly adds Brotli into the Accept-Encoding normalisation we can replace this with:\n\t\t# `set var.querystring = querystring.set(var.querystring, \"compression\", req.http.Accept-Encoding || \"\")`\n\n\t\t# Before SP2, IE\/6 doesn't always read and cache gzipped content correctly.\n\t\tif (req.http.Fastly-Orig-Accept-Encoding && req.http.User-Agent !~ \"MSIE 6\") {\n\t\t\tif (req.http.Fastly-Orig-Accept-Encoding ~ \"br\") {\n\t\t\t\tset var.querystring = querystring.set(var.querystring, \"compression\", \"br\");\n\t\t\t} elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"gzip\") {\n\t\t\t\tset var.querystring = querystring.set(var.querystring, \"compression\", \"gzip\");\n\t\t\t} else {\n\t\t\t\tset var.querystring = var.querystring \"&compression=\";\n\t\t\t}\n\t\t} else {\n\t\t\tset var.querystring = var.querystring \"&compression=\";\n\t\t}\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"compression\", re.group.1);\n\t}\n\tset req.url = var.url var.querystring;\n}\n\ninclude \"top_pops.vcl\";\ninclude \"normalise-user-agent-3-25-1.vcl\";\ninclude \"normalise-user-agent.vcl\";\n\n# The Fastly VCL boilerplate.\ninclude \"fastly-boilerplate-begin.vcl\";\n\ninclude \"breadcrumbs.vcl\";\ninclude \"redirects.vcl\";\ninclude \"synthetic-responses.vcl\";\ninclude \"polyfill-service.vcl\";\n\n# Finally include the last bit of VCL, this _must_ be last!\ninclude \"fastly-boilerplate-end.vcl\";\n","old_contents":"import querystring;\n\nsub sort_comma_separated_value {\n\t# This function takes a CSV and tranforms it into a url where each\n\t# comma-separated-value is a query-string parameter and then uses\n\t# Fastly's querystring.sort function to sort the values. Once sorted\n\t# it then turn the query-parameters back into a CSV.\n\t# Set the CSV on the header `Sort-Value`.\n\t# Returns the sorted CSV on the header `Sorted-Value`.\n\tdeclare local var.value STRING;\n\tset var.value = req.http.Sort-value;\n\n\t# If query value does not exist or is empty, set it to \"\"\n\tset var.value = if(var.value != \"\", var.value, \"\");\n\n\t# Replace all `&` characters with `^`, this is because `&` would break the value up into pieces.\n\tset var.value = regsuball(var.value, \"&\", \"^\");\n\n\t# Replace all `,` characters with `&` to break them into individual query values\n\t# Append `1-` infront of all the query values to make them simpler to transform later\n\tset var.value = \"1-\" regsuball(var.value, \",\", \"&1-\");\n\n\t# Create a querystring-like string in order for querystring.sort to work.\n\tset var.value = querystring.sort(\"?\" var.value);\n\n\t# Grab all the query values from the sorted url\n\tset var.value = regsub(var.value, \"\\?\", \"\");\n\n\t# Reverse all the previous transformations to get back the single `features` query value value\n\tset var.value = regsuball(var.value, \"1-\", \"\");\n\tset var.value = regsuball(var.value, \"&\", \",\");\n\tset var.value = regsuball(var.value, \"\\^\", \"&\");\n\n\tset req.http.Sorted-Value = var.value;\n}\n\nsub normalise_querystring_parameters_for_polyfill_bundle {\n\t# Store the url without the querystring into a temporary header.\n\tdeclare local var.url STRING;\n\tset var.url = querystring.remove(req.url);\n\n\tdeclare local var.querystring STRING;\n\tset var.querystring = \"?\";\n\n\t# Remove all querystring parameters which are not part of the public API.\n\t# set req.url = querystring.regfilter_except(req.url, \"^(features|excludes|rum|unknown|flags|version|ua|callback|compression)$\");\n\n\t# (?i) makes the regex case-insensitive\n\t# The regex will match only if their are characters after `features=` which are not an ampersand (&).\n\tif (req.url.qs ~ \"(?i)[^&=]*features=([^&]+)\") {\n\t\t# Parameter has already been set, use the already set value.\n\t\t# re.group.1 is the first regex capture group in the regex above.\n\t\tif (std.strlen(re.group.1) < 100) {\n\t\t\t# We add the value of the features parameter to this header\n\t\t\t# This is to be able to have sort_comma_separated_value sort the value\n\t\t\tset req.http.Sort-Value = urldecode(re.group.1);\n\t\t\tcall sort_comma_separated_value;\n\t\t\t# The header Sorted-Value now contains the sorted version of the features parameter.\n\t\t\tset var.querystring = querystring.set(var.querystring, \"features\", req.http.Sorted-Value);\n\t\t} else {\n\t\t\tset var.querystring = querystring.set(var.querystring, \"features\", urldecode(re.group.1));\n\t\t}\n\t} else {\n\t\t# Parameter has not been set, use the default value.\n\t\tset var.querystring = querystring.set(var.querystring, \"features\", \"default\");\n\t}\n\n\t# (?i) makes the regex case-insensitive\n\t# The regex will match only if their are characters after `excludes=` which are not an ampersand (&).\n\tif (req.url.qs ~ \"(?i)[^&=]*excludes=([^&]+)\") {\n\t\t# Parameter has already been set, use the already set value.\n\t\t# re.group.1 is the first regex capture group in the regex above.\n\t\tif (std.strlen(re.group.1) < 100) {\n\t\t\t# We add the value of the excludes parameter to this header\n\t\t\t# This is to be able to have sort_comma_separated_value sort the value\n\t\t\tset req.http.Sort-Value = urldecode(re.group.1);\n\t\t\tcall sort_comma_separated_value;\n\t\t\t# The header Sorted-Value now contains the sorted version of the excludes parameter.\n\t\t\tset var.querystring = querystring.set(var.querystring, \"excludes\", req.http.Sorted-Value);\n\t\t} else {\n\t\t\tset var.querystring = querystring.set(var.querystring, \"excludes\", urldecode(re.group.1));\n\t\t}\n\t} else {\n\t\t# If excludes is not set, set to default value \"\"\n\t\tset var.querystring = var.querystring \"&excludes=\";\n\t}\n\n\t# If rum is not set, set to default value \"0\"\n\tif (req.url.qs !~ \"(?i)[^&=]*rum=([^&]+)\") {\n\t\tset var.querystring = querystring.set(var.querystring, \"rum\", \"0\");\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"rum\", re.group.1);\n\t}\n\n\t# If unknown is not set, set to default value \"polyfill\"\n\tif (req.url.qs !~ \"(?i)[^&=]*unknown=([^&]+)\") {\n\t\tset var.querystring = querystring.set(var.querystring, \"unknown\", \"polyfill\");\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"unknown\", re.group.1);\n\t}\n\n\t# If flags is not set, set to default value \"\"\n\tif (req.url.qs !~ \"(?i)[^&=]*flags=([^&]+)\") {\n\t\tset var.querystring = var.querystring \"&flags=\";\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"flags\", urldecode(re.group.1));\n\t}\n\n\t# If version is not set, set to default value \"\"\n\tdeclare local var.version STRING;\n\tif (req.url.qs !~ \"(?i)[^&=]*version=([^&]+)\") {\n\t\tset var.querystring = var.querystring \"&version=\";\n\t} else {\n\t\tif (re.group.1 == \"3.46.0\" || re.group.1 == \"3.45.0\" || re.group.1 == \"3.44.0\" || re.group.1 == \"3.43.0\" || re.group.1 == \"3.42.0\" || re.group.1 == \"3.41.0\" || re.group.1 == \"3.40.0\" || re.group.1 == \"3.39.0\" || re.group.1 == \"3.38.0\" || re.group.1 == \"3.37.0\" || re.group.1 == \"3.36.0\" || re.group.1 == \"3.35.0\" || re.group.1 == \"3.34.0\" || re.group.1 == \"3.28.1\" || re.group.1 == \"3.27.4\" || re.group.1 == \"3.25.3\" || re.group.1 == \"3.25.2\" || re.group.1 == \"3.25.1\") {\n\t\t\tset var.querystring = querystring.set(var.querystring, \"version\", re.group.1);\n\t\t} else {\n\t\t\tset var.querystring = var.querystring \"&version=\";\n\t\t}\n\t}\n\n\t# If ua is not set, normalise the User-Agent header based upon the version of the polyfill-library that has been requested.\n\tif (req.url.qs !~ \"(?i)[^&=]*ua=([^&]+)\") {\n\t\tif (req.url.qs ~ \"(?i)[^&=]*version=3\\.25\\.1(&|$)\") {\n\t\t\tcall normalise_user_agent_3_25_1;\n\t\t} else {\n\t\t\tcall normalise_user_agent_1_5_0;\n\t\t}\n\t\tset var.querystring = querystring.set(var.querystring, \"ua\", req.http.Normalized-User-Agent);\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"ua\", urldecode(re.group.1));\n\t}\n\n\t# If callback is not set, set to default value \"\"\n\tif (req.url.qs !~ \"(?i)[^&=]*callback=([^&]+)\") {\n\t\tset var.querystring = var.querystring \"&callback=\";\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"callback\", re.group.1);\n\t}\n\n\t# If compression is not set, use the best compression that the user-agent supports.\n\tif (req.url.qs !~ \"(?i)[^&=]*compression=([^&]+)\") {\n\t\t# When Fastly adds Brotli into the Accept-Encoding normalisation we can replace this with:\n\t\t# `set var.querystring = querystring.set(var.querystring, \"compression\", req.http.Accept-Encoding || \"\")`\n\n\t\t# Before SP2, IE\/6 doesn't always read and cache gzipped content correctly.\n\t\tif (req.http.Fastly-Orig-Accept-Encoding && req.http.User-Agent !~ \"MSIE 6\") {\n\t\t\tif (req.http.Fastly-Orig-Accept-Encoding ~ \"br\") {\n\t\t\t\tset var.querystring = querystring.set(var.querystring, \"compression\", \"br\");\n\t\t\t} elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"gzip\") {\n\t\t\t\tset var.querystring = querystring.set(var.querystring, \"compression\", \"gzip\");\n\t\t\t} else {\n\t\t\t\tset var.querystring = var.querystring \"&compression=\";\n\t\t\t}\n\t\t} else {\n\t\t\tset var.querystring = var.querystring \"&compression=\";\n\t\t}\n\t} else {\n\t\tset var.querystring = querystring.set(var.querystring, \"compression\", re.group.1);\n\t}\n\tset req.url = var.url var.querystring;\n}\n\ninclude \"top_pops.vcl\";\ninclude \"normalise-user-agent-3-25-1.vcl\";\ninclude \"normalise-user-agent.vcl\";\n\n# The Fastly VCL boilerplate.\ninclude \"fastly-boilerplate-begin.vcl\";\n\ninclude \"breadcrumbs.vcl\";\ninclude \"redirects.vcl\";\ninclude \"synthetic-responses.vcl\";\ninclude \"polyfill-service.vcl\";\n\n# Finally include the last bit of VCL, this _must_ be last!\ninclude \"fastly-boilerplate-end.vcl\";\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"1751f15be31601904eab3e0ce65af05c396ac034","subject":"add a dynamic.director.","message":"add a dynamic.director.\n","repos":"amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon","old_file":"images\/varnish-drupal\/drupal.vcl","new_file":"images\/varnish-drupal\/drupal.vcl","new_contents":"vcl 4.0;\n\nimport std;\n\n# set backend default\nbackend default {\n .host = \"${VARNISH_BACKEND_HOST:-nginx}\";\n .port = \"${VARNISH_BACKEND_PORT:-8080}\";\n .first_byte_timeout = 35m;\n .between_bytes_timeout = 10m;\n}\n\n# Allow purging from localhost\n# @TODO allow from openshift network\nacl purge {\n \"127.0.0.1\";\n \"10.0.0.0\"\/8;\n \"172.16.0.0\"\/12;\n \"192.168.0.0\"\/16;\n}\n\nsub vcl_init {\n new www_dir = dynamic.director(\n port = \"${VARNISH_BACKEND_PORT:-8080}\",\n probe = www_probe,\n whitelist = purge,\n ttl = 60s);\n }\n\n\n# This configuration is optimized for Drupal hosting:\n# Respond to incoming requests.\nsub vcl_recv {\n set req.backend_hint = www_dir.backend(\"${VARNISH_BACKEND_HOST:-nginx}\");\n\n if (req.url ~ \"^\/varnish_status$\") {\n return (synth(200,\"OK\"));\n }\n # set the backend, which should be used:\n set req.backend_hint = default;\n\n # Always set the forward ip.\n if (req.restarts == 0) {\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n\n\n if (req.http.X-LAGOON-VARNISH ) {\n ## Pass all Requests which are handled via an upstream Varnish\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, \" + req.http.X-LAGOON-VARNISH;\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n } else if (req.http.Fastly-FF) {\n ## Pass all Requests which are handled via Fastly\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, fastly\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n set req.http.X-Forwarded-For = req.http.Fastly-Client-IP;\n } else if (req.http.CF-RAY) {\n ## Pass all Requests which are handled via CloudFlare\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, cloudflare\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n set req.http.X-Forwarded-For = req.http.CF-Connecting-IP;\n } else if (req.http.X-Pull) {\n ## Pass all Requests which are handled via KeyCDN\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, keycdn\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n } else {\n ## We set a header to let a Varnish Chain know that it already has been varnishcached\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}\";\n\n ## Allow to bypass based on env variable `VARNISH_BYPASS`\n set req.http.X-LAGOON-VARNISH-BYPASS = \"${VARNISH_BYPASS:-false}\";\n }\n\n # Websockets are piped\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n if (req.http.X-LAGOON-VARNISH-BYPASS == \"true\" || req.http.X-LAGOON-VARNISH-BYPASS == \"TRUE\") {\n return (pass);\n }\n\n # SA-CORE-2014-004 preventing access to \/xmlrpc.php\n if (req.url ~ \"^\/xmlrpc.php$\") {\n return (synth(701, \"Unauthorized\"));\n }\n\n # Strip out Google Analytics campaign variables. They are only needed\n # by the javascript running on the page\n # utm_source, utm_medium, utm_campaign, gclid\n if(req.url ~ \"(\\?|&)(gclid|utm_[a-z]+)=\") {\n set req.url = regsuball(req.url, \"(gclid|utm_[a-z]+)=[^\\&]+&?\", \"\");\n set req.url = regsub(req.url, \"(\\?|&)$\", \"\");\n }\n\n # Bypass a cache hit (the request is still sent to the backend)\n if (req.method == \"REFRESH\") {\n if (!client.ip ~ purge) { return (synth(405, \"Not allowed\")); }\n set req.method = \"GET\";\n set req.hash_always_miss = true;\n }\n\n # Only allow BAN requests from IP addresses in the 'purge' ACL.\n if (req.method == \"BAN\" || req.method == \"URIBAN\" || req.method == \"PURGE\") {\n # Only allow BAN from defined ACL\n if (!client.ip ~ purge) {\n return (synth(403, \"Your IP is not allowed.\"));\n }\n\n # Only allows BAN if the Host Header has the style of with \"${SERVICE_NAME:-varnish}:8080\" or \"${SERVICE_NAME:-varnish}\".\n # Such a request is only possible from within the Docker network, as a request from external goes trough the Kubernetes Router and for that needs a proper Host Header\n if (!req.http.host ~ \"^${SERVICE_NAME:-varnish}(:\\d+)?$\") {\n return (synth(403, \"Only allowed from within own network.\"));\n }\n\n if (req.method == \"BAN\") {\n # Logic for the ban, using the Cache-Tags header.\n if (req.http.Cache-Tags) {\n ban(\"obj.http.Cache-Tags ~ \" + req.http.Cache-Tags);\n # Throw a synthetic page so the request won't go to the backend.\n return (synth(200, \"Ban added.\"));\n }\n else {\n return (synth(403, \"Cache-Tags header missing.\"));\n }\n }\n\n if (req.method == \"URIBAN\" || req.method == \"PURGE\") {\n ban(\"req.url ~ \" + req.url);\n # Throw a synthetic page so the request won't go to the backend.\n return (synth(200, \"Ban added.\"));\n }\n\n }\n\n # Non-RFC2616 or CONNECT which is weird, we pipe that\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n return (pipe);\n }\n\n # We only try to cache GET and HEAD, other things are passed\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n # Any requests with Basic Auth are passed\n if (req.http.Authorization || req.http.Authenticate)\n {\n return (pass);\n }\n\n ## Pass requests which are from blackfire\n if (req.http.X-Blackfire-Query) {\n return (pass);\n }\n\n # Some URLs should never be cached\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/admin([\/?]|$).*$\" ||\n req.url ~ \"^\/info([\/?]|$).*$\" ||\n req.url ~ \"^\/flag([\/?]|$).*$\" ||\n req.url ~ \"^.*\/system\/files([\/?]|$).*$\" ||\n req.url ~ \"^\/cgi\" ||\n req.url ~ \"^\/cgi-bin\"\n ) {\n return (pass);\n }\n\n # Plupload likes to get piped\n if (req.url ~ \"^.*\/plupload-handle-uploads.*$\"\n ) {\n return (pipe);\n }\n\n # Handle compression correctly. Different browsers send different\n # \"Accept-Encoding\" headers, even though they mostly all support the same\n # compression mechanisms. By consolidating these compression headers into\n # a consistent format, we can reduce the size of the cache and get more hits.=\n # @see: http:\/\/ varnish.projects.linpro.no\/wiki\/FAQ\/Compression\n if (req.http.Accept-Encoding) {\n if (req.http.Accept-Encoding ~ \"gzip\") {\n # If the browser supports it, we'll use gzip.\n set req.http.Accept-Encoding = \"gzip\";\n }\n else if (req.http.Accept-Encoding ~ \"deflate\") {\n # Next, try deflate if it is supported.\n set req.http.Accept-Encoding = \"deflate\";\n }\n else {\n # Unknown algorithm. Remove it and send unencoded.\n unset req.http.Accept-Encoding;\n }\n }\n\n # Always cache the following file types for all users.\n if (req.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n unset req.http.Cookie;\n }\n\n # Remove all cookies that Drupal doesn't need to know about. ANY remaining\n # cookie will cause the request to pass-through to a backend. For the most part\n # we always set the NO_CACHE cookie after any POST request, disabling the\n # Varnish cache temporarily. The session cookie allows all authenticated users\n # to pass through as long as they're logged in.\n #\n # 1. Append a semi-colon to the front of the cookie string.\n # 2. Remove all spaces that appear after semi-colons.\n # 3. Match the cookies we want to keep, adding the space we removed\n # previously, back. (\\1) is first matching group in the regsuball.\n # 4. Remove all other cookies, identifying them by the fact that they have\n # no space after the preceding semi-colon.\n # 5. Remove all spaces and semi-colons from the beginning and end of the\n # cookie string.\n if (req.http.Cookie) {\n set req.http.CookieCheck = \";\" + req.http.Cookie;\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"; +\", \";\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";(${VARNISH_COOKIECHECK:-SESS[a-z0-9]+|SSESS[a-z0-9]+|NO_CACHE})=\", \"; \\1=\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";[^ ][^;]*\", \"\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"^[; ]+|[; ]+$\", \"\");\n\n set req.http.Cookie = req.http.Cookie + \";\";\n\n if (req.http.CookieCheck == \"\") {\n # If there are no remaining cookies, remove the cookie header. If there\n # aren't any cookie headers, Varnish's default behavior will be to cache\n # the page.\n\n unset req.http.CookieCheck;\n unset req.http.Cookie;\n }\n else {\n # If there is any cookies left (a session or NO_CACHE cookie), do not\n # cache the page. Pass it on to Apache directly.\n unset req.http.CookieCheck;\n return (pass);\n }\n }\n\n # Cacheable, lookup in cache.\n return (hash);\n}\n\nsub vcl_pipe {\n # Support for Websockets\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n set bereq.http.connection = req.http.connection;\n }\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n # normal hit\n return (deliver);\n }\n # We have no fresh fish. Lets look at the stale ones.\n if (std.healthy(req.backend_hint)) {\n # Backend is healthy. If the object is not older then 30secs, deliver it to the client\n # and automatically create a separate backend request to warm the cache for this request.\n if (obj.ttl + 30s > 0s) {\n set req.http.grace = \"normal(limited)\";\n return (deliver);\n } else {\n # No candidate for grace. Fetch a fresh object.\n return(miss);\n }\n } else {\n # backend is sick - use full grace\n if (obj.ttl + obj.grace > 0s) {\n set req.http.grace = \"full\";\n return (deliver);\n } else {\n # no graced object.\n return (miss);\n }\n }\n}\n\nsub vcl_backend_response {\n # Allow items to be stale if needed.\n set beresp.grace = 6h;\n\n # Set ban-lurker friendly custom headers.\n set beresp.http.X-Url = bereq.url;\n set beresp.http.X-Host = bereq.http.host;\n\n # If the backend sends a X-LAGOON-VARNISH-BACKEND-BYPASS header we directly deliver\n if(beresp.http.X-LAGOON-VARNISH-BACKEND-BYPASS == \"TRUE\") {\n return (deliver);\n }\n\n # Cache 404 and 403 for 10 seconds\n if(beresp.status == 404 || beresp.status == 403) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n # Don't allow static files to set cookies.\n if (bereq.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n # beresp == Back-end response from the web server.\n unset beresp.http.set-cookie;\n unset beresp.http.Cache-Control;\n\n # If an asset would come back with statuscode 500 we only cache it for 10 seconds instead of the usual static file cache\n if (beresp.status == 500) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n set beresp.ttl = ${VARNISH_ASSETS_TTL:-2628001}s;\n set beresp.http.Cache-Control = \"public, max-age=${VARNISH_ASSETS_TTL:-2628001}\";\n set beresp.http.Expires = \"\" + (now + beresp.ttl);\n }\n\n return (deliver);\n}\n\n# Set a header to track a cache HIT\/MISS.\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Varnish-Cache = \"HIT\";\n }\n else {\n set resp.http.X-Varnish-Cache = \"MISS\";\n }\n\n # Remove ban-lurker friendly custom headers when delivering to client.\n unset resp.http.X-Url;\n unset resp.http.X-Host;\n\n # unset Cache-Tags Header by default, can be disabled with VARNISH_UNSET_HEADER_CACHE_TAGS=true\n if (!${VARNISH_UNSET_HEADER_CACHE_TAGS:-false}) {\n unset resp.http.Cache-Tags;\n }\n\n unset resp.http.X-Generator;\n unset resp.http.Server;\n # Inject information about grace\n if (req.http.grace) {\n set resp.http.X-Varnish-Grace = req.http.grace;\n }\n set resp.http.X-LAGOON = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}>\" + resp.http.X-LAGOON;\n return (deliver);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n if (req.http.X-Forwarded-Proto) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n if (req.http.HTTPS) {\n hash_data(req.http.HTTPS);\n }\n return (lookup);\n}\n\nsub vcl_synth {\n if (resp.status == 701) {\n set resp.status = 401;\n set resp.http.Content-Type = \"text\/plain; charset=utf-8\";\n synthetic({\"XMLRPC Interface is blocked due to SA-CORE-2014-004 - mail support@amazee.io if you need it.\"});\n return (deliver);\n }\n if (resp.status == 700) {\n # Set a status the client will understand\n set resp.status = 200;\n # Create our synthetic response\n synthetic(\"\");\n return(deliver);\n}\n return (deliver);\n}\n\nsub vcl_backend_error {\n # Restart the request, when we have a backend server error, to try another backend.\n # Restart max twice.\n if (bereq.retries < 2) {\n return(retry);\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<head>\n <title>Server Error<\/title>\n <style type=\"text\/css\">\n body {\n font-family: helvetica, arial, sans-serif;\n }\n img {\n margin-top: 50px;\n }\n p {\n width: 6 00px;\n margin-top: 10px\n }\n div {\n background: #ccc;\n width: 600px;\n margin: auto;\n padding: 50px;\n }\n span {\n color: #ccc\n }\n <\/style>\n<\/head>\n<body>\n <div>\n <h1>We are sorry...<\/h1>\n <p>We encountered a server-side error. This means that the problem is not with your computer or Internet connection, but rather with the website's server.<\/p>\n <p>We are currently working on solving this problem and apologise for the inconvenience.<\/p>\n <span>\n <strong>Technical Information<\/strong><br \/>\n Error \"} + beresp.status + \" \" + beresp.reason + {\"<br \/>\n XID: \"} + bereq.xid + {\"<br \/>\n <\/span>\n <\/div>\n<\/body>\n<\/html>\n\n\"} );\n return (deliver);\n}\n","old_contents":"vcl 4.0;\n\nimport std;\n\n# set backend default\nbackend default {\n .host = \"${VARNISH_BACKEND_HOST:-nginx}\";\n .port = \"${VARNISH_BACKEND_PORT:-8080}\";\n .first_byte_timeout = 35m;\n .between_bytes_timeout = 10m;\n}\n\n# Allow purging from localhost\n# @TODO allow from openshift network\nacl purge {\n \"127.0.0.1\";\n \"10.0.0.0\"\/8;\n \"172.16.0.0\"\/12;\n \"192.168.0.0\"\/16;\n}\n\n# This configuration is optimized for Drupal hosting:\n# Respond to incoming requests.\nsub vcl_recv {\n if (req.url ~ \"^\/varnish_status$\") {\n return (synth(200,\"OK\"));\n }\n # set the backend, which should be used:\n set req.backend_hint = default;\n\n # Always set the forward ip.\n if (req.restarts == 0) {\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n\n\n if (req.http.X-LAGOON-VARNISH ) {\n ## Pass all Requests which are handled via an upstream Varnish\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, \" + req.http.X-LAGOON-VARNISH;\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n } else if (req.http.Fastly-FF) {\n ## Pass all Requests which are handled via Fastly\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, fastly\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n set req.http.X-Forwarded-For = req.http.Fastly-Client-IP;\n } else if (req.http.CF-RAY) {\n ## Pass all Requests which are handled via CloudFlare\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, cloudflare\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n set req.http.X-Forwarded-For = req.http.CF-Connecting-IP;\n } else if (req.http.X-Pull) {\n ## Pass all Requests which are handled via KeyCDN\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, keycdn\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n } else {\n ## We set a header to let a Varnish Chain know that it already has been varnishcached\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}\";\n\n ## Allow to bypass based on env variable `VARNISH_BYPASS`\n set req.http.X-LAGOON-VARNISH-BYPASS = \"${VARNISH_BYPASS:-false}\";\n }\n\n # Websockets are piped\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n if (req.http.X-LAGOON-VARNISH-BYPASS == \"true\" || req.http.X-LAGOON-VARNISH-BYPASS == \"TRUE\") {\n return (pass);\n }\n\n # SA-CORE-2014-004 preventing access to \/xmlrpc.php\n if (req.url ~ \"^\/xmlrpc.php$\") {\n return (synth(701, \"Unauthorized\"));\n }\n\n # Strip out Google Analytics campaign variables. They are only needed\n # by the javascript running on the page\n # utm_source, utm_medium, utm_campaign, gclid\n if(req.url ~ \"(\\?|&)(gclid|utm_[a-z]+)=\") {\n set req.url = regsuball(req.url, \"(gclid|utm_[a-z]+)=[^\\&]+&?\", \"\");\n set req.url = regsub(req.url, \"(\\?|&)$\", \"\");\n }\n\n # Bypass a cache hit (the request is still sent to the backend)\n if (req.method == \"REFRESH\") {\n if (!client.ip ~ purge) { return (synth(405, \"Not allowed\")); }\n set req.method = \"GET\";\n set req.hash_always_miss = true;\n }\n\n # Only allow BAN requests from IP addresses in the 'purge' ACL.\n if (req.method == \"BAN\" || req.method == \"URIBAN\" || req.method == \"PURGE\") {\n # Only allow BAN from defined ACL\n if (!client.ip ~ purge) {\n return (synth(403, \"Your IP is not allowed.\"));\n }\n\n # Only allows BAN if the Host Header has the style of with \"${SERVICE_NAME:-varnish}:8080\" or \"${SERVICE_NAME:-varnish}\".\n # Such a request is only possible from within the Docker network, as a request from external goes trough the Kubernetes Router and for that needs a proper Host Header\n if (!req.http.host ~ \"^${SERVICE_NAME:-varnish}(:\\d+)?$\") {\n return (synth(403, \"Only allowed from within own network.\"));\n }\n\n if (req.method == \"BAN\") {\n # Logic for the ban, using the Cache-Tags header.\n if (req.http.Cache-Tags) {\n ban(\"obj.http.Cache-Tags ~ \" + req.http.Cache-Tags);\n # Throw a synthetic page so the request won't go to the backend.\n return (synth(200, \"Ban added.\"));\n }\n else {\n return (synth(403, \"Cache-Tags header missing.\"));\n }\n }\n\n if (req.method == \"URIBAN\" || req.method == \"PURGE\") {\n ban(\"req.url ~ \" + req.url);\n # Throw a synthetic page so the request won't go to the backend.\n return (synth(200, \"Ban added.\"));\n }\n\n }\n\n # Non-RFC2616 or CONNECT which is weird, we pipe that\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n return (pipe);\n }\n\n # We only try to cache GET and HEAD, other things are passed\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n # Any requests with Basic Auth are passed\n if (req.http.Authorization || req.http.Authenticate)\n {\n return (pass);\n }\n\n ## Pass requests which are from blackfire\n if (req.http.X-Blackfire-Query) {\n return (pass);\n }\n\n # Some URLs should never be cached\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/admin([\/?]|$).*$\" ||\n req.url ~ \"^\/info([\/?]|$).*$\" ||\n req.url ~ \"^\/flag([\/?]|$).*$\" ||\n req.url ~ \"^.*\/system\/files([\/?]|$).*$\" ||\n req.url ~ \"^\/cgi\" ||\n req.url ~ \"^\/cgi-bin\"\n ) {\n return (pass);\n }\n\n # Plupload likes to get piped\n if (req.url ~ \"^.*\/plupload-handle-uploads.*$\"\n ) {\n return (pipe);\n }\n\n # Handle compression correctly. Different browsers send different\n # \"Accept-Encoding\" headers, even though they mostly all support the same\n # compression mechanisms. By consolidating these compression headers into\n # a consistent format, we can reduce the size of the cache and get more hits.=\n # @see: http:\/\/ varnish.projects.linpro.no\/wiki\/FAQ\/Compression\n if (req.http.Accept-Encoding) {\n if (req.http.Accept-Encoding ~ \"gzip\") {\n # If the browser supports it, we'll use gzip.\n set req.http.Accept-Encoding = \"gzip\";\n }\n else if (req.http.Accept-Encoding ~ \"deflate\") {\n # Next, try deflate if it is supported.\n set req.http.Accept-Encoding = \"deflate\";\n }\n else {\n # Unknown algorithm. Remove it and send unencoded.\n unset req.http.Accept-Encoding;\n }\n }\n\n # Always cache the following file types for all users.\n if (req.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n unset req.http.Cookie;\n }\n\n # Remove all cookies that Drupal doesn't need to know about. ANY remaining\n # cookie will cause the request to pass-through to a backend. For the most part\n # we always set the NO_CACHE cookie after any POST request, disabling the\n # Varnish cache temporarily. The session cookie allows all authenticated users\n # to pass through as long as they're logged in.\n #\n # 1. Append a semi-colon to the front of the cookie string.\n # 2. Remove all spaces that appear after semi-colons.\n # 3. Match the cookies we want to keep, adding the space we removed\n # previously, back. (\\1) is first matching group in the regsuball.\n # 4. Remove all other cookies, identifying them by the fact that they have\n # no space after the preceding semi-colon.\n # 5. Remove all spaces and semi-colons from the beginning and end of the\n # cookie string.\n if (req.http.Cookie) {\n set req.http.CookieCheck = \";\" + req.http.Cookie;\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"; +\", \";\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";(${VARNISH_COOKIECHECK:-SESS[a-z0-9]+|SSESS[a-z0-9]+|NO_CACHE})=\", \"; \\1=\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";[^ ][^;]*\", \"\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"^[; ]+|[; ]+$\", \"\");\n\n set req.http.Cookie = req.http.Cookie + \";\";\n\n if (req.http.CookieCheck == \"\") {\n # If there are no remaining cookies, remove the cookie header. If there\n # aren't any cookie headers, Varnish's default behavior will be to cache\n # the page.\n\n unset req.http.CookieCheck;\n unset req.http.Cookie;\n }\n else {\n # If there is any cookies left (a session or NO_CACHE cookie), do not\n # cache the page. Pass it on to Apache directly.\n unset req.http.CookieCheck;\n return (pass);\n }\n }\n\n # Cacheable, lookup in cache.\n return (hash);\n}\n\nsub vcl_pipe {\n # Support for Websockets\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n set bereq.http.connection = req.http.connection;\n }\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n # normal hit\n return (deliver);\n }\n # We have no fresh fish. Lets look at the stale ones.\n if (std.healthy(req.backend_hint)) {\n # Backend is healthy. If the object is not older then 30secs, deliver it to the client\n # and automatically create a separate backend request to warm the cache for this request.\n if (obj.ttl + 30s > 0s) {\n set req.http.grace = \"normal(limited)\";\n return (deliver);\n } else {\n # No candidate for grace. Fetch a fresh object.\n return(miss);\n }\n } else {\n # backend is sick - use full grace\n if (obj.ttl + obj.grace > 0s) {\n set req.http.grace = \"full\";\n return (deliver);\n } else {\n # no graced object.\n return (miss);\n }\n }\n}\n\nsub vcl_backend_response {\n # Allow items to be stale if needed.\n set beresp.grace = 6h;\n\n # Set ban-lurker friendly custom headers.\n set beresp.http.X-Url = bereq.url;\n set beresp.http.X-Host = bereq.http.host;\n\n # If the backend sends a X-LAGOON-VARNISH-BACKEND-BYPASS header we directly deliver\n if(beresp.http.X-LAGOON-VARNISH-BACKEND-BYPASS == \"TRUE\") {\n return (deliver);\n }\n\n # Cache 404 and 403 for 10 seconds\n if(beresp.status == 404 || beresp.status == 403) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n # Don't allow static files to set cookies.\n if (bereq.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n # beresp == Back-end response from the web server.\n unset beresp.http.set-cookie;\n unset beresp.http.Cache-Control;\n\n # If an asset would come back with statuscode 500 we only cache it for 10 seconds instead of the usual static file cache\n if (beresp.status == 500) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n set beresp.ttl = ${VARNISH_ASSETS_TTL:-2628001}s;\n set beresp.http.Cache-Control = \"public, max-age=${VARNISH_ASSETS_TTL:-2628001}\";\n set beresp.http.Expires = \"\" + (now + beresp.ttl);\n }\n\n return (deliver);\n}\n\n# Set a header to track a cache HIT\/MISS.\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Varnish-Cache = \"HIT\";\n }\n else {\n set resp.http.X-Varnish-Cache = \"MISS\";\n }\n\n # Remove ban-lurker friendly custom headers when delivering to client.\n unset resp.http.X-Url;\n unset resp.http.X-Host;\n\n # unset Cache-Tags Header by default, can be disabled with VARNISH_UNSET_HEADER_CACHE_TAGS=true\n if (!${VARNISH_UNSET_HEADER_CACHE_TAGS:-false}) {\n unset resp.http.Cache-Tags;\n }\n\n unset resp.http.X-Generator;\n unset resp.http.Server;\n # Inject information about grace\n if (req.http.grace) {\n set resp.http.X-Varnish-Grace = req.http.grace;\n }\n set resp.http.X-LAGOON = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}>\" + resp.http.X-LAGOON;\n return (deliver);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n if (req.http.X-Forwarded-Proto) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n if (req.http.HTTPS) {\n hash_data(req.http.HTTPS);\n }\n return (lookup);\n}\n\nsub vcl_synth {\n if (resp.status == 701) {\n set resp.status = 401;\n set resp.http.Content-Type = \"text\/plain; charset=utf-8\";\n synthetic({\"XMLRPC Interface is blocked due to SA-CORE-2014-004 - mail support@amazee.io if you need it.\"});\n return (deliver);\n }\n if (resp.status == 700) {\n # Set a status the client will understand\n set resp.status = 200;\n # Create our synthetic response\n synthetic(\"\");\n return(deliver);\n}\n return (deliver);\n}\n\nsub vcl_backend_error {\n # Restart the request, when we have a backend server error, to try another backend.\n # Restart max twice.\n if (bereq.retries < 2) {\n return(retry);\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<head>\n <title>Server Error<\/title>\n <style type=\"text\/css\">\n body {\n font-family: helvetica, arial, sans-serif;\n }\n img {\n margin-top: 50px;\n }\n p {\n width: 6 00px;\n margin-top: 10px\n }\n div {\n background: #ccc;\n width: 600px;\n margin: auto;\n padding: 50px;\n }\n span {\n color: #ccc\n }\n <\/style>\n<\/head>\n<body>\n <div>\n <h1>We are sorry...<\/h1>\n <p>We encountered a server-side error. This means that the problem is not with your computer or Internet connection, but rather with the website's server.<\/p>\n <p>We are currently working on solving this problem and apologise for the inconvenience.<\/p>\n <span>\n <strong>Technical Information<\/strong><br \/>\n Error \"} + beresp.status + \" \" + beresp.reason + {\"<br \/>\n XID: \"} + bereq.xid + {\"<br \/>\n <\/span>\n <\/div>\n<\/body>\n<\/html>\n\n\"} );\n return (deliver);\n}\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"d4f1107edf28b094ce1f9bd5b02bcc8fbba391a0","subject":"add vcl 4.0; at the top for default.vcl","message":"add vcl 4.0; at the top for default.vcl\n","repos":"varnish\/varnish-microservice-monitor,varnish\/zipnish,varnish\/varnish-microservice-monitor,varnish\/varnish-microservice-monitor,varnish\/zipnish,varnish\/varnish-microservice-monitor,varnish\/zipnish,varnish\/zipnish,varnish\/zipnish,varnish\/varnish-microservice-monitor","old_file":"provisioning\/files\/backend\/default.vcl","new_file":"provisioning\/files\/backend\/default.vcl","new_contents":"vcl 4.0;\n\nbackend default {\n .host = \"192.168.33.14\";\n .port = \"9000\";\n}\n\nsub vcl_recv {\n\treturn (pass);\n}\n\nsub vcl_backend_response {\n}\n\nsub vcl_deliver {\n}\n","old_contents":"backend default {\n .host = \"192.168.33.14\";\n .port = \"9000\";\n}\n\nsub vcl_recv {\n\treturn (pass);\n}\n\nsub vcl_backend_response {\n}\n\nsub vcl_deliver {\n}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"7e889298abadfbed924df61a36b30871004128fb","subject":"Per @acme X- is deprecated","message":"Per @acme X- is deprecated\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/fastly.vcl","new_file":"etc\/fastly.vcl","new_contents":"###############################################################################\n#\n# Fastly CDN for Magento 2\n#\n# NOTICE OF LICENSE\n#\n# This source file is subject to the Fastly CDN for Magento 2 End User License\n# Agreement that is bundled with this package in the file LICENSE_FASTLY_CDN.txt.\n#\n# @copyright Copyright (c) 2016 Fastly, Inc. (http:\/\/www.fastly.com)\n# @license BSD, see LICENSE_FASTLY_CDN.txt\n#\n###############################################################################\n\n# This is a basic VCL configuration file for Fastly CDN for Magento 2 module.\n\nsub vcl_recv {\n#FASTLY recv\n\n if (req.url ~ \"^\/static\/version(\\d*\/)?(.*)$\") {\n set req.url = \"\/static\/\" + re.group.2 + \"?\" + re.group.1;\n } \n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n set req.http.X-Sig = regsub(req.http.X-Purge-Token, \"^[^_]+_(.*)\", \"\\1\");\n set req.http.X-Exp = regsub(req.http.X-Purge-Token, \"^([^_]+)_.*\", \"\\1\");\n\n # validate signature\n if (req.http.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path req.http.X-Exp), \"^0x\", \"\")) {\n\n # use vcl time math to check expiration timestamp\n set req.http.X-Original-Grace = req.grace;\n set req.grace = std.atoi(strftime({\"%s\"}, now));\n set req.grace -= std.atoi(req.http.X-Exp);\n\n if (std.atoi(req.grace) > 0) {\n error 410;\n }\n\n # clean up grace since we used it for time math\n set req.grace = std.atoi(req.http.X-Original-Grace);\n unset req.http.X-Original-Grace;\n\n } else {\n error 403;\n }\n\n # cleanup variables\n unset req.http.X-Purge-Token;\n unset req.http.X-Sig;\n unset req.http.X-Exp;\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n # disable ESI processing on Origin Shield\n if (req.http.Fastly-FF) {\n set req.esi = false;\n }\n\n # We only deal with GET and HEAD by default\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n return (pass);\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n return (lookup);\n }\n\n # Bypass shopping cart and checkout requests\n if (req.url ~ \"\/checkout\") {\n return (pass);\n }\n\n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie ~ \"(X-Magento-Vary|form_key)=\") {\n error 200 \"\";\n } else {\n # append parameter with country code\n set req.url = req.url \"?country_code=\" geoip.country_code;\n }\n }\n\n return(lookup);\n}\n\nsub vcl_fetch {\n\n # Remove Set-Cookies from responses for static content\n # to match the cookie removal in recv.\n if (req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n }\n\n }\n\n#FASTLY fetch\n\n if (beresp.status >= 500) {\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n }\n\n if (req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Content-Type ~ \"text\/html\" || beresp.http.Content-Type ~ \"text\/xml\") {\n # enable ESI feature for Magento response by default\n esi;\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content\n if ((beresp.status == 200 || beresp.status == 404) && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url ~ \"\\.(css|js|html|eot|ico|otf|ttf|json)($|\\?)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # cache only successfully responses and 404s\n if (beresp.status != 200 && beresp.status != 301 && beresp.status != 404) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\")) {\n unset beresp.http.set-cookie;\n if (req.url !~ \"^\/(pub\/)?(media|static)\/.*\") {\n set beresp.http.Pragma = \"no-cache\";\n set beresp.http.Expires = \"-1\";\n set beresp.http.Cache-Control = \"no-store, no-cache, must-revalidate, max-age=0\";\n set beresp.grace = 1m;\n }\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type\n if (beresp.http.Content-Type ~ \"image\") {\n set beresp.http.Surrogate-Key = \"image\";\n } elsif (beresp.http.Content-Type ~ \"script\") {\n set beresp.http.Surrogate-Key = \"script\";\n } elsif (beresp.http.Content-Type ~ \"css\") {\n set beresp.http.Surrogate-Key = \"css\";\n }\n\n set beresp.http.X-Surrogate-Key = beresp.http.Surrogate-Key;\n return (deliver);\n }\n\n return (deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\n\nsub vcl_miss {\n # Deactivate gzip on origin\n unset bereq.http.Accept-Encoding;\n\n#FASTLY miss\n\n return(fetch);\n}\n\nsub vcl_deliver {\n\n # Add an easy way to see whether custom Fastly VCL has been uploaded\n if ( req.http.Fastly-Debug ) {\n set resp.http.Fastly-Magento-VCL-Uploaded = \"yes\";\n }\n # debug info\n if (resp.http.X-Magento-Debug) {\n if (obj.hits > 0) {\n set resp.http.X-Magento-Cache-Debug = \"HIT\";\n set resp.http.X-Magento-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Magento-Cache-Debug = \"MISS\";\n }\n } else {\n # remove Varnish\/proxy header\n remove resp.http.Age;\n remove resp.http.X-Magento-Debug;\n remove resp.http.X-Magento-Tags;\n remove resp.http.X-Surrogate-Key;\n remove resp.http.X-Magento-Cache-Control;\n remove resp.http.X-Powered-By;\n remove resp.http.Server;\n remove resp.http.X-Varnish;\n remove resp.http.Via;\n remove resp.http.Link;\n remove resp.http.X-Purge-URL;\n remove resp.http.X-Purge-Host;\n }\n\n#FASTLY deliver\n\n return (deliver);\n}\n\n\nsub vcl_error {\n # workaround for possible security issue\n if (req.url ~ \"^\\s\") {\n set obj.status = 400;\n set obj.response = \"Malformed request\";\n synthetic \"\";\n return (deliver);\n }\n\n # error 200\n if (obj.status == 200) {\n return (deliver);\n }\n\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} obj.status \" \" obj.response {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} obj.status \" \" obj.response {\"<\/h1>\n <p>\"} obj.response {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} req.xid {\"<\/p>\n <hr>\n <p>Fastly CDN server<\/p>\n <\/body>\n<\/html>\n\"};\n\n#FASTLY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n\nsub vcl_hash {\n set req.hash += req.http.Https;\n set req.hash += req.http.host;\n set req.hash += req.url;\n\n if (req.http.cookie:X-Magento-Vary ) {\n set req.hash += req.http.cookie:X-Magento-Vary;\n }\n \n set req.hash += \"#####GENERATION#####\";\n\n ### {{ design_exceptions_code }} ###\n\n return (hash);\n}\n\n","old_contents":"###############################################################################\n#\n# Fastly CDN for Magento 2\n#\n# NOTICE OF LICENSE\n#\n# This source file is subject to the Fastly CDN for Magento 2 End User License\n# Agreement that is bundled with this package in the file LICENSE_FASTLY_CDN.txt.\n#\n# @copyright Copyright (c) 2016 Fastly, Inc. (http:\/\/www.fastly.com)\n# @license BSD, see LICENSE_FASTLY_CDN.txt\n#\n###############################################################################\n\n# This is a basic VCL configuration file for Fastly CDN for Magento 2 module.\n\nsub vcl_recv {\n#FASTLY recv\n\n if (req.url ~ \"^\/static\/version(\\d*\/)?(.*)$\") {\n set req.url = \"\/static\/\" + re.group.2 + \"?\" + re.group.1;\n } \n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n set req.http.X-Sig = regsub(req.http.X-Purge-Token, \"^[^_]+_(.*)\", \"\\1\");\n set req.http.X-Exp = regsub(req.http.X-Purge-Token, \"^([^_]+)_.*\", \"\\1\");\n\n # validate signature\n if (req.http.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path req.http.X-Exp), \"^0x\", \"\")) {\n\n # use vcl time math to check expiration timestamp\n set req.http.X-Original-Grace = req.grace;\n set req.grace = std.atoi(strftime({\"%s\"}, now));\n set req.grace -= std.atoi(req.http.X-Exp);\n\n if (std.atoi(req.grace) > 0) {\n error 410;\n }\n\n # clean up grace since we used it for time math\n set req.grace = std.atoi(req.http.X-Original-Grace);\n unset req.http.X-Original-Grace;\n\n } else {\n error 403;\n }\n\n # cleanup variables\n unset req.http.X-Purge-Token;\n unset req.http.X-Sig;\n unset req.http.X-Exp;\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n # disable ESI processing on Origin Shield\n if (req.http.Fastly-FF) {\n set req.esi = false;\n }\n\n # We only deal with GET and HEAD by default\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n return (pass);\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n return (lookup);\n }\n\n # Bypass shopping cart and checkout requests\n if (req.url ~ \"\/checkout\") {\n return (pass);\n }\n\n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie ~ \"(X-Magento-Vary|form_key)=\") {\n error 200 \"\";\n } else {\n # append parameter with country code\n set req.url = req.url \"?country_code=\" geoip.country_code;\n }\n }\n\n return(lookup);\n}\n\nsub vcl_fetch {\n\n # Remove Set-Cookies from responses for static content\n # to match the cookie removal in recv.\n if (req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n }\n\n }\n\n#FASTLY fetch\n\n if (beresp.status >= 500) {\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n }\n\n if (req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Content-Type ~ \"text\/html\" || beresp.http.Content-Type ~ \"text\/xml\") {\n # enable ESI feature for Magento response by default\n esi;\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content\n if ((beresp.status == 200 || beresp.status == 404) && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url ~ \"\\.(css|js|html|eot|ico|otf|ttf|json)($|\\?)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # cache only successfully responses and 404s\n if (beresp.status != 200 && beresp.status != 301 && beresp.status != 404) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\")) {\n unset beresp.http.set-cookie;\n if (req.url !~ \"^\/(pub\/)?(media|static)\/.*\") {\n set beresp.http.Pragma = \"no-cache\";\n set beresp.http.Expires = \"-1\";\n set beresp.http.Cache-Control = \"no-store, no-cache, must-revalidate, max-age=0\";\n set beresp.grace = 1m;\n }\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type\n if (beresp.http.Content-Type ~ \"image\") {\n set beresp.http.Surrogate-Key = \"image\";\n } elsif (beresp.http.Content-Type ~ \"script\") {\n set beresp.http.Surrogate-Key = \"script\";\n } elsif (beresp.http.Content-Type ~ \"css\") {\n set beresp.http.Surrogate-Key = \"css\";\n }\n\n set beresp.http.X-Surrogate-Key = beresp.http.Surrogate-Key;\n return (deliver);\n }\n\n return (deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\n\nsub vcl_miss {\n # Deactivate gzip on origin\n unset bereq.http.Accept-Encoding;\n\n#FASTLY miss\n\n return(fetch);\n}\n\nsub vcl_deliver {\n\n # Add an easy way to see whether custom Fastly VCL has been uploaded\n if ( req.http.Fastly-Debug ) {\n set resp.http.X-Fastly-Magento-VCL-Uploaded = \"yes\";\n }\n # debug info\n if (resp.http.X-Magento-Debug) {\n if (obj.hits > 0) {\n set resp.http.X-Magento-Cache-Debug = \"HIT\";\n set resp.http.X-Magento-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Magento-Cache-Debug = \"MISS\";\n }\n } else {\n # remove Varnish\/proxy header\n remove resp.http.Age;\n remove resp.http.X-Magento-Debug;\n remove resp.http.X-Magento-Tags;\n remove resp.http.X-Surrogate-Key;\n remove resp.http.X-Magento-Cache-Control;\n remove resp.http.X-Powered-By;\n remove resp.http.Server;\n remove resp.http.X-Varnish;\n remove resp.http.Via;\n remove resp.http.Link;\n remove resp.http.X-Purge-URL;\n remove resp.http.X-Purge-Host;\n }\n\n#FASTLY deliver\n\n return (deliver);\n}\n\n\nsub vcl_error {\n # workaround for possible security issue\n if (req.url ~ \"^\\s\") {\n set obj.status = 400;\n set obj.response = \"Malformed request\";\n synthetic \"\";\n return (deliver);\n }\n\n # error 200\n if (obj.status == 200) {\n return (deliver);\n }\n\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} obj.status \" \" obj.response {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} obj.status \" \" obj.response {\"<\/h1>\n <p>\"} obj.response {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} req.xid {\"<\/p>\n <hr>\n <p>Fastly CDN server<\/p>\n <\/body>\n<\/html>\n\"};\n\n#FASTLY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n\nsub vcl_hash {\n set req.hash += req.http.Https;\n set req.hash += req.http.host;\n set req.hash += req.url;\n\n if (req.http.cookie:X-Magento-Vary ) {\n set req.hash += req.http.cookie:X-Magento-Vary;\n }\n \n set req.hash += \"#####GENERATION#####\";\n\n ### {{ design_exceptions_code }} ###\n\n return (hash);\n}\n\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"d115c9fcef9ce17b4b42fd96798f783e9388e22d","subject":"added again ESI capabilities","message":"added again ESI capabilities\n","repos":"domix\/poc-varnish-cache-docker,domix\/poc-varnish-cache-docker","old_file":"conf\/varnish.vcl","new_file":"conf\/varnish.vcl","new_contents":"vcl 4.0;\n\nbackend default {\n .host = \"web\";\n .port = \"9191\";\n}\n\nbackend management {\n .host = \"web\";\n .port = \"9192\";\n}\n\nsub vcl_recv {\n # Happens before we check if we have this in cache already.\n #\n # Typically you clean up the request here, removing cookies you don't need,\n # rewriting the request, etc.\n\n if (req.url ~ \"^\/management\/\") {\n set req.backend_hint = management;\n } else {\n set req.backend_hint = default;\n }\n\n if (req.method == \"BAN\" || req.method == \"PURGE\") {\n # Same ACL check as above:\n #if (!client.ip ~ purge) {\n #return(synth(403, \"Not allowed.\"));\n #}\n\n ban(\"obj.http.x-url ~ \" + req.url); # Assumes req.url is a regex. This might be a bit too simple\n\n # Throw a synthetic page so the\n # request won't go to the backend.\n return(synth(200, \"Ban added\"));\n }\n\n if (!req.url ~ \"\\.(jpg|jpeg|png|gif|ico|tiff|tif|bmp|ppm|pgm|xcf|psd|webp|svg)\") {\n set req.http.X-Esi = \"1\";\n }\n}\n\nsub vcl_backend_response {\n # Happens after we have read the response headers from the backend.\n #\n # Here you clean the response headers, removing silly Set-Cookie headers\n # and other mistakes your backend does.\n\n #if (beresp.http.Content-Type ~ \"^image\/\") {\n if (beresp.status == 404) {\n #set beresp.http.Cache-Control = \"public, max-age=60\";\n #set beresp.ttl = 60s;\n set beresp.http.Cache-Control = \"public, max-age=0\";\n set beresp.ttl = 0s;\n }\n\n #if (beresp.http.X-Esi) {\n # set beresp.do_esi = true;\n # unset beresp.http.X-Esi; # remove header\n #}\n\n #set beresp.http.X-url = bereq.url;\n}\n\nsub vcl_deliver {\n # Happens when we have all the pieces we need, and are about to send the\n # response to the client.\n #\n # You can do accounting or modifying the final object here.\n\n unset resp.http.Server;\n unset resp.http.X-Powered-By;\n}","old_contents":"vcl 4.0;\n\nbackend default {\n .host = \"web\";\n .port = \"9191\";\n}\n\nbackend management {\n .host = \"web\";\n .port = \"9192\";\n}\n\nsub vcl_recv {\n # Happens before we check if we have this in cache already.\n #\n # Typically you clean up the request here, removing cookies you don't need,\n # rewriting the request, etc.\n\n if (req.url ~ \"^\/management\/\") {\n set req.backend_hint = management;\n } else {\n set req.backend_hint = default;\n }\n\n if (req.method == \"BAN\" || req.method == \"PURGE\") {\n # Same ACL check as above:\n #if (!client.ip ~ purge) {\n #return(synth(403, \"Not allowed.\"));\n #}\n\n ban(\"obj.http.x-url ~ \" + req.url); # Assumes req.url is a regex. This might be a bit too simple\n\n # Throw a synthetic page so the\n # request won't go to the backend.\n return(synth(200, \"Ban added\"));\n }\n\n #if (!req.url ~ \"\\.(jpg|jpeg|png|gif|ico|tiff|tif|bmp|ppm|pgm|xcf|psd|webp|svg)\") {\n # set req.http.X-Esi = \"1\";\n #}\n}\n\nsub vcl_backend_response {\n # Happens after we have read the response headers from the backend.\n #\n # Here you clean the response headers, removing silly Set-Cookie headers\n # and other mistakes your backend does.\n\n #if (beresp.http.Content-Type ~ \"^image\/\") {\n if (beresp.status == 404) {\n #set beresp.http.Cache-Control = \"public, max-age=60\";\n #set beresp.ttl = 60s;\n set beresp.http.Cache-Control = \"public, max-age=0\";\n set beresp.ttl = 0s;\n }\n\n #if (beresp.http.X-Esi) {\n # set beresp.do_esi = true;\n # unset beresp.http.X-Esi; # remove header\n #}\n\n #set beresp.http.X-url = bereq.url;\n}\n\nsub vcl_deliver {\n # Happens when we have all the pieces we need, and are about to send the\n # response to the client.\n #\n # You can do accounting or modifying the final object here.\n\n unset resp.http.Server;\n unset resp.http.X-Powered-By;\n}","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"2e87216969ff7a978dbc6462f124d2499bb320ca","subject":"Make sure we import querystring module","message":"Make sure we import querystring module\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/fastly.vcl","new_file":"etc\/fastly.vcl","new_contents":"###############################################################################\n#\n# Fastly CDN for Magento 2\n#\n# NOTICE OF LICENSE\n#\n# This source file is subject to the Fastly CDN for Magento 2 End User License\n# Agreement that is bundled with this package in the file LICENSE_FASTLY_CDN.txt.\n#\n# @copyright Copyright (c) 2016 Fastly, Inc. (http:\/\/www.fastly.com)\n# @license BSD, see LICENSE_FASTLY_CDN.txt\n#\n###############################################################################\n\n# This is a basic VCL configuration file for Fastly CDN for Magento 2 module.\nimport querystring;\n\nsub vcl_recv {\n#FASTLY recv\n\n\n # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n if (req.url ~ \"^\/static\/version(\\d*\/)?(.*)$\") {\n set req.url = \"\/static\/\" + re.group.2 + \"?\" + re.group.1;\n } \n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n set req.http.X-Sig = regsub(req.http.X-Purge-Token, \"^[^_]+_(.*)\", \"\\1\");\n set req.http.X-Exp = regsub(req.http.X-Purge-Token, \"^([^_]+)_.*\", \"\\1\");\n\n # validate signature\n if (req.http.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path req.http.X-Exp), \"^0x\", \"\")) {\n\n # use vcl time math to check expiration timestamp\n set req.http.X-Original-Grace = req.grace;\n set req.grace = std.atoi(strftime({\"%s\"}, now));\n set req.grace -= std.atoi(req.http.X-Exp);\n\n if (std.atoi(req.grace) > 0) {\n error 410;\n }\n\n # clean up grace since we used it for time math\n set req.grace = std.atoi(req.http.X-Original-Grace);\n unset req.http.X-Original-Grace;\n\n } else {\n error 403;\n }\n\n # cleanup variables\n unset req.http.X-Purge-Token;\n unset req.http.X-Sig;\n unset req.http.X-Exp;\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n # disable ESI processing on Origin Shield\n if (req.http.Fastly-FF) {\n set req.esi = false;\n }\n\n # We only deal with GET and HEAD by default\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n return (pass);\n }\n \n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie ~ \"(X-Magento-Vary|form_key)=\") {\n error 200 \"\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url !~ \"country_code=\" ) {\n set req.url = req.url \"?country_code=\" if ( req.http.geo_override, req.http.geo_override, geoip.country_code);\n }\n }\n } else {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking\n set req.http.Fastly-Original-URL = req.url;\n set req.url = querystring.regfilter(req.url, \"^(utm_.*|gclid|gdftrk|_ga|mc_.*)\");\n }\n \n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n return (lookup);\n }\n\n # Bypass shopping cart and checkout requests\n if (req.url ~ \"\/checkout\") {\n return (pass);\n }\n\n return(lookup);\n}\n\nsub vcl_fetch {\n\n # Remove Set-Cookies from responses for static content\n # to match the cookie removal in recv.\n if (req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n }\n\n }\n\n#FASTLY fetch\n\n if (beresp.status >= 500) {\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n }\n\n if (req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Content-Type ~ \"text\/html\" || beresp.http.Content-Type ~ \"text\/xml\") {\n # enable ESI feature for Magento response by default\n esi;\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content\n if ((beresp.status == 200 || beresp.status == 404) && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url ~ \"\\.(css|js|html|eot|ico|otf|ttf|json)($|\\?)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # cache only successfully responses and 404s\n if (beresp.status != 200 && beresp.status != 301 && beresp.status != 404) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\")) {\n unset beresp.http.set-cookie;\n if (req.url !~ \"^\/(pub\/)?(media|static)\/.*\") {\n set beresp.http.Pragma = \"no-cache\";\n set beresp.http.Expires = \"-1\";\n set beresp.http.Cache-Control = \"no-store, no-cache, must-revalidate, max-age=0\";\n set beresp.grace = 1m;\n }\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type\n if (beresp.http.Content-Type ~ \"image\") {\n set beresp.http.Surrogate-Key = \"image\";\n } elsif (beresp.http.Content-Type ~ \"script\") {\n set beresp.http.Surrogate-Key = \"script\";\n } elsif (beresp.http.Content-Type ~ \"css\") {\n set beresp.http.Surrogate-Key = \"css\";\n }\n\n set beresp.http.X-Surrogate-Key = beresp.http.Surrogate-Key;\n return (deliver);\n }\n\n return (deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\n\nsub vcl_miss {\n # Deactivate gzip on origin\n unset bereq.http.Accept-Encoding;\n\n#FASTLY miss\n\n return(fetch);\n}\n\nsub vcl_deliver {\n\n # Add an easy way to see whether custom Fastly VCL has been uploaded\n if ( req.http.Fastly-Debug ) {\n set resp.http.Fastly-Magento-VCL-Uploaded = \"yes\";\n } else {\n remove resp.http.Fastly-Module-Enabled;\n }\n # debug info\n if (resp.http.X-Magento-Debug) {\n if (obj.hits > 0) {\n set resp.http.X-Magento-Cache-Debug = \"HIT\";\n set resp.http.X-Magento-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Magento-Cache-Debug = \"MISS\";\n }\n } else {\n # remove Varnish\/proxy header\n remove resp.http.Age;\n remove resp.http.X-Magento-Debug;\n remove resp.http.X-Magento-Tags;\n remove resp.http.X-Surrogate-Key;\n remove resp.http.X-Magento-Cache-Control;\n remove resp.http.X-Powered-By;\n remove resp.http.Server;\n remove resp.http.X-Varnish;\n remove resp.http.Via;\n remove resp.http.Link;\n remove resp.http.X-Purge-URL;\n remove resp.http.X-Purge-Host;\n }\n\n#FASTLY deliver\n\n return (deliver);\n}\n\n\nsub vcl_error {\n # workaround for possible security issue\n if (req.url ~ \"^\\s\") {\n set obj.status = 400;\n set obj.response = \"Malformed request\";\n synthetic \"\";\n return (deliver);\n }\n\n # error 200\n if (obj.status == 200) {\n return (deliver);\n }\n\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} obj.status \" \" obj.response {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} obj.status \" \" obj.response {\"<\/h1>\n <p>\"} obj.response {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} req.xid {\"<\/p>\n <hr>\n <p>Fastly CDN server<\/p>\n <\/body>\n<\/html>\n\"};\n\n#FASTLY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n\nsub vcl_hash {\n set req.hash += req.http.Https;\n set req.hash += req.http.host;\n set req.hash += req.url;\n\n if (req.http.cookie:X-Magento-Vary ) {\n set req.hash += req.http.cookie:X-Magento-Vary;\n }\n \n set req.hash += \"#####GENERATION#####\";\n\n ### {{ design_exceptions_code }} ###\n\n return (hash);\n}\n\n","old_contents":"###############################################################################\n#\n# Fastly CDN for Magento 2\n#\n# NOTICE OF LICENSE\n#\n# This source file is subject to the Fastly CDN for Magento 2 End User License\n# Agreement that is bundled with this package in the file LICENSE_FASTLY_CDN.txt.\n#\n# @copyright Copyright (c) 2016 Fastly, Inc. (http:\/\/www.fastly.com)\n# @license BSD, see LICENSE_FASTLY_CDN.txt\n#\n###############################################################################\n\n# This is a basic VCL configuration file for Fastly CDN for Magento 2 module.\n\nsub vcl_recv {\n#FASTLY recv\n\n # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n if (req.url ~ \"^\/static\/version(\\d*\/)?(.*)$\") {\n set req.url = \"\/static\/\" + re.group.2 + \"?\" + re.group.1;\n } \n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n set req.http.X-Sig = regsub(req.http.X-Purge-Token, \"^[^_]+_(.*)\", \"\\1\");\n set req.http.X-Exp = regsub(req.http.X-Purge-Token, \"^([^_]+)_.*\", \"\\1\");\n\n # validate signature\n if (req.http.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path req.http.X-Exp), \"^0x\", \"\")) {\n\n # use vcl time math to check expiration timestamp\n set req.http.X-Original-Grace = req.grace;\n set req.grace = std.atoi(strftime({\"%s\"}, now));\n set req.grace -= std.atoi(req.http.X-Exp);\n\n if (std.atoi(req.grace) > 0) {\n error 410;\n }\n\n # clean up grace since we used it for time math\n set req.grace = std.atoi(req.http.X-Original-Grace);\n unset req.http.X-Original-Grace;\n\n } else {\n error 403;\n }\n\n # cleanup variables\n unset req.http.X-Purge-Token;\n unset req.http.X-Sig;\n unset req.http.X-Exp;\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n # disable ESI processing on Origin Shield\n if (req.http.Fastly-FF) {\n set req.esi = false;\n }\n\n # We only deal with GET and HEAD by default\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n return (pass);\n }\n \n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie ~ \"(X-Magento-Vary|form_key)=\") {\n error 200 \"\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url !~ \"country_code=\" ) {\n set req.url = req.url \"?country_code=\" if ( req.http.geo_override, req.http.geo_override, geoip.country_code);\n }\n }\n } else {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking\n set req.http.Fastly-Original-URL = req.url;\n set req.url = querystring.regfilter(req.url, \"^(utm_.*|gclid|gdftrk|_ga|mc_.*)\");\n }\n \n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n return (lookup);\n }\n\n # Bypass shopping cart and checkout requests\n if (req.url ~ \"\/checkout\") {\n return (pass);\n }\n\n return(lookup);\n}\n\nsub vcl_fetch {\n\n # Remove Set-Cookies from responses for static content\n # to match the cookie removal in recv.\n if (req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n }\n\n }\n\n#FASTLY fetch\n\n if (beresp.status >= 500) {\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n }\n\n if (req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Content-Type ~ \"text\/html\" || beresp.http.Content-Type ~ \"text\/xml\") {\n # enable ESI feature for Magento response by default\n esi;\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content\n if ((beresp.status == 200 || beresp.status == 404) && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url ~ \"\\.(css|js|html|eot|ico|otf|ttf|json)($|\\?)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # cache only successfully responses and 404s\n if (beresp.status != 200 && beresp.status != 301 && beresp.status != 404) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\")) {\n unset beresp.http.set-cookie;\n if (req.url !~ \"^\/(pub\/)?(media|static)\/.*\") {\n set beresp.http.Pragma = \"no-cache\";\n set beresp.http.Expires = \"-1\";\n set beresp.http.Cache-Control = \"no-store, no-cache, must-revalidate, max-age=0\";\n set beresp.grace = 1m;\n }\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type\n if (beresp.http.Content-Type ~ \"image\") {\n set beresp.http.Surrogate-Key = \"image\";\n } elsif (beresp.http.Content-Type ~ \"script\") {\n set beresp.http.Surrogate-Key = \"script\";\n } elsif (beresp.http.Content-Type ~ \"css\") {\n set beresp.http.Surrogate-Key = \"css\";\n }\n\n set beresp.http.X-Surrogate-Key = beresp.http.Surrogate-Key;\n return (deliver);\n }\n\n return (deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\n\nsub vcl_miss {\n # Deactivate gzip on origin\n unset bereq.http.Accept-Encoding;\n\n#FASTLY miss\n\n return(fetch);\n}\n\nsub vcl_deliver {\n\n # Add an easy way to see whether custom Fastly VCL has been uploaded\n if ( req.http.Fastly-Debug ) {\n set resp.http.Fastly-Magento-VCL-Uploaded = \"yes\";\n } else {\n remove resp.http.Fastly-Module-Enabled;\n }\n # debug info\n if (resp.http.X-Magento-Debug) {\n if (obj.hits > 0) {\n set resp.http.X-Magento-Cache-Debug = \"HIT\";\n set resp.http.X-Magento-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Magento-Cache-Debug = \"MISS\";\n }\n } else {\n # remove Varnish\/proxy header\n remove resp.http.Age;\n remove resp.http.X-Magento-Debug;\n remove resp.http.X-Magento-Tags;\n remove resp.http.X-Surrogate-Key;\n remove resp.http.X-Magento-Cache-Control;\n remove resp.http.X-Powered-By;\n remove resp.http.Server;\n remove resp.http.X-Varnish;\n remove resp.http.Via;\n remove resp.http.Link;\n remove resp.http.X-Purge-URL;\n remove resp.http.X-Purge-Host;\n }\n\n#FASTLY deliver\n\n return (deliver);\n}\n\n\nsub vcl_error {\n # workaround for possible security issue\n if (req.url ~ \"^\\s\") {\n set obj.status = 400;\n set obj.response = \"Malformed request\";\n synthetic \"\";\n return (deliver);\n }\n\n # error 200\n if (obj.status == 200) {\n return (deliver);\n }\n\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} obj.status \" \" obj.response {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} obj.status \" \" obj.response {\"<\/h1>\n <p>\"} obj.response {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} req.xid {\"<\/p>\n <hr>\n <p>Fastly CDN server<\/p>\n <\/body>\n<\/html>\n\"};\n\n#FASTLY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n\nsub vcl_hash {\n set req.hash += req.http.Https;\n set req.hash += req.http.host;\n set req.hash += req.url;\n\n if (req.http.cookie:X-Magento-Vary ) {\n set req.hash += req.http.cookie:X-Magento-Vary;\n }\n \n set req.hash += \"#####GENERATION#####\";\n\n ### {{ design_exceptions_code }} ###\n\n return (hash);\n}\n\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"ae7576cfabc3c86aeebe96292332ee29908ec2dc","subject":"Display duration in get requests in example VCL","message":"Display duration in get requests in example VCL","repos":"Destination\/libvmod-abtest,Destination\/libvmod-abtest","old_file":"vcl\/default.vcl","new_file":"vcl\/default.vcl","new_contents":" import std;\n import abtest;\n\n C{\n #include <syslog.h>\n }C\n\n\n backend default {\n .host = \"127.0.0.1\";\n .port = \"3000\";\n }\n\n\/* Only permit localhost to manipulate abtest configuration *\/\nacl abconfig {\n \"localhost\";\n}\n\nsub vcl_init {\n if (abtest.load_config(\"\/tmp\/abtest.cfg\") != 0) {\n C{ syslog(LOG_ALERT, \"Unable to load AB config from \/tmp\/abtest.cfg\"); }C\n }\n abtest.set_rule(\"special\", \"a:10;b:90;\");\n abtest.rem_rule(\"base\");\n\n return (ok);\n}\n\nsub vcl_fini {\n}\n\nsub vcl_recv {\n std.log(abtest.get_rules());\n\n if (req.http.X-AB-Cfg) {\n if (!client.ip ~ abconfig) {\n std.log(\"AB Config request not allowed from \" + client.ip);\n error 405 \"Not allowed.\";\n } else {\n \/\/ curl localhost:8080 -X PUT -H \"X-AB-Cfg:base\" -H \"X-AB-Cfg-Val:a:25;b:75;\"\n if (req.request == \"PUT\") {\n std.log(\"AB Config PUT request: \" + req.http.X-AB-Cfg + \"|\" + req.http.X-AB-Cfg-Val);\n abtest.set_rule(req.http.X-AB-Cfg, req.http.X-AB-Cfg-Val);\n if (abtest.save_config(\"\/tmp\/abtest.cfg\") != 0) {\n std.log(\"ABTest - Error, could not save the configuration\");\n }\n }\n\n \/\/ curl localhost:8080 -X DELETE -H \"X-AB-Cfg:base\"\n if (req.request == \"DELETE\") {\n std.log(\"AB Config DELETE request: \" + req.http.X-AB-Cfg);\n abtest.rem_rule(req.http.X-AB-Cfg);\n }\n\n \/\/ curl localhost:8080 -X GET -H \"X-AB-Cfg;\"\n if (req.request == \"GET\") {\n std.log(\"AB Config GET request: \" + req.http.X-AB-Cfg);\n std.log(\"CFG -> \" + abtest.get_rules());\n if (req.http.X-AB-Cfg != \"\") {\n std.log(\"duration for '\" + req.http.X-AB-Cfg + \"': \" + abtest.get_duration(req.http.X-AB-Cfg));\n }\n }\n }\n }\n\n\/*\n if(req.http.Cookie ~ \"abtesting\") {\n }\n*\/\n}\n\nsub vcl_pipe {\n}\n\nsub vcl_pass {\n}\n\nsub vcl_hash {\n}\n\nsub vcl_hit {\n}\n\nsub vcl_miss {\n}\n\nsub vcl_fetch {\n}\n\nsub vcl_deliver {\n}\n\nsub vcl_error {\n}\n","old_contents":" import std;\n import abtest;\n\n C{\n #include <syslog.h>\n }C\n\n\n backend default {\n .host = \"127.0.0.1\";\n .port = \"3000\";\n }\n\n\/* Only permit localhost to manipulate abtest configuration *\/\nacl abconfig {\n \"localhost\";\n}\n\nsub vcl_init {\n if (abtest.load_config(\"\/tmp\/abtest.cfg\") != 0) {\n C{ syslog(LOG_ALERT, \"Unable to load AB config from \/tmp\/abtest.cfg\"); }C\n }\n abtest.set_rule(\"special\", \"a:10;b:90;\");\n abtest.rem_rule(\"base\");\n\n return (ok);\n}\n\nsub vcl_fini {\n}\n\nsub vcl_recv {\n std.log(abtest.get_rules());\n\n if (req.http.X-AB-Cfg) {\n if (!client.ip ~ abconfig) {\n std.log(\"AB Config request not allowed from \" + client.ip);\n error 405 \"Not allowed.\";\n } else {\n \/\/ curl localhost:8080 -X PUT -H \"X-AB-Cfg:base\" -H \"X-AB-Cfg-Val:a:25;b:75;\"\n if (req.request == \"PUT\") {\n std.log(\"AB Config PUT request: \" + req.http.X-AB-Cfg + \"|\" + req.http.X-AB-Cfg-Val);\n abtest.set_rule(req.http.X-AB-Cfg, req.http.X-AB-Cfg-Val);\n if (abtest.save_config(\"\/tmp\/abtest.cfg\") != 0) {\n std.log(\"ABTest - Error, could not save the configuration\");\n }\n }\n\n \/\/ curl localhost:8080 -X DELETE -H \"X-AB-Cfg:base\"\n if (req.request == \"DELETE\") {\n std.log(\"AB Config DELETE request: \" + req.http.X-AB-Cfg);\n abtest.rem_rule(req.http.X-AB-Cfg);\n }\n\n \/\/ curl localhost:8080 -X DELETE -H \"X-AB-Cfg;\"\n if (req.request == \"GET\") {\n std.log(\"AB Config GET request: \" + req.http.X-AB-Cfg);\n std.log(\"CFG -> \" + abtest.get_rules());\n }\n }\n }\n\n\/*\n if(req.http.Cookie ~ \"abtesting\") {\n }\n*\/\n}\n\nsub vcl_pipe {\n}\n\nsub vcl_pass {\n}\n\nsub vcl_hash {\n}\n\nsub vcl_hit {\n}\n\nsub vcl_miss {\n}\n\nsub vcl_fetch {\n}\n\nsub vcl_deliver {\n}\n\nsub vcl_error {\n}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"0ebef44d8db66770a43cf26ba7e890e80773fdf1","subject":"Varnish includes local configuration","message":"Varnish includes local configuration\n","repos":"lrkwz\/docker-magento-develop,lrkwz\/docker-magento-develop","old_file":"provision\/varnish\/etc\/default_3.0.vcl","new_file":"provision\/varnish\/etc\/default_3.0.vcl","new_contents":"# This is a basic VCL configuration file for PageCache powered by Varnish for Magento module.\n\nimport std;\ninclude \"local.vcl\";\n\nsub vcl_recv {\n if (req.restarts == 0) {\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"DELETE\" &&\n req.request != \"PURGE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n # purge request\n if (req.request == \"PURGE\") {\n if (!client.ip ~ purge) {\n error 405 \"Not allowed.\";\n }\n \/\/ban(\"obj.http.X-Purge-Host ~ \" + req.http.X-Purge-Host + \" && obj.http.X-Purge-URL ~ \" + req.http.X-Purge-Regex + \" && obj.http.Content-Type ~ \" + req.http.X-Purge-Content-Type);\n \/\/error 200 \"Purged.\";\n return(lookup);\n }\n\n if (req.request == \"BAN\") {\n if(!client.ip ~ purge) {\n error 405 \"Not allowed.\";\n }\n if (req.http.X-Cache-Tags) {\n ban(\"obj.http.X-Host ~ \" + req.http.X-Host\n + \" && obj.http.X-Url ~ \" + req.http.X-Url\n + \" && obj.http.content-type ~ \" + req.http.X-Content-Type\n + \" && obj.http.X-Cache-Tags ~ \" + req.http.X-Cache-Tags\n );\n } else {\n\/\/ ban(\"req.url ~ \"+req.url+\" && req.http.host == \"+req.http.host);\n ban(\"obj.http.X-Purge-Host ~ \" + req.http.X-Purge-Host + \" && obj.http.X-Purge-URL ~ \" + req.http.X-Purge-Regex + \" && obj.http.Content-Type ~ \" + req.http.X-Purge-Content-Type);\n }\n error 200 \"Banned \" + req.http.host + \" \" + req.url;\n }\n\n\n # no-cache request from authorized ip to warmup the cache\n if (req.http.Cache-Control ~ \"no-cache\" && client.ip ~ purge) {\n \t\tset req.hash_always_miss = true;\n \t}\n\n\n # switch to admin backend configuration\n if (req.http.cookie ~ \"adminhtml=\") {\n set req.backend = admin;\n }\n\n # tell backend that esi is supported\n set req.http.X-ESI-Capability = \"on\";\n\n # we only deal with GET and HEAD by default\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n return (pass);\n }\n\n # normalize url in case of leading HTTP scheme and domain\n set req.url = regsub(req.url, \"^http[s]?:\/\/[^\/]+\", \"\");\n\n # Normalize the header, remove the port\n \tset req.http.host = regsub(req.http.host, \":[0-9]+\", \"\");\n\n # collect all cookies\n std.collect(req.http.Cookie);\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(media|js|skin)\/.*\\.(png|jpg|jpeg|gif|css|js|swf|ico)$\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n # formkey lookup\n if (req.url ~ \"\/varnishcache\/getformkey\/\") {\n # check for formkey in cookie\n if (req.http.Cookie ~ \"PAGECACHE_FORMKEY\") {\n set req.http.X-Pagecache-Formkey = regsub(req.http.cookie, \".*PAGECACHE_FORMKEY=([^;]*)(;*.*)?\", \"\\1\");\n } else {\n # create formkey once\n set req.http.X-Pagecache-Formkey-Raw = req.http.Cookie + client.ip + req.xid;\n C{\n char *result = generate_formkey(VRT_GetHdr(sp, HDR_REQ, \"\\030X-Pagecache-Formkey-Raw:\"));\n VRT_SetHdr(sp, HDR_REQ, \"\\024X-Pagecache-Formkey:\", result, vrt_magic_string_end);\n }C\n }\n unset req.http.X-Pagecache-Formkey-Raw;\n error 760 req.http.X-Pagecache-Formkey;\n }\n\n # do not cache any page from index files\n if (req.url ~ \"^\/(index)\") {\n return (pass);\n }\n\n # as soon as we have a NO_CACHE cookie pass request\n if (req.http.cookie ~ \"NO_CACHE=\") {\n return (pass);\n }\n\n # normalize Accept-Encoding header\n # http:\/\/varnish.projects.linpro.no\/wiki\/FAQ\/Compression\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|flv)$\") {\n # No point in compressing these\n remove req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\" && req.http.user-agent !~ \"MSIE\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n # unknown algorithm\n remove req.http.Accept-Encoding;\n }\n }\n\n # remove Google gclid parameters\n set req.url = regsuball(req.url, \"\\?gclid=[^&]+$\", \"\"); # strips when QS = \"?gclid=AAA\"\n set req.url = regsuball(req.url, \"\\?gclid=[^&]+&\", \"?\"); # strips when QS = \"?gclid=AAA&foo=bar\"\n set req.url = regsuball(req.url, \"&gclid=[^&]+\", \"\"); # strips when QS = \"?foo=bar&gclid=AAA\" or QS = \"?foo=bar&gclid=AAA&bar=baz\"\n\n if (req.http.Cookie) {\n \t\tif (req.http.cookie !~ \"PHPSESSID\" && req.http.cookie ~ \"REMEMBERME\") {\n \t\t\treturn(pass);\n \t\t}\n\n \t\tif (req.http.Cookie ~ \"wordpress_logged_in_\" || req.http.Cookie ~ \"woocommerce_\" || req.http.Cookie ~ \"wp_postpass\" || req.http.Cookie ~ \"DokuWiki\"){\n \t\t\treturn (pass);\n \t\t} else {\n \t\t\tif (req.url ~ \"\\.(png|gif|jpg|swf|css|js)\\??.*?$\") {\n \t\t\t\tunset req.http.Cookie;\n \t\t\t} else {\n \t\t\t\t\/* Warning: Not a pretty solution *\/\n \t\t\t\t\/* Prefix header containing cookies with ';' *\/\n \t\t\t\tset req.http.Cookie = \";\" + req.http.Cookie;\n \t\t\t\t\/* Remove any spaces after ';' in header containing cookies *\/\n \t\t\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n \t\t\t\t\/* Prefix cookies we want to preserve with one space *\/\n \t\t\t\t\/* 'S{1,2}ESS[a-z0-9]+' is the regular expression matching a Drupal session cookie ({1,2} added for HTTPS support) *\/\n \t\t\t\t\/* 'NO_CACHE' is usually set after a POST request to make sure issuing user see the results of his post *\/\n \t\t\t\t\/* Keep in mind we should add here any cookie that should reach the backend such as splahs avoiding cookies *\/\n \t\t\t\tset req.http.Cookie = regsuball(req.http.Cookie, \";(ow_cookie_notice|PHPSESSID|NO_CACHE)=\", \"; \\1=\");\n \t\t\t\t\/* Remove from the header any single Cookie not prefixed with a space until next ';' separator *\/\n \t\t\t\tset req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n \t\t\t\t\/* Remove any '; ' at the start or the end of the header *\/\n \t\t\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n \t\t\t}\n\n \t\t\tif (req.http.Cookie == \"\") {\n \t\t\t\t\/* If there are no remaining cookies, remove the cookie header. *\/\n \t\t\t\tunset req.http.Cookie;\n \t\t\t}\n \t\t}\n \t}\n\n\/\/ return (lookup);\n\n}\n\n# sub vcl_pipe {\n# # Note that only the first request to the backend will have\n# # X-Forwarded-For set. If you use X-Forwarded-For and want to\n# # have it set for all requests, make sure to have:\n# # set bereq.http.connection = \"close\";\n# # here. It is not set by default as it might break some broken web\n# # applications, like IIS with NTLM authentication.\n# return (pipe);\n# }\n\n# sub vcl_pass {\n# return (pass);\n# }\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n\n if (req.http.cookie ~ \"PAGECACHE_ENV=\") {\n set req.http.pageCacheEnv = regsub(\n req.http.cookie,\n \"(.*)PAGECACHE_ENV=([^;]*)(.*)\",\n \"\\2\"\n );\n hash_data(req.http.pageCacheEnv);\n remove req.http.pageCacheEnv;\n }\n\n if (!(req.url ~ \"^\/(media|js|skin)\/.*\\.(png|jpg|jpeg|gif|css|js|swf|ico)$\")) {\n call design_exception;\n }\n\n \/* Hash cookie data\n As requests with same URL and host can produce diferent results when issued with different cookies,\n we need to store items hashed with the associated cookies. Note that cookies are already sanitized when we reach this point.\n *\/\n if (req.http.Cookie) {\n \/* Include cookie in cache hash *\/\n hash_data(req.http.Cookie);\n }\n\n return (hash);\n}\n\nsub vcl_hit {\n\tif (req.request == \"PURGE\") {\n\t\tpurge;\n\t\terror 204 \"Purged\";\n\t}\n}\n\n# The purge in vcl_miss is necessary to purge all variants in the cases where\n# you hit an object, but miss a particular variant.\nsub vcl_miss {\n\tif (req.request == \"PURGE\") {\n\t\tpurge;\n\t\terror 204 \"Purged (Not in cache)\";\n\t}\n}\n\nsub vcl_fetch {\n set beresp.http.X-Backend = beresp.backend.name;\n if (beresp.status >= 500) {\n # let SOAP errors pass - better debugging\n if ((beresp.http.Content-Type ~ \"text\/xml\") || (req.url ~ \"^\/errors\/\")) {\n return (deliver);\n }\n set beresp.saintmode = 10s;\n return (restart);\n }\n set beresp.grace = 5m;\n\n # enable ESI feature\n set beresp.do_esi = true;\n\n # add ban-lurker tags to object\n set beresp.http.X-Purge-URL = req.url;\n set beresp.http.X-Purge-Host = req.http.host;\n\n if (beresp.status == 200 || beresp.status == 301 || beresp.status == 404) {\n if (beresp.http.Content-Type ~ \"text\/html\" || beresp.http.Content-Type ~ \"text\/xml\") {\n \/* By default, Varnish3 ignores Cache-Control: no-cache and private\n https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/increasing_your_hitrate.html#cache-control\n *\/\n if (beresp.http.Cache-Control ~ \"private\" ||\n beresp.http.Cache-Control ~ \"no-cache\" ||\n beresp.http.Cache-Control ~ \"no-store\"\n ) {\n return (hit_for_pass);\n }\n if ((beresp.http.Set-Cookie ~ \"NO_CACHE=\") || (beresp.ttl < 1s)) {\n set beresp.ttl = 0s;\n return (hit_for_pass);\n }\n if (req.url ~ \"wp-(login|admin)|login\" || req.url ~ \"preview=true\") {\n \t\treturn (hit_for_pass);\n \t}\n\n # marker for vcl_deliver to reset Age:\n set beresp.http.magicmarker = \"1\";\n\n # Don't cache cookies\n unset beresp.http.set-cookie;\n } else {\n # set default TTL value for static content\n set beresp.ttl = 4h;\n }\n return (deliver);\n }\n\n return (hit_for_pass);\n}\n\nsub vcl_deliver {\n # debug info\n if (resp.http.X-Cache-Debug || client.ip ~ purge) {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n set resp.http.X-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n set resp.http.X-Cache-Expires = resp.http.Expires;\n } else {\n # remove Varnish\/proxy header\n remove resp.http.X-Varnish;\n remove resp.http.Via;\n remove resp.http.Age;\n remove resp.http.X-Purge-URL;\n remove resp.http.X-Purge-Host;\n remove resp.http.X-Powered-By;\n \tremove resp.http.Server;\n }\n\n if (resp.http.magicmarker) {\n # Remove the magic marker\n unset resp.http.magicmarker;\n\n set resp.http.Cache-Control = \"no-store, no-cache, must-revalidate, post-check=0, pre-check=0\";\n set resp.http.Pragma = \"no-cache\";\n set resp.http.Expires = \"Mon, 31 Mar 2008 10:00:00 GMT\";\n set resp.http.Age = \"0\";\n }\n}\n\nsub vcl_error {\n # workaround for possible security issue\n if (req.url ~ \"^\\s\") {\n set obj.status = 400;\n set obj.response = \"Malformed request\";\n synthetic \"\";\n return(deliver);\n }\n\n # formkey request\n if (obj.status == 760) {\n set obj.status = 200;\n\t synthetic obj.response;\n return(deliver);\n }\n\n # redirect request\n if (obj.status == 750) {\n set obj.http.Location = obj.response;\n set obj.status = 301;\n return(deliver);\n }\n\n # error 200\n if (obj.status == 200) {\n return (deliver);\n }\n\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + obj.status + \" \" + obj.response + {\"<\/h1>\n <p>\"} + obj.response + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"};\n return (deliver);\n}\n\n\n# sub vcl_fini {\n# return (ok);\n# }\n\nsub design_exception {\n}\n\nC{\n #include <string.h>\n #include <stdio.h>\n #include <stdlib.h>\n #include <openssl\/md5.h>\n\n \/**\n * create md5 hash of string and return it\n *\/\n char *generate_formkey(char *string) {\n \/\/ generate md5\n unsigned char result[MD5_DIGEST_LENGTH];\n MD5((const unsigned char *)string, strlen(string), result);\n\n \/\/ convert to chars\n static char md5string[MD5_DIGEST_LENGTH + 1];\n const char *hex = \"0123456789ABCDEF\";\n unsigned char *pin = result;\n char *pout = md5string;\n\n for(; pin < result + sizeof(result); pout+=2, pin++) {\n pout[0] = hex[(*pin>>4) & 0xF];\n pout[1] = hex[ *pin & 0xF];\n }\n pout[-1] = 0;\n\n \/\/ return md5\n return md5string;\n }\n}C\n","old_contents":"# This is a basic VCL configuration file for PageCache powered by Varnish for Magento module.\n\n# default backend definition. Set this to point to your content server.\nbackend default {\n .host = \"backend\";\n .port = \"80\";\n}\n\n# admin backend with longer timeout values. Set this to the same IP & port as your default server.\nbackend admin {\n .host = \"backend\";\n .port = \"80\";\n .first_byte_timeout = 18000s;\n .between_bytes_timeout = 18000s;\n}\n\n# add your Magento server IP to allow purges from the backend\nacl purge {\n \"localhost\";\n \"127.0.0.1\";\n \"172.17.0.1\"; # Ip dell'host docker\n \"83.103.96.33\"; # Ip della rete more\n}\n\nimport std;\n\nsub vcl_recv {\n if (req.restarts == 0) {\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"DELETE\" &&\n req.request != \"PURGE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n # purge request\n if (req.request == \"PURGE\") {\n if (!client.ip ~ purge) {\n error 405 \"Not allowed.\";\n }\n \/\/ban(\"obj.http.X-Purge-Host ~ \" + req.http.X-Purge-Host + \" && obj.http.X-Purge-URL ~ \" + req.http.X-Purge-Regex + \" && obj.http.Content-Type ~ \" + req.http.X-Purge-Content-Type);\n \/\/error 200 \"Purged.\";\n return(lookup);\n }\n\n if (req.request == \"BAN\") {\n if(!client.ip ~ purge) {\n error 405 \"Not allowed.\";\n }\n if (req.http.X-Cache-Tags) {\n ban(\"obj.http.X-Host ~ \" + req.http.X-Host\n + \" && obj.http.X-Url ~ \" + req.http.X-Url\n + \" && obj.http.content-type ~ \" + req.http.X-Content-Type\n + \" && obj.http.X-Cache-Tags ~ \" + req.http.X-Cache-Tags\n );\n } else {\n\/\/ ban(\"req.url ~ \"+req.url+\" && req.http.host == \"+req.http.host);\n ban(\"obj.http.X-Purge-Host ~ \" + req.http.X-Purge-Host + \" && obj.http.X-Purge-URL ~ \" + req.http.X-Purge-Regex + \" && obj.http.Content-Type ~ \" + req.http.X-Purge-Content-Type);\n }\n error 200 \"Banned \" + req.http.host + \" \" + req.url;\n }\n\n\n # no-cache request from authorized ip to warmup the cache\n if (req.http.Cache-Control ~ \"no-cache\" && client.ip ~ purge) {\n \t\tset req.hash_always_miss = true;\n \t}\n\n\n # switch to admin backend configuration\n if (req.http.cookie ~ \"adminhtml=\") {\n set req.backend = admin;\n }\n\n # tell backend that esi is supported\n set req.http.X-ESI-Capability = \"on\";\n\n # we only deal with GET and HEAD by default\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n return (pass);\n }\n\n # normalize url in case of leading HTTP scheme and domain\n set req.url = regsub(req.url, \"^http[s]?:\/\/[^\/]+\", \"\");\n\n # Normalize the header, remove the port\n \tset req.http.host = regsub(req.http.host, \":[0-9]+\", \"\");\n\n # collect all cookies\n std.collect(req.http.Cookie);\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(media|js|skin)\/.*\\.(png|jpg|jpeg|gif|css|js|swf|ico)$\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n # formkey lookup\n if (req.url ~ \"\/varnishcache\/getformkey\/\") {\n # check for formkey in cookie\n if (req.http.Cookie ~ \"PAGECACHE_FORMKEY\") {\n set req.http.X-Pagecache-Formkey = regsub(req.http.cookie, \".*PAGECACHE_FORMKEY=([^;]*)(;*.*)?\", \"\\1\");\n } else {\n # create formkey once\n set req.http.X-Pagecache-Formkey-Raw = req.http.Cookie + client.ip + req.xid;\n C{\n char *result = generate_formkey(VRT_GetHdr(sp, HDR_REQ, \"\\030X-Pagecache-Formkey-Raw:\"));\n VRT_SetHdr(sp, HDR_REQ, \"\\024X-Pagecache-Formkey:\", result, vrt_magic_string_end);\n }C\n }\n unset req.http.X-Pagecache-Formkey-Raw;\n error 760 req.http.X-Pagecache-Formkey;\n }\n\n # do not cache any page from index files\n if (req.url ~ \"^\/(index)\") {\n return (pass);\n }\n\n # as soon as we have a NO_CACHE cookie pass request\n if (req.http.cookie ~ \"NO_CACHE=\") {\n return (pass);\n }\n\n # normalize Accept-Encoding header\n # http:\/\/varnish.projects.linpro.no\/wiki\/FAQ\/Compression\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|flv)$\") {\n # No point in compressing these\n remove req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\" && req.http.user-agent !~ \"MSIE\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n # unknown algorithm\n remove req.http.Accept-Encoding;\n }\n }\n\n # remove Google gclid parameters\n set req.url = regsuball(req.url, \"\\?gclid=[^&]+$\", \"\"); # strips when QS = \"?gclid=AAA\"\n set req.url = regsuball(req.url, \"\\?gclid=[^&]+&\", \"?\"); # strips when QS = \"?gclid=AAA&foo=bar\"\n set req.url = regsuball(req.url, \"&gclid=[^&]+\", \"\"); # strips when QS = \"?foo=bar&gclid=AAA\" or QS = \"?foo=bar&gclid=AAA&bar=baz\"\n\n if (req.http.Cookie) {\n \t\tif (req.http.cookie !~ \"PHPSESSID\" && req.http.cookie ~ \"REMEMBERME\") {\n \t\t\treturn(pass);\n \t\t}\n\n \t\tif (req.http.Cookie ~ \"wordpress_logged_in_\" || req.http.Cookie ~ \"woocommerce_\" || req.http.Cookie ~ \"wp_postpass\" || req.http.Cookie ~ \"DokuWiki\"){\n \t\t\treturn (pass);\n \t\t} else {\n \t\t\tif (req.url ~ \"\\.(png|gif|jpg|swf|css|js)\\??.*?$\") {\n \t\t\t\tunset req.http.Cookie;\n \t\t\t} else {\n \t\t\t\t\/* Warning: Not a pretty solution *\/\n \t\t\t\t\/* Prefix header containing cookies with ';' *\/\n \t\t\t\tset req.http.Cookie = \";\" + req.http.Cookie;\n \t\t\t\t\/* Remove any spaces after ';' in header containing cookies *\/\n \t\t\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n \t\t\t\t\/* Prefix cookies we want to preserve with one space *\/\n \t\t\t\t\/* 'S{1,2}ESS[a-z0-9]+' is the regular expression matching a Drupal session cookie ({1,2} added for HTTPS support) *\/\n \t\t\t\t\/* 'NO_CACHE' is usually set after a POST request to make sure issuing user see the results of his post *\/\n \t\t\t\t\/* Keep in mind we should add here any cookie that should reach the backend such as splahs avoiding cookies *\/\n \t\t\t\tset req.http.Cookie = regsuball(req.http.Cookie, \";(ow_cookie_notice|PHPSESSID|NO_CACHE)=\", \"; \\1=\");\n \t\t\t\t\/* Remove from the header any single Cookie not prefixed with a space until next ';' separator *\/\n \t\t\t\tset req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n \t\t\t\t\/* Remove any '; ' at the start or the end of the header *\/\n \t\t\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n \t\t\t}\n\n \t\t\tif (req.http.Cookie == \"\") {\n \t\t\t\t\/* If there are no remaining cookies, remove the cookie header. *\/\n \t\t\t\tunset req.http.Cookie;\n \t\t\t}\n \t\t}\n \t}\n\n\/\/ return (lookup);\n\n}\n\n# sub vcl_pipe {\n# # Note that only the first request to the backend will have\n# # X-Forwarded-For set. If you use X-Forwarded-For and want to\n# # have it set for all requests, make sure to have:\n# # set bereq.http.connection = \"close\";\n# # here. It is not set by default as it might break some broken web\n# # applications, like IIS with NTLM authentication.\n# return (pipe);\n# }\n\n# sub vcl_pass {\n# return (pass);\n# }\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n\n if (req.http.cookie ~ \"PAGECACHE_ENV=\") {\n set req.http.pageCacheEnv = regsub(\n req.http.cookie,\n \"(.*)PAGECACHE_ENV=([^;]*)(.*)\",\n \"\\2\"\n );\n hash_data(req.http.pageCacheEnv);\n remove req.http.pageCacheEnv;\n }\n\n if (!(req.url ~ \"^\/(media|js|skin)\/.*\\.(png|jpg|jpeg|gif|css|js|swf|ico)$\")) {\n call design_exception;\n }\n\n \/* Hash cookie data\n As requests with same URL and host can produce diferent results when issued with different cookies,\n we need to store items hashed with the associated cookies. Note that cookies are already sanitized when we reach this point.\n *\/\n if (req.http.Cookie) {\n \/* Include cookie in cache hash *\/\n hash_data(req.http.Cookie);\n }\n\n return (hash);\n}\n\nsub vcl_hit {\n\tif (req.request == \"PURGE\") {\n\t\tpurge;\n\t\terror 204 \"Purged\";\n\t}\n}\n\n# The purge in vcl_miss is necessary to purge all variants in the cases where\n# you hit an object, but miss a particular variant.\nsub vcl_miss {\n\tif (req.request == \"PURGE\") {\n\t\tpurge;\n\t\terror 204 \"Purged (Not in cache)\";\n\t}\n}\n\nsub vcl_fetch {\n set beresp.http.X-Backend = beresp.backend.name;\n if (beresp.status >= 500) {\n # let SOAP errors pass - better debugging\n if ((beresp.http.Content-Type ~ \"text\/xml\") || (req.url ~ \"^\/errors\/\")) {\n return (deliver);\n }\n set beresp.saintmode = 10s;\n return (restart);\n }\n set beresp.grace = 5m;\n\n # enable ESI feature\n set beresp.do_esi = true;\n\n # add ban-lurker tags to object\n set beresp.http.X-Purge-URL = req.url;\n set beresp.http.X-Purge-Host = req.http.host;\n\n if (beresp.status == 200 || beresp.status == 301 || beresp.status == 404) {\n if (beresp.http.Content-Type ~ \"text\/html\" || beresp.http.Content-Type ~ \"text\/xml\") {\n \/* By default, Varnish3 ignores Cache-Control: no-cache and private\n https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/increasing_your_hitrate.html#cache-control\n *\/\n if (beresp.http.Cache-Control ~ \"private\" ||\n beresp.http.Cache-Control ~ \"no-cache\" ||\n beresp.http.Cache-Control ~ \"no-store\"\n ) {\n return (hit_for_pass);\n }\n if ((beresp.http.Set-Cookie ~ \"NO_CACHE=\") || (beresp.ttl < 1s)) {\n set beresp.ttl = 0s;\n return (hit_for_pass);\n }\n if (req.url ~ \"wp-(login|admin)|login\" || req.url ~ \"preview=true\") {\n \t\treturn (hit_for_pass);\n \t}\n\n # marker for vcl_deliver to reset Age:\n set beresp.http.magicmarker = \"1\";\n\n # Don't cache cookies\n unset beresp.http.set-cookie;\n } else {\n # set default TTL value for static content\n set beresp.ttl = 4h;\n }\n return (deliver);\n }\n\n return (hit_for_pass);\n}\n\nsub vcl_deliver {\n # debug info\n if (resp.http.X-Cache-Debug || client.ip ~ purge) {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n set resp.http.X-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n set resp.http.X-Cache-Expires = resp.http.Expires;\n } else {\n # remove Varnish\/proxy header\n remove resp.http.X-Varnish;\n remove resp.http.Via;\n remove resp.http.Age;\n remove resp.http.X-Purge-URL;\n remove resp.http.X-Purge-Host;\n remove resp.http.X-Powered-By;\n \tremove resp.http.Server;\n }\n\n if (resp.http.magicmarker) {\n # Remove the magic marker\n unset resp.http.magicmarker;\n\n set resp.http.Cache-Control = \"no-store, no-cache, must-revalidate, post-check=0, pre-check=0\";\n set resp.http.Pragma = \"no-cache\";\n set resp.http.Expires = \"Mon, 31 Mar 2008 10:00:00 GMT\";\n set resp.http.Age = \"0\";\n }\n}\n\nsub vcl_error {\n # workaround for possible security issue\n if (req.url ~ \"^\\s\") {\n set obj.status = 400;\n set obj.response = \"Malformed request\";\n synthetic \"\";\n return(deliver);\n }\n\n # formkey request\n if (obj.status == 760) {\n set obj.status = 200;\n\t synthetic obj.response;\n return(deliver);\n }\n\n # redirect request\n if (obj.status == 750) {\n set obj.http.Location = obj.response;\n set obj.status = 301;\n return(deliver);\n }\n\n # error 200\n if (obj.status == 200) {\n return (deliver);\n }\n\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + obj.status + \" \" + obj.response + {\"<\/h1>\n <p>\"} + obj.response + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"};\n return (deliver);\n}\n\n\n# sub vcl_fini {\n# return (ok);\n# }\n\nsub design_exception {\n}\n\nC{\n #include <string.h>\n #include <stdio.h>\n #include <stdlib.h>\n #include <openssl\/md5.h>\n\n \/**\n * create md5 hash of string and return it\n *\/\n char *generate_formkey(char *string) {\n \/\/ generate md5\n unsigned char result[MD5_DIGEST_LENGTH];\n MD5((const unsigned char *)string, strlen(string), result);\n\n \/\/ convert to chars\n static char md5string[MD5_DIGEST_LENGTH + 1];\n const char *hex = \"0123456789ABCDEF\";\n unsigned char *pin = result;\n char *pout = md5string;\n\n for(; pin < result + sizeof(result); pout+=2, pin++) {\n pout[0] = hex[(*pin>>4) & 0xF];\n pout[1] = hex[ *pin & 0xF];\n }\n pout[-1] = 0;\n\n \/\/ return md5\n return md5string;\n }\n}C\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"8fb095c00a588033f149c219117747e25662a641","subject":"do not cache pages starting with \/search","message":"do not cache pages starting with \/search\n","repos":"alexisbellido\/salt-django-stack,alexisbellido\/salt-django-stack,alexisbellido\/salt-django-stack,alexisbellido\/salt-django-stack","old_file":"zinibu\/varnish\/files\/etc\/varnish\/default-4.vcl","new_file":"zinibu\/varnish\/files\/etc\/varnish\/default-4.vcl","new_contents":"# Managed by saltstack.\n# host id: {{ salt['grains.get']('id', '') }}\n{% set settings = salt['pillar.get']('varnish', {}) -%}\n{% set zinibu_basic = salt['pillar.get']('zinibu_basic', {}) -%}\n#\n# This is an example VCL file for Varnish.\n#\n# It does not do anything by default, delegating control to the\n# builtin VCL. The builtin VCL is called when there is no explicit\n# return statement.\n#\n# See the VCL chapters in the Users Guide at https:\/\/www.varnish-cache.org\/docs\/\n# and https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExamples for more examples.\n\n# Marker to tell the VCL compiler that this VCL has been adapted to the\n# new 4.0 format.\nvcl 4.0;\n\nimport std;\nimport directors;\n\n{%- for id, haproxy_server in zinibu_basic.project.haproxy_servers.iteritems() %}\nbackend bk_appsrv_static_{{ id }} {\n .host = \"{{ haproxy_server.private_ip }}\";\n .port = \"{{ haproxy_server.port }}\";\n .probe = {\n .url = \"{{ zinibu_basic.project.haproxy_check }}\";\n .expected_response = 200;\n .timeout = 1s;\n .interval = 3s;\n .window = 2;\n .threshold = 2;\n .initial = 2;\n }\n}\n{%- endfor %}\n\nsub vcl_init {\n new bar = directors.round_robin();\n{%- for id, haproxy_server in zinibu_basic.project.haproxy_servers.iteritems() %}\n bar.add_backend(bk_appsrv_static_{{ id }});\n{%- endfor %}\n}\n\nacl purge {\n \"localhost\";\n \"127.0.0.1\";\n}\n\nsub vcl_recv {\n # Happens before we check if we have this in cache already.\n #\n # Typically you clean up the request here, removing cookies you don't need,\n # rewriting the request, etc.\n\n # debug bypass\n #return (pass);\n\n #std.log(\"vcl recv: \"+req.request);\n\n # Health Checking\n if (req.url == \"{{ zinibu_basic.project.varnish_check }}\") {\n return (synth(751, \"health check OK!\"));\n }\n\n # send all traffic to the bar director:\n set req.backend_hint = bar.backend();\n\n # Normalize the header, remove the port (in case you're testing this on various TCP ports)\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n # Normalize the query arguments\n set req.url = std.querysort(req.url);\n\n # Allow purging\n if (req.method == \"PURGE\") {\n if (!client.ip ~ purge) { # purge is the ACL defined at the begining\n\t # Not from an allowed IP? Then die with an error.\n return (synth(405, \"This IP is not allowed to send PURGE requests.\"));\n }\n # If you got this stage (and didn't error out above), purge the cached result\n return (purge);\n }\n\n # Only deal with \"normal\" types\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"PATCH\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n # Implementing websocket support (https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html)\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n # Only cache GET or HEAD requests. This makes sure the POST requests are always passed.\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n if (req.url ~ \"^\/search\/\") {\n return (pass);\n }\n\n # Don't think is needed anymore, just check for sessionid cookie\n # Django is setting this cookie so we only check here\n #if (req.http.Cookie ~ \"LOGGED_IN\") {\n # return (pass);\n #}\n\n if (req.http.Authorization) {\n # Not cacheable by default\n return (pass);\n }\n\n set req.http.X-Varnish-Use-Cache = \"TRUE\";\n # unless Django's sessionid or message cookies are in the request, don't pass ANY cookies (referral_source, utm, etc)\n # also, anything inside \/media or \/static should be cached\n if (req.url ~ \"^\/media\" || req.url ~ \"^\/static\" || (req.http.Cookie !~ \"logged_in\" && req.http.Cookie !~ \"sessionid\" && req.http.Cookie !~ \"messages\" && req.http.Cookie !~ \"csrftoken\")) {\n unset req.http.Cookie;\n return (hash);\n }\n\n # Large static files are delivered directly to the end-user without\n # waiting for Varnish to fully read the file first.\n # Varnish 4 fully supports Streaming, so set do_stream in vcl_backend_response()\n if (req.url ~ \"^[^?]*\\.(7z|avi|bz2|flac|flv|gz|mka|mkv|mov|mp3|mp4|mpeg|mpg|ogg|ogm|opus|rar|tar|tgz|tbz|txz|wav|webm|xz|zip)(\\?.*)?$\") {\n unset req.http.Cookie;\n return (hash);\n }\n\n # Remove all cookies for static files\n # A valid discussion could be held on this line: do you really need to cache static files that don't cause load? Only if you have memory left.\n # Sure, there's disk I\/O, but chances are your OS will already have these files in their buffers (thus memory).\n # Before you blindly enable this, have a read here: https:\/\/ma.ttias.be\/stop-caching-static-files\/\n if (req.url ~ \"^[^?]*\\.(7z|avi|bmp|bz2|css|csv|doc|docx|eot|flac|flv|gif|gz|ico|jpeg|jpg|js|less|mka|mkv|mov|mp3|mp4|mpeg|mpg|odt|otf|ogg|ogm|opus|pdf|png|ppt|pptx|rar|rtf|svg|svgz|swf|tar|tbz|tgz|ttf|txt|txz|wav|webm|webp|woff|woff2|xls|xlsx|xml|xz|zip)(\\?.*)?$\") {\n unset req.http.Cookie;\n return (hash);\n }\n \n # Are there cookies left with only spaces or that are empty?\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.Cookie;\n }\n\n # Some generic cookie manipulation, useful for all templates that follow\n # Remove the \"has_js\" cookie\n set req.http.Cookie = regsuball(req.http.Cookie, \"has_js=[^;]+(; )?\", \"\");\n\n # Remove any Google Analytics based cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__utm.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"_ga=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"_gat=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmctr=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmcmd.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmccn.=[^;]+(; )?\", \"\");\n\n # Remove DoubleClick offensive cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__gads=[^;]+(; )?\", \"\");\n\n # Remove the Quant Capital cookies (added by some plugin, all __qca)\n #set req.http.Cookie = regsuball(req.http.Cookie, \"__qc.=[^;]+(; )?\", \"\");\n\n # Remove the AddThis cookies\n #set req.http.Cookie = regsuball(req.http.Cookie, \"__atuv.=[^;]+(; )?\", \"\");\n\n # Remove a \";\" prefix in the cookie if present\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n\n if (req.http.Cache-Control ~ \"(?i)no-cache\") {\n #if (req.http.Cache-Control ~ \"(?i)no-cache\" && client.ip ~ editors) { # create the acl editors if you want to restrict the Ctrl-F5\n # http:\/\/varnish.projects.linpro.no\/wiki\/VCLExampleEnableForceRefresh\n # Ignore requests via proxy caches and badly behaved crawlers\n # like msnbot that send no-cache with every request.\n if (! (req.http.Via || req.http.User-Agent ~ \"(?i)bot\" || req.http.X-Purge)) {\n #set req.hash_always_miss = true; # Doesn't seems to refresh the object in the cache\n return(purge); # Couple this with restart in vcl_purge and X-Purge header to avoid loops\n }\n }\n\n # Strip hash, server doesn't need it.\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n # Strip a trailing ? if it exists\n if (req.url ~ \"\\?$\") {\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n return (hash);\n}\n\nsub vcl_pipe {\n # Called upon entering pipe mode.\n # In this mode, the request is passed on to the backend, and any further data from both the client\n # and backend is passed on unaltered until either end closes the connection. Basically, Varnish will\n # degrade into a simple TCP proxy, shuffling bytes back and forth. For a connection in pipe mode,\n # no other VCL subroutine will ever get called after vcl_pipe.\n\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n # set bereq.http.connection = \"close\";\n # here. It is not set by default as it might break some broken web\n # applications, like IIS with NTLM authentication.\n\n # set bereq.http.Connection = \"Close\";\n\n # Implementing websocket support (https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html)\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n\n return (pipe);\n}\n\nsub vcl_pass {\n # Called upon entering pass mode. In this mode, the request is passed on to the backend, and the\n # backend's response is passed on to the client, but is not entered into the cache. Subsequent\n # requests submitted over the same client connection are handled normally.\n\n # return (pass);\n}\n\nsub vcl_hash {\n # Called after vcl_recv to create a hash value for the request. This is used as a key\n # to look up the object in Varnish.\n \n hash_data(req.url);\n \n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n \n # hash cookies for requests that have them\n if (req.http.Cookie) {\n hash_data(req.http.Cookie);\n }\n\n return (lookup);\n}\n\nsub vcl_backend_response {\n # Happens after we have read the response headers from the backend.\n #\n # Here you clean the response headers, removing silly Set-Cookie headers\n # and other mistakes your backend does.\n\n # Called after the response headers has been successfully retrieved from the backend.\n # Enable ESI\n # TODO see if I need to add conditions to enable ESI\n set beresp.do_esi = true;\n # and make sure everything under \/no-cache is, well, not cached\n if (bereq.url ~ \"^\/no-cache\/\") {\n set beresp.uncacheable = true;\n return(deliver); \n }\n\n # Pause ESI request and remove Surrogate-Control header\n if (beresp.http.Surrogate-Control ~ \"ESI\/1.0\") {\n unset beresp.http.Surrogate-Control;\n set beresp.do_esi = true;\n }\n\n # Enable cache for all static files\n # The same argument as the static caches from above: monitor your cache size, if you get data nuked out of it, consider giving up the static file cache.\n # Before you blindly enable this, have a read here: https:\/\/ma.ttias.be\/stop-caching-static-files\/\n if (bereq.url ~ \"^[^?]*\\.(7z|avi|bmp|bz2|css|csv|doc|docx|eot|flac|flv|gif|gz|ico|jpeg|jpg|js|less|mka|mkv|mov|mp3|mp4|mpeg|mpg|odt|otf|ogg|ogm|opus|pdf|png|ppt|pptx|rar|rtf|svg|svgz|swf|tar|tbz|tgz|ttf|txt|txz|wav|webm|webp|woff|woff2|xls|xlsx|xml|xz|zip)(\\?.*)?$\") {\n unset beresp.http.set-cookie;\n }\n\n # Large static files are delivered directly to the end-user without\n # waiting for Varnish to fully read the file first.\n # Varnish 4 fully supports Streaming, so use streaming here to avoid locking.\n if (bereq.url ~ \"^[^?]*\\.(7z|avi|bz2|flac|flv|gz|mka|mkv|mov|mp3|mp4|mpeg|mpg|ogg|ogm|opus|rar|tar|tgz|tbz|txz|wav|webm|xz|zip)(\\?.*)?$\") {\n unset beresp.http.set-cookie;\n set beresp.do_stream = true; # Check memory usage it'll grow in fetch_chunksize blocks (128k by default) if the backend doesn't send a Content-Length header, so only enable it for big objects\n set beresp.do_gzip = false; # Don't try to compress it for storage\n }\n\n # Sometimes, a 301 or 302 redirect formed via Apache's mod_rewrite can mess with the HTTP port that is being passed along.\n # This often happens with simple rewrite rules in a scenario where Varnish runs on :80 and Apache on :8080 on the same box.\n # A redirect can then often redirect the end-user to a URL on :8080, where it should be :80.\n # This may need finetuning on your setup.\n #\n # To prevent accidental replace, we only filter the 301\/302 redirects for now.\n if (beresp.status == 301 || beresp.status == 302) {\n set beresp.http.Location = regsub(beresp.http.Location, \":[0-9]+\", \"\");\n }\n\n # Set 2min cache if unset for static files\n if (beresp.ttl <= 0s || beresp.http.Set-Cookie || beresp.http.Vary == \"*\") {\n set beresp.ttl = 120s; # Important, you shouldn't rely on this, SET YOUR HEADERS in the backend\n set beresp.uncacheable = true;\n\n # Study and test this\n # Mark as \"Hit-For-Pass\" for the next 60 minutes - 24 hours\n #if (bereq.url ~ \"\\.(jpe?g|png|gif|pdf|gz|tgz|bz2|tbz|tar|zip|tiff|tif)$\" || bereq.url ~ \"\/(image|(image_(?:[^\/]|(?!view.*).+)))$\") {\n # set beresp.ttl = std.duration(beresp.http.age+\"s\",0s) + 6h;\n #} elseif (bereq.url ~ \"\\.(svg|swf|ico|mp3|mp4|m4a|ogg|mov|avi|wmv|flv)$\") {\n # set beresp.ttl = std.duration(beresp.http.age+\"s\",0s) + 6h;\n #} elseif (bereq.url ~ \"\\.(xls|vsd|doc|ppt|pps|vsd|doc|ppt|pps|xls|pdf|sxw|rar|odc|odb|odf|odg|odi|odp|ods|odt|sxc|sxd|sxi|sxw|dmg|torrent|deb|msi|iso|rpm)$\") {\n # set beresp.ttl = std.duration(beresp.http.age+\"s\",0s) + 6h;\n #} elseif (bereq.url ~ \"\\.(css|js)$\") {\n # set beresp.ttl = std.duration(beresp.http.age+\"s\",0s) + 24h;\n #} else {\n # set beresp.ttl = std.duration(beresp.http.age+\"s\",0s) + 1h;\n #}\n\n return (deliver);\n }\n\n # Don't cache 50x responses\n if (beresp.status == 500 || beresp.status == 502 || beresp.status == 503 || beresp.status == 504) {\n return (abandon);\n }\n\n # Allow stale content, in case the backend goes down.\n # make Varnish keep all objects for 6 hours beyond their TTL\n set beresp.grace = 6h;\n\n return (deliver);\n}\n\nsub vcl_deliver {\n # Happens when we have all the pieces we need, and are about to send the\n # response to the client.\n #\n # You can do accounting or modifying the final object here.\n\n # Called before a cached object is delivered to the client.\n\n if (obj.hits > 0) { # Add debug header to see if it's a HIT\/MISS and the number of hits, disable when not needed\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n\n # Please note that obj.hits behaviour changed in 4.0, now it counts per objecthead, not per object\n # and obj.hits may not be reset in some cases where bans are in use. See bug 1492 for details.\n # So take hits with a grain of salt\n set resp.http.X-Cache-Hits = obj.hits;\n\n # Remove some headers: PHP version\n unset resp.http.X-Powered-By;\n\n # Remove some headers: Apache version & OS\n unset resp.http.Server;\n unset resp.http.X-Drupal-Cache;\n unset resp.http.X-Varnish;\n unset resp.http.Via;\n unset resp.http.Link;\n unset resp.http.X-Generator;\n\n return (deliver);\n}\n\nsub vcl_purge {\n # Only handle actual PURGE HTTP methods, everything else is discarded\n if (req.method != \"PURGE\") {\n # restart request\n set req.http.X-Purge = \"Yes\";\n return(restart);\n }\n}\n\nsub vcl_synth {\n # Health check\n if (resp.status == 751) {\n set resp.status = 200;\n return (deliver);\n }\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n set resp.http.Retry-After = \"5\";\n synthetic (\"Error\");\n return (deliver);\n}\n","old_contents":"# Managed by saltstack.\n# host id: {{ salt['grains.get']('id', '') }}\n{% set settings = salt['pillar.get']('varnish', {}) -%}\n{% set zinibu_basic = salt['pillar.get']('zinibu_basic', {}) -%}\n#\n# This is an example VCL file for Varnish.\n#\n# It does not do anything by default, delegating control to the\n# builtin VCL. The builtin VCL is called when there is no explicit\n# return statement.\n#\n# See the VCL chapters in the Users Guide at https:\/\/www.varnish-cache.org\/docs\/\n# and https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExamples for more examples.\n\n# Marker to tell the VCL compiler that this VCL has been adapted to the\n# new 4.0 format.\nvcl 4.0;\n\nimport std;\nimport directors;\n\n{%- for id, haproxy_server in zinibu_basic.project.haproxy_servers.iteritems() %}\nbackend bk_appsrv_static_{{ id }} {\n .host = \"{{ haproxy_server.private_ip }}\";\n .port = \"{{ haproxy_server.port }}\";\n .probe = {\n .url = \"{{ zinibu_basic.project.haproxy_check }}\";\n .expected_response = 200;\n .timeout = 1s;\n .interval = 3s;\n .window = 2;\n .threshold = 2;\n .initial = 2;\n }\n}\n{%- endfor %}\n\nsub vcl_init {\n new bar = directors.round_robin();\n{%- for id, haproxy_server in zinibu_basic.project.haproxy_servers.iteritems() %}\n bar.add_backend(bk_appsrv_static_{{ id }});\n{%- endfor %}\n}\n\nacl purge {\n \"localhost\";\n \"127.0.0.1\";\n}\n\nsub vcl_recv {\n # Happens before we check if we have this in cache already.\n #\n # Typically you clean up the request here, removing cookies you don't need,\n # rewriting the request, etc.\n\n # debug bypass\n #return (pass);\n\n #std.log(\"vcl recv: \"+req.request);\n\n # Health Checking\n if (req.url == \"{{ zinibu_basic.project.varnish_check }}\") {\n return (synth(751, \"health check OK!\"));\n }\n\n # send all traffic to the bar director:\n set req.backend_hint = bar.backend();\n\n # Normalize the header, remove the port (in case you're testing this on various TCP ports)\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n # Normalize the query arguments\n set req.url = std.querysort(req.url);\n\n # Allow purging\n if (req.method == \"PURGE\") {\n if (!client.ip ~ purge) { # purge is the ACL defined at the begining\n\t # Not from an allowed IP? Then die with an error.\n return (synth(405, \"This IP is not allowed to send PURGE requests.\"));\n }\n # If you got this stage (and didn't error out above), purge the cached result\n return (purge);\n }\n\n # Only deal with \"normal\" types\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"PATCH\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n # Implementing websocket support (https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html)\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n # Only cache GET or HEAD requests. This makes sure the POST requests are always passed.\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n # Don't think is needed anymore, just check for sessionid cookie\n # Django is setting this cookie so we only check here\n #if (req.http.Cookie ~ \"LOGGED_IN\") {\n # return (pass);\n #}\n\n if (req.http.Authorization) {\n # Not cacheable by default\n return (pass);\n }\n\n set req.http.X-Varnish-Use-Cache = \"TRUE\";\n # unless Django's sessionid or message cookies are in the request, don't pass ANY cookies (referral_source, utm, etc)\n # also, anything inside \/media or \/static should be cached\n if (req.url ~ \"^\/media\" || req.url ~ \"^\/static\" || (req.http.Cookie !~ \"logged_in\" && req.http.Cookie !~ \"sessionid\" && req.http.Cookie !~ \"messages\" && req.http.Cookie !~ \"csrftoken\")) {\n unset req.http.Cookie;\n return (hash);\n }\n\n # Large static files are delivered directly to the end-user without\n # waiting for Varnish to fully read the file first.\n # Varnish 4 fully supports Streaming, so set do_stream in vcl_backend_response()\n if (req.url ~ \"^[^?]*\\.(7z|avi|bz2|flac|flv|gz|mka|mkv|mov|mp3|mp4|mpeg|mpg|ogg|ogm|opus|rar|tar|tgz|tbz|txz|wav|webm|xz|zip)(\\?.*)?$\") {\n unset req.http.Cookie;\n return (hash);\n }\n\n # Remove all cookies for static files\n # A valid discussion could be held on this line: do you really need to cache static files that don't cause load? Only if you have memory left.\n # Sure, there's disk I\/O, but chances are your OS will already have these files in their buffers (thus memory).\n # Before you blindly enable this, have a read here: https:\/\/ma.ttias.be\/stop-caching-static-files\/\n if (req.url ~ \"^[^?]*\\.(7z|avi|bmp|bz2|css|csv|doc|docx|eot|flac|flv|gif|gz|ico|jpeg|jpg|js|less|mka|mkv|mov|mp3|mp4|mpeg|mpg|odt|otf|ogg|ogm|opus|pdf|png|ppt|pptx|rar|rtf|svg|svgz|swf|tar|tbz|tgz|ttf|txt|txz|wav|webm|webp|woff|woff2|xls|xlsx|xml|xz|zip)(\\?.*)?$\") {\n unset req.http.Cookie;\n return (hash);\n }\n \n # Are there cookies left with only spaces or that are empty?\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.Cookie;\n }\n\n # Some generic cookie manipulation, useful for all templates that follow\n # Remove the \"has_js\" cookie\n set req.http.Cookie = regsuball(req.http.Cookie, \"has_js=[^;]+(; )?\", \"\");\n\n # Remove any Google Analytics based cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__utm.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"_ga=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"_gat=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmctr=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmcmd.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmccn.=[^;]+(; )?\", \"\");\n\n # Remove DoubleClick offensive cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__gads=[^;]+(; )?\", \"\");\n\n # Remove the Quant Capital cookies (added by some plugin, all __qca)\n #set req.http.Cookie = regsuball(req.http.Cookie, \"__qc.=[^;]+(; )?\", \"\");\n\n # Remove the AddThis cookies\n #set req.http.Cookie = regsuball(req.http.Cookie, \"__atuv.=[^;]+(; )?\", \"\");\n\n # Remove a \";\" prefix in the cookie if present\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n\n if (req.http.Cache-Control ~ \"(?i)no-cache\") {\n #if (req.http.Cache-Control ~ \"(?i)no-cache\" && client.ip ~ editors) { # create the acl editors if you want to restrict the Ctrl-F5\n # http:\/\/varnish.projects.linpro.no\/wiki\/VCLExampleEnableForceRefresh\n # Ignore requests via proxy caches and badly behaved crawlers\n # like msnbot that send no-cache with every request.\n if (! (req.http.Via || req.http.User-Agent ~ \"(?i)bot\" || req.http.X-Purge)) {\n #set req.hash_always_miss = true; # Doesn't seems to refresh the object in the cache\n return(purge); # Couple this with restart in vcl_purge and X-Purge header to avoid loops\n }\n }\n\n # Strip hash, server doesn't need it.\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n # Strip a trailing ? if it exists\n if (req.url ~ \"\\?$\") {\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n return (hash);\n}\n\nsub vcl_pipe {\n # Called upon entering pipe mode.\n # In this mode, the request is passed on to the backend, and any further data from both the client\n # and backend is passed on unaltered until either end closes the connection. Basically, Varnish will\n # degrade into a simple TCP proxy, shuffling bytes back and forth. For a connection in pipe mode,\n # no other VCL subroutine will ever get called after vcl_pipe.\n\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n # set bereq.http.connection = \"close\";\n # here. It is not set by default as it might break some broken web\n # applications, like IIS with NTLM authentication.\n\n # set bereq.http.Connection = \"Close\";\n\n # Implementing websocket support (https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html)\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n\n return (pipe);\n}\n\nsub vcl_pass {\n # Called upon entering pass mode. In this mode, the request is passed on to the backend, and the\n # backend's response is passed on to the client, but is not entered into the cache. Subsequent\n # requests submitted over the same client connection are handled normally.\n\n # return (pass);\n}\n\nsub vcl_hash {\n # Called after vcl_recv to create a hash value for the request. This is used as a key\n # to look up the object in Varnish.\n \n hash_data(req.url);\n \n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n \n # hash cookies for requests that have them\n if (req.http.Cookie) {\n hash_data(req.http.Cookie);\n }\n\n return (lookup);\n}\n\nsub vcl_backend_response {\n # Happens after we have read the response headers from the backend.\n #\n # Here you clean the response headers, removing silly Set-Cookie headers\n # and other mistakes your backend does.\n\n # Called after the response headers has been successfully retrieved from the backend.\n # Enable ESI\n # TODO see if I need to add conditions to enable ESI\n set beresp.do_esi = true;\n # and make sure everything under \/no-cache is, well, not cached\n if (bereq.url ~ \"^\/no-cache\/\") {\n set beresp.uncacheable = true;\n return(deliver); \n }\n\n # Pause ESI request and remove Surrogate-Control header\n if (beresp.http.Surrogate-Control ~ \"ESI\/1.0\") {\n unset beresp.http.Surrogate-Control;\n set beresp.do_esi = true;\n }\n\n # Enable cache for all static files\n # The same argument as the static caches from above: monitor your cache size, if you get data nuked out of it, consider giving up the static file cache.\n # Before you blindly enable this, have a read here: https:\/\/ma.ttias.be\/stop-caching-static-files\/\n if (bereq.url ~ \"^[^?]*\\.(7z|avi|bmp|bz2|css|csv|doc|docx|eot|flac|flv|gif|gz|ico|jpeg|jpg|js|less|mka|mkv|mov|mp3|mp4|mpeg|mpg|odt|otf|ogg|ogm|opus|pdf|png|ppt|pptx|rar|rtf|svg|svgz|swf|tar|tbz|tgz|ttf|txt|txz|wav|webm|webp|woff|woff2|xls|xlsx|xml|xz|zip)(\\?.*)?$\") {\n unset beresp.http.set-cookie;\n }\n\n # Large static files are delivered directly to the end-user without\n # waiting for Varnish to fully read the file first.\n # Varnish 4 fully supports Streaming, so use streaming here to avoid locking.\n if (bereq.url ~ \"^[^?]*\\.(7z|avi|bz2|flac|flv|gz|mka|mkv|mov|mp3|mp4|mpeg|mpg|ogg|ogm|opus|rar|tar|tgz|tbz|txz|wav|webm|xz|zip)(\\?.*)?$\") {\n unset beresp.http.set-cookie;\n set beresp.do_stream = true; # Check memory usage it'll grow in fetch_chunksize blocks (128k by default) if the backend doesn't send a Content-Length header, so only enable it for big objects\n set beresp.do_gzip = false; # Don't try to compress it for storage\n }\n\n # Sometimes, a 301 or 302 redirect formed via Apache's mod_rewrite can mess with the HTTP port that is being passed along.\n # This often happens with simple rewrite rules in a scenario where Varnish runs on :80 and Apache on :8080 on the same box.\n # A redirect can then often redirect the end-user to a URL on :8080, where it should be :80.\n # This may need finetuning on your setup.\n #\n # To prevent accidental replace, we only filter the 301\/302 redirects for now.\n if (beresp.status == 301 || beresp.status == 302) {\n set beresp.http.Location = regsub(beresp.http.Location, \":[0-9]+\", \"\");\n }\n\n # Set 2min cache if unset for static files\n if (beresp.ttl <= 0s || beresp.http.Set-Cookie || beresp.http.Vary == \"*\") {\n set beresp.ttl = 120s; # Important, you shouldn't rely on this, SET YOUR HEADERS in the backend\n set beresp.uncacheable = true;\n\n # Study and test this\n # Mark as \"Hit-For-Pass\" for the next 60 minutes - 24 hours\n #if (bereq.url ~ \"\\.(jpe?g|png|gif|pdf|gz|tgz|bz2|tbz|tar|zip|tiff|tif)$\" || bereq.url ~ \"\/(image|(image_(?:[^\/]|(?!view.*).+)))$\") {\n # set beresp.ttl = std.duration(beresp.http.age+\"s\",0s) + 6h;\n #} elseif (bereq.url ~ \"\\.(svg|swf|ico|mp3|mp4|m4a|ogg|mov|avi|wmv|flv)$\") {\n # set beresp.ttl = std.duration(beresp.http.age+\"s\",0s) + 6h;\n #} elseif (bereq.url ~ \"\\.(xls|vsd|doc|ppt|pps|vsd|doc|ppt|pps|xls|pdf|sxw|rar|odc|odb|odf|odg|odi|odp|ods|odt|sxc|sxd|sxi|sxw|dmg|torrent|deb|msi|iso|rpm)$\") {\n # set beresp.ttl = std.duration(beresp.http.age+\"s\",0s) + 6h;\n #} elseif (bereq.url ~ \"\\.(css|js)$\") {\n # set beresp.ttl = std.duration(beresp.http.age+\"s\",0s) + 24h;\n #} else {\n # set beresp.ttl = std.duration(beresp.http.age+\"s\",0s) + 1h;\n #}\n\n return (deliver);\n }\n\n # Don't cache 50x responses\n if (beresp.status == 500 || beresp.status == 502 || beresp.status == 503 || beresp.status == 504) {\n return (abandon);\n }\n\n # Allow stale content, in case the backend goes down.\n # make Varnish keep all objects for 6 hours beyond their TTL\n set beresp.grace = 6h;\n\n return (deliver);\n}\n\nsub vcl_deliver {\n # Happens when we have all the pieces we need, and are about to send the\n # response to the client.\n #\n # You can do accounting or modifying the final object here.\n\n # Called before a cached object is delivered to the client.\n\n if (obj.hits > 0) { # Add debug header to see if it's a HIT\/MISS and the number of hits, disable when not needed\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n\n # Please note that obj.hits behaviour changed in 4.0, now it counts per objecthead, not per object\n # and obj.hits may not be reset in some cases where bans are in use. See bug 1492 for details.\n # So take hits with a grain of salt\n set resp.http.X-Cache-Hits = obj.hits;\n\n # Remove some headers: PHP version\n unset resp.http.X-Powered-By;\n\n # Remove some headers: Apache version & OS\n unset resp.http.Server;\n unset resp.http.X-Drupal-Cache;\n unset resp.http.X-Varnish;\n unset resp.http.Via;\n unset resp.http.Link;\n unset resp.http.X-Generator;\n\n return (deliver);\n}\n\nsub vcl_purge {\n # Only handle actual PURGE HTTP methods, everything else is discarded\n if (req.method != \"PURGE\") {\n # restart request\n set req.http.X-Purge = \"Yes\";\n return(restart);\n }\n}\n\nsub vcl_synth {\n # Health check\n if (resp.status == 751) {\n set resp.status = 200;\n return (deliver);\n }\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n set resp.http.Retry-After = \"5\";\n synthetic (\"Error\");\n return (deliver);\n}\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"564f1a881c5d5ce367e3476d13847d3e9eba2cbb","subject":"Expanded Varnish capabilities, added sanitization options to improve cache hit rates.","message":"Expanded Varnish capabilities, added sanitization options to improve cache hit rates.\n","repos":"kkwoker\/ansible-varnish,gotofbi\/ansible-varnish,gotofbi\/ansible-varnish,killerwails\/ansible-varnish,colstrom\/ansible-varnish,telusdigital\/ansible-varnish,noqcks\/ansible-varnish,killerwails\/ansible-varnish","old_file":"templates\/etc\/varnish\/default.vcl","new_file":"templates\/etc\/varnish\/default.vcl","new_contents":"vcl 4.0;\n\nimport directors;\nimport std;\n\n###\n# Varnish Documentation\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-built-in-subs.html\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/reference\/vcl.html\n##\n\n{% for backend in varnish_backend_hosts %}\nbackend application_{{ loop.index }} {\n .host = \"{{ backend }}\";\n .port = \"{{ varnish_backend_port }}\";\n{% if varnish_health_checks_enabled %}\n .probe = {\n .url = \"{{ varnish_health_check_url }}\";\n .interval = {{ varnish_health_check_interval }};\n .timeout = {{ varnish_health_check_timeout }};\n .window = {{ varnish_health_check_window }};\n .threshold = {{ varnish_health_check_threshold }};\n }\n{% endif %}\n}\n{% endfor %}\n\n###\n# vcl_init\n# Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n###\n# The vcl_init subroutine may terminate with calling return() with one of the following keywords:\n#\n# ok\n# Normal return, VCL continues loading.\n##\n\nsub vcl_init {\n new application = directors.round_robin();\n{% for backend in varnish_backend_hosts %}\n application.add_backend(application_{{ loop.index }});\n{% endfor %}\n}\n\n###\n# vcl_recv\n# Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use. \n# It is also used to modify the request\n###\n# The vcl_recv subroutine may terminate with calling return() on one of the following keywords:\n#\n# synth(status code, reason)\n# Return a synthetic object with the specified status code to the client and abandon the request.\n# pass\n# Switch to pass mode. Control will eventually pass to vcl_pass.\n# pipe\n# Switch to pipe mode. Control will eventually pass to vcl_pipe.\n# hash\n# Continue processing the object as a potential candidate for caching. Passes the control over to vcl_hash.\n# purge\n# Purge the object and it's variants. Control passes through vcl_hash to vcl_purge.\n#\n\nsub vcl_recv {\n set req.backend_hint = application.backend();\n\n ###\n # Avoid processing uncacheable requests\n ###\n\n if (req.http.Authorization) {\n return (pass);\n }\n\n ###\n # Inject X-Forwarded-For headers, but only once.\n ###\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n{% if varnish_header_sanitization_enabled %}\n ###\n # Header Sanitization\n ###\n\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_enabled %}\n ###\n # Cookie Sanitization\n ###\n\n ### Google Analytics\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n\n ### Quantcast\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n \n ### AddThis\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n\n ### General Cleanup\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n{% endif %}\n\n{% if varnish_uri_sanitization_enabled %}\n ###\n # URI Sanitization\n ###\n \n if (req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=\") {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n if (req.url ~ \"\\?$\") {\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n{% endif %}\n\n{% if varnish_workaround_telusdotcom_browser_profile %}\n ###\n # Workaround for BrowserProfile and Language\/Region Detection on TELUS.com\n ###\n\n if (req.http.Cookie ~ \"BrowserProfile\") {\n set req.http.X-Language = regsuball(req.http.Cookie, \"language..:\\\\.(.*)\\\\.,\", \"\\1\");\n set req.http.X-Province = regsuball(req.http.Cookie, \"region..:\\\\.(.*)\\\\.,\", \"\\1\");\n } else {\n if (req.http.Cookie ~ \"lang=\") {\n set req.http.X-Language = regsuball(req.http.Cookie, \"lang=(.*);\", \"\\1\");\n } else {\n set req.http.X-Language = \"en\";\n }\n\n if (req.http.Cookie ~ \"prov=\") {\n set req.http.X-Province = regsuball(req.http.Cookie, \"prov=(.*);\", \"\\1\");\n } else {\n set req.http.X-Province = \"BC\";\n }\n }\n\n if (req.url ~ \"\/(en|fr)\/\") {\n if (req.url ~ \"\/en\/\" && req.http.X-Language != \"en\") {\n return(pass);\n }\n if (req.url ~ \"\/fr\/\" && req.http.X-Language != \"fr\") {\n return(pass);\n }\n }\n\n if (req.url ~ \"\/(ab|bc|mb|nb|nl|ns|nt|nu|on|pe|qc|sk|yt)\/\") {\n {% for province in ['ab', 'bc', 'mb', 'nb', 'nl', 'ns', 'nt', 'nu', 'on', 'pe', 'qc', 'sk', 'yt'] %}\n if (req.url ~ \"{{ province }}\" && req.http.X-Province != \"{{ province }}\") {\n return(pass);\n }\n {% endfor %}\n }\n{% endif %}\n\n{% if varnish_blacklist_enabled %}\n if ((req.url ~ \"{{ varnish_blacklist_regexp }}\")) {\n return(pass);\n } else {\n{% if varnish_discards_client_cookies %}\n unset req.http.Cookie;\n{% endif %}\n }\n{% endif %}\n\n}\n\n###\n# vcl_hit\n# Called when a cache lookup is successful.\n###\n# The vcl_hit subroutine may terminate with calling return() with one of the following keywords:\n#\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n# deliver\n# Deliver the object. Control passes to vcl_deliver.\n# synth(status code, reason)\n# Return the specified status code to the client and abandon the request.\n###\n\nsub vcl_hit {\n if (obj.ttl > 0s) {\n return (deliver);\n }\n{% if varnish_health_checks_enabled %}\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (fetch);\n }\n{% else %}\n if (obj.ttl + obj.grace > 0s) {\n return (deliver);\n }\n\n return (fetch);\n{% endif %}\n}\n\n###\n# vcl_backend_response\n# Called after the response headers has been successfully retrieved from the backend.\n###\n# The vcl_backend_response subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Possibly insert the object into the cache, then deliver it to the Control will eventually pass to vcl_deliver.\n# abandon\n# Abandon the backend request and generates an error.\n# retry\n# Retry the backend transaction. Increases the retries counter. If the number of retries is higher than max_retries Varnish emits a guru meditation error.\n###\n\nsub vcl_backend_response {\n{% if varnish_blacklist_enabled %}\n if (bereq.url ~ \"{{ varnish_blacklist_regexp }}\") {\n set beresp.http.X-Cacheable = \"NO:Path in Blacklist\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n }\n{% else %}\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n{% endif %}\n\n{% if varnish_cache_diagnostics_enabled %}\n if (bereq.http.Cookie) {\n set beresp.http.X-Cacheable = \"NO:Cookie in Request\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO:Set-Cookie in Response\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.X-No-Cache) {\n set beresp.http.X-Cacheable = \"NO:X-No-Cache\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.ttl <= 0s) {\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n{% endif %}\n\n set beresp.grace = {{ varnish_grace_period }};\n}\n\n###\n# vcl_deliver\n# Called before a cached object is delivered to the client.\n###\n# The vcl_deliver subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Deliver the object to the client.\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n###\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n","old_contents":"vcl 4.0;\n\nimport directors;\nimport std;\n\n###\n# Varnish Documentation\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-built-in-subs.html\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/reference\/vcl.html\n##\n\n{% for backend in varnish_backend_hosts %}\nbackend application_{{ loop.index }} {\n .host = \"{{ backend }}\";\n .port = \"{{ varnish_backend_port }}\";\n{% if varnish_health_checks_enabled %}\n .probe = {\n .url = \"{{ varnish_health_check_url }}\";\n .interval = {{ varnish_health_check_interval }};\n .timeout = {{ varnish_health_check_timeout }};\n .window = {{ varnish_health_check_window }};\n .threshold = {{ varnish_health_check_threshold }};\n }\n{% endif %}\n}\n{% endfor %}\n\n###\n# vcl_init\n# Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n###\n# The vcl_init subroutine may terminate with calling return() with one of the following keywords:\n#\n# ok\n# Normal return, VCL continues loading.\n##\n\nsub vcl_init {\n new application = directors.round_robin();\n{% for backend in varnish_backend_hosts %}\n application.add_backend(application_{{ loop.index }});\n{% endfor %}\n}\n\n###\n# vcl_recv\n# Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use. \n# It is also used to modify the request\n###\n# The vcl_recv subroutine may terminate with calling return() on one of the following keywords:\n#\n# synth(status code, reason)\n# Return a synthetic object with the specified status code to the client and abandon the request.\n# pass\n# Switch to pass mode. Control will eventually pass to vcl_pass.\n# pipe\n# Switch to pipe mode. Control will eventually pass to vcl_pipe.\n# hash\n# Continue processing the object as a potential candidate for caching. Passes the control over to vcl_hash.\n# purge\n# Purge the object and it's variants. Control passes through vcl_hash to vcl_purge.\n#\n\nsub vcl_recv {\n{% if varnish_workaround_telusdotcom_browser_profile %}\n if (req.http.Cookie ~ \"BrowserProfile\") {\n set req.http.X-Language = regsuball(req.http.Cookie, \"language..:\\\\.(.*)\\\\.,\", \"\\1\");\n set req.http.X-Province = regsuball(req.http.Cookie, \"region..:\\\\.(.*)\\\\.,\", \"\\1\");\n } else {\n if (req.http.Cookie ~ \"lang=\") {\n set req.http.X-Language = regsuball(req.http.Cookie, \"lang=(.*);\", \"\\1\");\n } else {\n set req.http.X-Language = \"en\";\n }\n\n if (req.http.Cookie ~ \"prov=\") {\n set req.http.X-Province = regsuball(req.http.Cookie, \"prov=(.*);\", \"\\1\");\n } else {\n set req.http.X-Province = \"BC\";\n }\n }\n\n if (req.url ~ \"\/(en|fr)\/\") {\n if (req.url ~ \"\/en\/\" && req.http.X-Language != \"en\") {\n return(pass);\n }\n if (req.url ~ \"\/fr\/\" && req.http.X-Language != \"fr\") {\n return(pass);\n }\n }\n\n if (req.url ~ \"\/(ab|bc|mb|nb|nl|ns|nt|nu|on|pe|qc|sk|yt)\/\") {\n {% for province in ['ab', 'bc', 'mb', 'nb', 'nl', 'ns', 'nt', 'nu', 'on', 'pe', 'qc', 'sk', 'yt'] %}\n if (req.url ~ \"{{ province }}\" && req.http.X-Province != \"{{ province }}\") {\n return(pass);\n }\n {% endfor %}\n }\n{% endif %}\n\n{% if varnish_blacklist_enabled %}\n if ((req.url ~ \"{{ varnish_blacklist_regexp }}\")) {\n return(pass);\n } else {\n{% if varnish_discards_client_cookies %}\n unset req.http.Cookie;\n{% endif %}\n }\n{% endif %}\n\n set req.backend_hint = application.backend();\n}\n\n###\n# vcl_hit\n# Called when a cache lookup is successful.\n###\n# The vcl_hit subroutine may terminate with calling return() with one of the following keywords:\n#\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n# deliver\n# Deliver the object. Control passes to vcl_deliver.\n# synth(status code, reason)\n# Return the specified status code to the client and abandon the request.\n###\n\nsub vcl_hit {\n if (obj.ttl > 0s) {\n return (deliver);\n }\n{% if varnish_health_checks_enabled %}\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (fetch);\n }\n{% else %}\n if (obj.ttl + obj.grace > 0s) {\n return (deliver);\n }\n\n return (fetch);\n{% endif %}\n}\n\n###\n# vcl_backend_response\n# Called after the response headers has been successfully retrieved from the backend.\n###\n# The vcl_backend_response subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Possibly insert the object into the cache, then deliver it to the Control will eventually pass to vcl_deliver.\n# abandon\n# Abandon the backend request and generates an error.\n# retry\n# Retry the backend transaction. Increases the retries counter. If the number of retries is higher than max_retries Varnish emits a guru meditation error.\n###\n\nsub vcl_backend_response {\n{% if varnish_blacklist_enabled %}\n if (bereq.url ~ \"{{ varnish_blacklist_regexp }}\") {\n set beresp.http.X-Cacheable = \"NO:Path in Blacklist\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n }\n{% else %}\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n{% endif %}\n\n{% if varnish_cache_diagnostics_enabled %}\n if (bereq.http.Cookie) {\n set beresp.http.X-Cacheable = \"NO:Cookie in Request\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO:Set-Cookie in Response\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.X-No-Cache) {\n set beresp.http.X-Cacheable = \"NO:X-No-Cache\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.ttl <= 0s) {\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n{% endif %}\n\n set beresp.grace = {{ varnish_grace_period }};\n}\n\n###\n# vcl_deliver\n# Called before a cached object is delivered to the client.\n###\n# The vcl_deliver subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Deliver the object to the client.\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n###\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"8bbe96a6537fa379f6201756b684b173568f375d","subject":"honeycomb is always a tablet","message":"honeycomb is always a tablet\n","repos":"varnish\/varnish-devicedetect,varnish\/varnish-devicedetect,kevinquinnyo\/varnish-devicedetect,wikp\/varnish-devicedetect,wikp\/varnish-devicedetect,kevinquinnyo\/varnish-devicedetect","old_file":"devicedetect.vcl","new_file":"devicedetect.vcl","new_contents":"#\n# detectdevice.vcl - regex based device detection for Varnish\n# http:\/\/github.com\/lkarsten\/varnish-devicedetect\/\n#\n# Author: Lasse Karstensen <lasse@varnish-software.com>\n\nsub devicedetect {\n unset req.http.X-hash-input;\n unset req.http.X-UA-Device;\n set req.http.X-UA-Device = \"pc\";\n\n if (req.http.User-Agent ~ \"(?i)ip(hone|od)\") { set req.http.X-UA-Device = \"mobile-iphone\"; }\n elsif (req.http.User-Agent ~ \"(?i)ipad\") { set req.http.X-UA-Device = \"tablet-ipad\"; }\n # how do we differ between an android phone and an android tablet?\n # http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent\n elsif (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") { set req.http.X-UA-Device = \"mobile-android\"; } \n # android 3\/honeycomb was just about tablet-only, and any phones will probably handle a bigger page layout.\n elsif (req.http.User-Agent ~ \"(?i)android 3\") { set req.http.X-UA-Device = \"tablet-android\"; }\n # may very well give false positives towards android tablets. Suggestions welcome.\n elsif (req.http.User-Agent ~ \"(?i)android\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\n elsif (req.http.User-Agent ~ \"^HTC\" ||\n req.http.User-Agent ~ \"Fennec\" || \n req.http.User-Agent ~ \"IEMobile\" ||\n req.http.User-Agent ~ \"BlackBerry\" ||\n req.http.User-Agent ~ \"SymbianOS.*AppleWebKit\" ||\n req.http.User-Agent ~ \"Opera Mobi\") {\n set req.http.X-UA-Device = \"mobile-smartphone\";\n }\n elsif (req.http.User-Agent ~ \"(?i)symbian\" ||\n req.http.User-Agent ~ \"(?i)^sonyericsson\" ||\n req.http.User-Agent ~ \"(?i)^nokia\" ||\n req.http.User-Agent ~ \"(?i)^samsung\" ||\n req.http.User-Agent ~ \"(?i)^lg\" ||\n\treq.http.User-Agent ~ \"(?i)bada\" ||\n\treq.http.User-Agent ~ \"(?i)blazer\" ||\n\treq.http.User-Agent ~ \"(?i)cellphone\" ||\n\treq.http.User-Agent ~ \"(?i)iemobile\" ||\n\treq.http.User-Agent ~ \"(?i)midp-2.0\" ||\n\treq.http.User-Agent ~ \"(?i)u990\" ||\n\treq.http.User-Agent ~ \"(?i)netfront\" ||\n\treq.http.User-Agent ~ \"(?i)opera mini\" ||\n\treq.http.User-Agent ~ \"(?i)palm\" ||\n\treq.http.User-Agent ~ \"(?i)nintendo wii\" ||\n\treq.http.User-Agent ~ \"(?i)playstation portable\" ||\n\treq.http.User-Agent ~ \"(?i)portalmmm\" ||\n\treq.http.User-Agent ~ \"(?i)proxinet\" ||\n\treq.http.User-Agent ~ \"(?i)sonyericsson\" ||\n\treq.http.User-Agent ~ \"(?i)symbian\" ||\n\treq.http.User-Agent ~ \"(?i)windows\\ ?ce\" ||\n\treq.http.User-Agent ~ \"(?i)winwap\" ||\n\treq.http.User-Agent ~ \"(?i)eudoraweb\" ||\n\treq.http.User-Agent ~ \"(?i)htc\" ||\n\treq.http.User-Agent ~ \"(?i)240x320\" ||\n\treq.http.User-Agent ~ \"(?i)avantgo\") { \n set req.http.X-UA-Device = \"mobile-generic\";\n }\n\n # handle overrides\n if (req.http.Cookie ~ \"(i?)X-UA-Device-force\") {\n # ;?? means zero or one ;, non-greedy to match the first.\n set req.http.X-UA-Device = regsub(req.http.Cookie, \"(?i).*X-UA-Device-force=([^;]+);??.*\", \"\\1\");\n }\n set req.http.X-hash-input = req.http.X-UA-Device;\n}\n\n# vim: sw=4:tw=120 # meh\n","old_contents":"#\n# detectdevice.vcl - regex based device detection for Varnish\n# http:\/\/github.com\/lkarsten\/varnish-devicedetect\/\n#\n# Author: Lasse Karstensen <lasse@varnish-software.com>\n\nsub devicedetect {\n unset req.http.X-hash-input;\n unset req.http.X-UA-Device;\n set req.http.X-UA-Device = \"pc\";\n\n if (req.http.User-Agent ~ \"(?i)ip(hone|od)\") { set req.http.X-UA-Device = \"mobile-iphone\"; }\n elsif (req.http.User-Agent ~ \"(?i)ipad\") { set req.http.X-UA-Device = \"tablet-ipad\"; }\n # how do we differ between an android phone and an android tablet?\n # http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent\n elsif (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") { set req.http.X-UA-Device = \"mobile-android\"; } \n # may very well give false positives towards android tablets. Suggestions welcome.\n elsif (req.http.User-Agent ~ \"(?i)android\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\n elsif (req.http.User-Agent ~ \"^HTC\" ||\n req.http.User-Agent ~ \"Fennec\" || \n req.http.User-Agent ~ \"IEMobile\" ||\n req.http.User-Agent ~ \"BlackBerry\" ||\n req.http.User-Agent ~ \"SymbianOS.*AppleWebKit\" ||\n req.http.User-Agent ~ \"Opera Mobi\") {\n set req.http.X-UA-Device = \"mobile-smartphone\";\n }\n elsif (req.http.User-Agent ~ \"(?i)symbian\" ||\n req.http.User-Agent ~ \"(?i)^sonyericsson\" ||\n req.http.User-Agent ~ \"(?i)^nokia\" ||\n req.http.User-Agent ~ \"(?i)^samsung\" ||\n req.http.User-Agent ~ \"(?i)^lg\" ||\n\treq.http.User-Agent ~ \"(?i)bada\" ||\n\treq.http.User-Agent ~ \"(?i)blazer\" ||\n\treq.http.User-Agent ~ \"(?i)cellphone\" ||\n\treq.http.User-Agent ~ \"(?i)iemobile\" ||\n\treq.http.User-Agent ~ \"(?i)midp-2.0\" ||\n\treq.http.User-Agent ~ \"(?i)u990\" ||\n\treq.http.User-Agent ~ \"(?i)netfront\" ||\n\treq.http.User-Agent ~ \"(?i)opera mini\" ||\n\treq.http.User-Agent ~ \"(?i)palm\" ||\n\treq.http.User-Agent ~ \"(?i)nintendo wii\" ||\n\treq.http.User-Agent ~ \"(?i)playstation portable\" ||\n\treq.http.User-Agent ~ \"(?i)portalmmm\" ||\n\treq.http.User-Agent ~ \"(?i)proxinet\" ||\n\treq.http.User-Agent ~ \"(?i)sonyericsson\" ||\n\treq.http.User-Agent ~ \"(?i)symbian\" ||\n\treq.http.User-Agent ~ \"(?i)windows\\ ?ce\" ||\n\treq.http.User-Agent ~ \"(?i)winwap\" ||\n\treq.http.User-Agent ~ \"(?i)eudoraweb\" ||\n\treq.http.User-Agent ~ \"(?i)htc\" ||\n\treq.http.User-Agent ~ \"(?i)240x320\" ||\n\treq.http.User-Agent ~ \"(?i)avantgo\") { \n set req.http.X-UA-Device = \"mobile-generic\";\n }\n\n # handle overrides\n if (req.http.Cookie ~ \"(i?)X-UA-Device-force\") {\n # ;?? means zero or one ;, non-greedy to match the first.\n set req.http.X-UA-Device = regsub(req.http.Cookie, \"(?i).*X-UA-Device-force=([^;]+);??.*\", \"\\1\");\n }\n set req.http.X-hash-input = req.http.X-UA-Device;\n}\n\n# vim: sw=4:tw=120 # meh\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"74ad7dbba053128f305996bd759f3794a02b0576","subject":"Link is gone","message":"Link is gone\n","repos":"kevinquinnyo\/varnish-devicedetect,wikp\/varnish-devicedetect,varnish\/varnish-devicedetect,wikp\/varnish-devicedetect,kevinquinnyo\/varnish-devicedetect,varnish\/varnish-devicedetect","old_file":"devicedetect.vcl","new_file":"devicedetect.vcl","new_contents":"# Copyright (c) 2012-2014 Varnish Software AS\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions\n# are met:\n# 1. Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n# 2. Redistributions in binary form must reproduce the above copyright\n# notice, this list of conditions and the following disclaimer in the\n# documentation and\/or other materials provided with the distribution.\n#\n# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n# ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n# SUCH DAMAGE.\n#\n# detectdevice.vcl - regex based device detection for Varnish\n# http:\/\/github.com\/varnish\/varnish-devicedetect\/\n#\n# Author: Lasse Karstensen <lkarsten@varnish-software.com>\n\nsub devicedetect {\n\tunset req.http.X-UA-Device;\n\tset req.http.X-UA-Device = \"pc\";\n\n\t# Handle that a cookie may override the detection alltogether.\n\tif (req.http.Cookie ~ \"(?i)X-UA-Device-force\") {\n\t\t\/* ;?? means zero or one ;, non-greedy to match the first. *\/\n\t\tset req.http.X-UA-Device = regsub(req.http.Cookie, \"(?i).*X-UA-Device-force=([^;]+);??.*\", \"\\1\");\n\t\t\/* Clean up our mess in the cookie header *\/\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|; ) *X-UA-Device-force=[^;]+;? *\", \"\\1\");\n\t\t\/* If the cookie header is now empty, or just whitespace, unset it. *\/\n\t\tif (req.http.Cookie ~ \"^ *$\") { unset req.http.Cookie; }\n\t} else {\n if (req.http.User-Agent ~ \"\\(compatible; Googlebot-Mobile\/2.1; \\+http:\/\/www.google.com\/bot.html\\)\" ||\n (req.http.User-Agent ~ \"iPhone\" && req.http.User-Agent ~ \"\\(compatible; Googlebot\/2.1; \\+http:\/\/www.google.com\/bot.html\")) {\n set req.http.X-UA-Device = \"mobile-bot\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)(ads|google|bing|msn|yandex|baidu|ro|career|)bot\" ||\n\t\t req.http.User-Agent ~ \"(?i)(baidu|jike|symantec)spider\" ||\n\t\t req.http.User-Agent ~ \"(?i)scanner\" ||\n\t\t req.http.User-Agent ~ \"(?i)(web)crawler\") {\n\t\t\tset req.http.X-UA-Device = \"bot\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ipad\") { set req.http.X-UA-Device = \"tablet-ipad\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ip(hone|od)\") { set req.http.X-UA-Device = \"mobile-iphone\"; }\n\t\t\/* how do we differ between an android phone and an android tablet?\n\t\t http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent *\/\n\t\telsif (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") { set req.http.X-UA-Device = \"mobile-android\"; }\n\t\t\/\/ android 3\/honeycomb was just about tablet-only, and any phones will probably handle a bigger page layout.\n\t\telsif (req.http.User-Agent ~ \"(?i)android 3\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\t\/* Opera Mobile *\/\n\t\telsif (req.http.User-Agent ~ \"Opera Mobi\") { set req.http.X-UA-Device = \"mobile-smartphone\"; }\n\t\t\/\/ May very well give false positives towards android tablets. Suggestions welcome.\n\t\telsif (req.http.User-Agent ~ \"(?i)android\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\telsif (req.http.User-Agent ~ \"PlayBook; U; RIM Tablet\") { set req.http.X-UA-Device = \"tablet-rim\"; }\n\t\telsif (req.http.User-Agent ~ \"hp-tablet.*TouchPad\") { set req.http.X-UA-Device = \"tablet-hp\"; }\n\t\telsif (req.http.User-Agent ~ \"Kindle\/3\") { set req.http.X-UA-Device = \"tablet-kindle\"; }\n\t\telsif (req.http.User-Agent ~ \"Touch.+Tablet PC\") { set req.http.X-UA-Device = \"tablet-microsoft\"; }\n\t\telsif (req.http.User-Agent ~ \"Mobile.+Firefox\") { set req.http.X-UA-Device = \"mobile-firefoxos\"; }\n\t\telsif (req.http.User-Agent ~ \"^HTC\" ||\n\t\t req.http.User-Agent ~ \"Fennec\" ||\n\t\t req.http.User-Agent ~ \"IEMobile\" ||\n\t\t req.http.User-Agent ~ \"BlackBerry\" ||\n\t\t req.http.User-Agent ~ \"BB10.*Mobile\" ||\n\t\t req.http.User-Agent ~ \"GT-.*Build\/GINGERBREAD\" ||\n\t\t req.http.User-Agent ~ \"SymbianOS.*AppleWebKit\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-smartphone\";\n\t\t}\n\t\telsif (req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)^sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)^nokia\" ||\n\t\t req.http.User-Agent ~ \"(?i)^samsung\" ||\n\t\t req.http.User-Agent ~ \"(?i)^lg\" ||\n\t\t req.http.User-Agent ~ \"(?i)bada\" ||\n\t\t req.http.User-Agent ~ \"(?i)blazer\" ||\n\t\t req.http.User-Agent ~ \"(?i)cellphone\" ||\n\t\t req.http.User-Agent ~ \"(?i)iemobile\" ||\n\t\t req.http.User-Agent ~ \"(?i)midp-2.0\" ||\n\t\t req.http.User-Agent ~ \"(?i)u990\" ||\n\t\t req.http.User-Agent ~ \"(?i)netfront\" ||\n\t\t req.http.User-Agent ~ \"(?i)opera mini\" ||\n\t\t req.http.User-Agent ~ \"(?i)palm\" ||\n\t\t req.http.User-Agent ~ \"(?i)nintendo wii\" ||\n\t\t req.http.User-Agent ~ \"(?i)playstation portable\" ||\n\t\t req.http.User-Agent ~ \"(?i)portalmmm\" ||\n\t\t req.http.User-Agent ~ \"(?i)proxinet\" ||\n\t\t req.http.User-Agent ~ \"(?i)sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)windows\\ ?ce\" ||\n\t\t req.http.User-Agent ~ \"(?i)winwap\" ||\n\t\t req.http.User-Agent ~ \"(?i)eudoraweb\" ||\n\t\t req.http.User-Agent ~ \"(?i)htc\" ||\n\t\t req.http.User-Agent ~ \"(?i)240x320\" ||\n\t\t req.http.User-Agent ~ \"(?i)avantgo\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-generic\";\n\t\t}\n\t}\n}\n","old_contents":"# Copyright (c) 2012-2014 Varnish Software AS\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions\n# are met:\n# 1. Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n# 2. Redistributions in binary form must reproduce the above copyright\n# notice, this list of conditions and the following disclaimer in the\n# documentation and\/or other materials provided with the distribution.\n#\n# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n# ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n# SUCH DAMAGE.\n#\n# detectdevice.vcl - regex based device detection for Varnish\n# http:\/\/github.com\/varnish\/varnish-devicedetect\/\n#\n# Author: Lasse Karstensen <lkarsten@varnish-software.com>\n\nsub devicedetect {\n\tunset req.http.X-UA-Device;\n\tset req.http.X-UA-Device = \"pc\";\n\n\t# Handle that a cookie may override the detection alltogether.\n\tif (req.http.Cookie ~ \"(?i)X-UA-Device-force\") {\n\t\t\/* ;?? means zero or one ;, non-greedy to match the first. *\/\n\t\tset req.http.X-UA-Device = regsub(req.http.Cookie, \"(?i).*X-UA-Device-force=([^;]+);??.*\", \"\\1\");\n\t\t\/* Clean up our mess in the cookie header *\/\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|; ) *X-UA-Device-force=[^;]+;? *\", \"\\1\");\n\t\t\/* If the cookie header is now empty, or just whitespace, unset it. *\/\n\t\tif (req.http.Cookie ~ \"^ *$\") { unset req.http.Cookie; }\n\t} else {\n if (req.http.User-Agent ~ \"\\(compatible; Googlebot-Mobile\/2.1; \\+http:\/\/www.google.com\/bot.html\\)\" ||\n (req.http.User-Agent ~ \"iPhone\" && req.http.User-Agent ~ \"\\(compatible; Googlebot\/2.1; \\+http:\/\/www.google.com\/bot.html\")) {\n set req.http.X-UA-Device = \"mobile-bot\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)(ads|google|bing|msn|yandex|baidu|ro|career|)bot\" ||\n\t\t req.http.User-Agent ~ \"(?i)(baidu|jike|symantec)spider\" ||\n\t\t req.http.User-Agent ~ \"(?i)scanner\" ||\n\t\t req.http.User-Agent ~ \"(?i)(web)crawler\") {\n\t\t\tset req.http.X-UA-Device = \"bot\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ipad\") { set req.http.X-UA-Device = \"tablet-ipad\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ip(hone|od)\") { set req.http.X-UA-Device = \"mobile-iphone\"; }\n\t\t\/* how do we differ between an android phone and an android tablet?\n\t\t http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent *\/\n\t\telsif (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") { set req.http.X-UA-Device = \"mobile-android\"; }\n\t\t\/\/ android 3\/honeycomb was just about tablet-only, and any phones will probably handle a bigger page layout.\n\t\telsif (req.http.User-Agent ~ \"(?i)android 3\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\t\/* see http:\/\/my.opera.com\/community\/openweb\/idopera\/ *\/\n\t\telsif (req.http.User-Agent ~ \"Opera Mobi\") { set req.http.X-UA-Device = \"mobile-smartphone\"; }\n\t\t\/\/ May very well give false positives towards android tablets. Suggestions welcome.\n\t\telsif (req.http.User-Agent ~ \"(?i)android\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\telsif (req.http.User-Agent ~ \"PlayBook; U; RIM Tablet\") { set req.http.X-UA-Device = \"tablet-rim\"; }\n\t\telsif (req.http.User-Agent ~ \"hp-tablet.*TouchPad\") { set req.http.X-UA-Device = \"tablet-hp\"; }\n\t\telsif (req.http.User-Agent ~ \"Kindle\/3\") { set req.http.X-UA-Device = \"tablet-kindle\"; }\n\t\telsif (req.http.User-Agent ~ \"Touch.+Tablet PC\") { set req.http.X-UA-Device = \"tablet-microsoft\"; }\n\t\telsif (req.http.User-Agent ~ \"Mobile.+Firefox\") { set req.http.X-UA-Device = \"mobile-firefoxos\"; }\n\t\telsif (req.http.User-Agent ~ \"^HTC\" ||\n\t\t req.http.User-Agent ~ \"Fennec\" ||\n\t\t req.http.User-Agent ~ \"IEMobile\" ||\n\t\t req.http.User-Agent ~ \"BlackBerry\" ||\n\t\t req.http.User-Agent ~ \"BB10.*Mobile\" ||\n\t\t req.http.User-Agent ~ \"GT-.*Build\/GINGERBREAD\" ||\n\t\t req.http.User-Agent ~ \"SymbianOS.*AppleWebKit\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-smartphone\";\n\t\t}\n\t\telsif (req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)^sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)^nokia\" ||\n\t\t req.http.User-Agent ~ \"(?i)^samsung\" ||\n\t\t req.http.User-Agent ~ \"(?i)^lg\" ||\n\t\t req.http.User-Agent ~ \"(?i)bada\" ||\n\t\t req.http.User-Agent ~ \"(?i)blazer\" ||\n\t\t req.http.User-Agent ~ \"(?i)cellphone\" ||\n\t\t req.http.User-Agent ~ \"(?i)iemobile\" ||\n\t\t req.http.User-Agent ~ \"(?i)midp-2.0\" ||\n\t\t req.http.User-Agent ~ \"(?i)u990\" ||\n\t\t req.http.User-Agent ~ \"(?i)netfront\" ||\n\t\t req.http.User-Agent ~ \"(?i)opera mini\" ||\n\t\t req.http.User-Agent ~ \"(?i)palm\" ||\n\t\t req.http.User-Agent ~ \"(?i)nintendo wii\" ||\n\t\t req.http.User-Agent ~ \"(?i)playstation portable\" ||\n\t\t req.http.User-Agent ~ \"(?i)portalmmm\" ||\n\t\t req.http.User-Agent ~ \"(?i)proxinet\" ||\n\t\t req.http.User-Agent ~ \"(?i)sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)windows\\ ?ce\" ||\n\t\t req.http.User-Agent ~ \"(?i)winwap\" ||\n\t\t req.http.User-Agent ~ \"(?i)eudoraweb\" ||\n\t\t req.http.User-Agent ~ \"(?i)htc\" ||\n\t\t req.http.User-Agent ~ \"(?i)240x320\" ||\n\t\t req.http.User-Agent ~ \"(?i)avantgo\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-generic\";\n\t\t}\n\t}\n}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"1cf0ba1594dbca9c5fd02c71209e027582940e5a","subject":"[JR] - Fixing missing semi colon","message":"[JR] - Fixing missing semi colon\n","repos":"7digital\/fastly-deploy","old_file":"spec\/vcls\/detect_includes_vcls\/multiple_includes.vcl","new_file":"spec\/vcls\/detect_includes_vcls\/multiple_includes.vcl","new_contents":"include \"new_test_include\";\ninclude \"not_uploaded_again_include\";\n\nsub vcl_recv {\n#FASTLY recv\n error 900;\n}\n\ninclude \"test_include\";\n\nsub vcl_error {\n#FASTLY error\n if(obj.status == 900) {\n set obj.status = 400;\n set obj.response = \"BAD REQUEST\";\n synthetic \"ERROR\";\n return(deliver);\n }\n}","old_contents":"include \"new_test_include\";\ninclude \"not_uploaded_again_include\";\n\nsub vcl_recv {\n#FASTLY recv\n error 900;\n}\n\ninclude \"test_include\"\n\nsub vcl_error {\n#FASTLY error\n if(obj.status == 900) {\n set obj.status = 400;\n set obj.response = \"BAD REQUEST\";\n synthetic \"ERROR\";\n return(deliver);\n }\n}","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"188ffb05294bdf89d0e91fb5064b3087dc741749","subject":"Add SPDX license identifier","message":"Add SPDX license identifier","repos":"varnish\/varnish-devicedetect,varnish\/varnish-devicedetect","old_file":"devicedetect.vcl","new_file":"devicedetect.vcl","new_contents":"#\n# Copyright (c) 2016-2018 Varnish Cache project\n# Copyright (c) 2012-2016 Varnish Software AS\n#\n# SPDX-License-Identifier: BSD-2-Clause\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions\n# are met:\n# 1. Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n# 2. Redistributions in binary form must reproduce the above copyright\n# notice, this list of conditions and the following disclaimer in the\n# documentation and\/or other materials provided with the distribution.\n#\n# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n# ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n# SUCH DAMAGE.\n#\n# detectdevice.vcl - regex based device detection for Varnish\n# https:\/\/github.com\/varnishcache\/varnish-devicedetect\/\n#\n# Original author: Lasse Karstensen <lkarsten@varnish-software.com>\n\nsub devicedetect {\n\tunset req.http.X-UA-Device;\n\tset req.http.X-UA-Device = \"pc\";\n\n\t# Handle that a cookie may override the detection alltogether.\n\tif (req.http.Cookie ~ \"(?i)X-UA-Device-force\") {\n\t\t\/* ;?? means zero or one ;, non-greedy to match the first. *\/\n\t\tset req.http.X-UA-Device = regsub(req.http.Cookie, \"(?i).*X-UA-Device-force=([^;]+);??.*\", \"\\1\");\n\t\t\/* Clean up our mess in the cookie header *\/\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|; ) *X-UA-Device-force=[^;]+;? *\", \"\\1\");\n\t\t\/* If the cookie header is now empty, or just whitespace, unset it. *\/\n\t\tif (req.http.Cookie ~ \"^ *$\") { unset req.http.Cookie; }\n\t} else {\n if (req.http.User-Agent ~ \"\\(compatible; Googlebot-Mobile\/2.1; \\+http:\/\/www.google.com\/bot.html\\)\" ||\n (req.http.User-Agent ~ \"(Android|iPhone)\" && req.http.User-Agent ~ \"\\(compatible.?; Googlebot\/2.1.?; \\+http:\/\/www.google.com\/bot.html\") ||\n\t\t\t(req.http.User-Agent ~ \"(iPhone|Windows Phone)\" && req.http.User-Agent ~ \"\\(compatible; bingbot\/2.0; \\+http:\/\/www.bing.com\/bingbot.htm\")) {\n set req.http.X-UA-Device = \"mobile-bot\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)(ads|google|bing|msn|yandex|baidu|ro|career|seznam|)bot\" ||\n\t\t req.http.User-Agent ~ \"(?i)(baidu|jike|symantec)spider\" ||\n\t\t req.http.User-Agent ~ \"(?i)pingdom\" ||\n\t\t req.http.User-Agent ~ \"(?i)facebookexternalhit\" ||\n\t\t req.http.User-Agent ~ \"(?i)scanner\" ||\n\t\t req.http.User-Agent ~ \"(?i)slurp\" ||\n\t\t req.http.User-Agent ~ \"(?i)(web)crawler\") {\n\t\t\tset req.http.X-UA-Device = \"bot\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ipad\") { set req.http.X-UA-Device = \"tablet-ipad\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ip(hone|od)\") { set req.http.X-UA-Device = \"mobile-iphone\"; }\n\t\t\/* how do we differ between an android phone and an android tablet?\n\t\t http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent *\/\n\t\telsif (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") { set req.http.X-UA-Device = \"mobile-android\"; }\n\t\t\/\/ android 3\/honeycomb was just about tablet-only, and any phones will probably handle a bigger page layout.\n\t\telsif (req.http.User-Agent ~ \"(?i)android 3\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\t\/* Opera Mobile *\/\n\t\telsif (req.http.User-Agent ~ \"Opera Mobi\") { set req.http.X-UA-Device = \"mobile-smartphone\"; }\n\t\t\/\/ May very well give false positives towards android tablets. Suggestions welcome.\n\t\telsif (req.http.User-Agent ~ \"(?i)android\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\telsif (req.http.User-Agent ~ \"PlayBook; U; RIM Tablet\") { set req.http.X-UA-Device = \"tablet-rim\"; }\n\t\telsif (req.http.User-Agent ~ \"hp-tablet.*TouchPad\") { set req.http.X-UA-Device = \"tablet-hp\"; }\n\t\telsif (req.http.User-Agent ~ \"Kindle\/3\") { set req.http.X-UA-Device = \"tablet-kindle\"; }\n\t\telsif (req.http.User-Agent ~ \"Touch.+Tablet PC\" ||\n\t\t req.http.User-Agent ~ \"Windows NT [0-9.]+; ARM;\" ) {\n\t\t set req.http.X-UA-Device = \"tablet-microsoft\";\n\t\t}\n\t\telsif (req.http.User-Agent ~ \"Mobile.+Firefox\") { set req.http.X-UA-Device = \"mobile-firefoxos\"; }\n\t\telsif (req.http.User-Agent ~ \"^HTC\" ||\n\t\t req.http.User-Agent ~ \"Fennec\" ||\n\t\t req.http.User-Agent ~ \"IEMobile\" ||\n\t\t req.http.User-Agent ~ \"BlackBerry\" ||\n\t\t req.http.User-Agent ~ \"BB10.*Mobile\" ||\n\t\t req.http.User-Agent ~ \"GT-.*Build\/GINGERBREAD\" ||\n\t\t req.http.User-Agent ~ \"SymbianOS.*AppleWebKit\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-smartphone\";\n\t\t}\n\t\telsif (req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)^sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)^nokia\" ||\n\t\t req.http.User-Agent ~ \"(?i)^samsung\" ||\n\t\t req.http.User-Agent ~ \"(?i)^lg\" ||\n\t\t req.http.User-Agent ~ \"(?i)bada\" ||\n\t\t req.http.User-Agent ~ \"(?i)blazer\" ||\n\t\t req.http.User-Agent ~ \"(?i)cellphone\" ||\n\t\t req.http.User-Agent ~ \"(?i)iemobile\" ||\n\t\t req.http.User-Agent ~ \"(?i)midp-2.0\" ||\n\t\t req.http.User-Agent ~ \"(?i)u990\" ||\n\t\t req.http.User-Agent ~ \"(?i)netfront\" ||\n\t\t req.http.User-Agent ~ \"(?i)opera mini\" ||\n\t\t req.http.User-Agent ~ \"(?i)palm\" ||\n\t\t req.http.User-Agent ~ \"(?i)nintendo wii\" ||\n\t\t req.http.User-Agent ~ \"(?i)playstation portable\" ||\n\t\t req.http.User-Agent ~ \"(?i)portalmmm\" ||\n\t\t req.http.User-Agent ~ \"(?i)proxinet\" ||\n\t\t req.http.User-Agent ~ \"(?i)windows\\ ?ce\" ||\n\t\t req.http.User-Agent ~ \"(?i)winwap\" ||\n\t\t req.http.User-Agent ~ \"(?i)eudoraweb\" ||\n\t\t req.http.User-Agent ~ \"(?i)htc\" ||\n\t\t req.http.User-Agent ~ \"(?i)240x320\" ||\n\t\t req.http.User-Agent ~ \"(?i)avantgo\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-generic\";\n\t\t}\n\t}\n}\n","old_contents":"#\n# Copyright (c) 2016-2018 Varnish Cache project\n# Copyright (c) 2012-2016 Varnish Software AS\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions\n# are met:\n# 1. Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n# 2. Redistributions in binary form must reproduce the above copyright\n# notice, this list of conditions and the following disclaimer in the\n# documentation and\/or other materials provided with the distribution.\n#\n# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n# ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n# SUCH DAMAGE.\n#\n# detectdevice.vcl - regex based device detection for Varnish\n# https:\/\/github.com\/varnishcache\/varnish-devicedetect\/\n#\n# Original author: Lasse Karstensen <lkarsten@varnish-software.com>\n\nsub devicedetect {\n\tunset req.http.X-UA-Device;\n\tset req.http.X-UA-Device = \"pc\";\n\n\t# Handle that a cookie may override the detection alltogether.\n\tif (req.http.Cookie ~ \"(?i)X-UA-Device-force\") {\n\t\t\/* ;?? means zero or one ;, non-greedy to match the first. *\/\n\t\tset req.http.X-UA-Device = regsub(req.http.Cookie, \"(?i).*X-UA-Device-force=([^;]+);??.*\", \"\\1\");\n\t\t\/* Clean up our mess in the cookie header *\/\n\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"(^|; ) *X-UA-Device-force=[^;]+;? *\", \"\\1\");\n\t\t\/* If the cookie header is now empty, or just whitespace, unset it. *\/\n\t\tif (req.http.Cookie ~ \"^ *$\") { unset req.http.Cookie; }\n\t} else {\n if (req.http.User-Agent ~ \"\\(compatible; Googlebot-Mobile\/2.1; \\+http:\/\/www.google.com\/bot.html\\)\" ||\n (req.http.User-Agent ~ \"(Android|iPhone)\" && req.http.User-Agent ~ \"\\(compatible.?; Googlebot\/2.1.?; \\+http:\/\/www.google.com\/bot.html\") ||\n\t\t\t(req.http.User-Agent ~ \"(iPhone|Windows Phone)\" && req.http.User-Agent ~ \"\\(compatible; bingbot\/2.0; \\+http:\/\/www.bing.com\/bingbot.htm\")) {\n set req.http.X-UA-Device = \"mobile-bot\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)(ads|google|bing|msn|yandex|baidu|ro|career|seznam|)bot\" ||\n\t\t req.http.User-Agent ~ \"(?i)(baidu|jike|symantec)spider\" ||\n\t\t req.http.User-Agent ~ \"(?i)pingdom\" ||\n\t\t req.http.User-Agent ~ \"(?i)facebookexternalhit\" ||\n\t\t req.http.User-Agent ~ \"(?i)scanner\" ||\n\t\t req.http.User-Agent ~ \"(?i)slurp\" ||\n\t\t req.http.User-Agent ~ \"(?i)(web)crawler\") {\n\t\t\tset req.http.X-UA-Device = \"bot\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ipad\") { set req.http.X-UA-Device = \"tablet-ipad\"; }\n\t\telsif (req.http.User-Agent ~ \"(?i)ip(hone|od)\") { set req.http.X-UA-Device = \"mobile-iphone\"; }\n\t\t\/* how do we differ between an android phone and an android tablet?\n\t\t http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent *\/\n\t\telsif (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") { set req.http.X-UA-Device = \"mobile-android\"; }\n\t\t\/\/ android 3\/honeycomb was just about tablet-only, and any phones will probably handle a bigger page layout.\n\t\telsif (req.http.User-Agent ~ \"(?i)android 3\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\t\/* Opera Mobile *\/\n\t\telsif (req.http.User-Agent ~ \"Opera Mobi\") { set req.http.X-UA-Device = \"mobile-smartphone\"; }\n\t\t\/\/ May very well give false positives towards android tablets. Suggestions welcome.\n\t\telsif (req.http.User-Agent ~ \"(?i)android\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\t\telsif (req.http.User-Agent ~ \"PlayBook; U; RIM Tablet\") { set req.http.X-UA-Device = \"tablet-rim\"; }\n\t\telsif (req.http.User-Agent ~ \"hp-tablet.*TouchPad\") { set req.http.X-UA-Device = \"tablet-hp\"; }\n\t\telsif (req.http.User-Agent ~ \"Kindle\/3\") { set req.http.X-UA-Device = \"tablet-kindle\"; }\n\t\telsif (req.http.User-Agent ~ \"Touch.+Tablet PC\" ||\n\t\t req.http.User-Agent ~ \"Windows NT [0-9.]+; ARM;\" ) {\n\t\t set req.http.X-UA-Device = \"tablet-microsoft\";\n\t\t}\n\t\telsif (req.http.User-Agent ~ \"Mobile.+Firefox\") { set req.http.X-UA-Device = \"mobile-firefoxos\"; }\n\t\telsif (req.http.User-Agent ~ \"^HTC\" ||\n\t\t req.http.User-Agent ~ \"Fennec\" ||\n\t\t req.http.User-Agent ~ \"IEMobile\" ||\n\t\t req.http.User-Agent ~ \"BlackBerry\" ||\n\t\t req.http.User-Agent ~ \"BB10.*Mobile\" ||\n\t\t req.http.User-Agent ~ \"GT-.*Build\/GINGERBREAD\" ||\n\t\t req.http.User-Agent ~ \"SymbianOS.*AppleWebKit\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-smartphone\";\n\t\t}\n\t\telsif (req.http.User-Agent ~ \"(?i)symbian\" ||\n\t\t req.http.User-Agent ~ \"(?i)^sonyericsson\" ||\n\t\t req.http.User-Agent ~ \"(?i)^nokia\" ||\n\t\t req.http.User-Agent ~ \"(?i)^samsung\" ||\n\t\t req.http.User-Agent ~ \"(?i)^lg\" ||\n\t\t req.http.User-Agent ~ \"(?i)bada\" ||\n\t\t req.http.User-Agent ~ \"(?i)blazer\" ||\n\t\t req.http.User-Agent ~ \"(?i)cellphone\" ||\n\t\t req.http.User-Agent ~ \"(?i)iemobile\" ||\n\t\t req.http.User-Agent ~ \"(?i)midp-2.0\" ||\n\t\t req.http.User-Agent ~ \"(?i)u990\" ||\n\t\t req.http.User-Agent ~ \"(?i)netfront\" ||\n\t\t req.http.User-Agent ~ \"(?i)opera mini\" ||\n\t\t req.http.User-Agent ~ \"(?i)palm\" ||\n\t\t req.http.User-Agent ~ \"(?i)nintendo wii\" ||\n\t\t req.http.User-Agent ~ \"(?i)playstation portable\" ||\n\t\t req.http.User-Agent ~ \"(?i)portalmmm\" ||\n\t\t req.http.User-Agent ~ \"(?i)proxinet\" ||\n\t\t req.http.User-Agent ~ \"(?i)windows\\ ?ce\" ||\n\t\t req.http.User-Agent ~ \"(?i)winwap\" ||\n\t\t req.http.User-Agent ~ \"(?i)eudoraweb\" ||\n\t\t req.http.User-Agent ~ \"(?i)htc\" ||\n\t\t req.http.User-Agent ~ \"(?i)240x320\" ||\n\t\t req.http.User-Agent ~ \"(?i)avantgo\") {\n\t\t\tset req.http.X-UA-Device = \"mobile-generic\";\n\t\t}\n\t}\n}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"527d730ed76a0fc9791bd4b50740b1d508005a78","subject":"Looking for cookies","message":"Looking for cookies\n\nLooking req.http.Cookie and use hash to serve\n","repos":"kevin25\/fastly","old_file":"custom52.vcl","new_file":"custom52.vcl","new_contents":"sub vcl_recv {\n #FASTLY recv\n if (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n if (req.http.Cookie ~ \"WebSiteLang=\") {\n set req.http.MyLang = req.http.Cookie;\n unset req.http.Cookie;\n }\n return(lookup);\n\n}\nsub vcl_fetch {\n\t#FASTLY fetch\n\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", MyLang\";\n } else {\n set beresp.http.Vary = \"MyLang\";\n }\n if (beresp.http.Set-Cookie) {\n set req.http.MyLang = beresp.http.Set-Cookie;\n unset beresp.http.Set-Cookie;\n }\n if ((beresp.status == 500 || beresp.status == 503) && req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.status == 500 || beresp.status == 503) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n if (beresp.http.Expires || beresp.http.Surrogate-Control ~ \"max-age\" || beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # keep the ttl here\n } else {\n # apply the default ttl\n set beresp.ttl = 3600s;\n }\n return(deliver);\n\n}\nsub vcl_deliver {\n\t#FASTLY deliver\n if (resp.http.Vary) {\n set resp.http.Vary = regsub(resp.http.Vary, \"MyLang\", \"WebSiteLang\");\n } \n if (req.url ~ \"ja\" && req.http.Cookie !~ \"WebSiteLang=ja\") { \n add resp.http.Set-Cookie = \"WebSiteLang=ja; expires=\" now + 180d \"; path=\/;\";\n } \n if (req.url ~ \"es\" && req.http.Cookie !~ \"WebSiteLang=es\") { \n add resp.http.Set-Cookie = \"WebSiteLang=es; expires=\" now + 180d \"; path=\/;\";\n }\n if (req.url ~ \"pt\" && req.http.Cookie !~ \"WebSiteLang=pt\") { \n add resp.http.Set-Cookie = \"WebSiteLang=pt; expires=\" now + 180d \"; path=\/;\";\n } \n if (req.url ~ \"it\" && req.http.Cookie !~ \"WebSiteLang=it\") { \n add resp.http.Set-Cookie = \"WebSiteLang=it; expires=\" now + 180d \"; path=\/;\";\n } \n if (req.url ~ \"fr\" && req.http.Cookie !~ \"WebSiteLang=fr\") { \n add resp.http.Set-Cookie = \"WebSiteLang=fr; expires=\" now + 180d \"; path=\/;\";\n } \n if (req.url ~ \"de\" && req.http.Cookie !~ \"WebSiteLang=de\") { \n add resp.http.Set-Cookie = \"WebSiteLang=de; expires=\" now + 180d \"; path=\/;\";\n }\n if (req.url ~ \"en\" && req.http.Cookie !~ \"WebSiteLang=en\") { \n add resp.http.Set-Cookie = \"WebSiteLang=en; expires=\" now + 180d \"; path=\/;\";\n }\n if (req.http.MyLang) {\n set resp.http.Set-Cookie = req.http.MyLang;\n }\n}\nsub vcl_hash {\n #FASTLY hash\n if(req.http.WebSiteLang) {\n set req.hash += req.http.WebSiteLang;\n }\n return(hash);\n}\nsub vcl_hit {\n#FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\nsub vcl_miss {\n#FASTLY miss\n return(fetch);\n}\nsub vcl_error {\n#FASTLY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n","old_contents":"sub vcl_recv {\n #FASTLY recv\n if (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n return(lookup);\n\n}\nsub vcl_fetch {\n\t#FASTLY fetch\n\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", MyLang\";\n } else {\n set beresp.http.Vary = \"MyLang\";\n }\n if ((beresp.status == 500 || beresp.status == 503) && req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.status == 500 || beresp.status == 503) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n if (beresp.http.Expires || beresp.http.Surrogate-Control ~ \"max-age\" || beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # keep the ttl here\n } else {\n # apply the default ttl\n set beresp.ttl = 3600s;\n }\n return(deliver);\n\n}\nsub vcl_deliver {\n\t#FASTLY deliver\n if (resp.http.Vary) {\n set resp.http.Vary = regsub(resp.http.Vary, \"MyLang\", \"WebSiteLang\");\n } \n if (req.url ~ \"ja\" && req.http.Cookie !~ \"WebSiteLang=ja\") { \n add resp.http.Set-Cookie = \"WebSiteLang=ja; expires=\" now + 180d \"; path=\/;\";\n } \n if (req.url ~ \"es\" && req.http.Cookie !~ \"WebSiteLang=es\") { \n add resp.http.Set-Cookie = \"WebSiteLang=es; expires=\" now + 180d \"; path=\/;\";\n }\n if (req.url ~ \"pt\" && req.http.Cookie !~ \"WebSiteLang=pt\") { \n add resp.http.Set-Cookie = \"WebSiteLang=pt; expires=\" now + 180d \"; path=\/;\";\n } \n if (req.url ~ \"it\" && req.http.Cookie !~ \"WebSiteLang=it\") { \n add resp.http.Set-Cookie = \"WebSiteLang=it; expires=\" now + 180d \"; path=\/;\";\n } \n if (req.url ~ \"fr\" && req.http.Cookie !~ \"WebSiteLang=fr\") { \n add resp.http.Set-Cookie = \"WebSiteLang=fr; expires=\" now + 180d \"; path=\/;\";\n } \n if (req.url ~ \"de\" && req.http.Cookie !~ \"WebSiteLang=de\") { \n add resp.http.Set-Cookie = \"WebSiteLang=de; expires=\" now + 180d \"; path=\/;\";\n }\n if (req.url ~ \"en\" && req.http.Cookie !~ \"WebSiteLang=en\") { \n add resp.http.Set-Cookie = \"WebSiteLang=en; expires=\" now + 180d \"; path=\/;\";\n }\n \n}\nsub vcl_hit {\n#FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\nsub vcl_miss {\n#FASTLY miss\n return(fetch);\n}\nsub vcl_error {\n#FASTLY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"2de86747679b3b28dbea7a525177afd1ab59579a","subject":"Disable TLSv1.0 and TLSv1.1 (#3354)","message":"Disable TLSv1.0 and TLSv1.1 (#3354)\n\n","repos":"pypa\/warehouse,dstufft\/warehouse,pypa\/warehouse,dstufft\/warehouse,dstufft\/warehouse,pypa\/warehouse,dstufft\/warehouse,pypa\/warehouse","old_file":"vcl\/main.vcl","new_file":"vcl\/main.vcl","new_contents":"# Note: It is VERY important to ensure that any changes to VCL will work\n# properly with both the current version of ``master`` and the version in\n# the pull request that adds any new changes. This is because the\n# configuration will be applied automatically as part of the deployment\n# process, but while the previous version of the code is still up and\n# running. Thus backwards incompatible changes must be broken up over\n# multiple pull requests in order to phase them in over multiple deploys.\n\nsub vcl_recv {\n\n # Fastly is dropping support for TLSv1.0 and TLSv1.1, in preperation for\n # for that, we're going to block support for it now, using VCL. This will\n # let us present a better error message in the interim before Fastly shuts\n # off TLSv1.0 and TLSv1.1 support completely.\n if (tls.client.protocol ~ \"^TLSv1(\\.(0|1))?$\") {\n error 804 \"Bad SSL Version\";\n }\n\n # I'm not 100% sure on what this is exactly for, it was taken from the\n # Fastly documentation, however, what I *believe* it does is just ensure\n # that we don't serve a stale copy of the page from the shield node when\n # an edge node is requesting content.\n if (req.http.Fastly-FF) {\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Some (Older) clients will send a hash fragment as part of the URL even\n # though that is a local only modification. This breaks this badly for the\n # files in S3, and in general it's just not needed.\n set req.url = regsub(req.url, \"#.*$\", \"\");\n\n # Fastly does some normalization of the Accept-Encoding header so that it\n # reduces the number of cached copies (when served with the common,\n # Vary: Accept-Encoding) that are cached for any one URL. This makes a lot\n # of sense, except for the fact that we want to enable brotli compression\n # for our static files. Thus we need to work around the normalized encoding\n # in a way that still minimizes cached copies, but which will allow our\n # static files to be served using brotli.\n if (req.url ~ \"^\/static\/\" && req.http.Fastly-Orig-Accept-Encoding) {\n if (req.http.User-Agent ~ \"MSIE 6\") {\n # For that 0.3% of stubborn users out there\n unset req.http.Accept-Encoding;\n } elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"br\") {\n set req.http.Accept-Encoding = \"br\";\n } elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n\n # Most of the URLs in Warehouse do not support or require any sort of query\n # parameter. If we strip these at the edge then we'll increase our cache\n # efficiency when they won't otherwise change the output of the pages.\n #\n # This will match any URL except those that start with:\n #\n # * \/admin\/\n # * \/search\/\n # * \/account\/login\/\n # * \/account\/logout\/\n # * \/account\/register\/\n # * \/account\/reset-password\/\n # * \/account\/verify-email\/\n # * \/pypi\n if (req.url.path !~ \"^\/(admin\/|search(\/|$)|account\/(login|logout|register|reset-password|verify-email)\/|pypi)\") {\n set req.url = req.url.path;\n }\n\n # Sort all of our query parameters, this will ensure that the same query\n # parameters in a different order will end up being represented as the same\n # thing, reducing cache misses due to ordering differences.\n set req.url = boltsort.sort(req.url);\n\n # We have a number of items that we'll pass back to the origin.\n # Set a header to tell the backend if we're using https or http.\n if (req.http.Fastly-SSL) {\n set req.http.Warehouse-Proto = \"https\";\n } else {\n set req.http.Warehouse-Proto = \"http\";\n }\n # Pass the client IP address back to the backend.\n if (req.http.Fastly-Client-IP) {\n set req.http.Warehouse-IP = req.http.Fastly-Client-IP;\n }\n # Pass the real host value back to the backend.\n if (req.http.Host) {\n set req.http.Warehouse-Host = req.http.host;\n }\n\n # Currently Fastly does not provide a way to access response headers when\n # the response is a 304 response. This is because the RFC states that only\n # a limit set of headers should be sent with a 304 response, and the rest\n # are SHOULD NOT. Since this stripping happens *prior* to vcl_deliver being\n # ran, that breaks our ability to log on 304 responses. Ideally at some\n # point Fastly offers us a way to access the \"real\" response headers even\n # for a 304 response, but for now, we are going to remove the headers that\n # allow a conditional response to be made. If at some point Fastly does\n # allow this, then we can delete this code.\n if (!req.http.Fastly-FF\n && std.tolower(req.http.Warehouse-Host) == \"files.pythonhosted.org\"\n && req.url.path ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\") {\n unset req.http.If-None-Match;\n unset req.http.If-Modified-Since;\n }\n\n\n#FASTLY recv\n\n\n # We want to Force SSL for the WebUI by redirecting to the HTTPS version of\n # the page, however for API calls we want to return an error code directing\n # people to instead use HTTPS.\n if (!req.http.Fastly-SSL) {\n\n # The \/simple\/ and \/packages\/ API.\n if (req.url ~ \"^\/(simple|packages)\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy JSON API.\n if (req.url ~ \"^\/pypi\/.+\/json$\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy ?:action= API.\n if (req.url ~ \"^\/pypi.*(\\?|&)=:action\") {\n error 803 \"SSL is required\";\n }\n\n # If we're on the \/pypi page and we've received something other than a\n # GET or HEAD request, then we have no way to determine if a particular\n # request is an API call or not because it'll be in the request body\n # and that isn't available to us here. So in those cases, we won't\n # do a redirect.\n if (req.url ~ \"^\/pypi\") {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n error 801 \"Force SSL\";\n }\n }\n else {\n # This isn't a \/pypi URL so we'll just unconditionally redirect to\n # HTTPS.\n error 801 \"Force SSL\";\n }\n }\n\n # Redirect pypi.io, www.pypi.io, and warehouse.python.org to pypi.org, this\n # is purposely done *after* the HTTPS checks.\n if (std.tolower(req.http.host) ~ \"^(www.pypi.org|(www.)?pypi.io|warehouse.python.org)$\") {\n set req.http.Location = \"https:\/\/pypi.org\" req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n # Redirect warehouse-staging.python.org to test.pypi.io.\n if (std.tolower(req.http.host) ~ \"^(test.pypi.io|warehouse-staging.python.org)$\") {\n set req.http.Location = \"https:\/\/test.pypi.org\" req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n\n # Requests to \/packages\/ get dispatched to Amazon instead of to our typical\n # Origin. This requires a a bit of setup to make it work.\n if (req.http.host ~ \"^(test-)?files.pythonhosted.org$\"\n && req.url ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\") {\n # Setup our environment to better match what S3 expects\/needs\n set req.http.Host = req.http.AWS-Bucket-Name \".s3.amazonaws.com\";\n set req.http.Date = now;\n set req.url = regsuball(req.url, \"\\+\", urlencode(\"+\"));\n\n # Compute the Authorization header that S3 requires to be able to\n # access the files stored there.\n set req.http.Authorization = \"AWS \" req.http.AWS-Access-Key-ID \":\" digest.hmac_sha1_base64(req.http.AWS-Secret-Access-Key, \"GET\" LF LF LF req.http.Date LF \"\/\" req.http.AWS-Bucket-Name req.url.path);\n\n # We don't want to send our Warehouse-Token to S3, so we'll go ahead\n # and remove it.\n unset req.http.Warehouse-Token;\n }\n\n # We no longer need any of these variables, which would exist only to\n # shuffle configuration from the Fastly UI into our VCL.\n unset req.http.AWS-Access-Key-ID;\n unset req.http.AWS-Secret-Access-Key;\n unset req.http.AWS-Bucket-Name;\n\n # On a POST, we want to skip the shielding and hit backends directly.\n if (req.request == \"POST\") {\n set req.backend = F_Heroku;\n }\n\n # Do not bother to attempt to run the caching mechanisms for methods that\n # are not generally safe to cache.\n if (req.request != \"HEAD\" &&\n req.request != \"GET\" &&\n req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n # We don't ever want to cache our health URL. Outside systems should be\n # able to use it to reach past Fastly and get an end to end health check.\n if (req.url == \"\/_health\/\") {\n return(pass);\n }\n\n # We never want to cache our admin URLs, while this should be \"safe\" due to\n # the architecure of Warehouse, it'll just be easier to debug issues if\n # these always are uncached.\n if (req.url ~ \"^\/admin\/\") {\n return(pass);\n }\n\n # Finally, return the default lookup action.\n return(lookup);\n}\n\n\nsub vcl_fetch {\n\n # These are newer kinds of redirects which should be able to be cached by\n # default, even though Fastly doesn't currently have them in their default\n # list of cacheable status codes.\n if (http_status_matches(beresp.status, \"303,307,308\")) {\n set beresp.cacheable = true;\n }\n\n # For any 5xx status code we want to see if a stale object exists for it,\n # if so we'll go ahead and serve it.\n if (beresp.status >= 500 && beresp.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n\n#FASTLY fetch\n\n\n # Trigger a \"SSL is required\" error if the backend has indicated to do so.\n if (beresp.http.X-Fastly-Error == \"803\") {\n error 803 \"SSL is required\";\n }\n\n # If we've gotten a 502 or a 503 from the backend, we'll go ahead and retry\n # the request.\n if ((beresp.status == 502 || beresp.status == 503) &&\n req.restarts < 1 &&\n (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n # If we've restarted, then we'll record the number of restarts.\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n # If there is a Set-Cookie header, we'll ensure that we do not cache the\n # response.\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n # If the response has the private Cache-Control directive then we won't\n # cache it.\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # If we've gotten an error after the restarts we'll deliver the response\n # with a very short cache time.\n if (http_status_matches(beresp.status, \"500,502,503\")) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n # Apply a default TTL if there isn't a max-age or s-maxage.\n if (beresp.http.Expires ||\n beresp.http.Surrogate-Control ~ \"max-age\" ||\n beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # Keep the ttl here\n }\n else {\n # Apply the default ttl\n set beresp.ttl = 60s;\n }\n\n # Actually deliver the fetched response.\n return(deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n # If the object we have isn't cacheable, then just serve it directly\n # without going through any of the caching mechanisms.\n if (!obj.cacheable) {\n return(pass);\n }\n\n return(deliver);\n}\n\n\nsub vcl_deliver {\n # If this is an error and we have a stale response available, restart so\n # that we can pick it up and serve it.\n if (resp.status >= 500 && resp.status < 600) {\n if (stale.exists) {\n restart;\n }\n }\n\n#FASTLY deliver\n\n # Unset headers that we don't need\/want to send on to the client because\n # they are not generally useful.\n unset resp.http.Via;\n\n # Set our standard security headers, we do this in VCL rather than in\n # Warehouse itself so that we always get these headers, regardless of the\n # origin server being used.\n set resp.http.Strict-Transport-Security = \"max-age=31536000; includeSubDomains; preload\";\n set resp.http.X-Frame-Options = \"deny\";\n set resp.http.X-XSS-Protection = \"1; mode=block\";\n set resp.http.X-Content-Type-Options = \"nosniff\";\n set resp.http.X-Permitted-Cross-Domain-Policies = \"none\";\n\n # Currently Fastly does not provide a way to access response headers when\n # the response is a 304 response. This is because the RFC states that only\n # a limit set of headers should be sent with a 304 response, and the rest\n # are SHOULD NOT. Since this stripping happens *prior* to vcl_deliver being\n # ran, that breaks our ability to log on 304 responses. Ideally at some\n # point Fastly offers us a way to access the \"real\" response headers even\n # for a 304 response, but for now, we are going to remove the headers that\n # allow a conditional response to be made. If at some point Fastly does\n # allow this, then we can delete this code, and also allow a 304 response\n # in the http_status_matches() check further down.\n if (!req.http.Fastly-FF\n && std.tolower(req.http.Warehouse-Host) == \"files.pythonhosted.org\"\n && req.url.path ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\") {\n unset resp.http.ETag;\n unset resp.http.Last-Modified;\n }\n\n # If we're not executing a shielding request, and the URL is one of our file\n # URLs, and it's a GET request, and the response is either a 200 or a 304\n # then we want to log an event stating that a download has taken place.\n if (!req.http.Fastly-FF\n && std.tolower(req.http.Warehouse-Host) == \"files.pythonhosted.org\"\n && req.url.path ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\"\n && req.request == \"GET\"\n && http_status_matches(resp.status, \"200\")) {\n log {\"syslog \"} req.service_id {\" linehaul :: \"} \"2@\" now \"|\" geoip.country_code \"|\" req.url.path \"|\" tls.client.protocol \"|\" tls.client.cipher \"|\" resp.http.x-amz-meta-project \"|\" resp.http.x-amz-meta-version \"|\" resp.http.x-amz-meta-package-type \"|\" req.http.user-agent;\n log {\"syslog \"} req.service_id {\" downloads :: \"} \"2@\" now \"|\" geoip.country_code \"|\" req.url.path \"|\" tls.client.protocol \"|\" tls.client.cipher \"|\" resp.http.x-amz-meta-project \"|\" resp.http.x-amz-meta-version \"|\" resp.http.x-amz-meta-package-type \"|\" req.http.user-agent;\n }\n\n # Set X-Robots-Header for everything _but_ prod\n if (std.tolower(req.http.host) !~ \"^pypi.org$\") {\n set resp.http.X-Robots-Header = \"noindex\";\n }\n\n # Unset a few headers set by Amazon that we don't really have a need\/desire\n # to send to clients.\n unset resp.http.x-amz-replication-status;\n unset resp.http.x-amz-meta-python-version;\n unset resp.http.x-amz-meta-version;\n unset resp.http.x-amz-meta-package-type;\n unset resp.http.x-amz-meta-project;\n\n\n return(deliver);\n}\n\n\nsub vcl_error {\n#FASTLY error\n\n # If we have a 5xx error and there is a stale object available, then we\n # will deliver that stale object.\n if (obj.status >= 500 && obj.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n if (obj.status == 803) {\n set obj.status = 403;\n set obj.response = \"SSL is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic {\"SSL is required.\"};\n return (deliver);\n } else if(obj.status == 804) {\n set obj.status = 403;\n set obj.response = \"TLSv1.2+ is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic {\"Support for \" tls.client.protocol \" has been removed, please upgrade to a TLSv1.2+ client.\"};\n return (deliver);\n } else if (obj.status == 750) {\n set obj.status = 301;\n set obj.http.Location = req.http.Location;\n set obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n synthetic {\"<html><head><title>301 Moved Permanently<\/title><\/head><body><center><h1>301 Moved Permanently<\/h1><\/center><\/body><\/html>\"};\n return(deliver);\n }\n\n}\n","old_contents":"# Note: It is VERY important to ensure that any changes to VCL will work\n# properly with both the current version of ``master`` and the version in\n# the pull request that adds any new changes. This is because the\n# configuration will be applied automatically as part of the deployment\n# process, but while the previous version of the code is still up and\n# running. Thus backwards incompatible changes must be broken up over\n# multiple pull requests in order to phase them in over multiple deploys.\n\nsub vcl_recv {\n\n # I'm not 100% sure on what this is exactly for, it was taken from the\n # Fastly documentation, however, what I *believe* it does is just ensure\n # that we don't serve a stale copy of the page from the shield node when\n # an edge node is requesting content.\n if (req.http.Fastly-FF) {\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Some (Older) clients will send a hash fragment as part of the URL even\n # though that is a local only modification. This breaks this badly for the\n # files in S3, and in general it's just not needed.\n set req.url = regsub(req.url, \"#.*$\", \"\");\n\n # Fastly does some normalization of the Accept-Encoding header so that it\n # reduces the number of cached copies (when served with the common,\n # Vary: Accept-Encoding) that are cached for any one URL. This makes a lot\n # of sense, except for the fact that we want to enable brotli compression\n # for our static files. Thus we need to work around the normalized encoding\n # in a way that still minimizes cached copies, but which will allow our\n # static files to be served using brotli.\n if (req.url ~ \"^\/static\/\" && req.http.Fastly-Orig-Accept-Encoding) {\n if (req.http.User-Agent ~ \"MSIE 6\") {\n # For that 0.3% of stubborn users out there\n unset req.http.Accept-Encoding;\n } elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"br\") {\n set req.http.Accept-Encoding = \"br\";\n } elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n\n # Most of the URLs in Warehouse do not support or require any sort of query\n # parameter. If we strip these at the edge then we'll increase our cache\n # efficiency when they won't otherwise change the output of the pages.\n #\n # This will match any URL except those that start with:\n #\n # * \/admin\/\n # * \/search\/\n # * \/account\/login\/\n # * \/account\/logout\/\n # * \/account\/register\/\n # * \/account\/reset-password\/\n # * \/account\/verify-email\/\n # * \/pypi\n if (req.url.path !~ \"^\/(admin\/|search(\/|$)|account\/(login|logout|register|reset-password|verify-email)\/|pypi)\") {\n set req.url = req.url.path;\n }\n\n # Sort all of our query parameters, this will ensure that the same query\n # parameters in a different order will end up being represented as the same\n # thing, reducing cache misses due to ordering differences.\n set req.url = boltsort.sort(req.url);\n\n # We have a number of items that we'll pass back to the origin.\n # Set a header to tell the backend if we're using https or http.\n if (req.http.Fastly-SSL) {\n set req.http.Warehouse-Proto = \"https\";\n } else {\n set req.http.Warehouse-Proto = \"http\";\n }\n # Pass the client IP address back to the backend.\n if (req.http.Fastly-Client-IP) {\n set req.http.Warehouse-IP = req.http.Fastly-Client-IP;\n }\n # Pass the real host value back to the backend.\n if (req.http.Host) {\n set req.http.Warehouse-Host = req.http.host;\n }\n\n # Currently Fastly does not provide a way to access response headers when\n # the response is a 304 response. This is because the RFC states that only\n # a limit set of headers should be sent with a 304 response, and the rest\n # are SHOULD NOT. Since this stripping happens *prior* to vcl_deliver being\n # ran, that breaks our ability to log on 304 responses. Ideally at some\n # point Fastly offers us a way to access the \"real\" response headers even\n # for a 304 response, but for now, we are going to remove the headers that\n # allow a conditional response to be made. If at some point Fastly does\n # allow this, then we can delete this code.\n if (!req.http.Fastly-FF\n && std.tolower(req.http.Warehouse-Host) == \"files.pythonhosted.org\"\n && req.url.path ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\") {\n unset req.http.If-None-Match;\n unset req.http.If-Modified-Since;\n }\n\n\n#FASTLY recv\n\n\n # We want to Force SSL for the WebUI by redirecting to the HTTPS version of\n # the page, however for API calls we want to return an error code directing\n # people to instead use HTTPS.\n if (!req.http.Fastly-SSL) {\n\n # The \/simple\/ and \/packages\/ API.\n if (req.url ~ \"^\/(simple|packages)\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy JSON API.\n if (req.url ~ \"^\/pypi\/.+\/json$\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy ?:action= API.\n if (req.url ~ \"^\/pypi.*(\\?|&)=:action\") {\n error 803 \"SSL is required\";\n }\n\n # If we're on the \/pypi page and we've received something other than a\n # GET or HEAD request, then we have no way to determine if a particular\n # request is an API call or not because it'll be in the request body\n # and that isn't available to us here. So in those cases, we won't\n # do a redirect.\n if (req.url ~ \"^\/pypi\") {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n error 801 \"Force SSL\";\n }\n }\n else {\n # This isn't a \/pypi URL so we'll just unconditionally redirect to\n # HTTPS.\n error 801 \"Force SSL\";\n }\n }\n\n # Redirect pypi.io, www.pypi.io, and warehouse.python.org to pypi.org, this\n # is purposely done *after* the HTTPS checks.\n if (std.tolower(req.http.host) ~ \"^(www.pypi.org|(www.)?pypi.io|warehouse.python.org)$\") {\n set req.http.Location = \"https:\/\/pypi.org\" req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n # Redirect warehouse-staging.python.org to test.pypi.io.\n if (std.tolower(req.http.host) ~ \"^(test.pypi.io|warehouse-staging.python.org)$\") {\n set req.http.Location = \"https:\/\/test.pypi.org\" req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n\n # Requests to \/packages\/ get dispatched to Amazon instead of to our typical\n # Origin. This requires a a bit of setup to make it work.\n if (req.http.host ~ \"^(test-)?files.pythonhosted.org$\"\n && req.url ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\") {\n # Setup our environment to better match what S3 expects\/needs\n set req.http.Host = req.http.AWS-Bucket-Name \".s3.amazonaws.com\";\n set req.http.Date = now;\n set req.url = regsuball(req.url, \"\\+\", urlencode(\"+\"));\n\n # Compute the Authorization header that S3 requires to be able to\n # access the files stored there.\n set req.http.Authorization = \"AWS \" req.http.AWS-Access-Key-ID \":\" digest.hmac_sha1_base64(req.http.AWS-Secret-Access-Key, \"GET\" LF LF LF req.http.Date LF \"\/\" req.http.AWS-Bucket-Name req.url.path);\n\n # We don't want to send our Warehouse-Token to S3, so we'll go ahead\n # and remove it.\n unset req.http.Warehouse-Token;\n }\n\n # We no longer need any of these variables, which would exist only to\n # shuffle configuration from the Fastly UI into our VCL.\n unset req.http.AWS-Access-Key-ID;\n unset req.http.AWS-Secret-Access-Key;\n unset req.http.AWS-Bucket-Name;\n\n # On a POST, we want to skip the shielding and hit backends directly.\n if (req.request == \"POST\") {\n set req.backend = F_Heroku;\n }\n\n # Do not bother to attempt to run the caching mechanisms for methods that\n # are not generally safe to cache.\n if (req.request != \"HEAD\" &&\n req.request != \"GET\" &&\n req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n # We don't ever want to cache our health URL. Outside systems should be\n # able to use it to reach past Fastly and get an end to end health check.\n if (req.url == \"\/_health\/\") {\n return(pass);\n }\n\n # We never want to cache our admin URLs, while this should be \"safe\" due to\n # the architecure of Warehouse, it'll just be easier to debug issues if\n # these always are uncached.\n if (req.url ~ \"^\/admin\/\") {\n return(pass);\n }\n\n # Finally, return the default lookup action.\n return(lookup);\n}\n\n\nsub vcl_fetch {\n\n # These are newer kinds of redirects which should be able to be cached by\n # default, even though Fastly doesn't currently have them in their default\n # list of cacheable status codes.\n if (http_status_matches(beresp.status, \"303,307,308\")) {\n set beresp.cacheable = true;\n }\n\n # For any 5xx status code we want to see if a stale object exists for it,\n # if so we'll go ahead and serve it.\n if (beresp.status >= 500 && beresp.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n\n#FASTLY fetch\n\n\n # Trigger a \"SSL is required\" error if the backend has indicated to do so.\n if (beresp.http.X-Fastly-Error == \"803\") {\n error 803 \"SSL is required\";\n }\n\n # If we've gotten a 502 or a 503 from the backend, we'll go ahead and retry\n # the request.\n if ((beresp.status == 502 || beresp.status == 503) &&\n req.restarts < 1 &&\n (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n # If we've restarted, then we'll record the number of restarts.\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n # If there is a Set-Cookie header, we'll ensure that we do not cache the\n # response.\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n # If the response has the private Cache-Control directive then we won't\n # cache it.\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # If we've gotten an error after the restarts we'll deliver the response\n # with a very short cache time.\n if (http_status_matches(beresp.status, \"500,502,503\")) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n # Apply a default TTL if there isn't a max-age or s-maxage.\n if (beresp.http.Expires ||\n beresp.http.Surrogate-Control ~ \"max-age\" ||\n beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # Keep the ttl here\n }\n else {\n # Apply the default ttl\n set beresp.ttl = 60s;\n }\n\n # Actually deliver the fetched response.\n return(deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n # If the object we have isn't cacheable, then just serve it directly\n # without going through any of the caching mechanisms.\n if (!obj.cacheable) {\n return(pass);\n }\n\n return(deliver);\n}\n\n\nsub vcl_deliver {\n # If this is an error and we have a stale response available, restart so\n # that we can pick it up and serve it.\n if (resp.status >= 500 && resp.status < 600) {\n if (stale.exists) {\n restart;\n }\n }\n\n#FASTLY deliver\n\n # Unset headers that we don't need\/want to send on to the client because\n # they are not generally useful.\n unset resp.http.Via;\n\n # Set our standard security headers, we do this in VCL rather than in\n # Warehouse itself so that we always get these headers, regardless of the\n # origin server being used.\n set resp.http.Strict-Transport-Security = \"max-age=31536000; includeSubDomains; preload\";\n set resp.http.X-Frame-Options = \"deny\";\n set resp.http.X-XSS-Protection = \"1; mode=block\";\n set resp.http.X-Content-Type-Options = \"nosniff\";\n set resp.http.X-Permitted-Cross-Domain-Policies = \"none\";\n\n # Currently Fastly does not provide a way to access response headers when\n # the response is a 304 response. This is because the RFC states that only\n # a limit set of headers should be sent with a 304 response, and the rest\n # are SHOULD NOT. Since this stripping happens *prior* to vcl_deliver being\n # ran, that breaks our ability to log on 304 responses. Ideally at some\n # point Fastly offers us a way to access the \"real\" response headers even\n # for a 304 response, but for now, we are going to remove the headers that\n # allow a conditional response to be made. If at some point Fastly does\n # allow this, then we can delete this code, and also allow a 304 response\n # in the http_status_matches() check further down.\n if (!req.http.Fastly-FF\n && std.tolower(req.http.Warehouse-Host) == \"files.pythonhosted.org\"\n && req.url.path ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\") {\n unset resp.http.ETag;\n unset resp.http.Last-Modified;\n }\n\n # If we're not executing a shielding request, and the URL is one of our file\n # URLs, and it's a GET request, and the response is either a 200 or a 304\n # then we want to log an event stating that a download has taken place.\n if (!req.http.Fastly-FF\n && std.tolower(req.http.Warehouse-Host) == \"files.pythonhosted.org\"\n && req.url.path ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\"\n && req.request == \"GET\"\n && http_status_matches(resp.status, \"200\")) {\n log {\"syslog \"} req.service_id {\" linehaul :: \"} \"2@\" now \"|\" geoip.country_code \"|\" req.url.path \"|\" tls.client.protocol \"|\" tls.client.cipher \"|\" resp.http.x-amz-meta-project \"|\" resp.http.x-amz-meta-version \"|\" resp.http.x-amz-meta-package-type \"|\" req.http.user-agent;\n log {\"syslog \"} req.service_id {\" downloads :: \"} \"2@\" now \"|\" geoip.country_code \"|\" req.url.path \"|\" tls.client.protocol \"|\" tls.client.cipher \"|\" resp.http.x-amz-meta-project \"|\" resp.http.x-amz-meta-version \"|\" resp.http.x-amz-meta-package-type \"|\" req.http.user-agent;\n }\n\n # Set X-Robots-Header for everything _but_ prod\n if (std.tolower(req.http.host) !~ \"^pypi.org$\") {\n set resp.http.X-Robots-Header = \"noindex\";\n }\n\n # Unset a few headers set by Amazon that we don't really have a need\/desire\n # to send to clients.\n unset resp.http.x-amz-replication-status;\n unset resp.http.x-amz-meta-python-version;\n unset resp.http.x-amz-meta-version;\n unset resp.http.x-amz-meta-package-type;\n unset resp.http.x-amz-meta-project;\n\n\n return(deliver);\n}\n\n\nsub vcl_error {\n#FASTLY error\n\n # If we have a 5xx error and there is a stale object available, then we\n # will deliver that stale object.\n if (obj.status >= 500 && obj.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n if (obj.status == 803) {\n set obj.status = 403;\n set obj.response = \"SSL is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic {\"SSL is required.\"};\n return (deliver);\n } else if (obj.status == 750) {\n set obj.status = 301;\n set obj.http.Location = req.http.Location;\n set obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n synthetic {\"<html><head><title>301 Moved Permanently<\/title><\/head><body><center><h1>301 Moved Permanently<\/h1><\/center><\/body><\/html>\"};\n return(deliver);\n }\n\n}\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"690e4ac1646e4d81915c63b5134def485f23f993","subject":"Add serve stale on errors handling","message":"Add serve stale on errors handling\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/fastly.vcl","new_file":"etc\/fastly.vcl","new_contents":"###############################################################################\n#\n# Fastly CDN for Magento 2\n#\n# NOTICE OF LICENSE\n#\n# This source file is subject to the Fastly CDN for Magento 2 End User License\n# Agreement that is bundled with this package in the file LICENSE_FASTLY_CDN.txt.\n#\n# @copyright Copyright (c) 2016 Fastly, Inc. (http:\/\/www.fastly.com)\n# @license BSD, see LICENSE_FASTLY_CDN.txt\n#\n###############################################################################\n\n# This is a basic VCL configuration file for Fastly CDN for Magento 2 module.\n\nsub vcl_recv {\n#FASTLY recv\n\n # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n # Sort the query arguments\n set req.url = boltsort.sort(req.url);\n\n if (req.url ~ \"^\/static\/version(\\d*\/)?(.*)$\") {\n set req.url = \"\/static\/\" + re.group.2 + \"?\" + re.group.1;\n }\n \n # User's Cookie may contain some Magento Vary items we should vary on\n if (req.http.cookie:X-Magento-Vary ) {\n set req.http.X-Magento-Vary = req.http.cookie:X-Magento-Vary;\n } else {\n unset req.http.X-Magento-Vary;\n }\n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n set req.http.X-Sig = regsub(req.http.X-Purge-Token, \"^[^_]+_(.*)\", \"\\1\");\n set req.http.X-Exp = regsub(req.http.X-Purge-Token, \"^([^_]+)_.*\", \"\\1\");\n\n # validate signature\n if (req.http.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path req.http.X-Exp), \"^0x\", \"\")) {\n\n # use vcl time math to check expiration timestamp\n set req.http.X-Original-Grace = req.grace;\n set req.grace = std.atoi(strftime({\"%s\"}, now));\n set req.grace -= std.atoi(req.http.X-Exp);\n\n if (std.atoi(req.grace) > 0) {\n error 410;\n }\n\n # clean up grace since we used it for time math\n set req.grace = std.atoi(req.http.X-Original-Grace);\n unset req.http.X-Original-Grace;\n\n } else {\n error 403;\n }\n\n # cleanup variables\n unset req.http.X-Purge-Token;\n unset req.http.X-Sig;\n unset req.http.X-Exp;\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (req.http.Fastly-FF) {\n # disable ESI processing on Origin Shield\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # We only deal with GET and HEAD by default\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n return (pass);\n }\n \n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie ~ \"(X-Magento-Vary|form_key)=\") {\n error 200 \"\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url !~ \"country_code=\" ) {\n set req.url = req.url \"?country_code=\" if ( req.http.geo_override, req.http.geo_override, geoip.country_code);\n }\n }\n } else {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking\n set req.http.Fastly-Original-URL = req.url;\n set req.url = querystring.regfilter(req.url, \"^(utm_.*|gclid|gdftrk|_ga|mc_.*)\");\n }\n \n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n return (lookup);\n }\n\n # Bypass shopping cart and checkout requests\n if (req.url ~ \"\/checkout\") {\n return (pass);\n }\n\n return(lookup);\n}\n\nsub vcl_fetch {\n\n \/* handle 5XX (or any other unwanted status code) *\/\n if (beresp.status >= 500 && beresp.status < 600) {\n\n \/* deliver stale if the object is available *\/\n if (stale.exists) {\n return(deliver_stale);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n \/* else go to vcl_error to deliver a synthetic *\/\n error 503;\n }\n\n # Remove Set-Cookies from responses for static content\n # to match the cookie removal in recv.\n if (req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n }\n\n }\n\n#FASTLY fetch\n\n if (beresp.status >= 500) {\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n }\n\n if (req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Content-Type ~ \"text\/html\" || beresp.http.Content-Type ~ \"text\/xml\") {\n # enable ESI feature for Magento response by default\n esi;\n if (!beresp.http.Vary ~ \"X-Magento-Vary,Https\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \",X-Magento-Vary,Https\";\n } else {\n set beresp.http.Vary = \"X-Magento-Vary,Https\";\n }\n }\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content\n if ((beresp.status == 200 || beresp.status == 404) && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url ~ \"\\.(css|js|html|eot|ico|otf|ttf|json)($|\\?)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # cache only successfully responses and 404s\n if (beresp.status != 200 && beresp.status != 301 && beresp.status != 404) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\")) {\n unset beresp.http.set-cookie;\n if (req.url !~ \"^\/(pub\/)?(media|static)\/.*\") {\n set beresp.grace = 86400m;\n }\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type\n if (beresp.http.Content-Type ~ \"image\") {\n set beresp.http.Surrogate-Key = \"image\";\n } elsif (beresp.http.Content-Type ~ \"script\") {\n set beresp.http.Surrogate-Key = \"script\";\n } elsif (beresp.http.Content-Type ~ \"css\") {\n set beresp.http.Surrogate-Key = \"css\";\n }\n\n set beresp.http.X-Surrogate-Key = beresp.http.Surrogate-Key;\n return (deliver);\n }\n\n return (deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\n\nsub vcl_miss {\n # Deactivate gzip on origin\n unset bereq.http.Accept-Encoding;\n\n#FASTLY miss\n\n return(fetch);\n}\n\nsub vcl_deliver {\n\n if (resp.status >= 500 && resp.status < 600) {\n \/* restart if the stale object is available *\/\n if (stale.exists) {\n restart;\n }\n }\n\n # Send no cache headers to end users for non-static content. Also make sure\n # we only set this on the edge nodes and not on shields\n if (req.url !~ \"^\/(pub\/)?(media|static)\/.*\" && !req.http.Fastly-FF ) {\n set resp.http.Pragma = \"no-cache\";\n set resp.http.Cache-Control = \"no-store, no-cache, must-revalidate, max-age=0\";\n }\n\n # Remove X-Magento-Vary and HTTPs Vary served to the user\n if ( !req.http.Fastly-FF ) {\n set resp.http.Vary = regsub(resp.http.Vary, \"X-Magento-Vary,Https\", \"Cookie\");\n }\n\n # Add an easy way to see whether custom Fastly VCL has been uploaded\n if ( req.http.Fastly-Debug ) {\n set resp.http.Fastly-Magento-VCL-Uploaded = \"yes\";\n } else {\n remove resp.http.Fastly-Module-Enabled;\n }\n # debug info\n if (resp.http.X-Magento-Debug) {\n if (obj.hits > 0) {\n set resp.http.X-Magento-Cache-Debug = \"HIT\";\n set resp.http.X-Magento-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Magento-Cache-Debug = \"MISS\";\n }\n } else {\n # remove Varnish\/proxy header\n remove resp.http.Age;\n remove resp.http.X-Magento-Debug;\n remove resp.http.X-Magento-Tags;\n remove resp.http.X-Surrogate-Key;\n remove resp.http.X-Magento-Cache-Control;\n remove resp.http.X-Powered-By;\n remove resp.http.Server;\n remove resp.http.X-Varnish;\n remove resp.http.Via;\n remove resp.http.Link;\n remove resp.http.X-Purge-URL;\n remove resp.http.X-Purge-Host;\n }\n\n#FASTLY deliver\n\n return (deliver);\n}\n\n\nsub vcl_error {\n # workaround for possible security issue\n if (req.url ~ \"^\\s\") {\n set obj.status = 400;\n set obj.response = \"Malformed request\";\n synthetic \"\";\n return (deliver);\n }\n\n \/* handle 503s *\/\n if (obj.status >= 500 && obj.status < 600) {\n\n \/* deliver stale object if it is available *\/\n if (stale.exists) {\n return(deliver_stale);\n }\n\n \/* otherwise, return a synthetic *\/\n \/* include your HTML response here *\/\n synthetic {\"<!DOCTYPE html><html>Trouble connecting to origin<\/html>\"};\n return(deliver);\n }\n\n # error 200\n if (obj.status == 200) {\n return (deliver);\n }\n\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} obj.status \" \" obj.response {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} obj.status \" \" obj.response {\"<\/h1>\n <p>\"} obj.response {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} req.xid {\"<\/p>\n <hr>\n <p>Fastly CDN server<\/p>\n <\/body>\n<\/html>\n\"};\n\n#FASTLY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n\nsub vcl_hash {\n set req.hash += req.http.host;\n set req.hash += req.url;\n \n ### {{ design_exceptions_code }} ###\n\n# Please do not remove below. It's required for purge all functionality\n#FASTLY hash\n\n return (hash);\n\n}\n\n","old_contents":"###############################################################################\n#\n# Fastly CDN for Magento 2\n#\n# NOTICE OF LICENSE\n#\n# This source file is subject to the Fastly CDN for Magento 2 End User License\n# Agreement that is bundled with this package in the file LICENSE_FASTLY_CDN.txt.\n#\n# @copyright Copyright (c) 2016 Fastly, Inc. (http:\/\/www.fastly.com)\n# @license BSD, see LICENSE_FASTLY_CDN.txt\n#\n###############################################################################\n\n# This is a basic VCL configuration file for Fastly CDN for Magento 2 module.\n\nsub vcl_recv {\n#FASTLY recv\n\n # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n # Sort the query arguments\n set req.url = boltsort.sort(req.url);\n\n if (req.url ~ \"^\/static\/version(\\d*\/)?(.*)$\") {\n set req.url = \"\/static\/\" + re.group.2 + \"?\" + re.group.1;\n }\n \n # User's Cookie may contain some Magento Vary items we should vary on\n if (req.http.cookie:X-Magento-Vary ) {\n set req.http.X-Magento-Vary = req.http.cookie:X-Magento-Vary;\n } else {\n unset req.http.X-Magento-Vary;\n }\n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n set req.http.X-Sig = regsub(req.http.X-Purge-Token, \"^[^_]+_(.*)\", \"\\1\");\n set req.http.X-Exp = regsub(req.http.X-Purge-Token, \"^([^_]+)_.*\", \"\\1\");\n\n # validate signature\n if (req.http.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path req.http.X-Exp), \"^0x\", \"\")) {\n\n # use vcl time math to check expiration timestamp\n set req.http.X-Original-Grace = req.grace;\n set req.grace = std.atoi(strftime({\"%s\"}, now));\n set req.grace -= std.atoi(req.http.X-Exp);\n\n if (std.atoi(req.grace) > 0) {\n error 410;\n }\n\n # clean up grace since we used it for time math\n set req.grace = std.atoi(req.http.X-Original-Grace);\n unset req.http.X-Original-Grace;\n\n } else {\n error 403;\n }\n\n # cleanup variables\n unset req.http.X-Purge-Token;\n unset req.http.X-Sig;\n unset req.http.X-Exp;\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n # disable ESI processing on Origin Shield\n if (req.http.Fastly-FF) {\n set req.esi = false;\n }\n\n # We only deal with GET and HEAD by default\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n return (pass);\n }\n \n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie ~ \"(X-Magento-Vary|form_key)=\") {\n error 200 \"\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url !~ \"country_code=\" ) {\n set req.url = req.url \"?country_code=\" if ( req.http.geo_override, req.http.geo_override, geoip.country_code);\n }\n }\n } else {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking\n set req.http.Fastly-Original-URL = req.url;\n set req.url = querystring.regfilter(req.url, \"^(utm_.*|gclid|gdftrk|_ga|mc_.*)\");\n }\n \n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n return (lookup);\n }\n\n # Bypass shopping cart and checkout requests\n if (req.url ~ \"\/checkout\") {\n return (pass);\n }\n\n return(lookup);\n}\n\nsub vcl_fetch {\n\n # Remove Set-Cookies from responses for static content\n # to match the cookie removal in recv.\n if (req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n }\n\n }\n\n#FASTLY fetch\n\n if (beresp.status >= 500) {\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n }\n\n if (req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Content-Type ~ \"text\/html\" || beresp.http.Content-Type ~ \"text\/xml\") {\n # enable ESI feature for Magento response by default\n esi;\n if (!beresp.http.Vary ~ \"X-Magento-Vary,Https\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \",X-Magento-Vary,Https\";\n } else {\n set beresp.http.Vary = \"X-Magento-Vary,Https\";\n }\n }\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content\n if ((beresp.status == 200 || beresp.status == 404) && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url ~ \"\\.(css|js|html|eot|ico|otf|ttf|json)($|\\?)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # cache only successfully responses and 404s\n if (beresp.status != 200 && beresp.status != 301 && beresp.status != 404) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\")) {\n unset beresp.http.set-cookie;\n if (req.url !~ \"^\/(pub\/)?(media|static)\/.*\") {\n set beresp.grace = 86400m;\n }\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type\n if (beresp.http.Content-Type ~ \"image\") {\n set beresp.http.Surrogate-Key = \"image\";\n } elsif (beresp.http.Content-Type ~ \"script\") {\n set beresp.http.Surrogate-Key = \"script\";\n } elsif (beresp.http.Content-Type ~ \"css\") {\n set beresp.http.Surrogate-Key = \"css\";\n }\n\n set beresp.http.X-Surrogate-Key = beresp.http.Surrogate-Key;\n return (deliver);\n }\n\n return (deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\n\nsub vcl_miss {\n # Deactivate gzip on origin\n unset bereq.http.Accept-Encoding;\n\n#FASTLY miss\n\n return(fetch);\n}\n\nsub vcl_deliver {\n\n\n # Send no cache headers to end users for non-static content. Also make sure\n # we only set this on the edge nodes and not on shields\n if (req.url !~ \"^\/(pub\/)?(media|static)\/.*\" && !req.http.Fastly-FF ) {\n set resp.http.Pragma = \"no-cache\";\n set resp.http.Cache-Control = \"no-store, no-cache, must-revalidate, max-age=0\";\n }\n\n # Remove X-Magento-Vary and HTTPs Vary served to the user\n if ( !req.http.Fastly-FF ) {\n set resp.http.Vary = regsub(resp.http.Vary, \"X-Magento-Vary,Https\", \"Cookie\");\n }\n\n # Add an easy way to see whether custom Fastly VCL has been uploaded\n if ( req.http.Fastly-Debug ) {\n set resp.http.Fastly-Magento-VCL-Uploaded = \"yes\";\n } else {\n remove resp.http.Fastly-Module-Enabled;\n }\n # debug info\n if (resp.http.X-Magento-Debug) {\n if (obj.hits > 0) {\n set resp.http.X-Magento-Cache-Debug = \"HIT\";\n set resp.http.X-Magento-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Magento-Cache-Debug = \"MISS\";\n }\n } else {\n # remove Varnish\/proxy header\n remove resp.http.Age;\n remove resp.http.X-Magento-Debug;\n remove resp.http.X-Magento-Tags;\n remove resp.http.X-Surrogate-Key;\n remove resp.http.X-Magento-Cache-Control;\n remove resp.http.X-Powered-By;\n remove resp.http.Server;\n remove resp.http.X-Varnish;\n remove resp.http.Via;\n remove resp.http.Link;\n remove resp.http.X-Purge-URL;\n remove resp.http.X-Purge-Host;\n }\n\n#FASTLY deliver\n\n return (deliver);\n}\n\n\nsub vcl_error {\n # workaround for possible security issue\n if (req.url ~ \"^\\s\") {\n set obj.status = 400;\n set obj.response = \"Malformed request\";\n synthetic \"\";\n return (deliver);\n }\n\n # error 200\n if (obj.status == 200) {\n return (deliver);\n }\n\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} obj.status \" \" obj.response {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} obj.status \" \" obj.response {\"<\/h1>\n <p>\"} obj.response {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} req.xid {\"<\/p>\n <hr>\n <p>Fastly CDN server<\/p>\n <\/body>\n<\/html>\n\"};\n\n#FASTLY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n\nsub vcl_hash {\n set req.hash += req.http.host;\n set req.hash += req.url;\n \n ### {{ design_exceptions_code }} ###\n\n# Please do not remove below. It's required for purge all functionality\n#FASTLY hash\n\n return (hash);\n\n}\n\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"687e0de0269faee0470b81301829e58f33240d6d","subject":"beautify","message":"beautify\n","repos":"ewolff\/SCS-ESI,ewolff\/SCS-ESI,ewolff\/SCS-ESI,ewolff\/SCS-ESI","old_file":"docker\/varnish\/default.vcl","new_file":"docker\/varnish\/default.vcl","new_contents":"","old_contents":"","returncode":0,"stderr":"unknown","license":"apache-2.0","lang":"VCL"} {"commit":"1fe3ddf69b8c5805f5782bc406eaeb4813b2a1e8","subject":"Integration mode description","message":"Integration mode description","repos":"3scale\/libvmod-3scale,3scale\/libvmod-3scale","old_file":"vcl\/default_3scale_with_proxy.vcl","new_file":"vcl\/default_3scale_with_proxy.vcl","new_contents":"# This is a the VCL configuration file for 3scale's varnish plugin.\n# \n# Default backend definition. Set this to point to the 3scale's\n# backend. \n# \n# set the beresp.ttl in vcl_fetch to have a default global TTL\n# you can define custom TTL via regular expressions\n#\n# Integration mode: API proxy.\n# Traffic from API consumers will go through Varnish \n# Varnish will check with 3scale backend for API call authorization and reporting\n# (see https:\/\/support.3scale.net\/howtos\/api-configuration\/varnish)\n\n# Replace placeholders at lines 18, 19 and 42.\n\n## the backend of your API\nbackend backend_api {\n .host = \"YOUR_API_ENDPOINT\"; \n .port = \"YOUR_API_ENDPOINT\";\n}\n\n## real 3scale backend\nbackend backend_3scale {\n .host = \"su1.3scale.net\"; \n .port = \"80\";\n}\n\nimport std;\nimport threescale;\n\nsub vcl_recv {\n\n unset req.http.cookie;\n\n if (!req.http.X-3scale-authorization) {\n ## this request was send by the end-user\n set req.backend = backend_api;\n\n ## need to generate the string for the 3scale authorization,\n set req.http.X-3scale-authrep = \"\/transactions\/authrep.xml?provider_key=\";\n ## set your 3scale provider_key\n ## set req.http.X-3scale-authrep = req.http.X-3scale-authrep + \"YOUR_PROVIDER_KEY\";\n \n ## extract the parameters sent by the user\n set req.http.X-3scale-app_id = regsub(req.url,\".*[&?](app_id.[^&]*).*\",\"\\1\");\n set req.http.X-3scale-app_key = regsub(req.url,\".*[&?](app_key.[^&]*).*\",\"\\1\");\n set req.http.X-3scale-user_key = regsub(req.url,\".*[&?](user_key.[^&]*).*\",\"\\1\");\n set req.http.X-3scale-user_id = regsub(req.url,\".*[&?](user_id.[^&]*).*\",\"\\1\");\n\n if (req.http.X-3scale-app_id != req.url) {\n set req.http.X-3scale-authrep = req.http.X-3scale-authrep + \"&\" + req.http.X-3scale-app_id; \n }\n\n if (req.http.X-3scale-app_key != req.url ) {\n set req.http.X-3scale-authrep = req.http.X-3scale-authrep + \"&\" + req.http.X-3scale-app_key; \n }\n\n if (req.http.X-3scale-user_id != req.url) {\n set req.http.X-3scale-authrep = req.http.X-3scale-authrep + \"&\" + req.http.X-3scale-user_id; \n }\n\n if (req.http.X-3scale-user_key != req.url) {\n set req.http.X-3scale-authrep = req.http.X-3scale-authrep + \"&\" + req.http.X-3scale-user_key; \n }\n \n unset req.http.X-3scale-app_id;\n unset req.http.X-3scale-app_key;\n unset req.http.X-3scale-user_id;\n unset req.http.X-3scale-user_key;\n\n ## set the appropriate usage in a similar why than above, the basic one is...\n set req.http.X-3scale-authrep = req.http.X-3scale-authrep + \"&usage[hits]=1\"; \n\n ## now the additional paramters, for instance if you want to pass the url path \n set req.http.X-3scale-authrep = req.http.X-3scale-authrep + \"&object=\" + req.url;\n\n set req.http.X-3scale-authrep-result = threescale.send_get_request(\"localhost\",\"80\",req.http.X-3scale-authrep,\"X-3scale-authorization: true;\");\n\n if (req.http.X-3scale-authrep-result == \"200\") {\n ## the request from the user has been authorized, proceed as normal\n\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n return(pass);\n } \n else {\n return(lookup);\n }\n \n }\n else {\n ## the request from the users has not been authorized!! Returning an error\n ## FIXME: convert req.http.X-3scale-authrep-result; to int\n error 401;\n } \n\n unset req.http.X-3scale-authrep;\n unset req.http.X-3scale-authrep-result;\n\n\n }\n else {\n ## the request was not send by the end-user but by varnish itself\n set req.backend = backend_3scale;\n set req.http.host = \"su1.3scale.net\";\n\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n std.syslog(0,\"This should never happen!!\");\n } \n else {\n return(lookup);\n }\n\n }\n\n\t \n}\n\n# the hash of the request needs to be customized to remove all fields that are not \n# associated to the user\n\nsub vcl_hash {\n\n if (req.http.X-3scale-authorization) { \n ## remove no_body\n set req.http.X-url-tmp = regsub(req.url,\"[&?]no_body.[^&]*\",\"\");\n ## remove object_id\n set req.http.X-url-tmp = regsub(req.http.X-url-tmp,\"[&?]object.[^&]*\",\"\");\n ## remove object\n set req.http.X-url-tmp = regsub(req.http.X-url-tmp,\"[&?]object_id.[^&]*\",\"\");\n\n hash_data(req.http.X-url-tmp);\t\n unset req.http.X-url-tmp;\n }\n else {\n ## the default has of varnish for the end-user request, however we better remove the \n ## parameters specific to 3scale from the end-user request. If you want to remove other\n ## parameters from the original request so that they are not taken into account for the\n ## cache this is the place.\n\n set req.http.X-url-tmp = regsub(req.url,\"[&?]user_key.[^&]*\",\"\");\n set req.http.X-url-tmp = regsub(req.url,\"[&?]user_id.[^&]*\",\"\");\n set req.http.X-url-tmp = regsub(req.url,\"[&?]app_key.[^&]*\",\"\");\n set req.http.X-url-tmp = regsub(req.url,\"[&?]app_id.[^&]*\",\"\");\n\n hash_data(req.http.X-url-tmp);\n\n if (req.http.host) {\n hash_data(req.http.host);\n } \n else {\n hash_data(server.ip);\n }\n\n\t unset req.http.X-url-tmp;\n\n }\n\n return (hash);\n\n}\n\n#A HIT means that the request to your local cache of 3scale is still fresh and the\n#response will not have to fetch the data from the remote 3scale backend.\n#vmod_3scale plugin will send a replica of the call asynchronously to 3scale's remote\n#backend on its own\n\nsub vcl_hit {\n\n if (req.http.X-3scale-authorization) {\n if (req.url ~ \"^\/transactions\/authrep.xml\\?\") {\n\t if (threescale.send_get_request_threaded(\"su1.3scale.net\",\"80\",req.url,\"\")==0) {}\n }\n }\n \n\n}\n\n\nsub vcl_fetch {\n\n if (req.http.X-3scale-authorization) {\n ## cache the authorization from 3scale\n \tset beresp.ttl = 30s;\n }\n else {\n ## cache of the content of your API\n\t set beresp.ttl = 60s;\n }\n\n}\n\nsub vcl_deliver {\n ## remove control headers\n unset req.http.X-3scale-authrep;\n}\n\n\n\nsub vcl_error {\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n <\/head>\n <body>\n <div style=\"background-color:yellow;\">\n <h2>Authorization error trying to access this API<\/h2>\n <p>Did you forget to send your credentials?<\/p>\n <p>Are you over the limits of your account?<\/p> \n <p><b>Please go to your account at 3scale to find out<\/b><\/p>\n <\/div>\n <\/body>\n<\/html>\n\"};\n return (deliver);\n}\n\n\n\n\n","old_contents":"# This is a the VCL configuration file for 3scale's varnish plugin.\n# \n# Default backend definition. Set this to point to the 3scale's\n# backend. \n# \n# set the beresp.ttl in vcl_fetch to have a default global TTL\n# you can define custom TTL via regular expressions\n#\n\n## the backend of your API\nbackend backend_api {\n .host = \"YOUR_API_ENDPOINT\"; \n .port = \"YOUR_API_ENDPOINT\";\n}\n\n## real 3scale backend\nbackend backend_3scale {\n .host = \"su1.3scale.net\"; \n .port = \"80\";\n}\n\nimport std;\nimport threescale;\n\nsub vcl_recv {\n\n unset req.http.cookie;\n\n if (!req.http.X-3scale-authorization) {\n ## this request was send by the end-user\n set req.backend = backend_api;\n\n ## need to generate the string for the 3scale authorization,\n set req.http.X-3scale-authrep = \"\/transactions\/authrep.xml?provider_key=\";\n ## set your 3scale provider_key\n ## set req.http.X-3scale-authrep = req.http.X-3scale-authrep + \"YOUR_PROVIDER_KEY\";\n \n ## extract the parameters sent by the user\n set req.http.X-3scale-app_id = regsub(req.url,\".*[&?](app_id.[^&]*).*\",\"\\1\");\n set req.http.X-3scale-app_key = regsub(req.url,\".*[&?](app_key.[^&]*).*\",\"\\1\");\n set req.http.X-3scale-user_key = regsub(req.url,\".*[&?](user_key.[^&]*).*\",\"\\1\");\n set req.http.X-3scale-user_id = regsub(req.url,\".*[&?](user_id.[^&]*).*\",\"\\1\");\n\n if (req.http.X-3scale-app_id != req.url) {\n set req.http.X-3scale-authrep = req.http.X-3scale-authrep + \"&\" + req.http.X-3scale-app_id; \n }\n\n if (req.http.X-3scale-app_key != req.url ) {\n set req.http.X-3scale-authrep = req.http.X-3scale-authrep + \"&\" + req.http.X-3scale-app_key; \n }\n\n if (req.http.X-3scale-user_id != req.url) {\n set req.http.X-3scale-authrep = req.http.X-3scale-authrep + \"&\" + req.http.X-3scale-user_id; \n }\n\n if (req.http.X-3scale-user_key != req.url) {\n set req.http.X-3scale-authrep = req.http.X-3scale-authrep + \"&\" + req.http.X-3scale-user_key; \n }\n \n unset req.http.X-3scale-app_id;\n unset req.http.X-3scale-app_key;\n unset req.http.X-3scale-user_id;\n unset req.http.X-3scale-user_key;\n\n ## set the appropriate usage in a similar why than above, the basic one is...\n set req.http.X-3scale-authrep = req.http.X-3scale-authrep + \"&usage[hits]=1\"; \n\n ## now the additional paramters, for instance if you want to pass the url path \n set req.http.X-3scale-authrep = req.http.X-3scale-authrep + \"&object=\" + req.url;\n\n set req.http.X-3scale-authrep-result = threescale.send_get_request(\"localhost\",\"80\",req.http.X-3scale-authrep,\"X-3scale-authorization: true;\");\n\n if (req.http.X-3scale-authrep-result == \"200\") {\n ## the request from the user has been authorized, proceed as normal\n\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n return(pass);\n } \n else {\n return(lookup);\n }\n \n }\n else {\n ## the request from the users has not been authorized!! Returning an error\n ## FIXME: convert req.http.X-3scale-authrep-result; to int\n error 401;\n } \n\n unset req.http.X-3scale-authrep;\n unset req.http.X-3scale-authrep-result;\n\n\n }\n else {\n ## the request was not send by the end-user but by varnish itself\n set req.backend = backend_3scale;\n set req.http.host = \"su1.3scale.net\";\n\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n std.syslog(0,\"This should never happen!!\");\n } \n else {\n return(lookup);\n }\n\n }\n\n\t \n}\n\n# the hash of the request needs to be customized to remove all fields that are not \n# associated to the user\n\nsub vcl_hash {\n\n if (req.http.X-3scale-authorization) { \n ## remove no_body\n set req.http.X-url-tmp = regsub(req.url,\"[&?]no_body.[^&]*\",\"\");\n ## remove object_id\n set req.http.X-url-tmp = regsub(req.http.X-url-tmp,\"[&?]object.[^&]*\",\"\");\n ## remove object\n set req.http.X-url-tmp = regsub(req.http.X-url-tmp,\"[&?]object_id.[^&]*\",\"\");\n\n hash_data(req.http.X-url-tmp);\t\n unset req.http.X-url-tmp;\n }\n else {\n ## the default has of varnish for the end-user request, however we better remove the \n ## parameters specific to 3scale from the end-user request. If you want to remove other\n ## parameters from the original request so that they are not taken into account for the\n ## cache this is the place.\n\n set req.http.X-url-tmp = regsub(req.url,\"[&?]user_key.[^&]*\",\"\");\n set req.http.X-url-tmp = regsub(req.url,\"[&?]user_id.[^&]*\",\"\");\n set req.http.X-url-tmp = regsub(req.url,\"[&?]app_key.[^&]*\",\"\");\n set req.http.X-url-tmp = regsub(req.url,\"[&?]app_id.[^&]*\",\"\");\n\n hash_data(req.http.X-url-tmp);\n\n if (req.http.host) {\n hash_data(req.http.host);\n } \n else {\n hash_data(server.ip);\n }\n\n\t unset req.http.X-url-tmp;\n\n }\n\n return (hash);\n\n}\n\n#A HIT means that the request to your local cache of 3scale is still fresh and the\n#response will not have to fetch the data from the remote 3scale backend.\n#vmod_3scale plugin will send a replica of the call asynchronously to 3scale's remote\n#backend on its own\n\nsub vcl_hit {\n\n if (req.http.X-3scale-authorization) {\n if (req.url ~ \"^\/transactions\/authrep.xml\\?\") {\n\t if (threescale.send_get_request_threaded(\"su1.3scale.net\",\"80\",req.url,\"\")==0) {}\n }\n }\n \n\n}\n\n\nsub vcl_fetch {\n\n if (req.http.X-3scale-authorization) {\n ## cache the authorization from 3scale\n \tset beresp.ttl = 30s;\n }\n else {\n ## cache of the content of your API\n\t set beresp.ttl = 60s;\n }\n\n}\n\nsub vcl_deliver {\n ## remove control headers\n unset req.http.X-3scale-authrep;\n}\n\n\n\nsub vcl_error {\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n <\/head>\n <body>\n <div style=\"background-color:yellow;\">\n <h2>Authorization error trying to access this API<\/h2>\n <p>Did you forget to send your credentials?<\/p>\n <p>Are you over the limits of your account?<\/p> \n <p><b>Please go to your account at 3scale to find out<\/b><\/p>\n <\/div>\n <\/body>\n<\/html>\n\"};\n return (deliver);\n}\n\n\n\n\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"e611dc78b8336a936ad9f59f9e95d4c21c8e32bf","subject":"Remove some stray local domains","message":"Remove some stray local domains\n","repos":"jonathan-fielding\/polyfill-service,kdzwinel\/polyfill-service,kdzwinel\/polyfill-service,mcshaz\/polyfill-service,mcshaz\/polyfill-service,mcshaz\/polyfill-service,JakeChampion\/polyfill-service,kdzwinel\/polyfill-service,JakeChampion\/polyfill-service,jonathan-fielding\/polyfill-service,jonathan-fielding\/polyfill-service","old_file":"fastly-config.vcl","new_file":"fastly-config.vcl","new_contents":"sub vcl_recv {\n#FASTLY recv\n\n\tif (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n\t return(pass);\n\t}\n\n\t# Redirect legacy service users to legacy service\n\tset req.http.X-Referer-Host = regsub(req.http.Referer, \"^https?\\:\\\/\\\/([^\\\/]+)(\\\/.*)?$\", \"\\1\");\n\tif (req.url == \"\/normalize.js\" ||\n\t\treq.url == \"\/normalize.css\" ||\n\t\treq.url == \"\/normalise.js\" ||\n\t\treq.url == \"\/normalise.css\" ||\n\t\treq.http.X-Referer-Host == \"www.manrepeller.com\" ||\n\t\treq.http.X-Referer-Host == \"www.mulesoft.com\" ||\n\t\treq.http.X-Referer-Host == \"iluoghidelcuore.it\" ||\n\t\treq.http.X-Referer-Host == \"it.donga.com\" ||\n\t\treq.http.X-Referer-Host == \"www.watchguard.com\" ||\n\t\treq.http.X-Referer-Host == \"www.mulesoft.org\" ||\n\t\treq.http.X-Referer-Host == \"asmwall.com\" ||\n\t\treq.http.X-Referer-Host == \"www.jcsu.edu\" ||\n\t\treq.http.X-Referer-Host == \"adscendmedia.com\" ||\n\t\treq.http.X-Referer-Host == \"game.donga.com\" ||\n\t\treq.http.X-Referer-Host == \"framkino.no\" ||\n\t\treq.http.X-Referer-Host == \"www.accesswireless.com\" ||\n\t\treq.http.X-Referer-Host == \"represent.com\" ||\n\t\treq.http.X-Referer-Host == \"www.designergreek.com\" ||\n\t\treq.http.X-Referer-Host == \"www.plumbingoverstock.com\" ||\n\t\treq.http.X-Referer-Host == \"servicos.searh.rn.gov.br\" ||\n\t\treq.http.X-Referer-Host == \"www.jane-usa.com\" ||\n\t\treq.http.X-Referer-Host == \"www.juntaempresa.com.br\" ||\n\t\treq.http.X-Referer-Host == \"watchguard.com\" ||\n\t\treq.http.X-Referer-Host == \"www.logianalytics.com\" ||\n\t\treq.http.X-Referer-Host == \"www.thebathpoint.com\" ||\n\t\treq.http.X-Referer-Host == \"blogs.mulesoft.org\" ||\n\t\treq.http.X-Referer-Host == \"www.purecanadiangaming.com\" ||\n\t\treq.http.X-Referer-Host == \"play.egzaminatorius.lt\" ||\n\t\treq.http.X-Referer-Host == \"internetacademi.com\" ||\n\t\treq.http.X-Referer-Host == \"www.skyhighnetworks.com\" ||\n\t\treq.http.X-Referer-Host == \"interactive.guim.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"www.soloio.com\" ||\n\t\treq.http.X-Referer-Host == \"desenvolvimentoparaweb.com\" ||\n\t\treq.http.X-Referer-Host == \"daily-fantasy.trunk.development.manhattan.gq1.yahoo.com\" ||\n\t\treq.http.X-Referer-Host == \"blog.damyller.com.br\" ||\n\t\treq.http.X-Referer-Host == \"doggiebag.no\" ||\n\t\treq.http.X-Referer-Host == \"www.beverlydiamonds.com\" ||\n\t\treq.http.X-Referer-Host == \"www.rogerscup.com\" ||\n\t\treq.http.X-Referer-Host == \"blog.hudy.cz\" ||\n\t\treq.http.X-Referer-Host == \"techhamlet.com\" ||\n\t\treq.http.X-Referer-Host == \"www.flirtfachmann.de\" ||\n\t\treq.http.X-Referer-Host == \"alpacacomics.com\" ||\n\t\treq.http.X-Referer-Host == \"areariservata.fondoprevidenzafinanze.it\" ||\n\t\treq.http.X-Referer-Host == \"www.framkino.no\" ||\n\t\treq.http.X-Referer-Host == \"www.nationalsecurities.com\" ||\n\t\treq.http.X-Referer-Host == \"www.tenniscanada.com\" ||\n\t\treq.http.X-Referer-Host == \"libek.org.rs\" ||\n\t\treq.http.X-Referer-Host == \"learn.logianalytics.com\" ||\n\t\treq.http.X-Referer-Host == \"www.impartner.lt\" ||\n\t\treq.http.X-Referer-Host == \"chameleon.biworldwide.com\" ||\n\t\treq.http.X-Referer-Host == \"www.pujckapowebu.cz\" ||\n\t\treq.http.X-Referer-Host == \"www.dlcnetwork.com\" ||\n\t\treq.http.X-Referer-Host == \"www.forbes.com\" ||\n\t\treq.http.X-Referer-Host == \"blog.skyhighnetworks.com\" ||\n\t\treq.http.X-Referer-Host == \"rflx.bjornborg.com\" ||\n\t\treq.http.X-Referer-Host == \"www.coach-outlet-store.com\" ||\n\t\treq.http.X-Referer-Host == \"gist.io\" ||\n\t\treq.http.X-Referer-Host == \"www.suicideispreventable.org\" ||\n\t\treq.http.X-Referer-Host == \"www.rangemastertacticalgear.com\" ||\n\t\treq.http.X-Referer-Host == \"www.hcpozicka.sk\" ||\n\t\treq.http.X-Referer-Host == \"www.airsoftmegastore.com\" ||\n\t\treq.http.X-Referer-Host == \"colortile.github.io\" ||\n\t\treq.http.X-Referer-Host == \"brasstacksmadras.com\" ||\n\t\treq.http.X-Referer-Host == \"hotelcasadomingo.com.mx\" ||\n\t\treq.http.X-Referer-Host == \"www.worcesterpromotions.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"www.asmwall.com\" ||\n\t\treq.http.X-Referer-Host == \"training.mulesoft.com\" ||\n\t\treq.http.X-Referer-Host == \"exhilarateme.com\" ||\n\t\treq.http.X-Referer-Host == \"www.kommentatorskampen.viasatsport.se\" ||\n\t\treq.http.X-Referer-Host == \"www.golfgearselect.com\" ||\n\t\treq.http.X-Referer-Host == \"www.hcpujcka.cz\" ||\n\t\treq.http.X-Referer-Host == \"www.industriallawsociety.org.uk\" ||\n\t\treq.http.X-Referer-Host == \"www.locawebcorp.com.br\" ||\n\t\treq.http.X-Referer-Host == \"giffffr.giphy.com\" ||\n\t\treq.http.X-Referer-Host == \"mccall.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"kommentatorskampen.viasatsport.se\" ||\n\t\treq.http.X-Referer-Host == \"miraclebodyandpaint.com\" ||\n\t\treq.http.X-Referer-Host == \"www.tymprozdravi.cz\" ||\n\t\treq.http.X-Referer-Host == \"delicius.it\" ||\n\t\treq.http.X-Referer-Host == \"www.bluehighwaygames.com\" ||\n\t\treq.http.X-Referer-Host == \"tales-of-pikohan.de\" ||\n\t\treq.http.X-Referer-Host == \"demo.restoreadytest.com\" ||\n\t\treq.http.X-Referer-Host == \"mark.stratmann.me\" ||\n\t\treq.http.X-Referer-Host == \"apixtechnology.com\" ||\n\t\treq.http.X-Referer-Host == \"www.telefonickapozicka.sk\" ||\n\t\treq.http.X-Referer-Host == \"www.telefonnipujcka.cz\" ||\n\t\treq.http.X-Referer-Host == \"www.iteo.no\" ||\n\t\treq.http.X-Referer-Host == \"www.diktate.info\" ||\n\t\treq.http.X-Referer-Host == \"bpharm.192.168.56.102.xip.io\" ||\n\t\treq.http.X-Referer-Host == \"www.artisanprecast.com\" ||\n\t\treq.http.X-Referer-Host == \"tcisolutions.com\" ||\n\t\treq.http.X-Referer-Host == \"icelebrate.icehotel.com\" ||\n\t\treq.http.X-Referer-Host == \"www.thirtysevenwest.com\" ||\n\t\treq.http.X-Referer-Host == \"www.asgllc.com\" ||\n\t\treq.http.X-Referer-Host == \"www.mailinbox.net\" ||\n\t\treq.http.X-Referer-Host == \"rustyfelty.com\" ||\n\t\treq.http.X-Referer-Host == \"pulse.p2c.com\" ||\n\t\treq.http.X-Referer-Host == \"www.framkino.com\" ||\n\t\treq.http.X-Referer-Host == \"armourselfstorage.com\" ||\n\t\treq.http.X-Referer-Host == \"www.dezrezblog.com\" ||\n\t\treq.http.X-Referer-Host == \"goodpeople.com\" ||\n\t\treq.http.X-Referer-Host == \"www.eden-houlgate.com\" ||\n\t\treq.http.X-Referer-Host == \"www.patiovirtual.com.br\" ||\n\t\treq.http.X-Referer-Host == \"stats.egzaminatorius.lt\" ||\n\t\treq.http.X-Referer-Host == \"www.movieville.org\" ||\n\t\treq.http.X-Referer-Host == \"secure.watchguard.com\" ||\n\t\treq.http.X-Referer-Host == \"nationalsecurities.com\" ||\n\t\treq.http.X-Referer-Host == \"www.snaponindustrial.eu\" ||\n\t\treq.http.X-Referer-Host == \"www.fangear.com\" ||\n\t\treq.http.X-Referer-Host == \"www.scribbleshop.com\" ||\n\t\treq.http.X-Referer-Host == \"forums.mulesoft.org\" ||\n\t\treq.http.X-Referer-Host == \"dataentries.in\" ||\n\t\treq.http.X-Referer-Host == \"maki.alconost.com\" ||\n\t\treq.http.X-Referer-Host == \"dixso.github.io\" ||\n\t\treq.http.X-Referer-Host == \"citaprevia.volkswagen.es\" ||\n\t\treq.http.X-Referer-Host == \"movieville.org\" ||\n\t\treq.http.X-Referer-Host == \"www.seoestudios.com\" ||\n\t\treq.http.X-Referer-Host == \"tickets.campo.nu\" ||\n\t\treq.http.X-Referer-Host == \"perriehale.toucan\" ||\n\t\treq.http.X-Referer-Host == \"online.printstation.cz\" ||\n\t\treq.http.X-Referer-Host == \"www.le-bistrot-basque.com\" ||\n\t\treq.http.X-Referer-Host == \"www.thaiartofmassage.com\" ||\n\t\treq.http.X-Referer-Host == \"www.seevolution.com\" ||\n\t\treq.http.X-Referer-Host == \"janeusa.david\" ||\n\t\treq.http.X-Referer-Host == \"www.goodpeople.com\" ||\n\t\treq.http.X-Referer-Host == \"feeds.feedburner.com\" ||\n\t\treq.http.X-Referer-Host == \"www.millwardesque.com\" ||\n\t\treq.http.X-Referer-Host == \"cci.smartucs.a\" ||\n\t\treq.http.X-Referer-Host == \"forum.tales-of-pikohan.de\" ||\n\t\treq.http.X-Referer-Host == \"small.mu\" ||\n\t\treq.http.X-Referer-Host == \"crisp.toucan\" ||\n\t\treq.http.X-Referer-Host == \"dev1776.nationalsecurities.com\" ||\n\t\treq.http.X-Referer-Host == \"byose.net\" ||\n\t\treq.http.X-Referer-Host == \"www.eurodiary.ie\" ||\n\t\treq.http.X-Referer-Host == \"lemouvementassociatif.org\" ||\n\t\treq.http.X-Referer-Host == \"www.ey.com\" ||\n\t\treq.http.X-Referer-Host == \"cuterunslive.com\" ||\n\t\treq.http.X-Referer-Host == \"blog.odynia.org\" ||\n\t\treq.http.X-Referer-Host == \"solarenaymar.com.ar\" ||\n\t\treq.http.X-Referer-Host == \"www.aispaitalia.it\" ||\n\t\treq.http.X-Referer-Host == \"www.startupsaturday.it\" ||\n\t\treq.http.X-Referer-Host == \"support.watchguard.com\" ||\n\t\treq.http.X-Referer-Host == \"dax.absolnet.se\" ||\n\t\treq.http.X-Referer-Host == \"www.creativeinnovation.net.au\" ||\n\t\treq.http.X-Referer-Host == \"dev.raird.no\" ||\n\t\treq.http.X-Referer-Host == \"lesjeteursdencre.fr\" ||\n\t\treq.http.X-Referer-Host == \"itnotes.pl\" ||\n\t\treq.http.X-Referer-Host == \"www.thesocietyinternational.com\" ||\n\t\treq.http.X-Referer-Host == \"terminalfx.com\" ||\n\t\treq.http.X-Referer-Host == \"draft.sx\" ||\n\t\treq.http.X-Referer-Host == \"atelier-florent.fr\" ||\n\t\treq.http.X-Referer-Host == \"www.buona-tavola-ristorante.fr\" ||\n\t\treq.http.X-Referer-Host == \"www.terminalfx.com\" ||\n\t\treq.http.X-Referer-Host == \"www.taxattorney.com\" ||\n\t\treq.http.X-Referer-Host == \"proenter.dev\" ||\n\t\treq.http.X-Referer-Host == \"bodelo-advocaten.be\" ||\n\t\treq.http.X-Referer-Host == \"www.football1asia.com\" ||\n\t\treq.http.X-Referer-Host == \"rets.ly\" ||\n\t\treq.http.X-Referer-Host == \"erriol.com\" ||\n\t\treq.http.X-Referer-Host == \"shssandiego.com\" ||\n\t\treq.http.X-Referer-Host == \"notecrow.appspot.com\" ||\n\t\treq.http.X-Referer-Host == \"framkino.com\" ||\n\t\treq.http.X-Referer-Host == \"sexsite.daan\" ||\n\t\treq.http.X-Referer-Host == \"sro.dk\" ||\n\t\treq.http.X-Referer-Host == \"www.coloft.com\" ||\n\t\treq.http.X-Referer-Host == \"taxiplus.vsystem.hu\" ||\n\t\treq.http.X-Referer-Host == \"stage.mulesoft.com\" ||\n\t\treq.http.X-Referer-Host == \"local.dev.ugameplan.com\" ||\n\t\treq.http.X-Referer-Host == \"posh-nosh.com\" ||\n\t\treq.http.X-Referer-Host == \"phongthuyshop.vn\" ||\n\t\treq.http.X-Referer-Host == \"local.mansionhouse.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"www.compareaccounting.com\" ||\n\t\treq.http.X-Referer-Host == \"news.coinometrics.com\" ||\n\t\treq.http.X-Referer-Host == \"prod-yann.mailinbox.net\" ||\n\t\treq.http.X-Referer-Host == \"rachelree.se\" ||\n\t\treq.http.X-Referer-Host == \"dev1.accesswireless.usdigitalpartners.net\" ||\n\t\treq.http.X-Referer-Host == \"www.ewirisk.com\" ||\n\t\treq.http.X-Referer-Host == \"snapchan.com\" ||\n\t\treq.http.X-Referer-Host == \"www.trikatasieraakademija.lv\" ||\n\t\treq.http.X-Referer-Host == \"www.fosteringadoptionswindon.org.uk\" ||\n\t\treq.http.X-Referer-Host == \"patiovirtual.com.br\" ||\n\t\treq.http.X-Referer-Host == \"www.libmanpro.com\" ||\n\t\treq.http.X-Referer-Host == \"www.diktate.dev\" ||\n\t\treq.http.X-Referer-Host == \"idisco.pianetaitalia.intra\" ||\n\t\treq.http.X-Referer-Host == \"strudelfolhadinho.com.br\" ||\n\t\treq.http.X-Referer-Host == \"www.cunesoft.com\" ||\n\t\treq.http.X-Referer-Host == \"www.shropshirefoundation.org\" ||\n\t\treq.http.X-Referer-Host == \"speakingofbeauty.tv\" ||\n\t\treq.http.X-Referer-Host == \"www.sbs.com.au\" ||\n\t\treq.http.X-Referer-Host == \"bosch.pikmahosting.de\" ||\n\t\treq.http.X-Referer-Host == \"janeusa.lol\" ||\n\t\treq.http.X-Referer-Host == \"eso.toucan\" ||\n\t\treq.http.X-Referer-Host == \"www.lamedicis.com\" ||\n\t\treq.http.X-Referer-Host == \"cereseurope.com\" ||\n\t\treq.http.X-Referer-Host == \"www.pizza-moltobene.fr\" ||\n\t\treq.http.X-Referer-Host == \"www.kaptiva.com.br\" ||\n\t\treq.http.X-Referer-Host == \"flixified.com\" ||\n\t\treq.http.X-Referer-Host == \"www.12roundsboxing.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"www.tensionautomation.com\" ||\n\t\treq.http.X-Referer-Host == \"www.copyprint.nl\" ||\n\t\treq.http.X-Referer-Host == \"unisol\" ||\n\t\treq.http.X-Referer-Host == \"timepad.ews.co.rs\" ||\n\t\treq.http.X-Referer-Host == \"dev.rets.ly\" ||\n\t\treq.http.X-Referer-Host == \"www.vrhabilis.com\" ||\n\t\treq.http.X-Referer-Host == \"trondheggelund.no\" ||\n\t\treq.http.X-Referer-Host == \"www.ferienwohnungen-lebenswert.de\" ||\n\t\treq.http.X-Referer-Host == \"blog.mainline.com\" ||\n\t\treq.http.X-Referer-Host == \"arcstonepartners.com\" ||\n\t\treq.http.X-Referer-Host == \"dev-mj\" ||\n\t\treq.http.X-Referer-Host == \"www.crisp-cpd.com\" ||\n\t\treq.http.X-Referer-Host == \"purecanadiangaming.com\" ||\n\t\treq.http.X-Referer-Host == \"mainline.com\" ||\n\t\treq.http.X-Referer-Host == \"idx.dev.rets.ly\" ||\n\t\treq.http.X-Referer-Host == \"eneco.flicker.visualwind.com\" ||\n\t\treq.http.X-Referer-Host == \"mi.etoilemedia.it\" ||\n\t\treq.http.X-Referer-Host == \"www.atmosphericwatergenerator.net\" ||\n\t\treq.http.X-Referer-Host == \"www.gasnaturalenergyclass.com\" ||\n\t\treq.http.X-Referer-Host == \"salesmarketing.championpetfoods.com\" ||\n\t\treq.http.X-Referer-Host == \"www.watchgaurd.com\" ||\n\t\treq.http.X-Referer-Host == \"vm-sqlext-svil\" ||\n\t\treq.http.X-Referer-Host == \"dev.accesswireless.usdigitalpartners.net\" ||\n\t\treq.http.X-Referer-Host == \"kommentatorskampen.ohmytest.se\" ||\n\t\treq.http.X-Referer-Host == \"m.euvivoesporte.com.br\" ||\n\t\treq.http.X-Referer-Host == \"blog.dasroot.net\" ||\n\t\treq.http.X-Referer-Host == \"bugsdashboard.com\" ||\n\t\treq.http.X-Referer-Host == \"www.eurodiary.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"seecanadabetter-app.appspot.com\" ||\n\t\treq.http.X-Referer-Host == \"www.bobbychanblog.com\" ||\n\t\treq.http.X-Referer-Host == \"www.mybenefitsatwork.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"www.fotolotos.lt\" ||\n\t\treq.http.X-Referer-Host == \"robferguson.org\" ||\n\t\treq.http.X-Referer-Host == \"staging.motherapp.com\" ||\n\t\treq.http.X-Referer-Host == \"www.undergroundminingequipmentcompaniescalgaryquotes.com\" ||\n\t\treq.http.X-Referer-Host == \"idisco.pianetaitalia.com\" ||\n\t\treq.http.X-Referer-Host == \"cliocalman.com\" ||\n\t\treq.http.X-Referer-Host == \"sexymirror-app.com\" ||\n\t\treq.http.X-Referer-Host == \"taxes-in-serbia.192.168.56.102.xip.io\" ||\n\t\treq.http.X-Referer-Host == \"wunderbiz.com\" ||\n\t\treq.http.X-Referer-Host == \"thebathpoint.webdemo.es\" ||\n\t\treq.http.X-Referer-Host == \"www.restaurant-lemenhir.com\" ||\n\t\treq.http.X-Referer-Host == \"www.valdeure.fr\" ||\n\t\treq.http.X-Referer-Host == \"bpharm.ews.co.rs\" ||\n\t\treq.http.X-Referer-Host == \"teachersdunet.com\" ||\n\t\treq.http.X-Referer-Host == \"livesmartswmo.com\" ||\n\t\treq.http.X-Referer-Host == \"javiblog.com\" ||\n\t\treq.http.X-Referer-Host == \"mi.etoilemedia.com\" ||\n\t\treq.http.X-Referer-Host == \"www.lens.org\" ||\n\t\treq.http.X-Referer-Host == \"blacknet.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"my-faith-be-like.ghost.io\" ||\n\t\treq.http.X-Referer-Host == \"laravel.dev\" ||\n\t\treq.http.X-Referer-Host == \"fi-hpotts.2014-mansionhouse\" ||\n\t\treq.http.X-Referer-Host == \"mi.mailinbox.net\" ||\n\t\treq.http.X-Referer-Host == \"www.schulkeplusrewards.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"sasha-project.s3.amazonaws.com\" ||\n\t\treq.http.X-Referer-Host == \"www.solarenaymar.com.ar\" ||\n\t\treq.http.X-Referer-Host == \"generate.visualwind.com\" ||\n\t\treq.http.X-Referer-Host == \"drupaltest.wgti.net\" ||\n\t\treq.http.X-Referer-Host == \"minasdev.org\" ||\n\t\treq.http.X-Referer-Host == \"ims-logistic.dev\" ||\n\t\treq.http.X-Referer-Host == \"viaresto.com\" ||\n\t\treq.http.X-Referer-Host == \"learn.logixml.com\" ||\n\t\treq.http.X-Referer-Host == \"ox.espadrill-admin\" ||\n\t\treq.http.X-Referer-Host == \"smallmu-sandbox.s3-ap-southeast-1.amazonaws.com\" ||\n\t\treq.http.X-Referer-Host == \"www.firstinternet.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"m.facebook.com\" ||\n\t\treq.http.X-Referer-Host == \"www.ace.media\" ||\n\t\treq.http.X-Referer-Host == \"www.ewiretx.com\" ||\n\t\treq.http.X-Referer-Host == \"crisp.test.tdev.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"www.mifabricavisual.com\" ||\n\t\treq.http.X-Referer-Host == \"www.targetintervention.no\" ||\n\t\treq.http.X-Referer-Host == \"www.couperogers.com\" ||\n\t\treq.http.X-Referer-Host == \"skyhighstaging.local.com\" ||\n\t\treq.http.X-Referer-Host == \"altorendimientoacademico.queretaro.itesm.mx\" ||\n\t\treq.http.X-Referer-Host == \"www.gall-holl.com\" ||\n\t\treq.http.X-Referer-Host == \"sbs-moad.s3-ap-southeast-2.amazonaws.com\" ||\n\t\treq.http.X-Referer-Host == \"firstint.recruitment-lite\" ||\n\t\treq.http.X-Referer-Host == \"www.sro.dk\" ||\n\t\treq.http.X-Referer-Host == \"www.menbur.com\" ||\n\t\treq.http.X-Referer-Host == \"libmanpro.com\" ||\n\t\treq.http.X-Referer-Host == \"blurayaustralia.com\" ||\n\t\treq.http.X-Referer-Host == \"www.adscendmedia.com\" ||\n\t\treq.http.X-Referer-Host == \"blog.vincentbrouillet.com\" ||\n\t\treq.http.X-Referer-Host == \"www.investiumonline.nl\" ||\n\t\treq.http.X-Referer-Host == \"burakkp.com\" ||\n\t\treq.http.X-Referer-Host == \"audreysystem.seeties.me\" ||\n\t\treq.http.X-Referer-Host == \"everestsalesconsultants.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"accesswireless.usdphosting.com\" ||\n\t\treq.http.X-Referer-Host == \"frota.searh.rn.gov.br\" ||\n\t\treq.http.X-Referer-Host == \"qa.ugameplan.com\" ||\n\t\treq.http.X-Referer-Host == \"secure.yec.co\" ||\n\t\treq.http.X-Referer-Host == \"connect.eu.mulesoft.com\" ||\n\t\treq.http.X-Referer-Host == \"www.lastlongerreview.com\" ||\n\t\treq.http.X-Referer-Host == \"kommentatorskampen.lo\" ||\n\t\treq.http.X-Referer-Host == \"kido.bigroominternet.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"ohmydev.se\" ||\n\t\treq.http.X-Referer-Host == \"www.bentogarcia.es\" ||\n\t\treq.http.X-Referer-Host == \"rearview.herokai.com\" ||\n\t\treq.http.X-Referer-Host == \"lecafelatin.resto-ready.com\" ||\n\t\treq.http.X-Referer-Host == \"html24-dev.dk\" ||\n\t\treq.http.X-Referer-Host == \"seecanadabetter.ddev\" ||\n\t\treq.http.X-Referer-Host == \"portal.ad1.wrvc.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"garthwunsch.com\" ||\n\t\treq.http.X-Referer-Host == \"www.elitecustomsigns.com\" ||\n\t\treq.http.X-Referer-Host == \"kaptiva.com.br\" ||\n\t\treq.http.X-Referer-Host == \"nordicinox.com\" ||\n\t\treq.http.X-Referer-Host == \"www.nataktivisterna.lo\" ||\n\t\treq.http.X-Referer-Host == \"www.fidalgobaycoffee.com\" ||\n\t\treq.http.X-Referer-Host == \"mailinbox.net\" ||\n\t\treq.http.X-Referer-Host == \"www.tension.com\" ||\n\t\treq.http.X-Referer-Host == \"www.mccall.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"petbucks.org\" ||\n\t\treq.http.X-Referer-Host == \"mulesoftcompdev.prod.acquia-sites.com\" ||\n\t\treq.http.X-Referer-Host == \"logidev.devcloud.acquia-sites.com\" ||\n\t\treq.http.X-Referer-Host == \"www.cuterunslive.com\" ||\n\t\treq.http.X-Referer-Host == \"ec2-54-86-27-137.compute-1.amazonaws.com\" ||\n\t\treq.http.X-Referer-Host == \"coloft.com\" ||\n\t\treq.http.X-Referer-Host == \"dev-yann.mailinbox.net\" ||\n\t\treq.http.X-Referer-Host == \"titistore.es\" ||\n\t\treq.http.X-Referer-Host == \"biztro.pl\" ||\n\t\treq.http.X-Referer-Host == \"zd.ews.co.rs\" ||\n\t\treq.http.X-Referer-Host == \"www.cafelatincaen.com\" ||\n\t\treq.http.X-Referer-Host == \"togume.com\" ||\n\t\treq.http.X-Referer-Host == \"connect.mulesoft.com\" ||\n\t\treq.http.X-Referer-Host == \"nataktivisterna.lo\" ||\n\t\treq.http.X-Referer-Host == \"livelean.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"copyprint.nl\" ||\n\t\treq.http.X-Referer-Host == \"jayhathaway.com\" ||\n\t\treq.http.X-Referer-Host == \"rugsejis.epratybos.lt\" ||\n\t\treq.http.X-Referer-Host == \"media-env.elasticbeanstalk.com\" ||\n\t\treq.http.X-Referer-Host == \"id.snowfire.io\" ||\n\t\treq.http.X-Referer-Host == \"employme.at\" ||\n\t\treq.http.X-Referer-Host == \"booleanbrothers.com\" ||\n\t\treq.http.X-Referer-Host == \"www.fusiongroup.ie\" ||\n\t\treq.http.X-Referer-Host == \"skyhighnetworks.gravitatestaging.com\" ||\n\t\treq.http.X-Referer-Host == \"www.teachers.youtalkonline.com\" ||\n\t\treq.http.X-Referer-Host == \"sunshineandfrank.com\" ||\n\t\treq.http.X-Referer-Host == \"proof.acemedia.bigroominternet.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"personaltrainersinlosangeles.com\" ||\n\t\treq.http.X-Referer-Host == \"www.shawn.co\" ||\n\t\treq.http.X-Referer-Host == \"solidproperty.com.my\" ||\n\t\treq.http.X-Referer-Host == \"www.nordicinox.com\" ||\n\t\treq.http.X-Referer-Host == \"tension.com\" ||\n\t\treq.http.X-Referer-Host == \"especiaiss3.gshow.globo.com\" ||\n\t\treq.http.X-Referer-Host == \"seebstore.com\" ||\n\t\treq.http.X-Referer-Host == \"packerz.uk\" ||\n\t\treq.http.X-Referer-Host == \"happyliving.jp\" ||\n\t\treq.http.X-Referer-Host == \"www.vacacionesdebuenrollito.com\" ||\n\t\treq.http.X-Referer-Host == \"plastpack.ind.br\" ||\n\t\treq.http.X-Referer-Host == \"finance.trunk.development.manhattan.gq1.yahoo.com\" ||\n\t\treq.http.X-Referer-Host == \"elearningpprd.biworldwide.com\" ||\n\t\treq.http.X-Referer-Host == \"millwardesque.com\" ||\n\t\treq.http.X-Referer-Host == \"icehotel.lo\" ||\n\t\treq.http.X-Referer-Host == \"ongair.im\" ||\n\t\treq.http.X-Referer-Host == \"mule01a.managed.contegix.com\" ||\n\t\treq.http.X-Referer-Host == \"ipated.org\" ||\n\t\treq.http.X-Referer-Host == \"cientifica-research.com\" ||\n\t\treq.http.X-Referer-Host == \"andreypopp.github.io\" ||\n\t\treq.http.X-Referer-Host == \"schools.medsense.in\" ||\n\t\treq.http.X-Referer-Host == \"d-ycl.cigna.com\" ||\n\t\treq.http.X-Referer-Host == \"romankorver.com\" ||\n\t\treq.http.X-Referer-Host == \"ihaveanidea.me\" ||\n\t\treq.http.X-Referer-Host == \"evoyan.org\" ||\n\t\treq.http.X-Referer-Host == \"cectserver.dyndns.org\" ||\n\t\treq.http.X-Referer-Host == \"test.idx.dev.rets.ly\" ||\n\t\treq.http.X-Referer-Host == \"vastgoedpro.dataquote.nl\" ||\n\t\treq.http.X-Referer-Host == \"sifopweb\" ||\n\t\treq.http.X-Referer-Host == \"instituteofselfmastery.com.au\" ||\n\t\treq.http.X-Referer-Host == \"www.automobrella.com\" ||\n\t\treq.http.X-Referer-Host == \"panel.mibubu.com\" ||\n\t\treq.http.X-Referer-Host == \"whsb.herokuapp.com\" ||\n\t\treq.http.X-Referer-Host == \"heastea.com\" ||\n\t\treq.http.X-Referer-Host == \"meishinkan.pl\" ||\n\t\treq.http.X-Referer-Host == \"manrepeller.staging.wpengine.com\" ||\n\t\treq.http.X-Referer-Host == \"derprecated.com\" ||\n\t\treq.http.X-Referer-Host == \"fobesfamily.com\" ||\n\t\treq.http.X-Referer-Host == \"tensionautomation.com\" ||\n\t\treq.http.X-Referer-Host == \"www.jesuisoriginale.com\" ||\n\t\treq.http.X-Referer-Host == \"www.domgonsa.com.ar\" ||\n\t\treq.http.X-Referer-Host == \"www.digitalpark.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"debray.jerome.free.fr\" ||\n\t\treq.http.X-Referer-Host == \"rainmakerthinking.training\" ||\n\t\treq.http.X-Referer-Host == \"thespineauthority.com.au\" ||\n\t\treq.http.X-Referer-Host == \"pseudocubic.com\" ||\n\t\treq.http.X-Referer-Host == \"mi.sky8.it\" ||\n\t\treq.http.X-Referer-Host == \"iteo.staging.wpengine.com\" ||\n\t\treq.http.X-Referer-Host == \"adscend-q.dev\" ||\n\t\treq.http.X-Referer-Host == \"taxes-in-serbia.ews.co.rs\" ||\n\t\treq.http.X-Referer-Host == \"s.codepen.io\" ||\n\t\treq.http.X-Referer-Host == \"seecanadabetter.ca\" ||\n\t\treq.http.X-Referer-Host == \"www.werkbund.com.br\" ||\n\t\treq.http.X-Referer-Host == \"www.art365.co.za\" ||\n\t\treq.http.X-Referer-Host == \"tensionpackaging.com\" ||\n\t\treq.http.X-Referer-Host == \"ec2-54-164-179-111.compute-1.amazonaws.com\" ||\n\t\treq.http.X-Referer-Host == \"sms.loc\" ||\n\t\treq.http.X-Referer-Host == \"timeclock.neonandmore.com\" ||\n\t\treq.http.X-Referer-Host == \"silverblingblack.com\" ||\n\t\treq.http.X-Referer-Host == \"www.modulolanguage.com\" ||\n\t\treq.http.X-Referer-Host == \"visualise.today\" ||\n\t\treq.http.X-Referer-Host == \"pickinglist.constance.com.br\" ||\n\t\treq.http.X-Referer-Host == \"mobileshoppingapps.net\" ||\n\t\treq.http.X-Referer-Host == \"ashleyandbarry.com\" ||\n\t\treq.http.X-Referer-Host == \"www.planetgreen.cl\" ||\n\t\treq.http.X-Referer-Host == \"portal-intranet.ti.sabesp.com.br\" ||\n\t\treq.http.X-Referer-Host == \"gordonrecords.net\" ||\n\t\treq.http.X-Referer-Host == \"cce.pathlore.net\" ||\n\t\treq.http.X-Referer-Host == \"www.myclaimvalue.com\" ||\n\t\treq.http.X-Referer-Host == \"stage.mulesoft.org\" ||\n\t\treq.http.X-Referer-Host == \"javiblog.javigs.es\"\n\t) {\n\t\tset req.http.X-Redir-URL = \"https:\/\/legacy.polyfill.io\" req.url;\n\t\terror 900 req.http.X-Redir-URL;\n\t}\n\n\tif (req.url ~ \"^\/v1\/polyfill\\.\" && req.url !~ \"[\\?\\&]ua=\") {\n\t\tset req.http.X-Orig-URL = req.url;\n\t\tset req.url = \"\/v1\/normalizeUa?ua=\" regsuball(regsuball(regsuball(req.http.User-Agent, {\"%\"}, {\"%25\"}), {\" \"}, {\"%20\"}), {\"&\"}, {\"%26\"});\n\t}\n\n\treturn(lookup);\n}\n\nsub vcl_deliver {\n#FASTLY deliver\n\tif (req.url ~ \"^\/v1\/normalizeUa\" && resp.status == 200) {\n\t\tset req.http.Fastly-force-Shield = \"1\";\n\t\tif (req.http.X-Orig-URL ~ \"\\?\") {\n\t\t\tset req.url = req.http.X-Orig-URL \"&ua=\" resp.http.Normalized-User-Agent;\n\t\t} else {\n\t\t\tset req.url = req.http.X-Orig-URL \"?ua=\" resp.http.Normalized-User-Agent;\n\t\t}\n\t\trestart;\n\t} else if (req.url ~ \"^\/v1\/polyfill\\..*[\\?\\&]ua=\" && req.http.X-Orig-URL && req.http.X-Orig-URL !~ \"[\\?\\&]ua=\") {\n\t\tset resp.http.Vary = \"Accept-Encoding, User-Agent\";\n\t}\n\treturn(deliver);\n}\n\nsub vcl_error {\n\tif (obj.status == 900) {\n\t\tset obj.http.Location = obj.response;\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\tsynthetic {\"The referer header or request URI supplied in your request is known to be an attempt to use the previous version of polyfill.io, so for backwards compatibility we're redirecting you to legacy.polyfill.io which will handle your request using the old version of the service. The legacy version will be discontinued in the future, so please update to the new version, and then let us know by raising an issue in our repo at https:\/\/github.com\/financial-times\/polyfill-service.\"};\n\t\treturn (deliver);\n\t}\n}\n","old_contents":"sub vcl_recv {\n#FASTLY recv\n\n\tif (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n\t return(pass);\n\t}\n\n\t# Redirect legacy service users to legacy service\n\tset req.http.X-Referer-Host = regsub(req.http.Referer, \"^https?\\:\\\/\\\/([^\\\/]+)(\\\/.*)?$\", \"\\1\");\n\tif (req.url == \"\/normalize.js\" ||\n\t\treq.url == \"\/normalize.css\" ||\n\t\treq.url == \"\/normalise.js\" ||\n\t\treq.url == \"\/normalise.css\" ||\n\t\treq.http.X-Referer-Host == \"www.manrepeller.com\" ||\n\t\treq.http.X-Referer-Host == \"www.mulesoft.com\" ||\n\t\treq.http.X-Referer-Host == \"iluoghidelcuore.it\" ||\n\t\treq.http.X-Referer-Host == \"it.donga.com\" ||\n\t\treq.http.X-Referer-Host == \"www.watchguard.com\" ||\n\t\treq.http.X-Referer-Host == \"www.mulesoft.org\" ||\n\t\treq.http.X-Referer-Host == \"asmwall.com\" ||\n\t\treq.http.X-Referer-Host == \"www.jcsu.edu\" ||\n\t\treq.http.X-Referer-Host == \"adscendmedia.com\" ||\n\t\treq.http.X-Referer-Host == \"game.donga.com\" ||\n\t\treq.http.X-Referer-Host == \"framkino.no\" ||\n\t\treq.http.X-Referer-Host == \"www.accesswireless.com\" ||\n\t\treq.http.X-Referer-Host == \"represent.com\" ||\n\t\treq.http.X-Referer-Host == \"www.designergreek.com\" ||\n\t\treq.http.X-Referer-Host == \"www.plumbingoverstock.com\" ||\n\t\treq.http.X-Referer-Host == \"servicos.searh.rn.gov.br\" ||\n\t\treq.http.X-Referer-Host == \"www.jane-usa.com\" ||\n\t\treq.http.X-Referer-Host == \"www.juntaempresa.com.br\" ||\n\t\treq.http.X-Referer-Host == \"watchguard.com\" ||\n\t\treq.http.X-Referer-Host == \"www.logianalytics.com\" ||\n\t\treq.http.X-Referer-Host == \"www.thebathpoint.com\" ||\n\t\treq.http.X-Referer-Host == \"blogs.mulesoft.org\" ||\n\t\treq.http.X-Referer-Host == \"www.purecanadiangaming.com\" ||\n\t\treq.http.X-Referer-Host == \"play.egzaminatorius.lt\" ||\n\t\treq.http.X-Referer-Host == \"internetacademi.com\" ||\n\t\treq.http.X-Referer-Host == \"www.skyhighnetworks.com\" ||\n\t\treq.http.X-Referer-Host == \"interactive.guim.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"www.soloio.com\" ||\n\t\treq.http.X-Referer-Host == \"desenvolvimentoparaweb.com\" ||\n\t\treq.http.X-Referer-Host == \"daily-fantasy.trunk.development.manhattan.gq1.yahoo.com\" ||\n\t\treq.http.X-Referer-Host == \"blog.damyller.com.br\" ||\n\t\treq.http.X-Referer-Host == \"doggiebag.no\" ||\n\t\treq.http.X-Referer-Host == \"www.beverlydiamonds.com\" ||\n\t\treq.http.X-Referer-Host == \"www.rogerscup.com\" ||\n\t\treq.http.X-Referer-Host == \"blog.hudy.cz\" ||\n\t\treq.http.X-Referer-Host == \"techhamlet.com\" ||\n\t\treq.http.X-Referer-Host == \"www.flirtfachmann.de\" ||\n\t\treq.http.X-Referer-Host == \"alpacacomics.com\" ||\n\t\treq.http.X-Referer-Host == \"areariservata.fondoprevidenzafinanze.it\" ||\n\t\treq.http.X-Referer-Host == \"www.framkino.no\" ||\n\t\treq.http.X-Referer-Host == \"www.nationalsecurities.com\" ||\n\t\treq.http.X-Referer-Host == \"www.tenniscanada.com\" ||\n\t\treq.http.X-Referer-Host == \"libek.org.rs\" ||\n\t\treq.http.X-Referer-Host == \"learn.logianalytics.com\" ||\n\t\treq.http.X-Referer-Host == \"www.impartner.lt\" ||\n\t\treq.http.X-Referer-Host == \"chameleon.biworldwide.com\" ||\n\t\treq.http.X-Referer-Host == \"www.pujckapowebu.cz\" ||\n\t\treq.http.X-Referer-Host == \"www.dlcnetwork.com\" ||\n\t\treq.http.X-Referer-Host == \"www.forbes.com\" ||\n\t\treq.http.X-Referer-Host == \"blog.skyhighnetworks.com\" ||\n\t\treq.http.X-Referer-Host == \"rflx.bjornborg.com\" ||\n\t\treq.http.X-Referer-Host == \"www.coach-outlet-store.com\" ||\n\t\treq.http.X-Referer-Host == \"gist.io\" ||\n\t\treq.http.X-Referer-Host == \"www.suicideispreventable.org\" ||\n\t\treq.http.X-Referer-Host == \"www.rangemastertacticalgear.com\" ||\n\t\treq.http.X-Referer-Host == \"www.hcpozicka.sk\" ||\n\t\treq.http.X-Referer-Host == \"www.airsoftmegastore.com\" ||\n\t\treq.http.X-Referer-Host == \"colortile.github.io\" ||\n\t\treq.http.X-Referer-Host == \"brasstacksmadras.com\" ||\n\t\treq.http.X-Referer-Host == \"hotelcasadomingo.com.mx\" ||\n\t\treq.http.X-Referer-Host == \"client.local\" ||\n\t\treq.http.X-Referer-Host == \"www.worcesterpromotions.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"www.asmwall.com\" ||\n\t\treq.http.X-Referer-Host == \"training.mulesoft.com\" ||\n\t\treq.http.X-Referer-Host == \"exhilarateme.com\" ||\n\t\treq.http.X-Referer-Host == \"www.kommentatorskampen.viasatsport.se\" ||\n\t\treq.http.X-Referer-Host == \"www.golfgearselect.com\" ||\n\t\treq.http.X-Referer-Host == \"www.hcpujcka.cz\" ||\n\t\treq.http.X-Referer-Host == \"www.industriallawsociety.org.uk\" ||\n\t\treq.http.X-Referer-Host == \"www.locawebcorp.com.br\" ||\n\t\treq.http.X-Referer-Host == \"giffffr.giphy.com\" ||\n\t\treq.http.X-Referer-Host == \"mccall.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"kommentatorskampen.viasatsport.se\" ||\n\t\treq.http.X-Referer-Host == \"miraclebodyandpaint.com\" ||\n\t\treq.http.X-Referer-Host == \"www.tymprozdravi.cz\" ||\n\t\treq.http.X-Referer-Host == \"delicius.it\" ||\n\t\treq.http.X-Referer-Host == \"www.bluehighwaygames.com\" ||\n\t\treq.http.X-Referer-Host == \"tales-of-pikohan.de\" ||\n\t\treq.http.X-Referer-Host == \"demo.restoreadytest.com\" ||\n\t\treq.http.X-Referer-Host == \"mark.stratmann.me\" ||\n\t\treq.http.X-Referer-Host == \"apixtechnology.com\" ||\n\t\treq.http.X-Referer-Host == \"www.telefonickapozicka.sk\" ||\n\t\treq.http.X-Referer-Host == \"www.telefonnipujcka.cz\" ||\n\t\treq.http.X-Referer-Host == \"www.iteo.no\" ||\n\t\treq.http.X-Referer-Host == \"www.diktate.info\" ||\n\t\treq.http.X-Referer-Host == \"bpharm.192.168.56.102.xip.io\" ||\n\t\treq.http.X-Referer-Host == \"www.artisanprecast.com\" ||\n\t\treq.http.X-Referer-Host == \"tcisolutions.com\" ||\n\t\treq.http.X-Referer-Host == \"icelebrate.icehotel.com\" ||\n\t\treq.http.X-Referer-Host == \"www.thirtysevenwest.com\" ||\n\t\treq.http.X-Referer-Host == \"www.asgllc.com\" ||\n\t\treq.http.X-Referer-Host == \"www.mailinbox.net\" ||\n\t\treq.http.X-Referer-Host == \"rustyfelty.com\" ||\n\t\treq.http.X-Referer-Host == \"pulse.p2c.com\" ||\n\t\treq.http.X-Referer-Host == \"www.framkino.com\" ||\n\t\treq.http.X-Referer-Host == \"armourselfstorage.com\" ||\n\t\treq.http.X-Referer-Host == \"www.dezrezblog.com\" ||\n\t\treq.http.X-Referer-Host == \"goodpeople.com\" ||\n\t\treq.http.X-Referer-Host == \"www.eden-houlgate.com\" ||\n\t\treq.http.X-Referer-Host == \"www.patiovirtual.com.br\" ||\n\t\treq.http.X-Referer-Host == \"stats.egzaminatorius.lt\" ||\n\t\treq.http.X-Referer-Host == \"www.movieville.org\" ||\n\t\treq.http.X-Referer-Host == \"secure.watchguard.com\" ||\n\t\treq.http.X-Referer-Host == \"nationalsecurities.com\" ||\n\t\treq.http.X-Referer-Host == \"www.snaponindustrial.eu\" ||\n\t\treq.http.X-Referer-Host == \"www.fangear.com\" ||\n\t\treq.http.X-Referer-Host == \"www.scribbleshop.com\" ||\n\t\treq.http.X-Referer-Host == \"forums.mulesoft.org\" ||\n\t\treq.http.X-Referer-Host == \"dataentries.in\" ||\n\t\treq.http.X-Referer-Host == \"maki.alconost.com\" ||\n\t\treq.http.X-Referer-Host == \"dixso.github.io\" ||\n\t\treq.http.X-Referer-Host == \"citaprevia.volkswagen.es\" ||\n\t\treq.http.X-Referer-Host == \"movieville.org\" ||\n\t\treq.http.X-Referer-Host == \"www.seoestudios.com\" ||\n\t\treq.http.X-Referer-Host == \"tickets.campo.nu\" ||\n\t\treq.http.X-Referer-Host == \"perriehale.toucan\" ||\n\t\treq.http.X-Referer-Host == \"online.printstation.cz\" ||\n\t\treq.http.X-Referer-Host == \"www.le-bistrot-basque.com\" ||\n\t\treq.http.X-Referer-Host == \"www.thaiartofmassage.com\" ||\n\t\treq.http.X-Referer-Host == \"www.seevolution.com\" ||\n\t\treq.http.X-Referer-Host == \"janeusa.david\" ||\n\t\treq.http.X-Referer-Host == \"www.goodpeople.com\" ||\n\t\treq.http.X-Referer-Host == \"feeds.feedburner.com\" ||\n\t\treq.http.X-Referer-Host == \"www.millwardesque.com\" ||\n\t\treq.http.X-Referer-Host == \"cci.smartucs.a\" ||\n\t\treq.http.X-Referer-Host == \"forum.tales-of-pikohan.de\" ||\n\t\treq.http.X-Referer-Host == \"small.mu\" ||\n\t\treq.http.X-Referer-Host == \"crisp.toucan\" ||\n\t\treq.http.X-Referer-Host == \"www.fosterdenovo.local\" ||\n\t\treq.http.X-Referer-Host == \"dev1776.nationalsecurities.com\" ||\n\t\treq.http.X-Referer-Host == \"byose.net\" ||\n\t\treq.http.X-Referer-Host == \"www.eurodiary.ie\" ||\n\t\treq.http.X-Referer-Host == \"lemouvementassociatif.org\" ||\n\t\treq.http.X-Referer-Host == \"www.ey.com\" ||\n\t\treq.http.X-Referer-Host == \"cuterunslive.com\" ||\n\t\treq.http.X-Referer-Host == \"blog.odynia.org\" ||\n\t\treq.http.X-Referer-Host == \"solarenaymar.com.ar\" ||\n\t\treq.http.X-Referer-Host == \"www.aispaitalia.it\" ||\n\t\treq.http.X-Referer-Host == \"www.startupsaturday.it\" ||\n\t\treq.http.X-Referer-Host == \"support.watchguard.com\" ||\n\t\treq.http.X-Referer-Host == \"dax.absolnet.se\" ||\n\t\treq.http.X-Referer-Host == \"www.creativeinnovation.net.au\" ||\n\t\treq.http.X-Referer-Host == \"dev.raird.no\" ||\n\t\treq.http.X-Referer-Host == \"lesjeteursdencre.fr\" ||\n\t\treq.http.X-Referer-Host == \"itnotes.pl\" ||\n\t\treq.http.X-Referer-Host == \"www.thesocietyinternational.com\" ||\n\t\treq.http.X-Referer-Host == \"terminalfx.com\" ||\n\t\treq.http.X-Referer-Host == \"draft.sx\" ||\n\t\treq.http.X-Referer-Host == \"atelier-florent.fr\" ||\n\t\treq.http.X-Referer-Host == \"www.buona-tavola-ristorante.fr\" ||\n\t\treq.http.X-Referer-Host == \"www.terminalfx.com\" ||\n\t\treq.http.X-Referer-Host == \"www.taxattorney.com\" ||\n\t\treq.http.X-Referer-Host == \"proenter.dev\" ||\n\t\treq.http.X-Referer-Host == \"bodelo-advocaten.be\" ||\n\t\treq.http.X-Referer-Host == \"www.football1asia.com\" ||\n\t\treq.http.X-Referer-Host == \"rets.ly\" ||\n\t\treq.http.X-Referer-Host == \"erriol.com\" ||\n\t\treq.http.X-Referer-Host == \"shssandiego.com\" ||\n\t\treq.http.X-Referer-Host == \"notecrow.appspot.com\" ||\n\t\treq.http.X-Referer-Host == \"framkino.com\" ||\n\t\treq.http.X-Referer-Host == \"sexsite.daan\" ||\n\t\treq.http.X-Referer-Host == \"sro.dk\" ||\n\t\treq.http.X-Referer-Host == \"www.coloft.com\" ||\n\t\treq.http.X-Referer-Host == \"taxiplus.vsystem.hu\" ||\n\t\treq.http.X-Referer-Host == \"stage.mulesoft.com\" ||\n\t\treq.http.X-Referer-Host == \"local.dev.ugameplan.com\" ||\n\t\treq.http.X-Referer-Host == \"posh-nosh.com\" ||\n\t\treq.http.X-Referer-Host == \"phongthuyshop.vn\" ||\n\t\treq.http.X-Referer-Host == \"local.mansionhouse.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"www.compareaccounting.com\" ||\n\t\treq.http.X-Referer-Host == \"news.coinometrics.com\" ||\n\t\treq.http.X-Referer-Host == \"prod-yann.mailinbox.net\" ||\n\t\treq.http.X-Referer-Host == \"rachelree.se\" ||\n\t\treq.http.X-Referer-Host == \"dev1.accesswireless.usdigitalpartners.net\" ||\n\t\treq.http.X-Referer-Host == \"www.ewirisk.com\" ||\n\t\treq.http.X-Referer-Host == \"snapchan.com\" ||\n\t\treq.http.X-Referer-Host == \"www.trikatasieraakademija.lv\" ||\n\t\treq.http.X-Referer-Host == \"www.fosteringadoptionswindon.org.uk\" ||\n\t\treq.http.X-Referer-Host == \"patiovirtual.com.br\" ||\n\t\treq.http.X-Referer-Host == \"www.libmanpro.com\" ||\n\t\treq.http.X-Referer-Host == \"www.diktate.dev\" ||\n\t\treq.http.X-Referer-Host == \"idisco.pianetaitalia.intra\" ||\n\t\treq.http.X-Referer-Host == \"strudelfolhadinho.com.br\" ||\n\t\treq.http.X-Referer-Host == \"www.cunesoft.com\" ||\n\t\treq.http.X-Referer-Host == \"www.shropshirefoundation.org\" ||\n\t\treq.http.X-Referer-Host == \"speakingofbeauty.tv\" ||\n\t\treq.http.X-Referer-Host == \"www.sbs.com.au\" ||\n\t\treq.http.X-Referer-Host == \"bosch.pikmahosting.de\" ||\n\t\treq.http.X-Referer-Host == \"janeusa.lol\" ||\n\t\treq.http.X-Referer-Host == \"eso.toucan\" ||\n\t\treq.http.X-Referer-Host == \"www.lamedicis.com\" ||\n\t\treq.http.X-Referer-Host == \"cereseurope.com\" ||\n\t\treq.http.X-Referer-Host == \"www.pizza-moltobene.fr\" ||\n\t\treq.http.X-Referer-Host == \"www.kaptiva.com.br\" ||\n\t\treq.http.X-Referer-Host == \"flixified.com\" ||\n\t\treq.http.X-Referer-Host == \"www.12roundsboxing.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"www.tensionautomation.com\" ||\n\t\treq.http.X-Referer-Host == \"www.copyprint.nl\" ||\n\t\treq.http.X-Referer-Host == \"unisol\" ||\n\t\treq.http.X-Referer-Host == \"timepad.ews.co.rs\" ||\n\t\treq.http.X-Referer-Host == \"dev.rets.ly\" ||\n\t\treq.http.X-Referer-Host == \"www.vrhabilis.com\" ||\n\t\treq.http.X-Referer-Host == \"trondheggelund.no\" ||\n\t\treq.http.X-Referer-Host == \"www.ferienwohnungen-lebenswert.de\" ||\n\t\treq.http.X-Referer-Host == \"blog.mainline.com\" ||\n\t\treq.http.X-Referer-Host == \"arcstonepartners.com\" ||\n\t\treq.http.X-Referer-Host == \"dev-mj\" ||\n\t\treq.http.X-Referer-Host == \"www.crisp-cpd.com\" ||\n\t\treq.http.X-Referer-Host == \"purecanadiangaming.com\" ||\n\t\treq.http.X-Referer-Host == \"mainline.com\" ||\n\t\treq.http.X-Referer-Host == \"idx.dev.rets.ly\" ||\n\t\treq.http.X-Referer-Host == \"eneco.flicker.visualwind.com\" ||\n\t\treq.http.X-Referer-Host == \"mi.etoilemedia.it\" ||\n\t\treq.http.X-Referer-Host == \"www.atmosphericwatergenerator.net\" ||\n\t\treq.http.X-Referer-Host == \"www.gasnaturalenergyclass.com\" ||\n\t\treq.http.X-Referer-Host == \"salesmarketing.championpetfoods.com\" ||\n\t\treq.http.X-Referer-Host == \"www.watchgaurd.com\" ||\n\t\treq.http.X-Referer-Host == \"vm-sqlext-svil\" ||\n\t\treq.http.X-Referer-Host == \"dev.accesswireless.usdigitalpartners.net\" ||\n\t\treq.http.X-Referer-Host == \"kommentatorskampen.ohmytest.se\" ||\n\t\treq.http.X-Referer-Host == \"m.euvivoesporte.com.br\" ||\n\t\treq.http.X-Referer-Host == \"blog.dasroot.net\" ||\n\t\treq.http.X-Referer-Host == \"bugsdashboard.com\" ||\n\t\treq.http.X-Referer-Host == \"www.eurodiary.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"seecanadabetter-app.appspot.com\" ||\n\t\treq.http.X-Referer-Host == \"www.bobbychanblog.com\" ||\n\t\treq.http.X-Referer-Host == \"www.mybenefitsatwork.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"www.fotolotos.lt\" ||\n\t\treq.http.X-Referer-Host == \"robferguson.org\" ||\n\t\treq.http.X-Referer-Host == \"staging.motherapp.com\" ||\n\t\treq.http.X-Referer-Host == \"www.undergroundminingequipmentcompaniescalgaryquotes.com\" ||\n\t\treq.http.X-Referer-Host == \"idisco.pianetaitalia.com\" ||\n\t\treq.http.X-Referer-Host == \"cliocalman.com\" ||\n\t\treq.http.X-Referer-Host == \"sexymirror-app.com\" ||\n\t\treq.http.X-Referer-Host == \"taxes-in-serbia.192.168.56.102.xip.io\" ||\n\t\treq.http.X-Referer-Host == \"wunderbiz.com\" ||\n\t\treq.http.X-Referer-Host == \"thebathpoint.webdemo.es\" ||\n\t\treq.http.X-Referer-Host == \"www.restaurant-lemenhir.com\" ||\n\t\treq.http.X-Referer-Host == \"www.valdeure.fr\" ||\n\t\treq.http.X-Referer-Host == \"bpharm.ews.co.rs\" ||\n\t\treq.http.X-Referer-Host == \"teachersdunet.com\" ||\n\t\treq.http.X-Referer-Host == \"livesmartswmo.com\" ||\n\t\treq.http.X-Referer-Host == \"javiblog.com\" ||\n\t\treq.http.X-Referer-Host == \"portal.com.local\" ||\n\t\treq.http.X-Referer-Host == \"mi.etoilemedia.com\" ||\n\t\treq.http.X-Referer-Host == \"www.lens.org\" ||\n\t\treq.http.X-Referer-Host == \"blacknet.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"my-faith-be-like.ghost.io\" ||\n\t\treq.http.X-Referer-Host == \"laravel.dev\" ||\n\t\treq.http.X-Referer-Host == \"fi-hpotts.2014-mansionhouse\" ||\n\t\treq.http.X-Referer-Host == \"mi.mailinbox.net\" ||\n\t\treq.http.X-Referer-Host == \"www.schulkeplusrewards.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"sasha-project.s3.amazonaws.com\" ||\n\t\treq.http.X-Referer-Host == \"www.solarenaymar.com.ar\" ||\n\t\treq.http.X-Referer-Host == \"generate.visualwind.com\" ||\n\t\treq.http.X-Referer-Host == \"drupaltest.wgti.net\" ||\n\t\treq.http.X-Referer-Host == \"minasdev.org\" ||\n\t\treq.http.X-Referer-Host == \"ims-logistic.dev\" ||\n\t\treq.http.X-Referer-Host == \"viaresto.com\" ||\n\t\treq.http.X-Referer-Host == \"learn.logixml.com\" ||\n\t\treq.http.X-Referer-Host == \"ox.espadrill-admin\" ||\n\t\treq.http.X-Referer-Host == \"smallmu-sandbox.s3-ap-southeast-1.amazonaws.com\" ||\n\t\treq.http.X-Referer-Host == \"www.firstinternet.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"m.facebook.com\" ||\n\t\treq.http.X-Referer-Host == \"www.ace.media\" ||\n\t\treq.http.X-Referer-Host == \"www.ewiretx.com\" ||\n\t\treq.http.X-Referer-Host == \"crisp.test.tdev.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"www.mifabricavisual.com\" ||\n\t\treq.http.X-Referer-Host == \"www.targetintervention.no\" ||\n\t\treq.http.X-Referer-Host == \"www.couperogers.com\" ||\n\t\treq.http.X-Referer-Host == \"skyhighstaging.local.com\" ||\n\t\treq.http.X-Referer-Host == \"altorendimientoacademico.queretaro.itesm.mx\" ||\n\t\treq.http.X-Referer-Host == \"www.gall-holl.com\" ||\n\t\treq.http.X-Referer-Host == \"sbs-moad.s3-ap-southeast-2.amazonaws.com\" ||\n\t\treq.http.X-Referer-Host == \"firstint.recruitment-lite\" ||\n\t\treq.http.X-Referer-Host == \"www.sro.dk\" ||\n\t\treq.http.X-Referer-Host == \"www.menbur.com\" ||\n\t\treq.http.X-Referer-Host == \"libmanpro.com\" ||\n\t\treq.http.X-Referer-Host == \"blurayaustralia.com\" ||\n\t\treq.http.X-Referer-Host == \"www.adscendmedia.com\" ||\n\t\treq.http.X-Referer-Host == \"blog.vincentbrouillet.com\" ||\n\t\treq.http.X-Referer-Host == \"www.investiumonline.nl\" ||\n\t\treq.http.X-Referer-Host == \"burakkp.com\" ||\n\t\treq.http.X-Referer-Host == \"audreysystem.seeties.me\" ||\n\t\treq.http.X-Referer-Host == \"everestsalesconsultants.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"accesswireless.usdphosting.com\" ||\n\t\treq.http.X-Referer-Host == \"frota.searh.rn.gov.br\" ||\n\t\treq.http.X-Referer-Host == \"qa.ugameplan.com\" ||\n\t\treq.http.X-Referer-Host == \"secure.yec.co\" ||\n\t\treq.http.X-Referer-Host == \"connect.eu.mulesoft.com\" ||\n\t\treq.http.X-Referer-Host == \"www.lastlongerreview.com\" ||\n\t\treq.http.X-Referer-Host == \"kommentatorskampen.lo\" ||\n\t\treq.http.X-Referer-Host == \"kido.bigroominternet.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"ohmydev.se\" ||\n\t\treq.http.X-Referer-Host == \"www.bentogarcia.es\" ||\n\t\treq.http.X-Referer-Host == \"rearview.herokai.com\" ||\n\t\treq.http.X-Referer-Host == \"lecafelatin.resto-ready.com\" ||\n\t\treq.http.X-Referer-Host == \"html24-dev.dk\" ||\n\t\treq.http.X-Referer-Host == \"seecanadabetter.ddev\" ||\n\t\treq.http.X-Referer-Host == \"portal.ad1.wrvc.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"garthwunsch.com\" ||\n\t\treq.http.X-Referer-Host == \"www.elitecustomsigns.com\" ||\n\t\treq.http.X-Referer-Host == \"kaptiva.com.br\" ||\n\t\treq.http.X-Referer-Host == \"nordicinox.com\" ||\n\t\treq.http.X-Referer-Host == \"www.nataktivisterna.lo\" ||\n\t\treq.http.X-Referer-Host == \"www.fidalgobaycoffee.com\" ||\n\t\treq.http.X-Referer-Host == \"mailinbox.net\" ||\n\t\treq.http.X-Referer-Host == \"www.tension.com\" ||\n\t\treq.http.X-Referer-Host == \"www.mccall.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"petbucks.org\" ||\n\t\treq.http.X-Referer-Host == \"mulesoftcompdev.prod.acquia-sites.com\" ||\n\t\treq.http.X-Referer-Host == \"logidev.devcloud.acquia-sites.com\" ||\n\t\treq.http.X-Referer-Host == \"www.cuterunslive.com\" ||\n\t\treq.http.X-Referer-Host == \"ec2-54-86-27-137.compute-1.amazonaws.com\" ||\n\t\treq.http.X-Referer-Host == \"coloft.com\" ||\n\t\treq.http.X-Referer-Host == \"dev-yann.mailinbox.net\" ||\n\t\treq.http.X-Referer-Host == \"titistore.es\" ||\n\t\treq.http.X-Referer-Host == \"biztro.pl\" ||\n\t\treq.http.X-Referer-Host == \"zd.ews.co.rs\" ||\n\t\treq.http.X-Referer-Host == \"www.cafelatincaen.com\" ||\n\t\treq.http.X-Referer-Host == \"togume.com\" ||\n\t\treq.http.X-Referer-Host == \"connect.mulesoft.com\" ||\n\t\treq.http.X-Referer-Host == \"che.local\" ||\n\t\treq.http.X-Referer-Host == \"nataktivisterna.lo\" ||\n\t\treq.http.X-Referer-Host == \"livelean.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"copyprint.nl\" ||\n\t\treq.http.X-Referer-Host == \"jayhathaway.com\" ||\n\t\treq.http.X-Referer-Host == \"rugsejis.epratybos.lt\" ||\n\t\treq.http.X-Referer-Host == \"media-env.elasticbeanstalk.com\" ||\n\t\treq.http.X-Referer-Host == \"id.snowfire.io\" ||\n\t\treq.http.X-Referer-Host == \"employme.at\" ||\n\t\treq.http.X-Referer-Host == \"booleanbrothers.com\" ||\n\t\treq.http.X-Referer-Host == \"www.fusiongroup.ie\" ||\n\t\treq.http.X-Referer-Host == \"skyhighnetworks.gravitatestaging.com\" ||\n\t\treq.http.X-Referer-Host == \"www.teachers.youtalkonline.com\" ||\n\t\treq.http.X-Referer-Host == \"sunshineandfrank.com\" ||\n\t\treq.http.X-Referer-Host == \"proof.acemedia.bigroominternet.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"personaltrainersinlosangeles.com\" ||\n\t\treq.http.X-Referer-Host == \"www.shawn.co\" ||\n\t\treq.http.X-Referer-Host == \"solidproperty.com.my\" ||\n\t\treq.http.X-Referer-Host == \"www.nordicinox.com\" ||\n\t\treq.http.X-Referer-Host == \"tension.com\" ||\n\t\treq.http.X-Referer-Host == \"especiaiss3.gshow.globo.com\" ||\n\t\treq.http.X-Referer-Host == \"seebstore.com\" ||\n\t\treq.http.X-Referer-Host == \"packerz.uk\" ||\n\t\treq.http.X-Referer-Host == \"happyliving.jp\" ||\n\t\treq.http.X-Referer-Host == \"www.vacacionesdebuenrollito.com\" ||\n\t\treq.http.X-Referer-Host == \"plastpack.ind.br\" ||\n\t\treq.http.X-Referer-Host == \"finance.trunk.development.manhattan.gq1.yahoo.com\" ||\n\t\treq.http.X-Referer-Host == \"elearningpprd.biworldwide.com\" ||\n\t\treq.http.X-Referer-Host == \"millwardesque.com\" ||\n\t\treq.http.X-Referer-Host == \"icehotel.lo\" ||\n\t\treq.http.X-Referer-Host == \"ongair.im\" ||\n\t\treq.http.X-Referer-Host == \"mule01a.managed.contegix.com\" ||\n\t\treq.http.X-Referer-Host == \"ipated.org\" ||\n\t\treq.http.X-Referer-Host == \"cientifica-research.com\" ||\n\t\treq.http.X-Referer-Host == \"andreypopp.github.io\" ||\n\t\treq.http.X-Referer-Host == \"schools.medsense.in\" ||\n\t\treq.http.X-Referer-Host == \"d-ycl.cigna.com\" ||\n\t\treq.http.X-Referer-Host == \"romankorver.com\" ||\n\t\treq.http.X-Referer-Host == \"ihaveanidea.me\" ||\n\t\treq.http.X-Referer-Host == \"evoyan.org\" ||\n\t\treq.http.X-Referer-Host == \"cectserver.dyndns.org\" ||\n\t\treq.http.X-Referer-Host == \"test.idx.dev.rets.ly\" ||\n\t\treq.http.X-Referer-Host == \"vastgoedpro.dataquote.nl\" ||\n\t\treq.http.X-Referer-Host == \"sifopweb\" ||\n\t\treq.http.X-Referer-Host == \"instituteofselfmastery.com.au\" ||\n\t\treq.http.X-Referer-Host == \"www.automobrella.com\" ||\n\t\treq.http.X-Referer-Host == \"panel.mibubu.com\" ||\n\t\treq.http.X-Referer-Host == \"whsb.herokuapp.com\" ||\n\t\treq.http.X-Referer-Host == \"heastea.com\" ||\n\t\treq.http.X-Referer-Host == \"meishinkan.pl\" ||\n\t\treq.http.X-Referer-Host == \"manrepeller.staging.wpengine.com\" ||\n\t\treq.http.X-Referer-Host == \"derprecated.com\" ||\n\t\treq.http.X-Referer-Host == \"fobesfamily.com\" ||\n\t\treq.http.X-Referer-Host == \"tensionautomation.com\" ||\n\t\treq.http.X-Referer-Host == \"www.jesuisoriginale.com\" ||\n\t\treq.http.X-Referer-Host == \"www.domgonsa.com.ar\" ||\n\t\treq.http.X-Referer-Host == \"www.digitalpark.co.uk\" ||\n\t\treq.http.X-Referer-Host == \"debray.jerome.free.fr\" ||\n\t\treq.http.X-Referer-Host == \"rainmakerthinking.training\" ||\n\t\treq.http.X-Referer-Host == \"thespineauthority.com.au\" ||\n\t\treq.http.X-Referer-Host == \"pseudocubic.com\" ||\n\t\treq.http.X-Referer-Host == \"mi.sky8.it\" ||\n\t\treq.http.X-Referer-Host == \"iteo.staging.wpengine.com\" ||\n\t\treq.http.X-Referer-Host == \"adscend-q.dev\" ||\n\t\treq.http.X-Referer-Host == \"taxes-in-serbia.ews.co.rs\" ||\n\t\treq.http.X-Referer-Host == \"s.codepen.io\" ||\n\t\treq.http.X-Referer-Host == \"seecanadabetter.ca\" ||\n\t\treq.http.X-Referer-Host == \"www.werkbund.com.br\" ||\n\t\treq.http.X-Referer-Host == \"www.art365.co.za\" ||\n\t\treq.http.X-Referer-Host == \"tensionpackaging.com\" ||\n\t\treq.http.X-Referer-Host == \"ec2-54-164-179-111.compute-1.amazonaws.com\" ||\n\t\treq.http.X-Referer-Host == \"sms.loc\" ||\n\t\treq.http.X-Referer-Host == \"timeclock.neonandmore.com\" ||\n\t\treq.http.X-Referer-Host == \"silverblingblack.com\" ||\n\t\treq.http.X-Referer-Host == \"www.modulolanguage.com\" ||\n\t\treq.http.X-Referer-Host == \"visualise.today\" ||\n\t\treq.http.X-Referer-Host == \"pickinglist.constance.com.br\" ||\n\t\treq.http.X-Referer-Host == \"mobileshoppingapps.net\" ||\n\t\treq.http.X-Referer-Host == \"ashleyandbarry.com\" ||\n\t\treq.http.X-Referer-Host == \"www.planetgreen.cl\" ||\n\t\treq.http.X-Referer-Host == \"portal-intranet.ti.sabesp.com.br\" ||\n\t\treq.http.X-Referer-Host == \"gordonrecords.net\" ||\n\t\treq.http.X-Referer-Host == \"cce.pathlore.net\" ||\n\t\treq.http.X-Referer-Host == \"www.myclaimvalue.com\" ||\n\t\treq.http.X-Referer-Host == \"stage.mulesoft.org\" ||\n\t\treq.http.X-Referer-Host == \"javiblog.javigs.es\"\n\t) {\n\t\tset req.http.X-Redir-URL = \"https:\/\/legacy.polyfill.io\" req.url;\n\t\terror 900 req.http.X-Redir-URL;\n\t}\n\n\tif (req.url ~ \"^\/v1\/polyfill\\.\" && req.url !~ \"[\\?\\&]ua=\") {\n\t\tset req.http.X-Orig-URL = req.url;\n\t\tset req.url = \"\/v1\/normalizeUa?ua=\" regsuball(regsuball(regsuball(req.http.User-Agent, {\"%\"}, {\"%25\"}), {\" \"}, {\"%20\"}), {\"&\"}, {\"%26\"});\n\t}\n\n\treturn(lookup);\n}\n\nsub vcl_deliver {\n#FASTLY deliver\n\tif (req.url ~ \"^\/v1\/normalizeUa\" && resp.status == 200) {\n\t\tset req.http.Fastly-force-Shield = \"1\";\n\t\tif (req.http.X-Orig-URL ~ \"\\?\") {\n\t\t\tset req.url = req.http.X-Orig-URL \"&ua=\" resp.http.Normalized-User-Agent;\n\t\t} else {\n\t\t\tset req.url = req.http.X-Orig-URL \"?ua=\" resp.http.Normalized-User-Agent;\n\t\t}\n\t\trestart;\n\t} else if (req.url ~ \"^\/v1\/polyfill\\..*[\\?\\&]ua=\" && req.http.X-Orig-URL && req.http.X-Orig-URL !~ \"[\\?\\&]ua=\") {\n\t\tset resp.http.Vary = \"Accept-Encoding, User-Agent\";\n\t}\n\treturn(deliver);\n}\n\nsub vcl_error {\n\tif (obj.status == 900) {\n\t\tset obj.http.Location = obj.response;\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\tsynthetic {\"The referer header or request URI supplied in your request is known to be an attempt to use the previous version of polyfill.io, so for backwards compatibility we're redirecting you to legacy.polyfill.io which will handle your request using the old version of the service. The legacy version will be discontinued in the future, so please update to the new version, and then let us know by raising an issue in our repo at https:\/\/github.com\/financial-times\/polyfill-service.\"};\n\t\treturn (deliver);\n\t}\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"40081e73ef2d64db7844715b70c40146cb165d8c","subject":"messing with web sockets","message":"messing with web sockets\n","repos":"derbyjs\/candygram","old_file":"varnish_default.vcl","new_file":"varnish_default.vcl","new_contents":"# This is a basic VCL configuration file for varnish. See the vcl(7)\n# man page for details on VCL syntax and semantics.\n\nimport std;\n\n# static\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"4000\";\n}\nbackend examples {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\nbackend components {\n .host = \"127.0.0.1\";\n .port = \"3330\";\n}\n\nsub vcl_recv {\n if (!req.http.Host) {\n error 404 \"Need a host header\";\n }\n\n set req.http.Host = regsub(req.http.Host, \"^www\\.\", \"\");\n set req.http.Host = regsub(req.http.Host, \":80$\", \"\");\n\n if (\n req.http.Host ~ \"^chat\\.\" ||\n req.http.Host ~ \"^charts\\.\" ||\n req.http.Host ~ \"^directory\\.\" ||\n req.http.Host ~ \"^codemirror\\.\" ||\n req.http.Host ~ \"^hello\\.\" ||\n req.http.Host ~ \"^sink\\.\" ||\n req.http.Host ~ \"^todos\\.\" ||\n req.http.Host ~ \"^widgets\\.\"\n ) {\n set req.backend = examples;\n } else if (req.http.Host ~ \"^components\\.\") {\n set req.backend = components;\n }\n\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n if (req.restarts == 0) {\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For =\n req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization || req.http.Cookie) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n return (lookup);\n}\n\nsub vcl_pipe {\n # Websockets\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n}\n","old_contents":"# This is a basic VCL configuration file for varnish. See the vcl(7)\n# man page for details on VCL syntax and semantics.\n\nimport std;\n\n# static\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"4000\";\n}\nbackend examples {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\nbackend components {\n .host = \"127.0.0.1\";\n .port = \"3330\";\n}\n\nsub vcl_recv {\n if (!req.http.Host) {\n error 404 \"Need a host header\";\n }\n\n set req.http.Host = regsub(req.http.Host, \"^www\\.\", \"\");\n set req.http.Host = regsub(req.http.Host, \":80$\", \"\");\n\n if (req.restarts == 0) {\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For =\n req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n if (\n req.http.Host ~ \"^chat\\.\" ||\n req.http.Host ~ \"^charts\\.\" ||\n req.http.Host ~ \"^directory\\.\" ||\n req.http.Host ~ \"^codemirror\\.\" ||\n req.http.Host ~ \"^hello\\.\" ||\n req.http.Host ~ \"^sink\\.\" ||\n req.http.Host ~ \"^todos\\.\" ||\n req.http.Host ~ \"^widgets\\.\"\n ) {\n set req.backend = examples;\n } else if (req.http.Host ~ \"^components\\.\") {\n set req.backend = components;\n }\n\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization || req.http.Cookie) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n return (lookup);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n if (req.http.Origin) {\n hash_data(req.http.Origin);\n }\n return (hash);\n}\n\nsub vcl_pipe {\n # Websockets\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n}\n\nsub vcl_fetch {\n # Compress responses\n if (beresp.http.content-type ~ \"text\"\n || beresp.http.content-type ~ \"json\"\n || beresp.http.content-type ~ \"javascript\") {\n set beresp.do_gzip = true;\n }\n}\n\nsub vcl_error {\n if (obj.status == 750) {\n # moved permanently\n set obj.http.Location = req.http.Location;\n set obj.status = 301;\n } else if (obj.status == 752) {\n # moved temporarily\n set obj.http.Location = req.http.Location;\n set obj.status = 302;\n } else {\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic std.fileread(\"\/etc\/varnish\/503.html\");\n }\n return (deliver);\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"0cd9f7f4d03a9f83874da54f3c9c782ac4de0f5a","subject":"Move Cache-Control\/Pragma setting to vcl_deliver and extend grace to a day","message":"Move Cache-Control\/Pragma setting to vcl_deliver and extend grace to a day\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/fastly.vcl","new_file":"etc\/fastly.vcl","new_contents":"###############################################################################\n#\n# Fastly CDN for Magento 2\n#\n# NOTICE OF LICENSE\n#\n# This source file is subject to the Fastly CDN for Magento 2 End User License\n# Agreement that is bundled with this package in the file LICENSE_FASTLY_CDN.txt.\n#\n# @copyright Copyright (c) 2016 Fastly, Inc. (http:\/\/www.fastly.com)\n# @license BSD, see LICENSE_FASTLY_CDN.txt\n#\n###############################################################################\n\n# This is a basic VCL configuration file for Fastly CDN for Magento 2 module.\n\nsub vcl_recv {\n#FASTLY recv\n\n\n # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n if (req.url ~ \"^\/static\/version(\\d*\/)?(.*)$\") {\n set req.url = \"\/static\/\" + re.group.2 + \"?\" + re.group.1;\n } \n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n set req.http.X-Sig = regsub(req.http.X-Purge-Token, \"^[^_]+_(.*)\", \"\\1\");\n set req.http.X-Exp = regsub(req.http.X-Purge-Token, \"^([^_]+)_.*\", \"\\1\");\n\n # validate signature\n if (req.http.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path req.http.X-Exp), \"^0x\", \"\")) {\n\n # use vcl time math to check expiration timestamp\n set req.http.X-Original-Grace = req.grace;\n set req.grace = std.atoi(strftime({\"%s\"}, now));\n set req.grace -= std.atoi(req.http.X-Exp);\n\n if (std.atoi(req.grace) > 0) {\n error 410;\n }\n\n # clean up grace since we used it for time math\n set req.grace = std.atoi(req.http.X-Original-Grace);\n unset req.http.X-Original-Grace;\n\n } else {\n error 403;\n }\n\n # cleanup variables\n unset req.http.X-Purge-Token;\n unset req.http.X-Sig;\n unset req.http.X-Exp;\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n # disable ESI processing on Origin Shield\n if (req.http.Fastly-FF) {\n set req.esi = false;\n }\n\n # We only deal with GET and HEAD by default\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n return (pass);\n }\n \n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie ~ \"(X-Magento-Vary|form_key)=\") {\n error 200 \"\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url !~ \"country_code=\" ) {\n set req.url = req.url \"?country_code=\" if ( req.http.geo_override, req.http.geo_override, geoip.country_code);\n }\n }\n } else {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking\n set req.http.Fastly-Original-URL = req.url;\n set req.url = querystring.regfilter(req.url, \"^(utm_.*|gclid|gdftrk|_ga|mc_.*)\");\n }\n \n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n return (lookup);\n }\n\n # Bypass shopping cart and checkout requests\n if (req.url ~ \"\/checkout\") {\n return (pass);\n }\n\n return(lookup);\n}\n\nsub vcl_fetch {\n\n # Remove Set-Cookies from responses for static content\n # to match the cookie removal in recv.\n if (req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n }\n\n }\n\n#FASTLY fetch\n\n if (beresp.status >= 500) {\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n }\n\n if (req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Content-Type ~ \"text\/html\" || beresp.http.Content-Type ~ \"text\/xml\") {\n # enable ESI feature for Magento response by default\n esi;\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content\n if ((beresp.status == 200 || beresp.status == 404) && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url ~ \"\\.(css|js|html|eot|ico|otf|ttf|json)($|\\?)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # cache only successfully responses and 404s\n if (beresp.status != 200 && beresp.status != 301 && beresp.status != 404) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\")) {\n unset beresp.http.set-cookie;\n if (req.url !~ \"^\/(pub\/)?(media|static)\/.*\") {\n set beresp.grace = 86400m;\n }\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type\n if (beresp.http.Content-Type ~ \"image\") {\n set beresp.http.Surrogate-Key = \"image\";\n } elsif (beresp.http.Content-Type ~ \"script\") {\n set beresp.http.Surrogate-Key = \"script\";\n } elsif (beresp.http.Content-Type ~ \"css\") {\n set beresp.http.Surrogate-Key = \"css\";\n }\n\n set beresp.http.X-Surrogate-Key = beresp.http.Surrogate-Key;\n return (deliver);\n }\n\n return (deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\n\nsub vcl_miss {\n # Deactivate gzip on origin\n unset bereq.http.Accept-Encoding;\n\n#FASTLY miss\n\n return(fetch);\n}\n\nsub vcl_deliver {\n\n # Send no cache headers to end users for non-static content. Also make sure\n # we only set this on the edge nodes and not on shields\n if (req.url !~ \"^\/(pub\/)?(media|static)\/.*\" && !req.http.Fastly-FF ) {\n set resp.http.Pragma = \"no-cache\";\n set resp.http.Cache-Control = \"no-store, no-cache, must-revalidate, max-age=0\";\n }\n\n # Add an easy way to see whether custom Fastly VCL has been uploaded\n if ( req.http.Fastly-Debug ) {\n set resp.http.Fastly-Magento-VCL-Uploaded = \"yes\";\n } else {\n remove resp.http.Fastly-Module-Enabled;\n }\n # debug info\n if (resp.http.X-Magento-Debug) {\n if (obj.hits > 0) {\n set resp.http.X-Magento-Cache-Debug = \"HIT\";\n set resp.http.X-Magento-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Magento-Cache-Debug = \"MISS\";\n }\n } else {\n # remove Varnish\/proxy header\n remove resp.http.Age;\n remove resp.http.X-Magento-Debug;\n remove resp.http.X-Magento-Tags;\n remove resp.http.X-Surrogate-Key;\n remove resp.http.X-Magento-Cache-Control;\n remove resp.http.X-Powered-By;\n remove resp.http.Server;\n remove resp.http.X-Varnish;\n remove resp.http.Via;\n remove resp.http.Link;\n remove resp.http.X-Purge-URL;\n remove resp.http.X-Purge-Host;\n }\n\n#FASTLY deliver\n\n return (deliver);\n}\n\n\nsub vcl_error {\n # workaround for possible security issue\n if (req.url ~ \"^\\s\") {\n set obj.status = 400;\n set obj.response = \"Malformed request\";\n synthetic \"\";\n return (deliver);\n }\n\n # error 200\n if (obj.status == 200) {\n return (deliver);\n }\n\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} obj.status \" \" obj.response {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} obj.status \" \" obj.response {\"<\/h1>\n <p>\"} obj.response {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} req.xid {\"<\/p>\n <hr>\n <p>Fastly CDN server<\/p>\n <\/body>\n<\/html>\n\"};\n\n#FASTLY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n\nsub vcl_hash {\n set req.hash += req.http.Https;\n set req.hash += req.http.host;\n set req.hash += req.url;\n\n if (req.http.cookie:X-Magento-Vary ) {\n set req.hash += req.http.cookie:X-Magento-Vary;\n }\n \n set req.hash += \"#####GENERATION#####\";\n\n ### {{ design_exceptions_code }} ###\n\n return (hash);\n}\n\n","old_contents":"###############################################################################\n#\n# Fastly CDN for Magento 2\n#\n# NOTICE OF LICENSE\n#\n# This source file is subject to the Fastly CDN for Magento 2 End User License\n# Agreement that is bundled with this package in the file LICENSE_FASTLY_CDN.txt.\n#\n# @copyright Copyright (c) 2016 Fastly, Inc. (http:\/\/www.fastly.com)\n# @license BSD, see LICENSE_FASTLY_CDN.txt\n#\n###############################################################################\n\n# This is a basic VCL configuration file for Fastly CDN for Magento 2 module.\nimport querystring;\n\nsub vcl_recv {\n#FASTLY recv\n\n\n # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n if (req.url ~ \"^\/static\/version(\\d*\/)?(.*)$\") {\n set req.url = \"\/static\/\" + re.group.2 + \"?\" + re.group.1;\n } \n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n set req.http.X-Sig = regsub(req.http.X-Purge-Token, \"^[^_]+_(.*)\", \"\\1\");\n set req.http.X-Exp = regsub(req.http.X-Purge-Token, \"^([^_]+)_.*\", \"\\1\");\n\n # validate signature\n if (req.http.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path req.http.X-Exp), \"^0x\", \"\")) {\n\n # use vcl time math to check expiration timestamp\n set req.http.X-Original-Grace = req.grace;\n set req.grace = std.atoi(strftime({\"%s\"}, now));\n set req.grace -= std.atoi(req.http.X-Exp);\n\n if (std.atoi(req.grace) > 0) {\n error 410;\n }\n\n # clean up grace since we used it for time math\n set req.grace = std.atoi(req.http.X-Original-Grace);\n unset req.http.X-Original-Grace;\n\n } else {\n error 403;\n }\n\n # cleanup variables\n unset req.http.X-Purge-Token;\n unset req.http.X-Sig;\n unset req.http.X-Exp;\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n # disable ESI processing on Origin Shield\n if (req.http.Fastly-FF) {\n set req.esi = false;\n }\n\n # We only deal with GET and HEAD by default\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n return (pass);\n }\n \n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie ~ \"(X-Magento-Vary|form_key)=\") {\n error 200 \"\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url !~ \"country_code=\" ) {\n set req.url = req.url \"?country_code=\" if ( req.http.geo_override, req.http.geo_override, geoip.country_code);\n }\n }\n } else {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking\n set req.http.Fastly-Original-URL = req.url;\n set req.url = querystring.regfilter(req.url, \"^(utm_.*|gclid|gdftrk|_ga|mc_.*)\");\n }\n \n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n return (lookup);\n }\n\n # Bypass shopping cart and checkout requests\n if (req.url ~ \"\/checkout\") {\n return (pass);\n }\n\n return(lookup);\n}\n\nsub vcl_fetch {\n\n # Remove Set-Cookies from responses for static content\n # to match the cookie removal in recv.\n if (req.url ~ \"^\/(pub\/)?(media|static)\/\") {\n unset beresp.http.set-cookie;\n\n # Set a short TTL for 404's\n if (beresp.status == 404) {\n set beresp.ttl = 300s;\n }\n\n }\n\n#FASTLY fetch\n\n if (beresp.status >= 500) {\n # let SOAP errors pass - better debugging\n if (beresp.http.Content-Type ~ \"text\/xml\") {\n return (deliver);\n }\n\n if (req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n }\n\n if (req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Content-Type ~ \"text\/html\" || beresp.http.Content-Type ~ \"text\/xml\") {\n # enable ESI feature for Magento response by default\n esi;\n # Since varnish doesn't compress ESIs we need to hint to the HTTP\/2 terminators to\n # compress it\n set beresp.http.x-compress-hint = \"on\";\n } else {\n # enable gzip for all static content\n if ((beresp.status == 200 || beresp.status == 404) && (beresp.http.content-type ~ \"^(application\\\/x\\-javascript|text\\\/css|application\\\/javascript|text\\\/javascript|application\\\/json|application\\\/vnd\\.ms\\-fontobject|application\\\/x\\-font\\-opentype|application\\\/x\\-font\\-truetype|application\\\/x\\-font\\-ttf|application\\\/xml|font\\\/eot|font\\\/opentype|font\\\/otf|image\\\/svg\\+xml|image\\\/vnd\\.microsoft\\.icon|text\\\/plain)\\s*($|;)\" || req.url ~ \"\\.(css|js|html|eot|ico|otf|ttf|json)($|\\?)\" ) ) {\n # always set vary to make sure uncompressed versions dont always win\n if (!beresp.http.Vary ~ \"Accept-Encoding\") {\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", Accept-Encoding\";\n } else {\n set beresp.http.Vary = \"Accept-Encoding\";\n }\n }\n if (req.http.Accept-Encoding == \"gzip\") {\n set beresp.gzip = true;\n }\n }\n }\n\n # cache only successfully responses and 404s\n if (beresp.status != 200 && beresp.status != 301 && beresp.status != 404) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (req.request == \"GET\" || req.request == \"HEAD\")) {\n unset beresp.http.set-cookie;\n if (req.url !~ \"^\/(pub\/)?(media|static)\/.*\") {\n set beresp.http.Pragma = \"no-cache\";\n set beresp.http.Expires = \"-1\";\n set beresp.http.Cache-Control = \"no-store, no-cache, must-revalidate, max-age=0\";\n set beresp.grace = 1m;\n }\n\n # init surrogate keys\n if (beresp.http.X-Magento-Tags) {\n set beresp.http.Surrogate-Key = beresp.http.X-Magento-Tags \" text\";\n } else {\n set beresp.http.Surrogate-Key = \"text\";\n }\n\n # set surrogate keys by content type\n if (beresp.http.Content-Type ~ \"image\") {\n set beresp.http.Surrogate-Key = \"image\";\n } elsif (beresp.http.Content-Type ~ \"script\") {\n set beresp.http.Surrogate-Key = \"script\";\n } elsif (beresp.http.Content-Type ~ \"css\") {\n set beresp.http.Surrogate-Key = \"css\";\n }\n\n set beresp.http.X-Surrogate-Key = beresp.http.Surrogate-Key;\n return (deliver);\n }\n\n return (deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\n\nsub vcl_miss {\n # Deactivate gzip on origin\n unset bereq.http.Accept-Encoding;\n\n#FASTLY miss\n\n return(fetch);\n}\n\nsub vcl_deliver {\n\n # Add an easy way to see whether custom Fastly VCL has been uploaded\n if ( req.http.Fastly-Debug ) {\n set resp.http.Fastly-Magento-VCL-Uploaded = \"yes\";\n } else {\n remove resp.http.Fastly-Module-Enabled;\n }\n # debug info\n if (resp.http.X-Magento-Debug) {\n if (obj.hits > 0) {\n set resp.http.X-Magento-Cache-Debug = \"HIT\";\n set resp.http.X-Magento-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Magento-Cache-Debug = \"MISS\";\n }\n } else {\n # remove Varnish\/proxy header\n remove resp.http.Age;\n remove resp.http.X-Magento-Debug;\n remove resp.http.X-Magento-Tags;\n remove resp.http.X-Surrogate-Key;\n remove resp.http.X-Magento-Cache-Control;\n remove resp.http.X-Powered-By;\n remove resp.http.Server;\n remove resp.http.X-Varnish;\n remove resp.http.Via;\n remove resp.http.Link;\n remove resp.http.X-Purge-URL;\n remove resp.http.X-Purge-Host;\n }\n\n#FASTLY deliver\n\n return (deliver);\n}\n\n\nsub vcl_error {\n # workaround for possible security issue\n if (req.url ~ \"^\\s\") {\n set obj.status = 400;\n set obj.response = \"Malformed request\";\n synthetic \"\";\n return (deliver);\n }\n\n # error 200\n if (obj.status == 200) {\n return (deliver);\n }\n\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} obj.status \" \" obj.response {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} obj.status \" \" obj.response {\"<\/h1>\n <p>\"} obj.response {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} req.xid {\"<\/p>\n <hr>\n <p>Fastly CDN server<\/p>\n <\/body>\n<\/html>\n\"};\n\n#FASTLY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n\nsub vcl_hash {\n set req.hash += req.http.Https;\n set req.hash += req.http.host;\n set req.hash += req.url;\n\n if (req.http.cookie:X-Magento-Vary ) {\n set req.hash += req.http.cookie:X-Magento-Vary;\n }\n \n set req.hash += \"#####GENERATION#####\";\n\n ### {{ design_exceptions_code }} ###\n\n return (hash);\n}\n\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"924c1ced1a951486a9f83806116a31d0b0fde19a","subject":"fix varnish with multiple hosts","message":"fix varnish with multiple hosts\n","repos":"KhanovaSkola\/khanovaskola-v3,KhanovaSkola\/khanovaskola-v3,KhanovaSkola\/khanovaskola-v3,KhanovaSkola\/khanovaskola-v3,KhanovaSkola\/khanovaskola-v3,KhanovaSkola\/khanovaskola-v3","old_file":"production\/varnish.vcl","new_file":"production\/varnish.vcl","new_contents":"vcl 4.0;\n\n# Disable esi xml check on varnish Startup\n# Example:\n# DAEMON_OPTS=\"-a :6081 \\\n# -T localhost:6082 \\\n# -p feature=+esi_disable_xml_check\n# -p feature=+esi_ignore_https\n#\n\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8085\";\n}\n\nsub vcl_recv {\n if (req.method != \"GET\") {\n return (pass);\n }\n if (req.http.Cookie ~ \"\\bvarnish-force=pass\") {\n return (pass);\n }\n\n return (hash);\n}\n\nsub vcl_hash {\n hash_data(req.host);\n hash_data(req.url);\n return(lookup);\n}\n\nsub vcl_backend_response {\n if (beresp.http.Cache-Control != \"public\") {\n set beresp.uncacheable = true;\n set beresp.ttl = 3m;\n return (deliver);\n }\n\n set beresp.do_esi = true;\n set beresp.ttl = 15m;\n\n unset beresp.http.Set-Cookie;\n}\n","old_contents":"vcl 4.0;\n\n# Disable esi xml check on varnish Startup\n# Example:\n# DAEMON_OPTS=\"-a :6081 \\\n# -T localhost:6082 \\\n# -p feature=+esi_disable_xml_check\n# -p feature=+esi_ignore_https\n#\n\nbackend dev {\n .host = \"127.0.0.1\";\n .port = \"8085\";\n}\nbackend beta {\n .host = \"127.0.0.1\";\n .port = \"8086\";\n}\n\nsub vcl_recv {\n\t\tif (req.http.host == \"dev.khanovaskola.cz\") {\n\t\t\tset req.backend = dev;\n\t\t}\n\t\tif (req.http.host == \"beta.khanovaskola.cz\") {\n set req.backend = beta;\n }\n\n if (req.method != \"GET\") {\n return (pass);\n }\n if (req.http.Cookie ~ \"\\bvarnish-force=pass\") {\n return (pass);\n }\n\n return (hash);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n return(lookup);\n}\n\nsub vcl_backend_response {\n if (beresp.http.Cache-Control != \"public\") {\n set beresp.uncacheable = true;\n set beresp.ttl = 3m;\n return (deliver);\n }\n\n set beresp.do_esi = true;\n set beresp.ttl = 15m;\n\n unset beresp.http.Set-Cookie;\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"1cb3450ed08af1ab7edc508d1ba2dd1d287ffb17","subject":"varnish comment","message":"varnish comment\n","repos":"wikimedia\/analytics-dclass,TheWeatherChannel\/dClass,wikimedia\/analytics-dclass,TheWeatherChannel\/dClass,wikimedia\/analytics-dclass,TheWeatherChannel\/dClass,wikimedia\/analytics-dclass,TheWeatherChannel\/dClass","old_file":"servers\/varnish\/dclass.vcl","new_file":"servers\/varnish\/dclass.vcl","new_contents":"import dclass;\n#import urlcode;\n\nbackend default {\n\t.host = \"localhost\";\n\t.port = \"80\";\n}\n\nsub vcl_init {\n\t# load openddr \n\tdclass.init_dclass(\"\/some\/path\/dClass\/dtrees\/openddr.dtree\");\n\t#dclass.init_dclass_p(\"\/some\/path\/OpenDDR\/1.0.0.0\/resources\",0);\n\n\t# load browser dtree\n\tdclass.init_dclass_p(\"\/some\/path\/dClass\/dtrees\/browser.dtree\",1);\n}\n\nsub vcl_recv {\n\t# ua override\n\tif(req.url ~ \"[^\\w]ua=\"){\n\t\tset req.http.user-agent = regsub(req.url,\"^.*[^\\w]ua=([^&]*).*\",\"\\1\");\n\t\t#set req.http.user-agent = urlcode.decode(regsub(req.url,\"^.*[^\\w]ua=([^&]*).*\",\"\\1\"));\n\t}\n\n\t# do the lookup\n\tset req.http.dclass_openddr = dclass.classify(req.http.user-agent);\n\t#set req.http.dclass_openddr = dclass.classify_p(req.http.user-agent,0);\n\tset req.http.dclass_browser = dclass.classify_p(req.http.user-agent,1);\n\n\t# set dclass_type\n\tset req.http.dclass_type = \"unknown\";\n\tif(dclass.get_field(\"is_tablet\") == \"true\"){\n\t\tset req.http.dclass_type = \"tablet\";\n\t} else if(dclass.get_field(\"is_wireless_device\") == \"true\" && dclass.get_field(\"inputDevices\") == \"touchscreen\"){\n\t\tset req.http.dclass_type = \"smartphone\";\n\t} else if(dclass.get_field(\"is_wireless_device\") == \"true\"){\n\t\tset req.http.dclass_type = \"phone\";\n\t} else if(dclass.get_field(\"is_crawler\") == \"true\"){\n\t\tset req.http.dclass_type = \"crawler\";\n\t} else if(dclass.get_field(\"is_desktop\") == \"true\"){\n\t\tset req.http.dclass_type = \"desktop\";\n\t}\n\n\t# \/uadiag commands\n\tif(req.url ~ \"^\/uadiag.js\"){\n\t\terror 849 \"uadiag.js\";\n\t} else if(req.url ~ \"^\/uadiag\"){\n\t\terror 848 \"uadiag\";\n\t}\n}\n\n# add dclass_type to the hash\nsub vcl_hash {\n\thash_data(req.url);\n\n\tif (req.http.host) {\n\t\thash_data(req.http.host);\n\t} else {\n\t\thash_data(server.ip);\n\t}\n\n #use this if you are serving different device content on the same URL\n\thash_data(req.http.dclass_type);\n\n\treturn (hash);\n}\n\nsub vcl_error {\n\t# plain text ua diag\n\tif(obj.status == 848){\n\t\tset obj.status = 200;\n\t\tset obj.http.Content-Type = \"text\/html; charset=utf-8\";\n\t\tsynthetic\n{\"<html><title>UADIAG<\/title>\n<body>\n<h1>UADIAG<\/h1>\n<pre>\nUser-Agent: \"} + req.http.User-Agent + {\"\n\ndClass version: \"} + dclass.get_version() + {\"\n\ndClass type: \"} + req.http.dclass_type + {\"\n\nOpenDDR comment: \"} + dclass.get_comment() + {\"\nOpenDDR id: \"} + req.http.dclass_openddr + {\"\nOpenDDR device: \"} + dclass.get_field(\"vendor\") + {\" \"} + dclass.get_field(\"model\") + {\"\nOpenDDR display: \"} + dclass.get_ifield(\"displayWidth\") + {\"x\"} + dclass.get_ifield(\"displayHeight\") + {\"\nOpenDDR input: \"} + dclass.get_field(\"inputDevices\") + {\"\nOpenDDR js: \"} + dclass.get_field(\"ajax_support_javascript\") + {\"\nOpenDDR wireless: \"} + dclass.get_field(\"is_wireless_device\") + {\"\nOpenDDR tablet: \"} + dclass.get_field(\"is_tablet\") + {\"\nOpenDDR crawler: \"} + dclass.get_field(\"is_crawler\") + {\"\nOpenDDR desktop: \"} + dclass.get_field(\"is_desktop\") + {\"\n\nbrowser comment: \"} + dclass.get_comment_p(1) + {\"\nbrowser id: \"} + req.http.dclass_browser + {\"\nbrowser name: \"} + dclass.get_field_p(\"browser\",1) + {\"\nbrowser ver: \"} + dclass.get_ifield_p(\"version\",1) + {\"\nbrowser os: \"} + dclass.get_field_p(\"os\",1) + {\"\n<\/pre>\n<\/body>\n<\/html>\"};\n\t\treturn(deliver);\n\t}\n\t# json ua diag with optional jsonp callback parameter\n\telse if(obj.status == 849){\n\t\tset obj.status = 200;\n\t\tset req.http.dclass_cb = \"\";\n\t\tset req.http.dclass_cbe = \"\";\n\t\tif(req.url ~ \"[^\\w]callback=\\w+\"){\n\t\t\tset obj.http.Content-Type = \"application\/javascript; charset=utf-8\";\n\t\t\tset req.http.dclass_cb = regsub(req.url,\"^.*[^\\w]callback=(\\w+).*\",\"\\1(\");\n\t\t\tset req.http.dclass_cbe = \");\";\n\t\t} else {\n\t\t\tset obj.http.Content-Type = \"application\/json; charset=utf-8\";\n\t\t}\n\t\tsynthetic\nreq.http.dclass_cb + {\"{\n\"user_agent\":\"\"} + req.http.User-Agent + {\"\",\n\"dclass_version\":\"\"} + dclass.get_version() + {\"\",\n\"openddr_id\":\"\"} + req.http.dclass_openddr + {\"\",\n\"openddr_type\":\"\"} + req.http.dclass_type + {\"\",\n\"openddr_comment\":\"\"} + dclass.get_comment() + {\"\",\n\"openddr_device\":\"\"} + dclass.get_field(\"vendor\") + {\" \"} + dclass.get_field(\"model\") + {\"\",\n\"openddr_display\":\"\"} + dclass.get_ifield(\"displayWidth\") + {\"x\"} + dclass.get_ifield(\"displayHeight\") + {\"\",\n\"openddr_input\":\"\"} + dclass.get_field(\"inputDevices\") + {\"\",\n\"openddr_js\":\"\"} + dclass.get_field(\"ajax_support_javascript\") + {\"\",\n\"openddr_wireless\":\"\"} + dclass.get_field(\"is_wireless_device\") + {\"\",\n\"openddr_tablet\":\"\"} + dclass.get_field(\"is_tablet\") + {\"\",\n\"openddr_crawler\":\"\"} + dclass.get_field(\"is_crawler\") + {\"\",\n\"openddr_desktop\":\"\"} + dclass.get_field(\"is_desktop\") + {\"\",\n\"browser_id\":\"\"} + req.http.dclass_browser + {\"\",\n\"browser_comment\":\"\"} + dclass.get_comment_p(1) + {\"\",\n\"browser_name\":\"\"} + dclass.get_field_p(\"browser\",1) + {\"\",\n\"browser_ver\":\"\"} + dclass.get_ifield_p(\"version\",1) + {\"\",\n\"browser_os\":\"\"} + dclass.get_field_p(\"os\",1) + {\"\"\n}\"} + req.http.dclass_cbe;\n\t\treturn(deliver);\n\t}\n}\n\n","old_contents":"import dclass;\n#import urlcode;\n\nbackend default {\n\t.host = \"localhost\";\n\t.port = \"80\";\n}\n\nsub vcl_init {\n\t# load openddr \n\tdclass.init_dclass(\"\/some\/path\/dClass\/dtrees\/openddr.dtree\");\n\t#dclass.init_dclass_p(\"\/some\/path\/OpenDDR\/1.0.0.0\/resources\",0);\n\n\t# load browser dtree\n\tdclass.init_dclass_p(\"\/some\/path\/dClass\/dtrees\/browser.dtree\",1);\n}\n\nsub vcl_recv {\n\t# ua override\n\tif(req.url ~ \"[^\\w]ua=\"){\n\t\tset req.http.user-agent = regsub(req.url,\"^.*[^\\w]ua=([^&]*).*\",\"\\1\");\n\t\t#set req.http.user-agent = urlcode.decode(regsub(req.url,\"^.*[^\\w]ua=([^&]*).*\",\"\\1\"));\n\t}\n\n\t# do the lookup\n\tset req.http.dclass_openddr = dclass.classify(req.http.user-agent);\n\t#set req.http.dclass_openddr = dclass.classify_p(req.http.user-agent,0);\n\tset req.http.dclass_browser = dclass.classify_p(req.http.user-agent,1);\n\n\t# set dclass_type\n\tset req.http.dclass_type = \"unknown\";\n\tif(dclass.get_field(\"is_tablet\") == \"true\"){\n\t\tset req.http.dclass_type = \"tablet\";\n\t} else if(dclass.get_field(\"is_wireless_device\") == \"true\" && dclass.get_field(\"inputDevices\") == \"touchscreen\"){\n\t\tset req.http.dclass_type = \"smartphone\";\n\t} else if(dclass.get_field(\"is_wireless_device\") == \"true\"){\n\t\tset req.http.dclass_type = \"phone\";\n\t} else if(dclass.get_field(\"is_crawler\") == \"true\"){\n\t\tset req.http.dclass_type = \"crawler\";\n\t} else if(dclass.get_field(\"is_desktop\") == \"true\"){\n\t\tset req.http.dclass_type = \"desktop\";\n\t}\n\n\t# \/uadiag commands\n\tif(req.url ~ \"^\/uadiag.js\"){\n\t\terror 849 \"uadiag.js\";\n\t} else if(req.url ~ \"^\/uadiag\"){\n\t\terror 848 \"uadiag\";\n\t}\n}\n\n# add dclass_type to the hash\nsub vcl_hash {\n\thash_data(req.url);\n\n\tif (req.http.host) {\n\t\thash_data(req.http.host);\n\t} else {\n\t\thash_data(server.ip);\n\t}\n\n #use this if you are serving different device content on the same URL\n\thash_data(req.http.dclass_type);\n\n\treturn (hash);\n}\n\nsub vcl_error {\n\t# plain text ua diag\n\tif(obj.status == 848){\n\t\tset obj.status = 200;\n\t\tset obj.http.Content-Type = \"text\/html; charset=utf-8\";\n\t\tsynthetic\n{\"<html><title>UADIAG<\/title>\n<body>\n<h1>UADIAG<\/h1>\n<pre>\nUser-Agent: \"} + req.http.User-Agent + {\"\n\ndClass version: \"} + dclass.get_version() + {\"\n\ndClass type: \"} + req.http.dclass_type + {\"\n\nOpenDDR comment: \"} + dclass.get_comment() + {\"\nOpenDDR id: \"} + req.http.dclass_openddr + {\"\nOpenDDR device: \"} + dclass.get_field(\"vendor\") + {\" \"} + dclass.get_field(\"model\") + {\"\nOpenDDR display: \"} + dclass.get_ifield(\"displayWidth\") + {\"x\"} + dclass.get_ifield(\"displayHeight\") + {\"\nOpenDDR input: \"} + dclass.get_field(\"inputDevices\") + {\"\nOpenDDR js: \"} + dclass.get_field(\"ajax_support_javascript\") + {\"\nOpenDDR wireless: \"} + dclass.get_field(\"is_wireless_device\") + {\"\nOpenDDR tablet: \"} + dclass.get_field(\"is_tablet\") + {\"\nOpenDDR crawler: \"} + dclass.get_field(\"is_crawler\") + {\"\nOpenDDR desktop: \"} + dclass.get_field(\"is_desktop\") + {\"\n\nbrowser comment: \"} + dclass.get_comment_p(1) + {\"\nbrowser id: \"} + req.http.dclass_browser + {\"\nbrowser name: \"} + dclass.get_field_p(\"browser\",1) + {\"\nbrowser ver: \"} + dclass.get_ifield_p(\"version\",1) + {\"\nbrowser os: \"} + dclass.get_field_p(\"os\",1) + {\"\n<\/pre>\n<\/body>\n<\/html>\"};\n\t\treturn(deliver);\n\t}\n\t# json ua diag with optional jsonp callback parameter\n\telse if(obj.status == 849){\n\t\tset obj.status = 200;\n\t\tset req.http.dclass_cb = \"\";\n\t\tset req.http.dclass_cbe = \"\";\n\t\tif(req.url ~ \"[^\\w]callback=\\w+\"){\n\t\t\tset obj.http.Content-Type = \"application\/javascript; charset=utf-8\";\n\t\t\tset req.http.dclass_cb = regsub(req.url,\"^.*[^\\w]callback=(\\w+).*\",\"\\1(\");\n\t\t\tset req.http.dclass_cbe = \");\";\n\t\t} else {\n\t\t\tset obj.http.Content-Type = \"application\/json; charset=utf-8\";\n\t\t}\n\t\tsynthetic\nreq.http.dclass_cb + {\"{\n\"user_agent\":\"\"} + req.http.User-Agent + {\"\",\n\"dclass_version\":\"\"} + dclass.get_version() + {\"\",\n\"openddr_id\":\"\"} + req.http.dclass_openddr + {\"\",\n\"openddr_type\":\"\"} + req.http.dclass_type + {\"\",\n\"openddr_device\":\"\"} + dclass.get_field(\"vendor\") + {\" \"} + dclass.get_field(\"model\") + {\"\",\n\"openddr_display\":\"\"} + dclass.get_ifield(\"displayWidth\") + {\"x\"} + dclass.get_ifield(\"displayHeight\") + {\"\",\n\"openddr_input\":\"\"} + dclass.get_field(\"inputDevices\") + {\"\",\n\"openddr_js\":\"\"} + dclass.get_field(\"ajax_support_javascript\") + {\"\",\n\"openddr_wireless\":\"\"} + dclass.get_field(\"is_wireless_device\") + {\"\",\n\"openddr_tablet\":\"\"} + dclass.get_field(\"is_tablet\") + {\"\",\n\"openddr_crawler\":\"\"} + dclass.get_field(\"is_crawler\") + {\"\",\n\"openddr_desktop\":\"\"} + dclass.get_field(\"is_desktop\") + {\"\",\n\"browser_id\":\"\"} + req.http.dclass_browser + {\"\",\n\"browser_name\":\"\"} + dclass.get_field_p(\"browser\",1) + {\"\",\n\"browser_ver\":\"\"} + dclass.get_ifield_p(\"version\",1) + {\"\",\n\"browser_os\":\"\"} + dclass.get_field_p(\"os\",1) + {\"\"\n}\"} + req.http.dclass_cbe;\n\t\treturn(deliver);\n\t}\n}\n\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"cefde71935c959390625b477f147f403b1dfc43f","subject":"the route '\/customer\/section\/load' added as uncacheable","message":"the route '\/customer\/section\/load' added as uncacheable\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets\/recv.vcl","new_file":"etc\/vcl_snippets\/recv.vcl","new_contents":" # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n unset req.http.x-long-cache;\n\n # Rewrite \/static\/versionxxxxx URLs. Avoids us having to rewrite on nginx layer\n if (req.url ~ \"^\/static\/version(\\d*\/)?(.*)$\") {\n set req.url = \"\/static\/\" + re.group.2 + \"?\" + re.group.1;\n set req.http.x-long-cache = \"1\";\n }\n \n # User's Cookie may contain some Magento Vary items we should vary on\n if (req.http.cookie:X-Magento-Vary ) {\n set req.http.X-Magento-Vary = req.http.cookie:X-Magento-Vary;\n } else {\n unset req.http.X-Magento-Vary;\n }\n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n if (!req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n error 403;\n }\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n\n } else {\n error 403;\n }\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (req.http.Fastly-FF) {\n # disable ESI processing on Origin Shield\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie:X-Magento-Vary || req.http.cookie:form_key) {\n error 980 \"GeoIP already processed\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url.qs !~ \"country_code=\" ) {\n set req.url = req.url \"?country_code=\" if ( req.http.geo_override, req.http.geo_override, client.geo.country_code);\n }\n }\n } else {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking\n set req.http.Magento-Original-URL = req.url;\n set req.url = querystring.regfilter(req.url, \"^(utm_.*|gclid|gdftrk|_ga|mc_.*)\");\n }\n\n # Don't allow clients to force a pass\n if (req.restarts == 0) {\n unset req.http.x-pass;\n }\n \n # Pass on checkout URLs. Because it's a snippet we want to execute this after backend selection so we handle it\n # in the request condition\n if (req.url ~ \"\/(catalogsearch|checkout|customer\/section\/load)\") {\n set req.http.x-pass = \"1\";\n # Pass all admin actions\n } else if ( req.url ~ \"^\/(index\\.php\/)?admin(_.*)?\/\" ) {\n set req.http.x-pass = \"1\";\n } else {\n # Sort the query arguments to increase cache hit ratio with query arguments that\n # may be out od order\n set req.url = boltsort.sort(req.url);\n }\n\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n","old_contents":" # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n unset req.http.x-long-cache;\n\n # Rewrite \/static\/versionxxxxx URLs. Avoids us having to rewrite on nginx layer\n if (req.url ~ \"^\/static\/version(\\d*\/)?(.*)$\") {\n set req.url = \"\/static\/\" + re.group.2 + \"?\" + re.group.1;\n set req.http.x-long-cache = \"1\";\n }\n \n # User's Cookie may contain some Magento Vary items we should vary on\n if (req.http.cookie:X-Magento-Vary ) {\n set req.http.X-Magento-Vary = req.http.cookie:X-Magento-Vary;\n } else {\n unset req.http.X-Magento-Vary;\n }\n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n if (!req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n error 403;\n }\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n\n } else {\n error 403;\n }\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (req.http.Fastly-FF) {\n # disable ESI processing on Origin Shield\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie:X-Magento-Vary || req.http.cookie:form_key) {\n error 980 \"GeoIP already processed\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url.qs !~ \"country_code=\" ) {\n set req.url = req.url \"?country_code=\" if ( req.http.geo_override, req.http.geo_override, client.geo.country_code);\n }\n }\n } else {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking\n set req.http.Magento-Original-URL = req.url;\n set req.url = querystring.regfilter(req.url, \"^(utm_.*|gclid|gdftrk|_ga|mc_.*)\");\n }\n\n # Don't allow clients to force a pass\n if (req.restarts == 0) {\n unset req.http.x-pass;\n }\n \n # Pass on checkout URLs. Because it's a snippet we want to execute this after backend selection so we handle it\n # in the request condition\n if (req.url ~ \"\/(catalogsearch|checkout)\") {\n set req.http.x-pass = \"1\";\n # Pass all admin actions\n } else if ( req.url ~ \"^\/(index\\.php\/)?admin(_.*)?\/\" ) {\n set req.http.x-pass = \"1\";\n } else {\n # Sort the query arguments to increase cache hit ratio with query arguments that\n # may be out od order\n set req.url = boltsort.sort(req.url);\n }\n\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"191cbc164829db70588c9a6569eec981eb18becf","subject":"varnish: don't leak HTTP cache headers to clients","message":"varnish: don't leak HTTP cache headers to clients\n\nThis fixes issues when a not-logged-id user logs in, but still sees an\nold page. This is because the user's browser has cached the page due to\nhaving received it with 'Cache-Control: public, ...' headers. Now we\nmake varnish overwrite to always set 'Cache-Control: no-cache' so that\nclients will always hit the server again.\n\nFor not-logged-in users will also always hit the server, but varnish\nwill still handle the requests directly for as long as it has a valid\ncached version of the page.\n","repos":"evandrojr\/noosfero,coletivoEITA\/noosfero,CIRANDAS\/noosfero-ecosol,AlessandroCaetano\/noosfero,vfcosta\/noosfero,uniteddiversity\/noosfero,marcosronaldo\/noosfero,EcoAlternative\/noosfero-ecosol,tallysmartins\/noosfero,abner\/noosfero,alexandreab\/noosfero,evandrojr\/noosfero,hebertdougl\/noosfero,macartur\/noosfero,arthurmde\/noosfero,uniteddiversity\/noosfero,tallysmartins\/noosfero,coletivoEITA\/noosfero,abner\/noosfero,coletivoEITA\/noosfero-ecosol,EcoAlternative\/noosfero-ecosol,LuisBelo\/tccnoosfero,arthurmde\/noosfero,hebertdougl\/noosfero,larissa\/noosfero,marcosronaldo\/noosfero,samasti\/noosfero,uniteddiversity\/noosfero,uniteddiversity\/noosfero,alexandreab\/noosfero,larissa\/noosfero,alexandreab\/noosfero,evandrojr\/noosfero,uniteddiversity\/noosfero,samasti\/noosfero,alexandreab\/noosfero,evandrojr\/noosferogov,abner\/noosfero,blogoosfero\/noosfero,AlessandroCaetano\/noosfero,evandrojr\/noosferogov,arthurmde\/noosfero,larissa\/noosfero,abner\/noosfero,abner\/noosfero,alexandreab\/noosfero,CIRANDAS\/noosfero-ecosol,evandrojr\/noosfero,marcosronaldo\/noosfero,marcosronaldo\/noosfero,blogoosfero\/noosfero,CIRANDAS\/noosfero-ecosol,alexandreab\/noosfero,LuisBelo\/tccnoosfero,samasti\/noosfero,coletivoEITA\/noosfero,tallysmartins\/noosfero,AlessandroCaetano\/noosfero,evandrojr\/noosfero,blogoosfero\/noosfero,macartur\/noosfero,arthurmde\/noosfero,evandrojr\/noosfero,evandrojr\/noosferogov,EcoAlternative\/noosfero-ecosol,evandrojr\/noosfero,larissa\/noosfero,macartur\/noosfero,larissa\/noosfero,arthurmde\/noosfero,vfcosta\/noosfero,LuisBelo\/tccnoosfero,samasti\/noosfero,hebertdougl\/noosfero,coletivoEITA\/noosfero-ecosol,EcoAlternative\/noosfero-ecosol,larissa\/noosfero,vfcosta\/noosfero,abner\/noosfero,LuisBelo\/tccnoosfero,coletivoEITA\/noosfero,LuisBelo\/tccnoosfero,tallysmartins\/noosfero,coletivoEITA\/noosfero-ecosol,blogoosfero\/noosfero,macartur\/noosfero,alexandreab\/noosfero,CIRANDAS\/noosfero-ecosol,EcoAlternative\/noosfero-ecosol,samasti\/noosfero,macartur\/noosfero,marcosronaldo\/noosfero,tallysmartins\/noosfero,tallysmartins\/noosfero,evandrojr\/noosferogov,vfcosta\/noosfero,tallysmartins\/noosfero,larissa\/noosfero,arthurmde\/noosfero,EcoAlternative\/noosfero-ecosol,marcosronaldo\/noosfero,AlessandroCaetano\/noosfero,vfcosta\/noosfero,blogoosfero\/noosfero,vfcosta\/noosfero,coletivoEITA\/noosfero-ecosol,evandrojr\/noosferogov,coletivoEITA\/noosfero,blogoosfero\/noosfero,blogoosfero\/noosfero,EcoAlternative\/noosfero-ecosol,AlessandroCaetano\/noosfero,marcosronaldo\/noosfero,hebertdougl\/noosfero,abner\/noosfero,macartur\/noosfero,CIRANDAS\/noosfero-ecosol,coletivoEITA\/noosfero,macartur\/noosfero,evandrojr\/noosferogov,arthurmde\/noosfero,AlessandroCaetano\/noosfero,LuisBelo\/tccnoosfero,hebertdougl\/noosfero,uniteddiversity\/noosfero,coletivoEITA\/noosfero-ecosol,AlessandroCaetano\/noosfero,evandrojr\/noosferogov,hebertdougl\/noosfero,uniteddiversity\/noosfero,hebertdougl\/noosfero,coletivoEITA\/noosfero,samasti\/noosfero,coletivoEITA\/noosfero-ecosol","old_file":"etc\/noosfero\/varnish-noosfero.vcl","new_file":"etc\/noosfero\/varnish-noosfero.vcl","new_contents":"sub vcl_recv {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n if (req.http.Cookie) {\n # We only care about the \"_noosfero_.*\" cookies, used by Noosfero\n if (req.http.Cookie !~ \"_noosfero_.*\" ) {\n # strip all cookies\n unset req.http.Cookie;\n }\n }\n }\n}\n\nsub vcl_deliver {\n # Force clients to aways hit the server again for HTML pages\n if (resp.http.Content-Type ~ \"^text\/html\") {\n set resp.http.Cache-Control = \"no-cache\";\n }\n}\n\nsub vcl_error {\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n\n synthetic {\"\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Transitional\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-transitional.dtd\">\n<html xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n <head>\n <meta http-equiv=\"Content-Type\" content=\"text\/html; charset=utf-8\"\/>\n <meta http-equiv=\"refresh\" content=\"60\"\/>\n <title>Technical problems<\/title>\n <link rel=\"stylesheet\" type=\"text\/css\" href=\"\/designs\/themes\/default\/errors.css\"\/>\n <link rel=\"shortcut icon\" href='\/designs\/themes\/default\/favicon.ico' type=\"image\/x-icon\" \/>\n <script type='text\/javascript' src='https:\/\/ajax.googleapis.com\/ajax\/libs\/prototype\/1.7.0.0\/prototype.js'><\/script>\n <script type='text\/javascript'>\n function display_error_message(language) {\n if (!language) {\n var language = ((navigator.language) ? navigator.language : navigator.userLanguage).replace('-', '_');\n }\n element = $(language);\n if (!element) {\n element = $(language.replace(\/_.*$\/, ''));\n }\n if (!element) {\n element = $('en');\n }\n $$('.message').each(function(item) { item.hide() });\n element.getElementsBySelector('h1').each(function(title) { document.title = title.innerHTML; });\n element.show();\n }\n <\/script>\n<\/head>\n<body onload='display_error_message()'>\n <div id='wrap'>\n <div id='header'>\n <div id='logo'> <\/div>\n <div id='details'><b>\"} + obj.status + \"<\/b> - \" + obj.response + {\"<\/div>\n <\/div>\n\n <div id='de' style='display: none' class='message'>\n <h1>Kurzzeitiges Systemproblem<\/h1>\n <p>\n Unser technisches Team arbeitet gerade daran, bitte probieren Sie es nachher erneut. Wir entschuldigen uns für die Unannehmlichkeiten.\n <\/p>\n <ul>\n <li><a href='javascript: history.back()'>Zurück<\/a><\/li>\n <li><a href='\/'>Gehe zur Homepage<\/a><\/li>\n <\/ul>\n <\/div>\n\n <div id='en' style='display: none' class='message'>\n <h1>Temporary system problem<\/h1>\n <p>\n Our technical team is working on it, please try again later. Sorry for the inconvenience.\n <\/p>\n <ul>\n <li><a href='javascript: history.back()'>Go back<\/a><\/li>\n <li><a href='\/'>Go to the site home page<\/a><\/li>\n <\/ul>\n <\/div>\n\n <div id='es' style='display: none' class='message'>\n <h1>Temporary system problem<\/h1>\n <p>\n Our technical team is working on it, please try again later. Sorry for the inconvenience.\n <\/p>\n <ul>\n <li><a href='javascript: history.back()'>Go back<\/a><\/li>\n <li><a href='\/'>Go to the site home page<\/a><\/li>\n <\/ul>\n <\/div>\n\n <div id='fr' style='display: none' class='message'>\n <h1>Problème temporaire du système.<\/h1>\n <p>\n Notre équipe technique est en train d'y travailler. Merci de réessayer plus tard. Nous sommes désolés de la gêne occasionnée.\n <\/p>\n <ul>\n <li><a href='javascript: history.back()'>Retour<\/a><\/li>\n <li><a href='\/'>Aller à la page d'accueil du site<\/a><\/li>\n <\/ul>\n <\/div>\n\n <div id='hy' style='display: none' class='message'>\n <h1>Temporary system problem<\/h1>\n <p>\n Our technical team is working on it, please try again later. Sorry for the inconvenience.\n <\/p>\n <ul>\n <li><a href='javascript: history.back()'>Վերադառնալ<\/a><\/li>\n <li><a href='\/'>Go to the site home page<\/a><\/li>\n <\/ul>\n <\/div>\n\n <div id='pt' style='display: none' class='message'>\n <h1>Problema temporário no sistema<\/h1>\n <p>\n Nossa equipe técnica está trabalhando nele, por favor tente mais tarde. Perdoe o incoveniente.\n <\/p>\n <ul>\n <li><a href='javascript: history.back()'>Voltar<\/a><\/li>\n <li><a href='\/'>Ir para a página inicial do site.<\/a><\/li>\n <\/ul>\n <\/div>\n\n <div id='ru' style='display: none' class='message'>\n <h1>Временная ошибка системы<\/h1>\n <p>\n Техники уже работают над проблемой, пожалуйста, попробуйте позже.\n <\/p>\n <ul>\n <li><a href='javascript:history.back()'>Назад<\/a><\/li>\n <li><a href='\/'>Перейти на домашнюю страницу сайта<\/a><\/li>\n <\/ul>\n <\/div>\n\n <div id='languages'>\n <a href=\"javascript: display_error_message('de')\">Deutsch<\/a>\n <a href=\"javascript: display_error_message('en')\">English<\/a>\n <a href=\"javascript: display_error_message('es')\">Español<\/a>\n <a href=\"javascript: display_error_message('fr')\">Français<\/a>\n <a href=\"javascript: display_error_message('hy')\">հայերեն լեզու<\/a>\n <a href=\"javascript: display_error_message('pt')\">Português<\/a>\n <a href=\"javascript: display_error_message('ru')\">русский язык<\/a>\n <\/div>\n\n <\/div>\n<\/body>\n<\/html>\n \"};\n return(deliver);\n}\n","old_contents":"sub vcl_recv {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n if (req.http.Cookie) {\n # We only care about the \"_noosfero_.*\" cookies, used by Noosfero\n if (req.http.Cookie !~ \"_noosfero_.*\" ) {\n # strip all cookies\n unset req.http.Cookie;\n }\n }\n }\n}\n\nsub vcl_error {\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n\n synthetic {\"\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Transitional\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-transitional.dtd\">\n<html xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n <head>\n <meta http-equiv=\"Content-Type\" content=\"text\/html; charset=utf-8\"\/>\n <meta http-equiv=\"refresh\" content=\"60\"\/>\n <title>Technical problems<\/title>\n <link rel=\"stylesheet\" type=\"text\/css\" href=\"\/designs\/themes\/default\/errors.css\"\/>\n <link rel=\"shortcut icon\" href='\/designs\/themes\/default\/favicon.ico' type=\"image\/x-icon\" \/>\n <script type='text\/javascript' src='https:\/\/ajax.googleapis.com\/ajax\/libs\/prototype\/1.7.0.0\/prototype.js'><\/script>\n <script type='text\/javascript'>\n function display_error_message(language) {\n if (!language) {\n var language = ((navigator.language) ? navigator.language : navigator.userLanguage).replace('-', '_');\n }\n element = $(language);\n if (!element) {\n element = $(language.replace(\/_.*$\/, ''));\n }\n if (!element) {\n element = $('en');\n }\n $$('.message').each(function(item) { item.hide() });\n element.getElementsBySelector('h1').each(function(title) { document.title = title.innerHTML; });\n element.show();\n }\n <\/script>\n<\/head>\n<body onload='display_error_message()'>\n <div id='wrap'>\n <div id='header'>\n <div id='logo'> <\/div>\n <div id='details'><b>\"} + obj.status + \"<\/b> - \" + obj.response + {\"<\/div>\n <\/div>\n\n <div id='de' style='display: none' class='message'>\n <h1>Kurzzeitiges Systemproblem<\/h1>\n <p>\n Unser technisches Team arbeitet gerade daran, bitte probieren Sie es nachher erneut. Wir entschuldigen uns für die Unannehmlichkeiten.\n <\/p>\n <ul>\n <li><a href='javascript: history.back()'>Zurück<\/a><\/li>\n <li><a href='\/'>Gehe zur Homepage<\/a><\/li>\n <\/ul>\n <\/div>\n\n <div id='en' style='display: none' class='message'>\n <h1>Temporary system problem<\/h1>\n <p>\n Our technical team is working on it, please try again later. Sorry for the inconvenience.\n <\/p>\n <ul>\n <li><a href='javascript: history.back()'>Go back<\/a><\/li>\n <li><a href='\/'>Go to the site home page<\/a><\/li>\n <\/ul>\n <\/div>\n\n <div id='es' style='display: none' class='message'>\n <h1>Temporary system problem<\/h1>\n <p>\n Our technical team is working on it, please try again later. Sorry for the inconvenience.\n <\/p>\n <ul>\n <li><a href='javascript: history.back()'>Go back<\/a><\/li>\n <li><a href='\/'>Go to the site home page<\/a><\/li>\n <\/ul>\n <\/div>\n\n <div id='fr' style='display: none' class='message'>\n <h1>Problème temporaire du système.<\/h1>\n <p>\n Notre équipe technique est en train d'y travailler. Merci de réessayer plus tard. Nous sommes désolés de la gêne occasionnée.\n <\/p>\n <ul>\n <li><a href='javascript: history.back()'>Retour<\/a><\/li>\n <li><a href='\/'>Aller à la page d'accueil du site<\/a><\/li>\n <\/ul>\n <\/div>\n\n <div id='hy' style='display: none' class='message'>\n <h1>Temporary system problem<\/h1>\n <p>\n Our technical team is working on it, please try again later. Sorry for the inconvenience.\n <\/p>\n <ul>\n <li><a href='javascript: history.back()'>Վերադառնալ<\/a><\/li>\n <li><a href='\/'>Go to the site home page<\/a><\/li>\n <\/ul>\n <\/div>\n\n <div id='pt' style='display: none' class='message'>\n <h1>Problema temporário no sistema<\/h1>\n <p>\n Nossa equipe técnica está trabalhando nele, por favor tente mais tarde. Perdoe o incoveniente.\n <\/p>\n <ul>\n <li><a href='javascript: history.back()'>Voltar<\/a><\/li>\n <li><a href='\/'>Ir para a página inicial do site.<\/a><\/li>\n <\/ul>\n <\/div>\n\n <div id='ru' style='display: none' class='message'>\n <h1>Временная ошибка системы<\/h1>\n <p>\n Техники уже работают над проблемой, пожалуйста, попробуйте позже.\n <\/p>\n <ul>\n <li><a href='javascript:history.back()'>Назад<\/a><\/li>\n <li><a href='\/'>Перейти на домашнюю страницу сайта<\/a><\/li>\n <\/ul>\n <\/div>\n\n <div id='languages'>\n <a href=\"javascript: display_error_message('de')\">Deutsch<\/a>\n <a href=\"javascript: display_error_message('en')\">English<\/a>\n <a href=\"javascript: display_error_message('es')\">Español<\/a>\n <a href=\"javascript: display_error_message('fr')\">Français<\/a>\n <a href=\"javascript: display_error_message('hy')\">հայերեն լեզու<\/a>\n <a href=\"javascript: display_error_message('pt')\">Português<\/a>\n <a href=\"javascript: display_error_message('ru')\">русский язык<\/a>\n <\/div>\n\n <\/div>\n<\/body>\n<\/html>\n \"};\n return(deliver);\n}\n","returncode":0,"stderr":"","license":"agpl-3.0","lang":"VCL"} {"commit":"8cf5e85a3edeff7564bbad2ba3e829de43a43f30","subject":"500 errors are returned to the user","message":"500 errors are returned to the user\n","repos":"evolution\/wordpress,jalevin\/wordpress,jalevin\/wordpress,jalevin\/wordpress,evolution\/wordpress,jalevin\/wordpress,jalevin\/wordpress,evolution\/wordpress,evolution\/wordpress,evolution\/wordpress","old_file":"lib\/ansible\/roles\/varnish\/files\/etc-varnish\/production.vcl","new_file":"lib\/ansible\/roles\/varnish\/files\/etc-varnish\/production.vcl","new_contents":"# Default backend definition. Set this to point to your content server.\n# all paths relative to varnish option vcl_dir\n\ninclude \"custom.backend.vcl\";\ninclude \"custom.acl.vcl\";\n\n# Handle the HTTP request received by the client\nsub vcl_recv {\n # varnish serves stale (but cacheable) objects while retriving object from backend\n if (req.backend.healthy) {\n set req.grace = 30s;\n } else {\n set req.grace = 1h;\n }\n\n # shortcut for DFind requests\n if (req.url ~ \"^\/w00tw00t\") {\n error 404 \"Not Found\";\n }\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n # Normalize the header, remove the port (in case you're testing this on various TCP ports)\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n # Allow purging\n if (req.request == \"PURGE\") {\n if (!client.ip ~ purge) {\n # Not from an allowed IP? Then die with an error.\n error 405 \"This IP is not allowed to send PURGE requests.\";\n }\n\n # If you got this stage (and didn't error out above), do a cache-lookup\n # That will force entry into vcl_hit() or vcl_miss() below and purge the actual cache\n return (lookup);\n }\n\n # Only deal with \"normal\" types\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"PATCH\" &&\n req.request != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n # We only deal with GET and HEAD by default\n return (pass);\n }\n\n # Some generic URL manipulation, useful for all templates that follow\n # First remove the Google Analytics added parameters, useless for our backend\n if (req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=\") {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # Strip hash, server doesn't need it.\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n # Strip a trailing ? if it exists\n if (req.url ~ \"\\?$\") {\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # This is an example to redirect with a 301\/302 HTTP status code from within Varnish\n # if (req.http.Host ~ \"secure.mysite.tld\") {\n # # We may want to force our users from the secure site to the HTTPs version?\n # error 720 \"https:\/\/secure.mysite.tld\";\n # # If you want to keep the URLs intact, this also works:\n # error 720 \"https:\/\/\" + req.http.Host + req.url;\n # }\n #\n # Or to force a 302 temporary redirect, use error 721\n # if (req.http.Host ~ \"temp.mysite.tld\") {\n # # Temporary redirect\n # error 721 \"http:\/\/mysite.tld\/temp\";\n # }\n #\n\n # Some generic cookie manipulation, useful for all templates that follow\n\n # Remove any '_' prefixed cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"(^|;\\s*)_[^=]+=[^;]*\", \"\");\n\n # Remove a \";\" prefix in the cookie if present\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n\n # Are there cookies left with only spaces or that are empty?\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n\n # Normalize Accept-Encoding header\n # straight from the manual: https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/vary.html\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n # No point in compressing these\n remove req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n # unkown algorithm\n remove req.http.Accept-Encoding;\n }\n }\n\n # Include custom vcl_recv logic\n include \"conf.d\/receive\/wordpress.vcl\";\n\n # Remove all cookies for static files\n # A valid discussion could be held on this line: do you really need to cache static files that don't cause load? Only if you have memory left.\n # Sure, there's disk I\/O, but chances are your OS will already have these files in their buffers (thus memory).\n # Before you blindly enable this, have a read here: http:\/\/mattiasgeniar.be\/2012\/11\/28\/stop-caching-static-files\/\n # if (req.url ~ \"^[^?]*\\.(bmp|bz2|css|doc|eot|flv|gif|gz|ico|jpeg|jpg|js|less|mp[34]|pdf|png|rar|rtf|swf|tar|tgz|txt|wav|woff|xml|zip)(\\?.*)?$\") {\n # unset req.http.Cookie;\n # return (lookup);\n # }\n\n # Send Surrogate-Capability headers to announce ESI support to backend\n set req.http.Surrogate-Capability = \"key=ESI\/1.0\";\n\n if (req.http.Authorization || req.http.Cookie) {\n # Not cacheable by default\n return (pass);\n }\n\n return (lookup);\n}\n\nsub vcl_pipe {\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n # set bereq.http.connection = \"close\";\n # here. It is not set by default as it might break some broken web\n # applications, like IIS with NTLM authentication.\n\n #set bereq.http.Connection = \"Close\";\n return (pipe);\n}\n\nsub vcl_pass {\n return (pass);\n}\n\n# The data on which the hashing will take place\nsub vcl_hash {\n hash_data(req.url);\n\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n\n # hash cookies for object with auth\n if (req.http.Cookie) {\n hash_data(req.http.Cookie);\n }\n if (req.http.Authorization) {\n hash_data(req.http.Authorization);\n }\n\n return (hash);\n}\n\nsub vcl_hit {\n # Allow purges\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"purged\";\n }\n\n return (deliver);\n}\n\nsub vcl_miss {\n # Allow purges\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"purged\";\n }\n\n return (fetch);\n}\n\n# Handle the HTTP request coming from our backend\nsub vcl_fetch {\n set beresp.grace = 1h;\n\n # Include custom vcl_fetch logic\n include \"conf.d\/fetch\/wordpress.vcl\";\n\n # Parse ESI request and remove Surrogate-Control header\n if (beresp.http.Surrogate-Control ~ \"ESI\/1.0\") {\n unset beresp.http.Surrogate-Control;\n set beresp.do_esi = true;\n }\n\n # If the request to the backend returns a code is 5xx, return the error page\n if (beresp.status >= 500 && beresp.status <= 599){\n return(hit_for_pass);\n }\n\n # Enable cache for all static files\n # The same argument as the static caches from above: monitor your cache size, if you get data nuked out of it, consider giving up the static file cache.\n # Before you blindly enable this, have a read here: http:\/\/mattiasgeniar.be\/2012\/11\/28\/stop-caching-static-files\/\n # if (req.url ~ \"^[^?]*\\.(bmp|bz2|css|doc|eot|flv|gif|gz|ico|jpeg|jpg|js|less|mp[34]|pdf|png|rar|rtf|swf|tar|tgz|txt|wav|woff|xml|zip)(\\?.*)?$\") {\n # unset beresp.http.set-cookie;\n # }\n\n # Sometimes, a 301 or 302 redirect formed via Apache's mod_rewrite can mess with the HTTP port that is being passed along.\n # This often happens with simple rewrite rules in a scenario where Varnish runs on :80 and Apache on :8080 on the same box.\n # A redirect can then often redirect the end-user to a URL on :8080, where it should be :80.\n # This may need finetuning on your setup.\n #\n # To prevent accidental replace, we only filter the 301\/302 redirects for now.\n if (beresp.status == 301 || beresp.status == 302) {\n set beresp.http.Location = regsub(beresp.http.Location, \":[0-9]+\", \"\");\n }\n\n # Don't cache user & server errors\n if (beresp.status >= 400) {\n return (hit_for_pass);\n }\n\n # Non private responses without cookies and with a ttl of 0 should be artificially extended to 1 hour\n if (beresp.ttl <= 0s && beresp.http.Cache-Control !~ \"private\" && (!beresp.http.Set-Cookie)) {\n set beresp.ttl = 1h;\n set beresp.http.X-Cache-Extended = \"1\";\n }\n\n # Set 2min cache if unset for static files\n if (beresp.ttl <= 0s || beresp.http.Set-Cookie || beresp.http.Vary == \"*\") {\n set beresp.ttl = 120s;\n return (hit_for_pass);\n }\n\n return (deliver);\n}\n\n# The routine when we deliver the HTTP request to the user\n# Last chance to modify headers that are sent to the client\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"cached\";\n } else {\n set resp.http.x-Cache = \"uncached\";\n }\n\n # Remove some headers: PHP version\n unset resp.http.X-Powered-By;\n\n # Remove some headers: Apache version & OS\n unset resp.http.Server;\n unset resp.http.X-Drupal-Cache;\n unset resp.http.X-Varnish;\n unset resp.http.Via;\n unset resp.http.Link;\n\n return (deliver);\n}\n\nsub vcl_error {\n if (obj.status == 720) {\n # We use this special error status 720 to force redirects with 301 (permanent) redirects\n # To use this, call the following from anywhere in vcl_recv: error 720 \"http:\/\/host\/new.html\"\n set obj.status = 301;\n set obj.http.Location = obj.response;\n return (deliver);\n } elseif (obj.status == 721) {\n # And we use error status 721 to force redirects with a 302 (temporary) redirect\n # To use this, call the following from anywhere in vcl_recv: error 720 \"http:\/\/host\/new.html\"\n set obj.status = 302;\n set obj.http.Location = obj.response;\n return (deliver);\n }\n\n return (deliver);\n}\n\nsub vcl_init {\n return (ok);\n}\n\nsub vcl_fini {\n return (ok);\n}\n","old_contents":"# Default backend definition. Set this to point to your content server.\n# all paths relative to varnish option vcl_dir\n\ninclude \"custom.backend.vcl\";\ninclude \"custom.acl.vcl\";\n\n# Handle the HTTP request received by the client\nsub vcl_recv {\n # varnish serves stale (but cacheable) objects while retriving object from backend\n if (req.backend.healthy) {\n set req.grace = 30s;\n } else {\n set req.grace = 1h;\n }\n\n # shortcut for DFind requests\n if (req.url ~ \"^\/w00tw00t\") {\n error 404 \"Not Found\";\n }\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n # Normalize the header, remove the port (in case you're testing this on various TCP ports)\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n # Allow purging\n if (req.request == \"PURGE\") {\n if (!client.ip ~ purge) {\n # Not from an allowed IP? Then die with an error.\n error 405 \"This IP is not allowed to send PURGE requests.\";\n }\n\n # If you got this stage (and didn't error out above), do a cache-lookup\n # That will force entry into vcl_hit() or vcl_miss() below and purge the actual cache\n return (lookup);\n }\n\n # Only deal with \"normal\" types\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"PATCH\" &&\n req.request != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n # We only deal with GET and HEAD by default\n return (pass);\n }\n\n # Some generic URL manipulation, useful for all templates that follow\n # First remove the Google Analytics added parameters, useless for our backend\n if (req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=\") {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # Strip hash, server doesn't need it.\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n # Strip a trailing ? if it exists\n if (req.url ~ \"\\?$\") {\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # This is an example to redirect with a 301\/302 HTTP status code from within Varnish\n # if (req.http.Host ~ \"secure.mysite.tld\") {\n # # We may want to force our users from the secure site to the HTTPs version?\n # error 720 \"https:\/\/secure.mysite.tld\";\n # # If you want to keep the URLs intact, this also works:\n # error 720 \"https:\/\/\" + req.http.Host + req.url;\n # }\n #\n # Or to force a 302 temporary redirect, use error 721\n # if (req.http.Host ~ \"temp.mysite.tld\") {\n # # Temporary redirect\n # error 721 \"http:\/\/mysite.tld\/temp\";\n # }\n #\n\n # Some generic cookie manipulation, useful for all templates that follow\n\n # Remove any '_' prefixed cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"(^|;\\s*)_[^=]+=[^;]*\", \"\");\n\n # Remove a \";\" prefix in the cookie if present\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n\n # Are there cookies left with only spaces or that are empty?\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n\n # Normalize Accept-Encoding header\n # straight from the manual: https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/vary.html\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n # No point in compressing these\n remove req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n # unkown algorithm\n remove req.http.Accept-Encoding;\n }\n }\n\n # Include custom vcl_recv logic\n include \"conf.d\/receive\/wordpress.vcl\";\n\n # Remove all cookies for static files\n # A valid discussion could be held on this line: do you really need to cache static files that don't cause load? Only if you have memory left.\n # Sure, there's disk I\/O, but chances are your OS will already have these files in their buffers (thus memory).\n # Before you blindly enable this, have a read here: http:\/\/mattiasgeniar.be\/2012\/11\/28\/stop-caching-static-files\/\n # if (req.url ~ \"^[^?]*\\.(bmp|bz2|css|doc|eot|flv|gif|gz|ico|jpeg|jpg|js|less|mp[34]|pdf|png|rar|rtf|swf|tar|tgz|txt|wav|woff|xml|zip)(\\?.*)?$\") {\n # unset req.http.Cookie;\n # return (lookup);\n # }\n\n # Send Surrogate-Capability headers to announce ESI support to backend\n set req.http.Surrogate-Capability = \"key=ESI\/1.0\";\n\n if (req.http.Authorization || req.http.Cookie) {\n # Not cacheable by default\n return (pass);\n }\n\n return (lookup);\n}\n\nsub vcl_pipe {\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n # set bereq.http.connection = \"close\";\n # here. It is not set by default as it might break some broken web\n # applications, like IIS with NTLM authentication.\n\n #set bereq.http.Connection = \"Close\";\n return (pipe);\n}\n\nsub vcl_pass {\n return (pass);\n}\n\n# The data on which the hashing will take place\nsub vcl_hash {\n hash_data(req.url);\n\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n\n # hash cookies for object with auth\n if (req.http.Cookie) {\n hash_data(req.http.Cookie);\n }\n if (req.http.Authorization) {\n hash_data(req.http.Authorization);\n }\n\n return (hash);\n}\n\nsub vcl_hit {\n # Allow purges\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"purged\";\n }\n\n return (deliver);\n}\n\nsub vcl_miss {\n # Allow purges\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"purged\";\n }\n\n return (fetch);\n}\n\n# Handle the HTTP request coming from our backend\nsub vcl_fetch {\n set beresp.grace = 1h;\n\n # Include custom vcl_fetch logic\n include \"conf.d\/fetch\/wordpress.vcl\";\n\n # Parse ESI request and remove Surrogate-Control header\n if (beresp.http.Surrogate-Control ~ \"ESI\/1.0\") {\n unset beresp.http.Surrogate-Control;\n set beresp.do_esi = true;\n }\n\n # If the request to the backend returns a code is 5xx, restart the loop\n # If the number of restarts reaches the value of the parameter max_restarts,\n # the request will be error'ed. max_restarts defaults to 4. This prevents\n # an eternal loop in the event that, e.g., the object does not exist at all.\n if (beresp.status >= 500 && beresp.status <= 599){\n return(restart);\n }\n\n # Enable cache for all static files\n # The same argument as the static caches from above: monitor your cache size, if you get data nuked out of it, consider giving up the static file cache.\n # Before you blindly enable this, have a read here: http:\/\/mattiasgeniar.be\/2012\/11\/28\/stop-caching-static-files\/\n # if (req.url ~ \"^[^?]*\\.(bmp|bz2|css|doc|eot|flv|gif|gz|ico|jpeg|jpg|js|less|mp[34]|pdf|png|rar|rtf|swf|tar|tgz|txt|wav|woff|xml|zip)(\\?.*)?$\") {\n # unset beresp.http.set-cookie;\n # }\n\n # Sometimes, a 301 or 302 redirect formed via Apache's mod_rewrite can mess with the HTTP port that is being passed along.\n # This often happens with simple rewrite rules in a scenario where Varnish runs on :80 and Apache on :8080 on the same box.\n # A redirect can then often redirect the end-user to a URL on :8080, where it should be :80.\n # This may need finetuning on your setup.\n #\n # To prevent accidental replace, we only filter the 301\/302 redirects for now.\n if (beresp.status == 301 || beresp.status == 302) {\n set beresp.http.Location = regsub(beresp.http.Location, \":[0-9]+\", \"\");\n }\n\n # Don't cache user & server errors\n if (beresp.status >= 400) {\n return (hit_for_pass);\n }\n\n # Non private responses without cookies and with a ttl of 0 should be artificially extended to 1 hour\n if (beresp.ttl <= 0s && beresp.http.Cache-Control !~ \"private\" && (!beresp.http.Set-Cookie)) {\n set beresp.ttl = 1h;\n set beresp.http.X-Cache-Extended = \"1\";\n }\n\n # Set 2min cache if unset for static files\n if (beresp.ttl <= 0s || beresp.http.Set-Cookie || beresp.http.Vary == \"*\") {\n set beresp.ttl = 120s;\n return (hit_for_pass);\n }\n\n return (deliver);\n}\n\n# The routine when we deliver the HTTP request to the user\n# Last chance to modify headers that are sent to the client\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"cached\";\n } else {\n set resp.http.x-Cache = \"uncached\";\n }\n\n # Remove some headers: PHP version\n unset resp.http.X-Powered-By;\n\n # Remove some headers: Apache version & OS\n unset resp.http.Server;\n unset resp.http.X-Drupal-Cache;\n unset resp.http.X-Varnish;\n unset resp.http.Via;\n unset resp.http.Link;\n\n return (deliver);\n}\n\nsub vcl_error {\n if (obj.status == 720) {\n # We use this special error status 720 to force redirects with 301 (permanent) redirects\n # To use this, call the following from anywhere in vcl_recv: error 720 \"http:\/\/host\/new.html\"\n set obj.status = 301;\n set obj.http.Location = obj.response;\n return (deliver);\n } elseif (obj.status == 721) {\n # And we use error status 721 to force redirects with a 302 (temporary) redirect\n # To use this, call the following from anywhere in vcl_recv: error 720 \"http:\/\/host\/new.html\"\n set obj.status = 302;\n set obj.http.Location = obj.response;\n return (deliver);\n }\n\n return (deliver);\n}\n\nsub vcl_init {\n return (ok);\n}\n\nsub vcl_fini {\n return (ok);\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"7f5b79bf1d16341c05ac916d480cbe2f8e823b38","subject":"Closing if tags is probably a good plan. Derp.","message":"Closing if tags is probably a good plan. Derp.\n","repos":"killerwails\/ansible-varnish,kkwoker\/ansible-varnish,gotofbi\/ansible-varnish,colstrom\/ansible-varnish,killerwails\/ansible-varnish,telusdigital\/ansible-varnish,gotofbi\/ansible-varnish,noqcks\/ansible-varnish","old_file":"templates\/etc\/varnish\/default.vcl","new_file":"templates\/etc\/varnish\/default.vcl","new_contents":"vcl 4.0;\n\nimport directors;\n\n{% for backend in varnish_backend_hosts %}\n backend application_{{ loop.index }} {\n .host = \"{{ backend }}\";\n .port = \"{{ varnish_backend_port }}\";\n {% if varnish_health_checks_enabled %}\n .probe = {\n .url = '{{ varnish_health_check_url }}';\n .interval = {{ varnish_health_check_interval }};\n .timeout = {{ varnish_health_check_timeout }};\n .window = {{ varnish_health_check_window }};\n .threshold = {{ varnish_health_check_threshold }};\n }\n {% endif %}\n }\n{% endfor %}\n\nsub vcl_init {\n new application = directors.round_robin();\n {% for backend in varnish_backend_hosts %}\n application.add_backend(application_{{ loop.index }});\n {% endfor %}\n}\nsub vcl_recv {\n set req.backend_hint = application.backend();\n}\n\nsub vcl_hit {\n if (obj.ttl > 0s) {\n return (deliver);\n }\n {% if varnish_health_checks_enabled %}\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (fetch);\n }\n {% else %}\n if (obj.ttl + obj.grace > 0s) {\n return (deliver);\n }\n\n return (fetch);\n {% endif %}\n}\n\n{% if varnish_grace_enabled %}\n sub vcl_backend_response {\n set beresp.grace = {{ varnish_grace_period }};\n }\n{% endif %}","old_contents":"vcl 4.0;\n\nimport directors;\n\n{% for backend in varnish_backend_hosts %}\n backend application_{{ loop.index }} {\n .host = \"{{ backend }}\";\n .port = \"{{ varnish_backend_port }}\";\n {% if varnish_health_checks_enabled %}\n .probe = {\n .url = '{{ varnish_health_check_url }}';\n .interval = {{ varnish_health_check_interval }};\n .timeout = {{ varnish_health_check_timeout }};\n .window = {{ varnish_health_check_window }};\n .threshold = {{ varnish_health_check_threshold }};\n }\n }\n{% endfor %}\n\nsub vcl_init {\n new application = directors.round_robin();\n {% for backend in varnish_backend_hosts %}\n application.add_backend(application_{{ loop.index }});\n {% endfor %}\n}\nsub vcl_recv {\n set req.backend_hint = application.backend();\n}\n\nsub vcl_hit {\n if (obj.ttl > 0s) {\n return (deliver);\n }\n {% if varnish_health_checks_enabled %}\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (fetch);\n }\n {% else %}\n if (obj.ttl + obj.grace > 0s) {\n return (deliver);\n }\n\n return (fetch);\n {% endif %}\n}\n\n{% if varnish_grace_enabled %}\n sub vcl_backend_response {\n set beresp.grace = {{ varnish_grace_period }};\n }\n{% endif %}","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"b56f5454b3a937acc1507b831893eecacf3a51b7","subject":"Fix docs line emphasis","message":"Fix docs line emphasis\n","repos":"stof\/FOSHttpCache,stof\/FOSHttpCache,stof\/FOSHttpCache","old_file":"tests\/Functional\/Fixtures\/varnish-4\/ban.vcl","new_file":"tests\/Functional\/Fixtures\/varnish-4\/ban.vcl","new_contents":"sub vcl_recv {\n\n if (req.method == \"BAN\") {\n if (!client.ip ~ invalidators) {\n return (synth(405, \"Not allowed\"));\n }\n\n if (req.http.X-Cache-Tags) {\n ban(\"obj.http.X-Host ~ \" + req.http.X-Host\n + \" && obj.http.X-Url ~ \" + req.http.X-Url\n + \" && obj.http.content-type ~ \" + req.http.X-Content-Type\n + \" && obj.http.X-Cache-Tags ~ \" + req.http.X-Cache-Tags\n );\n } else {\n ban(\"obj.http.X-Host ~ \" + req.http.X-Host\n + \" && obj.http.X-Url ~ \" + req.http.X-Url\n + \" && obj.http.content-type ~ \" + req.http.X-Content-Type\n );\n }\n\n return (synth(200, \"Banned\"));\n }\n}\n\nsub vcl_backend_response {\n\n # Set ban-lurker friendly custom headers\n set beresp.http.X-Url = bereq.url;\n set beresp.http.X-Host = bereq.http.host;\n}\n\nsub vcl_deliver {\n\n # Keep ban-lurker headers only if debugging is enabled\n if (!resp.http.X-Cache-Debug) {\n # Remove ban-lurker friendly custom headers when delivering to client\n unset resp.http.X-Url;\n unset resp.http.X-Host;\n unset resp.http.X-Cache-Tags;\n }\n}\n","old_contents":"sub vcl_recv {\n\n if (req.method == \"BAN\") {\n if (!client.ip ~ invalidators) {\n return (synth(405, \"Not allowed\"));\n }\n\n if (req.http.X-Cache-Tags) {\n ban(\"obj.http.X-Host ~ \" + req.http.X-Host\n + \" && obj.http.X-Url ~ \" + req.http.X-Url\n + \" && obj.http.content-type ~ \" + req.http.X-Content-Type\n + \" && obj.http.X-Cache-Tags ~ \" + req.http.X-Cache-Tags\n );\n } else {\n ban(\"obj.http.X-Host ~ \" + req.http.X-Host\n + \" && obj.http.X-Url ~ \" + req.http.X-Url\n + \" && obj.http.content-type ~ \" + req.http.X-Content-Type\n );\n }\n\n return (synth(200, \"Banned\"));\n }\n}\n\nsub vcl_backend_response {\n\n # Set ban-lurker friendly custom headers\n set beresp.http.X-Url = bereq.url;\n set beresp.http.X-Host = bereq.http.host;\n}\n\nsub vcl_deliver {\n # Keep ban-lurker headers only if debugging is enabled\n if (!resp.http.X-Cache-Debug) {\n # Remove ban-lurker friendly custom headers when delivering to client\n unset resp.http.X-Url;\n unset resp.http.X-Host;\n unset resp.http.X-Cache-Tags;\n }\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"54d5ae961262887be500682d2a87b41c0497ee3b","subject":"Feedback on BAN","message":"Feedback on BAN\n","repos":"lrkwz\/docker-magento-develop,lrkwz\/docker-magento-develop","old_file":"provision\/varnish\/etc\/default_3.0.vcl","new_file":"provision\/varnish\/etc\/default_3.0.vcl","new_contents":"# This is a basic VCL configuration file for PageCache powered by Varnish for Magento module.\n\nimport std;\ninclude \"local.vcl\";\n\nsub vcl_recv {\n if (req.restarts == 0) {\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"DELETE\" &&\n req.request != \"BAN\" &&\n req.request != \"PURGE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n # purge request\n if (req.request == \"PURGE\") {\n if (!client.ip ~ purge) {\n error 405 \"Not allowed.\";\n }\n \/\/ban(\"obj.http.X-Purge-Host ~ \" + req.http.X-Purge-Host + \" && obj.http.X-Purge-URL ~ \" + req.http.X-Purge-Regex + \" && obj.http.Content-Type ~ \" + req.http.X-Purge-Content-Type);\n \/\/error 200 \"Purged.\";\n return(lookup);\n }\n\n if (req.request == \"BAN\") {\n if(!client.ip ~ purge) {\n error 405 \"Not allowed.\";\n }\n if (req.http.X-Cache-Tags) {\n ban(\"obj.http.X-Host ~ \" + req.http.X-Host\n + \" && obj.http.X-Url ~ \" + req.http.X-Url\n + \" && obj.http.content-type ~ \" + req.http.X-Content-Type\n + \" && obj.http.X-Cache-Tags ~ \" + req.http.X-Cache-Tags\n );\n } else {\n\/\/ ban(\"req.url ~ \"+req.url+\" && req.http.host == \"+req.http.host);\n ban(\"obj.http.X-Purge-Host ~ \" + req.http.X-Purge-Host + \" && obj.http.X-Purge-URL ~ \" + req.http.X-Purge-Regex + \" && obj.http.Content-Type ~ \" + req.http.X-Purge-Content-Type);\n }\n error 200 \"Banned \" + req.http.host + \" \" + req.url;\n }\n\n\n # no-cache request from authorized ip to warmup the cache\n if (req.http.Cache-Control ~ \"no-cache\" && client.ip ~ purge) {\n \t\tset req.hash_always_miss = true;\n \t}\n\n\n # switch to admin backend configuration\n if (req.http.cookie ~ \"adminhtml=\") {\n set req.backend = admin;\n }\n\n # tell backend that esi is supported\n set req.http.X-ESI-Capability = \"on\";\n\n # we only deal with GET and HEAD by default\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n return (pass);\n }\n\n # normalize url in case of leading HTTP scheme and domain\n set req.url = regsub(req.url, \"^http[s]?:\/\/[^\/]+\", \"\");\n\n # Normalize the header, remove the port\n \tset req.http.host = regsub(req.http.host, \":[0-9]+\", \"\");\n\n # collect all cookies\n std.collect(req.http.Cookie);\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(media|js|skin)\/.*\\.(png|jpg|jpeg|gif|css|js|swf|ico)$\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n # formkey lookup\n if (req.url ~ \"\/varnishcache\/getformkey\/\") {\n # check for formkey in cookie\n if (req.http.Cookie ~ \"PAGECACHE_FORMKEY\") {\n set req.http.X-Pagecache-Formkey = regsub(req.http.cookie, \".*PAGECACHE_FORMKEY=([^;]*)(;*.*)?\", \"\\1\");\n } else {\n # create formkey once\n set req.http.X-Pagecache-Formkey-Raw = req.http.Cookie + client.ip + req.xid;\n C{\n char *result = generate_formkey(VRT_GetHdr(sp, HDR_REQ, \"\\030X-Pagecache-Formkey-Raw:\"));\n VRT_SetHdr(sp, HDR_REQ, \"\\024X-Pagecache-Formkey:\", result, vrt_magic_string_end);\n }C\n }\n unset req.http.X-Pagecache-Formkey-Raw;\n error 760 req.http.X-Pagecache-Formkey;\n }\n\n # do not cache any page from index files\n if (req.url ~ \"^\/(index)\") {\n return (pass);\n }\n\n # as soon as we have a NO_CACHE cookie pass request\n if (req.http.cookie ~ \"NO_CACHE=\") {\n return (pass);\n }\n\n # normalize Accept-Encoding header\n # http:\/\/varnish.projects.linpro.no\/wiki\/FAQ\/Compression\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|flv)$\") {\n # No point in compressing these\n remove req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\" && req.http.user-agent !~ \"MSIE\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n # unknown algorithm\n remove req.http.Accept-Encoding;\n }\n }\n\n # remove Google gclid parameters\n set req.url = regsuball(req.url, \"\\?gclid=[^&]+$\", \"\"); # strips when QS = \"?gclid=AAA\"\n set req.url = regsuball(req.url, \"\\?gclid=[^&]+&\", \"?\"); # strips when QS = \"?gclid=AAA&foo=bar\"\n set req.url = regsuball(req.url, \"&gclid=[^&]+\", \"\"); # strips when QS = \"?foo=bar&gclid=AAA\" or QS = \"?foo=bar&gclid=AAA&bar=baz\"\n\n if (req.http.Cookie) {\n \t\tif (req.http.cookie !~ \"PHPSESSID\" && req.http.cookie ~ \"REMEMBERME\") {\n \t\t\treturn(pass);\n \t\t}\n\n \t\tif (req.http.Cookie ~ \"wordpress_logged_in_\" || req.http.Cookie ~ \"woocommerce_\" || req.http.Cookie ~ \"wp_postpass\" || req.http.Cookie ~ \"DokuWiki\"){\n \t\t\treturn (pass);\n \t\t} else {\n \t\t\tif (req.url ~ \"\\.(png|gif|jpg|swf|css|js)\\??.*?$\") {\n \t\t\t\tunset req.http.Cookie;\n \t\t\t} else {\n \t\t\t\t\/* Warning: Not a pretty solution *\/\n \t\t\t\t\/* Prefix header containing cookies with ';' *\/\n \t\t\t\tset req.http.Cookie = \";\" + req.http.Cookie;\n \t\t\t\t\/* Remove any spaces after ';' in header containing cookies *\/\n \t\t\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n \t\t\t\t\/* Prefix cookies we want to preserve with one space *\/\n \t\t\t\t\/* 'S{1,2}ESS[a-z0-9]+' is the regular expression matching a Drupal session cookie ({1,2} added for HTTPS support) *\/\n \t\t\t\t\/* 'NO_CACHE' is usually set after a POST request to make sure issuing user see the results of his post *\/\n \t\t\t\t\/* Keep in mind we should add here any cookie that should reach the backend such as splahs avoiding cookies *\/\n \t\t\t\tset req.http.Cookie = regsuball(req.http.Cookie, \";(ow_cookie_notice|PHPSESSID|NO_CACHE)=\", \"; \\1=\");\n \t\t\t\t\/* Remove from the header any single Cookie not prefixed with a space until next ';' separator *\/\n \t\t\t\tset req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n \t\t\t\t\/* Remove any '; ' at the start or the end of the header *\/\n \t\t\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n \t\t\t}\n\n \t\t\tif (req.http.Cookie == \"\") {\n \t\t\t\t\/* If there are no remaining cookies, remove the cookie header. *\/\n \t\t\t\tunset req.http.Cookie;\n \t\t\t}\n \t\t}\n \t}\n\n\/\/ return (lookup);\n\n}\n\n# sub vcl_pipe {\n# # Note that only the first request to the backend will have\n# # X-Forwarded-For set. If you use X-Forwarded-For and want to\n# # have it set for all requests, make sure to have:\n# # set bereq.http.connection = \"close\";\n# # here. It is not set by default as it might break some broken web\n# # applications, like IIS with NTLM authentication.\n# return (pipe);\n# }\n\n# sub vcl_pass {\n# return (pass);\n# }\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n\n if (req.http.cookie ~ \"PAGECACHE_ENV=\") {\n set req.http.pageCacheEnv = regsub(\n req.http.cookie,\n \"(.*)PAGECACHE_ENV=([^;]*)(.*)\",\n \"\\2\"\n );\n hash_data(req.http.pageCacheEnv);\n remove req.http.pageCacheEnv;\n }\n\n if (!(req.url ~ \"^\/(media|js|skin)\/.*\\.(png|jpg|jpeg|gif|css|js|swf|ico)$\")) {\n call design_exception;\n }\n\n \/* Hash cookie data\n As requests with same URL and host can produce diferent results when issued with different cookies,\n we need to store items hashed with the associated cookies. Note that cookies are already sanitized when we reach this point.\n *\/\n if (req.http.Cookie) {\n \/* Include cookie in cache hash *\/\n hash_data(req.http.Cookie);\n }\n\n return (hash);\n}\n\nsub vcl_hit {\n\tif (req.request == \"PURGE\") {\n\t\tpurge;\n\t\terror 204 \"Purged\";\n\t}\n}\n\n# The purge in vcl_miss is necessary to purge all variants in the cases where\n# you hit an object, but miss a particular variant.\nsub vcl_miss {\n\tif (req.request == \"PURGE\") {\n\t\tpurge;\n\t\terror 204 \"Purged (Not in cache)\";\n\t}\n}\n\nsub vcl_fetch {\n set beresp.http.X-Backend = beresp.backend.name;\n if (beresp.status >= 500) {\n # let SOAP errors pass - better debugging\n if ((beresp.http.Content-Type ~ \"text\/xml\") || (req.url ~ \"^\/errors\/\")) {\n return (deliver);\n }\n set beresp.saintmode = 10s;\n return (restart);\n }\n set beresp.grace = 5m;\n\n # enable ESI feature\n set beresp.do_esi = true;\n\n # add ban-lurker tags to object\n set beresp.http.X-Purge-URL = req.url;\n set beresp.http.X-Purge-Host = req.http.host;\n\n if (beresp.status == 200 || beresp.status == 301 || beresp.status == 404) {\n if (beresp.http.Content-Type ~ \"text\/html\" || beresp.http.Content-Type ~ \"text\/xml\") {\n \/* By default, Varnish3 ignores Cache-Control: no-cache and private\n https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/increasing_your_hitrate.html#cache-control\n *\/\n if (beresp.http.Cache-Control ~ \"private\" ||\n beresp.http.Cache-Control ~ \"no-cache\" ||\n beresp.http.Cache-Control ~ \"no-store\"\n ) {\n return (hit_for_pass);\n }\n if ((beresp.http.Set-Cookie ~ \"NO_CACHE=\") || (beresp.ttl < 1s)) {\n set beresp.ttl = 0s;\n return (hit_for_pass);\n }\n if (req.url ~ \"wp-(login|admin)|login\" || req.url ~ \"preview=true\") {\n \t\treturn (hit_for_pass);\n \t}\n\n # marker for vcl_deliver to reset Age:\n set beresp.http.magicmarker = \"1\";\n\n # Don't cache cookies\n unset beresp.http.set-cookie;\n } else {\n # set default TTL value for static content\n set beresp.ttl = 4h;\n }\n return (deliver);\n }\n\n return (hit_for_pass);\n}\n\nsub vcl_deliver {\n # debug info\n if (resp.http.X-Cache-Debug || client.ip ~ purge) {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n set resp.http.X-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n set resp.http.X-Cache-Expires = resp.http.Expires;\n } else {\n # remove Varnish\/proxy header\n remove resp.http.X-Varnish;\n remove resp.http.Via;\n remove resp.http.Age;\n remove resp.http.X-Purge-URL;\n remove resp.http.X-Purge-Host;\n remove resp.http.X-Powered-By;\n \tremove resp.http.Server;\n }\n\n if (resp.http.magicmarker) {\n # Remove the magic marker\n unset resp.http.magicmarker;\n\n set resp.http.Cache-Control = \"no-store, no-cache, must-revalidate, post-check=0, pre-check=0\";\n set resp.http.Pragma = \"no-cache\";\n set resp.http.Expires = \"Mon, 31 Mar 2008 10:00:00 GMT\";\n set resp.http.Age = \"0\";\n }\n}\n\nsub vcl_error {\n # workaround for possible security issue\n if (req.url ~ \"^\\s\") {\n set obj.status = 400;\n set obj.response = \"Malformed request\";\n synthetic \"\";\n return(deliver);\n }\n\n # formkey request\n if (obj.status == 760) {\n set obj.status = 200;\n\t synthetic obj.response;\n return(deliver);\n }\n\n # redirect request\n if (obj.status == 750) {\n set obj.http.Location = obj.response;\n set obj.status = 301;\n return(deliver);\n }\n\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + obj.status + \" \" + obj.response + {\"<\/h1>\n <p>\"} + obj.response + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"};\n return (deliver);\n}\n\n\n# sub vcl_fini {\n# return (ok);\n# }\n\nsub design_exception {\n}\n\nC{\n #include <string.h>\n #include <stdio.h>\n #include <stdlib.h>\n #include <openssl\/md5.h>\n\n \/**\n * create md5 hash of string and return it\n *\/\n char *generate_formkey(char *string) {\n \/\/ generate md5\n unsigned char result[MD5_DIGEST_LENGTH];\n MD5((const unsigned char *)string, strlen(string), result);\n\n \/\/ convert to chars\n static char md5string[MD5_DIGEST_LENGTH + 1];\n const char *hex = \"0123456789ABCDEF\";\n unsigned char *pin = result;\n char *pout = md5string;\n\n for(; pin < result + sizeof(result); pout+=2, pin++) {\n pout[0] = hex[(*pin>>4) & 0xF];\n pout[1] = hex[ *pin & 0xF];\n }\n pout[-1] = 0;\n\n \/\/ return md5\n return md5string;\n }\n}C\n","old_contents":"# This is a basic VCL configuration file for PageCache powered by Varnish for Magento module.\n\nimport std;\ninclude \"local.vcl\";\n\nsub vcl_recv {\n if (req.restarts == 0) {\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"DELETE\" &&\n req.request != \"PURGE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n # purge request\n if (req.request == \"PURGE\") {\n if (!client.ip ~ purge) {\n error 405 \"Not allowed.\";\n }\n \/\/ban(\"obj.http.X-Purge-Host ~ \" + req.http.X-Purge-Host + \" && obj.http.X-Purge-URL ~ \" + req.http.X-Purge-Regex + \" && obj.http.Content-Type ~ \" + req.http.X-Purge-Content-Type);\n \/\/error 200 \"Purged.\";\n return(lookup);\n }\n\n if (req.request == \"BAN\") {\n if(!client.ip ~ purge) {\n error 405 \"Not allowed.\";\n }\n if (req.http.X-Cache-Tags) {\n ban(\"obj.http.X-Host ~ \" + req.http.X-Host\n + \" && obj.http.X-Url ~ \" + req.http.X-Url\n + \" && obj.http.content-type ~ \" + req.http.X-Content-Type\n + \" && obj.http.X-Cache-Tags ~ \" + req.http.X-Cache-Tags\n );\n } else {\n\/\/ ban(\"req.url ~ \"+req.url+\" && req.http.host == \"+req.http.host);\n ban(\"obj.http.X-Purge-Host ~ \" + req.http.X-Purge-Host + \" && obj.http.X-Purge-URL ~ \" + req.http.X-Purge-Regex + \" && obj.http.Content-Type ~ \" + req.http.X-Purge-Content-Type);\n }\n error 200 \"Banned \" + req.http.host + \" \" + req.url;\n }\n\n\n # no-cache request from authorized ip to warmup the cache\n if (req.http.Cache-Control ~ \"no-cache\" && client.ip ~ purge) {\n \t\tset req.hash_always_miss = true;\n \t}\n\n\n # switch to admin backend configuration\n if (req.http.cookie ~ \"adminhtml=\") {\n set req.backend = admin;\n }\n\n # tell backend that esi is supported\n set req.http.X-ESI-Capability = \"on\";\n\n # we only deal with GET and HEAD by default\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n return (pass);\n }\n\n # normalize url in case of leading HTTP scheme and domain\n set req.url = regsub(req.url, \"^http[s]?:\/\/[^\/]+\", \"\");\n\n # Normalize the header, remove the port\n \tset req.http.host = regsub(req.http.host, \":[0-9]+\", \"\");\n\n # collect all cookies\n std.collect(req.http.Cookie);\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(media|js|skin)\/.*\\.(png|jpg|jpeg|gif|css|js|swf|ico)$\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n # formkey lookup\n if (req.url ~ \"\/varnishcache\/getformkey\/\") {\n # check for formkey in cookie\n if (req.http.Cookie ~ \"PAGECACHE_FORMKEY\") {\n set req.http.X-Pagecache-Formkey = regsub(req.http.cookie, \".*PAGECACHE_FORMKEY=([^;]*)(;*.*)?\", \"\\1\");\n } else {\n # create formkey once\n set req.http.X-Pagecache-Formkey-Raw = req.http.Cookie + client.ip + req.xid;\n C{\n char *result = generate_formkey(VRT_GetHdr(sp, HDR_REQ, \"\\030X-Pagecache-Formkey-Raw:\"));\n VRT_SetHdr(sp, HDR_REQ, \"\\024X-Pagecache-Formkey:\", result, vrt_magic_string_end);\n }C\n }\n unset req.http.X-Pagecache-Formkey-Raw;\n error 760 req.http.X-Pagecache-Formkey;\n }\n\n # do not cache any page from index files\n if (req.url ~ \"^\/(index)\") {\n return (pass);\n }\n\n # as soon as we have a NO_CACHE cookie pass request\n if (req.http.cookie ~ \"NO_CACHE=\") {\n return (pass);\n }\n\n # normalize Accept-Encoding header\n # http:\/\/varnish.projects.linpro.no\/wiki\/FAQ\/Compression\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|flv)$\") {\n # No point in compressing these\n remove req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\" && req.http.user-agent !~ \"MSIE\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n # unknown algorithm\n remove req.http.Accept-Encoding;\n }\n }\n\n # remove Google gclid parameters\n set req.url = regsuball(req.url, \"\\?gclid=[^&]+$\", \"\"); # strips when QS = \"?gclid=AAA\"\n set req.url = regsuball(req.url, \"\\?gclid=[^&]+&\", \"?\"); # strips when QS = \"?gclid=AAA&foo=bar\"\n set req.url = regsuball(req.url, \"&gclid=[^&]+\", \"\"); # strips when QS = \"?foo=bar&gclid=AAA\" or QS = \"?foo=bar&gclid=AAA&bar=baz\"\n\n if (req.http.Cookie) {\n \t\tif (req.http.cookie !~ \"PHPSESSID\" && req.http.cookie ~ \"REMEMBERME\") {\n \t\t\treturn(pass);\n \t\t}\n\n \t\tif (req.http.Cookie ~ \"wordpress_logged_in_\" || req.http.Cookie ~ \"woocommerce_\" || req.http.Cookie ~ \"wp_postpass\" || req.http.Cookie ~ \"DokuWiki\"){\n \t\t\treturn (pass);\n \t\t} else {\n \t\t\tif (req.url ~ \"\\.(png|gif|jpg|swf|css|js)\\??.*?$\") {\n \t\t\t\tunset req.http.Cookie;\n \t\t\t} else {\n \t\t\t\t\/* Warning: Not a pretty solution *\/\n \t\t\t\t\/* Prefix header containing cookies with ';' *\/\n \t\t\t\tset req.http.Cookie = \";\" + req.http.Cookie;\n \t\t\t\t\/* Remove any spaces after ';' in header containing cookies *\/\n \t\t\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n \t\t\t\t\/* Prefix cookies we want to preserve with one space *\/\n \t\t\t\t\/* 'S{1,2}ESS[a-z0-9]+' is the regular expression matching a Drupal session cookie ({1,2} added for HTTPS support) *\/\n \t\t\t\t\/* 'NO_CACHE' is usually set after a POST request to make sure issuing user see the results of his post *\/\n \t\t\t\t\/* Keep in mind we should add here any cookie that should reach the backend such as splahs avoiding cookies *\/\n \t\t\t\tset req.http.Cookie = regsuball(req.http.Cookie, \";(ow_cookie_notice|PHPSESSID|NO_CACHE)=\", \"; \\1=\");\n \t\t\t\t\/* Remove from the header any single Cookie not prefixed with a space until next ';' separator *\/\n \t\t\t\tset req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n \t\t\t\t\/* Remove any '; ' at the start or the end of the header *\/\n \t\t\t\tset req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n \t\t\t}\n\n \t\t\tif (req.http.Cookie == \"\") {\n \t\t\t\t\/* If there are no remaining cookies, remove the cookie header. *\/\n \t\t\t\tunset req.http.Cookie;\n \t\t\t}\n \t\t}\n \t}\n\n\/\/ return (lookup);\n\n}\n\n# sub vcl_pipe {\n# # Note that only the first request to the backend will have\n# # X-Forwarded-For set. If you use X-Forwarded-For and want to\n# # have it set for all requests, make sure to have:\n# # set bereq.http.connection = \"close\";\n# # here. It is not set by default as it might break some broken web\n# # applications, like IIS with NTLM authentication.\n# return (pipe);\n# }\n\n# sub vcl_pass {\n# return (pass);\n# }\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n\n if (req.http.cookie ~ \"PAGECACHE_ENV=\") {\n set req.http.pageCacheEnv = regsub(\n req.http.cookie,\n \"(.*)PAGECACHE_ENV=([^;]*)(.*)\",\n \"\\2\"\n );\n hash_data(req.http.pageCacheEnv);\n remove req.http.pageCacheEnv;\n }\n\n if (!(req.url ~ \"^\/(media|js|skin)\/.*\\.(png|jpg|jpeg|gif|css|js|swf|ico)$\")) {\n call design_exception;\n }\n\n \/* Hash cookie data\n As requests with same URL and host can produce diferent results when issued with different cookies,\n we need to store items hashed with the associated cookies. Note that cookies are already sanitized when we reach this point.\n *\/\n if (req.http.Cookie) {\n \/* Include cookie in cache hash *\/\n hash_data(req.http.Cookie);\n }\n\n return (hash);\n}\n\nsub vcl_hit {\n\tif (req.request == \"PURGE\") {\n\t\tpurge;\n\t\terror 204 \"Purged\";\n\t}\n}\n\n# The purge in vcl_miss is necessary to purge all variants in the cases where\n# you hit an object, but miss a particular variant.\nsub vcl_miss {\n\tif (req.request == \"PURGE\") {\n\t\tpurge;\n\t\terror 204 \"Purged (Not in cache)\";\n\t}\n}\n\nsub vcl_fetch {\n set beresp.http.X-Backend = beresp.backend.name;\n if (beresp.status >= 500) {\n # let SOAP errors pass - better debugging\n if ((beresp.http.Content-Type ~ \"text\/xml\") || (req.url ~ \"^\/errors\/\")) {\n return (deliver);\n }\n set beresp.saintmode = 10s;\n return (restart);\n }\n set beresp.grace = 5m;\n\n # enable ESI feature\n set beresp.do_esi = true;\n\n # add ban-lurker tags to object\n set beresp.http.X-Purge-URL = req.url;\n set beresp.http.X-Purge-Host = req.http.host;\n\n if (beresp.status == 200 || beresp.status == 301 || beresp.status == 404) {\n if (beresp.http.Content-Type ~ \"text\/html\" || beresp.http.Content-Type ~ \"text\/xml\") {\n \/* By default, Varnish3 ignores Cache-Control: no-cache and private\n https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/increasing_your_hitrate.html#cache-control\n *\/\n if (beresp.http.Cache-Control ~ \"private\" ||\n beresp.http.Cache-Control ~ \"no-cache\" ||\n beresp.http.Cache-Control ~ \"no-store\"\n ) {\n return (hit_for_pass);\n }\n if ((beresp.http.Set-Cookie ~ \"NO_CACHE=\") || (beresp.ttl < 1s)) {\n set beresp.ttl = 0s;\n return (hit_for_pass);\n }\n if (req.url ~ \"wp-(login|admin)|login\" || req.url ~ \"preview=true\") {\n \t\treturn (hit_for_pass);\n \t}\n\n # marker for vcl_deliver to reset Age:\n set beresp.http.magicmarker = \"1\";\n\n # Don't cache cookies\n unset beresp.http.set-cookie;\n } else {\n # set default TTL value for static content\n set beresp.ttl = 4h;\n }\n return (deliver);\n }\n\n return (hit_for_pass);\n}\n\nsub vcl_deliver {\n # debug info\n if (resp.http.X-Cache-Debug || client.ip ~ purge) {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n set resp.http.X-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n set resp.http.X-Cache-Expires = resp.http.Expires;\n } else {\n # remove Varnish\/proxy header\n remove resp.http.X-Varnish;\n remove resp.http.Via;\n remove resp.http.Age;\n remove resp.http.X-Purge-URL;\n remove resp.http.X-Purge-Host;\n remove resp.http.X-Powered-By;\n \tremove resp.http.Server;\n }\n\n if (resp.http.magicmarker) {\n # Remove the magic marker\n unset resp.http.magicmarker;\n\n set resp.http.Cache-Control = \"no-store, no-cache, must-revalidate, post-check=0, pre-check=0\";\n set resp.http.Pragma = \"no-cache\";\n set resp.http.Expires = \"Mon, 31 Mar 2008 10:00:00 GMT\";\n set resp.http.Age = \"0\";\n }\n}\n\nsub vcl_error {\n # workaround for possible security issue\n if (req.url ~ \"^\\s\") {\n set obj.status = 400;\n set obj.response = \"Malformed request\";\n synthetic \"\";\n return(deliver);\n }\n\n # formkey request\n if (obj.status == 760) {\n set obj.status = 200;\n\t synthetic obj.response;\n return(deliver);\n }\n\n # redirect request\n if (obj.status == 750) {\n set obj.http.Location = obj.response;\n set obj.status = 301;\n return(deliver);\n }\n\n # error 200\n if (obj.status == 200) {\n return (deliver);\n }\n\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + obj.status + \" \" + obj.response + {\"<\/h1>\n <p>\"} + obj.response + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"};\n return (deliver);\n}\n\n\n# sub vcl_fini {\n# return (ok);\n# }\n\nsub design_exception {\n}\n\nC{\n #include <string.h>\n #include <stdio.h>\n #include <stdlib.h>\n #include <openssl\/md5.h>\n\n \/**\n * create md5 hash of string and return it\n *\/\n char *generate_formkey(char *string) {\n \/\/ generate md5\n unsigned char result[MD5_DIGEST_LENGTH];\n MD5((const unsigned char *)string, strlen(string), result);\n\n \/\/ convert to chars\n static char md5string[MD5_DIGEST_LENGTH + 1];\n const char *hex = \"0123456789ABCDEF\";\n unsigned char *pin = result;\n char *pout = md5string;\n\n for(; pin < result + sizeof(result); pout+=2, pin++) {\n pout[0] = hex[(*pin>>4) & 0xF];\n pout[1] = hex[ *pin & 0xF];\n }\n pout[-1] = 0;\n\n \/\/ return md5\n return md5string;\n }\n}C\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"9e51782bd0e5757868ebda3090fdb9f1ed56a56f","subject":"Don't bog our webserver down when somebodys backend croaks.","message":"Don't bog our webserver down when somebodys backend croaks.\n\n\n\ngit-svn-id: 2c9807fa3ff65b17195bd55dc8a6c4261e10127b@4867 d4fa192b-c00b-0410-8231-f00ffab90ce4\n","repos":"alarky\/varnish-cache-doc-ja,ssm\/pkg-varnish,ambernetas\/varnish-cache,feld\/Varnish-Cache,wikimedia\/operations-debs-varnish,drwilco\/varnish-cache-drwilco,franciscovg\/Varnish-Cache,zhoualbeart\/Varnish-Cache,feld\/Varnish-Cache,alarky\/varnish-cache-doc-ja,chrismoulton\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,feld\/Varnish-Cache,alarky\/varnish-cache-doc-ja,varnish\/Varnish-Cache,gquintard\/Varnish-Cache,varnish\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,zhoualbeart\/Varnish-Cache,ssm\/pkg-varnish,chrismoulton\/Varnish-Cache,wikimedia\/operations-debs-varnish,mrhmouse\/Varnish-Cache,alarky\/varnish-cache-doc-ja,ssm\/pkg-varnish,ambernetas\/varnish-cache,franciscovg\/Varnish-Cache,feld\/Varnish-Cache,varnish\/Varnish-Cache,1HLtd\/Varnish-Cache,1HLtd\/Varnish-Cache,alarky\/varnish-cache-doc-ja,mrhmouse\/Varnish-Cache,feld\/Varnish-Cache,1HLtd\/Varnish-Cache,franciscovg\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,drwilco\/varnish-cache-old,gquintard\/Varnish-Cache,gquintard\/Varnish-Cache,gquintard\/Varnish-Cache,wikimedia\/operations-debs-varnish,varnish\/Varnish-Cache,drwilco\/varnish-cache-old,ajasty-cavium\/Varnish-Cache,chrismoulton\/Varnish-Cache,zhoualbeart\/Varnish-Cache,ssm\/pkg-varnish,1HLtd\/Varnish-Cache,franciscovg\/Varnish-Cache,wikimedia\/operations-debs-varnish,mrhmouse\/Varnish-Cache,ssm\/pkg-varnish,mrhmouse\/Varnish-Cache,drwilco\/varnish-cache-drwilco,ajasty-cavium\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,ambernetas\/varnish-cache,mrhmouse\/Varnish-Cache,drwilco\/varnish-cache-drwilco,zhoualbeart\/Varnish-Cache,franciscovg\/Varnish-Cache,chrismoulton\/Varnish-Cache,chrismoulton\/Varnish-Cache,zhoualbeart\/Varnish-Cache,varnish\/Varnish-Cache,wikimedia\/operations-debs-varnish,drwilco\/varnish-cache-old,gauthier-delacroix\/Varnish-Cache","old_file":"bin\/varnishd\/default.vcl","new_file":"bin\/varnishd\/default.vcl","new_contents":"\/*-\n * Copyright (c) 2006 Verdens Gang AS\n * Copyright (c) 2006-2009 Linpro AS\n * All rights reserved.\n *\n * Author: Poul-Henning Kamp <phk@phk.freebsd.dk>\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in the\n * documentation and\/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR \n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\n * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n * $Id$\n *\n * The default VCL code.\n *\n * NB! You do NOT need to copy & paste all of these functions into your\n * own vcl code, if you do not provide a definition of one of these\n * functions, the compiler will automatically fall back to the default\n * code from this file.\n *\n * This code will be prefixed with a backend declaration built from the\n * -b argument.\n *\/\n\nsub vcl_recv {\n if (req.http.x-forwarded-for) {\n\tset req.http.X-Forwarded-For =\n\t req.http.X-Forwarded-For \", \" client.ip;\n } else {\n\tset req.http.X-Forwarded-For = client.ip;\n }\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization || req.http.Cookie) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n return (lookup);\n}\n\nsub vcl_pipe {\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n # set req.http.connection = \"close\";\n # here. It is not set by default as it might break some broken web\n # applications, like IIS with NTLM authentication.\n return (pipe);\n}\n\nsub vcl_pass {\n return (pass);\n}\n\nsub vcl_hash {\n set req.hash += req.url;\n if (req.http.host) {\n set req.hash += req.http.host;\n } else {\n set req.hash += server.ip;\n }\n return (hash);\n}\n\nsub vcl_hit {\n if (!obj.cacheable) {\n return (pass);\n }\n return (deliver);\n}\n\nsub vcl_miss {\n return (fetch);\n}\n\nsub vcl_fetch {\n if (!beresp.cacheable) {\n return (pass);\n }\n if (beresp.http.Set-Cookie) {\n return (pass);\n }\n return (deliver);\n}\n\nsub vcl_deliver {\n return (deliver);\n}\n\nsub vcl_error {\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} obj.status \" \" obj.response {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} obj.status \" \" obj.response {\"<\/h1>\n <p>\"} obj.response {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} req.xid {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"};\n return (deliver);\n}\n","old_contents":"\/*-\n * Copyright (c) 2006 Verdens Gang AS\n * Copyright (c) 2006-2009 Linpro AS\n * All rights reserved.\n *\n * Author: Poul-Henning Kamp <phk@phk.freebsd.dk>\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in the\n * documentation and\/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR \n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\n * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n * $Id$\n *\n * The default VCL code.\n *\n * NB! You do NOT need to copy & paste all of these functions into your\n * own vcl code, if you do not provide a definition of one of these\n * functions, the compiler will automatically fall back to the default\n * code from this file.\n *\n * This code will be prefixed with a backend declaration built from the\n * -b argument.\n *\/\n\nsub vcl_recv {\n if (req.http.x-forwarded-for) {\n\tset req.http.X-Forwarded-For =\n\t req.http.X-Forwarded-For \", \" client.ip;\n } else {\n\tset req.http.X-Forwarded-For = client.ip;\n }\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization || req.http.Cookie) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n return (lookup);\n}\n\nsub vcl_pipe {\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n # set req.http.connection = \"close\";\n # here. It is not set by default as it might break some broken web\n # applications, like IIS with NTLM authentication.\n return (pipe);\n}\n\nsub vcl_pass {\n return (pass);\n}\n\nsub vcl_hash {\n set req.hash += req.url;\n if (req.http.host) {\n set req.hash += req.http.host;\n } else {\n set req.hash += server.ip;\n }\n return (hash);\n}\n\nsub vcl_hit {\n if (!obj.cacheable) {\n return (pass);\n }\n return (deliver);\n}\n\nsub vcl_miss {\n return (fetch);\n}\n\nsub vcl_fetch {\n if (!beresp.cacheable) {\n return (pass);\n }\n if (beresp.http.Set-Cookie) {\n return (pass);\n }\n return (deliver);\n}\n\nsub vcl_deliver {\n return (deliver);\n}\n\nsub vcl_error {\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} obj.status \" \" obj.response {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} obj.status \" \" obj.response {\"<\/h1>\n <p>\"} obj.response {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} req.xid {\"<\/p>\n <hr>\n <address>\n <a href=\"http:\/\/www.varnish-cache.org\/\">Varnish cache server<\/a>\n <\/address>\n <\/body>\n<\/html>\n\"};\n return (deliver);\n}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"b55154a863094e7a134206f8d5c770c4c0d8256c","subject":"Resolves #176: Fix Varnish probe URL. Changes to \/INSTALL.txt","message":"Resolves #176: Fix Varnish probe URL. Changes to \/INSTALL.txt\n","repos":"mshmsh5000\/dosomething-1,sergii-tkachenko\/phoenix,sbsmith86\/dosomething,chloealee\/dosomething,deadlybutter\/phoenix,angaither\/dosomething,mshmsh5000\/dosomething-1,jonuy\/dosomething,sergii-tkachenko\/phoenix,sergii-tkachenko\/phoenix,mshmsh5000\/dosomething-1,angaither\/dosomething,angaither\/dosomething,jonuy\/dosomething,mshmsh5000\/dosomething,jonuy\/dosomething,angaither\/dosomething,sbsmith86\/dosomething,chloealee\/dosomething,deadlybutter\/phoenix,DoSomething\/phoenix,DoSomething\/dosomething,jonuy\/dosomething,DoSomething\/dosomething,sergii-tkachenko\/phoenix,DoSomething\/phoenix,angaither\/dosomething,sbsmith86\/dosomething,DoSomething\/phoenix,sbsmith86\/dosomething,mshmsh5000\/dosomething,DoSomething\/dosomething,angaither\/dosomething,mshmsh5000\/dosomething-1,DoSomething\/dosomething,mshmsh5000\/dosomething,jonuy\/dosomething,sbsmith86\/dosomething,deadlybutter\/phoenix,deadlybutter\/phoenix,deadlybutter\/phoenix,DoSomething\/dosomething,DoSomething\/dosomething,sbsmith86\/dosomething,chloealee\/dosomething,sergii-tkachenko\/phoenix,jonuy\/dosomething,DoSomething\/phoenix,chloealee\/dosomething,DoSomething\/phoenix,chloealee\/dosomething,mshmsh5000\/dosomething-1,mshmsh5000\/dosomething,chloealee\/dosomething","old_file":"salt\/roots\/salt\/varnishd\/lullabot_varnish3.vcl","new_file":"salt\/roots\/salt\/varnishd\/lullabot_varnish3.vcl","new_contents":"#\n# Customized VCL file for serving up a Drupal site with multiple back-ends.\n#\n# For more information on this VCL, visit the Lullabot article:\n# http:\/\/www.lullabot.com\/articles\/varnish-multiple-web-servers-drupal\n#\n#\n# Do Something version: Customized for a Vagrant sandbox.\n\n# Define the internal network subnet.\n# These are used below to allow internal access to certain files while not\n# allowing access from the public internet.\nacl internal {\n \"127.0.0.1\";\n}\n\n# Define the list of backends (web servers).\n# The \"probe\" URL is set to INSTALL.txt, which should be in your default Drupal install.\n# Adjust as necessary. For a more advanced health check URL, see the status.php example\n# in the Lullabot article, referenced above.\n#\n# Port 80 Backend Servers\nbackend web1 { .host = \"127.0.0.1\"; .port = \"8888\"; .probe = { .url = \"\/INSTALL.txt\"; .interval = 5s; .timeout = 1s; .window = 5;.threshold = 3; }}\n\n# Port 443 Backend Servers for SSL\n# backend web1_ssl { .host = \"192.10.0.1\"; .port = \"443\"; .probe = { .url = \"\/status.php\"; .interval = 5s; .timeout = 1 s; .window = 5;.threshold = 3; }}\n# backend web2_ssl { .host = \"192.10.0.2\"; .port = \"443\"; .probe = { .url = \"\/status.php\"; .interval = 5s; .timeout = 1 s; .window = 5;.threshold = 3; }}\n\n# Define the director that determines how to distribute incoming requests.\ndirector default_director round-robin {\n { .backend = web1; }\n # { .backend = web2; }\n}\n\n#director ssl_director round-robin {\n# { .backend = web1_ssl; }\n# { .backend = web2_ssl; }\n#}\n\n# Respond to incoming requests.\nsub vcl_recv {\n # Set the director to cycle between web servers.\n #if (server.port == 443) {\n # set req.backend = ssl_director;\n #}\n #else {\n set req.backend = default_director;\n #}\n\n # Use anonymous, cached pages if all backends are down.\n if (!req.backend.healthy) {\n unset req.http.Cookie;\n }\n\n # Allow the backend to serve up stale content if it is responding slowly.\n set req.grace = 6h;\n\n # Do not cache these paths.\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/ooyala\/ping$\" ||\n req.url ~ \"^\/admin\/build\/features\" ||\n req.url ~ \"^\/info\/.*$\" ||\n req.url ~ \"^\/flag\/.*$\" ||\n req.url ~ \"^.*\/ajax\/.*$\" ||\n req.url ~ \"^.*\/ahah\/.*$\") {\n return (pass);\n }\n\n # Pipe these paths directly to Apache for streaming.\n if (req.url ~ \"^\/admin\/content\/backup_migrate\/export\" || req.url ~ \"^\/batch\") {\n return (pipe);\n }\n\n # Do not allow outside access to cron.php or install.php.\n if (req.url ~ \"^\/(cron|install)\\.php$\" && !client.ip ~ internal) {\n # Have Varnish throw the error directly.\n error 404 \"Page not found.\";\n # Use a custom error page that you've defined in Drupal at the path \"404\".\n # set req.url = \"\/404\";\n }\n\n # Handle compression correctly. Different browsers send different\n # \"Accept-Encoding\" headers, even though they mostly all support the same\n # compression mechanisms. By consolidating these compression headers into\n # a consistent format, we can reduce the size of the cache and get more hits.=\n # @see: http:\/\/ varnish.projects.linpro.no\/wiki\/FAQ\/Compression\n if (req.http.Accept-Encoding) {\n if (req.http.Accept-Encoding ~ \"gzip\") {\n # If the browser supports it, we'll use gzip.\n set req.http.Accept-Encoding = \"gzip\";\n }\n else if (req.http.Accept-Encoding ~ \"deflate\") {\n # Next, try deflate if it is supported.\n set req.http.Accept-Encoding = \"deflate\";\n }\n else {\n # Unknown algorithm. Remove it and send unencoded.\n unset req.http.Accept-Encoding;\n }\n }\n\n # Always cache the following file types for all users.\n if (req.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm)(\\?[a-z0-9]+)?$\") {\n unset req.http.Cookie;\n }\n\n # Remove all cookies that Drupal doesn't need to know about. ANY remaining\n # cookie will cause the request to pass-through to Apache. For the most part\n # we always set the NO_CACHE cookie after any POST request, disabling the\n # Varnish cache temporarily. The session cookie allows all authenticated users\n # to pass through as long as they're logged in.\n if (req.http.Cookie) {\n set req.http.Cookie = \";\" + req.http.Cookie;\n set req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n set req.http.Cookie = regsuball(req.http.Cookie, \";(S{1,2}ESS[a-z0-9]+|NO_CACHE|y\\_oauth\\_[A-Za-z0-9]+)=\", \"; \\1=\");\n set req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n\n if (req.http.Cookie == \"\") {\n # If there are no remaining cookies, remove the cookie header. If there\n # aren't any cookie headers, Varnish's default behavior will be to cache\n # the page.\n unset req.http.Cookie;\n }\n else {\n # If there is any cookies left (a session or NO_CACHE cookie), do not\n # cache the page. Pass it on to Apache directly.\n return (pass);\n }\n }\n}\n\n# Routine used to determine the cache key if storing\/retrieving a cached page.\nsub vcl_hash {\n # Include cookie in cache hash.\n # This check is unnecessary because we already pass on all cookies.\n # if (req.http.Cookie) {\n # hash_data(req.http.Cookie);\n # }\n \n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n if (req.http.X-Forwarded-Proto) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n return (hash);\n}\n\n# Code determining what to do when serving items from the Apache servers.\nsub vcl_fetch {\n # CJ - 3\/26\/2012 - Add support to pipe requests through to Apache for imagecache\n if (beresp.status >= 400 && req.restarts == 0) {\n return(restart);\n }\n \n # Don't allow static files to set cookies.\n if (req.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm)(\\?[a-z0-9]+)?$\") {\n # beresp == Back-end response from the web server.\n unset beresp.http.set-cookie;\n }\n\n # Allow items to be stale if needed.\n set beresp.grace = 6h;\n}\n\n# In the event of an error, show friendlier messages.\nsub vcl_error {\n # Redirect to some other URL in the case of a homepage failure.\n #if (req.url ~ \"^\/?$\") {\n # set obj.status = 302;\n # set obj.http.Location = \"http:\/\/backup.example.com\/\";\n #}\n\n # Otherwise redirect to the homepage, which will likely be in the cache.\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n synthetic {\"\n<html>\n<head>\n <title>Page Unavailable<\/title>\n <style>\n body { background: #303030; text-align: center; color: white; }\n #page { border: 1px solid #CCC; width: 500px; margin: 100px auto 0; padding: 30px; background: #323232; }\n a, a:link, a:visited { color: #CCC; }\n .error { color: #222; }\n <\/style>\n<\/head>\n<body onload=\"setTimeout(function() { window.location = '\/' }, 5000)\">\n <div id=\"page\">\n <h1 class=\"title\">Page Unavailable<\/h1>\n <p>The page you requested is temporarily unavailable.<\/p>\n <p>We're redirecting you to the <a href=\"\/\">homepage<\/a> in 5 seconds.<\/p>\n <div class=\"error\">(Error \"} + obj.status + \" \" + obj.response + {\")<\/div>\n <\/div>\n<\/body>\n<\/html>\n\"};\n return (deliver);\n}\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n","old_contents":"#\n# Customized VCL file for serving up a Drupal site with multiple back-ends.\n#\n# For more information on this VCL, visit the Lullabot article:\n# http:\/\/www.lullabot.com\/articles\/varnish-multiple-web-servers-drupal\n#\n#\n# Do Something version: Customized for a Vagrant sandbox.\n\n# Define the internal network subnet.\n# These are used below to allow internal access to certain files while not\n# allowing access from the public internet.\nacl internal {\n \"127.0.0.1\";\n}\n\n# Define the list of backends (web servers).\n# Port 80 Backend Servers\nbackend web1 { .host = \"127.0.0.1\"; .port = \"8888\"; .probe = { .url = \"\/status.php\"; .interval = 5s; .timeout = 1s; .window = 5;.threshold = 3; }}\n\n# Port 443 Backend Servers for SSL\n# backend web1_ssl { .host = \"192.10.0.1\"; .port = \"443\"; .probe = { .url = \"\/status.php\"; .interval = 5s; .timeout = 1 s; .window = 5;.threshold = 3; }}\n# backend web2_ssl { .host = \"192.10.0.2\"; .port = \"443\"; .probe = { .url = \"\/status.php\"; .interval = 5s; .timeout = 1 s; .window = 5;.threshold = 3; }}\n\n# Define the director that determines how to distribute incoming requests.\ndirector default_director round-robin {\n { .backend = web1; }\n # { .backend = web2; }\n}\n\n#director ssl_director round-robin {\n# { .backend = web1_ssl; }\n# { .backend = web2_ssl; }\n#}\n\n# Respond to incoming requests.\nsub vcl_recv {\n # Set the director to cycle between web servers.\n #if (server.port == 443) {\n # set req.backend = ssl_director;\n #}\n #else {\n set req.backend = default_director;\n #}\n\n # Use anonymous, cached pages if all backends are down.\n if (!req.backend.healthy) {\n unset req.http.Cookie;\n }\n\n # Allow the backend to serve up stale content if it is responding slowly.\n set req.grace = 6h;\n\n # Do not cache these paths.\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/ooyala\/ping$\" ||\n req.url ~ \"^\/admin\/build\/features\" ||\n req.url ~ \"^\/info\/.*$\" ||\n req.url ~ \"^\/flag\/.*$\" ||\n req.url ~ \"^.*\/ajax\/.*$\" ||\n req.url ~ \"^.*\/ahah\/.*$\") {\n return (pass);\n }\n\n # Pipe these paths directly to Apache for streaming.\n if (req.url ~ \"^\/admin\/content\/backup_migrate\/export\" || req.url ~ \"^\/batch\") {\n return (pipe);\n }\n\n # Do not allow outside access to cron.php or install.php.\n if (req.url ~ \"^\/(cron|install)\\.php$\" && !client.ip ~ internal) {\n # Have Varnish throw the error directly.\n error 404 \"Page not found.\";\n # Use a custom error page that you've defined in Drupal at the path \"404\".\n # set req.url = \"\/404\";\n }\n\n # Handle compression correctly. Different browsers send different\n # \"Accept-Encoding\" headers, even though they mostly all support the same\n # compression mechanisms. By consolidating these compression headers into\n # a consistent format, we can reduce the size of the cache and get more hits.=\n # @see: http:\/\/ varnish.projects.linpro.no\/wiki\/FAQ\/Compression\n if (req.http.Accept-Encoding) {\n if (req.http.Accept-Encoding ~ \"gzip\") {\n # If the browser supports it, we'll use gzip.\n set req.http.Accept-Encoding = \"gzip\";\n }\n else if (req.http.Accept-Encoding ~ \"deflate\") {\n # Next, try deflate if it is supported.\n set req.http.Accept-Encoding = \"deflate\";\n }\n else {\n # Unknown algorithm. Remove it and send unencoded.\n unset req.http.Accept-Encoding;\n }\n }\n\n # Always cache the following file types for all users.\n if (req.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm)(\\?[a-z0-9]+)?$\") {\n unset req.http.Cookie;\n }\n\n # Remove all cookies that Drupal doesn't need to know about. ANY remaining\n # cookie will cause the request to pass-through to Apache. For the most part\n # we always set the NO_CACHE cookie after any POST request, disabling the\n # Varnish cache temporarily. The session cookie allows all authenticated users\n # to pass through as long as they're logged in.\n if (req.http.Cookie) {\n set req.http.Cookie = \";\" + req.http.Cookie;\n set req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n set req.http.Cookie = regsuball(req.http.Cookie, \";(S{1,2}ESS[a-z0-9]+|NO_CACHE|y\\_oauth\\_[A-Za-z0-9]+)=\", \"; \\1=\");\n set req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n\n if (req.http.Cookie == \"\") {\n # If there are no remaining cookies, remove the cookie header. If there\n # aren't any cookie headers, Varnish's default behavior will be to cache\n # the page.\n unset req.http.Cookie;\n }\n else {\n # If there is any cookies left (a session or NO_CACHE cookie), do not\n # cache the page. Pass it on to Apache directly.\n return (pass);\n }\n }\n}\n\n# Routine used to determine the cache key if storing\/retrieving a cached page.\nsub vcl_hash {\n # Include cookie in cache hash.\n # This check is unnecessary because we already pass on all cookies.\n # if (req.http.Cookie) {\n # hash_data(req.http.Cookie);\n # }\n \n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n if (req.http.X-Forwarded-Proto) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n return (hash);\n}\n\n# Code determining what to do when serving items from the Apache servers.\nsub vcl_fetch {\n # CJ - 3\/26\/2012 - Add support to pipe requests through to Apache for imagecache\n if (beresp.status >= 400 && req.restarts == 0) {\n return(restart);\n }\n \n # Don't allow static files to set cookies.\n if (req.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm)(\\?[a-z0-9]+)?$\") {\n # beresp == Back-end response from the web server.\n unset beresp.http.set-cookie;\n }\n\n # Allow items to be stale if needed.\n set beresp.grace = 6h;\n}\n\n# In the event of an error, show friendlier messages.\nsub vcl_error {\n # Redirect to some other URL in the case of a homepage failure.\n #if (req.url ~ \"^\/?$\") {\n # set obj.status = 302;\n # set obj.http.Location = \"http:\/\/backup.example.com\/\";\n #}\n\n # Otherwise redirect to the homepage, which will likely be in the cache.\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n synthetic {\"\n<html>\n<head>\n <title>Page Unavailable<\/title>\n <style>\n body { background: #303030; text-align: center; color: white; }\n #page { border: 1px solid #CCC; width: 500px; margin: 100px auto 0; padding: 30px; background: #323232; }\n a, a:link, a:visited { color: #CCC; }\n .error { color: #222; }\n <\/style>\n<\/head>\n<body onload=\"setTimeout(function() { window.location = '\/' }, 5000)\">\n <div id=\"page\">\n <h1 class=\"title\">Page Unavailable<\/h1>\n <p>The page you requested is temporarily unavailable.<\/p>\n <p>We're redirecting you to the <a href=\"\/\">homepage<\/a> in 5 seconds.<\/p>\n <div class=\"error\">(Error \"} + obj.status + \" \" + obj.response + {\")<\/div>\n <\/div>\n<\/body>\n<\/html>\n\"};\n return (deliver);\n}\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"b48cecca76541b973b46e4f7bacf4534378458fd","subject":"Add comment","message":"Add comment\n","repos":"elifesciences\/builder,elifesciences\/builder","old_file":"src\/buildercore\/fastly\/vcl\/original-host.vcl","new_file":"src\/buildercore\/fastly\/vcl\/original-host.vcl","new_contents":"# Set X-Forwarded-Host if not a shield request\nif (!req.http.Fastly-FF) {\n set req.http.X-Forwarded-Host = req.http.host;\n}\n","old_contents":"if (!req.http.Fastly-FF) {\n set req.http.X-Forwarded-Host = req.http.host;\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"fd817e363e52fd60bb983a5f4bbe199994078811","subject":"Fixed production workers subnet IP for varnish","message":"Fixed production workers subnet IP for varnish\n","repos":"guillaume-sainthillier\/ByNight,guillaume-sainthillier\/ByNight,guillaume-sainthillier\/ByNight,guillaume-sainthillier\/ByNight","old_file":"docker\/prod\/varnish\/default.vcl","new_file":"docker\/prod\/varnish\/default.vcl","new_contents":"vcl 4.0;\n\nimport std;\nimport directors;\n\ninclude \"\/etc\/varnish\/fos\/fos_ban.vcl\";\ninclude \"\/etc\/varnish\/fos\/fos_custom_ttl.vcl\";\ninclude \"\/etc\/varnish\/fos\/fos_purge.vcl\";\ninclude \"\/etc\/varnish\/fos\/fos_refresh.vcl\";\n\n# by-night.fr\nbackend default {\n .host = \"app\";\n .port = \"80\";\n}\n\nacl invalidators {\n \"app\";\n \"localhost\";\n \"127.0.0.1\";\n \"::1\";\n \"172.19.0.0\"\/16;\n}\n\n# Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable,\n# which backend to use.\n# also used to modify the request\nsub vcl_recv {\n\n # Pass real client ip to request\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n # Normalize the header, remove the port (in case you're testing this on various TCP ports)\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n # Remove the proxy header (see https:\/\/httpoxy.org\/#mitigate-varnish)\n unset req.http.proxy;\n\n # Normalize the query arguments\n set req.url = std.querysort(req.url);\n\n # FOS purge & ban\n call fos_purge_recv;\n call fos_ban_recv;\n call fos_refresh_recv;\n\n # Only deal with \"normal\" types\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"PATCH\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (synth(404, \"Non-valid HTTP method!\"));\n }\n\n # Only cache GET or HEAD requests. This makes sure the POST requests are always passed.\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n # First remove the Google Analytics added parameters, useless for our backend\n if (req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=\") {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n }\n\n # Strip hash, server doesn't need it.\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n # Strip a trailing ? if it exists\n if (req.url ~ \"\\?$\") {\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # Suppression de tous les cookies sur les pages publiques\n if( ! req.url ~ \"^\/(login|inscription|resetting|logout|profile|commentaire|espace-perso|social|_administration|_private)\" ) {\n unset req.http.Cookie;\n set req.http.X-Cookie-State = \"Deleted\";\n }\n\n # Remove all cookies but no PHPSESSID\n if (req.http.Cookie) {\n set req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n set req.http.Cookie = regsuball(req.http.Cookie, \";(PHPSESSID|REMEMBERME|app_city)=\", \"; \\1=\");\n set req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n\n # Remove a \";\" prefix in the cookie if present\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n\n # Are there cookies left with only spaces or that are empty?\n if (req.http.Cookie ~ \"^\\s*$\") {\n unset req.http.Cookie;\n }\n\n set req.http.X-Cookie-State = \"Vanished\";\n set req.http.X-Cookie = req.http.Cookie;\n } else if(! req.http.X-Cookie-State) {\n set req.http.X-Cookie-State = \"Empty\";\n }\n\n # Send Surrogate-Capability headers to announce ESI support to backend\n set req.http.Surrogate-Capability = \"abc=ESI\/1.0\";\n\n # Delegating static files to nginx\n if (req.url ~ \"^[^?]*\\.(7z|avi|bz2|flac|flv|gz|mka|mkv|mov|mp3|mp4|mpeg|mpg|ogg|ogm|opus|rar|tar|tgz|tbz|txz|wav|webm|xz|zip)(\\?.*)?$\") {\n unset req.http.Cookie;\n return (pass);\n }\n\n # Delegating static files to nginx\n if (req.url ~ \"^[^?]*\\.(7z|avi|bmp|bz2|css|csv|doc|docx|eot|flac|flv|gif|gz|ico|jpeg|jpg|js|less|mka|mkv|mov|mp3|mp4|mpeg|mpg|odt|otf|ogg|ogm|opus|pdf|png|ppt|pptx|rar|rtf|svg|svgz|swf|tar|tbz|tgz|ttf|txt|txz|wav|webm|webp|woff|woff2|xls|xlsx|xml|xz|zip)(\\?.*)?$\") {\n unset req.http.Cookie;\n return (pass);\n }\n\n return (hash);\n}\n\n# The data on which the hashing will take place\nsub vcl_hash {\n # Called after vcl_recv to create a hash value for the request. This is used as a key\n # to look up the object in Varnish.\n\n hash_data(req.url);\n\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n\n # hash cookies for requests that have them\n if (req.http.Cookie) {\n hash_data(req.http.Cookie);\n }\n}\n\n# Called when a cache lookup is successful.\nsub vcl_hit {\n\n if (obj.ttl >= 0s) {\n # A pure unadultered hit, deliver it\n return (deliver);\n }\n\n # https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-grace.html\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (miss);\n }\n\n # We have no fresh fish. Lets look at the stale ones.\n if (std.healthy(req.backend_hint)) {\n # Backend is healthy. Limit age to 10s.\n if (obj.ttl + 10s > 0s) {\n #set req.http.grace = \"normal(limited)\";\n return (deliver);\n } else {\n # No candidate for grace. Fetch a fresh object.\n return (miss);\n }\n } else {\n # backend is sick - use full grace\n if (obj.ttl + obj.grace > 0s) {\n #set req.http.grace = \"full\";\n return (deliver);\n } else {\n # no graced object.\n return (miss);\n }\n }\n\n # fetch & deliver once we get the result\n return (miss); # Dead code, keep as a safeguard\n}\n\n# Handle the HTTP request coming from our backend\nsub vcl_backend_response {\n\t# Called after the response headers has been successfully retrieved from the backend.\n\n\t# Pause ESI request and remove Surrogate-Control header\n\tif (beresp.http.Surrogate-Control ~ \"ESI\/1.0\") {\n\t\tunset beresp.http.Surrogate-Control;\n\t\tset beresp.do_esi = true;\n\t}\n\n\t# Enable cache for all static files\n # The same argument as the static caches from above: monitor your cache size, if you get data nuked out of it, consider giving up the static file cache.\n # Before you blindly enable this, have a read here: https:\/\/ma.ttias.be\/stop-caching-static-files\/\n if (bereq.url ~ \"^[^?]*\\.(7z|avi|bmp|bz2|css|csv|doc|docx|eot|flac|flv|gif|gz|ico|jpeg|jpg|js|less|mka|mkv|mov|mp3|mp4|mpeg|mpg|odt|otf|ogg|ogm|opus|pdf|png|ppt|pptx|rar|rtf|svg|svgz|swf|tar|tbz|tgz|ttf|txt|txz|wav|webm|webp|woff|woff2|xls|xlsx|xml|xz|zip)(\\?.*)?$\") {\n unset beresp.http.set-cookie;\n }\n\n # Large static files are delivered directly to the end-user without\n # waiting for Varnish to fully read the file first.\n # Varnish 4 fully supports Streaming, so use streaming here to avoid locking.\n if (bereq.url ~ \"^[^?]*\\.(7z|avi|bz2|flac|flv|gz|mka|mkv|mov|mp3|mp4|mpeg|mpg|ogg|ogm|opus|rar|tar|tgz|tbz|txz|wav|webm|xz|zip)(\\?.*)?$\") {\n unset beresp.http.set-cookie;\n }\n\n \t# Don't cache 50x responses\n \tif (beresp.status == 500 || beresp.status == 502 || beresp.status == 503 || beresp.status == 504) {\n\t\treturn (abandon);\n \t}\n\n call fos_ban_backend_response;\n call fos_custom_ttl_backend_response;\n\n # Set 2min cache if unset for static files\n if (beresp.ttl <= 0s || beresp.http.Vary == \"*\") {\n set beresp.ttl = 0s; # Important, you shouldn't rely on this, SET YOUR HEADERS in the backend\n set beresp.uncacheable = true;\n return (deliver);\n }\n\n \t# Allow stale content, in case the backend goes down.\n \t# make Varnish keep all objects for 6 hours beyond their TTL\n \tset beresp.grace = 6h;\n\n \treturn (deliver);\n}\n\n\n# The routine when we deliver the HTTP request to the user\n# Last chance to modify headers that are sent to the client\nsub vcl_deliver {\n # Called before a cached object is delivered to the client.\n\n # Add debug header to see if it's a HIT\/MISS and the number of hits, disable when not needed\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n set resp.http.X-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n\n set resp.http.Server = \"By Night\";\n\n\tunset resp.http.Via;\n\tunset resp.http.X-Varnish;\n\n\tcall fos_ban_deliver;\n\n if (resp.http.X-Cache-Debug) {\n set resp.http.X-Cookie-Debug = req.http.X-Cookie;\n set resp.http.X-Cookie-State = req.http.X-Cookie-State;\n }\n\n return (deliver);\n}\n\nsub vcl_synth {\n if (resp.status == 720) {\n # We use this special error status 720 to force redirects with 301 (permanent) redirects\n # To use this, call the following from anywhere in vcl_recv: return (synth(720, \"http:\/\/host\/new.html\"));\n set resp.http.Location = resp.reason;\n set resp.status = 301;\n return (deliver);\n } elseif (resp.status == 721) {\n # And we use error status 721 to force redirects with a 302 (temporary) redirect\n # To use this, call the following from anywhere in vcl_recv: return (synth(720, \"http:\/\/host\/new.html\"));\n set resp.http.Location = resp.reason;\n set resp.status = 302;\n return (deliver);\n }\n\n return (deliver);\n}\n","old_contents":"vcl 4.0;\n\nimport std;\nimport directors;\n\ninclude \"\/etc\/varnish\/fos\/fos_ban.vcl\";\ninclude \"\/etc\/varnish\/fos\/fos_custom_ttl.vcl\";\ninclude \"\/etc\/varnish\/fos\/fos_purge.vcl\";\ninclude \"\/etc\/varnish\/fos\/fos_refresh.vcl\";\n\n# by-night.fr\nbackend default {\n .host = \"app\";\n .port = \"80\";\n}\n\nacl invalidators {\n \"app\";\n \"worker\";\n \"localhost\";\n \"127.0.0.1\";\n \"::1\";\n}\n\n# Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable,\n# which backend to use.\n# also used to modify the request\nsub vcl_recv {\n\n # Pass real client ip to request\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n # Normalize the header, remove the port (in case you're testing this on various TCP ports)\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n # Remove the proxy header (see https:\/\/httpoxy.org\/#mitigate-varnish)\n unset req.http.proxy;\n\n # Normalize the query arguments\n set req.url = std.querysort(req.url);\n\n # FOS purge & ban\n call fos_purge_recv;\n call fos_ban_recv;\n call fos_refresh_recv;\n\n # Only deal with \"normal\" types\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"PATCH\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (synth(404, \"Non-valid HTTP method!\"));\n }\n\n # Only cache GET or HEAD requests. This makes sure the POST requests are always passed.\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n # First remove the Google Analytics added parameters, useless for our backend\n if (req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=\") {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n }\n\n # Strip hash, server doesn't need it.\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n # Strip a trailing ? if it exists\n if (req.url ~ \"\\?$\") {\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # Suppression de tous les cookies sur les pages publiques\n if( ! req.url ~ \"^\/(login|inscription|resetting|logout|profile|commentaire|espace-perso|social|_administration|_private)\" ) {\n unset req.http.Cookie;\n set req.http.X-Cookie-State = \"Deleted\";\n }\n\n # Remove all cookies but no PHPSESSID\n if (req.http.Cookie) {\n set req.http.Cookie = regsuball(req.http.Cookie, \"; +\", \";\");\n set req.http.Cookie = regsuball(req.http.Cookie, \";(PHPSESSID|REMEMBERME|app_city)=\", \"; \\1=\");\n set req.http.Cookie = regsuball(req.http.Cookie, \";[^ ][^;]*\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"^[; ]+|[; ]+$\", \"\");\n\n # Remove a \";\" prefix in the cookie if present\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n\n # Are there cookies left with only spaces or that are empty?\n if (req.http.Cookie ~ \"^\\s*$\") {\n unset req.http.Cookie;\n }\n\n set req.http.X-Cookie-State = \"Vanished\";\n set req.http.X-Cookie = req.http.Cookie;\n } else if(! req.http.X-Cookie-State) {\n set req.http.X-Cookie-State = \"Empty\";\n }\n\n # Send Surrogate-Capability headers to announce ESI support to backend\n set req.http.Surrogate-Capability = \"abc=ESI\/1.0\";\n\n # Delegating static files to nginx\n if (req.url ~ \"^[^?]*\\.(7z|avi|bz2|flac|flv|gz|mka|mkv|mov|mp3|mp4|mpeg|mpg|ogg|ogm|opus|rar|tar|tgz|tbz|txz|wav|webm|xz|zip)(\\?.*)?$\") {\n unset req.http.Cookie;\n return (pass);\n }\n\n # Delegating static files to nginx\n if (req.url ~ \"^[^?]*\\.(7z|avi|bmp|bz2|css|csv|doc|docx|eot|flac|flv|gif|gz|ico|jpeg|jpg|js|less|mka|mkv|mov|mp3|mp4|mpeg|mpg|odt|otf|ogg|ogm|opus|pdf|png|ppt|pptx|rar|rtf|svg|svgz|swf|tar|tbz|tgz|ttf|txt|txz|wav|webm|webp|woff|woff2|xls|xlsx|xml|xz|zip)(\\?.*)?$\") {\n unset req.http.Cookie;\n return (pass);\n }\n\n return (hash);\n}\n\n# The data on which the hashing will take place\nsub vcl_hash {\n # Called after vcl_recv to create a hash value for the request. This is used as a key\n # to look up the object in Varnish.\n\n hash_data(req.url);\n\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n\n # hash cookies for requests that have them\n if (req.http.Cookie) {\n hash_data(req.http.Cookie);\n }\n}\n\n# Called when a cache lookup is successful.\nsub vcl_hit {\n\n if (obj.ttl >= 0s) {\n # A pure unadultered hit, deliver it\n return (deliver);\n }\n\n # https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-grace.html\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (miss);\n }\n\n # We have no fresh fish. Lets look at the stale ones.\n if (std.healthy(req.backend_hint)) {\n # Backend is healthy. Limit age to 10s.\n if (obj.ttl + 10s > 0s) {\n #set req.http.grace = \"normal(limited)\";\n return (deliver);\n } else {\n # No candidate for grace. Fetch a fresh object.\n return (miss);\n }\n } else {\n # backend is sick - use full grace\n if (obj.ttl + obj.grace > 0s) {\n #set req.http.grace = \"full\";\n return (deliver);\n } else {\n # no graced object.\n return (miss);\n }\n }\n\n # fetch & deliver once we get the result\n return (miss); # Dead code, keep as a safeguard\n}\n\n# Handle the HTTP request coming from our backend\nsub vcl_backend_response {\n\t# Called after the response headers has been successfully retrieved from the backend.\n\n\t# Pause ESI request and remove Surrogate-Control header\n\tif (beresp.http.Surrogate-Control ~ \"ESI\/1.0\") {\n\t\tunset beresp.http.Surrogate-Control;\n\t\tset beresp.do_esi = true;\n\t}\n\n\t# Enable cache for all static files\n # The same argument as the static caches from above: monitor your cache size, if you get data nuked out of it, consider giving up the static file cache.\n # Before you blindly enable this, have a read here: https:\/\/ma.ttias.be\/stop-caching-static-files\/\n if (bereq.url ~ \"^[^?]*\\.(7z|avi|bmp|bz2|css|csv|doc|docx|eot|flac|flv|gif|gz|ico|jpeg|jpg|js|less|mka|mkv|mov|mp3|mp4|mpeg|mpg|odt|otf|ogg|ogm|opus|pdf|png|ppt|pptx|rar|rtf|svg|svgz|swf|tar|tbz|tgz|ttf|txt|txz|wav|webm|webp|woff|woff2|xls|xlsx|xml|xz|zip)(\\?.*)?$\") {\n unset beresp.http.set-cookie;\n }\n\n # Large static files are delivered directly to the end-user without\n # waiting for Varnish to fully read the file first.\n # Varnish 4 fully supports Streaming, so use streaming here to avoid locking.\n if (bereq.url ~ \"^[^?]*\\.(7z|avi|bz2|flac|flv|gz|mka|mkv|mov|mp3|mp4|mpeg|mpg|ogg|ogm|opus|rar|tar|tgz|tbz|txz|wav|webm|xz|zip)(\\?.*)?$\") {\n unset beresp.http.set-cookie;\n }\n\n \t# Don't cache 50x responses\n \tif (beresp.status == 500 || beresp.status == 502 || beresp.status == 503 || beresp.status == 504) {\n\t\treturn (abandon);\n \t}\n\n call fos_ban_backend_response;\n call fos_custom_ttl_backend_response;\n\n # Set 2min cache if unset for static files\n if (beresp.ttl <= 0s || beresp.http.Vary == \"*\") {\n set beresp.ttl = 0s; # Important, you shouldn't rely on this, SET YOUR HEADERS in the backend\n set beresp.uncacheable = true;\n return (deliver);\n }\n\n \t# Allow stale content, in case the backend goes down.\n \t# make Varnish keep all objects for 6 hours beyond their TTL\n \tset beresp.grace = 6h;\n\n \treturn (deliver);\n}\n\n\n# The routine when we deliver the HTTP request to the user\n# Last chance to modify headers that are sent to the client\nsub vcl_deliver {\n # Called before a cached object is delivered to the client.\n\n # Add debug header to see if it's a HIT\/MISS and the number of hits, disable when not needed\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n set resp.http.X-Cache-Hits = obj.hits;\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n\n set resp.http.Server = \"By Night\";\n\n\tunset resp.http.Via;\n\tunset resp.http.X-Varnish;\n\n\tcall fos_ban_deliver;\n\n if (resp.http.X-Cache-Debug) {\n set resp.http.X-Cookie-Debug = req.http.X-Cookie;\n set resp.http.X-Cookie-State = req.http.X-Cookie-State;\n }\n\n return (deliver);\n}\n\nsub vcl_synth {\n if (resp.status == 720) {\n # We use this special error status 720 to force redirects with 301 (permanent) redirects\n # To use this, call the following from anywhere in vcl_recv: return (synth(720, \"http:\/\/host\/new.html\"));\n set resp.http.Location = resp.reason;\n set resp.status = 301;\n return (deliver);\n } elseif (resp.status == 721) {\n # And we use error status 721 to force redirects with a 302 (temporary) redirect\n # To use this, call the following from anywhere in vcl_recv: return (synth(720, \"http:\/\/host\/new.html\"));\n set resp.http.Location = resp.reason;\n set resp.status = 302;\n return (deliver);\n }\n\n return (deliver);\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"ab6614c8057ab5aca63358c44dd8753c360cabc3","subject":"add back first_byte_timeout and between_bytes_timeout to match openshift haproxy.","message":"add back first_byte_timeout and between_bytes_timeout to match openshift haproxy.\n","repos":"amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon,amazeeio\/lagoon","old_file":"images\/varnish-drupal\/drupal.vcl","new_file":"images\/varnish-drupal\/drupal.vcl","new_contents":"vcl 4.0;\n\nimport std;\nimport dynamic;\n\n# set backend default\nbackend default {\n .host = \"${VARNISH_BACKEND_HOST:-nginx}\";\n .port = \"${VARNISH_BACKEND_PORT:-8080}\";\n .first_byte_timeout = 35m;\n .between_bytes_timeout = 10m;\n}\n\n# Allow purging from localhost\n# @TODO allow from openshift network\nacl purge {\n \"127.0.0.1\";\n \"10.0.0.0\"\/8;\n \"172.16.0.0\"\/12;\n \"192.168.0.0\"\/16;\n}\n\nsub vcl_init {\n new www_dir = dynamic.director(\n port = \"${VARNISH_BACKEND_PORT:-8080}\",\n first_byte_timeout = 90s,\n between_bytes_timeout = 90s,\n whitelist = purge,\n ttl = 60s);\n }\n\n# This configuration is optimized for Drupal hosting:\n# Respond to incoming requests.\nsub vcl_recv {\n\n if (req.url ~ \"^\/varnish_status$\") {\n return (synth(200,\"OK\"));\n }\n # set the backend, which should be used:\n set req.backend_hint = www_dir.backend(\"${VARNISH_BACKEND_HOST:-nginx}\");\n\n # Always set the forward ip.\n if (req.restarts == 0) {\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n\n\n if (req.http.X-LAGOON-VARNISH ) {\n ## Pass all Requests which are handled via an upstream Varnish\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, \" + req.http.X-LAGOON-VARNISH;\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n } else if (req.http.Fastly-FF) {\n ## Pass all Requests which are handled via Fastly\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, fastly\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n set req.http.X-Forwarded-For = req.http.Fastly-Client-IP;\n } else if (req.http.CF-RAY) {\n ## Pass all Requests which are handled via CloudFlare\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, cloudflare\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n set req.http.X-Forwarded-For = req.http.CF-Connecting-IP;\n } else if (req.http.X-Pull) {\n ## Pass all Requests which are handled via KeyCDN\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, keycdn\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n } else {\n ## We set a header to let a Varnish Chain know that it already has been varnishcached\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}\";\n\n ## Allow to bypass based on env variable `VARNISH_BYPASS`\n set req.http.X-LAGOON-VARNISH-BYPASS = \"${VARNISH_BYPASS:-false}\";\n }\n\n # Websockets are piped\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n if (req.http.X-LAGOON-VARNISH-BYPASS == \"true\" || req.http.X-LAGOON-VARNISH-BYPASS == \"TRUE\") {\n return (pass);\n }\n\n # SA-CORE-2014-004 preventing access to \/xmlrpc.php\n if (req.url ~ \"^\/xmlrpc.php$\") {\n return (synth(701, \"Unauthorized\"));\n }\n\n # Strip out Google Analytics campaign variables. They are only needed\n # by the javascript running on the page\n # utm_source, utm_medium, utm_campaign, gclid\n if(req.url ~ \"(\\?|&)(gclid|utm_[a-z]+)=\") {\n set req.url = regsuball(req.url, \"(gclid|utm_[a-z]+)=[^\\&]+&?\", \"\");\n set req.url = regsub(req.url, \"(\\?|&)$\", \"\");\n }\n\n # Bypass a cache hit (the request is still sent to the backend)\n if (req.method == \"REFRESH\") {\n if (!client.ip ~ purge) { return (synth(405, \"Not allowed\")); }\n set req.method = \"GET\";\n set req.hash_always_miss = true;\n }\n\n # Only allow BAN requests from IP addresses in the 'purge' ACL.\n if (req.method == \"BAN\" || req.method == \"URIBAN\" || req.method == \"PURGE\") {\n # Only allow BAN from defined ACL\n if (!client.ip ~ purge) {\n return (synth(403, \"Your IP is not allowed.\"));\n }\n\n # Only allows BAN if the Host Header has the style of with \"${SERVICE_NAME:-varnish}:8080\" or \"${SERVICE_NAME:-varnish}\".\n # Such a request is only possible from within the Docker network, as a request from external goes trough the Kubernetes Router and for that needs a proper Host Header\n if (!req.http.host ~ \"^${SERVICE_NAME:-varnish}(:\\d+)?$\") {\n return (synth(403, \"Only allowed from within own network.\"));\n }\n\n if (req.method == \"BAN\") {\n # Logic for the ban, using the Cache-Tags header.\n if (req.http.Cache-Tags) {\n ban(\"obj.http.Cache-Tags ~ \" + req.http.Cache-Tags);\n # Throw a synthetic page so the request won't go to the backend.\n return (synth(200, \"Ban added.\"));\n }\n else {\n return (synth(403, \"Cache-Tags header missing.\"));\n }\n }\n\n if (req.method == \"URIBAN\" || req.method == \"PURGE\") {\n ban(\"req.url ~ \" + req.url);\n # Throw a synthetic page so the request won't go to the backend.\n return (synth(200, \"Ban added.\"));\n }\n\n }\n\n # Non-RFC2616 or CONNECT which is weird, we pipe that\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n return (pipe);\n }\n\n # We only try to cache GET and HEAD, other things are passed\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n # Any requests with Basic Auth are passed\n if (req.http.Authorization || req.http.Authenticate)\n {\n return (pass);\n }\n\n ## Pass requests which are from blackfire\n if (req.http.X-Blackfire-Query) {\n return (pass);\n }\n\n # Some URLs should never be cached\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/admin([\/?]|$).*$\" ||\n req.url ~ \"^\/info([\/?]|$).*$\" ||\n req.url ~ \"^\/flag([\/?]|$).*$\" ||\n req.url ~ \"^.*\/system\/files([\/?]|$).*$\" ||\n req.url ~ \"^\/cgi\" ||\n req.url ~ \"^\/cgi-bin\"\n ) {\n return (pass);\n }\n\n # Plupload likes to get piped\n if (req.url ~ \"^.*\/plupload-handle-uploads.*$\"\n ) {\n return (pipe);\n }\n\n # Handle compression correctly. Different browsers send different\n # \"Accept-Encoding\" headers, even though they mostly all support the same\n # compression mechanisms. By consolidating these compression headers into\n # a consistent format, we can reduce the size of the cache and get more hits.=\n # @see: http:\/\/ varnish.projects.linpro.no\/wiki\/FAQ\/Compression\n if (req.http.Accept-Encoding) {\n if (req.http.Accept-Encoding ~ \"gzip\") {\n # If the browser supports it, we'll use gzip.\n set req.http.Accept-Encoding = \"gzip\";\n }\n else if (req.http.Accept-Encoding ~ \"deflate\") {\n # Next, try deflate if it is supported.\n set req.http.Accept-Encoding = \"deflate\";\n }\n else {\n # Unknown algorithm. Remove it and send unencoded.\n unset req.http.Accept-Encoding;\n }\n }\n\n # Always cache the following file types for all users.\n if (req.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n unset req.http.Cookie;\n }\n\n # Remove all cookies that Drupal doesn't need to know about. ANY remaining\n # cookie will cause the request to pass-through to a backend. For the most part\n # we always set the NO_CACHE cookie after any POST request, disabling the\n # Varnish cache temporarily. The session cookie allows all authenticated users\n # to pass through as long as they're logged in.\n #\n # 1. Append a semi-colon to the front of the cookie string.\n # 2. Remove all spaces that appear after semi-colons.\n # 3. Match the cookies we want to keep, adding the space we removed\n # previously, back. (\\1) is first matching group in the regsuball.\n # 4. Remove all other cookies, identifying them by the fact that they have\n # no space after the preceding semi-colon.\n # 5. Remove all spaces and semi-colons from the beginning and end of the\n # cookie string.\n if (req.http.Cookie) {\n set req.http.CookieCheck = \";\" + req.http.Cookie;\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"; +\", \";\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";(${VARNISH_COOKIECHECK:-SESS[a-z0-9]+|SSESS[a-z0-9]+|NO_CACHE})=\", \"; \\1=\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";[^ ][^;]*\", \"\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"^[; ]+|[; ]+$\", \"\");\n\n set req.http.Cookie = req.http.Cookie + \";\";\n\n if (req.http.CookieCheck == \"\") {\n # If there are no remaining cookies, remove the cookie header. If there\n # aren't any cookie headers, Varnish's default behavior will be to cache\n # the page.\n\n unset req.http.CookieCheck;\n unset req.http.Cookie;\n }\n else {\n # If there is any cookies left (a session or NO_CACHE cookie), do not\n # cache the page. Pass it on to Apache directly.\n unset req.http.CookieCheck;\n return (pass);\n }\n }\n\n # Cacheable, lookup in cache.\n return (hash);\n}\n\nsub vcl_pipe {\n # Support for Websockets\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n set bereq.http.connection = req.http.connection;\n }\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n # normal hit\n return (deliver);\n }\n # We have no fresh fish. Lets look at the stale ones.\n if (std.healthy(req.backend_hint)) {\n # Backend is healthy. If the object is not older then 30secs, deliver it to the client\n # and automatically create a separate backend request to warm the cache for this request.\n if (obj.ttl + 30s > 0s) {\n set req.http.grace = \"normal(limited)\";\n return (deliver);\n } else {\n # No candidate for grace. Fetch a fresh object.\n return(miss);\n }\n } else {\n # backend is sick - use full grace\n if (obj.ttl + obj.grace > 0s) {\n set req.http.grace = \"full\";\n return (deliver);\n } else {\n # no graced object.\n return (miss);\n }\n }\n}\n\nsub vcl_backend_response {\n # Allow items to be stale if needed.\n set beresp.grace = 6h;\n\n # Set ban-lurker friendly custom headers.\n set beresp.http.X-Url = bereq.url;\n set beresp.http.X-Host = bereq.http.host;\n\n # If the backend sends a X-LAGOON-VARNISH-BACKEND-BYPASS header we directly deliver\n if(beresp.http.X-LAGOON-VARNISH-BACKEND-BYPASS == \"TRUE\") {\n return (deliver);\n }\n\n # Cache 404 and 403 for 10 seconds\n if(beresp.status == 404 || beresp.status == 403) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n # Don't allow static files to set cookies.\n if (bereq.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n # beresp == Back-end response from the web server.\n unset beresp.http.set-cookie;\n unset beresp.http.Cache-Control;\n\n # If an asset would come back with statuscode 500 we only cache it for 10 seconds instead of the usual static file cache\n if (beresp.status == 500) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n set beresp.ttl = ${VARNISH_ASSETS_TTL:-2628001}s;\n set beresp.http.Cache-Control = \"public, max-age=${VARNISH_ASSETS_TTL:-2628001}\";\n set beresp.http.Expires = \"\" + (now + beresp.ttl);\n }\n\n return (deliver);\n}\n\n# Set a header to track a cache HIT\/MISS.\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Varnish-Cache = \"HIT\";\n }\n else {\n set resp.http.X-Varnish-Cache = \"MISS\";\n }\n\n # Remove ban-lurker friendly custom headers when delivering to client.\n unset resp.http.X-Url;\n unset resp.http.X-Host;\n\n # unset Cache-Tags Header by default, can be disabled with VARNISH_UNSET_HEADER_CACHE_TAGS=true\n if (!${VARNISH_UNSET_HEADER_CACHE_TAGS:-false}) {\n unset resp.http.Cache-Tags;\n }\n\n unset resp.http.X-Generator;\n unset resp.http.Server;\n # Inject information about grace\n if (req.http.grace) {\n set resp.http.X-Varnish-Grace = req.http.grace;\n }\n set resp.http.X-LAGOON = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}>\" + resp.http.X-LAGOON;\n return (deliver);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n if (req.http.X-Forwarded-Proto) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n if (req.http.HTTPS) {\n hash_data(req.http.HTTPS);\n }\n return (lookup);\n}\n\nsub vcl_synth {\n if (resp.status == 701) {\n set resp.status = 401;\n set resp.http.Content-Type = \"text\/plain; charset=utf-8\";\n synthetic({\"XMLRPC Interface is blocked due to SA-CORE-2014-004 - mail support@amazee.io if you need it.\"});\n return (deliver);\n }\n if (resp.status == 700) {\n # Set a status the client will understand\n set resp.status = 200;\n # Create our synthetic response\n synthetic(\"\");\n return(deliver);\n}\n return (deliver);\n}\n\nsub vcl_backend_error {\n # Restart the request, when we have a backend server error, to try another backend.\n # Restart max twice.\n if (bereq.retries < 2) {\n return(retry);\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<head>\n <title>Server Error<\/title>\n <style type=\"text\/css\">\n body {\n font-family: helvetica, arial, sans-serif;\n }\n img {\n margin-top: 50px;\n }\n p {\n width: 6 00px;\n margin-top: 10px\n }\n div {\n background: #ccc;\n width: 600px;\n margin: auto;\n padding: 50px;\n }\n span {\n color: #ccc\n }\n <\/style>\n<\/head>\n<body>\n <div>\n <h1>We are sorry...<\/h1>\n <p>We encountered a server-side error. This means that the problem is not with your computer or Internet connection, but rather with the website's server.<\/p>\n <p>We are currently working on solving this problem and apologise for the inconvenience.<\/p>\n <span>\n <strong>Technical Information<\/strong><br \/>\n Error \"} + beresp.status + \" \" + beresp.reason + {\"<br \/>\n XID: \"} + bereq.xid + {\"<br \/>\n <\/span>\n <\/div>\n<\/body>\n<\/html>\n\n\"} );\n return (deliver);\n}\n","old_contents":"vcl 4.0;\n\nimport std;\nimport dynamic;\n\n# set backend default\nbackend default {\n .host = \"${VARNISH_BACKEND_HOST:-nginx}\";\n .port = \"${VARNISH_BACKEND_PORT:-8080}\";\n .first_byte_timeout = 35m;\n .between_bytes_timeout = 10m;\n}\n\n# Allow purging from localhost\n# @TODO allow from openshift network\nacl purge {\n \"127.0.0.1\";\n \"10.0.0.0\"\/8;\n \"172.16.0.0\"\/12;\n \"192.168.0.0\"\/16;\n}\n\nsub vcl_init {\n new www_dir = dynamic.director(\n port = \"${VARNISH_BACKEND_PORT:-8080}\",\n whitelist = purge,\n ttl = 60s);\n }\n\n# This configuration is optimized for Drupal hosting:\n# Respond to incoming requests.\nsub vcl_recv {\n\n if (req.url ~ \"^\/varnish_status$\") {\n return (synth(200,\"OK\"));\n }\n # set the backend, which should be used:\n set req.backend_hint = www_dir.backend(\"${VARNISH_BACKEND_HOST:-nginx}\");\n\n # Always set the forward ip.\n if (req.restarts == 0) {\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n\n\n if (req.http.X-LAGOON-VARNISH ) {\n ## Pass all Requests which are handled via an upstream Varnish\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, \" + req.http.X-LAGOON-VARNISH;\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n } else if (req.http.Fastly-FF) {\n ## Pass all Requests which are handled via Fastly\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, fastly\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n set req.http.X-Forwarded-For = req.http.Fastly-Client-IP;\n } else if (req.http.CF-RAY) {\n ## Pass all Requests which are handled via CloudFlare\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, cloudflare\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n set req.http.X-Forwarded-For = req.http.CF-Connecting-IP;\n } else if (req.http.X-Pull) {\n ## Pass all Requests which are handled via KeyCDN\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}, keycdn\";\n set req.http.X-LAGOON-VARNISH-BYPASS = \"true\";\n } else {\n ## We set a header to let a Varnish Chain know that it already has been varnishcached\n set req.http.X-LAGOON-VARNISH = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}\";\n\n ## Allow to bypass based on env variable `VARNISH_BYPASS`\n set req.http.X-LAGOON-VARNISH-BYPASS = \"${VARNISH_BYPASS:-false}\";\n }\n\n # Websockets are piped\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n if (req.http.X-LAGOON-VARNISH-BYPASS == \"true\" || req.http.X-LAGOON-VARNISH-BYPASS == \"TRUE\") {\n return (pass);\n }\n\n # SA-CORE-2014-004 preventing access to \/xmlrpc.php\n if (req.url ~ \"^\/xmlrpc.php$\") {\n return (synth(701, \"Unauthorized\"));\n }\n\n # Strip out Google Analytics campaign variables. They are only needed\n # by the javascript running on the page\n # utm_source, utm_medium, utm_campaign, gclid\n if(req.url ~ \"(\\?|&)(gclid|utm_[a-z]+)=\") {\n set req.url = regsuball(req.url, \"(gclid|utm_[a-z]+)=[^\\&]+&?\", \"\");\n set req.url = regsub(req.url, \"(\\?|&)$\", \"\");\n }\n\n # Bypass a cache hit (the request is still sent to the backend)\n if (req.method == \"REFRESH\") {\n if (!client.ip ~ purge) { return (synth(405, \"Not allowed\")); }\n set req.method = \"GET\";\n set req.hash_always_miss = true;\n }\n\n # Only allow BAN requests from IP addresses in the 'purge' ACL.\n if (req.method == \"BAN\" || req.method == \"URIBAN\" || req.method == \"PURGE\") {\n # Only allow BAN from defined ACL\n if (!client.ip ~ purge) {\n return (synth(403, \"Your IP is not allowed.\"));\n }\n\n # Only allows BAN if the Host Header has the style of with \"${SERVICE_NAME:-varnish}:8080\" or \"${SERVICE_NAME:-varnish}\".\n # Such a request is only possible from within the Docker network, as a request from external goes trough the Kubernetes Router and for that needs a proper Host Header\n if (!req.http.host ~ \"^${SERVICE_NAME:-varnish}(:\\d+)?$\") {\n return (synth(403, \"Only allowed from within own network.\"));\n }\n\n if (req.method == \"BAN\") {\n # Logic for the ban, using the Cache-Tags header.\n if (req.http.Cache-Tags) {\n ban(\"obj.http.Cache-Tags ~ \" + req.http.Cache-Tags);\n # Throw a synthetic page so the request won't go to the backend.\n return (synth(200, \"Ban added.\"));\n }\n else {\n return (synth(403, \"Cache-Tags header missing.\"));\n }\n }\n\n if (req.method == \"URIBAN\" || req.method == \"PURGE\") {\n ban(\"req.url ~ \" + req.url);\n # Throw a synthetic page so the request won't go to the backend.\n return (synth(200, \"Ban added.\"));\n }\n\n }\n\n # Non-RFC2616 or CONNECT which is weird, we pipe that\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n return (pipe);\n }\n\n # We only try to cache GET and HEAD, other things are passed\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n # Any requests with Basic Auth are passed\n if (req.http.Authorization || req.http.Authenticate)\n {\n return (pass);\n }\n\n ## Pass requests which are from blackfire\n if (req.http.X-Blackfire-Query) {\n return (pass);\n }\n\n # Some URLs should never be cached\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/admin([\/?]|$).*$\" ||\n req.url ~ \"^\/info([\/?]|$).*$\" ||\n req.url ~ \"^\/flag([\/?]|$).*$\" ||\n req.url ~ \"^.*\/system\/files([\/?]|$).*$\" ||\n req.url ~ \"^\/cgi\" ||\n req.url ~ \"^\/cgi-bin\"\n ) {\n return (pass);\n }\n\n # Plupload likes to get piped\n if (req.url ~ \"^.*\/plupload-handle-uploads.*$\"\n ) {\n return (pipe);\n }\n\n # Handle compression correctly. Different browsers send different\n # \"Accept-Encoding\" headers, even though they mostly all support the same\n # compression mechanisms. By consolidating these compression headers into\n # a consistent format, we can reduce the size of the cache and get more hits.=\n # @see: http:\/\/ varnish.projects.linpro.no\/wiki\/FAQ\/Compression\n if (req.http.Accept-Encoding) {\n if (req.http.Accept-Encoding ~ \"gzip\") {\n # If the browser supports it, we'll use gzip.\n set req.http.Accept-Encoding = \"gzip\";\n }\n else if (req.http.Accept-Encoding ~ \"deflate\") {\n # Next, try deflate if it is supported.\n set req.http.Accept-Encoding = \"deflate\";\n }\n else {\n # Unknown algorithm. Remove it and send unencoded.\n unset req.http.Accept-Encoding;\n }\n }\n\n # Always cache the following file types for all users.\n if (req.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n unset req.http.Cookie;\n }\n\n # Remove all cookies that Drupal doesn't need to know about. ANY remaining\n # cookie will cause the request to pass-through to a backend. For the most part\n # we always set the NO_CACHE cookie after any POST request, disabling the\n # Varnish cache temporarily. The session cookie allows all authenticated users\n # to pass through as long as they're logged in.\n #\n # 1. Append a semi-colon to the front of the cookie string.\n # 2. Remove all spaces that appear after semi-colons.\n # 3. Match the cookies we want to keep, adding the space we removed\n # previously, back. (\\1) is first matching group in the regsuball.\n # 4. Remove all other cookies, identifying them by the fact that they have\n # no space after the preceding semi-colon.\n # 5. Remove all spaces and semi-colons from the beginning and end of the\n # cookie string.\n if (req.http.Cookie) {\n set req.http.CookieCheck = \";\" + req.http.Cookie;\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"; +\", \";\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";(${VARNISH_COOKIECHECK:-SESS[a-z0-9]+|SSESS[a-z0-9]+|NO_CACHE})=\", \"; \\1=\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \";[^ ][^;]*\", \"\");\n set req.http.CookieCheck = regsuball(req.http.CookieCheck, \"^[; ]+|[; ]+$\", \"\");\n\n set req.http.Cookie = req.http.Cookie + \";\";\n\n if (req.http.CookieCheck == \"\") {\n # If there are no remaining cookies, remove the cookie header. If there\n # aren't any cookie headers, Varnish's default behavior will be to cache\n # the page.\n\n unset req.http.CookieCheck;\n unset req.http.Cookie;\n }\n else {\n # If there is any cookies left (a session or NO_CACHE cookie), do not\n # cache the page. Pass it on to Apache directly.\n unset req.http.CookieCheck;\n return (pass);\n }\n }\n\n # Cacheable, lookup in cache.\n return (hash);\n}\n\nsub vcl_pipe {\n # Support for Websockets\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n set bereq.http.connection = req.http.connection;\n }\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n # normal hit\n return (deliver);\n }\n # We have no fresh fish. Lets look at the stale ones.\n if (std.healthy(req.backend_hint)) {\n # Backend is healthy. If the object is not older then 30secs, deliver it to the client\n # and automatically create a separate backend request to warm the cache for this request.\n if (obj.ttl + 30s > 0s) {\n set req.http.grace = \"normal(limited)\";\n return (deliver);\n } else {\n # No candidate for grace. Fetch a fresh object.\n return(miss);\n }\n } else {\n # backend is sick - use full grace\n if (obj.ttl + obj.grace > 0s) {\n set req.http.grace = \"full\";\n return (deliver);\n } else {\n # no graced object.\n return (miss);\n }\n }\n}\n\nsub vcl_backend_response {\n # Allow items to be stale if needed.\n set beresp.grace = 6h;\n\n # Set ban-lurker friendly custom headers.\n set beresp.http.X-Url = bereq.url;\n set beresp.http.X-Host = bereq.http.host;\n\n # If the backend sends a X-LAGOON-VARNISH-BACKEND-BYPASS header we directly deliver\n if(beresp.http.X-LAGOON-VARNISH-BACKEND-BYPASS == \"TRUE\") {\n return (deliver);\n }\n\n # Cache 404 and 403 for 10 seconds\n if(beresp.status == 404 || beresp.status == 403) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n # Don't allow static files to set cookies.\n if (bereq.url ~ \"(?i)\\.(css|js|jpg|jpeg|gif|ico|png|tiff|tif|img|tga|wmf|swf|html|htm|woff|woff2|mp4|ttf|eot|svg)(\\?.*)?$\") {\n # beresp == Back-end response from the web server.\n unset beresp.http.set-cookie;\n unset beresp.http.Cache-Control;\n\n # If an asset would come back with statuscode 500 we only cache it for 10 seconds instead of the usual static file cache\n if (beresp.status == 500) {\n set beresp.ttl = 10s;\n return (deliver);\n }\n\n set beresp.ttl = ${VARNISH_ASSETS_TTL:-2628001}s;\n set beresp.http.Cache-Control = \"public, max-age=${VARNISH_ASSETS_TTL:-2628001}\";\n set beresp.http.Expires = \"\" + (now + beresp.ttl);\n }\n\n return (deliver);\n}\n\n# Set a header to track a cache HIT\/MISS.\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Varnish-Cache = \"HIT\";\n }\n else {\n set resp.http.X-Varnish-Cache = \"MISS\";\n }\n\n # Remove ban-lurker friendly custom headers when delivering to client.\n unset resp.http.X-Url;\n unset resp.http.X-Host;\n\n # unset Cache-Tags Header by default, can be disabled with VARNISH_UNSET_HEADER_CACHE_TAGS=true\n if (!${VARNISH_UNSET_HEADER_CACHE_TAGS:-false}) {\n unset resp.http.Cache-Tags;\n }\n\n unset resp.http.X-Generator;\n unset resp.http.Server;\n # Inject information about grace\n if (req.http.grace) {\n set resp.http.X-Varnish-Grace = req.http.grace;\n }\n set resp.http.X-LAGOON = \"${HOSTNAME}-${LAGOON_GIT_BRANCH:-undef}-${LAGOON_PROJECT}>\" + resp.http.X-LAGOON;\n return (deliver);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n if (req.http.X-Forwarded-Proto) {\n hash_data(req.http.X-Forwarded-Proto);\n }\n if (req.http.HTTPS) {\n hash_data(req.http.HTTPS);\n }\n return (lookup);\n}\n\nsub vcl_synth {\n if (resp.status == 701) {\n set resp.status = 401;\n set resp.http.Content-Type = \"text\/plain; charset=utf-8\";\n synthetic({\"XMLRPC Interface is blocked due to SA-CORE-2014-004 - mail support@amazee.io if you need it.\"});\n return (deliver);\n }\n if (resp.status == 700) {\n # Set a status the client will understand\n set resp.status = 200;\n # Create our synthetic response\n synthetic(\"\");\n return(deliver);\n}\n return (deliver);\n}\n\nsub vcl_backend_error {\n # Restart the request, when we have a backend server error, to try another backend.\n # Restart max twice.\n if (bereq.retries < 2) {\n return(retry);\n }\n\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<head>\n <title>Server Error<\/title>\n <style type=\"text\/css\">\n body {\n font-family: helvetica, arial, sans-serif;\n }\n img {\n margin-top: 50px;\n }\n p {\n width: 6 00px;\n margin-top: 10px\n }\n div {\n background: #ccc;\n width: 600px;\n margin: auto;\n padding: 50px;\n }\n span {\n color: #ccc\n }\n <\/style>\n<\/head>\n<body>\n <div>\n <h1>We are sorry...<\/h1>\n <p>We encountered a server-side error. This means that the problem is not with your computer or Internet connection, but rather with the website's server.<\/p>\n <p>We are currently working on solving this problem and apologise for the inconvenience.<\/p>\n <span>\n <strong>Technical Information<\/strong><br \/>\n Error \"} + beresp.status + \" \" + beresp.reason + {\"<br \/>\n XID: \"} + bereq.xid + {\"<br \/>\n <\/span>\n <\/div>\n<\/body>\n<\/html>\n\n\"} );\n return (deliver);\n}\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"d18e56fca661c68a3a718b33823f044ff8a8c3ce","subject":"update varnish config","message":"update varnish config\n","repos":"pombredanne\/sf1r-lite,izenecloud\/sf1r-ad-delivery,izenecloud\/sf1r-ad-delivery,izenecloud\/sf1r-ad-delivery,pombredanne\/sf1r-lite,izenecloud\/sf1r-lite,izenecloud\/sf1r-ad-delivery,izenecloud\/sf1r-lite,izenecloud\/sf1r-lite,pombredanne\/sf1r-lite,izenecloud\/sf1r-lite,pombredanne\/sf1r-lite,izenecloud\/sf1r-ad-delivery,pombredanne\/sf1r-lite,izenecloud\/sf1r-lite","old_file":"source\/process\/ImageServerProcess\/cgi\/default.vcl","new_file":"source\/process\/ImageServerProcess\/cgi\/default.vcl","new_contents":"# This is a basic VCL configuration file for varnish. See the vcl(7)\n# man page for details on VCL syntax and semantics.\n# \n# Default backend definition. Set this to point to your content\n# server.\n# \nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8888\";\n}\n\nacl purge {\n \"localhost\";\n \"172.16.0.0\"\/24;\n}\n\n# \n# Below is a commented-out copy of the default VCL logic. If you\n# redefine any of these subroutines, the built-in logic will be\n# appended to your code.\n# \n sub vcl_recv {\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For =\n req.http.X-Forwarded-For \", \" client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n if (req.request == \"PURGE\") {\n if (!client.ip ~ purge) {\n error 405 \"This IP is not allowed to send PURGE requests.\";\n }\n\n return (lookup);\n }\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.url ~ \"^\/image.cgi\") {\n unset req.http.cookie;\n }\n if (req.url ~ \"^\/image\/\") {\n unset req.http.cookie;\n }\n if (req.http.Authorization || req.http.Cookie) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n return (lookup);\n }\n \n sub vcl_pipe {\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n # set req.http.connection = \"close\";\n # here. It is not set by default as it might break some broken web\n # applications, like IIS with NTLM authentication.\n set req.http.connection = \"close\";\n return (pipe);\n }\n \nsub vcl_pass {\n return (pass);\n}\n# \n# sub vcl_hash {\n# set req.hash += req.url;\n# if (req.http.host) {\n# set req.hash += req.http.host;\n# } else {\n# set req.hash += server.ip;\n# }\n# return (hash);\n# }\n \n sub vcl_hit {\n if (req.request == \"PURGE\") {\n set obj.ttl = 0s;\n error 200 \"Purged\";\n }\n return (deliver);\n }\n \n sub vcl_miss {\n if (req.request == \"PURGE\") {\n error 404 \"Not in cache\";\n }\n return (fetch);\n }\n \n sub vcl_fetch {\n# if (!beresp.cacheable) {\n# return (pass);\n# }\n if( (req.request == \"GET\" || req.request == \"HEAD\") && (req.url ~ \"^\/image.cgi\" || req.url ~ \"^\/image\/\") ) {\n if(beresp.status == 200 || beresp.status == 302) {\n set beresp.ttl = 1h;\n }\n if(beresp.status == 404) {\n set beresp.ttl = 0s;\n }\n if(beresp.status >= 500) {\n set beresp.ttl = 0s;\n }\n return (deliver);\n }\n if (beresp.http.Set-Cookie) {\n return (pass);\n }\n }\n# \n# sub vcl_deliver {\n# return (deliver);\n# }\n# \n# sub vcl_error {\n# set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n# synthetic {\"\n# <?xml version=\"1.0\" encoding=\"utf-8\"?>\n# <!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n# \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n# <html>\n# <head>\n# <title>\"} obj.status \" \" obj.response {\"<\/title>\n# <\/head>\n# <body>\n# <h1>Error \"} obj.status \" \" obj.response {\"<\/h1>\n# <p>\"} obj.response {\"<\/p>\n# <h3>Guru Meditation:<\/h3>\n# <p>XID: \"} req.xid {\"<\/p>\n# <hr>\n# <p>Varnish cache server<\/p>\n# <\/body>\n# <\/html>\n# \"};\n# return (deliver);\n# }\n","old_contents":"# This is a basic VCL configuration file for varnish. See the vcl(7)\n# man page for details on VCL syntax and semantics.\n# \n# Default backend definition. Set this to point to your content\n# server.\n# \nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8888\";\n}\n\nacl purge {\n \"localhost\";\n \"172.16.0.0\"\/24;\n}\n\n# \n# Below is a commented-out copy of the default VCL logic. If you\n# redefine any of these subroutines, the built-in logic will be\n# appended to your code.\n# \n sub vcl_recv {\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For =\n req.http.X-Forwarded-For \", \" client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n if (req.request == \"PURGE\") {\n if (!client.ip ~ purge) {\n error 405 \"This IP is not allowed to send PURGE requests.\";\n }\n\n return (lookup);\n }\n if (req.request != \"GET\" &&\n req.request != \"HEAD\" &&\n req.request != \"PUT\" &&\n req.request != \"POST\" &&\n req.request != \"TRACE\" &&\n req.request != \"OPTIONS\" &&\n req.request != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.url ~ \"^\/image.cgi\") {\n unset req.http.cookie;\n }\n if (req.url ~ \"^\/image\/\") {\n unset req.http.cookie;\n }\n if (req.http.Authorization || req.http.Cookie) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n return (lookup);\n }\n \n sub vcl_pipe {\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n # set req.http.connection = \"close\";\n # here. It is not set by default as it might break some broken web\n # applications, like IIS with NTLM authentication.\n set req.http.connection = \"close\";\n return (pipe);\n }\n \nsub vcl_pass {\n return (pass);\n}\n# \n# sub vcl_hash {\n# set req.hash += req.url;\n# if (req.http.host) {\n# set req.hash += req.http.host;\n# } else {\n# set req.hash += server.ip;\n# }\n# return (hash);\n# }\n \n sub vcl_hit {\n if (req.request == \"PURGE\") {\n set obj.ttl = 0s;\n error 200 \"Purged\";\n }\n return (deliver);\n }\n \n sub vcl_miss {\n if (req.request == \"PURGE\") {\n error 404 \"Not in cache\";\n }\n return (fetch);\n }\n \n sub vcl_fetch {\n# if (!beresp.cacheable) {\n# return (pass);\n# }\n if( (req.request == \"GET\" || req.request == \"HEAD\") && (req.url ~ \"^\/image.cgi\" || req.url ~ \"^\/image\/\") ) {\n set beresp.ttl = 7d;\n if(beresp.status == 404) {\n set beresp.ttl = 0s;\n }\n if(beresp.status >= 500) {\n set beresp.ttl = 0s;\n }\n return (deliver);\n }\n if (beresp.http.Set-Cookie) {\n return (pass);\n }\n }\n# \n# sub vcl_deliver {\n# return (deliver);\n# }\n# \n# sub vcl_error {\n# set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n# synthetic {\"\n# <?xml version=\"1.0\" encoding=\"utf-8\"?>\n# <!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n# \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n# <html>\n# <head>\n# <title>\"} obj.status \" \" obj.response {\"<\/title>\n# <\/head>\n# <body>\n# <h1>Error \"} obj.status \" \" obj.response {\"<\/h1>\n# <p>\"} obj.response {\"<\/p>\n# <h3>Guru Meditation:<\/h3>\n# <p>XID: \"} req.xid {\"<\/p>\n# <hr>\n# <p>Varnish cache server<\/p>\n# <\/body>\n# <\/html>\n# \"};\n# return (deliver);\n# }\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"66f283d1defdb62975d724ddc2ca02ef0ce395fc","subject":"Set the Host header in order to let Heroku's router know which app to route to (#1127)","message":"Set the Host header in order to let Heroku's router know which app to route to (#1127)\n\n* Switch host dependant upon location and is QA or PROD\r\n\r\n* Add Host header when debugging\r\n","repos":"jonathan-fielding\/polyfill-service,jonathan-fielding\/polyfill-service,JakeChampion\/polyfill-service,jonathan-fielding\/polyfill-service,kdzwinel\/polyfill-service,mcshaz\/polyfill-service,kdzwinel\/polyfill-service,JakeChampion\/polyfill-service,mcshaz\/polyfill-service,mcshaz\/polyfill-service,kdzwinel\/polyfill-service","old_file":"vcl\/main.vcl","new_file":"vcl\/main.vcl","new_contents":"import boltsort;\n\nsub vcl_recv {\n#FASTLY recv\n\n\t# Enable API key authentication for URL purge requests\n\tif ( req.request == \"FASTLYPURGE\" ) {\n\t\tset req.http.Fastly-Purge-Requires-Auth = \"1\";\n\t}\n\n\tif (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n\t\treturn(pass);\n\t}\n\n\tif (req.http.Host ~ \"polyfills.io\") {\n\t\t# Do the canonicalise check before the SSL check to avoid a double redirect\n\t\terror 751 \"Canonicalise\";\n\t}\n\n\tif (!req.http.Fastly-SSL) {\n\t\t# 801 is a special error code that Fastly uses to Force SSL on the request\n\t\terror 801 \"Redirect to prod HTTPS\";\n\t}\n\n\n\tif (req.url ~ \"^\/v2\/(polyfill\\.|recordRumData)\" && req.url !~ \"[\\?\\&]ua=\") {\n\t\tset req.http.X-Orig-URL = req.url;\n\t\tset req.url = \"\/v2\/normalizeUa?ua=\" urlencode(req.http.User-Agent);\n\t}\n\n\tif (req.url ~ \"^\/v2\/recordRumData\" && req.http.Normalized-User-Agent) {\n\t\tset req.http.Log = regsub(req.url, \"^.*?\\?(.*)$\", \"\\1\") \"&ip=\" client.ip \"&refer_domain=\" regsub(req.http.Referer, \"^(https?\\:\\\/\\\/)?(www\\.)?(.+?)(\\:\\d+)?([\\\/\\?].*)?$\", \"\\3\") \"&country=\" geoip.country_code \"&data_center=\" if(req.http.Cookie:FastlyDC, req.http.Cookie:FastlyDC, server.datacenter);\n\t\terror 204 \"No Content\";\n\t}\n\n\tset req.url = boltsort.sort(req.url);\n\n\tdeclare local var.isQA BOOL;\n\n\tset var.isQA = (req.http.host == \"qa.polyfill.io\");\n\n\tif (req.http.X-Geoip-Continent ~ \"(NA|SA|OC|AS)\") {\n\t\tset req.backend = origami_polyfill_service_us;\n\t\tset req.http.Host = \"ft-polyfill-service-us.herokuapp.com\";\n\n\t\tif (!req.backend.healthy) {\n\t\t\tset req.backend = origami_polyfill_service_eu;\n\t\t\tset req.http.Host = \"ft-polyfill-service.herokuapp.com\";\n\t\t}\n\n\t} else {\n\t\tset req.backend = origami_polyfill_service_eu;\n\t\tset req.http.Host = \"ft-polyfill-service.herokuapp.com\";\n\n\t\tif (!req.backend.healthy) {\n\t\t\tset req.backend = origami_polyfill_service_us;\n\t\t\tset req.http.Host = \"ft-polyfill-service-us.herokuapp.com\";\n\t\t}\n\t}\n\n\tif (var.isQA) {\n\t\tif (req.backend == origami_polyfill_service_us) {\n\t\t\tset req.http.Host = \"ft-polyfill-service-us-qa.herokuapp.com\";\n\t\t} else {\n\t\t\tset req.http.Host = \"ft-polyfill-service-qa.herokuapp.com\";\n\t\t}\n\t}\n\n\treturn(lookup);\n}\n\nsub vcl_deliver {\n#FASTLY deliver\n\n\t# If the response is to a normalise request and there's a parked \"original request\", use the normalised UA response to modify the original request and restart it\n\tif (req.url ~ \"^\/v\\d\/normalizeUa\" && resp.status == 200 && req.http.X-Orig-URL ~ \"^\/v2\/(polyfill\\.|recordRumData)\") {\n\t\tset req.http.Fastly-force-Shield = \"1\";\n\t\tset req.http.Normalized-User-Agent = resp.http.Normalized-User-Agent;\n\t\tif (req.http.X-Orig-URL ~ \"\\?\") {\n\t\t\tset req.url = req.http.X-Orig-URL \"&ua=\" resp.http.Normalized-User-Agent;\n\t\t} else {\n\t\t\tset req.url = req.http.X-Orig-URL \"?ua=\" resp.http.Normalized-User-Agent;\n\t\t}\n\t\trestart;\n\n\t# If the original request didn't specify a UA override, and we added one when the request was sent to the backend, the backend won't have included a Vary:user-agent header (correctly) but we need to add one\n\t} else if (req.url ~ \"^\/v\\d\/polyfill\\..*[\\?\\&]ua=\" && req.http.X-Orig-URL && req.http.X-Orig-URL !~ \"[\\?\\&]ua=\") {\n\t\tadd resp.http.Vary = \"User-Agent\";\n\t}\n\n\tif (req.url ~ \"[\\&\\?]rum=1\") {\n\t\tadd resp.http.Set-Cookie = \"FastlyDC=\" server.datacenter \"; Path=\/; HttpOnly; max-age=60\";\n\t}\n\n\tif (req.http.Fastly-Debug) {\n\t\tset resp.http.Debug-Host = req.http.Host;\n\t}\n\n\treturn(deliver);\n}\n\nsub vcl_error {\n#FASTLY error\n\n\t# Redirect to canonical prod\/qa origins\n\tif (obj.status == 751) {\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\tset obj.http.Location = \"https:\/\/polyfill.io\" req.url;\n\t\tsynthetic {\"\"};\n\t\treturn (deliver);\n\t}\n}\n","old_contents":"import boltsort;\n\nsub vcl_recv {\n#FASTLY recv\n\n\t# Enable API key authentication for URL purge requests\n\tif ( req.request == \"FASTLYPURGE\" ) {\n\t\tset req.http.Fastly-Purge-Requires-Auth = \"1\";\n\t}\n\n\tif (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n\t\treturn(pass);\n\t}\n\n\tif (req.http.Host ~ \"polyfills.io\") {\n\t\t# Do the canonicalise check before the SSL check to avoid a double redirect\n\t\terror 751 \"Canonicalise\";\n\t}\n\n\tif (!req.http.Fastly-SSL) {\n\t\t# 801 is a special error code that Fastly uses to Force SSL on the request\n\t\terror 801 \"Redirect to prod HTTPS\";\n\t}\n\n\n\tif (req.url ~ \"^\/v2\/(polyfill\\.|recordRumData)\" && req.url !~ \"[\\?\\&]ua=\") {\n\t\tset req.http.X-Orig-URL = req.url;\n\t\tset req.url = \"\/v2\/normalizeUa?ua=\" urlencode(req.http.User-Agent);\n\t}\n\n\tif (req.url ~ \"^\/v2\/recordRumData\" && req.http.Normalized-User-Agent) {\n\t\tset req.http.Log = regsub(req.url, \"^.*?\\?(.*)$\", \"\\1\") \"&ip=\" client.ip \"&refer_domain=\" regsub(req.http.Referer, \"^(https?\\:\\\/\\\/)?(www\\.)?(.+?)(\\:\\d+)?([\\\/\\?].*)?$\", \"\\3\") \"&country=\" geoip.country_code \"&data_center=\" if(req.http.Cookie:FastlyDC, req.http.Cookie:FastlyDC, server.datacenter);\n\t\terror 204 \"No Content\";\n\t}\n\n\tset req.url = boltsort.sort(req.url);\n\n\n\tif (req.http.X-Geoip-Continent ~ \"(NA|SA|OC|AS)\") {\n\t\tset req.backend = origami_polyfill_service_us;\n\n\t\tif (!req.backend.healthy) {\n\t\t\tset req.backend = origami_polyfill_service_eu;\n\t\t}\n\n\t} else {\n\t\tset req.backend = origami_polyfill_service_eu;\n\n\t\tif (!req.backend.healthy) {\n\t\t\tset req.backend = origami_polyfill_service_us;\n\t\t}\n\t}\n\n\treturn(lookup);\n}\n\nsub vcl_deliver {\n#FASTLY deliver\n\n\t# If the response is to a normalise request and there's a parked \"original request\", use the normalised UA response to modify the original request and restart it\n\tif (req.url ~ \"^\/v\\d\/normalizeUa\" && resp.status == 200 && req.http.X-Orig-URL ~ \"^\/v2\/(polyfill\\.|recordRumData)\") {\n\t\tset req.http.Fastly-force-Shield = \"1\";\n\t\tset req.http.Normalized-User-Agent = resp.http.Normalized-User-Agent;\n\t\tif (req.http.X-Orig-URL ~ \"\\?\") {\n\t\t\tset req.url = req.http.X-Orig-URL \"&ua=\" resp.http.Normalized-User-Agent;\n\t\t} else {\n\t\t\tset req.url = req.http.X-Orig-URL \"?ua=\" resp.http.Normalized-User-Agent;\n\t\t}\n\t\trestart;\n\n\t# If the original request didn't specify a UA override, and we added one when the request was sent to the backend, the backend won't have included a Vary:user-agent header (correctly) but we need to add one\n\t} else if (req.url ~ \"^\/v\\d\/polyfill\\..*[\\?\\&]ua=\" && req.http.X-Orig-URL && req.http.X-Orig-URL !~ \"[\\?\\&]ua=\") {\n\t\tadd resp.http.Vary = \"User-Agent\";\n\t}\n\n\tif (req.url ~ \"[\\&\\?]rum=1\") {\n\t\tadd resp.http.Set-Cookie = \"FastlyDC=\" server.datacenter \"; Path=\/; HttpOnly; max-age=60\";\n\t}\n\n\treturn(deliver);\n}\n\nsub vcl_error {\n#FASTLY error\n\n\t# Redirect to canonical prod\/qa origins\n\tif (obj.status == 751) {\n\t\tset obj.status = 301;\n\t\tset obj.response = \"Moved Permanently\";\n\t\tset obj.http.Location = \"https:\/\/polyfill.io\" req.url;\n\t\tsynthetic {\"\"};\n\t\treturn (deliver);\n\t}\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"524f291dc55510a82c754bd793f8becf0d0a292b","subject":"Fix inability to purge by URL from the Fastly UI","message":"Fix inability to purge by URL from the Fastly UI\n","repos":"fastly\/fastly-magento,fastly\/fastly-magento,fastly\/fastly-magento,fastly\/fastly-magento","old_file":"app\/code\/community\/Fastly\/CDN\/etc\/vcl_snippets\/recv.vcl","new_file":"app\/code\/community\/Fastly\/CDN\/etc\/vcl_snippets\/recv.vcl","new_contents":" # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n # Pass any checkout, cart or customer\/myaccount urls\n if (req.url.path ~ \"\/(cart|checkout|customer)\") {\n set req.http.x-pass = \"1\";\n # Pass all admin actions\n } else if (req.url.path ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\") {\n set req.http.x-pass = \"1\";\n # bypass language switcher\n } else if (req.url.qs ~ \"(?i)___from_store=.*&___store=.*\") {\n set req.http.x-pass = \"1\";\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (req.http.cookie:FASTLY_CDN_ENV) {\n set req.http.Fastly-Cdn-Env = req.http.cookie:FASTLY_CDN_ENV;\n } else {\n unset req.http.Fastly-Cdn-Env;\n }\n\n ############################################################################################################\n # Following code block controls purge by URL. By default we want to protect all URL purges. In general this\n # is addressed by adding Fastly-Purge-Requires-Auth request header in vcl_recv however this runs the risk of\n # exposing API tokens if user attempts to purge non-https URLs. For this reason inside the Magento module\n # we use X-Purge-Token. Unfortunately this breaks purge from the Fastly UI. Therefore in the next code block\n # we check for presence of X-Purge-Token. If it's not present we force the Fastly-Purge-Requires-Auth\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n if (req.http.X-Purge-Token && req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n }\n\n } else {\n set req.http.Fastly-Purge-Requires-Auth = \"1\";\n }\n }\n\n # disable ESI processing on Origin Shield\n if (req.http.Fastly-FF) {\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url.path ~ \"^\/(media|js|skin)\/.*\\.(png|jpg|jpeg|gif|css|js|swf|ico|webp|svg)$\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n # formkey lookup\n if (req.url.path ~ \"\/fastlycdn\/getformkey\/\") {\n # check if we have a formkey cookie\n if (req.http.Cookie:FASTLY_CDN_FORMKEY) {\n set req.http.Formkey = req.http.Cookie:FASTLY_CDN_FORMKEY;\n } else {\n # create formkey\n set req.http.seed = req.http.Cookie client.ip remote.port client.geo.longitude client.geo.latitude client.geo.postal_code;\n set req.http.Formkey = regsub(digest.hash_md5(req.http.seed), \"^0x\", \"\");\n }\n error 760 req.http.Formkey;\n }\n\n # client.geo lookup\n if (req.url.path ~ \"fastlycdn\/esi\/getcountry\/\") {\n # check if GeoIP has been already processed by client\n if (req.http.Cookie:FASTLY_CDN_GEOIP_PROCESSED) {\n error 200 \"\";\n } else {\n # modify req.url and restart request processing\n error 750 client.geo.country_code;\n }\n }\n\n # client.geo get country code\n if (req.url.path ~ \"fastlycdn\/esi\/getcountrycode\/\") {\n # create and set req.http.X-Country-Code\n error 755 client.geo.country_code;\n }\n\n # check for ESI calls\n if (req.url.qs ~ \"esi_data=\") {\n # check for valid cookie data\n if (req.http.Cookie ~ \"FASTLY_CDN-([A-Za-z0-9-_]+)=([^;]*)\") {\n set req.url = querystring.filter(req.url, \"esi_data\") + \"&esi_data=\" + re.group.2;\n }\n }\n\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking\n set req.http.Magento-Original-URL = req.url;\n set req.url = querystring.regfilter(req.url, \"^(####QUERY_PARAMETERS####)\");\n # Sort the query arguments to increase cache hit ratio with query arguments that\n # may be out of order however only on URLs that are not being passed. \n if ( !req.http.x-pass ) {\n set req.url = boltsort.sort(req.url);\n }\n","old_contents":" # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n # Pass any checkout, cart or customer\/myaccount urls\n if (req.url.path ~ \"\/(cart|checkout|customer)\") {\n set req.http.x-pass = \"1\";\n # Pass all admin actions\n } else if (req.url.path ~ \"^\/(index\\.php\/)?####ADMIN_PATH####(_.*)?\/\") {\n set req.http.x-pass = \"1\";\n # bypass language switcher\n } else if (req.url.qs ~ \"(?i)___from_store=.*&___store=.*\") {\n set req.http.x-pass = \"1\";\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (req.http.cookie:FASTLY_CDN_ENV) {\n set req.http.Fastly-Cdn-Env = req.http.cookie:FASTLY_CDN_ENV;\n } else {\n unset req.http.Fastly-Cdn-Env;\n }\n\n # auth for purging\n if (req.request == \"FASTLYPURGE\") {\n\n if (!req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n error 403;\n }\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n\n } else {\n error 403;\n }\n\n }\n\n # disable ESI processing on Origin Shield\n if (req.http.Fastly-FF) {\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url.path ~ \"^\/(media|js|skin)\/.*\\.(png|jpg|jpeg|gif|css|js|swf|ico|webp|svg)$\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n # formkey lookup\n if (req.url.path ~ \"\/fastlycdn\/getformkey\/\") {\n # check if we have a formkey cookie\n if (req.http.Cookie:FASTLY_CDN_FORMKEY) {\n set req.http.Formkey = req.http.Cookie:FASTLY_CDN_FORMKEY;\n } else {\n # create formkey\n set req.http.seed = req.http.Cookie client.ip remote.port client.geo.longitude client.geo.latitude client.geo.postal_code;\n set req.http.Formkey = regsub(digest.hash_md5(req.http.seed), \"^0x\", \"\");\n }\n error 760 req.http.Formkey;\n }\n\n # client.geo lookup\n if (req.url.path ~ \"fastlycdn\/esi\/getcountry\/\") {\n # check if GeoIP has been already processed by client\n if (req.http.Cookie:FASTLY_CDN_GEOIP_PROCESSED) {\n error 200 \"\";\n } else {\n # modify req.url and restart request processing\n error 750 client.geo.country_code;\n }\n }\n\n # client.geo get country code\n if (req.url.path ~ \"fastlycdn\/esi\/getcountrycode\/\") {\n # create and set req.http.X-Country-Code\n error 755 client.geo.country_code;\n }\n\n # check for ESI calls\n if (req.url.qs ~ \"esi_data=\") {\n # check for valid cookie data\n if (req.http.Cookie ~ \"FASTLY_CDN-([A-Za-z0-9-_]+)=([^;]*)\") {\n set req.url = querystring.filter(req.url, \"esi_data\") + \"&esi_data=\" + re.group.2;\n }\n }\n\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking\n set req.http.Magento-Original-URL = req.url;\n set req.url = querystring.regfilter(req.url, \"^(####QUERY_PARAMETERS####)\");\n # Sort the query arguments to increase cache hit ratio with query arguments that\n # may be out of order however only on URLs that are not being passed. \n if ( !req.http.x-pass ) {\n set req.url = boltsort.sort(req.url);\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"8e138d6026d2544fb8cdad8f8cecd81a54dbdbd7","subject":"Don't reference the old TRAC wiki in example.vcl","message":"Don't reference the old TRAC wiki in example.vcl\n\nRefs #2948\n","repos":"gquintard\/Varnish-Cache,gquintard\/Varnish-Cache,gquintard\/Varnish-Cache,gquintard\/Varnish-Cache","old_file":"etc\/example.vcl","new_file":"etc\/example.vcl","new_contents":"#\n# This is an example VCL file for Varnish.\n#\n# It does not do anything by default, delegating control to the\n# builtin VCL. The builtin VCL is called when there is no explicit\n# return statement.\n#\n# See the VCL chapters in the Users Guide for a comprehensive documentation\n# at https:\/\/www.varnish-cache.org\/docs\/.\n\n# Marker to tell the VCL compiler that this VCL has been written with the\n# 4.0 or 4.1 syntax.\nvcl 4.1;\n\n# Default backend definition. Set this to point to your content server.\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\n\nsub vcl_recv {\n # Happens before we check if we have this in cache already.\n #\n # Typically you clean up the request here, removing cookies you don't need,\n # rewriting the request, etc.\n}\n\nsub vcl_backend_response {\n # Happens after we have read the response headers from the backend.\n #\n # Here you clean the response headers, removing silly Set-Cookie headers\n # and other mistakes your backend does.\n}\n\nsub vcl_deliver {\n # Happens when we have all the pieces we need, and are about to send the\n # response to the client.\n #\n # You can do accounting or modifying the final object here.\n}\n","old_contents":"#\n# This is an example VCL file for Varnish.\n#\n# It does not do anything by default, delegating control to the\n# builtin VCL. The builtin VCL is called when there is no explicit\n# return statement.\n#\n# See the VCL chapters in the Users Guide at https:\/\/www.varnish-cache.org\/docs\/\n# and https:\/\/www.varnish-cache.org\/trac\/wiki\/VCLExamples for more examples.\n\n# Marker to tell the VCL compiler that this VCL has been adapted to the\n# 4.0 or 4.1 syntax.\nvcl 4.1;\n\n# Default backend definition. Set this to point to your content server.\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\n\nsub vcl_recv {\n # Happens before we check if we have this in cache already.\n #\n # Typically you clean up the request here, removing cookies you don't need,\n # rewriting the request, etc.\n}\n\nsub vcl_backend_response {\n # Happens after we have read the response headers from the backend.\n #\n # Here you clean the response headers, removing silly Set-Cookie headers\n # and other mistakes your backend does.\n}\n\nsub vcl_deliver {\n # Happens when we have all the pieces we need, and are about to send the\n # response to the client.\n #\n # You can do accounting or modifying the final object here.\n}\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"VCL"} {"commit":"698e83ce9b941e989220c448c6a61a7e53d44d00","subject":"Formatting change.","message":"Formatting change.\n","repos":"telusdigital\/ansible-varnish,killerwails\/ansible-varnish,killerwails\/ansible-varnish,colstrom\/ansible-varnish","old_file":"templates\/etc\/varnish\/default.vcl","new_file":"templates\/etc\/varnish\/default.vcl","new_contents":"vcl 4.0;\n\n# {{ ansible_managed }}\n\nimport directors;\nimport std;\n\n###\n# Varnish Documentation\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-built-in-subs.html\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/reference\/vcl.html\n##\n\n{% for backend in varnish_backend_hosts %}\nbackend application_{{ loop.index }} {\n .host = \"{{ backend }}\";\n .port = \"{{ varnish_backend_port }}\";\n{% if varnish_health_checks_enabled %}\n .probe = {\n .url = \"{{ varnish_health_check_url }}\";\n .interval = {{ varnish_health_check_interval }};\n .timeout = {{ varnish_health_check_timeout }};\n .window = {{ varnish_health_check_window }};\n .threshold = {{ varnish_health_check_threshold }};\n }\n{% endif %}\n}\n{% endfor %}\n\n###\n# vcl_init\n# Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n###\n# The vcl_init subroutine may terminate with calling return() with one of the following keywords:\n#\n# ok\n# Normal return, VCL continues loading.\n##\n\nsub vcl_init {\n new application = directors.round_robin();\n{% for backend in varnish_backend_hosts %}\n application.add_backend(application_{{ loop.index }});\n{% endfor %}\n}\n\n###\n# vcl_recv\n# Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use.\n# It is also used to modify the request\n###\n# The vcl_recv subroutine may terminate with calling return() on one of the following keywords:\n#\n# synth(status code, reason)\n# Return a synthetic object with the specified status code to the client and abandon the request.\n# pass\n# Switch to pass mode. Control will eventually pass to vcl_pass.\n# pipe\n# Switch to pipe mode. Control will eventually pass to vcl_pipe.\n# hash\n# Continue processing the object as a potential candidate for caching. Passes the control over to vcl_hash.\n# purge\n# Purge the object and it's variants. Control passes through vcl_hash to vcl_purge.\n#\n\nsub vcl_recv {\n set req.backend_hint = application.backend();\n\n ###\n # Avoid processing uncacheable requests\n ###\n\n if (req.http.Authorization) {\n set req.http.X-Passthrough-Reason = \"No Caching Authenticated Content\";\n return (pass);\n }\n\n{% if varnish_uri_blacklist_enabled %}\n if ((req.url ~ \"{{ varnish_uri_blacklist_regexp }}\")) {\n set req.http.X-Passthrough-Reason = \"Path in Blacklist\";\n return(pass);\n }\n{% endif %}\n\n{% if varnish_diagnostic_headers_forwarded_for %}\n ###\n # Inject X-Forwarded-For headers, but only once.\n ###\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_enabled %}\n ###\n # Cookie Sanitization\n ###\n if (req.http.Cookie) {\n set req.http.X-Cookie-Unmodified = req.http.Cookie;\n\n {% for cookie in varnish_cookie_sanitization_blacklist %}\n# set req.http.Cookie = regsuball(req.http.Cookie, \"{{ cookie }}=[^;]+(; )?\", \"\");\n {% endfor %}\n\n ### General Cleanup\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n if (req.http.Cookie ~ \"^\\s*$\") {\n set req.http.X-Cookie-Discarded = \"YES:Empty\";\n unset req.http.Cookie;\n }\n if (req.http.Cookie) {\n set req.http.X-Cookie-Sanitized = req.http.Cookie;\n }\n }\n{% endif %}\n\n{% if varnish_header_sanitization_enabled %}\n ###\n # Header Sanitization\n ###\n\n{% if varnish_header_sanitization_discard_host_port %}\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n{% endif %}\n\n{% if varnish_header_sanitization_normalize_accept_encoding %}\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n{% endif %}\n\n{% endif %}\n\n{% if varnish_uri_sanitization_enabled %}\n ###\n # URI Sanitization\n ###\n\n if (req.url ~ \"(\\?|&){{ varnish_uri_sanitization_regexp }}=\") {\n set req.url = regsuball(req.url, \"&{{ varnish_uri_sanitization_regexp }}=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?{{ varnish_uri_sanitization_regexp }}=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n{% endif %}\n\n{% if varnish_workaround_telusdotcom_browser_profile %}\n ###\n # Workaround and Diagnostics for BrowserProfile and Language\/Region Detection on TELUS.com\n ###\n\n if (req.http.Cookie ~ \"BrowserProfile\") {\n set req.http.X-BrowserProfile = regsuball(req.http.Cookie, \"(.*)BrowserProfile=([^;]*)(.*)\", \"\\2\");\n if (req.http.X-BrowserProfile ~ \"language\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.X-BrowserProfile, \"(.*)language\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n set req.http.X-Language-Found = \"YES:BrowserProfile\";\n }\n if (req.http.X-BrowserProfile ~ \"region\") {\n set req.http.X-Region = std.tolower(regsuball(regsuball(req.http.X-BrowserProfile, \"geo\\\\.\\:{(.*)\\}\", \"\"), \"(.*)region\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n set req.http.X-Region-Found = \"YES:BrowserProfile\";\n }\n if (req.http.X-BrowserProfile ~ \"geo\") {\n set req.http.X-Geolocation = regsuball(req.http.X-BrowserProfile, \"(.*)geo..:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n set req.http.X-Geolocation-Found = \"YES:BrowserProfile\";\n\n if (req.http.X-Geolocation ~ \"country\") {\n set req.http.X-Geolocation-Country = regsuball(req.http.X-Geolocation, \"(.*)country\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-Geolocation ~ \"region\") {\n set req.http.X-Geolocation-Region = regsuball(req.http.X-Geolocation, \"(.*)region\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-Geolocation ~ \"city\") {\n set req.http.X-Geolocation-City = regsuball(req.http.X-Geolocation, \"(.*)city\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-Geolocation ~ \"isp\") {\n set req.http.X-Geolocation-ISP = regsuball(req.http.X-Geolocation, \"(.*)isp\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n } else {\n set req.http.X-Geolocation-Found = \"NO\";\n }\n }\n\n if (!req.http.X-Language) {\n if (req.http.Cookie ~ \"lang=\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.Cookie, \"(.*)lang=([^;]*)(.*)\", \"\\2\"));\n set req.http.X-Language-Found = \"YES:lang\";\n } else {\n set req.http.X-Language = \"en\";\n set req.http.X-Language-Found = \"NO\";\n }\n }\n\n if (!req.http.X-Region) {\n if (req.http.Cookie ~ \"prov=\") {\n set req.http.X-Region = std.tolower(regsuball(req.http.Cookie, \"(.*)prov=([^;]*)(.*)\", \"\\2\"));\n set req.http.X-Region-Found = \"YES:prov\";\n } else {\n set req.http.X-Region = \"bc\";\n set req.http.X-Region-Found = \"NO\";\n }\n }\n\n\n if (req.url ~ \"\/(en|fr)\/\") {\n if (req.url ~ \"\/en\/\" && req.http.X-Language != \"en\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Language (Path: \/en\/) vs (Cookie: \" + req.http.X-Language + \")\";\n return(pass);\n }\n if (req.url ~ \"\/fr\/\" && req.http.X-Language != \"fr\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Language (Path: \/fr\/) vs (Cookie: \" + req.http.X-Language + \")\";\n return(pass);\n }\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Language)\";\n return(pass);\n }\n\n if (req.url ~ \"\/(ab|bc|mb|nb|nl|ns|nt|nu|on|pe|qc|sk|yt)\/\") {\n {% for province in ['ab', 'bc', 'mb', 'nb', 'nl', 'ns', 'nt', 'nu', 'on', 'pe', 'qc', 'sk', 'yt'] %}\n if (req.url ~ \"\/{{ province }}\/\" && req.http.X-Region != \"{{ province }}\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Region (Path: \/{{ province }}\/) vs (Cookie: \" + req.http.X-Region + \")\";\n return(pass);\n }\n {% endfor %}\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Province)\";\n return(pass);\n }\n\n if (req.http.Cookie) {\n if (req.http.Cookie ~ \"resolution\") {\n set req.http.X-Screen-Resolution = regsuball(req.http.Cookie, \"(.*)resolution=([^;]*)(.*)\", \"\\2\");\n }\n\n if (req.http.Cookie ~ \"CustomerType\") {\n set req.http.X-Customer-Type = regsuball(req.http.Cookie, \"(.*)CustomerType=([^;]*)(.*)\", \"\\2\");\n }\n if (req.http.Cookie ~ \"outdated-browser-notification\") {\n set req.http.X-Outdated-Browser = regsuball(req.http.Cookie, \"(.*)outdated-browser-notification=([^;]*)(.*)\", \"\\2\");\n }\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_discard_from_client %}\n set req.http.X-Cookie-Discarded = \"YES:No Reason Not To\";\n unset req.http.Cookie;\n{% endif %}\n}\n\n###\n# vcl_hit\n# Called when a cache lookup is successful.\n###\n# The vcl_hit subroutine may terminate with calling return() with one of the following keywords:\n#\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n# deliver\n# Deliver the object. Control passes to vcl_deliver.\n# synth(status code, reason)\n# Return the specified status code to the client and abandon the request.\n###\n\nsub vcl_hit {\n if (obj.ttl > 0s) {\n return (deliver);\n }\n{% if varnish_health_checks_enabled %}\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (fetch);\n }\n{% else %}\n if (obj.ttl + obj.grace > 0s) {\n return (deliver);\n }\n\n return (fetch);\n{% endif %}\n}\n\n###\n# vcl_backend_response\n# Called after the response headers has been successfully retrieved from the backend.\n###\n# The vcl_backend_response subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Possibly insert the object into the cache, then deliver it to the Control will eventually pass to vcl_deliver.\n# abandon\n# Abandon the backend request and generates an error.\n# retry\n# Retry the backend transaction. Increases the retries counter. If the number of retries is higher than max_retries Varnish emits a guru meditation error.\n###\n\nsub vcl_backend_response {\n{% if varnish_workaround_telusdotcom_browser_profile %}\n if (bereq.http.X-Language) {\n set beresp.http.X-Language = bereq.http.X-Language;\n# if (bereq.http.X-Language-Found) {\n# set beresp.http.X-Language-Found = bereq.http.X-Language-Found;\n# }\n }\n if (bereq.http.X-Region) {\n set beresp.http.X-Region = bereq.http.X-Region;\n# if (bereq.http.X-Region-Found) {\n# set beresp.http.X-Region-Found = bereq.http.X-Region-Found;\n# }\n }\n{% endif %}\n\n{% if varnish_uri_blacklist_enabled %}\n if (bereq.url ~ \"{{ varnish_uri_blacklist_regexp }}\") {\n set beresp.http.X-Cacheable = \"NO:Path in Blacklist\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n if (bereq.http.X-Passthrough-Reason) {\n{% if varnish_diagnostic_headers_passthrough_reason %}\n set beresp.http.X-Passthrough-Reason = bereq.http.X-Passthrough-Reason;\n{% endif %}\n return(deliver);\n } else {\n{% if varnish_cookie_sanitization_discard_from_server %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n }\n }\n{% else %}\n{% if varnish_cookie_sanitization_discard_from_server %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n{% endif %}\n\n{% if varnish_diagnostic_headers_enabled %}\n if (bereq.http.Cookie) {\n set beresp.http.X-Cacheable = \"NO:Cookie in Request\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO:Set-Cookie in Response\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.X-No-Cache) {\n set beresp.http.X-Cacheable = \"NO:X-No-Cache\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.ttl <= 0s) {\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n{% endif %}\n\n set beresp.grace = {{ varnish_grace_period }};\n}\n\n###\n# vcl_deliver\n# Called before a cached object is delivered to the client.\n###\n# The vcl_deliver subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Deliver the object to the client.\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n###\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n","old_contents":"vcl 4.0;\n\n# {{ ansible_managed }}\n\nimport directors;\nimport std;\n\n###\n# Varnish Documentation\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-built-in-subs.html\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/reference\/vcl.html\n##\n\n{% for backend in varnish_backend_hosts %}\nbackend application_{{ loop.index }} {\n .host = \"{{ backend }}\";\n .port = \"{{ varnish_backend_port }}\";\n{% if varnish_health_checks_enabled %}\n .probe = {\n .url = \"{{ varnish_health_check_url }}\";\n .interval = {{ varnish_health_check_interval }};\n .timeout = {{ varnish_health_check_timeout }};\n .window = {{ varnish_health_check_window }};\n .threshold = {{ varnish_health_check_threshold }};\n }\n{% endif %}\n}\n{% endfor %}\n\n###\n# vcl_init\n# Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n###\n# The vcl_init subroutine may terminate with calling return() with one of the following keywords:\n#\n# ok\n# Normal return, VCL continues loading.\n##\n\nsub vcl_init {\n new application = directors.round_robin();\n{% for backend in varnish_backend_hosts %}\n application.add_backend(application_{{ loop.index }});\n{% endfor %}\n}\n\n###\n# vcl_recv\n# Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use. \n# It is also used to modify the request\n###\n# The vcl_recv subroutine may terminate with calling return() on one of the following keywords:\n#\n# synth(status code, reason)\n# Return a synthetic object with the specified status code to the client and abandon the request.\n# pass\n# Switch to pass mode. Control will eventually pass to vcl_pass.\n# pipe\n# Switch to pipe mode. Control will eventually pass to vcl_pipe.\n# hash\n# Continue processing the object as a potential candidate for caching. Passes the control over to vcl_hash.\n# purge\n# Purge the object and it's variants. Control passes through vcl_hash to vcl_purge.\n#\n\nsub vcl_recv {\n set req.backend_hint = application.backend();\n\n ###\n # Avoid processing uncacheable requests\n ###\n\n if (req.http.Authorization) {\n set req.http.X-Passthrough-Reason = \"No Caching Authenticated Content\";\n return (pass);\n }\n\n{% if varnish_uri_blacklist_enabled %}\n if ((req.url ~ \"{{ varnish_uri_blacklist_regexp }}\")) {\n set req.http.X-Passthrough-Reason = \"Path in Blacklist\";\n return(pass);\n }\n{% endif %}\n\n{% if varnish_diagnostic_headers_forwarded_for %}\n ###\n # Inject X-Forwarded-For headers, but only once.\n ###\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_enabled %}\n ###\n # Cookie Sanitization\n ###\n if (req.http.Cookie) {\n set req.http.X-Cookie-Unmodified = req.http.Cookie;\n\n {% for cookie in varnish_cookie_sanitization_blacklist %}\n# set req.http.Cookie = regsuball(req.http.Cookie, \"{{ cookie }}=[^;]+(; )?\", \"\");\n {% endfor %}\n\n ### General Cleanup\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n if (req.http.Cookie ~ \"^\\s*$\") {\n set req.http.X-Cookie-Discarded = \"YES:Empty\";\n unset req.http.Cookie;\n }\n if (req.http.Cookie) {\n set req.http.X-Cookie-Sanitized = req.http.Cookie;\n }\n }\n{% endif %}\n\n{% if varnish_header_sanitization_enabled %}\n ###\n # Header Sanitization\n ###\n\n{% if varnish_header_sanitization_discard_host_port %}\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n{% endif %}\n\n{% if varnish_header_sanitization_normalize_accept_encoding %}\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n{% endif %}\n\n{% endif %}\n\n{% if varnish_uri_sanitization_enabled %}\n ###\n # URI Sanitization\n ###\n \n if (req.url ~ \"(\\?|&){{ varnish_uri_sanitization_regexp }}=\") {\n set req.url = regsuball(req.url, \"&{{ varnish_uri_sanitization_regexp }}=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?{{ varnish_uri_sanitization_regexp }}=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n{% endif %}\n\n{% if varnish_workaround_telusdotcom_browser_profile %}\n ###\n # Workaround and Diagnostics for BrowserProfile and Language\/Region Detection on TELUS.com\n ###\n\n if (req.http.Cookie ~ \"BrowserProfile\") {\n set req.http.X-BrowserProfile = regsuball(req.http.Cookie, \"(.*)BrowserProfile=([^;]*)(.*)\", \"\\2\");\n if (req.http.X-BrowserProfile ~ \"language\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.X-BrowserProfile, \"(.*)language\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n set req.http.X-Language-Found = \"YES:BrowserProfile\";\n }\n if (req.http.X-BrowserProfile ~ \"region\") {\n set req.http.X-Region = std.tolower(regsuball(regsuball(req.http.X-BrowserProfile, \"geo\\\\.\\:{(.*)\\}\", \"\"), \"(.*)region\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n set req.http.X-Region-Found = \"YES:BrowserProfile\";\n }\n if (req.http.X-BrowserProfile ~ \"geo\") {\n set req.http.X-Geolocation = regsuball(req.http.X-BrowserProfile, \"(.*)geo..:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n set req.http.X-Geolocation-Found = \"YES:BrowserProfile\";\n\n if (req.http.X-Geolocation ~ \"country\") {\n set req.http.X-Geolocation-Country = regsuball(req.http.X-Geolocation, \"(.*)country\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-Geolocation ~ \"region\") {\n set req.http.X-Geolocation-Region = regsuball(req.http.X-Geolocation, \"(.*)region\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-Geolocation ~ \"city\") {\n set req.http.X-Geolocation-City = regsuball(req.http.X-Geolocation, \"(.*)city\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-Geolocation ~ \"isp\") {\n set req.http.X-Geolocation-ISP = regsuball(req.http.X-Geolocation, \"(.*)isp\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n } else {\n set req.http.X-Geolocation-Found = \"NO\";\n }\n }\n\n if (!req.http.X-Language) {\n if (req.http.Cookie ~ \"lang=\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.Cookie, \"(.*)lang=([^;]*)(.*)\", \"\\2\"));\n set req.http.X-Language-Found = \"YES:lang\";\n } else {\n set req.http.X-Language = \"en\";\n set req.http.X-Language-Found = \"NO\";\n }\n }\n\n if (!req.http.X-Region) {\n if (req.http.Cookie ~ \"prov=\") {\n set req.http.X-Region = std.tolower(regsuball(req.http.Cookie, \"(.*)prov=([^;]*)(.*)\", \"\\2\"));\n set req.http.X-Region-Found = \"YES:prov\";\n } else {\n set req.http.X-Region = \"bc\";\n set req.http.X-Region-Found = \"NO\";\n }\n }\n\n\n if (req.url ~ \"\/(en|fr)\/\") {\n if (req.url ~ \"\/en\/\" && req.http.X-Language != \"en\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Language (Path: \/en\/) vs (Cookie: \" + req.http.X-Language + \")\";\n return(pass);\n }\n if (req.url ~ \"\/fr\/\" && req.http.X-Language != \"fr\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Language (Path: \/fr\/) vs (Cookie: \" + req.http.X-Language + \")\";\n return(pass);\n }\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Language)\";\n return(pass);\n }\n\n if (req.url ~ \"\/(ab|bc|mb|nb|nl|ns|nt|nu|on|pe|qc|sk|yt)\/\") {\n {% for province in ['ab', 'bc', 'mb', 'nb', 'nl', 'ns', 'nt', 'nu', 'on', 'pe', 'qc', 'sk', 'yt'] %}\n if (req.url ~ \"\/{{ province }}\/\" && req.http.X-Region != \"{{ province }}\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Region (Path: \/{{ province }}\/) vs (Cookie: \" + req.http.X-Region + \")\";\n return(pass);\n }\n {% endfor %}\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Province)\";\n return(pass);\n }\n\n if (req.http.Cookie) {\n if (req.http.Cookie ~ \"resolution\") {\n set req.http.X-Screen-Resolution = regsuball(req.http.Cookie, \"(.*)resolution=([^;]*)(.*)\", \"\\2\");\n }\n\n if (req.http.Cookie ~ \"CustomerType\") {\n set req.http.X-Customer-Type = regsuball(req.http.Cookie, \"(.*)CustomerType=([^;]*)(.*)\", \"\\2\");\n }\n if (req.http.Cookie ~ \"outdated-browser-notification\") {\n set req.http.X-Outdated-Browser = regsuball(req.http.Cookie, \"(.*)outdated-browser-notification=([^;]*)(.*)\", \"\\2\");\n }\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_discard_from_client %}\n set req.http.X-Cookie-Discarded = \"YES:No Reason Not To\";\n unset req.http.Cookie;\n{% endif %}\n}\n\n###\n# vcl_hit\n# Called when a cache lookup is successful.\n###\n# The vcl_hit subroutine may terminate with calling return() with one of the following keywords:\n#\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n# deliver\n# Deliver the object. Control passes to vcl_deliver.\n# synth(status code, reason)\n# Return the specified status code to the client and abandon the request.\n###\n\nsub vcl_hit {\n if (obj.ttl > 0s) {\n return (deliver);\n }\n{% if varnish_health_checks_enabled %}\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (fetch);\n }\n{% else %}\n if (obj.ttl + obj.grace > 0s) {\n return (deliver);\n }\n\n return (fetch);\n{% endif %}\n}\n\n###\n# vcl_backend_response\n# Called after the response headers has been successfully retrieved from the backend.\n###\n# The vcl_backend_response subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Possibly insert the object into the cache, then deliver it to the Control will eventually pass to vcl_deliver.\n# abandon\n# Abandon the backend request and generates an error.\n# retry\n# Retry the backend transaction. Increases the retries counter. If the number of retries is higher than max_retries Varnish emits a guru meditation error.\n###\n\nsub vcl_backend_response {\n{% if varnish_workaround_telusdotcom_browser_profile %}\n if (bereq.http.X-Language) {\n set beresp.http.X-Language = bereq.http.X-Language;\n# if (bereq.http.X-Language-Found) {\n# set beresp.http.X-Language-Found = bereq.http.X-Language-Found;\n# }\n }\n if (bereq.http.X-Region) {\n set beresp.http.X-Region = bereq.http.X-Region;\n# if (bereq.http.X-Region-Found) {\n# set beresp.http.X-Region-Found = bereq.http.X-Region-Found;\n# }\n }\n{% endif %}\n\n{% if varnish_uri_blacklist_enabled %}\n if (bereq.url ~ \"{{ varnish_uri_blacklist_regexp }}\") {\n set beresp.http.X-Cacheable = \"NO:Path in Blacklist\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n if (bereq.http.X-Passthrough-Reason) {\n{% if varnish_diagnostic_headers_passthrough_reason %}\n set beresp.http.X-Passthrough-Reason = bereq.http.X-Passthrough-Reason;\n{% endif %}\n return(deliver);\n } else {\n{% if varnish_cookie_sanitization_discard_from_server %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n }\n }\n{% else %}\n{% if varnish_cookie_sanitization_discard_from_server %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n{% endif %}\n\n{% if varnish_diagnostic_headers_enabled %}\n if (bereq.http.Cookie) {\n set beresp.http.X-Cacheable = \"NO:Cookie in Request\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO:Set-Cookie in Response\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.X-No-Cache) {\n set beresp.http.X-Cacheable = \"NO:X-No-Cache\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.ttl <= 0s) {\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n{% endif %}\n\n set beresp.grace = {{ varnish_grace_period }};\n}\n\n###\n# vcl_deliver\n# Called before a cached object is delivered to the client.\n###\n# The vcl_deliver subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Deliver the object to the client.\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n###\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"ca1c335555ece3be5b3663361b1df824c2358b1b","subject":"re #120 - Update VCL description","message":"re #120 - Update VCL description\n","repos":"gokuale\/joomla-vagrant,gokuale\/joomla-vagrant,gokuale\/joomla-vagrant,joomlatools\/joomla-vagrant,Fabrik\/joomla-vagrant,joomlatools\/joomlatools-vagrant,Fabrik\/joomla-vagrant,Fabrik\/joomla-vagrant,joomlatools\/joomlatools-vagrant,joomlatools\/joomla-vagrant,joomlatools\/joomla-vagrant,joomlatools\/joomlatools-vagrant,joomlatools\/joomla-vagrant,gokuale\/joomla-vagrant,gokuale\/joomla-vagrant,joomlatools\/joomla-vagrant,joomlatools\/joomla-vagrant,joomlatools\/joomlatools-vagrant,Fabrik\/joomla-vagrant,Fabrik\/joomla-vagrant,Fabrik\/joomla-vagrant,gokuale\/joomla-vagrant,joomlatools\/joomlatools-vagrant","old_file":"puppet\/modules\/varnish\/files\/joomla.box.vcl","new_file":"puppet\/modules\/varnish\/files\/joomla.box.vcl","new_contents":"vcl 4.0;\n\n# This Varnish configuration is a very basic template to get started with caching Joomla sites.\n# In no way is this configuration complete: every site is unique and needs customisation!\n#\n# Joomla creates a session cookie by default, even if you not logged in. To deal with this,\n# we need to let Varnish know when a user is logged in or not. If the user is not logged in,\n# we will prevent the Joomla response from setting any cookies so Varnish can cache the page.\n#\n# To set the X-Logged-In header, append the following line in to the onAfterInitialise() method\n# in \/plugins\/system\/cache\/cache.php, right after \"$user = JFactory::getUser();\" (line #60):\n#\n# JFactory::getApplication()->setHeader('X-Logged-In', $user->guest ? 'false' : 'true', true);\n#\n# Now enable the Cache plugin and Varnish cache. Clear your existing cookies.\n# Your front-end pages will be cached as long as you browse the site as a guest.\n#\n# This VCL is based on https:\/\/snipt.net\/fevangelou\/the-perfect-varnish-configuration-for-joomla-websites\/\n\nimport std;\n\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n .probe = {\n .url = \"\/varnish-enabled\";\n .interval = 1s;\n .timeout = 1s;\n }\n}\n\nbackend alternative {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\n\nsub vcl_recv {\n # Forward client's IP to backend\n unset req.http.X-Forwarded-For;\n set req.http.X-Forwarded-For = client.ip;\n\n set req.http.X-Forwarded-By = server.ip;\n set req.http.X-Forwarded-Port = 80;\n\n # Check if we've still enabled Varnish, if not, passthrough every request\n if (! std.healthy(req.backend_hint))\n {\n set req.backend_hint = alternative;\n return (pass);\n }\n\n # Do not cache phpmyadmin\n if (req.http.host == \"phpmyadmin.joomla.box\") {\n return (pass);\n }\n\n # Do not cache system tools on joomla.box:\n if (req.http.host == \"joomla.box\")\n {\n if (req.url == \"\/apc\" || req.url == \"\/phpinfo\" || req.url == \"\/pimpmylog\") {\n return (pass);\n }\n }\n\n # Proxy (pass) any request that goes to the backend admin,\n # the banner component links or any post requests\n if(req.url ~ \"\/administrator\" || req.url ~ \"\/component\/banners\" || req.url ~ \"\/component\/users\" || req.method == \"POST\") {\n return (pass);\n }\n\n # Do not cache if user is logged in\n if (req.http.Authorization || req.http.Authenticate || req.http.Cookie) {\n return (pass);\n }\n\n # Don't cache ajax requests\n if(req.http.X-Requested-With == \"XMLHttpRequest\" || req.url ~ \"nocache\") {\n return (pass);\n }\n\n # Properly handle different encoding types\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf)$\") {\n # No point in compressing these\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n # unknown algorithm (aka crappy browser)\n unset req.http.Accept-Encoding;\n }\n }\n\n return (hash);\n}\n\nsub vcl_backend_response {\n # Unset the \"etag\" header (suggested)\n unset beresp.http.etag;\n\n # This is Joomla! specific: fix stupid \"no-cache\" header sent by Joomla! even\n # when caching is on - make sure to replace 300 with the number of seconds that\n # you want the browser to cache content\n if(beresp.http.Cache-Control ~ \"no-cache\" || beresp.http.Cache-Control == \"\"){\n set beresp.http.Cache-Control = \"max-age=300, public, must-revalidate\";\n }\n\n # Check for the custom \"x-Logged-In\" header to identify if the visitor is a guest,\n # then unset any cookie (including session cookies) provided it's not a POST request.\n if(bereq.method != \"POST\" && beresp.http.X-Logged-In == \"false\") {\n unset beresp.http.Set-Cookie;\n }\n\n # This is how long Varnish will cache content\n set beresp.ttl = 1w;\n\n return (deliver);\n}\n\nsub vcl_deliver {\n if (resp.http.x-varnish ~ \" \") {\n set resp.http.X-Varnish-Status = \"HIT\";\n } else {\n set resp.http.X-Varnish-Status = \"MISS\";\n }\n\n # Please note that obj.hits behaviour changed in 4.0, now it counts per objecthead, not per object\n # and obj.hits may not be reset in some cases where bans are in use. See bug 1492 for details.\n # So take hits with a grain of salt\n set resp.http.X-Varnish-Hits = obj.hits;\n}","old_contents":"vcl 4.0;\n\n# This Varnish configuration is a very basic template to get started with caching Joomla sites.\n# In no way is this configuration complete: every site is unique and needs customisation!\n#\n# Joomla creates a session cookie by default, even if you not logged in. To deal with this,\n# we need to let Varnish know when a user is logged in or not. If the user is not logged in,\n# we will prevent the Joomla response from setting any cookies so Varnish can cache the page.\n#\n# To set the X-Logged-In header, append the following line in to the onAfterInitialise() method\n# in \/plugins\/system\/cache\/cache.php, right after \"$user = JFactory::getUser();\" (line #60):\n#\n# JFactory::getApplication()->setHeader('X-Logged-In', $user->guest ? 'false' : 'true', true);\n#\n# Now enable the Cache plugin and Varnish cache. Your front-end pages will be cached\n# as long as you browse the site as a guest.\n#\n# This VCL is based on https:\/\/snipt.net\/fevangelou\/the-perfect-varnish-configuration-for-joomla-websites\/\n\nimport std;\n\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n .probe = {\n .url = \"\/varnish-enabled\";\n .interval = 1s;\n .timeout = 1s;\n }\n}\n\nbackend alternative {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\n\nsub vcl_recv {\n # Forward client's IP to backend\n unset req.http.X-Forwarded-For;\n set req.http.X-Forwarded-For = client.ip;\n\n set req.http.X-Forwarded-By = server.ip;\n set req.http.X-Forwarded-Port = 80;\n\n # Check if we've still enabled Varnish, if not, passthrough every request\n if (! std.healthy(req.backend_hint))\n {\n set req.backend_hint = alternative;\n return (pass);\n }\n\n # Do not cache phpmyadmin\n if (req.http.host == \"phpmyadmin.joomla.box\") {\n return (pass);\n }\n\n # Do not cache system tools on joomla.box:\n if (req.http.host == \"joomla.box\")\n {\n if (req.url == \"\/apc\" || req.url == \"\/phpinfo\" || req.url == \"\/pimpmylog\") {\n return (pass);\n }\n }\n\n # Proxy (pass) any request that goes to the backend admin,\n # the banner component links or any post requests\n if(req.url ~ \"\/administrator\" || req.url ~ \"\/component\/banners\" || req.url ~ \"\/component\/users\" || req.method == \"POST\") {\n return (pass);\n }\n\n # Do not cache if user is logged in\n if (req.http.Authorization || req.http.Authenticate || req.http.Cookie) {\n return (pass);\n }\n\n # Don't cache ajax requests\n if(req.http.X-Requested-With == \"XMLHttpRequest\" || req.url ~ \"nocache\") {\n return (pass);\n }\n\n # Properly handle different encoding types\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf)$\") {\n # No point in compressing these\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n # unknown algorithm (aka crappy browser)\n unset req.http.Accept-Encoding;\n }\n }\n\n return (hash);\n}\n\nsub vcl_backend_response {\n # Unset the \"etag\" header (suggested)\n unset beresp.http.etag;\n\n # This is Joomla! specific: fix stupid \"no-cache\" header sent by Joomla! even\n # when caching is on - make sure to replace 300 with the number of seconds that\n # you want the browser to cache content\n if(beresp.http.Cache-Control ~ \"no-cache\" || beresp.http.Cache-Control == \"\"){\n set beresp.http.Cache-Control = \"max-age=300, public, must-revalidate\";\n }\n\n # Check for the custom \"x-Logged-In\" header to identify if the visitor is a guest,\n # then unset any cookie (including session cookies) provided it's not a POST request.\n if(bereq.method != \"POST\" && beresp.http.X-Logged-In == \"false\") {\n unset beresp.http.Set-Cookie;\n }\n\n # This is how long Varnish will cache content\n set beresp.ttl = 1w;\n\n return (deliver);\n}\n\nsub vcl_deliver {\n if (resp.http.x-varnish ~ \" \") {\n set resp.http.X-Varnish-Status = \"HIT\";\n } else {\n set resp.http.X-Varnish-Status = \"MISS\";\n }\n\n # Please note that obj.hits behaviour changed in 4.0, now it counts per objecthead, not per object\n # and obj.hits may not be reset in some cases where bans are in use. See bug 1492 for details.\n # So take hits with a grain of salt\n set resp.http.X-Varnish-Hits = obj.hits;\n}","returncode":0,"stderr":"","license":"mpl-2.0","lang":"VCL"} {"commit":"afae4c647c32e78c9664943d758d0fd41b5d518a","subject":"Add new variations on parenthesist, for insert after parenthesis","message":"Add new variations on parenthesist, for insert after parenthesis\n","repos":"aschneiderman\/atom-voice-vocola","old_file":"atom.vcl","new_file":"atom.vcl","new_contents":"# Voice commands for atom\n\ninclude folders.vch;\ninclude letters.vch;\n\nGo Strawberry = {Ctrl+Alt+F8};\nGo Blueberry ={Ctrl+Alt+o};\nGo Banana = {Ctrl+Alt+F7};\n\n\n# Commands for developing Atom: init.config, packages; also for navigating existing packages\/commands\nReload Atom = {Ctrl+s} Wait(100) {Shift+Ctrl+Alt+F5};\nCommand Palette = {Ctrl+Shift+p};\nKeyboard Shortcuts = {Ctrl+.};\nRun Specs = {Ctrl+Alt+p};\nShow Console = {Ctrl+Alt+i};\n\n# Commands for developing D3: D3 visualizations, D3 Sandwiches\nSave and Reload = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Ctrl+r};\t\nSave and Really Reload = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Ctrl+Shift+r};\n\n# File commands\nFind (File | Document) = {Ctrl+t};\nSave As = {Ctrl+Shift+s};\n\n\n# --- Navigation commands ------------------------------------\n<delimiters> := (Quote = '\"' | 'Single Quote' = \"'\" | Comma = ',' | 'Equal Sign' = '=' | Equals = '=' \n\t| Period = '.' | Colon = ':' | 'Semi-Colon' = ';' | Hyphen = '-' | Underscore = '_' | Slash = '\/'\n\t| Paren = \"(\" | \"Close Paren\" = \")\" | Parentheses = \"(\" | \"Close Parentheses\" = \")\"\n\t| Bracket = '[' | \"Close Bracket\" = ']' | Brace = '{' | 'Close Brace' = '}'\t);\n\nLine 1..200 = {Ctrl+g} $1 {Enter};\n(Left = 'b' | Right = 'f') Word = {Alt+$1};\nTop = {Ctrl+Home};\nBottom = {Ctrl+End};\n(Find = 'Right' | 'Insert After' = 'Right' | 'Insert Before' = 'Left') (Next = 'Enter' | Last = 'Shift+F3') <delimiters> \n\t\t= {Ctrl+f} $3 {$2} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') <delimiters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') 1..20 <delimiters> = {Ctrl+f} $3 {Enter} {Esc} Wait(100) {F3_$2} {Shift+F3} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') Enda <delimiters> = {End} {Ctrl+f} $2 {Enter} {Esc} {Shift+F3} Wait(100) {$1};\n\nFine Alpha <letters> = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Left};\nInsert (Before = 'Left' | After = 'Right') Alpha <letters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nFine Number 0..9 = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Right};\nFind Again = {F3} {Right};\nFind Again 1..20 Times = {F3_$1} {Right};\n\nFind Symbol = {Ctrl+r};\n\n(Set | Add | Clear | Hide | Delete) Bookmark = {Ctrl+Alt+F2};\n(Next = 'F2' | Last = 'Shift+F2') Bookmark = {$1};\n\nNext Window = {Ctrl+Tab};\nLast Window = {Ctrl+Shift+Tab};\n\n\n# --- Editing commands ----------------------------------------\nSelect Line = {Ctrl+l};\nSelect (Next = 'Down' | Last = 'Up') 1..20 Lines = {Home} {Shift+$1_$2};\n(Join = 'j' | Indent = ']' | Dedent = '[') That = {Ctrl+$1};\nMove Line (Up | Down) 1..20 = {Ctrl+$1_$2};\n\n\n\nDelete Word = {Ctrl+Del};\nDelete 1..20 Words = {Ctrl+Del_$1};\nDelete (Back | Last) Word = {Ctrl+Backspace};\nDelete (Back | Last) 1..20 Words = {Ctrl+Backspace_$2};\nDelete Enda Word = {End} {Ctrl+Backspace};\n\n(Delete Line | Dede) = {Ctrl+Shift+k};\nDelete 1..20 Lines = {Ctrl+Shift+k_$1};\n(Cut = 'x' | Paste = 'v' | Copy = 'c') That = {Ctrl+$1};\n\nComment (That | Line) = {Ctrl+\/};\nComment 1..20 Lines = {Home} {Shift+Down_$1} {Ctrl+\/};\n\nSelect between (Delimiters | Brackets) ={Ctrl+m} {Ctrl+Alt+m};\n\nDelete Tags = {Ctrl+Alt+F4};\n\nReplace = {Ctrl+f};\nReplace All = {Ctrl+Enter};\n\n\n\n\n# --- Code commands -------------------------------------------\nStart (Item = 'li' | List = 'ul' | HTML = 'html' | pre = \"pre\"\n\t| 'Bold ID' = 'bold-id' | 'Input' = 'ds-input-text'\n\t| 'Fix Line' = 'fix-current-line' | 'Fix Current Line' = 'fix-current-line'\n\t| Snippet = 'my-snippet' | 'Recipe Row' = 'recipe-row' | 'Recipe Play' = 'recipe-play') = $1 {Tab};\nStart (para = '<p>' ) = $1;\nAdd (para = 'p') = '<' $1 '>' {End} '<\/' $1 '>';\nReplace With (para = 'p') = {Ctrl+Alt+F4} '<' $1 '>' {End} '<\/' $1 '>';\n\nStart (Header | Heading) 1..7 = h $2 {Tab};\nAdd (Header | Heading) 1..7 = '<h' $2 '>' {End} '<\/h' $2 '>';\nReplace With (Header | Heading) 1..7 = {Ctrl+Alt+F4} '<h' $2 '>' {End} '<\/h' $2 '>' {Home};\nMid HREF = '\">';\n\nPaste Function = 'function ' {Ctrl+v} ' {' {Enter} {Enter} '};' {Up};\n\nPre-Format Code = {Ctrl+Alt+F5};\n\n# TO ADD:\n# adding HTML comments, using a snippet\n\n\n\n","old_contents":"# Voice commands for atom\n\ninclude folders.vch;\ninclude letters.vch;\n\nGo Strawberry = {Ctrl+Alt+F8};\nGo Blueberry ={Ctrl+Alt+o};\nGo Banana = {Ctrl+Alt+F7};\n\n\n# Commands for developing Atom: init.config, packages; also for navigating existing packages\/commands\nReload Atom = {Ctrl+s} Wait(100) {Shift+Ctrl+Alt+F5};\nCommand Palette = {Ctrl+Shift+p};\nKeyboard Shortcuts = {Ctrl+.};\nRun Specs = {Ctrl+Alt+p};\nShow Console = {Ctrl+Alt+i};\n\n# Commands for developing D3: D3 visualizations, D3 Sandwiches\nSave and Reload = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Ctrl+r};\t\nSave and Really Reload = {Ctrl+s} Wait(100) SendSystemKeys(\"{Alt+Tab}\") {Ctrl+Shift+r};\n\n# File commands\nFind (File | Document) = {Ctrl+t};\nSave As = {Ctrl+Shift+s};\n\n\n# --- Navigation commands ------------------------------------\n<delimiters> := (Quote = '\"' | 'Single Quote' = \"'\" | Comma = ',' | 'Equal Sign' = '=' | Equals = '=' \n\t| Period = '.' | Colon = ':' | 'Semi-Colon' = ';' | Hyphen = '-' | Underscore = '_' | Slash = '\/'\n\t| Paren = \"(\" | \"Close Paren\" = \")\"\n\t| Bracket = '[' | \"Close Bracket\" = ']' | Brace = '{' | 'Close Brace' = '}'\t);\n\nLine 1..200 = {Ctrl+g} $1 {Enter};\n(Left = 'b' | Right = 'f') Word = {Alt+$1};\nTop = {Ctrl+Home};\nBottom = {Ctrl+End};\n(Find = 'Right' | 'Insert After' = 'Right' | 'Insert Before' = 'Left') (Next = 'Enter' | Last = 'Shift+F3') <delimiters> \n\t\t= {Ctrl+f} $3 {$2} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') <delimiters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') 1..20 <delimiters> = {Ctrl+f} $3 {Enter} {Esc} Wait(100) {F3_$2} {Shift+F3} Wait(100) {$1};\nInsert (Before = 'Left' | After = 'Right') Enda <delimiters> = {End} {Ctrl+f} $2 {Enter} {Esc} {Shift+F3} Wait(100) {$1};\n\nFine Alpha <letters> = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Left};\nInsert (Before = 'Left' | After = 'Right') Alpha <letters> = {Ctrl+f} $2 {Enter} {Esc} Wait(100) {$1};\nFine Number 0..9 = {Ctrl+f} $1 {Enter} {Esc} Wait(100) {Right};\nFind Again = {F3} {Right};\nFind Again 1..20 Times = {F3_$1} {Right};\n\nFind Symbol = {Ctrl+r};\n\n(Set | Add | Clear | Hide | Delete) Bookmark = {Ctrl+Alt+F2};\n(Next = 'F2' | Last = 'Shift+F2') Bookmark = {$1};\n\nNext Window = {Ctrl+Tab};\nLast Window = {Ctrl+Shift+Tab};\n\n\n# --- Editing commands ----------------------------------------\nSelect Line = {Ctrl+l};\nSelect (Next = 'Down' | Last = 'Up') 1..20 Lines = {Home} {Shift+$1_$2};\n(Join = 'j' | Indent = ']' | Dedent = '[') That = {Ctrl+$1};\nMove Line (Up | Down) 1..20 = {Ctrl+$1_$2};\n\n\n\nDelete Word = {Ctrl+Del};\nDelete 1..20 Words = {Ctrl+Del_$1};\nDelete (Back | Last) Word = {Ctrl+Backspace};\nDelete (Back | Last) 1..20 Words = {Ctrl+Backspace_$2};\nDelete Enda Word = {End} {Ctrl+Backspace};\n\n(Delete Line | Dede) = {Ctrl+Shift+k};\nDelete 1..20 Lines = {Ctrl+Shift+k_$1};\n(Cut = 'x' | Paste = 'v' | Copy = 'c') That = {Ctrl+$1};\n\nComment (That | Line) = {Ctrl+\/};\nComment 1..20 Lines = {Home} {Shift+Down_$1} {Ctrl+\/};\n\nSelect between (Delimiters | Brackets) ={Ctrl+m} {Ctrl+Alt+m};\n\nDelete Tags = {Ctrl+Alt+F4};\n\nReplace = {Ctrl+f};\nReplace All = {Ctrl+Enter};\n\n\n\n\n# --- Code commands -------------------------------------------\nStart (Item = 'li' | List = 'ul' | HTML = 'html' | pre = \"pre\"\n\t| 'Bold ID' = 'bold-id' | 'Input' = 'ds-input-text'\n\t| 'Fix Line' = 'fix-current-line' | 'Fix Current Line' = 'fix-current-line'\n\t| Snippet = 'my-snippet' | 'Recipe Row' = 'recipe-row' | 'Recipe Play' = 'recipe-play') = $1 {Tab};\nStart (para = '<p>' ) = $1;\nAdd (para = 'p') = '<' $1 '>' {End} '<\/' $1 '>';\nReplace With (para = 'p') = {Ctrl+Alt+F4} '<' $1 '>' {End} '<\/' $1 '>';\n\nStart (Header | Heading) 1..7 = h $2 {Tab};\nAdd (Header | Heading) 1..7 = '<h' $2 '>' {End} '<\/h' $2 '>';\nReplace With (Header | Heading) 1..7 = {Ctrl+Alt+F4} '<h' $2 '>' {End} '<\/h' $2 '>' {Home};\nMid HREF = '\">';\n\nPaste Function = 'function ' {Ctrl+v} ' {' {Enter} {Enter} '};' {Up};\n\nPre-Format Code = {Ctrl+Alt+F5};\n\n# TO ADD:\n# adding HTML comments, using a snippet\n\n\n\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"e34b48a1c7584b70c884cc3e40ad8ddf0c62ea87","subject":"Fix logging to correctly log downloads (#2057)","message":"Fix logging to correctly log downloads (#2057)\n\n* Only unset some of the headers\r\n\r\n* Remove pointless code\r\n\r\n* Unset all of our x-amz-* headers\r\n\r\n* Correctly send download events when we get one\r\n","repos":"alex\/warehouse,dstufft\/warehouse,alex\/warehouse,alex\/warehouse,pypa\/warehouse,pypa\/warehouse,dstufft\/warehouse,alex\/warehouse,alex\/warehouse,dstufft\/warehouse,pypa\/warehouse,pypa\/warehouse,dstufft\/warehouse","old_file":"vcl\/main.vcl","new_file":"vcl\/main.vcl","new_contents":"# Note: It is VERY important to ensure that any changes to VCL will work\n# properly with both the current version of ``master`` and the version in\n# the pull request that adds any new changes. This is because the\n# configuration will be applied automatically as part of the deployment\n# process, but while the previous version of the code is still up and\n# running. Thus backwards incompatible changes must be broken up over\n# multiple pull requests in order to phase them in over multiple deploys.\n\nsub vcl_recv {\n\n # I'm not 100% sure on what this is exactly for, it was taken from the\n # Fastly documentation, however, what I *believe* it does is just ensure\n # that we don't serve a stale copy of the page from the shield node when\n # an edge node is requesting content.\n if (req.http.Fastly-FF) {\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Some (Older) clients will send a hash fragment as part of the URL even\n # though that is a local only modification. This breaks this badly for the\n # files in S3, and in general it's just not needed.\n set req.url = regsub(req.url, \"#.*$\", \"\");\n\n # Fastly does some normalization of the Accept-Encoding header so that it\n # reduces the number of cached copies (when served with the common,\n # Vary: Accept-Encoding) that are cached for any one URL. This makes a lot\n # of sense, except for the fact that we want to enable brotli compression\n # for our static files. Thus we need to work around the normalized encoding\n # in a way that still minimizes cached copies, but which will allow our\n # static files to be served using brotli.\n if (req.url ~ \"^\/static\/\" && req.http.Fastly-Orig-Accept-Encoding) {\n if (req.http.User-Agent ~ \"MSIE 6\") {\n # For that 0.3% of stubborn users out there\n unset req.http.Accept-Encoding;\n } elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"br\") {\n set req.http.Accept-Encoding = \"br\";\n } elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n\n # Most of the URLs in Warehouse do not support or require any sort of query\n # parameter. If we strip these at the edge then we'll increase our cache\n # efficiency when they won't otherwise change the output of the pages.\n #\n # This will match any URL except those that start with:\n #\n # * \/admin\/\n # * \/search\/\n # * \/account\/login\/\n # * \/account\/logout\/\n # * \/account\/register\/\n # * \/pypi\n if (req.url.path !~ \"^\/(admin\/|search(\/|$)|account\/(login|logout|register)\/|pypi)\") {\n set req.url = req.url.path;\n }\n\n # Sort all of our query parameters, this will ensure that the same query\n # parameters in a different order will end up being represented as the same\n # thing, reducing cache misses due to ordering differences.\n set req.url = boltsort.sort(req.url);\n\n # We have a number of items that we'll pass back to the origin.\n # Set a header to tell the backend if we're using https or http.\n if (req.http.Fastly-SSL) {\n set req.http.Warehouse-Proto = \"https\";\n } else {\n set req.http.Warehouse-Proto = \"http\";\n }\n\n # Pass the client IP address back to the backend.\n if (req.http.Fastly-Client-IP) {\n set req.http.Warehouse-IP = req.http.Fastly-Client-IP;\n }\n\n # Pass the real host value back to the backend.\n if (req.http.Host) {\n set req.http.Warehouse-Host = req.http.host;\n }\n\n\n#FASTLY recv\n\n\n # We want to Force SSL for the WebUI by redirecting to the HTTPS version of\n # the page, however for API calls we want to return an error code directing\n # people to instead use HTTPS.\n if (!req.http.Fastly-SSL) {\n\n # The \/simple\/ and \/packages\/ API.\n if (req.url ~ \"^\/(simple|packages)\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy JSON API.\n if (req.url ~ \"^\/pypi\/.+\/json$\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy ?:action= API.\n if (req.url ~ \"^\/pypi.*(\\?|&)=:action\") {\n error 803 \"SSL is required\";\n }\n\n # If we're on the \/pypi page and we've received something other than a\n # GET or HEAD request, then we have no way to determine if a particular\n # request is an API call or not because it'll be in the request body\n # and that isn't available to us here. So in those cases, we won't\n # do a redirect.\n if (req.url ~ \"^\/pypi\") {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n error 801 \"Force SSL\";\n }\n }\n else {\n # This isn't a \/pypi URL so we'll just unconditionally redirect to\n # HTTPS.\n error 801 \"Force SSL\";\n }\n }\n\n # Redirect pypi.io, www.pypi.io, and warehouse.python.org to pypi.org, this\n # is purposely done *after* the HTTPS checks.\n if (std.tolower(req.http.host) ~ \"^(www.pypi.org|(www.)?pypi.io|warehouse.python.org)$\") {\n set req.http.Location = \"https:\/\/pypi.org\" req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n # Redirect warehouse-staging.python.org to test.pypi.io.\n if (std.tolower(req.http.host) ~ \"^(test.pypi.io|warehouse-staging.python.org)$\") {\n set req.http.Location = \"https:\/\/test.pypi.org\" req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n\n # Requests to \/packages\/ get dispatched to Amazon instead of to our typical\n # Origin. This requires a a bit of setup to make it work.\n if (req.http.host ~ \"^(test-)?files.pythonhosted.org$\"\n && req.url ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\") {\n # Setup our environment to better match what S3 expects\/needs\n set req.http.Host = req.http.AWS-Bucket-Name \".s3.amazonaws.com\";\n set req.http.Date = now;\n set req.url = regsuball(req.url, \"\\+\", urlencode(\"+\"));\n\n # Compute the Authorization header that S3 requires to be able to\n # access the files stored there.\n set req.http.Authorization = \"AWS \" req.http.AWS-Access-Key-ID \":\" digest.hmac_sha1_base64(req.http.AWS-Secret-Access-Key, \"GET\" LF LF LF req.http.Date LF \"\/\" req.http.AWS-Bucket-Name req.url.path);\n\n # We don't want to send our Warehouse-Token to S3, so we'll go ahead\n # and remove it.\n unset req.http.Warehouse-Token;\n }\n\n # We no longer need any of these variables, which would exist only to\n # shuffle configuration from the Fastly UI into our VCL.\n unset req.http.AWS-Access-Key-ID;\n unset req.http.AWS-Secret-Access-Key;\n unset req.http.AWS-Bucket-Name;\n\n # On a POST, we want to skip the shielding and hit backends directly.\n if (req.request == \"POST\") {\n set req.backend = F_Heroku;\n }\n\n # Do not bother to attempt to run the caching mechanisms for methods that\n # are not generally safe to cache.\n if (req.request != \"HEAD\" &&\n req.request != \"GET\" &&\n req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n # We don't ever want to cache our health URL. Outside systems should be\n # able to use it to reach past Fastly and get an end to end health check.\n if (req.url == \"\/_health\/\") {\n return(pass);\n }\n\n # We never want to cache our admin URLs, while this should be \"safe\" due to\n # the architecure of Warehouse, it'll just be easier to debug issues if\n # these always are uncached.\n if (req.url ~ \"^\/admin\/\") {\n return(pass);\n }\n\n # Finally, return the default lookup action.\n return(lookup);\n}\n\n\nsub vcl_fetch {\n\n # These are newer kinds of redirects which should be able to be cached by\n # default, even though Fastly doesn't currently have them in their default\n # list of cacheable status codes.\n if (http_status_matches(beresp.status, \"303,307,308\")) {\n set beresp.cacheable = true;\n }\n\n # For any 5xx status code we want to see if a stale object exists for it,\n # if so we'll go ahead and serve it.\n if (beresp.status >= 500 && beresp.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n\n#FASTLY fetch\n\n\n # Trigger a \"SSL is required\" error if the backend has indicated to do so.\n if (beresp.http.X-Fastly-Error == \"803\") {\n error 803 \"SSL is required\";\n }\n\n # If we've gotten a 502 or a 503 from the backend, we'll go ahead and retry\n # the request.\n if ((beresp.status == 502 || beresp.status == 503) &&\n req.restarts < 1 &&\n (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n # If we've restarted, then we'll record the number of restarts.\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n # If there is a Set-Cookie header, we'll ensure that we do not cache the\n # response.\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n # If the response has the private Cache-Control directive then we won't\n # cache it.\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # If we've gotten an error after the restarts we'll deliver the response\n # with a very short cache time.\n if (http_status_matches(beresp.status, \"500,502,503\")) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n # Apply a default TTL if there isn't a max-age or s-maxage.\n if (beresp.http.Expires ||\n beresp.http.Surrogate-Control ~ \"max-age\" ||\n beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # Keep the ttl here\n }\n else {\n # Apply the default ttl\n set beresp.ttl = 60s;\n }\n\n # Actually deliver the fetched response.\n return(deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n # If the object we have isn't cacheable, then just serve it directly\n # without going through any of the caching mechanisms.\n if (!obj.cacheable) {\n return(pass);\n }\n\n return(deliver);\n}\n\n\nsub vcl_deliver {\n # If this is an error and we have a stale response available, restart so\n # that we can pick it up and serve it.\n if (resp.status >= 500 && resp.status < 600) {\n if (stale.exists) {\n restart;\n }\n }\n\n#FASTLY deliver\n\n # Unset headers that we don't need\/want to send on to the client because\n # they are not generally useful.\n unset resp.http.Via;\n\n # Set our standard security headers, we do this in VCL rather than in\n # Warehouse itself so that we always get these headers, regardless of the\n # origin server being used.\n set resp.http.Strict-Transport-Security = \"max-age=31536000; includeSubDomains; preload\";\n set resp.http.X-Frame-Options = \"deny\";\n set resp.http.X-XSS-Protection = \"1; mode=block\";\n set resp.http.X-Content-Type-Options = \"nosniff\";\n set resp.http.X-Permitted-Cross-Domain-Policies = \"none\";\n\n # If we're not executing a shielding request, and the URL is one of our file\n # URLs, and it's a GET request, and the response is either a 200 or a 304\n # then we want to log an event stating that a download has taken place.\n if (!req.http.Fastly-FF\n && std.tolower(req.http.Warehouse-Host) == \"files.pythonhosted.org\"\n && req.url.path ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\"\n && req.request == \"GET\"\n && http_status_matches(resp.status, \"200,304\")) {\n log {\"syslog \"} req.service_id {\" linehaul :: \"} \"2@\" now \"|\" geoip.country_code \"|\" req.url.path \"|\" tls.client.protocol \"|\" tls.client.cipher \"|\" resp.http.x-amz-meta-project \"|\" resp.http.x-amz-meta-version \"|\" resp.http.x-amz-meta-package-type \"|\" req.http.user-agent;\n log {\"syslog \"} req.service_id {\" downloads :: \"} \"2@\" now \"|\" geoip.country_code \"|\" req.url.path \"|\" tls.client.protocol \"|\" tls.client.cipher \"|\" resp.http.x-amz-meta-project \"|\" resp.http.x-amz-meta-version \"|\" resp.http.x-amz-meta-package-type \"|\" req.http.user-agent;\n }\n\n # Unset a few headers set by Amazon that we don't really have a need\/desire\n # to send to clients.\n unset resp.http.x-amz-replication-status;\n unset resp.http.x-amz-meta-python-version;\n unset resp.http.x-amz-meta-version;\n unset resp.http.x-amz-meta-package-type;\n unset resp.http.x-amz-meta-project;\n\n\n return(deliver);\n}\n\n\nsub vcl_error {\n#FASTLY error\n\n # If we have a 5xx error and there is a stale object available, then we\n # will deliver that stale object.\n if (obj.status >= 500 && obj.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n if (obj.status == 803) {\n set obj.status = 403;\n set obj.response = \"SSL is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic {\"SSL is required.\"};\n return (deliver);\n } else if (obj.status == 750) {\n set obj.status = 301;\n set obj.http.Location = req.http.Location;\n set obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n synthetic {\"<html><head><title>301 Moved Permanently<\/title><\/head><body><center><h1>301 Moved Permanently<\/h1><\/center><\/body><\/html>\"};\n return(deliver);\n }\n\n}\n","old_contents":"# Note: It is VERY important to ensure that any changes to VCL will work\n# properly with both the current version of ``master`` and the version in\n# the pull request that adds any new changes. This is because the\n# configuration will be applied automatically as part of the deployment\n# process, but while the previous version of the code is still up and\n# running. Thus backwards incompatible changes must be broken up over\n# multiple pull requests in order to phase them in over multiple deploys.\n\nsub vcl_recv {\n\n # I'm not 100% sure on what this is exactly for, it was taken from the\n # Fastly documentation, however, what I *believe* it does is just ensure\n # that we don't serve a stale copy of the page from the shield node when\n # an edge node is requesting content.\n if (req.http.Fastly-FF) {\n set req.max_stale_while_revalidate = 0s;\n }\n\n # Some (Older) clients will send a hash fragment as part of the URL even\n # though that is a local only modification. This breaks this badly for the\n # files in S3, and in general it's just not needed.\n set req.url = regsub(req.url, \"#.*$\", \"\");\n\n # Fastly does some normalization of the Accept-Encoding header so that it\n # reduces the number of cached copies (when served with the common,\n # Vary: Accept-Encoding) that are cached for any one URL. This makes a lot\n # of sense, except for the fact that we want to enable brotli compression\n # for our static files. Thus we need to work around the normalized encoding\n # in a way that still minimizes cached copies, but which will allow our\n # static files to be served using brotli.\n if (req.url ~ \"^\/static\/\" && req.http.Fastly-Orig-Accept-Encoding) {\n if (req.http.User-Agent ~ \"MSIE 6\") {\n # For that 0.3% of stubborn users out there\n unset req.http.Accept-Encoding;\n } elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"br\") {\n set req.http.Accept-Encoding = \"br\";\n } elsif (req.http.Fastly-Orig-Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n\n # Most of the URLs in Warehouse do not support or require any sort of query\n # parameter. If we strip these at the edge then we'll increase our cache\n # efficiency when they won't otherwise change the output of the pages.\n #\n # This will match any URL except those that start with:\n #\n # * \/admin\/\n # * \/search\/\n # * \/account\/login\/\n # * \/account\/logout\/\n # * \/account\/register\/\n # * \/pypi\n if (req.url.path !~ \"^\/(admin\/|search(\/|$)|account\/(login|logout|register)\/|pypi)\") {\n set req.url = req.url.path;\n }\n\n # Sort all of our query parameters, this will ensure that the same query\n # parameters in a different order will end up being represented as the same\n # thing, reducing cache misses due to ordering differences.\n set req.url = boltsort.sort(req.url);\n\n\n#FASTLY recv\n\n\n # We want to Force SSL for the WebUI by redirecting to the HTTPS version of\n # the page, however for API calls we want to return an error code directing\n # people to instead use HTTPS.\n if (!req.http.Fastly-SSL) {\n\n # The \/simple\/ and \/packages\/ API.\n if (req.url ~ \"^\/(simple|packages)\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy JSON API.\n if (req.url ~ \"^\/pypi\/.+\/json$\") {\n error 803 \"SSL is required\";\n }\n\n # The Legacy ?:action= API.\n if (req.url ~ \"^\/pypi.*(\\?|&)=:action\") {\n error 803 \"SSL is required\";\n }\n\n # If we're on the \/pypi page and we've received something other than a\n # GET or HEAD request, then we have no way to determine if a particular\n # request is an API call or not because it'll be in the request body\n # and that isn't available to us here. So in those cases, we won't\n # do a redirect.\n if (req.url ~ \"^\/pypi\") {\n if (req.request == \"GET\" || req.request == \"HEAD\") {\n error 801 \"Force SSL\";\n }\n }\n else {\n # This isn't a \/pypi URL so we'll just unconditionally redirect to\n # HTTPS.\n error 801 \"Force SSL\";\n }\n }\n\n # Redirect pypi.io, www.pypi.io, and warehouse.python.org to pypi.org, this\n # is purposely done *after* the HTTPS checks.\n if (std.tolower(req.http.host) ~ \"^(www.pypi.org|(www.)?pypi.io|warehouse.python.org)$\") {\n set req.http.Location = \"https:\/\/pypi.org\" req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n # Redirect warehouse-staging.python.org to test.pypi.io.\n if (std.tolower(req.http.host) ~ \"^(test.pypi.io|warehouse-staging.python.org)$\") {\n set req.http.Location = \"https:\/\/test.pypi.org\" req.url;\n error 750 \"Redirect to Primary Domain\";\n }\n\n # Requests to \/packages\/ get dispatched to Amazon instead of to our typical\n # Origin. This requires a a bit of setup to make it work.\n if (req.http.host ~ \"^(test-)?files.pythonhosted.org$\"\n && req.url ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\") {\n # Setup our environment to better match what S3 expects\/needs\n set req.http.Host = req.http.AWS-Bucket-Name \".s3.amazonaws.com\";\n set req.http.Date = now;\n set req.url = regsuball(req.url, \"\\+\", urlencode(\"+\"));\n\n # Compute the Authorization header that S3 requires to be able to\n # access the files stored there.\n set req.http.Authorization = \"AWS \" req.http.AWS-Access-Key-ID \":\" digest.hmac_sha1_base64(req.http.AWS-Secret-Access-Key, \"GET\" LF LF LF req.http.Date LF \"\/\" req.http.AWS-Bucket-Name req.url.path);\n\n # We don't want to send our Warehouse-Token to S3, so we'll go ahead\n # and remove it.\n unset req.http.Warehouse-Token;\n }\n\n # We no longer need any of these variables, which would exist only to\n # shuffle configuration from the Fastly UI into our VCL.\n unset req.http.AWS-Access-Key-ID;\n unset req.http.AWS-Secret-Access-Key;\n unset req.http.AWS-Bucket-Name;\n\n # We have a number of items that we'll pass back to the origin, but only\n # if we have a Warehouse-Token that will allow them to be accepted.\n if (req.http.Warehouse-Token) {\n # Set a header to tell the backend if we're using https or http.\n if (req.http.Fastly-SSL) {\n set req.http.Warehouse-Proto = \"https\";\n } else {\n set req.http.Warehouse-Proto = \"http\";\n }\n\n # Pass the client IP address back to the backend.\n if (req.http.Fastly-Client-IP) {\n set req.http.Warehouse-IP = req.http.Fastly-Client-IP;\n }\n\n # Pass the real host value back to the backend.\n if (req.http.Host) {\n set req.http.Warehouse-Host = req.http.host;\n }\n }\n\n # On a POST, we want to skip the shielding and hit backends directly.\n if (req.request == \"POST\") {\n set req.backend = F_Heroku;\n }\n\n # Do not bother to attempt to run the caching mechanisms for methods that\n # are not generally safe to cache.\n if (req.request != \"HEAD\" &&\n req.request != \"GET\" &&\n req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n # We don't ever want to cache our health URL. Outside systems should be\n # able to use it to reach past Fastly and get an end to end health check.\n if (req.url == \"\/_health\/\") {\n return(pass);\n }\n\n # We never want to cache our admin URLs, while this should be \"safe\" due to\n # the architecure of Warehouse, it'll just be easier to debug issues if\n # these always are uncached.\n if (req.url ~ \"^\/admin\/\") {\n return(pass);\n }\n\n # Finally, return the default lookup action.\n return(lookup);\n}\n\n\nsub vcl_fetch {\n\n # These are newer kinds of redirects which should be able to be cached by\n # default, even though Fastly doesn't currently have them in their default\n # list of cacheable status codes.\n if (http_status_matches(beresp.status, \"303,307,308\")) {\n set beresp.cacheable = true;\n }\n\n # For any 5xx status code we want to see if a stale object exists for it,\n # if so we'll go ahead and serve it.\n if (beresp.status >= 500 && beresp.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n # When delivering a 304 response, we don't always have access to all the\n # headers in the resp because a 304 response is supposed to remove most of\n # the headers. So we'll instead stash these headers on the request so that\n # we can log this data from there instead of from the response.\n if (beresp.http.x-amz-meta-project\n || beresp.http.x-amz-meta-version\n || beresp.http.x-amz-meta-package-type) {\n set req.http.Fastly-amz-meta-project = beresp.http.x-amz-meta-project;\n set req.http.Fastly-amz-meta-version = beresp.http.x-amz-meta-version;\n set req.http.Fastly-amz-meta-package-type = beresp.http.x-amz-meta-package-type;\n }\n\n\n#FASTLY fetch\n\n\n # Trigger a \"SSL is required\" error if the backend has indicated to do so.\n if (beresp.http.X-Fastly-Error == \"803\") {\n error 803 \"SSL is required\";\n }\n\n # If we've gotten a 502 or a 503 from the backend, we'll go ahead and retry\n # the request.\n if ((beresp.status == 502 || beresp.status == 503) &&\n req.restarts < 1 &&\n (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n # If we've restarted, then we'll record the number of restarts.\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n # If there is a Set-Cookie header, we'll ensure that we do not cache the\n # response.\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n # If the response has the private Cache-Control directive then we won't\n # cache it.\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n # If we've gotten an error after the restarts we'll deliver the response\n # with a very short cache time.\n if (http_status_matches(beresp.status, \"500,502,503\")) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n # Apply a default TTL if there isn't a max-age or s-maxage.\n if (beresp.http.Expires ||\n beresp.http.Surrogate-Control ~ \"max-age\" ||\n beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # Keep the ttl here\n }\n else {\n # Apply the default ttl\n set beresp.ttl = 60s;\n }\n\n # Actually deliver the fetched response.\n return(deliver);\n}\n\n\nsub vcl_hit {\n#FASTLY hit\n\n # If the object we have isn't cacheable, then just serve it directly\n # without going through any of the caching mechanisms.\n if (!obj.cacheable) {\n return(pass);\n }\n\n return(deliver);\n}\n\n\nsub vcl_deliver {\n # If this is an error and we have a stale response available, restart so\n # that we can pick it up and serve it.\n if (resp.status >= 500 && resp.status < 600) {\n if (stale.exists) {\n restart;\n }\n }\n\n#FASTLY deliver\n\n # Unset headers that we don't need\/want to send on to the client because\n # they are not generally useful.\n unset resp.http.Via;\n\n # Unset a few headers set by Amazon that we don't really have a need\/desire\n # to send to clients.\n unset resp.http.X-AMZ-Replication-Status;\n unset resp.http.X-AMZ-Meta-Python-Version;\n unset resp.http.X-AMZ-Meta-Version;\n unset resp.http.X-AMZ-Meta-Package-Type;\n unset resp.http.X-AMZ-Meta-Project;\n\n # Set our standard security headers, we do this in VCL rather than in\n # Warehouse itself so that we always get these headers, regardless of the\n # origin server being used.\n set resp.http.Strict-Transport-Security = \"max-age=31536000; includeSubDomains; preload\";\n set resp.http.X-Frame-Options = \"deny\";\n set resp.http.X-XSS-Protection = \"1; mode=block\";\n set resp.http.X-Content-Type-Options = \"nosniff\";\n set resp.http.X-Permitted-Cross-Domain-Policies = \"none\";\n\n # Unstash our information about what project\/version\/package-type a\n # particular file download was for.\n if (req.http.Fastly-amz-meta-project\n || req.http.Fastly-amz-meta-version\n || req.http.Fastly-amz-meta-package-type) {\n set resp.http.x-amz-meta-project = req.http.Fastly-amz-meta-project;\n set resp.http.x-amz-meta-version = req.http.Fastly-amz-meta-version;\n set resp.http.x-amz-meta-package-type = req.http.Fastly-amz-meta-package-type;\n }\n\n # If we're not executing a shielding request, and the URL is one of our file\n # URLs, and it's a GET request, and the response is either a 200 or a 304\n # then we want to log an event stating that a download has taken place.\n if (!req.http.Fastly-FF\n && std.tolower(req.http.host) == \"files.pythonhosted.org\"\n && req.url.path ~ \"^\/packages\/[a-f0-9]{2}\/[a-f0-9]{2}\/[a-f0-9]{60}\/\"\n && req.request == \"GET\"\n && http_status_matches(resp.status, \"200,304\")) {\n log {\"syslog \"} req.service_id {\" linehaul :: \"} \"2@\" now \"|\" geoip.country_code \"|\" req.url.path \"|\" tls.client.protocol \"|\" tls.client.cipher \"|\" resp.http.x-amz-meta-project \"|\" resp.http.x-amz-meta-version \"|\" resp.http.x-amz-meta-package-type \"|\" req.http.user-agent;\n log {\"syslog \"} req.service_id {\" downloads :: \"} \"2@\" now \"|\" geoip.country_code \"|\" req.url.path \"|\" tls.client.protocol \"|\" tls.client.cipher \"|\" resp.http.x-amz-meta-project \"|\" resp.http.x-amz-meta-version \"|\" resp.http.x-amz-meta-package-type \"|\" req.http.user-agent;\n }\n\n return(deliver);\n}\n\n\nsub vcl_error {\n#FASTLY error\n\n # If we have a 5xx error and there is a stale object available, then we\n # will deliver that stale object.\n if (obj.status >= 500 && obj.status < 600) {\n if (stale.exists) {\n return(deliver_stale);\n }\n }\n\n if (obj.status == 803) {\n set obj.status = 403;\n set obj.response = \"SSL is required\";\n set obj.http.Content-Type = \"text\/plain; charset=UTF-8\";\n synthetic {\"SSL is required.\"};\n return (deliver);\n } else if (obj.status == 750) {\n set obj.status = 301;\n set obj.http.Location = req.http.Location;\n set obj.http.Content-Type = \"text\/html; charset=UTF-8\";\n synthetic {\"<html><head><title>301 Moved Permanently<\/title><\/head><body><center><h1>301 Moved Permanently<\/h1><\/center><\/body><\/html>\"};\n return(deliver);\n }\n\n}\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"VCL"} {"commit":"7e49ac8ed468d92c75ad945348359877cf245253","subject":"Updated VCL with further refinements to regexp, and case normalization.","message":"Updated VCL with further refinements to regexp, and case normalization.\n","repos":"gotofbi\/ansible-varnish,colstrom\/ansible-varnish,gotofbi\/ansible-varnish,noqcks\/ansible-varnish,kkwoker\/ansible-varnish,killerwails\/ansible-varnish,killerwails\/ansible-varnish,telusdigital\/ansible-varnish","old_file":"templates\/etc\/varnish\/default.vcl","new_file":"templates\/etc\/varnish\/default.vcl","new_contents":"vcl 4.0;\n\nimport directors;\nimport std;\n\n###\n# Varnish Documentation\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-built-in-subs.html\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/reference\/vcl.html\n##\n\n{% for backend in varnish_backend_hosts %}\nbackend application_{{ loop.index }} {\n .host = \"{{ backend }}\";\n .port = \"{{ varnish_backend_port }}\";\n{% if varnish_health_checks_enabled %}\n .probe = {\n .url = \"{{ varnish_health_check_url }}\";\n .interval = {{ varnish_health_check_interval }};\n .timeout = {{ varnish_health_check_timeout }};\n .window = {{ varnish_health_check_window }};\n .threshold = {{ varnish_health_check_threshold }};\n }\n{% endif %}\n}\n{% endfor %}\n\n###\n# vcl_init\n# Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n###\n# The vcl_init subroutine may terminate with calling return() with one of the following keywords:\n#\n# ok\n# Normal return, VCL continues loading.\n##\n\nsub vcl_init {\n new application = directors.round_robin();\n{% for backend in varnish_backend_hosts %}\n application.add_backend(application_{{ loop.index }});\n{% endfor %}\n}\n\n###\n# vcl_recv\n# Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use. \n# It is also used to modify the request\n###\n# The vcl_recv subroutine may terminate with calling return() on one of the following keywords:\n#\n# synth(status code, reason)\n# Return a synthetic object with the specified status code to the client and abandon the request.\n# pass\n# Switch to pass mode. Control will eventually pass to vcl_pass.\n# pipe\n# Switch to pipe mode. Control will eventually pass to vcl_pipe.\n# hash\n# Continue processing the object as a potential candidate for caching. Passes the control over to vcl_hash.\n# purge\n# Purge the object and it's variants. Control passes through vcl_hash to vcl_purge.\n#\n\nsub vcl_recv {\n set req.backend_hint = application.backend();\n\n ###\n # Avoid processing uncacheable requests\n ###\n\n if (req.http.Authorization) {\n return (pass);\n }\n\n ###\n # Inject X-Forwarded-For headers, but only once.\n ###\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n{% if varnish_header_sanitization_enabled %}\n ###\n # Header Sanitization\n ###\n\n{% if varnish_discards_port_from_host_header %}\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n{% endif %}\n\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_enabled %}\n ###\n # Cookie Sanitization\n ###\n\n ### Google Analytics\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n\n ### Quantcast\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n \n ### AddThis\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n\n ### General Cleanup\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n{% endif %}\n\n{% if varnish_uri_sanitization_enabled %}\n ###\n # URI Sanitization\n ###\n \n if (req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=\") {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n{% endif %}\n\n{% if varnish_workaround_telusdotcom_browser_profile %}\n ###\n # Workaround for BrowserProfile and Language\/Region Detection on TELUS.com\n ###\n\n if (req.http.Cookie ~ \"BrowserProfile\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.Cookie, \"(.*)language..:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n set req.http.X-Province = std.tolower(regsuball(req.http.Cookie, \"(.*)region..:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n } else {\n if (req.http.Cookie ~ \"lang=\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.Cookie, \"(.*)lang=([^;]*)(.*)\", \"\\2\"));\n } else {\n set req.http.X-Language = \"en\";\n }\n\n if (req.http.Cookie ~ \"prov=\") {\n set req.http.X-Province = std.tolower(regsuball(req.http.Cookie, \"(.*)prov=([^;]*)(.*)\", \"\\2\"));\n } else {\n set req.http.X-Province = \"BC\";\n }\n }\n\n if (req.url ~ \"\/(en|fr)\/\") {\n if (req.url ~ \"\/en\/\" && req.http.X-Language != \"en\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Language)\";\n return(pass);\n }\n if (req.url ~ \"\/fr\/\" && req.http.X-Language != \"fr\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Language)\";\n return(pass);\n }\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Language)\";\n return(pass);\n }\n\n if (req.url ~ \"\/(ab|bc|mb|nb|nl|ns|nt|nu|on|pe|qc|sk|yt)\/\") {\n {% for province in ['ab', 'bc', 'mb', 'nb', 'nl', 'ns', 'nt', 'nu', 'on', 'pe', 'qc', 'sk', 'yt'] %}\n if (req.url ~ \"{{ province }}\" && req.http.X-Province != \"{{ province }}\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Province)\";\n return(pass);\n }\n {% endfor %}\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Province)\";\n return(pass);\n }\n{% endif %}\n\n{% if varnish_blacklist_enabled %}\n if ((req.url ~ \"{{ varnish_blacklist_regexp }}\")) {\n set req.http.X-Passthrough-Reason = \"Path in Blacklist\";\n return(pass);\n } else {\n{% if varnish_discards_client_cookies %}\n unset req.http.Cookie;\n{% endif %}\n }\n{% endif %}\n\n}\n\n###\n# vcl_hit\n# Called when a cache lookup is successful.\n###\n# The vcl_hit subroutine may terminate with calling return() with one of the following keywords:\n#\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n# deliver\n# Deliver the object. Control passes to vcl_deliver.\n# synth(status code, reason)\n# Return the specified status code to the client and abandon the request.\n###\n\nsub vcl_hit {\n if (obj.ttl > 0s) {\n return (deliver);\n }\n{% if varnish_health_checks_enabled %}\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (fetch);\n }\n{% else %}\n if (obj.ttl + obj.grace > 0s) {\n return (deliver);\n }\n\n return (fetch);\n{% endif %}\n}\n\n###\n# vcl_backend_response\n# Called after the response headers has been successfully retrieved from the backend.\n###\n# The vcl_backend_response subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Possibly insert the object into the cache, then deliver it to the Control will eventually pass to vcl_deliver.\n# abandon\n# Abandon the backend request and generates an error.\n# retry\n# Retry the backend transaction. Increases the retries counter. If the number of retries is higher than max_retries Varnish emits a guru meditation error.\n###\n\nsub vcl_backend_response {\n{% if varnish_workaround_telusdotcom_browser_profile %}\n if (bereq.http.X-Language) {\n set beresp.http.X-Language = bereq.http.X-Language;\n }\n if (bereq.http.X-Province) {\n set beresp.http.X-Province = bereq.http.X-Province;\n }\n{% endif %}\n\n{% if varnish_blacklist_enabled %}\n if (bereq.url ~ \"{{ varnish_blacklist_regexp }}\") {\n set beresp.http.X-Cacheable = \"NO:Path in Blacklist\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n if (bereq.http.X-Passthrough-Reason) {\n set beresp.http.X-Passthrough-Reason = bereq.http.X-Passthrough-Reason;\n return(deliver);\n } else {\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n }\n }\n{% else %}\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n{% endif %}\n\n{% if varnish_cache_diagnostics_enabled %}\n if (bereq.http.Cookie) {\n set beresp.http.X-Cacheable = \"NO:Cookie in Request\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO:Set-Cookie in Response\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.X-No-Cache) {\n set beresp.http.X-Cacheable = \"NO:X-No-Cache\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.ttl <= 0s) {\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n{% endif %}\n\n set beresp.grace = {{ varnish_grace_period }};\n}\n\n###\n# vcl_deliver\n# Called before a cached object is delivered to the client.\n###\n# The vcl_deliver subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Deliver the object to the client.\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n###\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n","old_contents":"vcl 4.0;\n\nimport directors;\nimport std;\n\n###\n# Varnish Documentation\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-built-in-subs.html\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/reference\/vcl.html\n##\n\n{% for backend in varnish_backend_hosts %}\nbackend application_{{ loop.index }} {\n .host = \"{{ backend }}\";\n .port = \"{{ varnish_backend_port }}\";\n{% if varnish_health_checks_enabled %}\n .probe = {\n .url = \"{{ varnish_health_check_url }}\";\n .interval = {{ varnish_health_check_interval }};\n .timeout = {{ varnish_health_check_timeout }};\n .window = {{ varnish_health_check_window }};\n .threshold = {{ varnish_health_check_threshold }};\n }\n{% endif %}\n}\n{% endfor %}\n\n###\n# vcl_init\n# Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n###\n# The vcl_init subroutine may terminate with calling return() with one of the following keywords:\n#\n# ok\n# Normal return, VCL continues loading.\n##\n\nsub vcl_init {\n new application = directors.round_robin();\n{% for backend in varnish_backend_hosts %}\n application.add_backend(application_{{ loop.index }});\n{% endfor %}\n}\n\n###\n# vcl_recv\n# Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use. \n# It is also used to modify the request\n###\n# The vcl_recv subroutine may terminate with calling return() on one of the following keywords:\n#\n# synth(status code, reason)\n# Return a synthetic object with the specified status code to the client and abandon the request.\n# pass\n# Switch to pass mode. Control will eventually pass to vcl_pass.\n# pipe\n# Switch to pipe mode. Control will eventually pass to vcl_pipe.\n# hash\n# Continue processing the object as a potential candidate for caching. Passes the control over to vcl_hash.\n# purge\n# Purge the object and it's variants. Control passes through vcl_hash to vcl_purge.\n#\n\nsub vcl_recv {\n set req.backend_hint = application.backend();\n\n ###\n # Avoid processing uncacheable requests\n ###\n\n if (req.http.Authorization) {\n return (pass);\n }\n\n ###\n # Inject X-Forwarded-For headers, but only once.\n ###\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n{% if varnish_header_sanitization_enabled %}\n ###\n # Header Sanitization\n ###\n\n{% if varnish_discards_port_from_host_header %}\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n{% endif %}\n\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_enabled %}\n ###\n # Cookie Sanitization\n ###\n\n ### Google Analytics\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n\n ### Quantcast\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n \n ### AddThis\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n\n ### General Cleanup\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n{% endif %}\n\n{% if varnish_uri_sanitization_enabled %}\n ###\n # URI Sanitization\n ###\n \n if (req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=\") {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n{% endif %}\n\n{% if varnish_workaround_telusdotcom_browser_profile %}\n ###\n # Workaround for BrowserProfile and Language\/Region Detection on TELUS.com\n ###\n\n if (req.http.Cookie ~ \"BrowserProfile\") {\n set req.http.X-Language = regsuball(req.http.Cookie, \"language..:\\\\.([^\\\\]*)\", \"\\1\");\n set req.http.X-Province = regsuball(req.http.Cookie, \"region..:\\\\.([^\\\\]*)\", \"\\1\");\n } else {\n if (req.http.Cookie ~ \"lang=\") {\n set req.http.X-Language = regsuball(req.http.Cookie, \"lang=([^;]*)\", \"\\1\");\n } else {\n set req.http.X-Language = \"en\";\n }\n\n if (req.http.Cookie ~ \"prov=\") {\n set req.http.X-Province = regsuball(req.http.Cookie, \"prov=([^;]*)\", \"\\1\");\n } else {\n set req.http.X-Province = \"BC\";\n }\n }\n\n if (req.url ~ \"\/(en|fr)\/\") {\n if (req.url ~ \"\/en\/\" && req.http.X-Language != \"en\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Language)\";\n return(pass);\n }\n if (req.url ~ \"\/fr\/\" && req.http.X-Language != \"fr\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Language)\";\n return(pass);\n }\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Language)\";\n return(pass);\n }\n\n if (req.url ~ \"\/(ab|bc|mb|nb|nl|ns|nt|nu|on|pe|qc|sk|yt)\/\") {\n {% for province in ['ab', 'bc', 'mb', 'nb', 'nl', 'ns', 'nt', 'nu', 'on', 'pe', 'qc', 'sk', 'yt'] %}\n if (req.url ~ \"{{ province }}\" && req.http.X-Province != \"{{ province }}\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Path and Cookie (Province)\";\n return(pass);\n }\n {% endfor %}\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Province)\";\n return(pass);\n }\n{% endif %}\n\n{% if varnish_blacklist_enabled %}\n if ((req.url ~ \"{{ varnish_blacklist_regexp }}\")) {\n set req.http.X-Passthrough-Reason = \"Path in Blacklist\";\n return(pass);\n } else {\n{% if varnish_discards_client_cookies %}\n unset req.http.Cookie;\n{% endif %}\n }\n{% endif %}\n\n}\n\n###\n# vcl_hit\n# Called when a cache lookup is successful.\n###\n# The vcl_hit subroutine may terminate with calling return() with one of the following keywords:\n#\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n# deliver\n# Deliver the object. Control passes to vcl_deliver.\n# synth(status code, reason)\n# Return the specified status code to the client and abandon the request.\n###\n\nsub vcl_hit {\n if (obj.ttl > 0s) {\n return (deliver);\n }\n{% if varnish_health_checks_enabled %}\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (fetch);\n }\n{% else %}\n if (obj.ttl + obj.grace > 0s) {\n return (deliver);\n }\n\n return (fetch);\n{% endif %}\n}\n\n###\n# vcl_backend_response\n# Called after the response headers has been successfully retrieved from the backend.\n###\n# The vcl_backend_response subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Possibly insert the object into the cache, then deliver it to the Control will eventually pass to vcl_deliver.\n# abandon\n# Abandon the backend request and generates an error.\n# retry\n# Retry the backend transaction. Increases the retries counter. If the number of retries is higher than max_retries Varnish emits a guru meditation error.\n###\n\nsub vcl_backend_response {\n{% if varnish_workaround_telusdotcom_browser_profile %}\n if (bereq.http.X-Language) {\n set beresp.http.X-Language = bereq.http.X-Language;\n }\n if (bereq.http.X-Province) {\n set beresp.http.X-Province = bereq.http.X-Province;\n }\n{% endif %}\n\n{% if varnish_blacklist_enabled %}\n if (bereq.url ~ \"{{ varnish_blacklist_regexp }}\") {\n set beresp.http.X-Cacheable = \"NO:Path in Blacklist\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n if (bereq.http.X-Passthrough-Reason) {\n set beresp.http.X-Passthrough-Reason = bereq.http.X-Passthrough-Reason;\n return(deliver);\n } else {\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n }\n }\n{% else %}\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n{% endif %}\n\n{% if varnish_cache_diagnostics_enabled %}\n if (bereq.http.Cookie) {\n set beresp.http.X-Cacheable = \"NO:Cookie in Request\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO:Set-Cookie in Response\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.X-No-Cache) {\n set beresp.http.X-Cacheable = \"NO:X-No-Cache\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.ttl <= 0s) {\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n{% endif %}\n\n set beresp.grace = {{ varnish_grace_period }};\n}\n\n###\n# vcl_deliver\n# Called before a cached object is delivered to the client.\n###\n# The vcl_deliver subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Deliver the object to the client.\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n###\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"d4dc04ccc6421e01eaf71566217f8b7504247f3b","subject":"Documentation for vcl_pipe and connection: close","message":"Documentation for vcl_pipe and connection: close\n\nNote in the default VCL that connection: close might be wanted.\n\n\ngit-svn-id: 7d4b18ab7d176792635d6a7a77dd8cbbea8e8daa@3852 d4fa192b-c00b-0410-8231-f00ffab90ce4\n","repos":"wikimedia\/operations-debs-varnish,ssm\/pkg-varnish,CartoDB\/Varnish-Cache,ssm\/pkg-varnish,wikimedia\/operations-debs-varnish,CartoDB\/Varnish-Cache,ssm\/pkg-varnish,CartoDB\/Varnish-Cache,wikimedia\/operations-debs-varnish,ssm\/pkg-varnish,wikimedia\/operations-debs-varnish,ssm\/pkg-varnish,wikimedia\/operations-debs-varnish","old_file":"bin\/varnishd\/default.vcl","new_file":"bin\/varnishd\/default.vcl","new_contents":"","old_contents":"","returncode":128,"stderr":"remote: Support for password authentication was removed on August 13, 2021.\nremote: Please see https:\/\/docs.github.com\/en\/get-started\/getting-started-with-git\/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.\nfatal: Authentication failed for 'https:\/\/github.com\/wikimedia\/operations-debs-varnish.git\/'\n","license":"bsd-2-clause","lang":"VCL"} {"commit":"838e8218874b88f7c153e1a0e050a87924669957","subject":"Added example of VCL-file to improve integration with Spree","message":"Added example of VCL-file to improve integration with Spree\n","repos":"fastly\/spree_fastly,fastly\/spree_fastly","old_file":"public\/fastly_default.vcl","new_file":"public\/fastly_default.vcl","new_contents":"","old_contents":"","returncode":128,"stderr":"remote: Support for password authentication was removed on August 13, 2021.\nremote: Please see https:\/\/docs.github.com\/en\/get-started\/getting-started-with-git\/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.\nfatal: Authentication failed for 'https:\/\/github.com\/fastly\/spree_fastly.git\/'\n","license":"bsd-3-clause","lang":"VCL"} {"commit":"aed2f99388d85393f2adff5081be3d9fcce7a78a","subject":"Add vcl sample from previous commit.","message":"Add vcl sample from previous commit.\n","repos":"crowell\/modpagespeed_tmp,crowell\/modpagespeed_tmp,crowell\/modpagespeed_tmp,crowell\/modpagespeed_tmp,crowell\/modpagespeed_tmp,crowell\/modpagespeed_tmp,crowell\/modpagespeed_tmp","old_file":"src\/install\/sample_conf.vcl","new_file":"src\/install\/sample_conf.vcl","new_contents":"\/*\n This is the minimal VCL configuration required for passing the Apache\n mod_pagespeed system tests. To install varnish and start the varnish\n server at the right port, do the following:\n 1) sudo apt-get install varnish\n 2) sudo vim \/etc\/default\/varnish and put in the following lines at the\n bottom of the file:\n DAEMON_OPTS=\"-a :8020 \\\n -T localhost:6082 \\\n -f \/etc\/varnish\/default.vcl \\\n -S \/etc\/varnish\/secret \\\n -s file,\/var\/lib\/varnish\/$INSTANCE\/varnish_storage.bin,1G\"\n 3) sudo cp \/path\/to\/install\/sample_conf.vcl \/etc\/varnish\/default.vcl\n 4) sudo service varnish restart\n*\/\n\nbackend default {\n # Location of Apache mod_pagespeed server.\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\n\nacl purge {\n # Purge requests are only allowed from localhost.\n \"localhost\";\n \"127.0.0.1\";\n}\n\nsub vcl_recv {\n if (req.request == \"PURGE\") {\n if (!client.ip ~ purge) {\n error 405 \"Not allowed.\";\n }\n return (lookup);\n }\n}\n\nsub vcl_hit {\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged.\";\n }\n}\n\nsub vcl_miss {\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged.\";\n }\n}\n\nsub vcl_fetch {\n # Cache everything for 30s.\n set beresp.ttl = 30s;\n set beresp.grace = 30s;\n set beresp.http.X-Cacheable = \"YES\";\n return (deliver);\n}\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'src\/install\/sample_conf.vcl' did not match any file(s) known to git\n","license":"apache-2.0","lang":"VCL"} {"commit":"1bad8fd25921c8c495ce28d19d8a8a70af2d6e57","subject":"Race condition fix","message":"Race condition fix\n","repos":"denen99\/libmd5varnish","old_file":"md5_v4.vcl","new_file":"md5_v4.vcl","new_contents":"#Add the following to your Varnish 4 vcl file\n#In varnish 4 inlice C disabled by default. You must enable it using -p vcc_allow_inline_c=true \n\nC{\n #include <dlfcn.h>\n #include <stdlib.h>\n #include <stdio.h>\n\nstatic const char* (*md5_hash)(char* str) = NULL;\n\n__attribute__((constructor)) void\nload_module()\n{\n const char* symbol_name = \"md5_hash\";\n const char* plugin_name = \"\/etc\/varnish\/modules\/md5\/libmd5varnish.so\";\n void* handle = NULL;\n\n handle = dlopen( plugin_name, RTLD_NOW );\n if (handle != NULL) {\n md5_hash = dlsym( handle, symbol_name );\n if (md5_hash == NULL)\n fprintf( stderr, \"\\nError: Could not load MD5 plugin:\\n%s\\n\\n\", dlerror() );\n else\n printf( \"MD5 plugin loaded successfully.\\n\");\n }\n else\n fprintf( stderr, \"\\nError: Could not load MD5 plugin:\\n%s\\n\\n\", dlerror() );\n}\n}C\n\n## An Example of How to use it in vcl_recv\n#\nsub vcl_recv { \n\n C{\n \/\/\\6X-MD5: - \\6 is length of string in octal encoding\n static const struct gethdr_s VGC_HDR_REQ_VARNISH_X_MD5 = {\n HDR_REQ, \"\\6X-MD5:\"\n };\n\n\n static const struct gethdr_s VGC_HDR_REQ_VARNISH_X_DIGEST = {\n HDR_REQ, \"\\24X-MD5-Digest-String:\"\n };\n\n char* md5DigestString = VRT_GetHdr(ctx, &VGC_HDR_REQ_VARNISH_X_DIGEST);\n const char* calculatedMD5 = (*md5_hash)(md5DigestString);\n VRT_SetHdr(ctx, &VGC_HDR_REQ_VARNISH_X_MD5, calculatedMD5, vrt_magic_string_end);\n free((char*)calculatedMD5);\n }C\n\n\n}\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'md5_v4.vcl' did not match any file(s) known to git\n","license":"bsd-2-clause","lang":"VCL"} {"commit":"8d9494516c54e1d5aa829dd3112321d09dab0fed","subject":"added default.cl 4.0 vcl file","message":"added default.cl 4.0 vcl file\n","repos":"vkhatri\/chef-varnish-ng","old_file":"files\/default\/default4.0.vcl","new_file":"files\/default\/default4.0.vcl","new_contents":"#\n# This is an example VCL file for Varnish.\n#\n# It does not do anything by default, delegating control to the\n# builtin VCL. The builtin VCL is called when there is no explicit\n# return statement.\n#\n# See the VCL chapters in the Users Guide at https:\/\/www.varnish-cache.org\/docs\/\n# and http:\/\/varnish-cache.org\/trac\/wiki\/VCLExamples for more examples.\n\n# Update for work with Varnish 4\n\n\n# Marker to tell the VCL compiler that this VCL has been adapted to the\n# new 4.0 format.\nvcl 4.0;\n\n# Default backend definition. Set this to point to your content server.\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n .connect_timeout = 600s;\n .first_byte_timeout = 600s;\n .between_bytes_timeout = 600s;\n .max_connections = 800;\n}\n\n# Only allow purging from specific IPs\nacl purge {\n \"localhost\";\n \"127.0.0.1\";\n}\n\n# This function is used when a request is send by a HTTP client (Browser)\nsub vcl_recv {\n # Normalize the header, remove the port (in case you're testing this on various TCP ports)\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n # Allow purging from ACL\n if (req.method == \"PURGE\") {\n # If not allowed then a error 405 is returned\n if (!client.ip ~ purge) {\n return(synth(405, \"This IP is not allowed to send PURGE requests.\"));\n }\n # If allowed, do a cache_lookup -> vlc_hit() or vlc_miss()\n return (purge);\n }\n\n # Post requests will not be cached\n if (req.http.Authorization || req.method == \"POST\") {\n return (pass);\n }\n\n # --- Wordpress specific configuration\n\n # Did not cache the RSS feed\n if (req.url ~ \"\/feed\") {\n return (pass);\n }\n\n # Blitz hack\n if (req.url ~ \"\/mu-.*\") {\n return (pass);\n }\n\n\n # Did not cache the admin and login pages\n if (req.url ~ \"\/wp-(login|admin)\") {\n return (pass);\n }\n\n # Do not cache the WooCommerce pages\n ### REMOVE IT IF YOU DO NOT USE WOOCOMMERCE ###\n if (req.url ~ \"\/(cart|my-account|checkout|addons|\/?add-to-cart=)\") {\n return (pass);\n }\n\n # Remove the \"has_js\" cookie\n set req.http.Cookie = regsuball(req.http.Cookie, \"has_js=[^;]+(; )?\", \"\");\n\n # Remove any Google Analytics based cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__utm.=[^;]+(; )?\", \"\");\n\n # Remove the Quant Capital cookies (added by some plugin, all __qca)\n set req.http.Cookie = regsuball(req.http.Cookie, \"__qc.=[^;]+(; )?\", \"\");\n\n # Remove the wp-settings-1 cookie\n set req.http.Cookie = regsuball(req.http.Cookie, \"wp-settings-1=[^;]+(; )?\", \"\");\n\n # Remove the wp-settings-time-1 cookie\n set req.http.Cookie = regsuball(req.http.Cookie, \"wp-settings-time-1=[^;]+(; )?\", \"\");\n\n # Remove the wp test cookie\n set req.http.Cookie = regsuball(req.http.Cookie, \"wordpress_test_cookie=[^;]+(; )?\", \"\");\n\n # Are there cookies left with only spaces or that are empty?\n if (req.http.cookie ~ \"^ *$\") {\n unset req.http.cookie;\n }\n\n # Cache the following files extensions\n if (req.url ~ \"\\.(css|js|png|gif|jp(e)?g|swf|ico)\") {\n unset req.http.cookie;\n }\n\n # Normalize Accept-Encoding header and compression\n # https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/vary.html\n if (req.http.Accept-Encoding) {\n # Do no compress compressed files...\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n\n # Check the cookies for wordpress-specific items\n if (req.http.Cookie ~ \"wordpress_\" || req.http.Cookie ~ \"comment_\") {\n return (pass);\n }\n if (!req.http.cookie) {\n unset req.http.cookie;\n }\n\n # --- End of Wordpress specific configuration\n\n # Did not cache HTTP authentication and HTTP Cookie\n if (req.http.Authorization || req.http.Cookie) {\n # Not cacheable by default\n return (pass);\n }\n\n # Cache all others requests\n return (hash);\n}\n\nsub vcl_pipe {\n return (pipe);\n}\n\nsub vcl_pass {\n return (fetch);\n}\n\n# The data on which the hashing will take place\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n\n # If the client supports compression, keep that in a different cache\n if (req.http.Accept-Encoding) {\n hash_data(req.http.Accept-Encoding);\n }\n\n return (lookup);\n}\n\n# This function is used when a request is sent by our backend (Nginx server)\nsub vcl_backend_response {\n # Remove some headers we never want to see\n unset beresp.http.Server;\n unset beresp.http.X-Powered-By;\n\n # For static content strip all backend cookies\n if (bereq.url ~ \"\\.(css|js|png|gif|jp(e?)g)|swf|ico\") {\n unset beresp.http.cookie;\n }\n\n # Only allow cookies to be set if we're in admin area\n if (beresp.http.Set-Cookie && bereq.url !~ \"^\/wp-(login|admin)\") {\n unset beresp.http.Set-Cookie;\n }\n\n # don't cache response to posted requests or those with basic auth\n if ( bereq.method == \"POST\" || bereq.http.Authorization ) {\n set beresp.uncacheable = true;\n set beresp.ttl = 120s;\n return (deliver);\n }\n\n # don't cache search results\n if ( bereq.url ~ \"\\?s=\" ){\n set beresp.uncacheable = true;\n set beresp.ttl = 120s;\n return (deliver);\n }\n\n # only cache status ok\n if ( beresp.status != 200 ) {\n set beresp.uncacheable = true;\n set beresp.ttl = 120s;\n return (deliver);\n }\n\n # A TTL of 24h\n set beresp.ttl = 24h;\n # Define the default grace period to serve cached content\n set beresp.grace = 30s;\n\n return (deliver);\n}\n\n# The routine when we deliver the HTTP request to the user\n# Last chance to modify headers that are sent to the client\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"cached\";\n } else {\n set resp.http.x-Cache = \"uncached\";\n }\n\n # Remove some headers: PHP version\n unset resp.http.X-Powered-By;\n\n # Remove some headers: Apache version & OS\n unset resp.http.Server;\n\n # Remove some heanders: Varnish\n unset resp.http.Via;\n unset resp.http.X-Varnish;\n\n return (deliver);\n}\n\nsub vcl_init {\n return (ok);\n}\n\nsub vcl_fini {\n return (ok);\n}\n\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'files\/default\/default4.0.vcl' did not match any file(s) known to git\n","license":"apache-2.0","lang":"VCL"} {"commit":"d1c9065c45cb85804f4e1679955eb857266af5b4","subject":"Added example vcl to use in front of zope+plone (this could perhaps go in a contrib\/ directory instead)","message":"Added example vcl to use in front of zope+plone (this could perhaps go in a contrib\/ directory instead)\n\ngit-svn-id: 7d4b18ab7d176792635d6a7a77dd8cbbea8e8daa@1427 d4fa192b-c00b-0410-8231-f00ffab90ce4\n","repos":"ssm\/pkg-varnish,wikimedia\/operations-debs-varnish,ssm\/pkg-varnish,ssm\/pkg-varnish,wikimedia\/operations-debs-varnish,wikimedia\/operations-debs-varnish,wikimedia\/operations-debs-varnish,CartoDB\/Varnish-Cache,CartoDB\/Varnish-Cache,wikimedia\/operations-debs-varnish,CartoDB\/Varnish-Cache,ssm\/pkg-varnish,ssm\/pkg-varnish","old_file":"etc\/zope-plone.vcl","new_file":"etc\/zope-plone.vcl","new_contents":"","old_contents":"","returncode":128,"stderr":"remote: Support for password authentication was removed on August 13, 2021.\nremote: Please see https:\/\/docs.github.com\/en\/get-started\/getting-started-with-git\/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.\nfatal: Authentication failed for 'https:\/\/github.com\/wikimedia\/operations-debs-varnish.git\/'\n","license":"bsd-2-clause","lang":"VCL"} {"commit":"e631d319167d1f8a576bebc91e3b2b4f999ef15c","subject":"Add a skeleton VCL file to help new users along.","message":"Add a skeleton VCL file to help new users along.\n","repos":"franciscovg\/Varnish-Cache,alarky\/varnish-cache-doc-ja,gauthier-delacroix\/Varnish-Cache,zhoualbeart\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,chrismoulton\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,feld\/Varnish-Cache,alarky\/varnish-cache-doc-ja,feld\/Varnish-Cache,mrhmouse\/Varnish-Cache,franciscovg\/Varnish-Cache,chrismoulton\/Varnish-Cache,franciscovg\/Varnish-Cache,varnish\/Varnish-Cache,chrismoulton\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,feld\/Varnish-Cache,alarky\/varnish-cache-doc-ja,mrhmouse\/Varnish-Cache,franciscovg\/Varnish-Cache,franciscovg\/Varnish-Cache,gquintard\/Varnish-Cache,zhoualbeart\/Varnish-Cache,zhoualbeart\/Varnish-Cache,mrhmouse\/Varnish-Cache,feld\/Varnish-Cache,varnish\/Varnish-Cache,mrhmouse\/Varnish-Cache,varnish\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,chrismoulton\/Varnish-Cache,zhoualbeart\/Varnish-Cache,alarky\/varnish-cache-doc-ja,gauthier-delacroix\/Varnish-Cache,chrismoulton\/Varnish-Cache,mrhmouse\/Varnish-Cache,alarky\/varnish-cache-doc-ja,gquintard\/Varnish-Cache,varnish\/Varnish-Cache,zhoualbeart\/Varnish-Cache,gquintard\/Varnish-Cache,gquintard\/Varnish-Cache,varnish\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,feld\/Varnish-Cache","old_file":"etc\/example.vcl","new_file":"etc\/example.vcl","new_contents":"","old_contents":"","returncode":128,"stderr":"remote: Support for password authentication was removed on August 13, 2021.\nremote: Please see https:\/\/docs.github.com\/en\/get-started\/getting-started-with-git\/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.\nfatal: Authentication failed for 'https:\/\/github.com\/alarky\/varnish-cache-doc-ja.git\/'\n","license":"bsd-2-clause","lang":"VCL"} {"commit":"6df4bd58c72a0255f0f226a0cd27632ba2262a3c","subject":"updating varnish conf","message":"updating varnish conf\n","repos":"cristianocasella\/cristianocasella.com,cristianocasella\/cristianocasella.com","old_file":"varnish\/varnish.vcl","new_file":"varnish\/varnish.vcl","new_contents":"","old_contents":"","returncode":128,"stderr":"remote: Support for password authentication was removed on August 13, 2021.\nremote: Please see https:\/\/docs.github.com\/en\/get-started\/getting-started-with-git\/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.\nfatal: Authentication failed for 'https:\/\/github.com\/cristianocasella\/cristianocasella.com.git\/'\n","license":"mit","lang":"VCL"} {"commit":"d437081c41f3487667b4cd1370bf6e1f07842bce","subject":"comment reformatting on drupal_base.vcl","message":"comment reformatting on drupal_base.vcl\n","repos":"NITEMAN\/varnish-bites,NITEMAN\/Varnish_VCL_samps-hacks","old_file":"varnish 3 vcls\/drupal_base.vcl","new_file":"varnish 3 vcls\/drupal_base.vcl","new_contents":"","old_contents":"","returncode":1,"stderr":"error: pathspec 'varnish' did not match any file(s) known to git\nerror: pathspec '3' did not match any file(s) known to git\nerror: pathspec 'vcls\/drupal_base.vcl' did not match any file(s) known to git\n","license":"unknown","lang":"VCL"} {"commit":"07a2c002014721dc9477dc7a5e1ad51b1d4bf45c","subject":"added sample config for gzipping content on Varnish","message":"added sample config for gzipping content on Varnish\n","repos":"NITEMAN\/Varnish_VCL_samps-hacks,NITEMAN\/varnish-bites","old_file":"varnish 3 vcls\/drupal_base.vcl","new_file":"varnish 3 vcls\/drupal_base.vcl","new_contents":"","old_contents":"","returncode":1,"stderr":"error: pathspec 'varnish' did not match any file(s) known to git\nerror: pathspec '3' did not match any file(s) known to git\nerror: pathspec 'vcls\/drupal_base.vcl' did not match any file(s) known to git\n","license":"unknown","lang":"VCL"} {"commit":"f45cea4402bf71efc25d8159516fe261d9fcb6a7","subject":"comment and code reformatting on drupal_base.vcl","message":"comment and code reformatting on drupal_base.vcl\n","repos":"NITEMAN\/varnish-bites,NITEMAN\/Varnish_VCL_samps-hacks","old_file":"varnish 3 vcls\/drupal_base.vcl","new_file":"varnish 3 vcls\/drupal_base.vcl","new_contents":"","old_contents":"","returncode":128,"stderr":"fatal: unable to access 'https:\/\/github.com\/NITEMAN\/Varnish_VCL_samps-hacks.git\/': The requested URL returned error: 403\n","license":"unknown","lang":"VCL"} {"commit":"c0e0b9dfba0dc9d89c766f5ce1b260b2d588d56c","subject":"adding default.vcl file","message":"adding default.vcl file\n","repos":"varnish\/zipnish,varnish\/varnish-microservice-monitor,varnish\/varnish-microservice-monitor,varnish\/zipnish,varnish\/varnish-microservice-monitor,varnish\/zipnish,varnish\/varnish-microservice-monitor,varnish\/zipnish,varnish\/zipnish,varnish\/varnish-microservice-monitor","old_file":"default.vcl","new_file":"default.vcl","new_contents":"backend default {\n .host = \"127.0.0.1\";\n .port = \"9000\";\n}\n\nsub vcl_recv {\n\treturn (pass);\n}\n\nsub vcl_backend_response {\n}\n\nsub vcl_deliver {\n}\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'default.vcl' did not match any file(s) known to git\n","license":"bsd-2-clause","lang":"VCL"} {"commit":"4714540615b58402e7dda3adbef4562d9537576c","subject":"Add default.vcl Varnish file","message":"Add default.vcl Varnish file\n","repos":"Wildhoney\/AnsibleAlexa","old_file":"ansible\/files\/varnish\/default.vcl","new_file":"ansible\/files\/varnish\/default.vcl","new_contents":"C{\n#include <stdlib.h>\n#include <stdio.h>\n#include <time.h>\n#include <pthread.h>\nstatic pthread_mutex_t lrand_mutex = PTHREAD_MUTEX_INITIALIZER;\nvoid generate_uuid(char* buf) {\npthread_mutex_lock(&lrand_mutex);\nlong a = lrand48();\nlong b = lrand48();\nlong c = lrand48();\nlong d = lrand48();\npthread_mutex_unlock(&lrand_mutex);\n\/\/ SID must match this regex for Kount compat \/^\\w{1,32}$\/\nsprintf(buf, \"frontend=%08lx%04lx%04lx%04lx%04lx%08lx\",\na,\nb & 0xffff,\n(b & ((long)0x0fff0000) >> 16) | 0x4000,\n(c & 0x0fff) | 0x8000,\n(c & (long)0xffff0000) >> 16,\nd\n);\nreturn;\n}\n}C\nimport std;\nbackend default {\n.host = \"127.0.0.1\";\n.port = \"8080\";\n.first_byte_timeout = 300s;\n.between_bytes_timeout = 300s;\n}\nbackend admin {\n.host = \"127.0.0.1\";\n.port = \"8080\";\n.first_byte_timeout = 21600s;\n.between_bytes_timeout = 21600s;\n}\nacl crawler_acl {\n\"127.0.0.1\";\n}\nacl debug_acl {\n}\nsub generate_session {\nif (req.url ~ \".*[&?]SID=([^&]+).*\") {\nset req.http.X-Varnish-Faked-Session = regsub(\nreq.url, \".*[&?]SID=([^&]+).*\", \"frontend=\\1\");\n} else {\nC{\nchar uuid_buf [50];\ngenerate_uuid(uuid_buf);\nVRT_SetHdr(sp, HDR_REQ,\n\"\\030X-Varnish-Faked-Session:\",\nuuid_buf,\nvrt_magic_string_end\n);\n}C\n}\nif (req.http.Cookie) {\nstd.collect(req.http.Cookie);\nset req.http.Cookie = req.http.X-Varnish-Faked-Session +\n\"; \" + req.http.Cookie;\n} else {\nset req.http.Cookie = req.http.X-Varnish-Faked-Session;\n}\n}\nsub generate_session_expires {\nC{\ntime_t now = time(NULL);\nstruct tm now_tm = *gmtime(&now);\nnow_tm.tm_sec += 86400;\nmktime(&now_tm);\nchar date_buf [50];\nstrftime(date_buf, sizeof(date_buf)-1, \"%a, %d-%b-%Y %H:%M:%S %Z\", &now_tm);\nVRT_SetHdr(sp, HDR_RESP,\n\"\\031X-Varnish-Cookie-Expires:\",\ndate_buf,\nvrt_magic_string_end\n);\n}C\n}\nsub vcl_recv {\nif (req.restarts == 0) {\nif (req.http.X-Forwarded-For) {\nset req.http.X-Forwarded-For =\nreq.http.X-Forwarded-For + \", \" + client.ip;\n} else {\nset req.http.X-Forwarded-For = client.ip;\n}\n}\nif (!true || req.http.Authorization ||\nreq.request !~ \"^(GET|HEAD)$\" ||\nreq.http.Cookie ~ \"varnish_bypass=1\") {\nreturn (pipe);\n}\nset req.url = regsuball(req.url, \"(.*)\/\/+(.*)\", \"\\1\/\\2\");\nif (req.http.Accept-Encoding) {\nif (req.http.Accept-Encoding ~ \"gzip\") {\nset req.http.Accept-Encoding = \"gzip\";\n} else if (req.http.Accept-Encoding ~ \"deflate\") {\nset req.http.Accept-Encoding = \"deflate\";\n} else {\nunset req.http.Accept-Encoding;\n}\n}\nif (req.url ~ \"^(\/media\/|\/skin\/|\/js\/|\/)(?:(?:index|lightspeed)\\.php\/)?\") {\nset req.http.X-Turpentine-Secret-Handshake = \"1\";\nif (req.url ~ \"^(\/media\/|\/skin\/|\/js\/|\/)(?:(?:index|lightspeed)\\.php\/)?alexpie\") {\nset req.backend = admin;\nreturn (pipe);\n}\nif (req.http.Cookie ~ \"\\bcurrency=\") {\nset req.http.X-Varnish-Currency = regsub(\nreq.http.Cookie, \".*\\bcurrency=([^;]*).*\", \"\\1\");\n}\nif (req.http.Cookie ~ \"\\bstore=\") {\nset req.http.X-Varnish-Store = regsub(\nreq.http.Cookie, \".*\\bstore=([^;]*).*\", \"\\1\");\n}\nif (req.url ~ \"\/turpentine\/esi\/get(?:Block|FormKey)\/\") {\nset req.http.X-Varnish-Esi-Method = regsub(\nreq.url, \".*\/method\/(\\w+)\/.*\", \"\\1\");\nset req.http.X-Varnish-Esi-Access = regsub(\nreq.url, \".*\/access\/(\\w+)\/.*\", \"\\1\");\nif (req.http.X-Varnish-Esi-Method == \"esi\" && req.esi_level == 0 &&\n!(true || client.ip ~ debug_acl)) {\nerror 403 \"External ESI requests are not allowed\";\n}\n}\nif (req.http.Cookie !~ \"frontend=\") {\nif (client.ip ~ crawler_acl ||\nreq.http.User-Agent ~ \"^(?:ApacheBench\/.*|.*Googlebot.*|JoeDog\/.*Siege.*|magespeedtest\\.com|Nexcessnet_Turpentine\/.*)$\") {\nset req.http.Cookie = \"frontend=crawler-session\";\n} else {\ncall generate_session;\n}\n}\nif (true &&\nreq.url ~ \".*\\.(?:css|js|jpe?g|png|gif|ico|swf)(?=\\?|&|$)\") {\nunset req.http.Cookie;\nunset req.http.X-Varnish-Faked-Session;\nreturn (lookup);\n}\nif (req.url ~ \"^(\/media\/|\/skin\/|\/js\/|\/)(?:(?:index|lightspeed)\\.php\/)?(?:alexpie|api|cron\\.php)\" ||\nreq.url ~ \"\\?.*__from_store=\") {\nreturn (pipe);\n}\nif (true &&\nreq.url ~ \"(?:[?&](?:__SID|XDEBUG_PROFILE)(?=[&=]|$))\") {\nreturn (pass);\n}\nif (req.url ~ \"[?&](utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=\") {\nset req.url = regsuball(req.url, \"(?:(\\?)?|&)(?:utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=[^&]+\", \"\\1\");\nset req.url = regsuball(req.url, \"(?:(\\?)&|\\?$)\", \"\\1\");\n}\nreturn (lookup);\n}\n}\nsub vcl_pipe {\nunset bereq.http.X-Turpentine-Secret-Handshake;\nset bereq.http.Connection = \"close\";\n}\nsub vcl_hash {\nhash_data(req.url);\nif (req.http.Host) {\nhash_data(req.http.Host);\n} else {\nhash_data(server.ip);\n}\nhash_data(req.http.Ssl-Offloaded);\nif (req.http.X-Normalized-User-Agent) {\nhash_data(req.http.X-Normalized-User-Agent);\n}\nif (req.http.Accept-Encoding) {\nhash_data(req.http.Accept-Encoding);\n}\nif (req.http.X-Varnish-Store || req.http.X-Varnish-Currency) {\nhash_data(\"s=\" + req.http.X-Varnish-Store + \"&c=\" + req.http.X-Varnish-Currency);\n}\nif (req.http.X-Varnish-Esi-Access == \"private\" &&\nreq.http.Cookie ~ \"frontend=\") {\nhash_data(regsub(req.http.Cookie, \"^.*?frontend=([^;]*);*.*$\", \"\\1\"));\n}\nreturn (hash);\n}\nsub vcl_hit {\n}\nsub vcl_fetch {\nset req.grace = 15s;\nset beresp.http.X-Varnish-Host = req.http.host;\nset beresp.http.X-Varnish-URL = req.url;\nif (req.url ~ \"^(\/media\/|\/skin\/|\/js\/|\/)(?:(?:index|lightspeed)\\.php\/)?\") {\nunset beresp.http.Vary;\nset beresp.do_gzip = true;\nif (beresp.status != 200 && beresp.status != 404) {\nset beresp.ttl = 15s;\nreturn (hit_for_pass);\n} else {\nif (beresp.http.Set-Cookie) {\nset beresp.http.X-Varnish-Set-Cookie = beresp.http.Set-Cookie;\nunset beresp.http.Set-Cookie;\n}\nunset beresp.http.Cache-Control;\nunset beresp.http.Expires;\nunset beresp.http.Pragma;\nunset beresp.http.Cache;\nunset beresp.http.Age;\nif (beresp.http.X-Turpentine-Esi == \"1\") {\nset beresp.do_esi = true;\n}\nif (beresp.http.X-Turpentine-Cache == \"0\") {\nset beresp.ttl = 15s;\nreturn (hit_for_pass);\n} else {\nif (true &&\nbereq.url ~ \".*\\.(?:css|js|jpe?g|png|gif|ico|swf)(?=\\?|&|$)\") {\nset beresp.ttl = 28800s;\nset beresp.http.Cache-Control = \"max-age=28800\";\n} elseif (req.http.X-Varnish-Esi-Method) {\nif (req.http.X-Varnish-Esi-Access == \"private\" &&\nreq.http.Cookie ~ \"frontend=\") {\nset beresp.http.X-Varnish-Session = regsub(req.http.Cookie,\n\"^.*?frontend=([^;]*);*.*$\", \"\\1\");\n}\nif (req.http.X-Varnish-Esi-Method == \"ajax\" &&\nreq.http.X-Varnish-Esi-Access == \"public\") {\nset beresp.http.Cache-Control = \"max-age=\" + regsub(\nreq.url, \".*\/ttl\/(\\d+)\/.*\", \"\\1\");\n}\nset beresp.ttl = std.duration(\nregsub(\nreq.url, \".*\/ttl\/(\\d+)\/.*\", \"\\1s\"),\n300s);\nif (beresp.ttl == 0s) {\nset beresp.ttl = 15s;\nreturn (hit_for_pass);\n}\n} else {\nset beresp.ttl = 3600s;\n}\n}\n}\nreturn (deliver);\n}\n}\nsub vcl_deliver {\nif (req.http.X-Varnish-Faked-Session) {\ncall generate_session_expires;\nset resp.http.Set-Cookie = req.http.X-Varnish-Faked-Session +\n\"; expires=\" + resp.http.X-Varnish-Cookie-Expires + \"; path=\/\";\nif (req.http.Host) {\nset resp.http.Set-Cookie = resp.http.Set-Cookie +\n\"; domain=\" + regsub(req.http.Host, \":\\d+$\", \"\");\n}\nset resp.http.Set-Cookie = resp.http.Set-Cookie + \"; httponly\";\nunset resp.http.X-Varnish-Cookie-Expires;\n}\nif (req.http.X-Varnish-Esi-Method == \"ajax\" && req.http.X-Varnish-Esi-Access == \"private\") {\nset resp.http.Cache-Control = \"no-cache\";\n}\nif (true || client.ip ~ debug_acl) {\nset resp.http.X-Varnish-Hits = obj.hits;\nset resp.http.X-Varnish-Esi-Method = req.http.X-Varnish-Esi-Method;\nset resp.http.X-Varnish-Esi-Access = req.http.X-Varnish-Esi-Access;\nset resp.http.X-Varnish-Currency = req.http.X-Varnish-Currency;\nset resp.http.X-Varnish-Store = req.http.X-Varnish-Store;\n} else {\nunset resp.http.X-Varnish;\nunset resp.http.Via;\nunset resp.http.X-Powered-By;\nunset resp.http.Server;\nunset resp.http.X-Turpentine-Cache;\nunset resp.http.X-Turpentine-Esi;\nunset resp.http.X-Turpentine-Flush-Events;\nunset resp.http.X-Turpentine-Block;\nunset resp.http.X-Varnish-Session;\nunset resp.http.X-Varnish-Host;\nunset resp.http.X-Varnish-URL;\nunset resp.http.X-Varnish-Set-Cookie;\n}\n}","old_contents":"","returncode":1,"stderr":"error: pathspec 'ansible\/files\/varnish\/default.vcl' did not match any file(s) known to git\n","license":"mit","lang":"VCL"} {"commit":"7ec550fdd124d4f21e5e4357b1b4243408eb5b61","subject":"added the VCL code for the VEBAN method","message":"added the VCL code for the VEBAN method\n","repos":"thlc\/vbaner,thlc\/vbaner,thlc\/vbaner","old_file":"vcl\/veban.vcl","new_file":"vcl\/veban.vcl","new_contents":"# 1. VEBAN method\nsub vcl_recv {\n if (req.request == \"VEBAN\") {\n if (!client.ip ~ purge) {\n error 501 \"Method Not Implemented\";\n }\n if (req.http.X-VE-BanKey != \"complex-stuff-here\") {\n error 403 \"Forbidden\";\n }\n if (!req.http.X-VE-BanStr) {\n error 911 \"Bad VEBAN request (missing X-VE-BanStr)\";\n }\n ban(req.http.X-VE-BanStr);\n std.log(\"VEBAN added ban [\" + req.http.X-VE-BanStr + \"]\");\n error 910 \"VEBAN OK\";\n }\n}\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'vcl\/veban.vcl' did not match any file(s) known to git\n","license":"agpl-3.0","lang":"VCL"} {"commit":"9c845697ebc4419c6fb36c3cb1184cdf046f02ce","subject":"Create default.vcl","message":"Create default.vcl","repos":"rkruk\/Ubuntu-Nginx-PHP5-fpm-Varnish","old_file":"etc\/varnish\/default.vcl","new_file":"etc\/varnish\/default.vcl","new_contents":"# This is a basic VCL configuration file for varnish. See the vcl(7)\n# man page for details on VCL syntax and semantics.\n# \n# Default backend definition. Set this to point to your content\n# server.\n# \nbackend default {\n.host = \"127.0.0.1\";\n.port = \"8080\";\n.connect_timeout = 600s;\n.first_byte_timeout = 600s;\n.between_bytes_timeout = 600s;\n.max_connections = 800;\n\n}\n# Drop any cookies sent to WordPress.\nsub vcl_recv {\n if (!(req.url ~ \"wp-(login|admin)\")) {\n unset req.http.cookie;\n }\n}\n\n# Drop any cookies WordPress tries to send back to the client.\nsub vcl_fetch {\n if (!(req.url ~ \"wp-(login|admin)\")) {\n unset beresp.http.set-cookie;\n }\n}\n\n\nacl purge {\n \"localhost\";\n}\n\nsub vcl_recv {\n if (req.request == \"PURGE\") {\n if (!client.ip ~ purge) {\n error 405 \"Not allowed.\";\n }\n return(lookup);\n }\nif (req.url ~ \"^\/$\") {\n unset req.http.cookie;\n }\n}\nsub vcl_hit {\n if (req.request == \"PURGE\") {\n set obj.ttl = 0s;\n error 200 \"Purged.\";\n }\n}\nsub vcl_miss {\n if (req.request == \"PURGE\") {\n error 404 \"Not in cache.\";\n }\nif (!(req.url ~ \"wp-(login|admin)\")) {\n unset req.http.cookie;\n }\n if (req.url ~ \"^\/[^?]+.(jpeg|jpg|png|gif|ico|js|css|txt|gz|zip|lzma|bz2|tgz|tbz|html|htm)(\\?.|)$\") {\n unset req.http.cookie;\n set req.url = regsub(req.url, \"\\?.$\", \"\");\n }\n if (req.url ~ \"^\/$\") {\n unset req.http.cookie;\n }\n}\nsub vcl_fetch {\n if (req.url ~ \"^\/$\") {\n unset beresp.http.set-cookie;\n }\nif (!(req.url ~ \"wp-(login|admin)\")) {\n unset beresp.http.set-cookie;\n}\n\nset req.grace = 2m;\n\n# Set X-Forwarded-For header for logging in nginx\nremove req.http.X-Forwarded-For;\nset req.http.X-Forwarded-For = client.ip;\n\n# Remove has_js and CloudFlare\/Google Analytics __* cookies.\nset req.http.Cookie = regsuball(req.http.Cookie, \"(^|;\\s*)(_[_a-z]+|has_js)=[^;]*\", \"\");\n# Remove a \";\" prefix, if present.\nset req.http.Cookie = regsub(req.http.Cookie, \"^;\\s*\", \"\");\n\n# Remove the wp-settings-1 cookie\nset req.http.Cookie = regsuball(req.http.Cookie, \"wp-settings-1=[^;]+(; )?\", \"\");\n\n# Remove the wp-settings-time-1 cookie\nset req.http.Cookie = regsuball(req.http.Cookie, \"wp-settings-time-1=[^;]+(; )?\", \"\");\n\n# Remove the wp test cookie\nset req.http.Cookie = regsuball(req.http.Cookie, \"wordpress_test_cookie=[^;]+(; )?\", \"\");\n\n# Static content unique to the theme can be cached (so no user uploaded images)\n# The reason I don't take the wp-content\/uploads is because of cache size on bigger blogs\n# that would fill up with all those files getting pushed into cache\nif (req.url ~ \"wp-content\/themes\/\" && req.url ~ \"\\.(css|js|png|gif|jp(e)?g)\") {\n unset req.http.cookie;\n}\n}\n\nsub vcl_fetch {\n\t#set obj.grace = 5m;\n set beresp.grace = 2m;\n\n}\n\nsub vcl_hit {\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged.\";\n }\n}\n\nsub vcl_miss {\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged.\";\n }\n}\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'etc\/varnish\/default.vcl' did not match any file(s) known to git\n","license":"apache-2.0","lang":"VCL"} {"commit":"8f8fa659a8ae52638c94ea70a973ceceefe996ca","subject":"Create m2-default.vcl","message":"Create m2-default.vcl","repos":"whyneus\/magneto-ponies,whyneus\/magneto-ponies,whyneus\/magneto-ponies","old_file":"m2-default.vcl","new_file":"m2-default.vcl","new_contents":"vcl 4.0;\n \nimport std;\n# The minimal Varnish version is 4.0\n \nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n .first_byte_timeout = 1000s;\n}\n\nacl purge {\n \"127.0.0.1\";\n}\n\nsub vcl_recv {\n if (req.method == \"PURGE\") {\n if (client.ip !~ purge) {\n return (synth(405, \"Method not allowed\"));\n }\n if (!req.http.X-Magento-Tags-Pattern) {\n return (synth(400, \"X-Magento-Tags-Pattern header required\"));\n }\n ban(\"obj.http.X-Magento-Tags ~ \" + req.http.X-Magento-Tags-Pattern);\n return (synth(200, \"Purged\"));\n }\n \n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n \n # We only deal with GET and HEAD by default\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n # Bypass shopping cart and checkout requests\n if (req.url ~ \"\/checkout\") {\n return (pass);\n }\n\n # normalize url in case of leading HTTP scheme and domain\n set req.url = regsub(req.url, \"^http[s]?:\/\/\", \"\");\n\n # collect all cookies\n std.collect(req.http.Cookie);\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.url ~ \"^\/(pub\/)?(media|static)\/.*\\.(ico|css|js|jpg|jpeg|png|gif|tiff|bmp|mp3|ogg|svg|swf|woff|woff2|eot|ttf|otf)$\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n\n return (hash);\n}\n\nsub vcl_hash {\n if (req.http.cookie ~ \"X-Magento-Vary=\") {\n hash_data(regsub(req.http.cookie, \"^.*?X-Magento-Vary=([^;]+);*.*$\", \"\\1\"));\n }\n \n}\n\nsub vcl_backend_response {\n if (beresp.http.content-type ~ \"text\") {\n set beresp.do_esi = true;\n }\n\n if (bereq.url ~ \"\\.js$\" || beresp.http.content-type ~ \"text\") {\n set beresp.do_gzip = true;\n }\n \n # cache only successfully responses and 404s\n if (beresp.status != 200 && beresp.status != 404) {\n set beresp.ttl = 0s;\n set beresp.uncacheable = true;\n return (deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.uncacheable = true;\n set beresp.ttl = 86400s;\n return (deliver);\n }\n\n if (beresp.http.X-Magento-Debug) {\n set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;\n }\n\n # validate if we need to cache it and prevent from setting cookie\n # images, css and js are cacheable by default so we have to remove cookie also\n if (beresp.ttl > 0s && (bereq.method == \"GET\" || bereq.method == \"HEAD\")) {\n unset beresp.http.set-cookie;\n if (bereq.url !~ \"\\.(ico|css|js|jpg|jpeg|png|gif|tiff|bmp|gz|tgz|bz2|tbz|mp3|ogg|svg|swf|woff|woff2|eot|ttf|otf)(\\?|$)\") {\n set beresp.http.Pragma = \"no-cache\";\n set beresp.http.Expires = \"-1\";\n set beresp.http.Cache-Control = \"no-store, no-cache, must-revalidate, max-age=0\";\n set beresp.grace = 1m;\n }\n }\n return (deliver);\n}\n\nsub vcl_deliver {\n if (resp.http.X-Magento-Debug) {\n if (resp.http.x-varnish ~ \" \") {\n set resp.http.X-Magento-Cache-Debug = \"HIT\";\n } else {\n set resp.http.X-Magento-Cache-Debug = \"MISS\";\n }\n } else {\n unset resp.http.Age;\n }\n\n unset resp.http.X-Magento-Debug;\n unset resp.http.X-Magento-Tags;\n unset resp.http.X-Powered-By;\n unset resp.http.Server;\n unset resp.http.X-Varnish;\n unset resp.http.Via;\n unset resp.http.Link;\n}\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'm2-default.vcl' did not match any file(s) known to git\n","license":"mit","lang":"VCL"} {"commit":"858898510fe77550ac6550a6b306b5c7a2b93d31","subject":"Revert accidental change to backend port in Varnish config example (3000 is misleading as it suggests we recommend using Rack as the default backend)","message":"Revert accidental change to backend port in Varnish config example (3000 is misleading as it suggests we recommend using Rack as the default backend)","repos":"obshtestvo\/alaveteli-bulgaria,andreicristianpetcu\/alaveteli_old,datauy\/alaveteli,TEDICpy\/QueremoSaber,nzherald\/alaveteli,obshtestvo\/alaveteli-bulgaria,Br3nda\/alaveteli,TEDICpy\/QueremoSaber,hasadna\/alaveteli,andreicristianpetcu\/alaveteli_old,hasadna\/alaveteli,sarhane\/alaveteli-test,sarhane\/alaveteli-test,Br3nda\/alaveteli,andreicristianpetcu\/alaveteli_old,TEDICpy\/QueremoSaber,obshtestvo\/alaveteli-bulgaria,andreicristianpetcu\/alaveteli,4bic\/alaveteli,10layer\/alaveteli,petterreinholdtsen\/alaveteli,codeforcroatia\/alaveteli,nzherald\/alaveteli,andreicristianpetcu\/alaveteli,hasadna\/alaveteli,obshtestvo\/alaveteli-bulgaria,andreicristianpetcu\/alaveteli_old,TEDICpy\/QueremoSaber,4bic\/alaveteli,Br3nda\/alaveteli,codeforcroatia\/alaveteli,10layer\/alaveteli,sarhane\/alaveteli-test,nzherald\/alaveteli,10layer\/alaveteli,andreicristianpetcu\/alaveteli,TEDICpy\/QueremoSaber,petterreinholdtsen\/alaveteli,nzherald\/alaveteli,andreicristianpetcu\/alaveteli,Br3nda\/alaveteli,hasadna\/alaveteli,datauy\/alaveteli,obshtestvo\/alaveteli-bulgaria,codeforcroatia\/alaveteli,4bic\/alaveteli,petterreinholdtsen\/alaveteli,petterreinholdtsen\/alaveteli,4bic\/alaveteli,andreicristianpetcu\/alaveteli,Br3nda\/alaveteli,hasadna\/alaveteli,datauy\/alaveteli,petterreinholdtsen\/alaveteli,sarhane\/alaveteli-test,nzherald\/alaveteli,4bic\/alaveteli,hasadna\/alaveteli,codeforcroatia\/alaveteli,andreicristianpetcu\/alaveteli_old","old_file":"config\/varnish-alaveteli.vcl","new_file":"config\/varnish-alaveteli.vcl","new_contents":"","old_contents":"","returncode":128,"stderr":"remote: Support for password authentication was removed on August 13, 2021.\nremote: Please see https:\/\/docs.github.com\/en\/get-started\/getting-started-with-git\/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.\nfatal: Authentication failed for 'https:\/\/github.com\/4bic\/alaveteli.git\/'\n","license":"agpl-3.0","lang":"VCL"} {"commit":"e406a07104746e548f8ec578f693e7b406a32dc2","subject":"fixing ip address for backend","message":"fixing ip address for backend\n","repos":"cristianocasella\/cristianocasella.com,cristianocasella\/cristianocasella.com","old_file":"varnish\/varnish.vcl","new_file":"varnish\/varnish.vcl","new_contents":"","old_contents":"","returncode":128,"stderr":"remote: Support for password authentication was removed on August 13, 2021.\nremote: Please see https:\/\/docs.github.com\/en\/get-started\/getting-started-with-git\/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.\nfatal: Authentication failed for 'https:\/\/github.com\/cristianocasella\/cristianocasella.com.git\/'\n","license":"mit","lang":"VCL"} {"commit":"e13dbbdccfd3550076469e83536b8bd10315a26b","subject":"Don't strip last_seen_* cookies. Fixes #405","message":"Don't strip last_seen_* cookies. Fixes #405\n","repos":"Br3nda\/alaveteli,sarhane\/alaveteli-test,andreicristianpetcu\/alaveteli_old,obshtestvo\/alaveteli-bulgaria,datauy\/alaveteli,nzherald\/alaveteli,4bic\/alaveteli,hasadna\/alaveteli,petterreinholdtsen\/alaveteli,petterreinholdtsen\/alaveteli,4bic\/alaveteli,petterreinholdtsen\/alaveteli,hasadna\/alaveteli,nzherald\/alaveteli,datauy\/alaveteli,hasadna\/alaveteli,andreicristianpetcu\/alaveteli_old,hasadna\/alaveteli,4bic\/alaveteli,obshtestvo\/alaveteli-bulgaria,obshtestvo\/alaveteli-bulgaria,datauy\/alaveteli,codeforcroatia\/alaveteli,sarhane\/alaveteli-test,codeforcroatia\/alaveteli,andreicristianpetcu\/alaveteli_old,hasadna\/alaveteli,TEDICpy\/QueremoSaber,nzherald\/alaveteli,10layer\/alaveteli,codeforcroatia\/alaveteli,4bic\/alaveteli,10layer\/alaveteli,4bic\/alaveteli,petterreinholdtsen\/alaveteli,TEDICpy\/QueremoSaber,andreicristianpetcu\/alaveteli_old,andreicristianpetcu\/alaveteli_old,codeforcroatia\/alaveteli,obshtestvo\/alaveteli-bulgaria,andreicristianpetcu\/alaveteli,Br3nda\/alaveteli,Br3nda\/alaveteli,andreicristianpetcu\/alaveteli,TEDICpy\/QueremoSaber,10layer\/alaveteli,nzherald\/alaveteli,andreicristianpetcu\/alaveteli,TEDICpy\/QueremoSaber,Br3nda\/alaveteli,Br3nda\/alaveteli,obshtestvo\/alaveteli-bulgaria,sarhane\/alaveteli-test,petterreinholdtsen\/alaveteli,andreicristianpetcu\/alaveteli,sarhane\/alaveteli-test,TEDICpy\/QueremoSaber,hasadna\/alaveteli,nzherald\/alaveteli,andreicristianpetcu\/alaveteli","old_file":"config\/varnish-alaveteli.vcl","new_file":"config\/varnish-alaveteli.vcl","new_contents":"","old_contents":"","returncode":128,"stderr":"remote: Support for password authentication was removed on August 13, 2021.\nremote: Please see https:\/\/docs.github.com\/en\/get-started\/getting-started-with-git\/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.\nfatal: Authentication failed for 'https:\/\/github.com\/4bic\/alaveteli.git\/'\n","license":"agpl-3.0","lang":"VCL"} {"commit":"acd77ed194c2ba97fb32ed7f2ac72c4a4232e90a","subject":"added proper vary header to gzipping example","message":"added proper vary header to gzipping example\n","repos":"NITEMAN\/varnish-bites,NITEMAN\/Varnish_VCL_samps-hacks","old_file":"varnish 3 vcls\/drupal_base.vcl","new_file":"varnish 3 vcls\/drupal_base.vcl","new_contents":"","old_contents":"","returncode":1,"stderr":"error: pathspec 'varnish' did not match any file(s) known to git\nerror: pathspec '3' did not match any file(s) known to git\nerror: pathspec 'vcls\/drupal_base.vcl' did not match any file(s) known to git\n","license":"unknown","lang":"VCL"} {"commit":"df1c654c2cc8f691026ff18c100bd8696079901b","subject":"Add Varnish VCL test-file","message":"Add Varnish VCL test-file\n","repos":"sol\/pygments,sol\/pygments,sol\/pygments,sol\/pygments,sol\/pygments,sol\/pygments,sol\/pygments,sol\/pygments,sol\/pygments,sol\/pygments,sol\/pygments,sol\/pygments,sol\/pygments,sol\/pygments","old_file":"tests\/examplefiles\/varnish.vcl","new_file":"tests\/examplefiles\/varnish.vcl","new_contents":"","old_contents":"","returncode":128,"stderr":"fatal: unable to access 'https:\/\/github.com\/sol\/pygments.git\/': The requested URL returned error: 403\n","license":"bsd-2-clause","lang":"VCL"} {"commit":"825f89eca7b767375a0417a0691f0e92bc3a6d4f","subject":"more draft","message":"more draft\n","repos":"erezny\/twitter-import","old_file":"varnish\/twitter.vcl","new_file":"varnish\/twitter.vcl","new_contents":"","old_contents":"","returncode":128,"stderr":"remote: Support for password authentication was removed on August 13, 2021.\nremote: Please see https:\/\/docs.github.com\/en\/get-started\/getting-started-with-git\/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.\nfatal: Authentication failed for 'https:\/\/github.com\/erezny\/twitter-import.git\/'\n","license":"mit","lang":"VCL"} {"commit":"ccd5af05c701b729bd8d43db9aa44d2ff02875e9","subject":"tuning cache for static files","message":"tuning cache for static files\n","repos":"cristianocasella\/cristianocasella.com,cristianocasella\/cristianocasella.com","old_file":"varnish\/varnish.vcl","new_file":"varnish\/varnish.vcl","new_contents":"","old_contents":"","returncode":128,"stderr":"fatal: unable to access 'https:\/\/github.com\/cristianocasella\/cristianocasella.com.git\/': The requested URL returned error: 403\n","license":"mit","lang":"VCL"} {"commit":"6e82627374bd51a9c3041597579e72989219ecac","subject":"added gzip content-type","message":"added gzip content-type\n","repos":"NITEMAN\/varnish-bites,NITEMAN\/Varnish_VCL_samps-hacks","old_file":"varnish 3 vcls\/drupal_base.vcl","new_file":"varnish 3 vcls\/drupal_base.vcl","new_contents":"","old_contents":"","returncode":1,"stderr":"error: pathspec 'varnish' did not match any file(s) known to git\nerror: pathspec '3' did not match any file(s) known to git\nerror: pathspec 'vcls\/drupal_base.vcl' did not match any file(s) known to git\n","license":"unknown","lang":"VCL"} {"commit":"a2e892079253da24871d96902b4db5db7e61abcc","subject":"Add tarpitting of rate limited requests","message":"Add tarpitting of rate limited requests\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets_rate_limiting\/deliver.vcl","new_file":"etc\/vcl_snippets_rate_limiting\/deliver.vcl","new_contents":"# Tarpit Rate limited requests\nif ( resp.status == 429 && req.http.Rate-Limit ) {\n resp.tarpit(5, 100000);\n}\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'etc\/vcl_snippets_rate_limiting\/deliver.vcl' did not match any file(s) known to git\n","license":"bsd-3-clause","lang":"VCL"} {"commit":"281676c75b19d103b4aa0980d760b005080c8f4b","subject":"Added templates directory for the varnish template.","message":"Added templates directory for the varnish template.\n","repos":"mchao47\/Elasticd,FINRAOS\/Elasticd,gurumitts\/Elasticd,SMxJrz\/Elasticd,bryantrobbins\/Elasticd,bryantrobbins\/Elasticd,mchao47\/Elasticd,gurumitts\/Elasticd,FINRAOS\/Elasticd,SMxJrz\/Elasticd","old_file":"templates\/backend.vcl","new_file":"templates\/backend.vcl","new_contents":"The name is: {{ name }}","old_contents":"","returncode":1,"stderr":"error: pathspec 'templates\/backend.vcl' did not match any file(s) known to git\n","license":"apache-2.0","lang":"VCL"} {"commit":"3d72acac1589385d09651547d08970a65e9414a7","subject":"Create default.vcl","message":"Create default.vcl","repos":"torumaki\/config,torumaki\/config","old_file":"varnish3\/default.vcl","new_file":"varnish3\/default.vcl","new_contents":"backend default {\n .host = \"127.0.0.1\";\n .port = \"20080\";\n}\n\nsub vcl_recv {\n set req.hash_ignore_busy = true;\n if (req.restarts == 0) {\n if (req.http.x-forwarded-for) {\n set req.http.X-Forwarded-For =\n req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n error 403 \"Forbidden Method\";\n }\n\n set req.backend = default;\n set req.grace = 1h;\n\n return (lookup);\n}\n\nsub vcl_hash {\n\/***\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n***\/\n\n\/\/\/ if (req.url ~ \"\\?\") {\n\/\/\/ set req.http.X-TMP = regsub(req.url, \"^([^?]+).*\", \"\\1\");\n \/\/\/\/ DELETE parameter\n set req.http.X-TMP = regsub(req.url, \"\\?.*$\", \"\");\n hash_data(req.http.X-TMP);\n remove req.http.X-TMP;\n\/\/\/ }\n\n return (hash);\n}\n\nsub vcl_fetch {\n set beresp.grace = 1h;\n set beresp.ttl = 10s;\n\n if (beresp.status >= 400 && beresp.status < 500) {\n set beresp.ttl = 20s;\n }\n\n if (beresp.status >= 500 && beresp.status < 600) {\n set beresp.saintmode = 90s;\n return (restart);\n }\n\n \/\/ \u5727\u7e2e\u3055\u308c\u3066\u3044\u306a\u3044\u5834\u5408\u3001\u5727\u7e2e\u3059\u308b\n set beresp.do_gzip = true;\n\n \/\/ \u5727\u7e2e\u3055\u308c\u3066\u3044\u308b\u5834\u5408\u3001\u89e3\u51cd\u3059\u308b\n \/\/ set beresp.do_gunzip = true;\n\n return (deliver);\n}\n\nsub vcl_deliver {\n if(obj.hits > 0){\n set resp.http.X-Cache = \"Hit\";\n } else {\n set resp.http.X-Cache = \"Miss\";\n }\n}\n\nsub vcl_error {\n if((obj.status >= 100 && obj.status < 200)\n || obj.status == 204\n || obj.status == 304){\n return (deliver);\n }\n\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + obj.status + \" \" + obj.response + {\"<\/h1>\n <\/body>\n<\/html>\n\"};\n return (deliver);\n}\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'varnish3\/default.vcl' did not match any file(s) known to git\n","license":"mit","lang":"VCL"} {"commit":"7a6bedbc2d7bc74f4d1ced883508bd89ab822508","subject":"Updated with varnish-2","message":"Updated with varnish-2\n","repos":"kiranthomas\/sylius-docker,kiranthomas\/sylius-docker,kiranthomas\/sylius-docker,kiranthomas\/sylius-docker","old_file":"docker\/varnish\/default.vcl","new_file":"docker\/varnish\/default.vcl","new_contents":"","old_contents":"","returncode":128,"stderr":"fatal: unable to access 'https:\/\/github.com\/kiranthomas\/sylius-docker.git\/': The requested URL returned error: 403\n","license":"mit","lang":"VCL"} {"commit":"05153c67ee3fe801fe5d471010c658b9c31b00c4","subject":"first commit","message":"first commit\n","repos":"iraneagle\/Varnish-Drupal","old_file":"default.vcl","new_file":"default.vcl","new_contents":"# Marker to tell the VCL compiler that this VCL has been adapted to the\n# new 4.0 format.\nvcl 4.0;\n\n# Import VMod's\nimport std;\nimport directors;\n\n# Default backend definition. Set this to point to your content server.\nbackend default {\n .host = \"localhost\";\n .port = \"81\";\n .connect_timeout = 600s;\n .first_byte_timeout = 600s;\n .between_bytes_timeout = 600s;\n .max_connections = 300;\n}\n\n# Only allow purging from specific IPs\nacl purge {\n \"localhost\";\n \"127.0.0.1\";\n \"::1\";\n}\n\nacl internal {\n \"127.0.0.0\"\/24;\n # For remote access, add your IP address here.\n # Ex: 162.xxx.xx.xx\n}\n\n# This function is used when a request is send by a HTTP client (Browser) \nsub vcl_recv {\n # Normalize the header, remove the port (in case you're testing this on various TCP ports)\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n # Normalize the query arguments\n set req.url = std.querysort(req.url);\n\n # Check if request is allowed to invoke cache purge, Allow purging.\n if (req.method == \"PURGE\") {\n if (!client.ip ~ purge) { \n # purge is the ACL defined at the begining\n # Not from an allowed IP? Then die with an error.\n return (synth(405, \"Forbidden - Not allowed.\"));\n }\n # If you got this stage (and didn't error out above), purge the cached result\n return (purge);\n }\n\n # Verify HTTP request methods\n # Only deal with \"normal\" types.\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"PATCH\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n # Implementing websocket support (https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html)\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n # Only cache GET or HEAD requests. This makes sure the POST requests are always passed.\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n\n #if (req.http.Authorization || req.http.Cookie) {\n \/* Not cacheable by default *\/\n #return (pass);\n #}\n\n # Some generic URL manipulation, useful for all templates that follow\n # First remove the Google Analytics added parameters, useless for our backend\n if (req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=\") {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # Strip hash, server doesn't need it.\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n # Strip a trailing ? if it exists\n if (req.url ~ \"\\?$\") {\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # Some generic cookie manipulation, useful for all templates that follow\n # Remove the \"has_js\" cookie\n set req.http.Cookie = regsuball(req.http.Cookie, \"has_js=[^;]+(; )?\", \"\");\n\n # Remove any Google Analytics based cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__utm.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"_ga=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"_gat=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmctr=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmcmd.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmccn.=[^;]+(; )?\", \"\");\n\n # Remove DoubleClick offensive cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__gads=[^;]+(; )?\", \"\");\n\n # Remove the Quant Capital cookies (added by some plugin, all __qca)\n set req.http.Cookie = regsuball(req.http.Cookie, \"__qc.=[^;]+(; )?\", \"\");\n\n # Remove the AddThis cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__atuv.=[^;]+(; )?\", \"\");\n\n # Remove a \";\" prefix in the cookie if present\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n \n # Remove any Piiwik based cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"(^|;\\s*)(_pk_(ses|id)[\\.a-z0-9]*)=[^;]*\", \"\"); # removes Piwik cookies\n\n\n # Are there cookies left with only spaces or that are empty?\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n\n #if (req.http.Cache-Control ~ \"(?i)no-cache\") {\n #if (req.http.Cache-Control ~ \"(?i)no-cache\" && client.ip ~ editors) { # create the acl editors if you want to restrict the Ctrl-F5\n # http:\/\/varnish.projects.linpro.no\/wiki\/VCLExampleEnableForceRefresh\n # Ignore requests via proxy caches and badly behaved crawlers\n # like msnbot that send no-cache with every request.\n # if (! (req.http.Via || req.http.User-Agent ~ \"(?i)bot\" || req.http.X-Purge)) {\n #set req.hash_always_miss = true; # Doesn't seems to refresh the object in the cache\n # return(purge); # Couple this with restart in vcl_purge and X-Purge header to avoid loops\n # }\n #}\n\n # Large static files are delivered directly to the end-user without\n # waiting for Varnish to fully read the file first.\n # Varnish 4 fully supports Streaming, so set do_stream in vcl_backend_response()\n if (req.url ~ \"^[^?]*\\.(mp[34]|rar|tar|tgz|gz|wav|zip|bz2|xz|7z|avi|mov|ogm|mpe?g|mk[av]|webm)(\\?.*)?$\") {\n unset req.http.Cookie;\n return (hash);\n }\n\n # Remove all cookies for static files\n # A valid discussion could be held on this line: do you really need to cache static files that don't cause load? Only if you have memory left.\n # Sure, there's disk I\/O, but chances are your OS will already have these files in their buffers (thus memory).\n # Before you blindly enable this, have a read here: https:\/\/ma.ttias.be\/stop-caching-static-files\/\n if (req.url ~ \"^[^?]*\\.(bmp|bz2|css|doc|eot|flv|gif|gz|ico|jpeg|jpg|svg|js|less|pdf|png|rtf|swf|txt|woff|woff2|xml)(\\?.*)?$\") {\n unset req.http.Cookie;\n return (hash);\n }\n\n if (req.url ~ \"^\/phpmyadmin\/.*$\" || req.url ~ \"^\/phppgadmin\/.*$\" || req.url ~ \"^\/server-status.*$\") {\n return(synth(403, \"For security reasons, this URL is only accessible using localhost (127.0.0.1) as the hostname.\"));\n }\n\n # Send Surrogate-Capability headers to announce ESI support to backend\n set req.http.Surrogate-Capability = \"key=ESI\/1.0\";\n\n if (req.http.Authorization) {\n # Not cacheable by default\n return (pass);\n }\n\n # Modify (remove) progress.js request parameters.\n if (req.url ~ \"^\/misc\/progress\\.js\\?[0-9]+$\") {\n set req.url = \"\/misc\/progress.js\";\n }\n\n # Modify HTTP X-Forwarded-For header.\n # This will replace Varnish's IP with actual client's.\n unset req.http.X-Forwarded-For;\n set req.http.X-Forwarded-For = client.ip;\n\n # Do not cache these paths.\n if (req.url ~ \"^\/status\\.php$\" ||\n req.url ~ \"^\/update\\.php$\" ||\n req.url ~ \"^\/ooyala\/ping$\" ||\n req.url ~ \"^\/admin\" ||\n req.url ~ \"^\/admin\/.*$\" ||\n req.url ~ \"^\/user\" ||\n req.url ~ \"^\/user\/.*$\" ||\n req.url ~ \"^\/users\/.*$\" ||\n req.url ~ \"^\/info\/.*$\" ||\n req.url ~ \"^\/flag\/.*$\" ||\n req.url ~ \"^\/batch\/.*$\" ||\n req.url ~ \"^.*\/ajax\/.*$\" ||\n req.url ~ \"^.*\/ahah\/.*$\") {\n return (pass);\n }\n\n # Pipe these paths directly to Apache for streaming.\n if (req.url ~ \"^\/admin\/content\/backup_migrate\/export\") {\n return (pipe);\n }\n\n # Do not allow outside access to cron.php or install.php.\n if (req.url ~ \"^\/(cron|install)\\.php$\" && !client.ip ~ internal) {\n # Have Varnish throw the error directly.\n return(synth(404, \"Page not found.\"));\n # Use a custom error page that you've defined in Drupal at the path \"404\".\n # set req.url = \"\/404\";\n }\n\n return (hash);\n}\n\nsub vcl_pipe {\n # Called upon entering pipe mode.\n # In this mode, the request is passed on to the backend, and any further data from both the client\n # and backend is passed on unaltered until either end closes the connection. Basically, Varnish will\n # degrade into a simple TCP proxy, shuffling bytes back and forth. For a connection in pipe mode,\n # no other VCL subroutine will ever get called after vcl_pipe.\n\n # Note that only the first request to the backend will have\n # X-Forwarded-For set. If you use X-Forwarded-For and want to\n # have it set for all requests, make sure to have:\n # set bereq.http.connection = \"close\";\n # here. It is not set by default as it might break some broken web\n # applications, like IIS with NTLM authentication.\n\n # set bereq.http.Connection = \"Close\";\n\n # Implementing websocket support (https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html)\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n\n return (pipe);\n}\n \nsub vcl_pass {\n # Called upon entering pass mode. In this mode, the request is passed on to the backend, and the\n # backend's response is passed on to the client, but is not entered into the cache. Subsequent\n # requests submitted over the same client connection are handled normally.\n\n return (fetch);\n}\n\n# The data on which the hashing will take place\nsub vcl_hash {\n # Called after vcl_recv to create a hash value for the request. This is used as a key\n # to look up the object in Varnish.\n\n hash_data(req.url);\n\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n\n # If the client supports compression, keep that in a different cache\n if (req.http.Accept-Encoding) {\n hash_data(req.http.Accept-Encoding);\n }\n\n # hash cookies for requests that have them\n if (req.http.Cookie) {\n hash_data(req.http.Cookie);\n }\n\n return (lookup);\n}\n\nsub vcl_hit {\n # Called when a cache lookup is successful.\n\n if (obj.ttl >= 0s) {\n # A pure unadultered hit, deliver it\n return (deliver);\n }\n\n # https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-grace.html\n # When several clients are requesting the same page Varnish will send one request to the backend and place the others on hold while fetching one copy from the backend. In some products this is called request coalescing and Varnish does this automatically.\n # If you are serving thousands of hits per second the queue of waiting requests can get huge. There are two potential problems - one is a thundering herd problem - suddenly releasing a thousand threads to serve content might send the load sky high. Secondly - nobody likes to wait. To deal with this we can instruct Varnish to keep the objects in cache beyond their TTL and to serve the waiting requests somewhat stale content.\n\n # if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n # return (deliver);\n # } else {\n # return (fetch);\n # }\n\n # We have no fresh fish. Lets look at the stale ones.\n if (std.healthy(req.backend_hint)) {\n # Backend is healthy. Limit age to 10s.\n if (obj.ttl + 10s > 0s) {\n #set req.http.grace = \"normal(limited)\";\n return (deliver);\n } else {\n # No candidate for grace. Fetch a fresh object.\n return(fetch);\n }\n } else {\n # backend is sick - use full grace\n if (obj.ttl + obj.grace > 0s) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n \/\/ set req.http.grace = \"full\";\n return (deliver);\n } else {\n # no graced object.\n return (fetch);\n }\n }\n\n #if (req.method == \"PURGE\") {\n # purge;\n # return (synth(200, \"Purged.\"));\n #}\n\n # fetch & deliver once we get the result\n return (fetch); # Dead code, keep as a safeguard\n}\n\nsub vcl_miss {\n # Called after a cache lookup if the requested document was not found in the cache. Its purpose\n # is to decide whether or not to attempt to retrieve the document from the backend, and which\n # backend to use.\n\n #if (req.method == \"PURGE\") {\n # purge;\n # return (synth(200, \"Purged.\"));\n #}\n\n return (fetch);\n}\n \n# This function is used when a request is sent by our backend (Nginx server)\nsub vcl_backend_response {\n # Called after the response headers has been successfully retrieved from the backend.\n\n # Remove some headers we never want to see\n unset beresp.http.Server;\n unset beresp.http.X-Powered-By;\n\n # Pause ESI request and remove Surrogate-Control header\n if (beresp.http.Surrogate-Control ~ \"ESI\/1.0\") {\n unset beresp.http.Surrogate-Control;\n set beresp.do_esi = true;\n }\n\n # Enable cache for all static files\n # The same argument as the static caches from above: monitor your cache size, if you get data nuked out of it, consider giving up the static file cache.\n # Before you blindly enable this, have a read here: https:\/\/ma.ttias.be\/stop-caching-static-files\/\n if (bereq.url ~ \"^[^?]*\\.(bmp|bz2|css|doc|eot|flv|gif|gz|ico|jpeg|jpg|js|less|mp[34]|pdf|png|rar|rtf|swf|tar|tgz|txt|wav|woff|xml|zip|webm)(\\?.*)?$\") {\n unset beresp.http.set-cookie;\n }\n\n # Large static files are delivered directly to the end-user without\n # waiting for Varnish to fully read the file first.\n # Varnish 4 fully supports Streaming, so use streaming here to avoid locking.\n if (bereq.url ~ \"^[^?]*\\.(mp[34]|rar|tar|tgz|gz|wav|zip|bz2|xz|7z|avi|mov|ogm|mpe?g|mk[av]|webm)(\\?.*)?$\") {\n unset beresp.http.set-cookie;\n set beresp.do_stream = true; # Check memory usage it'll grow in fetch_chunksize blocks (128k by default) if the backend doesn't send a Content-Length header, so only enable it for big objects\n set beresp.do_gzip = false; # Don't try to compress it for storage\n }\n\n # Sometimes, a 301 or 302 redirect formed via Apache's mod_rewrite can mess with the HTTP port that is being passed along.\n # This often happens with simple rewrite rules in a scenario where Varnish runs on :80 and Apache on :8080 on the same box.\n # A redirect can then often redirect the end-user to a URL on :8080, where it should be :80.\n # This may need finetuning on your setup.\n #\n # To prevent accidental replace, we only filter the 301\/302 redirects for now.\n if (beresp.status == 301 || beresp.status == 302) {\n set beresp.http.Location = regsub(beresp.http.Location, \":[0-9]+\", \"\");\n }\n\n # Set 2min cache if unset for static files\n if (beresp.ttl <= 0s || beresp.http.Set-Cookie || beresp.http.Vary == \"*\") {\n \/*\n * Mark as \"Hit-For-Pass\" for the next 2 minutes\n *\/\n set beresp.ttl = 120s; # Important, you shouldn't rely on this, SET YOUR HEADERS in the backend\n set beresp.uncacheable = true;\n return (deliver);\n }\n\n # Allow stale content, in case the backend goes down.\n # make Varnish keep all objects for 6 hours beyond their TTL\n set beresp.grace = 6h;\n\n\t# Only allow cookies to be set if we're in admin area\n#\tif (beresp.http.Set-Cookie && bereq.url !~ \"^\/wp-(login|admin)\") {\n# \tunset beresp.http.Set-Cookie;\n# \t}\n\n\t# don't cache response to posted requests or those with basic auth\n#\tif ( bereq.method == \"POST\" || bereq.http.Authorization ) {\n# \tset beresp.uncacheable = true;\n#\t\tset beresp.ttl = 120s;\n#\t\treturn (deliver);\n# \t}\n \n \t# don't cache search results\n#\tif ( bereq.url ~ \"\\?s=\" ){\n#\t\tset beresp.uncacheable = true;\n# set beresp.ttl = 120s;\n# return (deliver);\n#\t}\n \n\t# only cache status ok\n#\tif ( beresp.status != 200 ) {\n#\t\tset beresp.uncacheable = true;\n# set beresp.ttl = 120s;\n# return (deliver);\n#\t}\n\n\t# A TTL of 24h\n#\tset beresp.ttl = 24h;\n\t# Define the default grace period to serve cached content\n#\tset beresp.grace = 30s;\n\t\n return (deliver);\n}\n \n# The routine when we deliver the HTTP request to the user\n# Last chance to modify headers that are sent to the client\nsub vcl_deliver {\n # Called before a cached object is delivered to the client.\n\n if (obj.hits > 0) { # Add debug header to see if it's a HIT\/MISS and the number of hits, disable when not needed\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n\n # Please note that obj.hits behaviour changed in 4.0, now it counts per objecthead, not per object\n # and obj.hits may not be reset in some cases where bans are in use. See bug 1492 for details.\n # So take hits with a grain of salt\n set resp.http.X-Cache-Hits = obj.hits;\n\n # Remove some headers: PHP version\n unset resp.http.X-Powered-By;\n\n # Remove some headers: Apache version & OS\n unset resp.http.Server;\n unset resp.http.X-Drupal-Cache;\n unset resp.http.X-Varnish;\n unset resp.http.Via;\n unset resp.http.Link;\n unset resp.http.X-Generator;\n\n return (deliver);\n}\n\nsub vcl_purge {\n # Only handle actual PURGE HTTP methods, everything else is discarded\n if (req.method != \"PURGE\") {\n # restart request\n set req.http.X-Purge = \"Yes\";\n return(restart);\n }\n\n return (synth(200, \"Purged\"));\n}\n\nsub vcl_synth {\n if (resp.status == 720) {\n # We use this special error status 720 to force redirects with 301 (permanent) redirects\n # To use this, call the following from anywhere in vcl_recv: return (synth(720, \"http:\/\/host\/new.html\"));\n set resp.http.Location = resp.reason;\n set resp.status = 301;\n return (deliver);\n } elseif (resp.status == 721) {\n # And we use error status 721 to force redirects with a 302 (temporary) redirect\n # To use this, call the following from anywhere in vcl_recv: return (synth(720, \"http:\/\/host\/new.html\"));\n set resp.http.Location = resp.reason;\n set resp.status = 302;\n return (deliver);\n }\n\n return (deliver);\n}\n\nsub vcl_init {\n return (ok);\n}\n \nsub vcl_fini {\n # Called when VCL is discarded only after all requests have exited the VCL.\n # Typically used to clean up VMODs.\n\n return (ok);\n}\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'default.vcl' did not match any file(s) known to git\n","license":"mit","lang":"VCL"} {"commit":"048328e052f97df6530decbae2415bb1a70318a1","subject":"added more comments to drupal_base.vcl","message":"added more comments to drupal_base.vcl\n","repos":"NITEMAN\/Varnish_VCL_samps-hacks,NITEMAN\/varnish-bites","old_file":"varnish 3 vcls\/drupal_base.vcl","new_file":"varnish 3 vcls\/drupal_base.vcl","new_contents":"","old_contents":"","returncode":1,"stderr":"error: pathspec 'varnish' did not match any file(s) known to git\nerror: pathspec '3' did not match any file(s) known to git\nerror: pathspec 'vcls\/drupal_base.vcl' did not match any file(s) known to git\n","license":"unknown","lang":"VCL"} {"commit":"b159ed30da33906114f9374d7f39c0dba24f8228","subject":"Add VCL snippet for force TLS that executes before all the other snippets","message":"Add VCL snippet for force TLS that executes before all the other snippets\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets_force_tls\/recv.vcl","new_file":"etc\/vcl_snippets_force_tls\/recv.vcl","new_contents":"# Force SSL immediately to avoid magento module VCL stripping off\n# google campaign ids like gclid\n if (!req.http.Fastly-SSL) { \n error 972 \"Force SSL\"; \n }\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'etc\/vcl_snippets_force_tls\/recv.vcl' did not match any file(s) known to git\n","license":"bsd-3-clause","lang":"VCL"} {"commit":"34736e5d07105f51337941a91a2890f0b83b9066","subject":"Add Varnish VCL test-file","message":"Add Varnish VCL test-file\n","repos":"dscorbett\/pygments,pygments\/pygments,pygments\/pygments,pygments\/pygments,pygments\/pygments,pygments\/pygments,pygments\/pygments,pygments\/pygments,pygments\/pygments,pygments\/pygments,dscorbett\/pygments,pygments\/pygments,dscorbett\/pygments,dscorbett\/pygments,dscorbett\/pygments,pygments\/pygments,dscorbett\/pygments,dscorbett\/pygments,pygments\/pygments,dscorbett\/pygments,pygments\/pygments,dscorbett\/pygments,pygments\/pygments,dscorbett\/pygments,dscorbett\/pygments,pygments\/pygments,pygments\/pygments,dscorbett\/pygments,dscorbett\/pygments,dscorbett\/pygments,pygments\/pygments,dscorbett\/pygments,dscorbett\/pygments,pygments\/pygments,dscorbett\/pygments,dscorbett\/pygments","old_file":"tests\/examplefiles\/varnish.vcl","new_file":"tests\/examplefiles\/varnish.vcl","new_contents":"# This is the VCL configuration Varnish will automatically append to your VCL\n# file during compilation\/loading. See the vcl(7) man page for details on syntax\n# and semantics.\n# New users is recommended to use the example.vcl file as a starting point.\n\nvcl 4.0;\n\nbackend foo { .host = \"192.168.1.1\"; }\n\nprobe blatti { .url = \"foo\"; }\n\nsub vcl_recv {\n if (req.method == \"PRI\") {\n\t\/* We do not support SPDY or HTTP\/2.0 *\/\n\treturn (synth(405));\n }\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization || req.http.Cookie) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n return (hash);\n}\n\nsub vcl_pipe {\n # By default Connection: close is set on all piped requests, to stop\n # connection reuse from sending future requests directly to the\n # (potentially) wrong backend. If you do want this to happen, you can undo\n # it here.\n # unset bereq.http.connection;\n return (pipe);\n}\n\nsub vcl_pass {\n return (fetch);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n return (lookup);\n}\n\nsub vcl_purge {\n return (synth(200, \"Purged\"));\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n \/\/ A pure unadultered hit, deliver it\n return (deliver);\n }\n if (obj.ttl + obj.grace > 0s) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n return (deliver);\n }\n \/\/ fetch & deliver once we get the result\n return (miss);\n}\n\nsub vcl_miss {\n return (fetch);\n}\n\nsub vcl_deliver {\n return (deliver);\n}\n\n\/*\n * We can come here \"invisibly\" with the following errors: 413, 417 & 503\n *\/\nsub vcl_synth {\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n set resp.http.Retry-After = \"5\";\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n return (deliver);\n}\n\n#######################################################################\n# Backend Fetch\n\nsub vcl_backend_fetch {\n return (fetch);\n}\n\nsub vcl_backend_response {\n if (beresp.ttl <= 0s ||\n beresp.http.Set-Cookie ||\n beresp.http.Surrogate-control ~ \"no-store\" ||\n (!beresp.http.Surrogate-Control &&\n beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n beresp.http.Vary == \"*\") {\n \/*\n * Mark as \"Hit-For-Pass\" for the next 2 minutes\n *\/\n set beresp.ttl = 120s;\n set beresp.uncacheable = true;\n }\n return (deliver);\n}\n\nsub vcl_backend_error {\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + beresp.status + \" \" + beresp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + beresp.status + \" \" + beresp.reason + {\"<\/h1>\n <p>\"} + beresp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + bereq.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n return (deliver);\n}\n\n#######################################################################\n# Housekeeping\n\nsub vcl_init {\n}\n\nsub vcl_fini {\n return (ok);\n}\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'tests\/examplefiles\/varnish.vcl' did not match any file(s) known to git\n","license":"bsd-2-clause","lang":"VCL"} {"commit":"15de6bf7e26c2d1b2d2eb5b4da779a87bddeb258","subject":"Add a trivial example showing off the vmod API.","message":"Add a trivial example showing off the vmod API.","repos":"SBRDevelopment\/libvmod-redis,zephirworks\/libvmod-redis,zephirworks\/libvmod-redis,brandonwamboldt\/libvmod-redis,brandonwamboldt\/libvmod-redis,SBRDevelopment\/libvmod-redis","old_file":"examples\/example.vcl","new_file":"examples\/example.vcl","new_contents":"#\n# A trivial example to demonstrate how to use this vmod\n#\n\nimport redis;\n\nbackend be1 {\n .host = \"192.168.0.1\";\n .port = \"80\";\n}\n\nsub vcl_recv {\n #\n # redis.call is a procedure, it will send the command to redis and ignore\n # the response. If the command errors out, it will be logged but the VCL\n # will not know.\n #\n redis.send(\"LPUSH client \" + client.ip);\n\n #\n # redis.call is a function that sends the command to redis and return the\n # return value.\n #\n set req.http.x-redis = redis.call(\"LTRIM client 0 99\");\n}\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'examples\/example.vcl' did not match any file(s) known to git\n","license":"bsd-2-clause","lang":"VCL"} {"commit":"3fad9794daa01d50fe87f5b708221a2de07e4fc2","subject":"add default varnish config","message":"add default varnish config\n","repos":"majestrate\/nntpchan,majestrate\/nntpchan,chen-chan\/nntpchan,majestrate\/nntpchan,chen-chan\/nntpchan,chen-chan\/nntpchan,chen-chan\/nntpchan,chen-chan\/nntpchan,chen-chan\/nntpchan,majestrate\/nntpchan,chen-chan\/nntpchan,majestrate\/nntpchan,majestrate\/nntpchan,majestrate\/nntpchan,chen-chan\/nntpchan","old_file":"contrib\/configs\/varnish\/srndv2.vcl","new_file":"contrib\/configs\/varnish\/srndv2.vcl","new_contents":"","old_contents":"","returncode":128,"stderr":"fatal: unable to access 'https:\/\/github.com\/majestrate\/nntpchan.git\/': The requested URL returned error: 403\n","license":"mit","lang":"VCL"} {"commit":"02860ee79cf21ed1cec8b6b82574f97b8e6c7bcd","subject":"Update varnish vcl","message":"Update varnish vcl\n","repos":"a25kk\/lra,a25kk\/lra,a25kk\/lra,a25kk\/lra,a25kk\/lra","old_file":"buildout.d\/varnish.vcl","new_file":"buildout.d\/varnish.vcl","new_contents":"","old_contents":"","returncode":128,"stderr":"remote: Support for password authentication was removed on August 13, 2021.\nremote: Please see https:\/\/docs.github.com\/en\/get-started\/getting-started-with-git\/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.\nfatal: Authentication failed for 'https:\/\/github.com\/a25kk\/lra.git\/'\n","license":"mit","lang":"VCL"} {"commit":"8fed0cdc4e7042a591929ca0f2226aa731f08966","subject":"Create default.vcl","message":"Create default.vcl","repos":"babim\/docker-varnish","old_file":"default.vcl","new_file":"default.vcl","new_contents":"","old_contents":"","returncode":128,"stderr":"fatal: unable to access 'https:\/\/github.com\/babim\/docker-varnish.git\/': The requested URL returned error: 403\n","license":"mit","lang":"VCL"} {"commit":"1a974e455763dee338f7963396aaafb93f94bda0","subject":"Check in varnish config","message":"Check in varnish config\n","repos":"EFForg\/action-center-platform,EFForg\/action-center-platform,EFForg\/action-center-platform,EFForg\/action-center-platform","old_file":"varnish.vcl","new_file":"varnish.vcl","new_contents":"sub vcl_recv {\n#FASTLY recv\n\n if (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n\n if (req.http.cookie ~ \"logged_in\" && req.url !~ \"^\/assets\/\") {\n set req.hash_always_miss = true;\n return(pass);\n }\n\n if (req.url !~ \"^\/(ahoy)\/\") {\n unset req.http.Cookie;\n }\n\n return(lookup);\n}\n\nsub vcl_fetch {\n if (req.http.cookie !~ \"logged_in\" && req.url !~ \"^\/(login)|(confirmation\/new)|(unlock\/new)|(password\/new)|(ahoy\/)\") {\n unset beresp.http.Set-Cookie;\n }\n\n#FASTLY fetch\n\n if ((beresp.status == 500 || beresp.status == 503) && req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n if (req.restarts > 0) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return(pass);\n }\n\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return(pass);\n }\n\n if (beresp.status == 500 || beresp.status == 503) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return(deliver);\n }\n\n if (beresp.http.Expires || beresp.http.Surrogate-Control ~ \"max-age\" || beresp.http.Cache-Control ~ \"(s-maxage|max-age)\") {\n # keep the ttl here\n } else {\n # apply the default ttl\n set beresp.ttl = 3600s;\n }\n\n return(deliver);\n}\n\nsub vcl_hit {\n#FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\nsub vcl_miss {\n#FASTLY miss\n return(fetch);\n}\n\nsub vcl_deliver {\n#FASTLY deliver\n return(deliver);\n}\n\nsub vcl_error {\n#FASTLY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n\nsub vcl_log {\n#FASTLY log\n}\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'varnish.vcl' did not match any file(s) known to git\n","license":"agpl-3.0","lang":"VCL"} {"commit":"c8e482d5fc5a3906e6d312f963e5b8573d631683","subject":"Added example vcl to use in front of zope+plone (this could perhaps go in a contrib\/ directory instead)","message":"Added example vcl to use in front of zope+plone (this could perhaps go in a contrib\/ directory instead)\n\ngit-svn-id: 2c9807fa3ff65b17195bd55dc8a6c4261e10127b@1427 d4fa192b-c00b-0410-8231-f00ffab90ce4\n","repos":"ssm\/pkg-varnish,chrismoulton\/Varnish-Cache,mrhmouse\/Varnish-Cache,wikimedia\/operations-debs-varnish,drwilco\/varnish-cache-old,franciscovg\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,drwilco\/varnish-cache-drwilco,drwilco\/varnish-cache-drwilco,gquintard\/Varnish-Cache,1HLtd\/Varnish-Cache,1HLtd\/Varnish-Cache,feld\/Varnish-Cache,ssm\/pkg-varnish,drwilco\/varnish-cache-old,drwilco\/varnish-cache-old,gauthier-delacroix\/Varnish-Cache,chrismoulton\/Varnish-Cache,wikimedia\/operations-debs-varnish,varnish\/Varnish-Cache,drwilco\/varnish-cache-drwilco,wikimedia\/operations-debs-varnish,mrhmouse\/Varnish-Cache,mrhmouse\/Varnish-Cache,mrhmouse\/Varnish-Cache,alarky\/varnish-cache-doc-ja,gauthier-delacroix\/Varnish-Cache,varnish\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,franciscovg\/Varnish-Cache,wikimedia\/operations-debs-varnish,feld\/Varnish-Cache,franciscovg\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,ambernetas\/varnish-cache,franciscovg\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,gquintard\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,zhoualbeart\/Varnish-Cache,1HLtd\/Varnish-Cache,ssm\/pkg-varnish,zhoualbeart\/Varnish-Cache,chrismoulton\/Varnish-Cache,wikimedia\/operations-debs-varnish,ambernetas\/varnish-cache,alarky\/varnish-cache-doc-ja,zhoualbeart\/Varnish-Cache,feld\/Varnish-Cache,varnish\/Varnish-Cache,alarky\/varnish-cache-doc-ja,ambernetas\/varnish-cache,ajasty-cavium\/Varnish-Cache,chrismoulton\/Varnish-Cache,ssm\/pkg-varnish,alarky\/varnish-cache-doc-ja,zhoualbeart\/Varnish-Cache,feld\/Varnish-Cache,varnish\/Varnish-Cache,mrhmouse\/Varnish-Cache,1HLtd\/Varnish-Cache,chrismoulton\/Varnish-Cache,gquintard\/Varnish-Cache,gquintard\/Varnish-Cache,ssm\/pkg-varnish,varnish\/Varnish-Cache,alarky\/varnish-cache-doc-ja,zhoualbeart\/Varnish-Cache,franciscovg\/Varnish-Cache,feld\/Varnish-Cache","old_file":"etc\/zope-plone.vcl","new_file":"etc\/zope-plone.vcl","new_contents":"","old_contents":"","returncode":128,"stderr":"remote: Support for password authentication was removed on August 13, 2021.\nremote: Please see https:\/\/docs.github.com\/en\/get-started\/getting-started-with-git\/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.\nfatal: Authentication failed for 'https:\/\/github.com\/alarky\/varnish-cache-doc-ja.git\/'\n","license":"bsd-2-clause","lang":"VCL"} {"commit":"04132c832ecf716a7f48eb0ed0cb8e8dc5acef0c","subject":"We have to turn off Accept-Encoding in pass as well since response may contain ESIs","message":"We have to turn off Accept-Encoding in pass as well since response may contain ESIs\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets\/pass.vcl","new_file":"etc\/vcl_snippets\/pass.vcl","new_contents":" # Deactivate gzip on origin\n unset bereq.http.Accept-Encoding;\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'etc\/vcl_snippets\/pass.vcl' did not match any file(s) known to git\n","license":"bsd-3-clause","lang":"VCL"} {"commit":"acc8909f7439d55a085d90b879b57db46bc4da13","subject":"Regex set for doing device detection","message":"Regex set for doing device detection\n","repos":"gauthier-delacroix\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,franciscovg\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,mrhmouse\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,1HLtd\/Varnish-Cache,franciscovg\/Varnish-Cache,chrismoulton\/Varnish-Cache,alarky\/varnish-cache-doc-ja,feld\/Varnish-Cache,1HLtd\/Varnish-Cache,chrismoulton\/Varnish-Cache,gquintard\/Varnish-Cache,varnish\/Varnish-Cache,zhoualbeart\/Varnish-Cache,varnish\/Varnish-Cache,chrismoulton\/Varnish-Cache,1HLtd\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,zhoualbeart\/Varnish-Cache,feld\/Varnish-Cache,feld\/Varnish-Cache,alarky\/varnish-cache-doc-ja,alarky\/varnish-cache-doc-ja,alarky\/varnish-cache-doc-ja,mrhmouse\/Varnish-Cache,franciscovg\/Varnish-Cache,zhoualbeart\/Varnish-Cache,alarky\/varnish-cache-doc-ja,zhoualbeart\/Varnish-Cache,mrhmouse\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,feld\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,gquintard\/Varnish-Cache,franciscovg\/Varnish-Cache,1HLtd\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,varnish\/Varnish-Cache,mrhmouse\/Varnish-Cache,mrhmouse\/Varnish-Cache,feld\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,zhoualbeart\/Varnish-Cache,chrismoulton\/Varnish-Cache,varnish\/Varnish-Cache,gquintard\/Varnish-Cache,gquintard\/Varnish-Cache,varnish\/Varnish-Cache,franciscovg\/Varnish-Cache,chrismoulton\/Varnish-Cache","old_file":"etc\/devicedetect.vcl","new_file":"etc\/devicedetect.vcl","new_contents":"","old_contents":"","returncode":128,"stderr":"remote: Support for password authentication was removed on August 13, 2021.\nremote: Please see https:\/\/docs.github.com\/en\/get-started\/getting-started-with-git\/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.\nfatal: Authentication failed for 'https:\/\/github.com\/alarky\/varnish-cache-doc-ja.git\/'\n","license":"bsd-2-clause","lang":"VCL"} {"commit":"0cfe97a14640c64c4cb4c052aa561a3fc93db306","subject":"Add Snippet for Basic Auth","message":"Add Snippet for Basic Auth\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets_basic_auth\/error.vcl","new_file":"etc\/vcl_snippets_basic_auth\/error.vcl","new_contents":" if (obj.status == 971) {\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.WWW-Authenticate = \"Basic realm=Secured\";\n set obj.status = 401;\n synthetic {\"<!DOCTYPE HTML PUBLIC \"-\/\/W3C\/\/DTD HTML 4.01 Transitional\/\/EN\" \n \"http:\/\/www.w3.org\/TR\/1999\/REC-html401-19991224\/loose.dtd\">\n <HTML>\n <HEAD>\n <TITLE>Error<\/TITLE>\n <META HTTP-EQUIV='Content-Type' CONTENT='text\/html;'>\n <\/HEAD>\n <BODY><H1>401 Unauthorized<\/H1><\/BODY>\n <\/HTML>\n \"};\n return (deliver);\n }\n\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'etc\/vcl_snippets_basic_auth\/error.vcl' did not match any file(s) known to git\n","license":"bsd-3-clause","lang":"VCL"} {"commit":"75068788191fbf499001bffbb0e66ad62a987f24","subject":"Documentation for vcl_pipe and connection: close","message":"Documentation for vcl_pipe and connection: close\n\nNote in the default VCL that connection: close might be wanted.\n\n\ngit-svn-id: 2c9807fa3ff65b17195bd55dc8a6c4261e10127b@3852 d4fa192b-c00b-0410-8231-f00ffab90ce4\n","repos":"gquintard\/Varnish-Cache,wikimedia\/operations-debs-varnish,1HLtd\/Varnish-Cache,wikimedia\/operations-debs-varnish,feld\/Varnish-Cache,varnish\/Varnish-Cache,mrhmouse\/Varnish-Cache,ssm\/pkg-varnish,varnish\/Varnish-Cache,mrhmouse\/Varnish-Cache,ssm\/pkg-varnish,alarky\/varnish-cache-doc-ja,varnish\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,feld\/Varnish-Cache,wikimedia\/operations-debs-varnish,alarky\/varnish-cache-doc-ja,drwilco\/varnish-cache-old,wikimedia\/operations-debs-varnish,feld\/Varnish-Cache,ambernetas\/varnish-cache,mrhmouse\/Varnish-Cache,wikimedia\/operations-debs-varnish,alarky\/varnish-cache-doc-ja,1HLtd\/Varnish-Cache,chrismoulton\/Varnish-Cache,mrhmouse\/Varnish-Cache,ssm\/pkg-varnish,ajasty-cavium\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,zhoualbeart\/Varnish-Cache,zhoualbeart\/Varnish-Cache,varnish\/Varnish-Cache,drwilco\/varnish-cache-drwilco,chrismoulton\/Varnish-Cache,drwilco\/varnish-cache-drwilco,gquintard\/Varnish-Cache,drwilco\/varnish-cache-old,gauthier-delacroix\/Varnish-Cache,ambernetas\/varnish-cache,feld\/Varnish-Cache,mrhmouse\/Varnish-Cache,feld\/Varnish-Cache,zhoualbeart\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,gquintard\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,franciscovg\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,chrismoulton\/Varnish-Cache,ssm\/pkg-varnish,alarky\/varnish-cache-doc-ja,gquintard\/Varnish-Cache,alarky\/varnish-cache-doc-ja,zhoualbeart\/Varnish-Cache,drwilco\/varnish-cache-drwilco,zhoualbeart\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,chrismoulton\/Varnish-Cache,chrismoulton\/Varnish-Cache,1HLtd\/Varnish-Cache,franciscovg\/Varnish-Cache,ssm\/pkg-varnish,drwilco\/varnish-cache-old,ambernetas\/varnish-cache,franciscovg\/Varnish-Cache,franciscovg\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,varnish\/Varnish-Cache,1HLtd\/Varnish-Cache,franciscovg\/Varnish-Cache","old_file":"bin\/varnishd\/default.vcl","new_file":"bin\/varnishd\/default.vcl","new_contents":"","old_contents":"","returncode":128,"stderr":"remote: Support for password authentication was removed on August 13, 2021.\nremote: Please see https:\/\/docs.github.com\/en\/get-started\/getting-started-with-git\/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.\nfatal: Authentication failed for 'https:\/\/github.com\/alarky\/varnish-cache-doc-ja.git\/'\n","license":"bsd-2-clause","lang":"VCL"} {"commit":"48d05273efd92df0c263d3ef885e9e734bdb9ccf","subject":"Added \"default.vcl\" for varnish.","message":"Added \"default.vcl\" for varnish.\n","repos":"sysadmama\/misc,sysadmama\/misc","old_file":"varnish\/default.vcl","new_file":"varnish\/default.vcl","new_contents":"## \/etc\/varnish\/default.vcl \/ 20150504\n## Marianne Spiller <github@spiller.me>\n## v 3.0.5-2\n\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n .connect_timeout = 600s;\n .first_byte_timeout = 600s;\n .between_bytes_timeout = 600s;\n .max_connections = 800;\n }\n\n# Import Varnish Standard Module so I can serve custom error pages\nimport std;\n\n# Set who is allowed to purge\nacl purge {\n \"localhost\";\n \"127.0.0.1\";\n \"92.222.22.102\";\n}\n\n#----------------------------------------------------------------------\n# vcl_recv\n#\nsub vcl_recv {\n # Ignore all \"POST\" requests - nothing cacheable there\n if (req.request == \"POST\") {\n return (pass);\n }\n\n # In the event of a backend overload (HA!), serve stale objects for up to two minutes\n set req.grace = 2m;\n\n #--------------------------------------------------------------------\n # Ignore these hosts\n # Great when I'm working on the blog\n ##\n ##\t if (req.http.host ~ \"spiller.me\") {\n ##\t return(pass);\n ##\t }\n ##\t\n ##\t if (req.http.host ~ \"www.spiller.me\") {\n ##\t return(pass);\n ##\t }\n\n # No caching of the Wordpress \"preview\" sites\n if (req.url ~ \"preview=true\") {\n\treturn(pass);\n }\n\n # Use the \"purge\" ACL we set earlier to allow purging from the LAN\n if (req.request == \"PURGE\") {\n\tif (!client.ip ~ purge) {\n\t\terror 405 \"Not allowed.\";\n\t}\n\treturn (lookup);\n }\n\n # Static Elements should always go to the cache...\n if (req.url ~ \"(?i)\\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm|woff|ttf|eot|svg)(\\?[a-zA-Z0-9\\=\\.\\-]+)?$\") {\n\tremove req.http.Cookie;\n }\n\n # I throw away *all* cookies from *both* Wordpress installations - except wp-admin\n if (req.http.host ~ \"www.spiller.me|www.urban-exploring.eu\") {\n\tif (req.url ~ \"wp-(login|admin)\") {\n return (pass);\n\t}\n\n\t # Tell Varnish to use X-Forwarded-For, to set \"real\" IP addresses on all requests\n\tremove req.http.X-Forwarded-For;\n\tset req.http.X-Forwarded-For = req.http.rlnclientipaddr;\n }\n}\n\n#----------------------------------------------------------------------\n# vcl_pass\n#\nsub vcl_pass { \n set bereq.http.connection = \"close\";\n if (req.http.X-Forwarded-For) {\n\tset bereq.http.X-Forwarded-For = req.http.X-Forwarded-For;\n }\n else {\n\tset bereq.http.X-Forwarded-For = regsub(client.ip, \":.*\", \"\");\n }\n}\n\n#----------------------------------------------------------------------\n# vcl_pipe\n#\nsub vcl_pipe { \n set bereq.http.connection = \"close\";\n if (req.http.X-Forwarded-For) {\n\tset bereq.http.X-Forwarded-For = req.http.X-Forwarded-For;\n }\n else {\n\tset bereq.http.X-Forwarded-For = regsub(client.ip, \":.*\", \"\");\n }\n}\n\n#----------------------------------------------------------------------\n# vcl_pipe\n#\nsub vcl_fetch { \n set beresp.grace = 2m;\n if (req.http.host ~ \"www.spiller.me\") {\n\tif (!(req.url ~ \"wp-(login|admin)\")) {\n\t remove beresp.http.set-cookie;\n }\n }\n\n # Strip cookies before static items are inserted into cache.\n if (req.url ~ \"\\.(png|gif|jpg|swf|css|js|ico|html|htm|woff|eof|ttf|svg)$\") {\n\tremove beresp.http.set-cookie;\n }\n\n # Adjusting caching:\n # - cacheable objects stay for 24 hours\n # - objects declared as uncacheable stay for 60 seconds\n # - exception for the photo blog: its content stays for 5 days\n if (req.http.host ~ \"www.urban-exploring.eu\") {\n\tset beresp.ttl = 5d;\n }\n else {\n\tif (beresp.ttl < 24h) {\n\t if (beresp.http.Cache-Control ~ \"(private|no-cache|no-store)\") {\n\t set beresp.ttl = 60s;\n\t }\n\t else {\n\t set beresp.ttl = 24h;\n\t }\n\t}\n }\n}\n\n\n#----------------------------------------------------------------------\n# vcl_hit\n#\nsub vcl_hit { \n if (req.request == \"PURGE\") {\n\tpurge;\n\terror 200 \"Purged.\";\n }\n}\n\n#----------------------------------------------------------------------\n# vcl_miss\n#\nsub vcl_miss { \n if (req.request == \"PURGE\") {\n\tpurge;\n\terror 200 \"Purged.\";\n }\n}\n\n#----------------------------------------------------------------------\n# vcl_error\n#\nsub vcl_error { \n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.MyError = std.fileread(\"\/var\/www\/spillerme\/varnisherr.html\");\n synthetic obj.http.MyError;\n return(deliver);\n}\n\n#----------------------------------------------------------------------\n# vcl_deliver\n#\nsub vcl_deliver { \n # Display hit\/miss info\n if (obj.hits > 0) {\n\tset resp.http.X-Cache = \"HIT\";\n }\n else {\n\tset resp.http.X-Cache = \"MISS\";\n }\n\n # Remove the Varnish header\n remove resp.http.X-Varnish;\n\n # Display my header\n set resp.http.X-sysadmama-is-awesome = \"YAY\";\n\n # Remove custom error header\n remove resp.http.MyError;\n return (deliver);\n}\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'varnish\/default.vcl' did not match any file(s) known to git\n","license":"cc0-1.0","lang":"VCL"} {"commit":"1ef5407e6a0db320a33eaee295bd145ec502e8fe","subject":"add vcl example","message":"add vcl example\n","repos":"3scale\/libvmod-3scale,3scale\/libvmod-3scale","old_file":"vcl\/default_3scale_simple.vcl","new_file":"vcl\/default_3scale_simple.vcl","new_contents":"# This is a the VCL configuration file for 3scale's varnish plugin.\n# \n# Default backend definition. Set this to point to the 3scale's\n# backend. \n# \n# set the beresp.ttl in vcl_fetch to have a default global TTL\n# you can define custom TTL via regular expresions\n#\n \nbackend default {\n\t.host = \"su1.3scale.net\"; \n \t.port = \"80\";\n}\n\nimport std;\nimport threescale;\n\nsub vcl_recv {\n\n\tunset req.http.cookie;\n\tset req.http.host = \"su1.3scale.net\";\n\tset req.grace = 1s;\n\n\tif (req.request != \"GET\" && req.request != \"HEAD\") {\n \t\treturn(pass);\n \t}\n \telse {\n \t\t## GET or HEAD requests\n \t\treturn(lookup);\n \t}\n\t \n}\n\n# the hash of the request needs to be customized to remove all fields that are not \n# associated to the user\n\nsub vcl_hash {\n\n\t## remove no_body\n\tset req.http.X-url-tmp = regsub(req.url,\"[&?]no_body.[^&]*\",\"\");\n\t## remove object_id\n\tset req.http.X-url-tmp = regsub(req.http.X-url-tmp,\"[&?]object.[^&]*\",\"\");\n\t## remove object\n\tset req.http.X-url-tmp = regsub(req.http.X-url-tmp,\"[&?]object_id.[^&]*\",\"\");\n\n\thash_data(req.http.X-url-tmp);\t\n\tunset req.http.X-url-tmp;\n \treturn (hash);\n\n}\n\n#A HIT means that the request to your local cache of 3scale is still fresh and the\n#response will not have to fetch the data from the remote 3scale backend.\n#vmod_3scale plugin will send a replica of the call asynchronously to 3scale's remote\n#backend on its own\n\nsub vcl_hit {\n\tif (threescale.request_no_response(\"su1.3scale.net\",\"80\",req.url)==0) {}\n}\n\n\nsub vcl_fetch {\n\tset beresp.ttl = 30s;\n}\n\n\n\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'vcl\/default_3scale_simple.vcl' did not match any file(s) known to git\n","license":"bsd-2-clause","lang":"VCL"} {"commit":"66c830ff3f7caad768060b9930e5a6ffadbb228b","subject":"note added for the convenience of restarting POST request on backend failures","message":"note added for the convenience of restarting POST request on backend failures\n","repos":"NITEMAN\/varnish-bites,NITEMAN\/Varnish_VCL_samps-hacks","old_file":"varnish 3 vcls\/drupal_base.vcl","new_file":"varnish 3 vcls\/drupal_base.vcl","new_contents":"","old_contents":"","returncode":1,"stderr":"error: pathspec 'varnish' did not match any file(s) known to git\nerror: pathspec '3' did not match any file(s) known to git\nerror: pathspec 'vcls\/drupal_base.vcl' did not match any file(s) known to git\n","license":"unknown","lang":"VCL"} {"commit":"76e5f648a92133ad19af222b22fcf46f757803cb","subject":"moving vlc_error subroutine outside","message":"moving vlc_error subroutine outside\n","repos":"kkwoker\/ansible-varnish","old_file":"templates\/etc\/varnish\/emergency.vcl","new_file":"templates\/etc\/varnish\/emergency.vcl","new_contents":"","old_contents":"","returncode":128,"stderr":"remote: Support for password authentication was removed on August 13, 2021.\nremote: Please see https:\/\/docs.github.com\/en\/get-started\/getting-started-with-git\/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.\nfatal: Authentication failed for 'https:\/\/github.com\/kkwoker\/ansible-varnish.git\/'\n","license":"mit","lang":"VCL"} {"commit":"699dded3715136cc1e3e18b3b7a0126427f1e46a","subject":"Boilerplate","message":"Boilerplate\n","repos":"rhargreaves\/fastly-vcl-experiments,rhargreaves\/fastly-vcl-experiments","old_file":"oauth_sig_check.vcl","new_file":"oauth_sig_check.vcl","new_contents":"sub vcl_recv {\n#FASTLY recv\n\n\tif (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n\t\treturn(pass);\n\t}\n\n\treturn(lookup);\n}\n\nsub vcl_fetch {\n#FASTLY fetch\n\n\tif ((beresp.status == 500 || beresp.status == 503) && req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n\t\trestart;\n\t}\n\n\tif(req.restarts > 0 ) {\n\t\tset beresp.http.Fastly-Restarts = req.restarts;\n\t}\n\n\tif (beresp.http.Set-Cookie) {\n\t\tset req.http.Fastly-Cachetype = \"SETCOOKIE\";\n\t\treturn (pass);\n\t}\n\n\tif (beresp.http.Cache-Control ~ \"private\") {\n\t\tset req.http.Fastly-Cachetype = \"PRIVATE\";\n\t\treturn (pass);\n\t}\n\n\tif (beresp.status == 500 || beresp.status == 503) {\n\t\tset req.http.Fastly-Cachetype = \"ERROR\";\n\t\tset beresp.ttl = 1s;\n\t\tset beresp.grace = 5s;\n\t\treturn (deliver);\n\t}\n\n\tif (beresp.http.Expires || beresp.http.Surrogate-Control ~ \"max-age\" || beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n# keep the ttl here\n\t} else {\n# apply the default ttl\n\t\tset beresp.ttl = 3600s;\n\t}\n\n\treturn(deliver);\n}\n\nsub vcl_hit {\n#FASTLY hit\n\n\tif (!obj.cacheable) {\n\t\treturn(pass);\n\t}\n\treturn(deliver);\n}\n\nsub vcl_miss {\n#FASTLY miss\n\treturn(fetch);\n}\n\nsub vcl_deliver {\n#FASTLY deliver\n\treturn(deliver);\n}\n\nsub vcl_error {\n#FASTLY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'oauth_sig_check.vcl' did not match any file(s) known to git\n","license":"mit","lang":"VCL"} {"commit":"491f7603b7bbcaca6adbbc833d5e5be0b62eef21","subject":"Regression testcase for #433","message":"Regression testcase for #433\n\n\n\ngit-svn-id: 7d4b18ab7d176792635d6a7a77dd8cbbea8e8daa@3576 d4fa192b-c00b-0410-8231-f00ffab90ce4\n","repos":"wikimedia\/operations-debs-varnish,ssm\/pkg-varnish,wikimedia\/operations-debs-varnish,ssm\/pkg-varnish,wikimedia\/operations-debs-varnish,ssm\/pkg-varnish,ssm\/pkg-varnish,wikimedia\/operations-debs-varnish,CartoDB\/Varnish-Cache,ssm\/pkg-varnish,CartoDB\/Varnish-Cache,wikimedia\/operations-debs-varnish,CartoDB\/Varnish-Cache","old_file":"bin\/varnishtest\/tests\/r00433.vcl","new_file":"bin\/varnishtest\/tests\/r00433.vcl","new_contents":"","old_contents":"","returncode":128,"stderr":"remote: Support for password authentication was removed on August 13, 2021.\nremote: Please see https:\/\/docs.github.com\/en\/get-started\/getting-started-with-git\/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.\nfatal: Authentication failed for 'https:\/\/github.com\/wikimedia\/operations-debs-varnish.git\/'\n","license":"bsd-2-clause","lang":"VCL"} {"commit":"7276266555793ae61db8e80fd510f600ccadd664","subject":"add varnish configuration","message":"add varnish configuration\n","repos":"KhanovaSkola\/khanovaskola-v3,KhanovaSkola\/khanovaskola-v3,KhanovaSkola\/khanovaskola-v3,KhanovaSkola\/khanovaskola-v3,KhanovaSkola\/khanovaskola-v3,KhanovaSkola\/khanovaskola-v3","old_file":"production\/varnish.vcl","new_file":"production\/varnish.vcl","new_contents":"","old_contents":"","returncode":128,"stderr":"fatal: unable to access 'https:\/\/github.com\/KhanovaSkola\/khanovaskola-v3.git\/': The requested URL returned error: 403\n","license":"mit","lang":"VCL"} {"commit":"e94e3b9fd19708b21abe3b6c5ce7645d7c4717fc","subject":"Add vcl sample from previous commit.","message":"Add vcl sample from previous commit.\n","repos":"patricmutwiri\/mod_pagespeed,jalonsoa\/mod_pagespeed,hashashin\/src,webhost\/mod_pagespeed,webhost\/mod_pagespeed,webscale-networks\/mod_pagespeed,webscale-networks\/mod_pagespeed,wanrui\/mod_pagespeed,patricmutwiri\/mod_pagespeed,webscale-networks\/mod_pagespeed,VersoBit\/mod_pagespeed,pagespeed\/mod_pagespeed,ajayanandgit\/mod_pagespeed,webscale-networks\/mod_pagespeed,jalonsoa\/mod_pagespeed,VersoBit\/mod_pagespeed,ajayanandgit\/mod_pagespeed,wanrui\/mod_pagespeed,pagespeed\/mod_pagespeed,webscale-networks\/mod_pagespeed,webscale-networks\/mod_pagespeed,VersoBit\/mod_pagespeed,patricmutwiri\/mod_pagespeed,webhost\/mod_pagespeed,ajayanandgit\/mod_pagespeed,jalonsoa\/mod_pagespeed,VersoBit\/mod_pagespeed,hashashin\/src,webhost\/mod_pagespeed,wanrui\/mod_pagespeed,hashashin\/src,VersoBit\/mod_pagespeed,ajayanandgit\/mod_pagespeed,webhost\/mod_pagespeed,wanrui\/mod_pagespeed,patricmutwiri\/mod_pagespeed,hashashin\/src,webhost\/mod_pagespeed,webhost\/mod_pagespeed,ajayanandgit\/mod_pagespeed,wanrui\/mod_pagespeed,ajayanandgit\/mod_pagespeed,jalonsoa\/mod_pagespeed,wanrui\/mod_pagespeed,webscale-networks\/mod_pagespeed,ajayanandgit\/mod_pagespeed,pagespeed\/mod_pagespeed,pagespeed\/mod_pagespeed,wanrui\/mod_pagespeed,webscale-networks\/mod_pagespeed,pagespeed\/mod_pagespeed,patricmutwiri\/mod_pagespeed,patricmutwiri\/mod_pagespeed,webhost\/mod_pagespeed,hashashin\/src,jalonsoa\/mod_pagespeed,pagespeed\/mod_pagespeed,VersoBit\/mod_pagespeed,pagespeed\/mod_pagespeed,hashashin\/src,jalonsoa\/mod_pagespeed,ajayanandgit\/mod_pagespeed,hashashin\/src,jalonsoa\/mod_pagespeed,patricmutwiri\/mod_pagespeed,wanrui\/mod_pagespeed,jalonsoa\/mod_pagespeed,patricmutwiri\/mod_pagespeed,hashashin\/src,VersoBit\/mod_pagespeed","old_file":"src\/install\/sample_conf.vcl","new_file":"src\/install\/sample_conf.vcl","new_contents":"\/*\n This is the minimal VCL configuration required for passing the Apache\n mod_pagespeed system tests. To install varnish and start the varnish\n server at the right port, do the following:\n 1) sudo apt-get install varnish\n 2) sudo vim \/etc\/default\/varnish and put in the following lines at the\n bottom of the file:\n DAEMON_OPTS=\"-a :8020 \\\n -T localhost:6082 \\\n -f \/etc\/varnish\/default.vcl \\\n -S \/etc\/varnish\/secret \\\n -s file,\/var\/lib\/varnish\/$INSTANCE\/varnish_storage.bin,1G\"\n 3) sudo cp \/path\/to\/install\/sample_conf.vcl \/etc\/varnish\/default.vcl\n 4) sudo service varnish restart\n*\/\n\nbackend default {\n # Location of Apache mod_pagespeed server.\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\n\nacl purge {\n # Purge requests are only allowed from localhost.\n \"localhost\";\n \"127.0.0.1\";\n}\n\nsub vcl_recv {\n if (req.request == \"PURGE\") {\n if (!client.ip ~ purge) {\n error 405 \"Not allowed.\";\n }\n return (lookup);\n }\n}\n\nsub vcl_hit {\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged.\";\n }\n}\n\nsub vcl_miss {\n if (req.request == \"PURGE\") {\n purge;\n error 200 \"Purged.\";\n }\n}\n\nsub vcl_fetch {\n # Cache everything for 30s.\n set beresp.ttl = 30s;\n set beresp.grace = 30s;\n set beresp.http.X-Cacheable = \"YES\";\n return (deliver);\n}\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'src\/install\/sample_conf.vcl' did not match any file(s) known to git\n","license":"apache-2.0","lang":"VCL"} {"commit":"9a31c6b4f21933f903c426d45dc4a3fdabc7ec52","subject":"Minor updates to VCL.","message":"Minor updates to VCL.\n","repos":"kkwoker\/ansible-varnish,noqcks\/ansible-varnish,killerwails\/ansible-varnish,colstrom\/ansible-varnish,gotofbi\/ansible-varnish,telusdigital\/ansible-varnish,gotofbi\/ansible-varnish,killerwails\/ansible-varnish","old_file":"templates\/etc\/varnish\/default.vcl","new_file":"templates\/etc\/varnish\/default.vcl","new_contents":"vcl 4.0;\n\nimport directors;\nimport std;\n\n###\n# Varnish Documentation\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-built-in-subs.html\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/reference\/vcl.html\n##\n\n{% for backend in varnish_backend_hosts %}\nbackend application_{{ loop.index }} {\n .host = \"{{ backend }}\";\n .port = \"{{ varnish_backend_port }}\";\n{% if varnish_health_checks_enabled %}\n .probe = {\n .url = \"{{ varnish_health_check_url }}\";\n .interval = {{ varnish_health_check_interval }};\n .timeout = {{ varnish_health_check_timeout }};\n .window = {{ varnish_health_check_window }};\n .threshold = {{ varnish_health_check_threshold }};\n }\n{% endif %}\n}\n{% endfor %}\n\n###\n# vcl_init\n# Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n###\n# The vcl_init subroutine may terminate with calling return() with one of the following keywords:\n#\n# ok\n# Normal return, VCL continues loading.\n##\n\nsub vcl_init {\n new application = directors.round_robin();\n{% for backend in varnish_backend_hosts %}\n application.add_backend(application_{{ loop.index }});\n{% endfor %}\n}\n\n###\n# vcl_recv\n# Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use. \n# It is also used to modify the request\n###\n# The vcl_recv subroutine may terminate with calling return() on one of the following keywords:\n#\n# synth(status code, reason)\n# Return a synthetic object with the specified status code to the client and abandon the request.\n# pass\n# Switch to pass mode. Control will eventually pass to vcl_pass.\n# pipe\n# Switch to pipe mode. Control will eventually pass to vcl_pipe.\n# hash\n# Continue processing the object as a potential candidate for caching. Passes the control over to vcl_hash.\n# purge\n# Purge the object and it's variants. Control passes through vcl_hash to vcl_purge.\n#\n\nsub vcl_recv {\n set req.backend_hint = application.backend();\n\n ###\n # Avoid processing uncacheable requests\n ###\n\n if (req.http.Authorization) {\n set req.http.X-Passthrough-Reason = \"No Caching Authenticated Content\";\n return (pass);\n }\n\n{% if varnish_uri_blacklist_enabled %}\n if ((req.url ~ \"{{ varnish_uri_blacklist_regexp }}\")) {\n set req.http.X-Passthrough-Reason = \"Path in Blacklist\";\n return(pass);\n }\n{% endif %}\n\n{% if varnish_diagnostic_headers_forwarded_for %}\n ###\n # Inject X-Forwarded-For headers, but only once.\n ###\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n{% endif %}\n\n{% if varnish_header_sanitization_enabled %}\n ###\n # Header Sanitization\n ###\n\n{% if varnish_header_sanitization_discard_host_port %}\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n{% endif %}\n\n{% if varnish_header_sanitization_normalize_accept_encoding %}\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n{% endif %}\n\n{% endif %}\n\n{% if varnish_cookie_sanitization_enabled %}\n ###\n # Cookie Sanitization\n ###\n\n{% for cookie in varnish_cookie_sanitization_blacklist %}\n set req.http.Cookie = regsuball(req.http.Cookie, \"{{ cookie }}=[^;]+(; )?\", \"\");\n{% endfor %}\n\n ### General Cleanup\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n{% endif %}\n\n{% if varnish_uri_sanitization_enabled %}\n ###\n # URI Sanitization\n ###\n \n if (req.url ~ \"(\\?|&){{ varnish_uri_sanitization_regexp }}=\") {\n set req.url = regsuball(req.url, \"&{{ varnish_uri_sanitization_regexp }}=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?{{ varnish_uri_sanitization_regexp }}=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n{% endif %}\n\n{% if varnish_workaround_telusdotcom_browser_profile %}\n ###\n # Workaround and Diagnostics for BrowserProfile and Language\/Region Detection on TELUS.com\n ###\n\n if (req.http.Cookie ~ \"BrowserProfile\") {\n set req.http.X-BrowserProfile = regsuball(req.http.Cookie, \"(.*)BrowserProfile=([^;]*)(.*)\", \"\\2\");\n if (req.http.X-BrowserProfile ~ \"language\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.X-BrowserProfile, \"(.*)language\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n set req.http.X-Language-Found = \"YES:BrowserProfile\";\n }\n if (req.http.X-BrowserProfile ~ \"region\") {\n set req.http.X-Region = std.tolower(regsuball(regsuball(req.http.X-BrowserProfile, \"geo\\\\.\\:{(.*)\\}\", \"\"), \"(.*)region\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n set req.http.X-Region-Found = \"YES:BrowserProfile\";\n }\n if (req.http.X-BrowserProfile ~ \"geo\") {\n set req.http.X-BrowserProfile-Geolocation = regsuball(req.http.X-BrowserProfile, \"(.*)geo..:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n set req.http.X-BrowserProfile-Geolocation-Found = \"YES\";\n\n if (req.http.X-BrowserProfile-Geolocation ~ \"country\") {\n set req.http.X-BrowserProfile-Geolocation-Country = regsuball(req.http.X-BrowserProfile-Geolocation, \"(.*)country\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-BrowserProfile-Geolocation ~ \"region\") {\n set req.http.X-BrowserProfile-Geolocation-Region = regsuball(req.http.X-BrowserProfile-Geolocation, \"(.*)region\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-BrowserProfile-Geolocation ~ \"city\") {\n set req.http.X-BrowserProfile-Geolocation-City = regsuball(req.http.X-BrowserProfile-Geolocation, \"(.*)city\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-BrowserProfile-Geolocation ~ \"isp\") {\n set req.http.X-BrowserProfile-Geolocation-ISP = regsuball(req.http.X-BrowserProfile-Geolocation, \"(.*)isp\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n } else {\n set req.http.X-BrowserProfile-Geolocation-Found = \"NO\";\n }\n }\n\n if (!req.http.X-Language) {\n if (req.http.Cookie ~ \"lang=\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.Cookie, \"(.*)lang=([^;]*)(.*)\", \"\\2\"));\n set req.http.X-Language-Found = \"YES:lang\";\n } else {\n set req.http.X-Language = \"en\";\n set req.http.X-Language-Found = \"NO\";\n }\n }\n\n if (!req.http.X-Region) {\n if (req.http.Cookie ~ \"prov=\") {\n set req.http.X-Region = std.tolower(regsuball(req.http.Cookie, \"(.*)prov=([^;]*)(.*)\", \"\\2\"));\n set req.http.X-Region-Found = \"YES:prov\";\n } else {\n set req.http.X-Region = \"bc\";\n set req.http.X-Region-Found = \"NO\";\n }\n }\n\n if (req.url ~ \"\/(en|fr)\/\") {\n if (req.url ~ \"\/en\/\" && req.http.X-Language != \"en\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Language (Path: \/en\/) vs (Cookie: \" + req.http.X-Language + \")\";\n return(pass);\n }\n if (req.url ~ \"\/fr\/\" && req.http.X-Language != \"fr\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Language (Path: \/fr\/) vs (Cookie: \" + req.http.X-Language + \")\";\n return(pass);\n }\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Language)\";\n return(pass);\n }\n\n if (req.url ~ \"\/(ab|bc|mb|nb|nl|ns|nt|nu|on|pe|qc|sk|yt)\/\") {\n {% for province in ['ab', 'bc', 'mb', 'nb', 'nl', 'ns', 'nt', 'nu', 'on', 'pe', 'qc', 'sk', 'yt'] %}\n if (req.url ~ \"\/{{ province }}\/\" && req.http.X-Region != \"{{ province }}\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Region (Path: \/{{ province }}\/) vs (Cookie: \" + req.http.X-Region + \")\";\n return(pass);\n }\n {% endfor %}\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Province)\";\n return(pass);\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_discard_from_client %}\n unset req.http.Cookie;\n{% endif %}\n}\n\n###\n# vcl_hit\n# Called when a cache lookup is successful.\n###\n# The vcl_hit subroutine may terminate with calling return() with one of the following keywords:\n#\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n# deliver\n# Deliver the object. Control passes to vcl_deliver.\n# synth(status code, reason)\n# Return the specified status code to the client and abandon the request.\n###\n\nsub vcl_hit {\n if (obj.ttl > 0s) {\n return (deliver);\n }\n{% if varnish_health_checks_enabled %}\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (fetch);\n }\n{% else %}\n if (obj.ttl + obj.grace > 0s) {\n return (deliver);\n }\n\n return (fetch);\n{% endif %}\n}\n\n###\n# vcl_backend_response\n# Called after the response headers has been successfully retrieved from the backend.\n###\n# The vcl_backend_response subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Possibly insert the object into the cache, then deliver it to the Control will eventually pass to vcl_deliver.\n# abandon\n# Abandon the backend request and generates an error.\n# retry\n# Retry the backend transaction. Increases the retries counter. If the number of retries is higher than max_retries Varnish emits a guru meditation error.\n###\n\nsub vcl_backend_response {\n{% if varnish_workaround_telusdotcom_browser_profile %}\n if (bereq.http.X-Language) {\n set beresp.http.X-Language = bereq.http.X-Language;\n# if (bereq.http.X-Language-Found) {\n# set beresp.http.X-Language-Found = bereq.http.X-Language-Found;\n# }\n }\n if (bereq.http.X-Region) {\n set beresp.http.X-Region = bereq.http.X-Region;\n# if (bereq.http.X-Region-Found) {\n# set beresp.http.X-Region-Found = bereq.http.X-Region-Found;\n# }\n }\n{% endif %}\n\n{% if varnish_uri_blacklist_enabled %}\n if (bereq.url ~ \"{{ varnish_uri_blacklist_regexp }}\") {\n set beresp.http.X-Cacheable = \"NO:Path in Blacklist\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n if (bereq.http.X-Passthrough-Reason) {\n{% if varnish_diagnostic_headers_passthrough_reason %}\n set beresp.http.X-Passthrough-Reason = bereq.http.X-Passthrough-Reason;\n{% endif %}\n return(deliver);\n }\n }\n{% else %}\n{% if varnish_cookie_sanitization_discard_from_server %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n{% endif %}\n\n{% if varnish_diagnostic_headers_enabled %}\n if (bereq.http.Cookie) {\n set beresp.http.X-Cacheable = \"NO:Cookie in Request\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO:Set-Cookie in Response\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.X-No-Cache) {\n set beresp.http.X-Cacheable = \"NO:X-No-Cache\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.ttl <= 0s) {\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n{% endif %}\n\n set beresp.grace = {{ varnish_grace_period }};\n}\n\n###\n# vcl_deliver\n# Called before a cached object is delivered to the client.\n###\n# The vcl_deliver subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Deliver the object to the client.\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n###\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n","old_contents":"vcl 4.0;\n\nimport directors;\nimport std;\n\n###\n# Varnish Documentation\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-built-in-subs.html\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/reference\/vcl.html\n##\n\n{% for backend in varnish_backend_hosts %}\nbackend application_{{ loop.index }} {\n .host = \"{{ backend }}\";\n .port = \"{{ varnish_backend_port }}\";\n{% if varnish_health_checks_enabled %}\n .probe = {\n .url = \"{{ varnish_health_check_url }}\";\n .interval = {{ varnish_health_check_interval }};\n .timeout = {{ varnish_health_check_timeout }};\n .window = {{ varnish_health_check_window }};\n .threshold = {{ varnish_health_check_threshold }};\n }\n{% endif %}\n}\n{% endfor %}\n\n###\n# vcl_init\n# Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n###\n# The vcl_init subroutine may terminate with calling return() with one of the following keywords:\n#\n# ok\n# Normal return, VCL continues loading.\n##\n\nsub vcl_init {\n new application = directors.round_robin();\n{% for backend in varnish_backend_hosts %}\n application.add_backend(application_{{ loop.index }});\n{% endfor %}\n}\n\n###\n# vcl_recv\n# Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use. \n# It is also used to modify the request\n###\n# The vcl_recv subroutine may terminate with calling return() on one of the following keywords:\n#\n# synth(status code, reason)\n# Return a synthetic object with the specified status code to the client and abandon the request.\n# pass\n# Switch to pass mode. Control will eventually pass to vcl_pass.\n# pipe\n# Switch to pipe mode. Control will eventually pass to vcl_pipe.\n# hash\n# Continue processing the object as a potential candidate for caching. Passes the control over to vcl_hash.\n# purge\n# Purge the object and it's variants. Control passes through vcl_hash to vcl_purge.\n#\n\nsub vcl_recv {\n set req.backend_hint = application.backend();\n\n ###\n # Avoid processing uncacheable requests\n ###\n\n if (req.http.Authorization) {\n return (pass);\n }\n\n{% if varnish_uri_blacklist_enabled %}\n if ((req.url ~ \"{{ varnish_uri_blacklist_regexp }}\")) {\n set req.http.X-Passthrough-Reason = \"Path in Blacklist\";\n return(pass);\n }\n{% endif %}\n\n ###\n # Inject X-Forwarded-For headers, but only once.\n ###\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n{% if varnish_header_sanitization_enabled %}\n ###\n # Header Sanitization\n ###\n\n{% if varnish_header_sanitization_discard_host_port %}\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n{% endif %}\n\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_enabled %}\n ###\n # Cookie Sanitization\n ###\n{% for cookie in varnish_cookie_sanitization_blacklist %}\n set req.http.Cookie = regsuball(req.http.Cookie, \"{{ cookie }}=[^;]+(; )?\", \"\");\n{% endfor %}\n\n ### General Cleanup\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n{% endif %}\n\n{% if varnish_uri_sanitization_enabled %}\n ###\n # URI Sanitization\n ###\n \n if (req.url ~ \"(\\?|&){{ varnish_uri_sanitization_regexp }}=\") {\n set req.url = regsuball(req.url, \"&{{ varnish_uri_sanitization_regexp }}=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?{{ varnish_uri_sanitization_regexp }}=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n{% endif %}\n\n{% if varnish_workaround_telusdotcom_browser_profile %}\n ###\n # Workaround for BrowserProfile and Language\/Region Detection on TELUS.com\n ###\n\n if (req.http.Cookie ~ \"BrowserProfile\") {\n set req.http.X-BrowserProfile = regsuball(req.http.Cookie, \"(.*)BrowserProfile=([^;]*)(.*)\", \"\\2\");\n if (req.http.X-BrowserProfile ~ \"language\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.X-BrowserProfile, \"(.*)language\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n set req.http.X-Language-Found = \"YES:BrowserProfile\";\n }\n if (req.http.X-BrowserProfile ~ \"region\") {\n set req.http.X-Region = std.tolower(regsuball(regsuball(req.http.X-BrowserProfile, \"geo\\\\.\\:{(.*)\\}\", \"\"), \"(.*)region\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n set req.http.X-Region-Found = \"YES:BrowserProfile\";\n }\n if (req.http.X-BrowserProfile ~ \"geo\") {\n set req.http.X-BrowserProfile-Geolocation = regsuball(req.http.X-BrowserProfile, \"(.*)geo..:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n set req.http.X-BrowserProfile-Geolocation-Found = \"YES\";\n\n if (req.http.X-BrowserProfile-Geolocation ~ \"country\") {\n set req.http.X-BrowserProfile-Geolocation-Country = regsuball(req.http.X-BrowserProfile-Geolocation, \"(.*)country\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-BrowserProfile-Geolocation ~ \"region\") {\n set req.http.X-BrowserProfile-Geolocation-Region = regsuball(req.http.X-BrowserProfile-Geolocation, \"(.*)region\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-BrowserProfile-Geolocation ~ \"city\") {\n set req.http.X-BrowserProfile-Geolocation-City = regsuball(req.http.X-BrowserProfile-Geolocation, \"(.*)city\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-BrowserProfile-Geolocation ~ \"isp\") {\n set req.http.X-BrowserProfile-Geolocation-ISP = regsuball(req.http.X-BrowserProfile-Geolocation, \"(.*)isp\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n } else {\n set req.http.X-BrowserProfile-Geolocation-Found = \"NO\";\n }\n }\n\n if (!req.http.X-Language) {\n if (req.http.Cookie ~ \"lang=\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.Cookie, \"(.*)lang=([^;]*)(.*)\", \"\\2\"));\n set req.http.X-Language-Found = \"YES:lang\";\n } else {\n set req.http.X-Language = \"en\";\n set req.http.X-Language-Found = \"NO\";\n }\n }\n\n if (!req.http.X-Region) {\n if (req.http.Cookie ~ \"prov=\") {\n set req.http.X-Region = std.tolower(regsuball(req.http.Cookie, \"(.*)prov=([^;]*)(.*)\", \"\\2\"));\n set req.http.X-Region-Found = \"YES:prov\";\n } else {\n set req.http.X-Region = \"bc\";\n set req.http.X-Region-Found = \"NO\";\n }\n }\n\n if (req.url ~ \"\/(en|fr)\/\") {\n if (req.url ~ \"\/en\/\" && req.http.X-Language != \"en\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Language (Path: \/en\/) vs (Cookie: \" + req.http.X-Language + \")\";\n return(pass);\n }\n if (req.url ~ \"\/fr\/\" && req.http.X-Language != \"fr\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Language (Path: \/fr\/) vs (Cookie: \" + req.http.X-Language + \")\";\n return(pass);\n }\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Language)\";\n return(pass);\n }\n\n if (req.url ~ \"\/(ab|bc|mb|nb|nl|ns|nt|nu|on|pe|qc|sk|yt)\/\") {\n {% for province in ['ab', 'bc', 'mb', 'nb', 'nl', 'ns', 'nt', 'nu', 'on', 'pe', 'qc', 'sk', 'yt'] %}\n if (req.url ~ \"\/{{ province }}\/\" && req.http.X-Region != \"{{ province }}\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Region (Path: \/{{ province }}\/) vs (Cookie: \" + req.http.X-Region + \")\";\n return(pass);\n }\n {% endfor %}\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Province)\";\n return(pass);\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_discard_from_client %}\n unset req.http.Cookie;\n{% endif %}\n}\n\n###\n# vcl_hit\n# Called when a cache lookup is successful.\n###\n# The vcl_hit subroutine may terminate with calling return() with one of the following keywords:\n#\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n# deliver\n# Deliver the object. Control passes to vcl_deliver.\n# synth(status code, reason)\n# Return the specified status code to the client and abandon the request.\n###\n\nsub vcl_hit {\n if (obj.ttl > 0s) {\n return (deliver);\n }\n{% if varnish_health_checks_enabled %}\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (fetch);\n }\n{% else %}\n if (obj.ttl + obj.grace > 0s) {\n return (deliver);\n }\n\n return (fetch);\n{% endif %}\n}\n\n###\n# vcl_backend_response\n# Called after the response headers has been successfully retrieved from the backend.\n###\n# The vcl_backend_response subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Possibly insert the object into the cache, then deliver it to the Control will eventually pass to vcl_deliver.\n# abandon\n# Abandon the backend request and generates an error.\n# retry\n# Retry the backend transaction. Increases the retries counter. If the number of retries is higher than max_retries Varnish emits a guru meditation error.\n###\n\nsub vcl_backend_response {\n{% if varnish_workaround_telusdotcom_browser_profile %}\n if (bereq.http.X-Language) {\n set beresp.http.X-Language = bereq.http.X-Language;\n# if (bereq.http.X-Language-Found) {\n# set beresp.http.X-Language-Found = bereq.http.X-Language-Found;\n# }\n }\n if (bereq.http.X-Region) {\n set beresp.http.X-Region = bereq.http.X-Region;\n# if (bereq.http.X-Region-Found) {\n# set beresp.http.X-Region-Found = bereq.http.X-Region-Found;\n# }\n }\n{% endif %}\n\n{% if varnish_uri_blacklist_enabled %}\n if (bereq.url ~ \"{{ varnish_uri_blacklist_regexp }}\") {\n set beresp.http.X-Cacheable = \"NO:Path in Blacklist\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n if (bereq.http.X-Passthrough-Reason) {\n set beresp.http.X-Passthrough-Reason = bereq.http.X-Passthrough-Reason;\n return(deliver);\n }\n }\n{% else %}\n{% if varnish_cookie_sanitization_discard_from_server %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n{% endif %}\n\n{% if varnish_diagnostic_headers_enabled %}\n if (bereq.http.Cookie) {\n set beresp.http.X-Cacheable = \"NO:Cookie in Request\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO:Set-Cookie in Response\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.X-No-Cache) {\n set beresp.http.X-Cacheable = \"NO:X-No-Cache\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.ttl <= 0s) {\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n{% endif %}\n\n set beresp.grace = {{ varnish_grace_period }};\n}\n\n###\n# vcl_deliver\n# Called before a cached object is delivered to the client.\n###\n# The vcl_deliver subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Deliver the object to the client.\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n###\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"3f106b09f2c708d51fc333f4eabf4e3d05c0e560","subject":"added varnish v3.0 default.vcl","message":"added varnish v3.0 default.vcl\n","repos":"vkhatri\/chef-varnish-ng","old_file":"files\/default\/default3.0.vcl","new_file":"files\/default\/default3.0.vcl","new_contents":"#\n# This is an example VCL file for Varnish.\n#\n# It does not do anything by default, delegating control to the\n# builtin VCL. The builtin VCL is called when there is no explicit\n# return statement.\n#\n# See the VCL chapters in the Users Guide at https:\/\/www.varnish-cache.org\/docs\/\n# and http:\/\/varnish-cache.org\/trac\/wiki\/VCLExamples for more examples.\n#\n# This is a basic VCL configuration file for varnish. See the vcl(7)\n# man page for details on VCL syntax and semantics.\n#\n# Default backend definition. Set this to point to your content server.\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n .connect_timeout = 600s;\n .first_byte_timeout = 600s;\n .between_bytes_timeout = 600s;\n .max_connections = 800;\n}\n\n# Only allow purging from specific IPs\nacl purge {\n \"localhost\";\n \"127.0.0.1\";\n}\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'files\/default\/default3.0.vcl' did not match any file(s) known to git\n","license":"apache-2.0","lang":"VCL"} {"commit":"ab87c7b6deacb2f21bbc4fb3590bd3e1f98a2254","subject":"removing expire controls from varnish","message":"removing expire controls from varnish\n","repos":"cristianocasella\/cristianocasella.com,cristianocasella\/cristianocasella.com","old_file":"varnish\/varnish.vcl","new_file":"varnish\/varnish.vcl","new_contents":"","old_contents":"","returncode":128,"stderr":"remote: Support for password authentication was removed on August 13, 2021.\nremote: Please see https:\/\/docs.github.com\/en\/get-started\/getting-started-with-git\/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.\nfatal: Authentication failed for 'https:\/\/github.com\/cristianocasella\/cristianocasella.com.git\/'\n","license":"mit","lang":"VCL"} {"commit":"5ae7f8a17b32ad245e66dc780f094b11726200be","subject":"first draft at varnish","message":"first draft at varnish\n","repos":"erezny\/twitter-import","old_file":"varnish\/twitter.vcl","new_file":"varnish\/twitter.vcl","new_contents":"","old_contents":"","returncode":128,"stderr":"remote: Support for password authentication was removed on August 13, 2021.\nremote: Please see https:\/\/docs.github.com\/en\/get-started\/getting-started-with-git\/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.\nfatal: Authentication failed for 'https:\/\/github.com\/erezny\/twitter-import.git\/'\n","license":"mit","lang":"VCL"} {"commit":"b0753ff892d811ab7a248fe3d0ae23b4c72983a0","subject":"* Move PURGE to a place where it does some good","message":"* Move PURGE to a place where it does some good\n\n* Make http auth work\n\n\n\ngit-svn-id: 7d4b18ab7d176792635d6a7a77dd8cbbea8e8daa@1499 d4fa192b-c00b-0410-8231-f00ffab90ce4\n","repos":"wikimedia\/operations-debs-varnish,CartoDB\/Varnish-Cache,CartoDB\/Varnish-Cache,ssm\/pkg-varnish,ssm\/pkg-varnish,wikimedia\/operations-debs-varnish,ssm\/pkg-varnish,ssm\/pkg-varnish,CartoDB\/Varnish-Cache,ssm\/pkg-varnish,wikimedia\/operations-debs-varnish,wikimedia\/operations-debs-varnish,wikimedia\/operations-debs-varnish","old_file":"etc\/zope-plone.vcl","new_file":"etc\/zope-plone.vcl","new_contents":"","old_contents":"","returncode":128,"stderr":"remote: Support for password authentication was removed on August 13, 2021.\nremote: Please see https:\/\/docs.github.com\/en\/get-started\/getting-started-with-git\/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.\nfatal: Authentication failed for 'https:\/\/github.com\/wikimedia\/operations-debs-varnish.git\/'\n","license":"bsd-2-clause","lang":"VCL"} {"commit":"0076475fa09f011d2b60f8ec6b3de5aa18fbfa7d","subject":"tuning varnish","message":"tuning varnish\n","repos":"cristianocasella\/cristianocasella.com,cristianocasella\/cristianocasella.com","old_file":"varnish\/varnish.vcl","new_file":"varnish\/varnish.vcl","new_contents":"","old_contents":"","returncode":128,"stderr":"remote: Support for password authentication was removed on August 13, 2021.\nremote: Please see https:\/\/docs.github.com\/en\/get-started\/getting-started-with-git\/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.\nfatal: Authentication failed for 'https:\/\/github.com\/cristianocasella\/cristianocasella.com.git\/'\n","license":"mit","lang":"VCL"} {"commit":"278c0d595d56211db7fc2d7a5737f07dd71f818c","subject":"added twitter page when down","message":"added twitter page when down\n","repos":"chrisguilbeau\/taproot,chrisguilbeau\/taproot","old_file":"config\/default.vcl","new_file":"config\/default.vcl","new_contents":"# This is a basic VCL configuration file for varnish. See the vcl(7)\n# man page for details on VCL syntax and semantics.\n#\n# Default backend definition. Set this to point to your content\n# server.\n#\nbackend default {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n}\n\nsub vcl_error {\n if (obj.status >= 500 && obj.status <= 505) {\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n synthetic {\"\n <html>\n <head>\n <title>taproot is down<\/title>\n <\/head>\n <body>\n <center>\n <a class=\"twitter-timeline\" href=\"https:\/\/twitter.com\/hashtag\/taprootapp\" data-widget-id=\"505821277383180288\">#taprootapp Tweets<\/a>\n <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=\/^http:\/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+\":\/\/platform.twitter.com\/widgets.js\";fjs.parentNode.insertBefore(js,fjs);}}(document,\"script\",\"twitter-wjs\");<\/script>\n <\/center>\n <\/body>\n <\/html>\n \"};\n }\n return (deliver);\n}\n#\n# Below is a commented-out copy of the default VCL logic. If you\n# redefine any of these subroutines, the built-in logic will be\n# appended to your code.\n# sub vcl_recv {\n# if (req.restarts == 0) {\n# \tif (req.http.x-forwarded-for) {\n# \t set req.http.X-Forwarded-For =\n# \t\treq.http.X-Forwarded-For + \", \" + client.ip;\n# \t} else {\n# \t set req.http.X-Forwarded-For = client.ip;\n# \t}\n# }\n# if (req.request != \"GET\" &&\n# req.request != \"HEAD\" &&\n# req.request != \"PUT\" &&\n# req.request != \"POST\" &&\n# req.request != \"TRACE\" &&\n# req.request != \"OPTIONS\" &&\n# req.request != \"DELETE\") {\n# \/* Non-RFC2616 or CONNECT which is weird. *\/\n# return (pipe);\n# }\n# if (req.request != \"GET\" && req.request != \"HEAD\") {\n# \/* We only deal with GET and HEAD by default *\/\n# return (pass);\n# }\n# if (req.http.Authorization || req.http.Cookie) {\n# \/* Not cacheable by default *\/\n# return (pass);\n# }\n# return (lookup);\n# }\n#\n# sub vcl_pipe {\n# # Note that only the first request to the backend will have\n# # X-Forwarded-For set. If you use X-Forwarded-For and want to\n# # have it set for all requests, make sure to have:\n# # set bereq.http.connection = \"close\";\n# # here. It is not set by default as it might break some broken web\n# # applications, like IIS with NTLM authentication.\n# return (pipe);\n# }\n#\n# sub vcl_pass {\n# return (pass);\n# }\n#\n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (hash);\n# }\n#\n# sub vcl_hit {\n# return (deliver);\n# }\n#\n# sub vcl_miss {\n# return (fetch);\n# }\n#\n# sub vcl_fetch {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Vary == \"*\") {\n# \t\t\/*\n# \t\t * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# \t\t *\/\n# \t\tset beresp.ttl = 120 s;\n# \t\treturn (hit_for_pass);\n# }\n# return (deliver);\n# }\n#\n# sub vcl_deliver {\n# return (deliver);\n# }\n#\n# sub vcl_error {\n# set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n# set obj.http.Retry-After = \"5\";\n# synthetic {\"\n# <?xml version=\"1.0\" encoding=\"utf-8\"?>\n# <!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n# \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n# <html>\n# <head>\n# <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n# <\/head>\n# <body>\n# <h1>Error \"} + obj.status + \" \" + obj.response + {\"<\/h1>\n# <p>\"} + obj.response + {\"<\/p>\n# <h3>Guru Meditation:<\/h3>\n# <p>XID: \"} + req.xid + {\"<\/p>\n# <hr>\n# <p>Varnish cache server<\/p>\n# <\/body>\n# <\/html>\n# \"};\n# return (deliver);\n# }\n#\n# sub vcl_init {\n# \treturn (ok);\n# }\n#\n# sub vcl_fini {\n# \treturn (ok);\n# }\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'config\/default.vcl' did not match any file(s) known to git\n","license":"mit","lang":"VCL"} {"commit":"adea0950fd596b228e0e426cf00a6e39cb55f06a","subject":"added debugging headers in vcl_fetch","message":"added debugging headers in vcl_fetch\n","repos":"NITEMAN\/Varnish_VCL_samps-hacks,NITEMAN\/varnish-bites","old_file":"varnish 3 vcls\/drupal_base.vcl","new_file":"varnish 3 vcls\/drupal_base.vcl","new_contents":"","old_contents":"","returncode":1,"stderr":"error: pathspec 'varnish' did not match any file(s) known to git\nerror: pathspec '3' did not match any file(s) known to git\nerror: pathspec 'vcls\/drupal_base.vcl' did not match any file(s) known to git\n","license":"unknown","lang":"VCL"} {"commit":"8ca29b5aa712dc2a246cb58e40e2af7df3edb37a","subject":"fixed typo","message":"fixed typo\n","repos":"NITEMAN\/varnish-bites,NITEMAN\/Varnish_VCL_samps-hacks","old_file":"varnish 3 vcls\/drupal_base.vcl","new_file":"varnish 3 vcls\/drupal_base.vcl","new_contents":"","old_contents":"","returncode":1,"stderr":"error: pathspec 'varnish' did not match any file(s) known to git\nerror: pathspec '3' did not match any file(s) known to git\nerror: pathspec 'vcls\/drupal_base.vcl' did not match any file(s) known to git\n","license":"unknown","lang":"VCL"} {"commit":"4ad1aa9fa2f7b0597419508e54f147c97b08fa97","subject":"Avoid DOS by CVE-2013-4484. See https:\/\/www.varnish-cache.org\/lists\/pipermail\/varnish-announce\/2013-October\/000686.html","message":"Avoid DOS by CVE-2013-4484. See https:\/\/www.varnish-cache.org\/lists\/pipermail\/varnish-announce\/2013-October\/000686.html\n","repos":"NITEMAN\/Varnish_VCL_samps-hacks,NITEMAN\/varnish-bites","old_file":"varnish 3 vcls\/drupal_base.vcl","new_file":"varnish 3 vcls\/drupal_base.vcl","new_contents":"","old_contents":"","returncode":1,"stderr":"error: pathspec 'varnish' did not match any file(s) known to git\nerror: pathspec '3' did not match any file(s) known to git\nerror: pathspec 'vcls\/drupal_base.vcl' did not match any file(s) known to git\n","license":"unknown","lang":"VCL"} {"commit":"dca4fde0d0fac098814a41cb678fcf78eb819f2c","subject":"New example of configuration file: varnish to proxy your API request with 3scale backend not proxied","message":"New example of configuration file: varnish to proxy your API request with 3scale backend not proxied\n","repos":"3scale\/libvmod-3scale,3scale\/libvmod-3scale","old_file":"vcl\/default_3scale_only_proxy.vcl","new_file":"vcl\/default_3scale_only_proxy.vcl","new_contents":"# This is a the VCL configuration file for 3scale's varnish plugin.\n# \n# Default backend definition. Set this to point to the 3scale's\n# backend. \n# \n# set the beresp.ttl in vcl_fetch to have a default global TTL\n# you can define custom TTL via regular expressions\n#\n\n## the backend of your API\nbackend origin_server {\n .host = \"YOU_ORIGIN_API_HOSTNAME\"; \n .port = \"80\";\n}\n\nimport std;\nimport threescale;\n\nsub vcl_recv {\n\n unset req.http.cookie;\n\n\n ## this request was send by the end-user\n set req.backend = origin_server;\n \n set req.http.X-3scale-authrep = \"\/transactions\/authrep.xml?provider_key=YOUR_PROVIDER_KEY\";\n\n ## ------------------\n ## MAPPING OF METHODS\n ## ------------------\n\n if (req.url ~ \"^\/deals\/\") {\n set req.http.X-3scale-authrep = req.http.X-3scale-authrep + \"&usage[deals]=1\";\n }\n\n if (req.url ~ \"^\/sales\/local\") {\n set req.http.X-3scale-authrep = req.http.X-3scale-authrep + \"&usage[sales]=1&usage[local]=1\";\n }\n \n ## ----------------------\n ## END MAPPING OF METHODS\n ## ----------------------\n\n ## extract the parameters sent by the user\n set req.http.X-3scale-app_id = regsub(req.url,\".*[&?](app_id.[^&]*).*\",\"\\1\");\n set req.http.X-3scale-app_key = regsub(req.url,\".*[&?](app_key.[^&]*).*\",\"\\1\");\n set req.http.X-3scale-user_key = regsub(req.url,\".*[&?](user_key.[^&]*).*\",\"\\1\");\n set req.http.X-3scale-user_id = regsub(req.url,\".*[&?](user_id.[^&]*).*\",\"\\1\");\n\n if (req.http.X-3scale-app_id != req.url) {\n set req.http.X-3scale-authrep = req.http.X-3scale-authrep + \"&\" + req.http.X-3scale-app_id; \n }\n\n if (req.http.X-3scale-app_key != req.url ) {\n set req.http.X-3scale-authrep = req.http.X-3scale-authrep + \"&\" + req.http.X-3scale-app_key; \n }\n\n if (req.http.X-3scale-user_id != req.url) {\n set req.http.X-3scale-authrep = req.http.X-3scale-authrep + \"&\" + req.http.X-3scale-user_id; \n }\n\n if (req.http.X-3scale-user_key != req.url) {\n set req.http.X-3scale-authrep = req.http.X-3scale-authrep + \"&\" + req.http.X-3scale-user_key; \n }\n \n unset req.http.X-3scale-app_id;\n unset req.http.X-3scale-app_key;\n unset req.http.X-3scale-user_id;\n unset req.http.X-3scale-user_key;\n\n\n set req.http.X-3scale-authrep-result = threescale.send_get_request(\"su1.3scale.net\",\"80\",req.http.X-3scale-authrep,\"\");\n\n if (req.http.X-3scale-authrep-result == \"200\") {\n ## the request from the user has been authorized, proceed as normal\n\n if (req.request != \"GET\" && req.request != \"HEAD\") {\n return(pass);\n } \n else {\n return(lookup);\n }\n \n }\n else {\n ## the request from the users has not been authorized!! Returning an error\n ## FIXME: convert req.http.X-3scale-authrep-result; to int\n error 401;\n } \n\n unset req.http.X-3scale-authrep;\n unset req.http.X-3scale-authrep-result;\n\n\t \n}\n\n# the hash of the request needs to be customized to remove all fields that are not \n# associated to the user\n\nsub vcl_hash {\n\n set req.http.X-url-tmp = regsub(req.url,\"[&?]user_key.[^&]*\",\"\");\n set req.http.X-url-tmp = regsub(req.url,\"[&?]user_id.[^&]*\",\"\");\n set req.http.X-url-tmp = regsub(req.url,\"[&?]app_key.[^&]*\",\"\");\n set req.http.X-url-tmp = regsub(req.url,\"[&?]app_id.[^&]*\",\"\");\n\n hash_data(req.http.X-url-tmp);\n\n if (req.http.host) {\n hash_data(req.http.host);\n } \n else {\n hash_data(server.ip);\n }\n \n unset req.http.X-url-tmp;\n\n return (hash);\n\n}\n\n#A HIT means that the request to your local cache of 3scale is still fresh and the\n#response will not have to fetch the data from the remote 3scale backend.\n#vmod_3scale plugin will send a replica of the call asynchronously to 3scale's remote\n#backend on its own\n\nsub vcl_fetch {\n ## 5 minutes caching for everything\n set beresp.ttl = 5m;\n}\n\nsub vcl_deliver {\n ## remove control headers\n unset req.http.X-3scale-authrep;\n}\n\n\n\nsub vcl_error {\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n synthetic {\"\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n<html>\n <head>\n <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n <\/head>\n <body>\n <div style=\"background-color:yellow;\">\n <h2>Authorization error trying to access this API<\/h2>\n <p>Did you forget to send your credentials?<\/p>\n <p>Are you over the limits of your account?<\/p> \n <p><b>Please go to your account at http:\/\/your3scaledomain.com to find out<\/b><\/p>\n <\/div>\n <\/body>\n<\/html>\n\"};\n return (deliver);\n}\n\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'vcl\/default_3scale_only_proxy.vcl' did not match any file(s) known to git\n","license":"bsd-2-clause","lang":"VCL"} {"commit":"29a35f87edf4284ee615f5b5b58ac9ec36aebb70","subject":"VCL request","message":"VCL request\n\nAdded custom Deliver Custom Header\n","repos":"kevin25\/fastly","old_file":"custom52.vcl","new_file":"custom52.vcl","new_contents":"sub vcl_recv {\n #FASTLY recv\n if (req.request != \"HEAD\" && req.request != \"GET\" && req.request != \"FASTLYPURGE\") {\n return(pass);\n }\n return(lookup);\n\n}\nsub vcl_fetch {\n\t#FASTLY fetch\n\n if (beresp.http.Vary) {\n set beresp.http.Vary = beresp.http.Vary \", MyLang\";\n } else {\n set beresp.http.Vary = \"MyLang\";\n }\n if ((beresp.status == 500 || beresp.status == 503) && req.restarts < 1 && (req.request == \"GET\" || req.request == \"HEAD\")) {\n restart;\n }\n\n if(req.restarts > 0 ) {\n set beresp.http.Fastly-Restarts = req.restarts;\n }\n\n if (beresp.http.Set-Cookie) {\n set req.http.Fastly-Cachetype = \"SETCOOKIE\";\n return (pass);\n }\n\n if (beresp.http.Cache-Control ~ \"private\") {\n set req.http.Fastly-Cachetype = \"PRIVATE\";\n return (pass);\n }\n\n if (beresp.status == 500 || beresp.status == 503) {\n set req.http.Fastly-Cachetype = \"ERROR\";\n set beresp.ttl = 1s;\n set beresp.grace = 5s;\n return (deliver);\n }\n\n if (beresp.http.Expires || beresp.http.Surrogate-Control ~ \"max-age\" || beresp.http.Cache-Control ~\"(s-maxage|max-age)\") {\n # keep the ttl here\n } else {\n # apply the default ttl\n set beresp.ttl = 3600s;\n }\n return(deliver);\n\n}\nsub vcl_deliver {\n\t#FASTLY deliver\n if (resp.http.Vary) {\n set resp.http.Vary = regsub(resp.http.Vary, \"MyLang\", \"WebSiteLang\");\n } \n if (req.url ~ \"ja\" && req.http.Cookie !~ \"WebSiteLang=ja\") { \n add resp.http.Set-Cookie = \"WebSiteLang=ja; expires=\" now + 180d \"; path=\/;\";\n } \n if (req.url ~ \"es\" && req.http.Cookie !~ \"WebSiteLang=es\") { \n add resp.http.Set-Cookie = \"WebSiteLang=es; expires=\" now + 180d \"; path=\/;\";\n }\n if (req.url ~ \"pt\" && req.http.Cookie !~ \"WebSiteLang=pt\") { \n add resp.http.Set-Cookie = \"WebSiteLang=pt; expires=\" now + 180d \"; path=\/;\";\n } \n if (req.url ~ \"it\" && req.http.Cookie !~ \"WebSiteLang=it\") { \n add resp.http.Set-Cookie = \"WebSiteLang=it; expires=\" now + 180d \"; path=\/;\";\n } \n if (req.url ~ \"fr\" && req.http.Cookie !~ \"WebSiteLang=fr\") { \n add resp.http.Set-Cookie = \"WebSiteLang=fr; expires=\" now + 180d \"; path=\/;\";\n } \n if (req.url ~ \"de\" && req.http.Cookie !~ \"WebSiteLang=de\") { \n add resp.http.Set-Cookie = \"WebSiteLang=de; expires=\" now + 180d \"; path=\/;\";\n }\n if (req.url ~ \"en\" && req.http.Cookie !~ \"WebSiteLang=en\") { \n add resp.http.Set-Cookie = \"WebSiteLang=en; expires=\" now + 180d \"; path=\/;\";\n }\n \n}\nsub vcl_hit {\n#FASTLY hit\n\n if (!obj.cacheable) {\n return(pass);\n }\n return(deliver);\n}\n\nsub vcl_miss {\n#FASTLY miss\n return(fetch);\n}\nsub vcl_error {\n#FASTLY error\n}\n\nsub vcl_pass {\n#FASTLY pass\n}\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'custom52.vcl' did not match any file(s) known to git\n","license":"mit","lang":"VCL"} {"commit":"5b9d854514899041351ef142166056c527bc20b2","subject":"fixing ip address for backend","message":"fixing ip address for backend\n","repos":"cristianocasella\/cristianocasella.com,cristianocasella\/cristianocasella.com","old_file":"varnish\/varnish.vcl","new_file":"varnish\/varnish.vcl","new_contents":"","old_contents":"","returncode":128,"stderr":"remote: Support for password authentication was removed on August 13, 2021.\nremote: Please see https:\/\/docs.github.com\/en\/get-started\/getting-started-with-git\/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.\nfatal: Authentication failed for 'https:\/\/github.com\/cristianocasella\/cristianocasella.com.git\/'\n","license":"mit","lang":"VCL"} {"commit":"01a660000d00043d1c6620256a070b385179202b","subject":"Comment cleanup","message":"Comment cleanup\n\nAs noted by @kbemelmans on https:\/\/github.com\/NITEMAN\/Varnish_VCL_samps-hacks\/commit\/4ad1aa9fa2f7b0597419508e54f147c97b08fa97#commitcomment-4548026","repos":"NITEMAN\/Varnish_VCL_samps-hacks,NITEMAN\/varnish-bites","old_file":"varnish 3 vcls\/drupal_base.vcl","new_file":"varnish 3 vcls\/drupal_base.vcl","new_contents":"","old_contents":"","returncode":1,"stderr":"error: pathspec 'varnish' did not match any file(s) known to git\nerror: pathspec '3' did not match any file(s) known to git\nerror: pathspec 'vcls\/drupal_base.vcl' did not match any file(s) known to git\n","license":"unknown","lang":"VCL"} {"commit":"5fdd253782e30925b81a46952210d8407a80f2c4","subject":"drupal_base.vcl Mix & Fun of X-Forwarded-Proto thanks to penyaskito","message":"drupal_base.vcl Mix & Fun of X-Forwarded-Proto thanks to penyaskito\n","repos":"NITEMAN\/varnish-bites,NITEMAN\/Varnish_VCL_samps-hacks","old_file":"varnish 3 vcls\/drupal_base.vcl","new_file":"varnish 3 vcls\/drupal_base.vcl","new_contents":"","old_contents":"","returncode":1,"stderr":"error: pathspec 'varnish' did not match any file(s) known to git\nerror: pathspec '3' did not match any file(s) known to git\nerror: pathspec 'vcls\/drupal_base.vcl' did not match any file(s) known to git\n","license":"unknown","lang":"VCL"} {"commit":"67cb9ea18e4c98986c66b2c8eb74655c9370814d","subject":"Started developing\/learning a varnish.vcl file for D3Up. Dont judge!","message":"Started developing\/learning a varnish.vcl file for D3Up. Dont judge!\n","repos":"D3Up\/D3Up.com,D3Up\/D3Up.com,D3Up\/D3Up.com,D3Up\/D3Up.com","old_file":"varnish.vcl","new_file":"varnish.vcl","new_contents":"","old_contents":"","returncode":128,"stderr":"remote: Support for password authentication was removed on August 13, 2021.\nremote: Please see https:\/\/docs.github.com\/en\/get-started\/getting-started-with-git\/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.\nfatal: Authentication failed for 'https:\/\/github.com\/D3Up\/D3Up.com.git\/'\n","license":"mit","lang":"VCL"} {"commit":"9a876e54f0e15cbeb3b290b1cab9822fe7b55519","subject":"added placeholders TO-DOs to give a better debugging info","message":"added placeholders TO-DOs to give a better debugging info\n","repos":"NITEMAN\/Varnish_VCL_samps-hacks,NITEMAN\/varnish-bites","old_file":"varnish 3 vcls\/drupal_base.vcl","new_file":"varnish 3 vcls\/drupal_base.vcl","new_contents":"","old_contents":"","returncode":1,"stderr":"error: pathspec 'varnish' did not match any file(s) known to git\nerror: pathspec '3' did not match any file(s) known to git\nerror: pathspec 'vcls\/drupal_base.vcl' did not match any file(s) known to git\n","license":"unknown","lang":"VCL"} {"commit":"09ec69262f97d6648bd46a2dca36907cba8141af","subject":"re #444 : Add nooku.vcl for varnish 4.0","message":"re #444 : Add nooku.vcl for varnish 4.0\n","repos":"nooku\/nooku-platform,timble\/kodekit-platform,timble\/kodekit-platform,nooku\/nooku-platform,timble\/kodekit-platform,nooku\/nooku-platform,nooku\/nooku-platform,timble\/kodekit-platform,timble\/kodekit-platform,nooku\/nooku-platform","old_file":"component\/varnish\/resources\/varnish\/nooku.vcl","new_file":"component\/varnish\/resources\/varnish\/nooku.vcl","new_contents":"vcl 4.0;\n\n# Based on: https:\/\/github.com\/mattiasgeniar\/varnish-4.0-configuration-templates\/blob\/master\/default.vcl\n# Corrected & improved for 4.0.2 by jnerin@gmail.com\n\nimport std;\nimport directors;\n\n# Backend definitions\nbackend default\n{\n .host = \"127.0.0.1\"; # IP or Hostname of backend\n .port = \"8080\"; # Port Apache or whatever is listening\n .max_connections = 300; # That's it\n .probe = {\n #.url = \"\/varnish-enabled\";\n # We prefer to only do a HEAD \/\n .request =\n \"HEAD \/varnish-enabled HTTP\/1.1\"\n \"Host: localhost\"\n \"Connection: close\";\n .interval = 5s; # check the health of each backend every 5 seconds\n .timeout = 1s; # timing out after 1 second.\n # If 3 out of the last 5 polls succeeded the backend is considered healthy, otherwise it will be marked as sick\n .window = 5;\n .threshold = 3;\n }\n\n .connect_timeout = 600s; # How long to wait before we receive a first byte from our backend?\n .first_byte_timeout = 600s; # How long to wait for a backend connection?\n .between_bytes_timeout = 600s; # How long to wait between bytes received from our backend?\n}\n\n# Acl definitions\nacl localhost\n{\n \"localhost\";\n \"33.33.33.63\";\n \"::1\";\n}\n\n# Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\nsub vcl_init\n{\n new vdir = directors.round_robin();\n vdir.add_backend(default);\n # vdir.add_backend(server...);\n # vdir.add_backend(servern);\n}\n\n# Called at the beginning of a request, after the complete request has been received and parsed. Its purpose is to\n# decide whether or not to serve the request, how to do it, and, if applicable, which backend to use also used to\n# modify the request\nsub vcl_recv\n{\n # Add a Surrogate-Capability header to announce ESI support.\n set req.http.Surrogate-Capability = \"varnish=ESI\/1.0\";\n\n # Send all traffic to the vdir director\n set req.backend_hint = vdir.backend(); # send all traffic to the vdir director\n\n if (req.restarts == 0)\n {\n # Set or append the client.ip to X-Forwarded-For header\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n\n set req.http.X-Forwarded-By = server.ip;\n set req.http.X-Forwarded-Port = std.port(client.ip);\n }\n\n # Normalize the header, remove the port (in case you're testing this on various TCP ports)\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n\n # Normalize the query arguments\n set req.url = std.querysort(req.url);\n\n # Allow purging\n if (req.method == \"PURGE\")\n {\n # purge is the ACL defined at the begining\n if (!client.ip ~ localhost) {\n return (synth(405, \"This IP is not allowed to send PURGE requests.\"));\n }\n\n return (purge);\n }\n\n # Only deal with \"normal\" types\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"PATCH\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n # Implementing websocket support (https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html)\n if (req.http.Upgrade ~ \"(?i)websocket\") {\n return (pipe);\n }\n\n # Only cache GET or HEAD requests. This makes sure the POST requests are always passed.\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n return (pass);\n }\n\n # Send Surrogate-Capability headers to announce ESI support to backend\n set req.http.Surrogate-Capability = \"key=ESI\/1.0\";\n if (req.http.Authorization)\n {\n # Not cacheable by default\n return (pass);\n }\n\n # Check if we've still enabled Varnish, if not, passthrough every request\n if (! std.healthy(req.backend_hint))\n {\n set req.backend_hint = default;\n return (pass);\n }\n\n # Specific Nooku Platform rules\n\n # Do not cache \/administrator\n if(req.url ~ \"^\/administrator\") {\n return (pass);\n }\n\n # Specific Nooku Server rules\n\n # Do not cache webgrind.nooku.dev\n if (req.http.host == \"webgrind.nooku.dev\") {\n return (pass);\n }\n\n # Do not cache phpmyadmin.nooku.dev\n if (req.http.host == \"phpmyadmin.nooku.dev\") {\n return (pass);\n }\n\n # Do not cache \/apc and \/phpinfo\n if (req.url == \"\/apc\" || req.url == \"\/phpinfo\") {\n return (pass);\n }\n\n # Generic URL manipulation, useful for all templates that follow\n\n # Remove the Google Analytics added parameters, useless for our backend\n if (req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=\") {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|utm_content|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # Strip hash, server doesn't need it.\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n # Strip a trailing ? if it exists\n if (req.url ~ \"\\?$\") {\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n\n # Cookie manipulation\n\n # Remove the \"has_js\" cookie\n set req.http.Cookie = regsuball(req.http.Cookie, \"has_js=[^;]+(; )?\", \"\");\n\n # Remove any Google Analytics based cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__utm.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"_ga=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmctr=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmcmd.=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"utmccn.=[^;]+(; )?\", \"\");\n\n # Remove DoubleClick offensive cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__gads=[^;]+(; )?\", \"\");\n\n # Remove the Quant Capital cookies (added by some plugin, all __qca)\n set req.http.Cookie = regsuball(req.http.Cookie, \"__qc.=[^;]+(; )?\", \"\");\n\n # Remove the AddThis cookies\n set req.http.Cookie = regsuball(req.http.Cookie, \"__atuv.=[^;]+(; )?\", \"\");\n\n # Remove a \";\" prefix in the cookie if present\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n\n # Remove the csrf_token cookie\n set req.http.Cookie = regsuball(req.http.Cookie, \"csrf_token=[^;]+(; )?\", \"\");\n\n # Are there cookies left with only spaces or that are empty?\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n\n # We do not support SPDY or HTTP\/2.0\n if (req.method == \"PRI\") {\n return (synth(405));\n }\n\n # Normalize Accept-Encoding header\n # straight from the manual: https:\/\/www.varnish-cache.org\/docs\/3.0\/tutorial\/vary.html\n # TODO: Test if it's still needed, Varnish 4 now does this by itself if http_gzip_support = on\n # https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/compression.html\n # https:\/\/www.varnish-cache.org\/docs\/trunk\/phk\/gzip.html\n if (req.http.Accept-Encoding)\n {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n # No point in compressing these\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n # unkown algorithm\n unset req.http.Accept-Encoding;\n }\n }\n\n if (req.http.Cache-Control ~ \"(?i)no-cache\" && client.ip ~ localhost)\n {\n # http:\/\/varnish.projects.linpro.no\/wiki\/VCLExampleEnableForceRefresh\n # Ignore requests via proxy caches and badly behaved crawlers\n # like msnbot that send no-cache with every request.\n if (! (req.http.Via || req.http.User-Agent ~ \"(?i)bot\" || req.http.X-Purge))\n {\n # Doesn't seems to refresh the object in the cache\n set req.hash_always_miss = true;\n\n # Couple this with restart in vcl_purge and X-Purge header to avoid loops\n return(purge);\n }\n }\n\n # Large static files are delivered directly to the end-user without waiting for Varnish to fully read the file first.\n # Varnish 4 fully supports Streaming, so set do_stream in vcl_backend_response()\n if (req.url ~ \"^[^?]*\\.(mp[34]|rar|tar|tgz|gz|wav|zip|bz2|xz|7z|avi|mov|ogm|mpe?g|mk[av])(\\?.*)?$\") {\n unset req.http.Cookie;\n return (hash);\n }\n\n # Remove all cookies for static files\n # Before you blindly enable this, have a read here: https:\/\/ma.ttias.be\/stop-caching-static-files\/\n if (req.method == \"GET\")\n {\n # Cache files with these extensions and remove cookie\n if (req.url ~ \"^[^?]*\\.(bmp|bz2|css|doc|eot|flv|gif|gz|ico|jpeg|jpg|js|less|pdf|png|rtf|swf|txt|woff|xml)(\\?.*)?$\") {\n unset req.http.Cookie;\n return (hash);\n }\n }\n\n return (hash);\n}\n\n# Called upon entering pipe mode. In this mode, the request is passed on to the backend, and any further data from both\n# the client and backend is passed on unaltered until either end closes the connection. Basically, Varnish will degrade\n# into a simple TCP proxy, shuffling bytes back and forth. For a connection in pipe mode, no other VCL subroutine will\n# ever get called after vcl_pipe.\nsub vcl_pipe\n{\n # Note that only the first request to the backend will have X-Forwarded-For set.\n # If you use X-Forwarded-For and want to have it set for all requests, make sure to have:\n # set bereq.http.connection = \"close\";\n # It is not set by default as it might break some broken web applications, like IIS with NTLM authentication.\n # set bereq.http.Connection = \"Close\";\n\n # Implementing websocket support (https:\/\/www.varnish-cache.org\/docs\/4.0\/users-guide\/vcl-example-websockets.html)\n if (req.http.upgrade) {\n set bereq.http.upgrade = req.http.upgrade;\n }\n\n return (pipe);\n}\n\n# Called upon entering pass mode. In this mode, the request is passed on to the backend, and the backend's response\n# is passed on to the client, but is not entered into the cache. Subsequent requests submitted over the same client\n# connection are handled normally.\nsub vcl_pass\n{\n return (fetch);\n}\n\n# Called after vcl_recv to create a hash value for the request. This is used as a key to look up the object in Varnish.\nsub vcl_hash\n{\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n\n # hash cookies for requests that have them\n if (req.http.Cookie) {\n hash_data(req.http.Cookie);\n }\n}\n\n# Called when a cache lookup is successful.\nsub vcl_hit\n{\n # A pure unadultered hit, deliver it\n if (obj.ttl >= 0s) {\n return (deliver);\n }\n\n # https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-grace.html\n # When several clients are requesting the same page Varnish will send one request to the backend and place the\n # others on hold while fetching one copy from the backend. In some products this is called request coalescing and\n # Varnish does this automatically.\n\n # If you are serving thousands of hits per second the queue of waiting requests can get huge. There are two\n # potential problems - one is a thundering herd problem - suddenly releasing a thousand threads to serve content\n # might send the load sky high. Secondly - nobody likes to wait. To deal with this we can instruct Varnish to keep\n # the objects in cache beyond their TTL and to serve the waiting requests somewhat stale content.\n\n # if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n # return (deliver);\n # } else {\n # return (fetch);\n # }\n\n # We have no fresh fish. Lets look at the stale ones.\n if (std.healthy(req.backend_hint))\n {\n # Backend is healthy. Limit age to 10s.\n if (obj.ttl + 10s > 0s)\n {\n #set req.http.grace = \"normal(limited)\";\n return (deliver);\n }\n else\n {\n # No candidate for grace. Fetch a fresh object.\n return(fetch);\n }\n }\n else\n {\n # backend is sick - use full grace\n if (obj.ttl + obj.grace > 0s)\n {\n #set req.http.grace = \"full\";\n return (deliver);\n }\n else\n {\n # no graced object.\n return (fetch);\n }\n }\n\n # fetch & deliver once we get the result\n return (fetch); # Dead code, keep as a safeguard\n}\n\n# Called after a cache lookup if the requested document was not found in the cache. Its purpose is to decide whether\n# or not to attempt to retrieve the document from the backend, and which backend to use.\nsub vcl_miss\n{\n return (fetch);\n}\n\n # Called after the response headers has been successfully retrieved from the backend.\nsub vcl_backend_response\n{\n # Enable ESI handling\n if (beresp.http.Surrogate-Control ~ \"ESI\/1.0\" ) {\n set beresp.do_esi = true;\n }\n\n # Store the csrf_token cookie temporarily if the response is cacheabale\n if (beresp.http.Set-Cookie && beresp.uncacheable )\n {\n set beresp.http.X-Varnish-Cookie = beresp.http.Set-Cookie;\n unset beresp.http.Set-Cookie;\n }\n\n # Enable cache for all static files\n # Before you blindly enable this, have a read here: https:\/\/ma.ttias.be\/stop-caching-static-files\/\n if (bereq.method == \"GET\")\n {\n if (bereq.url ~ \"^[^?]*\\.(bmp|bz2|css|doc|eot|flv|gif|gz|ico|jpeg|jpg|js|less|mp[34]|pdf|png|rar|rtf|swf|tar|tgz|txt|wav|woff|xml|zip)(\\?.*)?$\") {\n unset beresp.http.Set-Cookie;\n }\n }\n\n # Large static files are delivered directly to the end-user without waiting for Varnish to fully read the file first.\n # Varnish 4 fully supports Streaming, so use streaming here to avoid locking.\n if (bereq.url ~ \"^[^?]*\\.(mp[34]|rar|tar|tgz|gz|wav|zip|bz2|xz|7z|avi|mov|ogm|mpe?g|mk[av])(\\?.*)?$\")\n {\n unset beresp.http.Set-Cookie;\n set beresp.do_stream = true;\n # Check memory usage it'll grow in fetch_chunksize blocks (128k by default) if\n # the backend doesn't send a Content-Length header, so only enable it for big objects\n set beresp.do_gzip = false; # Don't try to compress it for storage\n }\n\n # Sometimes, a 301 or 302 redirect formed via Apache's mod_rewrite can mess with the HTTP port that is being passed along.\n # This often happens with simple rewrite rules in a scenario where Varnish runs on :80 and Apache on :8080 on the same box.\n # A redirect can then often redirect the end-user to a URL on :8080, where it should be :80.\n # This may need finetuning on your setup.\n #\n # To prevent accidental replace, we only filter the 301\/302 redirects for now.\n if (beresp.status == 301 || beresp.status == 302) {\n set beresp.http.Location = regsub(beresp.http.Location, \":[0-9]+\", \"\");\n }\n\n # Set 2min cache if unset for static files\n if (beresp.ttl <= 0s || beresp.http.Set-Cookie || beresp.http.Vary == \"*\")\n {\n set beresp.ttl = 120s; # Important, you shouldn't rely on this, SET YOUR HEADERS in the backend\n set beresp.uncacheable = true;\n\n return (deliver);\n }\n\n # Do not cache errors from the backend\n if (beresp.status >= 400)\n {\n set beresp.uncacheable = true;\n set beresp.ttl = 0s;\n\n return (deliver);\n }\n\n # Allow stale content, in case the backend goes down. Make Varnish keep all objects for 6 hours beyond their TTL\n set beresp.grace = 6h;\n\n # Set ban-lurker friendly custom headers\n set beresp.http.X-Varnish-Url = bereq.url;\n set beresp.http.X-Varnish-Host = bereq.http.host;\n\n return (deliver);\n}\n\n# Called when the backend returns an error\nsub vcl_backend_error\n{\n if (beresp.status == 503 && bereq.retries < 5)\n {\n set beresp.http.X-Varnish-Retries = bereq.retries;\n return(retry);\n }\n\n return(deliver);\n}\n\n# Called before a cached object is delivered to the client.\nsub vcl_deliver\n{\n # Send the Cookie header again if a temporay header was stored\n if (req.http.X-Varnish-Cookie) {\n set resp.http.Set-Cookie = req.http.X-Varnish-Cookie;\n }\n\n # Add extra headers if debugging is enabled\n if (resp.http.x-varnish-debug && server.ip ~ localhost)\n {\n set resp.http.X-Served-By = server.hostname;\n\n if (resp.http.x-varnish ~ \" \") {\n set resp.http.X-Varnish-Status = \"HIT\";\n } else {\n set resp.http.X-Varnish-Status = \"MISS\";\n }\n\n # Please note that obj.hits behaviour changed in 4.0, now it counts per objecthead, not per object\n # and obj.hits may not be reset in some cases where bans are in use. See bug 1492 for details.\n # So take hits with a grain of salt\n set resp.http.X-Varnish-Hits = obj.hits;\n }\n else\n {\n # Remove ban-lurker friendly custom headers when delivering to client\n unset resp.http.X-Url;\n unset resp.http.X-Host;\n\n # Remove some headers: PHP version\n unset resp.http.X-Powered-By;\n\n # Remove some headers: Apache version & OS\n unset resp.http.Server;\n unset resp.http.Via;\n unset resp.http.Link;\n unset resp.http.X-Varnish;\n unset resp.http.X-Varnish-Tag;\n unset resp.http.X-Varnish-Debug;\n unset resp.http.X-Varnish-Host;\n unset resp.http.X-Varnish-Url;\n unset resp.http.X-Varnish-Retries;\n unset resp.http.X-Varnish-Cookie;\n unset resp.http.Surrogate-Control;\n }\n\n return (deliver);\n}\n\nsub vcl_purge\n{\n # Only handle actual PURGE HTTP methods, everything else is discarded\n if (req.method != \"PURGE\" && server.ip ~ localhost)\n {\n set req.http.X-Varnish-Purge = \"Yes\";\n return(restart);\n }\n}\n\nsub vcl_synth\n{\n if (resp.status == 720)\n {\n # We use this special error status 720 to force redirects with 301 (permanent) redirects\n # To use this, call the following from anywhere in vcl_recv: return (synth(720, \"http:\/\/host\/new.html\"));\n set resp.status = 301;\n set resp.http.Location = resp.reason;\n\n return (deliver);\n }\n elseif (resp.status == 721)\n {\n # And we use error status 721 to force redirects with a 302 (temporary) redirect\n # To use this, call the following from anywhere in vcl_recv: return (synth(720, \"http:\/\/host\/new.html\"));\n\n set resp.status = 302;\n set resp.http.Location = resp.reason;\n\n return (deliver);\n }\n\n return (deliver);\n}\n\n# Called when VCL is discarded only after all requests have exited the VCL. Typically used to clean up VMODs.\nsub vcl_fini\n{\n return (ok);\n}\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'component\/varnish\/resources\/varnish\/nooku.vcl' did not match any file(s) known to git\n","license":"mpl-2.0","lang":"VCL"} {"commit":"dea1017af72fae76d16301e5c930b13311072a38","subject":"Added example VCL, set rule from curl.","message":"Added example VCL, set rule from curl.","repos":"Destination\/libvmod-abtest,Destination\/libvmod-abtest","old_file":"vcl\/default.vcl","new_file":"vcl\/default.vcl","new_contents":"\/*-\n * Copyright (c) 2006 Verdens Gang AS\n * Copyright (c) 2006-2011 Varnish Software AS\n * All rights reserved.\n *\n * Author: Poul-Henning Kamp <phk@phk.freebsd.dk>\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in the\n * documentation and\/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\n * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\n * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\n * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n * The default VCL code.\n *\n * NB! You do NOT need to copy & paste all of these functions into your\n * own vcl code, if you do not provide a definition of one of these\n * functions, the compiler will automatically fall back to the default\n * code from this file.\n *\n * This code will be prefixed with a backend declaration built from the\n * -b argument.\n *\/\n\n import std;\n import abtest;\n\n C{\n #include <syslog.h>\n }C\n\n\n backend default {\n .host = \"127.0.0.1\";\n .port = \"3000\";\n }\n\n\/* Only permit localhost to manipulate abtest configuration *\/\nacl abconfig {\n \"localhost\";\n}\n\nsub vcl_init {\n if (abtest.load_config(\"\/tmp\/abtest.cfg\") != 0) {\n C{ syslog(LOG_ALERT, \"Unable to load AB config from \/tmp\/abtest.cfg\"); }C\n }\n return (ok);\n}\n\nsub vcl_fini {\n}\n\nsub vcl_recv {\n if (req.http.AB-Cfg) {\n if (!client.ip ~ abconfig) {\n std.log(\"AB Config request not allowed from \" + client.ip);\n error 405 \"Not allowed.\";\n } else {\n \/\/ curl localhost:8080 -X PUT -H \"AB-Cfg:base\" -H \"AB-Cfg-Val:a:25;b:75;\"\n if (req.request == \"PUT\") {\n std.log(\"AB Config PUT request: \" + req.http.AB-Cfg + \"|\" + req.http.AB-Cfg-Val);\n abtest.set_rule(req.http.AB-Cfg, req.http.AB-Cfg-Val);\n abtest.save_config(\"\/tmp\/abtest.cfg\");\n }\n\n if (req.request == \"DELETE\") {\n std.log(\"AB Config DELETE request: \" + req.http.AB-Cfg);\n }\n\n if (req.request == \"GET\") {\n std.log(\"AB Config GET request: \" + req.http.AB-Cfg);\n }\n }\n }\n\n\/*\n if(req.http.Cookie ~ \"abtesting\") {\n }\n*\/\n}\n\nsub vcl_pipe {\n}\n\nsub vcl_pass {\n}\n\nsub vcl_hash {\n}\n\nsub vcl_hit {\n}\n\nsub vcl_miss {\n}\n\nsub vcl_fetch {\n}\n\nsub vcl_deliver {\n}\n\nsub vcl_error {\n}\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'vcl\/default.vcl' did not match any file(s) known to git\n","license":"bsd-2-clause","lang":"VCL"} {"commit":"fd2b63edb6be5da78be4252901c84cd92087844e","subject":"Add varnish configuration","message":"Add varnish configuration\n","repos":"nextchan\/infinity-next,nextchan\/infinity-next,nextchan\/infinity-next,nextchan\/infinity-next","old_file":"varnish.vcl","new_file":"varnish.vcl","new_contents":"","old_contents":"","returncode":128,"stderr":"remote: Support for password authentication was removed on August 13, 2021.\nremote: Please see https:\/\/docs.github.com\/en\/get-started\/getting-started-with-git\/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.\nfatal: Authentication failed for 'https:\/\/github.com\/nextchan\/infinity-next.git\/'\n","license":"agpl-3.0","lang":"VCL"} {"commit":"9b7e9b6a72d8a9b13bf89fa7dc741c6fb03a7c4e","subject":"add the vcl","message":"add the vcl\n","repos":"teohhanhui\/docker-varnish,tripviss\/docker-varnish","old_file":"varnish.vcl","new_file":"varnish.vcl","new_contents":"\/*-\n * Copyright (c) 2006 Verdens Gang AS\n * Copyright (c) 2006-2014 Varnish Software AS\n * All rights reserved.\n *\n * Author: Poul-Henning Kamp <phk@phk.freebsd.dk>\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n * 1. Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in the\n * documentation and\/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH DAMAGE.\n *\n\n *\n * The built-in (previously called default) VCL code.\n *\n * NB! You do NOT need to copy & paste all of these functions into your\n * own vcl code, if you do not provide a definition of one of these\n * functions, the compiler will automatically fall back to the default\n * code from this file.\n *\n * This code will be prefixed with a backend declaration built from the\n * -b argument.\n *\/\n\nvcl 4.0;\n\n#######################################################################\n# Client side\n\nsub vcl_recv {\n if (req.method == \"PRI\") {\n\t\/* We do not support SPDY or HTTP\/2.0 *\/\n\treturn (synth(405));\n }\n if (req.method != \"GET\" &&\n req.method != \"HEAD\" &&\n req.method != \"PUT\" &&\n req.method != \"POST\" &&\n req.method != \"TRACE\" &&\n req.method != \"OPTIONS\" &&\n req.method != \"DELETE\") {\n \/* Non-RFC2616 or CONNECT which is weird. *\/\n return (pipe);\n }\n\n if (req.method != \"GET\" && req.method != \"HEAD\") {\n \/* We only deal with GET and HEAD by default *\/\n return (pass);\n }\n if (req.http.Authorization || req.http.Cookie) {\n \/* Not cacheable by default *\/\n return (pass);\n }\n return (hash);\n}\n\nsub vcl_pipe {\n # By default Connection: close is set on all piped requests, to stop\n # connection reuse from sending future requests directly to the\n # (potentially) wrong backend. If you do want this to happen, you can undo\n # it here.\n # unset bereq.http.connection;\n return (pipe);\n}\n\nsub vcl_pass {\n return (fetch);\n}\n\nsub vcl_hash {\n hash_data(req.url);\n if (req.http.host) {\n hash_data(req.http.host);\n } else {\n hash_data(server.ip);\n }\n return (lookup);\n}\n\nsub vcl_purge {\n return (synth(200, \"Purged\"));\n}\n\nsub vcl_hit {\n if (obj.ttl >= 0s) {\n \/\/ A pure unadultered hit, deliver it\n return (deliver);\n }\n if (obj.ttl + obj.grace > 0s) {\n \/\/ Object is in grace, deliver it\n \/\/ Automatically triggers a background fetch\n return (deliver);\n }\n \/\/ fetch & deliver once we get the result\n return (fetch);\n}\n\nsub vcl_miss {\n return (fetch);\n}\n\nsub vcl_deliver {\n return (deliver);\n}\n\n\/*\n * We can come here \"invisibly\" with the following errors: 413, 417 & 503\n *\/\nsub vcl_synth {\n set resp.http.Content-Type = \"text\/html; charset=utf-8\";\n set resp.http.Retry-After = \"5\";\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + resp.status + \" \" + resp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + resp.status + \" \" + resp.reason + {\"<\/h1>\n <p>\"} + resp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + req.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n return (deliver);\n}\n\n#######################################################################\n# Backend Fetch\n\nsub vcl_backend_fetch {\n return (fetch);\n}\n\nsub vcl_backend_response {\n if (beresp.ttl <= 0s ||\n beresp.http.Set-Cookie ||\n beresp.http.Surrogate-control ~ \"no-store\" ||\n (!beresp.http.Surrogate-Control &&\n beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n beresp.http.Vary == \"*\") {\n \/*\n * Mark as \"Hit-For-Pass\" for the next 2 minutes\n *\/\n set beresp.ttl = 120s;\n set beresp.uncacheable = true;\n }\n return (deliver);\n}\n\nsub vcl_backend_error {\n set beresp.http.Content-Type = \"text\/html; charset=utf-8\";\n set beresp.http.Retry-After = \"5\";\n synthetic( {\"<!DOCTYPE html>\n<html>\n <head>\n <title>\"} + beresp.status + \" \" + beresp.reason + {\"<\/title>\n <\/head>\n <body>\n <h1>Error \"} + beresp.status + \" \" + beresp.reason + {\"<\/h1>\n <p>\"} + beresp.reason + {\"<\/p>\n <h3>Guru Meditation:<\/h3>\n <p>XID: \"} + bereq.xid + {\"<\/p>\n <hr>\n <p>Varnish cache server<\/p>\n <\/body>\n<\/html>\n\"} );\n return (deliver);\n}\n\n#######################################################################\n# Housekeeping\n\nsub vcl_init {\n return (ok);\n}\n\nsub vcl_fini {\n return (ok);\n}\n\nbackend ap1 {\n .host = \"127.0.0.1\";\n .port = \"8080\";\n .first_byte_timeout = 200s;\n .probe = {\n .url = \"\/\";\n .interval = 5s;\n .timeout = 1 s;\n .window = 5;\n .threshold = 3;\n .initial = 1;\n }\n}\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'varnish.vcl' did not match any file(s) known to git\n","license":"apache-2.0","lang":"VCL"} {"commit":"660214d34647bf32eef21f0a10baddb62eb1dc0c","subject":"Strip trailing spaces only","message":"Strip trailing spaces only\n","repos":"petterreinholdtsen\/alaveteli,4bic\/alaveteli,andreicristianpetcu\/alaveteli_old,petterreinholdtsen\/alaveteli,4bic\/alaveteli,Br3nda\/alaveteli,petterreinholdtsen\/alaveteli,andreicristianpetcu\/alaveteli,nzherald\/alaveteli,nzherald\/alaveteli,Br3nda\/alaveteli,4bic\/alaveteli,andreicristianpetcu\/alaveteli_old,nzherald\/alaveteli,4bic\/alaveteli,Br3nda\/alaveteli,Br3nda\/alaveteli,andreicristianpetcu\/alaveteli,petterreinholdtsen\/alaveteli,andreicristianpetcu\/alaveteli_old,andreicristianpetcu\/alaveteli,andreicristianpetcu\/alaveteli_old,petterreinholdtsen\/alaveteli,andreicristianpetcu\/alaveteli_old,nzherald\/alaveteli,andreicristianpetcu\/alaveteli,andreicristianpetcu\/alaveteli,Br3nda\/alaveteli,nzherald\/alaveteli,4bic\/alaveteli","old_file":"config\/varnish-alaveteli.vcl","new_file":"config\/varnish-alaveteli.vcl","new_contents":"","old_contents":"","returncode":128,"stderr":"remote: Support for password authentication was removed on August 13, 2021.\nremote: Please see https:\/\/docs.github.com\/en\/get-started\/getting-started-with-git\/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.\nfatal: Authentication failed for 'https:\/\/github.com\/4bic\/alaveteli.git\/'\n","license":"agpl-3.0","lang":"VCL"} {"commit":"a331f9504c4e1998f470c13c5ee628d62d2f4fa0","subject":"Using emergency regex to template","message":"Using emergency regex to template\n","repos":"kkwoker\/ansible-varnish","old_file":"templates\/etc\/varnish\/emergency.vcl","new_file":"templates\/etc\/varnish\/emergency.vcl","new_contents":"","old_contents":"","returncode":128,"stderr":"remote: Support for password authentication was removed on August 13, 2021.\nremote: Please see https:\/\/docs.github.com\/en\/get-started\/getting-started-with-git\/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.\nfatal: Authentication failed for 'https:\/\/github.com\/kkwoker\/ansible-varnish.git\/'\n","license":"mit","lang":"VCL"} {"commit":"1031df8bdae94306140979ea428c79bb0a493f56","subject":"Regression testcase for #433","message":"Regression testcase for #433\n\n\n\ngit-svn-id: 2c9807fa3ff65b17195bd55dc8a6c4261e10127b@3576 d4fa192b-c00b-0410-8231-f00ffab90ce4\n","repos":"drwilco\/varnish-cache-drwilco,drwilco\/varnish-cache-old,franciscovg\/Varnish-Cache,chrismoulton\/Varnish-Cache,varnish\/Varnish-Cache,mrhmouse\/Varnish-Cache,ssm\/pkg-varnish,franciscovg\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,gquintard\/Varnish-Cache,wikimedia\/operations-debs-varnish,gauthier-delacroix\/Varnish-Cache,feld\/Varnish-Cache,wikimedia\/operations-debs-varnish,feld\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,1HLtd\/Varnish-Cache,zhoualbeart\/Varnish-Cache,wikimedia\/operations-debs-varnish,alarky\/varnish-cache-doc-ja,zhoualbeart\/Varnish-Cache,gquintard\/Varnish-Cache,mrhmouse\/Varnish-Cache,1HLtd\/Varnish-Cache,franciscovg\/Varnish-Cache,varnish\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,chrismoulton\/Varnish-Cache,ssm\/pkg-varnish,wikimedia\/operations-debs-varnish,1HLtd\/Varnish-Cache,feld\/Varnish-Cache,feld\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,mrhmouse\/Varnish-Cache,ssm\/pkg-varnish,ssm\/pkg-varnish,ambernetas\/varnish-cache,ajasty-cavium\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,drwilco\/varnish-cache-old,ambernetas\/varnish-cache,varnish\/Varnish-Cache,drwilco\/varnish-cache-drwilco,varnish\/Varnish-Cache,chrismoulton\/Varnish-Cache,drwilco\/varnish-cache-drwilco,zhoualbeart\/Varnish-Cache,alarky\/varnish-cache-doc-ja,varnish\/Varnish-Cache,franciscovg\/Varnish-Cache,alarky\/varnish-cache-doc-ja,zhoualbeart\/Varnish-Cache,mrhmouse\/Varnish-Cache,franciscovg\/Varnish-Cache,ambernetas\/varnish-cache,ssm\/pkg-varnish,mrhmouse\/Varnish-Cache,gquintard\/Varnish-Cache,drwilco\/varnish-cache-old,feld\/Varnish-Cache,alarky\/varnish-cache-doc-ja,gquintard\/Varnish-Cache,alarky\/varnish-cache-doc-ja,zhoualbeart\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,chrismoulton\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,chrismoulton\/Varnish-Cache,wikimedia\/operations-debs-varnish,1HLtd\/Varnish-Cache","old_file":"bin\/varnishtest\/tests\/r00433.vcl","new_file":"bin\/varnishtest\/tests\/r00433.vcl","new_contents":"","old_contents":"","returncode":128,"stderr":"remote: Support for password authentication was removed on August 13, 2021.\nremote: Please see https:\/\/docs.github.com\/en\/get-started\/getting-started-with-git\/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.\nfatal: Authentication failed for 'https:\/\/github.com\/alarky\/varnish-cache-doc-ja.git\/'\n","license":"bsd-2-clause","lang":"VCL"} {"commit":"5299bcaf9b9651ba749345ad32d65a2a4cd576de","subject":"tuning cache for static files","message":"tuning cache for static files\n","repos":"cristianocasella\/cristianocasella.com,cristianocasella\/cristianocasella.com","old_file":"varnish\/varnish.vcl","new_file":"varnish\/varnish.vcl","new_contents":"","old_contents":"","returncode":128,"stderr":"remote: Support for password authentication was removed on August 13, 2021.\nremote: Please see https:\/\/docs.github.com\/en\/get-started\/getting-started-with-git\/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.\nfatal: Authentication failed for 'https:\/\/github.com\/cristianocasella\/cristianocasella.com.git\/'\n","license":"mit","lang":"VCL"} {"commit":"70498b3d0249c376408191efdbb93df8974ab15a","subject":"added example default.vcl","message":"added example default.vcl\n","repos":"pariahsoft\/libvmod-authentication,pariahsoft\/libvmod-authentication","old_file":"examples\/default.vcl","new_file":"examples\/default.vcl","new_contents":"# This is a basic VCL configuration file for varnish. See the vcl(7)\n# man page for details on VCL syntax and semantics.\n# \n# Default backend definition. Set this to point to your content\n# server.\n# \nbackend default {\n .host = \"127.0.0.1\";\n .port = \"80\";\n}\n\nimport authentication;\n\nsub vcl_recv {\n\tif(!authentication.match(\"admin\", \"test\")) {\n\t\terror 401 \"Authentication Required\";\n\t}\n\t\n\treturn (lookup);\n}\n\nsub vcl_error {\n\tif(obj.status == 401) {\n\t\tset obj.http.WWW-Authenticate = \"Basic realm=Secure Area\";\n\t}\n}\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'examples\/default.vcl' did not match any file(s) known to git\n","license":"bsd-2-clause","lang":"VCL"} {"commit":"72b02deb17e8af33524a6903b5ee52e9125f375e","subject":"Don't send Accept-Encoding to the origin even on passes since responses may have embedded ESIs","message":"Don't send Accept-Encoding to the origin even on passes since responses may have embedded ESIs\n","repos":"fastly\/fastly-magento,fastly\/fastly-magento,fastly\/fastly-magento,fastly\/fastly-magento","old_file":"app\/code\/community\/Fastly\/CDN\/etc\/vcl_snippets\/pass.vcl","new_file":"app\/code\/community\/Fastly\/CDN\/etc\/vcl_snippets\/pass.vcl","new_contents":"","old_contents":"","returncode":128,"stderr":"fatal: unable to access 'https:\/\/github.com\/fastly\/fastly-magento.git\/': The requested URL returned error: 403\n","license":"bsd-3-clause","lang":"VCL"} {"commit":"8d30e43619d8b4dd5e963f6ec384eb8cbfe0c7ad","subject":"corrected restart limit","message":"corrected restart limit\n","repos":"NITEMAN\/Varnish_VCL_samps-hacks,NITEMAN\/varnish-bites","old_file":"varnish 3 vcls\/drupal_base.vcl","new_file":"varnish 3 vcls\/drupal_base.vcl","new_contents":"","old_contents":"","returncode":1,"stderr":"error: pathspec 'varnish' did not match any file(s) known to git\nerror: pathspec '3' did not match any file(s) known to git\nerror: pathspec 'vcls\/drupal_base.vcl' did not match any file(s) known to git\n","license":"unknown","lang":"VCL"} {"commit":"75d3eb91dfe351fb33c09dc50e0815473a8e1d21","subject":"fixed typo","message":"fixed typo\n","repos":"NITEMAN\/Varnish_VCL_samps-hacks,NITEMAN\/varnish-bites","old_file":"varnish 3 vcls\/drupal_base.vcl","new_file":"varnish 3 vcls\/drupal_base.vcl","new_contents":"","old_contents":"","returncode":1,"stderr":"error: pathspec 'varnish' did not match any file(s) known to git\nerror: pathspec '3' did not match any file(s) known to git\nerror: pathspec 'vcls\/drupal_base.vcl' did not match any file(s) known to git\n","license":"unknown","lang":"VCL"} {"commit":"5765f28ec0cd4ae37436bb8f566c54c734fb5597","subject":"put the development server backend and override cookie stuff into a different files","message":"put the development server backend and override cookie stuff into a different files\n","repos":"wikp\/varnish-devicedetect,varnish\/varnish-devicedetect,varnish\/varnish-devicedetect,kevinquinnyo\/varnish-devicedetect,wikp\/varnish-devicedetect,kevinquinnyo\/varnish-devicedetect","old_file":"devicedetect-dev.vcl","new_file":"devicedetect-dev.vcl","new_contents":"#\n# devicedetect-dev.vcl\n#\n# Enable test URLs and cookie overrides\n\nbackend devicetest { \n .host = \"127.0.0.1\";\n .port = \"8000\";\n}\n\nsub vcl_recv {\n if (req.url ~ \"^\/set_devicetype\/\") { error 701 regsub(req.url, \"^\/set_devicetype\/\", \"\"); }\n if (req.url ~ \"^\/devicetest\") { set backend = devicetest; }\n}\n\nsub vcl_error { \n if (obj.status == 701 ) {\n # obj.response == mobile-generic\n set obj.http.Set-Cookie = \"X-UA-device=\" + obj.response;\n set obj.http.Content-Type = \"text\/plain; charset=utf-8\";\n synthetic {\" 200 OK, Cookie set \"};\n\treturn(deliver)\n }\n}\n\"\"\"\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'devicedetect-dev.vcl' did not match any file(s) known to git\n","license":"bsd-2-clause","lang":"VCL"} {"commit":"d5259acea34691aaaf32c1083c4406a6562eebd3","subject":"Update varnish configuration","message":"Update varnish configuration\n","repos":"ade25\/z3,ade25\/z3","old_file":"buildout.d\/templates\/varnish.vcl","new_file":"buildout.d\/templates\/varnish.vcl","new_contents":"","old_contents":"","returncode":128,"stderr":"remote: Support for password authentication was removed on August 13, 2021.\nremote: Please see https:\/\/docs.github.com\/en\/get-started\/getting-started-with-git\/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.\nfatal: Authentication failed for 'https:\/\/github.com\/ade25\/z3.git\/'\n","license":"mit","lang":"VCL"} {"commit":"cdf60707b358837677e672da1eafcd7525864e9e","subject":"Add New Method","message":"Add New Method\n\nAdd New Method\n","repos":"kevin25\/fastly","old_file":"trace_cookies.vcl","new_file":"trace_cookies.vcl","new_contents":"sub vcl_recv {\n if (req.http.Cookie ~ \"WebSiteLang=\") {\n # The request does have a tracking cookie so store it temporarily\n set req.http.Lang-Set-Cookie = req.http.Cookie;\n unset req.http.Cookie;\n } if (req.url ~ \"pt\") {\n set req.http.Lang-Set-Cookie = \"WebSiteLang=pt; expires=\" now + 180d \"; Max-Age=31536000;\";\n }\n\n#FASTLY recv\n}\n\nsub vcl_fetch {\n # The response has a Set-Cookie ...\n if (beresp.http.Set-Cookie) {\n # ... so store it temporarily\n set req.http.Lang-Set-Cookie = beresp.http.Set-Cookie;\n # ... and then unset it\n unset beresp.http.Set-Cookie;\n }\n\n#FASTLY fetch\n}\n\nsub vcl_deliver {\n # Send the Cookie header again if we have it\n if (req.http.Lang-Set-Cookie) {\n set resp.http.Set-Cookie = req.http.Lang-Set-Cookie;\n }\n #if (req.url ~ \"pt\" || resp.http.Set-Cookie ~ \"WebSiteLang=pt\") {\n # add resp.http.Set-Cookie = \"WebSiteLang=pt; expires=\" now + 180d \"; Max-Age=31536000;\";\n #}\n #if (req.url ~ \"es\" || resp.http.Set-Cookie ~ \"WebSiteLang=es\") {\n # add resp.http.Set-Cookie = \"WebSiteLang=es; expires=\" now + 180d \"; Max-Age=31536000;\";\n #}\n#FASTLY deliver\n}","old_contents":"","returncode":1,"stderr":"error: pathspec 'trace_cookies.vcl' did not match any file(s) known to git\n","license":"mit","lang":"VCL"} {"commit":"67fd02737600480aba64a14fc257c04f022f5daa","subject":"Create default.vcl","message":"Create default.vcl","repos":"mediafigaro\/docker-symfony","old_file":"varnish\/default.vcl","new_file":"varnish\/default.vcl","new_contents":"vcl 4.0;\n\nbackend default {\n .host = \"localhost\";\n .port = \"80\";\n}\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'varnish\/default.vcl' did not match any file(s) known to git\n","license":"mit","lang":"VCL"} {"commit":"a930c7213c16f02f0e37bf8dae1a0f2b319a3c58","subject":"fixing ip address for backend","message":"fixing ip address for backend\n","repos":"cristianocasella\/cristianocasella.com,cristianocasella\/cristianocasella.com","old_file":"varnish\/varnish.vcl","new_file":"varnish\/varnish.vcl","new_contents":"","old_contents":"","returncode":128,"stderr":"remote: Support for password authentication was removed on August 13, 2021.\nremote: Please see https:\/\/docs.github.com\/en\/get-started\/getting-started-with-git\/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.\nfatal: Authentication failed for 'https:\/\/github.com\/cristianocasella\/cristianocasella.com.git\/'\n","license":"mit","lang":"VCL"} {"commit":"135452662bb294cd86af30eac082e9addf055552","subject":"Modifying the backend response ttl time to 5 minutes by default.","message":"Modifying the backend response ttl time to 5 minutes by default.\n","repos":"mmswebinternet\/php-dockerized,mmswebinternet\/php-dockerized,mmswebinternet\/php-dockerized,mmswebinternet\/php-dockerized","old_file":"conf\/varnish\/etc\/default.vcl","new_file":"conf\/varnish\/etc\/default.vcl","new_contents":"","old_contents":"","returncode":128,"stderr":"remote: Support for password authentication was removed on August 13, 2021.\nremote: Please see https:\/\/docs.github.com\/en\/get-started\/getting-started-with-git\/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.\nfatal: Authentication failed for 'https:\/\/github.com\/mmswebinternet\/php-dockerized.git\/'\n","license":"mit","lang":"VCL"} {"commit":"9601a100319d5951bf32fb950eeed612ae6e8f1a","subject":"fiexed encoding conditional","message":"fiexed encoding conditional\n","repos":"NITEMAN\/varnish-bites,NITEMAN\/Varnish_VCL_samps-hacks","old_file":"varnish 3 vcls\/drupal_base.vcl","new_file":"varnish 3 vcls\/drupal_base.vcl","new_contents":"","old_contents":"","returncode":1,"stderr":"error: pathspec 'varnish' did not match any file(s) known to git\nerror: pathspec '3' did not match any file(s) known to git\nerror: pathspec 'vcls\/drupal_base.vcl' did not match any file(s) known to git\n","license":"unknown","lang":"VCL"} {"commit":"64c689265a79383e09358df2b345f5124862c4bd","subject":"Reindent","message":"Reindent\n\n\ngit-svn-id: 7d4b18ab7d176792635d6a7a77dd8cbbea8e8daa@3009 d4fa192b-c00b-0410-8231-f00ffab90ce4\n","repos":"CartoDB\/Varnish-Cache,CartoDB\/Varnish-Cache,ssm\/pkg-varnish,ssm\/pkg-varnish,ssm\/pkg-varnish,wikimedia\/operations-debs-varnish,wikimedia\/operations-debs-varnish,CartoDB\/Varnish-Cache,wikimedia\/operations-debs-varnish,wikimedia\/operations-debs-varnish,ssm\/pkg-varnish,wikimedia\/operations-debs-varnish,ssm\/pkg-varnish","old_file":"etc\/default.vcl","new_file":"etc\/default.vcl","new_contents":"","old_contents":"","returncode":128,"stderr":"remote: Support for password authentication was removed on August 13, 2021.\nremote: Please see https:\/\/docs.github.com\/en\/get-started\/getting-started-with-git\/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.\nfatal: Authentication failed for 'https:\/\/github.com\/wikimedia\/operations-debs-varnish.git\/'\n","license":"bsd-2-clause","lang":"VCL"} {"commit":"5a26092a2262e3a502ce522acea890ea071ede4e","subject":"Some more comments added as suggested by pcambra","message":"Some more comments added as suggested by pcambra\n","repos":"NITEMAN\/Varnish_VCL_samps-hacks,NITEMAN\/varnish-bites","old_file":"varnish 3 vcls\/drupal_base.vcl","new_file":"varnish 3 vcls\/drupal_base.vcl","new_contents":"","old_contents":"","returncode":1,"stderr":"error: pathspec 'varnish' did not match any file(s) known to git\nerror: pathspec '3' did not match any file(s) known to git\nerror: pathspec 'vcls\/drupal_base.vcl' did not match any file(s) known to git\n","license":"unknown","lang":"VCL"} {"commit":"126abec8cc5cf203fb5bf23bbb38c6c3ea9547f1","subject":"Add test vcl 6.4","message":"Add test vcl 6.4\n","repos":"emgag\/docker-varnish","old_file":"test\/6.4.vcl","new_file":"test\/6.4.vcl","new_contents":"","old_contents":"","returncode":1,"stderr":"error: pathspec 'test\/6.4.vcl' did not match any file(s) known to git\n","license":"mit","lang":"VCL"} {"commit":"9fe7e13483a79375ed7fae66d04652c80a705f0d","subject":"Add the recv snippet","message":"Add the recv snippet\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets_basic_auth\/recv.vcl","new_file":"etc\/vcl_snippets_basic_auth\/recv.vcl","new_contents":" if ( table.lookup(magentomodule_basic_auth, req.http.Authorization, \"NOTFOUND\") == \"NOTFOUND\" ) {\n error 971;\n }\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'etc\/vcl_snippets_basic_auth\/recv.vcl' did not match any file(s) known to git\n","license":"bsd-3-clause","lang":"VCL"} {"commit":"f0c04be9873c4f08287d80011f5f2f2129e6e5c3","subject":"added restart count","message":"added restart count\n","repos":"NITEMAN\/varnish-bites,NITEMAN\/Varnish_VCL_samps-hacks","old_file":"varnish 3 vcls\/drupal_base.vcl","new_file":"varnish 3 vcls\/drupal_base.vcl","new_contents":"","old_contents":"","returncode":1,"stderr":"error: pathspec 'varnish' did not match any file(s) known to git\nerror: pathspec '3' did not match any file(s) known to git\nerror: pathspec 'vcls\/drupal_base.vcl' did not match any file(s) known to git\n","license":"unknown","lang":"VCL"} {"commit":"69df11ae47e8d96aa2457f2215c6a45e71415125","subject":"adding varnish conf for kube","message":"adding varnish conf for kube\n","repos":"cristianocasella\/cristianocasella.com,cristianocasella\/cristianocasella.com","old_file":"varnish\/varnish-kube.vcl","new_file":"varnish\/varnish-kube.vcl","new_contents":"","old_contents":"","returncode":128,"stderr":"remote: Support for password authentication was removed on August 13, 2021.\nremote: Please see https:\/\/docs.github.com\/en\/get-started\/getting-started-with-git\/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.\nfatal: Authentication failed for 'https:\/\/github.com\/cristianocasella\/cristianocasella.com.git\/'\n","license":"mit","lang":"VCL"} {"commit":"e35cf244c195bf87037027b42a7fb7c63442103c","subject":"Missing 403 on wrong token","message":"Missing 403 on wrong token\n","repos":"fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2,fastly\/fastly-magento2","old_file":"etc\/vcl_snippets\/recv.vcl","new_file":"etc\/vcl_snippets\/recv.vcl","new_contents":" # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n unset req.http.x-long-cache;\n\n # Rewrite \/static\/versionxxxxx URLs. Avoids us having to rewrite on nginx layer\n if (req.url ~ \"^\/static\/version(\\d*\/)?(.*)$\") {\n set req.url = \"\/static\/\" + re.group.2 + \"?\" + re.group.1;\n set req.http.x-long-cache = \"1\";\n }\n \n # User's Cookie may contain some Magento Vary items we should vary on\n if (req.http.cookie:X-Magento-Vary ) {\n set req.http.X-Magento-Vary = req.http.cookie:X-Magento-Vary;\n } else {\n unset req.http.X-Magento-Vary;\n }\n\n ############################################################################################################\n # Following code block controls purge by URL. By default we want to protect all URL purges. In general this\n # is addressed by adding Fastly-Purge-Requires-Auth request header in vcl_recv however this runs the risk of\n # exposing API tokens if user attempts to purge non-https URLs. For this reason inside the Magento module\n # we use X-Purge-Token. Unfortunately this breaks purge from the Fastly UI. Therefore in the next code block\n # we check for presence of X-Purge-Token. If it's not present we force the Fastly-Purge-Requires-Auth\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n if (req.http.X-Purge-Token && req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n } else {\n error 403;\n }\n } else {\n set req.http.Fastly-Purge-Requires-Auth = \"1\";\n }\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (req.http.Fastly-FF) {\n # disable ESI processing on Origin Shield\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie:X-Magento-Vary || req.http.cookie:form_key) {\n error 980 \"GeoIP already processed\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url.qs !~ \"country_code=\" ) {\n set req.url = req.url \"?country_code=\" if ( req.http.geo_override, req.http.geo_override, client.geo.country_code);\n }\n }\n } else {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking by default\n # and allow custom parameters to be set. List of parameters is configurable in admin\n set req.http.Magento-Original-URL = req.url;\n # Change the list of ignored parameters by configuring them in the Advanced section\n set req.url = querystring.regfilter(req.url, \"^(####QUERY_PARAMETERS####)\");\n }\n\n # Don't allow clients to force a pass\n if (req.restarts == 0) {\n unset req.http.x-pass;\n }\n \n # Pass on checkout URLs. Because it's a snippet we want to execute this after backend selection so we handle it\n # in the request condition\n if (!req.http.x-long-cache && req.url ~ \"\/(catalogsearch|checkout|customer\/section\/load)\") {\n set req.http.x-pass = \"1\";\n # Pass all admin actions\n # ####ADMIN_PATH#### is replaced with value of frontName from app\/etc\/env.php\n } else if ( req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" ) {\n set req.http.x-pass = \"1\";\n } else {\n # Sort the query arguments to increase cache hit ratio with query arguments that\n # may be out od order. In case you want to restore the unsorted URL add a snippet\n # after this one that sets req.url to req.http.Magento-Original-URL\n set req.url = boltsort.sort(req.url);\n }\n\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.http.x-long-cache || req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n","old_contents":" # Fixup for Varnish ESI not dealing with https:\/\/ absolute URLs well\n if (req.is_esi_subreq && req.url ~ \"\/https:\/\/([^\/]+)(\/.*)$\") {\n set req.http.Host = re.group.1;\n set req.url = re.group.2;\n }\n\n unset req.http.x-long-cache;\n\n # Rewrite \/static\/versionxxxxx URLs. Avoids us having to rewrite on nginx layer\n if (req.url ~ \"^\/static\/version(\\d*\/)?(.*)$\") {\n set req.url = \"\/static\/\" + re.group.2 + \"?\" + re.group.1;\n set req.http.x-long-cache = \"1\";\n }\n \n # User's Cookie may contain some Magento Vary items we should vary on\n if (req.http.cookie:X-Magento-Vary ) {\n set req.http.X-Magento-Vary = req.http.cookie:X-Magento-Vary;\n } else {\n unset req.http.X-Magento-Vary;\n }\n\n ############################################################################################################\n # Following code block controls purge by URL. By default we want to protect all URL purges. In general this\n # is addressed by adding Fastly-Purge-Requires-Auth request header in vcl_recv however this runs the risk of\n # exposing API tokens if user attempts to purge non-https URLs. For this reason inside the Magento module\n # we use X-Purge-Token. Unfortunately this breaks purge from the Fastly UI. Therefore in the next code block\n # we check for presence of X-Purge-Token. If it's not present we force the Fastly-Purge-Requires-Auth\n if (req.request == \"FASTLYPURGE\") {\n # extract token signature and expiration\n if (req.http.X-Purge-Token && req.http.X-Purge-Token ~ \"^([^_]+)_(.*)\" ) {\n\n declare local var.X-Exp STRING;\n declare local var.X-Sig STRING;\n \/* extract token expiration and signature *\/\n set var.X-Exp = re.group.1;\n set var.X-Sig = re.group.2;\n\n \/* validate signature *\/\n if (var.X-Sig == regsub(digest.hmac_sha1(req.service_id, req.url.path var.X-Exp), \"^0x\", \"\")) {\n \/* check that expiration time has not elapsed *\/\n if (time.is_after(now, std.integer2time(std.atoi(var.X-Exp)))) {\n error 410;\n }\n }\n\n } else {\n set req.http.Fastly-Purge-Requires-Auth = \"1\";\n }\n }\n\n # set HTTPS header for offloaded TLS\n if (req.http.Fastly-SSL) {\n set req.http.Https = \"on\";\n }\n\n if (req.http.Fastly-FF) {\n # disable ESI processing on Origin Shield\n set req.esi = false;\n # Needed for proper handling of stale while revalidated when shielding is involved\n set req.max_stale_while_revalidate = 0s;\n }\n\n # geoip lookup\n if (req.url ~ \"fastlyCdn\/geoip\/getaction\/\") {\n # check if GeoIP has been already processed by client. this normally happens before essential cookies are set.\n if (req.http.cookie:X-Magento-Vary || req.http.cookie:form_key) {\n error 980 \"GeoIP already processed\";\n } else {\n # append parameter with country code only if it doesn't exist already\n if ( req.url.qs !~ \"country_code=\" ) {\n set req.url = req.url \"?country_code=\" if ( req.http.geo_override, req.http.geo_override, client.geo.country_code);\n }\n }\n } else {\n # Per suggestions in https:\/\/github.com\/sdinteractive\/SomethingDigital_PageCacheParams\n # we'll strip out query parameters used in Google AdWords, Mailchimp tracking by default\n # and allow custom parameters to be set. List of parameters is configurable in admin\n set req.http.Magento-Original-URL = req.url;\n # Change the list of ignored parameters by configuring them in the Advanced section\n set req.url = querystring.regfilter(req.url, \"^(####QUERY_PARAMETERS####)\");\n }\n\n # Don't allow clients to force a pass\n if (req.restarts == 0) {\n unset req.http.x-pass;\n }\n \n # Pass on checkout URLs. Because it's a snippet we want to execute this after backend selection so we handle it\n # in the request condition\n if (!req.http.x-long-cache && req.url ~ \"\/(catalogsearch|checkout|customer\/section\/load)\") {\n set req.http.x-pass = \"1\";\n # Pass all admin actions\n # ####ADMIN_PATH#### is replaced with value of frontName from app\/etc\/env.php\n } else if ( req.url ~ \"^\/(index\\.php\/)?####ADMIN_PATH####\/\" ) {\n set req.http.x-pass = \"1\";\n } else {\n # Sort the query arguments to increase cache hit ratio with query arguments that\n # may be out od order. In case you want to restore the unsorted URL add a snippet\n # after this one that sets req.url to req.http.Magento-Original-URL\n set req.url = boltsort.sort(req.url);\n }\n\n\n # static files are always cacheable. remove SSL flag and cookie\n if (req.http.x-long-cache || req.url ~ \"^\/(pub\/)?(media|static)\/.*\") {\n unset req.http.Https;\n unset req.http.Cookie;\n }\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"VCL"} {"commit":"cf00515683b7c36f332b69e8e54d2bcf127eef2f","subject":"Add example Varnish config","message":"Add example Varnish config\n","repos":"AstunTechnology\/NRW_FishMapMon,AstunTechnology\/NRW_FishMapMon,AstunTechnology\/NRW_FishMapMon,AstunTechnology\/NRW_FishMapMon","old_file":"config\/varnish\/default.vcl","new_file":"config\/varnish\/default.vcl","new_contents":"# This is a basic VCL configuration file for varnish. See the vcl(7)\n# man page for details on VCL syntax and semantics.\n# \n# Default backend definition. Set this to point to your content\n# server.\n# \nbackend cy {\n .host = \"cy.blah\";\n .port = \"8001\";\n}\n\nbackend en {\n .host = \"en.blah\";\n .port = \"8002\";\n}\n\n\n# \n# Below is a commented-out copy of the default VCL logic. If you\n# redefine any of these subroutines, the built-in logic will be\n# appended to your code.\nsub vcl_recv {\n# if (req.restarts == 0) {\n# \tif (req.http.x-forwarded-for) {\n# \t set req.http.X-Forwarded-For =\n# \t\treq.http.X-Forwarded-For + \", \" + client.ip;\n# \t} else {\n# \t set req.http.X-Forwarded-For = client.ip;\n# \t}\n# }\n# if (req.request != \"GET\" &&\n# req.request != \"HEAD\" &&\n# req.request != \"PUT\" &&\n# req.request != \"POST\" &&\n# req.request != \"TRACE\" &&\n# req.request != \"OPTIONS\" &&\n# req.request != \"DELETE\") {\n# \/* Non-RFC2616 or CONNECT which is weird. *\/\n# return (pipe);\n# }\n# if (req.request != \"GET\" && req.request != \"HEAD\") {\n# \/* We only deal with GET and HEAD by default *\/\n# return (pass);\n# }\n# if (req.http.Authorization || req.http.Cookie) {\n# \/* Not cacheable by default *\/\n# return (pass);\n# }\n\tif (req.http.host ~ \"(?i)^(www.)?cy.blah\") {\n\t\tset req.http.host = \"cy.blah\";\n\t\tset req.backend = cy;\n\t}\n\telsif (req.http.host ~ \"(?i)^(www.)?en.blah\") {\n\t\tset req.http.host = \"en.blah\";\n\t\tset req.backend = en;\n\t}\n\n\tif ( req.url ~ \"^\/wms\\?map=fishmap\" ) {\n\t\treturn (pass);\n\t}\n\n\tif ( req.url ~ \"^\/static\/\" ) {\n\t\treturn (lookup);\n\t}\n\tif ( req.url ~ \"^\/wms\" ) {\n\t\treturn (lookup);\n\t}\n return (lookup);\n}\n# \n# sub vcl_pipe {\n# # Note that only the first request to the backend will have\n# # X-Forwarded-For set. If you use X-Forwarded-For and want to\n# # have it set for all requests, make sure to have:\n# # set bereq.http.connection = \"close\";\n# # here. It is not set by default as it might break some broken web\n# # applications, like IIS with NTLM authentication.\n# return (pipe);\n# }\n# \n# sub vcl_pass {\n# return (pass);\n# }\n# \n# sub vcl_hash {\n# hash_data(req.url);\n# if (req.http.host) {\n# hash_data(req.http.host);\n# } else {\n# hash_data(server.ip);\n# }\n# return (hash);\n# }\n# \n# sub vcl_hit {\n# return (deliver);\n# }\n# \n# sub vcl_miss {\n# return (fetch);\n# }\n# \nsub vcl_fetch {\n# if (beresp.ttl <= 0s ||\n# beresp.http.Set-Cookie ||\n# beresp.http.Vary == \"*\") {\n# \t\t\/*\n# \t\t * Mark as \"Hit-For-Pass\" for the next 2 minutes\n# \t\t *\/\n# \t\tset beresp.ttl = 120 s;\n# \t\treturn (hit_for_pass);\n# }\n\tif ( req.url ~ \"^\/wms\" ) {\n \t\tunset beresp.http.set-cookie;\n\t\tunset beresp.http.expires;\n \t\tset beresp.ttl = 1w;\n\t set beresp.http.Cache-Control = \"max-age=1900\";\n\t}\t\t\n return (deliver);\n}\n# \n# sub vcl_deliver {\n# return (deliver);\n# }\n# \n# sub vcl_error {\n# set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n# set obj.http.Retry-After = \"5\";\n# synthetic {\"\n# <?xml version=\"1.0\" encoding=\"utf-8\"?>\n# <!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\"\n# \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\">\n# <html>\n# <head>\n# <title>\"} + obj.status + \" \" + obj.response + {\"<\/title>\n# <\/head>\n# <body>\n# <h1>Error \"} + obj.status + \" \" + obj.response + {\"<\/h1>\n# <p>\"} + obj.response + {\"<\/p>\n# <h3>Guru Meditation:<\/h3>\n# <p>XID: \"} + req.xid + {\"<\/p>\n# <hr>\n# <p>Varnish cache server<\/p>\n# <\/body>\n# <\/html>\n# \"};\n# return (deliver);\n# }\n# \n# sub vcl_init {\n# \treturn (ok);\n# }\n# \n# sub vcl_fini {\n# \treturn (ok);\n# }\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'config\/varnish\/default.vcl' did not match any file(s) known to git\n","license":"mit","lang":"VCL"} {"commit":"83dba21c2882830042273c8699c89194b741aa93","subject":"Fixed headers broken by last fix.","message":"Fixed headers broken by last fix.\n","repos":"colstrom\/ansible-varnish,killerwails\/ansible-varnish,killerwails\/ansible-varnish,noqcks\/ansible-varnish,gotofbi\/ansible-varnish,kkwoker\/ansible-varnish,gotofbi\/ansible-varnish,telusdigital\/ansible-varnish","old_file":"templates\/etc\/varnish\/default.vcl","new_file":"templates\/etc\/varnish\/default.vcl","new_contents":"vcl 4.0;\n\nimport directors;\nimport std;\n\n###\n# Varnish Documentation\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-built-in-subs.html\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/reference\/vcl.html\n##\n\n{% for backend in varnish_backend_hosts %}\nbackend application_{{ loop.index }} {\n .host = \"{{ backend }}\";\n .port = \"{{ varnish_backend_port }}\";\n{% if varnish_health_checks_enabled %}\n .probe = {\n .url = \"{{ varnish_health_check_url }}\";\n .interval = {{ varnish_health_check_interval }};\n .timeout = {{ varnish_health_check_timeout }};\n .window = {{ varnish_health_check_window }};\n .threshold = {{ varnish_health_check_threshold }};\n }\n{% endif %}\n}\n{% endfor %}\n\n###\n# vcl_init\n# Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n###\n# The vcl_init subroutine may terminate with calling return() with one of the following keywords:\n#\n# ok\n# Normal return, VCL continues loading.\n##\n\nsub vcl_init {\n new application = directors.round_robin();\n{% for backend in varnish_backend_hosts %}\n application.add_backend(application_{{ loop.index }});\n{% endfor %}\n}\n\n###\n# vcl_recv\n# Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use. \n# It is also used to modify the request\n###\n# The vcl_recv subroutine may terminate with calling return() on one of the following keywords:\n#\n# synth(status code, reason)\n# Return a synthetic object with the specified status code to the client and abandon the request.\n# pass\n# Switch to pass mode. Control will eventually pass to vcl_pass.\n# pipe\n# Switch to pipe mode. Control will eventually pass to vcl_pipe.\n# hash\n# Continue processing the object as a potential candidate for caching. Passes the control over to vcl_hash.\n# purge\n# Purge the object and it's variants. Control passes through vcl_hash to vcl_purge.\n#\n\nsub vcl_recv {\n set req.backend_hint = application.backend();\n\n ###\n # Avoid processing uncacheable requests\n ###\n\n if (req.http.Authorization) {\n set req.http.X-Passthrough-Reason = \"No Caching Authenticated Content\";\n return (pass);\n }\n\n{% if varnish_uri_blacklist_enabled %}\n if ((req.url ~ \"{{ varnish_uri_blacklist_regexp }}\")) {\n set req.http.X-Passthrough-Reason = \"Path in Blacklist\";\n return(pass);\n }\n{% endif %}\n\n{% if varnish_diagnostic_headers_forwarded_for %}\n ###\n # Inject X-Forwarded-For headers, but only once.\n ###\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_enabled %}\n ###\n # Cookie Sanitization\n ###\n if (req.http.Cookie) {\n set req.http.X-Cookie-Unmodified = req.http.Cookie;\n\n {% for cookie in varnish_cookie_sanitization_blacklist %}\n# set req.http.Cookie = regsuball(req.http.Cookie, \"{{ cookie }}=[^;]+(; )?\", \"\");\n {% endfor %}\n\n ### General Cleanup\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n if (req.http.Cookie ~ \"^\\s*$\") {\n set req.http.X-Cookie-Discarded = \"YES:Empty\";\n unset req.http.Cookie;\n }\n if (req.http.Cookie) {\n set req.http.X-Cookie-Sanitized = req.http.Cookie;\n }\n }\n{% endif %}\n\n{% if varnish_header_sanitization_enabled %}\n ###\n # Header Sanitization\n ###\n\n{% if varnish_header_sanitization_discard_host_port %}\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n{% endif %}\n\n{% if varnish_header_sanitization_normalize_accept_encoding %}\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n{% endif %}\n\n{% endif %}\n\n{% if varnish_uri_sanitization_enabled %}\n ###\n # URI Sanitization\n ###\n \n if (req.url ~ \"(\\?|&){{ varnish_uri_sanitization_regexp }}=\") {\n set req.url = regsuball(req.url, \"&{{ varnish_uri_sanitization_regexp }}=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?{{ varnish_uri_sanitization_regexp }}=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n{% endif %}\n\n{% if varnish_workaround_telusdotcom_browser_profile %}\n ###\n # Workaround and Diagnostics for BrowserProfile and Language\/Region Detection on TELUS.com\n ###\n\n if (req.http.Cookie ~ \"BrowserProfile\") {\n set req.http.X-BrowserProfile = regsuball(req.http.Cookie, \"(.*)BrowserProfile=([^;]*)(.*)\", \"\\2\");\n if (req.http.X-BrowserProfile ~ \"language\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.X-BrowserProfile, \"(.*)language\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n set req.http.X-Language-Found = \"YES:BrowserProfile\";\n }\n if (req.http.X-BrowserProfile ~ \"region\") {\n set req.http.X-Region = std.tolower(regsuball(regsuball(req.http.X-BrowserProfile, \"geo\\\\.\\:{(.*)\\}\", \"\"), \"(.*)region\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n set req.http.X-Region-Found = \"YES:BrowserProfile\";\n }\n if (req.http.X-BrowserProfile ~ \"geo\") {\n set req.http.X-Geolocation = regsuball(req.http.X-BrowserProfile, \"(.*)geo..:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n set req.http.X-Geolocation-Found = \"YES:BrowserProfile\";\n\n if (req.http.X-Geolocation ~ \"country\") {\n set req.http.X-Geolocation-Country = regsuball(req.http.X-Geolocation, \"(.*)country\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-Geolocation ~ \"region\") {\n set req.http.X-Geolocation-Region = regsuball(req.http.X-Geolocation, \"(.*)region\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-Geolocation ~ \"city\") {\n set req.http.X-Geolocation-City = regsuball(req.http.X-Geolocation, \"(.*)city\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-Geolocation ~ \"isp\") {\n set req.http.X-Geolocation-ISP = regsuball(req.http.X-Geolocation, \"(.*)isp\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n } else {\n set req.http.X-Geolocation-Found = \"NO\";\n }\n }\n\n if (!req.http.X-Language) {\n if (req.http.Cookie ~ \"lang=\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.Cookie, \"(.*)lang=([^;]*)(.*)\", \"\\2\"));\n set req.http.X-Language-Found = \"YES:lang\";\n } else {\n set req.http.X-Language = \"en\";\n set req.http.X-Language-Found = \"NO\";\n }\n }\n\n if (!req.http.X-Region) {\n if (req.http.Cookie ~ \"prov=\") {\n set req.http.X-Region = std.tolower(regsuball(req.http.Cookie, \"(.*)prov=([^;]*)(.*)\", \"\\2\"));\n set req.http.X-Region-Found = \"YES:prov\";\n } else {\n set req.http.X-Region = \"bc\";\n set req.http.X-Region-Found = \"NO\";\n }\n }\n\n\n if (req.url ~ \"\/(en|fr)\/\") {\n if (req.url ~ \"\/en\/\" && req.http.X-Language != \"en\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Language (Path: \/en\/) vs (Cookie: \" + req.http.X-Language + \")\";\n return(pass);\n }\n if (req.url ~ \"\/fr\/\" && req.http.X-Language != \"fr\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Language (Path: \/fr\/) vs (Cookie: \" + req.http.X-Language + \")\";\n return(pass);\n }\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Language)\";\n return(pass);\n }\n\n if (req.url ~ \"\/(ab|bc|mb|nb|nl|ns|nt|nu|on|pe|qc|sk|yt)\/\") {\n {% for province in ['ab', 'bc', 'mb', 'nb', 'nl', 'ns', 'nt', 'nu', 'on', 'pe', 'qc', 'sk', 'yt'] %}\n if (req.url ~ \"\/{{ province }}\/\" && req.http.X-Region != \"{{ province }}\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Region (Path: \/{{ province }}\/) vs (Cookie: \" + req.http.X-Region + \")\";\n return(pass);\n }\n {% endfor %}\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Province)\";\n return(pass);\n }\n\n if (req.http.Cookie) {\n if (req.http.Cookie ~ \"***REMOVED***\") {\n set req.http.X-Screen-Resolution = regsuball(req.http.Cookie, \"(.*)***REMOVED***=([^;]*)(.*)\", \"\\2\");\n }\n\n if (req.http.Cookie ~ \"***REMOVED***\") {\n set req.http.X-Customer-Type = regsuball(req.http.Cookie, \"(.*)***REMOVED***=([^;]*)(.*)\", \"\\2\");\n }\n if (req.http.Cookie ~ \"***REMOVED***\") {\n set req.http.X-Outdated-Browser = regsuball(req.http.Cookie, \"(.*)***REMOVED***=([^;]*)(.*)\", \"\\2\");\n }\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_discard_from_client %}\n set req.http.X-Cookie-Discarded = \"YES:No Reason Not To\";\n unset req.http.Cookie;\n{% endif %}\n}\n\n###\n# vcl_hit\n# Called when a cache lookup is successful.\n###\n# The vcl_hit subroutine may terminate with calling return() with one of the following keywords:\n#\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n# deliver\n# Deliver the object. Control passes to vcl_deliver.\n# synth(status code, reason)\n# Return the specified status code to the client and abandon the request.\n###\n\nsub vcl_hit {\n if (obj.ttl > 0s) {\n return (deliver);\n }\n{% if varnish_health_checks_enabled %}\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (fetch);\n }\n{% else %}\n if (obj.ttl + obj.grace > 0s) {\n return (deliver);\n }\n\n return (fetch);\n{% endif %}\n}\n\n###\n# vcl_backend_response\n# Called after the response headers has been successfully retrieved from the backend.\n###\n# The vcl_backend_response subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Possibly insert the object into the cache, then deliver it to the Control will eventually pass to vcl_deliver.\n# abandon\n# Abandon the backend request and generates an error.\n# retry\n# Retry the backend transaction. Increases the retries counter. If the number of retries is higher than max_retries Varnish emits a guru meditation error.\n###\n\nsub vcl_backend_response {\n{% if varnish_workaround_telusdotcom_browser_profile %}\n if (bereq.http.X-Language) {\n set beresp.http.X-Language = bereq.http.X-Language;\n# if (bereq.http.X-Language-Found) {\n# set beresp.http.X-Language-Found = bereq.http.X-Language-Found;\n# }\n }\n if (bereq.http.X-Region) {\n set beresp.http.X-Region = bereq.http.X-Region;\n# if (bereq.http.X-Region-Found) {\n# set beresp.http.X-Region-Found = bereq.http.X-Region-Found;\n# }\n }\n{% endif %}\n\n{% if varnish_uri_blacklist_enabled %}\n if (bereq.url ~ \"{{ varnish_uri_blacklist_regexp }}\") {\n set beresp.http.X-Cacheable = \"NO:Path in Blacklist\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n if (bereq.http.X-Passthrough-Reason) {\n{% if varnish_diagnostic_headers_passthrough_reason %}\n set beresp.http.X-Passthrough-Reason = bereq.http.X-Passthrough-Reason;\n{% endif %}\n return(deliver);\n } else {\n{% if varnish_cookie_sanitization_discard_from_server %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n }\n }\n{% else %}\n{% if varnish_cookie_sanitization_discard_from_server %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n{% endif %}\n\n{% if varnish_diagnostic_headers_enabled %}\n if (bereq.http.Cookie) {\n set beresp.http.X-Cacheable = \"NO:Cookie in Request\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO:Set-Cookie in Response\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.X-No-Cache) {\n set beresp.http.X-Cacheable = \"NO:X-No-Cache\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.ttl <= 0s) {\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n{% endif %}\n\n set beresp.grace = {{ varnish_grace_period }};\n}\n\n###\n# vcl_deliver\n# Called before a cached object is delivered to the client.\n###\n# The vcl_deliver subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Deliver the object to the client.\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n###\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n","old_contents":"vcl 4.0;\n\nimport directors;\nimport std;\n\n###\n# Varnish Documentation\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-built-in-subs.html\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/reference\/vcl.html\n##\n\n{% for backend in varnish_backend_hosts %}\nbackend application_{{ loop.index }} {\n .host = \"{{ backend }}\";\n .port = \"{{ varnish_backend_port }}\";\n{% if varnish_health_checks_enabled %}\n .probe = {\n .url = \"{{ varnish_health_check_url }}\";\n .interval = {{ varnish_health_check_interval }};\n .timeout = {{ varnish_health_check_timeout }};\n .window = {{ varnish_health_check_window }};\n .threshold = {{ varnish_health_check_threshold }};\n }\n{% endif %}\n}\n{% endfor %}\n\n###\n# vcl_init\n# Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n###\n# The vcl_init subroutine may terminate with calling return() with one of the following keywords:\n#\n# ok\n# Normal return, VCL continues loading.\n##\n\nsub vcl_init {\n new application = directors.round_robin();\n{% for backend in varnish_backend_hosts %}\n application.add_backend(application_{{ loop.index }});\n{% endfor %}\n}\n\n###\n# vcl_recv\n# Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use. \n# It is also used to modify the request\n###\n# The vcl_recv subroutine may terminate with calling return() on one of the following keywords:\n#\n# synth(status code, reason)\n# Return a synthetic object with the specified status code to the client and abandon the request.\n# pass\n# Switch to pass mode. Control will eventually pass to vcl_pass.\n# pipe\n# Switch to pipe mode. Control will eventually pass to vcl_pipe.\n# hash\n# Continue processing the object as a potential candidate for caching. Passes the control over to vcl_hash.\n# purge\n# Purge the object and it's variants. Control passes through vcl_hash to vcl_purge.\n#\n\nsub vcl_recv {\n set req.backend_hint = application.backend();\n\n ###\n # Avoid processing uncacheable requests\n ###\n\n if (req.http.Authorization) {\n set req.http.X-Passthrough-Reason = \"No Caching Authenticated Content\";\n return (pass);\n }\n\n{% if varnish_uri_blacklist_enabled %}\n if ((req.url ~ \"{{ varnish_uri_blacklist_regexp }}\")) {\n set req.http.X-Passthrough-Reason = \"Path in Blacklist\";\n return(pass);\n }\n{% endif %}\n\n{% if varnish_diagnostic_headers_forwarded_for %}\n ###\n # Inject X-Forwarded-For headers, but only once.\n ###\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_enabled %}\n ###\n # Cookie Sanitization\n ###\n if (req.http.Cookie) {\n set req.http.X-Cookie-Unmodified = req.http.Cookie;\n\n {% for cookie in varnish_cookie_sanitization_blacklist %}\n# set req.http.Cookie = regsuball(req.http.Cookie, \"{{ cookie }}=[^;]+(; )?\", \"\");\n {% endfor %}\n\n ### General Cleanup\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n if (req.http.Cookie ~ \"^\\s*$\") {\n set req.http.X-Cookie-Discarded = \"YES:Empty\";\n unset req.http.Cookie;\n }\n if (req.http.Cookie) {\n set req.http.X-Cookie-Sanitized = req.http.Cookie;\n }\n }\n{% endif %}\n\n{% if varnish_header_sanitization_enabled %}\n ###\n # Header Sanitization\n ###\n\n{% if varnish_header_sanitization_discard_host_port %}\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n{% endif %}\n\n{% if varnish_header_sanitization_normalize_accept_encoding %}\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n{% endif %}\n\n{% endif %}\n\n{% if varnish_uri_sanitization_enabled %}\n ###\n # URI Sanitization\n ###\n \n if (req.url ~ \"(\\?|&){{ varnish_uri_sanitization_regexp }}=\") {\n set req.url = regsuball(req.url, \"&{{ varnish_uri_sanitization_regexp }}=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?{{ varnish_uri_sanitization_regexp }}=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n{% endif %}\n\n{% if varnish_workaround_telusdotcom_browser_profile %}\n ###\n # Workaround and Diagnostics for BrowserProfile and Language\/Region Detection on TELUS.com\n ###\n\n if (req.http.Cookie ~ \"BrowserProfile\") {\n set req.http.X-BrowserProfile = regsuball(req.http.Cookie, \"(.*)BrowserProfile=([^;]*)(.*)\", \"\\2\");\n if (req.http.X-BrowserProfile ~ \"language\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.X-BrowserProfile, \"(.*)language\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n set req.http.X-Language-Found = \"YES:BrowserProfile\";\n }\n if (req.http.X-BrowserProfile ~ \"region\") {\n set req.http.X-Region = std.tolower(regsuball(regsuball(req.http.X-BrowserProfile, \"geo\\\\.\\:{(.*)\\}\", \"\"), \"(.*)region\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n set req.http.X-Region-Found = \"YES:BrowserProfile\";\n }\n if (req.http.X-BrowserProfile ~ \"geo\") {\n set req.http.X-Geolocation = regsuball(req.http.X-BrowserProfile, \"(.*)geo..:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n set req.http.X-Geolocation-Found = \"YES:BrowserProfile\";\n\n if (req.http.X-Geolocation ~ \"country\") {\n set req.http.X-Geolocation-Country = regsuball(req.http.X-BrowserProfile-Geolocation, \"(.*)country\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-Geolocation ~ \"region\") {\n set req.http.X-Geolocation-Region = regsuball(req.http.X-BrowserProfile-Geolocation, \"(.*)region\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-Geolocation ~ \"city\") {\n set req.http.X-Geolocation-City = regsuball(req.http.X-BrowserProfile-Geolocation, \"(.*)city\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-Geolocation ~ \"isp\") {\n set req.http.X-Geolocation-ISP = regsuball(req.http.X-BrowserProfile-Geolocation, \"(.*)isp\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n } else {\n set req.http.X-Geolocation-Found = \"NO\";\n }\n }\n\n if (!req.http.X-Language) {\n if (req.http.Cookie ~ \"lang=\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.Cookie, \"(.*)lang=([^;]*)(.*)\", \"\\2\"));\n set req.http.X-Language-Found = \"YES:lang\";\n } else {\n set req.http.X-Language = \"en\";\n set req.http.X-Language-Found = \"NO\";\n }\n }\n\n if (!req.http.X-Region) {\n if (req.http.Cookie ~ \"prov=\") {\n set req.http.X-Region = std.tolower(regsuball(req.http.Cookie, \"(.*)prov=([^;]*)(.*)\", \"\\2\"));\n set req.http.X-Region-Found = \"YES:prov\";\n } else {\n set req.http.X-Region = \"bc\";\n set req.http.X-Region-Found = \"NO\";\n }\n }\n\n\n if (req.url ~ \"\/(en|fr)\/\") {\n if (req.url ~ \"\/en\/\" && req.http.X-Language != \"en\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Language (Path: \/en\/) vs (Cookie: \" + req.http.X-Language + \")\";\n return(pass);\n }\n if (req.url ~ \"\/fr\/\" && req.http.X-Language != \"fr\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Language (Path: \/fr\/) vs (Cookie: \" + req.http.X-Language + \")\";\n return(pass);\n }\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Language)\";\n return(pass);\n }\n\n if (req.url ~ \"\/(ab|bc|mb|nb|nl|ns|nt|nu|on|pe|qc|sk|yt)\/\") {\n {% for province in ['ab', 'bc', 'mb', 'nb', 'nl', 'ns', 'nt', 'nu', 'on', 'pe', 'qc', 'sk', 'yt'] %}\n if (req.url ~ \"\/{{ province }}\/\" && req.http.X-Region != \"{{ province }}\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Region (Path: \/{{ province }}\/) vs (Cookie: \" + req.http.X-Region + \")\";\n return(pass);\n }\n {% endfor %}\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Province)\";\n return(pass);\n }\n\n if (req.http.Cookie) {\n if (req.http.Cookie ~ \"***REMOVED***\") {\n set req.http.X-Screen-Resolution = regsuball(req.http.Cookie, \"(.*)***REMOVED***=([^;]*)(.*)\", \"\\2\");\n }\n\n if (req.http.Cookie ~ \"***REMOVED***\") {\n set req.http.X-Customer-Type = regsuball(req.http.Cookie, \"(.*)***REMOVED***=([^;]*)(.*)\", \"\\2\");\n }\n if (req.http.Cookie ~ \"***REMOVED***\") {\n set req.http.X-Outdated-Browser = regsuball(req.http.Cookie, \"(.*)***REMOVED***=([^;]*)(.*)\", \"\\2\");\n }\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_discard_from_client %}\n set req.http.X-Cookie-Discarded = \"YES:No Reason Not To\";\n unset req.http.Cookie;\n{% endif %}\n}\n\n###\n# vcl_hit\n# Called when a cache lookup is successful.\n###\n# The vcl_hit subroutine may terminate with calling return() with one of the following keywords:\n#\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n# deliver\n# Deliver the object. Control passes to vcl_deliver.\n# synth(status code, reason)\n# Return the specified status code to the client and abandon the request.\n###\n\nsub vcl_hit {\n if (obj.ttl > 0s) {\n return (deliver);\n }\n{% if varnish_health_checks_enabled %}\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (fetch);\n }\n{% else %}\n if (obj.ttl + obj.grace > 0s) {\n return (deliver);\n }\n\n return (fetch);\n{% endif %}\n}\n\n###\n# vcl_backend_response\n# Called after the response headers has been successfully retrieved from the backend.\n###\n# The vcl_backend_response subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Possibly insert the object into the cache, then deliver it to the Control will eventually pass to vcl_deliver.\n# abandon\n# Abandon the backend request and generates an error.\n# retry\n# Retry the backend transaction. Increases the retries counter. If the number of retries is higher than max_retries Varnish emits a guru meditation error.\n###\n\nsub vcl_backend_response {\n{% if varnish_workaround_telusdotcom_browser_profile %}\n if (bereq.http.X-Language) {\n set beresp.http.X-Language = bereq.http.X-Language;\n# if (bereq.http.X-Language-Found) {\n# set beresp.http.X-Language-Found = bereq.http.X-Language-Found;\n# }\n }\n if (bereq.http.X-Region) {\n set beresp.http.X-Region = bereq.http.X-Region;\n# if (bereq.http.X-Region-Found) {\n# set beresp.http.X-Region-Found = bereq.http.X-Region-Found;\n# }\n }\n{% endif %}\n\n{% if varnish_uri_blacklist_enabled %}\n if (bereq.url ~ \"{{ varnish_uri_blacklist_regexp }}\") {\n set beresp.http.X-Cacheable = \"NO:Path in Blacklist\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n if (bereq.http.X-Passthrough-Reason) {\n{% if varnish_diagnostic_headers_passthrough_reason %}\n set beresp.http.X-Passthrough-Reason = bereq.http.X-Passthrough-Reason;\n{% endif %}\n return(deliver);\n } else {\n{% if varnish_cookie_sanitization_discard_from_server %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n }\n }\n{% else %}\n{% if varnish_cookie_sanitization_discard_from_server %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n{% endif %}\n\n{% if varnish_diagnostic_headers_enabled %}\n if (bereq.http.Cookie) {\n set beresp.http.X-Cacheable = \"NO:Cookie in Request\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO:Set-Cookie in Response\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.X-No-Cache) {\n set beresp.http.X-Cacheable = \"NO:X-No-Cache\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.ttl <= 0s) {\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n{% endif %}\n\n set beresp.grace = {{ varnish_grace_period }};\n}\n\n###\n# vcl_deliver\n# Called before a cached object is delivered to the client.\n###\n# The vcl_deliver subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Deliver the object to the client.\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n###\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"9d09170bdca2018cca44d28714ed4b81b6029c2f","subject":"Regex set for doing device detection","message":"Regex set for doing device detection\n","repos":"ssm\/pkg-varnish,ssm\/pkg-varnish,ssm\/pkg-varnish,ssm\/pkg-varnish,ssm\/pkg-varnish","old_file":"etc\/devicedetect.vcl","new_file":"etc\/devicedetect.vcl","new_contents":"#\n# detectdevice.vcl - regex based device detection for Varnish\n# http:\/\/github.com\/varnish\/varnish-devicedetect\/\n#\n# Author: Lasse Karstensen <lasse@varnish-software.com>\n\nsub devicedetect {\n unset req.http.X-UA-Device;\n set req.http.X-UA-Device = \"pc\";\n\n if (req.http.User-Agent ~ \"(?i)(ads|google|bing|msn|yandex|baidu|ro|career|)bot\" ||\n\treq.http.User-Agent ~ \"(?i)(baidu|symantec)spider\" ||\n\treq.http.User-Agent ~ \"(?i)scanner\" ||\n\treq.http.User-Agent ~ \"(?i)(web)crawler\") {\n\tset req.http.X-UA-Device = \"bot\"; }\n elsif (req.http.User-Agent ~ \"(?i)ip(hone|od)\") { set req.http.X-UA-Device = \"mobile-iphone\"; }\n elsif (req.http.User-Agent ~ \"(?i)ipad\") { set req.http.X-UA-Device = \"tablet-ipad\"; }\n # how do we differ between an android phone and an android tablet?\n # http:\/\/stackoverflow.com\/questions\/5341637\/how-do-detect-android-tablets-in-general-useragent\n elsif (req.http.User-Agent ~ \"(?i)android.*(mobile|mini)\") { set req.http.X-UA-Device = \"mobile-android\"; } \n # android 3\/honeycomb was just about tablet-only, and any phones will probably handle a bigger page layout.\n elsif (req.http.User-Agent ~ \"(?i)android 3\") { set req.http.X-UA-Device = \"tablet-android\"; }\n # may very well give false positives towards android tablets. Suggestions welcome.\n elsif (req.http.User-Agent ~ \"(?i)android\") { set req.http.X-UA-Device = \"tablet-android\"; }\n\n elsif (req.http.User-Agent ~ \"^HTC\" ||\n req.http.User-Agent ~ \"Fennec\" || \n req.http.User-Agent ~ \"IEMobile\" ||\n req.http.User-Agent ~ \"BlackBerry\" ||\n req.http.User-Agent ~ \"SymbianOS.*AppleWebKit\" ||\n req.http.User-Agent ~ \"Opera Mobi\") {\n set req.http.X-UA-Device = \"mobile-smartphone\";\n }\n elsif (req.http.User-Agent ~ \"(?i)symbian\" ||\n req.http.User-Agent ~ \"(?i)^sonyericsson\" ||\n req.http.User-Agent ~ \"(?i)^nokia\" ||\n req.http.User-Agent ~ \"(?i)^samsung\" ||\n req.http.User-Agent ~ \"(?i)^lg\" ||\n\treq.http.User-Agent ~ \"(?i)bada\" ||\n\treq.http.User-Agent ~ \"(?i)blazer\" ||\n\treq.http.User-Agent ~ \"(?i)cellphone\" ||\n\treq.http.User-Agent ~ \"(?i)iemobile\" ||\n\treq.http.User-Agent ~ \"(?i)midp-2.0\" ||\n\treq.http.User-Agent ~ \"(?i)u990\" ||\n\treq.http.User-Agent ~ \"(?i)netfront\" ||\n\treq.http.User-Agent ~ \"(?i)opera mini\" ||\n\treq.http.User-Agent ~ \"(?i)palm\" ||\n\treq.http.User-Agent ~ \"(?i)nintendo wii\" ||\n\treq.http.User-Agent ~ \"(?i)playstation portable\" ||\n\treq.http.User-Agent ~ \"(?i)portalmmm\" ||\n\treq.http.User-Agent ~ \"(?i)proxinet\" ||\n\treq.http.User-Agent ~ \"(?i)sonyericsson\" ||\n\treq.http.User-Agent ~ \"(?i)symbian\" ||\n\treq.http.User-Agent ~ \"(?i)windows\\ ?ce\" ||\n\treq.http.User-Agent ~ \"(?i)winwap\" ||\n\treq.http.User-Agent ~ \"(?i)eudoraweb\" ||\n\treq.http.User-Agent ~ \"(?i)htc\" ||\n\treq.http.User-Agent ~ \"(?i)240x320\" ||\n\treq.http.User-Agent ~ \"(?i)avantgo\") { \n set req.http.X-UA-Device = \"mobile-generic\";\n } \n # handle overrides\n if (req.http.Cookie ~ \"(i?)X-UA-Device-force\") {\n # ;?? means zero or one ;, non-greedy to match the first.\n set req.http.X-UA-Device = regsub(req.http.Cookie, \"(?i).*X-UA-Device-force=([^;]+);??.*\", \"\\1\");\n }\n}\n\n# vim: sw=4:tw=120 # meh\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'etc\/devicedetect.vcl' did not match any file(s) known to git\n","license":"bsd-2-clause","lang":"VCL"} {"commit":"0f73fb958d3b08888dd9aa766d7099cc8b3fc078","subject":"Update backend declaration syntax. Note that a) vcl.7 needs a partial rewrite to track this change, and b) there have been other changes which also need to be merged in.","message":"Update backend declaration syntax. Note that a) vcl.7 needs a partial\nrewrite to track this change, and b) there have been other changes which\nalso need to be merged in.\n\n\ngit-svn-id: 2c9807fa3ff65b17195bd55dc8a6c4261e10127b@2446 d4fa192b-c00b-0410-8231-f00ffab90ce4\n","repos":"ssm\/pkg-varnish,chrismoulton\/Varnish-Cache,1HLtd\/Varnish-Cache,feld\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,mrhmouse\/Varnish-Cache,ssm\/pkg-varnish,alarky\/varnish-cache-doc-ja,1HLtd\/Varnish-Cache,franciscovg\/Varnish-Cache,drwilco\/varnish-cache-old,varnish\/Varnish-Cache,ssm\/pkg-varnish,alarky\/varnish-cache-doc-ja,ajasty-cavium\/Varnish-Cache,varnish\/Varnish-Cache,varnish\/Varnish-Cache,alarky\/varnish-cache-doc-ja,ssm\/pkg-varnish,drwilco\/varnish-cache-drwilco,mrhmouse\/Varnish-Cache,franciscovg\/Varnish-Cache,drwilco\/varnish-cache-drwilco,gauthier-delacroix\/Varnish-Cache,chrismoulton\/Varnish-Cache,mrhmouse\/Varnish-Cache,zhoualbeart\/Varnish-Cache,franciscovg\/Varnish-Cache,varnish\/Varnish-Cache,feld\/Varnish-Cache,mrhmouse\/Varnish-Cache,ambernetas\/varnish-cache,ajasty-cavium\/Varnish-Cache,zhoualbeart\/Varnish-Cache,zhoualbeart\/Varnish-Cache,zhoualbeart\/Varnish-Cache,alarky\/varnish-cache-doc-ja,gquintard\/Varnish-Cache,chrismoulton\/Varnish-Cache,ssm\/pkg-varnish,franciscovg\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,franciscovg\/Varnish-Cache,wikimedia\/operations-debs-varnish,drwilco\/varnish-cache-old,1HLtd\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,drwilco\/varnish-cache-drwilco,ambernetas\/varnish-cache,alarky\/varnish-cache-doc-ja,chrismoulton\/Varnish-Cache,ajasty-cavium\/Varnish-Cache,gquintard\/Varnish-Cache,wikimedia\/operations-debs-varnish,wikimedia\/operations-debs-varnish,ambernetas\/varnish-cache,1HLtd\/Varnish-Cache,chrismoulton\/Varnish-Cache,wikimedia\/operations-debs-varnish,gauthier-delacroix\/Varnish-Cache,gauthier-delacroix\/Varnish-Cache,gquintard\/Varnish-Cache,mrhmouse\/Varnish-Cache,drwilco\/varnish-cache-old,gquintard\/Varnish-Cache,varnish\/Varnish-Cache,feld\/Varnish-Cache,zhoualbeart\/Varnish-Cache,wikimedia\/operations-debs-varnish,feld\/Varnish-Cache,feld\/Varnish-Cache","old_file":"etc\/default.vcl","new_file":"etc\/default.vcl","new_contents":"","old_contents":"","returncode":128,"stderr":"remote: Support for password authentication was removed on August 13, 2021.\nremote: Please see https:\/\/docs.github.com\/en\/get-started\/getting-started-with-git\/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.\nfatal: Authentication failed for 'https:\/\/github.com\/alarky\/varnish-cache-doc-ja.git\/'\n","license":"bsd-2-clause","lang":"VCL"} {"commit":"80a31fab5c6f719caa81e732a18d2bcac41c6d6f","subject":"Update region detection workaround for TELUS.com.","message":"Update region detection workaround for TELUS.com.\n","repos":"colstrom\/ansible-varnish,telusdigital\/ansible-varnish,kkwoker\/ansible-varnish,killerwails\/ansible-varnish,gotofbi\/ansible-varnish,gotofbi\/ansible-varnish,noqcks\/ansible-varnish,killerwails\/ansible-varnish","old_file":"templates\/etc\/varnish\/default.vcl","new_file":"templates\/etc\/varnish\/default.vcl","new_contents":"vcl 4.0;\n\nimport directors;\nimport std;\n\n###\n# Varnish Documentation\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-built-in-subs.html\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/reference\/vcl.html\n##\n\n{% for backend in varnish_backend_hosts %}\nbackend application_{{ loop.index }} {\n .host = \"{{ backend }}\";\n .port = \"{{ varnish_backend_port }}\";\n{% if varnish_health_checks_enabled %}\n .probe = {\n .url = \"{{ varnish_health_check_url }}\";\n .interval = {{ varnish_health_check_interval }};\n .timeout = {{ varnish_health_check_timeout }};\n .window = {{ varnish_health_check_window }};\n .threshold = {{ varnish_health_check_threshold }};\n }\n{% endif %}\n}\n{% endfor %}\n\n###\n# vcl_init\n# Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n###\n# The vcl_init subroutine may terminate with calling return() with one of the following keywords:\n#\n# ok\n# Normal return, VCL continues loading.\n##\n\nsub vcl_init {\n new application = directors.round_robin();\n{% for backend in varnish_backend_hosts %}\n application.add_backend(application_{{ loop.index }});\n{% endfor %}\n}\n\n###\n# vcl_recv\n# Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use. \n# It is also used to modify the request\n###\n# The vcl_recv subroutine may terminate with calling return() on one of the following keywords:\n#\n# synth(status code, reason)\n# Return a synthetic object with the specified status code to the client and abandon the request.\n# pass\n# Switch to pass mode. Control will eventually pass to vcl_pass.\n# pipe\n# Switch to pipe mode. Control will eventually pass to vcl_pipe.\n# hash\n# Continue processing the object as a potential candidate for caching. Passes the control over to vcl_hash.\n# purge\n# Purge the object and it's variants. Control passes through vcl_hash to vcl_purge.\n#\n\nsub vcl_recv {\n set req.backend_hint = application.backend();\n\n ###\n # Avoid processing uncacheable requests\n ###\n\n if (req.http.Authorization) {\n return (pass);\n }\n\n ###\n # Inject X-Forwarded-For headers, but only once.\n ###\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n{% if varnish_header_sanitization_enabled %}\n ###\n # Header Sanitization\n ###\n\n{% if varnish_discards_port_from_host_header %}\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n{% endif %}\n\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_enabled %}\n ###\n # Cookie Sanitization\n ###\n\n ### Google Analytics\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n\n ### Quantcast\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n \n ### AddThis\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n\n ### General Cleanup\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n{% endif %}\n\n{% if varnish_uri_sanitization_enabled %}\n ###\n # URI Sanitization\n ###\n \n if (req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=\") {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n{% endif %}\n\n{% if varnish_workaround_telusdotcom_browser_profile %}\n ###\n # Workaround for BrowserProfile and Language\/Region Detection on TELUS.com\n ###\n\n if (req.http.Cookie ~ \"BrowserProfile\") {\n set req.http.X-Language = regsuball(req.http.Cookie, \"language..:\\\\.(.*)\\\\.,\", \"\\1\");\n set req.http.X-Province = regsuball(req.http.Cookie, \"region..:\\\\.(.*)\\\\.,\", \"\\1\");\n } else {\n if (req.http.Cookie ~ \"lang=\") {\n set req.http.X-Language = regsuball(req.http.Cookie, \"lang=(.*);\", \"\\1\");\n } else {\n set req.http.X-Language = \"en\";\n }\n\n if (req.http.Cookie ~ \"prov=\") {\n set req.http.X-Province = regsuball(req.http.Cookie, \"prov=(.*);\", \"\\1\");\n } else {\n set req.http.X-Province = \"BC\";\n }\n }\n\n if (req.url ~ \"\/(en|fr)\/\") {\n if (req.url ~ \"\/en\/\" && req.http.X-Language != \"en\") {\n return(pass);\n }\n if (req.url ~ \"\/fr\/\" && req.http.X-Language != \"fr\") {\n return(pass);\n }\n } else {\n return(pass);\n }\n\n if (req.url ~ \"\/(ab|bc|mb|nb|nl|ns|nt|nu|on|pe|qc|sk|yt)\/\") {\n {% for province in ['ab', 'bc', 'mb', 'nb', 'nl', 'ns', 'nt', 'nu', 'on', 'pe', 'qc', 'sk', 'yt'] %}\n if (req.url ~ \"{{ province }}\" && req.http.X-Province != \"{{ province }}\") {\n return(pass);\n }\n {% endfor %}\n } else {\n return(pass);\n }\n{% endif %}\n\n{% if varnish_blacklist_enabled %}\n if ((req.url ~ \"{{ varnish_blacklist_regexp }}\")) {\n return(pass);\n } else {\n{% if varnish_discards_client_cookies %}\n unset req.http.Cookie;\n{% endif %}\n }\n{% endif %}\n\n}\n\n###\n# vcl_hit\n# Called when a cache lookup is successful.\n###\n# The vcl_hit subroutine may terminate with calling return() with one of the following keywords:\n#\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n# deliver\n# Deliver the object. Control passes to vcl_deliver.\n# synth(status code, reason)\n# Return the specified status code to the client and abandon the request.\n###\n\nsub vcl_hit {\n if (obj.ttl > 0s) {\n return (deliver);\n }\n{% if varnish_health_checks_enabled %}\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (fetch);\n }\n{% else %}\n if (obj.ttl + obj.grace > 0s) {\n return (deliver);\n }\n\n return (fetch);\n{% endif %}\n}\n\n###\n# vcl_backend_response\n# Called after the response headers has been successfully retrieved from the backend.\n###\n# The vcl_backend_response subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Possibly insert the object into the cache, then deliver it to the Control will eventually pass to vcl_deliver.\n# abandon\n# Abandon the backend request and generates an error.\n# retry\n# Retry the backend transaction. Increases the retries counter. If the number of retries is higher than max_retries Varnish emits a guru meditation error.\n###\n\nsub vcl_backend_response {\n{% if varnish_blacklist_enabled %}\n if (bereq.url ~ \"{{ varnish_blacklist_regexp }}\") {\n set beresp.http.X-Cacheable = \"NO:Path in Blacklist\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n }\n{% else %}\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n{% endif %}\n\n{% if varnish_cache_diagnostics_enabled %}\n if (bereq.http.Cookie) {\n set beresp.http.X-Cacheable = \"NO:Cookie in Request\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO:Set-Cookie in Response\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.X-No-Cache) {\n set beresp.http.X-Cacheable = \"NO:X-No-Cache\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.ttl <= 0s) {\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n{% endif %}\n\n set beresp.grace = {{ varnish_grace_period }};\n}\n\n###\n# vcl_deliver\n# Called before a cached object is delivered to the client.\n###\n# The vcl_deliver subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Deliver the object to the client.\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n###\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n","old_contents":"vcl 4.0;\n\nimport directors;\nimport std;\n\n###\n# Varnish Documentation\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-built-in-subs.html\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/reference\/vcl.html\n##\n\n{% for backend in varnish_backend_hosts %}\nbackend application_{{ loop.index }} {\n .host = \"{{ backend }}\";\n .port = \"{{ varnish_backend_port }}\";\n{% if varnish_health_checks_enabled %}\n .probe = {\n .url = \"{{ varnish_health_check_url }}\";\n .interval = {{ varnish_health_check_interval }};\n .timeout = {{ varnish_health_check_timeout }};\n .window = {{ varnish_health_check_window }};\n .threshold = {{ varnish_health_check_threshold }};\n }\n{% endif %}\n}\n{% endfor %}\n\n###\n# vcl_init\n# Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n###\n# The vcl_init subroutine may terminate with calling return() with one of the following keywords:\n#\n# ok\n# Normal return, VCL continues loading.\n##\n\nsub vcl_init {\n new application = directors.round_robin();\n{% for backend in varnish_backend_hosts %}\n application.add_backend(application_{{ loop.index }});\n{% endfor %}\n}\n\n###\n# vcl_recv\n# Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use. \n# It is also used to modify the request\n###\n# The vcl_recv subroutine may terminate with calling return() on one of the following keywords:\n#\n# synth(status code, reason)\n# Return a synthetic object with the specified status code to the client and abandon the request.\n# pass\n# Switch to pass mode. Control will eventually pass to vcl_pass.\n# pipe\n# Switch to pipe mode. Control will eventually pass to vcl_pipe.\n# hash\n# Continue processing the object as a potential candidate for caching. Passes the control over to vcl_hash.\n# purge\n# Purge the object and it's variants. Control passes through vcl_hash to vcl_purge.\n#\n\nsub vcl_recv {\n set req.backend_hint = application.backend();\n\n ###\n # Avoid processing uncacheable requests\n ###\n\n if (req.http.Authorization) {\n return (pass);\n }\n\n ###\n # Inject X-Forwarded-For headers, but only once.\n ###\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n\n{% if varnish_header_sanitization_enabled %}\n ###\n # Header Sanitization\n ###\n\n{% if varnish_discards_port_from_host_header %}\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n{% endif %}\n\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_enabled %}\n ###\n # Cookie Sanitization\n ###\n\n ### Google Analytics\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n\n ### Quantcast\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n \n ### AddThis\n set req.http.Cookie = regsuball(req.http.Cookie, \"***REMOVED***=[^;]+(; )?\", \"\");\n\n ### General Cleanup\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n{% endif %}\n\n{% if varnish_uri_sanitization_enabled %}\n ###\n # URI Sanitization\n ###\n \n if (req.url ~ \"(\\?|&)(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=\") {\n set req.url = regsuball(req.url, \"&(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?(utm_source|utm_medium|utm_campaign|gclid|cx|ie|cof|siteurl)=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n\n{% endif %}\n\n{% if varnish_workaround_telusdotcom_browser_profile %}\n ###\n # Workaround for BrowserProfile and Language\/Region Detection on TELUS.com\n ###\n\n if (req.http.Cookie ~ \"BrowserProfile\") {\n set req.http.X-Language = regsuball(req.http.Cookie, \"language..:\\\\.(.*)\\\\.,\", \"\\1\");\n set req.http.X-Province = regsuball(req.http.Cookie, \"region..:\\\\.(.*)\\\\.,\", \"\\1\");\n } else {\n if (req.http.Cookie ~ \"lang=\") {\n set req.http.X-Language = regsuball(req.http.Cookie, \"lang=(.*);\", \"\\1\");\n } else {\n set req.http.X-Language = \"en\";\n }\n\n if (req.http.Cookie ~ \"prov=\") {\n set req.http.X-Province = regsuball(req.http.Cookie, \"prov=(.*);\", \"\\1\");\n } else {\n set req.http.X-Province = \"BC\";\n }\n }\n\n if (req.url ~ \"\/(en|fr)\/\") {\n if (req.url ~ \"\/en\/\" && req.http.X-Language != \"en\") {\n return(pass);\n }\n if (req.url ~ \"\/fr\/\" && req.http.X-Language != \"fr\") {\n return(pass);\n }\n }\n\n if (req.url ~ \"\/(ab|bc|mb|nb|nl|ns|nt|nu|on|pe|qc|sk|yt)\/\") {\n {% for province in ['ab', 'bc', 'mb', 'nb', 'nl', 'ns', 'nt', 'nu', 'on', 'pe', 'qc', 'sk', 'yt'] %}\n if (req.url ~ \"{{ province }}\" && req.http.X-Province != \"{{ province }}\") {\n return(pass);\n }\n {% endfor %}\n }\n{% endif %}\n\n{% if varnish_blacklist_enabled %}\n if ((req.url ~ \"{{ varnish_blacklist_regexp }}\")) {\n return(pass);\n } else {\n{% if varnish_discards_client_cookies %}\n unset req.http.Cookie;\n{% endif %}\n }\n{% endif %}\n\n}\n\n###\n# vcl_hit\n# Called when a cache lookup is successful.\n###\n# The vcl_hit subroutine may terminate with calling return() with one of the following keywords:\n#\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n# deliver\n# Deliver the object. Control passes to vcl_deliver.\n# synth(status code, reason)\n# Return the specified status code to the client and abandon the request.\n###\n\nsub vcl_hit {\n if (obj.ttl > 0s) {\n return (deliver);\n }\n{% if varnish_health_checks_enabled %}\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (fetch);\n }\n{% else %}\n if (obj.ttl + obj.grace > 0s) {\n return (deliver);\n }\n\n return (fetch);\n{% endif %}\n}\n\n###\n# vcl_backend_response\n# Called after the response headers has been successfully retrieved from the backend.\n###\n# The vcl_backend_response subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Possibly insert the object into the cache, then deliver it to the Control will eventually pass to vcl_deliver.\n# abandon\n# Abandon the backend request and generates an error.\n# retry\n# Retry the backend transaction. Increases the retries counter. If the number of retries is higher than max_retries Varnish emits a guru meditation error.\n###\n\nsub vcl_backend_response {\n{% if varnish_blacklist_enabled %}\n if (bereq.url ~ \"{{ varnish_blacklist_regexp }}\") {\n set beresp.http.X-Cacheable = \"NO:Path in Blacklist\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n }\n{% else %}\n{% if varnish_discards_server_cookies %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n{% endif %}\n\n{% if varnish_cache_diagnostics_enabled %}\n if (bereq.http.Cookie) {\n set beresp.http.X-Cacheable = \"NO:Cookie in Request\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO:Set-Cookie in Response\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.X-No-Cache) {\n set beresp.http.X-Cacheable = \"NO:X-No-Cache\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.ttl <= 0s) {\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n{% endif %}\n\n set beresp.grace = {{ varnish_grace_period }};\n}\n\n###\n# vcl_deliver\n# Called before a cached object is delivered to the client.\n###\n# The vcl_deliver subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Deliver the object to the client.\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n###\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"8662a84b03193f704a7df028e6038e941709fa86","subject":"removed bad code in varnish: https:\/\/serverfault.com\/questions\/779038\/varnish-purge-hard-refresh-on-browser?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa","message":"removed bad code in varnish: https:\/\/serverfault.com\/questions\/779038\/varnish-purge-hard-refresh-on-browser?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa\n","repos":"cristianocasella\/cristianocasella.com,cristianocasella\/cristianocasella.com","old_file":"varnish\/varnish.vcl","new_file":"varnish\/varnish.vcl","new_contents":"","old_contents":"","returncode":128,"stderr":"remote: Support for password authentication was removed on August 13, 2021.\nremote: Please see https:\/\/docs.github.com\/en\/get-started\/getting-started-with-git\/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.\nfatal: Authentication failed for 'https:\/\/github.com\/cristianocasella\/cristianocasella.com.git\/'\n","license":"mit","lang":"VCL"} {"commit":"3d852613c250e2ea7598fef1ad391b33e2322285","subject":"Add vcl_error function used with fastly","message":"Add vcl_error function used with fastly\n\nThis doesn't really belong here (not used by our varnish module).\n","repos":"holderdeord\/hdo-puppet,holderdeord\/hdo-puppet,holderdeord\/hdo-puppet,holderdeord\/hdo-puppet,holderdeord\/hdo-puppet","old_file":"modules\/varnish\/templates\/fastly.vcl_error.vcl","new_file":"modules\/varnish\/templates\/fastly.vcl_error.vcl","new_contents":"sub vcl_error {\n if (obj.status == 801) {\n set obj.status = 301;\n set obj.response = \"Moved Permanently\";\n set obj.http.Location = \"https:\/\/\" req.http.host req.url;\n synthetic {\"\"};\n return (deliver);\n }\n\n if (req.http.Fastly-Restart-On-Error) {\n if (obj.status == 503 && req.restarts == 0) {\n restart;\n }\n }\n\n#--FASTLY ERROR START\n {\n if (obj.status == 550) {\n return(deliver);\n }\n }\n#--FASTLY ERROR END\n\n #\n # error response if all else fails\n #\n\n set obj.http.Content-Type = \"text\/html; charset=utf-8\";\n set obj.http.Retry-After = \"5\";\n\n if (req.url ~ \"widget\") {\n # no HTML response for widgets\n synthetic {\"\"};\n } else {\n\n synthetic {\"\n <!DOCTYPE html>\n <html>\n <head>\n <meta http-equiv='Content-Type' content='text\/html; charset=UTF-8' \/>\n <title>Holder de ord<\/title>\n <meta name='title' content='Holder de ord' \/>\n <meta property='og:description' content='Holder de ord er en politisk uavhengig organisasjon som kartlegger norske politiske partiers l\u00f8fter og sammenligner disse med hva de gj\u00f8r p\u00e5 storting og i regjering.' \/>\n <style type='text\/css' media='screen'>\n body{-webkit-font-smoothing:antialiased !important;}html body{margin:0;}#container{position:relative;}#logo{margin-left:auto;margin-right:auto;position:relative;width:300px;padding-bottom:20px;}.information{font-family:Verdana;font-size:16px;font-weight:100;color:#111;text-align:center;position:absolute;top:40%;left:50%;height:30%;width:50%;margin:-15% 0 0 -25%;}\n <\/style>\n <\/head>\n <body>\n <div class='container'>\n <div class='information'>\n <div id='logo'><a href='http:\/\/www.holderdeord.no'><img alt='Holder de ord - Bringer politikken til folket' src='data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAASwAAAC9CAYAAAAJMEAnAAAEJGlDQ1BJQ0MgUHJvZmlsZQAAOBGFVd9v21QUPolvUqQWPyBYR4eKxa9VU1u5GxqtxgZJk6XtShal6dgqJOQ6N4mpGwfb6baqT3uBNwb8AUDZAw9IPCENBmJ72fbAtElThyqqSUh76MQPISbtBVXhu3ZiJ1PEXPX6yznfOec7517bRD1fabWaGVWIlquunc8klZOnFpSeTYrSs9RLA9Sr6U4tkcvNEi7BFffO6+EdigjL7ZHu\/k72I796i9zRiSJPwG4VHX0Z+AxRzNRrtksUvwf7+Gm3BtzzHPDTNgQCqwKXfZwSeNHHJz1OIT8JjtAq6xWtCLwGPLzYZi+3YV8DGMiT4VVuG7oiZpGzrZJhcs\/hL49xtzH\/Dy6bdfTsXYNY+5yluWO4D4neK\/ZUvok\/17X0HPBLsF+vuUlhfwX4j\/rSfAJ4H1H0qZJ9dN7nR19frRTeBt4Fe9FwpwtN+2p1MXscGLHR9SXrmMgjONd1ZxKzpBeA71b4tNhj6JGoyFNp4GHgwUp9qplfmnFW5oTdy7NamcwCI49kv6fN5IAHgD+0rbyoBc3SOjczohbyS1drbq6pQdqumllRC\/0ymTtej8gpbbuVwpQfyw66dqEZyxZKxtHpJn+tZnpnEdrYBbueF9qQn93S7HQGGHnYP7w6L+YGHNtd1FJitqPAR+hERCNOFi1i1alKO6RQnjKUxL1GNjwlMsiEhcPLYTEiT9ISbN15OY\/jx4SMshe9LaJRpTvHr3C\/ybFYP1PZAfwfYrPsMBtnE6SwN9ib7AhLwTrBDgUKcm06FSrTfSj187xPdVQWOk5Q8vxAfSiIUc7Z7xr6zY\/+hpqwSyv0I0\/QMTRb7RMgBxNodTfSPqdraz\/sDjzKBrv4zu2+a2t0\/HHzjd2Lbcc2sG7GtsL42K+xLfxtUgI7YHqKlqHK8HbCCXgjHT1cAdMlDetv4FnQ2lLasaOl6vmB0CMmwT\/IPszSueHQqv6i\/qluqF+oF9TfO2qEGTumJH0qfSv9KH0nfS\/9TIp0Wboi\/SRdlb6RLgU5u++9nyXYe69fYRPdil1o1WufNSdTTsp75BfllPy8\/LI8G7AUuV8ek6fkvfDsCfbNDP0dvRh0CrNqTbV7LfEEGDQPJQadBtfGVMWEq3QWWdufk6ZSNsjG2PQjp3ZcnOWWing6noonSInvi0\/Ex+IzAreevPhe+CawpgP1\/pMTMDo64G0sTCXIM+KdOnFWRfQKdJvQzV1+Bt8OokmrdtY2yhVX2a+qrykJfMq4Ml3VR4cVzTQVz+UoNne4vcKLoyS+gyKO6EHe+75Fdt0Mbe5bRIf\/wjvrVmhbqBN97RD1vxrahvBOfOYzoosH9bq94uejSOQGkVM6sN\/7HelL4t10t9F4gPdVzydEOx83Gv+uNxo7XyL\/FtFl8z9ZAHF4bBsrEwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAXFpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IlhNUCBDb3JlIDQuNC4wIj4KICAgPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4KICAgICAgPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIKICAgICAgICAgICAgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIj4KICAgICAgICAgPHhtcDpDcmVhdG9yVG9vbD5BZG9iZSBQaG90b3Nob3AgQ1M1IE1hY2ludG9zaDwveG1wOkNyZWF0b3JUb29sPgogICAgICA8L3JkZjpEZXNjcmlwdGlvbj4KICAgPC9yZGY6UkRGPgo8L3g6eG1wbWV0YT4KJMk4MgAAQABJREFUeAHsvQmAXEd17l\/3dvcsWmzLsrzgRaPFtjbbITZgCMRjICSQAC+ABAmQsATvxiwJj38WyyYkL3\/AYGxLtpU4bEkIEiRAgLBG4zzALHLAWJstjUbyJtuyvEmzdt973+87dW9PjzQz6pnukWbkLmn67lWnTp3z1alTW5AkibvgggsKTz\/99KzWOA7CMEzi9BhFUVgcaCqd98j9T61NksgdhvD8efOOKzrXksvl4srkREvLwMCzGx5+uKfy\/kScB9d35N2SPUmyfHk5z8HNNx\/jguAsF+aXuSRZ4hJ3pgv4S9xcjjM4Oo6OZ928t5PrbVxv47jFhclGl8\/fn1xyyTMZvcG6dTk3Z06QtLeXsnv1PAaEpUuXTi90d+efpUyzuI+hbHU9a9asng0bNsDqIxvOWbjw9GLRnREELoHkGHEUF8cdciGSEgS9+WLY4\/LR\/ub+\/n3DyQxpheeff37u7rvvjtCBIbI27sSH+fC8k0+eHra2FirLYJjXJuxWVt6tra29GzduHKg2IWHCvn37ji0MDOT70MUMG6r9vvI94UlpoLmUzEgGZsyY0Tec3F0cXJx3rsOtT5JR9SEQYC1esOCcIHarkOpjkJZ+boUIUIQIzUADd4Y5d8XGzs4HVMgTUbhZvCL6sbYHPgYdr4GOpzmGWcaDJJgehMH1m3ZsW6t72TfZ83ocDUQ2bw6SlSuNacH114eAyvkuCn4LNXoFf893hcIs19TkkyvyGtrm4gp5DyG5UOAP\/isMICMDxaf59peA2X+5IPmuO\/HEDRkYkgbguGQIOPoPx\/eb8eXMM888plBMbiC9c5Mk2E95hqQPAAfT4Gsff3+9def29byfo0zLwDy+VMf2FWkaKJFusqRt4V\/Am5XQJmUaoGBz0DbugEBHxIcMBz0k8hTy+xiR7eTe\/S52m6I4v+W+B+97uDIBKWc9gUv5U96UBvn7aBIkr4Lv3Vwm0GR5r0x\/gs6pApIS+N9K\/H1BEv\/d5l07vrcC\/o5mfIgXApSlc89cGofJDUHizuB7dDEpQPn4igYiAhdQvkkPEVBpB7vhUCd82RwXC5sqyyMti1LGvwN5Y1oFCh0HNrwsDzJZFYfOid9YOa4Ylc4oxtG09MOJYrbFu+\/8fYHbGzy\/KZ8\/m3qSJNPkOOSC0JVKJTEvC3WlJVizpoAFZBaHAdXxc17pZp\/4dorod930abPEcgMnAVSxCJjzj1KAGIHqIC1i3EB\/7Pr70+dBDoA7DhBrh6ntrqfnA+7xJ74V3HLrP7m9j3+vDI4V6WcZHM9xeUpLvjdfSPIDr2jKF+ZFUWzkizQsaCvjOIk\/q\/jbXbv0q6xg40mzlm9IeUYY5grQpr\/pJtq1RegLQyUiNUnjUt5RwIEwLG1d0rbghzz73kDO\/Xj79u2PZzV+pqy1JJ9+q2RNufl5MWXwAqyMOkQ7tijK5R2T9zj+F3294\/zzJa8jVlB9fX3GsjhwxyCvFxXyhZZSHJn+jQ+tSI0PfRUlCnyw8oiTUpgvbV7ctvC7vPFvW3Zuu0tlYQI5QkVqgJUkuSJZeiaJo2OJboCaiDYE6Jy4Fojem8POzhI6DMdnBFYwuJ9M5JA4SMNOCJM8J70V6Y+bfxVxSKADd31HLlmZgtXq1S8AqN7LO292M2cUXD8VQ2+PpE08UGFjqTjRNRgqz60STZ+LQqDAFQdi+9N3Aq\/mpj90+\/avcLPnrAtuvvWm5OrLfyKwNGtr5cqIz2rOWy7Yj6nRtLcURfMQjn54iOWSFKmQVOMOIBR9gxk4omcDUuY0wwP4IySTNecfqPJslPyo6nAuj9I0hUHuXOq+c6M4vqIpSn6KsqxLXOnftu7c2SVluTgI8h3YzPCsLghD8k9TBjIAVBmKFsnQYBiv1TIYw\/Bn5Dkrb45Y1L68Z86cWRVvKZNSGAZ7AatTKZMe2hLNnqfDJzeWu9Aj\/Mohg3kqq3M5P7cUx++hIvknNOTT8Gob8dGyP9j6TwHLAFAFqpLKQ1iouknXZDRXB\/mpPj+gJ2YA6SJgZEoljdaLFGhTe6t+wSwpopOVg4U1zQ2UAKrgTwGq2a4Pfd6\/v2gCRlOYt2jnlQMaJoEO+ZOVf2CQssR8o+9MQOGhQIz7AwORgVc+X3CtrX\/g9u\/7neCW1Te4vpk3Qke3aCJCNUtrVhhKMOf5lhQ4+jKlXLGuVO7D0H1gPib+mqZbKGmDnypqCbEVvk\/ZdMt+xkYJ4nJQ7igwajyaRj6+wOVzYe5FJPuiKMn9yZJ5C27rD91nO5PE\/IxyT6xP1o\/qT6mKJpROpJA3KlxjegVlFadVRTaGl4gaN4ppDlku0O4fU2KFfIJDEVCBkcBLpos+BygFeYl4dsiyETilVEuHQ4GK6BJHVCsEcSwfIoZ\/eCx\/V0Zx9Kql8878s01d277G\/YNAywBrODb4hCAWxMpSHO69qXovWIHTe9114lkSrFp1Frz8OADyOmXYgErMTZza7QQrF5USAgy3wzDv8oWQNjNSIVyq4JC+F5apSVvidczeNAIAK6HABML8RaUIsIpdczPNzfCjuDguDG655c8Aqq1KUf60zM+l69pDBY1EX3t8kzMGcV8FgFoI8FVwsjSkePLLivd2m2KKsbJk+uRxfSzieGNzFP8eFtfKLTu3\/1hgdfHFgNb6OoCWkiR4pg+yHrqk9LLcB2\/am\/X5If4S+ZWOF2M6NMYR6wF0pZcwEqlXJXzIQP48y3nTAEgtFX8TA8kqJ1VXlFiCQqAYudyZlMvapW0LLt+0s\/MfU9Aq+85lAQwbiNOKdtiHU\/xmsGJFLlm7XMie0CR7Gdj0VTdj5utcH63Q\/n5ZVbKmsmYf5S6HIWxuaSm46TPy5lQfKA643r5H8EltdN37f+p6un\/kj1z39T2Mn6sfUHNu+vS8fWdOb+KxBq4xUMpDk5P0+mjpzpjxe9DxNUCrXU8FVtYJYK8+F38oGylGiPdyDH9YTaEQKBeGBUw3moBBwRSD6gMu0izzVTDy7SskbtL8UVNZyvJKlOfrS9rO\/BNxXGAl0NJ5fYNUy8wK0dkkWiforxVeOOJuATbkCnD0\/B0AQqPmbBgM4Jb\/r0NVf8In1RZpuTRRHgWLwgwApQ9JPCa2HGDVr3IDXVfRRPzdlDo+IQLCBBRGmsQkPajJlaxdq1rNBTevfhWM+rybNuMkt+9ZCbRM1tSqsgx48JrW0oSlBJj1PcHdDfz9DHm7l0ZrF9Kue\/vpFSwBUoBZfrrri+ZQQm2uVFyGA\/6FxHkBltSJLsw14Q\/jdRSnbL0BWgKxfc\/GgOFZAN+6YNVt70yuvOwbGWjV19JS8pM4SAtgrgSU0234Vb+HkY+BkOSNT6ORbhV\/MI33jiGO2bx6EqV8CgozE8zLUz9RjPx44KKc0QFzpzg5\/GVxyW8zm3f+fvG8Bc\/b0tX5kQy06mlppQpKayh5iDbRIxBE9pRfy\/xoORzDM3IdJLiD41Zy2QtrHtHHM++uzoeVJmQgkSUKfTHAozEy+yD1RprX9yPnMxi1YPqUvTfkGLjmxEWMPghOgNen8t1CmL6IioXeajzT1gJR2ZKUQClJAKu4SOXRAvGfOPv0s39J2TzMI1l00XMKsMxntXKlSUVwy20vB6z+yU2bPsd1dxdhlniRFRC8xGfd3FyQP8319HVicP4bf19306ZtSN7xjtEc1nuJ5wH+7ubvK4zfanZB069jSb2W6zcQ59kUmiwrmetqIvo\/uZi6uweI\/wRA6wuA6ZuTq6\/4rluxIg6uuy6sh0+L9KdA8IhCLYt6RD\/dvLPzyrESra77bW1tM\/vC8ERa5\/PpFz2vFAcvIZ4XoyhzUJgC5rWag9IRayaiULK4UJZEHRJNXF+\/dN6C3KauzpUGWsjH+kOMEaqOTp+odJP0PxM3Fz5O73drfgCnZn5AVn8mg9VFN8pbpEF0HvufLg08q1dr8cvBEyoODW2Ke+iWu2PTjh27Rkl+2EdL2tpOwVV5fpREbwCkl1NBzIhwqoJU+k8SRnSojhgsw0WMrrqGiD5EPuTPMiUdNuKj7SZSEDDeSbV2HNx8+3mAz2dorgFWPSlYlQVFtUUIkOVdb+8+pOoOCmdNcsUVWzKeWFxr1gyC\/e7dg1XjKVToWbjkklJy9dW0M91d+gtuuv0zANW7UYxLAKZZNCf1ptKj9rD0m7gHaE0\/DtC6A9\/a6ymo\/wFoJd6ifTAdfXmUBzJb9pNIWKV91WQ5HWf0NO\/q737+vq0hC91PPP0C+p\/fzPUf0DyZg0XFqZqJ5gLQuUITyQygOU2w\/Fqc8U9u7ur89HrAChJqHrOmDEhA9Mc4pL1bt25FxrBYDkMYCw+HI4daHBkEVwTuERaTc7vmzZvX0razreTah\/vCuTkdHck6skowZm\/euXM3b35Df4vmn\/lVTN5PAkwLKAuBlpgi1FIlUiIpOiqSNy2ZP3\/VZg+OOI+fK2HdutCaWKtWzQbFb6X5dQY+J5gi0K4AK9W4LS1YVd3\/g1j9ZXLV5f+ZsQjgQIhpvl13nWpCCfqoQQISrF2bc5s3M2xi5UDy3kvVXfthrLtvA0wfca0tL2PYBIPfYiscL8VOzcYiPq3TsLhWB7fd9jq+fZy08y4d0DpqokfRQ7Evyw6j0uWkVbO9fC97lh4zLNBl0N7eHmT+mnRQqMrrx\/rDsf4lmhsfJL438FfAqqKJroGRRO1jaUJRBmj+NNFk+ZtF8xbet7Vr+7cZ41bXQFLmV4KGcOHChYXTtp8W2VjEOqWiIQzigY4dHR1qDY\/H8T4cNYlmFOiBwOpQVhv5s8Drml0QaqyXRt1v3bHt68vmLniSpvE6eghPBrO8pZWWA\/TK4JoHSr6cbz8j\/j8nAGtIj1sSXIdl9WIACXmhphhUAHovGDnbhKO8t\/crdOC8D+voIZ6rx67JLV9eFOjoGuCww6F+YLjEXwVLbxCKtm5dAdAcSK66rAPr6fdx8n8CB\/476K\/Ku1I0CFoql\/3d+LSmvwg6r+P7K0i7NCQf3DzqA6iR5RHQkcLpunwve1ZxHPGZmombly7NSVHUC8iwhZ89OvcBjbe7Frf+sbRKaKLjS8lAC0tLzUN8KdNpmn5k0RmLfrU1SR6p4+BSTGbv+yFbamoVtyXb6gUoFSyZ4NP2Q8eflpteNF3QScbHjbs6f7h47sK\/RT9uggfWG8i5xoGim95Zz8DEC\/nkM7KcpbBHdTCgWL7cBCG4adXrYcJVNMuUZ93L8u\/BSlNq+gf+0cWltwqsNPo9BYkBNGFEZaiGgfpeYCU\/miy15Mor9+JYfyfjsm42P1kuJ6eyLAgFrGKuNBYsCC7Hn\/UG3TQLUdOFGmHMHJCwC6ykFMuWLWuSVbBlZ+cnaZK8jebIQ9TwVN5YcFkpIzgoWh5LjDERuReEuZJ8KS4diV1uqo6ZkMoP1L4aDJXng3eP0jM\/SPdiM5jyuZjiSbapJ9GCLCuBllmEpgqL5tH01LOjX\/jVFET2ghtvPA6\/9l8y1gqcN3NWzm6eGHDlGH2uIQ1fck8sulR+JznLNfpcIGFMrNMPllIsS82c8Ur+qsvfy0DS25kcTWmYT9GnZ2O1sLrUPA2DP8ciU6+XwtFfZj6fE\/IrJRBwqYZXAlt2dX4D+fgjWiOP4ADGwjKfltBKzRFkRM1QSZB7N82Xl+obNWt0bITaODDHdVj1cO+OHY9RLj8z69ZHKeZTFBo7Ztr7vOl0oOjRUc14WTNlwMk3v50eugvMavE1m4crcaEFEOvtvQv+XJmsbFfTqyl1luvphAQDRTU1FWJ6Qvr7v+ma00pEICrqNNCxp5dJES3nA7lv06vWNGQcmc4bYfwcyKbhAEqBTQJPgvfR5uznUkAm36bpCvpSwMdSYsDUbNr171KK2bfjT73xpTiAM74cAKedwia4bgaGPTAvPGdBMpN5gsx3PsoBy23aJLV3wQ03nIAAvscLIY5HpFL3YRBDF5pCBm7uZRLCB9RMs0nQNN3s+QT\/WBOxDI7Rn+Js7wKcRJv3ZQhYtWqGD+8JPv0PJ9np8nq7f9MUnmOH9fT8yZmvbG\/atW0dRtUNXmDoncoc1LqB4hBUGK9d3Hbmi\/X+vvPP9zKki0aonQOJY9iFEOtgtsL5MIhCs4iPWgvLrKt0gKhrnvZahjGfwzIvMNasUHElsik2CCLhpuTyy3\/CzcAxFEE3DltYscImPSdXXcWUnOBjDDTF5U770HfrigwWS+FeU\/NSly\/ZyN+GL6t+pSNrST4txdiUd5\/GmrqLbnbVaVnTHJHBl0WbET8XXfkJMxLKvqyjVn+Ux8MagnRoianjQSkn+LesEj96Gb5piUG1gAvpe5NNp6GP2qwrD1JIKHI6ULzHtTTdYixK\/V0HsWsCb1jVzXpYlsRJJ\/wjoyXXW0+lrF+PreSDQY7ycSXJm2QBpuQcvWU3gfweLupNmzZpSZPcPSw1Q9P7Vo3PgulMH4HvFniKL8tX\/smr6DF8nm6zQKJZZ\/6dxu9YOVDZTkDUT1bdLCEvxyOjloCB2xtEiY1VOyqFXtLllm72GZ8z51xA4CU2EVl2vfKvZlbIJKsSFlcQ\/GPy7nc\/acCW9iaWGXaYTsxi6ujIq4mIwvwDfqsYgKVsNHFaI4ChmKmL\/L6E6T\/npGSpK9wK9DCRedQmo0ojc6SHcd83yeidWFOq23zTnBu8ksP60r3zgmDgfDFjzqY55ee6boTxccAs3MAt09coqAZFmveKCsNOOTySK07XgNOj1Ol+3XWDy7NE7qW2BpUf56Y8+6AVQUul7S5p+rLdwN8lZmWPD\/txzx6fdlLSKOANZlEJkHRXEKuVH5qaj2V4ym+INvU2MoC1AVhiRh0C47w0kj3Y+OCDTwJOX8cBr1hlZRkoweiQsVrMpQuZTB2+UA81NIJPjspKX\/mrKnRU9dZBL4nXe1y7yW9pX98LqBEuzNyGqhXEdw6aASLY+tU9j97TrUhGNGnL6MZLuYgxQgRG4+bpDg6rXQRM31QTiFe9XlHTY4\/le3JM46onbIQMOtMyMPJfwQHiltPd97Kx6mRy5bseMRrXrj2yteXgnMFnGQn\/PYZeMGmagax0IUI4zUMUh64qClBO35uNZqYa2bHxUzMHZGWlvixGuMc\/Aq8eA5xOQii06omZWzBbzUKVwa9prfZ7Hn20G8tMsjQ+2amAuuXON5AQ0bqWqfJVM3PqHIGASFiyftt69crmFs+d\/+dYtC1+eg6VM4E6WksEhdxTs\/x7uqfBvyMCFi9bRsE6FLz0pD7Ytm0b3t8JCebo\/vGDD\/ayBjaD++qTRnDjZ1maOFiaNosZuGwWpRRfY66EyT9QStYcTCdF1yflscciwYIOL\/xBdKcbSN6HZTgdJ7wahOIIUItesLdEcMOaE5IPXqJVIhqhjhxoaWnxMl8qbUvyzVtQppPUFky5Ly3yohS4s4rTp8uPtS1bUrhWMva4PXWS+lopqep7FvfLG9w+tPAhLbqYVPqjshg0bEH3zZJq93eZIiRRFwhFWroHsLqR9YNek1q0km+MCjFdXYPUE0nws0Lf\/m\/ra81JHBGwpM2+pFxznOQuXDR\/\/la6Fmdk3nqffH1+IVYeg75SPp7GSmsnGLnjjJr8BjSV\/NeF7lOx5E8zRUffTeIkFgKsUvFhXES\/9C8KDeyF7PLIHDPne7HILjvNDzBdfbHXkpQcNWsTd5prdqdw5wnmKPqp+LUw7MjkdFKmquk\/IkzNQiY9b+G0HdbaiqFpOaA\/Jkcn02BBtty2DOT0XZUhFUTMstgxlcGHbD4e6el5XYN0oh7xyoiR+oAotI1ja6KNx4iBnHDJGfMvJrIPcPoaZZk\/s6gs43RwgIYFmuDIe3CrLFm+scp8RMCCMM1MJyIAJEjWBHFITwrr10yAYhOvxIDVu4wjs4S2Sn9cpca3hLTQ88+jo+c4pl\/AZSVhyci855Wgi5+H9PKkCQCQaEne977dbFKxAxoXwwjxgYLg168uwAC6WLX7vQCzFRDnjVAfDlhHhpQbMdpucoiicIEypfPbrIS0QYOVgdPE6rEkrXhUlipQaunfp0VxImKp9aBkTvBEsllbMEBJbACslPir0P9DgYTyUUvM0IwCQV8CeCTB8+bNm7erOYqOLzU1jTgUSNuDBVFhepwvzeZU62EtXTx3wW8AVi\/FgpopUIIurbxqC2b6c8d+OCzKG8df2rxr2xdSmnmkyZ4jBhFmi+nksKpgql6snZnDJ5fFq\/XGVZpWcNnN4T8Z6S5LsZQVOYlZSE9z9ExCVEFwYs1Cfb1rokezj0TiiPeHNksf9P5eM5HVzy45pN7BFC+W5igOFeBkaM6OmJ8p9kD8TFcYLaHdDzL0KkKprGaH+6HXVgSIIkHNsjIog1x12fVibWUXBO20e9oNBOz2+ES+Ml3FICnXWDIFlP5RDj9sd+26URNgEbdAT9EeBzNua01y+1m2IcfiYrp3UOB92n4ComgakD+T62MBzmb+DLBZv130qJWg5WQkz7KytFwsLtz4f6Io90FFKt8Vz6xiGAWw9Kopi0Yvka6inPgAYdoEQ3wfdyAOT2sQHGsTi71lAkeIMt3wgPPHx53ABH5Ixs0M5LA3tQxJzfLjS0CdUkEwcwJJeE5HvWfPHtP0OMztwX37LJI4S7pUZopkC5Sh7tAOU1mQvA6+k90d\/ahylpKO\/tYYn1psFqm13hAV21NgjLGM9LrHAyLNA+RnVa2mps2+kSDSVBEAUrJatTpGOt6QyleSjX6yU889IM47tF+hwIxvylbsIQBLhEOkrbfMaX15OyxXlFjdQhwVbHhAOUJlAHmUkASBFnebXEE4raEK3tLSGk3QCYllvhvdXMfTy4SnA2TL142TunAAtsu\/dGAnk0DGrF0Ua7AMfCmNMV3qHwOW2qyeYRJFxwM2UE1s9D76VJNVdXD8BlpOK7YSd1kyD36v4k6FsUOWZTLIauWPM4vBozbOd9pA8c\/yQfK6ex\/c8Vg6QX1Ic7MKwCJqz1lFXR2BFbSO9ZQsmAkx1u+GfZ9m+7D3ddM3D0d8fMQfWD0\/EhUV+0RmA2RHerVxf1wcoJ5Hi4YtBDNdRno4lsSQdSnUsImMJZ7KdxUnIT34i\/r\/AlW2A5Gp18g6liXs34AmmSMpaUO\/0k0wlpuJOz0Kwt\/m+vOaNgX4ij\/lt0cHLIvGox\/jJMC\/NLGMkAk4Yi6m+FiHxALXa36fMtmeL+I2fKs06ScgJ+OI0rPaF452QVZdVDaGFR\/XVqjx\/nHE3vhkDBygZ1xO4APBRGWDH8dKgmU0agmKxGtjLbEM9y0xM7hVsi5xiWXN1D+kRgwARGfBIaIX16TVJrwGPl4DjY362CJgqAQL9IXhKbz2OTYBadMmIHwlH6F8Z2Ypjg5YSsO4ipMxTh5mN4sOou7HS0ZBGhWHoLS6x4bXWuDfL+1xMQSeTtKWdnUxVLxFcwoaUz9QvNcU3vymaXRZtLGz+WAVX06KU6j0jE3Y8cXYTDnJK2vlyo+GNkzG5uyk4F7tRJSHKYTxDHrGp3lzKuU\/0SObFIIVkc1tS1P0ZTam5K1JSOHWt8kGKIjCImJuaxWh7kOaVGMiccSXiZ1UNABrxFfSB2KMfwtzBymW+gl7pN+c4sfyriu9TmRMf4ojOgxyKPD1i+cvfHTLju1r7Blf65NRAEvxEQm1PF73u2HrOzY\/0LlR9yYqQFO4pG3+V+mYOT2mm0AZGFda6in0fqBH4Uw3lsp0b6mIdYbUqjnna7dnFumznSDGlU69P0rptiWZg+AMK2k\/Mt+kW5t7s5Sy9ja0DgMyk+Wz3pQ8Z+Obn47FCqLcSdhSM5Af2A0IwGrpmnguVeNkj5gkmeVgulId0\/iYjwjyht3Bh5\/lrxkTQr3xGBkGkdVFNcxbxIqoa\/yRlhjGq10I7tOxw3UMsdV1bzyBnAsRRb2c59\/k5BskVWLAgyzSoXzwcwSKeNVb+OoEPpkLaefAgXPpXGxVXjXdyX8mFhuiMQVK6+mzN2ESXb94wYK7eO9e9RTy\/QjbfIka1puGrDxgJQfe\/9kywWBFikLdePG8haOhqF4bNcAxEyp7KQge4upxegrnSbfFaw4YiqrY3AKWJ17Ae\/fqXZUB6Q9luEVyGH+yqTa7n5yLssyXskA01ZFNocKlYmW2l\/mEfjoRAGdzCg8jiUdzUqkMeMUOkjYbvqAJz\/Izeckw8wVF7UWmrAza29vDsexZqGikXvrjZ+Pmru0\/1ulEhvrJthQIZgAs8OCO3iC+qqurqzz4tZo8LFiw4NjmOFzMcIs3AVTvxJo6nrhgC8Ju9YLpYR6wYjR57mRGPvwZ8f6RlrgmH6PvmgNd6ll\/LBcF94iYedrSp40tfTp0Vb+g4f0aMXv66ae3zsw15bxs1CH+JUt2u41bOg2wBFXAO4zxzSrtTxe7F5OKAZYHhzqkWUsUmzebHDPN9gVEc5o1\/8rxQbemEgauy+Ujm7mubcvKjxsnNXOg3bWrRiixQUXetbmlKIhEht5aPwiTa6wB1fTBbuz\/B5VgNgxiPIlTotZs07dKs15W0IG01Ksihl5N\/taqFfujnLu9q7Orb6xg2NnZ+Qz0\/UR\/bD7xRfYkvAnQekklaAmYeM7kX3YyYv2xZQsWvGBjZ+fPl8P44ZuEUGZGL9ohMI2avHm5c+fOARDVnF8HMqWWawmCvmdCZPGxrgdIvT4haWe5401bfkFmXkmMADrWihyp8gNprfS+6NXcXyMr5UgPwDTVGNzG65XQF7LTtMiWUxOeUBJWju4X7JHYcLrXR0SGxLJnqR+D9UjbTmbjh7+e2ttmYqkEFAzDnLuvaUaTAVbZ5+Uf1\/QrYBEA1BTJAR\/XC6wULQIoG0jYsB9EMcsKndXW84DLIUNAhcDXwLLsIHRxy67td5932plvLuaTr+JsPx+rq9w85HkoUGCowyxajVo08eeaSygkGzaIOD2g0CoZWHk+7HfjvGnxZvvIjTOOwc9Sx7u\/Ef7IFF\/NqbSxzP1S2iy8KLjllgvsPayVegvLIEFVnPmJzy5YvXohdF5sX1hHhDVHKAVERauRxsmPyrGlU3nK142TmjjAQn7WHMwlwW8gLGem00aYKaFopfoJSydbEhvYyMIqjbFOzRlCYEXVjxrblaVSx58h6dV4ISNG2UcY2ZbQt86ev3074z9wHB36L9J8yfXItN7VGCtEOrznoW0PEeO1gBWzCmwcEslIVW1UvSxaYdBvaAaCvhsRsCrzxse+mCpvTuJziKWP4XoDQfbI\/DmkbvcrdqaQJZ9EkUqhqXkWEP52ZUWL6IkzRyIYUG5KVx2N3Zuhtc0v2JfVttClLchK0QNsSCxzWnslanPWCpE\/EpQfPWlKgVCI6IJTT50Gd9+QTm0pZmYt99TlHjCdpBczwyqNTInqxAUvr3WKbIKjgQW4tgl72tvHRbfGWMn\/pzjwhf0Xh5+oTvZBZpKu1PKyZBY80fnQXD2rCrDSWKbkgbXSHyHP37cpOj6\/vlko60UhCd4S3LLGr+KZWjmHPaO3355P1i6P6LU8g7T\/iK4d+dlEH2ahSoyC1EpAQfL95Ko\/6Trs9B3lCUo35t8938C\/p6n1dWT31bROZFN5\/ZAe4RqRs5n\/G1wxv0EsqVuLQJE9B4OWmlG2zXHP2onW3paUpyhVNi+Yg8jkTtuA5egFrMpmYeK+wjZeJZcvNwvFp9CaWC0t7HfGjjUELJZScJi30JLvTPsfKn03UPoAu+acZU1YVTAKMpA1G7S3h7NwrW7xIGAnalMwXTdCbRyQH2ZtsjY6Z\/58lCJ5H7NvpTS2zrvFDHJxbPKH4BtbHtqyV\/drag5axI2fjAPI9DNp1ZzdsqMhGrxn8qZNhTpqActQmk0lLNfNuTvB7fWu0CQAEBDoV13VJSdDJnBvDW5Z\/WZ7ly20zAFvFxP7Y8DjLjIag1W3\/R41zHusWRqzbbpZV6nLoLlZhHyH5m2HTmjuqic1LUu70\/gZJwfUFMzWdCrFwYfCIPci22dXYxTFYUkLTmV6x3B7JtsjF31dSWl1UgCsUWmIGXUI2K448Y3h4vjQoOFVaY\/qUQtYluNsgTtZMEl4u22X5Z0TmaDlWSudvQlbZHr9TXDT7WeaL4uP1UwYyrX6XhlYrVmTt41b5Wh3ycfY0HUaY8OEoLT\/CKrSqe6xruRsX22br4qulSvNOVxfip57sQms5EtRzhlVfQlK8wGPQRod7svfQClx1HQUR5D8031dXVt1joNelUoj1IkDjI8ecQA3ZVBgfSx2Oz7KfVjmlF671oPy3se+RhX5n7bLs8+3t7WQTJpgCVvYL2D802ptaW\/fLU+\/q1OBVEZjFlxHR05NweDWW2cxQeF20l\/Mhq7ev+ahUtVN7FoZfpEkX3TvvfIbFsd11zWsq0pmjuMczA8rwWpp24K3MuT6Uzarw+8H6SsM1Sp4l9UiZyDjL\/O54B+VXOqgzyq9cVDQ+CTlgGTcApVFr11UmgnSUG7yTKPfj37AMk7g6zE\/kcY4BfHfue7uHs1XMOvFs0tNwwSwcIDGK+k5XMP7LeYE156GdQ7EbcpgY8RWrZrNPIovkO7L8bEBTJaYH1VNj5Vrac67\/fsfA7f+D7VMop5Blp957lhXSGo92S+gskGhcDqzrJgKdiXI8w\/0ALLInHXEDDYF5ceiW5YmopxYH7t3+\/YHFQe+q4Z1Vc+CIS6kewQLyxBL\/hsDLF+T1DnxyRQd2S1P1WEr+v\/GV\/V33PqIRqTBJdWSoapR7mmRwhw2zekACN10g+tt1yM\/BjZEJMe+4gs+fevZjFyXZXWRgSWef0vfJ1aiKZhnuUhV8dcmV17lR+PTxFXwr4z\/N0UBO8xxc2qOb\/yUTPyXAph2Vtuc4zrEOoG9WUbL5s07OXbhSuTgMj\/VJAUrkSRp0FQQF9AU0fTN4JYtXdu\/qEftyMv6rIdZN2oJoc10qSWGo+Zb5sv15kYYFipBRUifG4CVlSiZTrtLw80pEEgq\/eOErYQKbFTeg5kThH+dfOhD+1KrzIQ7i2MsRxSFnjyalUttuk0MUJUtIxzsv8\/swE8AVvOxrGTfyfjVEAYFvZe3pmt3923JVZf72epYZhnY2Vvj\/TFlxKPHQD1FsaedhTXRwPFGN6HfVQCDNjqFpSoPye9IIWD6ht+lhSODMcGdQZDSR+edfN704rTuN7KDwIewqpZqcChDGARO5WYg31i5qylYiuPvFJLiSn1rzciEqTp1ClgVlZba5CyDOuX1UNFQqKYIle+hFlJb+4eGMD5ulH0JKz+c8ueMYkca4uBTn2p1Ta2X2xb1fX0SSjW\/8BshrNq2vlj6anLlpd8ysFm7Ng9ojQOwLiLaO7VyKCDFYNSKwHivReDR+ymB97jmZlbr6tVzlYhvevqlqEM3gx7c7v3fwuj73\/pczci6gJUigxHkL2TdR6uxNBdOAyDndMxJ6rnVVAVYKNWxBAESfLcND041WgEQraKwASThmf7GHM5ZuPD0qBS\/yrUE72CCyUvlrwKnFCFaYSsBqCTMsiLyIE9nBwuGbCgkuSt+tWv7U5U+rzEnfuAHyoGp4uBcQoZWaOR3CWtQ+Z+QQJnYiPQJiXx8kdpUJIpVyNQn5vvWzgGRiSN4mXX3qG8SylISeJg11dT0WgaQvsJGuSv3nhEJ4OFcT\/cuhgau1G0xkMOAzscX2sufBWxB73615TwmGqygMP7ItU472Xor+\/rVBBRQeQGVNSHgnA5Y7e++kyfvplfw2fqBlbLkd0LCstDmBBog+XmmmNSQT0U5ehD4p\/wc\/cXsqbXOqUUku869jIXc3sajz2u2fvbKoY5K85wzzjhuIJc7PRcH5xDTRXzzcubtLlDtMGhVsfAAJrWVgLHHxl4V1JEMWP2CFtsf\/2rXfTvk99qQ+N7EQ6V9qOepyAHINg3lNefOnbv6V7t2PZUNrTjU97U+H3N51Jpgld9jNfRRGCX4w27bQ4N4hgI\/NwBLKxqgMDjeP9viZofeuupVb1zqt2JhHtsGPgnuSN576bahrKr+SoIAMBbc8ce3AIqzqAvmYiE9H8F8OeDT7qZNP8bS6emR9UDENuufI5qpnqkcw9tbAM793d\/FCntncsVVj5ad7CtXVk\/IyG9a7QUvmCDPXntB8Eb23rsVt8FqTI193FcWDpSVkWMb5Uk+yueisNizZdeux4z3ipgwyidDHiGgtsIkY59YZiS5aem8BYtZNcRGl4vO7OU0WjGyhbvNZJBdWdxJi9sWnM44loVhHMynnGez0JRV3gJBwMqsWqXhZcAqKFufnHtYOTQDo3g9W85dsvHBbdu1DlOHb6ZnydZ2NC57QGamz0tKSeH2s89Y8HFmXj1WigqUCxvnTkCI46aQ+X\/PwD8b9DoBSYw3SpUnAhl1M7GgSJnIf5yFirJ+DlhYQ6yr2T2vZz2pdhvdbuxAxK0S56IU4ZdILsS3dAfLT7WqEs44VtVRrZebV8taVTsbsHKnUiecih+q2ZaEGSB6AZVPEasKtZJYJgwQRYCx8Aq2rmB3z+ddqf8a9iV8WpaVu24lbZbqFZ0YRw+kqeYPUdqyswDCZaDXHyIuT5hk1KwqAj1XjMKYbeHy3\/21trZLIehp\/E\/iDUyoNsgOYpCJ9utk5yMw48MMLPAwTwKVQQlarvSBHnCtO+KaikXsA4BUnsqd3q4EKvFB6ywVbGCoXFdJvAaf1Yd\/9eCupy7G4u0ArOpdBkaGj5SWKW63MHlNFAWPYWCQPuhq7laorUMgMrGCdKJjwkJpNVGuVLTkeUyVSB1IOSgKsUB02IM4v59e\/D4Im+YL74DXk2CG7hzdTcIh1lVwuWvGT9WL78rLNKWG8DJ8mSPWzbTX+AnSGVaJj5LxakL6rl6XeKgSLyF8fQzeDXCie2A0fUqj9M7WfMH7znp7mJYQ\/C0O9o8pNQ9W16EoK6sloBoiy++QfVkwmmJPmyg8BqPimPLDmk68JaNsFYulBX0lDcgVG\/q8UI4xbtEJjSCVMCUV7GHikImqKsbDk3E445vS1YdERS4VeELWFaHACqDy93G8b4+D5G+3dnV+Rq\/Jr7e+wumve\/UNkCVCrAyC6dAx38c\/LlaNSJoYoYzLDVAqlahIy0EJZXwq3zzg5FDPD3h9XJeW4TgsdaOOWnb6+CwWKzd4JLil8rE9GEYELArf3s8+nmpHs66y1QxO6PtflNhFjCLPsmFMsuLKwEvNRBWgf5K9V8tRciJLyvf+CbikVgLJXB6gwvLtZ7mYnp7v885Hkqsv+79KTGBlDva6NAOHlOGQnEmDpbqyYki\/XoKpNAYwaFowErpzwf6xxutprKBUoGWVgAT30IFMKV+ELA6+EpBhbGHNKiZMGEw2fqxcAIw9vP1FFmP41Naurp36VD4rLYWi84kNQmFrHlIGVeVvzOTAjzTimOktAYP9yqEqfpbfnqAT9eoqxANN+8Om0jO+VtEdkScfhfkuNbnzhPNOPnl6BWBxywcVMZLuM2ocTR8cjoOlBwVKX3ToR4Uq4iVwVdOQ9QzefHMzzZPLXAH\/UH+f+S+IS9EqkcEwttgHvxt6JgoFevqVU11HpUMzBF9ZoZCzJqIsr97S3WTp791JJ3yG6UCGpOmSMXVUlMEyhQwtjlaZY6OcG7p30P2h2RrDFTqYRlZVnIikb+tR0nxZpMS1ka64VhGqimrwffE9DRQAbaxAq+HnjTLDP4YyJMkDyMA34codWkhOr\/NcIAYJNiYrjaHmg9HCjx0rSCtHTO6UwTFmsvz5qCfkP+WFCXj1aQgrVDL+C5PjwXJJoxw15eoeUltYCoVZhWfj7tJj6aWIRl5pANhQFq0Xn5zaP23aaRWA5RPwRPF6mbNZhqsjoNa3ZOZY1Uf6pGyc4UfHqplt1lXWMxjksK7oJZJ1pfgEHuVCHEKtSrTqNIZ8OfRCPhIyQTJaNFBHXauJONCvGek\/h54vQ8Xa5PLLntKn1gRknFY2j3FodDVdGf9UpmQ9QwG7VxFrPfJs0Y0nIuy7gsY7CaMo8GYktIK08Zzyvf\/Px9mJd3IDUntI5F508buRi7+WzQtUKukI+Pr6qw4m3+SYnwkrg4OTrOlOBZ2IkECMAFfL5wx2qynMSXmh3urFbQvvI\/LfSiNM2eRdbaR+Wi525xpghXGUZ8+OGSz6TnnG3EOAWE9Z7d5ilBzHeBXDkJooq\/rjYIYJcMR6zqnbQZ9aV3NcYmJdOcC3kYOqyeCOO2gPB3\/pjsMPrgnEGhxoCnGwpTFyTGN8gkvMHOjMqWYRvj4GR1BrJPeT7k\/BjB+4pvBH2XIyB45+H2NKo74eJTPIafEYdYLiN07L1D4ZlW+jRlrFQ2CnWWmy0N3MYjxNgjRqSGtQWCS+qdBqQyzkV3YBbe2gG\/2iQkh2w\/f7if2eXBj\/rD+fu2fbtu0890G+KtZlElDV0bLNYueYJMiz1KxCmLmoeGOiTy0trz+xDb5ME9R92DJ8iGxF0fg4lSUdq82aGEJeDBNKYAKdBIYdrn3476u9u66SBtYaU+lrDBzlAZe4SNjBmiPdt7liqfRmSzQu0EMRu8+VotIMXhngBTll1f09HXx7GJKfSQkYMYPVEjjCexavBgdubFvw7WKx2M2NZzMTnW8Cds9Q1\/XGiu+HpYVvvG2mF3sjnIzBve7JJ+8j55hYQ4SmIqoaT2WNeuNZNHUjjk9yfASrtgtr6n6c+dszkFJKZaDSKqd1DpkA5AZy\/XFh4CvFqLQI4nqwsiSg+pvQIMUfiAdmUVY\/LxQLtH2dm7NpU9aTYWnzTrl3iE66\/2CUxePgPE5wdVBoFdzMGBwLqaQoR3oYIDvxU4ypeyKKw8dmlvY\/uuHhh4fMU5Nctbv2gIGUEwVUZdlELL4zEJXgv8tomPAyOIBrRgvzIafD2B9WPCvTWHGPsppjZZWP3eOlXPB5aNfGpvvgmZYoFiZM48PHg1z8hL7LFuGrjGMs58Spzg9vRrnoTsDwMzBIDvZ+4ZDFpZcEXGz+oRfHEv+UejdYwTLCrOQ5GYi2Zuopp+Tc7t0RTvUhCjwZ6DsSNAwK6sSnfrEG5ba3S8GQfY1faISpyIGjGrCOVIFIEZ2WtXnqqdCddVbi7rwzZlApenIU1w7jZDasCrF2fE06zjiGfNY+uHTxzJkzk9QCEEgdvTXzEAYc3RdlwJLgjJRVyvqw1Uim7CM3XSR3VQuexXXddYfXBGdpZrW+xkLnSHyv9f4heFlr9If6fkxldajIpurzI1wGB7JtTGUC7YcdE0ZLU5kpA9aBOWtcNzjQ4ECDA5ONAyMi6GQjtEFPgwMNDjQ40ACshgw0ONDgwJThQAOwpkxRNQhtcKDBgQZgNWSgwYEGB6YMBxqANWWKqkFogwMNDjQAqyEDDQ40ODBlONAArClTVA1CGxxocKABWA0ZaHCgwYEpw4EGYE2ZomoQ2uBAgwMNwGrIQIMDDQ5MGQ40AGvKFFWD0AYHGhxoAFZDBhocaHBgynCgAVhTpqgahDY40OBAA7AaMtDgQIMDU4YDDcCaMkXVILTBgQYH\/ELyDT40OHAYOWCL2mkdxuuv94srbtoUuKVLBxdmnESLIB5GtjSSqoID5QX8DrXSXxVxHfjKoADyZBKtwHkgnYf7Wko6ppUfDzeB9U6PDAcpOHmLXluawYPR0rE18LV905Ilidu8OZkMS0wb0I68Gu5o2Rnp2RAeHC4dSfMxEk11uT9ReSkDVl2oHCaSlDlhOwU9xy1P1rl1KiQrqInK1DBkNG4dZg5YufvlqUM3AkDZO5\/5TLOL4wL72bP1bFRMrr66vAVXJckGYGyOK\/A62jbxgA8hOyCbtZnuejQlK7RU1wPlRRukdng9N32vl65POGBVCl3lOZnL9jq09eLrlaHKNBrnh58DJrQCKu28XbGNWbBmzTTXFy1ml9xlVFdno56ncTwBmZ7O7msFjhJs7Xa7jw2\/HsO22sVztmfL3ev27r6\/EqRsm7SjELiy0hKAcS4AOyo2z5BMAGJhPcDYAGvZ\/PnnxXFwLQxiW\/dA26aP1xkvobMmD8c+BG4fq8Zrj75H2cxyVxTGO4Kmph1bt27dx71yWAF41SMz5QgrTsSsDAwXz5\/\/qiAJ\/4TrIpvY0SxJxpvPihSqP4UUNYWOY4+Kr2zesf3z+pJ72gPysG3yUT21Y38zs4IyoAKkCm4gfhky8DvE9hvIw5kc57gmtpjTxpwwYtgg7Iq0EW2RzU2TR3lvE+\/dCZB9O7n6sl9k3xhwLV9uW9dm9+p91Ear69evLy2eN68tSHJ\/AT1tUPcM5VYP\/28vOM1mr8FuZLEzDpNNM48\/fvOGDRuKygdpiEG2R6iuawmKK9ODpW0LX81us+8ivgESEP9GKIjqUyQC9hF0z6LnT7AFC5vXul0ll+8674H7d61lP8MspixPXI8LjD3Tk\/AUNqB8g7YJJ1NZ3OM8Ku9pHJxqf1GLk22Ic0nwZNJffGBJ28JfcvfOMB\/8973btz+YZUjAlfK1ngo8SFAcnsOuski46NOfHh2+oBTZl116+DinBljtfoureub38GUoTcmE8LrrclhBtnty8IkvTHet3W+m4N8Kn1\/kmpqnO+1ALVwWEJWEQ5yz46l+0EyxRqfUI1YogQFaoZB3udxpPD\/NlYq\/DePeH6y6bT0q\/Pnk8su\/WQbGdew\/WWHNpWTV5bBnzx6QFTvPFY6LXfTGQr4wq0QeyDN3PdnjSyj93nROUbGdbBI83v3E05uXzF347SSMUItkJ08i0lJrZFwKznfloHIiTnYuTc4r5PJvigVVNeWhHHX5ZDDGpDt0pcc3zp3fuXjegp8HcbI+nDntLpLfz8sGYOPJlwEWhJewqdiVPikQYQQrrZDKVIzrhJJI8cAOQVDgxklI50nUuC8gzfdEJbd98byFP+Dev27p2taRAdd4MlIViYkbiFAU8qi\/GHqG5jOlt6q4xvGSeMs2tzkK1XZEHkcUk+4Ts6quu86VwWr1bW91LclVaPSFrqU1tZQEUAMSUm0jL7kQp9OjFYHnvP3CHQGZtCnCIPW2Rghwha65ZQ47aa9wvX3\/K7jl1m+DIp8EuO4UWE20tVUKSmxJHTwbxfEspKefrYibIVT6WUOo0BEsBq7QjeAk5ORi4OtSKvbPNgfRzVw\/zUOFmqxx4vH0ogdxDIt1afdIuTJkV3o7O698XnmecaDiPTsNQ+00PY8I5sGvVyZBfE3c3bsR8PomKa+9r6trK0kLjBWqzldVZm1KU0ZaJbkjnUOzkMEeG5eoQ+1oO5KbJUXxB24hbyyEeW9byhb11Furtu7cvj7NSP2tLcw6owm60BY0gu3NpR5ZGDzL7tT1SMFIaVVbVqTUUdc0DmdkAgmAyteWN9++BJZ+hEJ9o2sFqIogTW9vDKP1PCTHOc4zv6XPv5VGBSsy4jNAk4SY9CM9MWZNf4mXaYo1FZpcLv8619f78mDVrWvcQN\/fJO9\/\/5O8GghAK\/1dWZT1Pw6lmyvdGHpz9ESlI+JA9o1BBxkVcoW5MJjPg4\/0J7nXLG478wM8vEvxj0W5R0oerpou+uTNyjUul9\/PKNKNyvPyC8OcDL7Hmdd23cryE4ThNBJ5IfdeGMTBpUvmLViLQ+ZW8nW\/XlsRrMAttO6QVuSghWHbfxohVu4q+8G\/qsnOclImn0hC\/UFTHuHLI4E5iBRhJVl2QnkyM50ieiN8\/OaStgWrlrS1ncJzDD6sIG8OZ\/HWdvS1O9kSIxPoInZSlxB4GmuL\/rn0NcCQz5phWDtvQ0a\/46a1vhFLCPuxN6LZVzL20gqG2dakkfTCo9TKguX5fAj48Nfk\/wqc57GkTPaMm3rXNxsF9PIbBVwPDJRII3GFphlYXR9whZb\/DFatejFCZz2IZm1NTGEgJhYkOpwM6ojJETRyd5Q\/XB7++aDe+Ugq9IMcJs50A\/l3uTC8EN5+Df\/ra9O0BVoZHemtsR2kchYBvxylB\/6vdj1QvMqLylvGEPoO9dJldB3rVHpPaz94XhiE76Ox+4PFbQs\/KD\/h2mStVWyHylsl44bJtbIGBeMJoJCAANYQgwDC2uCyamiKkSnEVX8CJWUmjqOEZFrDMHcF+fzukrkLXmnfkVn5toYhrn63xEXIHE82x\/IN+W6ioChCOjfKob18NlVOgo6OfLkJuOrW68nPF1xr82lYVKiaHFRW7nngQ8rnQQr2GjhNaw3NApNYRKU+LLEnAKBHXFF\/xac0tAEgc7wT8AeAAWqSQuQkjQvZCaUMNGz6S66fURDTpr0Qkfo6wPmH4mG5iXhYGJrpiOQnd4i\/0D\/P5YIcNhRgZEE6kumH4Zd0QwoPN6MoLuXDcA716x2L5i78DURVxoB0y\/Sq1iwqsnIYrx6g6xDkaSrrO1qNrhM\/QoD+kifpPUmAW95QwYo8jQ8\/8ejOB\/7tnDPOXKBnooUoRsQlMWaEQFJ86SNJNKxiAFaNGNGQSALXBHGtfDsNBc0Ju3guOxG5sz+Ez7CQFIw4MoJgxyBxkFA+4TIA7KuL5y58\/5Zd2\/9evq2LqV3XY5UNSacuF2k+XdKHSjyBGIjEugjDgeTBzVKxVDyRApTT3cIc1zFEZrL7k\/Wonr\/kkkuKsrDc7JM+7Zqbr8DfhFXVV6R4TTCtelJ5Cq5U2TSl7p6B\/icApg0o30+pv7bw95BLCk\/xVtEgvFhscVF4gosH5uJkP4f7LyKuX3et01ppEoYAm9iCUFvvripD5BEh7+lB2lpOwLf1OUBrdnLV5TdnoJVZgRPBTymkFBWB6UYz\/wVaHkB+pwU4bEZID9EyHToGOcOf607nej4ZOVHIRc0t4cMnrncQwbRCN9DKhXMiF33y3Llzf4d3nkJvVImbgo+Q1hhvS+oFnKYHe6HPGj+HjITKl2LG9+1a+LwFfkC39B1OcFMZFp\/4ITsCNWRE9wRcPFAe82HuteTt7CXz57+H+\/9NPCJlWL\/W8ICl5HB5EjuRJ4\/D\/reHuXgjN47JFcN4gLgOzIhMBo3403EgLBaSUjAzyCfHQ+upcRIsgrZfg+TnE+cc\/igcZQZhoxb2GcmASxmJZW1N5501i9sWzNyys\/OT6wGri+sOWmKnr65I6+fU2++CngE6e5uKZFjP6hpILZcv5aK+HF3ZPmQdDdn1ZD6aZSWwWrEu5y468SbX0ny5G8BXFWMV0UCTjkkYOUqRcoCZd7r39W5AAr\/Ii99xhcL9Arxq8hl8gd7GZ3vOlZOd6u7NNP\/mYoGpm1VlI2FXBSqQTHgH0GtmGEX\/TYCWK4PWBPq0kFu5LKRYz9LF94ktnZ3yx1QdFi1aNDPp7z+VLFwYJPEfwLhXGXDRdCJLWJZeccldjFmCWRW+sBQUriKBv+ZPaQsUDtLFqgmofDEISqRdwFD4OcOPrgaBHiuFwbFJVDiorDJdbwJbB3Ilyj1oLsTBTAplDlbHGRTMEorn+dB9DlZkC9fikel7CsYi3YCLd0qYkSG992dFcbSWltXbePf7ekHhwPwND1hkBFZ5jzTDEUpRfut9u+57jNv6G1e44IILCs8+8cRCXFmvQK7fCkpdCINy6q0gKxGpWbMPGgWSsiWLnDOg0N2ApbVPltZ6QEvPeVzHmkXZsQph\/8bt27ePK3PPgY\/MZ5UOW3C\/ueejrrl1EKzkpxJYyYhG8\/BjMQqAouvr20JZ3kDxrkuuuvrZA9kkB7nd01xCBc0nZB4hGmhKmLz97d3cvUt\/+KhWu77+9xD\/FTQVZ+HD0hdUeAZY+r7g+jHBmpubAK0bAK29gBZWj5UuhPk4dV33IFwpBgwuI60RLIPh0kzHI27l2Va++8KStvl\/BPc+jl7MRi\/KoMVzuU40loKRD8lbl82b9\/dcP6q0eFYfwCIeK4Qk2H\/ezh0b04r00eHorubemWeeeUxuIDkHTf49DJYV1okA\/coXSZENo12Fo6YvXSoxgJk7KQ6iL9D0fRP5+5F0nT9siUFQHhGwMquhvsEAAEAASURBVKKIGj\/CwExdC3TuvvtuX7uZHAxhlvJ7IPOUlt1LB8PRDHBbzjv5vM8UW\/a9hTbDn4LAi3glB1UaTgFY8QuVxFQAyIpYY4B3fCPI27V5V+f3lQaPD0Je7tcQIJGmqPInOuUE7OjoUD4nIohPQwphIhKpZ5wClrLP6ubV7wGQPmzjqeRvCgAKH1SFxq65KWdWV6n\/FjwWf5NceUVZ6A2gNL1GQfMDK8DJR2FCZT19Gimfvadev+TKK3dx\/ZfBLbd\/FV\/Z\/49193IsrRzN0Qy0pAdN+LSKAFqBd24MVt3exbd3CWxJawLcCRnVSGxolatra2trQjzVdvX0l18ZPGHUtwUGSytIP6QmqoQ\/Q6fT42jMF7GmZtLS8KCFOqDgekfHs6MgvJh3sVilKXXTBU8vo2O3nnHGMcT9FKDTTB0uC0vPKnU7y1vlPdFXvt62bZsqqB\/p77zTzlxVzCeXEcWVeO6OS5u+6Lu3ssiCWWBgWYm67mQXxWtoHr6G6HZdrI4WRu7xZ+GQgKW3QHxT3vmA1d1VKpsYqW9FjA4qJI1mJ8T3PHqPas476A38FhFfy+PLZG1hVkEYvYke68WiAvZXkUxMK8XRDWeffrYy8bAAhe\/LmeC8HiFJwdgJrERnPSI9KuI45RRZv3Fw8630WNEcUVOvt3eAc7MqKD+BVeRaWvJYVU9x\/\/1YN59T3k0O1q4Nq50DiMQbkGV8Q4iCrNdP\/qjkqks34Ed7resb+Ft6FK+hGy2nRgVfqWmokIe2yE2fNsd193wyuPXW1wBaT9kQjAkaXEqaSRRqRKxzs2fPjrq6usYkO9KRZcuWFTZu3DiweWcnPeULP05j9yMotPlxyBY+GPnt5NjHuRQnLyWpLyKjNo5J6dYzdOfzRv+xxx5blR5YGUNAqusixZcEfJEe3fPQtoe495dnL1jwNRw+f4e19XISsJbSAaCVRIy9C3O5JdhhH+ObN6\/3rSrjgyL2JrnORgmkbsipGkEUjPJq+ZHeS4MyrWG72TAFjCYz9YLNO3fu3tzVeTkRXgZY7acwAKJAoFWOhwTztHEjHHPnhvnoQ3qgqRIXBwZag+\/V56wi4fpEONVjKTvZV6+egRhe62bMPAlAUK3rwUocE1i1tgJW\/TjR3YrkyhSsZNkwr9CABitpPLwg+sS+TweHGvBccklPctVl78NZ8Vc8BaJogspv5ksPHSClXpqMLc0XcvfPla7i4HamSOMhZcK+QT9igVVaEePndJ\/l1i70xKcpywra9Z7dCIIlAFxaWdQ3T2IhxoPnZJU5TvVcBwM4jtJ1AbhaQ2rWmbvnvs7On++P+mkiJp9WzgACBlHbe7xJBu09pq+p1ejcisXzF16iEwWeGTOqAiz\/SX1+00wpM0EGOlu6tt+OmfhOKH1mELSy9Dyh1CoqmcuWzl3wCj3pcB3mdMzeahzrzwEpibv0Um\/JJsEfMyzh1dYjJ2e3iQ9p4uM0y6q3dw\/TM9+RXH3590WJmmFqRqo5Vy\/KBDpuxfLY5igSKWl9lKER1yLNJJjN\/bHUaCom6ggQfe\/B\/\/Wbdvf6601x7HwS\/mDZG1BouhqE\/1TIq5xxE+E3PbDnXJ6ae7r\/xDQLWUnULUfmPqtDbOi6goGXwEjDkx588MHezV3b3wcG\/5UycyBocQt\/ncPfT95j92fLFiw4gzgkQ4ZVhx2wMj6IiPXJoKW0ddeOLwdxeDXoSyekLC2afGlRQLrMxxL+ribmR1yjtrW+b29vn9QCmOV1yh6vv15TtZLgllvmoTKXmSM9juWf8XxHsFwe73o\/PXRheA1+ph8or2YFTZDPCGFObFiFJlYTkquu+GtA6zZrplp3usGUgCqP853O9tZjaU1dY+9Ck\/nRdDHJA\/ncLpwiI9ICAyr0wI6g13H9TdHxykLmD9N5vcJYLaxq0kWMIlposfzEen\/zzu0fJVcfFw4LzChWX7GRW87laVfzdyF3L0\/jNwPliAFWlslK0Nq8a9sXoPMT9syPQaFnxL9JJkJ17eJ0fG2hGL9Cd6mRJqQN71N8bv9KsbGOBE7oTG4FVtSy1LryTnY\/zkqTk\/XGx5MrLpUTGMuKQaUT5ytSEhYqQQsZ+XPX23MXNEpaEHwptil6yToHXPJqeg1fnX56xGU+pWO4gwGSPQhYZkchlX8758e\/kDRRuc\/I7qHwB7yVPZlcR1V+6tTKQOukeaf\/OdbcN2wwtZGq6khZNme8WfZc\/kE6qDQBnLXGx5EPAq0sE0lL\/u\/IVwcoL8LJgC8iSkQjnulFEMnBW0S1GNCwsias\/GTlOqyr5\/H7JgOmZEjvV+SmTWfwXd8PXV\/uU\/buunVNycp234ScMLIqIr7kErOYmAD9FNLxF\/it+nEA2bCYVLXz9CQmNvDUJW\/Xl2qmTgkrK7HBsRWZHTyVVoSBd\/IP3p06Z3Ru4YNmIDi+aJZ7+jDjxR9D3+U4o7IxxOLXW1l4H+aWwujNyp067SYFYIkYIa8ciRqbAlDdiJ+915qGjHDJapksE+DYq5bNPZPBaYxUS9v9Om+E+nAgrbFT4Mm1Y6xcQO8fkccGYqo4HOusuJ5uObpvSj54yRPms1q+3Ftk9SHjkLEg2qrNTIaTK65Yz+UdttaW\/1LPGB5Dz7NVekF7cONqBi9bmDRyn9KTHSospZAmH5fKRUXwLwQ9FM4z2W1V3Nn5VDiK3o40Z5t2bdsE8TcqX8idVjKxpiHXvhdRTUYX\/t4Fp546jc\/wCE2isGnTJjnj3aaubV+DzG+LVIhMa0xd0b2L8x0T8qQ4jC\/Su+p9JKOTKh+ia0oHv7aV79QI3CuZq8cQzXSOoDKmUXLNLTr7lpvR+h86caec4nXJLg7fj1lMrBphKeaC22m2PmlzFhGclAoWTqJTM58\/Ba\/Wq+ye1omfnMHoUoUBixeLRDUxYKw4rvOUx8njzXFsg7hldUzOrIxOFcVTniNMD8ln6XS7T452Cyo7AZUGjVr2knN78y0v1rNJpejKRLlpGCTrNJBMpiLlVenLEkCp0nw5RxNUmoX1zseUFAJf2nX59fxctWoBsb3E5gqqee7lKaJ5WHDdDKULwi8n73hHn1lXVU63qQt1B0ayebNRRtPwV5D5VescsHfky6KDgGHUgBj0Bi\/jRRtmMdmahchycP7555s8Lz59wVLIfFGKueSBwaE4pTN558amX+3alU3vmrKyCtha2NjV9Sjl8iVdcFTT0PJE\/m1AKXORpzM+ol3P663oirOmMPPuu43YIIk6GNzLnA2JWLkW4YLcCICZl8iytadZYh0ddqjxJ8iAr921a+wIgF\/3P6O\/Rjon\/vMlS8zSZZUQFMcttEnHGsqgwBxTb10lv3JJ6U67d6TliDW5KCvP29h91fUwBkvOTi8okh8\/RitJlrpVq86cSJpnzpw5JgAR3Rres3TpUptlYbSFyfvpIZudApZpMfKuVU40RYLr4Pt6j08nnf4a\/dX\/CITTPMTfwkDp4dp\/rWwKvGgGCgOwLV+gd71PovoEJvzNjnQGugaVsjrhL9CQ8xA8pumIZuXG5iiIjrlBFCzkuEvfkJlap+skGuGuiBnjpbEjYxI8fXc0BFkeNLNSwIqW4bDO2dpTmFMya5EdrACxJrgrnS7jmEbj3z9CDDDZuO46yTK9gnkmWkebXaF5iYvZiScL8lEHwSmIj3yf99e5CctsfoZ7Evbdf38TA0Ddvn24Yg8RNHMEMRPvUn8hrGxb+GfQ+S4Bk1lVxndxnDlyKoI42VzM0xRPw1SWU9HO2CwDrIF8fkuhFN+LGr\/I5Ew\/ptRUNvK1sx\/A2XPnzp10gKVMQGc6bN\/do4LjWiWmZmFeDRNJoQaY8qpqyx+k3yjjgwKaFmh1B8PBEvEYYCm+6r4b31tWDhOcxvgos6\/ER9Xm1A\/hQt87iFJpXJMsFeZNeAd88j96e4KnvBhBY\/lJ3nfJ7uCW1Rug2zplTCJkHQqwcrkWpvGcZfHNmmVlPZa4R3yXIR5xGGm6mdvw8MOsdTP2sOz0hQtZh+IaRP0qIR1yrzLwA3Tp5EBm8hJKgOuO7ds7H5cM2eXYk5qUX2juIcul\/xJlfxEEmo4rg8icKSPnJ4ZJbv6kAyzRSFteSqO1sTYz7mofZYOdPQgiBizqBk2CeXpfgTEalj9\/VfWvviFiw6czYNgfE2kJOzWPONQNtAIttejCVkzE7afsOv3\/Qr8E0Mzdqik9XC9mzvM1azQB9nSfrMmPTmOc10xu7mehvWSbPdu8WX4XWQlHNgx1pN\/L\/H\/oofbG7qYkNQGPtY+aWLo5OkOEZlN1KOTayxlAxMKarnhPP\/301oUPLSy6dl0NDWZ17d5dwJpo7o2apjfl2UEodGcyi+NlDJV+PQvHna6JwYCVnxiMdCIrlhGmpoG50Q\/2RwO3prEOTtUZmsyUusKPVeY\/un6vtFFgbDpucJXqdeBmUJBtkxKwMj8AOdkF5XuRO1aLKOdLBWLdJWTq1Kx09rS3jwOw7BMWREGYg2AZ0v1Zjt5ZMyS5LJXxHVncy++WU4q+\/eRJW35GLKXUwVq\/Wn58pB381e7dno+l0jFw+YRsALJkR9rjLS73hCsEjxz88RG8w3Zf5dSDsJOlZlSmqp8FV0Y8ckThJnPK711\/faAVI8rXYzxBgVhlRJIZHAsifmzJvIVPzMw3Nz8294HYdSlNE1rPTztHEZtYSjVJZhTyyWy+PwklPV6rQotM1oOyPECuOd91kyzgjcNAjKMHqKI\/+ODOB3t1j0dHvpIYI79GeF15FECh08kOwNsQK3sXHhn\/VIQYEqdOSsDKxlYl\/YW9rhDthfg2SYWJQJoTk7IgOEE1muYnZRkc3xGeSPDKhsT4YhnpKwkXxcAE3aTINl\/jVpCR4q\/r\/VNO8fTFMRZDfgbVvWGVMUgFAAZweJrq3o\/Ezt6vKxHjiAy6guuuk\/9NC6w9jjHYxyBSmoDKgDWt1KzV8kUz69WMJUUDRPSthZay1nmrKhiD+UEZDag0uV8f8j0tCzFYQU81QJSdS6JoNx6sSzbu2HYPl9Zk9+8cNb\/KM8AV7mYrtWcxHI71ubf8GT+MK3FwwqQELMxECz1hTze7DNgAOTIADHva7SGlCSxPb2lp0VSRXjzlNYZUgmqMZZjPkTHtlqOF+ScIEYdJtA63WJSP9aVAWv5MNyVTabzdWFo1VhJ1oLAiCquhV6yTMmvIYR+NVzb2DGywWMVrQoUW99RTrI\/jesprbg15YawXBlpqrqkZB7OqC5Ln9E3pYgVQ6S654UdDenBl3Y9Z+JbNXdt+cbFfG+qo6hCycksd76zTsC\/IBc9SRsz\/PJiP1A7TJyVgqcRE7osfemhg49wFWnlZgXIdmguMrhDvkC\/4dnunlh8it224aolj2G9TC0vifLSY8cPm84jfxJFpQYvfoOrp1WE4AFUa74V8kqiadYdKWyCl\/\/ahEXjAF\/ace4qPBuMsvbM+9X1WEb9FOeV+mlievMQC5WR+uKBq09dIwz2dBPc2L12qZlQGqpTdgTlhZJlNQYLYjnEQXI5OUVvA2S6He93\/2A3IEmspqiKeGkHLs7BIH+Ri23qS0yM+GEyK1kmXDa1iqpDTFCKt+JGRDd2yEk1+kl43a5avBLP3a80IMZOA2p426wL5sTWgRjlmeqfhDAN8zBGALUuGqSzDvOMIR\/wiBpF9l2XCLxGZVH4VY5dqJXxyfU\/TWKA\/8mJcMDhj3OSi3EsWq932tyBn1vti5rYv0FQKpUeu59geTasitNvv+H+QF2RB8lD3P4hixyHIDtzApPdhZU73MFQ3\/X7mQUkbCWI+J2a4BMdyoV5E57L37eLI\/UBdhQM9PxtK8L9h7JgNI94jLZ72Z+u9mkQGIix+ymKaJHiIP73DArvypucZW6UllTVkQb638nislHDWQNeySjkA0K1iQ5Y3ZBzmG68N2Y2pfTQJo7RaqFZM34fLDhnuy6yX4Z4fsXvtKi2FXncM9eRxdo642TH9seJKgifvfuQR70vpqHxa5bkJMM4EzB9waiNJfAqbjc0vYtaRH3GrpiojH\/IaHZFRKzFum\/nIWTZBmBnrk7N5mDnRBwb2uXyzemjTjEjp+Wf+YfW05VnFwWkDhckR6PEzh7uoiaP5bPuFeGNISZLUUpOfRADm3KP6sVBDD2EWhSwrsMPsZ9wTd9Ei+G8kqgiI0TrILNPsbSNHg\/3wocWzkWH1cs9DDOezDLh6\/mSnydqSv1PIpwqCnsi4SEuiwOiYjy9qa\/sF73WRJu9MfRdDJfCGSZ6mb3zQiABxzyt\/sHdSAta+8883wGpuip7HCs8nZOSK8DTYc5zuD1N4Q4Ase6HKo30rPWTs385NOzv\/scrvanpNhQTZpj01RTQRH+\/e7fn5zDPPutknPuiTyJpTWOSaA53LH4dmadDufx3pUe4VLBCyep6GwXlaZ9gF\/ZqSI8VmJx8el3BuJeFOfVOfnkLfzqQ4wRW2Lm7OXXnfffc9ofirCfPmzWvBV3A6AxReCNi9ljhexxCGVu1zZ\/Uz\/UyAlmSFTRWUhWB+FOc\/QNxXc68eszuqIXOi3ynrAqM3TgPsW8sKjZbT0SbhE3918cikBKxsHBZFdDaKcYI17vVjMAXdVPvKADnZnnGT6TQ1AICY4Zq1kikjbvu1zM2cOWyxVsegQYPa5EKCxl+5TOqYRL2isnzLWmHE+DazqKw2Nz8QE+sxsaYxXaen59eVoA3AZLWEejezxpuZ4NP\/cBIQdaEfOEosXmb81mP9\/TRzg\/st7qeeEsDVZOVSiDGWD5unxN24Um\/YfN\/2J7QMML3cKmfgRibSwSEr\/66uLq3Zsy39+2em5fw+VtTfaicpAIzoTcgVDcMxXAl5x7+aLF8698zbtCwL39Wch4OpO+x3yjwCp5fSUEblo0H9EHKLjcwzxLvVOekAS6VDgVpbnuMFFJ7fdFVDUpA+laJOkAhWZgu3iL18ooIbzOT4eJ6kWxo5lrkpT9MZX1RT9ysDqjIABZtYFE+j2xm5yM40ftdeKbmslguDG29rS9532U52xDmizRPEOWCzi4hBoKjwwAupz5bZhO2KSo4pRSqUh5nkYjKD761WeSFRX\/uzDu7TbJsjn5\/7xcKF+YRKT3Ks6+FC+kzPtUJD2NfXF\/gdc7b\/O3sOdtHxvQ43xUJAy1taSLhVz1CM90t7972ebwVYao5KX2rOy3B0Ho57y9NE\/CotNi3HdNzKVM8EV1zA40cBsm1S9EkV2lkpQQSdferZjLJmaRNR6+dSaTiwHqnm0r3tSdRvtaVWWZjKhaZMTargAQgpCTehIdttaRYtiawg0OpXJ1twLjtHXmT3JE9HMrC5RLn8g+D3HTvbUyMDsAYaEpq0Yg42GsB6WutGM5CRD0J2QCZoaywdRc8hglnbWrhSYCWFhdwcS60wn44NGpB1rv1SK+QAibfh8JajIPxNe6aX7JFSnHqBPARYo8qD637qqUUg7wsB5jQj5FQM9P488p9s2bpzZ9ekA6x95\/tZ7mFT6bcopF\/zZVIuDMsN+eRGctfWBx6YXNNDymRO+ROvzE892onQ\/MRbJzRIvCxpUlvRTbfOnDcGn\/1sC1ZZKdvJ5ojkPJ1HGNx8+3mk\/3rbyNXcS0az1u+if1Z9HckPRV+6SUbdAEsRMzm0pvgEXJm1Uejd\/x8o6s\/Vm+iDRy\/Y79NIkrNwvp+RPsxeSi+n1EGGhuWJlVdeT2PqeDodfAbIlfIrUBMGYFn+WA8mFWBdTPdutkg9xvbbyUAeq5gmiDZXtQyo1rHt7Tn5blY02bIw2XXjWCMHaF6ly8wwZzv8rm0+kcvLSkkVBvnpx\/2SJK92+\/t+11KrQxNrPFQPcZ4H0Z\/gXzueFUZpQQxqOzv7QHn0MIbW9y2NdMG\/8aQ3kd9gbVi459FHu5H\/X8p4Qm\/LC9qpCWrqHAQodk49jBbI6lQGLccGycrLHyszALVGglt+yFYs0AbTngzCyMpuUgFW1jvYvffpP4T03\/HISvPdykMoG0S2JlDiNlKn\/bcyqM0nM5TWdSPUzgH4Kb3wzaiQIbkJG363aJaLNrnVgWclutymz+Cd5Gp2V55lVhabUNjzw\/STCbaRtHr1Szi+0xXNkrJb\/Eh2WBbH5P\/\/Jlddcq8eEDzw+vPJ+RskTxphw2FRwpSp0NH9P3UDYFSewJ3LRez8HuCzMzhGvgylwC4NGreyu2vjjh1aNGDyWFjqoZN1xSqibUDUhzSwDr2Rgph1xREtYiEv6Of+Oi3wx73GJhRiwsQEA6fkssseRoC+nI6\/EiB5qdJwgR6Wfmpuvojx3e8VCfQUDmi55IkhZ5hY16yxLcWCm29upvFwLdbVdNu23iwOE3RtlhHQcaDR5H4JXr\/B66QHLJgsE3aYTJs+a6trzYeckoHiCdpduxXQsrkLXopOX6MqEv3WNJDUiKKRyPA2eg5lV\/6rMqoe2ElhYWXDCcgHHYC5j9EUXEJLsAxQvlSCyHoM4\/hBIMwyoKVltQnFlCy1SU609Ramm5UiMWtZtG+zmz5NUsVgJgJOBS6YviOlSj7Evn+vs\/vyO7BqaXo+YQdrCmbryIf5P2Otq992vabjUgT+JD4MwLSWbHKn2\/v4NzL6Joyo2iMuIxStiZ7yRWW8xm6twJtMvqlRlXSOcC6w0nLQ2trvvIULT4xC90laTTMBJg9WsijNxPejQijFH7eW+v9N0clBP+GCNQLd5dsZWOnG4rb5nyQ\/y4WqlIuNIPaVjLTCRv8KhW\/d0tl5v95n7NWwZapnjVAHDuzebZUBmzvsILbbXBGji923Oc8qiQJNsKJrbZ0GRHw6uOX2CwR0PA+DFelONnUg48AozL+WbtYKUC5HKK71o9it8spkuuSamkOsKwA2WG1N1iliXSm\/SPwIK5ci8igJGjLlAAuyQ4GVekUZ6zijGLk1jLt6AWt90TuiCjBr\/5rrB1819wN3k1Zx5VuNHjg0YKk1eaDA1ONa1pH8TxqoqSOrfX6aWuUalRQpakVODZbzIQjYQDWHeRj9NB7I\/71upr6rTHHSFxuHenJgiJXVs++zrtj\/7dTKshrF0kpcAVCIAK026pjPBTff9nyBg1u7PA46OurePESwy1NwglW3\/R5AuZpmKcDJEHxbcwyq\/BCMAs1Baf6Xk6su\/2rKl0nfFEzpJFtxr+lCduOAI574DLAyLTngjfFdwt8JCdluWAKrs88++4R4f9\/ncai\/XsYJgTyANN644kbCnG+VdLB2c9d2a8rrHYWsNhqRSPADl5Kiqk+4GCeoiJdJqJ1ftQ31o10P\/CvEez+IJoDKqatiUKqBY25fUGAmN2scJX9138P3PcF1qG3q60NRORafWvmycSIO2JbwAE\/yoQ+xYF\/yEXZX2AM4acyRvNtZGcmS0Qj4JUjLvwY3rb6Y4kvYlrtE061Jomfv1uNnxYoKmU1+3c2YeQLjwnB0UEMrFcmNfppw8XR3b8K\/dr3uyLeWWn+6nPQB02IECytjeUD7fGKCjVetQ9ToaSDDQvou\/zR4Ey+dN+9Fuf7Sv+Nk\/30GogmFtI5YWnbWscbsAYyTONrJyPZrRYaMG32r84rC1+VgICoTMnBP3YwmBjzNjoMvHuJMRMtZlg6MC9fjSM+GLiydt+CdUZj8B7PR3whBEH8AWOnasRgvP+Torzbv2vG9NDk55MdMy2ikwqpKAKxr3KOlOyWe3XmnrwavvPIuJOCvbExTIc\/ifqk\/y+sQoNUjS+sslwvWYv1crrzJEQ8zE43TqodvK1m71oZceL7Fn3P7nt1ED6bkGAHiVy0CZI6mqy42J9dcfp9\/dwr0DIpi0a6jC3oPFELppL9nzZ4JsbC8feI5lk2R81fV\/Yr+i1OjRF\/IKJG+L1iw4FjtCISNBFjlXgooerDyTT0fObu8Y1nlaSLKgf2ncv0QXYjrp6ybI5rsMMzzJnH5XJG5l4S2trYmiCnNqQCuPeKta\/cJ6pfTbIujim2MlKAlumjRopmud+C3sajewb3fxcGuQclCH\/msBi2rFLxwtNNBFa3evLPzE7yfoa31YOm6xqBMkjdSdon67S2famcDsmUm1ZjGQZ+LZx3wkDBhaRyUaA03rGnoLZRScvUVtzPHcL5rav0QBVfgT054WVy+XuntLbmWZqyegdXBqlt\/E6\/DDclVl26QpSYSZOnYFlvatUbrUWnFBK+jenzIYBXVkiWm1NpmDGD8JAJyB3HgQrBamBHhVHRxJNl+abBqzYuSKy\/5KedCMCvfQyZy5F7wOucJ7aNW9n7cA+kh9wywzADrwKdjvzZuGtxTiEnYuq\/V5FJblqEZcTu8q9T5LIE96unj4TD6XtZPzVgJmkqvbU7cuyjml4I\/Wp9e8RN16vbx6RfBnIKowDj58Kad27+SpWNlnl6MCFiG5mJf4J5XyiWv5KwznayZxVP1Ecf6MbmB5BwW9bmIjsrfpva7EKBq0uYPtGGZE6hJnRU+K\/Y2Id2CwIqm4D\/3BfEHlZjMSzUlq074UC\/CQRCL0R80jRN3zpK2thfyyU\/Vzj7Up\/V6rlKrLJB6xVvveOSXkpVkwLN3z1+42SfNYgrMexhAWkACrbxIU6KXp4lWZLWEAlN63sKmpu0A3Jdg8b8kV1\/2M\/NvHUAcH6EnZV094OnQS3t3xYo4uP12T8v0ln9x+3vewpiw33I93d7KksxrZPu0aae43u7LiOGnRj\/pkEp1CQ1N9rBfIZl9MAUlduj60CAmo\/fWJJTsSIaGvjGOKybmEhXMCX4tnt6\/jBh+UrFl2ZiA\/ty5c2cVw6bzEOxXoOW\/DdNfwJJe1G1mVSlPLL\/N72DGBsgv4EiNEid\/s3nndjNOyFZ5rFaWo+EBi4j4lnV4Es1GxwRKrl06d373QFPuO819fYa+3AZvqAAKhUKx1AS29CVR1AwMlaazbvEs\/J+nQNE8GLCI1cmWQszZRHoC5qBMC1lNarvymCZfmXgeyCwMIB4K2WH8H6YX+67Z8vDDfWrH1hWsMg7g4NN0ACabstNu+OlFcxd+MGoK7iWfw\/Om\/N34TsS3YjQtHGgeKO3YsWMfvBiTMIwv1fp8Zf4sgdbKlUXGPl3tKHLX1HKZCyM5vUEIBjSq4CSQJZzgUSmkuXYy969xfQNvoUfvh2DJf\/H+zwG1zuT9739SL8ODQdHVjUMF\/7pZbMk73tGHo\/9\/u+6e83GyM8q95P1ZqvQi6EqC1wWrbn9xcuWld7nrO3JuZXv9KrxD0Tm+5+IgXueoh2kG8FTjrWCP55Dnrl5wQf0sLIs7oSnG+PkwnMPxhqXz5394IJe7J9\/bW8DQGLZ8pPuulJtRdPEslw+fh+NpIQQucWF+GQvMnY1OHec3f8UwieKSjCAC1jhvWZbMgmQweNBk\/qzYXQtY\/bXYlvqtDiqrUZQSOFGbGVQk4eehzHcUisn9cb5J40M0cUoue15xoFSJePIxI1ZDXGgtcZCbwdNjIK5FSyU6efwRMiMqYjCoIjaUNc6LPqLxzaO8II8mLO9ct3XXjo9KoScMrKwYDC2lM5Abvoil\/L4WluJO8imelqHUiKzDT5wwIC5fPK45Dn61eO7c9xPlbrMcaevXIfoJj6LshL\/66n6ad1e62XP2YDH\/FQvmNeHDUk8dTS\/qf3WcqFj7+rz11dJyEnLwRhbVeyON\/8ddoWUnAPYQHN6DbOzjfQ3uRCyqDJI8Fo2hzmMZZ6uxn+XL4znXEwXtn+ig63jGZ72H67sSwIoEpH3+DXttkv5Euf1Q2g83Zw5LLRuw1Jdyr+\/SURziL8FU+fd8Eu8ICs2aG2cafGB6vNrC9OxpPJwJThwL8LSgRKnWpPrOqirQr3JVKyrlvNgfqCy0hRkLE0ZPIwN\/unnnjjuUxmgtqVEAS596ZcaSYkkXlnLNBcuGZZ7IGRIMSyEOom24vQcpQIE84aeyIOIJWIGytLA8WC5WC1rGW7j+C7oz\/12vjUa8j6cevyQsWqywwtno2+xh81lrUuITaTBEQ73wM\/JJs9WSe\/bskX9lygTr\/VPPoYYvOHdtsPq2+wCFv6PH7jQb\/U4zn\/saliLgkl8iBrhkmWsgZ+iamk5EK06EGS9UgxyHDH\/jzL54qjhKeBY0TgyhtZhsYCtWVpzIv\/Z6ei5fkrz3ih+7jo6co\/fS3plkPxJA9MPoj3PsJJ0E3WSHBSx94IHJKWopdDkmu89R34yXg4PREK8pwVj0wKiVvosC6bsaDEzh8hqFvYJFlT6DQt7wfkQWIwQHzD\/9Q4Zo\/H8bd+34oQg5VOVdhaIYd9S+LUFMkT8dB\/8QTvmhhv6xVhXIClpjKolGq23p7TPHqHiCiOkZC5gEtG5Z25o7+0HaG10YvxqzcBCsDpfloWwSANiSzNcheazMby3nxMsCbb20hlV2TxXDAWsOslVZ7cIm4g9jMNC6vsMqn+SKy\/4ZMWQi9P4vWV08bZrMfmSLikpgJck0K4hfNRVldWktfq21pUnURfBNK5mO508gJRsgLT9TjowPGpeVWVm54E9029N9fRVyn0Vy2I8eAgaa9yMUz9iFkWAiklqHquKDEy449dSahzYMxi\/mGBsH9WA4fa+U\/7LeD+q7xeKta+m7LYkjfReIEb0Mk1wejQcvHkPH\/jKMBl6\/cVenByu5fQ6h7yZwxo\/MkDayjTn2Y8\/8C+mcvgNu+9EPg69VnKXMALEgmJ\/sEbJVXqwf5e2O4uArINiarTs7f6R3eB6w1Ea4Pl3IL\/uuzkfoMZL0o9z7owdXbtmzOidJEZo\/wAQuNwrr6pzuxERnTays9\/C9l22kifg2d\/ycr+GEvxp\/0otdgc3YtXZWCb9SGbis0hIjYLD9R5hVqdXAb\/+pxE2dJ2kgfgx3qv4BrCy1718fMEE6uQIr65RTNGraKovs7SqP5dgtnUGdqfLz6l\/LHZfbF+9nQ9hMiaBXAMCl+EUFkJzSn6NTgc4w\/tK3qo8\/ywhHxLBCEiv1wF7K3jwwbpI84FFGqgcoRYrB5tUZfccXzgu0oJ5AGP6VMVZ\/v7Wr81eKVXjAgc+o4A4RDLCUNBHLsNbHGEYHUGKRDHdPD0a6bx\/JbCFKGG1WrOSUhHzv4DZY\/w1aDeu2dG27y97mRyYhh3hC5ggaLFEihLHnM6OwlqPxCnOAuWB4B2uJabJ8a71vfu6gdl2WwH0x+NQd32Fc6WtZl+oPuW5ndLwAIyxbUl7pvOAgD3UK8pSo2ZmGVC4xRbCyIkbDH8\/xnTz8sfnhoBl6qy4D5EV2gmbiSn6UjgDEdAZpYrHAUfUgI6rqo3qql7Qt2MYHr1Q65E1iizaxVDJDjfg7mbUMlvK8s921Q17anKsiBXTQ8k18GjbBmKLhFP5Q+Rn2+bD6TqvCRUl0bxAHX43D+Cv37dhxT0ZmOgJeK\/wOG2H2Xnb0FhZeehClWWMkyEMB\/0L2fFzHShkUHeZsj+MnEZ3tsGoDYHsnzu2fbOzsfCBLAMblxPiJ6QnMUnEt8h\/RvlVbnbZ1bfksxzqGE8SdFrCWRk+OzcdNRoCWyB1DFJPu1VTxNenZ\/FrJ+9+t3r\/PMQxiHVXqC2j+vQrAugigXuoKheOwvKhtlWVktDo5HV+epQKqvSNwVKuQDvS\/O1h9+1eSKy79Nk\/E+6oBK4xwW9AbprIj2lbkVbTT4aRxhKXjc3Q5jY\/Ig74S1WlI\/kfp5HKBRnpDMSQniTm2cQ610Dn1Rl78unSG9w4pQ3qHeBRTK51bsMYUnpPa9KAyZcXu9T3Zi6zfD5D\/lEK4E4n\/ycadXY9mObsYX3aHciOn\/BiCARZV02P\/r70zgfOrqPL93f69JGlCgBi2JL2FrGwmijsdF5znzCgDbqM+ZeYpI0\/BEdFRZxSfuL4ZwYURxhHUUXAeDDroDAOipnFkCwlbdnpPAgFCAll6+S\/33vf91b3179vd\/+50QsDmw7+gc++tOnXq1DmnTp06Vff+aeRWRlEtFrzA5P9segA\/XP301h5o3wmLHsU57PVcv8cpDW5dv22b2cq2NMI0v62tTYw8oDto6xzqlYMYfYRJHoCJ\/E6gdilwrZ\/v5MalYinm2Ef8cMnNm58oO9w\/ePF8d8m2V\/a2WHLJi+FPr5fcoT\/369+b6cyMmgmML8aILUCr56Nrsxn9Myln8kBbNFQPOOyAmWwy+CRifKN8QT+7Vc9UL6\/kVkMrrQEiqHGTjS\/qZ9T5EHJ7sVRshcbd+Ca8BB6XwjhqgOTtKheShrUNE+Ibt6HhAhN410hmFP43Y\/J2xs9RINW5LKOvMEqeHkF3N9JB7M2bN6ttcW7CtoVTzeCx9ZTCkj4QOCT7At5D5npKl04OPANxT4Bpu8Y7nlRXfRxvfaCn5xm1aZMMleO0OasOcbzLUMjS+suPP57zHocpHXdcUcfxJ8Jmln7tHN1ndpgI7nCW6csQM0qlenFQ56FYmh6yoA6VLrU7vVTyCvX1JX4Sqh\/+T3qWP9Q2\/xD18LY858wzPYfXesZbeuk9Q45J1zp79ybeybRpfKNg4PDKxOLUNQw93JXIOf\/8vQwwM3gnyxuNkdbW1unoj7c31R3J8gh0aH8QRPyAiWSZWZJOFvPEcPqqQa6\/P1CbgpTO2nb1fGRj4\/4DBaoFl03PdhzYsaOrTsXnZ+aL+ohBto3sPbxzcUr82e3t8bMN9Ug5jJuYbeC5uJfA5UnxTRh9FkZxsud1oIpptHlQSvpc8GE0zqlK12g6D\/VZ\/XNuuMFzZs92nZ0746nyc2AH05\/JymiycAfT9mRgD6bdg4GdTNvjwdBOdryPEycbr\/b4+dbDcokfcT5lfMBDKmnHNCUzmQzUH9xYwEQPo2nc6kPqz+GoBEPEZ802NzJhTgW+HI5uTRaH8bz0LuAf4rvqZ57pON\/9Lj95esNBe0Ia6OUx0k5v2zI95hlNP2yD0mIe0abNzFwP1WN5zsZBwgeN8+dMr43ByvCgelvlQJUDVQ5MWQ78Yb2NKcuWKmFVDlQ5MBU5UDVYU1EqVZqqHKhyoCIHqgarIluqmVUOVDkwFTlQNVhTUSpVmqocqHKgIgeqBqsiW6qZVQ5UOTAVOVA1WFNRKlWaqhyocqAiB6oGqyJbqplVDlQ5MBU5UDVYU1EqVZqqHKhyoCIHqgarIluqmVUOVDkwFTlQNVhTUSpVmqocqHKgIgeqBqsiW6qZVQ5UOTAVOVA1WFNRKlWaqhyocqAiB8znZSqWVDOrHKhyoMqBKcaBqoc1xQRSJafKgSoHKnNAn2Kqfl6mMm+quVUOVDkwBTngLm5sOXsK0lUlqcqBKgde7BzQ7yDxwXn+4+eJIn5o2e\/Sr3Hc9GLnS7X\/VQ5UOTD1OECAnRWgfiTD8fjxVZfv2V8bcFONY009WVUpqnKgygE4wPeWfe0M8oMX+u5yQ8Avsa6tcqbKgSoHqhyYihzQDw7zW7gedmoa9+uDsNb\/o6lIaJWmKgeqHKhywNkPD2YkP2\/m+8FQdZewqhNVDlQ58ILhgPsO1ogvGGqrhFY5UOXAi5IDOwnAt+NoVT2sF6X4q52ucuCFyYHqDuELU25VqqsceFFyoGqwXpRir3a6yoEXJgeqBuuFKbcq1VUOvCg5UDVYL0qxVztd5cALkwMjDJY7Mnn28XB0DVzeypUrA10PB74qjgNzIJWfkWMWOiOLQ9ohFt6V7spgpetKnjqIXE48qr2DkvGh1Ck3+AK4oX\/wy4VfK4PR5KqMNEZGo+HGe1ZdjasVK1bkuD8keWZxixjSGHqS7LH52brPx71hoAhsc9qkZKE+4ZA2bK4iVIzeuXSnt2TDhvCGOA4PljDhAG1EPf1V0\/PEgVSWVp6m1Wcri7S+cJYqdSOVc6WicfMOpc64yKZgQSqH8fglXo6Q0WS6IDlwJMkDt8bjYRtXKa1j6BkvfzK0Hk4YzY4yJmMIHK8RGa92pz1r2MYDHZEvBi9dujS3YcOGEs0dNgaPaKT6MGkOLFu2rGYiWUheQjaebmhGb1jbEK+KV5mBKPjRsJXysgRWKq+Ul60zVe9Ft2gbzQNL72T4ZWEPdB3NoxUnnDBtV01N1NPTM6S6o8sPhG+iOoeCazLtHQhG7QpmND\/NOayFCxce4xfDt1B6HJarlnd3cnzWoQa7X+C6j+87bPNib\/PGvs6HQWA8rMl0JAuzpKn13eC7iL9\/n7N17uVSdMp9i+9AHaiWT44D8FSzbiSDFO4f\/CjaexLf6Pjhxp6OeyyGpfOb3xe53gVoxC2b+rq+IqXIysrisPD2upJlzao4Li2dv2Bp7MVfotpAFAef29K3pVswSxobj3Oc4CPoUF0QON9a19m5DVwVZWzbWDZ\/wZLQi\/8K1dxVCrxvdnR07LVltt2pfh2PXpu\/uKXlZDd0voAsisWie0nH9o7t6pMm\/8fnbbuAoXkKQvvR+r6u3yufemOMv\/KVsmVLm5rOiGP\/g7gcJzmxezQ8fMAP3M9OxPcEy8h\/LZ26Lmls\/gBfczmT77n8eENf128s5OKmlj9Hj96MjbhhY2\/XLcq39SzM4bpOhNcsCYOh4h\/Fnvcjj9CD3oqGMOzKsNOFYjphFO3l21m3LWluvnJjd\/fvyBuh5OMQa5aZSVl85rS6+lcO5Ifc7a3bryZv7\/LlyzPl42CoZh8UB1gmmJlpcHCwvtZxLqwJco2FUqEHJGWDxbukZ02rq30Vsph+4oknXk7ZIH\/oCXJPUkUPeOfSpZKXE\/pOS43nnx1FseNH4TVkGYPlxX5L5Dl\/66NHpTD+Jfnb2traDD2qZ5MaamM5wzMYwpfm\/NxFxVJpyC8Wf0zeXtsHCz+Vr+oLLBvDrxF9LMULgyB3DgbF8WpK4rcxWLvn7K6F5RfU1OQWFwrFreQbg8V1onFhypa1trZGjvejmiBYWAxxcl2niNHyWL4cSf1thHjG8J38igkZGVmgC7WM+r+oq6l97WA+\/yjAxmCpL4sam\/+c\/D8dKgxJV4zBog1TryLSZ5FZiZ8WnTFYsece7WOoMEqFqBT+C4VbeTPaw9Py6cCRiGQRNuv1tbncOwrF0qsxWudhtG4HzjDPIste1cnsM8zcV4pCmcE90\/btM15aQ0MDj5WTra\/xUxni8OXatoTxYNuzdQ+13nPaJt5xKJ7HXjHLLQSzh7ff0XH3mbq6OjPYZCSIT5r7Zc3NL48i9zympAc29XX+s+qqn0wwRhZu7OTRFYfvExEacPNZ3DQ2QMk0j68Xjcgf9TBbo5cUua4QacDthR6Td+Mo2AM9HqoMhPfZ1pXclzQteIUTR++nS2s39fVcqzz46dEP0x8i2IOwyjx4TlDI9odxtj9CFlyzMjL1snAprTZm5cRh\/EYM\/UIM\/WOR514QuNGDxVIQRF4kQ+MobJOtP5l+zkHo\/Y47IJ1Bjlm5eshmyOQ7o+SdbWSCe9u+QMSf0aAqt\/mLG1tfxdT5XizQQ5u6O78nWFueGKzIHYhlXuJ4N2G8L2GM+rIIAfYWNba+Ll8qfrsmlzsZo\/WZBQsWyMvKq0z4NJO2t7fHWF3XaTNEaclXVlrXDW8qFuNBwoP3PfzEEwPCD3yo+gwEv3ntWgPbjde1lntwG4bLbRasjZXoPpuor7b9ffv2uRMZwNnQNnrDgKq+9fJoz7Sv9vYt3+dCg2JtIxhraRV96qfgoGUMXJY+ey86acv0pXlts9pSHw3+DF7FBss8s3V1zcCUeUOeoR96KtYbJn4kSkzV9cVSYTfLwrUswYxiPtDaKtoMz8PIe2d9bc0FQ4X87U1NTT9WbIQJvUY8ES1x6K+LvOInXMfLO2GwWXlKJQyOl4xRxw0T45OUJAoHz3zxjGu8kyGlRB8McTCSlUiFOqlsxXN4Y+hL6xm9yeZPxA\/KjJ6gdI6MpfRMOmdxqm6qw+LlMOsMlWP\/kZ7QDxWUMFbvq62pvWCoWLi1sbHxOvKG7j7xxBpn+3YTUwrD4EE\/KF2McS\/m3GKvKinl\/KfiglNn7k3\/zd34\/xADloyMwYtid64eIHTz5u6OX2Rrqa\/qg67SuVH9HMO3bF17LxT2nqvu0+csb9oNyDvhnfip8acxneWfHU8AmnEimrSrqYqrViXxT90rvs0lMeau84HaXO35+WL+d9S\/VmNf5VQtmooevrz8IXro+UXiVyQhtg1zlVK1L21s+Saz6jVYv9P8fHwyeWsQmjeeMbH1U1z3Aq8\/k5SnmxR3dkSVlVLlFjfgMoxCWWakzct2XHUmk8RkUKmt8doTiZrRkgHFQ3qfpXVEU6oATJk+W5jJz86itngED0RXJcMKWtE5ou00z9BPG6Y\/We8ED9nwWNJUY8CIh2rvbi76MymlrzyjAjzISAbOeaqnNwnkWsMmZdu8dfNjVNTSxqSmpqY6GbUADYIY0xhtJG1jINQuz6LdGLy0mrnQCkS5dIxqfPooLdNgq1hHtAKjsknxQ\/hUB3jJJdu+4ZvKlVJ85h5w27Z5Hv1Piq+MC4LyQk8jZX5t27ZNSycTp9oSb5HXc4XFo0Fs9Vpmmv8mldavX1\/2zqgyoHowzbSTRaC+ZvowQucokhyMHq1MY5JO+4jahho8vtFU2Wd7NZVoZ8w4En9SjOJjmU\/KE21cTB5gVh+jEX2L42IC5u62fLLlxmDR7fIgKwahydNsCEJ1zGV2DaSwKNXmxH13p7m+gnzG9YwXNy1oQ9leGrnRLVEQPFZTCN+KO7cCrPdt6O26TkQumteywvPclSBcu7m387fKU\/2TG09aXHKitzhetK7k+3fUlEqnsdJvg+XHoGYhPe8tlYJfAi6hl5VPnSXPMP7k5uY5cOBUL3JPRII1LIF4lKEnIocxplZNHMUbN\/Z1\/TrFYRS+iYFWH3tvoJw2nVmwoYCP0O2FcTuVO4GNrQHhOVbw1Ands6D8nhmlwQcGcnUr0beV0LnNm15\/DSD7ocsKUE2V6ZWS7mjqa+HjGAu9ODqBfh2Lss6Ap3glzuNh7Ny9ua\/zThmrbN+y+Ba2tLzMj5xXM8aPT5DHO+jjPZt6O+6mbVPP5I\/5J+E1MIZfSxoXvBRD8XrXix7S0p78eNH81lfz7dnlaBRfIHKXh2EIK92FBGE\/aNjI8tEPC7c\/3Nf39KJ5i473\/dKfgmyozglvxlg9oyblYTGARrS+vbXVjzs6kIfj4KWvpN8vdTxnX43n\/PtDnZ1PeghbAy+b5ElYBV3atOBt0LQA\/Xq8UOPfCKkyrMbYLJvf8hoU5OXQexxDBHLix0LPuWtLV9d9wIkfyD7xZLUhEDvBuejgk3uLQ7880q9vRF\/fBGdONG278Q4v8m5b39exkbqsVIf1K0ub7imPl85rfi3TPHx090D+KWbp7biLFs9v\/RDDhmxvfzFwb+mIO\/aKXy78omo+rg1u2hxv3ic8xRDqjXugp8oJOqyxdbRUD0PvDGI1\/UC\/EueBi9tsZISQYP+u\/WHhFhlL9UEYzQaJG50Jf+bileGlxDu92L2PgPoqYLQK8vAsBZqm1BaY2jbPXEcKlqzexsYgZqJaOH9hMx8wfn3sRsewxpc+2Y+ChmZDrxC+AX1bjGo0oFP9GMNNgRvLBjxhW5D+STfg3QAqsSThZ9yCk\/SXCCPHsnp3MLDvltRg2Wq4qXzrXU86d9U2u83ZuXOnN3v27GQ2ct0GOi6BFfQnOBkztxhdyMe1zimF4bl+Ma71gmB54AcOLt3tgFwnOI6cvZvl5CfyxcJNK133d6tSyytjFfjeP5RCZ3sQxR0EEs\/MBQkNmnoUK\/H98IMYvA9v3tq1xuBKjYKEuWh+y0dYmlxAh5Z4fExVXDUdcAJTVxO9vgJdiqPfAk6zsSxZpN2petf7v1iUPxat9Eqo1TcGXtSD4n1V8Zust8My5218Uvoy+rkJY7ULWb+GuJ76udUZHPw51ffbJaZBxj8ogwZNacf8ba9lQHwHpVrKx\/TZ3IBWmjTffwUgKpUGEc5V7oz6S6HBGD6yuY3DJgxrneN9noDih4MgmEV+OUHLviVNLd+PanOqt0\/b5xSO8B7KwOkNSvGOXJD7dKFUuo0syQg2OGcjw0uSQQAPsFhswrzU9YJ\/ps9OoVjcmw+CNwJ6n+cVT4fLV9ODfUUn9xB5DwpHNsFrw9DaWsVxHYcNm3OQyz\/T7lGFUvG6Ad\/7VwOPgBLOi4bkluMWxitY2tR6EWXfMvKL4q9aL2\/hCexq50pfRD0+gK5My7Ybh+GepU0tV9UXhi6DHwPp8gOD6Z8Oz78jHjUENfeETvQK+tWQ1JUsIulIN3R+clNv18\/Il5dSNhaCyz5HnvfOnO9\/FHzM4YZfhJK8FejgCt\/Lwa9Cfy7vvIJq650gXIFhvlr0xIWCPNstwjfJJHU28owi709yOf9zpk3pqZGRu9hDRr7nO4Rsdk7zpqnNbvX7id6tH4HoT\/m+fzy66vipjhP3Chc1tvz45NbWz4NrG\/pVQx0zqUySJgPGRDVEaGh24EVXMYbOKobxk7R3h8WxuLn5LD\/2\/g9j8xXQSLYkzcxCjCyM4rWL57d8gV3q\/xC878bn+EHAsplPITPm6Zv4eTL8vCaX9G1vmJuRxFRkTMUVxIa9CHcLgZ3hdG8TXyt9hx\/kGFzFXkL0JnYxc2DA76+p58QzjXruqzAwg\/zdGIaFLfA0swSMdSpaUs\/tTHebErxRrTEqnnciHdFs9\/swLP2e2eAp1KWVqeo9GIXlCOMyturfAYP3462AyAyCT4Lz63TMQXZ3hWF8J9k6hnEkxu6VlL0ST5CyaCMaeQV1jeDN9rvnX8vgOQPh5UsMIDr\/CCrawPA5i521lxVLxX9CeftR3uvVVppqwC1jsxgdZUqPb8UAP8z9w7n+\/l2CUTzJAuuq2Jqu8PY4z\/OXqj79\/AnxzYdZAOUZokwgzqtxBd\/NxsfFYf+gJoLPiFboN7ZXxirw\/M8IT7EU\/hajdwe+DCxyXkOdN9PXj8dDJWnERWvWrBmxBFCd0Ql6azQZMBpVxySm5+vR416U6igy3sYAWI4cu90w+q9CGNbR1janEDwmYGjTZrIGalCMwoo+QoSmClZ6xCbN62jtyppcDcaqcHsUBn\/T0btlr8rRSjYdkxSGOXML\/hjev4fcy5EFfS5e6w\/Uf0VQ8MRfPL\/56xjuv0wV+2ZYep+KoOyV0P0W+Pnp\/hoTG\/pMOVzguhzTQXau14BxehOye6gUltrRvW3UPRb5nFubq2lGnl9eMrdlHSR0pMa\/zE\/RJRqU4Ne16A1jwDsKRp6DHE6DH13o2m384ck4O4Ia50nBsv8QoDS6zfmhGbm6n2wa9nUi5wZo3oGeqs230ubLGfjbMdI3o\/91cGBrriFn2sRYfYi+ftPTZF0K72cs\/Qe7G4Po28vg4TkY+vPQ\/WnLXrLsf\/U82aPvejpPsByZAfJxCCvnU98YcsbjjFwp\/g7Bf4xVKQ9Pzt+At6\/68gYR7rW5XHACZzl2QOe\/wZPtyOBY6Pwzxt7yQli6llXDHxuP2PGuQ7d7aGQWY\/Dt9O0UfimnLwrdX9K3eups87zSLqOwBEqTqQ1FZqP6dBRsI2o0QxrgeKWaKPZOoBtvR0vVSXK9b3MWY4cIG5o1q+T2m61OWcZfu5H78Y1bO9erbFQaggBpVZ6dqbLg6TsBeKxuHG7FEv\/V+p7OW7P18HQeYEb+J+r9UdifX07ZHVrXLm5qanRi\/yK8MwxS6WvTjpn1+exgbZJXEvt\/78fuR6kzVAic\/+ZqEpuf5+X84IxisfQU0+j7NvV2ytMwadncuZcXY\/fKXC7355RfvPjExbdt2r7JGCO4ZGl9hMjLhZu6O35l6+maCnJYwTKF6qf6D\/NY\/gWX2rNLKciVeEkPMrF8DQN9Md7kTfImGR+RBM+i8ULDo6j0tVLO+0JHR2de9cDpMUv9LQb0iyjDhSzNb9rU03GHyo7AIuZZ1eh+TMJQJrQ4gynNMYr2AHD6wxtqrcP7wGCF9yNn8c8ktWdumMwV40ImgyjWCAOdgqILycA0y0\/Tq1mPAAAcOElEQVTX\/R6TznH5YvG3LJPe19mz5UkZAysvQySaZusubWz9H3TuuzV+wPHA0o\/mNM37K2t4lsxvOYuyv0SJBf6xjT2d37b11Bf48Vk8si\/Bnf9t+ahyFDwvgtFRBmf08c19PT+Av2XawXsbXtEN9HsR8\/+bqNKhgL7Fnb2mPCvzC9nNwos5LYpLazb2dH0kC6t7ms3HWDN0bSD0WEscRILGsgzTcWXGFueiINV\/eRiXNtBmWUZCnSzR3E94eMalUunHtW540QPpsl3lWrYyjr\/HeHtnOH3oFrJ+pPx0l7DcnvLGpNjJWZrC\/qFv4GW+C1xEA5x3b+jpuNnCYzMu5sjFCYzdhznD+Z6NfR0bbNmyua3fLcSln1K+AvleQv67NvZ23M9Vf5zna5mD6E+JitG6Db2d6P5wMkqiicfwxXWPwgO4kTl\/IxP4atb497EguxcF+Q9m+PNg+tOUvwfk31dMRmiM8YljRfCxbu6DWWNFXlkJkRa+DqLjpNtw88mdma4dZ0fd0Uf+RjmKG9m6vheyAxI\/gnSkdAtsXRZ6p9HkCfCqnw2pH1rllzIJRu4qW7zfZ2AWyHlpXclZoXydCoaOt+oevDcywI2x0kFL1V2\/bRs7pdHVMsz09TQ3KMjFTpLxLAz6XmusbHsCsIJMoUdcKEM\/1H\/W44Hxhpy0TcOPsBBcE8bRQxjSGrj2OltZywAG4AwGaFch8C63yyKVgzPyBuquoI8Pij9k\/Imth3dkCLXP2SsF4i+kuPqZN6OgTRh4C8P8aWhCeCNwsNxNZJfs0dj6I2CEQxlMFE+wXDgCHv5TbVCzkJ3ltUHknt9J3Cr1XGxzBl513Hp358mNjYsh6Pso80yU+WYM3EUyVtCb6KoT\/7GWiHiJd7rT664WEi1\/hFN9wWG7Bl71Bp53BCvvN5YbEX7j5cT7mHh+DagxHOmS0ZmzdV47IHdJF2m\/RfUEY9vVs01qx+q\/8tD7hC\/JQsWAqR5\/Jh9wnA8S46SGoWLxHOxV+mLr4GGzxyFej\/WI8ETOgEct8O9JpPsta6wsPUyG14LnRoVCoOmNFu\/+hgbbD9tM9kpDRkqKn2FUWv8Om3A+SzdR8CEmjn9XF1V28rwF8C9uM5Oi6\/7jhtRYoQ+1Kl+\/rbMTZlybTJrxmThI85VfTgzu9H4Mr8oGRQAwlhnF7eVvM7Q9wnULTOngbxdlPLrTYVSzCLPR+xRxctHpeJIMjv7asgKUXElQYK66H06oNa5dfvduLUecu9kSbksOpTnETQao8WTCrLgcv8HNnmH44zr7PQ61qt6pxx47XdufMkp6ptfPUHcvdIupZkAO1NbOpq1WLSeIQ5S9OS1d6KOhrej793LXzfICFHGjcGUTxjdoaWmZqTy1J35ky8e9T3vuFlmekPL5vKmn+lse3fIUfdwkBnFdXMbhOgu15IVD92CsdipfCqaBRjVv\/ZPr9zNgzNKbXi5RXrnu+DeJLEBqQY4++ujyzK\/JRfkYNN8q2Wgjk9RL+GVx6Er7Pr7EIJPdQtaLV9XV5FawDHyE9fN567Z2dKlcy+bR3guk7HPz4atC1\/8Bsc7jMXCrCr5zPn3eKxqkm9QVvxal7d1hwxYyaHbCWt\/T8zhE3CueQU1TCiv+wR7zROdyOlzpCK9itLpvd9rRfedx6Rn\/HaG8NBkZ2Qd7Bb7MLwZ9wi8MU1Nq+BsbG42MLXx6LfN7VP6kHvUurwWEH6ZN+uRLNilvbPFJMrzQtW5WlN+oTOlMGwyR3lAXPPFdRt1dZ0FxT5GTHoQbisVxdQdY3HU0jY0wPPCPIonLNJTRgAs39XT+UPWJZ5s+I\/tGil6iGBuxqfIYy062fOv4t4pTCc4tOfNU3yZaMbMGjXl2YrATi\/GS6CwBVpZlrruLA3\/vXd\/d\/dCiRYsagt1BPNgw6KMtRxICezsgX5G7jdutwf85NTA0NEQ2zWaSDVSDd1wGZMDTW9cp5AMjkDlz5pTatxsFcgjaRlFpkD4AZjbUEnAyHlcQhVlzDkwjCOzseOjxx431574gKObHk6HgGIwTXfPMso6Iez3xbnYSwRA7r13UvIBrNB0lZSMxZu52B4LYOYb2YL665Y0I6govya3fV29oJUCsIP6I\/icgFf5VH4C0y6iZM2fS5PCyhEIZWJoeNszkmcFFVRObEFa9AyhMtl36Ycro0ZHLjz9esmHpKgiJ5uATlZL+YCRO7+wywVgZmbKHVUY5Er3vR3jqnM3S75y4zqUYjVNYBnYwdt7HUn99qg8iO1qJdyc0cC4dCO4xPFzBQFuMgfsdq9m\/6OzsflITH8I1NDQ2NireWU991VzI615nc0N8wRgjEaNzgeCNjxcMA3as7BB0yS3JODmnd3YavLoXTSxFdEsC30EkWjL4VLGxt9Hg1ATQ29t7EFgODpR+Jm0ybJGNOeNkMUC80Rm49PTd27eb8IE2MugjGpHqBLFg8YiuTnf9fCXjatGZKzjxC5jkHeds7k+UBAgZfJoY75UCkNHEezbxvtQ5MDzEAXs7cupGRvUGEf8ggkH+FvOnGFGA\/9lgy9IrLOWOStYx0vkulRmlUc\/NfETQHQOwWwWbNydbr7on7eHvG7iBdSjhl9hFO4\/jCNev631kU39\/v1dPKNNAZf4pMyaTN\/GtWJAkGUF7P+JqhUSmN1h\/TzR96BcY2reVXOfyJc2tx\/gl985C7A3VuFFd5IZskXqXssRi+7h4p9dfa9b+2gXl3TXiGewtOs4lNHSJDLqSjLYxF3AqmaFFU1xJmFg2vQTgOG2qMNmUdlF6Y6uIT1Kk9NlebbGEZohDgkZgaYGtb+GNUoIpIKaYdGYYw7O5c3e2tdm2DogH68uOu5OHNwS241PEz1IU37yeYwaqzAyc0yyrPr9DPSP58IIbTTzagdZykCfeV+tJDi\/jUrrt6S4Zy3\/MEYdOYBe4zwXNuQI3IhhBpVmBqWCswRI0jFLhTme8viXlgplkGm69bZI1DhdYMrTVvunTaLTwyhpTsb1cLFFJc+E+sYPJ9dfw3fEWaTeekAMrL\/NWjPFUU7kO657r5pFRLVR9I2l3NHmMP2YyLQtDN0q8xTJ1FW9MH43Bsq3Qd14QcI21k7ssD8Aaj2TJ5NxKbOdL9PtEXLqTQbtJSuT4lcZ0xUafXWYiHINDSyECjw8wSN5WwysKdPxHJS8cwpfcz6q6nm3U6exassNU2ohB+pTgVbHolbSBxc6WAv3R9XDhYVhprb+4ChNcJgZORpmXv91fmwbH+QdferQkxoEUZv5GQaMEo3IMiCAPlLL1hkVY9sMOVH2S5e2ThAMMBytEL+rhK7O5sxqXlbM18QVsb\/9uU3f3L61SaxCtTEcPQSJFxOTe7mLwENvwzkDMnyAwfA\/HStbSfNTGmUDQ8+KJVjPEhpArVqud+fU28hUXsZzVFRLY28QbAHQNzyZNdlBa+Bf41eiP2Jrth3SNvOEySnkYCZStMOpeVWHsGmLZcxHCAuLbn8cD\/mgHZ+PSkEF5UqWpnHSd\/7+DSHaASnKy9GiM4eYyxtjIKhV9s9kzqrmKj8ZgZUvCIDIurdw7GjXWeWXqvmMxWYPxOg6NYygqzl5ZXM\/l\/ZKWFg4TOh+Axv3FSGdy4ia4r3eQpsGVRxk0vbzp1s4Rjp+t7+rcCrOTg6ZRDV+goIt0ggN0P9nQ0\/lfzyWdI3BbcWUyoWvYw2KX1hTxCkIGZEj39Gu6zWvjsd30oKwAZpJB+oP5mflM3QoNWiSTusIkGhs\/CT8wadLBUWyJjjkwa8dfoexdHGV4P8vCq9gtfDTdCVKXZWANcYwBxaZwqqJ9VP8Uq\/yvcrzgVdS5muMnb0W+O4i\/GD1tbGwssV1v4Km+alNP19ds2+Nd1Zb0WE2MB3MY8su47TGWw4DzWaBI3veDqFrFftIdVvFdwtKf\/Fp2sYwQrAc2cXuEjfCcdUToVk4J9DEdcD4v+PD6xuZeKn5dMcQ03ol9MEs98X2IKPA\/4GFvnRi5YzZOUjqzoIZm8JT5mxqs4SVKECrQ7DiKVwi6zSwJ2gyS2Asb6CfGitMRrvuMyZzkP7Q4rNmTrDMRGFb+eLyoJmjZ4zv+7et7HnlwPHjTj\/TNctaDe5ycuxPjeySuqAK4\/0W58VASxTZCVUzDMIkyVi3ZOFPSCuv3Q+6Plk7CsmvXLr0LqNuiaCQ2eLxRovRUvwqYEh+Tq4cxWig6ReN2To8vnzlT7RtlQ3oLBQvRj9ojD+b5MPxjg9LogcdgHIVxLAvEK3hbL6X248JfF4rO8ppcsJSzVN9dOHfhuZQ\/qgDw7A0bRg0Ud0bR9x7kJd4Pc7ygnXM6K0LO+DAI3ivPTA1LoYmHPG6IiJ2TLDFWRuKhzaOdspLbvOfjalcke\/bs8Vj2jurj80GBGWiPJuY5nv9UX9\/RtPoEy\/FAh3jtRgUrkcYk7OE+7pdKZtOKJRqnAlO2GQ0dQa\/lZ61OCRAeaoTDf0trX0MmfewS\/quNYXHmaiervQHwTyOs3gwW4zAIG2LRhGPkNEJG7Sotp7IcyRElIV62rnwMRP8ytenKVM\/RhyHFqxxZTBCGUhIFvkwjkft+bSmTtrJnYHYfjJtuDLVhlO2UYEYkKKAMfozIzTxMPANqxKp6GT9MXofRusVzPCLX4S0ETG+HiZdxfcuiefOOz2BObtuSi85U0a\/VibCcs5vY1eEZG5J4k1xNytQfJjl1sdUXG8PKwE14a5YkqohHwQra8FhHL+zuFh7Iyyk9Q0sZjFZ5KQPSu3DDyYpXLp3f0qZGNIDL9fhSANJ7PUQT1yl\/nkRgaqvML5OR\/ScpqVhOJpSSWFFbBZceNKxdOwJeriF6MTKPZpXBUZOX6DUeYD7GifqdHC48ww\/Cb4jfwtnLax2mDf4RvP74vMzRm7q61tGRj3NA0mGT9tygGH\/JwiXX+G41gMq\/UW8rKA8yzFLECC79J1PH9MUsGwzwBDxJx0Gm7mRvTRvwomT5JRndWDZYlkf2mkErGanzh5oyMi7v5LrRA0wQzIreqWHk\/6lQix5LG6+YnUST58Aq9XiNOcoDjP2KiiFlWOvNo\/5JB6FZWXFC\/XN8feUX6XGaf9QXFsBnahVznCzghIFsBfJ\/j6k78Rgrt6Eb6phPW6C\/xgYpzwbfjdJgbYExoDnPy53Gu09OkOOtQg4BERlr4CM7vCPV\/G4scNJJx\/3Jxq5Ojj04zvTp0yM+FJcyPcGi\/DEJxqZyGS0eUxeJj85PUCgmw2EKPWRhxGTeM\/seTDoLo3kctB7H7tsbJQRSP4f57meBcmvkR\/9GnmiV0TUeCmvBf+GMynt5ReZ1fFzlGj4P8p1c4GzHarHg5QOGvFtRdMDHM+9CraaudS0O3E+1XiFRUQFpKUg9AbLlHFDtdwLOQpdKhTCoO4UgzmV4FUcVwuJDvhOtsihKgfvzXCm6gLIz2Dy4mhPgX6AXd6qcNxxexqHRz9P\/GZxm3uh78c9tvX6+NFKjTWMSg9tcbdkwH61IbElypdwKdJ4OIeqQqzkqsnx5ebmZIhyBN8UCu3EhvcSI6CNwi5pa\/gZ+X8u5nXdNi+Ie4D4jYy14G1uCROLztTTtOBu7O\/+F+GQz1F2Kt3YJsuzmcORVKuOk+C9Cp\/QxliPzi3Hpe0xQX0GeG4oFSnyvxvUZLqF3DHHhI1jFPAApiUemygkbKtFsSgVgBWwzJnkdoh0ZzlYdaN7U09N76rGnagmvPpbjOnQ2RT+MVbJICEp0fLjkgHdjaLXeXcH3V3Mo7f8Fgf9ujiowiTfXRk7NLbWlsBjm4mW0dAn6dBLx3cfg\/022pd25XDRDTIKg0RMRMCmZyWqAvsaLGhv\/muOKJ3DIejkHRK\/i+ezNvb09XV1de9DTnwByOrr3IeT3NMp\/fbGYeypXU+J1WEfva9VhdI7ldcrBR7Z2S5+zfDIeH5w5nteH5rKkfLSRYyLSGeMuUbkWxcc2uUdz\/2+8K7aOwcDZHn81J9fvc\/3gBjp4DgNar8BcMeiGxCeSZA6Ouu4M43mxRWrz06tRQN1TdZrWwHBihmVsClOnurR7RDSN0MeoVDqKoH7sHJHC2OA4Z65OnQ5nzyM\/IPB\/DTb3FRztvxD6fkYbHM\/wXosCf5nV9O\/wXj4otDDQzAAEgH\/F06f1yCsKzADx3cVStCYM49VhEK\/hPbPVOd\/7De7Dv3oDpfmWJJhVb\/rpOg3hMcmScKfG3CQSxl7bigUCxjOg46eRX\/tIGPt3RkHN\/XRwFfx9DQq0iyjhJ3WWCIVxVxI7ZGbci928GC+lGy9lAUb5OhzjtRwZXcNJ5xvJO5n+70D4F63r7n7CnlsxJzngqXhOu3VZEvHXptl+2Hydi6LJVB\/iB3UgkLZewUHM25k9uwZq6m7d\/+TTpwoeeusp0+2RHHQve0qeHymMMB26ICdxxXl2N\/d0\/QAivqyRwPuKn17auOCzyhcCbGoZF1mQmqTNvd1f1CtM5sCw6313yfwF\/1Ml5iyX432MPu\/mtZ1Xs7v4n+JHLohW+25pDZPU6sB3f8\/sfAsvO5+RokMlIkRqeHGkH6W7Um22NLlC33SMKlQOxwtHQgw\/IcPy4VF6sha9c6CVF\/79X+PpdxTr+m9fPLdlsWqAry7lVwNjyDBO+WF0jDqMjKT\/cVZGFXUqq2vUqxet6L2JXwqfjrvAQ1\/eFCugS\/GyVgdB7lhCJ1d6TvH+Yo6AOSEQdO0NlA0gx0\/pDQd7xkkn3REcYxkecPxHOMtJ+YY37jT1XfkyTtxchG4+WZerYVc4uH5ZS8s8lc0KC1fBk2u0E8jk8ilOvq\/mhfk1LBbYjHHuw66s8d3gV5idK3R+Szih3fAmihiDGCDaW4FBbOd94Q7eWvnNknmty1Lmefcy2FcRD+qA+TpoyRFYV64f25LxbpZcq3nv59s4kCt5VeNiWTrrfmppAtfv4ttJvajyQyI2k4yBMM+8b8fXCrcimtU6E2Jh6HqHzuqAYxXvJZpzVLM3zFY9w5QZM2YMcfP7wXyhGy9ks62XnzbwBjp4Nkzp54To1zf0PHIvr9hcCX3nhgVeK4l5lScs\/SednoNb8496n011JVBdmbG\/Do\/+BMX\/GY\/bKEFAfIWC3QueH8fdvQ\/pfZ8TEI8JXgmiNvMlxh5Y+3teCDceQnvZ7Tcg4\/+Dk0vSNpe8CglaZzdeQptHkdfDDPUD7s\/a2Gc+jCg8HM6NzVKcft0Ve9Fb8LC+xWn4zfiBencTIUcdig0RPn3z8Ods2w0N9Iu4j3sHLy1vxE02y3dTIMRxtG4on++FBuOppfniuRkoQ\/rqRhx9BqPVg1LzXiZxiNidgfIJhhVb9BgKdS8adhtT9lNpfWq7Oxh4txOYvQtIxpfjNHJ2Std9Yf7L1LmCpV4fMCtQ7BOVzzTZjXe4FgNze5gLzU6uYlzwhNcMo0\/Cl5+y9O9lAL5m7ty5ZhAlr4B4b0In8bCjDvGDtnEO1Ld4t94YoI0f8qbDJuUpwckd8l6R\/235YmBo5mwPW43tpk8JlHv\/YCEvXbg\/eTb\/wqbKydblNP7PEevn6HcXBDDpx03QpIPNpi6e7zbK7oaKX5Uirxz7rZtXl8iIg7VMsGXdprWKbbZndI2h\/fBgocD5JudO8SqlUPVMjIil9SO85vln6MFlYRw+nJRjbJy4D535CbtnZ+lLKsq3GwXNjz2m15fuZJz2IeQtSR2IAT\/yWa3xC3\/LY1xn5KSb6MfH+BbYfUDOKsXeaap3F1+MGHSjj5ai6Dxo+DVlTyMjnAyNM16TcuJe9OG\/0ePriH0VVIeYn9G\/oGHaLzBaf8eqqRv9mwVsI3zVRC+DmvCmidgCHJ5JFp5jyGoocc9zXmGAdd9uu\/4VYgSRLK30QJLx2r9\/f91xxx03qFhHkjvyX838fAFCs0hhFC6f0+L1nPouamYYWSt50u5D7Z7a3OydG4bamZigmZdjWy\/hPcK\/h9Y1vF\/3GtUVHTa2o5o6jV4bunfiGi9lSfJZdpW+qnzRYtfEesbCv8Qv+kbha3JhkS9v71+3deszakfl9Fd8Mp+a2QitZI3og2DGS5YmXORzGPA3IXoGi\/vmfeHQpmlBMN+Na\/OcZNxr31cUHtve6Hs9q0+5MMTI1XLIZehpxYmUr5Stp+cmZDq9f3qwYeeGAci3Sk3\/3WDHwoX1LCXLcQ3BK2VxwPfZtUPxTPLiApsVjzz2iOJ\/ZiY8Zc6cet4ji9c8+uhAUjP591UYlX5OTOsjjYJNcRp9EW7qTds\/fXowa9asATPZpXlajuizKBYX2baOv3Q2+jEz76HYMmhCmygtD6c3NR3Jt1Rm5aIcvl5YCvO5\/objGvZYPVCbghe+U+acUr87t3tEO7Y9Xa0ea5K09bPlle4tfpVl+VWKgmc2P7p5d9q26ffoPqZ1iIXX6sdZ9EmY4WVRpcYyebRrxg1ZY3RRNAlUbeuqQ+BuPn80X47yh2qdvYwVM5moDNARY1mTBQamdvRYrpSfrStdQ79rCyTJMVvGPS+sz39JMcrxJVoF9nkXtS7aBx3J0k+EpAlYIy89ip+YdJb2XlxE\/8TPssGyFSa6Chnl6uC4jM02OBEulR0MrMUlq66T9KzLP8Ly4krNank\/Xq51s4WxV+Ff3Nh8f+AFp3H04TN2G5xs65ZLpmXlt\/UO59UaLJYJf0a7P2NJ8FQu9s94OP3hhmxbli5IKhsXlZMvvktWI\/Jt3fHq2XJdhWOyfZ0IdqKybHuj26TeiIExunx03bR8TB2br+t4\/FDZ85km4slEZaNpPBjY0XVHPwsXeRPpzITlo\/GN90wzFWUkeMoq7rCPh8vmi\/bxdNUMXAGsZNblohjEmD8ZCeULIYjGGCvKvJV4LbqO11AWxhIm2Ey+wW\/LsldgfIv\/xnKBfzcu417W2y01kftFBTvliclA6KqP+vHh\/M9D0mn6ljyxrDWqCi4JSk2bwW\/7Rna538pbmfJDdWwCxvZzXFot7Ogrrrjalc\/rluLQ7LQ0MSsJp9rTH8VlurL1lakyYA2crtn78eoJJuXbCAUg3\/bDGu5sc4YIwfCnduxV9waPrivhT8o70y8hUH6GdyPaFL8p9kWPrad+kQeuJG8EETxk6wBW5rnyVSw8KS7RVv6z+ITb4tS98rkIrpxvy3Ule0K+ZGGz92k\/yu2rjbF9HMuvtE0\/pWvcsZNty95naC3zxZbpKppIhucZHhlZ6jmFGTMBZvCO0I3x8tM24FvyQ7GCs3RQpuNP6Pc7R\/CGPPOsOln4TD1jF1K6R+ifCZiqZwBXXMpZJBNdRTTlYzqfrTMezHj5o+qWjSQdNMqmQ4jsPlxKnOpyAucXEZx7L1vgWwZ2Pb0\/R5CZtXQzS8YTTdfi+HJiPKyjTdJAMrRyVb\/LuNPycS9pvQn7OV5l6pqTFFQuv66vHdYU53jVyvnAHRStqkiVin1L25ywHylMuf3sDWUV9SXNr9jmePSMh8u2R3lFfAdqy9a31wO1k9InnkzIF4tv9HU8OlO8FfmVllXs32j8o59pb1K0TkTXaJwpPRXxTtTeJMoqNTVhXopzDEx5h2dMyRTNoCNmVtaVwPk3+ezuw3xq9v1YsTexy8lJdxl4nX+LnsYDu5mHn27q6zaOmYwd1Q5JIZ8tOzhW\/DTBN5atcR8vBpm1e\/a7YM8Wf7V+lQMvBg78fxAN2T5iTbNnAAAAAElFTkSuQmCC' \/><\/a><\/div>\n <h2>Oj, det ser ut som om tjenesten for tiden er utilgjengelig.<\/h2>\n <p>Straks tilbake!<\/p>\n <\/div>\n <\/div>\n <\/body>\n <\/html>\n \"};\n\n }\n\n return(deliver);\n}\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'modules\/varnish\/templates\/fastly.vcl_error.vcl' did not match any file(s) known to git\n","license":"bsd-3-clause","lang":"VCL"} {"commit":"8c32cedd8585a704567a9ae45049917f81938abf","subject":"Fixed Set-Cookie causing cache misses.","message":"Fixed Set-Cookie causing cache misses.\n","repos":"colstrom\/ansible-varnish,telusdigital\/ansible-varnish,gotofbi\/ansible-varnish,gotofbi\/ansible-varnish,killerwails\/ansible-varnish,noqcks\/ansible-varnish,kkwoker\/ansible-varnish,killerwails\/ansible-varnish","old_file":"templates\/etc\/varnish\/default.vcl","new_file":"templates\/etc\/varnish\/default.vcl","new_contents":"vcl 4.0;\n\nimport directors;\nimport std;\n\n###\n# Varnish Documentation\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-built-in-subs.html\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/reference\/vcl.html\n##\n\n{% for backend in varnish_backend_hosts %}\nbackend application_{{ loop.index }} {\n .host = \"{{ backend }}\";\n .port = \"{{ varnish_backend_port }}\";\n{% if varnish_health_checks_enabled %}\n .probe = {\n .url = \"{{ varnish_health_check_url }}\";\n .interval = {{ varnish_health_check_interval }};\n .timeout = {{ varnish_health_check_timeout }};\n .window = {{ varnish_health_check_window }};\n .threshold = {{ varnish_health_check_threshold }};\n }\n{% endif %}\n}\n{% endfor %}\n\n###\n# vcl_init\n# Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n###\n# The vcl_init subroutine may terminate with calling return() with one of the following keywords:\n#\n# ok\n# Normal return, VCL continues loading.\n##\n\nsub vcl_init {\n new application = directors.round_robin();\n{% for backend in varnish_backend_hosts %}\n application.add_backend(application_{{ loop.index }});\n{% endfor %}\n}\n\n###\n# vcl_recv\n# Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use. \n# It is also used to modify the request\n###\n# The vcl_recv subroutine may terminate with calling return() on one of the following keywords:\n#\n# synth(status code, reason)\n# Return a synthetic object with the specified status code to the client and abandon the request.\n# pass\n# Switch to pass mode. Control will eventually pass to vcl_pass.\n# pipe\n# Switch to pipe mode. Control will eventually pass to vcl_pipe.\n# hash\n# Continue processing the object as a potential candidate for caching. Passes the control over to vcl_hash.\n# purge\n# Purge the object and it's variants. Control passes through vcl_hash to vcl_purge.\n#\n\nsub vcl_recv {\n set req.backend_hint = application.backend();\n\n ###\n # Avoid processing uncacheable requests\n ###\n\n if (req.http.Authorization) {\n set req.http.X-Passthrough-Reason = \"No Caching Authenticated Content\";\n return (pass);\n }\n\n{% if varnish_uri_blacklist_enabled %}\n if ((req.url ~ \"{{ varnish_uri_blacklist_regexp }}\")) {\n set req.http.X-Passthrough-Reason = \"Path in Blacklist\";\n return(pass);\n }\n{% endif %}\n\n{% if varnish_diagnostic_headers_forwarded_for %}\n ###\n # Inject X-Forwarded-For headers, but only once.\n ###\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n{% endif %}\n\n{% if varnish_header_sanitization_enabled %}\n ###\n # Header Sanitization\n ###\n\n{% if varnish_header_sanitization_discard_host_port %}\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n{% endif %}\n\n{% if varnish_header_sanitization_normalize_accept_encoding %}\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n{% endif %}\n\n{% endif %}\n\n{% if varnish_cookie_sanitization_enabled %}\n ###\n # Cookie Sanitization\n ###\n set req.http.X-Cookie-Unmodified = req.http.Cookie;\n\n{% for cookie in varnish_cookie_sanitization_blacklist %}\n set req.http.Cookie = regsuball(req.http.Cookie, \"{{ cookie }}=[^;]+(; )?\", \"\");\n{% endfor %}\n\n ### General Cleanup\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n set req.http.X-Cookie-Sanitized = req.http.Cookie;\n{% endif %}\n\n{% if varnish_uri_sanitization_enabled %}\n ###\n # URI Sanitization\n ###\n \n if (req.url ~ \"(\\?|&){{ varnish_uri_sanitization_regexp }}=\") {\n set req.url = regsuball(req.url, \"&{{ varnish_uri_sanitization_regexp }}=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?{{ varnish_uri_sanitization_regexp }}=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n{% endif %}\n\n{% if varnish_workaround_telusdotcom_browser_profile %}\n ###\n # Workaround and Diagnostics for BrowserProfile and Language\/Region Detection on TELUS.com\n ###\n\n if (req.http.Cookie ~ \"BrowserProfile\") {\n set req.http.X-BrowserProfile = regsuball(req.http.Cookie, \"(.*)BrowserProfile=([^;]*)(.*)\", \"\\2\");\n if (req.http.X-BrowserProfile ~ \"language\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.X-BrowserProfile, \"(.*)language\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n set req.http.X-Language-Found = \"YES:BrowserProfile\";\n }\n if (req.http.X-BrowserProfile ~ \"region\") {\n set req.http.X-Region = std.tolower(regsuball(regsuball(req.http.X-BrowserProfile, \"geo\\\\.\\:{(.*)\\}\", \"\"), \"(.*)region\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n set req.http.X-Region-Found = \"YES:BrowserProfile\";\n }\n if (req.http.X-BrowserProfile ~ \"geo\") {\n set req.http.X-BrowserProfile-Geolocation = regsuball(req.http.X-BrowserProfile, \"(.*)geo..:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n set req.http.X-BrowserProfile-Geolocation-Found = \"YES\";\n\n if (req.http.X-BrowserProfile-Geolocation ~ \"country\") {\n set req.http.X-BrowserProfile-Geolocation-Country = regsuball(req.http.X-BrowserProfile-Geolocation, \"(.*)country\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-BrowserProfile-Geolocation ~ \"region\") {\n set req.http.X-BrowserProfile-Geolocation-Region = regsuball(req.http.X-BrowserProfile-Geolocation, \"(.*)region\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-BrowserProfile-Geolocation ~ \"city\") {\n set req.http.X-BrowserProfile-Geolocation-City = regsuball(req.http.X-BrowserProfile-Geolocation, \"(.*)city\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-BrowserProfile-Geolocation ~ \"isp\") {\n set req.http.X-BrowserProfile-Geolocation-ISP = regsuball(req.http.X-BrowserProfile-Geolocation, \"(.*)isp\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n } else {\n set req.http.X-BrowserProfile-Geolocation-Found = \"NO\";\n }\n }\n\n if (!req.http.X-Language) {\n if (req.http.Cookie ~ \"lang=\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.Cookie, \"(.*)lang=([^;]*)(.*)\", \"\\2\"));\n set req.http.X-Language-Found = \"YES:lang\";\n } else {\n set req.http.X-Language = \"en\";\n set req.http.X-Language-Found = \"NO\";\n }\n }\n\n if (!req.http.X-Region) {\n if (req.http.Cookie ~ \"prov=\") {\n set req.http.X-Region = std.tolower(regsuball(req.http.Cookie, \"(.*)prov=([^;]*)(.*)\", \"\\2\"));\n set req.http.X-Region-Found = \"YES:prov\";\n } else {\n set req.http.X-Region = \"bc\";\n set req.http.X-Region-Found = \"NO\";\n }\n }\n\n if (req.url ~ \"\/(en|fr)\/\") {\n if (req.url ~ \"\/en\/\" && req.http.X-Language != \"en\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Language (Path: \/en\/) vs (Cookie: \" + req.http.X-Language + \")\";\n return(pass);\n }\n if (req.url ~ \"\/fr\/\" && req.http.X-Language != \"fr\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Language (Path: \/fr\/) vs (Cookie: \" + req.http.X-Language + \")\";\n return(pass);\n }\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Language)\";\n return(pass);\n }\n\n if (req.url ~ \"\/(ab|bc|mb|nb|nl|ns|nt|nu|on|pe|qc|sk|yt)\/\") {\n {% for province in ['ab', 'bc', 'mb', 'nb', 'nl', 'ns', 'nt', 'nu', 'on', 'pe', 'qc', 'sk', 'yt'] %}\n if (req.url ~ \"\/{{ province }}\/\" && req.http.X-Region != \"{{ province }}\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Region (Path: \/{{ province }}\/) vs (Cookie: \" + req.http.X-Region + \")\";\n return(pass);\n }\n {% endfor %}\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Province)\";\n return(pass);\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_discard_from_client %}\n unset req.http.Cookie;\n{% endif %}\n}\n\n###\n# vcl_hit\n# Called when a cache lookup is successful.\n###\n# The vcl_hit subroutine may terminate with calling return() with one of the following keywords:\n#\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n# deliver\n# Deliver the object. Control passes to vcl_deliver.\n# synth(status code, reason)\n# Return the specified status code to the client and abandon the request.\n###\n\nsub vcl_hit {\n if (obj.ttl > 0s) {\n return (deliver);\n }\n{% if varnish_health_checks_enabled %}\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (fetch);\n }\n{% else %}\n if (obj.ttl + obj.grace > 0s) {\n return (deliver);\n }\n\n return (fetch);\n{% endif %}\n}\n\n###\n# vcl_backend_response\n# Called after the response headers has been successfully retrieved from the backend.\n###\n# The vcl_backend_response subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Possibly insert the object into the cache, then deliver it to the Control will eventually pass to vcl_deliver.\n# abandon\n# Abandon the backend request and generates an error.\n# retry\n# Retry the backend transaction. Increases the retries counter. If the number of retries is higher than max_retries Varnish emits a guru meditation error.\n###\n\nsub vcl_backend_response {\n{% if varnish_workaround_telusdotcom_browser_profile %}\n if (bereq.http.X-Language) {\n set beresp.http.X-Language = bereq.http.X-Language;\n# if (bereq.http.X-Language-Found) {\n# set beresp.http.X-Language-Found = bereq.http.X-Language-Found;\n# }\n }\n if (bereq.http.X-Region) {\n set beresp.http.X-Region = bereq.http.X-Region;\n# if (bereq.http.X-Region-Found) {\n# set beresp.http.X-Region-Found = bereq.http.X-Region-Found;\n# }\n }\n{% endif %}\n\n{% if varnish_uri_blacklist_enabled %}\n if (bereq.url ~ \"{{ varnish_uri_blacklist_regexp }}\") {\n set beresp.http.X-Cacheable = \"NO:Path in Blacklist\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n if (bereq.http.X-Passthrough-Reason) {\n{% if varnish_diagnostic_headers_passthrough_reason %}\n set beresp.http.X-Passthrough-Reason = bereq.http.X-Passthrough-Reason;\n{% endif %}\n return(deliver);\n } else {\n{% if varnish_cookie_sanitization_discard_from_server %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n }\n }\n{% else %}\n{% if varnish_cookie_sanitization_discard_from_server %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n{% endif %}\n\n{% if varnish_diagnostic_headers_enabled %}\n if (bereq.http.Cookie) {\n set beresp.http.X-Cacheable = \"NO:Cookie in Request\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO:Set-Cookie in Response\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.X-No-Cache) {\n set beresp.http.X-Cacheable = \"NO:X-No-Cache\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.ttl <= 0s) {\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n{% endif %}\n\n set beresp.grace = {{ varnish_grace_period }};\n}\n\n###\n# vcl_deliver\n# Called before a cached object is delivered to the client.\n###\n# The vcl_deliver subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Deliver the object to the client.\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n###\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n","old_contents":"vcl 4.0;\n\nimport directors;\nimport std;\n\n###\n# Varnish Documentation\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/vcl-built-in-subs.html\n# https:\/\/www.varnish-cache.org\/docs\/trunk\/reference\/vcl.html\n##\n\n{% for backend in varnish_backend_hosts %}\nbackend application_{{ loop.index }} {\n .host = \"{{ backend }}\";\n .port = \"{{ varnish_backend_port }}\";\n{% if varnish_health_checks_enabled %}\n .probe = {\n .url = \"{{ varnish_health_check_url }}\";\n .interval = {{ varnish_health_check_interval }};\n .timeout = {{ varnish_health_check_timeout }};\n .window = {{ varnish_health_check_window }};\n .threshold = {{ varnish_health_check_threshold }};\n }\n{% endif %}\n}\n{% endfor %}\n\n###\n# vcl_init\n# Called when VCL is loaded, before any requests pass through it. Typically used to initialize VMODs.\n###\n# The vcl_init subroutine may terminate with calling return() with one of the following keywords:\n#\n# ok\n# Normal return, VCL continues loading.\n##\n\nsub vcl_init {\n new application = directors.round_robin();\n{% for backend in varnish_backend_hosts %}\n application.add_backend(application_{{ loop.index }});\n{% endfor %}\n}\n\n###\n# vcl_recv\n# Called at the beginning of a request, after the complete request has been received and parsed.\n# Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use. \n# It is also used to modify the request\n###\n# The vcl_recv subroutine may terminate with calling return() on one of the following keywords:\n#\n# synth(status code, reason)\n# Return a synthetic object with the specified status code to the client and abandon the request.\n# pass\n# Switch to pass mode. Control will eventually pass to vcl_pass.\n# pipe\n# Switch to pipe mode. Control will eventually pass to vcl_pipe.\n# hash\n# Continue processing the object as a potential candidate for caching. Passes the control over to vcl_hash.\n# purge\n# Purge the object and it's variants. Control passes through vcl_hash to vcl_purge.\n#\n\nsub vcl_recv {\n set req.backend_hint = application.backend();\n\n ###\n # Avoid processing uncacheable requests\n ###\n\n if (req.http.Authorization) {\n set req.http.X-Passthrough-Reason = \"No Caching Authenticated Content\";\n return (pass);\n }\n\n{% if varnish_uri_blacklist_enabled %}\n if ((req.url ~ \"{{ varnish_uri_blacklist_regexp }}\")) {\n set req.http.X-Passthrough-Reason = \"Path in Blacklist\";\n return(pass);\n }\n{% endif %}\n\n{% if varnish_diagnostic_headers_forwarded_for %}\n ###\n # Inject X-Forwarded-For headers, but only once.\n ###\n\n if (req.restarts == 0) {\n if (req.http.X-Forwarded-For) {\n set req.http.X-Forwarded-For = req.http.X-Forwarded-For + \", \" + client.ip;\n } else {\n set req.http.X-Forwarded-For = client.ip;\n }\n }\n{% endif %}\n\n{% if varnish_header_sanitization_enabled %}\n ###\n # Header Sanitization\n ###\n\n{% if varnish_header_sanitization_discard_host_port %}\n set req.http.Host = regsub(req.http.Host, \":[0-9]+\", \"\");\n{% endif %}\n\n{% if varnish_header_sanitization_normalize_accept_encoding %}\n if (req.http.Accept-Encoding) {\n if (req.url ~ \"\\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$\") {\n unset req.http.Accept-Encoding;\n } elsif (req.http.Accept-Encoding ~ \"gzip\") {\n set req.http.Accept-Encoding = \"gzip\";\n } elsif (req.http.Accept-Encoding ~ \"deflate\") {\n set req.http.Accept-Encoding = \"deflate\";\n } else {\n unset req.http.Accept-Encoding;\n }\n }\n{% endif %}\n\n{% endif %}\n\n{% if varnish_cookie_sanitization_enabled %}\n ###\n # Cookie Sanitization\n ###\n set req.http.X-Cookie-Unmodified = req.http.Cookie;\n\n{% for cookie in varnish_cookie_sanitization_blacklist %}\n set req.http.Cookie = regsuball(req.http.Cookie, \"{{ cookie }}=[^;]+(; )?\", \"\");\n{% endfor %}\n\n ### General Cleanup\n set req.http.Cookie = regsuball(req.http.Cookie, \"^;\\s*\", \"\");\n if (req.http.cookie ~ \"^\\s*$\") {\n unset req.http.cookie;\n }\n set req.http.X-Cookie-Sanitized = req.http.Cookie;\n{% endif %}\n\n{% if varnish_uri_sanitization_enabled %}\n ###\n # URI Sanitization\n ###\n \n if (req.url ~ \"(\\?|&){{ varnish_uri_sanitization_regexp }}=\") {\n set req.url = regsuball(req.url, \"&{{ varnish_uri_sanitization_regexp }}=([A-z0-9_\\-\\.%25]+)\", \"\");\n set req.url = regsuball(req.url, \"\\?{{ varnish_uri_sanitization_regexp }}=([A-z0-9_\\-\\.%25]+)\", \"?\");\n set req.url = regsub(req.url, \"\\?&\", \"?\");\n set req.url = regsub(req.url, \"\\?$\", \"\");\n }\n if (req.url ~ \"\\#\") {\n set req.url = regsub(req.url, \"\\#.*$\", \"\");\n }\n{% endif %}\n\n{% if varnish_workaround_telusdotcom_browser_profile %}\n ###\n # Workaround and Diagnostics for BrowserProfile and Language\/Region Detection on TELUS.com\n ###\n\n if (req.http.Cookie ~ \"BrowserProfile\") {\n set req.http.X-BrowserProfile = regsuball(req.http.Cookie, \"(.*)BrowserProfile=([^;]*)(.*)\", \"\\2\");\n if (req.http.X-BrowserProfile ~ \"language\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.X-BrowserProfile, \"(.*)language\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n set req.http.X-Language-Found = \"YES:BrowserProfile\";\n }\n if (req.http.X-BrowserProfile ~ \"region\") {\n set req.http.X-Region = std.tolower(regsuball(regsuball(req.http.X-BrowserProfile, \"geo\\\\.\\:{(.*)\\}\", \"\"), \"(.*)region\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\"));\n set req.http.X-Region-Found = \"YES:BrowserProfile\";\n }\n if (req.http.X-BrowserProfile ~ \"geo\") {\n set req.http.X-BrowserProfile-Geolocation = regsuball(req.http.X-BrowserProfile, \"(.*)geo..:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n set req.http.X-BrowserProfile-Geolocation-Found = \"YES\";\n\n if (req.http.X-BrowserProfile-Geolocation ~ \"country\") {\n set req.http.X-BrowserProfile-Geolocation-Country = regsuball(req.http.X-BrowserProfile-Geolocation, \"(.*)country\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-BrowserProfile-Geolocation ~ \"region\") {\n set req.http.X-BrowserProfile-Geolocation-Region = regsuball(req.http.X-BrowserProfile-Geolocation, \"(.*)region\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-BrowserProfile-Geolocation ~ \"city\") {\n set req.http.X-BrowserProfile-Geolocation-City = regsuball(req.http.X-BrowserProfile-Geolocation, \"(.*)city\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n if (req.http.X-BrowserProfile-Geolocation ~ \"isp\") {\n set req.http.X-BrowserProfile-Geolocation-ISP = regsuball(req.http.X-BrowserProfile-Geolocation, \"(.*)isp\\\\.:\\\\.([^\\\\]*)(.*)\", \"\\2\");\n }\n } else {\n set req.http.X-BrowserProfile-Geolocation-Found = \"NO\";\n }\n }\n\n if (!req.http.X-Language) {\n if (req.http.Cookie ~ \"lang=\") {\n set req.http.X-Language = std.tolower(regsuball(req.http.Cookie, \"(.*)lang=([^;]*)(.*)\", \"\\2\"));\n set req.http.X-Language-Found = \"YES:lang\";\n } else {\n set req.http.X-Language = \"en\";\n set req.http.X-Language-Found = \"NO\";\n }\n }\n\n if (!req.http.X-Region) {\n if (req.http.Cookie ~ \"prov=\") {\n set req.http.X-Region = std.tolower(regsuball(req.http.Cookie, \"(.*)prov=([^;]*)(.*)\", \"\\2\"));\n set req.http.X-Region-Found = \"YES:prov\";\n } else {\n set req.http.X-Region = \"bc\";\n set req.http.X-Region-Found = \"NO\";\n }\n }\n\n if (req.url ~ \"\/(en|fr)\/\") {\n if (req.url ~ \"\/en\/\" && req.http.X-Language != \"en\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Language (Path: \/en\/) vs (Cookie: \" + req.http.X-Language + \")\";\n return(pass);\n }\n if (req.url ~ \"\/fr\/\" && req.http.X-Language != \"fr\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Language (Path: \/fr\/) vs (Cookie: \" + req.http.X-Language + \")\";\n return(pass);\n }\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Language)\";\n return(pass);\n }\n\n if (req.url ~ \"\/(ab|bc|mb|nb|nl|ns|nt|nu|on|pe|qc|sk|yt)\/\") {\n {% for province in ['ab', 'bc', 'mb', 'nb', 'nl', 'ns', 'nt', 'nu', 'on', 'pe', 'qc', 'sk', 'yt'] %}\n if (req.url ~ \"\/{{ province }}\/\" && req.http.X-Region != \"{{ province }}\") {\n set req.http.X-Passthrough-Reason = \"Unaligned Region (Path: \/{{ province }}\/) vs (Cookie: \" + req.http.X-Region + \")\";\n return(pass);\n }\n {% endfor %}\n } else {\n set req.http.X-Passthrough-Reason = \"Not Set in Path (Province)\";\n return(pass);\n }\n{% endif %}\n\n{% if varnish_cookie_sanitization_discard_from_client %}\n unset req.http.Cookie;\n{% endif %}\n}\n\n###\n# vcl_hit\n# Called when a cache lookup is successful.\n###\n# The vcl_hit subroutine may terminate with calling return() with one of the following keywords:\n#\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n# deliver\n# Deliver the object. Control passes to vcl_deliver.\n# synth(status code, reason)\n# Return the specified status code to the client and abandon the request.\n###\n\nsub vcl_hit {\n if (obj.ttl > 0s) {\n return (deliver);\n }\n{% if varnish_health_checks_enabled %}\n if (!std.healthy(req.backend_hint) && (obj.ttl + obj.grace > 0s)) {\n return (deliver);\n } else {\n return (fetch);\n }\n{% else %}\n if (obj.ttl + obj.grace > 0s) {\n return (deliver);\n }\n\n return (fetch);\n{% endif %}\n}\n\n###\n# vcl_backend_response\n# Called after the response headers has been successfully retrieved from the backend.\n###\n# The vcl_backend_response subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Possibly insert the object into the cache, then deliver it to the Control will eventually pass to vcl_deliver.\n# abandon\n# Abandon the backend request and generates an error.\n# retry\n# Retry the backend transaction. Increases the retries counter. If the number of retries is higher than max_retries Varnish emits a guru meditation error.\n###\n\nsub vcl_backend_response {\n{% if varnish_workaround_telusdotcom_browser_profile %}\n if (bereq.http.X-Language) {\n set beresp.http.X-Language = bereq.http.X-Language;\n# if (bereq.http.X-Language-Found) {\n# set beresp.http.X-Language-Found = bereq.http.X-Language-Found;\n# }\n }\n if (bereq.http.X-Region) {\n set beresp.http.X-Region = bereq.http.X-Region;\n# if (bereq.http.X-Region-Found) {\n# set beresp.http.X-Region-Found = bereq.http.X-Region-Found;\n# }\n }\n{% endif %}\n\n{% if varnish_uri_blacklist_enabled %}\n if (bereq.url ~ \"{{ varnish_uri_blacklist_regexp }}\") {\n set beresp.http.X-Cacheable = \"NO:Path in Blacklist\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n if (bereq.http.X-Passthrough-Reason) {\n{% if varnish_diagnostic_headers_passthrough_reason %}\n set beresp.http.X-Passthrough-Reason = bereq.http.X-Passthrough-Reason;\n{% endif %}\n return(deliver);\n }\n }\n{% else %}\n{% if varnish_cookie_sanitization_discard_from_server %}\n unset beresp.http.Set-Cookie;\n{% endif %}\n{% endif %}\n\n{% if varnish_diagnostic_headers_enabled %}\n if (bereq.http.Cookie) {\n set beresp.http.X-Cacheable = \"NO:Cookie in Request\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Set-Cookie) {\n set beresp.http.X-Cacheable = \"NO:Set-Cookie in Response\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.Cache-Control ~ \"private\") {\n set beresp.http.X-Cacheable = \"NO:Cache-Control=private\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.http.X-No-Cache) {\n set beresp.http.X-Cacheable = \"NO:X-No-Cache\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } elsif (beresp.ttl <= 0s) {\n set beresp.http.X-Cacheable = \"NO:Not Cacheable\";\n set beresp.uncacheable = true;\n set beresp.ttl = {{ varnish_backend_response_ttl }}s;\n return(deliver);\n } else {\n set beresp.http.X-Cacheable = \"YES\";\n }\n{% endif %}\n\n set beresp.grace = {{ varnish_grace_period }};\n}\n\n###\n# vcl_deliver\n# Called before a cached object is delivered to the client.\n###\n# The vcl_deliver subroutine may terminate with calling return() with one of the following keywords:\n#\n# deliver\n# Deliver the object to the client.\n# restart\n# Restart the transaction. Increases the restart counter. If the number of restarts is higher than max_restarts Varnish emits a guru meditation error.\n###\n\nsub vcl_deliver {\n if (obj.hits > 0) {\n set resp.http.X-Cache = \"HIT\";\n } else {\n set resp.http.X-Cache = \"MISS\";\n }\n}\n","returncode":0,"stderr":"","license":"mit","lang":"VCL"} {"commit":"e747275022c94e68b3d2b95a26916d0348e2364e","subject":"Configuration for Varnish.","message":"Configuration for Varnish.\n","repos":"cebartling\/reverse-proxy-url-rewrite-experiment,cebartling\/reverse-proxy-url-rewrite-experiment","old_file":"proxy-servers\/varnish\/default.vcl","new_file":"proxy-servers\/varnish\/default.vcl","new_contents":"","old_contents":"","returncode":128,"stderr":"fatal: unable to access 'https:\/\/github.com\/cebartling\/reverse-proxy-url-rewrite-experiment.git\/': The requested URL returned error: 403\n","license":"mit","lang":"VCL"}